From 23c40f7e8698b54e0dd497942ff4ae9f755333d2 Mon Sep 17 00:00:00 2001 From: plyatov Date: Sun, 6 May 2007 16:03:28 +0000 Subject: [PATCH] Initial import of KiCad. --- 3d-viewer/3d_aux.cpp | 269 +++ 3d-viewer/3d_canvas.cpp | 619 ++++++ 3d-viewer/3d_class.cpp | 119 ++ 3d-viewer/3d_draw.cpp | 787 ++++++++ 3d-viewer/3d_frame.cpp | 322 ++++ 3d-viewer/3d_read_mesh.cpp | 518 +++++ 3d-viewer/3d_struct.h | 136 ++ 3d-viewer/3d_toolbar.cpp | 129 ++ 3d-viewer/3d_viewer.h | 172 ++ 3d-viewer/bitmaps3d.h | 15 + 3d-viewer/bitmaps3d/axis3d.xpm | 27 + 3d-viewer/bitmaps3d/axis3d_back.xpm | 27 + 3d-viewer/bitmaps3d/axis3d_bottom.xpm | 27 + 3d-viewer/bitmaps3d/axis3d_front.xpm | 27 + 3d-viewer/bitmaps3d/axis3d_left.xpm | 27 + 3d-viewer/bitmaps3d/axis3d_right.xpm | 27 + 3d-viewer/bitmaps3d/axis3d_top.xpm | 27 + 3d-viewer/bitmaps3d/import3d.xpm | 48 + 3d-viewer/bitmaps3d/rotate+x.xpm | 32 + 3d-viewer/bitmaps3d/rotate+y.xpm | 32 + 3d-viewer/bitmaps3d/rotate+z.xpm | 32 + 3d-viewer/bitmaps3d/rotate-x.xpm | 32 + 3d-viewer/bitmaps3d/rotate-y.xpm | 32 + 3d-viewer/bitmaps3d/rotate-z.xpm | 32 + 3d-viewer/bitmaps3d/zoomoins3d.xpm | 28 + 3d-viewer/bitmaps3d/zoompage3d.xpm | 32 + 3d-viewer/bitmaps3d/zoomplus3d.xpm | 29 + 3d-viewer/bitmaps3d/zoomrefr3d.xpm | 29 + 3d-viewer/makefile.g95 | 24 + 3d-viewer/makefile.gtk | 35 + 3d-viewer/makefile.include | 28 + 3d-viewer/makefile.macosx | 35 + 3d-viewer/trackball.cpp | 324 ++++ 3d-viewer/trackball.h | 78 + bitmaps/3d.xpm | 28 + bitmaps/Add_Arc.xpm | 72 + bitmaps/Add_Circle.xpm | 60 + bitmaps/Add_Component.xpm | 91 + bitmaps/Add_Dashed_Line.xpm | 39 + bitmaps/Add_Entry.xpm | 34 + bitmaps/Add_GLabel.xpm | 78 + bitmaps/Add_Junction.xpm | 84 + bitmaps/Add_Line.xpm | 27 + bitmaps/Add_Line_Label.xpm | 48 + bitmaps/Add_Polygon.xpm | 78 + bitmaps/Add_Rectangle.xpm | 48 + bitmaps/Add_Text.xpm | 28 + bitmaps/Apply.xpm | 40 + bitmaps/Cancel.xpm | 127 ++ bitmaps/CopyBlock.xpm | 42 + bitmaps/Cursor_Shape.xpm | 77 + bitmaps/Datasheet.xpm | 46 + bitmaps/Delete_Arc.xpm | 162 ++ bitmaps/Delete_Circle.xpm | 150 ++ bitmaps/Delete_Cotation.xpm | 134 ++ bitmaps/Delete_Field.xpm | 148 ++ bitmaps/Delete_Line.xpm | 155 ++ bitmaps/Delete_Polygon.xpm | 144 ++ bitmaps/Delete_Rectangle.xpm | 138 ++ bitmaps/Delete_Segment.xpm | 135 ++ bitmaps/Delete_Text.xpm | 138 ++ bitmaps/Display_Options.xpm | 114 ++ bitmaps/Edit.xpm | 52 + bitmaps/Edit_Text.xpm | 32 + bitmaps/Exit.xpm | 87 + bitmaps/File_FootPrint.xpm | 62 + bitmaps/Fonts.xpm | 70 + bitmaps/Info.xpm | 87 + bitmaps/Mirror_H.xpm | 53 + bitmaps/Mirror_V.xpm | 55 + bitmaps/Morgan1.xpm | 103 + bitmaps/Morgan2.xpm | 101 + bitmaps/Move.xpm | 72 + bitmaps/Move_Arc.xpm | 80 + bitmaps/Move_Circle.xpm | 73 + bitmaps/Move_Field.xpm | 86 + bitmaps/Move_Line.xpm | 72 + bitmaps/Move_Polygon.xpm | 70 + bitmaps/Move_Rectangle.xpm | 64 + bitmaps/Move_Text.xpm | 70 + bitmaps/New_Library.xpm | 157 ++ bitmaps/Open_Library.xpm | 159 ++ bitmaps/Options_Arc.xpm | 73 + bitmaps/Options_Circle.xpm | 78 + bitmaps/Options_New_Pad.xpm | 77 + bitmaps/Options_Pad.xpm | 57 + bitmaps/Options_Rectangle.xpm | 68 + bitmaps/Options_Segment.xpm | 55 + bitmaps/Options_Text.xpm | 64 + bitmaps/Orient.xpm | 138 ++ bitmaps/Pad_Sketch.xpm | 27 + bitmaps/Read_SetUp.xpm | 109 ++ bitmaps/Repaint.xpm | 102 + bitmaps/Rotate+.xpm | 117 ++ bitmaps/Rotate-.xpm | 120 ++ bitmaps/Rotate_Field.xpm | 100 + bitmaps/Save_CmpStuff.xpm | 123 ++ bitmaps/Save_Library.xpm | 123 ++ bitmaps/Save_NetList.xpm | 115 ++ bitmaps/Save_Project.xpm | 87 + bitmaps/Save_SetUp.xpm | 98 + bitmaps/Text_Sketch.xpm | 26 + bitmaps/Zoom_1.xpm | 56 + bitmaps/Zoom_Center.xpm | 30 + bitmaps/Zoom_In.xpm | 66 + bitmaps/Zoom_Optimal.xpm | 107 + bitmaps/Zoom_Out.xpm | 64 + bitmaps/Zoom_Page.xpm | 92 + bitmaps/Zoom_Select.xpm | 63 + bitmaps/Zoom_Selected.xpm | 62 + bitmaps/anchor.xpm | 26 + bitmaps/annotate.xpm | 118 ++ bitmaps/auto_associe.xpm | 149 ++ bitmaps/book.xpm | 47 + bitmaps/cancel_tool.xpm | 123 ++ bitmaps/config.xpm | 79 + bitmaps/copy.xpm | 31 + bitmaps/cursor.xpm | 97 + bitmaps/cut.xpm | 30 + bitmaps/dashline.xpm | 31 + bitmaps/del_body.xpm | 39 + bitmaps/del_track.xpm | 40 + bitmaps/delete.xpm | 176 ++ bitmaps/down.xpm | 49 + bitmaps/drc.xpm | 111 ++ bitmaps/drc_off.xpm | 104 + bitmaps/eeschema.xpm | 102 + bitmaps/erc.xpm | 124 ++ bitmaps/ercerr.xpm | 20 + bitmaps/ercgreen.xpm | 20 + bitmaps/ercwarn.xpm | 20 + bitmaps/export.xpm | 67 + bitmaps/find.xpm | 34 + bitmaps/general_deletions.xpm | 182 ++ bitmaps/green.xpm | 33 + bitmaps/grid.xpm | 30 + bitmaps/grid_select.xpm | 33 + bitmaps/hammer.xpm | 29 + bitmaps/help.xpm | 130 ++ bitmaps/icon_3d.xpm | 45 + bitmaps/icon_cvpcb.xpm | 412 ++++ bitmaps/icon_eeschema.xpm | 240 +++ bitmaps/icon_gerbview.xpm | 358 ++++ bitmaps/icon_kicad.xpm | 58 + bitmaps/icon_modedit.xpm | 386 ++++ bitmaps/icon_pcbnew.xpm | 176 ++ bitmaps/import.xpm | 76 + bitmaps/jigsaw.xpm | 28 + bitmaps/kicad_icon_small.xpm | 42 + bitmaps/label.xpm | 28 + bitmaps/left.xpm | 50 + bitmaps/libedprt.xpm | 32 + bitmaps/library.xpm | 31 + bitmaps/library_update.xpm | 31 + bitmaps/libsavem.xpm | 33 + bitmaps/libview.xpm | 38 + bitmaps/mirepcb.xpm | 30 + bitmaps/modedit.xpm | 114 ++ bitmaps/modratsnest.xpm | 32 + bitmaps/module.xpm | 29 + bitmaps/netlist.xpm | 68 + bitmaps/new.xpm | 47 + bitmaps/noconn.xpm | 29 + bitmaps/open.xpm | 88 + bitmaps/pad.xpm | 30 + bitmaps/palette.xpm | 38 + bitmaps/paste.xpm | 78 + bitmaps/pcbnew.xpm | 80 + bitmaps/pin.xpm | 32 + bitmaps/plot.xpm | 36 + bitmaps/plot_HPG.xpm | 41 + bitmaps/plot_PS.xpm | 38 + bitmaps/polar.xpm | 57 + bitmaps/preference.xpm | 30 + bitmaps/print.xpm | 32 + bitmaps/ratsnest.xpm | 32 + bitmaps/red.xpm | 36 + bitmaps/redo.xpm | 31 + bitmaps/right.xpm | 49 + bitmaps/save.xpm | 107 + bitmaps/save_as.xpm | 135 ++ bitmaps/schematic.xpm | 35 + bitmaps/select_grid.xpm | 30 + bitmaps/sheetset.xpm | 31 + bitmaps/showdcode.xpm | 31 + bitmaps/showmodedge.xpm | 29 + bitmaps/showtrack.xpm | 30 + bitmaps/tools.xpm | 31 + bitmaps/transistor.xpm | 41 + bitmaps/treensel.xpm | 35 + bitmaps/treesel.xpm | 29 + bitmaps/undelete.xpm | 117 ++ bitmaps/undo.xpm | 31 + bitmaps/unit_inch.xpm | 43 + bitmaps/unit_mm.xpm | 47 + bitmaps/up.xpm | 50 + bitmaps/zoom.xpm | 29 + common/base_screen.cpp | 482 +++++ common/base_struct.cpp | 681 +++++++ common/basicframe.cpp | 274 +++ common/bitmaps.cpp | 23 + common/bitmaps/Lang_De.xpm | 24 + common/bitmaps/Lang_Default.xpm | 71 + common/bitmaps/Lang_En.xpm | 40 + common/bitmaps/Lang_Es.xpm | 24 + common/bitmaps/Lang_Fr.xpm | 24 + common/bitmaps/Lang_Hu.xpm | 24 + common/bitmaps/Lang_It.xpm | 24 + common/bitmaps/Lang_Ko.xpm | 39 + common/bitmaps/Lang_Po.xpm | 23 + common/bitmaps/Lang_Pt.xpm | 35 + common/bitmaps/Lang_Ru.xpm | 24 + common/bitmaps/Lang_Sl.xpm | 24 + common/bitmaps/Language.xpm | 111 ++ common/block_commande.cpp | 285 +++ common/common.cpp | 415 ++++ common/common_plotHPGL_functions.cpp | 206 ++ common/common_plotPS_functions.cpp | 293 +++ common/common_plot_functions.cpp | 333 ++++ common/confirm.cpp | 145 ++ common/copy_to_clipboard.cpp | 141 ++ common/dcsvg.cpp | 872 +++++++++ common/displlst.cpp | 261 +++ common/drawtxt.cpp | 413 ++++ common/eda_dde.cpp | 203 ++ common/eda_doc.cpp | 256 +++ common/edaappl.cpp | 592 ++++++ common/edamenu.cpp | 106 + common/gestfich.cpp | 571 ++++++ common/get_component_dialog.cpp | 252 +++ common/gr_basic.cpp | 1387 +++++++++++++ common/makefile.g95 | 15 + common/makefile.gtk | 27 + common/makefile.include | 87 + common/makefile.macosx | 26 + common/msgpanel.cpp | 144 ++ common/projet_config.cpp | 467 +++++ common/selcolor.cpp | 142 ++ common/string.cpp | 342 ++++ common/svg_print.cpp | 509 +++++ common/svg_print.h | 142 ++ common/svg_print.pjd | 1081 +++++++++++ common/toolbars.cpp | 36 + common/trigo.cpp | 188 ++ common/worksheet.cpp | 274 +++ common/wxwineda.cpp | 379 ++++ contrib_makefiles.txt | 309 +++ cvpcb/affiche.cpp | 19 + cvpcb/autosel.cpp | 170 ++ cvpcb/bitmaps/delete_association.xpm | 167 ++ cvpcb/bitmaps/module_filtered_list.xpm | 24 + cvpcb/bitmaps/module_full_list.xpm | 25 + cvpcb/cfg.cpp | 85 + cvpcb/cfg.h | 158 ++ cvpcb/class_cvpcb.cpp | 59 + cvpcb/cvframe.cpp | 523 +++++ cvpcb/cvpcb.cpp | 93 + cvpcb/cvpcb.h | 154 ++ cvpcb/cvpcb.ico | Bin 0 -> 3262 bytes cvpcb/cvpcb.r | 7 + cvpcb/cvpcb.rc | 2 + cvpcb/cvstruct.h | 208 ++ cvpcb/dialog_cvpcb_config.cpp | 360 ++++ cvpcb/dialog_cvpcb_config.h | 163 ++ cvpcb/dialog_cvpcb_config.rc | 1 + cvpcb/dialog_display_options.cpp | 266 +++ cvpcb/dialog_display_options.h | 125 ++ cvpcb/dialog_display_options.rc | 1 + cvpcb/displayframe.cpp | 287 +++ cvpcb/genequiv.cpp | 59 + cvpcb/genorcad.cpp | 201 ++ cvpcb/init.cpp | 236 +++ cvpcb/licence.h | 6 + cvpcb/listboxes.cpp | 472 +++++ cvpcb/listlib.cpp | 250 +++ cvpcb/loadcmp.cpp | 100 + cvpcb/makefile.g95 | 35 + cvpcb/makefile.gtk | 40 + cvpcb/makefile.include | 141 ++ cvpcb/makefile.macosx | 42 + cvpcb/memoire.cpp | 58 + cvpcb/menucfg.cpp | 325 ++++ cvpcb/options.cpp | 225 +++ cvpcb/protos.h | 131 ++ cvpcb/rdorcad.cpp | 320 +++ cvpcb/rdpcad.cpp | 274 +++ cvpcb/readschematicnetlist.cpp | 365 ++++ cvpcb/savecmp.cpp | 167 ++ cvpcb/setvisu.cpp | 66 + cvpcb/tool_cvpcb.cpp | 191 ++ cvpcb/viewlnet.cpp | 292 +++ cvpcb/viewlogi.cpp | 422 ++++ cvpcb/visumod.cpp | 176 ++ cvpcb/writenetlistpcbnew.cpp | 235 +++ eeschema/affiche.cpp | 146 ++ eeschema/annotate.cpp | 720 +++++++ eeschema/annotate_dialog.cpp | 211 ++ eeschema/annotate_dialog.h | 125 ++ eeschema/annotate_dialog.pjd | 574 ++++++ eeschema/annotate_dialog.rc | 1 + eeschema/bitmaps/AddBus2Bus.xpm | 47 + eeschema/bitmaps/AddLine2Bus.xpm | 48 + eeschema/bitmaps/Add_Bus2Bus.xpm | 57 + eeschema/bitmaps/Add_GLabel.xpm | 73 + eeschema/bitmaps/Add_Junction.xpm | 79 + eeschema/bitmaps/Add_Line2Bus.xpm | 50 + eeschema/bitmaps/Add_Line_Label.xpm | 43 + eeschema/bitmaps/Add_Power.xpm | 45 + eeschema/bitmaps/Break_Bus.xpm | 55 + eeschema/bitmaps/Break_Line.xpm | 53 + eeschema/bitmaps/Delete_Bus.xpm | 149 ++ eeschema/bitmaps/Delete_Connection.xpm | 176 ++ eeschema/bitmaps/Delete_GLabel.xpm | 152 ++ eeschema/bitmaps/Delete_Node.xpm | 151 ++ eeschema/bitmaps/Delete_Pin.xpm | 148 ++ eeschema/bitmaps/Delete_Pinsheet.xpm | 178 ++ eeschema/bitmaps/Delete_Sheet.xpm | 153 ++ eeschema/bitmaps/Edit_Comp_Ref.xpm | 91 + eeschema/bitmaps/Edit_Comp_Value.xpm | 92 + eeschema/bitmaps/Edit_Component.xpm | 99 + eeschema/bitmaps/Edit_Part.xpm | 101 + eeschema/bitmaps/Edit_Sheet.xpm | 68 + eeschema/bitmaps/Enter_Sheet.xpm | 63 + eeschema/bitmaps/GL_Change.xpm | 49 + eeschema/bitmaps/GLabel2Label.xpm | 49 + eeschema/bitmaps/GLabel2Text.xpm | 61 + eeschema/bitmaps/Hidden_Pin.xpm | 152 ++ eeschema/bitmaps/Hierarchy_Nav.xpm | 26 + eeschema/bitmaps/Hierarchy_cursor.xpm | 80 + eeschema/bitmaps/Import_GLabel.xpm | 111 ++ eeschema/bitmaps/Label2GLabel.xpm | 53 + eeschema/bitmaps/Label2Text.xpm | 54 + eeschema/bitmaps/Leave_Sheet.xpm | 77 + eeschema/bitmaps/Lib_next.xpm | 82 + eeschema/bitmaps/Lib_previous.xpm | 83 + eeschema/bitmaps/Lines90.xpm | 43 + eeschema/bitmaps/Mirror_H.xpm | 48 + eeschema/bitmaps/Mirror_V.xpm | 49 + eeschema/bitmaps/Move_GLabel.xpm | 85 + eeschema/bitmaps/Move_Pinsheet.xpm | 100 + eeschema/bitmaps/Move_Sheet.xpm | 87 + eeschema/bitmaps/Normal.xpm | 126 ++ eeschema/bitmaps/Options_Pin.xpm | 67 + eeschema/bitmaps/Options_Pinsheet.xpm | 97 + eeschema/bitmaps/Pin_Name_to.xpm | 77 + eeschema/bitmaps/Pin_Number_to.xpm | 77 + eeschema/bitmaps/Pin_Size_to.xpm | 72 + eeschema/bitmaps/Pin_to.xpm | 67 + eeschema/bitmaps/Resize_Sheet.xpm | 34 + eeschema/bitmaps/Rotate_GLabel.xpm | 110 ++ eeschema/bitmaps/Rotate_Pin.xpm | 91 + eeschema/bitmaps/add_bus.xpm | 23 + eeschema/bitmaps/add_hierar_pin.xpm | 56 + eeschema/bitmaps/add_hierar_symbol.xpm | 54 + eeschema/bitmaps/cvpcb.xpm | 66 + eeschema/bitmaps/libedit.xpm | 149 ++ eeschema/bitmaps/libedit_icon.xpm | 147 ++ eeschema/bitmaps/library_browse.xpm | 149 ++ eeschema/bitmaps/new_component.xpm | 45 + eeschema/bitmaps/part_properties.xpm | 104 + eeschema/bitmaps/pin2pin.xpm | 82 + eeschema/bitmaps/viewlibs_icon.xpm | 380 ++++ eeschema/block.cpp | 1593 +++++++++++++++ eeschema/block_libedit.cpp | 670 +++++++ eeschema/bus-wire-junction.cpp | 824 ++++++++ eeschema/busentry.cpp | 172 ++ eeschema/class_hierarchy_sheet.cpp | 173 ++ eeschema/class_screen.cpp | 300 +++ eeschema/class_screen.h | 177 ++ eeschema/class_text-label.cpp | 262 +++ eeschema/cleanup.cpp | 257 +++ eeschema/cmpclass.cpp | 249 +++ eeschema/component_class.cpp | 633 ++++++ eeschema/component_class.h | 105 + eeschema/controle.cpp | 346 ++++ eeschema/dangling_ends.cpp | 409 ++++ eeschema/database.cpp | 131 ++ eeschema/delete.cpp | 495 +++++ eeschema/delsheet.cpp | 113 ++ eeschema/dialog_build_BOM.cpp | 985 ++++++++++ eeschema/dialog_build_BOM.h | 154 ++ eeschema/dialog_build_BOM.pjd | 1378 +++++++++++++ eeschema/dialog_cmp_graphic_properties.cpp | 233 +++ eeschema/dialog_cmp_graphic_properties.h | 112 ++ eeschema/dialog_cmp_graphic_properties.pjd | 623 ++++++ eeschema/dialog_cmp_graphic_properties.rc | 1 + eeschema/dialog_create_component.cpp | 333 ++++ eeschema/dialog_create_component.h | 135 ++ eeschema/dialog_create_component.pjd | 1413 ++++++++++++++ eeschema/dialog_create_component.rc | 3 + eeschema/dialog_edit_component_in_lib.cpp | 301 +++ eeschema/dialog_edit_component_in_lib.h | 207 ++ eeschema/dialog_edit_component_in_lib.pjd | 1674 ++++++++++++++++ eeschema/dialog_edit_component_in_lib.rc | 1 + .../dialog_edit_component_in_schematic.cpp | 313 +++ eeschema/dialog_edit_component_in_schematic.h | 157 ++ .../dialog_edit_component_in_schematic.pjd | 1419 ++++++++++++++ .../dialog_edit_component_in_schematic.rc | 1 + eeschema/dialog_edit_label.cpp | 257 +++ eeschema/dialog_edit_label.h | 121 ++ eeschema/dialog_edit_label.pjd | 890 +++++++++ eeschema/dialog_edit_label.rc | 1 + eeschema/dialog_eeschema_config.cpp | 455 +++++ eeschema/dialog_eeschema_config.h | 135 ++ eeschema/dialog_eeschema_config.pjd | 1076 +++++++++++ eeschema/dialog_erc.cpp | 320 +++ eeschema/dialog_erc.h | 152 ++ eeschema/dialog_erc.pjd | 1463 ++++++++++++++ eeschema/dialog_erc.rc | 1 + eeschema/dialog_find.cpp | 238 +++ eeschema/dialog_find.h | 126 ++ eeschema/dialog_find.pjd | 847 ++++++++ eeschema/dialog_find.rc | 1 + eeschema/dialog_options.cpp | 416 ++++ eeschema/dialog_options.h | 132 ++ eeschema/dialog_options.pjd | 1262 ++++++++++++ eeschema/dialog_options.rc | 1 + eeschema/dialog_set_status.cpp | 282 +++ eeschema/dialog_set_status.h | 124 ++ eeschema/dialog_set_status.pjd | 1175 +++++++++++ eeschema/dialog_set_status.rc | 1 + eeschema/divers.cpp | 52 + eeschema/edit_component_in_lib.cpp | 1103 +++++++++++ eeschema/edit_component_in_schematic.cpp | 780 ++++++++ eeschema/edit_label.cpp | 337 ++++ eeschema/editpart.cpp | 795 ++++++++ eeschema/eeclass.cpp | 118 ++ eeschema/eeconfig.cpp | 155 ++ eeschema/eeconfig.h | 537 ++++++ eeschema/eecreate.cpp | 531 +++++ eeschema/eelayer.cpp | 473 +++++ eeschema/eelibs1.cpp | 1150 +++++++++++ eeschema/eelibs2.cpp | 974 ++++++++++ eeschema/eeload.cpp | 197 ++ eeschema/eeredraw.cpp | 657 +++++++ eeschema/eeschema.cpp | 118 ++ eeschema/eeschema.ico | Bin 0 -> 2238 bytes eeschema/eeschema.r | 7 + eeschema/eeschema.rc | 4 + eeschema/eestatus.cpp | 332 ++++ eeschema/eestring.cpp | 506 +++++ eeschema/erc.cpp | 809 ++++++++ eeschema/fieldedi.cpp | 1118 +++++++++++ eeschema/files-io.cpp | 138 ++ eeschema/find.cpp | 493 +++++ eeschema/general.h | 266 +++ eeschema/genliste.cpp | 730 +++++++ eeschema/getpart.cpp | 467 +++++ eeschema/hierarch.cpp | 376 ++++ eeschema/hotkeys.cpp | 130 ++ eeschema/lib_export.cpp | 144 ++ eeschema/libalias.cpp | 86 + eeschema/libarch.cpp | 151 ++ eeschema/libclass.cpp | 697 +++++++ eeschema/libcmp.h | 417 ++++ eeschema/libedit.cpp | 619 ++++++ eeschema/libedit_icon.ico | Bin 0 -> 3262 bytes eeschema/libedit_onleftclick.cpp | 260 +++ eeschema/libedit_onrightclick.cpp | 265 +++ eeschema/libedit_undo_redo.cpp | 80 + eeschema/libedpart.cpp | 1128 +++++++++++ eeschema/libfield.cpp | 349 ++++ eeschema/libframe.cpp | 700 +++++++ eeschema/load_one_schematic_file.cpp | 969 ++++++++++ eeschema/locate.cpp | 1095 +++++++++++ eeschema/makefile.g95 | 32 + eeschema/makefile.gtk | 47 + eeschema/makefile.include | 187 ++ eeschema/makefile.macosx | 50 + eeschema/menubar.cpp | 186 ++ eeschema/netform.cpp | 1013 ++++++++++ eeschema/netlist.cpp | 1044 ++++++++++ eeschema/netlist.h | 111 ++ eeschema/netlist_control.cpp | 549 ++++++ eeschema/onleftclick.cpp | 350 ++++ eeschema/onrightclick.cpp | 557 ++++++ eeschema/options.cpp | 285 +++ eeschema/optionsframe.cpp | 172 ++ eeschema/optionsframe.h | 89 + eeschema/pinedit-dialog.cpp | 392 ++++ eeschema/pinedit-dialog.h | 150 ++ eeschema/pinedit-dialog.pjd | 1538 +++++++++++++++ eeschema/pinedit-dialog.rc | 1 + eeschema/pinedit.cpp | 893 +++++++++ eeschema/plot.cpp | 702 +++++++ eeschema/plothpgl.cpp | 713 +++++++ eeschema/plothpgl.h | 151 ++ eeschema/plothpgl.pjd | 1446 ++++++++++++++ eeschema/plothpgl.rc | 1 + eeschema/plotps.cpp | 503 +++++ eeschema/plotps.h | 122 ++ eeschema/plotps.pjd | 842 ++++++++ eeschema/plotps.rc | 1 + eeschema/plugins/makefile.g95 | 19 + eeschema/plugins/makefile.gtk | 31 + eeschema/plugins/makefile.macosx | 21 + eeschema/plugins/netlist_form_pads-pcb.cpp | 319 +++ eeschema/priorque.cpp | 312 +++ eeschema/priorque.h | 29 + eeschema/program.h | 200 ++ eeschema/protos.h | 463 +++++ eeschema/save_schemas.cpp | 510 +++++ eeschema/savelib.cpp | 603 ++++++ eeschema/schedit.cpp | 787 ++++++++ eeschema/schematic_undo_redo.cpp | 636 ++++++ eeschema/schframe.cpp | 294 +++ eeschema/selpart.cpp | 142 ++ eeschema/sheet.cpp | 563 ++++++ eeschema/sheet.h | 124 ++ eeschema/sheet.pjd | 1037 ++++++++++ eeschema/sheet.rc | 1 + eeschema/sheetlab.cpp | 445 +++++ eeschema/symbdraw.cpp | 793 ++++++++ eeschema/symbedit.cpp | 472 +++++ eeschema/symbtext.cpp | 341 ++++ eeschema/symbtext.h | 117 ++ eeschema/symbtext.pjd | 984 ++++++++++ eeschema/symbtext.rc | 1 + eeschema/tool_lib.cpp | 274 +++ eeschema/tool_sch.cpp | 327 ++++ eeschema/tool_viewlib.cpp | 152 ++ eeschema/viewlib_frame.cpp | 321 +++ eeschema/viewlibs.cpp | 344 ++++ eeschema/viewlibs_icon.ico | Bin 0 -> 3262 bytes eeschema/wxprint.h | 89 + eeschema/xx.cpp | 139 ++ eeschema/xx.h | 95 + gerbview/affiche.cpp | 108 ++ gerbview/block.cpp | 430 +++++ gerbview/cfg.cpp | 113 ++ gerbview/cfg.h | 590 ++++++ gerbview/controle.cpp | 198 ++ gerbview/dcode.cpp | 481 +++++ gerbview/deltrack.cpp | 76 + gerbview/edit.cpp | 350 ++++ gerbview/files.cpp | 225 +++ gerbview/gerberframe.cpp | 449 +++++ gerbview/gerbview.cpp | 76 + gerbview/gerbview.h | 199 ++ gerbview/gerbview.ico | Bin 0 -> 3262 bytes gerbview/gerbview.r | 7 + gerbview/gerbview.rc | 2 + gerbview/initpcb.cpp | 218 +++ gerbview/lay2plot.cpp | 59 + gerbview/locate.cpp | 448 +++++ gerbview/makefile.g95 | 31 + gerbview/makefile.gtk | 38 + gerbview/makefile.include | 169 ++ gerbview/makefile.macosx | 42 + gerbview/onrightclick.cpp | 86 + gerbview/options.cpp | 403 ++++ gerbview/pcbplot.cpp | 31 + gerbview/pcbplot.h | 26 + gerbview/pcbtexte.cpp | 399 ++++ gerbview/protos.h | 142 ++ gerbview/readgerb.cpp | 269 +++ gerbview/reglage.cpp | 165 ++ gerbview/rs274d.cpp | 762 ++++++++ gerbview/rs274x.cpp | 461 +++++ gerbview/set_color.cpp | 344 ++++ gerbview/set_color.h | 302 +++ gerbview/struct.cpp | 93 + gerbview/tool_gerber.cpp | 285 +++ gerbview/tracepcb.cpp | 143 ++ gerbview/trpiste.cpp | 349 ++++ gerbview/undelete.cpp | 108 ++ how-to-build-kicad.txt | 125 ++ include/appl_wxstruct.h | 92 + include/base_struct.h | 258 +++ include/bitmaps.h | 180 ++ include/build_version.h | 12 + include/colors.h | 93 + include/common.h | 632 ++++++ include/dcsvg.h | 315 +++ include/drawpanel_wxstruct.h | 271 +++ include/eda_dde.h | 27 + include/fctsys.h | 79 + include/gr_basic.h | 163 ++ include/grfonte.h | 270 +++ include/id.h | 840 ++++++++ include/macros.h | 93 + include/pcbstruct.h | 357 ++++ include/plot_common.h | 70 + include/trigo.h | 1531 +++++++++++++++ include/worksheet.h | 252 +++ include/wxstruct.h | 1509 +++++++++++++++ install.txt | 161 ++ kicad/bitmaps/Browse_Files.xpm | 85 + kicad/bitmaps/Editor.xpm | 79 + kicad/bitmaps/Fonts.xpm | 65 + kicad/bitmaps/New_Project.xpm | 49 + kicad/bitmaps/Open_Project.xpm | 86 + kicad/bitmaps/Save_Project.xpm | 82 + kicad/bitmaps/unzip.xpm | 35 + kicad/bitmaps/zip.xpm | 35 + kicad/bitmaps/zip_tool.xpm | 37 + kicad/buildmnu.cpp | 309 +++ kicad/files-io.cpp | 282 +++ kicad/kicad.cpp | 92 + kicad/kicad.h | 117 ++ kicad/kicad.ico | Bin 0 -> 3262 bytes kicad/kicad.r | 7 + kicad/kicad.rc | 2 + kicad/mainframe.rc | 1 + kicad/makefile.g95 | 34 + kicad/makefile.gtk | 43 + kicad/makefile.include | 29 + kicad/makefile.macosx | 45 + kicad/mdiframe.cpp | 352 ++++ kicad/minizip/crypt.h | 132 ++ kicad/minizip/ioapi.c | 177 ++ kicad/minizip/ioapi.h | 75 + kicad/minizip/iowin32.c | 270 +++ kicad/minizip/iowin32.h | 21 + kicad/minizip/makefile | 14 + kicad/minizip/makefile.unx | 15 + kicad/minizip/makefile.win | 14 + kicad/minizip/minizip.c | 378 ++++ kicad/minizip/zip.c | 1170 +++++++++++ kicad/minizip/zip.h | 235 +++ kicad/preferences.cpp | 121 ++ kicad/prjconfig.cpp | 64 + kicad/prjconfig.h | 28 + kicad/protos.h | 2 + kicad/treeprj.cpp | 169 ++ libs.linux | 79 + libs.macosx | 13 + libs.win | 58 + make_static.linux | 17 + makefile.g95 | 16 + makefile.gtk | 15 + makefile.macosx | 16 + mybuild_wxWidgets_linux.txt | 2 + mybuild_wxWidgets_linux_unicode.txt | 2 + mybuild_wxWidgets_macosX.txt | 2 + mybuild_wxWidgets_macosX_unicode.txt | 2 + mybuild_wxWidgets_windows.txt | 2 + mybuild_wxWidgets_windows_unicode.txt | 2 + nsis_win_installer/English.nsh | 28 + nsis_win_installer/French.nsh | 31 + nsis_win_installer/Installer Docs.odt | Bin 0 -> 30110 bytes nsis_win_installer/Italian.nsh | 31 + nsis_win_installer/Portuguese.nsh | 30 + nsis_win_installer/Russian.nsh | 30 + nsis_win_installer/Spanish.nsh | 31 + nsis_win_installer/install.ico | Bin 0 -> 3638 bytes nsis_win_installer/install.nsi | 273 +++ nsis_win_installer/uninstall.ico | Bin 0 -> 3638 bytes pcbnew/affiche.cpp | 375 ++++ pcbnew/ar_protos.h | 85 + pcbnew/attribut.cpp | 90 + pcbnew/automove.cpp | 405 ++++ pcbnew/autoplac.cpp | 1157 +++++++++++ pcbnew/autorout.cpp | 212 ++ pcbnew/autorout.h | 163 ++ pcbnew/basepcbframe.cpp | 124 ++ pcbnew/bitmaps/Add_Mires.xpm | 83 + pcbnew/bitmaps/Add_Tracks.xpm | 35 + pcbnew/bitmaps/Add_Zone.xpm | 22 + pcbnew/bitmaps/Break_Line.xpm | 53 + pcbnew/bitmaps/Delete_Line.xpm | 150 ++ pcbnew/bitmaps/Delete_Module.xpm | 148 ++ pcbnew/bitmaps/Delete_Net.xpm | 147 ++ pcbnew/bitmaps/Delete_Node.xpm | 151 ++ pcbnew/bitmaps/Delete_Pad.xpm | 139 ++ pcbnew/bitmaps/Delete_Track.xpm | 134 ++ pcbnew/bitmaps/Drag_Module.xpm | 82 + pcbnew/bitmaps/Drag_Pad.xpm | 67 + pcbnew/bitmaps/Edges_Sketch.xpm | 22 + pcbnew/bitmaps/Edit_Module.xpm | 67 + pcbnew/bitmaps/Export_Module.xpm | 105 + pcbnew/bitmaps/Export_Options_Pad.xpm | 90 + pcbnew/bitmaps/Flag.xpm | 43 + pcbnew/bitmaps/Global_Options_Pad.xpm | 100 + pcbnew/bitmaps/Import_Module.xpm | 98 + pcbnew/bitmaps/Invert_Module.xpm | 50 + pcbnew/bitmaps/Load_Module_Board.xpm | 99 + pcbnew/bitmaps/Load_Module_Lib.xpm | 162 ++ pcbnew/bitmaps/Locked.xpm | 109 ++ pcbnew/bitmaps/Mode_Module.xpm | 115 ++ pcbnew/bitmaps/Mode_Track.xpm | 61 + pcbnew/bitmaps/Modul_Edit.xpm | 56 + pcbnew/bitmaps/Module_Check.xpm | 148 ++ pcbnew/bitmaps/Module_Ratsnet.xpm | 58 + pcbnew/bitmaps/Move_Field.xpm | 81 + pcbnew/bitmaps/Move_Module.xpm | 74 + pcbnew/bitmaps/Move_Pad.xpm | 63 + pcbnew/bitmaps/Move_Pin.xpm | 75 + pcbnew/bitmaps/Net_HighLight.xpm | 93 + pcbnew/bitmaps/Net_Locked.xpm | 109 ++ pcbnew/bitmaps/Net_UnLocked.xpm | 109 ++ pcbnew/bitmaps/New_FootPrint.xpm | 35 + pcbnew/bitmaps/New_Module.xpm | 92 + pcbnew/bitmaps/Options_All_Tracks&Vias.xpm | 68 + pcbnew/bitmaps/Options_All_Tracks.xpm | 58 + pcbnew/bitmaps/Options_All_Vias.xpm | 75 + pcbnew/bitmaps/Options_Module.xpm | 72 + pcbnew/bitmaps/Options_Track.xpm | 64 + pcbnew/bitmaps/Options_Tracks.xpm | 55 + pcbnew/bitmaps/Options_Vias.xpm | 63 + pcbnew/bitmaps/PcbOffset.xpm | 26 + pcbnew/bitmaps/Post_Compo.xpm | 81 + pcbnew/bitmaps/Post_Drill.xpm | 54 + pcbnew/bitmaps/Post_Module.xpm | 71 + pcbnew/bitmaps/Repl_Module_Board.xpm | 100 + pcbnew/bitmaps/Rotate_Field.xpm | 95 + pcbnew/bitmaps/Rotate_Module+.xpm | 108 ++ pcbnew/bitmaps/Rotate_Module-.xpm | 96 + pcbnew/bitmaps/Select_Layer_Pair.xpm | 94 + pcbnew/bitmaps/Select_W_Layer.xpm | 43 + pcbnew/bitmaps/Show_Zone.xpm | 90 + pcbnew/bitmaps/Swap_Layer.xpm | 25 + pcbnew/bitmaps/Track_Locked.xpm | 108 ++ pcbnew/bitmaps/Track_Sketch.xpm | 24 + pcbnew/bitmaps/Track_UnLocked.xpm | 100 + pcbnew/bitmaps/Unlocked.xpm | 107 + pcbnew/bitmaps/Width_Net.xpm | 25 + pcbnew/bitmaps/Width_Segment.xpm | 22 + pcbnew/bitmaps/Width_Track.xpm | 28 + pcbnew/bitmaps/Width_Track_Via.xpm | 29 + pcbnew/bitmaps/Width_Vias.xpm | 24 + pcbnew/bitmaps/add_cotation.xpm | 33 + pcbnew/bitmaps/general_ratsnet.xpm | 60 + pcbnew/bitmaps/local_ratsnet.xpm | 80 + pcbnew/bitmaps/module_options.xpm | 84 + pcbnew/bitmaps/mw_Add_Gap.xpm | 32 + pcbnew/bitmaps/mw_Add_Line.xpm | 25 + pcbnew/bitmaps/mw_Add_Shape.xpm | 40 + pcbnew/bitmaps/mw_Add_Stub.xpm | 33 + pcbnew/bitmaps/mw_Add_stub_arc.xpm | 74 + pcbnew/bitmaps/mw_toolbar.xpm | 86 + pcbnew/bitmaps/net_hightlight.xpm | 26 + pcbnew/bitmaps/tool_ratsnet.xpm | 72 + pcbnew/block.cpp | 1397 ++++++++++++++ pcbnew/block_module_editor.cpp | 680 +++++++ pcbnew/board.cpp | 520 +++++ pcbnew/cell.h | 75 + pcbnew/class_board.cpp | 245 +++ pcbnew/class_cotation.cpp | 383 ++++ pcbnew/class_cotation.h | 47 + pcbnew/class_edge_mod.cpp | 402 ++++ pcbnew/class_edge_mod.h | 43 + pcbnew/class_equipot.cpp | 141 ++ pcbnew/class_equipot.h | 36 + pcbnew/class_mire.cpp | 196 ++ pcbnew/class_mire.h | 37 + pcbnew/class_module.cpp | 1072 +++++++++++ pcbnew/class_module.h | 108 ++ pcbnew/class_pad.cpp | 819 ++++++++ pcbnew/class_pad.h | 85 + pcbnew/class_pcb_text.cpp | 140 ++ pcbnew/class_pcb_text.h | 30 + pcbnew/class_text_mod.cpp | 267 +++ pcbnew/class_text_mod.h | 56 + pcbnew/class_track.cpp | 562 ++++++ pcbnew/class_track.h | 93 + pcbnew/classpcb.cpp | 323 ++++ pcbnew/classtrc.cpp | 460 +++++ pcbnew/clean.cpp | 831 ++++++++ pcbnew/connect.cpp | 757 ++++++++ pcbnew/controle.cpp | 348 ++++ pcbnew/cotation.cpp | 477 +++++ pcbnew/cursors.cpp | 70 + pcbnew/deltrack.cpp | 199 ++ pcbnew/dialog_display_options.cpp | 354 ++++ pcbnew/dialog_display_options.h | 128 ++ pcbnew/dialog_display_options.rc | 1 + pcbnew/dialog_drc.cpp | 258 +++ pcbnew/dialog_drc.h | 131 ++ pcbnew/dialog_edit_mod_text.cpp | 390 ++++ pcbnew/dialog_edit_mod_text.h | 136 ++ pcbnew/dialog_edit_module.cpp | 751 ++++++++ pcbnew/dialog_edit_module.h | 97 + pcbnew/dialog_general_options.cpp | 536 ++++++ pcbnew/dialog_general_options.h | 140 ++ pcbnew/dialog_general_options.rc | 1 + pcbnew/dialog_graphic_items_options.cpp | 328 ++++ pcbnew/dialog_graphic_items_options.h | 129 ++ pcbnew/dialog_graphic_items_options.rc | 1 + pcbnew/dialog_initpcb.cpp | 225 +++ pcbnew/dialog_initpcb.h | 123 ++ pcbnew/dialog_initpcb.rc | 1 + pcbnew/dialog_module_edit.rc | 1 + pcbnew/dialog_netlist.cpp | 269 +++ pcbnew/dialog_netlist.h | 139 ++ pcbnew/dialog_netlist.rc | 1 + pcbnew/dialog_pad_edit.cpp | 420 ++++ pcbnew/dialog_pad_edit.h | 179 ++ pcbnew/dialog_pad_edit.rc | 1 + pcbnew/dialog_setup_libs.cpp | 392 ++++ pcbnew/dialog_setup_libs.h | 133 ++ pcbnew/dialog_track_options.cpp | 373 ++++ pcbnew/dialog_track_options.h | 127 ++ pcbnew/dialog_track_options.rc | 1 + pcbnew/dist.cpp | 156 ++ pcbnew/docedit.cpp | 54 + pcbnew/drag.h | 41 + pcbnew/dragsegm.cpp | 213 ++ pcbnew/drc.cpp | 1103 +++++++++++ pcbnew/dupltrac.cpp | 520 +++++ pcbnew/edgemod.cpp | 400 ++++ pcbnew/edit.cpp | 1311 +++++++++++++ pcbnew/edit_track_width.cpp | 156 ++ pcbnew/editedge.cpp | 378 ++++ pcbnew/editmod.cpp | 166 ++ pcbnew/editpads.cpp | 452 +++++ pcbnew/editrack-part2.cpp | 384 ++++ pcbnew/editrack.cpp | 744 +++++++ pcbnew/editrout.cpp | 155 ++ pcbnew/edtxtmod.cpp | 230 +++ pcbnew/edtxtmod.rc | 1 + pcbnew/essai.cpp | 151 ++ pcbnew/essai.h | 100 + pcbnew/essai.rc | 1 + pcbnew/export_gencad.cpp | 820 ++++++++ pcbnew/files.cpp | 331 ++++ pcbnew/find.cpp | 337 ++++ pcbnew/find.h | 121 ++ pcbnew/find.rc | 1 + pcbnew/gen_modules_placefile.cpp | 437 +++++ pcbnew/gen_self.h | 510 +++++ pcbnew/gendrill.cpp | 1373 +++++++++++++ pcbnew/globaleditpad.cpp | 327 ++++ pcbnew/graphpcb.cpp | 754 ++++++++ pcbnew/hotkeys.cpp | 207 ++ pcbnew/icon_modedit.ico | Bin 0 -> 3262 bytes pcbnew/icon_pcbnew.ico | Bin 0 -> 3262 bytes pcbnew/icon_w3d.ico | Bin 0 -> 766 bytes pcbnew/initpcb.cpp | 353 ++++ pcbnew/ioascii.cpp | 1115 +++++++++++ pcbnew/lay2plot.cpp | 216 +++ pcbnew/librairi.cpp | 831 ++++++++ pcbnew/loadcmp.cpp | 556 ++++++ pcbnew/locate.cpp | 1246 ++++++++++++ pcbnew/makefile.g95 | 32 + pcbnew/makefile.gtk | 39 + pcbnew/makefile.include | 287 +++ pcbnew/makefile.macosx | 39 + pcbnew/menubarmodedit.cpp | 85 + pcbnew/menubarpcb.cpp | 312 +++ pcbnew/mirepcb.cpp | 278 +++ pcbnew/modedit.cpp | 627 ++++++ pcbnew/modedit_onclick.cpp | 432 +++++ pcbnew/modedit_undo_redo.cpp | 81 + pcbnew/modeditoptions.cpp | 88 + pcbnew/moduleframe.cpp | 298 +++ pcbnew/modules.cpp | 672 +++++++ pcbnew/move-drag_pads.cpp | 378 ++++ pcbnew/move_copy_track.cpp | 645 +++++++ pcbnew/muonde.cpp | 707 +++++++ pcbnew/muwave_command.cpp | 114 ++ pcbnew/netlist.cpp | 948 +++++++++ pcbnew/onrightclick.cpp | 632 ++++++ pcbnew/pcbcfg.cpp | 168 ++ pcbnew/pcbcfg.h | 920 +++++++++ pcbnew/pcbframe.cpp | 488 +++++ pcbnew/pcbnew.cpp | 101 + pcbnew/pcbnew.h | 309 +++ pcbnew/pcbnew.r | 8 + pcbnew/pcbnew.rc | 4 + pcbnew/pcbpiste.cpp | 284 +++ pcbnew/pcbplot.cpp | 581 ++++++ pcbnew/pcbplot.h | 192 ++ pcbnew/pcbtexte.cpp | 388 ++++ pcbnew/plot_rtn.cpp | 784 ++++++++ pcbnew/plotgerb.cpp | 841 ++++++++ pcbnew/plotgerb.h | 108 ++ pcbnew/plothpgl.cpp | 869 +++++++++ pcbnew/plotps.cpp | 710 +++++++ pcbnew/protos.h | 458 +++++ pcbnew/queue.cpp | 180 ++ pcbnew/ratsnest.cpp | 1253 ++++++++++++ pcbnew/reglage.cpp | 281 +++ pcbnew/router.cpp | 568 ++++++ pcbnew/sel_layer.cpp | 277 +++ pcbnew/set_color.cpp | 792 ++++++++ pcbnew/set_grid.cpp | 238 +++ pcbnew/set_grid.h | 110 ++ pcbnew/set_grid.rc | 1 + pcbnew/solve.cpp | 998 ++++++++++ pcbnew/struct.cpp | 160 ++ pcbnew/surbrill.cpp | 117 ++ pcbnew/tool_modedit.cpp | 303 +++ pcbnew/tool_onrightclick.cpp | 83 + pcbnew/tool_pcb.cpp | 471 +++++ pcbnew/tr_modif.cpp | 212 ++ pcbnew/tracemod.cpp | 89 + pcbnew/tracepcb.cpp | 192 ++ pcbnew/track.cpp | 401 ++++ pcbnew/trpiste.cpp | 160 ++ pcbnew/undelete.cpp | 144 ++ pcbnew/via_edit.cpp | 104 + pcbnew/work.cpp | 207 ++ pcbnew/xchgmod.cpp | 628 ++++++ pcbnew/zones.cpp | 1264 ++++++++++++ pcbnew/zones.h | 126 ++ pcbnew/zones.rc | 1 + share/dialog_print.cpp | 339 ++++ share/dialog_print.h | 160 ++ share/dialog_print.pjd | 1472 ++++++++++++++ share/drawframe.cpp | 826 ++++++++ share/drawpanel.cpp | 933 +++++++++ share/gr_basic.cpp | 1402 ++++++++++++++ share/infospgm.cpp | 63 + share/selcolor.cpp | 162 ++ share/setpage.cpp | 498 +++++ share/setpage.h | 160 ++ share/setpage.pjd | 1714 +++++++++++++++++ share/svg_print.cpp | 512 +++++ share/svg_print.h | 142 ++ share/svg_print.pjd | 1067 ++++++++++ share/worksheet.cpp | 281 +++ share/wxprint.cpp | 745 +++++++ share/zoom.cpp | 445 +++++ 914 files changed, 210683 insertions(+) create mode 100644 3d-viewer/3d_aux.cpp create mode 100644 3d-viewer/3d_canvas.cpp create mode 100644 3d-viewer/3d_class.cpp create mode 100644 3d-viewer/3d_draw.cpp create mode 100644 3d-viewer/3d_frame.cpp create mode 100644 3d-viewer/3d_read_mesh.cpp create mode 100644 3d-viewer/3d_struct.h create mode 100644 3d-viewer/3d_toolbar.cpp create mode 100644 3d-viewer/3d_viewer.h create mode 100644 3d-viewer/bitmaps3d.h create mode 100644 3d-viewer/bitmaps3d/axis3d.xpm create mode 100644 3d-viewer/bitmaps3d/axis3d_back.xpm create mode 100644 3d-viewer/bitmaps3d/axis3d_bottom.xpm create mode 100644 3d-viewer/bitmaps3d/axis3d_front.xpm create mode 100644 3d-viewer/bitmaps3d/axis3d_left.xpm create mode 100644 3d-viewer/bitmaps3d/axis3d_right.xpm create mode 100644 3d-viewer/bitmaps3d/axis3d_top.xpm create mode 100644 3d-viewer/bitmaps3d/import3d.xpm create mode 100644 3d-viewer/bitmaps3d/rotate+x.xpm create mode 100644 3d-viewer/bitmaps3d/rotate+y.xpm create mode 100644 3d-viewer/bitmaps3d/rotate+z.xpm create mode 100644 3d-viewer/bitmaps3d/rotate-x.xpm create mode 100644 3d-viewer/bitmaps3d/rotate-y.xpm create mode 100644 3d-viewer/bitmaps3d/rotate-z.xpm create mode 100644 3d-viewer/bitmaps3d/zoomoins3d.xpm create mode 100644 3d-viewer/bitmaps3d/zoompage3d.xpm create mode 100644 3d-viewer/bitmaps3d/zoomplus3d.xpm create mode 100644 3d-viewer/bitmaps3d/zoomrefr3d.xpm create mode 100644 3d-viewer/makefile.g95 create mode 100644 3d-viewer/makefile.gtk create mode 100644 3d-viewer/makefile.include create mode 100644 3d-viewer/makefile.macosx create mode 100644 3d-viewer/trackball.cpp create mode 100644 3d-viewer/trackball.h create mode 100644 bitmaps/3d.xpm create mode 100644 bitmaps/Add_Arc.xpm create mode 100644 bitmaps/Add_Circle.xpm create mode 100644 bitmaps/Add_Component.xpm create mode 100644 bitmaps/Add_Dashed_Line.xpm create mode 100644 bitmaps/Add_Entry.xpm create mode 100644 bitmaps/Add_GLabel.xpm create mode 100644 bitmaps/Add_Junction.xpm create mode 100644 bitmaps/Add_Line.xpm create mode 100644 bitmaps/Add_Line_Label.xpm create mode 100644 bitmaps/Add_Polygon.xpm create mode 100644 bitmaps/Add_Rectangle.xpm create mode 100644 bitmaps/Add_Text.xpm create mode 100644 bitmaps/Apply.xpm create mode 100644 bitmaps/Cancel.xpm create mode 100644 bitmaps/CopyBlock.xpm create mode 100644 bitmaps/Cursor_Shape.xpm create mode 100644 bitmaps/Datasheet.xpm create mode 100644 bitmaps/Delete_Arc.xpm create mode 100644 bitmaps/Delete_Circle.xpm create mode 100644 bitmaps/Delete_Cotation.xpm create mode 100644 bitmaps/Delete_Field.xpm create mode 100644 bitmaps/Delete_Line.xpm create mode 100644 bitmaps/Delete_Polygon.xpm create mode 100644 bitmaps/Delete_Rectangle.xpm create mode 100644 bitmaps/Delete_Segment.xpm create mode 100644 bitmaps/Delete_Text.xpm create mode 100644 bitmaps/Display_Options.xpm create mode 100644 bitmaps/Edit.xpm create mode 100644 bitmaps/Edit_Text.xpm create mode 100644 bitmaps/Exit.xpm create mode 100644 bitmaps/File_FootPrint.xpm create mode 100644 bitmaps/Fonts.xpm create mode 100644 bitmaps/Info.xpm create mode 100644 bitmaps/Mirror_H.xpm create mode 100644 bitmaps/Mirror_V.xpm create mode 100644 bitmaps/Morgan1.xpm create mode 100644 bitmaps/Morgan2.xpm create mode 100644 bitmaps/Move.xpm create mode 100644 bitmaps/Move_Arc.xpm create mode 100644 bitmaps/Move_Circle.xpm create mode 100644 bitmaps/Move_Field.xpm create mode 100644 bitmaps/Move_Line.xpm create mode 100644 bitmaps/Move_Polygon.xpm create mode 100644 bitmaps/Move_Rectangle.xpm create mode 100644 bitmaps/Move_Text.xpm create mode 100644 bitmaps/New_Library.xpm create mode 100644 bitmaps/Open_Library.xpm create mode 100644 bitmaps/Options_Arc.xpm create mode 100644 bitmaps/Options_Circle.xpm create mode 100644 bitmaps/Options_New_Pad.xpm create mode 100644 bitmaps/Options_Pad.xpm create mode 100644 bitmaps/Options_Rectangle.xpm create mode 100644 bitmaps/Options_Segment.xpm create mode 100644 bitmaps/Options_Text.xpm create mode 100644 bitmaps/Orient.xpm create mode 100644 bitmaps/Pad_Sketch.xpm create mode 100644 bitmaps/Read_SetUp.xpm create mode 100644 bitmaps/Repaint.xpm create mode 100644 bitmaps/Rotate+.xpm create mode 100644 bitmaps/Rotate-.xpm create mode 100644 bitmaps/Rotate_Field.xpm create mode 100644 bitmaps/Save_CmpStuff.xpm create mode 100644 bitmaps/Save_Library.xpm create mode 100644 bitmaps/Save_NetList.xpm create mode 100644 bitmaps/Save_Project.xpm create mode 100644 bitmaps/Save_SetUp.xpm create mode 100644 bitmaps/Text_Sketch.xpm create mode 100644 bitmaps/Zoom_1.xpm create mode 100644 bitmaps/Zoom_Center.xpm create mode 100644 bitmaps/Zoom_In.xpm create mode 100644 bitmaps/Zoom_Optimal.xpm create mode 100644 bitmaps/Zoom_Out.xpm create mode 100644 bitmaps/Zoom_Page.xpm create mode 100644 bitmaps/Zoom_Select.xpm create mode 100644 bitmaps/Zoom_Selected.xpm create mode 100644 bitmaps/anchor.xpm create mode 100644 bitmaps/annotate.xpm create mode 100644 bitmaps/auto_associe.xpm create mode 100644 bitmaps/book.xpm create mode 100644 bitmaps/cancel_tool.xpm create mode 100644 bitmaps/config.xpm create mode 100644 bitmaps/copy.xpm create mode 100644 bitmaps/cursor.xpm create mode 100644 bitmaps/cut.xpm create mode 100644 bitmaps/dashline.xpm create mode 100644 bitmaps/del_body.xpm create mode 100644 bitmaps/del_track.xpm create mode 100644 bitmaps/delete.xpm create mode 100644 bitmaps/down.xpm create mode 100644 bitmaps/drc.xpm create mode 100644 bitmaps/drc_off.xpm create mode 100644 bitmaps/eeschema.xpm create mode 100644 bitmaps/erc.xpm create mode 100644 bitmaps/ercerr.xpm create mode 100644 bitmaps/ercgreen.xpm create mode 100644 bitmaps/ercwarn.xpm create mode 100644 bitmaps/export.xpm create mode 100644 bitmaps/find.xpm create mode 100644 bitmaps/general_deletions.xpm create mode 100644 bitmaps/green.xpm create mode 100644 bitmaps/grid.xpm create mode 100644 bitmaps/grid_select.xpm create mode 100644 bitmaps/hammer.xpm create mode 100644 bitmaps/help.xpm create mode 100644 bitmaps/icon_3d.xpm create mode 100644 bitmaps/icon_cvpcb.xpm create mode 100644 bitmaps/icon_eeschema.xpm create mode 100644 bitmaps/icon_gerbview.xpm create mode 100644 bitmaps/icon_kicad.xpm create mode 100644 bitmaps/icon_modedit.xpm create mode 100644 bitmaps/icon_pcbnew.xpm create mode 100644 bitmaps/import.xpm create mode 100644 bitmaps/jigsaw.xpm create mode 100644 bitmaps/kicad_icon_small.xpm create mode 100644 bitmaps/label.xpm create mode 100644 bitmaps/left.xpm create mode 100644 bitmaps/libedprt.xpm create mode 100644 bitmaps/library.xpm create mode 100644 bitmaps/library_update.xpm create mode 100644 bitmaps/libsavem.xpm create mode 100644 bitmaps/libview.xpm create mode 100644 bitmaps/mirepcb.xpm create mode 100644 bitmaps/modedit.xpm create mode 100644 bitmaps/modratsnest.xpm create mode 100644 bitmaps/module.xpm create mode 100644 bitmaps/netlist.xpm create mode 100644 bitmaps/new.xpm create mode 100644 bitmaps/noconn.xpm create mode 100644 bitmaps/open.xpm create mode 100644 bitmaps/pad.xpm create mode 100644 bitmaps/palette.xpm create mode 100644 bitmaps/paste.xpm create mode 100644 bitmaps/pcbnew.xpm create mode 100644 bitmaps/pin.xpm create mode 100644 bitmaps/plot.xpm create mode 100644 bitmaps/plot_HPG.xpm create mode 100644 bitmaps/plot_PS.xpm create mode 100644 bitmaps/polar.xpm create mode 100644 bitmaps/preference.xpm create mode 100644 bitmaps/print.xpm create mode 100644 bitmaps/ratsnest.xpm create mode 100644 bitmaps/red.xpm create mode 100644 bitmaps/redo.xpm create mode 100644 bitmaps/right.xpm create mode 100644 bitmaps/save.xpm create mode 100644 bitmaps/save_as.xpm create mode 100644 bitmaps/schematic.xpm create mode 100644 bitmaps/select_grid.xpm create mode 100644 bitmaps/sheetset.xpm create mode 100644 bitmaps/showdcode.xpm create mode 100644 bitmaps/showmodedge.xpm create mode 100644 bitmaps/showtrack.xpm create mode 100644 bitmaps/tools.xpm create mode 100644 bitmaps/transistor.xpm create mode 100644 bitmaps/treensel.xpm create mode 100644 bitmaps/treesel.xpm create mode 100644 bitmaps/undelete.xpm create mode 100644 bitmaps/undo.xpm create mode 100644 bitmaps/unit_inch.xpm create mode 100644 bitmaps/unit_mm.xpm create mode 100644 bitmaps/up.xpm create mode 100644 bitmaps/zoom.xpm create mode 100644 common/base_screen.cpp create mode 100644 common/base_struct.cpp create mode 100644 common/basicframe.cpp create mode 100644 common/bitmaps.cpp create mode 100644 common/bitmaps/Lang_De.xpm create mode 100644 common/bitmaps/Lang_Default.xpm create mode 100644 common/bitmaps/Lang_En.xpm create mode 100644 common/bitmaps/Lang_Es.xpm create mode 100644 common/bitmaps/Lang_Fr.xpm create mode 100644 common/bitmaps/Lang_Hu.xpm create mode 100644 common/bitmaps/Lang_It.xpm create mode 100644 common/bitmaps/Lang_Ko.xpm create mode 100644 common/bitmaps/Lang_Po.xpm create mode 100644 common/bitmaps/Lang_Pt.xpm create mode 100644 common/bitmaps/Lang_Ru.xpm create mode 100644 common/bitmaps/Lang_Sl.xpm create mode 100644 common/bitmaps/Language.xpm create mode 100644 common/block_commande.cpp create mode 100644 common/common.cpp create mode 100644 common/common_plotHPGL_functions.cpp create mode 100644 common/common_plotPS_functions.cpp create mode 100644 common/common_plot_functions.cpp create mode 100644 common/confirm.cpp create mode 100644 common/copy_to_clipboard.cpp create mode 100644 common/dcsvg.cpp create mode 100644 common/displlst.cpp create mode 100644 common/drawtxt.cpp create mode 100644 common/eda_dde.cpp create mode 100644 common/eda_doc.cpp create mode 100644 common/edaappl.cpp create mode 100644 common/edamenu.cpp create mode 100644 common/gestfich.cpp create mode 100644 common/get_component_dialog.cpp create mode 100644 common/gr_basic.cpp create mode 100644 common/makefile.g95 create mode 100644 common/makefile.gtk create mode 100644 common/makefile.include create mode 100644 common/makefile.macosx create mode 100644 common/msgpanel.cpp create mode 100644 common/projet_config.cpp create mode 100644 common/selcolor.cpp create mode 100644 common/string.cpp create mode 100644 common/svg_print.cpp create mode 100644 common/svg_print.h create mode 100644 common/svg_print.pjd create mode 100644 common/toolbars.cpp create mode 100644 common/trigo.cpp create mode 100644 common/worksheet.cpp create mode 100644 common/wxwineda.cpp create mode 100644 contrib_makefiles.txt create mode 100644 cvpcb/affiche.cpp create mode 100644 cvpcb/autosel.cpp create mode 100644 cvpcb/bitmaps/delete_association.xpm create mode 100644 cvpcb/bitmaps/module_filtered_list.xpm create mode 100644 cvpcb/bitmaps/module_full_list.xpm create mode 100644 cvpcb/cfg.cpp create mode 100644 cvpcb/cfg.h create mode 100644 cvpcb/class_cvpcb.cpp create mode 100644 cvpcb/cvframe.cpp create mode 100644 cvpcb/cvpcb.cpp create mode 100644 cvpcb/cvpcb.h create mode 100644 cvpcb/cvpcb.ico create mode 100644 cvpcb/cvpcb.r create mode 100644 cvpcb/cvpcb.rc create mode 100644 cvpcb/cvstruct.h create mode 100644 cvpcb/dialog_cvpcb_config.cpp create mode 100644 cvpcb/dialog_cvpcb_config.h create mode 100644 cvpcb/dialog_cvpcb_config.rc create mode 100644 cvpcb/dialog_display_options.cpp create mode 100644 cvpcb/dialog_display_options.h create mode 100644 cvpcb/dialog_display_options.rc create mode 100644 cvpcb/displayframe.cpp create mode 100644 cvpcb/genequiv.cpp create mode 100644 cvpcb/genorcad.cpp create mode 100644 cvpcb/init.cpp create mode 100644 cvpcb/licence.h create mode 100644 cvpcb/listboxes.cpp create mode 100644 cvpcb/listlib.cpp create mode 100644 cvpcb/loadcmp.cpp create mode 100644 cvpcb/makefile.g95 create mode 100644 cvpcb/makefile.gtk create mode 100644 cvpcb/makefile.include create mode 100644 cvpcb/makefile.macosx create mode 100644 cvpcb/memoire.cpp create mode 100644 cvpcb/menucfg.cpp create mode 100644 cvpcb/options.cpp create mode 100644 cvpcb/protos.h create mode 100644 cvpcb/rdorcad.cpp create mode 100644 cvpcb/rdpcad.cpp create mode 100644 cvpcb/readschematicnetlist.cpp create mode 100644 cvpcb/savecmp.cpp create mode 100644 cvpcb/setvisu.cpp create mode 100644 cvpcb/tool_cvpcb.cpp create mode 100644 cvpcb/viewlnet.cpp create mode 100644 cvpcb/viewlogi.cpp create mode 100644 cvpcb/visumod.cpp create mode 100644 cvpcb/writenetlistpcbnew.cpp create mode 100644 eeschema/affiche.cpp create mode 100644 eeschema/annotate.cpp create mode 100644 eeschema/annotate_dialog.cpp create mode 100644 eeschema/annotate_dialog.h create mode 100644 eeschema/annotate_dialog.pjd create mode 100644 eeschema/annotate_dialog.rc create mode 100644 eeschema/bitmaps/AddBus2Bus.xpm create mode 100644 eeschema/bitmaps/AddLine2Bus.xpm create mode 100644 eeschema/bitmaps/Add_Bus2Bus.xpm create mode 100644 eeschema/bitmaps/Add_GLabel.xpm create mode 100644 eeschema/bitmaps/Add_Junction.xpm create mode 100644 eeschema/bitmaps/Add_Line2Bus.xpm create mode 100644 eeschema/bitmaps/Add_Line_Label.xpm create mode 100644 eeschema/bitmaps/Add_Power.xpm create mode 100644 eeschema/bitmaps/Break_Bus.xpm create mode 100644 eeschema/bitmaps/Break_Line.xpm create mode 100644 eeschema/bitmaps/Delete_Bus.xpm create mode 100644 eeschema/bitmaps/Delete_Connection.xpm create mode 100644 eeschema/bitmaps/Delete_GLabel.xpm create mode 100644 eeschema/bitmaps/Delete_Node.xpm create mode 100644 eeschema/bitmaps/Delete_Pin.xpm create mode 100644 eeschema/bitmaps/Delete_Pinsheet.xpm create mode 100644 eeschema/bitmaps/Delete_Sheet.xpm create mode 100644 eeschema/bitmaps/Edit_Comp_Ref.xpm create mode 100644 eeschema/bitmaps/Edit_Comp_Value.xpm create mode 100644 eeschema/bitmaps/Edit_Component.xpm create mode 100644 eeschema/bitmaps/Edit_Part.xpm create mode 100644 eeschema/bitmaps/Edit_Sheet.xpm create mode 100644 eeschema/bitmaps/Enter_Sheet.xpm create mode 100644 eeschema/bitmaps/GL_Change.xpm create mode 100644 eeschema/bitmaps/GLabel2Label.xpm create mode 100644 eeschema/bitmaps/GLabel2Text.xpm create mode 100644 eeschema/bitmaps/Hidden_Pin.xpm create mode 100644 eeschema/bitmaps/Hierarchy_Nav.xpm create mode 100644 eeschema/bitmaps/Hierarchy_cursor.xpm create mode 100644 eeschema/bitmaps/Import_GLabel.xpm create mode 100644 eeschema/bitmaps/Label2GLabel.xpm create mode 100644 eeschema/bitmaps/Label2Text.xpm create mode 100644 eeschema/bitmaps/Leave_Sheet.xpm create mode 100644 eeschema/bitmaps/Lib_next.xpm create mode 100644 eeschema/bitmaps/Lib_previous.xpm create mode 100644 eeschema/bitmaps/Lines90.xpm create mode 100644 eeschema/bitmaps/Mirror_H.xpm create mode 100644 eeschema/bitmaps/Mirror_V.xpm create mode 100644 eeschema/bitmaps/Move_GLabel.xpm create mode 100644 eeschema/bitmaps/Move_Pinsheet.xpm create mode 100644 eeschema/bitmaps/Move_Sheet.xpm create mode 100644 eeschema/bitmaps/Normal.xpm create mode 100644 eeschema/bitmaps/Options_Pin.xpm create mode 100644 eeschema/bitmaps/Options_Pinsheet.xpm create mode 100644 eeschema/bitmaps/Pin_Name_to.xpm create mode 100644 eeschema/bitmaps/Pin_Number_to.xpm create mode 100644 eeschema/bitmaps/Pin_Size_to.xpm create mode 100644 eeschema/bitmaps/Pin_to.xpm create mode 100644 eeschema/bitmaps/Resize_Sheet.xpm create mode 100644 eeschema/bitmaps/Rotate_GLabel.xpm create mode 100644 eeschema/bitmaps/Rotate_Pin.xpm create mode 100644 eeschema/bitmaps/add_bus.xpm create mode 100644 eeschema/bitmaps/add_hierar_pin.xpm create mode 100644 eeschema/bitmaps/add_hierar_symbol.xpm create mode 100644 eeschema/bitmaps/cvpcb.xpm create mode 100644 eeschema/bitmaps/libedit.xpm create mode 100644 eeschema/bitmaps/libedit_icon.xpm create mode 100644 eeschema/bitmaps/library_browse.xpm create mode 100644 eeschema/bitmaps/new_component.xpm create mode 100644 eeschema/bitmaps/part_properties.xpm create mode 100644 eeschema/bitmaps/pin2pin.xpm create mode 100644 eeschema/bitmaps/viewlibs_icon.xpm create mode 100644 eeschema/block.cpp create mode 100644 eeschema/block_libedit.cpp create mode 100644 eeschema/bus-wire-junction.cpp create mode 100644 eeschema/busentry.cpp create mode 100644 eeschema/class_hierarchy_sheet.cpp create mode 100644 eeschema/class_screen.cpp create mode 100644 eeschema/class_screen.h create mode 100644 eeschema/class_text-label.cpp create mode 100644 eeschema/cleanup.cpp create mode 100644 eeschema/cmpclass.cpp create mode 100644 eeschema/component_class.cpp create mode 100644 eeschema/component_class.h create mode 100644 eeschema/controle.cpp create mode 100644 eeschema/dangling_ends.cpp create mode 100644 eeschema/database.cpp create mode 100644 eeschema/delete.cpp create mode 100644 eeschema/delsheet.cpp create mode 100644 eeschema/dialog_build_BOM.cpp create mode 100644 eeschema/dialog_build_BOM.h create mode 100644 eeschema/dialog_build_BOM.pjd create mode 100644 eeschema/dialog_cmp_graphic_properties.cpp create mode 100644 eeschema/dialog_cmp_graphic_properties.h create mode 100644 eeschema/dialog_cmp_graphic_properties.pjd create mode 100644 eeschema/dialog_cmp_graphic_properties.rc create mode 100644 eeschema/dialog_create_component.cpp create mode 100644 eeschema/dialog_create_component.h create mode 100644 eeschema/dialog_create_component.pjd create mode 100644 eeschema/dialog_create_component.rc create mode 100644 eeschema/dialog_edit_component_in_lib.cpp create mode 100644 eeschema/dialog_edit_component_in_lib.h create mode 100644 eeschema/dialog_edit_component_in_lib.pjd create mode 100644 eeschema/dialog_edit_component_in_lib.rc create mode 100644 eeschema/dialog_edit_component_in_schematic.cpp create mode 100644 eeschema/dialog_edit_component_in_schematic.h create mode 100644 eeschema/dialog_edit_component_in_schematic.pjd create mode 100644 eeschema/dialog_edit_component_in_schematic.rc create mode 100644 eeschema/dialog_edit_label.cpp create mode 100644 eeschema/dialog_edit_label.h create mode 100644 eeschema/dialog_edit_label.pjd create mode 100644 eeschema/dialog_edit_label.rc create mode 100644 eeschema/dialog_eeschema_config.cpp create mode 100644 eeschema/dialog_eeschema_config.h create mode 100644 eeschema/dialog_eeschema_config.pjd create mode 100644 eeschema/dialog_erc.cpp create mode 100644 eeschema/dialog_erc.h create mode 100644 eeschema/dialog_erc.pjd create mode 100644 eeschema/dialog_erc.rc create mode 100644 eeschema/dialog_find.cpp create mode 100644 eeschema/dialog_find.h create mode 100644 eeschema/dialog_find.pjd create mode 100644 eeschema/dialog_find.rc create mode 100644 eeschema/dialog_options.cpp create mode 100644 eeschema/dialog_options.h create mode 100644 eeschema/dialog_options.pjd create mode 100644 eeschema/dialog_options.rc create mode 100644 eeschema/dialog_set_status.cpp create mode 100644 eeschema/dialog_set_status.h create mode 100644 eeschema/dialog_set_status.pjd create mode 100644 eeschema/dialog_set_status.rc create mode 100644 eeschema/divers.cpp create mode 100644 eeschema/edit_component_in_lib.cpp create mode 100644 eeschema/edit_component_in_schematic.cpp create mode 100644 eeschema/edit_label.cpp create mode 100644 eeschema/editpart.cpp create mode 100644 eeschema/eeclass.cpp create mode 100644 eeschema/eeconfig.cpp create mode 100644 eeschema/eeconfig.h create mode 100644 eeschema/eecreate.cpp create mode 100644 eeschema/eelayer.cpp create mode 100644 eeschema/eelibs1.cpp create mode 100644 eeschema/eelibs2.cpp create mode 100644 eeschema/eeload.cpp create mode 100644 eeschema/eeredraw.cpp create mode 100644 eeschema/eeschema.cpp create mode 100644 eeschema/eeschema.ico create mode 100644 eeschema/eeschema.r create mode 100644 eeschema/eeschema.rc create mode 100644 eeschema/eestatus.cpp create mode 100644 eeschema/eestring.cpp create mode 100644 eeschema/erc.cpp create mode 100644 eeschema/fieldedi.cpp create mode 100644 eeschema/files-io.cpp create mode 100644 eeschema/find.cpp create mode 100644 eeschema/general.h create mode 100644 eeschema/genliste.cpp create mode 100644 eeschema/getpart.cpp create mode 100644 eeschema/hierarch.cpp create mode 100644 eeschema/hotkeys.cpp create mode 100644 eeschema/lib_export.cpp create mode 100644 eeschema/libalias.cpp create mode 100644 eeschema/libarch.cpp create mode 100644 eeschema/libclass.cpp create mode 100644 eeschema/libcmp.h create mode 100644 eeschema/libedit.cpp create mode 100644 eeschema/libedit_icon.ico create mode 100644 eeschema/libedit_onleftclick.cpp create mode 100644 eeschema/libedit_onrightclick.cpp create mode 100644 eeschema/libedit_undo_redo.cpp create mode 100644 eeschema/libedpart.cpp create mode 100644 eeschema/libfield.cpp create mode 100644 eeschema/libframe.cpp create mode 100644 eeschema/load_one_schematic_file.cpp create mode 100644 eeschema/locate.cpp create mode 100644 eeschema/makefile.g95 create mode 100644 eeschema/makefile.gtk create mode 100644 eeschema/makefile.include create mode 100644 eeschema/makefile.macosx create mode 100644 eeschema/menubar.cpp create mode 100644 eeschema/netform.cpp create mode 100644 eeschema/netlist.cpp create mode 100644 eeschema/netlist.h create mode 100644 eeschema/netlist_control.cpp create mode 100644 eeschema/onleftclick.cpp create mode 100644 eeschema/onrightclick.cpp create mode 100644 eeschema/options.cpp create mode 100644 eeschema/optionsframe.cpp create mode 100644 eeschema/optionsframe.h create mode 100644 eeschema/pinedit-dialog.cpp create mode 100644 eeschema/pinedit-dialog.h create mode 100644 eeschema/pinedit-dialog.pjd create mode 100644 eeschema/pinedit-dialog.rc create mode 100644 eeschema/pinedit.cpp create mode 100644 eeschema/plot.cpp create mode 100644 eeschema/plothpgl.cpp create mode 100644 eeschema/plothpgl.h create mode 100644 eeschema/plothpgl.pjd create mode 100644 eeschema/plothpgl.rc create mode 100644 eeschema/plotps.cpp create mode 100644 eeschema/plotps.h create mode 100644 eeschema/plotps.pjd create mode 100644 eeschema/plotps.rc create mode 100644 eeschema/plugins/makefile.g95 create mode 100644 eeschema/plugins/makefile.gtk create mode 100644 eeschema/plugins/makefile.macosx create mode 100644 eeschema/plugins/netlist_form_pads-pcb.cpp create mode 100644 eeschema/priorque.cpp create mode 100644 eeschema/priorque.h create mode 100644 eeschema/program.h create mode 100644 eeschema/protos.h create mode 100644 eeschema/save_schemas.cpp create mode 100644 eeschema/savelib.cpp create mode 100644 eeschema/schedit.cpp create mode 100644 eeschema/schematic_undo_redo.cpp create mode 100644 eeschema/schframe.cpp create mode 100644 eeschema/selpart.cpp create mode 100644 eeschema/sheet.cpp create mode 100644 eeschema/sheet.h create mode 100644 eeschema/sheet.pjd create mode 100644 eeschema/sheet.rc create mode 100644 eeschema/sheetlab.cpp create mode 100644 eeschema/symbdraw.cpp create mode 100644 eeschema/symbedit.cpp create mode 100644 eeschema/symbtext.cpp create mode 100644 eeschema/symbtext.h create mode 100644 eeschema/symbtext.pjd create mode 100644 eeschema/symbtext.rc create mode 100644 eeschema/tool_lib.cpp create mode 100644 eeschema/tool_sch.cpp create mode 100644 eeschema/tool_viewlib.cpp create mode 100644 eeschema/viewlib_frame.cpp create mode 100644 eeschema/viewlibs.cpp create mode 100644 eeschema/viewlibs_icon.ico create mode 100644 eeschema/wxprint.h create mode 100644 eeschema/xx.cpp create mode 100644 eeschema/xx.h create mode 100644 gerbview/affiche.cpp create mode 100644 gerbview/block.cpp create mode 100644 gerbview/cfg.cpp create mode 100644 gerbview/cfg.h create mode 100644 gerbview/controle.cpp create mode 100644 gerbview/dcode.cpp create mode 100644 gerbview/deltrack.cpp create mode 100644 gerbview/edit.cpp create mode 100644 gerbview/files.cpp create mode 100644 gerbview/gerberframe.cpp create mode 100644 gerbview/gerbview.cpp create mode 100644 gerbview/gerbview.h create mode 100644 gerbview/gerbview.ico create mode 100644 gerbview/gerbview.r create mode 100644 gerbview/gerbview.rc create mode 100644 gerbview/initpcb.cpp create mode 100644 gerbview/lay2plot.cpp create mode 100644 gerbview/locate.cpp create mode 100644 gerbview/makefile.g95 create mode 100644 gerbview/makefile.gtk create mode 100644 gerbview/makefile.include create mode 100644 gerbview/makefile.macosx create mode 100644 gerbview/onrightclick.cpp create mode 100644 gerbview/options.cpp create mode 100644 gerbview/pcbplot.cpp create mode 100644 gerbview/pcbplot.h create mode 100644 gerbview/pcbtexte.cpp create mode 100644 gerbview/protos.h create mode 100644 gerbview/readgerb.cpp create mode 100644 gerbview/reglage.cpp create mode 100644 gerbview/rs274d.cpp create mode 100644 gerbview/rs274x.cpp create mode 100644 gerbview/set_color.cpp create mode 100644 gerbview/set_color.h create mode 100644 gerbview/struct.cpp create mode 100644 gerbview/tool_gerber.cpp create mode 100644 gerbview/tracepcb.cpp create mode 100644 gerbview/trpiste.cpp create mode 100644 gerbview/undelete.cpp create mode 100644 how-to-build-kicad.txt create mode 100644 include/appl_wxstruct.h create mode 100644 include/base_struct.h create mode 100644 include/bitmaps.h create mode 100644 include/build_version.h create mode 100644 include/colors.h create mode 100644 include/common.h create mode 100644 include/dcsvg.h create mode 100644 include/drawpanel_wxstruct.h create mode 100644 include/eda_dde.h create mode 100644 include/fctsys.h create mode 100644 include/gr_basic.h create mode 100644 include/grfonte.h create mode 100644 include/id.h create mode 100644 include/macros.h create mode 100644 include/pcbstruct.h create mode 100644 include/plot_common.h create mode 100644 include/trigo.h create mode 100644 include/worksheet.h create mode 100644 include/wxstruct.h create mode 100644 install.txt create mode 100644 kicad/bitmaps/Browse_Files.xpm create mode 100644 kicad/bitmaps/Editor.xpm create mode 100644 kicad/bitmaps/Fonts.xpm create mode 100644 kicad/bitmaps/New_Project.xpm create mode 100644 kicad/bitmaps/Open_Project.xpm create mode 100644 kicad/bitmaps/Save_Project.xpm create mode 100644 kicad/bitmaps/unzip.xpm create mode 100644 kicad/bitmaps/zip.xpm create mode 100644 kicad/bitmaps/zip_tool.xpm create mode 100644 kicad/buildmnu.cpp create mode 100644 kicad/files-io.cpp create mode 100644 kicad/kicad.cpp create mode 100644 kicad/kicad.h create mode 100644 kicad/kicad.ico create mode 100644 kicad/kicad.r create mode 100644 kicad/kicad.rc create mode 100644 kicad/mainframe.rc create mode 100644 kicad/makefile.g95 create mode 100644 kicad/makefile.gtk create mode 100644 kicad/makefile.include create mode 100644 kicad/makefile.macosx create mode 100644 kicad/mdiframe.cpp create mode 100644 kicad/minizip/crypt.h create mode 100644 kicad/minizip/ioapi.c create mode 100644 kicad/minizip/ioapi.h create mode 100644 kicad/minizip/iowin32.c create mode 100644 kicad/minizip/iowin32.h create mode 100644 kicad/minizip/makefile create mode 100644 kicad/minizip/makefile.unx create mode 100644 kicad/minizip/makefile.win create mode 100644 kicad/minizip/minizip.c create mode 100644 kicad/minizip/zip.c create mode 100644 kicad/minizip/zip.h create mode 100644 kicad/preferences.cpp create mode 100644 kicad/prjconfig.cpp create mode 100644 kicad/prjconfig.h create mode 100644 kicad/protos.h create mode 100644 kicad/treeprj.cpp create mode 100644 libs.linux create mode 100644 libs.macosx create mode 100644 libs.win create mode 100644 make_static.linux create mode 100644 makefile.g95 create mode 100644 makefile.gtk create mode 100644 makefile.macosx create mode 100644 mybuild_wxWidgets_linux.txt create mode 100644 mybuild_wxWidgets_linux_unicode.txt create mode 100644 mybuild_wxWidgets_macosX.txt create mode 100644 mybuild_wxWidgets_macosX_unicode.txt create mode 100644 mybuild_wxWidgets_windows.txt create mode 100644 mybuild_wxWidgets_windows_unicode.txt create mode 100644 nsis_win_installer/English.nsh create mode 100644 nsis_win_installer/French.nsh create mode 100644 nsis_win_installer/Installer Docs.odt create mode 100644 nsis_win_installer/Italian.nsh create mode 100644 nsis_win_installer/Portuguese.nsh create mode 100644 nsis_win_installer/Russian.nsh create mode 100644 nsis_win_installer/Spanish.nsh create mode 100644 nsis_win_installer/install.ico create mode 100644 nsis_win_installer/install.nsi create mode 100644 nsis_win_installer/uninstall.ico create mode 100644 pcbnew/affiche.cpp create mode 100644 pcbnew/ar_protos.h create mode 100644 pcbnew/attribut.cpp create mode 100644 pcbnew/automove.cpp create mode 100644 pcbnew/autoplac.cpp create mode 100644 pcbnew/autorout.cpp create mode 100644 pcbnew/autorout.h create mode 100644 pcbnew/basepcbframe.cpp create mode 100644 pcbnew/bitmaps/Add_Mires.xpm create mode 100644 pcbnew/bitmaps/Add_Tracks.xpm create mode 100644 pcbnew/bitmaps/Add_Zone.xpm create mode 100644 pcbnew/bitmaps/Break_Line.xpm create mode 100644 pcbnew/bitmaps/Delete_Line.xpm create mode 100644 pcbnew/bitmaps/Delete_Module.xpm create mode 100644 pcbnew/bitmaps/Delete_Net.xpm create mode 100644 pcbnew/bitmaps/Delete_Node.xpm create mode 100644 pcbnew/bitmaps/Delete_Pad.xpm create mode 100644 pcbnew/bitmaps/Delete_Track.xpm create mode 100644 pcbnew/bitmaps/Drag_Module.xpm create mode 100644 pcbnew/bitmaps/Drag_Pad.xpm create mode 100644 pcbnew/bitmaps/Edges_Sketch.xpm create mode 100644 pcbnew/bitmaps/Edit_Module.xpm create mode 100644 pcbnew/bitmaps/Export_Module.xpm create mode 100644 pcbnew/bitmaps/Export_Options_Pad.xpm create mode 100644 pcbnew/bitmaps/Flag.xpm create mode 100644 pcbnew/bitmaps/Global_Options_Pad.xpm create mode 100644 pcbnew/bitmaps/Import_Module.xpm create mode 100644 pcbnew/bitmaps/Invert_Module.xpm create mode 100644 pcbnew/bitmaps/Load_Module_Board.xpm create mode 100644 pcbnew/bitmaps/Load_Module_Lib.xpm create mode 100644 pcbnew/bitmaps/Locked.xpm create mode 100644 pcbnew/bitmaps/Mode_Module.xpm create mode 100644 pcbnew/bitmaps/Mode_Track.xpm create mode 100644 pcbnew/bitmaps/Modul_Edit.xpm create mode 100644 pcbnew/bitmaps/Module_Check.xpm create mode 100644 pcbnew/bitmaps/Module_Ratsnet.xpm create mode 100644 pcbnew/bitmaps/Move_Field.xpm create mode 100644 pcbnew/bitmaps/Move_Module.xpm create mode 100644 pcbnew/bitmaps/Move_Pad.xpm create mode 100644 pcbnew/bitmaps/Move_Pin.xpm create mode 100644 pcbnew/bitmaps/Net_HighLight.xpm create mode 100644 pcbnew/bitmaps/Net_Locked.xpm create mode 100644 pcbnew/bitmaps/Net_UnLocked.xpm create mode 100644 pcbnew/bitmaps/New_FootPrint.xpm create mode 100644 pcbnew/bitmaps/New_Module.xpm create mode 100644 pcbnew/bitmaps/Options_All_Tracks&Vias.xpm create mode 100644 pcbnew/bitmaps/Options_All_Tracks.xpm create mode 100644 pcbnew/bitmaps/Options_All_Vias.xpm create mode 100644 pcbnew/bitmaps/Options_Module.xpm create mode 100644 pcbnew/bitmaps/Options_Track.xpm create mode 100644 pcbnew/bitmaps/Options_Tracks.xpm create mode 100644 pcbnew/bitmaps/Options_Vias.xpm create mode 100644 pcbnew/bitmaps/PcbOffset.xpm create mode 100644 pcbnew/bitmaps/Post_Compo.xpm create mode 100644 pcbnew/bitmaps/Post_Drill.xpm create mode 100644 pcbnew/bitmaps/Post_Module.xpm create mode 100644 pcbnew/bitmaps/Repl_Module_Board.xpm create mode 100644 pcbnew/bitmaps/Rotate_Field.xpm create mode 100644 pcbnew/bitmaps/Rotate_Module+.xpm create mode 100644 pcbnew/bitmaps/Rotate_Module-.xpm create mode 100644 pcbnew/bitmaps/Select_Layer_Pair.xpm create mode 100644 pcbnew/bitmaps/Select_W_Layer.xpm create mode 100644 pcbnew/bitmaps/Show_Zone.xpm create mode 100644 pcbnew/bitmaps/Swap_Layer.xpm create mode 100644 pcbnew/bitmaps/Track_Locked.xpm create mode 100644 pcbnew/bitmaps/Track_Sketch.xpm create mode 100644 pcbnew/bitmaps/Track_UnLocked.xpm create mode 100644 pcbnew/bitmaps/Unlocked.xpm create mode 100644 pcbnew/bitmaps/Width_Net.xpm create mode 100644 pcbnew/bitmaps/Width_Segment.xpm create mode 100644 pcbnew/bitmaps/Width_Track.xpm create mode 100644 pcbnew/bitmaps/Width_Track_Via.xpm create mode 100644 pcbnew/bitmaps/Width_Vias.xpm create mode 100644 pcbnew/bitmaps/add_cotation.xpm create mode 100644 pcbnew/bitmaps/general_ratsnet.xpm create mode 100644 pcbnew/bitmaps/local_ratsnet.xpm create mode 100644 pcbnew/bitmaps/module_options.xpm create mode 100644 pcbnew/bitmaps/mw_Add_Gap.xpm create mode 100644 pcbnew/bitmaps/mw_Add_Line.xpm create mode 100644 pcbnew/bitmaps/mw_Add_Shape.xpm create mode 100644 pcbnew/bitmaps/mw_Add_Stub.xpm create mode 100644 pcbnew/bitmaps/mw_Add_stub_arc.xpm create mode 100644 pcbnew/bitmaps/mw_toolbar.xpm create mode 100644 pcbnew/bitmaps/net_hightlight.xpm create mode 100644 pcbnew/bitmaps/tool_ratsnet.xpm create mode 100644 pcbnew/block.cpp create mode 100644 pcbnew/block_module_editor.cpp create mode 100644 pcbnew/board.cpp create mode 100644 pcbnew/cell.h create mode 100644 pcbnew/class_board.cpp create mode 100644 pcbnew/class_cotation.cpp create mode 100644 pcbnew/class_cotation.h create mode 100644 pcbnew/class_edge_mod.cpp create mode 100644 pcbnew/class_edge_mod.h create mode 100644 pcbnew/class_equipot.cpp create mode 100644 pcbnew/class_equipot.h create mode 100644 pcbnew/class_mire.cpp create mode 100644 pcbnew/class_mire.h create mode 100644 pcbnew/class_module.cpp create mode 100644 pcbnew/class_module.h create mode 100644 pcbnew/class_pad.cpp create mode 100644 pcbnew/class_pad.h create mode 100644 pcbnew/class_pcb_text.cpp create mode 100644 pcbnew/class_pcb_text.h create mode 100644 pcbnew/class_text_mod.cpp create mode 100644 pcbnew/class_text_mod.h create mode 100644 pcbnew/class_track.cpp create mode 100644 pcbnew/class_track.h create mode 100644 pcbnew/classpcb.cpp create mode 100644 pcbnew/classtrc.cpp create mode 100644 pcbnew/clean.cpp create mode 100644 pcbnew/connect.cpp create mode 100644 pcbnew/controle.cpp create mode 100644 pcbnew/cotation.cpp create mode 100644 pcbnew/cursors.cpp create mode 100644 pcbnew/deltrack.cpp create mode 100644 pcbnew/dialog_display_options.cpp create mode 100644 pcbnew/dialog_display_options.h create mode 100644 pcbnew/dialog_display_options.rc create mode 100644 pcbnew/dialog_drc.cpp create mode 100644 pcbnew/dialog_drc.h create mode 100644 pcbnew/dialog_edit_mod_text.cpp create mode 100644 pcbnew/dialog_edit_mod_text.h create mode 100644 pcbnew/dialog_edit_module.cpp create mode 100644 pcbnew/dialog_edit_module.h create mode 100644 pcbnew/dialog_general_options.cpp create mode 100644 pcbnew/dialog_general_options.h create mode 100644 pcbnew/dialog_general_options.rc create mode 100644 pcbnew/dialog_graphic_items_options.cpp create mode 100644 pcbnew/dialog_graphic_items_options.h create mode 100644 pcbnew/dialog_graphic_items_options.rc create mode 100644 pcbnew/dialog_initpcb.cpp create mode 100644 pcbnew/dialog_initpcb.h create mode 100644 pcbnew/dialog_initpcb.rc create mode 100644 pcbnew/dialog_module_edit.rc create mode 100644 pcbnew/dialog_netlist.cpp create mode 100644 pcbnew/dialog_netlist.h create mode 100644 pcbnew/dialog_netlist.rc create mode 100644 pcbnew/dialog_pad_edit.cpp create mode 100644 pcbnew/dialog_pad_edit.h create mode 100644 pcbnew/dialog_pad_edit.rc create mode 100644 pcbnew/dialog_setup_libs.cpp create mode 100644 pcbnew/dialog_setup_libs.h create mode 100644 pcbnew/dialog_track_options.cpp create mode 100644 pcbnew/dialog_track_options.h create mode 100644 pcbnew/dialog_track_options.rc create mode 100644 pcbnew/dist.cpp create mode 100644 pcbnew/docedit.cpp create mode 100644 pcbnew/drag.h create mode 100644 pcbnew/dragsegm.cpp create mode 100644 pcbnew/drc.cpp create mode 100644 pcbnew/dupltrac.cpp create mode 100644 pcbnew/edgemod.cpp create mode 100644 pcbnew/edit.cpp create mode 100644 pcbnew/edit_track_width.cpp create mode 100644 pcbnew/editedge.cpp create mode 100644 pcbnew/editmod.cpp create mode 100644 pcbnew/editpads.cpp create mode 100644 pcbnew/editrack-part2.cpp create mode 100644 pcbnew/editrack.cpp create mode 100644 pcbnew/editrout.cpp create mode 100644 pcbnew/edtxtmod.cpp create mode 100644 pcbnew/edtxtmod.rc create mode 100644 pcbnew/essai.cpp create mode 100644 pcbnew/essai.h create mode 100644 pcbnew/essai.rc create mode 100644 pcbnew/export_gencad.cpp create mode 100644 pcbnew/files.cpp create mode 100644 pcbnew/find.cpp create mode 100644 pcbnew/find.h create mode 100644 pcbnew/find.rc create mode 100644 pcbnew/gen_modules_placefile.cpp create mode 100644 pcbnew/gen_self.h create mode 100644 pcbnew/gendrill.cpp create mode 100644 pcbnew/globaleditpad.cpp create mode 100644 pcbnew/graphpcb.cpp create mode 100644 pcbnew/hotkeys.cpp create mode 100644 pcbnew/icon_modedit.ico create mode 100644 pcbnew/icon_pcbnew.ico create mode 100644 pcbnew/icon_w3d.ico create mode 100644 pcbnew/initpcb.cpp create mode 100644 pcbnew/ioascii.cpp create mode 100644 pcbnew/lay2plot.cpp create mode 100644 pcbnew/librairi.cpp create mode 100644 pcbnew/loadcmp.cpp create mode 100644 pcbnew/locate.cpp create mode 100644 pcbnew/makefile.g95 create mode 100644 pcbnew/makefile.gtk create mode 100644 pcbnew/makefile.include create mode 100644 pcbnew/makefile.macosx create mode 100644 pcbnew/menubarmodedit.cpp create mode 100644 pcbnew/menubarpcb.cpp create mode 100644 pcbnew/mirepcb.cpp create mode 100644 pcbnew/modedit.cpp create mode 100644 pcbnew/modedit_onclick.cpp create mode 100644 pcbnew/modedit_undo_redo.cpp create mode 100644 pcbnew/modeditoptions.cpp create mode 100644 pcbnew/moduleframe.cpp create mode 100644 pcbnew/modules.cpp create mode 100644 pcbnew/move-drag_pads.cpp create mode 100644 pcbnew/move_copy_track.cpp create mode 100644 pcbnew/muonde.cpp create mode 100644 pcbnew/muwave_command.cpp create mode 100644 pcbnew/netlist.cpp create mode 100644 pcbnew/onrightclick.cpp create mode 100644 pcbnew/pcbcfg.cpp create mode 100644 pcbnew/pcbcfg.h create mode 100644 pcbnew/pcbframe.cpp create mode 100644 pcbnew/pcbnew.cpp create mode 100644 pcbnew/pcbnew.h create mode 100644 pcbnew/pcbnew.r create mode 100644 pcbnew/pcbnew.rc create mode 100644 pcbnew/pcbpiste.cpp create mode 100644 pcbnew/pcbplot.cpp create mode 100644 pcbnew/pcbplot.h create mode 100644 pcbnew/pcbtexte.cpp create mode 100644 pcbnew/plot_rtn.cpp create mode 100644 pcbnew/plotgerb.cpp create mode 100644 pcbnew/plotgerb.h create mode 100644 pcbnew/plothpgl.cpp create mode 100644 pcbnew/plotps.cpp create mode 100644 pcbnew/protos.h create mode 100644 pcbnew/queue.cpp create mode 100644 pcbnew/ratsnest.cpp create mode 100644 pcbnew/reglage.cpp create mode 100644 pcbnew/router.cpp create mode 100644 pcbnew/sel_layer.cpp create mode 100644 pcbnew/set_color.cpp create mode 100644 pcbnew/set_grid.cpp create mode 100644 pcbnew/set_grid.h create mode 100644 pcbnew/set_grid.rc create mode 100644 pcbnew/solve.cpp create mode 100644 pcbnew/struct.cpp create mode 100644 pcbnew/surbrill.cpp create mode 100644 pcbnew/tool_modedit.cpp create mode 100644 pcbnew/tool_onrightclick.cpp create mode 100644 pcbnew/tool_pcb.cpp create mode 100644 pcbnew/tr_modif.cpp create mode 100644 pcbnew/tracemod.cpp create mode 100644 pcbnew/tracepcb.cpp create mode 100644 pcbnew/track.cpp create mode 100644 pcbnew/trpiste.cpp create mode 100644 pcbnew/undelete.cpp create mode 100644 pcbnew/via_edit.cpp create mode 100644 pcbnew/work.cpp create mode 100644 pcbnew/xchgmod.cpp create mode 100644 pcbnew/zones.cpp create mode 100644 pcbnew/zones.h create mode 100644 pcbnew/zones.rc create mode 100644 share/dialog_print.cpp create mode 100644 share/dialog_print.h create mode 100644 share/dialog_print.pjd create mode 100644 share/drawframe.cpp create mode 100644 share/drawpanel.cpp create mode 100644 share/gr_basic.cpp create mode 100644 share/infospgm.cpp create mode 100644 share/selcolor.cpp create mode 100644 share/setpage.cpp create mode 100644 share/setpage.h create mode 100644 share/setpage.pjd create mode 100644 share/svg_print.cpp create mode 100644 share/svg_print.h create mode 100644 share/svg_print.pjd create mode 100644 share/worksheet.cpp create mode 100644 share/wxprint.cpp create mode 100644 share/zoom.cpp diff --git a/3d-viewer/3d_aux.cpp b/3d-viewer/3d_aux.cpp new file mode 100644 index 0000000000..9cb437fc3f --- /dev/null +++ b/3d-viewer/3d_aux.cpp @@ -0,0 +1,269 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: 3d_aux.cpp +///////////////////////////////////////////////////////////////////////////// + + +#ifdef __GNUG__ +#pragma implementation +#pragma interface +#endif + +#include "fctsys.h" + +#if !wxUSE_GLCANVAS +#error Please set wxUSE_GLCANVAS to 1 in setup.h. +#endif + +#include "common.h" +#include "trigo.h" + +#include "bitmaps.h" + +#include "3d_viewer.h" +#include "3d_struct.h" +#include "trackball.h" + +/**************************************************************************/ +void Struct3D_Master::Set_Object_Coords(S3D_Vertex * coord, int nbcoord ) +/**************************************************************************/ +{ +int ii; + + + /* adjust object scale, rotation and offset position */ + for ( ii = 0; ii < nbcoord; ii++ ) + { + coord[ii].x *= m_MatScale.x; + coord[ii].y *= m_MatScale.y; + coord[ii].z *= m_MatScale.z; + /* adjust rotation */ + if ( m_MatRotation.x ) + RotatePoint(&coord[ii].y, &coord[ii].z, + (int)(m_MatRotation.x * 10)); + if ( m_MatRotation.y ) + RotatePoint(&coord[ii].z, &coord[ii].x, + (int)(m_MatRotation.y * 10)); + if ( m_MatRotation.z ) + RotatePoint(&coord[ii].x, &coord[ii].y, + (int)(m_MatRotation.z * 10)); + /* adjust offset position (offset is given in UNIT 3D (0.1 inch) */ +#define SCALE_3D_CONV (PCB_INTERNAL_UNIT/UNITS3D_TO_UNITSPCB) + coord[ii].x += m_MatPosition.x * SCALE_3D_CONV; + coord[ii].y += m_MatPosition.y * SCALE_3D_CONV; + coord[ii].z += m_MatPosition.z * SCALE_3D_CONV; + } +} + +/************************************************************/ +void Set_Object_Data(const S3D_Vertex * coord, int nbcoord ) +/************************************************************/ +{ +int ii; +GLfloat ax,ay,az,bx,by,bz,nx,ny,nz,r; + + /* ignore faces with less than 3 points */ + if (nbcoord < 3) return; + + /* calculate normal direction */ + ax = coord[1].x - coord[0].x; + ay = coord[1].y - coord[0].y; + az = coord[1].z - coord[0].z; + + bx = coord[nbcoord-1].x - coord[0].x; + by = coord[nbcoord-1].y - coord[0].y; + bz = coord[nbcoord-1].z - coord[0].z; + + nx = ay * bz - az * by; + ny = az * bx - ax * bz; + nz = ax * by - ay * bx; + + r = sqrt(nx*nx + ny*ny + nz*nz); + if (r >= 0.000001) /* avoid division by zero */ + { + nx /= r; ny /= r; nz /= r; + glNormal3f(nx,ny,nz); + } + + /* glBegin/glEnd */ + switch (nbcoord) + { + case 3: + glBegin(GL_TRIANGLES); + break; + + case 4: + glBegin(GL_QUADS); + break; + + default: + glBegin(GL_POLYGON); + break; + } + + /* draw polygon/triangle/quad */ + for (ii = 0; ii < nbcoord; ii++) + { + glVertex3f(coord[ii].x * DataScale3D, + coord[ii].y * DataScale3D, + coord[ii].z * DataScale3D); + } + + glEnd(); +} + + +/**********************************************/ +GLuint Pcb3D_GLCanvas::DisplayCubeforTest(void) +/**********************************************/ +{ +GLuint gllist = glGenLists( 1 ); + + glNewList( gllist, GL_COMPILE_AND_EXECUTE ); + /* draw six faces of a cube */ + glBegin(GL_QUADS); + glNormal3f( 0.0F, 0.0F, 1.0F); + glVertex3f( 0.5F, 0.5F, 0.5F); glVertex3f(-0.5F, 0.5F, 0.5F); + glVertex3f(-0.5F,-0.5F, 0.5F); glVertex3f( 0.5F,-0.5F, 0.5F); + + glNormal3f( 0.0F, 0.0F,-1.0F); + glVertex3f(-0.5F,-0.5F,-0.5F); glVertex3f(-0.5F, 0.5F,-0.5F); + glVertex3f( 0.5F, 0.5F,-0.5F); glVertex3f( 0.5F,-0.5F,-0.5F); + + glNormal3f( 0.0F, 1.0F, 0.0F); + glVertex3f( 0.5F, 0.5F, 0.5F); glVertex3f( 0.5F, 0.5F,-0.5F); + glVertex3f(-0.5F, 0.5F,-0.5F); glVertex3f(-0.5F, 0.5F, 0.5F); + + glNormal3f( 0.0F,-1.0F, 0.0F); + glVertex3f(-0.5F,-0.5F,-0.5F); glVertex3f( 0.5F,-0.5F,-0.5F); + glVertex3f( 0.5F,-0.5F, 0.5F); glVertex3f(-0.5F,-0.5F, 0.5F); + + glNormal3f( 1.0F, 0.0F, 0.0F); + glVertex3f( 0.5F, 0.5F, 0.5F); glVertex3f( 0.5F,-0.5F, 0.5F); + glVertex3f( 0.5F,-0.5F,-0.5F); glVertex3f( 0.5F, 0.5F,-0.5F); + + glNormal3f(-1.0F, 0.0F, 0.0F); + glVertex3f(-0.5F,-0.5F,-0.5F); glVertex3f(-0.5F,-0.5F, 0.5F); + glVertex3f(-0.5F, 0.5F, 0.5F); glVertex3f(-0.5F, 0.5F,-0.5F); + glEnd(); + + glEndList(); + + return gllist; +} + + + +/**********************/ +/* class Info_3D_Visu */ +/**********************/ + +/* Constructor */ +Info_3D_Visu::Info_3D_Visu(void) +{ +int ii; + m_Beginx = m_Beginy = 0.0; /* position of mouse */ + m_Zoom = 1.0; /* field of view in degrees */ + trackball( m_Quat, 0.0, 0.0, 0.0, 0.0 ); + for ( ii = 0; ii < 4; ii++ ) m_Rot[ii] = 0.0; + m_Layers = 1; + m_BoardSettings = NULL; +} + + +Info_3D_Visu::~Info_3D_Visu(void) +{ +} + + +/*****************************************************************/ +/* Classe pour afficher et editer un Vertex (triplet de valeurs),*/ +/* en INCHES ou MM ou sans unites */ +/*****************************************************************/ + +WinEDA_VertexCtrl::WinEDA_VertexCtrl(wxWindow *parent, const wxString & title, + wxBoxSizer * BoxSizer, + int units, int internal_unit) +{ +wxString text; +wxStaticText * msgtitle; + + m_Units = units; + m_Internal_Unit = internal_unit; + + if ( title.IsEmpty() ) text = _("Vertex "); + else text = title; + text += ReturnUnitSymbol(units); + + msgtitle = new wxStaticText(parent, -1, text, wxDefaultPosition, wxSize(-1,-1), 0 ); + BoxSizer->Add(msgtitle, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxADJUST_MINSIZE); + + wxFlexGridSizer * GridSizer = new wxFlexGridSizer(3, 2, 0, 0); + BoxSizer->Add(GridSizer, 0, wxGROW|wxALL, 5); + + msgtitle = new wxStaticText(parent, -1, wxT("X:")); + GridSizer->Add(msgtitle, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + m_XValueCtrl = new wxTextCtrl(parent, -1, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0 ); + GridSizer->Add(m_XValueCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5); + + msgtitle = new wxStaticText(parent, -1, wxT("Y:"), wxDefaultPosition, wxSize(-1,-1), 0 ); + GridSizer->Add(msgtitle, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + m_YValueCtrl = new wxTextCtrl(parent, -1, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0 ); + GridSizer->Add(m_YValueCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5); + + msgtitle = new wxStaticText(parent, -1, wxT("Z:"), wxDefaultPosition, wxSize(-1,-1), 0 ); + GridSizer->Add(msgtitle, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + m_ZValueCtrl = new wxTextCtrl(parent, -1, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0 ); + GridSizer->Add(m_ZValueCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5); +} + +WinEDA_VertexCtrl::~WinEDA_VertexCtrl(void) +{ +} + + +/*******************************************/ +S3D_Vertex WinEDA_VertexCtrl::GetValue(void) +/*******************************************/ +/* Retourne (en unites internes) les coordonnes entrees (en unites utilisateur) +*/ +{ +S3D_Vertex value; +double dtmp; + + m_XValueCtrl->GetValue().ToDouble(&dtmp); + value.x = dtmp; + m_YValueCtrl->GetValue().ToDouble(&dtmp); + value.y = dtmp; + m_ZValueCtrl->GetValue().ToDouble(&dtmp); + value.z = dtmp; + return value; +} + +/**************************************************/ +void WinEDA_VertexCtrl::SetValue(S3D_Vertex vertex) +/**************************************************/ +{ +wxString text; + + text.Printf( wxT("%f"), vertex.x); + m_XValueCtrl->Clear(); + m_XValueCtrl->AppendText(text); + + text.Printf(wxT("%f"), vertex.y); + m_YValueCtrl->Clear(); + m_YValueCtrl->AppendText(text); + + text.Printf(wxT("%f"), vertex.z); + m_ZValueCtrl->Clear(); + m_ZValueCtrl->AppendText(text); +} + +/*****************************************/ +void WinEDA_VertexCtrl::Enable(bool onoff) +/*****************************************/ +{ + m_XValueCtrl->Enable(onoff); + m_YValueCtrl->Enable(onoff); + m_ZValueCtrl->Enable(onoff); +} + diff --git a/3d-viewer/3d_canvas.cpp b/3d-viewer/3d_canvas.cpp new file mode 100644 index 0000000000..4e6c207da1 --- /dev/null +++ b/3d-viewer/3d_canvas.cpp @@ -0,0 +1,619 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: 3d_canvas.cpp +///////////////////////////////////////////////////////////////////////////// + + +#ifdef __GNUG__ +#pragma implementation +#pragma interface +#endif + +#include "fctsys.h" +#include "trigo.h" + +#include "wx/image.h" + +#if !wxUSE_GLCANVAS +#error Please set wxUSE_GLCANVAS to 1 in setup.h. +#endif + +#include "wx/dataobj.h" +#include "wx/clipbrd.h" + +#include "fctsys.h" +#include "common.h" +#include "id.h" + +#include "3d_viewer.h" +#include "trackball.h" + +/* Tool and button Bitmaps */ +#define XPM_3D_MAIN +#include "bitmaps3d.h" +#include "bitmaps.h" + +enum onrclick_id +{ + ID_POPUP_3D_VIEW_START = 2000, + ID_POPUP_ZOOMIN, + ID_POPUP_ZOOMOUT, + ID_POPUP_VIEW_XPOS, + ID_POPUP_VIEW_XNEG, + ID_POPUP_VIEW_YPOS, + ID_POPUP_VIEW_YNEG, + ID_POPUP_VIEW_ZPOS, + ID_POPUP_VIEW_ZNEG, + ID_POPUP_MOVE3D_LEFT, + ID_POPUP_MOVE3D_RIGHT, + ID_POPUP_MOVE3D_UP, + ID_POPUP_MOVE3D_DOWN, + ID_POPUP_3D_VIEW_END +}; + + +/* + * Pcb3D_GLCanvas implementation + */ + +BEGIN_EVENT_TABLE(Pcb3D_GLCanvas, wxGLCanvas) + EVT_SIZE(Pcb3D_GLCanvas::OnSize) + EVT_PAINT(Pcb3D_GLCanvas::OnPaint) + EVT_CHAR(Pcb3D_GLCanvas::OnChar) + EVT_MOUSE_EVENTS(Pcb3D_GLCanvas::OnMouseEvent) + EVT_ERASE_BACKGROUND(Pcb3D_GLCanvas::OnEraseBackground) + EVT_MENU_RANGE(ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END, + Pcb3D_GLCanvas::OnPopUpMenu) +END_EVENT_TABLE() + +/*************************************************************************/ +Pcb3D_GLCanvas::Pcb3D_GLCanvas(WinEDA3D_DrawFrame *parent, wxWindowID id, + int* gl_attrib): + wxGLCanvas(parent, id, wxPoint(-1,-1), wxSize(-1,-1), 0, wxT("Pcb3D_glcanvas"), gl_attrib) +/*************************************************************************/ +{ + m_init = FALSE; + m_gllist = 0; + m_Parent = parent; + DisplayStatus(); +} + + +/*************************************/ +Pcb3D_GLCanvas::~Pcb3D_GLCanvas(void) +/*************************************/ +{ + ClearLists(); +} + +/*************************************/ +void Pcb3D_GLCanvas::ClearLists(void) +/*************************************/ +{ + if( m_gllist > 0 ) + glDeleteLists(m_gllist, 1); + m_init = FALSE; + m_gllist = 0; +} + +/*********************************************/ +void Pcb3D_GLCanvas::OnChar(wxKeyEvent& event) +/*********************************************/ +{ + SetView3D(event.GetKeyCode()); + event.Skip(); +} + +/*********************************************/ +void Pcb3D_GLCanvas::SetView3D(int keycode) +/*********************************************/ +{ +int ii; +double delta_move = 0.7 * g_Parm_3D_Visu.m_Zoom; + + switch(keycode) + { + case WXK_LEFT: + g_Draw3d_dx -= delta_move; + break; + case WXK_RIGHT: + g_Draw3d_dx += delta_move; + break; + case WXK_UP: + g_Draw3d_dy += delta_move; + break; + case WXK_DOWN: + g_Draw3d_dy -= delta_move; + break; + + case WXK_HOME: + g_Parm_3D_Visu.m_Zoom = 1.0; + g_Draw3d_dx = g_Draw3d_dy = 0; + trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); + break; + + case WXK_END: + break; + + case WXK_F1: + g_Parm_3D_Visu.m_Zoom /= 1.4; + if ( g_Parm_3D_Visu.m_Zoom <= 0.01) + g_Parm_3D_Visu.m_Zoom = 0.01; + break; + + case WXK_F2: + g_Parm_3D_Visu.m_Zoom *= 1.4; + break; + + case '+': + break; + + case '-': + break; + + case 'r': + case 'R': + g_Draw3d_dx = g_Draw3d_dy = 0; + for ( ii = 0; ii < 4; ii++ ) + g_Parm_3D_Visu.m_Rot[ii] = 0.0; + trackball(g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); + break; + + case 'x': + for ( ii = 0; ii < 4; ii++ ) + g_Parm_3D_Visu.m_Rot[ii] = 0.0; + trackball(g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); + g_Parm_3D_Visu.m_ROTZ = -90; + g_Parm_3D_Visu.m_ROTX = -90; + break; + + case 'X': + for ( ii = 0; ii < 4; ii++ ) + g_Parm_3D_Visu.m_Rot[ii] = 0.0; + trackball(g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); + g_Parm_3D_Visu.m_ROTZ = 90; + g_Parm_3D_Visu.m_ROTX = -90; + break; + + case 'y': + for ( ii = 0; ii < 4; ii++ ) + g_Parm_3D_Visu.m_Rot[ii] = 0.0; + trackball(g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); + g_Parm_3D_Visu.m_ROTX = -90; + break; + + case 'Y': + for ( ii = 0; ii < 4; ii++ ) + g_Parm_3D_Visu.m_Rot[ii] = 0.0; + trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); + g_Parm_3D_Visu.m_ROTX = -90; + g_Parm_3D_Visu.m_ROTZ = -180; + break; + + case 'z': + for ( ii = 0; ii < 4; ii++ ) + g_Parm_3D_Visu.m_Rot[ii] = 0.0; + trackball(g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); + break; + + case 'Z': + for ( ii = 0; ii < 4; ii++ ) + g_Parm_3D_Visu.m_Rot[ii] = 0.0; + trackball(g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); + g_Parm_3D_Visu.m_ROTX = -180; + break; + + default: + return; + } + + DisplayStatus(); + Refresh(FALSE); +} + +/********************************************************/ +void Pcb3D_GLCanvas::OnMouseEvent(wxMouseEvent& event) +/********************************************************/ +{ +wxSize size(GetClientSize()); +float spin_quat[4]; + + + if( event.RightDown() ) + { + OnRightClick(event); return; + } + + if ( event.m_wheelRotation ) + { + if ( event.GetWheelRotation() > 0 ) + { + g_Parm_3D_Visu.m_Zoom /= 1.4; + if ( g_Parm_3D_Visu.m_Zoom <= 0.01) + g_Parm_3D_Visu.m_Zoom = 0.01; + } + + else g_Parm_3D_Visu.m_Zoom *= 1.4; + DisplayStatus(); + Refresh(FALSE); + } + + if (event.Dragging()) + { + /* drag in progress, simulate trackball */ + trackball(spin_quat, + (2.0*g_Parm_3D_Visu.m_Beginx - size.x) / size.x, + (size.y - 2.0*g_Parm_3D_Visu.m_Beginy) / size.y, + ( 2.0*event.GetX() - size.x) / size.x, + ( size.y - 2.0*event.GetY()) / size.y); + + add_quats( spin_quat, g_Parm_3D_Visu.m_Quat, g_Parm_3D_Visu.m_Quat ); + + /* orientation has changed, redraw mesh */ + DisplayStatus(); + Refresh(FALSE); + } + + g_Parm_3D_Visu.m_Beginx = event.GetX(); + g_Parm_3D_Visu.m_Beginy = event.GetY(); +} + +/*******************************************************/ +void Pcb3D_GLCanvas::OnRightClick(wxMouseEvent& event) +/*******************************************************/ +/* Construit et affiche un menu Popup lorsque on actionne le bouton droit + de la souris +*/ +{ +wxPoint pos; +wxMenu PopUpMenu; + + pos.x = event.GetX(); pos.y = event.GetY(); + wxMenuItem *item = new wxMenuItem(&PopUpMenu, ID_POPUP_ZOOMIN, + _("Zoom +")); + item->SetBitmap(zoom_in_xpm); + PopUpMenu.Append(item); + + item = new wxMenuItem(&PopUpMenu, ID_POPUP_ZOOMOUT, + _("Zoom -")); + item->SetBitmap(zoom_out_xpm); + PopUpMenu.Append(item); + + PopUpMenu.AppendSeparator(); + item = new wxMenuItem(&PopUpMenu, ID_POPUP_VIEW_ZPOS, + _("Top View")); + item->SetBitmap(axis3d_top_xpm); + PopUpMenu.Append(item); + + item = new wxMenuItem(&PopUpMenu, ID_POPUP_VIEW_ZNEG, + _("Bottom View")); + item->SetBitmap(axis3d_bottom_xpm); + PopUpMenu.Append(item); + + PopUpMenu.AppendSeparator(); + item = new wxMenuItem(&PopUpMenu, ID_POPUP_VIEW_XPOS, + _("Right View")); + item->SetBitmap(axis3d_right_xpm); + PopUpMenu.Append(item); + + item = new wxMenuItem(&PopUpMenu, ID_POPUP_VIEW_XNEG, + _("Left View")); + item->SetBitmap(axis3d_left_xpm); + PopUpMenu.Append(item); + + + PopUpMenu.AppendSeparator(); + item = new wxMenuItem(&PopUpMenu, ID_POPUP_VIEW_YPOS, + _("Front View")); + item->SetBitmap(axis3d_front_xpm); + PopUpMenu.Append(item); + + item = new wxMenuItem(&PopUpMenu, ID_POPUP_VIEW_YNEG, + _("Back View")); + item->SetBitmap(axis3d_back_xpm); + PopUpMenu.Append(item); + + PopUpMenu.AppendSeparator(); + item = new wxMenuItem(&PopUpMenu, ID_POPUP_MOVE3D_LEFT, + _("Move left <-")); + item->SetBitmap(left_xpm); + PopUpMenu.Append(item); + + item = new wxMenuItem(&PopUpMenu, ID_POPUP_MOVE3D_RIGHT, + _("Move right ->")); + item->SetBitmap(right_xpm); + PopUpMenu.Append(item); + + item = new wxMenuItem(&PopUpMenu, ID_POPUP_MOVE3D_UP, + _("Move Up ^")); + item->SetBitmap(up_xpm); + PopUpMenu.Append(item); + + item = new wxMenuItem(&PopUpMenu, ID_POPUP_MOVE3D_DOWN, + _("Move Down")); + item->SetBitmap(down_xpm); + PopUpMenu.Append(item); + + PopupMenu( &PopUpMenu, pos); +} + +/*******************************************************/ +void Pcb3D_GLCanvas::OnPopUpMenu(wxCommandEvent & event) +/*******************************************************/ +{ +int key = 0; + + switch( event.GetId() ) + { + case ID_POPUP_ZOOMIN: + key = WXK_F1; + break; + + case ID_POPUP_ZOOMOUT: + key = WXK_F2; + break; + + case ID_POPUP_VIEW_XPOS: + key = 'x'; + break; + + case ID_POPUP_VIEW_XNEG: + key = 'X'; + break; + + case ID_POPUP_VIEW_YPOS: + key = 'y'; + break; + + case ID_POPUP_VIEW_YNEG: + key = 'Y'; + break; + + case ID_POPUP_VIEW_ZPOS: + key = 'z'; + break; + + case ID_POPUP_VIEW_ZNEG: + key = 'Z'; + break; + + case ID_POPUP_MOVE3D_LEFT: + key = WXK_LEFT; + break; + + case ID_POPUP_MOVE3D_RIGHT: + key = WXK_RIGHT; + break; + + case ID_POPUP_MOVE3D_UP: + key = WXK_UP; + break; + + case ID_POPUP_MOVE3D_DOWN: + key = WXK_DOWN; + break; + + default: + return; + } + SetView3D(key); +} + + +/***************************************/ +void Pcb3D_GLCanvas::DisplayStatus(void) +/***************************************/ +{ +wxString msg; + msg.Printf(wxT("dx %3.2f"), g_Draw3d_dx); + m_Parent->SetStatusText(msg,1); + + msg.Printf(wxT("dy %3.2f"), g_Draw3d_dy); + m_Parent->SetStatusText(msg,2); + + msg.Printf(wxT("View: %3.1f"), 45 * g_Parm_3D_Visu.m_Zoom); + m_Parent->SetStatusText(msg,3); +} + + +/*************************************************/ +void Pcb3D_GLCanvas::OnPaint( wxPaintEvent& event ) +/*************************************************/ +{ + wxPaintDC dc(this); + +#ifndef __WXMOTIF__ + if (!GetContext()) return; +#endif + Redraw(); + event.Skip(); +} + + +/**********************************************/ +void Pcb3D_GLCanvas::OnSize(wxSizeEvent& event) +/**********************************************/ +{ + // this is also necessary to update the context on some platforms + wxGLCanvas::OnSize(event); + + // set GL viewport (not called by wxGLCanvas::OnSize on all platforms...) + int w, h; + GetClientSize(&w, &h); +#ifndef __WXMOTIF__ + if (GetContext()) +#endif + { + SetCurrent(); + glViewport(0, 0, (GLint) w, (GLint) h); + } +} + +/***********************************************************/ +void Pcb3D_GLCanvas::OnEraseBackground(wxEraseEvent& event) +/***********************************************************/ +{ + // Do nothing, to avoid flashing. +} + + +/****************************/ +void Pcb3D_GLCanvas::InitGL() +/****************************/ +/* Int parametres generaux pour OPENGL +*/ +{ +wxSize size = GetClientSize(); + + if (! m_init) + { + m_init = TRUE; + g_Parm_3D_Visu.m_Zoom = 1.0; + ZBottom = 1.0; ZTop = 10.0; + } + + SetCurrent(); + + /* set viewing projection */ +double ratio_HV = (double) size.x / size.y; // Ratio largeur /hauteur de la fenetre d'affichage + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + +#define MAX_VIEW_ANGLE 160.0/45.0 + if ( g_Parm_3D_Visu.m_Zoom > MAX_VIEW_ANGLE) + g_Parm_3D_Visu.m_Zoom = MAX_VIEW_ANGLE; + gluPerspective( 45.0 * g_Parm_3D_Visu.m_Zoom, ratio_HV, 1 ,10 ); + +// glFrustum(-1., 1.1F, -1.1F, 1.1F, ZBottom, ZTop); + + /* position viewer */ + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0F, 0.0F, - ( ZBottom +ZTop) / 2); + + /* clear color and depth buffers */ + glClearColor( g_Parm_3D_Visu.m_BgColor.m_Red, + g_Parm_3D_Visu.m_BgColor.m_Green, + g_Parm_3D_Visu.m_BgColor.m_Blue, 1 ); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + /* Setup light souces: */ + SetLights(); + + + glDisable(GL_CULL_FACE); // show back faces + + glEnable(GL_DEPTH_TEST); // Enable z-buferring + + glEnable(GL_LINE_SMOOTH); + glEnable(GL_COLOR_MATERIAL); + glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); + + /* speedups */ + glEnable(GL_DITHER); + glShadeModel(GL_SMOOTH); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); + glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST); + + /* blend */ + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +} + + +/***********************************/ +void Pcb3D_GLCanvas::SetLights(void) +/***********************************/ +/* Init sources lumineuses pour OPENGL +*/ +{ +double light; +GLfloat light_color[4]; + + SetCurrent(); + + /* set viewing projection */ + light_color[3] = 1.0; + GLfloat Z_axis_pos[4] = { 0.0, 0.0, 3.0, 0.0 }; + GLfloat lowZ_axis_pos[4] = { 0.0, 0.0, -3.0, 0.5 }; + + /* activate light */ + light = 1.0; + light_color[0] = light_color[1] = light_color[2]= light; + glLightfv(GL_LIGHT0, GL_POSITION, Z_axis_pos); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_color); + light = 0.3; + light_color[0] = light_color[1] = light_color[2] = light; + glLightfv(GL_LIGHT1, GL_POSITION, lowZ_axis_pos); + glLightfv(GL_LIGHT1, GL_DIFFUSE, light_color); + glEnable(GL_LIGHT0); // White spot on Z axis + glEnable(GL_LIGHT1); // White spot on Z axis ( bottom) + glEnable(GL_LIGHTING); +} + + +/**********************************************************/ +void Pcb3D_GLCanvas::TakeScreenshot(wxCommandEvent & event) +/**********************************************************/ +/* Create a Screenshot of the current 3D view. + Output file format is png or jpeg, or image is copied on clipboard +*/ +{ +wxString FullFileName; +wxString file_ext, mask; +bool fmt_is_jpeg = FALSE; + + if ( event.GetId() == ID_MENU_SCREENCOPY_JPEG ) fmt_is_jpeg = TRUE; + if ( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD ) + { + file_ext = fmt_is_jpeg ? wxT(".jpg") : wxT(".png";) + mask = wxT("*") + file_ext; + FullFileName = m_Parent->m_Parent->GetScreen()->m_FileName; + ChangeFileNameExt(FullFileName,file_ext); + + FullFileName = + EDA_FileSelector( _("3D Image filename:"), + wxEmptyString, /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + file_ext, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + TRUE + ); + if ( FullFileName.IsEmpty() ) return; + } + wxSize image_size = GetClientSize(); + wxClientDC dc(this); + wxBitmap bitmap(image_size.x, image_size.y ); + wxMemoryDC memdc; + memdc.SelectObject( bitmap ); + memdc.Blit(0, 0, image_size.x, image_size.y, &dc, 0, 0); + memdc.SelectObject( wxNullBitmap ); + + if ( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD ) + { + wxBitmapDataObject *dobjBmp = new wxBitmapDataObject; + dobjBmp->SetBitmap(bitmap); + if (wxTheClipboard->Open()) + { + if ( !wxTheClipboard->SetData(dobjBmp) ) + wxLogError( _T("Failed to copy image to clipboard")); + wxTheClipboard->Flush(); /* the data on clipboard + will stay available after the application exits */ + wxTheClipboard->Close(); + } + } + + else + { + wxImage image = bitmap.ConvertToImage(); + + if ( !image.SaveFile( FullFileName, + fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG)) + wxLogError(wxT("Can't save file")); + + image.Destroy(); + } +} + + diff --git a/3d-viewer/3d_class.cpp b/3d-viewer/3d_class.cpp new file mode 100644 index 0000000000..69a7ed6d0d --- /dev/null +++ b/3d-viewer/3d_class.cpp @@ -0,0 +1,119 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: 3d_class.cpp +///////////////////////////////////////////////////////////////////////////// + + +#ifdef __GNUG__ +#pragma implementation +#pragma interface +#endif + +#include "fctsys.h" + +#include "common.h" + +#include "3d_struct.h" +#include "3d_viewer.h" + + +/****************************/ +S3D_Vertex::S3D_Vertex(void) +/****************************/ +{ + x = y = z = 0.0; +} + + +/**************************************************************************/ +S3D_Material::S3D_Material(Struct3D_Master * father, const wxString & name): + EDA_BaseStruct( father, -1) +/**************************************************************************/ +{ + m_DiffuseColor.x = m_DiffuseColor.y = m_DiffuseColor.z = 1.0; + m_SpecularColor.x = m_SpecularColor.y = m_SpecularColor.z = 1.0; + m_AmbientIntensity = 1.0; + m_Transparency = 0.0; + m_Shininess = 1.0; + m_Name = name; +} + +/***********************************/ +void S3D_Material::SetMaterial(void) +/***********************************/ +{ + glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); + glColor4f(m_DiffuseColor.x * m_AmbientIntensity, + m_DiffuseColor.y * m_AmbientIntensity, + m_DiffuseColor.z * m_AmbientIntensity, + 1.0 - m_Transparency ); +#if 0 + glColorMaterial(GL_FRONT_AND_BACK,GL_SPECULAR); + glColor3f(m_SpecularColor.x, m_SpecularColor.y,m_SpecularColor.z); +#endif + glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); +} + +/****************************************************/ +void Struct3D_Master::Copy(Struct3D_Master * pattern) +/****************************************************/ +{ + m_Shape3DName = pattern->m_Shape3DName; + m_MatScale = pattern->m_MatScale; + m_MatRotation = pattern->m_MatRotation; + m_MatPosition = pattern->m_MatPosition; + m_3D_Drawings = NULL; + m_Materials = NULL; +} + +/***************************************************************/ +Struct3D_Master::Struct3D_Master(EDA_BaseStruct * StructFather): + EDA_BaseStruct( StructFather, -1) +/***************************************************************/ +{ + m_MatScale.x = m_MatScale.y = m_MatScale.z = 1.0; + m_3D_Drawings = NULL; + m_Materials = NULL; +} + + +/***************************************/ +Struct3D_Master:: ~Struct3D_Master(void) +/***************************************/ +{ +Struct3D_Shape * next; +S3D_Material * nextmat; + + for( ; m_3D_Drawings != NULL; m_3D_Drawings = next ) + { + next = (Struct3D_Shape *) m_3D_Drawings->Pnext; + delete m_3D_Drawings; + } + + for( ; m_Materials != NULL; m_Materials = nextmat ) + { + nextmat = (S3D_Material *) m_Materials->Pnext; + delete m_Materials; + } +} + + + +/***************************************************************/ +Struct3D_Shape::Struct3D_Shape(EDA_BaseStruct * StructFather): + EDA_BaseStruct( StructFather, -1) +/***************************************************************/ +{ + m_3D_Coord = NULL; + m_3D_CoordIndex = NULL; + m_3D_Points = 0; +} + + +/***************************************/ +Struct3D_Shape:: ~Struct3D_Shape(void) +/***************************************/ +{ + delete m_3D_Coord; + delete m_3D_CoordIndex; +} + diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp new file mode 100644 index 0000000000..ab1c610d77 --- /dev/null +++ b/3d-viewer/3d_draw.cpp @@ -0,0 +1,787 @@ +////////////////////////////////////// +// Name: 3d_draw.cpp +////////////////////////////////////// + + +#ifdef __GNUG__ +#pragma implementation +#pragma interface +#endif + +#include "fctsys.h" +#include "trigo.h" + + +#if !wxUSE_GLCANVAS +#error Please set wxUSE_GLCANVAS to 1 in setup.h. +#endif + +#include "common.h" +#include "pcbstruct.h" +#include "macros.h" + +//#include "pcbnew.h" + +#include "3d_viewer.h" +#include "trackball.h" + +#include "3d_struct.h" + +static void Draw3D_FilledCircle(double posx, double posy, + double rayon, double hole_rayon, double zpos); +static void Draw3D_FilledSegment(double startx, double starty, + double endx, double endy,double width, double zpos); +static void Draw3D_FilledCylinder(double posx, double posy, + double rayon, double height, double zpos); +static void Draw3D_FilledSegmentWithHole(double startx, double starty, + double endx, double endy,double width, + double holex, double holey, double holeradius, double zpos); + + +/**********************************/ +void Pcb3D_GLCanvas::Redraw( void ) +/**********************************/ +{ + SetCurrent(); + + InitGL(); + + glMatrixMode(GL_MODELVIEW); /* position viewer */ + /* transformations */ + GLfloat mat[4][4]; + + build_rotmatrix( mat, g_Parm_3D_Visu.m_Quat ); + glMultMatrixf( &mat[0][0] ); + + glTranslatef(g_Draw3d_dx, g_Draw3d_dy, 0.0F); + + glRotatef(g_Parm_3D_Visu.m_Rot[0], 1.0, 0.0, 0.0); + glRotatef(g_Parm_3D_Visu.m_Rot[1], 0.0, 1.0, 0.0); + glRotatef(g_Parm_3D_Visu.m_Rot[2], 0.0, 0.0, 1.0); + + if( m_gllist ) glCallList( m_gllist ); + else + { + m_gllist = CreateDrawGL_List(); +// m_gllist = DisplayCubeforTest(); // Only for test + } + + glFlush(); + SwapBuffers(); + } + +/**********************************************/ +GLuint Pcb3D_GLCanvas::CreateDrawGL_List(void) +/**********************************************/ +/* Creation de la liste des elements a afficher +*/ +{ +GLuint gllist = glGenLists( 1 ); +WinEDA_BasePcbFrame * pcbframe = m_Parent->m_Parent; +BOARD * pcb = pcbframe->m_Pcb; +TRACK * pt_piste; +int ii; + + wxBusyCursor dummy; + + pcb->ComputeBoundaryBox(); + g_Parm_3D_Visu.m_BoardSettings = pcb->m_BoardSettings; + g_Parm_3D_Visu.m_BoardSize = pcb->m_BoundaryBox.GetSize(); + g_Parm_3D_Visu.m_BoardPos = pcb->m_BoundaryBox.Centre(); + g_Parm_3D_Visu.m_BoardPos.y = - g_Parm_3D_Visu.m_BoardPos.y; + g_Parm_3D_Visu.m_Layers = pcb->m_BoardSettings->m_CopperLayerCount; + g_Parm_3D_Visu.m_BoardScale = 2.0 / MAX(g_Parm_3D_Visu.m_BoardSize.x, g_Parm_3D_Visu.m_BoardSize.y); + float epoxy_width = 1.6; // epoxy width in mm + g_Parm_3D_Visu.m_Epoxy_Width = epoxy_width/2.54 * 1000 + * g_Parm_3D_Visu.m_BoardScale; + + /* calcul de l'altitude de chaque couche */ + for ( ii = 0; ii < 32; ii++ ) + { + if ( ii < g_Parm_3D_Visu.m_Layers ) + g_Parm_3D_Visu.m_LayerZcoord[ii] = g_Parm_3D_Visu.m_Epoxy_Width * ii + / (g_Parm_3D_Visu.m_Layers-1); + else g_Parm_3D_Visu.m_LayerZcoord[ii] = g_Parm_3D_Visu.m_Epoxy_Width; + } + GLfloat zpos_cu = 500 * g_Parm_3D_Visu.m_BoardScale; + GLfloat zpos_cmp = g_Parm_3D_Visu.m_Epoxy_Width + zpos_cu; + g_Parm_3D_Visu.m_LayerZcoord[ADHESIVE_N_CU] = -zpos_cu*2; + g_Parm_3D_Visu.m_LayerZcoord[ADHESIVE_N_CMP] = zpos_cmp + zpos_cu; + g_Parm_3D_Visu.m_LayerZcoord[SILKSCREEN_N_CU] = -zpos_cu; + g_Parm_3D_Visu.m_LayerZcoord[SILKSCREEN_N_CMP] = zpos_cmp; + g_Parm_3D_Visu.m_LayerZcoord[DRAW_N] = zpos_cmp + zpos_cu; + g_Parm_3D_Visu.m_LayerZcoord[COMMENT_N] = zpos_cmp + zpos_cu; + g_Parm_3D_Visu.m_LayerZcoord[ECO1_N] = zpos_cmp + zpos_cu; + g_Parm_3D_Visu.m_LayerZcoord[ECO2_N] = zpos_cmp + zpos_cu; + + glNewList( gllist, GL_COMPILE_AND_EXECUTE ); + + glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); + + /* draw axes*/ + glEnable(GL_COLOR_MATERIAL); + SetGLColor(WHITE); + glBegin(GL_LINES); + glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis + glVertex3f( 0.0 , 0.0, 0.0); glVertex3f(1.0, 0.0, 0.0); // X axis + glVertex3f( 0.0 , 0.0, 0.0); glVertex3f(0.0, -1.0, 0.0); // y axis + glNormal3f( 1.0, 0.0, 0.0); // Normal is Y axis + glVertex3f( 0.0 , 0.0, 0.0); glVertex3f(0.0, 0.0, 0.3); // z axis + glEnd(); + + /* Draw epoxy limits (do not use, works and test in progress)*/ +#if 0 +glEnable(GL_FOG); + GLfloat param; +// param = GL_LINEAR; glFogfv(GL_FOG_MODE,& param); + param = 0.2; glFogfv(GL_FOG_DENSITY,& param); + param = g_Parm_3D_Visu.m_LayerZcoord[15]; glFogfv(GL_FOG_END,& param); + glBegin(GL_QUADS); + SetGLColor(g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[CMP_N]); + double sx = DataScale3D * g_Parm_3D_Visu.m_BoardSize.x / 2; + double sy = DataScale3D * g_Parm_3D_Visu.m_BoardSize.y / 2; + double zpos = g_Parm_3D_Visu.m_LayerZcoord[15]; + glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis + sx = sy = 0.5; + glVertex3f( -sx, -sy , zpos); + glVertex3f( -sx, sy , zpos); + glVertex3f( sx, sy , zpos); + glVertex3f( sx, -sy , zpos); + glEnd(); + glBegin(GL_QUADS); + SetGLColor(g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[CUIVRE_N]); + glNormal3f( 0.0, 0.0, -1.0); // Normal is -Z axis + glVertex3f( -sx, -sy , 0); + glVertex3f( -sx, sy , 0); + glVertex3f( sx, sy , 0); + glVertex3f( sx, -sy , 0); + glEnd(); +#endif + + /* Translation du tracé du BOARD pour placer son centre en 0, 0 */ + glTranslatef(-g_Parm_3D_Visu.m_BoardPos.x * g_Parm_3D_Visu.m_BoardScale, + -g_Parm_3D_Visu.m_BoardPos.y * g_Parm_3D_Visu.m_BoardScale, + 0.0F); + + glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis + /* Tracé des pistes : */ + for (pt_piste = pcb->m_Track ; pt_piste != NULL ; pt_piste = (TRACK*) pt_piste->Pnext ) + { + if ( pt_piste->m_StructType == TYPEVIA ) + Draw3D_Via((SEGVIA*)pt_piste); + else Draw3D_Track( pt_piste); + } + + /* Tracé des edges */ +EDA_BaseStruct * PtStruct; + for ( PtStruct = pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Pnext) + { + #define STRUCT ((DRAWSEGMENT *) PtStruct) + if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; + Draw3D_DrawSegment(STRUCT); + } + + /* tracé des modules */ +MODULE * Module = (MODULE*) pcb->m_Modules; + for ( ; Module != NULL; Module = (MODULE *) Module->Pnext ) + { + Module->Draw3D(this); + } + glEndList(); + + /* Test for errors */ + GLenum err = glGetError(); + if ( err != GL_NO_ERROR ) + DisplayError(this, wxT("Error in GL commands") ); + return gllist; +} + +/************************************************/ +void Pcb3D_GLCanvas::Draw3D_Track(TRACK * track) +/************************************************/ +{ +double zpos; +int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[track->m_Layer]; +int layer = track->m_Layer; +double ox, oy, fx, fy; +double w; + + if ( color & ITEM_NOT_SHOW ) return; + if ( track->m_Layer == CMP_N ) layer = g_Parm_3D_Visu.m_Layers -1; + zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; + + SetGLColor(color); + glNormal3f( 0.0, 0.0, (layer == CUIVRE_N) ? -1.0 : 1.0); + + w = track->m_Width * g_Parm_3D_Visu.m_BoardScale; + ox = track->m_Start.x * g_Parm_3D_Visu.m_BoardScale; + oy = track->m_Start.y * g_Parm_3D_Visu.m_BoardScale; + fx = track->m_End.x * g_Parm_3D_Visu.m_BoardScale; + fy = track->m_End.y * g_Parm_3D_Visu.m_BoardScale; + Draw3D_FilledSegment(ox, -oy, fx, -fy, w, zpos); +} + +/********************************************/ +void Pcb3D_GLCanvas::Draw3D_Via(SEGVIA * via) +/*********************************************/ +/* 3D drawing for a VIA (cylinder + filled circles) +*/ +{ +double x, y, r, hole; +int layer, top_layer, bottom_layer; +double zpos, height; +int color; + + r = via->m_Width * g_Parm_3D_Visu.m_BoardScale / 2; + hole = g_Parm_3D_Visu.m_BoardSettings->m_ViaDrill * g_Parm_3D_Visu.m_BoardScale / 2; + x = via->m_Start.x * g_Parm_3D_Visu.m_BoardScale; + y = via->m_Start.y * g_Parm_3D_Visu.m_BoardScale; + + via->ReturnLayerPair(&top_layer, &bottom_layer); + + // Drawing filled circles: + for ( layer = bottom_layer; layer < g_Parm_3D_Visu.m_Layers; layer++ ) + { + zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; + if ( layer < g_Parm_3D_Visu.m_Layers-1 ) + color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; + else color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[CMP_N]; + if ( color & ITEM_NOT_SHOW ) continue; + SetGLColor(color); + glNormal3f( 0.0, 0.0, (layer == CUIVRE_N) ? -1.0 : 1.0); + Draw3D_FilledCircle(x, -y, r, hole, zpos); + if ( layer >= top_layer) break; + + } + // Drawing hole: + SetGLColor(DARKGRAY); + height = g_Parm_3D_Visu.m_LayerZcoord[top_layer] - g_Parm_3D_Visu.m_LayerZcoord[bottom_layer]; + Draw3D_FilledCylinder(x, -y, hole, height, g_Parm_3D_Visu.m_LayerZcoord[bottom_layer]); +} + + +/*************************************************************/ +void Pcb3D_GLCanvas::Draw3D_DrawSegment(DRAWSEGMENT * segment) +/*************************************************************/ +{ +int layer; +double x, y, xf, yf; +double zpos, w; +int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[segment->m_Layer]; + + if ( color & ITEM_NOT_SHOW ) return; + + SetGLColor(color); + w = segment->m_Width * g_Parm_3D_Visu.m_BoardScale; + x = segment->m_Start.x * g_Parm_3D_Visu.m_BoardScale; + y = segment->m_Start.y * g_Parm_3D_Visu.m_BoardScale; + xf = segment->m_End.x * g_Parm_3D_Visu.m_BoardScale; + yf = segment->m_End.y * g_Parm_3D_Visu.m_BoardScale; + + if ( segment->m_Layer == EDGE_N) + { + for ( layer = 0; layer < g_Parm_3D_Visu.m_Layers; layer++ ) + { + glNormal3f( 0.0, 0.0, (layer == CUIVRE_N) ? -1.0 : 1.0); + zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; + Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos); + } + } + + else + { + zpos = g_Parm_3D_Visu.m_LayerZcoord[segment->m_Layer]; + Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos); + } +} + + + +/*********************************************/ +void MODULE::Draw3D(Pcb3D_GLCanvas * glcanvas) +/*********************************************/ +{ +D_PAD * pad = m_Pads; + +#if 0 + if( ! DisplayOpt.Show_Modules_Cmp ) + { + if(m_Layer == CMP_N) return; + } + if( ! DisplayOpt.Show_Modules_Cu ) + { + if(m_Layer == CUIVRE_N) return; + } +#endif + + /* Draw pads */ + glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); + glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis + for( ; pad != NULL; pad = (D_PAD*) pad->Pnext ) + { + pad->Draw3D(glcanvas); + } + + /* Draw module shape: 3D shape if exists (or module edge if not exists)*/ +Struct3D_Master * Struct3D = m_3D_Drawings; +bool As3dShape = FALSE; + glPushMatrix(); + glTranslatef(m_Pos.x * g_Parm_3D_Visu.m_BoardScale, + -m_Pos.y * g_Parm_3D_Visu.m_BoardScale, + g_Parm_3D_Visu.m_LayerZcoord[m_Layer] ); + if ( m_Orient ) + { + glRotatef( (double)m_Orient / 10, 0.0, 0.0, 1.0 ); + } + if ( m_Layer == CUIVRE_N ) + { + glRotatef( 180.0, 0.0, 1.0, 0.0 ); + glRotatef( 180.0, 0.0, 0.0, 1.0 ); + } + DataScale3D = g_Parm_3D_Visu.m_BoardScale*UNITS3D_TO_UNITSPCB; + + for ( ; Struct3D != NULL; Struct3D = (Struct3D_Master *) Struct3D->Pnext ) + { + if ( ! Struct3D->m_Shape3DName.IsEmpty() ) + { + As3dShape = TRUE; + Struct3D->ReadData(); + } + } + glPopMatrix(); + + if ( ! As3dShape) + { + EDA_BaseStruct * Struct = m_Drawings; + glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis + for( ;Struct != NULL; Struct = Struct->Pnext ) + { + switch( Struct->m_StructType ) + { + case TYPETEXTEMODULE: + break; + + case TYPEEDGEMODULE: + ((EDGE_MODULE *) Struct)->Draw3D(glcanvas); + break; + + default: break; + } + } + } +} + +/***************************************************/ +void EDGE_MODULE::Draw3D(Pcb3D_GLCanvas * glcanvas) +/***************************************************/ +{ +int ux0, uy0, dx, dy,rayon, StAngle, EndAngle; +double scale, x, y, fx, fy, w, zpos ; +int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[m_Layer]; + + if ( color & ITEM_NOT_SHOW ) return; + + SetGLColor(color); + glNormal3f( 0.0, 0.0, (m_Layer == CUIVRE_N) ? -1.0 : 1.0); + scale = g_Parm_3D_Visu.m_BoardScale; + + ux0 = m_Start.x; + uy0 = m_Start.y; + dx = m_End.x; + dy = m_End.y; + zpos = g_Parm_3D_Visu.m_LayerZcoord[m_Layer]; + w = m_Width * g_Parm_3D_Visu.m_BoardScale; + switch (m_Shape ) + { + case S_SEGMENT: + x = m_Start.x * g_Parm_3D_Visu.m_BoardScale; + y = m_Start.y * g_Parm_3D_Visu.m_BoardScale; + fx = dx * g_Parm_3D_Visu.m_BoardScale; + fy = dy * g_Parm_3D_Visu.m_BoardScale; + Draw3D_FilledSegment(x, -y, fx, -fy, w, zpos); + break ; + + case S_CIRCLE: + rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) ); + /* TO DO */ + break; + + case S_ARC: + rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) ); + StAngle = (int)ArcTangente( dy-uy0, dx-ux0 ); + EndAngle = StAngle + m_Angle; + /* TO DO */ + break; + } +} + + +/***********************************************/ +void D_PAD::Draw3D(Pcb3D_GLCanvas * glcanvas) +/***********************************************/ +/* Dessin 3D des pads avec leur trou de percage +*/ +{ +int ii, ll, layer, nlmax; +int ux0,uy0, + dx,dx0,dy,dy0, + delta_cx, delta_cy, + xc, yc; +int angle, delta_angle; +int coord[4][2]; +double fcoord[8][2], f_hole_coord[8][2]; +float scale; +double zpos; +wxPoint shape_pos; +double x, y, r, w, hole, holeX, holeY; +double drillx, drilly; +bool Oncu, Oncmp, Both; +int color; + + scale = g_Parm_3D_Visu.m_BoardScale; + holeX = (double)m_Drill.x * scale / 2; + holeY = (double)m_Drill.y * scale / 2; + hole = MIN (holeX,holeY); + + /* calcul du centre des formes des pads : */ + shape_pos = ReturnShapePos(); + ux0 = shape_pos.x; + uy0 = shape_pos.y; + xc = ux0; + yc = uy0; + + /* le trace depend de la rotation de l'empreinte */ + dx = dx0 = m_Size.x >> 1 ; + dy = dy0 = m_Size.y >> 1 ; /* demi dim dx et dy */ + + angle = m_Orient; + drillx = m_Pos.x * scale; + drilly = m_Pos.y * scale; + /* Draw the pad hole (TODO: draw OBLONG hole)*/ + if ( holeX && holeY ) + { + SetGLColor(DARKGRAY); + Draw3D_FilledCylinder(drillx, -drilly, hole, g_Parm_3D_Visu.m_LayerZcoord[CMP_N], 0.0); + } + + glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis + nlmax = g_Parm_3D_Visu.m_Layers-1; + Oncu = (m_Masque_Layer & CUIVRE_LAYER) ? TRUE : FALSE; + Oncmp = (m_Masque_Layer & CMP_LAYER) ? TRUE : FALSE; + Both = Oncu && Oncmp; + switch (m_PadShape & 0x7F) + { + case CIRCLE : + x = xc * scale; + y = yc * scale; + r = (double)dx * scale; + for ( layer = CUIVRE_N; layer <= CMP_N; layer ++) + { + if (layer && (layer == nlmax) ) layer = CMP_N; + if ( (layer == CMP_N) && ! Oncmp ) continue; + if ( (layer == CUIVRE_N) && ! Oncu ) continue; + if ( (layer > CUIVRE_N) && (layer < CMP_N) && !Both) continue; + color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; + if ( color & ITEM_NOT_SHOW ) continue; + SetGLColor(color); + glNormal3f( 0.0, 0.0, (layer == CUIVRE_N) ? -1.0 : 1.0); + zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; + Draw3D_FilledCircle(x, -y, r, hole, zpos); + } + break; + + case OVALE : + /* calcul de l'entraxe de l'ellipse */ + if( dx > dy ) /* ellipse horizontale */ + { + delta_cx = dx - dy; delta_cy = 0; + w = m_Size.y * scale; + delta_angle = angle+900; + } + else /* ellipse verticale */ + { + delta_cx = 0; delta_cy = dy - dx; + w = m_Size.x * scale; + delta_angle = angle; + } + RotatePoint(&delta_cx, &delta_cy, angle); + { + double ox, oy, fx, fy; + ox = (double)(ux0 + delta_cx) * scale; + oy = (double)(uy0 + delta_cy) * scale; + fx = (double)(ux0 - delta_cx) * scale; + fy = (double)(uy0 - delta_cy) * scale; + for ( layer = CUIVRE_N; layer <= CMP_N; layer ++) + { + if (layer && (layer == nlmax) ) layer = CMP_N; + if ( (layer == CMP_N) && ! Oncmp ) continue; + if ( (layer == CUIVRE_N) && ! Oncu ) continue; + if ( (layer > CUIVRE_N) && (layer < CMP_N) && !Both) continue; + color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; + glNormal3f( 0.0, 0.0, (layer == CUIVRE_N) ? -1.0 : 1.0); + if ( color & ITEM_NOT_SHOW ) continue; + SetGLColor(color); + zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; + Draw3D_FilledSegmentWithHole(ox, -oy, fx, -fy, w, drillx, -drilly, hole, zpos); + } + } + break; + + case RECT : + case SPECIAL_PAD: + case TRAPEZE: + { + int ddx, ddy ; + ddx = m_DeltaSize.x >> 1 ; + ddy = m_DeltaSize.y >> 1 ; /* demi dim dx et dy */ + + coord[0][0] = - dx - ddy; + coord[0][1] = + dy + ddx; + + coord[1][0] = - dx + ddy; + coord[1][1] = - dy - ddx; + + coord[2][0] = + dx - ddy; + coord[2][1] = - dy + ddx; + + coord[3][0] = + dx + ddy; + coord[3][1] = + dy - ddx; + + for (ii = 0; ii < 4; ii++) + { + RotatePoint(&coord[ii][0],&coord[ii][1], angle); + coord[ii][0] += ux0; + coord[ii][1] += uy0; + ll = ii*2; + fcoord[ll][0] = coord[ii][0] * scale; + fcoord[ll][1] = coord[ii][1] * scale; + } + for (ii = 0; ii < 7; ii+=2) + { + ll = ii+2; if (ll > 7) ll -= 8; + fcoord[ii+1][0] = (fcoord[ii][0] + fcoord[ll][0])/2; + fcoord[ii+1][1] = (fcoord[ii][1] + fcoord[ll][1])/2; + } + for (ii = 0; ii < 8; ii++) + { + f_hole_coord[ii][0] = -hole*0.707; + f_hole_coord[ii][1] = hole*0.707; + RotatePoint(&f_hole_coord[ii][0], &f_hole_coord[ii][1], + angle -(ii * 450) ); + f_hole_coord[ii][0] += drillx; + f_hole_coord[ii][1] += drilly; + } + + for ( layer = CUIVRE_N; layer <= CMP_N; layer ++) + { + if (layer && (layer == nlmax) ) layer = CMP_N; + if ( (layer == CMP_N) && ! Oncmp ) continue; + if ( (layer == CUIVRE_N) && ! Oncu ) continue; + if ( (layer > CUIVRE_N) && (layer < CMP_N) && !Both) continue; + color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; + glNormal3f( 0.0, 0.0, (layer == CUIVRE_N) ? -1.0 : 1.0); + if ( color & ITEM_NOT_SHOW ) continue; + SetGLColor(color); + zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; + glBegin(GL_QUAD_STRIP); + for ( ii = 0; ii < 8; ii++ ) + { + glVertex3f( f_hole_coord[ii][0], -f_hole_coord[ii][1] , zpos); + glVertex3f( fcoord[ii][0], -fcoord[ii][1] , zpos); + } + glVertex3f( f_hole_coord[0][0], -f_hole_coord[0][1] , zpos); + glVertex3f( fcoord[0][0], -fcoord[0][1] , zpos); + glEnd(); + } + break; + + default: + break; + } + } + +} + +/*************************/ +void SetGLColor(int color) +/*************************/ +{ +double red, green,blue; +StructColors colordata = ColorRefs[color & MASKCOLOR]; + + red = colordata.m_Red / 255.0; + blue = colordata.m_Blue / 255.0; + green = colordata.m_Green / 255.0; + glColor3f(red, green,blue); +} + +/********************************************************/ +static void Draw3D_FilledCircle(double posx, double posy, + double rayon, double hole, double zpos) +/********************************************************/ +{ +int ii, slice = 16; +double x, y; + + glBegin(GL_QUAD_STRIP); + for ( ii = 0; ii <= slice; ii++ ) + { + x = hole; y = 0.0; + RotatePoint(&x, &y, ii * 225); + glVertex3f( x + posx, y + posy, zpos); + x = rayon; y = 0.0; + RotatePoint(&x, &y, ii * 225); + glVertex3f( x + posx, y + posy, zpos); + } + glEnd(); +} + +/*********************************************************/ +static void Draw3D_FilledCylinder(double posx, double posy, + double rayon, double height, double zpos) +/*********************************************************/ +{ +int ii; +double x, y; +#define NB_SEGM 12 +S3D_Vertex coords[4]; +double tmp = DataScale3D; + + DataScale3D = 1.0; //les coord sont deja a l'echelle pour Set_Object_Data(); + coords[0].x = coords[1].x = posx + rayon; + coords[0].y = coords[1].y = posy; + coords[0].z = coords[3].z = zpos; + coords[1].z = coords[2].z = zpos + height; + + for ( ii = 0; ii <= NB_SEGM; ii++ ) + { + x = rayon; y = 0.0; + RotatePoint(&x, &y, ii * (3600/NB_SEGM)); + coords[2].x = coords[3].x = posx + x; + coords[2].y = coords[3].y = posy + y; + Set_Object_Data(coords, 4 ); + coords[0].x = coords[2].x; + coords[0].y = coords[2].y; + coords[1].x = coords[3].x; + coords[1].y = coords[3].y; + } + glNormal3f( 0.0, 0.0, 1.0); // Normal is Z axis + DataScale3D = tmp; +} + +/*****************************************************************/ +static void Draw3D_FilledSegment(double startx, double starty, + double endx, double endy,double width, double zpos) +/*****************************************************************/ +/* trace un polygone semblable a un segment a bouts ronds +*/ +{ +double dx, dy, x, y, firstx=0, firsty=0; +int ii, angle; + + /* on va calculer les coordonnées du segment supposé horizontal, + puis tourner les cordonnes de l'angle voulu */ + + dx = endx - startx; dy = endy - starty; + angle = (int)(( atan2( dy, dx ) / M_PI * 1800)+0.5) ; + + RotatePoint(&dx, &dy, angle); // apres rotation: dx = longueur du segment + // dy = 0; + width /= 2; + + glBegin(GL_POLYGON); + // tracé de l'arrondi a droite (1er demi polygone a la fin du segment) + for ( ii = 0; ii <= 8; ii++ ) + { + x = 0.0; y =-width; + RotatePoint(&x, &y, -ii * 225); + x += dx; + RotatePoint(&x, &y, -angle); + glVertex3f( startx + x, starty+y, zpos); + if ( ii == 0 ) + { + firstx = startx + x; + firsty = starty + y; + } + } + // tracé de l'arrondi a gauche (2ieme demi polygone a l'origine du segment) + for ( ii = 0; ii <= 8; ii++ ) + { + int jj = ii * 225; + x = 0.0; y = width; + RotatePoint(&x, &y, -angle -jj); + glVertex3f( startx + x, starty+y, zpos); + } + + glVertex3f( firstx, firsty, zpos); + glEnd(); +} + +/*****************************************************************/ +static void Draw3D_FilledSegmentWithHole(double startx, double starty, + double endx, double endy,double width, + double holex, double holey, double holeradius, double zpos) +/*****************************************************************/ +/* trace un polygone semblable a un segment a bouts ronds avec trou +*/ +{ +double x, y, xin, yin; +double firstx=0, firsty=0, firstxin=0, firstyin=0; +int ii, angle, theta; + + /* on va calculer les coordonnées du segment supposé horizontal, + puis tourner les cordonnes de l'angle voulu + Tous des calculs se font avec startx, starty comme origine du tracé */ + + endx -= startx; endy -= starty; + holex -= startx; holey -= starty; + angle = (int)(( atan2( endy, endx ) / M_PI * 1800)+0.5) ; + + RotatePoint(&endx, &endy, angle); // apres rotation: endx = longueur du segment + // endy = 0; + RotatePoint(&holex, &holey, angle); + width /= 2; + + glBegin(GL_QUAD_STRIP); + // tracé de l'arrondi a droite (1er demi polygone a la fin du segment) + // autour du demi-trou de percage + for ( ii = 0; ii <= 8; ii++ ) + { + x = 0.0; y = -width; + xin = 0.0; yin = - holeradius; + theta = -ii * 225; + RotatePoint(&x, &y, theta); + RotatePoint(&xin, &yin, theta); + x += endx; + RotatePoint(&x, &y, -angle); + xin += holex; + RotatePoint(&xin, &yin, -angle); + glVertex3f( startx + xin, starty+yin, zpos); + glVertex3f( startx + x, starty+y, zpos); + if ( ii == 0 ) // Memorisation du point de départ du tracé + { + firstx = startx + x; + firsty = starty + y; + firstxin = startx + xin; + firstyin = starty + yin; + } + } + // tracé de l'arrondi a gauche (2ieme demi polygone a l'origine du segment) + for ( ii = 0; ii <= 8; ii++ ) + { + theta = - ii * 225; + x = 0.0; y = width; + RotatePoint(&x, &y, -angle + theta); + xin = 0.0; yin = holeradius; + RotatePoint(&xin, &yin, theta); + xin += holex; + RotatePoint(&xin, &yin, -angle); + glVertex3f( startx + xin,starty + yin, zpos); + glVertex3f( startx + x, starty + y, zpos); + } + + glVertex3f( firstxin, firstyin, zpos); + glVertex3f( firstx, firsty, zpos); + glEnd(); +} + diff --git a/3d-viewer/3d_frame.cpp b/3d-viewer/3d_frame.cpp new file mode 100644 index 0000000000..5a28fe2228 --- /dev/null +++ b/3d-viewer/3d_frame.cpp @@ -0,0 +1,322 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: 3d_frame.cpp +///////////////////////////////////////////////////////////////////////////// + + +#ifdef __GNUG__ +#pragma implementation +#pragma interface +#endif + + +#include "fctsys.h" + +#include + +#if !wxUSE_GLCANVAS +#error Please set wxUSE_GLCANVAS to 1 in setup.h. +#endif + +#include "bitmaps.h" +#include "id.h" + +#define VIEWER_MAIN +#include "3d_viewer.h" +#include "trackball.h" + + +BEGIN_EVENT_TABLE(WinEDA3D_DrawFrame, wxFrame) + EVT_TOOL_RANGE(ID_ZOOM_PLUS_BUTT, ID_ZOOM_PAGE_BUTT, + WinEDA3D_DrawFrame::Process_Zoom) + EVT_TOOL_RANGE(ID_START_COMMAND_3D, ID_END_COMMAND_3D, + WinEDA3D_DrawFrame::Process_Special_Functions) + EVT_MENU(wxID_EXIT, WinEDA3D_DrawFrame::Exit3DFrame) + EVT_MENU(ID_MENU_SCREENCOPY_PNG, WinEDA3D_DrawFrame::Process_Special_Functions) + EVT_MENU(ID_MENU_SCREENCOPY_JPEG, WinEDA3D_DrawFrame::Process_Special_Functions) + EVT_CLOSE(WinEDA3D_DrawFrame::OnCloseWindow) +END_EVENT_TABLE() + +/*******************************************************************/ +WinEDA3D_DrawFrame::WinEDA3D_DrawFrame(WinEDA_BasePcbFrame * parent, + WinEDA_App *app_parent, const wxString& title ): + wxFrame(parent, DISPLAY3D_FRAME, title, + wxPoint(-1,-1), wxSize(-1,-1) ) +/*******************************************************************/ +{ + m_FrameName = wxT("Frame3D"); + m_Canvas = NULL; + m_Parent = parent; + m_ParentAppl = app_parent; + m_HToolBar = NULL; + m_VToolBar = NULL; + m_InternalUnits = 10000; // Unites internes = 1/10000 inch + + // Give it an icon + SetIcon(wxICON(icon_w3d)); + + GetSettings(); + SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y); + // Create the status line +int dims[5] = { -1, 100, 100, 100, 140}; + CreateStatusBar(5); + SetStatusWidths(5,dims); + ReCreateMenuBar(); + ReCreateHToolbar(); +// ReCreateAuxiliaryToolbar(); + ReCreateVToolbar(); + + // Make a Pcb3D_GLCanvas + + m_Canvas = new Pcb3D_GLCanvas(this, -1, gl_attrib ); + /* init OpenGL once */ + m_Canvas->InitGL(); +} + + + +/***********************************************************/ +void WinEDA3D_DrawFrame::Exit3DFrame(wxCommandEvent& event) +/***********************************************************/ +{ + Close(TRUE); +} + +/***********************************************************/ +void WinEDA3D_DrawFrame::OnCloseWindow(wxCloseEvent & Event) +/***********************************************************/ +{ + SaveSettings(); + if ( m_Parent ) + { + m_Parent->m_Draw3DFrame = NULL; + } + Destroy(); +} + + +/******************************************/ +void WinEDA3D_DrawFrame::GetSettings(void) +/******************************************/ +{ +wxString text; +wxConfig * Config = m_ParentAppl->m_EDA_Config; // Current config used by application + + if( m_ParentAppl->m_EDA_Config ) + { + text = m_FrameName + wxT("Pos_x"); + Config->Read(text, &m_FramePos.x); + text = m_FrameName + wxT("Pos_y"); + Config->Read(text, &m_FramePos.y); + text = m_FrameName + wxT("Size_x"); + Config->Read(text, &m_FrameSize.x, 600); + text = m_FrameName + wxT("Size_y"); + Config->Read(text, &m_FrameSize.y, 400); + Config->Read(wxT("BgColor_Red"), &g_Parm_3D_Visu.m_BgColor.m_Red, 0.0); + Config->Read(wxT("BgColor_Green"), &g_Parm_3D_Visu.m_BgColor.m_Green, 0.0); + Config->Read(wxT("BgColor_Blue"), &g_Parm_3D_Visu.m_BgColor.m_Blue, 0.0); + } +#ifdef __WXMAC__ + // for macOSX, the window must be below system (macOSX) toolbar + if ( m_FramePos.y < GetMBarHeight() ) m_FramePos.y = GetMBarHeight(); +#endif +} + +/*******************************************/ +void WinEDA3D_DrawFrame::SaveSettings(void) +/*******************************************/ +{ +wxString text; +wxConfig * Config = m_ParentAppl->m_EDA_Config; // Current config used by application + + if( ! Config ) return; + + Config->Write(wxT("BgColor_Red"), g_Parm_3D_Visu.m_BgColor.m_Red); + Config->Write(wxT("BgColor_Green"), g_Parm_3D_Visu.m_BgColor.m_Green); + Config->Write(wxT("BgColor_Blue"), g_Parm_3D_Visu.m_BgColor.m_Blue); + + if( IsIconized() ) return; + + m_FrameSize = GetSize(); + m_FramePos = GetPosition(); + + text = m_FrameName + wxT("Pos_x"); + Config->Write(text, (long)m_FramePos.x); + text = m_FrameName + wxT("Pos_y"); + Config->Write(text, (long)m_FramePos.y); + text = m_FrameName + wxT("Size_x"); + Config->Write(text, (long)m_FrameSize.x); + text = m_FrameName + wxT("Size_y"); + Config->Write(text, (long)m_FrameSize.y); +} + + +/***********************************************************/ +void WinEDA3D_DrawFrame::Process_Zoom(wxCommandEvent& event) +/***********************************************************/ +{ +int ii; + switch(event.GetId()) + { + case ID_ZOOM_PAGE_BUTT: + for ( ii = 0; ii < 4; ii++ ) g_Parm_3D_Visu.m_Rot[ii] = 0.0; + g_Parm_3D_Visu.m_Zoom = 1.0; + g_Draw3d_dx = g_Draw3d_dy = 0; + trackball(g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); + break; + + case ID_ZOOM_PLUS_BUTT: + g_Parm_3D_Visu.m_Zoom /= 1.2; + if ( g_Parm_3D_Visu.m_Zoom <= 0.01) + g_Parm_3D_Visu.m_Zoom = 0.01; + break; + + case ID_ZOOM_MOINS_BUTT: + g_Parm_3D_Visu.m_Zoom *= 1.2; + break; + + case ID_ZOOM_REDRAW_BUTT: + break; + + default: + return; + } + m_Canvas->DisplayStatus(); + m_Canvas->Refresh(FALSE); +} + + + +/************************************************************************/ +void WinEDA3D_DrawFrame::OnLeftClick(wxDC * DC, const wxPoint& MousePos) +/************************************************************************/ +{ +} + + +/*******************************************************************************/ +void WinEDA3D_DrawFrame::OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu) +/*******************************************************************************/ +{ +} + +/************************************/ +int WinEDA3D_DrawFrame::BestZoom(void) +/************************************/ +// Retourne le meilleur zoom +{ + return 1; +} + + +/*******************************************************************/ +void WinEDA3D_DrawFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg) +/*******************************************************************/ +{ +} + + +/************************************************************************/ +void WinEDA3D_DrawFrame::Process_Special_Functions(wxCommandEvent& event) +/************************************************************************/ +{ +#define ROT_ANGLE 10.0 + + switch(event.GetId()) + { + case ID_RELOAD3D_BOARD: + NewDisplay(); + break; + + case ID_ROTATE3D_X_POS: + g_Parm_3D_Visu.m_ROTX += ROT_ANGLE; + break; + + case ID_ROTATE3D_X_NEG: + g_Parm_3D_Visu.m_ROTX -= ROT_ANGLE; + break; + + case ID_ROTATE3D_Y_POS: + g_Parm_3D_Visu.m_ROTY += ROT_ANGLE; + break; + + case ID_ROTATE3D_Y_NEG: + g_Parm_3D_Visu.m_ROTY -= ROT_ANGLE; + break; + + case ID_ROTATE3D_Z_POS: + g_Parm_3D_Visu.m_ROTZ += ROT_ANGLE; + break; + + case ID_ROTATE3D_Z_NEG: + g_Parm_3D_Visu.m_ROTZ -= ROT_ANGLE; + break; + + case ID_MOVE3D_LEFT: + m_Canvas->SetView3D(WXK_LEFT); + return; + + case ID_MOVE3D_RIGHT: + m_Canvas->SetView3D(WXK_RIGHT); + return; + + case ID_MOVE3D_UP: + m_Canvas->SetView3D(WXK_UP); + return; + + case ID_MOVE3D_DOWN: + m_Canvas->SetView3D(WXK_DOWN); + return; + + case ID_TOOL_SCREENCOPY_TOCLIBBOARD: + case ID_MENU_SCREENCOPY_PNG: + case ID_MENU_SCREENCOPY_JPEG: + m_Canvas->TakeScreenshot(event); + break; + + case ID_MENU3D_BGCOLOR_SELECTION: + Set3DBgColor(); + return; + + default: + wxMessageBox( + wxT("WinEDA3D_DrawFrame::Process_Special_Functions() error: unknown command")); + return; + } + m_Canvas->DisplayStatus(); + m_Canvas->Refresh(FALSE); +} + + +/*****************************************/ +void WinEDA3D_DrawFrame::NewDisplay(void) +/*****************************************/ +{ + m_Canvas->ClearLists(); + m_Canvas->InitGL(); + m_Canvas->DisplayStatus(); + m_Canvas->Refresh(FALSE); +} + + +/******************************************/ +void WinEDA3D_DrawFrame::Set3DBgColor(void) +/******************************************/ +/* called to set the background color of the 3D scene +*/ +{ +S3D_Color color; +wxColour newcolor, oldcolor; + + oldcolor.Set((int) round(g_Parm_3D_Visu.m_BgColor.m_Red*255), + (int) round(g_Parm_3D_Visu.m_BgColor.m_Green*255), + (int) round(g_Parm_3D_Visu.m_BgColor.m_Blue*255)); + + newcolor = wxGetColourFromUser(this, oldcolor); + if ( newcolor != oldcolor ) + { + g_Parm_3D_Visu.m_BgColor.m_Red = (double) newcolor.Red() / 255.0; + g_Parm_3D_Visu.m_BgColor.m_Green = (double) newcolor.Green() / 255.0; + g_Parm_3D_Visu.m_BgColor.m_Blue = (double) newcolor.Blue() / 255.0; + NewDisplay(); + } +} diff --git a/3d-viewer/3d_read_mesh.cpp b/3d-viewer/3d_read_mesh.cpp new file mode 100644 index 0000000000..10b9c5fe73 --- /dev/null +++ b/3d-viewer/3d_read_mesh.cpp @@ -0,0 +1,518 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: 3d_read_mesh.cpp +///////////////////////////////////////////////////////////////////////////// + + +#ifdef __GNUG__ +#pragma implementation +#pragma interface +#endif + +#include "fctsys.h" + +#include "common.h" +#include "macros.h" + + +#include "3d_struct.h" +#include "3d_viewer.h" + + +/***********************************/ +int Struct3D_Master:: ReadData(void) +/************************************/ +{ +char line[1024], *text; +wxString fullfilename; +FILE * file; +int LineNum = 0; + + if ( m_Shape3DName.IsEmpty() ) + { + return 1; + } + + if ( wxIsAbsolutePath(m_Shape3DName) ) fullfilename.Empty(); + else fullfilename = g_RealLibDirBuffer + LIB3D_PATH; + fullfilename += m_Shape3DName; +#if defined (__WINDOWS__) + fullfilename.Replace(UNIX_STRING_DIR_SEP,WIN_STRING_DIR_SEP); +#else +#if defined (__UNIX__) + fullfilename.Replace(WIN_STRING_DIR_SEP,UNIX_STRING_DIR_SEP); +#endif +#endif + + file = wxFopen( fullfilename, wxT("rt") ); + if ( file == NULL ) + { + return -1; + } + + while ( GetLine(file, line, &LineNum, 512) ) + { + text = strtok(line, " \t\n\r"); + if ( stricmp (text, "DEF" ) == 0 ) + { + while ( GetLine(file, line, &LineNum, 512) ) + { + text = strtok(line, " \t\n\r"); + if ( text == NULL ) continue; + if ( * text == '}' ) break; + if ( stricmp (text, "children") == 0 ) + { + ReadChildren(file, &LineNum); + } + } + } + } + + fclose (file); + return 0; +} + +/*********************************************************/ +int Struct3D_Master:: ReadMaterial(FILE * file, int *LineNum) +/*********************************************************/ +/* +analyse la description du type: + material DEF yellow Material { + diffuseColor 1.00000 1.00000 0.00000e+0 + emissiveColor 0.00000e+0 0.00000e+0 0.00000e+0 + specularColor 1.00000 1.00000 1.00000 + ambientIntensity 1.00000 + transparency 0.00000e+0 + shininess 1.00000 + } +ou du type: + material USE yellow +*/ +{ +char line[512], * text, * command; +wxString mat_name; +S3D_Material * material = NULL; + + // Lecture de la commande: + command = strtok(NULL, " \t\n\r"); + text = strtok(NULL, " \t\n\r"); + mat_name = CONV_FROM_UTF8(text); + if ( stricmp(command, "USE") == 0 ) + { + + for ( material = m_Materials; material != NULL; + material = (S3D_Material *) material->Pnext) + { + if ( material->m_Name == mat_name) + { + material->SetMaterial(); + return 1; + } + } + + printf("ReadMaterial error: material not found\n"); + return 0; + } + + if ( stricmp(command, "DEF") == 0 ) + { + material = new S3D_Material(this, mat_name); + material->Pnext = m_Materials; + m_Materials = material; + while ( GetLine(file, line, LineNum, 512) ) + { + text = strtok(line," \t\n\r"); + if ( text == NULL ) continue; + if ( text[0] == '}' ) + { + material->SetMaterial(); + return 0; + } + if ( stricmp (text, "diffuseColor") == 0 ) + { + text = strtok(NULL," \t\n\r"); + material->m_DiffuseColor.x = atof(from_point(text)); + text = strtok(NULL," \t\n\r"); + material->m_DiffuseColor.y = atof(from_point(text)); + text = strtok(NULL," \t\n\r"); + material->m_DiffuseColor.z = atof(from_point(text)); + } + else if ( stricmp (text, "emissiveColor") == 0 ) + { + text = strtok(NULL," \t\n\r"); + material->m_EmissiveColor.x = atof(from_point(text)); + text = strtok(NULL," \t\n\r"); + material->m_EmissiveColor.y = atof(from_point(text)); + text = strtok(NULL," \t\n\r"); + material->m_EmissiveColor.z = atof(from_point(text)); + } + else if ( strnicmp (text, "specularColor", 13 ) == 0 ) + { + text = strtok(NULL," \t\n\r"); + material->m_SpecularColor.x = atof(from_point(text)); + text = strtok(NULL," \t\n\r"); + material->m_SpecularColor.y = atof(from_point(text)); + text = strtok(NULL," \t\n\r"); + material->m_SpecularColor.z = atof(from_point(text)); + } + else if ( strnicmp (text, "ambientIntensity", 16 ) == 0 ) + { + text = strtok(NULL," \t\n\r"); + material->m_AmbientIntensity = atof(from_point(text)); + } + else if ( strnicmp (text, "transparency", 12 ) == 0 ) + { + text = strtok(NULL," \t\n\r"); + material->m_Transparency = atof(from_point(text)); + } + else if ( strnicmp (text, "shininess", 9 ) == 0 ) + { + text = strtok(NULL," \t\n\r"); + material->m_Shininess = atof(from_point(text)); + } + } + } + return -1; +} + + +/**********************************************************/ +int Struct3D_Master::ReadChildren(FILE * file, int *LineNum) +/***********************************************************/ +{ +char line[1024], *text; + + while ( GetLine(file, line, LineNum, 512) ) + { + text = strtok(line, " \t\n\r"); + if ( * text == ']' ) return 0; + if ( * text == ',' ) continue; + + if ( stricmp (text, "Shape" ) == 0 ) + { + ReadShape(file, LineNum); + } + else + { + printf ("ReadChildren error line %d <%s> \n", *LineNum, text); + break; + } + } + return 1; +} + +/********************************************************/ +int Struct3D_Master::ReadShape(FILE * file, int *LineNum) +/********************************************************/ +{ +char line[1024], *text; +int err = 1; + + while ( GetLine(file, line, LineNum, 512) ) + { + text = strtok(line, " \t\n\r"); + if ( * text == '}' ) + { + err = 0; + break; + } + + if ( stricmp (text, "appearance" ) == 0 ) + { + ReadAppearance(file, LineNum); + } + else if ( stricmp (text, "geometry" ) == 0 ) + { + ReadGeometry(file, LineNum); + } + else + { + printf ("ReadShape error line %d <%s> \n", *LineNum, text); + break; + } + } + + return err; +} + +/*************************************************************/ +int Struct3D_Master::ReadAppearance(FILE * file, int *LineNum) +/*************************************************************/ +{ +char line[1024], *text; +int err = 1; + + while ( GetLine(file, line, LineNum, 512) ) + { + text = strtok(line, " \t\n\r"); + if ( * text == '}' ) + { + err = 0; break; + } + + if ( stricmp (text, "material" ) == 0 ) + { + ReadMaterial(file, LineNum ); + } + else + { + printf ("ReadAppearance error line %d <%s> \n", *LineNum, text); + break; + } + } + + return err; +} + +#define BUFSIZE 2000 + +/************************************************************************************/ +double * ReadCoordsList(FILE * file, char * text_buffer, int * bufsize, int *LineNum) +/************************************************************************************/ +/* Read a coordinate liste like: + coord Coordinate { point [ + -5.24489 6.57640e-3 -9.42129e-2, + -5.11821 6.57421e-3 0.542654, + -3.45868 0.256565 1.32000 ] } + or: + normal Normal { vector [ + 0.995171 -6.08102e-6 9.81541e-2, + 0.923880 -4.09802e-6 0.382683, + 0.707107 -9.38186e-7 0.707107] + } + + Return the coordinate list + text_buffer contains the first line of this node : + "coord Coordinate { point [" + */ +{ +double * data_list = NULL; +unsigned int ii = 0, jj = 0, nn = BUFSIZE; +char * text; +bool HasData = FALSE; +bool StartData = FALSE; +bool EndData = FALSE; +bool EndNode = FALSE; +char string_num[512]; + + text = text_buffer; + while ( !EndNode ) + { + if ( * text == 0 ) // Needs data ! + { + text = text_buffer; + GetLine(file, text_buffer, LineNum, 512); + } + + while ( !EndNode && *text ) + { + switch ( *text ) + { + case '[': + StartData = TRUE; + jj = 0; string_num[jj] = 0; + data_list = (double *) MyZMalloc(nn * sizeof(double) ); + break; + + case '}': + EndNode = TRUE; + break; + + case ']': + case '\t': + case ' ': + case ',': + jj = 0; + if ( ! StartData || !HasData) break; + data_list[ii] = atof(from_point(string_num)); + string_num[jj] = 0; + ii++; + if ( ii >= nn ) + { + nn *= 2; + data_list = (double *) realloc(data_list, (nn * sizeof(double)) ); + } + HasData = FALSE; + if ( *text == ']' ) + { + StartData = FALSE; + EndData = TRUE; + } + break; + + default: + if ( ! StartData ) break; + if ( jj >= sizeof(string_num) ) break; + string_num[jj] = *text; + jj++; string_num[jj] = 0; + HasData = TRUE; + break; + } + text++; + } + } + + if ( data_list ) + data_list = (double *) realloc(data_list, (ii * sizeof(double)) ); + if ( bufsize ) *bufsize = ii; + return data_list; +} + +/***********************************************************/ +int Struct3D_Master::ReadGeometry(FILE * file, int *LineNum) +/***********************************************************/ +{ +char line[1024], buffer[1024], *text; +int err = 1; +int nn = BUFSIZE; +double * points = NULL; +int * index = NULL; + + while ( GetLine(file, line, LineNum, 512) ) + { + strcpy(buffer,line); + text = strtok(buffer, " \t\n\r"); + if ( * text == '}' ) + { + err = 0; break; + } + + if ( stricmp (text, "normalPerVertex" ) == 0 ) + { + text = strtok(NULL, " ,\t\n\r"); + if( stricmp (text, "TRUE") == 0 ) + { + } + else + { + } + continue; + } + + if ( stricmp (text, "colorPerVertex" ) == 0 ) + { + text = strtok(NULL, " ,\t\n\r"); + if( stricmp (text, "TRUE") == 0 ) + { + } + else + { + } + continue; + } + + if ( stricmp (text, "normal" ) == 0 ) + { + int coord_number; + double * buf_points = ReadCoordsList(file, line, &coord_number, LineNum); + continue; + free(buf_points); + continue; + } + if ( stricmp (text, "normalIndex" ) == 0 ) + { + while ( GetLine(file, line, LineNum, 512) ) + { + text = strtok(line, " ,\t\n\r"); + while ( text ) + { + if ( *text == ']') break; + text = strtok(NULL, " ,\t\n\r"); + } + if ( text && (*text == ']') ) break; + } + continue; + } + + if ( stricmp (text, "color" ) == 0 ) + { + int coord_number; + double * buf_points = ReadCoordsList(file, line, &coord_number, LineNum); + continue; + free(buf_points); + continue; + } + if ( stricmp (text, "colorIndex" ) == 0 ) + { + while ( GetLine(file, line, LineNum, 512) ) + { + text = strtok(line, " ,\t\n\r"); + while ( text ) + { + if ( *text == ']') break; + text = strtok(NULL, " ,\t\n\r"); + } + if ( text && (*text == ']') ) break; + } + continue; + } + + if ( stricmp (text, "coord" ) == 0 ) + { + int coord_number; + points = ReadCoordsList(file, line, &coord_number, LineNum); + } + else if ( stricmp (text, "coordIndex" ) == 0 ) + { + index = (int *) MyMalloc(nn * sizeof(int) ); + S3D_Vertex * coords = + (S3D_Vertex *) MyMalloc(nn * sizeof(S3D_Vertex) ); + while ( GetLine(file, line, LineNum, 512) ) + { + int coord_count = 0, jj; + text = strtok(line, " ,\t\n\r"); + while ( text ) + { + if ( *text == ']') break; + jj = atoi(from_point(text)); + if ( jj < 0 ) + { + S3D_Vertex * curr_coord = coords; + for ( jj = 0; jj < coord_count; jj ++ ) + { + int kk = index[jj] * 3; + curr_coord->x = points[kk]; + curr_coord->y = points[kk+1]; + curr_coord->z = points[kk+2]; + curr_coord++; + } + Set_Object_Coords(coords, coord_count ); + Set_Object_Data(coords, coord_count ); + coord_count = 0; + } + else + { + index[coord_count++] = jj; + } + text = strtok(NULL, " ,\t\n\r"); + } + if ( text && (*text == ']') ) break; + } + free(index); + free(coords); + } + else + { + printf ("ReadGeometry error line %d <%s> \n", *LineNum, text); + break; + } + } + if ( points ) free (points); + + return err; +} + + + +/*********************************************************/ +int Struct3D_Shape:: ReadData(FILE * file, int *LineNum) +/*********************************************************/ +{ +char line[512]; + + while ( GetLine(file, line, LineNum, 512) ) + { + } + + return -1; +} + diff --git a/3d-viewer/3d_struct.h b/3d-viewer/3d_struct.h new file mode 100644 index 0000000000..05d70886d9 --- /dev/null +++ b/3d-viewer/3d_struct.h @@ -0,0 +1,136 @@ + /********************************************************/ + /* 3d_struct.h : definition des structures de donnees */ + /* pour la representation 3D des modules */ + /********************************************************/ + +#ifndef STRUCT_3D_H +#define STRUCT_3D_H + +#include "base_struct.h" + +/* 3D modeler units -> PCB units conversion scale: + 1 "3D unit modeler" = 1 unit wings3d = 2,54 mm = 0.1 inch */ +#define UNITS3D_TO_UNITSPCB 1000 + + +class Struct3D_Master; +class Struct3D_Shape; + +class S3D_Color /* This is a 3D color (R, G, G) 3 floats range 0 to 1.0*/ +{ +public: + double m_Red, m_Green, m_Blue; +public: + S3D_Color(void) + { + m_Red = m_Green = m_Blue = 0; + } +}; + +class S3D_Vertex /* This is a 3D coordinate (3 float numbers: x,y,z coordinates)*/ +{ +public: + double x, y, z; +public: + S3D_Vertex(void); +}; + +class S3D_Material: public EDA_BaseStruct /* openGL "material" data*/ +{ +public: + wxString m_Name; + S3D_Vertex m_DiffuseColor; + S3D_Vertex m_EmissiveColor; + S3D_Vertex m_SpecularColor; + float m_AmbientIntensity; + float m_Transparency; + float m_Shininess; + +public: + S3D_Material(Struct3D_Master * father, const wxString & name); + void SetMaterial(void); +}; + +/*******************************************/ +class Struct3D_Master: public EDA_BaseStruct +/*******************************************/ +/* Master structure for a 3D item description */ +{ +public: + wxString m_Shape3DName; /* 3D shape name in 3D library */ + S3D_Vertex m_MatScale; + S3D_Vertex m_MatRotation; + S3D_Vertex m_MatPosition; + Struct3D_Shape * m_3D_Drawings; + S3D_Material *m_Materials; + +public: + + Struct3D_Master(EDA_BaseStruct * StructFather); + ~Struct3D_Master(void); + + void Copy(Struct3D_Master * pattern); + int ReadData(void); + int ReadMaterial(FILE * file, int *LineNum); + int ReadChildren(FILE * file, int *LineNum); + int ReadShape(FILE * file, int *LineNum); + int ReadAppearance(FILE * file, int *LineNum); + int ReadGeometry(FILE * file, int *LineNum); + void Set_Object_Coords(S3D_Vertex * coord, int nbcoord ); + +}; + + +/*********************************************/ +class Struct3D_Shape: public EDA_BaseStruct +/*********************************************/ +/* decrit une forme complexe 3D */ +{ +public: + S3D_Vertex * m_3D_Coord; + int * m_3D_CoordIndex; + int m_3D_Points; + +public: + + Struct3D_Shape(EDA_BaseStruct * StructFather); + ~Struct3D_Shape(void); + + int ReadData(FILE * file, int *LineNum); +}; + + + +/*****************************************************************/ +/* Classe pour afficher et editer un Vertex (triplet de valeurs),*/ +/* en INCHES ou MM ou sans unites */ +/*****************************************************************/ +/* internal_unit is the internal unit number by inch: + - 1000 for EESchema + - 10000 for PcbNew +*/ +class WinEDA_VertexCtrl +{ +private: + int m_Units; + int m_Internal_Unit; + wxTextCtrl * m_XValueCtrl, * m_YValueCtrl, * m_ZValueCtrl; + wxStaticText * m_Text; + +public: + // Constructor and destructor + WinEDA_VertexCtrl(wxWindow *parent, const wxString & title, + wxBoxSizer * BoxSizer, + int units, int internal_unit); + + ~WinEDA_VertexCtrl(void); + + S3D_Vertex GetValue(void); + void SetValue(S3D_Vertex vertex); + void Enable(bool enbl); + void SetToolTip(const wxString & text); +}; + + + +#endif /* STRUCT_3D_H */ diff --git a/3d-viewer/3d_toolbar.cpp b/3d-viewer/3d_toolbar.cpp new file mode 100644 index 0000000000..6443dd55dc --- /dev/null +++ b/3d-viewer/3d_toolbar.cpp @@ -0,0 +1,129 @@ + /*******************************************************************/ + /* 3d_toolbar.cpp: construction des tool bars de la frame visu 3d */ + /*******************************************************************/ + +#include "fctsys.h" +#include "macros.h" + +#include "bitmaps3d.h" +#include "bitmaps.h" + +#include "id.h" + +#define BITMAP wxBitmap +#include "3d_viewer.h" + + +/*********************************************/ +void WinEDA3D_DrawFrame::ReCreateHToolbar(void) +/*********************************************/ +{ + + if ( m_HToolBar != NULL ) + { // simple mise a jour de la liste des fichiers anciens + SetToolbars(); + return; + } + + + m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE); + SetToolBar(m_HToolBar); + + // Set up toolbar + m_HToolBar->AddTool(ID_RELOAD3D_BOARD, wxEmptyString, BITMAP(import3d_xpm), + _("Reload board")); +#ifdef __WINDOWS__ // do not work properly under linux + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_TOOL_SCREENCOPY_TOCLIBBOARD, wxEmptyString, BITMAP(copy_button), + _("Copy 3D Image to Clipboard")); +#endif + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP(zoom_in_xpm), + _("zoom + (F1)")); + + m_HToolBar->AddTool(ID_ZOOM_MOINS_BUTT, wxEmptyString, BITMAP(zoom_out_xpm), + _("zoom - (F2)")); + + m_HToolBar->AddTool(ID_ZOOM_REDRAW_BUTT, wxEmptyString, BITMAP(repaint_xpm), + _("redraw (F3)")); + + m_HToolBar->AddTool(ID_ZOOM_PAGE_BUTT, wxEmptyString, BITMAP(zoom_optimal_xpm), + _("auto zoom")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_ROTATE3D_X_POS, wxEmptyString, BITMAP(rotate_pos_X_xpm), + _("Rotate X ->") ); + + m_HToolBar->AddTool(ID_ROTATE3D_X_NEG, wxEmptyString, BITMAP(rotate_neg_X_xpm), + _("Rotate X <-") ); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_ROTATE3D_Y_POS, wxEmptyString, BITMAP(rotate_pos_Y_xpm), + _("Rotate Y ->") ); + m_HToolBar->AddTool(ID_ROTATE3D_Y_NEG, wxEmptyString, BITMAP(rotate_neg_Y_xpm), + _("Rotate Y <-") ); + + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_ROTATE3D_Z_POS, wxEmptyString, BITMAP(rotate_pos_Z_xpm), + _("Rotate Z ->") ); + + m_HToolBar->AddTool(ID_ROTATE3D_Z_NEG, wxEmptyString, BITMAP(rotate_neg_Z_xpm), + _("Rotate Z <-") ); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_MOVE3D_LEFT, wxEmptyString, BITMAP(left_xpm), + _("Move left <-") ); + + m_HToolBar->AddTool(ID_MOVE3D_RIGHT, wxEmptyString, BITMAP(right_xpm), + _("Move right ->") ); + + m_HToolBar->AddTool(ID_MOVE3D_UP, wxEmptyString, BITMAP(up_xpm), + _("Move Up ^") ); + + m_HToolBar->AddTool(ID_MOVE3D_DOWN, wxEmptyString, BITMAP(down_xpm), + _("Move Down") ); + + + m_HToolBar->Realize(); + +// SetToolbars(); +} + +/*********************************************/ +void WinEDA3D_DrawFrame::ReCreateVToolbar(void) +/*********************************************/ +{ +} + +/**********************************************/ +void WinEDA3D_DrawFrame::ReCreateMenuBar(void) +/**********************************************/ +{ + wxMenuBar *menuBar = new wxMenuBar; + + wxMenu *fileMenu = new wxMenu; + menuBar->Append(fileMenu, _("&File") ); + + fileMenu->Append(ID_MENU_SCREENCOPY_PNG, _("Create Image (png format)")); + fileMenu->Append(ID_MENU_SCREENCOPY_JPEG, _("Create Image (jpeg format)")); + fileMenu->AppendSeparator(); + fileMenu->Append(wxID_EXIT, _("&Exit")); + + wxMenu *referencesMenu = new wxMenu; + menuBar->Append(referencesMenu, _("&Preferences") ); + + ADD_MENUITEM(referencesMenu, ID_MENU3D_BGCOLOR_SELECTION, + _("Choose background color"), palette_xpm) + + + SetMenuBar(menuBar); +} + +/*****************************************/ +void WinEDA3D_DrawFrame::SetToolbars(void) +/*****************************************/ +{ +} + diff --git a/3d-viewer/3d_viewer.h b/3d-viewer/3d_viewer.h new file mode 100644 index 0000000000..c888b4190e --- /dev/null +++ b/3d-viewer/3d_viewer.h @@ -0,0 +1,172 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: 3d_viewer.h +///////////////////////////////////////////////////////////////////////////// +#if !wxUSE_GLCANVAS +#error Please set wxUSE_GLCANVAS to 1 in setup.h. +#endif + +#include "wx/glcanvas.h" + +#ifdef __WXMAC__ +# ifdef __DARWIN__ +# include +# include +# else +# include +# include +# endif +#else +# include +# include +#endif + +#ifdef VIEWER_MAIN +#define global_3d +#else +#define global_3d extern +#endif + +#include "pcbstruct.h" +#include "3d_struct.h" + +#define LIB3D_PATH wxT("packages3d/") + +class Pcb3D_GLCanvas; +class WinEDA3D_DrawFrame; +class Info_3D_Visu; +class S3D_Vertex; +class SEGVIA; + + +#define m_ROTX m_Rot[0] +#define m_ROTY m_Rot[1] +#define m_ROTZ m_Rot[2] + +/* information needed to display 3D board */ +class Info_3D_Visu +{ +public: + float m_Beginx, m_Beginy; /* position of mouse */ + float m_Quat[4]; /* orientation of object */ + float m_Rot[4]; /* man rotation of object */ + float m_Zoom; /* field of view in degrees */ + S3D_Color m_BgColor; + wxPoint m_BoardPos; + wxSize m_BoardSize; + int m_Layers; + EDA_BoardDesignSettings * m_BoardSettings; // Link to current board design settings + float m_Epoxy_Width; /* Epoxy tickness (normalized) */ + + float m_BoardScale; /* Normalisation scale for coordinates: + when scaled tey are between -1.0 and +1.0 */ + float m_LayerZcoord[32]; +public: + Info_3D_Visu(void); + ~Info_3D_Visu(void); +}; + + +class Pcb3D_GLCanvas: public wxGLCanvas +{ +public: + WinEDA3D_DrawFrame * m_Parent; + +private: + bool m_init; + GLuint m_gllist; + +public: + Pcb3D_GLCanvas(WinEDA3D_DrawFrame *parent, const wxWindowID id = -1, + int* gl_attrib = NULL); + ~Pcb3D_GLCanvas(void); + + void ClearLists(void); + + void OnPaint(wxPaintEvent& event); + void OnSize(wxSizeEvent& event); + void OnEraseBackground(wxEraseEvent& event); + void OnChar(wxKeyEvent& event); + void OnMouseEvent(wxMouseEvent& event); + void OnRightClick(wxMouseEvent& event); + void OnPopUpMenu(wxCommandEvent & event); + void TakeScreenshot(wxCommandEvent & event); + void SetView3D(int keycode); + void DisplayStatus(void); + void Redraw(void); + GLuint DisplayCubeforTest(void); + + void OnEnterWindow( wxMouseEvent& event ); + + void Render( void ); + GLuint CreateDrawGL_List(void); + void InitGL(void); + void SetLights(void); + void Draw3D_Track(TRACK * track); + void Draw3D_Via(SEGVIA * via); + void Draw3D_DrawSegment(DRAWSEGMENT * segment); + +DECLARE_EVENT_TABLE() +}; + + +class WinEDA3D_DrawFrame: public wxFrame +{ +public: + WinEDA_BasePcbFrame * m_Parent; + WinEDA_App * m_ParentAppl; + Pcb3D_GLCanvas * m_Canvas; + wxToolBar * m_HToolBar; + wxToolBar * m_VToolBar; + int m_InternalUnits; + wxPoint m_FramePos; + wxSize m_FrameSize; + +private: + wxString m_FrameName; // name used for writting and reading setup + // It is "Frame3D" + + +public: + WinEDA3D_DrawFrame(WinEDA_BasePcbFrame * parent, WinEDA_App *app_parent, + const wxString& title ); + + void Exit3DFrame(wxCommandEvent& event); + void OnCloseWindow(wxCloseEvent & Event); + void ReCreateMenuBar(void); + void ReCreateHToolbar(void); + void ReCreateVToolbar(void); + void SetToolbars(void); + void GetSettings(void); + void SaveSettings(void); + + void OnLeftClick(wxDC * DC, const wxPoint& MousePos); + void OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu); + void OnKeyEvent(wxKeyEvent& event); + int BestZoom(void); // Retourne le meilleur zoom + void RedrawActiveWindow(wxDC * DC, bool EraseBg); + void Process_Special_Functions(wxCommandEvent& event); + void Process_Zoom(wxCommandEvent& event); + + void NewDisplay(void); + void Set3DBgColor(void); + +DECLARE_EVENT_TABLE() +}; + +void SetGLColor(int color); +void Set_Object_Data(const S3D_Vertex * coord, int nbcoord ); + +global_3d Info_3D_Visu g_Parm_3D_Visu; +global_3d double g_Draw3d_dx, g_Draw3d_dy; +global_3d double ZBottom, ZTop; +global_3d double DataScale3D; // coeff de conversion unites utilsateut -> unites 3D +global_3d int gl_attrib[] +#ifdef VIEWER_MAIN += { WX_GL_RGBA, WX_GL_MIN_RED, 8, WX_GL_MIN_GREEN, 8, + WX_GL_MIN_BLUE, 8, WX_GL_DEPTH_SIZE, 16, + WX_GL_DOUBLEBUFFER, + GL_NONE } +#endif +; + + diff --git a/3d-viewer/bitmaps3d.h b/3d-viewer/bitmaps3d.h new file mode 100644 index 0000000000..581dcf1670 --- /dev/null +++ b/3d-viewer/bitmaps3d.h @@ -0,0 +1,15 @@ +#include "bitmaps3d/import3d.xpm" + +#include "bitmaps3d/rotate+x.xpm" +#include "bitmaps3d/rotate-x.xpm" +#include "bitmaps3d/rotate+y.xpm" +#include "bitmaps3d/rotate-y.xpm" +#include "bitmaps3d/rotate+z.xpm" +#include "bitmaps3d/rotate-z.xpm" +#include "bitmaps3d/axis3d.xpm" +#include "bitmaps3d/axis3d_bottom.xpm" +#include "bitmaps3d/axis3d_top.xpm" +#include "bitmaps3d/axis3d_left.xpm" +#include "bitmaps3d/axis3d_right.xpm" +#include "bitmaps3d/axis3d_front.xpm" +#include "bitmaps3d/axis3d_back.xpm" diff --git a/3d-viewer/bitmaps3d/axis3d.xpm b/3d-viewer/bitmaps3d/axis3d.xpm new file mode 100644 index 0000000000..81ee03318c --- /dev/null +++ b/3d-viewer/bitmaps3d/axis3d.xpm @@ -0,0 +1,27 @@ +/* XPM bitmap */ +#ifndef XPM_3D_MAIN +extern char * axis3d_xpm[]; + +#else +char * axis3d_xpm[] = { +"16 15 3 1", +" c None", +". c Blue", +"x c Red", +" . ", +" ... ", +" . ", +" . ", +" . ", +" . ", +" . . ", +" ............", +" . . ", +" . ", +" . ", +" . ", +" .. ", +" . ", +" " +}; +#endif diff --git a/3d-viewer/bitmaps3d/axis3d_back.xpm b/3d-viewer/bitmaps3d/axis3d_back.xpm new file mode 100644 index 0000000000..f27380f070 --- /dev/null +++ b/3d-viewer/bitmaps3d/axis3d_back.xpm @@ -0,0 +1,27 @@ +/* XPM bitmap */ +#ifndef XPM_3D_MAIN +extern char * axis3d_back_xpm[]; + +#else +char * axis3d_back_xpm[] = { +"16 15 3 1", +" c None", +". c Blue", +"x c Red", +" . x ", +" ... x ", +" . x ", +" . xxxxx ", +" . xxx ", +" . x ", +" . . ", +" ............", +" . . ", +" . ", +" . ", +" . ", +" .. ", +" . ", +" " +}; +#endif diff --git a/3d-viewer/bitmaps3d/axis3d_bottom.xpm b/3d-viewer/bitmaps3d/axis3d_bottom.xpm new file mode 100644 index 0000000000..57fd6c1f75 --- /dev/null +++ b/3d-viewer/bitmaps3d/axis3d_bottom.xpm @@ -0,0 +1,27 @@ +/* XPM bitmap */ +#ifndef XPM_3D_MAIN +extern char * axis3d_bottom_xpm[]; + +#else +char * axis3d_bottom_xpm[] = { +"16 15 3 1", +" c None", +". c Blue", +"x c Red", +" . ", +" ... ", +" . ", +" . ", +" . ", +" . ", +" . . ", +" ............", +" . . ", +" . x ", +" . xxx ", +" . xxxxx ", +" .. x ", +" . x ", +" x " +}; +#endif diff --git a/3d-viewer/bitmaps3d/axis3d_front.xpm b/3d-viewer/bitmaps3d/axis3d_front.xpm new file mode 100644 index 0000000000..f7732ba889 --- /dev/null +++ b/3d-viewer/bitmaps3d/axis3d_front.xpm @@ -0,0 +1,27 @@ +/* XPM bitmap */ +#ifndef XPM_3D_MAIN +extern char * axis3d_front_xpm[]; + +#else +char * axis3d_front_xpm[] = { +"16 15 3 1", +" c None", +". c Blue", +"x c Red", +" . ", +" ... ", +" . ", +" . ", +" . ", +" . ", +" . . ", +" ............", +" . x . ", +" . xxx ", +" . xxxxx ", +" . x ", +" .. x ", +" . x ", +" " +}; +#endif diff --git a/3d-viewer/bitmaps3d/axis3d_left.xpm b/3d-viewer/bitmaps3d/axis3d_left.xpm new file mode 100644 index 0000000000..c9e410229f --- /dev/null +++ b/3d-viewer/bitmaps3d/axis3d_left.xpm @@ -0,0 +1,27 @@ +/* XPM bitmap */ +#ifndef XPM_3D_MAIN +extern char * axis3d_left_xpm[]; + +#else +char * axis3d_left_xpm[] = { +"16 15 3 1", +" c None", +". c Blue", +"x c Red", +" . ", +" ... ", +" . ", +" . ", +" x. ", +" xx ", +"xxxxxx . ", +" xx...........", +" x . ", +" . ", +" . ", +" . ", +" .. ", +" . ", +" " +}; +#endif diff --git a/3d-viewer/bitmaps3d/axis3d_right.xpm b/3d-viewer/bitmaps3d/axis3d_right.xpm new file mode 100644 index 0000000000..2eb7c81f0e --- /dev/null +++ b/3d-viewer/bitmaps3d/axis3d_right.xpm @@ -0,0 +1,27 @@ +/* XPM bitmap */ +#ifndef XPM_3D_MAIN +extern char * axis3d_right_xpm[]; + +#else +char * axis3d_right_xpm[] = { +"16 15 3 1", +" c None", +". c Blue", +"x c Red", +" . ", +" ... ", +" . ", +" . ", +" . x ", +" . xx ", +" . xxxxxx", +" .......xx...", +" . x . ", +" . ", +" . ", +" . ", +" .. ", +" . ", +" " +}; +#endif diff --git a/3d-viewer/bitmaps3d/axis3d_top.xpm b/3d-viewer/bitmaps3d/axis3d_top.xpm new file mode 100644 index 0000000000..f5e18614a3 --- /dev/null +++ b/3d-viewer/bitmaps3d/axis3d_top.xpm @@ -0,0 +1,27 @@ +/* XPM bitmap */ +#ifndef XPM_3D_MAIN +extern char * axis3d_top_xpm[]; + +#else +char * axis3d_top_xpm[] = { +"16 15 3 1", +" c None", +". c Blue", +"x c Red", +" . x ", +" ... x ", +" . x ", +" . xxxxx ", +" . xxx ", +" . x ", +" . . ", +" ............", +" . . ", +" . ", +" . ", +" . ", +" .. ", +" . ", +" " +}; +#endif diff --git a/3d-viewer/bitmaps3d/import3d.xpm b/3d-viewer/bitmaps3d/import3d.xpm new file mode 100644 index 0000000000..0044389e8e --- /dev/null +++ b/3d-viewer/bitmaps3d/import3d.xpm @@ -0,0 +1,48 @@ +/* XPM bitmap */ +#ifndef XPM_3D_MAIN +extern char *import3d_xpm[]; + +#else +char *import3d_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 3 1", +"- c Black", +"X c None", +"o c Green", + +/* pixels */ +"XXXXXXXXXXXXXXXX", +"----------------", +"-oooooooooooooo-", +"X-oooooooooooo-X", +"X-oooooooooooo-X", +"XX-oooooooooo-XX", +"XX-oooooooooo-XX", +"----oooooooo----", +"X-oooooooooooo-X", +"XX-oooooooooo-XX", +"XXX-oooooooo-XXX", +"XXXX-oooooo-XXXX", +"XXXXX-oooo-XXXXX", +"XXXXXX-oo-XXXXXX", +"XXXXXXX--XXXXXXX" + +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX" + +}; +#endif + diff --git a/3d-viewer/bitmaps3d/rotate+x.xpm b/3d-viewer/bitmaps3d/rotate+x.xpm new file mode 100644 index 0000000000..2d071afcb9 --- /dev/null +++ b/3d-viewer/bitmaps3d/rotate+x.xpm @@ -0,0 +1,32 @@ +/* XPM */ +#ifndef XPM_3D_MAIN +extern char *rotate_pos_X_xpm[]; + +#else +char *rotate_pos_X_xpm[] = { +/* width height num_colors chars_per_pixel */ +" 16 15 4 1", +/* colors */ +". c #000080", +"# c #c0c0c0", +"a c #808080", +"o c #008000", +/* pixels */ +"##oo###oo#######", +"###oo#oo########", +"####ooo#########", +"###oo#oo########", +"##oo###oo...a###", +"##.###...###.a##", +"##..#.#######.##", +"##...########.##", +"##....#######.##", +"##.....#####.a##", +"###########a.###", +"################", +"################", +"################", +"################" +}; + +#endif diff --git a/3d-viewer/bitmaps3d/rotate+y.xpm b/3d-viewer/bitmaps3d/rotate+y.xpm new file mode 100644 index 0000000000..ed3be83032 --- /dev/null +++ b/3d-viewer/bitmaps3d/rotate+y.xpm @@ -0,0 +1,32 @@ +/* XPM */ +#ifndef XPM_3D_MAIN +extern char *rotate_pos_Y_xpm[]; + +#else +char *rotate_pos_Y_xpm[] = { +/* width height num_colors chars_per_pixel */ +" 16 15 4 1", +/* colors */ +". c #000080", +"# c #c0c0c0", +"a c #808080", +"o c #FF0000", +/* pixels */ +"##oo###oo#######", +"###oo#oo########", +"####ooo#########", +"####oo##########", +"o##oo...########", +"#oo.####..###.##", +"##.#######.#..##", +"##.########...##", +"##.#######....##", +"##a.#####.....##", +"###.a###########", +"################", +"################", +"################", +"################" +}; +#endif + diff --git a/3d-viewer/bitmaps3d/rotate+z.xpm b/3d-viewer/bitmaps3d/rotate+z.xpm new file mode 100644 index 0000000000..b56ed9510c --- /dev/null +++ b/3d-viewer/bitmaps3d/rotate+z.xpm @@ -0,0 +1,32 @@ +/* XPM */ +#ifndef XPM_3D_MAIN +extern char *rotate_pos_Z_xpm[]; + +#else +char *rotate_pos_Z_xpm[] = { +/* width height num_colors chars_per_pixel */ +" 16 15 4 1", +/* colors */ +". c #000080", +"# c #c0c0c0", +"a c #808080", +"o c #008000", +/* pixels */ +"###oooooo#######", +"######oo########", +"#####oo#########", +"####oo##########", +"###oooooo...a###", +"##.###..####.a##", +"##..#.#######.##", +"##...########.##", +"##....#######.##", +"##.....#####.a##", +"###########a.###", +"################", +"################", +"################", +"################" +}; + +#endif diff --git a/3d-viewer/bitmaps3d/rotate-x.xpm b/3d-viewer/bitmaps3d/rotate-x.xpm new file mode 100644 index 0000000000..19206f1f9b --- /dev/null +++ b/3d-viewer/bitmaps3d/rotate-x.xpm @@ -0,0 +1,32 @@ +/* XPM */ +#ifndef XPM_3D_MAIN +extern char *rotate_neg_X_xpm[]; + +#else +char *rotate_neg_X_xpm[] = { +/* width height num_colors chars_per_pixel */ +" 16 15 4 1", +/* colors */ +". c #000080", +"# c #c0c0c0", +"a c #808080", +"o c #004000", +/* pixels */ +"##oo###oo#######", +"###oo#oo########", +"####ooo#########", +"###oo#oo########", +"##oo...oo#######", +"##a.####..###.##", +"##.#######.#..##", +"##.########...##", +"##.#######....##", +"##a.#####.....##", +"###.a###########", +"################", +"################", +"################", +"################" +}; +#endif + diff --git a/3d-viewer/bitmaps3d/rotate-y.xpm b/3d-viewer/bitmaps3d/rotate-y.xpm new file mode 100644 index 0000000000..5824331b5d --- /dev/null +++ b/3d-viewer/bitmaps3d/rotate-y.xpm @@ -0,0 +1,32 @@ +/* XPM */ +#ifndef XPM_3D_MAIN +extern char *rotate_neg_Y_xpm[]; + +#else +char *rotate_neg_Y_xpm[] = { +/* width height num_colors chars_per_pixel */ +" 16 15 4 1", +/* colors */ +". c #000080", +"# c #c0c0c0", +"a c #808080", +"o c #FF0000", +/* pixels */ +"##oo###oo#######", +"###oo#oo########", +"####ooo#########", +"####oo##########", +"o##oo###....a###", +"#oo###..####.a##", +"##..#.#######.##", +"##...########.##", +"##....#######.##", +"##.....#####.a##", +"###########a.###", +"################", +"################", +"################", +"################" +}; + +#endif diff --git a/3d-viewer/bitmaps3d/rotate-z.xpm b/3d-viewer/bitmaps3d/rotate-z.xpm new file mode 100644 index 0000000000..4bdd1551bf --- /dev/null +++ b/3d-viewer/bitmaps3d/rotate-z.xpm @@ -0,0 +1,32 @@ +/* XPM */ +#ifndef XPM_3D_MAIN +extern char *rotate_neg_Z_xpm[]; + +#else +char *rotate_neg_Z_xpm[] = { +/* width height num_colors chars_per_pixel */ +" 16 15 4 1", +/* colors */ +". c #000080", +"# c #c0c0c0", +"a c #808080", +"o c #008000", +/* pixels */ +"###oooooo#######", +"######oo########", +"#####oo#########", +"####oo##########", +"###oooooo#######", +"##a.####..###.##", +"##.#######.#..##", +"##.########...##", +"##.#######....##", +"##a.#####.....##", +"###.a###########", +"################", +"################", +"################", +"################" +}; +#endif + diff --git a/3d-viewer/bitmaps3d/zoomoins3d.xpm b/3d-viewer/bitmaps3d/zoomoins3d.xpm new file mode 100644 index 0000000000..a46c398a0b --- /dev/null +++ b/3d-viewer/bitmaps3d/zoomoins3d.xpm @@ -0,0 +1,28 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char * zoomoins3d_xpm[]; + +#else +char * zoomoins3d_xpm[] = { +"16 16 3 1", +" c None", +". c Black", +"X c Gray100", +" .... ", +" ..XXXX.. ", +" .XXXXXXXX. ", +" .XXXXXXXX. ", +".XXXXXXXXXX. ", +".XX......XX. ", +".XX......XX. ", +".XXXXXXXXXX. ", +" .XXXXXXXX. ", +" .XXXXXXXX. ", +" ..XXXX... ", +" .... ... ", +" ... ", +" ... ", +" ... ", +" .. " +}; +#endif diff --git a/3d-viewer/bitmaps3d/zoompage3d.xpm b/3d-viewer/bitmaps3d/zoompage3d.xpm new file mode 100644 index 0000000000..fd561d990c --- /dev/null +++ b/3d-viewer/bitmaps3d/zoompage3d.xpm @@ -0,0 +1,32 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char * zoompage3d_xpm[]; + +#else +char *zoompage3d_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 5 1", +" c Black", +". c None", +"X c Gray100", +"o c #808080", +"O c Cyan", +/* pixels */ +" .......", +" XXXXXXX ......", +" XXXXXXX . .....", +" XXXXXXX ....", +" XXXXXXXXXX ....", +" XXXXXXX ....", +" XXXXXX o..o ...", +" XXXXX oOO.oo ..", +" XXXXX .O..o. ..", +" XXXXX ....o. ..", +" XXXXX o..Ooo ..", +" XXXXXX o..o o..", +" XXXXXXX o .", +" XXXXXXXXXX . ", +" .. " +}; +#endif + diff --git a/3d-viewer/bitmaps3d/zoomplus3d.xpm b/3d-viewer/bitmaps3d/zoomplus3d.xpm new file mode 100644 index 0000000000..d84311fa9a --- /dev/null +++ b/3d-viewer/bitmaps3d/zoomplus3d.xpm @@ -0,0 +1,29 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char * zoomplus3d_xpm[]; + +#else +char * zoomplus3d_xpm[] = { +"16 16 3 1", +" c None", +". c Black", +"X c Gray100", +" .... ", +" ..XXXX.. ", +" .XXXXXXXX. ", +" .XXX..XXX. ", +".XXXX..XXXX. ", +".XX......XX. ", +".XX......XX. ", +".XXXX..XXXX. ", +" .XXX..XXX. ", +" .XXXXXXXX. ", +" ..XXXX... ", +" .... ... ", +" ... ", +" ... ", +" ... ", +" .. " +}; +#endif + diff --git a/3d-viewer/bitmaps3d/zoomrefr3d.xpm b/3d-viewer/bitmaps3d/zoomrefr3d.xpm new file mode 100644 index 0000000000..66ab990198 --- /dev/null +++ b/3d-viewer/bitmaps3d/zoomrefr3d.xpm @@ -0,0 +1,29 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char * zoomrefr3d_xpm[]; + +#else +char * zoomrefr3d_xpm[] = { +"16 16 3 1", +" c None", +". c #0000A0", +"X c #C0C0A0", +" .... ", +" ..XXXX.. ", +" .XXXXXXXX. ", +" .XXXXXXXX. ", +".XXXXXXXXXX. ", +".XXXXXXXXXX. ", +".XXXXXXXXXX. ", +".XXXXXXXXXX. ", +" .XXXXXXXX. ", +" .XXXXXXXX. ", +" ..XXXX... ", +" .... ... ", +" ... ", +" ... ", +" ... ", +" .. " +}; +#endif + diff --git a/3d-viewer/makefile.g95 b/3d-viewer/makefile.g95 new file mode 100644 index 0000000000..ecd3e3ff0d --- /dev/null +++ b/3d-viewer/makefile.g95 @@ -0,0 +1,24 @@ +WXDIR = $(WXWIN) + +TARGET=3d-viewer +DLLSUFF=.dll + +include ../libs.win + +DLLGEN=dllwrap --export-all --output-def $(TARGET).def --implib lib$(TARGET).a --driver-name c++ + +all: $(TARGET).a + +include makefile.include + + +$(TARGET).a: $(OBJECTS3D) + ar ruv $@ $(OBJECTS3D) + ranlib $@ + + +clean : + rm -f *.o + rm -f *.bak + rm -f $(TARGET).a + diff --git a/3d-viewer/makefile.gtk b/3d-viewer/makefile.gtk new file mode 100644 index 0000000000..dd843890c1 --- /dev/null +++ b/3d-viewer/makefile.gtk @@ -0,0 +1,35 @@ +## Makefile for 3d-viewer.a ( wxGTK - LINUX ) +CC = gcc + +# Compiler flags. + +CPPFLAGS = -Wall -O2 -DPCBNEW -I../pcbnew -I ../include -I../common\ + `wx-config --cxxflags` + + +include ../libs.linux + +TARGET = 3d-viewer + +FINAL = 1 + +all: $(TARGET).a + +include makefile.include + + +$(TARGET).a: $(OBJECTS3D) makefile.gtk makefile.include + rm -f $@ + ar -rv $@ $(OBJECTS3D) + ranlib $@ + + +clean: + rm -f *.o + rm -f *.exe + rm -f *.res + rm -f *.map + rm -f $(TARGET).a + + + diff --git a/3d-viewer/makefile.include b/3d-viewer/makefile.include new file mode 100644 index 0000000000..45644ea331 --- /dev/null +++ b/3d-viewer/makefile.include @@ -0,0 +1,28 @@ +EXTRALIBS = +EXTRACPPFLAGS= -I./ -I../include -I../common -I../pcbnew + +OBJECTS3D = 3d_frame.o 3d_read_mesh.o 3d_canvas.o trackball.o 3d_aux.o\ + 3d_draw.o 3d_toolbar.o 3d_class.o + + +OBJECTS= ../common/trigo.o + +AUXLIBS= -mthreads -o $(TARGET)$(DLLSUFF)\ + $(WXLIB_BASE) $(LIBS3D)\ + -lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm\ + -lshell32 -lcomctl32 -lcomdlg32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32 + +3d_class.o: 3d_class.cpp 3d_struct.h 3d_viewer.h + +3d_read_mesh.o: 3d_read_mesh.cpp 3d_struct.h 3d_viewer.h + +3d_frame.o: 3d_frame.cpp 3d_viewer.h + +3d_canvas.o: 3d_canvas.cpp 3d_viewer.h + +3d_aux.o: 3d_aux.cpp 3d_viewer.h + +3d_draw.o: 3d_draw.cpp 3d_viewer.h 3d_struct.h + +3d_toolbar.o: 3d_toolbar.cpp 3d_viewer.h + diff --git a/3d-viewer/makefile.macosx b/3d-viewer/makefile.macosx new file mode 100644 index 0000000000..84f622cd50 --- /dev/null +++ b/3d-viewer/makefile.macosx @@ -0,0 +1,35 @@ +## Makefile for 3d-viewer.a ( wxMAC - mac os X) +CC = gcc + +# Compiler flags. + +CPPFLAGS = -Wall -O2 -DPCBNEW -I../pcbnew -I ../include -I../common\ + `wx-config --cxxflags` + + +include ../libs.macosx + +TARGET = 3d-viewer + +FINAL = 1 + +all: $(TARGET).a + +include makefile.include + + +$(TARGET).a: $(OBJECTS3D) makefile.gtk makefile.include + rm -f $@ + ar -rv $@ $(OBJECTS3D) + ranlib $@ + + +clean: + rm -f *.o + rm -f *.exe + rm -f *.res + rm -f *.map + rm -f $(TARGET).a + + + diff --git a/3d-viewer/trackball.cpp b/3d-viewer/trackball.cpp new file mode 100644 index 0000000000..cdaf00dbaa --- /dev/null +++ b/3d-viewer/trackball.cpp @@ -0,0 +1,324 @@ +/* + * (c) Copyright 1993, 1994, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * Trackball code: + * + * Implementation of a virtual trackball. + * Implemented by Gavin Bell, lots of ideas from Thant Tessman and + * the August '88 issue of Siggraph's "Computer Graphics," pp. 121-129. + * + * Vector manip code: + * + * Original code from: + * David M. Ciemiewicz, Mark Grossman, Henry Moreton, and Paul Haeberli + * + * Much mucking with by: + * Gavin Bell + */ +#include +#include "trackball.h" + +/* + * This size should really be based on the distance from the center of + * rotation to the point on the object underneath the mouse. That + * point would then track the mouse as closely as possible. This is a + * simple example, though, so that is left as an Exercise for the + * Programmer. + */ +#define TRACKBALLSIZE (0.8f) + +/* + * Local function prototypes (not defined in trackball.h) + */ +static float tb_project_to_sphere(float, float, float); +static void normalize_quat(float [4]); + +void +vzero(float *v) +{ + v[0] = 0.0; + v[1] = 0.0; + v[2] = 0.0; +} + +void +vset(float *v, float x, float y, float z) +{ + v[0] = x; + v[1] = y; + v[2] = z; +} + +void +vsub(const float *src1, const float *src2, float *dst) +{ + dst[0] = src1[0] - src2[0]; + dst[1] = src1[1] - src2[1]; + dst[2] = src1[2] - src2[2]; +} + +void +vcopy(const float *v1, float *v2) +{ + register int i; + for (i = 0 ; i < 3 ; i++) + v2[i] = v1[i]; +} + +void +vcross(const float *v1, const float *v2, float *cross) +{ + float temp[3]; + + temp[0] = (v1[1] * v2[2]) - (v1[2] * v2[1]); + temp[1] = (v1[2] * v2[0]) - (v1[0] * v2[2]); + temp[2] = (v1[0] * v2[1]) - (v1[1] * v2[0]); + vcopy(temp, cross); +} + +float +vlength(const float *v) +{ + return (float) sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); +} + +void +vscale(float *v, float div) +{ + v[0] *= div; + v[1] *= div; + v[2] *= div; +} + +void +vnormal(float *v) +{ + vscale(v, 1.0f/vlength(v)); +} + +float +vdot(const float *v1, const float *v2) +{ + return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]; +} + +void +vadd(const float *src1, const float *src2, float *dst) +{ + dst[0] = src1[0] + src2[0]; + dst[1] = src1[1] + src2[1]; + dst[2] = src1[2] + src2[2]; +} + +/* + * Ok, simulate a track-ball. Project the points onto the virtual + * trackball, then figure out the axis of rotation, which is the cross + * product of P1 P2 and O P1 (O is the center of the ball, 0,0,0) + * Note: This is a deformed trackball-- is a trackball in the center, + * but is deformed into a hyperbolic sheet of rotation away from the + * center. This particular function was chosen after trying out + * several variations. + * + * It is assumed that the arguments to this routine are in the range + * (-1.0 ... 1.0) + */ +void +trackball(float q[4], float p1x, float p1y, float p2x, float p2y) +{ + float a[3]; /* Axis of rotation */ + float phi; /* how much to rotate about axis */ + float p1[3], p2[3], d[3]; + float t; + + if (p1x == p2x && p1y == p2y) { + /* Zero rotation */ + vzero(q); + q[3] = 1.0; + return; + } + + /* + * First, figure out z-coordinates for projection of P1 and P2 to + * deformed sphere + */ + vset(p1, p1x, p1y, tb_project_to_sphere(TRACKBALLSIZE, p1x, p1y)); + vset(p2, p2x, p2y, tb_project_to_sphere(TRACKBALLSIZE, p2x, p2y)); + + /* + * Now, we want the cross product of P1 and P2 + */ + vcross(p2,p1,a); + + /* + * Figure out how much to rotate around that axis. + */ + vsub(p1, p2, d); + t = vlength(d) / (2.0f*TRACKBALLSIZE); + + /* + * Avoid problems with out-of-control values... + */ + if (t > 1.0) t = 1.0; + if (t < -1.0) t = -1.0; + phi = 2.0f * (float) asin(t); + + axis_to_quat(a,phi,q); +} + +/* + * Given an axis and angle, compute quaternion. + */ +void +axis_to_quat(float a[3], float phi, float q[4]) +{ + vnormal(a); + vcopy(a, q); + vscale(q, (float) sin(phi/2.0)); + q[3] = (float) cos(phi/2.0); +} + +/* + * Project an x,y pair onto a sphere of radius r OR a hyperbolic sheet + * if we are away from the center of the sphere. + */ +static float +tb_project_to_sphere(float r, float x, float y) +{ + float d, t, z; + + d = (float) sqrt(x*x + y*y); + if (d < r * 0.70710678118654752440) { /* Inside sphere */ + z = (float) sqrt(r*r - d*d); + } else { /* On hyperbola */ + t = r / 1.41421356237309504880f; + z = t*t / d; + } + return z; +} + +/* + * Given two rotations, e1 and e2, expressed as quaternion rotations, + * figure out the equivalent single rotation and stuff it into dest. + * + * This routine also normalizes the result every RENORMCOUNT times it is + * called, to keep error from creeping in. + * + * NOTE: This routine is written so that q1 or q2 may be the same + * as dest (or each other). + */ + +#define RENORMCOUNT 97 + +void +add_quats(float q1[4], float q2[4], float dest[4]) +{ + static int count=0; + float t1[4], t2[4], t3[4]; + float tf[4]; + + vcopy(q1,t1); + vscale(t1,q2[3]); + + vcopy(q2,t2); + vscale(t2,q1[3]); + + vcross(q2,q1,t3); + vadd(t1,t2,tf); + vadd(t3,tf,tf); + tf[3] = q1[3] * q2[3] - vdot(q1,q2); + + dest[0] = tf[0]; + dest[1] = tf[1]; + dest[2] = tf[2]; + dest[3] = tf[3]; + + if (++count > RENORMCOUNT) { + count = 0; + normalize_quat(dest); + } +} + +/* + * Quaternions always obey: a^2 + b^2 + c^2 + d^2 = 1.0 + * If they don't add up to 1.0, dividing by their magnitued will + * renormalize them. + * + * Note: See the following for more information on quaternions: + * + * - Shoemake, K., Animating rotation with quaternion curves, Computer + * Graphics 19, No 3 (Proc. SIGGRAPH'85), 245-254, 1985. + * - Pletinckx, D., Quaternion calculus as a basic tool in computer + * graphics, The Visual Computer 5, 2-13, 1989. + */ +static void +normalize_quat(float q[4]) +{ + int i; + float mag; + + mag = (q[0]*q[0] + q[1]*q[1] + q[2]*q[2] + q[3]*q[3]); + for (i = 0; i < 4; i++) q[i] /= mag; +} + +/* + * Build a rotation matrix, given a quaternion rotation. + * + */ +void +build_rotmatrix(float m[4][4], float q[4]) +{ + m[0][0] = 1.0f - 2.0f * (q[1] * q[1] + q[2] * q[2]); + m[0][1] = 2.0f * (q[0] * q[1] - q[2] * q[3]); + m[0][2] = 2.0f * (q[2] * q[0] + q[1] * q[3]); + m[0][3] = 0.0f; + + m[1][0] = 2.0f * (q[0] * q[1] + q[2] * q[3]); + m[1][1]= 1.0f - 2.0f * (q[2] * q[2] + q[0] * q[0]); + m[1][2] = 2.0f * (q[1] * q[2] - q[0] * q[3]); + m[1][3] = 0.0f; + + m[2][0] = 2.0f * (q[2] * q[0] - q[1] * q[3]); + m[2][1] = 2.0f * (q[1] * q[2] + q[0] * q[3]); + m[2][2] = 1.0f - 2.0f * (q[1] * q[1] + q[0] * q[0]); + m[2][3] = 0.0f; + + m[3][0] = 0.0f; + m[3][1] = 0.0f; + m[3][2] = 0.0f; + m[3][3] = 1.0f; +} + diff --git a/3d-viewer/trackball.h b/3d-viewer/trackball.h new file mode 100644 index 0000000000..6f201f78af --- /dev/null +++ b/3d-viewer/trackball.h @@ -0,0 +1,78 @@ +/* + * (c) Copyright 1993, 1994, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * trackball.h + * A virtual trackball implementation + * Written by Gavin Bell for Silicon Graphics, November 1988. + */ + +/* + * Pass the x and y coordinates of the last and current positions of + * the mouse, scaled so they are from (-1.0 ... 1.0). + * + * The resulting rotation is returned as a quaternion rotation in the + * first paramater. + */ +void +trackball(float q[4], float p1x, float p1y, float p2x, float p2y); + +/* + * Given two quaternions, add them together to get a third quaternion. + * Adding quaternions to get a compound rotation is analagous to adding + * translations to get a compound translation. When incrementally + * adding rotations, the first argument here should be the new + * rotation, the second and third the total rotation (which will be + * over-written with the resulting new total rotation). + */ +void +add_quats(float *q1, float *q2, float *dest); + +/* + * A useful function, builds a rotation matrix in Matrix based on + * given quaternion. + */ +void +build_rotmatrix(float m[4][4], float q[4]); + +/* + * This function computes a quaternion based on an axis (defined by + * the given vector) and an angle about which to rotate. The angle is + * expressed in radians. The result is put into the third argument. + */ +void +axis_to_quat(float a[3], float phi, float q[4]); + diff --git a/bitmaps/3d.xpm b/bitmaps/3d.xpm new file mode 100644 index 0000000000..a446b29f91 --- /dev/null +++ b/bitmaps/3d.xpm @@ -0,0 +1,28 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *show_3d_xpm[]; + +#else +char *show_3d_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 3 1", +"J c #FF0000", +"x c #0000FF", +". c none", +"................", +"..JJJJ...JJ.....", +".JJJJJJ..JJJJ...", +".JJ..JJ..JJ.JJ..", +".....JJ..JJ..JJ.", +"..JJJJ...JJ...JJ", +"..JJJJJ..JJ...JJ", +".....JJ..JJ...JJ", +".JJ..JJ..JJ..JJJ", +".JJJJJJ..JJJJJJ.", +"..JJJJ....JJJJ.x", +"..........xxxxxx", +".....xxxxxx.....", +"xxxxxx..........", +"x..............." +}; +#endif diff --git a/bitmaps/Add_Arc.xpm b/bitmaps/Add_Arc.xpm new file mode 100644 index 0000000000..ee291aea78 --- /dev/null +++ b/bitmaps/Add_Arc.xpm @@ -0,0 +1,72 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *add_arc_xpm[]; + +#else +char * add_arc_xpm[] = { +"16 16 48 1", +" c None", +". c #222224", +"+ c #07071F", +"@ c #000087", +"# c #00009C", +"$ c #00009B", +"% c #474747", +"& c #FEE2CA", +"* c #C59A74", +"= c #000047", +"- c #00009A", +"; c #000095", +"> c #473C33", +", c #FEBB7F", +"' c #C57B3A", +") c #000015", +"! c #000017", +"~ c #00003A", +"{ c #000075", +"] c #000097", +"^ c #000096", +"/ c #211306", +"( c #060300", +"_ c #000000", +": c #000083", +"< c #000094", +"[ c #00008D", +"} c #000090", +"| c #000055", +"1 c #000081", +"2 c #222222", +"3 c #080807", +"4 c #000091", +"5 c #00008B", +"6 c #070300", +"7 c #14141F", +"8 c #12112D", +"9 c #000059", +"0 c #161616", +"a c #F2D7C1", +"b c #F2BD8E", +"c c #120C10", +"d c #161210", +"e c #F2B279", +"f c #F29747", +"g c #130901", +"h c #140B04", +"i c #140900", +" ", +" .+@#$#$ ", +" %&*=$$$$-; ", +" >,')! ~{]$^ ", +" /(_ :$< ", +" [$} ", +" ]$| ", +" -$1 ", +" 23 $4 ", +" %&*_ $; ", +" >,'_ $5 ", +" /6 789 ", +" 0abc ", +" defg ", +" hi_ ", +" "}; +#endif diff --git a/bitmaps/Add_Circle.xpm b/bitmaps/Add_Circle.xpm new file mode 100644 index 0000000000..a76f9eb8dd --- /dev/null +++ b/bitmaps/Add_Circle.xpm @@ -0,0 +1,60 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *add_circle_xpm[]; + +#else +char * add_circle_xpm[] = { +"16 16 36 1", +" c None", +". c #00009B", +"+ c #000096", +"@ c #00008C", +"# c #000053", +"$ c #00008A", +"% c #00009A", +"& c #000073", +"* c #00007A", +"= c #000092", +"- c #00006F", +"; c #161616", +"> c #161513", +", c #12122F", +"' c #121125", +") c #F2D7C1", +"! c #F2BD8E", +"~ c #140D08", +"{ c #151519", +"] c #130D07", +"^ c #161210", +"/ c #F2B279", +"( c #F29747", +"_ c #140A01", +": c #151213", +"< c #130901", +"[ c #140B04", +"} c #140900", +"| c #000000", +"1 c #120A18", +"2 c #12080C", +"3 c #00003F", +"4 c #000094", +"5 c #000044", +"6 c #000083", +"7 c #00006A", +" .... ", +" .......+ ", +" ..@# #$.% ", +" ..& *.= ", +" .@ =.- ", +"..# ;> ,' ", +".. ;)!~ {)!] ", +".. ^/(_ :/(< ", +"..# [}| 12| ", +" .$ .@3| ", +" +.* ..4 ", +" %.= ..%5 ", +" =......45 ", +" -64467 ", +" ", +" "}; +#endif diff --git a/bitmaps/Add_Component.xpm b/bitmaps/Add_Component.xpm new file mode 100644 index 0000000000..c5a0205781 --- /dev/null +++ b/bitmaps/Add_Component.xpm @@ -0,0 +1,91 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *add_component_xpm[]; + +#else +char * add_component_xpm[] = { +"16 16 67 1", +" c None", +"! c black", +"# c #D72E2E", +"$ c #D72F2F", +"% c #D62E2E", +"& c #D83434", +"' c #FEFEFF", +"( c #FBFBFF", +") c #F6F6FF", +"* c #F1F1FF", +"+ c #EBE9FC", +", c #E3C3D7", +"- c #DA6C77", +". c #D13838", +"0 c #FF0000", +"1 c #FAFAFF", +"2 c #F5F5FF", +"3 c #F0F0FF", +"4 c #EBEBFF", +"5 c #E6E6FF", +"6 c #E1E1FF", +"7 c #DBDBFF", +"8 c #D6555F", +"9 c #BD5C5C", +": c #9B9B9B", +"; c #F4F4FF", +"< c #EFEFFF", +"= c #EAEAFF", +"> c #E5E5FF", +"? c #E0E0FF", +"@ c #D6D6FF", +"A c #D390AC", +"B c #CB4444", +"C c #E4E4FF", +"D c #DFDFFF", +"E c #DADAFF", +"F c #D5D5FF", +"G c #D0D0FF", +"H c #CCB8E6", +"I c #D73334", +"J c #E9E9FF", +"K c #D4D4FF", +"L c #CFCFFF", +"M c #CACAFF", +"N c #CB8BAF", +"O c #CB4141", +"P c #E3E3FF", +"Q c #DEDEFF", +"R c #D9D9FF", +"S c #C9C9FF", +"T c #C4C4FF", +"U c #D05364", +"V c #B96262", +"W c #9C9C9C", +"X c #DDDDFF", +"Y c #D8D8FF", +"Z c #D3D3FF", +"[ c #CECEFF", +"] c #C9C7FC", +"^ c #C7A8D8", +"_ c #CE647C", +"` c #CD3E3E", +"a c #9E9595", +"b c #D62F2F", +"c c #CC4141", +"d c #BC5C5C", +"e c #9D9595", +" ", +" ", +" ", +" ######$% ", +" &'()*+,-. ", +"0##&123456789 ", +" :&;<=>?7@AB ", +" &<=CDEFGH###0", +" IJCDEKLMNO:::", +" IPQRKLSTUVW ", +"0##IXYZ[]^_`a ", +" :#####bcde: ", +" :::::::: ", +" ", +" ", +" "}; +#endif diff --git a/bitmaps/Add_Dashed_Line.xpm b/bitmaps/Add_Dashed_Line.xpm new file mode 100644 index 0000000000..aa0bc59630 --- /dev/null +++ b/bitmaps/Add_Dashed_Line.xpm @@ -0,0 +1,39 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *add_dashed_line_xpm[]; + +#else +char * add_dashed_line_xpm[] = { +"16 16 15 1", +" c None", +". c #03039B", +"+ c #8E8E9B", +"@ c #00009B", +"# c #1F1F9B", +"$ c #93939B", +"% c #00009A", +"& c #46469A", +"* c #9B9B9B", +"= c #93939A", +"- c #16169A", +"; c #0B0B9B", +"> c #97979B", +", c #1E1E9B", +"' c #91919B", +" ", +" .+ ", +" @#$ ", +" @#$ ", +" @#$ ", +" ", +" %&* ", +" %#= ", +" %#= ", +" -= ", +" ;* ", +" @#> ", +" @#$ ", +" @,$ ", +" ' ", +" "}; +#endif diff --git a/bitmaps/Add_Entry.xpm b/bitmaps/Add_Entry.xpm new file mode 100644 index 0000000000..f61efb2607 --- /dev/null +++ b/bitmaps/Add_Entry.xpm @@ -0,0 +1,34 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *add_entry_xpm[]; + +#else +char * add_entry_xpm[] = { +"16 16 10 1", +" c None", +". c #006800", +"+ c #006900", +"@ c #6C8B6C", +"# c #9B9B9B", +"$ c #6C8C6C", +"% c #9A9A9A", +"& c #6B8B6B", +"* c #9C9C9C", +"= c #6A8B6A", +" ", +" ", +" . ", +" +@ ", +" +@# ", +" +$% ", +" +$% ", +" +&# ", +" .&* ", +" .&* ", +" .&# ", +" +=# ", +" =# ", +" % ", +" ", +" "}; +#endif diff --git a/bitmaps/Add_GLabel.xpm b/bitmaps/Add_GLabel.xpm new file mode 100644 index 0000000000..22ed8df82a --- /dev/null +++ b/bitmaps/Add_GLabel.xpm @@ -0,0 +1,78 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *add_glabel_xpm[]; + +#else +char * add_glabel_xpm[] = { +"16 16 54 1", +" c None", +". c #695F00", +"+ c #837E52", +"@ c #6D640F", +"# c #6F6714", +"$ c #706818", +"% c #9C9C9C", +"& c #9191FF", +"* c #9B9BFF", +"= c #A5A5FF", +"- c #857F66", +"; c #746D25", +"> c #827D4F", +", c #7E7841", +"' c #8F8C76", +") c #9E9EFF", +"! c #A8A8FF", +"~ c #B2B2FF", +"{ c #BBBBF9", +"] c #7D7539", +"^ c #7A7437", +"/ c #95948B", +"( c #878460", +"_ c #7D773E", +": c #ACACFF", +"< c #B6B6FF", +"[ c #C0C0FF", +"} c #CACAFF", +"| c #BFBDCC", +"1 c #8C896D", +"2 c #6C6209", +"3 c #989894", +"4 c #B9B9FF", +"5 c #C3C3FF", +"6 c #CECEFF", +"7 c #D5D5F9", +"8 c #847C39", +"9 c #7B7437", +"0 c #9B9B9B", +"a c #797233", +"b c #817C4D", +"c c #756D25", +"d c #898664", +"e c #C7C7FF", +"f c #D1D1FF", +"g c #DBDBFF", +"h c #9B9566", +"i c #999997", +"j c #96958D", +"k c #86825B", +"l c #766F2B", +"m c #706716", +"n c #97968F", +"o c #9A9A9A", +" ", +" ", +" ", +" .. ", +" ...+ ..... ", +" .@#$% .&*=-; ", +" .>,.' .)!~{]^ ", +" ../(._ .:<[}|.1", +" .....23.4567890", +"..abbc.d.efgh;i0", +"..j00k.l....mn0 ", +" o0 0o00000 ", +" ", +" ", +" ", +" "}; +#endif diff --git a/bitmaps/Add_Junction.xpm b/bitmaps/Add_Junction.xpm new file mode 100644 index 0000000000..4a446ec6ad --- /dev/null +++ b/bitmaps/Add_Junction.xpm @@ -0,0 +1,84 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *add_junction_xpm[]; + +#else +char * add_junction_xpm[] = { +"16 16 60 1", +" c None", +". c #007D00", +"+ c #4D8B4D", +"@ c #9B9B9B", +"# c #000000", +"$ c #000700", +"% c #0A130A", +"& c #282828", +"* c #222222", +"= c #868483", +"- c #E1D5CA", +"; c #B7A595", +"> c #564A3F", +", c #080707", +"' c #151515", +") c #EAE2DB", +"! c #FFEBDA", +"~ c #FFE0C5", +"{ c #FFD5B1", +"] c #FFCA9C", +"^ c #806044", +"/ c #004C00", +"( c #645F59", +"_ c #FFE6CF", +": c #FFDBBB", +"< c #FFD0A6", +"[ c #FFC591", +"} c #FFBA7D", +"| c #E49C5D", +"1 c #000D00", +"2 c #2F552F", +"3 c #64584D", +"4 c #FFD5B0", +"5 c #FFCA9B", +"6 c #FFBF87", +"7 c #FFB472", +"8 c #FFA95D", +"9 c #E48D41", +"0 c #080F08", +"a c #757575", +"b c #16120F", +"c c #EAB485", +"d c #FFB97C", +"e c #FFAF67", +"f c #FFA453", +"g c #FF993E", +"h c #804715", +"i c #3A3A3A", +"j c #414141", +"k c #22180F", +"l c #865931", +"m c #E18B40", +"n c #B76925", +"o c #562E0A", +"p c #131110", +"q c #8E8E8E", +"r c #686868", +"s c #242424", +"t c #3F3F3F", +"u c #909090", +" .. ", +" .+@ ", +" .+@ ", +" #$%& ", +" *=-;>, ", +" ')!~{]^* ", +".../(_:<[}|1... ", +".++234567890+++@", +" @@abcdefghi@@@@", +" jklmnopq ", +" rs$%tu ", +" @.+@ ", +" .+@ ", +" .+@ ", +" .+@ ", +" @@ "}; +#endif diff --git a/bitmaps/Add_Line.xpm b/bitmaps/Add_Line.xpm new file mode 100644 index 0000000000..5bd9946af4 --- /dev/null +++ b/bitmaps/Add_Line.xpm @@ -0,0 +1,27 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *add_line_xpm[]; + +#else +char * add_line_xpm[] = { +"16 16 3 1", +" c None", +". c #006900", +"+ c #9B9B9B", +" ", +" ", +"...... ", +" ++++.+ ", +" .+ ", +" .+ ", +" .+ ", +" .+ ", +" .+ ", +" .+ ", +" .+ ", +" .......... ", +" ++++++++++", +" ", +" ", +" "}; +#endif diff --git a/bitmaps/Add_Line_Label.xpm b/bitmaps/Add_Line_Label.xpm new file mode 100644 index 0000000000..f2886638d5 --- /dev/null +++ b/bitmaps/Add_Line_Label.xpm @@ -0,0 +1,48 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *add_line_label_xpm[]; + +#else +char * add_line_label_xpm[] = { +"16 16 24 1", +" c None", +". c #000000", +"+ c #020202", +"@ c #8D8D8D", +"# c #202020", +"$ c #555555", +"% c #9A9A9A", +"& c #8C8C8C", +"* c #080808", +"= c #161616", +"- c #9B9B9B", +"; c #131313", +"> c #969696", +", c #212121", +"' c #7C7C7C", +") c #414141", +"! c #515151", +"~ c #525252", +"{ c #070707", +"] c #0B0B0B", +"^ c #979797", +"/ c #1F1F1F", +"( c #6B6B6B", +"_ c #009B00", +" ", +" ..+ ", +" ..+@ ", +" .#.$% ", +" ..&*=- ", +" .;>,.' ", +" ......)- ", +" ..!~~{]^ ", +" ./-% #+( ", +" -- -- ", +" ", +"________________", +"________________", +"----------------", +" ", +" "}; +#endif diff --git a/bitmaps/Add_Polygon.xpm b/bitmaps/Add_Polygon.xpm new file mode 100644 index 0000000000..32caf2ac0c --- /dev/null +++ b/bitmaps/Add_Polygon.xpm @@ -0,0 +1,78 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *add_polygon_xpm[]; + +#else +char * add_polygon_xpm[] = { +"16 16 54 1", +" c None", +". c #161616", +"+ c #161513", +"@ c #080808", +"# c #222222", +"$ c #F2D7C0", +"% c #F2BC8E", +"& c #120C24", +"* c #00009B", +"= c #000047", +"- c #C5C4C4", +"; c #FEE2CA", +"> c #46372A", +", c #16120F", +"' c #F2B279", +") c #F29647", +"! c #12091F", +"~ c #C5A68C", +"{ c #FEBB7F", +"] c #462B17", +"^ c #000033", +"/ c #140C04", +"( c #130900", +"_ c #000000", +": c #070402", +"< c #1F1211", +"[ c #00005E", +"} c #000091", +"| c #00008C", +"1 c #00009A", +"2 c #00005F", +"3 c #000040", +"4 c #858484", +"5 c #857D75", +"6 c #26262B", +"7 c #FFE3CB", +"8 c #FFC796", +"9 c #25190E", +"0 c #856243", +"a c #855327", +"b c #00006E", +"c c #12122F", +"d c #12112D", +"e c #F2D7C1", +"f c #F2BD8E", +"g c #130D07", +"h c #161210", +"i c #F29747", +"j c #12091E", +"k c #120F2A", +"l c #130901", +"m c #140B04", +"n c #130800", +"o c #130A04", +" .+ @# ", +".$%&**=-;> ", +",')!**=~{]^ ", +" /(__ :<[} ", +" |12 ", +" 345_ ", +" 6789 ", +" _0a_ ", +" bb_ ", +" ** ", +" ** ", +" .+ cd_ ", +" .ef&*****cefg ", +" h'ij*****k'il ", +" mn__ _on_ ", +" "}; +#endif diff --git a/bitmaps/Add_Rectangle.xpm b/bitmaps/Add_Rectangle.xpm new file mode 100644 index 0000000000..290118add2 --- /dev/null +++ b/bitmaps/Add_Rectangle.xpm @@ -0,0 +1,48 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *add_rectangle_xpm[]; + +#else +char * add_rectangle_xpm[] = { +"16 16 24 1", +" c None", +". c #161616", +"+ c #161513", +"@ c #F2D7C0", +"# c #F2BC8E", +"$ c #120C24", +"% c #00009B", +"& c #16120F", +"* c #F2B279", +"= c #F29647", +"- c #12091F", +"; c #120A21", +"> c #12081D", +", c #000000", +"' c #12122F", +") c #12112D", +"! c #F2D7C1", +"~ c #F2BD8E", +"{ c #130D07", +"] c #120F2A", +"^ c #F29747", +"/ c #130901", +"( c #130A04", +"_ c #130800", +" .+ ", +".@#$%%%%%%%%%% ", +"&*=-%%%%%%%%%% ", +" ;>,, %% ", +" %%, %% ", +" %% %% ", +" %% %% ", +" %% %% ", +" %% %% ", +" %% %% ", +" %% %% ", +" %% '), ", +" %%%%%%%%%%'!~{ ", +" %%%%%%%%%%]*^/ ", +" ,(_, ", +" "}; +#endif diff --git a/bitmaps/Add_Text.xpm b/bitmaps/Add_Text.xpm new file mode 100644 index 0000000000..1ee7e66e60 --- /dev/null +++ b/bitmaps/Add_Text.xpm @@ -0,0 +1,28 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *add_text_xpm[]; + +#else +char * add_text_xpm[] = { +"16 16 4 1", +" c None", +". c #00009B", +"+ c #000098", +"@ c #00005D", +" .............. ", +" .............. ", +" .+ .... +. ", +" .@ .... . ", +" .... ", +" .... ", +" .... ", +" .... ", +" .... ", +" .... ", +" .... ", +" .... ", +" .... ", +" .....+ ", +" ........ ", +" "}; +#endif diff --git a/bitmaps/Apply.xpm b/bitmaps/Apply.xpm new file mode 100644 index 0000000000..317719e474 --- /dev/null +++ b/bitmaps/Apply.xpm @@ -0,0 +1,40 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *apply_xpm[]; + +#else +char * apply_xpm[] = { +"16 16 16 1", +" c None", +". c #000000", +"+ c #C8D7E5", +"@ c #8EA8C0", +"# c #9DB8D2", +"$ c #7E94AA", +"% c #8299AF", +"& c #D6E1EB", +"* c #C4CED6", +"= c #ACBED0", +"- c #404040", +"; c #ACB9C5", +"> c #727272", +", c #889FB6", +"' c #B1BFCB", +") c #98B2CC", +" ", +" ", +" ", +" .. ", +" .+@. ", +" .+#$. ", +" .. .+#%. ", +" .&&. .+#%. ", +" .*#=. .+#%. ", +" -=#=.&#%. ", +" .;####%. ", +" >,##%. ", +" .')$. ", +" ... ", +" ", +" "}; +#endif diff --git a/bitmaps/Cancel.xpm b/bitmaps/Cancel.xpm new file mode 100644 index 0000000000..ef4e076dbf --- /dev/null +++ b/bitmaps/Cancel.xpm @@ -0,0 +1,127 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *cancel_xpm[]; + +#else +char * cancel_xpm[] = { +"16 16 103 2", +" c None", +"! c black", +"# c #422019", +"$ c #391C17", +"% c #0D0D0D", +"& c #020202", +"' c #050505", +"( c #321813", +") c #DD8D7D", +"* c #D05F49", +"+ c #4E1D14", +", c #2D1714", +"- c #C16E5E", +". c #AD4632", +"0 c #090504", +"1 c #3E1E18", +"2 c #D3634E", +"3 c #C95641", +"4 c #C64D37", +"5 c #4C1B13", +"6 c #301914", +"7 c #D9705B", +"8 c #C24129", +"9 c #962E1C", +": c #120502", +"; c #0E0B09", +"< c #C34C36", +"= c #C03B22", +"> c #BF3B22", +"? c #C44D36", +"@ c #5C251B", +"A c #1D0F0C", +"B c #D66F5B", +"C c #B93B24", +"D c #922C1B", +"E c #4E160D", +"F c #2F1510", +"G c #BE3B22", +"H c #B23821", +"I c #3B1711", +"J c #CA6D5B", +"K c #B83E27", +"L c #822617", +"M c #2C0B05", +"N c #2B130E", +"O c #BD3B22", +"P c #BA3B22", +"Q c #B73922", +"R c #B45B4A", +"S c #CE523A", +"T c #992F1D", +"U c #200804", +"V c #3C1812", +"W c #BA3A22", +"X c #C84E37", +"Y c #B63922", +"Z c #2F0E07", +"[ c #49160C", +"] c #CE6653", +"^ c #BD3C24", +"_ c #BB3B22", +"` c #B43922", +"a c #2C140F", +"b c #1B0704", +"c c #D17F70", +"d c #BE3F27", +"e c #B63D26", +"f c #BC3B22", +"g c #B03720", +"h c #381914", +"i c #CB7868", +"j c #BD3F28", +"k c #922F1E", +"l c #090909", +"m c #B43A23", +"n c #25120F", +"o c #010101", +"p c #572119", +"q c #CC7261", +"r c #B93A22", +"s c #96311E", +"t c #200B08", +"u c #411710", +"v c #A23A26", +"w c #080505", +"x c #230A06", +"y c #CD7261", +"z c #BD3D25", +"{ c #98311E", +"| c #240D09", +"} c #C23B22", +"~ c #AD3620", +" ! c #26110D", +"!! c #0F0907", +"#! c #912F1E", +"$! c #94301E", +"%! c #180906", +"&! c #A13521", +"'! c #26110E", +"(! c #2C0E09", +")! c #1C0905", +"*! c #341A15", +"+! c #311712", +" ", +" # $ % & ' ", +" ( ) * + % , - . 0 ", +" 1 2 3 4 5 6 7 8 9 : ", +" ; < = > ? @ A B C D E ", +" F < G G H I ' J K L M ", +" N < O P Q R S T U ", +" V < W W X Y Z & ", +" & [ ] ^ W _ ` a ", +" b c d e Q f O g N ", +" h i j k l I < G G m n ", +" o p q r s t u ? > = v w ", +" x y z { | 5 4 } ~ ! ", +" !!#!$!%! % + X &!'! ", +" (!)! % *!+! ", +" "}; +#endif diff --git a/bitmaps/CopyBlock.xpm b/bitmaps/CopyBlock.xpm new file mode 100644 index 0000000000..3c6f28f3e6 --- /dev/null +++ b/bitmaps/CopyBlock.xpm @@ -0,0 +1,42 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *copyblock_xpm[]; + +#else +char * copyblock_xpm[] = { +"16 16 18 1", +" c None", +". c #000000", +"+ c #B3B3B3", +"@ c #FFFFFF", +"# c #D6D6D6", +"$ c #646464", +"% c #4D4D4D", +"& c #505050", +"* c #696969", +"= c #787878", +"- c #4C4C4C", +"; c #E3E3E3", +"> c #5A5A5A", +", c #535353", +"' c #919191", +") c #A2A2A2", +"! c #5C5C5C", +"~ c #666666", +".......... ", +".+@@@@@@#. ", +".@@@@@@@@. ", +".@$%&@*=@. ", +".@@@@@@@@. ", +".@&-@&......... ", +".@@@@.+@@@@@@#. ", +".;>,'.@@@@@@@@. ", +".@@@@.@$%&@*=@. ", +".#@@@.@@@@@@@@. ", +"......@&-@)*+@. ", +" .@@@@@@@@. ", +" .;>,'@!~@. ", +" .@@@@@@@@. ", +" .#@@@@@@#. ", +" ......... "}; +#endif diff --git a/bitmaps/Cursor_Shape.xpm b/bitmaps/Cursor_Shape.xpm new file mode 100644 index 0000000000..0b39d4b286 --- /dev/null +++ b/bitmaps/Cursor_Shape.xpm @@ -0,0 +1,77 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *cursor_shape_xpm[]; + +#else +char * cursor_shape_xpm[] = { +"16 16 53 1", +" c None", +". c #373737", +"+ c #9B9B9B", +"@ c #2E2E2E", +"# c #323232", +"$ c #252525", +"% c #121212", +"& c #696969", +"* c #858585", +"= c #777777", +"- c #040404", +"; c #383838", +"> c #7D7D7D", +", c #FFFFFF", +"' c #BDBDCB", +") c #28282F", +"! c #6D6D6D", +"~ c #F7F7FF", +"{ c #E6E6FF", +"] c #D1D1F9", +"^ c #61617D", +"/ c #050507", +"( c #363636", +"_ c #5E5E5E", +": c #F0F0FF", +"< c #DFDFFF", +"[ c #BFBFEC", +"} c #6E6E93", +"| c #1C1C27", +"1 c #4C4C4E", +"2 c #E8E8FF", +"3 c #9F9FBC", +"4 c #7B7B9D", +"5 c #343434", +"6 c #9A9A9A", +"7 c #38383B", +"8 c #52525D", +"9 c #1C1C1D", +"0 c #A6A6DE", +"a c #393953", +"b c #636363", +"c c #242424", +"d c #7E7E7E", +"e c #7A7A7A", +"f c #4E4E6C", +"g c #9B9BED", +"h c #12121F", +"i c #959595", +"j c #2D2D30", +"k c #9494EC", +"l c #54548A", +"m c #000000", +"n c #181827", +" . ", +" .+ ", +"..@#........... ", +" +$%&++++++++++ ", +" .*=- ", +" ;>,') ", +" .!~{]^/ ", +" (_:<[}| ", +" (123456+ ", +" .7890ab ", +" .cdefgh ", +" .i+ jklm ", +" .6 !n# ", +" .+ e++ ", +" .+ + ", +" + "}; +#endif diff --git a/bitmaps/Datasheet.xpm b/bitmaps/Datasheet.xpm new file mode 100644 index 0000000000..06d2a08cb4 --- /dev/null +++ b/bitmaps/Datasheet.xpm @@ -0,0 +1,46 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *datasheet_xpm[]; + +#else +char * datasheet_xpm[] = { +"16 16 22 1", +" c None", +". c #000000", +"+ c #010101", +"@ c #FEFEFE", +"# c #EBEBEB", +"$ c #696969", +"% c #272727", +"& c #FFFFFF", +"* c #787878", +"= c #D4D4D4", +"- c #212121", +"; c #3A3A3A", +"> c #757575", +", c #595959", +"' c #B0B0B0", +") c #8E8E8E", +"! c #C3C3C3", +"~ c #913131", +"{ c #8D2D2D", +"] c #852525", +"^ c #C69696", +"/ c #C29292", +" ..........+. ", +".@#########$%. ", +".&##.#.#.#.*=-. ", +".&#........;>,. ", +".&#';######.)!. ", +".&#';######.#!. ", +".&#.........#!. ", +".&##.#.#.#.##!. ", +".&###########!. ", +".~{{{{{{{{{{{]. ", +".~&&^{&&^{&&&]. ", +".~&{&{&{&{&{{]. ", +".~&{&{&{&{&&{]. ", +".~&&^{&{&{&{{]. ", +".~&]]]&&/]&]]]. ", +"............... "}; +#endif diff --git a/bitmaps/Delete_Arc.xpm b/bitmaps/Delete_Arc.xpm new file mode 100644 index 0000000000..43122424c8 --- /dev/null +++ b/bitmaps/Delete_Arc.xpm @@ -0,0 +1,162 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *delete_arc_xpm[]; + +#else +char * delete_arc_xpm[] = { +"16 16 138 2", +" c None", +". c #00009B", +"+ c #000099", +"@ c #000097", +"# c #000096", +"$ c #000073", +"% c #000039", +"& c #000036", +"* c #000051", +"= c #000086", +"- c #00008E", +"; c #000093", +"> c #000085", +", c #000074", +"' c #0D0D0D", +") c #414141", +"! c #494949", +"~ c #3D3D3D", +"{ c #2B2B2B", +"] c #000001", +"^ c #010177", +"/ c #000082", +"( c #000000", +"_ c #838170", +": c #EEEBD6", +"< c #F0EFE7", +"[ c #ECEBE2", +"} c #C5C4B8", +"| c #525146", +"1 c #01013F", +"2 c #0F0F0F", +"3 c #C0BEA3", +"4 c #BFBDA3", +"5 c #797866", +"6 c #47463F", +"7 c #262624", +"8 c #35342D", +"9 c #858371", +"0 c #9E9C86", +"a c #A19F89", +"b c #A3A18B", +"c c #2A2A2A", +"d c #D1CFBA", +"e c #DAD8C2", +"f c #E0DECD", +"g c #B7B5A0", +"h c #63615A", +"i c #383735", +"j c #3B3B32", +"k c #605F52", +"l c #989681", +"m c #B5B39A", +"n c #B1B097", +"o c #A2A089", +"p c #E6E2D1", +"q c #F2EFE7", +"r c #F0EFE2", +"s c #E8E7D8", +"t c #E3E0D0", +"u c #D3D0BC", +"v c #C1BFA5", +"w c #ADAB92", +"x c #BEBCA2", +"y c #C4C2AB", +"z c #B6B49B", +"A c #787665", +"B c #888774", +"C c #EFEBD0", +"D c #F9F6E7", +"E c #F7F3EB", +"F c #F6F5EC", +"G c #F6F5EA", +"H c #F3F1E4", +"I c #EAE8D7", +"J c #DCDBC9", +"K c #9B9988", +"L c #626154", +"M c #575649", +"N c #515045", +"O c #727064", +"P c #9D9B8F", +"Q c #E2DFC6", +"R c #E7E3CD", +"S c #E0DEC9", +"T c #CFCFC9", +"U c #8C8B7E", +"V c #757463", +"W c #676658", +"X c #424138", +"Y c #282721", +"Z c #1E1E1A", +"` c #33332F", +" . c #4A4843", +".. c #676661", +"+. c #6F6E65", +"@. c #6A6A63", +"#. c #6D6B5C", +"$. c #57564A", +"%. c #383830", +"&. c #161514", +"*. c #191915", +"=. c #1E1D18", +"-. c #292922", +";. c #9E9E93", +">. c #4C4C3F", +",. c #35352F", +"'. c #292925", +"). c #2E2E29", +"!. c #0E0E0C", +"~. c #0A0A08", +"{. c #0F0F0C", +"]. c #3D3D37", +"^. c #33332A", +"/. c #23231E", +"(. c #2A2A23", +"_. c #A3A297", +":. c #B5B4AC", +"<. c #706F66", +"[. c #9F9F90", +"}. c #737262", +"|. c #3F3F34", +"1. c #68685A", +"2. c #38382E", +"3. c #68685E", +"4. c #3E3E33", +"5. c #25251F", +"6. c #2B2B24", +"7. c #ABABA1", +"8. c #D7D7D0", +"9. c #89897E", +"0. c #D4D3CC", +"a. c #86867A", +"b. c #57564E", +"c. c #919185", +"d. c #49493C", +"e. c #77776A", +"f. c #4F4F41", +"g. c #282821", +" . . . . . ", +" . . . . . . . . + @ ", +" # $ % & * = . . - ", +" ; . > ", +" # . , ", +" ' ) ! ~ { ] ^ / ", +" ( ( _ : < [ } | ] ] 1 ", +" 2 3 4 5 6 7 8 9 0 a b ( ", +" c d e f g h i j k l m n o ( ", +" ( p q r s t u v w x y z A ( ", +" ( B C D E F G H I J K L M ( ", +" ( N O P Q R S T U V W X Y ( ", +" Z ` ...+.@.#.$.%.&.*.=. ", +" -.;.>.,.'.).!.~.{.].^./. ", +" (._.:.<.[.}.|.1.2.3.4.5. ", +" 6.7.8.9.0.a.b.c.d.e.f.g. "}; +#endif diff --git a/bitmaps/Delete_Circle.xpm b/bitmaps/Delete_Circle.xpm new file mode 100644 index 0000000000..e3c210ee04 --- /dev/null +++ b/bitmaps/Delete_Circle.xpm @@ -0,0 +1,150 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *delete_circle_xpm[]; + +#else +char * delete_circle_xpm[] = { +"16 16 126 2", +" c None", +". c #00009B", +"+ c #000096", +"@ c #00008C", +"# c #000053", +"$ c #00008A", +"% c #00009A", +"& c #000073", +"* c #00007A", +"= c #000092", +"- c #00006F", +"; c #000083", +"> c #0D0D0D", +", c #414141", +"' c #494949", +") c #3D3D3D", +"! c #2B2B2B", +"~ c #000001", +"{ c #010177", +"] c #000081", +"^ c #000000", +"/ c #838170", +"( c #EEEBD6", +"_ c #F0EFE7", +": c #ECEBE2", +"< c #C5C4B8", +"[ c #525146", +"} c #010101", +"| c #010140", +"1 c #0F0F0F", +"2 c #C0BEA3", +"3 c #BFBDA3", +"4 c #797866", +"5 c #47463F", +"6 c #262624", +"7 c #35342D", +"8 c #858371", +"9 c #9E9C87", +"0 c #A19F89", +"a c #A3A18B", +"b c #2A2A2B", +"c c #D1CFBA", +"d c #DAD8C2", +"e c #E0DECD", +"f c #B7B5A0", +"g c #63615A", +"h c #383735", +"i c #3B3B32", +"j c #605F53", +"k c #989682", +"l c #B5B39A", +"m c #B1B096", +"n c #A2A089", +"o c #E6E2D1", +"p c #F2EFE7", +"q c #F0EFE2", +"r c #E8E7D8", +"s c #E3E0D0", +"t c #D3D0BC", +"u c #C1BFA6", +"v c #ADAB93", +"w c #BEBCA3", +"x c #C4C2AB", +"y c #B6B49A", +"z c #787665", +"A c #888775", +"B c #EFEBD1", +"C c #F9F6E8", +"D c #F7F3EC", +"E c #F6F5ED", +"F c #F6F5EB", +"G c #F3F1E5", +"H c #EAE8D8", +"I c #DCDBCA", +"J c #9B9987", +"K c #626153", +"L c #575649", +"M c #00003B", +"N c #515046", +"O c #727065", +"P c #9D9B90", +"Q c #E2DFC7", +"R c #E7E3CE", +"S c #E0DECA", +"T c #CFCFCA", +"U c #8C8B7F", +"V c #757463", +"W c #676657", +"X c #424137", +"Y c #282721", +"Z c #1E1E1A", +"` c #33332F", +" . c #4A4844", +".. c #676662", +"+. c #6F6E66", +"@. c #6A6A64", +"#. c #6D6B5C", +"$. c #57564A", +"%. c #383830", +"&. c #161514", +"*. c #191915", +"=. c #1E1D18", +"-. c #292922", +";. c #9E9E93", +">. c #4C4C3F", +",. c #35352F", +"'. c #292925", +"). c #2E2E29", +"!. c #0E0E0C", +"~. c #0A0A08", +"{. c #0F0F0C", +"]. c #3D3D37", +"^. c #33332A", +"/. c #23231E", +"(. c #2A2A23", +"_. c #A3A297", +":. c #B5B4AC", +"<. c #706F66", +"[. c #9F9F90", +"}. c #737262", +"|. c #3F3F34", +"1. c #68685A", +"2. c #38382E", +"3. c #68685E", +"4. c #3E3E33", +"5. c #25251F", +" . . . . ", +" . . . . . . . + ", +" . . @ # # $ . % ", +" . . & * . = ", +" . @ = . - ", +". . # . ; ", +". . > , ' ) ! ~ { ] ", +". . ^ ^ / ( _ : < [ ~ ~ } ", +". . | 1 2 3 4 5 6 7 8 9 0 a ^ ", +" . b c d e f g h i j k l m n ^ ", +" + ~ o p q r s t u v w x y z ^ ", +" ~ A B C D E F G H I J K L ^ ", +" M N O P Q R S T U V W X Y ^ ", +" Z ` ...+.@.#.$.%.&.*.=. ", +" -.;.>.,.'.).!.~.{.].^./. ", +" (._.:.<.[.}.|.1.2.3.4.5. "}; +#endif diff --git a/bitmaps/Delete_Cotation.xpm b/bitmaps/Delete_Cotation.xpm new file mode 100644 index 0000000000..3ad73c7af0 --- /dev/null +++ b/bitmaps/Delete_Cotation.xpm @@ -0,0 +1,134 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *delete_cotation_xpm[]; + +#else +char * delete_cotation_xpm[] = { +"16 16 110 2", +" c None", +". c #000000", +"+ c #00009B", +"@ c #000097", +"# c #000099", +"$ c #00008B", +"% c #000095", +"& c #000088", +"* c #000072", +"= c #010101", +"- c #0D0D0D", +"; c #414141", +"> c #494949", +", c #3D3D3D", +"' c #2B2B2B", +") c #01014F", +"! c #000081", +"~ c #00008F", +"{ c #010166", +"] c #838170", +"^ c #EEEBD6", +"/ c #F0EFE7", +"( c #ECEBE2", +"_ c #C5C4B8", +": c #525146", +"< c #000001", +"[ c #01016F", +"} c #0F0F0F", +"| c #C0BEA3", +"1 c #BFBDA3", +"2 c #797866", +"3 c #47463F", +"4 c #262624", +"5 c #35342D", +"6 c #858371", +"7 c #9E9C87", +"8 c #A19F88", +"9 c #A3A18A", +"0 c #2A2A2A", +"a c #D1CFBA", +"b c #DAD8C2", +"c c #E0DECD", +"d c #B7B5A0", +"e c #63615A", +"f c #383735", +"g c #3B3B32", +"h c #605F52", +"i c #989681", +"j c #B5B399", +"k c #B1B096", +"l c #A2A08A", +"m c #E6E2D1", +"n c #F2EFE7", +"o c #F0EFE2", +"p c #E8E7D8", +"q c #E3E0D0", +"r c #D3D0BC", +"s c #C1BFA5", +"t c #ADAB92", +"u c #BEBCA2", +"v c #C4C2AA", +"w c #B6B49A", +"x c #787666", +"y c #888774", +"z c #EFEBD0", +"A c #F9F6E7", +"B c #F7F3EB", +"C c #F6F5EC", +"D c #F6F5EA", +"E c #F3F1E4", +"F c #EAE8D7", +"G c #DCDBC9", +"H c #9B9987", +"I c #626153", +"J c #57564A", +"K c #515045", +"L c #727064", +"M c #9D9B8F", +"N c #E2DFC6", +"O c #E7E3CD", +"P c #E0DEC9", +"Q c #CFCFC9", +"R c #8C8B7E", +"S c #757463", +"T c #676657", +"U c #424137", +"V c #282722", +"W c #1E1E1A", +"X c #33332F", +"Y c #4A4843", +"Z c #676661", +"` c #6F6E65", +" . c #6A6A63", +".. c #6D6B5C", +"+. c #383830", +"@. c #161514", +"#. c #191915", +"$. c #1E1D19", +"%. c #292922", +"&. c #9E9E93", +"*. c #4C4C3F", +"=. c #35352F", +"-. c #292925", +";. c #2E2E29", +">. c #0E0E0C", +",. c #0A0A08", +"'. c #0F0F0C", +"). c #3D3D37", +"!. c #33332A", +"~. c #23231E", +" . . ", +" . . . ", +" . . . . ", +" . . ", +"+ + @ . . # + ", +"+ $ @ % + ", +"+ # + + + + + + + + + + + + + ", +"+ & * = - ; > , ' . ) ! + . ", +"+ ~ { . . ] ^ / ( _ : < . [ ", +"+ } | 1 2 3 4 5 6 7 8 9 < ", +"+ 0 a b c d e f g h i j k l . ", +"+ . m n o p q r s t u v w x . ", +"+ . y z A B C D E F G H I J . ", +"+ . K L M N O P Q R S T U V . ", +" W X Y Z ` ...J +.@.#.$. ", +" %.&.*.=.-.;.>.,.'.).!.~. "}; +#endif diff --git a/bitmaps/Delete_Field.xpm b/bitmaps/Delete_Field.xpm new file mode 100644 index 0000000000..c4b13573dc --- /dev/null +++ b/bitmaps/Delete_Field.xpm @@ -0,0 +1,148 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *delete_field_xpm[]; + +#else +char * delete_field_xpm[] = { +"16 16 124 2", +" c None", +". c #D2D2D2", +"+ c #9D9D9D", +"@ c #DEDEDE", +"# c #E0E0E0", +"$ c #5C5C5C", +"% c #000000", +"& c #EDEDED", +"* c #939393", +"= c #FDFDFD", +"- c #E4E4E4", +"; c #F1F1F1", +"> c #C8C8C8", +", c #E7E7E7", +"' c #F4F4F4", +") c #8F8F8F", +"! c #E9E9E9", +"~ c #F6F6F6", +"{ c #C0C0C0", +"] c #FAFAFA", +"^ c #9C9C9C", +"/ c #999999", +"( c #F0F0F0", +"_ c #B5B5B5", +": c #0E0E0E", +"< c #424242", +"[ c #4A4A4A", +"} c #3E3E3E", +"| c #2C2C2C", +"1 c #010101", +"2 c #C1C1C1", +"3 c #DDDDDD", +"4 c #7B7B7B", +"5 c #848271", +"6 c #EFECD7", +"7 c #F1F0E8", +"8 c #EDECE3", +"9 c #C6C5B9", +"0 c #535246", +"a c #707070", +"b c #0F0F0F", +"c c #C0BEA3", +"d c #BFBDA3", +"e c #797866", +"f c #47463F", +"g c #262624", +"h c #35342D", +"i c #858371", +"j c #9E9C86", +"k c #A19F88", +"l c #A3A18A", +"m c #2A2A2A", +"n c #D1CFBA", +"o c #DAD8C2", +"p c #E0DECD", +"q c #B7B5A0", +"r c #63615A", +"s c #383735", +"t c #3B3B32", +"u c #605F52", +"v c #989681", +"w c #B5B399", +"x c #B1B096", +"y c #A2A089", +"z c #E6E2D1", +"A c #F2EFE7", +"B c #F0EFE2", +"C c #E8E7D8", +"D c #E3E0D0", +"E c #D3D0BC", +"F c #C1BFA5", +"G c #ADAB92", +"H c #BEBCA2", +"I c #C4C2AA", +"J c #B6B49A", +"K c #787665", +"L c #888774", +"M c #EFEBD0", +"N c #F9F6E7", +"O c #F7F3EB", +"P c #F6F5EC", +"Q c #F6F5EA", +"R c #F3F1E4", +"S c #EAE8D7", +"T c #DCDBC9", +"U c #9B9987", +"V c #626153", +"W c #575649", +"X c #515045", +"Y c #727064", +"Z c #9D9B8F", +"` c #E2DFC6", +" . c #E7E3CD", +".. c #E0DEC9", +"+. c #CFCFC9", +"@. c #8C8B7E", +"#. c #757463", +"$. c #676657", +"%. c #424137", +"&. c #282721", +"*. c #1E1E1A", +"=. c #33332F", +"-. c #4A4843", +";. c #676661", +">. c #6F6E65", +",. c #6A6A63", +"'. c #6D6B5C", +"). c #57564A", +"!. c #383830", +"~. c #161514", +"{. c #191915", +"]. c #1E1D18", +"^. c #292922", +"/. c #9E9E93", +"(. c #4C4C3F", +"_. c #35352F", +":. c #292925", +"<. c #2E2E29", +"[. c #0E0E0C", +"}. c #0A0A08", +"|. c #0F0F0C", +"1. c #3D3D37", +"2. c #33332A", +"3. c #23231E", +". + + + + + + + + + + + + + + . ", +"+ . @ @ @ @ @ @ @ @ @ @ @ @ @ + ", +"+ # $ % % $ & % % % * & = = = + ", +"+ - % ; ; % ; % ; > % ; = = = + ", +"+ , % ' ' % ' % % % ) ' = = = + ", +"+ ! % % % % ~ % ~ { % ~ = = = + ", +"+ & % ] ] % ] % % % ^ ] / = / + ", +"+ ( = & _ : < [ } | 1 2 3 = = + ", +". + 4 1 1 5 6 7 8 9 0 1 1 a + . ", +" b c d e f g h i j k l % ", +" m n o p q r s t u v w x y % ", +" % z A B C D E F G H I J K % ", +" % L M N O P Q R S T U V W % ", +" % X Y Z ` ...+.@.#.$.%.&.% ", +" *.=.-.;.>.,.'.).!.~.{.]. ", +" ^./.(._.:.<.[.}.|.1.2.3. "}; +#endif diff --git a/bitmaps/Delete_Line.xpm b/bitmaps/Delete_Line.xpm new file mode 100644 index 0000000000..bee73d31ef --- /dev/null +++ b/bitmaps/Delete_Line.xpm @@ -0,0 +1,155 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *delete_line_xpm[]; + +#else +char * delete_line_xpm[] = { +"16 16 131 2", +" c None", +". c #007D00", +"+ c #4D8B4D", +"@ c #9B9B9B", +"# c #060606", +"$ c #202020", +"% c #242424", +"& c #1E1E1E", +"* c #151515", +"= c #000000", +"- c #48473F", +"; c #97968B", +"> c #9C9C98", +", c #94948F", +"' c #787872", +") c #292822", +"! c #080808", +"~ c #605F51", +"{ c #5F5E51", +"] c #7E7D6B", +"^ c #9A988A", +"/ c #8B8A85", +"( c #908F87", +"_ c #A5A494", +": c #787766", +"< c #504F44", +"[ c #515045", +"} c #161616", +"| c #706F65", +"1 c #CDCBB3", +"2 c #CFCDB8", +"3 c #989683", +"4 c #55534C", +"5 c #2F2F2D", +"6 c #383830", +"7 c #737161", +"8 c #9B9984", +"9 c #ABA991", +"0 c #AAA990", +"a c #515044", +"b c #DBD8C5", +"c c #E6E3D4", +"d c #E8E6D7", +"e c #CFCEBC", +"f c #A3A095", +"g c #858379", +"h c #7E7D6C", +"i c #868572", +"j c #ABA992", +"k c #BDBBA2", +"l c #B4B298", +"m c #8D8B77", +"n c #B7B5A2", +"o c #F0EDDB", +"p c #F4F2E4", +"q c #EFEDE1", +"r c #ECEADE", +"s c #E4E2D3", +"t c #DAD8C4", +"u c #CBC9B5", +"v c #CDCBB6", +"w c #B0AE99", +"x c #8C8A77", +"y c #676657", +"z c #6D6C5C", +"A c #B0AD9A", +"B c #CBC8BB", +"C c #ECE9D8", +"D c #EEECDC", +"E c #EBE9D9", +"F c #E1E0D6", +"G c #BBBAAA", +"H c #A8A796", +"I c #817F6F", +"J c #525145", +"K c #3F3F35", +"L c #383730", +"M c #525149", +"N c #747269", +"O c #A4A293", +"P c #ABA899", +"Q c #A5A496", +"R c #9E9D92", +"S c #727164", +"T c #565649", +"U c #3F3E36", +"V c #2E2D26", +"W c #23221D", +"X c #24241E", +"Y c #696961", +"Z c #4B4A41", +"` c #4E4D48", +" . c #4C4B45", +".. c #4C4C46", +"+. c #3E3D34", +"@. c #313029", +"#. c #2A2926", +"$. c #262620", +"%. c #21201B", +"&. c #2A2A23", +"*. c #A1A095", +"=. c #808076", +"-. c #52524A", +";. c #64645B", +">. c #505045", +",. c #272720", +"'. c #393931", +"). c #24241D", +"!. c #39392F", +"~. c #24241F", +"{. c #2B2B24", +"]. c #A7A79C", +"^. c #C6C5BE", +"/. c #7D7C72", +"(. c #BAB9AE", +"_. c #7D7C6E", +":. c #7D7D70", +"<. c #404035", +"[. c #6F6F64", +"}. c #46463A", +"|. c #ABABA1", +"1. c #D7D7D0", +"2. c #8B8B7F", +"3. c #D7D7CF", +"4. c #989888", +"5. c #59594F", +"6. c #98988B", +"7. c #4A4A3E", +"8. c #77776A", +"9. c #4F4F41", +"0. c #282821", +" ", +". . . . . . . . . . . . . . . ", +". + + + + + + + + + + + + + + @ ", +" @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ ", +" # $ % & * = ", +" = = - ; > , ' ) = = ", +" ! ~ { ] ^ / ( _ : < [ = ", +" } | 1 2 3 4 5 6 7 8 9 0 a = ", +" * b c d e f g h i j k l m = ", +" = n o p q r s t u v w x y = ", +" = z A B C D E F G H I J K = ", +" L M N O P Q R S T U V W ", +" X Y Z ` ...+.@.X #.$.%. ", +" &.*.=.-.;.>.,.'.).-.!.~. ", +" {.].^./.(._.Z :.<.[.}.,. ", +" {.|.1.2.3.4.5.6.7.8.9.0. "}; +#endif diff --git a/bitmaps/Delete_Polygon.xpm b/bitmaps/Delete_Polygon.xpm new file mode 100644 index 0000000000..53e3bb2b72 --- /dev/null +++ b/bitmaps/Delete_Polygon.xpm @@ -0,0 +1,144 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *Delete_Polygon_xpm[]; + +#else +char * Delete_Polygon_xpm[] = { +"16 16 120 2", +" c None", +". c #00009B", +"+ c #000099", +"@ c #00007D", +"# c #000094", +"$ c #000093", +"% c #00008C", +"& c #000098", +"* c #000080", +"= c #0D0D0D", +"- c #414141", +"; c #494949", +"> c #3D3D3D", +", c #2B2B2C", +"' c #000001", +") c #010101", +"! c #000000", +"~ c #838170", +"{ c #EEEBD6", +"] c #F0EFE7", +"^ c #ECEBE2", +"/ c #C5C4B9", +"( c #525146", +"_ c #0F0F0F", +": c #C0BEA3", +"< c #BFBDA3", +"[ c #797866", +"} c #47463F", +"| c #262624", +"1 c #35342D", +"2 c #858372", +"3 c #9E9C87", +"4 c #A19F88", +"5 c #A3A18A", +"6 c #2A2A2A", +"7 c #D1CFBA", +"8 c #DAD8C2", +"9 c #E0DECD", +"0 c #B7B5A0", +"a c #63615A", +"b c #383735", +"c c #3B3B32", +"d c #605F53", +"e c #989682", +"f c #B5B399", +"g c #B1B096", +"h c #A2A089", +"i c #E6E2D1", +"j c #F2EFE7", +"k c #F0EFE2", +"l c #E8E7D8", +"m c #E3E0D0", +"n c #D3D0BC", +"o c #C1BFA5", +"p c #ADAB93", +"q c #BEBCA3", +"r c #C4C2AA", +"s c #B6B49A", +"t c #787665", +"u c #888775", +"v c #EFEBD1", +"w c #F9F6E8", +"x c #F7F3EC", +"y c #F6F5ED", +"z c #F6F5EB", +"A c #F3F1E5", +"B c #EAE8D8", +"C c #DCDBCA", +"D c #9B9987", +"E c #626153", +"F c #575649", +"G c #00004D", +"H c #515046", +"I c #727065", +"J c #9D9B90", +"K c #E2DFC7", +"L c #E7E3CE", +"M c #E0DECA", +"N c #CFCFCA", +"O c #8C8B7F", +"P c #757464", +"Q c #676657", +"R c #424137", +"S c #282721", +"T c #1E1E1A", +"U c #33332F", +"V c #4A4843", +"W c #676661", +"X c #6F6E65", +"Y c #6A6A63", +"Z c #6D6B5C", +"` c #57564A", +" . c #383830", +".. c #161514", +"+. c #191915", +"@. c #1E1D18", +"#. c #292922", +"$. c #9E9E93", +"%. c #4C4C3F", +"&. c #35352F", +"*. c #292925", +"=. c #2E2E29", +"-. c #0E0E0C", +";. c #0A0A08", +">. c #0F0F0C", +",. c #3D3D37", +"'. c #33332A", +"). c #23231E", +"!. c #2A2A23", +"~. c #A3A297", +"{. c #B5B4AC", +"]. c #706F66", +"^. c #9F9F90", +"/. c #737262", +"(. c #3F3F34", +"_. c #68685A", +":. c #38382E", +"<. c #68685E", +"[. c #3E3E33", +"}. c #25251F", +". . . . . . . . ", +". . . . . . . . + ", +" @ . # ", +" $ . % ", +" & . * ", +" . . ", +" = - ; > , ' ) ", +" ! ! ~ { ] ^ / ( ! ! ", +" _ : < [ } | 1 2 3 4 5 ! ", +" 6 7 8 9 0 a b c d e f g h ! ", +" ! i j k l m n o p q r s t ! ", +" . ' u v w x y z A B C D E F ! ", +" . G H I J K L M N O P Q R S ! ", +" T U V W X Y Z ` ...+.@. ", +" #.$.%.&.*.=.-.;.>.,.'.). ", +" !.~.{.].^./.(._.:.<.[.}. "}; +#endif diff --git a/bitmaps/Delete_Rectangle.xpm b/bitmaps/Delete_Rectangle.xpm new file mode 100644 index 0000000000..92eb58edad --- /dev/null +++ b/bitmaps/Delete_Rectangle.xpm @@ -0,0 +1,138 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *delete_rectangle_xpm[]; + +#else +char * delete_rectangle_xpm[] = { +"16 16 114 2", +" c None", +". c #00009B", +"+ c #0D0D0D", +"@ c #414141", +"# c #494949", +"$ c #3D3D3D", +"% c #2B2B2B", +"& c #000001", +"* c #010177", +"= c #000000", +"- c #838170", +"; c #EEEBD6", +"> c #F0EFE7", +", c #ECEBE2", +"' c #C5C4B8", +") c #525146", +"! c #010101", +"~ c #0F0F0F", +"{ c #C0BEA3", +"] c #BFBDA3", +"^ c #797866", +"/ c #47463F", +"( c #262624", +"_ c #35342D", +": c #858371", +"< c #9E9C87", +"[ c #A19F89", +"} c #A3A18A", +"| c #2A2A2A", +"1 c #D1CFBA", +"2 c #DAD8C2", +"3 c #E0DECD", +"4 c #B7B5A0", +"5 c #63615A", +"6 c #383735", +"7 c #3B3B32", +"8 c #605F52", +"9 c #989682", +"0 c #B5B39A", +"a c #B1B096", +"b c #A2A089", +"c c #E6E2D1", +"d c #F2EFE7", +"e c #F0EFE2", +"f c #E8E7D8", +"g c #E3E0D0", +"h c #D3D0BC", +"i c #C1BFA5", +"j c #ADAB92", +"k c #BEBCA3", +"l c #C4C2AB", +"m c #B6B49A", +"n c #787665", +"o c #888775", +"p c #EFEBD1", +"q c #F9F6E8", +"r c #F7F3EC", +"s c #F6F5ED", +"t c #F6F5EB", +"u c #F3F1E5", +"v c #EAE8D8", +"w c #DCDBCA", +"x c #9B9988", +"y c #626153", +"z c #575649", +"A c #00004D", +"B c #515046", +"C c #727065", +"D c #9D9B90", +"E c #E2DFC7", +"F c #E7E3CE", +"G c #E0DECA", +"H c #CFCFCA", +"I c #8C8B7F", +"J c #757464", +"K c #676657", +"L c #424137", +"M c #282721", +"N c #1E1E1A", +"O c #33332F", +"P c #4A4843", +"Q c #676661", +"R c #6F6E65", +"S c #6A6A63", +"T c #6D6B5C", +"U c #57564A", +"V c #383830", +"W c #161514", +"X c #191915", +"Y c #1E1D18", +"Z c #292922", +"` c #9E9E93", +" . c #4C4C3F", +".. c #35352F", +"+. c #292925", +"@. c #2E2E29", +"#. c #0E0E0C", +"$. c #0A0A08", +"%. c #0F0F0C", +"&. c #3D3D37", +"*. c #33332A", +"=. c #23231E", +"-. c #2A2A23", +";. c #A3A297", +">. c #B5B4AC", +",. c #706F66", +"'. c #9F9F90", +"). c #737262", +"!. c #3F3F34", +"~. c #68685A", +"{. c #38382E", +"]. c #68685E", +"^. c #3E3E33", +"/. c #25251F", +". . . . . . . . . . . . . ", +". . . . . . . . . . . . . ", +". . . . ", +". . . . ", +". . . . ", +". . . . ", +". . + @ # $ % & * ", +". . = = - ; > , ' ) & = ", +". . ! ~ { ] ^ / ( _ : < [ } = ", +". . | 1 2 3 4 5 6 7 8 9 0 a b = ", +". . = c d e f g h i j k l m n = ", +". . & o p q r s t u v w x y z = ", +". . A B C D E F G H I J K L M = ", +" N O P Q R S T U V W X Y ", +" Z ` ...+.@.#.$.%.&.*.=. ", +" -.;.>.,.'.).!.~.{.].^./. "}; +#endif diff --git a/bitmaps/Delete_Segment.xpm b/bitmaps/Delete_Segment.xpm new file mode 100644 index 0000000000..88032ef705 --- /dev/null +++ b/bitmaps/Delete_Segment.xpm @@ -0,0 +1,135 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *delete_segment_xpm[]; + +#else +char * delete_segment_xpm[] = { +"16 16 111 2", +" c None", +". c #007D00", +"+ c #007C00", +"@ c #0D0D0D", +"# c #414141", +"$ c #494949", +"% c #3D3D3D", +"& c #2B2B2B", +"* c #000000", +"= c #838170", +"- c #EEEBD6", +"; c #F0EFE7", +"> c #ECEBE2", +", c #C5C4B8", +"' c #525145", +") c #0F0F0F", +"! c #C0BEA3", +"~ c #BFBDA3", +"{ c #797866", +"] c #47463F", +"^ c #262624", +"/ c #35342D", +"( c #858371", +"_ c #9E9C86", +": c #A19F88", +"< c #A3A18A", +"[ c #2A2A2A", +"} c #D1CFBA", +"| c #DAD8C2", +"1 c #E0DECD", +"2 c #B7B5A0", +"3 c #63615A", +"4 c #383735", +"5 c #3B3B32", +"6 c #605F52", +"7 c #989681", +"8 c #B5B399", +"9 c #B1B096", +"0 c #A2A089", +"a c #E6E2D1", +"b c #F2EFE7", +"c c #F0EFE2", +"d c #E8E7D8", +"e c #E3E0D0", +"f c #D3D0BC", +"g c #C1BFA5", +"h c #ADAB92", +"i c #BEBCA2", +"j c #C4C2AA", +"k c #B6B49A", +"l c #787665", +"m c #888774", +"n c #EFEBD0", +"o c #F9F6E7", +"p c #F7F3EB", +"q c #F6F5EC", +"r c #F6F5EA", +"s c #F3F1E4", +"t c #EAE8D7", +"u c #DCDBC9", +"v c #9B9987", +"w c #626153", +"x c #575649", +"y c #515045", +"z c #727064", +"A c #9D9B8F", +"B c #E2DFC6", +"C c #E7E3CD", +"D c #E0DEC9", +"E c #CFCFC9", +"F c #8C8B7E", +"G c #757463", +"H c #676657", +"I c #424137", +"J c #282721", +"K c #1E1E1A", +"L c #33332F", +"M c #4A4843", +"N c #676661", +"O c #6F6E65", +"P c #6A6A63", +"Q c #6D6B5C", +"R c #57564A", +"S c #383830", +"T c #161514", +"U c #191915", +"V c #1E1D18", +"W c #292922", +"X c #9E9E93", +"Y c #4C4C3F", +"Z c #35352F", +"` c #292925", +" . c #2E2E29", +".. c #0E0E0C", +"+. c #0A0A08", +"@. c #0F0F0C", +"#. c #3D3D37", +"$. c #33332A", +"%. c #23231E", +"&. c #2A2A23", +"*. c #A3A297", +"=. c #B5B4AC", +"-. c #706F66", +";. c #9F9F90", +">. c #737262", +",. c #3F3F34", +"'. c #68685A", +"). c #38382E", +"!. c #68685E", +"~. c #3E3E33", +"{. c #25251F", +" ", +". . . . . . . . . . . . . . . . ", +"+ . . . . . . . . . . . . . . . ", +" ", +" ", +" ", +" @ # $ % & * ", +" * * = - ; > , ' * * ", +" ) ! ~ { ] ^ / ( _ : < * ", +" [ } | 1 2 3 4 5 6 7 8 9 0 * ", +" * a b c d e f g h i j k l * ", +" * m n o p q r s t u v w x * ", +" * y z A B C D E F G H I J * ", +" K L M N O P Q R S T U V ", +" W X Y Z ` ...+.@.#.$.%. ", +" &.*.=.-.;.>.,.'.).!.~.{. "}; +#endif diff --git a/bitmaps/Delete_Text.xpm b/bitmaps/Delete_Text.xpm new file mode 100644 index 0000000000..ac21236e42 --- /dev/null +++ b/bitmaps/Delete_Text.xpm @@ -0,0 +1,138 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *delete_text_xpm[]; + +#else +char * delete_text_xpm[] = { +"16 16 114 2", +" c None", +". c #00009B", +"+ c #000098", +"@ c #00005D", +"# c #01016F", +"$ c #0D0D0E", +"% c #414142", +"& c #49494A", +"* c #3D3D3D", +"= c #2B2B2B", +"- c #000000", +"; c #000001", +"> c #838171", +", c #EEEBD7", +"' c #F0EFE8", +") c #ECEBE2", +"! c #C5C4B8", +"~ c #525145", +"{ c #0F0F0F", +"] c #C0BEA3", +"^ c #BFBDA4", +"/ c #797867", +"( c #474640", +"_ c #262625", +": c #35342D", +"< c #858371", +"[ c #9E9C86", +"} c #A19F88", +"| c #A3A18A", +"1 c #2A2A2A", +"2 c #D1CFBA", +"3 c #DAD8C2", +"4 c #E0DECE", +"5 c #B7B5A1", +"6 c #63615B", +"7 c #383736", +"8 c #3B3B32", +"9 c #605F52", +"0 c #989681", +"a c #B5B399", +"b c #B1B096", +"c c #A2A089", +"d c #E6E2D1", +"e c #F2EFE7", +"f c #F0EFE3", +"g c #E8E7D9", +"h c #E3E0D1", +"i c #D3D0BD", +"j c #C1BFA5", +"k c #ADAB92", +"l c #BEBCA2", +"m c #C4C2AA", +"n c #B6B49A", +"o c #787665", +"p c #888774", +"q c #EFEBD0", +"r c #F9F6E8", +"s c #F7F3EC", +"t c #F6F5ED", +"u c #F6F5EB", +"v c #F3F1E4", +"w c #EAE8D7", +"x c #DCDBC9", +"y c #9B9987", +"z c #626153", +"A c #575649", +"B c #515045", +"C c #727065", +"D c #9D9B90", +"E c #E2DFC7", +"F c #E7E3CE", +"G c #E0DECA", +"H c #CFCFC9", +"I c #8C8B7E", +"J c #757463", +"K c #676657", +"L c #424137", +"M c #282721", +"N c #1E1E1B", +"O c #333330", +"P c #4A4844", +"Q c #676662", +"R c #6F6E66", +"S c #6A6A64", +"T c #6D6B5D", +"U c #57564B", +"V c #383830", +"W c #161514", +"X c #191915", +"Y c #1E1D18", +"Z c #292923", +"` c #9E9E94", +" . c #4C4C40", +".. c #353530", +"+. c #292926", +"@. c #2E2E2A", +"#. c #0E0E0D", +"$. c #0A0A09", +"%. c #0F0F0C", +"&. c #3D3D37", +"*. c #33332A", +"=. c #23231E", +"-. c #2A2A23", +";. c #A3A297", +">. c #B5B4AC", +",. c #706F66", +"'. c #9F9F90", +"). c #737262", +"!. c #3F3F34", +"~. c #68685A", +"{. c #38382E", +"]. c #68685E", +"^. c #3E3E33", +"/. c #25251F", +". . . . . . . . . . . . . . ", +". . . . . . . . . . . . . . ", +". + . . . . + . ", +". @ . . . . . ", +" . . . . ", +" . . . . ", +" # $ % & * = - ", +" - ; > , ' ) ! ~ - - ", +" { ] ^ / ( _ : < [ } | - ", +" 1 2 3 4 5 6 7 8 9 0 a b c - ", +" - d e f g h i j k l m n o - ", +" - p q r s t u v w x y z A - ", +" - B C D E F G H I J K L M - ", +" N O P Q R S T U V W X Y ", +" Z ` ...+.@.#.$.%.&.*.=. ", +" -.;.>.,.'.).!.~.{.].^./. "}; +#endif diff --git a/bitmaps/Display_Options.xpm b/bitmaps/Display_Options.xpm new file mode 100644 index 0000000000..31d62a3aa0 --- /dev/null +++ b/bitmaps/Display_Options.xpm @@ -0,0 +1,114 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *display_options_xpm[]; + +#else +char * display_options_xpm[] = { +"16 16 90 1", +" c None", +". c #000000", +"+ c #E5E1E1", +"@ c #EDEDE9", +"# c #EDEDED", +"$ c #F1F1ED", +"% c #E9E5E5", +"& c #C9C5BE", +"* c #BDB9B1", +"= c #B5B1AD", +"- c #ADA9A2", +"; c #010101", +"> c #A3A197", +", c #9D9D9D", +"' c #A1A1A1", +") c #A1A5A1", +"! c #919591", +"~ c #818581", +"{ c #5D615D", +"] c #3D413D", +"^ c #2D312D", +"/ c #1D211D", +"( c #A7A299", +"_ c #9DA19D", +": c #8D918D", +"< c #717571", +"[ c #515551", +"} c #424842", +"| c #353935", +"1 c #ABA79C", +"2 c #E9E9E5", +"3 c #999D99", +"4 c #7D817D", +"5 c #797D79", +"6 c #F0F0F0", +"7 c #DEDEDE", +"8 c #DFDFDF", +"9 c #E0E0E0", +"0 c #BFBFBF", +"a c #C0C0C0", +"b c #C1C1C1", +"c c #D1D1CA", +"d c #676961", +"e c #707470", +"f c #979797", +"g c #989898", +"h c #B1ADA6", +"i c #52554F", +"j c #616561", +"k c #E3E3E3", +"l c #DDDDDD", +"m c #C8C8C8", +"n c #656565", +"o c #848484", +"p c #878787", +"q c #A9A59D", +"r c #313931", +"s c #353D35", +"t c #A3A3A3", +"u c #010100", +"v c #A19D94", +"w c #ADA999", +"x c #B1A9A1", +"y c #CFCFCF", +"z c #A4A4A4", +"A c #989897", +"B c #ABABAB", +"C c #EEEEEE", +"D c #999588", +"E c #838383", +"F c #8D8D81", +"G c #656561", +"H c #69655D", +"I c #696559", +"J c #B5B5B5", +"K c #757575", +"L c #6B6B6B", +"M c #777777", +"N c #888888", +"O c #54544C", +"P c #757169", +"Q c #79796E", +"R c #010000", +"S c #E0E0DF", +"T c #C1C1C0", +"U c #A7A7A7", +"V c #7B7B7B", +"W c #747474", +"X c #717171", +"Y c #7D7D7D", +"............... ", +".+@#@$$$@%+&*=-;", +".@;;;;;;;;;;;;>;", +".$;,')!!~{{]^/(;", +".$;_):~~<[[}|/1;", +".2;3:4........;.", +".2;~5.6788888898", +".+;~5.8000000aba", +".c;de.80f...gaba", +".h;ij.80.klm.nop", +".q;rs.80.lat..u.", +".vw-x;9a;yzA.BC#", +".D;;;.8ag...nEbb", +".FGHI.8aJKLnMN..", +" ;OPQRSTUVVWX.kl", +" .;;.8aY.....la"}; +#endif diff --git a/bitmaps/Edit.xpm b/bitmaps/Edit.xpm new file mode 100644 index 0000000000..acf1e9dc24 --- /dev/null +++ b/bitmaps/Edit.xpm @@ -0,0 +1,52 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *edit_xpm[]; + +#else +char * edit_xpm[] = { +"16 16 28 1", +" c None", +". c #000000", +"+ c #F9E53A", +"@ c #F0B44C", +"# c #FAE93C", +"$ c #F5B343", +"% c #635632", +"& c #FAE73A", +"* c #F5B344", +"= c #6B5E33", +"- c #F8E239", +"; c #F2B043", +"> c #615739", +", c #F7DD38", +"' c #F1AD41", +") c #615637", +"! c #F7DA37", +"~ c #EDB24C", +"{ c #655931", +"] c #F6D636", +"^ c #EEA73E", +"/ c #64582F", +"( c #F4D035", +"_ c #EBA23D", +": c #5B512F", +"< c #D5AC73", +"[ c #60552E", +"} c #4E4014", +" ", +" ... ", +" .+@. ", +" .#$%. ", +" .&*=. ", +" .-;>. ", +" .,'). ", +" .!~{. ", +" .]^/. ", +" .(_:. ", +" .<[. ", +" .}.. ", +" .. ", +" ", +" ", +" "}; +#endif diff --git a/bitmaps/Edit_Text.xpm b/bitmaps/Edit_Text.xpm new file mode 100644 index 0000000000..515f74c9ba --- /dev/null +++ b/bitmaps/Edit_Text.xpm @@ -0,0 +1,32 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *edit_text_xpm[]; + +#else +char * edit_text_xpm[] = { +"16 16 8 1", +" c None", +". c #1D2E40", +"+ c #1B2C3D", +"@ c #1B2B3D", +"# c #1E3043", +"$ c #1C2D3F", +"% c #111B26", +"& c #1C2C3E", +" ", +" ", +" .+ +@ ", +" ## ", +" ## ", +" ## ", +" ## ", +" ## ", +" ## ", +" ## ", +" ## ", +" ## ", +" ## ", +" .$ %&& ", +" ", +" "}; +#endif diff --git a/bitmaps/Exit.xpm b/bitmaps/Exit.xpm new file mode 100644 index 0000000000..d2d33d8b82 --- /dev/null +++ b/bitmaps/Exit.xpm @@ -0,0 +1,87 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *exit_xpm[]; + +#else +char * exit_xpm[] = { +"16 16 63 1", +" c None", +". c #000000", +"+ c #E2E2E0", +"@ c #D3D3D0", +"# c #C0C0BD", +"$ c #ADADAB", +"% c #929291", +"& c #B7B7B5", +"* c #9A9A98", +"= c #E46245", +"- c #DEDEDC", +"; c #C1C1BE", +"> c #B9B9B7", +", c #9C9C9B", +"' c #060806", +") c #070907", +"! c #E7755B", +"~ c #B3533E", +"{ c #D0D0CD", +"] c #0E110C", +"^ c #0F120D", +"/ c #DF421E", +"( c #B14D36", +"_ c #BDBDBB", +": c #A4A4A2", +"< c #161C14", +"[ c #191F16", +"} c #B0160A", +"| c #B11B10", +"1 c #993929", +"2 c #797977", +"3 c #5B5B5A", +"4 c #1D251B", +"5 c #20281D", +"6 c #990000", +"7 c #880000", +"8 c #AA3F2C", +"9 c #6C6C6A", +"0 c #273124", +"a c #2A3526", +"b c #C83E2B", +"c c #A1100B", +"d c #A3140E", +"e c #2B3727", +"f c #313D2C", +"g c #D4D4D1", +"h c #354331", +"i c #B4B4B2", +"j c #8D8D8B", +"k c #2D3A29", +"l c #3B4A35", +"m c #E0E0DE", +"n c #C9C9C7", +"o c #939491", +"p c #51544F", +"q c #34412F", +"r c #42543D", +"s c #495D43", +"t c #5C6059", +"u c #495C42", +"v c #4F6448", +"w c #53684B", +"x c #546A4D", +" ", +" .......... ", +" .+@#$%.... ", +" ...+@#&*.... ", +" .=.-@;>,.'). ", +"....!~.{;>,.]^. ", +".====/(._:,.<[. ", +".=}}}}|1.23.45. ", +".=666678.9,.0a. ", +".bcd778.;>,.ef. ", +"....78.g;>,.ah. ", +" .8.+g;ij.kl. ", +" ...mnop.qrs. ", +" .&t.luvwx. ", +" .......... ", +" "}; +#endif diff --git a/bitmaps/File_FootPrint.xpm b/bitmaps/File_FootPrint.xpm new file mode 100644 index 0000000000..81c8e7af67 --- /dev/null +++ b/bitmaps/File_FootPrint.xpm @@ -0,0 +1,62 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *file_footprint_xpm[]; + +#else +char * file_footprint_xpm[] = { +"16 16 38 1", +" c None", +". c #000000", +"+ c #F8F8F8", +"@ c #7C7C7C", +"# c #1E1E1E", +"$ c #FFFFFF", +"% c #ECECEC", +"& c #B3B3B3", +"* c #BBBBBB", +"= c #3D3D3D", +"- c #EBEBEB", +"; c #646464", +"> c #CACACA", +", c #B5B5B5", +"' c #A7A7A7", +") c #282828", +"! c #606060", +"~ c #C4C4C4", +"{ c #626262", +"] c #D2D2D2", +"^ c #AEAEAE", +"/ c #7D7D7D", +"( c #FEFEFE", +"_ c #D73333", +": c #AB8989", +"< c #E6E6E6", +"[ c #D93F3F", +"} c #D72E2E", +"| c #AC8989", +"1 c #D73838", +"2 c #AFAFAF", +"3 c #EAE4E4", +"4 c #615E5E", +"5 c #EAE5E5", +"6 c #FDFDFD", +"7 c #646161", +"8 c #ABABAB", +"9 c #050505", +" ......... ", +".++++++++@# ", +".$%%%%%%%&*= ", +".$-;;>>;;,'*) ", +".$-!~{{~!]^^/. ", +".(_:_<<[:_>>^. ", +".(}|}--1|}--2. ", +".(343--543--2. ", +".(_:_--[:_--2. ", +".(}|}--1|}--2. ", +".6343--543--2. ", +".6_:_--_:_--2. ", +".6}|}--}|}--2. ", +".6347;;743--2. ", +".228888882222. ", +"............9. "}; +#endif diff --git a/bitmaps/Fonts.xpm b/bitmaps/Fonts.xpm new file mode 100644 index 0000000000..822f4c153c --- /dev/null +++ b/bitmaps/Fonts.xpm @@ -0,0 +1,70 @@ +/* XPM */ +#ifndef XPMMAIN +extern const char *fonts_xpm[]; + +#else +const char * fonts_xpm[] = { +"16 16 46 1", +" c None", +". c #70653B", +"+ c #463F24", +"@ c #6B6139", +"# c #1B180D", +"$ c #2C2818", +"% c #595030", +"& c #252112", +"* c #292516", +"= c #70643B", +"- c #827544", +"; c #3D3721", +"> c #37311D", +", c #3E3721", +"' c #302B1A", +") c #5C5331", +"! c #010101", +"~ c #1A170E", +"{ c #1E1A10", +"] c #403922", +"^ c #584F2F", +"/ c #16140C", +"( c #1E1B10", +"_ c #312B1A", +": c #0F0D07", +"< c #2D2818", +"[ c #322D1A", +"} c #231F11", +"| c #3C3620", +"1 c #5A5230", +"2 c #332E1B", +"3 c #12100A", +"4 c #4F472A", +"5 c #413A23", +"6 c #302B19", +"7 c #342E1B", +"8 c #4A4227", +"9 c #6E633A", +"0 c #080704", +"a c #2F2919", +"b c #4C4529", +"c c #51472B", +"d c #242113", +"e c #322D1B", +"f c #5E5432", +"g c #211E12", +" ", +" .+ ", +" @ # ", +" $ ", +" %&* ", +" = * -;> ", +" , ' )!~ ", +" { !] ^!/ (_ ", +" :<[ }| 1!2 c #B5CADD", +", c #9BB5CE", +"' c #596776", +") c #DBE5EE", +"! c #F2F2F2", +"~ c #727679", +"{ c #D0DDE9", +"] c #BACCDF", +"^ c #AAC2D8", +"/ c #9DB1C5", +"( c #D7E2EC", +"_ c #85898D", +": c #A8B0B6", +"< c #A3AEBA", +"[ c #6F7B86", +"} c #C4D4DF", +"| c #C1CBD9", +"1 c #BDCFE0", +"2 c #CDDBE8", +"3 c #79838D", +"4 c #828B93", +"5 c #D7E1E7", +"6 c #CED5E0", +"7 c #8597A8", +"8 c #ADC2D4", +"9 c #B7C8D9", +"0 c #BCCDDC", +"a c #C4D1DF", +"b c #8A939A", +"c c #D1DAE2", +"d c #868F97", +"e c #6D7F90", +"f c #93A7B9", +"g c #A1B4C4", +"h c #8A95A1", +"i c #868F9A", +"j c #7E8892", +"k c #B4AA89", +"l c #C4B069", +"m c #A19156", +"n c #A49B7E", +"o c #F8EECD", +"p c #FDFDFB", +"q c #F6E9BD", +"r c #D8C274", +"s c #686350", +"t c #F5F0DF", +"u c #FCF8EC", +"v c #EADFB7", +"w c #B2A05F", +"x c #3B382D", +" ", +" .... ", +" .+@#$%&. ", +" .+*=-;>,'. ", +" .)=!~{]^/. ", +" .(-_:<[}|. ", +" .1;{23456. ", +" 7890abcd. ", +" .efghij. ", +" .klmn. ", +" .opqr. ", +" slms ", +" .tuvw. ", +" x... ", +" .. ", +" "}; +#endif diff --git a/bitmaps/Mirror_H.xpm b/bitmaps/Mirror_H.xpm new file mode 100644 index 0000000000..a130721c4d --- /dev/null +++ b/bitmaps/Mirror_H.xpm @@ -0,0 +1,53 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *mirror_H_xpm[]; + +#else +char * mirror_H_xpm[] = { +"16 16 29 1", +" c None", +". c #000000", +"+ c #9B9B9B", +"@ c #858585", +"# c #4C4C4C", +"$ c #1A1A1A", +"% c #939393", +"& c #696969", +"* c #606060", +"= c #D2D2D2", +"- c #202020", +"; c #FFFFFF", +"> c #3C3C3C", +", c #737373", +"' c #A0A0A5", +") c #373737", +"! c #EAEAF9", +"~ c #141417", +"{ c #F9F9FF", +"] c #E9E8FF", +"^ c #666578", +"/ c #F2F2FF", +"( c #E2E1FF", +"_ c #B7B6DF", +": c #0F0E0F", +"< c #EBEAFF", +"[ c #DAD9FF", +"} c #CAC9FF", +"| c #36364B", +" . ", +" .+ ", +" .+. ", +" .+.@ ", +" +.# ", +" .$% ", +" . .&* ", +" .+.=- ", +" .+.;>, ", +" .+.;') ", +" +.;!~@ ", +" .{]^# ", +" . ./(_:% ", +" .+.<[}|* ", +" .+.....- ", +" .+ ++++++"}; +#endif diff --git a/bitmaps/Mirror_V.xpm b/bitmaps/Mirror_V.xpm new file mode 100644 index 0000000000..02b0b6016f --- /dev/null +++ b/bitmaps/Mirror_V.xpm @@ -0,0 +1,55 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *mirror_V_xpm[]; + +#else +char * mirror_V_xpm[] = { +"16 16 30 1", +" c None", +". c #000000", +"+ c #9B9B9B", +"@ c #E3E3FF", +"# c #EBEAFF", +"$ c #F2F2FF", +"% c #F9F9FF", +"& c #FFFFFF", +"* c #D2D2D2", +"= c #696969", +"- c #1A1A1A", +"; c #4D4D4D", +"> c #8C8C8C", +", c #D3D2FF", +"' c #DAD9FF", +") c #E2E1FF", +"! c #E4E3F9", +"~ c #9B9BA5", +"{ c #3A3A3C", +"] c #202020", +"^ c #636363", +"/ c #979797", +"( c #C3C1FF", +"_ c #B1B0DF", +": c #626278", +"< c #141417", +"[ c #373737", +"} c #7A7A7A", +"| c #34344B", +"1 c #0E0E0F", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +".... .... ....", +" ++++ ++++ +++", +" ............. ", +" .@#$%&&*=-;>++ ", +" .,')!~{]^/++ ", +" .(_:<[}++ ", +" .|1;>++ ", +" .^/++ ", +" + "}; +#endif + diff --git a/bitmaps/Morgan1.xpm b/bitmaps/Morgan1.xpm new file mode 100644 index 0000000000..a795ca6869 --- /dev/null +++ b/bitmaps/Morgan1.xpm @@ -0,0 +1,103 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *morgan1_xpm[]; + +#else +char * morgan1_xpm[] = { +"16 16 79 1", +" c None", +". c #6361D1", +"+ c #6260D0", +"@ c #5452B1", +"# c #474596", +"$ c #5B5AC2", +"% c #5E5CC7", +"& c #615FCE", +"* c #302F66", +"= c #5251AE", +"- c #514FAB", +"; c #504EA9", +"> c #5A59C0", +", c #5755B9", +"' c #D72E2E", +") c #D72D2D", +"! c #D62E2E", +"~ c #FEFEFF", +"{ c #FBFBFF", +"] c #F6F6FF", +"^ c #F1F1FF", +"/ c #EBE9FC", +"( c #E3C5D9", +"_ c #DA727E", +": c #D13737", +"< c #FAFAFF", +"[ c #F5F5FF", +"} c #F0F0FF", +"| c #EBEBFF", +"1 c #E6E6FF", +"2 c #E1E1FF", +"3 c #DBDBFF", +"4 c #D65F6B", +"5 c #BE5A5A", +"6 c #9B9B9B", +"7 c #D53131", +"8 c #F4F4FF", +"9 c #EFEFFF", +"0 c #EAEAFF", +"a c #E5E5FF", +"b c #E0E0FF", +"c c #D6D6FF", +"d c #D398B6", +"e c #D13838", +"f c #D43232", +"g c #E4E4FF", +"h c #DFDFFF", +"i c #DADAFF", +"j c #D5D5FF", +"k c #D0D0FF", +"l c #CBBCEC", +"m c #B5CCFF", +"n c #D62D2D", +"o c #E9E9FF", +"p c #D4D4FF", +"q c #CFCFFF", +"r c #CACAFF", +"s c #CB92B8", +"t c #D03838", +"u c #B56A6A", +"v c #E3E3FF", +"w c #DEDEFF", +"x c #D9D9FF", +"y c #C9C9FF", +"z c #C4C4FF", +"A c #CF5C70", +"B c #BB5E5E", +"C c #DDDDFF", +"D c #D8D8FF", +"E c #D3D3FF", +"F c #CECEFF", +"G c #C9C7FC", +"H c #C6A9DA", +"I c #CD6983", +"J c #CE3D3D", +"K c #9E9494", +"L c #D52E2E", +"M c #CD4040", +"N c #BE5B5B", +" .... ", +" .+@#$+% ", +".&* =.- ... ", +".# .; .> ,,", +".# ....& .", +" ", +" ''''''') ", +" !~{]^/(_: ", +"'''<[}|12345 ", +" 67890ab3cdef ", +" !90ghijkl!mn''", +" !oghipqrs:tu66", +" !vwxpqyzAB6 ", +"'''CDEFGHIJK ", +" 67''''LMNK6 ", +" 66666666 "}; +#endif diff --git a/bitmaps/Morgan2.xpm b/bitmaps/Morgan2.xpm new file mode 100644 index 0000000000..eb3d21e33c --- /dev/null +++ b/bitmaps/Morgan2.xpm @@ -0,0 +1,101 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *morgan2_xpm[]; + +#else +char * morgan2_xpm[] = { +"16 16 77 1", +" c None", +". c #6361D1", +"+ c #615FCE", +"@ c #4D4CA3", +"# c #4E4CA5", +"$ c #6260D0", +"% c #605ECC", +"& c #5755B8", +"* c #5F5DC8", +"= c #5F5DCA", +"- c #504EA9", +"; c #615FCD", +"> c #5958BD", +", c #5E5CC7", +"' c #4F4DA7", +") c #D72D2D", +"! c #D72E2E", +"~ c #D62D2D", +"{ c #D52D2D", +"] c #EEB7BA", +"^ c #F6F6FF", +"/ c #F1F1FF", +"( c #EAE1F3", +"_ c #E0A1B1", +": c #D73A3C", +"< c #D32D2D", +"[ c #B5CCFF", +"} c #D12C2C", +"| c #D93F40", +"1 c #EEE6F4", +"2 c #EBEBFF", +"3 c #E6E6FF", +"4 c #E1E1FF", +"5 c #DAC2E1", +"6 c #D6383B", +"7 c #C52A2A", +"8 c #992121", +"9 c #CD2B2B", +"0 c #921F1F", +"a c #E5B6C5", +"b c #E5E5FF", +"c c #E0E0FF", +"d c #DBDBFF", +"e c #D6D6FF", +"f c #D2A1C2", +"g c #D62E2E", +"h c #DE93A2", +"i c #DFDFFF", +"j c #DADAFF", +"k c #D5D5FF", +"l c #D0D0FF", +"m c #CBCBFF", +"n c #D25C6D", +"o c #DCA3B8", +"p c #D4D4FF", +"q c #CFCFFF", +"r c #CACAFF", +"s c #CA99C2", +"t c #5E1414", +"u c #D73233", +"v c #D8C6E8", +"w c #C9C9FF", +"x c #C6AEE1", +"y c #D5373B", +"z c #8F1E1E", +"A c #CE2B2B", +"B c #D795AD", +"C c #D3D3FF", +"D c #CECEFF", +"E c #C9C0F3", +"F c #CB8CB1", +"G c #D4373C", +"H c #A02222", +"I c #B12525", +"J c #D32C2C", +"K c #B92727", +"L c #6F1818", +" .... ", +" ..+@#$% ", +"... ..& *. ", +"= -; .. >. ", +" ,...' .. ", +" ", +" )!!!!!! ", +" ~{]^/(_:< ", +"!~[}|1234567 ", +" 890{abcdefg ", +" {hijklmn}!!!", +" ! !ojpqrs~t ", +"!~[}uvpqwxyz ", +" 8A9BCDEFGH ", +" I!!!!JKL ", +" "}; +#endif diff --git a/bitmaps/Move.xpm b/bitmaps/Move.xpm new file mode 100644 index 0000000000..f34e25fa43 --- /dev/null +++ b/bitmaps/Move.xpm @@ -0,0 +1,72 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *move_xpm[]; + +#else +char * move_xpm[] = { +"16 16 48 1", +" c None", +". c #000000", +"+ c #31313D", +"@ c #DCDCEF", +"# c #33333F", +"$ c #595959", +"% c #84849B", +"& c #FFFFFF", +"* c #010101", +"= c #4B4B4B", +"- c #9B9B9B", +"; c #F1F1FF", +"> c #464646", +", c #E7E5FF", +"' c #5D5D84", +") c #232332", +"! c #767676", +"~ c #FBFBFF", +"{ c #EAEAFF", +"] c #E2E1FF", +"^ c #DBDBFF", +"/ c #D5D3FF", +"( c #CDCDFF", +"_ c #C8C6FF", +": c #C1C1FF", +"< c #BDBBFF", +"[ c #B7B7FF", +"} c #9594D7", +"| c #202020", +"1 c #33333E", +"2 c #808099", +"3 c #D2D0FF", +"4 c #53527C", +"5 c #222231", +"6 c #7D7D7D", +"7 c #C8C8FF", +"8 c #6C6C6C", +"9 c #C0BFFF", +"0 c #B8B8FF", +"a c #B2B0FF", +"b c #52527B", +"c c #ABAAFF", +"d c #4C4C76", +"e c #3E3E3E", +"f c #1F1F2F", +"g c #8887D0", +"h c #1F1F2E", +"i c #181818", +" . ", +" +@#$ ", +" .%&%*= ", +" .&.--- ", +" .&.-- ", +" . .;.-- .> ", +" +%....,.....')!", +".@&~;{]^/(_:<[}|", +" 12....3.....456", +" *---.7.----*8-", +" -- .9.-- --", +" .0.-- ", +" .a.-- ", +" .bcd*e ", +" fgh8-- ", +" i6-- "}; +#endif diff --git a/bitmaps/Move_Arc.xpm b/bitmaps/Move_Arc.xpm new file mode 100644 index 0000000000..5af7af45fc --- /dev/null +++ b/bitmaps/Move_Arc.xpm @@ -0,0 +1,80 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *move_arc_xpm[]; + +#else +char * move_arc_xpm[] = { +"16 16 56 1", +" c None", +". c #00009B", +"+ c #000099", +"@ c #000097", +"# c #000096", +"$ c #000073", +"% c #000039", +"& c #000036", +"* c #000051", +"= c #000086", +"- c #00008E", +"; c #000006", +"> c #00006D", +", c #000085", +"' c #31313D", +") c #DCDCEF", +"! c #31313C", +"~ c #00005D", +"{ c #000074", +"] c #000000", +"^ c #84849B", +"/ c #FFFFFF", +"( c #00004C", +"_ c #000095", +": c #000078", +"< c #000050", +"[ c #000058", +"} c #F1F1FF", +"| c #000001", +"1 c #00003B", +"2 c #E7E5FF", +"3 c #646489", +"4 c #232333", +"5 c #FBFBFF", +"6 c #EAEAFF", +"7 c #E2E1FF", +"8 c #DBDBFF", +"9 c #D5D3FF", +"0 c #CDCDFF", +"a c #C8C6FF", +"b c #C1C1FF", +"c c #9F9DDB", +"d c #30303B", +"e c #7A7A96", +"f c #D2D0FF", +"g c #5A5981", +"h c #1F1F2F", +"i c #C8C8FF", +"j c #00000D", +"k c #C0BFFF", +"l c #5C5C82", +"m c #B8B8FF", +"n c #56557D", +"o c #20202F", +"p c #9493D6", +"q c #1D1D2C", +" ..... ", +" ........+@ ", +" #$% &*=..- ", +" ;>., ", +" ')!~.{ ", +" ]^/^](_ ", +" ]/] :<[ ", +" ] ]}] .|1 ", +" '^]]]2]]]34 ", +" ])5}67890abc]", +" de]]]f]]]gh]", +" ] ]i] |j ", +" ] ]k] ] ", +" ]lmn]] ", +" opq] ", +" ] "}; +#endif diff --git a/bitmaps/Move_Circle.xpm b/bitmaps/Move_Circle.xpm new file mode 100644 index 0000000000..f2ebf10b52 --- /dev/null +++ b/bitmaps/Move_Circle.xpm @@ -0,0 +1,73 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *move_circle_xpm[]; + +#else +char * move_circle_xpm[] = { +"16 16 49 1", +" c None", +". c #00009B", +"+ c #000096", +"@ c #00008C", +"# c #000053", +"$ c #00008A", +"% c #00009A", +"& c #000073", +"* c #000000", +"= c #000092", +"- c #31313D", +"; c #DCDCEF", +"> c #31313C", +", c #000055", +"' c #00006F", +") c #84849B", +"! c #FFFFFF", +"~ c #00004C", +"{ c #000083", +"] c #00007C", +"^ c #00004A", +"/ c #F1F1FF", +"( c #000001", +"_ c #E7E5FF", +": c #646489", +"< c #232332", +"[ c #FBFBFF", +"} c #EAEAFF", +"| c #E2E1FF", +"1 c #DBDBFF", +"2 c #D5D3FF", +"3 c #CDCDFF", +"4 c #C8C6FF", +"5 c #C1C1FF", +"6 c #9F9DDB", +"7 c #30303B", +"8 c #7A7A96", +"9 c #D2D0FF", +"0 c #5A5981", +"a c #1F1F2F", +"b c #C8C8FF", +"c c #000062", +"d c #00002E", +"e c #C0BFFF", +"f c #5C5C82", +"g c #B8B8FF", +"h c #56557D", +"i c #9493D6", +"j c #1D1D2C", +" .... ", +" .......+ ", +" ..@# #$.% ", +" ..& *#.= ", +" .@ -;>,.' ", +"..# *)!)*~{ ", +".. *!* ]^ ", +".. * */* .(* ", +"..# -)***_***:< ", +" .$*;[/}|123456*", +" +.#78***9***0a ", +" %.,* *b*cd** ", +" =.~].*e*d * ", +" '{^(fgh** ", +" *aij* ", +" * "}; +#endif diff --git a/bitmaps/Move_Field.xpm b/bitmaps/Move_Field.xpm new file mode 100644 index 0000000000..27cefc6901 --- /dev/null +++ b/bitmaps/Move_Field.xpm @@ -0,0 +1,86 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *move_field_xpm[]; + +#else +char * move_field_xpm[] = { +"16 16 62 1", +" c None", +". c #D2D2D2", +"+ c #9D9D9D", +"@ c #DEDEDE", +"# c #E0E0E0", +"$ c #5C5C5C", +"% c #000000", +"& c #EDEDED", +"* c #939393", +"= c #FDFDFD", +"- c #E4E4E4", +"; c #F1F1F1", +"> c #C3C3C3", +", c #272727", +"' c #E7E7E7", +") c #F4F4F4", +"! c #30303B", +"~ c #DCDCEF", +"{ c #33333E", +"] c #9A9A9A", +"^ c #E9E9E9", +"/ c #8C8C8C", +"( c #84849B", +"_ c #FFFFFF", +": c #010101", +"< c #7C7C7C", +"[ c #FAFAFA", +"} c #B0B0B0", +"| c #7A7A7A", +"1 c #848484", +"2 c #999999", +"3 c #F0F0F0", +"4 c #B1B1B1", +"5 c #020202", +"6 c #CBCBCB", +"7 c #F1F1FF", +"8 c #989898", +"9 c #7F7F7F", +"0 c #343440", +"a c #E7E5FF", +"b c #646489", +"c c #262635", +"d c #FBFBFF", +"e c #EAEAFF", +"f c #E2E1FF", +"g c #DBDBFF", +"h c #D5D3FF", +"i c #CDCDFF", +"j c #C8C6FF", +"k c #C1C1FF", +"l c #9F9DDB", +"m c #7A7A96", +"n c #D2D0FF", +"o c #5A5981", +"p c #20202F", +"q c #C8C8FF", +"r c #C0BFFF", +"s c #5C5C82", +"t c #B8B8FF", +"u c #56557D", +"v c #9493D6", +"w c #1D1D2C", +".++++++++++++++.", +"+.@@@@@@@@@@@@@+", +"+#$%%$&%%%*&===+", +"+-%;;%;%>,%;===+", +"+'%))%)%!~{]===+", +"+^%%%%/%(_(:<==+", +"+&%[[%-%%_%}|12+", +"+3==456=%7%6=58+", +".++90(%%%a%%%bc]", +" %~d7efghijkl%", +" !m%%%n%%%op ", +" % %q% %% ", +" % %r% % ", +" %stu%% ", +" pvw% ", +" % "}; +#endif diff --git a/bitmaps/Move_Line.xpm b/bitmaps/Move_Line.xpm new file mode 100644 index 0000000000..d7d31e9f5d --- /dev/null +++ b/bitmaps/Move_Line.xpm @@ -0,0 +1,72 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *move_line_xpm[]; + +#else +char * move_line_xpm[] = { +"16 16 48 1", +" c None", +". c #00009B", +"+ c #29299B", +"@ c #43439B", +"# c #45459B", +"$ c #46469B", +"% c #9B9B9B", +"& c #47479B", +"* c #39397D", +"= c #0D0D1E", +"- c #353575", +"; c #70709A", +"> c #2E2E9B", +", c #49499B", +"' c #4A4A9B", +") c #565656", +"! c #32323E", +"~ c #DCDCEF", +"{ c #4A4A4A", +"] c #000000", +"^ c #84849B", +"/ c #FFFFFF", +"( c #F1F1FF", +"_ c #31313D", +": c #E7E5FF", +"< c #646489", +"[ c #232332", +"} c #FBFBFF", +"| c #EAEAFF", +"1 c #E2E1FF", +"2 c #DBDBFF", +"3 c #D5D3FF", +"4 c #CDCDFF", +"5 c #C8C6FF", +"6 c #C1C1FF", +"7 c #9F9DDB", +"8 c #30303B", +"9 c #7A7A96", +"0 c #D2D0FF", +"a c #5A5981", +"b c #20202F", +"c c #C8C8FF", +"d c #C0BFFF", +"e c #5C5C82", +"f c #B8B8FF", +"g c #56557D", +"h c #9493D6", +"i c #1D1D2C", +" ", +"..... ...... ...", +"+@@#$% &*=-; >,'", +" %%%%% )!~!{ %%", +" ]^/^]] ", +" ]/] ", +" ] ](] ] ", +" _^]]]:]]]<[ ", +" ]~}(|1234567]", +" 89]]]0]]]ab ", +" ] ]c] ]] ", +" ] ]d] ] ", +" ]efg]] ", +" bhi] ", +" ] ", +" "}; +#endif diff --git a/bitmaps/Move_Polygon.xpm b/bitmaps/Move_Polygon.xpm new file mode 100644 index 0000000000..6a1123a8ff --- /dev/null +++ b/bitmaps/Move_Polygon.xpm @@ -0,0 +1,70 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *move_polygon_xpm[]; + +#else +char * move_polygon_xpm[] = { +"16 16 46 1", +" c None", +". c #00009B", +"+ c #000099", +"@ c #00007D", +"# c #000094", +"$ c #000074", +"% c #00001E", +"& c #000066", +"* c #31313D", +"= c #DCDCEF", +"- c #30303E", +"; c #000046", +"> c #000000", +", c #84849B", +"' c #FFFFFF", +") c #000001", +"! c #00006D", +"~ c #F1F1FF", +"{ c #00007C", +"] c #E7E5FF", +"^ c #646489", +"/ c #232332", +"( c #FBFBFF", +"_ c #EAEAFF", +": c #E2E1FF", +"< c #DBDBFF", +"[ c #D5D3FF", +"} c #CDCDFF", +"| c #C8C6FF", +"1 c #C1C1FF", +"2 c #9F9DDB", +"3 c #30303B", +"4 c #7A7A96", +"5 c #D2D0FF", +"6 c #5A5981", +"7 c #20202F", +"8 c #000062", +"9 c #C8C8FF", +"0 c #000063", +"a c #00004C", +"b c #C0BFFF", +"c c #5C5C82", +"d c #B8B8FF", +"e c #56557D", +"f c #9493D6", +"g c #1D1D2C", +"........ ", +"........+ ", +" @.# ", +" $%& ", +" *=-; ", +" >,',)> ", +" >'>!> ", +" > >~>{ > ", +" *,>>>]>>>^/ ", +" >=(~_:<[}|12>", +" 34>>>5>>>67 ", +" ...8)!{>9>0>>> ", +" ....a{.>b>{ > ", +" >>cde>> ", +" 7fg> ", +" > "}; +#endif diff --git a/bitmaps/Move_Rectangle.xpm b/bitmaps/Move_Rectangle.xpm new file mode 100644 index 0000000000..96e55499c2 --- /dev/null +++ b/bitmaps/Move_Rectangle.xpm @@ -0,0 +1,64 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *move_rectangle_xpm[]; + +#else +char * move_rectangle_xpm[] = { +"16 16 40 1", +" c None", +". c #00009B", +"+ c #000000", +"@ c #31313D", +"# c #DCDCEF", +"$ c #31313C", +"% c #000062", +"& c #84849B", +"* c #FFFFFF", +"= c #000001", +"- c #00004C", +"; c #00006D", +"> c #00007C", +", c #F1F1FF", +"' c #E7E5FF", +") c #646489", +"! c #232332", +"~ c #FBFBFF", +"{ c #EAEAFF", +"] c #E2E1FF", +"^ c #DBDBFF", +"/ c #D5D3FF", +"( c #CDCDFF", +"_ c #C8C6FF", +": c #C1C1FF", +"< c #9F9DDB", +"[ c #30303B", +"} c #7A7A96", +"| c #D2D0FF", +"1 c #5A5981", +"2 c #20202F", +"3 c #C8C8FF", +"4 c #000063", +"5 c #C0BFFF", +"6 c #00006F", +"7 c #5C5C82", +"8 c #B8B8FF", +"9 c #56557D", +"0 c #9493D6", +"a c #1D1D2C", +"............. ", +"............. ", +".. .. ", +".. + .. ", +".. @#$%. ", +".. +&*&=- ", +".. +*+;>+ ", +".. + +,+>.+ ", +".. @&+++'+++)! ", +".. +#~,{]^/(_:<+", +".. [}+++|+++12 ", +"....%=;>+3+4>++ ", +".....->.+5+>6+ ", +" ++789++ ", +" 20a+ ", +" + "}; +#endif diff --git a/bitmaps/Move_Text.xpm b/bitmaps/Move_Text.xpm new file mode 100644 index 0000000000..79bc300036 --- /dev/null +++ b/bitmaps/Move_Text.xpm @@ -0,0 +1,70 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *move_text_xpm[]; + +#else +char * move_text_xpm[] = { +"16 16 46 1", +" c None", +". c #00009B", +"+ c #000098", +"@ c #00005D", +"# c #00007D", +"$ c #000000", +"% c #00006C", +"& c #303040", +"* c #DCDCEF", +"= c #31313C", +"- c #000058", +"; c #000001", +"> c #84849B", +", c #FFFFFF", +"' c #00008D", +") c #00007C", +"! c #F1F1FF", +"~ c #31313D", +"{ c #E7E5FF", +"] c #646489", +"^ c #232332", +"/ c #FBFBFF", +"( c #EAEAFF", +"_ c #E2E1FF", +": c #DBDBFF", +"< c #D5D3FF", +"[ c #CDCDFF", +"} c #C8C6FF", +"| c #C1C1FF", +"1 c #9F9DDB", +"2 c #30303B", +"3 c #7A7A96", +"4 c #D2D0FF", +"5 c #5A5981", +"6 c #20202F", +"7 c #00006D", +"8 c #C8C8FF", +"9 c #00004C", +"0 c #C0BFFF", +"a c #000050", +"b c #5C5C82", +"c c #B8B8FF", +"d c #56557D", +"e c #1F1F31", +"f c #9493D6", +"g c #1C1C2F", +".............. ", +".............. ", +".+ .... +. ", +".@ ...#$ . ", +" ..%&*= ", +" .-;>,>$$ ", +" -')$,$ ", +" ;).$!$ $ ", +" ~>$$${$$$]^ ", +" $*/!(_:<[}|1$", +" 23$$$4$$$56 ", +" ;7)$8$ $$ ", +" 9).$0$ $ ", +" ..a;bcd$$ ", +" ....@efg$ ", +" $$$ "}; +#endif diff --git a/bitmaps/New_Library.xpm b/bitmaps/New_Library.xpm new file mode 100644 index 0000000000..2223098144 --- /dev/null +++ b/bitmaps/New_Library.xpm @@ -0,0 +1,157 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *new_library_xpm[]; + +#else +char * new_library_xpm[] = { +"16 16 133 2", +" c None", +". c #060708", +"+ c #323538", +"@ c #1E1E1F", +"# c #FFF500", +"$ c #0A0D0E", +"% c #E4E6E7", +"& c #F5F5F5", +"* c #919175", +"= c #EFE500", +"- c #B4B272", +"; c #F6F6F6", +"> c #D7D7D7", +", c #DFE0E1", +"' c #636222", +") c #F7EE0B", +"! c #F7ED0C", +"~ c #9B9B9B", +"{ c #050608", +"] c #E3E6E7", +"^ c #D7D8D8", +"/ c #D1D1D1", +"( c #A9A881", +"_ c #070A0D", +": c #E5E7E9", +"< c #F8F8F8", +"[ c #D4D4D4", +"} c #BCBCBC", +"| c #CCCCCC", +"1 c #C9C9C9", +"2 c #B4B172", +"3 c #F7EE0C", +"4 c #FBF101", +"5 c #020305", +"6 c #9E9E9F", +"7 c #F4F4F5", +"8 c #CECECE", +"9 c #CFCFCF", +"0 c #B5B5B5", +"a c #CBCAAC", +"b c #FBF20F", +"c c #CBC888", +"d c #F6ED0B", +"e c #626144", +"f c #353535", +"g c #0A0A0A", +"h c #000000", +"i c #838686", +"j c #B3B7BB", +"k c #DDDDDD", +"l c #B7B7B7", +"m c #C8C8C8", +"n c #C4C4C4", +"o c #B7BABD", +"p c #A8AA8F", +"q c #A1A1A1", +"r c #E4E3C6", +"s c #A2A2A2", +"t c #DFDFDF", +"u c #232324", +"v c #1B1B1B", +"w c #98999B", +"x c #BBBBBB", +"y c #C3C3C3", +"z c #BCBDBE", +"A c #A2A5A7", +"B c #CECFD0", +"C c #DADBDB", +"D c #E1E2E3", +"E c #F6F7F8", +"F c #D6D6D8", +"G c #AEB0B1", +"H c #7B7E80", +"I c #B3B6B8", +"J c #BFBFBF", +"K c #AEB1B5", +"L c #B9BBBC", +"M c #F2F2F2", +"N c #FBFCFC", +"O c #F8FAFB", +"P c #F7F8F9", +"Q c #CACBCD", +"R c #858B91", +"S c #171818", +"T c #737E87", +"U c #B9B9B9", +"V c #D8D8D8", +"W c #A7AAAC", +"X c #E4E4E4", +"Y c #E5E5E5", +"Z c #E3E4E4", +"` c #F9FAFB", +" . c #DEDFDF", +".. c #B3B6BA", +"+. c #171A1D", +"@. c #414447", +"#. c #8D9398", +"$. c #ABADAF", +"%. c #FEFEFE", +"&. c #FDFDFD", +"*. c #F9FAFA", +"=. c #F9F9FA", +"-. c #CBCDD0", +";. c #737B84", +">. c #626973", +",. c #868788", +"'. c #EAEAEA", +"). c #FDFEFE", +"!. c #FCFDFD", +"~. c #FAFBFB", +"{. c #EFF0F0", +"]. c #A8ADB3", +"^. c #15171A", +"/. c #11151A", +"(. c #47515D", +"_. c #C0C6CC", +":. c #C4C8CB", +"<. c #D5D6D7", +"[. c #DBDBDB", +"}. c #F3F4F4", +"|. c #D1D1D2", +"1. c #798087", +"2. c #191B1D", +"3. c #2A2D30", +"4. c #474D50", +"5. c #7E8284", +"6. c #9B9D9F", +"7. c #9FA5AB", +"8. c #91989E", +"9. c #0C0E10", +"0. c #2A333D", +"a. c #181D21", +"b. c #1D2227", +" . + @ # ", +" $ % & * = # - # ", +" $ % ; > , ' ) # ! ~ ", +" { ] ; ^ / # # # ( # # # ", +" _ : < [ } | 1 2 3 # 4 2 ~ ~ ", +"5 6 7 8 9 | 0 a b c # 2 d e f g ", +"h i j k l m n o p q # ~ r s t u ", +" v w x m y z A B C D ~ E F G h ", +" h H I t J K L M N O P E Q R h ", +" S T U V W X Y Z ` P ...+. ", +" h @.#.$.[ %.&.N *.=.-.;.h ", +" h >.,.Y '.).!.~.{.].^. ", +" /.(._.:.<.[.}.|.1.h ", +" 2.3.4.5.6.7.8.9. ", +" 0.a.b. ", +" "}; +#endif diff --git a/bitmaps/Open_Library.xpm b/bitmaps/Open_Library.xpm new file mode 100644 index 0000000000..b5a456db17 --- /dev/null +++ b/bitmaps/Open_Library.xpm @@ -0,0 +1,159 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *open_library_xpm[]; + +#else +char * open_library_xpm[] = { +"16 16 135 2", +" c None", +". c #060708", +"+ c #323538", +"@ c #1E1E1F", +"# c #0A0D0E", +"$ c #E4E6E7", +"% c #F5F5F5", +"& c #828486", +"* c #040405", +"= c #F6F6F6", +"- c #D5D5D5", +"; c #DFE0E1", +"> c #1F2021", +", c #050608", +"' c #E3E6E7", +") c #F2F2F2", +"! c #7B7C7C", +"~ c #212121", +"{ c #DADADA", +"] c #BEBFC2", +"^ c #0E0E0E", +"/ c #070A0D", +"( c #E5E7E9", +"_ c #191919", +": c #777777", +"< c #C9C9C9", +"[ c #DCDDDD", +"} c #525354", +"| c #020305", +"1 c #9E9E9F", +"2 c #F4F4F5", +"3 c #3F3F3F", +"4 c #292929", +"5 c #272727", +"6 c #A6A7A8", +"7 c #C5C5C5", +"8 c #555555", +"9 c #343434", +"0 c #353535", +"a c #0A0A0A", +"b c #000000", +"c c #838686", +"d c #B3B7BB", +"e c #DDDDDD", +"f c #9A9A9A", +"g c #171717", +"h c #949494", +"i c #6D6D6E", +"j c #0F0F10", +"k c #999A9A", +"l c #FBFCFC", +"m c #FBFBFB", +"n c #FAFAFB", +"o c #F9FAFB", +"p c #E9E9E9", +"q c #232324", +"r c #1B1B1B", +"s c #98999B", +"t c #BBBBBB", +"u c #C2C2C2", +"v c #9E9E9E", +"w c #BBBCBD", +"x c #9EA0A1", +"y c #8A8B8B", +"z c #141414", +"A c #BABBBC", +"B c #F7F8F9", +"C c #F6F7F8", +"D c #DFDFE1", +"E c #AEB0B1", +"F c #7B7E80", +"G c #B3B6B8", +"H c #DFDFDF", +"I c #BEBEBE", +"J c #AEB1B5", +"K c #B9BBBC", +"L c #6B6B6B", +"M c #333334", +"N c #E0E1E2", +"O c #CDCECF", +"P c #CACBCD", +"Q c #858B91", +"R c #171818", +"S c #737E87", +"T c #B9B9B9", +"U c #D8D8D8", +"V c #A7AAAC", +"W c #E4E4E4", +"X c #D7D7D7", +"Y c #767676", +"Z c #4A4A4B", +"` c #626262", +" . c #B3B6BA", +".. c #171A1D", +"+. c #414447", +"@. c #8D9398", +"#. c #ABADAF", +"$. c #D4D4D4", +"%. c #FEFEFE", +"&. c #D0D0D0", +"*. c #323232", +"=. c #0D0D0D", +"-. c #060606", +";. c #AEAFB1", +">. c #737B84", +",. c #626973", +"'. c #868788", +"). c #E5E5E5", +"!. c #EAEAEA", +"~. c #E9EAEA", +"{. c #ABABAB", +"]. c #505050", +"^. c #4D4D4D", +"/. c #A7ACB2", +"(. c #15171A", +"_. c #11151A", +":. c #47515D", +"<. c #C0C6CC", +"[. c #C4C8CB", +"}. c #D5D6D7", +"|. c #D9D9D9", +"1. c #BCBCBC", +"2. c #BCBCBD", +"3. c #798087", +"4. c #191B1D", +"5. c #2A2D30", +"6. c #474D50", +"7. c #7E8284", +"8. c #9B9D9F", +"9. c #9FA5AB", +"0. c #91989E", +"a. c #0C0E10", +"b. c #2A333D", +"c. c #181D21", +"d. c #1D2227", +" . + @ ", +" # $ % & * ", +" # $ = - ; > ", +" , ' ) ! ~ { ] ^ ", +" / ( = ^ _ : < [ } ", +"| 1 2 < 3 ~ 4 5 6 7 8 9 9 9 0 a ", +"b c d e f g h i j k l m n o p q ", +" r s t u v w x y z A B C D E b ", +" b F G H I J K e L M N O P Q b ", +" R S T U V W X Y 5 Z ` ... ", +" b +.@.#.$.%.&.*.=.-.;.>.b ", +" b ,.'.).!.~.{.].^./.(. ", +" _.:.<.[.}.|.1.2.3.b ", +" 4.5.6.7.8.9.0.a. ", +" b.c.d. ", +" "}; +#endif diff --git a/bitmaps/Options_Arc.xpm b/bitmaps/Options_Arc.xpm new file mode 100644 index 0000000000..11f9eccb81 --- /dev/null +++ b/bitmaps/Options_Arc.xpm @@ -0,0 +1,73 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *options_arc_xpm[]; + +#else +char * options_arc_xpm[] = { +"16 16 49 1", +" c None", +". c #00009B", +"+ c #000099", +"@ c #000097", +"# c #000096", +"$ c #000073", +"% c #000039", +"& c #000036", +"* c #000051", +"= c #000086", +"- c #00008E", +"; c #000093", +"> c #000085", +", c #000074", +"' c #000095", +") c #000058", +"! c #000000", +"~ c #000001", +"{ c #F0F0F0", +"] c #DEDEDE", +"^ c #DFDFDF", +"/ c #DFDFE0", +"( c #BFBFBF", +"_ c #C0C0C0", +": c #C0C0C1", +"< c #979797", +"[ c #989898", +"} c #E3E3E3", +"| c #DDDDDD", +"1 c #C8C8C8", +"2 c #656565", +"3 c #838384", +"4 c #878788", +"5 c #888888", +"6 c #AFAFAF", +"7 c #A3A3A3", +"8 c #F1F1F1", +"9 c #CECECE", +"0 c #ABABAB", +"a c #EEEEEE", +"b c #EDEDED", +"c c #E9E9E9", +"d c #D9D9D9", +"e c #838383", +"f c #C1C1C1", +"g c #B5B5B5", +"h c #757575", +"i c #6B6B6B", +"j c #777777", +" ..... ", +" ........+@ ", +" #$% &*=..- ", +" ;.> ", +" #., ", +" .' ", +" +.) ", +" !!!!!!!!~~!!", +" !{]^^^^^^//^^", +" !^((((((_::__", +" !^( c #000001", +", c #F0F0F0", +"' c #DEDEDE", +") c #DFDFDF", +"! c #DFDFE0", +"~ c #BFBFBF", +"{ c #C0C0C1", +"] c #C0C0C0", +"^ c #979797", +"/ c #989898", +"( c #E3E3E3", +"_ c #DDDDDD", +": c #C8C8C8", +"< c #656566", +"[ c #838384", +"} c #878787", +"| c #888888", +"1 c #AFAFAF", +"2 c #A3A3A4", +"3 c #F1F1F1", +"4 c #BFBFC0", +"5 c #CECECF", +"6 c #979798", +"7 c #ABABAC", +"8 c #EEEEEE", +"9 c #EDEDED", +"0 c #E9E9E9", +"a c #D9D9D9", +"b c #989899", +"c c #838383", +"d c #C1C1C1", +"e c #B5B5B6", +"f c #757576", +"g c #6B6B6C", +"h c #656565", +"i c #777777", +"j c #A7A7A7", +"k c #7B7B7B", +"l c #747474", +"m c #717171", +"n c #7D7D7D", +"o c #A3A3A3", +" .... ", +" .......+ ", +" ..@# #$.% ", +" ..& *.= ", +" .@ =.- ", +"..# ;;;;;;;>>>;;", +".. ;,')))))!!!))", +".. ;)~~~~~~{{{]]", +"..#;)~^;;;/{{{]]", +" .$;)~;(_:><[}|1", +" +.;)~;_]2>>>;;3", +" %>!4>526>7890a", +" >!{b>>> c #428200", +", c #EBE200", +"' c #F6ED00", +") c #007600", +"! c #006100", +"~ c #2B2900", +"{ c #427600", +"] c #EBE600", +"^ c #F8EF00", +"/ c #6A6500", +"( c #268200", +"_ c #EBEB00", +": c #428D00", +"< c #585400", +"[ c #F7ED00", +"} c #007800", +"| c #1E8600", +"1 c #003F00", +"2 c #006E00", +"3 c #003800", +"4 c #F0F0F0", +"5 c #DEDEDE", +"6 c #DFDFDF", +"7 c #BFBFBF", +"8 c #C0C0C0", +"9 c #979797", +"0 c #989898", +"a c #E3E3E3", +"b c #DDDDDD", +"c c #C8C8C8", +"d c #656565", +"e c #838383", +"f c #878787", +"g c #888888", +"h c #A3A3A3", +"i c #CECECE", +"j c #ABABAB", +"k c #EEEEEE", +"l c #EDEDED", +"m c #E9E9E9", +"n c #C1C1C1", +" ..... + ", +" @#$%$&* +=+ ", +" @-;;;;;>,+' ", +".#;;)!)+++~+++ ", +".$;) %{]+^/ ", +".%;! (_:+<[ ", +".$;) }|1+. ", +".#;;%2};;3.. ", +" @-;;...........", +" @#.45666666666", +" ..67777778888", +" .679...08888", +" .67.abc.defg", +" .67.b8h.....", +" .67.ih9.jklm", +" .680...dennn"}; +#endif diff --git a/bitmaps/Options_Pad.xpm b/bitmaps/Options_Pad.xpm new file mode 100644 index 0000000000..fa7499729d --- /dev/null +++ b/bitmaps/Options_Pad.xpm @@ -0,0 +1,57 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *options_pad_xpm[]; + +#else +char * options_pad_xpm[] = { +"16 16 33 1", +" c None", +". c #000000", +"+ c #000200", +"@ c #003B00", +"# c #006400", +"$ c #007700", +"% c #005F00", +"& c #007D00", +"* c #007600", +"= c #006100", +"- c #006E00", +"; c #007800", +"> c #F0F0F0", +", c #DEDEDE", +"' c #DFDFDF", +") c #BFBFBF", +"! c #C0C0C0", +"~ c #979797", +"{ c #989898", +"] c #E3E3E3", +"^ c #DDDDDD", +"/ c #C8C8C8", +"( c #656565", +"_ c #838383", +": c #878787", +"< c #888888", +"[ c #A3A3A3", +"} c #CECECE", +"| c #ABABAB", +"1 c #EEEEEE", +"2 c #EDEDED", +"3 c #E9E9E9", +"4 c #C1C1C1", +" ..... ", +" +@#$#@+ ", +" +%&&&&&%+ ", +".@&&*=*&&@. ", +".#&* $&#. ", +".$&= -&$. ", +".#&* ;&#. ", +".@&&$-;&&@. ", +" +%&&...........", +" +@.>,'''''''''", +" ..'))))))!!!!", +" .')~...{!!!!", +" .').]^/.(_:<", +" .').^![.....", +" .').}[~.|123", +" .'!{...(_444"}; +#endif diff --git a/bitmaps/Options_Rectangle.xpm b/bitmaps/Options_Rectangle.xpm new file mode 100644 index 0000000000..257ddf12be --- /dev/null +++ b/bitmaps/Options_Rectangle.xpm @@ -0,0 +1,68 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *options_rectangle_xpm[]; + +#else +char * options_rectangle_xpm[] = { +"16 16 44 1", +" c None", +". c #00009B", +"+ c #000000", +"@ c #000001", +"# c #F0F0F0", +"$ c #DEDEDE", +"% c #DFDFDF", +"& c #DFDFE0", +"* c #BFBFBF", +"= c #C0C0C1", +"- c #C0C0C0", +"; c #979797", +"> c #989898", +", c #E3E3E3", +"' c #DDDDDD", +") c #C8C8C8", +"! c #656566", +"~ c #838384", +"{ c #878787", +"] c #888888", +"^ c #AFAFAF", +"/ c #A3A3A3", +"( c #F1F1F1", +"_ c #BFBFC0", +": c #CECECF", +"< c #A3A3A4", +"[ c #979798", +"} c #ABABAC", +"| c #EEEEEF", +"1 c #EDEDED", +"2 c #E9E9E9", +"3 c #D9D9D9", +"4 c #989899", +"5 c #C1C1C1", +"6 c #B5B5B5", +"7 c #757575", +"8 c #6B6B6B", +"9 c #656565", +"0 c #777777", +"a c #A7A7A7", +"b c #7B7B7B", +"c c #747474", +"d c #717171", +"e c #7D7D7D", +"............. ", +"............. ", +".. .. ", +".. .. ", +".. .. ", +".. +++++++@@+++", +".. +#$%%%%%&&%%%", +".. +%******==---", +".. +%*;+++>==---", +".. +%*+,')+!~{]^", +".. +%*+'-/+@@++(", +"...@&_@:<[@}|123", +"...@&=4@@@!~5555", +" +%-67890]+++>", +" +%-abbcd+,')+", +" +%-e+++++'-/+"}; +#endif diff --git a/bitmaps/Options_Segment.xpm b/bitmaps/Options_Segment.xpm new file mode 100644 index 0000000000..01069604e2 --- /dev/null +++ b/bitmaps/Options_Segment.xpm @@ -0,0 +1,55 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *options_segment_xpm[]; + +#else +char * options_segment_xpm[] = { +"16 16 31 1", +" c None", +". c #007D00", +"+ c #000000", +"@ c #F0F0F0", +"# c #DEDEDE", +"$ c #DFDFDF", +"% c #BFBFBF", +"& c #C0C0C0", +"* c #979797", +"= c #989898", +"- c #E3E3E3", +"; c #DDDDDD", +"> c #C8C8C8", +", c #656565", +"' c #838383", +") c #878787", +"! c #888888", +"~ c #AFAFAF", +"{ c #A3A3A3", +"] c #F1F1F1", +"^ c #CECECE", +"/ c #ABABAB", +"( c #EEEEEE", +"_ c #EDEDED", +": c #E9E9E9", +"< c #D9D9D9", +"[ c #C1C1C1", +"} c #B5B5B5", +"| c #757575", +"1 c #6B6B6B", +"2 c #777777", +" ", +" ", +"................", +"................", +" ", +" ", +" ", +" ++++++++++++", +" +@#$$$$$$$$$$", +" +$%%%%%%&&&&&", +" +$%*+++=&&&&&", +" +$%+-;>+,')!~", +" +$%+;&{+++++]", +" +$%+^{*+/(_:<", +" +$&=+++,'[[[[", +" +$&}|1,2!+++="}; +#endif diff --git a/bitmaps/Options_Text.xpm b/bitmaps/Options_Text.xpm new file mode 100644 index 0000000000..fc10dc13c1 --- /dev/null +++ b/bitmaps/Options_Text.xpm @@ -0,0 +1,64 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *options_text_xpm[]; + +#else +char * options_text_xpm[] = { +"16 16 40 1", +" c None", +". c #00009B", +"+ c #000098", +"@ c #00005D", +"# c #000000", +"$ c #000001", +"% c #F0F0F0", +"& c #DEDEDE", +"* c #DFDFE0", +"= c #DFDFDF", +"- c #BFBFBF", +"; c #BFBFC0", +"> c #C0C0C0", +", c #979798", +"' c #989898", +") c #C1C1C1", +"! c #E3E3E4", +"~ c #DDDDDE", +"{ c #C8C8C9", +"] c #656565", +"^ c #838383", +"/ c #878787", +"( c #888888", +"_ c #AFAFAF", +": c #C0C0C1", +"< c #A3A3A4", +"[ c #F1F1F1", +"} c #CECECF", +"| c #ABABAC", +"1 c #EEEEEE", +"2 c #EDEDED", +"3 c #E9E9E9", +"4 c #D9D9D9", +"5 c #989899", +"6 c #656566", +"7 c #838384", +"8 c #B5B5B5", +"9 c #757575", +"0 c #6B6B6B", +"a c #777777", +".............. ", +".............. ", +".+ .... +. ", +".@ .... . ", +" .... ", +" .... ", +" .... ", +" ##$$$$#######", +" #%&****=======", +" #=-;;;;->>>>>>", +" #=-,$$$'>>>>>)", +" #=-$!~{#]^/(_)", +" #=;$~:<#####[>", +" #*;$}<,$|1234)", +" #*:5$$$67))))>", +" #=>890]a(###'>"}; +#endif diff --git a/bitmaps/Orient.xpm b/bitmaps/Orient.xpm new file mode 100644 index 0000000000..7796c8cc6a --- /dev/null +++ b/bitmaps/Orient.xpm @@ -0,0 +1,138 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *orient_xpm[]; + +#else +char * orient_xpm[] = { +"16 16 114 2", +" c None", +". c #000000", +"+ c #010101", +"@ c #656565", +"# c #B2B2B2", +"$ c #6E6E70", +"% c #6A6A70", +"& c #A1A1AD", +"* c #585860", +"= c #1A1A1A", +"- c #C19393", +"; c #F6DBDD", +"> c #F5F5FB", +", c #76767B", +"' c #72727A", +") c #DDDDF3", +"! c #D5D5F1", +"~ c #9A9AB2", +"{ c #141418", +"] c #BEBEBE", +"^ c #F3DBDD", +"/ c #CE0D0C", +"( c #E0959D", +"_ c #E4E4F6", +": c #DCDCF3", +"< c #D5D5F0", +"[ c #CDCDEE", +"} c #C5C5EB", +"| c #8E8EAE", +"1 c #676262", +"2 c #FAF3F5", +"3 c #F2F0F8", +"4 c #C42223", +"5 c #CD0100", +"6 c #D14D54", +"7 c #D3C7E1", +"8 c #CCCCEE", +"9 c #BDBDE8", +"0 c #B5B5E6", +"a c #45455A", +"b c #B1A4A6", +"c c #E18185", +"d c #D96166", +"e c #C8282B", +"f c #CD1416", +"g c #CCA4BE", +"h c #BCBCE8", +"i c #B4B4E5", +"j c #ADADE3", +"k c #74749D", +"l c #6C6C70", +"m c #767278", +"n c #DB8E99", +"o c #CD474E", +"p c #D87F81", +"q c #F5F3F6", +"r c #C4C4EA", +"s c #ACACE3", +"t c #51516F", +"u c #464663", +"v c #69696F", +"w c #70707A", +"x c #DADAF2", +"y c #D09AB0", +"z c #C81415", +"A c #E0ACAF", +"B c #FFFFFF", +"C c #DCDCEE", +"D c #C1C1E9", +"E c #4D4D6E", +"F c #424262", +"G c #9F9FAC", +"H c #D2D2EF", +"I c #CACAED", +"J c #B99BB0", +"K c #F7F5F6", +"L c #E2E2ED", +"M c #C0C0E9", +"N c #66669B", +"O c #565660", +"P c #C2C2EA", +"Q c #B2B2DD", +"R c #8484A3", +"S c #D4D4DD", +"T c #DBDBE6", +"U c #9696DB", +"V c #9292DA", +"W c #3B3B5A", +"X c #9797B1", +"Y c #C1C1EA", +"Z c #B9B9E7", +"` c #B2B2E5", +" . c #A7A7DE", +".. c #7B7BAA", +"+. c #A4A4BB", +"@. c #F8F8FA", +"#. c #8E8ED0", +"$. c #6262A0", +"%. c #000001", +"&. c #8B8BAD", +"*. c #B1B1E4", +"=. c #A9A9E2", +"-. c #50506F", +";. c #4C4C6D", +">. c #8080BF", +",. c #75759D", +"'. c #7777A0", +"). c #0D0D15", +"!. c #43435A", +"~. c #71719D", +"{. c #444462", +"]. c #414162", +"^. c #616197", +"/. c #313150", +" ", +" . . . . ", +" + @ # $ % & * + ", +" = - ; > , ' ) ! ~ { ", +" + ] ^ / ( _ : < [ } | + ", +" 1 2 3 4 5 6 7 8 } 9 0 a . ", +" . b c d e 5 5 f g h i j k . ", +" . l m n o 5 5 p q r s t u . ", +" . v w x y z A B B C D E F . ", +" . G x H I J K B B L ! M N . ", +" O H I P Q R S B T U V W . ", +" + X Y Z ` ...+.@.#.$.%. ", +" { &.*.=.-.;.>.,.'.).. ", +" + !.~.{.].^./.. . ", +" . . . . . . ", +" "}; +#endif diff --git a/bitmaps/Pad_Sketch.xpm b/bitmaps/Pad_Sketch.xpm new file mode 100644 index 0000000000..d1eef47792 --- /dev/null +++ b/bitmaps/Pad_Sketch.xpm @@ -0,0 +1,27 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *pad_sketch_xpm[]; + +#else +char * pad_sketch_xpm[] = { +"16 16 3 1", +" c None", +". c #007D00", +"+ c #007C00", +" ", +" .... ", +" ..++++.. ", +" .. .. ", +" .. .. ", +" . .. . ", +" .+ .... +. ", +" .+ .. .. +. ", +" .+ .. .. +. ", +" .+ .... +. ", +" . .. . ", +" .. .. ", +" .. .. ", +" ..++++.. ", +" .... ", +" "}; +#endif diff --git a/bitmaps/Read_SetUp.xpm b/bitmaps/Read_SetUp.xpm new file mode 100644 index 0000000000..e4437fadcc --- /dev/null +++ b/bitmaps/Read_SetUp.xpm @@ -0,0 +1,109 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *read_setup_xpm[]; + +#else +char * read_setup_xpm[] = { +"16 16 85 1", +" c None", +". c #000000", +"+ c #E1E1E1", +"@ c #C1C1C1", +"# c #999999", +"$ c #9A9A9A", +"% c #C2C2C2", +"& c #E5E5E5", +"* c #DFDFDF", +"= c #CACACA", +"- c #666666", +"; c #858585", +"> c #898989", +", c #8A8A8A", +"' c #B1B1B1", +") c #A5A5A5", +"! c #F3F3F3", +"~ c #D0D0D0", +"{ c #ADADAD", +"] c #F0F0F0", +"^ c #EFEFEF", +"/ c #EBEBEB", +"( c #DBDBDB", +"_ c #C3C3C3", +": c #E4E5DF", +"< c #D5D6CB", +"[ c #D6D7CA", +"} c #B7B7B7", +"| c #767676", +"1 c #6C6C6C", +"2 c #787878", +"3 c #8D907B", +"4 c #92957E", +"5 c #90937D", +"6 c #A9A9A9", +"7 c #7C7C7C", +"8 c #757575", +"9 c #505050", +"0 c #8A8C7D", +"a c #8E917B", +"b c #91947F", +"c c #7E7E7E", +"d c #878A75", +"e c #666858", +"f c #4B4D3F", +"g c #4D4F40", +"h c #404135", +"i c #424337", +"j c #434437", +"k c #404236", +"l c #3C3D32", +"m c #48493C", +"n c #1A1A16", +"o c #939393", +"p c #848672", +"q c #25261F", +"r c #F1F2E9", +"s c #DDE0C7", +"t c #D6DABB", +"u c #CDD2AC", +"v c #C7CCA7", +"w c #989C80", +"x c #5F6152", +"y c #888980", +"z c #A7AB8C", +"A c #878A70", +"B c #6D6D6D", +"C c #676767", +"D c #777777", +"E c #EFF0E5", +"F c #9EA284", +"G c #606060", +"H c #888888", +"I c #818181", +"J c #7B7B7B", +"K c #96968D", +"L c #E3E5D1", +"M c #83866D", +"N c #EDEFE2", +"O c #A2A688", +"P c #E7E9DA", +"Q c #D1D3BD", +"R c #BBBF9D", +"S c #989B80", +"T c #6E715C", +" .+@#...$%%%%%", +" .+@.&*=.-;>,'", +" .+@.*%).....!", +" .+@.~)#.{]^/(", +"....+%$...-;____", +":<[.+%}|1-2,...$", +"345.+%67789.&*=.", +"0ab.+%c.....*%).", +"defghiijklmno)#.", +"pqrstuuuuuvw...-", +"xysuuuuuuuzA.BCD", +"qEtuuuuuuuF.GHIJ", +"KLuuuuuuuuM.....", +"NuuuuuuuuO.. ", +"PQRRRRRRST. ", +"........... "}; +#endif diff --git a/bitmaps/Repaint.xpm b/bitmaps/Repaint.xpm new file mode 100644 index 0000000000..38e0fcba6e --- /dev/null +++ b/bitmaps/Repaint.xpm @@ -0,0 +1,102 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * repaint_xpm[]; + +#else +char * repaint_xpm[] = { +"16 16 78 1", +" c None", +". c #000000", +"+ c #817858", +"@ c #D6D0BD", +"# c #413C27", +"$ c #E7D8A6", +"% c #F2EDD9", +"& c #877B52", +"* c #E9DBAE", +"= c #F1EBD6", +"- c #918458", +"; c #DACD9F", +"> c #F4EED9", +", c #6B6040", +"' c #EDE4C6", +") c #0C0B07", +"! c #A29771", +"~ c #9A8F6A", +"{ c #ADA281", +"] c #D5CCAF", +"^ c #7F7862", +"/ c #A39B7B", +"( c #7B6F4A", +"_ c #CCBC85", +": c #E2CF8B", +"< c #BCAC75", +"[ c #CEBD82", +"} c #C1B178", +"| c #5B5438", +"1 c #A39878", +"2 c #918C74", +"3 c #8B8468", +"4 c #8B8365", +"5 c #91896C", +"6 c #90886A", +"7 c #6A634C", +"8 c #D1C7A8", +"9 c #E8E7E3", +"0 c #D3D2CE", +"a c #B9B8B5", +"b c #948E78", +"c c #51504F", +"d c #161616", +"e c #101010", +"f c #121211", +"g c #0E0D0B", +"h c #555555", +"i c #050505", +"j c #040404", +"k c #6B372D", +"l c #6D392E", +"m c #974E3F", +"n c #44231C", +"o c #2F2F2F", +"p c #272727", +"q c #9D5546", +"r c #6C392E", +"s c #9C5344", +"t c #964E3F", +"u c #6C382D", +"v c #542B22", +"w c #9F5647", +"x c #A75E4F", +"y c #AD5C4B", +"z c #A55C4D", +"A c #2F1813", +"B c #B35D4B", +"C c #7E4134", +"D c #8D493B", +"E c #582D24", +"F c #6C372D", +"G c #613228", +"H c #64332A", +"I c #623228", +"J c #65342A", +"K c #502921", +"L c #4C271F", +"M c #3C1E18", +" .. ", +" .+@#. ", +" .$%&. ", +" .*=-. ", +" .;>,. ", +" ...').. ", +" .!~{]^/(. ", +" ._::::<[}|. ", +" .123444567. ", +" .890a9a9ab. ", +" .cdedddfdg. ", +" .hij.k.jlm. ", +" nholpqrstu. ", +" vwxyxzxzxA ", +"BCDEFGHIJIKLM ", +" "}; +#endif diff --git a/bitmaps/Rotate+.xpm b/bitmaps/Rotate+.xpm new file mode 100644 index 0000000000..31a02be702 --- /dev/null +++ b/bitmaps/Rotate+.xpm @@ -0,0 +1,117 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *rotate_pos_xpm[]; + +#else +char * rotate_pos_xpm[] = { +"16 16 93 2", +" c None", +". c #202020", +"+ c #090909", +"@ c #0C0C0C", +"# c #CACACB", +"$ c #3E3E3E", +"% c #9B9B9B", +"& c #010101", +"* c #A8A8A9", +"= c #FEFEFF", +"- c #727275", +"; c #646469", +"> c #505057", +", c #141416", +"' c #4A4A4A", +") c #F8F8FF", +"! c #F1F1FF", +"~ c #EBEBFF", +"{ c #E0E0FA", +"] c #A3A3BC", +"^ c #484855", +"/ c #171717", +"( c #96969A", +"_ c #C3C3CE", +": c #E6E6FA", +"< c #E4E4FF", +"[ c #DDDDFF", +"} c #D7D7FF", +"| c #707089", +"1 c #3B3B3D", +"2 c #000000", +"3 c #272727", +"4 c #444444", +"5 c #727272", +"6 c #4B4B4C", +"7 c #46464C", +"8 c #B3B3CE", +"9 c #D0D0FF", +"0 c #49495C", +"a c #5B5B5B", +"b c #5A5A76", +"c c #656580", +"d c #3B3B48", +"e c #5C5C5C", +"f c #313131", +"g c #4B4B4B", +"h c #494949", +"i c #8C8C8C", +"j c #212122", +"k c #BCBCDF", +"l c #8686AA", +"m c #474747", +"n c #8888B2", +"o c #C9C9FF", +"p c #B1B1D9", +"q c #262627", +"r c #595959", +"s c #2F2F2F", +"t c #40404C", +"u c #686880", +"v c #5A5A72", +"w c #262626", +"x c #4C4C64", +"y c #A9A9C9", +"z c #404048", +"A c #0D0D0F", +"B c #C0C0C5", +"C c #323232", +"D c #222222", +"E c #4D4D4D", +"F c #535353", +"G c #28282A", +"H c #737392", +"I c #DFDFF9", +"J c #BCBCCC", +"K c #93939C", +"L c #A1A1A2", +"M c #383838", +"N c #353535", +"O c #4F4F5F", +"P c #A3A3C1", +"Q c #DADAFC", +"R c #424242", +"S c #6C6C6C", +"T c #3D3D3F", +"U c #595961", +"V c #62626A", +"W c #73737A", +"X c #404040", +"Y c #040404", +"Z c #303031", +"` c #989898", +" . c #8F8F8F", +" ", +" . + ", +" @ # $ % ", +" & * = - ; > , ", +" ' = = ) ! ~ { ] ^ ", +" / * = ( _ : < [ } | 1 ", +" 2 2 2 3 # 4 5 6 7 8 } 9 0 a ", +"2 b c d e f g h i j k 9 l m ", +"2 n o p q r s q t u v w ", +" x o 9 y z A w B C D E E F ", +" G H 9 } [ I J K ) L M % % % ", +" N O P Q < ~ ! ) = R S ", +" r T U V W ) L ' % ", +" % % X B $ % % ", +" Y Z ` % ", +" .% "}; +#endif diff --git a/bitmaps/Rotate-.xpm b/bitmaps/Rotate-.xpm new file mode 100644 index 0000000000..608fc96e6a --- /dev/null +++ b/bitmaps/Rotate-.xpm @@ -0,0 +1,120 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *rotate_neg_xpm[]; + +#else +char * rotate_neg_xpm[] = { +"16 16 96 2", +" c None", +". c #000000", +"+ c #2A2A2B", +"@ c #C5C5CB", +"# c #313131", +"$ c #141416", +"% c #4D4D57", +"& c #5F5F67", +"* c #6F6F75", +"= c #F8F8FF", +"- c #A8A8A9", +"; c #343434", +"> c #444454", +", c #9F9FBC", +"' c #D9D9FA", +") c #E4E4FF", +"! c #EBEBFF", +"~ c #F1F1FF", +"{ c #FEFEFF", +"] c #4A4A4A", +"^ c #646464", +"/ c #6C6C89", +"( c #D0D0FF", +"_ c #D7D7FF", +": c #DDDDFF", +"< c #E0E0FA", +"[ c #BEBECE", +"} c #92929A", +"| c #3F3F3F", +"1 c #9B9B9B", +"2 c #46465C", +"3 c #C9C9FF", +"4 c #AEAECE", +"5 c #44444C", +"6 c #4B4B4C", +"7 c #727272", +"8 c #444444", +"9 c #363636", +"0 c #949494", +"a c #3A3A3A", +"b c #8282AA", +"c c #B6B6DF", +"d c #252526", +"e c #939393", +"f c #8F8F8F", +"g c #494949", +"h c #202020", +"i c #2C2C2D", +"j c #686868", +"k c #3D3D48", +"l c #686880", +"m c #5D5D76", +"n c #575772", +"o c #656580", +"p c #3E3E4C", +"q c #6E6E6E", +"r c #959595", +"s c #1E1E1E", +"t c #050505", +"u c #828282", +"v c #050507", +"w c #B7B7D9", +"x c #8C8CB2", +"y c #272727", +"z c #4D4D4D", +"A c #929292", +"B c #1F1F1F", +"C c #C4C4C5", +"D c #292929", +"E c #2C2C2C", +"F c #3A3A41", +"G c #AEAEC9", +"H c #4F4F64", +"I c #6F6F6F", +"J c #2F2F2F", +"K c #A1A1A2", +"L c #98989C", +"M c #C1C1CC", +"N c #E5E5F9", +"O c #777792", +"P c #545455", +"Q c #424242", +"R c #E1E1FC", +"S c #A7A7C1", +"T c #51515F", +"U c #525252", +"V c #101010", +"W c #77777A", +"X c #65656A", +"Y c #5B5B61", +"Z c #3D3D3F", +"` c #5D5D5D", +" . c #3E3E3E", +".. c #989898", +"+. c #3D3D3D", +"@. c #404040", +" ", +" . + ", +" . @ # ", +" $ % & * = - ; ", +" > , ' ) ! ~ = { ] ^ ", +" / ( _ : < [ } = - | 1 ", +" 2 3 ( 4 5 6 7 8 @ 9 0 a . . ", +". b 3 c d e f g h i 0 j k l m . ", +". n o p q r s t u e v w ( x y ", +" | z z A B C D E F G _ ( H I ", +" 1 1 J K { L M N ) : _ O P 1 ", +" Q { { = ~ ! R S T U 1 1 ", +" V K { W X Y Z ` r 1 1 ", +" 1 .C 8 1 1 1 1 1 1 ", +" ..+.@.1 1 1 1 ", +" e ` "}; +#endif diff --git a/bitmaps/Rotate_Field.xpm b/bitmaps/Rotate_Field.xpm new file mode 100644 index 0000000000..533daeabe9 --- /dev/null +++ b/bitmaps/Rotate_Field.xpm @@ -0,0 +1,100 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *rotate_field_xpm[]; + +#else +char * rotate_field_xpm[] = { +"16 16 76 1", +" c None", +". c #D2D2D2", +"+ c #9D9D9D", +"@ c #DEDEDE", +"# c #E0E0E0", +"$ c #5C5C5C", +"% c #000000", +"& c #EDEDED", +"* c #939393", +"= c #FDFDFD", +"- c #E4E4E4", +"; c #F1F1F1", +"> c #CFCFCF", +", c #C7C7C7", +"' c #E7E7E7", +") c #F4F4F4", +"! c #8F8F8F", +"~ c #E9E9E9", +"{ c #B1B1B1", +"] c #373737", +"^ c #67676A", +"/ c #3B3B3B", +"( c #A3A3A3", +"_ c #D1D1D1", +": c #FAFAFA", +"< c #636363", +"[ c #F7F7F8", +"} c #F8F8FF", +"| c #EBEBF9", +"1 c #E0E0F3", +"2 c #BFBFD6", +"3 c #8B8BA0", +"4 c #4F4F57", +"5 c #B6B6B6", +"6 c #F0F0F0", +"7 c #9F9F9F", +"8 c #F1F1FF", +"9 c #EBEBFF", +"0 c #E4E4FF", +"a c #DDDDFF", +"b c #CECEF4", +"c c #393945", +"d c #777777", +"e c #606060", +"f c #3A3A3A", +"g c #69696C", +"h c #353536", +"i c #3B3B3E", +"j c #3F3F45", +"k c #777789", +"l c #D4D4FC", +"m c #8888A7", +"n c #2E2E2E", +"o c #9494B0", +"p c #B8B8E2", +"q c #A1A1CC", +"r c #A0A0C4", +"s c #757594", +"t c #CFCFFE", +"u c #7D7D94", +"v c #383842", +"w c #2F2F34", +"x c #1D1D1F", +"y c #5C5C61", +"z c #434345", +"A c #2B2B37", +"B c #C2C2EE", +"C c #D7D7FF", +"D c #F5F5FC", +"E c #6F6F6F", +"F c #22222A", +"G c #83839B", +"H c #B5B5D1", +"I c #D8D8F2", +"J c #E5E5F9", +"K c #59595E", +".++++++++++++++.", +"+.@@@@@@@@@@@@@+", +"+#$%%$&%%%*&===+", +"+-%;;%;%>,%;===+", +"+'%))%)%%%!)===+", +"+~%%%%{]^/%(_==+", +"+&%::%<[}|12345+", +"+6===7<[}890abcd", +".+++++efghijklmn", +" %%% % %op%", +" %qr% % %%%", +" %stuvwxyz ", +" ABCa098DE ", +" FGHIJ8DE% ", +" %%%Kz% ", +" %% "}; +#endif diff --git a/bitmaps/Save_CmpStuff.xpm b/bitmaps/Save_CmpStuff.xpm new file mode 100644 index 0000000000..1a3805bad9 --- /dev/null +++ b/bitmaps/Save_CmpStuff.xpm @@ -0,0 +1,123 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *save_cmpstuff_xpm[]; + +#else +char * save_cmpstuff_xpm[] = { +"16 16 99 2", +" c None", +". c #160A00", +"+ c #FF7800", +"@ c #000000", +"# c #231000", +"$ c #E1DFDE", +"% c #44260C", +"& c #E86D00", +"* c #FFFFFF", +"= c #C35B00", +"- c #FAF6F3", +"; c #A38F7C", +"> c #C7B4A5", +", c #FDBD85", +"' c #FFBF87", +") c #FFF3EC", +"! c #FEE6D6", +"~ c #D8BDA8", +"{ c #C7874F", +"] c #F9B880", +"^ c #FFF5EF", +"/ c #FFE8D8", +"( c #FFDBC2", +"_ c #B9957C", +": c #010101", +"< c #FFEADC", +"[ c #FFDDC5", +"} c #FFD0AF", +"| c #F6F7F9", +"1 c #CADCEA", +"2 c #C78980", +"3 c #D08E83", +"4 c #CF8D82", +"5 c #CF8E82", +"6 c #FFDFC8", +"7 c #FFD1B2", +"8 c #FFC49C", +"9 c #DAE6EF", +"0 c #8CA8BC", +"a c #B6867D", +"b c #C67568", +"c c #C67467", +"d c #C57366", +"e c #C57365", +"f c #FFD3B5", +"g c #FFC69F", +"h c #FFB988", +"i c #010100", +"j c #CEDFEB", +"k c #D6D6D5", +"l c #FDFDFD", +"m c #FCFCFC", +"n c #FFC8A2", +"o c #FFBB8C", +"p c #FFAE75", +"q c #D6D6D6", +"r c #D5D5D5", +"s c #FFBD8F", +"t c #FFB079", +"u c #FFA262", +"v c #8CA8BD", +"w c #FBFBFB", +"x c #F3F3F3", +"y c #E9E9E9", +"z c #FFB27C", +"A c #FFA465", +"B c #FE9A55", +"C c #D6D5D5", +"D c #D3D2D2", +"E c #C4C3C3", +"F c #C4C4C4", +"G c #C3C3C3", +"H c #FFA669", +"I c #FAA162", +"J c #A37E60", +"K c #CEDFEC", +"L c #EDEDED", +"M c #F1F0F0", +"N c #EAE9E9", +"O c #EAEAEA", +"P c #E1A074", +"Q c #442102", +"R c #CEDEEB", +"S c #ADBDCB", +"T c #C8D4DD", +"U c #C5CDD8", +"V c #BEC9D4", +"W c #BECAD5", +"X c #BDC9D4", +"Y c #8CA7BC", +"Z c #87A4BA", +"` c #7E98AC", +" . c #8098AC", +".. c #7F98AC", +"+. c #7D97AB", +"@. c #8BA6BB", +"#. c #A6AFBB", +"$. c #CDCCCC", +"%. c #9A9B9B", +" . + + + ", +" @ # + + + ", +" @ $ % & * = + * + @ @ ", +" @ * - ; > , ' ' * * + + + * @ ", +" @ * ) ! ~ { ] ' * * + + + * @ ", +"@ @ ^ / ( _ : : : : : : : : : @ ", +" @ < [ } : | 1 2 3 3 3 3 4 4 5 ", +" @ 6 7 8 : 9 0 a b c c c d e d ", +" @ f g h i j 0 k l l l l m m m ", +" @ n o p i j 0 q q q q q r r r ", +"@ @ s t u i j v q l l l l w x y ", +" @ z A B i j v q q q C D E F G ", +" @ H I J : K v L l l M N N O y ", +" @ P Q @ R v S T U V W V X X ", +" @ # @ R Y Y Z ` . . ...+.", +" . @ R Y @.#.G E $.N r %."}; +#endif diff --git a/bitmaps/Save_Library.xpm b/bitmaps/Save_Library.xpm new file mode 100644 index 0000000000..68ec1a9e09 --- /dev/null +++ b/bitmaps/Save_Library.xpm @@ -0,0 +1,123 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *save_library_xpm[]; + +#else +char * save_library_xpm[] = { +"16 16 99 2", +" c None", +". c #070809", +"+ c #323538", +"@ c #1F1F20", +"# c #0B0D0E", +"$ c #E5E7E8", +"% c #F6F6F6", +"& c #838587", +"* c #050506", +"= c #0B0D0F", +"- c #F7F7F7", +"; c #D8D8D8", +"> c #E0E1E2", +", c #1F2021", +"' c #050709", +") c #E4E7E8", +"! c #D8D9D9", +"~ c #D2D2D2", +"{ c #E2E2E2", +"] c #BFC1C3", +"^ c #0F0F0F", +"/ c #000000", +"( c #363737", +"_ c #D18F84", +": c #D19084", +"< c #D39186", +"[ c #BFD5E8", +"} c #565656", +"| c #353535", +"1 c #363636", +"2 c #0B0B0B", +"3 c #C77467", +"4 c #C77466", +"5 c #C87668", +"6 c #CD867A", +"7 c #8DA9BE", +"8 c #54697C", +"9 c #FCFDFD", +"0 c #FCFCFC", +"a c #FBFBFC", +"b c #FAFBFC", +"c c #EAEAEA", +"d c #242425", +"e c #FEFEFE", +"f c #F9F9F9", +"g c #84A0B5", +"h c #4F6475", +"i c #E2E3E4", +"j c #F8F9FA", +"k c #F7F8F9", +"l c #E0E0E2", +"m c #AFB1B2", +"n c #D7D7D7", +"o c #D6D6D6", +"p c #F1F1F1", +"q c #819AAE", +"r c #496072", +"s c #F9FBFC", +"t c #CBCCCE", +"u c #868C92", +"v c #F4F4F4", +"w c #EBEBEB", +"x c #DFE0E0", +"y c #B4B7BB", +"z c #181B1E", +"A c #D4D4D4", +"B c #C5C5C5", +"C c #FAFBFB", +"D c #FAFAFB", +"E c #CCCED1", +"F c #747C85", +"G c #F2F2F2", +"H c #EEEEEE", +"I c #FBFCFC", +"J c #F0F1F1", +"K c #A9AEB4", +"L c #16181B", +"M c #BFCBD6", +"N c #A1B6C4", +"O c #F4F5F5", +"P c #D2D2D3", +"Q c #7A8188", +"R c #7E99AD", +"S c #7D97AC", +"T c #A0A6AD", +"U c #92999F", +"V c #0D0F11", +"W c #CECECE", +"X c #9C9D9D", +"Y c #2F4656", +"Z c #80868C", +"` c #191E22", +" . c #1E2328", +".. c #183042", +"+. c #33495A", +"@. c #B9B9B9", +"#. c #132D3C", +"$. c #586D80", +"%. c #97A5B0", +" . + @ ", +" # $ % & * ", +" = $ - ; > , ", +" ' ) - ! ~ { ] ^ ", +"/ / / / / / / / / ( ", +"_ _ _ _ : _ < [ [ / } | | | 1 2 ", +"3 3 3 4 3 5 6 7 8 / 9 0 a b c d ", +"e e e e e e f g h / i j k l m / ", +"n n n n n o p q r / s j k t u / ", +"e e 0 v w w p q r / b j x y z ", +"n A B B B B p q r / C D E F / ", +"G w w w w w H q r / I J K L ", +"M M M M M M N q r / O P Q / ", +"q q q q R S q q r / T U V ", +"B W w n X Y Z q r / ` . ", +"..+.o B @.#.$.%.r / "}; +#endif diff --git a/bitmaps/Save_NetList.xpm b/bitmaps/Save_NetList.xpm new file mode 100644 index 0000000000..6ba517e8a4 --- /dev/null +++ b/bitmaps/Save_NetList.xpm @@ -0,0 +1,115 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *save_netlist_xpm[]; + +#else +char * save_netlist_xpm[] = { +"16 16 91 1", +" c None", +". c #000000", +"+ c #F0F0F0", +"@ c #FFFFFF", +"# c #0F0F0F", +"$ c #EFEFEF", +"% c #101010", +"& c #B3D7F0", +"* c #0B0D0F", +"= c #B3D6EF", +"- c #51616D", +"; c #39454D", +"> c #BFE5FF", +", c #0B0E10", +"' c #FAF9F9", +") c #746355", +"! c #E3C8B4", +"~ c #FFCAA5", +"{ c #FFBD8E", +"] c #F1B58B", +"^ c #4C392A", +"/ c #F3F1F0", +"( c #A7C8E0", +"_ c #C3DCEC", +": c #B9C9D3", +"< c #A38266", +"[ c #FDC49C", +"} c #FEB481", +"| c #AE8868", +"1 c #777471", +"2 c #C4DCEB", +"3 c #BFE5FE", +"4 c #FFEBD9", +"5 c #FFEAD7", +"6 c #E9CAAF", +"7 c #E3BB9E", +"8 c #EBBB99", +"9 c #E4C2A5", +"0 c #A38E7B", +"a c #FFFDFC", +"b c #8EA0AA", +"c c #010101", +"d c #000101", +"e c #FFC38E", +"f c #F6F7F9", +"g c #CADCEA", +"h c #C78980", +"i c #D08E83", +"j c #CF8E82", +"k c #DBB48E", +"l c #DAE6F0", +"m c #8CA8BD", +"n c #B6867E", +"o c #C67568", +"p c #C67467", +"q c #C57366", +"r c #C67466", +"s c #CEDFEC", +"t c #D6D6D6", +"u c #FDFDFD", +"v c #FCFCFC", +"w c #FB7E0F", +"x c #010100", +"y c #CEDEEB", +"z c #D6D6D5", +"A c #D6D5D5", +"B c #D5D5D5", +"C c #FF800F", +"D c #FDFDFC", +"E c #FDFCFC", +"F c #FBFBFB", +"G c #F3F3F3", +"H c #E9E9E9", +"I c #D5D6D6", +"J c #D3D3D3", +"K c #C3C3C3", +"L c #C4C4C4", +"M c #EDEDED", +"N c #F1F1F1", +"O c #EAEAEA", +"P c #ADBECC", +"Q c #C9D5DE", +"R c #C6CED9", +"S c #BECAD5", +"T c #BDC9D4", +"U c #CDDEEB", +"V c #8BA7BC", +"W c #87A4BA", +"X c #7E98AC", +"Y c #7F98AC", +"Z c #7D97AB", +" ...............", +".+@@@@#$@#$@@@@%", +".&*=-......;>*=,", +".+@@')!~{]^/@@@%", +".&.(_:<[}|123.(,", +".+@@45678905a@@%", +".&*=_bccccdcc.c.", +".+@@ecfghiiiiiij", +".&.(kclmnopppqrq", +".+@@@csmtuuuuuuv", +".&*=wxymtzzAtBtB", +".+@@CxymtDDEuFGH", +".&.(>csmttItJKLK", +".+@@@csmMuuNOOOH", +".&*=>csmPQRSSTST", +" .....UVVWXYYYYZ"}; +#endif diff --git a/bitmaps/Save_Project.xpm b/bitmaps/Save_Project.xpm new file mode 100644 index 0000000000..6c63ea7b76 --- /dev/null +++ b/bitmaps/Save_Project.xpm @@ -0,0 +1,87 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *save_project_xpm[]; + +#else +char * save_project_xpm[] = { +"16 16 63 1", +" c None", +". c #000000", +"+ c #020202", +"@ c #F8F8F8", +"# c #ECECEC", +"$ c #EBEBEB", +"% c #6B6B6B", +"& c #2D2D2D", +"* c #181818", +"= c #C5C5C5", +"- c #434343", +"; c #5E5E5E", +"> c #F0F0F0", +", c #707070", +"' c #3D3D3D", +") c #C3C3C3", +"! c #0E0E0E", +"~ c #9C9C9C", +"{ c #4B4B4B", +"] c #616161", +"^ c #131313", +"/ c #D18F84", +"( c #D19084", +"_ c #D39186", +": c #BFD5E8", +"< c #C6C6C6", +"[ c #1B1B1B", +"} c #C77467", +"| c #C77466", +"1 c #C87668", +"2 c #CD867A", +"3 c #8DA9BE", +"4 c #54697C", +"5 c #FEFEFE", +"6 c #F9F9F9", +"7 c #84A0B5", +"8 c #4F6475", +"9 c #D7D7D7", +"0 c #D6D6D6", +"a c #F1F1F1", +"b c #819AAE", +"c c #496072", +"d c #FCFCFC", +"e c #F4F4F4", +"f c #090909", +"g c #D4D4D4", +"h c #F2F2F2", +"i c #EEEEEE", +"j c #121212", +"k c #BFCBD6", +"l c #A1B6C4", +"m c #7E99AD", +"n c #7D97AC", +"o c #CECECE", +"p c #9C9D9D", +"q c #2F4656", +"r c #80868C", +"s c #183042", +"t c #33495A", +"u c #B9B9B9", +"v c #132D3C", +"w c #586D80", +"x c #97A5B0", +" ......+ ", +" .@#$$$%& ", +" ......*=$-;.", +" .>#$$$,')$=!", +".........~{]^$=!", +"////(/_::.$<[$=!", +"}}}|}1234.$<[$=!", +"555555678.$<[$=!", +"999990abc.$<[$=!", +"55de$$abc.$<[))f", +"9g====abc.$<[.. ", +"h$$$$$ibc.))j ", +"kkkkkklbc.... ", +"bbbbmnbbc. ", +"=o$9pqrbc. ", +"st0=uvwxc. "}; +#endif diff --git a/bitmaps/Save_SetUp.xpm b/bitmaps/Save_SetUp.xpm new file mode 100644 index 0000000000..e16648faa7 --- /dev/null +++ b/bitmaps/Save_SetUp.xpm @@ -0,0 +1,98 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *save_setup_xpm[]; + +#else +char * save_setup_xpm[] = { +"16 16 74 1", +" c None", +". c #000000", +"+ c #E1E1E1", +"@ c #C1C1C1", +"# c #999999", +"$ c #9A9A9A", +"% c #C2C2C2", +"& c #E5E5E5", +"* c #DFDFDF", +"= c #CACACA", +"- c #666666", +"; c #858585", +"> c #898989", +", c #8A8A8A", +"' c #B1B1B1", +") c #A5A5A5", +"! c #F3F3F3", +"~ c #D0D0D0", +"{ c #ADADAD", +"] c #F0F0F0", +"^ c #EFEFEF", +"/ c #EBEBEB", +"( c #DBDBDB", +"_ c #C3C3C3", +": c #D18F84", +"< c #D19084", +"[ c #D39186", +"} c #BFD5E8", +"| c #787878", +"1 c #C77467", +"2 c #C77466", +"3 c #C87668", +"4 c #CD867A", +"5 c #8DA9BE", +"6 c #54697C", +"7 c #727272", +"8 c #FEFEFE", +"9 c #F9F9F9", +"0 c #84A0B5", +"a c #4F6475", +"b c #D7D7D7", +"c c #D6D6D6", +"d c #F1F1F1", +"e c #819AAE", +"f c #496072", +"g c #FCFCFC", +"h c #F4F4F4", +"i c #9C9C9C", +"j c #D4D4D4", +"k c #C5C5C5", +"l c #C4C4C4", +"m c #B9B9B9", +"n c #777777", +"o c #6D6D6D", +"p c #676767", +"q c #F2F2F2", +"r c #EEEEEE", +"s c #979797", +"t c #888888", +"u c #818181", +"v c #7B7B7B", +"w c #BFCBD6", +"x c #A1B6C4", +"y c #7E99AD", +"z c #7D97AC", +"A c #CECECE", +"B c #9C9D9D", +"C c #2F4656", +"D c #80868C", +"E c #183042", +"F c #33495A", +"G c #132D3C", +"H c #586D80", +"I c #97A5B0", +" .+@#...$%%%%%", +" .+@.&*=.-;>,'", +" .+@.*%).....!", +" .+@.~)#.{]^/(", +"..........-;____", +"::::<:[}}.|,...$", +"111213456.7.&*=.", +"88888890a...*%).", +"bbbbbcdef.^.~)#.", +"88gh//def._i...-", +"bjkkkkdef.lmnopn", +"q/////ref.ssttuv", +"wwwwwwxef.......", +"eeeeyzeef. ", +"kA/bBCDef. ", +"EFckmGHIf. "}; +#endif diff --git a/bitmaps/Text_Sketch.xpm b/bitmaps/Text_Sketch.xpm new file mode 100644 index 0000000000..c4b60017f0 --- /dev/null +++ b/bitmaps/Text_Sketch.xpm @@ -0,0 +1,26 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *text_sketch_xpm[]; + +#else +char * text_sketch_xpm[] = { +"16 16 2 1", +" c None", +". c #00009B", +" .............. ", +" . . ", +" . .... .... . ", +" .. . . .. ", +" . . . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" ........ "}; +#endif diff --git a/bitmaps/Zoom_1.xpm b/bitmaps/Zoom_1.xpm new file mode 100644 index 0000000000..1139ac455c --- /dev/null +++ b/bitmaps/Zoom_1.xpm @@ -0,0 +1,56 @@ +/* XPM */ +static char * zoom_1_xpm[] = { +"16 16 36 1", +" c None", +". c #000000", +"+ c #262626", +"@ c #C5C5C5", +"# c #EEEEEE", +"$ c #EDEDED", +"% c #ABABAB", +"& c #464646", +"* c #878787", +"= c #F1F1F1", +"- c #FEFEFE", +"; c #FDFDFD", +"> c #FCFCFC", +", c #EAEAEA", +"' c #707070", +") c #FBFBFB", +"! c #E8E8E8", +"~ c #B0B0B0", +"{ c #434343", +"] c #FAFAFA", +"^ c #A4A4A4", +"/ c #E5E5E5", +"( c #E4E4E4", +"_ c #F9F9F9", +": c #BABABA", +"< c #E7E7E7", +"[ c #858585", +"} c #E3E3E3", +"| c #6D6D6D", +"1 c #A1A1A1", +"2 c #202020", +"3 c #686868", +"4 c #343434", +"5 c #797979", +"6 c #3A3A3A", +"7 c #1F1F1F", +" .... ", +" .+@#$%&. ", +" .*=--;>,'. ", +" &=--..;)!& ", +".~--{..;>]^. ", +".#---..;)]/. ", +".$;--..>)](. ", +".%>;;..)]_:. ", +" &,)>..]_<& ", +" .[!]]]_}|. ", +" .&^/(1&.... ", +" .... 22.. ", +" .34.. ", +" .56..", +" .37.", +" .. "}; +#endif diff --git a/bitmaps/Zoom_Center.xpm b/bitmaps/Zoom_Center.xpm new file mode 100644 index 0000000000..b177d095aa --- /dev/null +++ b/bitmaps/Zoom_Center.xpm @@ -0,0 +1,30 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char * zoom_center_xpm[]; + +#else +char * zoom_center_xpm[] = { +"16 16 4 1", +" c None", +". c Black", +"c c Red", +"X c Gray100", +" .... ", +" ..XXXX.. ", +" .XXXXXXXX. ", +" .XXccccXX. ", +".XXccccccXX. ", +".XXccccccXX. ", +".XXccccccXX. ", +".XXccccccXX. ", +" .XXccccXX. ", +" .XXXXXXXX. ", +" ..XXXX... ", +" .... ... ", +" ... ", +" ... ", +" ... ", +" .. " +}; +#endif + diff --git a/bitmaps/Zoom_In.xpm b/bitmaps/Zoom_In.xpm new file mode 100644 index 0000000000..40bacabe15 --- /dev/null +++ b/bitmaps/Zoom_In.xpm @@ -0,0 +1,66 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * zoom_in_xpm[]; + +#else +char * zoom_in_xpm[] = { +"16 16 42 1", +" c None", +". c #000000", +"+ c #262626", +"@ c #C5C5C5", +"# c #EEEEEE", +"$ c #EDEDED", +"% c #ABABAB", +"& c #464646", +"* c #878787", +"= c #F1F1F1", +"- c #FEFEFE", +"; c #FDFDFD", +"> c #FCFCFC", +", c #EAEAEA", +"' c #707070", +") c #252525", +"! c #282828", +"~ c #FBFBFB", +"{ c #E8E8E8", +"] c #B0B0B0", +"^ c #FFFFFF", +"/ c #050505", +"( c #040404", +"_ c #FAFAFA", +": c #A4A4A4", +"< c #090909", +"[ c #242424", +"} c #E5E5E5", +"| c #E4E4E4", +"1 c #F9F9F9", +"2 c #BABABA", +"3 c #E7E7E7", +"4 c #858585", +"5 c #E3E3E3", +"6 c #6D6D6D", +"7 c #A1A1A1", +"8 c #202020", +"9 c #686868", +"0 c #343434", +"a c #797979", +"b c #3A3A3A", +"c c #1F1F1F", +" .... ", +" .+@#$%&. ", +" .*=--;>,'. ", +" &=--)!;~{& ", +".]--^/(;>_:. ", +".#-//<(([_}. ", +".$;[(../[_|. ", +".%>;;((~_12. ", +" &,~><)_13& ", +" .4{___156. ", +" .&:}|7&.... ", +" .... 88.. ", +" .90.. ", +" .ab..", +" .9c.", +" .. "}; +#endif diff --git a/bitmaps/Zoom_Optimal.xpm b/bitmaps/Zoom_Optimal.xpm new file mode 100644 index 0000000000..d14c119dd2 --- /dev/null +++ b/bitmaps/Zoom_Optimal.xpm @@ -0,0 +1,107 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * zoom_optimal_xpm[]; + +#else +char * zoom_optimal_xpm[] = { +"16 16 83 1", +" c None", +". c #000000", +"+ c #262626", +"@ c #C5C5C5", +"# c #EEEEEE", +"$ c #EDEDED", +"% c #ABABAB", +"& c #464646", +"* c #878787", +"= c #F1F1F1", +"- c #FEFEFE", +"; c #FDFDFD", +"> c #FCFCFC", +", c #EAEAEA", +"' c #707070", +") c #FBFBFB", +"! c #E8E8E8", +"~ c #565656", +"{ c #7C7C7C", +"] c #7D7D7D", +"^ c #FAFAFA", +"/ c #A4A4A4", +"( c #747474", +"_ c #F8F2DD", +": c #DEDEDE", +"< c #E5E5E5", +"[ c #F7F1DC", +"} c #F5E9BD", +"| c #DDE0E4", +"1 c #7B7B7B", +"2 c #E4E4E4", +"3 c #535353", +"4 c #F6F0DB", +"5 c #F4E8BC", +"6 c #BCBCBC", +"7 c #C0CCD8", +"8 c #7A7A7A", +"9 c #D5D5D5", +"0 c #BABABA", +"a c #222222", +"b c #E5DFCB", +"c c #F2E6BB", +"d c #F3E7BB", +"e c #CDC5A7", +"f c #DEE3E7", +"g c #B5C2D1", +"h c #AAB5C2", +"i c #929292", +"j c #333333", +"k c #827F74", +"l c #E0D5AC", +"m c #F1E5BA", +"n c #AFAFAF", +"o c #C9D3DD", +"p c #B4C1D0", +"q c #A4B0BE", +"r c #353535", +"s c #181712", +"t c #505050", +"u c #CBCFD3", +"v c #A5B1BF", +"w c #747D87", +"x c #32363A", +"y c #F5E9BF", +"z c #817445", +"A c #17150C", +"B c #010100", +"C c #010102", +"D c #0B0E11", +"E c #191F26", +"F c #101010", +"G c #202020", +"H c #EED680", +"I c #6A6A6A", +"J c #9EB1C6", +"K c #7590AE", +"L c #686868", +"M c #343434", +"N c #C7D0D8", +"O c #617891", +"P c #797979", +"Q c #3A3A3A", +"R c #1F1F1F", +" .... ", +" .+@#$%&. ", +" .*=--;>,'. ", +" &=----;)!& ", +".~{{]{{;>^/. ", +".(-___{{:^<. ", +".([}}}{|1^2. ", +".3455567890. ", +".abcdefghi& ", +" jklmnopqr. ", +" .satuvwx.... ", +" .yzABCDE.FG.. ", +" .yHHIJKK..LM.. ", +" ....NKKKO..PQ..", +" ....... .LR.", +" .. "}; +#endif diff --git a/bitmaps/Zoom_Out.xpm b/bitmaps/Zoom_Out.xpm new file mode 100644 index 0000000000..204082923e --- /dev/null +++ b/bitmaps/Zoom_Out.xpm @@ -0,0 +1,64 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * zoom_out_xpm[]; + +#else +char * zoom_out_xpm[] = { +"16 16 40 1", +" c None", +". c #000000", +"+ c #262626", +"@ c #C5C5C5", +"# c #EEEEEE", +"$ c #EDEDED", +"% c #ABABAB", +"& c #464646", +"* c #878787", +"= c #F1F1F1", +"- c #FEFEFE", +"; c #FDFDFD", +"> c #FCFCFC", +", c #EAEAEA", +"' c #707070", +") c #FBFBFB", +"! c #E8E8E8", +"~ c #B0B0B0", +"{ c #FFFFFF", +"] c #FAFAFA", +"^ c #A4A4A4", +"/ c #050505", +"( c #090909", +"_ c #040404", +": c #242424", +"< c #E5E5E5", +"[ c #E4E4E4", +"} c #F9F9F9", +"| c #BABABA", +"1 c #E7E7E7", +"2 c #858585", +"3 c #E3E3E3", +"4 c #6D6D6D", +"5 c #A1A1A1", +"6 c #202020", +"7 c #686868", +"8 c #343434", +"9 c #797979", +"0 c #3A3A3A", +"a c #1F1F1F", +" .... ", +" .+@#$%&. ", +" .*=--;>,'. ", +" &=----;)!& ", +".~--{--;>]^. ", +".#-//(__:]<. ", +".$;:_../:][. ", +".%>;;;>)]}|. ", +" &,)>))]}1& ", +" .2!]]]}34. ", +" .&^<[5&.... ", +" .... 66.. ", +" .78.. ", +" .90..", +" .7a.", +" .. "}; +#endif diff --git a/bitmaps/Zoom_Page.xpm b/bitmaps/Zoom_Page.xpm new file mode 100644 index 0000000000..e0553617e1 --- /dev/null +++ b/bitmaps/Zoom_Page.xpm @@ -0,0 +1,92 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * zoom_page_xpm[]; + +#else +char * zoom_page_xpm[] = { +"16 16 68 1", +" c None", +". c #000000", +"+ c #262626", +"@ c #C5C5C5", +"# c #EEEEEE", +"$ c #EDEDED", +"% c #ABABAB", +"& c #464646", +"* c #878787", +"= c #F1F1F1", +"- c #FEFEFE", +"; c #FDFDFD", +"> c #FCFCFC", +", c #EAEAEA", +"' c #707070", +") c #2E2E2E", +"! c #A0A0A0", +"~ c #A9A9A9", +"{ c #E5E5E5", +"] c #FBFBFB", +"^ c #E8E8E8", +"/ c #AFAFAF", +"( c #F4F4F4", +"_ c #E9E9E9", +": c #E1E1E1", +"< c #FAFAFA", +"[ c #A4A4A4", +"} c #F9F9F9", +"| c #A8A8A8", +"1 c #E2E2E2", +"2 c #F8F8F8", +"3 c #D0D0D0", +"4 c #C7C7C7", +"5 c #BDBDBD", +"6 c #A7A7A7", +"7 c #E4E4E4", +"8 c #F7F7F7", +"9 c #F3F3F3", +"0 c #D4D4D4", +"a c #C0C0C0", +"b c #AEAEAE", +"c c #A6A6A6", +"d c #BABABA", +"e c #444444", +"f c #F5F5F5", +"g c #F6F6F6", +"h c #E7E7E7", +"i c #858585", +"j c #828282", +"k c #E3E3E3", +"l c #979797", +"m c #6D6D6D", +"n c #D6D6D6", +"o c #2D2D2D", +"p c #E0E0E0", +"q c #DEDEDE", +"r c #949494", +"s c #7C7C7C", +"t c #050505", +"u c #040404", +"v c #202020", +"w c #BBBBBB", +"x c #686868", +"y c #343434", +"z c #C2C2C2", +"A c #797979", +"B c #3A3A3A", +"C c #1F1F1F", +" .... ", +" .+@#$%&. ", +" .*=--;>,'. ", +" )!~~~{;]^& ", +"./;;(_~:><[. ", +"._}},>:|1<{. ", +".^2}13456<7. ", +".|8290abc}d. ", +".e{fgffhch& ", +".ijk((9{lm. ", +".noe!pqr).... ", +".;{s)tu. vv.. ", +".;7kkkw. .xy.. ", +".zwwww!. .AB..", +" ...... .xC.", +" .. "}; +#endif diff --git a/bitmaps/Zoom_Select.xpm b/bitmaps/Zoom_Select.xpm new file mode 100644 index 0000000000..be930384db --- /dev/null +++ b/bitmaps/Zoom_Select.xpm @@ -0,0 +1,63 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * zoom_select_xpm[]; + +#else +char * zoom_select_xpm[] = { +"16 16 39 1", +" c None", +"! c black", +"# c #252525", +"$ c #C4C4C4", +"% c #EDEDED", +"& c #ECECEC", +"' c #AAAAAA", +"( c #454545", +") c #868686", +"* c #F0F0F0", +"+ c #FDFDFD", +", c #FCFCFC", +"- c #FBFBFB", +". c #E9E9E9", +"0 c #6F6F6F", +"1 c #FF8548", +"2 c #D90000", +"3 c #FAFAFA", +"4 c #E7E7E7", +"5 c #AFAFAF", +"6 c #FEFEFE", +"7 c white", +"8 c #F9F9F9", +"9 c #A3A3A3", +": c #E4E4E4", +"; c #E3E3E3", +"< c #F8F8F8", +"= c #B9B9B9", +"> c #E6E6E6", +"? c #848484", +"@ c #E2E2E2", +"A c #6C6C6C", +"B c #A0A0A0", +"C c #202020", +"D c #1F1F1F", +"E c #676767", +"F c #333333", +"G c #787878", +"H c #393939", +" !!!! ", +" !#$%&'(! ", +" !)*++,-.0! ", +" (*+122134( ", +"!5++6712-89! ", +"!%+7722178:! ", +"!&,7727778;! ", +"!'-,,7738<=! ", +" (.3-278<>( ", +" !?4818<@A! ", +" !(9:;B(!!!! ", +" !!!! CD!! ", +" !EF!! ", +" !GH!!", +" !ED!", +" !! "}; +#endif diff --git a/bitmaps/Zoom_Selected.xpm b/bitmaps/Zoom_Selected.xpm new file mode 100644 index 0000000000..8de2310c0a --- /dev/null +++ b/bitmaps/Zoom_Selected.xpm @@ -0,0 +1,62 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * zoom_selected_xpm[]; + +#else +char * zoom_selected_xpm[] = { +"16 16 38 1", +" c None", +". c #000000", +"+ c #C5C5C5", +"@ c #EDEDED", +"# c #464646", +"$ c #878787", +"% c #CACACA", +"& c #FEFEFE", +"* c #D5D5D5", +"= c #FDFDFD", +"- c #D3D3D3", +"; c #EAEAEA", +"> c #707070", +", c #AAAAAA", +"' c #FBFBFB", +") c #E8E8E8", +"! c #B0B0B0", +"~ c #FFFFFF", +"{ c #FCFCFC", +"] c #FAFAFA", +"^ c #A4A4A4", +"/ c #E5E5E5", +"( c #C6C6C6", +"_ c #E4E4E4", +": c #B1B1B1", +"< c #F9F9F9", +"[ c #BABABA", +"} c #E7E7E7", +"| c #858585", +"1 c #E3E3E3", +"2 c #6D6D6D", +"3 c #A1A1A1", +"4 c #202020", +"5 c #686868", +"6 c #343434", +"7 c #797979", +"8 c #3A3A3A", +"9 c #1F1F1F", +".. .... .. ", +"....+.@.#. . .. ", +" .$%&*=-;>. ", +" .,&&&&=')# . ", +".!&&~&&={]^. ", +"..*&&&&=']/. . ", +".(=&&&={']_. ", +"..:==={']<[. . ", +".#;'{'']<}# ", +" .|)]]]<12. . ", +" .#^/_3#.... ", +" . .... 44.. ", +" .56.. ", +".. . . . . .78..", +".. .59.", +" .. "}; +#endif diff --git a/bitmaps/anchor.xpm b/bitmaps/anchor.xpm new file mode 100644 index 0000000000..c7619cf568 --- /dev/null +++ b/bitmaps/anchor.xpm @@ -0,0 +1,26 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *anchor_xpm[]; + +#else +char * anchor_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" .. ", +" .... ", +" .. .. ", +" .. .. ", +" .... ", +" ............ ", +" ........... ", +" .. ", +". .. .", +".. .. ..", +".. .. ..", +".. .. ..", +". .. .... . .", +" ............ ", +" .......... ", +" ...... "}; +#endif diff --git a/bitmaps/annotate.xpm b/bitmaps/annotate.xpm new file mode 100644 index 0000000000..f236462abd --- /dev/null +++ b/bitmaps/annotate.xpm @@ -0,0 +1,118 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char *annotate_xpm[]; + +#else +char *annotate_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 16 93 2", +" c None", +". c #000000", +"+ c #080808", +"@ c #B0B0B0", +"# c #1B1B1C", +"$ c #161616", +"% c #FBFBFF", +"& c #EAEAF3", +"* c #69696F", +"= c #0A0A0A", +"- c #F7F7FF", +"; c #F3F3FF", +"> c #EEEEFF", +", c #BBBBCC", +"' c #2E2E33", +") c #9B9B9B", +"! c #F4F4FF", +"~ c #EFEFFF", +"{ c #EBEBFF", +"] c #E6E6FF", +"^ c #DFDFFC", +"/ c #7D7D90", +"( c #111113", +"_ c #F0F0FF", +": c #ECECFF", +"< c #E7E7FF", +"[ c #C5C5DD", +"} c #0C0C0E", +"| c #9999B6", +"1 c #000001", +"2 c #DCDBD9", +"3 c #050506", +"4 c #0F0F0F", +"5 c #020202", +"6 c #EDEDFF", +"7 c #E8E8FF", +"8 c #E4E4FF", +"9 c #ECECED", +"0 c #B1B1AF", +"a c #0A0A0C", +"b c #474540", +"c c #9E9C95", +"d c #484641", +"e c #010101", +"f c #86857F", +"g c #0C0C0C", +"h c #090909", +"i c #E9E9FF", +"j c #E5E5FF", +"k c #E0E0FF", +"l c #9C9B97", +"m c #8F8E89", +"n c #9D9B94", +"o c #8E8C84", +"p c #95938C", +"q c #807D74", +"r c #E1E1FF", +"s c #DDDDFF", +"t c #8B8BA4", +"u c #020203", +"v c #595854", +"w c #605E57", +"x c #888782", +"y c #76746B", +"z c #E2E2FF", +"A c #D4D4F3", +"B c #43423F", +"C c #272623", +"D c #35332F", +"E c #6C6A62", +"F c #9A9AB0", +"G c #18181C", +"H c #EDEDEC", +"I c #B5B4AE", +"J c #585753", +"K c #201F1D", +"L c #090807", +"M c #171715", +"N c #E4E4E2", +"O c #7F7C73", +"P c #64625B", +"Q c #5F5D56", +"R c #676767", +"S c #050505", +"T c #878681", +"U c #151513", +"V c #8A8987", +"W c #DDDCDA", +"X c #8E8E8E", +"Y c #AEADA7", +"Z c #B4B3AD", +"` c #D3D2CF", +" . c #918F89", +" . . . . . ", +" . . . ", +" . . . . . . ", +" . + . . . ", +" . @ # $ . . . . ", +" . % & * = . ", +". . - ; > , ' $ ", +") . ! ~ { ] ^ / ( . . . ", +" . _ : < [ } } | 1 2 3 4 5 . ", +" . 6 7 8 } 9 0 a b c d e f g h ", +" . i j k } l m n n n o p q d h ", +". . ] r s t u n c v w x q y . ", +") . z A e . b c w B C D n E b . ", +" . F G e H I c J K L M N O P Q ", +" . g R 5 S d n T D U V W P b . ", +" . X ) . Y O Z N ` .P . "}; +#endif diff --git a/bitmaps/auto_associe.xpm b/bitmaps/auto_associe.xpm new file mode 100644 index 0000000000..3fc54b5620 --- /dev/null +++ b/bitmaps/auto_associe.xpm @@ -0,0 +1,149 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *auto_associe_xpm[]; + +#else +char *auto_associe_xpm[] = { +/* width height num_colors chars_per_pixel */ +"16 16 124 2", +" c None", +". c #160A00", +"+ c #FF7800", +"@ c #000000", +"# c #231000", +"$ c #E1DFDE", +"% c #44260C", +"& c #E86D00", +"* c #FFFFFF", +"= c #C35B00", +"- c #FAF6F3", +"; c #A38F7C", +"> c #C7B4A5", +", c #FDBD85", +"' c #FFBF87", +") c #FFF3EC", +"! c #FEE6D6", +"~ c #D8BDA8", +"{ c #C7874F", +"] c #F9B880", +"^ c #FFF5EF", +"/ c #FFE8D8", +"( c #FFDBC2", +"_ c #FFCEAB", +": c #F4C8A9", +"< c #D6B69C", +"[ c #F6EDE6", +"} c #F3F3F3", +"| c #878787", +"1 c #FFEADC", +"2 c #FFDDC5", +"3 c #FFD0AF", +"4 c #FFC298", +"5 c #FFB582", +"6 c #FDB380", +"7 c #EAC6A8", +"8 c #F7EADF", +"9 c #FDFDFD", +"0 c #272727", +"a c #FFDFC8", +"b c #FFD1B2", +"c c #FFC49C", +"d c #FFB785", +"e c #FFAA6F", +"f c #FF9D58", +"g c #FE9248", +"h c #F9C197", +"i c #FBEEE4", +"j c #FEFEFE", +"k c #C7C7C7", +"l c #FFD3B5", +"m c #FFC69F", +"n c #FFB988", +"o c #FFAC72", +"p c #FF9F5B", +"q c #FF9145", +"r c #FE8835", +"s c #030202", +"t c #030303", +"u c #FFC8A2", +"v c #FFBB8C", +"w c #FFAE75", +"x c #DD8C52", +"y c #0E0804", +"z c #BC9A7F", +"A c #080707", +"B c #DCDBD9", +"C c #080808", +"D c #CBCBCB", +"E c #020202", +"F c #FFBD8F", +"G c #FFB079", +"H c #FFA262", +"I c #EDEBEA", +"J c #B1B1AF", +"K c #0E0D0D", +"L c #484641", +"M c #9E9C95", +"N c #0E0E0E", +"O c #878680", +"P c #1F1F1F", +"Q c #FFB27C", +"R c #FFA465", +"S c #FE9A55", +"T c #0C0906", +"U c #9C9B96", +"V c #908F89", +"W c #8F8C84", +"X c #96938C", +"Y c #807C73", +"Z c #FFA669", +"` c #FAA162", +" . c #A37E60", +".. c #A09185", +"+. c #0E0A07", +"@. c #595854", +"#. c #605E57", +"$. c #888681", +"%. c #76736A", +"&. c #E1A074", +"*. c #442102", +"=. c #010000", +"-. c #484540", +";. c #605D56", +">. c #42413E", +",. c #272623", +"'. c #36332F", +"). c #6D6A62", +"!. c #474540", +"~. c #ECECEB", +"{. c #B5B3AD", +"]. c #9E9B94", +"^. c #595753", +"/. c #201F1D", +"(. c #090807", +"_. c #181715", +":. c #E5E4E2", +"<. c #64625B", +"[. c #5F5D56", +"}. c #35332F", +"|. c #151513", +"1. c #8B8987", +"2. c #DEDCDA", +"3. c #65625B", +" . + + + ", +" @ # + + + ", +" @ $ % & * = + * + @ @ ", +" @ * - ; > , ' ' * * + + + * @ ", +" @ * ) ! ~ { ] ' * * + + + * @ ", +"@ @ ^ / ( _ : < [ * * * * } | @ ", +" @ 1 2 3 4 5 6 7 8 * * 9 0 ", +" @ a b c d e f g h i j k @ ", +" @ l m n o p q r s t t k @ ", +" @ u v w x y y z A B C D E @ ", +"@ @ F G H y I J K L M L N O P @ ", +" @ Q R S T U V M M M W X Y L @ ", +" @ Z ` ...+.M M @.#.$.Y %.N @ ", +" @ &.*.=.@ -.M ;.>.,.'.M ).!.@ ", +" @ # @ ~.{.].^./.(._.:.Y <.[.", +" . @ @ -.].$.}.|.1.2.3.!.@ "}; +#endif diff --git a/bitmaps/book.xpm b/bitmaps/book.xpm new file mode 100644 index 0000000000..c91e84e54b --- /dev/null +++ b/bitmaps/book.xpm @@ -0,0 +1,47 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * book_xpm[]; + +#else +char * book_xpm[] = { +"16 16 21 1", +" c None", +". c #007F7F", +"+ c #660000", +"@ c #CC0000", +"# c #E50000", +"$ c #FF0000", +"% c #F20000", +"& c #D80000", +"* c #720000", +"= c #7F0000", +"- c #BFBFBF", +"; c #E57F7F", +"> c #7F7F7F", +", c #FFFFFF", +"' c #F2BFBF", +") c #723F3F", +"! c #A5A5A5", +"~ c #E5E5E5", +"{ c #B2B2B2", +"] c #003F3F", +"^ c #000000", +" ", +" ......... ", +" +@#$$$$$%&+ ", +" +##$$$$$$$* ", +" +##$$$$$$$=- ", +" +##$$$$$$$=;> ", +" +##$$$$$$$=;,. ", +" +##$$$$$$$=;,. ", +" +##$$$$$$$=''. ", +" +##$$$$$$$=,;. ", +" +##$$$$$$%+,;. ", +" +&++++++++),;. ", +" ++!~~~~~~~~~,. ", +" ++!~~~~~~~~~{. ", +" ]^^^^^^^^^^^ ", +" " +}; +#endif + diff --git a/bitmaps/cancel_tool.xpm b/bitmaps/cancel_tool.xpm new file mode 100644 index 0000000000..40b25a2ce1 --- /dev/null +++ b/bitmaps/cancel_tool.xpm @@ -0,0 +1,123 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *cancel_tool_xpm[]; + +#else +char * cancel_tool_xpm[] = { +"16 16 99 2", +" c None", +". c #411F18", +"+ c #371B16", +"@ c #060606", +"# c #010101", +"$ c #040404", +"% c #2C1510", +"& c #DB8B7C", +"* c #CE5E48", +"= c #4D1C13", +"- c #2C1613", +"; c #BF6D5D", +"> c #AB4531", +", c #070403", +"' c #000000", +") c #361A15", +"! c #D1624D", +"~ c #C75540", +"{ c #C44C36", +"] c #4B1A12", +"^ c #2E1813", +"/ c #D76F5A", +"( c #C04028", +"_ c #942D1B", +": c #0F0401", +"< c #FDFDFD", +"[ c #0A0807", +"} c #C14B35", +"| c #BF3B22", +"1 c #BD3A21", +"2 c #C24C35", +"3 c #582319", +"4 c #1C0E0B", +"5 c #D46E5A", +"6 c #B73A23", +"7 c #902B1A", +"8 c #4D150C", +"9 c #212120", +"0 c #2E140F", +"a c #C24C36", +"b c #BC3A21", +"c c #B03720", +"d c #C86C5A", +"e c #B63D26", +"f c #802516", +"g c #2B0A04", +"h c #EDEDED", +"i c #818181", +"j c #2B130E", +"k c #BB3A21", +"l c #B83A21", +"m c #CC5139", +"n c #972E1C", +"o c #1F0703", +"p c #C1C1C1", +"q c #1A0603", +"r c #CF7E6F", +"s c #BC3E26", +"t c #BA3A21", +"u c #AE361F", +"v c #29120D", +"w c #361813", +"x c #C97767", +"y c #BB3E27", +"z c #902E1D", +"A c #B23922", +"B c #22100E", +"C c #717171", +"D c #562018", +"E c #CA7160", +"F c #B73921", +"G c #94301D", +"H c #1E0A07", +"I c #40160F", +"J c #BE3A21", +"K c #A03925", +"L c #060404", +"M c #341E1B", +"N c #CB7160", +"O c #BB3C24", +"P c #96301D", +"Q c #230C08", +"R c #C03A21", +"S c #AB351F", +"T c #220F0B", +"U c #383331", +"V c #8F2E1D", +"W c #922F1D", +"X c #170805", +"Y c #070707", +"Z c #C64D36", +"` c #9F3420", +" . c #220F0C", +".. c #9DA08E", +"+. c #9F9F9F", +"@. c #371B17", +"#. c #190804", +"$. c #321914", +"%. c #301611", +" . + @ # $ ", +" % & * = - ; > , ", +" ' ' ) ! ~ { ] ^ / ( _ : ", +"' < ' [ } | 1 2 3 4 5 6 7 8 ", +"' < ' ' 9 0 a b b c d e f g ", +"' < h h h i j } k l m n o ", +" ' < h h p # q r s t k u v ", +" ' ' < p ' w x y z } b b A B ", +" ' < C D E F G H I 2 1 J K L ", +" ' < M N O P Q ] { R S T ", +" ' < U V W X Y = Z ` .", +"..' < h +.@.#. @ $.%. ", +"' < h h h h p ' ", +"' < ' ' ' ' h ' ", +"' < ' ' h ' ", +" ' ' ' ' "}; +#endif diff --git a/bitmaps/config.xpm b/bitmaps/config.xpm new file mode 100644 index 0000000000..e7b49871ff --- /dev/null +++ b/bitmaps/config.xpm @@ -0,0 +1,79 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *config_xpm[]; + +#else +char * config_xpm[] = { +"16 16 55 1", +" c None", +". c #000000", +"+ c #F2F2F2", +"@ c #E0E0E0", +"# c #E1E1E1", +"$ c #C3C3C3", +"% c #C1C1C1", +"& c #C2C2C2", +"* c #969696", +"= c #999999", +"- c #9A9A9A", +"; c #E5E5E5", +"> c #DFDFDF", +", c #CACACA", +"' c #666666", +") c #858585", +"! c #898989", +"~ c #8A8A8A", +"{ c #B1B1B1", +"] c #A5A5A5", +"^ c #F3F3F3", +"/ c #959595", +"( c #D0D0D0", +"_ c #ADADAD", +": c #F0F0F0", +"< c #EFEFEF", +"[ c #EBEBEB", +"} c #DBDBDB", +"| c #B7B7B7", +"1 c #767676", +"2 c #6C6C6C", +"3 c #787878", +"4 c #979797", +"5 c #A9A9A9", +"6 c #7C7C7C", +"7 c #757575", +"8 c #727272", +"9 c #929292", +"0 c #7E7E7E", +"a c #8C8C8C", +"b c #B5B5B5", +"c c #EDEDED", +"d c #9C9C9C", +"e c #848484", +"f c #E2E2E2", +"g c #C4C4C4", +"h c #B9B9B9", +"i c #777777", +"j c #6D6D6D", +"k c #676767", +"l c #AAAAAA", +"m c #888888", +"n c #818181", +"o c #7B7B7B", +"p c #797979", +" .............. ", +".+@###########$.", +".#%%%%%%&&&&&&*.", +".#%=...-&&&&&$*.", +".#%.;>,.')!~{$*.", +".#%.>&].....^&/.", +".#%.(]=._:<[}$*.", +".#&-...')$$$$&/.", +".#&|12'3~...-&4.", +".#&56678.;>,.94.", +".#&0.....>&].a/.", +".#&bc<<<.(]=.a/.", +".#$$$$$$d...'e/.", +".f$$$$$ghijki_/.", +".l****444mmno/p.", +" .............. "}; +#endif diff --git a/bitmaps/copy.xpm b/bitmaps/copy.xpm new file mode 100644 index 0000000000..3ae7f0a1b1 --- /dev/null +++ b/bitmaps/copy.xpm @@ -0,0 +1,31 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *copy_button[]; + +#else +char *copy_button[] = { +/* columns rows colors chars-per-pixel */ +"16 15 4 1", +" c None", +". c Black", +"X c Gray100", +"o c #000080", +/* pixels */ +" ", +" ...... ", +" .XXXX.. ", +" .XXXX.X. ", +" .X..X.oooooo ", +" .XXXXXoXXXXoo ", +" .X....oXXXXoXo ", +" .XXXXXoX..Xoooo", +" .X....oXXXXXXXo", +" .XXXXXoX.....Xo", +" ......oXXXXXXXo", +" oX.....Xo", +" oXXXXXXXo", +" ooooooooo", +" " +}; +#endif + diff --git a/bitmaps/cursor.xpm b/bitmaps/cursor.xpm new file mode 100644 index 0000000000..5b6dc550d4 --- /dev/null +++ b/bitmaps/cursor.xpm @@ -0,0 +1,97 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *cursor_xpm[]; + +#else +char * cursor_xpm[] = { +"16 16 73 1", +" c None", +". c #000000", +"+ c #0C0C0C", +"@ c #0D0D0D", +"# c #D3D3D3", +"$ c #434343", +"% c #1A1A1A", +"& c #E5E5E5", +"* c #FFFFFF", +"= c #919199", +"- c #0E0E0F", +"; c #202020", +"> c #D5D5D5", +", c #F9F9FF", +"' c #ECECFF", +") c #C6C6E2", +"! c #3A3A47", +"~ c #252525", +"{ c #C6C6C6", +"] c #F3F3FF", +"^ c #E6E6FF", +"/ c #D9D9FF", +"( c #CCCCFF", +"_ c #76769E", +": c #0B0B11", +"< c #2A2A2A", +"[ c #B3B3B7", +"} c #EDEDFF", +"| c #E0E0FF", +"1 c #D3D3FF", +"2 c #A3A3D2", +"3 c #535372", +"4 c #101018", +"5 c #2E2E2E", +"6 c #A0A0A7", +"7 c #E7E7FF", +"8 c #C0C0E1", +"9 c #BBBBE9", +"0 c #0C0C10", +"a c #565656", +"b c #989898", +"c c #323232", +"d c #8E8E98", +"e c #9E9EB3", +"f c #0B0B0D", +"g c #9C9CC8", +"h c #7A7AA7", +"i c #999999", +"j c #9B9B9B", +"k c #363636", +"l c #2D2D31", +"m c #5D5D5D", +"n c #3F3F53", +"o c #B4B4FF", +"p c #3C3C5B", +"q c #060606", +"r c #393939", +"s c #474747", +"t c #181819", +"u c #9595DB", +"v c #9898F0", +"w c #13131F", +"x c #606060", +"y c #454568", +"z c #9B9BFF", +"A c #60609E", +"B c #969696", +"C c #161619", +"D c #41416B", +"E c #2F2F2F", +"F c #5A5A5A", +"G c #3E3E3E", +"H c #8E8E8E", +" . ", +" .+ ", +" @#$. ", +" %&*=- ", +" ;>,')!. ", +" ~{]^/(_: ", +" <[}|1234. ", +" 567890ab ", +" cdefgh~ij ", +" kl c #00FF00", +"( c #800000", +": c #800080", +"- c #808080", +". c None", +"? c #FF0000", +"U c #FF00FF", +"$ c #FFFF00", +"o c White", + +"............Xoo$", +"...........Xoo$$", +"..........Xoo$$%", +".........X>Xo$%-", +"........X>$>X%--", +".......X>$>WWX-X", +"......?UX>WW%)X.", +".o...?UoUXW%)X..", +".oo.?UoU?UX)X...", +"ooo.U?o?UU)X....", +"oooo?U?UU:(.....", +"oooo-?UU:(......", +"ooooo-(((.......", +".oooooo.........", +"..o..o.........." +}; +#endif diff --git a/bitmaps/del_track.xpm b/bitmaps/del_track.xpm new file mode 100644 index 0000000000..ecc8e5b9f3 --- /dev/null +++ b/bitmaps/del_track.xpm @@ -0,0 +1,40 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * auto_delete_track_xpm[]; + +#else +char * auto_delete_track_xpm[] = +{ +"16 15 14 1", +"X c Black", +"% c #000080", +"W c #008000", +") c #008080", +"> c #00FF00", +"( c #800000", +": c #800080", +"- c #808080", +". c None", +"? c #FF0000", +"U c #FF00FF", +"$ c #FFFF00", +"o c White", +"z c Red", + +"zz..........Xoo$", +"zz.........Xoo$$", +"zz........Xoo$$%", +".zz......X>Xo$%-", +"..zz....X>$>X%--", +"...zz..X>$>WWX-X", +"....zz?UX>WW%)X.", +".o...?UoUXW%)X..", +".oo.?UoU?UX)X...", +"ooo.U?o?UU)X....", +"oooo?U?UU:(.....", +"oooo-?UU:(......", +"ooooo-(((zz.....", +".oooooo....zz...", +"..o..o.......zz." +}; +#endif diff --git a/bitmaps/delete.xpm b/bitmaps/delete.xpm new file mode 100644 index 0000000000..472fe15e58 --- /dev/null +++ b/bitmaps/delete.xpm @@ -0,0 +1,176 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *delete_xpm[]; + +#else +char * delete_xpm[] = { +"16 16 152 2", +" c None", +". c #0E0E0E", +"+ c #424242", +"@ c #4A4A4A", +"# c #3E3E3E", +"$ c #2C2C2C", +"% c #000000", +"& c #858371", +"* c #F0EDD8", +"= c #F2F1E9", +"- c #EEEDE4", +"; c #C7C6BA", +"> c #535246", +", c #101010", +"' c #C2C0A5", +") c #C1BFA5", +"! c #7A7967", +"~ c #484740", +"{ c #272725", +"] c #36352E", +"^ c #878572", +"/ c #A09E88", +"( c #A3A18A", +"_ c #A5A38C", +": c #2B2B2B", +"< c #D3D1BC", +"[ c #DCDAC4", +"} c #E2E0CF", +"| c #B9B7A2", +"1 c #64625B", +"2 c #393836", +"3 c #3C3C33", +"4 c #616053", +"5 c #9A9883", +"6 c #B7B59B", +"7 c #B3B298", +"8 c #A4A28B", +"9 c #E8E4D3", +"0 c #F4F1E9", +"a c #F2F1E4", +"b c #EAE9DA", +"c c #E5E2D2", +"d c #D5D2BE", +"e c #C3C1A7", +"f c #AFAD94", +"g c #C0BEA4", +"h c #C6C4AC", +"i c #B8B69C", +"j c #797766", +"k c #8A8975", +"l c #F1EDD2", +"m c #FBF8E9", +"n c #F9F5ED", +"o c #F8F7EE", +"p c #F8F7EC", +"q c #F5F3E6", +"r c #ECEAD9", +"s c #DEDDCB", +"t c #9D9B89", +"u c #636254", +"v c #58574A", +"w c #525146", +"x c #737165", +"y c #9F9D91", +"z c #E4E1C8", +"A c #E9E5CF", +"B c #E2E0CB", +"C c #D1D1CB", +"D c #8E8D7F", +"E c #767564", +"F c #686758", +"G c #434238", +"H c #292822", +"I c #1F1F1B", +"J c #343430", +"K c #4B4944", +"L c #686762", +"M c #706F66", +"N c #6B6B64", +"O c #6E6C5D", +"P c #58574B", +"Q c #393931", +"R c #171615", +"S c #1A1A16", +"T c #1F1E19", +"U c #2A2A23", +"V c #A0A095", +"W c #4D4D40", +"X c #363630", +"Y c #2A2A26", +"Z c #2F2F2A", +"` c #0F0F0D", +" . c #0B0B09", +".. c #10100D", +"+. c #3E3E38", +"@. c #34342B", +"#. c #24241F", +"$. c #2B2B24", +"%. c #A5A499", +"&. c #B7B6AE", +"*. c #717067", +"=. c #A1A192", +"-. c #747363", +";. c #404035", +">. c #69695B", +",. c #39392F", +"'. c #69695F", +"). c #3F3F34", +"!. c #262620", +"~. c #2C2C25", +"{. c #ADADA3", +"]. c #D9D9D2", +"^. c #8B8B7F", +"/. c #D6D5CE", +"(. c #88887B", +"_. c #58574F", +":. c #939387", +"<. c #4A4A3D", +"[. c #78786B", +"}. c #505042", +"|. c #292922", +"1. c #DADAD3", +"2. c #8F8E81", +"3. c #DDDDD4", +"4. c #ACAB99", +"5. c #5D5D52", +"6. c #A0A093", +"7. c #79796C", +"8. c #7E7E75", +"9. c #D8D8D1", +"0. c #8D8D80", +"a. c #DDDDD3", +"b. c #444438", +"c. c #282822", +"d. c #272721", +"e. c #43433D", +"f. c #8E8E86", +"g. c #5E5E55", +"h. c #DADAD0", +"i. c #949484", +"j. c #5D5D53", +"k. c #23231D", +"l. c #060606", +"m. c #42413A", +"n. c #8F8F7B", +"o. c #7A7A6C", +"p. c #44443C", +"q. c #6C6C5E", +"r. c #35352C", +"s. c #2E2E29", +"t. c #0F0F0F", +"u. c #050505", +" . + @ # $ % ", +" % % & * = - ; > % % ", +" , ' ) ! ~ { ] ^ / ( _ % ", +" : < [ } | 1 2 3 4 5 6 7 8 % ", +" % 9 0 a b c d e f g h i j % ", +" % k l m n o p q r s t u v % ", +" % w x y z A B C D E F G H % ", +" I J K L M N O P Q R S T ", +" U V W X Y Z ` ...+.@.#. ", +" $.%.&.*.=.-.;.>.,.'.).!. ", +" ~.{.].^./.(._.:.<.[.}.|. ", +" ~.{.1.2.3.4.5.6.W 7.}.|. ", +" $.8.9.0.a.4.5.6.W [.b.c. ", +" d.e.f.g.h.4.5.i.W j.c.k. ", +" l.l.m.n.o.p.q.r.s.% ", +" l.% t.u.% % "}; +#endif diff --git a/bitmaps/down.xpm b/bitmaps/down.xpm new file mode 100644 index 0000000000..ff4e31bcce --- /dev/null +++ b/bitmaps/down.xpm @@ -0,0 +1,49 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *down_xpm[]; + +#else +char * down_xpm[] = { +"16 16 25 1", +" c None", +". c #000000", +"+ c #B5C9DC", +"@ c #9BB6D0", +"# c #91B0CC", +"$ c #49749C", +"% c #456F96", +"& c #AFC5DA", +"* c #A0BAD3", +"= c #9EB8D1", +"- c #3F6588", +"; c #375978", +"> c #B2C7DB", +", c #9CB7D1", +"' c #9AB5CF", +") c #B6CADD", +"! c #5B88B2", +"~ c #A4BDD5", +"{ c #2A435B", +"] c #5080AD", +"^ c #97B3CE", +"/ c #080D11", +"( c #5F8BB4", +"_ c #95B2CE", +": c #4C79A3", +" ", +" ", +" ....... ", +" .+@#$%. ", +" .&*=-;. ", +" .>,'-;. ", +" .),'-;. ", +" .)@@-;. ", +" ....)',-;.... ", +" .!=~*,---{. ", +" .],,,--{. ", +" .]^*-{. ", +" /(_{. ", +" .:. ", +" . ", +" "}; +#endif diff --git a/bitmaps/drc.xpm b/bitmaps/drc.xpm new file mode 100644 index 0000000000..c0ab4ff4c0 --- /dev/null +++ b/bitmaps/drc.xpm @@ -0,0 +1,111 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *drc_xpm[]; + +#else +char *drc_xpm[] = { +"16 16 87 1", +" c None", +". c #000000", +"+ c #333F4D", +"@ c #467096", +"# c #516980", +"$ c #8DACC8", +"% c #0A1116", +"& c #253341", +"* c #BFD0E0", +"= c #31506C", +"- c #3D6283", +"; c #0D151B", +"> c #1A2027", +", c #96AFC7", +"' c #618BB3", +") c #0B1217", +"! c #16222D", +"~ c #D5E0EA", +"{ c #1D2F40", +"] c #6289B0", +"^ c #A2BBD3", +"/ c #345573", +"( c #5784AF", +"_ c #B0C5D9", +": c #24394D", +"< c #1C272F", +"[ c #A1BAD2", +"} c #5885B0", +"| c #121D27", +"1 c #070B0E", +"2 c #799DBF", +"3 c #759ABD", +"4 c #203345", +"5 c #060A0C", +"6 c #89A9C7", +"7 c #7197BB", +"8 c #3B5F7F", +"9 c #000100", +"0 c #1F3242", +"a c #769BBE", +"b c #628CB4", +"c c #304D66", +"d c #5381AD", +"e c #1B2C3C", +"f c #000101", +"g c #477299", +"h c #658EB5", +"i c #94A7B9", +"j c #05080A", +"k c #040608", +"l c #040709", +"m c #DBDAD8", +"n c #0F1920", +"o c #5C88B2", +"p c #E9EAEB", +"q c #B0B0AE", +"r c #474540", +"s c #9D9B94", +"t c #86857F", +"u c #23394E", +"v c #030507", +"w c #9B9A96", +"x c #8F8E88", +"y c #8E8C84", +"z c #95938C", +"A c #7F7C73", +"B c #030608", +"C c #15222E", +"D c #010101", +"E c #585753", +"F c #5F5D56", +"G c #878681", +"H c #75736A", +"I c #42413E", +"J c #272623", +"K c #35332F", +"L c #6C6A62", +"M c #ECECEB", +"N c #B4B3AD", +"O c #201F1D", +"P c #090807", +"Q c #171715", +"R c #E4E4E2", +"S c #64625B", +"T c #151513", +"U c #8A8987", +"V c #DDDCDA", +" .. ", +" .+@. ", +" .#$%. ", +" &*=. ", +"-; >,'). ", +"!~{ .]^/. ", +" (_: .<[}|. ", +" 123456789 ", +" 0abc_de... ", +" fghijkl.m. .. ", +" nokpq.rsr.t..", +" uvwxsssyzAr.", +" BCDssEFGAH. ", +" ..rsFIJKsLr.", +" .MNsEOPQRASF", +" ..rsGKTUVSr."}; +#endif diff --git a/bitmaps/drc_off.xpm b/bitmaps/drc_off.xpm new file mode 100644 index 0000000000..352dd5bf41 --- /dev/null +++ b/bitmaps/drc_off.xpm @@ -0,0 +1,104 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *drc_off_xpm[]; + +#else +char * drc_off_xpm[] = { +"16 16 80 1", +" c None", +"! c #FF0000", +"# c black", +"$ c #252525", +"% c #C4C4C4", +"& c #EDEDED", +"' c #ECECEC", +"( c #AAAAAA", +") c #454545", +"* c #333F4D", +"+ c #F0F0F0", +", c #FDFDFD", +"- c #FCFCFC", +". c #FBFBFB", +"0 c #E9E9E9", +"1 c #6F6F6F", +"2 c #516980", +"3 c #0A1116", +"4 c #FAFAFA", +"5 c #FEFEFE", +"6 c white", +"7 c #E7E7E7", +"8 c #232323", +"9 c #253341", +": c #31506C", +"; c #AFAFAF", +"< c #F2F2F2", +"= c #476C8D", +"> c #D0D0D0", +"? c #A2A2A2", +"@ c #393F46", +"A c #618BB3", +"B c #0B1217", +"C c #EAEAEA", +"D c #323E49", +"E c #D6E1EB", +"F c #A4A4A4", +"G c #F4F4F4", +"H c #2C2C2C", +"I c #A2BBD3", +"J c #345573", +"K c #9E9E9E", +"L c #5885B0", +"M c #B1C6DA", +"N c #929393", +"O c #6A6A6A", +"P c #121D27", +"Q c #F3F3F3", +"R c #3C4043", +"S c #7A9EC0", +"T c #769BBE", +"U c #8AAAC8", +"V c #7298BC", +"W c #3B5F7F", +"X c #000100", +"Y c #D6D6D6", +"Z c #263949", +"[ c #779CBF", +"] c #5381AD", +"^ c #1B2C3C", +"_ c #848484", +"` c #5B5C5C", +"a c #668FB6", +"b c #ACC2D7", +"c c #41688B", +"d c #05090B", +"e c #A3A3A3", +"f c #242E35", +"g c #5D89B3", +"h c #48739A", +"i c #41698D", +"j c #23394E", +"k c #3C6182", +"l c #284057", +"m c #0B131A", +"n c #030608", +"o c #1A2A39", +"p c #404040", +"q c #767676", +"r c #676767", +"! #### ##!", +" !#$%&'()# #*!#", +" #!+,,-.01##2!3#", +" )+!456-4789!:# ", +"#;<=!>4-.?@!AB# ", +"#&CDE!FG6H!IJ# ", +"#'4KLM!NO!ILP# ", +"#(.QRST!!UVWX ", +" )04YZ[!!M]^# ", +" #_7G`!ab!cd ", +" #)e!fghi!## ", +" !##jklm!## ", +" ! nom#p!## ", +" ! ####q!##", +" ! # #r!#", +"! ##!"}; +#endif diff --git a/bitmaps/eeschema.xpm b/bitmaps/eeschema.xpm new file mode 100644 index 0000000000..700f92934c --- /dev/null +++ b/bitmaps/eeschema.xpm @@ -0,0 +1,102 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char *eeschema_xpm[]; + +#else +char *eeschema_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 16 76 1", +" c None", +". c #000000", +"+ c #FDFDFD", +"@ c #FCFCFC", +"# c #DEDEDE", +"$ c #BFBFBF", +"% c #F0F0F0", +"& c #C1C1C1", +"* c #F9F9F9", +"= c #A6A6A6", +"- c #E7E7E7", +"; c #676767", +"> c #ABABAB", +", c #757575", +"' c #5C5C5C", +") c #3F3F3F", +"! c #E2E2E2", +"~ c #8F8F8F", +"{ c #B1B1B1", +"] c #282625", +"^ c #6F3400", +"/ c #FF7800", +"( c #848383", +"_ c #4A4A48", +": c #151515", +"< c #823D00", +"[ c #040404", +"} c #9A4800", +"| c #BDBDBD", +"1 c #EEEEEE", +"2 c #E0E0E0", +"3 c #8E8E8E", +"4 c #AFAFAF", +"5 c #753700", +"6 c #F67400", +"7 c #BCBCBC", +"8 c #F5F5F5", +"9 c #565656", +"0 c #DFDFDF", +"a c #EDEDED", +"b c #E4E4E4", +"c c #666666", +"d c #231000", +"e c #BD5900", +"f c #101010", +"g c #E5E5E5", +"h c #1A1A1A", +"i c #AEAEAE", +"j c #EBEBEB", +"k c #EAEAEA", +"l c #ACACAC", +"m c #636363", +"n c #D9D9D9", +"o c #545454", +"p c #B9B9B9", +"q c #F4F4F4", +"r c #262423", +"s c #AAAAAA", +"t c #8A8A8A", +"u c #E6E6E6", +"v c #BEBEBE", +"w c #F37200", +"x c #252322", +"y c #A8A8A8", +"z c #888888", +"A c #D6D6D6", +"B c #E3E3E3", +"C c #060606", +"D c #B05300", +"E c #1C0D00", +"F c #626262", +"G c #DADADA", +"H c #BABABA", +"I c #8B8B8B", +"J c #BBBBBB", +"K c #9F9F9F", +" .......... ", +" .++++++@#$.. ", +" .+%%%%%%&*=.. ", +" .+%%%%-;>,'). ", +" .+%!~{]^/(_:. ", +" ....<[}///.|. ", +" .+1234]56/.7. ", +" .890aabcde.f. ", +" .g.hijkklh.i. ", +" .:.edm#--nop. ", +" .q./65rstnuv. ", +" .q.///}[<.... ", +" .q./w^xyzAB7. ", +" .C.DEFGB!!!H. ", +" .H.:IJJHHHHK. ", +" ........... "}; +#endif + diff --git a/bitmaps/erc.xpm b/bitmaps/erc.xpm new file mode 100644 index 0000000000..c921463481 --- /dev/null +++ b/bitmaps/erc.xpm @@ -0,0 +1,124 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *erc_xpm[]; + +#else +char *erc_xpm[] = { +"16 16 100 2", +" c None", +". c #000000", +"+ c #252525", +"@ c #C4C4C4", +"# c #EDEDED", +"$ c #ECECEC", +"% c #AAAAAA", +"& c #454545", +"* c #333F4D", +"= c #467096", +"- c #868686", +"; c #F0F0F0", +"> c #FDFDFD", +", c #FCFCFC", +"' c #FBFBFB", +") c #E9E9E9", +"! c #6F6F6F", +"~ c #516980", +"{ c #8DACC8", +"] c #0A1116", +"^ c #F5F5F5", +"/ c #FAFAFA", +"( c #FEFEFE", +"_ c #FFFFFF", +": c #E7E7E7", +"< c #232323", +"[ c #253341", +"} c #BFD0E0", +"| c #31506C", +"1 c #AFAFAF", +"2 c #F2F2F2", +"3 c #476C8D", +"4 c #2D353B", +"5 c #D0D0D0", +"6 c #A2A2A2", +"7 c #393F46", +"8 c #96AFC7", +"9 c #618BB3", +"0 c #0B1217", +"a c #EAEAEA", +"b c #323E49", +"c c #D6E1EB", +"d c #27394A", +"e c #A4A4A4", +"f c #F4F4F4", +"g c #2C2C2C", +"h c #638AB1", +"i c #A2BBD3", +"j c #345573", +"k c #9E9E9E", +"l c #5885B0", +"m c #B1C6DA", +"n c #283D51", +"o c #929393", +"p c #6A6A6A", +"q c #4A555D", +"r c #121D27", +"s c #F3F3F3", +"t c #3C4043", +"u c #7A9EC0", +"v c #769BBE", +"w c #243749", +"x c #54585A", +"y c #8AAAC8", +"z c #7298BC", +"A c #3B5F7F", +"B c #000100", +"C c #D6D6D6", +"D c #263949", +"E c #779CBF", +"F c #638DB5", +"G c #34516A", +"H c #5381AD", +"I c #1B2C3C", +"J c #848484", +"K c #5B5C5C", +"L c #48739A", +"M c #668FB6", +"N c #ACC2D7", +"O c #628CB4", +"P c #41688B", +"Q c #05090B", +"R c #A3A3A3", +"S c #242E35", +"T c #5D89B3", +"U c #41698D", +"V c #253B50", +"W c #23394E", +"X c #3C6182", +"Y c #284057", +"Z c #0B131A", +"` c #0C0C0C", +" . c #030608", +".. c #1A2A39", +"+. c #404040", +"@. c #303030", +"#. c #767676", +"$. c #393939", +"%. c #676767", +"&. c #1F1F1F", +" . . . . . . ", +" . + @ # $ % & . . * = . ", +" . - ; > > , ' ) ! . . ~ { ] . ", +" & ; ^ / ( _ , / : < [ } | . ", +". 1 2 3 4 5 / , ' 6 7 8 9 0 . ", +". # a b c d e f _ g h i j . ", +". $ / k l m n o p q i l r . ", +". % ' s t u v w x y z A B ", +" & ) / C D E F G m H I . ", +" . J : f K L M N O P Q ", +" . & R C S T L U V . . ", +" . . . W X Y Z ` . . ", +" ...Z . +.@.. . ", +" . . . . #.$.. . ", +" . . %.&.. ", +" . . "}; +#endif diff --git a/bitmaps/ercerr.xpm b/bitmaps/ercerr.xpm new file mode 100644 index 0000000000..cab6f19161 --- /dev/null +++ b/bitmaps/ercerr.xpm @@ -0,0 +1,20 @@ +/* XPM */ +static char *error_xpm[] = { +/* columns rows colors chars-per-pixel */ +"11 11 2 1", +"- c Black", +"X c Red", + +/* pixels */ +"XXXXXXXXXXXX", +"X----------X", +"X---------XX", +"X--XXXXXXXXX", +"X--XXXXXXXXX", +"X------XXXXX", +"X--XXXXXXXXX", +"X--XXXXXXXXX", +"X---------XX", +"X----------X", +"XXXXXXXXXXXX" +}; diff --git a/bitmaps/ercgreen.xpm b/bitmaps/ercgreen.xpm new file mode 100644 index 0000000000..b013ff5ff2 --- /dev/null +++ b/bitmaps/ercgreen.xpm @@ -0,0 +1,20 @@ +/* XPM */ +static char *green_xpm[] = { +/* columns rows colors chars-per-pixel */ +"11 11 2 1", +"- c Black", +"X c Green", + +/* pixels */ +"XXXXXXXXXXXX", +"XXXXXXXXXXXX", +"XXXXXXXXXXXX", +"XXXXXXXXXXXX", +"XXXXXXXXXXXX", +"XXXXXXXXXXXX", +"XXXXXXXXXXXX", +"XXXXXXXXXXXX", +"XXXXXXXXXXXX", +"XXXXXXXXXXXX", +"XXXXXXXXXXXX" +}; diff --git a/bitmaps/ercwarn.xpm b/bitmaps/ercwarn.xpm new file mode 100644 index 0000000000..dbe20fb81f --- /dev/null +++ b/bitmaps/ercwarn.xpm @@ -0,0 +1,20 @@ +/* XPM */ +static char *warning_xpm[] = { +/* columns rows colors chars-per-pixel */ +"11 11 2 1", +"- c Black", +"X c Yellow", + +/* pixels */ +"XXXXXXXXXXX", +"XXXXXXXXXXX", +"X-XXXXXXX-X", +"X-XXXXXXX-X", +"X-XXXXXXX-X", +"X-XXX-XXX-X", +"X-XXX-XXX-X", +"X-XXX-XXX-X", +"XX-X-X-X-XX", +"XXX-XXX-XXX", +"XXXXXXXXXXX" +}; diff --git a/bitmaps/export.xpm b/bitmaps/export.xpm new file mode 100644 index 0000000000..85c32cab73 --- /dev/null +++ b/bitmaps/export.xpm @@ -0,0 +1,67 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *export_xpm[]; + +#else +char * export_xpm[] = { +"16 16 43 1", +" c None", +". c #000000", +"+ c #1D1D1D", +"@ c #FFFFFF", +"# c #757575", +"$ c #EBEBEB", +"% c #B5B5B5", +"& c #A1A1A1", +"* c #C3C3C3", +"= c #212121", +"- c #ABABAB", +"; c #545454", +"> c #009B00", +", c #00BD00", +"' c #002A00", +") c #777777", +"! c #8F8F8F", +"~ c #006100", +"{ c #008E00", +"] c #0F1B0F", +"^ c #001800", +"/ c #E9E9E9", +"( c #335133", +"_ c #00B100", +": c #00A700", +"< c #006600", +"[ c #003E00", +"} c #006500", +"| c #005F00", +"1 c #D7D7D7", +"2 c #1A381A", +"3 c #00A600", +"4 c #E2E2E2", +"5 c #6E756E", +"6 c #034603", +"7 c #008600", +"8 c #00BB00", +"9 c #006E00", +"0 c #B6B6B6", +"a c #008B00", +"b c #000400", +"c c #004200", +"d c #001000", +" ......+. ", +".@@@@@@##. ", +".@$$$$$#$#. ", +".@$$$$$%%&. ", +".@$$$$$$$*. ", +".@$$$=...-. ", +".@$$$;>,'). . ", +".@$$$!~,{]. ^. ", +".@$$$/(_,:<[}|. ", +".@$$$$123,,,,,|.", +".@$$$$$4567:8,9.", +".@$$$$$$$0. |ab ", +".@$$$$$$$*. cd ", +".*********. . ", +"........... ", +" "}; +#endif diff --git a/bitmaps/find.xpm b/bitmaps/find.xpm new file mode 100644 index 0000000000..af51798c21 --- /dev/null +++ b/bitmaps/find.xpm @@ -0,0 +1,34 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *find_xpm[]; + +#else +char *find_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 6 1", + +"E c #404040", +". c None", +"I c #808080", +"L c #FFFF00", +"M c #0000FF", +"P c White", + +"................", +"....EE....EE....", +"....EE....EE....", +"....EE....EE....", +"...EEEE..EEEE...", +"..EPMMEEEEPMME..", +"..EPMMEIIEPMME..", +"..EMMEE..EEMME...", +"..EPME....EPME..", +"..EPME....EPME..", +"..EPME....EPME..", +".EPEEEE..EPEEEE.", +".EPEEEE..EPEEEE.", +".EEEEEE..EEEEEE.", +"................" +}; +#endif + diff --git a/bitmaps/general_deletions.xpm b/bitmaps/general_deletions.xpm new file mode 100644 index 0000000000..5708abb7d2 --- /dev/null +++ b/bitmaps/general_deletions.xpm @@ -0,0 +1,182 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *general_deletions_xpm[]; + +#else +char * general_deletions_xpm[] = { +"16 16 158 2", +" c None", +". c #0D0D0D", +"+ c #414141", +"@ c #494949", +"# c #3D3D3D", +"$ c #2B2B2B", +"% c #000000", +"& c #838170", +"* c #EEEBD6", +"= c #F0EFE7", +"- c #ECEBE2", +"; c #C5C4B8", +"> c #525145", +", c #0F0F0F", +"' c #C0BEA3", +") c #BFBDA3", +"! c #797866", +"~ c #47463F", +"{ c #262624", +"] c #35342D", +"^ c #858371", +"/ c #9E9C86", +"( c #A19F88", +"_ c #A3A18A", +": c #2A2A2A", +"< c #D1CFBA", +"[ c #DAD8C2", +"} c #E0DECD", +"| c #B7B5A0", +"1 c #63615A", +"2 c #383735", +"3 c #3B3B32", +"4 c #605F52", +"5 c #989681", +"6 c #B5B399", +"7 c #B1B096", +"8 c #A2A089", +"9 c #E6E2D1", +"0 c #F2EFE7", +"a c #F0EFE2", +"b c #E8E7D8", +"c c #E3E0D0", +"d c #D3D0BC", +"e c #C1BFA5", +"f c #ADAB92", +"g c #BEBCA2", +"h c #C4C2AA", +"i c #B6B49A", +"j c #787665", +"k c #888774", +"l c #EFEBD0", +"m c #F9F6E7", +"n c #F7F3EB", +"o c #F6F5EC", +"p c #F6F5EA", +"q c #F3F1E4", +"r c #EAE8D7", +"s c #DCDBC9", +"t c #9B9987", +"u c #626153", +"v c #575649", +"w c #515045", +"x c #727064", +"y c #9D9B8F", +"z c #E2DFC6", +"A c #E7E3CD", +"B c #E0DEC9", +"C c #CFCFC9", +"D c #8C8B7E", +"E c #757463", +"F c #676657", +"G c #424137", +"H c #282721", +"I c #1E1E1A", +"J c #33332F", +"K c #4A4843", +"L c #676661", +"M c #6F6E65", +"N c #6A6A63", +"O c #6D6B5C", +"P c #57564A", +"Q c #383830", +"R c #161514", +"S c #191915", +"T c #1E1D18", +"U c #292922", +"V c #9E9E93", +"W c #4C4C3F", +"X c #35352F", +"Y c #292925", +"Z c #2E2E29", +"` c #0E0E0C", +" . c #0A0A08", +".. c #010101", +"+. c #010100", +"@. c #23231E", +"#. c #2A2A23", +"$. c #A3A297", +"%. c #B5B4AC", +"&. c #706F66", +"*. c #8A8A7D", +"=. c #060605", +"-. c #030303", +";. c #545448", +">. c #020201", +",. c #DBDAD8", +"'. c #020202", +"). c #1E1E19", +"!. c #2B2B24", +"~. c #ABABA1", +"{. c #D7D7D0", +"]. c #89897E", +"^. c #0C0C0B", +"/. c #EBEBEA", +"(. c #B0B0AE", +"_. c #080807", +":. c #474540", +"<. c #9D9B94", +"[. c #86857F", +"}. c #D8D8D1", +"|. c #8D8C7F", +"1. c #0C0C0C", +"2. c #9C9B97", +"3. c #8F8E88", +"4. c #9E9C95", +"5. c #8E8C84", +"6. c #95938C", +"7. c #7F7C73", +"8. c #7D7D74", +"9. c #D6D6CF", +"0. c #8B8B7F", +"a. c #B0B0A8", +"b. c #090908", +"c. c #585753", +"d. c #5F5D56", +"e. c #878681", +"f. c #75736A", +"g. c #262620", +"h. c #42423C", +"i. c #8C8C84", +"j. c #030302", +"k. c #484641", +"l. c #605E57", +"m. c #42413E", +"n. c #272623", +"o. c #35332F", +"p. c #6C6A62", +"q. c #050505", +"r. c #EDEDEB", +"s. c #B4B3AD", +"t. c #201F1D", +"u. c #090807", +"v. c #171715", +"w. c #E4E4E2", +"x. c #64625B", +"y. c #151513", +"z. c #8A8987", +"A. c #DDDCDA", +" . + @ # $ % ", +" % % & * = - ; > % % ", +" , ' ) ! ~ { ] ^ / ( _ % ", +": < [ } | 1 2 3 4 5 6 7 8 % ", +"% 9 0 a b c d e f g h i j % ", +"% k l m n o p q r s t u v % ", +"% w x y z A B C D E F G H % ", +" I J K L M N O P Q R S T ", +" U V W X Y Z ` .% ..+.@. ", +" #.$.%.&.*.=.-.;.>.,.'.).% % ", +" !.~.{.].^./.(._.:.<.:.'.[.% % ", +" !.~.}.|.1.2.3.4.<.<.5.6.7.:.% ", +" #.8.9.0.a.b.<.4.c.d.e.7.f.% ", +" g.h.i...j.k.<.l.m.n.o.<.p.:.% ", +" q.q...r.s.<.c.t.u.v.w.7.x.d.", +" % % :.<.e.o.y.z.A.x.:.% "}; +#endif diff --git a/bitmaps/green.xpm b/bitmaps/green.xpm new file mode 100644 index 0000000000..d5ff356014 --- /dev/null +++ b/bitmaps/green.xpm @@ -0,0 +1,33 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *green_xpm[]; + +#else +char *green_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 6 1", +" c Gray0", +"X c #7b7b7b7b7b7b", +"O c Green", +"# c White", +"+ c Yellow", +"@ c None", + +/* pixels */ +"@@@@@@@@@@@@@@@@", +"@@@@@@@@@@@@@@@@", +"@@@@@@@@@@@@@@@@", +"@@@@X X@@@@@@", +"@@@ OOOO @@@@@", +"@@X +#OOOO X@@@@", +"@@ O#+OOOOO @@@@", +"@@ OOOOOOOO @@@@", +"@@ OOOOOO+O X@@@", +"@@ OOOOO++O X@@@", +"@@X OOO++O XX@@@", +"@@@ OOOO XXX@@", +"@@@@X XXXX@@@", +"@@@@@@@XXXXXX@@@", +"@@@@@@@@@@X@@@@@" +}; +#endif diff --git a/bitmaps/grid.xpm b/bitmaps/grid.xpm new file mode 100644 index 0000000000..a13080e90d --- /dev/null +++ b/bitmaps/grid.xpm @@ -0,0 +1,30 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char *grid_xpm[]; + +#else +char * grid_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 2 1", +"X c None", +"o c Black", + +/* pixels */ +"XXXXXXXXXXXXXXXX", +"oXXXoXXXoXXXoXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"oXXXoXXXoXXXoXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"oXXXoXXXoXXXoXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXX", +"oXXXoXXXoXXXoXXX", +"XXXXXXXXXXXXXXXX" +}; +#endif + diff --git a/bitmaps/grid_select.xpm b/bitmaps/grid_select.xpm new file mode 100644 index 0000000000..8ef430ea00 --- /dev/null +++ b/bitmaps/grid_select.xpm @@ -0,0 +1,33 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *grid_select_xpm[]; + +#else +char *grid_select_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 16 8 1", +" c Black", +". c none", +"X c #00807f", +"o c #008080", +"O c #00827d", +"+ c #00817e", +"@ c #00847b", +"# c #00857a", +" .. .. .. .. .. ", +"................", +"................", +" .. .. .. .. .. ", +"................", +"................", +" .X.oX .. XO.X. ", +"..XOXo....+X@X..", +"..Xo+......ooX..", +" .XXXXXXXXXXoX. ", +"..XoX......oXX..", +"..X#Xo....+o#X..", +" .X.oo .. oO.X. ", +"................", +"................", +" .. .. .. .. .. "}; +#endif diff --git a/bitmaps/hammer.xpm b/bitmaps/hammer.xpm new file mode 100644 index 0000000000..3951d99e92 --- /dev/null +++ b/bitmaps/hammer.xpm @@ -0,0 +1,29 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * hammer_xpm[]; + +#else +char * hammer_xpm[] = { +"16 15 6 1", +" c none", +". c #444244", +"X c #848284", +"o c #542e04", +"O c #c4c2c4", +"+ c #94723c", +" .X ", +" oXX ", +" o.X ", +" o.X ", +" OX o.X ", +" OX+ oo ", +" OX+ ", +" OX+ ", +" OX+ ", +" OX+ ", +" OX+ ", +" OX+ ", +" OX+ ", +" X+ ", +" "}; +#endif diff --git a/bitmaps/help.xpm b/bitmaps/help.xpm new file mode 100644 index 0000000000..fd60b31c7f --- /dev/null +++ b/bitmaps/help.xpm @@ -0,0 +1,130 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *help_xpm[]; + +#else +char * help_xpm[] = { +"16 16 106 2", +" c None", +". c #000000", +"+ c #0C0C0C", +"@ c #272522", +"# c #767371", +"$ c #D8D5D1", +"% c #F2F1ED", +"& c #F2F1EB", +"* c #E7E4DE", +"= c #BAB7B5", +"- c #646361", +"; c #0B0A0A", +"> c #E8A291", +", c #F0D2C7", +"' c #E8E5E1", +") c #E4E3DF", +"! c #ECEBE7", +"~ c #EDEAE6", +"{ c #E38C74", +"] c #A83419", +"^ c #E8B1A5", +"/ c #F0AA97", +"( c #D67D69", +"_ c #C9BBB4", +": c #B4B3AD", +"< c #C0BEB7", +"[ c #E1E0DA", +"} c #E8C9BF", +"| c #E4512F", +"1 c #DF4926", +"2 c #6F2312", +"3 c #010000", +"4 c #1D1D1C", +"5 c #51504E", +"6 c #F1A998", +"7 c #D76348", +"8 c #943019", +"9 c #645551", +"0 c #1F1E1E", +"a c #903F2D", +"b c #EA7B61", +"c c #E86141", +"d c #CC4B2D", +"e c #644E47", +"f c #2E2C2B", +"g c #E6E2E1", +"h c #DEA191", +"i c #BA4429", +"j c #3B3938", +"k c #C4624B", +"l c #ED917C", +"m c #E1B3A6", +"n c #65615C", +"o c #D0CFCB", +"p c #A68E85", +"q c #F4E9E3", +"r c #E2DFDB", +"s c #86837D", +"t c #F3F0EA", +"u c #D4D1CF", +"v c #B1AEA8", +"w c #F3F2EE", +"x c #D8D7D3", +"y c #75736E", +"z c #E7E2DE", +"A c #DDDBD8", +"B c #CBCAC6", +"C c #F0EDEB", +"D c #CAC7C5", +"E c #EAE6E3", +"F c #E3BAAE", +"G c #9B5B4C", +"H c #D39382", +"I c #D9B9B0", +"J c #B6B3AF", +"K c #3C3C3B", +"L c #E38166", +"M c #E97454", +"N c #EE977F", +"O c #C87561", +"P c #D69383", +"Q c #D36E56", +"R c #CC4829", +"S c #935D4E", +"T c #454242", +"U c #A8351B", +"V c #DF5130", +"W c #E96C4A", +"X c #EEA895", +"Y c #F2EEEB", +"Z c #F5F2EE", +"` c #F4E3DD", +" . c #D06B53", +".. c #D44929", +"+. c #912D16", +"@. c #CA5535", +"#. c #DCBCB1", +"$. c #DDDCD6", +"%. c #D4D3CF", +"&. c #C8C7C3", +"*. c #AD7868", +"=. c #080605", +"-. c #84817D", +";. c #7E7C75", +">. c #7E7D77", +",. c #595552", +" . . . . . . . . + . . ", +" . @ . # $ % & * = - ; . ", +" . . > , ' ) ' ! ~ { ] . . ", +" . ^ / ( _ : < [ } | 1 2 3 ", +" 4 5 6 7 8 9 0 . 5 a b c d e f ", +" . g h i j . . k l m n . ", +" . % o p j j q r s . ", +" . t u v . . w x y . ", +" . z A B j j C D y . ", +" . = E F G . . H I J K . ", +" ; 5 L M N O . . . P Q R S T + ", +" . U V W X Y Z ` ...+.+.. . ", +" . . 2 @.#.$.%.&.*.+.+.. . . ", +" . =.. 5 -.;.>.# ,.. . . . ", +" . . . . . . . . . ", +" "}; +#endif diff --git a/bitmaps/icon_3d.xpm b/bitmaps/icon_3d.xpm new file mode 100644 index 0000000000..14a10ecdeb --- /dev/null +++ b/bitmaps/icon_3d.xpm @@ -0,0 +1,45 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * icon_w3d_xpm[]; + +#else +char * icon_w3d_xpm[] = +{ +"32 32 3 1", +"J c #FF0000", +"M c #0000FF", +". c #FFFFFF", +"................................", +"................................", +"................................", +"................................", +"................................", +".....JJJJJ.......JJ.............", +"....JJJJJJJJ....JJJJJ...........", +"...JJJJJJJJJ....JJJJJJJJ........", +"...JJJ...JJJJ...JJJ.JJJJJ.......", +"..........JJJ...JJJ...JJJJJ.....", +"..........JJJ...JJJ.....JJJJ....", +"........JJJJJ...JJJ......JJJJ...", +".....JJJJJJJ....JJJ.......JJJ...", +".....JJJJJJ.....JJJ........JJJ..", +".....JJJJJJJ....JJJ........JJJ..", +"........JJJJJ...JJJ........JJJ..", +".........JJJJ...JJJ........JJJ..", +"..........JJJ...JJJ........JJJ..", +"..........JJJ...JJJ.......JJJJ..", +"..JJJ.....JJJ...JJJ.......JJJ...", +"..JJJ....JJJJ...JJJ.....JJJJJ...", +"..JJJJJJJJJJ....JJJJJJJJJJJJ....", +"...JJJJJJJJ.....JJJJJJJJJJJ.....", +".....JJJJJ.........JJJJJJ.......", +"..........................MMMMMM", +"....................MMMMMMMMMMMM", +"..............MMMMMMMMMMMMMMMMMM", +"........MMMMMMMMMMMMMMMMMMM.....", +"MMMMMMMMMMMMMMMMMMMMM...........", +"MMMMMMMMMMMMMMM.................", +"MMMMMMMMM.......................", +"M..............................." +}; +#endif diff --git a/bitmaps/icon_cvpcb.xpm b/bitmaps/icon_cvpcb.xpm new file mode 100644 index 0000000000..f6af39c9e3 --- /dev/null +++ b/bitmaps/icon_cvpcb.xpm @@ -0,0 +1,412 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * icon_cvpcb_xpm[]; + +#else +char * icon_cvpcb_xpm[] = { +"32 32 372 2", +" c None", +". c #FF7800", +"+ c #632E00", +"@ c #642F00", +"# c #5A2A00", +"$ c #502600", +"% c #482200", +"& c #3F1D00", +"* c #000000", +"= c #421F00", +"- c #371900", +"; c #2C1400", +"> c #210F00", +", c #160A00", +"' c #FFFEFE", +") c #484747", +"! c #D6D5D5", +"~ c #FFF9F5", +"{ c #FFF1E6", +"] c #FFEAD7", +"^ c #FFE2C9", +"/ c #FFDABA", +"( c #FFD2AB", +"_ c #FFCB9D", +": c #FFC38E", +"< c #FFBB7F", +"[ c #FFB370", +"} c #FFAB62", +"| c #FFA453", +"1 c #FF9C45", +"2 c #FF9436", +"3 c #FF8C27", +"4 c #FF8518", +"5 c #FF7D0A", +"6 c #3E2107", +"7 c #7D7C7C", +"8 c #F0EFEF", +"9 c #FFF2E6", +"0 c #FFEAD8", +"a c #FFD3AC", +"b c #FFBB80", +"c c #FFB471", +"d c #FFAC62", +"e c #FF9536", +"f c #FF8D28", +"g c #FF8519", +"h c #FE7800", +"i c #AC611F", +"j c #574C43", +"k c #B0AFAF", +"l c #FCFBFB", +"m c #FFFAF6", +"n c #FFF2E7", +"o c #FFDBBB", +"p c #FFCB9E", +"q c #FFC38F", +"r c #FFBC80", +"s c #FFAC63", +"t c #FFA454", +"u c #FF9537", +"v c #FF7D0B", +"w c #FF8920", +"x c #F59540", +"y c #A27B59", +"z c #827F7E", +"A c #D7D6D6", +"B c #FFEAD9", +"C c #FFE3CA", +"D c #FFD3AD", +"E c #FFC48F", +"F c #FFBC81", +"G c #FFB472", +"H c #FF9D46", +"I c #FF8D29", +"J c #FF851A", +"K c #FF7E0B", +"L c #FF9A41", +"M c #EAB17F", +"N c #A9998C", +"O c #B5B4B4", +"P c #F1ECE9", +"Q c #FFF2E8", +"R c #FFEBD9", +"S c #FFDBBC", +"T c #FFCC9F", +"U c #FFC490", +"V c #FFAD64", +"W c #FFA555", +"X c #FF9538", +"Y c #FF8E29", +"Z c #FF861A", +"` c #FF7E0C", +" . c #8C8B8B", +".. c #FFBD83", +"+. c #FECEA3", +"@. c #E1CBB7", +"#. c #BFBBB6", +"$. c #DFD4CA", +"%. c #FBE7D6", +"&. c #FEE2CA", +"*. c #FED3AC", +"=. c #FDCA9D", +"-. c #FDC28E", +";. c #FDBA80", +">. c #FDB372", +",. c #FEAC63", +"'. c #FF9D47", +"). c #FF861B", +"!. c #F6F5F5", +"~. c #F5933E", +"{. c #C7864C", +"]. c #926C4B", +"^. c #705A48", +"/. c #483F37", +"(. c #232120", +"_. c #0C0C0C", +":. c #040403", +"<. c #030202", +"[. c #594C41", +"}. c #D0AC8D", +"|. c #BC9675", +"1. c #453527", +"2. c #040202", +"3. c #1F160D", +"4. c #4D341E", +"5. c #7F522A", +"6. c #AE6B30", +"7. c #CE792E", +"8. c #ED8327", +"9. c #FB841B", +"0. c #7D3D06", +"a. c #200F00", +"b. c #FD871F", +"c. c #D98337", +"d. c #BB8352", +"e. c #CCA888", +"f. c #D6C3B2", +"g. c #CEC6C0", +"h. c #CBC9C8", +"i. c #DAD9D9", +"j. c #EFEFEF", +"k. c #C0BFBF", +"l. c #444343", +"m. c #695747", +"n. c #695441", +"o. c #343333", +"p. c #999796", +"q. c #CEC5BD", +"r. c #D5BCA7", +"s. c #E3B892", +"t. c #F0B077", +"u. c #F7A358", +"v. c #FC9336", +"w. c #67360A", +"x. c #E57B1C", +"y. c #C17431", +"z. c #CA9363", +"A. c #A78466", +"B. c #5D4B3B", +"C. c #37302A", +"D. c #1A1817", +"E. c #090808", +"F. c #787777", +"G. c #777676", +"H. c #010000", +"I. c #666565", +"J. c #6B6968", +"K. c #1F160E", +"L. c #4E351F", +"M. c #81532C", +"N. c #AD6B30", +"O. c #CD782E", +"P. c #C56D21", +"Q. c #F38A2E", +"R. c #E49A5A", +"S. c #E3AE80", +"T. c #E7C5A8", +"U. c #CBBAAA", +"V. c #66605B", +"W. c #141212", +"X. c #363535", +"Y. c #797878", +"Z. c #9C9B9B", +"`. c #BAB9B9", +" + c #CBCACA", +".+ c #D3D2D2", +"++ c #E7E6E6", +"@+ c #F3F1EF", +"#+ c #CAC0B8", +"$+ c #856B55", +"%+ c #82542C", +"&+ c #B7753C", +"*+ c #DE8A40", +"=+ c #9B5A1F", +"-+ c #E0781C", +";+ c #B66D2E", +">+ c #B68355", +",+ c #937358", +"'+ c #524234", +")+ c #2D2722", +"!+ c #121110", +"~+ c #060505", +"{+ c #676666", +"]+ c #474646", +"^+ c #4C4A49", +"/+ c #20160E", +"(+ c #49311D", +"_+ c #724A27", +":+ c #985E2B", +"<+ c #BF702C", +"[+ c #935319", +"}+ c #F5831E", +"|+ c #CA7933", +"1+ c #AC7A4F", +"2+ c #B6977D", +"3+ c #B8A99C", +"4+ c #AFA9A5", +"5+ c #AAA9A8", +"6+ c #A9A8A8", +"7+ c #919090", +"8+ c #3C3B3B", +"9+ c #4E4D4D", +"0+ c #4E4843", +"a+ c #908E8C", +"b+ c #B0A59B", +"c+ c #BEA38C", +"d+ c #CD9F76", +"e+ c #DC9A5F", +"f+ c #E8934A", +"g+ c #CE782C", +"h+ c #F7841E", +"i+ c #E18739", +"j+ c #AD7442", +"k+ c #71533A", +"l+ c #493B2E", +"m+ c #27221E", +"n+ c #0F0E0D", +"o+ c #040303", +"p+ c #020101", +"q+ c #474443", +"r+ c #9E8A78", +"s+ c #93765D", +"t+ c #3C2E22", +"u+ c #0C0806", +"v+ c #281C12", +"w+ c #563B22", +"x+ c #89592F", +"y+ c #B26E33", +"z+ c #CF7A30", +"A+ c #EC8529", +"B+ c #67370B", +"C+ c #FB861F", +"D+ c #F2923D", +"E+ c #EA9D59", +"F+ c #E3A874", +"G+ c #DBB18C", +"H+ c #D1B7A1", +"I+ c #C7BCB3", +"J+ c #BEBDBD", +"K+ c #B9B8B7", +"L+ c #C7BAB0", +"M+ c #DBBEA4", +"N+ c #DBB798", +"O+ c #CBA381", +"P+ c #C59872", +"Q+ c #CF9A6B", +"R+ c #DE9F67", +"S+ c #EAA05F", +"T+ c #F39F54", +"U+ c #F79A48", +"V+ c #F9943A", +"W+ c #FD8E2C", +"X+ c #7D3E08", +"Y+ c #FE881F", +"Z+ c #FB973F", +"`+ c #F8A75F", +" @ c #F5B57D", +".@ c #F2C49B", +"+@ c #EED1B7", +"@@ c #E8DBD1", +"#@ c #D1CDCA", +"$@ c #D0C1B6", +"%@ c #ECD4BF", +"&@ c #F5D5B9", +"*@ c #F5CDAB", +"=@ c #EDBF97", +"-@ c #E9B488", +";@ c #EDB17C", +">@ c #F2AD70", +",@ c #F7A964", +"'@ c #FBA458", +")@ c #FC9E4A", +"!@ c #FD963C", +"~@ c #FF902E", +"{@ c #FF881F", +"]@ c #FF8010", +"^@ c #FF7902", +"/@ c #E0C9B5", +"(@ c #BAB7B4", +"_@ c #DDD4CD", +":@ c #FBE9DA", +"<@ c #FDE4CE", +"[@ c #FEDDC0", +"}@ c #FED5B1", +"|@ c #FDCCA2", +"1@ c #FDC593", +"2@ c #FDBD84", +"3@ c #FDB577", +"4@ c #FEAE68", +"5@ c #FFA85A", +"6@ c #FFA04C", +"7@ c #FF983D", +"8@ c #FF8111", +"9@ c #E9B07E", +"0@ c #A49487", +"a@ c #B2B1B1", +"b@ c #F1EFEE", +"c@ c #FFF6EE", +"d@ c #FFEEDF", +"e@ c #FFE6D0", +"f@ c #FFDEC2", +"g@ c #FFD7B3", +"h@ c #FFCFA4", +"i@ c #FFC796", +"j@ c #FFBF87", +"k@ c #FFB778", +"l@ c #FFB069", +"m@ c #FFA85B", +"n@ c #FF983E", +"o@ c #FF912F", +"p@ c #FF7903", +"q@ c #9D7654", +"r@ c #7C7978", +"s@ c #D8D7D7", +"t@ c #FFFEFD", +"u@ c #FFE6D1", +"v@ c #FFCFA5", +"w@ c #FFB879", +"x@ c #FFB06A", +"y@ c #FFA04D", +"z@ c #FF8921", +"A@ c #FF8112", +"B@ c #A85D1B", +"C@ c #50453C", +"D@ c #AFAEAE", +"E@ c #FFF6EF", +"F@ c #FFEEE0", +"G@ c #FFDFC2", +"H@ c #FFD7B4", +"I@ c #FFC797", +"J@ c #FFC088", +"K@ c #FFA85C", +"L@ c #FFA14D", +"M@ c #FF993E", +"N@ c #FF9130", +"O@ c #FF8212", +"P@ c #FF7A04", +"Q@ c #3A1C02", +"R@ c #EFEEEE", +"S@ c #FFEFE0", +"T@ c #FFE7D2", +"U@ c #FFDFC3", +"V@ c #FFD0A6", +"W@ c #FFC897", +"X@ c #FFB87A", +"Y@ c #FFB06B", +"Z@ c #FFA95C", +"`@ c #FFA14E", +" # c #FF993F", +".# c #FF8A22", +"+# c #FF8213", +"@# c #070300", +" . . . . . . . . . . ", +" . . . . . . . . . . ", +" . . . . . . ", +" . . . . . . ", +" . . . . . . . . . . ", +" + @ # $ % & * * = - ; > , * * ", +" ' ) ! ' ' ' ' ' ' ~ { ] ^ / ( _ : < [ } | 1 2 3 4 5 . * ", +" ' * 6 7 8 ' ' ' ' ~ 9 0 ^ / a _ : b c d | 1 e f g 5 . * ", +" ' * h i j k l ' ' m n 0 ^ o a p q r c s t 1 u f g v . * ", +" ' * . w x y z A ' m n B C o D p E F G s t H u I J K . * ", +"* * * * * * . w L d M N O P Q R C S D T U F G V W H X Y Z ` . * ", +" .* . w L d ..+.@.#.$.%.&.S *.=.-.;.>.,.W '.X Y ).` . * ", +" !.* . w ~.{.].^./.(._.:.<.[.}.|.1.2.3.4.5.6.7.8.9.0.a.* ", +" ' * . b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.* ", +" ' * . x.y.z.A.B.C.D.E.<.F.G.H.H.I.J.K.L.M.N.O.P.* ", +" ' * . Q.R.S.T.U.V.W.X.Y.Z.`. +.+++@+#+$+%+&+*+=+* ", +" ' * . -+;+>+,+'+)+!+~+<.{+I.H.H.]+^+/+(+_+:+<+[+* ", +" ' * . }+|+1+2+3+4+5+6+6+7+8+9+0+8+a+b+c+d+e+f+g+* ", +" ' * . h+i+j+k+l+m+n+o+p+p+q+r+s+t+u+v+w+x+y+z+A+B+* ", +" ' * . C+D+E+F+G+H+I+J+K+L+M+N+O+P+Q+R+S+T+U+V+W+C+X+a.* ", +" ' * . Y+Z+`+ @.@+@@@#@$@%@&@*@=@-@;@>@,@'@)@!@~@{@]@^@* ", +" ' * . w L d ..+./@(@_@:@<@[@}@|@1@2@3@4@5@6@7@~@w 8@^@* ", +"* * * * * * . w L d 9@0@a@b@c@d@e@f@g@h@i@j@k@l@m@6@n@o@w 8@p@* ", +" .* . w x q@r@s@' t@c@d@u@f@g@v@i@j@w@x@m@y@n@o@z@A@p@* ", +" !.* h B@C@D@l ' ' t@E@F@u@G@H@v@I@J@w@x@K@L@M@N@z@O@P@* ", +" ' * Q@F.R@' ' ' ' ' E@S@T@U@H@V@W@J@X@Y@Z@`@ #N@.#+#P@* ", +" @# + @ # $ % & * * = - ; > , * * ", +" . . . . . . . . . . ", +" . . . . . . ", +" . . . . . . ", +" . . . . . . . . . . ", +" . . . . . . . . . . "}; +#endif diff --git a/bitmaps/icon_eeschema.xpm b/bitmaps/icon_eeschema.xpm new file mode 100644 index 0000000000..71228d4068 --- /dev/null +++ b/bitmaps/icon_eeschema.xpm @@ -0,0 +1,240 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * icon_eeschema_xpm[]; + +#else +char * icon_eeschema_xpm[] = { +"32 32 200 2", +" c None", +". c #000000", +"+ c #AEAEAE", +"@ c #FFFFFF", +"# c #1E1E1E", +"$ c #D2D2D2", +"% c #181818", +"& c #FEFEFE", +"* c #FEFEFF", +"= c #FCFCFF", +"- c #FBFBFF", +"; c #F9F9FF", +"> c #F8F8FF", +", c #F6F6FF", +"' c #F5F5FF", +") c #F3F3FF", +"! c #F1F1FF", +"~ c #F0F0FF", +"{ c #EEEEFF", +"] c #EDEDFF", +"^ c #0F0F10", +"/ c #F0F0F0", +"( c #C7C7C7", +"_ c #080808", +": c #FDFDFF", +"< c #FAFAFF", +"[ c #F2F2FF", +"} c #EFEFFF", +"| c #EBEBFF", +"1 c #A4A4A4", +"2 c #4F4F50", +"3 c #CDCDCF", +"4 c #F7F7FF", +"5 c #F4F4FF", +"6 c #ECECFF", +"7 c #EAEAFF", +"8 c #FAFAFA", +"9 c #717171", +"0 c #0E0E0F", +"a c #341902", +"b c #626264", +"c c #E2E2E8", +"d c #E9E9FF", +"e c #0E0E10", +"f c #F6F6F6", +"g c #E7E7E7", +"h c #D8D8D8", +"i c #404040", +"j c #0E0E0E", +"k c #0D0D0E", +"l c #EE7000", +"m c #9A4800", +"n c #1C130C", +"o c #848489", +"p c #BDBDC6", +"q c #39393C", +"r c #2B2B2E", +"s c #AAAAB6", +"t c #E7E7FF", +"u c #E3E3E3", +"v c #D5D5D5", +"w c #C6C6C6", +"x c #B0B0B0", +"y c #202020", +"z c #F07100", +"A c #FF7800", +"B c #E86D00", +"C c #592A00", +"D c #080809", +"E c #A44D00", +"F c #C65D00", +"G c #222124", +"H c #7D7C86", +"I c #77767F", +"J c #E1E1F7", +"K c #E8E8FF", +"L c #E6E6FF", +"M c #7C7B86", +"N c #030100", +"O c #E0E0F7", +"P c #E5E5FF", +"Q c #B8B8BA", +"R c #B6B6B6", +"S c #181819", +"T c #828289", +"U c #BABAC6", +"V c #38383C", +"W c #2A2A2E", +"X c #A7A7B6", +"Y c #E4E4FF", +"Z c #E2E2FF", +"` c #E0E0FF", +" . c #DFDFFF", +".. c #DDDDFF", +"+. c #DCDCFF", +"@. c #DADAFF", +"#. c #B7B7BA", +"$. c #171719", +"%. c #FDFDFE", +"&. c #110F0F", +"*. c #E8E8EF", +"=. c #5F5F64", +"-. c #DCDCE8", +";. c #100E0F", +">. c #0D0B0C", +",. c #37363E", +"'. c #A09FBB", +"). c #D9D9FF", +"!. c #E7E7EF", +"~. c #4C4C50", +"{. c #C6C6CF", +"]. c #090707", +"^. c #0E0D0E", +"/. c #F27200", +"(. c #984700", +"_. c #231000", +":. c #9998B5", +"<. c #E6E6EF", +"[. c #E3E3FF", +"}. c #E1E1FF", +"|. c #AE5200", +"1. c #2D2C34", +"2. c #D5D5E0", +"3. c #F57300", +"4. c #080505", +"5. c #0C0B0A", +"6. c #E3E3EF", +"7. c #B25400", +"8. c #28272E", +"9. c #E2E2EF", +"0. c #4B4B50", +"a. c #C2C2CF", +"b. c #020000", +"c. c #0E0C0E", +"d. c #F37200", +"e. c #994800", +"f. c #261100", +"g. c #8C8BA9", +"h. c #E1E1EF", +"i. c #5C5C64", +"j. c #D4D4E8", +"k. c #D0D0EF", +"l. c #0F0D0F", +"m. c #33323B", +"n. c #9392B1", +"o. c #D1D1FF", +"p. c #080707", +"q. c #1B120C", +"r. c #7C7C89", +"s. c #B2B2C6", +"t. c #35353C", +"u. c #28282E", +"v. c #A0A0B6", +"w. c #CECEEF", +"x. c #DBDBFF", +"y. c #D8D8FF", +"z. c #D6D6FF", +"A. c #D4D4FF", +"B. c #D3D3FF", +"C. c #D0D0FF", +"D. c #0D0D0F", +"E. c #201F24", +"F. c #767586", +"G. c #C6C6E7", +"H. c #D5D5FF", +"I. c #D2D2FF", +"J. c #CECEFF", +"K. c #757486", +"L. c #6F6E7F", +"M. c #D3D3F7", +"N. c #D7D7FF", +"O. c #CFCFFF", +"P. c #CDCDFF", +"Q. c #B6B6BA", +"R. c #0C0C0E", +"S. c #797989", +"T. c #AFAFC6", +"U. c #34343C", +"V. c #9D9DB6", +"W. c #CCCCFF", +"X. c #595964", +"Y. c #CFCFE8", +"Z. c #CACAFF", +"`. c #161619", +" + c #484850", +".+ c #BABACF", +"++ c #DEDEFF", +"@+ c #0C0B0C", +"#+ c #CBCBFF", +"$+ c #C9C9FF", +"%+ c #C8C8FF", +"&+ c #FCFCFE", +"*+ c #C7C7FF", +"=+ c #C5C5FF", +"-+ c #C6C6FF", +";+ c #C4C4FF", +">+ c #C3C3FF", +",+ c #C1C1FF", +"'+ c #AEAEB1", +")+ c #9494A4", +" . . . . . . . . . . . . . . . . . . . ", +" . + @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ # $ % ", +" . & * * * * * = - ; > , ' ) ! ~ { ] ^ / ( _ ", +" . & * * * * : - < > , ' ) [ ~ } ] | ^ / @ 1 . ", +" . & * * 2 3 - < > 4 ' 5 [ ~ } ] 6 7 ^ / @ 8 9 . ", +" . & * * 0 a b c 4 ' 5 [ ! } ] 6 7 d e / f g h i . ", +" . j . . k l m n o p q r s { 6 | d t e u u v w x y . ", +" . & * = 0 z A B C D E F G H I J K L e . . . . . . . ", +" . & : - 0 z A B C D E F G M N O L P Q R R R R R R S ", +" . & N . k l m n T U V W X 7 N t P Y Z ` ...+.@.#.$. ", +" . %.&.*.0 a =.-.~ } ] 6 7 d N P Y ;.N N >.,.'.).#.$. ", +" . %.&.!.~.{.[ ! } { 6 7 d t ].N N ^.A A /.(._.:.#.$. ", +" . %.&.<.5 ) ! } { 6 | d K L Y [.}.;.A A A A |.1.#.$. ", +" N N N 2.) ! ~ { ] | d K L P [.Z ` ;.A A A A 3.4.N 5. ", +" . %.&.6.[ ~ { ] | 7 K t P [.Z ` .;.A A A A 7.8.#.$. ", +" . %.&.9.0.a.] 6 7 K t P Y Z ].b.N c.A A d.e.f.g.#.$. ", +" . %.&.h.0 a i.j.d t L Y Z }.;.k.+.l.N N >.m.n.o.#.$. ", +" . %.p.. k l m q.r.s.t.u.v. .;.w.x.).y.z.A.B.o.C.#.$. ", +" . %.~ { D.z A B C D E F E.F.].G.).y.z.H.B.I.C.J.#.$. ", +" . %.} ] D.z A B C D E F E.K.L.M.y.N.H.B.I.C.O.P.Q.$. ", +" . j . . R.l m q.S.T.U.u.V.+.@.y.N.H.A.I.o.O.P.W.Q.$. ", +" . %.] 7 D.a X.Y.Z }. ...+.@.).N.z.A.I.o.O.J.W.Z.Q.`. ", +" . %.| d +.+Y Z }. .+++.x.N N N N N N N N N N N N @+ ", +" . %.7 t L Y [.}.` +++.x.).N z.H.B.o.C.J.P.#+$+%+Q.`. ", +" . &+d L P [.}.` ++..x.@.y.N H.B.I.C.J.P.#+Z.%+*+Q.`. ", +" . &+t P [.Z ` ...x.@.y.N.N A.I.C.O.P.W.Z.%+*+=+Q.`. ", +" . &+L Y Z ` ...+.@.).N.H.N N N N N N N N N N N N @+ ", +" . &+P Z }. .+++.@.).N.z.A.N o.O.J.W.#+$+*+-+;+>+Q.`. ", +" . &+Y }. .+++.x.).y.z.A.B.N C.J.W.#+$+%+-+=+>+,+Q.`. ", +" . '+R R R R R R R R R R R N R R R R R R R R R R )+. ", +" . . . . . . . . . . . . . . . . . . . . . . . . . ", +" "}; +#endif diff --git a/bitmaps/icon_gerbview.xpm b/bitmaps/icon_gerbview.xpm new file mode 100644 index 0000000000..be90157bc1 --- /dev/null +++ b/bitmaps/icon_gerbview.xpm @@ -0,0 +1,358 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * icon_gerbview_xpm[]; + +#else +char * icon_gerbview_xpm[] = { +"32 32 318 2", +" c None", +". c #030100", +"+ c #FFFFFF", +"@ c #F4F4F4", +"# c #B1B1B1", +"$ c #7F7F7F", +"% c #4C4C4C", +"& c #191919", +"* c #FEFEFF", +"= c #FDFDFF", +"- c #FCFCFF", +"; c #FAFAFF", +"> c #BBBBC0", +", c #202021", +"' c #373737", +") c #666666", +"! c #919191", +"~ c #BCBCBC", +"{ c #1A1A1C", +"] c #AEAEBC", +"^ c #EAEAFF", +"/ c #E9E9FF", +"( c #E8E8FF", +"_ c #E7E7FF", +": c #E6E6FF", +"< c #E4E4FF", +"[ c #E3E3FF", +"} c #E2E2FF", +"| c #E1E1FF", +"1 c #DFDFFF", +"2 c #86869B", +"3 c #FCF9FA", +"4 c #F1C097", +"5 c #6D3E16", +"6 c #151515", +"7 c #949494", +"8 c #D1D1D1", +"9 c #BB8A5E", +"0 c #261C13", +"a c #5A5A63", +"b c #DEDEF5", +"c c #DEDEFF", +"d c #FBC89E", +"e c #452000", +"f c #484848", +"g c #C3C3C3", +"h c #D1CFCD", +"i c #EC9A51", +"j c #FF7800", +"k c #F88015", +"l c #705238", +"m c #303035", +"n c #E2E2FB", +"o c #DDDDFF", +"p c #85859B", +"q c #96571E", +"r c #2C2C2C", +"s c #CFCFCF", +"t c #E3AE7F", +"u c #FC7D0C", +"v c #4C3725", +"w c #6B3505", +"x c #FD7E0F", +"y c #DCDCFF", +"z c #84849B", +"A c #D9D9DF", +"B c #412106", +"C c #FE7800", +"D c #FE7902", +"E c #FE7903", +"F c #FE7A04", +"G c #FD7904", +"H c #FD7A06", +"I c #FD7B07", +"J c #FD7B08", +"K c #FD7C09", +"L c #EA9F5D", +"M c #D5C7BB", +"N c #CF9969", +"O c #130B06", +"P c #BC5800", +"Q c #DADAFF", +"R c #83839B", +"S c #525255", +"T c #C7742B", +"U c #FF7700", +"V c #A97241", +"W c #2F2F35", +"X c #D3D3F2", +"Y c #DBDBFF", +"Z c #D9D9FF", +"` c #241C16", +" . c #FC7B08", +".. c #F58018", +"+. c #0C0C0E", +"@. c #A3A3BC", +"#. c #D8D8FF", +"$. c #82829B", +"%. c #E5E5E5", +"&. c #131313", +"*. c #E6A66D", +"=. c #2B1D10", +"-. c #85695A", +";. c #F78C34", +">. c #E7B49E", +",. c #D8D5FA", +"'. c #D7D7FF", +"). c #B2B2B2", +"!. c #3D3D3D", +"~. c #F38D32", +"{. c #754E2B", +"]. c #6C3200", +"^. c #F57300", +"/. c #E6B39E", +"(. c #D6D6FF", +"_. c #80809B", +":. c #8C8C8C", +"<. c #5D5D5D", +"[. c #F58828", +"}. c #FC7B09", +"|. c #F58929", +"1. c #E4AA77", +"2. c #5E5C5B", +"3. c #552700", +"4. c #C8A6A1", +"5. c #E3BDB7", +"6. c #F68B34", +"7. c #D4D4FF", +"8. c #D9C1AC", +"9. c #F09340", +"0. c #FA8014", +"a. c #BA9B96", +"b. c #E2BCB7", +"c. c #D3D3FF", +"d. c #7F7F9B", +"e. c #DEB692", +"f. c #8B4000", +"g. c #E16900", +"h. c #E3B09E", +"i. c #D2D2FF", +"j. c #151517", +"k. c #BABABA", +"l. c #D3CBC3", +"m. c #FA7F12", +"n. c #0B0B0C", +"o. c #56433C", +"p. c #EB8430", +"q. c #D2CFFA", +"r. c #D1D1FF", +"s. c #7E7E9B", +"t. c #4F4F55", +"u. c #6F6F6F", +"v. c #DEB591", +"w. c #DABEA6", +"x. c #FB7E0F", +"y. c #FD7A05", +"z. c #FE7801", +"A. c #CE7525", +"B. c #212124", +"C. c #343434", +"D. c #34343E", +"E. c #B0B0D5", +"F. c #D0D0FF", +"G. c #7D7D9B", +"H. c #CFCFDF", +"I. c #0E0C0B", +"J. c #D39660", +"K. c #EC9A52", +"L. c #F1913D", +"M. c #F87C0E", +"N. c #191008", +"O. c #919192", +"P. c #FDFDFD", +"Q. c #939393", +"R. c #141414", +"S. c #65657B", +"T. c #C8C8F6", +"U. c #CECEFF", +"V. c #7C7C9B", +"W. c #ECECFF", +"X. c #8D501D", +"Y. c #FA8115", +"Z. c #71441C", +"`. c #322B2A", +" + c #F4F4FF", +".+ c #E7E7E7", +"++ c #595959", +"@+ c #231203", +"#+ c #9494B8", +"$+ c #EBEBFF", +"%+ c #FA8F34", +"&+ c #3A1B00", +"*+ c #5C4D3F", +"=+ c #F48522", +"-+ c #F8851F", +";+ c #190C00", +">+ c #8A8AB6", +",+ c #CFCFFF", +"'+ c #F8F8FF", +")+ c #262626", +"!+ c #2B2B36", +"~+ c #020100", +"{+ c #F0BD9E", +"]+ c #4E2400", +"^+ c #211A13", +"/+ c #D4823A", +"(+ c #F98117", +"_+ c #DBBDA2", +":+ c #383842", +"<+ c #23232A", +"[+ c #3E3E4F", +"}+ c #A5A5E1", +"|+ c #C6C6FF", +"1+ c #EFEFFF", +"2+ c #F8F8F8", +"3+ c #808080", +"4+ c #080707", +"5+ c #020101", +"6+ c #E7E4FA", +"7+ c #EFBC9E", +"8+ c #F58B33", +"9+ c #91521E", +"0+ c #120E0C", +"a+ c #3C3835", +"b+ c #976C45", +"c+ c #CE8340", +"d+ c #C0B6AD", +"e+ c #101014", +"f+ c #616174", +"g+ c #81819B", +"h+ c #A1A1C3", +"i+ c #76768F", +"j+ c #141418", +"k+ c #6A6A89", +"l+ c #BABAFB", +"m+ c #CBCBFF", +"n+ c #DADADA", +"o+ c #464646", +"p+ c #020202", +"q+ c #E5E5FF", +"r+ c #C1C1DC", +"s+ c #666674", +"t+ c #42424D", +"u+ c #27272E", +"v+ c #0D0D0F", +"w+ c #41414D", +"x+ c #5A5A6B", +"y+ c #7C7C94", +"z+ c #8C8CA8", +"A+ c #BEBEE6", +"B+ c #BAB7DF", +"C+ c #4A3934", +"D+ c #25252D", +"E+ c #9292C3", +"F+ c #C2C2FF", +"G+ c #F9F9FF", +"H+ c #A7A7A7", +"I+ c #E0E0FF", +"J+ c #DADAFB", +"K+ c #C2C2E0", +"L+ c #B0B0CD", +"M+ c #9E9EB9", +"N+ c #8C8CA5", +"O+ c #8B8BA5", +"P+ c #9B9BB9", +"Q+ c #ACACCD", +"R+ c #BBBBE0", +"S+ c #CFCFFB", +"T+ c #E0AD9E", +"U+ c #B45500", +"V+ c #211001", +"W+ c #4E4E63", +"X+ c #ACACEC", +"Y+ c #C7C7FF", +"Z+ c #F0F0FF", +"`+ c #FC7D0F", +" @ c #D9B3B7", +".@ c #CFABAF", +"+@ c #773801", +"@@ c #141314", +"#@ c #78789D", +"$@ c #BDBDFE", +"%@ c #FC7C0D", +"&@ c #D8B2B7", +"*@ c #D7B1B7", +"=@ c #C8702B", +"-@ c #2E2E3B", +";@ c #31313D", +">@ c #9D9DD3", +",@ c #D5D5FF", +"'@ c #CDCDFF", +")@ c #CCCCFF", +"!@ c #DEAB9E", +"~@ c #DBA89E", +"{@ c #C2C2FE", +"]@ c #47475D", +"^@ c #050404", +"/@ c #5D5D77", +"(@ c #B2B2F4", +"_@ c #CBC8FA", +":@ c #DCA99E", +"<@ c #F38834", +"[@ c #C4C1FA", +"}@ c #75759B", +"|@ c #1A1A1F", +"1@ c #CACAFF", +"2@ c #C8C8FF", +"3@ c #C5C5FF", +"4@ c #C3C3FF", +"5@ c #C1C1FF", +"6@ c #74749B", +"7@ c #7B7B9B", +"8@ c #7A7A9B", +"9@ c #79799B", +"0@ c #78789B", +"a@ c #77779B", +"b@ c #76769B", +"c@ c #030000", +". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", +". + + + + + + @ # $ % & & % $ # @ + + + + + + + + + + + + . ", +". + * = - ; > , ' ) ! ~ ~ ! ) ' { ] ^ / ( _ : < [ } | 1 2 . ", +". + = 3 4 5 6 7 8 8 8 8 8 8 8 8 9 0 a b _ : < [ } | 1 c 2 . ", +". + - d e f g 8 8 8 8 8 8 8 h i j k l m n < [ } | 1 c o p . ", +". + ; q r s 8 8 8 8 8 8 8 8 t j j j u v w x x x x x x y z . ", +". + A B j C D E F G H I J K E j j L M N O P j j j j j Q R . ", +". + S T j j j j j j j j j j U j j M 8 M V W X c o y Y Z R . ", +". + ` .j j j j j j j j j j U j j L M L ..+.@.o y Y Z #.$.. ", +". %.&.8 8 8 8 8 8 8 8 8 8 8 *.j j j j j j =.-.;.;.>.,.'.$.. ", +". ).!.8 8 8 8 8 8 8 8 8 8 8 h ~.j j j j j {.].^.j j /.(._.. ", +". :.<.8 8 8 8 8 8 8 8 8 8 8 8 h *.[.}.|.1.2.3.4.5.j 6.7._.. ", +". ).!.8 8 8 8.9.0.0.9.8.8 8 8 8 8 8 8 8 8 !.].a.b.j 6.c.d.. ", +". %.&.8 8 e.G j j j j G e.8 8 8 8 8 8 8 8 &.f.g.j j h.i.d.. ", +". + j.k.l.m.j j j j j j m.l.8 8 8 8 8 8 k.n.o.p.6.h.q.r.s.. ", +". + t.u.v.j j 0.w.w.x.j j H J H y.F D z.A.B.C.D.E.i.r.F.G.. ", +". + H.I.J.j j K.8 8 L.j j U j j j j j M.N.O.P.Q.R.S.T.U.V.. ", +". + W.X.v Y.j 0.w.w.x.j j j j j j j j Z.`.n ++ .+++@+#+V.. ", +". + $+%+&+*+=+j j j j j -+8 8 8 8 g f ;+>+,+o $+'++ k.)+!+~+ ", +". + / {+^.]+^+/+u j j (+_+8 8 8 7 6 :+<+[+}+|+7.} 1+= 2+3+4+5+ ", +". + ( 6+7+8+9+0+a+b+c+d+~ ! ) ' e+f+g+h+i+j+k+l+m+Z : ++ n+o+p+", +". + _ : q+[ } r+s+t+u+v+v+u+w+x+y+z+A+i.r.B+C+D+E+F+F.o $+G++ H+", +". + : q+[ } | I+J+K+L+M+N+O+P+Q+R+S+i.r.F.T+j U+V+W+X+Y+7.} Z+* ", +". + q+x x x x x x `+`+`+`+`+`+`+`+`+`+`+`+`+j @.@+@@@#@$@m+Z _ ", +". + [ j j j j j j j j j j j j j j j j j j %@j &@*@j =@-@;@>@F+F.", +". + } | I+c o y Y Q #.'.(.,@c.i.r.F.U.'@)@!@j j j j ~@{@]@^@/@(@", +". + | I+c o y Y Q #.'.(.,@c.i.r.F.U.'@)@m+_@:@<@<@~@[@F+}@~+5+|@", +". + I+c o y Y Q #.'.(.,@c.i.r.F.U.'@)@m+1@2@Y+|+3@4@F+5@6@. ", +". + 2 2 p p z R $.$.g+_.d.d.s.G.V.V.7@8@9@0@0@a@b@}@}@6@6@. ", +". . . . . . . . . . . . . . . . . . . . . . . . . . . . . c@ ", +" ", +" "}; +#endif diff --git a/bitmaps/icon_kicad.xpm b/bitmaps/icon_kicad.xpm new file mode 100644 index 0000000000..de53859b17 --- /dev/null +++ b/bitmaps/icon_kicad.xpm @@ -0,0 +1,58 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char *kicad_icon_xpm[]; + +#else +char * kicad_icon_xpm[] = +{ +"32 32 16 1", +" c none", +". c #281b11", +"X c #716e86", +"o c #eed4bc", +"O c #c4b4a6", +"+ c #99939d", +"@ c #6e5f55", +"# c #454245", +"$ c #c3966e", +"% c #603c21", +"& c #6c4f33", +"* c #f9b577", +"= c #fa9638", +"- c #e47816", +"; c #7977c5", +": c #a8a7f5", +" .X oooO XoOO+@#$@$@% ", +" &&o ooo +***O##$*==# ", +" &=@Oooo $o**O@#$===& ", +" &==$+oO +o***##$===# ", +" +$&====+OX+OoOO@#$$O=#... ", +" o @===*=$ooO OOoo$O $$OO# ", +".%%&@&=====$+X#X@@ $$O-O @ ", +"%----&====*-@;:::;X+$===O # ", +"...X$@===&@;:::::::;@@==O @ ", +" o @=&X::::::::::::;@@O # ", +" : #X::::::::::::::;;#o @ ", +" o@:::::::::::::::;;;# # ", +" :#::;XXX:::::::;X;;;XO @ ", +" o#;;XX;;:::::+;;;;;;X@oO# ", +" :X;;;;;::::;;;;;;;+OXOooOXXX+", +" o@;;;;;;::;;;;;;;XOO@oo o ooo", +" :X;;;;;;:;;;;;+oOX;+@o ooo ", +" o+;;;;;;;+;;++X+OX@@@Oo O+OO+", +" oo#.;;;;;+;o++X++#+@X OO@ ", +" o @=&X;;;;X+O+##@OoX@ # ", +" o $==-#;;XXXO%$@@ @X # ", +" o @====#XXX#X@O@@O$&@O @ ", +"..%@$&=====&#@=X&$X@$===O # ", +"%----&===*=*=*$X@*O+$*==O @ ", +".%%&$&=====**$$X&O $===O # ", +" o @====*=$O*@O* $$O=O @ ", +" +O@====$$XOO o*XX$Oo$&##. ", +" &====XO +ooOO##$$O=# ", +" &==@Ooo $o***@#$*==& ", +" &=@oooo +o**O##$===& ", +" && oooO +***O@&$===& ", +" .Xo ooO XoOO$##X$@@& " +}; +#endif diff --git a/bitmaps/icon_modedit.xpm b/bitmaps/icon_modedit.xpm new file mode 100644 index 0000000000..e99177a135 --- /dev/null +++ b/bitmaps/icon_modedit.xpm @@ -0,0 +1,386 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *icon_modedit_xpm[]; + +#else +char * icon_modedit_xpm[] = { +"32 32 346 2", +" c None", +". c #2C2C37", +"+ c #383846", +"@ c #4D4D5E", +"# c #686878", +"$ c #6C6C77", +"% c #535358", +"& c #434344", +"* c #1F1F1F", +"= c #121213", +"- c #4C4C5A", +"; c #9C9CC3", +"> c #BEBEFF", +", c #BDBDFD", +"' c #8888A5", +") c #C5C5EE", +"! c #DDDDFF", +"~ c #E7E7FF", +"{ c #F2F2FF", +"] c #8A8A8B", +"^ c #3D3D40", +"/ c #BFBFD4", +"( c #DADAFF", +"_ c #D0D0FF", +": c #B3B3E6", +"< c #848495", +"[ c #AB9D93", +"} c #805431", +"| c #856353", +"1 c #DEDEFD", +"2 c #EAEAFF", +"3 c #F2F2FD", +"4 c #4E4E4E", +"5 c #2E2E2E", +"6 c #D8D8DE", +"7 c #ECECFF", +"8 c #E2E2FF", +"9 c #D8D8FF", +"0 c #828291", +"a c #7C5432", +"b c #AF5C11", +"c c #6E4725", +"d c #B0570A", +"e c #928793", +"f c #D8D8DF", +"g c #2B2B2B", +"h c #151517", +"i c #30303A", +"j c #393942", +"k c #303035", +"l c #161617", +"m c #616161", +"n c #FEFEFF", +"o c #F4F4FF", +"p c #BDBDD7", +"q c #CDCDCE", +"r c #BEB0A4", +"s c #A06736", +"t c #A3876D", +"u c #B7B4B4", +"v c #9D9DBB", +"w c #DBDBFF", +"x c #E5E5FF", +"y c #EFEFFF", +"z c #A0A0A4", +"A c #1C1C21", +"B c #4D4D61", +"C c #8484AA", +"D c #A9A9E0", +"E c #C6C6FE", +"F c #CCCCFB", +"G c #C3C3DD", +"H c #97979C", +"I c #FEFEFE", +"J c #FCFCFF", +"K c #B0B0C1", +"L c #EEEEEE", +"M c #FFFFFF", +"N c #F0F0F0", +"O c #B4B4BB", +"P c #B4B4D8", +"Q c #F1F1FF", +"R c #5E5E5F", +"S c #3A3A42", +"T c #B3B3D6", +"U c #CBCBFF", +"V c #A9A9DD", +"W c #8383A2", +"X c #9696A3", +"Y c #7E7E8D", +"Z c #A198B0", +"` c #896A5D", +" . c #D1CFE8", +".. c #BEBEC1", +"+. c #F9F9FF", +"@. c #C6C6D3", +"#. c #877362", +"$. c #906239", +"%. c #A55E20", +"&. c #D5CEC7", +"*. c #9797A2", +"=. c #AFADCE", +"-. c #DFDFFE", +";. c #E0E0EB", +">. c #333333", +",. c #73737D", +"'. c #D2D2EE", +"). c #9898AE", +"!. c #676770", +"~. c #757578", +"{. c #DBDBDB", +"]. c #B5A597", +"^. c #A36731", +"/. c #724C2A", +"(. c #D86906", +"_. c #7F5A42", +":. c #C4C4D9", +"<. c #DCDCDD", +"[. c #7C6350", +"}. c #E56C00", +"|. c #593E25", +"1. c #A95E1B", +"2. c #9C8570", +"3. c #F1F1F1", +"4. c #B09B88", +"5. c #8E643D", +"6. c #B45908", +"7. c #917975", +"8. c #B4B4BA", +"9. c #58585A", +"0. c #A2A2AB", +"a. c #A3A3A7", +"b. c #E8E8E8", +"c. c #F5F5F5", +"d. c #E5E5E5", +"e. c #DFDBD7", +"f. c #A15D20", +"g. c #855124", +"h. c #785846", +"i. c #A19CB4", +"j. c #A0949E", +"k. c #B1B1BC", +"l. c #F4F4F4", +"m. c #F3F3F3", +"n. c #8D6A4F", +"o. c #6E5A4D", +"p. c #B5A79A", +"q. c #D4690A", +"r. c #8F592B", +"s. c #955821", +"t. c #6E4D39", +"u. c #D6D6FB", +"v. c #E4E4FF", +"w. c #EEEEFF", +"x. c #707072", +"y. c #242424", +"z. c #DCDCDC", +"A. c #B6AEAE", +"B. c #79563A", +"C. c #9B734E", +"D. c #FDFDFD", +"E. c #E2E1E0", +"F. c #BCAEA3", +"G. c #8E623C", +"H. c #7B4E29", +"I. c #D76807", +"J. c #9F8C8B", +"K. c #B3B3B7", +"L. c #F1F1FE", +"M. c #A7A7B5", +"N. c #9E9EA9", +"O. c #AFAFB4", +"P. c #927B68", +"Q. c #957F6E", +"R. c #9B9BA3", +"S. c #777786", +"T. c #C6C6F1", +"U. c #E7E7F5", +"V. c #3E3E3F", +"W. c #3F3F3F", +"X. c #D9D7D6", +"Y. c #98571F", +"Z. c #AD611D", +"`. c #895426", +" + c #936135", +".+ c #D5D1CE", +"++ c #AB9582", +"@+ c #DD6B05", +"#+ c #7D4E27", +"$+ c #915F3F", +"%+ c #A19097", +"&+ c #BEBED3", +"*+ c #FAFAFF", +"=+ c #F0F0FF", +"-+ c #D0D0F3", +";+ c #B8B8E1", +">+ c #A6A6D5", +",+ c #B6B6F6", +"'+ c #C1C1FF", +")+ c #C8C8FC", +"!+ c #ABABCE", +"~+ c #B8B8D0", +"{+ c #D3D3E8", +"]+ c #C4C4CD", +"^+ c #1C1C1C", +"/+ c #7E7E7E", +"(+ c #C1B3A6", +"_+ c #9D7B60", +":+ c #888282", +"<+ c #927C68", +"[+ c #A36E3E", +"}+ c #B6A596", +"|+ c #A9998B", +"1+ c #BBB6AF", +"2+ c #71543F", +"3+ c #88542B", +"4+ c #9A5B28", +"5+ c #A5A2AB", +"6+ c #F7F7FF", +"7+ c #EDEDFF", +"8+ c #E3E3FF", +"9+ c #D9D9FF", +"0+ c #9897BC", +"a+ c #6A6A7F", +"b+ c #656475", +"c+ c #59586A", +"d+ c #555468", +"e+ c #535367", +"f+ c #5E5D6E", +"g+ c #646372", +"h+ c #2C2C32", +"i+ c #202020", +"j+ c #CFCFCF", +"k+ c #BBB3AD", +"l+ c #A15716", +"m+ c #754922", +"n+ c #A35919", +"o+ c #81532A", +"p+ c #ECECEC", +"q+ c #825D3C", +"r+ c #D66909", +"s+ c #764F2D", +"t+ c #9E602F", +"u+ c #9C8C90", +"v+ c #ABABB1", +"w+ c #F5F5FF", +"x+ c #CFCFE2", +"y+ c #727180", +"z+ c #58576D", +"A+ c #5B5A71", +"B+ c #1D1D22", +"C+ c #4A4A4A", +"D+ c #FCFCFC", +"E+ c #95755A", +"F+ c #A5734B", +"G+ c #736358", +"H+ c #B3A89F", +"I+ c #9D7B5C", +"J+ c #E9E7E5", +"K+ c #E5E3E1", +"L+ c #9C7A5C", +"M+ c #A89D94", +"N+ c #9696AE", +"O+ c #DFDFFA", +"P+ c #BCBCBD", +"Q+ c #EAEAED", +"R+ c #5D5C6C", +"S+ c #5A5970", +"T+ c #484757", +"U+ c #282830", +"V+ c #27272E", +"W+ c #26262D", +"X+ c #25242B", +"Y+ c #232329", +"Z+ c #8D8D8D", +"`+ c #AF9F94", +" @ c #9F612C", +".@ c #7A512D", +"+@ c #D56908", +"@@ c #855F3D", +"#@ c #E8E8E9", +"$@ c #9A9AA4", +"%@ c #86869C", +"&@ c #D5D5FF", +"*@ c #DEDEFF", +"=@ c #BFBFD2", +"-@ c #DADADB", +";@ c #85848C", +">@ c #41404F", +",@ c #272727", +"'@ c #E5E1DE", +")@ c #A86327", +"!@ c #8A5426", +"~@ c #806249", +"{@ c #D5D1CD", +"]@ c #B4B4B9", +"^@ c #9090A3", +"/@ c #8D8DB7", +"(@ c #B4B4F2", +"_@ c #80809D", +":@ c #767689", +"<@ c #777687", +"[@ c #7F7F8E", +"}@ c #85858C", +"|@ c #6B6A77", +"1@ c #4D4C5E", +"2@ c #111113", +"3@ c #555555", +"4@ c #E6E5E7", +"5@ c #F1F1FB", +"6@ c #BBBBC9", +"7@ c #9999A0", +"8@ c #9898AA", +"9@ c #C2C2EB", +"0@ c #8686A3", +"a@ c #6C6B7F", +"b@ c #58586A", +"c@ c #58576C", +"d@ c #5B5A6E", +"e@ c #2A2A33", +"f@ c #9D9D9D", +"g@ c #FBFBFF", +"h@ c #B8B8CF", +"i@ c #6C6C7B", +"j@ c #59586E", +"k@ c #3D3C4B", +"l@ c #1A1A1E", +"m@ c #2F2F2F", +"n@ c #F5F5FC", +"o@ c #868690", +"p@ c #5D5D6F", +"q@ c #424150", +"r@ c #1D1D21", +"s@ c #1F1F24", +"t@ c #25252D", +"u@ c #212026", +"v@ c #5F5F5F", +"w@ c #75757C", +"x@ c #403F4E", +"y@ c #17161A", +"z@ c #3E3D44", +"A@ c #59586F", +"B@ c #2B2B35", +"C@ c #24232B", +"D@ c #434250", +"E@ c #1F1F25", +" ", +" ", +" ", +" ", +" ", +" . + @ # $ % & * ", +" = - ; > , ' ) ! ~ { ] ", +" ^ / ( _ : < [ } | 1 2 3 4 ", +" 5 6 7 8 9 0 a b c d e 8 7 f g ", +" h i j k l m n o 2 p q r s t u v w x y z ", +" A B C D E F 9 G H I J { K L M N M M O P ! ~ Q R ", +" S T U V W X Y Z ` ...M +.@.#.$.%.&.M M *.=.-.2 ;.>. ", +" ,.'.).!.~.{.].^./.(._.:.<.M [.}.|.1.2.3.4.5.6.7.8 7 8. ", +" 9.0.a.b.c.d.M e.f.g.h.i.j.k.l.m.n.o.<.M p.q.r.s.t.u.v.w.x. ", +"y.z.A.B.%.C.D.M M E.F.G.H.I.J.K.M J L.M.N.O.P.Q.R.S.T.! ~ U.V. ", +"W.X.Y.Z.`. +.+M M M ++@+#+$+%+&+q M *+=+x -+;+>+,+'+)+!+~+{+]+^+", +" /+(+_+:+<+[+}+M M M |+1+2+3+4+5+b.M 6+7+8+9+0+a+b+c+d+e+f+g+h+", +" i+j+k+l+m+n+o+p+M M M q+r+s+t+u+v+D.M w+x+y+z+A+A+A+A+A+A+A+B+", +" C+D+E+F+G+H+I+J+M M K+L+M+N+w O+P+M Q+R+A+A+S+T+U+V+W+X+Y+ ", +" Z+M `+ @.@+@@@M M M #@$@%@&@*@=@-@;@A+A+>@B+ ", +" ,@{.'@)@!@~@{@D+]@^@/@(@_@:@<@[@}@|@A+1@2@ ", +" 3@M 4@5@6@7@8@9@0@a@b@A+A+A+A+c@d@A+e@ ", +" f@M g@{ 2 h@i@j@A+A+A+A+A+A+A+S+k@l@ ", +" m@d.M n@o@p@A+A+z+q@U+r@s@t@>@u@ ", +" v@D.w@j@A+A+x@y@ ", +" z@A@A+z+B@ ", +" C@D@E@ ", +" ", +" ", +" ", +" ", +" "}; +#endif diff --git a/bitmaps/icon_pcbnew.xpm b/bitmaps/icon_pcbnew.xpm new file mode 100644 index 0000000000..f4d8db55e8 --- /dev/null +++ b/bitmaps/icon_pcbnew.xpm @@ -0,0 +1,176 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *a_icon_pcbnew_xpm[]; + +#else +char * a_icon_pcbnew_xpm[] = { +"32 32 136 2", +" c None", +". c #040200", +"+ c #030100", +"@ c #FFFFFF", +"# c #FEFEFF", +"$ c #FDFDFF", +"% c #FCFCFF", +"& c #FAFAFF", +"* c #F9F9FF", +"= c #F8F8FF", +"- c #F7F7FF", +"; c #F5F5FF", +"> c #F4F4FF", +", c #F3F3FF", +"' c #F2F2FF", +") c #F1F1FF", +"! c #EFEFFF", +"~ c #EEEEFF", +"{ c #EDEDFF", +"] c #ECECFF", +"^ c #EAEAFF", +"/ c #E9E9FF", +"( c #E8E8FF", +"_ c #E7E7FF", +": c #E6E6FF", +"< c #E4E4FF", +"[ c #E3E3FF", +"} c #E2E2FF", +"| c #E1E1FF", +"1 c #DFDFFF", +"2 c #86869B", +"3 c #FCF9FA", +"4 c #FBC89E", +"5 c #FD9234", +"6 c #FAC79E", +"7 c #F5F2FA", +"8 c #DEDEFF", +"9 c #FF7800", +"0 c #F8C59E", +"a c #DDDDFF", +"b c #85859B", +"c c #F9D3B7", +"d c #F8D2B7", +"e c #FE7F0F", +"f c #FD7E0F", +"g c #DCDCFF", +"h c #84849B", +"i c #F7D1B7", +"j c #FE7E0D", +"k c #DADAFF", +"l c #83839B", +"m c #F6C39E", +"n c #DBDBFF", +"o c #D9D9FF", +"p c #F6F3FA", +"q c #FC9134", +"r c #EFECFA", +"s c #D8D8FF", +"t c #82829B", +"u c #F6F6FF", +"v c #EBEBFF", +"w c #DEDBFA", +"x c #E9B69E", +"y c #F78C34", +"z c #E7B49E", +"A c #D8D5FA", +"B c #D7D7FF", +"C c #E6B39E", +"D c #D6D6FF", +"E c #80809B", +"F c #FC7D0F", +"G c #E3BDB7", +"H c #F68B34", +"I c #D4D4FF", +"J c #FD7D0D", +"K c #E2BCB7", +"L c #D3D3FF", +"M c #7F7F9B", +"N c #E3B09E", +"O c #D2D2FF", +"P c #E0E0FF", +"Q c #D2CFFA", +"R c #D1D1FF", +"S c #7E7E9B", +"T c #EDEAFA", +"U c #F3C09E", +"V c #FA8F34", +"W c #F0BD9E", +"X c #E7E4FA", +"Y c #D0D0FF", +"Z c #7D7D9B", +"` c #EFBC9E", +" . c #CECEFF", +".. c #7C7C9B", +"+. c #EEC8B7", +"@. c #EDC7B7", +"#. c #CDCDFF", +"$. c #CCCCFF", +"%. c #7B7B9B", +"&. c #EDBA9E", +"*. c #D5D5FF", +"=. c #CBCBFF", +"-. c #7A7A9B", +";. c #F98E34", +">. c #E1DEFA", +",. c #C9C9FF", +"'. c #79799B", +"). c #E5E5FF", +"!. c #D0CDFA", +"~. c #E0AD9E", +"{. c #F48934", +"]. c #DEAB9E", +"^. c #CAC7FA", +"/. c #C8C8FF", +"(. c #78789B", +"_. c #DCA99E", +":. c #C7C7FF", +"<. c #D9B3B7", +"[. c #D8B2B7", +"}. c #F38834", +"|. c #C6C6FF", +"1. c #77779B", +"2. c #FC7C0D", +"3. c #D7B1B7", +"4. c #C5C5FF", +"5. c #76769B", +"6. c #DBA89E", +"7. c #C3C3FF", +"8. c #75759B", +"9. c #CBC8FA", +"0. c #C4C1FA", +"a. c #C2C2FF", +"b. c #CACAFF", +"c. c #C1C1FF", +"d. c #74749B", +"e. c #81819B", +" ", +" . + + + + + + + + + + + + + + + + + + + + + + + + + + + + . ", +" + @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ + ", +" + @ # $ % & * = - ; > , ' ) ! ~ { ] ^ / ( _ : < [ } | 1 2 + ", +" + @ $ 3 4 5 5 6 7 > , ' ) ! ~ { ] ^ / ( _ : < [ } | 1 8 2 + ", +" + @ % 4 9 9 9 9 0 , ' ) ! ~ { ] ^ / ( _ : < [ } | 1 8 a b + ", +" + @ & 5 9 c d 9 e e e e e f f f f f f f f f f f f f f g h + ", +" + @ * 5 9 d i 9 j 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 k l + ", +" + @ = 6 9 9 9 9 m ! ~ { ] ^ / ( _ : < [ } | 1 8 a g n o l + ", +" + @ - p 0 q q m r ~ { ] ^ / ( _ : < [ } | 1 8 a g n o s t + ", +" + @ u > , ' ) ! ~ { ] v / ( _ : < [ } | 1 w x y y z A B t + ", +" + @ > , ' ) ! ~ { ] v / ( _ : < [ } | 1 8 x 9 9 9 9 C D E + ", +" + @ , e e e e f f f f f f f f f f f f f f F 9 G G 9 H I E + ", +" + @ ' 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 J 9 G K 9 H L M + ", +" + @ ) ! ~ { ] v / ( _ : < [ } | 1 8 a g n z 9 9 9 9 N O M + ", +" + @ ! ~ { ] v / ( _ : < [ } | P 8 a g n o A C H H N Q R S + ", +" + @ ~ T U V V W X : < [ } | P 8 a g n o s B D I L O R Y Z + ", +" + @ { U 9 9 9 9 ` < [ } | P 8 a g n o s B D I L O R Y ...+ ", +" + @ ] V 9 +.@.9 f f f f f f f F F F F F F F F F F F F #...+ ", +" + @ v V 9 @.@.9 J 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 $.%.+ ", +" + @ / W 9 9 9 9 &.| P 8 a g n o s B D *.L O R Y .#.$.=.-.+ ", +" + @ ( X ` ;.;.&.>.P 8 a g n o s B D *.L O R Y .#.$.=.,.'.+ ", +" + @ _ : ).[ } | P 8 a g n o s B D *.L O R !.~.{.{.].^./.(.+ ", +" + @ : ).[ } | P 8 a g n o s B D *.L O R Y ~.9 9 9 9 _.:.(.+ ", +" + @ ).f f f f f f F F F F F F F F F F F F F 9 <.[.9 }.|.1.+ ", +" + @ [ 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 2.9 [.3.9 }.4.5.+ ", +" + @ } | P 8 a g n k s B D *.L O R Y .#.$.].9 9 9 9 6.7.8.+ ", +" + @ | P 8 a g n k s B D *.L O R Y .#.$.=.9._.}.}.6.0.a.8.+ ", +" + @ P 8 a g n k s B D *.L O R Y .#.$.=.b./.:.|.4.7.a.c.d.+ ", +" + @ 2 2 b b h l t t e.E M M S Z ....%.-.'.(.(.1.5.8.8.d.d.+ ", +" . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ", +" "}; +#endif diff --git a/bitmaps/import.xpm b/bitmaps/import.xpm new file mode 100644 index 0000000000..9da35b9505 --- /dev/null +++ b/bitmaps/import.xpm @@ -0,0 +1,76 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *import_xpm[]; + +#else +char * import_xpm[] = { +"16 16 52 1", +" c None", +". c #000000", +"+ c #1D1D1D", +"@ c #FFFFFF", +"# c #757575", +"$ c #D9D9D9", +"% c #EBEBEB", +"& c #00A200", +"* c #00BD00", +"= c #002400", +"- c #FDFDFD", +"; c #343434", +"> c #E1E1E1", +", c #B5B5B5", +"' c #A1A1A1", +") c #006B00", +"! c #008900", +"~ c #000A00", +"{ c #FAFAFA", +"] c #001800", +"^ c #464646", +"/ c #E8E8E8", +"( c #C3C3C3", +"_ c #002D00", +": c #00B500", +"< c #00A300", +"[ c #006300", +"} c #306130", +"| c #006A00", +"1 c #005900", +"2 c #5A5A5A", +"3 c #002800", +"4 c #00AB00", +"5 c #717171", +"6 c #001100", +"7 c #004900", +"8 c #00A800", +"9 c #00BB00", +"0 c #006900", +"a c #6F6F6F", +"b c #909090", +"c c #006500", +"d c #008600", +"e c #555655", +"f c #F7F7F7", +"g c #004400", +"h c #3C463C", +"i c #E6E6E6", +"j c #2D2D2D", +"k c #DFDFDF", +"l c #FCFCFC", +"m c #D4D4D4", +" ......+. ", +" .@@@@@@##. ", +".... .@$%%%%#%#.", +".&*= .-;>%%%,,'.", +" )*!~.{]^/%%%%(.", +" _:*<[}|12%%%%(.", +" 34*****15%%%(.", +" 67!89*0a%%%(.", +" .bcde%%%%(.", +" .fghi%%%%(.", +" .fjk%%%%%(.", +" .lm%%%%%%(.", +" .@%%%%%%%(.", +" .(((((((((.", +" ...........", +" "}; +#endif diff --git a/bitmaps/jigsaw.xpm b/bitmaps/jigsaw.xpm new file mode 100644 index 0000000000..0e5a08ec46 --- /dev/null +++ b/bitmaps/jigsaw.xpm @@ -0,0 +1,28 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * jigsaw_xpm[]; + +#else +char * jigsaw_xpm[] = { +"16 15 5 1", +" c none", +". c #645264", +"X c #F4F26c", +"o c #A44e08", +"O c #F4F2F4", +" .... ", +" ... .. ", +" ... .. ", +".. .. ", +".. .. X", +".. .. XX", +".. .. .X ", +".. .. .Xo ", +".. .. Oo ", +".. ..OO ", +".. .. ", +".. ", +".. ", +".. ", +" "}; +#endif diff --git a/bitmaps/kicad_icon_small.xpm b/bitmaps/kicad_icon_small.xpm new file mode 100644 index 0000000000..3e7179f3de --- /dev/null +++ b/bitmaps/kicad_icon_small.xpm @@ -0,0 +1,42 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * kicad_icon_small_xpm[]; + +#else +char * kicad_icon_small_xpm[] = { +"16 16 16 1", +" c none", +". c #634931", +"X c #c49c7b", +"o c #e6d0bd", +"O c #c5b9af", +"+ c #8a6c5c", +"@ c #e9bb91", +"# c #f49640", +"$ c #bc7334", +"% c #8b8086", +"& c #716c94", +"* c #472b14", +"= c #827fc6", +"- c #aaa9f3", +"; c #a57f60", +": c #a29ca7", + +" ", +" .$@o%@@.X#. ", +" XX##XOo@OXX%& ", +"*$.###%=&-X#oO ", +"*+;#%=----&$oO ", +" O==-------& O ", +" :&=&=---===O% ", +" :&==--===::@o@O", +" :&=====:O&+ooOo", +" O%+==:O&%%%O: ", +" :X#$&&%;+o% O ", +"*$$###;X;:##oO ", +"*+$###XXX XXoO ", +" %+##X%o@+XX.. ", +" .#Xo%@O.X#. ", +" .Xoo+@@.X#. " +}; +#endif diff --git a/bitmaps/label.xpm b/bitmaps/label.xpm new file mode 100644 index 0000000000..fb989ebb53 --- /dev/null +++ b/bitmaps/label.xpm @@ -0,0 +1,28 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char *label_xpm[]; + +#else +char * label_xpm[] = { +"16 15 3 1", +" c None", +". c Black", +"x c Green", + +/* bitmap */ +" ", +" .. ", +" .... ", +" . ... ", +" .. ... ", +" . .. ", +" .. ... ", +" ........ ", +" . ... ", +" .. .. ", +" . ... ", +" .. .... ", +" ", +"xxxxxxxxxxxxxxxx", +"xxxxxxxxxxxxxxxx"}; +#endif diff --git a/bitmaps/left.xpm b/bitmaps/left.xpm new file mode 100644 index 0000000000..4868f1c54c --- /dev/null +++ b/bitmaps/left.xpm @@ -0,0 +1,50 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *left_xpm[]; + +#else +char * left_xpm[] = { +"16 16 26 1", +" c None", +". c #000000", +"+ c #C4D4E3", +"@ c #A3BCD4", +"# c #A6BED5", +"$ c #AAC1D7", +"% c #ABC2D8", +"& c #AFC5DA", +"* c #AEC4D9", +"= c #6892B9", +"- c #9CB7D1", +"; c #A4BDD5", +"> c #9FB9D2", +", c #9BB6D0", +"' c #9AB5CF", +") c #49759E", +"! c #1C2D3D", +"~ c #C5D5E4", +"{ c #A0BAD3", +"] c #9EB8D1", +"^ c #4B78A2", +"/ c #2A435B", +"( c #3F6588", +"_ c #34536F", +": c #29425A", +"< c #2D4760", +" ", +" . ", +" .. ", +" .+. ", +" .+@....... ", +" .+#$%&%*@=. ", +" .+-;@>,,>'). ", +" !~>{]]->>>>^. ", +" ./((((((((_. ", +" ./((:::::<. ", +" ./(....... ", +" ./. ", +" .. ", +" . ", +" ", +" "}; +#endif diff --git a/bitmaps/libedprt.xpm b/bitmaps/libedprt.xpm new file mode 100644 index 0000000000..bdf9caf830 --- /dev/null +++ b/bitmaps/libedprt.xpm @@ -0,0 +1,32 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char *libedit_part_xpm[]; + +#else +char *libedit_part_xpm[] = { +/* columns rows colors chars-per-pixel */ + +"16 15 3 1", +"- c Red", +"X c None", +"o c Blue", + +/* pixels */ +"X-----------XXXX", +"X----------XXXXX", +"X--XXXXXXXXXXXXX", +"X--XXXXXXXXXXXXX", +"X--------XXXXXXX", +"X--------XXXXXXX", +"X--XXXXXXXXXXXXX", +"X--XXXXXXXXXXXXX", +"X----------XXXXX", +"X-----------XXXX", +"XXXXoooooooXXXXX", +"XXoooXXXXXXoXXXX", +"XXXXoXXXXXXooooX", +"XXoooXXXXXXoXXXX", +"XXXXoooooooXXXXX" +}; +#endif + diff --git a/bitmaps/library.xpm b/bitmaps/library.xpm new file mode 100644 index 0000000000..e967c5a9f2 --- /dev/null +++ b/bitmaps/library.xpm @@ -0,0 +1,31 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * library_xpm[]; + +#else +char * library_xpm[] = { +"16 15 6 1", +"X c Black", +". c None", +"o c Black", +"= c Blue", +"+ c Yellow", +"' c Red", +"........XXXXXX..", +"....ooooX=====X.", +"........X======X", +"........X=======", +"......XXXXXX===X", +"..ooooX+++++X=X.", +"......X++++++X..", +"......X+++++++Xo", +"....XXXXXX+++X..", +"ooooX'''''X+X...", +"....X''''''X....", +"....X'''''''Xooo", +"....X''''''X....", +"ooooX'''''X.....", +"....XXXXXX......" +}; +#endif + diff --git a/bitmaps/library_update.xpm b/bitmaps/library_update.xpm new file mode 100644 index 0000000000..984b3c4a5c --- /dev/null +++ b/bitmaps/library_update.xpm @@ -0,0 +1,31 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * library_update_xpm[]; + +#else +char * library_update_xpm[] = { +"16 15 6 1", +"X c Black", +". c None", +"o c Black", +"= c Gray", +"+ c Green", +"' c Gray", +"........XXXXXX..", +"....ooooX=====X.", +"........X======X", +"........X=======", +"......XXXXXX===X", +"..ooooX+++++X=X.", +"......X++++++X..", +"......X+++++++Xo", +"....XXXXXX+++X..", +"ooooX'''''X+X...", +"....X''''''X....", +"....X'''''''Xooo", +"....X''''''X....", +"ooooX'''''X.....", +"....XXXXXX......" +}; +#endif + diff --git a/bitmaps/libsavem.xpm b/bitmaps/libsavem.xpm new file mode 100644 index 0000000000..8c94bab53f --- /dev/null +++ b/bitmaps/libsavem.xpm @@ -0,0 +1,33 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char *save_part_in_mem_xpm[]; + +#else +char *save_part_in_mem_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 5 1", +" c None", +". c Black", +"x c White", +"o c Red", +"- c BLUE", + +/* pixels */ +" - xxxxxxxxx", +" -- x.......x", +"------ x.......x", +"-------x.ooooo.x", +"------ x..o.o..x", +"-- -- x.oo.oo.x", +"-- - x..o.o..x", +"-- x.oo.oo.x", +"-- x..o.o..x", +"-- x.ooooo.x", +"-- x.......x", +"-- x.......x", +"-- xxxxxxxxx", +"-- ", +"-- " +}; +#endif + diff --git a/bitmaps/libview.xpm b/bitmaps/libview.xpm new file mode 100644 index 0000000000..84b05352e6 --- /dev/null +++ b/bitmaps/libview.xpm @@ -0,0 +1,38 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char * libview_xpm[]; + +#else +char *libview_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 10 1", +"Q c Black", +". c None", +"X c Black", +"u c #808080", +"O c Cyan", +"- c Blue", +"o c Black", +"= c Cyan", +"+ c Yellow", +"' c Red", + +/* pixels */ +"........XXXXXX..", +"....ooooX=====X.", +"........X======X", +"........X=======", +"......XXX======X", +"..ooooX+QQQQX=X.", +"......XQu++uQ...", +"......QuOO+uuQ..", +"....XXQXOXXu.Q..", +"ooooX'Quu''uXQ..", +"....X'Qu''OuuQ..", +"....X''Qu''uQuoo", +"....X'''QQQQuQQ.", +"ooooX'''''X..QQQ", +"....XXXXXX....QQ" +}; +#endif + diff --git a/bitmaps/mirepcb.xpm b/bitmaps/mirepcb.xpm new file mode 100644 index 0000000000..293cef475a --- /dev/null +++ b/bitmaps/mirepcb.xpm @@ -0,0 +1,30 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char *mirepcb_xpm[]; + +#else +char *mirepcb_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 3 1", +"- c Blue", +". c Red", +"X c None", +/* pixels */ +"XXXXXXX-XXXXXXXX", +"XXXXXXX-XXXXXXXX", +"XXXXXX...XXXXXXX", +"XXXXX.X-X.XXXXXX", +"XXXX.XX-XX.XXXXX", +"XXXX.XX-XX.XXXXX", +"XXX.XXX-XXX.XXXX", +"---.-------.----", +"XXX.XXX-XXX.XXXX", +"XXXX.XX-XX.XXXXX", +"XXXX.XX-XX.XXXXX", +"XXXXX.X-X.XXXXXX", +"XXXXXX...XXXXXXX", +"XXXXXXX-XXXXXXXX", +"XXXXXXX-XXXXXXXX", +}; +#endif + diff --git a/bitmaps/modedit.xpm b/bitmaps/modedit.xpm new file mode 100644 index 0000000000..ae3d3e9136 --- /dev/null +++ b/bitmaps/modedit.xpm @@ -0,0 +1,114 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *modedit_xpm[]; + +#else +char * modedit_xpm[] = { +"16 16 90 1", +" c None", +". c #FF7800", +"+ c #010000", +"@ c #000000", +"# c #FAE53A", +"$ c #F0B44C", +"% c #FFFFFF", +"& c #FBEA3D", +"* c #F6B343", +"= c #635632", +"- c #FDFDFF", +"; c #F9F9FF", +"> c #EDECFF", +", c #010101", +"' c #FBE73A", +") c #F6B344", +"! c #6C5E33", +"~ c #F8F8FF", +"{ c #F5F5FF", +"] c #F9E33A", +"^ c #F3B043", +"/ c #625739", +"( c #D9D8FF", +"_ c #FAFAFF", +": c #F7F7FF", +"< c #F4F4FF", +"[ c #F1F0FF", +"} c #EEEDFF", +"| c #EAEAFF", +"1 c #F8DE39", +"2 c #F2AE42", +"3 c #625738", +"4 c #CAC9F0", +"5 c #66667B", +"6 c #F6F5FF", +"7 c #F3F2FF", +"8 c #EFEFFF", +"9 c #ECECFF", +"0 c #E9E9FF", +"a c #F8DB38", +"b c #EEB34D", +"c c #665A32", +"d c #D3D2FC", +"e c #19191E", +"f c #F1F1FF", +"g c #EEEEFF", +"h c #EBEAFF", +"i c #E8E7FF", +"j c #F7D737", +"k c #EFA83F", +"l c #655930", +"m c #D5D4FF", +"n c #9291B1", +"o c #F0F0FF", +"p c #EAE9FF", +"q c #E7E6FF", +"r c #F5D136", +"s c #ECA33E", +"t c #5C5230", +"u c #D4D3FF", +"v c #D0CFFF", +"w c #8E8EB1", +"x c #ECEBFF", +"y c #E8E8FF", +"z c #E5E5FF", +"A c #E2E1FF", +"B c #D6AD74", +"C c #61562F", +"D c #D2D1FF", +"E c #CFCEFF", +"F c #CCCBFF", +"G c #C7C6FC", +"H c #17171E", +"I c #E7E7FF", +"J c #E4E3FF", +"K c #E1E0FF", +"L c #4F4115", +"M c #D1D0FF", +"N c #CECDFF", +"O c #CBC9FF", +"P c #C8C6FF", +"Q c #C4C3FF", +"R c #B6B5F0", +"S c #5C5B7B", +"T c #C9C8FF", +"U c #C6C5FF", +"V c #BAB8FF", +"W c #C5C4FF", +"X c #C2C0FF", +"Y c #B5B3FF", +" ... ... ..+@@", +" ... ... .+#$@", +"@.%.@@.%.@@+&*=@", +"@...-;...>,')!,@", +"@...~{...,]^/+(@", +"@-_:<[}|,123,45@", +"@;67890,abc,de ", +"@pq,rst,uvw@ ", +"@xyzA,BC,DEFGH ", +"@IJK,L,,MNOPQRS@", +"@...,,...TU...V@", +"@...mD...WX...Y@", +"@.%.@@.%.@@.%.@@", +" ... ... ... ", +" ... ... ... "}; +#endif diff --git a/bitmaps/modratsnest.xpm b/bitmaps/modratsnest.xpm new file mode 100644 index 0000000000..a0fc664567 --- /dev/null +++ b/bitmaps/modratsnest.xpm @@ -0,0 +1,32 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * mod_ratsnest_xpm[]; + +#else +char * mod_ratsnest_xpm[] = { +"16 15 5 1", +"X c Red", +". c None", +"o c Blue", +"c c Gray", +"- c White", + +"...........-....", +"--........-.-...", +"..--XXX..-XX.-..", +".cooX--.-..Xoo-.", +".cooX..--..Xooc.", +"....X.-..--X....", +".cooX-.....X--c.", +".coo-......Xoo-.", +"...-X......X....", +".c-oX......Xooc.", +".-ooX......Xoo-.", +"..-.XXXXXXXX..-.", +"...-..........-.", +"....-..........-", +".....-.........-" + +}; +#endif + diff --git a/bitmaps/module.xpm b/bitmaps/module.xpm new file mode 100644 index 0000000000..006ac2da64 --- /dev/null +++ b/bitmaps/module.xpm @@ -0,0 +1,29 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * module_xpm[]; + +#else +char * module_xpm[] = { +"16 15 4 1", +"X c Red", +". c None", +"o c Blue", +"c c Gray", +"....XXX..XXX....", +".cooX..XX..Xooc.", +".cooX......Xooc.", +"....X......X....", +".cooX......Xooc.", +".cooX......Xooc.", +"....X......X....", +".cooX......Xooc.", +".cooX......Xooc.", +"....X......X....", +".cooX......Xooc.", +".cooX......Xooc.", +"....X......X....", +".cooX......Xooc.", +"....XXXXXXXX...." +}; +#endif + diff --git a/bitmaps/netlist.xpm b/bitmaps/netlist.xpm new file mode 100644 index 0000000000..ee91d7d12a --- /dev/null +++ b/bitmaps/netlist.xpm @@ -0,0 +1,68 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *netlist_xpm[]; + +#else +char * netlist_xpm[] = { +"16 16 44 1", +" c None", +". c #000000", +"+ c #FFFFFF", +"@ c #BFE5FF", +"# c #45535D", +"$ c #F6F5F4", +"% c #6C5B4C", +"& c #EC8F3D", +"* c #FF7800", +"= c #C4DCEB", +"- c #B6C5CC", +"; c #A6805E", +"> c #FC9F4C", +", c #FFEAD7", +"' c #F7E2CF", +") c #E7C7AB", +"! c #E1B894", +"~ c #F0DBC8", +"{ c #ABBDC9", +"] c #FFF4EB", +"^ c #F1DECD", +"/ c #A6B9C4", +"( c #FFBF87", +"_ c #EECEB2", +": c #FFFEFD", +"< c #EDCDB1", +"[ c #DDB187", +"} c #DCC2AB", +"| c #DBC2AA", +"1 c #8B8B8B", +"2 c #898989", +"3 c #FFBB80", +"4 c #2C343B", +"5 c #B8BBBD", +"6 c #3A4248", +"7 c #394146", +"8 c #B6B9BB", +"9 c #2E373E", +"0 c #202020", +"a c #393939", +"b c #E3E3E3", +"c c #E2E2E2", +"d c #353535", +"e c #262626", +"................", +".+++++.++.+++++.", +".@.@#......#@.@.", +".+++$%&**&%$+++.", +".@.@=-;>>;-=@.@.", +".+++,')!!)~,+++.", +".@.@={]^^]/=@.@.", +".+++(_(::(<(+++.", +".@.@[}(++(|[@.@.", +".++++1++++2++++.", +".@.@*3*++*3*@.@.", +".+++*3*++*3*+++.", +".@.@@456789@@.@.", +".++++0abcde++++.", +".@.@@@@@@@@@@.@.", +"................"}; +#endif diff --git a/bitmaps/new.xpm b/bitmaps/new.xpm new file mode 100644 index 0000000000..c69694c292 --- /dev/null +++ b/bitmaps/new.xpm @@ -0,0 +1,47 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *new_xpm[]; + +#else +char * new_xpm[] = { +"16 16 23 1", +" c None", +"! c black", +"# c #FEFEFE", +"$ c #090909", +"% c #EEEEEE", +"& c #F1F1F1", +"' c #FBFBFB", +"( c #767676", +") c #F0F0F0", +"* c #161616", +"+ c #EFEFEF", +", c #C4C4C4", +"- c #ECECEC", +". c #EBEBEB", +"0 c #EDEDED", +"1 c #EAEAEA", +"2 c #E8E8E8", +"3 c #E9E9E9", +"4 c #E7E7E7", +"5 c #E6E6E6", +"6 c #E5E5E5", +"7 c #E4E4E4", +"8 c #E3E3E3", +" !!!!!!!!!!!! ", +"!##########$#! ", +"!#%%%&&&&&&$'#! ", +"!#%%%&&&&&&$(##!", +"!#%%%&&&&&)$$$*!", +"!#%%%&++++++%%,!", +"!#%%%+++%%%%%-,!", +"!#%%%%%%%%%%%.,!", +"!#%%%0---..111,!", +"!#%%%.22222222,!", +"!#%%%113322244,!", +"!#%%%255555556,!", +"!#%%%445556677,!", +"!#%%%%%%%%7888,!", +"!,,,,,,,,,,,,,,!", +" !!!!!!!!!!!!!! "}; +#endif diff --git a/bitmaps/noconn.xpm b/bitmaps/noconn.xpm new file mode 100644 index 0000000000..14538957fb --- /dev/null +++ b/bitmaps/noconn.xpm @@ -0,0 +1,29 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char *noconn_button[]; + +#else +char *noconn_button[] = { +/* columns rows colors chars-per-pixel */ +"16 15 2 1", +" c None", +"- c Blue", +/* pixels */ +" ", +" ", +" - - ", +" - - ", +" - - ", +" - - ", +" - - ", +" - ", +" - - ", +" - - ", +" - - ", +" - - ", +" - - ", +" ", +" " +}; +#endif + diff --git a/bitmaps/open.xpm b/bitmaps/open.xpm new file mode 100644 index 0000000000..82ba7ddff0 --- /dev/null +++ b/bitmaps/open.xpm @@ -0,0 +1,88 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *open_xpm[]; + +#else +char * open_xpm[] = { +"16 16 64 1", +" c None", +". c #000000", +"+ c #E4E5DF", +"@ c #D5D6CB", +"# c #D6D7CA", +"$ c #A3A39D", +"% c #F5F6F0", +"& c #8D907B", +"* c #92957E", +"= c #90937D", +"- c #979B84", +"; c #6D705F", +"> c #EAECDB", +", c #8A8C7D", +"' c #8E917B", +") c #91947F", +"! c #8B8E7A", +"~ c #999B87", +"{ c #919480", +"] c #989B86", +"^ c #B1B4A2", +"/ c #A2A394", +"( c #F7F7F7", +"_ c #878A75", +": c #666858", +"< c #4B4D3F", +"[ c #4D4F40", +"} c #404135", +"| c #424337", +"1 c #434437", +"2 c #404236", +"3 c #3C3D32", +"4 c #48493C", +"5 c #1A1A16", +"6 c #C6C6BE", +"7 c #848672", +"8 c #25261F", +"9 c #F1F2E9", +"0 c #DDE0C7", +"a c #D6DABB", +"b c #CDD2AC", +"c c #C7CCA7", +"d c #989C80", +"e c #C6C7BE", +"f c #5F6152", +"g c #888980", +"h c #A7AB8C", +"i c #878A70", +"j c #9FA19A", +"k c #EFF0E5", +"l c #9EA284", +"m c #80817B", +"n c #96968D", +"o c #E3E5D1", +"p c #83866D", +"q c #97998D", +"r c #EDEFE2", +"s c #A2A688", +"t c #767671", +"u c #E7E9DA", +"v c #D1D3BD", +"w c #BBBF9D", +"x c #989B80", +"y c #6E715C", +" ", +" ", +" .... ", +" .+@#$. ", +" .%&*=-;..... ", +" .>,')!~{]{^/. ", +" .(_:<[}||12345 ", +" .67890abbbbbcd.", +" .efg0bbbbbbbhi.", +" .j8kabbbbbbbl. ", +" .mnobbbbbbbbp. ", +" .qrbbbbbbbbs. ", +" .tuvwwwwwwxy. ", +" ........... ", +" ", +" "}; +#endif diff --git a/bitmaps/pad.xpm b/bitmaps/pad.xpm new file mode 100644 index 0000000000..b549d534ff --- /dev/null +++ b/bitmaps/pad.xpm @@ -0,0 +1,30 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char *pad_xpm[]; + +#else +char * pad_xpm[] = { +"16 15 3 1", +"- c green", +" c None", +": c Red", + +/* pixels */ +" ---- ", +" --::::-- ", +" -::::::::- ", +" -::::::::::- ", +" -::::::::::::- ", +" -:::: ::::- ", +"-:::: ::::-", +"-:::: ::::-", +"-:::: ::::-", +" -:::: ::::- ", +" -::::::::::::- ", +" -::::::::: - ", +" -::::::::- ", +" --::::-- ", +" ---- " +}; +#endif + diff --git a/bitmaps/palette.xpm b/bitmaps/palette.xpm new file mode 100644 index 0000000000..a469bc0789 --- /dev/null +++ b/bitmaps/palette.xpm @@ -0,0 +1,38 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *palette_xpm[]; + +#else +char * palette_xpm[] = { +"16 15 14 1", +" c #c0c0c0", +". c #808080", +"X c Gray100", +"o c Yellow", +"O c Blue", +"+ c Red", +"@ c Cyan", +"# c #800000", +"$ c #000080", +"% c Green", +"& c #008000", +"* c #808000", +"= c Magenta", +"- c #800080", +" ..... ", +" .XoXoX. O ", +" .Xo+++Xo. @O ", +" .oX##++X. @O$ ", +" .oXoXo#oXo.O$$ ", +" .X%&&XoXoX*#. ", +" .o&&&oXoX*##. ", +" .X&XoXoX*##Xo. ", +" .oXoOoX*##XoX. ", +" .o$$Oo * oXo. ", +" .X$$$Xo=-XoX. ", +" ..X$oX=---Xo. ", +" .oXo---Xo. ", +" *#.oXXoXo.. ", +" *# ...... "} +#endif +; diff --git a/bitmaps/paste.xpm b/bitmaps/paste.xpm new file mode 100644 index 0000000000..f5533ca6f6 --- /dev/null +++ b/bitmaps/paste.xpm @@ -0,0 +1,78 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *paste_xpm[]; + +#else +char * paste_xpm[] = { +"16 16 54 1", +" c None", +". c #000000", +"+ c #8E8E8E", +"@ c #E3E3E3", +"# c #696969", +"$ c #F1F0E1", +"% c #ECE9D5", +"& c #EDEBD8", +"* c #2E2D29", +"= c #7E7D76", +"- c #5D5C58", +"; c #53534F", +"> c #21211E", +", c #79776C", +"' c #979487", +") c #8C866C", +"! c #EBE7D3", +"~ c #C1B485", +"{ c #343124", +"] c #ABA89E", +"^ c #EFECE0", +"/ c #AEABA3", +"( c #6C6A66", +"_ c #26241A", +": c #8F8663", +"< c #7A7251", +"[ c #988E69", +"} c #353225", +"| c #26231A", +"1 c #302D21", +"2 c #333023", +"3 c #6E674C", +"4 c #A69B72", +"5 c #7A7051", +"6 c #EBE8D4", +"7 c #D8D0B3", +"8 c #58523D", +"9 c #E9E6D2", +"0 c #FFFFFF", +"a c #B9B9B9", +"b c #A1A1A1", +"c c #AAAAAA", +"d c #D3D3D3", +"e c #E9E6D1", +"f c #E9E6D0", +"g c #E8E5D0", +"h c #A39870", +"i c #EDEAD7", +"j c #E9E5CE", +"k c #AEAEAE", +"l c #898267", +"m c #746A45", +"n c #6B623D", +"o c #655A37", +" ... ", +" ....+@#.... ", +".$%&*=-;>,'). ", +".!~{]^^/(_:<. ", +".%~[}|1|2345. ", +".6~~78......... ", +".9~[~.000000000.", +".9~~7.0aba0cbd0.", +".e~[~.000000000.", +".f~~7.0abadab00.", +".g~h~.000000000.", +".g~~7.0abba0cd0.", +".i~h~.000000000.", +".j~~~.0dbb0cbk0.", +".lmno.000000000.", +" .............. "}; +#endif diff --git a/bitmaps/pcbnew.xpm b/bitmaps/pcbnew.xpm new file mode 100644 index 0000000000..e915f6d49c --- /dev/null +++ b/bitmaps/pcbnew.xpm @@ -0,0 +1,80 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char *pcbnew_xpm[]; + +#else +char *pcbnew_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 16 54 1", +" c None", +". c #000000", +"+ c #FEFEFF", +"@ c #F9AB7F", +"# c #F55A00", +"$ c #FDFDFF", +"% c #9B9B9B", +"& c #FFFFFF", +"* c #F9F9FF", +"= c #FCFCFF", +"- c #F8F8FF", +"; c #F4F4FF", +"> c #F8AA7F", +", c #F4A67F", +"' c #F0F0FF", +") c #ECECFF", +"! c #FAFAFF", +"~ c #F7F7FF", +"{ c #F0A27F", +"] c #E8E8FF", +"^ c #F6F6FF", +"/ c #F2F2FF", +"( c #EFEFFF", +"_ c #EBEBFF", +": c #E7E7FF", +"< c #E4E4FF", +"[ c #DFDFFF", +"} c #F5F5FF", +"| c #F1F1FF", +"1 c #EEEEFF", +"2 c #EAEAFF", +"3 c #E6E6FF", +"4 c #E3E3FF", +"5 c #DBDBFF", +"6 c #EDEDFF", +"7 c #EB9D7F", +"8 c #E89A7F", +"9 c #D7D7FF", +"0 c #D3D3FF", +"a c #FBFBFF", +"b c #E9E9FF", +"c c #E5E5FF", +"d c #E1E1FF", +"e c #DDDDFF", +"f c #E7997F", +"g c #E3957F", +"h c #CFCFFF", +"i c #F3F3FF", +"j c #D9D9FF", +"k c #D5D5FF", +"l c #D2D2FF", +"m c #CECEFF", +"n c #CACAFF", +"o c #4D4D4D", +"............... ", +".+@#@++++++++$.%", +".+#&#########*.%", +".+@#@++++++=-;.%", +".+++++++++>#,'.%", +".+#########&#).%", +".+++++++!~,#{].%", +".+@#@++!^/(_:<.%", +".+#&#########[.%", +".+@#@*}|1234[5.%", +".++=-}|6237#89.%", +".+#########�.%", +".a~;')bcdef#gh.%", +".~i')] c #757575", +", c #707070", +"' c #C8C8C8", +") c #A6A6A6", +"! c #3C3C3C", +"................", +".++++++++++++++.", +".+..........@#+.", +".+$%%%%%%%%%&++.", +".+$%%%%...%%&*+.", +".+$%%%%%%%%%&++.", +"..$...%...%%&...", +" .=%%%%%%%%%&-. ", +" ..%.%..;%>.,-. ", +" ..%.%.%.%.%&-. ", +" ....%..>%.>.-. ", +" ..%.%.%%%.%.-. ", +" ..%.%.%%%>.,-. ", +" .'))))))))))-. ", +" .-..........-. ", +" .!. .!. "}; +#endif diff --git a/bitmaps/plot_PS.xpm b/bitmaps/plot_PS.xpm new file mode 100644 index 0000000000..c80f733982 --- /dev/null +++ b/bitmaps/plot_PS.xpm @@ -0,0 +1,38 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *plot_PS_xpm[]; + +#else +char * plot_PS_xpm[] = { +"16 16 14 1", +" c None", +"! c black", +"# c #C3C3C3", +"$ c #616161", +"% c #D72E2E", +"& c #F5F5F5", +"' c #EBEBEB", +"( c #E1E1E1", +") c #006900", +"* c #5B5B5B", +"+ c #D2D2D2", +", c #C8C8C8", +"- c #A6A6A6", +". c #3C3C3C", +"!!!!!!!!!!!!!!!!", +"!##############!", +"!#!!!!!!!!!!$%#!", +"!#&'''''''''(##!", +"!#&''''!!!''()#!", +"!#&'''''''''(##!", +"!!&!!!'!!!''(!!!", +" !&'''''''''(*! ", +" !&'!!+'+!+'(*! ", +" !&'!'!'!'''(*! ", +" !&'!!+'+!+'(*! ", +" !&'!'''''!'(*! ", +" !&'!'''!!+'(*! ", +" !,----------*! ", +" !*!!!!!!!!!!*! ", +" !.! !.! "}; +#endif diff --git a/bitmaps/polar.xpm b/bitmaps/polar.xpm new file mode 100644 index 0000000000..16d9b81571 --- /dev/null +++ b/bitmaps/polar.xpm @@ -0,0 +1,57 @@ +/* XPM */ +#ifndef XPMMAIN +extern const char *polar_coord_xpm[]; + +#else +const char * polar_coord_xpm[] = { +"16 16 33 1", +" c None", +"! c black", +"# c #161616", +"$ c #161513", +"% c #F2D7C0", +"& c #F2BC8E", +"' c #140D07", +"( c #14111C", +") c #F2B279", +"* c #F29647", +"+ c #140A01", +", c #000075", +"- c #120A1F", +". c #130904", +"0 c #00009A", +"1 c #000046", +"2 c #00009B", +"3 c #000066", +"4 c #00007B", +"5 c #000034", +"6 c #000097", +"7 c #000093", +"8 c #000098", +"9 c #000036", +": c #000088", +"; c #00008D", +"< c #000052", +"= c #00006B", +"> c #00006C", +"? c #000081", +"@ c #000080", +"A c #000094", +"B c #121212", +"! #$ ", +"! #%&' ", +"! ()*+ ", +"! ,-.! ", +"! 001 ", +"! 223 ", +"! 224 ", +"! 2205 ", +"! 2627 ", +"! 089:2; ", +"! 20< 62= ", +"! 22> 2: ", +"!?2@ 2A ", +"!2; 28 ", +"!!!!!!!!!!!!!!!B", +" "}; +#endif diff --git a/bitmaps/preference.xpm b/bitmaps/preference.xpm new file mode 100644 index 0000000000..4a994bb8a6 --- /dev/null +++ b/bitmaps/preference.xpm @@ -0,0 +1,30 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *preference_xpm[]; + +#else +char * preference_xpm[] = { +"16 15 7 1", +" c None", +". c #808000", +"X c #c0c0c0", +"o c #808080", +"O c Black", +"+ c #008080", +"@ c Blue", +" .... ", +" ..XXoo.. ", +" .XXoo..O.O ", +" .Xoo.X XOO ", +" .Xo.. XXO ", +" .X.O XX +O ", +" .o.OX XXXO ", +" .o..OXXXXOO ", +" .o. XXXXO ", +" .OXXXXXO ", +" O OOOO ", +" ++XXO ", +" +++@@@@ ", +" ++++++@@@ ", +" OOOOOOOOOO "}; +#endif diff --git a/bitmaps/print.xpm b/bitmaps/print.xpm new file mode 100644 index 0000000000..24a5d4a8f8 --- /dev/null +++ b/bitmaps/print.xpm @@ -0,0 +1,32 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char *print_button[]; + +#else +char *print_button[] = { +/* columns rows colors chars-per-pixel */ +"16 15 5 1", +" c None", +". c Black", +"X c Gray100", +"o c #808000", +"O c Yellow", +/* pixels */ +" ", +" ......... ", +" .XXXXXXXX. ", +" .X.....X. ", +" .XXXXXXXX. ", +" .X.....X.... ", +" .XXXXXXXX. . .", +" .......... . ..", +". . . .", +"............. .", +". ooo . . ", +". OOO ... ", +"............. . ", +" . . . ", +" ........... " +}; +#endif + diff --git a/bitmaps/ratsnest.xpm b/bitmaps/ratsnest.xpm new file mode 100644 index 0000000000..78d9f0e990 --- /dev/null +++ b/bitmaps/ratsnest.xpm @@ -0,0 +1,32 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *ratsnest_xpm[]; + +#else +char *ratsnest_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 16 3 1", +"- c White", +"o c Red", +"X c None", + +/* pixels */ +"XoXXXXXXXXXXXX-o", +"XX-XXXXXXXXXX-XX", +"XXX-XXXXXXXo-XXX", +"XXXX-XXXXXo-oXXX", +"XXXXX-XXXXXo-XXX", +"XXXXXX-XXXXXX-XX", +"XXXXXXX-oXXXX-XX", +"XXXXXXXoooXXXX-o", +"XXXXXXX-oXXXXXo-", +"XXXXXX-XXXXXXXXo", +"XXXXX-XXXXXXXXXX", +"XXXX-oXXXXXXXXXX", +"XXXXooo-XXXXXXXX", +"XXXX-oXXX--XXXXX", +"XXX-XXXXXXXX--XX", +"XX-XXXXXXXXXXXX-" +}; +#endif + diff --git a/bitmaps/red.xpm b/bitmaps/red.xpm new file mode 100644 index 0000000000..c8b99917e8 --- /dev/null +++ b/bitmaps/red.xpm @@ -0,0 +1,36 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *red_xpm[]; + +#else +char *red_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 6 1", +" c Gray0", +"X c #7b7b7b7b7b7b", +"O c Red", +"# c White", +"+ c Yellow", +"@ c None", + +/* pixels */ +"@@@@@@@@@@@@@@@@", +"@@@@@@@@@@@@@@@@", +"@@@@@@@@@@@@@@@@", +"@@@@X X@@@@@@", +"@@@ OOOO @@@@@", +"@@X +#OOOO X@@@@", +"@@ O#+OOOOO @@@@", +"@@ OOOOOOOO @@@@", +"@@ OOOOOO+O X@@@", +"@@ OOOOO++O X@@@", +"@@X OOO++O XX@@@", +"@@@ OOOO XXX@@", +"@@@@X XXXX@@@", +"@@@@@@@XXXXXX@@@", +"@@@@@@@@@@X@@@@@" +}; +#endif + + + diff --git a/bitmaps/redo.xpm b/bitmaps/redo.xpm new file mode 100644 index 0000000000..0fe9cf3540 --- /dev/null +++ b/bitmaps/redo.xpm @@ -0,0 +1,31 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *redo_xpm[]; + +#else +char *redo_xpm[] = { +/* width height num_colors chars_per_pixel */ +"16 16 4 1", +/* colors */ +" c None", +"X c #0000E0", +"a c #808080", +". c #404040", +/* pixels */ +" ", +" ", +" ", +" ", +" aXXXX.. ", +" aX....XX.. X..", +" XX ..X XX..", +" XX ..XXX..", +" XX ..XXXX..", +" XX ..XXXXX..", +" .aXX .........", +" .XXXa ", +" ", +" ", +" ", +" "}; +#endif diff --git a/bitmaps/right.xpm b/bitmaps/right.xpm new file mode 100644 index 0000000000..03a2758de1 --- /dev/null +++ b/bitmaps/right.xpm @@ -0,0 +1,49 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *right_xpm[]; + +#else +char * right_xpm[] = { +"16 16 25 1", +" c None", +". c #000000", +"+ c #5B88B2", +"@ c #9EB8D1", +"# c #5080AD", +"$ c #B5C9DC", +"% c #AFC5DA", +"& c #B2C7DB", +"* c #B6CADD", +"= c #A4BDD5", +"- c #9CB7D1", +"; c #080D11", +"> c #9BB6D0", +", c #A0BAD3", +"' c #9AB5CF", +") c #97B3CE", +"! c #5F8BB4", +"~ c #91B0CC", +"{ c #95B2CE", +"] c #4C79A3", +"^ c #49749C", +"/ c #3F6588", +"( c #2A435B", +"_ c #456F96", +": c #375978", +" ", +" . ", +" .. ", +" .+. ", +" .......@#. ", +" .$%&***=-#; ", +" .>,-->',-)!. ", +" .~@''>---,{]. ", +" .^////////(. ", +" ._::::://(. ", +" ......./(. ", +" .(. ", +" .. ", +" . ", +" ", +" "}; +#endif diff --git a/bitmaps/save.xpm b/bitmaps/save.xpm new file mode 100644 index 0000000000..f89778b3c9 --- /dev/null +++ b/bitmaps/save.xpm @@ -0,0 +1,107 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *save_xpm[]; + +#else +char * save_xpm[] = { +"16 16 83 1", +" c None", +". c #000000", +"+ c #F7F8FA", +"@ c #CBDDEB", +"# c #C88A80", +"$ c #D18F84", +"% c #D19084", +"& c #D39186", +"* c #BFD5E8", +"= c #DBE7F1", +"- c #8DA9BE", +"; c #B7877E", +"> c #C77568", +", c #C77467", +"' c #C77466", +") c #C87668", +"! c #CD867A", +"~ c #54697C", +"{ c #CFE0ED", +"] c #D7D7D7", +"^ c #FEFEFE", +"/ c #F9F9F9", +"( c #84A0B5", +"_ c #4F6475", +": c #D6D6D6", +"< c #F1F1F1", +"[ c #819AAE", +"} c #496072", +"| c #FCFCFC", +"1 c #F4F4F4", +"2 c #EBEBEB", +"3 c #D4D4D4", +"4 c #C5C5C5", +"5 c #EEEEEE", +"6 c #F2F2F2", +"7 c #AEBFCD", +"8 c #CAD6DF", +"9 c #C7CFDA", +"0 c #BFCBD6", +"a c #A1B6C4", +"b c #89A6BC", +"c c #7F9AAE", +"d c #7E99AD", +"e c #7D97AC", +"f c #8CA8BD", +"g c #A8B1BD", +"h c #CECECE", +"i c #9C9D9D", +"j c #2F4656", +"k c #80868C", +"l c #183042", +"m c #33495A", +"n c #B9B9B9", +"o c #132D3C", +"p c #586D80", +"q c #97A5B0", +"r c #86A4B9", +"s c #CDCDCD", +"t c #2E4353", +"u c #5A7082", +"v c #BFBFBF", +"w c #112835", +"x c #9DA9B0", +"y c #6B7882", +"z c #839EB2", +"A c #E6E6E6", +"B c #213648", +"C c #5F7989", +"D c #C2C2C2", +"E c #B2B2B2", +"F c #112C3A", +"G c #9FA9B0", +"H c #59636D", +"I c #A1A1A1", +"J c #C0C0C0", +"K c #909090", +"L c #868686", +"M c #6E6E6E", +"N c #7A7A7A", +"O c #2D3949", +"P c #3E4F5C", +"Q c #80878F", +"R c #1A3140", +" .............. ", +".+@#$$$$$$%$&**.", +".=-;>,,,,',)!-~.", +".{-]^^^^^^^^/(_.", +".{-]]]]]]]]:<[}.", +".{-]^^^^|122<[}.", +".{-]]]]34444<[}.", +".{-5^^6222225[}.", +".{-789000000a[}.", +".{--bc[[[[de[[}.", +".{-fg44h2]ijk[}.", +".{-(44lm:4nopq}.", +".{r[4stu44vwux}.", +".yz[sABC4DEFuG}.", +" .H_IJKKLMNOPQR.", +" ............. "}; +#endif diff --git a/bitmaps/save_as.xpm b/bitmaps/save_as.xpm new file mode 100644 index 0000000000..0c297e6bae --- /dev/null +++ b/bitmaps/save_as.xpm @@ -0,0 +1,135 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *save_as_xpm[]; + +#else +char * save_as_xpm[] = { +"16 16 111 2", +" c None", +". c #000000", +"+ c #F7F8FA", +"@ c #CBDDEB", +"# c #C88A80", +"$ c #D18F84", +"% c #CF8D82", +"& c #A49626", +"* c #634A1E", +"= c #A8BBCC", +"- c #BFD5E8", +"; c #DBE7F1", +"> c #8DA9BE", +", c #B7877E", +"' c #C77568", +") c #C77467", +"! c #C57366", +"~ c #FCEB3D", +"{ c #F7B544", +"] c #61522E", +"^ c #72899A", +"/ c #54697C", +"( c #CFE0ED", +"_ c #D7D7D7", +": c #FEFEFE", +"< c #FCFCFC", +"[ c #F9DF39", +"} c #F7B545", +"| c #6C5F34", +"1 c #B4B4B4", +"2 c #84A0B5", +"3 c #4F6475", +"4 c #D6D6D6", +"5 c #F8D837", +"6 c #EFB44D", +"7 c #584D2B", +"8 c #8F8F8F", +"9 c #F1F1F1", +"0 c #819AAE", +"a c #496072", +"b c #FDFDFD", +"c c #F6D236", +"d c #EDA43E", +"e c #584E2B", +"f c #AAAAAA", +"g c #D3D3D3", +"h c #485F71", +"i c #D5D5D5", +"j c #D7AE74", +"k c #61562F", +"l c #737373", +"m c #C5C5C5", +"n c #B0B0B0", +"o c #7F98AC", +"p c #EDEDED", +"q c #4F4115", +"r c #8D8D8D", +"s c #EBEBEB", +"t c #ECECEC", +"u c #ACBDCB", +"v c #6F767D", +"w c #9AA3AC", +"x c #BFCBD6", +"y c #BDC9D4", +"z c #A1B6C4", +"A c #8BA7BC", +"B c #809CB0", +"C c #6C8394", +"D c #7D97AB", +"E c #7D97AC", +"F c #A4ACB8", +"G c #B9B9B9", +"H c #C7C7C7", +"I c #E1E1E1", +"J c #D4D4D4", +"K c #9C9D9D", +"L c #2F4656", +"M c #80868C", +"N c #183042", +"O c #33495A", +"P c #132D3C", +"Q c #586D80", +"R c #97A5B0", +"S c #86A4B9", +"T c #CDCDCD", +"U c #2E4353", +"V c #5A7082", +"W c #BFBFBF", +"X c #112835", +"Y c #9DA9B0", +"Z c #6B7882", +"` c #829DB1", +" . c #CBCBCB", +".. c #E5E5E5", +"+. c #213648", +"@. c #5F7989", +"#. c #C2C2C2", +"$. c #B2B2B2", +"%. c #112C3A", +"&. c #9FA9B0", +"*. c #59636D", +"=. c #A1A1A1", +"-. c #C0C0C0", +";. c #909090", +">. c #868686", +",. c #6E6E6E", +"'. c #7A7A7A", +"). c #2D3949", +"!. c #3E4F5C", +"~. c #80878F", +"{. c #1A3140", +" . . . . . . . . . . . . . . ", +". + @ # $ $ $ $ % . & * . = - . ", +". ; > , ' ) ) ! . ~ { ] . ^ / . ", +". ( > _ : : < . [ } | . 1 2 3 . ", +". ( > _ _ 4 . 5 6 7 . 8 9 0 a . ", +". ( > _ b . c d e . f g 9 0 h . ", +". ( > _ i . j k . l m n 9 o a . ", +". ( > p . q . . r g s s t 0 a . ", +". ( > u . . v w x x x y z 0 a . ", +". ( > A B C 0 0 0 0 D E 0 0 a . ", +". ( > A F G G H I J K L M 0 a . ", +". ( > 2 m m N O i m G P Q R a . ", +". ( S 0 m T U V m m W X V Y a . ", +". Z ` o ...+.@.m #.$.%.V &.a . ", +". . *.3 =.-.;.;.>.,.'.).!.~.{.. ", +" . . . . . . . . . . . . . . "}; +#endif diff --git a/bitmaps/schematic.xpm b/bitmaps/schematic.xpm new file mode 100644 index 0000000000..ebf71fb1f6 --- /dev/null +++ b/bitmaps/schematic.xpm @@ -0,0 +1,35 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char * schematic_xpm[]; + +#else +char *schematic_xpm[] = { + +/* columns rows colors chars-per-pixel */ +"16 15 6 1", +" c None", +". c Black", +"X c Gray100", +"o c Blue", +"- c Green", +"! c Red", + +/* pixels */ +".............. ", +".XXXXXXXXXXXX.. ", +".XXXXXXXXXXXX...", +".XXoooooXXXXXXX.", +".oooXXXXoXXXXXX.", +".XXoXXXXo--XXXX.", +".oooXXXXoX-XXXX.", +".XXoooooXX-XXXX.", +".XXXXXXXXX-XXXX.", +".XX--------XXXX.", +".XX-XXXXXXXXXXX.", +".XX-XX!XXX!XXXX.", +".XX--!X!X!X!X!-.", +".XXXXXXX!XXX!XX.", +"................" +}; +#endif + diff --git a/bitmaps/select_grid.xpm b/bitmaps/select_grid.xpm new file mode 100644 index 0000000000..99a79d6b95 --- /dev/null +++ b/bitmaps/select_grid.xpm @@ -0,0 +1,30 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *select_grid_xpm[]; + +#else +char *select_grid_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 16 5 1", +" c #ffffff", +". c none", +"X c #04827c", +"o c #048284", +"O c #04867c", +" .. .. .. .. .. ", +"................", +"................", +" .. .. .. .. .. ", +"................", +"................", +" .X.oX .. oX.o. ", +"..oXXo....XXXX..", +"..XoX......oXo..", +" .oXoXooXooXoX. ", +"..XXo......oXo..", +"..oOXX....XXOX..", +" .o.oo .. oo.o. ", +"................", +"................", +" .. .. .. .. .. "}; +#endif diff --git a/bitmaps/sheetset.xpm b/bitmaps/sheetset.xpm new file mode 100644 index 0000000000..5916e05171 --- /dev/null +++ b/bitmaps/sheetset.xpm @@ -0,0 +1,31 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char *sheetset_xpm[]; + +#else +char *sheetset_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 4 1", +" c None", +". c Black", +"= c Blue", +"X c Gray100", +/* pixels */ +" ............ ", +" .XXX=XXXXX.. ", +" .XX===XXXX.X. ", +" .XXX=XXXXX.... ", +" .XXX=XXXXXXXX. ", +" .X=X=XXXXXX=X. ", +" .============. ", +" .X=X=XXXXXX=X. ", +" .XXX=XXXXXXXX. ", +" .XXX=XXXXXXXX. ", +" .XXX=XXXXXXXX. ", +" .XXX=XX.....X. ", +" .XX===X.....X. ", +" .XXX=XXXXXXXX. ", +" .............. " +}; +#endif + diff --git a/bitmaps/showdcode.xpm b/bitmaps/showdcode.xpm new file mode 100644 index 0000000000..f0704a24f7 --- /dev/null +++ b/bitmaps/showdcode.xpm @@ -0,0 +1,31 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char *show_dcodenumber_xpm[]; + +#else +char * show_dcodenumber_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 3 1", +"- c Red", +"X c None", +": c Blue", + +/* pixels */ +"XXXXXX----XXXXXX", +"XXXX--XXXX--XXXX", +"XXX-XXXXXXXX-XXX", +"XX-XXXXXXXXXX-XX", +"X-XX:::::XXXXX-X", +"X-XX:XXXX:XXXX-X", +"-XXX:XXXXX:XXXX-", +"-XXX:XXXXX:XXXX-", +"-XXX:XXXXX:XXXX-", +"X-XX:XXXX:XXXX-X", +"X-XX:::::XXXXX-X", +"XX-XXXXXXXXXX-XX", +"XXX-XXXXXXXX-XXX", +"XXXX--XXXX--XXXX", +"XXXXXX----XXXXXX" +}; +#endif + diff --git a/bitmaps/showmodedge.xpm b/bitmaps/showmodedge.xpm new file mode 100644 index 0000000000..35493c4a7c --- /dev/null +++ b/bitmaps/showmodedge.xpm @@ -0,0 +1,29 @@ +/* XPM */ +#ifndef XPMMAIN +extern char * show_mod_edge_xpm[]; + +#else +char * show_mod_edge_xpm[] = { +"16 15 4 1", +"X c Red", +". c None", +"o c Blue", +"c c Gray", +"..XXXXX..XXXXX..", +"coX....XX....Xoc", +"coX.XXX..XXX.Xoc", +"..X.X..XX..X.X..", +"coX.X......X.Xoc", +"coX.X......X.Xoc", +"..X.X......X.X..", +"coX.X......X.Xoc", +"coX.X......X.Xoc", +"..X.X......X.X..", +"coX.X......X.Xoc", +"coX.X......X.oc.", +"..X.XXXXXXXX.X..", +"coX..........Xoc", +"..XXXXXXXXXXXX.." +}; +#endif + diff --git a/bitmaps/showtrack.xpm b/bitmaps/showtrack.xpm new file mode 100644 index 0000000000..e3f9534fb6 --- /dev/null +++ b/bitmaps/showtrack.xpm @@ -0,0 +1,30 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char *showtrack_xpm[]; + +#else +char *showtrack_xpm[] = { +/* columns rows colors chars per pixel */ +"16 15 3 1", +"= c Red", +": c #008000", +" c none", +/* pixels */ +" : : ", +"====== : : ", +" = : : ", +" = : : ", +"==== = : : ", +" = = : : ", +" = = : : ", +" = = : : ", +" = = : : ", +" = = : : ", +" = = : : ", +" = ==========", +" = : : ", +" = : : ", +" ============" +}; +#endif + diff --git a/bitmaps/tools.xpm b/bitmaps/tools.xpm new file mode 100644 index 0000000000..6a6c57e9b2 --- /dev/null +++ b/bitmaps/tools.xpm @@ -0,0 +1,31 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char *tools_xpm[]; + +#else +char *tools_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 3 1", +"- c Blue", +"X c Gray100", +" c None", + +/* pixels */ +"XXXXXXX XXXXXXX", +"XXXXXXX XXXXXXX", +"X-----X XXXXXXX", +"X-----X X-----X", +"XXXXXXX X-----X", +"XXXXXXX XXXXXXX", +"X-----X XXXXXXX", +"X-----X XXXXXXX", +"XXXXXXX XXXXXXX", +"XXXXXXX X-----X", +"XXXXXXX X-----X", +"X-----X XXXXXXX", +"X-----X XXXXXXX", +"XXXXXXX X-----X", +"XXXXXXX XXXXXXX" +}; +#endif + diff --git a/bitmaps/transistor.xpm b/bitmaps/transistor.xpm new file mode 100644 index 0000000000..6a0e5c4123 --- /dev/null +++ b/bitmaps/transistor.xpm @@ -0,0 +1,41 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *transistor_xpm[]; + +#else +char * transistor_xpm[] = +{ +"16 15 16 1", +" c none", +". c #050305", +"X c Gray15", +"o c #5a5146", +"O c #191a19", +"+ c #8e8d8c", +"@ c #eaeaea", +"# c #dcdddc", +"$ c #66625f", +"% c #5c442c", +"& c #49372c", +"* c #b2b4b2", +"= c #fb7904", +"- c #97500c", +"; c #c5c6c5", +": c #4a2b10", +" .... . ", +" ..XXooXOO.. ", +" .O+ @+O. ", +" .X#$%&# *.. ", +".O# o=-; $$;O.", +"O+ o=-; *&; +O", +"X# o=-*$$@ #X", +"O o=-X; O", +"X o=-o+ #@ O", +"O@ o=-;+$*:+ @O", +"O* o=-; +:=% *O", +".X@ o=-; o&-:;X.", +" .o $-:; ;%O. ", +" OX*#@ ;X. ", +" .OX$++$XO.. " +}; +#endif diff --git a/bitmaps/treensel.xpm b/bitmaps/treensel.xpm new file mode 100644 index 0000000000..4876fc6f3c --- /dev/null +++ b/bitmaps/treensel.xpm @@ -0,0 +1,35 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *tree_nosel_xpm[]; + +#else +char *tree_nosel_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 6 1", +" c Gray0", +"X c #7b7b7b", +"O c Red", +"# c White", +"+ c Yellow", +"@ c None", + +/* pixels */ +"@@@@@@@@@@@@@@@@", +"@@@@@@@@@@@@@@@@", +"@@@@@@@@@@@@@@@@", +"@@@@X X@@@@@@", +"@@@ OOOO @@@@@", +"@@X +#OOOO X@@@@", +"@@ O#+OOOOO @@@@", +"@@ OOOOOOOO @@@@", +"@@ OOOOOO+O X@@@", +"@@ OOOOO++O X@@@", +"@@X OOO++O XX@@@", +"@@@ OOOO XXX@@", +"@@@@X XXXX@@@", +"@@@@@@@XXXXXX@@@", +"@@@@@@@@@@X@@@@@" +}; + +#endif + diff --git a/bitmaps/treesel.xpm b/bitmaps/treesel.xpm new file mode 100644 index 0000000000..eb8bf65029 --- /dev/null +++ b/bitmaps/treesel.xpm @@ -0,0 +1,29 @@ +/* XPM */ +static char *tree_sel_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 6 1", +" c Gray0", +"X c #7b7b7b", +"O c Green", +"# c White", +"+ c Yellow", +"@ c None", + +/* pixels */ +"@@@@@@@@@@@@@@@@", +"@@@@@@@@@@@@@@@@", +"@@@@@@@@@@@@@@@@", +"@@@@X X@@@@@@", +"@@@ OOOO @@@@@", +"@@X +#OOOO X@@@@", +"@@ O#+OOOOO @@@@", +"@@ OOOOOOOO @@@@", +"@@ OOOOOO+O X@@@", +"@@ OOOOO++O X@@@", +"@@X OOO++O XX@@@", +"@@@ OOOO XXX@@", +"@@@@X XXXX@@@", +"@@@@@@@XXXXXX@@@", +"@@@@@@@@@@X@@@@@" +}; + diff --git a/bitmaps/undelete.xpm b/bitmaps/undelete.xpm new file mode 100644 index 0000000000..10368c1846 --- /dev/null +++ b/bitmaps/undelete.xpm @@ -0,0 +1,117 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *undelete_xpm[]; + +#else +char * undelete_xpm[] = { +"16 16 93 2", +" c None", +". c #000000", +"+ c #FFFFFF", +"@ c #2A2A2A", +"# c #EFEFEF", +"$ c #267726", +"% c #CCCCCC", +"& c #0F0F0F", +"* c #F4F4F4", +"= c #CDCDCA", +"- c #A7A7A2", +"; c #E1E1E0", +"> c #45453F", +", c #47473E", +"' c #515147", +") c #D3D3D2", +"! c #5F5F56", +"~ c #44443C", +"{ c #111111", +"] c #919185", +"^ c #DADAD7", +"/ c #EBEBEB", +"( c #EDEDED", +"_ c #BBC2CC", +": c #1C1C1C", +"< c #A6A699", +"[ c #828276", +"} c #79796E", +"| c #4E4E45", +"1 c #181818", +"2 c #ADAD9F", +"3 c #8F8F81", +"4 c #C6C6BD", +"5 c #88887B", +"6 c #090909", +"7 c #818173", +"8 c #D1D1C9", +"9 c #858577", +"0 c #A4A494", +"a c #646454", +"b c #7F7F71", +"c c #4D4D3F", +"d c #68685B", +"e c #4A4023", +"f c #ABAB9E", +"g c #CDCDC6", +"h c #A9A999", +"i c #666656", +"j c #7D7D6F", +"k c #49493C", +"l c #636358", +"m c #5A491D", +"n c #ACAC9F", +"o c #878779", +"p c #CECEC4", +"q c #89897D", +"r c #A8A89A", +"s c #656558", +"t c #79796B", +"u c #434336", +"v c #5D5D53", +"w c #5D4B1B", +"x c #A9A99B", +"y c #CACAC1", +"z c #A5A596", +"A c #616156", +"B c #77776B", +"C c #47473B", +"D c #535349", +"E c #614F20", +"F c #C7C7BE", +"G c #B1B1A3", +"H c #B2B2A9", +"I c #8F8F7D", +"J c #888880", +"K c #67675A", +"L c #65655F", +"M c #675B36", +"N c #493A12", +"O c #010101", +"P c #8B8B7C", +"Q c #79796A", +"R c #6C6C5E", +"S c #646459", +"T c #545448", +"U c #424238", +"V c #272720", +"W c #564210", +"X c #020202", +"Y c #040404", +"Z c #060606", +"` c #050505", +" . c #030303", +" . . . . . . . . . ", +" . + + + + + + + . ", +" @ @ @ . + # $ $ $ $ % . ", +" & @ * = - . + # # $ $ $ % . ", +" @ ; > , ' . + # $ $ $ $ % . ", +" @ ) ! ~ ' . + $ $ $ # $ % . ", +" { ] ^ / ( . + _ $ # # # % . ", +" : < [ } | . + % % % % % % 1 ", +" : 2 3 4 5 . . 6 . . . . . . ", +" : 2 7 8 9 0 a b c d e . ", +" : f 9 g 5 h i j k l m . ", +" { n o p q r s t u v w . ", +" . x 5 y 5 z A B C D E . ", +" . n F G H I J K L M N . ", +" O P Q R S T U V W . . ", +" X Y Z ` .X . . "}; +#endif diff --git a/bitmaps/undo.xpm b/bitmaps/undo.xpm new file mode 100644 index 0000000000..0fed7a3db5 --- /dev/null +++ b/bitmaps/undo.xpm @@ -0,0 +1,31 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *undo_xpm[]; + +#else +char *undo_xpm[] = { +/* width height num_colors chars_per_pixel */ +"16 16 4 1", +/* colors */ +" c None", +"X c #0000E0", +"a c #808080", +". c #404040", +/* pixels */ +" ", +" ", +" ", +" ", +" ..XXXXa ", +"..X ..XX....Xa ", +"..XX X.. ...XX ", +"..XXX ..XX ", +"..XXXX ..XX ", +"..XXXXX ..XX ", +"....... ..XXa ", +" ..aXXX ", +" ", +" ", +" ", +" "}; +#endif diff --git a/bitmaps/unit_inch.xpm b/bitmaps/unit_inch.xpm new file mode 100644 index 0000000000..023901f3cf --- /dev/null +++ b/bitmaps/unit_inch.xpm @@ -0,0 +1,43 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *unit_inch_xpm[]; + +#else +char * unit_inch_xpm[] = { +"16 16 19 1", +" c None", +". c #3F3F9B", +"+ c #9B9B9B", +"@ c #000000", +"# c #010101", +"$ c #232323", +"% c #666666", +"& c #111111", +"* c #252525", +"= c #0D0D0D", +"- c #747474", +"; c #878787", +"> c #131313", +", c #585858", +"' c #565656", +") c #0B0B0B", +"! c #272727", +"~ c #5E5E5E", +"{ c #949494", +" ", +" .... ", +" ..++ ", +" ..+ ", +" ..+ ", +" ..+ ", +" ..+ ", +" .... ", +" ++++ ", +" @ #$ ", +" @%+ &* ", +" @@@@@@@@@@@@@@ ", +" =-++++++++;>,+", +" ') @!+ ", +" ~{ + ", +" "}; +#endif diff --git a/bitmaps/unit_mm.xpm b/bitmaps/unit_mm.xpm new file mode 100644 index 0000000000..fd04656fa6 --- /dev/null +++ b/bitmaps/unit_mm.xpm @@ -0,0 +1,47 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *unit_mm_xpm[]; + +#else +char * unit_mm_xpm[] = { +"16 16 23 1", +" c None", +"! c black", +"# c #FF0000", +"$ c #FF4848", +"% c #9B9B9B", +"& c #98989B", +"' c #99999B", +"( c #9A9A9B", +") c #010101", +"* c #232323", +"+ c #666666", +", c #111111", +"- c #252525", +". c #0D0D0D", +"0 c #747474", +"1 c #878787", +"2 c #131313", +"3 c #585858", +"4 c #565656", +"5 c #0B0B0B", +"6 c #272727", +"7 c #5E5E5E", +"8 c #949494", +" ", +" ", +" ## ## ## ## ", +"#$$#$$# #$$#$$# ", +"#%%#%%#%#%%#&%#'", +"#% #% #%#% #' #'", +"#% #% #%#% #( #&", +" % % % % % %", +" ", +" ! )* ", +" !+% ,- ", +" !!!!!!!!!!!!!!)", +" .0%%%%%%%%123%", +" 45 !6% ", +" 78 % ", +" "}; +#endif diff --git a/bitmaps/up.xpm b/bitmaps/up.xpm new file mode 100644 index 0000000000..754ffd5509 --- /dev/null +++ b/bitmaps/up.xpm @@ -0,0 +1,50 @@ +/* XPM */ +#ifndef XPMMAIN +extern char *up_xpm[]; + +#else +char * up_xpm[] = { +"16 16 26 1", +" c None", +". c #1C2D3D", +"+ c #000000", +"@ c #C5D5E4", +"# c #C4D4E3", +"$ c #9FB9D2", +"% c #2A435B", +"& c #9CB7D1", +"* c #A0BAD3", +"= c #3F6588", +"- c #A6BED5", +"; c #A4BDD5", +"> c #9EB8D1", +", c #A3BCD4", +"' c #AAC1D7", +") c #ABC2D8", +"! c #29425A", +"~ c #AFC5DA", +"{ c #9BB6D0", +"] c #AEC4D9", +"^ c #9AB5CF", +"/ c #6892B9", +"( c #49759E", +"_ c #4B78A2", +": c #34536F", +"< c #2D4760", +" ", +" . ", +" +@+ ", +" +#$%+ ", +" +#&*=%+ ", +" +#-;>==%+ ", +" +#,',>===%+ ", +" ++++)$&=!++++ ", +" +~{$=!+ ", +" +){$=!+ ", +" +]$$=!+ ", +" +,^$=!+ ", +" +/(_:<+ ", +" +++++++ ", +" ", +" "}; +#endif diff --git a/bitmaps/zoom.xpm b/bitmaps/zoom.xpm new file mode 100644 index 0000000000..b28a14748d --- /dev/null +++ b/bitmaps/zoom.xpm @@ -0,0 +1,29 @@ +/* XPM bitmap */ +#ifndef XPMMAIN +extern char * zoom_xpm[]; + +#else +char * zoom_xpm[] = { +"16 16 3 1", +" c None", +". c #00A000", +"X c #A0C0A0", +" .... ", +" ..XXXX.. ", +" .XXXXXXXX. ", +" .XXXXXXXX. ", +".XXXXXXXXXX. ", +".XXXXXXXXXX. ", +".XXXXXXXXXX. ", +".XXXXXXXXXX. ", +" .XXXXXXXX. ", +" .XXXXXXXX. ", +" ..XXXX... ", +" .... ... ", +" ... ", +" ... ", +" ... ", +" .. " +}; +#endif + diff --git a/common/base_screen.cpp b/common/base_screen.cpp new file mode 100644 index 0000000000..c5057ee5c9 --- /dev/null +++ b/common/base_screen.cpp @@ -0,0 +1,482 @@ + /******************************************************************/ + /* drawpanel.cpp - fonctions des classes du type WinEDA_DrawPanel */ + /******************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" +#include "common.h" + + +/* defines locaux */ +#define CURSOR_SIZE 12 /* taille de la croix du curseur PCB */ + + /*******************************************************/ + /* Class BASE_SCREEN: classe de gestion d'un affichage */ + /*******************************************************/ +BASE_SCREEN::BASE_SCREEN(int idscreen): EDA_BaseStruct(SCREEN_STRUCT_TYPE) +{ + EEDrawList = NULL; /* Schematic items list */ + m_Type = idscreen; + m_ZoomList = NULL; + m_GridList = NULL; + m_UndoList = NULL; + m_RedoList = NULL; + m_UndoRedoCountMax = 1; + m_FirstRedraw = TRUE; + InitDatas(); +} + + +/******************************/ +BASE_SCREEN::~BASE_SCREEN(void) +/******************************/ +{ + if ( m_ZoomList ) free(m_ZoomList); + if ( m_GridList ) free(m_GridList); + ClearUndoRedoList(); +} + +/*******************************/ +void BASE_SCREEN::InitDatas(void) +/*******************************/ +{ + m_SheetNumber = m_NumberOfSheet = 1; /* gestion hierarchie: Root: SheetNumber = 1 */ + m_Zoom = 32; + m_Grid = wxSize(50,50); /* pas de la grille */ + m_UserGrid = g_UserGrid; /* pas de la grille "utilisateur" */ + m_UserGridIsON = FALSE; + m_UserGridUnit = g_UserGrid_Unit; + m_Diviseur_Grille = 1; + m_Center = TRUE; + + /* offsets pour tracer le circuit sur l'ecran */ + switch (m_Type ) // Init taille sheet par defaut + { + case SCHEMATIC_FRAME : + m_Center = FALSE; + m_CurrentSheet = &g_Sheet_A4; + break; + + default: + case CVPCB_DISPLAY_FRAME: + case MODULE_EDITOR_FRAME: + case PCB_FRAME: + m_CurrentSheet = &g_Sheet_A3; + break; + + case GERBER_FRAME: + m_CurrentSheet = &g_Sheet_GERBER; + break; + } + + if ( m_Center ) + { + m_Curseur.x = m_Curseur.y = 0; + m_DrawOrg.x = - ReturnPageSize().x/2; + m_DrawOrg.y = - ReturnPageSize().y/2; + } + else + { + m_DrawOrg.x = m_DrawOrg.y = 0; + m_Curseur.x = ReturnPageSize().x/2; + m_Curseur.y = ReturnPageSize().y/2; + } + + // DrawOrg est rendu multiple du zoom min : + m_DrawOrg.x -= m_DrawOrg.x % 256; m_DrawOrg.y -= m_DrawOrg.y % 256; + + m_O_Curseur = m_Curseur; + + m_CurrentItem = NULL; + + /* indicateurs divers */ + m_FlagRefreshReq = 0; /* indique que l'ecran doit redessine */ + m_FlagModified = 0; // indique modif du PCB,utilise pour eviter une sortie sans sauvegarde + m_FlagSave = 1; // indique sauvegarde auto faite +} + + +/***************************************/ +int BASE_SCREEN::GetInternalUnits(void) +/***************************************/ +{ + switch (m_Type ) + { + default: + case SCHEMATIC_FRAME : + return EESCHEMA_INTERNAL_UNIT; + break; + + case GERBER_FRAME: + case CVPCB_DISPLAY_FRAME: + case MODULE_EDITOR_FRAME: + case PCB_FRAME: + return PCB_INTERNAL_UNIT; + } +} + +/*****************************************/ +wxSize BASE_SCREEN::ReturnPageSize(void) +/*****************************************/ +/* Retourne en unites internes la taille de la feuille de dessin + (la taille de la feuille est connue en 1/1000 ") +*/ +{ +wxSize PageSize; + + switch (m_Type ) + { + default: + case SCHEMATIC_FRAME : + PageSize = m_CurrentSheet->m_Size; + break; + + case GERBER_FRAME: + case CVPCB_DISPLAY_FRAME: + case MODULE_EDITOR_FRAME: + case PCB_FRAME: + PageSize.x = m_CurrentSheet->m_Size.x * (PCB_INTERNAL_UNIT/1000); + PageSize.y = m_CurrentSheet->m_Size.y * (PCB_INTERNAL_UNIT/1000); + break; + } + + return PageSize; +} + + +/********************************************/ +void BASE_SCREEN::SetZoomList(int * zoomlist) +/********************************************/ +/* init liste des zoom (NULL terminated) +*/ +{ +int ii, nbitems, * zoom; + // Decompte des items + for ( nbitems = 1, zoom = zoomlist; ; zoom ++, nbitems++ ) + { + if ( *zoom == 0 ) break; + } + + // Init liste + if ( m_ZoomList ) free(m_ZoomList); + m_ZoomList = (int*) MyZMalloc( nbitems * sizeof ( int) ); + + for ( ii = 0, zoom = zoomlist; ii < nbitems; zoom ++, ii++ ) + { + m_ZoomList[ii] = *zoom; + } +} + +/***********************************/ +void BASE_SCREEN::SetFirstZoom(void) +/***********************************/ +/* ajuste le coeff de zoom a 1*/ +{ + m_Zoom = 1; +} + + +/****************************/ +int BASE_SCREEN::GetZoom(void) +/****************************/ +/* retourne le coeff de zoom */ +{ + return m_Zoom; +} + +/***********************************/ +void BASE_SCREEN::SetZoom(int coeff) +/***********************************/ +/* ajuste le coeff de zoom a coeff */ +{ + m_Zoom = coeff; + if ( m_Zoom < 1 ) m_Zoom = 1; +} + + +/********************************/ +void BASE_SCREEN::SetNextZoom(void) +/********************************/ +/* Selectionne le prochain coeff de zoom +*/ +{ + m_Zoom *= 2; + + if ( m_ZoomList == NULL ) return; + +int ii, zoom_max = 512; + for ( ii = 0; m_ZoomList[ii] != 0; ii ++ ) zoom_max = m_ZoomList[ii]; + if ( m_Zoom > zoom_max ) m_Zoom = zoom_max; +} + + +/*************************************/ +void BASE_SCREEN::SetPreviousZoom(void) +/*************************************/ +/* Selectionne le precedent coeff de zoom +*/ +{ + m_Zoom /= 2; + if ( m_Zoom < 1 ) m_Zoom = 1; +} + + +/**********************************/ +void BASE_SCREEN::SetLastZoom(void) +/**********************************/ +/* ajuste le coeff de zoom au max +*/ +{ + if ( m_ZoomList == NULL ) return; +int ii; + for ( ii = 0; m_ZoomList[ii] != 0; ii ++ ) m_Zoom = m_ZoomList[ii]; +} + + +/********************************************/ +void BASE_SCREEN::SetGridList(wxSize * gridlist) +/********************************************/ +/* init liste des zoom (NULL terminated) +*/ +{ +int ii, nbitems; +wxSize * grid; + // Decompte des items + for ( nbitems = 0, grid = gridlist; ; grid ++, nbitems++ ) + { + if ( (grid->x <= 0) || (grid->y <= 0) ) break; + } + + // Init liste + if ( m_GridList ) free(m_GridList); + m_GridList = (wxSize*) MyZMalloc( nbitems * sizeof (wxSize) ); + + for ( ii = 0, grid = gridlist; ii < nbitems; grid ++, ii++ ) + { + m_GridList[ii] = *grid; + } +} + +/**********************************************/ +void BASE_SCREEN::SetGrid( const wxSize & size ) +/**********************************************/ +{ + if ( m_GridList == NULL ) return; + + if ( (size.x <= 0) || (size.y <= 0) ) + { + m_UserGrid = g_UserGrid; + m_UserGridIsON = TRUE; + } + else + { + m_Grid = size; + m_UserGridIsON = FALSE; + } +} + +/*********************************/ +wxSize BASE_SCREEN::GetGrid(void) +/*********************************/ +{ +wxSize grid = m_Grid; +double xx, scale; + + if ( m_GridList == NULL ) return wxSize(1,1); + + if ( m_UserGridIsON || m_Grid.x < 0 || m_Grid.y < 0 ) + { + if ( m_UserGridUnit == INCHES ) scale = 10000; + else scale = 10000/25.4; + xx = m_UserGrid.x * scale; + grid.x = (int)(xx + 0.5); + xx = m_UserGrid.y * scale; + grid.y = (int)(xx + 0.5); + } + return grid; +} + + +/*********************************/ +void BASE_SCREEN::SetNextGrid(void) +/*********************************/ +/* Selectionne la prochaine grille +*/ +{ +int ii; + + if ( m_GridList == NULL ) return; + + for ( ii = 0; ; ii++ ) + { + if ( m_GridList[ii].x <= 0 ) break; + if ( (m_Grid.x == m_GridList[ii].x) && (m_Grid.y == m_GridList[ii].y) ) + break; + } + if ( (m_GridList[ii].x > 0) && (ii > 0) ) + m_Grid = m_GridList[ii - 1]; +} + + +/*************************************/ +void BASE_SCREEN::SetPreviousGrid(void) +/*************************************/ +/* Selectionne le precedent coeff de grille +*/ +{ +int ii; + + if ( m_GridList == NULL ) return; + + for ( ii = 0; ; ii++ ) + { + if ( m_GridList[ii].x <= 0 ) break; + if ( (m_Grid.x == m_GridList[ii].x) && (m_Grid.y == m_GridList[ii].y) ) + break; + } + if ( (m_GridList[ii].x > 0) && (m_GridList[ii+1].x > 0) ) + m_Grid = m_GridList[ii + 1]; +} + + +/**********************************/ +void BASE_SCREEN::SetFirstGrid(void) +/**********************************/ +/* ajuste le coeff de grille a 1 +*/ +{ + if ( m_GridList == NULL ) return; + +int ii = 0; + while ( m_GridList[ii].x > 0 ) ii ++; + m_Grid = m_GridList[ii-1]; +} + + + +/**********************************/ +void BASE_SCREEN::SetLastGrid(void) +/**********************************/ +/* ajuste le coeff de grille au max +*/ +{ + if ( m_GridList == NULL ) return; + m_Grid = m_GridList[0]; +} + + +/*****************************************/ +void BASE_SCREEN::ClearUndoRedoList(void) +/*****************************************/ +/* free the undo and the redo lists +*/ +{ +EDA_BaseStruct *nextitem; + + while ( m_UndoList ) + { + nextitem = m_UndoList->Pnext; + delete m_UndoList; + m_UndoList = nextitem; + } + + while ( m_RedoList ) + { + nextitem = m_RedoList->Pnext; + delete m_RedoList; + m_RedoList = nextitem; + } + +} + +/***********************************************************/ +void BASE_SCREEN::AddItemToUndoList(EDA_BaseStruct * newitem) +/************************************************************/ +/* Put newitem in head of undo list + Deletes olds items if > count max. +*/ +{ +int ii; +EDA_BaseStruct * item, *nextitem; + + if ( newitem == NULL ) return; + + newitem->Pnext = m_UndoList; + m_UndoList = newitem; + + /* Free first items, if count max reached */ + for ( ii = 0, item = m_UndoList; ii < m_UndoRedoCountMax; ii++ ) + { + if ( item->Pnext == NULL ) return; + item = item->Pnext; + } + + if ( item == NULL ) return; + + nextitem = item->Pnext; + item->Pnext = NULL; // Set end of chain + + // Delete the extra items + for(item = nextitem ; item != NULL; item = nextitem ) + { + nextitem = item->Pnext; + delete item; + } + +} + +/***********************************************************/ +void BASE_SCREEN::AddItemToRedoList(EDA_BaseStruct * newitem) +/***********************************************************/ +{ +int ii; +EDA_BaseStruct * item, *nextitem; + + if ( newitem == NULL ) return; + + newitem->Pnext = m_RedoList; + m_RedoList = newitem; + /* Free first items, if count max reached */ + for ( ii = 0, item = m_RedoList; ii < m_UndoRedoCountMax; ii++ ) + { + if ( item->Pnext == NULL ) break; + item = item->Pnext; + } + + if ( item == NULL ) return; + + nextitem = item->Pnext; + item->Pnext = NULL; // Set end of chain + + // Delete the extra items + for(item = nextitem ; item != NULL; item = nextitem ) + { + nextitem = item->Pnext; + delete item; + } + +} + +/*****************************************************/ +EDA_BaseStruct * BASE_SCREEN::GetItemFromUndoList(void) +/*****************************************************/ +{ +EDA_BaseStruct * item = m_UndoList; + + if ( item ) m_UndoList = item->Pnext; + return item; +} + +/******************************************************/ +EDA_BaseStruct * BASE_SCREEN::GetItemFromRedoList(void) +/******************************************************/ +{ +EDA_BaseStruct * item = m_RedoList; + + if ( item ) m_RedoList = item->Pnext; + return item; +} + diff --git a/common/base_struct.cpp b/common/base_struct.cpp new file mode 100644 index 0000000000..0bfae13348 --- /dev/null +++ b/common/base_struct.cpp @@ -0,0 +1,681 @@ + /********************************************************/ + /* methodes pour les structures de base: */ + /* EDA_BaseStruct (classe non utilisable seule) */ + /* EDA_TextStruct (classe non utilisable seule) */ + /********************************************************/ + + /* Fichier base_struct.cpp */ + +#include "fctsys.h" +#include "gr_basic.h" +#include "trigo.h" +#include "common.h" +#include "wxstruct.h" +#include "base_struct.h" +#include "grfonte.h" + +#include "macros.h" + + +// DrawStructureType names for error messages only: +static wxString DrawStructureTypeName[MAX_STRUCT_TYPE_ID+1] + = { +wxT("Not init"), + +wxT("Pcb"), +wxT("Equipot"), +wxT("Module"), +wxT("Pad"), +wxT("DrawSegment"), +wxT("Text (pcb)"), +wxT("Text module"), +wxT("edge module"), +wxT("track"), +wxT("zone"), +wxT("via"), +wxT("marker"), +wxT("cotation"), +wxT("mire"), +wxT("screen"), +wxT("block"), +wxT("edge zone"), + +wxT("Polyline"), +wxT("Junction"), +wxT("Text"), +wxT("Label"), +wxT("Glob label"), +wxT("Lib item"), +wxT("Pick struct"), +wxT("Segment"), +wxT("Raccord"), +wxT("Sheet"), +wxT("Sheet label"), +wxT("Marker"), +wxT("No connect"), +wxT("Text (lib item)"), +wxT("Screen"), +wxT("Block locate"), +wxT("Library component"), +wxT("lib cmp draw circle"), +wxT("lib cmp draw graphic text"), +wxT("lib cmp draw rect"), +wxT("lib cmp draw poly line"), +wxT("lib cmp draw line"), +wxT("lib cmp pin"), +wxT("lib cmp field"), +wxT("unknown"), +wxT("unknown") +}; + + + + +enum textbox { + ID_TEXTBOX_LIST = 8010 +}; + + +/******************************************************************************/ +EDA_BaseStruct::EDA_BaseStruct(EDA_BaseStruct * parent, int idType) +/******************************************************************************/ +{ + InitVars(); + m_StructType = idType; + m_Parent = parent; /* Chainage hierarchique sur struct racine */ +} + + +/********************************************/ +EDA_BaseStruct::EDA_BaseStruct(int idType) +/********************************************/ +{ + InitVars(); + m_StructType = idType; +} + +/********************************************/ +void EDA_BaseStruct::InitVars(void) +/********************************************/ +{ + m_StructType = TYPE_NOT_INIT; + Pnext = NULL; /* Linked list: Link (next struct) */ + Pback = NULL; /* Linked list: Link (previous struct) */ + m_Parent = NULL; /* Linked list: Link (parent struct) */ + m_Son = NULL; /* Linked list: Link (son struct) */ + m_Image = NULL; /* Link to an image copy for undelete or abort command */ + m_Flags = 0; /* flags for editions and other */ + m_TimeStamp = 0; // Time stamp used for logical links + m_Status = 0; + m_Selected = 0; /* Used by block commands, and selective editing */ +} + + +/* Gestion de l'etat (status) de la structure (active, deleted..) */ +int EDA_BaseStruct::GetState(int type) +{ + return(m_Status & type); +} + +void EDA_BaseStruct::SetState(int type, int state ) +{ + if( state ) m_Status |= type; /* state = ON ou OFF */ + else m_Status &= ~type; +} + + +/*********************************************************/ +void EDA_BaseStruct::AddToChain(EDA_BaseStruct * laststruct) +/*********************************************************/ +/* +addition d'une nouvelle struct a la liste chainée, apres la structure laststruct +*/ +{ + Pnext = laststruct->Pnext; + Pback = laststruct; + laststruct->Pnext = this; +} + + +/**************************************************************************************/ +void EDA_BaseStruct::Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, + int draw_mode, int Color) +/**************************************************************************************/ +/* Virtual +*/ +{ + wxString msg, name; + msg.Printf( wxT("EDA_BaseStruct::Draw() error. Method for struct type %d used but not implemented ("), + m_StructType); + msg += ReturnClassName() + wxT(")\n"); + printf ( CONV_TO_UTF8(msg)); +} + +#if 0 +/**************************************************************/ +void EDA_BaseStruct::Place(WinEDA_DrawFrame * frame, wxDC * DC) +/**************************************************************/ +/* fonction virtuelle de placement: non utilisee en pcbnew (utilisee eeschema) +---- A mieux utiliser (TODO...) +*/ +{ +} +#endif + +/*********************************************/ +wxString EDA_BaseStruct::ReturnClassName(void) +/*********************************************/ +/* Used at run time for diags: return the class name of the item, + from its .m_StructType value. +*/ +{ +int ii = m_StructType; +wxString classname; + + if ( (ii < 0) || (ii > MAX_STRUCT_TYPE_ID) ) ii = MAX_STRUCT_TYPE_ID; + classname = DrawStructureTypeName[ii]; + + return classname; +} + + + +/**********************************************************************************************/ +EDA_BaseLineStruct::EDA_BaseLineStruct(EDA_BaseStruct * StructFather, DrawStructureType idtype): + EDA_BaseStruct(StructFather, idtype) +/**********************************************************************************************/ +{ + m_Layer = 0; + m_Width = 0; // 0 = line, > 0 = tracks, bus ... +}; + + +/*********************************************************/ +/* EDA_TextStruct (classe de base, non utilisée seule */ +/*********************************************************/ +EDA_TextStruct::EDA_TextStruct(const wxString & text) +{ + m_Layer = 0; + m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT; /* XY size of font */ + m_Orient = 0; /* Orient in 0.1 degrees */ + m_Attributs = 0; + m_Miroir = 0; // vue normale / miroir + m_HJustify = GR_TEXT_HJUSTIFY_CENTER; + m_VJustify = GR_TEXT_VJUSTIFY_CENTER; /* Justifications Horiz et Vert du texte */ + m_Width = 0; /* epaisseur du trait */ + m_CharType = 0; /* normal, bold, italic ... */ + m_Text = text; + m_ZoomLevelDrawable = 0; /* Niveau de zoom acceptable pour affichage normal */ + m_TextDrawings = NULL; /* Pointeur sur le dessin du caractere */ + m_TextDrawingsSize = 0; /* taille du tableau pointé */ +} + + +EDA_TextStruct::~EDA_TextStruct(void) +{ + if( m_TextDrawings ) /* pointeur sur la liste des segments de dessin */ + { + free(m_TextDrawings); m_TextDrawings = NULL; + } + m_TextDrawingsSize = 0; /* nombre de sommets a dessiner */ +} + +/********************************/ +int EDA_TextStruct::Len_Size(void) +/********************************/ +// Return the text lenght in internal units +{ +int nbchar = m_Text.Len(); +int len; + if ( nbchar == 0 ) return 0; + + len = ((10 * m_Size.x ) / 9) * nbchar; + return len; +} + + +/*************************************************/ +int EDA_TextStruct::Locate(const wxPoint & posref) +/*************************************************/ +/* locate function + return: + 1 if posref is inside the text area. + 0 else. +*/ +{ +int dx, dy; +int spot_cX, spot_cY; + + dx = (Pitch() * GetLength()) / 2; + dy = m_Size.y /2 ; + + /* Is the ref point inside the text area ? */ + spot_cX = posref.x - m_Pos.x ; spot_cY = posref.y - m_Pos.y ; + RotatePoint(&spot_cX, &spot_cY, - m_Orient); + if( (abs(spot_cX) <= abs(dx) ) && ( abs(spot_cY) <= abs(dy) ) ) return 1; + return 0; +} + +/*******************************/ +int EDA_TextStruct::Pitch(void) +/*******************************/ +/* retourne le pas entre 2 caracteres +*/ +{ + return ((10 * m_Size.x ) / 9) + m_Width; +} + +/***************************************************************/ +void EDA_TextStruct::Draw(WinEDA_DrawPanel * panel, wxDC * DC, + const wxPoint & offset, int color, int draw_mode, + int display_mode, int anchor_color) +/***************************************************************/ +/* + Trace de 1 texte type EDA_TextStruct. + offset = Offset de trace (usuellement (0,0) + color = couleur du texte + draw_mode = GR_OR, GR_XOR.., -1 si mode courant. + display_mose = FILAIRE, FILLED ou SKETCH + anchor_color = couleur de l'ancre ( -1 si pas d'ancre ). +*/ +{ +int zoom; +int coord[104]; +int ii, jj, kk, ll, nbpoints; +int width; + + if( m_TextDrawings == NULL) /* pointeur sur la liste des segments de dessin */ + CreateDrawData(); + if( m_TextDrawings == NULL) return; + + zoom = panel->GetZoom(); + width = m_Width / zoom; + if ( display_mode == FILAIRE ) width = 0; + /* choix de la couleur du texte : */ + if ( draw_mode != -1 ) GRSetDrawMode(DC, draw_mode); + + /* trace du texte */ + if ( zoom > m_ZoomLevelDrawable) + { + GRLine(&panel->m_ClipBox, DC, + m_TextDrawings[1] + offset.x + m_Pos.x, + m_TextDrawings[2] + offset.y + m_Pos.y, + m_TextDrawings[3] + offset.x + m_Pos.x, + m_TextDrawings[4] + offset.y + m_Pos.y, + color); + } + + else + { + /* trace ancre du texte ? */ + if( anchor_color != -1) + { + int anchor_size = 2 * zoom; + anchor_color &= MASKCOLOR; + /* calcul de la position du texte */ + int cX = m_Pos.x - offset.x; + int cY = m_Pos.y - offset.y; + /* trace ancre du texte */ + GRLine(&panel->m_ClipBox, DC, cX - anchor_size, cY, + cX + anchor_size, cY, anchor_color); + GRLine(&panel->m_ClipBox, DC, cX, cY - anchor_size , + cX, cY + anchor_size , anchor_color); + } + jj = 5; ii = jj+1; + while (ii < m_TextDrawingsSize) + { + nbpoints = m_TextDrawings[jj]; + if (nbpoints > 50 ) nbpoints = 50; + for ( kk = 0, ll = 0; (kk < nbpoints) && (ii < m_TextDrawingsSize) ; kk++) + { + coord[ll] = m_TextDrawings[ii] + offset.x + m_Pos.x; + ll++; ii++; + coord[ll] = m_TextDrawings[ii] + offset.y + m_Pos.y; + ll++; ii++; + } + jj = ii; ii++; + + if( width > 2) + { + for ( kk = 0, ll = 0; kk < (nbpoints-1); kk ++, ll+= 2 ) + { + if( display_mode == SKETCH) + GRCSegm(&panel->m_ClipBox, DC, + coord[ll],coord[ll+1], + coord[ll+2],coord[ll+3], + m_Width, color) ; + + else GRFillCSegm(&panel->m_ClipBox, DC, + coord[ll],coord[ll+1], + coord[ll+2],coord[ll+3], + m_Width, color) ; + } + } + else + GRPoly(&panel->m_ClipBox, DC, nbpoints, coord, 0, color, color); + + } + } +} + +/****************************************/ +void EDA_TextStruct::CreateDrawData(void) +/****************************************/ +/* Cree le tableau de données nécessaire au trace d'un texte (pcb, module..) + Met a jour: + m_ZoomLevelDrawable Niveau de zoom acceptable pour affichage normal + m_TextDrawings Pointeur sur le tableau de données + m_TextDrawingsSize taille (en int) du tableau + Codage dans le tableau: + Suite des coord des sommets des polygones a tracer précédé du nombre de sommets + nn xx1 yy1 xx2 yy2 .. xxn yyn mm xx1 yy1 xx2 yy2 .. xxm yym + les 2 premiers sommets sont le segment symbolisant le texte pour les + affichages a trop petite echelle +*/ +{ +int ii, jj, kk,nbchar, nbpoints, AsciiCode, endcar; +int k1 , k2 , x0 , y0 ; +int size_h , size_v , espacement ; +char f_cod , plume = 'U'; +const wxChar * ptr; +const SH_CODE * ptcar; +int ux0, uy0, dx, dy; // Coord de trace des segments de texte & variables de calcul */ +int cX, cY; // Centre du texte +int ox, oy; // coord de trace du caractere courant +int * coord; // liste des coord des segments a tracer +int coord_count_max = 1000; + + if( m_TextDrawings ) /* pointeur sur la liste des segments de dessin */ + { + free(m_TextDrawings); m_TextDrawings = 0; + } + m_TextDrawingsSize = 0; /* nombre de segments a dessiner */ + + nbchar = m_Text.Length(); + if ( nbchar == 0 ) return; + + size_h = m_Size.x; + size_v = m_Size.y; + espacement = Pitch(); + if ( m_Miroir == 0 ) + { + size_h = -size_h; espacement = - espacement; + } + + kk = 0; ptr = m_Text.GetData() ; /* ptr pointe 1er caractere du texte */ + + /* calcul de la position du debut des textes: ox et oy */ + ox = cX = 0; oy = cY = 0; + + /* Calcul du cadrage du texte */ + dx = (espacement * nbchar) / 2; + dy = size_v / 2; /* Decalage du debut du texte / centre */ + + ux0 = uy0 = 0; /* Decalage du centre du texte / ccord de ref */ + + if( (m_Orient == 0) || (m_Orient == 1800) ) /* Texte Horizontal */ + { + switch(m_HJustify) + { + case GR_TEXT_HJUSTIFY_CENTER: + break; + + case GR_TEXT_HJUSTIFY_RIGHT: + ux0 = - dx; + break; + + case GR_TEXT_HJUSTIFY_LEFT: + ux0 = dx; + break; + } + + switch(m_VJustify) + { + case GR_TEXT_VJUSTIFY_CENTER: + break; + + case GR_TEXT_VJUSTIFY_TOP: + uy0 = dy; + break; + + case GR_TEXT_VJUSTIFY_BOTTOM: + uy0 = -dy; + break; + } + } + + else /* Texte Vertical */ + { + switch(m_HJustify) + { + case GR_TEXT_HJUSTIFY_CENTER: + break; + + case GR_TEXT_HJUSTIFY_RIGHT: + ux0 = - dy; + break; + + case GR_TEXT_HJUSTIFY_LEFT: + ux0 = dy; + break; + } + + switch(m_VJustify) + { + case GR_TEXT_VJUSTIFY_CENTER: + break; + + case GR_TEXT_VJUSTIFY_TOP: + uy0 = dx; + break; + + case GR_TEXT_VJUSTIFY_BOTTOM: + uy0 = -dx; + break; + } + } + cX += ux0; cY += uy0; + ox = cX - dx; ; oy = cY + dy; + + /* lorsque les chars sont trop petits pour etre dessines, + le texte est symbolise par une barre */ + m_ZoomLevelDrawable = m_Size.x / 3; + dx = (espacement * nbchar) / 2; + dy = size_v / 2; /* Decalage du debut du texte / centre */ + ux0 = cX - dx; uy0 = cY; + dx += cX; dy = cY; + RotatePoint(&ux0, &uy0, cX, cY, m_Orient); + RotatePoint(&dx, &dy, cX, cY, m_Orient); + + coord = (int*) MyMalloc( (coord_count_max+2) * sizeof(int)); + coord[0] = 2; + coord[1] = ux0; coord[2] = uy0; + coord[3] = dx; coord[4] = dy; + + jj = 5; ii = jj+1; nbpoints = 0; + while(kk++ < nbchar) + { + x0 = 0 ; y0 = 0 ; + AsciiCode = (*ptr) & 255; + ptcar = graphic_fonte_shape[AsciiCode] ; /* ptcar pointe la description + du caractere a dessiner */ + + for(endcar = FALSE; ! endcar; ptcar++) + { + f_cod = *ptcar ; /* get code n de la forme selectionnee */ + switch(f_cod) + { + case 'X' : + endcar = TRUE;/* fin du caractere */ + break; + + case 'U' : + if(nbpoints && (plume == 'D' ) ) + { + if ( jj >= coord_count_max ) + { + coord_count_max *= 2; + coord = (int*)realloc( coord, coord_count_max * sizeof(int) ); + } + coord[jj] = nbpoints; + jj = ii; ii++; + } + plume = f_cod; nbpoints = 0; + break; + + case 'D' : + plume = f_cod; + nbpoints = 1; /* 1 point va suivre (origine du tracé) */ + break ; + + default : + { + k1 = f_cod; /* trace sur axe V */ + k1 = - ((k1 * size_v) / 9) ; + ptcar++ ; + f_cod = *ptcar ; + k2 = f_cod; /* trace sur axe H */ + k2 = (k2 * size_h) / 9 ; + dx = k2 + ox; dy = k1 + oy; + RotatePoint(&dx, &dy, cX, cY, m_Orient); + if ( ii >= coord_count_max ) + { + coord_count_max *= 2; + coord = (int*)realloc( coord, coord_count_max * sizeof(int) ); + } + coord[ii] = dx; ii++; coord[ii] = dy; ii++; + nbpoints++; + break ; + } + } /* end switch */ + } /* end boucle for = end trace de 1 caractere */ + + ptr++; ox += espacement; + } /* end trace du texte */ + + m_TextDrawings = (int*) realloc( coord, ii * sizeof(int) ); + m_TextDrawingsSize = ii; //taille (en int) du tableau +} + + + +/******************************/ +void EDA_Rect::Normalize(void) +/******************************/ +// Ensure the height ant width are >= 0 +{ + if ( m_Size.y < 0 ) + { + m_Size.y = - m_Size.y; + m_Pos.y -= m_Size.y; + } + if ( m_Size.x < 0 ) + { + m_Size.x = - m_Size.x; + m_Pos.x -= m_Size.x; + } +} + + +/*******************************************/ +bool EDA_Rect::Inside(const wxPoint & point) +/*******************************************/ +/* Return TRUE if point is in Rect + Accept rect size < 0 +*/ +{ +int rel_posx = point.x - m_Pos.x; +int rel_posy = point.y - m_Pos.y; +wxSize size = m_Size; + + if ( size.x < 0 ) + { + size.x = -size.x; rel_posx += size.x; + } + + if ( size.y < 0 ) + { + size.y = -size.y; rel_posy += size.y; + } + return ( (rel_posx >= 0) && (rel_posy >= 0) + && ( rel_posy <= size.y) + && ( rel_posx <= size.x) + ); +} + +/**************************************************/ +EDA_Rect& EDA_Rect::Inflate(wxCoord dx, wxCoord dy) +/**************************************************/ +{ + if (-2*dx > m_Size.x) + { + // Don't allow deflate to eat more width than we have, + // a well-defined rectangle cannot have negative width. + m_Pos.x += m_Size.x/2; + m_Size.x = 0; + } + else + { + // The inflate is valid. + m_Pos.x-=dx; + m_Size.x += 2*dx; + } + + if (-2*dy > m_Size.y) + { + // Don't allow deflate to eat more height than we have, + // a well-defined rectangle cannot have negative height. + m_Pos.y += m_Size.y / 2; + m_Size.y = 0; + } + else + { + // The inflate is valid. + m_Pos.y -= dy; + m_Size.y += 2*dy; + } + + return *this; +} + + + + /**************************/ + /* class DrawPickedStruct */ + /**************************/ + +/* This class has only one useful member: .m_PickedStruct, used as a link. + It does not describe really an item. + It is used to create a linked list of selected items (in block selection). + Each DrawPickedStruct item has is member: .m_PickedStruct pointing the + real selected item +*/ + +/*******************************************************************/ +DrawPickedStruct::DrawPickedStruct(EDA_BaseStruct *pickedstruct ) : + EDA_BaseStruct(DRAW_PICK_ITEM_STRUCT_TYPE) +/*******************************************************************/ +{ + m_PickedStruct = pickedstruct; +} + +DrawPickedStruct::~DrawPickedStruct(void) +{ +} + + +/*********************************************/ +void DrawPickedStruct::DeleteWrapperList(void) +/*********************************************/ +/* Delete this item all the items of the linked list + Free the wrapper, but DOES NOT delete the picked items linked by .m_PickedStruct +*/ +{ +DrawPickedStruct * wrapp_struct, * next_struct; + + for ( wrapp_struct = Next(); wrapp_struct != NULL; wrapp_struct = next_struct) + { + next_struct = wrapp_struct->Next(); + delete wrapp_struct; + } +} diff --git a/common/basicframe.cpp b/common/basicframe.cpp new file mode 100644 index 0000000000..7ec32250ac --- /dev/null +++ b/common/basicframe.cpp @@ -0,0 +1,274 @@ + /******************************************************************/ + /* basicframe.cpp - fonctions des classes du type WinEDA_BasicFrame */ + /******************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" +#include +#include "common.h" +#include "id.h" + + + /*******************************************************/ + /* Constructeur de WinEDA_BasicFrame: la fenetre generale */ + /*******************************************************/ + +WinEDA_BasicFrame::WinEDA_BasicFrame( wxWindow * father, int idtype, + WinEDA_App *parent, const wxString & title, + const wxPoint& pos, const wxSize& size): + wxFrame(father, -1, title, pos, size, + wxDEFAULT_FRAME_STYLE|wxWANTS_CHARS) +{ +wxSize minsize; + + m_Ident = idtype; + m_Parent = parent; + SetFont(*g_StdFont); + m_MenuBar = NULL; // menu du haut d'ecran + m_HToolBar = NULL; + m_FrameIsActive = FALSE; + m_MsgFrameHeight = MSG_PANEL_DEFAULT_HEIGHT; + + minsize.x = 470; + minsize.y = 350 + m_MsgFrameHeight; + SetSizeHints( minsize.x, minsize.y, -1,-1, -1,-1); + + /* Verification des parametres de creation */ + if ( (size.x < minsize.x) || (size.y < minsize.y) ) + SetSize(0,0, minsize.x, minsize.y); + + // Create child subwindows. + GetClientSize(&m_FrameSize.x, &m_FrameSize.y); /* dimx, dimy = dimensions utiles de la + zone utilisateur de la fenetre principale */ + m_FramePos.x = m_FramePos.y = 0; + m_FrameSize.y -= m_MsgFrameHeight; +} + +/******************************************/ +WinEDA_BasicFrame::~WinEDA_BasicFrame(void) +/******************************************/ +{ + if ( m_Parent->m_HtmlCtrl ) delete m_Parent->m_HtmlCtrl; + m_Parent->m_HtmlCtrl = NULL; +} + +/********************************************/ +void WinEDA_BasicFrame::ReCreateMenuBar(void) +/********************************************/ +// Virtual function +{ +} + + +/*********************************************/ +void WinEDA_BasicFrame::GetSettings(void) +/*********************************************/ +{ +wxString text; +int Ypos_min; + + if( m_Parent->m_EDA_Config ) + { + text = m_FrameName + wxT("Pos_x"); + m_Parent->m_EDA_Config->Read(text, &m_FramePos.x); + text = m_FrameName + wxT("Pos_y"); + m_Parent->m_EDA_Config->Read(text, &m_FramePos.y); + text = m_FrameName + wxT("Size_x"); + m_Parent->m_EDA_Config->Read(text, &m_FrameSize.x, 600); + text = m_FrameName + wxT("Size_y"); + m_Parent->m_EDA_Config->Read(text, &m_FrameSize.y, 400); + } + + // Ensure Window title bar is visible +#ifdef __WXMAC__ + // for macOSX, the window must be below system (macOSX) toolbar + Ypos_min = GetMBarHeight(); +#else + Ypos_min = 0; +#endif + if ( m_FramePos.y < Ypos_min ) m_FramePos.y = Ypos_min; +} + + +/*****************************************/ +void WinEDA_BasicFrame::SaveSettings(void) +/*****************************************/ +{ +wxString text; + + if ( !m_Parent || !m_Parent->m_EDA_Config ) return; + + if( ! m_Parent->m_EDA_Config || IsIconized() ) return; + + m_FrameSize = GetSize(); + m_FramePos = GetPosition(); + + text = m_FrameName + wxT("Pos_x"); + m_Parent->m_EDA_Config->Write(text, (long)m_FramePos.x); + text = m_FrameName + wxT("Pos_y"); + m_Parent->m_EDA_Config->Write(text, (long)m_FramePos.y); + text = m_FrameName + wxT("Size_x"); + m_Parent->m_EDA_Config->Write(text, (long)m_FrameSize.x); + text = m_FrameName + wxT("Size_y"); + m_Parent->m_EDA_Config->Write(text, (long)m_FrameSize.y); +} + + + +/******************************************************/ +void WinEDA_BasicFrame::PrintMsg(const wxString & text) +/******************************************************/ +{ + SetStatusText(text); +} + +/*************************************************************************/ +void WinEDA_BasicFrame::DisplayActivity(int PerCent, const wxString & Text) +/*************************************************************************/ +/* Display a bargraph (0 to 50 point length) for a PerCent value from 0 to 100 +*/ +{ +wxString Line; + + Line = Text; + + PerCent = (PerCent < 0) ? 0 : PerCent; + PerCent = (PerCent > 100) ? 100 : PerCent; + PerCent /= 2; // Bargraph is 0 .. 50 points from 0% to 100% + if (PerCent) Line.Pad(PerCent, '*'); + + SetStatusText(Line); +} + +/*******************************************************************/ +void WinEDA_BasicFrame::SetLastProject(const wxString & FullFileName) +/*******************************************************************/ +/* Met a jour la liste des anciens projets +*/ +{ +unsigned ii; + + if ( FullFileName.IsEmpty() ) return; + + //suppression d'une ancienne trace eventuelle du meme fichier + for ( ii = 0; ii < m_Parent->m_LastProject.GetCount(); ) + { + if(m_Parent->m_LastProject[ii].IsEmpty() ) break; +#ifdef __WINDOWS__ + if ( m_Parent->m_LastProject[ii].CmpNoCase(FullFileName) == 0 ) +#else + if ( m_Parent->m_LastProject[ii] == FullFileName ) +#endif + { +#if ( (wxMAJOR_VERSION < 2) || ((wxMAJOR_VERSION == 2)&& (wxMINOR_VERSION <= 4)) ) + m_Parent->m_LastProject.Remove(ii); +#else + m_Parent->m_LastProject.RemoveAt(ii); +#endif + } + else ii++; + } + + while (m_Parent->m_LastProject.GetCount() >= m_Parent->m_LastProjectMaxCount) + { +#if ( (wxMAJOR_VERSION < 2) || ((wxMAJOR_VERSION == 2)&& (wxMINOR_VERSION <= 4)) ) + files.Remove(files.GetCount() - 1); +#else + m_Parent->m_LastProject.RemoveAt(m_Parent->m_LastProject.GetCount() - 1); +#endif + } + m_Parent->m_LastProject.Insert(FullFileName, 0); + + ReCreateMenuBar(); +} + +/**************************************************/ +wxString WinEDA_BasicFrame::GetLastProject(int rang) +/**************************************************/ +{ + if ( rang < 0 ) rang = 0; + if ( (unsigned) rang >= m_Parent->m_LastProject.GetCount() ) + return wxEmptyString; + return m_Parent->m_LastProject[rang]; +} + + +/**************************************************************/ +void WinEDA_BasicFrame::GetKicadHelp(wxCommandEvent& event) +/**************************************************************/ +{ + if ( m_Parent->m_HtmlCtrl == NULL ) + { + m_Parent->InitOnLineHelp(); + } + + + if ( m_Parent->m_HtmlCtrl ) + { + m_Parent->m_HtmlCtrl->DisplayContents(); + m_Parent->m_HtmlCtrl->Display(m_Parent->m_HelpFileName); + } + else + { + wxString msg; + msg.Printf( _("Help file %s not found"), m_Parent->m_HelpFileName.GetData() ); + DisplayError(this, msg); + } +} + +/***********************************************************/ +void WinEDA_BasicFrame::GetKicadAbout(wxCommandEvent& event) +/**********************************************************/ +{ + Print_Kicad_Infos(this); +} + +/********************************************************************/ +void WinEDA_BasicFrame::ProcessFontPreferences(int id) +/********************************************************************/ +{ +wxFont font; + + switch (id) + { + + case ID_PREFERENCES_FONT: + break; + + case ID_PREFERENCES_FONT_STATUS: + { + font = wxGetFontFromUser(this, *g_StdFont); + if ( font.Ok() ) + { + int pointsize = font.GetPointSize(); + *g_StdFont = font; + SetFont(*g_StdFont); + if ( GetStatusBar() ) + GetStatusBar()->SetFont(*g_StdFont); + g_StdFontPointSize = pointsize; + } + break; + } + + case ID_PREFERENCES_FONT_DIALOG: + { + font = wxGetFontFromUser(this, *g_DialogFont); + if ( font.Ok() ) + { + int pointsize = font.GetPointSize(); + *g_DialogFont = font; + SetFont(*g_DialogFont); + g_DialogFontPointSize = pointsize; + g_FixedFontPointSize = pointsize; + g_FixedFont->SetPointSize(g_FixedFontPointSize); + } + break; + } + + default: DisplayError(this, wxT("WinEDA_BasicFrame::ProcessFontPreferences Internal Error") ); + break; + } +} diff --git a/common/bitmaps.cpp b/common/bitmaps.cpp new file mode 100644 index 0000000000..17a18f8088 --- /dev/null +++ b/common/bitmaps.cpp @@ -0,0 +1,23 @@ +/************************************************/ +/* MODULE: bitmaps.cpp */ +/************************************************/ + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWindows headers +#ifndef WX_PRECOMP +#include +#endif + +#include "fctsys.h" +#include "common.h" + +#define XPMMAIN +#include "bitmaps.h" + diff --git a/common/bitmaps/Lang_De.xpm b/common/bitmaps/Lang_De.xpm new file mode 100644 index 0000000000..daa6096364 --- /dev/null +++ b/common/bitmaps/Lang_De.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char * lang_de_xpm[] = { +"16 16 5 1", +" c None", +". c #000000", +"@ c #000000", +"# c #C00000", +"+ c #C0C000", +" ", +" ", +".............. ", +".@@@@@@@@@@@@. ", +".@@@@@@@@@@@@. ", +".@@@@@@@@@@@@. ", +".############. ", +".############. ", +".############. ", +".++++++++++++. ", +".++++++++++++. ", +".++++++++++++. ", +".............. ", +" ", +" ", +" "}; diff --git a/common/bitmaps/Lang_Default.xpm b/common/bitmaps/Lang_Default.xpm new file mode 100644 index 0000000000..9f0dcb1a93 --- /dev/null +++ b/common/bitmaps/Lang_Default.xpm @@ -0,0 +1,71 @@ +/* XPM */ +static char * lang_def_xpm[] = { +"16 16 52 1", +" c None", +". c #000000", +"+ c #C3C3C3", +"@ c #020202", +"# c #A9A9A9", +"$ c #0B0B0B", +"% c #9D9D9D", +"& c #060606", +"* c #DCDBD9", +"= c #ECECEC", +"- c #B1B1AF", +"; c #484641", +"> c #9E9C95", +", c #86857F", +"' c #9C9B97", +") c #908F89", +"! c #8F8D85", +"~ c #96948D", +"{ c #7F7C73", +"] c #474540", +"^ c #595854", +"/ c #605E57", +"( c #888782", +"_ c #807D74", +": c #75736A", +"< c #43423F", +"[ c #282724", +"} c #363430", +"| c #6C6A62", +"1 c #EDEDEC", +"2 c #B5B4AE", +"3 c #21201E", +"4 c #0A0908", +"5 c #181816", +"6 c #E5E5E3", +"7 c #64625B", +"8 c #5F5D56", +"9 c #9D9B94", +"0 c #878681", +"a c #35332F", +"b c #151513", +"c c #8A8987", +"d c #DDDCDA", +"e c #AEADA7", +"f c #B4B3AD", +"g c #E4E4E2", +"h c #D3D2CF", +"i c #918F89", +"j c #A9A7A1", +"k c #5C5B54", +"l c #585753", +"m c #484842", +" ", +" ", +".............. ", +".++++++++++++. ", +".++++++++++++. ", +".++++++++@@@+. ", +".++++#$$%&*&%.. ", +".++++$=-$;>;$,..", +".++++$')>>>!~{].", +".++++%$>>^/(_:. ", +".+++@@;>/<[}>|].", +".+++@12>^3456{78", +"......]90abcd7].", +" ..e{fghi7. ", +" .fj9{{::k].", +" ..l.]:].m.."}; diff --git a/common/bitmaps/Lang_En.xpm b/common/bitmaps/Lang_En.xpm new file mode 100644 index 0000000000..85221d131f --- /dev/null +++ b/common/bitmaps/Lang_En.xpm @@ -0,0 +1,40 @@ +/* XPM */ +static char * lang_en_xpm[] = { +"16 16 21 1", +" c None", +". c #000000", +"+ c #FFFFFF", +"@ c #A2A2E8", +"# c #0D0DC3", +"$ c #0000C0", +"% c #F77F7F", +"& c #5D5DD6", +"* c #F2F2FB", +"= c #DBDBF6", +"- c #3434CC", +"; c #2424C8", +"> c #CBCBF2", +", c #FAFAFD", +"' c #7474DC", +") c #8080DF", +"! c #8282DF", +"~ c #C5C5F0", +"{ c #FEFEFE", +"] c #F00000", +"^ c #EF0000", +" ", +" ", +".............. ", +".+@#$$%%$$#@+. ", +".&*=-$%%$-=*&. ", +".$;>,'%%',>;$. ", +".))!~{%%{~!)). ", +".]]]]]^^]]]]]. ", +".))!~{%%{~!)). ", +".$;>,'%%',>;$. ", +".&*=-$%%$-=*&. ", +".+@#$$%%$$#@+. ", +".............. ", +" ", +" ", +" "}; diff --git a/common/bitmaps/Lang_Es.xpm b/common/bitmaps/Lang_Es.xpm new file mode 100644 index 0000000000..25b3892baf --- /dev/null +++ b/common/bitmaps/Lang_Es.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char * lang_es_xpm[] = { +"16 16 5 1", +" c None", +". c #000000", +"+ c #F00000", +"@ c #B47800", +"# c #F0F000", +" ", +" ", +".............. ", +".++++++++++++. ", +".++++++++++++. ", +".@@@@@@@@@@@@. ", +".############. ", +".############. ", +".############. ", +".@@@@@@@@@@@@. ", +".++++++++++++. ", +".++++++++++++. ", +".............. ", +" ", +" ", +" "}; diff --git a/common/bitmaps/Lang_Fr.xpm b/common/bitmaps/Lang_Fr.xpm new file mode 100644 index 0000000000..91c8f22f4d --- /dev/null +++ b/common/bitmaps/Lang_Fr.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char * lang_fr_xpm[] = { +"16 16 5 1", +" c None", +". c #000000", +"+ c #0000D2", +"@ c #FFFFFF", +"# c #F00000", +" ", +" ", +".............. ", +".++++@@@@####. ", +".++++@@@@####. ", +".++++@@@@####. ", +".++++@@@@####. ", +".++++@@@@####. ", +".++++@@@@####. ", +".++++@@@@####. ", +".++++@@@@####. ", +".++++@@@@####. ", +".............. ", +" ", +" ", +" "}; diff --git a/common/bitmaps/Lang_Hu.xpm b/common/bitmaps/Lang_Hu.xpm new file mode 100644 index 0000000000..4af5086540 --- /dev/null +++ b/common/bitmaps/Lang_Hu.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char * lang_hu_xpm[] = { +"16 16 5 1", +" c None", +". c #000000", +"@ c #D00000", +"# c #F0F0F0", +"+ c #00C000", +" ", +" ", +".............. ", +".@@@@@@@@@@@@. ", +".@@@@@@@@@@@@. ", +".@@@@@@@@@@@@. ", +".############. ", +".############. ", +".############. ", +".++++++++++++. ", +".++++++++++++. ", +".++++++++++++. ", +".............. ", +" ", +" ", +" "}; diff --git a/common/bitmaps/Lang_It.xpm b/common/bitmaps/Lang_It.xpm new file mode 100644 index 0000000000..2e236d721c --- /dev/null +++ b/common/bitmaps/Lang_It.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char * lang_it_xpm[] = { +"16 16 5 1", +" c None", +". c #000000", +"+ c #008000", +"@ c #FFFFFF", +"# c #F00000", +" ", +" ", +".............. ", +".++++@@@@####. ", +".++++@@@@####. ", +".++++@@@@####. ", +".++++@@@@####. ", +".++++@@@@####. ", +".++++@@@@####. ", +".++++@@@@####. ", +".++++@@@@####. ", +".++++@@@@####. ", +".............. ", +" ", +" ", +" "}; diff --git a/common/bitmaps/Lang_Ko.xpm b/common/bitmaps/Lang_Ko.xpm new file mode 100644 index 0000000000..1a8707a71b --- /dev/null +++ b/common/bitmaps/Lang_Ko.xpm @@ -0,0 +1,39 @@ +/* XPM */ +static char * lang_ko_xpm[] = +{ +"16 16 17 1", + +" c None", +"A c #881844", +"B c #8F8F8F", +"C c #D0D2D0", +"D c #AFB0AF", +"E c #0C4A82", +"F c #F8F9F8", +"G c #F4AAB4", +"H c #3C3668", +"I c #EC8E9C", +"J c #797979", +"K c #D80A2A", +"L c #5C5E5C", +"M c #98B4CC", +"N c #E1DFDF", +"O c #A2A1A2", +"P c #C4C2C4", +" ", +" ", +" ", +"NNFNFNFFNFFNFNFC", +"FFFJPFFFFFFDOFFN", +"FFBLOFFFFFFDJOFN", +"FFFDFFIKKGFFDFFN", +"FFFFFNKKHHFFFFFN", +"FFFFFFAAEEFFFFFN", +"FFFPFFMEEPFFPFFN", +"FFBBOFFFFFFPBDFN", +"FFFJOFFFFFFBDFFN", +"NFFNFFFFFFFFNFFC", +" ", +" ", +" " +}; diff --git a/common/bitmaps/Lang_Po.xpm b/common/bitmaps/Lang_Po.xpm new file mode 100644 index 0000000000..c41d8068e7 --- /dev/null +++ b/common/bitmaps/Lang_Po.xpm @@ -0,0 +1,23 @@ +/* XPM */ +static char * lang_po_xpm[] = { +"16 16 4 1", +" c None", +". c #000000", +"@ c #F0F0F0", +"+ c #C00000", +" ", +" ", +".............. ", +".@@@@@@@@@@@@. ", +".@@@@@@@@@@@@. ", +".@@@@@@@@@@@@. ", +".@@@@@@@@@@@@. ", +".@@@@@@@@@@@@. ", +".++++++++++++. ", +".++++++++++++. ", +".++++++++++++. ", +".++++++++++++. ", +".............. ", +" ", +" ", +" "}; diff --git a/common/bitmaps/Lang_Pt.xpm b/common/bitmaps/Lang_Pt.xpm new file mode 100644 index 0000000000..619f4451d1 --- /dev/null +++ b/common/bitmaps/Lang_Pt.xpm @@ -0,0 +1,35 @@ +/* XPM */ +static char * lang_pt_xpm[] = { +"16 16 16 1", +" c None", +". c #000000", +"+ c #00C000", +"@ c #0FC200", +"# c #9CDF00", +"$ c #3DCC00", +"% c #D4E901", +"& c #ABBD37", +"* c #07C100", +"= c #84DA00", +"- c #EFEF00", +"; c #678B6D", +"> c #0040C0", +", c #9ADE00", +"' c #F0F000", +") c #1952AC", +" ", +" ", +".............. ", +".++++++++++++. ", +".++++@##@++++. ", +".+++$%&&%$+++. ", +".+*=-;>>;-=*+. ", +".+,'')>>)'',+. ", +".+*=-;>>;-=*+. ", +".+++$%&&%$+++. ", +".++++@##@++++. ", +".++++++++++++. ", +".............. ", +" ", +" ", +" "}; diff --git a/common/bitmaps/Lang_Ru.xpm b/common/bitmaps/Lang_Ru.xpm new file mode 100644 index 0000000000..dd9fa93bc0 --- /dev/null +++ b/common/bitmaps/Lang_Ru.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char * lang_ru_xpm[] = { +"16 16 5 1", +" c None", +". c #000000", +"@ c #FFFFFF", +"# c #1000FF", +"+ c #C00000", +" ", +" ", +".............. ", +".@@@@@@@@@@@@. ", +".@@@@@@@@@@@@. ", +".@@@@@@@@@@@@. ", +".############. ", +".############. ", +".############. ", +".++++++++++++. ", +".++++++++++++. ", +".++++++++++++. ", +".............. ", +" ", +" ", +" "}; diff --git a/common/bitmaps/Lang_Sl.xpm b/common/bitmaps/Lang_Sl.xpm new file mode 100644 index 0000000000..d4c7d6a09c --- /dev/null +++ b/common/bitmaps/Lang_Sl.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char * lang_sl_xpm[] = { +"16 16 5 1", +" c None", +". c #000000", +"@ c #F0F0F0", +"# c #0000FF", +"+ c #C00000", +" ", +" ", +".............. ", +".@@@@@@@@@@@@. ", +".@####@@@@@@@. ", +".@#@@#@@@@@@@. ", +".#@@@@#######. ", +".##@@########. ", +".############. ", +".++++++++++++. ", +".++++++++++++. ", +".++++++++++++. ", +".............. ", +" ", +" ", +" "}; diff --git a/common/bitmaps/Language.xpm b/common/bitmaps/Language.xpm new file mode 100644 index 0000000000..78389b182d --- /dev/null +++ b/common/bitmaps/Language.xpm @@ -0,0 +1,111 @@ +/* XPM */ +static char * language_xpm[] = { +"16 16 92 2", +" c None", +". c #000000", +"+ c #7F91A3", +"@ c #C0C8D1", +"# c #FAFAFA", +"$ c #8495A7", +"% c #597088", +"& c #8395A6", +"* c #DFE3E7", +"= c #F9F9F9", +"- c #F7F7F7", +"; c #EDEDED", +"> c #F3F3F3", +", c #DDDDDD", +"' c #8C9CAD", +") c #5D738B", +"! c #4A637D", +"~ c #798C9F", +"{ c #D9DEE2", +"] c #F1F1F1", +"^ c #F4F4F4", +"/ c #8F9FAF", +"( c #4F6781", +"_ c #3D5874", +": c #33506D", +"< c #AA5C50", +"[ c #C95841", +"} c #E35D3E", +"| c #E46345", +"1 c #CE5236", +"2 c #8B9BAC", +"3 c #3C5774", +"4 c #8394A6", +"5 c #324F6D", +"6 c #AA5C51", +"7 c #7FBF5F", +"8 c #84C166", +"9 c #97C97A", +"0 c #FFFFFF", +"a c #FDFBF9", +"b c #F59B5E", +"c c #FA9D5F", +"d c #EE6306", +"e c #687C92", +"f c #905957", +"g c #DD5A3C", +"h c #8EC672", +"i c #4BA51F", +"j c #51A521", +"k c #FBFBFB", +"l c #F2F2F2", +"m c #F2EEEB", +"n c #FF7011", +"o c #FF7E29", +"p c #E77528", +"q c #91C876", +"r c #3F9F0F", +"s c #48A015", +"t c #F0F0F0", +"u c #F8F5F2", +"v c #FF7C25", +"w c #FF812D", +"x c #E76F1F", +"y c #8DC671", +"z c #359A03", +"A c #459D12", +"B c #F6F6F6", +"C c #FCF9F6", +"D c #FF812E", +"E c #FF7B24", +"F c #E76813", +"G c #85C267", +"H c #329700", +"I c #439A12", +"J c #FCFCFC", +"K c #FFFBF8", +"L c #FF7317", +"M c #E76006", +"N c #7FBF60", +"O c #319500", +"P c #419511", +"Q c #FFFBF9", +"R c #FF7418", +"S c #FF6C0A", +"T c #E75D01", +"U c #358F08", +"V c #2B8300", +"W c #3C8810", +"X c #E7E7E7", +"Y c #E7E4E2", +"Z c #E76209", +"` c #D45400", +" ", +". . . . . . . . . . . ", +". + @ # # # # # # # . ", +". $ % & * = - ; > , . ", +". ' ) ! ~ { ] ^ ^ , . ", +". / ( _ : < [ } | 1 . ", +". 2 3 : . . . . . . . . . . . ", +". 4 5 6 . 7 8 9 0 0 a b c d . ", +". e f g . h i j k l m n o p . ", +". . . . . q r s ^ t u v w x . ", +" . y z A t B C D E F . ", +" . G H I ^ J K E L M . ", +" . N O P # 0 Q R S T . ", +" . U V W X X Y Z T ` . ", +" . . . . . . . . . . . ", +" "}; diff --git a/common/block_commande.cpp b/common/block_commande.cpp new file mode 100644 index 0000000000..177470d862 --- /dev/null +++ b/common/block_commande.cpp @@ -0,0 +1,285 @@ + /****************************************************/ + /* Routines de gestion des commandes sur blocks */ + /* (section commune eeschema/pcbnew... */ + /****************************************************/ + + /* Fichier common.cpp */ + +#include "fctsys.h" +#include "gr_basic.h" +#include "wxstruct.h" +#include "common.h" +#include "macros.h" + + + /*******************/ + /* DrawBlockStruct */ + /*******************/ + +/****************************************************************************/ +DrawBlockStruct::DrawBlockStruct(void): + EDA_BaseStruct(BLOCK_LOCATE_STRUCT_TYPE), EDA_Rect() +/****************************************************************************/ +{ + m_State = STATE_NO_BLOCK; /* Etat (enum BlockState) du block */ + m_Command = BLOCK_IDLE; /* Type (enum CmdBlockType) d'operation */ + m_BlockDrawStruct = NULL; /* pointeur sur la structure */ + m_Color = BROWN; +} + + +/****************************************/ +DrawBlockStruct::~DrawBlockStruct(void) +/****************************************/ +{ +} + + + +/***************************************************************/ +void DrawBlockStruct::SetMessageBlock(WinEDA_DrawFrame * frame) +/***************************************************************/ +/* + Print block command message (Block move, Block copy ...) in status bar +*/ +{ +wxString msg; + + switch(m_Command) + { + case BLOCK_IDLE: + break; + + case BLOCK_MOVE: /* Move */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + msg = _("Block Move"); + break; + + case BLOCK_DRAG: /* Drag */ + msg = _("Block Drag"); + break; + + case BLOCK_COPY: /* Copy */ + msg = _("Block Copy"); + break; + + case BLOCK_DELETE: /* Delete */ + msg = _("Block Delete"); + break; + + case BLOCK_SAVE: /* Save */ + msg = _("Block Save"); + break; + + case BLOCK_PASTE: + msg = _("Block Paste"); + break; + + case BLOCK_ZOOM: /* Window Zoom */ + msg = _("Win Zoom"); + break; + + case BLOCK_ROTATE: /* Rotate 90 deg */ + msg = _("Block Rotate"); + break; + + case BLOCK_INVERT: /* Flip */ + msg = _("Block Invert"); + break; + + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: /* mirror */ + msg = _("Block Mirror"); + break; + + case BLOCK_ABORT: + break; + + default: + msg = wxT("????"); + break; + } + + frame->DisplayToolMsg(msg); +} + + +/**************************************************************/ +void DrawBlockStruct::Draw(WinEDA_DrawPanel * panel, wxDC * DC) +/**************************************************************/ +{ + int w = GetWidth()/panel->GetZoom(); + int h = GetHeight()/panel->GetZoom(); + if ( w == 0 || h == 0 ) + GRLine(&panel->m_ClipBox, DC, GetX(), GetY(), + GetRight(), GetBottom(), m_Color); + else + GRRect(&panel->m_ClipBox, DC, GetX(), GetY(), + GetRight(), GetBottom(), m_Color); +} + +/*************************************************************************/ +bool WinEDA_DrawFrame::HandleBlockBegin(wxDC * DC, int key, + const wxPoint & startpos) +/*************************************************************************/ +/* First command block function: + Init the Block infos: command type, initial position, and other variables.. +*/ +{ +DrawBlockStruct * Block = & GetScreen()->BlockLocate; + + if ( (Block->m_Command != BLOCK_IDLE) || + ( Block->m_State != STATE_NO_BLOCK) ) + return FALSE; + + Block->m_Flags = 0; + Block->m_Command = (CmdBlockType) ReturnBlockCommand(key); + if ( Block->m_Command == 0 ) + return FALSE; + + switch(Block->m_Command) + { + case BLOCK_IDLE: break; + + case BLOCK_MOVE: /* Move */ + case BLOCK_DRAG: /* Drag */ + case BLOCK_COPY: /* Copy */ + case BLOCK_DELETE: /* Delete */ + case BLOCK_SAVE: /* Save */ + case BLOCK_ROTATE: /* Rotate 90 deg */ + case BLOCK_INVERT: /* Flip */ + case BLOCK_ZOOM: /* Window Zoom */ + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: /* mirror */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + InitBlockLocateDatas(DrawPanel,startpos); + break; + + case BLOCK_PASTE: + InitBlockLocateDatas(DrawPanel,startpos); + Block->m_BlockLastCursorPosition.x = 0; + Block->m_BlockLastCursorPosition.y = 0; + InitBlockPasteInfos(); + if( Block->m_BlockDrawStruct == NULL ) /* No data to paste */ + { + DisplayError(this, wxT("No Block to paste"), 20); + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + DrawPanel->ManageCurseur = NULL; + return TRUE; + } + if ( DrawPanel->ManageCurseur == NULL ) + { + Block->m_BlockDrawStruct = NULL; + DisplayError(this, + wxT("WinEDA_DrawFrame::HandleBlockBegin() Err: ManageCurseur NULL")); + return TRUE; + } + Block->m_State = STATE_BLOCK_MOVE; + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + break; + + default: + { + wxString msg; + msg << wxT("WinEDA_DrawFrame::HandleBlockBegin() error: Unknown command ") << Block->m_Command; + DisplayError( this, msg ); + } + break; + } + + Block->SetMessageBlock(this); + return TRUE; +} + + +/******************************************************************/ +void AbortBlockCurrentCommand(WinEDA_DrawPanel * Panel, wxDC * DC) +/******************************************************************/ +/* + Cancel Current block operation. +*/ +{ +BASE_SCREEN * screen = Panel->GetScreen(); + + if( Panel->ManageCurseur) /* Erase current drawing on screen */ + { + Panel->ManageCurseur(Panel,DC, FALSE); /* Efface dessin fantome */ + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + screen->m_CurrentItem = NULL; + + /* Delete the picked wrapper if this is a picked list. */ + if( (screen->BlockLocate.m_Command != BLOCK_PASTE) && + screen->BlockLocate.m_BlockDrawStruct ) + { + if(screen->BlockLocate.m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + DrawPickedStruct * PickedList; + PickedList = (DrawPickedStruct*)screen->BlockLocate.m_BlockDrawStruct; + PickedList->DeleteWrapperList(); + } + screen->BlockLocate.m_BlockDrawStruct = NULL; + } + } + + screen->BlockLocate.m_Flags = 0; + screen->BlockLocate.m_State = STATE_NO_BLOCK; + + screen->BlockLocate.m_Command = BLOCK_ABORT; + Panel->m_Parent->HandleBlockEnd(DC); + + screen->BlockLocate.m_Command = BLOCK_IDLE; + Panel->m_Parent->DisplayToolMsg(wxEmptyString); +} + +/*************************************************************************/ +void InitBlockLocateDatas( WinEDA_DrawPanel * Panel,const wxPoint & startpos ) +/*************************************************************************/ +/* + Init the initial values of a BlockLocate, before starting a block command +*/ +{ +BASE_SCREEN * screen = Panel->GetScreen(); + screen->BlockLocate.m_State = STATE_BLOCK_INIT; + screen->BlockLocate.SetOrigin(startpos); + screen->BlockLocate.SetSize(wxSize(0,0)); + screen->BlockLocate.Pnext = NULL; + screen->BlockLocate.m_BlockDrawStruct = NULL; + Panel->ManageCurseur = DrawAndSizingBlockOutlines; + Panel->ForceCloseManageCurseur = AbortBlockCurrentCommand; +} + +/********************************************************************************/ +void DrawAndSizingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase ) +/********************************************************************************/ +/* Redraw the outlines of the block which shows the search area for block commands + The first point of the rectangle showing the area is initialised + by InitBlockLocateDatas(). + The other point of the rectangle is the mouse cursor + */ +{ +DrawBlockStruct * PtBlock; + + PtBlock = &panel->GetScreen()->BlockLocate; + + PtBlock->m_MoveVector = wxPoint(0,0); + + GRSetDrawMode(DC, g_XorMode); + + /* Effacement ancien cadre */ + if( erase ) PtBlock->Draw(panel, DC); + + PtBlock->m_BlockLastCursorPosition = panel->GetScreen()->m_Curseur; + PtBlock->SetEnd(panel->GetScreen()->m_Curseur); + + PtBlock->Draw(panel, DC); + + if ( PtBlock->m_State == STATE_BLOCK_INIT ) + { + if ( PtBlock->GetWidth() || PtBlock->GetHeight() ) + /* 2ieme point existant: le rectangle n'est pas de surface nulle */ + PtBlock->m_State = STATE_BLOCK_END; + } +} + + diff --git a/common/common.cpp b/common/common.cpp new file mode 100644 index 0000000000..ec19a37590 --- /dev/null +++ b/common/common.cpp @@ -0,0 +1,415 @@ + /**********************************************************/ + /* Routines d'affichage de parametres et caracteristiques */ + /**********************************************************/ + + /* Fichier common.cpp */ + +#include "fctsys.h" +#include "gr_basic.h" +#include "trigo.h" +#include "wxstruct.h" +#include "base_struct.h" +#include "common.h" +#include "macros.h" +#include "build_version.h" + +/*****************************/ +wxString GetBuildVersion(void) +/*****************************/ +/* Return the build date +*/ +{ + return g_BuildVersion; +} + +/*********************************************************************************************/ +Ki_PageDescr::Ki_PageDescr(const wxSize & size, const wxPoint & offset, const wxString & name) +/*********************************************************************************************/ +{ + // All sizes are in 1/1000 inch + m_Size = size; m_Offset = offset, m_Name = name; + // Adjust the default value for margins to 400 mils (0,4 inch or 10 mm) + m_LeftMargin = m_RightMargin = m_TopMargin = m_BottomMargin = 400; +} + +/************************************/ +wxString ReturnUnitSymbol(int Units ) +/************************************/ +{ +wxString label; + + switch ( Units ) + { + case INCHES: + label = _(" (\"):"); + break; + + case MILLIMETRE: + label = _(" (mm):"); + break; + + default: + break; + } + + return label; +} + +/**************************************************/ +void AddUnitSymbol(wxStaticText & Stext, int Units) +/**************************************************/ +/* Add string " (mm):" or " ("):" to the static text Stext. +Used in dialog boxes for entering values depending on selected units +*/ +{ +wxString msg = Stext.GetLabel() + ReturnUnitSymbol(Units); + Stext.SetLabel(msg); +} + +/****************************************************************************/ +void PutValueInLocalUnits(wxTextCtrl & TextCtr, int Value, int Internal_Unit) +/****************************************************************************/ +/* Convert the number Value in a string according to the internal units + and the selected unit (g_UnitMetric) and put it in the wxTextCtrl TextCtrl +*/ +{ +wxString msg = ReturnStringFromValue(g_UnitMetric, Value, Internal_Unit); + TextCtr.SetValue(msg); +} + +/*******************************************************************/ +int ReturnValueFromTextCtrl(const wxTextCtrl & TextCtr, int Internal_Unit) +/********************************************************************/ +/* Convert the Value in the wxTextCtrl TextCtrl in an integer, + according to the internal units and the selected unit (g_UnitMetric) +*/ +{ +int value; +wxString msg = TextCtr.GetValue(); + value = ReturnValueFromString(g_UnitMetric, msg, Internal_Unit); + + return value; +} + +/****************************************************************************/ +wxString ReturnStringFromValue(int Units, int Value, int Internal_Unit) +/****************************************************************************/ +/* Return the string from Value, according to units (inch, mm ...) for display, + and the initial unit for value + Unit = display units (INCH, MM ..) + Value = value in Internal_Unit + Internal_Unit = units per inch for Value +*/ +{ +wxString StringValue; +double value_to_print; + + if ( Units >= CENTIMETRE ) StringValue << Value; + else + { + value_to_print = To_User_Unit(Units, Value,Internal_Unit); + StringValue.Printf( ( Internal_Unit > 1000 ) ? wxT("%.4f") : wxT("%.3f"), + value_to_print ); + } + + return StringValue; +} + +/****************************************************************************/ +int ReturnValueFromString(int Units, const wxString & TextValue, int Internal_Unit) +/****************************************************************************/ +/* Return the string from Value, according to units (inch, mm ...) for display, + and the initial unit for value + Unit = display units (INCH, MM ..) + Value = text + Internal_Unit = units per inch for computed value +*/ +{ +int Value; +double dtmp = 0; + + TextValue.ToDouble(&dtmp); + if ( Units >= CENTIMETRE ) Value = (int) round(dtmp); + else Value = From_User_Unit(Units, dtmp, Internal_Unit); + + return Value; +} +/******************************************************************/ +double To_User_Unit(bool is_metric, int val,int internal_unit_value) +/******************************************************************/ +/* Convert in inch or mm the variable "val" given in internal units +*/ +{ +double value; + + if (is_metric) + value = (double) (val) * 25.4 / internal_unit_value; + else value = (double) (val) / internal_unit_value; + + return value; +} + +/**********************************************************************/ +int From_User_Unit(bool is_metric, double val,int internal_unit_value) +/**********************************************************************/ +/* Return in internal units the value "val" given in inch or mm +*/ +{ +double value; + + if (is_metric) value = val * internal_unit_value / 25.4 ; + else value = val * internal_unit_value; + + return (int) round(value); +} + +/**********************/ +wxString GenDate(void) +/**********************/ +/* Return the string date "day month year" like "23 jun 2005" +*/ +{ +wxString mois[12] = + { + wxT("jan"), wxT("feb"), wxT("mar"), wxT("apr"), wxT("may"), wxT("jun"), + wxT("jul"), wxT("aug"), wxT("sep"), wxT("oct"), wxT("nov"), wxT("dec") + }; +time_t buftime; +struct tm * Date; +wxString string_date; + + time(&buftime); + Date = gmtime(&buftime); + string_date.Printf( wxT("%d %s %d"), Date->tm_mday, + mois[Date->tm_mon].GetData(), + Date->tm_year + 1900); + return(string_date); +} + +/***********************************/ +void * MyMalloc (size_t nb_octets) +/***********************************/ +/* My memory allocation */ +{ +void * pt_mem; + if (nb_octets == 0) + { + DisplayError(NULL, wxT("Allocate 0 bytes !!")); + return(NULL); + } + pt_mem = malloc(nb_octets); + if (pt_mem == NULL) + { + wxString msg; + msg.Printf( wxT("Out of memory: allocation %d bytes"), nb_octets); + DisplayError(NULL, msg); + } + return(pt_mem); +} + +/************************************/ +void * MyZMalloc (size_t nb_octets) +/************************************/ +/* My memory allocation, memory space is cleared +*/ +{ + void * pt_mem = MyMalloc (nb_octets); + if ( pt_mem) memset(pt_mem, 0, nb_octets); + return(pt_mem); +} + +/*******************************/ +void MyFree (void * pt_mem) +/*******************************/ +{ + if( pt_mem ) free(pt_mem); +} + + +/**************************************************************/ +wxString ReturnPcbLayerName(int layer_number, bool is_filename) +/**************************************************************/ +/* Return the name of the layer number "layer_number". + if "is_filefame" == TRUE, the name can be used for a file name + (not internatinalized, no space) +*/ +{ +wxString layer_name; +wxString layer_name_list[] = { + _("Copper "), _("Inner L1 "), _("Inner L2 "), _("Inner L3 "), + _("Inner L4 "), _("Inner L5 "), _("Inner L6 "), _("Inner L7 "), + _("Inner L8 "), _("Inner L9 "), _("Inner L10"), _("Inner L11"), + _("Inner L12"), _("Inner L13"), _("Inner L14"), _("Component"), + _("Adhes Cop"), _("Adhes Cmp"), _("SoldP Cop"), _("SoldP Cmp"), + _("SilkS Cop"), _("SilkS Cmp"), _("Mask Copp"), _("Mask Cmp "), + _("Drawings "), _("Comments "), _("Eco1 "), _("Eco2 "), + _("Edges Pcb"), _("--- "), _("--- "), _("--- ") + }; + +// Same as layer_name_list, without space, not internationalized +wxString layer_name_list_for_filename[] = { + wxT("Copper"), wxT("InnerL1"), wxT("InnerL2"), wxT("InnerL3"), + wxT("InnerL4"), wxT("InnerL5"), wxT("InnerL6"), wxT("InnerL7"), + wxT("InnerL8"), wxT("InnerL9"), wxT("InnerL10"), wxT("InnerL11"), + wxT("InnerL12"), wxT("InnerL13"), wxT("InnerL14"), wxT("Component"), + wxT("AdhesCop"), wxT("AdhesCmp"), wxT("SoldPCop"), wxT("SoldPCmp"), + wxT("SilkSCop"), wxT("SilkSCmp"), wxT("MaskCopp"), wxT("MaskCmp"), + wxT("Drawings"), wxT("Comments"), wxT("Eco1"), wxT("Eco2"), + wxT("Edges Pcb"), wxT("---"), wxT("---"), wxT("---") + }; + if ( layer_number >= 31 ) layer_number = 31; + +#if 0 // Use it (#if 1) to return layer_name internationalized, without space + if ( is_filename ) + { + int ll = layer_name_list[layer_number].Length(); + int ii; + for ( ii = 0; ii < ll; ii++ ) + { + char cc = layer_name_list[layer_number].GetChar(ii); + if ( cc != ' ' ) + layer_name += cc; + } + } +#else + if ( is_filename ) layer_name = layer_name_list_for_filename[layer_number]; +#endif + else layer_name = layer_name_list[layer_number]; + + return layer_name; + +} + + +enum textbox { + ID_TEXTBOX_LIST = 8010 +}; + +BEGIN_EVENT_TABLE(WinEDA_TextFrame, wxDialog) + EVT_LISTBOX_DCLICK(ID_TEXTBOX_LIST, WinEDA_TextFrame::D_ClickOnList) + EVT_LISTBOX(ID_TEXTBOX_LIST, WinEDA_TextFrame::D_ClickOnList) + EVT_CLOSE( WinEDA_TextFrame::OnClose ) +END_EVENT_TABLE() + +/***************************************************************************/ +WinEDA_TextFrame::WinEDA_TextFrame(wxWindow * parent, const wxString & title): + wxDialog(parent, -1, title, wxPoint(-1,-1), wxSize(250,350), + wxDEFAULT_DIALOG_STYLE| wxFRAME_FLOAT_ON_PARENT ) +/***************************************************************************/ +{ +wxSize size; + + m_Parent = parent; + + CentreOnParent(); + + size = GetClientSize(); + m_List = new wxListBox(this, ID_TEXTBOX_LIST, + wxPoint(0,0), size, + 0, NULL, + wxLB_ALWAYS_SB|wxLB_SINGLE); + m_List->SetBackgroundColour(wxColour(200,255,255)); + SetReturnCode(-1); +} + +/***************************************************/ +void WinEDA_TextFrame::Append( const wxString & text) +/***************************************************/ +{ + m_List->Append(text); +} + +/**********************************************************/ +void WinEDA_TextFrame::D_ClickOnList(wxCommandEvent& event) +/**********************************************************/ +{ +int ii = m_List->GetSelection(); + EndModal(ii); +} + +/*************************************************/ +void WinEDA_TextFrame::OnClose(wxCloseEvent& event) +/*************************************************/ +{ + EndModal(-1); +} + + + +/*****************************************************************************/ +void Affiche_1_Parametre(WinEDA_DrawFrame * frame , int pos_X, + const wxString & texte_H,const wxString & texte_L,int color) +/*****************************************************************************/ +/* + Routine d'affichage d'un parametre. + pos_X = cadrage horizontal + si pos_X < 0 : la position horizontale est la derniere + valeur demandee >= 0 + texte_H = texte a afficher en ligne superieure. + si "", par d'affichage sur cette ligne + texte_L = texte a afficher en ligne inferieure. + si "", par d'affichage sur cette ligne + color = couleur d'affichage +*/ +{ + frame->MsgPanel->Affiche_1_Parametre(pos_X, texte_H,texte_L, color); +} + +/****************************************************************************/ +void AfficheDoc(WinEDA_DrawFrame * frame, const wxString & Doc, const wxString & KeyW) +/****************************************************************************/ +/* + Routine d'affichage de la documentation associee a un composant +*/ +{ +wxString Line1( wxT("Doc: ")), Line2( wxT("KeyW: ")); +int color = BLUE; + + if ( frame && frame->MsgPanel) + { + frame->MsgPanel->EraseMsgBox(); + Line1 += Doc; + Line2 += KeyW; + frame->MsgPanel->Affiche_1_Parametre(10, Line1, Line2, color); + } +} + + + + +/***********************/ +int GetTimeStamp(void) +/***********************/ +/* + Retourne une identification temporelle (Time stamp) differente a chaque appel +*/ +{ +static int OldTimeStamp, NewTimeStamp; + + NewTimeStamp = time(NULL); + if(NewTimeStamp <= OldTimeStamp) NewTimeStamp = OldTimeStamp + 1; + OldTimeStamp = NewTimeStamp; + return(NewTimeStamp); +} + +/*************************************************/ +void valeur_param(int valeur,wxString & buf_texte) +/*************************************************/ +/* Retourne pour affichage la valeur d'un parametre, selon type d'unites choisies + entree : valeur en mils , buffer de texte + retourne en buffer : texte : valeur exprimee en pouces ou millimetres + suivie de " ou mm +*/ +{ + if ( g_UnitMetric ) + { + buf_texte.Printf( wxT("%3.3f "),(float) valeur * 0.00254); + buf_texte << wxT("mm") ; + } + else + { + buf_texte.Printf( wxT("%2.4f "),(float) valeur * 0.0001); + buf_texte << wxT("\" "); + } +} + diff --git a/common/common_plotHPGL_functions.cpp b/common/common_plotHPGL_functions.cpp new file mode 100644 index 0000000000..ab3a3dc86e --- /dev/null +++ b/common/common_plotHPGL_functions.cpp @@ -0,0 +1,206 @@ + /******************************************/ + /* Kicad: Common plot HPGL Routines */ + /******************************************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "trigo.h" +#include "wxstruct.h" +#include "base_struct.h" +#include "common.h" +#include "plot_common.h" +#include "macros.h" + +/* parametre HPGL pour trace de cercle: */ +#define CHORD_ANGLE 10 + +// Variables partagees avec Common plot Postscript Routines +extern wxPoint LastPenPosition; +extern wxPoint PlotOffset; +extern FILE * PlotOutputFile; +extern double XScale, YScale; +extern int PenWidth; +extern int PlotOrientOptions, etat_plume; + +//Variables locales +void Move_Plume_HPGL( wxPoint pos, int plume ); +void Plume_HPGL( int plume ); + + +/***********************************************************************************/ +void InitPlotParametresHPGL(wxPoint offset, double xscale, double yscale, int orient) +/***********************************************************************************/ +/* Set the plot offset for the current plotting + xscale,yscale = coordinate scale (scale coefficient for coordinates) + device_xscale,device_yscale = device coordinate scale (i.e scale used by plot device) +*/ +{ + PlotOffset = offset; + XScale = xscale; + YScale = yscale; + PenWidth = 6; /* epaisseur du trait standard en 1/1000 pouce */ + PlotOrientOptions = orient; +} + + + +/*****************************************************************/ +bool PrintHeaderHPGL(FILE * plot_file, int pen_speed, int pen_num) +/*****************************************************************/ +{ +char Line[256]; + + PlotOutputFile = plot_file; + etat_plume = 'U'; + sprintf(Line,"IN;VS%d;PU;PA;SP%d;\n",pen_speed,pen_num); + fputs(Line,plot_file); + return TRUE; +} + +/**********************************/ +bool CloseFileHPGL(FILE * plot_file) +/**********************************/ +{ + fputs("PU;PA;SP0;\n",PlotOutputFile) ; fclose(PlotOutputFile) ; + fclose(plot_file); + return TRUE; +} + + +/************************************************************/ +void PlotCircle_HPGL(wxPoint centre, int diameter, int width) +/************************************************************/ +{ +int rayon; +char Line[256]; + + UserToDeviceCoordinate(centre); + rayon = (int)(diameter / 2 * XScale); + + if(rayon < 0 ) rayon = 0 ; + + Plume_HPGL('U'); + sprintf(Line,"PA %d,%d;CI %d,%d;\n", centre.x, centre.y, rayon , CHORD_ANGLE); + fputs(Line,PlotOutputFile) ; + + Plume_HPGL('U'); return ; +} + + +/********************************************************************/ +void PlotArcHPGL(wxPoint centre, int StAngle, int EndAngle, int rayon) +/********************************************************************/ +/* trace d'un arc de cercle: + centre = coord du centre + StAngle, EndAngle = angle de debut et fin + rayon = rayon de l'arc + commande + PU;PA x,y;PD;AA start_arc_X, start_arc_Y, angle, NbSegm; PU; + ou PU;PA x,y;PD;AA start_arc_X, start_arc_Y, angle; PU; +*/ +{ +char Line[256]; +wxPoint cmap; /* point de depart */ +wxPoint cpos; /* centre */ +float angle; /* angle de l'arc*/ + + if(rayon <= 0 ) return ; + + cpos = centre; UserToDeviceCoordinate(cpos); + + if( PlotOrientOptions == PLOT_MIROIR) + { + EndAngle = - EndAngle; + StAngle = - StAngle; + EXCHG (StAngle, EndAngle); + } + angle = (EndAngle - StAngle) /10.0; + /* Calcul des coord du point de depart : */ + cmap.x = (int)( centre.x + ( rayon * cos(StAngle * M_PI / 1800 ) ) ); + cmap.y = (int)(centre.y + ( rayon * sin(StAngle * M_PI / 1800 ) ) ); + UserToDeviceCoordinate(cmap); + + Plume_HPGL('U'); + sprintf(Line,"PU;PA %d,%d;PD;AA %d,%d, ", cmap.x, cmap.y, cpos.x, cpos.y); + fputs(Line,PlotOutputFile) ; + sprintf(Line,"%f", - angle); to_point(Line); // Transforme , et . du separateur + fputs(Line,PlotOutputFile) ; + sprintf(Line,", %d", CHORD_ANGLE); fputs(Line,PlotOutputFile) ; + sprintf(Line,";PU;\n"); fputs(Line,PlotOutputFile) ; + Plume_HPGL('U'); +} + + +/*****************************************************/ +void PlotPolyHPGL( int nb, int * coord, int fill) +/*****************************************************/ +/* Trace un polygone (ferme si rempli) en format HPGL + coord = tableau des coord des sommets + nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau ) + fill : si != 0 polygone rempli +*/ +{ +int ii; + if( nb <= 1 ) return; + + Move_Plume_HPGL( wxPoint(coord[0],coord[1]), 'U'); + for( ii = 1; ii < nb ; ii ++ ) + { + Move_Plume_HPGL( wxPoint(coord[ii * 2],coord[(ii*2) +1]), 'D'); + } + + /* Fermeture eventuelle du polygone */ + if ( fill ) + { + ii = (nb - 1) * 2; + if( (coord[ii] != coord[0] ) || (coord[ii+1] != coord[0]) ) + Move_Plume_HPGL( wxPoint(coord[0],coord[1]), 'D'); + } + Plume_HPGL('U'); +} + + +/**********************************************/ +void Move_Plume_HPGL( wxPoint pos, int plume ) +/**********************************************/ +/* + deplace la plume levee (plume = 'U') ou baissee (plume = 'D') + en position x,y + Unites en Unites DESSIN + Si plume = 'Z' lever de plume sans deplacement +*/ +{ +char Line[256]; + + if ( plume == 'Z') + { + Plume_HPGL('U'); + return; + } + Plume_HPGL(plume); + UserToDeviceCoordinate(pos); + + sprintf(Line,"PA %d,%d;\n",pos.x,pos.y) ; fputs(Line,PlotOutputFile) ; +} + + +/***************************/ +void Plume_HPGL( int plume ) +/***************************/ +/* leve (plume = 'U') ou baisse (plume = 'D') la plume +*/ +{ + if ( plume == 'U') + { + if(etat_plume != 'U' ) fputs("PU;",PlotOutputFile) ; + etat_plume = 'U'; + } + else + { + if(etat_plume != 'D' )fputs("PD;",PlotOutputFile) ; + etat_plume = 'D'; + } +} + + + diff --git a/common/common_plotPS_functions.cpp b/common/common_plotPS_functions.cpp new file mode 100644 index 0000000000..427c1f1193 --- /dev/null +++ b/common/common_plotPS_functions.cpp @@ -0,0 +1,293 @@ + /******************************************/ + /* Kicad: Common plot Postscript Routines */ + /******************************************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "trigo.h" +#include "wxstruct.h" +#include "base_struct.h" +#include "common.h" +#include "plot_common.h" +#include "macros.h" + +// Variables partagees avec Common plot Postscript Routines +extern wxPoint LastPenPosition; +extern wxPoint PlotOffset; +extern FILE * PlotOutputFile; +extern double XScale, YScale; +extern int PenWidth; +extern int PlotOrientOptions, etat_plume; + +// Locales +static Ki_PageDescr * SheetPS; + +/*************************************************************************************/ +void InitPlotParametresPS(wxPoint offset, Ki_PageDescr * sheet, + double xscale, double yscale, int orient) +/*************************************************************************************/ +/* Set the plot offset for the current plotting + xscale,yscale = coordinate scale (scale coefficient for coordinates) + device_xscale,device_yscale = device coordinate scale (i.e scale used by plot device) +*/ +{ + PlotOrientOptions = orient; + PlotOffset = offset; + SheetPS = sheet; + XScale = xscale; + YScale = yscale; +} + +/*************************************************************************************/ +void SetDefaultLineWidthPS( int width) +/*************************************************************************************/ +/* Set the default line width (in 1/1000 inch) for the current plotting +*/ +{ + PenWidth = width; /* epaisseur du trait standard en 1/1000 pouce */ +} + +/******************************/ +void SetColorMapPS(int color) +/******************************/ +/* Print the postscript set color command: + r g b setrgbcolor, + r, g, b = color values (= 0 .. 1.0 ) + + color = color index in ColorRefs[] +*/ +{ +char Line[1024]; + + sprintf( Line,"%.3f %.3f %.3f setrgbcolor\n", + (float)ColorRefs[color].m_Red/255, + (float)ColorRefs[color].m_Green/255, + (float)ColorRefs[color].m_Blue/255 + ); + to_point(Line); + fputs( Line, PlotOutputFile); +} + +/***************************************************************/ +void PlotFilledSegmentPS(wxPoint start , wxPoint end, int width) +/***************************************************************/ +/* Plot 1 segment like a track segment + */ +{ + UserToDeviceCoordinate(start); + UserToDeviceCoordinate(end); + + fprintf(PlotOutputFile,"%d setlinewidth\n", (int)(XScale * width)); + fprintf(PlotOutputFile,"%d %d %d %d line\n", start.x, start.y, end.x, end.y); +} + + +/******************************************************/ +void PlotCircle_PS(wxPoint pos, int diametre, int width) +/******************************************************/ +{ +int rayon; +char Line[256]; + + UserToDeviceCoordinate(pos); + rayon = (int)(XScale * diametre / 2); + + if(rayon < 0 ) rayon = 0 ; + + if ( width > 0 ) + { + sprintf(Line,"%d setlinewidth\n", (int)( width * XScale) ) ; + fputs(Line,PlotOutputFile); + } + + sprintf(Line,"newpath %d %d %d 0 360 arc stroke\n", pos.x, pos.y, rayon); + fputs(Line,PlotOutputFile) ; +} + + + +/********************************************************************/ +void PlotArcPS(wxPoint centre, int StAngle, int EndAngle, int rayon) +/********************************************************************/ +/* Plot an arc: + StAngle, EndAngle = start and end arc in 0.1 degree +*/ +{ +char Line[256]; + + if(rayon <= 0 ) return ; + + /* Calcul des coord du point de depart : */ + UserToDeviceCoordinate(centre); + + if( PlotOrientOptions == PLOT_MIROIR) + sprintf(Line, "newpath %d %d %d %f %f arc stroke\n", centre.x, centre.y, + (int)(rayon * XScale), (float)StAngle/10, (float)EndAngle/10 ) ; + else + sprintf(Line, "newpath %d %d %d %f %f arc stroke\n", centre.x, centre.y, + (int)(rayon * XScale), -(float)EndAngle/10, -(float)StAngle/10 ) ; + // Undo internationalization printf (float x.y printed x,y) + to_point(Line); + fputs(Line,PlotOutputFile) ; + +} + +/*****************************************************************************/ +void PlotArcPS(wxPoint centre, int StAngle, int EndAngle, int rayon, int width) +/*****************************************************************************/ +/* trace d'un arc de cercle: + x, y = coord du centre + StAngle, EndAngle = angle de debut et fin + rayon = rayon de l'arc + w = epaisseur de l'arc +*/ +{ +char Line[256]; + + if(rayon <= 0 ) return ; + + sprintf(Line,"%d setlinewidth\n", (int) (width * XScale) ); + fputs(Line, PlotOutputFile); + PlotArcPS( centre, StAngle, EndAngle, rayon); +} + + +/***************************************************/ +void PlotPolyPS( int nb_segm, int * coord, int fill) +/***************************************************/ +/* Trace un polygone ( ferme si rempli ) en format POSTSCRIPT + coord = tableau des coord des sommets + nb_segm = nombre de coord ( 1 coord = 2 elements: X et Y du tableau ) + fill : si != 0 polygone rempli +*/ +{ +int ii; +wxPoint pos; + + if( nb_segm <= 1 ) return; + + pos.x = coord[0]; pos.y = coord[1]; + UserToDeviceCoordinate(pos); + fprintf(PlotOutputFile, "newpath %d %d moveto\n", pos.x, pos.y); + + for( ii = 1; ii < nb_segm; ii ++ ) + { + pos.x = coord[ii*2]; pos.y = coord[(ii*2)+1]; + UserToDeviceCoordinate(pos); + fprintf(PlotOutputFile, "%d %d lineto\n", pos.x, pos.y); + } + + /* Fermeture du polygone */ + if( fill ) fprintf(PlotOutputFile, "closepath "); + if( fill == 1 ) fprintf(PlotOutputFile, "fill "); + fprintf(PlotOutputFile, "stroke\n"); +} + + +/*************************************/ +/* Routine to draw to a new position */ +/*************************************/ +void LineTo_PS(wxPoint pos, int plume) +{ + if ( plume == 'Z') return; + + UserToDeviceCoordinate(pos); + if ( plume == 'D') + { + char Line[256]; + sprintf(Line,"%d %d %d %d line\n", + LastPenPosition.x, LastPenPosition.y, pos.x, pos.y); + fputs(Line,PlotOutputFile); + } + LastPenPosition = pos; +} + + +/**********************************************************/ +void PrintHeaderPS(FILE * file, const wxString & Creator, + const wxString & FileName, int BBox[4]) +/***********************************************************/ +/* BBox is the boundary box (position and size of the "client rectangle" +for drawings (page - margins) in mils (0.001 inch) +*/ +{ +wxString msg; +char Line[1024]; +const char *PSMacro[] = { +"/line {\n", +" newpath\n", +" moveto\n", +" lineto\n", +" stroke\n", +"} def\n", +"gsave\n", +"72 72 scale\t\t\t%% Talk inches\n", +"1 setlinecap\n", +"1 setlinejoin\n", +"1 setlinewidth\n", + NULL +}; +#define MIL_TO_INCH 0.001 +int ii; +time_t time1970 = time(NULL); + + PlotOutputFile = file; + + fputs("%!PS-Adobe-3.0\n",PlotOutputFile); // Print header + + /* Print boundary box en 1/72 pouce, box is in mils */ + #define CONV_SCALE (MIL_TO_INCH * 72) + sprintf( Line, "%%%%BoundingBox: %d %d %d %d\n", + (int)(BBox[1]*CONV_SCALE), (int)(BBox[0]*CONV_SCALE), + (int)(BBox[3]*CONV_SCALE), (int)(BBox[2]*CONV_SCALE)); + fputs(Line, PlotOutputFile); + + sprintf( Line, "%%%%Title: %s\n", CONV_TO_UTF8(FileName) ); + fputs(Line, PlotOutputFile); + + sprintf( Line, "%%%%Creator: %s_n", CONV_TO_UTF8(Creator) ); + fputs(Line, PlotOutputFile); + + sprintf( Line, "%%%%CreationDate: %s\n", ctime(&time1970) ); + fputs(Line, PlotOutputFile); + + sprintf( Line, "%%%%DocumentPaperSizes: %s\n", CONV_TO_UTF8(SheetPS->m_Name) ); + fputs(Line, PlotOutputFile); + + sprintf( Line, "%%%%Orientation: Landscape\n%%%%EndComments\n"); + fputs(Line, PlotOutputFile); + + for (ii = 0; PSMacro[ii] != NULL; ii++) + { + fputs(PSMacro[ii],PlotOutputFile); + } + + sprintf(Line, "%f %f translate 90 rotate\n", + (float) BBox[3] * MIL_TO_INCH, (float)BBox[0] * MIL_TO_INCH ); + // compensation internationalisation printf (float x.y généré x,y) + to_point(Line); + + fputs(Line,PlotOutputFile); + + sprintf(Line,"%f %f scale\t\t%% Move to User coordinates\n", + XScale, YScale); + to_point(Line); + fputs(Line,PlotOutputFile); + + // Set default line width: + fprintf(PlotOutputFile,"%d setlinewidth\n", PenWidth ); //PenWidth in user units +} + + +/******************************************/ +bool CloseFilePS(FILE * plot_file) +/******************************************/ +{ + fputs("showpage\n",plot_file); + fputs("grestore\n",plot_file); + + fclose(plot_file); + + return TRUE; +} + diff --git a/common/common_plot_functions.cpp b/common/common_plot_functions.cpp new file mode 100644 index 0000000000..e3c10776ee --- /dev/null +++ b/common/common_plot_functions.cpp @@ -0,0 +1,333 @@ + /******************************************/ + /* Kicad: Common plot Postscript Routines */ + /******************************************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "trigo.h" +#include "wxstruct.h" +#include "base_struct.h" +#include "common.h" +#include "plot_common.h" +#include "worksheet.h" +#include "macros.h" + + +// Variables partagees avec Common plot Postscript et HPLG Routines +wxPoint LastPenPosition; +wxPoint PlotOffset; +FILE * PlotOutputFile; +double XScale, YScale; +int PenWidth; +int PlotOrientOptions, etat_plume; + + +// Locales +static Ki_PageDescr * SheetPS; + +/**********************************************/ +void SetPlotScale(double xscale, double yscale) +/**********************************************/ +/* Set the plot scale for the current plotting) +*/ +{ + XScale = xscale; + YScale = yscale; +} + +/*********************************/ +void SetPlotOffset(wxPoint offset) +/*********************************/ +/* Set the plot offset for the current plotting) +*/ +{ + PlotOffset = offset; +} + +/***************************************************************************/ +void InitPlotParametresGERBER(wxPoint offset, double xscale, double yscale) +/***************************************************************************/ +/* Set the plot offset for the current plotting + xscale,yscale = coordinate scale (scale coefficient for coordinates) +*/ +{ + PlotOrientOptions = 0; + PlotOffset = offset; + SheetPS = NULL; + XScale = xscale; + YScale = yscale; + PenWidth = 120; /* epaisseur du trait standard en 1/1000 pouce */ +} + + +/*******************************************************/ +void PlotWorkSheet(int format_plot, BASE_SCREEN * screen) +/*******************************************************/ +/* Plot sheet references + margin is in mils (1/1000 inch) +*/ +{ +#define WSTEXTSIZE 50 // Text size in mils +Ki_PageDescr * Sheet = screen->m_CurrentSheet; +int ii, jj, xg , yg, ipas, gxpas, gypas; +wxSize PageSize; +wxPoint pos, ref; +int color; +Ki_WorkSheetData * WsItem; +int conv_unit = screen->GetInternalUnits()/1000; +wxString msg; +wxSize text_size; +void (*FctPlume)(wxPoint pos, int state); +int UpperLimit = VARIABLE_BLOCK_START_POSITION; + + switch ( format_plot) + { + case PLOT_FORMAT_POST: + FctPlume = LineTo_PS; + break; + + case PLOT_FORMAT_HPGL: + FctPlume = Move_Plume_HPGL; + break; + + case PLOT_FORMAT_GERBER: + default: + return; + } + + color = BLACK; + + PageSize.x = Sheet->m_Size.x; + PageSize.y = Sheet->m_Size.y; + + /* trace de la bordure */ + ref.x = Sheet->m_LeftMargin * conv_unit; + ref.y = Sheet->m_TopMargin * conv_unit; /* Upper left corner */ + xg = (PageSize.x - Sheet->m_RightMargin) * conv_unit; + yg = (PageSize.y - Sheet->m_BottomMargin) * conv_unit; /* lower right corner */ + + for ( ii = 0; ii < 2 ; ii++ ) + { + FctPlume(ref,'U'); + pos.x = xg; pos.y = ref.y; + FctPlume(pos,'D'); + pos.x = xg; pos.y = yg; + FctPlume(pos,'D'); + pos.x = ref.x; pos.y = yg; + FctPlume( pos,'D' ); + FctPlume(ref,'D'); + ref.x += GRID_REF_W * conv_unit; ref.y += GRID_REF_W * conv_unit; + xg -= GRID_REF_W * conv_unit; yg -= GRID_REF_W * conv_unit; + } + + /* trace des reperes */ + text_size.x = WSTEXTSIZE * conv_unit; + text_size.y = WSTEXTSIZE * conv_unit; + + ref.x = Sheet->m_LeftMargin * conv_unit; + ref.y = Sheet->m_TopMargin * conv_unit; /* Upper left corner */ + xg = (PageSize.x - Sheet->m_RightMargin) * conv_unit; + yg = (PageSize.y - Sheet->m_BottomMargin) * conv_unit; /* lower right corner */ + + /* Trace des reperes selon l'axe X */ + ipas = (xg - ref.x) / PAS_REF; + gxpas = ( xg - ref.x) / ipas; + for ( ii = ref.x + gxpas, jj = 1; ipas > 0 ; ii += gxpas , jj++, ipas--) + { + msg.Empty(); msg << jj; + if( ii < xg - PAS_REF/2 ) + { + pos.x = ii * conv_unit; pos.y = ref.y * conv_unit; + FctPlume(pos, 'U'); + pos.x = ii * conv_unit; pos.y = (ref.y + GRID_REF_W) * conv_unit; + FctPlume(pos,'D'); + } + pos.x = (ii - gxpas/2) * conv_unit; + pos.y = (ref.y + GRID_REF_W/2) * conv_unit; + PlotGraphicText(format_plot, pos, color, + msg, TEXT_ORIENT_HORIZ,text_size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + + if( ii < xg - PAS_REF/2 ) + { + pos.x = ii * conv_unit; pos.y = yg * conv_unit; + FctPlume(pos,'U'); + pos.x = ii * conv_unit; pos.y = (yg - GRID_REF_W) * conv_unit; + FctPlume(pos,'D'); + } + pos.x = (ii - gxpas/2) * conv_unit; + pos.y = (yg - GRID_REF_W/2) * conv_unit; + PlotGraphicText(format_plot, pos, color, + msg, TEXT_ORIENT_HORIZ,text_size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + } + + /* Trace des reperes selon l'axe Y */ + ipas = (yg - ref.y) / PAS_REF; + gypas = ( yg - ref.y) / ipas; + for ( ii = ref.y + gypas, jj = 0; ipas > 0 ; ii += gypas , jj++, ipas--) + { + msg.Empty(); msg << jj; + if( ii < yg - PAS_REF/2 ) + { + pos.x = ref.x * conv_unit; pos.y = ii * conv_unit; + FctPlume(pos,'U'); + pos.x = (ref.x + GRID_REF_W) * conv_unit; pos.y = ii * conv_unit; + FctPlume(pos, 'D'); + } + pos.x = (ref.x + GRID_REF_W/2) * conv_unit; + pos.y = (ii - gypas/2) * conv_unit; + PlotGraphicText(format_plot, pos, color, + msg, TEXT_ORIENT_HORIZ,text_size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + + if( ii < yg - PAS_REF/2 ) + { + pos.x = xg * conv_unit; pos.y = ii * conv_unit; + FctPlume(pos,'U'); + pos.x = (xg - GRID_REF_W) * conv_unit; pos.y = ii * conv_unit; + FctPlume(pos,'D'); + } + pos.x = (xg - GRID_REF_W/2) * conv_unit; + pos.y = (ii - gypas/2) * conv_unit; + PlotGraphicText(format_plot, pos, color, msg, TEXT_ORIENT_HORIZ,text_size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + } + + /* Trace du cartouche */ + text_size.x = SIZETEXT * conv_unit; + text_size.y = SIZETEXT * conv_unit; + ref.x = PageSize.x - GRID_REF_W - Sheet->m_RightMargin; + ref.y = PageSize.y - GRID_REF_W - Sheet->m_BottomMargin; + + for( WsItem = &WS_Date; WsItem != NULL; WsItem = WsItem->Pnext ) + { + pos.x = (ref.x - WsItem->m_Posx) * conv_unit; + pos.y = (ref.y - WsItem->m_Posy) * conv_unit; + if(WsItem->m_Legende) msg = WsItem->m_Legende; + else msg.Empty(); + switch( WsItem->m_Type ) + { + case WS_DATE: + msg += screen->m_Date; + break; + + case WS_REV: + msg += screen->m_Revision; + break; + + case WS_LICENCE: + msg += g_ProductName; + break; + + case WS_SIZESHEET: + msg += screen->m_CurrentSheet->m_Name; + break; + + case WS_IDENTSHEET: + msg << screen->m_SheetNumber << wxT("/") << screen->m_NumberOfSheet; + break; + + case WS_COMPANY_NAME: + msg += screen->m_Company; + if ( ! msg.IsEmpty() ) + UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); + break; + + case WS_TITLE: + msg += screen->m_Title; + break; + + case WS_COMMENT1: + msg += screen->m_Commentaire1; + if ( ! msg.IsEmpty() ) + UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); + break; + + case WS_COMMENT2: + msg += screen->m_Commentaire2; + if ( ! msg.IsEmpty() ) + UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); + break; + + case WS_COMMENT3: + msg += screen->m_Commentaire3; + if ( ! msg.IsEmpty() ) + UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); + break; + + case WS_COMMENT4: + msg += screen->m_Commentaire4; + if ( ! msg.IsEmpty() ) + UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); + break; + + case WS_UPPER_SEGMENT: + if (UpperLimit == 0 ) break; + case WS_LEFT_SEGMENT: + WS_MostUpperLine.m_Posy = + WS_MostUpperLine.m_Endy = + WS_MostLeftLine.m_Posy = UpperLimit; + pos.y = (ref.y - WsItem->m_Posy) * conv_unit; + case WS_SEGMENT: + { + wxPoint auxpos; + auxpos.x = (ref.x - WsItem->m_Endx) * conv_unit;; + auxpos.y = (ref.y - WsItem->m_Endy) * conv_unit;; + FctPlume(pos, 'U'); + FctPlume(auxpos, 'D'); + } + break; + + } + if ( ! msg.IsEmpty() ) + { + PlotGraphicText(format_plot, pos, color, + msg.GetData(), TEXT_ORIENT_HORIZ,text_size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + } + } + + switch ( format_plot ) + { + case PLOT_FORMAT_HPGL: + Plume_HPGL('U'); + break; + case PLOT_FORMAT_POST: + break; + } +} + + +/******************************************/ +void UserToDeviceCoordinate(wxPoint & pos ) +/******************************************/ +/* modifie les coord pos.x et pos.y pour le trace selon l'orientation, + l'echelle, les offsets de trace */ +{ + + pos.x = (int) (pos.x * XScale); + pos.y = (int) (pos.y * YScale); + + switch ( PlotOrientOptions) /* Calcul du cadrage */ + { + default : + pos.x -= PlotOffset.x ; pos.y = PlotOffset.y - pos.y; + break ; + + case PLOT_MIROIR : + pos.x -= PlotOffset.x ; pos.y = - PlotOffset.y + pos.y; + break ; + + } +} + +/************************************/ +void UserToDeviceSize(wxSize & size ) +/************************************/ +/* modifie les dimension size.x et size.y pour le trace selon l'echelle */ +{ + size.x = (int) (size.x * XScale); + size.y = (int) (size.y * YScale); +} + diff --git a/common/confirm.cpp b/common/confirm.cpp new file mode 100644 index 0000000000..2374199b8f --- /dev/null +++ b/common/confirm.cpp @@ -0,0 +1,145 @@ + /*************************/ + /* Menu " CONFIRMATION " */ + /* fonction Get_Message */ + /* test demande ESC */ + /*************************/ + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWindows headers +#ifndef WX_PRECOMP +#include +#endif + +#include "fctsys.h" +#include "common.h" + +enum id_dialog { + ID_TIMOUT = 1500 +}; + +/* Classe d'affichage de messages, identique a wxMessageDialog, + mais pouvant etre effacee au bout d'un time out donne +*/ +class WinEDA_MessageDialog: public wxMessageDialog +{ +public: + int m_LifeTime; +private: + wxTimer m_Timer; + +public: + WinEDA_MessageDialog(wxWindow * parent, const wxString & msg, + const wxString & title, int style, int lifetime); + ~WinEDA_MessageDialog(){}; + + void OnTimeOut(wxTimerEvent& event); + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(WinEDA_MessageDialog, wxMessageDialog) + EVT_TIMER(ID_TIMOUT, WinEDA_MessageDialog::OnTimeOut) +END_EVENT_TABLE() + +/**********************************************************************************/ +WinEDA_MessageDialog::WinEDA_MessageDialog(wxWindow * parent, const wxString & msg, + const wxString & title, int style, int lifetime) : + wxMessageDialog(parent, msg, title, style) +/**********************************************************************************/ +{ + m_LifeTime = lifetime; + m_Timer.SetOwner(this,ID_TIMOUT); + if ( m_LifeTime > 0 ) + m_Timer.Start(100*m_LifeTime, wxTIMER_ONE_SHOT); // m_LifeTime = duree en 0.1 secondes +} + +/********************************************************/ +void WinEDA_MessageDialog::OnTimeOut(wxTimerEvent& event) +/********************************************************/ +{ + // TODO : EndModal() request +} + +/*****************************************************************************/ +void DisplayError(wxWindow * parent, const wxString & text, int displaytime ) +/*****************************************************************************/ +/* Affiche un Message d'Erreur ou d'avertissement. + si warn > 0 le dialogue disparait apres warn 0.1 secondes +*/ +{ +wxMessageDialog * dialog; + + if ( displaytime > 0 ) + dialog = new WinEDA_MessageDialog(parent, text, _("Warning"), + wxOK | wxICON_INFORMATION | wxSTAY_ON_TOP, displaytime); + else + dialog = new WinEDA_MessageDialog(parent, text, _("Error"), + wxOK | wxICON_EXCLAMATION | wxSTAY_ON_TOP, 0); + + dialog->ShowModal(); dialog->Destroy(); +} + +/**************************************************************************/ +void DisplayInfo(wxWindow * parent, const wxString & text, int displaytime) +/**************************************************************************/ +/* Affiche un Message d'information. +*/ + +{ +wxMessageDialog * dialog; + + dialog = new WinEDA_MessageDialog(parent, text, _("Infos:"), + wxOK | wxICON_INFORMATION | wxSTAY_ON_TOP, displaytime); + + dialog->ShowModal(); dialog->Destroy(); +} + + +/**************************************************/ +bool IsOK(wxWindow * parent, const wxString & text) +/**************************************************/ +{ +int ii; + ii = wxMessageBox(text, _("Confirmation"), wxYES_NO|wxCENTRE|wxICON_HAND, parent); + if (ii == wxYES) return TRUE; + return FALSE; +} + +/***********************************************************************/ +int Get_Message(const wxString & title, wxString & buffer, wxWindow * frame) +/***********************************************************************/ +/* Get a text from user + titre = titre a afficher + buffer : text enter by user + leading and trailing spaces are removed + if buffer != "" buffer is displayed + return: + 0 if OK + != 0 if ESCAPE +*/ +{ +wxString message, default_text; + + if ( buffer ) default_text = buffer; + + message = wxGetTextFromUser(title, _("Text:"), + default_text, frame); + if ( !message.IsEmpty() ) + { + message.Trim(FALSE); // Remove blanks at beginning + message.Trim(TRUE); // Remove blanks at end + buffer = message; + return 0; + } + + return(1); +} + + + diff --git a/common/copy_to_clipboard.cpp b/common/copy_to_clipboard.cpp new file mode 100644 index 0000000000..b0af12b12b --- /dev/null +++ b/common/copy_to_clipboard.cpp @@ -0,0 +1,141 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: copy_to_clipboard.cpp +// Author: jean-pierre Charras +// Created: 18 aug 2006 +// Licence: License GNU +///////////////////////////////////////////////////////////////////////////// +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + + +#include +#include "wx/metafile.h" +#include "fctsys.h" + +#include "common.h" +#include "id.h" + +extern BASE_SCREEN * ActiveScreen; + +static bool s_PlotBlackAndWhite = FALSE; +static bool Print_Sheet_Ref = TRUE; + +static bool DrawPage(WinEDA_DrawPanel * panel); + +/************************************************************/ +void WinEDA_DrawFrame::CopyToClipboard(wxCommandEvent& event) +/************************************************************/ +/* calls the function to copy the current page or the current bock to the clipboard +*/ +{ + DrawPage(DrawPanel); + + if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD ) + { + if (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE) + DrawPanel->SetCursor(wxCursor(DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor) ); + + if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) + { + wxClientDC dc(DrawPanel); + DrawPanel->PrepareGraphicContext(&dc); + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + } +} + +/*****************************************************************/ +bool DrawPage(WinEDA_DrawPanel * panel) +/*****************************************************************/ +/* copy the current page or block to the clipboard , + to export drawings to other applications (word processing ...) + Thi is not suitable for copy command within eeschema or pcbnew +*/ +{ +bool success = TRUE; + +#ifdef __WINDOWS__ +int tmpzoom; +wxPoint tmp_startvisu; +wxPoint old_org; +wxPoint DrawOffset; // Offset de trace +int ClipboardSizeX, ClipboardSizeY; +bool DrawBlock = FALSE; +wxRect DrawArea; + + /* scale is the ratio resolution/internal units */ + float scale = 82.0 / panel->m_Parent->m_InternalUnits; + + if ( ActiveScreen->BlockLocate.m_Command != BLOCK_IDLE ) + { + DrawBlock = TRUE; + DrawArea.SetX((int)(ActiveScreen->BlockLocate.GetX()) ); + DrawArea.SetY((int)(ActiveScreen->BlockLocate.GetY())); + DrawArea.SetWidth((int)(ActiveScreen->BlockLocate.GetWidth())); + DrawArea.SetHeight((int)(ActiveScreen->BlockLocate.GetHeight())); + } + + /* modification des cadrages et reglages locaux */ + tmp_startvisu = ActiveScreen->m_StartVisu; + tmpzoom = ActiveScreen->GetZoom(); + old_org = ActiveScreen->m_DrawOrg; + ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0; + ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.y = 0; + + ActiveScreen->SetZoom(1); + +wxMetafileDC dc/*(wxT(""), DrawArea.GetWidth(), DrawArea.GetHeight())*/; + + if ( ! dc.Ok() ) + { + DisplayError(NULL, wxT("CopyToClipboard: DrawPage error: wxMetafileDC not OK")); + success = FALSE; + } + + else + { + EDA_Rect tmp = panel->m_ClipBox; + GRResetPenAndBrush(&dc); + GRForceBlackPen(s_PlotBlackAndWhite); + g_IsPrinting = TRUE; + dc.SetUserScale(scale, scale); + ClipboardSizeX = dc.MaxX() + 10; + ClipboardSizeY = dc.MaxY() + 10; + panel->m_ClipBox.SetX(0);panel->m_ClipBox.SetY(0); + panel->m_ClipBox.SetWidth(0x7FFFFF0); panel->m_ClipBox.SetHeight(0x7FFFFF0); + + if ( DrawBlock ) + { + dc.SetClippingRegion( DrawArea ); + } + panel->PrintPage(&dc, Print_Sheet_Ref, -1); + g_IsPrinting = FALSE; + panel->m_ClipBox = tmp; + wxMetafile *mf = dc.Close(); + if (mf) + { + success = mf->SetClipboard(ClipboardSizeX, ClipboardSizeY); + delete mf; + } + } + + + GRForceBlackPen(FALSE); + SetPenMinWidth(1); + + ActiveScreen->m_StartVisu = tmp_startvisu; + ActiveScreen->m_DrawOrg = old_org; + ActiveScreen->SetZoom(tmpzoom); +#endif + + return success; +} + diff --git a/common/dcsvg.cpp b/common/dcsvg.cpp new file mode 100644 index 0000000000..f1aca3218d --- /dev/null +++ b/common/dcsvg.cpp @@ -0,0 +1,872 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: svg.cpp +// Purpose: SVG plot +// Author: Chris Elliott +// Modified by: JP Charras (dec 2006) +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +#include "dcsvg.h" + +#include "wx/image.h" + +#define wxSVG_DEBUG FALSE +// or TRUE to see the calls being executed +#define newline wxString(wxT("\n")) +#define space wxString(wxT(" ")) +#define semicolon wxString(wxT(";")) +#define wx_round(a) (int)((a)+.5) + +#ifdef __BORLANDC__ +#pragma warn -rch +#pragma warn -ccc +#endif + + +/* some define not included in early wxWidget versions: */ +#ifndef twips2mm +#define twips2mm 0.0176388888889 +#endif +#ifndef pt2mm +#define pt2mm 0.352777777778 +#endif + +static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; } ; + +wxString wxColStr ( wxColour c ) +{ + unsigned char r, g, b ; + r = c.Red (); + g = c.Green (); + b = c. Blue (); + + // possible Unicode bug here + wxString s = wxDecToHex(r) + wxDecToHex(g) + wxDecToHex(b) ; + return s ; +} + + +wxString wxBrushString ( wxColour c, int style ) +{ + wxString s = wxT("fill:#") + wxColStr (c) + semicolon + space ; + switch ( style ) + { + case wxSOLID : + s = s + wxT("fill-opacity:1.0; "); + break ; + case wxTRANSPARENT: + s = s + wxT("fill-opacity:0.0; "); + break ; + + default : + wxASSERT_MSG(FALSE, wxT("wxSVGFileDC::Requested Brush Style not available")) ; + + } + s = s + newline ; + return s ; +} + + +/***********************************************************************/ +void wxSVGFileDC::Init (wxString f, int Width, int Height, float dpi) +/***********************************************************************/ +/* set up things first wxDCBase does all this? +*/ +{ + m_width = Width ; + m_height = Height ; + + m_clipping = FALSE; + m_OK = TRUE; + + m_mm_to_pix_x = dpi/25.4; + m_mm_to_pix_y = dpi/25.4; + + m_signX = m_signY = 1; + + m_userScaleX = m_userScaleY = + m_deviceOriginX = m_deviceOriginY = 0; + + m_OriginX = m_OriginY = 0; + m_logicalOriginX = m_logicalOriginY = 0; + m_logicalScaleX = m_logicalScaleY = 0 ; + m_scaleX = m_scaleY = 1.0 ; + + m_logicalFunction = wxCOPY; + m_backgroundMode = wxTRANSPARENT; + m_mappingMode = wxMM_TEXT; + + m_backgroundBrush = *wxTRANSPARENT_BRUSH; + m_textForegroundColour = *wxBLACK; + m_textBackgroundColour = *wxWHITE; + m_colour = wxColourDisplay(); + + m_pen = *wxBLACK_PEN; + m_font = *wxNORMAL_FONT; + m_brush = *wxWHITE_BRUSH; + + m_graphics_changed = TRUE ; + + ////////////////////code here + + m_outfile = new wxFileOutputStream(f) ; + m_OK = m_outfile->Ok (); + if (m_OK) + { + m_filename = f ; + m_sub_images = 0 ; + wxString s ; + s = wxT("") ; s = s + newline ; + write(s); + s = wxT(" ")+ newline ; + write(s); + + s.Printf ( wxT("\n") ); + write(s); + + s = wxT(" SVG Picture created as ") + wxFileNameFromPath(f) + wxT(" ") + newline ; + write(s); + s = wxString (wxT(" Picture generated by wxSVG ")) + wxSVGVersion + wxT(" ")+ newline ; + write(s); + s = wxT(" ") + newline ; + write(s); + + } +} + + +// constructors +wxSVGFileDC::wxSVGFileDC (wxString f) +{ + // quarter 640x480 screen display at 72 dpi + Init (f,320,240,72.0); +}; + +wxSVGFileDC::wxSVGFileDC (wxString f, int Width, int Height) +{ + Init (f,Width,Height,72.0); +}; + +wxSVGFileDC::wxSVGFileDC (wxString f, int Width, int Height, float dpi) +{ + Init (f,Width,Height,dpi); +}; + +wxSVGFileDC::~wxSVGFileDC() +{ + wxString s = wxT(" \n \n") ; + write(s); + delete m_outfile ; +} + + +////////////////////////////////////////////////////////////////////////////////////////// + +void wxSVGFileDC::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) +{ + if (m_graphics_changed) NewGraphics (); + wxString s ; + s.Printf ( wxT(" \n"), x1,y1,x2,y2 ); + if (m_OK) + { + write(s); + } + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DrawLine Call executed")) ; + CalcBoundingBox(x1, y1) ; + CalcBoundingBox(x2, y2) ; + return; +}; + +void wxSVGFileDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset , wxCoord yoffset ) +{ + for ( int i = 1; i < n ; i++ ) + { + DoDrawLine ( points [i-1].x + xoffset, points [i-1].y + yoffset, + points [ i ].x + xoffset, points [ i ].y + yoffset ) ; + } +} + + +void wxSVGFileDC::DoDrawPoint (wxCoord x1, wxCoord y1) +{ + wxString s; + if (m_graphics_changed) NewGraphics (); + s = wxT(" ") + newline ; + write(s); + DrawLine ( x1,y1,x1,y1 ); + s = wxT(""); + write(s); +} + + +void wxSVGFileDC::DoDrawCheckMark(wxCoord x1, wxCoord y1, wxCoord width, wxCoord height) +{ + wxDCBase::DoDrawCheckMark (x1,y1,width,height) ; +} + + +void wxSVGFileDC::DoDrawText(const wxString& text, wxCoord x1, wxCoord y1) +{ + DoDrawRotatedText(text, x1,y1,0.0); + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DrawText Call executed")) ; +} + + +void wxSVGFileDC::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoord y, double angle) +{ + //known bug; if the font is drawn in a scaled DC, it will not behave exactly as wxMSW + if (m_graphics_changed) NewGraphics (); + wxString s, sTmp; + + // calculate bounding box + wxCoord w, h, desc ; + DoGetTextExtent(sText, &w, &h, &desc); + + double rad = DegToRad(angle); + + // wxT("upper left") and wxT("upper right") + CalcBoundingBox(x, y); + CalcBoundingBox((wxCoord)(x + w*cos(rad)), (wxCoord)(y - h*sin(rad))); + + // wxT("bottom left") and wxT("bottom right") + x += (wxCoord)(h*sin(rad)); + y += (wxCoord)(h*cos(rad)); + CalcBoundingBox(x, y); + CalcBoundingBox((wxCoord)(x + h*sin(rad)), (wxCoord)(y + h*cos(rad))); + + if (m_backgroundMode == wxSOLID) + { + // draw background first + // just like DoDrawRectangle except we pass the text color to it and set the border to a 1 pixel wide text background + + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::Draw Rotated Text Call plotting text background")) ; + sTmp.Printf ( wxT(" "), -angle, x,y ) ; + s = s + sTmp + newline ; + write(s); + } + //now do the text itself + s.Printf (wxT(" 0) s = s + wxT("style=\"font-family:") + sTmp + wxT("; "); + else s = s + wxT("style=\" ") ; + + wxString fontweights [3] = { wxT("normal"), wxT("lighter"), wxT("bold") }; + s = s + wxT("font-weight:") + fontweights[m_font.GetWeight() - wxNORMAL] + semicolon + space; + + wxString fontstyles [5] = { wxT("normal"), wxT("style error"), wxT("style error"), wxT("italic"), wxT("oblique") }; + s = s + wxT("font-style:") + fontstyles[m_font.GetStyle() - wxNORMAL] + semicolon + space; + + sTmp.Printf (wxT("font-size:%dpt; fill:#"), m_font.GetPointSize () ); + s = s + sTmp ; + s = s + wxColStr (m_textForegroundColour) + wxT("; stroke:#") + wxColStr (m_textForegroundColour) + wxT("; ") ; + sTmp.Printf ( wxT("stroke-width:0;\" transform=\"rotate( %.2g %d %d ) \" >"), -angle, x,y ) ; + s = s + sTmp + sText + wxT(" ") + newline ; + if (m_OK) + { + write(s); + } + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DrawRotatedText Call executed")) ; + +} + + +void wxSVGFileDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +{ + DoDrawRoundedRectangle(x, y, width, height, 0) ; +} + + +void wxSVGFileDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) + +{ + if (m_graphics_changed) NewGraphics (); + wxString s ; + + s.Printf ( wxT(" ") + newline ; + write(s); + + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawRoundedRectangle Call executed")) ; + CalcBoundingBox(x, y) ; + CalcBoundingBox(x + width, y + height) ; + +} + + +void wxSVGFileDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int fillStyle) +{ + if (m_graphics_changed) NewGraphics (); + wxString s, sTmp ; + s = wxT(" ") ; + s = s + newline ; + write(s); + + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawPolygon Call executed")) ; +} + + +void wxSVGFileDC::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord height) + +{ + if (m_graphics_changed) NewGraphics (); + + int rh = height /2 ; + int rw = width /2 ; + + wxString s; + s.Printf ( wxT(" ") + newline ; + + write(s); + + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawEllipse Call executed")) ; + CalcBoundingBox(x, y) ; + CalcBoundingBox(x + width, y + height) ; +} + + +void wxSVGFileDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc) +{ + /* Draws an arc of a circle, centred on (xc, yc), with starting point + (x1, y1) and ending at (x2, y2). The current pen is used for the outline + and the current brush for filling the shape. + + The arc is drawn in an anticlockwise direction from the start point to + the end point. */ + + if (m_graphics_changed) NewGraphics (); + wxString s ; + + // we need the radius of the circle which has two estimates + double r1 = sqrt ( double( (x1-xc)*(x1-xc) ) + double( (y1-yc)*(y1-yc) ) ); + double r2 = sqrt ( double( (x2-xc)*(x2-xc) ) + double( (y2-yc)*(y2-yc) ) ); + + wxASSERT_MSG( (fabs ( r2-r1 ) <= 3), wxT("wxSVGFileDC::DoDrawArc Error in getting radii of circle")) ; + if ( fabs ( r2-r1 ) > 3 ) //pixels + { + s = wxT(" \n") ; + write(s); + } + + double theta1 = atan2((double)(yc-y1),(double)(x1-xc)); + if ( theta1 < 0 ) theta1 = theta1 + M_PI * 2; + double theta2 = atan2((double)(yc-y2), (double)(x2-xc)); + if ( theta2 < 0 ) theta2 = theta2 + M_PI * 2; + if ( theta2 < theta1 ) theta2 = theta2 + M_PI *2 ; + + int fArc ; // flag for large or small arc 0 means less than 180 degrees + if ( fabs(theta2 - theta1) > M_PI ) fArc = 1; else fArc = 0 ; + + int fSweep = 0 ; // flag for sweep always 0 + +// s.Printf ( wxT(" ") + newline ; + + + if (m_OK) + { + write(s); + } + + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawArc Call executed")) ; +} + + +void wxSVGFileDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) +{ + /* + Draws an arc of an ellipse. The current pen is used for drawing the arc + and the current brush is used for drawing the pie. This function is + currently only available for X window and PostScript device contexts. + + x and y specify the x and y coordinates of the upper-left corner of the + rectangle that contains the ellipse. + + width and height specify the width and height of the rectangle that + contains the ellipse. + + start and end specify the start and end of the arc relative to the + three-o'clock position from the center of the rectangle. Angles are + specified in degrees (360 is a complete circle). Positive values mean + counter-clockwise motion. If start is equal to end, a complete ellipse + will be drawn. */ + + //known bug: SVG draws with the current pen along the radii, but this does not happen in wxMSW + + if (m_graphics_changed) NewGraphics (); + + wxString s ; + //radius + double rx = w / 2 ; + double ry = h / 2 ; + // center + double xc = x + rx ; + double yc = y + ry ; + + double xs, ys, xe, ye ; + xs = xc + rx * cos (DegToRad(sa)) ; + xe = xc + rx * cos (DegToRad(ea)) ; + ys = yc - ry * sin (DegToRad(sa)) ; + ye = yc - ry * sin (DegToRad(ea)) ; + + ///now same as circle arc... + + double theta1 = atan2(ys-yc, xs-xc); + double theta2 = atan2(ye-yc, xe-xc); + + int fArc ; // flag for large or small arc 0 means less than 180 degrees + if ( (theta2 - theta1) > 0 ) fArc = 1; else fArc = 0 ; + + int fSweep ; + if ( fabs(theta2 - theta1) > M_PI) fSweep = 1; else fSweep = 0 ; + +// s.Printf ( wxT(" ") + newline ; + + if (m_OK) + { + write(s); + } + + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawEllipticArc Call executed")) ; +} + + +void wxSVGFileDC::DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent , wxCoord *externalLeading , wxFont *font) const + +{ + wxScreenDC sDC ; + + sDC.SetFont (m_font); + if ( font != NULL ) sDC.SetFont ( *font ); + sDC.GetTextExtent(string, w, h, descent, externalLeading ); + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::GetTextExtent Call executed")) ; +} + + +wxCoord wxSVGFileDC::GetCharHeight() const + +{ + wxScreenDC sDC ; + sDC.SetFont (m_font); + + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::GetCharHeight Call executing")) ; + return ( sDC.GetCharHeight() ); + +} + + +wxCoord wxSVGFileDC::GetCharWidth() const +{ + wxScreenDC sDC ; + sDC.SetFont (m_font); + + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::GetCharWidth Call executing")) ; + return ( sDC.GetCharWidth() ) ; + +} + + +/// Set Functions ///////////////////////////////////////////////////////////////// +void wxSVGFileDC::SetBackground( const wxBrush &brush ) +{ + + m_backgroundBrush = brush; + return; +} + + +void wxSVGFileDC::SetBackgroundMode( int mode ) +{ + m_backgroundMode = mode; + return; +} + + +void wxSVGFileDC::SetBrush(const wxBrush& brush) + +{ + m_brush = brush ; + + m_graphics_changed = TRUE ; + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::SetBrush Call executed")) ; +} + + +void wxSVGFileDC::SetPen(const wxPen& pen) +{ + // width, color, ends, joins : currently implemented + // dashes, stipple : not implemented + m_pen = pen ; + + m_graphics_changed = TRUE ; + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::SetPen Call executed")) ; +} + +void wxSVGFileDC::NewGraphics () +{ + + int w = m_pen.GetWidth (); + wxColour c = m_pen.GetColour () ; + + wxString s, sBrush, sPenCap, sPenJoin, sPenStyle, sLast, sWarn; + + sBrush = wxT("\n \n") ; + } + + sLast.Printf ( wxT("stroke-width:%d\" \n transform=\"translate(%.2g %.2g) scale(%.2g %.2g)\">"), + w, m_OriginX, m_OriginY, m_scaleX, m_scaleY ); + + s = sBrush + sPenCap + sPenJoin + sPenStyle + sLast + newline + sWarn; + write(s); + m_graphics_changed = FALSE ; + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::NewGraphics Call executed")) ; +} + + +void wxSVGFileDC::SetFont(const wxFont& font) + +{ + m_font = font ; + + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::SetFont Call executed")) ; +} + + +void wxSVGFileDC::ComputeScaleAndOrigin() +{ + m_scaleX = m_logicalScaleX * m_userScaleX; + m_scaleY = m_logicalScaleY * m_userScaleY; + m_OriginX = m_logicalOriginX * m_logicalScaleX + m_deviceOriginX ; + m_OriginY = m_logicalOriginY * m_logicalScaleY + m_deviceOriginY ; + m_graphics_changed = TRUE; +} + + +int wxSVGFileDC::GetMapMode() +{ + return m_mappingMode ; +} + + +void wxSVGFileDC::SetMapMode( int mode ) +{ + switch (mode) + { + case wxMM_TWIPS: + SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); + break; + case wxMM_POINTS: + SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); + break; + case wxMM_METRIC: + SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); + break; + case wxMM_LOMETRIC: + SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); + break; + default: + case wxMM_TEXT: + SetLogicalScale( 1.0, 1.0 ); + break; + } + m_mappingMode = mode; + + /* we don't do this mega optimisation + if (mode != wxMM_TEXT) + { + m_needComputeScaleX = TRUE; + m_needComputeScaleY = TRUE; + } + */ +} + + +void wxSVGFileDC::GetUserScale(double *x, double *y) const +{ + *x = m_userScaleX ; + *y = m_userScaleY ; +} + + +void wxSVGFileDC::SetUserScale( double x, double y ) +{ + // allow negative ? -> no + m_userScaleX = x; + m_userScaleY = y; + ComputeScaleAndOrigin(); +} + + +void wxSVGFileDC::SetLogicalScale( double x, double y ) +{ + // allow negative ? + m_logicalScaleX = x; + m_logicalScaleY = y; + ComputeScaleAndOrigin(); +} + + +void wxSVGFileDC::SetLogicalOrigin( wxCoord x, wxCoord y ) +{ + // is this still correct ? + m_logicalOriginX = x * m_signX; + m_logicalOriginY = y * m_signY; + ComputeScaleAndOrigin(); +} + + +void wxSVGFileDC::SetDeviceOrigin( wxCoord x, wxCoord y ) +{ + // only wxPostScripDC has m_signX = -1, + m_deviceOriginX = x; + m_deviceOriginY = y; + ComputeScaleAndOrigin(); +} + + +void wxSVGFileDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) +{ + // only wxPostScripDC has m_signX = -1, + m_signX = (xLeftRight ? 1 : -1); + m_signY = (yBottomUp ? -1 : 1); + ComputeScaleAndOrigin(); +} + + +// export a bitmap as a raster image in png +bool wxSVGFileDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, + wxDC* source, wxCoord xsrc, wxCoord ysrc, + int logicalFunc /*= wxCOPY*/, bool useMask /*= FALSE*/, + wxCoord /*xsrcMask = -1*/, wxCoord /*ysrcMask = -1*/) +{ + if (logicalFunc != wxCOPY) + { + wxASSERT_MSG(FALSE, wxT("wxSVGFileDC::DoBlit Call requested nonCopy mode; this is not possible")) ; + return FALSE ; + } + if (useMask != FALSE) + { + wxASSERT_MSG(FALSE, wxT("wxSVGFileDC::DoBlit Call requested False mask ; this is not possible")) ; + return FALSE ; + } + wxBitmap myBitmap (width, height) ; + wxMemoryDC memDC; + memDC.SelectObject( myBitmap ); + memDC.Blit(0, 0, width, height, source, xsrc, ysrc); + memDC.SelectObject( wxNullBitmap ); + DoDrawBitmap(myBitmap, xdest, ydest); + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoBlit Call executed")) ; + return FALSE ; +} + + +void wxSVGFileDC::DoDrawIcon(const class wxIcon & myIcon, wxCoord x, wxCoord y) +{ + wxBitmap myBitmap (myIcon.GetWidth(), myIcon.GetHeight() ) ; + wxMemoryDC memDC; + memDC.SelectObject( myBitmap ); + memDC.DrawIcon(myIcon,0,0); + memDC.SelectObject( wxNullBitmap ); + DoDrawBitmap(myBitmap, x, y); + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawIcon Call executed")) ; + return ; +} + + + +void wxSVGFileDC::DoDrawBitmap(const class wxBitmap & bmp, wxCoord x, wxCoord y , bool WXUNUSED(bTransparent) /*=0*/ ) +{ + if (m_graphics_changed) NewGraphics (); + + wxString sTmp, s, sPNG ; + wxImage::AddHandler(new wxPNGHandler); + +// create suitable file name + sTmp.Printf ( wxT("_image%d.png"), m_sub_images); + sPNG = m_filename.BeforeLast(wxT('.')) + sTmp; + while (wxFile::Exists(sPNG) ) + { + m_sub_images ++ ; + sTmp.Printf ( wxT("_image%d.png"), m_sub_images); + sPNG = m_filename.BeforeLast(wxT('.')) + sTmp; + } + +//create copy of bitmap (wxGTK doesn't like saving a constant bitmap) + wxBitmap myBitmap = bmp ; +//save it + bool bPNG_OK = myBitmap.SaveFile(sPNG,wxBITMAP_TYPE_PNG); + +// refrence the bitmap from the SVG doc + int w = myBitmap.GetWidth(); + int h = myBitmap.GetHeight(); + sTmp.Printf ( wxT(" \n"), sPNG.c_str() ); + s = s + sTmp + wxT("Image from wxSVG ") + newline; + + if (m_OK && bPNG_OK) + { + write(s); + } + m_OK = m_outfile->Ok () && bPNG_OK; + wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawBitmap Call executed")) ; + + return ; +} + + +// --------------------------------------------------------------------------- +// coordinates transformations +// --------------------------------------------------------------------------- + +wxCoord wxSVGFileDC::DeviceToLogicalX(wxCoord x) const +{ + return XDEV2LOG(x); +} + + +wxCoord wxSVGFileDC::DeviceToLogicalY(wxCoord y) const +{ + return YDEV2LOG(y); +} + + +wxCoord wxSVGFileDC::DeviceToLogicalXRel(wxCoord x) const +{ + return XDEV2LOGREL(x); +} + + +wxCoord wxSVGFileDC::DeviceToLogicalYRel(wxCoord y) const +{ + return YDEV2LOGREL(y); +} + + +wxCoord wxSVGFileDC::LogicalToDeviceX(wxCoord x) const +{ + return XLOG2DEV(x); +} + + +wxCoord wxSVGFileDC::LogicalToDeviceY(wxCoord y) const +{ + return YLOG2DEV(y); +} + + +wxCoord wxSVGFileDC::LogicalToDeviceXRel(wxCoord x) const +{ + return XLOG2DEVREL(x); +} + + +wxCoord wxSVGFileDC::LogicalToDeviceYRel(wxCoord y) const +{ + return YLOG2DEVREL(y); +} + +void wxSVGFileDC::write(const wxString &s) +{ + const wxWX2MBbuf buf = s.mb_str(wxConvUTF8); + m_outfile->Write(buf, strlen((const char *)buf)); + m_OK = m_outfile->Ok(); +} + +#ifdef __BORLANDC__ +#pragma warn .rch +#pragma warn .ccc +#endif diff --git a/common/displlst.cpp b/common/displlst.cpp new file mode 100644 index 0000000000..ac47d30193 --- /dev/null +++ b/common/displlst.cpp @@ -0,0 +1,261 @@ +/********************************/ +/* MODULE displlst.cpp */ +/********************************/ + +#include "fctsys.h" + +#include "wxstruct.h" +#include "gr_basic.h" +#include "macros.h" +#include "common.h" + + + + /***********************/ + /* class WinEDAListBox */ + /***********************/ + +enum listbox { + ID_LISTBOX_CANCEL = 8000, + ID_LISTBOX_LIST, + ID_LISTBOX_OK +}; + +BEGIN_EVENT_TABLE(WinEDAListBox, wxDialog) + EVT_BUTTON(ID_LISTBOX_OK, WinEDAListBox::Ok) + EVT_BUTTON(ID_LISTBOX_CANCEL, WinEDAListBox::Cancel) + EVT_LISTBOX(ID_LISTBOX_LIST, WinEDAListBox::ClickOnList) + EVT_LISTBOX_DCLICK(ID_LISTBOX_LIST, WinEDAListBox::D_ClickOnList) + EVT_CLOSE( WinEDAListBox::OnClose ) +END_EVENT_TABLE() + + + /*******************************/ + /* Constructeur et destructeur */ + /*******************************/ +/* Permet l'affichage d'une liste d'elements pour selection. + itemlist = pointeur sur la liste des pinteurs de noms + reftext = preselection + movefct = fonction de création de commentaires a afficher +*/ + +WinEDAListBox::WinEDAListBox( wxWindow * parent, const wxString & title, + const wxChar ** itemlist, + const wxString & reftext, + void(* movefct)(wxString & Text), + const wxColour & colour, wxPoint dialog_position): + wxDialog(parent, -1, title, dialog_position, wxDefaultSize, + wxDEFAULT_DIALOG_STYLE +// |wxRESIZE_BORDER + ) +{ +wxSize size; +const wxChar ** names; +int ii; + + m_ItemList = itemlist; + m_Parent = parent; + m_MoveFct = movefct; + m_WinMsg = NULL; + SetReturnCode(-1); + SetFont(*g_DialogFont); + + if ( itemlist ) + for ( names = m_ItemList, ii = 0; *names != NULL; names++) + ii++; + else ii = 30; + + wxBoxSizer * GeneralBoxSizer = new wxBoxSizer(wxVERTICAL); + SetSizer(GeneralBoxSizer); + + wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); + GeneralBoxSizer->Add(MainBoxSizer, 0, wxGROW|wxEXPAND|wxALL, 1); + + wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); + wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + size.x = 200; + size.y = 350; + m_List = new wxListBox(this, + ID_LISTBOX_LIST, + wxDefaultPosition, size, + 0, NULL, + wxLB_NEEDED_SB|wxLB_SINGLE|wxLB_HSCROLL ); + if ( colour != wxNullColour) + { + m_List->SetBackgroundColour(colour); + m_List->SetForegroundColour(*wxBLACK); + } + LeftBoxSizer->Add(m_List, 0, wxGROW|wxALL, 5); + + + if ( itemlist ) + for ( names = m_ItemList, ii = 0; *names != NULL; names++, ii++ ) + { + m_List->Append(*names); + } + + wxButton * butt = new wxButton(this, ID_LISTBOX_OK, _("Ok")); + RightBoxSizer->Add(butt, 0, wxGROW|wxALL, 5); + butt->SetDefault(); + + butt = new wxButton(this, ID_LISTBOX_CANCEL, _("Cancel")); + RightBoxSizer->Add(butt, 0, wxGROW|wxALL, 5); + + if (m_MoveFct ) + { + size.x = -1; size.y = 60; + m_WinMsg = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, size, + wxTE_READONLY|wxTE_MULTILINE); + GeneralBoxSizer->Add(m_WinMsg, 0, wxGROW|wxALL, 5); + } + + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + + if ( dialog_position == wxDefaultPosition ) // Put the window on the parent centre + { + Centre(); + } + else // Ensure the window dialog is on screen : + { + wxPoint pos; + m_Parent->GetPosition(& pos.x, &pos.y); + if ( pos.x < 0 ) pos.x = 0; + if ( pos.y < 0 ) pos.y = 0; + pos.x += 20; pos.y += 30; + Move(pos); + } +} + + +WinEDAListBox:: ~WinEDAListBox(void) +{ +} + + +/******************************************/ +void WinEDAListBox::MoveMouseToOrigin(void) +/******************************************/ +{ +int x, y, w, h; +wxSize list_size = m_List->GetSize(); +int orgx = m_List->GetRect().GetLeft(); +int orgy = m_List->GetRect().GetTop(); + + wxClientDisplayRect(&x, &y, &w, &h); + + WarpPointer(x + orgx + 20, y + orgy + (list_size.y/2) ); +} + +/*********************************************/ +wxString WinEDAListBox::GetTextSelection(void) +/*********************************************/ +{ +wxString text = m_List->GetStringSelection(); + return text; +} + +/***************************************************************/ +void WinEDAListBox::WinEDAListBox::Append(const wxString & item) +/***************************************************************/ +{ + m_List->Append(item); +} + +/******************************************************************************/ +void WinEDAListBox::InsertItems(const wxArrayString & itemlist, int position) +/******************************************************************************/ +{ + m_List->InsertItems(itemlist, position); +} + +/************************************************/ +void WinEDAListBox::Cancel(wxCommandEvent& event) +/************************************************/ +{ + EndModal(-1); +} + +/*****************************************************/ +void WinEDAListBox::ClickOnList(wxCommandEvent& event) +/*****************************************************/ +{ +wxString text; + + if (m_MoveFct) + { + m_WinMsg->Clear(); + text = m_List->GetStringSelection(); + m_MoveFct(text); + m_WinMsg->WriteText(text.GetData()); + } +} + +/*******************************************************/ +void WinEDAListBox::D_ClickOnList(wxCommandEvent& event) +/*******************************************************/ +{ +int ii = m_List->GetSelection(); + EndModal(ii); +} + + +/***********************************************/ +void WinEDAListBox::Ok(wxCommandEvent& event) +/***********************************************/ +{ +int ii = m_List->GetSelection(); + EndModal(ii); +} + +/***********************************************/ +void WinEDAListBox::OnClose(wxCloseEvent& event) +/***********************************************/ +{ + EndModal(-1); +} + + +/********************************************************************/ +static int SortItems( const wxString ** ptr1, const wxString ** ptr2 ) +/********************************************************************/ +/* Routines de comparaison pour le tri tri alphabetique, + avec traitement des nombres en tant que valeur numerique +*/ +{ + return StrNumICmp( (*ptr1)->GetData(), (*ptr2)->GetData() ); +} + + +/************************************/ +void WinEDAListBox:: SortList( void ) +/************************************/ +{ +int ii, NbItems = m_List->GetCount(); +const wxString ** BufList; + + if( NbItems <= 0 ) return; + + BufList = (const wxString **) MyZMalloc( 100*NbItems * sizeof(wxString*) ); + for( ii = 0; ii < NbItems; ii++ ) + { + BufList[ii] = new wxString(m_List->GetString(ii)); + } + + qsort(BufList, NbItems, sizeof(wxString *), + (int(*)(const void *,const void *)) SortItems); + + m_List->Clear(); + for( ii = 0; ii < NbItems; ii++ ) + { + m_List->Append(*BufList[ii]); + delete BufList[ii]; + } + + free(BufList); +} + + diff --git a/common/drawtxt.cpp b/common/drawtxt.cpp new file mode 100644 index 0000000000..8283e2622c --- /dev/null +++ b/common/drawtxt.cpp @@ -0,0 +1,413 @@ + /************************************************/ + /* drawtxt.cpp : trace des textes de composants */ + /************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "plot_common.h" + +#include "trigo.h" +#include "macros.h" + +#ifndef DEFAULT_SIZE_TEXT +#define DEFAULT_SIZE_TEXT 50 +#endif + +#define EDA_DRAWBASE +#include "grfonte.h" + +/* fonctions locales : */ + + +/****************************************************************************/ +void DrawGraphicText(WinEDA_DrawPanel * panel, wxDC * DC, + const wxPoint & Pos, int gcolor, const wxString & Text, + int orient, const wxSize & Size, int h_justify, int v_justify, int width) +/*****************************************************************************/ +/* Draw a graphic text (like module texts) + Text = text to draw + Pos = text position (according to h_justify, v_justify) + Size = text size (size.x or size.y can be < 0 for mirrored texts) + orient = angle in 0.1 degree + mode_color = GR_OR, GR_XOR.. + h_justify = horizontal justification (Left, center, right) + v_justify = vertical justification (bottom, center, top) + width = line width (pen width) (default = 0) + if width < 0 : draw segments in sketch mode, width = abs(width) +*/ +{ +int ii, kk,nbchar, AsciiCode, endcar; +int k1 , k2, x0, y0; +int zoom; +int size_h , size_v , espacement ; +SH_CODE f_cod , plume = 'U'; +const SH_CODE * ptcar; +int ptr; +int ux0, uy0, dx, dy; // Coord de trace des segments de texte & variables de calcul */ +int cX, cY; // Centre du texte +int ox, oy; // coord de trace du caractere courant +int coord[100]; // liste des coord des segments a tracer +bool sketch_mode = FALSE; + + zoom = panel->GetZoom(); + + size_h = Size.x; + size_v = Size.y; + + if ( width < 0 ) + { + width = - width; + sketch_mode = TRUE; + } + kk = 0 ; ptr = 0; /* ptr = text index */ + + /* calcul de la position du debut des textes: ox et oy */ + nbchar = Text.Len(); + if ( nbchar == 0 ) return; + + espacement = (10 * size_h ) / 9; + ox = cX = Pos.x; oy = cY = Pos.y; + + /* Si le texte est totalement hors fenetre d'affichage, terminé! */ + if ( panel ) + { + int xm, ym, ll, xc, yc; + int textsize = ABS(espacement); + ll = (textsize * nbchar) / zoom; + xc = GRMapX(cX); + yc = GRMapY(cY); + x0 = panel->m_ClipBox.GetX() - ll; + y0 = panel->m_ClipBox.GetY() -ll ; + xm = panel->m_ClipBox.GetRight() + ll; + ym = panel->m_ClipBox.GetBottom() + ll; + if ( xc < x0 ) return; + if ( yc < y0 ) return; + if ( xc > xm ) return; + if ( yc > ym ) return; + } + + + /* Calcul du cadrage du texte */ + dx = (espacement * nbchar) / 2; + dy = size_v / 2; /* Decalage du debut du texte / centre */ + + ux0 = uy0 = 0; /* Decalage du centre du texte / coord de ref */ + + if( (orient == 0) || (orient == 1800) ) /* Texte Horizontal */ + { + switch(h_justify) + { + case GR_TEXT_HJUSTIFY_CENTER: + break; + + case GR_TEXT_HJUSTIFY_RIGHT: + ux0 = - dx; + break; + + case GR_TEXT_HJUSTIFY_LEFT: + ux0 = dx; + break; + } + + switch(v_justify) + { + case GR_TEXT_VJUSTIFY_CENTER: + break; + + case GR_TEXT_VJUSTIFY_TOP: + uy0 = dy; + break; + + case GR_TEXT_VJUSTIFY_BOTTOM: + uy0 = -dy; + break; + } + } + + else /* Texte Vertical */ + { + switch(h_justify) + { + case GR_TEXT_HJUSTIFY_CENTER: + break; + + case GR_TEXT_HJUSTIFY_RIGHT: + ux0 = - dy; + break; + + case GR_TEXT_HJUSTIFY_LEFT: + ux0 = dy; + break; + } + + switch(v_justify) + { + case GR_TEXT_VJUSTIFY_CENTER: + break; + + case GR_TEXT_VJUSTIFY_TOP: + uy0 = dx; + break; + + case GR_TEXT_VJUSTIFY_BOTTOM: + uy0 = -dx; + break; + } + } + cX += ux0; cY += uy0; + ox = cX - dx; ; oy = cY + dy; + + if( (Size.x/zoom) == 0 ) return; + + if( ABS((Size.x/zoom)) < 3) /* chars trop petits pour etre dessines */ + { /* le texte est symbolise par une barre */ + dx = (espacement * nbchar) / 2; + dy = size_v / 2; /* Decalage du debut du texte / centre */ + + ux0 = cX - dx; uy0 = cY; + dx += cX; dy = cY; + RotatePoint(&ux0, &uy0, cX, cY, orient); + RotatePoint(&dx, &dy, cX, cY, orient); + GRLine(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, gcolor); + + return; + } + +#if 0 +dx = (espacement * nbchar) / 2; +dy = size_v / 2; /* Decalage du debut du texte / centre */ +ux0 = cX - dx; uy0 = cY; +dx += cX; dy = cY; +RotatePoint(&ux0, &uy0, cX, cY, orient); +RotatePoint(&dx, &dy, cX, cY, orient); +DC->SetTextForeground( wxColour( + ColorRefs[gcolor].r, + ColorRefs[gcolor].g, + ColorRefs[gcolor].b) ); +DC->DrawRotatedText(Text, GRMapX(ux0), GRMapY(uy0), (double) orient / 10.0); +return; +#endif + + while(kk++ < nbchar) + { + x0 = 0 ; y0 = 0 ; + AsciiCode = Text.GetChar(ptr) & 255; + ptcar = graphic_fonte_shape[AsciiCode] ; /* ptcar pointe la description + du caractere a dessiner */ + + for(ii = 0, endcar = FALSE; ! endcar; ptcar++) + { + f_cod = *ptcar ; /* get code n de la forme selectionnee */ + switch(f_cod) + { + case 'X' : + endcar = TRUE;/* fin du caractere */ + break; + + case 'U' : + if(ii && (plume == 'D' ) ) + { + if ( width <= 1 ) + GRPoly(&panel->m_ClipBox, DC, ii /2, coord, 0, + gcolor, gcolor); + else if ( sketch_mode ) + { + int ik, * coordptr; + coordptr = coord; + for ( ik = 0; ik < (ii-2); ik += 2, coordptr+= 2) + GRCSegm(&panel->m_ClipBox, DC, *coordptr, *(coordptr+1), + *(coordptr+2), *(coordptr+3), width, gcolor) ; + } + + else + GRPolyLines(&panel->m_ClipBox, DC, ii /2, coord, + gcolor, gcolor, width); + } + plume = f_cod; ii = 0; + break; + + case 'D' : plume = f_cod ; break ; + + default : + { + k1 = f_cod; /* trace sur axe V */ + k1 = - ((k1 * size_v) / 9) ; + ptcar++ ; + f_cod = *ptcar ; + k2 = f_cod; /* trace sur axe H */ + k2 = (k2 * size_h) / 9 ; + dx = k2 + ox; dy = k1 + oy; + RotatePoint(&dx, &dy, cX, cY, orient); + coord[ii] = dx; ii++; coord[ii] = dy; ii++; + break ; + } + } /* end switch */ + } /* end boucle for = end trace de 1 caractere */ + + ptr++; ox += espacement; + } /* end trace du texte */ + +} + + +/******************************************************************************************/ +void PlotGraphicText(int format_plot, const wxPoint & Pos, int gcolor, + const wxString & Text, + int orient, const wxSize & Size, int h_justify, int v_justify) +/******************************************************************************************/ +/* + id DrawGraphicText, for plot graphic text +*/ +{ +int kk, nbchar, end, AsciiCode; +int k1 , k2 , x0 , y0, ox, oy ; +int size_h , size_v , espacement ; +SH_CODE f_cod , plume = 'U'; +const SH_CODE * ptcar; +int ptr; +int ux0, uy0, dx, dy; // Coord de trace des segments de texte & variables de calcul */ +int cX, cY; // Centre du texte +void (*FctPlume)(wxPoint pos, int state); + + switch ( format_plot) + { + case PLOT_FORMAT_POST: + FctPlume = LineTo_PS; + break; + + case PLOT_FORMAT_HPGL: + FctPlume = Move_Plume_HPGL; + break; + + case PLOT_FORMAT_GERBER: + default: + return; + } + + if ( (gcolor >= 0) && (format_plot == PLOT_FORMAT_POST) ) + SetColorMapPS ( gcolor ); + + size_h = Size.x; + size_v = Size.y; + if(size_h == 0) size_h = DEFAULT_SIZE_TEXT; + if(size_v == 0) size_v = DEFAULT_SIZE_TEXT; + + kk = 0 ; ptr = 0; /* ptr = text index */ + + /* calcul de la position du debut des textes: ox et oy */ + nbchar = Text.Len(); + + espacement = (10 * size_h ) / 9; + ox = cX = Pos.x; oy = cY = Pos.y; + + /* Calcul du cadrage du texte */ + dx = (espacement * nbchar) / 2; + dy = size_v / 2; /* Decalage du debut du texte / centre */ + + ux0 = uy0 = 0; /* Decalage du centre du texte / ccord de ref */ + + if( (orient == 0) || (orient == 1800) ) /* Texte Horizontal */ + { + switch(h_justify) + { + case GR_TEXT_HJUSTIFY_CENTER: + break; + + case GR_TEXT_HJUSTIFY_RIGHT: + ux0 = - dx; + break; + + case GR_TEXT_HJUSTIFY_LEFT: + ux0 = dx; + break; + } + + switch(v_justify) + { + case GR_TEXT_VJUSTIFY_CENTER: + break; + + case GR_TEXT_VJUSTIFY_TOP: + uy0 = dy; + break; + + case GR_TEXT_VJUSTIFY_BOTTOM: + uy0 = -dy; + break; + } + } + + else /* Texte Vertical */ + { + switch(h_justify) + { + case GR_TEXT_HJUSTIFY_CENTER: + break; + + case GR_TEXT_HJUSTIFY_RIGHT: + ux0 = -dy; + break; + + case GR_TEXT_HJUSTIFY_LEFT: + ux0 = dy; + break; + } + + switch(v_justify) + { + case GR_TEXT_VJUSTIFY_CENTER: + break; + + case GR_TEXT_VJUSTIFY_TOP: + uy0 = dx; + break; + + case GR_TEXT_VJUSTIFY_BOTTOM: + uy0 = -dx; + break; + } + } + cX += ux0; cY += uy0; /* cX, cY = coord du centre du texte */ + ox = -dx; oy = +dy; /* ox, oy = coord debut texte, relativement au centre */ + + FctPlume(wxPoint(0,0), 'Z'); + + while(kk++ < nbchar) + { + AsciiCode = Text.GetChar(ptr) & 255; + ptcar = graphic_fonte_shape[AsciiCode] ; /* ptcar pointe la description + du caractere a dessiner */ + + for(end = 0 ; end == 0; ptcar++) + { + f_cod = *ptcar ; /* get code n de la forme selectionnee */ + switch(f_cod) + { + case 'X' : end = 1 ;/* fin du caractere */ + + case 'U' : + case 'D' : plume = f_cod ; break ; + + default : + k1 = f_cod ; /* trace sur axe V */ + k1 = -(k1 * size_v) / 9 ; + ptcar++ ; + f_cod = *ptcar; + k2 = f_cod; /* trace sur axe H */ + k2 = (k2 * size_h) / 9 ; + dx = k2 + ox; dy = k1 + oy; + RotatePoint(&dx, &dy, orient); + FctPlume(wxPoint(cX + dx, cY + dy), plume); + x0 = k2 ; y0 = k1 ; + break ; + } /* end switch */ + } /* end boucle for = end trace de 1 caractere */ + + FctPlume(wxPoint(0,0), 'Z'); + ptr++; ox += espacement; + } /* end trace du texte */ + FctPlume(wxPoint(0,0), 'Z'); +} + diff --git a/common/eda_dde.cpp b/common/eda_dde.cpp new file mode 100644 index 0000000000..f8ca2c51d9 --- /dev/null +++ b/common/eda_dde.cpp @@ -0,0 +1,203 @@ + + ////////////////////// + // Name: eda_dde.cc // + ////////////////////// + +// For compilers that support precompilation, includes "wx/wx.h". +#include + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +// for all others, include the necessary headers +#ifndef WX_PRECOMP +#include +#endif + +#include "fctsys.h" +#include "eda_dde.h" +#include "wxstruct.h" +#include "id.h" + +#include "common.h" + +#define ID_CONN "CAO_COM" + +wxString HOSTNAME(wxT("localhost")); + +/* variables locales */ +#define IPC_BUF_SIZE 4000 +char client_ipc_buffer[IPC_BUF_SIZE]; +char server_ipc_buffer[IPC_BUF_SIZE]; + +wxServer * server; + +void (* RemoteFct)(char * cmd); + +char buffcar[1024]; + +void SetupServerFunction(void (* remotefct)(char * remotecmd) ) +{ + RemoteFct = remotefct; +} + + + /*****************************/ + /* Routines liees au SERVEUR */ + /*****************************/ +/* Fonction d'initialisation d'un serveur socket +*/ +WinEDA_Server * CreateServer(wxWindow * window, int service) +{ +wxIPV4address addr; + + // Create a new server + addr.Service(service); + + server = new wxServer(addr); + if(server) + { + server->SetNotify(wxSOCKET_CONNECTION_FLAG); + server->SetEventHandler(*window, ID_EDA_SOCKET_EVENT_SERV); + server->Notify(TRUE); + } + + return server; +} + + +/********************************************************/ +void WinEDA_DrawFrame::OnSockRequest(wxSocketEvent& evt) +/********************************************************/ +/* Fonction appelee a chaque demande d'un client +*/ +{ +size_t len; +wxSocketBase *sock = evt.GetSocket(); + + switch (evt.GetSocketEvent()) + { + case wxSOCKET_INPUT: + sock->Read(server_ipc_buffer,1); + len = sock->Read(server_ipc_buffer+1,IPC_BUF_SIZE-2).LastCount(); + server_ipc_buffer[len+1] = 0; + if(RemoteFct ) RemoteFct(server_ipc_buffer); + break; + + case wxSOCKET_LOST: + return; + break; + + default: + wxPrintf( wxT("WinEDA_DrawFrame::OnSockRequest() error: Invalid event !")); + break; + } +} + +/**************************************************************/ +void WinEDA_DrawFrame::OnSockRequestServer(wxSocketEvent& evt) +/**************************************************************/ +/* fonction appelée lors d'une demande de connexion d'un client +*/ +{ +wxSocketBase *sock2; +wxSocketServer *server = (wxSocketServer *) evt.GetSocket(); + + sock2 = server->Accept(); + if (sock2 == NULL) return; + + sock2->Notify(TRUE); + sock2->SetEventHandler(*this, ID_EDA_SOCKET_EVENT); + sock2->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG); +} + + + /****************************/ + /* Routines liees au CLIENT */ + /*****************************/ + +/********************************************/ +bool SendCommand( int service, char * cmdline) +/********************************************/ +/* Fonction utilisee par un client pour envoyer une information a un serveur. + - Etablit une connection Socket Client + - envoie le contenu du buffer cmdline + - ferme la connexion + + service contient le numéro de service en ascii. +*/ +{ +wxSocketClient * sock_client; +bool success = FALSE; +wxIPV4address addr; + + // Create a connexion + addr.Hostname(HOSTNAME); + addr.Service(service); + + // Mini-tutorial for Connect() :-) (JP CHARRAS Note: see wxWidgets: sockets/client.cpp sample) + // --------------------------- + // + // There are two ways to use Connect(): blocking and non-blocking, + // depending on the value passed as the 'wait' (2nd) parameter. + // + // Connect(addr, true) will wait until the connection completes, + // returning true on success and false on failure. This call blocks + // the GUI (this might be changed in future releases to honour the + // wxSOCKET_BLOCK flag). + // + // Connect(addr, false) will issue a nonblocking connection request + // and return immediately. If the return value is true, then the + // connection has been already successfully established. If it is + // false, you must wait for the request to complete, either with + // WaitOnConnect() or by watching wxSOCKET_CONNECTION / LOST + // events (please read the documentation). + // + // WaitOnConnect() itself never blocks the GUI (this might change + // in the future to honour the wxSOCKET_BLOCK flag). This call will + // return false on timeout, or true if the connection request + // completes, which in turn might mean: + // + // a) That the connection was successfully established + // b) That the connection request failed (for example, because + // it was refused by the peer. + // + // Use IsConnected() to distinguish between these two. + // + // So, in a brief, you should do one of the following things: + // + // For blocking Connect: + // + // bool success = client->Connect(addr, true); + // + // For nonblocking Connect: + // + // client->Connect(addr, false); + // + // bool waitmore = true; + // while (! client->WaitOnConnect(seconds, millis) && waitmore ) + // { + // // possibly give some feedback to the user, + // // update waitmore if needed. + // } + // bool success = client->IsConnected(); + // + // And that's all :-) + sock_client = new wxSocketClient(); + sock_client->SetTimeout(2); // Time out in Seconds + sock_client->Connect(addr, FALSE); + sock_client->WaitOnConnect(0, 100); + + if (sock_client->Ok() && sock_client->IsConnected()) + { + success = TRUE; + sock_client->SetFlags(wxSOCKET_NOWAIT /*wxSOCKET_WAITALL*/); + sock_client->Write(cmdline, strlen(cmdline)); + } + + sock_client->Close(); + sock_client->Destroy(); + return success; +} + diff --git a/common/eda_doc.cpp b/common/eda_doc.cpp new file mode 100644 index 0000000000..7165683a4f --- /dev/null +++ b/common/eda_doc.cpp @@ -0,0 +1,256 @@ + /***************/ + /* eda_doc.cpp */ + /***************/ + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWindows headers +#ifndef WX_PRECOMP +#include +#endif +#include +#include + +#include "fctsys.h" +#include "wxstruct.h" +#include "common.h" + +/*****************************************/ +void WinEDA_App::ReadPdfBrowserInfos(void) +/*****************************************/ +/* Read from Common config the Pdf browser choice +*/ +{ + if ( m_EDA_CommonConfig ) + { + m_PdfBrowserIsDefault = m_EDA_CommonConfig->Read(wxT("PdfBrowserIsDefault"), TRUE); + m_PdfBrowser = m_EDA_CommonConfig->Read(wxT("PdfBrowserName"), wxEmptyString); + } + if ( m_PdfBrowser.IsEmpty() ) m_PdfBrowserIsDefault = TRUE; +} + +/*****************************************/ +void WinEDA_App::WritePdfBrowserInfos(void) +/*****************************************/ +/* Write into Common config the Pdf browser choice +*/ +{ + if ( ! m_EDA_CommonConfig ) return; + if ( m_PdfBrowser.IsEmpty() ) m_PdfBrowserIsDefault = TRUE; + m_EDA_CommonConfig->Write(wxT("PdfBrowserIsDefault"), m_PdfBrowserIsDefault); + m_EDA_CommonConfig->Write(wxT("PdfBrowserName"), m_PdfBrowser); +} + + +// Mime type extensions +static wxMimeTypesManager * mimeDatabase; +static const wxFileTypeInfo EDAfallbacks[] = + { + wxFileTypeInfo(wxT("text/pdf"), + wxT("xpdf %s"), + wxT("xpdf -p %s"), + wxT("pdf document (from Kicad)"), + wxT("pdf"), wxT("PDF"), NULL), + + wxFileTypeInfo(wxT("text/html"), + wxT("wxhtml %s"), + wxT("wxhtml %s"), + wxT("html document (from Kicad)"), + wxT("htm"), wxT("html"), NULL), + + wxFileTypeInfo(wxT("application/sch"), + wxT("eeschema %s"), + wxT("eeschema -p %s"), + wxT("sch document (from Kicad)"), + wxT("sch"), wxT("SCH"), NULL), + // must terminate the table with this! + wxFileTypeInfo() +}; + + +/********************************************************************/ +bool GetAssociatedDocument(wxFrame * frame, const wxString & LibPath, + const wxString & DocName) +/*********************************************************************/ +/* Launch the viewer for the doc file DocName (mime type) + LibPath is the doc file search path: + (kicad/library) + DocName is the short filename with ext. Wildcarts are allowed + Seach file is made in LibPath/doc/DocName + + if DocName is starting by http: or ftp: or www. the default internet browser is launched +*/ +{ +wxString docpath, fullfilename; +wxString Line; +wxString command; +bool success = FALSE; + + // Is an internet url + wxString url_header[3] = {wxT("http:"), wxT("ftp:"),wxT("www.") }; + for ( int ii = 0; ii < 3; ii ++ ) + { + if ( DocName.First(url_header[ii]) == 0 ) //. seems an internet url + { + wxLaunchDefaultBrowser(DocName); + return TRUE; + } + } + + /* Compute the full file name */ + if ( wxIsAbsolutePath(DocName) ) fullfilename = DocName; + else + { + docpath = LibPath + wxT("doc/"); + fullfilename = docpath + DocName; + } + +#ifdef __WINDOWS__ + fullfilename.Replace(UNIX_STRING_DIR_SEP, WIN_STRING_DIR_SEP); +#else + fullfilename.Replace(WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP); +#endif + + if ( wxIsWild(fullfilename) ) + { + fullfilename = + EDA_FileSelector(_("Doc Files"), /* Titre de la fenetre */ + wxPathOnly(fullfilename), /* Chemin par defaut */ + fullfilename, /* nom fichier par defaut */ + wxEmptyString, /* extension par defaut */ + wxEmptyString, /* Masque d'affichage */ + frame, /* parent frame */ + wxFD_OPEN, /* wxSAVE, wxFD_OPEN ..*/ + TRUE, /* true = ne change pas le repertoire courant */ + wxPoint(-1,-1) + ); + if ( fullfilename.IsEmpty() ) return FALSE; + } + + if ( ! wxFileExists(fullfilename) ) + { + Line = _("Doc File ") + fullfilename + _(" not found"); + DisplayError(frame, Line); + return FALSE; + } + + /* Try to launch some browser (usefull under linux) */ + EDA_Appl->ReadPdfBrowserInfos(); + if ( EDA_Appl->m_PdfBrowserIsDefault ) + { + wxFileType * filetype; + wxFileName CurrentFileName(fullfilename); + wxString ext, type; + ext = CurrentFileName.GetExt(); + filetype = wxTheMimeTypesManager->GetFileTypeFromExtension(ext); + + if ( ! filetype ) // 2ieme tentative + { + mimeDatabase = new wxMimeTypesManager; + mimeDatabase->AddFallbacks(EDAfallbacks); + filetype = mimeDatabase->GetFileTypeFromExtension(ext); + delete mimeDatabase; + mimeDatabase = NULL; + } + + if ( filetype ) + { + wxFileType::MessageParameters params(fullfilename, type); + success = filetype->GetOpenCommand( &command, params); + delete filetype; + if ( success ) wxExecute(command); + } + + if ( ! success) + { + #ifdef __LINUX__ + if ( ext == wxT("pdf") ) + { + success = TRUE; command.Empty(); + if ( wxFileExists( wxT("/usr/bin/xpdf")) ) + command = wxT("xpdf ") + fullfilename; + else if ( wxFileExists( wxT("/usr/bin/konqueror") )) + command = wxT("konqueror ") + fullfilename; + else if ( wxFileExists( wxT("/usr/bin/gpdf") )) + command = wxT("gpdf ") + fullfilename; + if ( command.IsEmpty() ) // not started + { + DisplayError(frame, + _(" Cannot find the PDF viewer (xpdf, gpdf or konqueror) in /usr/bin/") ); + success = FALSE; + } + else wxExecute(command); + } + else + #endif + { + Line.Printf( _("Unknown MIME type for Doc File [%s] (%s)"), + fullfilename.GetData(), ext.GetData()); + DisplayError(frame, Line); + } + } + } + + else + { + command = EDA_Appl->m_PdfBrowser; + if ( wxFileExists(command) ) + { + success = TRUE; + AddDelimiterString(fullfilename); + command += wxT(" ") + fullfilename; + wxExecute(command); + } + + else + { + Line.Printf( _("Cannot find Pdf viewer %s"), command.GetData()); + DisplayError(frame, Line); + } + } + + return success; +} + +/******************************************************************/ +int KeyWordOk(const wxString & KeyList, const wxString & Database ) +/******************************************************************/ +/* Recherche si dans le texte Database on retrouve tous les mots + cles donnes dans KeyList ( KeyList = suite de mots cles + separes par des espaces + Retourne: + 0 si aucun mot cle trouvé + 1 si mot cle trouvé +*/ +{ +wxString KeysCopy, DataList; + + if( KeyList.IsEmpty() ) return(0); + + KeysCopy = KeyList; KeysCopy.MakeUpper(); + DataList = Database; DataList.MakeUpper(); + +wxStringTokenizer Token(KeysCopy, wxT(" \n\r")); + while ( Token.HasMoreTokens() ) + { + wxString Key = Token.GetNextToken(); + // Search Key in Datalist: + wxStringTokenizer Data(DataList, wxT(" \n\r")); + while ( Data.HasMoreTokens() ) + { + wxString word = Data.GetNextToken(); + if ( word == Key ) return 1; // Key found ! + } + } + + // keyword not found + return(0); +} + + diff --git a/common/edaappl.cpp b/common/edaappl.cpp new file mode 100644 index 0000000000..4d4687e85c --- /dev/null +++ b/common/edaappl.cpp @@ -0,0 +1,592 @@ + /***************/ + /* edaappl.cpp */ + /***************/ +/* + ROLE: methodes relative a la classe winEDA_App, communes + aux environements window et linux +*/ +#define EDA_BASE +#define COMMON_GLOBL + +#include "fctsys.h" +#include +#include "wx/html/htmlwin.h" +#include "wx/fs_zip.h" + + +#include "wxstruct.h" +#include "macros.h" + +#include "gr_basic.h" +#include "common.h" +#include "worksheet.h" +#include "id.h" +#include "build_version.h" + +#include "bitmaps.h" +#include "Language.xpm" + +#ifdef __WINDOWS__ +/* Icons for language choice (only for Windows)*/ +#include "Lang_Default.xpm" +#include "Lang_En.xpm" +#include "Lang_Es.xpm" +#include "Lang_Fr.xpm" +#include "Lang_Pt.xpm" +#include "Lang_It.xpm" +#include "Lang_De.xpm" +#include "Lang_Sl.xpm" +#include "Lang_Hu.xpm" +#include "Lang_Po.xpm" +#include "Lang_Ko.xpm" +#include "Lang_Ru.xpm" +#endif + + +#define FONT_DEFAULT_SIZE 10 /* Default font size. + The real font size will be computed at run time */ + + + /*****************************/ + /* Constructeur de WinEDA_App */ + /*****************************/ + +WinEDA_App::WinEDA_App(void) +{ + m_Checker = NULL; + m_MainFrame = NULL; + m_PcbFrame = NULL; + m_ModuleEditFrame = NULL; // Edition des modules + SchematicFrame = NULL; // Edition des Schemas + LibeditFrame = NULL; // Edition des composants + ViewlibFrame = NULL; // Visualisation des composants + m_CvpcbFrame = NULL; + m_GerberFrame = NULL; // ecran de visualisation GERBER + + m_LastProjectMaxCount = 10; + m_HtmlCtrl = NULL; + m_EDA_CommonConfig = NULL; + m_EDA_Config = NULL; + m_Env_Defined = FALSE; + m_LanguageId = wxLANGUAGE_DEFAULT; + m_Language_Menu = NULL; + m_Locale = NULL; + + m_PdfBrowserIsDefault = TRUE; + + /* Init de variables globales d'interet general: */ + g_FloatSeparator = '.'; // Nombres flottants = 0.1 par exemple +} + + /*****************************/ + /* Destructeur de WinEDA_App */ + /*****************************/ + +WinEDA_App::~WinEDA_App(void) +{ + SaveSettings(); + + /* delete data non directement geree par wxAppl */ + delete g_Prj_Config; + delete m_EDA_Config; + delete m_EDA_CommonConfig; + delete g_StdFont; + delete g_DialogFont; + delete g_ItalicFont; + delete g_FixedFont; + delete g_MsgFont; + delete DrawPen; + delete DrawBrush; + if ( m_Checker ) delete m_Checker; + delete m_Locale; +} + + +/**************************************************/ +void WinEDA_App::InitEDA_Appl(const wxString & name) +/***************************************************/ +{ +wxString ident; +wxString EnvLang; + + ident = name + wxT("-") + wxGetUserId(); + m_Checker = new wxSingleInstanceChecker(ident); + + /* Init environnement + (KICAD definit le chemin de kicad ex: set KICAD=d:\kicad) */ + m_Env_Defined = wxGetEnv( wxT("KICAD"), &m_KicadEnv); + if ( m_Env_Defined ) // m_KicadEnv doit finir par "/" ou "\" + { + m_KicadEnv.Replace(WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP); + if ( m_KicadEnv.Last() != '/' ) m_KicadEnv += UNIX_STRING_DIR_SEP; + } + + /* Prepare On Line Help */ + m_HelpFileName = name + wxT(".html"); + + // Init parametres pour configuration + SetVendorName(wxT("kicad")); + SetAppName(name); + m_EDA_Config = new wxConfig(name); + m_EDA_CommonConfig = new wxConfig(wxT("kicad_common")); + + /* Creation des outils de trace */ + DrawPen = new wxPen( wxT("GREEN"), 1, wxSOLID); + DrawBrush = new wxBrush(wxT("BLACK"), wxTRANSPARENT); + + /* Creation des fontes utiles */ + g_StdFontPointSize = FONT_DEFAULT_SIZE; + g_MsgFontPointSize = FONT_DEFAULT_SIZE; + g_DialogFontPointSize = FONT_DEFAULT_SIZE; + g_FixedFontPointSize = FONT_DEFAULT_SIZE; + g_StdFont = new wxFont(g_StdFontPointSize, wxFONTFAMILY_ROMAN, wxNORMAL, wxNORMAL); + g_MsgFont = new wxFont(g_StdFontPointSize, wxFONTFAMILY_ROMAN, wxNORMAL, wxNORMAL); + g_DialogFont = new wxFont(g_DialogFontPointSize, wxFONTFAMILY_ROMAN, wxNORMAL, wxNORMAL); + g_ItalicFont = new wxFont(g_DialogFontPointSize, wxFONTFAMILY_ROMAN, wxFONTSTYLE_ITALIC, wxNORMAL); + g_FixedFont = new wxFont(g_FixedFontPointSize, wxFONTFAMILY_MODERN, wxNORMAL, wxNORMAL); + + /* installation des gestionnaires de visu d'images (pour help) */ + wxImage::AddHandler(new wxPNGHandler); + wxImage::AddHandler(new wxGIFHandler); + wxImage::AddHandler(new wxJPEGHandler); + wxFileSystem::AddHandler(new wxZipFSHandler); + + // Analyse command line & init binary path + SetBinDir(); + + ReadPdfBrowserInfos(); + // Internationalisation: chargement du Dictionnaire de kicad + m_EDA_CommonConfig->Read(wxT("Language"), &m_LanguageId, wxLANGUAGE_DEFAULT); + +bool succes = SetLanguage(TRUE); + if ( ! succes ) + { + } + + if ( atof("0,1") ) g_FloatSeparator = ','; // Nombres flottants = 0,1 + else g_FloatSeparator = '.'; + +} + + +/*****************************************/ +void WinEDA_App::InitOnLineHelp(void) +/*****************************************/ +/* Init On Line Help +*/ +{ +wxString fullfilename = FindKicadHelpPath(); + + fullfilename += wxT("kicad.hhp"); + if ( wxFileExists(fullfilename) ) + { + m_HtmlCtrl = new wxHtmlHelpController(wxHF_TOOLBAR | + wxHF_CONTENTS | wxHF_PRINT | wxHF_OPEN_FILES + /*| wxHF_SEARCH */); + m_HtmlCtrl->UseConfig(m_EDA_CommonConfig); + m_HtmlCtrl->SetTitleFormat( wxT("Kicad Help") ); + m_HtmlCtrl->AddBook(fullfilename); + } +} + + +/*******************************/ +bool WinEDA_App::SetBinDir(void) +/*******************************/ +/* + Analyse la ligne de commande pour retrouver le chemin de l'executable + Sauve en WinEDA_App::m_BinDir le repertoire de l'executable +*/ + +{ + /* Calcul du chemin ou se trouve l'executable */ + +#ifdef __UNIX__ + /* Sous LINUX ptarg[0] ne donne pas le chemin complet de l'executable, + il faut le retrouver par la commande "which si aucun + chemin n'est donne */ +FILE * ftmp; + +#define TMP_FILE "/tmp/kicad.tmp" +char Line[1024]; +char FileName[1024]; +wxString str_arg0; +int ii; + + FileName[0] = 0; + str_arg0 = argv[0]; + if( strchr( (const char *)argv[0],'/') == NULL ) /* pas de chemin */ + { + sprintf( FileName, "which %s > %s", CONV_TO_UTF8(str_arg0), TMP_FILE); + ii = system(FileName); + if( (ftmp = fopen(TMP_FILE, "rt")) != NULL ) + { + fgets(Line,1000,ftmp); + fclose(ftmp); + remove(TMP_FILE); + } + m_BinDir = CONV_FROM_UTF8(Line); + } + else m_BinDir = argv[0]; +#else + m_BinDir = argv[0]; +#endif + + m_BinDir.Replace(WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP); + while ( m_BinDir.Last() != '/' ) m_BinDir.RemoveLast(); + + return TRUE; +} + + +/*********************************/ +void WinEDA_App::GetSettings(void) +/*********************************/ +/* Lit les infos utiles sauvees lors de la derniere utilisation du logiciel +*/ +{ +wxString Line, Ident; +unsigned ii; + + m_HelpSize.x = 500; m_HelpSize.y = 400; + + if ( m_EDA_CommonConfig ) + { + m_LanguageId = m_EDA_CommonConfig->Read(wxT("Language"), wxLANGUAGE_DEFAULT); + g_EditorName = m_EDA_CommonConfig->Read(wxT("Editor")); + } + + if ( ! m_EDA_Config ) return; + + + for ( ii = 0; ii < 10; ii++ ) + { + Ident = wxT("LastProject"); if ( ii ) Ident << ii; + if( m_EDA_Config->Read(Ident, &Line) ) + m_LastProject.Add(Line); + } + + g_StdFontPointSize = m_EDA_Config->Read(wxT("SdtFontSize"), FONT_DEFAULT_SIZE); + g_MsgFontPointSize = m_EDA_Config->Read(wxT("MsgFontSize"), FONT_DEFAULT_SIZE); + g_DialogFontPointSize = m_EDA_Config->Read(wxT("DialogFontSize"), FONT_DEFAULT_SIZE); + g_FixedFontPointSize = m_EDA_Config->Read(wxT("FixedFontSize"), FONT_DEFAULT_SIZE); + + Line = m_EDA_Config->Read(wxT("SdtFontType"), wxEmptyString); + if ( ! Line.IsEmpty() ) g_StdFont->SetFaceName(Line); + ii = m_EDA_Config->Read(wxT("SdtFontStyle"), wxFONTFAMILY_ROMAN); + g_StdFont->SetStyle(ii); + ii = m_EDA_Config->Read(wxT("SdtFontWeight"), wxNORMAL); + g_StdFont->SetWeight(ii); + g_StdFont->SetPointSize(g_StdFontPointSize); + + + Line = m_EDA_Config->Read(wxT("MsgFontType"), wxEmptyString); + if ( ! Line.IsEmpty() ) g_MsgFont->SetFaceName(Line); + ii = m_EDA_Config->Read(wxT("MsgFontStyle"), wxFONTFAMILY_ROMAN); + g_MsgFont->SetStyle(ii); + ii = m_EDA_Config->Read(wxT("MsgFontWeight"), wxNORMAL); + g_MsgFont->SetWeight(ii); + g_MsgFont->SetPointSize(g_MsgFontPointSize); + + Line = m_EDA_Config->Read(wxT("DialogFontType"), wxEmptyString); + if ( ! Line.IsEmpty() ) g_DialogFont->SetFaceName(Line); + ii = m_EDA_Config->Read(wxT("DialogFontStyle"), wxFONTFAMILY_ROMAN); + g_DialogFont->SetStyle(ii); + ii = m_EDA_Config->Read(wxT("DialogFontWeight"), wxNORMAL); + g_DialogFont->SetWeight(ii); + g_DialogFont->SetPointSize(g_DialogFontPointSize); + + g_FixedFont->SetPointSize(g_FixedFontPointSize); + + m_EDA_Config->Read(wxT("ShowPageLimits"), & g_ShowPageLimits); + + if( m_EDA_Config->Read(wxT("WorkingDir"), &Line) ) + { + if ( wxDirExists(Line) ) wxSetWorkingDirectory(Line); + } + m_EDA_Config->Read( wxT("BgColor"), &g_DrawBgColor); +} + + +/**********************************/ +void WinEDA_App::SaveSettings(void) +/**********************************/ +{ +unsigned int ii; + + + if( m_EDA_Config == NULL ) return; + + m_EDA_Config->Write(wxT("SdtFontSize"), g_StdFontPointSize); + m_EDA_Config->Write(wxT("SdtFontType"), g_StdFont->GetFaceName()); + m_EDA_Config->Write(wxT("SdtFontStyle"), g_StdFont->GetStyle()); + m_EDA_Config->Write(wxT("SdtFontWeight"), g_StdFont->GetWeight()); + + m_EDA_Config->Write(wxT("MsgFontSize"), g_MsgFontPointSize); + m_EDA_Config->Write(wxT("MsgFontType"), g_MsgFont->GetFaceName()); + m_EDA_Config->Write(wxT("MsgFontStyle"), g_MsgFont->GetStyle()); + m_EDA_Config->Write(wxT("MsgFontWeight"), g_MsgFont->GetWeight()); + + m_EDA_Config->Write(wxT("DialogFontSize"), g_DialogFontPointSize); + m_EDA_Config->Write(wxT("DialogFontType"), g_DialogFont->GetFaceName()); + m_EDA_Config->Write(wxT("DialogFontStyle"), g_DialogFont->GetStyle()); + m_EDA_Config->Write(wxT("DialogFontWeight"), g_DialogFont->GetWeight()); + + m_EDA_Config->Write(wxT("FixedFontSize"), g_FixedFontPointSize); + + m_EDA_Config->Write(wxT("ShowPageLimits"), g_ShowPageLimits); + + m_EDA_Config->Write(wxT("WorkingDir"), wxGetCwd()); + + for( ii = 0; ii < 10; ii++ ) + { + wxString msg = wxT("LastProject"); + if ( ii ) msg << ii; + + if ( ii < m_LastProject.GetCount() ) + m_EDA_Config->Write(msg, m_LastProject[ii]); + else + m_EDA_Config->Write(msg, wxEmptyString); + } +} + +/*********************************************/ +bool WinEDA_App::SetLanguage(bool first_time) +/*********************************************/ +/* Set the dictionary file name for internationalization + the files are in kicad/internat/xx or kicad/internat/xx_XX + and are named kicad.mo +*/ +{ +wxString DictionaryName( wxT("kicad")); // dictionary file name without extend (full name is kicad.mo) +wxString BaseDictionaryPath( wxT("internat")); // Real path is kicad/internat/xx_XX or kicad/internat/xx +wxString dic_path; + + if ( m_Locale != NULL ) delete m_Locale; + m_Locale = new wxLocale(); + m_Locale->Init(m_LanguageId); + dic_path = ReturnKicadDatasPath() + BaseDictionaryPath; + m_Locale->AddCatalogLookupPathPrefix(dic_path); + + if ( ! first_time ) + { + if ( m_EDA_CommonConfig ) + m_EDA_CommonConfig->Write( wxT("Language"), m_LanguageId); + } + + if ( ! m_Locale->IsLoaded(DictionaryName) ) + m_Locale->AddCatalog(DictionaryName); + SetLanguageList(NULL); + + + if ( atof("0,1") ) g_FloatSeparator = ','; // Nombres flottants = 0,1 + else g_FloatSeparator = '.'; + + return m_Locale->IsOk(); +} + + +/**************************************************/ +void WinEDA_App::SetLanguageIdentifier(int menu_id) +/**************************************************/ +/* return in m_LanguageId the language id (wxWidgets language identifier) + from menu id (internal menu identifier) +*/ +{ + switch (menu_id) + { + case ID_LANGUAGE_ITALIAN: + m_LanguageId = wxLANGUAGE_ITALIAN; + break; + + case ID_LANGUAGE_PORTUGUESE: + m_LanguageId = wxLANGUAGE_PORTUGUESE; + break; + + case ID_LANGUAGE_RUSSIAN: + m_LanguageId = wxLANGUAGE_RUSSIAN; + break; + + case ID_LANGUAGE_GERMAN: + m_LanguageId = wxLANGUAGE_GERMAN; + break; + + case ID_LANGUAGE_SPANISH: + m_LanguageId = wxLANGUAGE_SPANISH; + break; + + case ID_LANGUAGE_ENGLISH: + m_LanguageId = wxLANGUAGE_ENGLISH; + break; + + case ID_LANGUAGE_FRENCH: + m_LanguageId = wxLANGUAGE_FRENCH; + break; + + case ID_LANGUAGE_SLOVENIAN: + m_LanguageId = wxLANGUAGE_SLOVENIAN; + break; + + case ID_LANGUAGE_HUNGARIAN: + m_LanguageId = wxLANGUAGE_HUNGARIAN ; + break; + + case ID_LANGUAGE_POLISH: + m_LanguageId = wxLANGUAGE_POLISH ; + break; + + case ID_LANGUAGE_KOREAN: + m_LanguageId = wxLANGUAGE_KOREAN; + break; + + default: + m_LanguageId = wxLANGUAGE_DEFAULT; + break; + + } +} + + + +/*********************************************************/ +wxMenu * WinEDA_App::SetLanguageList(wxMenu * MasterMenu) +/*********************************************************/ +/* Create menu list for language choice. +*/ +{ +wxMenuItem * item; + + if ( m_Language_Menu == NULL ) + { + m_Language_Menu = new wxMenu; + item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_DEFAULT, + _("Default"), wxEmptyString, wxITEM_CHECK ); + SETBITMAPS(lang_def_xpm); + m_Language_Menu->Append(item); + + item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_ENGLISH, + wxT("English"), wxEmptyString, wxITEM_CHECK); + SETBITMAPS(lang_en_xpm); + m_Language_Menu->Append(item); + + item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_FRENCH, + _("French"), wxEmptyString, wxITEM_CHECK); + SETBITMAPS(lang_fr_xpm); + m_Language_Menu->Append(item); + + item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_SPANISH, + _("Spanish"), wxEmptyString, wxITEM_CHECK); + SETBITMAPS(lang_es_xpm); + m_Language_Menu->Append(item); + + item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_PORTUGUESE, + _("Portuguese"), wxEmptyString, wxITEM_CHECK); + SETBITMAPS(lang_pt_xpm); + m_Language_Menu->Append(item); + + + item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_ITALIAN, + _("Italian"), wxEmptyString, wxITEM_CHECK); + SETBITMAPS(lang_it_xpm); + m_Language_Menu->Append(item); + + item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_GERMAN, + _("German"), wxEmptyString, wxITEM_CHECK); + SETBITMAPS(lang_de_xpm); + m_Language_Menu->Append(item); + + item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_SLOVENIAN, + _("Slovenian"), wxEmptyString, wxITEM_CHECK); + SETBITMAPS(lang_sl_xpm); + m_Language_Menu->Append(item); + + item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_HUNGARIAN, + _("Hungarian"), wxEmptyString, wxITEM_CHECK); + SETBITMAPS(lang_hu_xpm); + m_Language_Menu->Append(item); + + item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_POLISH, + _("Polish"), wxEmptyString, wxITEM_CHECK); + SETBITMAPS(lang_po_xpm); + m_Language_Menu->Append(item); + + item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_RUSSIAN, + _("Russian"), wxEmptyString, wxITEM_CHECK); + SETBITMAPS(lang_ru_xpm); + m_Language_Menu->Append(item); + + item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_KOREAN, + _("Korean"), wxEmptyString, wxITEM_CHECK); + SETBITMAPS(lang_ko_xpm); + m_Language_Menu->Append(item); + } + + m_Language_Menu->Check(ID_LANGUAGE_KOREAN, FALSE); + m_Language_Menu->Check(ID_LANGUAGE_RUSSIAN, FALSE); + m_Language_Menu->Check(ID_LANGUAGE_POLISH, FALSE); + m_Language_Menu->Check(ID_LANGUAGE_HUNGARIAN, FALSE); + m_Language_Menu->Check(ID_LANGUAGE_SLOVENIAN, FALSE); + m_Language_Menu->Check(ID_LANGUAGE_ITALIAN, FALSE); + m_Language_Menu->Check(ID_LANGUAGE_PORTUGUESE, FALSE); + m_Language_Menu->Check(ID_LANGUAGE_GERMAN, FALSE); + m_Language_Menu->Check(ID_LANGUAGE_SPANISH, FALSE); + m_Language_Menu->Check(ID_LANGUAGE_FRENCH, FALSE); + m_Language_Menu->Check(ID_LANGUAGE_ENGLISH, FALSE); + m_Language_Menu->Check(ID_LANGUAGE_DEFAULT, FALSE); + + switch ( m_LanguageId ) + { + case wxLANGUAGE_KOREAN: + m_Language_Menu->Check(ID_LANGUAGE_KOREAN, TRUE); + break; + case wxLANGUAGE_RUSSIAN: + m_Language_Menu->Check(ID_LANGUAGE_RUSSIAN, TRUE); + break; + case wxLANGUAGE_GERMAN: + m_Language_Menu->Check(ID_LANGUAGE_GERMAN, TRUE); + break; + case wxLANGUAGE_FRENCH: + m_Language_Menu->Check(ID_LANGUAGE_FRENCH, TRUE); + break; + case wxLANGUAGE_ENGLISH: + m_Language_Menu->Check(ID_LANGUAGE_ENGLISH, TRUE); + break; + case wxLANGUAGE_SPANISH: + m_Language_Menu->Check(ID_LANGUAGE_SPANISH, TRUE); + break; + case wxLANGUAGE_PORTUGUESE: + m_Language_Menu->Check(ID_LANGUAGE_PORTUGUESE, TRUE); + break; + + case wxLANGUAGE_ITALIAN: + m_Language_Menu->Check(ID_LANGUAGE_ITALIAN, TRUE); + break; + + case wxLANGUAGE_SLOVENIAN: + m_Language_Menu->Check(ID_LANGUAGE_SLOVENIAN, TRUE); + break; + + case wxLANGUAGE_HUNGARIAN: + m_Language_Menu->Check(ID_LANGUAGE_HUNGARIAN, TRUE); + break; + + case wxLANGUAGE_POLISH: + m_Language_Menu->Check(ID_LANGUAGE_POLISH, TRUE); + break; + + default: + m_Language_Menu->Check(ID_LANGUAGE_DEFAULT, TRUE); + break; + } + + if ( MasterMenu ) + { + ADD_MENUITEM_WITH_HELP_AND_SUBMENU(MasterMenu, m_Language_Menu, + ID_LANGUAGE_CHOICE, _("Language"), + wxT("For test only, use Default setup for normal use"), + language_xpm); + } + return m_Language_Menu; +} + + diff --git a/common/edamenu.cpp b/common/edamenu.cpp new file mode 100644 index 0000000000..c988137fe4 --- /dev/null +++ b/common/edamenu.cpp @@ -0,0 +1,106 @@ +/************************************************************************/ +/* MODULE edamenu.cpp */ +/************************************************************************/ + +/****************************/ +/* INCLUDES SYSTEMES */ +/****************************/ + +#include "fctsys.h" + +#include "wxstruct.h" +#include "gr_basic.h" +#include "macros.h" +#include "common.h" + +#include "worksheet.h" + +/* Pour imprimer / lire en unites utilisateur ( INCHES / MM ) */ + +/* Retourne la valeur en inch ou mm de la valeur val en unités internes +*/ +double To_User_Unit(bool is_metric, int val,int internal_unit_value) +{ +double value; + + if (is_metric) + value = (double) (val) * 25.4 / internal_unit_value; + else value = (double) (val) / internal_unit_value; + + return value; +} + +/* Retourne la valeur en unités internes de la valeur val exprimée en inch ou mm +*/ +int From_User_Unit(bool is_metric, double val,int internal_unit_value) +{ +double value; + + if (is_metric) value = val * internal_unit_value / 25.4 ; + else value = val * internal_unit_value; + + return (int) round(value); +} + +/**********************/ +wxString GenDate(void) +/**********************/ +/* Retourne la chaine de caractere donnant la date */ +{ +static char * mois[12] = + { + "jan", "feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec" + }; +time_t buftime; +struct tm * Date; +wxString string_date; +char Line[1024]; + + time(&buftime); + Date = gmtime(&buftime); + sprintf(Line,"%d %s %d", Date->tm_mday, + mois[Date->tm_mon], + Date->tm_year + 1900); + string_date = Line; + return(string_date); +} + +/***********************************/ +void * MyMalloc (size_t nb_octets) +/***********************************/ +/* Routine d'allocation memoire */ +{ +void * pt_mem; +char txt[60]; + + if (nb_octets == 0) + { + DisplayError(NULL, "Allocate 0 bytes !!"); + return(NULL); + } + pt_mem = malloc(nb_octets); + if (pt_mem == NULL) + { + sprintf(txt,"Out of memory: allocation %d bytes", nb_octets); + DisplayError(NULL, txt); + } + return(pt_mem); +} + +/************************************/ +void * MyZMalloc (size_t nb_octets) +/************************************/ +/* Routine d'allocation memoire, avec remise a zero de la zone allouee */ +{ + void * pt_mem = MyMalloc (nb_octets); + if ( pt_mem) memset(pt_mem, 0, nb_octets); + return(pt_mem); +} + +/*******************************/ +void MyFree (void * pt_mem) +/*******************************/ +{ + if( pt_mem ) free(pt_mem); +} + diff --git a/common/gestfich.cpp b/common/gestfich.cpp new file mode 100644 index 0000000000..484e1b3e6e --- /dev/null +++ b/common/gestfich.cpp @@ -0,0 +1,571 @@ +/************************************************/ +/* MODULE: gestfich.cpp */ +/* ROLE: fonctions de gestion de fichiers */ +/************************************************/ + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWindows headers +#ifndef WX_PRECOMP +#include +#endif + +#include +#include +#include + +#ifdef __WINDOWS__ +#ifndef _MSC_VER +#include +#endif +#endif + +#include "fctsys.h" +#include "common.h" +#include "wxstruct.h" + + +// Path list for online help +static wxString s_HelpPathList[] = { +#ifdef __WINDOWS__ + wxT("c:/kicad/help/"), + wxT("d:/kicad/help/"), +#else + wxT("/usr/local/kicad/help/"), + wxT("/usr/share/doc/kicad/"), +#endif + wxT("end_list") // End of list symbol, do not change +}; + +// Path list for kicad data files +static wxString s_KicadDataPathList[] = { +#ifdef __WINDOWS__ + wxT("c:/kicad/"), + wxT("d:/kicad/"), +#else + wxT("/usr/local/kicad/"), + wxT("/usr/share/kicad/"), +#endif + wxT("end_list") // End of list symbol, do not change +}; + +// Path list for kicad binary files +static wxString s_KicadBinaryPathList[] = { +#ifdef __WINDOWS__ + wxT("c:/kicad/winexe/"), + wxT("d:/kicad/winexe/"), +#else + wxT("/usr/local/kicad/linux/"), + wxT("/usr/local/bin/"), + wxT("/usr/bin/"), +#endif + wxT("end_list") // End of list symbol, do not change +}; +extern WinEDA_App * EDA_Appl; + + +/***************************************************************************/ +wxString MakeReducedFileName( const wxString & fullfilename, + const wxString & default_path, + const wxString & default_ext) +/***************************************************************************/ + +/* Calcule le nom "reduit" d'un fichier d'apres les chaines + fullfilename = nom complet + default_path = prefixe (chemin) par defaut + default_ext = extension par defaut + + retourne le nom reduit, c'est a dire: + sans le chemin si le chemin est default_path + avec ./ si si le chemin est le chemin courant + sans l'extension si l'extension est default_ext + + Renvoie un chemin en notation unix ('/' en separateur de repertoire) +*/ +{ +wxString reduced_filename = fullfilename; +wxString Cwd, ext, path; + + Cwd = default_path; + ext = default_ext; + path = wxPathOnly(reduced_filename) + UNIX_STRING_DIR_SEP; + reduced_filename.Replace(WIN_STRING_DIR_SEP,UNIX_STRING_DIR_SEP); + Cwd.Replace(WIN_STRING_DIR_SEP,UNIX_STRING_DIR_SEP); + if ( Cwd.Last() != '/' ) Cwd += UNIX_STRING_DIR_SEP; + path.Replace(WIN_STRING_DIR_SEP,UNIX_STRING_DIR_SEP); + +#ifdef __WINDOWS__ + path.MakeLower(); + Cwd.MakeLower(); + ext.MakeLower(); +#endif + + // Si le fichier est dans chemin par defaut -> suppression du chemin par defaut + wxString root_path = path.Left(Cwd.Length()); + if ( root_path == Cwd ) + { + reduced_filename.Remove(0, Cwd.Length()); + } + else // Si fichier dans repertoire courant -> chemin = ./ + { + Cwd = wxGetCwd() + UNIX_STRING_DIR_SEP; +#ifdef __WINDOWS__ + Cwd.MakeLower(); +#endif + Cwd.Replace(WIN_STRING_DIR_SEP,UNIX_STRING_DIR_SEP); + if ( path == Cwd ) + { // lib est dans répertoire courant -> Chemin = "./" + reduced_filename.Remove(0, Cwd.Length()); + wxString tmp = wxT("./") + reduced_filename; + reduced_filename = tmp; + } + } + + // Suppression extension standard: + if ( !ext.IsEmpty() && reduced_filename.Contains(ext) ) + reduced_filename.Truncate(reduced_filename.Length() - ext.Length()); + + return(reduced_filename); +} + + + + +/***************************************************************************/ +wxString MakeFileName( const wxString & dir, + const wxString & shortname, const wxString & ext) +/***************************************************************************/ + +/* Calcule le nom complet d'un fichier d'apres les chaines + dir = prefixe (chemin) (peut etre "") + shortname = nom avec ou sans chemin ou extension + ext = extension (peut etre "") + + si shortname possede deja un chemin ou une extension, elles + ne seront pas modifiees + + retourne la chaine calculee +*/ +{ +wxString fullfilename; +int ii; + + if ( ! dir.IsEmpty() ) + { + if( ! shortname.Contains( UNIX_STRING_DIR_SEP ) && ! shortname.Contains( WIN_STRING_DIR_SEP) + && ! shortname.Contains( wxT(":") ) ) + { /* aucun chemin n'est donne */ + fullfilename = dir; + } + } + + fullfilename += shortname; + fullfilename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); + + /* Placement de l'extension s'il n'y en a pas deja une */ + if( ext.IsEmpty() ) return(fullfilename); + + /* Recherche d'une eventuelle extension */ + ii = fullfilename.Length(); /* Pointe la fin du texte */ + for ( ; ii >= 0 ; ii-- ) + { + if ( fullfilename.GetChar(ii) == '/' ) + { + /* Pas d'extension: placement de l'extension standard */ + fullfilename += ext; + break; + } + if ( fullfilename.GetChar(ii) == '.' ) /* extension trouvee */ + break; + } + + return(fullfilename); +} + + +/*************************************************************************/ +void ChangeFileNameExt( wxString & FullFileName, const wxString & NewExt ) +/**************************************************************************/ +/* Change l'extension du "filename FullFileName" en NewExt. +*/ +{ +wxString FileName; + + FileName = FullFileName.BeforeLast('.'); + if ( !FileName.IsEmpty() ) FileName += NewExt; + else FileName = FullFileName + NewExt; + + if ( FileName.StartsWith( wxT("\"")) && ( FileName.Last() != '"' ) ) + FileName += wxT("\""); + FullFileName = FileName; +} + +/*******************************************/ +void AddDelimiterString( wxString & string ) +/*******************************************/ +/* ajoute un " en debut et fin de string s'il n'y en a pas deja. +*/ +{ +wxString text; + + if ( ! string.StartsWith( wxT("\"")) ) text = wxT("\""); + text += string; + if( (text.Last() != '"' ) || (text.length() <= 1) ) text += wxT("\""); + string = text; +} + + + + /*************************************/ + /* Fonction de selection de Repertoires */ + /*************************************/ + +bool EDA_DirectorySelector(const wxString & Title, /* Titre de la fenetre */ + wxString & Path, /* Chemin par defaut */ + int flag, /* reserve */ + wxWindow * Frame, /* parent frame */ + const wxPoint & Pos) +{ +int ii; +bool selected = FALSE; + + wxDirDialog * DirFrame = new wxDirDialog( + Frame, + wxString(Title), + Path, /* Chemin par defaut */ + flag, + Pos ); + + ii = DirFrame->ShowModal(); + if ( ii == wxID_OK ) + { + Path = DirFrame->GetPath(); + selected = TRUE; + } + + DirFrame->Destroy(); + return selected; +} + + /******************************/ + /* Selection file dialog box: */ + /******************************/ + +wxString EDA_FileSelector(const wxString & Title, /* Dialog title */ + const wxString & Path, /* Default path */ + const wxString &FileName, /* default filename */ + const wxString & Ext, /* default filename extension */ + const wxString & Mask, /* filter for filename list */ + wxWindow * Frame, /* parent frame */ + int flag, /* wxFD_SAVE, wxFD_OPEN ..*/ + const bool keep_working_directory, /* true = keep the current path */ + const wxPoint & Pos) +{ +wxString fullfilename; +wxString curr_cwd = wxGetCwd(); +wxString defaultname = FileName; +wxString defaultpath = Path; + + defaultname.Replace(wxT("/"), STRING_DIR_SEP); + defaultpath.Replace(wxT("/"), STRING_DIR_SEP); + if ( defaultpath.IsEmpty() ) defaultpath = wxGetCwd(); + + fullfilename = wxFileSelector( wxString(Title), + defaultpath, + defaultname, + Ext, + Mask, + flag, /* options d'affichage (wxFD_OPEN, wxFD_SAVE .. */ + Frame, + Pos.x, Pos.y ); + + if ( keep_working_directory ) wxSetWorkingDirectory(curr_cwd); + + return fullfilename; +} + +/********************************************************/ +wxString FindKicadHelpPath(void) +/********************************************************/ +/* Find absolute path for kicad/help (or kicad/help/) */ +/* Find path kicad/help/xx/ ou kicad/help/: + from BinDir + else from environment variable KICAD + else from one of s_HelpPathList + typically c:\kicad\help or /usr/local/kicad/help or /usr/share/doc/kicad + (must have kicad in path name) + + xx = iso639-1 language id (2 letters (generic) or 4 letters): + fr = french (or fr_FR) + en = English (or en_GB or en_US ...) + de = deutch + es = spanish + pt = portuguese (or pt_BR ...) + + default = en (if not found = fr) + +*/ +{ +wxString FullPath, LangFullPath, tmp; +wxString LocaleString; +bool PathFound = FALSE; + + /* find kicad/help/ */ + tmp = EDA_Appl->m_BinDir; + if ( tmp.Last() == '/' ) tmp.RemoveLast(); + FullPath = tmp.BeforeLast('/'); // Idem cd .. + FullPath += wxT("/help/"); + LocaleString = EDA_Appl->m_Locale->GetCanonicalName(); + + if ( FullPath.Contains( wxT("kicad")) ) + { + if ( wxDirExists(FullPath) ) PathFound = TRUE; + } + + /* find kicad/help/ from environment variable KICAD */ + if ( ! PathFound && EDA_Appl->m_Env_Defined ) + { + FullPath = EDA_Appl->m_KicadEnv + wxT("/help/"); + if ( wxDirExists(FullPath) ) PathFound = TRUE; + } + + /* find kicad/help/ from default path list: + /usr/local/kicad/help or c:/kicad/help + (see s_HelpPathList) */ + int ii = 0; + while ( ! PathFound ) + { + FullPath = s_HelpPathList[ii++]; + if ( FullPath == wxT("end_list") ) break; + if ( wxDirExists(FullPath) ) PathFound = TRUE; + } + + + if ( PathFound ) + { + LangFullPath = FullPath + LocaleString + UNIX_STRING_DIR_SEP; + + if ( wxDirExists(LangFullPath) ) return LangFullPath; + + LangFullPath = FullPath + LocaleString.Left(2) + UNIX_STRING_DIR_SEP; + if ( wxDirExists(LangFullPath) ) return LangFullPath; + + LangFullPath = FullPath + wxT("en/"); + if ( wxDirExists(LangFullPath) ) return LangFullPath; + else + { + LangFullPath = FullPath + wxT("fr/"); + if ( wxDirExists(LangFullPath) ) return LangFullPath; + } + return FullPath; + } + return wxEmptyString; +} + +/********************************************************/ +wxString FindKicadFile(const wxString & shortname) +/********************************************************/ +/* Search the executable file shortname in kicad binary path + and return full file name if found or shortname + kicad binary path is + kicad/winexe or kicad/linux + + kicad binary path is found from: + BinDir + or environment variable KICAD + or (default) c:\kicad ou /usr/local/kicad + or default binary path +*/ +{ +wxString FullFileName; + + /* test de la presence du fichier shortname dans le repertoire de + des binaires de kicad */ + FullFileName = EDA_Appl->m_BinDir + shortname; + if ( wxFileExists(FullFileName) ) return FullFileName; + + /* test de la presence du fichier shortname dans le repertoire + defini par la variable d'environnement KICAD */ + if ( EDA_Appl->m_Env_Defined ) + { + FullFileName = EDA_Appl->m_KicadEnv + shortname; + if ( wxFileExists(FullFileName) ) return FullFileName; + } + + /* find binary file from default path list: + /usr/local/kicad/linux or c:/kicad/winexe + (see s_KicadDataPathList) */ + int ii = 0; + while ( 1 ) + { + if ( s_KicadBinaryPathList[ii] == wxT("end_list") ) break; + FullFileName = s_KicadBinaryPathList[ii++] + shortname; + if ( wxFileExists(FullFileName) ) return FullFileName; + } + + return shortname; +} + +/***********************************************************************************/ +int ExecuteFile(wxWindow * frame, const wxString & ExecFile, const wxString & param) +/***********************************************************************************/ +/* appelle le logiciel ExecFile, avec les parametres filename +*/ +{ +wxString FullFileName; + + FullFileName = FindKicadFile(ExecFile); + + if ( wxFileExists(FullFileName) ) + { + if( !param.IsEmpty() ) FullFileName += wxT(" ") + param; + wxExecute(FullFileName); + return 0; + } + + + wxString msg; + msg.Printf( wxT("Command file <%s> not found"), FullFileName.GetData() ); + DisplayError(frame, msg, 20); + return -1; +} + + +/****************************************************/ +void SetRealLibraryPath(const wxString & shortlibname) +/****************************************************/ +/* met a jour le chemin des librairies g_RealLibDirBuffer (global) +a partir de UserLibDirBuffer (global): + Si UserLibDirBuffer non vide g_RealLibDirBuffer = g_UserLibDirBuffer. + Sinon si variable d'environnement KICAD definie (KICAD = chemin pour kicad), + g_UserLibDirBuffer = /shortlibname; + Sinon g_UserLibDirBuffer = ../shortlibname/ + Sinon g_UserLibDirBuffer = /usr/share/kicad/shortlibname/ + +Remarque: + Les \ sont remplacés par / (a la mode Unix) +*/ +{ +bool PathFound = FALSE; + + if ( ! g_UserLibDirBuffer.IsEmpty() ) // Chemin impose par la configuration + { + g_RealLibDirBuffer = g_UserLibDirBuffer; + PathFound = TRUE; + } + + else + { + g_RealLibDirBuffer = ReturnKicadDatasPath(); + if ( EDA_Appl->m_Env_Defined ) // Chemin impose par la variable d'environnement + { + PathFound = TRUE; + } + g_RealLibDirBuffer += shortlibname; + if ( wxDirExists(g_RealLibDirBuffer) ) PathFound = TRUE; + } + + + g_RealLibDirBuffer.Replace(WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP); + if ( g_RealLibDirBuffer.Last() != '/' ) g_RealLibDirBuffer += UNIX_STRING_DIR_SEP; +} + +/***********************************/ +wxString ReturnKicadDatasPath(void) +/***********************************/ +/* Retourne le chemin des donnees communes de kicad. + Si variable d'environnement KICAD definie (KICAD = chemin pour kicad), + retourne /; + Sinon retourne / (si "kicad" est dans le nom du chemin) + Sinon retourne /usr/share/kicad/ + +Remarque: + Les \ sont remplacés par / (a la mode Unix) +*/ +{ +bool PathFound = FALSE; +wxString data_path; + + if ( EDA_Appl->m_Env_Defined ) // Chemin impose par la variable d'environnement + { + data_path = EDA_Appl->m_KicadEnv; + PathFound = TRUE; + } + else // Chemin cherche par le chemin des executables + { // le chemin est bindir../ + wxString tmp = EDA_Appl->m_BinDir; + if ( tmp.Contains( wxT("kicad") ) ) + { + if ( tmp.Last() == '/' ) tmp.RemoveLast(); + data_path = tmp.BeforeLast('/'); // id cd ../ + data_path += UNIX_STRING_DIR_SEP; + if ( wxDirExists(data_path) ) PathFound = TRUE; + } + } + + /* find kicad from default path list: + /usr/local/kicad/ or c:/kicad/ + (see s_KicadDataPathList) */ + int ii = 0; + while ( ! PathFound ) + { + if ( s_KicadDataPathList[ii] == wxT("end_list") ) break; + data_path = s_KicadDataPathList[ii++]; + if ( wxDirExists(data_path) ) PathFound = TRUE; + } + + if ( PathFound ) + { + data_path.Replace(WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP); + if ( data_path.Last() != '/' ) data_path += UNIX_STRING_DIR_SEP; + } + + else data_path.Empty(); + + return data_path; +} + + +/***************************/ +wxString GetEditorName(void) +/***************************/ +/* Return the prefered editor name +*/ +{ + wxString editorname = g_EditorName; + + if ( editorname.IsEmpty() ) // We get the prefered editor name from environment variable + { + wxGetEnv(wxT("EDITOR"), &editorname); + } + if ( editorname.IsEmpty() ) // We must get a prefered editor name + { + DisplayInfo(NULL, _("No default editor found, you must choose it") ); + wxString mask(wxT("*")); +#ifdef __WINDOWS__ + mask += wxT(".exe"); +#endif + editorname = EDA_FileSelector(_("Prefered Editor:"), + wxEmptyString, /* Default path */ + wxEmptyString, /* default filename */ + wxEmptyString, /* default filename extension */ + mask, /* filter for filename list */ + NULL, /* parent frame */ + wxFD_OPEN, /* wxFD_SAVE, wxFD_OPEN ..*/ + TRUE /* true = keep the current path */ + ); + } + + if ( (!editorname.IsEmpty()) && EDA_Appl->m_EDA_CommonConfig) + { + g_EditorName = editorname; + EDA_Appl->m_EDA_CommonConfig->Write( wxT("Editor"), g_EditorName); + } + return g_EditorName; +} diff --git a/common/get_component_dialog.cpp b/common/get_component_dialog.cpp new file mode 100644 index 0000000000..26bf48b821 --- /dev/null +++ b/common/get_component_dialog.cpp @@ -0,0 +1,252 @@ +/*********************************/ +/* get_component_dialog.cpp */ +/*********************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "macros.h" + +/****************************************************************************/ +/* Show a dialog frame to choose a name from an history list, or a new name */ +/* to select a component or a module */ +/****************************************************************************/ + +static unsigned s_HistoryMaxCount = 8; // Max number of items displayed in history list +static wxString s_ItemName; + + +enum selcmp_id { + ID_ACCEPT_NAME = 3900, + ID_ACCEPT_KEYWORD, + ID_ENTER_NAME, + ID_CANCEL, + ID_LIST_ALL, + ID_EXTRA_TOOL, + ID_SEL_BY_LISTBOX +}; + +/***************************************/ +class WinEDA_SelectCmp: public wxDialog +/***************************************/ +{ +private: + WinEDA_DrawFrame * m_Parent; + bool m_AuxTool; + wxString * m_Text; + wxTextCtrl * m_TextCtrl; + wxListBox * m_List; +public: + bool m_GetExtraFunction; + +public: + + // Constructor and destructor + WinEDA_SelectCmp(WinEDA_DrawFrame *parent, const wxPoint& framepos, + wxArrayString & HistoryList, const wxString & Title, + bool show_extra_tool ); + ~WinEDA_SelectCmp(void) {}; + +private: + void Accept(wxCommandEvent& event); + void GetExtraSelection(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() + +}; +BEGIN_EVENT_TABLE(WinEDA_SelectCmp, wxDialog) + EVT_BUTTON(ID_ACCEPT_NAME, WinEDA_SelectCmp::Accept) + EVT_BUTTON(ID_ACCEPT_KEYWORD, WinEDA_SelectCmp::Accept) + EVT_BUTTON(ID_CANCEL, WinEDA_SelectCmp::Accept) + EVT_BUTTON(ID_LIST_ALL, WinEDA_SelectCmp::Accept) + EVT_BUTTON(ID_EXTRA_TOOL, WinEDA_SelectCmp::GetExtraSelection) + EVT_LISTBOX(ID_SEL_BY_LISTBOX, WinEDA_SelectCmp::Accept) +END_EVENT_TABLE() + + +/****************************************************************************/ +WinEDA_SelectCmp::WinEDA_SelectCmp(WinEDA_DrawFrame *parent, const wxPoint& framepos, + wxArrayString & HistoryList, const wxString & Title, + bool show_extra_tool ): + wxDialog(parent, -1, Title, framepos, + wxDefaultSize, DIALOG_STYLE) +/****************************************************************************/ +/* Dialog frame to choose a component or a footprint + This dialog shows an history of last selected items +*/ +{ +wxButton * Button; +wxStaticText * Text; + + m_Parent = parent; + m_AuxTool = show_extra_tool; + m_GetExtraFunction = FALSE; + + SetFont(*g_DialogFont); + s_ItemName.Empty(); + m_Text = & s_ItemName; + + wxBoxSizer* MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(MainBoxSizer); + + wxBoxSizer* LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(LeftBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxADJUST_MINSIZE, 5); + wxBoxSizer* RightBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + Text = new wxStaticText(this, -1, _("Name:")); + LeftBoxSizer->Add(Text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); + + m_TextCtrl = new wxTextCtrl(this, ID_ENTER_NAME, *m_Text); + m_TextCtrl->SetInsertionPoint(1); + LeftBoxSizer->Add(m_TextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM|wxADJUST_MINSIZE, 5); + + Text = new wxStaticText(this, -1, _("History list:")); + LeftBoxSizer->Add(Text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); + + m_List = new wxListBox(this, ID_SEL_BY_LISTBOX, wxDefaultPosition, + wxSize(220, -1), HistoryList, wxLB_SINGLE ); + LeftBoxSizer->Add(m_List, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM|wxADJUST_MINSIZE, 5); + + Button = new wxButton(this, ID_ACCEPT_NAME, _("OK")); + Button->SetForegroundColour(*wxRED); + Button->SetDefault(); + RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM, 5); + + Button = new wxButton(this, ID_ACCEPT_KEYWORD, _("Search KeyWord")); + Button->SetForegroundColour(*wxRED); + RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + Button = new wxButton(this, ID_CANCEL, _("Cancel")); + Button->SetForegroundColour(*wxBLUE); + RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + Button = new wxButton(this, ID_LIST_ALL, _("List All")); + Button->SetForegroundColour(wxColor(0, 80, 0)); + RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + +#ifndef __WXMAC__ + if ( m_AuxTool ) /* The selection can be done by an extra function */ + { + + Button = new wxButton(this, ID_EXTRA_TOOL, _("By Lib Browser")); + Button->SetForegroundColour(wxColor(80, 0, 80)); + RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + } +#endif + + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); +} + +/*********************************************************/ +void WinEDA_SelectCmp::Accept(wxCommandEvent& event) +/*********************************************************/ +{ + switch (event.GetId() ) + { + case ID_SEL_BY_LISTBOX: + *m_Text = m_List->GetStringSelection(); + break; + + case ID_ACCEPT_NAME: + *m_Text = m_TextCtrl->GetValue(); + break; + + case ID_ACCEPT_KEYWORD: + *m_Text = wxT("= ") + m_TextCtrl->GetValue(); + break; + + case ID_CANCEL: + *m_Text = wxEmptyString; + break; + + case ID_LIST_ALL: + *m_Text = wxT("*"); + break; + + } + m_Text->Trim(FALSE); // Remove blanks at beginning + m_Text->Trim(TRUE); // Remove blanks at end + Close(TRUE); +} + + +/**************************************************************/ +void WinEDA_SelectCmp::GetExtraSelection(wxCommandEvent& event) +/**************************************************************/ +/* Get the component name by the extra function +*/ +{ + m_GetExtraFunction = TRUE; + Close(TRUE); +} + + + +/******************************************************************************/ +wxString GetComponentName(WinEDA_DrawFrame * frame, + wxArrayString & HistoryList, const wxString & Title, + wxString(*AuxTool)(WinEDA_DrawFrame *parent)) +/*******************************************************************************/ +/* Dialog frame to choose a component name +*/ +{ +wxPoint framepos; +int x, y, w, h; +bool GetExtraFunction; + + framepos = wxGetMousePosition(); + wxClientDisplayRect(&x, &y, &w, &h); + framepos.x -= 100; framepos.y -= 50; + if ( framepos.x < x ) framepos.x = x; + if ( framepos.y < y ) framepos.y = y; + if ( framepos.x < x ) framepos.x = x; + x += w -350; if ( framepos.x > x ) framepos.x = x; + if ( framepos.y < y ) framepos.y = y; +WinEDA_SelectCmp * selframe = + new WinEDA_SelectCmp(frame, framepos, HistoryList, Title, AuxTool ? TRUE : FALSE); + selframe->ShowModal(); + GetExtraFunction = selframe->m_GetExtraFunction; + selframe->Destroy(); + + if ( GetExtraFunction ) s_ItemName = AuxTool(frame); + return s_ItemName; +} + + +/*******************************************************************************/ +void AddHistoryComponentName(wxArrayString & HistoryList, const wxString & Name) +/*******************************************************************************/ +/* Add the string "Name" to the history list HistoryList +*/ +{ +int ii, c_max; + + if ( HistoryList.GetCount() > 0) + { + if (Name == HistoryList[0] ) return; + + /* remove an old identical selection if exists */ + for ( ii = 1; (unsigned)ii < HistoryList.GetCount(); ii ++ ) + { + if ( Name == HistoryList[ii] ) + { + HistoryList.RemoveAt(ii); ii--; + } + } + + /* shift the list */ + if ( HistoryList.GetCount() < s_HistoryMaxCount ) + HistoryList.Add(wxT("")); + + c_max = HistoryList.GetCount() - 2; + for ( ii = c_max; ii >= 0 ; ii -- ) HistoryList[ii+1] = HistoryList[ii]; + + /* Add the new name at the beginning of the history list */ + HistoryList[0] = Name; + } + else + HistoryList.Add(Name); +} diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp new file mode 100644 index 0000000000..533629d7c5 --- /dev/null +++ b/common/gr_basic.cpp @@ -0,0 +1,1387 @@ + /********************************/ + /* Low level graphics routines */ + /********************************/ + + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" +#include "trigo.h" +#include "macros.h" + +#ifndef FILLED +#define FILLED 1 +#endif + + +/* global variables */ +extern BASE_SCREEN * ActiveScreen; + +/* Variables locales */ +static int GRLastMoveToX , GRLastMoveToY; +static int Text_Color = LIGHTGRAY; + +static int PenMinWidth = 1; /* largeur minimum de la plume (DOIT etre > 0) + (utile pour trace sur imprimante) */ +static int ForceBlackPen; /* si != 0 : traces en noir (utilise pour trace + sur imprimante */ +static int xcliplo = 0, + ycliplo = 0, + xcliphi = 2000, + ycliphi = 2000; /* coord de la surface de trace */ +static int lastcolor = -1; +static int lastwidth = -1; +static wxDC * lastDC = NULL; + +/* + Macro de clipping du trace d'une ligne: + la ligne (x1,y1 x2,y2) est clippee pour rester dans le cadre + (xcliplo,ycliplo xcliphi,ycliphi) (variables globales,locales a ce fichier) + Ceci est necessaire sous WIN95 car les coord de trace + (bien que en int 32bits) sont tronquees en 16 bits (stupide BG) +*/ +#ifndef us +#define us unsigned int +#endif + +static inline int USCALE(us arg, us num, us den) +{ + int ii; + + ii = (int)( ((float) arg * num) / den); + return( ii ); +} + + +#ifdef WX_ZOOM +#define GET_ZOOM 1 +#else +#define GET_ZOOM ActiveScreen->GetZoom() +#endif + +static int inline ZoomValue(int value_to_zoom) +{ +int zoom = GET_ZOOM; + if ( value_to_zoom >= 0 ) + return( (value_to_zoom + (zoom >> 1 ) ) /zoom ); + else + return( (value_to_zoom - (zoom >> 1 ) ) /zoom ); +} + +/****************************************/ +/* External reference for the mappings. */ +/****************************************/ +int GRMapX(int x) +{ +int coord = x - ActiveScreen->m_DrawOrg.x; + +#ifndef WX_ZOOM + coord = ZoomValue(coord); + coord -= ActiveScreen->m_StartVisu.x; +#endif + + return coord; +} + +int GRMapY(int y) +{ +int coord = y - ActiveScreen->m_DrawOrg.y; + +#ifndef WX_ZOOM + coord = ZoomValue(coord); + coord -= ActiveScreen->m_StartVisu.y; +#endif + + return coord; +} + + + +#define WHEN_OUTSIDE return +#define WHEN_INSIDE + +#define CLIP_LINE(x1,y1,x2,y2) \ +{\ +int temp;\ +do {\ + if(x1 > x2) { EXCHG(x1,x2); EXCHG(y1,y2); }\ + if((x2 < xcliplo) || (x1 > xcliphi)) { WHEN_OUTSIDE; }\ + if(y1 < y2)\ + {\ + if((y2 < ycliplo) || (y1 > ycliphi)) { WHEN_OUTSIDE;}\ + if(y1 < ycliplo)\ + {\ + temp = USCALE((x2 - x1),(ycliplo - y1),(y2 - y1));\ + if((x1 += temp) > xcliphi) { WHEN_OUTSIDE; }\ + y1 = ycliplo;\ + WHEN_INSIDE;\ + }\ + if(y2 > ycliphi)\ + {\ + temp = USCALE((x2 - x1),(y2 - ycliphi),(y2 - y1));\ + if((x2 -= temp) < xcliplo) { WHEN_OUTSIDE; }\ + y2 = ycliphi;\ + WHEN_INSIDE;\ + }\ + if(x1 < xcliplo)\ + {\ + temp = USCALE((y2 - y1),(xcliplo - x1),(x2 - x1));\ + y1 += temp; x1 = xcliplo;\ + WHEN_INSIDE;\ + }\ + if(x2 > xcliphi)\ + {\ + temp = USCALE((y2 - y1),(x2 - xcliphi),(x2 - x1));\ + y2 -= temp; x2 = xcliphi;\ + WHEN_INSIDE;\ + }\ + }\ + else\ + {\ + if((y1 < ycliplo) || (y2 > ycliphi)) { WHEN_OUTSIDE; }\ + if(y1 > ycliphi)\ + {\ + temp = USCALE((x2 - x1),(y1 - ycliphi),(y1 - y2));\ + if((x1 += temp) > xcliphi) { WHEN_OUTSIDE; }\ + y1 = ycliphi;\ + WHEN_INSIDE;\ + }\ + if(y2 < ycliplo)\ + {\ + temp = USCALE((x2 - x1),(ycliplo - y2),(y1 - y2));\ + if((x2 -= temp) < xcliplo) { WHEN_OUTSIDE; }\ + y2 = ycliplo;\ + WHEN_INSIDE;\ + }\ + if(x1 < xcliplo)\ + {\ + temp = USCALE((y1 - y2),(xcliplo - x1),(x2 - x1));\ + y1 -= temp; x1 = xcliplo;\ + WHEN_INSIDE;\ + }\ + if(x2 > xcliphi)\ + {\ + temp = USCALE((y1 - y2),(x2 - xcliphi),(x2 - x1));\ + y2 += temp; x2 = xcliphi;\ + WHEN_INSIDE;\ + }\ + }\ + } while(0);\ +} + +static void WinClipAndDrawLine(EDA_Rect * ClipBox, wxDC * DC, + int x1, int y1, int x2, int y2, + int Color, int width = 1 ) +{ + GRLastMoveToX = x2; + GRLastMoveToY = y2; + + if ( ClipBox ) + { + xcliplo = ClipBox->GetX(); + ycliplo = ClipBox->GetY(); + xcliphi = ClipBox->GetRight(); + ycliphi = ClipBox->GetBottom(); + + xcliplo -= width; + ycliplo -= width; + + xcliphi += width; + ycliphi += width; + + CLIP_LINE(x1, y1, x2, y2); + } + + GRSetColorPen(DC, Color, width); + DC->DrawLine(x1, y1, x2, y2); +} + + +/* Routine de forcage de la reinit de la plume courante. + Doit etre appelee par securite apres changement de contexte graphique + avant tout trace + */ +void GRResetPenAndBrush(wxDC * DC) +{ + lastcolor = -1; + GRSetBrush(DC, BLACK); // Force no fill + lastDC = NULL; +} + +/* routine d'ajustage de la largeur mini de plume */ +void SetPenMinWidth(int minwidth) +{ + PenMinWidth = minwidth; + if( PenMinWidth < 1 ) PenMinWidth = 1; +} + + +/* Routine de changement de couleurs et epaisseur de la plume courante */ +void GRSetColorPen(wxDC * DC, int Color , int width) +{ + Color &= MASKCOLOR; // Pour 32 couleurs Max + + if(width < PenMinWidth) width = PenMinWidth; + + if( ForceBlackPen && Color != WHITE ) Color = BLACK; + + if( (lastcolor != Color) || (lastwidth != width) || (lastDC != DC ) ) + { + DrawPen->SetColour( + ColorRefs[Color].m_Red, + ColorRefs[Color].m_Green, + ColorRefs[Color].m_Blue + ); + + DrawPen->SetWidth(width); + if ( &DC->GetPen() != DrawPen ) DC->SetPen(*DrawPen); + lastcolor = Color; lastwidth = width; lastDC = DC; + } +} + +/***********************************************/ +void GRSetBrush(wxDC * DC, int Color , int fill) +/***********************************************/ +{ + Color &= MASKCOLOR; // Pour 32 couleurs Max + if( ForceBlackPen && Color != WHITE ) Color = BLACK; + DrawBrush->SetColour( + ColorRefs[Color].m_Red, + ColorRefs[Color].m_Green, + ColorRefs[Color].m_Blue + ); + + if ( fill ) DrawBrush->SetStyle(wxSOLID); + else DrawBrush->SetStyle(wxTRANSPARENT); + if ( &DC->GetBrush() != DrawBrush ) DC->SetBrush(*DrawBrush); +} + +/*************************************/ +void GRForceBlackPen(bool flagforce ) +/*************************************/ +{ + ForceBlackPen = flagforce; +} + + +/************************************************************/ +/* routines de controle et positionnement du curseur souris */ +/************************************************************/ +/* positionne la souris au point de coord pos */ +void GRMouseWarp(WinEDA_DrawPanel * panel, const wxPoint& pos) +{ + if( panel == NULL ) return; + panel->WarpPointer(pos.x, pos.y); +} + +/**********************************************/ +/* Routine pour selectionner le mode de trace */ +/**********************************************/ +void GRSetDrawMode(wxDC * DC, int draw_mode) +{ + if( draw_mode & GR_OR ) DC->SetLogicalFunction(wxOR); + else if( draw_mode & GR_XOR ) DC->SetLogicalFunction(wxXOR); + else if( draw_mode & GR_NXOR ) DC->SetLogicalFunction(wxEQUIV); + else DC->SetLogicalFunction(wxCOPY); +} + + +/*********************************************************************/ +void GRPutPixel(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int Color) +/*********************************************************************/ +{ + GRSPutPixel(ClipBox, DC, GRMapX(x), GRMapY(y), Color); +} + + +/********************************************************************/ +void GRSPutPixel(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int Color) +/********************************************************************/ +{ + + if ( ClipBox ) /* suppression des pixels hors ecran */ + { + if ( x < ClipBox->GetX() ) return; + if ( y < ClipBox->GetY() ) return; + if ( x > (ClipBox->GetRight()) ) return; + if ( y > (ClipBox->GetBottom()) ) return; + } + GRSetColorPen(DC, Color ); + DC->DrawPoint( x, y); +} + + /*******************************************/ + /* int GRGetPixel(wxDC * DC, int x, int y) */ + /*******************************************/ + +int GRGetPixel(wxDC * DC, int x, int y) +{ +wxColour colour; +unsigned char r, g, b; +int ii; + + DC->GetPixel( (long)x, (long)y, &colour); + r = colour.Red(); + b = colour.Blue(); + g = colour.Green(); + for ( ii = 0; ii < NBCOLOR; ii++ ) + { + if( ( r == ColorRefs[ii].m_Red ) && + ( g == ColorRefs[ii].m_Green ) && + ( b == ColorRefs[ii].m_Blue ) ) + break; + } + + return ii; +} + + + +/**************************************************************************** +* Routine to draw a line, in Object spaces. * +****************************************************************************/ +void GRLine(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + GRSLine(ClipBox, DC, GRMapX(x1), GRMapY(y1), GRMapX(x2), GRMapY(y2), Color); +} + +/***************************************************/ +/* Routine to draw a Dashed line, in Screen space. */ +/***************************************************/ +void GRSDashedLine(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + GRLastMoveToX = x2; + GRLastMoveToY = y2; + lastcolor = -1; + DrawPen->SetStyle(wxSHORT_DASH); + GRSLine(ClipBox, DC, x1, y1, x2, y2, Color); + lastcolor = -1; + DrawPen->SetStyle(wxSOLID); +} + +void GRSDashedLineTo(EDA_Rect * ClipBox,wxDC * DC, int x2, int y2, int Color) +{ + lastcolor = -1; + DrawPen->SetStyle(wxSHORT_DASH); + GRSLine(ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x2, y2, Color); + lastcolor = -1; + DrawPen->SetStyle(wxSOLID); + GRLastMoveToX = x2; + GRLastMoveToY = y2; +} +/**************************************************************************** +* Routine to draw a Dashed line, in Object spaces. * +****************************************************************************/ +void GRDashedLineTo(EDA_Rect * ClipBox,wxDC * DC,int x2, int y2, int Color) +{ + GRSDashedLineTo(ClipBox, DC, GRMapX(x2), GRMapY(y2), Color); +} + +void GRDashedLine(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + GRSDashedLine(ClipBox, DC, GRMapX(x1), GRMapY(y1), GRMapX(x2), GRMapY(y2), Color); +} + + +/*************************************************/ +/* Routine to draw a Bus line, in Object spaces. */ +/*************************************************/ + +void GRBusLine(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + x1 = GRMapX(x1); x2 = GRMapX(x2); + y1 = GRMapY(y1); y2 = GRMapY(y2); + GRSBusLine(ClipBox, DC, x1, y1, x2, y2, Color); +} + +/**************************************************************** +* Routine to draw a Bus Line, in Screen (pixels) space. * +****************************************************************************/ +void GRSBusLine(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + GRSFillCSegm(ClipBox, DC, x1, y1, x2, y2, 3*PenMinWidth, Color); + GRLastMoveToX = x2; + GRLastMoveToY = y2; +} + + +/**************************************************************************** +* Routine to move to a new position, in Object space. * +****************************************************************************/ +void GRMoveTo(int x, int y) +{ + GRLastMoveToX = GRMapX(x); + GRLastMoveToY = GRMapY(y); +} + +/*******************************************************/ +/* Routine to draw to a new position, in Object space. */ +/*******************************************************/ +void GRLineTo(EDA_Rect * ClipBox,wxDC * DC, int x, int y, int Color) +{ +int GRLineToX, GRLineToY; + + GRLineToX = GRMapX(x); GRLineToY = GRMapY(y); + GRSLine(ClipBox, DC, GRLastMoveToX, GRLastMoveToY, GRLineToX, GRLineToY, Color); +} + +/*************************************************/ +/* Routine to draw a Mixed line, in Object space */ +/*************************************************/ +void GRMixedLine(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + GRSMixedLine(ClipBox, DC, GRMapX(x1), GRMapY(y1), GRMapX(x2), GRMapY(y2), Color); +} + +/***********************************************************/ +/* Routine to draw a Mixed line, in Screen (Pixels) space */ +/***********************************************************/ +void GRSMixedLine(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + DrawPen->SetStyle(wxDOT_DASH); + GRSLine(ClipBox, DC, x1, y1, x2, y2, Color); + DrawPen->SetStyle(wxSOLID); +} + +/*******************************************************************/ +/* Routine to draw a Bus line to a new position, in Object spaces. */ +/*******************************************************************/ +void GRBusLineTo(EDA_Rect * ClipBox,wxDC * DC, int x, int y, int Color) +{ +int GRLineToX, GRLineToY; + + GRLineToX = GRMapX(x); GRLineToY = GRMapY(y); + + GRSBusLine(ClipBox, DC, GRLastMoveToX, GRLastMoveToY, GRLineToX, GRLineToY, + Color); + GRLastMoveToX = GRLineToX; + GRLastMoveToY = GRLineToY; +} + +/**************************************************************************** +* Routine to move to a new position, in Screen (pixels) space. * +****************************************************************************/ +void GRSMoveTo(int x, int y) +{ + GRLastMoveToX = x; + GRLastMoveToY = y; +} + +/**************************************************************************** +* Routine to draw to a new position, in Screen (pixels) space. * +****************************************************************************/ +void GRSLineTo(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int Color) +{ + GRSLine(ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x, y, Color); + GRLastMoveToX = x; GRLastMoveToY = y; +} + +/**************************************************************************** +* Routine to draw to a new position, in Screen (pixels) space. * +****************************************************************************/ +void GRSLine(EDA_Rect * ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int Color) +{ + WinClipAndDrawLine(ClipBox, DC, x1, y1, x2, y2, Color); + GRLastMoveToX = x2; GRLastMoveToY = y2; +} + +/****************************************************************************/ +/* Routine to move to a new position relative to current one, as in Object */ +/* space. */ +/****************************************************************************/ +void GRMoveRel(int x, int y) +{ + GRLastMoveToX += ZoomValue(x); + GRLastMoveToY += ZoomValue(y); +} + +/**************************************************************************** +* Routine to line to a new position relative to current one, as in Object * +* space. * +****************************************************************************/ +void GRLineRel(EDA_Rect * ClipBox,wxDC * DC, int x, int y, int Color) +{ +int GRLineToX = GRLastMoveToX, + GRLineToY = GRLastMoveToY; + + GRLineToX += ZoomValue(x); + GRLineToY += ZoomValue(y); + + GRSLine(ClipBox, DC, GRLastMoveToX, GRLastMoveToY, GRLineToX, GRLineToY, Color); +} + +/**************************************************************************** +* Routine to move to a new position relative to current one, as in Screen * +* space (pixel coords.). * +****************************************************************************/ +void GRSMoveRel(int x, int y) +{ + GRLastMoveToX += x; + GRLastMoveToY += y; +} + +/**************************************************************************** +* Routine to line to a new position relative to current one, as in Screen * +* space (pixel coords.). * +****************************************************************************/ +void GRSLineRel(EDA_Rect * ClipBox,wxDC * DC, int x, int y, int Color) +{ +long GRLineToX = GRLastMoveToX + x, + GRLineToY = GRLastMoveToY + y; + + GRSLine(ClipBox, DC, GRLastMoveToX, GRLastMoveToY, GRLineToX, GRLineToY, Color); + GRLastMoveToX = GRLineToX; + GRLastMoveToY = GRLineToY; +} + +/**************************************************/ +/* Routine de trace d'un segment a bouts arrondis */ +/* Object space = real coords.). */ +/**************************************************/ +void GRCSegm(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int width, int Color) +{ + GRSCSegm(ClipBox, DC, GRMapX(x1), GRMapY(y1), GRMapX(x2), GRMapY(y2), + ZoomValue(width), Color); +} + +/******************************************************************* +* Routine de trace d'un segment (plein) a bouts arrondis in Object * +* space (real coords.). * +********************************************************************/ +void GRFillCSegm(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int width, int Color) +{ + GRSFillCSegm(ClipBox, DC, GRMapX(x1), GRMapY(y1), GRMapX(x2), GRMapY(y2), + ZoomValue(width), Color); +} + + + /**********************************************************/ + /* Routine de trace d'un segment (plein) a bouts arrondis */ + /* ( Screen space = pixel coords.). */ + /**********************************************************/ + +void GRSFillCSegm(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int width, int Color) +{ + WinClipAndDrawLine(ClipBox, DC, x1,y1,x2,y2, Color, width); +} + + +/****************************************************************/ +/* Routine de trace d'un segment a bouts arrondis (Mode SKETCH) */ +/* Screen space (pixel coords.). */ +/****************************************************************/ +void GRSCSegm(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int width, int Color) +{ +long rayon, dwx, dwy; +long dx, dy, dwx2, dwy2; +long sx1, sy1, ex1, ey1; /* coord du 1er bord */ +long sx2, sy2, ex2, ey2; /* coord du 1eme bord */ +bool swap_ends = FALSE; + + + GRLastMoveToX = x2; + GRLastMoveToY = y2; + + if ( ClipBox ) + { + xcliplo = ClipBox->GetX(); + ycliplo = ClipBox->GetY(); + xcliphi = ClipBox->GetRight(); + ycliphi = ClipBox->GetHeight(); + + xcliplo -= width; + ycliplo -= width; + + xcliphi += width; + ycliphi += width; + + CLIP_LINE(x1, y1, x2, y2); + } + + + if ( width <= 2 ) /* ligne simple ou epaisse de 2 pixels*/ + { + GRSetColorPen(DC, Color, width ); + DC->DrawLine(x1, y1, x2, y2); + return; + } + + GRSetColorPen(DC, Color ); + GRSetBrush(DC,Color,FALSE); + + rayon = (width+1) >> 1; + dx = x2 - x1; dy = y2 - y1; + if ( dx == 0 ) /* segment vertical */ + { + dwx = rayon; + if ( dy >= 0 ) dwx = -dwx; + sx1 = x1 - dwx; sy1 = y1; + ex1 = x2 - dwx; ey1 = y2; + DC->DrawLine(sx1 , sy1, ex1, ey1); + + sx2 = x1 + dwx; sy2 = y1; + ex2 = x2 + dwx; ey2 = y2; + DC->DrawLine(sx2, sy2, ex2, ey2); + } + + else if ( dy == 0 ) /* segment horizontal */ + { + dwy = rayon; + if ( dx < 0 ) dwy = -dwy; + sx1 = x1, sy1 = y1 - dwy; + ex1 = x2; ey1 = y2 - dwy; + DC->DrawLine(sx1, sy1, ex1 , ey1); + + sx2 = x1; sy2 = y1 + dwy; + ex2 = x2; ey2 = y2 + dwy; + DC->DrawLine(sx2, sy2, ex2 , ey2); + } + + else + { + if ( ABS(dx) == ABS(dy) ) /* segment a 45 degre */ + { + dwx = dwy = ((width * 5)+ 4) / 7; // = width/2 * 0.707 + if ( dy < 0 ) + { + if ( dx <= 0 ) + { + dwx = -dwx; swap_ends = TRUE; + } + } + else + { + if( dx > 0 ) + { + dwy = -dwy; swap_ends = TRUE; + } + } + } + + else + { + int delta_angle = ArcTangente(dy, dx); + dwx = 0; dwy = width; + RotatePoint( (int*)&dwx, (int*)&dwy, -delta_angle); + } + dwx2 = dwx >> 1; dwy2 = dwy >> 1; + sx1 = x1 - dwx2; sy1 = y1 - dwy2; + ex1 = x2 - dwx2; ey1 = y2 - dwy2; + DC->DrawLine(sx1, sy1, ex1, ey1); + + sx2 = x1 + dwx2; sy2 = y1 + dwy2; + ex2 = x2 + dwx2; ey2 = y2 + dwy2; + DC->DrawLine(sx2, sy2, ex2, ey2); + } + + if ( swap_ends ) + { + DC->DrawArc(sx2, sy2, sx1 , sy1, x1, y1); + DC->DrawArc(ex1, ey1, ex2, ey2, x2, y2); + } + else + { + DC->DrawArc(sx1, sy1, sx2 , sy2, x1, y1); + DC->DrawArc(ex2, ey2, ex1, ey1, x2, y2); + } +} + + + +static bool IsGRSPolyDrawable( EDA_Rect * ClipBox,int n, int *Points) +{ +int ii; +int Xmin, Xmax, Ymin, Ymax; + + Xmin = Xmax = Points[0]; + Ymin = Ymax = Points[1]; + + for ( ii = 1; ii < n; ii++) // calcul du rectangle d'encadrement + { + int jj = ii * 2; + Xmin = MIN(Xmin,Points[jj]); + Xmax = MAX(Xmax,Points[jj]); + Ymin = MIN(Ymin,Points[jj+1]); + Ymax = MAX(Ymax,Points[jj+1]); + } + + xcliplo = ClipBox->GetX(); + ycliplo = ClipBox->GetY(); + xcliphi = ClipBox->GetRight(); + ycliphi = ClipBox->GetHeight(); + + if ( Xmax < xcliplo ) return FALSE; + if ( Xmin > xcliphi ) return FALSE; + if ( Ymax < ycliplo ) return FALSE; + if ( Ymin > ycliphi ) return FALSE; + + return TRUE; + +} +/************************************************************************/ +/* Routine to draw a new polyline and fill it if Fill, in screen space. */ +/************************************************************************/ +void GRSPoly(EDA_Rect * ClipBox,wxDC * DC, int n, int *Points, int Fill, + int Color, int BgColor) +{ +int startx, starty; + + if ( ! IsGRSPolyDrawable(ClipBox, n, Points) ) return; + + GRSetColorPen(DC, Color ); + + if( Fill && ( n > 2 ) ) + { + GRSetBrush(DC, BgColor, FILLED); + DC->DrawPolygon(n, (wxPoint*)Points); + } + else + { + startx = Points[n * 2 - 2]; starty = Points[n * 2 - 1]; + GRSetBrush(DC, Color); + DC->DrawLines(n, (wxPoint*)Points); + } +} + +/************************************************************************/ +/* Routine to draw a new polyline (line width = Width), in screen space. */ +/************************************************************************/ +void GRSPolyLines(EDA_Rect * ClipBox,wxDC * DC, int n, int *Points, + int Color, int BgColor, int Width) +{ +int startx, starty; + + if ( ! IsGRSPolyDrawable(ClipBox, n, Points) ) return; + + GRSetColorPen(DC, Color, Width ); + + startx = Points[n * 2 - 2]; starty = Points[n * 2 - 1]; + GRSetBrush(DC, Color); + DC->DrawLines(n, (wxPoint*)Points); +} + +/******************************************************************************/ +/* Routine to draw a new closed polyline and fill it if Fill, in screen space */ +/******************************************************************************/ +void GRSClosedPoly(EDA_Rect * ClipBox,wxDC * DC, int n, int *Points, + int Fill, int Color, int BgColor) +{ +int startx, starty; + + if ( ! IsGRSPolyDrawable(ClipBox, n, Points) ) return; + + GRSetColorPen(DC, Color ); + + if( Fill && ( n > 2 ) ) + { + GRSMoveTo(Points[n * 2 - 2], Points[n * 2 - 1]); + GRSetBrush(DC, BgColor, FILLED); + DC->DrawPolygon(n, (wxPoint*) Points, 0, 0,wxODDEVEN_RULE ); + } + else + { + startx = Points[n * 2 - 2]; starty = Points[n * 2 - 1]; + GRSetBrush(DC, BgColor); + DC->DrawLines(n, (wxPoint*)Points); + + /* Fermeture du polygone */ + if( (startx != Points[0]) || (starty != Points[1]) ) + { + GRSLine(ClipBox, DC, Points[0], Points[1], startx, starty, Color); + } + } +} + + +/************************************************************************/ +/* Routine to draw a new polyline and fill it if Fill, in drawing space. */ +/************************************************************************/ +void GRPoly(EDA_Rect * ClipBox, wxDC * DC, int n, int *Points, + int Fill, int Color, int BgColor) +{ +int ii, jj; + + for (ii = 0; ii < n; ii++) + { + jj = ii << 1; + Points[jj] = GRMapX(Points[jj]); + jj++; + Points[jj] = GRMapY(Points[jj]); + } + GRSPoly(ClipBox, DC, n, Points, Fill, Color, BgColor); +} + +void GRPolyLines(EDA_Rect * ClipBox, wxDC * DC, int n, int *Points, + int Color, int BgColor, int width) +{ +int ii, jj; + + width = ZoomValue(width); + + for (ii = 0; ii < n; ii++) + { + jj = ii << 1; + Points[jj] = GRMapX(Points[jj]); + jj++; + Points[jj] = GRMapY(Points[jj]); + } + if ( width <= 1 ) GRSPoly(ClipBox, DC, n, Points, 0, Color, BgColor); + else GRSPolyLines(ClipBox, DC, n, Points, Color, BgColor, width); +} +/**************************************************************************/ +/* Routine to draw a closed polyline and fill it if Fill, in object space */ +/**************************************************************************/ +void GRClosedPoly(EDA_Rect * ClipBox,wxDC * DC, int n, int *Points, + int Fill, int Color, int BgColor) +{ +int ii, jj; + + for (ii = 0; ii < n; ii++) + { + jj = ii << 1; + Points[jj] = GRMapX(Points[jj]); + jj++; + Points[jj] = GRMapY(Points[jj]); + } + GRSClosedPoly(ClipBox, DC, n, Points, Fill, Color, BgColor); +} + +/***********************************************/ +/* Routine to draw a circle, in object space. */ +/***********************************************/ +void GRCircle(EDA_Rect * ClipBox,wxDC * DC, int x, int y, int r, int Color) +{ +int cx = GRMapX(x); +int cy = GRMapY(y); +int rayon = ZoomValue(r); + + GRSCircle(ClipBox, DC, cx, cy, rayon, Color ); +} + +/*****************************************************/ +/* Routine to draw a Filled circle, in object space. */ +/*****************************************************/ +void GRFilledCircle(EDA_Rect * ClipBox,wxDC * DC, int x, int y, int r, + int Color, int BgColor) +{ + r = ZoomValue(r); + GRSFilledCircle(ClipBox, DC, GRMapX(x), GRMapY(y), r, Color, BgColor ); +} + +/***********************************************************/ +/* Routine to draw un anneau, epaisseur w, in object space. */ +/***********************************************************/ +void GRCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r, int width, int Color) +{ + r = ZoomValue(r); + width = ZoomValue(width); + GRSCircle(ClipBox, DC, GRMapX(x), GRMapY(y), r, width, Color); +} + + +/***********************************************/ +/* Routine to draw a circle, in drawing space. */ +/***********************************************/ +void GRSCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r, int Color) +{ +int d = r + r; + + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int x0, y0, xm, ym; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + if ( x < (x0-r) ) return; + if ( y < (y0-r) ) return; + if ( x > (r+xm) ) return; + if ( y > (r+ym) ) return; + } + + GRSetColorPen(DC, Color); + GRSetBrush(DC,Color,FALSE); + DC->DrawEllipse(x-r,y-r, d, d); +} + +/******************************************************/ +/* Routine to draw a FILLED circle, in drawing space. */ +/******************************************************/ +void GRSFilledCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r, + int Color, int BgColor) +{ + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int x0, y0, xm, ym; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + if ( x < (x0-r) ) return; + if ( y < (y0-r) ) return; + if ( x > (r+xm) ) return; + if ( y > (r+ym) ) return; + } + + GRSetColorPen(DC, Color ); + GRSetBrush(DC, BgColor, FILLED); + DC->DrawEllipse(x-r, y-r, r+r, r+r); +} + + /***********************************************************************/ + /* Routine de trace d'un cercle epais ( Screen space = pixel coords.) */ + /***********************************************************************/ + +void GRSCircle(EDA_Rect * ClipBox,wxDC * DC, int xc, int yc, int r, int width, int Color) +{ + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int x0, y0, xm, ym; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + if ( xc < (x0-r - width) ) return; + if ( yc < (y0-r - width) ) return; + if ( xc > (r+xm + width) ) return; + if ( yc > (r+ym + width) ) return; + } + + GRSetColorPen(DC, Color, width); + GRSetBrush(DC, Color, FALSE); + DC->DrawEllipse(xc-r, yc-r, r+r, r+r); +} + + +/************************************************/ +/* Routine to draw an arc, in USER space. */ +/* Debut et fin de l'arc donnes par leur coord. */ +/************************************************/ +void GRArc1(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int xc, int yc, int Color) +{ + GRSArc1(ClipBox, DC, + GRMapX(x1), GRMapY(y1), GRMapX(x2), GRMapY(y2), + GRMapX(xc), GRMapY(yc), Color); +} + +/************************************************/ +/* Routine to draw an arc, width = width in USER space. */ +/* Debut et fin de l'arc donnes par leur coord. */ +/************************************************/ +void GRArc1(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int xc, int yc, int width, int Color) +{ + GRSArc1(ClipBox, DC, + GRMapX(x1), GRMapY(y1), GRMapX(x2), GRMapY(y2), + GRMapX(xc), GRMapY(yc), ZoomValue(width), Color); +} + +/************************************************/ +/* Routine to draw an arc, in screen space. */ +/* Debut et fin de l'arc donnes par leur coord. */ +/************************************************/ +void GRSArc1(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int xc, int yc, int Color) +{ + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int x0, y0, xm, ym, r; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + r = (int)hypot(x1-xc, y1-yc); + if ( xc < (x0-r) ) return; + if ( yc < (y0-r) ) return; + if ( xc > (r+xm) ) return; + if ( yc > (r+ym) ) return; + } + + GRSetColorPen(DC, Color ); + GRSetBrush(DC,Color,FALSE); + DC->DrawArc(x1, y1, x2, y2, xc, yc); +} + +/************************************************/ +/* Routine to draw an arc, width = width, in screen space. */ +/* Debut et fin de l'arc donnes par leur coord. */ +/************************************************/ +void GRSArc1(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int xc, int yc, int width, int Color) +{ + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int x0, y0, xm, ym, r; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + r = (int)hypot(x1-xc, y1-yc); + if ( xc < (x0-r) ) return; + if ( yc < (y0-r) ) return; + if ( xc > (r+xm) ) return; + if ( yc > (r+ym) ) return; + } + + GRSetColorPen(DC, Color , width); + GRSetBrush(DC, Color); + DC->DrawArc(x1, y1, x2, y2, xc, yc); +} + +/********************************************************************/ +/* Routine to draw an arc, in screen space. */ +/* As the Y axe is inverted the Angles should be inverted as well. */ +/********************************************************************/ +void GRSArc(EDA_Rect * ClipBox,wxDC * DC, int xc, int yc, + int StAngle, int EndAngle, int r, int Color) +{ +int x1, y1, x2, y2; + + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int x0, y0, xm, ym; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + if ( xc < (x0-r - 1) ) return; + if ( yc < (y0-r - 1) ) return; + if ( xc > (r+xm + 1) ) return; + if ( yc > (r+ym + 1) ) return; + } + + x1 = r; y1 = 0; + RotatePoint( &x1, & y1, EndAngle); + + x2 = r; y2 = 0; + RotatePoint( &x2, & y2, StAngle); + + GRSetColorPen(DC, Color); + GRSetBrush(DC,Color,FALSE); + DC->DrawArc(xc + x1, yc - y1, xc + x2, yc - y2, xc, yc); +} + +/********************************************************************/ +/* Routine to draw an arc, width = width, in screen space. */ +/* As the Y axe is inverted the Angles should be inverted as well. */ +/********************************************************************/ +void GRSArc(EDA_Rect * ClipBox,wxDC * DC, int xc, int yc, int StAngle, int EndAngle, + int r, int width, int Color) +{ +int x1, y1, x2, y2; + + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int x0, y0, xm, ym; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + if ( xc < (x0-r - width) ) return; + if ( yc < (y0-r - width) ) return; + if ( xc > (r+xm + width) ) return; + if ( yc > (r+ym + width) ) return; + } + + x1 = r; y1 = 0; + RotatePoint( &x1, & y1, EndAngle); + + x2 = r; y2 = 0; + RotatePoint( &x2, & y2, StAngle); + + GRSetColorPen(DC, Color , width); + GRSetBrush(DC, Color); + DC->DrawArc(xc + x1, yc - y1, xc + x2, yc - y2, xc, yc); +} + +/********************************************************************/ +/* Routine to draw an Filled arc, in screen space. */ +/* As the Y axes is inverted the Angles should be inverted as well. */ +/********************************************************************/ +void GRSFilledArc(EDA_Rect * ClipBox,wxDC * DC, int xc, int yc, + int StAngle, int EndAngle, int r, int Color, int BgColor) +{ +int x1, y1, x2, y2; + + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int x0, y0, xm, ym; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + if ( xc < (x0-r - 1) ) return; + if ( yc < (y0-r - 1) ) return; + if ( xc > (r+xm + 1) ) return; + if ( yc > (r+ym + 1) ) return; + } + + x1 = r; y1 = 0; + RotatePoint( &x1, & y1, EndAngle); + + x2 = r; y2 = 0; + RotatePoint( &x2, & y2, StAngle); + + GRSetBrush(DC, BgColor, FILLED); + GRSetColorPen(DC, Color); + DC->DrawArc(xc + x1, yc - y1, xc + x2, yc - y2, xc, yc); +} + +/********************************************************************/ +/* Routine to draw a Filled arc, in drawing space. */ +/* As the Y axes is inverted the Angles should be inverted as well. */ +/********************************************************************/ +void GRFilledArc(EDA_Rect * ClipBox,wxDC * DC, int x, int y, + int StAngle, int EndAngle, int r, int Color, int BgColor) +{ + GRSFilledArc(ClipBox, DC, GRMapX(x), GRMapY(y), + StAngle, EndAngle, + ZoomValue(r), Color, BgColor); +} + +/********************************************************************/ +/* Routine to draw an arc, in drawing space. */ +/* As the Y axes is inverted the Angles should be inverted as well. */ +/********************************************************************/ +void GRArc(EDA_Rect * ClipBox,wxDC * DC, int xc, int yc, int StAngle, + int EndAngle, int r, int Color) +{ +int x1, y1, x2, y2; + + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int rayon = ZoomValue(r) + 1; + int x0, y0, xm, ym, x, y; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + x = GRMapX(xc); y = GRMapY(yc); + if ( x < (x0 - rayon) ) return; + if ( y < (y0 - rayon) ) return; + if ( x > (xm + rayon) ) return; + if ( y > (ym + rayon) ) return; + } + + x1 = r; y1 = 0; + RotatePoint( &x1, & y1, EndAngle); + + x2 = r; y2 = 0; + RotatePoint( &x2, & y2, StAngle); + + GRSetColorPen(DC, Color); + GRSetBrush(DC,Color,FALSE); + DC->DrawArc(GRMapX(xc + x1), GRMapY(yc - y1), + GRMapX(xc + x2), GRMapY(yc - y2), + GRMapX(xc), GRMapY(yc) ); +} + +/********************************************************************/ +/* Routine to draw an arc, width = width, in drawing space. */ +/* As the Y axes is inverted the Angles should be inverted as well. */ +/********************************************************************/ +void GRArc(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int StAngle, int EndAngle, + int r, int width, int Color) +{ + GRSArc(ClipBox, DC, GRMapX(x), GRMapY(y), + StAngle, EndAngle, + ZoomValue(r), + ZoomValue(width), + Color); +} + +/**************************************************/ +/* Routine to draw a Rectangle, in drawing space. */ +/**************************************************/ +void GRRect(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + x1 = GRMapX(x1); y1 = GRMapY(y1); + x2 = GRMapX(x2); y2 = GRMapY(y2); + + GRSRect(ClipBox, DC, x1, y1, x2, y2, Color ); +} + +/************************************************************************************/ +void GRFilledRect(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int Color, int BgColor) +/************************************************************************************/ +/* Routine to draw a Rectangle (filled with AreaColor), in drawing space. */ +{ + x1 = GRMapX(x1); y1 = GRMapY(y1); + x2 = GRMapX(x2); y2 = GRMapY(y2); + + GRSFilledRect(ClipBox, DC, x1, y1, x2, y2, Color, BgColor ); +} + + +/*************************************************/ +/* Routine to draw a Rectangle, in screen space. */ +/*************************************************/ +void GRSRect(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + if(x1 > x2) EXCHG(x1,x2); + if(y1 > y2) EXCHG(y1,y2); + + /* Clipping des coordonnees */ + if ( ClipBox ) + { + int xmin = ClipBox->GetX(); + int ymin = ClipBox->GetY(); + int xmax = ClipBox->GetRight(); + int ymax = ClipBox->GetBottom(); + + if ( x1 > xmax ) return; + if ( x2 < xmin ) return; + if ( y1 > ymax ) return; + if ( y2 < ymin ) return; + } + + GRSetColorPen(DC, Color ); + if ( (x1 == x2) || (y1 == y2) ) DC->DrawLine(x1, y1, x2, y2); + else + { + GRSetBrush(DC, BLACK ); + DC->DrawRectangle(x1, y1, x2 - x1, y2 - y1); + } +} + + +/***************************************************************************************/ +void GRSFilledRect(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int Color, int BgColor) +/***************************************************************************************/ +/* Routine to draw a Filled Rectangle, in screen space. */ +{ + if(x1 > x2) EXCHG(x1,x2); + if(y1 > y2) EXCHG(y1,y2); + if ( ClipBox ) + { + int xmin = ClipBox->GetX(); + int ymin = ClipBox->GetY(); + int xmax = ClipBox->GetRight(); + int ymax = ClipBox->GetBottom(); + + if ( x1 > xmax ) return; + if ( x2 < xmin ) return; + if ( y1 > ymax ) return; + if ( y2 < ymin ) return; + + // Clipping des coordonnees + if ( x1 < xmin )x1 = xmin -1; + if ( y1 < ymin )y1 = ymin -1; + if ( x2 > xmax ) x2 = xmax +1; + if ( y2 > ymax ) y2 = ymax +1; + } + + GRSetColorPen(DC, Color ); + if ( (x1 == x2) || (y1 == y2) ) DC->DrawLine(x1, y1, x2, y2); + else + { + GRSetBrush(DC, BgColor, FILLED); + DC->DrawRectangle(x1, y1, x2 - x1, y2 - y1); + } +} + + + /****************************************/ + /* Routines relatives au trace de texte */ + /****************************************/ + + /*********************************************/ + /* Routine de selection de la fonte courante */ + /*********************************************/ + +void GRSetFont(wxDC * DC, wxFont * Font) +{ + DC->SetFont(*Font); +} + + /*********************************************************/ + /* void GRSetTextFgColor(wxFont * Font, int Color) */ + /*********************************************************/ + +/* Mise a la valeur Color des textes a afficher */ +void GRSetTextFgColor(wxDC * DC, int Color) +{ + DC->SetTextForeground(wxColour( + ColorRefs[Color].m_Red, + ColorRefs[Color].m_Green, + ColorRefs[Color].m_Blue) + ); +} + +/* Mise a la valeur Color des textes a afficher */ +void GRSetTextFgColor(wxDC * DC, wxFont *, int Color) +{ + DC->SetTextForeground(wxColour( + ColorRefs[Color].m_Red, + ColorRefs[Color].m_Green, + ColorRefs[Color].m_Blue) + ); +} + + +/*****************************************************************************/ +void GRGetTextExtent(wxDC * DC, const wxChar * Text, long * width, long * height) +/*****************************************************************************/ +/* donne la taille du rectangle d'encadrement du texte Text +*/ +{ +long w = 0, h = 0; + + if ( Text ) + { + DC->GetTextExtent(Text, &w, &h ); + } + if ( width ) *width = w; + if ( height ) * height = h; +} + + /********************************/ + /* void GRReseTextFgColor(void) */ + /********************************/ + +/* Mise a la couleur par defaut des textes a afficher */ +void GRResetTextFgColor(wxDC * DC) +{ + GRSetTextFgColor(DC, Text_Color); +} + + + /*********************************************************/ + /* void GRSetTextBgColor(wxFont * Font, int Color) */ + /*********************************************************/ + +/* Mise a la valeur Color du fond pour les textes a afficher */ +void GRSetTextBgColor(wxDC * DC, int Color) +{ + Color &= MASKCOLOR; // Pour 32 couleurs Max + DC->SetTextBackground(wxColour( + ColorRefs[Color].m_Red, + ColorRefs[Color].m_Green, + ColorRefs[Color].m_Blue) + ); +} + +void GRSetTextBgColor(wxDC * DC, wxFont *, int Color) +{ + Color &= MASKCOLOR; // Pour 32 couleurs Max + DC->SetTextBackground(wxColour( + ColorRefs[Color].m_Red, + ColorRefs[Color].m_Green, + ColorRefs[Color].m_Blue) + ); +} + diff --git a/common/makefile.g95 b/common/makefile.g95 new file mode 100644 index 0000000000..aa2a7c8837 --- /dev/null +++ b/common/makefile.g95 @@ -0,0 +1,15 @@ +WXDIR = $(WXWIN) + +all: common.a + +include makefile.include +include ../libs.win + +common.a: $(OBJECTS) ../libs.win makefile.include + ar ruv $@ $(OBJECTS) + ranlib $@ + +clean: + rm -f *.bak + rm -f *.o + rm -f common.a diff --git a/common/makefile.gtk b/common/makefile.gtk new file mode 100644 index 0000000000..378425af7e --- /dev/null +++ b/common/makefile.gtk @@ -0,0 +1,27 @@ +## Makefile for common.a +CC = gcc + +# Compiler flags. +CPPFLAGS = -Wall -O2 -I./ -I../include `wx-config --cflags` + +EDACPPFLAGS = $(CPPFLAGS) + +all: common.a + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + + +common.a: $(OBJECTS) makefile.gtk makefile.include + rm -f $@ + ar -rv $@ $(OBJECTS) + ranlib $@ + + +clean: + rm -f *.o; rm -f *~; rm core; rm *.bak; rm *.obj + rm -f common.a + + diff --git a/common/makefile.include b/common/makefile.include new file mode 100644 index 0000000000..a28312b94a --- /dev/null +++ b/common/makefile.include @@ -0,0 +1,87 @@ +EXTRACPPFLAGS= -I$(SYSINCLUDE) -I./ -Ibitmaps -I../include + +COMMON = ../include/colors.h + + + +OBJECTS= \ + confirm.o \ + base_struct.o\ + copy_to_clipboard.o\ + basicframe.o\ + common_plot_functions.o\ + common_plotPS_functions.o\ + common_plotHPGL_functions.o\ + drawtxt.o \ + wxwineda.o \ + string.o \ + gr_basic.o\ + gestfich.o\ + trigo.o\ + selcolor.o\ + bitmaps.o\ + common.o\ + eda_doc.o\ + toolbars.o\ + displlst.o \ + edaappl.o\ + block_commande.o\ + msgpanel.o\ + projet_config.o\ + get_component_dialog.o\ + eda_dde.o\ + worksheet.o\ + base_screen.o\ + dcsvg.o + +gr_basic.o: gr_basic.cpp ../include/gr_basic.h $(DEPEND) + +confirm.o: confirm.cpp $(COMMON) + +worksheet.o: worksheet.cpp ../include/worksheet.h $(COMMON) + +selcolor.o: selcolor.cpp ../include/colors.h $(COMMON) + +get_component_dialog.o: get_component_dialog.cpp $(COMMON) + +common_plotPS_functions.o: common_plotPS_functions.cpp ../include/plot_common.h $(COMMON) + +common_plotHPGL_functions.o: common_plotPS_functions.cpp ../include/plot_common.h $(COMMON) + +drawtxt.o: drawtxt.cpp ../include/grfonte.h $(COMMON) + +svg_print.o: svg_print.cpp $(COMMON) + +gr_basic.o: gr_basic.cpp ../include/gr_basic.h $(COMMON) ../include/plot_common.h + +dcsvg.o: dcsvg.cpp $(COMMON) ../include/dcsvg.h + +projet_config.o: projet_config.cpp $(COMMON) + +base_struct.o: base_struct.cpp $(COMMON) + +eda_doc.o: eda_doc.cpp $(COMMON) + +common.o: common.cpp $(COMMON) + +gestfich.o: gestfich.cpp $(COMMON) + +toolbars.o: toolbars.cpp $(COMMON) + +msgpanel.o: msgpanel.cpp $(COMMON) + +block_commande.o: block_commande.cpp $(COMMON) + +string.o: string.cpp + +trigo.o: trigo.cpp ../include/trigo.h + +bitmaps.o: bitmaps.cpp ../include/bitmaps.h + +edaappl.o: edaappl.cpp $(COMMON) ../include/worksheet.h\ + ../include/common.h ../include/gr_basic.h\ + ../include/build_version.h + +eda_dde.o: eda_dde.cpp $(COMMON) ../include/eda_dde.h + +displlst.o: displlst.cpp $(COMMON) diff --git a/common/makefile.macosx b/common/makefile.macosx new file mode 100644 index 0000000000..333439dabe --- /dev/null +++ b/common/makefile.macosx @@ -0,0 +1,26 @@ +## Makefile for common.a +CC = gcc + +# Compiler flags. +CPPFLAGS = -Wall -O2 -I./ -I../include `wx-config --cflags` + +EDACPPFLAGS = $(CPPFLAGS) + +all: common.a + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + + +common.a: $(OBJECTS) makefile.macosx makefile.include + rm -f $@ + ar -rv $@ $(OBJECTS) + ranlib $@ + + +clean: + rm -f *.o; rm -f *~; rm core; rm *.bak; rm *.obj + rm -f common.a + diff --git a/common/msgpanel.cpp b/common/msgpanel.cpp new file mode 100644 index 0000000000..6ad27b2e19 --- /dev/null +++ b/common/msgpanel.cpp @@ -0,0 +1,144 @@ + /******************************************************************/ + /* msgpanel.cpp - fonctions des classes du type WinEDA_MsgPanel */ + /******************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" + +#include "wxstruct.h" +#include "gr_basic.h" +#include "macros.h" +#include "common.h" + +/* table des evenements captes par un WinEDA_MsgPanel */ +BEGIN_EVENT_TABLE(WinEDA_MsgPanel, wxPanel) + EVT_PAINT(WinEDA_MsgPanel::OnPaint) +END_EVENT_TABLE() + + + + /***********************************************************/ + /* Fonctions de base de WinEDA_MsgPanel: l'ecran de messages */ + /***********************************************************/ + +WinEDA_MsgPanel::WinEDA_MsgPanel(WinEDA_DrawFrame *parent, int id, + const wxPoint& pos, const wxSize& size): + wxPanel(parent, id, pos, size ) +{ + m_Parent = parent; + SetFont( *g_MsgFont ); +} + + + +WinEDA_MsgPanel::~WinEDA_MsgPanel(void) +{ +} + + + +/*************************************************/ +void WinEDA_MsgPanel::OnPaint(wxPaintEvent & event) +/*************************************************/ +{ +wxPaintDC dc(this); + + EraseMsgBox(&dc); event.Skip(); +} + + + + +/*****************************************************************************/ +void WinEDA_MsgPanel::Affiche_1_Parametre(int pos_X,const wxString & texte_H, + const wxString & texte_L,int color) +/*****************************************************************************/ +/* + Routine d'affichage d'un parametre. + pos_X = cadrage horizontal + si pos_X < 0 : la position horizontale est la derniere + valeur demandee >= 0 + texte_H = texte a afficher en ligne superieure. + si "", par d'affichage sur cette ligne + texte_L = texte a afficher en ligne inferieure. + si "", par d'affichage sur cette ligne + color = couleur d'affichage +*/ +{ +static int old_pos_X; +wxPoint pos; +wxSize FontSizeInPixels, DrawSize; +wxClientDC dc(this); + + DrawSize = GetClientSize(); + + dc.SetBackground(* wxBLACK_BRUSH ); + dc.SetBackgroundMode(wxSOLID); +// dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetTextBackground(GetBackgroundColour()); + dc.SetFont(*g_MsgFont); + dc.GetTextExtent( wxT("W"), &FontSizeInPixels.x, &FontSizeInPixels.y ); + + if ( color >= 0 ) + { + color &= MASKCOLOR; + dc.SetTextForeground(wxColour( + ColorRefs[color].m_Red, ColorRefs[color].m_Green, + ColorRefs[color].m_Blue) ); + } + + if ( pos_X >= 0 ) + { + old_pos_X = pos.x = pos_X * (FontSizeInPixels.x + 2); + } + else pos.x = old_pos_X; + + + if( !texte_H.IsEmpty()) + { + pos.y = (DrawSize.y/2) - FontSizeInPixels.y;; + dc.DrawText(texte_H.GetData(), pos.x, pos.y); + } + if( !texte_L.IsEmpty()) + { + pos.y = DrawSize.y - FontSizeInPixels.y; + dc.DrawText(texte_L.GetData(), pos.x, pos.y); + } +} + +/****************************************/ +void WinEDA_MsgPanel::EraseMsgBox(void) +/****************************************/ +/* Effacement de la fenetre d'affichage des messages de bas d'ecran +*/ +{ +wxClientDC dc(this); + EraseMsgBox(&dc); +} + +/*******************************************/ +void WinEDA_MsgPanel::EraseMsgBox(wxDC * DC) +/*******************************************/ +{ +wxSize size; +wxColor color; +wxPen pen; +wxBrush brush; + + size = GetClientSize(); + color = GetBackgroundColour(); + pen.SetColour(color); + brush.SetColour(color); + brush.SetStyle(wxSOLID); + DC->SetPen(pen); + DC->SetBrush(brush); + + DC->DrawRectangle(0,0,size.x,size.y); + DC->SetBrush(wxNullBrush); + DC->SetPen(wxNullPen); +} + + diff --git a/common/projet_config.cpp b/common/projet_config.cpp new file mode 100644 index 0000000000..a25e4b16dc --- /dev/null +++ b/common/projet_config.cpp @@ -0,0 +1,467 @@ + /**************************************************/ + /* projet_config : routines de trace du cartouche */ + /**************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" + +#define CONFIG_VERSION 1 + +#define FORCE_LOCAL_CONFIG TRUE + + +/*********************************************************************/ +static bool ReCreatePrjConfig(const wxString & local_config_filename, + const wxString & GroupName, bool ForceUseLocalConfig) +/*********************************************************************/ +/* Cree ou recree la configuration locale de kicad (filename.pro) + initialise: + g_Prj_Config + g_Prj_Config_LocalFilename + g_Prj_Default_Config_FullFilename + return: + TRUE si config locale + FALSE si default config +*/ +{ + // free old config + if ( g_Prj_Config ) delete g_Prj_Config; + g_Prj_Config = NULL; + + // Init local Config filename + if ( local_config_filename.IsEmpty() ) g_Prj_Config_LocalFilename = wxT("kicad"); + else g_Prj_Config_LocalFilename = local_config_filename; + + ChangeFileNameExt( g_Prj_Config_LocalFilename, g_Prj_Config_Filename_ext ); + + // Init local config filename + if ( ForceUseLocalConfig || wxFileExists(g_Prj_Config_LocalFilename) ) + { + g_Prj_Default_Config_FullFilename.Empty(); + g_Prj_Config = new wxFileConfig(wxEmptyString, wxEmptyString, + g_Prj_Config_LocalFilename, wxEmptyString, + wxCONFIG_USE_RELATIVE_PATH); + g_Prj_Config->DontCreateOnDemand(); + + if ( ForceUseLocalConfig ) return TRUE; + + // Test de la bonne version du fichier (ou groupe) de configuration + int version = -1, def_version = 0; + g_Prj_Config->SetPath(GroupName); + version = g_Prj_Config->Read( wxT("version"), def_version); + g_Prj_Config->SetPath(UNIX_STRING_DIR_SEP); + if ( version > 0 ) return TRUE; + else delete g_Prj_Config; // Version incorrecte + } + + + // Fichier local non trouve ou invalide + g_Prj_Config_LocalFilename.Empty(); + g_Prj_Default_Config_FullFilename = + ReturnKicadDatasPath() + + wxT("template/kicad") + + g_Prj_Config_Filename_ext; + + // Recreate new config + g_Prj_Config = new wxFileConfig(wxEmptyString, wxEmptyString, + wxEmptyString, g_Prj_Default_Config_FullFilename, + wxCONFIG_USE_RELATIVE_PATH); + g_Prj_Config->DontCreateOnDemand(); + + return FALSE; +} + + +/***************************************************************************************/ +void WinEDA_App::WriteProjectConfig(const wxString & local_config_filename, + const wxString & GroupName, PARAM_CFG_BASE ** List) +/***************************************************************************************/ +/* enregistrement de la config "projet"*/ +{ +const PARAM_CFG_BASE * pt_cfg; +wxString msg; + + ReCreatePrjConfig(local_config_filename, GroupName, + FORCE_LOCAL_CONFIG); + /* Write date ( surtout pour eviter bug de wxFileConfig + qui se trompe de rubrique si declaration [xx] en premiere ligne + (en fait si groupe vide) */ + g_Prj_Config->SetPath(UNIX_STRING_DIR_SEP); + msg = DateAndTime(); + g_Prj_Config->Write( wxT("update"), msg); + msg = GetAppName(); + g_Prj_Config->Write( wxT("last_client"), msg); + + /* ecriture de la configuration */ + g_Prj_Config->DeleteGroup(GroupName); // Erase all datas + g_Prj_Config->Flush(); + + g_Prj_Config->SetPath(GroupName); + g_Prj_Config->Write( wxT("version"), CONFIG_VERSION); + g_Prj_Config->SetPath(UNIX_STRING_DIR_SEP); + + for( ; *List != NULL ; List++) + { + pt_cfg = *List; + if ( pt_cfg->m_Group ) g_Prj_Config->SetPath(pt_cfg->m_Group); + else g_Prj_Config->SetPath(GroupName); + + switch( pt_cfg->m_Type ) + { + case PARAM_INT: + #undef PTCFG + #define PTCFG ((PARAM_CFG_INT *)pt_cfg) + if (PTCFG->m_Pt_param == NULL) break; + if ( pt_cfg->m_Setup) + m_EDA_Config->Write(pt_cfg->m_Ident, *PTCFG->m_Pt_param); + else + g_Prj_Config->Write(pt_cfg->m_Ident, *PTCFG->m_Pt_param); + break; + + case PARAM_SETCOLOR: + #undef PTCFG + #define PTCFG ((PARAM_CFG_SETCOLOR *)pt_cfg) + if (PTCFG->m_Pt_param == NULL) break; + if ( pt_cfg->m_Setup) + m_EDA_Config->Write(pt_cfg->m_Ident, *PTCFG->m_Pt_param); + else + g_Prj_Config->Write(pt_cfg->m_Ident, *PTCFG->m_Pt_param); + break; + + case PARAM_DOUBLE: + #undef PTCFG + #define PTCFG ((PARAM_CFG_DOUBLE *)pt_cfg) + if (PTCFG->m_Pt_param == NULL) break; + if ( pt_cfg->m_Setup) + m_EDA_Config->Write(pt_cfg->m_Ident, *PTCFG->m_Pt_param); + else + g_Prj_Config->Write(pt_cfg->m_Ident, *PTCFG->m_Pt_param); + break; + + case PARAM_BOOL: + #undef PTCFG + #define PTCFG ((PARAM_CFG_BOOL *)pt_cfg) + if (PTCFG->m_Pt_param == NULL) break; + if ( pt_cfg->m_Setup) + m_EDA_Config->Write(pt_cfg->m_Ident, (int)*PTCFG->m_Pt_param); + else + g_Prj_Config->Write(pt_cfg->m_Ident, (int)*PTCFG->m_Pt_param); + break; + + case PARAM_WXSTRING: + #undef PTCFG + #define PTCFG ((PARAM_CFG_WXSTRING *)pt_cfg) + if (PTCFG->m_Pt_param == NULL) break; + if ( pt_cfg->m_Setup) + m_EDA_Config->Write(pt_cfg->m_Ident, *PTCFG->m_Pt_param); + else + g_Prj_Config->Write(pt_cfg->m_Ident, *PTCFG->m_Pt_param); + break; + + case PARAM_LIBNAME_LIST: + { + #undef PTCFG + #define PTCFG ((PARAM_CFG_LIBNAME_LIST *)pt_cfg) + if (PTCFG->m_Pt_param == NULL) break; + wxArrayString * libname_list = PTCFG->m_Pt_param; + if ( libname_list == NULL ) break; + unsigned indexlib = 0; + wxString cle_config; + for ( ; indexlib < libname_list->GetCount(); indexlib++ ) + { + cle_config = pt_cfg->m_Ident; + // We use indexlib+1 because first lib name is LibName1 + cle_config << (indexlib+1); + g_Prj_Config->Write(cle_config, libname_list->Item(indexlib)); + } + break; + } + + case PARAM_COMMAND_ERASE: // Erase all datas + if ( pt_cfg->m_Ident ) + { + m_EDA_Config->DeleteGroup(pt_cfg->m_Ident); + g_Prj_Config->DeleteGroup(pt_cfg->m_Ident); + } + break; + } + } + + g_Prj_Config->SetPath(UNIX_STRING_DIR_SEP); + delete g_Prj_Config; + g_Prj_Config = NULL; +} + + +/***************************************************************************************/ +bool WinEDA_App::ReadProjectConfig(const wxString & local_config_filename, + const wxString & GroupName, PARAM_CFG_BASE ** List, + bool Load_Only_if_New) +/***************************************************************************************/ +/* Lecture de la config "projet" + *** si Load_Only_if_New == TRUE, elle n'est lue que si elle + *** est differente de la config actuelle (dates differentes) + + return: + TRUE si lue. + Met a jour en plus: + EDA_Appl->m_CurrentOptionFileDateAndTime + EDA_Appl->m_CurrentOptionFile +*/ +{ +const PARAM_CFG_BASE * pt_cfg; +wxString timestamp; + + if ( List == NULL )return FALSE; + + ReCreatePrjConfig(local_config_filename, GroupName, FALSE); + + g_Prj_Config->SetPath(UNIX_STRING_DIR_SEP); + timestamp = g_Prj_Config->Read( wxT("update") ); + if ( Load_Only_if_New && ( !timestamp.IsEmpty() ) && + (timestamp == EDA_Appl->m_CurrentOptionFileDateAndTime) ) + { + return FALSE; + } + + EDA_Appl->m_CurrentOptionFileDateAndTime = timestamp; + + if ( ! g_Prj_Default_Config_FullFilename.IsEmpty() ) + EDA_Appl->m_CurrentOptionFile = g_Prj_Default_Config_FullFilename; + else + { + if ( wxPathOnly(g_Prj_Config_LocalFilename).IsEmpty() ) + EDA_Appl->m_CurrentOptionFile = + wxGetCwd() + STRING_DIR_SEP + g_Prj_Config_LocalFilename; + else + EDA_Appl->m_CurrentOptionFile = g_Prj_Config_LocalFilename; + } + + for( ; *List != NULL ; List++) + { + pt_cfg = *List; + if ( pt_cfg->m_Group ) g_Prj_Config->SetPath(pt_cfg->m_Group); + else g_Prj_Config->SetPath(GroupName); + switch( pt_cfg->m_Type ) + { + case PARAM_INT: + { + #undef PTCFG + #define PTCFG ((PARAM_CFG_INT *)pt_cfg) + int itmp; + if ( pt_cfg->m_Setup) + itmp = m_EDA_Config->Read(pt_cfg->m_Ident, PTCFG->m_Default ); + else + itmp = g_Prj_Config->Read(pt_cfg->m_Ident, PTCFG->m_Default ); + if( (itmp < PTCFG->m_Min) || (itmp > PTCFG->m_Max) ) + itmp = PTCFG->m_Default; + *PTCFG->m_Pt_param = itmp; + break; + } + + case PARAM_SETCOLOR: + { + #undef PTCFG + #define PTCFG ((PARAM_CFG_SETCOLOR *)pt_cfg) + int itmp; + if ( pt_cfg->m_Setup) + itmp = m_EDA_Config->Read(pt_cfg->m_Ident, PTCFG->m_Default ); + else + itmp = g_Prj_Config->Read(pt_cfg->m_Ident, PTCFG->m_Default ); + if( (itmp < 0) || (itmp > MAX_COLOR) ) + itmp = PTCFG->m_Default; + *PTCFG->m_Pt_param = itmp; + break; + } + + case PARAM_DOUBLE: + { + #undef PTCFG + #define PTCFG ((PARAM_CFG_DOUBLE *)pt_cfg) + double ftmp = 0; wxString msg; + if ( pt_cfg->m_Setup) + msg = m_EDA_Config->Read(pt_cfg->m_Ident, wxT("") ); + else + msg = g_Prj_Config->Read(pt_cfg->m_Ident, wxT("") ); + + if ( msg.IsEmpty() ) ftmp = PTCFG->m_Default; + else + { + msg.ToDouble(&ftmp); + if( (ftmp < PTCFG->m_Min) || (ftmp > PTCFG->m_Max) ) + ftmp = PTCFG->m_Default; + } + *PTCFG->m_Pt_param = ftmp; + break; + } + + case PARAM_BOOL: + { + #undef PTCFG + #define PTCFG ((PARAM_CFG_BOOL *)pt_cfg) + int itmp; + if ( pt_cfg->m_Setup) + itmp = m_EDA_Config->Read(pt_cfg->m_Ident, PTCFG->m_Default ); + else + itmp = g_Prj_Config->Read(pt_cfg->m_Ident, PTCFG->m_Default ); + *PTCFG->m_Pt_param = itmp ? TRUE : FALSE; + break; + } + + case PARAM_WXSTRING: + { + #undef PTCFG + #define PTCFG ((PARAM_CFG_WXSTRING *)pt_cfg) + if (PTCFG->m_Pt_param == NULL) break; + if ( pt_cfg->m_Setup) + *PTCFG->m_Pt_param = m_EDA_Config->Read(pt_cfg->m_Ident ); + else + *PTCFG->m_Pt_param = g_Prj_Config->Read(pt_cfg->m_Ident ); + break; + } + + case PARAM_LIBNAME_LIST: + { + #undef PTCFG + #define PTCFG ((PARAM_CFG_LIBNAME_LIST *)pt_cfg) + int indexlib = 1; // We start indexlib to 1 because first lib name is LibName1 + wxString libname, id_lib; + wxArrayString * libname_list = PTCFG->m_Pt_param; + while ( 1 ) + { + id_lib = pt_cfg->m_Ident; id_lib << indexlib; indexlib++; + libname = g_Prj_Config->Read(id_lib, wxT("") ); + if( libname.IsEmpty() ) break; + libname_list->Add(libname); + } + break; + } + + case PARAM_COMMAND_ERASE: + break; + } + } + + delete g_Prj_Config; + g_Prj_Config = NULL; + + return TRUE; +} + + +/**************************************************************/ +/* Constructeurs des descripteurs de structs de configuration */ +/**************************************************************/ + +PARAM_CFG_BASE::PARAM_CFG_BASE(const wxChar * ident, const paramcfg_id type, + const wxChar * group) +{ + m_Ident = ident; + m_Type = type; + m_Group = group; + m_Setup = FALSE; +} + + +PARAM_CFG_INT::PARAM_CFG_INT(const wxChar * ident, int * ptparam, + int default_val, int min, int max, + const wxChar * group) + : PARAM_CFG_BASE(ident, PARAM_INT, group) +{ + m_Pt_param = ptparam; + m_Default = default_val; + m_Min = min; + m_Max = max; +} + +PARAM_CFG_INT::PARAM_CFG_INT(bool Insetup, const wxChar * ident, int * ptparam, + int default_val, int min, int max, + const wxChar * group) + : PARAM_CFG_BASE(ident, PARAM_INT, group) +{ + m_Pt_param = ptparam; + m_Default = default_val; + m_Min = min; + m_Max = max; + m_Setup = Insetup; +} + +PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR(const wxChar * ident, int * ptparam, + int default_val, const wxChar * group) + : PARAM_CFG_BASE(ident, PARAM_SETCOLOR, group) +{ + m_Pt_param = ptparam; + m_Default = default_val; +} + +PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR(bool Insetup, const wxChar * ident, int * ptparam, + int default_val, const wxChar * group) + : PARAM_CFG_BASE(ident, PARAM_SETCOLOR, group) +{ + m_Pt_param = ptparam; + m_Default = default_val; + m_Setup = Insetup; +} + +PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE(const wxChar * ident, double * ptparam, + double default_val, double min , double max, + const wxChar * group) + : PARAM_CFG_BASE(ident, PARAM_DOUBLE, group) +{ + m_Pt_param = ptparam; + m_Default = default_val; + m_Min = min; + m_Max = max; +} +PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE(bool Insetup, const wxChar * ident, double * ptparam, + double default_val, double min , double max, + const wxChar * group) + : PARAM_CFG_BASE(ident, PARAM_DOUBLE, group) +{ + m_Pt_param = ptparam; + m_Default = default_val; + m_Min = min; + m_Max = max; + m_Setup = Insetup; +} + +PARAM_CFG_BOOL::PARAM_CFG_BOOL(const wxChar * ident, bool * ptparam, + int default_val, const wxChar * group) + : PARAM_CFG_BASE(ident, PARAM_BOOL, group) +{ + m_Pt_param = ptparam; + m_Default = default_val ? TRUE : FALSE; +} + +PARAM_CFG_BOOL::PARAM_CFG_BOOL(bool Insetup, const wxChar * ident, bool * ptparam, + int default_val, const wxChar * group) + : PARAM_CFG_BASE(ident, PARAM_BOOL, group) +{ + m_Pt_param = ptparam; + m_Default = default_val ? TRUE : FALSE; + m_Setup = Insetup; +} + +PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING(const wxChar * ident, + wxString * ptparam, const wxChar * group) + : PARAM_CFG_BASE(ident, PARAM_WXSTRING, group) +{ + m_Pt_param = ptparam; +} + +PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING(bool Insetup, const wxChar * ident, + wxString * ptparam, const wxChar * group) + : PARAM_CFG_BASE(ident, PARAM_WXSTRING, group) +{ + m_Pt_param = ptparam; + m_Setup = Insetup; +} + +PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST(const wxChar * ident, + wxArrayString * ptparam, const wxChar * group) + : PARAM_CFG_BASE(ident, PARAM_LIBNAME_LIST, group) +{ + m_Pt_param = ptparam; +} diff --git a/common/selcolor.cpp b/common/selcolor.cpp new file mode 100644 index 0000000000..be3b4ae19a --- /dev/null +++ b/common/selcolor.cpp @@ -0,0 +1,142 @@ + /************************/ + /* SETCOLOR.CPP */ + /************************/ +/* Affichage et selection de la palette des couleurs disponibles +dans une frame +*/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "macros.h" + +#include "common.h" +#include "colors.h" + + +enum colors_id { + ID_COLOR_BLACK = 2000, // ID_COLOR_ = ID_COLOR_BLACK a ID_COLOR_BLACK + 31 +}; + + +/*******************************************/ +class WinEDA_SelColorFrame: public wxDialog +/*******************************************/ +/* Frame d'affichage de la palette des couleurs disponibles +*/ +{ +private: +public: + + // Constructor and destructor + WinEDA_SelColorFrame(wxWindow *parent, const wxPoint& framepos); + ~WinEDA_SelColorFrame(void) {}; + +private: + void SelColor(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() + +}; +/* Construction de la table des evenements pour FrameClassMain */ +BEGIN_EVENT_TABLE(WinEDA_SelColorFrame, wxDialog) + EVT_COMMAND_RANGE(ID_COLOR_BLACK,ID_COLOR_BLACK+31, + wxEVT_COMMAND_BUTTON_CLICKED, + WinEDA_SelColorFrame::SelColor) +END_EVENT_TABLE() + +/***************************************/ +int DisplayColorFrame(wxWindow * parent) +/***************************************/ +{ +wxPoint framepos; +int color; + + wxGetMousePosition(&framepos.x, &framepos.y); + + WinEDA_SelColorFrame * frame = new WinEDA_SelColorFrame(parent,framepos); + color = frame->ShowModal(); frame->Destroy(); + if (color > NBCOLOR) color = -1; + return color; +} + +/*******************************************************************/ +WinEDA_SelColorFrame::WinEDA_SelColorFrame(wxWindow *parent, + const wxPoint& framepos): + wxDialog(parent, -1, _("Colors"), framepos, wxSize(375, 240), + DIALOG_STYLE ) +/*******************************************************************/ +{ +#define START_Y 10 +wxBitmapButton * Button; +int ii, butt_ID, buttcolor; +wxPoint pos; +int w = 20, h = 20; +wxStaticText * text; +int right, bottom, line_height; + + SetFont(*g_DialogFont); + + SetReturnCode(-1); + + bottom = pos.x = 5; right = pos.y = START_Y; + line_height = h; + for ( ii = 0; ColorRefs[ii].m_Name != NULL ; ii++ ) + { + butt_ID = ID_COLOR_BLACK + ii; + wxMemoryDC iconDC; + wxBitmap ButtBitmap(w,h); + wxBrush Brush; + iconDC.SelectObject( ButtBitmap ); + buttcolor = ColorRefs[ii].m_Numcolor; + iconDC.SetPen(*wxBLACK_PEN); + Brush.SetColour( + ColorRefs[buttcolor].m_Red, + ColorRefs[buttcolor].m_Green, + ColorRefs[buttcolor].m_Blue + ); + Brush.SetStyle(wxSOLID); + + iconDC.SetBrush(Brush); + iconDC.SetBackground(*wxGREY_BRUSH); + iconDC.Clear(); + iconDC.DrawRoundedRectangle(0,0, w, h, (double)h/3); + + text = new wxStaticText(this,-1, + ColorRefs[ii].m_Name, + wxPoint(pos.x + 2 + w , pos.y ), + wxSize(-1,-1), 0 ); + line_height = MAX( line_height, text->GetRect().GetHeight()); + right = MAX(right, text->GetRect().GetRight()); + bottom = MAX(bottom, text->GetRect().GetBottom()); + + Button = new wxBitmapButton(this, butt_ID, + ButtBitmap, + wxPoint(pos.x, pos.y - ((h -line_height)/2)), + wxSize(w,h) ); + + pos.y += line_height + 5; + if ( ii == 7 ) + { + pos.x = right + 10; pos.y = START_Y; + } + else if ( (ii == 15) || (ii == 23) ) + { + pos.x = right+ 10; pos.y = START_Y; + } + } + + SetClientSize( wxSize(right + 10, bottom + 10) ); +} + + +/*********************************************************/ +void WinEDA_SelColorFrame::SelColor(wxCommandEvent& event) +/*********************************************************/ +{ +int id = event.GetId(); + + EndModal(id - ID_COLOR_BLACK); +} + + + diff --git a/common/string.cpp b/common/string.cpp new file mode 100644 index 0000000000..654533c8c1 --- /dev/null +++ b/common/string.cpp @@ -0,0 +1,342 @@ +/****************************************************************************/ +/* MODULE: string.cpp */ +/* ROLE: fonctions complementaires de traitement de chaines de caracteres */ +/****************************************************************************/ + +#include "fctsys.h" +#include +#include "common.h" + + +/*********************************************************************/ +int ReadDelimitedText(char * dest, char * source, int NbMaxChar ) +/*********************************************************************/ +/* lit et place dans dest la chaine de caractere trouvee dans source, + delimitee par " . + transfere NbMaxChar max + retourne le nombre de codes lus dans source + dest est termine par NULL +*/ +{ +int ii, jj, flag = 0; + + for ( ii = 0, jj = 0; ii < NbMaxChar - 1 ; jj++, source++) + { + if ( * source == 0 ) break; /* fin de ligne */ + if ( * source == '"' ) /* delimiteur trouve */ + { + if ( flag ) break; /* Fin de texte delimite */ + flag = 1; /* Marque 1er delimiteur trouve */ + } + else if ( flag ) + { + * dest = * source; dest++; ii++; + } + } + *dest = 0; /* Null terminaison */ + return (jj); +} + + +/********************************/ +char * StrPurge(char * text) +/********************************/ +/* Supprime les caracteres Space en debut de la ligne text + retourne un pointeur sur le 1er caractere non Space de text +*/ +{ +char * ptspace; + if ( text == NULL ) return NULL; + + while( (*text <= ' ') && *text ) text++; + ptspace = text + strlen(text) -1; + while( (*ptspace <= ' ') && *ptspace && (ptspace >= text) ) + { + *ptspace = 0; ptspace--; + } + return(text); +} + + +/*****************************************************************/ +char * GetLine(FILE *File, char *Line, int *LineNum, int SizeLine) +/*****************************************************************/ +/* Routine de lecture de 1 ligne utile + retourne la 1ere ligne utile lue. + elimine lignes vides et commentaires + incremente *LineNum a chaque ligne lue +*/ +{ + do { + if (fgets(Line, SizeLine, File) == NULL) return NULL; + if( LineNum ) *LineNum += 1; + } while (Line[0] == '#' || Line[0] == '\n' || Line[0] == '\r' || + Line[0] == 0); + + strtok(Line,"\n\r"); + return Line; +} + + +/*******************************/ +char * DateAndTime(char * Line) +/*******************************/ +/* Retourne la chaine de caractere donnant date+heure */ +{ +time_t Time_Buf; +struct tm * Date; + + time(&Time_Buf); + Date = gmtime(&Time_Buf); + sprintf(Line,"%d/%d/%d-%2.2d:%2.2d:%2.2d", + Date->tm_mday, Date->tm_mon + 1, Date->tm_year + 1900, + Date->tm_hour, Date->tm_min, Date->tm_sec ); + + return(Line); +} + +/*******************************/ +wxString DateAndTime(void) +/*******************************/ +/* Retourne la chaine de caractere donnant date+heure */ +{ +time_t Time_Buf; +struct tm * Date; +wxString Line; + + time(&Time_Buf); + Date = gmtime(&Time_Buf); + Line.Printf( wxT("%d/%d/%d-%2.2d:%2.2d:%2.2d"), + Date->tm_mday, Date->tm_mon + 1, Date->tm_year + 1900, + Date->tm_hour, Date->tm_min, Date->tm_sec ); + + return(Line); +} + + +/************************************************************/ +int StrLenNumCmp(const wxChar *str1,const wxChar *str2, int NbMax) +/************************************************************/ +/* +routine (compatible qsort() ) de comparaison pour classement alphab‚tique +Analogue a strncmp() mais les nombres sont compar‚s selon leur valeur num‚rique +et non pas par leur code ascii +*/ +{ +int i; +int nb1 = 0 , nb2 = 0; + + if( (str1 == NULL) || (str2 == NULL) ) return(0); + + for ( i = 0 ; i < NbMax ; i++ ) + { + if (isdigit(*str1) && isdigit(*str2) ) /* nombres en jeu */ + { + nb1 = 0 ; nb2 = 0 ; + while (isdigit(*str1)) + { + nb1 = nb1*10 + *str1 -'0'; str1++; + } + while (isdigit(*str2)) + { + nb2 = nb2*10 + *str2 -'0'; str2++; + } + if ( nb1 < nb2 ) return(-1) ; + if ( nb1 > nb2 ) return(1) ; + } + + if( *str1 < *str2 ) return(-1) ; + if( *str1 > *str2 ) return(1) ; + if( (*str1 == 0 ) && ( *str2 == 0 ) ) return(0) ; + str1++ ; str2++ ; + } + + return(0); +} + + +/***********************************************/ +int StrNumICmp(const wxChar *str1,const wxChar *str2) +/***********************************************/ +/* +routine (compatible qsort() ) de comparaison pour classement alphabétique, +avec lower case == upper case. +Analogue a stricmp() mais les nombres sont comparés selon leur valeur numérique +et non pas par leur code ascii +*/ +{ + return StrLenNumICmp( str1, str2, 32735); +} + + +/**************************************************************/ +int StrLenNumICmp(const wxChar *str1,const wxChar *str2, int NbMax) +/**************************************************************/ +/* +routine (compatible qsort() ) de comparaison pour classement alphabetique, +avec lower case == upper case. +Analogue a stricmp() mais les nombres sont compares selon leur valeur numerique +et non pas par leur code ascii +*/ +{ +int i; +int nb1 = 0 , nb2 = 0; + + if( (str1 == NULL) || (str2 == NULL) ) return(0); + + for ( i = 0 ; i < NbMax ; i++ ) + { + if (isdigit(*str1) && isdigit(*str2) ) /* nombres en jeu */ + { + nb1 = 0 ; nb2 = 0 ; + while (isdigit(*str1)) + { + nb1 = nb1*10 + *str1 -'0'; str1++; + } + while (isdigit(*str2)) + { + nb2 = nb2*10 + *str2 -'0'; str2++; + } + if ( nb1 < nb2 ) return(-1) ; + if ( nb1 > nb2 ) return(1) ; + } + + if( toupper(*str1) < toupper(*str2) ) return(-1) ; + if( toupper(*str1) > toupper(*str2) ) return(1) ; + if( (*str1 == 0 ) && ( *str2 == 0 ) ) return(0) ; + str1++ ; str2++ ; + } + + return(0); +} + + +/***********************************************************************/ +bool WildCompareString(const wxString & pattern, const wxString & string_to_tst, + bool case_sensitive ) +/***********************************************************************/ +/* compare 2 noms de composants, selon regles usuelles + ( Jokers * , ? , autorisés). + la chaine de reference est "pattern" + si case_sensitive == TRUE, comparaison exacte + retourne TRUE si match + retourne FALSE si differences +*/ +{ +const wxChar *cp = NULL, *mp = NULL; +const wxChar * wild, * string; +wxString _pattern, _string_to_tst; + + if ( case_sensitive ) + { + wild = pattern.GetData(); string = string_to_tst.GetData(); + } + else + { + _pattern = pattern; _pattern.MakeUpper(); + _string_to_tst = string_to_tst; _string_to_tst.MakeUpper(); + wild = _pattern.GetData(); string = _string_to_tst.GetData(); + } + + while ( (*string) && (*wild != '*') ) + { + if ( (*wild != *string) && (*wild != '?') ) return FALSE; + wild++; string++; + } + + while (*string) + { + if (*wild == '*') + { + if (!*++wild) return 1; + mp = wild; + cp = string+1; + } + else if ((*wild == *string) || (*wild == '?')) + { + wild++; + string++; + } + else + { + wild = mp; + string = cp++; + } + } + + while (*wild == '*') { + wild++; + } + return !*wild; +} + +/***********************************************/ +void ChangeSpaces(char * Text, int NewChar) +/***********************************************/ +/* Change dans un texte les espaces en NewChar */ +{ + if ( Text == NULL ) return; + while( *Text ) + { + if( *Text == ' ') *Text = (char) NewChar; + Text++; + } +} + + + +/***************************/ +char * to_point(char * Text) +/**************************/ +/* convertit les , en . dans une chaine. utilisé pour compenser +l'internalisation imbecile de la fct printf +qui genere les flottants avec une virgule au lieu du point +*/ +{ +char * line = Text; + + if ( Text == NULL ) return NULL; + for ( ; *Text != 0; Text++ ) + if (*Text == g_FloatSeparator) *Text = '.'; + + return line; +} + +/****************************/ +char * from_point(char * Text) +/****************************/ +/* convertit les . en , dans une chaine. utilisé pour compenser +l'internalisation imbecile de la fct scanf +qui lit les flottants avec une virgule au lieu du point +*/ +{ +char * line = Text; + if ( Text == NULL ) return NULL; + + for ( ; *Text != 0; Text++ ) + if (*Text == '.') *Text = g_FloatSeparator; + + return line; +} + +/********************************/ +char * strupper(char * Text) +/********************************/ +/* Change les caracteres 'a' ... 'z' en 'A' ... 'Z'. dans la chaine Text. +Retourne Text +*/ +{ +char * code = Text; + + if( Text ) + { + while( * code) + { + if( (*code >= 'a') && (*code <= 'z') ) *code += 'A' - 'a'; + code ++; + } + } + + return(Text); +} + diff --git a/common/svg_print.cpp b/common/svg_print.cpp new file mode 100644 index 0000000000..214ed8bcbe --- /dev/null +++ b/common/svg_print.cpp @@ -0,0 +1,509 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: svg_print.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 05/02/2006 11:05:19 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 05/02/2006 11:05:19 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "svg_print.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes + +#include +#include "wx/metafile.h" +#include "wx/dcsvg.h" +#include "wx/image.h" + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" + +#include "svg_print.h" + +////@begin XPM images +////@end XPM images + +extern BASE_SCREEN * ActiveScreen; +extern int PenMinWidth; /* dim mini (en 1/100 mmm) pour les traits imprimes */ + +#define WIDTH_MAX_VALUE 100 +#define WIDTH_MIN_VALUE 1 + +// Variables locales +static int Select_PrintAll = FALSE; +static bool Print_Sheet_Ref = TRUE; +static int s_PlotBlackAndWhite = 0; + + + +/*******************************************************/ +void WinEDA_DrawFrame::SVG_Print(wxCommandEvent& event) +/*******************************************************/ +/* Prepare les structures de donnees de gestion de l'impression +et affiche la fenetre de dialogue de gestion de l'impression des feuilles +*/ +{ + // Arret des commandes en cours + if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) + { + wxClientDC dc(DrawPanel); + DrawPanel->PrepareDC(dc); + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + SetToolID(0, wxCURSOR_ARROW,wxEmptyString); + +WinEDA_PrintSVGFrame frame(this); + frame.ShowModal(); +} + + +/*! + * WinEDA_PrintSVGFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_PrintSVGFrame, wxDialog ) + +/*! + * WinEDA_PrintSVGFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_PrintSVGFrame, wxDialog ) + +////@begin WinEDA_PrintSVGFrame event table entries + EVT_CLOSE( WinEDA_PrintSVGFrame::OnCloseWindow ) + + EVT_SPINCTRL( ID_SPINCTRL, WinEDA_PrintSVGFrame::OnSpinctrlUpdated ) + + EVT_RADIOBOX( ID_RADIOBOX_SETPRINTMODE, WinEDA_PrintSVGFrame::OnRadioboxSetprintmodeSelected ) + + EVT_BUTTON( ID_PRINT_EXECUTE, WinEDA_PrintSVGFrame::OnPrintExecuteClick ) + + EVT_BUTTON( wxID_CLOSE, WinEDA_PrintSVGFrame::OnCloseClick ) + +////@end WinEDA_PrintSVGFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_PrintSVGFrame constructors + */ + +WinEDA_PrintSVGFrame::WinEDA_PrintSVGFrame( ) +{ +} + +WinEDA_PrintSVGFrame::WinEDA_PrintSVGFrame( WinEDA_DrawFrame* parent, + wxWindowID id, const wxString& caption, const wxPoint& pos, + const wxSize& size, long style ) +{ + m_Parent = parent; + m_ImageXSize_mm = 270; + wxConfig * Config = m_Parent->m_Parent->m_EDA_Config; + if ( Config ) + { + Config->Read(wxT("PlotSVGPenWidth"), &PenMinWidth); + Config->Read(wxT("PlotSVGModeColor"), &s_PlotBlackAndWhite); + } + + Create(parent, id, caption, pos, size, style); +} + +/*! + * WinEDA_PrintSVGFrame creator + */ + +bool WinEDA_PrintSVGFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_PrintSVGFrame member initialisation + m_ButtPenWidth = NULL; + m_ModeColorOption = NULL; + m_Print_Sheet_Ref = NULL; + m_PagesOption = NULL; + m_FileNameCtrl = NULL; + m_MessagesBox = NULL; +////@end WinEDA_PrintSVGFrame member initialisation + +////@begin WinEDA_PrintSVGFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + if (GetSizer()) + { + GetSizer()->SetSizeHints(this); + } + Centre(); +////@end WinEDA_PrintSVGFrame creation + return true; +} + +/*! + * Control creation for WinEDA_PrintSVGFrame + */ + +void WinEDA_PrintSVGFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_PrintSVGFrame content construction + // Generated by DialogBlocks, 09/09/2006 10:31:06 (unregistered) + + WinEDA_PrintSVGFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("Pen width mini"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer4->Add(itemStaticText5, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_ButtPenWidth = new wxSpinCtrl( itemDialog1, ID_SPINCTRL, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 100, 0 ); + itemBoxSizer4->Add(m_ButtPenWidth, 0, wxALIGN_LEFT|wxALL, 5); + + wxString m_ModeColorOptionStrings[] = { + _("Color"), + _("Black and White") + }; + m_ModeColorOption = new wxRadioBox( itemDialog1, ID_RADIOBOX_SETPRINTMODE, _("Print mode"), wxDefaultPosition, wxDefaultSize, 2, m_ModeColorOptionStrings, 1, wxRA_SPECIFY_COLS ); + m_ModeColorOption->SetSelection(0); + itemBoxSizer4->Add(m_ModeColorOption, 0, wxALIGN_LEFT|wxALL, 5); + + m_Print_Sheet_Ref = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Print Sheet Ref"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_Print_Sheet_Ref->SetValue(false); + itemBoxSizer4->Add(m_Print_Sheet_Ref, 0, wxALIGN_LEFT|wxALL, 5); + + itemBoxSizer4->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 56); + + wxString m_PagesOptionStrings[] = { + _("Current"), + _("All") + }; + m_PagesOption = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Page Print:"), wxDefaultPosition, wxDefaultSize, 2, m_PagesOptionStrings, 1, wxRA_SPECIFY_COLS ); + m_PagesOption->SetSelection(0); + itemBoxSizer4->Add(m_PagesOption, 0, wxALIGN_LEFT|wxALL, 5); + + itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 15); + + wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton13 = new wxButton( itemDialog1, ID_PRINT_EXECUTE, _("Create &File"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton13->SetForegroundColour(wxColour(0, 128, 0)); + itemBoxSizer12->Add(itemButton13, 0, wxGROW|wxALL, 5); + + wxButton* itemButton14 = new wxButton( itemDialog1, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton14->SetForegroundColour(wxColour(0, 0, 198)); + itemBoxSizer12->Add(itemButton14, 0, wxGROW|wxALL, 5); + + wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, wxID_STATIC, _("Filename:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add(itemStaticText15, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_FileNameCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add(m_FileNameCtrl, 0, wxGROW|wxALL, 5); + + itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxStaticText* itemStaticText18 = new wxStaticText( itemDialog1, wxID_STATIC, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add(itemStaticText18, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_MessagesBox = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxSize(-1, 100), wxTE_MULTILINE|wxTE_READONLY ); + itemBoxSizer2->Add(m_MessagesBox, 0, wxGROW|wxALL, 5); + + // Set validators + m_ButtPenWidth->SetValidator( wxGenericValidator(& PenMinWidth) ); + m_ModeColorOption->SetValidator( wxGenericValidator(& s_PlotBlackAndWhite) ); + m_Print_Sheet_Ref->SetValidator( wxGenericValidator(& Print_Sheet_Ref) ); +////@end WinEDA_PrintSVGFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_PrintSVGFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_PrintSVGFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_PrintSVGFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_PrintSVGFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_PrintSVGFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_PrintSVGFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_PrintSVGFrame icon retrieval +} + + +/******************************************************/ +wxString WinEDA_PrintSVGFrame::ReturnFullFileName(void) +/******************************************************/ +{ +wxString name, ext; + + name = m_Parent->m_CurrentScreen->m_FileName; + ChangeFileNameExt(name, wxT(".svg")); + return name; +} + + +/*********************************************************/ +void WinEDA_PrintSVGFrame::SetPenWidth(wxSpinEvent& event) +/*********************************************************/ +{ + PenMinWidth = m_ButtPenWidth->GetValue(); + if ( PenMinWidth > WIDTH_MAX_VALUE ) + { + PenMinWidth = WIDTH_MAX_VALUE; + wxBell(); + } + if ( PenMinWidth < WIDTH_MIN_VALUE ) + { + PenMinWidth = WIDTH_MIN_VALUE; + wxBell(); + } + m_ButtPenWidth->SetValue(PenMinWidth); +} + + + +/**************************************************************/ +void WinEDA_PrintSVGFrame::PrintSVGDoc(wxCommandEvent& event) +/**************************************************************/ +/* Called on activate "Print CURRENT" button +*/ +{ +bool print_ref = TRUE; +wxString msg; + + Select_PrintAll = FALSE; + if ( m_PagesOption && (m_PagesOption->GetSelection() == 1) ) + Select_PrintAll = TRUE; + + if ( (m_Print_Sheet_Ref == NULL) || (m_Print_Sheet_Ref->GetValue() == FALSE) ) + print_ref = FALSE; + +wxSpinEvent spinevent; + SetPenWidth(spinevent); + + +BASE_SCREEN * screen = m_Parent->m_CurrentScreen; +BASE_SCREEN *oldscreen = screen; + + if( Select_PrintAll ) + while ( screen->Pback ) screen = (BASE_SCREEN *) screen->Pback; + + if ( (m_Parent->m_Ident == PCB_FRAME) || (m_Parent->m_Ident == GERBER_FRAME) ) + { + if( Select_PrintAll ) + { + m_PrintMaskLayer = 0xFFFFFFFF; + } + else m_PrintMaskLayer = 1; + } + + if (screen == NULL) return; + + if ( Select_PrintAll && m_Parent->m_Ident == SCHEMATIC_FRAME ) + { + SCH_SCREEN ** ScreenList; + int ScreenCount; + ScreenList = ((WinEDA_SchematicFrame*) m_Parent)->ReturnScreenList(NULL, &ScreenCount); + + for( int ii = 0; ii < ScreenCount; ii++ ) + { + SCH_SCREEN *schscreen = ScreenList[ii]; + /* Create all files *.svg */ + m_Parent->m_CurrentScreen = (BASE_SCREEN *)schscreen; + ActiveScreen = screen; + wxString FullFileName = ReturnFullFileName(); + bool success = DrawPage(FullFileName); + msg = _("Create file ") + FullFileName; + if ( ! success ) msg += _(" error"); + msg += wxT("\n"); + m_MessagesBox->AppendText(msg); + } + } + else + { + ActiveScreen = screen; + wxString FullFileName = m_FileNameCtrl->GetValue(); + if ( FullFileName.IsEmpty() ) + FullFileName = ReturnFullFileName(); + bool success = DrawPage(FullFileName); + msg = _("Create file ") + FullFileName; + if ( ! success ) msg += _(" error"); + msg += wxT("\n"); + m_MessagesBox->AppendText(msg); + } + ActiveScreen = oldscreen; +} + +/*****************************************************************/ +bool WinEDA_PrintSVGFrame::DrawPage(const wxString & FullFileName) +/*****************************************************************/ +/* + Routine effective d'impression +*/ +{ +int tmpzoom; +wxPoint tmp_startvisu; +wxSize SheetSize; // Sheet size in internal units +wxPoint old_org; +float dpi; +bool success = TRUE; + + /* modification des cadrages et reglages locaux */ + tmp_startvisu = ActiveScreen->m_StartVisu; + tmpzoom = ActiveScreen->GetZoom(); + old_org = ActiveScreen->m_DrawOrg; + ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0; + ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.y = 0; + SheetSize = ActiveScreen->m_CurrentSheet->m_Size; // size in 1/1000 inch + SheetSize.x *= m_Parent->m_InternalUnits / 1000; + SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in pixels + + ActiveScreen->SetZoom(1); + dpi = (float)SheetSize.x * 25.4 /m_ImageXSize_mm; + + WinEDA_DrawPanel * panel = m_Parent->DrawPanel; + +wxSVGFileDC dc(FullFileName, SheetSize.x, SheetSize.y, dpi) ; + + if ( ! dc.Ok() ) + { + DisplayError(this, wxT("SVGprint error: wxSVGFileDC not OK")); + success = FALSE; + } + + else + { + EDA_Rect tmp = panel->m_ClipBox; + GRResetPenAndBrush(&dc); + PenMinWidth = m_ButtPenWidth->GetValue(); + SetPenMinWidth(PenMinWidth); + GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? FALSE : TRUE ); + + + panel->m_ClipBox.SetX(0);panel->m_ClipBox.SetY(0); + panel->m_ClipBox.SetWidth(0x7FFFFF0); panel->m_ClipBox.SetHeight(0x7FFFFF0); + + g_IsPrinting = TRUE; + panel->PrintPage(&dc, m_Print_Sheet_Ref, m_PrintMaskLayer); + g_IsPrinting = FALSE; + panel->m_ClipBox = tmp; + } + + + GRForceBlackPen(FALSE); + SetPenMinWidth(1); + + ActiveScreen->m_StartVisu = tmp_startvisu; + ActiveScreen->m_DrawOrg = old_org; + ActiveScreen->SetZoom(tmpzoom); + + return success; +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PRINT_EXECUTE + */ + +void WinEDA_PrintSVGFrame::OnPrintExecuteClick( wxCommandEvent& event ) +{ + PrintSVGDoc(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + */ + +void WinEDA_PrintSVGFrame::OnCloseClick( wxCommandEvent& event ) +{ + Close(TRUE); +} + + +/*! + * wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_SPINCTRL + */ + +void WinEDA_PrintSVGFrame::OnSpinctrlUpdated( wxSpinEvent& event ) +{ + SetPenWidth(event); +} + + +/*! + * wxEVT_CLOSE_WINDOW event handler for ID_DIALOG + */ + +void WinEDA_PrintSVGFrame::OnCloseWindow( wxCloseEvent& event ) +{ + wxConfig * Config = m_Parent->m_Parent->m_EDA_Config; + if ( Config ) + { + s_PlotBlackAndWhite = m_ModeColorOption->GetSelection(); + Config->Write(wxT("PlotSVGPenWidth"), PenMinWidth); + Config->Write(wxT("PlotSVGModeColor"), s_PlotBlackAndWhite); + } + event.Skip(); +} + + + + +/*! + * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX_SETPRINTMODE + */ + +void WinEDA_PrintSVGFrame::OnRadioboxSetprintmodeSelected( wxCommandEvent& event ) +{ + s_PlotBlackAndWhite = m_ModeColorOption->GetSelection(); + event.Skip(); +} + + diff --git a/common/svg_print.h b/common/svg_print.h new file mode 100644 index 0000000000..5410015e3b --- /dev/null +++ b/common/svg_print.h @@ -0,0 +1,142 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: svg_print.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 05/02/2006 11:05:20 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 05/02/2006 11:05:20 + +#ifndef _SVG_PRINT_H_ +#define _SVG_PRINT_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "svg_print.h" +#endif + +/*! + * Includes + */ + +////@begin includes +#include "wx/valgen.h" +#include "wx/spinctrl.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +class wxSpinCtrl; +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_PRINTSVGFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxFRAME_FLOAT_ON_PARENT +#define SYMBOL_WINEDA_PRINTSVGFRAME_TITLE _("Create SVG file") +#define SYMBOL_WINEDA_PRINTSVGFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_PRINTSVGFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_PRINTSVGFRAME_POSITION wxDefaultPosition +#define ID_SPINCTRL 10003 +#define ID_RADIOBOX_SETPRINTMODE 10007 +#define ID_CHECKBOX 10004 +#define ID_RADIOBOX 10005 +#define ID_PRINT_EXECUTE 10002 +#define ID_TEXTCTRL 10001 +#define ID_TEXTCTRL1 10006 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_PrintSVGFrame class declaration + */ + +class WinEDA_PrintSVGFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_PrintSVGFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_PrintSVGFrame( ); + WinEDA_PrintSVGFrame( WinEDA_DrawFrame* parent, + wxWindowID id = SYMBOL_WINEDA_PRINTSVGFRAME_IDNAME, + const wxString& caption = SYMBOL_WINEDA_PRINTSVGFRAME_TITLE, + const wxPoint& pos = SYMBOL_WINEDA_PRINTSVGFRAME_POSITION, + const wxSize& size = SYMBOL_WINEDA_PRINTSVGFRAME_SIZE, + long style = SYMBOL_WINEDA_PRINTSVGFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PRINTSVGFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PRINTSVGFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PRINTSVGFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PRINTSVGFRAME_SIZE, long style = SYMBOL_WINEDA_PRINTSVGFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_PrintSVGFrame event handler declarations + + /// wxEVT_CLOSE_WINDOW event handler for ID_DIALOG + void OnCloseWindow( wxCloseEvent& event ); + + /// wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_SPINCTRL + void OnSpinctrlUpdated( wxSpinEvent& event ); + + /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX_SETPRINTMODE + void OnRadioboxSetprintmodeSelected( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PRINT_EXECUTE + void OnPrintExecuteClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + void OnCloseClick( wxCommandEvent& event ); + +////@end WinEDA_PrintSVGFrame event handler declarations + +////@begin WinEDA_PrintSVGFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_PrintSVGFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void PrintSVGDoc(wxCommandEvent& event); + bool DrawPage(const wxString & FullFileName); + void SetPenWidth(wxSpinEvent& event); + wxString ReturnFullFileName(void); + +////@begin WinEDA_PrintSVGFrame member variables + wxSpinCtrl* m_ButtPenWidth; + wxRadioBox* m_ModeColorOption; + wxCheckBox* m_Print_Sheet_Ref; + wxRadioBox* m_PagesOption; + wxTextCtrl* m_FileNameCtrl; + wxTextCtrl* m_MessagesBox; +////@end WinEDA_PrintSVGFrame member variables + + WinEDA_DrawFrame * m_Parent; + int m_PrintMaskLayer; + int m_ImageXSize_mm; +}; + +#endif + // _SVG_PRINT_H_ diff --git a/common/svg_print.pjd b/common/svg_print.pjd new file mode 100644 index 0000000000..123eec42b1 --- /dev/null +++ b/common/svg_print.pjd @@ -0,0 +1,1081 @@ + + +
+ 0 + "" + "" + "" + "" + 26 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "Print SVG file" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "wxEVT_CLOSE_WINDOW|OnCloseWindow" + "ID_DIALOG" + 10000 + "WinEDA_PrintSVGFrame" + "wxDialog" + "wxDialog" + "svg_print.cpp" + "svg_print.h" + "" + "Create SVG file" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "wxFRAME_FLOAT_ON_PARENT" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Vertical" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Pen width mini" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxSpinCtrl: ID_SPINCTRL" + "dialog-control-document" + "" + "spinctrl" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbSpinCtrlProxy" + "wxEVT_COMMAND_SPINCTRL_UPDATED|OnSpinctrlUpdated" + "ID_SPINCTRL" + 10003 + "wxSpinCtrl" + "m_ButtPenWidth" + 1 + 100 + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "PenMinWidth" + "wxGenericValidator(& %VARIABLE%)" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxRadioBox: ID_RADIOBOX_SETPRINTMODE" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "25/11/2006" + "wbRadioBoxProxy" + "wxEVT_COMMAND_RADIOBOX_SELECTED|OnRadioboxSetprintmodeSelected" + "ID_RADIOBOX_SETPRINTMODE" + 10007 + "wxRadioBox" + "m_ModeColorOption" + "Print mode" + 1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "s_PlotBlackAndWhite" + "wxGenericValidator(& %VARIABLE%)" + 0 + 1 + "Color|Black and White" + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX" + 10004 + "wxCheckBox" + "m_Print_Sheet_Ref" + "Print Sheet Ref" + 0 + "" + "" + "Print_Sheet_Ref" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxRadioBox: ID_RADIOBOX" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX" + 10005 + "wxRadioBox" + "m_PagesOption" + "Page Print:" + 1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + "Current|All" + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 15 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: ID_PRINT_EXECUTE" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnPrintExecuteClick" + "ID_PRINT_EXECUTE" + 10002 + "wxButton" + "" + "Create &File" + 0 + "" + "" + "" + "008000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_CLOSE" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCloseClick" + "wxID_CLOSE" + 5001 + "wxButton" + "" + "&Close" + 0 + "" + "" + "" + "0000C6" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Filename:" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Top" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL" + 10001 + "wxTextCtrl" + "m_FileNameCtrl" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "5/9/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "5/9/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Messages:" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL1" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "5/9/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL1" + 10006 + "wxTextCtrl" + "m_MessagesBox" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + 100 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "svg_print.rc" + "source-editor-document" + "svg_print.rc" + "source-editor" + 0 + 0 + 1 + 0 + "5/7/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/common/toolbars.cpp b/common/toolbars.cpp new file mode 100644 index 0000000000..7fe8b8340a --- /dev/null +++ b/common/toolbars.cpp @@ -0,0 +1,36 @@ + /******************************************************************/ + /* toolbars.cpp - fonctions des classes du type WinEDA_ttolbar */ + /******************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" +#include "common.h" + + +#include "id.h" + + /*************************/ + /* class WinEDA_HToolbar */ + /*************************/ + +WinEDA_Toolbar::WinEDA_Toolbar(id_toolbar type, wxWindow * parent, + wxWindowID id, bool horizontal): + wxToolBar(parent,id, wxPoint(-1,-1), wxSize(-1,-1), + horizontal ? wxTB_HORIZONTAL : wxTB_VERTICAL) +{ + m_Parent = parent; + Pnext = NULL; + m_Ident = type; + m_Horizontal = horizontal; + m_Size = 24; + + SetToolBitmapSize(wxSize(16,16)); + SetMargins(0,0); + SetToolSeparation(1); + SetToolPacking(1); +} + + diff --git a/common/trigo.cpp b/common/trigo.cpp new file mode 100644 index 0000000000..ad5d041378 --- /dev/null +++ b/common/trigo.cpp @@ -0,0 +1,188 @@ + /************************/ + /* Routines de rotation */ + /************************/ + + /* Fichier TRIGO.CPP */ + +#include "fctsys.h" +#define global extern +#include "trigo.h" + + +/***********************************/ +int ArcTangente(int dy, int dx) +/***********************************/ +/* Retourne l'arc tangente en 0.1 degres du vecteur de coord dx, dy + entre -1800 et 1800 + Analogue a atan2 ( mais plus rapide pour les calculs si + l'angle est souvent 0, -1800, ou +- 900 +*/ +{ +double fangle; + + if(dy == 0) + { + if(dx >= 0 ) return(0); + else return(-1800); + } + + if(dx == 0) + { + if(dy >= 0 ) return(900); + else return(-900); + } + + if(dx == dy) + { + if(dx >= 0) return(450); + else return(-1800+450); + } + + if(dx == -dy) + { + if(dx >= 0) return(-450); + else return(1800-450); + } + + fangle = atan2( (double)dy, (double)dx ) / M_PI * 1800; + return( (int) round(fangle) ); +} + + +/*********************************************/ +void RotatePoint(int *pX, int *pY, int angle) +/*********************************************/ +/* + Fonction surchargee! + calcule les nouvelles coord du point de coord pX, pY, + pour une rotation de centre 0, 0, et d'angle angle ( en 1/10 degre) +*/ +{ +float fpx, fpy; +int tmp; + + while (angle < 0) angle += 3600; + while (angle >= 3600) angle -= 3600; + + if (angle == 0) return; + + /* Calcul des coord : + coord: xrot = y*sin + x*cos + yrot = y*cos - x*sin + */ + if( angle == 900 ) /* sin = 1, cos = 0 */ + { + tmp = *pX; + *pX = *pY; + *pY = - tmp; + } + + else if( angle == 1800 ) /* sin = 0, cos = -1 */ + { + *pX = - *pX; + *pY = - *pY; + } + + else if( angle == 2700 ) /* sin = -1, cos = 0 */ + { + tmp = *pX; + *pX = - *pY; + *pY = tmp; + } + + else + { + fpx = (*pY * fsinus[angle]) + (*pX * fcosinus[angle]); + fpy = (*pY * fcosinus[angle]) - (*pX * fsinus[angle]); + *pX = (int)round(fpx); *pY = (int)round(fpy); + } +} + + +/************************************************************/ +void RotatePoint(int *pX, int *pY, int cx, int cy, int angle) +/*************************************************************/ +/* + Fonction surchargee! + calcule les nouvelles coord du point de coord pX, pY, + pour une rotation de centre cx, cy, et d'angle angle ( en 1/10 degre) +*/ +{ +int ox, oy; + + ox = *pX - cx; oy = *pY - cy; + RotatePoint(&ox, &oy, angle); + *pX = ox + cx; + *pY = oy + cy; +} + +/*****************************************************************/ +void RotatePoint(wxPoint *point, const wxPoint & centre, int angle) +/*****************************************************************/ +/* + Fonction surchargee! + calcule les nouvelles coord du point point, + pour une rotation de centre centre, et d'angle angle ( en 1/10 degre) +*/ +{ +int ox, oy; + + ox = point->x - centre.x; oy = point->y - centre.y; + RotatePoint(&ox, &oy, angle); + point->x = ox + centre.x; + point->y = oy + centre.y; +} + + +/*************************************************************************/ +void RotatePoint(double *pX, double *pY, double cx, double cy, int angle) +/*************************************************************************/ +{ +double ox, oy; + + ox = *pX - cx; oy = *pY - cy; + RotatePoint(&ox, &oy, angle); + *pX = ox + cx; + *pY = oy + cy; +} + + +/*************************************************/ +void RotatePoint(double *pX, double *pY, int angle) +/*************************************************/ +/* Calcul des coord : + coord: xrot = y*sin + x*cos + yrot = y*cos - x*sin +*/ +{ +double tmp; + while (angle < 0) angle += 3600; + while (angle >= 3600) angle -= 3600; + if (angle == 0) return; + if( angle == 900 ) /* sin = 1, cos = 0 */ + { + tmp = *pX; + *pX = *pY; + *pY = - tmp; + } + + else if( angle == 1800 ) /* sin = 0, cos = -1 */ + { + *pX = - *pX; + *pY = - *pY; + } + + else if( angle == 2700 ) /* sin = -1, cos = 0 */ + { + tmp = *pX; + *pX = - *pY; + *pY = tmp; + } + + else + { + double fpx = (*pY * fsinus[angle]) + (*pX * fcosinus[angle]); + double fpy = (*pY * fcosinus[angle]) - (*pX * fsinus[angle]); + *pX = fpx; *pY = fpy; + } +} diff --git a/common/worksheet.cpp b/common/worksheet.cpp new file mode 100644 index 0000000000..d4f9a5efd2 --- /dev/null +++ b/common/worksheet.cpp @@ -0,0 +1,274 @@ + /**************************************************/ + /* WORKSHEET.CPP : routines de trace du cartouche */ + /**************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "macros.h" + +#include "common.h" + +#include "worksheet.h" + +/* Must be defined in main applications: */ +extern wxString g_Main_Title; + +/*********************************************************************/ +void WinEDA_DrawFrame::TraceWorkSheet(wxDC * DC, BASE_SCREEN * screen) +/*********************************************************************/ +/* Draw the sheet references +*/ +{ + if ( ! m_Draw_Sheet_Ref ) return; + +Ki_PageDescr * Sheet = screen->m_CurrentSheet; +int ii, jj, xg , yg, ipas, gxpas, gypas; +wxPoint pos; +int refx, refy,Color; +wxString Line; +Ki_WorkSheetData * WsItem; +int scale = m_InternalUnits/1000; +wxSize size(SIZETEXT*scale,SIZETEXT*scale); +wxSize size_ref(SIZETEXT_REF*scale,SIZETEXT_REF*scale); +wxString msg; +int UpperLimit = VARIABLE_BLOCK_START_POSITION; + + Color = RED; + if(Sheet == NULL) + { + DisplayError(this, + wxT("WinEDA_DrawFrame::TraceWorkSheet() error: m_CurrentSheet NULL")); + return; + } + + // if not printing, draw the page limits: + if ( ! g_IsPrinting & g_ShowPageLimits ) + { + GRSetDrawMode(DC, GR_COPY); + GRRect(&DrawPanel->m_ClipBox, DC, 0, 0, + Sheet->m_Size.x * scale, Sheet->m_Size.y * scale, + g_DrawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY ); + } + + GRSetDrawMode(DC, GR_COPY); + /* trace de la bordure */ + refx = Sheet->m_LeftMargin; + refy = Sheet->m_TopMargin; /* Upper left corner */ + xg = Sheet->m_Size.x - Sheet->m_RightMargin; + yg = Sheet->m_Size.y - Sheet->m_BottomMargin; /* lower right corner */ + + for ( ii = 0; ii < 2 ; ii++ ) + { + GRRect(&DrawPanel->m_ClipBox, DC, refx * scale, refy * scale, + xg * scale, yg * scale, Color); + + refx += GRID_REF_W; refy += GRID_REF_W; + xg -= GRID_REF_W; yg -= GRID_REF_W; + } + /* trace des reperes */ + refx = Sheet->m_LeftMargin; + refy = Sheet->m_TopMargin; /* Upper left corner */ + xg = Sheet->m_Size.x - Sheet->m_RightMargin; + yg = Sheet->m_Size.y - Sheet->m_BottomMargin; /* lower right corner */ + + /* Trace des reperes selon l'axe X */ + ipas = (xg - refx) / PAS_REF; + gxpas = ( xg - refx) / ipas; + for ( ii = refx + gxpas, jj = 1; ipas > 0 ; ii += gxpas , jj++, ipas--) + { + Line.Printf( wxT("%d"),jj); + if( ii < xg - PAS_REF/2 ) + { + GRLine(&DrawPanel->m_ClipBox, DC, ii * scale, refy * scale, + ii * scale, (refy + GRID_REF_W) * scale, Color); + } + DrawGraphicText(DrawPanel, DC, + wxPoint( (ii - gxpas/2) * scale, (refy + GRID_REF_W/2) * scale), + Color, + Line, TEXT_ORIENT_HORIZ, size_ref, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + if( ii < xg - PAS_REF/2 ) + { + GRLine(&DrawPanel->m_ClipBox, DC,ii * scale, yg * scale, + ii * scale, (yg - GRID_REF_W) * scale, Color); + } + DrawGraphicText(DrawPanel, DC, + wxPoint( (ii - gxpas/2) * scale, (yg - GRID_REF_W/2) * scale), + Color, + Line, TEXT_ORIENT_HORIZ, size_ref, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + } + + /* Trace des reperes selon l'axe Y */ + ipas = (yg - refy) / PAS_REF; + gypas = ( yg - refy) / ipas; + for ( ii = refy + gypas, jj = 0; ipas > 0 ; ii += gypas , jj++, ipas--) + { + Line.Empty(); + if( jj < 26 ) Line.Printf(wxT("%c"), jj + 'A'); + else Line.Printf(wxT("%c"), 'a' + jj - 26); + if( ii < yg - PAS_REF/2 ) + { + GRLine(&DrawPanel->m_ClipBox, DC, refx * scale, ii * scale, + (refx + GRID_REF_W) * scale, ii * scale, Color); + } + DrawGraphicText(DrawPanel, DC, + wxPoint((refx + GRID_REF_W/2) * scale, (ii - gypas/2) * scale), + Color, + Line, TEXT_ORIENT_HORIZ, size_ref, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + if( ii < yg - PAS_REF/2 ) + { + GRLine(&DrawPanel->m_ClipBox, DC, xg * scale, ii * scale, + (xg - GRID_REF_W) * scale, ii * scale, Color); + } + DrawGraphicText(DrawPanel, DC, + wxPoint((xg - GRID_REF_W/2) * scale, (ii - gxpas/2) * scale), + Color, + Line, TEXT_ORIENT_HORIZ, size_ref, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + } + + + + /* Trace du cartouche */ + refx = Sheet->m_Size.x - Sheet->m_RightMargin - GRID_REF_W; + refy = Sheet->m_Size.y - Sheet->m_BottomMargin - GRID_REF_W; /* lower right corner */ + + for( WsItem = &WS_Date; WsItem != NULL; WsItem = WsItem->Pnext ) + { + pos.x = (refx - WsItem->m_Posx)* scale; + pos.y = (refy - WsItem->m_Posy)* scale; + msg.Empty(); + switch( WsItem->m_Type ) + { + case WS_DATE: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += screen->m_Date; + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + break; + + case WS_REV: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += screen->m_Revision; + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + break; + + case WS_LICENCE: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += g_ProductName + g_Main_Title; + msg += wxT(" ") + GetBuildVersion(); + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + break; + + case WS_SIZESHEET: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += Sheet->m_Name; + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + break; + + + case WS_IDENTSHEET: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg << screen->m_SheetNumber << wxT("/") << + screen->m_NumberOfSheet; + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + break; + + case WS_COMPANY_NAME: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += screen->m_Company; + if ( ! msg.IsEmpty() ) + { + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); + } + break; + + case WS_TITLE: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += screen->m_Title; + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + break; + + case WS_COMMENT1: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += screen->m_Commentaire1; + if ( ! msg.IsEmpty() ) + { + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); + } + break; + + case WS_COMMENT2: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += screen->m_Commentaire2; + if ( ! msg.IsEmpty() ) + { + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); + } + break; + + case WS_COMMENT3: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += screen->m_Commentaire3; + if ( ! msg.IsEmpty() ) + { + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); + } + break; + + case WS_COMMENT4: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += screen->m_Commentaire4; + if ( ! msg.IsEmpty() ) + { + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); + } + break; + + case WS_UPPER_SEGMENT: + if (UpperLimit == 0 ) break; + case WS_LEFT_SEGMENT: + WS_MostUpperLine.m_Posy = + WS_MostUpperLine.m_Endy = + WS_MostLeftLine.m_Posy = UpperLimit; + pos.y = (refy - WsItem->m_Posy)* scale; + case WS_SEGMENT: + xg = Sheet->m_Size.x - + GRID_REF_W - Sheet->m_RightMargin - WsItem->m_Endx; + yg = Sheet->m_Size.y - + GRID_REF_W - Sheet->m_BottomMargin - WsItem->m_Endy; + GRLine(&DrawPanel->m_ClipBox, DC, pos.x, pos.y, + xg * scale, yg * scale, Color); + break; + + } + } +} diff --git a/common/wxwineda.cpp b/common/wxwineda.cpp new file mode 100644 index 0000000000..eadf1cb0ba --- /dev/null +++ b/common/wxwineda.cpp @@ -0,0 +1,379 @@ + /**********************************************************/ + /* wxwineda.cpp - fonctions des classes du type WinEDAxxxx */ + /**********************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" +#include "common.h" + + + +/**********************************************************************************/ +/* Classe WinEDA_EnterText pour entrer une ligne texte au clavier dans les frames */ +/**********************************************************************************/ +WinEDA_EnterText::WinEDA_EnterText(wxWindow *parent, const wxString &Title, + const wxString & TextToEdit, wxBoxSizer * BoxSizer, const wxSize & Size ) +{ + m_Modify = FALSE; + if ( TextToEdit ) m_NewText = TextToEdit; + + m_Title = new wxStaticText(parent, -1, Title); + m_Title->SetForegroundColour(wxColour(200,0,0) ); + BoxSizer->Add(m_Title, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_FrameText = new wxTextCtrl(parent, -1, TextToEdit, wxDefaultPosition, Size); + m_FrameText->SetInsertionPoint(1); + BoxSizer->Add(m_FrameText, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5); +} + + +/****************************************/ +wxString WinEDA_EnterText::GetValue(void) +/****************************************/ +{ + m_Modify = m_FrameText->IsModified(); + m_NewText = m_FrameText->GetValue(); + return m_NewText; +} + +void WinEDA_EnterText::GetValue(char * buffer, int lenmax) +{ + m_Modify = m_FrameText->IsModified(); + if (buffer) + { + m_NewText = m_FrameText->GetValue(); + int ii, ll = m_NewText.Len(); + for ( ii = 0; ii < ll && ii < (lenmax-1); ii++ ); + buffer[ii] = m_NewText.GetChar(ii); + buffer[lenmax-1] = 0; + } +} + +void WinEDA_EnterText::SetValue(const wxString & new_text) +{ + m_FrameText->SetValue(new_text); +} + +void WinEDA_EnterText::Enable(bool enbl) +{ + m_Title->Enable(enbl); + m_FrameText->Enable(enbl); +} + + +/*********************************************************************/ +/* Classe pour editer un texte graphique + dimension en INCHES ou MM */ +/*********************************************************************/ +WinEDA_GraphicTextCtrl::WinEDA_GraphicTextCtrl(wxWindow *parent, + const wxString & Title, + const wxString & TextToEdit, int textsize, + int units, wxBoxSizer * BoxSizer, int framelen, + int internal_unit) +{ + m_Units = units; + m_Internal_Unit = internal_unit; + m_Title = NULL; + // Limitation de la taille du texte a de valeurs raisonnables + if ( textsize < 10 ) textsize = 10; + if ( textsize > 3000 ) textsize = 3000; + + m_Title = new wxStaticText(parent, -1, Title); + BoxSizer->Add(m_Title, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_FrameText = new wxTextCtrl(parent, -1, TextToEdit); + BoxSizer->Add(m_FrameText, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + if ( ! Title.IsEmpty()) + { + wxString msg; msg = _("Size") + ReturnUnitSymbol(m_Units); + wxStaticText * text = new wxStaticText(parent, -1, msg); + BoxSizer->Add(text, 0, wxGROW|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + } + + wxString value; + value.Printf(( m_Internal_Unit > 1000 ) ? wxT("%.4f") : wxT("%.3f"), + To_User_Unit(m_Units, textsize, m_Internal_Unit) ); + m_FrameSize = new wxTextCtrl(parent, -1, value, wxDefaultPosition ,wxSize(70,-1)); + BoxSizer->Add(m_FrameSize, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); +} + + +WinEDA_GraphicTextCtrl::~WinEDA_GraphicTextCtrl(void) +{ + delete m_FrameText; + delete m_Title; +} + +void WinEDA_GraphicTextCtrl::SetTitle(const wxString & title) +{ + m_Title->SetLabel(title); +} + +void WinEDA_GraphicTextCtrl::SetValue(const wxString & value) +{ + m_FrameText->SetValue(value); +} + +void WinEDA_GraphicTextCtrl::SetValue(int value) +{ + wxString msg; + msg.Printf(( m_Internal_Unit > 1000 ) ? wxT("%.4f") : wxT("%.3f"), + To_User_Unit(m_Units, value, m_Internal_Unit) ); + m_FrameSize->SetValue(msg); +} + + +wxString WinEDA_GraphicTextCtrl::GetText(void) +{ +wxString text = m_FrameText->GetValue(); + return text; +} + +int WinEDA_GraphicTextCtrl::GetTextSize(void) +{ +int textsize; +double dtmp; + + m_FrameSize->GetValue().ToDouble(&dtmp); + textsize = (int)From_User_Unit( m_Units, + dtmp, + m_Internal_Unit); + // Limitation de la taille du texte a de valeurs raisonnables + if ( textsize < 10 ) textsize = 10; + if ( textsize > 3000 ) textsize = 3000; + return textsize; +} + +void WinEDA_GraphicTextCtrl::Enable(bool state) +{ + m_FrameText->Enable(state); +} + + + +/*****************************************************************/ +/* Classe pour afficher et editer une coordonnée en INCHES ou MM */ +/*****************************************************************/ + +WinEDA_PositionCtrl::WinEDA_PositionCtrl(wxWindow *parent, const wxString & title, + const wxPoint & pos_to_edit, int units, wxBoxSizer * BoxSizer, + int internal_unit ) +{ +wxString text; + + m_Units = units; + m_Internal_Unit = internal_unit; + if ( title.IsEmpty() ) text = _("Pos "); + else text = title; + text += _("X") + ReturnUnitSymbol(m_Units); + m_TextX = new wxStaticText(parent, -1, text ); + BoxSizer->Add(m_TextX, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + m_FramePosX = new wxTextCtrl(parent, -1, wxEmptyString, wxDefaultPosition ); + BoxSizer->Add(m_FramePosX, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + + if ( title.IsEmpty() ) text = _("Pos "); + else text = title; + text += _("Y") + ReturnUnitSymbol(m_Units); + m_TextY = new wxStaticText(parent, -1, text ); + BoxSizer->Add(m_TextY, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_FramePosY = new wxTextCtrl(parent, -1, wxEmptyString ); + BoxSizer->Add(m_FramePosY, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + SetValue(pos_to_edit.x, pos_to_edit.y); +} + + +WinEDA_PositionCtrl::~WinEDA_PositionCtrl(void) +{ + delete m_TextX; + delete m_TextY; + delete m_FramePosX; + delete m_FramePosY; +} + +/******************************************/ +wxPoint WinEDA_PositionCtrl::GetValue(void) +/******************************************/ +/* Retourne (en unites internes) les coordonnes entrees (en unites utilisateur) +*/ +{ +wxPoint coord; +double value = 0; + + m_FramePosX->GetValue().ToDouble(&value); + coord.x = From_User_Unit(m_Units, value, m_Internal_Unit); + m_FramePosY->GetValue().ToDouble(&value); + coord.y = From_User_Unit(m_Units, value, m_Internal_Unit); + + return coord; +} + + +/************************************************************/ +void WinEDA_PositionCtrl::Enable(bool x_win_on, bool y_win_on) +/************************************************************/ +{ + m_FramePosX->Enable(x_win_on); + m_FramePosY->Enable(y_win_on); +} + +/***********************************************************/ +void WinEDA_PositionCtrl::SetValue(int x_value, int y_value) +/***********************************************************/ +{ +wxString msg; + + m_Pos_To_Edit.x = x_value; + m_Pos_To_Edit.y = y_value; + + msg = ReturnStringFromValue(m_Units, m_Pos_To_Edit.x, m_Internal_Unit); + m_FramePosX->Clear(); + m_FramePosX->SetValue(msg); + + msg = ReturnStringFromValue(m_Units, m_Pos_To_Edit.y, m_Internal_Unit); + m_FramePosY->Clear(); + m_FramePosY->SetValue(msg); +} + + /*******************/ + /* WinEDA_SizeCtrl */ + /*******************/ +WinEDA_SizeCtrl::WinEDA_SizeCtrl(wxWindow *parent, const wxString & title, + const wxSize & size_to_edit, + int units, wxBoxSizer * BoxSizer, + int internal_unit): + WinEDA_PositionCtrl(parent, title, + wxPoint(size_to_edit.x, size_to_edit.y), + units, BoxSizer, internal_unit) +{ +} + +/*************************************/ +wxSize WinEDA_SizeCtrl::GetValue(void) +/*************************************/ +{ +wxPoint pos = WinEDA_PositionCtrl::GetValue(); +wxSize size; + size.x = pos.x; + size.y = pos.y; + return size; +} + + +/***********************************************************************/ +/* Classe pour afficher et editer une dimension en INCHES MM ou autres*/ +/***********************************************************************/ + +/* Unites: + si units = 0 : unite = inch + si units = 1 : unite = mm + si units >1 : affichage direct +*/ +WinEDA_ValueCtrl::WinEDA_ValueCtrl(wxWindow *parent, const wxString & title, + int value, int units, wxBoxSizer *BoxSizer, + int internal_unit ) +{ +wxString label = title; + + m_Units = units; + m_Internal_Unit = internal_unit; + m_Value = value; + label += ReturnUnitSymbol(m_Units); + + m_Text = new wxStaticText(parent, -1, label); + BoxSizer->Add(m_Text, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + +wxString stringvalue = ReturnStringFromValue(m_Units, m_Value,m_Internal_Unit); + m_ValueCtrl = new wxTextCtrl(parent, -1, stringvalue); + BoxSizer->Add(m_ValueCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5); +} + +WinEDA_ValueCtrl::~WinEDA_ValueCtrl(void) +{ + delete m_ValueCtrl; + delete m_Text; +} + +/***********************************/ +int WinEDA_ValueCtrl::GetValue(void) +/***********************************/ +{ +int coord; +wxString txtvalue = m_ValueCtrl->GetValue(); + + coord = ReturnValueFromString(m_Units, txtvalue, m_Internal_Unit); + return coord; +} + +/********************************************/ +void WinEDA_ValueCtrl::SetValue(int new_value) +/********************************************/ +{ +wxString buffer; + m_Value = new_value; + + buffer = ReturnStringFromValue(m_Units, m_Value, m_Internal_Unit); + m_ValueCtrl->SetValue(buffer); +} + +/* Active ou desactive la frame: */ +void WinEDA_ValueCtrl::Enable(bool enbl) +{ + m_ValueCtrl->Enable(enbl); + m_Text->Enable(enbl); +} + +/***************************************************************/ +/* Classe pour afficher et editer une valeur en double flottant*/ +/***************************************************************/ +WinEDA_DFloatValueCtrl::WinEDA_DFloatValueCtrl(wxWindow *parent, const wxString & title, + double value, wxBoxSizer * BoxSizer ) +{ +wxString buffer; +wxString label = title; + + m_Value = value; + + m_Text = new wxStaticText(parent, -1, label ); + BoxSizer->Add(m_Text, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); + + buffer.Printf(wxT("%lf"), m_Value); + m_ValueCtrl = new wxTextCtrl(parent, -1, buffer ); + BoxSizer->Add(m_ValueCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); +} + +WinEDA_DFloatValueCtrl::~WinEDA_DFloatValueCtrl(void) +{ + delete m_ValueCtrl; + delete m_Text; +} + +double WinEDA_DFloatValueCtrl::GetValue(void) +{ +double coord = 0; + + m_ValueCtrl->GetValue().ToDouble(&coord); + return coord; +} + +void WinEDA_DFloatValueCtrl::SetValue(double new_value) +{ +wxString buffer; + m_Value = new_value; + + buffer.Printf( wxT("%lf"), m_Value); + m_ValueCtrl->SetValue(buffer); +} + +/* Active ou desactive la frame: */ +void WinEDA_DFloatValueCtrl::Enable(bool enbl) +{ + m_ValueCtrl->Enable(enbl); + m_Text->Enable(enbl); +} + diff --git a/contrib_makefiles.txt b/contrib_makefiles.txt new file mode 100644 index 0000000000..6a763954cb --- /dev/null +++ b/contrib_makefiles.txt @@ -0,0 +1,309 @@ +libs.dynamic + +CC = `wx-config --cc` +# Note: at least on Debian using gcc gives a smaller binary than using: +# `wx-config --ld` +LD = gcc + +SRCSUFF = .cpp +OBJSUFF = .o +FINAL = 1 + +WXPATH = `wx-config --prefix`/lib +PREFIX_WX_LIBS = `wx-config --basename` +SUFFIX_WX_LIBGL = _gl-$(LIBVERSION) + +LIBSTDC = -lstdc++ +LIBVERSION=`wx-config --release` +WXSYSLIB= `wx-config --libs` + +# attention à l'ordre des libairies +LIBS = -L/usr/local/lib -L/usr/X11R6/lib\ + $(EXTRALIBS) $(WXSYSLIB)\ + $(LIBSTDC) + +LIBS3D = -l$(PREFIX_WX_LIBS)$(SUFFIX_WX_LIBGL) -lGL -lGLU + +# Sub-projects +KICAD_SUBDIRS = common 3d-viewer eeschema pcbnew cvpcb kicad gerbview wxhtml +# How to invoke make +MAKE := $(MAKE) -f makefile.gtk +# File with the libraries definitions +LIBSDEF = libs.dynamic +# Prefix, can be from command line +ifneq ($(strip $(prefix)),) + IPREFIX=$(prefix) +else + IPREFIX=/usr/local/kicad/linux +endif +# Install tool, can be from command line +ifeq ($(INSTALL),) + INSTALL=install +endif +# C Flags, can be from command line +ifeq ($(CFLAGS),) + CFLAGS=-Wall -O2 + #CFLAGS=-Wall -Werror -g3 +endif +CFLAGS:=$(CFLAGS) `wx-config --cxxflags` +# Linker flags (strip) +LDFLAGS = -s +export + +.PHONY: $(KICAD_SUBDIRS) + +all: $(KICAD_SUBDIRS) + +common: + cd $@ ; $(MAKE) + +3d-viewer: + cd $@ ; $(MAKE) + +eeschema: + cd $@ ; $(MAKE) + +pcbnew: + cd $@ ; $(MAKE) + +cvpcb: + cd $@ ; $(MAKE) + +kicad: + cd $@ ; $(MAKE) + +gerbview: + cd $@ ; $(MAKE) + +wxhtml: + cd $@ ; $(MAKE) + +install: + @for d in $(KICAD_SUBDIRS); do (cd $$d && $(MAKE) install); done + +clean: + @for d in $(KICAD_SUBDIRS); do (cd $$d && $(MAKE) clean); done + +3d-viewer/makefile.gtk +## Makefile for 3d-viewer.a ( wxGTK - LINUX ) + +# Compiler flags. +CPPFLAGS = $(CFLAGS) -DPCBNEW -I../pcbnew -I ../include -I../common + +include ../$(LIBSDEF) + +TARGET = 3d-viewer + +all: $(TARGET).a + +include makefile.include + +$(TARGET).a: $(OBJECTS3D) makefile.gtk makefile.include + rm -f $@ + ar -rv $@ $(OBJECTS3D) + ranlib $@ + +clean: + -rm *.o *.a *~ .*~ core *.bak *.exe *.obj 2> /dev/null + +# No install target + +## Makefile for common.a + +# Compiler flags. +CPPFLAGS = $(CFLAGS) -I./ -I../include +EDACPPFLAGS = $(CPPFLAGS) + +all: common.a + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + + +common.a: $(OBJECTS) makefile.gtk makefile.include + rm -f $@ + ar -rv $@ $(OBJECTS) + ranlib $@ + + +clean: + -rm *.o *.a *~ .*~ core *.bak *.exe *.obj 2> /dev/null + +# No install target + +# File: makefile + +# Compiler flags. +CPPFLAGS = $(CFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + +include ../$(LIBSDEF) + + +TARGET = cvpcb + +all: $(TARGET) + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + + +$(TARGET): $(OBJECTS) makefile.gtk makefile.include $(EXTRALIBS) ../$(LIBSDEF) $(LIBVIEWER3D) + $(LD) $(OBJECTS) $(LDFLAGS) $(LIBS) $(LIBVIEWER3D) $(LIBS3D) -o $(TARGET) + +install: + $(INSTALL) -d -m 0755 $(IPREFIX) + $(INSTALL) -m 0755 $(TARGET) $(IPREFIX) + +clean: + -rm *.o *.a *~ .*~ core *.bak *.exe *.obj $(TARGET) 2> /dev/null + +## Makefile for eeschema + +include ../$(LIBSDEF) + +TARGET = eeschema + +CPPFLAGS = $(CFLAGS) + +all: $(TARGET) + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + +$(TARGET): $(OBJECTS) makefile.gtk makefile.include $(EXTRALIBS) ../$(LIBSDEF) + $(LD) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $(TARGET) + +install: + $(INSTALL) -d -m 0755 $(IPREFIX) + $(INSTALL) -m 0755 $(TARGET) $(IPREFIX) + +clean: + -rm *.o *.a *~ .*~ core *.bak *.exe *.obj $(TARGET) 2> /dev/null + + +## Makefile for GERBVIEW et wxGTK + +# Compiler flags. +CPPFLAGS = $(CFLAGS) + +EXTRALIBS = ../common/common.a +include ../$(LIBSDEF) + + +TARGET = gerbview + +all: $(TARGET) + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + + +$(TARGET): $(OBJECTS) makefile.gtk makefile.include $(EXTRALIBS) ../$(LIBSDEF) + $(LD) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $(TARGET) + +install: + $(INSTALL) -d -m 0755 $(IPREFIX) + $(INSTALL) -m 0755 $(TARGET) $(IPREFIX) + +clean: + -rm *.o *.a *~ .*~ core *.bak *.exe *.obj $(TARGET) 2> /dev/null + +# File: makefile for kicad, wxGTK + +# Compiler flags. +CPPFLAGS = $(CFLAGS) + +include ../$(LIBSDEF) + +TARGET = kicad + +all: $(TARGET) + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + + +$(TARGET): $(OBJECTS) makefile.gtk $(EXTRALIBS) ../$(LIBSDEF) + $(LD) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $(TARGET) + +install: + $(INSTALL) -d -m 0755 $(IPREFIX) + $(INSTALL) -m 0755 $(TARGET) $(IPREFIX) + +clean: + -rm *.o *.a *~ .*~ core *.bak *.exe *.obj $(TARGET) 2> /dev/null + +## Makefile for PCBNEW et wxGTK + +# Compiler flags. +CPPFLAGS = $(CFLAGS) + +include ../$(LIBSDEF) + +TARGET = pcbnew + +all: $(TARGET) + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + +$(TARGET): $(OBJECTS) makefile.gtk makefile.include $(LIBVIEWER3D) $(EXTRALIBS) ../$(LIBSDEF) + $(LD) $(LDFLAGS) $(OBJECTS) $(LIBS) $(LIBVIEWER3D) $(LIBS3D)\ + -o $(TARGET) + +install: + $(INSTALL) -d -m 0755 $(IPREFIX) + $(INSTALL) -m 0755 $(TARGET) $(IPREFIX) + +clean: + -rm *.o *.a *~ .*~ core *.bak *.exe *.obj $(TARGET) 2> /dev/null + +######################################################################## +######################################################################## + +# Compiler flags. +CPPFLAGS = $(CFLAGS) -I./ -I../include -I../common + +EXTRALIBS = + +include ../$(LIBSDEF) + +TARGET = wxhtml + +OBJDIR = +OBJSUFF = o + +.SUFFIXES: .cpp .h .o .cc +.cpp.o : + $(CC) -c $< -o $(<:.cpp=.o) $(CPPFLAGS) + + +DEPEND = + + +OBJECTS = $(TARGET).o helpfrm.o + + +$(TARGET): $(OBJECTS) makefile.gtk ../common/common.a ../$(LIBSDEF) + $(LD) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $(TARGET) + +install: + $(INSTALL) -d -m 0755 $(IPREFIX) + $(INSTALL) -m 0755 $(TARGET) $(IPREFIX) + +clean: + -rm *.o *.a *~ .*~ core *.bak *.exe *.obj $(TARGET) 2> /dev/null + diff --git a/cvpcb/affiche.cpp b/cvpcb/affiche.cpp new file mode 100644 index 0000000000..dfb3491d25 --- /dev/null +++ b/cvpcb/affiche.cpp @@ -0,0 +1,19 @@ + /**********************************************************/ + /* Routines d'affichage de parametres et caracteristiques */ + /**********************************************************/ + + /* Fichier AFFICHE.CC */ + + +#include "fctsys.h" + +#include "wxstruct.h" +#include "menu.h" +#include "pcbnew.h" +#include "cvpcb.h" + +#include "3d_struct.h" + +#include "protos.h" + + diff --git a/cvpcb/autosel.cpp b/cvpcb/autosel.cpp new file mode 100644 index 0000000000..a8e3597924 --- /dev/null +++ b/cvpcb/autosel.cpp @@ -0,0 +1,170 @@ + /**********************/ + /* CVPCB: autosel.cpp */ + /**********************/ + +/* Routines de selection automatique des modules */ + +#include "fctsys.h" + +#include "common.h" +#include "cvpcb.h" + +#include "protos.h" + +#define QUOTE '\'' + +class AUTOMODULE +{ +public: + int m_Type; + AUTOMODULE * Pnext; + wxString m_Name; + wxString m_LibName; + wxString m_Library; + + AUTOMODULE(void) { m_Type = 0; Pnext = NULL; } +} ; + + +/* routines locales : */ +static int auto_select(WinEDA_CvpcbFrame * frame, STORECMP * Cmp, AUTOMODULE * BaseListeMod); +static void auto_associe(WinEDA_CvpcbFrame * frame); + + + /*************************************************************/ +void WinEDA_CvpcbFrame::AssocieModule(wxCommandEvent& event) +/*************************************************************/ +/* Fonction liee au boutton "Auto" + Lance l'association automatique modules/composants +*/ +{ + auto_associe(this); +} + +/**************************************************/ +static void auto_associe(WinEDA_CvpcbFrame * frame) +/**************************************************/ +{ +unsigned ii, j, k; +wxString EquivFileName, msg; +char Line[1024]; +FILE *fichierstf ; /* sert en lecture des differents fichiers *.STF */ +AUTOMODULE * ItemModule,* NextMod; +AUTOMODULE * BaseListeMod = NULL; +STORECMP * Componant; + +int nb_correspondances = 0; + + if( nbcomp <= 0 ) return; + + /* recherche des equivalences a travers les fichiers possibles */ + for( ii= 0 ; ii < g_ListName_Equ.GetCount(); ii++) + { + /* Calcul du nom complet avec son chemin */ + EquivFileName = MakeFileName(g_RealLibDirBuffer,g_ListName_Equ[ii],g_EquivExtBuffer); + + if ( (fichierstf = wxFopen(EquivFileName, wxT("rt"))) == 0) + { + msg.Printf( _("Library: <%s> not found"),EquivFileName.GetData()); + DisplayError(frame, msg,10); + continue ; + } + + /* lecture fichier n */ + while ( fgets(Line,79,fichierstf) != 0 ) + { + /* elimination des lignes vides */ + for (j = 0 ; j < 40 ; j++ ) + { + if (Line[j] == 0 ) goto fin_de_while ; + if (Line[j] == QUOTE ) break ; + } + + ItemModule = new AUTOMODULE(); + ItemModule->Pnext = BaseListeMod; + BaseListeMod = ItemModule; + + /* stockage du composant ( 'namecmp' 'namelib') + name et namelib */ + for ( j++ ; j < 40 ; j++, k++) + { + if ( Line[j] == QUOTE) break ; + ItemModule->m_Name.Append(Line[j]); + } + j++ ; + for ( ; j < 80 ; ) if (Line[j++] == QUOTE) break ; + for (; ; j++) + { + if (Line[j] == QUOTE) break ; + ItemModule->m_LibName.Append(Line[j]); + } + nb_correspondances++ ; + fin_de_while:; + } + fclose(fichierstf) ; + + /* Affichage Statistiques */ + msg.Printf(_("%d equivalences"),nb_correspondances); + frame->SetStatusText(msg, 0); + } + + Componant = g_BaseListeCmp; + for ( ii = 0; Componant != NULL; Componant = Componant->Pnext, ii++ ) + { + frame->m_ListCmp->SetSelection(ii,TRUE); + if( Componant->m_Module.IsEmpty() ) + auto_select(frame, Componant, BaseListeMod); + } + + /* Liberation memoire */ + for( ItemModule = BaseListeMod; ItemModule != NULL; ItemModule = NextMod) + { + NextMod = ItemModule->Pnext; delete ItemModule; + } + BaseListeMod = NULL; +} + + +/****************************************************************/ +static int auto_select(WinEDA_CvpcbFrame * frame, STORECMP * Cmp, + AUTOMODULE * BaseListeMod) +/****************************************************************/ + +/* associe automatiquement composant et Module + Retourne; + 0 si OK + 1 si module specifie non trouve en liste librairie + 2 si pas de module specifie dans la liste des equivalences +*/ +{ +AUTOMODULE * ItemModule; +STOREMOD * Module; +wxString msg; + + /* examen de la liste des correspondances */ + ItemModule = BaseListeMod; + for ( ; ItemModule != NULL; ItemModule = ItemModule->Pnext ) + { + if ( ItemModule->m_Name.CmpNoCase(Cmp->m_Valeur) != 0) continue; + + /* Correspondance trouvee, recherche nom module dans la liste des + modules disponibles en librairie */ + Module= g_BaseListePkg; + for ( ;Module != NULL; Module = Module->Pnext ) + { + + if( ItemModule->m_LibName.CmpNoCase(Module->m_Module) == 0 ) + { /* empreinte trouv‚e */ + frame->SetNewPkg(Module->m_Module); + return(0); + } + } + msg.Printf( + _("Component %s: Footprint %s not found in libraries"), + Cmp->m_Valeur.GetData(), ItemModule->m_LibName.GetData()); + DisplayError(frame, msg, 10); + return( 2 ); + } + return(1); +} + diff --git a/cvpcb/bitmaps/delete_association.xpm b/cvpcb/bitmaps/delete_association.xpm new file mode 100644 index 0000000000..45a4c16742 --- /dev/null +++ b/cvpcb/bitmaps/delete_association.xpm @@ -0,0 +1,167 @@ +/* XPM */ +static char * delete_association_xpm[] = { +"16 16 148 2", +" c None", +". c #160A00", +"+ c #FF7800", +"@ c #000000", +"# c #231000", +"$ c #E1DFDE", +"% c #44260C", +"& c #E86D00", +"* c #FFFFFF", +"= c #C35B00", +"- c #FAF6F3", +"; c #A38F7C", +"> c #C7B4A5", +", c #FDBD85", +"' c #FFBF87", +") c #FFF3EC", +"! c #FEE6D6", +"~ c #D8BDA8", +"{ c #C7874F", +"] c #F9B880", +"^ c #FFF5EF", +"/ c #FFE8D8", +"( c #FFDBC2", +"_ c #FFCEAB", +": c #F4C8A9", +"< c #D6B69C", +"[ c #F6EDE6", +"} c #F3F3F3", +"| c #878787", +"1 c #FFEADC", +"2 c #FFDDC5", +"3 c #EFC3A4", +"4 c #B68B6D", +"5 c #0E0E0E", +"6 c #424242", +"7 c #4A4A4A", +"8 c #3E3E3E", +"9 c #2C2C2C", +"0 c #010101", +"a c #C1C1C1", +"b c #222222", +"c c #FFDFC8", +"d c #C7A38B", +"e c #848270", +"f c #EFECD6", +"g c #F1F0E7", +"h c #EDECE3", +"i c #C6C5B9", +"j c #535246", +"k c #C3A28B", +"l c #101010", +"m c #C1BFA4", +"n c #C0BEA3", +"o c #7A7966", +"p c #48473F", +"q c #272724", +"r c #36352E", +"s c #868472", +"t c #9F9D87", +"u c #A2A089", +"v c #A3A18A", +"w c #2B2B2B", +"x c #D2D0BB", +"y c #DBD9C2", +"z c #E1DFCD", +"A c #B8B6A0", +"B c #64625A", +"C c #393836", +"D c #3C3C33", +"E c #616053", +"F c #999782", +"G c #B6B49A", +"H c #B1B096", +"I c #E7E3D1", +"J c #F3F0E7", +"K c #F1F0E2", +"L c #E9E8D8", +"M c #E4E1D1", +"N c #D4D1BD", +"O c #C2C0A6", +"P c #AEAC93", +"Q c #BFBDA3", +"R c #C5C3AB", +"S c #B7B59B", +"T c #797766", +"U c #010100", +"V c #898874", +"W c #F0ECD0", +"X c #FAF7E7", +"Y c #F8F4EB", +"Z c #F7F6ED", +"` c #F7F6EB", +" . c #F4F2E5", +".. c #EBE9D8", +"+. c #DDDBC9", +"@. c #9C9987", +"#. c #636153", +"$. c #58574A", +"%. c #7E5234", +"&. c #525145", +"*. c #737064", +"=. c #9E9C90", +"-. c #E3E0C7", +";. c #E8E4CE", +">. c #E1DFCA", +",. c #D0D0CA", +"'. c #8D8C7F", +"). c #767463", +"!. c #686657", +"~. c #434137", +"{. c #292822", +"]. c #E1A074", +"^. c #1E1E1A", +"/. c #33332F", +"(. c #4A4843", +"_. c #686661", +":. c #706F66", +"<. c #6B6A63", +"[. c #6D6B5C", +"}. c #57564A", +"|. c #393830", +"1. c #171615", +"2. c #1A1915", +"3. c #1E1D18", +"4. c #2A2922", +"5. c #9E9E93", +"6. c #4C4C3F", +"7. c #36352F", +"8. c #2A2925", +"9. c #2F2E29", +"0. c #0E0E0C", +"a. c #0A0A08", +"b. c #100F0C", +"c. c #3E3D37", +"d. c #34332A", +"e. c #23231E", +"f. c #2B2A23", +"g. c #A3A297", +"h. c #B5B4AC", +"i. c #716F66", +"j. c #A09F90", +"k. c #747262", +"l. c #3F3F34", +"m. c #68685A", +"n. c #39382E", +"o. c #69685E", +"p. c #3F3E33", +"q. c #25251F", +" . + + + ", +" @ # + + + ", +" @ $ % & * = + * + @ @ ", +" @ * - ; > , ' ' * * + + + * @ ", +" @ * ) ! ~ { ] ' * * + + + * @ ", +"@ @ ^ / ( _ : < [ * * * * } | @ ", +" @ 1 2 3 4 5 6 7 8 9 0 a b ", +" @ c d 0 0 e f g h i j 0 @ ", +" @ k l m n o p q r s t u v @ ", +" @ w x y z A B C D E F G H u @ ", +"@ @ 0 I J K L M N O P Q R S T @ ", +" @ U V W X Y Z ` ...+.@.#.$.@ ", +" @ %.&.*.=.-.;.>.,.'.).!.~.{.@ ", +" @ ].^./.(._.:.<.[.}.|.1.2.3.@ ", +" @ # 4.5.6.7.8.9.0.a.b.c.d.e. ", +" . f.g.h.i.j.k.l.m.n.o.p.q. "}; diff --git a/cvpcb/bitmaps/module_filtered_list.xpm b/cvpcb/bitmaps/module_filtered_list.xpm new file mode 100644 index 0000000000..f146c6f111 --- /dev/null +++ b/cvpcb/bitmaps/module_filtered_list.xpm @@ -0,0 +1,24 @@ +/* XPM */ +char * module_filtered_list_xpm[] = { +"16 15 5 1", +"X c #808080", +" c None", +"o c #808000", +"c c Gray", +"D c Red", +" XXX XXX ", +" cooX XX Xooc ", +" cooX Xooc ", +" XDDDDDDX ", +" cooX Xooc ", +" cooXDDDDD Xooc ", +" X X ", +" cooXDDDD Xooc ", +" cooX Xooc ", +" XDDD X ", +" cooX Xooc ", +" cooXDD Xooc ", +" X X ", +" cooXD Xooc ", +" XXXXXXXX " +}; diff --git a/cvpcb/bitmaps/module_full_list.xpm b/cvpcb/bitmaps/module_full_list.xpm new file mode 100644 index 0000000000..84a5b74083 --- /dev/null +++ b/cvpcb/bitmaps/module_full_list.xpm @@ -0,0 +1,25 @@ +/* XPM */ +char * module_full_list_xpm[] = { +"16 15 5 1", +"X c #808080", +" c None", +"o c #808000", +"c c Gray", +"D c Red", +" XXX XXX ", +" cooX XX Xooc ", +" cooX Xooc ", +" XDDDDDDX ", +" cooX Xooc ", +" cooXDDDDDDXooc ", +" X X ", +" cooXDDDDDDXooc ", +" cooX Xooc ", +" XDDDDDDX ", +" cooX Xooc ", +" cooXDDDDDDXooc ", +" X X ", +" cooXDDDDDDXooc ", +" XXXXXXXX " +}; + diff --git a/cvpcb/cfg.cpp b/cvpcb/cfg.cpp new file mode 100644 index 0000000000..84e2706254 --- /dev/null +++ b/cvpcb/cfg.cpp @@ -0,0 +1,85 @@ + /***************************************/ + /** cfg.cpp : configuration de CVPCB **/ + /***************************************/ + +/* lit ou met a jour la configuration de CVPCB */ + +#include "fctsys.h" + +#include "wxstruct.h" +#include "common.h" +#include "cvpcb.h" +#include "protos.h" + +#include "cfg.h" + +/* Routines Locales */ +/**/ + + +/**************************************************/ +void Read_Config( const wxString & FileName ) +/**************************************************/ +/* lit la configuration + 1 - lit cvpcb.cnf + 2 - si non trouve lit /cvpcb.cnf + 3 - si non trouve: init des variables aux valeurs par defaut + +Remarque: + le chemin de l'executable cvpcb.exe doit etre dans BinDir +*/ +{ +wxString FullFileName = FileName ; + + /* Init des valeurs par defaut */ + g_LibName_List.Clear(); + g_ListName_Equ.Clear(); + + EDA_Appl->ReadProjectConfig(FullFileName, + GROUP, ParamCfgList, FALSE); + + if ( PkgInExtBuffer.IsEmpty() ) PkgInExtBuffer = wxT(".pkg"); + if ( NetInExtBuffer.IsEmpty() ) NetInExtBuffer = wxT(".net"), + + /* Inits autres variables */ + SetRealLibraryPath( wxT("modules")); +} + + +/************************************************************/ +void WinEDA_CvpcbFrame::Update_Config(wxCommandEvent& event) +/************************************************************/ +/* fonction relai d'appel a Save_Config, + la vraie fonction de sauvegarde de la config +*/ +{ + Save_Config(this); +} + +/************************************/ +void Save_Config(wxWindow * parent) +/************************************/ +/* enregistrement de la config */ +{ +wxString path, FullFileName; +wxString mask( wxT("*")); + + FullFileName = FFileName; + ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); + + path = wxGetCwd(); + FullFileName = EDA_FileSelector(_("Save config file"), + path, /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + g_Prj_Config_Filename_ext, /* extension par defaut */ + mask, /* Masque d'affichage */ + parent, + wxFD_SAVE, + TRUE + ); + if ( FullFileName.IsEmpty()) return; + + /* ecriture de la configuration */ + EDA_Appl->WriteProjectConfig(FullFileName, GROUP, ParamCfgList); +} + diff --git a/cvpcb/cfg.h b/cvpcb/cfg.h new file mode 100644 index 0000000000..27585fb848 --- /dev/null +++ b/cvpcb/cfg.h @@ -0,0 +1,158 @@ + /*******************************************************/ + /** cfg.h : configuration: definition des structures **/ + /*******************************************************/ + +#ifndef eda_global +#define eda_global extern +#endif + +#define INSETUP TRUE + +#define GROUP wxT("/cvpcb") +#define GROUPCOMMON wxT("/common") +#define GROUPLIB wxT("/pcbnew/libraries") +#define GROUPEQU wxT("/cvpcb/libraries") + +/* Liste des parametres */ + +static PARAM_CFG_BASE CommandCfg +( + GROUPLIB, /* identification de groupe */ + PARAM_COMMAND_ERASE /* type */ +); + +static PARAM_CFG_LIBNAME_LIST LibNameBufCfg +( + wxT("LibName"), /* identification */ + &g_LibName_List, /* Adresse du parametre */ + GROUPLIB +); + +static PARAM_CFG_LIBNAME_LIST EquivNameBufCfg +( + wxT("EquName"), /* identification */ + &g_ListName_Equ, /* Adresse du parametre */ + GROUPEQU +); + + +static PARAM_CFG_INT NetInTypeCfg // format Netliste ( 0= auto 1=ORCADPCB2 3,4=VIEWLOGIC) +( + wxT("NetITyp"), /* identification */ + &g_NetType, /* Adresse du parametre */ + 0, 4, /* Valeurs extremes */ + 1 /* Valeur par defaut */ +); + +static PARAM_CFG_WXSTRING NetInExtBufCfg +( + wxT("NetIExt"), /* identification */ + &NetInExtBuffer +); + +static PARAM_CFG_WXSTRING PkgInExtBufCfg +( + wxT("PkgIExt"), /* identification */ + &PkgInExtBuffer /* Adresse du parametre */ +); + +static PARAM_CFG_WXSTRING NetDirBufCfg +( + wxT("NetDir"), /* identification */ + &g_UserNetDirBuffer, /* Adresse du parametre */ + GROUPCOMMON +); + +static PARAM_CFG_WXSTRING UserLibDirBufCfg +( + wxT("LibDir"), /* identification */ + &g_UserLibDirBuffer, /* Adresse du parametre */ + GROUPLIB +); + +static PARAM_CFG_INT NetTypeCfg +( + wxT("NetType"), /* identification */ + &g_NetType, /* Adresse du parametre */ + 0, /* Valeur par defaut */ + 0, 1 /* Valeurs extremes */ +); + +static PARAM_CFG_BOOL DisplayPadFillCfg +( + INSETUP, + wxT("DiPadFi"), /* identification */ + &DisplayOpt.DisplayPadFill, /* Adresse du parametre */ + TRUE /* Valeur par defaut */ +); + +static PARAM_CFG_BOOL DisplayPadNumCfg +( + INSETUP, + wxT("DiPadNu"), /* identification */ + &DisplayOpt.DisplayPadNum, /* Adresse du parametre */ + TRUE /* Valeur par defaut */ +); + +static PARAM_CFG_BOOL DisplayPadNoConnCfg +( + INSETUP, + wxT("DiPadNC"), /* identification */ + &DisplayOpt.DisplayPadNoConn, /* Adresse du parametre */ + FALSE /* Valeur par defaut */ +); + +static PARAM_CFG_BOOL DisplayPadIsolCfg +( + INSETUP, + wxT("DiPadMg"), /* identification */ + &DisplayOpt.DisplayPadIsol, /* Adresse du parametre */ + FALSE /* Valeur par defaut */ +); + +static PARAM_CFG_INT DisplayModEdgeCfg +( + INSETUP, + wxT("DiModEd"), /* identification */ + &DisplayOpt.DisplayModEdge, /* Adresse du parametre */ + 1, /* Valeur par defaut */ + 0, 1 /* Valeurs extremes */ +); + +static PARAM_CFG_INT DisplayModTextCfg +( + INSETUP, + wxT("DiModTx"), /* identification */ + &DisplayOpt.DisplayModText, /* Adresse du parametre */ + 1, /* Valeur par defaut */ + 0, 1 /* Valeurs extremes */ +); + +static PARAM_CFG_BOOL DisplayPcbTrackFillCfg +( + INSETUP, + wxT("DiPcbTF"), /* identification */ + &DisplayOpt.DisplayPcbTrackFill, /* Adresse du parametre */ + TRUE /* Valeur par defaut */ +); + +static PARAM_CFG_BASE * ParamCfgList[] = +{ + & CommandCfg, + & NetInTypeCfg, + & NetInExtBufCfg, + & PkgInExtBufCfg, + & NetDirBufCfg, + & UserLibDirBufCfg, + & LibNameBufCfg, + & EquivNameBufCfg, + & NetTypeCfg, + & DisplayPadFillCfg, + & DisplayPadNumCfg, + & DisplayPadNoConnCfg, + & DisplayPadIsolCfg, + & DisplayModEdgeCfg, + & DisplayModTextCfg, + & DisplayPcbTrackFillCfg, + NULL +}; diff --git a/cvpcb/class_cvpcb.cpp b/cvpcb/class_cvpcb.cpp new file mode 100644 index 0000000000..25a455a506 --- /dev/null +++ b/cvpcb/class_cvpcb.cpp @@ -0,0 +1,59 @@ +/*******************/ +/* class_cvpcb.cpp */ +/*******************/ + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWindows headers +#ifndef WX_PRECOMP +#include +#endif + +#include "fctsys.h" +#include "common.h" + +#include "cvpcb.h" + +STORECMP::STORECMP(void) +{ + Pnext = Pback = NULL; + m_Type = STRUCT_COMPONENT; + m_Pins = NULL; + m_Num = 0; + m_Multi = 0; +} + +STORECMP::~STORECMP(void) +{ +STOREPIN * Pin, * NextPin; + + for( Pin = m_Pins; Pin != NULL; Pin = NextPin ) + { + NextPin = Pin->Pnext; delete Pin; + } +} + + + +STOREMOD::STOREMOD(void) +{ + Pnext = Pback = NULL; + m_Type = STRUCT_MODULE; + m_Num = 0; +} + + +STOREPIN::STOREPIN(void) +{ + m_Type = STRUCT_PIN; /* Type de la structure */ + Pnext = NULL; /* Chainage avant */ + m_Index = 0; /* variable utilisee selon types de netlistes */ + m_PinType = 0; /* code type electrique ( Entree Sortie Passive..) */ +} + diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp new file mode 100644 index 0000000000..b84bc0844a --- /dev/null +++ b/cvpcb/cvframe.cpp @@ -0,0 +1,523 @@ + /*********************/ + /* File: cvframe.cpp */ + /*********************/ +#include "fctsys.h" +#include "common.h" +#include + +#include "cvpcb.h" +#include "gr_basic.h" +#include "pcbnew.h" + +#include "bitmaps.h" + +#include "protos.h" + +#include "id.h" + +#define FRAME_MIN_SIZE_X 450 +#define FRAME_MIN_SIZE_Y 300 + + /*******************************************************/ + /* Constructeur de WinEDA_CvpcbFrame: la fenetre generale */ + /*******************************************************/ +WinEDA_CvpcbFrame::WinEDA_CvpcbFrame(WinEDA_App *parent, const wxString & title ): + WinEDA_BasicFrame(NULL, CVPCB_FRAME, parent, title, wxDefaultPosition, wxDefaultSize ) +{ + m_FrameName = wxT("CvpcbFrame"); + m_ListCmp = NULL; + m_FootprintList = NULL; + DrawFrame = NULL; + m_FilesMenu = NULL; + m_HToolBar = NULL; + + // Give an icon + #ifdef __WINDOWS__ + SetIcon( wxICON(a_icon_cvpcb)); + #else + SetIcon( wxICON(icon_cvpcb)); + #endif + + SetFont(*g_StdFont); + + SetAutoLayout(TRUE); + + GetSettings(); + if ( m_FrameSize.x < FRAME_MIN_SIZE_X ) m_FrameSize.x = FRAME_MIN_SIZE_X; + if ( m_FrameSize.y < FRAME_MIN_SIZE_Y ) m_FrameSize.y = FRAME_MIN_SIZE_Y; + + // create the status bar +int dims[3] = { -1, -1, 250}; + CreateStatusBar(3); + SetStatusWidths(3,dims); + ReCreateMenuBar(); + ReCreateHToolbar(); + + // Creation des listes de modules disponibles et des composants du schema + // Create child subwindows. + BuildCmpListBox(); + BuildFootprintListBox(); + + /* Creation des contraintes de dimension de la fenetre d'affichage des composants + du schema */ + wxLayoutConstraints * linkpos = new wxLayoutConstraints; + linkpos->top.SameAs(this,wxTop); + linkpos->bottom.SameAs(this,wxBottom); + linkpos->left.SameAs(this,wxLeft); + linkpos->width.PercentOf(this,wxWidth,66); + if ( m_ListCmp ) m_ListCmp->SetConstraints(linkpos); + + /* Creation des contraintes de dimension de la fenetre d'affichage des modules + de la librairie */ + linkpos = new wxLayoutConstraints; + linkpos->top.SameAs(m_ListCmp,wxTop); + linkpos->bottom.SameAs(m_ListCmp,wxBottom); + linkpos->right.SameAs(this,wxRight); + linkpos->left.SameAs(m_ListCmp,wxRight); + if ( m_FootprintList ) m_FootprintList->SetConstraints(linkpos); + + SetSizeHints(FRAME_MIN_SIZE_X,FRAME_MIN_SIZE_Y, -1,-1, -1,-1); // Set minimal size to w,h + SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y); +} + + +/******************************************/ +WinEDA_CvpcbFrame::~WinEDA_CvpcbFrame(void) +/******************************************/ +{ + if( m_Parent->m_EDA_Config ) + { + int state = m_HToolBar->GetToolState(ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST); + m_Parent->m_EDA_Config->Write(wxT(FILTERFOOTPRINTKEY), state); + } +} + +/************************************************/ +void WinEDA_CvpcbFrame::OnSize(wxSizeEvent& event) +/************************************************/ +{ + event.Skip(); +} + +/***************************************************************/ +/* Construction de la table des evenements pour WinEDA_CvpcbFrame */ +/***************************************************************/ + +BEGIN_EVENT_TABLE(WinEDA_CvpcbFrame, wxFrame) + + EVT_MENU_RANGE(ID_LOAD_PROJECT,ID_LOAD_FILE_10, + WinEDA_CvpcbFrame::LoadNetList) + EVT_MENU(ID_SAVE_PROJECT, WinEDA_CvpcbFrame::SaveQuitCvpcb) + EVT_MENU(ID_CVPCB_QUIT, WinEDA_CvpcbFrame::OnQuit) + EVT_MENU(ID_CVPCB_DISPLAY_HELP, WinEDA_CvpcbFrame::GetKicadHelp) + EVT_MENU(ID_CVPCB_DISPLAY_LICENCE, WinEDA_CvpcbFrame::GetKicadAbout) + EVT_MENU(ID_CONFIG_REQ,WinEDA_CvpcbFrame::ConfigCvpcb) + EVT_MENU(ID_CONFIG_SAVE,WinEDA_CvpcbFrame::Update_Config) + + EVT_MENU_RANGE(ID_PREFERENCES_FONT_INFOSCREEN, ID_PREFERENCES_FONT_END, + WinEDA_CvpcbFrame::ProcessFontPreferences) + + EVT_MENU_RANGE(ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, + WinEDA_CvpcbFrame::SetLanguage) + + EVT_TOOL(ID_CVPCB_QUIT, WinEDA_CvpcbFrame::OnQuit) + EVT_TOOL(ID_CVPCB_READ_INPUT_NETLIST, WinEDA_CvpcbFrame::LoadNetList) + EVT_TOOL(ID_CVPCB_SAVEQUITCVPCB, WinEDA_CvpcbFrame::SaveQuitCvpcb) + EVT_TOOL(ID_CVPCB_CREATE_CONFIGWINDOW,WinEDA_CvpcbFrame::ConfigCvpcb) + EVT_TOOL(ID_CVPCB_CREATE_SCREENCMP, WinEDA_CvpcbFrame::DisplayModule) + EVT_TOOL(ID_CVPCB_GOTO_FIRSTNA, WinEDA_CvpcbFrame::ToFirstNA) + EVT_TOOL(ID_CVPCB_GOTO_PREVIOUSNA, WinEDA_CvpcbFrame::ToPreviousNA) + EVT_TOOL(ID_CVPCB_DEL_ASSOCIATIONS, WinEDA_CvpcbFrame::DelAssociations) + EVT_TOOL(ID_CVPCB_AUTO_ASSOCIE, WinEDA_CvpcbFrame::AssocieModule) + EVT_TOOL(ID_CVPCB_CREATE_STUFF_FILE, WinEDA_CvpcbFrame::WriteStuffList) + EVT_TOOL(ID_PCB_DISPLAY_FOOTPRINT_DOC, WinEDA_CvpcbFrame::DisplayDocFile) + EVT_TOOL(ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, WinEDA_CvpcbFrame::OnSelectFilteringFootprint) + EVT_TOOL(ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, WinEDA_CvpcbFrame::OnSelectFilteringFootprint) + + EVT_CHAR_HOOK(WinEDA_CvpcbFrame::OnChar) + EVT_CLOSE(WinEDA_CvpcbFrame::OnCloseWindow) + EVT_SIZE( WinEDA_CvpcbFrame::OnSize) + + EVT_LIST_ITEM_SELECTED (ID_CVPCB_FOOTPRINT_LIST, WinEDA_CvpcbFrame::OnLeftClick) + EVT_LIST_ITEM_ACTIVATED (ID_CVPCB_FOOTPRINT_LIST, WinEDA_CvpcbFrame::OnLeftDClick) + + EVT_LIST_ITEM_SELECTED(ID_CVPCB_COMPONENT_LIST, WinEDA_CvpcbFrame::OnSelectComponent) + +END_EVENT_TABLE() + + /************************************************************/ + /* Fonctions de base de WinEDA_CvpcbFrame: la fenetre generale */ + /************************************************************/ + +/* Sortie de CVPCB */ + +void WinEDA_CvpcbFrame::OnQuit(wxCommandEvent& event) +{ + Close(TRUE); +} + +/**********************************************************/ +void WinEDA_CvpcbFrame::OnCloseWindow(wxCloseEvent & Event) +/**********************************************************/ +{ +int diag; + + if( modified ) + { + unsigned ii; + wxMessageDialog dialog(this, _("Netlist and Cmp list modified, Save before exit ?"), + _("Confirmation"), wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT); + ii = dialog.ShowModal(); + switch ( ii ) + { + case wxID_CANCEL: + Event.Veto(); + return; + + case wxID_NO: + break; + + case wxID_OK: + case wxID_YES: + diag = SaveNetList(wxEmptyString); + if( diag > 0 ) modified = 0; + else if ( diag == 0 ) + { + if( ! IsOK(this, _("Problem when saving files, Exit anyway") ) ) + { + Event.Veto(); return; + } + } + break; + } + } + + // Close the help frame + if ( m_Parent->m_HtmlCtrl ) + { + if ( m_Parent->m_HtmlCtrl->GetFrame() ) // returns NULL if no help frame active + m_Parent->m_HtmlCtrl->GetFrame()->Close(TRUE); + } + + if ( ! NetInNameBuffer.IsEmpty() ) + { + SetLastProject(NetInNameBuffer); + } + + FreeMemoryModules(); + FreeMemoryComponants(); + modified = 0; + + SaveSettings(); + + Destroy(); + return; +} + + +/************************************************/ +void WinEDA_CvpcbFrame::OnChar(wxKeyEvent& event) +/************************************************/ +{ + event.Skip(); +} + + + +/*******************************************************/ +void WinEDA_CvpcbFrame::ToFirstNA(wxCommandEvent& event) +/*******************************************************/ +{ +STORECMP * Composant; +int ii, selection;; + + Composant = g_BaseListeCmp; + selection= m_ListCmp->GetSelection(); + if(selection < 0) selection = 0; + for (ii = 0 ; Composant != NULL; Composant = Composant->Pnext) + { + if( Composant->m_Module.IsEmpty() && (ii > selection) ) + break; + ii++; + } + + if ( Composant == NULL ) + { + wxBell(); ii = selection; + } + + if ( g_BaseListeCmp ) m_ListCmp->SetSelection(ii); +} + +/**********************************************************/ +void WinEDA_CvpcbFrame::ToPreviousNA(wxCommandEvent& event) +/**********************************************************/ +{ +STORECMP * Composant; +int ii, selection; + + Composant = g_BaseListeCmp; + selection = m_ListCmp->GetSelection(); + if(selection < 0) selection = 0; + + for (ii = 0 ; Composant != NULL; Composant = Composant->Pnext) + { + if( ii == selection ) break; + ii ++; + } + + for ( ; Composant != NULL ; Composant = Composant->Pback) + { + if( Composant->m_Module.IsEmpty() && (ii != selection) ) + break; + ii--; + } + + if ( Composant == NULL ) + { + wxBell(); ii = selection; + } + + if ( g_BaseListeCmp ) m_ListCmp->SetSelection(ii); +} + + +/**********************************************************/ +void WinEDA_CvpcbFrame::SaveQuitCvpcb(wxCommandEvent& event) +/**********************************************************/ +{ + if( SaveNetList(wxEmptyString) > 0) + { + modified = 0; + Close(TRUE); + } +} + +/*************************************************************/ +void WinEDA_CvpcbFrame::DelAssociations(wxCommandEvent& event) +/*************************************************************/ +/* Supprime toutes les associations deja faites +*/ +{ +int ii; +STORECMP * Composant; +wxString Line; + + if( IsOK(this, _("Delete selections")) ) + { + Composant = g_BaseListeCmp; + for ( ii = 0; Composant != NULL; Composant = Composant->Pnext, ii++) + { + Composant->m_Module.Empty(); + m_ListCmp->SetSelection(ii); + SetNewPkg(wxEmptyString); + } + m_ListCmp->SetSelection(0); + composants_non_affectes = nbcomp; + } + + Line.Printf( _("Componants: %d (free: %d)"), nbcomp, composants_non_affectes); + SetStatusText(Line,1); +} + + +/***********************************************************/ +void WinEDA_CvpcbFrame::LoadNetList(wxCommandEvent& event) +/***********************************************************/ +/* Fonction liee au boutton "Load" + Lit la netliste +*/ +{ +int id = event.GetId(); +wxString fullfilename; +wxString oldfilename; +bool newfile; + + if ( ! NetInNameBuffer.IsEmpty() ) + { + oldfilename = NetInNameBuffer; + } + + switch ( id ) + { + case ID_LOAD_FILE_1: + case ID_LOAD_FILE_2: + case ID_LOAD_FILE_3: + case ID_LOAD_FILE_4: + case ID_LOAD_FILE_5: + case ID_LOAD_FILE_6: + case ID_LOAD_FILE_7: + case ID_LOAD_FILE_8: + case ID_LOAD_FILE_9: + case ID_LOAD_FILE_10: + id -= ID_LOAD_FILE_1; + fullfilename = GetLastProject(id); + break; + } + newfile = ReadInputNetList(fullfilename); + if (newfile && ! oldfilename.IsEmpty() ) + { + SetLastProject(NetInNameBuffer); + ReCreateMenuBar(); + } +} + + +/***********************************************************/ +void WinEDA_CvpcbFrame::ConfigCvpcb(wxCommandEvent& event) +/***********************************************************/ +/* Fonction liee au boutton "Config" + Affiche le panneau de configuration +*/ +{ + CreateConfigWindow(); +} + +/************************************************************/ +void WinEDA_CvpcbFrame::DisplayModule(wxCommandEvent& event) +/************************************************************/ +/* Fonction liee au boutton "Visu" + Affiche l'ecran de visualisation des modules +*/ +{ + CreateScreenCmp(); + DrawFrame->AdjustScrollBars(); + DrawFrame->Recadre_Trace(FALSE); +} + + +/****************************************************************/ +void WinEDA_CvpcbFrame::AddFontSelectionMenu(wxMenu * main_menu) +/*****************************************************************/ +/* create the submenu for fonte selection and setup fonte size +*/ +{ +wxMenu * fontmenu = new wxMenu(); + ADD_MENUITEM(fontmenu, ID_PREFERENCES_FONT_DIALOG, _("font for dialog boxes"), + fonts_xpm ); + ADD_MENUITEM(fontmenu, ID_PREFERENCES_FONT_INFOSCREEN, _("font for Lists"), + fonts_xpm ); + ADD_MENUITEM(fontmenu, ID_PREFERENCES_FONT_STATUS, _("font for Status Line"), + fonts_xpm ); + ADD_MENUITEM_WITH_HELP_AND_SUBMENU(main_menu, fontmenu, + ID_PREFERENCES_FONT, _("&Font selection"), + _("Choose font type and size for dialogs, infos and status box"), + fonts_xpm); +} + + +/********************************************************/ +void WinEDA_CvpcbFrame::SetLanguage(wxCommandEvent& event) +/********************************************************/ +{ +int id = event.GetId(); + + m_Parent->SetLanguageIdentifier(id ); + m_Parent->SetLanguage(); +} + +/*************************************************************/ +void WinEDA_CvpcbFrame::DisplayDocFile(wxCommandEvent & event) +/*************************************************************/ +{ + wxString msg = FindKicadHelpPath(); + msg += wxT("pcbnew/footprints.pdf"); + GetAssociatedDocument(this, wxEmptyString, msg); +} + +/********************************************************************/ +void WinEDA_CvpcbFrame::ProcessFontPreferences(wxCommandEvent& event) +/********************************************************************/ +{ +int id = event.GetId(); +wxFont font; + + switch (id) + { + + case ID_PREFERENCES_FONT: + case ID_PREFERENCES_FONT_DIALOG: + case ID_PREFERENCES_FONT_STATUS: + WinEDA_BasicFrame::ProcessFontPreferences(id); + break; + + + case ID_PREFERENCES_FONT_INFOSCREEN: + { + font = wxGetFontFromUser(this, *g_FixedFont); + if ( font.Ok() ) + { + int pointsize = font.GetPointSize(); + *g_FixedFont = font; + g_FixedFontPointSize = pointsize; + m_FootprintList->SetFont(*g_FixedFont); + m_ListCmp->SetFont(*g_FixedFont); + } + break; + } + default: DisplayError(this, wxT("WinEDA_DrawFrame::ProcessFontPreferences Internal Error") ); + break; + } +} + +/******************************************************/ +void WinEDA_CvpcbFrame::OnLeftClick(wxListEvent& event) +/******************************************************/ +{ + m_FootprintList->OnLeftClick(event); +} + +/******************************************************/ +void WinEDA_CvpcbFrame::OnLeftDClick(wxListEvent& event) +/******************************************************/ +{ + m_FootprintList->OnLeftDClick(event); +} + +/*************************************************************/ +void WinEDA_CvpcbFrame::OnSelectComponent(wxListEvent& event) +/*************************************************************/ +{ +STORECMP * Component; +int selection; + + if ( ! m_HToolBar->GetToolState(ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST) ) + { + m_FootprintList->SetActiveFootprintList(TRUE, TRUE); + return; + } + + selection = m_ListCmp->GetSelection(); + if(selection < 0) + { + m_FootprintList->SetActiveFootprintList(TRUE, TRUE); + return; + } + + Component = g_BaseListeCmp; + for (int ii = 0 ; Component != NULL; Component = Component->Pnext) + { + if( ii == selection ) break; + ii ++; + } + + if ( Component == NULL ) + { + m_FootprintList->SetActiveFootprintList(TRUE, TRUE); + return; + } + + m_FootprintList->SetFootprintFilteredList(Component); +} + + +/************************************************************************/ +void WinEDA_CvpcbFrame::OnSelectFilteringFootprint(wxCommandEvent & event) +/************************************************************************/ +/* Select full/filtered footprint display on tool click +*/ +{ +wxListEvent l_event; + OnSelectComponent(l_event); +} + diff --git a/cvpcb/cvpcb.cpp b/cvpcb/cvpcb.cpp new file mode 100644 index 0000000000..e5e2642076 --- /dev/null +++ b/cvpcb/cvpcb.cpp @@ -0,0 +1,93 @@ + /*******************/ + /* File: cvpcb.cpp */ + /*******************/ +#define MAIN +#define eda_global + +#include "fctsys.h" +#include "common.h" + +#include "cvpcb.h" +#include "trigo.h" +#include "gr_basic.h" + +#include "bitmaps.h" + +#include "protos.h" + +#include "id.h" + +wxString g_Main_Title = wxT("Cvpcb"); + +// Create a new application object +IMPLEMENT_APP(WinEDA_App) + +/* fonctions locales */ + + /************************************/ + /* Called to initialize the program */ + /************************************/ + +bool WinEDA_App::OnInit(void) +{ +wxString msg; +wxString currCWD = wxGetCwd(); + + EDA_Appl = this; + InitEDA_Appl( wxT("cvpcb") ); + + if ( m_Checker && m_Checker->IsAnotherRunning() ) + { + if ( ! IsOK(NULL, _("Cvpcb is already running, Continue?") ) ) + return false; + } + + GetSettings(); // read current setup + + wxSetWorkingDirectory(currCWD); // mofifie par GetSetting + SetRealLibraryPath( wxT("modules") ); + + if(argc > 1 ) + { + NetInNameBuffer = argv[1]; + NetNameBuffer = argv[1]; + } + + if ( ! NetInNameBuffer.IsEmpty() ) + wxSetWorkingDirectory( wxPathOnly(NetInNameBuffer) ); + g_DrawBgColor = BLACK; + + Read_Config(NetInNameBuffer); + + wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); + m_CvpcbFrame = new WinEDA_CvpcbFrame(this, Title); + + msg.Printf( wxT("Modules: %d"), nblib); + m_CvpcbFrame->SetStatusText(msg,2); + + // Show the frame + SetTopWindow(m_CvpcbFrame); + + m_CvpcbFrame->Show(TRUE); + + listlib(); + m_CvpcbFrame->BuildFootprintListBox(); + + if( ! NetInNameBuffer.IsEmpty() ) /* nom de fichier passe a la commande */ + { + FFileName = MakeFileName(NetDirBuffer, + NetInNameBuffer, NetInExtBuffer); + + m_CvpcbFrame->ReadNetListe(); + } + else /* Mise a jour du titre de la fenetre principale */ + { + wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); + msg.Printf( wxT("%s {%s%c} [no file]"), + Title.GetData(), wxGetCwd().GetData(), DIR_SEP); + m_CvpcbFrame->SetTitle(msg); + } + + return TRUE; +} + diff --git a/cvpcb/cvpcb.h b/cvpcb/cvpcb.h new file mode 100644 index 0000000000..5676b64cd2 --- /dev/null +++ b/cvpcb/cvpcb.h @@ -0,0 +1,154 @@ + /**********************************************/ + /* CVPCB : declaration des variables globales */ + /**********************************************/ + + +#ifndef eda_global +#define eda_global extern +#endif + +#include "wxstruct.h" +#include "pcbnew.h" +#include "cvstruct.h" + +#include "gr_basic.h" +#include "colors.h" + +// Define print format d to display a schematic component line +#define CMP_FORMAT wxT("%3d %8.8s - %16.16s : %-.32s") + +#define FILTERFOOTPRINTKEY "FilterFootprint" + +enum TypeOfStruct + { + STRUCT_NOT_INIT, + STRUCT_COMPONENT, + STRUCT_PIN, + STRUCT_MODULE, + STRUCT_PSEUDOMODULE + }; + +class STOREPIN +{ +public: + int m_Type; /* Type de la structure */ + STOREPIN * Pnext; /* Chainage avant */ + int m_Index; /* variable utilisee selon types de netlistes */ + int m_PinType; /* code type electrique ( Entree Sortie Passive..) */ + wxString m_PinNet; /* Pointeur sur le texte nom de net */ + wxString m_PinNum; + wxString m_PinName; + wxString m_Repere; /* utilise selon formats de netliste */ + + STOREPIN(void); +} ; + +class STORECMP +{ +public: + int m_Type; /* Type de la structure */ + STORECMP * Pnext; /* Chainage avant */ + STORECMP * Pback; /* Chainage arriere */ + int m_Num; /* Numero d'ordre */ + int m_Multi; /* Nombre d' unites par boitier */ + STOREPIN * m_Pins; /* pointeur sur la liste des Pins */ + wxString m_Reference; /* U3, R5 ... */ + wxString m_Valeur; /* 7400, 47K ... */ + wxString m_TimeStamp; /* Signature temporelle ("00000000" si absente) */ + wxString m_Module; /* Nom du module (Package) corresp */ + wxString m_Repere; /* utilise selon formats de netliste */ + wxArrayString m_FootprintFilter; /* List of allowed footprints (wildcart allowed + if void: no filtering */ + + STORECMP(void); + ~STORECMP(void); +} ; + +class STOREMOD +{ +public: + int m_Type; /* Type de la structure */ + STOREMOD * Pnext; /* Chainage avant */ + STOREMOD * Pback; /* Chainage arriere */ + wxString m_Module; /* Nom du module */ + wxString m_LibName; /* Nom de la librairie contenant ce module */ + int m_Num ; /* Numero d'ordre pour affichage sur la liste */ + wxString m_Doc; /* Doc associee */ + wxString m_KeyWord; /* Mots cles associes */ + + STOREMOD(void); +}; + + +eda_global STOREMOD * g_BaseListePkg; +eda_global STORECMP * g_BaseListeCmp; + +eda_global FILE *source ; +eda_global FILE *dest ; +eda_global FILE *libcmp ; +eda_global FILE *lib_module ; + +/* nom des fichiers a traiter */ +eda_global wxString FFileName; + +/* Types de netliste: */ +#define TYPE_NON_SPECIFIE 0 +#define TYPE_ORCADPCB2 1 +#define TYPE_PCAD 2 +#define TYPE_VIEWLOGIC_WIR 3 +#define TYPE_VIEWLOGIC_NET 4 + +/* Gestion des noms des librairies */ +eda_global wxString g_EquivExtBuffer +#ifdef MAIN +( wxT(".equ") ) +#endif +; +eda_global wxString g_ExtCmpBuffer +#ifdef MAIN + ( wxT(".cmp") ) +#endif +; + +eda_global wxString g_UserNetDirBuffer; // Netlist path (void = current working directory) + +eda_global wxArrayString g_ListName_Equ; // list of .equ files to load + +eda_global int g_FlagEESchema; +eda_global int Rjustify; /* flag pout troncature des noms de Net: + = 0: debut de chaine conservee (->ORCADPCB2) + = 1: fin de chaine conservee (->VIEWLOGIC) */ +eda_global int selection_type; /* 0 pour sel par U??, 1 pour sel par ref ORCADPCB */ + +eda_global int modified; /* Flag != 0 si modif attribution des modules */ +eda_global int ListModIsModified; /* Flag != 0 si modif liste des lib modules */ + +eda_global char alim[1024]; + +eda_global int nbcomp ; /* nombre de composants trouves */ +eda_global int nblib ; /* nombre d'empreintes trouvees */ +eda_global int composants_non_affectes ;/* nbre de composants non affectes */ + +eda_global wxString NameBuffer; +eda_global wxString NetInNameBuffer; +eda_global wxString NetInExtBuffer; +eda_global wxString PkgInExtBuffer; +eda_global wxString NetDirBuffer; + +eda_global wxString ExtRetroBuffer +#ifdef MAIN + ( wxT(".stf") ) +#endif +; + + +// Variables generales */ +// Unused, for pcbnew compatibility: +eda_global Ki_PageDescr * SheetList[] +#ifdef MAIN += {NULL} +#endif +; + +// Unused, for pcbnew compatibility: +void Plume(int state); diff --git a/cvpcb/cvpcb.ico b/cvpcb/cvpcb.ico new file mode 100644 index 0000000000000000000000000000000000000000..cc83a577511d6dffcf4291d53648029ab4ceb40d GIT binary patch literal 3262 zcmcK62~ZPP7y#gfpi;$)I@ALV(3zr^MjQlMK~SlJ2-Fd*g0;4yD5Z9gDg*=p!zCg` zqktfy0ySv3L~l@HMnJQhK74_to)MeXo&BP88~m}&?r z1)qHQDjQtRgY9WBJq|{(@cv=Y3Q~OwiN!gr9em^vI z!!@~|bqA8_a6hmVzC%6-oX>-e+&4S|x>Wwrqj7Q{435CcQ(`y&G-hCMd;2}K1oHcb z;1S_Jgu-?}eqtR&^GE!x$Ug@*$*|-&;C?vJ0#)nBanzW&zbXZGaN$sXZ}iE`f`Tjk zq5;BhMD@%4Ooh+nfp_|Ns{ds{|G4-r`{OkHT5@j zJ{QzCmDDuy@4hH&6<@9wC-Gm#6!iudy!6c(+?hSRB~#*f_KkI-6#4WRm=X4`ew1Xz zi9z?YzWto8xPs2}yr#m+x~i(HywbA#^195coyok;@C>0}a;;Cwo!#jVx1Z~COMmT< zGQ9lcpC<8AdXz-lCIp*qfL{%zM%KR|V)(P@C#(18EO*_^`?=#-82g&o*LMPt?}Y)n902_2m-xBW6EbF%7!2DDuS=%iT)qXgKP##AbnlFM_xs zNhN2pOS7``IN6stoNRO?BpkQ0vUYZMv2$=iL0o)7YF2(+##R6H`t2#dI}^hI?zrs-q*)r$tmawDazDOkE^Q-O94c_d%%FWx%Y*}K`>8jd>iO1lE` zUv0@4wqU=RY(ag075fkV0kL6=ouca2e}BTk!`IT*!NBlC9UUE-mKJ&mtDM}AaT^aL zRvMeH(bUwMsz+b2%z5#~P*a~=Mqq<6>*c%%$;1^D?@#6Zhu9y8&o58-q@;o`xcjKB zMIl_u+np+&?RXpA^0)7u+&&-xAe-4CY3{6sr0azKs4Y*Uo8kUS2-A z{}cYbKDhN1_qi>A``00?6804V;jcM^`wNf39OQ>kTpz-pWM~r{93m3ELPPQp{|ViL zK=|eNaX(E6@yM^heYBIiW&-jp6#is2zP-IeYik?Hk^$}yK)bwt(c@k1-Xw-9z* zR`@5uI1Xk<0;R8XkJW_l_WiB~rAkx&6roH~%^p9e{PTv42_H=+gYh9XXOJeL5oeJs z8K{{(ewq--M`d3nIle`828j@XdLN*MMf3-30KC_*B(iGk6`G>x_-sWy@=Qa|lTm_CurrentOptionFile; + SetTitle(title); + Create(parent, id, caption, pos, size, style); +} + +/*! + * KiConfigCvpcbFrame creator + */ + +bool KiConfigCvpcbFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin KiConfigCvpcbFrame member initialisation + m_NetFormatBox = NULL; + m_FileExtList = NULL; + m_RightBoxSizer = NULL; + m_ListLibr = NULL; + m_ListEquiv = NULL; + m_FileExtBoxSizerH = NULL; + m_NetExtBoxSizer = NULL; + m_PkgExtBoxSizer = NULL; +////@end KiConfigCvpcbFrame member initialisation + +////@begin KiConfigCvpcbFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end KiConfigCvpcbFrame creation + return true; +} + +/*! + * Control creation for KiConfigCvpcbFrame + */ + +void KiConfigCvpcbFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin KiConfigCvpcbFrame content construction + // Generated by DialogBlocks, 28/02/2006 16:11:39 (unregistered) + + KiConfigCvpcbFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5); + + wxButton* itemButton4 = new wxButton( itemDialog1, SAVE_CFG, _("Save Cfg"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton4->SetForegroundColour(wxColour(198, 0, 0)); + itemBoxSizer3->Add(itemButton4, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); + + wxButton* itemButton5 = new wxButton( itemDialog1, ID_READ_OLDCFG, _("Read Cfg"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton5->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer3->Add(itemButton5, 0, wxGROW|wxLEFT|wxRIGHT, 5); + + wxButton* itemButton6 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton6->SetForegroundColour(wxColour(0, 128, 0)); + itemBoxSizer3->Add(itemButton6, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxString m_NetFormatBoxStrings[] = { + _("&PcbNew"), + _("&ViewLogic"), + _("View &Net + Pkg") + }; + m_NetFormatBox = new wxRadioBox( itemDialog1, FORMAT_NETLIST, _("NetList Formats:"), wxDefaultPosition, wxDefaultSize, 3, m_NetFormatBoxStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer3->Add(m_NetFormatBox, 0, wxGROW|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer8Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Files ext:")); + m_FileExtList = new wxStaticBoxSizer(itemStaticBoxSizer8Static, wxVERTICAL); + itemBoxSizer3->Add(m_FileExtList, 0, wxGROW|wxALL, 5); + + m_RightBoxSizer = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(m_RightBoxSizer, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL); + m_RightBoxSizer->Add(itemBoxSizer10, 0, wxALIGN_CENTER_HORIZONTAL, 5); + + wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer10->Add(itemBoxSizer11, 0, wxGROW|wxLEFT|wxTOP|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer11->Add(itemBoxSizer12, 0, wxALIGN_CENTER_HORIZONTAL, 5); + + wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer12->Add(itemBoxSizer13, 0, wxALIGN_CENTER_HORIZONTAL, 5); + + wxButton* itemButton14 = new wxButton( itemDialog1, DEL_LIB, _("Del"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton14->SetForegroundColour(wxColour(191, 0, 0)); + itemBoxSizer13->Add(itemButton14, 0, wxGROW|wxLEFT|wxTOP|wxBOTTOM, 5); + + wxButton* itemButton15 = new wxButton( itemDialog1, ADD_LIB, _("Add"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton15->SetForegroundColour(wxColour(0, 128, 0)); + itemBoxSizer13->Add(itemButton15, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5); + + wxButton* itemButton16 = new wxButton( itemDialog1, INSERT_LIB, _("Ins"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton16->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer13->Add(itemButton16, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer12->Add(itemBoxSizer17, 0, wxGROW|wxTOP, 5); + + wxStaticText* itemStaticText18 = new wxStaticText( itemDialog1, wxID_STATIC, _("Libraries"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticText18->SetForegroundColour(wxColour(204, 0, 0)); + itemBoxSizer17->Add(itemStaticText18, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + wxString* m_ListLibrStrings = NULL; + m_ListLibr = new wxListBox( itemDialog1, ID_LISTBOX, wxDefaultPosition, wxSize(-1, 200), 0, m_ListLibrStrings, wxLB_SINGLE ); + itemBoxSizer17->Add(m_ListLibr, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer10->Add(itemBoxSizer20, 0, wxGROW|wxTOP|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer21 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer20->Add(itemBoxSizer21, 0, wxALIGN_CENTER_HORIZONTAL, 5); + + wxBoxSizer* itemBoxSizer22 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer21->Add(itemBoxSizer22, 0, wxALIGN_CENTER_HORIZONTAL, 5); + + wxButton* itemButton23 = new wxButton( itemDialog1, DEL_EQU, _("Del"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton23->SetForegroundColour(wxColour(196, 0, 0)); + itemBoxSizer22->Add(itemButton23, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5); + + wxButton* itemButton24 = new wxButton( itemDialog1, ADD_EQU, _("Add"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton24->SetForegroundColour(wxColour(0, 128, 0)); + itemBoxSizer22->Add(itemButton24, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5); + + wxButton* itemButton25 = new wxButton( itemDialog1, INSERT_EQU, _("Ins"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton25->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer22->Add(itemButton25, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer26 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer21->Add(itemBoxSizer26, 0, wxGROW|wxTOP, 5); + + wxStaticText* itemStaticText27 = new wxStaticText( itemDialog1, wxID_STATIC, _("Equiv"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticText27->SetForegroundColour(wxColour(204, 0, 0)); + itemBoxSizer26->Add(itemStaticText27, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + wxString* m_ListEquivStrings = NULL; + m_ListEquiv = new wxListBox( itemDialog1, ID_LISTBOX1, wxDefaultPosition, wxSize(-1, 200), 0, m_ListEquivStrings, wxLB_SINGLE ); + itemBoxSizer26->Add(m_ListEquiv, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_FileExtBoxSizerH = new wxBoxSizer(wxHORIZONTAL); + m_RightBoxSizer->Add(m_FileExtBoxSizerH, 0, wxGROW, 5); + + m_NetExtBoxSizer = new wxBoxSizer(wxVERTICAL); + m_FileExtBoxSizerH->Add(m_NetExtBoxSizer, 0, wxGROW|wxRIGHT, 5); + + m_PkgExtBoxSizer = new wxBoxSizer(wxVERTICAL); + m_FileExtBoxSizerH->Add(m_PkgExtBoxSizer, 0, wxGROW|wxLEFT|wxRIGHT, 5); + +////@end KiConfigCvpcbFrame content construction + + SetDialogDatas(); +} + +/*! + * Should we show tooltips? + */ + +bool KiConfigCvpcbFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap KiConfigCvpcbFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin KiConfigCvpcbFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end KiConfigCvpcbFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon KiConfigCvpcbFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin KiConfigCvpcbFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end KiConfigCvpcbFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for SAVE_CFG + */ + +void KiConfigCvpcbFrame::OnSaveCfgClick( wxCommandEvent& event ) +{ + SaveCfg(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_READ_OLDCFG + */ + +void KiConfigCvpcbFrame::OnReadOldcfgClick( wxCommandEvent& event ) +{ + ReadOldCfg(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void KiConfigCvpcbFrame::OnOkClick( wxCommandEvent& event ) +{ + AcceptCfg(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for DEL_LIB + */ + +void KiConfigCvpcbFrame::OnDelLibClick( wxCommandEvent& event ) +{ + LibDelFct(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ADD_LIB + */ + +void KiConfigCvpcbFrame::OnAddLibClick( wxCommandEvent& event ) +{ + LibAddFct(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for INSERT_LIB + */ + +void KiConfigCvpcbFrame::OnInsertLibClick( wxCommandEvent& event ) +{ + LibAddFct(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for DEL_EQU + */ + +void KiConfigCvpcbFrame::OnDelEquClick( wxCommandEvent& event ) +{ + EquDelFct(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ADD_EQU + */ + +void KiConfigCvpcbFrame::OnAddEquClick( wxCommandEvent& event ) +{ + EquAddFct(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for INSERT_EQU + */ + +void KiConfigCvpcbFrame::OnInsertEquClick( wxCommandEvent& event ) +{ + EquAddFct(event); +} + + +/*! + * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for FORMAT_NETLIST + */ + +void KiConfigCvpcbFrame::OnFormatNetlistSelected( wxCommandEvent& event ) +{ + ReturnNetFormat(event); +} + + diff --git a/cvpcb/dialog_cvpcb_config.h b/cvpcb/dialog_cvpcb_config.h new file mode 100644 index 0000000000..5ce961b6f8 --- /dev/null +++ b/cvpcb/dialog_cvpcb_config.h @@ -0,0 +1,163 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_cvpcb_config.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 17/02/2006 18:43:13 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 17/02/2006 18:43:13 + +#ifndef _DIALOG_CVPCB_CONFIG_H_ +#define _DIALOG_CVPCB_CONFIG_H_ + +/*! + * Includes + */ + +////@begin includes +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +class wxBoxSizer; +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_KICONFIGCVPCBFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_KICONFIGCVPCBFRAME_TITLE _("Dialog") +#define SYMBOL_KICONFIGCVPCBFRAME_IDNAME ID_DIALOG +#define SYMBOL_KICONFIGCVPCBFRAME_SIZE wxSize(400, 300) +#define SYMBOL_KICONFIGCVPCBFRAME_POSITION wxDefaultPosition +#define SAVE_CFG 10001 +#define ID_READ_OLDCFG 10002 +#define FORMAT_NETLIST 10003 +#define DEL_LIB 10004 +#define ADD_LIB 10005 +#define INSERT_LIB 10006 +#define ID_LISTBOX 10010 +#define DEL_EQU 10007 +#define ADD_EQU 10008 +#define INSERT_EQU 10009 +#define ID_LISTBOX1 10011 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * KiConfigCvpcbFrame class declaration + */ + +class KiConfigCvpcbFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( KiConfigCvpcbFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + KiConfigCvpcbFrame( ); + KiConfigCvpcbFrame( WinEDA_CvpcbFrame* parent, wxWindowID id = SYMBOL_KICONFIGCVPCBFRAME_IDNAME, const wxString& caption = SYMBOL_KICONFIGCVPCBFRAME_TITLE, const wxPoint& pos = SYMBOL_KICONFIGCVPCBFRAME_POSITION, const wxSize& size = SYMBOL_KICONFIGCVPCBFRAME_SIZE, long style = SYMBOL_KICONFIGCVPCBFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_KICONFIGCVPCBFRAME_IDNAME, const wxString& caption = SYMBOL_KICONFIGCVPCBFRAME_TITLE, const wxPoint& pos = SYMBOL_KICONFIGCVPCBFRAME_POSITION, const wxSize& size = SYMBOL_KICONFIGCVPCBFRAME_SIZE, long style = SYMBOL_KICONFIGCVPCBFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin KiConfigCvpcbFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for SAVE_CFG + void OnSaveCfgClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_READ_OLDCFG + void OnReadOldcfgClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for FORMAT_NETLIST + void OnFormatNetlistSelected( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for DEL_LIB + void OnDelLibClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ADD_LIB + void OnAddLibClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for INSERT_LIB + void OnInsertLibClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for DEL_EQU + void OnDelEquClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ADD_EQU + void OnAddEquClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for INSERT_EQU + void OnInsertEquClick( wxCommandEvent& event ); + +////@end KiConfigCvpcbFrame event handler declarations + +////@begin KiConfigCvpcbFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end KiConfigCvpcbFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void Update(void); + void AcceptCfg(wxCommandEvent& event); + void SaveCfg(wxCommandEvent& event); + void ReadOldCfg(wxCommandEvent& event); + void LibDelFct(wxCommandEvent& event); + void LibAddFct(wxCommandEvent& event); + void EquDelFct(wxCommandEvent& event); + void EquAddFct(wxCommandEvent& event); + void ReturnNetFormat(wxCommandEvent& event); + void SetDialogDatas(void); + + +////@begin KiConfigCvpcbFrame member variables + wxRadioBox* m_NetFormatBox; + wxStaticBoxSizer* m_FileExtList; + wxBoxSizer* m_RightBoxSizer; + wxListBox* m_ListLibr; + wxListBox* m_ListEquiv; + wxBoxSizer* m_FileExtBoxSizerH; + wxBoxSizer* m_NetExtBoxSizer; + wxBoxSizer* m_PkgExtBoxSizer; +////@end KiConfigCvpcbFrame member variables + + WinEDA_CvpcbFrame * m_Parent; + bool m_DoUpdate; + + WinEDA_EnterText * m_LibDirCtrl; + WinEDA_EnterText * m_NetInputExtCtrl; + WinEDA_EnterText * m_PkgExtCtrl; + WinEDA_EnterText * m_TextHelpModulesFileName; +}; + +#endif + // _DIALOG_CVPCB_CONFIG_H_ diff --git a/cvpcb/dialog_cvpcb_config.rc b/cvpcb/dialog_cvpcb_config.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/cvpcb/dialog_cvpcb_config.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/cvpcb/dialog_display_options.cpp b/cvpcb/dialog_display_options.cpp new file mode 100644 index 0000000000..50c18faf37 --- /dev/null +++ b/cvpcb/dialog_display_options.cpp @@ -0,0 +1,266 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_display_options.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 17/02/2006 17:47:55 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 17/02/2006 17:47:55 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "dialog_display_options.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes +#include "fctsys.h" + +#include "wxstruct.h" +#include "common.h" +#include "cvpcb.h" +#include "protos.h" + +#include "dialog_display_options.h" + +////@begin XPM images +////@end XPM images + + +/*********************************************************************/ +void WinEDA_DisplayFrame::InstallOptionsDisplay(wxCommandEvent& event) +/*********************************************************************/ +/* Creation de la fenetre d'options de la fenetre de visu */ +{ + KiDisplayOptionsFrame * OptionWindow = new KiDisplayOptionsFrame(this); + OptionWindow->ShowModal(); OptionWindow->Destroy(); +} + + + +/*! + * KiDisplayOptionsFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( KiDisplayOptionsFrame, wxDialog ) + +/*! + * KiDisplayOptionsFrame event table definition + */ + +BEGIN_EVENT_TABLE( KiDisplayOptionsFrame, wxDialog ) + +////@begin KiDisplayOptionsFrame event table entries + EVT_CHECKBOX( PADNUM_OPT, KiDisplayOptionsFrame::OnPadnumOptClick ) + + EVT_BUTTON( ID_SAVE_CONFIG, KiDisplayOptionsFrame::OnSaveConfigClick ) + + EVT_CHECKBOX( PADFILL_OPT, KiDisplayOptionsFrame::OnPadfillOptClick ) + + EVT_RADIOBOX( EDGE_SELECT, KiDisplayOptionsFrame::OnEdgeSelectSelected ) + + EVT_RADIOBOX( TEXT_SELECT, KiDisplayOptionsFrame::OnTextSelectSelected ) + +////@end KiDisplayOptionsFrame event table entries + +END_EVENT_TABLE() + +/*! + * KiDisplayOptionsFrame constructors + */ + +KiDisplayOptionsFrame::KiDisplayOptionsFrame( ) +{ +} + +KiDisplayOptionsFrame::KiDisplayOptionsFrame( WinEDA_BasePcbFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + + Create(parent, id, caption, pos, size, style); +} + +/*! + * KiDisplayOptionsFrame creator + */ + +bool KiDisplayOptionsFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin KiDisplayOptionsFrame member initialisation + m_IsShowPadNum = NULL; + m_IsShowPadFill = NULL; + m_EdgesDisplayOption = NULL; + m_TextDisplayOption = NULL; +////@end KiDisplayOptionsFrame member initialisation + +////@begin KiDisplayOptionsFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end KiDisplayOptionsFrame creation + return true; +} + +/*! + * Control creation for KiDisplayOptionsFrame + */ + +void KiDisplayOptionsFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin KiDisplayOptionsFrame content construction + // Generated by DialogBlocks, 17/02/2006 18:31:55 (unregistered) + + KiDisplayOptionsFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxFlexGridSizer* itemFlexGridSizer3 = new wxFlexGridSizer(3, 2, 0, 0); + itemBoxSizer2->Add(itemFlexGridSizer3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + m_IsShowPadNum = new wxCheckBox( itemDialog1, PADNUM_OPT, _("Pad &Num"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_IsShowPadNum->SetValue(false); + itemFlexGridSizer3->Add(m_IsShowPadNum, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton5 = new wxButton( itemDialog1, ID_SAVE_CONFIG, _("Save Cfg"), wxDefaultPosition, wxDefaultSize, 0 ); + itemFlexGridSizer3->Add(itemButton5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); + + m_IsShowPadFill = new wxCheckBox( itemDialog1, PADFILL_OPT, _("&Pad Fill"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_IsShowPadFill->SetValue(false); + itemFlexGridSizer3->Add(m_IsShowPadFill, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5); + + itemFlexGridSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5); + + wxString m_EdgesDisplayOptionStrings[] = { + _("&Filaire"), + _("&Filled"), + _("&Sketch") + }; + m_EdgesDisplayOption = new wxRadioBox( itemDialog1, EDGE_SELECT, _("Edges:"), wxDefaultPosition, wxDefaultSize, 3, m_EdgesDisplayOptionStrings, 1, wxRA_SPECIFY_COLS ); + itemFlexGridSizer3->Add(m_EdgesDisplayOption, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxString m_TextDisplayOptionStrings[] = { + _("&Filaire"), + _("&Filled"), + _("&Sketch") + }; + m_TextDisplayOption = new wxRadioBox( itemDialog1, TEXT_SELECT, _("Texts:"), wxDefaultPosition, wxDefaultSize, 3, m_TextDisplayOptionStrings, 1, wxRA_SPECIFY_COLS ); + itemFlexGridSizer3->Add(m_TextDisplayOption, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); + + // Set validators + m_IsShowPadNum->SetValidator( wxGenericValidator(& DisplayOpt.DisplayPadNum) ); + m_IsShowPadFill->SetValidator( wxGenericValidator(& DisplayOpt.DisplayPadFill) ); + m_EdgesDisplayOption->SetValidator( wxGenericValidator(& DisplayOpt.DisplayModEdge) ); + m_TextDisplayOption->SetValidator( wxGenericValidator(& DisplayOpt.DisplayModText) ); +////@end KiDisplayOptionsFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool KiDisplayOptionsFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap KiDisplayOptionsFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin KiDisplayOptionsFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end KiDisplayOptionsFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon KiDisplayOptionsFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin KiDisplayOptionsFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end KiDisplayOptionsFrame icon retrieval +} + + +/*! + * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for PADFILL_OPT + */ + +void KiDisplayOptionsFrame::OnPadfillOptClick( wxCommandEvent& event ) +{ + DisplayOpt.DisplayPadFill = m_Parent->m_DisplayPadFill = + m_IsShowPadFill->GetValue(); + m_Parent->ReDrawPanel(); +} + +/*! + * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for PADNUM_OPT + */ + +void KiDisplayOptionsFrame::OnPadnumOptClick( wxCommandEvent& event ) +{ + DisplayOpt.DisplayPadNum = m_Parent->m_DisplayPadNum = m_IsShowPadNum->GetValue(); + m_Parent->ReDrawPanel(); +} + +/*! + * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for EDGE_SELECT + */ + +void KiDisplayOptionsFrame::OnEdgeSelectSelected( wxCommandEvent& event ) +{ + DisplayOpt.DisplayModEdge = m_Parent->m_DisplayModEdge = + m_EdgesDisplayOption->GetSelection(); + m_Parent->ReDrawPanel(); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SAVE_CONFIG + */ + +void KiDisplayOptionsFrame::OnSaveConfigClick( wxCommandEvent& event ) +{ + Save_Config(this); +} + +/*! + * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for TEXT_SELECT + */ + +void KiDisplayOptionsFrame::OnTextSelectSelected( wxCommandEvent& event ) +{ + DisplayOpt.DisplayModText = m_Parent->m_DisplayModText = + m_TextDisplayOption->GetSelection(); + m_Parent->ReDrawPanel(); +} + + diff --git a/cvpcb/dialog_display_options.h b/cvpcb/dialog_display_options.h new file mode 100644 index 0000000000..0eb721f05b --- /dev/null +++ b/cvpcb/dialog_display_options.h @@ -0,0 +1,125 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_display_options.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 17/02/2006 17:47:55 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 17/02/2006 17:47:55 + +#ifndef _DIALOG_DISPLAY_OPTIONS_H_ +#define _DIALOG_DISPLAY_OPTIONS_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "dialog_display_options.h" +#endif + +/*! + * Includes + */ + +////@begin includes +#include "wx/valgen.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_KIDISPLAYOPTIONSFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_KIDISPLAYOPTIONSFRAME_TITLE _("Options") +#define SYMBOL_KIDISPLAYOPTIONSFRAME_IDNAME ID_DIALOG +#define SYMBOL_KIDISPLAYOPTIONSFRAME_SIZE wxSize(400, 300) +#define SYMBOL_KIDISPLAYOPTIONSFRAME_POSITION wxDefaultPosition +#define PADNUM_OPT 10002 +#define ID_SAVE_CONFIG 10005 +#define PADFILL_OPT 10001 +#define EDGE_SELECT 10003 +#define TEXT_SELECT 10004 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * KiDisplayOptionsFrame class declaration + */ + +class KiDisplayOptionsFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( KiDisplayOptionsFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + KiDisplayOptionsFrame( ); + KiDisplayOptionsFrame( WinEDA_BasePcbFrame* parent, wxWindowID id = SYMBOL_KIDISPLAYOPTIONSFRAME_IDNAME, const wxString& caption = SYMBOL_KIDISPLAYOPTIONSFRAME_TITLE, const wxPoint& pos = SYMBOL_KIDISPLAYOPTIONSFRAME_POSITION, const wxSize& size = SYMBOL_KIDISPLAYOPTIONSFRAME_SIZE, long style = SYMBOL_KIDISPLAYOPTIONSFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_KIDISPLAYOPTIONSFRAME_IDNAME, const wxString& caption = SYMBOL_KIDISPLAYOPTIONSFRAME_TITLE, const wxPoint& pos = SYMBOL_KIDISPLAYOPTIONSFRAME_POSITION, const wxSize& size = SYMBOL_KIDISPLAYOPTIONSFRAME_SIZE, long style = SYMBOL_KIDISPLAYOPTIONSFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin KiDisplayOptionsFrame event handler declarations + + /// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for PADNUM_OPT + void OnPadnumOptClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SAVE_CONFIG + void OnSaveConfigClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for PADFILL_OPT + void OnPadfillOptClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for EDGE_SELECT + void OnEdgeSelectSelected( wxCommandEvent& event ); + + /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for TEXT_SELECT + void OnTextSelectSelected( wxCommandEvent& event ); + +////@end KiDisplayOptionsFrame event handler declarations + +////@begin KiDisplayOptionsFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end KiDisplayOptionsFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + +////@begin KiDisplayOptionsFrame member variables + wxCheckBox* m_IsShowPadNum; + wxCheckBox* m_IsShowPadFill; + wxRadioBox* m_EdgesDisplayOption; + wxRadioBox* m_TextDisplayOption; +////@end KiDisplayOptionsFrame member variables + + WinEDA_BasePcbFrame * m_Parent; + +}; + +#endif + // _DIALOG_DISPLAY_OPTIONS_H_ diff --git a/cvpcb/dialog_display_options.rc b/cvpcb/dialog_display_options.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/cvpcb/dialog_display_options.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/cvpcb/displayframe.cpp b/cvpcb/displayframe.cpp new file mode 100644 index 0000000000..7eabef5f95 --- /dev/null +++ b/cvpcb/displayframe.cpp @@ -0,0 +1,287 @@ +/*********************************************************************/ +/** setvisu() : initialisations de l'ecran d'affichage du composant **/ +/*********************************************************************/ + +#include "fctsys.h" +#include "common.h" + +#include "wxstruct.h" +#include "cvpcb.h" +#include "id.h" +#include "bitmaps.h" + +#include "protos.h" + +#define BITMAP wxBitmap + +/*****************************************************************/ +/* Construction de la table des evenements pour WinEDA_DrawFrame */ +/*****************************************************************/ + +BEGIN_EVENT_TABLE(WinEDA_DisplayFrame, wxFrame) + + COMMON_EVENTS_DRAWFRAME + + EVT_CLOSE(WinEDA_DisplayFrame::OnCloseWindow) + EVT_SIZE(WinEDA_DrawFrame::OnSize) + EVT_TOOL_RANGE(ID_ZOOM_PLUS_BUTT, ID_ZOOM_PAGE_BUTT, + WinEDA_DisplayFrame::Process_Zoom) + EVT_TOOL(ID_OPTIONS_SETUP, WinEDA_DisplayFrame::InstallOptionsDisplay) + EVT_TOOL(ID_CVPCB_SHOW3D_FRAME, WinEDA_BasePcbFrame::Show3D_Frame) +END_EVENT_TABLE() + + + + + /*********************************************************************/ + /* Constructeur de WinEDA_DisplayFrame: la fenetre de visu du composant */ + /*********************************************************************/ + +WinEDA_DisplayFrame::WinEDA_DisplayFrame( wxWindow * father, WinEDA_App *parent, + const wxString & title, + const wxPoint& pos, const wxSize& size): + WinEDA_BasePcbFrame(father, parent, CVPCB_DISPLAY_FRAME, title, pos, size) +{ + m_FrameName = wxT("CmpFrame"); + m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines + m_Draw_Grid = TRUE; // TRUE pour avoir la axes dessinee + m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessiné + + SetIcon(wxIcon( wxT("icon_cvpcb"))); // Give an icon + SetTitle(title); + + m_Pcb = new BOARD(NULL, this); + m_CurrentScreen = new PCB_SCREEN(CVPCB_DISPLAY_FRAME); + GetSettings(); + SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y); + ReCreateHToolbar(); + ReCreateVToolbar(); + Show(TRUE); +} + + + /*****************************************/ + /* Fonctions de base de WinEDA_DisplayFrame */ + /*****************************************/ +// Destructeur +WinEDA_DisplayFrame::~WinEDA_DisplayFrame(void) +{ + if ( m_Pcb->m_Modules ) DeleteStructure( m_Pcb->m_Modules ); + m_Pcb->m_Modules = NULL; + delete m_CurrentScreen; + delete m_Pcb; + m_Parent->m_CvpcbFrame->DrawFrame = NULL; +} + + +/************************************************************/ +void WinEDA_DisplayFrame::OnCloseWindow(wxCloseEvent& event) +/************************************************************/ +/* Fermeture par icone ou systeme +*/ +{ +wxPoint pos; +wxSize size; + + size = GetSize(); + pos = GetPosition(); + + SaveSettings(); + Destroy(); +} + + + +/************************************************/ +void WinEDA_DisplayFrame::ReCreateVToolbar(void) +/************************************************/ +{ +} + + +/************************************************/ +void WinEDA_DisplayFrame::ReCreateHToolbar(void) +/************************************************/ +{ + if ( m_HToolBar != NULL ) return; + + m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE); + SetToolBar(m_HToolBar); + + m_HToolBar->AddTool(ID_OPTIONS_SETUP, wxEmptyString, + BITMAP(display_options_xpm), + _("Display Options")); + + m_HToolBar->AddSeparator(); + + m_HToolBar->AddTool(ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP(zoom_in_xpm), + _("zoom + (F1)")); + + m_HToolBar->AddTool(ID_ZOOM_MOINS_BUTT, wxEmptyString, BITMAP(zoom_out_xpm), + _("zoom - (F2)")); + + m_HToolBar->AddTool(ID_ZOOM_REDRAW_BUTT, wxEmptyString, BITMAP(repaint_xpm), + _("redraw (F3)")); + + m_HToolBar->AddTool(ID_ZOOM_PAGE_BUTT, wxEmptyString, BITMAP(zoom_optimal_xpm), + _("1:1 zoom")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_CVPCB_SHOW3D_FRAME, wxEmptyString, BITMAP(show_3d_xpm), + _("1:1 zoom")); + + // after adding the buttons to the toolbar, must call Realize() to reflect + // the changes + m_HToolBar->Realize(); +} + + +/*******************************************/ +void WinEDA_DisplayFrame::SetToolbars(void) +/*******************************************/ +{ +} + + +void WinEDA_DisplayFrame::OnLeftClick(wxDC * DC, const wxPoint& MousePos) +{ +} + +void WinEDA_DisplayFrame::OnLeftDClick(wxDC * DC, const wxPoint& MousePos) +{ +} + +void WinEDA_DisplayFrame::OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu) +{ +} + + +/****************************************************************/ +void WinEDA_BasePcbFrame::GeneralControle(wxDC *DC, wxPoint Mouse) +/****************************************************************/ +{ +wxSize delta; +int flagcurseur = 0; +int zoom = m_CurrentScreen->GetZoom(); +wxPoint curpos, oldpos; + + curpos = DrawPanel->CursorRealPosition(Mouse); + oldpos = m_CurrentScreen->m_Curseur; + + delta.x = m_CurrentScreen->GetGrid().x / zoom; + delta.y = m_CurrentScreen->GetGrid().y / zoom; + if( delta.x <= 0 ) delta.x = 1; + if( delta.y <= 0 ) delta.y = 1; + + if( g_KeyPressed) + { + switch( g_KeyPressed ) + { + case WXK_F1 : + OnZoom(ID_ZOOM_PLUS_KEY); + flagcurseur = 2; + curpos = m_CurrentScreen->m_Curseur; + break; + case WXK_F2 : + OnZoom(ID_ZOOM_MOINS_KEY); + flagcurseur = 2; + curpos = m_CurrentScreen->m_Curseur; + break; + case WXK_F3 : + OnZoom(ID_ZOOM_REDRAW_KEY); + flagcurseur = 2; + break; + case WXK_F4 : + OnZoom(ID_ZOOM_CENTER_KEY); + flagcurseur = 2; + curpos = m_CurrentScreen->m_Curseur; + break; + + case ' ': + m_CurrentScreen->m_O_Curseur = m_CurrentScreen->m_Curseur; + break; + + case WXK_NUMPAD8: /* Deplacement curseur vers le haut */ + case WXK_UP : + DrawPanel->CalcScrolledPosition(Mouse.x, Mouse.y - delta.y, + &Mouse.x, &Mouse.y); + GRMouseWarp(DrawPanel, Mouse); + break ; + + case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ + case WXK_DOWN: + DrawPanel->CalcScrolledPosition(Mouse.x, Mouse.y + delta.y, + &Mouse.x, &Mouse.y); + GRMouseWarp(DrawPanel, Mouse); + break ; + + case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ + case WXK_LEFT : + DrawPanel->CalcScrolledPosition(Mouse.x - delta.x, Mouse.y, + &Mouse.x, &Mouse.y); + GRMouseWarp(DrawPanel, Mouse); + break ; + + case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ + case WXK_RIGHT : + DrawPanel->CalcScrolledPosition(Mouse.x + delta.x, Mouse.y, + &Mouse.x, &Mouse.y); + GRMouseWarp(DrawPanel, Mouse); + break ; + } + } + + /* Recalcul de la position du curseur schema */ + m_CurrentScreen->m_Curseur = curpos; + /* Placement sur la grille generale */ + PutOnGrid( & m_CurrentScreen->m_Curseur); + + if( m_CurrentScreen->IsRefreshReq() ) + { + flagcurseur = 2; + RedrawActiveWindow(DC, TRUE); + } + + if ( (oldpos.x != m_CurrentScreen->m_Curseur.x) || + (oldpos.y != m_CurrentScreen->m_Curseur.y) ) + { + if ( flagcurseur != 2 ) + { + curpos = m_CurrentScreen->m_Curseur; + m_CurrentScreen->m_Curseur = oldpos; + DrawPanel->CursorOff(DC); + + m_CurrentScreen->m_Curseur = curpos; + DrawPanel->CursorOn(DC); + } + + if(DrawPanel->ManageCurseur) + { + DrawPanel->ManageCurseur(DrawPanel, DC, 0); + } + } + + Affiche_Status_Box(); /* Affichage des coord curseur */ +} + +/*************************************************************************/ +void WinEDA_DisplayFrame::Process_Special_Functions(wxCommandEvent& event) +/*************************************************************************/ +/* Traite les selections d'outils et les commandes appelees du menu POPUP +*/ +{ +int id = event.GetId(); +wxClientDC dc(DrawPanel); + + DrawPanel->PrepareGraphicContext(&dc); + + switch ( id ) + { + default: + wxMessageBox( wxT("WinEDA_DisplayFrame::Process_Special_Functions error")); + break; + } + + SetToolbars(); +} + diff --git a/cvpcb/genequiv.cpp b/cvpcb/genequiv.cpp new file mode 100644 index 0000000000..0189ff80d9 --- /dev/null +++ b/cvpcb/genequiv.cpp @@ -0,0 +1,59 @@ + /***************/ + /* genstf() */ + /***************/ + +/* genere le fichier STF type 'ref' 'nom_empreinte' pour DRAFT */ + +#include "fctsys.h" + +#include "wxstruct.h" +#include "common.h" +#include "cvpcb.h" + +#include "protos.h" + +void WinEDA_CvpcbFrame::WriteStuffList(wxCommandEvent & event) +{ +FILE * FileEquiv; +STORECMP * Cmp; +wxString Line, FullFileName, Mask; + + if( nbcomp <= 0 ) return; + + /* calcul du nom du fichier */ + Mask = wxT("*") + ExtRetroBuffer; + FullFileName = FFileName; + ChangeFileNameExt(FullFileName, ExtRetroBuffer); + + FullFileName = EDA_FileSelector( wxT("Create Stuff File"), + wxGetCwd(), /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + ExtRetroBuffer, /* extension par defaut */ + Mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + TRUE + ); + if ( FullFileName.IsEmpty() ) return; + + FileEquiv = wxFopen(FullFileName, wxT("wt") ); + if (FileEquiv == 0 ) + { + Line = _("Unable to create ") + FullFileName; + DisplayError(this, Line,30); + return; + } + + /* Generation de la liste */ + for (Cmp = g_BaseListeCmp ; Cmp != NULL ; Cmp = Cmp->Pnext ) + { + /* génération du composant si son empreinte est définie */ + if ( Cmp->m_Module.IsEmpty() ) continue; + fprintf(FileEquiv, "comp = \"%s\" module = \"%s\"\n", + CONV_TO_UTF8(Cmp->m_Reference), + CONV_TO_UTF8(Cmp->m_Module)); + } + + fclose(FileEquiv); +} + diff --git a/cvpcb/genorcad.cpp b/cvpcb/genorcad.cpp new file mode 100644 index 0000000000..071b6ded6d --- /dev/null +++ b/cvpcb/genorcad.cpp @@ -0,0 +1,201 @@ + /***************/ + /* genorcad() */ + /***************/ + +/* +ComplŠte la netliste (*.NET) en y placant les ref *.lib FORMAT ORCADPCB +La valeur (Part Value) est tronquee a 16 lettres +*/ + +#include "fctsys.h" + +#include "common.h" +#include "cvpcb.h" + +#include "protos.h" + +#define MAX_LEN_NETNAME 16 + +/* Routines locales */ +static void TriPinsModule( STORECMP * CurrentCmp ); +static int PinCompare(const void *cmp1, const void *cmp2); +static void ChangePinNet( wxString & PinNet ); + +/* Variables Locales */ +int NetNumCode; /* Nombre utilise pour cree des NetNames lors de + reaffectation de NetNames */ + +int genorcad(void) +{ +char Line[1024]; +STOREPIN * Pin; +STORECMP * CurrentCmp; +wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); + + NetNumCode = 1; DateAndTime(Line); + fprintf(dest,"( { Netlist by %s, date = %s }\n", + CONV_TO_UTF8(Title), Line ) ; + + /***********************/ + /* Lecture de la liste */ + /***********************/ + + CurrentCmp = BaseListeCmp; + for( ; CurrentCmp != NULL; CurrentCmp = CurrentCmp->Pnext) + { + fprintf(dest," ( %s ", CONV_TO_UTF8(CurrentCmp->m_TimeStamp)); + + if( ! CurrentCmp->m_Module.IsEmpty() ) + fprintf(dest, CONV_TO_UTF8(CurrentCmp->m_Module)); + + else fprintf(dest,"$noname$") ; + + fprintf(dest," %s ",CONV_TO_UTF8(CurrentCmp->m_Reference)) ; + + /* placement de la valeur */ + fprintf(dest,"%s\n",CONV_TO_UTF8(CurrentCmp->m_Valeur)) ; + + /* Tri des pins */ + TriPinsModule( CurrentCmp ); + + /* Placement de la liste des pins */ + Pin = CurrentCmp->m_Pins; + for( ; Pin != NULL; Pin = Pin->Pnext ) + { + if( Pin->m_PinNet.Len() > MAX_LEN_NETNAME) + ChangePinNet( Pin->m_PinNet ); + + if( ! Pin->m_PinNet.IsEmpty() ) + fprintf(dest," ( %s %s )\n", + CONV_TO_UTF8(Pin->m_PinNum), + CONV_TO_UTF8(Pin->m_PinNet)); + else + fprintf(dest," ( %s ? )\n", CONV_TO_UTF8(Pin->m_PinNum)); + } + fprintf(dest," )\n"); + } + fprintf(dest,")\n*\n"); + fclose(dest); + return(0); +} + + + +/***********************************************/ +static void TriPinsModule( STORECMP * CurrentCmp ) +/***********************************************/ +/* Tri et controle des pins du module CurrentCmp +*/ +{ +STOREPIN * Pin, * NextPin, ** BasePin; +int nbpins = 0, ii; + + Pin = CurrentCmp->m_Pins; + if( Pin == NULL ) return; + + /* comptage des pins */ + for( ; Pin != NULL ; Pin = Pin->Pnext ) nbpins++; + + /* Tri des pins: etablissement de la liste des pointeurs */ + BasePin = (STOREPIN ** )MyZMalloc( nbpins * sizeof(STOREPIN*) ); + + Pin = CurrentCmp->m_Pins; + for( ii = 0 ; ii < nbpins ; ii++, Pin = Pin->Pnext ) + { + BasePin[ii] = Pin; + } + /* Tri des Pins */ + qsort( BasePin, nbpins, sizeof( STORECMP*), PinCompare) ; + + /* Remise a jour des pointeurs chaines */ + for( ii = 0 ; ii < nbpins-1 ; ii++ ) + { + BasePin[ii]->Pnext = BasePin[ii+1]; + } + BasePin[ii]->Pnext = NULL; + CurrentCmp->m_Pins = BasePin[0]; + + MyFree(BasePin); + + /* Elimination des redondances */ + Pin = CurrentCmp->m_Pins; + while( Pin != NULL) + { + NextPin = Pin->Pnext; + if ( NextPin == NULL ) break; + if( Pin->m_PinNum != NextPin->m_PinNum ) + { + Pin = Pin->Pnext; continue; + } + /* 2 pins successives ont le meme numero */ + if( Pin->m_PinNet != NextPin->m_PinNet ) + { + wxString msg; + msg.Printf( _("%s %s pin %s : Different Nets"), + CurrentCmp->m_Reference.GetData(),CurrentCmp->m_Valeur.GetData(), + Pin->m_PinNum.GetData()); + DisplayError(NULL, msg, 60 ); + } + Pin->Pnext = NextPin->Pnext; + delete NextPin; + } +} + + +/*******************************************************/ +static int PinCompare(const void *cmp1,const void *cmp2) +/*******************************************************/ +/* +routine PinCompare() pour qsort() pour classement alphabetique + pour tri de la liste des Pins +*/ +{ +STOREPIN **pt1 , **pt2 ; +int ii; + + pt1 = (STOREPIN**)cmp1; + pt2 = (STOREPIN**)cmp2; + + ii = StrLenNumICmp( (*pt1)->m_PinNum.GetData(), (*pt2)->m_PinNum.GetData(), 4); + return(ii); +} + + +/*******************************************/ +static void ChangePinNet( wxString & PinNet ) +/*******************************************/ +/* Change le NetName PinNet par un nom compose des 8 derniers codes de PinNet + suivi de _Xnnnnn ou nnnnn est un nom de 0 a 99999 +*/ +{ +STOREPIN * Pin; +STORECMP * CurrentCmp; +int ii; +wxString OldName; +wxString NewName; + + OldName = PinNet; + ii = PinNet.Len(); + if( Rjustify ) /* On conserve les 8 dernieres lettres du nom */ + { + NewName= OldName.Right(8); NewName << NetNumCode; + } + + else /* On conserve les 8 premieres lettres du nom */ + { + NewName = OldName.Left(8); NewName << NetNumCode; + } + NetNumCode ++; + + CurrentCmp = BaseListeCmp; + for( ; CurrentCmp != NULL; CurrentCmp = CurrentCmp->Pnext) + { + Pin = CurrentCmp->m_Pins; + for( ; Pin != NULL; Pin = Pin->Pnext ) + { + if( Pin->m_PinNet != OldName ) continue; + Pin->m_PinNet = NewName; + } + } +} + diff --git a/cvpcb/init.cpp b/cvpcb/init.cpp new file mode 100644 index 0000000000..d6d63e943d --- /dev/null +++ b/cvpcb/init.cpp @@ -0,0 +1,236 @@ + /*******************************************************************/ + /* CVPCB: Routines de base : */ + /* lecture Netliste et creation des fenetres composants et modules */ + /*******************************************************************/ + +#include "fctsys.h" +#include "common.h" + +#include "cvpcb.h" +#include "gr_basic.h" + +#include "protos.h" +#include "id.h" + + +/* routines locales : */ + + +/**********************************************************/ +void WinEDA_CvpcbFrame::SetNewPkg(const wxString & package) +/*********************************************************/ +/* + - Affecte un module au composant selectionne + - Selectionne le composant suivant +*/ +{ +STORECMP * Composant; +int ii, NumCmp, IsNew = 1; +wxString Line; + + if ( g_BaseListeCmp == NULL ) return; + + NumCmp = m_ListCmp->GetSelection(); + if( NumCmp < 0 ) + { + NumCmp = 0; + m_ListCmp->SetSelection(NumCmp, TRUE); + } + + Composant = g_BaseListeCmp; + for ( ii = 0; Composant != NULL; Composant = Composant->Pnext, ii++ ) + { + if ( NumCmp == ii ) break; + } + + if ( Composant == NULL ) return; + if ( ! Composant->m_Module.IsEmpty() ) IsNew = 0; + + Composant->m_Module = package; + + Line.Printf( CMP_FORMAT ,ii+1, + Composant->m_Reference.GetData(), Composant->m_Valeur.GetData(), + Composant->m_Module.GetData()); + modified = 1; + if ( IsNew ) composants_non_affectes -= 1; + + m_ListCmp->SetString(NumCmp, Line); + m_ListCmp->SetSelection(NumCmp, FALSE); + + // We activate next component: + if ( NumCmp < (m_ListCmp->GetCount() - 1) ) NumCmp++; + m_ListCmp->SetSelection(NumCmp, TRUE); + + Line.Printf( _("Components: %d (free: %d)"), + nbcomp, composants_non_affectes); + SetStatusText(Line,1); +} + +/********************************************/ +void WinEDA_CvpcbFrame::ReadNetListe(void) +/*******************************************/ +/* Lecture de la netliste selon format, ainsi que du fichier des composants +*/ +{ +STORECMP * Composant; +wxString msg; +int ii; +int error_level = -1; + + switch( g_NetType ) + { + case TYPE_NON_SPECIFIE: + case TYPE_ORCADPCB2: + error_level = ReadSchematicNetlist(); + break; + + case TYPE_PCAD: + error_level = rdpcad() ; + break; + + case TYPE_VIEWLOGIC_WIR: + error_level = ReadViewlogicWirList() ; + break; + + case TYPE_VIEWLOGIC_NET: + error_level = ReadViewlogicNetList() ; + break; + + default: + DisplayError(this, _("Unknown Netlist Format") ); + break; + } + + if ( error_level < 0 ) return; + + /* lecture des correspondances */ + loadcmp(); + + if (m_ListCmp == NULL ) return; + + if ( ! NetInNameBuffer.IsEmpty() ) + wxSetWorkingDirectory( wxPathOnly(NetInNameBuffer) ); + + Read_Config(NetInNameBuffer); // relecture de la config (elle peut etre modifiée) + + listlib(); + BuildFootprintListBox(); + + m_ListCmp->Clear(); + Composant = g_BaseListeCmp; + + composants_non_affectes = 0; + for ( ii = 1;Composant != NULL; Composant = Composant->Pnext, ii++ ) + { + msg.Printf(CMP_FORMAT ,ii, + Composant->m_Reference.GetData(), Composant->m_Valeur.GetData(), + Composant->m_Module.GetData()); + m_ListCmp->AppendLine(msg); + if( Composant->m_Module.IsEmpty() ) composants_non_affectes += 1; + } + if ( g_BaseListeCmp ) + m_ListCmp->SetSelection(0, TRUE); + + msg.Printf(_("Componants: %d (free: %d)"), nbcomp, composants_non_affectes); + SetStatusText(msg,1); + + /* Mise a jour du titre de la fenetre principale */ + wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); + msg.Printf( wxT("%s [%s]"), Title.GetData(), FFileName.GetData()); + SetTitle(msg); + +} + + +/*****************************************************************/ +int WinEDA_CvpcbFrame::SaveNetList(const wxString & FullFilename) +/*****************************************************************/ +/* Sauvegarde des fichiers netliste et cmp + Le nom complet du fichier Netliste doit etre dans FFileName. + Le nom du fichier cmp en est deduit +*/ +{ +wxString NetlistFullFileName = FullFilename; + + if ( NetlistFullFileName.IsEmpty() ) + { + wxString Mask = wxT("*") + NetExtBuffer; + if ( ! NetNameBuffer.IsEmpty() ) + { + NetlistFullFileName = NetNameBuffer; + ChangeFileNameExt(NetlistFullFileName, NetExtBuffer); + } + + NetlistFullFileName = EDA_FileSelector( _("Save Net List & Cmp"), + NetDirBuffer, /* Chemin par defaut */ + NetlistFullFileName, /* nom fichier par defaut */ + NetExtBuffer, /* extension par defaut */ + Mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + TRUE + ); + } + if ( NetlistFullFileName.IsEmpty() ) return -1; + + FFileName = NetlistFullFileName; + NetNameBuffer = NetlistFullFileName; + if( SaveComponentList(NetlistFullFileName) == 0 ) + { + DisplayError(this, _("Unable to create component file (.cmp)") ); + return 0; + } + + dest = wxFopen(NetlistFullFileName, wxT("wt") ); + if( dest == 0 ) + { + DisplayError(this, _("Unable to create netlist file") ); + return 0; + } + + GenNetlistPcbnew() ; + + return 1; +} + + +/**********************************************************************/ +bool WinEDA_CvpcbFrame::ReadInputNetList(const wxString & FullFileName) +/**********************************************************************/ +/* Routine de selection du nom de la netliste d'entree, et de lecure de +celle-ci +*/ +{ +wxString Mask, Line; + + if ( FullFileName.IsEmpty() ) + { + if( ! NetInExtBuffer.IsEmpty() ) Mask = wxT("*") + NetInExtBuffer; + else Mask = wxT("*.net"); + Line = EDA_FileSelector(_("Load Net List"), + NetDirBuffer, /* Chemin par defaut */ + NetInNameBuffer, /* nom fichier par defaut */ + NetInExtBuffer, /* extension par defaut */ + Mask, /* Masque d'affichage */ + this, + 0, + FALSE + ); + if ( Line.IsEmpty()) return(FALSE); + } + else Line = FullFileName; + + NetInNameBuffer = Line; + NetNameBuffer = Line; + FFileName = NetInNameBuffer; + + /* Mise a jour du titre de la fenetre principale */ + Line = g_Main_Title + wxT(" ") + GetBuildVersion(); + Line += wxT(" ") + NetInNameBuffer; + SetTitle(Line); + + ReadNetListe(); + + return(TRUE); +} + diff --git a/cvpcb/licence.h b/cvpcb/licence.h new file mode 100644 index 0000000000..2662c2fc1d --- /dev/null +++ b/cvpcb/licence.h @@ -0,0 +1,6 @@ +#define MACHINE "PC" +#define NB_CLES 16 +#define POSITION_LICENCE 50 +#define POSITION_CLE 250 +#define TAILLE_LICENCE 256 + diff --git a/cvpcb/listboxes.cpp b/cvpcb/listboxes.cpp new file mode 100644 index 0000000000..e049464ee1 --- /dev/null +++ b/cvpcb/listboxes.cpp @@ -0,0 +1,472 @@ +/*************************************************************************/ +/* listboxes.cpp: class for displaying footprint list and component list */ +/*************************************************************************/ + +#include "fctsys.h" + +#include "wxstruct.h" +#include "common.h" +#include "cvpcb.h" + +#include "id.h" + +#include "protos.h" + +/************************************************************************/ +/* Class (from wxListView) for displaying component and footprint lists */ +/************************************************************************/ + +ListBoxBase::ListBoxBase(WinEDA_CvpcbFrame * parent, + wxWindowID id, const wxPoint& loc, const wxSize& size): + LIST_BOX_TYPE(parent, id, loc, size, + wxSUNKEN_BORDER | wxLC_NO_HEADER | + wxLC_SINGLE_SEL|wxLC_REPORT | wxLC_VIRTUAL) +{ + m_Parent = parent; + InsertColumn(0, wxEmptyString); + SetColumnWidth(0, wxLIST_AUTOSIZE ); +} + + + +ListBoxBase::~ListBoxBase(void) +{ +} + +/************************************************/ +void ListBoxBase::OnSize(wxSizeEvent& event) +/************************************************/ +// Ajust the column width to the entire available window width +{ +wxSize size = GetClientSize(); +int width = 0; + +// SetColumnWidth(0, wxLIST_AUTOSIZE ); +// width = GetColumnWidth(0); + SetColumnWidth(0, MAX(width, size.x) ); + + event.Skip(); +} + + +/*********************************/ +int ListBoxBase::GetSelection(void) +/*********************************/ +// Return an index for the selected item +{ + return GetFirstSelected(); +} + + +/************************************************************/ +/* ListBox derivee pour l'affichage de la liste des Modules */ +/************************************************************/ + +FootprintListBox::FootprintListBox(WinEDA_CvpcbFrame * parent, + wxWindowID id, const wxPoint& loc, const wxSize& size, + int nbitems, wxString choice[]): + ListBoxBase(parent, id, loc, size) +{ + SetActiveFootprintList(TRUE); +} + + + +FootprintListBox::~FootprintListBox(void) +{ +} + + +/**********************************/ +int FootprintListBox::GetCount(void) +/**********************************/ +// Return number of items +{ + return m_ActiveFootprintList->Count(); +} + + +/*****************************************************************************/ +void FootprintListBox::SetString(unsigned linecount, const wxString & text) +/*****************************************************************************/ +// Change an item text +{ + if (linecount >= m_ActiveFootprintList->Count()) + linecount = m_ActiveFootprintList->Count()-1; + if ( linecount >= 0 ) (*m_ActiveFootprintList)[linecount] = text; +} + +/***************************************************/ +wxString FootprintListBox::GetSelectedFootprint(void) +/***************************************************/ +// Return an index for the selected item +{ +wxString FootprintName; +int ii = GetFirstSelected(); + + if ( ii >= 0 ) + { + wxString msg = (*m_ActiveFootprintList)[ii]; + msg.Trim(TRUE); msg.Trim(FALSE); + FootprintName = msg.AfterFirst(wxChar(' ')); + } + + return FootprintName; +} + + +/*********************************************************/ +void FootprintListBox::AppendLine(const wxString & text) +/*********************************************************/ +// Add an item at end of list +{ + m_ActiveFootprintList->Add(text); + SetItemCount(m_ActiveFootprintList->Count() ); +} + + +/*********************************************************************/ +wxString FootprintListBox::OnGetItemText(long item, long column) const +/*********************************************************************/ +/* Overlayed function: MUST be provided in wxLC_VIRTUAL mode + because real datas are not handled by ListBoxBase +*/ +{ + return m_ActiveFootprintList->Item(item); +} + +/*****************************************************************/ +void FootprintListBox::SetSelection(unsigned index, bool State) +/*****************************************************************/ +// Enable or disable an item +{ + if ( (int) index >= GetCount() ) index = GetCount()-1; + +#ifndef __WXMAC__ + Select(index, State); +#endif + EnsureVisible(index); +#ifdef __WXMAC__ + Refresh(); +#endif +} + + +/***************************************************************/ +/* ListBox derivee pour l'affichage de la liste des Composants */ +/***************************************************************/ + +ListBoxCmp::ListBoxCmp(WinEDA_CvpcbFrame * parent, wxWindowID id, + const wxPoint& loc, const wxSize& size, + int nbitems, wxString choice[]): + ListBoxBase(parent, id, loc, size) +{ +} + + + +ListBoxCmp::~ListBoxCmp(void) +{ +} + + + +/***********************************************************************/ +/* Construction de la table des evenements pour la fenetre des composants */ +/***********************************************************************/ + +BEGIN_EVENT_TABLE(ListBoxCmp, LIST_BOX_TYPE) + EVT_SIZE( ListBoxBase::OnSize) + +END_EVENT_TABLE() + +/****************************/ +void ListBoxCmp::Clear(void) +/****************************/ +// Reset ALL datas +{ + m_ComponentList.Clear(); + SetItemCount(0); +} + +/******************************/ +int ListBoxCmp::GetCount(void) +/******************************/ +// Return number of items +{ + return m_ComponentList.Count(); +} +/********************************************************************/ +void ListBoxCmp::SetString(unsigned linecount, const wxString & text) +/********************************************************************/ +// Change an item text +{ + if (linecount >= m_ComponentList.Count()) + linecount = m_ComponentList.Count()-1; + if ( linecount >= 0 ) m_ComponentList[linecount] = text; +} + +/****************************************************/ +void ListBoxCmp::AppendLine(const wxString & text) +/****************************************************/ +// Add an item at end of list +{ + m_ComponentList.Add(text); + SetItemCount(m_ComponentList.Count() ); +} + + +/****************************************************************/ +wxString ListBoxCmp::OnGetItemText(long item, long column) const +/****************************************************************/ +/* Overlayed function: MUST be provided in wxLC_VIRTUAL mode + because real datas are not handled by ListBoxBase +*/ +{ + return m_ComponentList.Item(item); +} + +/********************************************************/ +void ListBoxCmp::SetSelection(unsigned index, bool State) +/*********************************************************/ +// Enable or disable an item +{ + if ( (int) index >= GetCount() ) index = GetCount()-1; + +#ifndef __WXMAC__ + Select(index, State); +#endif + EnsureVisible(index); +#ifdef __WXMAC__ + Refresh(); +#endif +} + +/********************************************/ +void WinEDA_CvpcbFrame::BuildCmpListBox(void) +/********************************************/ +/* Construit la fenetre d'affichage de la liste des composant. + dimx et dimy sont les dimensions de la surface totale d'affichage + et non les dims de la fenetre des Cmp + Si la fenetre d'affichage a deja ete creee, il y a seulement + mise a jour de la liste +*/ +{ +int ii; +STORECMP * Composant; +wxString msg; +wxSize size(10,10); + + if( m_ListCmp == NULL ) + { + m_ListCmp = new ListBoxCmp(this, ID_CVPCB_COMPONENT_LIST, + wxDefaultPosition, size, + 0, NULL); + m_ListCmp->SetBackgroundColour(wxColour(225,255,255)); + m_ListCmp->SetForegroundColour(wxColour(0,0,0)); + m_ListCmp->SetFont(*g_FixedFont); + } + + m_ListCmp->m_ComponentList.Clear(); + Composant = g_BaseListeCmp; + for (ii = 1 ; Composant != NULL; Composant = Composant->Pnext, ii++ ) + { + msg.Printf(CMP_FORMAT ,ii, + Composant->m_Reference.GetData(), Composant->m_Valeur.GetData(), + Composant->m_Module.GetData()); + m_ListCmp->m_ComponentList.Add(msg); + } + m_ListCmp->SetItemCount(m_ListCmp->m_ComponentList.Count() ); + + m_ListCmp->SetSelection(0, TRUE); +} + + +/*************************************************************/ +void WinEDA_CvpcbFrame::BuildFootprintListBox(void) +/*************************************************************/ +/* Construit la fenetre d'affichage de la liste des Modules. + dimx et dimy sont les dimensions de la surface totale d'affichage + et non les dims de la fenetre des Modules + Si la fenetre d'affichage a deja ete creee, il y a seulement + mise a jour de la liste +*/ +{ +wxString msg; +wxSize size(10,10); + + if( m_FootprintList == NULL ) + { + m_FootprintList = new FootprintListBox(this, ID_CVPCB_FOOTPRINT_LIST, + wxDefaultPosition, size, + 0, NULL); + m_FootprintList->SetBackgroundColour(wxColour(225,255,225)); + m_FootprintList->SetForegroundColour(wxColour(0,0,0)); + m_FootprintList->SetFont(*g_FixedFont); + } + + m_FootprintList->SetFootprintFullList(); + + msg.Printf(_("Footprints: %d"), m_FootprintList->GetCount()); + SetStatusText(msg,2); +} + + +/************************************************/ +void FootprintListBox::SetFootprintFullList(void) +/************************************************/ +{ +STOREMOD * FootprintItem; +wxString msg; +int OldSelection = GetSelection(); + + m_FullFootprintList.Clear(); + FootprintItem = g_BaseListePkg; + + for ( int ii = 1; FootprintItem != NULL; FootprintItem = FootprintItem->Pnext, ii++ ) + { + msg.Printf( wxT("%3d %s"), ii, FootprintItem->m_Module.GetData()); + m_FullFootprintList.Add(msg); + } + + SetActiveFootprintList(TRUE); + + if ( (GetCount() == 0) || (OldSelection < 0) || ( OldSelection >= GetCount() ) ) + SetSelection(0, TRUE); + Refresh(); +} + +/**********************************************************************/ +void FootprintListBox::SetFootprintFilteredList(STORECMP * Component) +/*********************************************************************/ +{ +STOREMOD * FootprintItem; +wxString msg; +int OldSelection = GetSelection(); +bool HasItem = FALSE; + + m_FilteredFootprintList.Clear(); + FootprintItem = g_BaseListePkg; + + int cmpnum = 1; + for ( int ii = 0; FootprintItem != NULL; FootprintItem = FootprintItem->Pnext, ii++ ) + { + /* Search for matching footprints */ + for ( unsigned jj = 0; jj < Component->m_FootprintFilter.GetCount(); jj ++ ) + { + if ( ! FootprintItem->m_Module.Matches(Component->m_FootprintFilter[jj]) ) + continue; + msg.Printf( wxT("%3d %s"), cmpnum++, FootprintItem->m_Module.GetData()); + m_FilteredFootprintList.Add(msg); + HasItem = TRUE; + } + } + + + if ( HasItem ) SetActiveFootprintList(FALSE); + else SetActiveFootprintList(TRUE); + + + if ( (GetCount() == 0) || ( OldSelection >= GetCount() ) ) + SetSelection(0, TRUE); + + Refresh(); +} + + +/**************************************************************************/ +void FootprintListBox::SetActiveFootprintList(bool FullList, bool Redraw) +/**************************************************************************/ +{ +bool old_selection = m_UseFootprintFullList; + + if ( FullList ) + { + m_UseFootprintFullList = TRUE; + m_ActiveFootprintList = &m_FullFootprintList; + SetItemCount(m_FullFootprintList.GetCount() ); + } + else + { + m_UseFootprintFullList = FALSE; + m_ActiveFootprintList = &m_FilteredFootprintList; + SetItemCount(m_FilteredFootprintList.GetCount() ); + } + + if ( Redraw ) + { + if ( ! m_UseFootprintFullList || (m_UseFootprintFullList != old_selection) ) + { + Refresh(); + } + } + + if ( ! m_UseFootprintFullList || (m_UseFootprintFullList != old_selection) ) + { + m_Parent->SetStatusText(wxEmptyString,0); + m_Parent->SetStatusText(wxEmptyString,1); + } + + wxString msg; + if ( FullList ) + msg.Printf(_("Footprints (All): %d"), m_ActiveFootprintList->GetCount()); + else + msg.Printf(_("Footprints (filtered): %d"), m_ActiveFootprintList->GetCount()); + m_Parent->SetStatusText(msg,2); +} + +/***********************************************************************/ +/* Construction de la table des evenements pour la fenetre des modules */ +/***********************************************************************/ + +BEGIN_EVENT_TABLE(FootprintListBox, LIST_BOX_TYPE) + EVT_SIZE( ListBoxBase::OnSize) + +END_EVENT_TABLE() + + +/********************************************************/ +void FootprintListBox::OnLeftClick(wxListEvent & event) +/********************************************************/ +{ +STOREMOD * Module; +wxString msg; +wxString FootprintName = GetSelectedFootprint(); + + Module = GetModuleDescrByName(FootprintName); + if( m_Parent->DrawFrame ) + { + m_Parent->CreateScreenCmp(); /* refresh general */ + } + + if ( Module ) msg = Module->m_Doc; + m_Parent->SetStatusText(msg,0); + + msg = wxT("KeyW: "); + if( Module ) msg += Module->m_KeyWord; + m_Parent->SetStatusText(msg, 1); +} + + +/******************************************************/ +void FootprintListBox::OnLeftDClick(wxListEvent & event) +/******************************************************/ +{ +wxString FootprintName = GetSelectedFootprint(); + + m_Parent->SetNewPkg(FootprintName); +} + +/**************************************************************/ +STOREMOD * GetModuleDescrByName(const wxString & FootprintName) +/**************************************************************/ +{ +STOREMOD * FootprintItem = g_BaseListePkg; + + for ( ; FootprintItem != NULL; FootprintItem = FootprintItem->Pnext ) + { + if( FootprintItem->m_Module == FootprintName) + break; // found ! + } + return FootprintItem; +} diff --git a/cvpcb/listlib.cpp b/cvpcb/listlib.cpp new file mode 100644 index 0000000000..03b731a0d9 --- /dev/null +++ b/cvpcb/listlib.cpp @@ -0,0 +1,250 @@ + /**************/ + /* listlib.cpp */ + /**************/ + +/* +cherche toutes les ref *.??? si nom fichier pr‚sent, +ou examine [MODULE.LIB] +*/ + +#include "fctsys.h" + +#include "wxstruct.h" + +#include "common.h" +#include "cvpcb.h" + +#include "protos.h" + +FILE *name_libmodules ; /* pour lecture librairie */ + +/* routines locales : */ +static void ReadDocLib(const wxString & ModLibName ); +static int LibCompare(void * mod1, void * mod2); +static STOREMOD * TriListeModules(STOREMOD * BaseListe, int nbitems); +/**/ + +/*********************/ +int listlib(void) +/*********************/ +/* Routine lisant la liste des librairies, et generant la liste chainee + des modules disponibles + +Module descr format: +$MODULE c64acmd +Li c64acmd +Cd Connecteur DIN Europe 96 Contacts AC male droit +Kw CONN DIN +$EndMODULE + +*/ +{ +char buffer[1024]; +wxString FullLibName; +int errorlevel = 0, end; +int flag_librairie; +STOREMOD * ItemLib; +unsigned ii; +wxString msg; + + if( g_BaseListePkg ) /* Liste Deja existante, a supprimer */ + { + FreeMemoryModules(); g_BaseListePkg = NULL; + } + + if ( g_LibName_List.GetCount() == 0 ) return -4; + + /* init recherche */ + SetRealLibraryPath( wxT("modules")); + nblib = 0; + + /* Lecture des Librairies */ + for( ii= 0 ; ii < g_LibName_List.GetCount(); ii++) + { + /* Calcul du nom complet de la librairie */ + FullLibName = MakeFileName(g_RealLibDirBuffer, g_LibName_List[ii], LibExtBuffer); + /* acces a une librairie */ + if ((name_libmodules = wxFopen(FullLibName, wxT("rt"))) == NULL ) + { + msg.Printf( _("Library file <%s> not found"),FullLibName.GetData()); + DisplayError(NULL, msg, 20); + continue; + } + + /* Controle du type de la librairie : */ + flag_librairie = 0; + fgets(buffer,32,name_libmodules) ; + if( strncmp(buffer,ENTETE_LIBRAIRIE,L_ENTETE_LIB) != 0 ) + { + msg.Printf(_("Library file <%s> is not a module library"), + FullLibName.GetData()); + DisplayError(NULL, msg, 20); + fclose(name_libmodules); continue; + } + + /* Lecture du nombre de composants */ + fseek(name_libmodules,0,0) ; + + /* lecture nom des composants : */ + end = 0; + while( !end && fgets(buffer,255,name_libmodules) != NULL ) + { + if(strnicmp(buffer,"$INDEX",6) == 0 ) + { + while( fgets(buffer,255,name_libmodules) != NULL ) + { + if(strnicmp(buffer,"$EndINDEX",6) == 0 ) + { end = 1; break; } + + ItemLib = new STOREMOD(); + ItemLib->Pnext = g_BaseListePkg; + g_BaseListePkg = ItemLib; + ItemLib->m_Module = CONV_FROM_UTF8(StrPurge(buffer)); + ItemLib->m_LibName = FullLibName; + + nblib++; + } + if( !end ) errorlevel = -3; + } + } + fclose(name_libmodules); + ReadDocLib(FullLibName ); + } + + /* classement alphabetique: */ + if( g_BaseListePkg ) + g_BaseListePkg = TriListeModules(g_BaseListePkg, nblib); + + return(errorlevel) ; +} + +/************************************************/ +static int LibCompare(void * mod1, void * mod2) +/************************************************/ +/* +routine compare() pour qsort() en classement alphabétique des modules +*/ +{ +int ii; +STOREMOD *pt1 , *pt2; + + pt1 = * ((STOREMOD**)mod1); + pt2 = * ((STOREMOD**)mod2); + + ii = StrNumICmp( pt1->m_Module.GetData(), pt2->m_Module.GetData() ); + return(ii); +} + + + +/********************************************************************/ +static STOREMOD * TriListeModules(STOREMOD * BaseListe, int nbitems) +/********************************************************************/ +/* Tri la liste des Modules par ordre alphabetique et met a jour +le nouveau chainage avant/arriere + retourne un pointeur sur le 1er element de la liste +*/ +{ +STOREMOD ** bufferptr, * Item; +int ii, nb; + + if (nbitems <= 0 ) return(NULL); + if ( BaseListe == NULL ) return(NULL); + + if (nbitems == 1 ) return(BaseListe); // Tri inutile et impossible + + bufferptr = (STOREMOD**)MyZMalloc( (nbitems+3) * sizeof(STOREMOD*) ); + + for( ii = 1, nb = 0, Item = BaseListe; Item != NULL; Item = Item->Pnext, ii++) + { + nb++; + bufferptr[ii] = Item; + } + + /* ici bufferptr[0] = NULL et bufferptr[nbitem+1] = NULL et ces 2 valeurs + representent le chainage arriere du 1er element ( = NULL), + et le chainage avant du dernier element ( = NULL ) */ + + qsort(bufferptr+1,nb,sizeof(STOREMOD*), + (int(*)(const void*,const void*))LibCompare) ; + + /* Mise a jour du chainage */ + for( ii = 1; ii <= nb; ii++ ) + { + Item = bufferptr[ii]; + Item->m_Num = ii; + Item->Pnext = bufferptr[ii+1]; + Item->Pback = bufferptr[ii-1]; + } + + Item = bufferptr[1]; + MyFree(bufferptr); + + return(Item); +} + + + +/***************************************************/ +static void ReadDocLib(const wxString & ModLibName ) +/***************************************************/ +/* Routine de lecture du fichier Doc associe a la librairie ModLibName. + Cree en memoire la chaine liste des docs pointee par MList + ModLibName = full file Name de la librairie Modules +*/ +{ +STOREMOD * NewMod; +char Line[1024]; +wxString ModuleName; +wxString docfilename; +FILE * LibDoc; + + docfilename = ModLibName; + ChangeFileNameExt(docfilename, EXT_DOC); + + if( (LibDoc = wxFopen(docfilename, wxT("rt"))) == NULL ) return; + + GetLine(LibDoc, Line, NULL, sizeof(Line) -1); + if(strnicmp( Line,ENTETE_LIBDOC, L_ENTETE_LIB) != 0) return; + + /* Lecture de la librairie */ + while( GetLine(LibDoc,Line, NULL, sizeof(Line) -1) ) + { + NewMod = NULL; + if( Line[0] != '$' ) continue; + if( Line[1] == 'E' ) break;; + if( Line[1] == 'M' ) /* Debut decription 1 module */ + { + while( GetLine(LibDoc,Line, NULL, sizeof(Line) -1) ) + { + if( Line[0] == '$' ) /* $EndMODULE */ + break; + switch( Line[0] ) + { + case 'L': /* LibName */ + ModuleName = CONV_FROM_UTF8(StrPurge(Line+3)); + NewMod = g_BaseListePkg; + while ( NewMod ) + { + if( ModuleName == NewMod->m_Module ) break; + NewMod = NewMod->Pnext; + } + break; + + case 'K': /* KeyWords */ + if( NewMod && (! NewMod->m_KeyWord) ) + NewMod->m_KeyWord = CONV_FROM_UTF8(StrPurge(Line+3) ); + break; + + case 'C': /* Doc */ + if( NewMod && (! NewMod->m_Doc ) ) + NewMod->m_Doc = CONV_FROM_UTF8(StrPurge(Line+3) ); + break; + } + } + } /* lecture 1 descr module */ + } /* Fin lecture librairie */ + fclose(LibDoc); +} + + diff --git a/cvpcb/loadcmp.cpp b/cvpcb/loadcmp.cpp new file mode 100644 index 0000000000..fc9d8f276c --- /dev/null +++ b/cvpcb/loadcmp.cpp @@ -0,0 +1,100 @@ + /***************************************************/ + /* Localisation des elements pointes par la souris */ + /***************************************************/ + +#include "fctsys.h" + +#include "wxstruct.h" +#include "common.h" +#include "cvpcb.h" +#include "protos.h" + + + +/*****************************************************************/ +MODULE * WinEDA_DisplayFrame::Get_Module(const wxString & CmpName) +/*****************************************************************/ +/* + Analyse les LIBRAIRIES pour trouver le module demande + Si ce module est trouve, le copie en memoire, et le + chaine en fin de liste des modules + - Entree: + name_cmp = nom du module + - Retour: + Pointeur sur le nouveau module. +*/ +{ +int LineNum, Found = 0; +unsigned ii; +char Line[1024], Name[255]; +wxString libname; +MODULE * Module = NULL; + + for( ii= 0 ; ii < g_LibName_List.GetCount(); ii++) + { + /* Calcul du nom complet de la librairie */ + libname = MakeFileName(g_RealLibDirBuffer, g_LibName_List[ii], LibExtBuffer); + + if ((lib_module = wxFopen(libname, wxT("rt"))) == NULL ) + { + continue ; + } + + /* lecture entete chaine definie par ENTETE_LIBRAIRIE */ + LineNum = 0; + GetLine(lib_module, Line, &LineNum) ; + StrPurge(Line); + if(strnicmp( Line,ENTETE_LIBRAIRIE, L_ENTETE_LIB) != 0) + { + DisplayError(this, _("This file is NOT a library file") ); + return(NULL); + } + + /* Lecture de la liste des composants de la librairie */ + Found = 0; + while( !Found && GetLine(lib_module,Line, &LineNum) ) + { + if( strncmp( Line, "$MODULE",6) == 0 ) break; + if( strnicmp( Line,"$INDEX",6) == 0 ) + { + while( GetLine(lib_module,Line, &LineNum) ) + { + if( strnicmp( Line,"$EndINDEX",9) == 0 ) break; + StrPurge(Line); + if( stricmp(Line, CONV_TO_UTF8(CmpName)) == 0 ) + { + Found = 1; break; /* Trouve! */ + } + } + } + } + + /* Lecture de la librairie */ + while( Found && GetLine(lib_module,Line, &LineNum) ) + { + if( Line[0] != '$' ) continue; + if( Line[1] != 'M' ) continue; + if( strnicmp( Line, "$MODULE",7) != 0 ) continue; + /* Lecture du nom du composant */ + sscanf(Line+7," %s",Name); + if( stricmp(Name,CONV_TO_UTF8(CmpName)) == 0 ) /* composant localise */ + { + Module = new MODULE(m_Pcb); + Module->ReadDescr(lib_module, &LineNum); + Module->SetPosition(wxPoint(0,0) ); + fclose(lib_module); + return(Module) ; + } + } + fclose(lib_module) ; lib_module = 0; + } + + if( lib_module ) fclose(lib_module) ; + + wxString msg; + msg.Printf(_("Module %s not found"),CmpName.GetData()); + DisplayError(this, msg); + return(NULL) ; +} + + diff --git a/cvpcb/makefile.g95 b/cvpcb/makefile.g95 new file mode 100644 index 0000000000..613b385120 --- /dev/null +++ b/cvpcb/makefile.g95 @@ -0,0 +1,35 @@ +# makefile pour cvpcb (mingw) +OBJSUFF = o + +TARGET=cvpcb + +WXDIR = $(WXWIN) + +all: $(TARGET).exe + +include makefile.include +include ../libs.win + + +$(TARGET).exe: $(OBJECTS) $(TARGET)_resources.o\ + $(EDALIBS) $(LIBVIEWER3D) makefile.g95 + $(CXX) $(ALL_LDFLAGS) -o $(TARGET).exe\ + $(OBJECTS) $(LIBVIEWER3D) $(TARGET)_resources.o $(EDALIBS) $(SYSWXLIB) + + +install:$(KICAD_BIN)/$(TARGET).exe + cp $(TARGET).exe $(KICAD_BIN) + +$(KICAD_BIN)/$(TARGET).exe:$(TARGET).exe + +$(TARGET)_resources.o: $(TARGET).rc + $(RESCOMP) $(RCINPUTSWITCH) $(TARGET).rc $(RCOUTPUTSWITCH) $(TARGET)_resources.o $(RESFLAGS) + + +clean: + rm -f *.o + rm -f *.rsc + rm -f *.res + rm -f *.exe + rm -f *.bak + diff --git a/cvpcb/makefile.gtk b/cvpcb/makefile.gtk new file mode 100644 index 0000000000..46b231a72a --- /dev/null +++ b/cvpcb/makefile.gtk @@ -0,0 +1,40 @@ +# File: makefile + +# Compiler flags. +CC = gcc +LD = gcc + +FINAL = 1 + +# Compiler flags. + +CPPFLAGS = -Wall -O2 `wx-config --cxxflags` + +LDFLAGS = -s + +EDACPPFLAGS = $(CPPFLAGS) + +include ../libs.linux + + +TARGET = cvpcb + +all: $(TARGET) + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + + +$(TARGET): $(OBJECTS) makefile.gtk makefile.include $(EXTRALIBS) ../libs.linux $(LIBVIEWER3D) + $(LD) $(OBJECTS) $(LDFLAGS) $(LIBVIEWER3D) $(LIBS_WITH_GL) -o $(TARGET) + + +install: + cp -f $(TARGET) $(KICAD_BIN) + +clean: + rm *.o + rm $(TARGET) + diff --git a/cvpcb/makefile.include b/cvpcb/makefile.include new file mode 100644 index 0000000000..2f851b5f78 --- /dev/null +++ b/cvpcb/makefile.include @@ -0,0 +1,141 @@ +# makefile pour cvpcb (mingw) +OBJSUFF = o + +EXTRACPPFLAGS = -DCVPCB -I./ -I../cvpcb -I../include -Ibitmaps -I../pcbnew -I../3d-viewer +EXTRALIBS = ../common/common.a + +LIBVIEWER3D = ../3d-viewer/3d-viewer.a + +# DEPEND = cvpcb.h ../include/pcbstruct.h + +OBJECTS = $(TARGET).o \ + class_cvpcb.o\ + memoire.o \ + cvframe.o\ + listboxes.o\ + drawframe.o\ + class_pcb_text.o\ + class_cotation.o\ + class_mire.o\ + displayframe.o\ + drawpanel.o \ + init.o rdpcad.o \ + readschematicnetlist.o\ + viewlogi.o viewlnet.o \ + loadcmp.o savecmp.o \ + tool_cvpcb.o \ + writenetlistpcbnew.o\ + genequiv.o \ + ioascii.o \ + menucfg.o \ + cfg.o listlib.o \ + infospgm.o autosel.o \ + setvisu.o\ + dialog_display_options.o\ + zoom.o \ + visumod.o\ + tracemod.o \ + classpcb.o \ + class_board.o \ + class_module.o \ + class_pad.o \ + class_text_mod.o \ + class_edge_mod.o \ + class_equipot.o \ + class_track.o\ + basepcbframe.o + +cvpcb.o: cvpcb.cpp cvpcb.h $(DEPEND) + +displayframe.o: displayframe.cpp $(DEPEND) + +listboxes.o: listboxes.cpp $(DEPEND) + +drawpanel.o: ../share/drawpanel.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +drawframe.o: ../share/drawframe.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +init.o: init.cpp $(DEPEND) + +memoire.o: memoire.cpp $(DEPEND) + +rdpcad.o: rdpcad.cpp $(DEPEND) + +classpcb.o: ../pcbnew/classpcb.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +class_mire.o: ../pcbnew/class_mire.cpp ../pcbnew/class_mire.h $(COMMON) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +class_cotation.o: ../pcbnew/class_cotation.cpp ../pcbnew/class_cotation.h $(COMMON) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +class_pcb_text.o: ../pcbnew/class_pcb_text.cpp ../pcbnew/class_pcb_text.h $(COMMON) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +class_board.o: ../pcbnew/class_board.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +class_track.o: ../pcbnew/class_track.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +class_pad.o: ../pcbnew/class_pad.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +class_module.o: ../pcbnew/class_module.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +class_text_mod.o: ../pcbnew/class_text_mod.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +class_edge_mod.o: ../pcbnew/class_edge_mod.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +class_equipot.o: ../pcbnew/class_equipot.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +basepcbframe.o: ../pcbnew/basepcbframe.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +readschematicnetlist.o: readschematicnetlist.cpp $(DEPEND) + +viewlogi.o: viewlogi.cpp $(DEPEND) + +viewlnet.o: viewlnet.cpp $(DEPEND) + +loadcmp.o: loadcmp.cpp $(DEPEND) + +savecmp.o: savecmp.cpp $(DEPEND) + +writenetlistpcbnew.o: writenetlistpcbnew.cpp $(DEPEND) + +genequiv.o: genequiv.cpp $(DEPEND) + +ioascii.o: ../pcbnew/ioascii.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +listlib.o: listlib.cpp $(DEPEND) + +cfg.o: cfg.cpp cfg.h $(DEPEND) + +menucfg.o: menucfg.cpp dialog_cvpcb_config.cpp dialog_cvpcb_config.h $(DEPEND) + +infospgm.o: ../share/infospgm.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +autosel.o: autosel.cpp $(DEPEND) + +setvisu.o: setvisu.cpp $(DEPEND) + +zoom.o: ../share/zoom.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +visumod.o: visumod.cpp $(DEPEND) + +tracemod.o: ../pcbnew/tracemod.cpp ../include/gr_basic.h $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +dialog_display_options.o: dialog_display_options.cpp dialog_display_options.h $(DEPEND) + diff --git a/cvpcb/makefile.macosx b/cvpcb/makefile.macosx new file mode 100644 index 0000000000..a484d6b5fa --- /dev/null +++ b/cvpcb/makefile.macosx @@ -0,0 +1,42 @@ +# File: makefile + +# Compiler flags. +CC = gcc +LD = g++ + +FINAL = 1 + +# Compiler flags. + +CPPFLAGS = -Wall -O2 `wx-config --cxxflags` + +LDFLAGS = + +EDACPPFLAGS = $(CPPFLAGS) + +include ../libs.macosx + + +TARGET = cvpcb + +all: $(TARGET) + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + + +$(TARGET): $(OBJECTS) $(TARGET).r makefile.macosx makefile.include $(EXTRALIBS) ../libs.macosx $(LIBVIEWER3D) + $(LD) $(OBJECTS) $(LDFLAGS) $(LIBVIEWER3D) $(LIBS3D) -o $(TARGET) + $(RESCOMP) -o $(TARGET) Carbon.r $(TARGET).r + $(SETFILE) -a C $(TARGET) + + +install: + cp -f $(TARGET) $(KICAD_BIN) + +clean: + rm *.o + rm $(TARGET) + diff --git a/cvpcb/memoire.cpp b/cvpcb/memoire.cpp new file mode 100644 index 0000000000..ca87bd4acc --- /dev/null +++ b/cvpcb/memoire.cpp @@ -0,0 +1,58 @@ + /**********************************************/ + /* Routines de gestion de la memoire */ + /**********************************************/ + + /* Fichier memoire.cpp */ + +#include "fctsys.h" +#include "wxstruct.h" +#include "common.h" +#include "cvpcb.h" + + +/********************************/ +void FreeMemoryModules(void) +/********************************/ + +/* Routine de liberation memoire de la liste des modules + - remet a NULL g_BaseListePkg + - remet a 0 nblib; +*/ +{ +STOREMOD * Module, * NextMod; + + if( g_BaseListePkg == NULL) return; + + for ( Module = g_BaseListePkg; Module != NULL; Module = NextMod) + { + NextMod = Module->Pnext; + delete Module; + } + + nblib = 0; + g_BaseListePkg = NULL; +} + +/***********************************/ +void FreeMemoryComponants(void) +/***********************************/ + +/* Routine de liberation memoire de la liste des composants + - remet a NULL BaseListeMod + - remet a 0 nbcomp +*/ +{ +STORECMP * Cmp, * NextCmp; + + if( g_BaseListeCmp == NULL ) return; + + for( Cmp = g_BaseListeCmp; Cmp != NULL; Cmp = NextCmp ) + { + NextCmp = Cmp->Pnext; + delete Cmp; + } + + nbcomp = 0; + g_BaseListeCmp = NULL; +} + diff --git a/cvpcb/menucfg.cpp b/cvpcb/menucfg.cpp new file mode 100644 index 0000000000..56b7f4c60b --- /dev/null +++ b/cvpcb/menucfg.cpp @@ -0,0 +1,325 @@ + /***************************************/ + /** menucfg : configuration de CVPCB **/ + /***************************************/ + +/* cree et/ou affiche et modifie la configuration de CVPCB */ + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWindows headers +#ifndef WX_PRECOMP +#include +#endif + +#include "fctsys.h" +#include "common.h" + +#include "cvpcb.h" +#include "protos.h" + + +/* Routines Locales */ + + + /*****************************************/ + /* classe pour la frame de Configuration */ + /*****************************************/ +#include "dialog_cvpcb_config.cpp" + + + +/***************************************************/ +void WinEDA_CvpcbFrame::CreateConfigWindow(void) +/***************************************************/ +/* Creation de la fenetre de configuration de CVPCB */ +{ +KiConfigCvpcbFrame * ConfigFrame = new KiConfigCvpcbFrame(this); + ConfigFrame->ShowModal(); ConfigFrame->Destroy(); +} + + +/*********************************************/ +void KiConfigCvpcbFrame::SetDialogDatas(void) +/*********************************************/ +{ + m_ListLibr->InsertItems(g_LibName_List,0); + m_ListEquiv->InsertItems(g_ListName_Equ,0); + + switch( g_NetType ) + { + case TYPE_NON_SPECIFIE: + case TYPE_ORCADPCB2: + m_NetFormatBox->SetSelection(0); + break; + + case TYPE_PCAD: + break; + + case TYPE_VIEWLOGIC_WIR: + m_NetFormatBox->SetSelection(1); + break; + + case TYPE_VIEWLOGIC_NET: + m_NetFormatBox->SetSelection(2); + break; + + default: + break; + } + + m_LibDirCtrl = new WinEDA_EnterText(this, + _("Lib Dir:"), g_UserLibDirBuffer, + m_RightBoxSizer, wxDefaultSize); + + m_NetInputExtCtrl = new WinEDA_EnterText(this, + _("Net Input Ext:"),NetInExtBuffer, + m_NetExtBoxSizer, wxDefaultSize); + + m_PkgExtCtrl = new WinEDA_EnterText(this, + _("Pkg Ext:"), PkgInExtBuffer, + m_PkgExtBoxSizer, wxDefaultSize); + + wxString DocModuleFileName = + EDA_Appl->m_EDA_CommonConfig->Read( wxT("module_doc_file"), wxT("pcbnew/footprints.pdf")); + m_TextHelpModulesFileName = new WinEDA_EnterText(this, + _("Module Doc File:"), DocModuleFileName, + m_RightBoxSizer, wxDefaultSize); + + /* Create info on Files ext */ + wxStaticText * StaticText; + wxString text; + text.Printf( wxT("%s %s"), _("Cmp ext:"), g_ExtCmpBuffer.GetData() ); + StaticText = new wxStaticText(this, -1,text); + m_FileExtList->Add(StaticText, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxADJUST_MINSIZE); + + text.Printf( wxT("%s %s"), _("Lib ext:"), LibExtBuffer.GetData()); + StaticText = new wxStaticText(this, -1,text); + m_FileExtList->Add(StaticText, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxADJUST_MINSIZE); + + text.Printf( wxT("%s %s"), _("NetOut ext:"), NetExtBuffer.GetData()); + StaticText = new wxStaticText(this, -1,text); + m_FileExtList->Add(StaticText, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxADJUST_MINSIZE); + + text.Printf( wxT("%s %s"), _("Equiv ext:"), g_EquivExtBuffer.GetData()); + StaticText = new wxStaticText(this, -1,text); + m_FileExtList->Add(StaticText, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxADJUST_MINSIZE); + + text.Printf( wxT("%s %s"), _("Retro ext:"), ExtRetroBuffer.GetData()); + StaticText = new wxStaticText(this, -1,text); + m_FileExtList->Add(StaticText, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxADJUST_MINSIZE); +} + +/********************************************************/ +void KiConfigCvpcbFrame::AcceptCfg(wxCommandEvent& event) +/********************************************************/ +{ + Update(); + Close(); +} + +/**********************************/ +void KiConfigCvpcbFrame::Update(void) +/**********************************/ +{ +wxString msg; + + if ( ! m_DoUpdate ) return; + NetInExtBuffer = m_NetInputExtCtrl->GetValue(); + PkgInExtBuffer = m_PkgExtCtrl->GetValue(); + EDA_Appl->m_EDA_CommonConfig->Write( wxT("module_doc_file"), + m_TextHelpModulesFileName->GetValue()); + + msg = m_LibDirCtrl->GetValue(); + if ( msg != g_UserLibDirBuffer ) + { + g_UserLibDirBuffer = m_LibDirCtrl->GetValue(); + SetRealLibraryPath( wxT("modules") ); + listlib(); + ListModIsModified = 1; + m_Parent->BuildFootprintListBox(); + } +} + + +/****************************************************/ +void KiConfigCvpcbFrame::SaveCfg(wxCommandEvent& event) +/****************************************************/ +{ + Update(); + Save_Config(this); +} + +/******************************************************/ +void KiConfigCvpcbFrame::ReadOldCfg(wxCommandEvent& event) +/******************************************************/ +{ +wxString line; + + NetInNameBuffer.Replace(WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP); + +wxString FullFileName = NetInNameBuffer.AfterLast('/'); + + ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); + + FullFileName = EDA_FileSelector(_("Read config file"), + wxGetCwd(), /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + g_Prj_Config_Filename_ext, /* extension par defaut */ + FullFileName, /* Masque d'affichage */ + this, + wxFD_OPEN, + TRUE /* ne change pas de repertoire courant */ + ); + if ( FullFileName.IsEmpty() ) return; + if ( ! wxFileExists(FullFileName) ) + { + line.Printf( _("File %s not found"), FullFileName.GetData()); + DisplayError(this, line); return; + } + + Read_Config( FullFileName ); + m_DoUpdate = FALSE; + Close(TRUE); +} + + +/*******************************************************/ +void KiConfigCvpcbFrame::LibDelFct(wxCommandEvent& event) +/*******************************************************/ +{ +int ii; + + ii = m_ListLibr->GetSelection(); + if ( ii < 0 ) return; + + ListModIsModified = 1; + g_LibName_List.RemoveAt(ii); + + /* suppression de la reference dans la liste des librairies */ + m_ListLibr->Delete(ii); + + g_UserLibDirBuffer = m_LibDirCtrl->GetValue(); + SetRealLibraryPath( wxT("modules") ); + listlib(); + + m_Parent->BuildFootprintListBox(); + +} + +/********************************************************/ +void KiConfigCvpcbFrame::LibAddFct(wxCommandEvent& event) +/********************************************************/ +{ +int ii; +wxString FullFileName, ShortLibName, mask; + + ii = m_ListLibr->GetSelection(); + if ( event.GetId() == ADD_LIB ) /* Ajout apres selection */ + { + ii ++; + } + if ( ii < 0 ) ii = 0; + + Update(); + 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; + + ShortLibName = MakeReducedFileName(FullFileName,g_RealLibDirBuffer,LibExtBuffer); + + g_LibName_List.Insert(ShortLibName, ii); + + g_UserLibDirBuffer = m_LibDirCtrl->GetValue(); + SetRealLibraryPath( wxT("modules") ); + listlib(); + ListModIsModified = 1; + + m_Parent->BuildFootprintListBox(); + + m_ListLibr->Clear(); + m_ListLibr->InsertItems(g_LibName_List, 0); + +} + + +/********************************************************/ +void KiConfigCvpcbFrame::EquDelFct(wxCommandEvent& event) +/********************************************************/ +{ +int ii; + + ii = m_ListEquiv->GetSelection(); + if ( ii < 0 ) return; + + g_ListName_Equ.RemoveAt(ii); + m_ListEquiv->Delete(ii); +} + +/********************************************************/ +void KiConfigCvpcbFrame::EquAddFct(wxCommandEvent& event) +/********************************************************/ +{ +int ii; +wxString FullFileName, ShortLibName, mask; + + ii = m_ListEquiv->GetSelection(); + if ( event.GetId() == ADD_EQU ) ii ++; /* Ajout apres selection */ + if ( ii < 0 ) ii = 0; + + Update(); + 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; + + ShortLibName = MakeReducedFileName(FullFileName,g_RealLibDirBuffer,g_EquivExtBuffer); + + g_ListName_Equ.Insert(ShortLibName, ii); + + /* Mise a jour de l'affichage */ + g_UserLibDirBuffer = m_LibDirCtrl->GetValue(); + SetRealLibraryPath( wxT("modules") ); + listlib(); + + m_ListEquiv->Clear(); + m_ListEquiv->InsertItems(g_ListName_Equ, 0); +} + + + + +/*****************************************************************/ +void KiConfigCvpcbFrame::ReturnNetFormat(wxCommandEvent& event) +/*****************************************************************/ +{ +int ii; + + ii = m_NetFormatBox->GetSelection(); + g_NetType = TYPE_ORCADPCB2; + if ( ii == 1 ) g_NetType = TYPE_VIEWLOGIC_WIR; + if ( ii == 2 ) g_NetType = TYPE_VIEWLOGIC_NET; + +} + diff --git a/cvpcb/options.cpp b/cvpcb/options.cpp new file mode 100644 index 0000000000..33a514c488 --- /dev/null +++ b/cvpcb/options.cpp @@ -0,0 +1,225 @@ + /*****************************************************************/ + /** options.cpp: options pour la visualisation des composants **/ + /****************************************************************/ + +#include "fctsys.h" + +#include "wxstruct.h" +#include "common.h" +#include "cvpcb.h" +#include "protos.h" + +enum { + SET_OPTION = 8000, + SET_EDGE_FORMAT, + SET_TEXTE_FORMAT, + PADFILL_OPT, + PADNUM_OPT, + EDGE_SELECT, + TEXT_SELECT, + ID_SAVE_CONFIG + }; + + +/********************************************/ +/* Classes derivees pour la fenetre Options */ +/********************************************/ + +class wxMyCheckBox: public wxCheckBox +{ +private: +protected: +public: + bool * BoolVar; + + // Constructor and destructor + wxMyCheckBox(wxWindow *parent, int id, const wxString & Title, + bool * RefVar, wxPoint& pos); + ~wxMyCheckBox(void) { }; +}; + + + /************************************************************/ + /* classe derivee pour la fenetre de selection des options */ + /* d'affichage du module */ + /************************************************************/ + +class wxOptionsBox: public wxDialog +{ +private: +protected: +public: + + WinEDA_BasePcbFrame * m_Parent; + wxMyCheckBox * IsShowPadFill; + wxMyCheckBox * IsShowPadNum; + wxRadioBox * EdgeRadioBox; + wxRadioBox *TextRadioBox; + + // Constructor and destructor + wxOptionsBox(WinEDA_BasePcbFrame * parent, wxPoint& pos); + ~wxOptionsBox(void); + + bool OnClose(void); + void SetOptPadFill( wxCommandEvent& event); + void SetOptPadNum( wxCommandEvent& event); + void ReturnDisplayEdgeFormat(wxCommandEvent& event); + void ReturnDisplayTexteFormat(wxCommandEvent& event); + void SaveConfig(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() +}; +BEGIN_EVENT_TABLE(wxOptionsBox, wxDialog ) + EVT_CHECKBOX(PADFILL_OPT, wxOptionsBox::SetOptPadFill) + EVT_CHECKBOX(PADNUM_OPT, wxOptionsBox::SetOptPadNum) + EVT_RADIOBOX(EDGE_SELECT, wxOptionsBox::ReturnDisplayEdgeFormat) + EVT_RADIOBOX(TEXT_SELECT, wxOptionsBox::ReturnDisplayTexteFormat) + EVT_BUTTON(ID_SAVE_CONFIG, wxOptionsBox::SaveConfig) +END_EVENT_TABLE() + + +/*********************************************************************/ +void WinEDA_DisplayFrame::InstallOptionsDisplay(wxCommandEvent& event) +/*********************************************************************/ +/* Creation de la fenetre d'options de la fenetre de visu */ +{ +wxPoint pos; + + GetPosition(&pos.x, &pos.y); + pos.x += 10; if (pos.x < 0 ) pos.x = 0; + pos.y += 50; if (pos.y < 0 ) pos.y = 0; + + wxOptionsBox * OptionWindow = new wxOptionsBox(this, pos); + OptionWindow->ShowModal(); OptionWindow->Destroy(); +} + + + + /********************************/ + /* Constructeur de wxMyCheckBox */ + /********************************/ + +wxMyCheckBox::wxMyCheckBox(wxWindow *parent, int id, const wxString & Title, + bool * RefVar, wxPoint& pos): + wxCheckBox(parent, id, Title, pos) +{ + BoolVar = RefVar; + if( * BoolVar ) this->SetValue(TRUE); + else this->SetValue(FALSE); +} + + +/******************************************************/ +void wxOptionsBox::SetOptPadFill(wxCommandEvent& event) +/******************************************************/ +{ + *IsShowPadFill->BoolVar == 0 ? + * IsShowPadFill->BoolVar = 1 : * IsShowPadFill->BoolVar = 0; + DisplayOpt.DisplayPadFill = m_Parent->m_DisplayPadFill = IsShowPadFill->BoolVar; + m_Parent->ReDrawPanel(); +} + +/******************************************************/ +void wxOptionsBox::SetOptPadNum(wxCommandEvent& event) +/******************************************************/ +{ + *IsShowPadNum->BoolVar == 0 ? + *IsShowPadNum->BoolVar = TRUE : *IsShowPadNum->BoolVar = FALSE; + + DisplayOpt.DisplayPadNum = m_Parent->m_DisplayPadNum = IsShowPadNum->BoolVar; + m_Parent->ReDrawPanel(); +} + + /********************************/ + /* Constructeur de wxOptionsBox */ + /********************************/ + +wxOptionsBox::wxOptionsBox(WinEDA_BasePcbFrame * parent, wxPoint& bpos): + wxDialog(parent, -1, _("Options"), bpos, wxSize(220, 195), + DIALOG_STYLE) +{ +wxPoint pos; + + m_Parent = parent; + + SetFont(*g_DialogFont); + + pos.x = 100; pos.y = 15; + new wxButton(this, ID_SAVE_CONFIG, _("Save Cfg"), pos); + + pos.x = 10; pos.y = 10; + IsShowPadFill = new wxMyCheckBox(this, + PADFILL_OPT, + _("&Pad Fill"), + &DisplayOpt.DisplayPadFill, pos); + + pos.y += 20; + IsShowPadNum = new wxMyCheckBox(this, + PADNUM_OPT, + _("Pad &Num"), + &DisplayOpt.DisplayPadNum, pos); + + pos.y += 25; +wxString DrawOpt[] = { _("&Filaire"), _("&Filled"), _("&Sketch")}; + EdgeRadioBox = new wxRadioBox(this, EDGE_SELECT, + _("Edges:"), + pos, wxSize(-1,-1), + 3,DrawOpt,1,wxRA_SPECIFY_COLS); + + EdgeRadioBox->SetSelection(DisplayOpt.DisplayModEdge); + + pos.x += 100; + TextRadioBox = new wxRadioBox(this, TEXT_SELECT, + _("Texts:"), + pos,wxSize(-1,-1), + 3, DrawOpt, 1,wxRA_SPECIFY_COLS); + + TextRadioBox->SetSelection(DisplayOpt.DisplayModText); + +} + + /*****************************/ + /* Destructeur de OptionsBox */ + /*****************************/ + +wxOptionsBox::~wxOptionsBox(void) +{ +} + + + /**************************************/ + /* Fonctions de base de wxMyDialogBox */ + /**************************************/ + +/*******************************/ +bool wxOptionsBox::OnClose(void) +/*******************************/ +{ + Show(FALSE); + return TRUE; +} + +/****************************************************************/ +void wxOptionsBox::ReturnDisplayEdgeFormat(wxCommandEvent& event) +/****************************************************************/ +{ + DisplayOpt.DisplayModEdge = m_Parent->m_DisplayModEdge = EdgeRadioBox->GetSelection(); + m_Parent->ReDrawPanel(); +} + +/****************************************************************/ +void wxOptionsBox::ReturnDisplayTexteFormat(wxCommandEvent& event) +/****************************************************************/ +{ + DisplayOpt.DisplayModText = m_Parent->m_DisplayModText = TextRadioBox->GetSelection(); + m_Parent->ReDrawPanel(); +} + + +/***************************************************/ +void wxOptionsBox::SaveConfig(wxCommandEvent& event) +/***************************************************/ +{ + Save_Config(this); +} + diff --git a/cvpcb/protos.h b/cvpcb/protos.h new file mode 100644 index 0000000000..97f31df270 --- /dev/null +++ b/cvpcb/protos.h @@ -0,0 +1,131 @@ + /**************************************/ + /** protos.h liste des fonctions **/ + /**************************************/ + +#ifndef PROTOS_H +#define PROTOS_H + +class DESCR_EDGE; + +int reaffect( char *ib, char *net) ; +int GenNetlistPcbnew(void) ; +int loadcmp(void) ; +int listlib(void) ; +STOREMOD * GetModuleDescrByName(const wxString & FootprintName); + + /***********/ + /* CVPCB.CPP */ + /***********/ +void ModListProcedure(wxListBox& list, wxCommandEvent& event); + + /***********/ + /* CFG.CPP */ + /***********/ + +void Save_Config(wxWindow * parent); +void Read_Config( const wxString & FullFileName ); /* lit la configuration */ + + /**************/ + /* VISUMOD.CC */ + /**************/ + +void AfficheModule(WinEDA_DrawPanel * panel, wxDC * DC); /* Affiche le module courant dans un cadre */ +void Set_Rectangle_Encadrement(MODULE * PtModule); + /* Mise a jour du rectangle d'encadrement du module + Entree : pointeur sur module */ + +void DeleteStructure( void * GenericStructure ); + /* Supprime de la liste chainee la stucture pointee par GenericStructure + et libere la memoire correspondante */ + + /**************/ + /* MEMOIRE.CC */ + /**************/ +void FreeMemoryComponants(void); + /* Routine de liberation memoire de la liste des composants + - remet a NULL BaseListeMod + - remet a 0 NbComp */ + +void FreeMemoryModules(void); + /* Routine de liberation memoire de la liste des modules + - remet a NULL g_BaseListePkg + - rement a 0 NbLib; */ + + + /***************/ + /* TRACEMOD.CC */ + /***************/ + +void Trace_empreinte(WinEDA_DrawPanel * panel, wxDC * DC, + MODULE * Module,int ox, int oy,int mode_color); +void Trace_1_Pad(WinEDA_DrawPanel * panel, wxDC * DC, + D_PAD* ptr_pad,int ox, int oy,int mode_color); +void Trace_Ancre_Module(WinEDA_DrawPanel * panel, + wxDC * DC, MODULE * Module, int ox, int oy, int dim, int mode_color); +void Trace_DrawSegmentModule(WinEDA_DrawPanel * panel, wxDC * DC, DESCR_EDGE* PtDrawSegment, + int ox, int oy, int mode_color); +void Gr_E_texte(WinEDA_DrawPanel * panel, wxDC * DC, + MODULE * Module, TEXTE_MODULE * ptr,int ox,int oy,int mode_color) ; +void Trace_Contour_Module(WinEDA_DrawPanel * panel, wxDC * DC, + EDA_BaseStruct * PtStruct, + int ox, int oy, int mode_color); + + +void Affiche_1_Segment(WinEDA_DrawPanel * panel, wxDC * DC, + int ux0, int uy0, int dx, int dy, + int width, int mode, int color); + +/**************/ +/* RDORCAD.CC */ +/**************/ + +STORECMP * TriListeComposantss(STORECMP * BaseListe, int nbitems); + /* Tri la liste des composants par ordre alphabetique et me a jour + le nouveau chainage avant/arriere + retourne un pointeur sur le 1er element de la liste */ + +int CmpCompare( void * cmp1, void * cmp2); /* routine pour qsort() + de tri de liste des composants */ + + +/***************/ +/* viewlogi.cc */ +/***************/ +int ReadViewlogicWirList(void); + +/***************/ +/* viewlnet.cc */ +/***************/ +int ReadViewlogicNetList(void); + +/***************/ +/* TRACEMOD.CC */ +/***************/ +void Display_1_Texte(WinEDA_DrawPanel * panel, wxDC * DC, + const char * Text, int Nmax, int ox, int oy, + int size_h, int size_v, int width, int orient, int Color); + /* Affichage de 1 texte a l'ecran. Parametres: + char * Text = pointeur sur le texte a afficher + int Nmax = Nombre max de caracteres a afficher + int ox, int oy = coord de trace relatives ( absolue - offset ) + int size_h = taille H, si < 0: affichage en miroir. + int size_v = taille V + int width = epaisseur; si = 0 ou 1: affichage en filaire. + int orient = orientation en 0,1 degre + int Color = couleur | mode */ + +/**********/ +/* COLORS */ +/**********/ +void BuildPensBrushes(void); +void FreePensBrushes(void); +int GetNewColor(wxWindow * Frame, int OldColor = -1); /* Routine de selection d'une couleur */ + +/***********/ +/* OPTIONS */ +/***********/ +void CreateOptionsWindow(WinEDA_DrawFrame * parent); + /* Creation de la fenetre d'options de la fenetre de visu */ + +#endif // PROTOS_H + diff --git a/cvpcb/rdorcad.cpp b/cvpcb/rdorcad.cpp new file mode 100644 index 0000000000..be850980e7 --- /dev/null +++ b/cvpcb/rdorcad.cpp @@ -0,0 +1,320 @@ + /************/ + /* rdorcad()*/ + /************/ + +/* convertit la netliste ORCADPCB en netliste ORCADPCB (fichier temporaire) +assure la r‚affectation des alimentations selon le format : +( XXXXXX VALEUR|(pin1,pin2,...=newalim) ID VALEUR +*/ + +#include "fctsys.h" + +#include "wxstruct.h" +#include "common.h" +#include "cvpcb.h" + +#include "protos.h" + +#define SEPARATEUR '|' /* caractere separateur dans netliste */ + +/* routines locales : */ + +int pin_orcad(STORECMP * CurrentCmp); + + + /****************************************/ + /* int WinEDA_CvpcbFrame::rdorcad(void) */ + /****************************************/ + +int WinEDA_CvpcbFrame::rdorcad(void) +{ +int i , j , k ,l ; +char * LibName; +char Line[1024]; +int FlagEESchema = 0; +char label[80] ; /* buffer des references composants */ +char ref_schema[80] ; /* buffer de la ref schematique */ +char val[80] ; /* buffer des valeurs/ref.lib */ +char postval[80] ; /* buffer de la valeur de fin de ligne (vraie valeur) */ +char *ptchar ; /* pointeur de service */ +STORECMP * Cmp; + + modified = 0; + Rjustify = 0; + + /* Raz buffer et variable de gestion */ + if( BaseListeCmp ) FreeMemoryComponants(); + + /* Ouverture du fichier source */ + source = wxFopen(FFileName, wxT("rt")); + if (source == 0) + { + wxString msg; + msg.Printf( _("File <%s> not found"),FFileName.GetData()); + DisplayError(this, msg); return(-1); + } + + /* Read the file header (must be "( { OrCAD PCB" or "({ OrCAD PCB" ) */ + /* or "# EESchema Netliste"*/ + fgets(Line,255,source) ; + /* test for netlist type PCB2 */ + i = strnicmp(Line,"( {",3) ; + if( i != 0 ) + i = strnicmp(Line,"({",2) ; + if( i != 0 ) + { + i = strnicmp(Line,"# EESchema",7) ; /* net type EESchema */ + if( i == 0 ) FlagEESchema = 1; + } + + if ( i != 0 ) + { + wxString msg, Lineconv = CONV_FROM_UTF8(Line); + msg.Printf( _("Unknown file format <%s>"), Lineconv.GetData()); + DisplayError(this, msg); + fclose(source); return(-3) ; + } + + SetStatusText( _("Netlist Format: EESchema"), 0); + + + /* Lecture de la liste */ + for (;;) + { + /* recherche du debut de la description d'un composant */ + + if( fgets(Line,80,source) == 0 ) break; + + /* suppression des blancs en d‚but de ligne */ + i = 0 ; while (Line[i] == ' ') i++ ; + + /* elimination des lignes vides : */ + if (Line[i] < ' ') continue ; + + if (strnicmp(&Line[i],"( ",2) != 0) continue ; + + /****************************/ + /* debut description trouve */ + /****************************/ + /* memo ident schema */ + while ( Line[i] != ' ') i++ ; + while ( Line[i] == ' ') i++ ; /* i pointe 1er caractere de l'ident schema */ + + j = 0 ; while ( Line[i] != ' ') ref_schema[j++] = Line[i++] ; + ref_schema[j] = 0 ; + + /* recherche val/ref.lib */ + while ( Line[i] == ' ') i++ ; /* i pointe la valeur du composant */ + LibName = Line + i; + + memset(label, 0, sizeof(label)); + memset(val, 0, sizeof(val) ) ; + memset(postval, 0, sizeof(postval) ) ; + memset(alim, 0, sizeof(alim) ) ; + + /* lecture valeur du composant */ + + /* recherche fin de valeur (' ') */ + ptchar = strstr(&Line[i]," ") ; + if (ptchar == 0) + { + wxString msg; + msg.Printf( _("Netlist error: %s"),Line) ; + DisplayError(NULL, msg); + k = 0 ; + } + else k = ptchar - Line ; + + for (j = 0 ; i < k ; i++) + { + if ( Line[i] == SEPARATEUR ) break ; + if ( j < 8 ) val[j++] = Line[i] ; + } + + if ( (Line[++i] == '(') && (Line[k-1] == ')' ) ) + { + i++ ; l = 0 ; while ( k-1 > i ) alim[l++] = Line[i++] ; + } + + else i = k ; + + /* recherche reference du composant */ + while(Line[i] != ' ') i++ ; /* elimination fin valeur */ + while(Line[i] == ' ') i++ ; /* recherche debut reference */ + + /* debut reference trouv‚ */ + for ( k = 0 ; k < 8 ; i++ , k++ ) + { + if ( Line[i] <= ' ' ) break ; + label[k] = Line[i] ; + } + + /* recherche vraie valeur du composant */ + while(Line[i] != ' ') i++ ; /* elimination fin reference */ + while(Line[i] == ' ') i++ ; /* recherche debut vraie valeur */ + + /* debut vraie valeur trouv‚e */ + for ( k = 0 ; k < 16 ; i++ , k++ ) + { + if ( Line[i] <= ' ' ) break ; + postval[k] = Line[i] ; + } + + + /* classement du composant ,suivi de sa valeur */ + Cmp = new STORECMP(); + Cmp->Pnext = BaseListeCmp; + BaseListeCmp = Cmp; + Cmp->m_Reference = CONV_FROM_UTF8(label); + Cmp->m_Valeur = CONV_FROM_UTF8(postval) ; + + if( FlagEESchema ) /* Copie du nom module: */ + { + if( strnicmp(LibName, "$noname", 7 ) != 0 ) + { + while( *LibName > ' ' ) + { + Cmp->m_Module.Append(*LibName); + LibName++; + } + } + } + /* classement du TimeStamp */ + Cmp->m_TimeStamp = CONV_FROM_UTF8(ref_schema); + + pin_orcad( Cmp) ; + + nbcomp++ ; + } + fclose(source); + + /* reclassement alpab‚tique : */ + BaseListeCmp = TriListeComposantss( BaseListeCmp, nbcomp); + + return(0); +} + +/***********************************/ +int pin_orcad(STORECMP * Cmp) +/***********************************/ +{ +int i , jj; +char numpin[9] , net[1024] ; +char Line[1024]; +STOREPIN * Pin = NULL; +STOREPIN ** LastPin = & Cmp->m_Pins; + +for ( ;; ) + { + /* debut description trouv‚ */ + for ( ;; ) + { + if ( fgets(Line,80,source) == 0 ) return(-1) ; + + /* suppression des blancs en d‚but de ligne */ + i = 0 ; while (Line[i] == ' ') i++ ; + while (Line[i] == '(') i++ ; + while (Line[i] == ' ') i++ ; + + /* elimination des lignes vides : */ + if (Line[i] < ' ') continue ; + + /* fin de description ? */ + if (Line[i] == ')' ) return(0) ; + + memset( net, 0, sizeof(net) ); + memset( numpin, 0, sizeof(numpin) ); + + /* lecture name pin , 4 lettres */ + for (jj = 0 ; jj < 4 ; jj++ , i++) + { + if ( Line[i] == ' ' ) break ; + numpin[jj] = Line[i] ; + } + + /* recherche affectation forc‚e de net */ + if ( reaffect(numpin,net) != 0) + { + Pin = new STOREPIN(); + *LastPin = Pin; LastPin = &Pin->Pnext; + Pin->m_PinNum = CONV_FROM_UTF8(numpin); + Pin->m_PinNet = CONV_FROM_UTF8(net); + continue ; + } + + /* recherche netname */ + while(Line[i] == ' ') i++ ; /* recherche debut reference */ + + /* debut netname trouv‚ */ + for ( jj = 0 ; jj < (int)sizeof(net)-1 ; i++ , jj++ ) + { + if ( Line[i] <= ' ' ) break ; + net[jj] = Line[i] ; + } + + Pin = new STOREPIN(); + *LastPin = Pin; LastPin = &Pin->Pnext; + Pin->m_PinNum = CONV_FROM_UTF8(numpin); + Pin->m_PinNet = CONV_FROM_UTF8(net); + } + } +} + + +/****************************************************************/ +STORECMP * TriListeComposantss(STORECMP * BaseListe, int nbitems) +/****************************************************************/ +/* Tri la liste des composants par ordre alphabetique et me a jour +le nouveau chainage avant/arriere + retourne un pointeur sur le 1er element de la liste +*/ +{ +STORECMP ** bufferptr, * Item; +int ii; + + if (nbitems <= 0 ) return(NULL); + bufferptr = (STORECMP**)MyZMalloc( (nbitems+2) * sizeof(STORECMP*) ); + + for( ii= 1, Item = BaseListe; Item != NULL; Item = Item->Pnext, ii++) + { + bufferptr[ii] = Item; + } + + /* ici bufferptr[0] = NULL et bufferptr[nbitem+1] = NULL et ces 2 valeurs + representent le chainage arriere du 1er element, et le chainage avant + du dernier element */ + + qsort(bufferptr+1,nbitems,sizeof(STORECMP*), + (int(*)(const void*,const void*))CmpCompare) ; + /* Mise a jour du chainage */ + for( ii = 1; ii <= nbitems; ii++ ) + { + Item = bufferptr[ii]; + Item->m_Num = ii; + Item->Pnext = bufferptr[ii+1]; + Item->Pback = bufferptr[ii-1]; + } + return(bufferptr[1]); +} + + +/****************************************/ +int CmpCompare(void * mod1, void * mod2) +/****************************************/ +/* +routine compare() pour qsort() en classement alphabetique des composants +*/ +{ +int ii; +STORECMP *pt1 , *pt2 ; + + pt1 = * ((STORECMP**)mod1); + pt2 = * ((STORECMP**)mod2); + + //FIXME: + ii = StrNumICmp( (const wxChar*) pt1->m_Reference, (const wxChar*) pt2->m_Reference ); + return(ii); +} + + + diff --git a/cvpcb/rdpcad.cpp b/cvpcb/rdpcad.cpp new file mode 100644 index 0000000000..8f0aed331c --- /dev/null +++ b/cvpcb/rdpcad.cpp @@ -0,0 +1,274 @@ + /****************/ + /* rdpcad() */ + /***************/ + +/* convertit la netliste PCAD en netliste standard (fichier temporaire) +assure la reaffectation des alimentations selon le format : +{I VALEUR(pin1,pin2,...=newalim).PRT ID +*/ + +#include "fctsys.h" + +#include "wxstruct.h" +#include "common.h" +#include "colors.h" +#include "cvpcb.h" +#include "protos.h" + +#define SEPARATEUR '|' + +/* routines locales : */ +int pin(void) ; + +/***************************************/ +int WinEDA_CvpcbFrame::rdpcad(void) +/***************************************/ +{ +int i , j , k ,l ; +char Line[1024]; +char label[80] ; /* buffer des references composants */ +char val[80] ; /* buffer des valeurs */ +char *ptchar ; /* pointeur de service */ +STORECMP * Cmp; + + modified = 0; + Rjustify = 0; + + /* Raz buffer et variable de gestion */ + if( g_BaseListeCmp ) FreeMemoryComponants(); + + /* Ouverture du fichier source */ + source = wxFopen(FFileName, wxT("rt")); + if (source == 0) + { + wxString msg; + msg.Printf( _("File <%s> not found"),FFileName.GetData()); + DisplayError(this, msg); return(-1); + } + + /* Lecture entete qui doit etre "{COMPONENT ORCAD.PCB" ou "{ OrCAD PCB"*/ + fgets(Line,255,source) ; + i = strncmp(Line,"{COMPONENT ORCAD.PCB",9) ; /* net type PCAD */ + + if ( i != 0 ) + { + wxString msg, Lineconv = CONV_FROM_UTF8(Line); + msg.Printf( _("Unknown file format <%s>"), Lineconv.GetData()); + DisplayError(this, msg); + fclose(source); return(-3) ; + } + + SetStatusText( _("Netlist Format: Pcad"), 0); + + /* Lecture de la liste */ + +for ( ;; ) + { + /* recherche du debut de la description d'un composant */ + + if ( fgets(Line,80,source) == 0 ) break ; + + /* suppression des blancs en d‚but de ligne */ + i = 0 ; while (Line[i] == ' ') i++ ; + + /* elimination des lignes vides : */ + if (Line[i] < ' ') continue ; + + if (strncmp(&Line[i],"{I",2) != 0) continue ; + + /****************************/ + /* debut description trouv‚ */ + /****************************/ + + i += 3 ; /* i pointe le 1er caractere de la valeur du composant */ + + for (j = 0 ; j < 20 ; j++) + { + label[j] = 0 ; val[j] = ' ' ; + } + val[16] = 0 ; + + for (j =0 ; j < 80 ; j++) alim[j] = 0 ; + + /* lecture valeur du composant ( toujours r‚ecrire sur 8 caracteres) */ + + /* recherche fin de valeur (.PRT) */ + ptchar = strstr(Line,".PRT") ; + if (ptchar == 0) + { + sprintf(cbuf,"Netlist error: %s\n",Line) ; +// Affiche_Message(cbuf) ; + } + k = ptchar - Line ; + + for (j = 0 ; i < k ; i++) + { + if ( Line[i] == SEPARATEUR ) break ; + if ( j < 8 ) val[j++] = Line[i] ; + } + + if ( (Line[++i] == '(') && (Line[k-1] == ')' ) ) + { + i++ ; l = 0 ; while ( k-1 > i ) alim[l++] = Line[i++] ; + } + + else i = k ; + + /* recherche reference du composant */ + while(Line[i] != ' ') i++ ; /* elimination fin valeur */ + while(Line[i] == ' ') i++ ; /* recherche debut reference */ + + /* debut reference trouv‚ */ + for ( k = 0 ; k < 8 ; i++ , k++ ) + { + if ( Line[i] <= ' ' ) break ; + label[k] = Line[i] ; + } + /* classement du composant ,suivi de sa valeur */ + Cmp = new STORECMP(); + Cmp->Pnext = g_BaseListeCmp; + g_BaseListeCmp = Cmp; + Cmp->m_Reference = CONV_FROM_UTF8(label); + Cmp->m_Valeur = CONV_FROM_UTF8(val); + pin() ; + nbcomp++ ; + } + + fclose(source); + + /* reclassement alpab‚tique : */ + g_BaseListeCmp = TriListeComposantss( g_BaseListeCmp, nbcomp); + + return(0); +} + + /***********************************/ + /* pin() : analyse liste des pines */ + /***********************************/ + +int pin(void) +{ +int i , j , k ; +char numpin[9] , net[9] ; +char Line[1024]; + +for ( ;; ) + { + /* recherche du debut de la description des pins d'un composant */ + + if ( fgets(Line,80,source) == 0 ) return(-1) ; + /* suppression des blancs en d‚but de ligne */ + i = 0 ; while (Line[i] == ' ') i++ ; + + /* elimination des lignes vides : */ + if (Line[i] < ' ') continue ; + + if (strncmp(&Line[i],"{CN",3) != 0) continue ; + + /* debut description trouv‚ */ + for ( ;; ) + { + if ( fgets(Line,80,source) == 0 ) return(-1) ; + /* suppression des blancs en d‚but de ligne */ + i = 0 ; while (Line[i] == ' ') i++ ; + + + /* elimination des lignes vides : */ + if (Line[i] < ' ') continue ; + + /* fin de description ? */ + if (Line[i] == '}' ) return(0) ; + + memset( net, 0, sizeof(net) ) ; + memset( numpin, 0, sizeof(numpin) ) ; + + + /* lecture name pin , 4 lettres */ + for (j = 0 ; j < 4 ; j++ , i++) + { + if ( Line[i] == ' ' ) break ; + numpin[j] = Line[i] ; + } + j = 0 ; + + /* recherche affectation forc‚e de net */ + if ( reaffect(&numpin[j],net) != 0) + { +// fprintf(dest,"%s:%s\n",&numpin[j],net) ; + continue ; + } + + /* recherche netname */ + while(Line[i] == ' ') i++ ; /* recherche debut reference */ + + /* debut netname trouv‚ */ + for ( k = 0 ; k < 8 ; i++ , k++ ) + { + if ( Line[i] <= ' ' ) break ; + net[k] = Line[i] ; + } + /* les pins non connect‚es sont ‚limin‚es :*/ + if (net[0] == '?' ) continue ; + +// fprintf(dest,"%s:%s\n",&numpin[j],net) ; + } + } +} + + +/**************************************/ +int reaffect( char *ib, char *net) +/**************************************/ +/* force un nom de net pour une pine +ib = reference de pin , net = nouveau net ; alim = ligne de consigne +*/ +{ +char *pt , *pt0 , npin[12] ; +int i ; + +pt = alim ; + +while (*pt != 0 ) + { + memset( npin, 0, sizeof(npin) ) ; + + /* recherche separateur (':' ou ',') */ + while ( (*pt != ':') && (*pt != ',') ) + { + pt++ ; if (*pt == 0 ) return(0) ; + } + /* suppression des blancs eventuels */ + pt0 = pt ; /* save position du nom du net */ + pt0-- ; while (*pt0 == ' ') pt0-- ; + + for (i = 3 ; i >= 0 ; i-- ) + { + if ( (*pt0 == ',') || (*pt0 ==' ')) break ; + npin[i] = *pt0 ; + if (pt0 == alim) break ; + pt0-- ; + } + + while ( npin[0] == ' ' ) /* suppression des espaces a gauche */ + { + npin[0] = npin[1] ; + npin[1] = npin[2] ; + npin[2] = npin[3] ; + npin[3] = ' ' ; + } + if (strncmp(npin,ib,4) == 0 ) /* pin trouv‚e */ + { + pt++ ; while ((*pt == ' ' ) && (*pt != 0 )) pt++ ; + i = 0 ; + while ((*pt != 0) && (*pt != ',') && ( i < 8 ) ) + { + net[i++] = *pt++ ; + } + net[i] = 0 ; + return(1) ; + } + pt++ ; + } +return(0) ; +} + diff --git a/cvpcb/readschematicnetlist.cpp b/cvpcb/readschematicnetlist.cpp new file mode 100644 index 0000000000..cdb5c65a30 --- /dev/null +++ b/cvpcb/readschematicnetlist.cpp @@ -0,0 +1,365 @@ +/***************************/ +/* readschematicnetlist.cpp*/ +/***************************/ + +/* convertit la netliste ORCADPCB en netliste ORCADPCB (fichier temporaire) +assure la r‚affectation des alimentations selon le format : +( XXXXXX VALEUR|(pin1,pin2,...=newalim) ID VALEUR +*/ + +#include "fctsys.h" + +#include "wxstruct.h" +#include "common.h" +#include "cvpcb.h" + +#include "protos.h" + +#define SEPARATEUR '|' /* caractere separateur dans netliste */ + +/* routines locales : */ + +static int pin_orcad(STORECMP * CurrentCmp); + + +/************************************************/ +int WinEDA_CvpcbFrame::ReadSchematicNetlist(void) +/************************************************/ +{ +int i , j , k ,l ; +char * LibName; +char Line[1024]; +char label[80] ; /* buffer des references composants */ +char ref_schema[80] ; /* buffer de la ref schematique */ +char val[80] ; /* buffer des valeurs/ref.lib */ +char postval[80] ; /* buffer de la valeur de fin de ligne (vraie valeur) */ +char *ptchar ; /* pointeur de service */ +STORECMP * Cmp; + + modified = 0; + Rjustify = 0; + g_FlagEESchema = FALSE; + + /* Raz buffer et variable de gestion */ + if( g_BaseListeCmp ) FreeMemoryComponants(); + + /* Ouverture du fichier source */ + source = wxFopen(FFileName, wxT("rt")); + if (source == 0) + { + wxString msg; + msg.Printf( _("File <%s> not found"),FFileName.GetData()); + DisplayError(this, msg); return(-1); + } + + /* Read the file header (must be "( { OrCAD PCB" or "({ OrCAD PCB" ) */ + /* or "# EESchema Netliste"*/ + fgets(Line,255,source) ; + /* test for netlist type PCB2 */ + i = strnicmp(Line,"( {",3) ; + if( i != 0 ) + i = strnicmp(Line,"({",2) ; + if( i != 0 ) + { + i = strnicmp(Line,"# EESchema",7) ; /* net type EESchema */ + if( i == 0 ) g_FlagEESchema = TRUE; + } + + if ( i != 0 ) + { + wxString msg, Lineconv = CONV_FROM_UTF8(Line); + msg.Printf( _("Unknown file format <%s>"), Lineconv.GetData()); + DisplayError(this, msg); + fclose(source); return(-3) ; + } + + SetStatusText( _("Netlist Format: EESchema"), 0); + + + /* Lecture de la liste */ + for (;;) + { + /* recherche du debut de la description d'un composant */ + + if( fgets(Line,255,source) == 0 ) break; + + /* Remove blanks */ + i = 0 ; while (Line[i] == ' ') i++ ; + + /* elimination des lignes vides : */ + if (Line[i] < ' ') continue ; + + if (strnicmp(&Line[i],"{ Allowed footprints", 20 ) == 0 ) + { + ReadFootprintFilterList(source); + continue; + } + + if (strnicmp(&Line[i],"( ",2) != 0) continue ; + + /****************************/ + /* debut description trouve */ + /****************************/ + /* memo ident schema */ + while ( Line[i] != ' ') i++ ; + while ( Line[i] == ' ') i++ ; /* i pointe 1er caractere de l'ident schema */ + + j = 0 ; while ( Line[i] != ' ') ref_schema[j++] = Line[i++] ; + ref_schema[j] = 0 ; + + /* recherche val/ref.lib */ + while ( Line[i] == ' ') i++ ; /* i pointe la valeur du composant */ + LibName = Line + i; + + memset(label, 0, sizeof(label)); + memset(val, 0, sizeof(val) ) ; + memset(postval, 0, sizeof(postval) ) ; + memset(alim, 0, sizeof(alim) ) ; + + /* lecture valeur du composant */ + + /* recherche fin de valeur (' ') */ + ptchar = strstr(&Line[i]," ") ; + if (ptchar == 0) + { + wxString msg; + msg.Printf( _("Netlist error: %s"),Line) ; + DisplayError(NULL, msg); + k = 0 ; + } + else k = ptchar - Line ; + + for (j = 0 ; i < k ; i++) + { + if ( Line[i] == SEPARATEUR ) break ; + if ( j < 8 ) val[j++] = Line[i] ; + } + + if ( (Line[++i] == '(') && (Line[k-1] == ')' ) ) + { + i++ ; l = 0 ; while ( k-1 > i ) alim[l++] = Line[i++] ; + } + + else i = k ; + + /* recherche reference du composant */ + while(Line[i] != ' ') i++ ; /* elimination fin valeur */ + while(Line[i] == ' ') i++ ; /* recherche debut reference */ + + /* debut reference trouv‚ */ + for ( k = 0 ; k < 8 ; i++ , k++ ) + { + if ( Line[i] <= ' ' ) break ; + label[k] = Line[i] ; + } + + /* recherche vraie valeur du composant */ + while(Line[i] != ' ') i++ ; /* elimination fin reference */ + while(Line[i] == ' ') i++ ; /* recherche debut vraie valeur */ + + /* debut vraie valeur trouv‚e */ + for ( k = 0 ; k < 16 ; i++ , k++ ) + { + if ( Line[i] <= ' ' ) break ; + postval[k] = Line[i] ; + } + + + /* classement du composant ,suivi de sa valeur */ + Cmp = new STORECMP(); + Cmp->Pnext = g_BaseListeCmp; + g_BaseListeCmp = Cmp; + Cmp->m_Reference = CONV_FROM_UTF8(label); + Cmp->m_Valeur = CONV_FROM_UTF8(postval) ; + + if( g_FlagEESchema ) /* Copie du nom module: */ + { + if( strnicmp(LibName, "$noname", 7 ) != 0 ) + { + while( *LibName > ' ' ) + { + Cmp->m_Module.Append(*LibName); + LibName++; + } + } + } + /* classement du TimeStamp */ + Cmp->m_TimeStamp = CONV_FROM_UTF8(ref_schema); + + pin_orcad( Cmp) ; + + nbcomp++ ; + } + fclose(source); + + /* reclassement alpabetique : */ + g_BaseListeCmp = TriListeComposantss( g_BaseListeCmp, nbcomp); + + return(0); +} + +/********************************************************/ +int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE * f) +/********************************************************/ +{ +char Line[1024]; +wxString CmpRef; +STORECMP * Cmp = NULL; + + for (;;) + { + if( fgets(Line,255,source) == 0 ) break; + if (strnicmp(Line,"$endlist", 8 ) == 0 ) + { + Cmp = NULL; + continue; + } + if (strnicmp(Line,"$endfootprintlist", 4 ) == 0 ) return 0; + + if (strnicmp(Line,"$component", 10 ) == 0 ) // New component ref found + { + CmpRef = CONV_FROM_UTF8(Line+11); + CmpRef.Trim(TRUE); CmpRef.Trim(FALSE); + /* Search the new component in list */ + for ( Cmp = g_BaseListeCmp; Cmp != NULL; Cmp = Cmp->Pnext ) + { + if ( Cmp->m_Reference == CmpRef) break; + } + } + + else if ( Cmp ) + { + wxString fp = CONV_FROM_UTF8(Line+1); + fp.Trim(FALSE); fp.Trim(TRUE); + Cmp->m_FootprintFilter.Add(fp); + } + } + + return 1; +} + + +/***********************************/ +int pin_orcad(STORECMP * Cmp) +/***********************************/ +{ +int i , jj; +char numpin[9] , net[1024] ; +char Line[1024]; +STOREPIN * Pin = NULL; +STOREPIN ** LastPin = & Cmp->m_Pins; + +for ( ;; ) + { + /* debut description trouv‚ */ + for ( ;; ) + { + if ( fgets(Line,80,source) == 0 ) return(-1) ; + + /* suppression des blancs en d‚but de ligne */ + i = 0 ; while (Line[i] == ' ') i++ ; + while (Line[i] == '(') i++ ; + while (Line[i] == ' ') i++ ; + + /* elimination des lignes vides : */ + if (Line[i] < ' ') continue ; + + /* fin de description ? */ + if (Line[i] == ')' ) return(0) ; + + memset( net, 0, sizeof(net) ); + memset( numpin, 0, sizeof(numpin) ); + + /* lecture name pin , 4 lettres */ + for (jj = 0 ; jj < 4 ; jj++ , i++) + { + if ( Line[i] == ' ' ) break ; + numpin[jj] = Line[i] ; + } + + /* recherche affectation forc‚e de net */ + if ( reaffect(numpin,net) != 0) + { + Pin = new STOREPIN(); + *LastPin = Pin; LastPin = &Pin->Pnext; + Pin->m_PinNum = CONV_FROM_UTF8(numpin); + Pin->m_PinNet = CONV_FROM_UTF8(net); + continue ; + } + + /* recherche netname */ + while(Line[i] == ' ') i++ ; /* recherche debut reference */ + + /* debut netname trouv‚ */ + for ( jj = 0 ; jj < (int)sizeof(net)-1 ; i++ , jj++ ) + { + if ( Line[i] <= ' ' ) break ; + net[jj] = Line[i] ; + } + + Pin = new STOREPIN(); + *LastPin = Pin; LastPin = &Pin->Pnext; + Pin->m_PinNum = CONV_FROM_UTF8(numpin); + Pin->m_PinNet = CONV_FROM_UTF8(net); + } + } +} + + +/****************************************************************/ +STORECMP * TriListeComposantss(STORECMP * BaseListe, int nbitems) +/****************************************************************/ +/* Tri la liste des composants par ordre alphabetique et me a jour +le nouveau chainage avant/arriere + retourne un pointeur sur le 1er element de la liste +*/ +{ +STORECMP ** bufferptr, * Item; +int ii; + + if (nbitems <= 0 ) return(NULL); + bufferptr = (STORECMP**)MyZMalloc( (nbitems+2) * sizeof(STORECMP*) ); + + for( ii= 1, Item = BaseListe; Item != NULL; Item = Item->Pnext, ii++) + { + bufferptr[ii] = Item; + } + + /* ici bufferptr[0] = NULL et bufferptr[nbitem+1] = NULL et ces 2 valeurs + representent le chainage arriere du 1er element, et le chainage avant + du dernier element */ + + qsort(bufferptr+1,nbitems,sizeof(STORECMP*), + (int(*)(const void*,const void*))CmpCompare) ; + /* Mise a jour du chainage */ + for( ii = 1; ii <= nbitems; ii++ ) + { + Item = bufferptr[ii]; + Item->m_Num = ii; + Item->Pnext = bufferptr[ii+1]; + Item->Pback = bufferptr[ii-1]; + } + return(bufferptr[1]); +} + + +/****************************************/ +int CmpCompare(void * mod1, void * mod2) +/****************************************/ +/* +routine compare() pour qsort() en classement alphabetique des composants +*/ +{ +int ii; +STORECMP *pt1 , *pt2 ; + + pt1 = * ((STORECMP**)mod1); + pt2 = * ((STORECMP**)mod2); + + //FIXME: + ii = StrNumICmp( (const wxChar*) pt1->m_Reference, (const wxChar*) pt2->m_Reference ); + return(ii); +} + + + diff --git a/cvpcb/savecmp.cpp b/cvpcb/savecmp.cpp new file mode 100644 index 0000000000..1eb16209c5 --- /dev/null +++ b/cvpcb/savecmp.cpp @@ -0,0 +1,167 @@ + /**************/ + /* savecmp() */ + /**************/ + +/* sauvegarde la liste des associations composants/empreintes */ + +#include "fctsys.h" + +#include "wxstruct.h" +#include "common.h" +#include "cvpcb.h" +#include "protos.h" + +/* Chaines de caractere d'identification */ +char EnteteCmpMod[] = {"Cmp-Mod V01"}; + +/****************************************************************************/ +int WinEDA_CvpcbFrame::SaveComponentList(const wxString & NetlistFullFileName) +/*****************************************************************************/ +/* Routine de sauvegarde du fichier des modules + Retourne 1 si OK + 0 si ecriture non faite +*/ +{ +STORECMP * Cmp; +wxString FullFileName; +char Line[1024]; +wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); + + /* calcul du nom du fichier */ + FullFileName = NetlistFullFileName; + ChangeFileNameExt(FullFileName, g_ExtCmpBuffer); + + dest = wxFopen(FullFileName, wxT("wt") ); + if( dest == NULL ) return(0); /* Erreur ecriture */ + + fprintf(dest,"%s", EnteteCmpMod); + fprintf(dest," Created by %s", CONV_TO_UTF8(Title)); + fprintf(dest," date = %s\n", DateAndTime(Line)); + + for ( Cmp = g_BaseListeCmp ; Cmp != NULL ; Cmp = Cmp->Pnext ) + { + fprintf(dest,"\nBeginCmp\n"); + fprintf(dest,"TimeStamp = %s;\n", CONV_TO_UTF8(Cmp->m_TimeStamp)); + fprintf(dest,"Reference = %s;\n", CONV_TO_UTF8(Cmp->m_Reference)); + fprintf(dest,"ValeurCmp = %s;\n", CONV_TO_UTF8(Cmp->m_Valeur)); + fprintf(dest,"IdModule = %s;\n", CONV_TO_UTF8(Cmp->m_Module)); + fprintf(dest,"EndCmp\n"); + } + fprintf(dest,"\nEndListe\n") ; + fclose(dest) ; + + return(1) ; +} + +/****************/ +int loadcmp(void) +/***************/ +/* recupere la liste des associations composants/empreintes +*/ +{ +wxString timestamp, valeur, ilib, namecmp; +bool read_cmp_data = FALSE, eof = FALSE; +STORECMP * Cmp; +char Line[1024], * ident, *data; +wxString FullFileName; + + /* calcul du nom du fichier */ + FullFileName = FFileName; + ChangeFileNameExt(FullFileName, g_ExtCmpBuffer); + + source = wxFopen(FullFileName, wxT("rt") ); + if (source == NULL ) + { + return(0) ; + } + + /* Identification du Type de fichier CmpMod */ + if ( fgets(Line,79,source) == 0 ) return(0); + if( strnicmp(Line, EnteteCmpMod, 11 ) != 0 ) /* old file version*/ + { + fclose(source) ; + DisplayError( NULL, wxT("Old version of Componaent file, recreate it!")); + return(0) ; + } + + /* lecture de la liste */ + while( ! eof && fgets(Line,79,source) != 0 ) + { + if( strnicmp(Line, "EndListe", 8 ) == 0 ) break; + + /* Recherche du debut de description du composant */ + if( strnicmp(Line, "BeginCmp", 8 ) != 0 ) continue; + timestamp.Empty(); + valeur.Empty(); + ilib.Empty(); + namecmp.Empty(); + read_cmp_data = TRUE; + + while( ! eof && read_cmp_data ) + { + if( fgets(Line, 1024,source) == 0 ) + { + eof = TRUE; break; + } + + if( strnicmp(Line, "EndCmp", 6 ) == 0 ) + { + read_cmp_data = TRUE; break; + } + + ident = strtok ( Line,"=;\n\r"); + data = strtok ( NULL,";\n\r"); + if( strnicmp(ident, "TimeStamp", 9) == 0) + { + timestamp = CONV_FROM_UTF8(data); + timestamp.Trim(TRUE); + timestamp.Trim(FALSE); + continue; + } + + if( strnicmp(ident, "Reference", 9) == 0) + { + namecmp = CONV_FROM_UTF8(data); + namecmp.Trim(TRUE); + namecmp.Trim(FALSE); + continue; + } + + if( strnicmp(ident, "ValeurCmp", 9) == 0) + { + valeur = CONV_FROM_UTF8(data); + valeur.Trim(TRUE); + valeur.Trim(FALSE); + continue; + } + + if( strnicmp(ident, "IdModule", 8) == 0) + { + ilib = CONV_FROM_UTF8(data); + ilib.Trim(TRUE); + ilib.Trim(FALSE); + continue; + } + } /* Fin lecture description de 1 composant */ + + /* Recherche du composant correspondant en netliste et + mise a jour de ses parametres */ + for ( Cmp = g_BaseListeCmp ; Cmp != NULL ; Cmp = Cmp->Pnext ) + { + if (selection_type == 1 ) + { + if( timestamp != Cmp->m_TimeStamp ) + continue ; + } + else + if( namecmp != Cmp->m_Reference ) continue; + + /* composant identifie , copie du nom du module correspondant */ + Cmp->m_Module= ilib; + } + } + fclose(source) ; + return(1) ; +} + + diff --git a/cvpcb/setvisu.cpp b/cvpcb/setvisu.cpp new file mode 100644 index 0000000000..8218a3ae15 --- /dev/null +++ b/cvpcb/setvisu.cpp @@ -0,0 +1,66 @@ +/*********************************************************************/ +/** setvisu.cpp: initialisations de l'ecran d'affichage du composant **/ +/*********************************************************************/ + +#include "fctsys.h" + +#include "wxstruct.h" +#include "common.h" +#include "cvpcb.h" +#include "3d_viewer.h" +#include "id.h" +#include "bitmaps.h" + +#include "protos.h" + +/*******************************************/ +void WinEDA_CvpcbFrame::CreateScreenCmp(void) +/*******************************************/ +/* Creation de la fenetre d'affichage du composant +*/ +{ +wxString msg, FootprintName; +bool IsNew = FALSE; + + FootprintName = m_FootprintList->GetSelectedFootprint(); + + if ( DrawFrame == NULL) + { + DrawFrame = new WinEDA_DisplayFrame(this, m_Parent, _("Module"), + wxPoint(0,0) , wxSize(600,400) ); + IsNew = TRUE; + } + else DrawFrame->Maximize(FALSE); + + DrawFrame->SetFocus(); /* Active entree clavier */ + DrawFrame->Show(TRUE); + + if( ! FootprintName.IsEmpty() ) + { + msg = _("Footprint: ") + FootprintName; + DrawFrame->SetTitle(msg); + STOREMOD * Module = GetModuleDescrByName(FootprintName); + msg = _("Lib: "); + if ( Module ) msg += Module->m_LibName; + else msg += wxT("???"); + DrawFrame->SetStatusText(msg, 0); + if ( DrawFrame->m_Pcb->m_Modules ) + { + DeleteStructure( DrawFrame->m_Pcb->m_Modules ); + DrawFrame->m_Pcb->m_Modules = NULL; + } + DrawFrame->m_Pcb->m_Modules = DrawFrame->Get_Module(FootprintName); + DrawFrame->Zoom_Automatique(FALSE); + if ( DrawFrame->m_Draw3DFrame ) + DrawFrame->m_Draw3DFrame->NewDisplay(); + } + + else if ( !IsNew ) + { + DrawFrame->ReDrawPanel(); + if ( DrawFrame->m_Draw3DFrame ) + DrawFrame->m_Draw3DFrame->NewDisplay(); + } +} + + diff --git a/cvpcb/tool_cvpcb.cpp b/cvpcb/tool_cvpcb.cpp new file mode 100644 index 0000000000..7edef47689 --- /dev/null +++ b/cvpcb/tool_cvpcb.cpp @@ -0,0 +1,191 @@ + /***************************************************/ + /* tool_cvpcb.cpp: construction du menu principal */ + /***************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + + +#include "common.h" +#include "cvpcb.h" +#include "trigo.h" + +#include "protos.h" + +#define BITMAP wxBitmap + +#include "bitmaps.h" +#include "delete_association.xpm" +#include "module_filtered_list.xpm" +#include "module_full_list.xpm" + +#include "id.h" + + +/*********************************************/ +void WinEDA_CvpcbFrame::ReCreateHToolbar(void) +/*********************************************/ +{ + if ( m_HToolBar != NULL ) return; + + m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE); + SetToolBar(m_HToolBar); + + m_HToolBar->AddTool(ID_CVPCB_READ_INPUT_NETLIST, BITMAP(netlist_xpm), + _("Open Netlist")); + + m_HToolBar->AddTool(ID_CVPCB_SAVEQUITCVPCB, BITMAP(save_netlist_xpm), + _("Save Nelist and Cmp list")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_CVPCB_CREATE_CONFIGWINDOW, BITMAP(config_xpm), + _("Configuration")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_CVPCB_CREATE_SCREENCMP, BITMAP(module_xpm), + _("View selected part")); + + m_HToolBar->AddTool(ID_CVPCB_AUTO_ASSOCIE, BITMAP(auto_associe_xpm), + _("Automatic Association")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_CVPCB_GOTO_PREVIOUSNA, BITMAP(left_xpm), + _("Select previous free component")); + + m_HToolBar->AddTool(ID_CVPCB_GOTO_FIRSTNA, BITMAP(right_xpm), + _("Select next free component")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_CVPCB_DEL_ASSOCIATIONS, BITMAP(delete_association_xpm), + _("Delete all associations")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_CVPCB_CREATE_STUFF_FILE, BITMAP(save_cmpstuff_xpm), + _("Create stuff file (component/module list)")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_PCB_DISPLAY_FOOTPRINT_DOC, BITMAP(file_footprint_xpm), + _("Display/print component documentation (footprint.pdf)")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddSeparator(); + m_HToolBar->AddRadioTool(ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, + wxEmptyString, BITMAP(module_filtered_list_xpm), + wxNullBitmap, + _("Display the filtered footprint list for the current component")); + m_HToolBar->AddRadioTool(ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, + wxEmptyString, BITMAP(module_full_list_xpm), + wxNullBitmap, + _("Display the full footprint list (without filtering)")); + + if( m_Parent->m_EDA_Config ) + { + wxString key = wxT(FILTERFOOTPRINTKEY); + int opt = m_Parent->m_EDA_Config->Read(key, (long)1); + m_HToolBar->ToggleTool(ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, opt); + m_HToolBar->ToggleTool(ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, ! opt); + } + + // after adding the buttons to the toolbar, must call Realize() to reflect + // the changes + m_HToolBar->Realize(); +} + + +/*******************************************/ +void WinEDA_CvpcbFrame::ReCreateMenuBar(void) +/*******************************************/ +/* Creation des menus de la fenetre principale +*/ +{ +int ii; +wxMenuBar * menuBar = GetMenuBar(); + + if( menuBar == NULL ) + { + menuBar = new wxMenuBar(); + // Associate the menu bar with the frame + SetMenuBar(menuBar); + + m_FilesMenu = new wxMenu; + wxMenuItem *item = new wxMenuItem(m_FilesMenu, ID_LOAD_PROJECT, + _("&Load Netlist File"), + _("Load a Netlist") ); + item->SetBitmap(open_xpm); + m_FilesMenu->Append(item); + + m_FilesMenu->AppendSeparator(); + item = new wxMenuItem(m_FilesMenu, ID_SAVE_PROJECT, + _("&Save Netlist"), + _("Save New Netlist and Cmp file") ); + item->SetBitmap(save_netlist_xpm); + m_FilesMenu->Append(item); + + m_FilesMenu->AppendSeparator(); + item = new wxMenuItem(m_FilesMenu, ID_CVPCB_QUIT, _("E&xit"), _("Quit Cvpcb" )); + item->SetBitmap(exit_xpm); + m_FilesMenu->Append(item); + +// Creation des selections des anciens fichiers + m_FilesMenu->AppendSeparator(); + for ( ii = 0; ii < 10; ii++ ) + { + if ( GetLastProject(ii).IsEmpty() ) break; + m_FilesMenu->Append(ID_LOAD_FILE_1 + ii, GetLastProject(ii) ); + } + + // Menu Configuration: + wxMenu * configmenu = new wxMenu; + item = new wxMenuItem(configmenu, ID_CONFIG_REQ, _("&Configuration"), + _("Setting Libraries, Directories and others...")); + item->SetBitmap(config_xpm); + configmenu->Append(item); + + // Font selection and setup + AddFontSelectionMenu(configmenu); + + m_Parent->SetLanguageList(configmenu); + + configmenu->AppendSeparator(); + item = new wxMenuItem(configmenu, ID_CONFIG_SAVE, + _("&Save config"), + _("Save configuration in current dir")); + item->SetBitmap(save_setup_xpm); + configmenu->Append(item); + + // Menu Help: + wxMenu *helpMenu = new wxMenu; + item = new wxMenuItem(helpMenu , ID_CVPCB_DISPLAY_HELP, _("&Help"), + _("On line doc")); + item->SetBitmap(help_xpm); + helpMenu->Append(item); + item = new wxMenuItem(helpMenu , ID_CVPCB_DISPLAY_LICENCE, _("Cvpcb &About"), + _("Kicad Infos")); + item->SetBitmap(info_xpm); + helpMenu->Append(item); + + menuBar->Append(m_FilesMenu, _("&Files")); + menuBar->Append(configmenu, _("&Preferences")); + menuBar->Append(helpMenu, _("&Help")); + } + + else // simple mise a jour de la liste des fichiers anciens + { + wxMenuItem * item; + int max_file = m_Parent->m_LastProjectMaxCount; + for ( ii = max_file-1; ii >=0 ; ii-- ) + { + if( m_FilesMenu->FindItem(ID_LOAD_FILE_1 + ii) ) + { + item = m_FilesMenu->Remove(ID_LOAD_FILE_1 + ii); + if ( item ) delete item; + } + } + for ( ii = 0; ii < max_file; ii++ ) + { + if ( GetLastProject(ii).IsEmpty() ) break; + m_FilesMenu->Append(ID_LOAD_FILE_1 + ii, GetLastProject(ii) ); + } + } +} + diff --git a/cvpcb/viewlnet.cpp b/cvpcb/viewlnet.cpp new file mode 100644 index 0000000000..eeb187af1e --- /dev/null +++ b/cvpcb/viewlnet.cpp @@ -0,0 +1,292 @@ + /*************************************************************/ + /* Traitement des netlistes VIEWLOGIC , Format NETLISt + PKG */ + /*************************************************************/ + +/* Traite la netliste VIEWLOGIC au format .net, avec fichiers .pkg +format .pkg +ex: +valeur;package;liste des composants +74LS00;14PDIP;U8,U9 +74LS04;14PDIP;U2 +CAP_NPOL;;CP1,CP2,CP3,CP4,CP5,CP6,CP7 +RVERT;R_250MW;R11,R12,R13,R14,R15,R16,R17,R21,R22,R23,R24,R25,R26,R27,R31,R32, + R33,R34,R35,R36,R37 +.. + +format .net +netname;cmp^pin,... +ex: +$1I1\$1N2;U2^8,U3^10 +$1I1\$1N6;U3^9,U6^9 +$1N30;J2_8^2,Q1^2,Q2^2,Q3^2,Q4^2,Q5^2,Q6^2,Q7^2,R21^2,R22^2,R23^2,R24^2,R25^2, + R26^2,R27^2,RP1^1,RP2^1,RP3^1,RP4^1,RP5^1,RP6^1,RP7^1 +*/ + +#include "fctsys.h" + +#include "wxstruct.h" +#include "common.h" +#include "cvpcb.h" +#include "protos.h" + +/* routines locales : */ +static void GenPin( STORECMP *BaseCmp,char *CmpName, char *PinNum, char *PinNet); +static int GenListeComposants(FILE * PkgFile); + +/* Variables Locales */ + + /******************************/ + /* int ReadViewlogicNet(void) */ + /******************************/ + +int WinEDA_CvpcbFrame::ReadViewlogicNetList(void) +{ +int ii, LineNum; +char Line[1024], *Text; +wxString PkgFileName; +char PinName[256], NetName[256], RefName[256], *Data; +STORECMP * Cmp; +wxString msg; + + modified = 0; + Rjustify = 1; + + /* Raz buffer et variable de gestion */ + if( g_BaseListeCmp ) FreeMemoryComponants(); + + Cmp = NULL; LineNum = 0; + memset(Line, 0, sizeof(Line) ); + + /* Tst de la presence du fichier principal Netliste, et son format: + Si format = PCBNEW, appel de ReadSchematicNetlist + */ + source = wxFopen(FFileName, wxT("rt") ); + if (source == 0) + { + msg = _("File not found ") + FFileName; + DisplayError(this, msg); return(-1); + } + + if ( fgets(Line, sizeof(Line)-1, source) == 0 ) + { /* fichier vide */ + fclose(source); return(-1); + } + + fclose(source); + Text = StrPurge(Line); + + ii = strnicmp(Line,"( { ",4) ; /* net type PCB2 */ + if( ii != 0 ) ii = strnicmp(Line,"# EESchema",4) ; /* net type EESchema */ + if( ii == 0 ) + { + ii = ReadSchematicNetlist(); return(ii); + } + + + /* Traitement reel de la netliste Viewlogic ( .net et .pkg ) */ + SetStatusText( _("Format Netlist: ViewLogic net&pkg"), 0); + + /* Calcul du nom (full file name) du fichier .pkg */ + PkgFileName = FFileName; + ChangeFileNameExt(PkgFileName, PkgInExtBuffer); + + /* Ouverture du fichier .pkg */ + source = wxFopen(PkgFileName, wxT("rt")); + if (source == 0) + { + msg = _("File not found ") + PkgFileName; + DisplayError(this, msg); + return(-1); + } + + nbcomp = GenListeComposants(source); + fclose(source); + + /* reclassement alpab‚tique : */ + g_BaseListeCmp = TriListeComposantss( g_BaseListeCmp, nbcomp); + + /* Ouverture du fichier netliste */ + source = wxFopen(FFileName, wxT("rt")); + if (source == 0) + { + msg = _("File not found ") + FFileName; + DisplayError(this, msg); + return(-1); + } + + /* Lecture de la liste ( fichier netliste ) */ + LineNum = 0; + for ( ;; ) + { + LineNum++; + if ( fgets(Line, sizeof(Line)-1, source) == 0 ) break ; + Text = StrPurge(Line); + if (*Text < ' ' ) continue; /* Ligne vide */ + + /* Lecture du NetName */ + for( ii = 0; ii < 80; ii++, Text++) + { + if( *Text == 0 ) break; + if( *Text == ';' ) break; + NetName[ii] = *Text; + } + NetName[ii] = 0; if ( *Text == ';' ) Text++; + if( NetName[0] == 0 ) + { + msg.Printf( wxT("Err. Pin Name ligne %s"),Line); + DisplayError(this, msg, 20); + } + + /* Lecture des attributions de pins */ + while( *Text != 0 ) + { + Data = RefName; RefName[0] = PinName[0] = 0; + for( ii = 0; ii < 1000; ii++, Text++ ) + { + if( *Text == 0 ) break; + if( *Text == ',' ) break; + if( *Text == '^' ) + { + *Data = 0; Data = PinName; continue; + } + *Data = *Text; Data++; + } + *Data = 0; + if( (PinName[0] == 0 ) || (PinName[0] == 0 ) ) + { + msg.Printf( wxT("Err. Pin Name ligne %s"),Line); + DisplayError(this, msg, 20); break; + } + GenPin( g_BaseListeCmp, RefName, PinName, NetName); + if ( *Text == ',' ) /* Autre element a traiter, ou nouvelle */ + /* ligne a lire ( continuation de ligne ) */ + { + Text++; Text = StrPurge(Text); + if( *Text == 0 ) /* Nouvelle ligne a lire */ + { + LineNum++; + if ( fgets(Line, sizeof(Line)-1, source) == 0 ) break ; + Text = StrPurge(Line); + } + } + } + } + + fclose(source); + + return(0); +} + + + +/******************************************************************************/ +static void GenPin( STORECMP *BaseCmp, char * CmpName, + char *PinNum, char *PinNet) +/******************************************************************************/ + +/* Routine de creation d'une pin pour le composant de ref CmpName. + la pin a pour "numero" PinNum, et pour Net PinNet +*/ +{ +STORECMP *Cmp; +STOREPIN * Pin; +wxString StrCmpName = CONV_FROM_UTF8(CmpName); + + /* Recherche du composant */ + Cmp = BaseCmp; + for( ; Cmp != NULL; Cmp = Cmp->Pnext ) + { + if( Cmp->m_Reference.CmpNoCase(StrCmpName) == 0 ) break; + } + + if( Cmp == NULL ) + { + wxString msg; + msg.Printf( _("Component [%s] not found in .pkg file"), CmpName); + DisplayError(NULL, msg, 1); + return; + } + + /* Creation de la Pin */ + Pin = new STOREPIN(); + Pin->Pnext = Cmp->m_Pins; Cmp->m_Pins = Pin; + Pin->m_PinNum = CONV_FROM_UTF8(PinNum); + Pin->m_PinNet = CONV_FROM_UTF8(PinNet); +} + + +/******************************************/ +static int GenListeComposants(FILE * PkgFile) +/******************************************/ +/* Cree la liste des composants cites dans le fichier .pkg + Retourne le nombre de composants +*/ +{ +int ii, LineNum, NbComp; +char Line[1024], *Text; +char Valeur[256], Package[256], Name[256]; +STORECMP * Cmp; + + LineNum = 0; NbComp = 0; + + /* Lecture de la liste ( fichier .pkg ) */ + for ( ;; ) + { + LineNum++; + if ( fgets(Line, sizeof(Line)-1, PkgFile) == 0 ) break ; + Text = StrPurge(Line); + if (*Text < ' ' ) continue; /* Ligne vide */ + + /* Lecture de la Valeur */ + for( ii = 0; ii < 80; ii++, Text++) + { + if( *Text == 0 ) break; + if( *Text == ';' ) break; + Valeur[ii] = *Text; + } + Valeur[ii] = 0; if ( *Text == ';' ) Text++; + + /* Lecture du type du boitier */ + for( ii = 0; ii < 80; ii++, Text++) + { + if( *Text == 0 ) break; + if( *Text == ';' ) break; + Package[ii] = *Text; + } + Package[ii] = 0; if ( *Text == ';' ) Text++; + + /* Lecture des composants */ + while( *Text ) + { + /* Lecture du nom du composant */ + for( ii = 0; ii < 80; ii++, Text++) + { + if( *Text <= ' ' ) break; + if( *Text == ',' ) break; + Name[ii] = *Text; + } + Name[ii] = 0; + Cmp = new STORECMP(); + Cmp->Pnext = g_BaseListeCmp; + g_BaseListeCmp = Cmp; + NbComp++ ; + Cmp->m_Reference = CONV_FROM_UTF8( StrPurge(Name) ); + Cmp->m_Valeur = CONV_FROM_UTF8( StrPurge(Valeur) ); + Cmp->m_Module = CONV_FROM_UTF8( StrPurge(Package) ); + Cmp->m_TimeStamp = wxT("00000000"); + + if ( *Text == ',' ) /* Autre element a traiter, ou nouvelle */ + /* ligne a lire ( continuation de ligne ) */ + { + Text++; Text = StrPurge(Text); + if( *Text == 0 ) /* Nouvelle ligne a lire */ + { + LineNum++; + if ( fgets(Line, sizeof(Line)-1, PkgFile) == 0 ) break ; + Text = StrPurge(Line); + } + } + } + } + return(NbComp); +} diff --git a/cvpcb/viewlogi.cpp b/cvpcb/viewlogi.cpp new file mode 100644 index 0000000000..584f14904a --- /dev/null +++ b/cvpcb/viewlogi.cpp @@ -0,0 +1,422 @@ + /********************************************************/ + /* Traitement des netlistes VIEWLOGIC , Format WIRELIST */ + /********************************************************/ + +/* Traite la netliste VIEWLOGIC au format WIRELIST +*/ + +#include "fctsys.h" + +#include "common.h" +#include "cvpcb.h" + +#include "protos.h" + +/* routines locales : */ +static int ReadVLDescrCmp( char * Line, STORECMP * Cmp, int Type); +static int ReadReelNumPin( char * Line, STORECMP * Cmp, int Type); +static int RegroupeUnitsComposant( STORECMP * BaseCmp ); +static STORECMP *TraitePseudoCmp(char * Text, STORECMP *PseudoCmp, int Header); +static void MergePseudoCmp(STORECMP * BaseCmp, STORECMP * BasePseudoCmp); + +/* Variables Locales */ +STORECMP * BasePseudoCmp; /* Stockage des descriptions generales */ + +/* Identificateurs de debut de ligne */ +#define API ( (('A'&255) << 16) | (('P'&255) << 8 ) | ('I'&255) ) +#define AP_ ( (('A'&255) << 8) | ('P'&255) ) +#define AS_ ( (('A'&255) << 8) | ('S'&255) ) +#define A__ ('A' & 255) +#define W__ ('W' & 255) +#define M__ ('M' & 255) +#define I__ ('I' & 255) + + +/************************************************/ +int WinEDA_CvpcbFrame::ReadViewlogicWirList(void) +/************************************************/ +{ +int ii, Type = 0, error, Header; +char RefDes[40], val[40], LocalRef[40], Generic[40] ; +char Line[1024], *Text; +STORECMP * Cmp, *NextCmp; +STORECMP * PseudoCmp = NULL; +wxString msg; + + modified = 0; + Rjustify = 1; + + /* Raz buffer et variable de gestion */ + if( g_BaseListeCmp ) FreeMemoryComponants(); + + Cmp = NULL; + + /* Ouverture du fichier source */ + msg = _("Netlist file ") + FFileName; + SetStatusText(msg,0); + + source = wxFopen(FFileName, wxT("rt")); + if (source == 0) + { + msg = _("File not found ") + FFileName; + DisplayError(this, msg); return(-1); + } + + /* Lecture entete qui doit etre "| Wirelist ..*/ + fgets(Line,1024,source) ; + ii = strncmp(Line,"| Wirelist",3) ; /* net type Viewlogic */ + + if ( ii != 0 ) + { + wxString Lineconv = CONV_FROM_UTF8(Line); + msg.Printf( _("Unknown file format <%s>"), Lineconv.GetData()); + fclose(source); return(-3) ; + } + + SetStatusText( wxT("Format Netliste ViewLogic wirelist"), 0); + + /* Lecture de la liste */ + for ( ;; ) + { + if ( fgets(Line,1024,source) == 0 ) break ; + Text = StrPurge(Line); + + Header = *Text & 255; /* Header est la copie du 1er mot de la ligne */ + for( ii = 1; ii < 3 ; ii++ ) + { + if( Text[ii] <= ' ' ) break; + Header <<= 8; Header |= Text[ii] & 255; + } + + switch( Header ) + { + case AP_ : + case AS_ : + PseudoCmp = TraitePseudoCmp(Text, PseudoCmp, Header); + Type = 0; + break; + + case API : + if( (nbcomp <= 0 ) || (Cmp == NULL) ) + { + DisplayError(NULL, wxT("Description API inattendue"), 20); + break; + } + error = ReadReelNumPin( Text, Cmp, Type ); + if( error < 0 ) + { + msg.Printf( wxT("Erreur %d ligne API"), -error ); + DisplayError(NULL, msg,10 ); + } + break; + + case I__ : /* Lecture descr 1 composant */ + if( nbcomp <= 0 ) + { + DisplayError(NULL, wxT("Description Composant inattendue"), 20); + break; + } + *RefDes = 0; *val = 0; + ReadVLDescrCmp( Text, Cmp, Type); + Type = 1; /* pour lecture num pins */ + break; + + case W__ : + case M__ : + Cmp = new STORECMP(); + Cmp->Pnext = g_BaseListeCmp; + g_BaseListeCmp = Cmp; + nbcomp++ ; + Type = Header; + Text = strtok(NULL, " \t\n\r"); + if( Text == NULL ) break; + strncpy(Generic, Text, 40); + Text = strtok(NULL, " \n\r"); + if( Text == NULL ) break; + strncpy(LocalRef, Text, 40); + break; + + default: + Type = 0; + break; + } + } + + fclose(source); + + /* reclassement alpab‚tique : */ + g_BaseListeCmp = TriListeComposantss( g_BaseListeCmp, nbcomp); + nbcomp -= RegroupeUnitsComposant( g_BaseListeCmp ); + + /* Addition des renseignements issus des pseudo composants */ + MergePseudoCmp( g_BaseListeCmp, BasePseudoCmp); + + /* Renumerotation des composants */ + Cmp = g_BaseListeCmp; + for( ii = 1; Cmp != NULL; ii++, Cmp = Cmp->Pnext) + { + Cmp->m_Num = ii; + } + + /* Liberation memoire */ + Cmp = BasePseudoCmp; + for( ; Cmp != NULL; Cmp = NextCmp ) + { + NextCmp = Cmp->Pnext; delete Cmp; + } + BasePseudoCmp = NULL; + + return(0); +} + + +/****************************************************************/ +static int ReadVLDescrCmp( char * Line, STORECMP * Cmp, int Type) +/****************************************************************/ +/* Lecture de la description d'un composant + (ligne commencant par I ...) +*/ +{ +char * Text, *Ident; +int nbpins = 0; +char numpin[9]; +STOREPIN * Pin = NULL; +STOREPIN ** LastPin = & Cmp->m_Pins; + + Text = strtok(Line, " \n\t\r`"); + + Text = strtok(NULL, " \n\t\r`"); /* Text pointe 1er mot utile */ + + Ident = strtok(NULL, " \n\t\r`"); /* Ident pointe identificateur */ + Cmp->m_Repere = CONV_FROM_UTF8(Ident); + + while ( Text ) + { + Text = strtok(NULL, " \t\n\r`"); + if( Text == NULL ) break; + + if( strncmp(Text, "VALUE=" ,6) == 0 ) + { + Cmp->m_Valeur = CONV_FROM_UTF8(Text+6); + continue; + } + + if( strncmp(Text, "REFDES=",7 ) == 0 ) + { + Cmp->m_Reference = CONV_FROM_UTF8(Text+7); + if( !isdigit(Cmp->m_Reference.Last() ) ) + Cmp->m_Reference.RemoveLast(); + continue; + } + + /* Lecture d'un net pin */ + nbpins++; + Pin = (STOREPIN *)MyZMalloc( sizeof(STOREPIN) ); + *LastPin = Pin; LastPin = &Pin->Pnext; + sprintf(numpin,"%d", nbpins); + Pin->m_Index = nbpins; + Pin->m_PinNum = CONV_FROM_UTF8(numpin); + Pin->m_PinNet = CONV_FROM_UTF8(Text); + } + + if( Cmp->m_Valeur.IsEmpty()) + { + Cmp->m_Valeur = CONV_FROM_UTF8(Ident); + } + + + /* Mise en place du TimeStamp init a 0 */ + Cmp->m_TimeStamp = wxT("00000000"); + + /* Analyse du type */ + switch( Type ) + { + case M__: return(0); + case W__: return(0); + default: break; + } + return(-1); +} + + /*********************************************************************/ + /* int ReadReelNumPin( char * Line, STORECMP * Cmp, int Type) */ + /*********************************************************************/ + +/* Lit les lignes commencant par "API" pour recuperer le vrai numero de pin +*/ +static int ReadReelNumPin( char * Line, STORECMP * Cmp, int Type) +{ +char * Text, *Ident; +int numpin; +STOREPIN * Pin; + + + if( Type != 1 ) return (-1); + + Text = strtok(Line, " \n\t\r"); + + Ident = strtok(NULL, " \n\t\r"); /* Ident pointe identificateur */ + + Text = strtok(NULL, " \n\t\r"); /* Text pointe type composant */ + + Text = strtok(NULL, " \n\t\r"); /* pointe numero d'ordre */ + if( Text == NULL ) return(-2);; + + numpin = atoi(Text); + + Text = strtok(NULL, " \n\t\r"); /* pointe Reel NumPin */ + if( Text == NULL ) return(-3); + + if( strncmp(Text, "#=" ,2) ) return (-4); + + for(Pin = Cmp->m_Pins ; Pin != NULL; Pin = Pin->Pnext ) + { + if( Pin->m_Type != STRUCT_PIN ) return(-5); + if( Pin->m_Index != numpin ) continue; + Pin->m_PinNum = CONV_FROM_UTF8(Text+2); + return(0); + } + return(-6 ); +} + + + /***********************************************/ + /* int RegroupeComposant( STORECMP * BaseCmp ) */ + /***********************************************/ + +/* Regroupe les pins des differentes Unites d'un meme composant + et modifie le chainage +*/ +static int RegroupeUnitsComposant( STORECMP * BaseCmp ) +{ +STORECMP * Cmp = BaseCmp; +STORECMP * NextCmp = Cmp->Pnext; +STOREPIN * Pin; +int Deleted = 0; + + + if( NextCmp == NULL ) return(0); + + for( ; NextCmp != NULL; Cmp = NextCmp, NextCmp = NextCmp->Pnext ) + { + if( Cmp->m_Reference != NextCmp->m_Reference ) continue; + /* 2 composants identiques : Pins a regrouper */ + Deleted++; + Pin = Cmp->m_Pins; + if( Pin == NULL ) Cmp->m_Pins = NextCmp->m_Pins; + else + { + while(Pin->Pnext) Pin = Pin->Pnext; + Pin->Pnext = NextCmp->m_Pins; + } + NextCmp->m_Pins = NULL; + Cmp->Pnext = NextCmp->Pnext; + (Cmp->Pnext)->Pback = Cmp; + delete NextCmp; + NextCmp = Cmp; + } + return(Deleted); +} + + + +/****************************************************************************/ +static STORECMP *TraitePseudoCmp(char * Line, STORECMP *PseudoCmp, int Header) +/****************************************************************************/ +{ +STORECMP * Cmp = PseudoCmp; +STOREPIN * Pin; +char *Text; +wxString Name; + + Text = strtok(Line," \t\n\r"); + Text = strtok(NULL," \t\n\r"); /* Pointe Name */ + Name = CONV_FROM_UTF8(Text); + Text = strtok(NULL," \t\n\r"); /* Pointe partie utile */ + + if( Cmp == NULL ) + { + Cmp = BasePseudoCmp = new STORECMP(); + Cmp->m_Repere = Name; + Cmp->m_Valeur = Name; + } + + else if( Name != Cmp->m_Valeur ) /* Nouveau pseudo composant */ + { + Cmp = new STORECMP(); + PseudoCmp->Pnext = Cmp; + Cmp->m_Valeur = Name; + Cmp->m_Repere = Name; + } + + switch ( Header ) + { + case AS_ : + if( strnicmp(Text,"PKG_TYPE=",9) == 0 ) + { + Cmp->m_Module = CONV_FROM_UTF8(Text+9); + break; + } + if( strnicmp(Text,"PARTS =",7) == 0 ) + { + Cmp->m_Multi = atoi(Text+7); + break; + } + if( strnicmp(Text,"REFDES=",7) == 0 ) + { + Cmp->m_Reference = CONV_FROM_UTF8(Text+7); + break; + } + if( strnicmp(Text,"SIGNAL=",7) == 0 ) + { + Text = strtok(Text," ;=\t\n\r"); + Text = strtok(NULL," ;=\t\n\r"); /* Pointe partie utile */ + Pin = new STOREPIN(); + Pin->Pnext = Cmp->m_Pins; + Cmp->m_Pins = Pin; + Pin->m_PinNet = CONV_FROM_UTF8(Text); + Text = strtok(NULL," ;=\t\n\r"); /* Pointe partie utile */ + Pin->m_PinNum = CONV_FROM_UTF8(Text); + break; + } + break; + + case AP_ : + break; + + } + + return(Cmp); +} + + +/*********************************************************************/ +static void MergePseudoCmp(STORECMP * BaseCmp, STORECMP * BasePseudoCmp) +/*********************************************************************/ +/* Additionne aux composants standards les renseignements contenus +dans les descriptions generales +*/ +{ +STORECMP * Cmp, * PseudoCmp; +STOREPIN * Pin, * PseudoPin; + + Cmp = BaseCmp; + for( ; Cmp != NULL; Cmp = Cmp->Pnext) + { + PseudoCmp = BasePseudoCmp; + for( ; PseudoCmp != NULL; PseudoCmp = PseudoCmp->Pnext) + { + if( Cmp->m_Repere != PseudoCmp->m_Repere ) continue; + /* Description trouvee, transfert des infos */ + Cmp->m_Multi = PseudoCmp->m_Multi; + PseudoPin = PseudoCmp->m_Pins; + for ( ; PseudoPin != NULL; PseudoPin = PseudoPin->Pnext) + { + Pin = new STOREPIN(*PseudoPin); + Pin->Pnext = Cmp->m_Pins; Cmp->m_Pins = Pin; + } + break; + } + } +} + diff --git a/cvpcb/visumod.cpp b/cvpcb/visumod.cpp new file mode 100644 index 0000000000..d6282643e2 --- /dev/null +++ b/cvpcb/visumod.cpp @@ -0,0 +1,176 @@ + /************************************************/ + /* Routines de visualisation du module courant */ + /************************************************/ + + +#include "fctsys.h" +#include "common.h" +#include "cvpcb.h" +#include "macros.h" +#include "pcbnew.h" + +#include "protos.h" + +/* defines locaux */ + +/* Variables locales */ + + +/*******************************************************************/ +void WinEDA_DisplayFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg) +/*******************************************************************/ +/* Affiche le module courant */ +{ + if (! m_Pcb ) return; + +MODULE * Module= m_Pcb->m_Modules; + + ActiveScreen = (PCB_SCREEN *) GetScreen(); + + if ( EraseBg ) DrawPanel->EraseScreen(DC); + + DrawPanel->DrawBackGround(DC); + + if( Module ) + { + Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_COPY); + Module->Display_Infos(this); + } + + Affiche_Status_Box(); + DrawPanel->Trace_Curseur(DC); +} + + + +/***********************************************/ +void DeleteStructure( void * GenericStructure ) +/***********************************************/ +/* Supprime de la liste chainee la stucture pointee par GenericStructure + et libere la memoire correspondante +*/ +{ +EDA_BaseStruct * PtStruct, *PtNext, *PtBack; +int IsDeleted; +int typestruct; +wxString msg; + + PtStruct = (EDA_BaseStruct *) GenericStructure; + if( PtStruct == NULL) return ; + + typestruct = (int)PtStruct->m_StructType; + IsDeleted = PtStruct->GetState(DELETED); + + PtNext = PtStruct->Pnext; + PtBack = PtStruct->Pback; + + switch( typestruct ) + { + case TYPE_NOT_INIT: + DisplayError(NULL, wxT("DeleteStruct: Type Structure Non Initialise")); + break; + + case PCB_EQUIPOT_STRUCT_TYPE: + #undef Struct + #define Struct ((EQUIPOT*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEMODULE: + #undef Struct + #define Struct ((MODULE*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + + case TYPEPAD: + #undef Struct + #define Struct ((D_PAD*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPECOTATION: + #undef Struct + #define Struct ((COTATION*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEMIRE: + #undef Struct + #define Struct ((MIREPCB*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEDRAWSEGMENT: + #undef Struct + #define Struct ((DRAWSEGMENT*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPETEXTE: + #undef Struct + #define Struct ((TEXTE_PCB*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + + case TYPETEXTEMODULE: + #undef Struct + #define Struct ((TEXTE_MODULE*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEEDGEMODULE: + #undef Struct + #define Struct ((EDGE_MODULE*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPETRACK: + #undef Struct + #define Struct ((TRACK*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEVIA: + #undef Struct + #define Struct ((SEGVIA*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEZONE: + #undef Struct + #define Struct ((SEGZONE*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEMARQUEUR: + #undef Struct + #define Struct ((MARQUEUR*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEPCB: + + default: + msg.Printf( wxT(" DeleteStructure: Type %d Inattendu"), + PtStruct->m_StructType); + DisplayError(NULL, msg); + break; + } +} + + diff --git a/cvpcb/writenetlistpcbnew.cpp b/cvpcb/writenetlistpcbnew.cpp new file mode 100644 index 0000000000..b0347a2dbe --- /dev/null +++ b/cvpcb/writenetlistpcbnew.cpp @@ -0,0 +1,235 @@ + /***************************/ + /* writenetlistpcbnew.cpp */ + /***************************/ + +/* +Complete la netliste (*.NET) en y placant les ref *.lib FORMAT PCBNEW ou ORCADPCB +*/ + +#include "fctsys.h" + +#include "common.h" +#include "cvpcb.h" + +#include "protos.h" + +#define MAX_LEN_NETNAME 16 + +/* Routines locales */ +static void TriPinsModule( STORECMP * CurrentCmp ); +static int PinCompare(const void *cmp1, const void *cmp2); +static void ChangePinNet( wxString & PinNet ); +static void WriteFootprintFilterInfos(FILE * dest); + +/* Variables Locales */ +int NetNumCode; /* Nombre utilise pour cree des NetNames lors de + reaffectation de NetNames */ + + +/*************************/ +int GenNetlistPcbnew(void) +/*************************/ +{ +#define NETLIST_HEAD_STRING "EESchema Netlist Version 1.1" +char Line[1024]; +STOREPIN * Pin; +STORECMP * CurrentCmp; +wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); + + NetNumCode = 1; DateAndTime(Line); + if ( g_FlagEESchema ) + fprintf( dest, "# %s created %s\n(\n", NETLIST_HEAD_STRING, Line); + else fprintf( dest, "( { netlist created %s }\n", Line ); + + /***********************/ + /* Lecture de la liste */ + /***********************/ + + CurrentCmp = g_BaseListeCmp; + for( ; CurrentCmp != NULL; CurrentCmp = CurrentCmp->Pnext) + { + fprintf(dest," ( %s ", CONV_TO_UTF8(CurrentCmp->m_TimeStamp)); + + if( ! CurrentCmp->m_Module.IsEmpty() ) + fprintf(dest, CONV_TO_UTF8(CurrentCmp->m_Module)); + + else fprintf(dest,"$noname$") ; + + fprintf(dest," %s ",CONV_TO_UTF8(CurrentCmp->m_Reference)) ; + + /* placement de la valeur */ + fprintf(dest,"%s\n",CONV_TO_UTF8(CurrentCmp->m_Valeur)) ; + + /* Tri des pins */ + TriPinsModule( CurrentCmp ); + + /* Placement de la liste des pins */ + Pin = CurrentCmp->m_Pins; + for( ; Pin != NULL; Pin = Pin->Pnext ) + { + if( Pin->m_PinNet.Len() > MAX_LEN_NETNAME) + ChangePinNet( Pin->m_PinNet ); + + if( ! Pin->m_PinNet.IsEmpty() ) + fprintf(dest," ( %s %s )\n", + CONV_TO_UTF8(Pin->m_PinNum), + CONV_TO_UTF8(Pin->m_PinNet)); + else + fprintf(dest," ( %s ? )\n", CONV_TO_UTF8(Pin->m_PinNum)); + } + fprintf(dest," )\n"); + } + fprintf(dest,")\n*\n"); + if ( g_FlagEESchema ) WriteFootprintFilterInfos(dest); + fclose(dest); + return(0); +} + +/******************************************/ +void WriteFootprintFilterInfos(FILE * dest) +/******************************************/ +/* Write the allowed footprint list for each component */ +{ +STORECMP * component = g_BaseListeCmp; +bool WriteHeader = FALSE; + + for ( ; component != NULL; component = component->Pnext ) + { + unsigned int FilterCount; + FilterCount = component->m_FootprintFilter.GetCount(); + if ( FilterCount == 0 ) continue; + if ( ! WriteHeader ) + { + fprintf( dest, "{ Allowed footprints by component:\n" ); + WriteHeader = TRUE; + } + fprintf(dest, "$component %s\n", CONV_TO_UTF8(component->m_Reference)); + /* Write the footprint list */ + for ( unsigned int jj = 0; jj < FilterCount; jj ++ ) + { + fprintf(dest, " %s\n", CONV_TO_UTF8(component->m_FootprintFilter[jj])); + } + fprintf(dest, "$endlist\n"); + } + if ( WriteHeader ) + fprintf(dest, "$endfootprintlist\n}\n"); +} + +/***********************************************/ +static void TriPinsModule( STORECMP * CurrentCmp ) +/***********************************************/ +/* Tri et controle des pins du module CurrentCmp +*/ +{ +STOREPIN * Pin, * NextPin, ** BasePin; +int nbpins = 0, ii; + + Pin = CurrentCmp->m_Pins; + if( Pin == NULL ) return; + + /* comptage des pins */ + for( ; Pin != NULL ; Pin = Pin->Pnext ) nbpins++; + + /* Tri des pins: etablissement de la liste des pointeurs */ + BasePin = (STOREPIN ** )MyZMalloc( nbpins * sizeof(STOREPIN*) ); + + Pin = CurrentCmp->m_Pins; + for( ii = 0 ; ii < nbpins ; ii++, Pin = Pin->Pnext ) + { + BasePin[ii] = Pin; + } + /* Tri des Pins */ + qsort( BasePin, nbpins, sizeof( STORECMP*), PinCompare) ; + + /* Remise a jour des pointeurs chaines */ + for( ii = 0 ; ii < nbpins-1 ; ii++ ) + { + BasePin[ii]->Pnext = BasePin[ii+1]; + } + BasePin[ii]->Pnext = NULL; + CurrentCmp->m_Pins = BasePin[0]; + + MyFree(BasePin); + + /* Elimination des redondances */ + Pin = CurrentCmp->m_Pins; + while( Pin != NULL) + { + NextPin = Pin->Pnext; + if ( NextPin == NULL ) break; + if( Pin->m_PinNum != NextPin->m_PinNum ) + { + Pin = Pin->Pnext; continue; + } + /* 2 pins successives ont le meme numero */ + if( Pin->m_PinNet != NextPin->m_PinNet ) + { + wxString msg; + msg.Printf( _("%s %s pin %s : Different Nets"), + CurrentCmp->m_Reference.GetData(),CurrentCmp->m_Valeur.GetData(), + Pin->m_PinNum.GetData()); + DisplayError(NULL, msg, 60 ); + } + Pin->Pnext = NextPin->Pnext; + delete NextPin; + } +} + + +/*******************************************************/ +static int PinCompare(const void *cmp1,const void *cmp2) +/*******************************************************/ +/* +routine PinCompare() pour qsort() pour classement alphabetique + pour tri de la liste des Pins +*/ +{ +STOREPIN **pt1 , **pt2 ; +int ii; + + pt1 = (STOREPIN**)cmp1; + pt2 = (STOREPIN**)cmp2; + + ii = StrLenNumICmp( (*pt1)->m_PinNum.GetData(), (*pt2)->m_PinNum.GetData(), 4); + return(ii); +} + + +/*******************************************/ +static void ChangePinNet( wxString & PinNet ) +/*******************************************/ +/* Change le NetName PinNet par un nom compose des 8 derniers codes de PinNet + suivi de _Xnnnnn ou nnnnn est un nom de 0 a 99999 +*/ +{ +STOREPIN * Pin; +STORECMP * CurrentCmp; +int ii; +wxString OldName; +wxString NewName; + + OldName = PinNet; + ii = PinNet.Len(); + if( Rjustify ) /* On conserve les 8 dernieres lettres du nom */ + { + NewName= OldName.Right(8); NewName << NetNumCode; + } + + else /* On conserve les 8 premieres lettres du nom */ + { + NewName = OldName.Left(8); NewName << NetNumCode; + } + NetNumCode ++; + + CurrentCmp = g_BaseListeCmp; + for( ; CurrentCmp != NULL; CurrentCmp = CurrentCmp->Pnext) + { + Pin = CurrentCmp->m_Pins; + for( ; Pin != NULL; Pin = Pin->Pnext ) + { + if( Pin->m_PinNet != OldName ) continue; + Pin->m_PinNet = NewName; + } + } +} + diff --git a/eeschema/affiche.cpp b/eeschema/affiche.cpp new file mode 100644 index 0000000000..78f4eb1b84 --- /dev/null +++ b/eeschema/affiche.cpp @@ -0,0 +1,146 @@ + /**********************************************************/ + /* Routines d'affichage de parametres et caracteristiques */ + /**********************************************************/ + + /* Fichier AFFICHE.CPP */ + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + + +/***********************************************************/ +void DrawSheetStruct::Display_Infos(WinEDA_DrawFrame * frame) +/************************************************************/ +{ + frame->MsgPanel->EraseMsgBox(); + Affiche_1_Parametre(frame, 1, _("Name"), m_SheetName, CYAN); + Affiche_1_Parametre(frame, 30, _("FileName"), m_FileName, BROWN); +} + +/***************************************************************/ +void EDA_SchComponentStruct::Display_Infos(WinEDA_DrawFrame * frame) +/***************************************************************/ +{ +EDA_LibComponentStruct * Entry = FindLibPart(m_ChipName.GetData(),wxEmptyString,FIND_ROOT);; +wxString msg; + + frame->MsgPanel->EraseMsgBox(); + + Affiche_1_Parametre(frame, 1, _("Ref"), + m_Field[REFERENCE].m_Text, DARKCYAN); + + if (Entry && Entry->m_Options == ENTRY_POWER) + msg = _("Pwr Symb"); + else msg = _("Val"); + Affiche_1_Parametre(frame, 10, msg, m_Field[VALUE].m_Text, DARKCYAN); + + Affiche_1_Parametre(frame, 28, _("RefLib"), m_ChipName.GetData(), BROWN); + + msg = FindLibName; + Affiche_1_Parametre(frame, 40, _("Lib"), msg, DARKRED); + + if( Entry ) + { + Affiche_1_Parametre(frame, 52, Entry->m_Doc, wxEmptyString, DARKCYAN); + Affiche_1_Parametre(frame, 52, wxEmptyString, Entry->m_KeyWord, DARKGREEN); + } +} + + + +/*******************************************************/ +void LibDrawPin::Display_Infos(WinEDA_DrawFrame * frame) +/*******************************************************/ +/* Affiche en bas d'ecran les caracteristiques de la pin +*/ +{ +wxString Text; +int ii; + + frame->MsgPanel->EraseMsgBox(); + + /* Affichage du nom */ + Affiche_1_Parametre(frame, 24, _("PinName"), m_PinName, DARKCYAN); + + /* Affichage du numero */ + if(m_PinNum == 0) Text = wxT("?" ); + else ReturnPinStringNum(Text); + + Affiche_1_Parametre(frame, 40, _("PinNum"), Text, DARKCYAN); + + /* Affichage du type */ + ii = m_PinType; + Affiche_1_Parametre(frame, 48, _("PinType"), MsgPinElectricType[ii], RED); + + /* Affichage de la visiblite */ + ii = m_Attributs; + if( ii & 1 ) Text = _("no"); + else Text = _("yes"); + Affiche_1_Parametre(frame, 58, _("Display"), Text, DARKGREEN); + + /* Affichage de la longueur */ + Text.Printf( wxT("%d"), m_PinLen); + Affiche_1_Parametre(frame, 66, _("Lengh"), Text, MAGENTA); + + /* Affichage de l'orientation */ + switch(m_Orient) + { + case PIN_UP: Text = _("Up"); break; + case PIN_DOWN: Text = _("Down"); break; + case PIN_LEFT: Text = _("Left"); break; + case PIN_RIGHT: Text = _("Right"); break; + default: Text = wxT("??"); break; + } + + Affiche_1_Parametre(frame, 72, _("Orient"), Text, MAGENTA); +} + + +/***********************************************************************/ +void LibEDA_BaseStruct::Display_Infos_DrawEntry(WinEDA_DrawFrame * frame) +/***********************************************************************/ +/* Affiche en bas d'ecran les caracteristiques de l'element +*/ +{ +wxString msg; + + frame->MsgPanel->EraseMsgBox(); + + /* affichage du type */ + msg = wxT("??"); + switch( m_StructType ) + { + case COMPONENT_ARC_DRAW_TYPE: msg = wxT("Arc"); break; + case COMPONENT_CIRCLE_DRAW_TYPE: msg = wxT("Circle"); break; + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: msg = wxT("Text"); break; + case COMPONENT_RECT_DRAW_TYPE: msg = wxT("Rect"); break; + case COMPONENT_POLYLINE_DRAW_TYPE: msg = wxT("PolyLine"); break; + case COMPONENT_LINE_DRAW_TYPE: msg = wxT("Segment"); break; + case COMPONENT_PIN_DRAW_TYPE: + ((LibDrawPin*) this)->Display_Infos(frame); + msg = wxT("Pin"); + break; + } + + Affiche_1_Parametre(frame, 1, wxT("Type"), msg, CYAN); + + + /* Affichage de l'appartenance */ + if( m_Unit == 0 ) msg = _("All"); + else msg.Printf( wxT("%d"), m_Unit ); + Affiche_1_Parametre(frame, 10, _("Unit"), msg, BROWN); + + if( m_Convert == 0 ) msg = _("All" ); + else if( m_Convert == 1 ) msg = _("no"); + else if( m_Convert == 2 ) msg = _("yes"); + else msg = wxT("?"); + Affiche_1_Parametre(frame, 16, _("Convert"), msg, BROWN); +} + + diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp new file mode 100644 index 0000000000..33d35fb58a --- /dev/null +++ b/eeschema/annotate.cpp @@ -0,0 +1,720 @@ + /**************************************/ + /* annotate.cpp: component annotation */ + /**************************************/ + +#include "annotate_dialog.cpp" + +#include "netlist.h" +#include "protos.h" + +/* fonctions exportees */ +int ListeComposants( CmpListStruct * BaseListeCmp, SCH_SCREEN *screen, int NumSheet); +int AnnotTriComposant(CmpListStruct *Objet1, CmpListStruct *Objet2); +void BreakReference( CmpListStruct * BaseListeCmp,int NbOfCmp ); + +/* fonctions locales */ +static void ReAnnotateComponents( CmpListStruct * BaseListeCmp,int NbOfCmp ); +static void ComputeReferenceNumber( CmpListStruct * BaseListeCmp,int NbOfCmp); +static int GetLastReferenceNumber(CmpListStruct *Objet, CmpListStruct * BaseListeCmp, + int NbOfCmp); +static int ExistUnit(CmpListStruct *Objet, int Unit, + CmpListStruct * BaseListeCmp,int NbOfCmp); + +/* Variable locales */ +static bool AnnotProject = TRUE; + + +/**************************************/ +void ReAnnotatePowerSymbolsOnly( void ) +/**************************************/ +/* Used to reannotate the power symbols, before testing erc or computing netlist +when a true component reannotation is not necessary + +In order to avoid conflicts the ref number start with a 0: + PWR with id 12 is named PWR12 in global annotation and PWR012 by the Power annotation +*/ +{ + /* Build the screen list */ + EDA_ScreenList ScreenList(NULL); + + /* Update the sheet number, sheet count and date */ + ScreenList.UpdateSheetNumberAndDate(); + + SCH_SCREEN* screen; + int CmpNumber = 1; + for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + EDA_BaseStruct *DrawList = screen->EEDrawList; + for ( ; DrawList != NULL ; DrawList = DrawList->Pnext ) + { + if ( DrawList->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + continue; + EDA_SchComponentStruct * DrawLibItem = (EDA_SchComponentStruct *) DrawList; + EDA_LibComponentStruct * Entry = + FindLibPart(DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if ( (Entry == NULL) || (Entry->m_Options != ENTRY_POWER) ) + continue; + DrawLibItem->ClearAnnotation(); + DrawLibItem->m_RefIdNumber = CmpNumber; + DrawLibItem->m_Field[REFERENCE].m_Text.RemoveLast(); // Remove the '?' + DrawLibItem->m_Field[REFERENCE].m_Text << wxT("0") << CmpNumber; + CmpNumber++; + } + } +} + + +/******************************************************************/ +void InstallAnnotateFrame(WinEDA_SchematicFrame *parent, wxPoint & pos) +/******************************************************************/ +{ + WinEDA_AnnotateFrame * frame = new WinEDA_AnnotateFrame(parent); + frame->ShowModal(); frame->Destroy(); +} + + +/******************************************************************/ +void WinEDA_AnnotateFrame::AnnotateComponents(wxCommandEvent& event) +/******************************************************************/ +/* + Compute the annotation of the components for the whole projeect, or the current sheet only. + All the components or the new ones only will be annotated. +*/ +{ +int NbSheet, ii , NbOfCmp; +SCH_SCREEN *screen; +CmpListStruct * BaseListeCmp; + + wxBusyCursor dummy; + + AnnotProject = (m_AnnotProjetCtrl->GetSelection() == 0) ? TRUE : FALSE; + + /* If it is an annotation for all the components, reset previous annotation: */ + if( m_AnnotNewCmpCtrl->GetSelection() == 0 ) DeleteAnnotation(event); + if (m_Abort ) return; + + + /* Build the screen list */ + EDA_ScreenList ScreenList(NULL); + NbSheet = ScreenList.GetCount(); + + /* Update the sheet number, sheet count and date */ + ScreenSch->SetModify(); + ScreenList.UpdateSheetNumberAndDate(); + + /* First pass: Component counting */ + screen = (SCH_SCREEN*) m_Parent->m_CurrentScreen; + if( AnnotProject == TRUE ) + { + NbOfCmp = 0; + for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + NbOfCmp += ListeComposants(NULL, screen, screen->m_SheetNumber); + } + } + else NbOfCmp = ListeComposants(NULL, screen, screen->m_SheetNumber); + + if( NbOfCmp == 0 ) + return; + + ii = sizeof(CmpListStruct) * NbOfCmp; + BaseListeCmp = (CmpListStruct *) MyZMalloc(ii); + + /* Second pass : Int data tables */ + screen = (SCH_SCREEN*) m_Parent->m_CurrentScreen; + if( AnnotProject == TRUE ) + { + ii = 0; + for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + ii += ListeComposants(BaseListeCmp + ii, + screen, screen->m_SheetNumber); + } + } + else ii = ListeComposants(BaseListeCmp, screen, screen->m_SheetNumber); + + if( ii != NbOfCmp ) + DisplayError(this, wxT("Internal error in AnnotateComponents()")); + + /* Separation des Numeros de la reference: IC1 -> IC, et 1 dans .m_NumRef */ + BreakReference(BaseListeCmp, NbOfCmp); + + qsort( BaseListeCmp, NbOfCmp, sizeof(CmpListStruct), + (int(*)(const void*, const void*))AnnotTriComposant); + + /* Recalcul des numeros de reference */ + ComputeReferenceNumber(BaseListeCmp, NbOfCmp); + ReAnnotateComponents(BaseListeCmp, NbOfCmp); + + MyFree(BaseListeCmp); BaseListeCmp = NULL; + + /* Final control */ + CheckAnnotate(m_Parent, AnnotProject ? FALSE : TRUE); + + m_Parent->DrawPanel->Refresh(TRUE); /* Refresh screen */ + Close(); +} + + +/********************************************************************/ +void WinEDA_AnnotateFrame::DeleteAnnotation(wxCommandEvent& event) +/********************************************************************/ +/* Clear the current annotation for the whole project or only for the current sheet + Update sheet number and number of sheets +*/ +{ +int NbSheet; +SCH_SCREEN * screen; +EDA_SchComponentStruct *DrawLibItem; + + if( !IsOK(this, _("Previous Annotation will be deleted. Continue ?") ) ) + { + m_Abort = TRUE; return; + } + + AnnotProject = (m_AnnotProjetCtrl->GetSelection() == 0) ? TRUE : FALSE; + m_Abort = FALSE; + + /* Build the screen list */ + EDA_ScreenList ScreenList(NULL); + NbSheet = ScreenList.GetCount(); + + /* Update the sheet number, sheet count and date */ + ScreenList.UpdateSheetNumberAndDate(); + + ScreenSch->SetModify(); + + if( AnnotProject == TRUE ) screen = ScreenList.GetFirst(); + else screen = (SCH_SCREEN*) m_Parent->m_CurrentScreen; + + for ( ; screen != NULL; screen = ScreenList.GetNext() ) + { + EDA_BaseStruct *DrawList = screen->EEDrawList; + for ( ; DrawList != NULL ; DrawList = DrawList->Pnext ) + { + if ( DrawList->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE ) + { + DrawLibItem = (EDA_SchComponentStruct *) DrawList; + DrawLibItem->ClearAnnotation(); + } + } + if( ! AnnotProject ) break; + } + + m_Parent->DrawPanel->Refresh(TRUE); + Close(); +} + + +/************************************************************************************/ +int ListeComposants(CmpListStruct * BaseListeCmp, SCH_SCREEN *screen, int NumSheet) +/***********************************************************************************/ +/* if BaseListeCmp == NULL : Components counting + else update data table BaseListeCmp +*/ +{ +int NbrCmp = 0; +EDA_BaseStruct *DrawList = screen->EEDrawList; +EDA_SchComponentStruct *DrawLibItem; +EDA_LibComponentStruct *Entry; + + DrawList = screen->EEDrawList; + + while ( DrawList ) + { + switch( DrawList->m_StructType ) + { + case DRAW_SEGMENT_STRUCT_TYPE : + case DRAW_JUNCTION_STRUCT_TYPE : + case DRAW_TEXT_STRUCT_TYPE : + case DRAW_LABEL_STRUCT_TYPE : + case DRAW_GLOBAL_LABEL_STRUCT_TYPE : + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE : + DrawLibItem = (EDA_SchComponentStruct *) DrawList; + Entry = FindLibPart(DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if( Entry == NULL) break; + if ( BaseListeCmp == NULL ) /* Items counting only */ + { + NbrCmp++; break; + } + BaseListeCmp[NbrCmp].m_Cmp = DrawLibItem; + BaseListeCmp[NbrCmp].m_NbParts = Entry->m_UnitCount; + BaseListeCmp[NbrCmp].m_Unit = DrawLibItem->m_Multi; + BaseListeCmp[NbrCmp].m_PartsLocked = Entry->m_UnitSelectionLocked; + BaseListeCmp[NbrCmp].m_Sheet = NumSheet; + BaseListeCmp[NbrCmp].m_IsNew = FALSE; + BaseListeCmp[NbrCmp].m_TimeStamp = DrawLibItem->m_TimeStamp; + if( DrawLibItem->m_Field[REFERENCE].m_Text.IsEmpty() ) + DrawLibItem->m_Field[REFERENCE].m_Text = wxT("DefRef?"); + strncpy( BaseListeCmp[NbrCmp].m_TextRef, + CONV_TO_UTF8(DrawLibItem->m_Field[REFERENCE].m_Text), 32); + + BaseListeCmp[NbrCmp].m_NumRef = -1; + + if( DrawLibItem->m_Field[VALUE].m_Text.IsEmpty() ) + DrawLibItem->m_Field[VALUE].m_Text = wxT("~"); + strncpy( BaseListeCmp[NbrCmp].m_TextValue, + CONV_TO_UTF8(DrawLibItem->m_Field[VALUE].m_Text), 32); + NbrCmp++; + break; + + case DRAW_PICK_ITEM_STRUCT_TYPE : + case DRAW_POLYLINE_STRUCT_TYPE : + case DRAW_BUSENTRY_STRUCT_TYPE : + case DRAW_SHEET_STRUCT_TYPE : + case DRAW_SHEETLABEL_STRUCT_TYPE : + case DRAW_MARKER_STRUCT_TYPE : + case DRAW_NOCONNECT_STRUCT_TYPE : + break; + + default : + break; + } + + DrawList = DrawList->Pnext; + } + +return(NbrCmp); +} + +/*****************************************************************/ +int AnnotTriComposant(CmpListStruct *Objet1, CmpListStruct *Objet2) +/****************************************************************/ +/* function used par qsort() for sorting the list + Composants are sorted + by reference + if same reference: by value + if same value: by unit number + if same unit number, by sheet + if same sheet, by time stamp +**/ +{ +int ii; + + ii = strnicmp( Objet1->m_TextRef, Objet2->m_TextRef, 32 ); + + if ( ii == 0 ) ii = strnicmp( Objet1->m_TextValue, Objet2->m_TextValue, 32 ); + if ( ii == 0 ) ii = Objet1->m_Unit - Objet2->m_Unit; + if ( ii == 0 ) ii = Objet1->m_Sheet - Objet2->m_Sheet; + if ( ii == 0 ) ii = Objet1->m_TimeStamp - Objet2->m_TimeStamp; + + return(ii); +} + + +/********************************************************************/ +static void ReAnnotateComponents( CmpListStruct * BaseListeCmp, int NbOfCmp) +/********************************************************************/ +/* Update the reference component for the schematic project (or the current sheet) +*/ +{ +int ii; +char *Text; +EDA_SchComponentStruct *DrawLibItem; + + /* Reattribution des numeros */ + for ( ii = 0; ii < NbOfCmp ; ii++ ) + { + Text = BaseListeCmp[ii].m_TextRef; + DrawLibItem = BaseListeCmp[ii].m_Cmp; + + if ( BaseListeCmp[ii].m_NumRef < 0 ) strcat( Text, "?" ); + else sprintf( Text + strlen(Text),"%d",BaseListeCmp[ii].m_NumRef ); + + DrawLibItem->m_Field[REFERENCE].m_Text = CONV_FROM_UTF8(Text); + DrawLibItem->m_Multi = BaseListeCmp[ii].m_Unit; + DrawLibItem->m_RefIdNumber = BaseListeCmp[ii].m_NumRef; + if ( DrawLibItem->m_RefIdNumber < 0 ) DrawLibItem->m_RefIdNumber = 0; + } +} + + + +/**************************************************************/ +void BreakReference( CmpListStruct * BaseListeCmp, int NbOfCmp) +/**************************************************************/ + +/* Modifie dans BaseListeCmp la reference des composants en supprimant la + partie nombre de la partie texte. +Place le nombre dans .m_NumRef +Pour les composants multiples non encore annotes, met .m_Unit a sa valeur max + Utilise: + BaseListeCmp + NbOfCmp +*/ +{ +int ii, ll; +char * Text; + + /* Separation des Numeros de la reference: IC1 -> IC, et 1 dans .m_NumRef */ + for ( ii = 0; ii < NbOfCmp ; ii++ ) + { + BaseListeCmp[ii].m_NumRef = - 1; + Text = BaseListeCmp[ii].m_TextRef; + ll = strlen( Text ) - 1; + if( Text[ll] == '?' ) + { + BaseListeCmp[ii].m_IsNew = TRUE; + if ( ! BaseListeCmp[ii].m_PartsLocked ) + BaseListeCmp[ii].m_Unit = 0x7FFFFFFF; + Text[ll] = 0; continue; + } + + if( isdigit(Text[ll]) == 0 ) + { + BaseListeCmp[ii].m_IsNew = TRUE; + if ( ! BaseListeCmp[ii].m_PartsLocked ) + BaseListeCmp[ii].m_Unit = 0x7FFFFFFF; + continue; + } + + while( ll >= 0 ) + { + if( (Text[ll] <= ' ' ) || isdigit(Text[ll]) ) + ll--; + else + { + if( isdigit(Text[ll+1]) ) + BaseListeCmp[ii].m_NumRef = atoi(& Text[ll+1]); + Text[ll+1] = 0; + break; + } + } + } +} + + +/*****************************************************************************/ +static void ComputeReferenceNumber( CmpListStruct * BaseListeCmp, int NbOfCmp) +/*****************************************************************************/ +/* Compute the reference number for components without reference number + Compute .m_NumRef member +*/ +{ +int ii, jj, LastReferenceNumber, NumberOfUnits, Unit; +char * Text, * RefText, *ValText; +CmpListStruct * ObjRef, * ObjToTest; + + /* Components with an invisible reference (power...) always are re-annotated*/ + for ( ii = 0; ii < NbOfCmp ; ii++ ) + { + Text = BaseListeCmp[ii].m_TextRef; + if (*Text == '#') + { + BaseListeCmp[ii].m_IsNew = TRUE; + BaseListeCmp[ii].m_NumRef = 0; + } + } + + ValText = RefText = ""; LastReferenceNumber = 1; + for ( ii = 0; ii < NbOfCmp ; ii++ ) + { + ObjRef = & BaseListeCmp[ii]; + if( BaseListeCmp[ii].m_Flag ) continue; + + Text = BaseListeCmp[ii].m_TextRef; + if( strnicmp(RefText, Text, 32) != 0 ) /* Nouveau Identificateur */ + { + RefText = BaseListeCmp[ii].m_TextRef; + LastReferenceNumber = GetLastReferenceNumber(BaseListeCmp + ii, BaseListeCmp, NbOfCmp); + } + + /* Annotation of mono-part components ( 1 part per package ) (trivial case)*/ + if( BaseListeCmp[ii].m_NbParts <= 1 ) + { + if ( BaseListeCmp[ii].m_IsNew ) + { + LastReferenceNumber++; + BaseListeCmp[ii].m_NumRef = LastReferenceNumber; + } + BaseListeCmp[ii].m_Unit = 1; + BaseListeCmp[ii].m_Flag = 1; + BaseListeCmp[ii].m_IsNew = FALSE; + continue; + } + + /* Annotation of multi-part components ( n parts per package ) (complex case) */ + ValText = BaseListeCmp[ii].m_TextValue; + NumberOfUnits = BaseListeCmp[ii].m_NbParts; + + if ( BaseListeCmp[ii].m_IsNew ) + { + LastReferenceNumber++; BaseListeCmp[ii].m_NumRef = LastReferenceNumber; + if ( ! BaseListeCmp[ii].m_PartsLocked ) + BaseListeCmp[ii].m_Unit = 1; + BaseListeCmp[ii].m_Flag = 1; + } + + for( Unit = 1; Unit <= NumberOfUnits; Unit++ ) + { + if( BaseListeCmp[ii].m_Unit == Unit ) continue; + jj = ExistUnit( BaseListeCmp + ii , Unit, BaseListeCmp, NbOfCmp ); + if ( jj >= 0 ) continue; /* Unit exists for this reference */ + + /* Search a component to annotate ( same prefix, same value) */ + for ( jj = ii+1; jj < NbOfCmp ; jj++ ) + { + ObjToTest = &BaseListeCmp[jj]; + if( BaseListeCmp[jj].m_Flag ) continue; + Text = BaseListeCmp[jj].m_TextRef; + if( strnicmp(RefText, Text, 32) != 0 ) break; // references are different + Text = BaseListeCmp[jj].m_TextValue; + if( strnicmp(ValText, Text, 32) != 0 ) break; // values are different + if ( ! BaseListeCmp[jj].m_IsNew ) + { + //BaseListeCmp[jj].m_Flag = 1; + continue; + } + /* Component without reference number found, annotate it if possible */ + if ( ! BaseListeCmp[jj].m_PartsLocked || (BaseListeCmp[jj].m_Unit == Unit) ) + { + BaseListeCmp[jj].m_NumRef = BaseListeCmp[ii].m_NumRef; + BaseListeCmp[jj].m_Unit = Unit; + BaseListeCmp[jj].m_Flag = 1; + BaseListeCmp[jj].m_IsNew = FALSE; + break; + } + } + } + } +} + + +/*************************************************************************************************/ +static int GetLastReferenceNumber(CmpListStruct *Objet, CmpListStruct * BaseListeCmp, int NbOfCmp) +/*************************************************************************************************/ +/* Recherche le plus grand numero de reference dans les composants + de meme prefixe de reference que celui pointe par Objet + la liste des composants est supposee triee +*/ +{ +CmpListStruct * LastObjet = BaseListeCmp + NbOfCmp; +int LastNumber = 0; +const char * RefText; + + RefText = Objet->m_TextRef; + for ( ; Objet < LastObjet; Objet++ ) + { + if( strnicmp(RefText, Objet->m_TextRef, 32) != 0 ) /* Nouveau Identificateur */ + break; + if( LastNumber < Objet->m_NumRef ) LastNumber = Objet->m_NumRef; + } + return(LastNumber); +} + + +/*****************************************************************/ +static int ExistUnit(CmpListStruct *Objet, int Unit, + CmpListStruct * BaseListeCmp, int NbOfCmp) +/****************************************************************/ +/* Recherche dans la liste triee des composants, pour les composants + multiples s'il existe pour le composant de reference Objet, + une unite de numero Unit + Retourne index dans BaseListeCmp si oui + retourne -1 si non +*/ +{ +CmpListStruct * EndList = BaseListeCmp + NbOfCmp; +char * RefText, * ValText; +int NumRef, ii; +CmpListStruct *ItemToTest; + + RefText = Objet->m_TextRef; + ValText = Objet->m_TextValue; + NumRef = Objet->m_NumRef; + for ( ItemToTest = BaseListeCmp, ii = 0; ItemToTest < EndList; ItemToTest++, ii++ ) + { + if ( Objet == ItemToTest ) continue; + if ( ItemToTest->m_IsNew ) continue; /* non affecte */ + if ( ItemToTest->m_NumRef != NumRef ) continue; + if( strnicmp(RefText, ItemToTest->m_TextRef, 32) != 0 ) /* Nouveau Identificateur */ + continue; + if( ItemToTest->m_Unit == Unit) + { + return(ii); + } + } + return(-1); +} + +/******************************************************************/ +int CheckAnnotate(WinEDA_SchematicFrame * frame, bool OneSheetOnly) +/******************************************************************/ + +/* Retourne le nombre de composants non annotés ou de meme référence (doublés) + Si OneSheetOnly : recherche sur le schema courant + sinon: recherche sur toute la hierarchie +*/ +{ +int NbSheet, ii, NumSheet = 1, error, NbOfCmp; +SCH_SCREEN *screen; +CmpListStruct * ListeCmp = NULL; +wxString Buff; +wxString msg, cmpref; + + /* build tje screen list */ + EDA_ScreenList ScreenList(NULL); + NbSheet = ScreenList.GetCount(); + + /* Update the sheet number, sheet count and date */ + ScreenSch->SetModify(); + ScreenList.UpdateSheetNumberAndDate(); + + /* 1ere passe : Comptage du nombre de composants */ + screen = (SCH_SCREEN*) frame->m_CurrentScreen; + if( ! OneSheetOnly ) + { + NbOfCmp = 0; + for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + NbOfCmp += ListeComposants(NULL, screen, NumSheet); + } + } + else NbOfCmp = ListeComposants(NULL, screen, NumSheet); + + if( NbOfCmp == 0 ) + { + wxBell(); + return(0); + } + + ii = sizeof(CmpListStruct) * NbOfCmp; + ListeCmp = (CmpListStruct *) MyZMalloc(ii); + + /* 2eme passe : Remplissage du tableau des caracteristiques */ + if( OneSheetOnly == 0 ) + { + ii = 0; screen = ScreenSch; + for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + ii += ListeComposants(ListeCmp + ii, screen, NumSheet); + } + } + else + { + screen = (SCH_SCREEN*) frame->m_CurrentScreen; + ListeComposants(ListeCmp, screen, NumSheet); + } + + qsort( ListeCmp, NbOfCmp, sizeof(CmpListStruct), + (int(*)(const void*, const void*))AnnotTriComposant); + + + /* Separation des Numeros de la reference: IC1 -> IC, et 1 dans .m_NumRef */ + BreakReference(ListeCmp, NbOfCmp); + + /* comptage des elements non annotes */ + error = 0; + for( ii = 0; ii < NbOfCmp-1 ; ii++ ) + { + msg.Empty(); Buff.Empty(); + if ( ListeCmp[ii].m_IsNew ) + { + if( ListeCmp[ii].m_NumRef >= 0 ) Buff << ListeCmp[ii].m_NumRef; + else Buff = wxT("?"); + cmpref = CONV_FROM_UTF8(ListeCmp[ii].m_TextRef); + msg.Printf( _("item not annotated: %s%s"), cmpref.GetData(), Buff.GetData()); + + if( (ListeCmp[ii].m_Unit > 0) && (ListeCmp[ii].m_Unit < 0x7FFFFFFF) ) + { + Buff.Printf( _("( unit %d)"), ListeCmp[ii].m_Unit); + msg << Buff; + } + DisplayError(NULL, msg); + error++; break; + } + + if( MAX(ListeCmp[ii].m_NbParts, 1) < ListeCmp[ii].m_Unit ) // Annotate error + { + if( ListeCmp[ii].m_NumRef >= 0 ) Buff << ListeCmp[ii].m_NumRef; + else Buff = wxT("?"); + + cmpref = CONV_FROM_UTF8(ListeCmp[ii].m_TextRef); + msg.Printf( _("Error item %s%s"), cmpref.GetData(), Buff.GetData()); + + Buff.Printf( _(" unit %d and no more than %d parts"), + ListeCmp[ii].m_Unit, ListeCmp[ii].m_NbParts); + msg << Buff; + DisplayError(frame, msg); + error++; break; + } + } + + if ( error ) return error; + + /* comptage des elements doublés (si tous sont annotés) */ + for( ii = 0; (ii < NbOfCmp-1) && (error < 4); ii++ ) + { + msg.Empty(); Buff.Empty(); + if( (stricmp(ListeCmp[ii].m_TextRef,ListeCmp[ii+1].m_TextRef) != 0) || + ( ListeCmp[ii].m_NumRef != ListeCmp[ii+1].m_NumRef ) ) + continue; + /* Meme reference trouvée */ + + /* Il y a erreur si meme unite */ + if( ListeCmp[ii].m_Unit == ListeCmp[ii+1].m_Unit ) + { + + if( ListeCmp[ii].m_NumRef >= 0 ) Buff << ListeCmp[ii].m_NumRef; + else Buff = wxT("?"); + + cmpref = CONV_FROM_UTF8(ListeCmp[ii].m_TextRef); + msg.Printf( _("Multiple item %s%s"), + cmpref.GetData(),Buff.GetData()); + + if( (ListeCmp[ii].m_Unit > 0) && (ListeCmp[ii].m_Unit < 0x7FFFFFFF) ) + { + Buff.Printf( _(" (unit %d)"), ListeCmp[ii].m_Unit); + msg << Buff; + } + DisplayError(frame, msg); + error++; continue; + } + + /* Il y a erreur si unites differentes mais nombre de parts differentes + par boitier (ex U3 ( 1 part) et U3B sont incompatibles) */ + if( ListeCmp[ii].m_NbParts != ListeCmp[ii+1].m_NbParts ) + { + + if( ListeCmp[ii].m_NumRef >= 0 ) Buff << ListeCmp[ii].m_NumRef; + else Buff = wxT("?"); + + cmpref = CONV_FROM_UTF8(ListeCmp[ii].m_TextRef); + msg.Printf( _("Multiple item %s%s"), cmpref.GetData(), Buff.GetData()); + + if( (ListeCmp[ii].m_Unit > 0) && (ListeCmp[ii].m_Unit < 0x7FFFFFFF) ) + { + Buff.Printf( _(" (unit %d)"), ListeCmp[ii].m_Unit); + msg << Buff; + } + + DisplayError(frame, msg); + error++; + } + + /* Il y a erreur si unites differentes ET valeurs différentes */ + if( stricmp(ListeCmp[ii].m_TextValue,ListeCmp[ii+1].m_TextValue) != 0) + { + wxString nextcmpref, cmpvalue, nextcmpvalue; + cmpref = CONV_FROM_UTF8(ListeCmp[ii].m_TextRef); + nextcmpref = CONV_FROM_UTF8(ListeCmp[ii+1].m_TextRef); + cmpvalue = CONV_FROM_UTF8(ListeCmp[ii].m_TextValue); + nextcmpvalue = CONV_FROM_UTF8(ListeCmp[ii+1].m_TextValue); + msg.Printf( _("Diff values for %s%d%c (%s) and %s%d%c (%s)"), + cmpref.GetData(), ListeCmp[ii].m_NumRef, ListeCmp[ii].m_Unit+'A'-1, + cmpvalue.GetData(), + nextcmpref.GetData(), ListeCmp[ii+1].m_NumRef, ListeCmp[ii+1].m_Unit+'A'-1, + nextcmpvalue.GetData()); + + DisplayError(frame, msg); + error++; + } + } + + MyFree(ListeCmp); + return(error); +} + + diff --git a/eeschema/annotate_dialog.cpp b/eeschema/annotate_dialog.cpp new file mode 100644 index 0000000000..7aa3ce9942 --- /dev/null +++ b/eeschema/annotate_dialog.cpp @@ -0,0 +1,211 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: annotate_dialog.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 05/02/2006 12:31:28 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 05/02/2006 12:31:28 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "annotate_dialog.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes + +#include "annotate_dialog.h" + +////@begin XPM images +////@end XPM images + +/*! + * WinEDA_AnnotateFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_AnnotateFrame, wxDialog ) + +/*! + * WinEDA_AnnotateFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_AnnotateFrame, wxDialog ) + +////@begin WinEDA_AnnotateFrame event table entries + EVT_BUTTON( ID_ANNOTATE_CMP, WinEDA_AnnotateFrame::OnAnnotateCmpClick ) + + EVT_BUTTON( ID_DEANNOTATE_CMP, WinEDA_AnnotateFrame::OnDeannotateCmpClick ) + + EVT_BUTTON( wxID_CLOSE, WinEDA_AnnotateFrame::OnCloseClick ) + +////@end WinEDA_AnnotateFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_AnnotateFrame constructors + */ + +WinEDA_AnnotateFrame::WinEDA_AnnotateFrame( ) +{ +} + +WinEDA_AnnotateFrame::WinEDA_AnnotateFrame( WinEDA_SchematicFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + m_Abort = FALSE; + Create(parent, id, caption, pos, size, style); + m_AnnotNewCmpCtrl->SetSelection(1); +} + +/*! + * WinEDA_AnnotateFrame creator + */ + +bool WinEDA_AnnotateFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_AnnotateFrame member initialisation + m_AnnotProjetCtrl = NULL; + m_AnnotNewCmpCtrl = NULL; +////@end WinEDA_AnnotateFrame member initialisation + +////@begin WinEDA_AnnotateFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_AnnotateFrame creation + return true; +} + +/*! + * Control creation for WinEDA_AnnotateFrame + */ + +void WinEDA_AnnotateFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_AnnotateFrame content construction + // Generated by DialogBlocks, 05/02/2006 12:40:51 (unregistered) + + WinEDA_AnnotateFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5); + + wxString m_AnnotProjetCtrlStrings[] = { + _("Hierarchy"), + _("Current sheet") + }; + m_AnnotProjetCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("annotate:"), wxDefaultPosition, wxDefaultSize, 2, m_AnnotProjetCtrlStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer3->Add(m_AnnotProjetCtrl, 0, wxALIGN_LEFT|wxALL, 5); + + wxString m_AnnotNewCmpCtrlStrings[] = { + _("all components"), + _("new components only") + }; + m_AnnotNewCmpCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("select items:"), wxDefaultPosition, wxDefaultSize, 2, m_AnnotNewCmpCtrlStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer3->Add(m_AnnotNewCmpCtrl, 0, wxALIGN_LEFT|wxALL, 5); + + wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton7 = new wxButton( itemDialog1, ID_ANNOTATE_CMP, _("&Annotate"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton7->SetDefault(); + itemButton7->SetForegroundColour(wxColour(198, 0, 0)); + itemBoxSizer6->Add(itemButton7, 0, wxGROW|wxALL, 5); + + wxButton* itemButton8 = new wxButton( itemDialog1, ID_DEANNOTATE_CMP, _("&Del Annotate"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton8->SetForegroundColour(wxColour(0, 0, 230)); + itemBoxSizer6->Add(itemButton8, 0, wxGROW|wxALL, 5); + + wxButton* itemButton9 = new wxButton( itemDialog1, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer6->Add(itemButton9, 0, wxGROW|wxALL, 5); + +////@end WinEDA_AnnotateFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_AnnotateFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_AnnotateFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_AnnotateFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_AnnotateFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_AnnotateFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_AnnotateFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_AnnotateFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ANNOTATE_CMP + */ + +void WinEDA_AnnotateFrame::OnAnnotateCmpClick( wxCommandEvent& event ) +{ + AnnotateComponents(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DEANNOTATE_CMP + */ + +void WinEDA_AnnotateFrame::OnDeannotateCmpClick( wxCommandEvent& event ) +{ + DeleteAnnotation(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + */ + +void WinEDA_AnnotateFrame::OnCloseClick( wxCommandEvent& event ) +{ + Close(TRUE); +} + + diff --git a/eeschema/annotate_dialog.h b/eeschema/annotate_dialog.h new file mode 100644 index 0000000000..250f7f77ca --- /dev/null +++ b/eeschema/annotate_dialog.h @@ -0,0 +1,125 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: annotate_dialog.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 05/02/2006 12:31:28 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 05/02/2006 12:31:28 + +#ifndef _ANNOTATE_DIALOG_H_ +#define _ANNOTATE_DIALOG_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "annotate_dialog.h" +#endif + +/*! + * Includes + */ + +////@begin includes +////@end includes + +#include "fctsys.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_ANNOTATEFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_ANNOTATEFRAME_TITLE _("EESchema Annotation") +#define SYMBOL_WINEDA_ANNOTATEFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_ANNOTATEFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_ANNOTATEFRAME_POSITION wxDefaultPosition +#define ID_RADIOBOX 10001 +#define ID_RADIOBOX1 10002 +#define ID_ANNOTATE_CMP 10003 +#define ID_DEANNOTATE_CMP 10004 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_AnnotateFrame class declaration + */ + +class WinEDA_AnnotateFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_AnnotateFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_AnnotateFrame( ); + WinEDA_AnnotateFrame( WinEDA_SchematicFrame* parent, wxWindowID id = SYMBOL_WINEDA_ANNOTATEFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_ANNOTATEFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_ANNOTATEFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_ANNOTATEFRAME_SIZE, long style = SYMBOL_WINEDA_ANNOTATEFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_ANNOTATEFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_ANNOTATEFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_ANNOTATEFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_ANNOTATEFRAME_SIZE, long style = SYMBOL_WINEDA_ANNOTATEFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_AnnotateFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ANNOTATE_CMP + void OnAnnotateCmpClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DEANNOTATE_CMP + void OnDeannotateCmpClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + void OnCloseClick( wxCommandEvent& event ); + +////@end WinEDA_AnnotateFrame event handler declarations + +////@begin WinEDA_AnnotateFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_AnnotateFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + +////@begin WinEDA_AnnotateFrame member variables + wxRadioBox* m_AnnotProjetCtrl; + wxRadioBox* m_AnnotNewCmpCtrl; +////@end WinEDA_AnnotateFrame member variables + + WinEDA_SchematicFrame * m_Parent; + bool m_Abort; + +private: + void AnnotateComponents(wxCommandEvent& event); + void DeleteAnnotation(wxCommandEvent& event); +}; + +#endif + // _ANNOTATE_DIALOG_H_ diff --git a/eeschema/annotate_dialog.pjd b/eeschema/annotate_dialog.pjd new file mode 100644 index 0000000000..cebd17f3d0 --- /dev/null +++ b/eeschema/annotate_dialog.pjd @@ -0,0 +1,574 @@ + + +
+ 0 + "" + "" + "" + "" + 16 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "EESchema Annotation" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "5/2/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "ID_DIALOG" + 10000 + "WinEDA_AnnotateFrame" + "wxDialog" + "wxDialog" + "annotate_dialog.cpp" + "annotate_dialog.h" + "" + "EESchema Annotation" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Horizontal" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "5/2/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxRadioBox: ID_RADIOBOX" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "5/2/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX" + 10001 + "wxRadioBox" + "m_AnnotProjetCtrl" + "annotate:" + 1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + "Hierarchy|Current sheet" + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxRadioBox: ID_RADIOBOX1" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "5/2/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX1" + 10002 + "wxRadioBox" + "m_AnnotNewCmpCtrl" + "select items:" + 1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + "all components|new components only" + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "5/2/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: ID_ANNOTATE_CMP" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "5/2/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnAnnotateCmpClick" + "ID_ANNOTATE_CMP" + 10003 + "wxButton" + "" + "&Annotate" + 1 + "" + "" + "" + "C60000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: ID_DEANNOTATE_CMP" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "5/2/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnDeannotateCmpClick" + "ID_DEANNOTATE_CMP" + 10004 + "wxButton" + "" + "&Del Annotate" + 0 + "" + "" + "" + "0000E6" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_CLOSE" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "5/2/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCloseClick" + "wxID_CLOSE" + 5001 + "wxButton" + "" + "&Close" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "annotate_dialog.rc" + "source-editor-document" + "annotate_dialog.rc" + "source-editor" + 0 + 0 + 1 + 0 + "5/2/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/annotate_dialog.rc b/eeschema/annotate_dialog.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/eeschema/annotate_dialog.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/eeschema/bitmaps/AddBus2Bus.xpm b/eeschema/bitmaps/AddBus2Bus.xpm new file mode 100644 index 0000000000..0b3d5d0b3b --- /dev/null +++ b/eeschema/bitmaps/AddBus2Bus.xpm @@ -0,0 +1,47 @@ +/* XPM */ +static char * AddBus2Bus_xpm[] = { +"16 16 28 1", +" c None", +". c #9B9BFF", +"+ c #C3C3C3", +"@ c #000069", +"# c #AEAEE1", +"$ c #4A4A80", +"% c #AAAAAA", +"& c #4B4B81", +"* c #9B9B9B", +"= c #676798", +"- c #4C4C81", +"; c #0F0F6D", +"> c #03036A", +", c #4D4D81", +"' c #10106D", +") c #4E4E82", +"! c #10106E", +"~ c #4E4E81", +"{ c #A8A8A8", +"] c #A0A0A0", +"^ c #12126E", +"/ c #505082", +"( c #646495", +"_ c #515182", +": c #04046B", +"< c #535384", +"[ c #13136F", +"} c #13136E", +" .. ........", +" ..+ @.......#", +" ..+ @$%+++++++", +" ..+ @&* ", +" ..=@-*;........", +" ..>,*'@.......#", +" ..)*!@~{+++++++", +" ..]^@/* ", +" ..(@_*'........", +" ..:_*^@.......#", +" ..<*[@~{+++++++", +" ..]}@/* ", +" ..(@_* ", +" ..:_* ", +" ..<* ", +" .#] "}; diff --git a/eeschema/bitmaps/AddLine2Bus.xpm b/eeschema/bitmaps/AddLine2Bus.xpm new file mode 100644 index 0000000000..b63c80aacf --- /dev/null +++ b/eeschema/bitmaps/AddLine2Bus.xpm @@ -0,0 +1,48 @@ +/* XPM */ +static char * AddLine2Bus_xpm[] = { +"16 16 29 1", +" c None", +". c #9B9BFF", +"+ c #006900", +"@ c #95F400", +"# c #9B9B9B", +"$ c #397B39", +"% c #026902", +"& c #437E43", +"* c #879487", +"= c #046A04", +"- c #498049", +"; c #788F78", +"> c #126F12", +", c #4C814C", +"' c #006800", +") c #397C39", +"! c #4D814D", +"~ c #437F43", +"{ c #126E12", +"] c #387B38", +"^ c #9A9A9A", +"/ c #4D824D", +"( c #016901", +"_ c #427E42", +": c #488048", +"< c #799079", +"[ c #4B814B", +"} c #869386", +"| c #9B9BCD", +" .. +@@@@@@@@", +" ..# +$########", +" ..# %&# ", +" ..*=-;+@@@@@@@@", +" ..>,;')########", +" ..!;%~# ", +" ..*=-;+@@@@@@@@", +" ..{,;']^#######", +" ../;(_# ", +" ..*=:<+@@@@@@@@", +" ..{[<')########", +" ../<%~# ", +" ..}=-# ", +" ..{,# ", +" ../# ", +" .|# "}; diff --git a/eeschema/bitmaps/Add_Bus2Bus.xpm b/eeschema/bitmaps/Add_Bus2Bus.xpm new file mode 100644 index 0000000000..2452632cc7 --- /dev/null +++ b/eeschema/bitmaps/Add_Bus2Bus.xpm @@ -0,0 +1,57 @@ +/* XPM */ +static char * add_bus2bus_xpm[] = { +"16 16 38 1", +" c None", +". c #AFAFFF", +"+ c #9B9B9B", +"@ c #00009A", +"# c #02029B", +"$ c #A4A4CA", +"% c #91919A", +"& c #00009B", +"* c #03039A", +"= c #5F5F9A", +"- c #ACACFD", +"; c #16169B", +"> c #0F0F9B", +", c #7A7A9B", +"' c #A9A9FC", +") c #25259A", +"! c #8C8C9A", +"~ c #AAAAFC", +"{ c #41419A", +"] c #96969A", +"^ c #0D0D9A", +"/ c #909099", +"( c #08089A", +"_ c #A9A9F9", +": c #97979A", +"< c #19199A", +"[ c #01019B", +"} c #A5A5CD", +"| c #AEAEFC", +"1 c #929299", +"2 c #0F0F9A", +"3 c #5D5D9B", +"4 c #18189A", +"5 c #77779B", +"6 c #22229A", +"7 c #898999", +"8 c #3E3E9B", +"9 c #96969B", +" .. ", +" ..+ @....... ", +" ..+ @#.......$", +" ..%@&*=++++++++", +" .-;&>, ", +" .'&)! @....... ", +" .~{]^@#.......$", +" ../@&*=++++++++", +" .-;&>, ", +" .'&)! (........", +" ._{:<[&.......}", +" .|12&*3++++++++", +" ..4&>5 ", +" ..&67 ", +" ..89 ", +" .}+ "}; diff --git a/eeschema/bitmaps/Add_GLabel.xpm b/eeschema/bitmaps/Add_GLabel.xpm new file mode 100644 index 0000000000..127c9630d3 --- /dev/null +++ b/eeschema/bitmaps/Add_GLabel.xpm @@ -0,0 +1,73 @@ +/* XPM */ +static char * add_glabel_xpm[] = { +"16 16 54 1", +" c None", +". c #695F00", +"+ c #837E52", +"@ c #6D640F", +"# c #6F6714", +"$ c #706818", +"% c #9C9C9C", +"& c #9191FF", +"* c #9B9BFF", +"= c #A5A5FF", +"- c #857F66", +"; c #746D25", +"> c #827D4F", +", c #7E7841", +"' c #8F8C76", +") c #9E9EFF", +"! c #A8A8FF", +"~ c #B2B2FF", +"{ c #BBBBF9", +"] c #7D7539", +"^ c #7A7437", +"/ c #95948B", +"( c #878460", +"_ c #7D773E", +": c #ACACFF", +"< c #B6B6FF", +"[ c #C0C0FF", +"} c #CACAFF", +"| c #BFBDCC", +"1 c #8C896D", +"2 c #6C6209", +"3 c #989894", +"4 c #B9B9FF", +"5 c #C3C3FF", +"6 c #CECEFF", +"7 c #D5D5F9", +"8 c #847C39", +"9 c #7B7437", +"0 c #9B9B9B", +"a c #797233", +"b c #817C4D", +"c c #756D25", +"d c #898664", +"e c #C7C7FF", +"f c #D1D1FF", +"g c #DBDBFF", +"h c #9B9566", +"i c #999997", +"j c #96958D", +"k c #86825B", +"l c #766F2B", +"m c #706716", +"n c #97968F", +"o c #9A9A9A", +" ", +" ", +" ", +" .. ", +" ...+ ..... ", +" .@#$% .&*=-; ", +" .>,.' .)!~{]^ ", +" ../(._ .:<[}|.1", +" .....23.4567890", +"..abbc.d.efgh;i0", +"..j00k.l....mn0 ", +" o0 0o00000 ", +" ", +" ", +" ", +" "}; diff --git a/eeschema/bitmaps/Add_Junction.xpm b/eeschema/bitmaps/Add_Junction.xpm new file mode 100644 index 0000000000..f3de785652 --- /dev/null +++ b/eeschema/bitmaps/Add_Junction.xpm @@ -0,0 +1,79 @@ +/* XPM */ +static char * add_junction_xpm[] = { +"16 16 60 1", +" c None", +". c #007D00", +"+ c #4D8B4D", +"@ c #9B9B9B", +"# c #000000", +"$ c #000700", +"% c #0A130A", +"& c #282828", +"* c #222222", +"= c #868483", +"- c #E1D5CA", +"; c #B7A595", +"> c #564A3F", +", c #080707", +"' c #151515", +") c #EAE2DB", +"! c #FFEBDA", +"~ c #FFE0C5", +"{ c #FFD5B1", +"] c #FFCA9C", +"^ c #806044", +"/ c #004C00", +"( c #645F59", +"_ c #FFE6CF", +": c #FFDBBB", +"< c #FFD0A6", +"[ c #FFC591", +"} c #FFBA7D", +"| c #E49C5D", +"1 c #000D00", +"2 c #2F552F", +"3 c #64584D", +"4 c #FFD5B0", +"5 c #FFCA9B", +"6 c #FFBF87", +"7 c #FFB472", +"8 c #FFA95D", +"9 c #E48D41", +"0 c #080F08", +"a c #757575", +"b c #16120F", +"c c #EAB485", +"d c #FFB97C", +"e c #FFAF67", +"f c #FFA453", +"g c #FF993E", +"h c #804715", +"i c #3A3A3A", +"j c #414141", +"k c #22180F", +"l c #865931", +"m c #E18B40", +"n c #B76925", +"o c #562E0A", +"p c #131110", +"q c #8E8E8E", +"r c #686868", +"s c #242424", +"t c #3F3F3F", +"u c #909090", +" .. ", +" .+@ ", +" .+@ ", +" #$%& ", +" *=-;>, ", +" ')!~{]^* ", +".../(_:<[}|1... ", +".++234567890+++@", +" @@abcdefghi@@@@", +" jklmnopq ", +" rs$%tu ", +" @.+@ ", +" .+@ ", +" .+@ ", +" .+@ ", +" @@ "}; diff --git a/eeschema/bitmaps/Add_Line2Bus.xpm b/eeschema/bitmaps/Add_Line2Bus.xpm new file mode 100644 index 0000000000..205f30ba85 --- /dev/null +++ b/eeschema/bitmaps/Add_Line2Bus.xpm @@ -0,0 +1,50 @@ +/* XPM */ +static const char * add_line2bus_xpm[] = { +"16 16 31 1", +" c None", +"! c black", +"# c #9B9BFF", +"$ c #006900", +"% c #95F400", +"& c #9B9B9B", +"' c #397B39", +"( c #026902", +") c #437E43", +"* c #FFFBF0", +"+ c #879487", +", c #046A04", +"- c #498049", +". c #788F78", +"0 c #126F12", +"1 c #4C814C", +"2 c #006800", +"3 c #397C39", +"4 c #4D814D", +"5 c #437F43", +"6 c #126E12", +"7 c #387B38", +"8 c #9A9A9A", +"9 c #4D824D", +": c #016901", +"; c #427E42", +"< c #488048", +"= c #799079", +"> c #4B814B", +"? c #869386", +"@ c #9B9BCD", +" ## $%%%%%%%%", +" ##& $'&&&&&&&&", +" ##& ()&********", +" ##+,-.$%%%%%%%%", +" ##01.23&&&&&&&&", +" ##4.(5&********", +" ##+,-.$%%%%%%%%", +" ##61.278&&&&&&&", +" ##9.:;&********", +" ##+,<=$%%%%%%%%", +" ##6>=23&&&&&&&&", +" ##9=(5& ", +" ##?,-& ", +" ##61& ", +" ##9& ", +" #@& "}; diff --git a/eeschema/bitmaps/Add_Line_Label.xpm b/eeschema/bitmaps/Add_Line_Label.xpm new file mode 100644 index 0000000000..a1dd06fae8 --- /dev/null +++ b/eeschema/bitmaps/Add_Line_Label.xpm @@ -0,0 +1,43 @@ +/* XPM */ +static char * add_line_label_xpm[] = { +"16 16 24 1", +" c None", +". c #000000", +"+ c #020202", +"@ c #8D8D8D", +"# c #202020", +"$ c #555555", +"% c #9A9A9A", +"& c #8C8C8C", +"* c #080808", +"= c #161616", +"- c #9B9B9B", +"; c #131313", +"> c #969696", +", c #212121", +"' c #7C7C7C", +") c #414141", +"! c #515151", +"~ c #525252", +"{ c #070707", +"] c #0B0B0B", +"^ c #979797", +"/ c #1F1F1F", +"( c #6B6B6B", +"_ c #009B00", +" ", +" ..+ ", +" ..+@ ", +" .#.$% ", +" ..&*=- ", +" .;>,.' ", +" ......)- ", +" ..!~~{]^ ", +" ./-% #+( ", +" -- -- ", +" ", +"________________", +"________________", +"----------------", +" ", +" "}; diff --git a/eeschema/bitmaps/Add_Power.xpm b/eeschema/bitmaps/Add_Power.xpm new file mode 100644 index 0000000000..702aa5389b --- /dev/null +++ b/eeschema/bitmaps/Add_Power.xpm @@ -0,0 +1,45 @@ +/* XPM */ +static char * add_power_xpm[] = { +"16 16 26 1", +" c None", +". c #D72D2D", +"+ c #E88B8B", +"@ c #ECDBE9", +"# c #D87B8B", +"$ c #C54C4C", +"% c #DCDCFF", +"& c #CAB9E9", +"* c #D13838", +"= c #9A9A9A", +"- c #C76A8B", +"; c #BE5959", +"> c #9B9B9B", +", c #D72E2E", +"' c #A18E8E", +") c #C35252", +"! c #DC4848", +"~ c #EFDAE5", +"{ c #E5E5FF", +"] c #D6C1E5", +"^ c #D54148", +"/ c #B96464", +"( c #D74348", +"_ c #CCA2CB", +": c #D33F48", +"< c #B37070", +" ", +" ... ", +" .+@#$ ", +" .@%&*= ", +" .#&-;> ", +" $,;'= ", +" ,>= ", +" ,> ", +" ,> ", +" > ", +" ,,,,,,,,, ", +" )!~{]^/>> ", +" )(_:/>> ", +" ),/>> ", +" <>> ", +" "}; diff --git a/eeschema/bitmaps/Break_Bus.xpm b/eeschema/bitmaps/Break_Bus.xpm new file mode 100644 index 0000000000..0a91f3b751 --- /dev/null +++ b/eeschema/bitmaps/Break_Bus.xpm @@ -0,0 +1,55 @@ +/* XPM */ +static char * break_bus_xpm[] = { +"16 16 36 1", +" c None", +". c #D72E2E", +"+ c #D82E2E", +"@ c #D43232", +"# c #9B9B9B", +"$ c #D82F2F", +"% c #CF3A3A", +"& c #C45050", +"* c #D62D2D", +"= c #A98080", +"- c #B66868", +"; c #9C9C9C", +"> c #0000C3", +", c #1818BC", +"' c #0000C2", +") c #1212BE", +"! c #4E4EAE", +"~ c #0404C1", +"{ c #1111BE", +"] c #2C2CB7", +"^ c #7474A4", +"/ c #1B1BBB", +"( c #0A0AC0", +"_ c #6F6FA6", +": c #6767A8", +"< c #1C1CBB", +"[ c #2020BA", +"} c #0202C2", +"| c #0909C0", +"1 c #5656AC", +"2 c #97979B", +"3 c #5353AD", +"4 c #0C0CBF", +"5 c #7C7CA3", +"6 c #8E8E9E", +"7 c #6161A9", +" ", +" . ", +" +@ .# $ ", +" %& .# *= ", +" - #$=; ", +" ", +" >>, >') ", +" >>>'!>>>~{ ", +" >>>>>]^/>>>>( ", +"'>>>,_## :<>>>[ ", +" }|12# 34'5#", +" 6# 7# ", +" ", +" ", +" ", +" "}; diff --git a/eeschema/bitmaps/Break_Line.xpm b/eeschema/bitmaps/Break_Line.xpm new file mode 100644 index 0000000000..9d6e4166aa --- /dev/null +++ b/eeschema/bitmaps/Break_Line.xpm @@ -0,0 +1,53 @@ +/* XPM */ +static char * break_line_xpm[] = { +"16 16 34 1", +" c None", +". c #D72E2E", +"+ c #D82E2E", +"@ c #D43232", +"# c #9B9B9B", +"$ c #D82F2F", +"% c #CF3A3A", +"& c #C45050", +"* c #D62D2D", +"= c #A98080", +"- c #B66868", +"; c #9C9C9C", +"> c #007D00", +", c #017D01", +"' c #077E07", +") c #568D56", +"! c #0E7F0E", +"~ c #158115", +"{ c #418941", +"] c #8F988F", +"^ c #4C8B4C", +"/ c #0A7F0A", +"( c #1A821A", +"_ c #268426", +": c #819681", +"< c #3A883A", +"[ c #057E05", +"} c #118011", +"| c #6C916C", +"1 c #699169", +"2 c #0D7F0D", +"3 c #8B978B", +"4 c #969A96", +"5 c #809580", +" ", +" . ", +" +@ .# $ ", +" %& .# *= ", +" - #$=; ", +" ", +" > , ", +" >>')!>~ ", +" >,{] ^/,( ", +" >>_:# <,'( ", +"[}|# 1_23", +" 4 5 ", +" ", +" ", +" ", +" "}; diff --git a/eeschema/bitmaps/Delete_Bus.xpm b/eeschema/bitmaps/Delete_Bus.xpm new file mode 100644 index 0000000000..2b108639db --- /dev/null +++ b/eeschema/bitmaps/Delete_Bus.xpm @@ -0,0 +1,149 @@ +/* XPM */ +static char * delete_bus_xpm[] = { +"16 16 130 2", +" c None", +". c #0000C3", +"+ c #9B9B9B", +"@ c #060606", +"# c #202020", +"$ c #242424", +"% c #1E1E1E", +"& c #151515", +"* c #000000", +"= c #48473F", +"- c #97968B", +"; c #9C9C98", +"> c #94948F", +", c #787872", +"' c #292822", +") c #080808", +"! c #605F51", +"~ c #5F5E51", +"{ c #7E7D6B", +"] c #9A988A", +"^ c #8B8A85", +"/ c #908F87", +"( c #A5A494", +"_ c #787766", +": c #504F44", +"< c #515045", +"[ c #161616", +"} c #706F65", +"| c #CDCBB3", +"1 c #CFCDB8", +"2 c #989683", +"3 c #55534C", +"4 c #2F2F2D", +"5 c #383830", +"6 c #737161", +"7 c #9B9984", +"8 c #ABA991", +"9 c #AAA990", +"0 c #515044", +"a c #DBD8C5", +"b c #E6E3D4", +"c c #E8E6D7", +"d c #CFCEBC", +"e c #A3A095", +"f c #858379", +"g c #7E7D6C", +"h c #868572", +"i c #ABA992", +"j c #BDBBA2", +"k c #B4B298", +"l c #8D8B77", +"m c #B7B5A2", +"n c #F0EDDB", +"o c #F4F2E4", +"p c #EFEDE1", +"q c #ECEADE", +"r c #E4E2D3", +"s c #DAD8C4", +"t c #CBC9B5", +"u c #CDCBB6", +"v c #B0AE99", +"w c #8C8A77", +"x c #676657", +"y c #6D6C5C", +"z c #B0AD9A", +"A c #CBC8BB", +"B c #ECE9D8", +"C c #EEECDC", +"D c #EBE9D9", +"E c #E1E0D6", +"F c #BBBAAA", +"G c #A8A796", +"H c #817F6F", +"I c #525145", +"J c #3F3F35", +"K c #383730", +"L c #525149", +"M c #747269", +"N c #A4A293", +"O c #ABA899", +"P c #A5A496", +"Q c #9E9D92", +"R c #727164", +"S c #565649", +"T c #3F3E36", +"U c #2E2D26", +"V c #23221D", +"W c #24241E", +"X c #696961", +"Y c #4B4A41", +"Z c #4E4D48", +"` c #4C4B45", +" . c #4C4C46", +".. c #3E3D34", +"+. c #313029", +"@. c #2A2926", +"#. c #262620", +"$. c #21201B", +"%. c #2A2A23", +"&. c #A1A095", +"*. c #808076", +"=. c #52524A", +"-. c #64645B", +";. c #505045", +">. c #272720", +",. c #393931", +"'. c #24241D", +"). c #39392F", +"!. c #24241F", +"~. c #2B2B24", +"{. c #A7A79C", +"]. c #C6C5BE", +"^. c #7D7C72", +"/. c #BAB9AE", +"(. c #7D7C6E", +"_. c #7D7D70", +":. c #404035", +"<. c #6F6F64", +"[. c #46463A", +"}. c #ABABA1", +"|. c #D7D7D0", +"1. c #8B8B7F", +"2. c #D7D7CF", +"3. c #989888", +"4. c #59594F", +"5. c #98988B", +"6. c #4A4A3E", +"7. c #77776A", +"8. c #4F4F41", +"9. c #282821", +". . . . . . . . . . . . . . . ", +". . . . . . . . . . . . . . . + ", +". . . . . . . . . . . . . . . + ", +" + + + + + + + + + + + + + + + ", +" @ # $ % & * ", +" * * = - ; > , ' * * ", +" ) ! ~ { ] ^ / ( _ : < * ", +" [ } | 1 2 3 4 5 6 7 8 9 0 * ", +" & a b c d e f g h i j k l * ", +" * m n o p q r s t u v w x * ", +" * y z A B C D E F G H I J * ", +" K L M N O P Q R S T U V ", +" W X Y Z ` ...+.W @.#.$. ", +" %.&.*.=.-.;.>.,.'.=.).!. ", +" ~.{.].^./.(.Y _.:.<.[.>. ", +" ~.}.|.1.2.3.4.5.6.7.8.9. "}; diff --git a/eeschema/bitmaps/Delete_Connection.xpm b/eeschema/bitmaps/Delete_Connection.xpm new file mode 100644 index 0000000000..ca223253c0 --- /dev/null +++ b/eeschema/bitmaps/Delete_Connection.xpm @@ -0,0 +1,176 @@ +/* XPM */ +static char * delete_connection_xpm[] = { +"16 16 157 2", +" c None", +". c #000000", +"+ c #242424", +"@ c #424242", +"# c #222222", +"$ c #868483", +"% c #E1D5CA", +"& c #B7A595", +"* c #564A3F", +"= c #0B0A0A", +"- c #151515", +"; c #EAE2DB", +"> c #FFEBDA", +", c #FFE0C5", +"' c #FFD5B1", +") c #FFCA9C", +"! c #806044", +"~ c #2B2B2B", +"{ c #645F59", +"] c #FFE6CF", +"^ c #FFDBBB", +"/ c #FFD0A6", +"( c #FFC591", +"_ c #FFBA7D", +": c #E49C5D", +"< c #111111", +"[ c #FFFFFF", +"} c #9C9C9C", +"| c #64584D", +"1 c #FFD5B0", +"2 c #FFCA9B", +"3 c #FFBF87", +"4 c #FFB472", +"5 c #FFA95D", +"6 c #E48D41", +"7 c #D8D8D8", +"8 c #C1C1C1", +"9 c #16120F", +"0 c #EAB485", +"a c #FFB97C", +"b c #FFAF67", +"c c #FFA453", +"d c #FF993E", +"e c #804715", +"f c #3A3A3A", +"g c #CACACA", +"h c #393939", +"i c #22180F", +"j c #865931", +"k c #E18B40", +"l c #B76925", +"m c #562E0A", +"n c #030100", +"o c #6E6E6E", +"p c #010101", +"q c #5C5A4E", +"r c #383732", +"s c #0E0E0D", +"t c #212120", +"u c #51514C", +"v c #4D4C41", +"w c #0F0F0F", +"x c #C0BEA3", +"y c #BFBDA3", +"z c #7A7967", +"A c #484740", +"B c #272725", +"C c #36352E", +"D c #868472", +"E c #9F9D87", +"F c #A19F88", +"G c #A3A18A", +"H c #2A2A2A", +"I c #D1CFBA", +"J c #DAD8C2", +"K c #E0DECD", +"L c #B7B5A0", +"M c #63615A", +"N c #383735", +"O c #3C3C33", +"P c #616053", +"Q c #989681", +"R c #B5B399", +"S c #B1B096", +"T c #A2A089", +"U c #E6E2D1", +"V c #F2EFE7", +"W c #F0EFE2", +"X c #E8E7D8", +"Y c #E3E0D0", +"Z c #D3D0BC", +"` c #C2C0A6", +" . c #AEAC93", +".. c #BEBCA2", +"+. c #C4C2AA", +"@. c #B6B49A", +"#. c #787665", +"$. c #888774", +"%. c #EFEBD0", +"&. c #F9F6E7", +"*. c #F7F3EB", +"=. c #F6F5EC", +"-. c #F6F5EA", +";. c #F4F2E5", +">. c #EBE9D8", +",. c #DCDBC9", +"'. c #9B9987", +"). c #626153", +"!. c #575649", +"~. c #515045", +"{. c #727064", +"]. c #9D9B8F", +"^. c #E2DFC6", +"/. c #E7E3CD", +"(. c #E0DEC9", +"_. c #D0D0CA", +":. c #8D8C7F", +"<. c #757463", +"[. c #676657", +"}. c #424137", +"|. c #282721", +"1. c #1E1E1A", +"2. c #33332F", +"3. c #4A4843", +"4. c #676661", +"5. c #6F6E65", +"6. c #6A6A63", +"7. c #6D6B5C", +"8. c #57564A", +"9. c #383830", +"0. c #161514", +"a. c #191915", +"b. c #1E1D18", +"c. c #292922", +"d. c #9E9E93", +"e. c #4C4C3F", +"f. c #35352F", +"g. c #292925", +"h. c #2E2E29", +"i. c #0E0E0C", +"j. c #0A0A08", +"k. c #0F0F0C", +"l. c #3D3D37", +"m. c #33332A", +"n. c #23231E", +"o. c #2A2A23", +"p. c #A3A297", +"q. c #B5B4AC", +"r. c #706F66", +"s. c #9F9F90", +"t. c #737262", +"u. c #3F3F34", +"v. c #68685A", +"w. c #38382E", +"x. c #68685E", +"y. c #3E3E33", +"z. c #25251F", +" . . + @ ", +" # $ % & * = ", +" - ; > , ' ) ! ~ ", +" { ] ^ / ( _ : < ", +" [ [ } | 1 2 3 4 5 6 < 7 [ [ [ ", +" [ [ 8 9 0 a b c d e f g [ [ [ ", +" h i j k l m n o ", +" . p q r s t u v p . ", +" w x y z A B C D E F G . ", +" H I J K L M N O P Q R S T . ", +" . U V W X Y Z ` ...+.@.#.. ", +" . $.%.&.*.=.-.;.>.,.'.).!.. ", +" . ~.{.].^./.(._.:.<.[.}.|.. ", +" 1.2.3.4.5.6.7.8.9.0.a.b. ", +" c.d.e.f.g.h.i.j.k.l.m.n. ", +" o.p.q.r.s.t.u.v.w.x.y.z. "}; diff --git a/eeschema/bitmaps/Delete_GLabel.xpm b/eeschema/bitmaps/Delete_GLabel.xpm new file mode 100644 index 0000000000..1d672e0a2e --- /dev/null +++ b/eeschema/bitmaps/Delete_GLabel.xpm @@ -0,0 +1,152 @@ +/* XPM */ +static char * delete_glabel_xpm[] = { +"16 16 133 2", +" c None", +". c #695F00", +"+ c #685E00", +"@ c #635A00", +"# c #4B4400", +"$ c #9191FF", +"% c #9B9BFF", +"& c #A5A5FF", +"* c #857F66", +"= c #5F5500", +"- c #5E5500", +"; c #574E00", +"> c #625800", +", c #9E9EFF", +"' c #A8A8FF", +") c #B2B2FF", +"! c #BBBBF9", +"~ c #7D7539", +"{ c #595100", +"] c #ACACFF", +"^ c #B6B6FF", +"/ c #C0C0FF", +"( c #CACAFF", +"_ c #BFBDCC", +": c #B9B9FF", +"< c #C3C3FF", +"[ c #CECEFF", +"} c #D5D5F9", +"| c #847C39", +"1 c #4E4700", +"2 c #C7C7FF", +"3 c #D1D1FF", +"4 c #DBDBFF", +"5 c #9B9566", +"6 c #574F00", +"7 c #0E0D00", +"8 c #0D0D0D", +"9 c #414141", +"0 c #494949", +"a c #3D3D3D", +"b c #2B2B2B", +"c c #000000", +"d c #010101", +"e c #838170", +"f c #EEEBD6", +"g c #F0EFE7", +"h c #ECEBE2", +"i c #C5C4B8", +"j c #525145", +"k c #0F0F0F", +"l c #C0BEA3", +"m c #BFBDA3", +"n c #797866", +"o c #47463F", +"p c #262624", +"q c #35342D", +"r c #858371", +"s c #9E9C86", +"t c #A19F88", +"u c #A3A18A", +"v c #2A2A2A", +"w c #D1CFBA", +"x c #DAD8C2", +"y c #E0DECD", +"z c #B7B5A0", +"A c #63615A", +"B c #383735", +"C c #3B3B32", +"D c #605F52", +"E c #989681", +"F c #B5B399", +"G c #B1B096", +"H c #A2A089", +"I c #E6E2D1", +"J c #F2EFE7", +"K c #F0EFE2", +"L c #E8E7D8", +"M c #E3E0D0", +"N c #D3D0BC", +"O c #C1BFA5", +"P c #ADAB92", +"Q c #BEBCA2", +"R c #C4C2AA", +"S c #B6B49A", +"T c #787665", +"U c #888774", +"V c #EFEBD0", +"W c #F9F6E7", +"X c #F7F3EB", +"Y c #F6F5EC", +"Z c #F6F5EA", +"` c #F3F1E4", +" . c #EAE8D7", +".. c #DCDBC9", +"+. c #9B9987", +"@. c #626153", +"#. c #575649", +"$. c #515045", +"%. c #727064", +"&. c #9D9B8F", +"*. c #E2DFC6", +"=. c #E7E3CD", +"-. c #E0DEC9", +";. c #CFCFC9", +">. c #8C8B7E", +",. c #757463", +"'. c #676657", +"). c #424137", +"!. c #282721", +"~. c #1E1E1A", +"{. c #33332F", +"]. c #4A4843", +"^. c #676661", +"/. c #6F6E65", +"(. c #6A6A63", +"_. c #6D6B5C", +":. c #57564A", +"<. c #383830", +"[. c #161514", +"}. c #191915", +"|. c #1E1D18", +"1. c #292922", +"2. c #9E9E93", +"3. c #4C4C3F", +"4. c #35352F", +"5. c #292925", +"6. c #2E2E29", +"7. c #0E0E0C", +"8. c #0A0A08", +"9. c #0F0F0C", +"0. c #3D3D37", +"a. c #33332A", +"b. c #23231E", +" . . . . . . . ", +" . + @ # . $ % & * = ", +" . - ; > . , ' ) ! ~ { ", +" . . . . . ] ^ / ( _ . ", +". + @ # . : < [ } | 1 ", +". - . > . 2 3 4 5 6 ", +" . . . . - 7 ", +" 8 9 0 a b c d ", +" c c e f g h i j c c ", +" k l m n o p q r s t u c ", +" v w x y z A B C D E F G H c ", +" c I J K L M N O P Q R S T c ", +" c U V W X Y Z ` ...+.@.#.c ", +" c $.%.&.*.=.-.;.>.,.'.).!.c ", +" ~.{.].^./.(._.:.<.[.}.|. ", +" 1.2.3.4.5.6.7.8.9.0.a.b. "}; diff --git a/eeschema/bitmaps/Delete_Node.xpm b/eeschema/bitmaps/Delete_Node.xpm new file mode 100644 index 0000000000..b543f4383b --- /dev/null +++ b/eeschema/bitmaps/Delete_Node.xpm @@ -0,0 +1,151 @@ +/* XPM */ +static char * delete_node_xpm[] = { +"16 16 132 2", +" c None", +". c #007D00", +"+ c #4D8B4D", +"@ c #ABABAB", +"# c #001900", +"$ c #0F1C0F", +"% c #545454", +"& c #3C3C3C", +"* c #C9C8C8", +"= c #C9BBAE", +"- c #3C342C", +"; c #2E2E2E", +"> c #C9C3BE", +", c #FFE6D0", +"' c #FFD4AE", +") c #C9996E", +"! c #0D1A0D", +"~ c #C9B099", +"{ c #FFCDA1", +"] c #FFBB7F", +"^ c #C98549", +"/ c #091609", +"( c #448244", +"_ c #9B9B9B", +": c #555555", +"< c #3C2F23", +"[ c #C98E5A", +"} c #C9803F", +"| c #3C220B", +"1 c #4C4C4C", +"2 c #9C9C9C", +"3 c #0C0C0C", +"4 c #1A1A1A", +"5 c #020E02", +"6 c #000000", +"7 c #838170", +"8 c #DFDDC9", +"9 c #2E6C2B", +"0 c #7A7972", +"a c #4D4C41", +"b c #0F0F0F", +"c c #C0BEA3", +"d c #BFBDA3", +"e c #797866", +"f c #47463F", +"g c #0F4E0D", +"h c #6B6A5B", +"i c #9E9C86", +"j c #A19F88", +"k c #A3A18A", +"l c #2A2A2A", +"m c #D1CFBA", +"n c #DAD8C2", +"o c #E0DECD", +"p c #B7B5A0", +"q c #63615A", +"r c #11500F", +"s c #4D4D42", +"t c #989681", +"u c #B5B399", +"v c #B1B096", +"w c #A2A089", +"x c #E6E2D1", +"y c #F2EFE7", +"z c #F0EFE2", +"A c #E8E7D8", +"B c #E3E0D0", +"C c #3A7831", +"D c #8B8A76", +"E c #BEBCA2", +"F c #C4C2AA", +"G c #B6B49A", +"H c #787665", +"I c #888774", +"J c #EFEBD0", +"K c #F9F6E7", +"L c #F7F3EB", +"M c #F6F5EC", +"N c #498745", +"O c #BCBBAD", +"P c #DCDBC9", +"Q c #9B9987", +"R c #626153", +"S c #575649", +"T c #515045", +"U c #727064", +"V c #9D9B8F", +"W c #E2DFC6", +"X c #E7E3CD", +"Y c #E0DEC9", +"Z c #7E7E7A", +"` c #717066", +" . c #757463", +".. c #676657", +"+. c #424137", +"@. c #282721", +"#. c #1E1E1A", +"$. c #33332F", +"%. c #4A4843", +"&. c #676661", +"*. c #6F6E65", +"=. c #6A6A63", +"-. c #6D6B5C", +";. c #57564A", +">. c #383830", +",. c #161514", +"'. c #191915", +"). c #1E1D18", +"!. c #292922", +"~. c #9E9E93", +"{. c #4C4C3F", +"]. c #35352F", +"^. c #292925", +"/. c #2E2E29", +"(. c #0E0E0C", +"_. c #0A0A08", +":. c #0F0F0C", +"<. c #3D3D37", +"[. c #33332A", +"}. c #23231E", +"|. c #2A2A23", +"1. c #A3A297", +"2. c #B5B4AC", +"3. c #706F66", +"4. c #9F9F90", +"5. c #737262", +"6. c #3F3F34", +"7. c #68685A", +"8. c #38382E", +"9. c #68685E", +"0. c #3E3E33", +"a. c #25251F", +" . + @ ", +" # $ % ", +" & * = - ; ", +". . . . . # > , ' ) # . . . . ", +". + + + + ! ~ { ] ^ / ( + + + _ ", +" @ @ @ @ : < [ } | 1 2 @ @ @ @ ", +" 3 4 # 5 3 6 ", +" 6 6 7 8 . 9 0 a 6 6 ", +" b c d e f . g h i j k 6 ", +" l m n o p q . r s t u v w 6 ", +" 6 x y z A B . C D E F G H 6 ", +" 6 I J K L M . N O P Q R S 6 ", +" 6 T U V W X Y Z ` ...+.@.6 ", +" #.$.%.&.*.=.-.;.>.,.'.). ", +" !.~.{.].^./.(._.:.<.[.}. ", +" |.1.2.3.4.5.6.7.8.9.0.a. "}; diff --git a/eeschema/bitmaps/Delete_Pin.xpm b/eeschema/bitmaps/Delete_Pin.xpm new file mode 100644 index 0000000000..f42a57ad9e --- /dev/null +++ b/eeschema/bitmaps/Delete_Pin.xpm @@ -0,0 +1,148 @@ +/* XPM */ +static char * delete_pin_xpm[] = { +"16 16 129 2", +" c None", +". c #D72E2E", +"+ c #DE676B", +"@ c #DA636B", +"# c #D62E2E", +"$ c #E5E5FF", +"% c #D7D7FF", +"& c #D25B6B", +"* c #D23535", +"= c #CACAFF", +"- c #CE576B", +"; c #D03939", +"> c #B96464", +", c #9B9B9B", +"' c #C35151", +") c #B17171", +"! c #B36E6E", +"~ c #CA4444", +"{ c #9C9898", +"] c #919191", +"^ c #6F6F6F", +"/ c #0E0E0E", +"( c #414141", +"_ c #494949", +": c #3D3D3D", +"< c #2B2B2B", +"[ c #000000", +"} c #838170", +"| c #EEEBD6", +"1 c #F0EFE7", +"2 c #ECEBE2", +"3 c #C5C4B8", +"4 c #525145", +"5 c #0F0F0F", +"6 c #C0BEA3", +"7 c #BFBDA3", +"8 c #797866", +"9 c #47463F", +"0 c #262624", +"a c #35342D", +"b c #858371", +"c c #9E9C86", +"d c #A19F88", +"e c #A3A18A", +"f c #2A2A2A", +"g c #D1CFBA", +"h c #DAD8C2", +"i c #E0DECD", +"j c #B7B5A0", +"k c #63615A", +"l c #383735", +"m c #3B3B32", +"n c #605F52", +"o c #989681", +"p c #B5B399", +"q c #B1B096", +"r c #A2A089", +"s c #E6E2D1", +"t c #F2EFE7", +"u c #F0EFE2", +"v c #E8E7D8", +"w c #E3E0D0", +"x c #D3D0BC", +"y c #C1BFA5", +"z c #ADAB92", +"A c #BEBCA2", +"B c #C4C2AA", +"C c #B6B49A", +"D c #787665", +"E c #888774", +"F c #EFEBD0", +"G c #F9F6E7", +"H c #F7F3EB", +"I c #F6F5EC", +"J c #F6F5EA", +"K c #F3F1E4", +"L c #EAE8D7", +"M c #DCDBC9", +"N c #9B9987", +"O c #626153", +"P c #575649", +"Q c #515045", +"R c #727064", +"S c #9D9B8F", +"T c #E2DFC6", +"U c #E7E3CD", +"V c #E0DEC9", +"W c #CFCFC9", +"X c #8C8B7E", +"Y c #757463", +"Z c #676657", +"` c #424137", +" . c #282721", +".. c #1E1E1A", +"+. c #33332F", +"@. c #4A4843", +"#. c #676661", +"$. c #6F6E65", +"%. c #6A6A63", +"&. c #6D6B5C", +"*. c #57564A", +"=. c #383830", +"-. c #161514", +";. c #191915", +">. c #1E1D18", +",. c #292922", +"'. c #9E9E93", +"). c #4C4C3F", +"!. c #35352F", +"~. c #292925", +"{. c #2E2E29", +"]. c #0E0E0C", +"^. c #0A0A08", +"/. c #0F0F0C", +"(. c #3D3D37", +"_. c #33332A", +":. c #23231E", +"<. c #2A2A23", +"[. c #A3A297", +"}. c #B5B4AC", +"|. c #706F66", +"1. c #9F9F90", +"2. c #737262", +"3. c #3F3F34", +"4. c #68685A", +"5. c #38382E", +"6. c #68685E", +"7. c #3E3E33", +"8. c #25251F", +" . . ", +" . + @ . ", +"# + $ % & . . . . . . . . . ", +"* @ % = - ; > > > > > > > > , ", +"' . & - . ) , , , , , , , , , ", +" ! ~ ~ ) { ", +" , ] ^ / ( _ : < [ ", +" [ [ } | 1 2 3 4 [ [ ", +" 5 6 7 8 9 0 a b c d e [ ", +" f g h i j k l m n o p q r [ ", +" [ s t u v w x y z A B C D [ ", +" [ E F G H I J K L M N O P [ ", +" [ Q R S T U V W X Y Z ` .[ ", +" ..+.@.#.$.%.&.*.=.-.;.>. ", +" ,.'.).!.~.{.].^./.(._.:. ", +" <.[.}.|.1.2.3.4.5.6.7.8. "}; diff --git a/eeschema/bitmaps/Delete_Pinsheet.xpm b/eeschema/bitmaps/Delete_Pinsheet.xpm new file mode 100644 index 0000000000..4fcd3cbd10 --- /dev/null +++ b/eeschema/bitmaps/Delete_Pinsheet.xpm @@ -0,0 +1,178 @@ +/* XPM */ +static char * delete_pinsheet_xpm[] = { +"16 16 159 2", +" c None", +". c #6F6500", +"+ c #FEFEFF", +"@ c #FCFCFF", +"# c #F1F1FF", +"$ c #D3D2D8", +"% c #746B0E", +"& c #8D8A6C", +"* c #6E6400", +"= c #695F00", +"- c #4F4800", +"; c #F8F8FF", +"> c #EDEDFF", +", c #E2E2FF", +"' c #D6D6FF", +") c #AEABB1", +"! c #716707", +"~ c #92907D", +"{ c #635A00", +"] c #5C5300", +"^ c #675E00", +"/ c #F3F3FF", +"( c #E8E8FF", +"_ c #DDDDFF", +": c #D2D2FF", +"< c #C7C7FF", +"[ c #BCBCFF", +"} c #827B4C", +"| c #787020", +"1 c #939180", +"2 c #E4E4FF", +"3 c #D9D9FF", +"4 c #CECEFF", +"5 c #C2C2FF", +"6 c #B7B7FF", +"7 c #9895B1", +"8 c #847F4D", +"9 c #72690E", +"0 c #D4D4FF", +"a c #C9C9FF", +"b c #BEBEFF", +"c c #B3B3FF", +"d c #9E9DD8", +"e c #71680E", +"f c #9B9B9B", +"g c #756D18", +"h c #675F0B", +"i c #685F00", +"j c #504901", +"k c #0E0E0D", +"l c #424242", +"m c #4A4A4A", +"n c #3E3E3E", +"o c #2B2B2B", +"p c #000000", +"q c #797979", +"r c #010101", +"s c #848271", +"t c #EFECD7", +"u c #F1F0E8", +"v c #ECEBE2", +"w c #C5C4B8", +"x c #525145", +"y c #0F0F0F", +"z c #C0BEA3", +"A c #BFBDA3", +"B c #797866", +"C c #47463F", +"D c #262624", +"E c #35342D", +"F c #858371", +"G c #9E9C86", +"H c #A19F88", +"I c #A3A18A", +"J c #2A2A2A", +"K c #D1CFBA", +"L c #DAD8C2", +"M c #E0DECD", +"N c #B7B5A0", +"O c #63615A", +"P c #383735", +"Q c #3B3B32", +"R c #605F52", +"S c #989681", +"T c #B5B399", +"U c #B1B096", +"V c #A2A089", +"W c #E6E2D1", +"X c #F2EFE7", +"Y c #F0EFE2", +"Z c #E8E7D8", +"` c #E3E0D0", +" . c #D3D0BC", +".. c #C1BFA5", +"+. c #ADAB92", +"@. c #BEBCA2", +"#. c #C4C2AA", +"$. c #B6B49A", +"%. c #787665", +"&. c #888774", +"*. c #EFEBD0", +"=. c #F9F6E7", +"-. c #F7F3EB", +";. c #F6F5EC", +">. c #F6F5EA", +",. c #F3F1E4", +"'. c #EAE8D7", +"). c #DCDBC9", +"!. c #9B9987", +"~. c #626153", +"{. c #575649", +"]. c #515045", +"^. c #727064", +"/. c #9D9B8F", +"(. c #E2DFC6", +"_. c #E7E3CD", +":. c #E0DEC9", +"<. c #CFCFC9", +"[. c #8C8B7E", +"}. c #757463", +"|. c #676657", +"1. c #424137", +"2. c #282721", +"3. c #1E1E1A", +"4. c #33332F", +"5. c #4A4843", +"6. c #676661", +"7. c #6F6E65", +"8. c #6A6A63", +"9. c #6D6B5C", +"0. c #57564A", +"a. c #383830", +"b. c #161514", +"c. c #191915", +"d. c #1E1D18", +"e. c #292922", +"f. c #9E9E93", +"g. c #4C4C3F", +"h. c #35352F", +"i. c #292925", +"j. c #2E2E29", +"k. c #0E0E0C", +"l. c #0A0A08", +"m. c #0F0F0C", +"n. c #3D3D37", +"o. c #33332A", +"p. c #23231E", +"q. c #2A2A23", +"r. c #A3A297", +"s. c #B5B4AC", +"t. c #706F66", +"u. c #9F9F90", +"v. c #737262", +"w. c #3F3F34", +"x. c #68685A", +"y. c #38382E", +"z. c #68685E", +"A. c #3E3E33", +"B. c #25251F", +". . . . . . . . ", +". + + @ # $ % & . * = - ", +". + ; > , ' ) ! ~ . { ] ^ ", +". / ( _ : < [ } | 1 . . . . ", +". 2 3 4 5 6 7 ! ~ 8 9 = - ", +". 0 a b c d e & f g h . ^ ", +". . . . i j k l m n o p ", +" f f q r r s t u v w x p p ", +" y z A B C D E F G H I p ", +" J K L M N O P Q R S T U V p ", +" p W X Y Z ` ...+.@.#.$.%.p ", +" p &.*.=.-.;.>.,.'.).!.~.{.p ", +" p ].^./.(._.:.<.[.}.|.1.2.p ", +" 3.4.5.6.7.8.9.0.a.b.c.d. ", +" e.f.g.h.i.j.k.l.m.n.o.p. ", +" q.r.s.t.u.v.w.x.y.z.A.B. "}; diff --git a/eeschema/bitmaps/Delete_Sheet.xpm b/eeschema/bitmaps/Delete_Sheet.xpm new file mode 100644 index 0000000000..1ae573c35c --- /dev/null +++ b/eeschema/bitmaps/Delete_Sheet.xpm @@ -0,0 +1,153 @@ +/* XPM */ +static char * delete_sheet_xpm[] = { +"16 16 134 2", +" c None", +". c #000000", +"+ c #FFFFFF", +"@ c #242424", +"# c #FDFDFD", +"$ c #EBEBEB", +"% c #787878", +"& c #484848", +"* c #FCFCFC", +"= c #424242", +"- c #616161", +"; c #FAFAFA", +"> c #BCBCBC", +", c #101010", +"' c #F9F9F9", +") c #C7C7C7", +"! c #1A1A1A", +"~ c #F8F8F8", +"{ c #DCDCDC", +"] c #A8A8A8", +"^ c #0E0E0E", +"/ c #4A4A4A", +"( c #3D3D3D", +"_ c #2B2B2B", +": c #F6F6F6", +"< c #B7B7B7", +"[ c #010101", +"} c #848271", +"| c #EFECD7", +"1 c #F1F0E8", +"2 c #ECEBE2", +"3 c #C5C4B8", +"4 c #525145", +"5 c #F5F5F5", +"6 c #B4B4B4", +"7 c #C1BFA4", +"8 c #C0BEA4", +"9 c #7A7967", +"0 c #484740", +"a c #272725", +"b c #35342D", +"c c #858371", +"d c #9E9C86", +"e c #A19F88", +"f c #A3A18A", +"g c #F3F3F3", +"h c #D2D0BB", +"i c #DBD9C3", +"j c #E1DFCE", +"k c #B8B6A1", +"l c #64625B", +"m c #393836", +"n c #3B3B32", +"o c #605F52", +"p c #989681", +"q c #B5B399", +"r c #B1B096", +"s c #A2A089", +"t c #F2F2F2", +"u c #E7E3D2", +"v c #F3F0E8", +"w c #F1F0E3", +"x c #E9E8D9", +"y c #E4E1D1", +"z c #D4D1BD", +"A c #C1BFA5", +"B c #ADAB92", +"C c #BEBCA2", +"D c #C4C2AA", +"E c #B6B49A", +"F c #787665", +"G c #F0F0F0", +"H c #898875", +"I c #F0ECD1", +"J c #FAF7E8", +"K c #F8F4EC", +"L c #F7F6ED", +"M c #F7F6EB", +"N c #F3F1E4", +"O c #EAE8D7", +"P c #DCDBC9", +"Q c #9B9987", +"R c #626153", +"S c #575649", +"T c #BEBEBE", +"U c #606060", +"V c #525146", +"W c #737165", +"X c #9E9C90", +"Y c #E3E0C7", +"Z c #E8E4CE", +"` c #E1DFCA", +" . c #CFCFC9", +".. c #8C8B7E", +"+. c #757463", +"@. c #676657", +"#. c #424137", +"$. c #282721", +"%. c #1E1E1A", +"&. c #33332F", +"*. c #4A4843", +"=. c #676661", +"-. c #6F6E65", +";. c #6A6A63", +">. c #6D6B5C", +",. c #57564A", +"'. c #383830", +"). c #161514", +"!. c #191915", +"~. c #1E1D18", +"{. c #292922", +"]. c #9E9E93", +"^. c #4C4C3F", +"/. c #35352F", +"(. c #292925", +"_. c #2E2E29", +":. c #0E0E0C", +"<. c #0A0A08", +"[. c #0F0F0C", +"}. c #3D3D37", +"|. c #33332A", +"1. c #23231E", +"2. c #2A2A23", +"3. c #A3A297", +"4. c #B5B4AC", +"5. c #706F66", +"6. c #9F9F90", +"7. c #737262", +"8. c #3F3F34", +"9. c #68685A", +"0. c #38382E", +"a. c #68685E", +"b. c #3E3E33", +"c. c #25251F", +". . . . . . . . ", +". + + + + + + @ . ", +". # $ $ $ $ $ % & . ", +". * $ $ $ $ $ = - . ", +". ; $ $ $ $ $ $ > , ", +". ' $ $ $ $ $ $ ) ! ", +". ~ $ $ { ] ^ = / ( _ . ", +". : $ < [ [ } | 1 2 3 4 . . ", +". 5 6 , 7 8 9 0 a b c d e f . ", +". g _ h i j k l m n o p q r s . ", +". t [ u v w x y z A B C D E F . ", +". G [ H I J K L M N O P Q R S . ", +". T U V W X Y Z ` ...+.@.#.$.. ", +". . . %.&.*.=.-.;.>.,.'.).!.~. ", +" {.].^./.(._.:.<.[.}.|.1. ", +" 2.3.4.5.6.7.8.9.0.a.b.c. "}; diff --git a/eeschema/bitmaps/Edit_Comp_Ref.xpm b/eeschema/bitmaps/Edit_Comp_Ref.xpm new file mode 100644 index 0000000000..aa9d25a1a7 --- /dev/null +++ b/eeschema/bitmaps/Edit_Comp_Ref.xpm @@ -0,0 +1,91 @@ +/* XPM */ +static char * edit_comp_ref_xpm[] = { +"16 16 72 1", +" c None", +". c #000000", +"+ c #080808", +"@ c #B0B0B0", +"# c #1B1B1C", +"$ c #161616", +"% c #FBFBFF", +"& c #EAEAF3", +"* c #69696F", +"= c #0A0A0A", +"- c #F7F7FF", +"; c #F3F3FF", +"> c #EEEEFF", +", c #BBBBCC", +"' c #2E2E33", +") c #9B9B9B", +"! c #F4F4FF", +"~ c #EFEFFF", +"{ c #EBEBFF", +"] c #E6E6FF", +"^ c #DFDFFC", +"/ c #7D7D90", +"( c #111113", +"_ c #0C0C0C", +": c #F0F0FF", +"< c #ECECFF", +"[ c #E7E7FF", +"} c #E3E3FF", +"| c #DEDEFF", +"1 c #D9D9FF", +"2 c #BEBEE3", +"3 c #0D0D10", +"4 c #B4B4B4", +"5 c #A2A2B0", +"6 c #131313", +"7 c #1C1C1C", +"8 c #EDEDFF", +"9 c #E8E8FF", +"0 c #E4E4FF", +"a c #DFDFFF", +"b c #DADAFF", +"c c #D6D6FF", +"d c #BABAE3", +"e c #AAAAB8", +"f c #9898B4", +"g c #171717", +"h c #464646", +"i c #333333", +"j c #E9E9FF", +"k c #E5E5FF", +"l c #E0E0FF", +"m c #DCDCFF", +"n c #D4D4FC", +"o c #777790", +"p c #151517", +"q c #4E4E4E", +"r c #202020", +"s c #767676", +"t c #E1E1FF", +"u c #DDDDFF", +"v c #ADADCC", +"w c #2A2A33", +"x c #8E8E8E", +"y c #E2E2FF", +"z c #D4D4F3", +"A c #5E5E6F", +"B c #0D0D0E", +"C c #676767", +"D c #9A9AB0", +"E c #18181C", +"F c #F2F2F2", +"G c #C0C0C0", +" . . . ... ", +" .+ . . . ", +" .@#$ . . ... ", +" .%&*= ... . ", +"..-;>,'$ ", +").!~{]^/(_.. ", +" .:<[}|1234567. ", +" .890abcd3efghi)", +" .jklmnopqrrs)))", +"..]tuvwix) )) ", +").yzABC)) ", +" .DEix) ", +" ._C)))) ) )))))", +" .x) ) ))))FG )", +" ) ) ))))FG ) ", +" ) ) )))))"}; diff --git a/eeschema/bitmaps/Edit_Comp_Value.xpm b/eeschema/bitmaps/Edit_Comp_Value.xpm new file mode 100644 index 0000000000..238af69d06 --- /dev/null +++ b/eeschema/bitmaps/Edit_Comp_Value.xpm @@ -0,0 +1,92 @@ +/* XPM */ +static char * edit_comp_value_xpm[] = { +"16 16 73 1", +" c None", +". c #000000", +"+ c #9B9B9B", +"@ c #080808", +"# c #B0B0B0", +"$ c #1B1B1C", +"% c #161616", +"& c #FBFBFF", +"* c #EAEAF3", +"= c #69696F", +"- c #0A0A0A", +"; c #F7F7FF", +"> c #F3F3FF", +", c #EEEEFF", +"' c #BBBBCC", +") c #2E2E33", +"! c #F4F4FF", +"~ c #EFEFFF", +"{ c #EBEBFF", +"] c #E6E6FF", +"^ c #DFDFFC", +"/ c #7D7D90", +"( c #111113", +"_ c #0C0C0C", +": c #F0F0FF", +"< c #ECECFF", +"[ c #E7E7FF", +"} c #E3E3FF", +"| c #DEDEFF", +"1 c #D9D9FF", +"2 c #BEBEE3", +"3 c #0D0D10", +"4 c #B4B4B4", +"5 c #A2A2B0", +"6 c #131313", +"7 c #1C1C1C", +"8 c #EDEDFF", +"9 c #E8E8FF", +"0 c #E4E4FF", +"a c #DFDFFF", +"b c #DADAFF", +"c c #D6D6FF", +"d c #BABAE3", +"e c #AAAAB8", +"f c #9898B4", +"g c #171717", +"h c #464646", +"i c #333333", +"j c #E9E9FF", +"k c #E5E5FF", +"l c #E0E0FF", +"m c #DCDCFF", +"n c #D4D4FC", +"o c #777790", +"p c #151517", +"q c #4E4E4E", +"r c #202020", +"s c #767676", +"t c #E1E1FF", +"u c #DDDDFF", +"v c #ADADCC", +"w c #2A2A33", +"x c #8E8E8E", +"y c #E2E2FF", +"z c #D4D4F3", +"A c #5E5E6F", +"B c #0D0D0E", +"C c #676767", +"D c #9A9AB0", +"E c #18181C", +"F c #0B0B0B", +"G c #E0E0E0", +"H c #606060", +" . + + +++ ", +" .@ + + + ", +" .#$% + + +++ ", +" .&*=- +++ + ", +"..;>,')% ", +"+.!~{]^/(_.. ", +" .:<[}|1234567. ", +" .890abcd3efghi+", +" .jklmnopqrrs+++", +"..]tuvwix+ ++ ", +"+.yzABC++ ", +" .DEix+ ", +" ._C..F. . .....", +" .x+ . ....GH .", +" + . ....GH . ", +" . . ....."}; diff --git a/eeschema/bitmaps/Edit_Component.xpm b/eeschema/bitmaps/Edit_Component.xpm new file mode 100644 index 0000000000..5045527b32 --- /dev/null +++ b/eeschema/bitmaps/Edit_Component.xpm @@ -0,0 +1,99 @@ +/* XPM */ +static char * edit_component_xpm[] = { +"16 16 80 1", +" c None", +". c #000000", +"+ c #F9E53A", +"@ c #F0B44C", +"# c #FAE93C", +"$ c #F5B343", +"% c #635632", +"& c #0D0D0D", +"* c #FAE73A", +"= c #F5B344", +"- c #6B5E33", +"; c #F5F5F5", +"> c #3D3D3E", +", c #161616", +"' c #F8E239", +") c #F2B043", +"! c #615739", +"~ c #FBFBFF", +"{ c #F1F1FA", +"] c #9E9EA4", +"^ c #111111", +"/ c #F7DD38", +"( c #F1AD41", +"_ c #615637", +": c #F7F7FF", +"< c #F3F3FF", +"[ c #EEEEFF", +"} c #D6D6E7", +"| c #515156", +"1 c #F7DA37", +"2 c #EDB24C", +"3 c #655931", +"4 c #9B9B9B", +"5 c #F4F4FF", +"6 c #EFEFFF", +"7 c #EBEBFF", +"8 c #E6E6FF", +"9 c #010101", +"0 c #F7D737", +"a c #EEA73E", +"b c #64582F", +"c c #F0F0FF", +"d c #ECECFF", +"e c #E7E7FF", +"f c #F5D136", +"g c #ECA33E", +"h c #5C5230", +"i c #B8B8B8", +"j c #A6A6B4", +"k c #131313", +"l c #1C1C1C", +"m c #EDEDFF", +"n c #E8E8FF", +"o c #E4E4FF", +"p c #D6AD74", +"q c #61562F", +"r c #141417", +"s c #AAAAB8", +"t c #9898B4", +"u c #171717", +"v c #464646", +"w c #333333", +"x c #E9E9FF", +"y c #E5E5FF", +"z c #4F4115", +"A c #1D1D1F", +"B c #4E4E4E", +"C c #202020", +"D c #767676", +"E c #E1E1FF", +"F c #42424B", +"G c #8E8E8E", +"H c #E2E2FF", +"I c #DADAF9", +"J c #838394", +"K c #0F0F10", +"L c #676767", +"M c #BABAD0", +"N c #27272B", +"O c #0C0C0C", +" .+@", +" . .#$%", +" .& .*=-.", +" .;>, .')!. ", +" .~{]^ ./(_. ", +"...:<[}|.123. ", +" 4.567890ab.. ", +" .cde9fgh.ijkl.", +" .mno9pq9rstuvw", +" .xy9z99ABCCD44", +"...8E99FwG4 44 ", +" 4.HIJKL44 ", +" .MNwG4 ", +" .OL44 ", +" .G4 ", +" 4 "}; diff --git a/eeschema/bitmaps/Edit_Part.xpm b/eeschema/bitmaps/Edit_Part.xpm new file mode 100644 index 0000000000..db39f06ea3 --- /dev/null +++ b/eeschema/bitmaps/Edit_Part.xpm @@ -0,0 +1,101 @@ +/* XPM */ +static char * Edit_Part_xpm[] = { +"16 16 82 1", +" c None", +". c #000000", +"+ c #F9E53A", +"@ c #F0B44C", +"# c #FAE93C", +"$ c #F5B343", +"% c #635632", +"& c #080808", +"* c #FAE73A", +"= c #F5B344", +"- c #6B5E33", +"; c #B0B0B0", +"> c #1C1A19", +", c #161616", +"' c #F8E239", +") c #F2B043", +"! c #615739", +"~ c #FFF3EC", +"{ c #F3DBCB", +"] c #6F5E53", +"^ c #0A0909", +"/ c #F7DD38", +"( c #F1AD41", +"_ c #615637", +": c #FFE8D8", +"< c #FFDBC2", +"[ c #FFCEAB", +"} c #CC9A77", +"| c #332419", +"1 c #F7DA37", +"2 c #EDB24C", +"3 c #655931", +"4 c #9B9B9B", +"5 c #FFDDC5", +"6 c #FFD0AF", +"7 c #FFC298", +"8 c #FFB582", +"9 c #010100", +"0 c #F7D636", +"a c #EEA73E", +"b c #64582F", +"c c #FFD1B2", +"d c #FFC49C", +"e c #FFB785", +"f c #F5D135", +"g c #ECA33D", +"h c #5C512F", +"i c #B8B8B8", +"j c #B49681", +"k c #131313", +"l c #1C1C1C", +"m c #FFC69F", +"n c #FFB988", +"o c #FFAC72", +"p c #D6AD73", +"q c #61562E", +"r c #010000", +"s c #100600", +"t c #B89A85", +"u c #B47950", +"v c #171717", +"w c #464646", +"x c #333333", +"y c #FFBB8C", +"z c #FFAE75", +"A c #4F4114", +"B c #17100B", +"C c #4E4E4E", +"D c #202020", +"E c #767676", +"F c #FFB079", +"G c #FFA262", +"H c #331906", +"I c #8E8E8E", +"J c #FFA465", +"K c #F3904B", +"L c #6F3C18", +"M c #0E0C0B", +"N c #676767", +"O c #B06A39", +"P c #1C0F07", +"Q c #0C0C0C", +" .+@", +" . .#$%", +" .& .*=-.", +" .;>, .')!. ", +" .~{]^ ./(_. ", +"...:<[}|.123. ", +" 4.567890ab.. ", +" .cde9fgh.ijkl.", +" .mno9pqrstuvwx", +" .yz9A9rBCDDE44", +"...FG9rHxI4 44 ", +" 4.JKLMN44 ", +" .OPxI4 ", +" .QN44 ", +" .I4 ", +" 4 "}; diff --git a/eeschema/bitmaps/Edit_Sheet.xpm b/eeschema/bitmaps/Edit_Sheet.xpm new file mode 100644 index 0000000000..8743e3a13f --- /dev/null +++ b/eeschema/bitmaps/Edit_Sheet.xpm @@ -0,0 +1,68 @@ +/* XPM */ +static char * edit_sheet_xpm[] = { +"16 16 49 1", +" c None", +". c #000000", +"+ c #F9E53A", +"@ c #F0B44C", +"# c #FAE93C", +"$ c #F5B343", +"% c #635632", +"& c #FFFFFF", +"* c #242424", +"= c #FAE73A", +"- c #F5B344", +"; c #6B5E33", +"> c #FDFDFD", +", c #EBEBEB", +"' c #787878", +") c #484848", +"! c #F8E239", +"~ c #F2B043", +"{ c #615739", +"] c #FCFCFC", +"^ c #424242", +"/ c #F7DD38", +"( c #F1AD41", +"_ c #615637", +": c #FAFAFA", +"< c #010101", +"[ c #F8DB38", +"} c #EDB24C", +"| c #655931", +"1 c #F9F9F9", +"2 c #F7D737", +"3 c #EFA83F", +"4 c #64582F", +"5 c #F8F8F8", +"6 c #F5D136", +"7 c #ECA33E", +"8 c #5C5230", +"9 c #F6F6F6", +"0 c #D6AD74", +"a c #61562F", +"b c #1A1A1A", +"c c #F5F5F5", +"d c #4F4115", +"e c #C6C6C6", +"f c #F3F3F3", +"g c #F2F2F2", +"h c #F0F0F0", +"i c #BEBEBE", +"j c #C3C3C3", +" ...", +" .+@.", +"........ .#$%.", +".&&&&&&*. .=-;. ", +".>,,,,,').!~{. ", +".],,,,,^./(_. ", +".:,,,,,<[}|. ", +".1,,,,<234. ", +".5,,,<678. ", +".9,,,<0a c #B8B8EF", +"? c #9797CF", +"@ c #14141D", +"A c #E8E8FA", +"B c #DCDCF7", +"C c #B7B7EF", +"D c #ABABEC", +"E c #8C8CCE", +"F c #12121D", +"G c #CFCFF4", +"H c #C3C3F1", +"I c #8B8BCD", +"J c #B8B8B8", +"K c #0C0C0C", +"L c #BEBEBE", +"M c #C3C3C3", +" ", +" !!!!!!!! ", +" !#####$%! ", +" !!$&&&&&'(!", +" !)*&&&&&+,!", +"!!!!!!-.0&&&&&12", +"!334567890&&&&12", +"!3:;6<=>?@0&&&12", +"!:AB<=CDEF0&&&12", +"!ABGHCDIF0&&&&12", +"!!!!!!IF0&&&&&12", +" !F!&&&&&&JK", +" !!!&&&&&&JK", +" !LMMMMMMM!", +" !!!!!!!!!!", +" "}; diff --git a/eeschema/bitmaps/GL_Change.xpm b/eeschema/bitmaps/GL_Change.xpm new file mode 100644 index 0000000000..07bebfefe6 --- /dev/null +++ b/eeschema/bitmaps/GL_Change.xpm @@ -0,0 +1,49 @@ +/* XPM */ +static char * gl_change_xpm[] = { +"16 16 30 1", +" c None", +". c #695F00", +"+ c #685E00", +"@ c #635A00", +"# c #4B4400", +"$ c #5E5500", +"% c #574E00", +"& c #625800", +"* c #000000", +"= c #00AA00", +"- c #007900", +"; c #008200", +"> c #00B300", +", c #002900", +"' c #005F00", +") c #004300", +"! c #00BD00", +"~ c #00BC00", +"{ c #009C00", +"] c #007300", +"^ c #005700", +"/ c #00B800", +"( c #003300", +"_ c #000F00", +": c #004800", +"< c #007D00", +"[ c #000100", +"} c #009600", +"| c #000800", +"1 c #001500", +" .. ", +" .+@# ", +" .$%& ", +" .... ", +".+ @# ", +".$ .& ", +" ", +" *** ", +" *=-* * ", +" *;>, *'* ", +" )!~{]!'* ", +" *^/!!!!( ", +" _:^!<[ ", +" *}| ", +" *1 ", +" "}; diff --git a/eeschema/bitmaps/GLabel2Label.xpm b/eeschema/bitmaps/GLabel2Label.xpm new file mode 100644 index 0000000000..ec12da76d9 --- /dev/null +++ b/eeschema/bitmaps/GLabel2Label.xpm @@ -0,0 +1,49 @@ +/* XPM */ +static char * glabel2label_xpm[] = { +"16 16 30 1", +" c None", +". c #695F00", +"+ c #685E00", +"@ c #635A00", +"# c #4B4400", +"$ c #5E5500", +"% c #574E00", +"& c #625800", +"* c #000000", +"= c #00AA00", +"- c #007900", +"; c #008200", +"> c #00B300", +", c #002900", +"' c #005F00", +") c #004300", +"! c #00BD00", +"~ c #00BC00", +"{ c #009C00", +"] c #007300", +"^ c #005700", +"/ c #00B800", +"( c #003300", +"_ c #000F00", +": c #004800", +"< c #007D00", +"[ c #000100", +"} c #009600", +"| c #000800", +"1 c #001500", +" .. ", +" .+@# ", +" .$%& ", +" .... ", +".+ @# ", +".$ .& ", +" ", +"*** ", +"*=-* * ", +"*;>, *'* ** ", +" )!~{]!'* **** ", +" *^/!!!!( **** ", +" _:^!<[ **** ", +" *}| ** ** ", +" *1 ** ** ", +" "}; diff --git a/eeschema/bitmaps/GLabel2Text.xpm b/eeschema/bitmaps/GLabel2Text.xpm new file mode 100644 index 0000000000..cd0c4a770c --- /dev/null +++ b/eeschema/bitmaps/GLabel2Text.xpm @@ -0,0 +1,61 @@ +/* XPM */ +static char * glabel2text_xpm[] = { +"16 16 42 1", +" c None", +". c #695F00", +"+ c #685E00", +"@ c #635A00", +"# c #4B4400", +"$ c #5E5500", +"% c #574E00", +"& c #625800", +"* c #000000", +"= c #00009B", +"- c #00AA00", +"; c #007900", +"> c #000070", +", c #000074", +"' c #000093", +") c #008200", +"! c #00B300", +"~ c #002900", +"{ c #005F00", +"] c #000092", +"^ c #00006F", +"/ c #004300", +"( c #00BD00", +"_ c #00BC00", +": c #009C00", +"< c #007300", +"[ c #005700", +"} c #00B800", +"| c #003300", +"1 c #000F00", +"2 c #004800", +"3 c #007D00", +"4 c #000100", +"5 c #000087", +"6 c #009600", +"7 c #000800", +"8 c #000091", +"9 c #000079", +"0 c #001500", +"a c #00009A", +"b c #000098", +"c c #000072", +" .. ", +" .+@# ", +" .$%& ", +" .... ", +".+ @# ", +".$ .& ", +" ", +"*** ======= ", +"*-;* * = >=, ' ", +"*)!~ *{* ]=^ ", +" /(_:<({* =^ ", +" *[}((((| =^ ", +" 12[(34 5=^ ", +" *67 8=9 ", +" *0 =abc ", +" "}; diff --git a/eeschema/bitmaps/Hidden_Pin.xpm b/eeschema/bitmaps/Hidden_Pin.xpm new file mode 100644 index 0000000000..0781950ec7 --- /dev/null +++ b/eeschema/bitmaps/Hidden_Pin.xpm @@ -0,0 +1,152 @@ +/* XPM */ +static char * hidden_pin_xpm[] = { +"16 16 133 2", +" c None", +". c #030303", +"+ c #050505", +"@ c #040404", +"# c #232324", +"$ c #AEAEB4", +"% c #B9B9C1", +"& c #0B0B0C", +"* c #020202", +"= c #BCBCC1", +"- c #7A7A7F", +"; c #79797F", +"> c #55555C", +", c #000000", +"' c #F5F5FD", +") c #F5F5FF", +"! c #F2F2FF", +"~ c #9B9BA7", +"{ c #09090A", +"] c #010101", +"^ c #F6F6FF", +"/ c #ACACBA", +"( c #080809", +"_ c #D72E2E", +": c #DF6669", +"< c #DD6469", +"[ c #D62F2F", +"} c #F4F4FF", +"| c #F1F1FF", +"1 c #EEEEFF", +"2 c #B6B6C7", +"3 c #070708", +"4 c #E89FA4", +"5 c #ECECFF", +"6 c #E1E1FF", +"7 c #D68DA4", +"8 c #C64C4C", +"9 c #010102", +"0 c #212124", +"a c #EFEFFF", +"b c #EBEBFF", +"c c #BEBED2", +"d c #060607", +"e c #E9D7E8", +"f c #E2E2FF", +"g c #D7D7FF", +"h c #CDBBE8", +"i c #CA2B2B", +"j c #110506", +"k c #B45D67", +"l c #D97887", +"m c #D77E91", +"n c #D5849A", +"o c #C58199", +"p c #0C0506", +"q c #D12C2C", +"r c #C94545", +"s c #DD94A4", +"t c #CDCDFF", +"u c #CB82A4", +"v c #BE5A5A", +"w c #494949", +"x c #434347", +"y c #B6B6C4", +"z c #B7B7C8", +"A c #B8B8CD", +"B c #B9B9D1", +"C c #B9B9D6", +"D c #323239", +"E c #666666", +"F c #9B9B9B", +"G c #CF3B3B", +"H c #D45B69", +"I c #D15869", +"J c #987F7F", +"K c #C8C8D3", +"L c #A3A3B5", +"M c #E3E3FF", +"N c #DFDFFF", +"O c #7E7E97", +"P c #0A0A0C", +"Q c #9B9999", +"R c #AC7A7A", +"S c #9B9A9A", +"T c #363636", +"U c #35353A", +"V c #D0D0E4", +"W c #62626E", +"X c #E0E0FF", +"Y c #DCDCFF", +"Z c #CFCFF7", +"` c #070709", +" . c #040405", +".. c #B1B1BD", +"+. c #EDEDFF", +"@. c #D3D3E7", +"#. c #494951", +"$. c #CECEEA", +"%. c #DDDDFF", +"&. c #D8D8FF", +"*. c #D2D2FF", +"=. c #30303D", +"-. c #0D0D0F", +";. c #DFDFF3", +">. c #484850", +",. c #CCCCE7", +"'. c #DEDEFF", +"). c #D9D9FF", +"!. c #D5D5FF", +"~. c #CFCFFF", +"{. c #646482", +"]. c #2A2A2F", +"^. c #9E9EAE", +"/. c #8C8C9D", +"(. c #D9D9F8", +"_. c #DBDBFF", +":. c #D6D6FF", +"<. c #D1D1FF", +"[. c #CBCBFF", +"}. c #8484AC", +"|. c #0A0A0D", +"1. c #26262B", +"2. c #7D7D8B", +"3. c #383840", +"4. c #030304", +"5. c #76768E", +"6. c #B3B3DA", +"7. c #8888AC", +"8. c #444459", +"9. c #060608", +"0. c #050506", +"a. c #09090B", +"b. c #0C0C0F", +" . . . + ", +" @ # $ % & ", +" * = - ; > + ", +" , ' ) ! ~ { ", +" ] ^ , , / ( ", +" _ : < [ . } | 1 2 3 ", +"_ 4 5 6 7 8 9 0 ! a b c d ", +"[ e f g h _ i j k l m n o p q ", +"r s g t u v w x y z A B C D E F ", +" G H I G J @ K 1 b L M N O P ", +" Q R R S T U a 5 V W X Y Z ` ", +" ...+.@.#.$.%.&.*.=., ", +" -.1 ;.>.,.'.).!.~.{.` ", +" , ].5 ^./.(._.:.<.[.}.|.", +" . 1.2.3.4.d 5.6.7.8.9.9.", +" , 3 P 0. a.0.b.d "}; diff --git a/eeschema/bitmaps/Hierarchy_Nav.xpm b/eeschema/bitmaps/Hierarchy_Nav.xpm new file mode 100644 index 0000000000..d7bccf22b0 --- /dev/null +++ b/eeschema/bitmaps/Hierarchy_Nav.xpm @@ -0,0 +1,26 @@ +/* XPM */ +static char * hierarchy_nav_xpm[] = { +"16 16 7 1", +" c None", +". c #000000", +"+ c #D783D7", +"@ c #9B9B9B", +"# c #373737", +"$ c #83D7D7", +"% c #83D783", +"........ ", +".++++++.@ ", +"........@ ", +" #@@@@@@@ ", +" # ........ ", +" ##.$$$$$$.@ ", +" ........@ ", +" #@@@@@@@ ", +" # ........ ", +" ###.%%%%%%.@", +" # ........@", +" # @@@@@@@@", +" # ........ ", +" ###.%%%%%%.@", +" ........@", +" @@@@@@@@"}; diff --git a/eeschema/bitmaps/Hierarchy_cursor.xpm b/eeschema/bitmaps/Hierarchy_cursor.xpm new file mode 100644 index 0000000000..b353ef68fd --- /dev/null +++ b/eeschema/bitmaps/Hierarchy_cursor.xpm @@ -0,0 +1,80 @@ +/* XPM */ +static char * hierarchy_cursor_xpm[] = { +"16 16 61 1", +" c None", +". c #000000", +"+ c #D783D7", +"@ c #9B9B9B", +"# c #373737", +"$ c #4B7B7B", +"% c #71BABA", +"& c #83D7D7", +"* c #343434", +"= c #141414", +"- c #D6D6D6", +"; c #989898", +"> c #2E2E2F", +", c #838383", +"' c #171717", +") c #C8C8C8", +"! c #FFFFFF", +"~ c #D2D2E1", +"{ c #3B3B45", +"] c #1A1A1A", +"^ c #B8B8B8", +"/ c #F7F7FF", +"( c #E6E6FF", +"_ c #D6D6FF", +": c #767699", +"< c #1F3121", +"[ c #6DB46D", +"} c #83D783", +"| c #1E1E1E", +"1 c #A9A9A9", +"2 c #F0F0FF", +"3 c #DFDFFF", +"4 c #72728E", +"5 c #1C1C26", +"6 c #222222", +"7 c #959599", +"8 c #ADADBF", +"9 c #7A7A91", +"0 c #6E6E8D", +"a c #363636", +"b c #606060", +"c c #878787", +"d c #262626", +"e c #36363A", +"f c #050506", +"g c #101014", +"h c #B7B7F5", +"i c #2E2E44", +"j c #2B2B2B", +"k c #212121", +"l c #6C6C96", +"m c #9595E5", +"n c #212F28", +"o c #7FD17F", +"p c #181824", +"q c #8282D0", +"r c #1B1B2D", +"s c #383838", +"t c #161616", +"u c #4B4B4B", +"v c #898989", +"........ ", +".++++++.@ ", +"........@ ", +" #@@@@@@@ ", +" # ........ ", +" ##.$%&&&&.@ ", +" ..*.....@ ", +" =-;>,@@@ ", +" ')!~{...... ", +" ]^/(_:<[}}.@", +" |12345.....@", +" 67890abc@@@@", +" defghi..... ", +" j=k.lmno}}.@", +" .pqr....@", +" stuv@@@@"}; diff --git a/eeschema/bitmaps/Import_GLabel.xpm b/eeschema/bitmaps/Import_GLabel.xpm new file mode 100644 index 0000000000..b0ee8ff2db --- /dev/null +++ b/eeschema/bitmaps/Import_GLabel.xpm @@ -0,0 +1,111 @@ +/* XPM */ +static char * import_glabel_xpm[] = { +"16 16 92 2", +" c None", +". c #000000", +"+ c #020202", +"@ c #00AE00", +"# c #007000", +"$ c #7C7C7C", +"% c #3C3C3C", +"& c #E5E5E5", +"* c #EBEBEB", +"= c #98914E", +"- c #6F6500", +"; c #676767", +"> c #303030", +", c #008800", +"' c #00AD00", +") c #002600", +"! c #6A6F6A", +"~ c #005800", +"{ c #505050", +"] c #E4E4E0", +"^ c #746A09", +"/ c #8D853A", +"( c #E5E5E1", +"_ c #3F3F3F", +": c #606060", +"< c #004900", +"[ c #00BD00", +"} c #00BA00", +"| c #009A00", +"1 c #007400", +"2 c #535143", +"3 c #C9C6AE", +"4 c #C1BE9C", +"5 c #C3C3C3", +"6 c #005C00", +"7 c #00B800", +"8 c #002D00", +"9 c #544C00", +"0 c #001300", +"a c #004500", +"b c #015B01", +"c c #007800", +"d c #302C03", +"e c #BCB892", +"f c #727872", +"g c #009200", +"h c #3B3F2F", +"i c #6E6400", +"j c #DBDACD", +"k c #747674", +"l c #314131", +"m c #A49F71", +"n c #695F00", +"o c #B3AF86", +"p c #9E9E9E", +"q c #DADADA", +"r c #AAA575", +"s c #7D7880", +"t c #9B9BFF", +"u c #A5A5FF", +"v c #A4A3D8", +"w c #6E6510", +"x c #C3C0A4", +"y c #FDFDFD", +"z c #847F80", +"A c #A8A8FF", +"B c #B2B2FF", +"C c #BDBDFF", +"D c #AAA7B1", +"E c #6F660C", +"F c #B2B09E", +"G c #8B8680", +"H c #B6B6FF", +"I c #C0C0FF", +"J c #CACAFF", +"K c #D4D4FF", +"L c #8C854C", +"M c #7C7429", +"N c #918C80", +"O c #C3C3FF", +"P c #CECEFF", +"Q c #D8D8FF", +"R c #BDBAB1", +"S c #70670C", +"T c #989380", +"U c #D1D1FF", +"V c #DBDBFF", +"W c #D2D1D8", +"X c #716810", +"Y c #BEBEBE", +"Z c #969161", +"` c #9C986F", +". . . . . . . . . . . . + ", +". @ # . $ % & * = - = * ; > ", +". , ' ) . ! ~ { ] ^ / ^ ( _ : . ", +" < [ } | 1 [ ~ 2 - 3 - 4 * 5 . ", +" 6 7 [ [ [ [ 8 9 - - = * 5 . ", +" 0 a b [ c d e * e ^ ( 5 . ", +" . f g h i j * j - 4 5 . ", +" . k l m n n n n o * 5 . ", +" . p q r s t u v w x 5 . ", +" . y * r z A B C D E F . ", +" . y * r G H I J K L M . ", +" . y * r N O P Q R S F . ", +" . y * r T U V W X x 5 . ", +" . Y 5 Z n n n n ` 5 5 . ", +" . . . . . . . . . . . . ", +" "}; diff --git a/eeschema/bitmaps/Label2GLabel.xpm b/eeschema/bitmaps/Label2GLabel.xpm new file mode 100644 index 0000000000..bba0f21303 --- /dev/null +++ b/eeschema/bitmaps/Label2GLabel.xpm @@ -0,0 +1,53 @@ +/* XPM */ +static char * label2glabel_xpm[] = { +"16 16 34 1", +" c None", +". c #000000", +"+ c #00AA00", +"@ c #007900", +"# c #008200", +"$ c #00B300", +"% c #002900", +"& c #005F00", +"* c #695F00", +"= c #004300", +"- c #00BD00", +"; c #00BC00", +"> c #009C00", +", c #007300", +"' c #6A6000", +") c #675D00", +"! c #635900", +"~ c #4A4300", +"{ c #005700", +"] c #00B800", +"^ c #003300", +"/ c #5E5500", +"( c #574F00", +"_ c #625800", +": c #000F00", +"< c #004800", +"[ c #007D00", +"} c #000100", +"| c #009600", +"1 c #000800", +"2 c #4F4700", +"3 c #001500", +"4 c #685D00", +"5 c #696000", +" .. ", +" .... ", +" .... ", +" .... ", +".. .. ", +".. .. ", +" ", +"... ", +".+@. . ", +".#$% .&. ** ", +" =-;>,-&. ')!~ ", +" .{]----^ */(_ ", +" :<{-[} **** ", +" .|1 2) !~ ", +" .3 4/ 5_ ", +" "}; diff --git a/eeschema/bitmaps/Label2Text.xpm b/eeschema/bitmaps/Label2Text.xpm new file mode 100644 index 0000000000..0a358fdf96 --- /dev/null +++ b/eeschema/bitmaps/Label2Text.xpm @@ -0,0 +1,54 @@ +/* XPM */ +static char * label2text_xpm[] = { +"16 16 35 1", +" c None", +". c #000000", +"+ c #00009B", +"@ c #00AA00", +"# c #007900", +"$ c #000070", +"% c #000074", +"& c #000093", +"* c #008200", +"= c #00B300", +"- c #002900", +"; c #005F00", +"> c #000092", +", c #00006F", +"' c #004300", +") c #00BD00", +"! c #00BC00", +"~ c #009C00", +"{ c #007300", +"] c #005700", +"^ c #00B800", +"/ c #003300", +"( c #000F00", +"_ c #004800", +": c #007D00", +"< c #000100", +"[ c #000087", +"} c #009600", +"| c #000800", +"1 c #000091", +"2 c #000079", +"3 c #001500", +"4 c #00009A", +"5 c #000098", +"6 c #000072", +" .. ", +" .... ", +" .... ", +" .... ", +".. .. ", +".. .. ", +" ", +"... +++++++ ", +".@#. . + $+% & ", +".*=- .;. >+, ", +" ')!~{);. +, ", +" .]^))))/ +, ", +" (_]):< [+, ", +" .}| 1+2 ", +" .3 +456 ", +" "}; diff --git a/eeschema/bitmaps/Leave_Sheet.xpm b/eeschema/bitmaps/Leave_Sheet.xpm new file mode 100644 index 0000000000..4550ab2fde --- /dev/null +++ b/eeschema/bitmaps/Leave_Sheet.xpm @@ -0,0 +1,77 @@ +/* XPM */ +static char * leave_sheet_xpm[] = { +"16 16 58 1", +" c None", +". c #000000", +"+ c #FFFFFF", +"@ c #242424", +"# c #FDFDFD", +"$ c #EBEBEB", +"% c #787878", +"& c #484848", +"* c #1C1C1C", +"= c #FBFBFB", +"- c #444444", +"; c #616161", +"> c #DADADA", +", c #060606", +"' c #C6C6C6", +") c #1B1B1B", +"! c #F7F7FD", +"~ c #E5E5F3", +"{ c #D9D9F0", +"] c #CCCCEE", +"^ c #C1C1EB", +"/ c #B5B5E8", +"( c #F6F6FD", +"_ c #EAEAFA", +": c #DEDEF7", +"< c #D2D2F5", +"[ c #C5C5F2", +"} c #B9B9EF", +"| c #ADADED", +"1 c #232323", +"2 c #DBDBE1", +"3 c #E9E9FA", +"4 c #DDDDF7", +"5 c #D1D1F4", +"6 c #B8B8EF", +"7 c #ACACEC", +"8 c #A0A0EA", +"9 c #212123", +"0 c #C4C4DC", +"a c #D0D0F4", +"b c #C4C4F2", +"c c #B7B7EF", +"d c #ABABEC", +"e c #9F9FEA", +"f c #9393E7", +"g c #1D1D22", +"h c #AEAED7", +"i c #060607", +"j c #050507", +"k c #040407", +"l c #1A1A22", +"m c #E8E8E8", +"n c #E6E6E6", +"o c #E4E4E4", +"p c #B8B8B8", +"q c #0C0C0C", +"r c #BEBEBE", +"s c #C3C3C3", +" ", +" ........ ", +" .++++++@. ", +" ...#$$$$$%&.", +" *..=$$$$$-;.", +" *>..,,,,$$$')", +" *>!~{]^/.$$$')", +" *>(_:<[}|.$$$')", +".12345[678.$$$')", +" .90abcdef.$$$')", +" .ghijjjk.$$$')", +" .l...mno$$$pq", +" ....$$$$$$pq", +" .rsssssss.", +" ..........", +" "}; diff --git a/eeschema/bitmaps/Lib_next.xpm b/eeschema/bitmaps/Lib_next.xpm new file mode 100644 index 0000000000..bcea7ce80b --- /dev/null +++ b/eeschema/bitmaps/Lib_next.xpm @@ -0,0 +1,82 @@ +/* XPM */ +static char * lib_next_xpm[] = { +"16 16 63 1", +" c None", +". c #000000", +"+ c #C5C9CD", +"@ c #FBFBFB", +"# c #E9E9E9", +"$ c #D4D4D4", +"% c #A0A0A0", +"& c #797979", +"* c #393939", +"= c #C1C1C1", +"- c #D6D6D6", +"; c #EBEBEB", +"> c #E1E1E1", +", c #C9C9C9", +"' c #6C7C8C", +") c #C2C7CB", +"! c #C3C3C3", +"~ c #B0B0B0", +"{ c #A8A8A8", +"] c #FFFFFF", +"^ c #F9F9F9", +"/ c #CACACA", +"( c #627080", +"_ c #627180", +": c #637181", +"< c #C2C7CC", +"[ c #A7A7A7", +"} c #878787", +"| c #5F5F5F", +"1 c #363636", +"2 c #647382", +"3 c #C3C7CC", +"4 c #657482", +"5 c #C3C7CD", +"6 c #667584", +"7 c #C4C8CD", +"8 c #687584", +"9 c #D3D6D9", +"0 c #CDCFD0", +"a c #BEC0C1", +"b c #B3B5B6", +"c c #A8A9AA", +"d c #DDDEDF", +"e c #D6D7D8", +"f c #CDCECF", +"g c #C5C7C8", +"h c #B6B7B8", +"i c #657382", +"j c #637488", +"k c #556A80", +"l c #5C6F84", +"m c #5D7084", +"n c #5E7185", +"o c #697888", +"p c #868A8E", +"q c #6B747E", +"r c #576674", +"s c #586776", +"t c #596776", +"u c #5A6776", +"v c #445464", +"w c #616467", +"x c #686D72", +" ", +"....... ....... ", +".+@#$%&*=-;>,'. ", +".)@#$!~{]^;>/(. ", +".)@#$!~{].;>,_. ", +".)@#$!~{]..>,:. ", +".<@#[}|1....,2. ", +".3@#$!~{]..>,4. ", +".5@#$!~{].;>,6. ", +".7@#$!~{]^;>,8. ", +".790abc[defghi. ", +".jklmnopqrstuv. ", +"......wxw...... ", +" ... ", +" ", +" "}; diff --git a/eeschema/bitmaps/Lib_previous.xpm b/eeschema/bitmaps/Lib_previous.xpm new file mode 100644 index 0000000000..9248009862 --- /dev/null +++ b/eeschema/bitmaps/Lib_previous.xpm @@ -0,0 +1,83 @@ +/* XPM */ +static char * lib_previous_xpm[] = { +"16 16 64 1", +" c None", +". c #000000", +"+ c #C5C9CD", +"@ c #FBFBFB", +"# c #E9E9E9", +"$ c #D4D4D4", +"% c #A0A0A0", +"& c #797979", +"* c #393939", +"= c #C1C1C1", +"- c #D6D6D6", +"; c #EBEBEB", +"> c #E1E1E1", +", c #C9C9C9", +"' c #6C7C8C", +") c #C2C7CB", +"! c #C3C3C3", +"~ c #B0B0B0", +"{ c #A8A8A8", +"] c #FFFFFF", +"^ c #F9F9F9", +"/ c #CACACA", +"( c #627080", +"_ c #627180", +": c #637181", +"< c #C2C7CC", +"[ c #363636", +"} c #8B8B8B", +"| c #ACACAC", +"1 c #BABABA", +"2 c #647382", +"3 c #C3C7CC", +"4 c #657482", +"5 c #C3C7CD", +"6 c #667584", +"7 c #C4C8CD", +"8 c #687584", +"9 c #D3D6D9", +"0 c #CDCFD0", +"a c #BEC0C1", +"b c #B3B5B6", +"c c #A8A9AA", +"d c #A7A7A7", +"e c #DDDEDF", +"f c #D6D7D8", +"g c #CDCECF", +"h c #C5C7C8", +"i c #B6B7B8", +"j c #657382", +"k c #637488", +"l c #556A80", +"m c #5C6F84", +"n c #5D7084", +"o c #5E7185", +"p c #697888", +"q c #868A8E", +"r c #6B747E", +"s c #576674", +"t c #586776", +"u c #596776", +"v c #5A6776", +"w c #445464", +"x c #616467", +"y c #686D72", +" ", +"....... ....... ", +".+@#$%&*=-;>,'. ", +".)@#$!~{]^;>/(. ", +".)@#$.~{]^;>,_. ", +".)@#..~{]^;>,:. ", +".<@....[}|1>,2. ", +".3@#..~{]^;>,4. ", +".5@#$.~{]^;>,6. ", +".7@#$!~{]^;>,8. ", +".790abcdefghij. ", +".klmnopqrstuvw. ", +"......xyx...... ", +" ... ", +" ", +" "}; diff --git a/eeschema/bitmaps/Lines90.xpm b/eeschema/bitmaps/Lines90.xpm new file mode 100644 index 0000000000..263cad559c --- /dev/null +++ b/eeschema/bitmaps/Lines90.xpm @@ -0,0 +1,43 @@ +/* XPM */ +static char * lines90_xpm[] = { +"16 16 24 1", +" c None", +". c #000000", +"+ c #9B9B9B", +"@ c #0000FF", +"# c #FEFEFF", +"$ c #F7F7FF", +"% c #EDECFF", +"& c #E3E2FF", +"* c #D9D8FF", +"= c #6969FF", +"- c #EDEDFF", +"; c #E3E3FF", +"> c #CFCEFF", +", c #EEEDFF", +"' c #D9D9FF", +") c #CFCFFF", +"! c #C5C4FF", +"~ c #E4E3FF", +"{ c #DAD9FF", +"] c #D0CFFF", +"^ c #C6C5FF", +"/ c #BCBAFF", +"( c #BCBBFF", +"_ c #B2B1FF", +" ", +" . ", +" .+ ", +" .+ ", +" .+ ", +" .+ ", +" .+ ", +" .@@@@@@ ", +" .#$%&*@= ", +" .$-;*>@= ", +" .,;')!@= ", +" .~{]^/@= ", +" .{]^(_@= ", +" .............. ", +" ++++++++++++++", +" "}; diff --git a/eeschema/bitmaps/Mirror_H.xpm b/eeschema/bitmaps/Mirror_H.xpm new file mode 100644 index 0000000000..7f1ab225f1 --- /dev/null +++ b/eeschema/bitmaps/Mirror_H.xpm @@ -0,0 +1,48 @@ +/* XPM */ +static char * mirror_H_xpm[] = { +"16 16 29 1", +" c None", +". c #000000", +"+ c #9B9B9B", +"@ c #858585", +"# c #4C4C4C", +"$ c #1A1A1A", +"% c #939393", +"& c #696969", +"* c #606060", +"= c #D2D2D2", +"- c #202020", +"; c #FFFFFF", +"> c #3C3C3C", +", c #737373", +"' c #A0A0A5", +") c #373737", +"! c #EAEAF9", +"~ c #141417", +"{ c #F9F9FF", +"] c #E9E8FF", +"^ c #666578", +"/ c #F2F2FF", +"( c #E2E1FF", +"_ c #B7B6DF", +": c #0F0E0F", +"< c #EBEAFF", +"[ c #DAD9FF", +"} c #CAC9FF", +"| c #36364B", +" . ", +" .+ ", +" .+. ", +" .+.@ ", +" +.# ", +" .$% ", +" . .&* ", +" .+.=- ", +" .+.;>, ", +" .+.;') ", +" +.;!~@ ", +" .{]^# ", +" . ./(_:% ", +" .+.<[}|* ", +" .+.....- ", +" .+ ++++++"}; diff --git a/eeschema/bitmaps/Mirror_V.xpm b/eeschema/bitmaps/Mirror_V.xpm new file mode 100644 index 0000000000..4efe6fbb5d --- /dev/null +++ b/eeschema/bitmaps/Mirror_V.xpm @@ -0,0 +1,49 @@ +/* XPM */ +static char * mirror_V_xpm[] = { +"16 16 30 1", +" c None", +". c #000000", +"+ c #9B9B9B", +"@ c #E3E3FF", +"# c #EBEAFF", +"$ c #F2F2FF", +"% c #F9F9FF", +"& c #FFFFFF", +"* c #D2D2D2", +"= c #696969", +"- c #1A1A1A", +"; c #4D4D4D", +"> c #8C8C8C", +", c #D3D2FF", +"' c #DAD9FF", +") c #E2E1FF", +"! c #E4E3F9", +"~ c #9B9BA5", +"{ c #3A3A3C", +"] c #202020", +"^ c #636363", +"/ c #979797", +"( c #C3C1FF", +"_ c #B1B0DF", +": c #626278", +"< c #141417", +"[ c #373737", +"} c #7A7A7A", +"| c #34344B", +"1 c #0E0E0F", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +".... .... ....", +" ++++ ++++ +++", +" ............. ", +" .@#$%&&*=-;>++ ", +" .,')!~{]^/++ ", +" .(_:<[}++ ", +" .|1;>++ ", +" .^/++ ", +" + "}; diff --git a/eeschema/bitmaps/Move_GLabel.xpm b/eeschema/bitmaps/Move_GLabel.xpm new file mode 100644 index 0000000000..3ef951ea1a --- /dev/null +++ b/eeschema/bitmaps/Move_GLabel.xpm @@ -0,0 +1,85 @@ +/* XPM */ +static char * move_glabel_xpm[] = { +"16 16 66 1", +" c None", +". c #695F00", +"+ c #685E00", +"@ c #635A00", +"# c #4B4400", +"$ c #9191FF", +"% c #9B9BFF", +"& c #A5A5FF", +"* c #857F66", +"= c #5F5500", +"- c #5E5500", +"; c #574E00", +"> c #625800", +", c #9E9EFF", +"' c #A8A8FF", +") c #B2B2FF", +"! c #BBBBF9", +"~ c #7D7539", +"{ c #595100", +"] c #8B8BCF", +"^ c #242432", +"/ c #9292C2", +"( c #CACAFF", +"_ c #BFBDCC", +": c #494200", +"< c #353542", +"[ c #DCDCEF", +"} c #343441", +"| c #86869D", +"1 c #847C39", +"2 c #4E4700", +"3 c #000000", +"4 c #010000", +"5 c #84849B", +"6 c #FFFFFF", +"7 c #010100", +"8 c #282400", +"9 c #544C00", +"0 c #413A00", +"a c #090800", +"b c #F1F1FF", +"c c #31313D", +"d c #E7E5FF", +"e c #646489", +"f c #232332", +"g c #FBFBFF", +"h c #EAEAFF", +"i c #E2E1FF", +"j c #DBDBFF", +"k c #D5D3FF", +"l c #CDCDFF", +"m c #C8C6FF", +"n c #C1C1FF", +"o c #9F9DDB", +"p c #30303B", +"q c #7A7A96", +"r c #D2D0FF", +"s c #5A5981", +"t c #20202F", +"u c #C8C8FF", +"v c #C0BFFF", +"w c #5C5C82", +"x c #B8B8FF", +"y c #56557D", +"z c #9493D6", +"A c #1D1D2C", +" .. ..... ", +" .+@# .$%&*= ", +" .-;> .,')!~{ ", +" .... .]^/(_. ", +".+ @# :<[}|12 ", +".- .>3456578 ", +" 3 93630a3 ", +" 3 3b33 3 ", +" c5333d333ef ", +" 3[gbhijklmno3", +" pq333r333st ", +" 3 3u3 33 ", +" 3 3v3 3 ", +" 3wxy33 ", +" tzA3 ", +" 3 "}; diff --git a/eeschema/bitmaps/Move_Pinsheet.xpm b/eeschema/bitmaps/Move_Pinsheet.xpm new file mode 100644 index 0000000000..d3ab4bfa54 --- /dev/null +++ b/eeschema/bitmaps/Move_Pinsheet.xpm @@ -0,0 +1,100 @@ +/* XPM */ +static char * move_pinsheet_xpm[] = { +"16 16 81 1", +" c None", +". c #6F6500", +"+ c #FEFEFF", +"@ c #FCFCFF", +"# c #F1F1FF", +"$ c #D3D2D8", +"% c #746B0E", +"& c #8D8A6C", +"* c #6E6400", +"= c #695F00", +"- c #4F4800", +"; c #F8F8FF", +"> c #EDEDFF", +", c #E2E2FF", +"' c #D6D6FF", +") c #AEABB1", +"! c #716707", +"~ c #92907D", +"{ c #635A00", +"] c #5C5300", +"^ c #675E00", +"/ c #F3F3FF", +"( c #E8E8FF", +"_ c #DDDDFF", +": c #D2D2FF", +"< c #C7C7FF", +"[ c #BCBCFF", +"} c #827B4C", +"| c #615A19", +"1 c #1C1B18", +"2 c #544D00", +"3 c #E4E4FF", +"4 c #D9D9FF", +"5 c #CECEFF", +"6 c #C2C2FF", +"7 c #B7B7FF", +"8 c #9895B1", +"9 c #4F4804", +"0 c #34343F", +"a c #DCDCEF", +"b c #32323B", +"c c #000000", +"d c #D4D4FF", +"e c #C9C9FF", +"f c #BEBEFF", +"g c #B3B3FF", +"h c #9E9DD8", +"i c #403B08", +"j c #010101", +"k c #84849B", +"l c #FFFFFF", +"m c #3F3900", +"n c #7C7750", +"o c #7C7C7C", +"p c #9B9B9B", +"q c #6C6C6C", +"r c #31313D", +"s c #E7E5FF", +"t c #646489", +"u c #232332", +"v c #FBFBFF", +"w c #EAEAFF", +"x c #E2E1FF", +"y c #DBDBFF", +"z c #D5D3FF", +"A c #CDCDFF", +"B c #C8C6FF", +"C c #C1C1FF", +"D c #9F9DDB", +"E c #30303B", +"F c #7A7A96", +"G c #D2D0FF", +"H c #5A5981", +"I c #20202F", +"J c #C8C8FF", +"K c #C0BFFF", +"L c #5C5C82", +"M c #B8B8FF", +"N c #56557D", +"O c #9493D6", +"P c #1D1D2C", +"...... .. ", +".++@#$%& .*=- ", +".+;>,')!~ .{]^ ", +"./(_:<[}|12... ", +".34567890abc =- ", +".defghijklkcc.^ ", +".....mnoclc ", +" pppqjopc#c c ", +" rkcccsccctu ", +" cav#wxyzABCDc", +" EFcccGcccHI ", +" c cJc cc ", +" c cKc c ", +" cLMNcc ", +" IOPc ", +" c "}; diff --git a/eeschema/bitmaps/Move_Sheet.xpm b/eeschema/bitmaps/Move_Sheet.xpm new file mode 100644 index 0000000000..3d709e4c98 --- /dev/null +++ b/eeschema/bitmaps/Move_Sheet.xpm @@ -0,0 +1,87 @@ +/* XPM */ +static char * move_sheet_xpm[] = { +"16 16 68 1", +" c None", +". c #000000", +"+ c #FFFFFF", +"@ c #B3B3B3", +"# c #393944", +"$ c #DCDCEF", +"% c #363642", +"& c #8A8A8A", +"* c #232323", +"= c #909090", +"- c #020202", +"; c #84849B", +"> c #010101", +", c #313131", +"' c #464646", +") c #FCFCFC", +"! c #E0E0E0", +"~ c #8E8E8E", +"{ c #282828", +"] c #424242", +"^ c #CFCFCF", +"/ c #EBEBEB", +"( c #F1F1FF", +"_ c #BCBCBC", +": c #BDBDBD", +"< c #31313D", +"[ c #E7E5FF", +"} c #606086", +"| c #222232", +"1 c #FBFBFF", +"2 c #EAEAFF", +"3 c #E2E1FF", +"4 c #DBDBFF", +"5 c #D5D3FF", +"6 c #CDCDFF", +"7 c #C8C6FF", +"8 c #C1C1FF", +"9 c #BDBBFF", +"0 c #9999D9", +"a c #30303B", +"b c #7A7A96", +"c c #D2D0FF", +"d c #56567F", +"e c #1E1E2D", +"f c #949494", +"g c #C8C8FF", +"h c #5B5B5B", +"i c #727272", +"j c #787878", +"k c #C0BFFF", +"l c #C6C6C6", +"m c #0E0E0E", +"n c #C9C9C9", +"o c #B8B8FF", +"p c #1A1A1A", +"q c #898989", +"r c #57577F", +"s c #B2B0FF", +"t c #51517A", +"u c #6B6B6B", +"v c #BEBEBE", +"w c #828282", +"x c #222231", +"y c #8D8CD3", +"z c #1E1E2E", +"A c #525252", +"B c #767676", +"C c #858585", +" ", +" ........ ", +" .+@#$%&*. ", +" .=-;+;>,'. ", +" .)!.+.~{]. ", +" .^/.(.~_:. ", +" <;...[....}| ", +" .$1(234567890. ", +" ab...c....de. ", +" .f~.g.hij.. ", +" .f/.k.~_lm ", +" .n/.o.~_lp ", +" .q-rst>ulp ", +" .vwxyzABC. ", +" .......... ", +" "}; diff --git a/eeschema/bitmaps/Normal.xpm b/eeschema/bitmaps/Normal.xpm new file mode 100644 index 0000000000..0b0593e93b --- /dev/null +++ b/eeschema/bitmaps/Normal.xpm @@ -0,0 +1,126 @@ +/* XPM */ +static char * normal_xpm[] = { +"16 16 107 2", +" c None", +". c #000000", +"+ c #010101", +"@ c #656565", +"# c #B2B2B2", +"$ c #DAB4B8", +"% c #D5BAC3", +"& c #A1A1AD", +"* c #585860", +"= c #1A1A1A", +"- c #BEBEBE", +"; c #FCFCFE", +"> c #F5F5FB", +", c #DC7377", +"' c #D2727A", +") c #CECEE2", +"! c #D5D5F1", +"~ c #9A9AB2", +"{ c #141418", +"] c #F4F4FB", +"^ c #ECECF8", +"/ c #D02325", +"( c #C72224", +"_ c #AAAAC0", +": c #CDCDEE", +"< c #C5C5EB", +"[ c #8E8EAE", +"} c #FBFBFD", +"| c #F3F3FB", +"1 c #DFBCCA", +"2 c #CD0100", +"3 c #927386", +"4 c #BDBDE8", +"5 c #B5B5E6", +"6 c #45455A", +"7 c #B0B0B2", +"8 c #EBEBF8", +"9 c #E3E3F5", +"0 c #D46D78", +"a c #A03C48", +"b c #ADADD6", +"c c #B4B4E5", +"d c #ADADE3", +"e c #74749D", +"f c #6C6C70", +"g c #75757B", +"h c #DBDBF2", +"i c #CD2327", +"j c #BD1417", +"k c #8E8EB5", +"l c #ACACE3", +"m c #51516F", +"n c #464663", +"o c #69696F", +"p c #70707A", +"q c #DADAF2", +"r c #D3D3F0", +"s c #FBFBFC", +"t c #FBFBFB", +"u c #E3E3E9", +"v c #737397", +"w c #A4A4E0", +"x c #4D4D6E", +"y c #424262", +"z c #9F9FAC", +"A c #D2D2EF", +"B c #CACAED", +"C c #E1E1F4", +"D c #FFFFFF", +"E c #B3B3C4", +"F c #6C6C94", +"G c #9B9BDD", +"H c #9494DA", +"I c #626298", +"J c #565660", +"K c #C2C2EA", +"L c #C6C6EB", +"M c #7B7B99", +"N c #7B7BAF", +"O c #9393DA", +"P c #8B8BD8", +"Q c #343454", +"R c #9797B1", +"S c #C1C1EA", +"T c #B9B9E7", +"U c #B2B2E5", +"V c #F1F1F8", +"W c #E2E2E9", +"X c #5D5D86", +"Y c #8888CA", +"Z c #8B8BD7", +"` c #6262A0", +" . c #000001", +".. c #8B8BAD", +"+. c #B1B1E4", +"@. c #A9A9E2", +"#. c #B0B0C7", +"$. c #616192", +"%. c #8A8AD7", +"&. c #6161A0", +"*. c #0D0D15", +"=. c #43435A", +"-. c #71719D", +";. c #A0A0D0", +">. c #7D7DAC", +",. c #4D4D79", +"'. c #333354", +" ", +" . . . . ", +" + @ # $ % & * + ", +" = - ; > , ' ) ! ~ { ", +" + - ; ] ^ / ( _ : < [ + ", +" @ } | ^ 1 2 2 3 < 4 5 6 . ", +" . 7 | 8 9 0 2 2 a b c d e . ", +" . f g 9 h i 2 2 j k l m n . ", +" . o p q r > s t u v w x y . ", +" . z q A B C D D E F G H I . ", +" J A B K L D D M N O P Q . ", +" + R S T U V W X Y Z ` . ", +" { ..+.@.A #.$.%.&.*.. ", +" + =.-.;.>.,.'. .. ", +" . . . . . . ", +" "}; diff --git a/eeschema/bitmaps/Options_Pin.xpm b/eeschema/bitmaps/Options_Pin.xpm new file mode 100644 index 0000000000..462afa3635 --- /dev/null +++ b/eeschema/bitmaps/Options_Pin.xpm @@ -0,0 +1,67 @@ +/* XPM */ +static char * options_pin_xpm[] = { +"16 16 48 1", +" c None", +". c #D72E2E", +"+ c #DE676B", +"@ c #DA636B", +"# c #D62E2E", +"$ c #E5E5FF", +"% c #D7D7FF", +"& c #D25B6B", +"* c #D23535", +"= c #CACAFF", +"- c #CE576B", +"; c #D03939", +"> c #B96464", +", c #9B9B9B", +"' c #C35151", +") c #B17171", +"! c #B36E6E", +"~ c #CA4444", +"{ c #9C9898", +"] c #000000", +"^ c #F0F0F0", +"/ c #DEDEDE", +"( c #DFDFDF", +"_ c #BFBFBF", +": c #C0C0C0", +"< c #979797", +"[ c #989898", +"} c #C1C1C1", +"| c #E3E3E3", +"1 c #DDDDDD", +"2 c #C8C8C8", +"3 c #656565", +"4 c #838383", +"5 c #878787", +"6 c #888888", +"7 c #AFAFAF", +"8 c #A3A3A3", +"9 c #F1F1F1", +"0 c #CECECE", +"a c #ABABAB", +"b c #EEEEEE", +"c c #EDEDED", +"d c #E9E9E9", +"e c #D9D9D9", +"f c #B5B5B5", +"g c #757575", +"h c #6B6B6B", +"i c #777777", +" .. ", +" .+@. ", +"#+$%&......... ", +"*@%=-;>>>>>>>>, ", +"'.&-.),,,,,,,,, ", +" !~~){ ", +" ,,, ", +" ]]]]]]]]]]]]]", +" ]^/(((((((((((", +" ](______::::::", +" ](_<]]][:::::}", +" ](_]|12]34567}", +" ](_]1:8]]]]]9:", +" ](_]08<]abcde}", +" ](:[]]]34}}}}:", +" ](:fgh3i6]]][:"}; diff --git a/eeschema/bitmaps/Options_Pinsheet.xpm b/eeschema/bitmaps/Options_Pinsheet.xpm new file mode 100644 index 0000000000..dc537064a7 --- /dev/null +++ b/eeschema/bitmaps/Options_Pinsheet.xpm @@ -0,0 +1,97 @@ +/* XPM */ +static char * options_pinsheet_xpm[] = { +"16 16 78 1", +" c None", +". c #6F6500", +"+ c #FEFEFF", +"@ c #FCFCFF", +"# c #F1F1FF", +"$ c #D3D2D8", +"% c #746B0E", +"& c #8D8A6C", +"* c #6E6400", +"= c #695F00", +"- c #4F4800", +"; c #F8F8FF", +"> c #EDEDFF", +", c #E2E2FF", +"' c #D6D6FF", +") c #AEABB1", +"! c #716707", +"~ c #92907D", +"{ c #635A00", +"] c #5C5300", +"^ c #675E00", +"/ c #F3F3FF", +"( c #E8E8FF", +"_ c #DDDDFF", +": c #D2D2FF", +"< c #C7C7FF", +"[ c #BCBCFF", +"} c #827B4C", +"| c #787020", +"1 c #939180", +"2 c #E4E4FF", +"3 c #D9D9FF", +"4 c #CECEFF", +"5 c #C2C2FF", +"6 c #B7B7FF", +"7 c #9895B1", +"8 c #847F4D", +"9 c #72690E", +"0 c #D4D4FF", +"a c #C9C9FF", +"b c #BEBEFF", +"c c #B3B3FF", +"d c #9E9DD8", +"e c #71680E", +"f c #9B9B9B", +"g c #756D18", +"h c #675F0B", +"i c #888358", +"j c #010101", +"k c #000000", +"l c #F0F0F0", +"m c #DEDEDE", +"n c #DFDFDF", +"o c #BFBFBF", +"p c #C0C0C0", +"q c #979797", +"r c #989898", +"s c #C1C1C1", +"t c #E3E3E3", +"u c #DDDDDD", +"v c #C8C8C8", +"w c #656565", +"x c #838383", +"y c #878787", +"z c #888888", +"A c #AFAFAF", +"B c #A3A3A3", +"C c #F1F1F1", +"D c #CECECE", +"E c #ABABAB", +"F c #EEEEEE", +"G c #EDEDED", +"H c #E9E9E9", +"I c #D9D9D9", +"J c #B5B5B5", +"K c #757575", +"L c #6B6B6B", +"M c #777777", +"...... .. ", +".++@#$%& .*=- ", +".+;>,')!~ .{]^ ", +"./(_:<[}|1.... ", +".234567!~89 =- ", +".0abcde&fgh .^ ", +"......iff ", +" ffjjjjjjkkkkkkk", +" klmnnnnnnnnnnn", +" knoooooopppppp", +" knoqkkkrppppps", +" knoktuvkwxyzAs", +" knokupBkkkkkCp", +" knokDBqkEFGHIs", +" knprkkkwxssssp", +" knpJKLwMzkkkrp"}; diff --git a/eeschema/bitmaps/Pin_Name_to.xpm b/eeschema/bitmaps/Pin_Name_to.xpm new file mode 100644 index 0000000000..60a77e0e78 --- /dev/null +++ b/eeschema/bitmaps/Pin_Name_to.xpm @@ -0,0 +1,77 @@ +/* XPM */ +static char * pin_name_to_xpm[] = { +"16 16 58 1", +" c None", +". c #D72E2E", +"+ c #D72D2D", +"@ c #D72F2F", +"# c #E06E72", +"$ c #DC6A72", +"% c #CA4343", +"& c #D62E2E", +"* c #DF696D", +"= c #E5E5FF", +"- c #D7D7FF", +"; c #D35D6D", +"> c #D23636", +", c #DB6168", +"' c #CACAFF", +") c #CF5568", +"! c #CF3A3A", +"~ c #B76767", +"{ c #B76666", +"] c #B86666", +"^ c #B86565", +"/ c #B86464", +"( c #9B9B9B", +"_ c #C35151", +": c #D35664", +"< c #CF5264", +"[ c #B17272", +"} c #B17171", +"| c #C84747", +"1 c #553838", +"2 c #393838", +"3 c #000000", +"4 c #161616", +"5 c #006600", +"6 c #004500", +"7 c #008C00", +"8 c #00A300", +"9 c #000800", +"0 c #002100", +"a c #006000", +"b c #00BD00", +"c c #009500", +"d c #005100", +"e c #002C00", +"f c #00AA00", +"g c #002500", +"h c #009300", +"i c #00B000", +"j c #002300", +"k c #000D00", +"l c #004F00", +"m c #008B00", +"n c #00A200", +"o c #00AD00", +"p c #001800", +"q c #00B200", +"r c #002D00", +"s c #004000", +" ... ", +" . . ", +" .. +.+ ", +" @#$@% . . ", +"&*=-;....... ", +">,-')!~{]]^/( ", +"_.:<.[( ", +" }||123 ", +" ((456 ", +" 3789 0 ", +" abcdefg ", +" 9hbbbbij ", +" klmnbop ", +" 33qr3 ", +" 3s3 ", +" "}; diff --git a/eeschema/bitmaps/Pin_Number_to.xpm b/eeschema/bitmaps/Pin_Number_to.xpm new file mode 100644 index 0000000000..81bec8b572 --- /dev/null +++ b/eeschema/bitmaps/Pin_Number_to.xpm @@ -0,0 +1,77 @@ +/* XPM */ +static char * pin_number_to_xpm[] = { +"16 16 58 1", +" c None", +". c #D72E2E", +"+ c #D72F2F", +"@ c #E06E72", +"# c #DC6A72", +"$ c #CA4343", +"% c #00009B", +"& c #D62E2E", +"* c #DF696D", +"= c #E5E5FF", +"- c #D7D7FF", +"; c #D35D6D", +"> c #D23636", +", c #DB6168", +"' c #CACAFF", +") c #CF5568", +"! c #CF3A3A", +"~ c #B76767", +"{ c #B76666", +"] c #B86666", +"^ c #B86565", +"/ c #B86464", +"( c #9B9B9B", +"_ c #C35151", +": c #D35664", +"< c #CF5264", +"[ c #B17272", +"} c #B17171", +"| c #C84747", +"1 c #553838", +"2 c #393838", +"3 c #000000", +"4 c #161616", +"5 c #006600", +"6 c #004500", +"7 c #008C00", +"8 c #00A300", +"9 c #000800", +"0 c #002100", +"a c #006000", +"b c #00BD00", +"c c #009500", +"d c #005100", +"e c #002C00", +"f c #00AA00", +"g c #002500", +"h c #009300", +"i c #00B000", +"j c #002300", +"k c #000D00", +"l c #004F00", +"m c #008B00", +"n c #00A200", +"o c #00AD00", +"p c #001800", +"q c #00B200", +"r c #002D00", +"s c #004000", +" ", +" ", +" .. ", +" +@#+$ %%%", +"&*=-;....... % %", +">,-')!~{]]^/(%%%", +"_.:<.[( % %", +" }||123 ", +" ((456 ", +" 3789 0 ", +" abcdefg ", +" 9hbbbbij ", +" klmnbop ", +" 33qr3 ", +" 3s3 ", +" "}; diff --git a/eeschema/bitmaps/Pin_Size_to.xpm b/eeschema/bitmaps/Pin_Size_to.xpm new file mode 100644 index 0000000000..2df111877f --- /dev/null +++ b/eeschema/bitmaps/Pin_Size_to.xpm @@ -0,0 +1,72 @@ +/* XPM */ +static char * pin_size_to_xpm[] = { +"16 16 53 1", +" c None", +". c #D72E2E", +"+ c #DE676B", +"@ c #DA636B", +"# c #D62E2E", +"$ c #E5E5FF", +"% c #D7D7FF", +"& c #D25B6B", +"* c #D62F2F", +"= c #D23535", +"- c #CACAFF", +"; c #CE576B", +"> c #D03939", +", c #B96363", +"' c #B96262", +") c #BA6262", +"! c #BA6161", +"~ c #BA6060", +"{ c #9B9B9B", +"] c #C35151", +"^ c #B17171", +"/ c #B36E6E", +"( c #CA4444", +"_ c #9C9898", +": c #989898", +"< c #777777", +"[ c #000000", +"} c #006600", +"| c #004500", +"1 c #008C00", +"2 c #00A300", +"3 c #000700", +"4 c #002100", +"5 c #006000", +"6 c #00BD00", +"7 c #009500", +"8 c #005100", +"9 c #002C00", +"0 c #00AA00", +"a c #002500", +"b c #000800", +"c c #009300", +"d c #00B000", +"e c #002300", +"f c #000D00", +"g c #004F00", +"h c #008B00", +"i c #00A200", +"j c #00AD00", +"k c #001800", +"l c #00B200", +"m c #002D00", +"n c #004000", +" .. ", +" .+@. ", +"#+$%&.######** ", +"=@%-;>,',,')!~{ ", +"].&;.^{{{{{{{{{ ", +" /((^_ ", +" :<{ ", +"[ [[[[[ [[ [ ", +"[[[ [}| [[[ ", +"[[[[[123[[4[[[[ ", +"[[[ 567890a[[[ ", +"[ [[ bc6666de [ ", +" fghi6jk ", +" [[lm[ ", +" [n[ ", +" "}; diff --git a/eeschema/bitmaps/Pin_to.xpm b/eeschema/bitmaps/Pin_to.xpm new file mode 100644 index 0000000000..1ea8e6d374 --- /dev/null +++ b/eeschema/bitmaps/Pin_to.xpm @@ -0,0 +1,67 @@ +/* XPM */ +static char * pin_to_xpm[] = { +"16 16 48 1", +" c None", +". c #D72E2E", +"+ c #DE676B", +"@ c #DA636B", +"# c #D62E2E", +"$ c #E5E5FF", +"% c #D7D7FF", +"& c #D25B6B", +"* c #D23535", +"= c #CACAFF", +"- c #CE576B", +"; c #D03939", +"> c #B96464", +", c #9B9B9B", +"' c #C35151", +") c #B17171", +"! c #B36E6E", +"~ c #CA4444", +"{ c #9C9898", +"] c #939393", +"^ c #838383", +"/ c #000900", +"( c #001100", +"_ c #000000", +": c #004D00", +"< c #00BD00", +"[ c #001700", +"} c #000100", +"| c #002500", +"1 c #008000", +"2 c #005200", +"3 c #001E00", +"4 c #000400", +"5 c #009500", +"6 c #00BA00", +"7 c #009800", +"8 c #009E00", +"9 c #00AB00", +"0 c #008C00", +"a c #00BC00", +"b c #001D00", +"c c #003F00", +"d c #008700", +"e c #00AF00", +"f c #001A00", +"g c #006000", +"h c #003000", +"i c #000D00", +" .. ", +" .+@. ", +"#+$%&......... ", +"*@%=-;>>>>>>>>, ", +"'.&-.),,,,,,,,, ", +" !~~){ ", +" ,]^ ", +" /(_ ", +" :<[ } ", +" |<1/ 23 ", +" 45<67893 ", +" (0a<<<0_ ", +" _bcdef ", +" gh ", +" i_ ", +" "}; diff --git a/eeschema/bitmaps/Resize_Sheet.xpm b/eeschema/bitmaps/Resize_Sheet.xpm new file mode 100644 index 0000000000..ec3b447e07 --- /dev/null +++ b/eeschema/bitmaps/Resize_Sheet.xpm @@ -0,0 +1,34 @@ +/* XPM */ +static char * resize_sheet_xpm[] = { +"16 16 15 1", +" c None", +". c #000000", +"+ c #020202", +"@ c #F8F8F8", +"# c #ECECEC", +"$ c #EBEBEB", +"% c #6A6A6A", +"& c #2C2C2C", +"* c #424242", +"= c #5E5E5E", +"- c #C4C4C4", +"; c #0D0D0D", +"> c #B8B8B8", +", c #C3C3C3", +"' c #080808", +" ......+ ", +" .@#$$$%& ... ", +" .@#$$$*=. ... ", +" .@#$$$$-; . ", +" .@#$$$$-; . ", +" .@#$$$$-; . ", +" .@#$$$$-; . ", +" .@#$$$$-; . ", +" .@#$$$$-; . ", +" .>,,,,,,' ....", +" ........ ... ", +" ", +" .. .. ", +" ......... ", +" .. .. ", +" "}; diff --git a/eeschema/bitmaps/Rotate_GLabel.xpm b/eeschema/bitmaps/Rotate_GLabel.xpm new file mode 100644 index 0000000000..b30b0b568b --- /dev/null +++ b/eeschema/bitmaps/Rotate_GLabel.xpm @@ -0,0 +1,110 @@ +/* XPM */ +static char * rotate_glabel_xpm[] = { +"16 16 91 1", +" c None", +". c #695F00", +"+ c #685E00", +"@ c #635A00", +"# c #4B4400", +"$ c #9191FF", +"% c #9B9BFF", +"& c #A5A5FF", +"* c #857F66", +"= c #5F5500", +"- c #5E5500", +"; c #574E00", +"> c #625800", +", c #9E9EFF", +"' c #A8A8FF", +") c #B2B2FF", +"! c #BBBBF9", +"~ c #7D7539", +"{ c #595100", +"] c #675D00", +"^ c #4A4A6F", +"/ c #B6B6FF", +"( c #C0C0FF", +"_ c #CACAFF", +": c #BFBDCC", +"< c #201D03", +"[ c #252526", +"} c #9898C7", +"| c #CECEFF", +"1 c #D5D5F9", +"2 c #847C39", +"3 c #4E4700", +"4 c #594F00", +"5 c #141414", +"6 c #B9B9BA", +"7 c #B5B5BA", +"8 c #73737B", +"9 c #757580", +"0 c #59595C", +"a c #302D1B", +"b c #020200", +"c c #000000", +"d c #B7B7B8", +"e c #FEFEFF", +"f c #F8F8FF", +"g c #F1F1FF", +"h c #EBEBFF", +"i c #E4E4FF", +"j c #DDDDFF", +"k c #7C7C93", +"l c #020204", +"m c #131313", +"n c #B8B8BD", +"o c #8B8B93", +"p c #9999A6", +"q c #A5A5B9", +"r c #D6D6F7", +"s c #D7D7FF", +"t c #606076", +"u c #030303", +"v c #242425", +"w c #19191D", +"x c #C6C6EB", +"y c #9494B5", +"z c #5F5F78", +"A c #3E3E4C", +"B c #474754", +"C c #5B5B70", +"D c #9B9BC5", +"E c #B7B7E0", +"F c #151518", +"G c #252527", +"H c #010101", +"I c #6A6A86", +"J c #D0D0FF", +"K c #CDCDF3", +"L c #9F9FB7", +"M c #9393A4", +"N c #878792", +"O c #BABAC5", +"P c #AAAAAF", +"Q c #0F0F0F", +"R c #070708", +"S c #8787A5", +"T c #A8A8A9", +"U c #202026", +"V c #50505C", +"W c #6A6A76", +"X c #70707A", +"Y c #B7B7C2", +"Z c #0D0D0D", +" .. ..... ", +" .+@# .$%&*= ", +" .-;> .,')!~{ ", +" .... ]^/(_:. ", +".+ @# <[}|123 ", +".- .4567890ab ", +" cdefghijkl ", +" m6nopqrstc", +" cc uv ccwxyc", +" czA c c BCc", +" cDEF GH ccc", +" IJKLMNOPQ ", +" RSsjihgfTc ", +" cUVWXYPZ ", +" GH ", +" c "}; diff --git a/eeschema/bitmaps/Rotate_Pin.xpm b/eeschema/bitmaps/Rotate_Pin.xpm new file mode 100644 index 0000000000..68d08d818c --- /dev/null +++ b/eeschema/bitmaps/Rotate_Pin.xpm @@ -0,0 +1,91 @@ +/* XPM */ +static char * Rotate_Pin_xpm[] = { +"16 16 72 1", +" c None", +". c #D72E2E", +"+ c #DE676B", +"@ c #DA636B", +"# c #D62E2E", +"$ c #E5E5FF", +"% c #D7D7FF", +"& c #D25B6B", +"* c #D23535", +"= c #CACAFF", +"- c #CE576B", +"; c #D03939", +"> c #B96464", +", c #9F5656", +"' c #B86363", +") c #9B9B9B", +"! c #C35151", +"~ c #B17171", +"{ c #666666", +"] c #070707", +"^ c #7E7E7E", +"/ c #B36E6E", +"( c #CA4444", +"_ c #9C9898", +": c #393939", +"< c #67676A", +"[ c #000000", +"} c #626262", +"| c #F7F7F8", +"1 c #F8F8FF", +"2 c #EBEBF9", +"3 c #E0E0F3", +"4 c #BFBFD6", +"5 c #8B8BA0", +"6 c #30303A", +"7 c #616161", +"8 c #F1F1FF", +"9 c #EBEBFF", +"0 c #E4E4FF", +"a c #DDDDFF", +"b c #CECEF4", +"c c #353541", +"d c #383838", +"e c #69696C", +"f c #161617", +"g c #28282B", +"h c #36363D", +"i c #777789", +"j c #D4D4FC", +"k c #8888A7", +"l c #9494B0", +"m c #B8B8E2", +"n c #A1A1CC", +"o c #A0A0C4", +"p c #757594", +"q c #CFCFFE", +"r c #7D7D94", +"s c #383842", +"t c #2F2F34", +"u c #1D1D1F", +"v c #5C5C61", +"w c #434345", +"x c #2B2B37", +"y c #C2C2EE", +"z c #F5F5FC", +"A c #6F6F6F", +"B c #22222A", +"C c #83839B", +"D c #B5B5D1", +"E c #D8D8F2", +"F c #E5E5F9", +"G c #59595E", +" .. ", +" .+@. ", +"#+$%&......... ", +"*@%=-;>>,'>>>>) ", +"!.&-.~){]^))))) ", +" /((~_ :<[ ", +" ))) }|123456 ", +" 7|1890abc ", +" defghijk[", +" [[[ [ [lm[", +" [no[ [ [[[", +" [pqrstuvw ", +" xy%a098zA ", +" BCDEF8zA[ ", +" [[[Gw[ ", +" [[ "}; diff --git a/eeschema/bitmaps/add_bus.xpm b/eeschema/bitmaps/add_bus.xpm new file mode 100644 index 0000000000..f9e6911fb8 --- /dev/null +++ b/eeschema/bitmaps/add_bus.xpm @@ -0,0 +1,23 @@ +/* XPM */ +static const char * add_bus_xpm[] = { +"16 16 4 1", +" c None", +"! c black", +"# c #0046D9", +"$ c #9B9B9B", +" ", +"###### ", +"###### ", +" $$$##$ ", +" ##$ ", +" ##$ ", +" ##$ ", +" ##$ ", +" ##$ ", +" ##$ ", +" ########### ", +" ########### ", +" $$$$$$$$$$", +" ", +" ", +" "}; diff --git a/eeschema/bitmaps/add_hierar_pin.xpm b/eeschema/bitmaps/add_hierar_pin.xpm new file mode 100644 index 0000000000..374ef71a46 --- /dev/null +++ b/eeschema/bitmaps/add_hierar_pin.xpm @@ -0,0 +1,56 @@ +/* XPM */ +static const char * add_hierar_pin_xpm[] = { +"16 16 37 1", +" c None", +"! c black", +"# c white", +"$ c #FDFDFD", +"% c #FCFCFC", +"& c #666666", +"' c #D99300", +"( c #F0F0F0", +") c #707070", +"* c #151515", +"+ c #747474", +", c #4A4A48", +"- c #ECECEC", +". c #EAEAEA", +"0 c #FF0000", +"1 c #D1D1D1", +"2 c #C4C4C4", +"3 c #287C00", +"4 c #EBEBEB", +"5 c #C3C3C3", +"6 c #3CBA00", +"7 c #0D0D0D", +"8 c #C2C2C2", +"9 c #0055F0", +": c #0C0C0C", +"; c #C0C0C0", +"< c #090909", +"= c #BFBFBF", +"> c #060606", +"? c #BEBEBE", +"@ c #040404", +"A c #BDBDBD", +"B c #010101", +"C c #BCBCBC", +"D c #BABABA", +"E c #B8B8B8", +"F c #9F9F9F", +" !!!!!!!!!!!! ", +"!####$$$$$%&'! ", +"!###$((((((&''! ", +"!###$((((((&'''!", +"!#)!!!!****!+,*!", +"!#!----...!0!12!", +"!#!333--44!00!5!", +"!#!6663-44!!!78!", +"!996663399945:;!", +"!#!6663-44945<=!", +"!#!333-444995>?!", +"!#!----444445@A!", +"!#!5552555555BC!", +"!#)!!!!!!!!!!)D!", +"!EEEEEEEEEEEEEF!", +" !!!!!!!!!!!!!! "}; diff --git a/eeschema/bitmaps/add_hierar_symbol.xpm b/eeschema/bitmaps/add_hierar_symbol.xpm new file mode 100644 index 0000000000..9f29d6a90b --- /dev/null +++ b/eeschema/bitmaps/add_hierar_symbol.xpm @@ -0,0 +1,54 @@ +/* XPM */ +static const char * add_hierar_symbol_xpm[] = { +"16 16 35 1", +" c None", +"! c black", +"# c white", +"$ c #FDFDFD", +"% c #FCFCFC", +"& c #666666", +"' c #F00000", +"( c #F0F0F0", +") c #707070", +"* c #151515", +"+ c #747474", +", c #4A4A48", +"- c #ECECEC", +". c #EAEAEA", +"0 c #FFCE6C", +"1 c #D1D1D1", +"2 c #C4C4C4", +"3 c #EBEBEB", +"4 c #C3C3C3", +"5 c #0D0D0D", +"6 c #C2C2C2", +"7 c #0C0C0C", +"8 c #C0C0C0", +"9 c #090909", +": c #BFBFBF", +"; c #060606", +"< c #BEBEBE", +"= c #040404", +"> c #BDBDBD", +"? c #010101", +"@ c #BCBCBC", +"A c #BABABA", +"B c #C1C1C1", +"C c #BBBBBB", +"D c #9F9F9F", +" !!!!!!!!!!!! ", +"!####$$$$$%&'! ", +"!###$((((((&''! ", +"!###$((((((&'''!", +"!#)!!!!****!+,*!", +"!#!----...!0!12!", +"!#!-----33!00!4!", +"!#!-----33!!!56!", +"!#!-----3333478!", +"!#!-----333349:!", +"!#!----333334;!", +"!#!4442444444?@!", +"!#)!!!!!!!!!!)A!", +"!###B@@@CCAAAAD!", +" !!!!!!!!!!!!!! "}; diff --git a/eeschema/bitmaps/cvpcb.xpm b/eeschema/bitmaps/cvpcb.xpm new file mode 100644 index 0000000000..15aac5db1a --- /dev/null +++ b/eeschema/bitmaps/cvpcb.xpm @@ -0,0 +1,66 @@ +/* XPM */ +static char *cvpcb_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 16 46 1", +" c None", +". c #160A00", +"+ c #FF7800", +"@ c #000000", +"# c #231000", +"$ c #DC8E49", +"% c #421F00", +"& c #E86D00", +"* c #FFFFFF", +"= c #C35B00", +"- c #FF8215", +"; c #F5933C", +"> c #9E7B5B", +", c #C7B4A5", +"' c #FDBD85", +") c #FFBF87", +"! c #FF8D29", +"~ c #FD9F4D", +"{ c #CFA078", +"] c #C7874F", +"^ c #F9B880", +"/ c #FF8519", +"( c #FF9231", +"_ c #FF9F49", +": c #FFAC62", +"< c #ECB88A", +"[ c #D5B69B", +"} c #F6EDE6", +"| c #F3F3F3", +"1 c #878787", +"2 c #FFB97A", +"3 c #F9C598", +"4 c #E8C9AE", +"5 c #F7EADF", +"6 c #FDFDFD", +"7 c #272727", +"8 c #FFC592", +"9 c #FDD1AA", +"0 c #F6DDC6", +"a c #FBEEE4", +"b c #FEFEFE", +"c c #C7C7C7", +"d c #F4F4F4", +"e c #888888", +"f c #EC6F00", +"g c #C65D00", +" . +++ ", +" @# +++ ", +" @$% &*= +*+@@", +" @-;>,'))**+++*@", +" @-!~{]^)**+++*@", +"@@/(_:<[}****|1@", +" @/(_:2345**67 ", +" @/(_:2890abc@ ", +" @/(_:2890abc@ ", +" @/(_:2345**67 ", +"@@/(_:<[}****de@", +" @-!~{]^)**+++*@", +" @-;>,'))**+++*@", +" @$% f*g +*+@@", +" @# +++ ", +" . +++ "}; diff --git a/eeschema/bitmaps/libedit.xpm b/eeschema/bitmaps/libedit.xpm new file mode 100644 index 0000000000..1c92c78c0e --- /dev/null +++ b/eeschema/bitmaps/libedit.xpm @@ -0,0 +1,149 @@ +/* XPM */ +static char * libedit_xpm[] = { +"16 16 130 2", +" c None", +". c #070809", +"+ c #323538", +"@ c #1F1F20", +"# c #0B0D0E", +"$ c #E5E7E8", +"% c #F6F6F6", +"& c #838587", +"* c #050506", +"= c #0B0D0F", +"- c #F7F7F7", +"; c #D8D8D8", +"> c #E0E1E2", +", c #1F2021", +"' c #050709", +") c #E4E7E8", +"! c #D8D9D9", +"~ c #D2D2D2", +"{ c #E2E2E2", +"] c #BFC1C3", +"^ c #0F0F0F", +"/ c #080B0D", +"( c #E6E8EA", +"_ c #F9F9F9", +": c #D5D5D5", +"< c #BDBDBD", +"[ c #CDCDCD", +"} c #CACACA", +"| c #DDDEDE", +"1 c #535455", +"2 c #030406", +"3 c #9F9FA0", +"4 c #F5F5F6", +"5 c #CFCFCF", +"6 c #D0D0D0", +"7 c #B6B6B6", +"8 c #C5C5C5", +"9 c #CDCFD1", +"0 c #C6C6C6", +"a c #565656", +"b c #353535", +"c c #363636", +"d c #0B0B0B", +"e c #000000", +"f c #848787", +"g c #B5B9BC", +"h c #DEDEDE", +"i c #B8B8B8", +"j c #C9C9C9", +"k c #B8BBBE", +"l c #9FA3A6", +"m c #EFF0F0", +"n c #FCFDFD", +"o c #FCFCFC", +"p c #FBFBFC", +"q c #FAFBFC", +"r c #EAEAEA", +"s c #242425", +"t c #1C1C1C", +"u c #999A9C", +"v c #BCBCBC", +"w c #C4C4C4", +"x c #BDBEBF", +"y c #A3A6A9", +"z c #CFD0D1", +"A c #E4E5E5", +"B c #E2E3E4", +"C c #F8F9FA", +"D c #F7F8F9", +"E c #E0E0E2", +"F c #AFB1B2", +"G c #7C7F81", +"H c #B4B7BA", +"I c #E0E0E0", +"J c #C0C0C0", +"K c #AFB2B6", +"L c #BABCBD", +"M c #F3F3F3", +"N c #F9FBFC", +"O c #CBCCCE", +"P c #868C92", +"Q c #171818", +"R c #747F88", +"S c #BABABA", +"T c #DADADA", +"U c #A9ABAD", +"V c #E5E5E5", +"W c #E6E6E6", +"X c #DFE0E0", +"Y c #B4B7BB", +"Z c #181B1E", +"` c #424548", +" . c #8E9599", +".. c #ACAEB0", +"+. c #FFFFFF", +"@. c #FEFEFE", +"#. c #FAFBFB", +"$. c #FAFAFB", +"%. c #CCCED1", +"&. c #747C85", +"*. c #000001", +"=. c #626A74", +"-. c #878889", +";. c #EBEBEB", +">. c #FEFFFF", +",. c #FDFEFE", +"'. c #FBFCFC", +"). c #F0F1F1", +"!. c #A9AEB4", +"~. c #16181B", +"{. c #12161B", +"]. c #47525E", +"^. c #C2C8CE", +"/. c #C5C9CC", +"(. c #D6D7D8", +"_. c #DCDCDC", +":. c #F4F5F5", +"<. c #D2D2D3", +"[. c #7A8188", +"}. c #191C1E", +"|. c #2A2E31", +"1. c #484D51", +"2. c #7F8385", +"3. c #9C9EA0", +"4. c #A0A6AD", +"5. c #92999F", +"6. c #0D0F11", +"7. c #2B343D", +"8. c #191E22", +"9. c #1E2328", +" . + @ ", +" # $ % & * ", +" = $ - ; > , ", +" ' ) - ! ~ { ] ^ ", +" / ( _ : < [ } | 1 ", +"2 3 4 5 6 [ 7 8 9 0 a b b b c d ", +"e f g h i j 8 k l m n o p q r s ", +" t u v j w x y z A B C D E F e ", +" e G H I J K L M n N C D O P e ", +" Q R S T U V W A q C X Y Z ", +" e ` ...: +.@.n #.$.%.&.e ", +" *.=.-.W ;.>.,.'.).!.~. ", +" {.].^./.(._.:.<.[.e ", +" }.|.1.2.3.4.5.6. ", +" 7.8.9. ", +" "}; diff --git a/eeschema/bitmaps/libedit_icon.xpm b/eeschema/bitmaps/libedit_icon.xpm new file mode 100644 index 0000000000..9539346db5 --- /dev/null +++ b/eeschema/bitmaps/libedit_icon.xpm @@ -0,0 +1,147 @@ +/* XPM */ +static char * libedit_icon_xpm[] = { +"32 32 112 2", +" c None", +". c #000000", +"+ c #FEFEFF", +"@ c #F9F9FF", +"# c #F1F1FF", +"$ c #E8E8FF", +"% c #E0E0FF", +"& c #D7D7FF", +"* c #CFCFFF", +"= c #C7C7FF", +"- c #BFBFFF", +"; c #FFFFFF", +"> c #010101", +", c #FDFDFF", +"' c #FBFBFF", +") c #F7F7FF", +"! c #F6F6FF", +"~ c #F4F4FF", +"{ c #F2F2FF", +"] c #F0F0FF", +"^ c #EEEEFF", +"/ c #ECECFF", +"( c #EBEBFF", +"_ c #E9E9FF", +": c #E7E7FF", +"< c #E5E5FF", +"[ c #E3E3FF", +"} c #B6B6B6", +"| c #030303", +"1 c #D4D4D4", +"2 c #A9A9A9", +"3 c #7F7F7F", +"4 c #545454", +"5 c #FAFAFF", +"6 c #F8F8FF", +"7 c #EFEFFF", +"8 c #EDEDFF", +"9 c #E6E6FF", +"0 c #E4E4FF", +"a c #E2E2FF", +"b c #040405", +"c c #A0A0A0", +"d c #E1E1FF", +"e c #060607", +"f c #D8D8FF", +"g c #FCFCFF", +"h c #09090A", +"i c #DEDEFF", +"j c #0A0A0C", +"k c #494949", +"l c #D6D6D6", +"m c #DFDFFF", +"n c #DDDDFF", +"o c #0D0D0F", +"p c #361B03", +"q c #6D6D6D", +"r c #EDEDED", +"s c #DCDCFF", +"t c #0F0F11", +"u c #FC7700", +"v c #8F4300", +"w c #1D1711", +"x c #929292", +"y c #BFBFBF", +"z c #363636", +"A c #C3C3C3", +"B c #DADAFF", +"C c #0F0F12", +"D c #FF7800", +"E c #E36B00", +"F c #4F2500", +"G c #080808", +"H c #B85700", +"I c #81807F", +"J c #51504F", +"K c #6F6E7F", +"L c #D9D9FF", +"M c #101013", +"N c #F5F5FF", +"O c #6E6D7F", +"P c #D6D6FF", +"Q c #D5D5FF", +"R c #F3F3FF", +"S c #D4D4FF", +"T c #111114", +"U c #D3D3FF", +"V c #D1D1FF", +"W c #121215", +"X c #D2D2FF", +"Y c #D0D0FF", +"Z c #EAEAFF", +"` c #69687F", +" . c #CDCDFF", +".. c #131316", +"+. c #68677F", +"@. c #CCCCFF", +"#. c #CBCBFF", +"$. c #131317", +"%. c #C9C9FF", +"&. c #141418", +"*. c #CACAFF", +"=. c #C8C8FF", +"-. c #C6C6FF", +";. c #C4C4FF", +">. c #151519", +",. c #CECEFF", +"'. c #C5C5FF", +"). c #C3C3FF", +"!. c #16161A", +"~. c #DBDBFF", +"{. c #C2C2FF", +"]. c #A0A0AD", +". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", +"+ @ # $ % & * = - . ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; > ", +"+ @ # $ % & * = - . + + + + , ' @ ) ! ~ { ] ^ / ( _ : < [ } | ", +"+ @ # $ % & * ; 1 2 3 4 + , ' 5 6 ! ~ { # 7 8 ( _ $ 9 0 a } b ", +"+ @ # $ % & * = - . + + + c c c c c c c c c c c c c c [ d } e ", +"+ @ # $ % f * = - . + + g c ; ; ; ; ; ; ; ; ; ; ; ; c d % } h ", +"+ @ # $ % f * = - . + , ' c ; ; ; ; ; ; ; ; ; ; ; ; c % i } j ", +"+ @ # $ % f * = - . + g 5 c ; ; k l ; ; ; ; ; ; ; ; c m n } o ", +"+ @ # $ % f * = - . g 5 @ c ; ; . p q r ; ; ; ; ; ; c n s } t ", +"+ @ # $ % f * = - . ' @ . . . . . u v w x y z z A ; c s B } C ", +"+ @ # $ % f * = - . 5 6 ! c ; ; . D D E F G H H z I J K L } M ", +"+ @ # $ % f * ; 1 2 3 4 N c ; ; . D D E F G H H z I J O f } M ", +"+ @ # $ % f * = - . ) N . . . . . u v w x y z z A ; c f P } M ", +"+ @ # $ % f * = - . ! ~ { c ; ; . p q r ; ; ; ; ; ; c & Q } M ", +"+ @ # $ % f * = - . ~ R # c ; ; k l ; ; ; ; ; ; ; ; c P S } T ", +"+ @ # $ % f * = - . R # 7 c ; ; ; ; ; ; ; ; ; ; ; ; c S U } T ", +"+ @ # $ % f * = - . { ] ^ c ; ; k l ; ; ; ; ; ; ; ; c U V } W ", +"+ @ # $ % f * = - . # 7 8 c ; ; . p q r ; ; ; ; ; ; c X Y } W ", +"+ @ # $ % f * = - . 7 8 . . . . . u v w x y z z A ; c Y * } W ", +"+ @ # $ % f * ; 1 2 3 4 Z c ; ; . D D E F G H H z I J ` .} .. ", +"+ @ # $ % f * = - . 8 ( _ c ; ; . D D E F G H H z I J +.@.} .. ", +"+ @ # $ % f * = - . ( _ . . . . . u v w x y z z A ; c .#.} $. ", +"+ @ # $ % f * = - . Z $ 9 c ; ; . p q r ; ; ; ; ; ; c #.%.} &. ", +"+ @ # $ % f * = - . _ : < c ; ; k l ; ; ; ; ; ; ; ; c *.=.} &. ", +"+ @ # $ % f * = - . : 9 0 c ; ; ; ; ; ; ; ; ; ; ; ; c %.= } &. ", +"+ @ # $ % f * = - . 9 0 a c ; ; ; ; ; ; ; ; ; ; ; ; c = -.} &. ", +"+ @ # $ % f * = - . < [ d c c c c c c c c c c c c c c -.;.} >. ", +"+ @ # $ % f * ; 1 2 3 4 % i s B L & Q U V Y ,.@.*.=.= '.).} !. ", +"+ @ # $ % f * = - . a % m n ~.L & P S X Y ,.@.#.%.= '.).{.} !. ", +"+ @ # $ % f * = - . } } } } } } } } } } } } } } } } } } } ].. ", +". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", +" "}; diff --git a/eeschema/bitmaps/library_browse.xpm b/eeschema/bitmaps/library_browse.xpm new file mode 100644 index 0000000000..b13bb9dfbb --- /dev/null +++ b/eeschema/bitmaps/library_browse.xpm @@ -0,0 +1,149 @@ +/* XPM */ +static char * library_browse_xpm[] = { +"16 16 130 2", +" c None", +". c #070809", +"+ c #323538", +"@ c #1F1F20", +"# c #0B0D0E", +"$ c #E5E7E8", +"% c #F6F6F6", +"& c #838587", +"* c #050506", +"= c #0B0D0F", +"- c #F7F7F7", +"; c #D8D8D8", +"> c #E0E1E2", +", c #1F2021", +"' c #050709", +") c #E4E7E8", +"! c #D8D9D9", +"~ c #D2D2D2", +"{ c #E2E2E2", +"] c #BFC1C3", +"^ c #0F0F0F", +"/ c #080B0D", +"( c #E6E8EA", +"_ c #F9F9F9", +": c #D5D5D5", +"< c #BDBDBD", +"[ c #CDCDCD", +"} c #CACACA", +"| c #DDDEDE", +"1 c #535455", +"2 c #030406", +"3 c #9F9FA0", +"4 c #F5F5F6", +"5 c #CFCFCF", +"6 c #D0D0D0", +"7 c #969696", +"8 c #5A5A5A", +"9 c #525253", +"0 c #4D4D4D", +"a c #3C3C3C", +"b c #292929", +"c c #333333", +"d c #353535", +"e c #363636", +"f c #0B0B0B", +"g c #000000", +"h c #848787", +"i c #B5B9BC", +"j c #DEDEDE", +"k c #B8B8B8", +"l c #A6A6A6", +"m c #5F5F5F", +"n c #B2B2B2", +"o c #F1F1F1", +"p c #F2F2F2", +"q c #C5C5C5", +"r c #6B6B6B", +"s c #ADADAD", +"t c #FAFBFC", +"u c #EAEAEA", +"v c #242425", +"w c #1C1C1C", +"x c #999A9C", +"y c #BCBCBC", +"z c #C9C9C9", +"A c #FCFCFC", +"B c #FEFEFE", +"C c #686868", +"D c #C3C3C4", +"E c #AFB1B2", +"F c #7C7F81", +"G c #B4B7BA", +"H c #E0E0E0", +"I c #4F4F4F", +"J c #EEEEEE", +"K c #F4F4F4", +"L c #7B7B7B", +"M c #9D9E9F", +"N c #868C92", +"O c #171818", +"P c #747F88", +"Q c #BABABA", +"R c #4E4E4E", +"S c #FDFDFD", +"T c #FBFBFB", +"U c #818181", +"V c #898B8F", +"W c #181B1E", +"X c #424548", +"Y c #8E9599", +"Z c #4F4F50", +"` c #FAFAFA", +" . c #E4E4E4", +".. c #69696A", +"+. c #616870", +"@. c #000001", +"#. c #626A74", +"$. c #626263", +"%. c #727272", +"&. c #D9D9D9", +"*. c #E1E1E1", +"=. c #2F3032", +"-. c #111315", +";. c #12161B", +">. c #45505B", +",. c #85898D", +"'. c #5D5E5E", +"). c #7A7A7A", +"!. c #7E7E7E", +"~. c #676767", +"{. c #4C4C4C", +"]. c #131313", +"^. c #030303", +"/. c #181B1D", +"(. c #2A2E31", +"_. c #3D4245", +":. c #616465", +"<. c #767879", +"[. c #868B91", +"}. c #74797E", +"|. c #272728", +"1. c #313131", +"2. c #2B343D", +"3. c #191E22", +"4. c #1D2227", +"5. c #3F3F3F", +"6. c #343434", +"7. c #040404", +"8. c #191919", +"9. c #050505", +" . + @ ", +" # $ % & * ", +" = $ - ; > , ", +" ' ) - ! ~ { ] ^ ", +" / ( _ : < [ } | 1 ", +"2 3 4 5 6 } 7 8 9 0 a b c d e f ", +"g h i j k l m n o p q r s t u v ", +" w x y z m k A B B A ; C D E g ", +" g F G H I J B B B A K L M N g ", +" O P Q R p B B S T % U V W ", +" g X Y Z q A A T ` ...+.g ", +" @.#.$.%.&.K % *.L =.-. ", +" ;.>.,.'.).!.~.{.].^. ", +" /.(._.:.<.[.}.|.1.^. ", +" 2.3.4. 5.6.7.", +" 8.9."}; diff --git a/eeschema/bitmaps/new_component.xpm b/eeschema/bitmaps/new_component.xpm new file mode 100644 index 0000000000..b4a3570147 --- /dev/null +++ b/eeschema/bitmaps/new_component.xpm @@ -0,0 +1,45 @@ +/* XPM */ +static const char * new_component_xpm[] = { +"16 16 26 1", +" c None", +"! c black", +"# c #FEFEFE", +"$ c #090909", +"% c #B4FFE6", +"& c #D90000", +"' c #EEEEEE", +"( c #F1F1F1", +") c white", +"* c #767676", +"+ c #F0F0F0", +", c #161616", +"- c #A0A0A4", +". c #EFEFEF", +"0 c #C4C4C4", +"1 c #ECECEC", +"2 c #FFE6B4", +"3 c #FFB4B4", +"4 c #EDEDED", +"5 c #E8E8E8", +"6 c #E7E7E7", +"7 c #B8B8B8", +"8 c #E6E6E6", +"9 c #E5E5E5", +": c #E4E4E4", +"; c #E3E3E3", +" !!!!!!!!!!!! ", +"!##########$%! ", +"!#&&'(((((($%%! ", +"!#&)&&((((($*%%!", +"!&&'))&(((+$$$,!", +"!-&''()&&...''0!", +"!#&''..))&&''10!", +"!#&'''''233&&&0!", +"!#&''4223&&---0!", +"!#&'223&&--5550!", +"!&&233&--555660!", +"!-&3&&788888890!", +"!#&&--688899::0!", +"!#--'''''':;;;0!", +"!00000000000000!", +" !!!!!!!!!!!!!! "}; diff --git a/eeschema/bitmaps/part_properties.xpm b/eeschema/bitmaps/part_properties.xpm new file mode 100644 index 0000000000..51e5175850 --- /dev/null +++ b/eeschema/bitmaps/part_properties.xpm @@ -0,0 +1,104 @@ +/* XPM */ +static char * part_properties_xpm[] = { +"16 16 85 1", +" c None", +". c #000000", +"+ c #585858", +"@ c #B0B0B0", +"# c #1C1A19", +"$ c #303030", +"% c #FFF3EC", +"& c #F3DBCB", +"* c #6F5E53", +"= c #0E0D0D", +"- c #FFE8D8", +"; c #FFDBC2", +"> c #FFCEAB", +", c #CC9A77", +"' c #332419", +") c #FFDDC5", +"! c #FFD0AF", +"~ c #FFC298", +"{ c #FFB582", +"] c #FCA66A", +"^ c #905830", +"/ c #17120E", +"( c #3F3F3F", +"_ c #030303", +": c #FFD1B2", +"< c #FFC49C", +"[ c #FFB785", +"} c #FFAA6F", +"| c #FF9D58", +"1 c #FF8F42", +"2 c #E37426", +"3 c #100701", +"4 c #B8B8B8", +"5 c #B89984", +"6 c #131313", +"7 c #444444", +"8 c #1C1C1C", +"9 c #FFC69F", +"0 c #FFB988", +"a c #010100", +"b c #010000", +"c c #010101", +"d c #FFBB8C", +"e c #F1F1F0", +"f c #DFDFDE", +"g c #E0E0DF", +"h c #E0DFDF", +"i c #DFDFDF", +"j c #E0E0E0", +"k c #FFB079", +"l c #C0BFBF", +"m c #BFBFBF", +"n c #C0C0C0", +"o c #C1C1C1", +"p c #FFA465", +"q c #979797", +"r c #999999", +"s c #B06A39", +"t c #E4E4E4", +"u c #DEDEDE", +"v c #C8C8C8", +"w c #656565", +"x c #838383", +"y c #878787", +"z c #888888", +"A c #AFAFAF", +"B c #A3A3A3", +"C c #F1F1F1", +"D c #CECECE", +"E c #ABABAB", +"F c #EEEEEE", +"G c #EDEDED", +"H c #E9E9E9", +"I c #D9D9D9", +"J c #989898", +"K c #B5B5B5", +"L c #757575", +"M c #6B6B6B", +"N c #777777", +"O c #A7A7A7", +"P c #7B7B7B", +"Q c #747474", +"R c #717171", +"S c #E3E3E3", +"T c #DDDDDD", +" ..+ ", +" .@#$ ", +" .%&*=+ ", +"..-;>,'$ ", +" .)!~{]^/(_. ", +" .:<[}|12345678 ", +" .90aaaab.cb...c", +" .daefghiiiiijjj", +"..kaglmmnnnoooon", +" .paimqcccrnnnnn", +" .s.inctuv.wxyzA", +" ...jncunB.....C", +" . cjn.DBq.EFGHI", +" cjnJ...wxoooo", +" .inKLMwNz...J", +" .inOPPQR.STv."}; diff --git a/eeschema/bitmaps/pin2pin.xpm b/eeschema/bitmaps/pin2pin.xpm new file mode 100644 index 0000000000..3626c6cfe6 --- /dev/null +++ b/eeschema/bitmaps/pin2pin.xpm @@ -0,0 +1,82 @@ +/* XPM bitmap */ +static char *pin2pin_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 16 61 1", +" c None", +". c #000000", +"+ c #00009A", +"@ c #000086", +"# c #00009B", +"$ c #000099", +"% c #010101", +"& c #47474B", +"* c #43434B", +"= c #000081", +"- c #E5E5FF", +"; c #D7D7FF", +"> c #3B3B4B", +", c #00002E", +"' c #000092", +") c #000016", +"! c #0A0A0A", +"~ c #CACAFF", +"{ c #37374B", +"] c #0F0F0F", +"^ c #4C4C4C", +"/ c #49494C", +"( c #161682", +"_ c #040493", +": c #000097", +"< c #141462", +"[ c #484848", +"} c #9B9B9B", +"| c #323232", +"1 c #606060", +"2 c #95959B", +"3 c #1C1C9B", +"4 c #08089A", +"5 c #3C3C5A", +"6 c #2E2E67", +"7 c #010199", +"8 c #252586", +"9 c #5B5B5B", +"0 c #1F1F1F", +"a c #989898", +"b c #000098", +"c c #000088", +"d c #D72E2E", +"e c #DE676B", +"f c #DA636B", +"g c #D62E2E", +"h c #D25B6B", +"i c #D62F2F", +"j c #D23636", +"k c #CE576B", +"l c #D03939", +"m c #B96363", +"n c #B96262", +"o c #BA6262", +"p c #BA6161", +"q c #BA6060", +"r c #C35050", +"s c #B27171", +"t c #B36D6D", +"u c #CA4444", +"v c #9C9898", +" ", +" .. +@ #$ ", +" %&*% $=#+ ", +" .&-;>...,$').% ", +" !*;~{]^/(_:<[[}", +" |%>{%12345678}}", +" 9001a b c ", +" }}} ", +" ", +" dd ", +" defd ", +" ge-;hgggggggii ", +" jf;~klmnmmnopq}", +" rdhkds}}}}}}}}}", +" tuusv ", +" }}} "}; + diff --git a/eeschema/bitmaps/viewlibs_icon.xpm b/eeschema/bitmaps/viewlibs_icon.xpm new file mode 100644 index 0000000000..efb2e7ae07 --- /dev/null +++ b/eeschema/bitmaps/viewlibs_icon.xpm @@ -0,0 +1,380 @@ +/* XPM */ +static char * viewlibs_icon_xpm[] = { +"32 32 345 2", +" c None", +". c #0C0C0E", +"+ c #373747", +"@ c #434354", +"# c #5D5D71", +"$ c #7B7B8D", +"% c #848491", +"& c #66666C", +"* c #535353", +"= c #262626", +"- c #1A1A1C", +"; c #575768", +"> c #A4A4CE", +", c #BEBEFF", +"' c #BFBFFF", +") c #C9C9FF", +"! c #D4D4FF", +"~ c #DEDEFF", +"{ c #E8E8FF", +"] c #F2F2FF", +"^ c #9D9D9E", +"/ c #3D3D40", +"( c #C8C8DE", +"_ c #DADAFF", +": c #D0D0FF", +"< c #C6C6FF", +"[ c #BCBCFF", +"} c #C2C2FF", +"| c #BCBCEC", +"1 c #9393B0", +"2 c #E0E0FF", +"3 c #EBEBFF", +"4 c #F5F5FF", +"5 c #5A5A5A", +"6 c #292929", +"7 c #D9D9E1", +"8 c #ECECFF", +"9 c #E2E2FF", +"0 c #D8D8FF", +"a c #CDCDFF", +"b c #C3C3FF", +"c c #B1B1F4", +"d c #A2A2D3", +"e c #777790", +"f c #757588", +"g c #E2E2FE", +"h c #EDEDFF", +"i c #E1E1E8", +"j c #303030", +"k c #1C1C20", +"l c #3F3F4C", +"m c #4A4A57", +"n c #3F3F47", +"o c #222225", +"p c #5E5E5E", +"q c #FEFEFF", +"r c #F4F4FF", +"s c #EAEAFF", +"t c #CFCFF8", +"u c #85859B", +"v c #A3A3AA", +"w c #CCCCCE", +"x c #C7C7C7", +"y c #AFAFB0", +"z c #9898A1", +"A c #A5A5B5", +"B c #EFEFFF", +"C c #B1B1B4", +"D c #202025", +"E c #65657E", +"F c #9090BC", +"G c #ACACE7", +"H c #8585A2", +"I c #858590", +"J c #757582", +"K c #D7D7F5", +"L c #9A9AA2", +"M c #F7F7F7", +"N c #FCFCFF", +"O c #E7E7FF", +"P c #8C8C9B", +"Q c #AA927D", +"R c #9B693D", +"S c #EFEDEC", +"T c #979797", +"U c #FFFFFF", +"V c #F6F6F6", +"W c #DADADB", +"X c #ADADBC", +"Y c #6C6C6C", +"Z c #3F3F48", +"` c #BABADD", +" . c #B6B6E5", +".. c #7A7A92", +"+. c #8B8B96", +"@. c #EBEBEB", +"#. c #D7D7D9", +"$. c #89899B", +"%. c #C6C6DF", +"&. c #B4B4B7", +"*. c #F9F9FF", +"=. c #9D9DA3", +"-. c #E2DDD7", +";. c #BE6B22", +">. c #905D2F", +",. c #919191", +"'. c #AAAAAA", +"). c #7C4C22", +"!. c #896D55", +"~. c #898996", +"{. c #E7E7F2", +"]. c #3A3A3A", +"^. c #787881", +"/. c #B3B3C9", +"(. c #7D7D89", +"_. c #9F9FA4", +":. c #F8F8F8", +"<. c #EFEFEF", +"[. c #6B533D", +"}. c #514A46", +"|. c #6B6B7B", +"1. c #CECEE6", +"2. c #CFCFD0", +"3. c #F7F7FF", +"4. c #76767B", +"5. c #A4A4A4", +"6. c #A99F97", +"7. c #C86C1B", +"8. c #9F7550", +"9. c #E3E2E2", +"0. c #A99482", +"a. c #9A9693", +"b. c #646475", +"c. c #D3D3EF", +"d. c #C2C2C8", +"e. c #191919", +"f. c #515153", +"g. c #7E7E85", +"h. c #979798", +"i. c #806A56", +"j. c #8E6E52", +"k. c #906C4D", +"l. c #8F6846", +"m. c #8E643E", +"n. c #524336", +"o. c #775F49", +"p. c #D8D5D3", +"q. c #939399", +"r. c #C3C3DF", +"s. c #BABAC8", +"t. c #EAEAEB", +"u. c #C9C9C9", +"v. c #C0C0C9", +"w. c #8B8B93", +"x. c #AEAEB2", +"y. c #CABBAE", +"z. c #A26938", +"A. c #B3AEAA", +"B. c #A0A0A9", +"C. c #9393B3", +"D. c #CECEFD", +"E. c #ACACC9", +"F. c #E5E5FF", +"G. c #7E7E81", +"H. c #1E1E1E", +"I. c #DADADA", +"J. c #DFDFE8", +"K. c #58585A", +"L. c #533C28", +"M. c #ED7000", +"N. c #FF7800", +"O. c #9E591D", +"P. c #D2CDC9", +"Q. c #7C7C85", +"R. c #D9D9F5", +"S. c #AEAEB4", +"T. c #FEFEFE", +"U. c #CECEE3", +"V. c #9393A4", +"W. c #9595AF", +"X. c #A4A4CF", +"Y. c #B6B6F3", +"Z. c #D3D3FF", +"`. c #DDDDFF", +" + c #EDEDFA", +".+ c #464646", +"++ c #2D2D2D", +"@+ c #E0E0E0", +"#+ c #C9C9CC", +"$+ c #A8A8B0", +"%+ c #9A9A9D", +"&+ c #755436", +"*+ c #FC7700", +"=+ c #BF620F", +"-+ c #B1A59B", +";+ c #F4F4F4", +">+ c #7B7B87", +",+ c #DCDCF7", +"'+ c #B0B0B2", +")+ c #FAFAFF", +"!+ c #DBDBFF", +"~+ c #D1D1FF", +"{+ c #BBBBF8", +"]+ c #A3A3CB", +"^+ c #8B8BA3", +"/+ c #9999AB", +"(+ c #BBBBCA", +"_+ c #C9C9D2", +":+ c #232323", +"<+ c #5D5D5D", +"[+ c #8B8B92", +"}+ c #5C5B5B", +"|+ c #663B14", +"1+ c #8F7C6B", +"2+ c #8F7D6C", +"3+ c #61544B", +"4+ c #4C4C55", +"5+ c #AEAEBE", +"6+ c #DBDBDC", +"7+ c #E3E3FF", +"8+ c #8686A4", +"9+ c #656578", +"0+ c #5C5B6C", +"a+ c #545367", +"b+ c #5B5A71", +"c+ c #59586F", +"d+ c #535265", +"e+ c #565565", +"f+ c #29282E", +"g+ c #A6A6A6", +"h+ c #B4B4BA", +"i+ c #85858C", +"j+ c #BABABA", +"k+ c #877A6E", +"l+ c #917760", +"m+ c #907258", +"n+ c #8F6E50", +"o+ c #8E6949", +"p+ c #614B38", +"q+ c #6F5B4A", +"r+ c #9F9083", +"s+ c #BDBDC0", +"t+ c #AAAABF", +"u+ c #B1B1BA", +"v+ c #F2F2F2", +"w+ c #BDBDCE", +"x+ c #696878", +"y+ c #5A5970", +"z+ c #1A1A1D", +"A+ c #363636", +"B+ c #EAEAEA", +"C+ c #FDFDFF", +"D+ c #F2F2FC", +"E+ c #6E5F53", +"F+ c #CC6306", +"G+ c #D86A08", +"H+ c #948476", +"I+ c #6F6F74", +"J+ c #D2D2ED", +"K+ c #B3B3B6", +"L+ c #DDDCDF", +"M+ c #5B5A6B", +"N+ c #56556A", +"O+ c #3A3946", +"P+ c #232329", +"Q+ c #1F1F24", +"R+ c #1E1E22", +"S+ c #19191D", +"T+ c #686868", +"U+ c #F6F6FA", +"V+ c #77777E", +"W+ c #6E6E72", +"X+ c #EA6E00", +"Y+ c #F07100", +"Z+ c #7E6652", +"`+ c #F9F9F9", +" @ c #A0A0A6", +".@ c #7A7A8B", +"+@ c #ABABCC", +"@@ c #D1D1E8", +"#@ c #CACACB", +"$@ c #7E7E86", +"%@ c #363542", +"&@ c #131315", +"*@ c #B8B8B8", +"=@ c #F8F8FF", +"-@ c #A2A2AC", +";@ c #4F4F51", +">@ c #5F3F22", +",@ c #7A5738", +"'@ c #E2E2E2", +")@ c #8E8E97", +"!@ c #787893", +"~@ c #8B8ABA", +"{@ c #797892", +"]@ c #6D6C7E", +"^@ c #6C6B7B", +"/@ c #747381", +"(@ c #76757E", +"_@ c #656571", +":@ c #454555", +"<@ c #3E3E3E", +"[@ c #F3F3F3", +"}@ c #C8C8D1", +"|@ c #A4A4AF", +"1@ c #908F90", +"2@ c #79787F", +"3@ c #86869C", +"4@ c #747489", +"5@ c #646376", +"6@ c #58576C", +"7@ c #58576D", +"8@ c #27262F", +"9@ c #757575", +"0@ c #FBFBFF", +"a@ c #F3F3FF", +"b@ c #C4C4D5", +"c@ c #A1A1B4", +"d@ c #626271", +"e@ c #545369", +"f@ c #57566C", +"g@ c #56556B", +"h@ c #31313C", +"i@ c #161618", +"j@ c #C8C8C8", +"k@ c #EFEFF5", +"l@ c #797883", +"m@ c #5A596C", +"n@ c #504F62", +"o@ c #31313D", +"p@ c #212127", +"q@ c #050507", +"r@ c #1C1C21", +"s@ c #2F2F3B", +"t@ c #1A1A1E", +"u@ c #454545", +"v@ c #EDEDED", +"w@ c #6D6D76", +"x@ c #353541", +"y@ c #0C0C0F", +"z@ c #2D2D32", +"A@ c #555469", +"B@ c #24242B", +"C@ c #302F3B", +"D@ c #1C1B20", +" ", +" ", +" ", +" ", +" ", +" ", +" . + @ # $ % & * = ", +" - ; > , ' ) ! ~ { ] ^ ", +" / ( _ : < [ } | 1 2 3 4 5 ", +" 6 7 8 9 0 a b c d e f g h i j ", +" k l m n o p q r s 2 t u v w x y z A B C ", +" D E F G H I J K L M N ] O P Q R S T U V W X ] Y ", +" Z ` ...+.@.U #.$.%.&.U *.B =.-.;.>.,.'.).!.~.s {.]. ", +" ^./.(._.:.U U <.[.}.|.1.2.U 3.4.5.6.7.8.9.0.a.b.c.h d.e. ", +" f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.A.B.C.D.E.F.B G. ", +"H.I.J.K.L.M.N.N.O.P.U U U Q.R.S.T.N ] U.V.W.X.Y., ) Z.`.O +.+ ", +"++@+#+$+%+&+*+=+-+U U U U ;+>+,+'+U )+B F.!+~+< [ {+]+^+/+(+_+:+", +" <+U )+[+}+|+1+U U U U U 2+3+4+5+6+U 3.h 7+0 8+9+0+a+b+c+d+e+f+", +" g+U h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+U 4 w+x+c+b+b+b+b+b+b+y+z+", +" A+B+C+D+4.E+F+N.N.G+H+U U U I+J+K+U L+M+b+b+N+O+P+Q+R+k S+ ", +" T+U U+V+W+i.X+Y+Z+U `+ @.@+@~ @@#@$@b+b+%@&@ ", +" *@U =@-@;@>@,@'@)@!@~@{@]@^@/@(@_@b+:@ ", +" <@[@q }@|@1@2@3@4@5@6@b+b+b+b+y+7@b+8@ ", +" 9@U 0@a@b@c@d@b+b+b+b+e@f@b+b+g@h@i@ ", +" j@U k@l@m@b+b+n@o@p@ q@r@s@t@ ", +" u@v@w@y+b+y+x@y@ ", +" z@f@b+A@B@ ", +" t@C@D@ ", +" ", +" ", +" ", +" "}; diff --git a/eeschema/block.cpp b/eeschema/block.cpp new file mode 100644 index 0000000000..50b2df4f20 --- /dev/null +++ b/eeschema/block.cpp @@ -0,0 +1,1593 @@ +/****************************************************/ +/* BLOCK.CPP */ +/* Gestion des Operations sur Blocks et Effacements */ +/****************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +/* Variables Locales */ + +/* Fonctions exportees */ + +/* Fonctions Locales */ +static EDA_BaseStruct * CopyStruct(WinEDA_DrawPanel * panel, wxDC * DC, BASE_SCREEN * screen, + EDA_BaseStruct *DrawStruct); +static void CollectStructsToDrag(SCH_SCREEN * screen); +static void AddPickedItem(SCH_SCREEN * screen, int px, int py ); +static LibEDA_BaseStruct * GetNextPinPosition( EDA_SchComponentStruct * DrawLibItem, + int * px, int * py ); +static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static EDA_BaseStruct * SaveStructListForPaste(EDA_BaseStruct *DrawStruct); +static bool MirrorStruct(WinEDA_DrawPanel * panel, wxDC * DC, EDA_BaseStruct *DrawStruct, wxPoint & Center); +static void MirrorOneStruct(EDA_BaseStruct *DrawStruct, wxPoint & Center); + +/*************************************************************************/ +int WinEDA_SchematicFrame::ReturnBlockCommand(int key) +/*************************************************************************/ +/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to + the key (ALT, SHIFT ALT ..) +*/ +{ +int cmd; + + switch ( key ) + { + default: + cmd = key & 0xFF; + break; + + case 0: + cmd = BLOCK_MOVE; + break; + + case GR_KB_ALT: + case GR_KB_SHIFT: + cmd = BLOCK_COPY; + break; + + case GR_KB_CTRL: + cmd = BLOCK_DRAG; + break; + + case GR_KB_SHIFTCTRL: + cmd = BLOCK_DELETE; + break; + + case MOUSE_MIDDLE: + cmd = BLOCK_ZOOM; + break; + } + return cmd; +} + +/*************************************************/ +void WinEDA_SchematicFrame::InitBlockPasteInfos() +/*************************************************/ +/* Init the parameters used by the block paste command +*/ +{ +DrawBlockStruct * block = & GetScreen()->BlockLocate; + + block->m_BlockDrawStruct = g_BlockSaveDataList; + DrawPanel->ManageCurseur = DrawMovingBlockOutlines; +} + + + +/******************************************************/ +void WinEDA_SchematicFrame::HandleBlockPlace(wxDC * DC) +/******************************************************/ +/* Routine to handle the BLOCK PLACE commande + Last routine for block operation for: + - block move & drag + - block copie & paste +*/ +{ +bool err = FALSE; +DrawBlockStruct * block = & GetScreen()->BlockLocate; +EDA_BaseStruct * NewStruct = NULL; + + if(DrawPanel->ManageCurseur == NULL) + { + err = TRUE; + DisplayError(this, wxT("HandleBlockPLace() : ManageCurseur = NULL") ); + } + + if(block->m_BlockDrawStruct == NULL) + { + wxString msg; + err = TRUE; + msg.Printf( wxT("HandleBlockPLace() : m_BlockDrawStruct = NULL (cmd %d, state %d)"), + block->m_Command, block->m_State); + DisplayError(this, msg ); + } + + block->m_State = STATE_BLOCK_STOP; + + switch(block->m_Command ) + { + case BLOCK_IDLE: + err = TRUE; + break; + case BLOCK_DRAG: /* Drag */ + case BLOCK_MOVE: /* Move */ + if ( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + + SaveCopyInUndoList(block->m_BlockDrawStruct, IS_CHANGED); + + MoveStruct(DrawPanel, DC, block->m_BlockDrawStruct); + block->m_BlockDrawStruct = NULL; + break; + + case BLOCK_COPY: /* Copy */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + if ( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + + NewStruct = CopyStruct(DrawPanel, DC, GetScreen(), block->m_BlockDrawStruct); + + SaveCopyInUndoList(NewStruct, + (block->m_Command == BLOCK_PRESELECT_MOVE) ? IS_CHANGED : IS_NEW); + + block->m_BlockDrawStruct = NULL; + break; + + case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */ + if ( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + PasteStruct(DC); + block->m_BlockDrawStruct = NULL; + break; + + case BLOCK_ZOOM: // Handled by HandleBlockEnd() + case BLOCK_DELETE: + case BLOCK_SAVE: + case BLOCK_ROTATE: + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: + case BLOCK_INVERT: + case BLOCK_ABORT: + case BLOCK_SELECT_ITEMS_ONLY: + break; + } + + GetScreen()->SetModify(); + + /* clear struct.m_Flags */ + EDA_BaseStruct * Struct; + for(Struct = GetScreen()->EEDrawList; Struct != NULL; Struct=Struct->Pnext) + Struct->m_Flags = 0; + + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + block->m_Flags = 0; + block->m_State = STATE_NO_BLOCK; + block->m_Command = BLOCK_IDLE; + GetScreen()->m_CurrentItem = NULL; + + TestDanglingEnds(GetScreen()->EEDrawList, DC); + + if ( block->m_BlockDrawStruct ) + { + DisplayError(this, wxT("HandleBlockPLace() error: DrawStruct != Null") ); + block->m_BlockDrawStruct = NULL; + } + + SetToolID(m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); +} + +/****************************************************/ +int WinEDA_SchematicFrame::HandleBlockEnd(wxDC * DC) +/****************************************************/ +/* Routine de gestion de la commande BLOCK END + retourne : + 0 si aucun composant selectionne + 1 sinon + -1 si commande terminée et composants trouvés (block delete, block save) +*/ +{ +int ii = 0; +bool zoom_command = FALSE; +DrawBlockStruct * block = & GetScreen()->BlockLocate; + + if ( block->m_BlockDrawStruct ) + { + BlockState state = block->m_State; + CmdBlockType command = block->m_Command; + if ( DrawPanel->ForceCloseManageCurseur ) + DrawPanel->ForceCloseManageCurseur(DrawPanel, DC); + block->m_State = state; + block->m_Command = command; + DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines; + DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand; + GetScreen()->m_Curseur.x = block->GetRight(); + GetScreen()->m_Curseur.y = block->GetBottom(); + if ( block->m_Command != BLOCK_ABORT ) + DrawPanel->MouseToCursorSchema(); + } + + if(DrawPanel->ManageCurseur != NULL) + switch( block->m_Command ) + { + case BLOCK_IDLE: + DisplayError(this, wxT("Error in HandleBlockPLace()") ); + break; + + case BLOCK_DRAG: /* Drag */ + BreakSegmentOnJunction(GetScreen() ); + case BLOCK_MOVE: /* Move */ + case BLOCK_COPY: /* Copy */ + block->m_BlockDrawStruct = + PickStruct(GetScreen()->BlockLocate, GetScreen()->EEDrawList, SEARCHALL); + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + if( block->m_BlockDrawStruct != NULL) + { + ii = 1; + CollectStructsToDrag(GetScreen()); + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + block->m_State = STATE_BLOCK_MOVE; + } + else + { + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + } + break; + + case BLOCK_DELETE: /* Delete */ + block->m_BlockDrawStruct = + PickStruct(GetScreen()->BlockLocate, + GetScreen()->EEDrawList, SEARCHALL); + DrawAndSizingBlockOutlines(DrawPanel, DC, FALSE); + if( block->m_BlockDrawStruct != NULL) + { + ii = -1; + DeleteStruct(DrawPanel, DC, block->m_BlockDrawStruct); + GetScreen()->SetModify(); + } + block->m_BlockDrawStruct = NULL; + TestDanglingEnds(GetScreen()->EEDrawList, DC); + break; + + case BLOCK_SAVE: /* Save */ + block->m_BlockDrawStruct = + PickStruct(GetScreen()->BlockLocate, + GetScreen()->EEDrawList, SEARCHALL); + DrawAndSizingBlockOutlines(DrawPanel, DC, FALSE); + if( block->m_BlockDrawStruct != NULL) + { + wxPoint oldpos = GetScreen()->m_Curseur; + GetScreen()->m_Curseur = wxPoint(0,0); + EDA_BaseStruct *DrawStructCopy = + SaveStructListForPaste(block->m_BlockDrawStruct); + PlaceStruct( GetScreen(), DrawStructCopy); + GetScreen()->m_Curseur = oldpos; + ii = -1; + } + block->m_BlockDrawStruct = NULL; + break; + + case BLOCK_PASTE: + block->m_State = STATE_BLOCK_MOVE; + break; + + case BLOCK_INVERT: /* pcbnew only! */ + break; + + case BLOCK_ROTATE: + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: + break; + + case BLOCK_ZOOM: /* Window Zoom */ + zoom_command = TRUE; + break; + + case BLOCK_SELECT_ITEMS_ONLY: /* Not used */ + case BLOCK_ABORT: /* not executed here */ + break; + } + + if ( block->m_Command == BLOCK_ABORT ) + { /* clear struct.m_Flags */ + EDA_BaseStruct * Struct; + for(Struct = GetScreen()->EEDrawList; Struct != NULL; Struct=Struct->Pnext) + Struct->m_Flags = 0; + } + + if ( ii <= 0 ) + { + block->m_Flags = 0; + block->m_State = STATE_NO_BLOCK; + block->m_Command = BLOCK_IDLE; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->m_CurrentItem = NULL; + SetToolID(m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); + } + + if ( zoom_command) + Window_Zoom( GetScreen()->BlockLocate); + + return(ii); +} + + +/***********************************************************************/ +void WinEDA_SchematicFrame::HandleBlockEndByPopUp(int Command, wxDC * DC) +/***********************************************************************/ +/* Routine de gestion de la commande BLOCK END by PopUp + Appelee apres HandleBlockEnd. + A partir de la commande bloc move, peut executer une commande autre que bloc move. +*/ +{ +int ii = 0; +DrawBlockStruct * block = & GetScreen()->BlockLocate; + + if( block->m_Command != BLOCK_MOVE ) return; + if( Command == BLOCK_MOVE ) return; + + block->m_Command = (CmdBlockType) Command; + block->SetMessageBlock(this); + + switch( block->m_Command ) + { + case BLOCK_COPY: /* move to copy */ + block->m_State = STATE_BLOCK_MOVE; + ii = 1; + break; + + case BLOCK_DRAG: /* move to Drag */ + /* Effacement de la liste des structures de pointage, + qui est devenue erronnee */ + if(DrawPanel->ManageCurseur) + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + if( block->m_BlockDrawStruct ) + { + if(block->m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { /* Delete the picked wrapper if this is a picked list. */ + DrawPickedStruct * PickedList; + PickedList = (DrawPickedStruct*)block->m_BlockDrawStruct; + PickedList->DeleteWrapperList(); + } + block->m_BlockDrawStruct = NULL; + } + BreakSegmentOnJunction(GetScreen() ); + block->m_BlockDrawStruct = + PickStruct(GetScreen()->BlockLocate, + GetScreen()->EEDrawList, SEARCHALL); + if( block->m_BlockDrawStruct != NULL) + { + ii = 1; + CollectStructsToDrag(GetScreen()); + if(DrawPanel->ManageCurseur) + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + block->m_State = STATE_BLOCK_MOVE; + } + break; + + case BLOCK_DELETE: /* move to Delete */ + if(DrawPanel->ManageCurseur) + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + if( block->m_BlockDrawStruct != NULL) + { + ii = -1; + DeleteStruct(DrawPanel, DC, block->m_BlockDrawStruct); + GetScreen()->SetModify(); + } + TestDanglingEnds(GetScreen()->EEDrawList, DC); + break; + + case BLOCK_SAVE: /* Save */ + if(DrawPanel->ManageCurseur) + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + if( block->m_BlockDrawStruct != NULL) + { + wxPoint oldpos = GetScreen()->m_Curseur; + GetScreen()->m_Curseur = wxPoint(0,0); + EDA_BaseStruct *DrawStructCopy = + SaveStructListForPaste(block->m_BlockDrawStruct); + PlaceStruct( GetScreen(), DrawStructCopy); + GetScreen()->m_Curseur = oldpos; + ii = -1; + } + break; + + case BLOCK_ZOOM: /* Window Zoom */ + DrawPanel->ForceCloseManageCurseur(DrawPanel, DC); + DrawPanel->SetCursor(DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor); + Window_Zoom( GetScreen()->BlockLocate); + break; + + + case BLOCK_ROTATE: + break; + + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: + if(DrawPanel->ManageCurseur) + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + if( block->m_BlockDrawStruct != NULL) + { + SaveCopyInUndoList(block->m_BlockDrawStruct, IS_CHANGED); + + ii = -1; + /* Compute the mirror centre and put it on grid */ + wxPoint Center = block->Centre(); + PutOnGrid(&Center); + MirrorStruct(DrawPanel, DC, block->m_BlockDrawStruct, Center); + GetScreen()->SetModify(); + } + TestDanglingEnds(GetScreen()->EEDrawList, DC); + break; + + default: + break; + } + + if ( ii <= 0 ) + { + block->m_BlockDrawStruct = NULL; + block->m_Flags = 0; + block->m_State = STATE_NO_BLOCK; + block->m_Command = BLOCK_IDLE; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->m_CurrentItem = NULL; + SetToolID(m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); + } + +} + + +/************************************************************************/ +static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, + bool erase ) +/************************************************************************/ +/* Retrace le contour du block de recherche de structures + L'ensemble du block suit le curseur +*/ +{ +DrawBlockStruct * PtBlock; +DrawPickedStruct *PickedList; +BASE_SCREEN * screen = panel->m_Parent->GetScreen(); + + PtBlock = &panel->GetScreen()->BlockLocate; + GRSetDrawMode(DC, g_XorMode); + + /* Effacement ancien cadre */ + if( erase && PtBlock->m_BlockDrawStruct) + { + PtBlock->Offset(PtBlock->m_MoveVector); + PtBlock->Draw(panel, DC); + PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y); + + /* Effacement ancien affichage */ + if(PtBlock->m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + PickedList = (DrawPickedStruct *) PtBlock->m_BlockDrawStruct; + while (PickedList) + { + DrawStructsInGhost(panel, DC, PickedList->m_PickedStruct, PtBlock->m_MoveVector.x, PtBlock->m_MoveVector.y); + PickedList = (DrawPickedStruct *)PickedList->Pnext; + } + } + else DrawStructsInGhost(panel, DC, PtBlock->m_BlockDrawStruct, PtBlock->m_MoveVector.x, PtBlock->m_MoveVector.y); + } + + /* Redessin nouvel affichage */ + + PtBlock->m_MoveVector.x = screen->m_Curseur.x - PtBlock->m_BlockLastCursorPosition.x; + PtBlock->m_MoveVector.y = screen->m_Curseur.y - PtBlock->m_BlockLastCursorPosition.y; + + GRSetDrawMode(DC, g_XorMode); + PtBlock->Offset(PtBlock->m_MoveVector); + PtBlock->Draw(panel, DC); + PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y); + + if(PtBlock->m_BlockDrawStruct ) + { + if(PtBlock->m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + PickedList = (DrawPickedStruct *) PtBlock->m_BlockDrawStruct; + while (PickedList) + { + DrawStructsInGhost(panel, DC, PickedList->m_PickedStruct, PtBlock->m_MoveVector.x, PtBlock->m_MoveVector.y); + PickedList = (DrawPickedStruct *)PickedList->Pnext; + } + } + else DrawStructsInGhost(panel, DC, PtBlock->m_BlockDrawStruct, PtBlock->m_MoveVector.x, PtBlock->m_MoveVector.y); + } +} + + +/***************************************************************************** +* Routine to move an object(s) to a new position. * +* If DrawStruct is of type DrawPickedStruct, a list of objects picked is * +* assumed, otherwise exactly one structure is assumed been picked. * +*****************************************************************************/ +bool MoveStruct(WinEDA_DrawPanel * panel, wxDC * DC, EDA_BaseStruct *DrawStruct) +{ +DrawPickedStruct *PickedList = NULL; + + if ( !DrawStruct ) return FALSE; + + if(DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + if ( DC ) + RedrawStructList(panel, DC, DrawStruct, g_XorMode); + PlaceStruct(panel->GetScreen(), DrawStruct); /* Place it in its new position. */ + if ( DC ) + RedrawStructList(panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE); + + /* Free the wrapper DrawPickedStruct chain: */ + PickedList = (DrawPickedStruct *) DrawStruct; + PickedList->DeleteWrapperList(); + } + + else + { + if ( DC ) + RedrawOneStruct(panel, DC, DrawStruct, g_XorMode); + PlaceStruct(panel->GetScreen(), DrawStruct); /* Place it in its new position. */ + if ( DC ) + RedrawOneStruct(panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE); + } + return TRUE; +} + + +static void MirrorYPoint(wxPoint & point, wxPoint & Center) +{ + point.x -= Center.x; + point.x = - point.x; + point.x += Center.x; +} + +/**************************************************************/ +void MirrorOneStruct(EDA_BaseStruct *DrawStruct, wxPoint & Center) +/**************************************************************/ +/* Given a structure rotate it to 90 degrees refer to the Center point. +*/ +{ +int dx, ii, *Points; +DrawPolylineStruct *DrawPoly; +DrawJunctionStruct *DrawConnect; +EDA_DrawLineStruct *DrawSegment; +DrawBusEntryStruct *DrawRaccord; +EDA_SchComponentStruct *DrawLibItem; +DrawSheetStruct *DrawSheet; +DrawSheetLabelStruct *DrawSheetLabel; +DrawMarkerStruct * DrawMarker; +DrawNoConnectStruct * DrawNoConnect; +DrawTextStruct * DrawText; +wxPoint px; + + if ( !DrawStruct ) return; + + switch (DrawStruct->m_StructType) + { + case TYPE_NOT_INIT: + break; + + case DRAW_POLYLINE_STRUCT_TYPE: + DrawPoly = (DrawPolylineStruct *) DrawStruct; + Points = DrawPoly->m_Points; + for (ii = 0; ii < DrawPoly->m_NumOfPoints; ii++) + { + wxPoint point; + point.x = Points[ii * 2]; point.y = Points[ii * 2 + 1]; + MirrorYPoint(point, Center); + Points[ii * 2] = point.x; Points[ii * 2 + 1] = point.y; + } + break; + + case DRAW_SEGMENT_STRUCT_TYPE: + DrawSegment = (EDA_DrawLineStruct *) DrawStruct; + if( (DrawSegment->m_Flags & STARTPOINT) == 0 ) + { + MirrorYPoint(DrawSegment->m_Start, Center); + } + if( (DrawSegment->m_Flags & ENDPOINT) == 0 ) + { + MirrorYPoint(DrawSegment->m_End, Center); + } + break; + + case DRAW_BUSENTRY_STRUCT_TYPE: + DrawRaccord = (DrawBusEntryStruct *) DrawStruct; + MirrorYPoint(DrawRaccord->m_Pos, Center); + break; + + case DRAW_JUNCTION_STRUCT_TYPE: + DrawConnect = (DrawJunctionStruct *) DrawStruct; + MirrorYPoint(DrawConnect->m_Pos, Center); + break; + + case DRAW_MARKER_STRUCT_TYPE: + DrawMarker = (DrawMarkerStruct *) DrawStruct; + MirrorYPoint(DrawMarker->m_Pos, Center); + break; + + case DRAW_NOCONNECT_STRUCT_TYPE: + DrawNoConnect = (DrawNoConnectStruct *) DrawStruct; + MirrorYPoint(DrawNoConnect->m_Pos, Center); + break; + + case DRAW_TEXT_STRUCT_TYPE: + case DRAW_LABEL_STRUCT_TYPE: + // Text is not really mirrored; it is moved to a suitable position + // which is the closest position for a true mirrored text + // The center position is mirrored and the text is moved for half horizontal len + DrawText = (DrawTextStruct *) DrawStruct; + px = DrawText->m_Pos; + if( DrawText->m_Orient == 0 ) /* horizontal text */ + dx = DrawText->Len_Size() / 2; + else if( DrawText->m_Orient == 2 ) /* invert horizontal text*/ + dx = - DrawText->Len_Size() / 2; + else dx = 0; + px.x += dx; + MirrorYPoint(px, Center); + px.x -= dx; + + EDA_Appl->SchematicFrame->PutOnGrid(&px); + DrawText->m_Pos.x = px.x; + break; + + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + // Text is not really mirrored: Orientation is changed + DrawText = (DrawGlobalLabelStruct *) DrawStruct; + if( DrawText->m_Orient == 0 ) /* horizontal text */ + DrawText->m_Orient = 2; + else if( DrawText->m_Orient == 2 ) /* invert horizontal text*/ + DrawText->m_Orient = 0; + + px = DrawText->m_Pos; + MirrorYPoint(px, Center); + EDA_Appl->SchematicFrame->PutOnGrid(&px); + DrawText->m_Pos.x = px.x; + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE: + DrawLibItem = (EDA_SchComponentStruct *) DrawStruct; + dx = DrawLibItem->m_Pos.x; + EDA_Appl->SchematicFrame->CmpRotationMiroir( DrawLibItem, + NULL, CMP_MIROIR_Y ); + MirrorYPoint(DrawLibItem->m_Pos, Center); + dx -= DrawLibItem->m_Pos.x; + for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) + { /* move the fields to the new position because the component itself has moved */ + DrawLibItem->m_Field[ii].m_Pos.x -= dx; + } + break; + + case DRAW_SHEET_STRUCT_TYPE: + DrawSheet = (DrawSheetStruct *) DrawStruct; + MirrorYPoint(DrawSheet->m_Pos, Center); + DrawSheet->m_Pos.x -= DrawSheet->m_Size.x; + + DrawSheetLabel = DrawSheet->m_Label; + while( DrawSheetLabel != NULL ) + { + MirrorYPoint(DrawSheetLabel->m_Pos, Center); + DrawSheetLabel->m_Edge = DrawSheetLabel->m_Edge ? 0 : 1; + DrawSheetLabel = (DrawSheetLabelStruct*)DrawSheetLabel->Pnext; + } + break; + + case DRAW_SHEETLABEL_STRUCT_TYPE: + DrawSheetLabel = (DrawSheetLabelStruct *) DrawStruct; + MirrorYPoint(DrawSheetLabel->m_Pos, Center); + break; + + case DRAW_PICK_ITEM_STRUCT_TYPE : break; + + default: break; + } +} + + + +/***************************************************************************** +* Routine to Mirror an object(s). * +* If DrawStruct is of type DrawPickedStruct, a list of objects picked is * +* assumed, otherwise exactly one structure is assumed been picked. * +*****************************************************************************/ +bool MirrorStruct(WinEDA_DrawPanel * panel, wxDC * DC, EDA_BaseStruct *DrawStruct, wxPoint & Center) +{ +DrawPickedStruct *PickedList = NULL; +DrawPickedStruct *DrawStructs; + if ( !DrawStruct ) return FALSE; + + if(DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + if ( DC ) + RedrawStructList(panel, DC, DrawStruct, g_XorMode); + DrawStructs = (DrawPickedStruct *) DrawStruct; + while (DrawStructs) + { + MirrorOneStruct(DrawStructs->m_PickedStruct, Center); + DrawStructs->m_PickedStruct->m_Flags = 0; + DrawStructs = (DrawPickedStruct *)DrawStructs->Pnext; + } + if ( DC ) + RedrawStructList(panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE); + + /* Free the wrapper DrawPickedStruct chain: */ + PickedList = (DrawPickedStruct *) DrawStruct; + PickedList->DeleteWrapperList(); + } + + else + { + if ( DC ) + RedrawOneStruct(panel, DC, DrawStruct, g_XorMode); + MirrorOneStruct(DrawStruct, Center); /* Place it in its new position. */ + if ( DC ) + RedrawOneStruct(panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE); + DrawStruct->m_Flags = 0; + } + + + return TRUE; +} + + +/*****************************************************************************/ +static EDA_BaseStruct * CopyStruct(WinEDA_DrawPanel * panel, wxDC * DC, BASE_SCREEN * screen, + EDA_BaseStruct *DrawStruct) +/*****************************************************************************/ +/* Routine to copy a new entity of an object and reposition it. +If DrawStruct is of type DrawPickedStruct, a list of objects picked is +assumed, otherwise exactly one structure is assumed been picked. +Return the new created struct +*/ +{ +EDA_BaseStruct *NewDrawStruct; +DrawPickedStruct *PickedList = NULL; + + if ( !DrawStruct ) return FALSE; + + NewDrawStruct = DuplicateStruct(DrawStruct); + if ( NewDrawStruct == NULL ) return NULL; + + PlaceStruct( screen, NewDrawStruct); + /* Draw the new structure and chain it in: */ + if (NewDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + PickedList = (DrawPickedStruct *) NewDrawStruct; + while (PickedList) // Clear annotation for new components + { + EDA_BaseStruct * Struct = PickedList->m_PickedStruct; + switch ( Struct->m_StructType ) + { + case DRAW_LIB_ITEM_STRUCT_TYPE: + { + ((EDA_SchComponentStruct*)Struct)->m_TimeStamp = GetTimeStamp(); + ((EDA_SchComponentStruct*)Struct)->ClearAnnotation(); + } + break; + case DRAW_SHEET_STRUCT_TYPE: + { + DrawSheetStruct * sheet = (DrawSheetStruct*)Struct; + sheet->m_TimeStamp = GetTimeStamp(); + sheet->m_UndoList = NULL; + sheet->m_RedoList = NULL; + sheet->EEDrawList = NULL; + sheet->m_Son = NULL; + sheet->m_SheetName.Printf(wxT("%8.8lX"), sheet->m_TimeStamp); + sheet->m_FileName = sheet->m_SheetName + wxT(".sch"); + break; + } + } + SetStructFather(Struct, screen); + PickedList = (DrawPickedStruct *)PickedList->Pnext; + } + RedrawStructList(panel, DC, NewDrawStruct, GR_DEFAULT_DRAWMODE); + /* Chain the new items */ + PickedList = (DrawPickedStruct *) NewDrawStruct; + while (PickedList) + { + PickedList->m_PickedStruct->Pnext = screen->EEDrawList; + screen->EEDrawList = PickedList->m_PickedStruct; + PickedList = PickedList->Next(); + } + } + + else + { + switch(NewDrawStruct->m_StructType) + { + case DRAW_POLYLINE_STRUCT_TYPE: + case DRAW_JUNCTION_STRUCT_TYPE: + case DRAW_SEGMENT_STRUCT_TYPE: + case DRAW_BUSENTRY_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_SHEETLABEL_STRUCT_TYPE: + case DRAW_PICK_ITEM_STRUCT_TYPE: + case DRAW_MARKER_STRUCT_TYPE: + case DRAW_NOCONNECT_STRUCT_TYPE: + default: + break; + + case DRAW_SHEET_STRUCT_TYPE: + { + DrawSheetStruct * sheet = (DrawSheetStruct*)NewDrawStruct; + sheet->m_TimeStamp = GetTimeStamp(); + sheet->m_UndoList = NULL; + sheet->m_RedoList = NULL; + sheet->EEDrawList = NULL; + sheet->m_Son = NULL; + sheet->m_SheetName.Printf(wxT("%8.8lX"), sheet->m_TimeStamp); + sheet->m_FileName = sheet->m_SheetName + wxT(".sch"); + break; + } + + case DRAW_LIB_ITEM_STRUCT_TYPE: + ((EDA_SchComponentStruct*)NewDrawStruct)->m_TimeStamp = GetTimeStamp(); + ((EDA_SchComponentStruct*)NewDrawStruct)->ClearAnnotation(); + break; + + } + + RedrawOneStruct(panel, DC, NewDrawStruct, GR_DEFAULT_DRAWMODE); + + SetStructFather(NewDrawStruct, screen); + NewDrawStruct->Pnext = screen->EEDrawList; + screen->EEDrawList = NewDrawStruct; + } + + /* Free the original DrawPickedStruct chain: */ + if (DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + PickedList = (DrawPickedStruct *) DrawStruct; + PickedList->DeleteWrapperList(); + } + + return NewDrawStruct; +} + +/*********************************************************************************/ +void DeleteStruct(WinEDA_DrawPanel * panel, wxDC * DC, EDA_BaseStruct *DrawStruct) +/*********************************************************************************/ +/* Routine to delete an object from global drawing object list. + Object is put in Undo list +*/ +{ +SCH_SCREEN * screen = (SCH_SCREEN *)panel->GetScreen(); +DrawPickedStruct *PickedList = NULL; +WinEDA_SchematicFrame * frame = (WinEDA_SchematicFrame *) panel->m_Parent; + + if ( !DrawStruct ) return; + + + if (DrawStruct->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE) + { /* Cette stucture est rattachee a une feuille, et n'est pas + accessible par la liste globale directement */ + frame->SaveCopyInUndoList(((DrawSheetLabelStruct*) DrawStruct)->m_Parent, IS_CHANGED); + frame->DeleteSheetLabel(DC, (DrawSheetLabelStruct*) DrawStruct); + return; + } + + if (DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + /* Unlink all picked structs from current EEDrawList */ + PickedList = (DrawPickedStruct *) DrawStruct; + while (PickedList) + { + screen->RemoveFromDrawList(PickedList->m_PickedStruct); + PickedList->m_PickedStruct->Pnext = + PickedList->m_PickedStruct->Pback = NULL; + PickedList->m_PickedStruct->m_Flags = IS_DELETED; + PickedList = PickedList->Next(); + } + RedrawStructList(panel, DC, DrawStruct, g_XorMode); + + /* Removed items are put to the Undo list */ + frame->SaveCopyInUndoList(DrawStruct, IS_DELETED); + } + + else /* structure classique */ + { + screen->RemoveFromDrawList(DrawStruct); + + RedrawOneStruct(panel, DC, DrawStruct, g_XorMode); + /* Unlink the structure */ + DrawStruct->Pnext = DrawStruct->Pback = NULL; // Only one struct -> no link + frame->SaveCopyInUndoList(DrawStruct, IS_DELETED); + } +} + +/*****************************************************************/ +EDA_BaseStruct * SaveStructListForPaste(EDA_BaseStruct *DrawStruct) +/*****************************************************************/ + +/* Routine to Save an object from global drawing object list. + This routine is the same as delete but: + - the original list is NOT removed. + - List is saved in g_BlockSaveDataList +*/ +{ +DrawPickedStruct *PickedList; +EDA_BaseStruct *DrawStructCopy; + + if ( !DrawStruct ) return NULL; + + /* Make a copy of the original picked item. */ + DrawStructCopy = DuplicateStruct(DrawStruct); + + if (DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + /* Delete the picked wrapper if this is a picked list. */ + PickedList = (DrawPickedStruct *) DrawStruct; + PickedList->DeleteWrapperList(); + } + + /* And delete old list and save the new list: */ + if (g_BlockSaveDataList ) /* Delete last deleted item or item list */ + { + EDA_BaseStruct * item = g_BlockSaveDataList, * next_item; + while (item) + { + next_item = item->Pnext; + delete item; + item = next_item; + } + } + + g_BlockSaveDataList = DrawStructCopy; + DrawStructCopy->m_Parent = NULL; + + return DrawStructCopy; +} + + +/***************************************************************************** +* Routine to paste a structure from the g_BlockSaveDataList stack. * +* This routine is the same as undelete but original list is NOT removed. * +*****************************************************************************/ +void WinEDA_SchematicFrame::PasteStruct(wxDC * DC) +{ +EDA_BaseStruct *DrawStruct; +DrawPickedStruct *PickedList = NULL; + + if (g_BlockSaveDataList == NULL) + { + DisplayError(this, wxT("No struct to paste") ); + return; + } + + DrawStruct = DuplicateStruct(g_BlockSaveDataList); + + PlaceStruct( GetScreen(), DrawStruct); + + RedrawStructList(DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE); + + // Clear annotation and init new time stamp for the new components: + if (DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + for(PickedList = (DrawPickedStruct *) DrawStruct; PickedList != NULL; ) // Clear annotation for new components + { + EDA_BaseStruct * Struct = PickedList->m_PickedStruct; + if ( Struct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE ) + { + ((EDA_SchComponentStruct*)Struct)->m_TimeStamp = GetTimeStamp(); + ((EDA_SchComponentStruct*)Struct)->ClearAnnotation(); + SetStructFather(Struct, GetScreen()); + } + PickedList = (DrawPickedStruct *)PickedList->Pnext; + } + RedrawStructList(DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE); + for(PickedList = (DrawPickedStruct *) DrawStruct; PickedList != NULL; ) + { + EDA_BaseStruct * Struct = PickedList->m_PickedStruct; + Struct->Pnext = GetScreen()->EEDrawList; + SetStructFather(Struct, GetScreen()); + GetScreen()->EEDrawList = Struct; + PickedList = (DrawPickedStruct *)PickedList->Pnext; + } + /* Save wrapper list in undo stack */ + SaveCopyInUndoList(DrawStruct, IS_NEW); + } + else + { + if ( DrawStruct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE ) + { + ((EDA_SchComponentStruct*)DrawStruct)->m_TimeStamp = GetTimeStamp(); + ((EDA_SchComponentStruct*)DrawStruct)->ClearAnnotation(); + } + SetStructFather(DrawStruct, GetScreen()); + RedrawOneStruct(DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE); + DrawStruct->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = DrawStruct; + SaveCopyInUndoList(DrawStruct, IS_NEW); + } + + /* clear .m_Flags member for all items */ + EDA_BaseStruct * Struct; + for(Struct = GetScreen()->EEDrawList; Struct != NULL; Struct=Struct->Pnext) + Struct->m_Flags = 0; + GetScreen()->SetModify(); + + return; +} + + +/***************************************************************************** +* Routine to place a given object. * +*****************************************************************************/ +bool PlaceStruct( BASE_SCREEN * screen, EDA_BaseStruct *DrawStruct) +{ +DrawPickedStruct * DrawStructs; +wxPoint move_vector; + + if ( !DrawStruct ) return FALSE; + + move_vector.x = screen->m_Curseur.x - + screen->BlockLocate.m_BlockLastCursorPosition.x; + move_vector.y = screen->m_Curseur.y - + screen->BlockLocate.m_BlockLastCursorPosition.y; + + switch (DrawStruct->m_StructType) + { + default: + case TYPE_NOT_INIT: + return FALSE; + + case DRAW_POLYLINE_STRUCT_TYPE: + case DRAW_JUNCTION_STRUCT_TYPE: + case DRAW_SEGMENT_STRUCT_TYPE: + case DRAW_BUSENTRY_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_LIB_ITEM_STRUCT_TYPE: + case DRAW_SHEET_STRUCT_TYPE: + case DRAW_SHEETLABEL_STRUCT_TYPE: + case DRAW_MARKER_STRUCT_TYPE: + case DRAW_NOCONNECT_STRUCT_TYPE: + MoveOneStruct(DrawStruct, move_vector); + break; + + case DRAW_PICK_ITEM_STRUCT_TYPE: + DrawStructs = (DrawPickedStruct *) DrawStruct; + while (DrawStructs) + { + MoveOneStruct(DrawStructs->m_PickedStruct, move_vector); + DrawStructs = (DrawPickedStruct *)DrawStructs->Pnext; + } + break; + } + return TRUE; +} + +/**************************************************************************/ +void MoveOneStruct(EDA_BaseStruct *DrawStruct, const wxPoint & move_vector) +/*************************************************************************/ +/* Given a structure move it by Dx, Dy. +*/ +{ +int ii, *Points; +DrawPolylineStruct *DrawPoly; +DrawJunctionStruct *DrawConnect; +EDA_DrawLineStruct *DrawSegment; +DrawBusEntryStruct *DrawRaccord; +EDA_SchComponentStruct *DrawLibItem; +DrawSheetStruct *DrawSheet; +DrawSheetLabelStruct *DrawSheetLabel; +DrawMarkerStruct * DrawMarker; +DrawNoConnectStruct * DrawNoConnect; + + if ( !DrawStruct ) return; + + switch (DrawStruct->m_StructType) + { + case TYPE_NOT_INIT: + break; + + case DRAW_POLYLINE_STRUCT_TYPE: + DrawPoly = (DrawPolylineStruct *) DrawStruct; + Points = DrawPoly->m_Points; + for (ii = 0; ii < DrawPoly->m_NumOfPoints; ii++) + { + Points[ii * 2] += move_vector.x; + Points[ii * 2 + 1] += move_vector.y; + } + break; + + case DRAW_SEGMENT_STRUCT_TYPE: + DrawSegment = (EDA_DrawLineStruct *) DrawStruct; + if( (DrawSegment->m_Flags & STARTPOINT) == 0 ) + { + DrawSegment->m_Start += move_vector; + } + if( (DrawSegment->m_Flags & ENDPOINT) == 0 ) + { + DrawSegment->m_End += move_vector; + } + break; + + case DRAW_BUSENTRY_STRUCT_TYPE: + DrawRaccord = (DrawBusEntryStruct *) DrawStruct; + DrawRaccord->m_Pos += move_vector; + break; + + case DRAW_JUNCTION_STRUCT_TYPE: + DrawConnect = (DrawJunctionStruct *) DrawStruct; + DrawConnect->m_Pos += move_vector; + break; + + case DRAW_MARKER_STRUCT_TYPE: + DrawMarker = (DrawMarkerStruct *) DrawStruct; + DrawMarker->m_Pos += move_vector; + break; + + case DRAW_NOCONNECT_STRUCT_TYPE: + DrawNoConnect = (DrawNoConnectStruct *) DrawStruct; + DrawNoConnect->m_Pos += move_vector; + break; + + case DRAW_TEXT_STRUCT_TYPE: + #define DrawText ((DrawTextStruct *) DrawStruct) + DrawText->m_Pos += move_vector; + break; + + case DRAW_LABEL_STRUCT_TYPE: + #define DrawLabel ((DrawLabelStruct *) DrawStruct) + DrawLabel->m_Pos += move_vector; + break; + + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + #define DrawGlobalLabel ((DrawGlobalLabelStruct *) DrawStruct) + DrawGlobalLabel->m_Pos += move_vector; + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE: + DrawLibItem = (EDA_SchComponentStruct *) DrawStruct; + DrawLibItem->m_Pos += move_vector; + for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) + { + DrawLibItem->m_Field[ii].m_Pos += move_vector; + } + break; + + case DRAW_SHEET_STRUCT_TYPE: + DrawSheet = (DrawSheetStruct *) DrawStruct; + DrawSheet->m_Pos += move_vector; + DrawSheetLabel = DrawSheet->m_Label; + while( DrawSheetLabel != NULL ) + { + DrawSheetLabel->m_Pos += move_vector; + DrawSheetLabel = DrawSheetLabel->Next(); + } + break; + + case DRAW_SHEETLABEL_STRUCT_TYPE: + DrawSheetLabel = (DrawSheetLabelStruct *) DrawStruct; + DrawSheetLabel->m_Pos += move_vector; + break; + + case DRAW_PICK_ITEM_STRUCT_TYPE : break; + + default: break; + } +} + + +/************************************************************/ +EDA_BaseStruct * DuplicateStruct(EDA_BaseStruct *DrawStruct) +/************************************************************/ +/* Routine to create a new copy of given struct. + The new object is not put in draw list (not linked) +*/ +{ +EDA_BaseStruct *NewDrawStruct = NULL; + + if ( DrawStruct == NULL ) + { + DisplayError(NULL, wxT("DuplicateStruct error: NULL struct") ); + return NULL; + } + + switch (DrawStruct->m_StructType) + { + case DRAW_POLYLINE_STRUCT_TYPE: + NewDrawStruct = ((DrawPolylineStruct*)DrawStruct)->GenCopy(); + break; + case DRAW_SEGMENT_STRUCT_TYPE: + NewDrawStruct = ((EDA_DrawLineStruct*)DrawStruct)->GenCopy(); + break; + case DRAW_BUSENTRY_STRUCT_TYPE: + NewDrawStruct = ((DrawBusEntryStruct*)DrawStruct)->GenCopy(); + break; + case DRAW_JUNCTION_STRUCT_TYPE: + NewDrawStruct = ((DrawJunctionStruct*)DrawStruct)->GenCopy(); + break; + case DRAW_MARKER_STRUCT_TYPE: + NewDrawStruct = ((DrawMarkerStruct*)DrawStruct)->GenCopy(); + break; + case DRAW_NOCONNECT_STRUCT_TYPE: + NewDrawStruct = ((DrawNoConnectStruct*)DrawStruct)->GenCopy(); + break; + case DRAW_TEXT_STRUCT_TYPE: + NewDrawStruct = ((DrawTextStruct*)DrawStruct)->GenCopy(); + break; + case DRAW_LABEL_STRUCT_TYPE: + NewDrawStruct = ((DrawLabelStruct*)DrawStruct)->GenCopy(); + break; + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + NewDrawStruct = ((DrawGlobalLabelStruct*)DrawStruct)->GenCopy(); + break; + case DRAW_LIB_ITEM_STRUCT_TYPE: + NewDrawStruct = ((EDA_SchComponentStruct*)DrawStruct)->GenCopy(); + break; + case DRAW_SHEET_STRUCT_TYPE: + NewDrawStruct = ((DrawSheetStruct*)DrawStruct)->GenCopy(); + break; + + case DRAW_PICK_ITEM_STRUCT_TYPE: + { + DrawPickedStruct *NewPickedItem, *PickedList = NULL, + *LastPickedItem = NULL; + PickedList = (DrawPickedStruct *) DrawStruct; + while (PickedList) + { + NewPickedItem = new DrawPickedStruct(); + if (NewDrawStruct == NULL) NewDrawStruct = NewPickedItem; + if (LastPickedItem ) LastPickedItem->Pnext = NewPickedItem; + LastPickedItem = NewPickedItem; + NewPickedItem->m_PickedStruct = + DuplicateStruct(PickedList->m_PickedStruct); + PickedList = (DrawPickedStruct *)PickedList->Pnext; + } + break; + } + + case DRAW_SHEETLABEL_STRUCT_TYPE: + case DRAW_PART_TEXT_STRUCT_TYPE: + case SCREEN_STRUCT_TYPE: + default: + { + wxString msg; + msg << wxT("DuplicateStruct error: unexpected StructType ") << + DrawStruct->m_StructType << wxT(" ") << DrawStruct->ReturnClassName(); + DisplayError(NULL, msg); + } + break; + } + + NewDrawStruct->m_Image = DrawStruct; + return NewDrawStruct; +} + + +/****************************************************/ +static void CollectStructsToDrag(SCH_SCREEN * screen) +/****************************************************/ +{ +DrawPickedStruct * DrawStructs, *FirstPicked; +EDA_BaseStruct * Struct; +EDA_DrawLineStruct* SegmStruct; +int ox, oy, fx, fy; + + /* Set membre .m_Flags des segments */ + for(Struct = screen->EEDrawList; Struct != NULL; Struct=Struct->Pnext) + Struct->m_Flags = 0; + + if(screen->BlockLocate.m_BlockDrawStruct->m_StructType == DRAW_SEGMENT_STRUCT_TYPE ) + screen->BlockLocate.m_BlockDrawStruct->m_Flags = SELECTED; + + else if (screen->BlockLocate.m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE ) + { + DrawStructs = (DrawPickedStruct *) screen->BlockLocate.m_BlockDrawStruct; + while (DrawStructs) + { + Struct = DrawStructs->m_PickedStruct; + DrawStructs = (DrawPickedStruct *)DrawStructs->Pnext; + Struct->m_Flags = SELECTED; + } + } + + if( screen->BlockLocate.m_Command != BLOCK_DRAG ) return; + + ox = screen->BlockLocate.GetX(); + oy = screen->BlockLocate.GetY(); + fx = screen->BlockLocate.GetRight(); + fy = screen->BlockLocate.GetBottom(); + + if (fx < ox) EXCHG(fx, ox); + if (fy < oy) EXCHG(fy, oy); + + /* Pour Drag Block: remise sous forme de liste de structure, s'il n'y + a qu'un seul element ( pour homogeneiser les traitements ulterieurs */ + if(screen->BlockLocate.m_BlockDrawStruct->m_StructType != DRAW_PICK_ITEM_STRUCT_TYPE ) + { + DrawStructs = new DrawPickedStruct(screen->BlockLocate.m_BlockDrawStruct); + screen->BlockLocate.m_BlockDrawStruct = DrawStructs; + } + + /* Suppression du deplacement des extremites de segments hors cadre + de selection */ + DrawStructs = (DrawPickedStruct *) screen->BlockLocate.m_BlockDrawStruct; + while (DrawStructs) + { + Struct = DrawStructs->m_PickedStruct; + DrawStructs = (DrawPickedStruct *)DrawStructs->Pnext; + if( Struct->m_StructType == DRAW_SEGMENT_STRUCT_TYPE) + { + SegmStruct = (EDA_DrawLineStruct*)Struct; + if( (SegmStruct->m_Start.x < ox) || (SegmStruct->m_Start.x > fx) || + (SegmStruct->m_Start.y < oy) || (SegmStruct->m_Start.y > fy) ) + SegmStruct->m_Flags |= STARTPOINT; + + if( (SegmStruct->m_End.x < ox) || (SegmStruct->m_End.x > fx) || + (SegmStruct->m_End.y < oy) || (SegmStruct->m_End.y > fy) ) + SegmStruct->m_Flags |= ENDPOINT; + } + } + + /* Recherche des elements complementaires a "dragger", c'est a dire les + fils et connexions hors bloc relies a des pins ou entries elles meme + draggees */ + + FirstPicked = DrawStructs = (DrawPickedStruct*)screen->BlockLocate.m_BlockDrawStruct; + while (DrawStructs) + { + Struct = DrawStructs->m_PickedStruct; + DrawStructs = (DrawPickedStruct * )DrawStructs->Pnext; + if( Struct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE) + { + LibEDA_BaseStruct *DrawItem; + int x, y; + DrawItem = GetNextPinPosition( (EDA_SchComponentStruct*)Struct, &x, &y); + while ( DrawItem ) + { + if( (x < ox) || (x > fx) || (y < oy) || (y > fy) ) + AddPickedItem(screen, x, y); + + DrawItem = GetNextPinPosition( NULL, &x, &y); + } + } + + if( Struct->m_StructType == DRAW_SHEET_STRUCT_TYPE) + { + DrawSheetLabelStruct * SLabel = ((DrawSheetStruct*)Struct)->m_Label; + while(SLabel) + { + if( SLabel->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE ) + AddPickedItem(screen, SLabel->m_Pos.x, SLabel->m_Pos.y); + SLabel = (DrawSheetLabelStruct*)SLabel->Pnext; + } + } + + if( Struct->m_StructType == DRAW_BUSENTRY_STRUCT_TYPE) + { + DrawBusEntryStruct * item = (DrawBusEntryStruct*)Struct; + AddPickedItem(screen, item->m_Pos.x, item->m_Pos.y); + AddPickedItem(screen, item->m_End().x, item->m_End().y); + } + } +} + + +/******************************************************************/ +static void AddPickedItem( SCH_SCREEN * screen, int px, int py ) +/******************************************************************/ +{ +DrawPickedStruct * DrawStructs; +EDA_BaseStruct * Struct; + + /* Examen de la liste des elements deja selectionnes */ + DrawStructs = (DrawPickedStruct *) screen->BlockLocate.m_BlockDrawStruct; + while (DrawStructs) + { + Struct = DrawStructs->m_PickedStruct; + DrawStructs = (DrawPickedStruct *)DrawStructs->Pnext; + switch( Struct->m_StructType ) + { + case DRAW_SEGMENT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((EDA_DrawLineStruct*)Struct) + if( (STRUCT->m_Start.x == px) && (STRUCT->m_Start.y == py) ) + STRUCT->m_Flags &= ~STARTPOINT; + + if( (STRUCT->m_End.x == px) && (STRUCT->m_End.y == py) ) + STRUCT->m_Flags &= ~ENDPOINT; + break; + default: break; + } + } + + /* Examen de la liste des elements non selectionnes */ + + Struct = screen->EEDrawList; + while ( Struct ) + { + switch (Struct->m_StructType) + { + case TYPE_NOT_INIT: + break; + case DRAW_POLYLINE_STRUCT_TYPE: + if( Struct->m_Flags & SELECTED ) break; /* Deja en liste */ + break; + + case DRAW_JUNCTION_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawJunctionStruct*)Struct) + if( Struct->m_Flags & SELECTED ) break; /* Deja en liste */ + if( STRUCT->m_Pos.x != px ) break; + if( STRUCT->m_Pos.y != py ) break; + DrawStructs = new DrawPickedStruct(Struct); + DrawStructs->Pnext = + (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; + break; + + case DRAW_SEGMENT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((EDA_DrawLineStruct*)Struct) + if( Struct->m_Flags & SELECTED ) break; /* Deja en liste */ + if( (STRUCT->m_Start.x == px ) && ( STRUCT->m_Start.y == py ) ) + { + DrawStructs = new DrawPickedStruct(Struct); + DrawStructs->Pnext = + (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*)DrawStructs; + Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; + Struct->m_Flags &= ~STARTPOINT; + } + else if( (STRUCT->m_End.x == px ) && ( STRUCT->m_End.y == py ) ) + { + DrawStructs = new DrawPickedStruct(Struct); + DrawStructs->Pnext = + (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; + Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; + Struct->m_Flags &= ~ENDPOINT; + } + break; + + case DRAW_BUSENTRY_STRUCT_TYPE: + break; + + case DRAW_TEXT_STRUCT_TYPE: + break; + + case DRAW_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawLabelStruct*)Struct) + if( Struct->m_Flags & SELECTED ) break; /* Deja en liste */ + if( STRUCT->m_Pos.x != px ) break; + if( STRUCT->m_Pos.y != py ) break; + DrawStructs = new DrawPickedStruct(Struct); + DrawStructs->Pnext = + (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; + Struct->m_Flags |= SELECTED; + break; + + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawGlobalLabelStruct*)Struct) + if( Struct->m_Flags & SELECTED ) break; /* Deja en liste */ + if( STRUCT->m_Pos.x != px ) break; + if( STRUCT->m_Pos.y != py ) break; + DrawStructs = new DrawPickedStruct(Struct); + DrawStructs->Pnext = + (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; + Struct->m_Flags |= SELECTED; + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE: + break; + + case DRAW_SHEET_STRUCT_TYPE: + break; + + case DRAW_SHEETLABEL_STRUCT_TYPE: + break; + + case DRAW_PICK_ITEM_STRUCT_TYPE: + break; + + case DRAW_MARKER_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawMarkerStruct*)Struct) + if( Struct->m_Flags & SELECTED ) break; /* Deja en liste */ + if( STRUCT->m_Pos.x != px ) break; + if( STRUCT->m_Pos.y != py ) break; + DrawStructs = new DrawPickedStruct(Struct); + DrawStructs->Pnext = + (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; + Struct->m_Flags |= SELECTED; + break; + + case DRAW_NOCONNECT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawNoConnectStruct*)Struct) + if( Struct->m_Flags & SELECTED ) break; /* Deja en liste */ + if( STRUCT->m_Pos.x != px ) break; + if( STRUCT->m_Pos.y != py ) break; + DrawStructs = new DrawPickedStruct(Struct); + DrawStructs->Pnext = + (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; + screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs; + Struct->m_Flags |= SELECTED; + break; + + default: + break; + } + Struct = Struct->Pnext; + } +} + +/*********************************************************************************/ +static LibEDA_BaseStruct * GetNextPinPosition( EDA_SchComponentStruct * DrawLibItem, + int * px, int * py ) +/*********************************************************************************/ +{ +EDA_LibComponentStruct *Entry; +static LibEDA_BaseStruct *NextItem; +static int Multi, convert, PartX, PartY, TransMat[2][2]; +LibEDA_BaseStruct *DEntry; +int x2, y2, orient; +LibDrawPin * Pin; + + if( DrawLibItem ) + { + NextItem = NULL; + if((Entry = FindLibPart(DrawLibItem->m_ChipName.GetData(),wxEmptyString,FIND_ROOT)) == NULL) + return(NULL); + DEntry = Entry->m_Drawings; + Multi = DrawLibItem->m_Multi; + convert = DrawLibItem->m_Convert; + PartX = DrawLibItem->m_Pos.x; + PartY = DrawLibItem->m_Pos.y; + memcpy(TransMat, DrawLibItem->m_Transform, sizeof(TransMat) ); + } + else DEntry = NextItem; + + for( ; DEntry != NULL; DEntry = DEntry->Next()) + { + /* Elimination des elements non relatifs a l'unite */ + if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) ) continue; + if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) ) + continue; + if( DEntry->m_StructType != COMPONENT_PIN_DRAW_TYPE ) continue; + + Pin = (LibDrawPin * ) DEntry; + + /* Calcul de l'orientation reelle de la Pin */ + orient = Pin->ReturnPinDrawOrient(TransMat); + + /* Calcul de la position du point de reference */ + x2 = PartX + (TransMat[0][0] * Pin->m_Pos.x) + + (TransMat[0][1] * Pin->m_Pos.y); + y2 = PartY + (TransMat[1][0] * Pin->m_Pos.x) + + (TransMat[1][1] * Pin->m_Pos.y); + *px = x2; *py = y2; + NextItem = DEntry->Next(); + return(DEntry); + } + + NextItem = NULL; + return(NULL); +} + diff --git a/eeschema/block_libedit.cpp b/eeschema/block_libedit.cpp new file mode 100644 index 0000000000..f931076fc5 --- /dev/null +++ b/eeschema/block_libedit.cpp @@ -0,0 +1,670 @@ +/****************************************************/ +/* BLOCK.CPP */ +/* Gestion des Operations sur Blocks et Effacements */ +/****************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +/* Variables Locales */ + +/* Fonctions exportees */ + +/* Fonctions Locales */ +static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static int MarkItemsInBloc(EDA_LibComponentStruct * LibComponent, + EDA_Rect & Rect); + +static void ClearMarkItems(EDA_LibComponentStruct * LibComponent); +static void CopyMarkedItems(EDA_LibComponentStruct *LibEntry, wxPoint offset); +static void MoveMarkedItems(EDA_LibComponentStruct *LibEntry, wxPoint offset); +static void MirrorMarkedItems(EDA_LibComponentStruct *LibEntry, wxPoint offset); +static void DeleteMarkedItems(EDA_LibComponentStruct *LibEntry); + +/*********************************************************/ +void ClearMarkItems(EDA_LibComponentStruct * LibComponent) +/*********************************************************/ +{ +LibEDA_BaseStruct * item; + + if ( LibComponent == NULL ) return; + + item = LibComponent->m_Drawings; + for ( ; item != NULL; item = item->Next() ) + item->m_Flags = item->m_Selected = 0; +} + +/***************************************************************/ +int MarkItemsInBloc(EDA_LibComponentStruct * LibComponent, + EDA_Rect & Rect) +/***************************************************************/ +/* Mark items inside rect. + Items are inside rect when an end point is inside rect + + Rules for convert drawings and other parts ( for multi part per package): + - Commons are always marked + - Specific graphic shapes must agree with the current displayed part and convert + - Because most of pins are specific to current part and current convert: + - if g_EditPinByPinIsOn == TRUE, or flag .m_UnitSelectionLocked == TRUE, + only the pins specific to current part and current convert are marked + - all specific to current convert pins are marked; +*/ +{ +LibEDA_BaseStruct * item; +int ItemsCount = 0; +wxPoint pos; +bool ItemIsInOtherPart, ItemIsInOtherConvert; + + if ( LibComponent == NULL ) return 0; + + item = LibComponent->m_Drawings; + for ( ; item != NULL; item = item->Next() ) + { + item->m_Selected = 0; + // Do not consider other units or other convert items: + ItemIsInOtherPart = ItemIsInOtherConvert = FALSE; + if( item->m_Unit && (item->m_Unit != CurrentUnit) ) + ItemIsInOtherPart = TRUE; + if( item->m_Convert && (item->m_Convert != CurrentConvert) ) + ItemIsInOtherConvert = TRUE; + if ( ItemIsInOtherPart || ItemIsInOtherConvert ) + { + if (item->m_StructType == COMPONENT_PIN_DRAW_TYPE) + { // Specific rules for pins: + if ( g_EditPinByPinIsOn ) continue; + if ( LibComponent->m_UnitSelectionLocked ) continue; + if ( ItemIsInOtherConvert ) continue; + } + else continue; + } + switch( item->m_StructType ) + { + case COMPONENT_ARC_DRAW_TYPE: + { + pos = ((LibDrawArc*)item)->m_Start; pos.y = -pos.y; + if ( Rect.Inside(pos) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + pos = ((LibDrawArc*)item)->m_End; pos.y = -pos.y; + if ( Rect.Inside(pos) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + break; + } + + case COMPONENT_CIRCLE_DRAW_TYPE: + pos = ((LibDrawCircle*)item)->m_Pos; pos.y = -pos.y; + if ( Rect.Inside(pos) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + break; + + case COMPONENT_RECT_DRAW_TYPE: + pos = ((LibDrawSquare*)item)->m_Start; pos.y = -pos.y; + if ( Rect.Inside(pos) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + pos = ((LibDrawSquare*)item)->m_End; pos.y = -pos.y; + if ( Rect.Inside(pos) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + { + int ii , imax = ((LibDrawPolyline*)item)->n * 2; + int * ptpoly = ((LibDrawPolyline*)item)->PolyList; + for ( ii = 0; ii < imax; ii += 2) + { + pos.x = ptpoly[ii]; pos.y = -ptpoly[ii + 1]; + if ( Rect.Inside(pos) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + break; + } + } + } + break; + + case COMPONENT_LINE_DRAW_TYPE: + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + pos = ((LibDrawText*)item)->m_Pos; pos.y = -pos.y; + if ( Rect.Inside(pos) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + break; + + case COMPONENT_PIN_DRAW_TYPE: + #undef STRUCT + #define STRUCT ((LibDrawPin*)item) + pos = STRUCT->m_Pos; pos.y = -pos.y; + if ( Rect.Inside(pos) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + pos = STRUCT->ReturnPinEndPoint(); pos.y = -pos.y; + if ( Rect.Inside(pos) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + break; + + case COMPONENT_FIELD_DRAW_TYPE: + break; + default: + break; + } + + } + return ItemsCount; + +} + +/*************************************************************************/ +int WinEDA_LibeditFrame::ReturnBlockCommand(int key) +/*************************************************************************/ +/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to + the key (ALT, SHIFT ALT ..) +*/ +{ +int cmd; + + switch ( key ) + { + default: + cmd = key & 0x255; + break; + + case -1: + cmd = BLOCK_PRESELECT_MOVE; + break; + + case 0: + cmd = BLOCK_MOVE; + break; + + case GR_KB_ALT: + case GR_KB_SHIFT: + cmd = BLOCK_COPY; + break; + + case GR_KB_SHIFTCTRL: + cmd = BLOCK_DELETE; + break; + + case GR_KB_CTRL: + cmd = BLOCK_INVERT; + break; + + case MOUSE_MIDDLE: + cmd = BLOCK_ZOOM; + break; + } + + return cmd; +} + + +/****************************************************/ +int WinEDA_LibeditFrame::HandleBlockEnd(wxDC * DC) +/****************************************************/ +/* Command BLOCK END (end of block sizing) + return : + 0 if command finished (zoom, delete ...) + 1 if HandleBlockPlace must follow (items found, and a block place command must follow) +*/ +{ +int ItemsCount = 0, MustDoPlace = 0; + + if ( GetScreen()->BlockLocate.m_BlockDrawStruct ) + { + BlockState state = GetScreen()->BlockLocate.m_State; + CmdBlockType command = GetScreen()->BlockLocate.m_Command; + DrawPanel->ForceCloseManageCurseur(DrawPanel, DC); + GetScreen()->BlockLocate.m_State = state; + GetScreen()->BlockLocate.m_Command = command; + DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines; + DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand; + GetScreen()->m_Curseur.x = GetScreen()->BlockLocate.GetRight(); + GetScreen()->m_Curseur.y = GetScreen()->BlockLocate.GetBottom(); + DrawPanel->MouseToCursorSchema(); + } + + switch( GetScreen()->BlockLocate.m_Command ) + { + case BLOCK_IDLE: + DisplayError(this, wxT("Error in HandleBlockPLace") ); + break; + + case BLOCK_DRAG: /* Drag */ + case BLOCK_MOVE: /* Move */ + case BLOCK_COPY: /* Copy */ + ItemsCount = MarkItemsInBloc(CurrentLibEntry, GetScreen()->BlockLocate); + if ( ItemsCount ) + { + MustDoPlace = 1; + if(DrawPanel->ManageCurseur != NULL) + { + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + } + GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; + DrawPanel->Refresh(TRUE); + } + break; + + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + MustDoPlace = 1; + DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; + break; + + case BLOCK_DELETE: /* Delete */ + ItemsCount = MarkItemsInBloc(CurrentLibEntry, GetScreen()->BlockLocate); + if ( ItemsCount ) SaveCopyInUndoList(CurrentLibEntry); + DeleteMarkedItems(CurrentLibEntry); + break; + + case BLOCK_SAVE: /* Save */ + case BLOCK_PASTE: + case BLOCK_ROTATE: + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: + break; + + + case BLOCK_INVERT: + ItemsCount = MarkItemsInBloc(CurrentLibEntry, GetScreen()->BlockLocate); + if ( ItemsCount ) SaveCopyInUndoList(CurrentLibEntry); + MirrorMarkedItems(CurrentLibEntry, GetScreen()->BlockLocate.Centre()); + break; + + case BLOCK_ZOOM: /* Window Zoom */ + Window_Zoom( GetScreen()->BlockLocate ); + break; + + case BLOCK_ABORT: + break; + + case BLOCK_SELECT_ITEMS_ONLY: + break; + } + + if ( MustDoPlace <= 0 ) + { + if ( GetScreen()->BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY ) + { + ClearMarkItems(CurrentLibEntry); + } + GetScreen()->BlockLocate.m_Flags = 0; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->m_CurrentItem = NULL; + SetToolID(m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); + DrawPanel->Refresh(TRUE); + } + + + return(MustDoPlace); +} + + +/******************************************************/ +void WinEDA_LibeditFrame::HandleBlockPlace(wxDC * DC) +/******************************************************/ +/* Routine to handle the BLOCK PLACE commande + Last routine for block operation for: + - block move & drag + - block copie & paste +*/ +{ +bool err = FALSE; + + if(DrawPanel->ManageCurseur == NULL) + { + err = TRUE; + DisplayError(this, wxT("HandleBlockPLace : ManageCurseur = NULL") ); + } + + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + + switch(GetScreen()->BlockLocate.m_Command ) + { + case BLOCK_IDLE: + err = TRUE; + break; + + case BLOCK_DRAG: /* Drag */ + case BLOCK_MOVE: /* Move */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + SaveCopyInUndoList(CurrentLibEntry); + MoveMarkedItems(CurrentLibEntry, GetScreen()->BlockLocate.m_MoveVector); + DrawPanel->Refresh(TRUE); + break; + + case BLOCK_COPY: /* Copy */ + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + SaveCopyInUndoList(CurrentLibEntry); + CopyMarkedItems(CurrentLibEntry, GetScreen()->BlockLocate.m_MoveVector); + break; + + case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */ + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + break; + + case BLOCK_INVERT: /* Invert by popup menu, from block move */ + SaveCopyInUndoList(CurrentLibEntry); + MirrorMarkedItems(CurrentLibEntry, GetScreen()->BlockLocate.Centre()); + break; + + case BLOCK_ZOOM: // Handled by HandleBlockEnd + case BLOCK_DELETE: + case BLOCK_SAVE: + case BLOCK_ROTATE: + case BLOCK_ABORT: + default: + break; + } + + GetScreen()->SetModify(); + + + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->BlockLocate.m_Flags = 0; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + GetScreen()->m_CurrentItem = NULL; + DrawPanel->Refresh(TRUE); + + SetToolID(m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); +} + + +/************************************************************************/ +static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, + bool erase ) +/************************************************************************/ +/* Retrace le contour du block de recherche de structures + L'ensemble du block suit le curseur +*/ +{ +DrawBlockStruct * PtBlock; +BASE_SCREEN * screen = panel->m_Parent->GetScreen(); +LibEDA_BaseStruct * item; +wxPoint move_offset; + + PtBlock = &panel->GetScreen()->BlockLocate; + GRSetDrawMode(DC, g_XorMode); + + /* Effacement ancien cadre */ + if( erase ) + { + PtBlock->Offset(PtBlock->m_MoveVector); + PtBlock->Draw(panel, DC); + PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y); + + if ( CurrentLibEntry ) + { + item = CurrentLibEntry->m_Drawings; + for ( ; item != NULL; item = item->Next() ) + { + if ( item->m_Selected == 0 ) continue; + /* Do not draw items for other units */ + if( CurrentUnit && item->m_Unit && (item->m_Unit != CurrentUnit) ) + continue; + if( CurrentConvert && item->m_Convert && (item->m_Convert != CurrentConvert) ) + continue; + DrawLibraryDrawStruct(panel, DC, CurrentLibEntry, + PtBlock->m_MoveVector.x , PtBlock->m_MoveVector.y, + item, CurrentUnit, g_XorMode); + } + } + } + + /* Redessin nouvel affichage */ + PtBlock->m_MoveVector.x = screen->m_Curseur.x - PtBlock->m_BlockLastCursorPosition.x; + PtBlock->m_MoveVector.y = screen->m_Curseur.y - PtBlock->m_BlockLastCursorPosition.y; + + GRSetDrawMode(DC, g_XorMode); + PtBlock->Offset(PtBlock->m_MoveVector); + PtBlock->Draw(panel, DC); + PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y); + + + if ( CurrentLibEntry ) + { + item = CurrentLibEntry->m_Drawings; + for ( ; item != NULL; item = item->Next() ) + { + if ( item->m_Selected == 0 ) continue; + /* Do not draw items for other units */ + if( CurrentUnit && item->m_Unit && (item->m_Unit != CurrentUnit) ) + continue; + if( CurrentConvert && item->m_Convert && (item->m_Convert != CurrentConvert) ) + continue; + DrawLibraryDrawStruct(panel, DC, CurrentLibEntry, + PtBlock->m_MoveVector.x , PtBlock->m_MoveVector.y, + item, CurrentUnit, g_XorMode); + } + } +} + +/****************************************************************************/ +void CopyMarkedItems(EDA_LibComponentStruct *LibEntry, wxPoint offset) +/****************************************************************************/ +/* Copy marked items, at new position = old position + offset +*/ +{ +LibEDA_BaseStruct * item; + + if ( LibEntry == NULL ) return; + + item = LibEntry->m_Drawings; + for ( ; item != NULL; item = item->Next() ) + { + if ( item->m_Selected == 0 ) continue; + item->m_Selected = 0; + LibEDA_BaseStruct * newitem = CopyDrawEntryStruct( NULL, item); + newitem->m_Selected = IS_SELECTED; + newitem->Pnext = LibEntry->m_Drawings; + LibEntry->m_Drawings = newitem; + } + + MoveMarkedItems(LibEntry, offset); +} + +/****************************************************************************/ +void MoveMarkedItems(EDA_LibComponentStruct *LibEntry, wxPoint offset) +/****************************************************************************/ +/* Move marked items, at new position = old position + offset +*/ +{ +LibEDA_BaseStruct * item; + + if ( LibEntry == NULL ) return; + + offset.y = - offset.y; // Y axis for lib items is Down to Up: reverse y offset value + item = LibEntry->m_Drawings; + for ( ; item != NULL; item = item->Next() ) + { + if ( item->m_Selected == 0 ) continue; + + switch ( item->m_StructType ) + { + case COMPONENT_PIN_DRAW_TYPE: + ((LibDrawPin*)item)->m_Pos.x += offset.x; + ((LibDrawPin*)item)->m_Pos.y += offset.y; + break; + + case COMPONENT_ARC_DRAW_TYPE: + { + ((LibDrawArc*)item)->m_Pos.x += offset.x; + ((LibDrawArc*)item)->m_Pos.y += offset.y; + ((LibDrawArc*)item)->m_Start.x += offset.x; + ((LibDrawArc*)item)->m_Start.y += offset.y; + ((LibDrawArc*)item)->m_End.x += offset.x; + ((LibDrawArc*)item)->m_End.y += offset.y; + break; + } + + case COMPONENT_CIRCLE_DRAW_TYPE: + ((LibDrawCircle*)item)->m_Pos.x += offset.x; + ((LibDrawCircle*)item)->m_Pos.y += offset.y; + break; + + case COMPONENT_RECT_DRAW_TYPE: + ((LibDrawSquare*)item)->m_Start.x += offset.x; + ((LibDrawSquare*)item)->m_Start.y += offset.y; + ((LibDrawSquare*)item)->m_End.x += offset.x; + ((LibDrawSquare*)item)->m_End.y += offset.y; + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + { + int ii , imax = ((LibDrawPolyline*)item)->n * 2; + int * ptpoly = ((LibDrawPolyline*)item)->PolyList; + for ( ii = 0; ii < imax; ii += 2) + { + ptpoly[ii] += offset.x; + ptpoly[ii + 1] += offset.y; + } + } + break; + + case COMPONENT_LINE_DRAW_TYPE: + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + ((LibDrawText*)item)->m_Pos.x += offset.x; + ((LibDrawText*)item)->m_Pos.y += offset.y; + break; + } + item->m_Flags = item->m_Selected = 0; + } +} + +/******************************************************/ +void DeleteMarkedItems(EDA_LibComponentStruct *LibEntry) +/******************************************************/ +/* Delete marked items +*/ +{ +LibEDA_BaseStruct * item, * next_item; + + if ( LibEntry == NULL ) return; + + item = LibEntry->m_Drawings; + for ( ; item != NULL; item = next_item ) + { + next_item = item->Next(); + if ( item->m_Selected == 0 ) continue; + DeleteOneLibraryDrawStruct(NULL, NULL, LibEntry, item, 0); + } +} + + +/****************************************************************************/ +void MirrorMarkedItems(EDA_LibComponentStruct *LibEntry, wxPoint offset) +/****************************************************************************/ +/* Mirror marked items, refer to a Vertical axis at position offset +*/ +{ +#define SETMIRROR(z) (z) -= offset.x; (z) = -(z); (z) += offset.x; +LibEDA_BaseStruct * item; + + if ( LibEntry == NULL ) return; + + offset.y = - offset.y; // Y axis for lib items is Down to Up: reverse y offset value + item = LibEntry->m_Drawings; + for ( ; item != NULL; item = item->Next() ) + { + if ( item->m_Selected == 0 ) continue; + + switch ( item->m_StructType ) + { + case COMPONENT_PIN_DRAW_TYPE: + SETMIRROR(((LibDrawPin*)item)->m_Pos.x); + switch (((LibDrawPin*)item)->m_Orient) + { + case PIN_RIGHT: + ((LibDrawPin*)item)->m_Orient = PIN_LEFT; + break; + + case PIN_LEFT: + ((LibDrawPin*)item)->m_Orient = PIN_RIGHT; + break; + + case PIN_UP: + case PIN_DOWN: + break; + } + break; + + case COMPONENT_ARC_DRAW_TYPE: + { + SETMIRROR(((LibDrawArc*)item)->m_Pos.x); + SETMIRROR(((LibDrawArc*)item)->m_Start.x); + SETMIRROR(((LibDrawArc*)item)->m_End.x); + EXCHG(((LibDrawArc*)item)->m_Start,((LibDrawArc*)item)->m_End); + break; + } + + case COMPONENT_CIRCLE_DRAW_TYPE: + SETMIRROR(((LibDrawCircle*)item)->m_Pos.x); + break; + + case COMPONENT_RECT_DRAW_TYPE: + SETMIRROR(((LibDrawSquare*)item)->m_Start.x); + SETMIRROR(((LibDrawSquare*)item)->m_End.x); + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + { + int ii , imax = ((LibDrawPolyline*)item)->n * 2; + int * ptpoly = ((LibDrawPolyline*)item)->PolyList; + for ( ii = 0; ii < imax; ii += 2) + { + SETMIRROR(ptpoly[ii]); + } + } + break; + + case COMPONENT_LINE_DRAW_TYPE: + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + SETMIRROR(((LibDrawText*)item)->m_Pos.x); + break; + } + item->m_Flags = item->m_Selected = 0; + } +} diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp new file mode 100644 index 0000000000..2e886cbc05 --- /dev/null +++ b/eeschema/bus-wire-junction.cpp @@ -0,0 +1,824 @@ +/*********************************************************/ +/* Modules de creations de Traits, Wires, Bus, Junctions */ +/*********************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + + +/* Routines Locales */ +static void Show_Polyline_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void Segment_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void AbortCreateNewLine(WinEDA_DrawPanel * Panel, wxDC * DC); +static bool IsTerminalPoint(SCH_SCREEN * screen, const wxPoint & pos, int layer ); +static bool IsJunctionNeeded (WinEDA_SchematicFrame * frame, wxPoint & pos ); +static void ComputeBreakPoint(EDA_DrawLineStruct * segment, const wxPoint & new_pos); + +EDA_BaseStruct * s_OldWiresList; +wxPoint s_ConnexionStartPoint; + +/*********************************************************/ +EDA_BaseStruct * SCH_SCREEN::ExtractWires(bool CreateCopy) +/*********************************************************/ +/* Extract the old wires, junctions and busses, an if CreateCopy replace them by a copy. +Old ones must be put in undo list, and the new ones can be modified by clean up +safely. +If an abord command is made, old wires must be put in EEDrawList, and copies must be deleted +This is because previously stored undo commands can handle pointers on wires or bus, +and we do not delete wires or bus, we must put they in undo list. + +Because cleanup delete and/or modify bus and wires, the more easy is to put all wires in undo list +and use a new copy of wires for cleanup +*/ +{ +EDA_BaseStruct *item, *next_item, *new_item, * List = NULL; + + for (item = EEDrawList; item != NULL; item = next_item) + { + next_item = item->Pnext; + switch ( item->m_StructType ) + { + case DRAW_JUNCTION_STRUCT_TYPE: + case DRAW_SEGMENT_STRUCT_TYPE: + RemoveFromDrawList(item); + item->Pnext = List; + List = item; + if ( CreateCopy ) + { + if ( item->m_StructType == DRAW_JUNCTION_STRUCT_TYPE) + new_item = ((DrawJunctionStruct*)item)->GenCopy(); + else + new_item = ((EDA_DrawLineStruct*)item)->GenCopy(); + new_item->Pnext = EEDrawList; + EEDrawList = new_item; + } + break; + + default: + break; + } + } + + return List; + +} + + +/*************************************************/ +static void RestoreOldWires(SCH_SCREEN * screen) +/*************************************************/ +/* Replace the wires in screen->EEDrawList by s_OldWiresList wires. +*/ +{ +EDA_BaseStruct *item, *next_item; + + for (item = screen->EEDrawList; item != NULL; item = next_item) + { + next_item = item->Pnext; + switch ( item->m_StructType ) + { + case DRAW_JUNCTION_STRUCT_TYPE: + case DRAW_SEGMENT_STRUCT_TYPE: + screen->RemoveFromDrawList(item); + delete item; + break; + + default: + break; + } + } + + while (s_OldWiresList) + { + next_item = s_OldWiresList->Pnext; + s_OldWiresList->Pnext = screen->EEDrawList, + screen->EEDrawList = s_OldWiresList; + s_OldWiresList = next_item; + } +} + + +/*************************************************************/ +void WinEDA_SchematicFrame::BeginSegment(wxDC * DC, int type) +/*************************************************************/ +/* Create a new segment ( WIRE, BUS ). +*/ +{ +EDA_DrawLineStruct * oldsegment, * newsegment, * nextsegment; +wxPoint cursorpos = GetScreen()->m_Curseur; + + if ( GetScreen()->m_CurrentItem && (GetScreen()->m_CurrentItem->m_Flags == 0) ) + GetScreen()->m_CurrentItem = NULL; + + if ( GetScreen()->m_CurrentItem ) + { + switch (GetScreen()->m_CurrentItem->m_StructType ) + { + case DRAW_SEGMENT_STRUCT_TYPE: + case DRAW_POLYLINE_STRUCT_TYPE: + break; + + default: + return; + } + } + + oldsegment = newsegment = + (EDA_DrawLineStruct *) GetScreen()->m_CurrentItem; + + if (!newsegment) /* first point : Create first wire ou bus */ + { + s_ConnexionStartPoint = cursorpos; + s_OldWiresList = GetScreen()->ExtractWires(TRUE); + GetScreen()->SchematicCleanUp(NULL); + switch(type) + { + default: + newsegment = new EDA_DrawLineStruct(cursorpos, LAYER_NOTES); + break; + case LAYER_WIRE: + newsegment = new EDA_DrawLineStruct(cursorpos, LAYER_WIRE); + /* A junction will be created later, when w'll know the + segment end position, and if the junction is really needed */ + break; + case LAYER_BUS: + newsegment = new EDA_DrawLineStruct(cursorpos, LAYER_BUS); + break; + } + + newsegment->m_Flags = IS_NEW; + if( g_HVLines ) // We need 2 segments to go from a given start pint to an end point + { + nextsegment = newsegment->GenCopy(); + nextsegment->m_Flags = IS_NEW; + newsegment->Pnext = nextsegment; + nextsegment->Pback = newsegment; + } + GetScreen()->m_CurrentItem = newsegment; + DrawPanel->ManageCurseur = Segment_in_Ghost; + DrawPanel->ForceCloseManageCurseur = AbortCreateNewLine; + g_ItemToRepeat = NULL; + } + + else /* Trace en cours: Placement d'un point supplementaire */ + { + nextsegment = (EDA_DrawLineStruct*)oldsegment->Pnext; + if( ! g_HVLines ) + { /* if only one segment is needed and the current is has len = 0, do not create a new one*/ + if( oldsegment->IsNull() ) return; + } + else + { /* if we want 2 segment and the last two have len = 0, do not create a new one*/ + if ( oldsegment->IsNull() && nextsegment && nextsegment->IsNull() ) + return; + } + + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + + /* Creation du segment suivant ou fin de tracé si point sur pin, jonction ...*/ + if ( IsTerminalPoint(GetScreen(), cursorpos, oldsegment->m_Layer) ) + { + EndSegment(DC); return; + } + + /* Placement en liste generale */ + oldsegment->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = oldsegment; + DrawPanel->CursorOff(DC); // Erase schematic cursor + RedrawOneStruct(DrawPanel,DC, oldsegment, GR_DEFAULT_DRAWMODE); + DrawPanel->CursorOn(DC); // Display schematic cursor + + /* Create a new segment, and chain it after the current new segment */ + if ( nextsegment ) + { + newsegment = nextsegment->GenCopy(); + nextsegment->m_Start = newsegment->m_End; + nextsegment->Pnext = NULL; + nextsegment->Pback = newsegment; + newsegment->Pnext = nextsegment; + newsegment->Pback = NULL; + } + else + { + newsegment = oldsegment->GenCopy(); + newsegment->m_Start = oldsegment->m_End; + } + newsegment->m_End = cursorpos; + oldsegment->m_Flags = SELECTED; + newsegment->m_Flags = IS_NEW; + GetScreen()->m_CurrentItem = newsegment; + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + if ( oldsegment->m_Start == s_ConnexionStartPoint ) + { /* This is the first segment: Now we know the start segment position. + Create a junction if needed. Note: a junction can be needed + later, if the new segment is merged (after a cleanup) with an older one + (tested when the connection will be finished)*/ + if ( IsJunctionNeeded(this, s_ConnexionStartPoint) ) + CreateNewJunctionStruct(DC, s_ConnexionStartPoint); + } + } +} + + +/***********************************************/ +void WinEDA_SchematicFrame::EndSegment(wxDC *DC) +/***********************************************/ +/* Called to terminate a bus, wire, or line creation +*/ +{ +EDA_DrawLineStruct * firstsegment = (EDA_DrawLineStruct *)GetScreen()->m_CurrentItem; +EDA_DrawLineStruct * lastsegment = firstsegment; +EDA_DrawLineStruct * segment; + + if ( firstsegment == NULL ) return; + if ( (firstsegment->m_Flags & IS_NEW) == 0) return; + + /* Delete Null segments and Put line it in Drawlist */ + lastsegment = firstsegment; + while ( lastsegment ) + { + EDA_DrawLineStruct * nextsegment = (EDA_DrawLineStruct *)lastsegment->Pnext; + if ( lastsegment->IsNull() ) + { + EDA_DrawLineStruct * previous_segment = (EDA_DrawLineStruct *)lastsegment->Pback; + if ( firstsegment == lastsegment ) firstsegment = nextsegment; + if ( nextsegment ) nextsegment->Pback = NULL; + if ( previous_segment ) previous_segment->Pnext = nextsegment; + delete lastsegment; + } + lastsegment = nextsegment; + } + /* put the segment list to the main linked list */ + segment = lastsegment = firstsegment; + while ( segment ) + { + lastsegment = segment; + segment = (EDA_DrawLineStruct *)segment->Pnext; + lastsegment->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = lastsegment; + } + + /* Fin de trace */ + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->m_CurrentItem = NULL; + +wxPoint end_point, alt_end_point; + /* A junction can be needed to connect the last segment + usually to m_End coordinate. + But if the last segment is removed by a cleanup, because od redundancy, + a junction can be needed to connect the previous segment m_End coordinate + with is also the lastsegment->m_Start coordinate */ + if ( lastsegment ) + { + end_point = lastsegment->m_End; + alt_end_point = lastsegment->m_Start; + } + + GetScreen()->SchematicCleanUp(NULL); + + /* clear flags and find last segment entered, for repeat function */ + segment = (EDA_DrawLineStruct *) GetScreen()->EEDrawList; + while ( segment ) + { + if ( segment->m_Flags ) + { + if ( ! g_ItemToRepeat ) g_ItemToRepeat = segment; + } + segment->m_Flags = 0; + segment = (EDA_DrawLineStruct *)segment->Pnext; + } + + // Automatic place of a junction on the end point, if needed + if ( lastsegment ) + { + if( IsJunctionNeeded(this, end_point) ) + CreateNewJunctionStruct(DC, end_point); + + else if( IsJunctionNeeded(this, alt_end_point) ) + CreateNewJunctionStruct(DC, alt_end_point); + } + + /* Automatic place of a junction on the start point if necessary because the + Cleanup can suppress intermediate points by merging wire segments*/ + if ( IsJunctionNeeded(this, s_ConnexionStartPoint) ) + CreateNewJunctionStruct(DC, s_ConnexionStartPoint); + + TestDanglingEnds(GetScreen()->EEDrawList, DC); + + + /* Redraw wires and junctions which can be changed by TestDanglingEnds() */ + DrawPanel->CursorOff(DC); // Erase schematic cursor + EDA_BaseStruct *item = GetScreen()->EEDrawList; + while ( item ) + { + switch ( item->m_StructType ) + { + case DRAW_JUNCTION_STRUCT_TYPE: + case DRAW_SEGMENT_STRUCT_TYPE: + RedrawOneStruct(DrawPanel,DC, item, GR_DEFAULT_DRAWMODE); + break; + + default: + break; + } + item = item->Pnext; + } + + + DrawPanel->CursorOn(DC); // Display schematic cursor + + SaveCopyInUndoList(s_OldWiresList, IS_WIRE_IMAGE); + s_OldWiresList = NULL; + + GetScreen()->SetModify(); +} + +/****************************************************************************/ +static void Segment_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/****************************************************************************/ +/* Redraw the segment (g_HVLines == FALSE ) or the two segments (g_HVLines == TRUE ) + from the start point to the cursor, when moving the mouse +*/ +{ +EDA_DrawLineStruct * CurrentLine = + (EDA_DrawLineStruct *) panel->m_Parent->GetScreen()->m_CurrentItem; +EDA_DrawLineStruct * segment; +int color; + + if ( CurrentLine == NULL ) return; + + color = ReturnLayerColor(CurrentLine->m_Layer) ^ HIGHT_LIGHT_FLAG; + + if( erase ) + { + segment = CurrentLine; + while ( segment ) + { + if ( ! segment->IsNull() ) // Redraw if segment lengtht != 0 + RedrawOneStruct(panel,DC, segment, g_XorMode, color); + segment = (EDA_DrawLineStruct*)segment->Pnext; + } + } + +wxPoint endpos = panel->m_Parent->GetScreen()->m_Curseur; + if( g_HVLines ) /* Coerce the line to vertical or horizontal one: */ + { + ComputeBreakPoint( CurrentLine, endpos); + } + + else CurrentLine->m_End = endpos; + + segment = CurrentLine; + while ( segment ) + { + if ( ! segment->IsNull() ) // Redraw if segment lengtht != 0 + RedrawOneStruct(panel,DC, segment, g_XorMode, color); + segment = (EDA_DrawLineStruct*)segment->Pnext; + } +} + + +/**************************************************************************************/ +static void ComputeBreakPoint( EDA_DrawLineStruct * segment, const wxPoint & new_pos ) +/**************************************************************************************/ +/* compute the middle coordinate for 2 segments, from the start point to new_pos + with the 2 segments kept H or V only +*/ +{ +EDA_DrawLineStruct * nextsegment = (EDA_DrawLineStruct *)segment->Pnext; +wxPoint middle_position = new_pos; + + if( nextsegment == NULL ) return; +#if 0 + if (ABS(middle_position.x - segment->m_Start.x) < ABS(middle_position.y - segment->m_Start.y)) + middle_position.x = segment->m_Start.x; + else + middle_position.y = segment->m_Start.y; +#else +int iDx = segment->m_End.x - segment->m_Start.x; +int iDy = segment->m_End.y - segment->m_Start.y; + if ( iDy != 0 ) // keep the first segment orientation (currently horizontal) + { + middle_position.x = segment->m_Start.x; + } + else if ( iDx != 0 ) // keep the first segment orientation (currently vertical) + { + middle_position.y = segment->m_Start.y; + } + else + { + if (ABS(middle_position.x - segment->m_Start.x) < ABS(middle_position.y - segment->m_Start.y)) + middle_position.x = segment->m_Start.x; + else + middle_position.y = segment->m_Start.y; + } +#endif + + segment->m_End = middle_position; + + nextsegment->m_Start = middle_position; + nextsegment->m_End = new_pos; +} + +/*****************************************************************************/ +static void Show_Polyline_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/*****************************************************************************/ +/* Dessin du du Polyline Fantome lors des deplacements du curseur +*/ +{ +DrawPolylineStruct * NewPoly = + (DrawPolylineStruct *)panel->m_Parent->GetScreen()->m_CurrentItem; +int color; +wxPoint endpos; + + endpos = panel->m_Parent->GetScreen()->m_Curseur; + color = ReturnLayerColor(NewPoly->m_Layer); + + GRSetDrawMode(DC, g_XorMode); + + if( g_HVLines ) + { + /* Coerce the line to vertical or horizontal one: */ + if (ABS(endpos.x - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2]) < + ABS(endpos.y - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1])) + endpos.x = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2]; + else + endpos.y = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1]; + } + + NewPoly->m_NumOfPoints++; + if( erase ) + RedrawOneStruct(panel,DC, NewPoly, g_XorMode, color); + + NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2] = endpos.x; + NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1] = endpos.y; + RedrawOneStruct(panel,DC, NewPoly, g_XorMode, color); + NewPoly->m_NumOfPoints--; +} + +/**********************************************************/ +void WinEDA_SchematicFrame::DeleteCurrentSegment(wxDC * DC) +/**********************************************************/ +/* +Routine effacant le dernier trait trace, ou l'element pointe par la souris +*/ +{ + + g_ItemToRepeat = NULL; + + if( (GetScreen()->m_CurrentItem == NULL) || + ((GetScreen()->m_CurrentItem->m_Flags & IS_NEW) == 0) ) + { + return; + } + + /* Trace en cours: annulation */ + if (GetScreen()->m_CurrentItem->m_StructType == DRAW_POLYLINE_STRUCT_TYPE) + { + Show_Polyline_in_Ghost(DrawPanel, DC, FALSE); /* Effacement du trace en cours */ + } + + else + { + Segment_in_Ghost(DrawPanel, DC, FALSE); /* Effacement du trace en cours */ + } + + EraseStruct(GetScreen()->m_CurrentItem, GetScreen()); + DrawPanel->ManageCurseur = NULL; + GetScreen()->m_CurrentItem = NULL; +} + + +/***************************************************************************/ +DrawJunctionStruct * WinEDA_SchematicFrame::CreateNewJunctionStruct( + wxDC * DC, const wxPoint & pos, bool PutInUndoList) +/***************************************************************************/ +/* Routine to create new connection struct. +*/ +{ +DrawJunctionStruct *NewJunction; + + NewJunction = new DrawJunctionStruct(pos); + + g_ItemToRepeat = NewJunction; + + DrawPanel->CursorOff(DC); // Erase schematic cursor + RedrawOneStruct(DrawPanel,DC, NewJunction, GR_DEFAULT_DRAWMODE); + DrawPanel->CursorOn(DC); // Display schematic cursor + + NewJunction->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = NewJunction; + GetScreen()->SetModify(); + if ( PutInUndoList ) + SaveCopyInUndoList(NewJunction, IS_NEW); + return(NewJunction); +} + +/**************************************************************************/ +EDA_BaseStruct *WinEDA_SchematicFrame::CreateNewNoConnectStruct(wxDC * DC) +/**************************************************************************/ +/*Routine to create new NoConnect struct. ( Symbole de Non Connexion) +*/ +{ +DrawNoConnectStruct *NewNoConnect; + + NewNoConnect = new DrawNoConnectStruct(GetScreen()->m_Curseur); + g_ItemToRepeat = NewNoConnect; + + DrawPanel->CursorOff(DC); // Erase schematic cursor + RedrawOneStruct(DrawPanel,DC, NewNoConnect, GR_DEFAULT_DRAWMODE); + DrawPanel->CursorOn(DC); // Display schematic cursor + + NewNoConnect->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = NewNoConnect; + GetScreen()->SetModify(); + SaveCopyInUndoList(NewNoConnect, IS_NEW); + return(NewNoConnect); +} + + +/*****************************************************************/ +static void AbortCreateNewLine(WinEDA_DrawPanel * Panel, wxDC * DC) +/*****************************************************************/ +/* Abort function for wire, bus or line creation +*/ +{ +SCH_SCREEN * Screen = (SCH_SCREEN *)Panel->GetScreen(); + + if( Screen->m_CurrentItem) /* trace en cours */ + { + Panel->ManageCurseur(Panel, DC, FALSE); + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + EraseStruct(Screen->m_CurrentItem,(SCH_SCREEN*) Screen); + Screen->m_CurrentItem = NULL; + RestoreOldWires(Screen); + } + + else g_ItemToRepeat = NULL; // Fin de commande generale + + /* Clear m_Flags wich is used in edit functions: */ + EDA_BaseStruct * item = Screen->EEDrawList; + while ( item ) + { + item->m_Flags = 0; + item = item->Pnext; + } +} + + +/***************************************************/ +void WinEDA_SchematicFrame::RepeatDrawItem(wxDC *DC) +/***************************************************/ +/* Routine de recopie du dernier element dessine + Les elements duplicables sont + fils, bus, traits, textes, labels + Les labels termines par un nombre seront incrementes +*/ +{ +wxPoint new_pos; + + if( g_ItemToRepeat == NULL ) return; + + switch( g_ItemToRepeat->m_StructType ) + { + case DRAW_JUNCTION_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawJunctionStruct*) g_ItemToRepeat) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos += g_RepeatStep; + new_pos = STRUCT->m_Pos; + break; + + case DRAW_NOCONNECT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawNoConnectStruct*) g_ItemToRepeat) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos += g_RepeatStep; + new_pos = STRUCT->m_Pos; + break; + + case DRAW_TEXT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawTextStruct*) g_ItemToRepeat) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos += g_RepeatStep; + new_pos = STRUCT->m_Pos; + /*** Increment du numero de label ***/ + IncrementLabelMember(STRUCT->m_Text); + break; + + + case DRAW_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawLabelStruct*) g_ItemToRepeat) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos += g_RepeatStep; + new_pos = STRUCT->m_Pos; + /*** Increment du numero de label ***/ + IncrementLabelMember(STRUCT->m_Text); + break; + + + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawGlobalLabelStruct*) g_ItemToRepeat) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos += g_RepeatStep; + new_pos = STRUCT->m_Pos; + /*** Increment du numero de label ***/ + IncrementLabelMember(STRUCT->m_Text); + break; + + case DRAW_SEGMENT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((EDA_DrawLineStruct*) g_ItemToRepeat) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Start += g_RepeatStep; + new_pos = STRUCT->m_Start; + STRUCT->m_End += g_RepeatStep; + break; + + case DRAW_BUSENTRY_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawBusEntryStruct*) g_ItemToRepeat) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos += g_RepeatStep; + new_pos = STRUCT->m_Pos; + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE: // In repeat command the new component is put in move mode + #undef STRUCT + #define STRUCT ((EDA_SchComponentStruct*) g_ItemToRepeat) + // Create the duplicate component, position = mouse cursor + g_ItemToRepeat = STRUCT->GenCopy(); + new_pos.x = m_CurrentScreen->m_Curseur.x - STRUCT->m_Pos.x; + new_pos.y = m_CurrentScreen->m_Curseur.y - STRUCT->m_Pos.y; + STRUCT->m_Pos = m_CurrentScreen->m_Curseur; + STRUCT->m_Flags = IS_NEW; + STRUCT->m_TimeStamp = GetTimeStamp(); + for( int ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) + { + STRUCT->m_Field[ii].m_Pos +=new_pos; + } + RedrawOneStruct(DrawPanel, DC, STRUCT, g_XorMode); + StartMovePart(STRUCT, DC); + return; + break; + + default: + g_ItemToRepeat = NULL; + DisplayError(this, wxT("Repeat Type Error"), 10); + break; + } + + if ( g_ItemToRepeat ) + { + g_ItemToRepeat->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = g_ItemToRepeat; + TestDanglingEnds(GetScreen()->EEDrawList, NULL); + RedrawOneStruct(DrawPanel,DC, g_ItemToRepeat, GR_DEFAULT_DRAWMODE); + SaveCopyInUndoList(g_ItemToRepeat, IS_NEW); + g_ItemToRepeat->m_Flags = 0; +// GetScreen()->Curseur = new_pos; +// GRMouseWarp(DrawPanel, DrawPanel->CursorScreenPosition() ); + } +} + + +/******************************************/ +void IncrementLabelMember(wxString & name) +/******************************************/ +/* Routine incrementant les labels, c'est a dire pour les textes finissant +par un nombre, ajoutant a ce nombre +*/ +{ +int ii, nn; +long number = 0; + + ii = name.Len() - 1; nn = 0; + if( !isdigit(name.GetChar(ii)) ) return; + + while( (ii >= 0) && isdigit(name.GetChar(ii)) ) { ii--; nn++ ; } + ii++; /* digits are starting at ii position */ +wxString litt_number = name.Right(nn); + if ( litt_number.ToLong(&number) ) + { + number += g_RepeatDeltaLabel; + name.Remove(ii); name << number; + } +} + +/***************************************************************************/ +static bool IsTerminalPoint(SCH_SCREEN * screen, const wxPoint & pos, int layer) +/***************************************************************************/ +/* Returne TRUE si pos est un point possible pour terminer automatiquement un +segment, c'est a dire pour + - type WIRE, si il y a + - une jonction + - ou une pin + - ou une extrémité unique de fil + + - type BUS, si il y a + - ou une extrémité unique de BUS +*/ +{ +EDA_BaseStruct * item; +LibDrawPin * pin; +EDA_SchComponentStruct * LibItem = NULL; +DrawSheetLabelStruct * pinsheet; +wxPoint itempos; + + switch ( layer ) + { + case LAYER_BUS: + item = PickStruct(pos, screen->EEDrawList, BUSITEM); + if ( item ) return TRUE; + pinsheet = LocateAnyPinSheet(pos, screen->EEDrawList ); + if ( pinsheet && IsBusLabel(pinsheet->m_Text) ) + { + itempos = pinsheet->m_Pos; + if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE; + } + break; + + case LAYER_NOTES: + item = PickStruct(pos, screen->EEDrawList, DRAWITEM); + if ( item ) + return TRUE; + break; + + case LAYER_WIRE: + item = PickStruct(pos, screen->EEDrawList, RACCORDITEM |JUNCTIONITEM); + if ( item ) return TRUE; + + pin = LocateAnyPin( screen->EEDrawList, pos, &LibItem ); + if ( pin && LibItem ) + { + // calcul de la position exacte du point de connexion de la pin, + // selon orientation du composant: + itempos = LibItem->GetScreenCoord(pin->m_Pos); + itempos.x += LibItem->m_Pos.x; + itempos.y += LibItem->m_Pos.y; + if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE; + } + + item = PickStruct(pos, screen->EEDrawList, WIREITEM); + if ( item ) return TRUE; + + item = PickStruct(pos, screen->EEDrawList, LABELITEM); + if ( item && (item->m_StructType != DRAW_TEXT_STRUCT_TYPE) && + ( ((DrawGlobalLabelStruct*)item)->m_Pos.x == pos.x) && + ( ((DrawGlobalLabelStruct*)item)->m_Pos.y == pos.y) ) + return TRUE; + + pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList ); + if ( pinsheet && ! IsBusLabel(pinsheet->m_Text) ) + { + itempos = pinsheet->m_Pos; + if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE; + } + + break; + + default: + break; + } + + return FALSE; +} + + +/****************************************************************/ +bool IsJunctionNeeded (WinEDA_SchematicFrame * frame, wxPoint & pos ) +/****************************************************************/ +/* Return True when a wire is located at pos "pos" if + - there is no junction. + - The wire has no ends at pos "pos", + and therefore it is considered as no connected. + - One (or more) wire has one end at pos "pos" + or + - a pin is on location pos +*/ +{ + if ( PickStruct(pos,frame->GetScreen()->EEDrawList, JUNCTIONITEM ) ) return FALSE; + + if ( PickStruct(pos,frame->GetScreen()->EEDrawList, WIREITEM |EXCLUDE_WIRE_BUS_ENDPOINTS ) ) + { + if ( PickStruct(pos,frame->GetScreen()->EEDrawList, WIREITEM |WIRE_BUS_ENDPOINTS_ONLY ) ) + return TRUE; + if ( frame->LocatePinEnd(frame->GetScreen()->EEDrawList, pos) ) + return TRUE; + } + + return FALSE; +} + diff --git a/eeschema/busentry.cpp b/eeschema/busentry.cpp new file mode 100644 index 0000000000..2df89b22a2 --- /dev/null +++ b/eeschema/busentry.cpp @@ -0,0 +1,172 @@ +/*************************************/ +/* Modules de creations de Bus Entry */ +/*************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "id.h" + +#include "protos.h" + + +/* Routines Locales */ + +/* Variables locales */ +static int s_LastShape = '\\'; +static wxPoint ItemInitialPosition; + +/**************************************************************/ +static void ExitBusEntry( WinEDA_DrawPanel * Panel, wxDC * DC ) +/**************************************************************/ +/* Routine de sortie des menus de trace */ +{ +DrawBusEntryStruct *BusEntry = + (DrawBusEntryStruct *)Panel->GetScreen()->m_CurrentItem; + + if( BusEntry) /* trace en cours */ + { + RedrawOneStruct(Panel, DC, BusEntry, g_XorMode); + if( BusEntry->m_Flags & IS_NEW ) + { + delete BusEntry; + Panel->GetScreen()->m_CurrentItem = NULL; + } + else + { + BusEntry->m_Pos = ItemInitialPosition; + RedrawOneStruct(Panel, DC, BusEntry, GR_DEFAULT_DRAWMODE); + BusEntry->m_Flags = 0; + } + } + + g_ItemToRepeat = NULL; + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; +} + +/************************************************************************/ +static void ShowWhileMoving(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/************************************************************************/ +/* Dessin du Segment "BusEntry" lors des deplacements du curseur +*/ +{ +BASE_SCREEN * screen = panel->m_Parent->GetScreen(); +DrawBusEntryStruct *BusEntry = (DrawBusEntryStruct *) screen->m_CurrentItem; + + if( BusEntry == NULL ) return; + + /* effacement apres deplacement curseur */ + if( erase ) + RedrawOneStruct(panel, DC, BusEntry, g_XorMode); + + /* Reaffichage au bon endroit */ + BusEntry->m_Pos = screen->m_Curseur; + RedrawOneStruct(panel, DC, BusEntry, g_XorMode); +} + +/**********************************************************************************/ +DrawBusEntryStruct * WinEDA_SchematicFrame::CreateBusEntry(wxDC * DC, int entry_type) +/**********************************************************************************/ +/* Create a new bus entry, and prepare moving function (for later place it) +*/ +{ +DrawBusEntryStruct * BusEntry = new DrawBusEntryStruct(GetScreen()->m_Curseur, + s_LastShape , entry_type); + BusEntry->m_Flags = IS_NEW; + + DrawPanel->CursorOff(DC); // Erase schematic cursor + RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode); + DrawPanel->CursorOn(DC); // Display schematic cursor + + GetScreen()->SetModify(); + + StartMoveBusEntry(BusEntry, DC); + return BusEntry; +} + + +/**************************************************************************/ +void WinEDA_SchematicFrame::StartMoveBusEntry(DrawBusEntryStruct * BusEntry, + wxDC * DC) +/**************************************************************************/ +{ + if ( BusEntry == NULL ) return; + + if ( (BusEntry->m_Flags & IS_NEW) == 0 ) // => not already in edit, save shape */ + { + delete g_ItemToUndoCopy; + g_ItemToUndoCopy = BusEntry->GenCopy(); + } + + BusEntry->m_Flags |= IS_MOVED; + + ItemInitialPosition = BusEntry->m_Pos; + + DrawPanel->CursorOff(DC); + GetScreen()->m_Curseur = BusEntry->m_Pos; + DrawPanel->MouseToCursorSchema(); + + GetScreen()->m_CurrentItem = BusEntry; + DrawPanel->ManageCurseur = ShowWhileMoving; + DrawPanel->ForceCloseManageCurseur = ExitBusEntry; + + DrawPanel->CursorOn(DC); +} + + +/************************************************************/ +void WinEDA_SchematicFrame::SetBusEntryShape(wxDC * DC, + DrawBusEntryStruct *BusEntry, int entry_shape) +/************************************************************/ +/* set the shape of BusEntry (shape = / or \ ) +*/ +{ + if ( BusEntry == NULL ) return; + + if ( BusEntry->m_StructType != DRAW_BUSENTRY_STRUCT_TYPE ) + { + DisplayError(this, wxT("SetBusEntryType: Bad StructType") ); + return; + } + + /* Put old item in undo list if it is not currently in edit */ + if ( BusEntry->m_Flags == 0 ) SaveCopyInUndoList(BusEntry, IS_CHANGED); + + RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode); + + switch( entry_shape ) + { + case '\\' : + s_LastShape = '\\'; + BusEntry->m_Size.y = 100; + break; + + case '/' : + s_LastShape = '/'; + BusEntry->m_Size.y = -100; + break; + } + + TestDanglingEnds(GetScreen()->EEDrawList, NULL); + RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode); + GetScreen()->SetModify(); +} + + +/************************************************************************/ +int WinEDA_SchematicFrame::GetBusEntryShape( DrawBusEntryStruct *BusEntry) +/************************************************************************/ +{ +int entry_shape = '\\'; + + if ( BusEntry->m_Size.y < 0 ) entry_shape = '/'; + return entry_shape; +} + + + diff --git a/eeschema/class_hierarchy_sheet.cpp b/eeschema/class_hierarchy_sheet.cpp new file mode 100644 index 0000000000..9fef1815de --- /dev/null +++ b/eeschema/class_hierarchy_sheet.cpp @@ -0,0 +1,173 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: sheet.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 08/02/2006 18:37:02 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + + + +/***********************************************************/ +DrawSheetStruct::DrawSheetStruct(const wxPoint & pos) : + SCH_SCREEN( SCHEMATIC_FRAME ) +/***********************************************************/ +{ + m_Label = NULL; + m_NbLabel = 0; + m_Layer = LAYER_SHEET; + m_Pos = pos; + m_SheetNameSize = m_FileNameSize = 60; + /* change the struct type: SCREEN_STRUCT_TYPE to DRAW_SHEET_STRUCT_TYPE */ + m_StructType = DRAW_SHEET_STRUCT_TYPE; +} + +/**************************************/ +DrawSheetStruct::~DrawSheetStruct(void) +/**************************************/ +{ +DrawSheetLabelStruct * label = m_Label, * next_label; + + while (label) + { + next_label = (DrawSheetLabelStruct *)label->Pnext; + delete label; + label = next_label; + } +} + + +/***********************************************/ +DrawSheetStruct * DrawSheetStruct::GenCopy(void) +/***********************************************/ +/* creates a copy of a sheet + The linked data itself (EEDrawList) is not duplicated +*/ +{ +DrawSheetStruct * newitem = new DrawSheetStruct(m_Pos); +DrawSheetLabelStruct * Slabel = NULL, * label = m_Label; + + newitem->m_Size = m_Size; + newitem->m_Parent = m_Parent; + newitem->m_TimeStamp = GetTimeStamp(); + + newitem->m_FileName = m_FileName; + newitem->m_FileNameSize = m_FileNameSize; + newitem->m_SheetName = m_SheetName; + newitem->m_SheetNameSize = m_SheetNameSize; + + if( label ) + { + Slabel = newitem->m_Label = label->GenCopy(); + Slabel->m_Parent = newitem; + label = (DrawSheetLabelStruct*)label->Pnext; + } + + while( label ) + { + Slabel->Pnext = label->GenCopy(); + Slabel = (DrawSheetLabelStruct*)Slabel->Pnext; + Slabel->m_Parent = newitem; + label = (DrawSheetLabelStruct*)label->Pnext; + } + + /* copy screen data */ + newitem->m_DrawOrg = m_DrawOrg; + newitem->m_Curseur = m_Curseur; + newitem->m_MousePosition = m_MousePosition; + newitem->m_O_Curseur = m_O_Curseur; + newitem->m_ScrollbarPos = m_ScrollbarPos; + newitem->m_ScrollbarNumber = m_ScrollbarNumber; + newitem->m_StartVisu = m_StartVisu; + newitem->m_FirstRedraw = m_FirstRedraw; + + newitem->EEDrawList = EEDrawList; /* Object list (main data) for schematic */ + newitem->m_UndoList = m_UndoList; /* Object list for the undo command (old data) */ + newitem->m_RedoList = m_RedoList; /* Object list for the redo command (old data) */ + + newitem->m_CurrentSheet = m_CurrentSheet; + newitem->m_SheetNumber = m_SheetNumber; + newitem->m_NumberOfSheet = m_NumberOfSheet; + newitem->m_FileName = m_FileName; + newitem->m_Title = m_Title; + newitem->m_Date = m_Date; + newitem->m_Revision = m_Revision; + newitem->m_Company = m_Company; + newitem->m_Commentaire1 = m_Commentaire1; + newitem->m_Commentaire2 = m_Commentaire2; + newitem->m_Commentaire3 = m_Commentaire3; + newitem->m_Commentaire4 = m_Commentaire4; + + return newitem; +} + + +/**********************************************************/ +void DrawSheetStruct::SwapData(DrawSheetStruct * copyitem) +/**********************************************************/ +/* Used if undo / redo command: + swap data between this and copyitem +*/ +{ + EXCHG(m_Pos, copyitem->m_Pos); + EXCHG(m_Size, copyitem->m_Size); + EXCHG(m_SheetName, copyitem->m_SheetName); + EXCHG(m_SheetNameSize, copyitem->m_SheetNameSize); + EXCHG(m_FileNameSize, copyitem->m_FileNameSize); + EXCHG(m_Label, copyitem->m_Label); + EXCHG(m_NbLabel, copyitem->m_NbLabel); +} + + /************************/ + /* DrawSheetLabelStruct */ + /************************/ + +/*******************************************************************/ +DrawSheetLabelStruct::DrawSheetLabelStruct(DrawSheetStruct * parent, + const wxPoint & pos, const wxString & text) : + EDA_BaseStruct(DRAW_SHEETLABEL_STRUCT_TYPE), + EDA_TextStruct(text) +/*******************************************************************/ +{ + m_Layer = LAYER_SHEETLABEL; + m_Parent = parent; + m_Pos = pos; + m_Edge = 0; + m_Shape = NET_INPUT; + m_IsDangling = TRUE; +} + +/***********************************************************/ +DrawSheetLabelStruct * DrawSheetLabelStruct::GenCopy(void) +/***********************************************************/ +{ +DrawSheetLabelStruct * newitem = + new DrawSheetLabelStruct( (DrawSheetStruct *)m_Parent, m_Pos, m_Text); + + newitem->m_Edge = m_Edge; + newitem->m_Shape = m_Shape; + + return newitem; +} diff --git a/eeschema/class_screen.cpp b/eeschema/class_screen.cpp new file mode 100644 index 0000000000..861d6f01f2 --- /dev/null +++ b/eeschema/class_screen.cpp @@ -0,0 +1,300 @@ +/**********************************************************/ +/* EECLASS.CPP */ +/* fonctions relatives aux classes definies dans EESCHEMA */ +/**********************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +/******************************************************************/ +void SetStructFather(EDA_BaseStruct * Struct, BASE_SCREEN * Screen) +/******************************************************************/ +{ + switch( Struct->m_StructType ) + { + case DRAW_POLYLINE_STRUCT_TYPE: + case DRAW_JUNCTION_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_LIB_ITEM_STRUCT_TYPE: + case DRAW_SEGMENT_STRUCT_TYPE: + case DRAW_BUSENTRY_STRUCT_TYPE: + case DRAW_SHEET_STRUCT_TYPE: + case DRAW_MARKER_STRUCT_TYPE: + case DRAW_NOCONNECT_STRUCT_TYPE: + Struct->m_Parent = Screen; + break; + + case DRAW_SHEETLABEL_STRUCT_TYPE: + case DRAW_PICK_ITEM_STRUCT_TYPE: + break; + + default: + break; + } +} + +/***************************************************************/ +void EDA_BaseStruct::Place(WinEDA_DrawFrame * frame, wxDC * DC) +/***************************************************************/ +/* place the struct in EEDrawList. + if it is a new item, it it also put in undo list + for an "old" item, saving it in undo list must be done before editiing, and not here! +*/ +{ + if( m_Flags & IS_NEW) + { + Pnext = frame->m_CurrentScreen->EEDrawList; + frame->m_CurrentScreen->EEDrawList = this; + g_ItemToRepeat = this; + if ( frame->m_Ident == SCHEMATIC_FRAME ) + ((WinEDA_SchematicFrame *)frame)->SaveCopyInUndoList(this, IS_NEW); + } + + m_Flags = 0; + frame->GetScreen()->SetModify(); + frame->GetScreen()->m_CurrentItem = NULL; + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; + + if ( DC ) + { + frame->DrawPanel->CursorOff(DC); // Erase schematic cursor + RedrawOneStruct(frame->DrawPanel, DC, this, GR_DEFAULT_DRAWMODE); + frame->DrawPanel->CursorOn(DC); // Display schematic cursor + } +} + + +/***********************************************************************/ +/* Class SCH_SCREEN: classe de gestion d'un affichage pour schematique */ +/***********************************************************************/ +static int table_zoom[] = {1,2,4,8,16,32,64,128, 0}; /* Valeurs standards du zoom */ + +/* Constructeur de SCREEN */ +SCH_SCREEN::SCH_SCREEN(int screentype): BASE_SCREEN(screentype) +{ + EEDrawList = NULL; /* Schematic items list */ + m_Zoom = 32; + m_Grid = wxSize(50,50); /* pas de la grille */ + SetZoomList(table_zoom); + SetGridList(g_GridList); + m_UndoRedoCountMax = 10; + +} + +/****************************/ +SCH_SCREEN::~SCH_SCREEN(void) +/****************************/ +{ + ClearUndoRedoList(); + FreeDrawList(); +} + + +/***********************************/ +void SCH_SCREEN::FreeDrawList(void) +/***********************************/ +/* Routine to clear (free) EESchema drawing list of a screen. +*/ +{ +EDA_BaseStruct *DrawStruct; + + while (EEDrawList != NULL) + { + DrawStruct = EEDrawList; + EEDrawList = EEDrawList->Pnext; + delete DrawStruct; + } +} + +/**************************************************************/ +void SCH_SCREEN::RemoveFromDrawList(EDA_BaseStruct *DrawStruct) +/**************************************************************/ +/* If found in EEDrawList, remove DrawStruct from EEDrawList. + DrawStruct is not deleted or modified +*/ +{ + if (DrawStruct == EEDrawList) + EEDrawList = EEDrawList->Pnext; + else + { + EDA_BaseStruct * DrawList = EEDrawList; + while (DrawList->Pnext) + { + if (DrawList->Pnext == DrawStruct) + { + DrawList->Pnext = DrawList->Pnext->Pnext; + break; + } + DrawList = DrawList->Pnext; + } + } +} + + +/*********************************************************************/ +/* Class EDA_ScreenList to handle the list of screens in a hierarchy */ +/*********************************************************************/ + +EDA_ScreenList::EDA_ScreenList(EDA_BaseStruct * DrawStruct) +/* create the list of screens (i.e hierarchycal sheets) found in DrawStruct +if DrawStruct == NULL: start from root sheet and the root screen is included in list +*/ +{ + m_Count = 0; + m_List = NULL; + m_Index = 0; + + /* Count the number of screens */ + BuildScreenList(NULL, DrawStruct, & m_Count); + if( m_Count > NB_MAX_SHEET ) + { + wxString msg; + msg.Printf(wxT("ReturnScreenList: Error: screen count > %d"), NB_MAX_SHEET); + DisplayError(NULL, msg); + } + + + m_List = (SCH_SCREEN **) MyZMalloc( sizeof(SCH_SCREEN *) * (m_Count + 2) ); + /* Fill the list */ + BuildScreenList(m_List, DrawStruct, & m_Count); +} + +/*****************************************/ +EDA_ScreenList::~EDA_ScreenList() +/*****************************************/ +{ + if ( m_List ) free( m_List ); + m_List = NULL; +} + +/*****************************************/ +SCH_SCREEN * EDA_ScreenList::GetFirst(void) +/*****************************************/ +{ + m_Index = 0; + if ( m_List ) return * m_List; + else return NULL; +} + +/*****************************************/ +SCH_SCREEN * EDA_ScreenList::GetNext(void) +/*****************************************/ +{ + if (m_Index < m_Count) m_Index ++; + + if ( (m_Index < m_Count) && m_List ) + { + return m_List[m_Index]; + } + else return NULL; +} + +/************************************************/ +SCH_SCREEN * EDA_ScreenList::GetScreen(int index) +/************************************************/ +/* return the m_List[index] item +*/ +{ +SCH_SCREEN * screen = NULL; + + if( (index >= 0) && index < m_Count ) + screen = m_List[index]; + + return screen; +} + +/**************************************************/ +void EDA_ScreenList::UpdateSheetNumberAndDate(void) +/**************************************************/ +/* Update the sheet number, the sheet count and the date for all sheets in list +*/ +{ +int SheetNumber = 1; +SCH_SCREEN * screen; +wxString sheet_date = GenDate(); + + for ( screen = GetFirst(); screen != NULL; screen = GetNext() ) + { + screen->m_SheetNumber = SheetNumber++; /* Update the sheet number */ + screen->m_NumberOfSheet = m_Count; /* Update the number of sheets */ + screen->m_Date = sheet_date; /* Update the sheet date */ + } +} + +/************************************************************************/ +SCH_SCREEN ** EDA_ScreenList::BuildScreenList(SCH_SCREEN ** ScreenList, + EDA_BaseStruct * DrawStruct, int * Count) +/************************************************************************/ +/* Count the Hierachical sheet number (ScreenList == NULL ) + or fill the screen pointer buffer (ScreenList != NULL ) + If DrawStruct = NULL, search starts from Root screen, and puts root screen in list + Recursive function ! +*/ +{ +bool HasSubhierarchy = FALSE; +EDA_BaseStruct * CurrStruct; + + if( * Count > NB_MAX_SHEET ) + { + return ScreenList; + } + + /* Read the current list and put Screen pointers in list */ + if ( DrawStruct == NULL ) + { + DrawStruct = ScreenSch->EEDrawList; + if ( ScreenList ) + { + *ScreenList = ScreenSch; + ScreenList++; + } + else (*Count)++; + } + + CurrStruct = DrawStruct; + while( CurrStruct ) + { + if(CurrStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE ) + { + HasSubhierarchy = TRUE; + if ( ScreenList ) + { + *ScreenList = (SCH_SCREEN*) CurrStruct; + ScreenList++; + } + else (*Count)++; + } + CurrStruct = CurrStruct->Pnext; + } + + if ( ! HasSubhierarchy ) return ScreenList; + + /* Read the Sub Hierarchies */ + CurrStruct = DrawStruct; + while( CurrStruct ) + { + if(CurrStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE ) + { + SCH_SCREEN* Screen = (SCH_SCREEN*) CurrStruct; + /* Go to Subhierachy if needed + (warning: BuildScreenList must not called with a NULL parameter + for DrawStruct, because BuildScreenList restart from the root screen + when DrawStruct == NULL */ + if ( Screen->EEDrawList ) + ScreenList = BuildScreenList(ScreenList, Screen->EEDrawList,Count); + } + CurrStruct = CurrStruct->Pnext; + } + return ScreenList; +} + diff --git a/eeschema/class_screen.h b/eeschema/class_screen.h new file mode 100644 index 0000000000..2d049f8f14 --- /dev/null +++ b/eeschema/class_screen.h @@ -0,0 +1,177 @@ + /********************************************/ + /* Definitions for the EESchema program: */ + /********************************************/ + +#ifndef CLASS_SCREEN_H +#define CLASS_SCREEN_H + +#ifndef eda_global +#define eda_global extern +#endif + +#include "macros.h" +#include "base_struct.h" + +/* Max number of sheets in a hierarchy project: */ +#define NB_MAX_SHEET 500 + + +/* Type des labels sur sheet (Labels sur hierarchie) et forme des Global-Labels*/ +typedef enum { + NET_INPUT, + NET_OUTPUT, + NET_BIDI, + NET_TRISTATE, + NET_UNSPECIFIED, + NET_TMAX /* Derniere valeur: fin de tableau */ +} TypeSheetLabel; + +/* Messages correspondants aux types ou forme des labels */ +#ifdef MAIN +const char * SheetLabelType[] = + { + "Input", + "Output", + "BiDi", + "3State", + "UnSpc", + "?????" + }; +#else +extern const char * SheetLabelType[]; +#endif + +/* Description du graphisme des icones associes aux types des Global_Labels */ +#ifdef MAIN +int TemplateIN_HN[] = {6, 0,0, -1,-1, -2,-1, -2,1, -1,1, 0,0}; +int TemplateIN_HI[] = {6, 0,0, 1,1, 2,1, 2,-1, 1,-1, 0,0}; +int TemplateIN_BOTTOM[] = {6, 0,0, 1,-1, 1,-2, -1,-2, -1,-1, 0,0}; +int TemplateIN_UP[] = {6, 0,0, 1,1, 1,2, -1,2, -1,1, 0,0}; + +int TemplateOUT_HN[] = {6, -2,0, -1,1, 0,1, 0,-1, -1,-1, -2,0}; +int TemplateOUT_HI[] = {6, 2,0, 1,-1, 0,-1, 0,1, 1,1, 2,0}; +int TemplateOUT_BOTTOM[] = {6, 0,-2, 1,-1, 1,0, -1,0, -1,-1, 0,-2}; +int TemplateOUT_UP[] = {6, 0,2, 1,1, 1,0, -1,0, -1,1, 0,2}; + +int TemplateUNSPC_HN[] = {5, 0,-1, -2,-1, -2,1, 0,1, 0,-1}; +int TemplateUNSPC_HI[] = {5, 0,-1, 2,-1, 2,1, 0,1, 0,-1}; +int TemplateUNSPC_BOTTOM[] = {5, 1,0, 1,-2, -1,-2, -1,0, 1,0}; +int TemplateUNSPC_UP[] = {5, 1,0, 1,2, -1,2, -1,0, 1,0}; + +int TemplateBIDI_HN[] = {5, 0,0, -1,-1, -2,0, -1,1, 0,0}; +int TemplateBIDI_HI[] = {5, 0,0, 1,-1, 2,0, 1,1, 0,0}; +int TemplateBIDI_BOTTOM[] = {5, 0,0, -1,-1, 0,-2, 1,-1, 0,0}; +int TemplateBIDI_UP[] = {5, 0,0, -1, 1, 0, 2, 1, 1, 0,0}; + +int Template3STATE_HN[] = {5, 0,0, -1,-1, -2,0, -1,1, 0,0}; +int Template3STATE_HI[] = {5, 0,0, 1,-1, 2,0, 1,1, 0,0}; +int Template3STATE_BOTTOM[] = {5, 0,0, -1,-1, 0,-2, 1,-1, 0,0}; +int Template3STATE_UP[] = {5, 0,0, -1,1, 0,2, 1,1, 0,0}; + +int * TemplateShape[5][4] = + { + {TemplateIN_HN,TemplateIN_UP,TemplateIN_HI,TemplateIN_BOTTOM}, + {TemplateOUT_HN,TemplateOUT_UP,TemplateOUT_HI,TemplateOUT_BOTTOM}, + {TemplateBIDI_HN,TemplateBIDI_UP,TemplateBIDI_HI,TemplateBIDI_BOTTOM}, + {Template3STATE_HN,Template3STATE_UP,Template3STATE_HI,Template3STATE_BOTTOM}, + {TemplateUNSPC_HN,TemplateUNSPC_UP,TemplateUNSPC_HI,TemplateUNSPC_BOTTOM} + }; +#else +extern int * TemplateShape[5][4]; +#endif + + +/* Forward declarations */ +class DrawSheetStruct; + + +class SCH_SCREEN: public BASE_SCREEN +{ + +public: + SCH_SCREEN(int idtype); + ~SCH_SCREEN(); + + void FreeDrawList(void); // Free EESchema drawing list (does not delete the sub hierarchies) + void Place(WinEDA_DrawFrame * frame, wxDC * DC) {}; + void RemoveFromDrawList(EDA_BaseStruct *DrawStruct);/* remove DrawStruct from EEDrawList. */ + void ClearUndoORRedoList(EDA_BaseStruct *List); + + bool SchematicCleanUp( wxDC * DC = NULL ); + EDA_BaseStruct * ExtractWires(bool CreateCopy); + + /* full undo redo management : */ + virtual void ClearUndoRedoList(void); + virtual void AddItemToUndoList(EDA_BaseStruct * item); + virtual void AddItemToRedoList(EDA_BaseStruct * item); +}; + + + +class DrawSheetLabelStruct: public EDA_BaseStruct, public EDA_TextStruct +{ +public: + int m_Edge, m_Shape; + bool m_IsDangling; // TRUE si non connecté + +public: + DrawSheetLabelStruct(DrawSheetStruct * parent, + const wxPoint & pos = wxPoint(0,0), const wxString & text = wxEmptyString); + ~DrawSheetLabelStruct(void) {} + DrawSheetLabelStruct * GenCopy(void); + DrawSheetLabelStruct * Next(void) + { return (DrawSheetLabelStruct *) Pnext;} + void Place(WinEDA_DrawFrame * frame, wxDC * DC); + virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); +}; + + +class DrawSheetStruct: public SCH_SCREEN /* Gestion de la hierarchie */ +{ +public: + wxString m_SheetName; + int m_SheetNameSize; +// wxString m_FileName; in SCH_SCREEN + int m_FileNameSize; + wxPoint m_Pos; + wxSize m_Size; /* Position and Size of sheet symbol */ + int m_Layer; + DrawSheetLabelStruct *m_Label; /* Points de connection */ + int m_NbLabel; /* Nombre de points de connexion */ + +public: + DrawSheetStruct(const wxPoint & pos = wxPoint(0,0) ); + ~DrawSheetStruct(void); + void Place(WinEDA_DrawFrame * frame, wxDC * DC); + DrawSheetStruct * GenCopy(void); + void Display_Infos(WinEDA_DrawFrame * frame); + void CleanupSheet(WinEDA_SchematicFrame * frame, wxDC *DC); + virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); + void SwapData(DrawSheetStruct * copyitem); +}; + + +/* Class to handle the list of screens in a hierarchy */ +class EDA_ScreenList +{ +private: + int m_Count; + SCH_SCREEN ** m_List; + int m_Index; + +public: + EDA_ScreenList(EDA_BaseStruct * DrawStruct); + ~EDA_ScreenList(); + int GetCount(void) { return m_Count; } + SCH_SCREEN * GetFirst(void); + SCH_SCREEN * GetNext(void); + SCH_SCREEN * GetScreen(int index); + void UpdateSheetNumberAndDate(void); + +private: + SCH_SCREEN ** BuildScreenList(SCH_SCREEN ** ScreenList, + EDA_BaseStruct * DrawStruct, int * Count); +}; + +#endif /* CLASS_SCREEN_H */ + diff --git a/eeschema/class_text-label.cpp b/eeschema/class_text-label.cpp new file mode 100644 index 0000000000..c4c0e9da3b --- /dev/null +++ b/eeschema/class_text-label.cpp @@ -0,0 +1,262 @@ +/***********************************************************************/ +/* Methodes de base de gestion des classes des elements de schematique */ +/***********************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "id.h" + +#include "protos.h" + + + /************************/ + /* class DrawTextStruct */ + /* class DrawLabelStruct */ + /* class DrawGlobalLabelStruct */ + /************************/ + +/**************************************************************************/ +DrawTextStruct::DrawTextStruct(const wxPoint & pos, const wxString & text): + EDA_BaseStruct(DRAW_TEXT_STRUCT_TYPE), + EDA_TextStruct(text) +/**************************************************************************/ +{ + m_Layer = LAYER_NOTES; + m_Pos = pos; + m_Shape = 0; + m_IsDangling = FALSE; +} + +/*********************************************/ +DrawTextStruct * DrawTextStruct::GenCopy(void) +/*********************************************/ +{ +DrawTextStruct * newitem = new DrawTextStruct(m_Pos, m_Text); + + newitem->m_StructType = m_StructType; + newitem->m_Layer = m_Layer; + newitem->m_Shape = m_Shape; + newitem->m_Orient = m_Orient; + newitem->m_Size = m_Size; + newitem->m_HJustify = m_HJustify; + newitem->m_VJustify = m_VJustify; + newitem->m_IsDangling = m_IsDangling ; + + return newitem; +} + + +/********************************************************/ +void DrawTextStruct::SwapData(DrawTextStruct * copyitem) +/********************************************************/ +{ + EXCHG(m_Text, copyitem->m_Text); + EXCHG(m_Pos, copyitem->m_Pos); + EXCHG(m_Size, copyitem->m_Size); + EXCHG(m_Shape, copyitem->m_Shape); + EXCHG(m_Orient, copyitem->m_Orient); + EXCHG(m_StructType, copyitem->m_StructType); + EXCHG(m_Layer, copyitem->m_Layer); + EXCHG(m_HJustify, copyitem->m_HJustify); + EXCHG(m_VJustify, copyitem->m_VJustify); + EXCHG(m_IsDangling, copyitem->m_IsDangling); +} + +/***************************************************************/ +void DrawTextStruct::Place(WinEDA_DrawFrame * frame, wxDC * DC) +/***************************************************************/ +{ + /* save old text in undo list */ + if ( g_ItemToUndoCopy && ((m_Flags & IS_NEW) == 0) ) + { + /* restore old values and save new ones */ + SwapData( (DrawTextStruct*)g_ItemToUndoCopy); + /* save in undo list */ + ((WinEDA_SchematicFrame*)frame)->SaveCopyInUndoList(this, IS_CHANGED); + /* restore new values */ + SwapData((DrawTextStruct*)g_ItemToUndoCopy); + delete g_ItemToUndoCopy; + g_ItemToUndoCopy = NULL; + } + + EDA_BaseStruct::Place(frame, DC); +} + + +/****************************************************************************/ +DrawLabelStruct::DrawLabelStruct(const wxPoint & pos, const wxString & text): + DrawTextStruct(pos, text) +/****************************************************************************/ +{ + m_StructType = DRAW_LABEL_STRUCT_TYPE; + m_Layer = LAYER_LOCLABEL; + m_IsDangling = TRUE; +} + + +/***********************************************************************************/ +DrawGlobalLabelStruct::DrawGlobalLabelStruct(const wxPoint & pos, const wxString & text): + DrawTextStruct(pos, text) +/***********************************************************************************/ +{ + m_StructType = DRAW_GLOBAL_LABEL_STRUCT_TYPE; + m_Layer = LAYER_GLOBLABEL; + m_Shape = NET_INPUT; + m_IsDangling = TRUE; +} + + +/***************************************************************/ +void DrawTextStruct::Draw(WinEDA_DrawPanel * panel,wxDC * DC, const wxPoint & offset, + int DrawMode, int Color) +/***************************************************************/ +/* Les textes type label ou notes peuvent avoir 4 directions, mais + sont tj cadres par rapport a la 1ere lettre du texte +*/ +{ + switch ( m_StructType ) + { + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + DrawAsGlobalLabel(panel, DC, offset, DrawMode, Color); + break; + + case DRAW_LABEL_STRUCT_TYPE: + DrawAsLabel(panel, DC, offset, DrawMode, Color); + break; + + default: + DrawAsText(panel, DC, offset, DrawMode, Color); + } +} + +/***************************************************************/ +void DrawTextStruct::DrawAsText(WinEDA_DrawPanel * panel,wxDC * DC, const wxPoint & offset, + int DrawMode, int Color) +/***************************************************************/ +/* Les textes type label ou notes peuvent avoir 4 directions, mais + sont tj cadres par rapport a la 1ere lettre du texte +*/ +{ +int color; + + if( Color >= 0 ) color = Color; + else color = ReturnLayerColor(m_Layer); + GRSetDrawMode(DC, DrawMode); + + switch(m_Orient) + { + case 0: /* Orientation horiz normale */ + DrawGraphicText(panel, DC, + wxPoint(m_Pos.x + offset.x, m_Pos.y - TXTMARGE + offset.y), + color, + m_Text, m_Orient*900, m_Size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM); + break; + + case 1: /* Orientation vert UP */ + DrawGraphicText(panel, DC, + wxPoint(m_Pos.x - TXTMARGE + offset.x, m_Pos.y + offset.y), color, + m_Text, m_Orient*900, m_Size, + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM); + break; + + case 2: /* Orientation horiz inverse */ + DrawGraphicText(panel, DC, + wxPoint(m_Pos.x + offset.x, m_Pos.y + TXTMARGE + offset.y), color, + m_Text, m_Orient*900, m_Size, + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_TOP); + break; + + case 3: /* Orientation vert BOTTOM */ + DrawGraphicText(panel, DC, + wxPoint(m_Pos.x + TXTMARGE + offset.y, m_Pos.y + offset.y), color, + m_Text, m_Orient*900, m_Size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP); + break; + } + if ( m_IsDangling ) + DrawDanglingSymbol(panel, DC, m_Pos + offset, color); +} + +/***************************************************************/ +void DrawTextStruct::DrawAsLabel(WinEDA_DrawPanel * panel,wxDC * DC, const wxPoint & offset, + int DrawMode, int Color) +/***************************************************************/ +{ + DrawAsText(panel, DC, offset, DrawMode, Color); +} + +/*****************************************************************************/ +void DrawTextStruct::DrawAsGlobalLabel(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint& offset, + int DrawMode, int Color) +/*****************************************************************************/ +/* Les textes type Global label peuvent avoir 4 directions, mais + sont tj cadres par rapport au symbole graphique (icone) +*/ +{ +int * Template; +int Poly[12]; +int ii, jj, imax, color, HalfSize; +wxSize Size = m_Size; + + if( Color >= 0 ) color = Color; + else color = ReturnLayerColor(m_Layer); + + GRSetDrawMode(DC, DrawMode); + + HalfSize = Size.x / 2; ii = Size.x + TXTMARGE; + + switch(m_Orient) + { + case 0: /* Orientation horiz normale */ + DrawGraphicText(panel, DC, + wxPoint(m_Pos.x - ii + offset.x, m_Pos.y + offset.y), color, + m_Text, TEXT_ORIENT_HORIZ, Size, + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER); + break; + + case 1: /* Orientation vert UP */ + DrawGraphicText(panel, DC, + wxPoint(m_Pos.x + offset.x, m_Pos.y + ii + offset.y), color, + m_Text, TEXT_ORIENT_VERT, Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP); + break; + + case 2: /* Orientation horiz inverse */ + DrawGraphicText(panel, DC, + wxPoint(m_Pos.x + ii + offset.x, m_Pos.y + offset.y), color, + m_Text, TEXT_ORIENT_HORIZ, Size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + break; + + case 3: /* Orientation vert BOTTOM */ + DrawGraphicText(panel, DC, + wxPoint(m_Pos.x + offset.x, m_Pos.y - ii + offset.y), color, + m_Text, TEXT_ORIENT_VERT, Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM); + break; + } + + + Template = TemplateShape[m_Shape][m_Orient]; + + imax = *Template; Template++; + for ( ii = 0, jj = 0; ii < imax ; ii++ ) + { + Poly[jj] = ( HalfSize * (*Template) ) + m_Pos.x + offset.x; + jj++; Template++; + Poly[jj] = ( HalfSize * (*Template) ) + m_Pos.y + offset.y; + jj++; Template++; + } + +// GRPoly(&panel->m_ClipBox, DC, imax,Poly,1, color, color ); /* Polygne Rempli */ + GRPoly(&panel->m_ClipBox, DC, imax,Poly,0, color, color ); /* Polygne Non Rempli */ + + if ( m_IsDangling ) + DrawDanglingSymbol(panel, DC, m_Pos + offset, color); +} diff --git a/eeschema/cleanup.cpp b/eeschema/cleanup.cpp new file mode 100644 index 0000000000..31912d1637 --- /dev/null +++ b/eeschema/cleanup.cpp @@ -0,0 +1,257 @@ + /*********************************/ + /* Module de nettoyage du schema */ + /*********************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "netlist.h" +#include "macros.h" +#include "protos.h" + + +/* Routines locales */ +static int TstAlignSegment(EDA_DrawLineStruct* RefSegm, EDA_DrawLineStruct* TstSegm); + +/* Variable locales */ + + +/*******************************************/ +bool SCH_SCREEN::SchematicCleanUp(wxDC * DC) +/*******************************************/ +/* Routine de nettoyage: + - regroupe les segments de fils (ou de bus) alignes en 1 seul segment + - Detecte les objets identiques superposes +*/ +{ +EDA_BaseStruct *DrawList, * TstDrawList; +int flag; +bool Modify = FALSE; + + DrawList = EEDrawList; + for ( ;DrawList != NULL; DrawList = DrawList->Pnext ) + { + if( DrawList->m_StructType == DRAW_SEGMENT_STRUCT_TYPE ) + { + TstDrawList = DrawList->Pnext; + while ( TstDrawList ) + { + if( TstDrawList->m_StructType == DRAW_SEGMENT_STRUCT_TYPE ) + { + flag = TstAlignSegment( (EDA_DrawLineStruct*)DrawList, + (EDA_DrawLineStruct*)TstDrawList); + if (flag ) /* Suppression de TstSegm */ + { + /* keep the bits set in .m_Flags, because the deleted segment can be flagged */ + DrawList->m_Flags |= TstDrawList->m_Flags; + EraseStruct(TstDrawList, this); + SetRefreshReq(); + TstDrawList = EEDrawList; + Modify = TRUE; + } + else TstDrawList = TstDrawList->Pnext; + } + else TstDrawList = TstDrawList->Pnext; + } + } + } + EDA_Appl->SchematicFrame->TestDanglingEnds(EEDrawList, DC); + return Modify; +} + + +/***********************************************/ +void BreakSegmentOnJunction( SCH_SCREEN * Screen ) +/************************************************/ +/* Routine creant des debuts / fin de segment (BUS ou WIRES) sur les jonctions +et les raccords +*/ +{ +EDA_BaseStruct *DrawList; + + if( Screen == NULL ) + { + DisplayError(NULL, wxT("BreakSegmentOnJunction() error: NULL screen")); + return; + } + + DrawList = Screen->EEDrawList; + while ( DrawList ) + { + switch( DrawList->m_StructType ) + { + case DRAW_JUNCTION_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((DrawJunctionStruct*)DrawList) + BreakSegment(Screen, STRUCT->m_Pos); + break; + + case DRAW_BUSENTRY_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((DrawBusEntryStruct*)DrawList) + BreakSegment(Screen, STRUCT->m_Pos); + BreakSegment(Screen, STRUCT->m_End()); + break; + + case DRAW_SEGMENT_STRUCT_TYPE : + case DRAW_NOCONNECT_STRUCT_TYPE : + case DRAW_LABEL_STRUCT_TYPE : + case DRAW_GLOBAL_LABEL_STRUCT_TYPE : + case DRAW_LIB_ITEM_STRUCT_TYPE : + case DRAW_PICK_ITEM_STRUCT_TYPE : + case DRAW_POLYLINE_STRUCT_TYPE : + case DRAW_MARKER_STRUCT_TYPE : + case DRAW_TEXT_STRUCT_TYPE : + case DRAW_SHEET_STRUCT_TYPE : + case DRAW_SHEETLABEL_STRUCT_TYPE : + break; + + default : + break; + } + DrawList = DrawList->Pnext; + } +} + + +/*********************************************************/ +DrawPickedStruct * BreakSegment(SCH_SCREEN * screen, + wxPoint breakpoint, bool PutInUndoList) +/*********************************************************/ +/* Coupe un segment ( BUS, WIRE ) en 2 au point breakpoint, + - si ce point est sur le segment + - extremites non comprises + If PutInUndoList == TRUE, create a list of modifictions, for undo command +*/ +{ +EDA_BaseStruct *DrawList; +EDA_DrawLineStruct * segment, * NewSegment; +int ox, oy, fx, fy; +DrawPickedStruct * List = NULL; + + DrawList = screen->EEDrawList; + while ( DrawList ) + { + switch( DrawList->m_StructType ) + { + case DRAW_SEGMENT_STRUCT_TYPE : + segment = (EDA_DrawLineStruct*)DrawList; + ox = segment->m_Start.x; oy = segment->m_Start.y; + fx = segment->m_End.x; fy = segment->m_End.y; + if( distance( fx - ox, fy - oy, breakpoint.x - ox, breakpoint.y - oy, 0 ) == 0 ) + break; + /* Segment connecte: doit etre coupe en 2 si px,py n'est + pas une extremite */ + if( (ox == breakpoint.x) && (oy == breakpoint.y ) ) break; + if( (fx == breakpoint.x) && (fy == breakpoint.y ) ) break; + /* Ici il faut couper le segment en 2 */ + if ( PutInUndoList ) // First: put copy of the old segment in undo list + { + DrawPickedStruct * wrapper = new DrawPickedStruct(); + wrapper->m_Flags = IS_CHANGED; + wrapper->m_PickedStruct = segment->GenCopy(); + wrapper->m_Image = segment; + wrapper->m_PickedStruct->m_Image = segment; + wrapper->Pnext = List; + List = wrapper; + } + NewSegment = segment->GenCopy(); + NewSegment->m_Start = breakpoint; + segment->m_End = NewSegment->m_Start; + NewSegment->Pnext = segment->Pnext; + segment->Pnext = NewSegment; + DrawList = NewSegment; + if ( PutInUndoList ) + { + DrawPickedStruct * wrapper = new DrawPickedStruct(); + wrapper->m_Flags = IS_NEW; + wrapper->m_Image = NewSegment; + wrapper->Pnext = List; + List = wrapper; + } + break; + + case DRAW_JUNCTION_STRUCT_TYPE : + case DRAW_BUSENTRY_STRUCT_TYPE : + case DRAW_POLYLINE_STRUCT_TYPE : + break; + + default : + break; + } + DrawList = DrawList->Pnext; + } + + return List; +} + + + +/***********************************************************/ +static int TstAlignSegment( EDA_DrawLineStruct* RefSegm, + EDA_DrawLineStruct* TstSegm) +/***********************************************************/ + +/* Search if the 2 segments RefSegm and TstSegm are on a line. + Retourn 0 if no + 1 if yes, and RefSegm is modified to be the equivalent segment +*/ +{ + if( RefSegm == TstSegm ) return(0); + if( RefSegm->m_Layer != TstSegm->m_Layer ) return(0); + + // search for a common end, and modify coordinates to ensure RefSegm->m_End == TstSegm->m_Start + if ( RefSegm->m_Start == TstSegm->m_Start ) + { + if ( RefSegm->m_End == TstSegm->m_End ) // trivial case: RefSegm and TstSegm are identical + return 1; + EXCHG(RefSegm->m_Start, RefSegm->m_End); // at this point, RefSegm->m_End == TstSegm->m_Start + } + else if ( RefSegm->m_Start == TstSegm->m_End ) + { + EXCHG(RefSegm->m_Start, RefSegm->m_End); + EXCHG(TstSegm->m_Start, TstSegm->m_End); // at this point, RefSegm->m_End == TstSegm->m_Start + } + else if ( RefSegm->m_End == TstSegm->m_End ) + { + EXCHG(TstSegm->m_Start, TstSegm->m_End); // at this point, RefSegm->m_End == TstSegm->m_Start + } + else if ( RefSegm->m_End != TstSegm->m_Start ) // No common end point, segments cannot be merged + return 0; + + /* Test alignment: */ + if ( RefSegm->m_Start.y == RefSegm->m_End.y ) // Horizontal segment + { + if ( TstSegm->m_Start.y == TstSegm->m_End.y ) + { + RefSegm->m_End = TstSegm->m_End; + return 1; + } + } + + else if ( RefSegm->m_Start.x == RefSegm->m_End.x ) // Vertical segment + { + if ( TstSegm->m_Start.x == TstSegm->m_End.x ) + { + RefSegm->m_End = TstSegm->m_End; + return 1; + } + } + + else + { + if (atan2(RefSegm->m_Start.x - RefSegm->m_End.x, RefSegm->m_Start.y - RefSegm->m_End.y) == + atan2(TstSegm->m_Start.x - TstSegm->m_End.x, TstSegm->m_Start.y - TstSegm->m_End.y) ) + { + RefSegm->m_End = TstSegm->m_End; + return 1; + } + } + + return(0); +} + diff --git a/eeschema/cmpclass.cpp b/eeschema/cmpclass.cpp new file mode 100644 index 0000000000..846f2b4e16 --- /dev/null +++ b/eeschema/cmpclass.cpp @@ -0,0 +1,249 @@ +/***********************************************************************/ +/* Methodes de base de gestion des classes des elements de schematique */ +/***********************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "id.h" + +#include "protos.h" + + + +/*******************************************************************/ +DrawBusEntryStruct::DrawBusEntryStruct(const wxPoint & pos, int shape, int id) : + EDA_BaseStruct(DRAW_BUSENTRY_STRUCT_TYPE) +/*******************************************************************/ +{ + + m_Pos = pos; + m_Size.x = 100; + m_Size.y = 100; + m_Layer = LAYER_WIRE; + m_Width = 0; + + if( id == BUS_TO_BUS ) + { + m_Layer = LAYER_BUS; + m_Width = 1; + } + + if(shape == '/' ) m_Size.y = - 100; + +} + + +/*************************************/ +wxPoint DrawBusEntryStruct::m_End(void) +/*************************************/ +// retourne la coord de fin du raccord +{ + return ( wxPoint(m_Pos.x + m_Size.x, m_Pos.y + m_Size.y) ); +} + +/***************************************************/ +DrawBusEntryStruct * DrawBusEntryStruct::GenCopy(void) +/***************************************************/ +{ +DrawBusEntryStruct * newitem = new DrawBusEntryStruct(m_Pos,0,0); + + newitem->m_Layer = m_Layer; + newitem->m_Width = m_Width; + newitem->m_Size = m_Size; + newitem->m_Flags = m_Flags; + + return newitem; +} + + + /****************************/ + /* class DrawJunctionStruct */ + /***************************/ + +/************************************************************/ +DrawJunctionStruct::DrawJunctionStruct(const wxPoint & pos) : + EDA_BaseStruct(DRAW_JUNCTION_STRUCT_TYPE) +/************************************************************/ +{ + m_Pos = pos; + m_Layer = LAYER_JUNCTION; +} + +DrawJunctionStruct * DrawJunctionStruct::GenCopy(void) +{ +DrawJunctionStruct * newitem = new DrawJunctionStruct(m_Pos); + + newitem->m_Layer = m_Layer; + newitem->m_Flags = m_Flags; + + return newitem; +} + + + /*****************************/ + /* class DrawNoConnectStruct */ + /*****************************/ + +DrawNoConnectStruct::DrawNoConnectStruct(const wxPoint & pos) : + EDA_BaseStruct(DRAW_NOCONNECT_STRUCT_TYPE) +{ + m_Pos = pos; +} + +DrawNoConnectStruct * DrawNoConnectStruct::GenCopy(void) +{ +DrawNoConnectStruct * newitem = new DrawNoConnectStruct(m_Pos); + + newitem->m_Flags = m_Flags; + + return newitem; +} + + + /**************************/ + /* class DrawMarkerStruct */ + /**************************/ + +DrawMarkerStruct::DrawMarkerStruct( const wxPoint & pos, const wxString & text): + EDA_BaseStruct(DRAW_MARKER_STRUCT_TYPE) +{ + m_Pos = pos; /* XY coordinates of marker. */ + m_Type = MARQ_UNSPEC; + m_MarkFlags = 0; // complements d'information + m_Comment = text; +} + +DrawMarkerStruct::~DrawMarkerStruct(void) +{ +} + +DrawMarkerStruct * DrawMarkerStruct::GenCopy(void) +{ +DrawMarkerStruct * newitem = new DrawMarkerStruct( m_Pos, m_Comment); + newitem->m_Type = m_Type; + newitem->m_MarkFlags = m_MarkFlags; + + return newitem; +} + + +wxString DrawMarkerStruct::GetComment(void) +{ + return m_Comment; +} + + + /***************************/ + /* Class EDA_DrawLineStruct */ + /***************************/ + +EDA_DrawLineStruct::EDA_DrawLineStruct(const wxPoint & pos, int layer ): + EDA_BaseLineStruct(NULL, DRAW_SEGMENT_STRUCT_TYPE) +{ + m_Start = pos; + m_End = pos; + m_StartIsDangling = m_EndIsDangling = FALSE; + + switch(layer) + { + default: + m_Layer = LAYER_NOTES; /* Mettre ds Notes */ + m_Width = GR_NORM_WIDTH; + break; + + case LAYER_WIRE: + m_Layer = LAYER_WIRE; + m_Width = GR_NORM_WIDTH; + break; + case LAYER_BUS: + m_Layer = LAYER_BUS; + m_Width = GR_THICK_WIDTH; + break; + } +} + +/***************************************************/ +EDA_DrawLineStruct * EDA_DrawLineStruct::GenCopy(void) +/***************************************************/ +{ +EDA_DrawLineStruct * newitem = new EDA_DrawLineStruct(m_Start, m_Layer); + + newitem->m_End = m_End; + + return newitem; +} + +/************************************************************/ +bool EDA_DrawLineStruct::IsOneEndPointAt(const wxPoint & pos) +/************************************************************/ +/* Return TRUE if the start or the end point is in position pos +*/ +{ + if ( (pos.x == m_Start.x) && (pos.y == m_Start.y) ) return TRUE; + if ( (pos.x == m_End.x) && (pos.y == m_End.y) ) return TRUE; + return FALSE; +} + + /****************************/ + /* Class DrawPolylineStruct */ + /****************************/ + +/***********************************************************/ +DrawPolylineStruct::DrawPolylineStruct(int layer): + EDA_BaseStruct(DRAW_POLYLINE_STRUCT_TYPE) +/***********************************************************/ +{ + m_NumOfPoints = 0; /* Number of XY pairs in Points array. */ + m_Points = NULL; /* XY pairs that forms the polyline. */ + m_Width = GR_NORM_WIDTH; + + switch ( layer ) + { + default: + m_Layer = LAYER_NOTES; + break; + + case LAYER_WIRE: + case LAYER_NOTES: + m_Layer = layer; + break; + + case LAYER_BUS: + m_Layer = layer; + m_Width = GR_THICK_WIDTH; + break; + } +} + + +/********************************************/ +DrawPolylineStruct::~DrawPolylineStruct(void) +/*********************************************/ +{ + if ( m_Points ) free ( m_Points ); +} + +/*****************************************************/ +DrawPolylineStruct * DrawPolylineStruct::GenCopy(void) +/*****************************************************/ +{ +int memsize; + +DrawPolylineStruct * newitem = + new DrawPolylineStruct( m_Layer ); + + memsize = sizeof(int) * 2 * m_NumOfPoints; + newitem->m_NumOfPoints = m_NumOfPoints; + newitem->m_Points = (int *) MyZMalloc(memsize); + memcpy ( newitem->m_Points, m_Points, memsize); + + return newitem; +} + + + diff --git a/eeschema/component_class.cpp b/eeschema/component_class.cpp new file mode 100644 index 0000000000..1678c8f72f --- /dev/null +++ b/eeschema/component_class.cpp @@ -0,0 +1,633 @@ +/***********************************************************************/ +/* Methodes de base de gestion des classes des elements de schematique */ +/***********************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "macros.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "id.h" + +#include "protos.h" + +#include "macros.h" + + + /***************************/ + /* class DrawPartStruct */ + /* class EDA_SchComponentStruct */ + /***************************/ + +/***********************************************************************************/ +DrawPartStruct::DrawPartStruct( DrawStructureType struct_type, const wxPoint & pos): + EDA_BaseStruct(struct_type) +/***********************************************************************************/ +{ + m_Pos = pos; + m_TimeStamp = 0; +} + +/************************************/ +DrawPartStruct::~DrawPartStruct(void) +/************************************/ +{ +} + +/****************************************************************/ +wxString ReturnDefaultFieldName(int FieldNumber) +/****************************************************************/ +/* Return the defult ield name from its number (REFERENCE, VALUE ..) + FieldDefaultNameList is not static, because we want the text translation + for I18n +*/ +{ +wxString FieldDefaultNameList[] = { + _("Ref"), /* Reference of part, i.e. "IC21" */ + _("Value"), /* Value of part, i.e. "3.3K" */ + _("Footprint"), /* Footprint, used by cvpcb or pcbnew, i.e. "16DIP300" */ + _("Sheet"), /* for components which are a schematic file, schematic file name, i.e. "cnt16.sch" */ + _("Field") /* User fields (1 to n) have an editable name*/ + }; +int ii = FieldNumber; + if ( ii > FIELD1 ) ii = FIELD1; +wxString FieldName = FieldDefaultNameList[ii]; + + if (FieldNumber >= FIELD1 ) FieldName << (FieldNumber - FIELD1 + 1); + return FieldName; +} + + +/****************************************************************/ +wxString EDA_SchComponentStruct::ReturnFieldName(int FieldNumber) +/****************************************************************/ +/* Return the Field name from its number (REFERENCE, VALUE ..) +*/ +{ +wxString FieldName = m_Field[FieldNumber].m_Name; + + if ( (FieldNumber < FIELD1) || FieldName.IsEmpty() ) + FieldName = ReturnDefaultFieldName(FieldNumber); + return FieldName; +} + + +/*******************************************************************/ +EDA_SchComponentStruct::EDA_SchComponentStruct(const wxPoint & pos): + DrawPartStruct(DRAW_LIB_ITEM_STRUCT_TYPE, pos) +/*******************************************************************/ +{ +int ii; + m_Multi = 0; /* In multi unit chip - which unit to draw. */ + m_RefIdNumber = 0; + m_FlagControlMulti = 0; + m_Convert = 0; /* Gestion des mutiples representations (conversion De Morgan) */ + /* The rotation/mirror transformation matrix. pos normal*/ + m_Transform[0][0] = 1; + m_Transform[0][1] = 0; + m_Transform[1][0] = 0; + m_Transform[1][1] = -1; + + /* initialisation des Fields */ + for(ii = 0; ii < NUMBER_OF_FIELDS; ii++) + { + m_Field[ii].m_Pos = m_Pos; + m_Field[ii].m_Layer = LAYER_FIELDS; + m_Field[ii].m_FieldId = REFERENCE + ii; + m_Field[ii].m_Parent = this; + } + + m_Field[VALUE].m_Layer = LAYER_VALUEPART; + m_Field[REFERENCE].m_Layer = LAYER_REFERENCEPART; + + m_PinIsDangling = NULL; + +} + + +/**********************************************************************/ +EDA_Rect EDA_SchComponentStruct::GetBoundaryBox( void ) +/**********************************************************************/ +{ +EDA_LibComponentStruct * Entry = FindLibPart(m_ChipName.GetData(), wxEmptyString, FIND_ROOT); +EDA_Rect BoundaryBox; +int x0, xm, y0, ym; + /* Get the basic Boundary box */ + if ( Entry ) + { + BoundaryBox = Entry->GetBoundaryBox( m_Multi, m_Convert); + x0 = BoundaryBox.GetX(); xm = BoundaryBox.GetRight(); + // We must reverse Y values, because matrix orientation + // suppose Y axis normal for the library items coordinates, + // m_Transform reverse Y values, but BoundaryBox ais already reversed! + y0 = - BoundaryBox.GetY(); + ym = - BoundaryBox.GetBottom(); + } + else /* if lib Entry not found, give a reasonable size */ + { + x0 = y0 = -50; + xm = ym = 50; + } + + /* Compute the real Boundary box (rotated, mirrored ...)*/ + int x1 = m_Transform[0][0] * x0 + m_Transform[0][1] * y0; + + int y1 = m_Transform[1][0] * x0 + m_Transform[1][1] * y0; + + int x2 = m_Transform[0][0] * xm + m_Transform[0][1] * ym; + + int y2 = m_Transform[1][0] * xm + m_Transform[1][1] * ym; + + // H and W must be > 0 for wxRect: + if ( x2 < x1 ) EXCHG( x2, x1 ); + if ( y2 < y1 ) EXCHG( y2, y1 ); + BoundaryBox.SetX(x1); BoundaryBox.SetY(y1); + BoundaryBox.SetWidth(x2-x1); + BoundaryBox.SetHeight(y2-y1); + + BoundaryBox.Offset(m_Pos); + return BoundaryBox; +} + + +/**************************************************************************/ +void PartTextStruct::SwapData(PartTextStruct * copyitem) +/**************************************************************************/ +/* Used if undo / redo command: + swap data between this and copyitem +*/ +{ + EXCHG(m_Text, copyitem->m_Text); + EXCHG(m_Layer, copyitem->m_Layer); + EXCHG(m_Pos, copyitem->m_Pos); + EXCHG(m_Size, copyitem->m_Size); + EXCHG(m_Width, copyitem->m_Width); + EXCHG(m_Orient, copyitem->m_Orient); + EXCHG(m_Miroir, copyitem->m_Miroir); + EXCHG(m_Attributs, copyitem->m_Attributs); + EXCHG(m_CharType, copyitem->m_CharType); + EXCHG(m_HJustify, copyitem->m_HJustify); + EXCHG(m_VJustify, copyitem->m_VJustify); + EXCHG(m_ZoomLevelDrawable, copyitem->m_ZoomLevelDrawable); + EXCHG(m_TextDrawings, copyitem->m_TextDrawings); + EXCHG(m_TextDrawingsSize, copyitem->m_TextDrawingsSize); +} + +/**************************************************************************/ +void EDA_SchComponentStruct::SwapData(EDA_SchComponentStruct * copyitem) +/**************************************************************************/ +/* Used if undo / redo command: + swap data between this and copyitem +*/ +{ + EXCHG(m_Pos, copyitem->m_Pos); + EXCHG(m_Multi, copyitem->m_Multi); + EXCHG(m_Convert, copyitem->m_Convert); + EXCHG(m_Transform[0][0], copyitem->m_Transform[0][0]); + EXCHG(m_Transform[0][1], copyitem->m_Transform[0][1]); + EXCHG(m_Transform[1][0], copyitem->m_Transform[1][0]); + EXCHG(m_Transform[1][1], copyitem->m_Transform[1][1]); + for ( int ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) + { + m_Field[ii].SwapData(©item->m_Field[ii]); + } +} + + +/***********************************************************************/ +void EDA_SchComponentStruct::Place(WinEDA_DrawFrame * frame, wxDC * DC) +/***********************************************************************/ +{ + /* save old text in undo list */ + if ( g_ItemToUndoCopy && + (g_ItemToUndoCopy->m_StructType == m_StructType) && + ((m_Flags & IS_NEW) == 0) ) + { + /* restore old values and save new ones */ + SwapData( (EDA_SchComponentStruct*) g_ItemToUndoCopy); + /* save in undo list */ + ((WinEDA_SchematicFrame*)frame)->SaveCopyInUndoList(this, IS_CHANGED); + /* restore new values */ + SwapData( (EDA_SchComponentStruct*) g_ItemToUndoCopy); + delete g_ItemToUndoCopy; + g_ItemToUndoCopy = NULL; + } + + EDA_BaseStruct::Place(frame, DC); +} + + +/***************************************************/ +void EDA_SchComponentStruct::ClearAnnotation(void) +/***************************************************/ +/* Suppress annotation ( i.i IC23 changed to IC? and part reset to 1) +*/ +{ + m_RefIdNumber = 0; + + while ( isdigit(m_Field[REFERENCE].m_Text.Last() ) ) + m_Field[REFERENCE].m_Text.RemoveLast(); + if ( m_Field[REFERENCE].m_Text.Last() != '?' ) + m_Field[REFERENCE].m_Text.Append('?'); + +EDA_LibComponentStruct *Entry; + Entry = FindLibPart(m_ChipName.GetData(),wxEmptyString,FIND_ROOT); + + if ( !Entry || ! Entry->m_UnitSelectionLocked ) + m_Multi = 1; +} + +/**************************************************************/ +EDA_SchComponentStruct * EDA_SchComponentStruct::GenCopy(void) +/**************************************************************/ +{ +EDA_SchComponentStruct * new_item = new EDA_SchComponentStruct( m_Pos ); +int ii; + + new_item->m_Multi = m_Multi; + new_item->m_ChipName = m_ChipName; + new_item->m_FlagControlMulti = m_FlagControlMulti; + new_item->m_Convert = m_Convert; + new_item->m_Transform[0][0] = m_Transform[0][0]; + new_item->m_Transform[0][1] = m_Transform[0][1]; + new_item->m_Transform[1][0] = m_Transform[1][0]; + new_item->m_Transform[1][1] = m_Transform[1][1]; + new_item->m_TimeStamp = m_TimeStamp; + + + /* initialisation des Fields */ + for(ii = 0; ii < NUMBER_OF_FIELDS; ii++) + { + m_Field[ii].PartTextCopy(& new_item->m_Field[ii]); + } + + return new_item; +} + + +/*****************************************************************/ +void EDA_SchComponentStruct::SetRotationMiroir( int type_rotate ) +/******************************************************************/ +/* Compute the new matrix transform for a schematic component + in order to have the requested transform (type_rotate = rot, mirror..) + which is applied to the initial transform. +*/ +{ +int TempMat[2][2]; +bool Transform = FALSE; + + switch (type_rotate) + { + case CMP_ORIENT_0: + case CMP_NORMAL: /* Position Initiale */ + m_Transform[0][0] = 1; + m_Transform[1][1] = -1; + m_Transform[1][0] = m_Transform[0][1] = 0; + break; + + case CMP_ROTATE_CLOCKWISE: /* Rotate + */ + TempMat[0][0] = TempMat[1][1] = 0; + TempMat[0][1] = 1; + TempMat[1][0] = -1; + Transform = TRUE; + break; + + case CMP_ROTATE_COUNTERCLOCKWISE: /* Rotate - */ + TempMat[0][0] = TempMat[1][1] = 0; + TempMat[0][1] = -1; + TempMat[1][0] = 1; + Transform = TRUE; + break; + + case CMP_MIROIR_Y: /* MirrorY */ + TempMat[0][0] = -1; + TempMat[1][1] = 1; + TempMat[0][1] = TempMat[1][0] = 0; + Transform = TRUE; + break; + + case CMP_MIROIR_X: /* MirrorX */ + TempMat[0][0] = 1; + TempMat[1][1] = -1; + TempMat[0][1] = TempMat[1][0] = 0; + Transform = TRUE; + break; + + case CMP_ORIENT_90: + SetRotationMiroir( CMP_ORIENT_0 ); + SetRotationMiroir( CMP_ROTATE_COUNTERCLOCKWISE ); + break; + + case CMP_ORIENT_180: + SetRotationMiroir( CMP_ORIENT_0 ); + SetRotationMiroir( CMP_ROTATE_COUNTERCLOCKWISE ); + SetRotationMiroir( CMP_ROTATE_COUNTERCLOCKWISE ); + break; + + case CMP_ORIENT_270: + SetRotationMiroir( CMP_ORIENT_0 ); + SetRotationMiroir( CMP_ROTATE_CLOCKWISE ); + break; + + case (CMP_ORIENT_0+CMP_MIROIR_X): + SetRotationMiroir( CMP_ORIENT_0 ); + SetRotationMiroir( CMP_MIROIR_X ); + break; + + case (CMP_ORIENT_0+CMP_MIROIR_Y): + SetRotationMiroir( CMP_ORIENT_0 ); + SetRotationMiroir( CMP_MIROIR_Y ); + break; + + case (CMP_ORIENT_90+CMP_MIROIR_X): + SetRotationMiroir( CMP_ORIENT_90 ); + SetRotationMiroir( CMP_MIROIR_X ); + break; + + case (CMP_ORIENT_90+CMP_MIROIR_Y): + SetRotationMiroir( CMP_ORIENT_90 ); + SetRotationMiroir( CMP_MIROIR_Y ); + break; + + case (CMP_ORIENT_180+CMP_MIROIR_X): + SetRotationMiroir( CMP_ORIENT_180 ); + SetRotationMiroir( CMP_MIROIR_X ); + break; + + case (CMP_ORIENT_180+CMP_MIROIR_Y): + SetRotationMiroir( CMP_ORIENT_180 ); + SetRotationMiroir( CMP_MIROIR_Y ); + break; + + case (CMP_ORIENT_270+CMP_MIROIR_X): + SetRotationMiroir( CMP_ORIENT_270 ); + SetRotationMiroir( CMP_MIROIR_X ); + break; + + case (CMP_ORIENT_270+CMP_MIROIR_Y): + SetRotationMiroir( CMP_ORIENT_270 ); + SetRotationMiroir( CMP_MIROIR_Y ); + break; + + default: + Transform = FALSE; + DisplayError(NULL, wxT("SetRotateMiroir() error: ill value") ); + break; + } + + if ( Transform ) + {/* The new matrix transform is the old matrix transform modified by the + requested transformation, which is the TempMat transform (rot, mirror ..) + in order to have (in term of matrix transform): + transform coord = new_m_Transform * coord + where transform coord is the coord modified by new_m_Transform from the initial + value coord. + new_m_Transform is computed (from old_m_Transform and TempMat) to have: + transform coord = old_m_Transform * coord * TempMat + */ + int NewMatrix[2][2]; + + NewMatrix[0][0] = m_Transform[0][0] * TempMat[0][0] + + m_Transform[1][0] * TempMat[0][1]; + + NewMatrix[0][1] = m_Transform[0][1] * TempMat[0][0] + + m_Transform[1][1] * TempMat[0][1]; + + NewMatrix[1][0] = m_Transform[0][0] * TempMat[1][0] + + m_Transform[1][0] * TempMat[1][1]; + + NewMatrix[1][1] = m_Transform[0][1] * TempMat[1][0] + + m_Transform[1][1] * TempMat[1][1]; + + m_Transform[0][0] = NewMatrix[0][0]; + m_Transform[0][1] = NewMatrix[0][1]; + m_Transform[1][0] = NewMatrix[1][0]; + m_Transform[1][1] = NewMatrix[1][1]; + } +} + + +/****************************************************/ +int EDA_SchComponentStruct::GetRotationMiroir(void) +/****************************************************/ +{ +int type_rotate = CMP_ORIENT_0; +int TempMat[2][2], MatNormal[2][2]; +int ii; +bool found = FALSE; + + memcpy(TempMat, m_Transform, sizeof(TempMat)); + SetRotationMiroir(CMP_ORIENT_0); + memcpy(MatNormal, m_Transform, sizeof(MatNormal)); + + for ( ii = 0; ii < 4; ii++ ) + { + if ( memcmp(TempMat, m_Transform, sizeof(MatNormal)) == 0) + { + found = TRUE; break; + } + SetRotationMiroir(CMP_ROTATE_COUNTERCLOCKWISE); + } + + if ( ! found ) + { + type_rotate = CMP_MIROIR_X + CMP_ORIENT_0; + SetRotationMiroir(CMP_NORMAL); + SetRotationMiroir(CMP_MIROIR_X); + for ( ii = 0; ii < 4; ii++ ) + { + if ( memcmp(TempMat, m_Transform, sizeof(MatNormal)) == 0) + { + found = TRUE; break; + } + SetRotationMiroir(CMP_ROTATE_COUNTERCLOCKWISE); + } + } + + if ( ! found ) + { + type_rotate = CMP_MIROIR_Y + CMP_ORIENT_0; + SetRotationMiroir(CMP_NORMAL); + SetRotationMiroir(CMP_MIROIR_Y); + for ( ii = 0; ii < 4; ii++ ) + { + if ( memcmp(TempMat, m_Transform, sizeof(MatNormal)) == 0) + { + found = TRUE; break; + } + SetRotationMiroir(CMP_ROTATE_COUNTERCLOCKWISE); + } + } + + memcpy(m_Transform, TempMat, sizeof(m_Transform)); + + if ( found ) + { + return (type_rotate + ii); + } + else + { + wxBell(); return CMP_NORMAL; + } +} + +/***********************************************************************/ +wxPoint EDA_SchComponentStruct::GetScreenCoord(const wxPoint & coord) +/***********************************************************************/ +/* Renvoie la coordonnée du point coord, en fonction de l'orientation +du composant (rotation, miroir). + Les coord sont toujours relatives à l'ancre (coord 0,0) du composant +*/ +{ +wxPoint screenpos; + screenpos.x = m_Transform[0][0] * coord.x + m_Transform[0][1] * coord.y; + screenpos.y = m_Transform[1][0] * coord.x + m_Transform[1][1] * coord.y; + return screenpos; +} + + +/***************************************************************************/ +PartTextStruct::PartTextStruct(const wxPoint & pos, const wxString & text): + EDA_BaseStruct(DRAW_PART_TEXT_STRUCT_TYPE), + EDA_TextStruct(text) +/***************************************************************************/ +{ + m_Pos = pos; + m_FieldId = 0; +} + +/************************************/ +PartTextStruct::~PartTextStruct(void) +/************************************/ +{ +} + +/***********************************************************/ +void PartTextStruct::PartTextCopy(PartTextStruct * target) +/***********************************************************/ +{ + target->m_Text = m_Text; + if ( m_FieldId >= FIELD1 )target->m_Name = m_Name; + target->m_Layer = m_Layer; + target->m_Pos = m_Pos; + target->m_Size = m_Size; + target->m_Attributs = m_Attributs; + target->m_FieldId = m_FieldId; + target->m_Orient = m_Orient; + target->m_HJustify = m_HJustify; + target->m_VJustify = m_VJustify; + target->m_Flags = m_Flags; +} + + +/*********************************/ +bool PartTextStruct::IsVoid(void) +/*********************************/ +/* return True if The field is void, i.e.: + contains wxEmptyString or "~" +*/ +{ + if ( m_Text.IsEmpty() || m_Text == wxT("~") ) return TRUE; + return FALSE; +} + + +/********************************************/ +EDA_Rect PartTextStruct::GetBoundaryBox(void) +/********************************************/ +/* return + EDA_Rect contains the real (user coordinates) boundary box for a text field, +according to the component position, rotation, mirror ... + +*/ +{ +EDA_Rect BoundaryBox; +int hjustify, vjustify; +int textlen; +int orient; +int dx, dy, x1, y1, x2, y2; + +EDA_SchComponentStruct * DrawLibItem = (EDA_SchComponentStruct *) m_Parent; + + orient = m_Orient; + wxPoint pos = DrawLibItem->m_Pos; + x1 = m_Pos.x - pos.x; + y1 = m_Pos.y - pos.y; + + textlen = GetLength(); + if ( m_FieldId == REFERENCE ) // Real Text can be U1 or U1A + { + EDA_LibComponentStruct *Entry = + FindLibPart(DrawLibItem->m_ChipName.GetData(),wxEmptyString,FIND_ROOT); + if ( Entry && (Entry->m_UnitCount > 1) ) + textlen ++; // because U1 is show as U1A or U1B ... + } + dx = m_Size.x * textlen; + + // Real X Size is 10/9 char size because space between 2 chars is 1/10 X Size + dx = (dx * 10) / 9; + + dy = m_Size.y; + hjustify = m_HJustify; + vjustify = m_VJustify; + + x2 = pos.x + (DrawLibItem->m_Transform[0][0] * x1) + + (DrawLibItem->m_Transform[0][1] * y1); + y2 = pos.y + (DrawLibItem->m_Transform[1][0] * x1) + + (DrawLibItem->m_Transform[1][1] * y1); + + /* If the component orientation is +/- 90 deg, the text orienation must be changed */ + if(DrawLibItem->m_Transform[0][1]) + { + if ( orient == TEXT_ORIENT_HORIZ) orient = TEXT_ORIENT_VERT; + else orient = TEXT_ORIENT_HORIZ; + /* is it mirrored (for text justify)*/ + EXCHG(hjustify, vjustify); + if (DrawLibItem->m_Transform[1][0] < 0 ) vjustify = - vjustify; + if (DrawLibItem->m_Transform[0][1] > 0 ) hjustify = - hjustify; + } + else /* component horizontal: is it mirrored (for text justify)*/ + { + if (DrawLibItem->m_Transform[0][0] < 0 ) + hjustify = - hjustify; + if (DrawLibItem->m_Transform[1][1] > 0 ) + vjustify = - vjustify; + } + + if ( orient == TEXT_ORIENT_VERT ) EXCHG(dx, dy); + + switch ( hjustify ) + { + case GR_TEXT_HJUSTIFY_CENTER: + x1 = x2 - (dx/2); + break; + case GR_TEXT_HJUSTIFY_RIGHT: + x1 = x2 - dx; + break; + default: + x1 = x2; + break; + } + switch ( vjustify ) + { + case GR_TEXT_VJUSTIFY_CENTER: + y1 = y2 - (dy/2); + break; + case GR_TEXT_VJUSTIFY_BOTTOM: + y1 = y2 - dy; + break; + default: + y1 = y2; + break; + } + + BoundaryBox.SetX(x1); + BoundaryBox.SetY(y1); + BoundaryBox.SetWidth(dx); + BoundaryBox.SetHeight(dy); + + return BoundaryBox; +} diff --git a/eeschema/component_class.h b/eeschema/component_class.h new file mode 100644 index 0000000000..eaa9c73326 --- /dev/null +++ b/eeschema/component_class.h @@ -0,0 +1,105 @@ + /*****************************************************/ + /* Definitions for the Component classes for EESchema */ + /*****************************************************/ + +#ifndef COMPONENT_CLASS_H +#define COMPONENT_CLASS_H + +#ifndef eda_global +#define eda_global extern +#endif + +#include "macros.h" +#include "base_struct.h" + + +/* Definition de la representation du composant */ +#define NUMBER_OF_FIELDS 12 /* Nombre de champs de texte affectes au composant */ +typedef enum +{ + REFERENCE = 0, /* Champ Reference of part, i.e. "IC21" */ + VALUE, /* Champ Value of part, i.e. "3.3K" */ + FOOTPRINT, /* Champ Name Module PCB, i.e. "16DIP300" */ + SHEET_FILENAME, /* Champ Name Schema component, i.e. "cnt16.sch" */ + FIELD1, + FIELD2, + FIELD3, + FIELD4, + FIELD5, + FIELD6, + FIELD7, + FIELD8 +} NumFieldType; + + +/* Class to manage component fields. + component fields are texts attached to the component (not the graphic texts) + There are 2 major fields : Reference and Value +*/ +class PartTextStruct: public EDA_BaseStruct, public EDA_TextStruct +{ +public: + int m_FieldId; + wxString m_Name; /* Field name (ref, value,pcb, sheet, filed 1.. + and for fields 1 to 8 the name is editable */ + +public: + PartTextStruct(const wxPoint & pos = wxPoint(0,0), const wxString & text = wxEmptyString); + ~PartTextStruct(void); + void PartTextCopy(PartTextStruct * target); + void Place(WinEDA_DrawFrame * frame, wxDC * DC); + + EDA_Rect GetBoundaryBox(void); + bool IsVoid(); + void SwapData(PartTextStruct * copyitem); +}; + +/* the class DrawPartStruct describes a basic virtual component + Not used directly: + used classes are EDA_SchComponentStruct (the "classic" schematic component + and the Pseudo component DrawSheetStruct +*/ +class DrawPartStruct: public EDA_BaseStruct +{ +public: + wxString m_ChipName; /* Key to look for in the library, i.e. "74LS00". */ + PartTextStruct m_Field[NUMBER_OF_FIELDS]; + wxPoint m_Pos; /* Exact position of part. */ + +public: + DrawPartStruct( DrawStructureType struct_type, const wxPoint & pos); + ~DrawPartStruct(void); +}; + + +/* the class EDA_SchComponentStruct describes a real component */ +class EDA_SchComponentStruct: public DrawPartStruct +{ +public: + int m_RefIdNumber; /* reference count: for U1, R2 .. it is the 1 or 2 value */ + int m_Multi; /* In multi unit chip - which unit to draw. */ + int m_FlagControlMulti; + int m_Convert; /* Gestion des mutiples representations (ex: conversion De Morgan) */ + int m_Transform[2][2]; /* The rotation/mirror transformation matrix. */ + bool * m_PinIsDangling; // liste des indicateurs de pin non connectee + +public: + EDA_SchComponentStruct(const wxPoint & pos = wxPoint(0,0)); + ~EDA_SchComponentStruct(void){} + EDA_SchComponentStruct * GenCopy(void); + void SetRotationMiroir( int type ); + int GetRotationMiroir(void); + wxPoint GetScreenCoord(const wxPoint & coord); + void Display_Infos(WinEDA_DrawFrame * frame); + void ClearAnnotation(void); + EDA_Rect GetBoundaryBox( void ); + wxString ReturnFieldName(int FieldNumber); + + virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); + void SwapData(EDA_SchComponentStruct * copyitem); + virtual void Place(WinEDA_DrawFrame * frame, wxDC * DC); +}; + + +#endif /* COMPONENT_CLASS_H */ + diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp new file mode 100644 index 0000000000..bdf3182959 --- /dev/null +++ b/eeschema/controle.cpp @@ -0,0 +1,346 @@ + /****************/ + /* controle.cpp */ + /****************/ + +#include "fctsys.h" + +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "eda_dde.h" + +#include "id.h" + +#include "protos.h" + +/* Routines locales */ + +/* variables externes */ + +#define MSG_TO_PCB KICAD_PCB_PORT_SERVICE_NUMBER + + +/**************************************************************/ +EDA_BaseStruct * WinEDA_SchematicFrame:: + SchematicGeneralLocateAndDisplay(bool IncludePin) +/**************************************************************/ + +/* Routine de localisation et d'affichage des caract (si utile ) + de l'element pointe par la souris + - marqueur + - noconnect + - jonction + - wire/bus/entry + - label + - composant + - pin + retourne + un pointeur sur le composant + Null sinon +*/ +{ +EDA_BaseStruct *DrawStruct; +LibDrawPin * Pin; +EDA_SchComponentStruct * LibItem; +wxString Text; +char Line[1024]; +wxString msg; +int ii; + + DrawStruct = PickStruct(GetScreen()->m_Curseur, GetScreen()->EEDrawList, MARKERITEM); + if( DrawStruct ) + { + DrawMarkerStruct * Marker = (DrawMarkerStruct *) DrawStruct; + ii = Marker->m_Type; + Text = Marker->GetComment(); + if(Text.IsEmpty() ) Text = wxT("NoComment"); + msg = NameMarqueurType[ii]; msg << wxT(" << ") << Text; + Affiche_Message(msg); + return(DrawStruct); + } + + DrawStruct = PickStruct(GetScreen()->m_Curseur, GetScreen()->EEDrawList, + NOCONNECTITEM); + if( DrawStruct ) + { + Affiche_Message(wxEmptyString); + return(DrawStruct); + } + + DrawStruct = PickStruct(GetScreen()->m_Curseur, GetScreen()->EEDrawList, + JUNCTIONITEM); + if( DrawStruct ) + { + Affiche_Message(wxEmptyString); + return(DrawStruct); + } + + DrawStruct = PickStruct(GetScreen()->m_Curseur, GetScreen()->EEDrawList, + WIREITEM|BUSITEM|RACCORDITEM); + if( DrawStruct ) // Recherche d'une pin eventelle + { + Pin = LocateAnyPin(m_CurrentScreen->EEDrawList,m_CurrentScreen->m_Curseur, &LibItem); + if( Pin ) + { + Pin->Display_Infos(this); + if ( LibItem ) + Affiche_1_Parametre( this, 1, + LibItem->m_Field[REFERENCE].m_Text, + LibItem->m_Field[VALUE].m_Text, + CYAN); + + /* envoi id pin a pcbnew */ + if(Pin->m_PinNum) + { + char pinnum[20]; + pinnum[0] = Pin->m_PinNum & 255; + pinnum[1] = (Pin->m_PinNum >> 8 ) & 255; + pinnum[2] = (Pin->m_PinNum >> 16 ) & 255; + pinnum[3] = (Pin->m_PinNum >> 24 ) & 255; + pinnum[4] = 0; + sprintf(Line,"$PIN: %s $PART: %s", pinnum, + CONV_TO_UTF8(LibItem->m_Field[REFERENCE].m_Text)); + SendCommand(MSG_TO_PCB, Line); + } + } + else Affiche_Message(wxEmptyString); + return(DrawStruct); + } + + // Cross probing: Send a command to pcbnew via a socket link, service 4242 + // Cross probing:1- look for a component, and send a locate footprint command to pcbnew + DrawStruct = PickStruct(GetScreen()->m_Curseur, GetScreen()->EEDrawList, + FIELDCMPITEM); + if( DrawStruct ) + { + PartTextStruct * Field = (PartTextStruct *) DrawStruct; + LibItem = (EDA_SchComponentStruct * )Field->m_Parent; + LibItem->Display_Infos(this); + + sprintf(Line,"$PART: %s", CONV_TO_UTF8(LibItem->m_Field[REFERENCE].m_Text) ); + SendCommand(MSG_TO_PCB, Line); + + return(DrawStruct); + } + + /* search for a pin */ + Pin = LocateAnyPin(m_CurrentScreen->EEDrawList,m_CurrentScreen->m_Curseur, &LibItem); + if( Pin ) + { + Pin->Display_Infos(this); + if ( LibItem ) + Affiche_1_Parametre( this, 1, + LibItem->m_Field[REFERENCE].m_Text, + LibItem->m_Field[VALUE].m_Text, + CYAN); + + // Cross probing:2 - pin found, and send a locate pin command to pcbnew (hightlight net) + if(Pin->m_PinNum) + { + wxString pinnum; + Pin->ReturnPinStringNum(pinnum); + sprintf(Line,"$PIN: %s $PART: %s", CONV_TO_UTF8(pinnum), + CONV_TO_UTF8(LibItem->m_Field[REFERENCE].m_Text)); + SendCommand(MSG_TO_PCB, Line); + } + + if ( IncludePin == TRUE ) return(LibItem); + } + + DrawStruct = PickStruct(GetScreen()->m_Curseur, GetScreen()->EEDrawList, + LIBITEM); + if( DrawStruct ) + { + DrawStruct = LocateSmallestComponent( GetScreen() ); + LibItem = (EDA_SchComponentStruct *) DrawStruct; + LibItem->Display_Infos(this); + + sprintf(Line,"$PART: %s", + CONV_TO_UTF8(LibItem->m_Field[REFERENCE].m_Text)); + SendCommand(MSG_TO_PCB, Line); + + return(DrawStruct); + } + + DrawStruct = PickStruct(GetScreen()->m_Curseur, GetScreen()->EEDrawList, + SHEETITEM); + if( DrawStruct ) + { + ((DrawSheetStruct*) DrawStruct)->Display_Infos(this); + return(DrawStruct); + } + + // Recherche des autres elements + DrawStruct = PickStruct(GetScreen()->m_Curseur, GetScreen()->EEDrawList, + SEARCHALL); + if( DrawStruct ) + { + return(DrawStruct); + } + + MsgPanel->EraseMsgBox(); + return(NULL); +} + + + +/**************************************************************/ +void WinEDA_DrawFrame::GeneralControle(wxDC *DC, wxPoint Mouse) +/**************************************************************/ +{ +wxSize delta; +int zoom = m_CurrentScreen->GetZoom(); +wxPoint curpos, oldpos; +int hotkey = 0; + + ActiveScreen = (SCH_SCREEN *) m_CurrentScreen; + + curpos = DrawPanel->CursorRealPosition(Mouse); + oldpos = m_CurrentScreen->m_Curseur; + + delta.x = m_CurrentScreen->GetGrid().x / zoom; + delta.y = m_CurrentScreen->GetGrid().y / zoom; + + if( delta.x <= 0 ) delta.x = 1; + if( delta.y <= 0 ) delta.y = 1; + + switch( g_KeyPressed ) + { + case EDA_PANNING_UP_KEY : + OnZoom(ID_ZOOM_PANNING_UP); + curpos = m_CurrentScreen->m_Curseur; + break; + case EDA_PANNING_DOWN_KEY : + OnZoom(ID_ZOOM_PANNING_DOWN); + curpos = m_CurrentScreen->m_Curseur; + break; + case EDA_PANNING_LEFT_KEY : + OnZoom(ID_ZOOM_PANNING_LEFT); + curpos = m_CurrentScreen->m_Curseur; + break; + case EDA_PANNING_RIGHT_KEY : + OnZoom(ID_ZOOM_PANNING_RIGHT); + curpos = m_CurrentScreen->m_Curseur; + break; + case WXK_F1 : + OnZoom(ID_ZOOM_PLUS_KEY); + curpos = m_CurrentScreen->m_Curseur; + break; + case WXK_F2 : + OnZoom(ID_ZOOM_MOINS_KEY); + curpos = m_CurrentScreen->m_Curseur; + break; + case WXK_F3 : + OnZoom(ID_ZOOM_REDRAW_KEY); + break; + case WXK_F4 : + OnZoom(ID_ZOOM_CENTER_KEY); + curpos = m_CurrentScreen->m_Curseur; + break; + + case ' ': // Remise a zero coord relatives + m_CurrentScreen->m_O_Curseur = m_CurrentScreen->m_Curseur; + break; + + case '\t': // Switch to drag mode, when block moving + ((WinEDA_SchematicFrame*)this)->HandleBlockEndByPopUp(BLOCK_DRAG, DC); + break; + + case WXK_NUMPAD8 : /* Deplacement curseur vers le haut */ + case WXK_UP : + Mouse.y -= delta.y; + DrawPanel->MouseTo(Mouse); + break ; + + case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ + case WXK_DOWN: + Mouse.y += delta.y; + DrawPanel->MouseTo(Mouse); + break ; + + case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ + case WXK_LEFT : + Mouse.x -= delta.x; + DrawPanel->MouseTo(Mouse); + break ; + + case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ + case WXK_RIGHT: + Mouse.x += delta.x; + DrawPanel->MouseTo(Mouse); + break; + + case WXK_INSERT: + case WXK_NUMPAD0: + if ( m_Ident == SCHEMATIC_FRAME ) + { + if ( g_ItemToRepeat && (g_ItemToRepeat->m_Flags == 0) ) + { + ((WinEDA_SchematicFrame*)this)->RepeatDrawItem(DC); + } + else wxBell(); + break; + } + if ( m_Ident == LIBEDITOR_FRAME ) + { + if ( LibItemToRepeat && (LibItemToRepeat->m_Flags == 0) && + (LibItemToRepeat->m_StructType == COMPONENT_PIN_DRAW_TYPE) ) + { + ((WinEDA_LibeditFrame*)this)->RepeatPinItem(DC, + (LibDrawPin*) LibItemToRepeat); + } + else wxBell(); + break; + } + + case 0: + case WXK_DECIMAL: + break; + + default: hotkey = g_KeyPressed; + break; + + } + + /* Recalcul de la position du curseur schema */ + m_CurrentScreen->m_Curseur = curpos; + /* Placement sur la grille generale */ + PutOnGrid( & m_CurrentScreen->m_Curseur); + + if( m_CurrentScreen->IsRefreshReq() ) + { + RedrawActiveWindow(DC, TRUE); + } + + if ( (oldpos.x != m_CurrentScreen->m_Curseur.x) || + (oldpos.y != m_CurrentScreen->m_Curseur.y) ) + { + curpos = m_CurrentScreen->m_Curseur; + m_CurrentScreen->m_Curseur = oldpos; + DrawPanel->CursorOff(DC); + m_CurrentScreen->m_Curseur = curpos; + DrawPanel->CursorOn(DC); + + if(DrawPanel->ManageCurseur) + { + DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); + } + } + + Affiche_Status_Box(); /* Affichage des coord curseur */ + + if ( hotkey ) + { + if( m_CurrentScreen->m_CurrentItem && + m_CurrentScreen->m_CurrentItem->m_Flags ) + OnHotKey(DC, hotkey, m_CurrentScreen->m_CurrentItem); + else OnHotKey(DC, hotkey, NULL); + } + +} + + diff --git a/eeschema/dangling_ends.cpp b/eeschema/dangling_ends.cpp new file mode 100644 index 0000000000..cba1c73ac1 --- /dev/null +++ b/eeschema/dangling_ends.cpp @@ -0,0 +1,409 @@ + /*********************/ + /* dangling_ends.cpp */ + /*********************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "netlist.h" /* Definitions generales liees au calcul de netliste */ +#include "protos.h" + +enum End_Type +{ + UNKNOWN = 0, + WIRE_START_END, + WIRE_END_END, + BUS_START_END, + BUS_END_END, + JUNCTION_END, + PIN_END, + LABEL_END, + ENTRY_END, + SHEET_LABEL_END +}; + +class DanglingEndHandle +{ +public: + const void * m_Item; + wxPoint m_Pos; + int m_Type; + DanglingEndHandle * m_Pnext; + + DanglingEndHandle(int type) + { + m_Item = NULL; + m_Type = type; + m_Pnext = NULL; + } +}; + +DanglingEndHandle * ItemList; + +static void TestWireForDangling(EDA_DrawLineStruct * DrawRef, + WinEDA_SchematicFrame * frame, wxDC * DC); +void TestLabelForDangling(DrawTextStruct * label, + WinEDA_SchematicFrame * frame, wxDC * DC); +DanglingEndHandle * RebuildEndList(EDA_BaseStruct *DrawList); + +/**********************************************************/ +bool SegmentIntersect(int Sx1, int Sy1, int Sx2, int Sy2, + int Px1, int Py1) +/**********************************************************/ +/* Retourne TRUE si le point P est sur le segment S. + Le segment est suppose horizontal ou vertical. +*/ +{ +int Sxmin, Sxmax, Symin, Symax; + + if (Sx1 == Sx2) /* Line S is vertical. */ + { + Symin = MIN(Sy1, Sy2); Symax = MAX(Sy1, Sy2); + if (Px1 != Sx1) return FALSE; + if (Py1 >= Symin && Py1 <= Symax) return TRUE; + else return FALSE; + } + + else if (Sy1 == Sy2) /* Line S is horizontal. */ + { + Sxmin = MIN(Sx1, Sx2); Sxmax = MAX(Sx1, Sx2); + if (Py1 != Sy1) return FALSE; + if (Px1 >= Sxmin && Px1 <= Sxmax) return TRUE; + else return FALSE; + } + else return FALSE; // Segments quelconques +} + + + +/******************************************************************************/ +void WinEDA_SchematicFrame::TestDanglingEnds(EDA_BaseStruct *DrawList, wxDC *DC) +/******************************************************************************/ +/* Met a jour les membres m_Dangling des wires, bus, labels +*/ +{ +EDA_BaseStruct * DrawItem; +const DanglingEndHandle * DanglingItem, * nextitem; + + if ( ItemList ) + for ( DanglingItem = ItemList; DanglingItem != NULL; DanglingItem = nextitem) + { + nextitem = DanglingItem->m_Pnext; + delete DanglingItem; + } + + ItemList = RebuildEndList(DrawList); + // Controle des elements + for ( DrawItem = DrawList; DrawItem != NULL; DrawItem= DrawItem->Pnext) + { + switch( DrawItem->m_StructType ) + { + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawLabelStruct*)DrawItem) + TestLabelForDangling(STRUCT, this, DC); + break; + break; + + case DRAW_SEGMENT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((EDA_DrawLineStruct*)DrawItem) + if( STRUCT->m_Layer == LAYER_WIRE) + { + TestWireForDangling(STRUCT, this, DC); + break; + } + if( STRUCT->m_Layer == LAYER_NOTES) break; + if( STRUCT->m_Layer == LAYER_BUS) + { + STRUCT->m_StartIsDangling = + STRUCT->m_EndIsDangling = FALSE; + break; + } + break; + } + } +} + +/********************************************************************/ +LibDrawPin * WinEDA_SchematicFrame::LocatePinEnd(EDA_BaseStruct *DrawList, + const wxPoint & pos) +/********************************************************************/ +/* Teste si le point de coordonnées pos est sur l'extrémité d'une PIN + retourne un pointeur sur la pin + NULL sinon +*/ +{ +EDA_SchComponentStruct * DrawLibItem; +LibDrawPin * Pin; +wxPoint pinpos; + + Pin = LocateAnyPin(DrawList,pos, &DrawLibItem); + if( ! Pin ) return NULL; + + pinpos = Pin->m_Pos; + + if(DrawLibItem == NULL ) pinpos.y = -pinpos.y; + + else + { + int x1 = pinpos.x, y1 = pinpos.y; + pinpos.x = DrawLibItem->m_Pos.x + DrawLibItem->m_Transform[0][0] * x1 + + DrawLibItem->m_Transform[0][1] * y1; + pinpos.y = DrawLibItem->m_Pos.y + DrawLibItem->m_Transform[1][0] * x1 + + DrawLibItem->m_Transform[1][1] * y1; + } + + if( (pos.x == pinpos.x) && (pos.y == pinpos.y) ) return Pin; + return NULL; +} + + +/****************************************************************************/ +void TestWireForDangling(EDA_DrawLineStruct * DrawRef, + WinEDA_SchematicFrame * frame, wxDC * DC) +/****************************************************************************/ +{ +DanglingEndHandle * terminal_item; +bool Sdangstate = TRUE, Edangstate = TRUE; + + for ( terminal_item = ItemList; terminal_item != NULL; + terminal_item = terminal_item->m_Pnext) + { + if ( terminal_item->m_Item == DrawRef ) continue; + + if ( (DrawRef->m_Start.x == terminal_item->m_Pos.x) && + (DrawRef->m_Start.y == terminal_item->m_Pos.y) ) + Sdangstate = FALSE; + + if ( (DrawRef->m_End.x == terminal_item->m_Pos.x) && + (DrawRef->m_End.y == terminal_item->m_Pos.y) ) + Edangstate = FALSE; + + if ( (Sdangstate == FALSE) && (Edangstate == FALSE) ) + break; + } + + if ( (Sdangstate != DrawRef->m_StartIsDangling) || + (Edangstate != DrawRef->m_EndIsDangling) ) + { + if ( DC ) + RedrawOneStruct(frame->DrawPanel,DC, DrawRef, g_XorMode); + DrawRef->m_StartIsDangling = Sdangstate; + DrawRef->m_EndIsDangling = Edangstate; + if ( DC ) + RedrawOneStruct(frame->DrawPanel,DC, DrawRef, GR_DEFAULT_DRAWMODE); + } +} + +/********************************************************/ +void TestLabelForDangling(DrawTextStruct * label, + WinEDA_SchematicFrame * frame, wxDC * DC) +/********************************************************/ +{ +DanglingEndHandle * terminal_item; +bool dangstate = TRUE; + + for ( terminal_item = ItemList; terminal_item != NULL; + terminal_item = terminal_item->m_Pnext) + { + if ( terminal_item->m_Item == label ) continue; + switch( terminal_item->m_Type ) + { + case PIN_END: + case LABEL_END: + case SHEET_LABEL_END: + if ( (label->m_Pos.x == terminal_item->m_Pos.x) && + (label->m_Pos.y == terminal_item->m_Pos.y) ) + dangstate = FALSE; + break; + + case WIRE_START_END: + case BUS_START_END: + dangstate = ! SegmentIntersect(terminal_item->m_Pos.x, + terminal_item->m_Pos.y, + terminal_item->m_Pnext->m_Pos.x, + terminal_item->m_Pnext->m_Pos.y, + label->m_Pos.x, label->m_Pos.y); + terminal_item = terminal_item->m_Pnext; + break; + + case UNKNOWN: + case JUNCTION_END: + case ENTRY_END: + case WIRE_END_END: + case BUS_END_END: + break; + } + + if (dangstate == FALSE) break; + } + + if ( dangstate != label->m_IsDangling ) + { + if ( DC ) + RedrawOneStruct(frame->DrawPanel,DC, label, g_XorMode); + label->m_IsDangling = dangstate; + if ( DC ) + RedrawOneStruct(frame->DrawPanel,DC, label, GR_DEFAULT_DRAWMODE); + } +} + + +/****************************************************/ +wxPoint ReturnPinPhysicalPosition( LibDrawPin * Pin, + EDA_SchComponentStruct * DrawLibItem) +/****************************************************/ +/* Retourne la position physique de la pin, qui dépend de l'orientation +du composant */ +{ +wxPoint PinPos = Pin->m_Pos; + + if(DrawLibItem == NULL ) PinPos.y = -PinPos.y; + + else + { + int x = Pin->m_Pos.x, y = Pin->m_Pos.y; + PinPos.x = DrawLibItem->m_Pos.x + DrawLibItem->m_Transform[0][0] * x + + DrawLibItem->m_Transform[0][1] * y; + PinPos.y = DrawLibItem->m_Pos.y + DrawLibItem->m_Transform[1][0] * x + + DrawLibItem->m_Transform[1][1] * y; + } + + return PinPos; +} + + +/***********************************************************/ +DanglingEndHandle * RebuildEndList(EDA_BaseStruct *DrawList) +/***********************************************************/ +{ +DanglingEndHandle * StartList = NULL, *item, *lastitem = NULL; +EDA_BaseStruct * DrawItem; + + for ( DrawItem = DrawList; DrawItem != NULL; DrawItem = DrawItem->Pnext) + { + switch( DrawItem->m_StructType ) + { + case DRAW_LABEL_STRUCT_TYPE: + break; + + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawGlobalLabelStruct*)DrawItem) + item = new DanglingEndHandle(LABEL_END); + item->m_Item = DrawItem; + item->m_Pos = STRUCT->m_Pos; + if ( lastitem ) lastitem->m_Pnext = item; + else StartList = item; + lastitem = item; + break; + + case DRAW_SEGMENT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((EDA_DrawLineStruct*)DrawItem) + if( STRUCT->m_Layer == LAYER_NOTES ) break; + if( (STRUCT->m_Layer == LAYER_BUS) || (STRUCT->m_Layer == LAYER_WIRE) ) + { + item = new DanglingEndHandle((STRUCT->m_Layer == LAYER_BUS) ? + BUS_START_END : WIRE_START_END); + item->m_Item = DrawItem; + item->m_Pos = STRUCT->m_Start; + if ( lastitem ) lastitem->m_Pnext = item; + else StartList = item; + lastitem = item; + item = new DanglingEndHandle((STRUCT->m_Layer == LAYER_BUS) ? + BUS_END_END : WIRE_END_END); + item->m_Item = DrawItem; + item->m_Pos = STRUCT->m_End; + lastitem->m_Pnext = item; + lastitem = item; + } + break; + + case DRAW_JUNCTION_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawJunctionStruct*)DrawItem) + item = new DanglingEndHandle(JUNCTION_END); + item->m_Item = DrawItem; + item->m_Pos = STRUCT->m_Pos; + if ( lastitem ) lastitem->m_Pnext = item; + else StartList = item; + lastitem = item; + break; + + case DRAW_BUSENTRY_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawBusEntryStruct*)DrawItem) + item = new DanglingEndHandle(ENTRY_END); + item->m_Item = DrawItem; + item->m_Pos = STRUCT->m_Pos; + if ( lastitem ) lastitem->m_Pnext = item; + else StartList = item; + lastitem = item; + item = new DanglingEndHandle(ENTRY_END); + item->m_Item = DrawItem; + item->m_Pos = STRUCT->m_End(); + lastitem->m_Pnext = item; + lastitem = item; + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE: + { + #undef STRUCT + #define STRUCT ((EDA_SchComponentStruct*)DrawItem) + EDA_LibComponentStruct * Entry; + Entry = FindLibPart( STRUCT->m_ChipName, wxEmptyString, FIND_ROOT); + if( Entry == NULL ) break; + LibEDA_BaseStruct * DrawLibItem = Entry->m_Drawings; + for ( ; DrawLibItem != NULL; DrawLibItem = DrawLibItem->Next()) + { + if(DrawLibItem->m_StructType != COMPONENT_PIN_DRAW_TYPE) continue; + + LibDrawPin * Pin = (LibDrawPin *) DrawLibItem; + + if( Pin->m_Unit && DrawLibItem->m_Unit && + (DrawLibItem->m_Unit != Pin->m_Unit) ) + continue; + + if( Pin->m_Convert && DrawLibItem->m_Convert && + (DrawLibItem->m_Convert != Pin->m_Convert) ) + continue; + + item = new DanglingEndHandle(PIN_END); + item->m_Item = Pin; + item->m_Pos = ReturnPinPhysicalPosition( Pin,STRUCT); + if ( lastitem ) lastitem->m_Pnext = item; + else StartList = item; + lastitem = item; + } + break; + + } + + case DRAW_SHEET_STRUCT_TYPE: + { + #undef STRUCT + #define STRUCT ((DrawSheetStruct*)DrawItem) + DrawSheetLabelStruct * pinsheet = STRUCT->m_Label; + while(pinsheet) + { + item = new DanglingEndHandle(SHEET_LABEL_END); + item->m_Item = pinsheet; + item->m_Pos = pinsheet->m_Pos; + if ( lastitem ) lastitem->m_Pnext = item; + else StartList = item; + lastitem = item; + pinsheet = (DrawSheetLabelStruct*)pinsheet->Pnext; + } + break; + } + } + } + return StartList; +} diff --git a/eeschema/database.cpp b/eeschema/database.cpp new file mode 100644 index 0000000000..9489a0e705 --- /dev/null +++ b/eeschema/database.cpp @@ -0,0 +1,131 @@ + /****************************/ + /* EESchema - database.cpp */ + /****************************/ + +/* Routine de selection d'un composant en librairie +*/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + + +/* Routines locales */ + +/* Variables locales */ + + +/********************************************************************************/ +bool DataBaseGetName(WinEDA_DrawFrame * frame, + wxString & Keys, wxString & BufName) +/********************************************************************************/ +/* + Routine de selection du nom d'un composant en librairie pour chargement, + Keys pointe la liste des mots cles de filtrage + Si Keys = "", recherche des composants qui correspondent +au masque BufName( avec * et ? ) + + Retourne + TRUE si composant selectionne + FALSE si commande annulee + place le nom du composant a charger, selectionne a partir d'une liste dans + BufName +*/ +{ +int ii; +EDA_LibComponentStruct * LibEntry; +LibraryStruct * Lib; +WinEDAListBox * ListBox; +const wxChar ** ListNames; + + BufName.MakeUpper(); + Keys.MakeUpper(); + + /* Examen de la liste des librairies pour comptage */ + for (Lib = g_LibraryList, ii = 0; Lib != NULL; Lib = Lib->m_Pnext) + { + LibEntry = (EDA_LibComponentStruct *) PQFirst(&Lib->m_Entries, FALSE); + while( LibEntry ) + { + if ( ! Keys.IsEmpty() ) + { + if( KeyWordOk(Keys, LibEntry->m_KeyWord) ) ii++; + } + else + { + if( WildCompareString( BufName, LibEntry->m_Name.m_Text, FALSE ) ) ii++; + } + LibEntry = (EDA_LibComponentStruct *) PQNext(Lib->m_Entries, LibEntry, NULL); + } + } + + if ( ii == 0 ) + { + DisplayError(frame, _("No Component found") ); + return 0; + } + + ListNames = (const wxChar**)MyZMalloc( (ii+1) * sizeof(const wxChar*)); + for (Lib = g_LibraryList, ii = 0; Lib != NULL; Lib = Lib->m_Pnext) + { + /* Examen de la liste des elements */ + LibEntry = (EDA_LibComponentStruct *) PQFirst(&Lib->m_Entries, FALSE); + while( LibEntry ) + { + if ( ! Keys.IsEmpty()) + { + if( KeyWordOk(Keys, LibEntry->m_KeyWord) ) + { + ListNames[ii] = LibEntry->m_Name.m_Text.GetData(); ii++; + } + } + else if( WildCompareString( BufName, LibEntry->m_Name.m_Text, FALSE ) ) + { + ListNames[ii] = LibEntry->m_Name.m_Text; ii++; + } + LibEntry = (EDA_LibComponentStruct *) PQNext(Lib->m_Entries, LibEntry, NULL); + } + } + + ListBox = new WinEDAListBox(frame, _("Selection"), ListNames, + wxEmptyString, DisplayCmpDoc, wxColour(200,200,255) ); + ListBox->MoveMouseToOrigin(); + + /* Affichage de la liste selectionnee */ + if( ii ) + { + ii = ListBox->ShowModal(); ListBox->Destroy(); + if ( ii < 0 ) ii = 0; + else + { + BufName = ListNames[ii]; + ii = 1; + } + } + + + free (ListNames); + return (ii) ; +} + + +/**********************************/ +void DisplayCmpDoc(wxString & Name) +/**********************************/ +{ +LibCmpEntry * CmpEntry; + + CmpEntry = FindLibPart(Name.GetData(), wxEmptyString, FIND_ALIAS); + if ( CmpEntry == NULL ) return; + + Name = wxT("Descr: ") + CmpEntry->m_Doc; + Name += wxT("\nKeyW: ") + CmpEntry->m_KeyWord; +} + + diff --git a/eeschema/delete.cpp b/eeschema/delete.cpp new file mode 100644 index 0000000000..08c1844643 --- /dev/null +++ b/eeschema/delete.cpp @@ -0,0 +1,495 @@ + /************************************/ + /* Delete.cpp: routines d'effacement */ + /************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" + +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +#define SELECTEDNODE 1 /* flag indiquant que la structure a deja selectionnee */ +#define STRUCT_DELETED 2 /* Bit flag de Status pour structures effacee */ +#define CANDIDATE 4 /* flag indiquant que la structure est connectee */ +#define SKIP_STRUCT 8 /* flag indiquant que la structure ne doit pas etre traitee */ + +/********************************************************************************/ +static int CountConnectedItems(WinEDA_SchematicFrame * frame, + EDA_BaseStruct * ListStruct, wxPoint pos, bool TstJunction) +/********************************************************************************/ +/* Count number of items connected to point pos : + pins, end wire or bus, and junctions if TstJunction == TRUE + Return this count + + Used by WinEDA_SchematicFrame::DeleteConnection() +*/ +{ +EDA_BaseStruct * Struct; +int count = 0; + + if ( frame->LocatePinEnd(ListStruct, pos) ) count++; + + for ( Struct = ListStruct; Struct != NULL; Struct = Struct->Pnext) + { + if ( Struct->m_Flags & STRUCT_DELETED ) continue; + if ( Struct->m_Flags & SKIP_STRUCT ) continue; + + + if ( TstJunction && (Struct->m_StructType == DRAW_JUNCTION_STRUCT_TYPE) ) + { + #define JUNCTION ((DrawJunctionStruct*)Struct) + if ( (JUNCTION->m_Pos.x == pos.x) && (JUNCTION->m_Pos.y == pos.y) ) + count++; + #undef JUNCTION + } + + if ( Struct->m_StructType != DRAW_SEGMENT_STRUCT_TYPE ) continue; + #define SEGM ((EDA_DrawLineStruct*)Struct) + if ( SEGM->IsOneEndPointAt(pos) ) count++; + #undef SEGM + } + + return count; +} + +/************************************************************************************/ +static bool MarkConnected(WinEDA_SchematicFrame * frame, EDA_BaseStruct * ListStruct, + EDA_DrawLineStruct* segment) +/************************************************************************************/ +/* Mark to "CANDIDATE" all wires or junction connected to "segment" in list "ListStruct" + Search wire stop at an any pin + + Used by WinEDA_SchematicFrame::DeleteConnection() +*/ +{ +EDA_BaseStruct * Struct; + + for ( Struct = ListStruct; Struct != NULL; Struct = Struct->Pnext) + { + if ( Struct->m_Flags ) continue; + if ( Struct->m_StructType == DRAW_JUNCTION_STRUCT_TYPE ) + { + #define JUNCTION ((DrawJunctionStruct*)Struct) + if ( segment->IsOneEndPointAt(JUNCTION->m_Pos) ) Struct->m_Flags |= CANDIDATE; + continue; + #undef JUNCTION + } + + if ( Struct->m_StructType != DRAW_SEGMENT_STRUCT_TYPE ) continue; + + #define SEGM ((EDA_DrawLineStruct*)Struct) + if ( segment->IsOneEndPointAt(SEGM->m_Start) ) + { + if ( ! frame->LocatePinEnd(ListStruct,SEGM->m_Start) ) + { + Struct->m_Flags |= CANDIDATE; + MarkConnected(frame, ListStruct, SEGM); + } + } + if ( segment->IsOneEndPointAt(SEGM->m_End) ) + { + if ( ! frame->LocatePinEnd(ListStruct,SEGM->m_End) ) + { + Struct->m_Flags |= CANDIDATE; + MarkConnected(frame, ListStruct, SEGM); + } + } + #undef SEGM + } + + return TRUE; +} + +/********************************************************************************/ +void WinEDA_SchematicFrame::DeleteConnection(wxDC * DC, bool DeleteFullConnection) +/********************************************************************************/ +/* Delete a connection, i.e wires or bus connected + stop on a node (more than 2 wires (bus) connected) +*/ +{ +wxPoint refpos = GetScreen()->m_Curseur; +EDA_BaseStruct * DelStruct ; +DrawPickedStruct * PickedItem, *PickedList = NULL; + + /* Clear .m_Flags member for all items */ + for(DelStruct = GetScreen()->EEDrawList; DelStruct != NULL; DelStruct=DelStruct->Pnext) + DelStruct->m_Flags = 0; + + BreakSegmentOnJunction( GetScreen() ); + DelStruct = GetScreen()->EEDrawList; + + /* Locate all the wires, bus or junction under the mouse cursor, and put them in a list + of items to delete + */ + while ( DelStruct && + (DelStruct = PickStruct(GetScreen()->m_Curseur, + DelStruct, JUNCTIONITEM|WIREITEM|BUSITEM)) != NULL ) + { + DelStruct->m_Flags = SELECTEDNODE|STRUCT_DELETED; + /* Put this structure in the picked list: */ + PickedItem = new DrawPickedStruct(DelStruct); + PickedItem->Pnext = PickedList; + PickedList = PickedItem; + DelStruct=DelStruct->Pnext; + } + + /* Mark all wires, junctions, .. connected to one of the item to delete + */ + if ( DeleteFullConnection ) + { + for ( DelStruct = GetScreen()->EEDrawList; DelStruct != NULL; DelStruct = DelStruct->Pnext) + { + if ( ! (DelStruct->m_Flags & SELECTEDNODE) ) continue; + #define SEGM ((EDA_DrawLineStruct*)DelStruct) + if ( DelStruct->m_StructType != DRAW_SEGMENT_STRUCT_TYPE ) continue; + MarkConnected(this, GetScreen()->EEDrawList, SEGM); + #undef SEGM + } + + // Search all removable wires (i.e wire with one new dangling end ) + for ( DelStruct = GetScreen()->EEDrawList; DelStruct != NULL; DelStruct = DelStruct->Pnext) + { + bool noconnect = FALSE; + + if ( DelStruct->m_Flags & STRUCT_DELETED ) continue; // Already seen + if ( ! (DelStruct->m_Flags & CANDIDATE) ) continue; // Already seen + if ( DelStruct->m_StructType != DRAW_SEGMENT_STRUCT_TYPE ) continue; + DelStruct->m_Flags |= SKIP_STRUCT; + #define SEGM ((EDA_DrawLineStruct*)DelStruct) + /* Test the SEGM->m_Start point: if this point was connected to an STRUCT_DELETED wire, + and now is not connected, the wire can be deleted */ + EDA_BaseStruct * removed_struct; + for ( removed_struct = GetScreen()->EEDrawList; removed_struct != NULL; removed_struct = removed_struct->Pnext) + { + if( (removed_struct->m_Flags & STRUCT_DELETED) == 0 ) continue; + if ( removed_struct->m_StructType != DRAW_SEGMENT_STRUCT_TYPE ) continue; + #define WIRE ((EDA_DrawLineStruct*)removed_struct) + if ( WIRE->IsOneEndPointAt(SEGM->m_Start) ) break; + } + + if ( WIRE && ! CountConnectedItems(this, GetScreen()->EEDrawList, SEGM->m_Start, TRUE) ) + noconnect = TRUE; + /* Test the SEGM->m_End point: if this point was connected to an STRUCT_DELETED wire, + and now is not connected, the wire can be deleted */ + for ( removed_struct = GetScreen()->EEDrawList; removed_struct != NULL; removed_struct = removed_struct->Pnext) + { + if( (removed_struct->m_Flags & STRUCT_DELETED) == 0 ) continue; + if ( removed_struct->m_StructType != DRAW_SEGMENT_STRUCT_TYPE ) continue; + if ( WIRE->IsOneEndPointAt(SEGM->m_End) ) break; + } + if ( removed_struct && ! CountConnectedItems(this, GetScreen()->EEDrawList, SEGM->m_End, TRUE) ) + noconnect = TRUE; + DelStruct->m_Flags &= ~SKIP_STRUCT; + + if ( noconnect ) + { + DelStruct->m_Flags |= STRUCT_DELETED; + /* Put this structure in the picked list: */ + PickedItem = new DrawPickedStruct(DelStruct); + PickedItem->Pnext = PickedList; + PickedList = PickedItem; + DelStruct = GetScreen()->EEDrawList; + } + #undef SEGM + } + + // Delete redundant junctions (junctions which connect < 3 end wires and no pin are removed) + for ( DelStruct = GetScreen()->EEDrawList; DelStruct != NULL; DelStruct = DelStruct->Pnext) + { + int count; + if ( DelStruct->m_Flags & STRUCT_DELETED ) continue; + if ( ! (DelStruct->m_Flags & CANDIDATE) ) continue; + if ( DelStruct->m_StructType == DRAW_JUNCTION_STRUCT_TYPE ) + { + #define JUNCTION ((DrawJunctionStruct*)DelStruct) + count = CountConnectedItems(this, GetScreen()->EEDrawList, JUNCTION->m_Pos, FALSE); + if ( count <= 2 ) + { + DelStruct->m_Flags |= STRUCT_DELETED; + /* Put this structure in the picked list: */ + PickedItem = new DrawPickedStruct(DelStruct); + PickedItem->Pnext = PickedList; + PickedList = PickedItem; + } + #undef JUNCTION + } + } + + // Delete labels attached to wires + wxPoint pos = GetScreen()->m_Curseur; + for ( DelStruct = GetScreen()->EEDrawList; DelStruct != NULL; DelStruct = DelStruct->Pnext) + { + if ( DelStruct->m_Flags & STRUCT_DELETED ) continue; + if ( DelStruct->m_StructType != DRAW_LABEL_STRUCT_TYPE ) continue; + GetScreen()->m_Curseur = ((DrawTextStruct*)DelStruct)->m_Pos; + EDA_BaseStruct * TstStruct = + PickStruct(GetScreen()->m_Curseur, GetScreen()->EEDrawList,WIREITEM|BUSITEM); + if ( TstStruct && TstStruct->m_Flags & STRUCT_DELETED ) + { + DelStruct->m_Flags |= STRUCT_DELETED; + /* Put this structure in the picked list: */ + PickedItem = new DrawPickedStruct(DelStruct); + PickedItem->Pnext = PickedList; + PickedList = PickedItem; + } + } + GetScreen()->m_Curseur = pos; + } + + for ( DelStruct = GetScreen()->EEDrawList; DelStruct != NULL; DelStruct = DelStruct->Pnext) + DelStruct->m_Flags = 0; + + if ( PickedList ) + { + DeleteStruct(DrawPanel, DC, PickedList); + GetScreen()->SetModify(); + } + +} + + +/*****************************************************************/ +void LocateAndDeleteItem(WinEDA_SchematicFrame * frame, wxDC * DC) +/*****************************************************************/ + +/* Routine d'effacement d'un element de schema ( et placement en "undelete" ) + si plusieurs elements sont superposes: ordre de priorite: + 1 : MARQUEUR + 2 : JUNCTION + 2 : NOCONNECT + 3 : WIRE ou BUS + 4 : DRAWITEM + 5 : TEXT + 6 : COMPOSANT + 7 : SHEET +*/ + +{ +EDA_BaseStruct * DelStruct; +SCH_SCREEN * screen = frame->GetScreen(); + + DelStruct = PickStruct(screen->m_Curseur, + screen->EEDrawList, MARKERITEM); + if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur, + screen->EEDrawList, JUNCTIONITEM); + if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur, + screen->EEDrawList, NOCONNECTITEM); + if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur, + screen->EEDrawList, RACCORDITEM); + if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur, + screen->EEDrawList, WIREITEM|BUSITEM); + if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur, + screen->EEDrawList, DRAWITEM); + if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur, + screen->EEDrawList, TEXTITEM|LABELITEM); + if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur, + screen->EEDrawList, LIBITEM); + if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur, + screen->EEDrawList, SHEETITEM); + + if (DelStruct) + { + g_ItemToRepeat = NULL; + DeleteStruct(frame->DrawPanel, DC, DelStruct); + frame->TestDanglingEnds(frame->m_CurrentScreen->EEDrawList, DC); + frame->GetScreen()->SetModify(); + } +} + + + + +/***************************************************************/ +void EraseStruct(EDA_BaseStruct *DrawStruct, SCH_SCREEN * Screen) +/***************************************************************/ +/* Suppression definitive d'une structure dans une liste chainee + d'elements de dessin + DrawStruct = pointeur sur la structure + Screen = pointeur sur l'ecran d'appartenance + Le chainage de la liste est modifie. + + Remarque: + pour les structures DRAW_SHEET_STRUCT_TYPE, l'ecran et les structures + correspondantes ne sont pas touches. + Ils doivent etre traites separement +*/ +{ +EDA_BaseStruct *DrawList; +DrawPickedStruct *PickedList = NULL; +DrawSheetLabelStruct* SheetLabel, *NextLabel; + + if( DrawStruct == NULL ) return; + if( Screen == NULL ) return; + + Screen->SetModify(); + + if (DrawStruct->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE) + { /* Cette stucture est rattachee a une feuille, et n'est pas + accessible par la liste globale directement */ + DrawList = Screen->EEDrawList; + for ( ; DrawList != NULL; DrawList = DrawList->Pnext ) + { + if(DrawList->m_StructType != DRAW_SHEET_STRUCT_TYPE) continue; + /* Examen de la Sheet */ + SheetLabel = ((DrawSheetStruct *) DrawList)->m_Label; + if (SheetLabel == NULL) continue; + if (SheetLabel == (DrawSheetLabelStruct*) DrawStruct) + { + ((DrawSheetStruct *) DrawList)->m_Label = + (DrawSheetLabelStruct *)SheetLabel->Pnext; + delete DrawStruct; + return; + } + else while( SheetLabel->Pnext )/* Examen de la liste dependante */ + { + NextLabel = (DrawSheetLabelStruct *)SheetLabel->Pnext; + if( NextLabel == (DrawSheetLabelStruct*) DrawStruct ) + { + SheetLabel->Pnext = (EDA_BaseStruct *)NextLabel->Pnext; + delete DrawStruct; + return; + } + SheetLabel = NextLabel; + } + } + return; + } + + + if (DrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + PickedList = (DrawPickedStruct *) DrawStruct; + while (PickedList) + { + if (PickedList->m_PickedStruct == Screen->EEDrawList) + { + Screen->EEDrawList = Screen->EEDrawList->Pnext; + delete DrawStruct; + } + else + { + DrawList = Screen->EEDrawList; + while ( DrawList && DrawList->Pnext) + { + if (DrawList->Pnext == PickedList->m_PickedStruct) + { + DrawList->Pnext = DrawList->Pnext->Pnext; + delete DrawStruct; + return; + } + DrawList = DrawList->Pnext; + } + } + PickedList = (DrawPickedStruct *)PickedList->Pnext; + } + } + else // structure usuelle */ + { + if (DrawStruct == Screen->EEDrawList) + { + Screen->EEDrawList = DrawStruct->Pnext; + delete DrawStruct; + } + else + { + DrawList = Screen->EEDrawList; + while (DrawList && DrawList->Pnext) + { + if (DrawList->Pnext == DrawStruct) + { + DrawList->Pnext = DrawStruct->Pnext; + delete DrawStruct; + return; + } + DrawList = DrawList->Pnext; + } + } + } +} + + + +/********************************/ +void DeleteAllMarkers(int type) +/********************************/ +/* Effacement des marqueurs du type "type" */ +{ +SCH_SCREEN * screen; +EDA_BaseStruct * DrawStruct, * NextStruct; +DrawMarkerStruct * Marker; + + EDA_ScreenList ScreenList(NULL); + for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + for ( DrawStruct = screen->EEDrawList; DrawStruct != NULL; DrawStruct = NextStruct) + { + NextStruct = DrawStruct->Pnext; + if(DrawStruct->m_StructType != DRAW_MARKER_STRUCT_TYPE ) continue; + /* Marqueur trouve */ + Marker = (DrawMarkerStruct * ) DrawStruct; + if( Marker->m_Type != type ) continue; + /* Suppression du marqueur */ + EraseStruct( DrawStruct, screen); + } + } +} + +/********************************************************************/ +void DeleteOneLibraryDrawStruct(WinEDA_DrawPanel * panel, wxDC * DC, + EDA_LibComponentStruct * LibEntry, + LibEDA_BaseStruct * DrawItem, int Affiche) +/********************************************************************/ +/* Routine d'effacement d'un "LibraryDrawStruct" + (d'un element de dessin d'un composant ) + + Parametres d'entree + Pointeur sur le composant comportant la structure + (Si NULL la structure a effacer est supposee non rattachee + a un composant) + Pointeur sur la structure a effacer + + Efface egalement le graphique correspondant de l'ecran +*/ +{ +LibEDA_BaseStruct *PreviousDrawItem; + + /* Effacement du graphique */ + if( Affiche && DC) + DrawLibraryDrawStruct(panel, DC, LibEntry, 0 , 0, DrawItem, CurrentUnit, g_XorMode); + + /* Effacement de la structure en memoire */ + if( LibEntry ) /* Recherche du predecesseur */ + { + PreviousDrawItem = LibEntry->m_Drawings; + + /* Cas du 1er symbole graphique = struct a supprimer */ + if( LibEntry->m_Drawings == DrawItem ) + { + LibEntry->m_Drawings = DrawItem->Next(); + delete DrawItem; + } + + else /* Cas des autres items */ + while(PreviousDrawItem) + { + if(PreviousDrawItem->Pnext == DrawItem) + { + PreviousDrawItem->Pnext = DrawItem->Pnext; + delete DrawItem; break; + } + PreviousDrawItem = PreviousDrawItem->Next(); + } + } + + else /* Structure non reliee a un composant */ + { + delete DrawItem; + } +} + + diff --git a/eeschema/delsheet.cpp b/eeschema/delsheet.cpp new file mode 100644 index 0000000000..7b2b121ef1 --- /dev/null +++ b/eeschema/delsheet.cpp @@ -0,0 +1,113 @@ + /*******************************************************/ + /* delsheet.cpp Routine d'effacement d'une hierarchie */ + /*******************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + + +/**************************************************************************/ +void DeleteSubHierarchy(DrawSheetStruct * FirstSheet, bool confirm_deletion) +/**************************************************************************/ + +/* Free (delete) all schematic data (include the sub hierarchy sheets ) + for the hierarchical sheet FirstSheet + FirstSheet is not deleted. +*/ +{ +EDA_BaseStruct *DrawStruct; +EDA_BaseStruct *EEDrawList; +WinEDA_SchematicFrame * frame = EDA_Appl->SchematicFrame; +wxString msg; + + if( FirstSheet == NULL ) return; + + if( FirstSheet->m_StructType != DRAW_SHEET_STRUCT_TYPE) + { + DisplayError(NULL, + wxT("DeleteSubHierarchy error(): NOT a Sheet")); + return; + } + + /* effacement du sous schema correspondant */ + if( FirstSheet->IsModify() && confirm_deletion ) + { + msg.Printf( _("Sheet %s (file %s) modified. Save it?"), + FirstSheet->m_SheetName.GetData(), + FirstSheet->m_FileName.GetData()); + if( IsOK(NULL, msg) ) + { + frame->SaveEEFile(FirstSheet, FILE_SAVE_AS); + } + } + + /* free the sub hierarchy */ + EEDrawList = FirstSheet->EEDrawList; + while (EEDrawList != NULL) + { + DrawStruct = EEDrawList; + EEDrawList = EEDrawList->Pnext; + if( DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) + { + DeleteSubHierarchy((DrawSheetStruct *) DrawStruct, confirm_deletion); + } + } + + /* Effacement des elements de la feuille courante */ + FirstSheet->FreeDrawList(); +} + +/*********************************************************************/ +void ClearDrawList(EDA_BaseStruct *DrawList, bool confirm_deletion) +/********************************************************************/ +/* free the draw list DrawList and the subhierarchies */ +{ +EDA_BaseStruct *DrawStruct; + + while (DrawList != NULL) + { + DrawStruct = DrawList; + DrawList = DrawList->Pnext; + + if( DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) + { + DeleteSubHierarchy((DrawSheetStruct*) DrawStruct, confirm_deletion); + } + + delete DrawStruct; + } +} + +/********************************************************************/ +bool ClearProjectDrawList(SCH_SCREEN * screen, bool confirm_deletion) +/********************************************************************/ +/* free the draw list screen->EEDrawList and the subhierarchies + clear the screen datas (filenames ..) +*/ +{ + if ( screen == NULL ) return(TRUE); + + ClearDrawList(screen->EEDrawList, confirm_deletion); + screen->EEDrawList = NULL; + + /* Clear the screen datas */ + screen->m_SheetNumber = screen->m_NumberOfSheet = 1; + screen->m_Title.Empty(); + screen->m_Revision.Empty(); + screen->m_Company.Empty(); + screen->m_Commentaire1.Empty(); + screen->m_Commentaire2.Empty(); + screen->m_Commentaire3.Empty(); + screen->m_Commentaire4.Empty(); + screen->m_Date = GenDate(); + + return TRUE; +} + diff --git a/eeschema/dialog_build_BOM.cpp b/eeschema/dialog_build_BOM.cpp new file mode 100644 index 0000000000..12826a003f --- /dev/null +++ b/eeschema/dialog_build_BOM.cpp @@ -0,0 +1,985 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_build_BOM.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 01/15/06 18:18:44 +// RCS-ID: +// Copyright: GNU license +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 01/15/06 18:18:44 + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma implementation "dialog_build_BOM.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +#include "fctsys.h" + +////@begin includes +////@end includes + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "netlist.h" + +#include "dialog_build_BOM.h" + + +#include "protos.h" + +////@begin XPM images +////@end XPM images + + +/* Structures pour memo et liste des elements */ +typedef struct ListLabel +{ + int m_StructType; + void * m_Label; + int m_SheetNumber; +} ListLabel; + + +/* fonctions locales */ +static int GenListeGLabels( ListLabel * List ); +static int ListTriComposantByRef(EDA_SchComponentStruct **Objet1, + EDA_SchComponentStruct **Objet2); +static int ListTriComposantByVal(EDA_SchComponentStruct **Objet1, + EDA_SchComponentStruct **Objet2); +static int ListTriGLabelBySheet(ListLabel *Objet1, ListLabel *Objet2); +static int ListTriGLabelByVal(ListLabel *Objet1, ListLabel *Objet2); +static void DeleteSubCmp( EDA_BaseStruct ** List , int NbItems); + +static int PrintListeGLabel( FILE *f, ListLabel *List, int NbItems); + +/* Local variables */ +static bool s_ListByRef = TRUE; +static bool s_ListByValue = TRUE; +static bool s_ListWithSubCmponents; +static bool s_ListHierarchicalPinByName; +static bool s_ListBySheet; +static bool s_BrowsList; +static bool s_Add_F1_state; +static bool s_Add_F2_state; +static bool s_Add_F3_state; +static bool s_Add_F4_state; +static bool s_Add_F5_state; +static bool s_Add_F6_state; +static bool s_Add_F7_state; +static bool s_Add_F8_state; + +/*! + * WinEDA_Build_BOM_Frame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_Build_BOM_Frame, wxDialog ) + +/*! + * WinEDA_Build_BOM_Frame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_Build_BOM_Frame, wxDialog ) + +////@begin WinEDA_Build_BOM_Frame event table entries + EVT_CLOSE( WinEDA_Build_BOM_Frame::OnCloseWindow ) + + EVT_BUTTON( wxID_OK, WinEDA_Build_BOM_Frame::OnOkClick ) + + EVT_BUTTON( wxID_EXIT, WinEDA_Build_BOM_Frame::OnExitClick ) + +////@end WinEDA_Build_BOM_Frame event table entries + +END_EVENT_TABLE() + +/***************************************************************/ +void InstallToolsFrame(WinEDA_DrawFrame *parent, wxPoint & pos) +/***************************************************************/ +{ + WinEDA_Build_BOM_Frame * frame = new WinEDA_Build_BOM_Frame(parent); + frame->ShowModal(); frame->Destroy(); +} + +/*! + * WinEDA_Build_BOM_Frame constructors + */ + +WinEDA_Build_BOM_Frame::WinEDA_Build_BOM_Frame( ) +{ +} + +WinEDA_Build_BOM_Frame::WinEDA_Build_BOM_Frame( WinEDA_DrawFrame* parent, + wxWindowID id, const wxString& caption, const wxPoint& pos, + const wxSize& size, long style ) +{ + m_Parent = parent; + Create(parent, id, caption, pos, size, style); +} + +/*! + * WinEDA_Build_BOM_Frame creator + */ + +bool WinEDA_Build_BOM_Frame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_Build_BOM_Frame member initialisation + m_ListCmpbyRefItems = NULL; + m_ListSubCmpItems = NULL; + m_ListCmpbyValItems = NULL; + m_GenListLabelsbyVal = NULL; + m_GenListLabelsbySheet = NULL; + m_FieldsToAppendListSizer = NULL; + m_AddField1 = NULL; + m_AddField2 = NULL; + m_AddField3 = NULL; + m_AddField4 = NULL; + m_AddField5 = NULL; + m_AddField6 = NULL; + m_AddField7 = NULL; + m_AddField8 = NULL; + m_GetListBrowser = NULL; +////@end WinEDA_Build_BOM_Frame member initialisation + +////@begin WinEDA_Build_BOM_Frame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + if (GetSizer()) + { + GetSizer()->SetSizeHints(this); + } + Centre(); +////@end WinEDA_Build_BOM_Frame creation + return TRUE; +} + +/*! + * Control creation for WinEDA_Build_BOM_Frame + */ + +void WinEDA_Build_BOM_Frame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_Build_BOM_Frame content construction + // Generated by DialogBlocks, 07/08/2006 10:59:57 (unregistered) + + WinEDA_Build_BOM_Frame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer4Static = new wxStaticBox(itemDialog1, wxID_ANY, _("List items : ")); + wxStaticBoxSizer* itemStaticBoxSizer4 = new wxStaticBoxSizer(itemStaticBoxSizer4Static, wxVERTICAL); + itemBoxSizer3->Add(itemStaticBoxSizer4, 0, wxGROW|wxALL, 5); + + m_ListCmpbyRefItems = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Components by Reference"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_ListCmpbyRefItems->SetValue(true); + itemStaticBoxSizer4->Add(m_ListCmpbyRefItems, 0, wxGROW|wxALL, 5); + + m_ListSubCmpItems = new wxCheckBox( itemDialog1, ID_CHECKBOX2, _("Sub Components (i.e U2A, U2B..)"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_ListSubCmpItems->SetValue(false); + itemStaticBoxSizer4->Add(m_ListSubCmpItems, 0, wxGROW|wxALL, 5); + + m_ListCmpbyValItems = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Components by Value"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_ListCmpbyValItems->SetValue(true); + itemStaticBoxSizer4->Add(m_ListCmpbyValItems, 0, wxGROW|wxALL, 5); + + m_GenListLabelsbyVal = new wxCheckBox( itemDialog1, ID_CHECKBOX3, _("Hierachy Pins by name"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_GenListLabelsbyVal->SetValue(false); + itemStaticBoxSizer4->Add(m_GenListLabelsbyVal, 0, wxGROW|wxALL, 5); + + m_GenListLabelsbySheet = new wxCheckBox( itemDialog1, ID_CHECKBOX4, _("Hierachy Pins by Sheets"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_GenListLabelsbySheet->SetValue(false); + itemStaticBoxSizer4->Add(m_GenListLabelsbySheet, 0, wxGROW|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer10Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Fields to Add")); + m_FieldsToAppendListSizer = new wxStaticBoxSizer(itemStaticBoxSizer10Static, wxVERTICAL); + itemBoxSizer3->Add(m_FieldsToAppendListSizer, 0, wxGROW|wxALL, 5); + + m_AddField1 = new wxCheckBox( itemDialog1, ID_CHECKBOX_FIELD1, _("Add Field 1"), wxDefaultPosition, wxDefaultSize, 0 ); + m_AddField1->SetValue(false); + m_FieldsToAppendListSizer->Add(m_AddField1, 0, wxGROW|wxALL, 5); + + m_AddField2 = new wxCheckBox( itemDialog1, ID_CHECKBOX_FIELD2, _("Add Field 2"), wxDefaultPosition, wxDefaultSize, 0 ); + m_AddField2->SetValue(false); + m_FieldsToAppendListSizer->Add(m_AddField2, 0, wxGROW|wxALL, 5); + + m_AddField3 = new wxCheckBox( itemDialog1, ID_CHECKBOX_FIELD1, _("Add Field 3"), wxDefaultPosition, wxDefaultSize, 0 ); + m_AddField3->SetValue(false); + m_FieldsToAppendListSizer->Add(m_AddField3, 0, wxGROW|wxALL, 5); + + m_AddField4 = new wxCheckBox( itemDialog1, ID_CHECKBOX_FIELD4, _("Add Field 4"), wxDefaultPosition, wxDefaultSize, 0 ); + m_AddField4->SetValue(false); + m_FieldsToAppendListSizer->Add(m_AddField4, 0, wxGROW|wxALL, 5); + + m_AddField5 = new wxCheckBox( itemDialog1, ID_CHECKBOX_FIELD5, _("Add Field 5"), wxDefaultPosition, wxDefaultSize, 0 ); + m_AddField5->SetValue(false); + m_FieldsToAppendListSizer->Add(m_AddField5, 0, wxGROW|wxALL, 5); + + m_AddField6 = new wxCheckBox( itemDialog1, ID_CHECKBOX_FIELD6, _("Add Field 6"), wxDefaultPosition, wxDefaultSize, 0 ); + m_AddField6->SetValue(false); + m_FieldsToAppendListSizer->Add(m_AddField6, 0, wxGROW|wxALL, 5); + + m_AddField7 = new wxCheckBox( itemDialog1, ID_CHECKBOX_FIELD7, _("Add Field 7"), wxDefaultPosition, wxDefaultSize, 0 ); + m_AddField7->SetValue(false); + m_FieldsToAppendListSizer->Add(m_AddField7, 0, wxGROW|wxALL, 5); + + m_AddField8 = new wxCheckBox( itemDialog1, ID_CHECKBOX_FIELD8, _("Add Field 8"), wxDefaultPosition, wxDefaultSize, 0 ); + m_AddField8->SetValue(false); + m_FieldsToAppendListSizer->Add(m_AddField8, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer19 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer19, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton20 = new wxButton( itemDialog1, wxID_OK, _("&Create List"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton20->SetDefault(); + itemButton20->SetForegroundColour(wxColour(166, 0, 0)); + itemBoxSizer19->Add(itemButton20, 0, wxGROW|wxALL, 5); + + wxButton* itemButton21 = new wxButton( itemDialog1, wxID_EXIT, _("&Quit"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton21->SetForegroundColour(wxColour(0, 0, 210)); + itemBoxSizer19->Add(itemButton21, 0, wxGROW|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer22Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Options")); + wxStaticBoxSizer* itemStaticBoxSizer22 = new wxStaticBoxSizer(itemStaticBoxSizer22Static, wxHORIZONTAL); + itemBoxSizer2->Add(itemStaticBoxSizer22, 0, wxGROW|wxALL, 10); + + m_GetListBrowser = new wxCheckBox( itemDialog1, ID_CHECKBOX5, _("Launch list browser"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_GetListBrowser->SetValue(false); + itemStaticBoxSizer22->Add(m_GetListBrowser, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + // Set validators + m_ListCmpbyRefItems->SetValidator( wxGenericValidator(& s_ListByRef) ); + m_ListSubCmpItems->SetValidator( wxGenericValidator(& s_ListWithSubCmponents) ); + m_ListCmpbyValItems->SetValidator( wxGenericValidator(& s_ListByValue) ); + m_GenListLabelsbyVal->SetValidator( wxGenericValidator(& s_ListHierarchicalPinByName) ); + m_GenListLabelsbySheet->SetValidator( wxGenericValidator(& s_ListBySheet) ); + m_AddField1->SetValidator( wxGenericValidator(& s_Add_F1_state) ); + m_AddField2->SetValidator( wxGenericValidator(& s_Add_F2_state) ); + m_AddField3->SetValidator( wxGenericValidator(& s_Add_F3_state) ); + m_AddField4->SetValidator( wxGenericValidator(& s_Add_F4_state) ); + m_AddField5->SetValidator( wxGenericValidator(& s_Add_F5_state) ); + m_AddField6->SetValidator( wxGenericValidator(& s_Add_F6_state) ); + m_AddField7->SetValidator( wxGenericValidator(& s_Add_F7_state) ); + m_AddField8->SetValidator( wxGenericValidator(& s_Add_F8_state) ); + m_GetListBrowser->SetValidator( wxGenericValidator(& s_BrowsList) ); +////@end WinEDA_Build_BOM_Frame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_Build_BOM_Frame::ShowToolTips() +{ + return TRUE; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_Build_BOM_Frame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_Build_BOM_Frame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_Build_BOM_Frame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_Build_BOM_Frame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_Build_BOM_Frame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_Build_BOM_Frame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_Build_BOM_Frame::OnOkClick( wxCommandEvent& event ) +{ + GenList(); +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK in WinEDA_Build_BOM_Frame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK in WinEDA_Build_BOM_Frame. +} + + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_EXIT + */ + +void WinEDA_Build_BOM_Frame::OnExitClick( wxCommandEvent& event ) +{ + s_Add_F1_state = m_AddField1->GetValue(); + s_Add_F2_state = m_AddField2->GetValue(); + s_Add_F3_state = m_AddField3->GetValue(); + s_Add_F4_state = m_AddField4->GetValue(); + s_Add_F5_state = m_AddField5->GetValue(); + s_Add_F6_state = m_AddField6->GetValue(); + s_Add_F7_state = m_AddField7->GetValue(); + s_Add_F8_state = m_AddField8->GetValue(); + EndModal(0); +} + +/**********************************************************/ +void WinEDA_Build_BOM_Frame::GenList(void) +/**********************************************************/ +{ +#define EXT_LIST wxT(".lst") +wxString mask, filename; + + s_ListByRef = m_ListCmpbyRefItems->GetValue(); + s_ListByValue = m_ListCmpbyValItems->GetValue(); + s_ListWithSubCmponents = m_ListSubCmpItems->GetValue(); + s_ListHierarchicalPinByName = m_GenListLabelsbyVal->GetValue(); + s_ListBySheet = m_GenListLabelsbySheet->GetValue(); + s_BrowsList = m_GetListBrowser->GetValue(); + + m_ListFileName = ScreenSch->m_FileName; + ChangeFileNameExt(m_ListFileName, EXT_LIST); + mask = wxT("*"); mask += EXT_LIST; + + filename = EDA_FileSelector(_("Bill of material:"), + wxEmptyString, /* Chemin par defaut (ici dir courante) */ + m_ListFileName, /* nom fichier par defaut, et resultat */ + EXT_LIST, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + TRUE + ); + if ( filename.IsEmpty() ) return; + else m_ListFileName = filename; + + /* Close dialog and show le list, if wanted */ + GenereListeOfItems(m_ListFileName); + Close(); + + if ( s_BrowsList ) + { + wxString editorname = GetEditorName(); + AddDelimiterString(filename); + ExecuteFile(this, editorname, filename); + } +} + +/****************************************************************************/ +void WinEDA_Build_BOM_Frame::GenereListeOfItems(const wxString & FullFileName) +/****************************************************************************/ +/* + Routine principale pour la creation des listings ( composants et/ou labels + globaux et "sheet labels" ) +*/ +{ +FILE *f; +EDA_BaseStruct ** List; +ListLabel * ListOfLabels; +int NbItems; +char Line[1024]; +wxString msg; + + /* Creation de la liste des elements */ + if ((f = wxFopen(FullFileName, wxT("wt"))) == NULL) + { + msg = _("Failed to open file "); msg << FullFileName; + DisplayError(this, msg); + return; + } + + NbItems = GenListeCmp(NULL ); + if ( NbItems ) + { + List = (EDA_BaseStruct **) + MyZMalloc( NbItems * sizeof(EDA_BaseStruct **) ); + if (List == NULL ) + { + fclose(f); return; + } + + GenListeCmp(List); + + /* generation du fichier listing */ + DateAndTime(Line); + wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); + fprintf( f, "%s >> Creation date: %s\n", CONV_TO_UTF8(Title), Line ); + + /* Tri et impression de la liste des composants */ + + qsort( List, NbItems, sizeof( EDA_BaseStruct * ), + (int(*)(const void*, const void*))ListTriComposantByRef); + + if( ! s_ListWithSubCmponents ) DeleteSubCmp(List, NbItems); + + if( s_ListByRef ) + { + PrintListeCmpByRef(f, List, NbItems); + } + + if( s_ListByValue ) + { + qsort( List, NbItems, sizeof( EDA_BaseStruct * ), + (int(*)(const void*, const void*))ListTriComposantByVal); + PrintListeCmpByVal(f, List, NbItems); + } + MyFree( List ); + } + + /***************************************/ + /* Generation liste des Labels globaux */ + /***************************************/ + + NbItems = GenListeGLabels( NULL ); + if ( NbItems ) + { + ListOfLabels = (ListLabel *) MyZMalloc( NbItems * sizeof(ListLabel) ); + if (ListOfLabels == NULL ) + { + fclose(f); return; + } + + GenListeGLabels(ListOfLabels); + + /* Tri de la liste */ + if( s_ListBySheet ) + { + qsort( ListOfLabels, NbItems, sizeof( ListLabel ), + (int(*)(const void*, const void*))ListTriGLabelBySheet); + + msg.Printf( _("\n#Glob labels ( order = Sheet Number ) count = %d\n"), NbItems); + fprintf( f, "%s", CONV_TO_UTF8(msg)); + PrintListeGLabel(f, ListOfLabels, NbItems); + } + + if( s_ListHierarchicalPinByName ) + { + qsort( ListOfLabels, NbItems, sizeof( ListLabel ), + (int(*)(const void*, const void*))ListTriGLabelByVal); + + msg.Printf(_("\n#Glob labels ( order = Alphab. ) count = %d\n\n"), NbItems); + fprintf( f, "%s", CONV_TO_UTF8(msg)); + PrintListeGLabel(f, ListOfLabels, NbItems); + } + MyFree( ListOfLabels ); + } + + msg = _("\n#End List\n"); + fprintf( f, "%s", CONV_TO_UTF8(msg)); + fclose(f); +} + + + +/****************************************/ +int GenListeCmp( EDA_BaseStruct ** List ) +/****************************************/ +/* Routine de generation de la liste des elements utiles du dessin + Si List == NULL: comptage des elements + Sinon remplissage de la liste + Initialise "FlagControlMulti" a SheetNumber pour la sortie des listes + et m_Father comme pointeur sur la sheet d'appartenance +*/ +{ +int ItemCount = 0; +EDA_BaseStruct *DrawList; +EDA_SchComponentStruct *DrawLibItem; +BASE_SCREEN * screen; + + /* Build the screen list */ + EDA_ScreenList ScreenList(NULL); + + for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + DrawList = screen->EEDrawList; + while ( DrawList ) + { + switch( DrawList->m_StructType ) + { + + case DRAW_LIB_ITEM_STRUCT_TYPE : + ItemCount++; + DrawLibItem = (EDA_SchComponentStruct *) DrawList; + DrawLibItem->m_FlagControlMulti = screen->m_SheetNumber; + DrawLibItem->m_Parent = screen; + if( List ) + { + *List = DrawList; List++; + } + break; + + + default: break; + } + DrawList = DrawList->Pnext; + } + } + return ( ItemCount ); +} + +/*********************************************/ +static int GenListeGLabels( ListLabel * List ) +/*********************************************/ +/* Count the Glabels, or fill the list Listwith Glabel pointers + If List == NULL: Item count only + Else fill list of Glabels +*/ +{ +int ItemCount = 0; +EDA_BaseStruct *DrawList; +DrawSheetLabelStruct *SheetLabel; +BASE_SCREEN * screen; + + /* Build the screen list */ + EDA_ScreenList ScreenList(NULL); + + for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + DrawList = screen->EEDrawList; + while ( DrawList ) + { + switch( DrawList->m_StructType ) + { + case DRAW_GLOBAL_LABEL_STRUCT_TYPE : + ItemCount++; + if( List ) + { + List->m_StructType = DRAW_GLOBAL_LABEL_STRUCT_TYPE; + List->m_SheetNumber = screen->m_SheetNumber; + List->m_Label = DrawList; + List++; + } + break; + + case DRAW_SHEET_STRUCT_TYPE : + { + #define Sheet ((DrawSheetStruct * ) DrawList) + SheetLabel= Sheet->m_Label; + while( SheetLabel != NULL ) + { + if ( List ) + { + List->m_StructType = DRAW_SHEETLABEL_STRUCT_TYPE; + List->m_SheetNumber = screen->m_SheetNumber; + List->m_Label = SheetLabel; + List++; + } + ItemCount++; + SheetLabel = (DrawSheetLabelStruct*)(SheetLabel->Pnext); + } + break; + } + + default: break; + } + DrawList = DrawList->Pnext; + } + } + return ( ItemCount ); +} + +/**********************************************************/ +static int ListTriComposantByVal(EDA_SchComponentStruct **Objet1, + EDA_SchComponentStruct **Objet2) +/**********************************************************/ + /* Routine de comparaison pour le tri du Tableau par qsort() + Les composants sont tries + par valeur + si meme valeur: par reference + si meme valeur: par numero d'unite + +*/ +{ +int ii; +const wxString * Text1, *Text2; + + if( (*Objet1 == NULL) && (*Objet2 == NULL ) ) return(0); + if( *Objet1 == NULL) return(-1); + if( *Objet2 == NULL) return(1); + + Text1 = &(*Objet1)->m_Field[VALUE].m_Text; + Text2 = &(*Objet2)->m_Field[VALUE].m_Text; + ii = Text1->CmpNoCase(*Text2); + + if( ii == 0 ) + { + Text1 = &(*Objet1)->m_Field[REFERENCE].m_Text; + Text2 = &(*Objet2)->m_Field[REFERENCE].m_Text; + ii = Text1->CmpNoCase(*Text2); + } + + if ( ii == 0 ) + { + ii = (*Objet1)->m_Multi - (*Objet2)->m_Multi; + } + + return(ii); +} + +/**********************************************************/ +static int ListTriComposantByRef(EDA_SchComponentStruct **Objet1, + EDA_SchComponentStruct **Objet2) +/**********************************************************/ + /* Routine de comparaison pour le tri du Tableau par qsort() + Les composants sont tries + par reference + si meme referenece: par valeur + si meme valeur: par numero d'unite + +*/ +{ +int ii; +const wxString * Text1, *Text2; + + if( (*Objet1 == NULL) && (*Objet2 == NULL ) ) return(0); + if( *Objet1 == NULL) return(-1); + if( *Objet2 == NULL) return(1); + + Text1 = &(*Objet1)->m_Field[REFERENCE].m_Text; + Text2 = &(*Objet2)->m_Field[REFERENCE].m_Text; + ii = Text1->CmpNoCase(*Text2); + + if( ii == 0 ) + { + Text1 = &(*Objet1)->m_Field[VALUE].m_Text; + Text2 = &(*Objet2)->m_Field[VALUE].m_Text; + ii = Text1->CmpNoCase(*Text2); + } + + if ( ii == 0 ) + { + ii = (*Objet1)->m_Multi - (*Objet2)->m_Multi; + } + + return(ii); +} + +/******************************************************************/ +static int ListTriGLabelByVal(ListLabel *Objet1, ListLabel *Objet2) +/*******************************************************************/ +/* Routine de comparaison pour le tri du Tableau par qsort() + Les labels sont tries + par comparaison ascii + si meme valeur: par numero de sheet + +*/ +{ +int ii; +const wxString * Text1, *Text2; + + if( Objet1->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE ) + Text1 = &((DrawSheetLabelStruct *)Objet1->m_Label)->m_Text; + else + Text1 = &((DrawTextStruct *)Objet1->m_Label)->m_Text; + + if( Objet2->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE ) + Text2 = &((DrawSheetLabelStruct *)Objet2->m_Label)->m_Text; + else + Text2 = &((DrawTextStruct *)Objet2->m_Label)->m_Text; + ii = Text1->CmpNoCase(*Text2); + + if ( ii == 0 ) + { + ii = Objet1->m_SheetNumber - Objet2->m_SheetNumber; + } + + return(ii); +} + +/*******************************************************************/ +static int ListTriGLabelBySheet(ListLabel *Objet1, ListLabel *Objet2) +/*******************************************************************/ +/* Routine de comparaison pour le tri du Tableau par qsort() + Les labels sont tries + par sheet number + si meme valeur, par ordre alphabetique + +*/ +{ +int ii; +const wxString * Text1, *Text2; + + ii = Objet1->m_SheetNumber - Objet2->m_SheetNumber; + + if ( ii == 0 ) + { + if( Objet1->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE ) + Text1 = &((DrawSheetLabelStruct *)Objet1->m_Label)->m_Text; + else + Text1 = &((DrawTextStruct *)Objet1->m_Label)->m_Text; + + if( Objet2->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE ) + Text2 = &((DrawSheetLabelStruct *)Objet2->m_Label)->m_Text; + else + Text2 = &((DrawTextStruct *)Objet2->m_Label)->m_Text; + ii = Text1->CmpNoCase(*Text2); + } + + return(ii); +} + + + +/**************************************************************/ +static void DeleteSubCmp( EDA_BaseStruct ** List, int NbItems ) +/**************************************************************/ +/* Supprime les sous-composants, c'est a dire les descriptions redonnantes des +boitiers multiples + La liste des composant doit etre triee par reference et par num d'unite +*/ +{ +int ii; +EDA_SchComponentStruct * LibItem; +const wxString * OldName = NULL; + + for( ii = 0; ii < NbItems ; ii++ ) + { + LibItem = (EDA_SchComponentStruct *) List[ii]; + if ( LibItem == NULL ) continue; + if( OldName ) + { + if ( OldName->CmpNoCase( LibItem->m_Field[REFERENCE].m_Text ) == 0 ) + { + List[ii] = NULL; + } + } + OldName = &LibItem->m_Field[REFERENCE].m_Text; + } +} + + +/*******************************************************************************************/ +void WinEDA_Build_BOM_Frame::PrintFieldData(FILE * f, EDA_SchComponentStruct * DrawLibItem) +/*******************************************************************************************/ +{ +wxCheckBox * FieldListCtrl[FIELD8-FIELD1+1] = { + m_AddField1, + m_AddField2, + m_AddField3, + m_AddField4, + m_AddField5, + m_AddField6, + m_AddField7, + m_AddField8 +}; +int ii; +wxCheckBox * FieldCtrl = FieldListCtrl[0]; + + for ( ii = FIELD1; ii <= FIELD8; ii ++ ) + { + FieldCtrl = FieldListCtrl[ii-FIELD1]; + if ( FieldCtrl == NULL ) continue; + if ( ! FieldCtrl->IsChecked() ) continue; + fprintf(f, "; %-12s", CONV_TO_UTF8(DrawLibItem->m_Field[ii].m_Text)); + } +} + +/*********************************************************************************************/ +int WinEDA_Build_BOM_Frame::PrintListeCmpByRef( FILE * f, EDA_BaseStruct ** List, int NbItems ) +/*********************************************************************************************/ +/* Print the B.O.M sorted by reference +*/ +{ +int ii, Multi, Unit; +EDA_BaseStruct *DrawList; +EDA_SchComponentStruct *DrawLibItem; +EDA_LibComponentStruct *Entry; +char NameCmp[80]; +wxString msg; + + msg = _("\n#Cmp ( order = Reference )"); + if ( s_ListWithSubCmponents ) msg << _(" (with SubCmp)"); + fprintf( f, "%s\n", CONV_TO_UTF8(msg)); + + for ( ii = 0; ii < NbItems; ii++ ) + { + DrawList = List[ii]; + + if( DrawList == NULL ) continue; + if( DrawList->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) continue; + + DrawLibItem = (EDA_SchComponentStruct *) DrawList; + if( DrawLibItem->m_Field[REFERENCE].m_Text[0] == '#' ) continue; + + Multi = 0; Unit = ' '; + Entry = FindLibPart(DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if( Entry ) Multi = Entry->m_UnitCount; + if( (Multi > 1 ) && s_ListWithSubCmponents ) + Unit = DrawLibItem->m_Multi + 'A' - 1; + + sprintf( NameCmp,"%s%c", CONV_TO_UTF8(DrawLibItem->m_Field[REFERENCE].m_Text), + Unit); + fprintf(f, "| %-10s %-12s", + NameCmp, + CONV_TO_UTF8(DrawLibItem->m_Field[VALUE].m_Text)); + + if ( s_ListWithSubCmponents ) + { + BASE_SCREEN * screen = (BASE_SCREEN *)(DrawLibItem->m_Parent); + wxString sheetname; + if( screen->m_Parent ) + sheetname = ((DrawSheetStruct*)screen->m_Parent)->m_SheetName.GetData(); + else sheetname = _("Root"); + fprintf(f, " (Sheet %.2d: \"%s\")", DrawLibItem->m_FlagControlMulti, + CONV_TO_UTF8(sheetname)); + } + + PrintFieldData(f, DrawLibItem); + + fprintf(f,"\n"); + } + msg = _("#End Cmp\n"); + fprintf(f, CONV_TO_UTF8(msg)); + return(0); +} + +/*********************************************************************************************/ +int WinEDA_Build_BOM_Frame::PrintListeCmpByVal( FILE * f, EDA_BaseStruct ** List, int NbItems ) +/**********************************************************************************************/ +{ +int ii, Multi; +wxChar Unit; +EDA_BaseStruct *DrawList; +EDA_SchComponentStruct *DrawLibItem; +EDA_LibComponentStruct *Entry; +wxString msg; + + msg = _("\n#Cmp ( order = Value )"); + if ( s_ListWithSubCmponents ) msg << _(" (with SubCmp)"); + msg << wxT("\n"); + fprintf(f, CONV_TO_UTF8(msg)); + + for ( ii = 0; ii < NbItems; ii++ ) + { + DrawList = List[ii]; + + if( DrawList == NULL ) continue; + if( DrawList->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) continue; + + DrawLibItem = (EDA_SchComponentStruct *) DrawList; + if( DrawLibItem->m_Field[REFERENCE].m_Text[0] == '#' ) continue; + + Multi = 0; Unit = ' '; + Entry = FindLibPart(DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if( Entry ) Multi = Entry->m_UnitCount; + if( (Multi > 1 ) && s_ListWithSubCmponents ) + Unit = DrawLibItem->m_Multi + 'A' - 1; + msg = DrawLibItem->m_Field[REFERENCE].m_Text; + msg.Append(Unit); + + fprintf(f, "| %-12s %-10s", + CONV_TO_UTF8(DrawLibItem->m_Field[VALUE].m_Text), + CONV_TO_UTF8(msg) ); + if ( s_ListWithSubCmponents ) + { + fprintf(f, " (Sheet %.2d)", DrawLibItem->m_FlagControlMulti); + } + + PrintFieldData(f, DrawLibItem); + + fprintf(f,"\n"); + } + msg = _("#End Cmp\n"); + fprintf(f, CONV_TO_UTF8(msg)); + return(0); +} + + +/******************************************************************/ +static int PrintListeGLabel( FILE *f, ListLabel *List, int NbItems) +/******************************************************************/ +{ +int ii, jj; +DrawGlobalLabelStruct *DrawTextItem; +DrawSheetLabelStruct * DrawSheetLabel; +ListLabel * LabelItem; +wxString msg; + + for ( ii = 0; ii < NbItems; ii++ ) + { + LabelItem = & List[ii]; + + switch( LabelItem->m_StructType ) + { + case DRAW_GLOBAL_LABEL_STRUCT_TYPE : + DrawTextItem = (DrawGlobalLabelStruct *)(LabelItem->m_Label); + msg.Printf( + _("> %-28.28s Global (Sheet %.2d) pos: %3.3f, %3.3f\n"), + DrawTextItem->m_Text.GetData(), + LabelItem->m_SheetNumber, + (float)DrawTextItem->m_Pos.x / 1000, + (float)DrawTextItem->m_Pos.y / 1000); + + fprintf(f, CONV_TO_UTF8(msg)); + break; + + case DRAW_SHEETLABEL_STRUCT_TYPE : + { + DrawSheetLabel = (DrawSheetLabelStruct *) LabelItem->m_Label; + jj = DrawSheetLabel->m_Shape; + if ( jj < 0 ) jj = NET_TMAX; if ( jj > NET_TMAX ) jj = 4; + wxString labtype = CONV_FROM_UTF8(SheetLabelType[jj]); + msg.Printf( + _("> %-28.28s Sheet %-7.7s (Sheet %.2d) pos: %3.3f, %3.3f\n"), + DrawSheetLabel->m_Text.GetData(), + labtype.GetData(), + LabelItem->m_SheetNumber, + (float)DrawSheetLabel->m_Pos.x / 1000, + (float)DrawSheetLabel->m_Pos.y / 1000); + fprintf(f, CONV_TO_UTF8(msg)); + } + break; + + default: break; + } + } + msg = _("#End labels\n"); + fprintf(f, CONV_TO_UTF8(msg)); + return(0); +} + +/*! + * wxEVT_CLOSE_WINDOW event handler for ID_DIALOG + */ + +void WinEDA_Build_BOM_Frame::OnCloseWindow( wxCloseEvent& event ) +{ + s_Add_F1_state = m_AddField1->GetValue(); + s_Add_F2_state = m_AddField2->GetValue(); + s_Add_F3_state = m_AddField3->GetValue(); + s_Add_F4_state = m_AddField4->GetValue(); + s_Add_F5_state = m_AddField5->GetValue(); + s_Add_F6_state = m_AddField6->GetValue(); + s_Add_F7_state = m_AddField7->GetValue(); + s_Add_F8_state = m_AddField8->GetValue(); + EndModal(0); +} + + diff --git a/eeschema/dialog_build_BOM.h b/eeschema/dialog_build_BOM.h new file mode 100644 index 0000000000..c465c9dfec --- /dev/null +++ b/eeschema/dialog_build_BOM.h @@ -0,0 +1,154 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_build_BOM.h +// Purpose: +// Author: jean-pieere Charras +// Modified by: +// Created: 01/15/06 18:18:44 +// RCS-ID: +// Copyright: GNU license +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 01/15/06 18:18:44 + +#ifndef _DIALOG_BUILD_BOM_H_ +#define _DIALOG_BUILD_BOM_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "dialog_build_BOM.cpp" +#endif + +/*! + * Includes + */ + +////@begin includes +#include "wx/valgen.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_BUILD_BOM_FRAME_STYLE wxDEFAULT_DIALOG_STYLE|wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxSTAY_ON_TOP|wxCLOSE_BOX +#define SYMBOL_WINEDA_BUILD_BOM_FRAME_TITLE _("List of Material") +#define SYMBOL_WINEDA_BUILD_BOM_FRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_BUILD_BOM_FRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_BUILD_BOM_FRAME_POSITION wxDefaultPosition +#define ID_CHECKBOX 10001 +#define ID_CHECKBOX2 10004 +#define ID_CHECKBOX1 10003 +#define ID_CHECKBOX3 10005 +#define ID_CHECKBOX4 10006 +#define ID_CHECKBOX_FIELD1 10007 +#define ID_CHECKBOX_FIELD2 10008 +#define ID_CHECKBOX_FIELD4 10010 +#define ID_CHECKBOX_FIELD5 10011 +#define ID_CHECKBOX_FIELD6 10012 +#define ID_CHECKBOX_FIELD7 10013 +#define ID_CHECKBOX_FIELD8 10014 +#define ID_CHECKBOX5 10002 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif +#ifndef wxFIXED_MINSIZE +#define wxFIXED_MINSIZE 0 +#endif + +/*! + * WinEDA_Build_BOM_Frame class declaration + */ + +class WinEDA_Build_BOM_Frame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_Build_BOM_Frame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_Build_BOM_Frame( ); + WinEDA_Build_BOM_Frame( WinEDA_DrawFrame* parent, + wxWindowID id = SYMBOL_WINEDA_BUILD_BOM_FRAME_IDNAME, + const wxString& caption = SYMBOL_WINEDA_BUILD_BOM_FRAME_TITLE, + const wxPoint& pos = SYMBOL_WINEDA_BUILD_BOM_FRAME_POSITION, + const wxSize& size = SYMBOL_WINEDA_BUILD_BOM_FRAME_SIZE, + long style = SYMBOL_WINEDA_BUILD_BOM_FRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_BUILD_BOM_FRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_BUILD_BOM_FRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_BUILD_BOM_FRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_BUILD_BOM_FRAME_SIZE, long style = SYMBOL_WINEDA_BUILD_BOM_FRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_Build_BOM_Frame event handler declarations + + /// wxEVT_CLOSE_WINDOW event handler for ID_DIALOG + void OnCloseWindow( wxCloseEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_EXIT + void OnExitClick( wxCommandEvent& event ); + +////@end WinEDA_Build_BOM_Frame event handler declarations + + void GenList(void); + +////@begin WinEDA_Build_BOM_Frame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_Build_BOM_Frame member function declarations + void GenereListeOfItems(const wxString & FullFileName); + int PrintListeCmpByRef( FILE * f, EDA_BaseStruct ** List, int NbItems ); + int PrintListeCmpByVal( FILE *f, EDA_BaseStruct **List, int NbItems); + void PrintFieldData(FILE * f, EDA_SchComponentStruct * DrawLibItem); + + + /// Should we show tooltips? + static bool ShowToolTips(); + +////@begin WinEDA_Build_BOM_Frame member variables + wxCheckBox* m_ListCmpbyRefItems; + wxCheckBox* m_ListSubCmpItems; + wxCheckBox* m_ListCmpbyValItems; + wxCheckBox* m_GenListLabelsbyVal; + wxCheckBox* m_GenListLabelsbySheet; + wxStaticBoxSizer* m_FieldsToAppendListSizer; + wxCheckBox* m_AddField1; + wxCheckBox* m_AddField2; + wxCheckBox* m_AddField3; + wxCheckBox* m_AddField4; + wxCheckBox* m_AddField5; + wxCheckBox* m_AddField6; + wxCheckBox* m_AddField7; + wxCheckBox* m_AddField8; + wxCheckBox* m_GetListBrowser; +////@end WinEDA_Build_BOM_Frame member variables + + WinEDA_DrawFrame * m_Parent; + wxString m_LibArchiveFileName; + wxString m_ListFileName; +}; + +#endif + // _DIALOG_BUILD_BOM_H_ diff --git a/eeschema/dialog_build_BOM.pjd b/eeschema/dialog_build_BOM.pjd new file mode 100644 index 0000000000..f79bba5f74 --- /dev/null +++ b/eeschema/dialog_build_BOM.pjd @@ -0,0 +1,1378 @@ + + +
+ 0 + "" + "" + "" + "" + 31 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pieere Charras" + "GNU license" + "" + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 0 + 4 + "" + 0 + 0 + 1 + 1 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + "GCC Release" + "gcc-config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "GCC" + 1 + "GCC" + "Release" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "List of Material" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "15/4/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "wxEVT_CLOSE_WINDOW|OnCloseWindow" + "ID_DIALOG" + 10000 + "WinEDA_Build_BOM_Frame" + "wxDialog" + "wxDialog" + "dialog_build_BOM.cpp" + "dialog_build_BOM.h" + "" + "List of Material" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "15/4/2006" + "wbBoxSizerProxy" + "Vertical" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "15/4/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "15/4/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + "List items : " + "" + "" + "" + 0 + 1 + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxCheckBox: ID_CHECKBOX" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "15/4/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX" + 10001 + "wxCheckBox" + "m_ListCmpbyRefItems" + "Components by Reference" + 1 + "" + "" + "s_ListByRef" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX2" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "7/8/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX2" + 10004 + "wxCheckBox" + "m_ListSubCmpItems" + "Sub Components (i.e U2A, U2B..)" + 0 + "" + "" + "s_ListWithSubCmponents" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX1" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "15/4/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX1" + 10003 + "wxCheckBox" + "m_ListCmpbyValItems" + "Components by Value" + 1 + "" + "" + "s_ListByValue" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX3" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "15/4/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX3" + 10005 + "wxCheckBox" + "m_GenListLabelsbyVal" + "Hierachy Pins by name" + 0 + "" + "" + "s_ListHierarchicalPinByName" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX4" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "15/4/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX4" + 10006 + "wxCheckBox" + "m_GenListLabelsbySheet" + "Hierachy Pins by Sheets" + 0 + "" + "" + "s_ListBySheet" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "7/8/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + "-1" + "Fields to Add" + "m_FieldsToAppendListSizer" + "" + "" + 0 + 1 + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxCheckBox: ID_CHECKBOX_FIELD1" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "7/8/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX_FIELD1" + 10007 + "wxCheckBox" + "m_AddField1" + "Add Field 1" + 0 + "" + "" + "s_Add_F1_state" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX_FIELD2" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "7/8/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX_FIELD2" + 10008 + "wxCheckBox" + "m_AddField2" + "Add Field 2" + 0 + "" + "" + "s_Add_F2_state" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX_FIELD1" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "7/8/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX_FIELD1" + 10007 + "wxCheckBox" + "m_AddField3" + "Add Field 3" + 0 + "" + "" + "s_Add_F3_state" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX_FIELD4" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "7/8/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX_FIELD4" + 10010 + "wxCheckBox" + "m_AddField4" + "Add Field 4" + 0 + "" + "" + "s_Add_F4_state" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX_FIELD5" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "7/8/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX_FIELD5" + 10011 + "wxCheckBox" + "m_AddField5" + "Add Field 5" + 0 + "" + "" + "s_Add_F5_state" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX_FIELD6" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "7/8/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX_FIELD6" + 10012 + "wxCheckBox" + "m_AddField6" + "Add Field 6" + 0 + "" + "" + "s_Add_F6_state" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX_FIELD7" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "7/8/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX_FIELD7" + 10013 + "wxCheckBox" + "m_AddField7" + "Add Field 7" + 0 + "" + "" + "s_Add_F7_state" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX_FIELD8" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "7/8/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX_FIELD8" + 10014 + "wxCheckBox" + "m_AddField8" + "Add Field 8" + 0 + "" + "" + "s_Add_F8_state" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "15/4/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: wxID_OK" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "15/4/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnOkClick" + "wxID_OK" + 5100 + "wxButton" + "" + "&Create List" + 1 + "" + "" + "" + "A60000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_EXIT" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "15/4/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnExitClick" + "wxID_EXIT" + 5006 + "wxButton" + "" + "&Quit" + 0 + "" + "" + "" + "0000D2" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + "wxStaticBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "24/2/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + "-1" + "Options" + "" + "" + "" + 0 + 1 + "Horizontal" + "" + "Expand" + "Centre" + 0 + 10 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxCheckBox: ID_CHECKBOX5" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "24/2/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX5" + 10002 + "wxCheckBox" + "m_GetListBrowser" + "Launch list browser" + 0 + "" + "" + "s_BrowsList" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "dialog_build_BOM.rc" + "source-editor-document" + "dialog_build_BOM.rc" + "source-editor" + 0 + 0 + 1 + 0 + "15/4/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/dialog_cmp_graphic_properties.cpp b/eeschema/dialog_cmp_graphic_properties.cpp new file mode 100644 index 0000000000..a17a5522e5 --- /dev/null +++ b/eeschema/dialog_cmp_graphic_properties.cpp @@ -0,0 +1,233 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_cmp_graphic_properties.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 12/02/2006 11:38:02 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 12/02/2006 11:38:02 + + +////@begin includes +////@end includes + +#include "dialog_cmp_graphic_properties.h" + +////@begin XPM images +////@end XPM images + +/*! + * WinEDA_bodygraphics_PropertiesFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_bodygraphics_PropertiesFrame, wxDialog ) + +/*! + * WinEDA_bodygraphics_PropertiesFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_bodygraphics_PropertiesFrame, wxDialog ) + +////@begin WinEDA_bodygraphics_PropertiesFrame event table entries + EVT_BUTTON( wxID_OK, WinEDA_bodygraphics_PropertiesFrame::OnOkClick ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_bodygraphics_PropertiesFrame::OnCancelClick ) + +////@end WinEDA_bodygraphics_PropertiesFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_bodygraphics_PropertiesFrame constructors + */ + +WinEDA_bodygraphics_PropertiesFrame::WinEDA_bodygraphics_PropertiesFrame( ) +{ +} + +WinEDA_bodygraphics_PropertiesFrame::WinEDA_bodygraphics_PropertiesFrame( WinEDA_LibeditFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +LibEDA_BaseStruct * CurrentItem = CurrentDrawItem; + + m_Parent = parent; + Create(parent, id, caption, pos, size, style); + + /* Set the dialog items: */ + if ( CurrentItem ) + { + if ( CurrentItem->m_Unit == 0 ) m_CommonUnit->SetValue(TRUE); + } + else if ( ! g_FlDrawSpecificUnit ) m_CommonUnit->SetValue(TRUE); + if ( CurrentItem ) + { + if ( CurrentItem->m_Convert == 0 ) m_CommonConvert->SetValue(TRUE); + } + else if ( !g_FlDrawSpecificConvert ) m_CommonConvert->SetValue(TRUE); + +bool show_fill_option = FALSE; +int fill_option = 0; + if( CurrentItem ) + switch(CurrentItem->m_StructType) + { + case COMPONENT_ARC_DRAW_TYPE: + show_fill_option = TRUE; + fill_option = ((LibDrawArc*)CurrentItem)->m_Fill; + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + show_fill_option = TRUE; + fill_option = ((LibDrawCircle*)CurrentItem)->m_Fill; + break; + + case COMPONENT_RECT_DRAW_TYPE: + show_fill_option = TRUE; + fill_option = ((LibDrawSquare *)CurrentItem)->m_Fill; + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + show_fill_option = TRUE; + fill_option = ((LibDrawPolyline*)CurrentItem)->m_Fill; + break; + + default: break; + } + + if ( show_fill_option ) m_Filled->SetSelection(fill_option); + else m_Filled->Enable(false); +} + +/*! + * WinEDA_bodygraphics_PropertiesFrame creator + */ + +bool WinEDA_bodygraphics_PropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_bodygraphics_PropertiesFrame member initialisation + m_CommonUnit = NULL; + m_CommonConvert = NULL; + m_Filled = NULL; +////@end WinEDA_bodygraphics_PropertiesFrame member initialisation + +////@begin WinEDA_bodygraphics_PropertiesFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_bodygraphics_PropertiesFrame creation + return true; +} + +/*! + * Control creation for WinEDA_bodygraphics_PropertiesFrame + */ + +void WinEDA_bodygraphics_PropertiesFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_bodygraphics_PropertiesFrame content construction + // Generated by DialogBlocks, 12/02/2006 11:50:42 (unregistered) + + WinEDA_bodygraphics_PropertiesFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Options :")); + wxStaticBoxSizer* itemStaticBoxSizer3 = new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxVERTICAL); + itemBoxSizer2->Add(itemStaticBoxSizer3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + m_CommonUnit = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Common to Units"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_CommonUnit->SetValue(false); + itemStaticBoxSizer3->Add(m_CommonUnit, 0, wxALIGN_LEFT|wxALL, 5); + + m_CommonConvert = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Common to convert"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_CommonConvert->SetValue(false); + itemStaticBoxSizer3->Add(m_CommonConvert, 0, wxALIGN_LEFT|wxALL, 5); + + wxString m_FilledStrings[] = { + _("Void"), + _("Filled"), + _("BgFilled") + }; + m_Filled = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Fill:"), wxDefaultPosition, wxDefaultSize, 3, m_FilledStrings, 1, wxRA_SPECIFY_COLS ); + itemStaticBoxSizer3->Add(m_Filled, 0, wxALIGN_LEFT|wxALL, 5); + + wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton8 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton8->SetForegroundColour(wxColour(206, 0, 0)); + itemBoxSizer7->Add(itemButton8, 0, wxGROW|wxALL, 5); + + wxButton* itemButton9 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton9->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer7->Add(itemButton9, 0, wxGROW|wxALL, 5); + +////@end WinEDA_bodygraphics_PropertiesFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_bodygraphics_PropertiesFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_bodygraphics_PropertiesFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_bodygraphics_PropertiesFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_bodygraphics_PropertiesFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_bodygraphics_PropertiesFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_bodygraphics_PropertiesFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_bodygraphics_PropertiesFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_bodygraphics_PropertiesFrame::OnOkClick( wxCommandEvent& event ) +{ + bodygraphics_PropertiesAccept(event); + Close(); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_bodygraphics_PropertiesFrame::OnCancelClick( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_bodygraphics_PropertiesFrame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_bodygraphics_PropertiesFrame. +} + + diff --git a/eeschema/dialog_cmp_graphic_properties.h b/eeschema/dialog_cmp_graphic_properties.h new file mode 100644 index 0000000000..ac1c6b86cb --- /dev/null +++ b/eeschema/dialog_cmp_graphic_properties.h @@ -0,0 +1,112 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_cmp_graphic_properties.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 12/02/2006 11:38:02 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 12/02/2006 11:38:02 + +#ifndef _DIALOG_CMP_GRAPHIC_PROPERTIES_H_ +#define _DIALOG_CMP_GRAPHIC_PROPERTIES_H_ + + +/*! + * Includes + */ + +////@begin includes +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_TITLE _("Graphic shape properties") +#define SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_POSITION wxDefaultPosition +#define ID_CHECKBOX 10001 +#define ID_CHECKBOX1 10002 +#define ID_RADIOBOX 10003 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_bodygraphics_PropertiesFrame class declaration + */ + +class WinEDA_bodygraphics_PropertiesFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_bodygraphics_PropertiesFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_bodygraphics_PropertiesFrame( ); + WinEDA_bodygraphics_PropertiesFrame( WinEDA_LibeditFrame* parent, wxWindowID id = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_IDNAME, + const wxString& caption = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_TITLE, + const wxPoint& pos = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_POSITION, + const wxSize& size = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_SIZE, + long style = SYMBOL_WINEDA_BODYGRAPHICS_PROPERTIESFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_bodygraphics_PropertiesFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + +////@end WinEDA_bodygraphics_PropertiesFrame event handler declarations + +////@begin WinEDA_bodygraphics_PropertiesFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_bodygraphics_PropertiesFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + void bodygraphics_PropertiesAccept(wxCommandEvent& event); + +////@begin WinEDA_bodygraphics_PropertiesFrame member variables + wxCheckBox* m_CommonUnit; + wxCheckBox* m_CommonConvert; + wxRadioBox* m_Filled; +////@end WinEDA_bodygraphics_PropertiesFrame member variables + WinEDA_LibeditFrame * m_Parent; +}; + +#endif + // _DIALOG_CMP_GRAPHIC_PROPERTIES_H_ diff --git a/eeschema/dialog_cmp_graphic_properties.pjd b/eeschema/dialog_cmp_graphic_properties.pjd new file mode 100644 index 0000000000..aa1aad1345 --- /dev/null +++ b/eeschema/dialog_cmp_graphic_properties.pjd @@ -0,0 +1,623 @@ + + +
+ 0 + "" + "" + "" + "" + 16 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "Graphic shape properties" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "ID_DIALOG" + 10000 + "WinEDA_bodygraphics_PropertiesFrame" + "wxDialog" + "wxDialog" + "dialog_cmp_graphic_properties.cpp" + "dialog_cmp_graphic_properties.h" + "" + "Graphic shape properties" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Horizontal" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + "-1" + "Options :" + "" + "" + "" + 0 + 1 + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxCheckBox: ID_CHECKBOX" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX" + 10001 + "wxCheckBox" + "m_CommonUnit" + "Common to Units" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX1" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX1" + 10002 + "wxCheckBox" + "m_CommonConvert" + "Common to convert" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxRadioBox: ID_RADIOBOX" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX" + 10003 + "wxRadioBox" + "m_Filled" + "Fill:" + 1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + "Void|Filled|BgFilled" + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: wxID_OK" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnOkClick" + "wxID_OK" + 5100 + "wxButton" + "" + "&OK" + 0 + "" + "" + "" + "CE0000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_CANCEL" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCancelClick" + "wxID_CANCEL" + 5101 + "wxButton" + "" + "&Cancel" + 0 + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "dialog_cmp_graphic_properties.rc" + "source-editor-document" + "dialog_cmp_graphic_properties.rc" + "source-editor" + 0 + 0 + 1 + 0 + "12/3/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/dialog_cmp_graphic_properties.rc b/eeschema/dialog_cmp_graphic_properties.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/eeschema/dialog_cmp_graphic_properties.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/eeschema/dialog_create_component.cpp b/eeschema/dialog_create_component.cpp new file mode 100644 index 0000000000..6a6085a205 --- /dev/null +++ b/eeschema/dialog_create_component.cpp @@ -0,0 +1,333 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_create_component.cpp +// Purpose: +// Author: +// Modified by: +// Created: 01/14/06 10:14:28 +// RCS-ID: +// Copyright: +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 01/14/06 10:14:28 + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma implementation "dialog_create_component.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +////@begin includes +////@end includes + +#include "dialog_create_component.h" + +////@begin XPM images +////@end XPM images + +/*! + * WinEDA_CreateCmpDialog type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_CreateCmpDialog, wxDialog ) + +/*! + * WinEDA_CreateCmpDialog event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_CreateCmpDialog, wxDialog ) + +////@begin WinEDA_CreateCmpDialog event table entries + EVT_BUTTON( wxID_OK, WinEDA_CreateCmpDialog::OnOkClick ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_CreateCmpDialog::OnCancelClick ) + +////@end WinEDA_CreateCmpDialog event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_CreateCmpDialog constructors + */ + +WinEDA_CreateCmpDialog::WinEDA_CreateCmpDialog( ) +{ +} + +WinEDA_CreateCmpDialog::WinEDA_CreateCmpDialog( WinEDA_DrawFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + Create(parent, id, caption, pos, size, style); +} + +/*! + * WinEDA_CreateCmpDialog creator + */ + +bool WinEDA_CreateCmpDialog::Create( WinEDA_DrawFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_CreateCmpDialog member initialisation + m_CmpName = NULL; + m_Reference = NULL; + m_AsConvert = NULL; + m_IsPowerSymbol = NULL; + m_PartsAreLocked = NULL; + m_PartsCount = NULL; + m_ShowPinNum = NULL; + m_ShowPinname = NULL; + m_PinNameInside = NULL; + m_SetSkew = NULL; +////@end WinEDA_CreateCmpDialog member initialisation + +////@begin WinEDA_CreateCmpDialog creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_CreateCmpDialog creation + return TRUE; +} + + +/**********************************************************************************/ +void WinEDA_CreateCmpDialog::SetComponentData( EDA_LibComponentStruct & component ) +/**********************************************************************************/ +{ + g_AsDeMorgan = m_AsConvert->GetValue(); + component.m_UnitCount = m_PartsCount->GetSelection() + 1; + component.m_Prefix.m_Text = m_Reference->GetValue(); + if ( m_PinNameInside->GetValue() == FALSE) + component.m_TextInside = 0; + else + component.m_TextInside = m_SetSkew->GetValue(); + + if ( m_IsPowerSymbol->GetValue() == TRUE) + component.m_Options = ENTRY_POWER; + else + component.m_Options = ENTRY_NORMAL; + + /* Set the option "Units locked". + Obviously, cannot be TRUE if there is only one part */ + component.m_UnitSelectionLocked = m_PartsAreLocked->GetValue(); + if ( component.m_UnitCount <= 1 ) + component.m_UnitSelectionLocked = FALSE; +} + +/*! + * Control creation for WinEDA_CreateCmpDialog + */ + +void WinEDA_CreateCmpDialog::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_CreateCmpDialog content construction + // Generated by DialogBlocks, 30/05/2006 08:00:22 (unregistered) + + WinEDA_CreateCmpDialog* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_LEFT|wxALL, 5); + + wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer5Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Name")); + wxStaticBoxSizer* itemStaticBoxSizer5 = new wxStaticBoxSizer(itemStaticBoxSizer5Static, wxVERTICAL); + itemBoxSizer4->Add(itemStaticBoxSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + m_CmpName = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer5->Add(m_CmpName, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer7Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Reference")); + wxStaticBoxSizer* itemStaticBoxSizer7 = new wxStaticBoxSizer(itemStaticBoxSizer7Static, wxVERTICAL); + itemBoxSizer4->Add(itemStaticBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + m_Reference = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _("U"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer7->Add(m_Reference, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer11Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Options")); + wxStaticBoxSizer* itemStaticBoxSizer11 = new wxStaticBoxSizer(itemStaticBoxSizer11Static, wxVERTICAL); + itemBoxSizer10->Add(itemStaticBoxSizer11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + m_AsConvert = new wxCheckBox( itemDialog1, ID_CHECKBOX3, _("As Convert"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_AsConvert->SetValue(false); + itemStaticBoxSizer11->Add(m_AsConvert, 0, wxALIGN_LEFT|wxALL, 5); + + m_IsPowerSymbol = new wxCheckBox( itemDialog1, ID_CHECKBOX4, _("Power Symbol"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_IsPowerSymbol->SetValue(false); + itemStaticBoxSizer11->Add(m_IsPowerSymbol, 0, wxALIGN_LEFT|wxALL, 5); + + m_PartsAreLocked = new wxCheckBox( itemDialog1, ID_CHECKBOX2, _("Parts are locked"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_PartsAreLocked->SetValue(false); + itemStaticBoxSizer11->Add(m_PartsAreLocked, 0, wxALIGN_LEFT|wxALL, 5); + + wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton16 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton16->SetDefault(); + itemButton16->SetForegroundColour(wxColour(188, 0, 0)); + itemBoxSizer15->Add(itemButton16, 0, wxGROW|wxALL, 5); + + wxButton* itemButton17 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton17->SetForegroundColour(wxColour(0, 0, 221)); + itemBoxSizer15->Add(itemButton17, 0, wxGROW|wxALL, 5); + + wxStaticLine* itemStaticLine18 = new wxStaticLine( itemDialog1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL|wxDOUBLE_BORDER ); + itemBoxSizer2->Add(itemStaticLine18, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer19 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer2->Add(itemBoxSizer19, 0, wxGROW|wxALL, 5); + + wxString m_PartsCountStrings[] = { + _("&1"), + _("&2"), + _("&3"), + _("&4"), + _("&5"), + _("&6"), + _("&7"), + _("&8"), + _("&9"), + _("&10"), + _("&11"), + _("&12"), + _("&13"), + _("&14"), + _("&15"), + _("&16"), + _("&17"), + _("&18"), + _("&19"), + _("&20"), + _("&21"), + _("&22"), + _("&23"), + _("&24"), + _("&25"), + _("&26") + }; + m_PartsCount = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Parts per package"), wxDefaultPosition, wxDefaultSize, 26, m_PartsCountStrings, 9, wxRA_SPECIFY_ROWS ); + itemBoxSizer19->Add(m_PartsCount, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + itemBoxSizer19->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer22Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Draw options")); + wxStaticBoxSizer* itemStaticBoxSizer22 = new wxStaticBoxSizer(itemStaticBoxSizer22Static, wxVERTICAL); + itemBoxSizer19->Add(itemStaticBoxSizer22, 0, wxGROW|wxALL, 5); + + m_ShowPinNum = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Show Pin Num"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_ShowPinNum->SetValue(true); + itemStaticBoxSizer22->Add(m_ShowPinNum, 0, wxALIGN_LEFT|wxALL, 5); + + m_ShowPinname = new wxCheckBox( itemDialog1, ID_CHECKBOX5, _("Show Pin Name"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_ShowPinname->SetValue(true); + itemStaticBoxSizer22->Add(m_ShowPinname, 0, wxALIGN_LEFT|wxALL, 5); + + m_PinNameInside = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Pin Name Inside"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_PinNameInside->SetValue(true); + itemStaticBoxSizer22->Add(m_PinNameInside, 0, wxALIGN_LEFT|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer26Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Skew:")); + wxStaticBoxSizer* itemStaticBoxSizer26 = new wxStaticBoxSizer(itemStaticBoxSizer26Static, wxVERTICAL); + itemStaticBoxSizer22->Add(itemStaticBoxSizer26, 0, wxALIGN_LEFT|wxALL, 5); + + m_SetSkew = new wxSpinCtrl( itemDialog1, ID_SPINCTRL, _T("40"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 100, 40 ); + itemStaticBoxSizer26->Add(m_SetSkew, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + +////@end WinEDA_CreateCmpDialog content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_CreateCmpDialog::ShowToolTips() +{ + return TRUE; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_CreateCmpDialog::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_CreateCmpDialog bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_CreateCmpDialog bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_CreateCmpDialog::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_CreateCmpDialog icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_CreateCmpDialog icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON + */ + +void WinEDA_CreateCmpDialog::OnOkClick( wxCommandEvent& event ) +{ + if ( m_CmpName->GetValue() == wxEmptyString ) + { + DisplayError(this,_("You must provide a name for this component")); + return; + } +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON in WinEDA_CreateCmpDialog. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON in WinEDA_CreateCmpDialog. +} + + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1 + */ + +void WinEDA_CreateCmpDialog::OnCancelClick( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1 in WinEDA_CreateCmpDialog. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1 in WinEDA_CreateCmpDialog. +} + + diff --git a/eeschema/dialog_create_component.h b/eeschema/dialog_create_component.h new file mode 100644 index 0000000000..7054319685 --- /dev/null +++ b/eeschema/dialog_create_component.h @@ -0,0 +1,135 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_create_component.h +// Purpose: +// Author: +// Modified by: +// Created: 01/14/06 10:14:28 +// RCS-ID: +// Copyright: +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 01/14/06 10:14:28 + +#ifndef _DIALOG_CREATE_COMPONENT_H_ +#define _DIALOG_CREATE_COMPONENT_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "dialog_create_component.cpp" +#endif + +/*! + * Includes + */ + +////@begin includes +#include "wx/statline.h" +#include "wx/spinctrl.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +class wxSpinCtrl; +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_CREATECMPDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxSTAY_ON_TOP|wxCLOSE_BOX +#define SYMBOL_WINEDA_CREATECMPDIALOG_TITLE _("Component Creation") +#define SYMBOL_WINEDA_CREATECMPDIALOG_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_CREATECMPDIALOG_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_CREATECMPDIALOG_POSITION wxDefaultPosition +#define ID_TEXTCTRL1 10009 +#define ID_TEXTCTRL 10008 +#define ID_CHECKBOX3 10005 +#define ID_CHECKBOX4 10006 +#define ID_CHECKBOX2 10004 +#define ID_RADIOBOX 10003 +#define ID_CHECKBOX1 10002 +#define ID_CHECKBOX5 10007 +#define ID_CHECKBOX 10001 +#define ID_SPINCTRL 10010 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif +#ifndef wxFIXED_MINSIZE +#define wxFIXED_MINSIZE 0 +#endif + +/*! + * WinEDA_CreateCmpDialog class declaration + */ + +class WinEDA_CreateCmpDialog: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_CreateCmpDialog ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_CreateCmpDialog( ); + WinEDA_CreateCmpDialog( WinEDA_DrawFrame* parent, wxWindowID id = SYMBOL_WINEDA_CREATECMPDIALOG_IDNAME, const wxString& caption = SYMBOL_WINEDA_CREATECMPDIALOG_TITLE, const wxPoint& pos = SYMBOL_WINEDA_CREATECMPDIALOG_POSITION, const wxSize& size = SYMBOL_WINEDA_CREATECMPDIALOG_SIZE, long style = SYMBOL_WINEDA_CREATECMPDIALOG_STYLE ); + + /// Creation + bool Create( WinEDA_DrawFrame* parent, wxWindowID id = SYMBOL_WINEDA_CREATECMPDIALOG_IDNAME, const wxString& caption = SYMBOL_WINEDA_CREATECMPDIALOG_TITLE, const wxPoint& pos = SYMBOL_WINEDA_CREATECMPDIALOG_POSITION, const wxSize& size = SYMBOL_WINEDA_CREATECMPDIALOG_SIZE, long style = SYMBOL_WINEDA_CREATECMPDIALOG_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + + // others functions: + wxString ReturnCmpName(void) + { + return m_CmpName->GetValue(); + } + void SetComponentData( EDA_LibComponentStruct & component ); +////@begin WinEDA_CreateCmpDialog event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + +////@end WinEDA_CreateCmpDialog event handler declarations + +////@begin WinEDA_CreateCmpDialog member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_CreateCmpDialog member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + +////@begin WinEDA_CreateCmpDialog member variables + wxTextCtrl* m_CmpName; + wxTextCtrl* m_Reference; + wxCheckBox* m_AsConvert; + wxCheckBox* m_IsPowerSymbol; + wxCheckBox* m_PartsAreLocked; + wxRadioBox* m_PartsCount; + wxCheckBox* m_ShowPinNum; + wxCheckBox* m_ShowPinname; + wxCheckBox* m_PinNameInside; + wxSpinCtrl* m_SetSkew; +////@end WinEDA_CreateCmpDialog member variables +}; + +#endif + // _DIALOG_CREATE_COMPONENT_H_ diff --git a/eeschema/dialog_create_component.pjd b/eeschema/dialog_create_component.pjd new file mode 100644 index 0000000000..14d7fbf183 --- /dev/null +++ b/eeschema/dialog_create_component.pjd @@ -0,0 +1,1413 @@ + + +
+ 0 + "" + "" + "" + "" + 35 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "GNU license" + "" + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: GNU +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + "GCC Release" + "gcc-config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "GCC" + 1 + "GCC" + "Release" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "Yes" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "Component Creation" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "ID_DIALOG" + 10000 + "WinEDA_CreateCmpDialog" + "wxDialog" + "wxDialog" + "dialog_create_component.cpp" + "dialog_create_component.h" + "" + "Component Creation" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "ID_BUTTON,ID_BUTTON1" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Vertical" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + "Name" + "" + "" + "" + 0 + 1 + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxTextCtrl: ID_TEXTCTRL1" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL1" + 10009 + "wxTextCtrl" + "m_CmpName" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + "Reference" + "" + "" + "" + 0 + 1 + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxTextCtrl: ID_TEXTCTRL" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL" + 10008 + "wxTextCtrl" + "m_Reference" + "U" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + "Options" + "" + "" + "" + 0 + 1 + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxCheckBox: ID_CHECKBOX3" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX3" + 10005 + "wxCheckBox" + "m_AsConvert" + "As Convert" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX4" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX4" + 10006 + "wxCheckBox" + "m_IsPowerSymbol" + "Power Symbol" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX2" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX2" + 10004 + "wxCheckBox" + "m_PartsAreLocked" + "Parts are locked" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: wxID_OK" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnOkClick" + "wxID_OK" + 5100 + "wxButton" + "" + "&OK" + 1 + "" + "" + "" + "BC0000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_CANCEL" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCancelClick" + "wxID_CANCEL" + 5101 + "wxButton" + "" + "&Cancel" + 0 + "" + "" + "" + "0000DD" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + "wxStaticLine: wxID_STATIC" + "dialog-control-document" + "" + "staticline" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbStaticLineProxy" + "wxID_STATIC" + 5105 + "wxStaticLine" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 1 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxRadioBox: ID_RADIOBOX" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX" + 10003 + "wxRadioBox" + "m_PartsCount" + "Parts per package" + 9 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 0 + "&1|&2|&3|&4|&5|&6|&7|&8|&9|&10|&11|&12|&13|&14|&15|&16|&17|&18|&19|&20|&21|&22|&23|&24|&25|&26" + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + "Draw options" + "" + "" + "" + 0 + 1 + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxCheckBox: ID_CHECKBOX1" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX1" + 10002 + "wxCheckBox" + "m_ShowPinNum" + "Show Pin Num" + 1 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX5" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX5" + 10007 + "wxCheckBox" + "m_ShowPinname" + "Show Pin Name" + 1 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX" + 10001 + "wxCheckBox" + "m_PinNameInside" + "Pin Name Inside" + 1 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + "Skew:" + "" + "" + "" + 0 + 1 + "Vertical" + "" + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxSpinCtrl: ID_SPINCTRL" + "dialog-control-document" + "" + "spinctrl" + 0 + 1 + 0 + 0 + "14/3/2006" + "wbSpinCtrlProxy" + "ID_SPINCTRL" + 10010 + "wxSpinCtrl" + "m_SetSkew" + 0 + 100 + 40 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "dialog_create_component.rc" + "source-editor-document" + "dialog_create_component.rc" + "source-editor" + 0 + 0 + 1 + 0 + "14/3/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/dialog_create_component.rc b/eeschema/dialog_create_component.rc new file mode 100644 index 0000000000..830c36a752 --- /dev/null +++ b/eeschema/dialog_create_component.rc @@ -0,0 +1,3 @@ +#ifndef APSTUDIO_INVOKED +#include "wx/msw/wx.rc" +#endif diff --git a/eeschema/dialog_edit_component_in_lib.cpp b/eeschema/dialog_edit_component_in_lib.cpp new file mode 100644 index 0000000000..6f67b69a33 --- /dev/null +++ b/eeschema/dialog_edit_component_in_lib.cpp @@ -0,0 +1,301 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_edit_component_in_lib.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 02/03/2006 08:51:09 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 02/03/2006 08:51:09 + + +////@begin includes +////@end includes + +#include "dialog_edit_component_in_lib.h" + +////@begin XPM images +////@end XPM images + +/*! + * WinEDA_PartPropertiesFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_PartPropertiesFrame, wxDialog ) + +/*! + * WinEDA_PartPropertiesFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_PartPropertiesFrame, wxDialog ) + +////@begin WinEDA_PartPropertiesFrame event table entries + EVT_BUTTON( ID_COPY_DOC_TO_ALIAS, WinEDA_PartPropertiesFrame::OnCopyDocToAliasClick ) + + EVT_BUTTON( ID_BROWSE_DOC_FILES, WinEDA_PartPropertiesFrame::OnBrowseDocFilesClick ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_PartPropertiesFrame::OnCancelClick ) + + EVT_BUTTON( wxID_OK, WinEDA_PartPropertiesFrame::OnOkClick ) + +////@end WinEDA_PartPropertiesFrame event table entries + EVT_RADIOBOX(ID_ON_SELECT_FIELD, WinEDA_PartPropertiesFrame::SelectNewField) + EVT_BUTTON(ID_ADD_ALIAS, WinEDA_PartPropertiesFrame::AddAliasOfPart) + EVT_BUTTON(ID_DELETE_ONE_ALIAS, WinEDA_PartPropertiesFrame::DeleteAliasOfPart) + EVT_BUTTON(ID_DELETE_ALL_ALIAS, WinEDA_PartPropertiesFrame::DeleteAllAliasOfPart) + EVT_BUTTON(ID_ADD_FOOTPRINT_FILTER, WinEDA_PartPropertiesFrame::AddFootprintFilter) + EVT_BUTTON(ID_DELETE_ONE_FOOTPRINT_FILTER, WinEDA_PartPropertiesFrame::DeleteOneFootprintFilter) + EVT_BUTTON(ID_DELETE_ALL_FOOTPRINT_FILTER, WinEDA_PartPropertiesFrame::DeleteAllFootprintFilter) +END_EVENT_TABLE() + +/*! + * WinEDA_PartPropertiesFrame constructors + */ + +WinEDA_PartPropertiesFrame::WinEDA_PartPropertiesFrame( ) +{ +} + +WinEDA_PartPropertiesFrame::WinEDA_PartPropertiesFrame( WinEDA_LibeditFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + m_RecreateToolbar = FALSE; + m_AliasLocation = -1; + m_CurrentFieldId = 0; + + InitBuffers(); + + Create(parent, id, caption, pos, size, style); + + SetTitle(m_Title); +} + +/*! + * WinEDA_PartPropertiesFrame creator + */ + +bool WinEDA_PartPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_FieldNameCtrl = NULL; +////@begin WinEDA_PartPropertiesFrame member initialisation + m_GeneralBoxSizer = NULL; + m_NoteBook = NULL; + m_PanelBasic = NULL; + m_PanelBasicBoxSizer = NULL; + m_OptionsBoxSizer = NULL; + SelNumberOfUnits = NULL; + m_SetSkew = NULL; + m_OptionPower = NULL; + m_OptionPartsLocked = NULL; + m_PanelDoc = NULL; + m_PanelDocBoxSizer = NULL; + m_Doc = NULL; + m_Keywords = NULL; + m_Docfile = NULL; + m_ButtonCopyDoc = NULL; + m_PanelAlias = NULL; +////@end WinEDA_PartPropertiesFrame member initialisation + +////@begin WinEDA_PartPropertiesFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_PartPropertiesFrame creation + return true; +} + +/*! + * Control creation for WinEDA_PartPropertiesFrame + */ + +void WinEDA_PartPropertiesFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_PartPropertiesFrame content construction + // Generated by DialogBlocks, 02/03/2006 16:15:16 (unregistered) + + WinEDA_PartPropertiesFrame* itemDialog1 = this; + + m_GeneralBoxSizer = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(m_GeneralBoxSizer); + + m_NoteBook = new wxNotebook( itemDialog1, ID_LIBEDIT_NOTEBOOK, wxDefaultPosition, wxDefaultSize, wxNB_TOP ); + + m_PanelBasic = new wxPanel( m_NoteBook, ID_PANEL_BASIC, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); + m_PanelBasicBoxSizer = new wxBoxSizer(wxVERTICAL); + m_PanelBasic->SetSizer(m_PanelBasicBoxSizer); + + wxStaticBox* itemStaticBoxSizer6Static = new wxStaticBox(m_PanelBasic, wxID_ANY, _("General :")); + m_OptionsBoxSizer = new wxStaticBoxSizer(itemStaticBoxSizer6Static, wxVERTICAL); + m_PanelBasicBoxSizer->Add(m_OptionsBoxSizer, 0, wxALIGN_LEFT|wxALL, 5); + + wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxHORIZONTAL); + m_PanelBasicBoxSizer->Add(itemBoxSizer7, 0, wxALIGN_LEFT|wxALL, 5); + wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer7->Add(itemBoxSizer8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxStaticText* itemStaticText9 = new wxStaticText( m_PanelBasic, wxID_STATIC, _("Number of Units:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer8->Add(itemStaticText9, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + SelNumberOfUnits = new wxSpinCtrl( m_PanelBasic, ID_SPINCTRL1, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 26, 0 ); + itemBoxSizer8->Add(SelNumberOfUnits, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer7->Add(itemBoxSizer11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxStaticText* itemStaticText12 = new wxStaticText( m_PanelBasic, wxID_STATIC, _("Skew:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer11->Add(itemStaticText12, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_SetSkew = new wxSpinCtrl( m_PanelBasic, ID_SPINCTRL, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 100, 0 ); + itemBoxSizer11->Add(m_SetSkew, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_OptionPower = new wxCheckBox( m_PanelBasic, ID_CHECKBOX, _("Power Symbol"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_OptionPower->SetValue(false); + m_PanelBasicBoxSizer->Add(m_OptionPower, 0, wxGROW|wxALL, 5); + + m_OptionPartsLocked = new wxCheckBox( m_PanelBasic, ID_CHECKBOX1, _("Parts are locked"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_OptionPartsLocked->SetValue(false); + m_PanelBasicBoxSizer->Add(m_OptionPartsLocked, 0, wxGROW|wxALL, 5); + + m_NoteBook->AddPage(m_PanelBasic, _("Options")); + + m_PanelDoc = new wxPanel( m_NoteBook, ID_PANEL_DOC, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); + m_PanelDocBoxSizer = new wxBoxSizer(wxVERTICAL); + m_PanelDoc->SetSizer(m_PanelDocBoxSizer); + + wxStaticText* itemStaticText18 = new wxStaticText( m_PanelDoc, wxID_STATIC, _("Doc:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticText18->SetForegroundColour(wxColour(196, 0, 0)); + m_PanelDocBoxSizer->Add(itemStaticText18, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_Doc = new wxTextCtrl( m_PanelDoc, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + m_PanelDocBoxSizer->Add(m_Doc, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxStaticText* itemStaticText20 = new wxStaticText( m_PanelDoc, wxID_STATIC, _("Keywords:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticText20->SetForegroundColour(wxColour(196, 0, 0)); + m_PanelDocBoxSizer->Add(itemStaticText20, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_Keywords = new wxTextCtrl( m_PanelDoc, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + m_PanelDocBoxSizer->Add(m_Keywords, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxStaticText* itemStaticText22 = new wxStaticText( m_PanelDoc, wxID_STATIC, _("DocFileName:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticText22->SetForegroundColour(wxColour(196, 0, 0)); + m_PanelDocBoxSizer->Add(itemStaticText22, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_Docfile = new wxTextCtrl( m_PanelDoc, ID_TEXTCTRL2, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + m_PanelDocBoxSizer->Add(m_Docfile, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxHORIZONTAL); + m_PanelDocBoxSizer->Add(itemBoxSizer24, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + m_ButtonCopyDoc = new wxButton( m_PanelDoc, ID_COPY_DOC_TO_ALIAS, _("Copy Doc"), wxDefaultPosition, wxDefaultSize, 0 ); + m_ButtonCopyDoc->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer24->Add(m_ButtonCopyDoc, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton26 = new wxButton( m_PanelDoc, ID_BROWSE_DOC_FILES, _("Browse DocFiles"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton26->SetForegroundColour(wxColour(202, 0, 0)); + itemBoxSizer24->Add(itemButton26, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + m_NoteBook->AddPage(m_PanelDoc, _("Doc")); + + m_PanelAlias = new wxPanel( m_NoteBook, ID_PANEL_ALIAS, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); + + m_NoteBook->AddPage(m_PanelAlias, _("Alias")); + + m_GeneralBoxSizer->Add(m_NoteBook, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer28 = new wxBoxSizer(wxHORIZONTAL); + m_GeneralBoxSizer->Add(itemBoxSizer28, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxButton* itemButton29 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton29->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer28->Add(itemButton29, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton30 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton30->SetDefault(); + itemButton30->SetForegroundColour(wxColour(202, 0, 0)); + itemBoxSizer28->Add(itemButton30, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + +////@end WinEDA_PartPropertiesFrame content construction + BuildPanelBasic(); + BuildPanelDoc(); + BuildPanelAlias(); + BuildPanelEditField(); // Add panel Field edition + BuildPanelFootprintFilter(); +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_PartPropertiesFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_PartPropertiesFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_PartPropertiesFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_PartPropertiesFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_PartPropertiesFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_PartPropertiesFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_PartPropertiesFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_COPY_DOC_TO_ALIAS + */ + +void WinEDA_PartPropertiesFrame::OnCopyDocToAliasClick( wxCommandEvent& event ) +{ + CopyDocToAlias(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BROWSE_DOC_FILES + */ + +void WinEDA_PartPropertiesFrame::OnBrowseDocFilesClick( wxCommandEvent& event ) +{ + BrowseAndSelectDocFile(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_PartPropertiesFrame::OnCancelClick( wxCommandEvent& event ) +{ + EndModal(0); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_PartPropertiesFrame::OnOkClick( wxCommandEvent& event ) +{ + PartPropertiesAccept(event); +} + + diff --git a/eeschema/dialog_edit_component_in_lib.h b/eeschema/dialog_edit_component_in_lib.h new file mode 100644 index 0000000000..83bf47c6da --- /dev/null +++ b/eeschema/dialog_edit_component_in_lib.h @@ -0,0 +1,207 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_edit_component_in_lib.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 02/03/2006 08:51:09 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 02/03/2006 08:51:09 + +#ifndef _DIALOG_EDIT_COMPONENT_IN_LIB_H_ +#define _DIALOG_EDIT_COMPONENT_IN_LIB_H_ + +/*! + * Includes + */ + +////@begin includes +#include "wx/notebook.h" +#include "wx/spinctrl.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +class wxBoxSizer; +class wxNotebook; +class wxSpinCtrl; +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_PARTPROPERTIESFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_PARTPROPERTIESFRAME_TITLE _("Lib Component Properties") +#define SYMBOL_WINEDA_PARTPROPERTIESFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_PARTPROPERTIESFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_PARTPROPERTIESFRAME_POSITION wxDefaultPosition +#define ID_LIBEDIT_NOTEBOOK 10001 +#define ID_PANEL_BASIC 10002 +#define ID_SPINCTRL1 10010 +#define ID_SPINCTRL 10009 +#define ID_CHECKBOX 10007 +#define ID_CHECKBOX1 10008 +#define ID_PANEL_DOC 10004 +#define ID_TEXTCTRL 10011 +#define ID_TEXTCTRL1 10012 +#define ID_TEXTCTRL2 10013 +#define ID_COPY_DOC_TO_ALIAS 10014 +#define ID_BROWSE_DOC_FILES 10005 +#define ID_PANEL_ALIAS 10003 +////@end control identifiers +#define ID_DELETE_ONE_FOOTPRINT_FILTER 10020 +#define ID_DELETE_ALL_FOOTPRINT_FILTER 10021 +#define ID_ADD_FOOTPRINT_FILTER 10022 + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_PartPropertiesFrame class declaration + */ + +class WinEDA_PartPropertiesFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_PartPropertiesFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_PartPropertiesFrame( ); + WinEDA_PartPropertiesFrame( WinEDA_LibeditFrame* parent, wxWindowID id = SYMBOL_WINEDA_PARTPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PARTPROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PARTPROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PARTPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_PARTPROPERTIESFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PARTPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PARTPROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PARTPROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PARTPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_PARTPROPERTIESFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_PartPropertiesFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_COPY_DOC_TO_ALIAS + void OnCopyDocToAliasClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BROWSE_DOC_FILES + void OnBrowseDocFilesClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + +////@end WinEDA_PartPropertiesFrame event handler declarations + +////@begin WinEDA_PartPropertiesFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_PartPropertiesFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void InitBuffers(void); + void BuildPanelBasic(void); + void BuildPanelDoc(void); + void BuildPanelAlias(void); + void BuildPanelEditField(); + void PartPropertiesAccept(wxCommandEvent& event); + void OnQuit(wxCommandEvent& event); + void DeleteAllAliasOfPart(wxCommandEvent& event); + void DeleteAliasOfPart(wxCommandEvent& event); + void AddAliasOfPart(wxCommandEvent& event); + bool ChangeNbUnitsPerPackage(int newUnit); + bool SetUnsetConvert(void); + void CopyDocToAlias(wxCommandEvent& event); + void BrowseAndSelectDocFile(wxCommandEvent& event); + void SelectNewField(wxCommandEvent& event); + void CopyFieldDataToBuffer(LibDrawField * Field); + void CopyBufferToFieldData(LibDrawField * Field); + void CopyDataToPanelField(void); + void CopyPanelFieldToData(void); + + void BuildPanelFootprintFilter(void); + void DeleteAllFootprintFilter(wxCommandEvent& event); + void DeleteOneFootprintFilter(wxCommandEvent& event); + void AddFootprintFilter(wxCommandEvent& event); + +////@begin WinEDA_PartPropertiesFrame member variables + wxBoxSizer* m_GeneralBoxSizer; + wxNotebook* m_NoteBook; + wxPanel* m_PanelBasic; + wxBoxSizer* m_PanelBasicBoxSizer; + wxStaticBoxSizer* m_OptionsBoxSizer; + wxSpinCtrl* SelNumberOfUnits; + wxSpinCtrl* m_SetSkew; + wxCheckBox* m_OptionPower; + wxCheckBox* m_OptionPartsLocked; + wxPanel* m_PanelDoc; + wxBoxSizer* m_PanelDocBoxSizer; + wxTextCtrl* m_Doc; + wxTextCtrl* m_Keywords; + wxTextCtrl* m_Docfile; + wxButton* m_ButtonCopyDoc; + wxButton* m_ButtonDeleteAllAlias; + wxButton* m_ButtonDeleteOneAlias; + wxPanel* m_PanelAlias; +////@end WinEDA_PartPropertiesFrame member variables + + WinEDA_LibeditFrame * m_Parent; + int m_CurrentFieldId; + wxString m_Title; + + wxPanel * m_PanelField; + wxPanel * m_PanelFootprintFilter; + wxButton * m_ButtonDeleteAllFootprintFilter; + wxButton * m_ButtonDeleteOneFootprintFilter; + + wxCheckBox * AsConvertButt; + wxCheckBox * ShowPinNumButt; + wxCheckBox * ShowPinNameButt; + wxCheckBox * m_PinsNameInsideButt; + + wxListBox * m_PartAliasList; + wxListBox * m_FootprintFilterListBox; + + wxRadioBox * m_FieldSelection; + wxCheckBox * m_ShowFieldTextCtrl; + wxCheckBox * m_VorientFieldTextCtrl; + wxRadioBox * m_FieldHJustifyCtrl; + wxRadioBox * m_FieldVJustifyCtrl; + WinEDA_GraphicTextCtrl * m_FieldTextCtrl; + WinEDA_EnterText * m_FieldNameCtrl; + WinEDA_PositionCtrl * m_FieldPositionCtrl; + int m_FieldFlags[NUMBER_OF_FIELDS]; + int m_FieldOrient[NUMBER_OF_FIELDS]; + int m_FieldHJustify[NUMBER_OF_FIELDS]; + int m_FieldVJustify[NUMBER_OF_FIELDS]; + int m_FieldSize[NUMBER_OF_FIELDS]; + wxString m_FieldText[NUMBER_OF_FIELDS]; + wxString m_FieldName[NUMBER_OF_FIELDS]; + wxPoint m_FieldPosition[NUMBER_OF_FIELDS]; + + bool m_RecreateToolbar; + int m_AliasLocation; + +}; + +#endif + // _DIALOG_EDIT_COMPONENT_IN_LIB_H_ diff --git a/eeschema/dialog_edit_component_in_lib.pjd b/eeschema/dialog_edit_component_in_lib.pjd new file mode 100644 index 0000000000..99d99dbc50 --- /dev/null +++ b/eeschema/dialog_edit_component_in_lib.pjd @@ -0,0 +1,1674 @@ + + +
+ 0 + "" + "" + "" + "" + 37 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "Lib Component Properties" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "ID_DIALOG" + 10000 + "WinEDA_PartPropertiesFrame" + "wxDialog" + "wxDialog" + "dialog_edit_component_in_lib.cpp" + "dialog_edit_component_in_lib.h" + "" + "Lib Component Properties" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Vertical" + "m_GeneralBoxSizer" + 0 + 0 + 0 + "<Any platform>" + + "wxNotebook: ID_LIBEDIT_NOTEBOOK" + "dialog-control-document" + "" + "notebook" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbNotebookProxy" + "ID_LIBEDIT_NOTEBOOK" + 10001 + "wxNotebook" + "m_NoteBook" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + "wxPanel: ID_PANEL_BASIC" + "dialog-control-document" + "" + "panel" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbPanelProxy" + "ID_PANEL_BASIC" + 10002 + "wxPanel" + "Options" + "" + "wxPanel" + "m_PanelBasic" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + "" + 1 + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbBoxSizerProxy" + "Vertical" + "m_PanelBasicBoxSizer" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + "General :" + "m_OptionsBoxSizer" + "" + "" + 0 + 1 + "Vertical" + "" + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Number of Units:" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxSpinCtrl: ID_SPINCTRL1" + "dialog-control-document" + "" + "spinctrl" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbSpinCtrlProxy" + "ID_SPINCTRL1" + 10010 + "wxSpinCtrl" + "SelNumberOfUnits" + 1 + 16 + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Skew:" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxSpinCtrl: ID_SPINCTRL" + "dialog-control-document" + "" + "spinctrl" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbSpinCtrlProxy" + "ID_SPINCTRL" + 10009 + "wxSpinCtrl" + "m_SetSkew" + 0 + 100 + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + + + "wxCheckBox: ID_CHECKBOX" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX" + 10007 + "wxCheckBox" + "m_OptionPower" + "Power Symbol" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX1" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX1" + 10008 + "wxCheckBox" + "m_OptionPartsLocked" + "Parts are locked" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + "wxPanel: ID_PANEL_DOC" + "dialog-control-document" + "" + "panel" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbPanelProxy" + "ID_PANEL_DOC" + 10004 + "wxPanel" + "Doc" + "" + "wxPanel" + "m_PanelDoc" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + "" + 1 + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbBoxSizerProxy" + "Vertical" + "m_PanelDocBoxSizer" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Doc:" + "" + "" + "" + "C40000" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL" + 10011 + "wxTextCtrl" + "m_Doc" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Keywords:" + "" + "" + "" + "C40000" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL1" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL1" + 10012 + "wxTextCtrl" + "m_Keywords" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "DocFileName:" + "" + "" + "" + "C40000" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL2" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL2" + 10013 + "wxTextCtrl" + "m_Docfile" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: ID_COPY_DOC_TO_ALIAS" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCopyDocToAliasClick" + "ID_COPY_DOC_TO_ALIAS" + 10014 + "wxButton" + "m_ButtonCopyDoc" + "Copy Doc" + 0 + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: ID_BROWSE_DOC_FILES" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "2/6/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnBrowseDocFilesClick" + "ID_BROWSE_DOC_FILES" + 10005 + "wxButton" + "" + "Browse DocFiles" + 0 + "" + "" + "" + "CA0000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + "wxPanel: ID_PANEL_ALIAS" + "dialog-control-document" + "" + "panel" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbPanelProxy" + "ID_PANEL_ALIAS" + 10003 + "wxPanel" + "Alias" + "" + "wxPanel" + "m_PanelAlias" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + "" + 1 + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + "" + + + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: wxID_CANCEL" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCancelClick" + "wxID_CANCEL" + 5101 + "wxButton" + "" + "&Cancel" + 0 + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_OK" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "2/8/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnOkClick" + "wxID_OK" + 5100 + "wxButton" + "" + "&OK" + 1 + "" + "" + "" + "CA0000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "dialog_edit_component_in_lib.rc" + "source-editor-document" + "dialog_edit_component_in_lib.rc" + "source-editor" + 0 + 0 + 1 + 0 + "2/8/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/dialog_edit_component_in_lib.rc b/eeschema/dialog_edit_component_in_lib.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/eeschema/dialog_edit_component_in_lib.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/eeschema/dialog_edit_component_in_schematic.cpp b/eeschema/dialog_edit_component_in_schematic.cpp new file mode 100644 index 0000000000..a609707f08 --- /dev/null +++ b/eeschema/dialog_edit_component_in_schematic.cpp @@ -0,0 +1,313 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_edit_component_in_schematic.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 03/03/2006 15:02:54 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 03/03/2006 15:02:54 + + +////@begin includes +////@end includes + +#include "dialog_edit_component_in_schematic.h" + +////@begin XPM images +////@end XPM images + +/*! + * WinEDA_ComponentPropertiesFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_ComponentPropertiesFrame, wxDialog ) + +/*! + * WinEDA_ComponentPropertiesFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_ComponentPropertiesFrame, wxDialog ) + +////@begin WinEDA_ComponentPropertiesFrame event table entries + EVT_BUTTON( wxID_CLOSE, WinEDA_ComponentPropertiesFrame::OnCloseClick ) + + EVT_BUTTON( ID_RESTORE_CMP_DEFAULTS, WinEDA_ComponentPropertiesFrame::OnRestoreCmpDefaultsClick ) + + EVT_BUTTON( wxID_OK, WinEDA_ComponentPropertiesFrame::OnOkClick ) + +////@end WinEDA_ComponentPropertiesFrame event table entries + + EVT_RADIOBOX(ID_ON_SELECT_FIELD, WinEDA_ComponentPropertiesFrame::SelectNewField) + +END_EVENT_TABLE() + +/*! + * WinEDA_ComponentPropertiesFrame constructors + */ + +WinEDA_ComponentPropertiesFrame::WinEDA_ComponentPropertiesFrame( ) +{ +} + +WinEDA_ComponentPropertiesFrame::WinEDA_ComponentPropertiesFrame( WinEDA_SchematicFrame* parent, + EDA_SchComponentStruct * cmp, + wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + m_Cmp = cmp; + m_LibEntry = FindLibPart(m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + + InitBuffers(); + + Create(parent, id, caption, pos, size, style); + + if ( m_LibEntry == NULL ) + { + SetTitle(_("Component properties (Not found in lib)")); + } +} + +/*! + * WinEDA_ComponentPropertiesFrame creator + */ + +bool WinEDA_ComponentPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_FieldNameCtrl = NULL; +////@begin WinEDA_ComponentPropertiesFrame member initialisation + m_GeneralBoxSizer = NULL; + m_NoteBook = NULL; + m_PanelBasic = NULL; + m_SelectUnit = NULL; + m_OrientUnit = NULL; + m_MirrorUnit = NULL; + m_MsgPartLocked = NULL; + m_ConvertButt = NULL; + m_RefInLib = NULL; + m_PanelField = NULL; + m_ShowFieldTextCtrl = NULL; + m_VorientFieldText = NULL; + m_FieldDatasBoxSizer = NULL; + m_FieldSelectionBoxSizer = NULL; +////@end WinEDA_ComponentPropertiesFrame member initialisation + +////@begin WinEDA_ComponentPropertiesFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + if (GetSizer()) + { + GetSizer()->SetSizeHints(this); + } + Centre(); +////@end WinEDA_ComponentPropertiesFrame creation + return true; +} + +/*! + * Control creation for WinEDA_ComponentPropertiesFrame + */ + +void WinEDA_ComponentPropertiesFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_ComponentPropertiesFrame content construction + // Generated by DialogBlocks, 24/11/2006 13:20:15 (unregistered) + + WinEDA_ComponentPropertiesFrame* itemDialog1 = this; + + m_GeneralBoxSizer = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(m_GeneralBoxSizer); + + m_NoteBook = new wxNotebook( itemDialog1, ID_SCHEDIT_NOTEBOOK, wxDefaultPosition, wxDefaultSize, wxNB_DEFAULT|wxNB_TOP ); + + m_PanelBasic = new wxPanel( m_NoteBook, ID_PANEL_BASIC, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); + wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL); + m_PanelBasic->SetSizer(itemBoxSizer5); + + wxString m_SelectUnitStrings[] = { + _("Unit 1"), + _("Unit 2"), + _("Unit 3"), + _("Unit 4"), + _("Unit 5"), + _("Unit 6"), + _("Unit 7"), + _("Unit 8"), + _("Unit 9"), + _("Unit 10"), + _("Unit 11"), + _("Unit 12"), + _("Unit 13"), + _("Unit 14"), + _("Unit 15"), + _("Unit 16"), + _("Unit 16"), + _("Unit 17"), + _("Unit 18"), + _("Unit 19"), + _("Unit 20"), + _("Unit 21"), + _("Unit 22"), + _("Unit 23"), + _("Unit 24"), + _("Unit 25"), + _("Unit 26") + }; + m_SelectUnit = new wxRadioBox( m_PanelBasic, ID_RADIOBOX_UNIT, _("Unit:"), wxDefaultPosition, wxDefaultSize, 27, m_SelectUnitStrings, 9, wxRA_SPECIFY_ROWS ); + m_SelectUnit->SetSelection(0); + itemBoxSizer5->Add(m_SelectUnit, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer5->Add(itemBoxSizer7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer7->Add(itemBoxSizer8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + wxString m_OrientUnitStrings[] = { + _("0"), + _("+90"), + _("180"), + _("-90") + }; + m_OrientUnit = new wxRadioBox( m_PanelBasic, ID_RADIOBOX_ORIENT, _("Orient:"), wxDefaultPosition, wxDefaultSize, 4, m_OrientUnitStrings, 1, wxRA_SPECIFY_COLS ); + m_OrientUnit->SetSelection(0); + itemBoxSizer8->Add(m_OrientUnit, 0, wxGROW|wxLEFT|wxRIGHT, 5); + + wxString m_MirrorUnitStrings[] = { + _("Normal"), + _("Mirror --"), + _("Mirror !") + }; + m_MirrorUnit = new wxRadioBox( m_PanelBasic, ID_RADIOBOX_MIRROR, _("Mirror:"), wxDefaultPosition, wxDefaultSize, 3, m_MirrorUnitStrings, 1, wxRA_SPECIFY_COLS ); + m_MirrorUnit->SetSelection(0); + itemBoxSizer8->Add(m_MirrorUnit, 0, wxGROW|wxLEFT|wxRIGHT, 5); + + m_MsgPartLocked = new wxStaticText( m_PanelBasic, wxID_STATIC, _("Parts are locked"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer7->Add(m_MsgPartLocked, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5); + + m_ConvertButt = new wxCheckBox( m_PanelBasic, ID_CHECKBOX, _("Convert"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_ConvertButt->SetValue(false); + itemBoxSizer7->Add(m_ConvertButt, 0, wxALIGN_LEFT|wxALL, 5); + + wxStaticText* itemStaticText13 = new wxStaticText( m_PanelBasic, wxID_STATIC, _("Chip Name:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticText13->SetForegroundColour(wxColour(202, 0, 0)); + itemBoxSizer7->Add(itemStaticText13, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_RefInLib = new wxTextCtrl( m_PanelBasic, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer7->Add(m_RefInLib, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_NoteBook->AddPage(m_PanelBasic, _("Options")); + + m_PanelField = new wxPanel( m_NoteBook, ID_PANEL_FIELD, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); + wxBoxSizer* itemBoxSizer16 = new wxBoxSizer(wxHORIZONTAL); + m_PanelField->SetSizer(itemBoxSizer16); + + wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer16->Add(itemBoxSizer17, 0, wxALIGN_TOP|wxALL, 5); + wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer17->Add(itemBoxSizer18, 0, wxGROW|wxALL, 5); + m_ShowFieldTextCtrl = new wxCheckBox( m_PanelField, ID_CHECKBOX_SHOW_FILED, _("Show Text"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_ShowFieldTextCtrl->SetValue(false); + itemBoxSizer18->Add(m_ShowFieldTextCtrl, 0, wxGROW|wxALL, 5); + + m_VorientFieldText = new wxCheckBox( m_PanelField, ID_CHECKBOX_FILED_ORIENT, _("Vertical"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_VorientFieldText->SetValue(false); + itemBoxSizer18->Add(m_VorientFieldText, 0, wxGROW|wxALL, 5); + + m_FieldDatasBoxSizer = new wxBoxSizer(wxVERTICAL); + itemBoxSizer17->Add(m_FieldDatasBoxSizer, 0, wxGROW|wxALL, 5); + + m_FieldSelectionBoxSizer = new wxBoxSizer(wxVERTICAL); + itemBoxSizer16->Add(m_FieldSelectionBoxSizer, 0, wxGROW|wxALL, 5); + + m_NoteBook->AddPage(m_PanelField, _("Fields")); + + m_GeneralBoxSizer->Add(m_NoteBook, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxHORIZONTAL); + m_GeneralBoxSizer->Add(itemBoxSizer23, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxButton* itemButton24 = new wxButton( itemDialog1, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton24->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer23->Add(itemButton24, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton25 = new wxButton( itemDialog1, ID_RESTORE_CMP_DEFAULTS, _("Defaults"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton25->SetForegroundColour(wxColour(206, 0, 0)); + itemBoxSizer23->Add(itemButton25, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton26 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton26->SetForegroundColour(wxColour(0, 128, 0)); + itemBoxSizer23->Add(itemButton26, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + +////@end WinEDA_ComponentPropertiesFrame content construction + BuildPanelBasic(); + BuildPanelFields(); +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_ComponentPropertiesFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_ComponentPropertiesFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_ComponentPropertiesFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_ComponentPropertiesFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_ComponentPropertiesFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_ComponentPropertiesFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_ComponentPropertiesFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + */ + +void WinEDA_ComponentPropertiesFrame::OnCloseClick( wxCommandEvent& event ) +{ + Close(true); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RESTORE_CMP_DEFAULTS + */ + +void WinEDA_ComponentPropertiesFrame::OnRestoreCmpDefaultsClick( wxCommandEvent& event ) +{ + SetInitCmp(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_ComponentPropertiesFrame::OnOkClick( wxCommandEvent& event ) +{ + ComponentPropertiesAccept(event); +} + + diff --git a/eeschema/dialog_edit_component_in_schematic.h b/eeschema/dialog_edit_component_in_schematic.h new file mode 100644 index 0000000000..73a294c178 --- /dev/null +++ b/eeschema/dialog_edit_component_in_schematic.h @@ -0,0 +1,157 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_edit_component_in_schematic.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 03/03/2006 15:02:54 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 03/03/2006 15:02:54 + +#ifndef _DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_H_ +#define _DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_H_ + +/*! + * Includes + */ + +////@begin includes +#include "wx/notebook.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +class wxBoxSizer; +class wxNotebook; +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define ID_SCHEDIT_NOTEBOOK 10001 +#define ID_PANEL_BASIC 10002 +#define ID_RADIOBOX_UNIT 10004 +#define ID_RADIOBOX_ORIENT 10005 +#define ID_RADIOBOX_MIRROR 10007 +#define ID_CHECKBOX 10008 +#define ID_TEXTCTRL 10009 +#define ID_PANEL_FIELD 10003 +#define ID_CHECKBOX_SHOW_FILED 10010 +#define ID_CHECKBOX_FILED_ORIENT 10011 +#define ID_RESTORE_CMP_DEFAULTS 10006 +#define SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_TITLE _("Component properties") +#define SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_POSITION wxDefaultPosition +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_ComponentPropertiesFrame class declaration + */ + +class WinEDA_ComponentPropertiesFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_ComponentPropertiesFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_ComponentPropertiesFrame( ); + WinEDA_ComponentPropertiesFrame( WinEDA_SchematicFrame* parent, + EDA_SchComponentStruct * cmp, + wxWindowID id = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_COMPONENTPROPERTIESFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_ComponentPropertiesFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + void OnCloseClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RESTORE_CMP_DEFAULTS + void OnRestoreCmpDefaultsClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + +////@end WinEDA_ComponentPropertiesFrame event handler declarations + +////@begin WinEDA_ComponentPropertiesFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_ComponentPropertiesFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void InitBuffers(void); + void BuildPanelBasic(void); + void BuildPanelFields(void); + void ComponentPropertiesAccept(wxCommandEvent& event); + void SetInitCmp( wxCommandEvent& event ); + void CopyDataToPanelField(void); + void CopyPanelFieldToData(void); + void SelectNewField(wxCommandEvent& event); + +////@begin WinEDA_ComponentPropertiesFrame member variables + wxBoxSizer* m_GeneralBoxSizer; + wxNotebook* m_NoteBook; + wxPanel* m_PanelBasic; + wxRadioBox* m_SelectUnit; + wxRadioBox* m_OrientUnit; + wxRadioBox* m_MirrorUnit; + wxStaticText* m_MsgPartLocked; + wxCheckBox* m_ConvertButt; + wxTextCtrl* m_RefInLib; + wxPanel* m_PanelField; + wxCheckBox* m_ShowFieldTextCtrl; + wxCheckBox* m_VorientFieldText; + wxBoxSizer* m_FieldDatasBoxSizer; + wxBoxSizer* m_FieldSelectionBoxSizer; +////@end WinEDA_ComponentPropertiesFrame member variables + + WinEDA_SchematicFrame * m_Parent; + EDA_SchComponentStruct * m_Cmp; + EDA_LibComponentStruct * m_LibEntry; + int m_CurrentFieldId; + + wxRadioBox * m_FieldSelection; + WinEDA_GraphicTextCtrl * m_FieldTextCtrl; + WinEDA_EnterText * m_FieldNameCtrl; + WinEDA_PositionCtrl * m_FieldPositionCtrl; + wxString m_FieldText[NUMBER_OF_FIELDS]; + wxString m_FieldName[NUMBER_OF_FIELDS]; + wxPoint m_FieldPosition[NUMBER_OF_FIELDS]; + int m_FieldSize[NUMBER_OF_FIELDS]; + int m_FieldFlags[NUMBER_OF_FIELDS]; + int m_FieldOrient[NUMBER_OF_FIELDS]; +}; + +#endif + // _DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_H_ diff --git a/eeschema/dialog_edit_component_in_schematic.pjd b/eeschema/dialog_edit_component_in_schematic.pjd new file mode 100644 index 0000000000..a673d37741 --- /dev/null +++ b/eeschema/dialog_edit_component_in_schematic.pjd @@ -0,0 +1,1419 @@ + + +
+ 0 + "" + "" + "" + "" + 33 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 0 + 4 + " " + "" + 0 + 0 + 1 + 1 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "Component properties" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "3/5/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "ID_DIALOG" + 10000 + "WinEDA_ComponentPropertiesFrame" + "wxDialog" + "wxDialog" + "dialog_edit_component_in_schematic.cpp" + "dialog_edit_component_in_schematic.h" + "" + "Component properties" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "3/5/2006" + "wbBoxSizerProxy" + "Vertical" + "m_GeneralBoxSizer" + 0 + 0 + 0 + "<Any platform>" + + "wxNotebook: ID_SCHEDIT_NOTEBOOK" + "dialog-control-document" + "" + "notebook" + 0 + 1 + 0 + 0 + "3/5/2006" + "wbNotebookProxy" + "ID_SCHEDIT_NOTEBOOK" + 10001 + "wxNotebook" + "m_NoteBook" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + 0 + + "wxPanel: ID_PANEL_BASIC" + "dialog-control-document" + "" + "panel" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbPanelProxy" + "ID_PANEL_BASIC" + 10002 + "wxPanel" + "wxPanel" + "m_PanelBasic" + "Options" + "" + 0 + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + "" + 1 + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + "" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxRadioBox: ID_RADIOBOX_UNIT" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX_UNIT" + 10004 + "wxRadioBox" + "m_SelectUnit" + "Unit:" + 9 + "Unit 1|Unit 2|Unit 3|Unit 4|Unit 5|Unit 6|Unit 7|Unit 8|Unit 9|Unit 10|Unit 11|Unit 12|Unit 13|Unit 14|Unit 15|Unit 16|Unit 16|Unit 17|Unit 18|Unit 19|Unit 20|Unit 21|Unit 22|Unit 23|Unit 24|Unit 25|Unit 26" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxRadioBox: ID_RADIOBOX_ORIENT" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX_ORIENT" + 10005 + "wxRadioBox" + "m_OrientUnit" + "Orient:" + 1 + "0|+90|180|-90" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "" + "" + + + "wxRadioBox: ID_RADIOBOX_MIRROR" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX_MIRROR" + 10007 + "wxRadioBox" + "m_MirrorUnit" + "Mirror:" + 1 + "Normal|Mirror --|Mirror !" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "" + "" + + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_MsgPartLocked" + "Parts are locked" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX" + 10008 + "wxCheckBox" + "m_ConvertButt" + "Convert" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Chip Name:" + -1 + "" + "" + "" + "CA0000" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL" + 10009 + "wxTextCtrl" + "m_RefInLib" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + + + + "wxPanel: ID_PANEL_FIELD" + "dialog-control-document" + "" + "panel" + 0 + 1 + 0 + 0 + "3/5/2006" + "wbPanelProxy" + "ID_PANEL_FIELD" + 10003 + "wxPanel" + "wxPanel" + "m_PanelField" + "Fields" + "" + 0 + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + "" + 1 + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + "" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "3/5/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Top" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Expand" + "Top" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxCheckBox: ID_CHECKBOX_SHOW_FILED" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX_SHOW_FILED" + 10010 + "wxCheckBox" + "m_ShowFieldTextCtrl" + "Show Text" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX_FILED_ORIENT" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX_FILED_ORIENT" + 10011 + "wxCheckBox" + "m_VorientFieldText" + "Vertical" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbBoxSizerProxy" + "Vertical" + "m_FieldDatasBoxSizer" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "3/4/2006" + "wbBoxSizerProxy" + "Vertical" + "m_FieldSelectionBoxSizer" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + + + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "3/5/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: wxID_CLOSE" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "3/5/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCloseClick" + "wxID_CLOSE" + 5001 + "wxButton" + "" + "&Close" + 0 + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: ID_RESTORE_CMP_DEFAULTS" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "3/5/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnRestoreCmpDefaultsClick" + "ID_RESTORE_CMP_DEFAULTS" + 10006 + "wxButton" + "" + "Defaults" + 0 + "" + "" + "" + "CE0000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_OK" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "3/5/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnOkClick" + "wxID_OK" + 5100 + "wxButton" + "" + "&OK" + 0 + "" + "" + "" + "008000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "dialog_edit_component_in_schematic.rc" + "source-editor-document" + "dialog_edit_component_in_schematic.rc" + "source-editor" + 0 + 0 + 1 + 0 + "3/5/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/dialog_edit_component_in_schematic.rc b/eeschema/dialog_edit_component_in_schematic.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/eeschema/dialog_edit_component_in_schematic.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/eeschema/dialog_edit_label.cpp b/eeschema/dialog_edit_label.cpp new file mode 100644 index 0000000000..57e513461f --- /dev/null +++ b/eeschema/dialog_edit_label.cpp @@ -0,0 +1,257 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_edit_label.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 19/02/2006 15:46:26 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 19/02/2006 15:46:26 + +/* This is the dialog box for labels, glob. labels and graphic texts edition */ + +////@begin includes +////@end includes + +#include "dialog_edit_label.h" + +////@begin XPM images +////@end XPM images + +/*! + * WinEDA_LabelPropertiesFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_LabelPropertiesFrame, wxDialog ) + +/*! + * WinEDA_LabelPropertiesFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_LabelPropertiesFrame, wxDialog ) + +////@begin WinEDA_LabelPropertiesFrame event table entries + EVT_CLOSE( WinEDA_LabelPropertiesFrame::OnCloseWindow ) + + EVT_BUTTON( wxID_OK, WinEDA_LabelPropertiesFrame::OnOkClick ) + + EVT_BUTTON( wxID_CLOSE, WinEDA_LabelPropertiesFrame::OnCloseClick ) + +////@end WinEDA_LabelPropertiesFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_LabelPropertiesFrame constructors + */ + +WinEDA_LabelPropertiesFrame::WinEDA_LabelPropertiesFrame( ) +{ +} + +WinEDA_LabelPropertiesFrame::WinEDA_LabelPropertiesFrame( WinEDA_SchematicFrame* parent, + DrawTextStruct * CurrentText, + const wxPoint& pos, + wxWindowID id, const wxString& caption, const wxSize& size, long style ) +{ +wxString msg; + + m_Parent = parent; + m_CurrentText = CurrentText; + Create(parent, id, caption, pos, size, style); + m_TextLabel->SetValue(m_CurrentText->m_Text); + m_TextLabel->SetFocus(); + switch( m_CurrentText->m_StructType ) + { + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + SetTitle(_("Global Label properties")); + break; + + case DRAW_LABEL_STRUCT_TYPE: + SetTitle(_("Label properties")); + break; + + default: + SetTitle(_("Text properties")); + break; + } + + + msg = m_SizeTitle->GetLabel() + ReturnUnitSymbol(); + m_SizeTitle->SetLabel(msg); + + msg = ReturnStringFromValue(g_UnitMetric, m_CurrentText->m_Size.x, m_Parent->m_InternalUnits); + m_TextSize->SetValue(msg); +} + +/*! + * WinEDA_LabelPropertiesFrame creator + */ + +bool WinEDA_LabelPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_LabelPropertiesFrame member initialisation + m_TextLabel = NULL; + m_TextOrient = NULL; + m_TextShape = NULL; + m_SizeTitle = NULL; + m_TextSize = NULL; +////@end WinEDA_LabelPropertiesFrame member initialisation + +////@begin WinEDA_LabelPropertiesFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_LabelPropertiesFrame creation + return true; +} + +/*! + * Control creation for WinEDA_LabelPropertiesFrame + */ + +void WinEDA_LabelPropertiesFrame::CreateControls() +{ + SetFont(*g_DialogFont); +////@begin WinEDA_LabelPropertiesFrame content construction + // Generated by DialogBlocks, 19/02/2006 16:49:06 (unregistered) + + WinEDA_LabelPropertiesFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5); + + wxStaticText* itemStaticText4 = new wxStaticText( itemDialog1, wxID_STATIC, _("Text "), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(itemStaticText4, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_TextLabel = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(250, -1), 0 ); + itemBoxSizer3->Add(m_TextLabel, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer3->Add(itemBoxSizer6, 0, wxGROW|wxALL, 5); + + wxString m_TextOrientStrings[] = { + _("Right"), + _("Up"), + _("Left"), + _("Down") + }; + m_TextOrient = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Text Orient:"), wxDefaultPosition, wxDefaultSize, 4, m_TextOrientStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer6->Add(m_TextOrient, 0, wxALIGN_TOP|wxALL, 5); + + itemBoxSizer6->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxString m_TextShapeStrings[] = { + _("Input"), + _("Output"), + _("Bidi"), + _("TriState"), + _("Passive") + }; + m_TextShape = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Glabel Shape:"), wxDefaultPosition, wxDefaultSize, 5, m_TextShapeStrings, 1, wxRA_SPECIFY_COLS ); + m_TextShape->Show(false); + itemBoxSizer6->Add(m_TextShape, 0, wxALIGN_TOP|wxALL, 5); + + wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer10, 0, wxGROW|wxALL, 5); + + m_SizeTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Size "), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer10->Add(m_SizeTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_TextSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer10->Add(m_TextSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + itemBoxSizer10->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxButton* itemButton14 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton14->SetDefault(); + itemButton14->SetForegroundColour(wxColour(204, 0, 0)); + itemBoxSizer10->Add(itemButton14, 0, wxGROW|wxALL, 5); + + wxButton* itemButton15 = new wxButton( itemDialog1, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton15->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer10->Add(itemButton15, 0, wxGROW|wxALL, 5); + + // Set validators + m_TextOrient->SetValidator( wxGenericValidator(& m_CurrentText->m_Orient) ); + m_TextShape->SetValidator( wxGenericValidator(& m_CurrentText->m_Shape) ); +////@end WinEDA_LabelPropertiesFrame content construction + + if (m_CurrentText->m_StructType == DRAW_GLOBAL_LABEL_STRUCT_TYPE ) + m_TextShape->Show(true); +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_LabelPropertiesFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_LabelPropertiesFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_LabelPropertiesFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_LabelPropertiesFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_LabelPropertiesFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_LabelPropertiesFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_LabelPropertiesFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_LabelPropertiesFrame::OnOkClick( wxCommandEvent& event ) +{ + TextPropertiesAccept(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + */ + +void WinEDA_LabelPropertiesFrame::OnCloseClick( wxCommandEvent& event ) +{ + Close(); +} + + +/*! + * wxEVT_CLOSE_WINDOW event handler for ID_DIALOG + */ + +void WinEDA_LabelPropertiesFrame::OnCloseWindow( wxCloseEvent& event ) +{ + m_Parent->DrawPanel->MouseToCursorSchema(); + event.Skip(); +} + + diff --git a/eeschema/dialog_edit_label.h b/eeschema/dialog_edit_label.h new file mode 100644 index 0000000000..48a0e85539 --- /dev/null +++ b/eeschema/dialog_edit_label.h @@ -0,0 +1,121 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_edit_label.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 19/02/2006 15:46:26 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 19/02/2006 15:46:26 + +#ifndef _DIALOG_EDIT_LABEL_H_ +#define _DIALOG_EDIT_LABEL_H_ + + +/*! + * Includes + */ + +////@begin includes +#include "wx/valgen.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_LABELPROPERTIESFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_LABELPROPERTIESFRAME_TITLE _("Dialog") +#define SYMBOL_WINEDA_LABELPROPERTIESFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_LABELPROPERTIESFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_LABELPROPERTIESFRAME_POSITION wxDefaultPosition +#define ID_TEXTCTRL 10001 +#define ID_RADIOBOX 10003 +#define ID_RADIOBOX1 10004 +#define ID_TEXTCTRL1 10002 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_LabelPropertiesFrame class declaration + */ + +class WinEDA_LabelPropertiesFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_LabelPropertiesFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_LabelPropertiesFrame( ); + WinEDA_LabelPropertiesFrame( WinEDA_SchematicFrame* parent, + DrawTextStruct * CurrentText, + const wxPoint& pos = SYMBOL_WINEDA_LABELPROPERTIESFRAME_POSITION, + wxWindowID id = SYMBOL_WINEDA_LABELPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_LABELPROPERTIESFRAME_TITLE, const wxSize& size = SYMBOL_WINEDA_LABELPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_LABELPROPERTIESFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_LABELPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_LABELPROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_LABELPROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_LABELPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_LABELPROPERTIESFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_LabelPropertiesFrame event handler declarations + + /// wxEVT_CLOSE_WINDOW event handler for ID_DIALOG + void OnCloseWindow( wxCloseEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + void OnCloseClick( wxCommandEvent& event ); + +////@end WinEDA_LabelPropertiesFrame event handler declarations + +////@begin WinEDA_LabelPropertiesFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_LabelPropertiesFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + void TextPropertiesAccept(wxCommandEvent& event); + +////@begin WinEDA_LabelPropertiesFrame member variables + wxTextCtrl* m_TextLabel; + wxRadioBox* m_TextOrient; + wxRadioBox* m_TextShape; + wxStaticText* m_SizeTitle; + wxTextCtrl* m_TextSize; +////@end WinEDA_LabelPropertiesFrame member variables + + WinEDA_SchematicFrame * m_Parent; + DrawTextStruct * m_CurrentText; + +}; + +#endif + // _DIALOG_EDIT_LABEL_H_ diff --git a/eeschema/dialog_edit_label.pjd b/eeschema/dialog_edit_label.pjd new file mode 100644 index 0000000000..fde4cb29b9 --- /dev/null +++ b/eeschema/dialog_edit_label.pjd @@ -0,0 +1,890 @@ + + +
+ 0 + "" + "" + "" + "" + 22 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "Untitled" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "19/3/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "wxEVT_CLOSE_WINDOW|OnCloseWindow" + "ID_DIALOG" + 10000 + "WinEDA_LabelPropertiesFrame" + "wxDialog" + "wxDialog" + "dialog_edit_label.cpp" + "dialog_edit_label.h" + "" + "Dialog" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Horizontal" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "19/2/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "19/2/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Text " + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "19/2/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL" + 10001 + "wxTextCtrl" + "m_TextLabel" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 250 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "19/2/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxRadioBox: ID_RADIOBOX" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "19/2/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX" + 10003 + "wxRadioBox" + "m_TextOrient" + "Text Orient:" + 1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "m_CurrentText->m_Orient" + "wxGenericValidator(& %VARIABLE%)" + 0 + 1 + "Right|Up|Left|Down" + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Top" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "19/2/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxRadioBox: ID_RADIOBOX1" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "19/2/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX1" + 10004 + "wxRadioBox" + "m_TextShape" + "Glabel Shape:" + 1 + "" + "" + "" + "" + "" + 1 + 1 + "<Any platform>" + "m_CurrentText->m_Shape" + "wxGenericValidator(& %VARIABLE%)" + 0 + 1 + "Input|Output|Bidi|TriState|Passive" + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Top" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "19/2/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "19/2/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_SizeTitle" + "Size " + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL1" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "19/2/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL1" + 10002 + "wxTextCtrl" + "m_TextSize" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "19/2/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxButton: wxID_OK" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "19/2/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnOkClick" + "wxID_OK" + 5100 + "wxButton" + "" + "&OK" + 1 + "" + "" + "" + "CC0000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_CLOSE" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "19/2/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCloseClick" + "wxID_CLOSE" + 5001 + "wxButton" + "" + "&Close" + 0 + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "dialog_edit_label.rc" + "source-editor-document" + "dialog_edit_label.rc" + "source-editor" + 0 + 0 + 1 + 0 + "19/3/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/dialog_edit_label.rc b/eeschema/dialog_edit_label.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/eeschema/dialog_edit_label.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/eeschema/dialog_eeschema_config.cpp b/eeschema/dialog_eeschema_config.cpp new file mode 100644 index 0000000000..2d0dc5fb8d --- /dev/null +++ b/eeschema/dialog_eeschema_config.cpp @@ -0,0 +1,455 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_eeschema_config.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 17/02/2006 21:14:46 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 17/02/2006 21:14:46 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "dialog_eeschema_config.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes +#include "fctsys.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" +#include "netlist.h" + +#include "id.h" + +#include "dialog_eeschema_config.h" + +////@begin XPM images +////@end XPM images + +/******************************************************************/ +void WinEDA_SchematicFrame::InstallConfigFrame(const wxPoint & pos) +/******************************************************************/ +{ + KiConfigEeschemaFrame * CfgFrame = new KiConfigEeschemaFrame(this); + CfgFrame->ShowModal(); CfgFrame->Destroy(); +} + + +/*! + * KiConfigEeschemaFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( KiConfigEeschemaFrame, wxDialog ) + +/*! + * KiConfigEeschemaFrame event table definition + */ + +BEGIN_EVENT_TABLE( KiConfigEeschemaFrame, wxDialog ) + +////@begin KiConfigEeschemaFrame event table entries + EVT_CLOSE( KiConfigEeschemaFrame::OnCloseWindow ) + + EVT_BUTTON( SAVE_CFG, KiConfigEeschemaFrame::OnSaveCfgClick ) + + EVT_RADIOBOX( FORMAT_NETLIST, KiConfigEeschemaFrame::OnFormatNetlistSelected ) + + EVT_BUTTON( DEL_LIB, KiConfigEeschemaFrame::OnDelLibClick ) + + EVT_BUTTON( ADD_LIB, KiConfigEeschemaFrame::OnAddLibClick ) + + EVT_BUTTON( INSERT_LIB, KiConfigEeschemaFrame::OnInsertLibClick ) + +////@end KiConfigEeschemaFrame event table entries + +END_EVENT_TABLE() + +/*! + * KiConfigEeschemaFrame constructors + */ + +KiConfigEeschemaFrame::KiConfigEeschemaFrame( ) +{ +} + +KiConfigEeschemaFrame::KiConfigEeschemaFrame( WinEDA_SchematicFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +wxString msg; + + m_Parent = parent; + m_LibListChanged = FALSE; + + Create(parent, id, caption, pos, size, style); + + msg = _("from ") + EDA_Appl->m_CurrentOptionFile; + SetTitle(msg); + SetFormatsNetListes(); + m_ListLibr->InsertItems(g_LibName_List, 0); + m_LibDirCtrl->SetValue( g_UserLibDirBuffer ); +} + +/*! + * KiConfigEeschemaFrame creator + */ + +bool KiConfigEeschemaFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin KiConfigEeschemaFrame member initialisation + m_NetFormatBox = NULL; + m_FileExtList = NULL; + m_ListLibr = NULL; + m_LibDirCtrl = NULL; +////@end KiConfigEeschemaFrame member initialisation + +////@begin KiConfigEeschemaFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end KiConfigEeschemaFrame creation + return true; +} + +/*! + * Control creation for KiConfigEeschemaFrame + */ + +void KiConfigEeschemaFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin KiConfigEeschemaFrame content construction + // Generated by DialogBlocks, 18/02/2006 09:45:23 (unregistered) + + KiConfigEeschemaFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer4, 0, wxGROW|wxALL, 5); + + wxButton* itemButton5 = new wxButton( itemDialog1, SAVE_CFG, _("Save Cfg"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton5->SetForegroundColour(wxColour(204, 0, 0)); + itemBoxSizer4->Add(itemButton5, 0, wxGROW|wxALL, 5); + + itemBoxSizer4->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxString m_NetFormatBoxStrings[] = { + _("PcbNew"), + _("&OrcadPcb2"), + _("&CadStar"), + _("&Spice"), + _("Other") + }; + m_NetFormatBox = new wxRadioBox( itemDialog1, FORMAT_NETLIST, _("NetList Formats:"), wxDefaultPosition, wxDefaultSize, 5, m_NetFormatBoxStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer4->Add(m_NetFormatBox, 0, wxGROW|wxALL, 5); + + itemBoxSizer4->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer9Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Files ext:")); + m_FileExtList = new wxStaticBoxSizer(itemStaticBoxSizer9Static, wxVERTICAL); + itemBoxSizer4->Add(m_FileExtList, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer10, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer10->Add(itemBoxSizer11, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer11->Add(itemBoxSizer12, 0, wxALIGN_CENTER_VERTICAL, 5); + + wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer12->Add(itemBoxSizer13, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxButton* itemButton14 = new wxButton( itemDialog1, DEL_LIB, _("Del"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton14->SetForegroundColour(wxColour(204, 0, 0)); + itemBoxSizer13->Add(itemButton14, 0, wxGROW|wxALL, 5); + + wxButton* itemButton15 = new wxButton( itemDialog1, ADD_LIB, _("Add"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton15->SetForegroundColour(wxColour(0, 128, 0)); + itemBoxSizer13->Add(itemButton15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton16 = new wxButton( itemDialog1, INSERT_LIB, _("Ins"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton16->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer13->Add(itemButton16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer12->Add(itemBoxSizer17, 0, wxGROW|wxALL, 5); + + wxStaticText* itemStaticText18 = new wxStaticText( itemDialog1, wxID_STATIC, _("Libraries"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticText18->SetForegroundColour(wxColour(204, 0, 0)); + itemBoxSizer17->Add(itemStaticText18, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + + wxString* m_ListLibrStrings = NULL; + m_ListLibr = new wxListBox( itemDialog1, ID_LIST_LIBS, wxDefaultPosition, wxSize(-1, 300), 0, m_ListLibrStrings, wxLB_SINGLE ); + itemBoxSizer17->Add(m_ListLibr, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxStaticText* itemStaticText20 = new wxStaticText( itemDialog1, wxID_STATIC, _("Library files path:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticText20->SetForegroundColour(wxColour(204, 0, 0)); + itemBoxSizer2->Add(itemStaticText20, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + + m_LibDirCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add(m_LibDirCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + +////@end KiConfigEeschemaFrame content construction + +wxString msg = _("Cmp file Ext: ") + g_NetCmpExtBuffer; + wxStaticText * text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); + m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + + msg = _("Net file Ext: ") + g_NetExtBuffer; + text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); + m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + + msg = _("Library file Ext: ") + g_LibExtBuffer; + text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); + m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + + msg = _("Symbol file Ext: ") + g_SymbolExtBuffer; + text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); + m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + + msg = _("Schematic file Ext: ") + g_SchExtBuffer; + text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); + m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); +} + +/*! + * Should we show tooltips? + */ + +bool KiConfigEeschemaFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap KiConfigEeschemaFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin KiConfigEeschemaFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end KiConfigEeschemaFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon KiConfigEeschemaFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin KiConfigEeschemaFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end KiConfigEeschemaFrame icon retrieval +} + + + +/**************************************************************/ +void KiConfigEeschemaFrame::OnCloseWindow(wxCloseEvent & event) +/**************************************************************/ +{ + ChangeSetup(); + if ( m_LibListChanged ) + { + LoadLibraries(m_Parent); + if ( m_Parent->m_Parent->ViewlibFrame ) + m_Parent->m_Parent->ViewlibFrame->ReCreateListLib(); + } + EndModal(0); +} + + +/*********************************************/ +void KiConfigEeschemaFrame::ChangeSetup(void) +/*********************************************/ +{ + g_UserLibDirBuffer = m_LibDirCtrl->GetValue(); + SetRealLibraryPath( wxT("library") ); +} + + + +/********************************************************/ +void KiConfigEeschemaFrame::LibDelFct(wxCommandEvent& event) +/********************************************************/ +{ +int ii; + + ii = m_ListLibr->GetSelection(); + if ( ii < 0 ) return; + + g_LibName_List.RemoveAt(ii); + m_ListLibr->Clear(); + m_ListLibr->InsertItems(g_LibName_List, 0); + m_LibListChanged = TRUE; +} + +/****************************************************************/ +void KiConfigEeschemaFrame::AddOrInsertLibrary(wxCommandEvent& event) +/****************************************************************/ +/* Insert or add a library to the existing library list: + New library is put in list before (insert) or after (add) + the selection +*/ +{ +int ii; +wxString FullLibName,ShortLibName, Mask; + + ii = m_ListLibr->GetSelection(); + if ( ii < 0 ) ii = 0; + ChangeSetup(); + if( event.GetId() == ADD_LIB) + { + if( g_LibName_List.GetCount() != 0 ) ii ++; /* Add after selection */ + } + + 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); + + //Add or insert new library name + if (FindLibrary(ShortLibName) == NULL) + { + m_LibListChanged = TRUE; + g_LibName_List.Insert(ShortLibName, ii); + m_ListLibr->Clear(); + m_ListLibr->InsertItems(g_LibName_List, 0); + } + + else DisplayError(this, _("Library already in use")); + +} + + + +/****************************************************/ +void KiConfigEeschemaFrame::SetFormatsNetListes(void) +/****************************************************/ +/* Adjust the m_NetFormatBox current selection, according to the current netlist format*/ + +{ + switch( g_NetFormat ) + { + case NET_TYPE_NOT_INIT: + case NET_TYPE_PCBNEW: + m_NetFormatBox->SetSelection(0); + break; + + case NET_TYPE_ORCADPCB2: + m_NetFormatBox->SetSelection(1); + break; + + case NET_TYPE_CADSTAR: + m_NetFormatBox->SetSelection(2); + break; + + case NET_TYPE_SPICE: + m_NetFormatBox->SetSelection(3); + break; + + default: + m_NetFormatBox->SetSelection(4); + break; + } +} + +/*! + * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for FORMAT_NETLIST + */ + +void KiConfigEeschemaFrame::OnFormatNetlistSelected( wxCommandEvent& event ) +{ +int ii; + + ii = m_NetFormatBox->GetSelection(); + if ( ii == 0 ) g_NetFormat = NET_TYPE_PCBNEW; + if ( ii == 1 ) g_NetFormat = NET_TYPE_ORCADPCB2; + else if ( ii == 2 ) g_NetFormat = NET_TYPE_CADSTAR; + else if ( ii == 3 ) g_NetFormat = NET_TYPE_SPICE; + else if ( g_NetFormat < NET_TYPE_CUSTOM1 ) g_NetFormat = NET_TYPE_CUSTOM1; +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for DEL_LIB + */ + +void KiConfigEeschemaFrame::OnDelLibClick( wxCommandEvent& event ) +{ + LibDelFct(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ADD_LIB + */ + +void KiConfigEeschemaFrame::OnAddLibClick( wxCommandEvent& event ) +{ + AddOrInsertLibrary(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for INSERT_LIB + */ + +void KiConfigEeschemaFrame::OnInsertLibClick( wxCommandEvent& event ) +{ + AddOrInsertLibrary(event); +} + + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for SAVE_CFG + */ + +void KiConfigEeschemaFrame::OnSaveCfgClick( wxCommandEvent& event ) +{ + ChangeSetup(); + m_Parent->Save_Config(this); +} + + diff --git a/eeschema/dialog_eeschema_config.h b/eeschema/dialog_eeschema_config.h new file mode 100644 index 0000000000..fd97efe265 --- /dev/null +++ b/eeschema/dialog_eeschema_config.h @@ -0,0 +1,135 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_eeschema_config.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 17/02/2006 21:14:46 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 17/02/2006 21:14:46 + +#ifndef _DIALOG_EESCHEMA_CONFIG_H_ +#define _DIALOG_EESCHEMA_CONFIG_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "dialog_eeschema_config.h" +#endif + +/*! + * Includes + */ + +////@begin includes +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_KICONFIGEESCHEMAFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_KICONFIGEESCHEMAFRAME_TITLE _("Dialog") +#define SYMBOL_KICONFIGEESCHEMAFRAME_IDNAME ID_DIALOG +#define SYMBOL_KICONFIGEESCHEMAFRAME_SIZE wxSize(400, 300) +#define SYMBOL_KICONFIGEESCHEMAFRAME_POSITION wxDefaultPosition +#define SAVE_CFG 10001 +#define FORMAT_NETLIST 10006 +#define DEL_LIB 10002 +#define ADD_LIB 10003 +#define INSERT_LIB 10004 +#define ID_LIST_LIBS 10005 +#define ID_TEXTCTRL 10007 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * KiConfigEeschemaFrame class declaration + */ + +class KiConfigEeschemaFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( KiConfigEeschemaFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + KiConfigEeschemaFrame( ); + KiConfigEeschemaFrame( WinEDA_SchematicFrame* parent, wxWindowID id = SYMBOL_KICONFIGEESCHEMAFRAME_IDNAME, const wxString& caption = SYMBOL_KICONFIGEESCHEMAFRAME_TITLE, const wxPoint& pos = SYMBOL_KICONFIGEESCHEMAFRAME_POSITION, const wxSize& size = SYMBOL_KICONFIGEESCHEMAFRAME_SIZE, long style = SYMBOL_KICONFIGEESCHEMAFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_KICONFIGEESCHEMAFRAME_IDNAME, const wxString& caption = SYMBOL_KICONFIGEESCHEMAFRAME_TITLE, const wxPoint& pos = SYMBOL_KICONFIGEESCHEMAFRAME_POSITION, const wxSize& size = SYMBOL_KICONFIGEESCHEMAFRAME_SIZE, long style = SYMBOL_KICONFIGEESCHEMAFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin KiConfigEeschemaFrame event handler declarations + + /// wxEVT_CLOSE_WINDOW event handler for ID_DIALOG + void OnCloseWindow( wxCloseEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for SAVE_CFG + void OnSaveCfgClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for FORMAT_NETLIST + void OnFormatNetlistSelected( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for DEL_LIB + void OnDelLibClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ADD_LIB + void OnAddLibClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for INSERT_LIB + void OnInsertLibClick( wxCommandEvent& event ); + +////@end KiConfigEeschemaFrame event handler declarations + +////@begin KiConfigEeschemaFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end KiConfigEeschemaFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void SetFormatsNetListes(void); + void LibDelFct(wxCommandEvent& event); + void AddOrInsertLibrary(wxCommandEvent& event); + void ChangeSetup(void); + +////@begin KiConfigEeschemaFrame member variables + wxRadioBox* m_NetFormatBox; + wxStaticBoxSizer* m_FileExtList; + wxListBox* m_ListLibr; + wxTextCtrl* m_LibDirCtrl; +////@end KiConfigEeschemaFrame member variables + + WinEDA_SchematicFrame * m_Parent; + bool m_LibListChanged; + +}; + +#endif + // _DIALOG_EESCHEMA_CONFIG_H_ diff --git a/eeschema/dialog_eeschema_config.pjd b/eeschema/dialog_eeschema_config.pjd new file mode 100644 index 0000000000..704adf8caf --- /dev/null +++ b/eeschema/dialog_eeschema_config.pjd @@ -0,0 +1,1076 @@ + + +
+ 0 + "" + "" + "" + "" + 28 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "Untitled" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "17/11/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "wxEVT_CLOSE_WINDOW|OnCloseWindow" + "ID_DIALOG" + 10000 + "KiConfigEeschemaFrame" + "wxDialog" + "wxDialog" + "dialog_eeschema_config.cpp" + "dialog_eeschema_config.h" + "" + "Dialog" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbBoxSizerProxy" + "Vertical" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: SAVE_CFG" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnSaveCfgClick" + "SAVE_CFG" + 10001 + "wxButton" + "" + "Save Cfg" + 0 + "" + "" + "" + "CC0000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "18/2/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxRadioBox: FORMAT_NETLIST" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "17/7/2006" + "wbRadioBoxProxy" + "wxEVT_COMMAND_RADIOBOX_SELECTED|OnFormatNetlistSelected" + "FORMAT_NETLIST" + 10006 + "wxRadioBox" + "m_NetFormatBox" + "NetList Formats:" + 1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + "PcbNew|&OrcadPcb2|&CadStar|&Spice|Other" + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "18/2/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + "Files ext:" + "m_FileExtList" + "" + "" + 0 + 1 + "Vertical" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: DEL_LIB" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnDelLibClick" + "DEL_LIB" + 10002 + "wxButton" + "" + "Del" + 0 + "" + "" + "" + "CC0000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: ADD_LIB" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnAddLibClick" + "ADD_LIB" + 10003 + "wxButton" + "" + "Add" + 0 + "" + "" + "" + "008000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: INSERT_LIB" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnInsertLibClick" + "INSERT_LIB" + 10004 + "wxButton" + "" + "Ins" + 0 + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Libraries" + "" + "" + "" + "CC0000" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 0 + 0 + 0 + 1 + 0 + "" + "" + + + "wxListBox: ID_LIST_LIBS" + "dialog-control-document" + "" + "listbox" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbListBoxProxy" + "ID_LIST_LIBS" + 10005 + "wxListBox" + "m_ListLibr" + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + 300 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + + + + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Library files path:" + "" + "" + "" + "CC0000" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Top" + 0 + 5 + 1 + 1 + 0 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "17/8/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL" + 10007 + "wxTextCtrl" + "m_LibDirCtrl" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "dialog_eeschema_config.rc" + "source-editor-document" + "dialog_eeschema_config.rc" + "source-editor" + 0 + 0 + 1 + 0 + "17/11/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/dialog_erc.cpp b/eeschema/dialog_erc.cpp new file mode 100644 index 0000000000..6fbcfed5af --- /dev/null +++ b/eeschema/dialog_erc.cpp @@ -0,0 +1,320 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_erc.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 12/02/2006 17:08:38 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 12/02/2006 17:08:38 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "dialog_erc.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes +#include "fctsys.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "netlist.h" + +#include "protos.h" + +#include "dialog_erc.h" + +////@begin XPM images +////@end XPM images + +/*! + * WinEDA_ErcFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_ErcFrame, wxDialog ) + +/*! + * WinEDA_ErcFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_ErcFrame, wxDialog ) + +////@begin WinEDA_ErcFrame event table entries + EVT_BUTTON( ID_ERC_CMP, WinEDA_ErcFrame::OnErcCmpClick ) + + EVT_BUTTON( ID_ERASE_DRC_MARKERS, WinEDA_ErcFrame::OnEraseDrcMarkersClick ) + + EVT_BUTTON( wxID_EXIT, WinEDA_ErcFrame::OnExitClick ) + + EVT_BUTTON( ID_RESET_MATRIX, WinEDA_ErcFrame::OnResetMatrixClick ) + +////@end WinEDA_ErcFrame event table entries + + EVT_COMMAND_RANGE(ID_MATRIX_0, + ID_MATRIX_0 + (PIN_NMAX * PIN_NMAX) - 1, + wxEVT_COMMAND_BUTTON_CLICKED, + WinEDA_ErcFrame::ChangeErrorLevel) + +END_EVENT_TABLE() + +/*! + * WinEDA_ErcFrame constructors + */ + +WinEDA_ErcFrame::WinEDA_ErcFrame( ) +{ +} + +WinEDA_ErcFrame::WinEDA_ErcFrame( WinEDA_SchematicFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +int ii, jj; + + m_Parent = parent; + m_Initialized = FALSE; + for( ii = 0; ii < PIN_NMAX; ii++ ) + for( jj = 0; jj < PIN_NMAX; jj++ ) + m_ButtonList[ii][jj] = NULL; + Create(parent, id, caption, pos, size, style); + + GetSizer()->SetSizeHints(this); + + wxString num; + num.Printf(wxT("%d"), g_EESchemaVar.NbErrorErc); + m_TotalErrCount->SetLabel(num); + + num.Printf(wxT("%d"), g_EESchemaVar.NbErrorErc-g_EESchemaVar.NbWarningErc); + m_LastErrCount->SetLabel(num); + + num.Printf(wxT("%d"), g_EESchemaVar.NbWarningErc); + m_LastWarningCount->SetLabel(num); + +} + +/*! + * WinEDA_ErcFrame creator + */ + +bool WinEDA_ErcFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_ErcFrame member initialisation + m_NoteBook = NULL; + m_PanelERC = NULL; + m_PanelERCSizer = NULL; + ErcTotalErrors = NULL; + WarnErcErrors = NULL; + ErcErrors = NULL; + m_TotalErrCount = NULL; + m_LastWarningCount = NULL; + m_LastErrCount = NULL; + m_WriteResultOpt = NULL; + m_PanelERCOptions = NULL; + m_PanelMatrixSizer = NULL; + m_ResetOptButton = NULL; + m_SeparatorLine = NULL; + m_MatrixSizer = NULL; +////@end WinEDA_ErcFrame member initialisation + +////@begin WinEDA_ErcFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + if (GetSizer()) + { + GetSizer()->SetSizeHints(this); + } + Centre(); +////@end WinEDA_ErcFrame creation + return true; +} + +/*! + * Control creation for WinEDA_ErcFrame + */ + +void WinEDA_ErcFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_ErcFrame content construction + // Generated by DialogBlocks, 19/11/2006 20:27:15 (unregistered) + + WinEDA_ErcFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + + m_NoteBook = new wxNotebook( itemDialog1, ID_ERC_NOTEBOOK, wxDefaultPosition, wxDefaultSize, wxNB_DEFAULT|wxNB_TOP ); + + m_PanelERC = new wxPanel( m_NoteBook, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); + m_PanelERCSizer = new wxBoxSizer(wxHORIZONTAL); + m_PanelERC->SetSizer(m_PanelERCSizer); + + wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxVERTICAL); + m_PanelERCSizer->Add(itemBoxSizer6, 0, wxGROW|wxALL, 5); + wxStaticBox* itemStaticBoxSizer7Static = new wxStaticBox(m_PanelERC, wxID_ANY, _("Erc File Report:")); + wxStaticBoxSizer* itemStaticBoxSizer7 = new wxStaticBoxSizer(itemStaticBoxSizer7Static, wxHORIZONTAL); + itemBoxSizer6->Add(itemStaticBoxSizer7, 0, wxALIGN_LEFT|wxALL, 5); + wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL); + itemStaticBoxSizer7->Add(itemBoxSizer8, 0, wxGROW|wxLEFT|wxTOP|wxBOTTOM, 5); + ErcTotalErrors = new wxStaticText( m_PanelERC, wxID_STATIC, _("-> Total Errors: "), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer8->Add(ErcTotalErrors, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5); + + WarnErcErrors = new wxStaticText( m_PanelERC, wxID_STATIC, _("-> Last Warnings: "), wxDefaultPosition, wxDefaultSize, 0 ); + WarnErcErrors->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer8->Add(WarnErcErrors, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5); + + ErcErrors = new wxStaticText( m_PanelERC, wxID_STATIC, _("-> Last Errors: "), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); + ErcErrors->SetForegroundColour(wxColour(202, 0, 0)); + itemBoxSizer8->Add(ErcErrors, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5); + + wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxVERTICAL); + itemStaticBoxSizer7->Add(itemBoxSizer12, 0, wxGROW|wxRIGHT|wxTOP|wxBOTTOM, 5); + m_TotalErrCount = new wxStaticText( m_PanelERC, wxID_STATIC, _("0000"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer12->Add(m_TotalErrCount, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5); + + m_LastWarningCount = new wxStaticText( m_PanelERC, wxID_STATIC, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); + m_LastWarningCount->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer12->Add(m_LastWarningCount, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5); + + m_LastErrCount = new wxStaticText( m_PanelERC, wxID_STATIC, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); + m_LastErrCount->SetForegroundColour(wxColour(202, 0, 0)); + itemBoxSizer12->Add(m_LastErrCount, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5); + + itemBoxSizer6->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer17Static = new wxStaticBox(m_PanelERC, wxID_ANY, _("Erc File Report:")); + wxStaticBoxSizer* itemStaticBoxSizer17 = new wxStaticBoxSizer(itemStaticBoxSizer17Static, wxHORIZONTAL); + itemBoxSizer6->Add(itemStaticBoxSizer17, 0, wxGROW|wxALL, 5); + m_WriteResultOpt = new wxCheckBox( m_PanelERC, ID_CHECKBOX, _("Write erc report"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_WriteResultOpt->SetValue(false); + itemStaticBoxSizer17->Add(m_WriteResultOpt, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer19 = new wxBoxSizer(wxVERTICAL); + m_PanelERCSizer->Add(itemBoxSizer19, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxButton* itemButton20 = new wxButton( m_PanelERC, ID_ERC_CMP, _("&Test Erc"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton20->SetForegroundColour(wxColour(198, 0, 0)); + itemBoxSizer19->Add(itemButton20, 0, wxGROW|wxALL, 5); + + wxButton* itemButton21 = new wxButton( m_PanelERC, ID_ERASE_DRC_MARKERS, _("&Del Markers"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer19->Add(itemButton21, 0, wxGROW|wxALL, 5); + + wxButton* itemButton22 = new wxButton( m_PanelERC, wxID_EXIT, _("&Quit"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton22->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer19->Add(itemButton22, 0, wxGROW|wxALL, 5); + + m_NoteBook->AddPage(m_PanelERC, _("erc")); + + m_PanelERCOptions = new wxPanel( m_NoteBook, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); + m_PanelMatrixSizer = new wxBoxSizer(wxVERTICAL); + m_PanelERCOptions->SetSizer(m_PanelMatrixSizer); + + m_ResetOptButton = new wxButton( m_PanelERCOptions, ID_RESET_MATRIX, _("Reset"), wxDefaultPosition, wxDefaultSize, 0 ); + m_PanelMatrixSizer->Add(m_ResetOptButton, 0, wxALIGN_LEFT|wxALL, 5); + + m_SeparatorLine = new wxStaticLine( m_PanelERCOptions, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + m_PanelMatrixSizer->Add(m_SeparatorLine, 0, wxGROW|wxALL, 5); + + m_MatrixSizer = new wxBoxSizer(wxVERTICAL); + m_PanelMatrixSizer->Add(m_MatrixSizer, 0, wxGROW|wxALL, 5); + + m_NoteBook->AddPage(m_PanelERCOptions, _("Options")); + + itemBoxSizer2->Add(m_NoteBook, 0, wxGROW|wxALL, 5); + + // Set validators + m_WriteResultOpt->SetValidator( wxGenericValidator(& WriteFichierERC) ); +////@end WinEDA_ErcFrame content construction + + // Init Panel Matrix + ReBuildMatrixPanel(); +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_ErcFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_ErcFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_ErcFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_ErcFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_ErcFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_ErcFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_ErcFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERASE_DRC_MARKERS + */ + +void WinEDA_ErcFrame::OnEraseDrcMarkersClick( wxCommandEvent& event ) +{ + DelERCMarkers(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_EXIT + */ + +void WinEDA_ErcFrame::OnExitClick( wxCommandEvent& event ) +{ + EndModal(0); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RESET_MATRIX + */ + +void WinEDA_ErcFrame::OnResetMatrixClick( wxCommandEvent& event ) +{ + ResetDefaultERCDiag(event); +} + + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERC_CMP + */ + +void WinEDA_ErcFrame::OnErcCmpClick( wxCommandEvent& event ) +{ + TestErc(event); +} + + diff --git a/eeschema/dialog_erc.h b/eeschema/dialog_erc.h new file mode 100644 index 0000000000..dfcea00056 --- /dev/null +++ b/eeschema/dialog_erc.h @@ -0,0 +1,152 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_erc.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 12/02/2006 17:08:38 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 12/02/2006 17:08:38 + +#ifndef _DIALOG_ERC_H_ +#define _DIALOG_ERC_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "dialog_erc.h" +#endif + +/*! + * Includes + */ + +////@begin includes +#include "wx/notebook.h" +#include "wx/valgen.h" +#include "wx/statline.h" +////@end includes + +/* Variable locales */ +extern int WriteFichierERC; +/*! + * Forward declarations + */ + +////@begin forward declarations +class wxNotebook; +class wxBoxSizer; +class wxStaticLine; +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define ID_ERC_NOTEBOOK 10001 +#define ID_PANEL 10004 +#define ID_CHECKBOX 10006 +#define ID_ERC_CMP 10002 +#define ID_ERASE_DRC_MARKERS 10003 +#define ID_PANEL1 10005 +#define ID_RESET_MATRIX 10007 +#define SYMBOL_WINEDA_ERCFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_ERCFRAME_TITLE _("EESchema Erc") +#define SYMBOL_WINEDA_ERCFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_ERCFRAME_SIZE wxDefaultSize +#define SYMBOL_WINEDA_ERCFRAME_POSITION wxDefaultPosition +////@end control identifiers +#define ID_MATRIX_0 1800 + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_ErcFrame class declaration + */ + +class WinEDA_ErcFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_ErcFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_ErcFrame( ); + WinEDA_ErcFrame( WinEDA_SchematicFrame* parent, wxWindowID id = SYMBOL_WINEDA_ERCFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_ERCFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_ERCFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_ERCFRAME_SIZE, long style = SYMBOL_WINEDA_ERCFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_ERCFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_ERCFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_ERCFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_ERCFRAME_SIZE, long style = SYMBOL_WINEDA_ERCFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_ErcFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERC_CMP + void OnErcCmpClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERASE_DRC_MARKERS + void OnEraseDrcMarkersClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_EXIT + void OnExitClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RESET_MATRIX + void OnResetMatrixClick( wxCommandEvent& event ); + +////@end WinEDA_ErcFrame event handler declarations + +////@begin WinEDA_ErcFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_ErcFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void DelERCMarkers(wxCommandEvent& event); + void TestErc(wxCommandEvent& event); + void SelLocal(wxCommandEvent& event); + void SelNewCmp(wxCommandEvent& event); + void ResetDefaultERCDiag(wxCommandEvent& event); + void ChangeErrorLevel(wxCommandEvent& event); + void ReBuildMatrixPanel(void); + +////@begin WinEDA_ErcFrame member variables + wxNotebook* m_NoteBook; + wxPanel* m_PanelERC; + wxBoxSizer* m_PanelERCSizer; + wxStaticText* ErcTotalErrors; + wxStaticText* WarnErcErrors; + wxStaticText* ErcErrors; + wxStaticText* m_TotalErrCount; + wxStaticText* m_LastWarningCount; + wxStaticText* m_LastErrCount; + wxCheckBox* m_WriteResultOpt; + wxPanel* m_PanelERCOptions; + wxBoxSizer* m_PanelMatrixSizer; + wxButton* m_ResetOptButton; + wxStaticLine* m_SeparatorLine; + wxBoxSizer* m_MatrixSizer; +////@end WinEDA_ErcFrame member variables + + WinEDA_SchematicFrame * m_Parent; + wxBitmapButton * m_ButtonList[PIN_NMAX][PIN_NMAX]; + bool m_Initialized; +}; + +#endif + // _DIALOG_ERC_H_ diff --git a/eeschema/dialog_erc.pjd b/eeschema/dialog_erc.pjd new file mode 100644 index 0000000000..dadfc068d3 --- /dev/null +++ b/eeschema/dialog_erc.pjd @@ -0,0 +1,1463 @@ + + +
+ 0 + "" + "" + "" + "" + 34 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 0 + 4 + " " + "" + 0 + 0 + 1 + 1 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "EESchema Erc" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "ID_DIALOG" + 10000 + "WinEDA_ErcFrame" + "wxDialog" + "wxDialog" + "dialog_erc.cpp" + "dialog_erc.h" + "" + "EESchema Erc" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + -1 + -1 + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Vertical" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxNotebook: ID_ERC_NOTEBOOK" + "dialog-control-document" + "" + "notebook" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbNotebookProxy" + "ID_ERC_NOTEBOOK" + 10001 + "wxNotebook" + "m_NoteBook" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + "wxPanel: ID_PANEL" + "dialog-control-document" + "" + "panel" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbPanelProxy" + "ID_PANEL" + 10004 + "wxPanel" + "wxPanel" + "m_PanelERC" + "erc" + "" + 0 + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + "" + 0 + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + "" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbBoxSizerProxy" + "Horizontal" + "m_PanelERCSizer" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + "Erc File Report:" + "" + "" + "" + 0 + 1 + "Horizontal" + "" + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "14/9/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "14/9/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "ErcTotalErrors" + "-> Total Errors: " + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "14/9/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "WarnErcErrors" + "-> Last Warnings: " + -1 + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "14/9/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "ErcErrors" + "-> Last Errors: " + -1 + "" + "" + "" + "CA0000" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + "" + "" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "14/9/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "14/9/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_TotalErrCount" + "0000" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "14/9/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_LastWarningCount" + "0" + -1 + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "14/9/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_LastErrCount" + "0" + -1 + "" + "" + "" + "CA0000" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + "" + "" + + + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "14/10/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxStaticBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "14/10/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + "Erc File Report:" + "" + "" + "" + 0 + 1 + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxCheckBox: ID_CHECKBOX" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "14/10/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX" + 10006 + "wxCheckBox" + "m_WriteResultOpt" + "Write erc report" + 0 + "" + "" + "WriteFichierERC" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: ID_ERC_CMP" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnErcCmpClick" + "ID_ERC_CMP" + 10002 + "wxButton" + "" + "&Test Erc" + 0 + "" + "" + "" + "C60000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: ID_ERASE_DRC_MARKERS" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnEraseDrcMarkersClick" + "ID_ERASE_DRC_MARKERS" + 10003 + "wxButton" + "" + "&Del Markers" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_EXIT" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnExitClick" + "wxID_EXIT" + 5006 + "wxButton" + "" + "&Quit" + 0 + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + "wxPanel: ID_PANEL1" + "dialog-control-document" + "" + "panel" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbPanelProxy" + "ID_PANEL1" + 10005 + "wxPanel" + "wxPanel" + "m_PanelERCOptions" + "Options" + "" + 0 + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + "" + 0 + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbBoxSizerProxy" + "Vertical" + "m_PanelMatrixSizer" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: ID_RESET_MATRIX" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "12/3/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnResetMatrixClick" + "ID_RESET_MATRIX" + 10007 + "wxButton" + "m_ResetOptButton" + "Reset" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticLine: wxID_STATIC" + "dialog-control-document" + "" + "staticline" + 0 + 1 + 0 + 0 + "14/10/2006" + "wbStaticLineProxy" + "wxID_STATIC" + 5105 + "wxStaticLine" + "m_SeparatorLine" + "" + "" + "" + 0 + 1 + "<Any platform>" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "14/4/2006" + "wbBoxSizerProxy" + "Vertical" + "m_MatrixSizer" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "dialog_erc.rc" + "source-editor-document" + "dialog_erc.rc" + "source-editor" + 0 + 0 + 1 + 0 + "12/3/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/dialog_erc.rc b/eeschema/dialog_erc.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/eeschema/dialog_erc.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/eeschema/dialog_find.cpp b/eeschema/dialog_find.cpp new file mode 100644 index 0000000000..2b060a5d3a --- /dev/null +++ b/eeschema/dialog_find.cpp @@ -0,0 +1,238 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_find.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 16/02/2006 20:18:11 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 16/02/2006 20:18:11 + + +////@begin includes +////@end includes + +#include "dialog_find.h" + +////@begin XPM images +////@end XPM images + +/*! + * WinEDA_FindFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_FindFrame, wxDialog ) + +/*! + * WinEDA_FindFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_FindFrame, wxDialog ) + +////@begin WinEDA_FindFrame event table entries + EVT_BUTTON( FIND_SHEET, WinEDA_FindFrame::OnFindSheetClick ) + + EVT_BUTTON( FIND_HIERARCHY, WinEDA_FindFrame::OnFindHierarchyClick ) + + EVT_BUTTON( FIND_NEXT, WinEDA_FindFrame::OnFindNextClick ) + + EVT_BUTTON( FIND_MARKERS, WinEDA_FindFrame::OnFindMarkersClick ) + + EVT_BUTTON( FIND_NEXT_MARKER, WinEDA_FindFrame::OnFindNextMarkerClick ) + + EVT_BUTTON( LOCATE_IN_LIBRARIES, WinEDA_FindFrame::OnLocateInLibrariesClick ) + +////@end WinEDA_FindFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_FindFrame constructors + */ + +WinEDA_FindFrame::WinEDA_FindFrame( ) +{ +} + +WinEDA_FindFrame::WinEDA_FindFrame( WinEDA_SchematicFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + Create(parent, id, caption, pos, size, style); +} + +/*! + * WinEDA_FindFrame creator + */ + +bool WinEDA_FindFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_FindFrame member initialisation + m_NewTextCtrl = NULL; +////@end WinEDA_FindFrame member initialisation + +////@begin WinEDA_FindFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_FindFrame creation + return true; +} + +/*! + * Control creation for WinEDA_FindFrame + */ + +void WinEDA_FindFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_FindFrame content construction + // Generated by DialogBlocks, 03/03/2006 08:14:51 (unregistered) + + WinEDA_FindFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxLEFT|wxRIGHT, 5); + + wxStaticText* itemStaticText4 = new wxStaticText( itemDialog1, wxID_STATIC, _("Item to find:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(itemStaticText4, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_NewTextCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(m_NewTextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer2->Add(itemBoxSizer6, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer6->Add(itemBoxSizer7, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); + + wxButton* itemButton8 = new wxButton( itemDialog1, FIND_SHEET, _("Item in &Sheet"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer7->Add(itemButton8, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 1); + + wxButton* itemButton9 = new wxButton( itemDialog1, FIND_HIERARCHY, _("Item in &Hierarchy"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer7->Add(itemButton9, 0, wxGROW|wxLEFT|wxRIGHT, 1); + + wxButton* itemButton10 = new wxButton( itemDialog1, FIND_NEXT, _("Find &Next Item (F5)"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer7->Add(itemButton10, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 1); + + wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer6->Add(itemBoxSizer11, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxFIXED_MINSIZE, 5); + + wxButton* itemButton12 = new wxButton( itemDialog1, FIND_MARKERS, _("Find Markers"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton12->SetForegroundColour(wxColour(41, 84, 84)); + itemBoxSizer11->Add(itemButton12, 0, wxGROW|wxLEFT|wxRIGHT, 1); + + wxButton* itemButton13 = new wxButton( itemDialog1, FIND_NEXT_MARKER, _("Next Marker (F5)"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton13->SetForegroundColour(wxColour(0, 0, 213)); + itemBoxSizer11->Add(itemButton13, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 1); + + wxButton* itemButton14 = new wxButton( itemDialog1, LOCATE_IN_LIBRARIES, _("Find Cmp in &Lib"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton14->SetForegroundColour(wxColour(170, 0, 0)); + itemBoxSizer11->Add(itemButton14, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 1); + + // Set validators + m_NewTextCtrl->SetValidator( wxTextValidator(wxFILTER_NONE, & s_OldStringFound) ); +////@end WinEDA_FindFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_FindFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_FindFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_FindFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_FindFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_FindFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_FindFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_FindFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON + */ + +void WinEDA_FindFrame::OnFindSheetClick( wxCommandEvent& event ) +{ + FindSchematicItem(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1 + */ + +void WinEDA_FindFrame::OnFindHierarchyClick( wxCommandEvent& event ) +{ + FindSchematicItem(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON3 + */ + +void WinEDA_FindFrame::OnLocateInLibrariesClick( wxCommandEvent& event ) +{ + LocatePartInLibs(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON5 + */ + +void WinEDA_FindFrame::OnFindNextMarkerClick( wxCommandEvent& event ) +{ + FindMarker(event); +} + + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for FIND_MARKERS + */ + +void WinEDA_FindFrame::OnFindMarkersClick( wxCommandEvent& event ) +{ + FindMarker(event); +} + + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for FIND_NEXT + */ + +void WinEDA_FindFrame::OnFindNextClick( wxCommandEvent& event ) +{ + FindSchematicItem(event); +} + + diff --git a/eeschema/dialog_find.h b/eeschema/dialog_find.h new file mode 100644 index 0000000000..23e3d07401 --- /dev/null +++ b/eeschema/dialog_find.h @@ -0,0 +1,126 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_find.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 16/02/2006 20:18:11 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 16/02/2006 20:18:11 + +#ifndef _DIALOG_FIND_H_ +#define _DIALOG_FIND_H_ + +/*! + * Includes + */ + +////@begin includes +#include "wx/valtext.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_FINDFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_FINDFRAME_TITLE _("EESchema Locate") +#define SYMBOL_WINEDA_FINDFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_FINDFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_FINDFRAME_POSITION wxDefaultPosition +#define ID_TEXTCTRL1 10008 +#define FIND_SHEET 10001 +#define FIND_HIERARCHY 10002 +#define FIND_NEXT 10005 +#define FIND_MARKERS 10003 +#define FIND_NEXT_MARKER 10006 +#define LOCATE_IN_LIBRARIES 10004 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_FindFrame class declaration + */ + +class WinEDA_FindFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_FindFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_FindFrame( ); + WinEDA_FindFrame( WinEDA_SchematicFrame* parent, wxWindowID id = SYMBOL_WINEDA_FINDFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_FINDFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_FINDFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_FINDFRAME_SIZE, long style = SYMBOL_WINEDA_FINDFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_FINDFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_FINDFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_FINDFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_FINDFRAME_SIZE, long style = SYMBOL_WINEDA_FINDFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_FindFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for FIND_SHEET + void OnFindSheetClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for FIND_HIERARCHY + void OnFindHierarchyClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for FIND_NEXT + void OnFindNextClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for FIND_MARKERS + void OnFindMarkersClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for FIND_NEXT_MARKER + void OnFindNextMarkerClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for LOCATE_IN_LIBRARIES + void OnLocateInLibrariesClick( wxCommandEvent& event ); + +////@end WinEDA_FindFrame event handler declarations + +////@begin WinEDA_FindFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_FindFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void FindSchematicItem(wxCommandEvent& event); + void FindMarker(wxCommandEvent& event); + void LocatePartInLibs(wxCommandEvent& event); + int ExploreAllLibraries(const wxString & wildmask, wxString & FindList); + +////@begin WinEDA_FindFrame member variables + wxTextCtrl* m_NewTextCtrl; +////@end WinEDA_FindFrame member variables + WinEDA_SchematicFrame * m_Parent; +}; + +#endif + // _DIALOG_FIND_H_ diff --git a/eeschema/dialog_find.pjd b/eeschema/dialog_find.pjd new file mode 100644 index 0000000000..0805ac311a --- /dev/null +++ b/eeschema/dialog_find.pjd @@ -0,0 +1,847 @@ + + +
+ 0 + "" + "" + "" + "" + 21 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "EESchema Locate" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "16/11/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "ID_DIALOG" + 10000 + "WinEDA_FindFrame" + "wxDialog" + "wxDialog" + "dialog_find.cpp" + "dialog_find.h" + "" + "EESchema Locate" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Vertical" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "16/11/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Expand" + "Expand" + 0 + 5 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "16/11/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Item to find:" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Top" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL1" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "16/11/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL1" + 10008 + "wxTextCtrl" + "m_NewTextCtrl" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "s_OldStringFound" + "wxTextValidator(wxFILTER_NONE, & %VARIABLE%)" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "16/11/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "16/11/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: FIND_SHEET" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "16/11/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnFindSheetClick" + "FIND_SHEET" + 10001 + "wxButton" + "" + "Item in &Sheet" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + + + "wxButton: FIND_HIERARCHY" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "16/11/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnFindHierarchyClick" + "FIND_HIERARCHY" + 10002 + "wxButton" + "" + "Item in &Hierarchy" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "" + "" + + + "wxButton: FIND_NEXT" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "3/3/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnFindNextClick" + "FIND_NEXT" + 10005 + "wxButton" + "" + "Find &Next Item (F5)" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 1 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "16/11/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 0 + 1 + "<Any platform>" + + "wxButton: FIND_MARKERS" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "16/11/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnFindMarkersClick" + "FIND_MARKERS" + 10003 + "wxButton" + "" + "Find Markers" + 0 + "" + "" + "" + "295454" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + "" + "" + + + "wxButton: FIND_NEXT_MARKER" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "3/3/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnFindNextMarkerClick" + "FIND_NEXT_MARKER" + 10006 + "wxButton" + "" + "Next Marker (F5)" + 0 + "" + "" + "" + "0000D5" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + "" + "" + + + "wxButton: LOCATE_IN_LIBRARIES" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "16/11/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnLocateInLibrariesClick" + "LOCATE_IN_LIBRARIES" + 10004 + "wxButton" + "" + "Find Cmp in &Lib" + 0 + "" + "" + "" + "AA0000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 1 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "dialog_find.rc" + "source-editor-document" + "dialog_find.rc" + "source-editor" + 0 + 0 + 1 + 0 + "16/11/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/dialog_find.rc b/eeschema/dialog_find.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/eeschema/dialog_find.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/eeschema/dialog_options.cpp b/eeschema/dialog_options.cpp new file mode 100644 index 0000000000..6c5af3a8f0 --- /dev/null +++ b/eeschema/dialog_options.cpp @@ -0,0 +1,416 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dilaog_options.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 31/01/2006 13:27:33 +// RCS-ID: +// Copyright: GNU Licence +// Licence: GNU +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 31/01/2006 13:27:33 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "dilaog_options.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "id.h" + +#include "protos.h" + +////@begin includes +////@end includes + +#include "dialog_options.h" + +////@begin XPM images +////@end XPM images + + + +/**************************************************************************/ +void DisplayOptionFrame(WinEDA_DrawFrame * parent, const wxPoint & framepos) +/**************************************************************************/ +{ + WinEDA_SetOptionsFrame * frame = + new WinEDA_SetOptionsFrame(parent); + frame->ShowModal(); frame->Destroy(); +} + + +/*! + * WinEDA_SetOptionsFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_SetOptionsFrame, wxDialog ) + +/*! + * WinEDA_SetOptionsFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_SetOptionsFrame, wxDialog ) + +////@begin WinEDA_SetOptionsFrame event table entries + EVT_BUTTON( wxID_OK, WinEDA_SetOptionsFrame::OnOkClick ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_SetOptionsFrame::OnCancelClick ) + +////@end WinEDA_SetOptionsFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_SetOptionsFrame constructors + */ + +WinEDA_SetOptionsFrame::WinEDA_SetOptionsFrame( ) +{ +} + +WinEDA_SetOptionsFrame::WinEDA_SetOptionsFrame( WinEDA_DrawFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + Create(parent, id, caption, pos, size, style); + + /* Init options */ + if ( m_Parent->GetScreen() ) + { + switch( m_Parent->GetScreen()->GetGrid().x ) + { + case 50: + m_SelGridSize->SetSelection(0); + break; + + case 25: + m_SelGridSize->SetSelection(1); + break; + + case 10: + m_SelGridSize->SetSelection(2); + break; + + case 5: + m_SelGridSize->SetSelection(3); + break; + + case 2: + m_SelGridSize->SetSelection(4); + break; + + case 1: + m_SelGridSize->SetSelection(5); + break; + + default: + DisplayError(this, wxT("WinEDA_SetOptionsFrame: Grid value not handle")); + break; + } + } + + /* Adjust the current selections and options: */ + m_ShowGridOpt->SetValue(m_Parent->m_Draw_Grid); + m_AutoPANOpt->SetValue(m_Parent->DrawPanel-> m_AutoPAN_Enable); + m_SelShowPins->SetSelection( g_ShowAllPins ? TRUE : FALSE); + m_Selunits->SetSelection( g_UnitMetric ? 0 : 1); + m_SelDirWires->SetSelection( g_HVLines ? 0 : 1); + m_Show_Page_Limits->SetSelection( g_ShowPageLimits ? 0 : 1); +wxString msg; + msg = ReturnStringFromValue( g_UnitMetric,g_RepeatStep.x, m_Parent->m_InternalUnits); + m_DeltaStepCtrl_X->SetValue( msg ); +wxString title = _("Delta Step X") + ReturnUnitSymbol(g_UnitMetric); + m_DeltaStepXTitle->SetLabel( title ); + + msg = ReturnStringFromValue( g_UnitMetric,g_RepeatStep.y, m_Parent->m_InternalUnits); + m_DeltaStepCtrl_Y->SetValue( msg ); + title = _("Delta Step Y") + ReturnUnitSymbol(g_UnitMetric); + m_DeltaStepYTitle->SetLabel( title ); + + m_DeltaLabelCtrl->SetValue( g_RepeatDeltaLabel ); + +} + +/*! + * WinEDA_SetOptionsFrame creator + */ + +bool WinEDA_SetOptionsFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_SetOptionsFrame member initialisation + m_ShowGridOpt = NULL; + m_SelGridSize = NULL; + m_SelShowPins = NULL; + m_AutoPANOpt = NULL; + m_Selunits = NULL; + m_SelDirWires = NULL; + m_Show_Page_Limits = NULL; + m_DeltaStepXTitle = NULL; + m_DeltaStepCtrl_X = NULL; + m_DeltaStepYTitle = NULL; + m_DeltaStepCtrl_Y = NULL; + m_DeltaIncTitle = NULL; + m_DeltaLabelCtrl = NULL; +////@end WinEDA_SetOptionsFrame member initialisation + +////@begin WinEDA_SetOptionsFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + if (GetSizer()) + { + GetSizer()->SetSizeHints(this); + } + Centre(); +////@end WinEDA_SetOptionsFrame creation + return true; +} + +/*! + * Control creation for WinEDA_SetOptionsFrame + */ + +void WinEDA_SetOptionsFrame::CreateControls() +{ + SetFont(*g_DialogFont); +////@begin WinEDA_SetOptionsFrame content construction + // Generated by DialogBlocks, 26/08/2006 18:23:26 (unregistered) + + WinEDA_SetOptionsFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + m_ShowGridOpt = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Show grid"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_ShowGridOpt->SetValue(false); + itemBoxSizer3->Add(m_ShowGridOpt, 0, wxALIGN_LEFT|wxALL, 5); + + wxString m_SelGridSizeStrings[] = { + _("Normal (50 mils)"), + _("Small (25 mils)"), + _("Very small (10 mils)"), + _("Special (5 mils)"), + _("Special (2 mils)"), + _("Special (1 mil)") + }; + m_SelGridSize = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Grid Size"), wxDefaultPosition, wxDefaultSize, 6, m_SelGridSizeStrings, 1, wxRA_SPECIFY_COLS ); + m_SelGridSize->SetSelection(0); + itemBoxSizer3->Add(m_SelGridSize, 0, wxGROW|wxALL, 5); + + wxString m_SelShowPinsStrings[] = { + _("Normal"), + _("Show alls") + }; + m_SelShowPins = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Show pins"), wxDefaultPosition, wxDefaultSize, 2, m_SelShowPinsStrings, 1, wxRA_SPECIFY_COLS ); + m_SelShowPins->SetSelection(0); + itemBoxSizer3->Add(m_SelShowPins, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + m_AutoPANOpt = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Auto PAN"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_AutoPANOpt->SetValue(false); + m_AutoPANOpt->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer7->Add(m_AutoPANOpt, 0, wxGROW|wxALL, 5); + + wxString m_SelunitsStrings[] = { + _("millimeter"), + _("inches") + }; + m_Selunits = new wxRadioBox( itemDialog1, ID_RADIOBOX2, _("Units"), wxDefaultPosition, wxDefaultSize, 2, m_SelunitsStrings, 1, wxRA_SPECIFY_COLS ); + m_Selunits->SetSelection(0); + itemBoxSizer7->Add(m_Selunits, 0, wxGROW|wxALL, 5); + + wxString m_SelDirWiresStrings[] = { + _("Horiz/Vertical"), + _("Any") + }; + m_SelDirWires = new wxRadioBox( itemDialog1, ID_RADIOBOX3, _("Wires - Bus orient"), wxDefaultPosition, wxDefaultSize, 2, m_SelDirWiresStrings, 1, wxRA_SPECIFY_COLS ); + m_SelDirWires->SetSelection(0); + itemBoxSizer7->Add(m_SelDirWires, 0, wxGROW|wxALL, 5); + + wxString m_Show_Page_LimitsStrings[] = { + _("Yes"), + _("No") + }; + m_Show_Page_Limits = new wxRadioBox( itemDialog1, ID_RADIOBOX4, _("Show page limits"), wxDefaultPosition, wxDefaultSize, 2, m_Show_Page_LimitsStrings, 1, wxRA_SPECIFY_COLS ); + m_Show_Page_Limits->SetSelection(0); + itemBoxSizer7->Add(m_Show_Page_Limits, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton13 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton13->SetForegroundColour(wxColour(202, 0, 0)); + itemBoxSizer12->Add(itemButton13, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxButton* itemButton14 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton14->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer12->Add(itemButton14, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer15Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Auto increment params")); + wxStaticBoxSizer* itemStaticBoxSizer15 = new wxStaticBoxSizer(itemStaticBoxSizer15Static, wxVERTICAL); + itemBoxSizer12->Add(itemStaticBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + m_DeltaStepXTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Delta Step X"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer15->Add(m_DeltaStepXTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_DeltaStepCtrl_X = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer15->Add(m_DeltaStepCtrl_X, 0, wxGROW|wxALL, 5); + + m_DeltaStepYTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Delta Step Y"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer15->Add(m_DeltaStepYTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_DeltaStepCtrl_Y = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer15->Add(m_DeltaStepCtrl_Y, 0, wxGROW|wxALL, 5); + + m_DeltaIncTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Delta Label:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer15->Add(m_DeltaIncTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_DeltaLabelCtrl = new wxSpinCtrl( itemDialog1, ID_SPINCTRL, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -16, 16, 0 ); + itemStaticBoxSizer15->Add(m_DeltaLabelCtrl, 0, wxGROW|wxALL, 5); + +////@end WinEDA_SetOptionsFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_SetOptionsFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_SetOptionsFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_SetOptionsFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_SetOptionsFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_SetOptionsFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_SetOptionsFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_SetOptionsFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_SetOptionsFrame::OnOkClick( wxCommandEvent& event ) +{ + Accept(event); +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK in WinEDA_SetOptionsFrame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK in WinEDA_SetOptionsFrame. +} + + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_SetOptionsFrame::OnCancelClick( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_SetOptionsFrame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_SetOptionsFrame. +} + + +/**************************************************************************/ +void WinEDA_SetOptionsFrame::Accept(wxCommandEvent& event) +/**************************************************************************/ +{ +wxSize grid; +bool setgrid = TRUE; +wxString msg; + + msg = m_DeltaStepCtrl_X->GetValue(); + g_RepeatStep.x = + ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits); + msg = m_DeltaStepCtrl_Y->GetValue(); + g_RepeatStep.y = + ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits); + + g_RepeatDeltaLabel = m_DeltaLabelCtrl->GetValue(); + + if ( m_Show_Page_Limits->GetSelection() == 0 ) g_ShowPageLimits = TRUE; + else g_ShowPageLimits = FALSE; + + if ( m_SelDirWires->GetSelection() == 0 ) g_HVLines = 1; + else g_HVLines = 0; + + if ( m_Selunits->GetSelection() == 0 ) g_UnitMetric = 1; + else g_UnitMetric = 0; + + if ( m_SelShowPins->GetSelection() == 0 ) g_ShowAllPins = FALSE; + else g_ShowAllPins = TRUE; + + g_ShowGrid = m_Parent->m_Draw_Grid = m_ShowGridOpt->GetValue(); + m_Parent->DrawPanel->m_AutoPAN_Enable = m_AutoPANOpt->GetValue(); + + m_Parent->m_Draw_Grid = m_ShowGridOpt->GetValue(); + switch( m_SelGridSize->GetSelection() ) + { + default: + setgrid = FALSE; + break; + + case 0: + grid = wxSize(50,50); + break; + case 1: + grid = wxSize(25,25); + break; + + case 2: + grid = wxSize(10,10); + break; + } + + if ( m_Parent->m_CurrentScreen ) + { + if ( setgrid ) m_Parent->m_CurrentScreen->SetGrid(grid); + m_Parent->m_CurrentScreen->SetRefreshReq(); + } +} + diff --git a/eeschema/dialog_options.h b/eeschema/dialog_options.h new file mode 100644 index 0000000000..c9cf47f7ca --- /dev/null +++ b/eeschema/dialog_options.h @@ -0,0 +1,132 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dilaog_options.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 31/01/2006 13:27:33 +// RCS-ID: +// Copyright: GNU License +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 31/01/2006 13:27:33 + +#ifndef _DILAOG_OPTIONS_H_ +#define _DILAOG_OPTIONS_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "dilaog_options.h" +#endif + +/*! + * Includes + */ + +////@begin includes +#include "wx/spinctrl.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +class wxSpinCtrl; +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_SETOPTIONSFRAME_STYLE wxDEFAULT_DIALOG_STYLE|wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxSTAY_ON_TOP|wxCLOSE_BOX +#define SYMBOL_WINEDA_SETOPTIONSFRAME_TITLE _("General Options") +#define SYMBOL_WINEDA_SETOPTIONSFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_SETOPTIONSFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_SETOPTIONSFRAME_POSITION wxDefaultPosition +#define ID_CHECKBOX1 10001 +#define ID_RADIOBOX 10003 +#define ID_RADIOBOX1 10004 +#define ID_CHECKBOX 10002 +#define ID_RADIOBOX2 10005 +#define ID_RADIOBOX3 10006 +#define ID_RADIOBOX4 10007 +#define ID_TEXTCTRL 10008 +#define ID_TEXTCTRL1 10009 +#define ID_SPINCTRL 10010 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_SetOptionsFrame class declaration + */ + +class WinEDA_SetOptionsFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_SetOptionsFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_SetOptionsFrame( ); + WinEDA_SetOptionsFrame( WinEDA_DrawFrame* parent, wxWindowID id = SYMBOL_WINEDA_SETOPTIONSFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_SETOPTIONSFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_SETOPTIONSFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_SETOPTIONSFRAME_SIZE, long style = SYMBOL_WINEDA_SETOPTIONSFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_SETOPTIONSFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_SETOPTIONSFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_SETOPTIONSFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_SETOPTIONSFRAME_SIZE, long style = SYMBOL_WINEDA_SETOPTIONSFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_SetOptionsFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + +////@end WinEDA_SetOptionsFrame event handler declarations + +////@begin WinEDA_SetOptionsFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_SetOptionsFrame member function declarations + + void Accept(wxCommandEvent& event); + + /// Should we show tooltips? + static bool ShowToolTips(); + + WinEDA_DrawFrame * m_Parent; + +////@begin WinEDA_SetOptionsFrame member variables + wxCheckBox* m_ShowGridOpt; + wxRadioBox* m_SelGridSize; + wxRadioBox* m_SelShowPins; + wxCheckBox* m_AutoPANOpt; + wxRadioBox* m_Selunits; + wxRadioBox* m_SelDirWires; + wxRadioBox* m_Show_Page_Limits; + wxStaticText* m_DeltaStepXTitle; + wxTextCtrl* m_DeltaStepCtrl_X; + wxStaticText* m_DeltaStepYTitle; + wxTextCtrl* m_DeltaStepCtrl_Y; + wxStaticText* m_DeltaIncTitle; + wxSpinCtrl* m_DeltaLabelCtrl; +////@end WinEDA_SetOptionsFrame member variables +}; + +#endif + // _DILAOG_OPTIONS_H_ diff --git a/eeschema/dialog_options.pjd b/eeschema/dialog_options.pjd new file mode 100644 index 0000000000..b3fc668d31 --- /dev/null +++ b/eeschema/dialog_options.pjd @@ -0,0 +1,1262 @@ + + +
+ 0 + "" + "" + "" + "" + 28 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "GNU License" + "" + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 0 + 4 + "" + 0 + 0 + 1 + 1 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "WinEDA_SetOptionsFrame" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "wbDialogProxy" + 10000 + 0 + "" + 0 + "ID_DIALOG" + 10000 + "WinEDA_SetOptionsFrame" + "wxDialog" + "wxDialog" + "dialog_options.cpp" + "dialog_options.h" + "" + "General Options" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Horizontal" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxCheckBox: ID_CHECKBOX1" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "wbCheckBoxProxy" + "ID_CHECKBOX1" + 10001 + "wxCheckBox" + "m_ShowGridOpt" + "Show grid" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxRadioBox: ID_RADIOBOX" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "wbRadioBoxProxy" + "ID_RADIOBOX" + 10003 + "wxRadioBox" + "m_SelGridSize" + "Grid Size" + 1 + "Normal (50 mils)|Small (25 mils)|Very small (10 mils)|Special (5 mils)|Special (2 mils)|Special (1 mil)" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxRadioBox: ID_RADIOBOX1" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "wbRadioBoxProxy" + "ID_RADIOBOX1" + 10004 + "wxRadioBox" + "m_SelShowPins" + "Show pins" + 1 + "Normal|Show alls" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxCheckBox: ID_CHECKBOX" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "wbCheckBoxProxy" + "ID_CHECKBOX" + 10002 + "wxCheckBox" + "m_AutoPANOpt" + "Auto PAN" + 0 + "" + "" + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxRadioBox: ID_RADIOBOX2" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "wbRadioBoxProxy" + "ID_RADIOBOX2" + 10005 + "wxRadioBox" + "m_Selunits" + "Units" + 1 + "millimeter|inches" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxRadioBox: ID_RADIOBOX3" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "wbRadioBoxProxy" + "ID_RADIOBOX3" + 10006 + "wxRadioBox" + "m_SelDirWires" + "Wires - Bus orient" + 1 + "Horiz/Vertical|Any" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxRadioBox: ID_RADIOBOX4" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "wbRadioBoxProxy" + "ID_RADIOBOX4" + 10007 + "wxRadioBox" + "m_Show_Page_Limits" + "Show page limits" + 1 + "Yes|No" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: wxID_OK" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnOkClick" + "wxID_OK" + 5100 + "wxButton" + "" + "&OK" + 0 + "" + "" + "" + "CA0000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_CANCEL" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCancelClick" + "wxID_CANCEL" + 5101 + "wxButton" + "" + "&Cancel" + 0 + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbStaticBoxSizerProxy" + "wxID_ANY" + "-1" + "Auto increment params" + "" + "" + "" + 0 + 1 + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_DeltaStepXTitle" + "Delta Step X" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "wbTextCtrlProxy" + "ID_TEXTCTRL" + 10008 + "wxTextCtrl" + "m_DeltaStepCtrl_X" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_DeltaStepYTitle" + "Delta Step Y" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL1" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "wbTextCtrlProxy" + "ID_TEXTCTRL1" + 10009 + "wxTextCtrl" + "m_DeltaStepCtrl_Y" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "26/8/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_DeltaIncTitle" + "Delta Label:" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxSpinCtrl: ID_SPINCTRL" + "dialog-control-document" + "" + "spinctrl" + 0 + 1 + 0 + 0 + "wbSpinCtrlProxy" + "ID_SPINCTRL" + 10010 + "wxSpinCtrl" + "m_DeltaLabelCtrl" + -16 + 16 + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "dialog_options.rc" + "source-editor-document" + "dialog_options.rc" + "source-editor" + 0 + 0 + 1 + 0 + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/dialog_options.rc b/eeschema/dialog_options.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/eeschema/dialog_options.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/eeschema/dialog_set_status.cpp b/eeschema/dialog_set_status.cpp new file mode 100644 index 0000000000..235cc6cd16 --- /dev/null +++ b/eeschema/dialog_set_status.cpp @@ -0,0 +1,282 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_set_status.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 11/02/2006 21:42:23 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 11/02/2006 21:42:23 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "dialog_set_status.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes + +#include "dialog_set_status.h" + +////@begin XPM images +////@end XPM images + +/*! + * WinEDA_ConfigFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_ConfigFrame, wxDialog ) + +/*! + * WinEDA_ConfigFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_ConfigFrame, wxDialog ) + +////@begin WinEDA_ConfigFrame event table entries + EVT_BUTTON( ID_BUTTON, WinEDA_ConfigFrame::OnButtonClick ) + + EVT_BUTTON( ID_BUTTON1, WinEDA_ConfigFrame::OnButton1Click ) + + EVT_BUTTON( ID_BUTTON2, WinEDA_ConfigFrame::OnButton2Click ) + + EVT_BUTTON( ID_BUTTON3, WinEDA_ConfigFrame::OnButton3Click ) + +////@end WinEDA_ConfigFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_ConfigFrame constructors + */ + +WinEDA_ConfigFrame::WinEDA_ConfigFrame( ) +{ +} + +WinEDA_ConfigFrame::WinEDA_ConfigFrame( WinEDA_SchematicFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + m_LibListChanged = FALSE; + + msg = _("from ") + EDA_Appl->m_CurrentOptionFile; + SetTitle(msg); + Create(parent, id, caption, pos, size, style); +} + +/*! + * WinEDA_ConfigFrame creator + */ + +bool WinEDA_ConfigFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_ConfigFrame member initialisation + m_CmpfileExtText = NULL; + m_NetfileExtText = NULL; + m_LibfileExtText = NULL; + m_SymbolfileExtText = NULL; + m_SchfileExtText = NULL; + m_ListLibr = NULL; + m_CmpfileExtText = NULL; + m_LibDirCtrl = NULL; +////@end WinEDA_ConfigFrame member initialisation + +////@begin WinEDA_ConfigFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_ConfigFrame creation + return true; +} + +/*! + * Control creation for WinEDA_ConfigFrame + */ + +void WinEDA_ConfigFrame::CreateControls() +{ + SetFont(*g_DialogFont); +////@begin WinEDA_ConfigFrame content construction + // Generated by DialogBlocks, 11/02/2006 22:06:21 (unregistered) + + WinEDA_ConfigFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, 0, 0); + + wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton5 = new wxButton( itemDialog1, ID_BUTTON, _("Save Cfg"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton5->SetForegroundColour(wxColour(204, 0, 0)); + itemBoxSizer4->Add(itemButton5, 0, wxGROW|wxALL, 5); + + wxString itemRadioBox6Strings[] = { + _("&PcbNew"), + _("&OrcadPcb2"), + _("&CadStar"), + _("&Spice"), + _("Other") + }; + wxRadioBox* itemRadioBox6 = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("NetList Formats:"), wxDefaultPosition, wxDefaultSize, 5, itemRadioBox6Strings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer4->Add(itemRadioBox6, 0, wxGROW|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer7Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Files ext:")); + wxStaticBoxSizer* itemStaticBoxSizer7 = new wxStaticBoxSizer(itemStaticBoxSizer7Static, wxVERTICAL); + itemBoxSizer4->Add(itemStaticBoxSizer7, 0, wxGROW|wxALL, 5); + + m_CmpfileExtText = new wxStaticText( itemDialog1, wxID_STATIC, _("Cmp file Ext: "), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer7->Add(m_CmpfileExtText, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5); + + m_NetfileExtText = new wxStaticText( itemDialog1, wxID_STATIC, _("Net file Ext: "), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer7->Add(m_NetfileExtText, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5); + + m_LibfileExtText = new wxStaticText( itemDialog1, wxID_STATIC, _("Library file Ext: "), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer7->Add(m_LibfileExtText, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5); + + m_SymbolfileExtText = new wxStaticText( itemDialog1, wxID_STATIC, _("Symbol file Ext: "), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer7->Add(m_SymbolfileExtText, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5); + + m_SchfileExtText = new wxStaticText( itemDialog1, wxID_STATIC, _("Schematic file Ext: "), wxDefaultPosition, wxDefaultSize, 0 ); + m_SchfileExtText->Enable(false); + itemStaticBoxSizer7->Add(m_SchfileExtText, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5); + + wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer13, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer13->Add(itemBoxSizer14, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxButton* itemButton15 = new wxButton( itemDialog1, ID_BUTTON1, _("Del"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton15->SetForegroundColour(wxColour(204, 0, 0)); + itemBoxSizer14->Add(itemButton15, 0, wxGROW|wxALL, 5); + + wxButton* itemButton16 = new wxButton( itemDialog1, ID_BUTTON2, _("Add"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton16->SetForegroundColour(wxColour(0, 128, 0)); + itemBoxSizer14->Add(itemButton16, 0, wxGROW|wxALL, 5); + + wxButton* itemButton17 = new wxButton( itemDialog1, ID_BUTTON3, _("Ins"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton17->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer14->Add(itemButton17, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxStaticText* itemStaticText18 = new wxStaticText( itemDialog1, wxID_STATIC, _("Libraries:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticText18->SetForegroundColour(wxColour(196, 0, 0)); + itemBoxSizer13->Add(itemStaticText18, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + wxString* m_ListLibrStrings = NULL; + m_ListLibr = new wxListBox( itemDialog1, ID_LISTBOX, wxDefaultPosition, wxSize(-1, 250), 0, m_ListLibrStrings, wxLB_SINGLE ); + itemBoxSizer13->Add(m_ListLibr, 0, wxGROW|wxALL, 5); + + m_CmpfileExtText = new wxStaticText( itemDialog1, wxID_STATIC, _("Library files path:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_CmpfileExtText->SetForegroundColour(wxColour(198, 0, 0)); + itemBoxSizer2->Add(m_CmpfileExtText, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_LibDirCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add(m_LibDirCtrl, 0, wxGROW|wxALL, 5); + +////@end WinEDA_ConfigFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_ConfigFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_ConfigFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_ConfigFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_ConfigFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_ConfigFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_ConfigFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_ConfigFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON + */ + +void WinEDA_ConfigFrame::OnButtonClick( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON in WinEDA_ConfigFrame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON in WinEDA_ConfigFrame. +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1 + */ + +void WinEDA_ConfigFrame::OnButton1Click( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1 in WinEDA_ConfigFrame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1 in WinEDA_ConfigFrame. +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON2 + */ + +void WinEDA_ConfigFrame::OnButton2Click( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON2 in WinEDA_ConfigFrame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON2 in WinEDA_ConfigFrame. +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON3 + */ + +void WinEDA_ConfigFrame::OnButton3Click( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON3 in WinEDA_ConfigFrame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON3 in WinEDA_ConfigFrame. +} + + diff --git a/eeschema/dialog_set_status.h b/eeschema/dialog_set_status.h new file mode 100644 index 0000000000..456afd09ce --- /dev/null +++ b/eeschema/dialog_set_status.h @@ -0,0 +1,124 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_set_status.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 11/02/2006 21:42:23 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 11/02/2006 21:42:23 + +#ifndef _DIALOG_SET_STATUS_H_ +#define _DIALOG_SET_STATUS_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "dialog_set_status.h" +#endif + +/*! + * Includes + */ + +////@begin includes +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_CONFIGFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_CONFIGFRAME_TITLE _("from ") +#define SYMBOL_WINEDA_CONFIGFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_CONFIGFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_CONFIGFRAME_POSITION wxDefaultPosition +#define ID_BUTTON 10001 +#define ID_RADIOBOX 10006 +#define ID_BUTTON1 10002 +#define ID_BUTTON2 10003 +#define ID_BUTTON3 10004 +#define ID_LISTBOX 10005 +#define ID_TEXTCTRL 10007 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_ConfigFrame class declaration + */ + +class WinEDA_ConfigFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_ConfigFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_ConfigFrame( ); + WinEDA_ConfigFrame( WinEDA_SchematicFrame* parent, wxWindowID id = SYMBOL_WINEDA_CONFIGFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_CONFIGFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_CONFIGFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_CONFIGFRAME_SIZE, long style = SYMBOL_WINEDA_CONFIGFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_CONFIGFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_CONFIGFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_CONFIGFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_CONFIGFRAME_SIZE, long style = SYMBOL_WINEDA_CONFIGFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_ConfigFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON + void OnButtonClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1 + void OnButton1Click( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON2 + void OnButton2Click( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON3 + void OnButton3Click( wxCommandEvent& event ); + +////@end WinEDA_ConfigFrame event handler declarations + +////@begin WinEDA_ConfigFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_ConfigFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + +////@begin WinEDA_ConfigFrame member variables + wxStaticText* m_CmpfileExtText; + wxStaticText* m_NetfileExtText; + wxStaticText* m_LibfileExtText; + wxStaticText* m_SymbolfileExtText; + wxStaticText* m_SchfileExtText; + wxListBox* m_ListLibr; + wxStaticText* m_CmpfileExtText; + wxTextCtrl* m_LibDirCtrl; +////@end WinEDA_ConfigFrame member variables +}; + +#endif + // _DIALOG_SET_STATUS_H_ diff --git a/eeschema/dialog_set_status.pjd b/eeschema/dialog_set_status.pjd new file mode 100644 index 0000000000..0273da75e9 --- /dev/null +++ b/eeschema/dialog_set_status.pjd @@ -0,0 +1,1175 @@ + + +
+ 0 + "" + "" + "" + "" + 28 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "from " + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "ID_DIALOG" + 10000 + "WinEDA_ConfigFrame" + "wxDialog" + "wxDialog" + "dialog_set_status.cpp" + "dialog_set_status.h" + "" + "from " + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbBoxSizerProxy" + "Vertical" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: ID_BUTTON" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnButtonClick" + "ID_BUTTON" + 10001 + "wxButton" + "" + "Save Cfg" + 0 + "" + "" + "" + "CC0000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxRadioBox: ID_RADIOBOX" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX" + 10006 + "wxRadioBox" + "" + "NetList Formats:" + 1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + "&PcbNew|&OrcadPcb2|&CadStar|&Spice|Other" + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + "Files ext:" + "" + "" + "" + 0 + 0 + "Vertical" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_CmpfileExtText" + "Cmp file Ext: " + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_NetfileExtText" + "Net file Ext: " + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_LibfileExtText" + "Library file Ext: " + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_SymbolfileExtText" + "Symbol file Ext: " + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_SchfileExtText" + "Schematic file Ext: " + "" + "" + "" + "" + "" + 0 + 0 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + "" + "" + + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: ID_BUTTON1" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnButton1Click" + "ID_BUTTON1" + 10002 + "wxButton" + "" + "Del" + 0 + "" + "" + "" + "CC0000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: ID_BUTTON2" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnButton2Click" + "ID_BUTTON2" + 10003 + "wxButton" + "" + "Add" + 0 + "" + "" + "" + "008000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: ID_BUTTON3" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnButton3Click" + "ID_BUTTON3" + 10004 + "wxButton" + "" + "Ins" + 0 + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Libraries:" + "" + "" + "" + "C40000" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxListBox: ID_LISTBOX" + "dialog-control-document" + "" + "listbox" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbListBoxProxy" + "ID_LISTBOX" + 10005 + "wxListBox" + "m_ListLibr" + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + 250 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_CmpfileExtText" + "Library files path:" + "" + "" + "" + "C60000" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "11/2/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL" + 10007 + "wxTextCtrl" + "m_LibDirCtrl" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "dialog_set_status.rc" + "source-editor-document" + "dialog_set_status.rc" + "source-editor" + 0 + 0 + 1 + 0 + "11/2/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/dialog_set_status.rc b/eeschema/dialog_set_status.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/eeschema/dialog_set_status.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/eeschema/divers.cpp b/eeschema/divers.cpp new file mode 100644 index 0000000000..64093cb29d --- /dev/null +++ b/eeschema/divers.cpp @@ -0,0 +1,52 @@ +/************************************************/ +/* Routines diverses */ +/************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" + +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + + +/**********************************************************/ +SCH_SCREEN * CreateNewScreen(WinEDA_DrawFrame * frame_source, + SCH_SCREEN * OldScreen, int TimeStamp) +/**********************************************************/ +/* Routine de creation ( par allocation memoire ) d'un nouvel ecran + cet ecran est en chainage arriere avec OldScreen + la valeur TimeStamp est attribuee au parametre NewScreen->TimeStamp +*/ +{ +SCH_SCREEN * NewScreen; + + NewScreen = new SCH_SCREEN(NULL, frame_source, SCHEMATIC_FRAME); + + NewScreen->SetRefreshReq(); + if(OldScreen) NewScreen->m_Company = OldScreen->m_Company; + NewScreen->m_TimeStamp = TimeStamp; + + NewScreen->Pback = OldScreen; + + return(NewScreen); +} + +/**************************************/ +void SetFlagModify(BASE_SCREEN * Window) +/**************************************/ +/* Mise a 1 du flag modified de l'ecran Window, et de la date de la feuille +*/ +{ + if( Window == NULL ) return; + Window->SetModify(); + + /* Mise a jour des dates */ + Window->m_Date = GenDate(); +} + + diff --git a/eeschema/edit_component_in_lib.cpp b/eeschema/edit_component_in_lib.cpp new file mode 100644 index 0000000000..ab698e5650 --- /dev/null +++ b/eeschema/edit_component_in_lib.cpp @@ -0,0 +1,1103 @@ +/**************************************************************/ +/* librairy editor: edition of component general properties */ +/**************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +enum id_libedit { + ID_PANEL_ALIAS, + ID_PANEL_FIELD, + ID_COPY_DOC_TO_ALIAS, + ID_BROWSE_DOC_FILES, + ID_ADD_ALIAS, + ID_DELETE_ONE_ALIAS, + ID_DELETE_ALL_ALIAS, + ID_ON_SELECT_FIELD +}; + + + +/* Routines locales */ + +/* Variables locales */ +extern int CurrentUnit; + +/* Classe de la frame des propriétés d'un composant en librairie */ + +/* Cette classe genere une fenetre type NoteBook, pour l'edition des propriétés +d'un composant le librairie. + On peut éditer: + Texte dimensions et justification de tous les champs (Ref, Val, et autres champs) + Documentation et mots clefs + Nombre de part par boitier + et autres propriérés générales +*/ + +#include "dialog_edit_component_in_lib.cpp" + + +/*****************************************************************/ +void WinEDA_LibeditFrame::InstallLibeditFrame(const wxPoint & pos) +/*****************************************************************/ +{ +wxPoint fpos = pos; + + WinEDA_PartPropertiesFrame * frame = + new WinEDA_PartPropertiesFrame(this); + int IsModified = frame->ShowModal(); frame->Destroy(); + if ( IsModified ) Refresh(); + +} + +/***************************************************************************/ +void WinEDA_PartPropertiesFrame::CopyFieldDataToBuffer(LibDrawField * Field) +/***************************************************************************/ +/* copy the field data (name, attributes, size, position... to corresponding buffers +for editing +*/ +{ +int id = Field->m_FieldId; + + m_FieldFlags[id] = (Field->m_Attributs & TEXT_NO_VISIBLE) ? 0 : 1; + m_FieldOrient[id] = Field->m_Orient; + + if ( Field->m_HJustify == GR_TEXT_HJUSTIFY_LEFT) + m_FieldHJustify[id] = 0; + else if ( Field->m_HJustify == GR_TEXT_HJUSTIFY_RIGHT) + m_FieldHJustify[id] = 2; + else + m_FieldHJustify[id] = 1; + + if ( Field->m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM) + m_FieldVJustify[id] = 0; + else if ( Field->m_VJustify == GR_TEXT_VJUSTIFY_TOP) + m_FieldVJustify[id] = 2; + else m_FieldVJustify[id] = 1; + + m_FieldText[id] = Field->m_Text; + if ( id >= FIELD1 ) m_FieldName[id] = Field->m_Name; + m_FieldPosition[id] = Field->m_Pos; + // Note: the Y axis for components in lib is from bottom to top + // and the screen axis is top to bottom: we must change the y coord sign for editing + m_FieldPosition[id].y = - m_FieldPosition[id].y; + m_FieldSize[id] = Field->m_Size.x; +} + + +/***************************************************************************/ +void WinEDA_PartPropertiesFrame::CopyBufferToFieldData(LibDrawField * Field) +/***************************************************************************/ +/* Copy data from buffers(name, attributes, size, position... )to the +field "Field" +*/ +{ +int hjustify[3] = { GR_TEXT_HJUSTIFY_LEFT , GR_TEXT_HJUSTIFY_CENTER, + GR_TEXT_HJUSTIFY_RIGHT }; +int vjustify[3] = { GR_TEXT_VJUSTIFY_BOTTOM , GR_TEXT_VJUSTIFY_CENTER, + GR_TEXT_VJUSTIFY_TOP }; +int ii = Field->m_FieldId; + + Field->m_Text = m_FieldText[ii]; + + if ( ii >= FIELD1 && m_FieldName[ii] != ReturnDefaultFieldName(ii) ) + Field->m_Name = m_FieldName[ii]; + else Field->m_Name.Empty(); + + Field->m_Size.x = Field->m_Size.y = m_FieldSize[ii]; + Field->m_HJustify = hjustify[m_FieldHJustify[ii]]; + Field->m_VJustify = vjustify[m_FieldVJustify[ii]]; + if ( m_FieldFlags[ii] ) + Field->m_Attributs &= ~TEXT_NO_VISIBLE; + else + Field->m_Attributs |= TEXT_NO_VISIBLE; + Field->m_Orient = m_FieldOrient[ii] ? 1 : 0; + Field->m_Pos = m_FieldPosition[ii]; + // Note: the Y axis for components in lib is from bottom to top + // and the screen axis is top to bottom: we must change the y coord sign after editing + Field->m_Pos.y = - Field->m_Pos.y; +} + +/*****************************************************/ +void WinEDA_PartPropertiesFrame::InitBuffers(void) +/*****************************************************/ +/* Init the buffers to a default value, + or to values from CurrentLibEntry if CurrentLibEntry != NULL +*/ +{ +int ii; + + m_CurrentFieldId = REFERENCE; + + for ( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) + { + if ( ii < FIELD1 ) + m_FieldName[ii] = ReturnDefaultFieldName(ii); + m_FieldFlags[ii] = 1; + m_FieldOrient[ii] = 0; + m_FieldSize[ii] = DEFAULT_TEXT_SIZE; + m_FieldHJustify[ii] = 1; + m_FieldVJustify[ii] = 1; + } + + m_AliasLocation = -1; + if ( CurrentLibEntry == NULL ) + { + m_Title = _("Lib Component Properties"); + return; + } + + wxString msg_text = _("Properties for "); + if ( ! CurrentAliasName.IsEmpty() ) + { + m_AliasLocation = LocateAlias( CurrentLibEntry->m_AliasList, CurrentAliasName); + m_Title = msg_text + CurrentAliasName + + _("(alias of ") + + wxString(CurrentLibEntry->m_Name.m_Text) + + wxT(")"); + } + else + { + m_Title = msg_text + CurrentLibEntry->m_Name.m_Text; + CurrentAliasName.Empty(); + } + + CopyFieldDataToBuffer(& CurrentLibEntry->m_Prefix); + CopyFieldDataToBuffer(& CurrentLibEntry->m_Name); + + LibDrawField * Field = CurrentLibEntry->Fields; + while ( Field ) + { + CopyFieldDataToBuffer(Field); + Field = (LibDrawField*)Field->Pnext; + } +} + + +/*****************************************************/ +void WinEDA_PartPropertiesFrame::BuildPanelAlias(void) +/*****************************************************/ +/* create the panel for component alias list editing +*/ +{ +wxButton * Button; + + m_PanelAlias->SetFont(*g_DialogFont); + wxBoxSizer * PanelAliasBoxSizer = new wxBoxSizer(wxHORIZONTAL); + m_PanelAlias->SetSizer(PanelAliasBoxSizer); + wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + PanelAliasBoxSizer->Add(LeftBoxSizer, 0 , wxGROW|wxALL, 5); + + wxStaticText * Msg = new wxStaticText(m_PanelAlias, -1, _("Alias")); + Msg->SetForegroundColour(wxColour(200,0,0) ); + LeftBoxSizer->Add(Msg, 0 , wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); + + m_PartAliasList = new wxListBox(m_PanelAlias, + -1, + wxDefaultPosition, wxSize(200,250), + 0,NULL, + wxLB_ALWAYS_SB|wxLB_SINGLE); + LeftBoxSizer->Add(m_PartAliasList, 0 , wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); + PanelAliasBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + Button = new wxButton(m_PanelAlias, ID_ADD_ALIAS, _("Add")); + Button->SetForegroundColour(*wxBLUE); + RightBoxSizer->Add(Button, 0 , wxGROW|wxALL, 5); + + m_ButtonDeleteOneAlias = new wxButton(m_PanelAlias, ID_DELETE_ONE_ALIAS, + _("Delete")); + m_ButtonDeleteOneAlias->SetForegroundColour(*wxRED); + RightBoxSizer->Add(m_ButtonDeleteOneAlias, 0 , wxGROW|wxALL, 5); + + m_ButtonDeleteAllAlias = new wxButton(m_PanelAlias, ID_DELETE_ALL_ALIAS, + _("Delete All")); + m_ButtonDeleteAllAlias->SetForegroundColour(*wxRED); + if ( ! CurrentAliasName.IsEmpty() ) m_ButtonDeleteAllAlias->Enable(FALSE); + RightBoxSizer->Add(m_ButtonDeleteAllAlias, 0 , wxGROW|wxALL, 5); + + + /* lecture des noms des alias */ + if ( CurrentLibEntry ) + { + for ( unsigned ii = 0; ii < CurrentLibEntry->m_AliasList.GetCount(); ii += ALIAS_NEXT) + m_PartAliasList->Append(CurrentLibEntry->m_AliasList[ii+ALIAS_NAME]); + } + + if ( (CurrentLibEntry == NULL) || (CurrentLibEntry->m_AliasList.GetCount() == 0) ) + { + m_ButtonDeleteAllAlias->Enable(FALSE); + m_ButtonDeleteOneAlias->Enable(FALSE); + } +} + + +/*****************************************************************/ +void WinEDA_PartPropertiesFrame::BuildPanelFootprintFilter(void) +/*****************************************************************/ +/* create the panel for footprint filtering in cvpcb list +*/ +{ + + m_PanelFootprintFilter = new wxPanel( m_NoteBook, -1, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); + m_NoteBook->AddPage(m_PanelFootprintFilter, _("Footprint Filter")); + + m_PanelFootprintFilter->SetFont(*g_DialogFont); + +wxBoxSizer * PanelFpFilterBoxSizer = new wxBoxSizer(wxHORIZONTAL); + m_PanelFootprintFilter->SetSizer(PanelFpFilterBoxSizer); + wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + PanelFpFilterBoxSizer->Add(LeftBoxSizer, 0 , wxGROW|wxALL, 5); + + wxStaticText * Msg = new wxStaticText(m_PanelFootprintFilter, -1, _("Footprints")); + Msg->SetForegroundColour(wxColour(200,0,0) ); + LeftBoxSizer->Add(Msg, 0 , wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); + + m_FootprintFilterListBox = new wxListBox(m_PanelFootprintFilter, + -1, + wxDefaultPosition, wxSize(200,250), + 0,NULL, + wxLB_ALWAYS_SB|wxLB_SINGLE); + LeftBoxSizer->Add(m_FootprintFilterListBox, 0 , wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); + PanelFpFilterBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton * Button = new wxButton(m_PanelFootprintFilter, ID_ADD_FOOTPRINT_FILTER, _("Add")); + Button->SetForegroundColour(*wxBLUE); + RightBoxSizer->Add(Button, 0 , wxGROW|wxALL, 5); + + m_ButtonDeleteOneFootprintFilter = new wxButton(m_PanelFootprintFilter, ID_DELETE_ONE_FOOTPRINT_FILTER, + _("Delete")); + m_ButtonDeleteOneFootprintFilter->SetForegroundColour(*wxRED); + RightBoxSizer->Add(m_ButtonDeleteOneFootprintFilter, 0 , wxGROW|wxALL, 5); + + m_ButtonDeleteAllFootprintFilter = new wxButton(m_PanelFootprintFilter, ID_DELETE_ALL_FOOTPRINT_FILTER, + _("Delete All")); + m_ButtonDeleteAllFootprintFilter->SetForegroundColour(*wxRED); + RightBoxSizer->Add(m_ButtonDeleteAllFootprintFilter, 0 , wxGROW|wxALL, 5); + + + /* Read the Footprint Filter list */ + if ( CurrentLibEntry ) + { + for ( unsigned ii = 0; ii < CurrentLibEntry->m_FootprintList.GetCount(); ii ++) + m_FootprintFilterListBox->Append(CurrentLibEntry->m_FootprintList[ii]); + } + + if ( (CurrentLibEntry == NULL) || (CurrentLibEntry->m_FootprintList.GetCount() == 0) ) + { + m_ButtonDeleteAllFootprintFilter->Enable(FALSE); + m_ButtonDeleteOneFootprintFilter->Enable(FALSE); + } +} + + + +/*****************************************************/ +void WinEDA_PartPropertiesFrame::BuildPanelDoc(void) +/*****************************************************/ +/* create the panel for component doc editing +*/ +{ +wxString msg_text; + + if ( m_AliasLocation >= 0 ) + msg_text = CurrentLibEntry->m_AliasList[m_AliasLocation+ALIAS_DOC]; + else + { + if (CurrentLibEntry && CurrentLibEntry->m_Doc) + msg_text = CurrentLibEntry->m_Doc; + } + m_Doc->SetValue( msg_text ); + + msg_text.Empty(); + if ( m_AliasLocation >= 0 ) + msg_text = CurrentLibEntry->m_AliasList[m_AliasLocation+ALIAS_KEYWORD]; + else + { + if (CurrentLibEntry ) msg_text = CurrentLibEntry->m_KeyWord; + } + m_Keywords->SetValue(msg_text); + + msg_text.Empty(); + if ( m_AliasLocation >= 0 ) + msg_text = CurrentLibEntry->m_AliasList[m_AliasLocation+ALIAS_DOC_FILENAME]; + else + { + if (CurrentLibEntry) msg_text = CurrentLibEntry->m_DocFile; + } + m_Docfile->SetValue( msg_text ); + + if ( m_AliasLocation < 0 ) m_ButtonCopyDoc->Enable(FALSE); + +} + + +/*****************************************************/ +void WinEDA_PartPropertiesFrame::BuildPanelBasic(void) +/*****************************************************/ +/* create the basic panel for component properties editing +*/ +{ + m_PanelBasic->SetFont(*g_DialogFont); + + AsConvertButt = new wxCheckBox(m_PanelBasic,-1, _("As Convert")); + if ( g_AsDeMorgan ) AsConvertButt->SetValue(TRUE); + m_OptionsBoxSizer->Add(AsConvertButt, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + ShowPinNumButt = new wxCheckBox(m_PanelBasic,-1, _("Show Pin Num")); + if ( CurrentLibEntry ) + { + if ( CurrentLibEntry->m_DrawPinNum ) ShowPinNumButt->SetValue(TRUE); + } + else ShowPinNumButt->SetValue(TRUE); + m_OptionsBoxSizer->Add(ShowPinNumButt, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + ShowPinNameButt = new wxCheckBox(m_PanelBasic,-1, _("Show Pin Name")); + if ( CurrentLibEntry ) + { + if( CurrentLibEntry->m_DrawPinName ) ShowPinNameButt->SetValue(TRUE); + } + else ShowPinNameButt->SetValue(TRUE); + m_OptionsBoxSizer->Add(ShowPinNameButt, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_PinsNameInsideButt = new wxCheckBox(m_PanelBasic,-1, _("Pin Name Inside")); + if ( CurrentLibEntry ) + { + if ( CurrentLibEntry->m_TextInside ) m_PinsNameInsideButt->SetValue(TRUE); + } + else m_PinsNameInsideButt->SetValue(TRUE); + m_OptionsBoxSizer->Add(m_PinsNameInsideButt, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + int number, number_of_units; + if ( CurrentLibEntry ) number_of_units = CurrentLibEntry->m_UnitCount; + else number_of_units = 1; + SelNumberOfUnits->SetValue(number_of_units); + + if ( CurrentLibEntry && CurrentLibEntry->m_TextInside) + number = CurrentLibEntry->m_TextInside; + else number = 40; + m_SetSkew->SetValue( number ); + + if ( CurrentLibEntry ) + { + if( CurrentLibEntry->m_Options == ENTRY_POWER ) + m_OptionPower->SetValue(TRUE); + } + + if ( CurrentLibEntry ) + { + if( CurrentLibEntry->m_UnitSelectionLocked ) + m_OptionPartsLocked->SetValue(TRUE); + } +} + +/*********************************************************/ +void WinEDA_PartPropertiesFrame::BuildPanelEditField(void) +/**********************************************************/ +/* Create and build the panel managing the fields (REF, VALUE ...) + of the component +*/ +{ +wxString Hjustify_list[] = + { _("Left justify"),_("Center"),_("Right justify")}; +wxString Vjustify_list[] = + { _("Bottom justify"),_("Center"),_("Top justify")}; +int FieldId = m_CurrentFieldId; + + m_PanelField = new wxPanel(m_NoteBook, ID_PANEL_FIELD); + m_PanelField->SetFont(*g_DialogFont); + m_NoteBook->AddPage(m_PanelField, _("Fields"), FALSE); + + wxBoxSizer * PanelFieldBoxSizer = new wxBoxSizer(wxHORIZONTAL); + m_PanelField->SetSizer(PanelFieldBoxSizer); + wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + PanelFieldBoxSizer->Add(LeftBoxSizer, 0 , wxGROW|wxALL, 5); + wxBoxSizer * MiddleBoxSizer = new wxBoxSizer(wxVERTICAL); + PanelFieldBoxSizer->Add(MiddleBoxSizer, 0 , wxGROW|wxALL, 5); + + m_ShowFieldTextCtrl = new wxCheckBox(m_PanelField,-1, + _("Show Text") ); + LeftBoxSizer->Add(m_ShowFieldTextCtrl, 0 , wxGROW|wxALL, 5); + + m_VorientFieldTextCtrl = new wxCheckBox(m_PanelField,-1, + _("Vertical")); + LeftBoxSizer->Add(m_VorientFieldTextCtrl, 0 , wxGROW|wxALL, 5); + + // Create the box for field name display or edition + m_FieldNameCtrl = new WinEDA_EnterText( m_PanelField, + _("Field Name:"), m_FieldName[FieldId], + LeftBoxSizer, wxSize( 200, -1) ); + if ( FieldId < FIELD1 ) m_FieldNameCtrl->Enable(FALSE ); + else m_FieldNameCtrl->Enable( TRUE ); + + // Create the box for text editing (text, size) + m_FieldTextCtrl = new WinEDA_GraphicTextCtrl( m_PanelField, + _("Value:"), + m_FieldText[FieldId], m_FieldSize[FieldId], + g_UnitMetric, LeftBoxSizer, 200); + + // Create the box for text editing (position) + m_FieldPositionCtrl = new WinEDA_PositionCtrl( m_PanelField, + _("Pos"), m_FieldPosition[FieldId], + g_UnitMetric , LeftBoxSizer); + + + m_FieldHJustifyCtrl = new wxRadioBox(m_PanelField,-1, + _("Hor Justify"), wxDefaultPosition, wxDefaultSize, + 3,Hjustify_list, 1 , wxRA_SPECIFY_COLS); + m_FieldHJustifyCtrl->SetSelection(1); + MiddleBoxSizer->Add(m_FieldHJustifyCtrl, 0 , wxGROW|wxALL, 5); + + m_FieldVJustifyCtrl = new wxRadioBox(m_PanelField,-1, + _("Vert Justify"), wxDefaultPosition, wxDefaultSize, + 3,Vjustify_list, 1 , wxRA_SPECIFY_COLS); + m_FieldVJustifyCtrl->SetSelection(1); + MiddleBoxSizer->Add(m_FieldVJustifyCtrl, 0 , wxGROW|wxALL, 5); + + // Create the field list +wxString fieldnamelist[NUMBER_OF_FIELDS]; + for ( int ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) + { + if ( m_FieldName[ii].IsEmpty() ) + fieldnamelist[ii] = ReturnDefaultFieldName(ii); + else fieldnamelist[ii] = m_FieldName[ii]; + } + + m_FieldSelection = new wxRadioBox(m_PanelField, ID_ON_SELECT_FIELD, + _("Field to edit"), wxDefaultPosition, wxDefaultSize, + NUMBER_OF_FIELDS, fieldnamelist, 2 , wxRA_SPECIFY_COLS); + PanelFieldBoxSizer->Add(m_FieldSelection, 0 , wxGROW|wxALL, 5); + + CopyDataToPanelField(); + +} + +/****************************************************************/ +void WinEDA_PartPropertiesFrame::CopyDataToPanelField(void) +/****************************************************************/ +/* Set the values displayed on the panel field according to + the current field number +*/ +{ +int FieldId = m_CurrentFieldId; + + for ( int ii = FIELD1; ii < NUMBER_OF_FIELDS; ii++ ) + { + if ( ! m_FieldName[ii].IsEmpty() ) + m_FieldSelection->SetString(ii, m_FieldName[ii]); + else m_FieldSelection->SetString(ii, ReturnDefaultFieldName(ii)); + } + + if ( m_FieldFlags[FieldId] ) + m_ShowFieldTextCtrl->SetValue(TRUE); + else m_ShowFieldTextCtrl->SetValue(FALSE); + + if ( m_FieldOrient[FieldId] ) m_VorientFieldTextCtrl->SetValue(TRUE); + else m_VorientFieldTextCtrl->SetValue(FALSE); + + m_FieldHJustifyCtrl->SetSelection(m_FieldHJustify[FieldId]); + + m_FieldVJustifyCtrl->SetSelection(m_FieldVJustify[FieldId]); + + m_FieldPositionCtrl->SetValue(m_FieldPosition[FieldId].x, m_FieldPosition[FieldId].y ); + + m_FieldNameCtrl->SetValue(m_FieldName[FieldId]); + if ( FieldId < FIELD1 ) m_FieldNameCtrl->Enable(FALSE ); + else m_FieldNameCtrl->Enable( TRUE ); + m_FieldTextCtrl->SetValue(m_FieldText[FieldId]); // display new text field + m_FieldTextCtrl->SetValue(m_FieldSize[FieldId]); // display new size field + +} + +/****************************************************************/ +void WinEDA_PartPropertiesFrame::CopyPanelFieldToData(void) +/****************************************************************/ +/* Copy the values displayed on the panel field to the buffers according to + the current field number +*/ +{ +int id = m_CurrentFieldId; + + m_FieldFlags[id] = m_ShowFieldTextCtrl->GetValue(); + m_FieldOrient[id] = m_VorientFieldTextCtrl->GetValue(); + m_FieldHJustify[id] = m_FieldHJustifyCtrl->GetSelection(); + m_FieldVJustify[id] = m_FieldVJustifyCtrl->GetSelection(); + m_FieldText[id] = m_FieldTextCtrl->GetText(); + m_FieldName[id] = m_FieldNameCtrl->GetValue(); + m_FieldPosition[id] = m_FieldPositionCtrl->GetValue(); + m_FieldSize[id] = m_FieldTextCtrl->GetTextSize(); +} + + +/********************************************************************/ +void WinEDA_PartPropertiesFrame::SelectNewField(wxCommandEvent& event) +/********************************************************************/ +/* called when changing the current field selected + Save the current field settings in buffer and display the new one +*/ +{ + CopyPanelFieldToData(); + m_CurrentFieldId = m_FieldSelection->GetSelection(); + CopyDataToPanelField(); +} + +/**************************************************************************/ +void WinEDA_PartPropertiesFrame::PartPropertiesAccept(wxCommandEvent& event) +/**************************************************************************/ +/* Updaye the current component parameters +*/ +{ +int ii, jj; + + if( CurrentLibEntry == NULL ) + { + Close(); return; + } + + m_Parent->m_CurrentScreen->SetModify(); + m_Parent->SaveCopyInUndoList(CurrentLibEntry); + + CopyPanelFieldToData(); + + /* A new name could be entered in VALUE field. + Must not be an existing alias name in alias list box */ + jj = m_PartAliasList->GetCount(); + wxString newvalue = m_FieldText[VALUE]; + for ( ii = 0; ii < jj; ii++ ) + { + if( newvalue.CmpNoCase(m_PartAliasList->GetString(ii).GetData()) == 0 ) + { + wxString msg; + msg.Printf( wxT("Alias %s exists!"), newvalue.GetData()); + DisplayError(this, msg); + return; + } + } + + /* Update the doc, keyword and doc filename strings */ + if ( m_AliasLocation < 0 ) + { + CurrentLibEntry->m_Doc = m_Doc->GetValue(); + CurrentLibEntry->m_KeyWord = m_Keywords->GetValue(); + CurrentLibEntry->m_DocFile = m_Docfile->GetValue(); + } + + else + { + CurrentLibEntry->m_AliasList[m_AliasLocation+ALIAS_DOC] = m_Doc->GetValue(); + CurrentLibEntry->m_AliasList[m_AliasLocation+ALIAS_KEYWORD] = m_Keywords->GetValue(); + CurrentLibEntry->m_AliasList[m_AliasLocation+ALIAS_DOC_FILENAME] = m_Docfile->GetValue(); + } + + /* Update the alias list */ + /* 1 - Add names: test for a not existing name in old alias list: */ + jj = m_PartAliasList->GetCount(); + for ( ii = 0; ii < jj; ii++ ) + { + if ( LocateAlias( CurrentLibEntry->m_AliasList, m_PartAliasList->GetString(ii)) < 0 ) + { // new alias must be created + CurrentLibEntry->m_AliasList.Add(m_PartAliasList->GetString(ii)); + CurrentLibEntry->m_AliasList.Add(wxEmptyString); // Add a void doc string + CurrentLibEntry->m_AliasList.Add(wxEmptyString); // Add a void keyword list string + CurrentLibEntry->m_AliasList.Add(wxEmptyString); // Add a void doc filename string + } + } + + /* 2 - Remove delete names: test for an non existing name in new alias list: */ + int kk, kkmax = CurrentLibEntry->m_AliasList.GetCount(); + for ( kk = 0; kk < kkmax; ) + { + jj = m_PartAliasList->GetCount(); + wxString aliasname = CurrentLibEntry->m_AliasList[kk]; + for ( ii = 0; ii < jj; ii++ ) + { + if( aliasname.CmpNoCase(m_PartAliasList->GetString(ii).GetData()) == 0 ) + { + kk += ALIAS_NEXT; // Alias exist in new list. keep it and test next old name + break; + } + } + + if ( ii == jj ) // Alias not found in new list, remove it (4 strings in kk position) + { + for( ii = 0; ii < ALIAS_NEXT; ii++ ) CurrentLibEntry->m_AliasList.RemoveAt(kk); + kkmax = CurrentLibEntry->m_AliasList.GetCount(); + } + + } + + + // Void fields for REFERENCE and VALUE are not allowed + if ( m_FieldText[REFERENCE].IsEmpty() ) + { + m_FieldText[REFERENCE] = CurrentLibEntry->m_Prefix.m_Text; + } + + if ( m_FieldText[VALUE].IsEmpty() ) + { + m_FieldText[VALUE] = CurrentLibEntry->m_Name.m_Text; + } + else + { + if ( CurrentLibEntry->m_Name.m_Text != m_FieldText[VALUE] ) + m_RecreateToolbar = TRUE; + } + + + CopyBufferToFieldData(& CurrentLibEntry->m_Prefix); + CopyBufferToFieldData(& CurrentLibEntry->m_Name); + + for ( ii = FOOTPRINT; ii < NUMBER_OF_FIELDS; ii++ ) + { + LibDrawField * Field = CurrentLibEntry->Fields; + LibDrawField * NextField, * previousField = NULL; + while ( Field ) + { + NextField = (LibDrawField*)Field->Pnext; + if( Field->m_FieldId == ii ) + { + CopyBufferToFieldData(Field); + // An old field exists; delete it if void + if( Field->m_Text.IsEmpty() ) + { + if ( ii < FIELD1 || Field->m_Name.IsEmpty() ) + { + delete Field; + if ( previousField ) previousField->Pnext = NextField; + else CurrentLibEntry->Fields = NextField; + } + } + break; + } + + previousField = Field; + Field = NextField; + } + + if ( Field == NULL) // Do not exists: must be created if not void + { + bool create = FALSE; + if ( ! m_FieldText[ii].IsEmpty() ) create = TRUE; + if ( ! m_FieldName[ii].IsEmpty() && (m_FieldName[ii] != ReturnDefaultFieldName(ii)) ) + create = TRUE; + if ( create ) + { + Field = new LibDrawField(ii); + CopyBufferToFieldData(Field); + Field->Pnext = CurrentLibEntry->Fields; + CurrentLibEntry->Fields = Field; + } + } + } + + /* for a user field (FieldId >= FIELD1), if a field value is void, + fill it with "~" because for a library componenta void field is not a very good idea + (we do not see anything...) and in schematic this text is like a void text */ + { + LibDrawField * Field = CurrentLibEntry->Fields; + while ( Field ) + { + if( Field->m_FieldId >= FIELD1 ) + if ( Field->m_Text.IsEmpty() ) Field->m_Text = wxT("~"); + Field = (LibDrawField*)Field->Pnext; + } + } + + ii = SelNumberOfUnits->GetValue(); + if ( ChangeNbUnitsPerPackage(ii) ) + m_RecreateToolbar = TRUE; + + if ( AsConvertButt->GetValue() ) + { + if ( ! g_AsDeMorgan ) + { + g_AsDeMorgan = 1; + if ( SetUnsetConvert() ) m_RecreateToolbar = TRUE; + } + } + else + { + if ( g_AsDeMorgan ) + { + g_AsDeMorgan = 0; + if ( SetUnsetConvert() ) m_RecreateToolbar = TRUE; + } + } + + CurrentLibEntry->m_DrawPinNum = ShowPinNumButt->GetValue() ? 1 : 0; + CurrentLibEntry->m_DrawPinName = ShowPinNameButt->GetValue() ? 1 : 0; + + if ( m_PinsNameInsideButt->GetValue() == FALSE) + CurrentLibEntry->m_TextInside = 0; + else + CurrentLibEntry->m_TextInside = m_SetSkew->GetValue(); + + if ( m_OptionPower->GetValue() == TRUE) + CurrentLibEntry->m_Options = ENTRY_POWER; + else + CurrentLibEntry->m_Options = ENTRY_NORMAL; + + /* Set the option "Units locked". + Obviously, cannot be TRUE if there is only one part */ + CurrentLibEntry->m_UnitSelectionLocked = m_OptionPartsLocked->GetValue(); + if ( CurrentLibEntry->m_UnitCount <= 1 ) + CurrentLibEntry->m_UnitSelectionLocked = FALSE; + + if ( m_RecreateToolbar ) m_Parent->ReCreateHToolbar(); + + m_Parent->DisplayLibInfos(); + + /* Update the footprint filter list */ + CurrentLibEntry->m_FootprintList.Clear(); + jj = m_FootprintFilterListBox->GetCount(); + for ( ii = 0; ii < jj; ii ++) + CurrentLibEntry->m_FootprintList.Add(m_FootprintFilterListBox->GetString(ii)); + + EndModal(1); +} + + +/*******************************************************************************/ +void WinEDA_PartPropertiesFrame::CopyDocToAlias(wxCommandEvent& WXUNUSED(event)) +/******************************************************************************/ +{ + if( CurrentLibEntry == NULL ) return; + if ( CurrentAliasName.IsEmpty() ) return; + + m_Doc->SetValue(CurrentLibEntry->m_Doc); + m_Docfile->SetValue(CurrentLibEntry->m_DocFile); + m_Keywords->SetValue(CurrentLibEntry->m_KeyWord); +} + +/**********************************************************/ +void WinEDA_PartPropertiesFrame::DeleteAllAliasOfPart( + wxCommandEvent& WXUNUSED(event)) +/**********************************************************/ +{ + + CurrentAliasName.Empty(); + if( CurrentLibEntry ) + { + if( IsOK(this, _("Ok to Delete Alias LIST") ) ) + { + m_PartAliasList->Clear(); + m_RecreateToolbar = TRUE; + m_ButtonDeleteAllAlias->Enable(FALSE); + m_ButtonDeleteOneAlias->Enable(FALSE); + } + } + +} + +/*******************************************************************************/ +void WinEDA_PartPropertiesFrame::AddAliasOfPart( wxCommandEvent& WXUNUSED(event)) +/*******************************************************************************/ +/* Add a new name to the alias list box + New name cannot be the root name, and must not exists +*/ +{ +wxString Line; +wxString aliasname; + + if(CurrentLibEntry == NULL) return; + + if( Get_Message(_("New alias:"),Line, this) != 0 ) return; + + Line.Replace( wxT(" "), wxT("_") ); + aliasname = Line; + + if ( CurrentLibEntry->m_Name.m_Text.CmpNoCase(Line) == 0 ) + { + DisplayError(this, _("This is the Root Part"), 10); return; + } + + /* test for an existing name: */ + int ii, jj = m_PartAliasList->GetCount(); + for ( ii = 0; ii < jj; ii++ ) + { + if( aliasname.CmpNoCase(m_PartAliasList->GetString(ii)) == 0 ) + { + DisplayError(this, _("Already in use"), 10); + return; + } + } + + m_PartAliasList->Append(aliasname); + if ( CurrentAliasName.IsEmpty() ) m_ButtonDeleteAllAlias->Enable(TRUE); + m_ButtonDeleteOneAlias->Enable(TRUE); + + m_RecreateToolbar = TRUE; +} + +/********************************************************/ +void WinEDA_PartPropertiesFrame::DeleteAliasOfPart( + wxCommandEvent& WXUNUSED(event)) +/********************************************************/ +{ +wxString aliasname = m_PartAliasList->GetStringSelection(); + + if ( aliasname.IsEmpty() ) return; + if ( aliasname == CurrentAliasName ) + { + wxString msg = CurrentAliasName + _(" is Current Selected Alias!"); + DisplayError(this, msg ); + return; + } + + int ii = m_PartAliasList->GetSelection(); + m_PartAliasList->Delete(ii); + + if ( ! CurrentLibEntry || (CurrentLibEntry->m_AliasList.GetCount() == 0) ) + { + m_ButtonDeleteAllAlias->Enable(FALSE); + m_ButtonDeleteOneAlias->Enable(FALSE); + } + m_RecreateToolbar = TRUE; +} + + + + +/********************************************************************/ +bool WinEDA_PartPropertiesFrame::ChangeNbUnitsPerPackage(int MaxUnit) +/********************************************************************/ +/* Routine de modification du nombre d'unites par package pour le + composant courant; +*/ +{ +int OldNumUnits, ii, FlagDel = -1; +LibEDA_BaseStruct* DrawItem, * NextDrawItem; + + if( CurrentLibEntry == NULL ) return FALSE; + + /* Si pas de changement: termine */ + if ( CurrentLibEntry->m_UnitCount == MaxUnit ) return FALSE; + + OldNumUnits = CurrentLibEntry->m_UnitCount; + if ( OldNumUnits < 1 ) OldNumUnits = 1; + + CurrentLibEntry->m_UnitCount = MaxUnit; + + + /* Traitement des unites enlevees ou rajoutees */ + if(OldNumUnits > CurrentLibEntry->m_UnitCount ) + { + DrawItem = CurrentLibEntry->m_Drawings; + for ( ; DrawItem != NULL; DrawItem = NextDrawItem) + { + NextDrawItem = DrawItem->Next(); + if( DrawItem->m_Unit > MaxUnit ) /* Item a effacer */ + { + if( FlagDel < 0 ) + { + if( IsOK(this, _("Delete units") ) ) + { + /* Si part selectee n'existe plus: selection 1ere unit */ + if( CurrentUnit > MaxUnit ) CurrentUnit = 1; + FlagDel = 1; + } + else + { + FlagDel = 0; + MaxUnit = OldNumUnits; + CurrentLibEntry->m_UnitCount = MaxUnit; + return FALSE; + } + } + DeleteOneLibraryDrawStruct(m_Parent->DrawPanel, NULL, CurrentLibEntry, + DrawItem, 0); + } + } + return TRUE; + } + + if(OldNumUnits < CurrentLibEntry->m_UnitCount ) + { + DrawItem = CurrentLibEntry->m_Drawings; + for ( ; DrawItem != NULL; DrawItem = DrawItem->Next() ) + { + /* Duplication des items pour autres elements */ + if( DrawItem->m_Unit == 1 ) + { + for ( ii = OldNumUnits +1; ii <= MaxUnit; ii ++ ) + { + NextDrawItem = CopyDrawEntryStruct(this, DrawItem); + NextDrawItem->Pnext = CurrentLibEntry->m_Drawings; + CurrentLibEntry->m_Drawings = NextDrawItem; + NextDrawItem->m_Unit = ii; + } + } + } + } + return TRUE; +} + + +/*****************************************************/ +bool WinEDA_PartPropertiesFrame::SetUnsetConvert(void) +/*****************************************************/ +/* crée ou efface (selon option AsConvert) les éléments + de la représentation convertie d'un composant +*/ +{ +int FlagDel = 0; +LibEDA_BaseStruct* DrawItem = NULL, * NextDrawItem; + + if( g_AsDeMorgan ) /* Representation convertie a creer */ + { + /* Traitement des elements a ajouter ( pins seulement ) */ + if( CurrentLibEntry ) DrawItem = CurrentLibEntry->m_Drawings; + for ( ; DrawItem != NULL; DrawItem = DrawItem->Next() ) + { + /* Duplication des items pour autres elements */ + if( DrawItem->m_StructType != COMPONENT_PIN_DRAW_TYPE ) continue; + if( DrawItem->m_Convert == 1 ) + { + if( FlagDel == 0 ) + { + if( IsOK(this, _("Create pins for Convert items")) ) + FlagDel = 1; + else + { + if( IsOK(this, _("Part as \"De Morgan\" anymore")) ) + return TRUE; + + g_AsDeMorgan = 0; return FALSE; + } + } + NextDrawItem = CopyDrawEntryStruct(this, DrawItem); + NextDrawItem->Pnext = CurrentLibEntry->m_Drawings; + CurrentLibEntry->m_Drawings = NextDrawItem; + NextDrawItem->m_Convert = 2; + } + } + } + + else /* Representation convertie a supprimer */ + { + /* Traitement des elements à supprimer */ + if( CurrentLibEntry ) DrawItem = CurrentLibEntry->m_Drawings; + for ( ; DrawItem != NULL; DrawItem = NextDrawItem) + { + NextDrawItem = DrawItem->Next(); + if( DrawItem->m_Convert > 1 ) /* Item a effacer */ + { + if( FlagDel == 0 ) + { + if( IsOK(this, _("Delete Convert items") ) ) + { + CurrentConvert = 1; + FlagDel = 1; + } + else + { + g_AsDeMorgan = 1; + return FALSE; + } + } + m_Parent->GetScreen()->SetModify(); + DeleteOneLibraryDrawStruct(m_Parent->DrawPanel, NULL, CurrentLibEntry, DrawItem, 0); + } + } + } + return TRUE; +} + +/****************************************************************************/ +void WinEDA_PartPropertiesFrame::BrowseAndSelectDocFile(wxCommandEvent& event) +/****************************************************************************/ +{ +wxString FullFileName, mask; +wxString docpath(g_RealLibDirBuffer), filename; + + docpath += wxT("doc"); + docpath += STRING_DIR_SEP; + mask = wxT("*"); + FullFileName = EDA_FileSelector(_("Doc Files"), + docpath, /* Chemin par defaut */ + wxEmptyString, /* nom fichier par defaut */ + wxEmptyString, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_OPEN, + TRUE + ); + if ( FullFileName.IsEmpty() ) return; + + // Suppression du chemin par defaut pour le fichier de doc: + filename = MakeReducedFileName(FullFileName,docpath, wxEmptyString); + m_Docfile->SetValue(filename); +} + + +/**********************************************************/ +void WinEDA_PartPropertiesFrame::DeleteAllFootprintFilter( + wxCommandEvent& WXUNUSED(event)) +/**********************************************************/ +{ + + if( IsOK(this, _("Ok to Delete FootprintFilter LIST") ) ) + { + m_FootprintFilterListBox->Clear(); + m_ButtonDeleteAllFootprintFilter->Enable(FALSE); + m_ButtonDeleteOneFootprintFilter->Enable(FALSE); + } +} + +/*******************************************************************************/ +void WinEDA_PartPropertiesFrame::AddFootprintFilter( wxCommandEvent& WXUNUSED(event)) +/*******************************************************************************/ +/* Add a new name to the alias list box + New name cannot be the root name, and must not exists +*/ +{ +wxString Line; + + if(CurrentLibEntry == NULL) return; + + if( Get_Message(_("New FootprintFilter:"),Line, this) != 0 ) return; + + Line.Replace( wxT(" "), wxT("_") ); + + /* test for an existing name: */ + int ii, jj = m_FootprintFilterListBox->GetCount(); + for ( ii = 0; ii < jj; ii++ ) + { + if( Line.CmpNoCase(m_FootprintFilterListBox->GetString(ii)) == 0 ) + { + DisplayError(this, _("Already in use"), 10); + return; + } + } + + m_FootprintFilterListBox->Append(Line); + m_ButtonDeleteAllFootprintFilter->Enable(TRUE); + m_ButtonDeleteOneFootprintFilter->Enable(TRUE); +} + +/********************************************************/ +void WinEDA_PartPropertiesFrame::DeleteOneFootprintFilter( + wxCommandEvent& WXUNUSED(event)) +/********************************************************/ +{ +int ii = m_FootprintFilterListBox->GetSelection(); + m_FootprintFilterListBox->Delete(ii); + + if ( ! CurrentLibEntry || (m_FootprintFilterListBox->GetCount() == 0) ) + { + m_ButtonDeleteAllFootprintFilter->Enable(FALSE); + m_ButtonDeleteOneFootprintFilter->Enable(FALSE); + } +} + + diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp new file mode 100644 index 0000000000..11abb2df07 --- /dev/null +++ b/eeschema/edit_component_in_schematic.cpp @@ -0,0 +1,780 @@ + /********************************/ + /* Scehematic component edition */ + /********************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "wx/checklst.h" + +#include "protos.h" + + +/* Fonctions exportees */ + +/* Fonctions locales */ +static void AbortMoveCmpField(WinEDA_DrawPanel * Panel, wxDC * DC); +static void MoveCmpField(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); + +/* variables locales */ +static PartTextStruct * CurrentField; +static int Multiflag; +static int TextFieldSize = DEFAULT_SIZE_TEXT; +static wxPoint OldPos; + + + /************************************/ + /* class WinEDA_PartPropertiesFrame */ + /************************************/ +#define ID_ON_SELECT_FIELD 3000 + +#include "dialog_edit_component_in_schematic.cpp" + +/**********************************************************************/ +void InstallCmpeditFrame(WinEDA_SchematicFrame * parent, wxPoint & pos, + EDA_SchComponentStruct * cmp) +/*********************************************************************/ +/* Create the dialog box for the current component edition +*/ +{ + parent->DrawPanel->m_IgnoreMouseEvents = TRUE; + if ( cmp->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + { + DisplayError( parent, wxT("InstallCmpeditFrame() error: This struct is not a component") ); + } + else + { + WinEDA_ComponentPropertiesFrame * frame = + new WinEDA_ComponentPropertiesFrame(parent, cmp); + frame->ShowModal(); frame->Destroy(); + } + + parent->DrawPanel->MouseToCursorSchema(); + parent->DrawPanel->m_IgnoreMouseEvents = FALSE; +} + +/*****************************************************/ +void WinEDA_ComponentPropertiesFrame::InitBuffers(void) +/*****************************************************/ +/* Init the buffers to a default value, + or to values from Component!= NULL +*/ +{ +int ii; + + m_CurrentFieldId = REFERENCE; + + /* Init default values */ + for ( ii = 0; ii < NUMBER_OF_FIELDS; ii++) + { + m_FieldSize[ii] = DEFAULT_SIZE_TEXT; + m_FieldFlags[ii] = 1; + m_FieldOrient[ii] = 0; + } + + if ( m_Cmp == NULL ) return; + + for ( ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ ) + { + m_FieldName[ii] = m_Cmp->ReturnFieldName(ii); + m_FieldText[ii] = m_Cmp->m_Field[ii].m_Text; + m_FieldSize[ii] = m_Cmp->m_Field[ii].m_Size.x; + m_FieldFlags[ii] = + (m_Cmp->m_Field[ii].m_Attributs & TEXT_NO_VISIBLE) ? 0 : 1; + m_FieldOrient[ii] = m_Cmp->m_Field[ii].m_Orient; + + if ( m_Cmp->m_Field[ii].m_Text.IsEmpty() ) continue; + // These values have meaning only if this field is not void: + m_FieldPosition[ii] = m_Cmp->m_Field[ii].m_Pos; + m_FieldPosition[ii].x -= m_Cmp->m_Pos.x; + m_FieldPosition[ii].y -= m_Cmp->m_Pos.y; + } +} + + +/****************************************************************/ +void WinEDA_ComponentPropertiesFrame::CopyDataToPanelField(void) +/****************************************************************/ +/* Set the values displayed on the panel field according to + the current field number +*/ +{ +int fieldId = m_CurrentFieldId; + + for ( int ii = FIELD1; ii < NUMBER_OF_FIELDS; ii++ ) + m_FieldSelection->SetString(ii, m_FieldName[ii]); + + if ( fieldId == VALUE && m_LibEntry && m_LibEntry->m_Options == ENTRY_POWER ) + m_FieldTextCtrl->Enable(FALSE); + + if ( m_FieldFlags[fieldId] ) + m_ShowFieldTextCtrl->SetValue(TRUE); + else m_ShowFieldTextCtrl->SetValue(FALSE); + + // If the field value is empty and the position is zero, we set the + // initial position as a small offset from the ref field, and orient + // it the same as the ref field. That is likely to put it at least + // close to the desired position. + if ( (m_FieldPosition[fieldId] == wxPoint(0,0)) && + m_FieldText[fieldId].IsEmpty()) { + m_VorientFieldText->SetValue(m_FieldOrient[REFERENCE] != 0); + m_FieldPositionCtrl->SetValue(m_FieldPosition[REFERENCE].x + 100, + m_FieldPosition[REFERENCE].y + 100 ); + } + else { + m_FieldPositionCtrl->SetValue(m_FieldPosition[fieldId].x, m_FieldPosition[fieldId].y ); + m_VorientFieldText->SetValue(m_FieldOrient[fieldId] != 0); + } + + m_FieldNameCtrl->SetValue(m_FieldName[fieldId]); + if ( fieldId < FIELD1 ) m_FieldNameCtrl->Enable(FALSE ); + else m_FieldNameCtrl->Enable( TRUE ); + m_FieldTextCtrl->SetValue(m_FieldText[fieldId]); + m_FieldTextCtrl->SetValue(m_FieldSize[fieldId]); +} + +/****************************************************************/ +void WinEDA_ComponentPropertiesFrame::CopyPanelFieldToData(void) +/****************************************************************/ +/* Copy the values displayed on the panel field to the buffers according to + the current field number +*/ +{ +int id = m_CurrentFieldId; + + m_FieldFlags[id] = m_ShowFieldTextCtrl->GetValue(); + m_FieldOrient[id] = m_VorientFieldText->GetValue(); + m_FieldText[id] = m_FieldTextCtrl->GetText(); + m_FieldName[id] = m_FieldNameCtrl->GetValue(); + m_FieldPosition[id] = m_FieldPositionCtrl->GetValue(); + m_FieldSize[id] = m_FieldTextCtrl->GetTextSize(); +} + + +/*************************************************************/ +void WinEDA_ComponentPropertiesFrame::BuildPanelFields( void ) +/*************************************************************/ +{ +int ii, FieldId; +wxPoint field_pos; + + m_CurrentFieldId = FieldId = REFERENCE; + + // Create the box field selection: +wxString fieldnamelist[NUMBER_OF_FIELDS]; + for ( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) + { + if ( m_FieldName[ii].IsEmpty() ) + fieldnamelist[ii] = ReturnDefaultFieldName(ii); + else fieldnamelist[ii] = m_FieldName[ii]; + } + m_FieldSelection = new wxRadioBox(m_PanelField, ID_ON_SELECT_FIELD, + _("Field to edit"), wxDefaultPosition, wxDefaultSize, + NUMBER_OF_FIELDS, fieldnamelist, 2 , wxRA_SPECIFY_COLS); + m_FieldSelectionBoxSizer->Add(m_FieldSelection, 0 , wxGROW|wxALL, 5); + + // Create the box for field name display + m_FieldNameCtrl = new WinEDA_EnterText( m_PanelField, + _("Field Name:"), m_FieldName[FieldId], + m_FieldDatasBoxSizer, wxSize( 200, -1) ); + if ( FieldId < FIELD1 ) m_FieldNameCtrl->Enable(FALSE ); + else m_FieldNameCtrl->Enable( TRUE ); + + // Create the box for text editing (text, size) + m_FieldTextCtrl = new WinEDA_GraphicTextCtrl( m_PanelField, + _("Value:"), + m_FieldText[FieldId], + m_FieldSize[FieldId], + g_UnitMetric , + m_FieldDatasBoxSizer, 200, m_Parent->m_InternalUnits); + + // Create the box for text editing (position) + m_FieldPositionCtrl = new WinEDA_PositionCtrl( m_PanelField, _("Pos"), + m_FieldPosition[FieldId], + g_UnitMetric , + m_FieldDatasBoxSizer, + m_Parent->m_InternalUnits ); + + CopyDataToPanelField(); +} + +/**********************************************************/ +void WinEDA_ComponentPropertiesFrame::BuildPanelBasic(void) +/**********************************************************/ +/* create the basic panel for component properties editing +*/ +{ +int Nb_Max_Unit = m_SelectUnit->GetCount(); +int ii; + +int nb_units = m_LibEntry ? MAX(m_LibEntry->m_UnitCount, 1) : 0; + + // Disable non existant units selection buttons + for ( ii = nb_units; ii < Nb_Max_Unit; ii++ ) + { + m_SelectUnit->Enable(ii, FALSE); + } + if ( m_Cmp->m_Multi <= Nb_Max_Unit ) + m_SelectUnit->SetSelection(m_Cmp->m_Multi -1); + + ii = m_Cmp->GetRotationMiroir() & ~(CMP_MIROIR_X|CMP_MIROIR_Y); + + if ( ii == CMP_ORIENT_90) m_OrientUnit->SetSelection(1); + else if ( ii == CMP_ORIENT_180) m_OrientUnit->SetSelection(2); + else if ( ii == CMP_ORIENT_270) m_OrientUnit->SetSelection(3); + + ii = m_Cmp->GetRotationMiroir() & (CMP_MIROIR_X|CMP_MIROIR_Y) ; + if ( ii == CMP_MIROIR_X ) m_MirrorUnit->SetSelection(1); + else if ( ii == CMP_MIROIR_Y ) m_MirrorUnit->SetSelection(2); + + // Positionnement de la selection normal/convert + if ( m_Cmp->m_Convert > 1 ) m_ConvertButt->SetValue(TRUE); + + if ( (m_LibEntry == NULL) || LookForConvertPart(m_LibEntry) <= 1) + { + m_ConvertButt->Enable(FALSE); + } + + // Show the "Parts Locked" option: + if ( ! m_LibEntry || ! m_LibEntry->m_UnitSelectionLocked ) + { + m_MsgPartLocked->Show(false); + } + + // Positionnement de la reference en librairie + m_RefInLib->SetValue(m_Cmp->m_ChipName); + +} + +/*************************************************************************/ +void WinEDA_ComponentPropertiesFrame::SelectNewField(wxCommandEvent& event) +/*************************************************************************/ +/* called when changing the current field selected + Save the current field settings in buffer and display the new one +*/ +{ + CopyPanelFieldToData(); + m_CurrentFieldId = m_FieldSelection->GetSelection(); + CopyDataToPanelField(); +} + +/***********************************************************************************/ +void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept(wxCommandEvent& event) +/***********************************************************************************/ +/* Update the new parameters for the current edited component +*/ +{ +wxPoint cmp_pos = m_Cmp->m_Pos; +wxClientDC dc(m_Parent->DrawPanel); +wxString newname; + + /* save old cmp in undo list if not already in edit, or moving ... */ + if ( m_Cmp->m_Flags == 0 ) + m_Parent->SaveCopyInUndoList(m_Cmp, IS_CHANGED); + + CopyPanelFieldToData(); + + m_Parent->DrawPanel->PrepareGraphicContext(&dc); + + + RedrawOneStruct(m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode); + + newname = m_RefInLib->GetValue(); + newname.MakeUpper(); + newname.Replace(wxT(" "), wxT("_")); + + if ( newname.IsEmpty() ) DisplayError(this, _("No Component Name!")); + else if ( newname.CmpNoCase(m_Cmp->m_ChipName) ) + { + if ( FindLibPart(newname.GetData(), wxEmptyString, FIND_ALIAS) == NULL ) + { + wxString msg; + msg.Printf( _("Component [%s] not found!"), newname.GetData() ); + DisplayError(this, msg); + } + else // Changement de composant! + { + m_Cmp->m_ChipName = newname; + } + } + + // Mise a jour de la representation: + if ( m_ConvertButt->IsEnabled() ) + (m_ConvertButt->GetValue() == TRUE) ? + m_Cmp->m_Convert = 2 : m_Cmp->m_Convert = 1; + + //Mise a jour de la selection de l'élément dans le boitier + if ( m_Cmp->m_Multi ) m_Cmp->m_Multi = m_SelectUnit->GetSelection() + 1; + + //Mise a jour de l'orientation: + switch (m_OrientUnit->GetSelection() ) + { + case 0: + m_Cmp->SetRotationMiroir(CMP_ORIENT_0); + break; + case 1: + m_Cmp->SetRotationMiroir(CMP_ORIENT_90); + break; + case 2: + m_Cmp->SetRotationMiroir(CMP_ORIENT_180); + break; + case 3: + m_Cmp->SetRotationMiroir(CMP_ORIENT_270); + break; + } + + switch (m_MirrorUnit->GetSelection() ) + { + case 0: + break; + case 1: + m_Cmp->SetRotationMiroir(CMP_MIROIR_X); + break; + case 2: + m_Cmp->SetRotationMiroir(CMP_MIROIR_Y); + break; + } + + + // Mise a jour des textes + for ( int ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ ) + { + if( ii == REFERENCE ) // la reference ne peut etre vide + { + if ( ! m_FieldText[ii].IsEmpty() ) + m_Cmp->m_Field[ii].m_Text = m_FieldText[ii]; + } + else if( ii == VALUE ) // la valeur ne peut etre vide et ne peut etre change sur un POWER + { + EDA_LibComponentStruct *Entry = FindLibPart(m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if( Entry && (Entry->m_Options == ENTRY_POWER) ) + m_Cmp->m_Field[ii].m_Text = m_Cmp->m_ChipName; + else if ( ! m_FieldText[ii].IsEmpty() ) + { + m_Cmp->m_Field[ii].m_Text = m_FieldText[ii]; + } + } + else + m_Cmp->m_Field[ii].m_Text = m_FieldText[ii]; + + if ( ii >= FIELD1 && m_FieldName[ii] != ReturnDefaultFieldName(ii) ) + m_Cmp->m_Field[ii].m_Name = m_FieldName[ii]; + else m_Cmp->m_Field[ii].m_Name.Empty(); + + m_Cmp->m_Field[ii].m_Size.x = + m_Cmp->m_Field[ii].m_Size.y = m_FieldSize[ii]; + if ( m_FieldFlags[ii] ) + m_Cmp->m_Field[ii].m_Attributs &= ~TEXT_NO_VISIBLE; + else + m_Cmp->m_Field[ii].m_Attributs |= TEXT_NO_VISIBLE; + m_Cmp->m_Field[ii].m_Orient = m_FieldOrient[ii] ? 1 : 0; + m_Cmp->m_Field[ii].m_Pos = m_FieldPosition[ii]; + m_Cmp->m_Field[ii].m_Pos.x += cmp_pos.x; + m_Cmp->m_Field[ii].m_Pos.y += cmp_pos.y; + } + m_Parent->m_CurrentScreen->SetModify(); + + RedrawOneStruct(m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE); + m_Parent->TestDanglingEnds(m_Parent->m_CurrentScreen->EEDrawList, &dc); + + Close(); +} + + + +/************************************************************************************/ +void WinEDA_SchematicFrame::StartMoveCmpField(PartTextStruct * Field, wxDC * DC) +/************************************************************************************/ +/* Prepare le deplacement du texte en cours d'edition +*/ +{ +EDA_LibComponentStruct *Entry; + + + CurrentField = Field; + if ( Field == NULL ) return; + + if(Field->m_Text == wxEmptyString) + { + DisplayError(this, _("No Field to move"), 10); + return; + } + +wxPoint pos, newpos; +int x1, y1; +EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) CurrentField->m_Parent; + + delete g_ItemToUndoCopy; + g_ItemToUndoCopy = Cmp->GenCopy(); + + pos = Cmp->m_Pos; + + /* Les positions sont calculees par la matrice TRANSPOSEE de la matrice + de rotation-miroir */ + x1 = Field->m_Pos.x - pos.x; + y1 = Field->m_Pos.y - pos.y; + // Empirically this is necessary. The Y coordinate appears to be inverted + // under some circumstances, but that inversion is not preserved by all + // combinations of mirroring and rotation. The following clause is true + // when the number of rotations and the number of mirrorings are both odd. + if (Cmp->m_Transform[1][0] * Cmp->m_Transform[0][1] < 0) { + y1 = -y1; + } + newpos.x = pos.x + Cmp->m_Transform[0][0] * x1 + Cmp->m_Transform[1][0] * y1; + newpos.y = pos.y + Cmp->m_Transform[0][1] * x1 + Cmp->m_Transform[1][1] * y1; + + DrawPanel->CursorOff(DC); + m_CurrentScreen->m_Curseur = newpos; + DrawPanel->MouseToCursorSchema(); + + OldPos = Field->m_Pos; + Multiflag = 0; + if( Field->m_FieldId == REFERENCE ) + { + Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); + if( Entry != NULL ) + { + if ( Entry->m_UnitCount > 1 ) Multiflag = 1; + } + } + + DrawPanel->ForceCloseManageCurseur = AbortMoveCmpField; + DrawPanel->ManageCurseur = MoveCmpField; + Field->m_Flags = IS_MOVED; + + DrawPanel->CursorOn(DC); +} + + +/**********************************************************************************/ +void WinEDA_SchematicFrame::EditCmpFieldText(PartTextStruct * Field, wxDC *DC) +/**********************************************************************************/ +/* Edit the field Field (text, size) */ +{ +int FieldNumber, flag; +EDA_LibComponentStruct *Entry; + + if( Field == NULL ) + { + DisplayError(this, _("No Field To Edit"), 10); + return; + } + +EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) Field->m_Parent; + + FieldNumber = Field->m_FieldId; + if( FieldNumber == VALUE ) + { + Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if( Entry && (Entry->m_Options == ENTRY_POWER) ) + { + DisplayInfo(this, + _("Part is a POWER, value cannot be modified!\nYou must create a new power") ); + return; + } + } + + flag = 0; + if( FieldNumber == REFERENCE ) + { + Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if( Entry != NULL ) + { + if ( Entry->m_UnitCount > 1 ) flag = 1; + } + } + + + /* save old cmp in undo list if not already in edit, or moving ... */ + if ( Field->m_Flags == 0 ) SaveCopyInUndoList(Cmp, IS_CHANGED); + + wxString newtext = Field->m_Text; + DrawPanel->m_IgnoreMouseEvents = TRUE; + Get_Message(Field->m_Name, newtext, this); + DrawPanel->MouseToCursorSchema(); + DrawPanel->m_IgnoreMouseEvents = FALSE; + + DrawTextField(DrawPanel, DC, Field, flag, g_XorMode); + + if ( ! newtext.IsEmpty() ) + { + if (Field->m_Text.IsEmpty()) + { + Field->m_Pos = Cmp->m_Pos; + Field->m_Size.x = Field->m_Size.y = TextFieldSize; + } + Field->m_Text = newtext; + } + + else /* Nouveau texte NULL */ + { + if( FieldNumber == REFERENCE ) + { + DisplayError(this, _("Reference needed !, No change")); + } + else if( FieldNumber == VALUE ) + { + DisplayError(this, _("Value needed !, No change")); + } + else + { + Field->m_Text = wxT("~"); + } + } + + DrawTextField(DrawPanel, DC, Field, flag, g_XorMode); + Cmp->Display_Infos(this); + m_CurrentScreen->SetModify(); +} + + +/************************************************************************/ +static void MoveCmpField(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/************************************************************************/ +/* Routine de deplacement d'un texte type Field. + Celle routine est normalement attachee au deplacement du curseur +*/ +{ +wxPoint pos; +int x1, y1; +int FieldNumber; + + if( CurrentField == NULL) return; + +EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*)CurrentField->m_Parent; + FieldNumber = CurrentField->m_FieldId; + + /* Effacement: */ + if( erase ) + DrawTextField(panel, DC, CurrentField, Multiflag, g_XorMode); + + pos = ((EDA_SchComponentStruct*)CurrentField->m_Parent)->m_Pos; + + /* Les positions sont caculees par la matrice TRANSPOSEE de la matrice + de rotation-miroir */ + x1 = panel->GetScreen()->m_Curseur.x - pos.x; + y1 = panel->GetScreen()->m_Curseur.y - pos.y; + CurrentField->m_Pos.x = pos.x + Cmp->m_Transform[0][0] * x1 + Cmp->m_Transform[1][0] * y1; + CurrentField->m_Pos.y = pos.y + Cmp->m_Transform[0][1] * x1 + Cmp->m_Transform[1][1] * y1; + + DrawTextField(panel, DC, CurrentField, Multiflag, g_XorMode); +} + + +/******************************************************************/ +static void AbortMoveCmpField(WinEDA_DrawPanel * Panel, wxDC * DC) +/******************************************************************/ +{ + Panel->ForceCloseManageCurseur = NULL; + Panel->ManageCurseur = NULL; + if ( CurrentField ) + { + DrawTextField(Panel, DC, CurrentField,Multiflag, g_XorMode); + CurrentField->m_Flags = 0; + CurrentField->m_Pos = OldPos; + DrawTextField(Panel, DC, CurrentField,Multiflag, GR_DEFAULT_DRAWMODE); + } + CurrentField = NULL; + delete g_ItemToUndoCopy; g_ItemToUndoCopy = NULL; +} + +/*********************************************************************************/ +void WinEDA_SchematicFrame::RotateCmpField(PartTextStruct * Field, wxDC * DC) +/*********************************************************************************/ +{ +int FieldNumber, flag; +EDA_LibComponentStruct *Entry; + + if (Field == NULL ) return; + if (Field->m_Text == wxEmptyString ) return; + +EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*)Field->m_Parent; + + FieldNumber = Field->m_FieldId; + flag = 0; + if( FieldNumber == REFERENCE ) + { + Entry = FindLibPart( ((EDA_SchComponentStruct*)Field->m_Parent)->m_ChipName.GetData(), + wxEmptyString, FIND_ROOT); + if( Entry != NULL ) + { + if ( Entry->m_UnitCount > 1 ) flag = 1; + } + } + + /* save old cmp in undo list if not already in edit, or moving ... */ + if ( Field->m_Flags == 0 ) SaveCopyInUndoList(Cmp, IS_CHANGED); + + DrawTextField(DrawPanel, DC, Field, flag, g_XorMode); + + if( Field->m_Orient == TEXT_ORIENT_HORIZ ) Field->m_Orient = TEXT_ORIENT_VERT; + else Field->m_Orient = TEXT_ORIENT_HORIZ; + DrawTextField(DrawPanel, DC, Field,flag, g_XorMode); + + GetScreen()->SetModify(); +} + + +/*********************************************************************/ +void PartTextStruct::Place( WinEDA_DrawFrame * frame, wxDC * DC) +/*********************************************************************/ +{ +int FieldNumber, flag; +EDA_LibComponentStruct *Entry; + + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; + +EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) m_Parent; + /* save old cmp in undo list */ + if ( g_ItemToUndoCopy && ( g_ItemToUndoCopy->m_StructType == Cmp->m_StructType) ) + { + Cmp->SwapData( (EDA_SchComponentStruct*) g_ItemToUndoCopy); + ((WinEDA_SchematicFrame *) frame)->SaveCopyInUndoList(Cmp, IS_CHANGED); + Cmp->SwapData( (EDA_SchComponentStruct*) g_ItemToUndoCopy); + } + + FieldNumber = m_FieldId; + flag = 0; + if( FieldNumber == REFERENCE ) + { + Entry = FindLibPart( Cmp->m_ChipName.GetData(), + wxEmptyString, FIND_ROOT); + if( Entry != NULL ) + { + if ( Entry->m_UnitCount > 1 ) flag = 1; + } + } + + DrawTextField(frame->DrawPanel, DC, this, flag, GR_DEFAULT_DRAWMODE); + m_Flags = 0; + frame->GetScreen()->m_CurrentItem = NULL; + frame->GetScreen()->SetModify(); + CurrentField = NULL; +} + + + +/**************************************************************************************************/ +void WinEDA_SchematicFrame::EditComponentReference(EDA_SchComponentStruct * Cmp, wxDC * DC) +/**************************************************************************************************/ +/* Edit the component text reference*/ +{ +wxString msg; +EDA_LibComponentStruct *Entry; +int flag = 0; + + if( Cmp == NULL ) return; + + Entry = FindLibPart(Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if ( Entry == NULL ) return; + + if ( Entry->m_UnitCount > 1 ) flag = 1; + + PartTextStruct * TextField = &Cmp->m_Field[REFERENCE]; + + msg = TextField->m_Text; + Get_Message(_("Reference") , msg, this); + + if ( ! msg.IsEmpty() ) // New text entered + { + /* save old cmp in undo list if not already in edit, or moving ... */ + if ( Cmp->m_Flags == 0 ) SaveCopyInUndoList(Cmp, IS_CHANGED); + + DrawTextField(DrawPanel, DC, &Cmp->m_Field[REFERENCE], flag, g_XorMode); + TextField->m_Text = msg; + DrawTextField(DrawPanel, DC, &Cmp->m_Field[REFERENCE], flag, + Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE); + GetScreen()->SetModify(); + } + Cmp->Display_Infos(this); +} + +/*****************************************************************************************/ +void WinEDA_SchematicFrame::EditComponentValue(EDA_SchComponentStruct * Cmp, wxDC * DC) +/*****************************************************************************************/ +/* Routine de changement du texte selectionne */ +{ +wxString msg; +EDA_LibComponentStruct *Entry; +int flag = 0; + + if( Cmp == NULL ) return; + + Entry = FindLibPart(Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if ( Entry == NULL ) return; + if ( Entry->m_UnitCount > 1 ) flag = 1; + + PartTextStruct * TextField = &Cmp->m_Field[VALUE]; + + msg = TextField->m_Text; + Get_Message(_("Value") , msg, this); + + if ( ! msg.IsEmpty() ) + { + /* save old cmp in undo list if not already in edit, or moving ... */ + if ( Cmp->m_Flags == 0 ) SaveCopyInUndoList(Cmp, IS_CHANGED); + + DrawTextField(DrawPanel, DC, &Cmp->m_Field[VALUE], flag, g_XorMode); + TextField->m_Text = msg; + DrawTextField(DrawPanel, DC, &Cmp->m_Field[VALUE], flag, + Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE); + m_CurrentScreen->SetModify(); + } + + Cmp->Display_Infos(this); +} + +/*****************************************************************************/ +void WinEDA_ComponentPropertiesFrame::SetInitCmp( wxCommandEvent& event ) +/*****************************************************************************/ +/* Replace le composant en position normale, dimensions et positions + fields comme definies en librairie +*/ +{ +EDA_LibComponentStruct *Entry; + + if ( m_Cmp == NULL ) return; + + Entry = FindLibPart(m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + + if( Entry == NULL) return; + +wxClientDC dc(m_Parent->DrawPanel); + m_Parent->DrawPanel->PrepareGraphicContext(&dc); + + RedrawOneStruct(m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode); + + /* Mise aux valeurs par defaut des champs et orientation */ + m_Cmp->m_Field[REFERENCE].m_Pos.x = + Entry->m_Prefix.m_Pos.x + m_Cmp->m_Pos.x; + m_Cmp->m_Field[REFERENCE].m_Pos.y = + Entry->m_Prefix.m_Pos.y + m_Cmp->m_Pos.y; + m_Cmp->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient; + m_Cmp->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size; + m_Cmp->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify; + m_Cmp->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify; + + m_Cmp->m_Field[VALUE].m_Pos.x = + Entry->m_Name.m_Pos.x + m_Cmp->m_Pos.x; + m_Cmp->m_Field[VALUE].m_Pos.y = + Entry->m_Name.m_Pos.y + m_Cmp->m_Pos.y; + m_Cmp->m_Field[VALUE].m_Orient = Entry->m_Name.m_Orient; + m_Cmp->m_Field[VALUE].m_Size = Entry->m_Name.m_Size; + m_Cmp->m_Field[VALUE].m_HJustify = Entry->m_Name.m_HJustify; + m_Cmp->m_Field[VALUE].m_VJustify = Entry->m_Name.m_VJustify; + + m_Cmp->SetRotationMiroir(CMP_NORMAL); + + m_Parent->m_CurrentScreen->SetModify(); + + RedrawOneStruct(m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE); + Close(); +} + + diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp new file mode 100644 index 0000000000..795bb812e7 --- /dev/null +++ b/eeschema/edit_label.cpp @@ -0,0 +1,337 @@ +/**************************************************************************/ +/* EESchema */ +/* editexte.cpp: creation/ editions des textes (labels, textes sur schema) */ +/**************************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +/* Fonctions locales */ +static void ShowWhileMoving(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void ExitMoveTexte(WinEDA_DrawPanel * panel, wxDC *DC); + +/* Variables locales */ +static wxPoint ItemInitialPosition; +static int OldOrient; +static wxSize OldSize; +static int ShapeGLabel = (int) NET_INPUT; +static int TextLabelSize = DEFAULT_SIZE_TEXT; + + /************************************/ + /* class WinEDA_LabelPropertiesFrame */ + /************************************/ + +#include "dialog_edit_label.cpp" + + +/****************************************************************************/ +void WinEDA_LabelPropertiesFrame::TextPropertiesAccept(wxCommandEvent& event) +/****************************************************************************/ +{ +wxString text; +int value; + + /* save old text in undo list if not already in edit */ + if ( m_CurrentText->m_Flags == 0 ) + m_Parent->SaveCopyInUndoList(m_CurrentText, IS_CHANGED); + + text = m_TextLabel->GetValue(); + if ( ! text.IsEmpty() ) m_CurrentText->m_Text = text; + else if ( (m_CurrentText->m_Flags & IS_NEW) == 0 ) + DisplayError(this, _("Empty Text!") ); + + m_CurrentText->m_Orient = m_TextOrient->GetSelection(); + text = m_TextSize->GetValue(); + value = ReturnValueFromString(g_UnitMetric, text, m_Parent->m_InternalUnits); + m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value; + if ( m_TextShape ) m_CurrentText->m_Shape = m_TextShape->GetSelection(); + + m_Parent->GetScreen()->SetModify(); + + Close(TRUE); +} + + + +/********************************************************************************/ +void WinEDA_SchematicFrame::StartMoveTexte(DrawTextStruct * TextStruct, wxDC *DC) +/********************************************************************************/ +{ + if(TextStruct == NULL) return; + + g_ItemToRepeat = NULL; + + if ( (TextStruct->m_Flags & IS_NEW) == 0 ) + { + delete g_ItemToUndoCopy; + g_ItemToUndoCopy = TextStruct->GenCopy(); + } + + TextStruct->m_Flags |= IS_MOVED; + + switch( TextStruct->m_StructType ) + { + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + ItemInitialPosition = TextStruct->m_Pos; + OldSize = TextStruct->m_Size; + OldOrient = TextStruct->m_Orient; + break; + + default: break; + } + + DrawPanel->CursorOff(DC); + m_CurrentScreen->m_Curseur = ItemInitialPosition; + DrawPanel->MouseToCursorSchema(); + + GetScreen()->SetModify(); + DrawPanel->ManageCurseur = ShowWhileMoving; + DrawPanel->ForceCloseManageCurseur = ExitMoveTexte; + DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); + + DrawPanel->CursorOn(DC); +} + + +/*************************************************************************/ +void WinEDA_SchematicFrame::EditSchematicText(DrawTextStruct * TextStruct, + wxDC * DC) +/*************************************************************************/ +/* Changement du texte (Label.. ) pointe par la souris +*/ +{ + if(TextStruct == NULL) return; + + DrawPanel->CursorOff(DC); + RedrawOneStruct(DrawPanel, DC, TextStruct, g_XorMode); + +WinEDA_LabelPropertiesFrame * frame = new WinEDA_LabelPropertiesFrame(this, + TextStruct, wxPoint(30,30)); + frame->ShowModal(); frame->Destroy(); + + RedrawOneStruct(DrawPanel, DC, TextStruct, GR_DEFAULT_DRAWMODE); + DrawPanel->CursorOn(DC); +} + + +/***********************************************************************************/ +void WinEDA_SchematicFrame::ChangeTextOrient(DrawTextStruct * TextStruct, wxDC * DC) +/***********************************************************************************/ +{ + if( TextStruct == NULL ) + TextStruct = (DrawTextStruct *) PickStruct(GetScreen()->m_Curseur, + GetScreen()->EEDrawList, TEXTITEM|LABELITEM); + if( TextStruct == NULL ) return; + + /* save old text in undo list if is not already in edit */ + if ( TextStruct->m_Flags == 0 ) + SaveCopyInUndoList(TextStruct, IS_CHANGED); + + /* Effacement du texte en cours */ + RedrawOneStruct(DrawPanel, DC, TextStruct, g_XorMode); + + /* Rotation du texte */ + switch( TextStruct->m_StructType ) + { + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + ((DrawTextStruct*)TextStruct)->m_Orient++; + ((DrawTextStruct*)TextStruct)->m_Orient &= 3; + break; + + default: break; + } + + GetScreen()->SetModify(); + + /* Reaffichage */ + RedrawOneStruct(DrawPanel, DC, TextStruct, g_XorMode); +} + +/*************************************************************************/ +EDA_BaseStruct * WinEDA_SchematicFrame::CreateNewText(wxDC * DC, int type) +/*************************************************************************/ +/* Routine to create new text struct (GraphicText, label or Glabel). +*/ +{ +DrawTextStruct * NewText = NULL; + + g_ItemToRepeat = NULL; + + switch( type ) + { + case LAYER_NOTES: + NewText = new DrawTextStruct(m_CurrentScreen->m_Curseur); + NewText->m_Size.x = NewText->m_Size.y = TextLabelSize; + break; + + case LAYER_LOCLABEL: + { + NewText = new DrawLabelStruct(m_CurrentScreen->m_Curseur); + NewText->m_Size.x = NewText->m_Size.y = TextLabelSize; + } + break; + + case LAYER_GLOBLABEL: + NewText = new DrawGlobalLabelStruct(m_CurrentScreen->m_Curseur); + NewText->m_Size.x = NewText->m_Size.y = TextLabelSize; + ((DrawGlobalLabelStruct*)NewText)->m_Shape = ShapeGLabel; + break; + + default: + DisplayError(this, wxT("Editexte: Internal error") ); + break; + } + + NewText->m_Flags = IS_NEW | IS_MOVED; + + EditSchematicText(NewText, DC); + + if ( NewText->m_Text.IsEmpty() ) + { + delete NewText; + return NULL; + } + + RedrawOneStruct(DrawPanel, DC, NewText, GR_DEFAULT_DRAWMODE); + DrawPanel->ManageCurseur = ShowWhileMoving; + DrawPanel->ForceCloseManageCurseur = ExitMoveTexte; + + m_CurrentScreen->m_CurrentItem = NewText; + + return NewText; +} + + + + /****************************************/ + /* Dessin du Texte en deplacement */ + /****************************************/ +static void ShowWhileMoving(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +{ +EDA_BaseStruct * TextStruct = panel->GetScreen()->m_CurrentItem; + + /* effacement ancienne position */ + if( erase ) + RedrawOneStruct(panel, DC, TextStruct, g_XorMode); + + /* Redessin du texte */ + switch( TextStruct->m_StructType ) + { + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + ((DrawTextStruct*)TextStruct)->m_Pos = panel->GetScreen()->m_Curseur; + break; + + default: break; + } + + RedrawOneStruct(panel, DC, TextStruct, g_XorMode); +} + + +/*************************************************************/ +static void ExitMoveTexte(WinEDA_DrawPanel * Panel, wxDC *DC) +/*************************************************************/ +/* Routine de sortie des menus de Texte */ +{ +SCH_SCREEN * screen = (SCH_SCREEN *) Panel->m_Parent->m_CurrentScreen; +EDA_BaseStruct * Struct = screen->m_CurrentItem; + + g_ItemToRepeat = NULL; + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + + if( Struct == NULL) /* Pas de trace en cours */ + { + return; + } + + /* ici : trace en cours */ + + /* Effacement du trace en cours et suppression eventuelle de la structure */ + RedrawOneStruct(Panel, DC, Struct, g_XorMode); + + if( Struct->m_Flags & IS_NEW ) /* Suppression du nouveau texte en cours de placement */ + { + delete Struct; + screen->m_CurrentItem = NULL; + } + + else /* Remise a jour des anciens parametres du texte */ + { + switch( Struct->m_StructType ) + { + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + { + DrawTextStruct * Text = (DrawTextStruct *) Struct; + Text->m_Pos = ItemInitialPosition; + Text->m_Size = OldSize; + Text->m_Orient = OldOrient; + } + break; + + default: break; + } + + RedrawOneStruct(Panel, DC, Struct, GR_DEFAULT_DRAWMODE); + Struct->m_Flags = 0; + } +} + +/*****************************************************************************/ +void WinEDA_SchematicFrame::ConvertTextType(DrawTextStruct * Text, + wxDC * DC, int newtype) +/*****************************************************************************/ + +/* Routine to change a text type to an other one (GraphicText, label or Glabel). +*/ +{ + if ( Text == NULL ) return; + + /* save Text in undo list if not already in edit, or moving ... */ + if ( Text->m_Flags == 0 ) + SaveCopyInUndoList(Text, IS_CHANGED); + + DrawPanel->CursorOff(DC); // Erase schematic cursor + RedrawOneStruct(DrawPanel, DC, Text, g_XorMode); // erase drawing + switch( newtype ) + { + case DRAW_LABEL_STRUCT_TYPE: + Text->m_StructType = DRAW_LABEL_STRUCT_TYPE; + Text->m_Layer = LAYER_LOCLABEL; + break; + + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + Text->m_StructType = DRAW_GLOBAL_LABEL_STRUCT_TYPE; + Text->m_Layer = LAYER_GLOBLABEL; + break; + + case DRAW_TEXT_STRUCT_TYPE: + Text->m_StructType = DRAW_TEXT_STRUCT_TYPE; + Text->m_Layer = LAYER_NOTES; + break; + + default: + DisplayError(this, wxT("ConvertTextType: Internal error") ); + break; + } + + RedrawOneStruct(DrawPanel, DC, Text, GR_DEFAULT_DRAWMODE); + DrawPanel->CursorOn(DC); // redraw schematic cursor +} + + diff --git a/eeschema/editpart.cpp b/eeschema/editpart.cpp new file mode 100644 index 0000000000..92e9459e32 --- /dev/null +++ b/eeschema/editpart.cpp @@ -0,0 +1,795 @@ + /***************************************************/ + /* EESchema: */ + /* Edition des textes sur Composants en Schematique */ + /****************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "wx/checklst.h" + +#include "protos.h" + + +/* Fonctions exportees */ + +/* Fonctions locales */ +static void AbortMoveCmpField(WinEDA_DrawFrame * frame, wxDC * DC); +static void MoveCmpField(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); + +/* variables locales */ +static PartTextStruct * CurrentField; +static int Multiflag; +static int TextFieldSize = DEFAULT_SIZE_TEXT; +static wxPoint OldPos; + +/* Classe de la frame des propriétés d'un composant en librairie */ + +enum id_cmpedit { + ID_SCHEDIT_NOTEBOOK = 3200, + ID_PANEL_BASIC, + ID_PANEL_REFERENCE, + ID_PANEL_VALUE, + ID_PANEL_FIELD1, + ID_PANEL_FIELD2, + ID_PANEL_FIELD3, + ID_PANEL_FIELD4, + ID_PANEL_FIELD5, + ID_PANEL_FIELD6, + ID_PANEL_FIELD7, + ID_PANEL_FIELD8, + ID_PANEL_MODULEPCB, + ID_PANEL_SUBSCHEMATIC, + ID_CLOSE_CMP_PROPERTIES, + ID_ACCEPT_CMP_PROPERTIES, + ID_RESTORE_CMP_DEFAULTS +}; + + + /************************************/ + /* class WinEDA_PartPropertiesFrame */ + /************************************/ + +class WinEDA_ComponentPropertiesFrame: public wxDialog +{ +private: + + WinEDA_SchematicFrame * m_Parent; + EDA_SchComponentStruct * m_Cmp; + EDA_LibComponentStruct * m_LibEntry; + + wxCheckBox * m_ConvertButt; + wxRadioBox * m_SelectUnit; + wxRadioBox * m_MirrorUnit; + wxRadioBox * m_OrientUnit; + wxNotebook* m_NoteBook; + WinEDA_EnterText * m_RefInLib; + wxPanel * m_PanelBasic; + + wxPanel * m_PanelField[NUMBER_OF_FIELDS]; + + wxCheckBox * ShowFieldText[NUMBER_OF_FIELDS]; + wxCheckBox * VorientFieldText[NUMBER_OF_FIELDS]; + + WinEDA_GraphicTextCtrl * FieldTextCtrl[NUMBER_OF_FIELDS]; + WinEDA_PositionCtrl * FieldPosition[NUMBER_OF_FIELDS]; + int FieldFlags[NUMBER_OF_FIELDS]; + int FieldOrient[NUMBER_OF_FIELDS]; + +public: + // Constructor and destructor + WinEDA_ComponentPropertiesFrame(WinEDA_SchematicFrame *parent, wxPoint& pos, + EDA_SchComponentStruct * cmp); + ~WinEDA_ComponentPropertiesFrame(void) + { + } + +private: + void BuildPanelBasic(void); + void ComponentPropertiesAccept(wxCommandEvent& event); + void SetInitCmp( wxCommandEvent& event ); + void OnQuit(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(WinEDA_ComponentPropertiesFrame, wxDialog) + EVT_BUTTON(ID_ACCEPT_CMP_PROPERTIES, WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept) + EVT_BUTTON(ID_CLOSE_CMP_PROPERTIES, WinEDA_ComponentPropertiesFrame::OnQuit) + EVT_BUTTON(ID_RESTORE_CMP_DEFAULTS, WinEDA_ComponentPropertiesFrame::SetInitCmp) +END_EVENT_TABLE() + + +/**********************************************************************/ +void InstallCmpeditFrame(WinEDA_SchematicFrame * parent, wxPoint & pos, + EDA_SchComponentStruct * cmp) +/*********************************************************************/ +/* Create the dialog box for the current component edition +*/ +{ + parent->DrawPanel->m_IgnoreMouseEvents = TRUE; + if ( cmp->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + { + DisplayError( parent, wxT("InstallCmpeditFrame() error: This struct is not a component") ); + } + else + { + WinEDA_ComponentPropertiesFrame * frame = + new WinEDA_ComponentPropertiesFrame(parent, pos, cmp); + frame->ShowModal(); frame->Destroy(); + } + parent->DrawPanel->m_IgnoreMouseEvents = FALSE; +} + + + +#define XSIZE 370 +#define YSIZE 300 +/***********************************************************************************/ +WinEDA_ComponentPropertiesFrame::WinEDA_ComponentPropertiesFrame( + WinEDA_SchematicFrame *parent, wxPoint& framepos, EDA_SchComponentStruct * cmp) + : wxDialog(parent, -1, _("Component properties"), framepos, + wxSize(XSIZE, YSIZE), DIALOG_STYLE ) +/***********************************************************************************/ +{ +wxPoint pos, postmp; +wxLayoutConstraints* c; +wxPoint cmp_pos; +int ii; + + Centre(); + m_Parent = parent; + m_Cmp = cmp; + cmp_pos = m_Cmp->m_Pos; + m_LibEntry = FindLibPart(m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + + if ( m_LibEntry == NULL ) + { + SetTitle(_("Component properties (Not found in lib)")); + } + + SetAutoLayout(TRUE); + + m_NoteBook = new wxNotebook(this, ID_SCHEDIT_NOTEBOOK, + wxDefaultPosition,wxSize(XSIZE-6, YSIZE - 70) ); + c = new wxLayoutConstraints; + c->left.SameAs(this, wxLeft, 4); + c->right.SameAs(this, wxRight, 4); + c->top.SameAs(this, wxTop, 4); + c->bottom.SameAs(this, wxBottom, 40); + m_NoteBook->SetConstraints(c); + m_NoteBook->SetAutoLayout(TRUE); + + /* Creation des boutons de commande */ + pos.x = 40; pos.y = YSIZE - 60; + wxButton * GButton = new wxButton(this, ID_CLOSE_CMP_PROPERTIES, + _("Close"), pos); + GButton->SetForegroundColour(*wxBLUE); + c = new wxLayoutConstraints; + c->left.SameAs(this, wxLeft, 20); + c->height.AsIs(); + c->width.AsIs(); + c->bottom.SameAs(this, wxBottom, 5); + GButton->SetConstraints(c); + + pos.x += GButton->GetDefaultSize().x + 10; + wxButton * MButton = new wxButton(this, ID_RESTORE_CMP_DEFAULTS, + _("Defaults"), pos); + MButton->SetForegroundColour(*wxRED); + c = new wxLayoutConstraints; + c->left.SameAs(GButton, wxRight, 20); + c->height.AsIs(); + c->width.AsIs(); + c->bottom.SameAs(this, wxBottom, 5); + MButton->SetConstraints(c); + + pos.x += MButton->GetDefaultSize().x + 10; + wxButton * Button = new wxButton(this, ID_ACCEPT_CMP_PROPERTIES, + _("Ok"), pos); + Button->SetForegroundColour(*wxBLUE); + c = new wxLayoutConstraints; + c->left.SameAs(MButton, wxRight, 20); + c->height.AsIs(); + c->width.AsIs(); + c->bottom.SameAs(this, wxBottom, 5); + Button->SetConstraints(c); + + // Add panel Basic + BuildPanelBasic(); + m_NoteBook->AddPage(m_PanelBasic, _("Options"), TRUE); + + // Add panel Fields + for ( ii = 0; ii < NUMBER_OF_FIELDS; ii++) + { + m_PanelField[ii] = new wxPanel(m_NoteBook, ID_PANEL_REFERENCE + ii); + c = new wxLayoutConstraints; + c->left.SameAs(m_NoteBook, wxLeft); + c->right.SameAs(m_NoteBook, wxRight); + c->bottom.SameAs(m_NoteBook, wxBottom); + m_PanelField[ii]->SetConstraints(c); + m_NoteBook->AddPage(m_PanelField[ii], + DrawPartStruct::ReturnFieldName(ii), FALSE); + + pos.x = 10; pos.y = 20; + ShowFieldText[ii] = new wxCheckBox(m_PanelField[ii],-1, + _("Show Text"), pos); + if ( (m_Cmp->m_Field[ii].m_Attributs & TEXT_NO_VISIBLE ) == 0 ) + ShowFieldText[ii]->SetValue(TRUE); + + pos.x += 150; + VorientFieldText[ii] = new wxCheckBox(m_PanelField[ii],-1, + _("Vertical"), pos); + if ( m_Cmp->m_Field[ii].m_Orient ) VorientFieldText[ii]->SetValue(TRUE); + + pos.x = 10; pos.y += 50; + + wxPoint field_pos; + FieldTextCtrl[ii] = new WinEDA_GraphicTextCtrl( m_PanelField[ii], + DrawPartStruct::ReturnFieldName(ii), + m_Cmp->m_Field[ii].m_Text, + m_Cmp->m_Field[ii].m_Size.x, + g_UnitMetric , + pos, 200, TRUE); + field_pos.x = m_Cmp->m_Field[ii].m_Pos.x - cmp_pos.x; + field_pos.y = m_Cmp->m_Field[ii].m_Pos.y - cmp_pos.y; + if ( m_Cmp->m_Field[ii].m_Text == wxEmptyString ) // Field non initialisé, set pos a 0,0) + field_pos = wxPoint(0,0); + FieldPosition[ii] = new WinEDA_PositionCtrl( m_PanelField[ii], _("Pos"), + field_pos, + g_UnitMetric , + wxPoint (pos.x + 150, pos.y + 32), + m_Parent->m_InternalUnits ); + } + + if ( m_LibEntry && m_LibEntry->m_Options == ENTRY_POWER ) + FieldTextCtrl[VALUE]->Enable(FALSE); + +} + +/************************************************************************/ +void WinEDA_ComponentPropertiesFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/************************************************************************/ +{ + // true is to force the frame to close + Close(true); +} + + +/**********************************************************/ +void WinEDA_ComponentPropertiesFrame::BuildPanelBasic(void) +/**********************************************************/ +/* create the basic panel for component properties editing +*/ +{ +wxPoint pos, postmp; +int ii, jj; + + m_PanelBasic = new wxPanel(m_NoteBook, ID_PANEL_BASIC); + wxLayoutConstraints * c = new wxLayoutConstraints; + c->left.SameAs(m_NoteBook, wxLeft); + c->right.SameAs(m_NoteBook, wxRight); + c->bottom.SameAs(m_NoteBook, wxBottom); + m_PanelBasic->SetConstraints(c); + + pos.x = 5; pos.y = 15; + +#define NB_MAX_UNIT 16 +int nb_units = m_LibEntry ? MAX(m_LibEntry->m_UnitCount, 1) : 0; +wxString list_units[NB_MAX_UNIT]; + + if ( nb_units > 16 ) nb_units = 16; + for ( ii = 0; ii < NB_MAX_UNIT; ii++ ) + list_units[ii] << _("Unit") << (ii+1); + m_SelectUnit = new wxRadioBox(m_PanelBasic, -1, _("Unit:"), + pos, wxSize(-1,-1), + (nb_units < 8 ) ? 8 : nb_units, list_units, 1); + for ( ii = nb_units; ii < 8; ii++ ) + { + m_SelectUnit->Enable(ii, FALSE); // Disable non existant units + } + m_SelectUnit->SetSelection(m_Cmp->m_Multi -1); + + m_SelectUnit->GetSize(&ii, &jj); + pos.x += ii + 5; postmp = pos; + +wxString list_orient[4] = { wxT("0"), wxT("+90"), wxT("180"), wxT("-90") }; + pos.x += 45; pos.y = 15; + m_OrientUnit = new wxRadioBox(m_PanelBasic, -1, _("Orient:"), + pos, wxSize(-1,-1), 4, list_orient, 1); + ii = m_Cmp->GetRotationMiroir() & ~(CMP_MIROIR_X|CMP_MIROIR_Y); + + if ( ii == CMP_ORIENT_90) m_OrientUnit->SetSelection(1); + else if ( ii == CMP_ORIENT_180) m_OrientUnit->SetSelection(2); + else if ( ii == CMP_ORIENT_270) m_OrientUnit->SetSelection(3); + + m_OrientUnit->GetSize(&ii, &jj); + pos.x += ii + 30; +wxString list_mirror[3] = { _("Normal"), _("Mirror --"), _("Mirror |")}; + m_MirrorUnit = new wxRadioBox(m_PanelBasic, -1, _("Mirror:"), + pos, wxSize(-1,-1), 3, list_mirror, 1); + ii = m_Cmp->GetRotationMiroir() & (CMP_MIROIR_X|CMP_MIROIR_Y) ; + if ( ii == CMP_MIROIR_X ) m_MirrorUnit->SetSelection(1); + else if ( ii == CMP_MIROIR_Y ) m_MirrorUnit->SetSelection(2); + + // Positionnement de la selection normal/convert + m_OrientUnit->GetSize(&ii, &jj); + pos = postmp; + pos.y += jj + 10; + m_ConvertButt = new wxCheckBox(m_PanelBasic,-1, _("Convert"), pos); + if ( m_Cmp->m_Convert > 1 ) m_ConvertButt->SetValue(TRUE); + + if ( (m_LibEntry == NULL) || LookForConvertPart(m_LibEntry) <= 1) + { + m_ConvertButt->Enable(FALSE); + } + + // Show the "Parts Locked" option: + if ( m_LibEntry && m_LibEntry->m_UnitSelectionLocked ) + { + new wxStaticText(m_PanelBasic, -1, _("Parts are locked"), + wxPoint(m_MirrorUnit->GetRect().x, pos.y) ); + } + + // Positionnement de la reference en librairie + m_ConvertButt->GetSize(&ii, &jj); + pos.y += jj + 20; + m_RefInLib = new WinEDA_EnterText(m_PanelBasic, _("Chip Name:"), + m_Cmp->m_ChipName, + pos, wxSize(XSIZE - pos.x - 30, -1) ); + +} + + +/***********************************************************************************/ +void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept(wxCommandEvent& event) +/***********************************************************************************/ +/* Update the new parameters for the current edited component +*/ +{ +wxPoint cmp_pos = m_Cmp->m_Pos; +wxClientDC dc(m_Parent->DrawPanel); +wxString newname; + + m_Parent->DrawPanel->PrepareGraphicContext(&dc); + + RedrawOneStruct(m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode); + + newname = m_RefInLib->GetValue(); + newname.MakeUpper(); + newname.Replace(wxT(" "), wxT("_")); + + if ( newname.IsEmpty() ) DisplayError(this, _("No Component Name!")); + else if ( newname.CmpNoCase(m_Cmp->m_ChipName) ) + { + if ( FindLibPart(newname.GetData(), wxEmptyString, FIND_ALIAS) == NULL ) + { + wxString msg; + msg.Printf( _("Component [%s] not found!"), newname.GetData() ); + DisplayError(this, msg); + } + else // Changement de composant! + { + m_Cmp->m_ChipName = newname; + } + } + + // Mise a jour de la representation: + if ( m_ConvertButt->IsEnabled() ) + (m_ConvertButt->GetValue() == TRUE) ? + m_Cmp->m_Convert = 2 : m_Cmp->m_Convert = 1; + + //Mise a jour de la selection de l'élément dans le boitier + if ( m_Cmp->m_Multi ) m_Cmp->m_Multi = m_SelectUnit->GetSelection() + 1; + + //Mise a jour de l'orientation: + switch (m_OrientUnit->GetSelection() ) + { + case 0: + m_Cmp->SetRotationMiroir(CMP_ORIENT_0); + break; + case 1: + m_Cmp->SetRotationMiroir(CMP_ORIENT_90); + break; + case 2: + m_Cmp->SetRotationMiroir(CMP_ORIENT_180); + break; + case 3: + m_Cmp->SetRotationMiroir(CMP_ORIENT_270); + break; + } + + switch (m_MirrorUnit->GetSelection() ) + { + case 0: + break; + case 1: + m_Cmp->SetRotationMiroir(CMP_MIROIR_X); + break; + case 2: + m_Cmp->SetRotationMiroir(CMP_MIROIR_Y); + break; + } + + + // Mise a jour des textes + for ( int ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ ) + { + if( ii == REFERENCE ) // la reference ne peut etre vide + { + if ( ! FieldTextCtrl[ii]->GetText().IsEmpty() ) + m_Cmp->m_Field[ii].m_Text = FieldTextCtrl[ii]->GetText(); + } + else if( ii == VALUE ) // la valeur ne peut etre vide et ne peut etre change sur un POWER + { + EDA_LibComponentStruct *Entry = FindLibPart(m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if( Entry && (Entry->m_Options == ENTRY_POWER) ) + m_Cmp->m_Field[ii].m_Text = m_Cmp->m_ChipName; + else if ( ! FieldTextCtrl[ii]->GetText().IsEmpty() ) + { + m_Cmp->m_Field[ii].m_Text = FieldTextCtrl[ii]->GetText(); + } + } + else + m_Cmp->m_Field[ii].m_Text = FieldTextCtrl[ii]->GetText(); + + m_Cmp->m_Field[ii].m_Size.x = + m_Cmp->m_Field[ii].m_Size.y = FieldTextCtrl[ii]->GetTextSize(); + if ( ShowFieldText[ii]->GetValue() ) + m_Cmp->m_Field[ii].m_Attributs &= ~TEXT_NO_VISIBLE; + else + m_Cmp->m_Field[ii].m_Attributs |= TEXT_NO_VISIBLE; + m_Cmp->m_Field[ii].m_Orient = VorientFieldText[ii]->GetValue() ? 1 : 0; + m_Cmp->m_Field[ii].m_Pos = FieldPosition[ii]->GetValue(); + m_Cmp->m_Field[ii].m_Pos.x += cmp_pos.x; + m_Cmp->m_Field[ii].m_Pos.y += cmp_pos.y; + } + m_Parent->m_CurrentScreen->SetModify(); + + RedrawOneStruct(m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE); + m_Parent->TestDanglingEnds(m_Parent->m_CurrentScreen->EEDrawList, &dc); + + Close(); +} + + + +/************************************************************************************/ +void WinEDA_SchematicFrame::StartMoveCmpField(PartTextStruct * Field, wxDC * DC) +/************************************************************************************/ +/* Prepare le deplacement du texte en cours d'edition +*/ +{ +EDA_LibComponentStruct *Entry; + + CurrentField = Field; + if ( Field == NULL ) return; + + if(Field->m_Text == wxEmptyString) + { + DisplayError(this, _("No Field to move"), 10); + return; + } + + OldPos = Field->m_Pos; + Multiflag = 0; + if( Field->m_FieldId == REFERENCE ) + { + Entry = FindLibPart( ((EDA_SchComponentStruct*)Field->m_Parent)->m_ChipName.GetData(), + wxEmptyString, FIND_ROOT); + if( Entry != NULL ) + { + if ( Entry->m_UnitCount > 1 ) Multiflag = 1; + } + } + + DrawPanel->ForceCloseManageCurseur = AbortMoveCmpField; + DrawPanel->ManageCurseur = MoveCmpField; + Field->m_Flags = IS_MOVED; +} + + +/**********************************************************************************/ +void WinEDA_SchematicFrame::EditCmpFieldText(PartTextStruct * Field, wxDC *DC) +/**********************************************************************************/ +/* Routine de changement du texte selectionne */ +{ +int FieldNumber, flag; +EDA_LibComponentStruct *Entry; + + if( Field == NULL ) + { + DisplayError(this, _("No Field To Edit"), 10); + return; + } + + FieldNumber = Field->m_FieldId; + if( FieldNumber == VALUE ) + { + Entry = FindLibPart( ((EDA_SchComponentStruct*)Field->m_Parent)->m_ChipName.GetData(), + wxEmptyString, FIND_ROOT); + if( Entry && (Entry->m_Options == ENTRY_POWER) ) + { + DisplayInfo(this, + _("Part is a POWER, value cannot be modified!\nYou must create a new power") ); + return; + } + } + + flag = 0; + if( FieldNumber == REFERENCE ) + { + Entry = FindLibPart( ((EDA_SchComponentStruct*)Field->m_Parent)->m_ChipName.GetData(), + wxEmptyString, FIND_ROOT); + if( Entry != NULL ) + { + if ( Entry->m_UnitCount > 1 ) flag = 1; + } + } + + + wxString newtext = Field->m_Text; + Get_Message(DrawPartStruct::ReturnFieldName(FieldNumber), newtext, this); + + DrawTextField(DrawPanel, DC, Field, flag, g_XorMode); + + if ( ! newtext.IsEmpty() ) + { + if (Field->m_Text.IsEmpty()) + { + Field->m_Pos = ((EDA_SchComponentStruct*)Field->m_Parent)->m_Pos; + Field->m_Size.x = Field->m_Size.y = TextFieldSize; + } + Field->m_Text = newtext; + } + + else /* Nouveau texte NULL */ + { + if( FieldNumber == REFERENCE ) + { + DisplayError(this, _("Reference needed !, No change")); + } + else if( FieldNumber == VALUE ) + { + DisplayError(this, _("Value needed !, No change")); + } + else + { + Field->m_Text = wxT("~"); + } + } + + DrawTextField(DrawPanel, DC, Field, flag, g_XorMode); + ((EDA_SchComponentStruct*)Field->m_Parent)->Display_Infos(this); + m_CurrentScreen->SetModify(); +} + + +/************************************************************************/ +static void MoveCmpField(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/************************************************************************/ +/* Routine de deplacement d'un texte type Field. + Celle routine est normalement attachee au deplacement du curseur +*/ +{ +#define TRF ((EDA_SchComponentStruct*)CurrentField->m_Parent)->m_Transform +wxPoint pos; +int x1, y1; +int FieldNumber; + + if( CurrentField == NULL) return; + + FieldNumber = CurrentField->m_FieldId; + + /* Effacement: */ + if( erase ) + DrawTextField(panel, DC, CurrentField, Multiflag, g_XorMode); + + pos = ((EDA_SchComponentStruct*)CurrentField->m_Parent)->m_Pos; + + /* Les positions sont caculees par la matrice TRANSPOSEE de la matrice + de rotation-miroir */ + x1 = panel->GetScreen()->m_Curseur.x - pos.x; + y1 = panel->GetScreen()->m_Curseur.y - pos.y; + CurrentField->m_Pos.x = pos.x + TRF[0][0] * x1 + TRF[1][0] * y1; + CurrentField->m_Pos.y = pos.y + TRF[0][1] * x1 + TRF[1][1] * y1; + + DrawTextField(panel, DC, CurrentField, Multiflag, g_XorMode); +} + + +/******************************************************************/ +static void AbortMoveCmpField(WinEDA_DrawFrame * frame, wxDC * DC) +/******************************************************************/ +{ + frame->DrawPanel->ForceCloseManageCurseur = NULL; + frame->DrawPanel->ManageCurseur = NULL; + if ( CurrentField ) + { + DrawTextField(frame->DrawPanel, DC, CurrentField,Multiflag, g_XorMode); + CurrentField->m_Flags = 0; + CurrentField->m_Pos = OldPos; + DrawTextField(frame->DrawPanel, DC, CurrentField,Multiflag, GR_DEFAULT_DRAWMODE); + } + CurrentField = NULL; +} + +/*********************************************************************************/ +void WinEDA_SchematicFrame::RotateCmpField(PartTextStruct * Field, wxDC * DC) +/*********************************************************************************/ +{ +int FieldNumber, flag; +EDA_LibComponentStruct *Entry; + + if (Field == NULL ) return; + if (Field->m_Text == wxEmptyString ) return; + + FieldNumber = Field->m_FieldId; + flag = 0; + if( FieldNumber == REFERENCE ) + { + Entry = FindLibPart( ((EDA_SchComponentStruct*)Field->m_Parent)->m_ChipName.GetData(), + wxEmptyString, FIND_ROOT); + if( Entry != NULL ) + { + if ( Entry->m_UnitCount > 1 ) flag = 1; + } + } + + DrawTextField(DrawPanel, DC, Field, flag, g_XorMode); + + if( Field->m_Orient == TEXT_ORIENT_HORIZ ) Field->m_Orient = TEXT_ORIENT_VERT; + else Field->m_Orient = TEXT_ORIENT_HORIZ; + DrawTextField(DrawPanel, DC, Field,flag, g_XorMode); + + GetScreen()->SetModify(); +} + + +/***************************************************************/ +void PartTextStruct::Place( WinEDA_DrawFrame * frame, wxDC * DC) +/***************************************************************/ +{ +int FieldNumber, flag; +EDA_LibComponentStruct *Entry; + + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; + + FieldNumber = m_FieldId; + flag = 0; + if( FieldNumber == REFERENCE ) + { + Entry = FindLibPart( ((EDA_SchComponentStruct*)m_Parent)->m_ChipName.GetData(), + wxEmptyString, FIND_ROOT); + if( Entry != NULL ) + { + if ( Entry->m_UnitCount > 1 ) flag = 1; + } + } + + DrawTextField(frame->DrawPanel, DC, this, flag, GR_DEFAULT_DRAWMODE); + m_Flags = 0; + frame->GetScreen()->m_CurrentItem = NULL; + frame->GetScreen()->SetModify(); + CurrentField = NULL; +} + + + +/**************************************************************************************************/ +void WinEDA_SchematicFrame::EditComponentReference(EDA_SchComponentStruct * DrawLibItem, wxDC * DC) +/**************************************************************************************************/ +/* Edit the component text reference*/ +{ +wxString msg; +EDA_LibComponentStruct *Entry; +int flag = 0; + + if( DrawLibItem == NULL ) return; + + Entry = FindLibPart(DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if ( Entry == NULL ) return; + + if ( Entry->m_UnitCount > 1 ) flag = 1; + + PartTextStruct * TextField = &DrawLibItem->m_Field[REFERENCE]; + + msg = TextField->m_Text; + Get_Message(_("Reference") , msg, this); + + if ( ! msg.IsEmpty() ) // New text entered + { + DrawTextField(DrawPanel, DC, &DrawLibItem->m_Field[REFERENCE], flag, g_XorMode); + TextField->m_Text = msg; + DrawTextField(DrawPanel, DC, &DrawLibItem->m_Field[REFERENCE], flag, + DrawLibItem->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE); + GetScreen()->SetModify(); + } + DrawLibItem->Display_Infos(this); +} + +/*****************************************************************************************/ +void WinEDA_SchematicFrame::EditComponentValue(EDA_SchComponentStruct * DrawLibItem, wxDC * DC) +/*****************************************************************************************/ +/* Routine de changement du texte selectionne */ +{ +wxString msg; +EDA_LibComponentStruct *Entry; +int flag = 0; + + if( DrawLibItem == NULL ) return; + + Entry = FindLibPart(DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if ( Entry == NULL ) return; + if ( Entry->m_UnitCount > 1 ) flag = 1; + + PartTextStruct * TextField = &DrawLibItem->m_Field[VALUE]; + + msg = TextField->m_Text; + Get_Message(_("Value") , msg, this); + + if ( ! msg.IsEmpty() ) + { + DrawTextField(DrawPanel, DC, &DrawLibItem->m_Field[VALUE], flag, g_XorMode); + TextField->m_Text = msg; + DrawTextField(DrawPanel, DC, &DrawLibItem->m_Field[VALUE], flag, + DrawLibItem->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE); + m_CurrentScreen->SetModify(); + } + + DrawLibItem->Display_Infos(this); +} + +/*****************************************************************************/ +void WinEDA_ComponentPropertiesFrame::SetInitCmp( wxCommandEvent& event ) +/*****************************************************************************/ +/* Replace le composant en position normale, dimensions et positions + fields comme definies en librairie +*/ +{ +EDA_LibComponentStruct *Entry; + + if ( m_Cmp == NULL ) return; + + Entry = FindLibPart(m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + + if( Entry == NULL) return; + +wxClientDC dc(m_Parent->DrawPanel); + m_Parent->DrawPanel->PrepareGraphicContext(&dc); + + RedrawOneStruct(m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode); + + /* Mise aux valeurs par defaut des champs et orientation */ + m_Cmp->m_Field[REFERENCE].m_Pos.x = + Entry->m_Prefix.m_Pos.x + m_Cmp->m_Pos.x; + m_Cmp->m_Field[REFERENCE].m_Pos.y = + Entry->m_Prefix.m_Pos.y + m_Cmp->m_Pos.y; + m_Cmp->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient; + m_Cmp->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size; + m_Cmp->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify; + m_Cmp->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify; + + m_Cmp->m_Field[VALUE].m_Pos.x = + Entry->m_Name.m_Pos.x + m_Cmp->m_Pos.x; + m_Cmp->m_Field[VALUE].m_Pos.y = + Entry->m_Name.m_Pos.y + m_Cmp->m_Pos.y; + m_Cmp->m_Field[VALUE].m_Orient = Entry->m_Name.m_Orient; + m_Cmp->m_Field[VALUE].m_Size = Entry->m_Name.m_Size; + m_Cmp->m_Field[VALUE].m_HJustify = Entry->m_Name.m_HJustify; + m_Cmp->m_Field[VALUE].m_VJustify = Entry->m_Name.m_VJustify; + + m_Cmp->SetRotationMiroir(CMP_NORMAL); + + m_Parent->m_CurrentScreen->SetModify(); + + RedrawOneStruct(m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE); + Close(); +} + + diff --git a/eeschema/eeclass.cpp b/eeschema/eeclass.cpp new file mode 100644 index 0000000000..66403af1ce --- /dev/null +++ b/eeschema/eeclass.cpp @@ -0,0 +1,118 @@ +/**********************************************************/ +/* EECLASS.CPP */ +/* fonctions relatives aux classes definies dans EESCHEMA */ +/**********************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + + +/************************************************************/ +void SetStructFather(EDA_BaseStruct * Struct, BASE_SCREEN * Screen) +/************************************************************/ +{ + switch( Struct->m_StructType ) + { + case DRAW_POLYLINE_STRUCT_TYPE: + case DRAW_JUNCTION_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_LIB_ITEM_STRUCT_TYPE: + case DRAW_SEGMENT_STRUCT_TYPE: + case DRAW_BUSENTRY_STRUCT_TYPE: + case DRAW_SHEET_STRUCT_TYPE: + case DRAW_MARKER_STRUCT_TYPE: + case DRAW_NOCONNECT_STRUCT_TYPE: + Struct->m_Parent = Screen; + break; + + case DRAW_SHEETLABEL_STRUCT_TYPE: + case DRAW_PICK_ITEM_STRUCT_TYPE: + break; + + default: + break; + } +} + +/*************************************************************/ +void EDA_BaseStruct::Place(WinEDA_DrawFrame * frame, wxDC * DC) +/*************************************************************/ +{ + if( m_Flags & IS_NEW) + { + Pnext = frame->m_CurrentScreen->EEDrawList; + frame->m_CurrentScreen->EEDrawList = this; + g_ItemToRepeat = this; + } + + m_Flags = 0; + SetFlagModify(frame->GetScreen()); + frame->GetScreen()->m_CurrentItem = NULL; + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; + + frame->DrawPanel->CursorOff(DC); // Erase schematic cursor + RedrawOneStruct(frame->DrawPanel, DC, this, GR_DEFAULT_DRAWMODE); + frame->DrawPanel->CursorOn(DC); // Display schematic cursor +} + + + /**************************************************/ + /* Class SCH_SCREEN: classe de gestion d'un affichage pour schematique */ + /***************************************************/ +static int table_zoom[] = {1,2,4,8,16,32,64,128, 0}; /* Valeurs standards du zoom */ + +/* Constructeur de SCREEN */ +SCH_SCREEN::SCH_SCREEN(EDA_BaseStruct * parent, WinEDA_DrawFrame * frame_source, int idtype): + BASE_SCREEN(parent, frame_source, idtype) +{ + EEDrawList = NULL; /* Schematic items list */ + m_Zoom = 32; + m_Grid = wxSize(50,50); /* pas de la grille */ + SetZoomList(table_zoom); + SetGridList(g_GridList); + m_UndoRedoCountMax = 10; + +} + +/****************************/ +SCH_SCREEN::~SCH_SCREEN(void) +/****************************/ +{ + ClearUndoRedoList(); + FreeDrawList(); +} + +/*************************************/ +SCH_SCREEN * SCH_SCREEN::GenCopy(void) +/*************************************/ +{ +// TODO + return NULL; +} + +/***********************************/ +void SCH_SCREEN::FreeDrawList(void) +/***********************************/ +/* Routine to clear EESchema drawing list of a screen. +*/ +{ +EDA_BaseStruct *DrawStruct; + + while (EEDrawList != NULL) + { + DrawStruct = EEDrawList; + EEDrawList = EEDrawList->Pnext; + delete DrawStruct; + } +} + diff --git a/eeschema/eeconfig.cpp b/eeschema/eeconfig.cpp new file mode 100644 index 0000000000..229eaf0705 --- /dev/null +++ b/eeschema/eeconfig.cpp @@ -0,0 +1,155 @@ + /******************************************************/ + /** eeconfig.cpp : routines et menus de configuration */ +/*******************************************************/ + +#include "fctsys.h" +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "protos.h" +#include "eeconfig.h" +#include "worksheet.h" + +#include "id.h" + +/* Variables locales */ + + +/*********************************************************************/ +void WinEDA_SchematicFrame::Process_Config(wxCommandEvent& event) +/*********************************************************************/ +{ +int id = event.GetId(); +wxPoint pos; + + wxGetMousePosition(&pos.x, &pos.y); + + pos.y += 5; + switch ( id ) + { + case ID_COLORS_SETUP : + DisplayColorSetupFrame(this, pos); + break; + + case ID_CONFIG_REQ : // Creation de la fenetre de configuration + { + InstallConfigFrame(pos); + break; + } + + case ID_OPTIONS_SETUP: + DisplayOptionFrame(this, pos); + break; + + case ID_CONFIG_SAVE: + Save_Config(this); + break; + + case ID_CONFIG_READ: + { + wxString mask( wxT("*") ); mask += g_Prj_Config_Filename_ext; + wxString FullFileName = ScreenSch->m_FileName; + ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); + + FullFileName = EDA_FileSelector(_("Read config file"), + wxGetCwd(), /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + g_Prj_Config_Filename_ext, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_OPEN, + TRUE /* ne change pas de repertoire courant */ + ); + if ( FullFileName.IsEmpty() ) break; + if ( ! wxFileExists(FullFileName) ) + { + wxString msg = _("File ") + FullFileName +_("not found");; + DisplayError(this, msg); break; + } + Read_Config(FullFileName, TRUE ); + } + break; + + default: + DisplayError(this, wxT("WinEDA_SchematicFrame::Process_Config internal error") ); + } +} + + +/***********************************************************************/ +bool Read_Config( const wxString & CfgFileName, bool ForceRereadConfig ) +/***********************************************************************/ +/* lit la configuration, si elle n'a pas deja ete lue + 1 - lit .pro + 2 - si non trouve lit ../template/kicad.pro + 3 - si non trouve: init des variables aux valeurs par defaut + + Retourne TRUE si lu, FALSE si config non lue +*/ +{ +wxString FullFileName; +bool IsRead = TRUE; +wxArrayString liblist_tmp = g_LibName_List; + + if ( CfgFileName.IsEmpty() ) FullFileName = ScreenSch->m_FileName; + else FullFileName = CfgFileName; + g_LibName_List.Clear(); + + if ( ! EDA_Appl->ReadProjectConfig(FullFileName, + GROUP, ParamCfgList, ForceRereadConfig ? FALSE : TRUE) ) // Config non lue + { + g_LibName_List = liblist_tmp; + IsRead = FALSE; + } + + /* Traitement des variables particulieres: */ + SetRealLibraryPath( wxT("library") ); + + // If the list is void, load the libraries "power.lib" and "device.lib" + if ( g_LibName_List.GetCount() == 0 ) + { + g_LibName_List.Add( wxT("power") ); + g_LibName_List.Add( wxT("device") ); + } + + if ( EDA_Appl->SchematicFrame ) + { + EDA_Appl->SchematicFrame->SetDrawBgColor(g_DrawBgColor); + EDA_Appl->SchematicFrame->m_Draw_Grid = g_ShowGrid; + } + + LoadLibraries(EDA_Appl->SchematicFrame); + + return IsRead; +} + + + +/****************************************************************/ +void WinEDA_SchematicFrame::Save_Config(wxWindow * displayframe) +/***************************************************************/ +{ +wxString path; +wxString FullFileName; +wxString mask( wxT("*") ); + + mask += g_Prj_Config_Filename_ext; + FullFileName = ScreenSch->m_FileName.AfterLast('/') /*ConfigFileName*/; + ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); + + path = wxGetCwd(); + FullFileName = EDA_FileSelector(_("Save config file"), + path, /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + g_Prj_Config_Filename_ext, /* extension par defaut */ + mask, /* Masque d'affichage */ + displayframe, + wxFD_SAVE, + TRUE + ); + if ( FullFileName.IsEmpty() ) return; + + /* ecriture de la configuration */ + EDA_Appl->WriteProjectConfig(FullFileName, GROUP, ParamCfgList); +} diff --git a/eeschema/eeconfig.h b/eeschema/eeconfig.h new file mode 100644 index 0000000000..b8dc1d402e --- /dev/null +++ b/eeschema/eeconfig.h @@ -0,0 +1,537 @@ + /************************************************************/ + /** eeconfig.h : configuration: definition des structures **/ + /************************************************************/ + +#ifndef eda_global +#define eda_global extern +#endif + +#define GROUP wxT("/eeschema") +#define GROUPCOMMON wxT("/common") +#define GROUPLIB wxT("libraries") + +#include "netlist.h" /* Definitions generales liees au calcul de netliste */ + +/* variables importees */ +extern int PenMinWidth; + +/* Liste des parametres */ + +#define INSETUP TRUE + + +static PARAM_CFG_WXSTRING UserLibDirBufCfg + ( + wxT("LibDir"), /* identification */ + &g_UserLibDirBuffer /* Adresse du parametre */ + ); + + +static PARAM_CFG_LIBNAME_LIST LibNameBufCfg +( + wxT("LibName"), /* identification */ + &g_LibName_List, /* Adresse du parametre */ + GROUPLIB /* Groupe */ +); + +static PARAM_CFG_INT NetFormatCfg +( + wxT("NetFmt"), /* identification */ + &g_NetFormat, /* Adresse du parametre */ + NET_TYPE_PCBNEW, /* Valeur par defaut */ + NET_TYPE_NOT_INIT, NET_TYPE_MAX-1 /* Valeurs extremes */ +); + +static PARAM_CFG_INT UnitCfg +( + INSETUP, + wxT("Unite"), /* identification */ + &g_UnitMetric, /* Adresse du parametre */ + 0, /* Valeur par defaut */ + 0, 1 /* Valeurs extremes */ +); + +static PARAM_CFG_INT CursorShapeCfg +( + INSETUP, + wxT("CuShape"), /* identification */ + &g_CursorShape, /* Adresse du parametre */ + 0, /* Valeur par defaut */ + 0, 1 /* Valeurs extremes */ +); + +static PARAM_CFG_INT ShowGridCfg +( + INSETUP, + wxT("ShGrid"), /* identification */ + &g_ShowGrid, /* Adresse du parametre */ + 0, 1, /* Valeurs extremes */ + 1 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR DrawBgColorCfg +( + INSETUP, + wxT("BgColor"), /* identification */ + &g_DrawBgColor, /* Adresse du parametre */ + WHITE /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerWireCfg +( + INSETUP, + wxT("ColWire"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_WIRE], /* Adresse du parametre */ + GREEN /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerBusCfg +( + INSETUP, + wxT("ColorBus"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_BUS], /* Adresse du parametre */ + BLUE /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerJunctionCfg +( + INSETUP, + wxT("ColorConn"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_JUNCTION], /* Adresse du parametre */ + GREEN /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerLLabelCfg +( + INSETUP, + wxT("ColorLlab"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_LOCLABEL], /* Adresse du parametre */ + BLACK /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerGLabelCfg +( + INSETUP, + wxT("ColorGlab"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_GLOBLABEL], /* Adresse du parametre */ + BROWN /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerPinFunCfg +( + INSETUP, + wxT("ColorPinF"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_PINFUN], /* Adresse du parametre */ + MAGENTA /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerPinNumCfg +( + INSETUP, + wxT("ColPinN"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_PINNUM], /* Adresse du parametre */ + RED /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerPinNamCfg +( + INSETUP, + wxT("ColorPNam"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_PINNAM], /* Adresse du parametre */ + CYAN /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerFieldsCfg +( + INSETUP, + wxT("ColorField"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_FIELDS], /* Adresse du parametre */ + MAGENTA /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerReferenceCfg +( + INSETUP, + wxT("ColorRef"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_REFERENCEPART], /* Adresse du parametre */ + CYAN /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerValueCfg +( + INSETUP, + wxT("ColorValue"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_VALUEPART], /* Adresse du parametre */ + CYAN /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerNotesCfg +( + INSETUP, + wxT("ColorNote"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_NOTES], /* Adresse du parametre */ + LIGHTBLUE /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerBodyCfg +( + INSETUP, + wxT("ColorBody"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_DEVICE], /* Adresse du parametre */ + RED /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerBodyBackgroundCfg +( + INSETUP, + wxT("ColorBodyBg"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_DEVICE_BACKGROUND], /* Adresse du parametre */ + LIGHTYELLOW /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerNetNameCfg +( + INSETUP, + wxT("ColorNetN"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_NETNAM], /* Adresse du parametre */ + DARKGRAY /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerPinCfg +( + INSETUP, + wxT("ColorPin"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_PIN], /* Adresse du parametre */ + RED /* Valeur par defaut */ +); + + +static PARAM_CFG_SETCOLOR ColorLayerSheetCfg +( + INSETUP, + wxT("ColorSheet"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_SHEET], /* Adresse du parametre */ + MAGENTA /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerSheetFileNameCfg +( + INSETUP, + wxT("ColorSheetFileName"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_SHEETFILENAME], /* Adresse du parametre */ + BROWN /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerSheetNameCfg +( + INSETUP, + wxT("ColorSheetName"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_SHEETNAME], /* Adresse du parametre */ + CYAN /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerSheetLabelCfg +( + INSETUP, + wxT("ColorSheetLab"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_SHEETLABEL], /* Adresse du parametre */ + BROWN /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerNoConnectCfg +( + INSETUP, + wxT("ColorNoCo"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_NOCONNECT], /* Adresse du parametre */ + BLUE /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerErcWarnCfg +( + INSETUP, + wxT("ColorErcW"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_ERC_WARN], /* Adresse du parametre */ + GREEN /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayerErcErrCfg +( + INSETUP, + wxT("ColorErcE"), /* identification */ + &g_LayerDescr.LayerColor[LAYER_ERC_ERR], /* Adresse du parametre */ + RED /* Valeur par defaut */ +); + +static PARAM_CFG_INT PlotMarginCfg +( + INSETUP, + wxT("Pltmarg"), /* identification */ + &g_PlotMargin, /* Adresse du parametre */ + 300, /* Valeur par defaut */ + 0,10000 /* Valeurs extremes */ +); + +static PARAM_CFG_INT HPGLSpeed +( + wxT("HPGLSpd"), /* identification */ + &g_HPGL_Pen_Descr.m_Pen_Speed, /* Adresse du parametre */ + 20, /* Valeur par defaut */ + 2,45 /* Valeurs extremes */ +); + +static PARAM_CFG_INT HPGLDiam +( + wxT("HPGLDm"), /* identification */ + &g_HPGL_Pen_Descr.m_Pen_Diam, /* Adresse du parametre */ + 15, /* Valeur par defaut */ + 1,150 /* Valeurs extremes */ +); + +static PARAM_CFG_INT HPGLPenNum +( + wxT("HPGLNum"), /* identification */ + &g_HPGL_Pen_Descr.m_Pen_Num, /* Adresse du parametre */ + 1, /* Valeur par defaut */ + 1,8 /* Valeurs extremes */ +); + +static PARAM_CFG_INT PlotSheetOffsetX_A4 +( + wxT("offX_A4"), /* identification */ + &g_Sheet_A4.m_Offset.x /* Adresse du parametre */ +); + +static PARAM_CFG_INT PlotSheetOffsetY_A4 +( + wxT("offY_A4"), /* identification */ + &g_Sheet_A4.m_Offset.y /* Adresse du parametre */ +); + +static PARAM_CFG_INT PlotSheetOffsetX_A3 +( + wxT("offX_A3"), /* identification */ + &g_Sheet_A3.m_Offset.x /* Adresse du parametre */ +); + +static PARAM_CFG_INT PlotSheetOffsetY_A3 +( + wxT("offY_A3"), /* identification */ + &g_Sheet_A3.m_Offset.y /* Adresse du parametre */ +); + +static PARAM_CFG_INT PlotSheetOffsetX_A2 +( + wxT("offX_A2"), /* identification */ + &g_Sheet_A2.m_Offset.x /* Adresse du parametre */ +); + +static PARAM_CFG_INT PlotSheetOffsetY_A2 +( + wxT("offY_A2"), /* identification */ + &g_Sheet_A2.m_Offset.y /* Adresse du parametre */ +); + + +static PARAM_CFG_INT PlotSheetOffsetX_A1 +( + wxT("offX_A1"), /* identification */ + &g_Sheet_A1.m_Offset.x /* Adresse du parametre */ +); + +static PARAM_CFG_INT PlotSheetOffsetY_A1 +( + wxT("offY_A1"), /* identification */ + &g_Sheet_A1.m_Offset.y /* Adresse du parametre */ +); + + +static PARAM_CFG_INT PlotSheetOffsetX_A0 +( + wxT("offX_A0"), /* identification */ + &g_Sheet_A0.m_Offset.x /* Adresse du parametre */ +); + +static PARAM_CFG_INT PlotSheetOffsetY_A0 +( + wxT("offY_A0"), /* identification */ + &g_Sheet_A0.m_Offset.y /* Adresse du parametre */ +); + + +static PARAM_CFG_INT PlotSheetOffsetX_A +( + wxT("offX_A"), /* identification */ + &g_Sheet_A.m_Offset.x /* Adresse du parametre */ +); + +static PARAM_CFG_INT PlotSheetOffsetY_A +( + wxT("offY_A"), /* identification */ + &g_Sheet_A.m_Offset.y /* Adresse du parametre */ +); + + +static PARAM_CFG_INT PlotSheetOffsetX_B +( + wxT("offX_B"), /* identification */ + &g_Sheet_B.m_Offset.x /* Adresse du parametre */ +); + +static PARAM_CFG_INT PlotSheetOffsetY_B +( + wxT("offY_B"), /* identification */ + &g_Sheet_B.m_Offset.y /* Adresse du parametre */ +); + + +static PARAM_CFG_INT PlotSheetOffsetX_C +( + wxT("offX_C"), /* identification */ + &g_Sheet_C.m_Offset.x /* Adresse du parametre */ +); + +static PARAM_CFG_INT PlotSheetOffsetY_C +( + wxT("offY_C"), /* identification */ + &g_Sheet_C.m_Offset.y /* Adresse du parametre */ +); + + +static PARAM_CFG_INT PlotSheetOffsetX_D +( + wxT("offX_D"), /* identification */ + &g_Sheet_D.m_Offset.x /* Adresse du parametre */ +); + +static PARAM_CFG_INT PlotSheetOffsetY_D +( + wxT("offY_D"), /* identification */ + &g_Sheet_D.m_Offset.y /* Adresse du parametre */ +); + + +static PARAM_CFG_INT PlotSheetOffsetX_E +( + wxT("offX_E"), /* identification */ + &g_Sheet_E.m_Offset.x /* Adresse du parametre */ +); + +static PARAM_CFG_INT PlotSheetOffsetY_E +( + wxT("offY_E"), /* identification */ + &g_Sheet_E.m_Offset.y /* Adresse du parametre */ +); + +static PARAM_CFG_INT CfgRepeatDeltaX +( + wxT("RptD_X"), /* identification */ + &g_RepeatStep.x, /* Adresse du parametre */ + 0, /* Valeur par defaut */ + -1000,+1000 /* Valeurs extremes */ +); + +static PARAM_CFG_INT CfgRepeatDeltaY +( + wxT("RptD_Y"), /* identification */ + &g_RepeatStep.y, /* Adresse du parametre */ + 100, /* Valeur par defaut */ + -1000,+1000 /* Valeurs extremes */ +); + +static PARAM_CFG_INT CfgRepeatDeltaLabel +( + wxT("RptLab"), /* identification */ + &g_RepeatDeltaLabel, /* Adresse du parametre */ + 1, /* Valeur par defaut */ + -10,+10 /* Valeurs extremes */ +); + +static PARAM_CFG_INT CfgPenMinWidth +( + wxT("PenMin"), /* identification */ + &PenMinWidth, /* Adresse du parametre */ + 30, /* Valeur par defaut */ + 5, 100 /* Valeurs extremes */ +); + +static PARAM_CFG_WXSTRING CfgSimulatorCommandLine +( + wxT("SimCmd"), /* identification */ + &g_SimulatorCommandLine /* Adresse du parametre */ +); + +static PARAM_CFG_INT OptNetListUseNamesCfg +( + wxT("UseNetN"), /* identification */ + &g_OptNetListUseNames, /* Adresse du parametre */ + 0, /* Valeur par defaut */ + 0, 1 /* Valeurs extremes */ +); + +PARAM_CFG_BASE * ParamCfgList[] = +{ + & UserLibDirBufCfg, + & LibNameBufCfg, + + & NetFormatCfg, + + & UnitCfg, + & CursorShapeCfg, + & ShowGridCfg, + & DrawBgColorCfg, + & ColorLayerWireCfg, + & ColorLayerBusCfg, + & ColorLayerJunctionCfg, + & ColorLayerLLabelCfg, + & ColorLayerGLabelCfg, + & ColorLayerPinFunCfg, + & ColorLayerPinNumCfg, + & ColorLayerPinNamCfg, + & ColorLayerFieldsCfg, + & ColorLayerReferenceCfg, + & ColorLayerValueCfg, + & ColorLayerNotesCfg, + & ColorLayerBodyCfg, + & ColorLayerBodyBackgroundCfg, + & ColorLayerNetNameCfg, + & ColorLayerPinCfg, + & ColorLayerSheetCfg, + & ColorLayerSheetFileNameCfg, + & ColorLayerSheetNameCfg, + & ColorLayerSheetLabelCfg, + & ColorLayerNoConnectCfg, + & ColorLayerErcWarnCfg, + & ColorLayerErcErrCfg, + + & PlotMarginCfg, + & HPGLSpeed, + & HPGLDiam, + & HPGLPenNum, + & PlotSheetOffsetX_A4, + & PlotSheetOffsetY_A4, + & PlotSheetOffsetX_A3, + & PlotSheetOffsetY_A3, + & PlotSheetOffsetX_A2, + & PlotSheetOffsetY_A2, + & PlotSheetOffsetX_A1, + & PlotSheetOffsetY_A1, + & PlotSheetOffsetX_A0, + & PlotSheetOffsetY_A0, + & PlotSheetOffsetX_A, + & PlotSheetOffsetY_A, + & PlotSheetOffsetX_B, + & PlotSheetOffsetY_B, + & PlotSheetOffsetX_C, + & PlotSheetOffsetY_C, + & PlotSheetOffsetX_D, + & PlotSheetOffsetY_D, + & PlotSheetOffsetX_E, + & PlotSheetOffsetY_E, + & CfgRepeatDeltaX, + & CfgRepeatDeltaY, + & CfgRepeatDeltaLabel, + & CfgPenMinWidth, + & CfgSimulatorCommandLine, + & OptNetListUseNamesCfg, + NULL +}; diff --git a/eeschema/eecreate.cpp b/eeschema/eecreate.cpp new file mode 100644 index 0000000000..6d34332e05 --- /dev/null +++ b/eeschema/eecreate.cpp @@ -0,0 +1,531 @@ +/*********************************************************/ +/* Modules de creations de Traits, Wires, Bus, Junctions */ +/*********************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + + +/* Routines Locales */ +static void Polyline_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void Segment_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void ExitTrace(WinEDA_DrawFrame * frame, wxDC * DC); +static bool IsTerminalPoint(SCH_SCREEN * screen, const wxPoint & pos, int layer ); + + +/*************************************************************/ +void WinEDA_SchematicFrame::BeginSegment(wxDC * DC, int type) +/*************************************************************/ +/* Routine de Trace de segments ( WIRES, BUS ) pour lesquels chaque segment +est une structure. +*/ +{ +DrawSegmentStruct * oldsegment, * newsegment; +wxPoint pos = GetScreen()->m_Curseur; + + if ( GetScreen()->m_CurrentItem && + (GetScreen()->m_CurrentItem->m_Flags == 0) ) + GetScreen()->m_CurrentItem = NULL; + + if ( GetScreen()->m_CurrentItem ) + { + switch (GetScreen()->m_CurrentItem->m_StructType ) + { + case DRAW_SEGMENT_STRUCT_TYPE: + case DRAW_POLYLINE_STRUCT_TYPE: + break; + + default: + return; + } + } + + oldsegment = newsegment = + (DrawSegmentStruct *) GetScreen()->m_CurrentItem; + + if (!newsegment) /* 1er point : creation de la 1ere structure */ + { + + switch(type) + { + default: + newsegment = new DrawSegmentStruct(pos, LAYER_NOTES); + break; + case LAYER_WIRE: + newsegment = new DrawSegmentStruct(pos, LAYER_WIRE); + if ( LocatePinEnd(GetScreen()->EEDrawList, pos) ) + newsegment->m_StartIsDangling = FALSE; + break; + case LAYER_BUS: + newsegment = new DrawSegmentStruct(pos, LAYER_BUS); + break; + } + + newsegment->m_Flags = IS_NEW; + GetScreen()->m_CurrentItem = newsegment; + GetScreen()->ManageCurseur = Segment_in_Ghost; + GetScreen()->ForceCloseManageCurseur = ExitTrace; + g_ItemToRepeat = NULL; + } + + else /* Trace en cours: Placement d'un point supplementaire */ + { + if( (oldsegment->m_Start.x == oldsegment->m_End.x) && + (oldsegment->m_Start.y == oldsegment->m_End.y) ) /* Structure inutile */ + return; + GetScreen()->ManageCurseur(DrawPanel, DC, FALSE); + oldsegment->m_EndIsDangling = FALSE; + + /* Creation du segment suivant ou fin de tracé si point sur pin, jonction ...*/ + if ( IsTerminalPoint(GetScreen(), oldsegment->m_End, oldsegment->m_Layer) ) + { + EndSegment(DC); return; + } + + /* Placement en liste generale */ + oldsegment->Pnext = GetScreen()->EEDrawList; + g_ItemToRepeat = GetScreen()->EEDrawList = oldsegment; + GetScreen()->CursorOff(DrawPanel, DC); // Erase schematic cursor + RedrawOneStruct(DrawPanel,DC, oldsegment, GR_DEFAULT_DRAWMODE); + GetScreen()->CursorOn(DrawPanel, DC); // Display schematic cursor + + /* Creation du segment suivant */ + newsegment = oldsegment->GenCopy(); + newsegment->m_Start = oldsegment->m_End; + newsegment->m_End = pos; + oldsegment->m_Flags = 0; + newsegment->m_Flags = IS_NEW; + GetScreen()->m_CurrentItem = newsegment; + GetScreen()->ManageCurseur(DrawPanel, DC, FALSE); + newsegment->m_StartIsDangling = FALSE; + newsegment->m_EndIsDangling = TRUE; + } +} + + +/*************************************************************/ +/* Routine de fin de trace d'une struct segment (Wire, Bus */ +/*************************************************************/ +void WinEDA_SchematicFrame::EndSegment(wxDC *DC) +{ +DrawSegmentStruct * segment = (DrawSegmentStruct *)GetScreen()->m_CurrentItem; + + if ( GetScreen()->ManageCurseur == NULL ) return; + if ( segment == NULL ) return; + if ( (segment->m_Flags & IS_NEW) == 0) return; + + if( (segment->m_Start.x == segment->m_End.x) && + (segment->m_Start.y == segment->m_End.y) ) /* Structure inutile */ + { + EraseStruct(segment, (SCH_SCREEN*)GetScreen()); + segment = NULL; + } + + else + { /* Placement en liste generale */ + GetScreen()->ManageCurseur(DrawPanel, DC, FALSE); + segment->Pnext = GetScreen()->EEDrawList; + g_ItemToRepeat = GetScreen()->EEDrawList = segment; + segment->m_Flags = 0; + } + + /* Fin de trace */ + GetScreen()->ManageCurseur = NULL; + GetScreen()->ForceCloseManageCurseur = NULL; + GetScreen()->m_CurrentItem = NULL; + + TestDanglingEnds(GetScreen()->EEDrawList, DC); + SetFlagModify(GetScreen()); + if( segment ) + { + GetScreen()->CursorOff(DrawPanel, DC); // Erase schematic cursor + RedrawOneStruct(DrawPanel,DC, segment, GR_DEFAULT_DRAWMODE); + GetScreen()->CursorOn(DrawPanel, DC); // Display schematic cursor + } +} + +/****************************************************************************/ +static void Segment_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/****************************************************************************/ +/* Dessin du Segment Fantome lors des deplacements du curseur +*/ +{ +DrawSegmentStruct * segment = + (DrawSegmentStruct *) panel->m_Parent->GetScreen()->m_CurrentItem; +wxPoint endpos; +int color; + + if ( segment == NULL ) return; + + color = ReturnLayerColor(segment->m_Layer) ^ HIGHT_LIGHT_FLAG; + + endpos = panel->m_Parent->GetScreen()->m_Curseur; + + if( g_HVLines ) /* Coerce the line to vertical or horizontal one: */ + { + if (ABS(endpos.x - segment->m_Start.x) < ABS(endpos.y - segment->m_Start.y)) + endpos.x = segment->m_Start.x; + else + endpos.y = segment->m_Start.y; + } + + if( erase ) // Redraw if segment lengtht != 0 + { + if ( (segment->m_Start.x != segment->m_End.x) || + (segment->m_Start.y != segment->m_End.y) ) + RedrawOneStruct(panel,DC, segment, XOR_MODE, color); + } + segment->m_End = endpos; + // Redraw if segment lengtht != 0 + + if ( (segment->m_Start.x != segment->m_End.x) || + (segment->m_Start.y != segment->m_End.y) ) + RedrawOneStruct(panel,DC, segment, XOR_MODE,color); +} + +/*****************************************************************************/ +static void Polyline_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/*****************************************************************************/ +/* Dessin du du Polyline Fantome lors des deplacements du curseur +*/ +{ +DrawPolylineStruct * NewPoly = + (DrawPolylineStruct *)panel->m_Parent->GetScreen()->m_CurrentItem; +int color; +wxPoint endpos; + + endpos = panel->m_Parent->GetScreen()->m_Curseur; + color = ReturnLayerColor(NewPoly->m_Layer); + + GRSetDrawMode(DC, XOR_MODE); + + if( g_HVLines ) + { + /* Coerce the line to vertical or horizontal one: */ + if (ABS(endpos.x - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2]) < + ABS(endpos.y - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1])) + endpos.x = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2]; + else + endpos.y = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1]; + } + + NewPoly->m_NumOfPoints++; + if( erase ) + RedrawOneStruct(panel,DC, NewPoly, XOR_MODE, color); + + NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2] = endpos.x; + NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1] = endpos.y; + RedrawOneStruct(panel,DC, NewPoly, XOR_MODE, color); + NewPoly->m_NumOfPoints--; +} + +/**********************************************************/ +void WinEDA_SchematicFrame::DeleteCurrentSegment(wxDC * DC) +/**********************************************************/ +/* +Routine effacant le dernier trait trace, ou l'element pointe par la souris +*/ +{ + + g_ItemToRepeat = NULL; + + if( (GetScreen()->m_CurrentItem == NULL) || + ((GetScreen()->m_CurrentItem->m_Flags & IS_NEW) == 0) ) + { + return; + } + + /* Trace en cours: annulation */ + if (GetScreen()->m_CurrentItem->m_StructType == DRAW_POLYLINE_STRUCT_TYPE) + { + Polyline_in_Ghost(DrawPanel, DC, FALSE); /* Effacement du trace en cours */ + } + + else + { + Segment_in_Ghost(DrawPanel, DC, FALSE); /* Effacement du trace en cours */ + } + + EraseStruct(GetScreen()->m_CurrentItem, GetScreen()); + GetScreen()->ManageCurseur = NULL; + GetScreen()->m_CurrentItem = NULL; +} + + +/***************************************************************************/ +EDA_BaseStruct * WinEDA_SchematicFrame::CreateNewJunctionStruct(wxDC * DC) +/***************************************************************************/ +/* Routine to create new connection struct. +*/ +{ +DrawJunctionStruct *NewConnect; + + NewConnect = new DrawJunctionStruct(GetScreen()->m_Curseur); + + g_ItemToRepeat = NewConnect; + + GetScreen()->CursorOff(DrawPanel, DC); // Erase schematic cursor + RedrawOneStruct(DrawPanel,DC, NewConnect, GR_DEFAULT_DRAWMODE); + GetScreen()->CursorOn(DrawPanel, DC); // Display schematic cursor + + NewConnect->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = NewConnect; + SetFlagModify(GetScreen()); + return(NewConnect); +} + +/*************************************************************************/ +EDA_BaseStruct *WinEDA_SchematicFrame::CreateNewNoConnectStruct(wxDC * DC) +/*************************************************************************/ +/*Routine to create new NoConnect struct. ( Symbole de Non Connexion) +*/ +{ +DrawNoConnectStruct *NewNoConnect; + + NewNoConnect = new DrawNoConnectStruct(GetScreen()->m_Curseur); + g_ItemToRepeat = NewNoConnect; + + GetScreen()->CursorOff(DrawPanel, DC); // Erase schematic cursor + RedrawOneStruct(DrawPanel,DC, NewNoConnect, GR_DEFAULT_DRAWMODE); + GetScreen()->CursorOn(DrawPanel, DC); // Display schematic cursor + + NewNoConnect->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = NewNoConnect; + SetFlagModify(GetScreen()); + return(NewNoConnect); +} + + +/**********************************************************/ +static void ExitTrace(WinEDA_DrawFrame * frame, wxDC * DC) +/**********************************************************/ +/* Routine de sortie des menus de trace */ +{ +BASE_SCREEN * Screen = frame->GetScreen(); + + if( Screen->m_CurrentItem) /* trace en cours */ + { + Screen->ManageCurseur(frame->DrawPanel, DC, FALSE); + Screen->ManageCurseur = NULL; + Screen->ForceCloseManageCurseur = NULL; + EraseStruct(Screen->m_CurrentItem,(SCH_SCREEN*) Screen); + Screen->m_CurrentItem = NULL; + return; + } + + else g_ItemToRepeat = NULL; // Fin de commande generale +} + + +/***************************************************/ +void WinEDA_SchematicFrame::RepeatDrawItem(wxDC *DC) +/***************************************************/ +/* Routine de recopie du dernier element dessine + Les elements duplicables sont + fils, bus, traits, textes, labels + Les labels termines par un nombre seront incrementes +*/ +{ +char Line[256]; +int ox = 0, oy = 0; + + if( g_ItemToRepeat == NULL ) return; + + switch( g_ItemToRepeat->m_StructType ) + { + case DRAW_JUNCTION_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawJunctionStruct*) g_ItemToRepeat) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; + STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; + break; + + case DRAW_NOCONNECT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawNoConnectStruct*) g_ItemToRepeat) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; + STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; + break; + + case DRAW_TEXT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawTextStruct*) g_ItemToRepeat) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; + STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; + /*** Increment du numero de label ***/ + strcpy(Line,STRUCT->GetText()); + IncrementLabelMember(Line); + STRUCT->m_Text = Line; + break; + + + case DRAW_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawLabelStruct*) g_ItemToRepeat) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; + STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; + /*** Increment du numero de label ***/ + strcpy(Line,STRUCT->GetText()); + IncrementLabelMember(Line); + STRUCT->m_Text = Line; + break; + + + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawGlobalLabelStruct*) g_ItemToRepeat) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; + STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; + /*** Increment du numero de label ***/ + strcpy(Line,STRUCT->GetText()); + IncrementLabelMember(Line); + STRUCT->m_Text = Line; + break; + + case DRAW_SEGMENT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawSegmentStruct*) g_ItemToRepeat) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Start.x += g_RepeatStep.x; ox = STRUCT->m_Start.x; + STRUCT->m_Start.y += g_RepeatStep.y; oy = STRUCT->m_Start.y; + STRUCT->m_End.x += g_RepeatStep.x; + STRUCT->m_End.y += g_RepeatStep.y; + break; + + case DRAW_RACCORD_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawRaccordStruct*) g_ItemToRepeat) + g_ItemToRepeat = STRUCT->GenCopy(); + STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x; + STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y; + break; + + default: + g_ItemToRepeat = NULL; + DisplayError(this, "Repeat Type Error", 10); + break; + } + + if ( g_ItemToRepeat ) + { + g_ItemToRepeat->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = g_ItemToRepeat; + TestDanglingEnds(GetScreen()->EEDrawList, NULL); + RedrawOneStruct(DrawPanel,DC, g_ItemToRepeat, GR_DEFAULT_DRAWMODE); +// GetScreen()->Curseur.x = ox; GetScreen()->Curseur.x = oy; +// GRMouseWarp(DrawPanel, DrawPanel->CursorScreenPosition() ); + } +} + + +/******************************************/ +void IncrementLabelMember(char * Line) +/******************************************/ +/* Routine incrementant les labels, c'est a dire pour les textes finissant +par un nombre, ajoutant a ce nombre +*/ +{ +char * strnum; +int ii; + + strnum = Line + strlen(Line) - 1; + if( !isdigit(*strnum) ) return; + + while( (strnum >= Line) && isdigit(*strnum) ) strnum--; + strnum++; /* pointe le debut de la chaine des digits */ + ii = atoi(strnum) + g_RepeatDeltaLabel; + sprintf(strnum, "%d", ii); +} + +/***************************************************************************/ +static bool IsTerminalPoint(SCH_SCREEN * screen, const wxPoint & pos, int layer) +/***************************************************************************/ +/* Returne TRUE si pos est un point possible pour terminer automatiquement un +segment, c'est a dire pour + - type WIRE, si il y a + - une jonction + - ou une pin + - ou une extrémité unique de fil + + - type BUS, si il y a + - ou une extrémité unique de BUS +*/ +{ +EDA_BaseStruct * item; +LibDrawPin * pin; +DrawLibItemStruct * LibItem = NULL; +DrawSheetLabelStruct * pinsheet; +wxPoint itempos; + + switch ( layer ) + { + case LAYER_BUS: + item = PickStruct(screen, BUSITEM); + if ( item ) return TRUE; + pinsheet = LocateAnyPinSheet(pos, screen->EEDrawList ); + if ( pinsheet && IsBusLabel(pinsheet->GetText()) ) + { + itempos = pinsheet->m_Pos; + if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE; + } + break; + + case LAYER_NOTES: + item = PickStruct(screen, DRAWITEM); + if ( item ) + return TRUE; + break; + + case LAYER_WIRE: + item = PickStruct(screen, RACCORDITEM |JUNCTIONITEM); + if ( item ) return TRUE; + + pin = LocateAnyPin( screen->EEDrawList, pos, &LibItem ); + if ( pin && LibItem ) + { + // calcul de la position exacte du point de connexion de la pin, + // selon orientation du composant: + itempos = LibItem->GetScreenCoord(pin->m_Pos); + itempos.x += LibItem->m_Pos.x; + itempos.y += LibItem->m_Pos.y; + if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE; + } + + item = PickStruct(screen, WIREITEM); + if ( item ) return TRUE; + + item = PickStruct(screen, LABELITEM); + if ( item && (item->m_StructType != DRAW_TEXT_STRUCT_TYPE) && + ( ((DrawGlobalLabelStruct*)item)->m_Pos.x == pos.x) && + ( ((DrawGlobalLabelStruct*)item)->m_Pos.y == pos.y) ) + return TRUE; + + pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList ); + if ( pinsheet && ! IsBusLabel(pinsheet->GetText()) ) + { + itempos = pinsheet->m_Pos; + if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE; + } + + break; + + default: + break; + } + + return FALSE; +} + + diff --git a/eeschema/eelayer.cpp b/eeschema/eelayer.cpp new file mode 100644 index 0000000000..29435c8dd5 --- /dev/null +++ b/eeschema/eelayer.cpp @@ -0,0 +1,473 @@ + /* Set up color Layers */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "id.h" + +#include "protos.h" + + +/* Variables locales */ + +/* Fonctions locales: */ + +/* Macro utile : */ +#define ADR(numlayer) &(g_LayerDescr.LayerColor[numlayer]) + +#define BUTT_SIZE_X 30 +#define BUTT_SIZE_Y 20 + + +enum col_sel_id { + ID_COLOR_SETUP = 1800 +}; + + /**********************************/ + /* Liste des menus de Menu_Layers */ + /**********************************/ +struct ColorButton + { + wxString m_Name; + int * m_Color; + int m_Id; + wxBitmapButton * m_Button; + int m_State; +}; + +static ColorButton Msg_General= +{ + _("General"), /* Title */ + NULL +}; + +static ColorButton Msg_Sheets= +{ + _("Sheets"), /* Title */ + NULL +}; + +static ColorButton Layer_Wire_Item= +{ + _("Wire"), /* Title */ + ADR(LAYER_WIRE) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_Bus_Item= +{ + _("Bus"), /* Title */ + ADR(LAYER_BUS) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_Jonction_Item= +{ + _("Junction"), /* Title */ + ADR(LAYER_JUNCTION) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_LocalLabel_Item= +{ + _("Label"), /* Title */ + ADR(LAYER_LOCLABEL) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_GlobLabel_Item= +{ + _("GlobLabel"), /* Title */ + ADR(LAYER_GLOBLABEL) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_PinNum_Item= +{ + _("PinNum"), /* Title */ + ADR(LAYER_PINNUM) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_PinNam_Item= +{ + _("PinNam"), /* Title */ + ADR(LAYER_PINNAM) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_Reference_Item= +{ + _("Reference"), /* Title */ + ADR(LAYER_REFERENCEPART) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_Value_Item= +{ + _("Value"), /* Title */ + ADR(LAYER_VALUEPART) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_Fields_Item= +{ + _("Fields"), /* Title */ + ADR(LAYER_FIELDS) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_BodyDevice_Item= +{ + _("Body"), /* Title */ + ADR(LAYER_DEVICE) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_BodyBackgroundDevice_Item= +{ + _("Body Bg"), /* Title */ + ADR(LAYER_DEVICE_BACKGROUND) /* adr du parametre optionnel */ +}; + +static ColorButton MsgDevice_Item= +{ + _("Device"), /* Title */ + NULL +}; + +static ColorButton Layer_Notes_Item= +{ + _("Notes"), /* Title */ + ADR(LAYER_NOTES) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_NetNam_Item= +{ + _("Netname"), /* Title */ + ADR(LAYER_NETNAM) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_Pin_Item= +{ + _("Pin"), /* Title */ + ADR(LAYER_PIN) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_Sheet_Item= +{ + _("Sheet"), /* Title */ + ADR(LAYER_SHEET) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_SheetName_Item= +{ + _("SheetName"), /* Title */ + ADR(LAYER_SHEETNAME) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_SheetFileName_Item= +{ + _("Sheetfile"), /* Title */ + ADR(LAYER_SHEETFILENAME) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_SheetLabel_Item= +{ + _("SheetLabel"), /* Title */ + ADR(LAYER_SHEETLABEL) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_NoConnect_Item= +{ + _("NoConn"), /* Title */ + ADR(LAYER_NOCONNECT) /* adr du parametre optionnel */ +}; + + +static ColorButton Msg_ErcMarck= +{ + _("Erc Mark"), /* Title */ + NULL +}; + +static ColorButton Layer_Erc_Warning_Item= +{ + _("Erc Warning"), /* Title */ + ADR(LAYER_ERC_WARN) /* adr du parametre optionnel */ +}; + +static ColorButton Layer_Erc_Error_Item= +{ + _("Erc Error"), /* Title */ + ADR(LAYER_ERC_ERR) /* adr du parametre optionnel */ +}; + +#define NB_BUTT 26 +static ColorButton * laytool_list[NB_BUTT+1] = { + &Msg_General, + &Layer_Wire_Item, + &Layer_Bus_Item, + &Layer_Jonction_Item, + &Layer_LocalLabel_Item, + &Layer_GlobLabel_Item, + &Layer_NetNam_Item, + &Layer_Notes_Item, + &Layer_NoConnect_Item, + + &MsgDevice_Item, + &Layer_BodyDevice_Item, + &Layer_BodyBackgroundDevice_Item, + &Layer_Pin_Item, + &Layer_PinNum_Item, + &Layer_PinNam_Item, + &Layer_Reference_Item, + &Layer_Value_Item, + &Layer_Fields_Item, + + &Msg_Sheets, + &Layer_Sheet_Item, + &Layer_SheetFileName_Item, + &Layer_SheetName_Item, + &Layer_SheetLabel_Item, + + &Msg_ErcMarck, + &Layer_Erc_Warning_Item, + &Layer_Erc_Error_Item, + + NULL +}; + +/*************************************************************/ +/* classe derivee pour la frame de Configuration des couleurs*/ +/*************************************************************/ + +class WinEDA_SetColorsFrame: public wxDialog +{ +private: + WinEDA_DrawFrame *m_Parent; + wxRadioBox * m_SelBgColor; + +public: + + // Constructor and destructor + WinEDA_SetColorsFrame(WinEDA_DrawFrame *parent, const wxPoint& framepos); + ~WinEDA_SetColorsFrame(void) {}; + +private: + void SetColor(wxCommandEvent& event); + void BgColorChoice(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() + +}; +/* Table des evenements pour WinEDA_SetColorsFrame */ +BEGIN_EVENT_TABLE(WinEDA_SetColorsFrame, wxDialog) + EVT_RADIOBOX(ID_SEL_BG_COLOR, WinEDA_SetColorsFrame::BgColorChoice) + EVT_COMMAND_RANGE(ID_COLOR_SETUP, ID_COLOR_SETUP+26, + wxEVT_COMMAND_BUTTON_CLICKED, + WinEDA_SetColorsFrame::SetColor) + +END_EVENT_TABLE() + + + +/**************************************************************/ +void DisplayColorSetupFrame(WinEDA_DrawFrame * parent, + const wxPoint & framepos) +/**************************************************************/ +{ + WinEDA_SetColorsFrame * frame = + new WinEDA_SetColorsFrame(parent, framepos); + frame->ShowModal(); frame->Destroy(); +} + +/**********************************************************************/ +WinEDA_SetColorsFrame::WinEDA_SetColorsFrame(WinEDA_DrawFrame *parent, + const wxPoint& framepos): + wxDialog(parent, -1, _("EESchema Preferences"), framepos, + wxSize(500, 270), DIALOG_STYLE) +/**********************************************************************/ +{ +#define START_Y 15 +wxBitmapButton * Button; +int ii, yy, butt_ID, buttcolor; +wxPoint pos; +int w = BUTT_SIZE_X, h = BUTT_SIZE_Y; +wxStaticText * text; +int right, bottom, line_height; +wxPoint bg_color_pos; + + m_Parent = parent; + SetFont(*g_DialogFont); + + pos.x = 10; pos.y = START_Y; + right = pos.x; bottom = 0; + line_height = h; + for ( ii = 0; laytool_list[ii] != NULL; ii++ ) + { + if( laytool_list[ii]->m_Color == NULL) + { + if( pos.y != START_Y ) + { + pos.x = right + 10; + pos.y = START_Y; + bg_color_pos = pos; + } + wxString msg = wxGetTranslation(laytool_list[ii]->m_Name); + text = new wxStaticText(this,-1, + msg, + wxPoint(pos.x, pos.y ), + wxSize(-1,-1), 0 ); + line_height = MAX(line_height, text->GetRect().GetHeight()); + pos.y += line_height; + continue; + } + butt_ID = ID_COLOR_SETUP + ii; + laytool_list[ii]->m_Id = butt_ID; + wxMemoryDC iconDC; + wxBitmap ButtBitmap(w,h); + iconDC.SelectObject( ButtBitmap ); + buttcolor = *laytool_list[ii]->m_Color; + wxBrush Brush; + iconDC.SelectObject( ButtBitmap ); + iconDC.SetPen(*wxBLACK_PEN); + Brush.SetColour( + ColorRefs[buttcolor].m_Red, + ColorRefs[buttcolor].m_Green, + ColorRefs[buttcolor].m_Blue + ); + Brush.SetStyle(wxSOLID); + + iconDC.SetBrush(Brush); + iconDC.DrawRectangle(0,0, w, h); + + Button = new wxBitmapButton(this, butt_ID, + ButtBitmap, + wxPoint(pos.x, pos.y - ((h -line_height)/2) ), + wxSize(w,h) ); + laytool_list[ii]->m_Button = Button; + + wxString msg = wxGetTranslation(laytool_list[ii]->m_Name); + text = new wxStaticText(this,-1, + msg, + wxPoint(pos.x + 5 + w , pos.y ), + wxSize(-1,-1), 0 ); + wxPoint lowpos; + lowpos.x = text->GetRect().GetRight(); + lowpos.y = text->GetRect().GetBottom(); + right = MAX(right, lowpos.x); + bottom = MAX(bottom, lowpos.y); + bg_color_pos.y = lowpos.y; + + yy = line_height + 5; + pos.y += yy; + } + + bg_color_pos.x += 5; bg_color_pos.y += 25; +wxString bg_choice[2] = { _("White Background"), _("Black Background")}; + m_SelBgColor = new wxRadioBox(this, ID_SEL_BG_COLOR, + _("Background Colour"), bg_color_pos, + wxDefaultSize, 2, bg_choice, 1, wxRA_SPECIFY_COLS); + m_SelBgColor->SetSelection( (g_DrawBgColor == BLACK) ? 1 : 0); + bottom = MAX(bottom, m_SelBgColor->GetRect().GetBottom());; + right = MAX(right, m_SelBgColor->GetRect().GetRight());; + + SetClientSize(wxSize(right+10, bottom+10)); +} + + +/***************************************************************/ +void WinEDA_SetColorsFrame::SetColor(wxCommandEvent& event) +/***************************************************************/ +{ +int id = event.GetId(); +int color = DisplayColorFrame(this); +int w = BUTT_SIZE_X, h = BUTT_SIZE_Y; + + if ( color < 0) return; + + for ( int ii = 0; laytool_list[ii] != NULL; ii++ ) + { + if( laytool_list[ii]->m_Id != id) continue; + + if( *laytool_list[ii]->m_Color == color) break; + + *laytool_list[ii]->m_Color = color; + wxMemoryDC iconDC; + + wxBitmapButton * Button = laytool_list[ii]->m_Button; + + wxBitmap ButtBitmap = Button->GetBitmapLabel(); + iconDC.SelectObject( ButtBitmap ); + int buttcolor = *laytool_list[ii]->m_Color; + wxBrush Brush; + iconDC.SelectObject( ButtBitmap ); + iconDC.SetPen(*wxBLACK_PEN); + Brush.SetColour( + ColorRefs[buttcolor].m_Red, + ColorRefs[buttcolor].m_Green, + ColorRefs[buttcolor].m_Blue + ); + Brush.SetStyle(wxSOLID); + + iconDC.SetBrush(Brush); + iconDC.DrawRectangle(0,0, w, h); + Button->SetBitmapLabel(ButtBitmap); + if ( m_Parent->GetScreen() ) + m_Parent->GetScreen()->SetRefreshReq(); + } + Refresh(FALSE); +} + + +/***************************************************************/ +void WinEDA_SetColorsFrame::BgColorChoice(wxCommandEvent& event) +/***************************************************************/ +{ +int color; + + if ( m_SelBgColor->GetSelection() == 0 ) color = WHITE; + else color = BLACK; + + if ( color != g_DrawBgColor ) + { + g_DrawBgColor = color; + m_Parent->SetDrawBgColor(g_DrawBgColor); + m_Parent->ReDrawPanel(); + } + + +} + + + +/*************************/ +void SeedLayers(void) +/*************************/ +{ +LayerStruct * LayerPointer = &g_LayerDescr; +int pt; + + LayerPointer->CommonColor = WHITE; + LayerPointer->Flags = 0; + pt=0; + LayerPointer->CurrentWidth = 1; + + /* seed Up the Layer colours, set all user layers off */ + for( pt = 0; pt < MAX_LAYERS; pt++ ) + { + LayerPointer->LayerStatus[pt]= 0; + LayerPointer->LayerColor[pt] = DARKGRAY; + } + + LayerPointer->NumberOfLayers = pt - 1; + /* Couleurs specifiques: Mise a jour par la lecture de la config*/ +} + + +/*******************************/ +int ReturnLayerColor(int Layer) +/*******************************/ +{ + if(g_LayerDescr.Flags==0) + return(g_LayerDescr.LayerColor[Layer]); + else + return(g_LayerDescr.CommonColor); +} + + diff --git a/eeschema/eelibs1.cpp b/eeschema/eelibs1.cpp new file mode 100644 index 0000000000..8a06da3e61 --- /dev/null +++ b/eeschema/eelibs1.cpp @@ -0,0 +1,1150 @@ +/***********************************************************/ +/* Module to handle libraries (first part - file and io). */ +/***********************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "trigo.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +/* Variables Locales */ + +/* Fonctions locales */ +/* pour librairies de composants */ +static LibEDA_BaseStruct *GetDrawEntry(WinEDA_DrawFrame * frame, FILE *f, + char *Line, int *LineNum); +static bool GetLibEntryField(EDA_LibComponentStruct *LibEntry, char * line); +static bool AddAliasNames(EDA_LibComponentStruct *LibEntry, char * line); +static void InsertAlias(PriorQue ** PQ, + EDA_LibComponentStruct *LibEntry, int *NumOfParts); +static bool ReadLibEntryDateAndTime(EDA_LibComponentStruct * LibEntry, char * Line); +static int AddFootprintFilterList(EDA_LibComponentStruct *LibEntryLibEntry, + FILE * f, char * Line, int *LineNum); + +/* pour doc librairies */ + + + /****************************************************/ + /* Routines de lecture des librairies de composants */ + /****************************************************/ + + +/***************************************************************************** +* Routine to load the given library name. FullLibName should hold full path * +* of file name to open, while LibName should hold only its name. * +* IF library already exists, it is NOT reloaded. * +* return: new lib or NULL * +*****************************************************************************/ +LibraryStruct * LoadLibraryName(WinEDA_DrawFrame * frame, + const wxString & FullLibName, const wxString & LibName) +{ +int NumOfParts; +FILE *f; +LibraryStruct *NewLib; +PriorQue *Entries; +wxString FullFileName; + + if ( (NewLib = FindLibrary(LibName)) != NULL) + { + if ( NewLib->m_FullFileName == FullLibName ) + return NewLib; + FreeCmpLibrary(frame, LibName); + } + + NewLib = NULL; + + f = wxFopen(FullLibName, wxT("rt") ); + if (f == NULL) + { + wxString msg; + msg.Printf( _("Library <%s> not found"), FullLibName.GetData()); + DisplayError(frame, msg); + return NULL; + } + + NewLib = new LibraryStruct(LIBRARY_TYPE_EESCHEMA, LibName, FullLibName); + Entries = LoadLibraryAux(frame, NewLib, f, &NumOfParts); + if ( Entries != NULL) + { + NewLib->m_Entries = Entries; + NewLib->m_NumOfParts = NumOfParts; + + if ( g_LibraryList == NULL ) g_LibraryList = NewLib; + else + { + LibraryStruct *tmplib = g_LibraryList; + while ( tmplib->m_Pnext ) tmplib = tmplib->m_Pnext; + tmplib->m_Pnext = NewLib; + } + + FullFileName = FullLibName; + ChangeFileNameExt(FullFileName, DOC_EXT); + LoadDocLib(frame, FullFileName, NewLib->m_Name); + } + else delete NewLib; + + fclose(f); + return NewLib; +} + + +/******************************************/ +void LoadLibraries(WinEDA_DrawFrame * frame) +/******************************************/ +/* Delete toutes les librairies chargees et recree toutes les librairies +donnes dans la liste g_LibName_List +*/ +{ +wxString FullLibName, msg; +wxString LibName; +unsigned ii, iimax = g_LibName_List.GetCount(); + + frame->PrintMsg( _("Start loading schematic libs")); + + // Free the unwanted libraries (i.e. not in list) but keep the .cache lib +LibraryStruct *nextlib, *lib = g_LibraryList; + for (; lib != NULL; lib = nextlib ) + { + nextlib = lib->m_Pnext; + if ( lib->m_IsLibCache ) continue; + + wxString libname = lib->m_Name; + + // is this library in "wanted list" g_LibName_List ? + int test = g_LibName_List.Index(libname); + if ( test == wxNOT_FOUND ) FreeCmpLibrary(frame, libname); + } + + // Load missing libraries (if any) + for ( ii = 0 ; ii < iimax; ii++) + { + LibName = g_LibName_List[ii]; + + if( LibName.IsEmpty() ) continue; + FullLibName = MakeFileName(g_RealLibDirBuffer, LibName, g_LibExtBuffer); + msg = wxT("Loading ") + FullLibName; + if ( LoadLibraryName(frame, FullLibName, LibName) ) + msg += wxT(" OK"); + else + msg += wxT(" ->Error"); + frame->PrintMsg( msg ); + } + + // reorder the linked list to match the order filename list: + int NumOfLibs; + for (NumOfLibs = 0, lib = g_LibraryList; lib != NULL; lib = lib->m_Pnext) + { + lib->m_Flags = 0; + NumOfLibs++; + } + if ( NumOfLibs == 0 ) return; + + LibraryStruct ** libs = + (LibraryStruct **) MyZMalloc(sizeof(LibraryStruct *) * (NumOfLibs + 2)); + + int jj = 0; + for (ii = 0; ii < g_LibName_List.GetCount(); ii++) + { + if ( jj >= NumOfLibs ) break; + lib = FindLibrary(g_LibName_List[ii]); + if ( lib ) + { + lib->m_Flags = 1; + libs[jj++] = lib; + } + } + /* Put lib cache at end of list */ + for (lib = g_LibraryList; lib != NULL; lib = lib->m_Pnext) + { + if ( lib->m_Flags == 0 ) libs[jj++] = lib; + } + libs[jj] = NULL; + + /* Change the linked list pointers */ + for (ii = 0; libs[ii] != NULL; ii++) + libs[ii]->m_Pnext = libs[ii+1]; + + g_LibraryList = libs[0]; + + MyFree(libs); + + for (lib = g_LibraryList; lib != NULL; lib = lib->m_Pnext) + lib->m_Flags = 0; +} + +/***************************************************************************** +* Routine to free a library from the current loaded libraries. * +*****************************************************************************/ +void FreeCmpLibrary(wxWindow * frame, const wxString & LibName) +{ +int NumOfLibs = NumOfLibraries(); +LibraryStruct *Lib, *TempLib; + + if (NumOfLibs == 0) + { + DisplayError(frame, wxT("No libraries are loaded"),20); + return; + } + + /* Search for this library name: */ + for (Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext) + { + if (LibName == Lib->m_Name) break; + } + + if (Lib == NULL) return; + + if ( Lib == g_LibraryList) g_LibraryList = Lib->m_Pnext; + else + { + for( TempLib = g_LibraryList; TempLib->m_Pnext != Lib; TempLib=TempLib->m_Pnext); + TempLib->m_Pnext = TempLib->m_Pnext->m_Pnext; + } + + delete Lib; + + /* La librairie supprimee est peut etre celle selectee dans libedit */ + if ( Lib == CurrentLib ) CurrentLib = NULL; +} + +/******************************/ +const wxChar **GetLibNames(void) +/******************************/ +/* Routine to return pointers to all library names. + User is responsible to deallocate memory +*/ +{ +int ii, NumOfLibs = NumOfLibraries(); +const wxChar **Names; +LibraryStruct *Lib; + + Names = (const wxChar **) MyZMalloc(sizeof(wxChar *) * (NumOfLibs + 1)); + for (ii = 0, Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext, ii++) + { + Names[ii] = Lib->m_Name.GetData(); + } + Names[ii] = NULL; + + return Names; +} + + +/***************************************************************************** +* Routine to compare two EDA_LibComponentStruct for the PriorQue module. * +* Comparison (insensitive case) is based on Part name. * +*****************************************************************************/ +int LibraryEntryCompare(EDA_LibComponentStruct *LE1, EDA_LibComponentStruct *LE2) +{ + return LE1->m_Name.m_Text.CmpNoCase(LE2->m_Name.m_Text); +} + +/***************************************************************************** +* Routine to load a library from given open file. * +*****************************************************************************/ +PriorQue *LoadLibraryAux(WinEDA_DrawFrame * frame, LibraryStruct * Library, FILE *libfile, int *NumOfParts) +{ +int LineNum = 0; +char Line[1024]; +PriorQue *PQ = NULL; +EDA_LibComponentStruct *LibEntry; +wxString msg; + +wxBusyCursor ShowWait; // Display a Busy Cursor.. + + *NumOfParts = 0; + + if ( GetLine(libfile, Line, &LineNum, sizeof(Line) ) == NULL) + { + msg = _("File <") + Library->m_Name + _("> is empty!"); + DisplayError(frame, msg); + return NULL; + } + + if( strnicmp(Line, LIBFILE_IDENT, 10) != 0) + { + msg = _("File <") + Library->m_Name + _("> is NOT EESCHEMA library!"); + DisplayError(frame, msg); + return NULL; + } + + if ( Library ) Library->m_Header = CONV_FROM_UTF8(Line); + + PQInit(&PQ); + PQCompFunc((PQCompFuncType) LibraryEntryCompare); + + while (GetLine(libfile, Line, &LineNum, sizeof(Line)) ) + { + if (strnicmp(Line, "$HEADER", 7) == 0) + { + if ( Library ) + { + if ( ! Library->ReadHeader(libfile, &LineNum) ) + { + msg = _("Library <") + Library->m_Name + _("> header read error"); + DisplayError(frame, msg, 30); + } + } + continue; + } + + if (strnicmp(Line, "DEF", 3) == 0) + { + /* Read one DEF/ENDDEF part entry from library: */ + LibEntry = Read_Component_Definition(frame, Line, libfile, &LineNum); + if ( LibEntry ) + { + /* If we are here, this part is O.k. - put it in: */ + ++*NumOfParts; + PQInsert(&PQ, LibEntry); + InsertAlias(&PQ, LibEntry, NumOfParts); + } + } + } + + return PQ; +} + + +/*********************************************************************************************/ +EDA_LibComponentStruct * Read_Component_Definition(WinEDA_DrawFrame * frame, char * Line, + FILE *f, int *LineNum) +/*********************************************************************************************/ +/* Routine to Read a DEF/ENDDEF part entry from given open file. +*/ +{ +int unused; +char *p, *Name, *Prefix = NULL; +EDA_LibComponentStruct *LibEntry = NULL; +bool Res; +wxString Msg; + + p = strtok(Line, " \t\r\n"); + + if (strcmp(p, "DEF") != 0) + { + Msg.Printf( wxT("DEF command expected in line %d, aborted."), *LineNum); + DisplayError(frame, Msg); + return NULL; + } + + /* Read DEF line: */ + char drawnum = 0, drawname = 0; + LibEntry = new EDA_LibComponentStruct( NULL); + + if ((Name = strtok(NULL, " \t\n")) == NULL || /* Part name: */ + (Prefix = strtok(NULL, " \t\n")) == NULL || /* Prefix name: */ + (p = strtok(NULL, " \t\n")) == NULL || /* NumOfPins: */ + sscanf(p, "%d", &unused) != 1 || + (p = strtok(NULL, " \t\n")) == NULL || /* TextInside: */ + sscanf(p, "%d", &LibEntry->m_TextInside) != 1 || + (p = strtok(NULL, " \t\n")) == NULL || /* DrawNums: */ + sscanf(p, "%c", &drawnum) != 1 || + (p = strtok(NULL, " \t\n")) == NULL || /* DrawNums: */ + sscanf(p, "%c", &drawname) != 1 || + (p = strtok(NULL, " \t\n")) == NULL || /* m_UnitCount: */ + sscanf(p, "%d", &LibEntry->m_UnitCount) != 1 ) + { + Msg.Printf( wxT("Wrong DEF format in line %d, skipped."),*LineNum); + DisplayError(frame, Msg); + while (GetLine(f, Line, LineNum, 1024) ) + { + p = strtok(Line, " \t\n"); + if (stricmp(p, "ENDDEF") == 0) break; + } + return NULL; + } + + else /* Mise a jour des infos de la ligne "DEF" */ + { + LibEntry->m_DrawPinNum = (drawnum == 'N') ? FALSE : TRUE; + LibEntry->m_DrawPinName = (drawname == 'N') ? FALSE : TRUE; + /* Copy part name and prefix. */ + strupper(Name); + if(Name[0] != '~') LibEntry->m_Name.m_Text = CONV_FROM_UTF8(Name); + else + { + LibEntry->m_Name.m_Text = CONV_FROM_UTF8(&Name[1]); + LibEntry->m_Name.m_Attributs |= TEXT_NO_VISIBLE; + } + + if (strcmp(Prefix, "~") == 0) + { + LibEntry->m_Prefix.m_Text.Empty(); + LibEntry->m_Prefix.m_Attributs |= TEXT_NO_VISIBLE; + } + else LibEntry->m_Prefix.m_Text = CONV_FROM_UTF8(Prefix); + + // Copy optional infos + if ( (p = strtok(NULL, " \t\n")) != NULL ) // m_UnitSelectionLocked param + { + if ( *p == 'L') LibEntry->m_UnitSelectionLocked = TRUE; + } + if ( (p = strtok(NULL, " \t\n")) != NULL ) /* Type Of Component */ + { + if ( *p == 'P') LibEntry->m_Options = ENTRY_POWER; + } + } + + /* Analyse lignes suivantes */ + while (GetLine(f, Line, LineNum, 1024) ) + { + p = strtok(Line, " \t\n"); + Res = TRUE; /* Pour test d'erreur (Res = FALSE = erreur) */ + + if( (Line[0] == 'T') && (Line[1] == 'i') ) + { + Res = ReadLibEntryDateAndTime(LibEntry, Line); + } + + else if(Line[0] == 'F') + { + Res = GetLibEntryField(LibEntry, Line); + } + + else if (strcmp(p, "ENDDEF") == 0) + { + break; + } + + else if (strcmp(p, "DRAW") == 0) + { + LibEntry->m_Drawings = GetDrawEntry(frame, f, Line, LineNum); + } + + else if(strncmp(p, "ALIAS", 5) == 0 ) + { + p = strtok(NULL, "\r\n"); + Res = AddAliasNames(LibEntry, p); + } + + else if(strncmp(p, "$FPLIST", 5) == 0 ) + { + Res = AddFootprintFilterList(LibEntry, f, Line, LineNum); + } + + else + { + Msg.Printf( wxT("Undefined command \"%s\" in line %d, skipped."), p, * LineNum); + frame->PrintMsg(Msg); + } + + /* Fin analyse de la ligne ou block: test de l'info lue */ + if (!Res) + { /* Something went wrong there. */ + Msg.Printf( wxT(" Error Line %d, Library not loaded"), *LineNum); + DisplayError(frame, Msg); + delete LibEntry; + return NULL; + } + } + + /* If we are here, this part is O.k. - put it in: */ + LibEntry->SortDrawItems(); + return LibEntry; +} + + + +/***************************************************************************** +* Routine to load a DRAW definition from given file. Note "DRAW" line has * +* been read already. Reads upto and include ENDDRAW, or an error (NULL ret). * +*****************************************************************************/ + +static LibEDA_BaseStruct *GetDrawEntry(WinEDA_DrawFrame * frame, FILE *f, char *Line, int *LineNum) +{ +int i = 0, jj, ll, Unit, Convert, size1, size2; +char *p, Buffer[1024], BufName[256], + PinNum[256], + chartmp[256], chartmp1[256]; +int ctmp; +wxString MsgLine; +bool Error = FALSE; +LibEDA_BaseStruct *Tail = NULL, + *New = NULL, + *Head = NULL; + + while (TRUE) + { + if (GetLine(f, Line, LineNum, 1024 ) == NULL) + { + DisplayError(frame, wxT("File ended prematurely")); + return Head; + } + + if (strncmp(Line, "ENDDRAW", 7) == 0) + { + break; + } + + New = NULL; + + switch (Line[0]) + { + case 'A': /* Arc */ + { + int startx, starty, endx, endy; + LibDrawArc * Arc = new LibDrawArc(); + New = Arc; + ll = 0; + int nbarg = sscanf(&Line[2], "%d %d %d %d %d %d %d %d %c %d %d %d %d", + &Arc->m_Pos.x, &Arc->m_Pos.y, &Arc->m_Rayon, + &Arc->t1, &Arc->t2, &Unit, &Convert, + &Arc->m_Width, &ctmp, &startx, &starty, &endx, &endy); + if ( nbarg < 8 ) Error = TRUE; + Arc->m_Unit = Unit; Arc->m_Convert = Convert; + if ( ctmp == 'F') Arc->m_Fill = FILLED_SHAPE; + if ( ctmp == 'f') Arc->m_Fill = FILLED_WITH_BG_BODYCOLOR; + + NORMALIZE_ANGLE(Arc->t1); + NORMALIZE_ANGLE(Arc->t2); + + if ( nbarg >= 13 ) // Coord reelles des extremites de l'arc lues + { + Arc->m_Start.x = startx; Arc->m_Start.y = starty; + Arc->m_End.x = endx; Arc->m_End.y = endy; + } + else + { + Arc->m_Start.x = Arc->m_Rayon; Arc->m_Start.y = 0; + Arc->m_End.x = Arc->m_Rayon; Arc->m_End.y = 0; + RotatePoint( &Arc->m_Start.x, &Arc->m_Start.y, -Arc->t1); + Arc->m_Start.x += Arc->m_Pos.x; Arc->m_Start.y +=Arc->m_Pos.y; + RotatePoint( &Arc->m_End.x, &Arc->m_End.y, -Arc->t2); + Arc->m_End.x += Arc->m_Pos.x; Arc->m_End.y +=Arc->m_Pos.y; + } + } + break; + + case 'C': /* Circle */ + { + LibDrawCircle * Circle = new LibDrawCircle(); + New = Circle; ll = 0; + Error = sscanf(&Line[2], "%d %d %d %d %d %d %c", + &Circle->m_Pos.x, &Circle->m_Pos.y, &Circle->m_Rayon, + &Unit, &Convert,&Circle->m_Width, &ctmp) < 6; + Circle->m_Unit = Unit; + Circle->m_Convert = Convert; + if ( ctmp == 'F') Circle->m_Fill = FILLED_SHAPE; + if ( ctmp == 'f') Circle->m_Fill = FILLED_WITH_BG_BODYCOLOR; + } + break; + + case 'T': /* Text */ + { + LibDrawText * Text = new LibDrawText(); + New = Text; + Buffer[0] = 0; + Error = sscanf(&Line[2], "%d %d %d %d %d %d %d %s", + &Text->m_Horiz, + &Text->m_Pos.x, &Text->m_Pos.y, + &Text->m_Size.x, &Text->m_Type, + &Unit, &Convert, Buffer) != 8; + + Text->m_Unit = Unit; Text->m_Convert = Convert; + Text->m_Size.y = Text->m_Size.x; + if (!Error) + { /* Convert '~' to spaces. */ + Text->m_Text = CONV_FROM_UTF8(Buffer); + Text->m_Text.Replace(wxT("~"), wxT(" ")); // Les espaces sont restitués + } + } + break; + + case 'S': /* Square */ + { + LibDrawSquare * Square = new LibDrawSquare(); + New = Square; ll = 0; + Error = sscanf(&Line[2], "%d %d %d %d %d %d %d %s", + &Square->m_Start.x, &Square->m_Start.y, + &Square->m_End.x, &Square->m_End.y, + &Unit, &Convert,&Square->m_Width, &ctmp) < 7; + Square->m_Unit = Unit; Square->m_Convert = Convert; + if ( ctmp == 'F') Square->m_Fill = FILLED_SHAPE; + if ( ctmp == 'f') Square->m_Fill = FILLED_WITH_BG_BODYCOLOR; + } + break; + + case 'X': /* Pin Description */ + { + *Buffer = 0; + LibDrawPin * Pin = new LibDrawPin(); + New = Pin; + i = sscanf(Line+2, "%s %s %d %d %d %s %d %d %d %d %s %s", + BufName, PinNum, + &Pin->m_Pos.x, &Pin->m_Pos.y, + &ll, chartmp1, + &size1, &size2, + &Unit, &Convert, chartmp, Buffer); + + Pin->m_SizeNum = size1; /* Parametres type short */ + Pin->m_SizeName = size2; + Pin->m_PinLen = ll; + Pin->m_Orient = chartmp1[0] & 255; + + Pin->m_Unit = Unit; Pin->m_Convert = Convert; + strncpy((char*)&Pin->m_PinNum, PinNum, 4); + Error = (i != 11 && i != 12); + + Pin->m_PinName = CONV_FROM_UTF8(BufName); + + jj = *chartmp & 255; + switch(jj) + { + case 'I': + Pin->m_PinType = PIN_INPUT; break; + case 'O': + Pin->m_PinType = PIN_OUTPUT; break; + case 'B': + Pin->m_PinType = PIN_BIDI; break; + case 'T': + Pin->m_PinType = PIN_TRISTATE; break; + case 'P': + Pin->m_PinType = PIN_PASSIVE; break; + case 'U': + Pin->m_PinType = PIN_UNSPECIFIED; break; + case 'W': + Pin->m_PinType = PIN_POWER_IN; break; + case 'w': + Pin->m_PinType = PIN_POWER_OUT; break; + case 'C': + Pin->m_PinType = PIN_OPENCOLLECTOR; break; + case 'E': + Pin->m_PinType = PIN_OPENEMITTER; break; + default: + MsgLine.Printf( wxT("Unknown Pin Type [%c] line %d"), + jj, *LineNum); + DisplayError(frame, MsgLine); + } + if( i == 12 ) /* Special Symbole defined */ + for( jj = strlen(Buffer); jj > 0 ; ) + { + switch(Buffer[--jj]) + { + case '~': break; + case 'N': Pin->m_Attributs |= PINNOTDRAW; break; + case 'I': Pin->m_PinShape |= INVERT; break; + case 'C': Pin->m_PinShape |= CLOCK; break; + case 'L': Pin->m_PinShape |= LOWLEVEL_IN; break; + case 'V': Pin->m_PinShape |= LOWLEVEL_OUT; break; + default: + MsgLine.Printf( wxT("Unknown Pin Shape [%c] line %d"), + Buffer[jj], *LineNum); + DisplayError(frame, MsgLine); break; + } + } + } + break; + + case 'P': /* Polyline */ + { + LibDrawPolyline * Polyl = new LibDrawPolyline(); + New = Polyl; + + if (sscanf(&Line[2], "%d %d %d %d", + &Polyl->n, &Unit, &Convert, + &Polyl->m_Width) == 4 && + Polyl->n > 0) + { + Polyl->m_Unit = Unit; Polyl->m_Convert = Convert; + + Polyl->PolyList = (int *) + MyZMalloc(sizeof(int) * Polyl->n * 2); + + p = strtok(&Line[2], " \t\n"); + p = strtok(NULL, " \t\n"); + p = strtok(NULL, " \t\n"); + p = strtok(NULL, " \t\n"); + + for (i = 0; i < Polyl->n * 2 && !Error; i++) + { + p = strtok(NULL, " \t\n"); + Error = sscanf(p, "%d", &Polyl->PolyList[i]) != 1; + } + Polyl->m_Fill = NO_FILL; + if ( (p = strtok(NULL, " \t\n")) != NULL ) + { + if ( p[0] == 'F') Polyl->m_Fill = FILLED_SHAPE; + if ( p[0] == 'f') + Polyl->m_Fill = FILLED_WITH_BG_BODYCOLOR; + } + } + + else Error = TRUE; + } + break; + + default: + MsgLine.Printf( wxT("Undefined DRAW command in line %d, aborted."), + *LineNum); + DisplayError(frame, MsgLine); + return Head; + } + + if (Error) + { + MsgLine.Printf( wxT("Error in %c DRAW command in line %d, aborted."), + Line[0], *LineNum); + DisplayError(frame, MsgLine); + delete New; + /* FLush till end of draw: */ + do { + if (GetLine(f, Line, LineNum, 1024 ) == NULL) + { + DisplayError(frame, wxT("File ended prematurely") ); + return Head; + } + } while (strncmp(Line, "ENDDRAW", 7) != 0); + return (Head); + } + + else + { + if (Head == NULL) Head = Tail = New; + else + { + Tail->Pnext = New; Tail = New; + } + } + } + + return Head; +} + + +/***************************************************************************** +* Routine to find the library given its name. * +*****************************************************************************/ +LibraryStruct *FindLibrary(const wxString & Name) +{ +LibraryStruct *Lib = g_LibraryList; + + while (Lib) + { + if (Lib->m_Name == Name ) return Lib; + Lib = Lib->m_Pnext; + } + return NULL; +} + +/***************************************************************************** +* Routine to find the number of libraries currently loaded. * +*****************************************************************************/ +int NumOfLibraries(void) +{ +int ii; +LibraryStruct *Lib = g_LibraryList; + + for (ii = 0; Lib != NULL; Lib = Lib->m_Pnext) ii++; + return ii; +} + + +/*****************************************************************************/ +static bool GetLibEntryField(EDA_LibComponentStruct *LibEntry, char * line) +/*****************************************************************************/ +/* Analyse la ligne de description du champ de la forme: + Fn "CA3130" 150 -200 50 H V + ou n = 0 (REFERENCE), 1 (VALUE) , 2 .. 11 = autres champs, facultatifs +*/ +{ +int posx, posy, size, orient, hjustify, vjustify; +bool draw; +char *Text, + Char1[256], Char2[256], + Char3[256], Char4[256], + FieldUserName[1024]; +int NumOfField, nbparam; +LibDrawField * Field = NULL; + + if( sscanf(line+1, "%d", &NumOfField) != 1) return(0); + + /* Recherche du debut des donnees (debut du texte suivant) */ + while(*line != 0) line++; + while(*line == 0) line++; + + /* recherche du texte */ + while ( *line && (*line != '"') ) line++; + if ( *line == 0 ) return(0); + line ++; Text = line; + + /* recherche fin de texte */ + while ( *line && (*line != '"') ) line++; + if ( *line == 0 ) return(0); + *line = 0; line++; + + FieldUserName[0] = 0; + nbparam = sscanf(line, " %d %d %d %c %c %c %c", + &posx, &posy, &size, Char1, Char2, Char3, Char4); + orient = TEXT_ORIENT_HORIZ; if(Char1[0] == 'V') orient = TEXT_ORIENT_VERT; + draw = TRUE; if(Char2[0] == 'I') draw = FALSE; + hjustify = GR_TEXT_HJUSTIFY_CENTER; + vjustify = GR_TEXT_VJUSTIFY_CENTER; + if ( nbparam >= 6 ) + { + if ( *Char3 == 'L' ) hjustify = GR_TEXT_HJUSTIFY_LEFT; + else if ( *Char3 == 'R' ) hjustify = GR_TEXT_HJUSTIFY_RIGHT; + if ( *Char4 == 'B' ) vjustify = GR_TEXT_VJUSTIFY_BOTTOM; + else if ( *Char4 == 'T' ) vjustify = GR_TEXT_VJUSTIFY_TOP; + } + switch(NumOfField) + { + case REFERENCE: + Field = &LibEntry->m_Prefix; + Field->m_FieldId = REFERENCE; + break; + + case VALUE: + Field = &LibEntry->m_Name; + Field->m_FieldId = VALUE; + break; + + default: + if(NumOfField >= NUMBER_OF_FIELDS ) break; + Field = new LibDrawField(NumOfField); + Field->Pnext = LibEntry->Fields; + LibEntry->Fields = Field; + break; + } + + if ( Field == NULL ) return FALSE; + + Field->m_Pos.x = posx; Field->m_Pos.y = posy; + Field->m_Orient = orient; + if( draw == FALSE ) Field->m_Attributs |= TEXT_NO_VISIBLE; + Field->m_Size.x = Field->m_Size.y = size; + Field->m_Text = CONV_FROM_UTF8(Text); + if ( NumOfField >= FIELD1 ) + { + ReadDelimitedText(FieldUserName,line, sizeof(FieldUserName) ); + Field->m_Name = CONV_FROM_UTF8(FieldUserName); + } + Field->m_HJustify = hjustify; + Field->m_VJustify = vjustify; + return(TRUE); +} + + +/********************************************************************/ +static bool AddAliasNames(EDA_LibComponentStruct *LibEntry, char * line) +/********************************************************************/ +/* Read the alias names (in buffer line) and add them in alias list + names are separated by spaces +*/ +{ +char * text; +wxString name; + text = strtok(line, " \t\r\n"); + + while ( text ) + { + name = CONV_FROM_UTF8(text); + LibEntry->m_AliasList.Add(name); + text = strtok(NULL, " \t\r\n"); + } + return( TRUE ); +} + +/********************************************************************/ +static void InsertAlias(PriorQue ** PQ, EDA_LibComponentStruct *LibEntry, + int *NumOfParts) +/********************************************************************/ +/* create in library (in list PQ) aliases of the "root" component LibEntry*/ +{ +EDA_LibCmpAliasStruct *AliasEntry; +unsigned ii; + + if(LibEntry->m_AliasList.GetCount() == 0) + return; /* No alias for this component */ + + for( ii = 0; ii < LibEntry->m_AliasList.GetCount(); ii++ ) + { + AliasEntry = new EDA_LibCmpAliasStruct(LibEntry->m_AliasList[ii], + LibEntry->m_Name.m_Text.GetData()); + ++*NumOfParts; + PQInsert(PQ, AliasEntry); + } +} + + /*******************************************************/ + /* Routines de lecture des Documentation de composants */ + /*******************************************************/ + +/**********************************************************************************************/ +int LoadDocLib(WinEDA_DrawFrame * frame, const wxString & FullDocLibName, const wxString & Libname) +/**********************************************************************************************/ +/* Routine to load a library from given open file.*/ +{ +int LineNum = 0; +char Line[1024], *Name, *Text; +EDA_LibComponentStruct * Entry; +FILE * f; +wxString msg; + + f = wxFopen(FullDocLibName, wxT("rt") ); + if (f == NULL) return(0); + + if ( GetLine(f, Line, &LineNum, sizeof(Line) ) == NULL) + { /* pas de lignes utiles */ + fclose(f); + return 0; + } + + if( strnicmp(Line, DOCFILE_IDENT, 10) != 0) + { + DisplayError(frame, wxT("File is NOT EESCHEMA doclib!") ); + fclose(f); + return 0; + } + + while (GetLine(f, Line, &LineNum, sizeof(Line)) ) + { + if (strncmp(Line, "$CMP",4) != 0) + { + msg.Printf( wxT("$CMP command expected in line %d, aborted."), LineNum); + DisplayError(frame, msg); + fclose(f); + return 0; + } + + /* Read one $CMP/$ENDCMP part entry from library: */ + Name = strtok(Line + 5,"\n\r"); + wxString cmpname; cmpname = CONV_FROM_UTF8(Name); + Entry = FindLibPart(cmpname.GetData(),Libname,FIND_ALIAS); + while( GetLine(f, Line, &LineNum, sizeof(Line)) ) + { + if( strncmp(Line, "$ENDCMP",7) == 0) break; + Text = strtok(Line + 2,"\n\r"); + switch ( Line[0] ) + { + case 'D': + if(Entry) Entry->m_Doc = CONV_FROM_UTF8(Text); + break; + + case 'K': + if(Entry) Entry->m_KeyWord = CONV_FROM_UTF8(Text); + break; + + case 'F': + if(Entry) Entry->m_DocFile = CONV_FROM_UTF8(Text); + break; + } + } + } + fclose(f); + return 1; +} + + +/*********************************************************************************/ +static bool ReadLibEntryDateAndTime(EDA_LibComponentStruct * LibEntry, char * Line) +/*********************************************************************************/ +/* lit date et time de modif composant sous le format: + "Ti yy/mm/jj hh:mm:ss" +*/ +{ +int year,mon,day,hour,min,sec; +char * text; + + year = mon = day = hour = min = sec = 0; + text = strtok(Line," \r\t\n"); + text = strtok(NULL," \r\t\n"); // text pointe donnees utiles + + sscanf(Line,"%d/%d/%d %d:%d:%d",&year,&mon,&day,&hour,&min,&sec); + + LibEntry->m_LastDate = (sec & 63) + + ((min & 63) << 6) + + ((hour & 31) << 12) + + ((day & 31) << 17) + + ((mon & 15) << 22) + + ((year-1990) << 26); + + return TRUE; +} + +/*******************************************/ +static int SortItemsFct(const void * ref, const void * item); +void EDA_LibComponentStruct::SortDrawItems(void) +/*******************************************/ +/* Trie les éléments graphiques d'un composant lib pour améliorer +le tracé: +items remplis en premier, pins en dernier +En cas de superposition d'items, c'est plus lisible +*/ +{ +LibEDA_BaseStruct ** Bufentry, ** BufentryBase, *Entry = m_Drawings; +int ii, nbitems; + + if(Entry == NULL ) return; /* Pas d'alias pour ce composant */ + /* calcul du nombre d'items */ + for( nbitems = 0; Entry != NULL; Entry = Entry->Next()) nbitems++; + + BufentryBase = + (LibEDA_BaseStruct **) MyZMalloc( (nbitems+1) * sizeof(LibEDA_BaseStruct *)); + /* memorisation du chainage : */ + for( Entry = m_Drawings, ii = 0; Entry != NULL; Entry = Entry->Next()) + BufentryBase[ii++] = Entry; + + /* Tri du chainage */ + qsort(BufentryBase, nbitems, sizeof(LibEDA_BaseStruct *), SortItemsFct); + + /* Mise a jour du chainage. Remarque: + le dernier element de BufEntryBase (BufEntryBase[nbitems]) est NULL*/ + m_Drawings = * BufentryBase; + Bufentry = BufentryBase; + for (ii = 0 ; ii < nbitems; ii++) + { + (* Bufentry)->Pnext = * (Bufentry+1); + Bufentry++; + } + + MyFree(BufentryBase); +} + +int SortItemsFct(const void * ref, const void * item) +{ +#define Ref (*(LibEDA_BaseStruct **)(ref)) +#define Item (*(LibEDA_BaseStruct **)(item)) +#define BEFORE -1 +#define AFTER 1 + +int fill_ref = 0, fill_item = 0; + + switch (Ref->m_StructType) + { + case COMPONENT_ARC_DRAW_TYPE: + { + const LibDrawArc * draw = (const LibDrawArc *) Ref; + fill_ref = draw->m_Fill; + break; + } + + case COMPONENT_CIRCLE_DRAW_TYPE: + { + const LibDrawCircle * draw = (const LibDrawCircle *) Ref; + fill_ref = draw->m_Fill; + break; + } + + case COMPONENT_RECT_DRAW_TYPE: + { + const LibDrawSquare * draw = (const LibDrawSquare *) Ref; + fill_ref = draw->m_Fill; + break; + } + + case COMPONENT_POLYLINE_DRAW_TYPE: + { + const LibDrawPolyline * draw = (const LibDrawPolyline *) Ref; + fill_ref = draw->m_Fill; + break; + } + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + if ( Item->m_StructType == COMPONENT_PIN_DRAW_TYPE ) return BEFORE; + if ( Item->m_StructType == COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ) return 0; + return 1; + break; + + case COMPONENT_PIN_DRAW_TYPE: + if ( Item->m_StructType == COMPONENT_PIN_DRAW_TYPE ) + { + int ii; + // We sort the pins by orientation + ii = ((LibDrawPin *) Ref)->m_Orient - ((LibDrawPin *) Item)->m_Orient; + if ( ii ) return ii; + + /* We sort the pins by position (x or y). + note: at this point, most of pins have same x pos or y pos, + because they are sorted by orientation and generally are vertically or + horizontally aligned */ + wxPoint pos_ref, pos_tst; + pos_ref = ((LibDrawPin *) Ref)->m_Pos; + pos_tst = ((LibDrawPin *) Item)->m_Pos; + if ( (ii = pos_ref.x - pos_tst.x) ) return ii; + ii = pos_ref.y - pos_tst.y; + return ii; + } + else return AFTER; + break; + } + + /* Test de l'item */ + switch (Item->m_StructType) + { + case COMPONENT_ARC_DRAW_TYPE: + { + const LibDrawArc * draw = (const LibDrawArc *) Item; + fill_item = draw->m_Fill; + break; + } + + case COMPONENT_CIRCLE_DRAW_TYPE: + { + const LibDrawCircle * draw = (const LibDrawCircle *) Item; + fill_item = draw->m_Fill; + break; + } + + case COMPONENT_RECT_DRAW_TYPE: + { + const LibDrawSquare * draw = (const LibDrawSquare *) Item; + fill_item = draw->m_Fill; + break; + } + + case COMPONENT_POLYLINE_DRAW_TYPE: + { + const LibDrawPolyline * draw = (const LibDrawPolyline *) Item; + fill_item = draw->m_Fill; + break; + } + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + return BEFORE; + break; + + case COMPONENT_PIN_DRAW_TYPE: + return BEFORE; + break; + } + + if ( fill_ref & fill_item ) return 0; + if ( fill_ref ) return BEFORE; + return AFTER; +} + + +/*****************************************************************************/ +int AddFootprintFilterList(EDA_LibComponentStruct *LibEntryLibEntry, FILE * f, + char * Line, int *LineNum) +/******************************************************************************/ +/* read the FootprintFilter List stating with: + FPLIST + and ending with: + ENDFPLIST +*/ +{ + for ( ; ; ) + { + if (GetLine(f, Line, LineNum, 1024 ) == NULL) + { + DisplayError(NULL, wxT("File ended prematurely")); + return 0; + } + + if ( stricmp(Line, "$ENDFPLIST") == 0 ) + { + break; /*normal exit on end of list */ + } + + LibEntryLibEntry->m_FootprintList.Add(CONV_FROM_UTF8(Line+1)); + } + + return 1; +} diff --git a/eeschema/eelibs2.cpp b/eeschema/eelibs2.cpp new file mode 100644 index 0000000000..d9fa4d7a4f --- /dev/null +++ b/eeschema/eelibs2.cpp @@ -0,0 +1,974 @@ + /********************************************************/ + /* Module to handle libraries (second part - drawing ). */ + /********************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "component_class.h" +#include "general.h" +#include "trigo.h" +#include "protos.h" + +#define UNVISIBLE_COLOR DARKGRAY + +//#define DRAW_ARC_WITH_ANGLE // pour trace arc avec routine utilsant les angles + + +/* Fonctions locales */ + +/* Description du composant utilisé lorsque des composants non trouvés +en librarie doivent etre dessinés */ +/* +ce composant est un rectangle de 400 mils de coté avec le texte ?? au centre +DEF DUMMY U 0 40 Y Y 1 0 N +F0 "U" 0 -350 60 H V +F1 "DUMMY" 0 350 60 H V +DRAW +T 0 0 0 150 0 0 0 ?? +S -200 200 200 -200 0 1 0 +ENDDRAW +ENDDEF +*/ + +static int s_ItemSelectColor = BROWN; + +static EDA_LibComponentStruct * DummyCmp; +static int * Buf_Poly_Drawings, Buf_Poly_Size; // Used fo polyline drawings +static void DrawLibPartAux(WinEDA_DrawPanel * panel, wxDC * DC, + EDA_SchComponentStruct *Component, + EDA_LibComponentStruct *Entry, + const wxPoint & Pos, + int TransMat[2][2], + int Multi, int convert, + int DrawMode, int Color = -1, bool DrawPinText = TRUE); + +/******************************/ +static void CreateDummyCmp(void) +/******************************/ +{ + DummyCmp = new EDA_LibComponentStruct( NULL); + + LibDrawSquare * Square = new LibDrawSquare(); + Square->m_Start = wxPoint(- 200,200); + Square->m_End = wxPoint(200, - 200); + Square->m_Width = 4; + + LibDrawText * Text = new LibDrawText(); + Text->m_Size.x = Text->m_Size.y = 150; + Text->m_Text = wxT("??"); + + DummyCmp->m_Drawings = Square; + Square->Pnext = Text; +} + + +/*************************************************************/ +void DrawLibEntry(WinEDA_DrawPanel * panel,wxDC * DC, + EDA_LibComponentStruct *LibEntry, + int posX, int posY, + int Multi, int convert, + int DrawMode, int Color) +/**************************************************************/ +/* Routine de dessin d'un composant d'une librairie + LibEntry = pointeur sur la description en librairie + posX, posY = position du composant + DrawMode = GrOR .. + Color = 0 : dessin en vraies couleurs, sinon couleur = Color + + Une croix symbolise le point d'accrochage (ref position) du composant + + Le composant est toujours trace avec orientation 0 +*/ +{ +int color; +int TransMat[2][2]; +wxString Prefix; +LibDrawField * Field; +wxPoint text_pos; + + /* Orientation normale */ + TransMat[0][0] = 1; TransMat[1][1] = -1; + TransMat[1][0] = TransMat[0][1] = 0; + + DrawLibPartAux(panel, DC, NULL, LibEntry, wxPoint(posX, posY), + TransMat, Multi, + convert, DrawMode, Color); + + /* Trace des 2 champs ref et value (Attention aux coord: la matrice + de transformation change de signe les coord Y */ + + GRSetDrawMode(DC, DrawMode); + + if( LibEntry->m_Prefix.m_Attributs & TEXT_NO_VISIBLE ) + { + if( Color >= 0 ) color = Color; + else color = UNVISIBLE_COLOR; + } + + else { + if( Color >= 0) color = Color; + else color = ReturnLayerColor(LAYER_REFERENCEPART); + } + + if (LibEntry->m_UnitCount > 1) + Prefix.Printf( wxT("%s?%c"),LibEntry->m_Prefix.m_Text.GetData(),Multi + 'A' - 1); + else Prefix = LibEntry->m_Prefix.m_Text + wxT("?"); + + text_pos.x = LibEntry->m_Prefix.m_Pos.x + posX; + text_pos.y = posY - LibEntry->m_Prefix.m_Pos.y; + DrawGraphicText(panel, DC, text_pos, + color,LibEntry->m_Prefix.m_Text.GetData(), + LibEntry->m_Prefix.m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + LibEntry->m_Prefix.m_Size, + LibEntry->m_Prefix.m_HJustify, LibEntry->m_Prefix.m_VJustify); + + if( LibEntry->m_Name.m_Attributs & TEXT_NO_VISIBLE ) + { + if( Color >= 0) color = Color; + else color = UNVISIBLE_COLOR; + } + + else { + if( Color >= 0 ) color = Color; + else color = ReturnLayerColor(LAYER_VALUEPART); + } + + text_pos.x = LibEntry->m_Name.m_Pos.x + posX; + text_pos.y = posY - LibEntry->m_Name.m_Pos.y; + DrawGraphicText(panel, DC, text_pos, + color, LibEntry->m_Name.m_Text.GetData(), + LibEntry->m_Name.m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + LibEntry->m_Name.m_Size, + LibEntry->m_Name.m_HJustify, LibEntry->m_Name.m_VJustify); + + for( Field = LibEntry->Fields; Field != NULL; Field = (LibDrawField *)Field->Pnext ) + { + if( Field->m_Text.IsEmpty() ) return; + if( Field->m_Attributs & TEXT_NO_VISIBLE ) + { + if( Color >= 0) color = Color; + else color = UNVISIBLE_COLOR; + } + else { + if( Color >= 0) color = Color; + else color = ReturnLayerColor(LAYER_FIELDS); + } + + text_pos.x = Field->m_Pos.x + posX; + text_pos.y = posY - Field->m_Pos.y; + DrawGraphicText(panel, DC, text_pos, + color, Field->m_Text, + Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, + Field->m_HJustify, Field->m_VJustify); + } + + // Tracé de l'ancre + int len = 3 * panel->GetZoom(); + GRLine(&panel->m_ClipBox, DC, posX, posY - len, posX, posY + len, color); + GRLine(&panel->m_ClipBox, DC, posX - len, posY, posX + len, posY, color); + +} + +/***************************************************************************** +* Routine to draw the given part at given position, transformed/mirror as * +* specified, and in the given drawing mode. Only this one is visible... * +*****************************************************************************/ +void EDA_SchComponentStruct::Draw(WinEDA_DrawPanel * panel,wxDC * DC, + const wxPoint & offset, int DrawMode, int Color) +{ +EDA_LibComponentStruct *Entry; +int ii; +bool dummy = FALSE; + + if( (Entry = FindLibPart(m_ChipName.GetData(),wxEmptyString,FIND_ROOT)) == NULL) + { /* composant non trouvé, on affiche un composant "dummy" */ + dummy = TRUE; + if( DummyCmp == NULL ) CreateDummyCmp(); + Entry = DummyCmp; + } + + DrawLibPartAux(panel, DC, this, Entry, m_Pos + offset, + m_Transform, + dummy ? 0 : m_Multi, + dummy ? 0 : m_Convert, + DrawMode); + + /* Trace des champs, avec placement et orientation selon orient. du + composant + */ + + if( ((m_Field[REFERENCE].m_Attributs & TEXT_NO_VISIBLE) == 0) + && ! (m_Field[REFERENCE].m_Flags & IS_MOVED) ) + { + if ( Entry->m_UnitCount > 1 ) + DrawTextField(panel, DC, &m_Field[REFERENCE],1,DrawMode); + else + DrawTextField(panel, DC, &m_Field[REFERENCE],0,DrawMode); + } + + for( ii = VALUE; ii < NUMBER_OF_FIELDS; ii++ ) + { + if (m_Field[ii].m_Flags & IS_MOVED) continue; + DrawTextField(panel, DC, &m_Field[ii],0,DrawMode); + } +} + +/***********************************************************/ +void DrawTextField(WinEDA_DrawPanel * panel,wxDC * DC, + PartTextStruct * Field, int IsMulti, int DrawMode) +/***********************************************************/ +/* Routine de trace des textes type Field du composant. + entree: + IsMulti: flag Non Null si il y a plusieurs parts par boitier. + n'est utile que pour le champ reference pour ajouter a celui ci + l'identification de la part ( A, B ... ) + DrawMode: mode de trace +*/ +{ +int orient, color; +wxPoint pos; /* Position des textes */ +EDA_SchComponentStruct *DrawLibItem = (EDA_SchComponentStruct *) Field->m_Parent; +int hjustify, vjustify; + + if( Field->m_Attributs & TEXT_NO_VISIBLE ) return; + if( Field->IsVoid() ) return; + + GRSetDrawMode(DC, DrawMode); + + /* Calcul de la position des textes, selon orientation du composant */ + orient = Field->m_Orient; + hjustify = Field->m_HJustify; vjustify = Field->m_VJustify; + pos.x = Field->m_Pos.x - DrawLibItem->m_Pos.x; + pos.y = Field->m_Pos.y - DrawLibItem->m_Pos.y; + + pos = DrawLibItem->GetScreenCoord(pos); + pos.x += DrawLibItem->m_Pos.x; + pos.y += DrawLibItem->m_Pos.y; + + /* Y a t-il rotation (pour l'orientation, la justification)*/ + if(DrawLibItem->m_Transform[0][1]) // Rotation du composant de 90deg + { + if ( orient == TEXT_ORIENT_HORIZ) orient = TEXT_ORIENT_VERT; + else orient = TEXT_ORIENT_HORIZ; + /* Y a t-il rotation, miroir (pour les justifications)*/ + EXCHG(hjustify, vjustify); + if (DrawLibItem->m_Transform[1][0] < 0 ) vjustify = - vjustify; + if (DrawLibItem->m_Transform[1][0] > 0 ) hjustify = - hjustify; + } + else + { /* Texte horizontal: Y a t-il miroir (pour les justifications)*/ + if (DrawLibItem->m_Transform[0][0] < 0 ) + hjustify = - hjustify; + if (DrawLibItem->m_Transform[1][1] > 0 ) + vjustify = - vjustify; + } + + if( Field->m_FieldId == REFERENCE ) + color = ReturnLayerColor(LAYER_REFERENCEPART); + else if( Field->m_FieldId == VALUE ) + color = ReturnLayerColor(LAYER_VALUEPART); + else color = ReturnLayerColor(LAYER_FIELDS); + if( !IsMulti || (Field->m_FieldId != REFERENCE) ) + { + DrawGraphicText(panel, DC, pos, color, Field->m_Text.GetData(), + orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, + hjustify, vjustify); + } + + else /* Le champ est la reference, et il y a plusieurs parts par boitier */ + {/* On ajoute alors A ou B ... a la reference */ + wxString fulltext = Field->m_Text; + fulltext.Append('A' - 1 + DrawLibItem->m_Multi); + DrawGraphicText(panel, DC, pos, color, fulltext.GetData(), + orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, + hjustify, vjustify); + } +} + + +/********************************************************************************/ +EDA_LibComponentStruct *FindLibPart(const wxChar *Name, const wxString & LibName, int Alias) +/********************************************************************************/ +/* + Routine to find a part in one of the libraries given its name. + Name = Name of part. + LibName = Name of Lib; if "": seach in all libs + Alias = Flag: si flag != 0, retourne un pointeur sur une part ou un alias + si flag = 0, retourne un pointeur sur une part meme si le nom + correspond a un alias + Alias = FIND_ROOT, ou Alias = FIND_ALIAS +*/ +{ +EDA_LibComponentStruct *Entry; +static EDA_LibComponentStruct DummyEntry(wxEmptyString); /* Used only to call PQFind. */ +LibraryStruct *Lib = g_LibraryList; + + DummyEntry.m_Drawings = NULL; /* Used only to call PQFind. */ + DummyEntry.m_Name.m_Text = Name; + + PQCompFunc((PQCompFuncType) LibraryEntryCompare); + + Entry = NULL; FindLibName.Empty(); + while (Lib) + { + if( ! LibName.IsEmpty() ) + { + if( Lib->m_Name != LibName ) + { + Lib = Lib->m_Pnext; continue ; + } + } + if( Lib == NULL ) break; + Entry = (EDA_LibComponentStruct*)PQFind(Lib->m_Entries, &DummyEntry); + if( Entry != NULL) + { + FindLibName = Lib->m_Name; + break; + } + Lib = Lib->m_Pnext; + } + + /* Si le nom est un alias, recherche du vrai composant */ + if( Entry ) + { + if( (Entry->Type != ROOT ) && (Alias == FIND_ROOT) ) + Entry = FindLibPart( ((EDA_LibCmpAliasStruct*)Entry)->m_RootName.GetData() , + Lib->m_Name, FIND_ROOT); + } + + return (Entry); +} + +/***************************************************************************** +* Routine to draw the given part at given position, transformed/mirror as +* specified, and in the given drawing mode. +* if Color < 0: Draw in normal color +* else draw in color = Color +*****************************************************************************/ +/* DrawMode = GrXOR, GrOR ..*/ +void DrawLibPartAux(WinEDA_DrawPanel * panel,wxDC * DC, + EDA_SchComponentStruct *Component, + EDA_LibComponentStruct *Entry, + const wxPoint & Pos, + int TransMat[2][2], + int Multi, int convert, int DrawMode, + int Color, bool DrawPinText) +{ +int i, x1, y1, x2, y2, t1, t2, orient; +LibEDA_BaseStruct *DEntry = NULL; +int CharColor; +int fill_option; +int SetHightColor; +//#define GETCOLOR(l) Color < 0 ? (ReturnLayerColor(l)| SetHightColor) : Color; +#define GETCOLOR(l) Color < 0 ? SetHightColor ? s_ItemSelectColor : (ReturnLayerColor(l)| SetHightColor) : Color; + + if (Entry->m_Drawings == NULL) return; + GRSetDrawMode(DC, DrawMode); + + for( DEntry = Entry->m_Drawings; DEntry != NULL;DEntry = DEntry->Next()) + { + /* Elimination des elements non relatifs a l'unite */ + if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) ) continue; + if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) ) + continue; + + if ( DEntry->m_Flags & IS_MOVED ) continue; // Element en deplacement non trace + SetHightColor = (DEntry->m_Selected & IS_SELECTED) ? HIGHT_LIGHT_FLAG : 0; + switch (DEntry->m_StructType) + { + case COMPONENT_ARC_DRAW_TYPE: + { + int xc,yc, x2, y2; + LibDrawArc * Arc = (LibDrawArc *) DEntry; + CharColor = GETCOLOR(LAYER_DEVICE); + xc = Pos.x + TransMat[0][0] * Arc->m_Pos.x + + TransMat[0][1] * Arc->m_Pos.y; + yc = Pos.y + TransMat[1][0] * Arc->m_Pos.x + + TransMat[1][1] * Arc->m_Pos.y; + x2 = Pos.x + TransMat[0][0] * Arc->m_Start.x + + TransMat[0][1] * Arc->m_Start.y;; + y2 = Pos.y + TransMat[1][0] * Arc->m_Start.x + + TransMat[1][1] * Arc->m_Start.y; + x1 = Pos.x + TransMat[0][0] * Arc->m_End.x + + TransMat[0][1] * Arc->m_End.y;; + y1 = Pos.y + TransMat[1][0] * Arc->m_End.x + + TransMat[1][1] * Arc->m_End.y; + t1 = Arc->t1; t2 = Arc->t2; + bool swap = MapAngles(&t1, &t2, TransMat); + if ( swap ) { EXCHG(x1,x2); EXCHG(y1, y2) } + fill_option = Arc->m_Fill & (~g_PrintFillMask); + if ( Color < 0 ) // Normal Color Layer + { + if ( (fill_option == FILLED_WITH_BG_BODYCOLOR) && ! g_IsPrinting ) + GRFilledArc(&panel->m_ClipBox, DC, xc, yc, t1, t2, + Arc->m_Rayon, CharColor, + ReturnLayerColor(LAYER_DEVICE_BACKGROUND)); + else if ( fill_option == FILLED_SHAPE) + GRFilledArc(&panel->m_ClipBox, DC, xc, yc, t1, t2, + Arc->m_Rayon, CharColor, CharColor); +#ifdef DRAW_ARC_WITH_ANGLE + else GRArc(&panel->m_ClipBox, DC, xc, yc, t1, t2, + Arc->m_Rayon, CharColor); +#else + else GRArc1(&panel->m_ClipBox, DC, x1, y1, x2, y2, + xc, yc , CharColor); +#endif + } +#ifdef DRAW_ARC_WITH_ANGLE + else GRArc(&panel->m_ClipBox, DC, xc, yc, t1, t2, + Arc->m_Rayon, CharColor); +#else + else GRArc1(&panel->m_ClipBox, DC, x1, y1, x2, y2, + xc, yc, CharColor); +#endif + } + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + { + LibDrawCircle * Circle = (LibDrawCircle *) DEntry; + CharColor = GETCOLOR(LAYER_DEVICE); + x1 = Pos.x + TransMat[0][0] * Circle->m_Pos.x + + TransMat[0][1] * Circle->m_Pos.y; + y1 = Pos.y + TransMat[1][0] * Circle->m_Pos.x + + TransMat[1][1] * Circle->m_Pos.y; + fill_option = Circle->m_Fill & (~g_PrintFillMask); + if ( Color < 0 ) + { + if ( (fill_option == FILLED_WITH_BG_BODYCOLOR) && ! g_IsPrinting ) + GRFilledCircle(&panel->m_ClipBox, DC, x1, y1, + Circle->m_Rayon, CharColor, + ReturnLayerColor(LAYER_DEVICE_BACKGROUND)); + else if ( fill_option == FILLED_SHAPE) + GRFilledCircle(&panel->m_ClipBox, DC, x1, y1, + Circle->m_Rayon, CharColor, CharColor); + else GRCircle(&panel->m_ClipBox, DC, x1, y1, + Circle->m_Rayon, CharColor); + } + else GRCircle(&panel->m_ClipBox, DC, x1, y1, + Circle->m_Rayon, CharColor); + } + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + { + LibDrawText * Text = (LibDrawText *) DEntry; + CharColor = GETCOLOR(LAYER_DEVICE); + + /* The text orientation may need to be flipped if the + transformation matrix cuases xy axes to be flipped. */ + t1 = (TransMat[0][0] != 0) ^ (Text->m_Horiz != 0); + x1 = Pos.x + TransMat[0][0] * Text->m_Pos.x + + TransMat[0][1] * Text->m_Pos.y; + y1 = Pos.y + TransMat[1][0] * Text->m_Pos.x + + TransMat[1][1] * Text->m_Pos.y; + PutTextInfo(panel, DC, t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT, + wxPoint(x1, y1), + Text->m_Size, + Text->m_Text, DrawMode,CharColor); + } + break; + + case COMPONENT_RECT_DRAW_TYPE: + { + LibDrawSquare * Square = (LibDrawSquare *) DEntry; + CharColor = GETCOLOR(LAYER_DEVICE); + + x1 = Pos.x + TransMat[0][0] * Square->m_Start.x + + TransMat[0][1] * Square->m_Start.y; + y1 = Pos.y + TransMat[1][0] * Square->m_Start.x + + TransMat[1][1] * Square->m_Start.y; + x2 = Pos.x + TransMat[0][0] * Square->m_End.x + + TransMat[0][1] * Square->m_End.y; + y2 = Pos.y + TransMat[1][0] * Square->m_End.x + + TransMat[1][1] * Square->m_End.y; + fill_option = Square->m_Fill & (~g_PrintFillMask); + if ( Color < 0 ) + { + if ( (fill_option == FILLED_WITH_BG_BODYCOLOR) && ! g_IsPrinting ) + GRFilledRect(&panel->m_ClipBox, DC, x1, y1, x2, y2, + CharColor, + ReturnLayerColor(LAYER_DEVICE_BACKGROUND)); + else if ( fill_option == FILLED_SHAPE) + GRFilledRect(&panel->m_ClipBox, DC, x1, y1, x2, y2, + CharColor, CharColor); + else GRRect(&panel->m_ClipBox, DC, x1, y1, x2, y2, + CharColor); + } + else GRRect(&panel->m_ClipBox, DC, x1, y1, x2, y2, + CharColor); + } + break; + + case COMPONENT_PIN_DRAW_TYPE: /* Trace des Pins */ + { + LibDrawPin * Pin = (LibDrawPin *) DEntry; + if(Pin->m_Attributs & PINNOTDRAW) + { + if( (ActiveScreen->m_Type == SCHEMATIC_FRAME) && + !g_ShowAllPins ) + break; + } + /* Calcul de l'orientation reelle de la Pin */ + orient = Pin->ReturnPinDrawOrient(TransMat); + + /* Calcul de la position du point de reference */ + x2 = Pos.x + (TransMat[0][0] * Pin->m_Pos.x) + + (TransMat[0][1] * Pin->m_Pos.y); + y2 = Pos.y + (TransMat[1][0] * Pin->m_Pos.x) + + (TransMat[1][1] * Pin->m_Pos.y); + + /* Dessin de la pin et du symbole special associe */ + CharColor = GETCOLOR(LAYER_PIN); + DrawPinSymbol(panel, DC, x2, y2, Pin->m_PinLen, orient, + Pin->m_PinShape, DrawMode, + CharColor ); + + if ( DrawPinText ) + { + wxPoint pinpos(x2,y2); + CharColor = SetHightColor ? s_ItemSelectColor : Color; + Pin->DrawPinTexts(panel, DC, pinpos, orient, + Entry->m_TextInside, + Entry->m_DrawPinNum,Entry->m_DrawPinName, + CharColor, DrawMode); + } + } + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + { + LibDrawPolyline * polyline = (LibDrawPolyline *) DEntry; + CharColor = GETCOLOR(LAYER_DEVICE); + if ( Buf_Poly_Drawings == NULL ) + { + Buf_Poly_Size = polyline->n; + Buf_Poly_Drawings = (int *) MyMalloc(sizeof(int) * 2 * Buf_Poly_Size); + } + else if ( Buf_Poly_Size < polyline->n ) + { + Buf_Poly_Size = polyline->n; + Buf_Poly_Drawings = (int *) realloc(Buf_Poly_Drawings, + sizeof(int) * 2 * Buf_Poly_Size); + } + for (i = 0; i < polyline->n; i++) + { + Buf_Poly_Drawings[i * 2] = Pos.x + + TransMat[0][0] * polyline->PolyList[i * 2] + + TransMat[0][1] * polyline->PolyList[i * 2 + 1]; + Buf_Poly_Drawings[i * 2 + 1] = Pos.y + + TransMat[1][0] * polyline->PolyList[i * 2] + + TransMat[1][1] * polyline->PolyList[i * 2 + 1]; + } + fill_option = polyline->m_Fill & (~g_PrintFillMask); + if ( Color < 0 ) + { + if ( (fill_option == FILLED_WITH_BG_BODYCOLOR) && ! g_IsPrinting ) + GRPoly(&panel->m_ClipBox, DC, polyline->n, + Buf_Poly_Drawings, 1, CharColor, + ReturnLayerColor(LAYER_DEVICE_BACKGROUND)); + else if ( fill_option == FILLED_SHAPE) + GRPoly(&panel->m_ClipBox, DC, polyline->n, + Buf_Poly_Drawings, 1, CharColor, CharColor); + else GRPoly(&panel->m_ClipBox, DC, polyline->n, + Buf_Poly_Drawings, 0, CharColor, CharColor); + } + else GRPoly(&panel->m_ClipBox, DC, polyline->n, + Buf_Poly_Drawings, 0, CharColor, CharColor); + } + break; + + default: + wxBell(); + break; + } /* Fin Switch */ + } /* Fin Boucle de dessin */ + if ( g_DebugLevel > 4 ) /* Draw the component boundary box */ + { + EDA_Rect BoundaryBox; + if ( Component ) BoundaryBox = Component->GetBoundaryBox(); + else BoundaryBox = Entry->GetBoundaryBox(Multi, convert); + x1 = BoundaryBox.GetX(); + y1 = BoundaryBox.GetY(); + x2 = BoundaryBox.GetRight(); + y2 = BoundaryBox.GetBottom(); + GRRect(&panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN); + BoundaryBox = Component->m_Field[REFERENCE].GetBoundaryBox(); + x1 = BoundaryBox.GetX(); + y1 = BoundaryBox.GetY(); + x2 = BoundaryBox.GetRight(); + y2 = BoundaryBox.GetBottom(); + GRRect(&panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN); + BoundaryBox = Component->m_Field[VALUE].GetBoundaryBox(); + x1 = BoundaryBox.GetX(); + y1 = BoundaryBox.GetY(); + x2 = BoundaryBox.GetRight(); + y2 = BoundaryBox.GetBottom(); + GRRect(&panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN); + } +} + + +/*******************************************************/ +void DrawPinSymbol(WinEDA_DrawPanel * panel, wxDC * DC, + int posX, int posY, int len, int orient, + int Shape, int DrawMode, int Color) +/*******************************************************/ + +/* Dessine la pin du symbole en cours de trace + si Color != 0 dessin en couleur Color, sinon en couleurs standard. +*/ +{ +int MapX1, MapY1, x1, y1; +int color; + + if( Color >= 0) color = Color; + else color = ReturnLayerColor(LAYER_PIN); + GRSetDrawMode(DC, DrawMode); + + + MapX1 = MapY1 = 0; x1 = posX; y1 = posY; + switch ( orient ) + { + case PIN_UP: + y1 = posY - len; MapY1 = 1; + break; + case PIN_DOWN: + y1 = posY + len; MapY1 = -1; + break; + case PIN_LEFT: + x1 = posX - len, MapX1 = 1; + break; + case PIN_RIGHT: + x1 = posX + len; MapX1 = -1; + break; + } + + if( Shape & INVERT) + { + GRCircle(&panel->m_ClipBox, DC, MapX1 * INVERT_PIN_RADIUS + x1, + MapY1 * INVERT_PIN_RADIUS + y1, + INVERT_PIN_RADIUS, color); + + GRMoveTo(MapX1 * INVERT_PIN_RADIUS * 2 + x1, + MapY1 * INVERT_PIN_RADIUS * 2 + y1); + GRLineTo(&panel->m_ClipBox, DC, posX, posY, color); + } + + else + { + GRMoveTo(x1, y1); + GRLineTo(&panel->m_ClipBox, DC, posX, posY, color); + } + + if(Shape & CLOCK) + { + if(MapY1 == 0 ) /* MapX1 = +- 1 */ + { + GRMoveTo(x1, y1 + CLOCK_PIN_DIM); + GRLineTo(&panel->m_ClipBox, DC, x1 - MapX1 * CLOCK_PIN_DIM, y1, color); + GRLineTo(&panel->m_ClipBox, DC, x1, y1 - CLOCK_PIN_DIM, color); + } + else /* MapX1 = 0 */ + { + GRMoveTo(x1 + CLOCK_PIN_DIM, y1 ); + GRLineTo(&panel->m_ClipBox, DC, x1, y1 - MapY1 * CLOCK_PIN_DIM, color); + GRLineTo(&panel->m_ClipBox, DC, x1 - CLOCK_PIN_DIM, y1, color); + } + } + + if(Shape & LOWLEVEL_IN) /* IEEE symbol "Active Low Input" */ + { + if(MapY1 == 0 ) /* MapX1 = +- 1 */ + { + GRMoveTo(x1 + MapX1 * IEEE_SYMBOL_PIN_DIM*2, y1); + GRLineTo(&panel->m_ClipBox, DC, x1 + MapX1 * IEEE_SYMBOL_PIN_DIM*2, + y1 - IEEE_SYMBOL_PIN_DIM, color); + GRLineTo(&panel->m_ClipBox, DC, x1, y1, color); + } + else /* MapX1 = 0 */ + { + GRMoveTo(x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM*2); + GRLineTo(&panel->m_ClipBox, DC, x1 - IEEE_SYMBOL_PIN_DIM, + y1 + MapY1 * IEEE_SYMBOL_PIN_DIM*2, color); + GRLineTo(&panel->m_ClipBox, DC, x1 , y1, color); + } + } + + + if(Shape & LOWLEVEL_OUT) /* IEEE symbol "Active Low Output" */ + { + if(MapY1 == 0 ) /* MapX1 = +- 1 */ + { + GRMoveTo(x1, y1 - IEEE_SYMBOL_PIN_DIM); + GRLineTo(&panel->m_ClipBox, DC, x1 + MapX1 * IEEE_SYMBOL_PIN_DIM*2, y1, color); + } + else /* MapX1 = 0 */ + { + GRMoveTo(x1 - IEEE_SYMBOL_PIN_DIM, y1); + GRLineTo(&panel->m_ClipBox, DC, x1 , y1 + MapY1 * IEEE_SYMBOL_PIN_DIM*2, color); + } + } + + /* Draw the pin end target (active end of the pin) */ + if ( ! g_IsPrinting ) // Draw but do not print the pin end target */ + GRCircle(&panel->m_ClipBox, DC, posX,posY,TARGET_PIN_DIAM, color); +} + + +/***************************************************************************** +* Routine to rotate the given angular direction by the given Transformation. * +* Input (and output) angles must be as follows: * +* Unit is 0.1 degre * +* Angle1 in [0..3600], Angle2 > Angle1 in [0..7200]. Arc is assumed to be less * +* than 180.0 degrees. * +* Algorithm: * +* Map the angles to a point on the unit circle which is mapped using the * +* transform (only mirror and rotate so it remains on the unit circle) to * +* a new point which is used to detect new angle. * +*****************************************************************************/ +bool MapAngles(int *Angle1, int *Angle2, int TransMat[2][2]) +{ +int Angle, Delta; +double x, y, t; +bool swap = FALSE; + + Delta = *Angle2 - *Angle1; + if ( Delta >= 1800 ) + { + *Angle1 -=1; + *Angle2 +=1; + } + + x = cos(*Angle1 * M_PI / 1800.0); + y = sin(*Angle1 * M_PI / 1800.0); + t = x * TransMat[0][0] + y * TransMat[0][1]; + y = x * TransMat[1][0] + y * TransMat[1][1]; + x = t; + *Angle1 = (int) (atan2(y, x) * 1800.0 / M_PI + 0.5); + + x = cos(*Angle2 * M_PI / 1800.0); + y = sin(*Angle2 * M_PI / 1800.0); + t = x * TransMat[0][0] + y * TransMat[0][1]; + y = x * TransMat[1][0] + y * TransMat[1][1]; + x = t; + *Angle2 = (int) (atan2(y, x) * 1800.0 / M_PI + 0.5); + + NORMALIZE_ANGLE(*Angle1); + NORMALIZE_ANGLE(*Angle2); + if (*Angle2 < *Angle1) *Angle2 += 3600; + + if (*Angle2 - *Angle1 > 1800) + { /* Need to swap the two angles. */ + Angle = (*Angle1); + *Angle1 = (*Angle2); + *Angle2 = Angle; + + NORMALIZE_ANGLE(*Angle1); + NORMALIZE_ANGLE(*Angle2); + if (*Angle2 < *Angle1) *Angle2 += 3600; + swap = TRUE; + } + + if ( Delta >= 1800 ) + { + *Angle1 +=1; + *Angle2 -=1; + } + + return swap; +} + + +/***************************************************************************** +* Routine to display an outline version of given library entry. * +* This routine is applied by the PlaceLibItem routine above. * +*****************************************************************************/ +void DrawingLibInGhost(WinEDA_DrawPanel * panel, wxDC * DC, + EDA_LibComponentStruct *LibEntry, + EDA_SchComponentStruct *DrawLibItem, int PartX, int PartY, + int multi, int convert, int Color, bool DrawPinText) +{ +int DrawMode = g_XorMode; + + DrawLibPartAux(panel, DC, DrawLibItem, LibEntry, wxPoint(PartX, PartY), + DrawLibItem->m_Transform, + multi, convert, DrawMode, Color, DrawPinText); + +} + +/************************************************************/ +/* Routine to draw One LibraryDrawStruct at given position, */ +/* matrice de transformation 1 0 0 -1 (normale) */ +/* DrawMode = GrXOR, GrOR .. */ +/************************************************************/ +/* Utilise en LibEdit et Lib Browse */ +void DrawLibraryDrawStruct(WinEDA_DrawPanel * panel, wxDC * DC, + EDA_LibComponentStruct *LibEntry, + int PartX, int PartY, + LibEDA_BaseStruct *DrawItem, int Multi, + int DrawMode, int Color) +{ +int i, x1, y1, x2, y2, t1, t2, orient; +int CharColor; +int TransMat[2][2]; +int fill_option; + +#undef GETCOLOR +#define GETCOLOR(l) Color < 0 ? ReturnLayerColor(l) : Color; + + Multi = 0; /* unused */ + /* Trace de la structure */ + CharColor = GETCOLOR(LAYER_DEVICE); + GRSetDrawMode(DC, DrawMode); + + TransMat[0][0] = 1; + TransMat[0][1] = TransMat[1][0] = 0; + TransMat[1][1] = -1; + + switch (DrawItem->m_StructType) + { + case COMPONENT_ARC_DRAW_TYPE: + { + int xc,yc, x2,y2; + LibDrawArc * Arc = (LibDrawArc *) DrawItem; + t1 = Arc->t1; t2 = Arc->t2; + bool swap = MapAngles(&t1, &t2, TransMat); + xc = PartX + Arc->m_Pos.x; + yc = PartY - Arc->m_Pos.y; + x2 = PartX + Arc->m_Start.x; + y2 = PartY - Arc->m_Start.y; + x1 = PartX + Arc->m_End.x; + y1 = PartY - Arc->m_End.y; + + if ( swap ) { EXCHG(x1,x2); EXCHG(y1, y2)} + fill_option = Arc->m_Fill & (~g_PrintFillMask); + if ( (Arc->m_Fill == FILLED_WITH_BG_BODYCOLOR) && ! g_IsPrinting ) + GRFilledArc(&panel->m_ClipBox, DC, xc, yc, t1, t2, + Arc->m_Rayon, CharColor, + ReturnLayerColor(LAYER_DEVICE_BACKGROUND)); + else if ( Arc->m_Fill == FILLED_SHAPE) + GRFilledArc(&panel->m_ClipBox, DC, xc, yc, t1, t2, + Arc->m_Rayon, CharColor, CharColor); +#ifdef DRAW_ARC_WITH_ANGLE + else GRArc(&panel->m_ClipBox, DC, xc, yc, t1, t2, + Arc->m_Rayon, CharColor); +#else + else GRArc1(&panel->m_ClipBox, DC, x1, y1, x2, y2, + xc, yc, CharColor); +#endif + } + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + { + LibDrawCircle * Circle = (LibDrawCircle *) DrawItem; + x1 = PartX + Circle->m_Pos.x; + y1 = PartY - Circle->m_Pos.y; + fill_option = Circle->m_Fill & (~g_PrintFillMask); + if ( (fill_option == FILLED_WITH_BG_BODYCOLOR) && ! g_IsPrinting ) + GRFilledCircle(&panel->m_ClipBox, DC, x1, y1, + Circle->m_Rayon, CharColor, + ReturnLayerColor(LAYER_DEVICE_BACKGROUND)); + else if ( fill_option == FILLED_SHAPE) + GRFilledCircle(&panel->m_ClipBox, DC, x1, y1, + Circle->m_Rayon, CharColor, CharColor); + else GRCircle(&panel->m_ClipBox, DC, x1, y1, + Circle->m_Rayon, CharColor); + } + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + { + LibDrawText * Text = (LibDrawText *) DrawItem; + x1 = PartX + Text->m_Pos.x; + y1 = PartY - Text->m_Pos.y; + PutTextInfo(panel, DC, Text->m_Horiz, wxPoint(x1, y1), + Text->m_Size, Text->m_Text, + DrawMode,CharColor); + } + break; + + case COMPONENT_RECT_DRAW_TYPE: + { + LibDrawSquare * Square = (LibDrawSquare *) DrawItem; + x1 = PartX + Square->m_Start.x; + y1 = PartY - Square->m_Start.y; + x2 = PartX + Square->m_End.x; + y2 = PartY - Square->m_End.y; + fill_option = Square->m_Fill & (~g_PrintFillMask); + if ( (fill_option == FILLED_WITH_BG_BODYCOLOR) && ! g_IsPrinting ) + GRFilledRect(&panel->m_ClipBox, DC, x1, y1, x2, y2, + CharColor, + ReturnLayerColor(LAYER_DEVICE_BACKGROUND)); + else if ( fill_option == FILLED_SHAPE) + GRFilledRect(&panel->m_ClipBox, DC, x1, y1, x2, y2, + CharColor, CharColor); + else GRRect(&panel->m_ClipBox, DC, x1, y1, x2, y2, + CharColor); + } + break; + + case COMPONENT_PIN_DRAW_TYPE: /* Trace des Pins */ + { + LibDrawPin * Pin = (LibDrawPin *) DrawItem; + x2 = PartX + Pin->m_Pos.x; + y2 = PartY - Pin->m_Pos.y; + /* Compute the real pin orientation, i.e. pin orient + component orient */ + orient = Pin->ReturnPinDrawOrient(TransMat); + + /* Dessin de la pin et du symbole special associe */ + if( Pin->m_Attributs & PINNOTDRAW) CharColor = DARKGRAY; + else CharColor = -1; + + DrawPinSymbol(panel, DC, x2, y2, Pin->m_PinLen, orient, + Pin->m_PinShape, DrawMode); + wxPoint pinpos(x2,y2); + Pin->DrawPinTexts(panel, DC, pinpos, orient, + LibEntry->m_TextInside, + LibEntry->m_DrawPinNum,LibEntry->m_DrawPinName, + CharColor, DrawMode); + } + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + { + LibDrawPolyline * polyline = (LibDrawPolyline *) DrawItem; + if ( Buf_Poly_Drawings == NULL ) + { + Buf_Poly_Size = polyline->n; + Buf_Poly_Drawings = (int *) MyMalloc(sizeof(int) * 2 * Buf_Poly_Size); + } + else if ( Buf_Poly_Size < polyline->n ) + { + Buf_Poly_Size = polyline->n; + Buf_Poly_Drawings = (int *) realloc(Buf_Poly_Drawings, + sizeof(int) * 2 * Buf_Poly_Size); + } + for (i = 0; i < polyline->n; i++) + { + Buf_Poly_Drawings[i * 2] = PartX + polyline->PolyList[i * 2]; + Buf_Poly_Drawings[i * 2 + 1] = PartY - polyline->PolyList[i * 2 + 1]; + } + fill_option = polyline->m_Fill & (~g_PrintFillMask); + if ( (fill_option == FILLED_WITH_BG_BODYCOLOR) && ! g_IsPrinting ) + GRPoly(&panel->m_ClipBox, DC, polyline->n, + Buf_Poly_Drawings, 1, CharColor, + ReturnLayerColor(LAYER_DEVICE_BACKGROUND)); + else if ( fill_option == FILLED_SHAPE) + GRPoly(&panel->m_ClipBox, DC, polyline->n, + Buf_Poly_Drawings, 1, CharColor, CharColor); + else GRPoly(&panel->m_ClipBox, DC, polyline->n, + Buf_Poly_Drawings, 0, CharColor, CharColor); + break; + } + } +} + diff --git a/eeschema/eeload.cpp b/eeschema/eeload.cpp new file mode 100644 index 0000000000..9fa741153f --- /dev/null +++ b/eeschema/eeload.cpp @@ -0,0 +1,197 @@ + /****************************************/ + /* Module to load/save EESchema files. */ + /****************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +#include "id.h" + + +static void LoadSubHierarchy(WinEDA_SchematicFrame * frame, EDA_BaseStruct *DrawList); + +/* Variables locales */ + +/************************************************************************************/ +int WinEDA_SchematicFrame::LoadOneEEProject(const wxString & FileName, bool IsNew) +/************************************************************************************/ +/* + Routine de chargement d'un projet ( schema principal "Root" et ses + sous schemas ( hierarchie ) +*/ +{ +SCH_SCREEN *screen; +wxString FullFileName, msg; +bool LibCacheExist = FALSE; + + EDA_ScreenList ScreenList(NULL); + for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + if(screen->IsModify()) + break; + } + + if ( screen ) + { + if( ! IsOK(this, _("Clear Schematic Hierarchy (modified!)?")) ) return FALSE; + if ( ScreenSch->m_FileName != g_DefaultSchematicFileName ) + SetLastProject(ScreenSch->m_FileName); + } + + + screen = ScreenSch ; + + FullFileName = FileName; + if( (FullFileName.IsEmpty() ) && !IsNew ) + { + wxString mask = wxT("*") + g_SchExtBuffer; + FullFileName = EDA_FileSelector( _("Schematic files:"), + wxEmptyString, /* Chemin par defaut */ + wxEmptyString, /* nom fichier par defaut */ + g_SchExtBuffer, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_OPEN, + TRUE + ); + if ( FullFileName.IsEmpty() ) return ( FALSE ); + } + + if( ClearProjectDrawList(screen, TRUE) == FALSE ) return(1); + + ActiveScreen = m_CurrentScreen = screen = ScreenSch; + ScreenSch->ClearUndoRedoList(); + screen->m_CurrentItem = NULL; + wxSetWorkingDirectory(wxPathOnly(FullFileName) ); + m_CurrentScreen->m_FileName = FullFileName; + Affiche_Message(wxEmptyString); + MsgPanel->EraseMsgBox(); + + memset( &g_EESchemaVar,0, sizeof(g_EESchemaVar) ); + + m_CurrentScreen->ClrModify(); + m_CurrentScreen->Pnext = NULL; + + if( IsNew ) + { + screen->m_CurrentSheet = &g_Sheet_A4; + screen->SetZoom(32); + screen->m_SheetNumber = screen->m_NumberOfSheet = 1; + screen->m_Title = wxT("noname.sch"); + m_CurrentScreen->m_FileName = screen->m_Title; + screen->m_Company.Empty(); + screen->m_Commentaire1.Empty(); + screen->m_Commentaire2.Empty(); + screen->m_Commentaire3.Empty(); + screen->m_Commentaire4.Empty(); + Read_Config(wxEmptyString, TRUE); + Zoom_Automatique(TRUE); + ReDrawPanel(); + return (1); + } + // Rechargement de la configuration: + msg = _("Ready\nWorking dir: \n") + wxGetCwd(); + PrintMsg(msg); + + Read_Config(wxEmptyString, FALSE); + + // Delete old caches. +LibraryStruct *nextlib, *lib = g_LibraryList; + for (; lib != NULL; lib = nextlib ) + { + nextlib = lib->m_Pnext; + if ( lib->m_IsLibCache ) + FreeCmpLibrary(this, lib->m_Name); + } + + if( IsNew ) + { + ReDrawPanel(); + return (1); + } + + // Loading the project library cache + wxString FullLibName; + wxString shortfilename; + wxSplitPath(ScreenSch->m_FileName, NULL, &shortfilename, NULL); + FullLibName << wxT(".") << STRING_DIR_SEP << shortfilename << wxT(".cache") << g_LibExtBuffer; + if ( wxFileExists(FullLibName) ) + { + wxString libname; + libname = FullLibName; + ChangeFileNameExt(libname,wxEmptyString); + msg = wxT("Load ") + FullLibName; + LibraryStruct *LibCache = LoadLibraryName(this, FullLibName, libname); + if ( LibCache ) + { + LibCache->m_IsLibCache = TRUE; + msg += wxT(" OK"); + } + else msg += wxT(" ->Error"); + PrintMsg( msg ); + LibCacheExist = TRUE; + } + + if ( ! wxFileExists(ScreenSch->m_FileName) && !LibCacheExist) // Nouveau projet prpbablement + { + msg.Printf( _("File %s not found (new project ?)"), + ScreenSch->m_FileName.GetData() ); + DisplayInfo(this, msg, 20); + return (-1); + } + + if( LoadOneEEFile(ScreenSch, ScreenSch->m_FileName) == FALSE) return (0); + + /* load all subhierarchies fond in current list and new loaded list */ + LoadSubHierarchy(this, ScreenSch->EEDrawList); + + /* Reaffichage ecran de base (ROOT) si necessaire */ + ActiveScreen = ScreenSch; + Zoom_Automatique(FALSE); + + return (1); +} + + +/*******************************************************************************/ +void LoadSubHierarchy(WinEDA_SchematicFrame * frame, EDA_BaseStruct *DrawList) +/*******************************************************************************/ +/* load subhierarcy when sheets are found in DrawList + recursive function. +*/ +{ +EDA_BaseStruct * EEDrawList = DrawList; + + while(EEDrawList) + { + if( EEDrawList->m_StructType == DRAW_SHEET_STRUCT_TYPE) + { + #undef STRUCT + #define STRUCT ((DrawSheetStruct*)EEDrawList) + int timestamp = STRUCT->m_TimeStamp; + if(timestamp == 0 ) + { + timestamp = GetTimeStamp(); + STRUCT->m_TimeStamp = timestamp; + } + if( ! STRUCT->m_FileName.IsEmpty() ) + { + if( frame->LoadOneEEFile(STRUCT, STRUCT->m_FileName) == TRUE ) + { + LoadSubHierarchy(frame, STRUCT->EEDrawList); + } + } + else DisplayError(frame, _("No FileName in SubSheet")); + } + EEDrawList = EEDrawList->Pnext; + } +} + + diff --git a/eeschema/eeredraw.cpp b/eeschema/eeredraw.cpp new file mode 100644 index 0000000000..49393294b2 --- /dev/null +++ b/eeschema/eeredraw.cpp @@ -0,0 +1,657 @@ +/***************************************************************************** +* Program to draw EE diagrams. * +* This module redraw/draw all structs. * +*****************************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + + +char marq_bitmap[]= + { + 12, 12, 0, 0, /* Dimensions x et y, offsets x et y du bitmap de marqueurs*/ + YELLOW, /* Couleur */ + 1,1,1,1,1,1,1,1,0,0,0,0, /* bitmap: >= 1 : color, 0 = notrace */ + 1,1,1,0,1,0,1,1,0,0,0,0, + 1,1,1,1,0,0,0,1,0,0,0,0, + 1,0,1,1,1,0,0,0,0,0,0,0, + 1,1,0,1,1,1,0,0,0,0,0,0, + 1,1,0,0,1,1,1,0,0,0,0,0, + 1,1,1,0,0,1,1,1,0,0,0,0, + 0,0,0,0,0,0,1,1,1,0,0,0, + 0,0,0,0,0,0,0,1,1,1,0,0, + 0,0,0,0,0,0,0,0,1,1,1,0, + 0,0,0,0,0,0,0,0,0,1,1,1, + 0,0,0,0,0,0,0,0,0,0,1,0 + }; + +char marqERC_bitmap[]= + { + 8, 8, 0, 0, /* Dimensions x et y , offsets x et y du bitmap de marqueurs*/ + -1, /* Color: -1 = couleur non précisée */ + 1,1,1,1,1,0,0,0, + 1,1,1,0,1,0,0,0, + 1,1,1,1,0,0,0,0, + 1,0,1,1,1,0,0,0, + 1,1,0,1,1,1,0,0, + 0,0,0,0,1,1,1,0, + 0,0,0,0,0,1,1,1, + 0,0,0,0,0,0,1,0, + }; + + +static EDA_BaseStruct *HighLightStruct = NULL; + +/************************************************************/ +void DrawDanglingSymbol(WinEDA_DrawPanel * panel,wxDC * DC, + const wxPoint & pos, int Color) +/************************************************************/ +{ +#define DANGLING_SYMBOL_SIZE 12 + if ( ! g_IsPrinting ) // Draw but do not print the Dangling Symbol */ + { + GRRect(&panel->m_ClipBox, DC, + pos.x - DANGLING_SYMBOL_SIZE, pos.y - DANGLING_SYMBOL_SIZE, + pos.x + DANGLING_SYMBOL_SIZE, pos.y + DANGLING_SYMBOL_SIZE, + Color); + } +} + + +/*************************************************/ +void SetHighLightStruct(EDA_BaseStruct *HighLight) +/*************************************************/ +{ + HighLightStruct = HighLight; +} + +/**********************************************************************/ +void WinEDA_SchematicFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg) +/**********************************************************************/ +/* + Redraws only the active window which is assumed to be whole visible. +*/ +{ +wxString title; + if( GetScreen() == NULL ) return; + + ActiveScreen = GetScreen(); + /* Forcage de la reinit de la brosse et plume courante */ + GRResetPenAndBrush(DC); + DC->SetBackground(*wxBLACK_BRUSH); + DC->SetBackgroundMode(wxTRANSPARENT); + + DrawPanel->CursorOff(DC); // effacement curseur + + if(DrawPanel->ManageCurseur) + { + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + } + + if ( EraseBg ) DrawPanel->EraseScreen(DC); + + DrawPanel->DrawBackGround(DC); + + RedrawStructList(DrawPanel, DC, GetScreen()->EEDrawList, GR_DEFAULT_DRAWMODE); + + TraceWorkSheet(DC, GetScreen()); + + DrawPanel->CursorOn(DC); // reaffichage curseur + if(DrawPanel->ManageCurseur) + { + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + } + + Affiche_Status_Box(); + GetScreen()->ClrRefreshReq(); + if( GetScreen()->m_FileName == g_DefaultSchematicFileName ) + { + wxString msg = g_Main_Title + wxT(" ") + GetBuildVersion(); + title.Printf( wxT("%s [%s]"), msg.GetData(),GetScreen()->m_FileName.GetData()); + SetTitle(title); + } + else + { + title.Printf( wxT("[%s]"), GetScreen()->m_FileName.GetData()); + SetTitle(title); + } + +} + +/*******************************************************************************/ +void WinEDA_DrawPanel::PrintPage(wxDC * DC, bool Print_Sheet_Ref, int PrintMask) +/*******************************************************************************/ +{ +BASE_SCREEN * screen, * oldscreen = m_Parent->GetScreen(); + + wxBeginBusyCursor(); + + + screen = m_Parent->m_CurrentScreen = ActiveScreen; + RedrawStructList(this,DC, screen->EEDrawList, GR_COPY); + + if ( Print_Sheet_Ref ) + m_Parent->TraceWorkSheet(DC, screen); + + m_Parent->m_CurrentScreen = oldscreen; + wxEndBusyCursor(); +} + + +/***************************************************************************** +* Routine to redraw list of structs. * +* If the list is of DrawPickStruct types then the picked item are drawn. * +*****************************************************************************/ +void RedrawStructList(WinEDA_DrawPanel * panel, wxDC * DC, + EDA_BaseStruct *Structs, int DrawMode, int Color) +{ + while (Structs) + { + if (Structs->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + RedrawOneStruct(panel, DC, + ((DrawPickedStruct *) Structs)->m_PickedStruct, + DrawMode, Color); + } + else + { + if ( ! (Structs->m_Flags & IS_MOVED) ) + RedrawOneStruct(panel, DC, Structs, DrawMode, Color); + } + + Structs = Structs->Pnext; + } +} + +/***************************************************************************** +* Routine to redraw list of structs. * +*****************************************************************************/ +void RedrawOneStruct(WinEDA_DrawPanel * panel, wxDC * DC, + EDA_BaseStruct *Struct, int DrawMode, int Color) +{ + + if ( Struct == NULL ) return; + if (HighLightStruct == Struct) Color = HIGHLIGHT_COLOR; + + Struct->Draw(panel, DC, wxPoint(0,0), DrawMode, Color); +} + +/********************************************************************************************/ +void DrawSheetLabelStruct::Draw(WinEDA_DrawPanel * panel,wxDC * DC, const wxPoint & offset, + int DrawMode, int Color) +/********************************************************************************************/ +/* Routine de dessin des Labels type hierarchie */ +{ +int side, txtcolor; +int posx , tposx, posy, size2; +wxSize size; +int NbSegm, coord[12]; + + if( Color >= 0 ) txtcolor = Color; + else txtcolor = ReturnLayerColor(m_Layer); + GRSetDrawMode(DC, DrawMode); + + posx = m_Pos.x + offset.x; posy = m_Pos.y + offset.y; size = m_Size; + if( !m_Text.IsEmpty() ) + { + if( m_Edge ) + { + tposx = posx - size.x; + side = GR_TEXT_HJUSTIFY_RIGHT; + } + else + { + tposx = posx + size.x + (size.x /8) ; + side = GR_TEXT_HJUSTIFY_LEFT; + } + DrawGraphicText(panel, DC, wxPoint(tposx, posy), txtcolor, + m_Text, TEXT_ORIENT_HORIZ,size , + side, GR_TEXT_VJUSTIFY_CENTER); + } + /* dessin du symbole de connexion */ + + if(m_Edge) + { + size.x = -size.x; + size.y = -size.y; + } + + coord[0] = posx; coord[1] = posy; size2 = size.x /2; + NbSegm = 0; + switch(m_Shape) + { + case 0: /* input |> */ + coord[2] = posx ; coord[3] = posy - size2; + coord[4] = posx + size2; coord[5] = posy - size2; + coord[6] = posx + size.x; coord[7] = posy; + coord[8] = posx + size2; coord[9] = posy + size2; + coord[10] = posx ; coord[11] = posy + size2; + coord[12] = coord[0] ; coord[13] = coord[1]; + NbSegm = 7; + break; + + case 1: /* output <| */ + coord[2] = posx + size2; coord[3] = posy - size2; + coord[4] = posx + size.x; coord[5] = posy - size2; + coord[6] = posx + size.x; coord[7] = posy + size2; + coord[8] = posx + size2; coord[9] = posy + size2; + coord[10] = coord[0] ; coord[11] = coord[1]; + NbSegm = 6; + break; + + case 2: /* bidi <> */ + case 3: /* TriSt <> */ + coord[2] = posx + size2; coord[3] = posy - size2; + coord[4] = posx + size.x; coord[5] = posy; + coord[6] = posx + size2; coord[7] = posy +size2; + coord[8] = coord[0]; coord[9] = coord[1]; + NbSegm = 5; + break; + + default: /* unsp []*/ + coord[2] = posx ; coord[3] = posy - size2; + coord[4] = posx + size.x; coord[5] = posy - size2; + coord[6] = posx + size.x; coord[7] = posy + size2; + coord[8] = posx ; coord[9] = posy + size2; + coord[10] = coord[0] ; coord[11] = coord[1]; + NbSegm = 6; + break; + } +// GRPoly(&panel->m_ClipBox, DC, NbSegm, coord, 1, txtcolor, txtcolor); /* Poly rempli */ + GRPoly(&panel->m_ClipBox, DC, NbSegm, coord, 0, txtcolor, txtcolor); /* Poly Non rempli */ +} + + + +/**************************************************************************************/ +void DrawSheetStruct::Draw(WinEDA_DrawPanel * panel,wxDC * DC, const wxPoint & offset, + int DrawMode, int Color) +/**************************************************************************************/ +/* Draw the hierarchical sheet shape */ +{ +DrawSheetLabelStruct * SheetLabelStruct; +int txtcolor; +wxString Text; +int color; +wxPoint pos = m_Pos + offset; + + if( Color >= 0 ) color = Color; + else color = ReturnLayerColor(m_Layer); + GRSetDrawMode(DC, DrawMode); + + GRRect(&panel->m_ClipBox, DC, pos.x, pos.y, + pos.x + m_Size.x, pos.y + m_Size.y, color); + + /* Trace des textes : SheetName */ + if( Color > 0 ) txtcolor = Color; + else txtcolor = ReturnLayerColor(LAYER_SHEETNAME); + + Text = wxT("Sheet: ") + m_SheetName; + DrawGraphicText(panel, DC, + wxPoint(pos.x, pos.y - 8), txtcolor, + Text, TEXT_ORIENT_HORIZ, wxSize(m_SheetNameSize,m_SheetNameSize), + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM); + + /* Trace des textes : FileName */ + if( Color >= 0 ) txtcolor = Color; + else txtcolor = ReturnLayerColor(LAYER_SHEETFILENAME); + Text = wxT("File: ") + m_FileName; + DrawGraphicText(panel, DC, + wxPoint(pos.x, pos.y + m_Size.y + 4), + txtcolor, + Text, TEXT_ORIENT_HORIZ, wxSize(m_FileNameSize,m_FileNameSize), + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP); + + + /* Trace des textes : SheetLabel */ + SheetLabelStruct = m_Label; + while( SheetLabelStruct != NULL ) + { + SheetLabelStruct->Draw(panel, DC, offset,DrawMode, Color); + SheetLabelStruct = (DrawSheetLabelStruct*)(SheetLabelStruct->Pnext); + } +} + + +/*********************************************************************/ +void EDA_DrawLineStruct::Draw(WinEDA_DrawPanel * panel,wxDC * DC, const wxPoint & offset, + int DrawMode, int Color) +/*********************************************************************/ +/* Routine de dessin des segments type wire, Bus .. */ +{ +int color; +int zoom = panel->GetZoom(); + + if( Color >= 0 ) color = Color; + else color = ReturnLayerColor(m_Layer); + GRSetDrawMode(DC, DrawMode); + + if( m_Layer == LAYER_NOTES) + GRDashedLine(&panel->m_ClipBox, DC, m_Start.x + offset.x, m_Start.y + offset.y, + m_End.x + offset.x, m_End.y + offset.y, color); + + else if( (m_Layer == LAYER_BUS) && (zoom <= 16) ) + GRBusLine(&panel->m_ClipBox, DC, m_Start.x + offset.x, m_Start.y + offset.y, + m_End.x + offset.x, m_End.y + offset.y, color); + else + GRLine(&panel->m_ClipBox, DC, m_Start.x + offset.x, m_Start.y + offset.y, + m_End.x + offset.x, m_End.y + offset.y, color); + if ( m_StartIsDangling ) + DrawDanglingSymbol(panel, DC, m_Start + offset, color); + + if ( m_EndIsDangling ) + DrawDanglingSymbol(panel, DC, m_End + offset, color); +} + + +/*******************************************************************/ +void DrawMarkerStruct::Draw(WinEDA_DrawPanel * panel,wxDC * DC, const wxPoint & offset, + int DrawMode, int Color) +/*******************************************************************/ +/* Routine de dessin des marqueurs .. */ +{ +#define WAR 1 // utilisé aussi dans erc.cpp + + if( m_Type == MARQ_ERC ) + { + int color = Color; + if ( Color <= 0 ) + { + color = (m_MarkFlags == WAR ) ? + g_LayerDescr.LayerColor[LAYER_ERC_WARN] : + g_LayerDescr.LayerColor[LAYER_ERC_ERR]; + } + Draw_Marqueur(panel, DC, m_Pos+offset, marqERC_bitmap, DrawMode, color); + } + + else Draw_Marqueur(panel, DC, m_Pos+offset, marq_bitmap, DrawMode, Color); +} + +/*************************************************************************/ +void DrawNoConnectStruct::Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, + int DrawMode, int Color) +/*************************************************************************/ +/* Routine de dessin des symboles de "No Connexion" .. */ +{ +#define DELTA (DRAWNOCONNECT_SIZE/2) +int pX, pY, color; + + pX = m_Pos.x + offset.x; pY = m_Pos.y + offset.y; + + if( Color >= 0 ) color = Color; + else color = ReturnLayerColor(LAYER_NOCONNECT); + GRSetDrawMode(DC, DrawMode); + + GRLine(&panel->m_ClipBox, DC, pX - DELTA, pY - DELTA, pX + DELTA, pY + DELTA, color); + GRLine(&panel->m_ClipBox, DC, pX + DELTA, pY - DELTA, pX - DELTA, pY + DELTA, color); + +} + +/**************************************************************/ +void DrawBusEntryStruct::Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, + int DrawMode, int Color) +/***************************************************************/ + +/* Routine de dessin des Raccords a 45 degre type wire, Bus .. */ + +{ +int color; +int zoom = panel->GetZoom(); + + if( Color >= 0 ) color = Color; + else color = ReturnLayerColor(m_Layer); + GRSetDrawMode(DC, DrawMode); + + if( (m_Layer == LAYER_BUS) && (zoom <= 16) ) + GRBusLine(&panel->m_ClipBox, DC, m_Pos.x + offset.x, m_Pos.y + offset.y, + m_End().x + offset.x, m_End().y + offset.y, color); + else + GRLine(&panel->m_ClipBox, DC, m_Pos.x + offset.x, m_Pos.y + offset.y, + m_End().x + offset.x, m_End().y + offset.y, color); + +} + +/***************************************************************************** +* Routine to redraw polyline struct. * +*****************************************************************************/ +void DrawPolylineStruct::Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, + int DrawMode, int Color) +{ +int i, color ; +int zoom = panel->GetZoom(); + + if( Color >= 0 ) color = Color; + else color = ReturnLayerColor(m_Layer); + GRSetDrawMode(DC, DrawMode); + + GRMoveTo(m_Points[0], m_Points[1]); + if( m_Layer == LAYER_NOTES) + { + for (i = 1; i < m_NumOfPoints; i++) + GRDashedLineTo(&panel->m_ClipBox, DC, m_Points[i * 2] + offset.x, + m_Points[i * 2 + 1] + offset.y, color); + } + else if( (m_Layer == LAYER_BUS) && (zoom <= 16) ) + { + for (i = 1; i < m_NumOfPoints; i++) + GRBusLineTo(&panel->m_ClipBox, DC, m_Points[i * 2] + offset.x, + m_Points[i * 2 + 1] + offset.y, color); + } + else + { + for (i = 1; i < m_NumOfPoints; i++) + GRLineTo(&panel->m_ClipBox, DC, m_Points[i * 2] + offset.x, m_Points[i * 2 + 1] + offset.y, color); + } +} + +/***************************************************************************** +* Routine to redraw connection struct. * +*****************************************************************************/ +void DrawJunctionStruct::Draw(WinEDA_DrawPanel * panel,wxDC * DC, const wxPoint & offset, + int DrawMode, int Color) +{ +int color; +int Width = DRAWJUNCTION_SIZE; + + if( Color >= 0 ) color = Color; + else color = ReturnLayerColor(m_Layer); + GRSetDrawMode(DC, DrawMode); + + GRFilledRect(&panel->m_ClipBox, DC, m_Pos.x - Width + offset.x, m_Pos.y - Width + offset.y, + m_Pos.x + Width + offset.x, m_Pos.y + Width + offset.y, color, color); +} + +/**********************************************************/ +void DrawStructsInGhost(WinEDA_DrawPanel * panel,wxDC * DC, + EDA_BaseStruct * DrawStruct, int dx, int dy ) +/**********************************************************/ +/* Routine de redessin en mode fantome (Dessin simplifie en g_XorMode et + g_GhostColor +de structures. + Utilisee dans les deplacements de blocs +*/ +{ +int Width, ii; +int DrawMode = g_XorMode; + + GRSetDrawMode(DC, DrawMode); + + switch (DrawStruct->m_StructType) + { + case DRAW_POLYLINE_STRUCT_TYPE: + { + DrawPolylineStruct * Struct; + Struct = (DrawPolylineStruct * ) DrawStruct; + GRMoveTo(Struct->m_Points[0] + dx, Struct->m_Points[1] + dy); + for (ii = 1; ii < Struct->m_NumOfPoints; ii++) + GRLineTo(&panel->m_ClipBox, DC, Struct->m_Points[ii * 2] + dx, + Struct->m_Points[ii * 2 + 1] +dy, g_GhostColor); + break; + } + + case DRAW_SEGMENT_STRUCT_TYPE: + { + EDA_DrawLineStruct * Struct; + Struct = (EDA_DrawLineStruct * ) DrawStruct; + if( (Struct->m_Flags & STARTPOINT) == 0 ) + { + GRMoveTo(Struct->m_Start.x + dx, Struct->m_Start.y + dy); + } + else + { + GRMoveTo(Struct->m_Start.x, Struct->m_Start.y); + } + if( (Struct->m_Flags & ENDPOINT) == 0 ) + { + GRLineTo(&panel->m_ClipBox, DC, Struct->m_End.x + dx, Struct->m_End.y + dy, g_GhostColor); + } + else + { + GRLineTo(&panel->m_ClipBox, DC, Struct->m_End.x, Struct->m_End.y, g_GhostColor); + } + break; + } + + case DRAW_BUSENTRY_STRUCT_TYPE: + { + DrawBusEntryStruct * Struct = (DrawBusEntryStruct *) DrawStruct; + int xx = Struct->m_Pos.x + dx, yy = Struct->m_Pos.y + dy; + GRMoveTo(xx, yy); + GRLineTo(&panel->m_ClipBox, DC, Struct->m_Size.x + xx, Struct->m_Size.y + yy, g_GhostColor); + break; + } + + case DRAW_JUNCTION_STRUCT_TYPE: + { + DrawJunctionStruct * Struct; + Struct = (DrawJunctionStruct * ) DrawStruct; + Width = DRAWJUNCTION_SIZE; + GRFilledRect(&panel->m_ClipBox, DC, Struct->m_Pos.x - Width + dx, Struct->m_Pos.y - Width + dy, + Struct->m_Pos.x + Width + dx, Struct->m_Pos.y + Width + dy, + g_GhostColor, g_GhostColor); + break; + } + + case DRAW_TEXT_STRUCT_TYPE: + { + DrawTextStruct * Struct; + Struct = (DrawTextStruct * ) DrawStruct; + Struct->m_Pos.x += dx; Struct->m_Pos.y += dy; + Struct->Draw(panel, DC, wxPoint(0,0),DrawMode,g_GhostColor); + Struct->m_Pos.x -= dx; Struct->m_Pos.y -= dy; + break; + } + + case DRAW_LABEL_STRUCT_TYPE: + { + DrawLabelStruct * Struct; + Struct = (DrawLabelStruct * ) DrawStruct; + Struct->m_Pos.x += dx; Struct->m_Pos.y += dy; + Struct->Draw(panel, DC, wxPoint(0,0),DrawMode,g_GhostColor); + Struct->m_Pos.x -= dx; Struct->m_Pos.y -= dy; + break; + } + + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + { + DrawGlobalLabelStruct * Struct; + Struct = (DrawGlobalLabelStruct * ) DrawStruct; + Struct->m_Pos.x += dx; Struct->m_Pos.y += dy; + Struct->Draw(panel, DC, wxPoint(0,0),DrawMode,g_GhostColor); + Struct->m_Pos.x -= dx; Struct->m_Pos.y -= dy; + break; + } + + case DRAW_NOCONNECT_STRUCT_TYPE: + { + DrawNoConnectStruct * Struct; + Struct = (DrawNoConnectStruct * ) DrawStruct; + Struct->m_Pos.x += dx; Struct->m_Pos.y += dy; + Struct->Draw(panel, DC, wxPoint(0,0),DrawMode,g_GhostColor); + Struct->m_Pos.x -= dx; Struct->m_Pos.y -= dy; + break; + } + + case DRAW_LIB_ITEM_STRUCT_TYPE: + { + EDA_LibComponentStruct *LibEntry; + EDA_SchComponentStruct *Struct; + Struct = (EDA_SchComponentStruct * ) DrawStruct; + LibEntry = FindLibPart(Struct->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if( LibEntry == NULL ) break; + DrawingLibInGhost(panel, DC, LibEntry, Struct, Struct->m_Pos.x + dx, + Struct->m_Pos.y + dy, + Struct->m_Multi, Struct->m_Convert, + g_GhostColor, FALSE); + break; + } + + case DRAW_SHEET_STRUCT_TYPE: + { + DrawSheetStruct *Struct = (DrawSheetStruct * ) DrawStruct; + GRRect(&panel->m_ClipBox, DC, Struct->m_Pos.x + dx, Struct->m_Pos.y + dy, + Struct->m_Pos.x + Struct->m_Size.x + dx, + Struct->m_Pos.y + Struct->m_Size.y + dy, g_GhostColor); + break; + } + + case DRAW_SHEETLABEL_STRUCT_TYPE: + case DRAW_MARKER_STRUCT_TYPE: + break; + + default: + break; + } +} + + +/************************************************************/ +void Draw_Marqueur(WinEDA_DrawPanel * panel, wxDC * DC, + wxPoint pos, char* pt_bitmap, int DrawMode, int Color) +/************************************************************/ +/* + Place un repere sur l'ecran au point de coordonnees PCB pos_X, pos_Y + Le marqueur est defini par un tableau de 2 + (lig*col) elements: + 1er element: dim nbre ligne + 2er element: dim nbre col + suite: lig * col elements a 0 ou 1 : si 1 mise a color du pixel + + copie la description du marqueur en current_marqueur (global) +*/ +{ +int px, py, color; +char ii, ii_max, jj, jj_max; + + if ( pt_bitmap == NULL ) pt_bitmap = marq_bitmap; + + px = GRMapX(pos.x); py = GRMapY(pos.y); + + /* Lecture des dimensions */ + ii_max = *(pt_bitmap++); jj_max = *(pt_bitmap++); + + /* lecture des offsets */ + px += *(pt_bitmap++); py += *(pt_bitmap++); + + color = *(pt_bitmap++); + if ( (Color > 0) ) color = Color; + if (color < 0) color = 0; + GRSetDrawMode(DC, DrawMode); + + /* Trace du bitmap */ + for( ii = 0; ii < ii_max; ii++) + { + for( jj = 0; jj < jj_max; jj++, pt_bitmap++) + { + if(*pt_bitmap) GRSPutPixel(&panel->m_ClipBox, DC, px+ii , py+jj , color); + } + } +} + + diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp new file mode 100644 index 0000000000..9a6697fd4f --- /dev/null +++ b/eeschema/eeschema.cpp @@ -0,0 +1,118 @@ + /***********************************/ + /* eeschema.cpp - module principal */ + /***********************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#define eda_global +#define MAIN + +#include "fctsys.h" + +#include + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "netlist.h" +#include "worksheet.h" +#include "trigo.h" + +#include "protos.h" + +#include "bitmaps.h" + +/* Routines locales */ +static void CreateScreens(void); + +// Global variables +wxString g_Main_Title( wxT("EESchema") ); + + /************************************/ + /* Called to initialize the program */ + /************************************/ + +// Create a new application object: this macro will allow wxWindows to create +// the application object during program execution (it's better than using a +// static object for many reasons) and also declares the accessor function +// wxGetApp() which will return the reference of the right type (i.e. MyApp and +// not wxApp) +IMPLEMENT_APP(WinEDA_App) + +bool WinEDA_App::OnInit(void) +{ +wxString FFileName; + EDA_Appl = this; + + g_DebugLevel = 0; // Debug level */ + + InitEDA_Appl( wxT("eeschema") ); + + if ( m_Checker && m_Checker->IsAnotherRunning() ) + { + if ( ! IsOK(NULL, _("Eeschema is already running, Continue?") ) ) + return false; + } + + if(argc > 1 ) FFileName = argv[1]; + + CreateScreens(); + + /* init EESCHEMA */ + GetSettings(); // read current setup + SeedLayers(); + + // Create main frame (schematic frame) : + SchematicFrame = new WinEDA_SchematicFrame(NULL, this, + wxT("EESchema"), wxPoint(0,0), wxSize(600,400) ); + + SetTopWindow(SchematicFrame); + SchematicFrame->Show(TRUE); + + SchematicFrame->Zoom_Automatique(TRUE); + + /* Load file specified in the command line. */ + if( ! FFileName.IsEmpty() ) + { + ChangeFileNameExt(FFileName, g_SchExtBuffer); + wxSetWorkingDirectory( wxPathOnly(FFileName) ); + if ( SchematicFrame->DrawPanel ) + if ( SchematicFrame->LoadOneEEProject(FFileName, FALSE) <= 0 ) + SchematicFrame->DrawPanel->Refresh(TRUE); // File not found or error + } + + else + { + Read_Config(wxEmptyString, TRUE); // Read config file ici si pas de fichier a charger + if ( SchematicFrame->DrawPanel ) + SchematicFrame->DrawPanel->Refresh(TRUE); + } + + return TRUE; +} + + +/******************************/ +static void CreateScreens(void) +/******************************/ +/* + Fonction d'init des écrans utilisés dans EESchema: +*/ +{ + /* creation des ecrans Sch , Lib */ + + if(ScreenSch == NULL ) + ScreenSch = new SCH_SCREEN(SCHEMATIC_FRAME); + ScreenSch->m_FileName = g_DefaultSchematicFileName; + ScreenSch->m_Date = GenDate(); + ActiveScreen = ScreenSch; + + if(ScreenLib == NULL ) + ScreenLib = new SCH_SCREEN(LIBEDITOR_FRAME); + ScreenLib->SetZoom(4); + ScreenLib->m_UndoRedoCountMax = 10; +} + diff --git a/eeschema/eeschema.ico b/eeschema/eeschema.ico new file mode 100644 index 0000000000000000000000000000000000000000..59eba3b2fc799e4e74ce4893cb4bda3e1d6748d3 GIT binary patch literal 2238 zcmbtVd0bRg6#kTqL5CR@MG!(10~(Z4aYIbVR1ADfX3HQ-Ax7qcxPT-^nNg%IsHGwZ z)wm%dVvdHQf;hP2zAw0f>)-~ioX#B>2Cbj}bmsTXyYGJAIrp6N&ddXv@W;&!{4K+B z8Q=iGi@{q6V2J&HS(9gXa&vP*L~wO=#leFI;ppgy+S*!>z>_DS$B#h|AA%k{0999m z?%xO9y$ia18&p*Vx^)Y5^CoPRN>uTEX=y2BG8yRUQ_!PFpgVU!1_S8&b!fF(s6#_h zws$Y6rUrEH9_Ypm(6wuL#M;={SSS?=Gu4RU)Iq|BTNePJQ|d-Z~kw>Naz*&z10c<~~R9618LUXQ%IJnoqr z5L*RIC16}7pwhsKbH-pTFkFug?b;(baXOOX;!$({JgBk~bma^<3g#O$)(3vx!)2BfvPoiM`dN{Ri zjau%LQfUhVpAi)iflB6;3LD5MAxrB;p;fY0LEy>SjH&EBt{=bKZYM8obe)mH|GB<25;j%M*sS&SPx=^ zGNgJ0@^vsnXiR5{9LF<69%60Ei*vq|PDhD%@OLRI+{5`g*|@b(j!DjLA;VkWyC)!Peq!C1yTE6E-Y-xDaTiMz+!9@28Fv zg0zT5*;2-m%#}H7b(^;qnf+BE>bUq}1wtTc7ca?NnzM-o4Sb}#Ux-EsI7ca6yEs({ z3OAd17uANpHO3s%8XYg0&X2Tr&+`0h9Se*(re`b>Md%v*d4h7gbe+38Z_WJt5uBq| z2y)i05|bk=(%C*MAn>hzZ}%VY`?BRLSim{1%rWz}b`AU=F@JI&jYWLi;6DeQIsUv~ zf1AG`JbGbWqf;}@{Ky|XJZH^Tag|~5(Lav(Ns>PM`Ipp2{MR$Sv2X7l?5Ea*#mtnx z4Gc{F?)#KR{FiNP?d)BIKr}i!kS*ye6VEOALTMues$gz(*f1kMEm4|YR~{lqPHCsK zakgtO1l(vNKQ+PR&-~bNsFLiZD)#nRjgNQQzNzgQd_A^}BULDt<}AEM-;=e9)kGfn57x%Us(w zcajT%v51zfEIPc}Knq?bb7Xv)+J|828CG`eLght`ewrWViHOU+(x sM89y!?|h?G0ZNADi%{K&=QqwX+Vbb_&AbJ%pNQR-(U*}_597K203#onCIA2c literal 0 HcmV?d00001 diff --git a/eeschema/eeschema.r b/eeschema/eeschema.r new file mode 100644 index 0000000000..79cbe6622c --- /dev/null +++ b/eeschema/eeschema.r @@ -0,0 +1,7 @@ +data 'vers' (2) { +$"0100 2000 0000 0531 2E30 6430 0531 2E30" +$"6430"} ; + +data 'vers' (1) { +$"0100 2000 0000 0531 2E30 6430 0531 2E30" +$"6430"} ; diff --git a/eeschema/eeschema.rc b/eeschema/eeschema.rc new file mode 100644 index 0000000000..9fd52a6336 --- /dev/null +++ b/eeschema/eeschema.rc @@ -0,0 +1,4 @@ +a_icon_eeschema ICON eeschema.ico +libsch ICON libedit_icon.ico +viewlibs ICON viewlibs_icon.ico +#include "wx/msw/wx.rc" diff --git a/eeschema/eestatus.cpp b/eeschema/eestatus.cpp new file mode 100644 index 0000000000..bd26a26735 --- /dev/null +++ b/eeschema/eestatus.cpp @@ -0,0 +1,332 @@ + /*****************************************************/ + /* Gestion de la configuration generale de EESCHEMA */ + /*****************************************************/ +/* Gestion de la fenetre de selection des librarires actives, de leur chemin +et du format des netlistes générées +*/ + +#include "fctsys.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" +#include "netlist.h" + +#include "id.h" + + +/* Fonctions Locales */ + +/***********/ + +enum { + SAVE_CFG = 1000, + DEL_LIB, + ADD_LIB, + INSERT_LIB, + FORMAT_NETLIST + }; + +/* Forward declarations */ + +/* Routines Locales */ + + /*************************************************/ + /* classe derivee pour la frame de Configuration */ + /*************************************************/ + +class WinEDA_ConfigFrame: public wxDialog +{ +private: +protected: +public: + + WinEDA_SchematicFrame * m_Parent; + wxListBox * m_ListLibr; + wxRadioBox *m_NetFormatBox; + bool m_LibListChanged; + WinEDA_EnterText * LibDirCtrl; + + // Constructor and destructor + WinEDA_ConfigFrame(WinEDA_SchematicFrame *parent, const wxPoint& pos); + ~WinEDA_ConfigFrame(void) {}; + + void OnCloseWindow(wxCloseEvent & event); + + void CreateListFormatsNetListes(const wxPoint & pos); + + void SaveCfg(wxCommandEvent& event); + void LibDelFct(wxCommandEvent& event); + void AddOrInsertLibrary(wxCommandEvent& event); + void ReturnNetFormat(wxCommandEvent& event); + void ChangeSetup(void); + + DECLARE_EVENT_TABLE() + +}; +/* Construction de la table des evenements pour WinEDA_ConfigFrame */ +BEGIN_EVENT_TABLE(WinEDA_ConfigFrame, wxDialog) + EVT_BUTTON(SAVE_CFG, WinEDA_ConfigFrame::SaveCfg) + EVT_BUTTON(DEL_LIB, WinEDA_ConfigFrame::LibDelFct) + EVT_BUTTON(ADD_LIB, WinEDA_ConfigFrame::AddOrInsertLibrary) + EVT_BUTTON(INSERT_LIB, WinEDA_ConfigFrame::AddOrInsertLibrary) + EVT_RADIOBOX(FORMAT_NETLIST, WinEDA_ConfigFrame::ReturnNetFormat) + EVT_CLOSE(WinEDA_ConfigFrame::OnCloseWindow) +END_EVENT_TABLE() + +/******************************************************************/ +void WinEDA_SchematicFrame::InstallConfigFrame(const wxPoint & pos) +/******************************************************************/ +{ + WinEDA_ConfigFrame * CfgFrame = new WinEDA_ConfigFrame(this, pos); + CfgFrame->ShowModal(); CfgFrame->Destroy(); +} + + +#define X_SIZE 500 +#define Y_SIZE 360 + +/********************************************************************/ +WinEDA_ConfigFrame::WinEDA_ConfigFrame(WinEDA_SchematicFrame *parent, + const wxPoint& framepos): + wxDialog(parent, -1, wxEmptyString, framepos, wxSize(X_SIZE, Y_SIZE), + DIALOG_STYLE ) +/*****************************************************************/ +/* Constructeur de WinEDA_ConfigFrame: la fenetre de config des librairies +*/ +{ +wxPoint pos; +wxSize size; +int dimy; +wxString msg; +wxButton * Button; + + m_Parent = parent; + m_LibListChanged = FALSE; + SetFont(*g_DialogFont); + + msg = _("from ") + EDA_Appl->m_CurrentOptionFile; + SetTitle(msg); + + /* Creation des boutons de commande */ + pos.x = 10; pos.y = 5; + Button = new wxButton(this, SAVE_CFG, _("Save Cfg"), pos); + Button->SetForegroundColour(*wxRED); + + pos.x = 230; + Button = new wxButton(this, DEL_LIB, _("Del"), pos); + Button->SetForegroundColour(*wxRED); + + pos.x += Button->GetSize().x; + Button = new wxButton(this, ADD_LIB, _("Add"), pos ); + Button->SetForegroundColour(wxColor(0,80,0)); + + pos.x += Button->GetSize().x; + Button = new wxButton(this, INSERT_LIB, _("Ins"), pos ); + Button->SetForegroundColour(*wxBLUE); + + pos.x = 10; pos.y = 45; + CreateListFormatsNetListes(pos); + + pos.x = 235; pos.y = 55; + m_ListLibr = new wxListBox(this, + -1, pos, wxSize(X_SIZE - pos.x -10,225), + 0,NULL, + wxLB_ALWAYS_SB|wxLB_SINGLE); + wxStaticText * Msg = new wxStaticText(this, -1, _("Libraries"), + wxPoint(pos.x, pos.y - 14) ); + Msg->SetForegroundColour(wxColour(200,0,0) ); + m_ListLibr->InsertItems(g_LibName_List, 0); + + // Affichage des extensions des différents fichiers: + dimy = 17; + pos.x = 10; + pos.y = m_NetFormatBox->GetPosition().y + m_NetFormatBox->GetSize().y + 10; + wxStaticBox * Box = new wxStaticBox(this, -1, _("Files ext:"), pos, wxSize(180,110) ); + pos.y += 20; pos.x += 10; + msg = _("Cmp file Ext: ") + g_NetCmpExtBuffer; + wxStaticText * text = new wxStaticText(this, -1, msg, pos); + + pos.y += dimy; + msg = _("Net file Ext: ") + g_NetExtBuffer; + text = new wxStaticText(this, -1, msg, pos); + + pos.y += dimy; + msg = _("Library file Ext: ") + g_LibExtBuffer; + text = new wxStaticText(this, -1, msg, pos); + + pos.y += dimy; + msg = _("Symbol file Ext: ") + g_SymbolExtBuffer; + text = new wxStaticText(this, -1, msg, pos); + + pos.y += dimy; + msg = _("Schematic file Ext: ") + g_SchExtBuffer; + text = new wxStaticText(this, -1, msg, pos); + + + int posY = Box->GetPosition().y + Box->GetSize().y + 30; + pos.x = 10; pos.y = MAX(310, posY); + size.x = X_SIZE - pos.x -10; size.y = -1; + LibDirCtrl = new WinEDA_EnterText(this, + _("Library files path:"), g_UserLibDirBuffer, + pos, size); + pos.y += LibDirCtrl->GetDimension().y + 5; + + SetClientSize(wxSize(X_SIZE, pos.y) ); +} + + +/***********************************************************/ +void WinEDA_ConfigFrame::OnCloseWindow(wxCloseEvent & event) +/***********************************************************/ +{ + ChangeSetup(); + if ( m_LibListChanged ) + { + LoadLibraries(m_Parent); + if ( m_Parent->m_Parent->ViewlibFrame ) + m_Parent->m_Parent->ViewlibFrame->ReCreateListLib(); + } + EndModal(0); +} + + +/*******************************************/ +void WinEDA_ConfigFrame::ChangeSetup(void) +/*******************************************/ +{ + g_UserLibDirBuffer = LibDirCtrl->GetData(); + SetRealLibraryPath( wxT("library") ); +} + + +/******************************************************/ +void WinEDA_ConfigFrame::SaveCfg(wxCommandEvent& event) +/******************************************************/ +{ + ChangeSetup(); + m_Parent->Save_Config(this); +} + +/********************************************************/ +void WinEDA_ConfigFrame::LibDelFct(wxCommandEvent& event) +/********************************************************/ +{ +int ii; + + ii = m_ListLibr->GetSelection(); + if ( ii < 0 ) return; + + g_LibName_List.RemoveAt(ii); + m_ListLibr->Clear(); + m_ListLibr->InsertItems(g_LibName_List, 0); + m_LibListChanged = TRUE; +} + +/****************************************************************/ +void WinEDA_ConfigFrame::AddOrInsertLibrary(wxCommandEvent& event) +/****************************************************************/ +/* Insert or add a library to the existing library list: + New library is put in list before (insert) or after (add) + the selection +*/ +{ +int ii; +wxString FullLibName,ShortLibName, Mask; + + ii = m_ListLibr->GetSelection(); + if ( ii < 0 ) ii = 0; + ChangeSetup(); + if( event.GetId() == ADD_LIB) + { + if( g_LibName_List.GetCount() != 0 ) ii ++; /* Add after selection */ + } + + 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); + + //Add or insert new library name + if (FindLibrary(ShortLibName) == NULL) + { + m_LibListChanged = TRUE; + g_LibName_List.Insert(ShortLibName, ii); + m_ListLibr->Clear(); + m_ListLibr->InsertItems(g_LibName_List, 0); + } + + else DisplayError(this, _("Library already in use")); + +} + + + +/**************************************************************/ +void WinEDA_ConfigFrame::ReturnNetFormat(wxCommandEvent& event) +/**************************************************************/ +{ +int ii; + + ii = m_NetFormatBox->GetSelection(); + if ( ii == 0 ) g_NetFormat = NET_TYPE_PCBNEW; + if ( ii == 1 ) g_NetFormat = NET_TYPE_ORCADPCB2; + else if ( ii == 2 ) g_NetFormat = NET_TYPE_CADSTAR; + else if ( ii == 3 ) g_NetFormat = NET_TYPE_SPICE; + else if ( g_NetFormat < NET_TYPE_CUSTOM1 ) g_NetFormat = NET_TYPE_CUSTOM1; +} + + +/***********************************************************************/ +void WinEDA_ConfigFrame::CreateListFormatsNetListes(const wxPoint & pos) +/***********************************************************************/ +/* Message de wxRadioBox de selection type netliste */ + +{ +wxString Net_Select[] = + { wxT("&PcbNew"), wxT("&OrcadPcb2"), wxT("&CadStar"), wxT("&Spice"), wxT("Other")}; + + m_NetFormatBox = new wxRadioBox(this, FORMAT_NETLIST, + _("NetList Formats:"), + pos, wxSize(-1,-1), + 5, Net_Select, 1, wxRA_SPECIFY_COLS); + + switch( g_NetFormat ) + { + case NET_TYPE_NOT_INIT: + case NET_TYPE_PCBNEW: + m_NetFormatBox->SetSelection(0); + break; + + case NET_TYPE_ORCADPCB2: + m_NetFormatBox->SetSelection(1); + break; + + case NET_TYPE_CADSTAR: + m_NetFormatBox->SetSelection(2); + break; + + case NET_TYPE_SPICE: + m_NetFormatBox->SetSelection(3); + break; + + default: + m_NetFormatBox->SetSelection(4); + break; + } +} + + diff --git a/eeschema/eestring.cpp b/eeschema/eestring.cpp new file mode 100644 index 0000000000..ada7730a93 --- /dev/null +++ b/eeschema/eestring.cpp @@ -0,0 +1,506 @@ + /**************************************/ + /* Module to handle screen printing. */ + /**************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "plot_common.h" + +#include "protos.h" + +extern void Move_Plume( wxPoint pos, int plume ); // see plot.cpp + + +/*****************************************************************************/ +void PutTextInfo(WinEDA_DrawPanel * panel, wxDC * DC, + int Orient, const wxPoint& Pos, const wxSize& Size, + const wxString & Str, int DrawMode, int color) +/*****************************************************************************/ +/* Put out a string, always centered to the given position, with given + orientation, taking into account current zoom factor. +*/ +{ + + GRSetDrawMode(DC, DrawMode); + DrawGraphicText(panel, DC, Pos, color, Str, Orient, Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + +} + +/***************************************************************************** +Put out pin number and pin text info, given the pin line coordinates. +The line must be vertical or horizontal. +If PinText == NULL nothing is printed. If PinNum = 0 no number is printed. +Current Zoom factor is taken into account. +If TextInside then the text is been put inside,otherwise all is drawn outside. +Pin Name: substring beteween '~' is negated +*****************************************************************************/ +void LibDrawPin::DrawPinTexts(WinEDA_DrawPanel * panel, wxDC * DC, + wxPoint & pin_pos, int orient, + int TextInside, bool DrawPinNum, bool DrawPinName, + int Color, int DrawMode) +/* DrawMode = GR_OR, XOR ... */ +{ +int ii, x, y, x1, y1, dx, dy, len; +wxString StringPinNum; +wxString PinText; +int PinTextBarPos[256]; +int PinTextBarCount; +int NameColor, NumColor; +int PinTxtLen; +wxSize PinNameSize(m_SizeName,m_SizeName); +wxSize PinNumSize(m_SizeNum,m_SizeNum); + + GRSetDrawMode(DC, DrawMode); + + /* Get the num and name colors */ + NameColor = Color == - 1 ? ReturnLayerColor(LAYER_PINNAM) : Color; + NumColor = Color == - 1 ? ReturnLayerColor(LAYER_PINNUM) : Color; + + /* Create the pin num string */ + ReturnPinStringNum(StringPinNum); + + x1 = pin_pos.x; y1 = pin_pos.y; + switch(orient) + { + case PIN_UP: y1 -= m_PinLen; break; + case PIN_DOWN: y1 += m_PinLen; break; + case PIN_LEFT: x1 -= m_PinLen; break; + case PIN_RIGHT: x1 += m_PinLen; break; + } + + const wxChar * textsrc = m_PinName.GetData(); + float fPinTextPitch = PinNameSize.x * 1.1; + /* Do we need to invert the string? Is this string has only "~"? */ + PinTextBarCount = 0; PinTxtLen = 0; + ii = 0; + while ( * textsrc ) + { + if ( * textsrc == '~' ) + { + PinTextBarPos[PinTextBarCount++] = (int)(PinTxtLen * fPinTextPitch); + } + else + { + PinText.Append(* textsrc); + PinTxtLen ++; + } + + textsrc++; + } + + PinTxtLen = (int) (fPinTextPitch * PinTxtLen); + PinTextBarPos[PinTextBarCount] = PinTxtLen; // Needed if no end '~' + + if (PinText[0] == 0) DrawPinName = FALSE; + + if( TextInside ) /* Draw the text inside, but the pin numbers outside. */ + { + if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) ) + // It is an horizontal line + { + if (PinText && DrawPinName) + { + if( orient == PIN_RIGHT) + { + x = x1 + TextInside; + DrawGraphicText(panel, DC, wxPoint(x, y1), NameColor, PinText, + TEXT_ORIENT_HORIZ, + PinNameSize, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + + for ( ii = 0; ii < PinTextBarCount; ) + { + GRMoveTo(x, y1 - TXTMARGE); + dy = -PinNameSize.y / 2; + GRMoveRel(0, dy); + dx = PinTextBarPos[ii++]; // Get the line pos + GRMoveRel(dx, 0); + len = PinTextBarPos[ii++] - dx; // Get the line length + GRLineRel(&panel->m_ClipBox, DC, len, 0, NameColor); + } + } + else // Orient == PIN_LEFT + { + x = x1 - TextInside; + DrawGraphicText(panel, DC, wxPoint(x, y1) , NameColor, PinText, + TEXT_ORIENT_HORIZ, + PinNameSize, + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER); + + for ( ii = 0; ii < PinTextBarCount; ) + { + GRMoveTo(x, y1 - TXTMARGE); + dy = -PinNameSize.y / 2; + GRMoveRel(0, dy); + dx = PinTextBarPos[ii++]; // Get the line pos + GRMoveRel(dx - PinTxtLen, 0); + len = PinTextBarPos[ii++] - dx; // Get the line length + GRLineRel(&panel->m_ClipBox, DC, len, 0, NameColor); + } + } + } + + if ( DrawPinNum) + { + DrawGraphicText(panel, DC, + wxPoint((x1 + pin_pos.x) / 2, y1 - TXTMARGE), NumColor, StringPinNum, + TEXT_ORIENT_HORIZ, PinNumSize, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM); + } + } + + else /* Its a vertical line. */ + { // Text is drawn from bottom to top (i.e. to negative value for Y axis) + if (PinText && DrawPinName) + { + if ( orient == PIN_DOWN ) + { + y = y1 + TextInside; + + DrawGraphicText(panel, DC, wxPoint(x1, y), NameColor, PinText, + TEXT_ORIENT_VERT, PinNameSize, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP); + + for ( ii = 0; ii < PinTextBarCount; ) + { + GRMoveTo(x1 - TXTMARGE, y); + dy = -PinNameSize.y / 2; + GRMoveRel(dy , 0); + dx = PinTextBarPos[ii++]; // Get the line pos + GRMoveRel(0, PinTxtLen - dx); + len = PinTextBarPos[ii++] - dx; // Get the line length + GRLineRel(&panel->m_ClipBox, DC, 0, -len, NameColor); + } + } + + else /* PIN_UP */ + { + y = y1 - TextInside; + + DrawGraphicText(panel, DC, wxPoint(x1, y), NameColor, PinText, + TEXT_ORIENT_VERT, PinNameSize, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM); + + for ( ii = 0; ii < PinTextBarCount; ) + { + GRMoveTo(x1 - TXTMARGE, y); + dy = -PinNameSize.y / 2; + GRMoveRel(dy, 0); + dx = PinTextBarPos[ii++]; // Get the line pos + GRMoveRel(0, - dx); + len = PinTextBarPos[ii++] - dx; // Get the line length + GRLineRel(&panel->m_ClipBox, DC, 0, -len, NameColor); + } + } + } + + if(DrawPinNum) + { + DrawGraphicText(panel, DC, + wxPoint(x1 - TXTMARGE, (y1 + pin_pos.y) / 2) , NumColor, StringPinNum, + TEXT_ORIENT_VERT, PinNumSize, + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER); + } + } + } + + else /**** Draw num & text pin outside ****/ + { + if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) ) + /* Its an horizontal line. */ + { + if (PinText && DrawPinName) + { + x = (x1 + pin_pos.x) / 2; + DrawGraphicText(panel, DC, wxPoint(x , y1 - TXTMARGE), + NameColor, PinText, + TEXT_ORIENT_HORIZ, PinNameSize, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM); + + for ( ii = 0; ii < PinTextBarCount; ) + { + GRMoveTo(x, y1 - TXTMARGE*2); + GRMoveRel(-PinTxtLen / 2, -PinNameSize.y ); + dx = PinTextBarPos[ii++]; // Get the line pos + GRMoveRel(dx, 0); + len = PinTextBarPos[ii++] - dx; // Get the line length + GRLineRel(&panel->m_ClipBox, DC, len, 0, NameColor); + } + } + if(DrawPinNum) + { + x = (x1 + pin_pos.x) / 2; + DrawGraphicText(panel, DC, wxPoint(x, y1 + TXTMARGE), + NumColor, StringPinNum, + TEXT_ORIENT_HORIZ, PinNumSize, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP); + } + } + else /* Its a vertical line. */ + { + if (PinText && DrawPinName) + { + y = (y1 + pin_pos.y) / 2; + DrawGraphicText(panel, DC, wxPoint(x1 - TXTMARGE , y ), + NameColor, PinText, + TEXT_ORIENT_VERT, PinNameSize, + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER); + + for ( ii = 0; ii < PinTextBarCount; ) + { + GRMoveTo(x1 - (TXTMARGE * 2), y); + GRMoveRel(-PinNameSize.y, -PinTxtLen / 2); + dx = PinTextBarPos[ii++]; // Get the line pos + GRMoveRel(0, PinTxtLen - dx); + len = PinTextBarPos[ii++] - dx; // Get the line length + GRLineRel(&panel->m_ClipBox, DC, 0, - len, NameColor); + } + } + + if(DrawPinNum) + { + DrawGraphicText(panel, DC, wxPoint(x1 + TXTMARGE , (y1 + pin_pos.y) / 2), + NumColor, StringPinNum, + TEXT_ORIENT_VERT, PinNumSize, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + } + } + } +} + +/***************************************************************************** +* Plot pin number and pin text info, given the pin line coordinates. * +* Same as DrawPinTexts((), but output is the plotter +* The line must be vertical or horizontal. * +* If PinNext == NULL nothing is printed. * +* Current Zoom factor is taken into account. * +* If TextInside then the text is been put inside (moving from x1, y1 in * +* the opposite direction to x2,y2), otherwise all is drawn outside. * +*****************************************************************************/ +void LibDrawPin::PlotPinTexts(wxPoint & pin_pos, int orient, + int TextInside, bool DrawPinNum, bool DrawPinName) +{ +int dx, len, start; +int ii , x, y, x1, y1, cte; +wxString StringPinNum; +wxString PinText; +int PinTextBarPos[256]; +int PinTextBarCount; +int NameColor, NumColor; +int PinTxtLen = 0; +wxSize PinNameSize = wxSize(m_SizeName,m_SizeName); +wxSize PinNumSize = wxSize(m_SizeNum,m_SizeNum); +bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt; + + /* Get the num and name colors */ + NameColor = plot_color ? ReturnLayerColor(LAYER_PINNAM) : -1; + NumColor = plot_color ? ReturnLayerColor(LAYER_PINNUM) : -1; + + /* Create the pin num string */ + ReturnPinStringNum(StringPinNum); + x1 = pin_pos.x; y1 = pin_pos.y; + switch(orient) + { + case PIN_UP: y1 -= m_PinLen; break; + case PIN_DOWN: y1 += m_PinLen; break; + case PIN_LEFT: x1 -= m_PinLen; break; + case PIN_RIGHT: x1 += m_PinLen; break; + } + + const wxChar * textsrc = m_PinName.GetData(); + float fPinTextPitch = PinNameSize.x * 1.1; + /* Do we need to invert the string? Is this string has only "~"? */ + PinTextBarCount = 0; PinTxtLen = 0; + ii = 0; + while ( * textsrc ) + { + if ( * textsrc == '~' ) + { + PinTextBarPos[PinTextBarCount++] = (int) (fPinTextPitch * PinTxtLen); + } + else + { + PinText.Append(* textsrc); + PinTxtLen ++; + } + + textsrc++; + } + + PinTxtLen = (int) (fPinTextPitch * PinTxtLen); + PinTextBarPos[PinTextBarCount] = PinTxtLen; // Needed if no end '~' + + if (PinText[0] == 0) DrawPinName = FALSE; + + if (TextInside) /* Draw the text inside, but the pin numbers outside. */ + { + if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) ) + { /* Its an horizontal line. */ + if (PinText && DrawPinName) + { + if( orient == PIN_RIGHT) + { + x = x1 + TextInside; + PlotGraphicText(g_PlotFormat, wxPoint(x, y1), NameColor, PinText, + TEXT_ORIENT_HORIZ, + PinNameSize, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + + for ( ii = 0; ii < PinTextBarCount; ) + { + cte = y1 - PinNameSize.y/2 - TXTMARGE; + dx = PinTextBarPos[ii++]; // Get the line pos + Move_Plume( wxPoint(x+dx, cte), 'U'); + len = PinTextBarPos[ii++]; // Get the line end + Move_Plume( wxPoint(x + len, cte), 'D'); + } + } + else // orient == PIN_LEFT + { + x = x1 - TextInside; + PlotGraphicText(g_PlotFormat, wxPoint(x, y1), + NameColor, PinText, TEXT_ORIENT_HORIZ, + PinNameSize, + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER); + + for ( ii = 0; ii < PinTextBarCount; ) + { + cte = y1 - PinNameSize.y/2 - TXTMARGE; + dx = PinTextBarPos[ii++]; // Get the line pos + Move_Plume( wxPoint(x+dx - PinTxtLen, cte), 'U'); + len = PinTextBarPos[ii++]; // Get the line end + Move_Plume(wxPoint(x + len - PinTxtLen, cte), 'D'); + } + } + } + + if (DrawPinNum) + { + PlotGraphicText( g_PlotFormat, wxPoint((x1 + pin_pos.x) / 2, y1 - TXTMARGE), + NumColor, StringPinNum, + TEXT_ORIENT_HORIZ, PinNumSize, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM); + } + } + + else /* Its a vertical line. */ + { + if (PinText && DrawPinName) + { + if ( orient == PIN_DOWN ) + { + y = y1 + TextInside; + + PlotGraphicText( g_PlotFormat, wxPoint(x1, y), NameColor, PinText, + TEXT_ORIENT_VERT, PinNameSize, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP); + + for ( ii = 0; ii < PinTextBarCount; ) + { + cte = x1 - PinNameSize.y/2 - TXTMARGE; + dx = PinTextBarPos[ii++]; // Get the line pos + Move_Plume( wxPoint(cte, y + PinTxtLen - dx), 'U'); + len = PinTextBarPos[ii++]; // Get the line end + Move_Plume( wxPoint(cte , y + PinTxtLen - len), 'D'); + } + } + + else /* PIN_UP */ + { + y = y1 - TextInside; + + PlotGraphicText( g_PlotFormat, wxPoint(x1, y), NameColor, PinText, + TEXT_ORIENT_VERT, PinNameSize, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM); + + for ( ii = 0; ii < PinTextBarCount; ) + { + cte = x1 - PinNameSize.y/2 - TXTMARGE; + dx = PinTextBarPos[ii++]; // Get the line pos + Move_Plume( wxPoint(cte, y -dx), 'U'); + len = PinTextBarPos[ii++]; // Get the line end + Move_Plume(wxPoint(cte, y - len), 'D'); + } + } + } + + if (DrawPinNum) + { + PlotGraphicText( g_PlotFormat, wxPoint(x1 - TXTMARGE, (y1 + pin_pos.y) / 2), + NumColor, StringPinNum, + TEXT_ORIENT_VERT, PinNumSize, + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER); + } + } + } + + else /* Draw num & text pin outside */ + { + if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) ) + /* Its an horizontal line. */ + { + if (PinText && DrawPinName) + { + x = (x1 + pin_pos.x) / 2; + PlotGraphicText( g_PlotFormat, wxPoint(x, y1 - TXTMARGE), + NameColor, PinText, + TEXT_ORIENT_HORIZ, PinNameSize, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM); + + for ( ii = 0; ii < PinTextBarCount; ) + { + cte = y1 - PinNameSize.y - TXTMARGE*2; + start = x - (PinTxtLen / 2); + dx = PinTextBarPos[ii++]; // Get the line pos + Move_Plume( wxPoint(start + dx, cte), 'U'); + len = PinTextBarPos[ii++]; // Get the line end + Move_Plume(wxPoint(start + len, cte), 'D'); + } + } + if (DrawPinNum) + { + x = (x1 + pin_pos.x) / 2; + PlotGraphicText(g_PlotFormat, wxPoint(x, y1 + TXTMARGE), + NumColor, StringPinNum, + TEXT_ORIENT_HORIZ, PinNumSize, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP); + } + } + else /* Its a vertical line. */ + { + if (PinText && DrawPinName) + { + y = (y1 + pin_pos.y) / 2; + PlotGraphicText( g_PlotFormat, wxPoint(x1 - TXTMARGE,y), + NameColor, PinText, + TEXT_ORIENT_VERT, PinNameSize, + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER); + + for ( ii = 0; ii < PinTextBarCount; ) + { + cte = x1 - PinNameSize.y - TXTMARGE*2; + start = y + (PinTxtLen / 2); + dx = PinTextBarPos[ii++]; // Get the line pos + Move_Plume( wxPoint(cte, start - dx), 'U'); + len = PinTextBarPos[ii++]; // Get the line end + Move_Plume( wxPoint(cte, start - len), 'D'); + } + } + + if (DrawPinNum) + { + PlotGraphicText( g_PlotFormat, wxPoint(x1 + TXTMARGE, (y1 + pin_pos.y) / 2), + NumColor, StringPinNum, + TEXT_ORIENT_VERT, PinNumSize, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + } + } + } +} + diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp new file mode 100644 index 0000000000..2ecde4e447 --- /dev/null +++ b/eeschema/erc.cpp @@ -0,0 +1,809 @@ + /**************************************************/ + /* Module de tst "ERC" ( Electrical Rules Check ) */ + /**************************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "netlist.h" + +#include "protos.h" + + +#include "../bitmaps/ercgreen.xpm" +#include "../bitmaps/ercwarn.xpm" +#include "../bitmaps/ercerr.xpm" + +#include "dialog_erc.h" + +/* On teste + 1 - conflits entre pins connectees ( ex: 2 sorties connectees ) + 2 - les imperatifs minimaux ( 1 entree doit etre connectee a une sortie ) +*/ + + +/* fonctions exportees */ + +/* fonctions importees */ + +/* fonctions locales */ +static bool WriteDiagnosticERC(const wxString & FullFileName); +static void Diagnose(WinEDA_DrawPanel * panel, wxDC * DC, + ObjetNetListStruct * NetItemRef, + ObjetNetListStruct * NetItemTst, int MinConnexion, int Diag); +static void TestOthersItems(WinEDA_DrawPanel * panel, + wxDC * DC, ObjetNetListStruct * NetItemRef, + ObjetNetListStruct * NetStart, + int * NetNbItems, int * MinConnexion ); +static void TestLabel(WinEDA_DrawPanel * panel, wxDC * DC, + ObjetNetListStruct * NetItemRef, + ObjetNetListStruct * StartNet); + +/* Variable locales */ +int WriteFichierERC = FALSE; + +/* Tableau des types de conflit : + PIN_INPUT, PIN_OUTPUT, PIN_BIDI, PIN_TRISTATE, PIN_PASSIVE, + PIN_UNSPECIFIED, PIN_POWER_IN, PIN_POWER_OUT, PIN_OPENCOLLECTOR, + PIN_OPENEMITTER, PIN_NC +*/ +#define OK 0 +#define WAR 1 // utilisé aussi dans eeredraw +#define ERR 2 +#define UNC 3 + +static wxChar * CommentERC_H[] = +{ + wxT("Input Pin...."), + wxT("Output Pin..."), + wxT("BiDi Pin....."), + wxT("3 State Pin.."), + wxT("Passive Pin.."), + wxT("Unspec Pin..."), + wxT("Power IN Pin."), + wxT("PowerOUT Pin."), + wxT("Open Coll...."), + wxT("Open Emit...."), + wxT("No Conn......"), + NULL +}; +static wxChar * CommentERC_V[] = +{ + wxT("Input Pin"), + wxT("Output Pin"), + wxT("BiDi Pin"), + wxT("3 State Pin"), + wxT("Passive Pin"), + wxT("Unspec Pin"), + wxT("Power IN Pin"), + wxT("PowerOUT Pin"), + wxT("Open Coll"), + wxT("Open Emit"), + wxT("No Conn"), + NULL +}; + + +/* Look up table which gives the diag for a pair of connected pins + Can be modified by ERC options. + at start up: must be loaded by DefaultDiagErc +*/ +static int DiagErc[PIN_NMAX][PIN_NMAX]; +bool DiagErcTableInit; // go to TRUE after DiagErc init + +/* Default Look up table which gives the diag for a pair of connected pins + Same as DiagErc, but cannot be modified + Used to init or reset DiagErc +*/ +static int DefaultDiagErc[PIN_NMAX][PIN_NMAX] = +{ /* I, O, Bi, 3S, Pas, UnS,PwrI,PwrO, OC, OE, NC */ +/* I */ { OK, OK, OK, OK, OK, WAR, OK, OK, OK, OK, WAR }, +/* O */ { OK, ERR, OK, WAR, OK, WAR, OK, ERR, ERR, ERR, WAR }, +/* Bi*/ { OK, OK, OK, OK, OK, WAR, OK, WAR, OK, WAR, WAR }, +/* 3S*/ { OK, WAR, OK, OK, OK, WAR, WAR, ERR, WAR, WAR, WAR }, +/*Pas*/ { OK, OK, OK, OK, OK, WAR, OK, OK, OK, OK, WAR }, +/*UnS */{ WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR }, +/*PwrI*/{ OK, OK, OK, WAR, OK, WAR, OK, OK, OK, OK, ERR }, +/*PwrO*/{ OK, ERR, WAR, ERR, OK, WAR, OK, ERR, ERR, ERR, WAR }, +/* OC */{ OK, ERR, OK, WAR, OK, WAR, OK, ERR, OK, OK, WAR }, +/* OE */{ OK, ERR, WAR, WAR, OK, WAR, OK, ERR, OK, OK, WAR }, +/* NC */{ WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR } +} ; + + +/* Minimal connection table */ +#define DRV 3 /* Net driven by a signal (a pin output for instance) */ +#define NET_NC 2 /* Net "connected" to a "NoConnect symbol" */ +#define NOD 1 /* Net not driven ( Such as 2 or more connected inputs )*/ +#define NOC 0 /* Pin isolee, non connectee */ + +/* Look up table which gives the minimal drive for a pair of connected pins on a net + Initial state of a net is NOC (No Connection) + Can be updated to NET_NC, or NOD (Not Driven) or DRV (DRIven) + + Can be updated to NET_NC only if the previous state is NOC + + Nets are OK when their final state is NET_NC or DRV + Nets with the state NOD have no source signal +*/ +static int MinimalReq[PIN_NMAX][PIN_NMAX] = + { /* In, Out, Bi, 3S, Pas, UnS,PwrI,PwrO, OC, OE, NC */ +/* In*/ { NOD, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC }, +/*Out*/ { DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, NOC }, +/* Bi*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC }, +/* 3S*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC }, +/*Pas*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC }, +/*UnS*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC }, +/*PwrI*/{ NOD, DRV, NOD, NOD, NOD, NOD, NOD, DRV, NOD, NOD, NOC }, +/*PwrO*/{ DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, NOC }, +/* OC*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC }, +/* OE*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC }, +/* NC*/ { NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC } +} ; + + + + +/*************************************************************/ +void InstallErcFrame(WinEDA_SchematicFrame *parent, wxPoint & pos) +/*************************************************************/ +/* Install function for the ERC dialog frame +*/ +{ + WinEDA_ErcFrame * frame = new WinEDA_ErcFrame(parent); + frame->ShowModal(); frame->Destroy(); +} + + +/*********************************************/ +void WinEDA_ErcFrame::ReBuildMatrixPanel(void) +/*********************************************/ +/* construit ou reconstruit le panel d'affichage de la matrice de +controle ERC +*/ +{ +int ii, jj, event_id, text_height; +wxPoint pos, BoxMatrixPosition; +#define BITMAP_SIZE 19 +int bitmap_size = BITMAP_SIZE; +wxStaticText * text; +int x, y; +wxSize BoxMatrixMinSize; + + if ( ! DiagErcTableInit ) + { + memcpy(DiagErc, DefaultDiagErc, sizeof (DefaultDiagErc)); + DiagErcTableInit = TRUE; + } + + // Get the current text size : + text = new wxStaticText( m_PanelERCOptions,-1,wxT("W"), pos); // this is a dummy text + text_height = text->GetRect().GetHeight(); + bitmap_size = MAX(bitmap_size, text_height); + delete text; + // compute the Y pos interval: + BoxMatrixMinSize.y = (bitmap_size*(PIN_NMAX+1)) + 5; + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + pos = m_MatrixSizer->GetPosition(); + // Size computation is not made in constructor, in some wxWidgets version, + // and m_BoxSizerForERC_Opt position is always 0,0. and we can't use it + pos.x = MAX( pos.x, 5); + pos.y = MAX( pos.y, m_ResetOptButton->GetRect().GetHeight() + 30); + + BoxMatrixPosition = pos; + + pos.y += text_height; + + if ( m_Initialized == FALSE ) + { + for ( ii = 0; ii < PIN_NMAX; ii++ ) + { + y = pos.y + (ii * bitmap_size); + text = new wxStaticText( m_PanelERCOptions,-1,CommentERC_H[ii], wxPoint(5,y)); + x = text->GetRect().GetRight(); + pos.x = MAX(pos.x, x); + } + pos.x += 5; + } + else pos = m_ButtonList[0][0]->GetPosition(); + + for ( ii = 0; ii < PIN_NMAX; ii++ ) + { + y = pos.y + (ii * bitmap_size); + for ( jj = 0; jj <= ii; jj++ ) + { + int diag = DiagErc[ii][jj]; + x = pos.x + (jj * bitmap_size); + if( (ii == jj) && ! m_Initialized ) + { + wxPoint txtpos; + txtpos.x = x + 4; txtpos.y = y - bitmap_size; + text = new wxStaticText( m_PanelERCOptions,-1,CommentERC_V[ii], txtpos); + BoxMatrixMinSize.x = MAX( BoxMatrixMinSize.x, text->GetRect().GetRight()); + } + event_id = ID_MATRIX_0 + ii + (jj * PIN_NMAX); + delete m_ButtonList[ii][jj]; + switch ( diag ) + { + case OK: + m_ButtonList[ii][jj] = new wxBitmapButton(m_PanelERCOptions, + event_id, + wxBitmap(green_xpm), + wxPoint(x,y) ); + break; + + case WAR: + m_ButtonList[ii][jj] = new wxBitmapButton(m_PanelERCOptions, + event_id, + wxBitmap(warning_xpm), + wxPoint(x,y) ); + break; + + case ERR: + m_ButtonList[ii][jj] = new wxBitmapButton(m_PanelERCOptions, + event_id, + wxBitmap(error_xpm), + wxPoint(x,y) ); + break; + } + } + } + + if ( !m_Initialized ) + { + BoxMatrixMinSize.x += 5; + m_MatrixSizer->SetMinSize(BoxMatrixMinSize); + BoxMatrixMinSize.y += BoxMatrixPosition.y; + m_PanelMatrixSizer->SetMinSize(BoxMatrixMinSize); + } + m_Initialized = TRUE; +} + + +/**************************************************/ +void WinEDA_ErcFrame::TestErc(wxCommandEvent& event) +/**************************************************/ +{ +ObjetNetListStruct * NetItemRef, * OldItem, * StartNet, * Lim; +int NetNbItems, MinConn; + + if ( ! DiagErcTableInit ) + { + memcpy(DiagErc, DefaultDiagErc, sizeof (DefaultDiagErc)); + DiagErcTableInit = TRUE; + } + + WriteFichierERC = m_WriteResultOpt->GetValue(); + + ReAnnotatePowerSymbolsOnly(); + if( CheckAnnotate(m_Parent, 0) ) + { + DisplayError(this, _("Annotation Required!") ); + return; + } + + /* Effacement des anciens marqueurs DRC */ + DelERCMarkers(event); + +wxClientDC dc(m_Parent->DrawPanel); + + m_Parent->DrawPanel->PrepareGraphicContext(&dc); + + g_EESchemaVar.NbErrorErc = 0; + g_EESchemaVar.NbWarningErc = 0; + + /* Cleanup the entire hierarchy */ + EDA_ScreenList ScreenList(NULL); + for ( SCH_SCREEN * Screen = ScreenList.GetFirst(); Screen != NULL; Screen = ScreenList.GetNext() ) + { + bool ModifyWires; + ModifyWires = Screen->SchematicCleanUp(NULL); + /* if wire list has changed, delete Udo Redo list to avoid + pointers on deleted data problems */ + if ( ModifyWires ) + Screen->ClearUndoRedoList(); + } + + m_Parent->BuildNetListBase(); + + /* Analyse de la table des connexions : */ + Lim = g_TabObjNet + g_NbrObjNet; + + /* Reset du flag m_FlagOfConnection, utilise par la suite */ + for (NetItemRef = g_TabObjNet; NetItemRef < Lim; NetItemRef ++ ) + NetItemRef->m_FlagOfConnection = (IsConnectType) 0; + + NetNbItems = 0; MinConn = NOC; + StartNet = OldItem = NetItemRef = g_TabObjNet; + for ( ; NetItemRef < Lim; NetItemRef ++ ) + { + /* Tst changement de net */ + if( OldItem->m_NetCode != NetItemRef->m_NetCode) + { + MinConn = NOC; NetNbItems = 0; StartNet = NetItemRef; + } + + switch ( NetItemRef->m_Type ) + { + case NET_SEGMENT: + case NET_BUS: + case NET_JONCTION: + case NET_LABEL: + case NET_BUSLABELMEMBER: + case NET_PINLABEL: + break; + + case NET_GLOBLABEL: + case NET_GLOBBUSLABELMEMBER: + case NET_SHEETLABEL: + case NET_SHEETBUSLABELMEMBER: + TestLabel(m_Parent->DrawPanel, &dc, NetItemRef, StartNet); + break; + + case NET_NOCONNECT: + MinConn = NET_NC; + if( NetNbItems != 0 ) + Diagnose(m_Parent->DrawPanel, &dc, NetItemRef, NULL, MinConn, UNC); + break; + + case NET_PIN: + TestOthersItems(m_Parent->DrawPanel, &dc, + NetItemRef, StartNet, &NetNbItems , &MinConn); + break; + } + OldItem = NetItemRef; + } + + FreeTabNetList(g_TabObjNet, g_NbrObjNet ); + + wxString num; + num.Printf(wxT("%d"), g_EESchemaVar.NbErrorErc); + m_TotalErrCount->SetLabel(num); + + num.Printf(wxT("%d"), g_EESchemaVar.NbErrorErc-g_EESchemaVar.NbWarningErc); + m_LastErrCount->SetLabel(num); + + num.Printf(wxT("%d"), g_EESchemaVar.NbWarningErc); + m_LastWarningCount->SetLabel(num); + + /* Generation ouverture fichier diag */ + if( WriteFichierERC == TRUE ) + { + wxString ErcFullFileName; + ErcFullFileName = ScreenSch->m_FileName; + ChangeFileNameExt(ErcFullFileName, wxT(".erc")); + ErcFullFileName = EDA_FileSelector(_("ERC file:"), + wxEmptyString, /* Chemin par defaut */ + ErcFullFileName, /* nom fichier par defaut */ + wxT(".erc"), /* extension par defaut */ + wxT("*.erc"), /* Masque d'affichage */ + this, + wxFD_SAVE, + TRUE + ); + if ( ErcFullFileName.IsEmpty()) return; + + if ( WriteDiagnosticERC(ErcFullFileName) ) + { + Close(TRUE); + wxString editorname = GetEditorName(); + AddDelimiterString(ErcFullFileName); + ExecuteFile(this, editorname, ErcFullFileName); + } + } +} + + +/***********************************************************/ +void WinEDA_ErcFrame::DelERCMarkers(wxCommandEvent& event) +/***********************************************************/ +/* Delete the old ERC markers, over the whole hierarchy +*/ +{ +EDA_BaseStruct * DrawStruct; +DrawMarkerStruct * Marker; +wxClientDC dc(m_Parent->DrawPanel); + + m_Parent->DrawPanel->PrepareGraphicContext(&dc); + + // Delete markers for the current screen + DrawStruct = m_Parent->GetScreen()->EEDrawList; + for ( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) + { + if(DrawStruct->m_StructType != DRAW_MARKER_STRUCT_TYPE ) continue; + /* Marqueur trouve */ + Marker = (DrawMarkerStruct * ) DrawStruct; + if( Marker->m_Type == MARQ_ERC ) + RedrawOneStruct(m_Parent->DrawPanel, &dc, Marker, g_XorMode); + } + /* Suppression en memoire des marqueurs ERC */ + DeleteAllMarkers(MARQ_ERC); +} + + +/**************************************************************/ +void WinEDA_ErcFrame::ResetDefaultERCDiag(wxCommandEvent& event) +/**************************************************************/ +/* Remet aux valeurs par defaut la matrice de diagnostic +*/ +{ + memcpy(DiagErc,DefaultDiagErc, sizeof(DiagErc) ); + ReBuildMatrixPanel(); +} + +/************************************************************/ +void WinEDA_ErcFrame::ChangeErrorLevel(wxCommandEvent& event) +/************************************************************/ +/* Change the error level for the pressed button, on the matrix table +*/ +{ +int id, level, ii, x, y; +wxBitmapButton * Butt; +char ** new_bitmap_xpm = NULL; +wxPoint pos; + + id = event.GetId(); + ii = id - ID_MATRIX_0; + Butt = (wxBitmapButton*) event.GetEventObject(); + pos = Butt->GetPosition(); + + x = ii /PIN_NMAX; y = ii % PIN_NMAX; + + level = DiagErc[y][x]; + switch (level ) + { + case OK: + level = WAR; + new_bitmap_xpm = warning_xpm; + break; + + case WAR : + level = ERR; + new_bitmap_xpm = error_xpm; + break; + + case ERR: + level = OK; + new_bitmap_xpm = green_xpm; + break; + + } + + if ( new_bitmap_xpm ) + { + delete Butt; + Butt = new wxBitmapButton(m_PanelERCOptions, id, + wxBitmap(new_bitmap_xpm), pos); + m_ButtonList[y][x] = Butt; + DiagErc[y][x] = DiagErc[x][y] = level; + } +} + + +/********************************************************/ +static void Diagnose(WinEDA_DrawPanel * panel, wxDC * DC, + ObjetNetListStruct * NetItemRef, + ObjetNetListStruct * NetItemTst, + int MinConn, int Diag) +/********************************************************/ +/* Routine de creation du marqueur ERC correspondant au conflit electrique + entre NetItemRef et NetItemTst + si MinConn < 0: Traitement des erreurs sur labels +*/ +{ +DrawMarkerStruct * Marker = NULL; +wxString DiagLevel; +SCH_SCREEN * screen; +int ii, jj; + + if( Diag == OK ) return; + + /* Creation du nouveau marqueur type Erreur ERC */ + Marker = new DrawMarkerStruct(NetItemRef->m_Start, wxEmptyString); + Marker->m_Type = MARQ_ERC; + Marker->m_MarkFlags = WAR; + screen = NetItemRef->m_Screen; + Marker->Pnext = screen->EEDrawList; + screen->EEDrawList = Marker; + g_EESchemaVar.NbErrorErc++; + g_EESchemaVar.NbWarningErc++; + + if( MinConn < 0 ) // Traitement des erreurs sur labels + { + if( (NetItemRef->m_Type == NET_GLOBLABEL) || + (NetItemRef->m_Type == NET_GLOBBUSLABELMEMBER) ) + { + Marker->m_Comment.Printf( _("Warning GLabel %s not connected to SheetLabel"), + NetItemRef->m_Label->GetData()); + } + else Marker->m_Comment.Printf( _("Warning SheetLabel %s not connected to GLabel"), + NetItemRef->m_Label->GetData()); + + if( screen == panel->GetScreen() ) RedrawOneStruct(panel, DC, Marker, GR_COPY); + return; + } + + ii = NetItemRef->m_ElectricalType; + + if( NetItemTst == NULL ) + { + if( MinConn == NOC ) /* 1 seul element dans le net */ + { + Marker->m_Comment.Printf( _("Warning Pin %s Unconnected"), MsgPinElectricType[ii]); + if( screen == panel->GetScreen() ) + RedrawOneStruct(panel, DC, Marker, GR_COPY); + return; + } + + if( MinConn == NOD ) /* pas de pilotage du net */ + { + Marker->m_Comment.Printf( + _("Warning Pin %s not driven (Net %d)"), + MsgPinElectricType[ii], NetItemRef->m_NetCode); + if( screen == panel->GetScreen() ) + RedrawOneStruct(panel, DC, Marker, GR_COPY); + return; + } + + if( Diag == UNC ) + { + Marker->m_Comment.Printf( + _("Warning More than 1 Pin connected to UnConnect symbol") ); + if( screen == panel->GetScreen() ) + RedrawOneStruct(panel, DC, Marker, GR_COPY); + return; + } + + } + + if( NetItemTst ) /* Erreur entre 2 pins */ + { + jj = NetItemTst->m_ElectricalType; + DiagLevel = _("Warning"); + if(Diag == ERR) + { + DiagLevel = _("Error"); + Marker->m_MarkFlags = ERR; + g_EESchemaVar.NbWarningErc--; + } + + + Marker->m_Comment.Printf( _("%s: Pin %s connected to Pin %s (net %d)"), DiagLevel.GetData(), + MsgPinElectricType[ii], + MsgPinElectricType[jj], NetItemRef->m_NetCode); + + if( screen == panel->GetScreen() ) + RedrawOneStruct(panel, DC, Marker, GR_COPY); + } +} + + +/********************************************************************/ +static void TestOthersItems(WinEDA_DrawPanel * panel, wxDC * DC, + ObjetNetListStruct * NetItemRef, + ObjetNetListStruct * netstart, + int * NetNbItems, int * MinConnexion) +/********************************************************************/ +/* Routine testant les conflits electriques entre + NetItemRef + et les autres items du meme net +*/ +{ +ObjetNetListStruct * NetItemTst, * Lim; +int ref_elect_type, jj, erc = OK, local_minconn; + + /* Analyse de la table des connexions : */ + Lim = g_TabObjNet + g_NbrObjNet; // pointe la fin de la liste + ref_elect_type = NetItemRef->m_ElectricalType; + + NetItemTst = netstart; + local_minconn = NOC; + + /* Examen de la liste des Pins connectees a NetItemRef */ + for ( ; ; NetItemTst ++ ) + { + if ( NetItemRef == NetItemTst ) continue; + + /* Est - on toujours dans le meme net ? */ + if( (NetItemTst >= Lim) || // fin de liste (donc fin de net) + (NetItemRef->m_NetCode != NetItemTst->m_NetCode) ) // fin de net + { /* Fin de netcode trouve: Tst connexion minimum */ + if( (*MinConnexion < NET_NC ) && + (local_minconn < NET_NC ) ) /* pin non connectée ou non pilotee */ + { + Diagnose(panel, DC, NetItemRef, NULL, local_minconn, WAR); + * MinConnexion = DRV; // inhibition autres messages de ce type pour ce net + } + return; + } + + switch ( NetItemTst->m_Type ) + { + case NET_SEGMENT: + case NET_BUS: + case NET_JONCTION: + case NET_LABEL: + case NET_GLOBLABEL: + case NET_BUSLABELMEMBER: + case NET_GLOBBUSLABELMEMBER: + case NET_SHEETBUSLABELMEMBER: + case NET_SHEETLABEL: + case NET_PINLABEL: + break; + + case NET_NOCONNECT: + local_minconn = MAX( NET_NC, local_minconn); + break; + + case NET_PIN: + jj = NetItemTst->m_ElectricalType; + local_minconn = MAX( MinimalReq[ref_elect_type][jj], local_minconn ); + + if ( NetItemTst <= NetItemRef ) break; + *NetNbItems += 1; + if( erc == OK ) // 1 marqueur par pin maxi + { + erc = DiagErc[ref_elect_type][jj]; + if (erc != OK ) + { + if( NetItemTst->m_FlagOfConnection == 0 ) + { + Diagnose(panel, DC, NetItemRef, NetItemTst, 0, erc); + NetItemTst->m_FlagOfConnection = (IsConnectType) 1; + } + } + } + break; + } + } +} + + +/********************************************************/ +static bool WriteDiagnosticERC(const wxString & FullFileName) +/*********************************************************/ +/* Genere le fichier des diagnostics +*/ +{ +SCH_SCREEN * Window; +EDA_BaseStruct * DrawStruct; +DrawMarkerStruct * Marker; +char Line[256]; +static FILE * OutErc; +DrawSheetStruct * Sheet; +wxString msg; + + if( (OutErc = wxFopen( FullFileName, wxT("wt"))) == NULL ) return FALSE; + + DateAndTime(Line); + msg = _("ERC control"); + fprintf( OutErc, "%s (%s)\n", CONV_TO_UTF8(msg), Line); + + for( Window = ScreenSch; Window != NULL; Window = (SCH_SCREEN*)Window->Pnext ) + { + Sheet = (DrawSheetStruct *) Window->m_Parent; + + msg.Printf( _("\n***** Sheet %d (%s)\n"), + Window->m_SheetNumber, + Sheet ? Sheet->m_SheetName.GetData() : _("Root")); + fprintf( OutErc, "%s", CONV_TO_UTF8(msg)); + + DrawStruct = Window->EEDrawList; + for ( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext) + { + if(DrawStruct->m_StructType != DRAW_MARKER_STRUCT_TYPE ) + continue; + /* Marqueur trouve */ + + Marker = (DrawMarkerStruct * ) DrawStruct; + if( Marker->m_Type != MARQ_ERC ) continue; + /* Write diag marqueur */ + msg.Printf( _("ERC: %s (X= %2.3f inches, Y= %2.3f inches\n"), + Marker->GetComment().GetData(), + (float)Marker->m_Pos.x / 1000, + (float)Marker->m_Pos.y / 1000); + fprintf( OutErc, "%s", CONV_TO_UTF8(msg)); + } + } + msg.Printf( _("\n >> Errors ERC: %d\n"), g_EESchemaVar.NbErrorErc); + fprintf( OutErc, "%s", CONV_TO_UTF8(msg)); + fclose ( OutErc ); + + return TRUE; +} + + +/***********************************************************************/ +void TestLabel(WinEDA_DrawPanel * panel, wxDC * DC, + ObjetNetListStruct * NetItemRef, ObjetNetListStruct * StartNet) +/***********************************************************************/ +/* Routine controlant qu'un sheetLabel est bien connecte a un Glabel de la +sous-feuille correspondante +*/ +{ +ObjetNetListStruct * NetItemTst, * Lim; +int erc = 1; + + /* Analyse de la table des connexions : */ + Lim = g_TabObjNet + g_NbrObjNet; + + NetItemTst = StartNet; + + /* Examen de la liste des Labels connectees a NetItemRef */ + for ( ; ; NetItemTst ++ ) + { + if( NetItemTst == NetItemRef ) continue; + + /* Est - on toujours dans le meme net ? */ + if( ( NetItemTst == Lim ) || + ( NetItemRef->m_NetCode != NetItemTst->m_NetCode ) ) + { /* Fin de netcode trouve */ + if( erc ) + { /* GLabel ou SheetLabel orphelin */ + Diagnose(panel, DC, NetItemRef, NULL, -1, WAR); + } + return; + } + + if( (NetItemRef->m_Type == NET_GLOBLABEL) || + (NetItemRef->m_Type == NET_GLOBBUSLABELMEMBER) ) + { + switch ( NetItemTst->m_Type ) + { + case NET_SEGMENT: + case NET_BUS: + case NET_JONCTION: + case NET_LABEL: + case NET_GLOBLABEL: + case NET_BUSLABELMEMBER: + case NET_GLOBBUSLABELMEMBER: + case NET_PINLABEL: + case NET_NOCONNECT: + case NET_PIN: + break; + + case NET_SHEETBUSLABELMEMBER: + case NET_SHEETLABEL: + /* Tst si le GLabel est bien dans la bonne sousfeuille */ + if( NetItemRef->m_SheetNumber == NetItemTst->m_NumInclude ) + { + erc = 0; + } + break; + } + } + + else + { + switch ( NetItemTst->m_Type ) + { + case NET_SEGMENT: + case NET_BUS: + case NET_JONCTION: + case NET_LABEL: + case NET_BUSLABELMEMBER: + case NET_SHEETBUSLABELMEMBER: + case NET_SHEETLABEL: + case NET_PINLABEL: + case NET_NOCONNECT: + case NET_PIN: + break; + + case NET_GLOBLABEL: + case NET_GLOBBUSLABELMEMBER: + /* Tst si le GLabel est bien dans la bonne sous-feuille */ + if( NetItemTst->m_SheetNumber == NetItemRef->m_NumInclude ) + { + erc = 0; + } + break; + } + } + } +} + + diff --git a/eeschema/fieldedi.cpp b/eeschema/fieldedi.cpp new file mode 100644 index 0000000000..1529d0b7ce --- /dev/null +++ b/eeschema/fieldedi.cpp @@ -0,0 +1,1118 @@ +/*********************************************************************/ +/* EESchema - edition des librairies: Edition des champs ( Fields ) */ +/*********************************************************************/ + + /* Fichier fieldedi.cpp */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +#include "wx/spinctrl.h" + +static char *PanelText[] = +{ + "Ref", /* Champ Reference of part, i.e. "IC21" */ + "Name", /* Champ Value of part, i.e. "3.3K" */ + "Fld1", + "Fld2", + "Fld3", + "Fld4", + "Fld5", + "Fld6", + "Fld7", + "Fld8", + "Pcb", /* Champ Name Module PCB, i.e. "16DIP300" */ + "Sheet" /* Champ Name Schema component, i.e. "cnt16.sch" */ +}; + + +/* Routines locales */ +static void MoveField(wxDC *DC, int flag); +static char * PrefixText(LibraryEntryStruct * LibEntry, int Unit); + +/* Variables locales */ + +extern int CurrentUnit; +static wxPoint StartCursor; + +/* Classe de la frame des propriétés d'un composant en librairie */ + +enum id_libedit { + ID_LIBEDIT_NOTEBOOK = 3200, + ID_PANEL_BASIC, + ID_PANEL_ALIAS, + ID_PANEL_REFERENCE, + ID_PANEL_VALUE, + ID_PANEL_FIELD1, + ID_PANEL_FIELD2, + ID_PANEL_FIELD3, + ID_PANEL_FIELD4, + ID_PANEL_FIELD5, + ID_PANEL_FIELD6, + ID_PANEL_FIELD7, + ID_PANEL_FIELD8, + ID_PANEL_MODULEPCB, + ID_PANEL_SUBSCHEMATIC, + ID_CLOSE_PART_PROPERTIES, + ID_ACCEPT_PART_PROPERTIES, + ID_ADD_ALIAS, + ID_DELETE_ONE_ALIAS, + ID_DELETE_ALL_ALIAS +}; + + + /************************************/ + /* class WinEDA_PartPropertiesFrame */ + /************************************/ + +class WinEDA_PartPropertiesFrame: public wxDialog +{ +private: + + WinEDA_LibeditFrame * m_Parent; + wxNotebook* m_NoteBook; + wxListBox * PartAliasList; + wxPanel * PanelBasic; + wxPanel * PanelAlias; + wxPanel * PanelDoc; + wxPanel * PanelField[NUMBER_OF_FIELDS]; + + wxCheckBox * AsConvertButt; + + wxCheckBox * ShowFieldText[NUMBER_OF_FIELDS]; + wxCheckBox * VorientFieldText[NUMBER_OF_FIELDS]; + wxCheckBox * ShowPinNumButt; + wxCheckBox * ShowPinNameButt; + wxCheckBox * PinsNameInsideButt; + wxSpinCtrl * SelNumberOfUnits; + wxSpinCtrl * m_SetSkew; + + WinEDA_GraphicTextCtrl * FieldTextCtrl[NUMBER_OF_FIELDS]; + WinEDA_PositionCtrl * FieldPosition[NUMBER_OF_FIELDS]; + int FieldFlags[NUMBER_OF_FIELDS]; + int FieldOrient[NUMBER_OF_FIELDS]; + WinEDA_EnterText * NewDoc; + WinEDA_EnterText * NewDocfile; + WinEDA_EnterText * NewKeywords; + ListOfAliasStruct * AliasListCopy; + + +public: + // Constructor and destructor + WinEDA_PartPropertiesFrame(WinEDA_LibeditFrame *parent, wxPoint& pos); + ~WinEDA_PartPropertiesFrame(void) + { + if( AliasListCopy ) AliasListCopy->FreeList(); + }; + +private: + void PartPropertiesAccept(wxCommandEvent& event); + void DeleteAllAliasOfPart(void); + void DeleteAliasOfPart(void); + void AddAliasOfPart(void); + bool ChangeNbUnitsPerPackage(int newUnit); + bool SetUnsetConvert(void); + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(WinEDA_PartPropertiesFrame, wxDialog) + EVT_BUTTON(ID_ACCEPT_PART_PROPERTIES, WinEDA_PartPropertiesFrame::PartPropertiesAccept) + EVT_BUTTON(ID_CLOSE_PART_PROPERTIES, WinEDA_PartPropertiesFrame::Close) + EVT_BUTTON(ID_ADD_ALIAS, WinEDA_PartPropertiesFrame::AddAliasOfPart) + EVT_BUTTON(ID_DELETE_ONE_ALIAS, WinEDA_PartPropertiesFrame::DeleteAliasOfPart) + EVT_BUTTON(ID_DELETE_ALL_ALIAS, WinEDA_PartPropertiesFrame::DeleteAllAliasOfPart) +END_EVENT_TABLE() + + +void InstallLibeditFrame(WinEDA_LibeditFrame * parent, wxPoint & pos) +{ + WinEDA_PartPropertiesFrame * frame = new WinEDA_PartPropertiesFrame(parent, pos); + frame->ShowModal(); frame->Destroy(); +} + + +WinEDA_PartPropertiesFrame::WinEDA_PartPropertiesFrame(WinEDA_LibeditFrame *parent, wxPoint& framepos): + wxDialog(parent, -1, _("Componant properties"), framepos, wxSize(320, 300), + wxDEFAULT_DIALOG_STYLE | FLOAT_ON_PARENT ) +{ +wxPoint pos; +wxLayoutConstraints* c; + + m_Parent = parent; + + SetAutoLayout(TRUE); + + Doc[0] = 0; Docfile[0] = 0; Keywords[0] = 0; + AliasListCopy = NULL; + + for ( int ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) + { + FieldFlags[ii] = 0; + } + if ( CurrentLibEntry ) + { + if ( ListAlias ) AliasListCopy = ListAlias->DupList(); + + if( CurrentLibEntry->Doc ) + strncpy(Doc,CurrentLibEntry->Doc, 256); + if( CurrentLibEntry->KeyWord ) + strncpy(Keywords,CurrentLibEntry->KeyWord, 256); + if( CurrentLibEntry->DocFile ) + strncpy(Docfile,CurrentLibEntry->DocFile, 256); + + FieldFlags[REFERENCE] = CurrentLibEntry->m_Prefix.m_Attributs; + FieldOrient[REFERENCE] = CurrentLibEntry->m_Prefix.m_Orient; + + FieldFlags[VALUE] = CurrentLibEntry->m_Name.m_Attributs; + FieldOrient[VALUE] = CurrentLibEntry->m_Name.m_Orient; + + LibDrawField * Field = CurrentLibEntry->Fields; + while ( Field ) + { + FieldFlags[Field->m_FieldId] = Field->m_Attributs; + FieldOrient[Field->m_FieldId] = Field->m_Orient; + Field = (LibDrawField*)Field->Pnext; + } + } + + m_NoteBook = new wxNotebook(this, ID_LIBEDIT_NOTEBOOK); + c = new wxLayoutConstraints; + c->left.SameAs(this, wxLeft, 4); + c->right.SameAs(this, wxRight, 4); + c->top.SameAs(this, wxTop, 4); + c->bottom.SameAs(this, wxBottom, 40); + m_NoteBook->SetConstraints(c); + m_NoteBook->SetAutoLayout(TRUE); + + /* Creation des boutons de commande */ + pos.x = 80; pos.y = 240; + wxButton * Button = new wxButton(this, ID_CLOSE_PART_PROPERTIES, + _("Close"), pos); + c = new wxLayoutConstraints; + c->left.SameAs(this, wxLeft, 20); + c->height.AsIs(); + c->width.AsIs(); + c->bottom.SameAs(this, wxBottom, 5); + Button->SetConstraints(c); + + pos.x += Button->GetDefaultSize().x + 10; + Button = new wxButton(this, ID_ACCEPT_PART_PROPERTIES, + _("Ok"), pos); + c = new wxLayoutConstraints; + c->right.SameAs(this, wxRight, 20); + c->height.AsIs(); + c->width.AsIs(); + c->bottom.SameAs(this, wxBottom, 5); + Button->SetConstraints(c); + + // Add panel Basic + PanelBasic = new wxPanel(m_NoteBook, ID_PANEL_BASIC); + c = new wxLayoutConstraints; + c->left.SameAs(m_NoteBook, wxLeft); + c->right.SameAs(m_NoteBook, wxRight); + c->bottom.SameAs(m_NoteBook, wxBottom); + PanelBasic->SetConstraints(c); + m_NoteBook->AddPage(PanelBasic, _("Options"), TRUE); + + pos.x = 5; pos.y = 25; + new wxStaticBox(PanelBasic, -1,_(" General : "), pos, wxSize(150, 120)); + + pos.x = 10; pos.y += 22; + AsConvertButt = new wxCheckBox(PanelBasic,-1, _("As Convert"), pos); + if ( g_AsDeMorgan ) AsConvertButt->SetValue(TRUE); + + pos.y += 20; + ShowPinNumButt = new wxCheckBox(PanelBasic,-1, _("Show Pin Num"), pos); + if ( CurrentLibEntry ) + { + if ( CurrentLibEntry->DrawPinNum ) ShowPinNumButt->SetValue(TRUE); + } + else ShowPinNumButt->SetValue(TRUE); + + pos.y += 20; + ShowPinNameButt = new wxCheckBox(PanelBasic,-1, _("Show Pin Name"), pos); + if ( CurrentLibEntry ) + { + if( CurrentLibEntry->DrawPinName ) ShowPinNameButt->SetValue(TRUE); + } + else ShowPinNameButt->SetValue(TRUE); + + pos.y += 20; + PinsNameInsideButt = new wxCheckBox(PanelBasic,-1, _("Pin Name Inside"), pos); + if ( CurrentLibEntry ) + { + if ( CurrentLibEntry->TextInside ) PinsNameInsideButt->SetValue(TRUE); + } + else PinsNameInsideButt->SetValue(TRUE); + + pos.y += 40; + new wxStaticText(PanelBasic,-1,_("Number of Units:"), pos); + pos.y += 15; + wxString number; + if ( CurrentLibEntry ) number.Printf("%d", CurrentLibEntry->NumOfUnits); + else number = "1"; + SelNumberOfUnits = new wxSpinCtrl(PanelBasic,-1,number, pos, + wxDefaultSize, wxSP_ARROW_KEYS | wxSP_WRAP, + 1, 16); + + pos.y -= 15; pos.x += 140; + new wxStaticText(PanelBasic,-1,_("Skew:"), pos); + pos.y += 15; + if ( CurrentLibEntry && CurrentLibEntry->TextInside) + number.Printf("%d", CurrentLibEntry->TextInside); + else number = "40"; + m_SetSkew = new wxSpinCtrl(PanelBasic,-1,number, pos, + wxDefaultSize, wxSP_ARROW_KEYS | wxSP_WRAP, + 1, 100); + + // Add Panel Documentation + PanelDoc = new wxPanel(m_NoteBook, -1); + c = new wxLayoutConstraints; + c->left.SameAs(m_NoteBook, wxLeft); + c->right.SameAs(m_NoteBook, wxRight); + c->bottom.SameAs(m_NoteBook, wxBottom); + PanelDoc->SetConstraints(c); + m_NoteBook->AddPage(PanelDoc, _("Doc"), FALSE); + pos.x = 5; pos.y = 40; + NewDoc = new WinEDA_EnterText(PanelDoc, + _("Doc:"), Doc, + pos, wxSize(285,-1) ); + pos.y += 50; + NewKeywoed = new WinEDA_EnterText(PanelDoc, + _("Keywords:"), Keywords, + pos, wxSize(285,-1) ); + pos.y += 50; + NewDocFile = new WinEDA_EnterText(PanelDoc, + _("DocFileName:"), Docfile, + pos, wxSize(285,-1) ); + + // Add Panel Alias List + PanelAlias = new wxPanel(m_NoteBook, -1); + c = new wxLayoutConstraints; + c->left.SameAs(m_NoteBook, wxLeft); + c->right.SameAs(m_NoteBook, wxRight); + c->bottom.SameAs(m_NoteBook, wxBottom); + PanelAlias->SetConstraints(c); + m_NoteBook->AddPage(PanelAlias, _("Alias"), FALSE); + + pos.x = 200; pos.y = 70; + new wxButton(PanelAlias, ID_ADD_ALIAS, + _("Add"), pos); + pos.y += Button->GetDefaultSize().y + 10; + new wxButton(PanelAlias, ID_DELETE_ONE_ALIAS, + _("Delete"), pos); + pos.y += Button->GetDefaultSize().y + 10; + new wxButton(PanelAlias, ID_DELETE_ALL_ALIAS, + _("Delete All"), pos); + + pos.x = 5; pos.y = 30; + PartAliasList = new wxListBox(PanelAlias, + -1, + pos, wxSize(160,170), + 0,NULL, + wxLB_ALWAYS_SB|wxLB_SINGLE); + wxStaticText * Msg = new wxStaticText(PanelAlias, -1, _("Alias"), + wxPoint(pos.x,pos.y - 20) ); + Msg->SetForegroundColour(wxColour(200,0,0) ); + /* lecture des alias */ + ListOfAliasStruct * Alias = AliasListCopy; + while( Alias ) + { + PartAliasList->Append(Alias->m_Name.m_Text); + Alias = Alias->Next; + } + + // Add panel Fields + for ( int ii = 0; ii < NUMBER_OF_FIELDS; ii++) + { + PanelField[ii] = new wxPanel(m_NoteBook, ID_PANEL_REFERENCE + ii); + c = new wxLayoutConstraints; + c->left.SameAs(m_NoteBook, wxLeft); + c->right.SameAs(m_NoteBook, wxRight); + c->bottom.SameAs(m_NoteBook, wxBottom); + PanelField[ii]->SetConstraints(c); + m_NoteBook->AddPage(PanelField[ii], PanelText[ii], FALSE); + + pos.x = 10; pos.y = 20; + ShowFieldText[ii] = new wxCheckBox(PanelField[ii],-1, + _("Show Text"), pos); + if ( (FieldFlags[ii] & TEXT_NO_VISIBLE ) == 0 ) + ShowFieldText[ii]->SetValue(TRUE); + + pos.x += 150; + VorientFieldText[ii] = new wxCheckBox(PanelField[ii],-1, + _("Vertical"), pos); + if ( FieldOrient[ii] ) VorientFieldText[ii]->SetValue(TRUE); + + pos.x = 10; pos.y += 50; + wxPoint txtpos; + switch ( ii ) + { + case REFERENCE: + if ( CurrentLibEntry ) + txtpos = CurrentLibEntry->m_Prefix.m_Pos; + else txtpos = wxPoint(0,0); + FieldTextCtrl[ii] = new WinEDA_GraphicTextCtrl( PanelField[ii], + PanelText[ii], + CurrentLibEntry ? CurrentLibEntry->m_Prefix.m_Text : (char*) "U", + CurrentLibEntry ? CurrentLibEntry->m_Prefix.m_Size : 50, + UnitMetric , + pos, 200, TRUE); + FieldPosition[ii] = new WinEDA_PositionCtrl( PanelField[ii], + txtpos, + UnitMetric , wxPoint (pos.x + 150, pos.y + 32) ); + break; + + case VALUE: + if ( CurrentLibEntry ) + txtpos = CurrentLibEntry->m_Name.m_Pos; + else txtpos = wxPoint(0,0); + FieldTextCtrl[ii] = new WinEDA_GraphicTextCtrl( PanelField[ii], + PanelText[ii], + CurrentLibEntry ? CurrentLibEntry->m_Name.m_Text : NULL, + CurrentLibEntry ? CurrentLibEntry->m_Name.m_Size : 50, + UnitMetric , + pos, 200, TRUE); + FieldPosition[ii] = new WinEDA_PositionCtrl( PanelField[ii], + txtpos, + UnitMetric , wxPoint (pos.x + 150, pos.y + 32) ); + break; + default: + int fsize; char * ftext; wxPoint fpos; + fsize = 50; ftext = NULL; + LibDrawField * Field = NULL; + fpos = wxPoint(0,0); + //recherche du Field de FieldId correspondant, s'il existe + if ( CurrentLibEntry ) + { + Field = CurrentLibEntry->Fields; + while ( Field ) + { + if( Field->m_FieldId == ii ) + { + fsize = Field->m_Size; ftext = Field->m_Text; + fpos = Field->m_Pos; + break; + } + Field = (LibDrawField*)Field->Pnext; + } + } + + FieldTextCtrl[ii] = new WinEDA_GraphicTextCtrl( PanelField[ii], + PanelText[ii], + ftext, fsize, + UnitMetric , + pos, 200, TRUE); + FieldPosition[ii] = new WinEDA_PositionCtrl( PanelField[ii], + fpos, + UnitMetric , wxPoint (pos.x + 150, pos.y + 32) ); + break; + } + } + + SetModal(TRUE); +} + + +/***************************************************************************/ +/* WinEDA_PartPropertiesFrame::PartPropertiesAccept(wxCommandEvent& event) */ +/***************************************************************************/ + +/* Met a jour les differents parametres pour le composant en cours d'édition +*/ + +void WinEDA_PartPropertiesFrame::PartPropertiesAccept(wxCommandEvent& event) +{ +bool recreateTB = FALSE; + + if( CurrentLibEntry == NULL ) + { + Close(); return; + } + + m_Parent->CurrentScreen->SetModify(); + m_Parent->CurrentScreen->SetRefreshReq(); + + if( ListAlias ) ListAlias->FreeList(); + if( AliasListCopy ) ListAlias = AliasListCopy->DupList(); + + if( CurrentLibEntry->Doc && strcmp(Doc,CurrentLibEntry->Doc) ) + { + free(CurrentLibEntry->Doc); CurrentLibEntry->Doc = NULL; + } + if( strlen(Doc) )CurrentLibEntry->Doc = strdup(Doc); + + if( CurrentLibEntry->KeyWord && strcmp(Keywords,CurrentLibEntry->KeyWord) ) + { + free(CurrentLibEntry->KeyWord); CurrentLibEntry->KeyWord = NULL; + } + if( strlen(Keywords) ) CurrentLibEntry->KeyWord = strdup(Keywords); + + if( CurrentLibEntry->DocFile && strcmp(Docfile,CurrentLibEntry->DocFile) ) + { + free(CurrentLibEntry->DocFile); CurrentLibEntry->DocFile = NULL; + } + if( strlen(Docfile) ) CurrentLibEntry->DocFile = strdup(Docfile); + + + CurrentLibEntry->m_Prefix.SetText( (char*)FieldTextCtrl[REFERENCE]->GetText() ); + CurrentLibEntry->m_Name.SetText( (char*)FieldTextCtrl[VALUE]->GetText() ); + + CurrentLibEntry->m_Prefix.m_Size = FieldTextCtrl[REFERENCE]->GetTextSize(); + CurrentLibEntry->m_Name.m_Size = FieldTextCtrl[VALUE]->GetTextSize(); + + CurrentLibEntry->m_Prefix.m_Pos = FieldPosition[REFERENCE]->GetCoord(); + CurrentLibEntry->m_Name.m_Pos = FieldPosition[VALUE]->GetCoord(); + + CurrentLibEntry->m_Prefix.m_Orient = VorientFieldText[REFERENCE]->GetValue() ? 1 : 0; + CurrentLibEntry->m_Name.m_Orient = VorientFieldText[VALUE]->GetValue() ? 1 : 0; + + if ( ShowFieldText[REFERENCE]->GetValue() ) + CurrentLibEntry->m_Prefix.m_Attributs &= ~TEXT_NO_VISIBLE; + else + CurrentLibEntry->m_Prefix.m_Attributs |= TEXT_NO_VISIBLE; + + if ( ShowFieldText[VALUE]->GetValue() ) + CurrentLibEntry->m_Name.m_Attributs &= ~TEXT_NO_VISIBLE; + else + CurrentLibEntry->m_Name.m_Attributs |= TEXT_NO_VISIBLE; + + for ( int ii = FIELD1; ii < NUMBER_OF_FIELDS; ii++ ) + { + LibDrawField * Field = CurrentLibEntry->Fields; + LibDrawField * NextField, * previousField = NULL; + while ( Field ) + { + NextField = (LibDrawField*)Field->Pnext; + if( Field->m_FieldId == ii ) + { + Field->SetText((char*) FieldTextCtrl[ii]->GetText()); + Field->m_Size = FieldTextCtrl[ii]->GetTextSize(); + if ( ShowFieldText[ii]->GetValue() ) + Field->m_Attributs &= ~TEXT_NO_VISIBLE; + else + Field->m_Attributs |= TEXT_NO_VISIBLE; + Field->m_Orient = VorientFieldText[ii]->GetValue() ? 1 : 0; + Field->m_Pos = FieldPosition[Field->m_FieldId]->GetCoord(); + if( Field->m_Text == NULL ) + { + delete Field; + if ( previousField ) previousField->Pnext = NextField; + else CurrentLibEntry->Fields = NextField; + } + break; + } + + previousField = Field; + Field = NextField; + } + if ( (Field == NULL) && strlen(FieldTextCtrl[ii]->GetText()) ) + { // N'existe pas: a creer + Field = new LibDrawField(ii); + Field->SetText((char*) FieldTextCtrl[ii]->GetText()); + Field->m_Size = FieldTextCtrl[ii]->GetTextSize(); + Field->Pnext = CurrentLibEntry->Fields; + if ( ShowFieldText[Field->m_FieldId]->GetValue() ) + Field->m_Attributs &= ~TEXT_NO_VISIBLE; + else + Field->m_Attributs |= TEXT_NO_VISIBLE; + Field->m_Orient = VorientFieldText[Field->m_FieldId]->GetValue() ?1 : 0; + Field->m_Pos = FieldPosition[Field->m_FieldId]->GetCoord(); + CurrentLibEntry->Fields = Field; + } + } + + + int ii = SelNumberOfUnits->GetValue(); + if ( ChangeNbUnitsPerPackage(ii) ) recreateTB = TRUE; + + if ( AsConvertButt->GetValue() ) + { + if ( ! g_AsDeMorgan ) + { + g_AsDeMorgan = 1; + if ( SetUnsetConvert() ) recreateTB = TRUE; + } + } + else + { + if ( g_AsDeMorgan ) + { + g_AsDeMorgan = 0; + if ( SetUnsetConvert() ) recreateTB = TRUE; + } + } + + CurrentLibEntry->DrawPinNum = ShowPinNumButt->GetValue() ? 1 : 0; + CurrentLibEntry->DrawPinName = ShowPinNameButt->GetValue() ? 1 : 0; + + if ( PinsNameInsideButt->GetValue() == FALSE) + CurrentLibEntry->TextInside = 0; + else + CurrentLibEntry->TextInside = m_SetSkew->GetValue(); + + if ( recreateTB) m_Parent->ReCreateHToolbar(); + + Close(); +} + + + /***************************************************************/ + /* void WinEDA_PartPropertiesFrame::DeleteAllAliasOfPart(void) */ + /***************************************************************/ + +void WinEDA_PartPropertiesFrame::DeleteAllAliasOfPart(void) +{ + + if(CurrentLibEntry && AliasListCopy ) + { + if( confirmation(_("Ok to Delete Alias LIST")) == YES) + { + if( AliasListCopy ) AliasListCopy->FreeList(); + AliasListCopy = NULL; + PartAliasList->Clear(); + } + } + +} + + /*********************************************************/ + /* void WinEDA_PartPropertiesFrame::AddAliasOfPart(void) */ + /*********************************************************/ + +void WinEDA_PartPropertiesFrame::AddAliasOfPart(void) +{ +char Line[LINE_LEN]; +int llen; +ListOfAliasStruct * NewAlias; + + if(CurrentLibEntry == NULL) return; + + *Line = 0; + if( Get_Message(_("Alias:"),Line, this) != 0 ) return; + + ChangeSpaces(Line, '_'); + llen = strlen(Line) + 1; + + NewAlias = LocateAlias(AliasListCopy, Line); + if ( NewAlias ) + { + DisplayError(_("Already in use"), 10); return; + } + NewAlias = new ListOfAliasStruct(Line); + NewAlias->Next = AliasListCopy; + AliasListCopy = NewAlias; + + /* affichage des alias */ + PartAliasList->Clear(); + ListOfAliasStruct * Alias = AliasListCopy; + while( Alias ) + { + PartAliasList->Append(Alias->m_Name.m_Text); + Alias = Alias->Next; + } + +} + + /********************************/ + /* void DeleteAliasOfPart(void) */ + /********************************/ + +void WinEDA_PartPropertiesFrame::DeleteAliasOfPart(void) +{ +ListOfAliasStruct * Alias; +wxString aliasname; + + if(CurrentLibEntry == NULL) return; + if ( AliasListCopy == NULL ) return; + + aliasname = PartAliasList->GetStringSelection(); + if ( aliasname == "" ) return; + + Alias = AliasListCopy; + ListOfAliasStruct * Previous = NULL; + while ( Alias ) + { + if ( stricmp(aliasname.GetData(), Alias->m_Name.m_Text) == 0 ) + { + if ( Previous ) Previous->Next = Alias->Next; + else AliasListCopy = Alias->Next; + delete Alias; + break; + } + Previous = Alias; + Alias = Alias->Next; + } + /* affichage des alias */ + PartAliasList->Clear(); + Alias = AliasListCopy; + while( Alias ) + { + PartAliasList->Append(Alias->m_Name.m_Text); + Alias = Alias->Next; + } + +} + + +/************************************************************/ +static void ExitMoveField(WinEDA_DrawFrame * frame, wxDC * DC) +/************************************************************/ +{ + + frame->CurrentScreen->ManageCurseur = NULL; + frame->CurrentScreen->ForceCloseManageCurseur = NULL; + if(CurrentDrawItem == NULL) return; + + wxPoint curpos; + curpos = frame->CurrentScreen->Curseur; + frame->CurrentScreen->Curseur = StartCursor; + MoveField(DC, 1); + frame->CurrentScreen->Curseur = curpos; + CurrentDrawItem->m_Flags = 0; + + CurrentDrawItem = NULL; +} + + + + /*********************************************/ + /* static void StartMoveField(COMMAND * Cmd) */ + /*********************************************/ +/* Initialise le deplacement d'un champ ( ref ou Name) */ +void WinEDA_LibeditFrame::StartMoveField(wxDC * DC, LibDrawField *field) +{ + + if( (CurrentLibEntry == NULL) || ( field == NULL ) ) return; + CurrentDrawItem = field; + CurrentDrawItem->m_Flags |= IS_MOVED; + CurrentScreen->ManageCurseur = MoveField; + CurrentScreen->ForceCloseManageCurseur = ExitMoveField; + CurrentScreen->ManageCurseur(DC, 1); + StartCursor = CurrentScreen->Curseur; +} + +/*****************************************************************/ +/* Routine d'affichage du texte 'Field' en cours de deplacement. */ +/* Routine normalement attachee au curseur */ +/*****************************************************************/ +static void MoveField(wxDC *DC, int flag) +{ +int color; +LibDrawField *Field = (LibDrawField *)CurrentDrawItem; + + if( (CurrentLibEntry == NULL) || (Field == NULL) ) return; + + GRSetDrawMode(DC, XOR_MODE); + + switch (Field->m_FieldId) + { + case VALUE: + color = ReturnLayerColor(LAYER_VALUEPART); + break; + + case REFERENCE: + color = ReturnLayerColor(LAYER_REFERENCEPART); + break; + + default: + color = ReturnLayerColor(LAYER_FIELDS); + break; + } + + if( Field->m_Attributs & TEXT_NO_VISIBLE ) color = DARKGRAY; + if( flag >= 0 ) + Gr_E_texte(DC, Field->m_Pos.x, - Field->m_Pos.y, + color, Field->m_Text, + Field->m_Orient, Field->m_Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + + Field->m_Pos.x = ActiveScreen->Curseur.x; + Field->m_Pos.y = - ActiveScreen->Curseur.y; + + Gr_E_texte(DC, Field->m_Pos.x, - Field->m_Pos.y, + color, Field->m_Text, + Field->m_Orient, Field->m_Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); +} + + /********************************/ + /* static void PlaceField(void) */ + /********************************/ + +void WinEDA_LibeditFrame::PlaceField(wxDC * DC, LibDrawField *Field) +{ +int color; + + if(Field == NULL ) return; + + GRSetDrawMode(DC, GR_DEFAULT_DRAWMODE); + + switch (Field->m_FieldId) + { + case REFERENCE: + color = ReturnLayerColor(LAYER_REFERENCEPART); + break; + + case VALUE: + color = ReturnLayerColor(LAYER_VALUEPART); + break; + + default: + color = ReturnLayerColor(LAYER_FIELDS); + break; + } + + if( Field->m_Attributs & TEXT_NO_VISIBLE ) color = DARKGRAY; + Gr_E_texte(DC, Field->m_Pos.x, - Field->m_Pos.y, + color, Field->m_Text, + Field->m_Orient, Field->m_Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + + Field->m_Flags = 0; + + CurrentScreen->SetModify(); + CurrentScreen->ManageCurseur = NULL; + CurrentScreen->ForceCloseManageCurseur = NULL; + CurrentDrawItem = NULL; +} + + + /****************************************/ + /* static void EditField(COMMAND * Cmd) */ + /****************************************/ + +void WinEDA_LibeditFrame::EditField(wxDC * DC, LibDrawField *Field) +{ +char Text[LINE_LEN]; +int color; +wxClientDC dc(DrawPanel); + + if( Field== NULL) return; + + switch (Field->m_FieldId) + { + case REFERENCE: + color = ReturnLayerColor(LAYER_REFERENCEPART); + break; + + case VALUE: + color = ReturnLayerColor(LAYER_VALUEPART); + break; + + default: + color = ReturnLayerColor(LAYER_FIELDS); + break; + } + + *Text = 0; + if( Field->m_Attributs & TEXT_NO_VISIBLE ) color = DARKGRAY; + + if (Field->m_Text) strcpy(Text,Field->m_Text); + Get_Message(_("Text: "),Text, this); + ChangeSpaces(Text, '_'); + + GRSetDrawMode(&dc, XOR_MODE); + Gr_E_texte(DC, Field->m_Pos.x, - Field->m_Pos.y, + color, Field->m_Text, + Field->m_Orient, Field->m_Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + + Field->SetText(Text); + + if( Field->m_Flags == 0 ) GRSetDrawMode(&dc, GR_DEFAULT_DRAWMODE); + + Gr_E_texte(DC, Field->m_Pos.x, - Field->m_Pos.y, + color, Field->m_Text, + Field->m_Orient, Field->m_Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + + CurrentScreen->SetModify(); +} + +/*******************************************************************/ +void WinEDA_LibeditFrame::RotateField(wxDC * DC, LibDrawField *Field) +/*******************************************************************/ +/* + Routine de modification de l'orientation ( Horiz ou Vert. ) du champ. + si un champ est en cours d'edition, modif de celui ci. + sinon Modif du champ pointe par la souris +*/ +{ +int color; + + if( Field == NULL) return; + + CurrentScreen->SetModify(); + switch (Field->m_FieldId) + { + case REFERENCE: + color = ReturnLayerColor(LAYER_REFERENCEPART); + break; + + case VALUE: + color = ReturnLayerColor(LAYER_VALUEPART); + break; + + default: + color = ReturnLayerColor(LAYER_FIELDS); + break; + } + + if( Field->m_Attributs & TEXT_NO_VISIBLE ) color = DARKGRAY; + + GRSetDrawMode(DC, XOR_MODE); + Gr_E_texte(DC, Field->m_Pos.x, - Field->m_Pos.y, + color, Field->m_Text, + Field->m_Orient, Field->m_Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + + if( Field->m_Orient) Field->m_Orient = 0; + else Field->m_Orient = 1; + + if( Field->m_Flags == 0 ) GRSetDrawMode(DC, GR_DEFAULT_DRAWMODE); + + Gr_E_texte(DC, Field->m_Pos.x, - Field->m_Pos.y, + color, Field->m_Text, + Field->m_Orient, Field->m_Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); +} + + + /********************************************************/ + /* static int LocateField(LibraryEntryStruct *LibEntry) */ + /********************************************************/ + +/* Localise le champ (ref ou name) pointe par la souris + retourne: + < 0: Pas de champ + 0: Ref + 1: Name(s) + > 2 = Num Field +*/ +LibDrawField * WinEDA_LibeditFrame::LocateField(LibraryEntryStruct *LibEntry) +{ +int x0, y0, x1, y1; /* Rectangle d'encadrement des textes a localiser */ +int dx, dy; /* Dimensions du texte */ +LibDrawField *Field; + + /* Localisation du Nom */ + x0 = LibEntry->m_Name.m_Pos.x; + y0 = - LibEntry->m_Name.m_Pos.y; + dx = LibEntry->m_Name.m_Size * strlen(LibEntry->m_Name.m_Text), + dy = LibEntry->m_Name.m_Size; + if (LibEntry->m_Name.m_Orient) EXCHG(dx, dy); + x0 -= dx/2; y0 -= dy/2; + x1 = x0 + dx; y1 = y0 + dy; + + if( (CurrentScreen->Curseur.x >= x0) && ( CurrentScreen->Curseur.x <= x1) && + (CurrentScreen->Curseur.y >= y0) && ( CurrentScreen->Curseur.y <= y1) ) + return &LibEntry->m_Name; + + /* Localisation du Prefix */ + x0 = LibEntry->m_Prefix.m_Pos.x; + y0 = - LibEntry->m_Prefix.m_Pos.y; + dx = LibEntry->m_Prefix.m_Size * strlen(LibEntry->m_Prefix.m_Text), + dy = LibEntry->m_Prefix.m_Size; + if (LibEntry->m_Prefix.m_Orient) EXCHG(dx, dy); + x0 -= dx/2; y0 -= dy/2; + x1 = x0 + dx; y1 = y0 + dy; + + if( (CurrentScreen->Curseur.x >= x0) && ( CurrentScreen->Curseur.x <= x1) && + (CurrentScreen->Curseur.y >= y0) && ( CurrentScreen->Curseur.y <= y1) ) + return &LibEntry->m_Prefix; + + /* Localisation des autres fields */ + for (Field = LibEntry->Fields; Field != NULL; + Field = (LibDrawField*)Field->Pnext) + { + if ( Field->m_Text == NULL) continue; + x0 = Field->m_Pos.x; y0 = - Field->m_Pos.y; + dx = Field->m_Size * strlen(Field->m_Text), + dy = Field->m_Size; + if (Field->m_Orient) EXCHG(dx, dy); + x0 -= dx/2; y0 -= dy/2; + x1 = x0 + dx; y1 = y0 + dy; + if( (CurrentScreen->Curseur.x >= x0) && ( CurrentScreen->Curseur.x <= x1) && + (CurrentScreen->Curseur.y >= y0) && ( CurrentScreen->Curseur.y <= y1) ) + return(Field); + } + + return NULL; +} + + /*********************************************************************/ + /* static char * PrefixText(LibraryEntryStruct * LibEntry, int Unit) */ + /*********************************************************************/ + +/* Calcule l'affichage complet du prefixe ( texte + '?' + ident unit ) + Retourne un pointeur sur le nouveau texte (allocation statique) +*/ +static char * PrefixText(LibraryEntryStruct * LibEntry, int Unit) +{ +static char Text[LINE_LEN]; + + if (LibEntry->NumOfUnits > 1) + sprintf(Text,"%s?%c",LibEntry->m_Prefix.m_Text,Unit + 'A' - 1); + else sprintf(Text,"%s?",LibEntry->m_Prefix.m_Text); + return( Text ); +} + + + + /*****************************************************************/ + /* void WinEDA_PartPropertiesFrame::ChangeNbUnitsPerPackagevoid) */ + /*****************************************************************/ + +/* Routine de modification du nombre d'unites par package pour le + composant courant; +*/ +bool WinEDA_PartPropertiesFrame::ChangeNbUnitsPerPackage(int MaxUnit) +{ +int OldNumUnits, ii, FlagDel = -1; +LibEDA_BaseStruct* DrawItem, * NextDrawItem; + + if( CurrentLibEntry == NULL ) return FALSE; + + /* Si pas de changement: termine */ + if ( CurrentLibEntry->NumOfUnits == MaxUnit ) return FALSE; + + OldNumUnits = CurrentLibEntry->NumOfUnits; + if ( OldNumUnits < 1 ) OldNumUnits = 1; + + CurrentLibEntry->NumOfUnits = MaxUnit; + + + /* Traitement des unites enlevees ou rajoutees */ + if(OldNumUnits > CurrentLibEntry->NumOfUnits ) + { + DrawItem = CurrentLibEntry->Drawings; + for ( ; DrawItem != NULL; DrawItem = NextDrawItem) + { + NextDrawItem = DrawItem->Pnext; + if( DrawItem->m_Unit > MaxUnit ) /* Item a effacer */ + { + if( FlagDel < 0 ) + { + if( confirmation(_("Delete units")) == YES ) + { + /* Si part selectee n'existe plus: selection 1ere unit */ + if( CurrentUnit > MaxUnit ) CurrentUnit = 1; + FlagDel = 1; + } + else + { + FlagDel = 0; + MaxUnit = OldNumUnits; + CurrentLibEntry->NumOfUnits = MaxUnit; + return FALSE; + } + } + DeleteOneLibraryDrawStruct(NULL, CurrentLibEntry, + DrawItem, 0); + } + } + return TRUE; + } + + if(OldNumUnits < CurrentLibEntry->NumOfUnits ) + { + DrawItem = CurrentLibEntry->Drawings; + for ( ; DrawItem != NULL; DrawItem = DrawItem->Pnext ) + { + /* Duplication des items pour autres elements */ + if( DrawItem->m_Unit == 1 ) + { + for ( ii = OldNumUnits +1; ii <= MaxUnit; ii ++ ) + { + NextDrawItem = CopyDrawEntryStruct(DrawItem); + NextDrawItem->Pnext = CurrentLibEntry->Drawings; + CurrentLibEntry->Drawings = NextDrawItem; + NextDrawItem->m_Unit = ii; + } + } + } + } + return TRUE; +} + + + /**********************************************************/ + /* void WinEDA_PartPropertiesFrame::SetUnsetConvert(void) */ + /**********************************************************/ +/* crée ou efface (selon option AsConvert) les éléments + de la représentation convertie d'un composant +*/ +bool WinEDA_PartPropertiesFrame::SetUnsetConvert(void) +{ +int FlagDel = 0; +LibEDA_BaseStruct* DrawItem = NULL, * NextDrawItem; + + if( g_AsDeMorgan ) /* Representation convertie a creer */ + { + /* Traitement des elements a ajouter ( pins seulement ) */ + if( CurrentLibEntry ) DrawItem = CurrentLibEntry->Drawings; + for ( ; DrawItem != NULL; DrawItem = DrawItem->Pnext ) + { + /* Duplication des items pour autres elements */ + if( DrawItem->m_StructType != PIN_DRAW_TYPE ) continue; + if( DrawItem->m_Convert == 1 ) + { + if( FlagDel == 0 ) + { + if( confirmation(_("Create pins for Convert items")) == YES ) + FlagDel = 1; + else + { + if( confirmation(_("Part as \"De Morgan\" anymore")) == YES ) + return TRUE; + + g_AsDeMorgan = 0; return FALSE; + } + } + NextDrawItem = CopyDrawEntryStruct(DrawItem); + NextDrawItem->Pnext = CurrentLibEntry->Drawings; + CurrentLibEntry->Drawings = NextDrawItem; + NextDrawItem->m_Convert = 2; + } + } + } + + else /* Representation convertie a supprimer */ + { + /* Traitement des elements à supprimer */ + if( CurrentLibEntry ) DrawItem = CurrentLibEntry->Drawings; + for ( ; DrawItem != NULL; DrawItem = NextDrawItem) + { + NextDrawItem = DrawItem->Pnext; + if( DrawItem->m_Convert > 1 ) /* Item a effacer */ + { + if( FlagDel == 0 ) + { + if( confirmation(_("Delete Convert items")) == YES ) + { + CurrentConvert = 1; + FlagDel = 1; + } + else + { + g_AsDeMorgan = 1; + return FALSE; + } + } + ActiveScreen->SetModify(); + DeleteOneLibraryDrawStruct(NULL, CurrentLibEntry, DrawItem, 0); + } + } + } + return TRUE; +} + diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp new file mode 100644 index 0000000000..c3032e23cc --- /dev/null +++ b/eeschema/files-io.cpp @@ -0,0 +1,138 @@ + /****************************/ + /* EESCHEMA - files-io.cpp */ + /****************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" +#include "id.h" + +/* Fonctions locales */ + + +/****************************************************************/ +void WinEDA_SchematicFrame::Save_File(wxCommandEvent& event) +/****************************************************************/ +/* Commands to save shepatic project or the current page. +*/ +{ +int id = event.GetId(); + + switch (id) + { + case ID_SAVE_PROJECT: /* Update Schematic File */ + SaveProject(this); + break; + + case ID_SAVE_ONE_SHEET: /* Update Schematic File */ + SaveEEFile(NULL, FILE_SAVE_AS); + break; + + case ID_SAVE_ONE_SHEET_AS: /* Save EED (new name) */ + SaveEEFile(NULL, FILE_SAVE_NEW); + break; + + default: DisplayError(this, wxT("WinEDA_SchematicFrame::Save_File Internal Error")); + break; + } +} + + +/**********************************************************************************/ +bool WinEDA_SchematicFrame::LoadOneSheet(SCH_SCREEN * screen, const wxString & FullFileName) +/**********************************************************************************/ +{ + if( screen->EEDrawList != NULL ) + { + if( !IsOK(this, _("Clear SubHierarchy ?") ) ) return FALSE; + ClearProjectDrawList(screen, TRUE); + } + + if( FullFileName.IsEmpty()) + { + wxString filename, mask; + mask = wxT("*") + g_SchExtBuffer; + filename = EDA_FileSelector( _("Schematic files:"), + wxEmptyString, /* Chemin par defaut */ + screen->m_FileName, /* nom fichier par defaut */ + g_SchExtBuffer, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_OPEN, + FALSE + ); + if ( filename.IsEmpty() ) return FALSE; + else screen->m_FileName = filename; + } + + else screen->m_FileName = FullFileName; + + LoadOneEEFile(screen, screen->m_FileName); + screen->SetRefreshReq(); + return TRUE; +} + +/****************************************************/ +void SaveProject(WinEDA_SchematicFrame * frame) +/****************************************************/ +/* Sauvegarde toutes les feuilles du projet + et crée une librairie archive des composants, de nom .chche.lib +*/ +{ +SCH_SCREEN * screen_tmp; +wxString LibArchiveFileName; + + if ( frame == NULL) return; + + screen_tmp = frame->GetScreen(); + + EDA_ScreenList ScreenList(NULL); + for ( ActiveScreen = ScreenList.GetFirst(); ActiveScreen != NULL; ActiveScreen = ScreenList.GetNext() ) + { + frame->m_CurrentScreen = ActiveScreen; + frame->SaveEEFile( NULL, FILE_SAVE_AS); + } + + frame->m_CurrentScreen = ActiveScreen = screen_tmp; + + /* Creation du fichier d'archivage composants en repertoire courant */ + LibArchiveFileName = MakeFileName(wxEmptyString,ScreenSch->m_FileName,wxEmptyString); + ChangeFileNameExt(LibArchiveFileName, wxEmptyString); + /* mise a jour extension */ + LibArchiveFileName += wxT(".cache") + g_LibExtBuffer; + LibArchive(frame, LibArchiveFileName); + +} + +/************************/ +int CountCmpNumber(void) +/************************/ +/* Routine retournant le nombre de composants dans le schema, +powers non comprises */ +{ +BASE_SCREEN * Window; +EDA_BaseStruct *Phead; +int Nb = 0; + + Window = ScreenSch ; + while( Window ) + { + for( Phead=Window->EEDrawList; Phead != NULL; Phead=Phead->Pnext) + { + if (Phead->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE) + { + DrawPartStruct * Cmp = (DrawPartStruct *) Phead; + if ( Cmp->m_Field[VALUE].m_Text.GetChar(0) != '#' ) Nb++; + } + } + Window = (BASE_SCREEN*)Window->Pnext; + } + + return(Nb); +} diff --git a/eeschema/find.cpp b/eeschema/find.cpp new file mode 100644 index 0000000000..1808d3101d --- /dev/null +++ b/eeschema/find.cpp @@ -0,0 +1,493 @@ + /****************************************************************/ + /* EESchema: find.cpp (functions for seraching a schematic item */ + /****************************************************************/ +/* + Search a text (text, value, reference) withing e composent or + search a composant in libraries, a marker ..., + in current sheet or whole the project +*/ +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +/* Variables Locales */ +static int s_ItemsCount, s_MarkerCount; +static wxString s_OldStringFound; + +#include "dialog_find.cpp" + + +#include "protos.h" + + + +/**************************************************************/ +void InstallFindFrame(WinEDA_SchematicFrame *parent, wxPoint & pos) +/**************************************************************/ +{ + parent->DrawPanel->m_IgnoreMouseEvents = TRUE; + WinEDA_FindFrame * frame = new WinEDA_FindFrame(parent); + frame->ShowModal(); frame->Destroy(); + parent->DrawPanel->m_IgnoreMouseEvents = FALSE; +} + + +/**************************************************************/ +void WinEDA_FindFrame::FindMarker(wxCommandEvent& event) +/**************************************************************/ +/* Search de markers in whole the hierarchy. + Mouse cursor is put on the marker + search the first marker, or next marker +*/ +{ +int id = event.GetId(); + if( id != FIND_NEXT_MARKER ) m_Parent->FindMarker(0); + else m_Parent->FindMarker(1); + + Close(); + +} +/*****************************************************************/ +EDA_BaseStruct * WinEDA_SchematicFrame::FindMarker(int SearchType) +/*****************************************************************/ +/* Search markers in whole the hierarchy. + Mouse cursor is put on the marker + SearchType = 0: search the first marker, else search next marker +*/ +{ +SCH_SCREEN * Screen, * FirstScreen = NULL; +EDA_BaseStruct *DrawList, *FirstStruct = NULL, *Struct = NULL; +DrawMarkerStruct * Marker = NULL; +int StartCount; +bool NotFound; +wxPoint firstpos, pos; +wxSize size = DrawPanel->GetClientSize(); +wxPoint curpos, old_cursor_position; +bool force_recadre = FALSE; +wxString msg, WildText; + + g_LastSearchIsMarker = TRUE; + /* Set s_MarkerCount to 0 if we are look for the first marker */ + if( SearchType == 0 ) s_MarkerCount = 0; + + EDA_ScreenList ScreenList(NULL); + NotFound = TRUE; StartCount = 0; + /* Search for s_MarkerCount markers */ + for ( Screen = ScreenList.GetFirst(); Screen != NULL; Screen = ScreenList.GetNext() ) + { + DrawList = Screen->EEDrawList; + while ( DrawList && NotFound ) + { + if(DrawList->m_StructType == DRAW_MARKER_STRUCT_TYPE ) + { + Marker = (DrawMarkerStruct *) DrawList; + NotFound = FALSE; + pos = Marker->m_Pos; + if ( FirstScreen == NULL ) /* First item found */ + { + FirstScreen = Screen; firstpos = pos; + FirstStruct = DrawList; + } + + StartCount++; + if( s_MarkerCount >= StartCount ) + { + NotFound = TRUE; /* Search for other markers */ + } + else /* We have found s_MarkerCount markers -> Ok */ + { + Struct = DrawList; s_MarkerCount++; break ; + } + } + DrawList = DrawList->Pnext; + } + if( NotFound == FALSE ) break; + } + + if( NotFound && FirstScreen ) // markers are found, but we have reach the last marker */ + { // After the last marker, the first marker is used */ + NotFound = FALSE; Screen = FirstScreen; + Struct = FirstStruct; + pos = firstpos; s_MarkerCount = 1; + } + + if( NotFound == FALSE) + { + if ( Screen != GetScreen() ) + { + Screen->SetZoom(GetScreen()->GetZoom() ); + m_CurrentScreen = ActiveScreen = Screen; + force_recadre = TRUE; + } + + old_cursor_position = Screen->m_Curseur; + Screen->m_Curseur = pos; + curpos = DrawPanel->CursorScreenPosition(); + // calcul des coord curseur avec origine = screen + DrawPanel->GetViewStart(&m_CurrentScreen->m_StartVisu.x, + &m_CurrentScreen->m_StartVisu.y); + curpos.x -= m_CurrentScreen->m_StartVisu.x; + curpos.y -= m_CurrentScreen->m_StartVisu.y; + + /* Il y a peut-etre necessite de recadrer le dessin: */ + if( (curpos.x <= 0) || (curpos.x >= size.x-1) || + (curpos.y <= 0) || (curpos.y >= size.y) || force_recadre ) + { + Recadre_Trace(TRUE); + } + else + { + wxClientDC dc(DrawPanel); + DrawPanel->PrepareGraphicContext(&dc); + EXCHG(old_cursor_position, Screen->m_Curseur); + DrawPanel->CursorOff(&dc); + GRMouseWarp(DrawPanel, curpos ); + EXCHG(old_cursor_position, Screen->m_Curseur); + DrawPanel->CursorOn(&dc); + } + + msg.Printf( _("Marker %d found in %s"), s_MarkerCount, Screen->m_FileName.GetData()); + Affiche_Message(msg); + } + + else + { + Affiche_Message(wxEmptyString); + msg = _("Marker Not Found"); + DisplayError(this,msg, 10); + } + + return Marker; +} + + +/**************************************************************/ +void WinEDA_FindFrame::FindSchematicItem(wxCommandEvent& event) +/**************************************************************/ +/* Find a string in schematic. + Call to WinEDA_SchematicFrame::FindSchematicItem() +*/ +{ +int id = event.GetId(); + + if( id == FIND_SHEET ) + m_Parent->FindSchematicItem(m_NewTextCtrl->GetValue(), 0); + else if( id == FIND_HIERARCHY ) + m_Parent->FindSchematicItem(m_NewTextCtrl->GetValue(), 1); + else if( id == FIND_NEXT ) + m_Parent->FindSchematicItem(wxEmptyString, 2); + + Close(); +} + +/************************************************************************/ +EDA_BaseStruct * WinEDA_SchematicFrame::FindSchematicItem( + const wxString & pattern, int SearchType) +/************************************************************************/ +/* Find a string in schematic. + Search is made in current sheet (SearchType = 0), + or the whole hierarchy (SearchType = 1), + or for the next item (SearchType = 2). + Mouse cursor is put on item +*/ +{ +SCH_SCREEN * Screen, * FirstScreen = NULL; +EDA_BaseStruct *DrawList = NULL, *FirstStruct = NULL, *Struct = NULL; +int StartCount, ii, jj; +bool NotFound; +wxPoint firstpos, pos, old_cursor_position; +static int Find_in_hierarchy; +wxSize size = DrawPanel->GetClientSize(); +wxPoint curpos; +bool force_recadre = FALSE; +wxString msg, WildText; + + g_LastSearchIsMarker = FALSE; + + if( SearchType == 0 ) + { + s_OldStringFound = pattern; + Find_in_hierarchy = FALSE; + } + + if( SearchType == 1 ) + { + s_OldStringFound = pattern; + Find_in_hierarchy = TRUE; + } + + if( SearchType != 2 ) s_ItemsCount = 0; + + WildText = s_OldStringFound; + NotFound = TRUE; StartCount = 0; + + EDA_ScreenList ScreenList(NULL); + Screen = ScreenList.GetFirst(); + if ( ! Find_in_hierarchy ) Screen = (SCH_SCREEN*) m_CurrentScreen; + + for ( ; Screen != NULL; Screen = ScreenList.GetNext() ) + { + DrawList = Screen->EEDrawList; + while ( DrawList ) + { + switch (DrawList->m_StructType) + { + case DRAW_LIB_ITEM_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((EDA_SchComponentStruct*)DrawList) + if( WildCompareString( WildText, STRUCT->m_Field[REFERENCE].m_Text, FALSE ) ) + { + NotFound = FALSE; + pos = STRUCT->m_Field[REFERENCE].m_Pos; + break; + } + if( WildCompareString( WildText, STRUCT->m_Field[VALUE].m_Text, FALSE ) ) + { + NotFound = FALSE; + pos = STRUCT->m_Field[VALUE].m_Pos; + } + break; + + case DRAW_LABEL_STRUCT_TYPE : + case DRAW_GLOBAL_LABEL_STRUCT_TYPE : + case DRAW_TEXT_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((DrawTextStruct*)DrawList) + if( WildCompareString( WildText, STRUCT->m_Text, FALSE ) ) + { + NotFound = FALSE; + pos = STRUCT->m_Pos; + } + break; + + default: + break; + } + + if(NotFound == FALSE) /* Element trouve */ + { + if ( FirstScreen == NULL ) /* 1er element trouve */ + { + FirstScreen = Screen; firstpos = pos; + FirstStruct = DrawList; + } + + StartCount++; + if( s_ItemsCount >= StartCount ) + { + NotFound = TRUE; /* Continue recherche de l'element suivant */ + } + else + { + Struct = DrawList; s_ItemsCount++; break ; + } + } + if( NotFound == FALSE ) break; + DrawList = DrawList->Pnext; + } + if( NotFound == FALSE ) break; + if( Find_in_hierarchy == FALSE ) break; + } + + if( NotFound && FirstScreen ) + { + NotFound = FALSE; Screen = FirstScreen; Struct = FirstStruct; + pos = firstpos; s_ItemsCount = 1; + } + + if( NotFound == FALSE) + { + if ( Screen != GetScreen() ) + { + Screen->SetZoom(GetScreen()->GetZoom() ); + m_CurrentScreen = ActiveScreen = Screen; + force_recadre = TRUE; + } + + /* Si la struct localisee est du type DRAW_LIB_ITEM_STRUCT_TYPE, + Les coordonnes sont a recalculer en fonction de la matrice + d'orientation */ + if( Struct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE ) + { + #undef STRUCT + #define STRUCT ((EDA_SchComponentStruct*)Struct) + pos.x -= STRUCT->m_Pos.x; pos.y -= STRUCT->m_Pos.y; + ii = STRUCT->m_Transform[0][0] * pos.x + STRUCT->m_Transform[0][1] * pos.y; + jj = STRUCT->m_Transform[1][0] * pos.x + STRUCT->m_Transform[1][1] * pos.y; + pos.x = ii + STRUCT->m_Pos.x; pos.y = jj + STRUCT->m_Pos.y; + } + + old_cursor_position = Screen->m_Curseur; + Screen->m_Curseur = pos; + curpos = DrawPanel->CursorScreenPosition(); + DrawPanel->GetViewStart(&m_CurrentScreen->m_StartVisu.x, + &m_CurrentScreen->m_StartVisu.y); + + // calcul des coord curseur avec origine = screen + curpos.x -= m_CurrentScreen->m_StartVisu.x; + curpos.y -= m_CurrentScreen->m_StartVisu.y; + + /* Il y a peut-etre necessite de recadrer le dessin: */ + if( (curpos.x <= 0) || (curpos.x >= size.x-1) || + (curpos.y <= 0) || (curpos.y >= size.y) || force_recadre ) + { + Recadre_Trace(TRUE); + } + else + { + wxClientDC dc(DrawPanel); + DrawPanel->PrepareGraphicContext(&dc); + EXCHG(old_cursor_position, Screen->m_Curseur); + DrawPanel->CursorOff(&dc); + GRMouseWarp(DrawPanel, curpos ); + EXCHG(old_cursor_position, Screen->m_Curseur); + DrawPanel->CursorOn(&dc); + } + + msg = WildText + _(" Found in ") + Screen->m_FileName; + Affiche_Message(msg); + } + + else + { + Affiche_Message(wxEmptyString); + msg = WildText + _(" Not Found"); + DisplayError(this,msg, 10); + } + + return DrawList; +} + + +/*************************************************************/ +void WinEDA_FindFrame::LocatePartInLibs(wxCommandEvent& event) +/*************************************************************/ +/* Recherche exhaustive d'un composant en librairies, meme non chargees +*/ +{ +wxString Text, FindList; +const wxChar ** ListNames; +LibraryStruct *Lib = NULL; +EDA_LibComponentStruct * LibEntry; +bool FoundInLib = FALSE; // True si reference trouvee ailleurs qu'en cache + + Text = m_NewTextCtrl->GetValue(); + if ( Text.IsEmpty() ) + { + Close(); return; + } + s_OldStringFound = Text; + + int ii, nbitems, NumOfLibs = NumOfLibraries(); + if (NumOfLibs == 0) + { + DisplayError(this, _("No libraries are loaded")); + Close(); return; + } + + ListNames = GetLibNames(); + + nbitems = 0; + for (ii = 0; ii < NumOfLibs; ii++ ) /* Recherche de la librairie */ + { + bool IsLibCache; + Lib = FindLibrary(ListNames[ii]); + if ( Lib == NULL ) break; + if ( Lib->m_Name.Contains( wxT(".cache")) ) IsLibCache = TRUE; + else IsLibCache = FALSE; + LibEntry = (EDA_LibComponentStruct *) PQFirst(&Lib->m_Entries, FALSE); + while( LibEntry ) + { + if( WildCompareString(Text, LibEntry->m_Name.m_Text, FALSE) ) + { + nbitems ++; + if ( ! IsLibCache ) FoundInLib = TRUE; + if ( ! FindList.IsEmpty() ) FindList += wxT("\n"); + FindList << _("Found ") + + LibEntry->m_Name.m_Text + + _(" in lib ") + Lib->m_Name; + } + LibEntry = (EDA_LibComponentStruct *) PQNext(Lib->m_Entries, LibEntry, NULL); + } + } + + free (ListNames); + + if ( ! FoundInLib ) + { + if ( nbitems ) FindList = wxT("\n") + Text + _(" found only in cache"); + else FindList = Text + _(" not found"); + FindList += _("\nExplore All Libraries?"); + if ( IsOK(this, FindList) ) + { + FindList.Empty(); + ExploreAllLibraries(Text, FindList); + if ( FindList.IsEmpty() ) DisplayInfo(this, _("Nothing found") ); + else DisplayInfo(this, FindList); + } + } + else DisplayInfo(this, FindList); + + Close(); +} + + +/***************************************************************************************/ +int WinEDA_FindFrame::ExploreAllLibraries(const wxString & wildmask, wxString & FindList) +/***************************************************************************************/ +{ +wxString FullFileName; +FILE * file; +int nbitems = 0, LineNum = 0; +char Line[2048], *name; + + FullFileName = MakeFileName(g_RealLibDirBuffer, wxT("*"), g_LibExtBuffer); + + FullFileName = wxFindFirstFile(FullFileName); + while ( ! FullFileName.IsEmpty() ) + { + file = wxFopen(FullFileName, wxT("rt")); + if (file == NULL) continue; + + while (GetLine(file, Line, &LineNum, sizeof(Line)) ) + { + if (strnicmp(Line, "DEF", 3) == 0) + { /* Read one DEF part from library: DEF 74LS00 U 0 30 Y Y 4 0 N */ + strtok(Line, " \t\r\n"); + name = strtok(NULL, " \t\r\n"); + wxString st_name = CONV_FROM_UTF8(name); + if( WildCompareString(wildmask, st_name, FALSE) ) + { + nbitems ++; + if ( ! FindList.IsEmpty() ) FindList += wxT("\n"); + FindList << _("Found ") << CONV_FROM_UTF8(name) + << _(" in lib ") << FullFileName; + } + } + else if (strnicmp(Line, "ALIAS", 5) == 0) + { /* Read one ALIAS part from library: ALIAS 74HC00 74HCT00 7400 74LS37 */ + strtok(Line, " \t\r\n"); + while ( (name = strtok(NULL, " \t\r\n")) != NULL ) + { + wxString st_name = CONV_FROM_UTF8(name); + if( WildCompareString( wildmask, st_name, FALSE) ) + { + nbitems ++; + if ( ! FindList.IsEmpty() ) FindList += wxT("\n"); + FindList << _("Found ") << CONV_FROM_UTF8(name) + << _(" in lib ") << FullFileName; + } + } + } + } + fclose(file); + FullFileName = wxFindNextFile(); + } + + return nbitems; +} + diff --git a/eeschema/general.h b/eeschema/general.h new file mode 100644 index 0000000000..0dd9bb2987 --- /dev/null +++ b/eeschema/general.h @@ -0,0 +1,266 @@ + /***************************************/ + /* GENERAL.H : declarations communes */ + /***************************************/ + +#ifndef eda_global +#define eda_global extern +#endif + +#define us unsigned short +#define uc unsigned char +#define ul unsigned long + +/* Entete des fichiers schematique */ +#define EESCHEMA_VERSION 1 + +#define SCHEMATIC_HEAD_STRING "Schematic File Version" +#define EESCHEMA_FILE_STAMP "EESchema" +#define NULL_STRING "_NONAME_" + +#define MAX_PIN_INFO 10 + +#define TXTMARGE 10 /* Decalage (en 1/1000") des textes places + sur fils ( labels, num pins ) */ + +#define HIGHLIGHT_COLOR WHITE + +/* Flags used in editing commnands (EDA_BaseStruct, .Flags )*/ +#define IS_CHANGED 1 +#define IS_LINKED 2 +#define IS_MOVED 4 +#define IS_NEW 8 +#define IS_DELETED 0x10 +#define IS_RESIZED 0x20 +#define IN_EDIT 0x40 +#define IS_WIRE_IMAGE 0x100 +#define STARTPOINT 0x200 +#define ENDPOINT 0x400 +#define SELECTED 0x800 + +/* Used for EDA_BaseStruct, .m_Select member */ +#define IS_SELECTED 1 + +#define TEXT_NO_VISIBLE 1 + + +//#define GR_DEFAULT_DRAWMODE GR_COPY +#define GR_DEFAULT_DRAWMODE GR_COPY + + +/* Message de presentation */ +extern wxString g_Main_Title; +eda_global wxString g_DefaultSchematicFileName +#ifdef MAIN + (wxT("noname.sch")) +#endif +; + +/* Masque de recherche pour localisation d'objets a editer */ +#define LIBITEM 1 +#define WIREITEM 2 +#define BUSITEM 4 +#define RACCORDITEM 4 +#define JUNCTIONITEM 0x10 +#define DRAWITEM 0x20 +#define TEXTITEM 0x40 +#define LABELITEM 0x80 +#define SHEETITEM 0x100 +#define MARKERITEM 0x200 +#define NOCONNECTITEM 0x400 +#define SEARCH_PINITEM 0x800 +#define SHEETLABELITEM 0x1000 +#define FIELDCMPITEM 0x2000 +#define EXCLUDE_WIRE_BUS_ENDPOINTS 0x4000 +#define WIRE_BUS_ENDPOINTS_ONLY 0x8000 + +#define SEARCHALL LIBITEM|WIREITEM|BUSITEM|RACCORDITEM|JUNCTIONITEM\ + |DRAWITEM|TEXTITEM|LABELITEM|SHEETITEM|MARKERITEM\ + |NOCONNECTITEM|SEARCH_PINITEM|SHEETLABELITEM + +/* Numero des couches de travail */ +typedef enum { + LAYER_WIRE, + LAYER_BUS, + LAYER_JUNCTION, + LAYER_LOCLABEL, + LAYER_GLOBLABEL, + LAYER_PINFUN, + LAYER_PINNUM, + LAYER_PINNAM, + LAYER_REFERENCEPART, + LAYER_VALUEPART, + LAYER_FIELDS, + LAYER_DEVICE, + LAYER_NOTES, + LAYER_NETNAM, + LAYER_PIN, + LAYER_SHEET, + LAYER_SHEETNAME, + LAYER_SHEETFILENAME, + LAYER_SHEETLABEL, + LAYER_NOCONNECT, + LAYER_ERC_WARN, + LAYER_ERC_ERR, + LAYER_DEVICE_BACKGROUND, + + MAX_LAYER /* Nombre de couches */ + } LayerNumber; + +typedef enum { + FILE_SAVE_AS, + FILE_SAVE_NEW +} FileSaveType; + +eda_global wxSize g_GridList[] +#ifdef MAIN + = { + wxSize(50,50), wxSize(20,20), wxSize(10,10), + wxSize(-1,-1), wxSize(0,0) +} +#endif +; + + +/* variables generales */ +eda_global wxArrayString g_LibName_List; // library list (short filenames) to load +eda_global LibraryStruct *g_LibraryList; // All part libs are saved here. + +eda_global int g_NetFormat; /* Numero de reference du type de netliste */ +eda_global int g_OptNetListUseNames; /* TRUE pour utiliser les noms de net plutot que + les numeros (netlist PSPICE seulement) */ +eda_global int g_BGColor; /* couleur fond d'ecran (normalement blanc) */ +eda_global EDA_BaseStruct * g_ItemToRepeat; /* pointeur sur la derniere structure + dessinee pouvant etre dupliquee par la commande + Repeat ( NULL si aucune struct existe ) */ +eda_global wxSize g_RepeatStep; +eda_global int g_RepeatDeltaLabel; + +eda_global EDA_BaseStruct * g_ItemToUndoCopy; /* copy of last modified schematic item + before it is modified (used for undo managing to restore old values ) */ + +eda_global bool g_LastSearchIsMarker; // True if last seach is a marker serach + // False for a schematic item search + // Used for hotkey next search + +/* Block operation (copy, paste) */ +eda_global EDA_BaseStruct * g_BlockSaveDataList; // List of items to paste (Created by Block Save) + +// Gestion d'options +eda_global int g_ShowAllPins; +eda_global int g_ShowGrid; // Bool: display grid +#ifdef MAIN +wxSize g_User_Grid(50,50); +int g_HVLines = 1; // Bool: force H or V directions (Wires, Bus ..) +#else +extern wxSize g_User_Grid; +extern int g_HVLines; +#endif + +eda_global int g_PlotPSColorOpt; // True = plot postcript color (see plotps.cpp) + + +// Gestion de diverses variables, options... devant etre mémorisées mais +// Remises a 0 lors d'un rechargement de projetc +struct EESchemaVariables +{ + int NbErrorErc; + int NbWarningErc; +}; + +eda_global struct EESchemaVariables g_EESchemaVar; +/* Variable fonction print */ +eda_global int g_PrintFillMask; /* pour les options "FILL", + l'option reelle est m_Fill & ~PrintFillMask */ + +/* Variables eda_globales pour Libview */ +eda_global wxString g_CurrentViewLibraryName; /* nom de la librairie en cours d'examen */ +eda_global wxString g_CurrentViewComponentName; /* nom du le composant en cours d'examen */ +eda_global int g_ViewConvert; /* Vue normal / convert */ +eda_global int g_ViewUnit; /* unité a afficher (A, B ..) */ + +/* Variables eda_globales pour LibEdit */ +eda_global int g_LastTextSize +#ifdef MAIN += DEFAULT_SIZE_TEXT +#endif +; +eda_global int g_LastTextOrient +#ifdef MAIN += TEXT_ORIENT_HORIZ +#endif +; + +eda_global bool g_FlDrawSpecificUnit +#ifdef MAIN += FALSE +#endif +; +eda_global bool g_FlDrawSpecificConvert +#ifdef MAIN += TRUE +#endif +; + + /********************************************************/ + /* Description des structures des parametres principaux */ + /********************************************************/ + + /* Gestion des trace sur table tracante */ + +eda_global int g_PlotFormat; /* flag = TYPE_HPGL, TYPE_PS... */ +eda_global int g_PlotMargin; /* Marge pour traces du cartouche */ +eda_global float g_PlotScaleX, g_PlotScaleY; /* coeff d'echelle de trace en unites table tracante */ + + + +/* For HPGL plotting: Pen caract : */ +struct HPGL_Pen_Descr_Struct +{ + int m_Pen_Num; /* num de plume a charger */ + int m_Pen_Speed; /* vitesse en cm/s */ + int m_Pen_Diam; /* Pen diameter in mils */ +}; +eda_global HPGL_Pen_Descr_Struct g_HPGL_Pen_Descr; + +/* Ecrans usuels */ +eda_global SCH_SCREEN * ScreenSch; +eda_global SCH_SCREEN * ScreenLib; + + /*************************************/ + /* Gestion de recherche des elements */ + /*************************************/ + +/* valeur de flag indicant si le pointeur de reference pour une localisation +est le curseur sur grille ou le curseur a deplacement fin hors grille */ +#define CURSEUR_ON_GRILLE 0 +#define CURSEUR_OFF_GRILLE 1 + +/* Gestion des librairies schematiques */ +eda_global wxString g_NetNameBuffer; + +#ifdef MAIN +wxString g_NetCmpExtBuffer( wxT(".cmp") ); +wxString g_SymbolExtBuffer( wxT(".sym") ); +wxString g_NetExtBuffer( wxT(".net") ); +wxString g_SchExtBuffer( wxT(".sch") ); +wxString g_LibExtBuffer( wxT(".lib") ); +#else +eda_global wxString g_NetCmpExtBuffer; +eda_global wxString g_SymbolExtBuffer; +eda_global wxString g_NetExtBuffer; +eda_global wxString g_SchExtBuffer; +eda_global wxString g_LibExtBuffer; +#endif + +eda_global wxString g_SimulatorCommandLine; // ligne de commande pour l'appel au simulateur (gnucap, spice..) +eda_global wxString g_NetListerCommandLine; // ligne de commande pour l'appel au simulateur (gnucap, spice..) + +eda_global LayerStruct g_LayerDescr; /* couleurs des couches */ + +eda_global bool g_EditPinByPinIsOn /* bool: TRUE si edition des pins pin a pin au lieu */ +#ifdef MAIN /* de l'edition simultanée des pins de meme coordonnées */ + = FALSE +#endif +; + + diff --git a/eeschema/genliste.cpp b/eeschema/genliste.cpp new file mode 100644 index 0000000000..e2472375a8 --- /dev/null +++ b/eeschema/genliste.cpp @@ -0,0 +1,730 @@ + /***********************************************************/ + /* genliste.cpp */ + /* Module de generation de listing de composants, labels.. */ + /***********************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "netlist.h" + +#include "protos.h" + +/* Structures pour memo et liste des elements */ +typedef struct ListLabel +{ + int m_StructType; + void * m_Label; + int m_SheetNumber; +} ListLabel; + + +/* fonctions locales */ +static void GenereListeOfItems(wxWindow * frame, const wxString & FullFileName); +static int GenListeGLabels( ListLabel * List ); +static int ListTriComposantByRef(EDA_SchComponentStruct **Objet1, + EDA_SchComponentStruct **Objet2); +static int ListTriComposantByVal(EDA_SchComponentStruct **Objet1, + EDA_SchComponentStruct **Objet2); +static int ListTriGLabelBySheet(ListLabel *Objet1, ListLabel *Objet2); +static int ListTriGLabelByVal(ListLabel *Objet1, ListLabel *Objet2); +static void DeleteSubCmp( EDA_BaseStruct ** List , int NbItems); + +static int PrintListeCmpByRef( FILE *f, EDA_BaseStruct **List, int NbItems); +static int PrintListeCmpByVal( FILE *f, EDA_BaseStruct **List, int NbItems); + +static int PrintListeGLabel( FILE *f, ListLabel *List, int NbItems); + +// Constantes: +#define LISTCMP_BY_REF 1 +#define LISTCMP_BY_VAL 2 +#define LIST_SUBCMP 4 +#define LIST_HPINS_BY_NAME 8 +#define LIST_HPINS_BY_SHEET 0x10 + +/* Variable locales */ +int ItemsToList = LISTCMP_BY_REF | LISTCMP_BY_VAL; + +enum id_tools { + ID_TOOLS_GEN_LIST = 1500, + ID_EXIT_TOOLS, + ID_SET_FILENAME_LIST +}; + +/* Classe de la frame de gestion de l'annotation */ +class WinEDA_GenCmpListFrame: public wxDialog +{ +public: + WinEDA_DrawFrame * m_Parent; + + wxCheckBox * m_ListCmpbyRefItems; + wxCheckBox * m_ListCmpbyValItems; + wxCheckBox * m_ListSubCmpItems; + wxCheckBox * m_GenListLabelsbyVal; + wxCheckBox * m_GenListLabelsbySheet; + wxString m_LibArchiveFileName; + wxString m_ListFileName; + + // Constructor and destructor + WinEDA_GenCmpListFrame(WinEDA_DrawFrame *parent, wxPoint& pos); + ~WinEDA_GenCmpListFrame(void) {}; + + void GenList(wxCommandEvent& event); + void GenListUpdateOpt(void); + void ToolsExit(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(WinEDA_GenCmpListFrame, wxDialog) + EVT_BUTTON(ID_EXIT_TOOLS, WinEDA_GenCmpListFrame::ToolsExit) + EVT_BUTTON(ID_TOOLS_GEN_LIST, WinEDA_GenCmpListFrame::GenList) +END_EVENT_TABLE() + + +/***************************************************************/ +void InstallToolsFrame(WinEDA_DrawFrame *parent, wxPoint & pos) +/***************************************************************/ +{ + WinEDA_GenCmpListFrame * frame = new WinEDA_GenCmpListFrame(parent, pos); + frame->ShowModal(); frame->Destroy(); +} + + +/*****************************************************************************/ +WinEDA_GenCmpListFrame::WinEDA_GenCmpListFrame(WinEDA_DrawFrame *parent, + wxPoint& framepos): + wxDialog(parent, -1, _("List of Material"), framepos, wxSize(360, 200), + DIALOG_STYLE) +/*****************************************************************************/ +{ +wxPoint pos; + + m_Parent = parent; + SetFont(*g_DialogFont); + + if ( (framepos.x == -1) && (framepos.x == -1) ) Centre(); + + /* Calcul du nom du fichier d'archivage */ + m_LibArchiveFileName = MakeFileName(wxEmptyString,ScreenSch->m_FileName,wxEmptyString); + /* mise a jour extension */ + ChangeFileNameExt(m_LibArchiveFileName, g_LibExtBuffer); + + /* Calcul du nom du fichier de listage */ + m_ListFileName = MakeFileName(wxEmptyString,ScreenSch->m_FileName,wxEmptyString); + /* mise a jour extension */ + ChangeFileNameExt(m_ListFileName, wxT(".lst")); + + pos.x = 5; pos.y = 15; + new wxStaticBox(this, -1,_(" List items : "), pos, wxSize(230, 120)); + + pos.x = 10; pos.y += 22; + m_ListCmpbyRefItems = new wxCheckBox(this,-1, _("Components by Reference"), pos); + if ( ItemsToList & LISTCMP_BY_REF ) m_ListCmpbyRefItems->SetValue(TRUE); + pos.y += 17; + m_ListCmpbyValItems = new wxCheckBox(this,-1, _("Components by Value"), pos); + if ( ItemsToList & LISTCMP_BY_VAL ) m_ListCmpbyValItems->SetValue(TRUE); + pos.y += 17; + m_ListSubCmpItems = new wxCheckBox(this,-1, _("Sub Components (i.e U2A, U2B..)"), pos); + if ( ItemsToList & LIST_SUBCMP ) m_ListSubCmpItems->SetValue(TRUE); + pos.y += 17; + m_GenListLabelsbyVal = new wxCheckBox(this,-1, _("Hierachy Pins by name"), pos); + if ( ItemsToList & LIST_HPINS_BY_NAME ) m_GenListLabelsbyVal->SetValue(TRUE); + pos.y += 17; + m_GenListLabelsbySheet = new wxCheckBox(this,-1, _("Hierachy Pins by Sheets"), pos); + if ( ItemsToList & LIST_HPINS_BY_SHEET ) m_GenListLabelsbySheet->SetValue(TRUE); + + /* Creation des boutons de commande */ + pos.x = 260; pos.y = 40; + wxButton * Button = new wxButton(this, ID_TOOLS_GEN_LIST, + _("&Create List"), pos); + Button->SetForegroundColour(*wxRED); + + pos.y += Button->GetSize().y + 5; + Button = new wxButton(this, ID_EXIT_TOOLS, + _("&Exit"), pos); + Button->SetForegroundColour(*wxBLUE); +} + +// Fonctions de positionnement des variables d'option +void WinEDA_GenCmpListFrame::GenListUpdateOpt(void) +{ + ItemsToList = 0; + if ( m_ListCmpbyRefItems->GetValue() ) ItemsToList |= LISTCMP_BY_REF; + if ( m_ListCmpbyValItems->GetValue() ) ItemsToList |= LISTCMP_BY_VAL; + if ( m_ListSubCmpItems->GetValue() ) ItemsToList |= LIST_SUBCMP; + if ( m_GenListLabelsbyVal->GetValue() ) ItemsToList |= LIST_HPINS_BY_NAME; + if ( m_GenListLabelsbySheet->GetValue() ) ItemsToList |= LIST_HPINS_BY_SHEET; +} + +void WinEDA_GenCmpListFrame::GenList(wxCommandEvent& event) +{ +#define EXT_LIST wxT(".lst") +wxString mask, filename; + + GenListUpdateOpt(); + + mask = wxT("*"); mask += EXT_LIST; + filename = EDA_FileSelector(_("List of material:"), + wxEmptyString, /* Chemin par defaut (ici dir courante) */ + m_ListFileName, /* nom fichier par defaut, et resultat */ + EXT_LIST, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxSAVE, + TRUE + ); + if ( filename.IsEmpty() ) return; + else m_ListFileName = filename; + + GenereListeOfItems(this, m_ListFileName); + Close(); +} + +void WinEDA_GenCmpListFrame::ToolsExit(wxCommandEvent& event) +{ + GenListUpdateOpt(); + Close(); +} + + + +/***************************************************************************/ +static void GenereListeOfItems(wxWindow * frame, const wxString & FullFileName) +/***************************************************************************/ +/* + Routine principale pour la creation des listings ( composants et/ou labels + globaux et "sheet labels" ) +*/ +{ +FILE *f; +EDA_BaseStruct ** List; +ListLabel * ListOfLabels; +int NbItems; +char Line[1024]; +wxString msg; + + /* Creation de la liste des elements */ + if ((f = wxFopen(FullFileName, wxT("wt"))) == NULL) + { + msg = _("Failed to open file "); msg << FullFileName; + DisplayError(frame, msg); + return; + } + + NbItems = GenListeCmp(NULL ); + if ( NbItems ) + { + List = (EDA_BaseStruct **) + MyZMalloc( NbItems * sizeof(EDA_BaseStruct **) ); + if (List == NULL ) + { + fclose(f); return; + } + + GenListeCmp(List); + + /* generation du fichier listing */ + DateAndTime(Line); + fprintf( f, "%s >> Creation date: %s\n", CONV_TO_UTF8(Main_Title), Line ); + + /* Tri et impression de la liste des composants */ + + qsort( List, NbItems, sizeof( EDA_BaseStruct * ), + (int(*)(const void*, const void*))ListTriComposantByRef); + + if( (ItemsToList & LIST_SUBCMP) == 0 ) DeleteSubCmp(List, NbItems); + + if( (ItemsToList & LISTCMP_BY_REF) ) + { + PrintListeCmpByRef(f, List, NbItems); + } + + if( (ItemsToList & LISTCMP_BY_VAL) ) + { + qsort( List, NbItems, sizeof( EDA_BaseStruct * ), + (int(*)(const void*, const void*))ListTriComposantByVal); + PrintListeCmpByVal(f, List, NbItems); + } + MyFree( List ); + } + + /***************************************/ + /* Generation liste des Labels globaux */ + /***************************************/ + + NbItems = GenListeGLabels( NULL ); + if ( NbItems ) + { + ListOfLabels = (ListLabel *) MyZMalloc( NbItems * sizeof(ListLabel) ); + if (ListOfLabels == NULL ) + { + fclose(f); return; + } + + GenListeGLabels(ListOfLabels); + + /* Tri de la liste */ + if( (ItemsToList & LIST_HPINS_BY_SHEET) ) + { + qsort( ListOfLabels, NbItems, sizeof( ListLabel ), + (int(*)(const void*, const void*))ListTriGLabelBySheet); + + msg = _("\n#Glob labels ( order = Sheet Number )\n"); + fprintf( f, "%s", CONV_TO_UTF8(msg)); + PrintListeGLabel(f, ListOfLabels, NbItems); + } + + if( (ItemsToList & LIST_HPINS_BY_NAME) ) + { + qsort( ListOfLabels, NbItems, sizeof( ListLabel ), + (int(*)(const void*, const void*))ListTriGLabelByVal); + + msg = _("\n#Glob labels ( order = Alphab. )\n"); + fprintf( f, "%s", CONV_TO_UTF8(msg)); + PrintListeGLabel(f, ListOfLabels, NbItems); + } + MyFree( ListOfLabels ); + } + + msg = _("\n#End List\n"); + fprintf( f, "%s", CONV_TO_UTF8(msg)); + fclose(f); +} + + + +/****************************************/ +int GenListeCmp( EDA_BaseStruct ** List ) +/****************************************/ +/* Routine de generation de la liste des elements utiles du dessin + Si List == NULL: comptage des elements + Sinon remplissage de la liste + Initialise "FlagControlMulti" a SheetNumber pour la sortie des listes + et m_Father comme pointeur sur la sheet d'appartenance +*/ +{ +int ii = 0; +EDA_BaseStruct *DrawList; +EDA_SchComponentStruct *DrawLibItem; +BASE_SCREEN * screen = ScreenSch; + + for( ; screen != NULL ; screen = (BASE_SCREEN*)screen->Pnext ) + { + DrawList = screen->EEDrawList; + while ( DrawList ) + { + switch( DrawList->m_StructType ) + { + + case DRAW_LIB_ITEM_STRUCT_TYPE : + ii++; + DrawLibItem = (EDA_SchComponentStruct *) DrawList; + DrawLibItem->m_FlagControlMulti = screen->m_SheetNumber; + DrawLibItem->m_Parent = screen; + if( List ) + { + *List = DrawList; List++; + } + break; + + + default: break; + } + DrawList = DrawList->Pnext; + } + } + return ( ii ); +} + +/*********************************************/ +static int GenListeGLabels( ListLabel * List ) +/*********************************************/ +/* Count the Glabels, or fill the list Listwith Glabel pointers + If List == NULL: Item count only + Else fill list of Glabels +*/ +{ +int ii = 0; +EDA_BaseStruct *DrawList; +DrawSheetLabelStruct *SheetLabel; +BASE_SCREEN * screen = ScreenSch; + + for( ; screen != NULL ; screen = (BASE_SCREEN*)screen->Pnext ) + { + DrawList = screen->EEDrawList; + while ( DrawList ) + { + switch( DrawList->m_StructType ) + { + case DRAW_GLOBAL_LABEL_STRUCT_TYPE : + if( List ) + { + List->m_StructType = DRAW_TEXT_STRUCT_TYPE; + List->m_SheetNumber = screen->m_SheetNumber; + List->m_Label = DrawList; List++; + } + ii++; + break; + + case DRAW_SHEET_STRUCT_TYPE : + { + #define Sheet ((DrawSheetStruct * ) DrawList) + SheetLabel= Sheet->m_Label; + while( SheetLabel != NULL ) + { + if ( List ) + { + List->m_StructType = DRAW_SHEETLABEL_STRUCT_TYPE; + List->m_SheetNumber = screen->m_SheetNumber; + List->m_Label = SheetLabel; + List++; + } + ii++; + SheetLabel = (DrawSheetLabelStruct*)(SheetLabel->Pnext); + } + break; + } + + default: break; + } + DrawList = DrawList->Pnext; + } + } + return ( ii ); +} + +/**********************************************************/ +static int ListTriComposantByVal(EDA_SchComponentStruct **Objet1, + EDA_SchComponentStruct **Objet2) +/**********************************************************/ + /* Routine de comparaison pour le tri du Tableau par qsort() + Les composants sont tries + par valeur + si meme valeur: par reference + si meme valeur: par numero d'unite + +*/ +{ +int ii; +const wxString * Text1, *Text2; + + if( (*Objet1 == NULL) && (*Objet2 == NULL ) ) return(0); + if( *Objet1 == NULL) return(-1); + if( *Objet2 == NULL) return(1); + + Text1 = &(*Objet1)->m_Field[VALUE].m_Text; + Text2 = &(*Objet2)->m_Field[VALUE].m_Text; + ii = Text1->CmpNoCase(*Text2); + + if( ii == 0 ) + { + Text1 = &(*Objet1)->m_Field[REFERENCE].m_Text; + Text2 = &(*Objet2)->m_Field[REFERENCE].m_Text; + ii = Text1->CmpNoCase(*Text2); + } + + if ( ii == 0 ) + { + ii = (*Objet1)->m_Multi - (*Objet2)->m_Multi; + } + + return(ii); +} + +/**********************************************************/ +static int ListTriComposantByRef(EDA_SchComponentStruct **Objet1, + EDA_SchComponentStruct **Objet2) +/**********************************************************/ + /* Routine de comparaison pour le tri du Tableau par qsort() + Les composants sont tries + par reference + si meme referenece: par valeur + si meme valeur: par numero d'unite + +*/ +{ +int ii; +const wxString * Text1, *Text2; + + if( (*Objet1 == NULL) && (*Objet2 == NULL ) ) return(0); + if( *Objet1 == NULL) return(-1); + if( *Objet2 == NULL) return(1); + + Text1 = &(*Objet1)->m_Field[REFERENCE].m_Text; + Text2 = &(*Objet2)->m_Field[REFERENCE].m_Text; + ii = Text1->CmpNoCase(*Text2); + + if( ii == 0 ) + { + Text1 = &(*Objet1)->m_Field[VALUE].m_Text; + Text2 = &(*Objet2)->m_Field[VALUE].m_Text; + ii = Text1->CmpNoCase(*Text2); + } + + if ( ii == 0 ) + { + ii = (*Objet1)->m_Multi - (*Objet2)->m_Multi; + } + + return(ii); +} + +/******************************************************************/ +static int ListTriGLabelByVal(ListLabel *Objet1, ListLabel *Objet2) +/*******************************************************************/ +/* Routine de comparaison pour le tri du Tableau par qsort() + Les labels sont tries + par comparaison ascii + si meme valeur: par numero de sheet + +*/ +{ +int ii; +const wxString * Text1, *Text2; + + if( Objet1->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE ) + Text1 = &((DrawSheetLabelStruct *)Objet1->m_Label)->m_Text; + else + Text1 = &((DrawTextStruct *)Objet1->m_Label)->m_Text; + + if( Objet2->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE ) + Text2 = &((DrawSheetLabelStruct *)Objet2->m_Label)->m_Text; + else + Text2 = &((DrawTextStruct *)Objet2->m_Label)->m_Text; + ii = Text1->CmpNoCase(*Text2); + + if ( ii == 0 ) + { + ii = Objet1->m_SheetNumber - Objet2->m_SheetNumber; + } + + return(ii); +} + +/*******************************************************************/ +static int ListTriGLabelBySheet(ListLabel *Objet1, ListLabel *Objet2) +/*******************************************************************/ +/* Routine de comparaison pour le tri du Tableau par qsort() + Les labels sont tries + par sheet number + si meme valeur, par ordre alphabetique + +*/ +{ +int ii; +const wxString * Text1, *Text2; + + ii = Objet1->m_SheetNumber - Objet2->m_SheetNumber; + + if ( ii == 0 ) + { + if( Objet1->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE ) + Text1 = &((DrawSheetLabelStruct *)Objet1->m_Label)->m_Text; + else + Text1 = &((DrawTextStruct *)Objet1->m_Label)->m_Text; + + if( Objet2->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE ) + Text2 = &((DrawSheetLabelStruct *)Objet2->m_Label)->m_Text; + else + Text2 = &((DrawTextStruct *)Objet2->m_Label)->m_Text; + ii = Text1->CmpNoCase(*Text2); + } + + return(ii); +} + + + +/**************************************************************/ +static void DeleteSubCmp( EDA_BaseStruct ** List, int NbItems ) +/**************************************************************/ +/* Supprime les sous-composants, c'est a dire les descriptions redonnantes des +boitiers multiples + La liste des composant doit etre triee par reference et par num d'unite +*/ +{ +int ii; +EDA_SchComponentStruct * LibItem; +const wxString * OldName = NULL; + + for( ii = 0; ii < NbItems ; ii++ ) + { + LibItem = (EDA_SchComponentStruct *) List[ii]; + if ( LibItem == NULL ) continue; + if( OldName ) + { + if ( OldName->CmpNoCase( LibItem->m_Field[REFERENCE].m_Text ) == 0 ) + { + List[ii] = NULL; + } + } + OldName = &LibItem->m_Field[REFERENCE].m_Text; + } +} + + +/**********************************************************************/ +int PrintListeCmpByRef( FILE * f, EDA_BaseStruct ** List, int NbItems ) +/**********************************************************************/ +/* Impression de la liste des composants tries par reference +*/ +{ +int ii, Multi, Unit; +EDA_BaseStruct *DrawList; +EDA_SchComponentStruct *DrawLibItem; +EDA_LibComponentStruct *Entry; +char NameCmp[80]; +wxString msg; + + msg = _("\n#Cmp ( order = Reference )"); + if ( (ItemsToList & LIST_SUBCMP) ) msg << _(" (with SubCmp)"); + fprintf( f, "%s\n", CONV_TO_UTF8(msg)); + + for ( ii = 0; ii < NbItems; ii++ ) + { + DrawList = List[ii]; + + if( DrawList == NULL ) continue; + if( DrawList->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) continue; + + DrawLibItem = (EDA_SchComponentStruct *) DrawList; + if( DrawLibItem->m_Field[REFERENCE].m_Text[0] == '#' ) continue; + + Multi = 0; Unit = ' '; + Entry = FindLibPart(DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if( Entry ) Multi = Entry->m_UnitCount; + if( (Multi > 1 ) && ( ItemsToList & LIST_SUBCMP ) ) + Unit = DrawLibItem->m_Multi + 'A' - 1; + + sprintf( NameCmp,"%s%c", CONV_TO_UTF8(DrawLibItem->m_Field[REFERENCE].m_Text), + Unit); + fprintf(f, "| %-10.10s %-12.12s", + NameCmp, + CONV_TO_UTF8(DrawLibItem->m_Field[VALUE].m_Text)); + + if ( (ItemsToList & LIST_SUBCMP) ) + { + BASE_SCREEN * screen = (BASE_SCREEN *)(DrawLibItem->m_Parent); + wxString sheetname; + if( screen->m_Parent ) + sheetname = ((DrawSheetStruct*)screen->m_Parent)->m_Field[VALUE].m_Text.GetData(); + else sheetname = _("Root"); + fprintf(f, " (Sheet %.2d: \"%s\")", DrawLibItem->m_FlagControlMulti, + CONV_TO_UTF8(sheetname)); + } + + fprintf(f,"\n"); + } + msg = _("#End Cmp\n"); + fprintf(f, CONV_TO_UTF8(msg)); + return(0); +} + +/***********************************************************************/ +int PrintListeCmpByVal( FILE * f, EDA_BaseStruct ** List, int NbItems ) +/**********************************************************************/ +{ +int ii, Multi; +wxChar Unit; +EDA_BaseStruct *DrawList; +EDA_SchComponentStruct *DrawLibItem; +EDA_LibComponentStruct *Entry; +wxString msg; + + msg = _("\n#Cmp ( order = Value )"); + if ( (ItemsToList & LIST_SUBCMP) ) msg << _(" (with SubCmp)"); + msg << wxT("\n"); + fprintf(f, CONV_TO_UTF8(msg)); + + for ( ii = 0; ii < NbItems; ii++ ) + { + DrawList = List[ii]; + + if( DrawList == NULL ) continue; + if( DrawList->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) continue; + + DrawLibItem = (EDA_SchComponentStruct *) DrawList; + if( DrawLibItem->m_Field[REFERENCE].m_Text[0] == '#' ) continue; + + Multi = 0; Unit = ' '; + Entry = FindLibPart(DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if( Entry ) Multi = Entry->m_UnitCount; + if( (Multi > 1 ) && ( ItemsToList & LIST_SUBCMP ) ) + Unit = DrawLibItem->m_Multi + 'A' - 1; + msg = DrawLibItem->m_Field[REFERENCE].m_Text; + msg.Append(Unit); + + fprintf(f, "| %-12.12s %-10.10s", + CONV_TO_UTF8(DrawLibItem->m_Field[VALUE].m_Text), + CONV_TO_UTF8(msg) ); + if ( (ItemsToList & LIST_SUBCMP) ) + { + fprintf(f, " (Sheet %.2d)", DrawLibItem->m_FlagControlMulti); + } + + fprintf(f,"\n"); + } + msg = _("#End Cmp\n"); + fprintf(f, CONV_TO_UTF8(msg)); + return(0); +} + + +/******************************************************************/ +static int PrintListeGLabel( FILE *f, ListLabel *List, int NbItems) +/******************************************************************/ +{ +int ii, jj; +DrawGlobalLabelStruct *DrawTextItem; +DrawSheetLabelStruct * DrawSheetLabel; +ListLabel * LabelItem; +wxString msg; + + for ( ii = 0; ii < NbItems; ii++ ) + { + LabelItem = & List[ii]; + + switch( LabelItem->m_StructType ) + { + case DRAW_GLOBAL_LABEL_STRUCT_TYPE : + DrawTextItem = (DrawGlobalLabelStruct *)(LabelItem->m_Label); + msg.Printf( + _("> %-28.28s Global (Sheet %.2d) pos: %3.3f, %3.3f\n"), + DrawTextItem->m_Text.GetData(), + LabelItem->m_SheetNumber, + (float)DrawTextItem->m_Pos.x / 1000, + (float)DrawTextItem->m_Pos.y / 1000); + + fprintf(f, CONV_TO_UTF8(msg)); + break; + + case DRAW_SHEETLABEL_STRUCT_TYPE : + { + DrawSheetLabel = (DrawSheetLabelStruct *) LabelItem->m_Label; + jj = DrawSheetLabel->m_Shape; + if ( jj < 0 ) jj = NET_TMAX; if ( jj > NET_TMAX ) jj = 4; + wxString labtype = CONV_FROM_UTF8(SheetLabelType[jj]); + msg.Printf( + _("> %-28.28s Sheet %-7.7s (Sheet %.2d) pos: %3.3f, %3.3f\n"), + DrawSheetLabel->m_Text.GetData(), + labtype.GetData(), + LabelItem->m_SheetNumber, + (float)DrawSheetLabel->m_Pos.x / 1000, + (float)DrawSheetLabel->m_Pos.y / 1000); + fprintf(f, CONV_TO_UTF8(msg)); + } + break; + + default: break; + } + } + msg = _("#End labels\n"); + fprintf(f, CONV_TO_UTF8(msg)); + return(0); +} + diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp new file mode 100644 index 0000000000..e712387aab --- /dev/null +++ b/eeschema/getpart.cpp @@ -0,0 +1,467 @@ +/*************************************************/ +/* Module to handle Get & Place Library Part */ +/*************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" + +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + + +/* Routines Locales */ +static void ShowWhileMoving(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void ExitPlaceCmp(WinEDA_DrawPanel * Panel, wxDC * DC ); + +/* Variables locales */ +static int OldTransMat[2][2]; +static wxPoint OldPos; + + + +/*******************************************************/ +wxString SelectFromLibBrowser(WinEDA_DrawFrame *parent) +/*******************************************************/ +{ +wxString name; +WinEDA_ViewlibFrame * Viewer; +wxSemaphore semaphore(0,1); + + Viewer = parent->m_Parent->ViewlibFrame; + /* Close the current Lib browser, if open, and open a new one, in "modal" mode */ + if ( Viewer ) Viewer->Destroy(); + + Viewer = parent->m_Parent->ViewlibFrame = new + WinEDA_ViewlibFrame(parent->m_Parent->SchematicFrame, + parent->m_Parent, NULL, & semaphore ); + Viewer->AdjustScrollBars(); + + // Show the library viewer frame until it is closed + while ( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event + { + wxYield(); + wxMilliSleep(50); + } + name = g_CurrentViewComponentName; + return name; +} + + + +/**************************************************************************/ +EDA_SchComponentStruct * WinEDA_SchematicFrame::Load_Component(wxDC * DC, + const wxString & libname, wxArrayString & HistoryList, + bool UseLibBrowser) +/**************************************************************************/ +/* load from a library and place a component + if libname != "", search in lib "libname" + else search in all loaded libs +*/ +{ +int ii, CmpCount = 0; +LibDrawField * Field; +EDA_LibComponentStruct *Entry = NULL; +EDA_SchComponentStruct * DrawLibItem = NULL; +LibraryStruct *Library = NULL; +wxString Name, keys, msg; +bool AllowWildSeach = TRUE; + + g_ItemToRepeat = NULL; + DrawPanel->m_IgnoreMouseEvents = TRUE; + + if ( ! libname.IsEmpty() ) + { + Library = g_LibraryList; + while (Library) + { + if( Library->m_Name == libname ) + { + CmpCount = Library->m_NumOfParts; + break; + } + Library = Library->m_Pnext; + } + } + else + { + LibraryStruct * lib = g_LibraryList; + while (lib) + { + CmpCount += lib->m_NumOfParts; + lib = lib->m_Pnext; + } + } + + /* Ask for a component name or key words */ + msg.Printf (_("component selection (%d items loaded):"), CmpCount); + + Name = GetComponentName(this, HistoryList, msg, + UseLibBrowser ? SelectFromLibBrowser : NULL); + Name.MakeUpper(); + if( Name.IsEmpty() ) + { + DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->MouseToCursorSchema(); + return NULL; /* annulation de commande */ + } + + if( Name.GetChar(0) == '=' ) + { + AllowWildSeach = FALSE; + keys = Name.AfterFirst('='); + if( DataBaseGetName(this, keys, Name) == 0 ) + { + DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->MouseToCursorSchema(); + return NULL; + } + } + + else if( Name == wxT("*") ) + { + AllowWildSeach = FALSE; + if( GetNameOfPartToLoad(this, Library, Name) == 0 ) + { + DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->MouseToCursorSchema(); + return NULL; + } + } + + else if( Name.Contains( wxT("?")) || Name.Contains( wxT("*")) ) + { + AllowWildSeach = FALSE; + if( DataBaseGetName(this, keys, Name) == 0 ) + { + DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->MouseToCursorSchema(); + return NULL; + } + } + + Entry = FindLibPart(Name.GetData(), libname, FIND_ROOT); + if( (Entry == NULL) && AllowWildSeach ) /* Attemp to search with wildcard */ + { + AllowWildSeach = FALSE; + wxString wildname = wxChar('*') + Name + wxChar('*'); + Name = wildname; + if( DataBaseGetName(this, keys, Name) ) + Entry = FindLibPart(Name.GetData(), libname, FIND_ROOT); + if( Entry == NULL) + { + DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->MouseToCursorSchema(); + return NULL; + } + } + + + DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->MouseToCursorSchema(); + if( Entry == NULL) + { + msg = _("Failed to find part ") + Name + _(" in library"); + DisplayError(this, msg, 10); + return NULL; + } + + AddHistoryComponentName(HistoryList, Name); + + DrawPanel->ManageCurseur = ShowWhileMoving ; + DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp; + + DrawLibItem = new EDA_SchComponentStruct(m_CurrentScreen->m_Curseur); + DrawLibItem->m_Multi = 1; /* Selection de l'unite 1 dans le boitier */ + DrawLibItem->m_Convert = 1; + DrawLibItem->m_ChipName = Name; + DrawLibItem->m_TimeStamp = GetTimeStamp(); + DrawLibItem->m_Flags = IS_NEW | IS_MOVED; + + /* Init champ Valeur */ + DrawLibItem->m_Field[VALUE].m_Pos.x = + Entry->m_Name.m_Pos.x + DrawLibItem->m_Pos.x; + DrawLibItem->m_Field[VALUE].m_Pos.y = + Entry->m_Name.m_Pos.y + DrawLibItem->m_Pos.y; + DrawLibItem->m_Field[VALUE].m_Orient = Entry->m_Name.m_Orient; + DrawLibItem->m_Field[VALUE].m_Size = Entry->m_Name.m_Size; + DrawLibItem->m_Field[VALUE].m_Text = DrawLibItem->m_ChipName; + DrawLibItem->m_Field[VALUE].m_Attributs = Entry->m_Name.m_Attributs; + DrawLibItem->m_Field[VALUE].m_HJustify = Entry->m_Name.m_HJustify; + DrawLibItem->m_Field[VALUE].m_VJustify = Entry->m_Name.m_VJustify; + + msg = Entry->m_Prefix.m_Text; + if ( msg.IsEmpty() ) msg = wxT("U"); + msg += wxT("?"); + + /* Init champ Reference */ + DrawLibItem->m_Field[REFERENCE].m_Pos.x = + Entry->m_Prefix.m_Pos.x + DrawLibItem->m_Pos.x; + DrawLibItem->m_Field[REFERENCE].m_Pos.y = + Entry->m_Prefix.m_Pos.y + DrawLibItem->m_Pos.y; + DrawLibItem->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient; + DrawLibItem->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size; + DrawLibItem->m_Field[REFERENCE].m_Text = msg; + DrawLibItem->m_Field[REFERENCE].m_Attributs = Entry->m_Prefix.m_Attributs; + DrawLibItem->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify; + DrawLibItem->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify; + + /* Init des autres champs si predefinis dans la librairie */ + for( Field = Entry->Fields; Field != NULL; Field = (LibDrawField*)Field->Pnext ) + { + if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() ) continue; + ii = Field->m_FieldId; + if( ii < 2 ) continue; + if( ii >= NUMBER_OF_FIELDS ) continue; + DrawLibItem->m_Field[ii].m_Pos.x += Field->m_Pos.x; + DrawLibItem->m_Field[ii].m_Pos.y += Field->m_Pos.y; + DrawLibItem->m_Field[ii].m_Size = Field->m_Size; + DrawLibItem->m_Field[ii].m_Attributs = Field->m_Attributs; + DrawLibItem->m_Field[ii].m_Orient = Field->m_Orient; + DrawLibItem->m_Field[ii].m_Text = Field->m_Text; + DrawLibItem->m_Field[ii].m_Name = Field->m_Name; + DrawLibItem->m_Field[ii].m_HJustify = Field->m_HJustify; + DrawLibItem->m_Field[ii].m_VJustify = Field->m_VJustify; + } + + /* Trace du composant */ + DrawStructsInGhost(DrawPanel, DC, DrawLibItem, 0, 0 ); + MsgPanel->EraseMsgBox(); + DrawLibItem->Display_Infos(this); + + return DrawLibItem; +} + +/**************************************************************************/ +/*** Routine de deplacement du composant. ***/ +/*** Appele par GeneralControle grace a ActiveScreen->ManageCurseur. ***/ +/**************************************************************************/ +static void ShowWhileMoving(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +{ +wxPoint move_vector; + +EDA_SchComponentStruct * DrawLibItem = (EDA_SchComponentStruct * ) + panel->m_Parent->m_CurrentScreen->m_CurrentItem; + + /* Effacement du composant */ + if( erase ) + DrawStructsInGhost(panel, DC, DrawLibItem, 0, 0 ); + + move_vector.x = panel->m_Parent->m_CurrentScreen->m_Curseur.x - DrawLibItem->m_Pos.x; + move_vector.y = panel->m_Parent->m_CurrentScreen->m_Curseur.y - DrawLibItem->m_Pos.y; + MoveOneStruct(DrawLibItem, move_vector); + + DrawStructsInGhost(panel, DC, DrawLibItem, 0, 0 ); +} + +/**************************************************************************/ +void WinEDA_SchematicFrame::CmpRotationMiroir( + EDA_SchComponentStruct * DrawComponent, wxDC * DC, int type_rotate ) +/**************************************************************************/ +/* Routine permettant les rotations et les miroirs d'un composant + Si DC = NULL : pas de redessin +*/ +{ + if ( DrawComponent == NULL ) return; + + /* Efface le trace precedent */ + if ( DC ) + { + DrawPanel->CursorOff(DC); + if ( DrawComponent->m_Flags ) + DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 ); + else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), g_XorMode); + } + + DrawComponent->SetRotationMiroir(type_rotate); + + /* Redessine le composant dans la nouvelle position */ + if ( DC ) + { + if( DrawComponent->m_Flags ) + DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 ); + else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), GR_DEFAULT_DRAWMODE); + DrawPanel->CursorOn(DC); + } + + TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); + GetScreen()->SetModify(); +} + +/************************************************************/ +static void ExitPlaceCmp(WinEDA_DrawPanel * Panel, wxDC * DC ) +/************************************************************/ +/* Routine de sortie de la fonction de placement de composant +*/ +{ + +EDA_SchComponentStruct * DrawLibItem = (EDA_SchComponentStruct * ) + Panel->m_Parent->m_CurrentScreen->m_CurrentItem; + + if ( DrawLibItem->m_Flags & IS_NEW ) /* Nouveau Placement en cours, on l'efface */ + { + DrawStructsInGhost(Panel, DC, DrawLibItem, 0, 0 ); + delete DrawLibItem; + } + + else if ( DrawLibItem ) /* Deplacement ancien composant en cours */ + { + wxPoint move_vector; + DrawStructsInGhost(Panel, DC, DrawLibItem, 0, 0 ); + + move_vector.x = OldPos.x - DrawLibItem->m_Pos.x; + move_vector.y = OldPos.y - DrawLibItem->m_Pos.y; + + MoveOneStruct(DrawLibItem, move_vector); + + memcpy(DrawLibItem->m_Transform, OldTransMat, sizeof(OldTransMat) ); + DrawLibItem->Draw(Panel, DC, wxPoint(0,0), GR_DEFAULT_DRAWMODE); + } + + DrawLibItem->m_Flags = 0; + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + Panel->m_Parent->m_CurrentScreen->m_CurrentItem = NULL; +} + + + +/************************************************************************/ +void WinEDA_SchematicFrame::SelPartUnit(EDA_SchComponentStruct *DrawComponent, + int unit, wxDC * DC) +/************************************************************************/ +/* Selection de l'unite dans les boitiers a multiples Parts */ +{ +int m_UnitCount; +EDA_LibComponentStruct * LibEntry; + + if (DrawComponent == NULL) return; + + LibEntry = FindLibPart(DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if( LibEntry == NULL ) return; + + m_UnitCount = LibEntry->m_UnitCount; + + if( m_UnitCount <= 1 ) return; + + if( DrawComponent->m_Multi == unit ) return; + if ( unit < 1 ) unit = 1; + if ( unit > m_UnitCount ) unit = m_UnitCount; + + /* Efface le trace precedent */ + if ( DrawComponent->m_Flags ) + DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 ); + else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), g_XorMode); + + /* Mise a jour du numero d'unite */ + DrawComponent->m_Multi = unit; + + /* Redessine le composant dans la nouvelle position */ + if( DrawComponent->m_Flags ) + DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 ); + else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), GR_DEFAULT_DRAWMODE); + + TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); + GetScreen()->SetModify(); +} + +/************************************************************************/ +void WinEDA_SchematicFrame::ConvertPart(EDA_SchComponentStruct *DrawComponent, + wxDC * DC) +/************************************************************************/ +{ +int ii; +EDA_LibComponentStruct *LibEntry; + + if (DrawComponent == NULL) return; + + LibEntry = FindLibPart(DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if( LibEntry == NULL ) return; + + if( (ii = LookForConvertPart(LibEntry) ) < 2 ) + { + DisplayError(this, wxT("No Convert found"), 10); return; + } + + /* Efface le trace precedent */ + if ( DrawComponent->m_Flags ) + DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 ); + else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), g_XorMode); + + DrawComponent->m_Convert++; + if( DrawComponent->m_Convert > ii ) DrawComponent->m_Convert = 1; + + /* Redessine le composant dans la nouvelle position */ + if( DrawComponent->m_Flags & IS_MOVED) + DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 ); + else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), GR_DEFAULT_DRAWMODE); + + TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); + GetScreen()->SetModify(); +} + + +/**********************************************************/ +int LookForConvertPart( EDA_LibComponentStruct * LibEntry ) +/**********************************************************/ +/* Retourne la plus grande valeur trouvee dans la liste des elements + "drawings" du composant LibEntry, pour le membre .Convert + Si il n'y a pas de representation type "convert", la valeur + retournee est 0 ou 1 + Si il y a une representation type "convert", + la valeur retournee est > 1 (typiquement 2) + */ +{ +int ii; +LibEDA_BaseStruct *DrawLibEntry; + + DrawLibEntry = LibEntry->m_Drawings; + ii = 0; + while( DrawLibEntry) + { + if (ii < DrawLibEntry->m_Convert ) ii = DrawLibEntry->m_Convert; + DrawLibEntry = DrawLibEntry->Next(); + } + + return (ii); +} + + +/***********************************************************************************/ +void WinEDA_SchematicFrame::StartMovePart(EDA_SchComponentStruct * Component, + wxDC * DC) +/***********************************************************************************/ +{ + if( Component == NULL) return; + if( Component->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE) + return; + + if ( Component->m_Flags == 0 ) + { + if ( g_ItemToUndoCopy ) delete g_ItemToUndoCopy; + g_ItemToUndoCopy = Component->GenCopy(); + } + + DrawPanel->CursorOff(DC); + m_CurrentScreen->m_Curseur = Component->m_Pos; + DrawPanel->MouseToCursorSchema(); + + DrawPanel->ManageCurseur = ShowWhileMoving ; + DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp; + m_CurrentScreen->m_CurrentItem = Component; + OldPos = Component->m_Pos; + memcpy(OldTransMat, Component->m_Transform, sizeof(OldTransMat) ); + + RedrawOneStruct(DrawPanel, DC, Component, g_XorMode); + Component->m_Flags |= IS_MOVED; + DrawPanel->ManageCurseur(DrawPanel, DC,FALSE); + DrawPanel->m_AutoPAN_Request = TRUE; + + DrawPanel->CursorOn(DC); +} + + diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp new file mode 100644 index 0000000000..30a0d9ec6e --- /dev/null +++ b/eeschema/hierarch.cpp @@ -0,0 +1,376 @@ +/************************************************************************/ +/* hierarch.cpp: Gestion de la hierarchie: navigation dans les feuilles */ +/************************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +#include "wx/image.h" +#include "wx/imaglist.h" +#include "wx/treectrl.h" + + +#include "../bitmaps/treesel.xpm" +#include "../bitmaps/treensel.xpm" + + +static void InstallScreenFromSheet(WinEDA_SchematicFrame * frame, + DrawSheetStruct * Sheet ); + +enum { + ID_TREECTRL_HIERARCHY = 1600 +}; + + +class WinEDA_HierFrame; + +/* Cette classe permet de memoriser la feuille (sheet) associée a l'item + pour l'arbre de hierarchie */ +class TreeItemData: public wxTreeItemData +{ +public: + DrawSheetStruct * Sheet; + TreeItemData(DrawSheetStruct * sheet) :wxTreeItemData() + { + Sheet = sheet; + } +}; + +/* Classe de l'arbre de hierarchie */ +class WinEDA_Tree : public wxTreeCtrl +{ +private: + WinEDA_HierFrame * m_Parent; + wxImageList *imageList; + +public: + WinEDA_Tree(void) { } + WinEDA_Tree(WinEDA_HierFrame *parent); + + DECLARE_DYNAMIC_CLASS(WinEDA_Tree) +}; +IMPLEMENT_DYNAMIC_CLASS(WinEDA_Tree, wxTreeCtrl) + + + +WinEDA_Tree::WinEDA_Tree(WinEDA_HierFrame *parent) : + wxTreeCtrl( (wxWindow*)parent, ID_TREECTRL_HIERARCHY, + wxDefaultPosition, wxDefaultSize, + wxTR_HAS_BUTTONS, wxDefaultValidator, wxT("HierachyTreeCtrl")) +{ + m_Parent = parent; + // Make an image list containing small icons + imageList = new wxImageList(16, 15, TRUE, 2); + + imageList->Add(wxBitmap(tree_nosel_xpm)); + imageList->Add(wxBitmap(tree_sel_xpm)); + + AssignImageList(imageList); + +} + +/* Classe definissant la fenetre d'affichage de la hierarchie */ +class WinEDA_HierFrame : public wxDialog +{ +public: + WinEDA_SchematicFrame * m_Parent; + WinEDA_Tree * m_Tree; + int nbsheets; + wxDC * m_DC; + +private: + wxSize m_TreeSize; // Taille de l'arbre de hierarchie + int maxposx; + +public: + WinEDA_HierFrame(WinEDA_SchematicFrame *parent, wxDC * DC, const wxPoint& pos); + void BuildSheetList(EDA_BaseStruct * DrawStruct, + wxTreeItemId * previousmenu); + ~WinEDA_HierFrame(void); + + void OnSelect(wxTreeEvent& event); + +private: + void OnQuit(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(WinEDA_HierFrame, wxDialog) + EVT_TREE_ITEM_ACTIVATED(ID_TREECTRL_HIERARCHY, + WinEDA_HierFrame::OnSelect) +END_EVENT_TABLE() + + +/*************************************************************************/ +void WinEDA_SchematicFrame::InstallHierarchyFrame(wxDC * DC, wxPoint &pos) +/*************************************************************************/ +{ + WinEDA_HierFrame * treeframe = new WinEDA_HierFrame(this, DC, pos); + treeframe->ShowModal(); treeframe->Destroy(); +} + + +WinEDA_HierFrame::WinEDA_HierFrame(WinEDA_SchematicFrame *parent, wxDC * DC, + const wxPoint& pos): + wxDialog(parent, -1, _("Navigator"), pos, wxSize(110,50), + DIALOG_STYLE) +{ +wxTreeItemId cellule; + + m_Parent = parent; + m_DC = DC; + m_Tree = new WinEDA_Tree(this); + + nbsheets = 1; + + cellule = m_Tree->AddRoot(_("Root"), 0, 1); + m_Tree->SetItemBold(cellule, TRUE); + m_Tree->SetItemData( cellule, new TreeItemData(NULL) ); + +wxRect itemrect; +#ifdef __UNIX__ + itemrect.SetWidth(100); + itemrect.SetHeight(20); +#else + m_Tree->GetBoundingRect(cellule,itemrect); +#endif + m_TreeSize.x = itemrect.GetWidth() + 10; + m_TreeSize.y = 20; + + if (ScreenSch == m_Parent->m_CurrentScreen ) + { + m_Tree->SelectItem(cellule); + } + + maxposx = 15; + BuildSheetList(ScreenSch->EEDrawList, &cellule); + + if ( nbsheets > 1) + { + m_Tree->Expand(cellule); + + // Reajustage de la taille de la frame a une valeur optimale + m_TreeSize.y += nbsheets * itemrect.GetHeight(); + m_TreeSize.x = MIN(m_TreeSize.x, 250); + m_TreeSize.y = MIN( m_TreeSize.y, 350); + SetClientSize(m_TreeSize); + } +} + +WinEDA_HierFrame::~WinEDA_HierFrame(void) +{ +} + + +/************************************************************************/ +void WinEDA_HierFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/************************************************************************/ +{ + // true is to force the frame to close + Close(true); +} + +/********************************************************************/ +void WinEDA_HierFrame::BuildSheetList(EDA_BaseStruct * DrawStruct, + wxTreeItemId * previousmenu) +/********************************************************************/ +/* Routine de creation de l'arbre de navigation dans la hierarchy +schematique + Cette routine est Reentrante ! +*/ +{ +wxTreeItemId menu; +SCH_SCREEN * Screen; + + if( nbsheets > NB_MAX_SHEET ) + { + if( nbsheets == (NB_MAX_SHEET + 1) ) + { + wxString msg; + msg << wxT("BuildSheetList: Error: nbsheets > ") << NB_MAX_SHEET; + DisplayError(this, msg); + nbsheets++; + } + return; + } + + maxposx += m_Tree->GetIndent(); + + while( DrawStruct ) + { + if(DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE ) + { + #define STRUCT ((DrawSheetStruct*)DrawStruct) + nbsheets++; + menu = m_Tree->AppendItem(*previousmenu, + STRUCT->m_SheetName, 0 , 1 ); + m_Tree->SetItemData( menu, new TreeItemData(STRUCT) ); +// m_Tree->SetItemFont( menu, *StdFont); + + int ll = m_Tree->GetItemText(menu).Len(); +#ifdef __WINDOWS__ + ll *= 9; // * char width +#else + ll *= 12; // * char width +#endif + ll += maxposx + 20; + m_TreeSize.x = MAX(m_TreeSize.x, ll); + m_TreeSize.y += 1; + + Screen = (SCH_SCREEN*) DrawStruct; + if (Screen == m_Parent->m_CurrentScreen ) + { + m_Tree->EnsureVisible(menu); + m_Tree->SelectItem(menu); + } + + /* Examen des sous - hierarchies */ + if(Screen) + { + int oldnbsheets = nbsheets; + BuildSheetList(Screen->EEDrawList,&menu); + if( oldnbsheets != nbsheets ) + { + m_Tree->SetItemBold(menu, TRUE); + m_Tree->Expand(menu); + } + } + } + DrawStruct = DrawStruct->Pnext; + } + maxposx -= m_Tree->GetIndent(); +} + + +/***************************************************/ +void WinEDA_HierFrame::OnSelect(wxTreeEvent& event) +/***************************************************/ +/* appelee sur un double-click de la souris pour la selection d'un item: + Selectionne et affiche l'ecran demandé +*/ +{ +DrawSheetStruct * Sheet; + + wxTreeItemId ItemSel = m_Tree->GetSelection(); + Sheet = ((TreeItemData*)(m_Tree->GetItemData(ItemSel)))->Sheet; + InstallScreenFromSheet(m_Parent, Sheet); + Close(TRUE); +} + + +/******************************************************/ +void WinEDA_SchematicFrame::InstallPreviousScreen(void) +/******************************************************/ +/* Set the current screen to display the parent sheet of the current displayed sheet +*/ +{ +SCH_SCREEN * Screen; +EDA_BaseStruct * DrawStruct; + + if( m_CurrentScreen == ScreenSch ) return; + + g_ItemToRepeat = NULL; + MsgPanel->EraseMsgBox(); + + /* Build the screen list */ + EDA_ScreenList ScreenList(NULL); + + /* search the list which have the current scheet in EEDrawList */ + for ( Screen = ScreenList.GetFirst(); Screen != NULL; Screen = ScreenList.GetNext() ) + { + DrawStruct = Screen->EEDrawList; + while (DrawStruct != NULL ) + { + if ( DrawStruct == m_CurrentScreen ) break; // Found ! + DrawStruct = DrawStruct->Pnext; + } + if ( DrawStruct ) break; + } + + if ( Screen == NULL ) + { + DisplayError( this, wxT("InstallPreviousScreen() Error: Screen not found")); + return; + } + m_CurrentScreen = ActiveScreen = Screen; + DrawPanel->m_CanStartBlock = -1; + DrawPanel->SetScrollbars( DrawPanel->m_Scroll_unit, + DrawPanel->m_Scroll_unit, + m_CurrentScreen->m_ScrollbarNumber.x, + m_CurrentScreen->m_ScrollbarNumber.y, + m_CurrentScreen->m_ScrollbarPos.x, + m_CurrentScreen->m_ScrollbarPos.y,TRUE); + + ReDrawPanel(); + DrawPanel->MouseToCursorSchema(); +} + +/*********************************************************************/ +void WinEDA_SchematicFrame::InstallNextScreen(DrawSheetStruct * Sheet) +/*********************************************************************/ +/* Routine d'installation de l'ecran correspondant au symbole Sheet pointe + par la souris +*/ +{ + if( Sheet == NULL) + { + DisplayError(this,wxT("InstallNextScreen() error")); return; + } + g_ItemToRepeat = NULL; + MsgPanel->EraseMsgBox(); + InstallScreenFromSheet(this, Sheet ); +} + + + +/**************************************************************/ +static void InstallScreenFromSheet(WinEDA_SchematicFrame * frame, + DrawSheetStruct * Sheet ) +/**************************************************************/ + +/* Recherche et installe de l'ecran relatif au sheet symbole Sheet. + Si Sheet == NULL installation de l'ecran de base ( Root ). +*/ + +{ +SCH_SCREEN * NewScreen; +SCH_SCREEN * oldscreen = (SCH_SCREEN*) frame->m_CurrentScreen; + + if( Sheet == NULL ) NewScreen = ScreenSch; + else NewScreen = Sheet; + + frame->m_CurrentScreen = ActiveScreen = NewScreen; + if ( oldscreen != frame->m_CurrentScreen ) + { // Reinit des parametres d'affichage du nouvel ecran + frame->MsgPanel->EraseMsgBox(); + frame->DrawPanel->SetScrollbars( frame->DrawPanel->m_Scroll_unit, + frame->DrawPanel->m_Scroll_unit, + NewScreen->m_ScrollbarNumber.x, + NewScreen->m_ScrollbarNumber.y, + NewScreen->m_ScrollbarPos.x, + NewScreen->m_ScrollbarPos.y,TRUE); + + frame->DrawPanel->m_CanStartBlock = -1; + if ( NewScreen->m_FirstRedraw ) + { + NewScreen->m_FirstRedraw = FALSE; + frame->Zoom_Automatique(TRUE); + } + else + { + frame->ReDrawPanel(); + frame->DrawPanel->MouseToCursorSchema(); + } + } + + return; +} + diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp new file mode 100644 index 0000000000..b5f5dd695c --- /dev/null +++ b/eeschema/hotkeys.cpp @@ -0,0 +1,130 @@ + /***************/ + /* hotkeys.cpp */ + /***************/ + +#include "fctsys.h" + +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "id.h" + +#include "protos.h" + +/* Routines locales */ + +/* variables externes */ + +/***********************************************************/ +void WinEDA_SchematicFrame::OnHotKey(wxDC * DC, int hotkey, + EDA_BaseStruct * DrawStruct) +/***********************************************************/ +/* Gestion des commandes rapides (Raccourcis claviers) concernant l'element +sous le courseur souris + Les majuscules/minuscules sont indifferenciees + touche DELETE: Effacement (tout element) + touche R: Rotation (composant ou label) + touche X: Miroir X (composant) + touche Y: Miroir Y (composant) + touche N: Orient 0 (composant) + touche M: Start Move composant +*/ +{ +bool PopupOn = m_CurrentScreen->m_CurrentItem && + m_CurrentScreen->m_CurrentItem->m_Flags; + + if ( hotkey == 0 ) return; + + switch (hotkey) + { + case WXK_DELETE: + case WXK_NUMPAD_DELETE: + if ( PopupOn ) break; + LocateAndDeleteItem(this, DC); + m_CurrentScreen->SetModify(); + m_CurrentScreen->m_CurrentItem = NULL; + TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); + break; + + case WXK_F5 : + if ( g_LastSearchIsMarker ) WinEDA_SchematicFrame::FindMarker(1); + else FindSchematicItem(wxEmptyString, 2); + break; + + case 'r': // Rotation + case 'R': + if ( DrawStruct == NULL ) + { + DrawStruct = PickStruct( GetScreen()->m_Curseur, + GetScreen()->EEDrawList, LIBITEM|TEXTITEM|LABELITEM ); + if ( DrawStruct == NULL ) break; + if ( DrawStruct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE ) + DrawStruct = LocateSmallestComponent( GetScreen() ); + if ( DrawStruct == NULL ) break; + } + switch (DrawStruct->m_StructType) + { + case DRAW_LIB_ITEM_STRUCT_TYPE: + CmpRotationMiroir( + (EDA_SchComponentStruct *) DrawStruct, DC, CMP_ROTATE_COUNTERCLOCKWISE ); + break; + + case DRAW_TEXT_STRUCT_TYPE: + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + ChangeTextOrient( (DrawTextStruct*)DrawStruct, DC); + break; + } + break; + + case 'y': // Mirror Y (drawlibpart) + case 'Y': + if ( DrawStruct == NULL ) + DrawStruct = LocateSmallestComponent( GetScreen() ); + if ( DrawStruct ) + { + CmpRotationMiroir( + (EDA_SchComponentStruct *) DrawStruct, DC, CMP_MIROIR_Y ); + } + break; + + case 'x': // Mirror X (drawlibpart) + case 'X': + if ( DrawStruct == NULL ) + DrawStruct = LocateSmallestComponent( GetScreen() ); + if ( DrawStruct ) + { + CmpRotationMiroir( + (EDA_SchComponentStruct *) DrawStruct, DC, CMP_MIROIR_X ); + } + break; + + case 'n': + case 'N': // Orient 0, no mirror (drawlibpart) + if ( DrawStruct == NULL ) + DrawStruct = LocateSmallestComponent( GetScreen() ); + if ( DrawStruct ) + { + CmpRotationMiroir( + (EDA_SchComponentStruct *) DrawStruct, DC, CMP_NORMAL ); + TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); + } + break; + + case 'm': + case 'M': // Start move drawlibpart + if ( PopupOn ) break; + if ( DrawStruct == NULL ) + DrawStruct = LocateSmallestComponent( GetScreen() ); + if ( DrawStruct && (DrawStruct->m_Flags ==0) ) + { + m_CurrentScreen->m_CurrentItem = DrawStruct; + Process_Move_Item(m_CurrentScreen->m_CurrentItem, DC); + } + break; + } +} diff --git a/eeschema/lib_export.cpp b/eeschema/lib_export.cpp new file mode 100644 index 0000000000..7e0c1cc51d --- /dev/null +++ b/eeschema/lib_export.cpp @@ -0,0 +1,144 @@ + /*****************************/ + /* EESchema - lib_export.cpp */ + /*****************************/ + +/* Routines de maintenanace des librariries: + sauvegarde, modification de librairies. + creation edition suppression de composants +*/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +#include "id.h" + + + +/*************************************************/ +void WinEDA_LibeditFrame::ImportOnePart(void) +/*************************************************/ +/* Routine de lecture de 1 description. + Le format est celui des librairies, mais on ne charge que 1 composant + ou le 1er composant s'il y en a plusieurs. + Si le premier composant est un alias, on chargera la racine correspondante +*/ +{ +wxString Name, mask; +LibraryStruct * LibTmp; +EDA_LibComponentStruct *LibEntry; +int err = 1; + + mask = wxT("*") + g_LibExtBuffer; + Name = EDA_FileSelector( _("Import part:"), + wxEmptyString, /* Chemin par defaut */ + wxEmptyString, /* nom fichier par defaut */ + g_LibExtBuffer, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + 0, + TRUE + ); + if ( Name == wxEmptyString ) return; + + LibTmp = g_LibraryList; g_LibraryList = NULL; + + LoadLibraryName(this, Name, wxT("$tmplib$")); + + if ( g_LibraryList ) + { + LibEntry = (EDA_LibComponentStruct *)PQFirst(&g_LibraryList->m_Entries,FALSE); + + if( LibEntry ) + err = LoadOneLibraryPartAux(LibEntry, g_LibraryList, 1); + FreeCmpLibrary(this, g_LibraryList->m_Name); + + if ( err == 0 ) + { + ReCreateHToolbar(); + DisplayLibInfos(); + ReDrawPanel(); + } + } + + g_LibraryList = LibTmp; + if (err) DisplayError(this, _("File is empty"), 30); +} + + +/************************************************************/ +void WinEDA_LibeditFrame::ExportOnePart(bool create_lib) +/************************************************************/ +/* Routine de creation d'une nouvelle librairie et de sauvegarde du + composant courant dans cette librarie + si create_lib == TRUE sauvegarde dans le repertoire des libr + sinon: sauvegarde sous le nom demande sans modifications. + + Le format du fichier cree est dans tous les cas le meme. +*/ +{ +wxString Name, mask; +LibraryStruct * NewLib, * LibTmp, * CurLibTmp; +int err; + + if(CurrentLibEntry == NULL) + { + DisplayError(this, _("No Part to Save"),10); return; + } + + Name = CurrentLibEntry->m_Name.m_Text; + Name.MakeLower(); + + mask = wxT("*") + g_LibExtBuffer; + wxString def_path; + if ( create_lib ) def_path = g_RealLibDirBuffer; + Name = EDA_FileSelector( create_lib ? _("New Library") : _("Export part:"), + def_path, /* Chemin par defaut */ + Name, /* nom fichier par defaut */ + g_LibExtBuffer, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + TRUE + ); + if ( Name == wxEmptyString ) return; + + + /* Creation d'une librairie standard pour sauvegarde */ + ChangeFileNameExt(Name, g_LibExtBuffer); + + LibTmp = g_LibraryList; + CurLibTmp = CurrentLib; + + NewLib = new LibraryStruct(LIBRARY_TYPE_EESCHEMA, wxT("$libTmp$"), Name); + g_LibraryList = NewLib; + + /* Sauvegarde du composant: */ + CurrentLib = NewLib; + SaveOnePartInMemory(); + err = SaveOneLibrary(this, Name, NewLib); + + /* Suppression de la librarie temporaire */ + FreeCmpLibrary(this, NewLib->m_Name ); + g_LibraryList = LibTmp; + CurrentLib = CurLibTmp; + +wxString msg; + if ( create_lib && (err == 0) ) + { + msg = Name + _("0k"); + DisplayInfo(this, +_("Note: this new library will be available only if it is loaded by eeschema\nModify eeschema config if you want use it") ); + } + else msg = _("Error while create ") + Name; + Affiche_Message(msg); +} + + + diff --git a/eeschema/libalias.cpp b/eeschema/libalias.cpp new file mode 100644 index 0000000000..c1e86c6e2a --- /dev/null +++ b/eeschema/libalias.cpp @@ -0,0 +1,86 @@ + /****************************/ + /* EESchema - libalias.cpp */ + /****************************/ + +/* Routines de maintenanace des librairies: gestion des alias des composants +*/ + +#include "fctsys.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +/* Variables locales */ + + +/**************************************************************************/ +bool BuildAliasData(LibraryStruct * Lib, EDA_LibComponentStruct * component) +/**************************************************************************/ +/* Create the alias data for the lib component to edit + Alias data is: + alias name + doc string + keywords string + doc file name + + in .m_AliastList + Alias data (4 strings) replace each alias name. + +*/ +{ +wxArrayString List; +LibCmpEntry * CmpEntry; +unsigned ii; + + if ( component == NULL ) return FALSE; + if( Lib == NULL ) return FALSE; + if( component->m_AliasList.GetCount() == 0 ) return FALSE; + + List = component->m_AliasList; + component->m_AliasList.Clear(); + for ( ii = 0; ii < List.GetCount(); ii++ ) + { + CmpEntry = (LibCmpEntry*) FindLibPart(List[ii].GetData(), Lib->m_Name, FIND_ALIAS); + if(CmpEntry && CmpEntry->Type != ALIAS ) + { + DisplayError(NULL, wxT("BuildListAlias err: alias is a ROOT entry!")); + } + else + { + if( LocateAlias( component->m_AliasList, List[ii] ) < 0 ) + { /* Alias not found in list: create it (datas must be in this order) */ + component->m_AliasList.Add(List[ii]); + component->m_AliasList.Add(CmpEntry->m_Doc); + component->m_AliasList.Add(CmpEntry->m_KeyWord); + component->m_AliasList.Add(CmpEntry->m_DocFile); + } + } + } + return TRUE; +} + + +/***********************************************************************/ +int LocateAlias( const wxArrayString & AliasData, const wxString & Name) +/***********************************************************************/ +/* Return an index in alias data list + ( -1 if not found ) +*/ +{ +int index = -1; +unsigned ii; + + for ( ii = 0; ii < AliasData.GetCount(); ii += ALIAS_NEXT) + { + if ( Name.CmpNoCase(AliasData[ii+ALIAS_NAME].GetData()) == 0 ) + { + index = ii; + break; + } + } + return(index); +} diff --git a/eeschema/libarch.cpp b/eeschema/libarch.cpp new file mode 100644 index 0000000000..41080dcd1c --- /dev/null +++ b/eeschema/libarch.cpp @@ -0,0 +1,151 @@ + /**************************************************************/ + /* libarch.cc */ + /* Module de generation du fichier d'archivage des composants */ + /**************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "netlist.h" + +#include "protos.h" + +/* fonctions exportees */ + +/* fonctions locales */ +static int TriListEntry(EDA_LibComponentStruct **Objet1, + EDA_LibComponentStruct **Objet2); + +/* Variable locales */ + + +/*******************************************************************/ +bool LibArchive(wxWindow * frame, const wxString & ArchFullFileName) +/*******************************************************************/ +/* +Creation du fichier librairie contenant tous les composants utilisés dans +le projet en cours +retourne TRUE si fichier créé +*/ +{ +wxString DocFileName, msg; +char Line[256]; +FILE *ArchiveFile, *DocFile; +EDA_BaseStruct ** ListStruct; +EDA_LibComponentStruct ** ListEntry, *Entry; +int ii, NbItems; +const wxChar * Text; + + + /* Creation de la liste des elements */ + NbItems = GenListeCmp(NULL ); // Comptage des composants + if ( NbItems == 0 ) return FALSE; + + ListStruct = (EDA_BaseStruct **) + MyZMalloc( NbItems * sizeof(EDA_BaseStruct **) ); + if (ListStruct == NULL ) return FALSE; + + /* Calcul de la liste des composants */ + GenListeCmp(ListStruct); + + /* Calcul de la liste des Entrees de librairie + et Remplacement des alias par les composants "Root" */ + ListEntry = (EDA_LibComponentStruct ** ) + MyZMalloc( NbItems * sizeof(EDA_LibComponentStruct *) ); + if (ListEntry == NULL ) return FALSE; + + for ( ii = 0; ii < NbItems; ii++ ) + { + Text = ( (EDA_SchComponentStruct*)ListStruct[ii])->m_ChipName.GetData(); + Entry = FindLibPart(Text, wxEmptyString, FIND_ROOT); + ListEntry[ii] = Entry; // = NULL si Composant non trouvé en librairie + } + + MyFree(ListStruct); + + qsort( ListEntry, NbItems, sizeof(EDA_LibComponentStruct *), + (int(*)(const void*, const void*))TriListEntry); + + /* mise a jour extension fichier doc associe */ + DocFileName = ArchFullFileName; + ChangeFileNameExt(DocFileName, wxT(".bck")); + + if ((ArchiveFile = wxFopen(ArchFullFileName, wxT("wt"))) == NULL) + { + MyFree(ListEntry); + msg = _("Failed to create archive lib file ") + ArchFullFileName; + DisplayError(frame, msg); + return FALSE; + } + + if ((DocFile = wxFopen(DocFileName, wxT("wt"))) == NULL) + { + msg = _("Failed to create doc lib file ") + DocFileName; + DisplayError(frame, msg); + } + + fprintf(ArchiveFile,"%s %s\n#\n", LIBFILE_IDENT,DateAndTime(Line)); + if( DocFile) + fprintf(DocFile,"%s %s\n", DOCFILE_IDENT, DateAndTime(Line)); + + /* Generation des elements */ + for ( ii = 0; ii < NbItems; ii++ ) + { + if ( ListEntry[ii] == NULL ) // Composant non trouvé en librairie + { + continue; + } + if ( ii == 0 ) + { + WriteOneLibEntry(frame, ArchiveFile, ListEntry[ii]); + if( DocFile ) WriteOneDocLibEntry(DocFile, ListEntry[ii]); + } + else if ( ListEntry[ii-1] != ListEntry[ii] ) + { + WriteOneLibEntry(frame, ArchiveFile, ListEntry[ii]); + if( DocFile ) WriteOneDocLibEntry(DocFile, ListEntry[ii]); + } + } + + /* Generation fin de fichier */ + fprintf(ArchiveFile,"#\n#EndLibrary\n"); + fclose(ArchiveFile); + + if( DocFile ) + { + fprintf(DocFile,"#\n#End Doc Library\n"); + fclose(DocFile); + } + + MyFree(ListEntry); + + return TRUE; +} + +/***********************************************************/ +static int TriListEntry(EDA_LibComponentStruct **Objet1, + EDA_LibComponentStruct **Objet2) +/***********************************************************/ +/* Routine de comparaison pour le tri du Tableau par qsort() + Les composants sont tries par LibName +*/ +{ +int ii; +const wxString * Text1, *Text2; + + if( (*Objet1 == NULL) && (*Objet2 == NULL ) ) return(0); + if( *Objet1 == NULL) return(-1); + if( *Objet2 == NULL) return(1); + + Text1 = &(*Objet1)->m_Name.m_Text; + Text2 = &(*Objet2)->m_Name.m_Text; + + ii = Text1->CmpNoCase(* Text2); + return(ii); +} + + diff --git a/eeschema/libclass.cpp b/eeschema/libclass.cpp new file mode 100644 index 0000000000..49eff9b6a5 --- /dev/null +++ b/eeschema/libclass.cpp @@ -0,0 +1,697 @@ +/**********************************************************/ +/* libclass.cpp */ +/**********************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + + + /*******************************************************/ + /* Methodes relatives a la manipulation des librairies */ + /*******************************************************/ + +/***************************************************************************************/ +LibraryStruct::LibraryStruct(int type, const wxString & name, const wxString & fullname) +/***************************************************************************************/ +{ + m_Type = type; /* type indicator */ + m_Name = name; /* Name of library loaded. */ + m_FullFileName = fullname; /* Full File Name (with path) of library loaded. */ + m_NumOfParts = 0; /* Number of parts this library has. */ + m_Entries = NULL; /* Parts themselves are saved here. */ + m_Pnext = NULL; /* Point on next lib in chain. */ + m_Modified = FALSE; /* flag indicateur d'edition */ + m_TimeStamp = 0; + m_Flags = 0; + m_IsLibCache = FALSE; + +} + +/*****************************************/ +void FreeLibraryEntry(LibCmpEntry * Entry) +/*****************************************/ +/* Used by PQFreeFunc() to delete all entries +*/ +{ + delete Entry; +} + +/******************************/ +LibraryStruct::~LibraryStruct() +/******************************/ +{ + if ( m_Entries ) PQFreeFunc(m_Entries, (void(*)(void *))FreeLibraryEntry); +} + + +/*******************************************/ +bool LibraryStruct::WriteHeader(FILE * file) +/*******************************************/ +/* Ecrit l'entete du fichier librairie +*/ +{ +char BufLine[1024]; +bool succes = TRUE; + + DateAndTime(BufLine); + if ( fprintf(file,"%s %d.%d Date: %s\n", LIBFILE_IDENT, + LIB_VERSION_MAJOR, LIB_VERSION_MINOR, + BufLine) != 5 ) + succes = FALSE; +#if 0 + if ( fprintf(file,"$HEADER\n") != 1 ) succes = FALSE; + if ( fprintf(file,"TimeStamp %8.8lX\n", m_TimeStamp) != 2 ) succes = FALSE; + if ( fprintf(file,"Parts %d\n", m_NumOfParts) != 2 ) succes = FALSE; + if ( fprintf(file,"$ENDHEADER\n") != 1 ) succes = FALSE; +#endif + return (succes); +} + +/***********************************************************/ +bool LibraryStruct::ReadHeader(FILE * libfile, int * LineNum) +/***********************************************************/ +/* Ecrit l'entete du fichier librairie +*/ +{ +char Line[1024], * text, * data; + + while (GetLine(libfile, Line, LineNum, sizeof(Line)) ) + { + text = strtok(Line, " \t\r\n"); + data = strtok(NULL, " \t\r\n"); + if ( stricmp(text, "TimeStamp") == 0 ) + m_TimeStamp = atol(data); + if ( stricmp(text,"$ENDHEADER") == 0 ) return TRUE; + } + return FALSE; +} + + + /*********************/ + /* class LibCmpEntry */ + /*********************/ +/* Basic class for librarty oomponent description + Nor directly used + Used to create the 2 derived classes : + - EDA_LibCmpAliasStruct + - EDA_LibComponentStruct +*/ + +/********************************************************************/ +LibCmpEntry::LibCmpEntry(LibrEntryType CmpType, const wxChar * CmpName): + EDA_BaseStruct(LIBCOMPONENT_STRUCT_TYPE) +/********************************************************************/ +{ + Type = CmpType; + m_Name.m_FieldId = VALUE; + if ( CmpName ) m_Name.m_Text = CmpName; +} + +/******************************/ +LibCmpEntry::~LibCmpEntry(void) +/******************************/ +{ +} + + + /*******************************/ + /* class EDA_LibCmpAliasStruct */ + /*******************************/ + +/* Decrit un alias d'un composant standard en librairie + Un alias est identique au composant standard + Dans un alias on ne redefinit que le nom et la documentation associée. + Le gain de place en memoire est important +*/ + +EDA_LibCmpAliasStruct:: EDA_LibCmpAliasStruct( const wxChar * CmpName, + const wxChar * CmpRootName): + LibCmpEntry(ALIAS, CmpName) +{ + if ( CmpRootName == NULL) m_RootName.Empty(); + else m_RootName = CmpRootName; +} + +EDA_LibCmpAliasStruct::~EDA_LibCmpAliasStruct(void) +{ +} + + + /********************************/ + /* class EDA_LibComponentStruct */ + /********************************/ + +/* This is a standard component (in library) +*/ +EDA_LibComponentStruct:: EDA_LibComponentStruct( const wxChar * CmpName): + LibCmpEntry(ROOT, CmpName) +{ + m_Drawings = NULL; + m_LastDate = 0; + m_UnitCount = 1; + m_TextInside = 40; + m_Options = ENTRY_NORMAL; + m_UnitSelectionLocked = FALSE; + m_DrawPinNum = m_DrawPinName = 1; + + Fields = NULL; + m_Prefix.m_FieldId = REFERENCE; +} + +/******************************************************/ +EDA_LibComponentStruct::~EDA_LibComponentStruct( void ) +/******************************************************/ +{ +LibEDA_BaseStruct * DrawItem, * NextDrawItem; +LibDrawField *TempField, *field; + + field = Fields; Fields = NULL; + while (field) + { + TempField = field; field = (LibDrawField *) field->Pnext; + delete TempField; + } + + /* suppression des elements dependants */ + DrawItem = m_Drawings; m_Drawings = NULL; + while(DrawItem) + { + NextDrawItem = DrawItem->Next(); + delete DrawItem; + DrawItem = NextDrawItem; + } +} + + +/**********************************************************************/ +EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert) +/**********************************************************************/ +/* Return the componenty boundary box ( in user coordinates ) + The unit Unit, and the shape Convert are considered. + If Unit == 0, Unit is not used + if Convert == 0 Convert is non used +**/ +{ +int xmin, xmax, ymin, ymax, x1, y1; +int * pt, ii; +LibEDA_BaseStruct * DrawEntry; +EDA_Rect BoundaryBox; + + DrawEntry = m_Drawings; + if ( DrawEntry ) + { + xmin = ymin = 0x7FFFFFFF; xmax = ymax = 0x80000000; + } + else + { + xmin = ymin = -50; xmax = ymax = 50; // Min size in 1/1000 inch + } + + for ( ;DrawEntry != NULL; DrawEntry = DrawEntry->Next() ) + { + if ( DrawEntry->m_Unit > 0 ) // The item is non common to units + if ( (m_UnitCount > 1 ) && (Unit > 0) && (Unit != DrawEntry->m_Unit) ) + continue; + if ( DrawEntry->m_Convert > 0 ) //The item is not common to alls convert + if ( (Convert > 0) && (Convert != DrawEntry->m_Convert) ) + continue; + + switch ( DrawEntry->m_StructType) + { + case COMPONENT_ARC_DRAW_TYPE: + { + // Arc is reduced to a line from m_Start to m_End. + // TO DO better. + LibDrawArc * Arc = (LibDrawArc *) DrawEntry; + x1 = Arc->m_Start.x; + y1 = Arc->m_Start.y; + xmin = MIN(xmin, x1); + ymin = MIN(ymin, y1); + xmax = MAX(xmax, x1); + ymax = MAX(ymax, y1); + x1 = Arc->m_End.x; + y1 = Arc->m_End.y; + xmin = MIN(xmin, x1); + ymin = MIN(ymin, y1); + xmax = MAX(xmax, x1); + ymax = MAX(ymax, y1); + } + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + { + LibDrawCircle * Circle = (LibDrawCircle *) DrawEntry; + x1 = Circle->m_Pos.x - Circle->m_Rayon; + y1 = Circle->m_Pos.y - Circle->m_Rayon; + xmin = MIN(xmin, x1); + ymin = MIN(ymin, y1); + x1 = Circle->m_Pos.x + Circle->m_Rayon; + y1 = Circle->m_Pos.y + Circle->m_Rayon; + xmax = MAX(xmax, x1); + ymax = MAX(ymax, y1); + } + break; + + case COMPONENT_RECT_DRAW_TYPE: + { + LibDrawSquare * Square = (LibDrawSquare *) DrawEntry; + xmin = MIN(xmin, Square->m_Start.x); + xmin = MIN(xmin, Square->m_End.x); + xmax = MAX(xmax, Square->m_Start.x); + xmax = MAX(xmax, Square->m_End.x); + ymin = MIN(ymin, Square->m_Start.y); + ymin = MIN(ymin, Square->m_End.y); + ymax = MAX(ymax, Square->m_Start.y); + ymax = MAX(ymax, Square->m_End.y); + } + break; + + case COMPONENT_PIN_DRAW_TYPE: + { + LibDrawPin * Pin = (LibDrawPin *) DrawEntry; + x1 = Pin->m_Pos.x; + y1 = Pin->m_Pos.y; + xmin = MIN(xmin, x1); + xmax = MAX(xmax, x1); + ymin = MIN(ymin, y1); + ymax = MAX(ymax, y1); +#if 0 // 0 pour englober le point origine de la pin, 1 pour englober toute la pin + switch ( Pin->Orient ) + { + case PIN_UP: y1 += Pin->Len; break; + case PIN_DOWN: y1 -= Pin->Len; break; + case PIN_LEFT: x1 -= Pin->Len; break; + case PIN_RIGHT: x1 += Pin->Len; break; + } + xmin = MIN(xmin, x1); + xmax = MAX(xmax, x1); + ymin = MIN(ymin, y1); + ymax = MAX(ymax, y1); +#endif + } + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + { + LibDrawPolyline * polyline = (LibDrawPolyline *) DrawEntry; + pt = polyline->PolyList; + for( ii = 0; ii < polyline->n; ii++ ) + { + if( xmin > *pt ) xmin = *pt; + if( xmax < *pt ) xmax = *pt; + pt++; + if( ymin > *pt ) ymin = *pt; + if( ymax < *pt ) ymax = *pt; + pt++; + } + } + break; + } + } + + // Update the BoundaryBox. Remenber the fact the screen Y axis is the reverse */ + ymax = - ymax; ymin = -ymin; // Y is is screen axis sense + // Ensure w and H > 0 (wxRect assume it) + if ( xmax < xmin ) EXCHG( xmax, xmin ); + if ( ymax < ymin ) EXCHG( ymax, ymin ); + BoundaryBox.SetX(xmin); BoundaryBox.SetWidth(xmax-xmin); + BoundaryBox.SetY(ymin); BoundaryBox.SetHeight(ymax-ymin); + + return BoundaryBox; +} + + + /***************************/ + /* class LibraryFieldEntry */ + /***************************/ +/* a Field is a string linked to a component. + Unlike a pure graphic text, fields can be used in netlist generation + and other things. + + 4 fields have a special meaning: + REFERENCE + VALUE + FOOTPRINT NAME + SCHEMATIC LINK (reserved but not used in kicad) +*/ +LibDrawField::LibDrawField(int idfield) : LibEDA_BaseStruct(COMPONENT_FIELD_DRAW_TYPE) +{ + m_FieldId = idfield; /* 0 a 11, 0 = REFERENCE, 1 = VALUE*/ + if ( m_FieldId < 0 ) m_FieldId = 0; + if ( m_FieldId >= NUMBER_OF_FIELDS ) m_FieldId = NUMBER_OF_FIELDS - 1; + m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT; + m_Orient = 0; /* Orientation */ + m_Attributs = 0; /* Attributs = Non visible ... */ + m_HJustify = GR_TEXT_HJUSTIFY_CENTER; + m_VJustify = GR_TEXT_VJUSTIFY_CENTER; /* Justifications Horiz et Vert du texte */ +} + +LibDrawField::~LibDrawField(void) // Destructor +{ +} + + // Creation et Duplication d'un field +LibDrawField * LibDrawField::GenCopy(void) +{ + LibDrawField * newfield = new LibDrawField(m_FieldId); + Copy(newfield); + + return newfield; +} + + // copie du field dans le field Target +void LibDrawField::Copy(LibDrawField * Target) +{ + Target->m_Pos = m_Pos; + Target->m_Size = m_Size; + Target->m_Orient = m_Orient; + Target->m_Attributs = m_Attributs; + Target->m_Text = m_Text; + Target->m_Name = m_Name; + Target->m_HJustify = m_HJustify; + Target->m_VJustify = m_VJustify; +} + +/* Elements Graphiques */ +LibEDA_BaseStruct::LibEDA_BaseStruct(int struct_type): + EDA_BaseStruct(struct_type) +{ + m_Unit = 0; /* Unit identification (for multi part per package) + 0 if the item is common to all units */ + m_Convert = 0; /* Shape identification (for parts which have a convert shape) + 0 if the item is common to all shapes */ +} + +/***************************************************************/ +LibDrawPin::LibDrawPin(void) : LibEDA_BaseStruct(COMPONENT_PIN_DRAW_TYPE) +/***************************************************************/ +{ + m_PinLen = 300; /* default Pin len */ + m_Orient = PIN_RIGHT; /* Pin oprient: Up, Down, Left, Right */ + m_PinShape = NONE; /* Bit a bit: Pin shape (voir enum prec) */ + m_PinType = PIN_UNSPECIFIED; /* electrical type of pin */ + m_Attributs = 0; /* bit 0 != 0: pin invisible */ + m_PinNum = 0; /*pin number ( i.e. 4 codes Ascii ) */ + m_SizeNum = 50; + m_SizeName = 50; /* Default size for pin name and num */ +} + + +/******************************************/ +wxPoint LibDrawPin::ReturnPinEndPoint(void) +/******************************************/ +/* return the pin end position, for a component in normal orient +*/ +{ +wxPoint pos = m_Pos; + switch ( m_Orient ) + { + case PIN_UP: pos.y += m_PinLen; break; + case PIN_DOWN: pos.y -= m_PinLen; break; + case PIN_LEFT: pos.x -= m_PinLen; break; + case PIN_RIGHT: pos.x += m_PinLen; break; + } + + return pos; +} + +/********************************************************/ +int LibDrawPin::ReturnPinDrawOrient(int TransMat[2][2]) +/********************************************************/ +/* Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT), + according to its orientation, + AND the matrix transform (rot, mirror) TransMat +*/ +{ +int orient; +int x1 = 0, y1 = 0; +int t1, t2; + + switch ( m_Orient ) + { + case PIN_UP: y1 = 1; break; + case PIN_DOWN: y1 = -1; break; + case PIN_LEFT: x1 = -1; break; + case PIN_RIGHT: x1 = 1; break; + } + t1 = TransMat[0][0] * x1 + TransMat[0][1] * y1; + t2 = TransMat[1][0] * x1 + TransMat[1][1] * y1; + orient = PIN_UP; + if( t1 == 0 ) + { + if ( t2 > 0 ) orient = PIN_DOWN; + } + else + { + orient = PIN_RIGHT; + if ( t1 < 0 ) orient = PIN_LEFT; + } + + return orient; +} + + +/****************************************************/ +void LibDrawPin::ReturnPinStringNum(wxString & buffer) +/****************************************************/ +/* fill the buffer with pin num as a wxString + Pin num is coded as a long + Used to print/draw the pin num +*/ +{ +char ascii_buf[5]; + + strncpy(ascii_buf, (char*)&m_PinNum,4); + ascii_buf[4]=0; + + buffer = CONV_FROM_UTF8(ascii_buf); +} +/****************************************************/ +void LibDrawPin::SetPinNumFromString(wxString & buffer) +/****************************************************/ +/* fill the buffer with pin num as a wxString + Pin num is coded as a long + Used to print/draw the pin num +*/ +{ +char ascii_buf[4]; +unsigned ii, len = buffer.Len(); + + ascii_buf[0] = ascii_buf[1] = ascii_buf[2] = ascii_buf[3] = 0; + if ( len > 4 ) len = 4; + for ( ii = 0; ii < len; ii ++ ) + { + ascii_buf[ii] = buffer.GetChar(ii) & 0xFF; + } + strncpy((char*)&m_PinNum, ascii_buf, 4); +} + +/*************************************/ +LibDrawPin * LibDrawPin::GenCopy(void) +/*************************************/ +{ +LibDrawPin * newpin = new LibDrawPin(); + + newpin->m_Pos = m_Pos; + newpin->m_PinLen = m_PinLen; + newpin->m_Orient = m_Orient; + newpin->m_PinShape = m_PinShape; + newpin->m_PinType = m_PinType; + newpin->m_Attributs = m_Attributs; + newpin->m_PinNum = m_PinNum; + newpin->m_SizeNum = m_SizeNum; + newpin->m_SizeName = m_SizeName; + newpin->m_Unit = m_Unit; + newpin->m_Convert = m_Convert; + newpin->m_Flags = m_Flags; + + newpin->m_PinName = m_PinName; + + return newpin; +} + +/**************************************************************/ +LibDrawArc::LibDrawArc(void) : LibEDA_BaseStruct(COMPONENT_ARC_DRAW_TYPE) +/**************************************************************/ +{ + m_Rayon = 0; + t1 = t2 = 0; + m_Width = 0; + m_Fill = NO_FILL; +} + + +/************************************/ +LibDrawArc * LibDrawArc::GenCopy(void) +/************************************/ +{ +LibDrawArc * newitem = new LibDrawArc(); + + newitem->m_Pos = m_Pos; + newitem->m_Start = m_Start; + newitem->m_End = m_End; + newitem->m_Rayon = m_Rayon; + newitem->t1 = t1; + newitem->t2 = t2; + newitem->m_Width = m_Width; + newitem->m_Unit = m_Unit; + newitem->m_Convert = m_Convert; + newitem->m_Flags = m_Flags; + newitem->m_Fill = m_Fill; + return newitem; +} + + +/**********************************************************************/ +LibDrawCircle::LibDrawCircle(void) : LibEDA_BaseStruct(COMPONENT_CIRCLE_DRAW_TYPE) +/**********************************************************************/ +{ + m_Rayon = 0; + m_Width = 0; + m_Fill = NO_FILL; +} + +/*******************************************/ +LibDrawCircle * LibDrawCircle::GenCopy(void) +/*******************************************/ +{ +LibDrawCircle * newitem = new LibDrawCircle(); + + newitem->m_Pos = m_Pos; + newitem->m_Rayon = m_Rayon; + newitem->m_Width = m_Width; + newitem->m_Unit = m_Unit; + newitem->m_Convert = m_Convert; + newitem->m_Flags = m_Flags; + newitem->m_Fill = m_Fill; + return newitem; +} + + +/*****************************************************************/ +LibDrawText::LibDrawText(void) : LibEDA_BaseStruct(COMPONENT_GRAPHIC_TEXT_DRAW_TYPE) +/*****************************************************************/ +{ + m_Horiz = TEXT_ORIENT_HORIZ; + m_Size = wxSize(50,50); + m_Type = 0; +} + +/***************************************/ +LibDrawText * LibDrawText::GenCopy(void) +/***************************************/ +{ +LibDrawText * newitem = new LibDrawText(); + + newitem->m_Pos = m_Pos; + newitem->m_Horiz = m_Horiz; + newitem->m_Size = m_Size; + newitem->m_Type = m_Type; + newitem->m_Unit = m_Unit; + newitem->m_Convert = m_Convert; + newitem->m_Flags = m_Flags; + newitem->m_Text = m_Text; + return newitem; +} + + + +LibDrawSquare::LibDrawSquare(void) : LibEDA_BaseStruct(COMPONENT_RECT_DRAW_TYPE) +{ + m_Width = 0; + m_Fill = NO_FILL; +} + +LibDrawSquare * LibDrawSquare::GenCopy(void) +{ +LibDrawSquare * newitem = new LibDrawSquare(); + + newitem->m_Start = m_Start; + newitem->m_End = m_End; + newitem->m_Width = m_Width; + newitem->m_Unit = m_Unit; + newitem->m_Convert = m_Convert; + newitem->m_Flags = m_Flags; + newitem->m_Fill = m_Fill; + return newitem; +} + +LibDrawSegment::LibDrawSegment(void) : LibEDA_BaseStruct(COMPONENT_LINE_DRAW_TYPE) +{ + m_Width = 0; +} + +LibDrawSegment * LibDrawSegment::GenCopy(void) +{ +LibDrawSegment * newitem = new LibDrawSegment(); + + newitem->m_Start = m_Start; + newitem->m_End = m_End; + newitem->m_Width = m_Width; + newitem->m_Unit = m_Unit; + newitem->m_Convert = m_Convert; + newitem->m_Flags = m_Flags; + return newitem; +} + + +LibDrawPolyline::LibDrawPolyline(void) : LibEDA_BaseStruct(COMPONENT_POLYLINE_DRAW_TYPE) +{ + n = 0; + PolyList = NULL; + m_Fill = NO_FILL; + m_Width = 0; +} + +/************************************************/ +LibDrawPolyline * LibDrawPolyline::GenCopy(void) +/************************************************/ +{ +LibDrawPolyline * newitem = new LibDrawPolyline(); +int size; + + newitem->n = n; + size = sizeof(int) * 2 * n; + if( size ) + { + newitem->PolyList = (int*)MyMalloc(size); + memcpy(newitem->PolyList, PolyList, size); + } + newitem->m_Width = m_Width; + newitem->m_Unit = m_Unit; + newitem->m_Convert = m_Convert; + newitem->m_Flags = m_Flags; + newitem->m_Fill = m_Fill; + return newitem; +} + +/***************************************************/ +void LibDrawPolyline::AddPoint(const wxPoint & point) +/***************************************************/ +/* add a point to the polyline coordinate list, and realloc the memory +*/ +{ +int allocsize; + + n++; + allocsize = 2 * sizeof(int) * n; + if (PolyList == NULL) + PolyList = (int*)MyMalloc( allocsize ); + else + PolyList = (int*)realloc(PolyList, allocsize ); + + PolyList[(n*2) - 2] = point.x; + PolyList[(n*2) - 1] = - point.y; +} + + diff --git a/eeschema/libcmp.h b/eeschema/libcmp.h new file mode 100644 index 0000000000..fe04518ccd --- /dev/null +++ b/eeschema/libcmp.h @@ -0,0 +1,417 @@ +/****************************************************************/ +/* Headers fo library definition and lib component definitions */ +/****************************************************************/ + +#ifndef LIBCMP_H +#define LIBCMP_H + +#ifndef eda_global +#define eda_global extern +#endif + +#include "priorque.h" + +#define LIB_VERSION_MAJOR 2 +#define LIB_VERSION_MINOR 3 +#define LIBFILE_IDENT "EESchema-LIBRARY Version" /* Must be at the lib file start. */ +#define DOCFILE_IDENT "EESchema-DOCLIB Version 2.0" /* Must be at the doc file start. */ +#define DOC_EXT wxT(".dcm") /* extension des fichiers de documentation */ + +#define TARGET_PIN_DIAM 12 /* Diam cercle des extremites des pins */ + +#define DEFAULT_TEXT_SIZE 50 /* Default size for field texts */ +#define PART_NAME_LEN 15 /* Maximum length of part name. */ +#define PREFIX_NAME_LEN 5 /* Maximum length of prefix (IC, R, SW etc.). */ +#define PIN_WIDTH 100 /* Width between 2 pins in internal units. */ +#define PIN_LENGTH 300 /* Default Length of each pin to be drawn. */ + +#define INVERT_PIN_RADIUS 35 /* Radius of inverted pin circle. */ +#define CLOCK_PIN_DIM 40 /* Dim of clock pin symbol. */ +#define IEEE_SYMBOL_PIN_DIM 40 /* Dim of special pin symbol. */ + +#define NO_FILL 0 // Poly, Squar, Circle, Arc = option No Fill +#define FILLED_SHAPE 1 // Poly, Squar, Circle, Arc = option Fill with current color +#define FILLED_WITH_BG_BODYCOLOR 2 // Poly, Squar, Circle, Arc = option Fill + // with background body color + +//Offsets used in editing library component, for handle aliad dats +#define ALIAS_NAME 0 +#define ALIAS_DOC 1 +#define ALIAS_KEYWORD 2 +#define ALIAS_DOC_FILENAME 3 +#define ALIAS_NEXT 4 + + +typedef enum { + LOCATE_COMPONENT_ARC_DRAW_TYPE = 1, + LOCATE_COMPONENT_CIRCLE_DRAW_TYPE = 2, + LOCATE_COMPONENT_GRAPHIC_TEXT_DRAW_TYPE = 4, + LOCATE_COMPONENT_RECT_DRAW_TYPE = 8, + LOCATE_LINE_DRAW_TYPE = 0x10, + LOCATE_COMPONENT_POLYLINE_DRAW_TYPE = 0x20, + LOCATE_COMPONENT_LINE_DRAW_TYPE = 0x40 +} LocateDrawStructType; + +#define LOCATE_ALL_DRAW_ITEM 0xFFFFFFFF + +/* flags utilises dans FindLibPart() : */ +#define FIND_ROOT 0 /* indique la recherche du composant racine si + meme si le composant specifie est un alias */ +#define FIND_ALIAS 1 /* indique la recherche du composant specifie + (alias ou racine) */ + +/* definition des types des structures d'elements de librairie */ +typedef enum { + ROOT, /* Structure est a standard EDA_LibComponentStruct */ + ALIAS /* Structure is an alias */ +} LibrEntryType; + +/* valeur du membre .m_Options */ +typedef enum { + ENTRY_NORMAL, // Libentry is standard + ENTRY_POWER // Libentry is a power symbol +} LibrEntryOptions; + +/* Definitions des Pins */ + +typedef enum { /* Type des Pins. si modif: modifier tableau des mgs suivant */ + PIN_INPUT, + PIN_OUTPUT, + PIN_BIDI, + PIN_TRISTATE, + PIN_PASSIVE, + PIN_UNSPECIFIED, + PIN_POWER_IN, + PIN_POWER_OUT, + PIN_OPENCOLLECTOR, + PIN_OPENEMITTER, + PIN_NC, /* No connect */ + PIN_NMAX /* Valeur limite ( utilisee comme limite de tableaux) */ +} ElectricPinType; + +/* Messages d'affichage du type electrique */ +eda_global wxChar * MsgPinElectricType[] +#ifdef MAIN + = { + wxT("input"), + wxT("output"), + wxT("BiDi"), + wxT("3state"), + wxT("passive"), + wxT("unspc"), + wxT("power_in"), + wxT("power_out"), + wxT("openCol"), + wxT("openEm"), + wxT("?????") + } +#endif + ; + +/* Autres bits: bits du membre .Flag des Pins */ +#define PINNOTDRAW 1 /* si 1: pin invisible */ + +typedef enum { /* Forme des Pins */ + NONE = 0, + INVERT = 1, + CLOCK = 2, + LOWLEVEL_IN = 4, + LOWLEVEL_OUT = 8 + } DrawPinShape; + +typedef enum { /* Orientation des Pins */ + PIN_RIGHT = 'R', + PIN_LEFT = 'L', + PIN_UP = 'U', + PIN_DOWN = 'D', + } DrawPinOrient; + +/*************************************/ +/* Classe representant une librairie */ +/*************************************/ + +class LibraryStruct +{ +public: + int m_Type; /* type indicator */ + wxString m_Name; /* Name of library loaded. */ + wxString m_FullFileName; /* Full File Name (with path) of library loaded. */ + wxString m_Header; /* first line of library loaded. */ + int m_NumOfParts; /* Number of parts this library has. */ + PriorQue * m_Entries; /* Parts themselves are saved here. */ + LibraryStruct * m_Pnext; /* Point on next lib in chain. */ + int m_Modified; /* flag indicateur d'edition */ + int m_Size; // Size in bytes (for statistics) + long m_TimeStamp; // Signature temporelle + int m_Flags; // variable used in some functions + bool m_IsLibCache; // False for the "standard" libraries, + // True for the library cache + +public: + LibraryStruct(int type, const wxString & name, const wxString & fullname); + ~LibraryStruct(); + bool WriteHeader(FILE * file); + bool ReadHeader(FILE * file, int * LineNum); +}; + + +/*******************************************************************/ +/* Classes representant les eléments d'un composant d'une libraire */ +/*******************************************************************/ + + +/* class LibEDA_BaseStruct : Basic class for items used in a library component + (graphic shapes, texts, fields, pins) +*/ + +class LibEDA_BaseStruct : public EDA_BaseStruct +{ +public: + int m_Unit; /* Unit identification (for multi part per parkage) + 0 if the item is common to all units */ + int m_Convert; /* Shape identification (for parts which have a convert shape) + 0 if the item is common to all shapes */ + +public: + LibEDA_BaseStruct * Next(void) {return (LibEDA_BaseStruct *) Pnext;} + LibEDA_BaseStruct(int struct_type); + virtual ~LibEDA_BaseStruct(void){} + void Display_Infos_DrawEntry(WinEDA_DrawFrame * frame); +}; + +class LibDrawPin : public LibEDA_BaseStruct +{ +public: + wxPoint m_Pos; /* Pin position */ + short m_PinLen; /* Pin lenght */ + short m_Orient; /* Pin orientation (Up, Down, Left, Right) */ + short m_PinShape; /* Bitwise ORed: Pin shape (see enum DrawPinShape) */ + char m_PinType; /* Electrical pin properties */ + char m_Attributs; /* bit 0 != 0: pin invisible */ + long m_PinNum; /* Pin number: 4 Ascii code like + "12" or "anod" or "G6" + "12" is really "12\0\0"*/ + wxString m_PinName; + short m_SizeNum, m_SizeName; /* Pin num and Pin name sizes */ + +public: + LibDrawPin(void); + ~LibDrawPin(void) {} + LibDrawPin * GenCopy(void); + bool WriteDescr( FILE * File ); + void Display_Infos(WinEDA_DrawFrame * frame); + wxPoint ReturnPinEndPoint(void); + int ReturnPinDrawOrient(int TransMat[2][2]); + void ReturnPinStringNum(wxString & buffer); + void SetPinNumFromString(wxString & buffer); + void DrawPinTexts(WinEDA_DrawPanel * panel, wxDC * DC, + wxPoint & pin_pos, int orient, + int TextInside, bool DrawPinNum, bool DrawPinName, + int Color, int DrawMode); + void PlotPinTexts(wxPoint & pin_pos, int orient, + int TextInside, bool DrawPinNum, bool DrawPinName); +}; + + +class LibDrawArc : public LibEDA_BaseStruct +{ +public: + wxPoint m_Pos; /* Position du point de reference (Centre)*/ + int m_Rayon; + int m_Width; + int m_Fill; + int t1, t2; /* position des 2 extremites de l'arc en 0,1 degres */ + wxPoint m_Start, m_End; /* position des 2 extremites de l'arc en coord reelles*/ + +public: + LibDrawArc(void); + ~LibDrawArc(void){} + LibDrawArc * GenCopy(void); + bool WriteDescr( FILE * File ); +}; + +class LibDrawCircle : public LibEDA_BaseStruct +{ +public: + wxPoint m_Pos; /* Position du point de reference */ + int m_Rayon; + int m_Width; + int m_Fill; + +public: + LibDrawCircle(void); + ~LibDrawCircle(void){} + LibDrawCircle * GenCopy(void); + bool WriteDescr( FILE * File ); +}; + +class LibDrawText : public LibEDA_BaseStruct +{ +public: + wxPoint m_Pos; /* Position du point de reference */ + int m_Horiz; + wxSize m_Size; + int m_Type; + wxString m_Text; + +public: + LibDrawText(void); + ~LibDrawText(void){} + LibDrawText * GenCopy(void); + bool WriteDescr( FILE * File ); +}; + +class LibDrawSquare : public LibEDA_BaseStruct +{ +public: + wxPoint m_Start; + wxPoint m_End; + int m_Width; + int m_Fill; + +public: + LibDrawSquare(void); + ~LibDrawSquare(void){} + LibDrawSquare * GenCopy(void); + bool WriteDescr( FILE * File ); +}; + +class LibDrawSegment : public LibEDA_BaseStruct +{ +public: + wxPoint m_Start; + wxPoint m_End; + int m_Width; + +public: + LibDrawSegment(void); + ~LibDrawSegment(void){} + LibDrawSegment * GenCopy(void); + bool WriteDescr( FILE * File ); +}; + +class LibDrawPolyline : public LibEDA_BaseStruct +{ +public: + int n, *PolyList; + int m_Width; + int m_Fill; + +public: + LibDrawPolyline(void); + ~LibDrawPolyline(void){ if ( PolyList ) free(PolyList);} + LibDrawPolyline * GenCopy(void); + void AddPoint(const wxPoint & point); + bool WriteDescr( FILE * File ); +}; + +/* Fields identiques aux fields des composants, pouvant etre predefinis en lib +2 Fields sont toujours presents : Prefix (U, IC..) et Name (74LS00..)*/ +class LibDrawField : public LibEDA_BaseStruct +{ +public: + int m_FieldId; // 0 a 11 + // 0 = Name 1 = Valeur 2 .. 11 autres fields + wxPoint m_Pos; + wxSize m_Size; + int m_Orient; /* Orientation */ + int m_Attributs; /* Attributs (Non visible ...) */ + int m_HJustify, m_VJustify; /* Justifications Horiz et Vert du texte */ + wxString m_Text; /* Field Data */ + wxString m_Name; /* Field Name */ + +public: + LibDrawField(int idfield = 2); + ~LibDrawField(void); + + LibDrawField * GenCopy(void); + void Copy(LibDrawField * Target); + bool WriteDescr( FILE * File ); +}; + + +/* classe de base de description des composants en librairie */ +class LibCmpEntry : public EDA_BaseStruct +{ +public: + LibrEntryType Type; /* Type = ROOT; + = ALIAS pour struct LibraryAliasType */ + LibDrawField m_Name; // name (74LS00 ..) in lib ( = VALUE ) + wxString m_Doc; /* ligne de documentation */ + wxString m_KeyWord; /* liste des mots cles */ + wxString m_DocFile; /* nom du fichier Doc Associe */ + LibrEntryOptions m_Options; // special features (i.e. Entry is a POWER) + +public: + LibCmpEntry(LibrEntryType CmpType, const wxChar * CmpName); + virtual ~LibCmpEntry(void); + bool WriteDescr( FILE * File ); +}; + +class EDA_LibComponentStruct: public LibCmpEntry /* composant "racine" */ +{ +public: + LibDrawField m_Prefix; /* Prefix ( U, IC ... ) = REFERENCE */ + wxArrayString m_AliasList; /* ALIAS list for the component */ + wxArrayString m_FootprintList; /* list of suitable footprint names for the component (wildcard names accepted)*/ + int m_UnitCount; /* Units (or sections) per package */ + bool m_UnitSelectionLocked; // True if units are differents and their selection is locked + // (i.e. if part A cannot be automatically changed in part B + int m_TextInside; /* if 0: pin name drawn on the pin itself + if > 0 pin name drawn inside the component, + with a distance of m_TextInside in mils */ + bool m_DrawPinNum; + bool m_DrawPinName; + LibDrawField *Fields; /* Auxiliairy Field list (id = 2 a 11*/ + LibEDA_BaseStruct * m_Drawings; /* How to draw this part */ + long m_LastDate; // Last change Date + +public: + EDA_LibComponentStruct( const wxChar * CmpName); + EDA_Rect GetBoundaryBox( int Unit, int Convert); /* return Box around the part. */ + ~EDA_LibComponentStruct( void ); + void SortDrawItems(void); +}; + +class EDA_LibCmpAliasStruct: public LibCmpEntry +{ +public: + wxString m_RootName; /* Part name pour le composant de reference */ + +public: + EDA_LibCmpAliasStruct( const wxChar * CmpName, const wxChar * CmpRootName); + ~EDA_LibCmpAliasStruct(void); +}; + +/* Variables */ +extern LibraryStruct *LibraryList; /* All part libs are saved here. */ + +/* Variables Utiles pour les editions de composants en librairie */ +eda_global LibEDA_BaseStruct * LibItemToRepeat; /* pointeur sur l'élément que l'on + peut répéter (Pin..;) */ +eda_global LibraryStruct *CurrentLib; /* Pointeur sur la librairie du + composant en cours d'edition */ +eda_global EDA_LibComponentStruct *CurrentLibEntry; /* pointeur sur le composant en + cours d'edition */ +eda_global LibEDA_BaseStruct * CurrentDrawItem; /* pointeur sur les + elements de dessin du comp. en edition */ + +eda_global wxString CurrentAliasName; // Nom de l'alias selectionné +eda_global bool g_AsDeMorgan; // Pour libedit: +eda_global int CurrentUnit +#ifdef MAIN + = 1 +#endif +; +eda_global int CurrentConvert /* Convert = 1 .. 255 */ +#ifdef MAIN + = 1 +#endif +; + + +eda_global wxString FindLibName; /* nom de la librairie ou a ete trouve le + dernier composant recherche par FindLibPart() */ + +#endif // LIBCMP_H + diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp new file mode 100644 index 0000000000..9a37dcb87a --- /dev/null +++ b/eeschema/libedit.cpp @@ -0,0 +1,619 @@ + /****************************/ + /* EESchema - libedit.cpp */ + /****************************/ + +/* Routines de maintenanace des librairies: + sauvegarde, modification de librairies. + creation edition suppression de composants +*/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +#include "id.h" +#include "dialog_create_component.h" + +/* Routines locales */ + +/* Variables locales */ + + +/**********************************************/ +void WinEDA_LibeditFrame::DisplayLibInfos(void) +/**********************************************/ +/* Affiche dans la zone messages la librairie , et le composant edite */ +{ +wxString msg = wxT("Libedit: "); + + msg += CurrentLib ? CurrentLib->m_FullFileName : wxT("No Lib"); + SetTitle(msg); + + msg = _(" Part: "); + if ( CurrentLibEntry == NULL ) + { + msg += _("None"); + } + else + { + msg += CurrentLibEntry->m_Name.m_Text; + if ( !CurrentAliasName.IsEmpty() ) + msg << wxT(" Alias ") << CurrentAliasName; + } +wxChar UnitLetter[] = wxT("?ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + msg << wxT(" Unit ") << UnitLetter[CurrentUnit]; + + if ( CurrentConvert > 1 ) msg += _(" Convert"); + else msg += _(" Normal"); + + if ( CurrentLibEntry && (CurrentLibEntry->m_Options == ENTRY_POWER) ) + msg += _(" (Power Symbol)"); + + SetStatusText(msg, 0); +} + + +/**************************************************/ +void WinEDA_LibeditFrame::SelectActiveLibrary(void) +/**************************************************/ +/* Routine to Select Current library +*/ +{ +LibraryStruct *Lib; + + Lib = SelectLibraryFromList(this); + if( Lib ) + { + CurrentLib = Lib; + } + DisplayLibInfos(); +} + +/*************************************************/ +/* Routine to Load one selected library content. */ +/*************************************************/ +bool WinEDA_LibeditFrame::LoadOneLibraryPart(void) +{ +int i; +wxString msg; +wxString CmpName; +EDA_LibComponentStruct *LibEntry = NULL; + + if( ScreenLib->IsModify() ) + { + if( ! IsOK(this, _("Current Part not saved, continue ?") ) ) return FALSE; + } + + if(CurrentLib == NULL) SelectActiveLibrary(); + if(CurrentLib == NULL) return FALSE; + + i = GetNameOfPartToLoad(this, CurrentLib, CmpName); + if( i == 0) return FALSE; + + ScreenLib->ClrModify(); + CurrentDrawItem = NULL; + // Effacement ancien composant affiché + if( CurrentLibEntry) + { + delete CurrentLibEntry; + CurrentLibEntry = NULL; + } + + /* Chargement du composant */ + LibEntry = FindLibPart(CmpName.GetData(),CurrentLib->m_Name, FIND_ALIAS); + + if( LibEntry == NULL) + { + msg = _("Component "); msg << CmpName << _(" not found"); + DisplayError(this, msg, 20); + return FALSE; + } + + LoadOneLibraryPartAux(LibEntry, CurrentLib); + ReCreateHToolbar(); + Zoom_Automatique(FALSE); + ReDrawPanel(); + return TRUE; +} + +/**************************************************************************/ +int WinEDA_LibeditFrame::LoadOneLibraryPartAux(EDA_LibComponentStruct *LibEntry, + LibraryStruct *Library, int noMsg) +/**************************************************************************/ +/* Routine Pour Charger en memoire la copie de 1 libpart. +retourne + 0 si OK + 1 si err + CurrentLibEntry pointe la copie ainsi creee +*/ +{ +wxString msg; +const wxChar * CmpName, *RootName = NULL; + + if( (LibEntry == NULL) || (Library == NULL) ) return(1); + + CmpName = LibEntry->m_Name.m_Text.GetData(); + CurrentAliasName.Empty(); + if( LibEntry->Type != ROOT) + { + RootName = ((EDA_LibCmpAliasStruct*)LibEntry)->m_RootName.GetData() ; + if( !noMsg ) + { + msg.Printf( wxT("<%s> is Alias of <%s>"), CmpName, RootName); + } + + LibEntry = FindLibPart(RootName,Library->m_Name,FIND_ROOT); + + if( LibEntry == NULL) + { + msg.Printf( wxT("Root Part <%s> not found"), RootName); + DisplayError(this, msg, 20); + return(1); + } + CurrentAliasName = CmpName; + } + + if( CurrentLibEntry) delete CurrentLibEntry; + + CurrentLibEntry = CopyLibEntryStruct(this, LibEntry); + CurrentUnit = 1; CurrentConvert = 1; + DisplayLibInfos(); + + BuildAliasData(Library, CurrentLibEntry); + + ScreenLib->ClrModify(); + g_AsDeMorgan = 0; + + if( LookForConvertPart(CurrentLibEntry) > 1 ) g_AsDeMorgan = 1; + + return(0); +} + +/*********************************************************************/ +void WinEDA_LibeditFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg) +/*********************************************************************/ +/* Routine generale d'affichage a l'ecran du "PartLib" en cours d'edition */ +{ + if( m_CurrentScreen == NULL ) return; + + ActiveScreen = GetScreen(); + + DC->SetBackground(*wxBLACK_BRUSH ); + DC->SetBackgroundMode(wxTRANSPARENT); + GRResetPenAndBrush(DC); // reinit de la brosse et plume courante + + DrawPanel->CursorOff(DC); // effacement curseur + if(DrawPanel->ManageCurseur) + { + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); // effacement affichage lie au curseur + } + + if (EraseBg ) DrawPanel->EraseScreen(DC); + + DrawPanel->DrawBackGround(DC); + + if( CurrentLibEntry) + DrawLibEntry(DrawPanel, DC, CurrentLibEntry, 0, 0, + CurrentUnit, CurrentConvert, GR_DEFAULT_DRAWMODE); + + DrawPanel->CursorOn(DC); // reaffichage curseur + + if(DrawPanel->ManageCurseur) + { + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); // reaffichage lie au curseur + } + + m_CurrentScreen->ClrRefreshReq(); + DisplayLibInfos(); + Affiche_Status_Box(); +} + + +/*************************************************/ +void WinEDA_LibeditFrame::SaveActiveLibrary(void) +/*************************************************/ +/* Sauvegarde en fichier la librairie pointee par CurrentLib + une sauvegarde en .bak de l'ancien fichier est egalement cree +*/ +{ +wxString Name, msg; +int err; + + if(CurrentLib == NULL) + { + DisplayError(this, wxT("No Library specified")); return; + } + + Name = MakeFileName(g_RealLibDirBuffer, CurrentLib->m_Name, g_LibExtBuffer); + + msg = _("Ok to modify Library File ") + Name; + if( ! IsOK(this, msg) ) return; + + err = SaveOneLibrary(this, Name, CurrentLib); + + MsgPanel->EraseMsgBox(); + + if ( err ) + { + msg = _("Error while saving Library File ") + Name; + Affiche_1_Parametre(this, 1, wxT(" *** ERROR : **"), msg,BLUE); + DisplayError(this, msg); + } + else + { + msg = _("Library File ") + Name + wxT(" Ok"); + ChangeFileNameExt(Name,DOC_EXT); + wxString msg1 = _("Document File ") + Name + wxT(" Ok"); + Affiche_1_Parametre(this, 1,msg, msg1,BLUE); + } +} + + +/**************************************************************/ +void WinEDA_LibeditFrame::DisplayCmpDoc(const wxString & Name) +/**************************************************************/ +/* +Affiche la documentation du composant selectionne +Utilisée lors de l'affichage de la liste des composants en librairie +*/ +{ +LibCmpEntry * CmpEntry; + + if( CurrentLib == NULL ) return; + MsgPanel->EraseMsgBox(); + CmpEntry = FindLibPart(Name.GetData(), CurrentLib->m_Name, FIND_ALIAS); + if ( CmpEntry == NULL ) return; + + AfficheDoc(this, CmpEntry->m_Doc,CmpEntry->m_KeyWord); +} + +/*********************************************/ +void WinEDA_LibeditFrame::DeleteOnePart(void) +/*********************************************/ +/* Routine de suppression d'un composant dans la librairie courante + (effacement en memoire uniquement, le fichier n'est pas modifie) + Le composant peut etre un alias, ou la definition de base. + Si c'est un alias: + il est supprime, et la liste des alias de la definition + de base est modifiee + Si c'est le composant de base: + Si la liste des alias est nulle, il est supprime + Sinon le premier alias devient le composant de base, et les autres + alias deviennent dependants de celui ci. +*/ +{ +wxString CmpName; +int NumOfParts; +EDA_LibComponentStruct *LibEntry; +WinEDAListBox * ListBox; +const wxChar ** ListNames; +wxString msg; + + CurrentDrawItem = NULL; + + if(CurrentLib == NULL) + { + SelectActiveLibrary(); + if(CurrentLib == NULL) + { + DisplayError(this, _("No Active Library"), 20); return; + } + } + + NumOfParts = 0; + PQCompFunc((PQCompFuncType) LibraryEntryCompare); + LibEntry = (EDA_LibComponentStruct *) PQFirst(&CurrentLib->m_Entries, FALSE); + while( LibEntry != NULL ) + { + NumOfParts++; + LibEntry = (EDA_LibComponentStruct *) + PQNext(CurrentLib->m_Entries, LibEntry, NULL); + } + + ListNames = (const wxChar**) MyZMalloc((NumOfParts+1) * sizeof(wxChar*)); + LibEntry = (EDA_LibComponentStruct *) PQFirst(&CurrentLib->m_Entries, FALSE); + msg.Printf( _("Select Component (%d items)"), NumOfParts); + NumOfParts = 0; + while( LibEntry != NULL ) + { + ListNames[NumOfParts] = LibEntry->m_Name.m_Text.GetData(); + NumOfParts++; + LibEntry = (EDA_LibComponentStruct *) + PQNext(CurrentLib->m_Entries, LibEntry, NULL); + } + + ListBox = new WinEDAListBox(this, msg, + ListNames, wxEmptyString, NULL /*DisplayCmpDoc*/, + wxColour(255,255,200)); + + + int ii = ListBox->ShowModal(); ListBox->Destroy(); + + if( ii >= 0) + { + CmpName = ListNames[ii]; + LibEntry = FindLibPart(CmpName.GetData(), CurrentLib->m_Name, FIND_ALIAS); + + if( LibEntry == NULL ) + DisplayError(this, _("Component not found"), 20); + + else + { + msg = _("Delete component ") + LibEntry->m_Name.m_Text + + _(" in library ") + CurrentLib->m_Name + wxT("?"); + if( IsOK(this, msg) ) + { + DeletePartInLib( CurrentLib, LibEntry ); + } + } + } + + free (ListNames); +} + + +/****************************************************/ +void WinEDA_LibeditFrame::CreateNewLibraryPart(void) +/****************************************************/ +/* Routine to create a new library component + If an old component is currently in edit, it is deleted. +*/ +{ +wxString msg; +EDA_LibComponentStruct * NewStruct; +int diag; + + if( CurrentLibEntry ) + if( ! IsOK(this, _("Delete old component ?")) ) return; + + CurrentDrawItem = NULL; + + WinEDA_CreateCmpDialog Dialogbox(this); + diag = Dialogbox.ShowModal(); + if ( diag != wxID_OK ) return; + msg = Dialogbox.ReturnCmpName(); + if ( msg.IsEmpty() ) return; + msg.MakeUpper(); msg.Replace(wxT(" "), wxT("_") ); + + /* Test: y a t-il un composant deja de ce nom */ + if(CurrentLib) + { + if( FindLibPart(msg.GetData(), CurrentLib->m_Name, FIND_ALIAS) ) + { + wxString msg; + msg << _("Component ") << msg << + _(" exists in library ") << CurrentLib->m_Name; + DisplayError(this, msg); + return; + } + } + + NewStruct = new EDA_LibComponentStruct( msg); + Dialogbox.SetComponentData(*NewStruct); + if ( NewStruct->m_Prefix.m_Text.IsEmpty()) + NewStruct->m_Prefix.m_Text = wxT("U"); + NewStruct->m_Prefix.m_Text.MakeUpper(); + + // Effacement ancien composant affiché + if( CurrentLibEntry) delete CurrentLibEntry; + CurrentLibEntry = NewStruct; + CurrentUnit = 1; + CurrentConvert = 1; + ReCreateHToolbar(); + + DisplayLibInfos(); +} + + + + +/*******************************************************************/ +void WinEDA_LibeditFrame::DeletePartInLib( LibraryStruct * Library, + EDA_LibComponentStruct *Entry) +/*******************************************************************/ +/* Suppression du composant Entry en librairie Library. + (effacement en memoire uniquement, le fichier n'est pas modifie) + Le composant peut etre un alias, ou la definition de base. + Si c'est un alias: + il est supprime, et la liste des alias de la definition + de base est modifiee + Si c'est le composant de base: + Si la liste des alias est nulle, il est supprime + Sinon le premier alias devient le composant de base, et les autres + alias deviennent dependants de celui ci. +*/ +{ +EDA_LibComponentStruct *RootEntry; +EDA_LibCmpAliasStruct * AliasEntry; + + if ( (Library == NULL) || (Entry == NULL) ) return; + + PQCompFunc((PQCompFuncType) LibraryEntryCompare); + Library->m_Modified = 1; + + if( Entry->Type == ALIAS ) + { + RootEntry = FindLibPart( ((EDA_LibCmpAliasStruct*)Entry)->m_RootName.GetData(), + Library->m_Name,FIND_ROOT); + /* Remove alias name from the root component alias list */ + if( RootEntry == NULL ) + { + DisplayError(this, wxT("Warning: for Alias, root not found"), 30); + } + else + { + int index = wxNOT_FOUND; + if( RootEntry->m_AliasList.GetCount() != 0) + { + index = RootEntry->m_AliasList.Index(Entry->m_Name.m_Text.GetData(), FALSE ); + if ( index != wxNOT_FOUND ) RootEntry->m_AliasList.RemoveAt(index); + } + if ( index == wxNOT_FOUND ) + DisplayError(this, wxT("Warning: Root for Alias as no alias list"), 30); + } + + /* Effacement memoire pour cet alias */ + PQDelete( &Library->m_Entries, (void*) Entry ); + delete Entry; + if( Library->m_NumOfParts > 0 ) CurrentLib->m_NumOfParts --; + return; + } + + /* Entry is a standard component (not an alias) */ + if( Entry->m_AliasList.GetCount() == 0) // Trivial case: no alias, we can safety delete e=this entry + { + PQDelete( &Library->m_Entries, Entry ); + delete Entry; + if( Library->m_NumOfParts > 0 ) Library->m_NumOfParts --; + return; + } + + /* Entry is a component with alias + We must change the first alias to a "root" component, and for all the aliases + we must change the root component (which is deleted) by the first alias */ + wxString AliasName = Entry->m_AliasList[0]; + + /* The root component is not really deleted, it is renamed with the first alias name */ + AliasEntry = (EDA_LibCmpAliasStruct*) FindLibPart( + AliasName.GetData(), Library->m_Name, FIND_ALIAS); + if( AliasEntry == NULL ) + { + wxString msg; + msg.Printf(wxT("Warning: Alias <%s> not found"), AliasName.GetData()); + DisplayError(this, msg, 30); + } + + else + { + if( Library->m_NumOfParts > 0 ) Library->m_NumOfParts --; + + /* remove the root component from library */ + PQDelete( &Library->m_Entries, Entry ); + + /* remove the first alias from library*/ + PQDelete( &Library->m_Entries, AliasEntry ); + + /* remove the first alias name from alias list: */ + Entry->m_AliasList.RemoveAt(0); + /* change the old name. New name for "root" is the name of the first alias */ + Entry->m_Name.m_Text = AliasName; + Entry->m_Doc = AliasEntry->m_Doc; + + Entry->m_KeyWord = AliasEntry->m_KeyWord; + + FreeLibraryEntry((EDA_LibComponentStruct *)AliasEntry); + + /* root component (renamed) placed in library */ + PQInsert( &Library->m_Entries, Entry); + } + + /* Change the "RootName", for other aliases */ + for( unsigned ii = 0; ii < Entry->m_AliasList.GetCount(); ii++ ) + { + AliasName = Entry->m_AliasList[ii]; + + AliasEntry = (EDA_LibCmpAliasStruct*) FindLibPart( + AliasName.GetData(), Library->m_Name, FIND_ALIAS); + if( AliasEntry == NULL ) + { // Should not occurs. If happens, this is an error (or bug) + wxString msg; + msg.Printf( wxT("Warning: Alias <%s> not found"), AliasName.GetData()); + DisplayError(this, msg, 30); + continue; + } + if( AliasEntry->Type != ALIAS ) + { // Should not occurs. If happens, this is an error (or bug) + wxString msg; + msg.Printf( wxT("Warning: <%s> is not an Alias"), AliasName.GetData()); + DisplayError(this, msg, 30); + continue; + } + AliasEntry->m_RootName = Entry->m_Name.m_Text; + } +} + + +/***************************************************/ +void WinEDA_LibeditFrame::SaveOnePartInMemory(void) +/***************************************************/ +/* Routine de sauvegarde de la "partlib" courante dans la librairie courante + Sauvegarde en memoire uniquement, et PAS sur fichier + La routine efface l'ancien composant ( ou / et les alias ) a remplacer + s'il existe, et sauve le nouveau et cree les alias correspondants. +*/ +{ +EDA_LibComponentStruct *Entry; +EDA_LibCmpAliasStruct *AliasEntry; +wxString msg; +bool NewCmp = TRUE; + + if(CurrentLibEntry == NULL) + { + DisplayError(this, _("Warning: No component to Save") ); return; + } + + if(CurrentLib == NULL) SelectActiveLibrary(); + + if(CurrentLib == NULL) + { + DisplayError(this, _("No Library specified"), 20); return; + } + + CurrentLib->m_Modified = 1; + ScreenLib->ClrModify(); + + PQCompFunc((PQCompFuncType) LibraryEntryCompare); + + if( (Entry = FindLibPart(CurrentLibEntry->m_Name.m_Text.GetData(), + CurrentLib->m_Name, FIND_ROOT)) != NULL) + { + msg.Printf( _("Component %s exists, Change it ?"), + Entry->m_Name.m_Text.GetData()); + if( !IsOK(this, msg) ) return; + NewCmp = FALSE; + } + + /* Effacement des alias deja existants en librairie */ + for ( unsigned ii = 0; ii < CurrentLibEntry->m_AliasList.GetCount(); ii += ALIAS_NEXT ) + { + EDA_LibComponentStruct * LocalEntry; + wxString aliasname = CurrentLibEntry->m_AliasList[ii+ALIAS_NAME]; + while( (LocalEntry = FindLibPart(aliasname.GetData(), CurrentLib->m_Name, FIND_ALIAS)) != NULL ) + { + DeletePartInLib( CurrentLib, LocalEntry ); + } + } + + if( !NewCmp )DeletePartInLib( CurrentLib, Entry ); + + Entry = CopyLibEntryStruct(this, CurrentLibEntry); + Entry->m_AliasList.Clear(); + PQInsert( &CurrentLib->m_Entries, (void*)Entry ); + CurrentLib->m_NumOfParts ++; + + /* Creation des nouveaux alias */ + for ( unsigned ii = 0; ii < CurrentLibEntry->m_AliasList.GetCount(); ii += ALIAS_NEXT ) + { + wxString aliasname = CurrentLibEntry->m_AliasList[ii+ALIAS_NAME]; + Entry->m_AliasList.Add(aliasname); + AliasEntry = new EDA_LibCmpAliasStruct(aliasname.GetData(), Entry->m_Name.m_Text); + AliasEntry->m_Doc = CurrentLibEntry->m_AliasList[ii+ALIAS_DOC]; + AliasEntry->m_KeyWord = CurrentLibEntry->m_AliasList[ii+ALIAS_KEYWORD]; + AliasEntry->m_DocFile = CurrentLibEntry->m_AliasList[ii+ALIAS_DOC_FILENAME]; + + /* Placement en liste des composants de l'Alias */ + PQInsert( &CurrentLib->m_Entries, (void*) AliasEntry ); + CurrentLib->m_NumOfParts ++; + } + + msg.Printf( _("Component %s saved in %s"), + Entry->m_Name.m_Text.GetData(), CurrentLib->m_Name.GetData()); + Affiche_Message(msg); +} + diff --git a/eeschema/libedit_icon.ico b/eeschema/libedit_icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..13d9821138cd73d068a78f1ba19896147a42c60a GIT binary patch literal 3262 zcmds(%T8KR6owDMS~VKQd)qW|(xgw|xJgHjY!j0{LTwuCu$^I_povf5unszHIwMhw zcTo|%;RO{G6j2luQUCsXA2~gUun$d|CS9CE;IR4rwbxpE?X77xzB)QIzPD>%Yc;J^ z)3oQj`AB=gTRa!m&)@zx!_5sc8JwJ8e;-?0SYC$Li?K1d-JI(8KecazgL7qPH_xjD?vVtN`=Q<#_#Uj6)ukr50J)33*^B2V}8LBQhB z(2&dJ>gnkb5*r%`2C=$&E8+LU=fnK`Z;8oCjE@@<3Vtp=2#2w=gHUMDvccoQ=qUM* zT3U+wZ}1}#?Cvs3#KVG#Vf?ShLw2x~d@pz$#7$$4UD*xaB(I}aD_VG%4`Nh%pbYNh>?RIxc z8(~=jf(j_Dos<%0|FusL*ZUpqS$9=cmGkHyO1_rBv46nw+~L;~@6UU2xObbPp|y}L*Jr%7rkudm$HEDh#hOzbeeB?Jf9P0R-ok2<%e6|0wyISR^ z)1X8$Y4GWiBK~aPen0t54Gn7l&(D!caaf*}t{?7Dfq;U4r~XqZv;T_qoIv6D1 zVTI4rg_JP(>iU$20rKnX>eT*|e|?Q?*5I30Q{iVZOdbZvudS)E#FtYjgC7b}g8Z85 z>U;QH9j5b@$d0_ow`lr#gZzh;l|}h?>OU7Hk!xA5`l8lb6C1d`2kAShe%>JeK}AJT zzES@<|HUk1BE(^mi#pdg^zMqo!&?b?7~mAhx7+P%eqjnNKe5?tm_Flags ) + { + SaveCopyInUndoList(CurrentLibEntry); + switch (DrawEntry->m_StructType ) + { + case COMPONENT_PIN_DRAW_TYPE: + PlacePin(DC); + break; + + case COMPONENT_FIELD_DRAW_TYPE: + PlaceField(DC, (LibDrawField *) DrawEntry); + DrawEntry = NULL; + break; + + default: + EndDrawGraphicItem(DC); + break; + } + } + else + { + DrawEntry = LocatePin(m_CurrentScreen->m_Curseur, CurrentLibEntry, + CurrentUnit, CurrentConvert); + if (DrawEntry == NULL ) + { + DrawEntry = LocateDrawItem(GetScreen(), CurrentLibEntry,CurrentUnit, + CurrentConvert,LOCATE_ALL_DRAW_ITEM); + } + + if ( DrawEntry ) DrawEntry->Display_Infos_DrawEntry(this); + + else + { + EraseMsgBox(); + AfficheDoc(this, CurrentLibEntry->m_Doc.GetData(), + CurrentLibEntry->m_KeyWord.GetData()); + } + } + } + + if ( m_ID_current_state ) + { + switch ( m_ID_current_state ) + { + case ID_NO_SELECT_BUTT: + break; + + case ID_LIBEDIT_PIN_BUTT : + if( CurrentDrawItem == NULL ) + { + CreatePin(DC); + } + else + { + SaveCopyInUndoList(CurrentLibEntry); + PlacePin(DC); + } + break; + + case ID_LIBEDIT_BODY_LINE_BUTT : + case ID_LIBEDIT_BODY_ARC_BUTT : + case ID_LIBEDIT_BODY_CIRCLE_BUTT : + case ID_LIBEDIT_BODY_RECT_BUTT : + case ID_LIBEDIT_BODY_TEXT_BUTT : + if ( CurrentDrawItem == NULL) + { + CurrentDrawItem = CreateGraphicItem(DC); + } + else + { + if ( CurrentDrawItem->m_Flags & IS_NEW ) + GraphicItemBeginDraw(DC); + else + { + SaveCopyInUndoList(CurrentLibEntry); + EndDrawGraphicItem(DC); + } + } + break; + + case ID_LIBEDIT_DELETE_ITEM_BUTT : + DrawEntry = LocatePin(m_CurrentScreen->m_Curseur, CurrentLibEntry, + CurrentUnit, CurrentConvert); + if (DrawEntry == NULL ) + { + DrawEntry = LocateDrawItem(GetScreen(), CurrentLibEntry,CurrentUnit, + CurrentConvert,LOCATE_ALL_DRAW_ITEM); + } + + if ( DrawEntry == NULL ) + { + AfficheDoc(this, CurrentLibEntry->m_Doc.GetData(), + CurrentLibEntry->m_KeyWord.GetData()); + break; + } + SaveCopyInUndoList(CurrentLibEntry); + if ( DrawEntry->m_StructType == COMPONENT_PIN_DRAW_TYPE ) + DeletePin(DC, CurrentLibEntry, (LibDrawPin*)DrawEntry); + else + DeleteOneLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry,DrawEntry, TRUE); + DrawEntry = NULL; + m_CurrentScreen->SetModify(); + break; + + case ID_LIBEDIT_ANCHOR_ITEM_BUTT : + SaveCopyInUndoList(CurrentLibEntry); + PlaceAncre(); + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + break; + + + default : + DisplayError(this, wxT("WinEDA_LibeditFrame::OnLeftClick error") ); + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + break; + } + } +} + + +/*************************************************************************/ +void WinEDA_LibeditFrame::OnLeftDClick(wxDC * DC, const wxPoint& MousePos) +/*************************************************************************/ +/* Appelé sur un double click: + pour un élément editable (textes, composant): + appel de l'editeur correspondant. + pour une connexion en cours: + termine la connexion +*/ +{ +wxPoint pos = GetPosition(); +LibEDA_BaseStruct* DrawEntry = CurrentDrawItem; + + if ( CurrentLibEntry == NULL ) return; + + if ( !m_ID_current_state || // Simple localisation des elements + (DrawEntry == NULL) || (DrawEntry->m_Flags == 0) ) + { + DrawEntry = LocatePin(m_CurrentScreen->m_Curseur, CurrentLibEntry, + CurrentUnit, CurrentConvert); + if ( DrawEntry == NULL ) + { + DrawEntry = CurrentDrawItem = LocateDrawItem(GetScreen(), CurrentLibEntry,CurrentUnit, + CurrentConvert,LOCATE_ALL_DRAW_ITEM); + } + if ( DrawEntry == NULL ) + { + DrawEntry = CurrentDrawItem = (LibEDA_BaseStruct*) + LocateField(CurrentLibEntry); + } + if ( DrawEntry == NULL ) + { + wxPoint mpos; + wxGetMousePosition(&mpos.x, &mpos.y); + InstallLibeditFrame(mpos); + } + } + + // Si Commande en cours: affichage commande d'annulation + if ( m_ID_current_state ) + { + } + + else + { + } + + if ( DrawEntry ) DrawEntry->Display_Infos_DrawEntry(this); + else return; + + CurrentDrawItem = DrawEntry; + + DrawPanel->m_IgnoreMouseEvents = TRUE; + switch ( DrawEntry->m_StructType ) + { + case COMPONENT_PIN_DRAW_TYPE: + if( DrawEntry->m_Flags == 0 ) // Item localisé et non en edition: placement commande move + { + InstallPineditFrame(this, DC, pos); + } + break; + + case COMPONENT_ARC_DRAW_TYPE: + case COMPONENT_CIRCLE_DRAW_TYPE: + case COMPONENT_RECT_DRAW_TYPE: + if( DrawEntry->m_Flags == 0 ) + { + EditGraphicSymbol(DC, DrawEntry); + } + break; + + case COMPONENT_LINE_DRAW_TYPE: + case COMPONENT_POLYLINE_DRAW_TYPE: + if( DrawEntry->m_Flags == 0 ) + { + EditGraphicSymbol(DC, DrawEntry); + } + else if( DrawEntry->m_Flags & IS_NEW ) + { + EndDrawGraphicItem(DC); + } + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + if( DrawEntry->m_Flags == 0 ) + { + EditSymbolText(DC, DrawEntry); + } + break; + + case COMPONENT_FIELD_DRAW_TYPE: + if( DrawEntry->m_Flags == 0 ) + { + } + break; + + + default: + wxString msg; + msg.Printf( + wxT("WinEDA_LibeditFrame::OnLeftDClick Error: unknown StructType %d"), + DrawEntry->m_StructType); + DisplayError(this, msg ); + break; + } + DrawPanel->MouseToCursorSchema(); + DrawPanel->m_IgnoreMouseEvents = FALSE; +} + diff --git a/eeschema/libedit_onrightclick.cpp b/eeschema/libedit_onrightclick.cpp new file mode 100644 index 0000000000..55d4197301 --- /dev/null +++ b/eeschema/libedit_onrightclick.cpp @@ -0,0 +1,265 @@ + /****************************/ + /* EESchema - libedit_onrightclick.cpp */ + /****************************/ + +/* , In library editor, create the pop menu when clicking on mouse right button +*/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "bitmaps.h" +#include "protos.h" + +#include "id.h" + +#include "Pin_to.xpm" +#include "Pin_Size_to.xpm" +#include "Pin_Name_to.xpm" +#include "Pin_Number_to.xpm" +#include "Delete_Pin.xpm" + +/* functions to add commands and submenus depending on the item */ +static void AddMenusForBlock(wxMenu * PopMenu, WinEDA_LibeditFrame * frame); +static void AddMenusForPin(wxMenu * PopMenu, LibDrawPin* Pin, WinEDA_LibeditFrame * frame); + + +/********************************************************************************/ +void WinEDA_LibeditFrame::OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu) +/********************************************************************************/ +{ +LibEDA_BaseStruct* DrawEntry = CurrentDrawItem; +bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE); + + if ( CurrentLibEntry == NULL ) return; + + if ( (DrawEntry == NULL) || (DrawEntry->m_Flags == 0) ) + { // Simple localisation des elements + DrawEntry = LocatePin(m_CurrentScreen->m_Curseur, CurrentLibEntry, CurrentUnit, CurrentConvert); + if ( DrawEntry == NULL ) + { + DrawEntry = CurrentDrawItem = LocateDrawItem(GetScreen(), CurrentLibEntry,CurrentUnit, + CurrentConvert,LOCATE_ALL_DRAW_ITEM); + } + if ( DrawEntry == NULL ) + { + DrawEntry = CurrentDrawItem = (LibEDA_BaseStruct*) + LocateField(CurrentLibEntry); + } + } + + // If Command in progresss: put the menu "cancel" and "end tool" + if ( m_ID_current_state ) + { + if (DrawEntry && DrawEntry->m_Flags) + { + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, + _("Cancel"), cancel_xpm); + } + else + { + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, + _("End Tool"), cancel_tool_xpm); + } + PopMenu->AppendSeparator(); + } + + else + { + if ( (DrawEntry && DrawEntry->m_Flags) || BlockActive ) + { + if ( BlockActive ) AddMenusForBlock( PopMenu, this); + else ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, _("Cancel"), cancel_xpm); + PopMenu->AppendSeparator(); + } + } + + if ( DrawEntry ) DrawEntry->Display_Infos_DrawEntry(this); + else return; + + CurrentDrawItem = DrawEntry; + + switch ( DrawEntry->m_StructType ) + { + case COMPONENT_PIN_DRAW_TYPE: + AddMenusForPin(PopMenu, (LibDrawPin*)DrawEntry, this); + break; + + case COMPONENT_ARC_DRAW_TYPE: + if( DrawEntry->m_Flags == 0 ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, + _("Move Arc"), move_arc_xpm); + } + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, + _("Arc Options"), options_arc_xpm ); + if( DrawEntry->m_Flags == 0 ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, + _("Arc Delete"), delete_arc_xpm); + } + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + if( DrawEntry->m_Flags == 0 ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, + _("Move Circle"), move_circle_xpm); + } + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, + _("Circle Options"), options_circle_xpm); + if( DrawEntry->m_Flags == 0 ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, + _("Circle Delete"), delete_circle_xpm); + } + break; + + case COMPONENT_RECT_DRAW_TYPE: + if( DrawEntry->m_Flags == 0 ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, + _("Move Rect"), move_rectangle_xpm); + } + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, + _("Rect Options"), options_rectangle_xpm); + if( DrawEntry->m_Flags == 0 ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, + _("Rect Delete"), delete_rectangle_xpm); + } + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + if( DrawEntry->m_Flags == 0 ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, + _("Move Text"), move_text_xpm); + } + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, + _("Text Editor"), edit_text_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT, + _("Rotate Text"), edit_text_xpm); + if( DrawEntry->m_Flags == 0 ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, + _("Text Delete"), delete_text_xpm); + } + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + if( DrawEntry->m_Flags == 0 ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, + _("Move Line"), move_line_xpm); + } + if ( DrawEntry->m_Flags & IS_NEW ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_END_CREATE_ITEM, + _("Line End"), apply_xpm); + } + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, + _("Line Options"), options_segment_xpm); + if( DrawEntry->m_Flags == 0 ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, + _("Line Delete"), delete_segment_xpm); + } + else if( (DrawEntry->m_Flags & IS_NEW) ) + { + if( ((LibDrawPolyline*)DrawEntry)->n > 2 ) + ADD_MENUITEM(PopMenu, + ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT, + _("Segment Delete"), delete_segment_xpm); + } + break; + + case COMPONENT_FIELD_DRAW_TYPE: + if( DrawEntry->m_Flags == 0 ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, + _("Move Field"), move_field_xpm); + } + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM, + _("Field Rotate"), rotate_field_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM, + _("Field Edit"), edit_text_xpm); + break; + + + default: + wxString msg; + msg.Printf( + wxT("WinEDA_LibeditFrame::OnRightClick Error: unknown StructType %d"), + DrawEntry->m_StructType); + DisplayError(this, msg ); + CurrentDrawItem = NULL; + break; + } + PopMenu->AppendSeparator(); +} + +/**********************************************************************************/ +void AddMenusForPin(wxMenu * PopMenu, LibDrawPin* Pin, WinEDA_LibeditFrame * frame) +/**********************************************************************************/ +{ +bool selected = (Pin->m_Selected & IS_SELECTED) != 0; +bool not_in_move = (Pin->m_Flags == 0); + + if( not_in_move ) + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, _("Move Pin"), move_xpm ); + + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_PIN_EDIT, _("Pin Edit"), edit_xpm ); + + if( not_in_move ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, + _("Pin Delete"), delete_pin_xpm ); + } + wxMenu * global_pin_change = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU(PopMenu, global_pin_change, ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_ITEM, + _("Global"), pin_to_xpm); + ADD_MENUITEM(global_pin_change, ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM, + selected ? _("Pin Size to selected pins"): _("Pin Size to others"), + pin_size_to_xpm); + ADD_MENUITEM(global_pin_change, ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM, + selected ? _("Pin Name Size to selected pin") : _("Pin Name Size to others"), + pin_name_to_xpm); + ADD_MENUITEM(global_pin_change, ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM, + selected ?_("Pin Num Size to selected pin") : _("Pin Num Size to others"), + pin_number_to_xpm); +} + + +/**********************************************************************/ +void AddMenusForBlock(wxMenu * PopMenu, WinEDA_LibeditFrame * frame) +/**********************************************************************/ +/* Add menu commands for block +*/ +{ + ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, _("Cancel Block"), cancel_xpm); + + if ( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) + ADD_MENUITEM(PopMenu, ID_POPUP_ZOOM_BLOCK, + _("Win. Zoom (Midd butt drag mouse)"), zoom_selected_xpm); + + PopMenu->AppendSeparator(); + + ADD_MENUITEM(PopMenu, ID_POPUP_PLACE_BLOCK, _("Place Block"), apply_xpm ); + + if ( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_SELECT_ITEMS_BLOCK, _("Select items"), green_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_COPY_BLOCK, + _("Copy Block (shift + drag mouse)"), copyblock_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_INVERT_BLOCK, _("Mirror Block (ctrl + drag mouse)"), mirror_H_xpm ); + ADD_MENUITEM(PopMenu, ID_POPUP_DELETE_BLOCK, + _("Del. Block (shift+ctrl + drag mouse)"), delete_xpm ); + } +} + diff --git a/eeschema/libedit_undo_redo.cpp b/eeschema/libedit_undo_redo.cpp new file mode 100644 index 0000000000..c6c23ac205 --- /dev/null +++ b/eeschema/libedit_undo_redo.cpp @@ -0,0 +1,80 @@ + /********************************************/ + /* library editor: undo and redo functions */ + /********************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "id.h" + +#include "protos.h" + + +/*************************************************************************/ +void WinEDA_LibeditFrame::SaveCopyInUndoList(EDA_BaseStruct * ItemToCopy, + int unused_flag) +/*************************************************************************/ +{ +EDA_BaseStruct * item; +EDA_LibComponentStruct * CopyItem; + + CopyItem = CopyLibEntryStruct ( this, (EDA_LibComponentStruct *) ItemToCopy); + GetScreen()->AddItemToUndoList((EDA_BaseStruct *)CopyItem); + /* Clear current flags (which can be temporary set by a current edit command) */ + for ( item = CopyItem->m_Drawings; item != NULL; item = item->Pnext ) + item->m_Flags = 0; + + + /* Clear redo list, because after new save there is no redo to do */ + while ( GetScreen()->m_RedoList ) + { + item = GetScreen()->m_RedoList->Pnext; + delete GetScreen()->m_RedoList; + GetScreen()->m_RedoList = item; + } +} + +/******************************************************/ +void WinEDA_LibeditFrame::GetComponentFromRedoList(void) +/******************************************************/ +/* Redo the last edition: + - Place the current edited library component in undo list + - Get old version of the current edited library component +*/ +{ + if ( GetScreen()->m_RedoList == NULL ) return; + + GetScreen()->AddItemToUndoList((EDA_BaseStruct *)CurrentLibEntry); + CurrentLibEntry = + (EDA_LibComponentStruct *) GetScreen()->GetItemFromRedoList(); + if ( CurrentLibEntry ) CurrentLibEntry->Pnext = NULL; + CurrentDrawItem = NULL; + GetScreen()->SetModify(); + ReCreateHToolbar(); + SetToolbars(); +} + +/******************************************************/ +void WinEDA_LibeditFrame::GetComponentFromUndoList(void) +/******************************************************/ +/* Undo the last edition: + - Place the current edited library component in Redo list + - Get old version of the current edited library component +*/ +{ + if ( GetScreen()->m_UndoList == NULL ) return; + + GetScreen()->AddItemToRedoList((EDA_BaseStruct *)CurrentLibEntry); + CurrentLibEntry = + (EDA_LibComponentStruct *) GetScreen()->GetItemFromUndoList(); + + if ( CurrentLibEntry ) CurrentLibEntry->Pnext = NULL; + CurrentDrawItem = NULL; + GetScreen()->SetModify(); + ReCreateHToolbar(); + SetToolbars(); +} diff --git a/eeschema/libedpart.cpp b/eeschema/libedpart.cpp new file mode 100644 index 0000000000..f4301656c0 --- /dev/null +++ b/eeschema/libedpart.cpp @@ -0,0 +1,1128 @@ +/**************************************************************/ +/* librairy editor: edition of component general properties */ +/**************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +#include "wx/spinctrl.h" + + +/* Routines locales */ + +/* Variables locales */ + +extern int CurrentUnit; + +/* Classe de la frame des propriétés d'un composant en librairie */ + +enum id_libedit { + ID_LIBEDIT_NOTEBOOK = 3200, + ID_PANEL_BASIC, + ID_PANEL_ALIAS, + ID_PANEL_REFERENCE, + ID_PANEL_VALUE, + ID_PANEL_FOOTPRINT, + ID_PANEL_SUBSCHEMATIC, + ID_PANEL_FIELD1, + ID_PANEL_FIELD2, + ID_PANEL_FIELD3, + ID_PANEL_FIELD4, + ID_PANEL_FIELD5, + ID_PANEL_FIELD6, + ID_PANEL_FIELD7, + ID_PANEL_FIELD8, + ID_CLOSE_PART_PROPERTIES, + ID_ACCEPT_PART_PROPERTIES, + ID_COPY_DOC_TO_ALIAS, + ID_BROWSE_DOC_FILES, + ID_ADD_ALIAS, + ID_DELETE_ONE_ALIAS, + ID_DELETE_ALL_ALIAS +}; + + +/************************************************/ +class WinEDA_PartPropertiesFrame: public wxDialog +/************************************************/ +/* Cette classe genere une fenetre type NoteBook, pour l'edition des propriétés +d'un composant le librairie. + On peut éditer: + Texte dimensions et justification de tous les champs (Ref, Val, et autres champs) + Documentation et mots clefs + Nombre de part par boitier + et autres propriérés générales +*/ +{ +private: + + WinEDA_LibeditFrame * m_Parent; + wxNotebook* m_NoteBook; + wxListBox * m_PartAliasList; + wxPanel * m_PanelBasic; + wxPanel * m_PanelAlias; + wxPanel * m_PanelDoc; + wxPanel * PanelField[NUMBER_OF_FIELDS]; + + wxCheckBox * AsConvertButt; + + wxCheckBox * ShowFieldText[NUMBER_OF_FIELDS]; + wxCheckBox * VorientFieldText[NUMBER_OF_FIELDS]; + wxCheckBox * ShowPinNumButt; + wxCheckBox * ShowPinNameButt; + wxCheckBox * m_PinsNameInsideButt; + wxSpinCtrl * SelNumberOfUnits; + wxSpinCtrl * m_SetSkew; + wxCheckBox * m_OptionPower; + wxCheckBox * m_OptionPartsLocked; + + WinEDA_GraphicTextCtrl * FieldTextCtrl[NUMBER_OF_FIELDS]; + WinEDA_PositionCtrl * FieldPosition[NUMBER_OF_FIELDS]; + int FieldFlags[NUMBER_OF_FIELDS]; + int FieldOrient[NUMBER_OF_FIELDS]; + wxRadioBox * FieldHJustify[NUMBER_OF_FIELDS]; + wxRadioBox * FieldVJustify[NUMBER_OF_FIELDS]; + WinEDA_EnterText * m_Doc; + WinEDA_EnterText * m_Docfile; + WinEDA_EnterText * m_Keywords; + bool m_RecreateToolbar; + int m_AliasLocation; + + +public: + // Constructor and destructor + WinEDA_PartPropertiesFrame(WinEDA_LibeditFrame *parent, wxPoint& pos); + ~WinEDA_PartPropertiesFrame(void) + { + }; + +private: + void BuildPanelBasic(void); + void BuildPanelDoc(void); + void BuildPanelAlias(void); + void BuildPanelEditField(int fieldId); + void PartPropertiesAccept(wxCommandEvent& event); + void OnQuit(wxCommandEvent& event); + void DeleteAllAliasOfPart(wxCommandEvent& event); + void DeleteAliasOfPart(wxCommandEvent& event); + void AddAliasOfPart(wxCommandEvent& event); + bool ChangeNbUnitsPerPackage(int newUnit); + bool SetUnsetConvert(void); + void CopyDocToAlias(wxCommandEvent& event); + void BrowseAndSelectDocFile(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(WinEDA_PartPropertiesFrame, wxDialog) + EVT_BUTTON(ID_ACCEPT_PART_PROPERTIES, WinEDA_PartPropertiesFrame::PartPropertiesAccept) + EVT_BUTTON(ID_CLOSE_PART_PROPERTIES, WinEDA_PartPropertiesFrame::OnQuit) + EVT_BUTTON(ID_ADD_ALIAS, WinEDA_PartPropertiesFrame::AddAliasOfPart) + EVT_BUTTON(ID_DELETE_ONE_ALIAS, WinEDA_PartPropertiesFrame::DeleteAliasOfPart) + EVT_BUTTON(ID_DELETE_ALL_ALIAS, WinEDA_PartPropertiesFrame::DeleteAllAliasOfPart) + EVT_BUTTON(ID_COPY_DOC_TO_ALIAS, WinEDA_PartPropertiesFrame::CopyDocToAlias) + EVT_BUTTON(ID_BROWSE_DOC_FILES, WinEDA_PartPropertiesFrame::BrowseAndSelectDocFile) +END_EVENT_TABLE() + +/*****************************************************************/ +void WinEDA_LibeditFrame::InstallLibeditFrame(const wxPoint & pos) +/*****************************************************************/ +{ +wxPoint fpos = pos; + + WinEDA_PartPropertiesFrame * frame = + new WinEDA_PartPropertiesFrame(this, fpos); + frame->ShowModal(); frame->Destroy(); +} + + +#define XSIZE 370 +#define YSIZE 385 +/**********************************************************************************/ +WinEDA_PartPropertiesFrame::WinEDA_PartPropertiesFrame(WinEDA_LibeditFrame *parent, + wxPoint& framepos): + wxDialog(parent, -1, wxEmptyString, framepos, wxSize(XSIZE, YSIZE), + DIALOG_STYLE) +/**********************************************************************************/ +{ +wxPoint pos; +wxLayoutConstraints* c; +wxString msg_text; +wxButton * Button; +int ii; + + m_Parent = parent; + m_RecreateToolbar = FALSE; + SetFont(*g_DialogFont); + + SetAutoLayout(TRUE); + + for ( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) + FieldFlags[ii] = 0; + + m_AliasLocation = -1; + if ( CurrentLibEntry ) + { + msg_text = _("Properties for "); + if ( ! CurrentAliasName.IsEmpty() ) + { + m_AliasLocation = LocateAlias( CurrentLibEntry->m_AliasList, CurrentAliasName); + SetTitle( msg_text + CurrentAliasName + + _("(alias of ") + + wxString(CurrentLibEntry->m_Name.m_Text) + + wxT(")") ); + } + else + { + SetTitle( msg_text + CurrentLibEntry->m_Name.m_Text ); + CurrentAliasName.Empty(); + } + + FieldFlags[REFERENCE] = CurrentLibEntry->m_Prefix.m_Attributs; + FieldOrient[REFERENCE] = CurrentLibEntry->m_Prefix.m_Orient; + + FieldFlags[VALUE] = CurrentLibEntry->m_Name.m_Attributs; + FieldOrient[VALUE] = CurrentLibEntry->m_Name.m_Orient; + + LibDrawField * Field = CurrentLibEntry->Fields; + while ( Field ) + { + FieldFlags[Field->m_FieldId] = Field->m_Attributs; + FieldOrient[Field->m_FieldId] = Field->m_Orient; + Field = (LibDrawField*)Field->Pnext; + } + } + + else SetTitle(_("Lib Component Properties")); + + m_NoteBook = new wxNotebook(this, ID_LIBEDIT_NOTEBOOK, + wxDefaultPosition,wxSize(XSIZE-6, YSIZE - 70) ); + SetFont(*g_DialogFont); + m_NoteBook->SetAutoLayout(TRUE); + c = new wxLayoutConstraints; + c->left.SameAs(this, wxLeft, 4); + c->right.SameAs(this, wxRight, 4); + c->top.SameAs(this, wxTop, 4); + c->bottom.SameAs(this, wxBottom, 40); + m_NoteBook->SetConstraints(c); + + /* Creation des boutons de commande */ + pos.x = 50; pos.y = YSIZE - 60; + Button = new wxButton(this, ID_CLOSE_PART_PROPERTIES, + _("Cancel"), pos); + Button->SetForegroundColour(*wxBLUE); + c = new wxLayoutConstraints; + c->left.SameAs(this, wxLeft, 20); + c->height.AsIs(); + c->width.AsIs(); + c->bottom.SameAs(this, wxBottom, 5); + Button->SetConstraints(c); + + pos.x += Button->GetDefaultSize().x + 70; + Button = new wxButton(this, ID_ACCEPT_PART_PROPERTIES, + _("Ok"), pos); + Button->SetForegroundColour(*wxRED); + c = new wxLayoutConstraints; + c->right.SameAs(this, wxRight, 20); + c->height.AsIs(); + c->width.AsIs(); + c->bottom.SameAs(this, wxBottom, 5); + Button->SetConstraints(c); + + // Add panel Basic + BuildPanelBasic(); + m_NoteBook->AddPage(m_PanelBasic, _("Options"), TRUE); + + + // Add Panel Documentation + BuildPanelDoc(); + m_NoteBook->AddPage(m_PanelDoc, _("Doc"), FALSE); + + // Add Panel Alias List + BuildPanelAlias(); + m_NoteBook->AddPage(m_PanelAlias, _("Alias"), FALSE); + + // Add panel Fields + for ( ii = 0; ii < NUMBER_OF_FIELDS; ii++) BuildPanelEditField(ii); +} + +/*****************************************************/ +void WinEDA_PartPropertiesFrame::BuildPanelAlias(void) +/*****************************************************/ +/* create the panel for component alias list editing +*/ +{ +wxPoint pos; +wxButton * Button; + + m_PanelAlias = new wxPanel(m_NoteBook, -1); + m_PanelAlias->SetFont(*g_DialogFont); + wxLayoutConstraints * c = new wxLayoutConstraints; + c->left.SameAs(m_NoteBook, wxLeft); + c->right.SameAs(m_NoteBook, wxRight); + c->bottom.SameAs(m_NoteBook, wxBottom); + m_PanelAlias->SetConstraints(c); + + pos.x = 200; pos.y = 70; + Button = new wxButton(m_PanelAlias, ID_ADD_ALIAS, _("Add"), pos); + Button->SetForegroundColour(*wxBLUE); + + pos.y += Button->GetSize().y + 10; + Button = new wxButton(m_PanelAlias, ID_DELETE_ONE_ALIAS, + _("Delete"), pos); + Button->SetForegroundColour(*wxRED); + + pos.y += Button->GetSize().y + 10; + Button = new wxButton(m_PanelAlias, ID_DELETE_ALL_ALIAS, + _("Delete All"), pos); + Button->SetForegroundColour(*wxRED); + if ( ! CurrentAliasName.IsEmpty() ) Button->Enable(FALSE); + + pos.x = 5; pos.y = 30; + m_PartAliasList = new wxListBox(m_PanelAlias, + -1, + pos, wxSize(160,170), + 0,NULL, + wxLB_ALWAYS_SB|wxLB_SINGLE); + wxStaticText * Msg = new wxStaticText(m_PanelAlias, -1, _("Alias"), + wxPoint(pos.x,pos.y - 20) ); + Msg->SetForegroundColour(wxColour(200,0,0) ); + + /* lecture des noms des alias */ + if ( CurrentLibEntry ) + { + for ( unsigned ii = 0; ii < CurrentLibEntry->m_AliasList.GetCount(); ii += ALIAS_NEXT) + m_PartAliasList->Append(CurrentLibEntry->m_AliasList[ii+ALIAS_NAME]); + } +} + + +/*****************************************************/ +void WinEDA_PartPropertiesFrame::BuildPanelDoc(void) +/*****************************************************/ +/* create the panel for component doc editing +*/ +{ +wxPoint pos; +wxButton * Button; +wxString msg_text; + + m_PanelDoc = new wxPanel(m_NoteBook, -1); + m_PanelDoc->SetFont(*g_DialogFont); + wxLayoutConstraints * c = new wxLayoutConstraints; + c->left.SameAs(m_NoteBook, wxLeft); + c->right.SameAs(m_NoteBook, wxRight); + c->bottom.SameAs(m_NoteBook, wxBottom); + m_PanelDoc->SetConstraints(c); + + pos.x = 5; pos.y = 15; + + if ( CurrentLibEntry ) + { + msg_text = _("Properties for "); + if ( ! CurrentAliasName.IsEmpty() ) + { + msg_text += _("alias "); + msg_text += CurrentAliasName; + } + else + { + msg_text += CurrentLibEntry->m_Name.m_Text; + } + wxStaticText * text = new wxStaticText(m_PanelDoc, -1, msg_text, pos); + text->SetForegroundColour(*wxBLUE); + } + + pos.y += 30; + if ( m_AliasLocation >= 0 ) + msg_text = CurrentLibEntry->m_AliasList[m_AliasLocation+ALIAS_DOC]; + else + { + if (CurrentLibEntry && CurrentLibEntry->m_Doc) + msg_text = CurrentLibEntry->m_Doc; + } + m_Doc = new WinEDA_EnterText(m_PanelDoc, + _("Doc:"), msg_text, + pos, wxSize(285,-1) ); + + pos.y += 40; + msg_text.Empty(); + if ( m_AliasLocation >= 0 ) + msg_text = CurrentLibEntry->m_AliasList[m_AliasLocation+ALIAS_KEYWORD]; + else + { + if (CurrentLibEntry ) msg_text = CurrentLibEntry->m_KeyWord; + } + m_Keywords = new WinEDA_EnterText(m_PanelDoc, + _("Keywords:"), msg_text, + pos, wxSize(285,-1) ); + pos.y += 40; + msg_text.Empty(); + if ( m_AliasLocation >= 0 ) + msg_text = CurrentLibEntry->m_AliasList[m_AliasLocation+ALIAS_DOC_FILENAME]; + else + { + if (CurrentLibEntry) msg_text = CurrentLibEntry->m_DocFile; + } + m_Docfile = new WinEDA_EnterText(m_PanelDoc, + _("DocFileName:"), msg_text, + pos, wxSize(285,-1) ); + + pos.y += 40; + Button = new wxButton(m_PanelDoc, ID_COPY_DOC_TO_ALIAS, + _("Copy Doc"), pos); + Button->SetForegroundColour(*wxRED); + if ( m_AliasLocation < 0 ) Button->Enable(FALSE); + + Button = new wxButton(m_PanelDoc, ID_BROWSE_DOC_FILES, + _("Browse DocFiles"), wxPoint(pos.x + 140, pos.y) ); + Button->SetForegroundColour(*wxBLUE); +} + + +/*****************************************************/ +void WinEDA_PartPropertiesFrame::BuildPanelBasic(void) +/*****************************************************/ +/* create the basic panel for component properties editing +*/ +{ +wxPoint pos; + + m_PanelBasic = new wxPanel(m_NoteBook, ID_PANEL_BASIC); + m_PanelBasic->SetFont(*g_DialogFont); + wxLayoutConstraints * c = new wxLayoutConstraints; + c->left.SameAs(m_NoteBook, wxLeft); + c->right.SameAs(m_NoteBook, wxRight); + c->bottom.SameAs(m_NoteBook, wxBottom); + m_PanelBasic->SetConstraints(c); + + pos.x = 5; pos.y = 25; + new wxStaticBox(m_PanelBasic, -1,_("General :"), pos, wxSize(250, 120)); + + pos.x = 10; pos.y += 22; + AsConvertButt = new wxCheckBox(m_PanelBasic,-1, _("As Convert"), pos); + if ( g_AsDeMorgan ) AsConvertButt->SetValue(TRUE); + + pos.y += 20; + ShowPinNumButt = new wxCheckBox(m_PanelBasic,-1, _("Show Pin Num"), pos); + if ( CurrentLibEntry ) + { + if ( CurrentLibEntry->m_DrawPinNum ) ShowPinNumButt->SetValue(TRUE); + } + else ShowPinNumButt->SetValue(TRUE); + + pos.y += 20; + ShowPinNameButt = new wxCheckBox(m_PanelBasic,-1, _("Show Pin Name"), pos); + if ( CurrentLibEntry ) + { + if( CurrentLibEntry->m_DrawPinName ) ShowPinNameButt->SetValue(TRUE); + } + else ShowPinNameButt->SetValue(TRUE); + + pos.y += 20; + m_PinsNameInsideButt = new wxCheckBox(m_PanelBasic,-1, _("Pin Name Inside"), pos); + if ( CurrentLibEntry ) + { + if ( CurrentLibEntry->m_TextInside ) m_PinsNameInsideButt->SetValue(TRUE); + } + else m_PinsNameInsideButt->SetValue(TRUE); + + pos.y += 40; + new wxStaticText(m_PanelBasic,-1,_("Number of Units:"), pos); + pos.y += 15; + wxString number; + if ( CurrentLibEntry ) number.Printf( wxT("%d"), CurrentLibEntry->m_UnitCount); + else number = wxT("1"); + SelNumberOfUnits = new wxSpinCtrl(m_PanelBasic,-1,number, pos, + wxDefaultSize, wxSP_ARROW_KEYS | wxSP_WRAP, + 1, 16); + + pos.y -= 15; pos.x += 180; + new wxStaticText(m_PanelBasic,-1,_("Skew:"), pos); + pos.y += 15; + if ( CurrentLibEntry && CurrentLibEntry->m_TextInside) + number.Printf( wxT("%d"), CurrentLibEntry->m_TextInside); + else number = wxT("40"); + m_SetSkew = new wxSpinCtrl(m_PanelBasic,-1,number, pos, + wxDefaultSize, wxSP_ARROW_KEYS | wxSP_WRAP, + 1, 100); + + pos.x = 5; pos.y += 40; + m_OptionPower = new wxCheckBox(m_PanelBasic,-1, _("Power Symbol"), pos); + if ( CurrentLibEntry ) + { + if( CurrentLibEntry->m_Options == ENTRY_POWER ) + m_OptionPower->SetValue(TRUE); + } + + pos.y = m_OptionPower->GetRect().GetBottom() + 10; + m_OptionPartsLocked = new wxCheckBox(m_PanelBasic,-1, _("Parts are locked"), pos); + if ( CurrentLibEntry ) + { + if( CurrentLibEntry->m_UnitSelectionLocked ) + m_OptionPartsLocked->SetValue(TRUE); + } + if ( number == wxT("1") ) m_OptionPartsLocked->Enable(FALSE); + +} + +/****************************************************************/ +void WinEDA_PartPropertiesFrame::BuildPanelEditField(int fieldId) +/****************************************************************/ +{ +wxPoint pos; +int xx, yy; +LibDrawField * Field; +wxString Hjustify_list[] = + { _("Left justify"),_("Center"),_("Right justify")}; +wxString Vjustify_list[] = + { _("Bottom justify"),_("Center"),_("Top justify")}; +int ii = fieldId; + + PanelField[ii] = new wxPanel(m_NoteBook, ID_PANEL_REFERENCE + ii); + PanelField[ii]->SetFont(*g_DialogFont); + wxLayoutConstraints * c = new wxLayoutConstraints; + c->left.SameAs(m_NoteBook, wxLeft); + c->right.SameAs(m_NoteBook, wxRight); + c->bottom.SameAs(m_NoteBook, wxBottom); + PanelField[ii]->SetConstraints(c); + m_NoteBook->AddPage(PanelField[ii], DrawPartStruct::ReturnFieldName(ii), FALSE); + + pos.x = 10; pos.y = 10; + ShowFieldText[ii] = new wxCheckBox(PanelField[ii],-1, + _("Show Text"), pos); + if ( (FieldFlags[ii] & TEXT_NO_VISIBLE ) == 0 ) + ShowFieldText[ii]->SetValue(TRUE); + + ShowFieldText[ii]->GetSize(&xx, &yy); + pos.y += yy + 5; + VorientFieldText[ii] = new wxCheckBox(PanelField[ii],-1, + _("Vertical"), pos); + if ( FieldOrient[ii] ) VorientFieldText[ii]->SetValue(TRUE); + + pos.x = 150; pos.y = 5; + FieldHJustify[ii] = new wxRadioBox(PanelField[ii],-1, + _("Hor Justify"), pos, wxDefaultSize, + 3,Hjustify_list, 1 , wxRA_SPECIFY_COLS); + FieldHJustify[ii]->GetSize(&xx, &yy); + FieldHJustify[ii]->SetSelection(1); + + pos.y += yy + 5; + FieldVJustify[ii] = new wxRadioBox(PanelField[ii],-1, + _("Vert Justify"), pos, wxDefaultSize, + 3,Vjustify_list, 1 , wxRA_SPECIFY_COLS); + FieldVJustify[ii]->SetSelection(1); + + wxPoint txtpos; + pos.x = 10; pos.y = 70; +#define POSY_OFFSET 70 + switch ( ii ) + { + case REFERENCE: + if ( CurrentLibEntry ) + { + Field = &CurrentLibEntry->m_Prefix; + txtpos = Field->m_Pos; + if ( Field->m_HJustify == GR_TEXT_HJUSTIFY_LEFT) + FieldHJustify[ii]->SetSelection(0); + else if ( Field->m_HJustify == GR_TEXT_HJUSTIFY_RIGHT) + FieldHJustify[ii]->SetSelection(2); + if ( Field->m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM) + FieldVJustify[ii]->SetSelection(0); + else if ( Field->m_VJustify == GR_TEXT_VJUSTIFY_TOP) + FieldVJustify[ii]->SetSelection(2); + } + else txtpos = wxPoint(0,0); + FieldPosition[ii] = new WinEDA_PositionCtrl( PanelField[ii], + _("Pos"), txtpos, + g_UnitMetric , pos ); + FieldTextCtrl[ii] = new WinEDA_GraphicTextCtrl( PanelField[ii], + DrawPartStruct::ReturnFieldName(ii), + CurrentLibEntry ? + CurrentLibEntry->m_Prefix.m_Text.GetData() : wxT("U"), + CurrentLibEntry ? CurrentLibEntry->m_Prefix.m_Size.x : DEFAULT_TEXT_SIZE, + g_UnitMetric , + wxPoint(pos.x, pos.y +FieldPosition[ii]->GetDimension().y + POSY_OFFSET), + 200, TRUE); + break; + + case VALUE: + if ( CurrentLibEntry ) + { + Field = &CurrentLibEntry->m_Name; + txtpos = Field->m_Pos; + if ( Field->m_HJustify == GR_TEXT_HJUSTIFY_LEFT) + FieldHJustify[ii]->SetSelection(0); + else if ( Field->m_HJustify == GR_TEXT_HJUSTIFY_RIGHT) + FieldHJustify[ii]->SetSelection(2); + if ( Field->m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM) + FieldVJustify[ii]->SetSelection(0); + else if ( Field->m_VJustify == GR_TEXT_VJUSTIFY_TOP) + FieldVJustify[ii]->SetSelection(2); + } + else txtpos = wxPoint(0,0); + FieldPosition[ii] = new WinEDA_PositionCtrl( PanelField[ii], + _("Pos"), txtpos, + g_UnitMetric , pos); + FieldTextCtrl[ii] = new WinEDA_GraphicTextCtrl( PanelField[ii], + DrawPartStruct::ReturnFieldName(ii), + CurrentLibEntry ? CurrentLibEntry->m_Name.m_Text.GetData() : NULL, + CurrentLibEntry ? CurrentLibEntry->m_Name.m_Size.x : DEFAULT_TEXT_SIZE, + g_UnitMetric , + wxPoint(pos.x, pos.y +FieldPosition[ii]->GetDimension().y + POSY_OFFSET), + 200, TRUE); + break; + + default: + int fsize; + wxString ftext; + wxPoint fpos; + fsize = DEFAULT_TEXT_SIZE;; + Field = NULL; + fpos = wxPoint(0,0); + //recherche du Field de FieldId correspondant, s'il existe + if ( CurrentLibEntry ) + { + Field = CurrentLibEntry->Fields; + while ( Field ) + { + if( Field->m_FieldId == ii ) + { + fsize = Field->m_Size.x; + ftext = Field->m_Text; + fpos = Field->m_Pos; + if ( Field->m_HJustify == GR_TEXT_HJUSTIFY_LEFT) + FieldHJustify[ii]->SetSelection(0); + else if ( Field->m_HJustify == GR_TEXT_HJUSTIFY_RIGHT) + FieldHJustify[ii]->SetSelection(2); + if ( Field->m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM) + FieldVJustify[ii]->SetSelection(0); + else if ( Field->m_VJustify == GR_TEXT_VJUSTIFY_TOP) + FieldVJustify[ii]->SetSelection(2); + break; + } + Field = (LibDrawField*)Field->Pnext; + } + } + + FieldPosition[ii] = new WinEDA_PositionCtrl( PanelField[ii], + _("Pos"), fpos, + g_UnitMetric , pos); + FieldTextCtrl[ii] = new WinEDA_GraphicTextCtrl( PanelField[ii], + DrawPartStruct::ReturnFieldName(ii), + ftext, fsize, + g_UnitMetric , + wxPoint(pos.x, pos.y +FieldPosition[ii]->GetDimension().y + POSY_OFFSET), + 200, TRUE); + break; + } +} + + +/************************************************************************/ +void WinEDA_PartPropertiesFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/************************************************************************/ +{ + // true is to force the frame to close + Close(true); +} + +/**************************************************************************/ +void WinEDA_PartPropertiesFrame::PartPropertiesAccept(wxCommandEvent& event) +/**************************************************************************/ +/* Met a jour les differents parametres pour le composant en cours d'édition +*/ +{ +int ii, jj; +int hjustify[3] = { GR_TEXT_HJUSTIFY_LEFT , GR_TEXT_HJUSTIFY_CENTER, + GR_TEXT_HJUSTIFY_RIGHT }; +int vjustify[3] = { GR_TEXT_VJUSTIFY_BOTTOM , GR_TEXT_VJUSTIFY_CENTER, + GR_TEXT_VJUSTIFY_TOP }; + + if( CurrentLibEntry == NULL ) + { + Close(); return; + } + + m_Parent->m_CurrentScreen->SetModify(); + m_Parent->m_CurrentScreen->SetRefreshReq(); + m_Parent->SaveCopyInUndoList(); + + /* A new name could be entered in VALUE field. + Must not be an existing alias name in alias list box */ + jj = m_PartAliasList->GetCount(); + wxString newvalue = FieldTextCtrl[VALUE]->GetText(); + for ( ii = 0; ii < jj; ii++ ) + { + if( newvalue.CmpNoCase(m_PartAliasList->GetString(ii).GetData()) == 0 ) + { + wxString msg; + msg.Printf( wxT("Alias %s exists!"), newvalue.GetData()); + DisplayError(this, msg); + return; + } + } + + /* Update the doc, keyword and doc filename strings */ + if ( m_AliasLocation < 0 ) + { + CurrentLibEntry->m_Doc = m_Doc->GetValue(); + CurrentLibEntry->m_KeyWord = m_Keywords->GetValue(); + CurrentLibEntry->m_DocFile = m_Docfile->GetValue(); + } + + else + { + CurrentLibEntry->m_AliasList[m_AliasLocation+ALIAS_DOC] = m_Doc->GetValue(); + CurrentLibEntry->m_AliasList[m_AliasLocation+ALIAS_KEYWORD] = m_Keywords->GetValue(); + CurrentLibEntry->m_AliasList[m_AliasLocation+ALIAS_DOC_FILENAME] = m_Docfile->GetValue(); + } + + /* Update the alias list */ + /* 1 - Add names: test for a not existing name in old alias list: */ + jj = m_PartAliasList->GetCount(); + for ( ii = 0; ii < jj; ii++ ) + { + if ( LocateAlias( CurrentLibEntry->m_AliasList, m_PartAliasList->GetString(ii)) < 0 ) + { // new alias must be created + CurrentLibEntry->m_AliasList.Add(m_PartAliasList->GetString(ii)); + CurrentLibEntry->m_AliasList.Add(wxEmptyString); // Add a void doc string + CurrentLibEntry->m_AliasList.Add(wxEmptyString); // Add a void keyword list string + CurrentLibEntry->m_AliasList.Add(wxEmptyString); // Add a void doc filename string + } + } + + /* 2 - Remove delete names: test for an non existing name in new alias list: */ + int kk, kkmax = CurrentLibEntry->m_AliasList.GetCount(); + for ( kk = 0; kk < kkmax; ) + { + jj = m_PartAliasList->GetCount(); + wxString aliasname = CurrentLibEntry->m_AliasList[kk]; + for ( ii = 0; ii < jj; ii++ ) + { + if( aliasname.CmpNoCase(m_PartAliasList->GetString(ii).GetData()) == 0 ) + { + kk += ALIAS_NEXT; // Alias exist in new list. keep it and test next old name + break; + } + } + + if ( ii == jj ) // Alias not found in new list, remove it (4 strings in kk position) + { + for( ii = 0; ii < ALIAS_NEXT; ii++ ) CurrentLibEntry->m_AliasList.RemoveAt(kk); + kkmax = CurrentLibEntry->m_AliasList.GetCount(); + } + + } + + + if ( ! FieldTextCtrl[REFERENCE]->GetText().IsEmpty() ) + { + CurrentLibEntry->m_Prefix.m_Text = FieldTextCtrl[REFERENCE]->GetText(); + } + + if ( ! FieldTextCtrl[VALUE]->GetText().IsEmpty() ) + { + if ( CurrentLibEntry->m_Name.m_Text != FieldTextCtrl[VALUE]->GetText() ) + { + m_RecreateToolbar = TRUE; + CurrentLibEntry->m_Name.m_Text = FieldTextCtrl[VALUE]->GetText(); + } + } + + CurrentLibEntry->m_Prefix.m_Size.x = + CurrentLibEntry->m_Prefix.m_Size.y = FieldTextCtrl[REFERENCE]->GetTextSize(); + CurrentLibEntry->m_Name.m_Size.x = + CurrentLibEntry->m_Name.m_Size.y = FieldTextCtrl[VALUE]->GetTextSize(); + + CurrentLibEntry->m_Prefix.m_Pos = FieldPosition[REFERENCE]->GetValue(); + CurrentLibEntry->m_Name.m_Pos = FieldPosition[VALUE]->GetValue(); + + CurrentLibEntry->m_Prefix.m_Orient = VorientFieldText[REFERENCE]->GetValue() ? 1 : 0; + CurrentLibEntry->m_Name.m_Orient = VorientFieldText[VALUE]->GetValue() ? 1 : 0; + + CurrentLibEntry->m_Prefix.m_HJustify = + hjustify[FieldHJustify[REFERENCE]->GetSelection()]; + CurrentLibEntry->m_Prefix.m_VJustify = + vjustify[FieldVJustify[REFERENCE]->GetSelection()]; + CurrentLibEntry->m_Name.m_HJustify = + hjustify[FieldHJustify[VALUE]->GetSelection()]; + CurrentLibEntry->m_Name.m_VJustify = + vjustify[FieldVJustify[VALUE]->GetSelection()]; + + if ( ShowFieldText[REFERENCE]->GetValue() ) + CurrentLibEntry->m_Prefix.m_Attributs &= ~TEXT_NO_VISIBLE; + else + CurrentLibEntry->m_Prefix.m_Attributs |= TEXT_NO_VISIBLE; + + if ( ShowFieldText[VALUE]->GetValue() ) + CurrentLibEntry->m_Name.m_Attributs &= ~TEXT_NO_VISIBLE; + else + CurrentLibEntry->m_Name.m_Attributs |= TEXT_NO_VISIBLE; + + for ( ii = FOOTPRINT; ii < NUMBER_OF_FIELDS; ii++ ) + { + LibDrawField * Field = CurrentLibEntry->Fields; + LibDrawField * NextField, * previousField = NULL; + while ( Field ) + { + NextField = (LibDrawField*)Field->Pnext; + if( Field->m_FieldId == ii ) + { + Field->m_Text = FieldTextCtrl[ii]->GetText(); + Field->m_Size.x = Field->m_Size.y = FieldTextCtrl[ii]->GetTextSize(); + Field->m_HJustify = FieldHJustify[ii]->GetSelection(); + Field->m_VJustify = FieldVJustify[ii]->GetSelection(); + if ( ShowFieldText[ii]->GetValue() ) + Field->m_Attributs &= ~TEXT_NO_VISIBLE; + else + Field->m_Attributs |= TEXT_NO_VISIBLE; + Field->m_Orient = VorientFieldText[ii]->GetValue() ? 1 : 0; + Field->m_Pos = FieldPosition[ii]->GetValue(); + if( Field->m_Text.IsEmpty() ) // An old field exists; new is void, delete it + { + delete Field; + if ( previousField ) previousField->Pnext = NextField; + else CurrentLibEntry->Fields = NextField; + } + break; + } + + previousField = Field; + Field = NextField; + } + + if ( (Field == NULL) && ( ! FieldTextCtrl[ii]->GetText().IsEmpty() ) ) + { // Do not exists: must be created + Field = new LibDrawField(ii); + Field->m_Text = FieldTextCtrl[ii]->GetText(); + Field->m_Size.x = Field->m_Size.y = FieldTextCtrl[ii]->GetTextSize(); + if ( ShowFieldText[Field->m_FieldId]->GetValue() ) + Field->m_Attributs &= ~TEXT_NO_VISIBLE; + else + Field->m_Attributs |= TEXT_NO_VISIBLE; + Field->m_Orient = VorientFieldText[Field->m_FieldId]->GetValue() ?1 : 0; + Field->m_Pos = FieldPosition[Field->m_FieldId]->GetValue(); + Field->m_HJustify = hjustify[FieldHJustify[Field->m_FieldId]->GetSelection()]; + Field->m_VJustify = vjustify[FieldVJustify[Field->m_FieldId]->GetSelection()]; + Field->Pnext = CurrentLibEntry->Fields; + CurrentLibEntry->Fields = Field; + } + } + + ii = SelNumberOfUnits->GetValue(); + if ( ChangeNbUnitsPerPackage(ii) ) + m_RecreateToolbar = TRUE; + + if ( AsConvertButt->GetValue() ) + { + if ( ! g_AsDeMorgan ) + { + g_AsDeMorgan = 1; + if ( SetUnsetConvert() ) m_RecreateToolbar = TRUE; + } + } + else + { + if ( g_AsDeMorgan ) + { + g_AsDeMorgan = 0; + if ( SetUnsetConvert() ) m_RecreateToolbar = TRUE; + } + } + + CurrentLibEntry->m_DrawPinNum = ShowPinNumButt->GetValue() ? 1 : 0; + CurrentLibEntry->m_DrawPinName = ShowPinNameButt->GetValue() ? 1 : 0; + + if ( m_PinsNameInsideButt->GetValue() == FALSE) + CurrentLibEntry->m_TextInside = 0; + else + CurrentLibEntry->m_TextInside = m_SetSkew->GetValue(); + + if ( m_OptionPower->GetValue() == TRUE) + CurrentLibEntry->m_Options = ENTRY_POWER; + else + CurrentLibEntry->m_Options = ENTRY_NORMAL; + + /* Set the option "Units locked". + Obviously, cannot be TRUE if there is only one part */ + CurrentLibEntry->m_UnitSelectionLocked = m_OptionPartsLocked->GetValue(); + if ( CurrentLibEntry->m_UnitCount <= 1 ) + CurrentLibEntry->m_UnitSelectionLocked = FALSE; + + if ( m_RecreateToolbar ) m_Parent->ReCreateHToolbar(); + + m_Parent->DisplayLibInfos(); + + Close(); +} + + +/*******************************************************************************/ +void WinEDA_PartPropertiesFrame::CopyDocToAlias(wxCommandEvent& WXUNUSED(event)) +/******************************************************************************/ +{ + if( CurrentLibEntry == NULL ) return; + if ( CurrentAliasName.IsEmpty() ) return; + + m_Doc->SetValue(CurrentLibEntry->m_Doc); + m_Docfile->SetValue(CurrentLibEntry->m_DocFile); + m_Keywords->SetValue(CurrentLibEntry->m_KeyWord); +} + +/**********************************************************/ +void WinEDA_PartPropertiesFrame::DeleteAllAliasOfPart( + wxCommandEvent& WXUNUSED(event)) +/**********************************************************/ +{ + + CurrentAliasName.Empty(); + if( CurrentLibEntry ) + { + if( IsOK(this, _("Ok to Delete Alias LIST") ) ) + { + m_PartAliasList->Clear(); + m_RecreateToolbar = TRUE; + } + } + +} + +/*******************************************************************************/ +void WinEDA_PartPropertiesFrame::AddAliasOfPart( wxCommandEvent& WXUNUSED(event)) +/*******************************************************************************/ +/* Add a new name to the alias list box + New name cannot be the root name, and must not exists +*/ +{ +wxString Line; +wxString aliasname; + + if(CurrentLibEntry == NULL) return; + + if( Get_Message(_("New alias:"),Line, this) != 0 ) return; + + Line.Replace( wxT(" "), wxT("_") ); + aliasname = Line; + + if ( CurrentLibEntry->m_Name.m_Text.CmpNoCase(Line) == 0 ) + { + DisplayError(this, _("This is the Root Part"), 10); return; + } + + /* test for an existing name: */ + int ii, jj = m_PartAliasList->GetCount(); + for ( ii = 0; ii < jj; ii++ ) + { + if( aliasname.CmpNoCase(m_PartAliasList->GetString(ii)) == 0 ) + { + DisplayError(this, _("Already in use"), 10); + return; + } + } + + m_PartAliasList->Append(aliasname); + + m_RecreateToolbar = TRUE; +} + +/********************************************************/ +void WinEDA_PartPropertiesFrame::DeleteAliasOfPart( + wxCommandEvent& WXUNUSED(event)) +/********************************************************/ +{ +wxString aliasname = m_PartAliasList->GetStringSelection(); + + if ( aliasname.IsEmpty() ) return; + if ( aliasname == CurrentAliasName ) + { + wxString msg = CurrentAliasName + _(" is Current Selected Alias!"); + DisplayError(this, msg ); + return; + } + + int ii = m_PartAliasList->GetSelection(); + m_PartAliasList->Delete(ii); + + m_RecreateToolbar = TRUE; +} + + + + +/********************************************************************/ +bool WinEDA_PartPropertiesFrame::ChangeNbUnitsPerPackage(int MaxUnit) +/********************************************************************/ +/* Routine de modification du nombre d'unites par package pour le + composant courant; +*/ +{ +int OldNumUnits, ii, FlagDel = -1; +LibEDA_BaseStruct* DrawItem, * NextDrawItem; + + if( CurrentLibEntry == NULL ) return FALSE; + + /* Si pas de changement: termine */ + if ( CurrentLibEntry->m_UnitCount == MaxUnit ) return FALSE; + + OldNumUnits = CurrentLibEntry->m_UnitCount; + if ( OldNumUnits < 1 ) OldNumUnits = 1; + + CurrentLibEntry->m_UnitCount = MaxUnit; + + + /* Traitement des unites enlevees ou rajoutees */ + if(OldNumUnits > CurrentLibEntry->m_UnitCount ) + { + DrawItem = CurrentLibEntry->m_Drawings; + for ( ; DrawItem != NULL; DrawItem = NextDrawItem) + { + NextDrawItem = DrawItem->Next(); + if( DrawItem->m_Unit > MaxUnit ) /* Item a effacer */ + { + if( FlagDel < 0 ) + { + if( IsOK(this, _("Delete units") ) ) + { + /* Si part selectee n'existe plus: selection 1ere unit */ + if( CurrentUnit > MaxUnit ) CurrentUnit = 1; + FlagDel = 1; + } + else + { + FlagDel = 0; + MaxUnit = OldNumUnits; + CurrentLibEntry->m_UnitCount = MaxUnit; + return FALSE; + } + } + DeleteOneLibraryDrawStruct(m_Parent->DrawPanel, NULL, CurrentLibEntry, + DrawItem, 0); + } + } + return TRUE; + } + + if(OldNumUnits < CurrentLibEntry->m_UnitCount ) + { + DrawItem = CurrentLibEntry->m_Drawings; + for ( ; DrawItem != NULL; DrawItem = DrawItem->Next() ) + { + /* Duplication des items pour autres elements */ + if( DrawItem->m_Unit == 1 ) + { + for ( ii = OldNumUnits +1; ii <= MaxUnit; ii ++ ) + { + NextDrawItem = CopyDrawEntryStruct(this, DrawItem); + NextDrawItem->Pnext = CurrentLibEntry->m_Drawings; + CurrentLibEntry->m_Drawings = NextDrawItem; + NextDrawItem->m_Unit = ii; + } + } + } + } + return TRUE; +} + + +/*****************************************************/ +bool WinEDA_PartPropertiesFrame::SetUnsetConvert(void) +/*****************************************************/ +/* crée ou efface (selon option AsConvert) les éléments + de la représentation convertie d'un composant +*/ +{ +int FlagDel = 0; +LibEDA_BaseStruct* DrawItem = NULL, * NextDrawItem; + + if( g_AsDeMorgan ) /* Representation convertie a creer */ + { + /* Traitement des elements a ajouter ( pins seulement ) */ + if( CurrentLibEntry ) DrawItem = CurrentLibEntry->m_Drawings; + for ( ; DrawItem != NULL; DrawItem = DrawItem->Next() ) + { + /* Duplication des items pour autres elements */ + if( DrawItem->m_StructType != COMPONENT_PIN_DRAW_TYPE ) continue; + if( DrawItem->m_Convert == 1 ) + { + if( FlagDel == 0 ) + { + if( IsOK(this, _("Create pins for Convert items")) ) + FlagDel = 1; + else + { + if( IsOK(this, _("Part as \"De Morgan\" anymore")) ) + return TRUE; + + g_AsDeMorgan = 0; return FALSE; + } + } + NextDrawItem = CopyDrawEntryStruct(this, DrawItem); + NextDrawItem->Pnext = CurrentLibEntry->m_Drawings; + CurrentLibEntry->m_Drawings = NextDrawItem; + NextDrawItem->m_Convert = 2; + } + } + } + + else /* Representation convertie a supprimer */ + { + /* Traitement des elements à supprimer */ + if( CurrentLibEntry ) DrawItem = CurrentLibEntry->m_Drawings; + for ( ; DrawItem != NULL; DrawItem = NextDrawItem) + { + NextDrawItem = DrawItem->Next(); + if( DrawItem->m_Convert > 1 ) /* Item a effacer */ + { + if( FlagDel == 0 ) + { + if( IsOK(this, _("Delete Convert items") ) ) + { + CurrentConvert = 1; + FlagDel = 1; + } + else + { + g_AsDeMorgan = 1; + return FALSE; + } + } + m_Parent->GetScreen()->SetModify(); + DeleteOneLibraryDrawStruct(m_Parent->DrawPanel, NULL, CurrentLibEntry, DrawItem, 0); + } + } + } + return TRUE; +} + +/****************************************************************************/ +void WinEDA_PartPropertiesFrame::BrowseAndSelectDocFile(wxCommandEvent& event) +/****************************************************************************/ +{ +wxString FullFileName; +wxString docpath(g_RealLibDirBuffer), filename; + + docpath += wxT("doc"); + docpath += STRING_DIR_SEP; + FullFileName = EDA_FileSelector(_("Doc Files"), + docpath, /* Chemin par defaut */ + wxEmptyString, /* nom fichier par defaut */ + wxEmptyString, /* extension par defaut */ + wxEmptyString, /* Masque d'affichage */ + this, + wxFD_OPEN, + TRUE + ); + if ( FullFileName.IsEmpty() ) return; + + // Suppression du chemin par defaut pour le fichier de doc: + filename = MakeReducedFileName(FullFileName,docpath, wxEmptyString); + m_Docfile->SetValue(filename); +} diff --git a/eeschema/libfield.cpp b/eeschema/libfield.cpp new file mode 100644 index 0000000000..ae285a2439 --- /dev/null +++ b/eeschema/libfield.cpp @@ -0,0 +1,349 @@ +/*********************************************************************/ +/* EESchema - edition des librairies: Edition des champs ( Fields ) */ +/*********************************************************************/ + + /* Fichier libfield.cpp */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +#include "wx/spinctrl.h" + +/* Routines locales */ +static void ShowMoveField(WinEDA_DrawPanel * panel, wxDC *DC, bool erase); + +/* Variables locales */ + +extern int CurrentUnit; +static wxPoint StartCursor, LastTextPosition; + + +/***********************************************************/ +static void ExitMoveField(WinEDA_DrawPanel * Panel, wxDC * DC) +/***********************************************************/ +{ + + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + if(CurrentDrawItem == NULL) return; + + wxPoint curpos; + curpos = Panel->m_Parent->m_CurrentScreen->m_Curseur; + Panel->m_Parent->m_CurrentScreen->m_Curseur = StartCursor; + ShowMoveField(Panel, DC, TRUE); + Panel->m_Parent->m_CurrentScreen->m_Curseur = curpos; + CurrentDrawItem->m_Flags = 0; + + CurrentDrawItem = NULL; +} + + + +/****************************************************************************/ +void WinEDA_LibeditFrame::StartMoveField(wxDC * DC, LibDrawField *field) +/****************************************************************************/ +/* Initialise le deplacement d'un champ ( ref ou Name) */ +{ +wxPoint startPos; + + if( (CurrentLibEntry == NULL) || ( field == NULL ) ) return; + CurrentDrawItem = field; + LastTextPosition = field->m_Pos; + CurrentDrawItem->m_Flags |= IS_MOVED; + + startPos.x = LastTextPosition.x; + startPos.y = -LastTextPosition.y; + DrawPanel->CursorOff(DC); + m_CurrentScreen->m_Curseur = startPos; + DrawPanel->MouseToCursorSchema(); + + DrawPanel->ManageCurseur = ShowMoveField; + DrawPanel->ForceCloseManageCurseur = ExitMoveField; + DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); + StartCursor = m_CurrentScreen->m_Curseur; + + DrawPanel->CursorOn(DC); +} + +/*****************************************************************/ +/* Routine d'affichage du texte 'Field' en cours de deplacement. */ +/* Routine normalement attachee au curseur */ +/*****************************************************************/ +static void ShowMoveField(WinEDA_DrawPanel * panel, wxDC *DC, bool erase) +{ +int color; +LibDrawField *Field = (LibDrawField *)CurrentDrawItem; + + if( (CurrentLibEntry == NULL) || (Field == NULL) ) return; + + GRSetDrawMode(DC, g_XorMode); + + switch (Field->m_FieldId) + { + case VALUE: + color = ReturnLayerColor(LAYER_VALUEPART); + break; + + case REFERENCE: + color = ReturnLayerColor(LAYER_REFERENCEPART); + break; + + default: + color = ReturnLayerColor(LAYER_FIELDS); + break; + } + + if( Field->m_Attributs & TEXT_NO_VISIBLE ) color = DARKGRAY; + if( erase ) + DrawGraphicText(panel, DC, + wxPoint(LastTextPosition.x, - LastTextPosition.y), + color, Field->m_Text, + Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, + Field->m_HJustify, Field->m_VJustify); + + + LastTextPosition.x = panel->GetScreen()->m_Curseur.x; + LastTextPosition.y = - panel->GetScreen()->m_Curseur.y; + + Field->m_Pos = LastTextPosition; + + DrawGraphicText(panel, DC, + wxPoint(LastTextPosition.x, - LastTextPosition.y), + color, Field->m_Text, + Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, + Field->m_HJustify, Field->m_VJustify); +} + +/*******************************************************************/ +void WinEDA_LibeditFrame::PlaceField(wxDC * DC, LibDrawField *Field) +/*******************************************************************/ +{ +int color; + + if(Field == NULL ) return; + + GRSetDrawMode(DC, GR_DEFAULT_DRAWMODE); + + switch (Field->m_FieldId) + { + case REFERENCE: + color = ReturnLayerColor(LAYER_REFERENCEPART); + break; + + case VALUE: + color = ReturnLayerColor(LAYER_VALUEPART); + break; + + default: + color = ReturnLayerColor(LAYER_FIELDS); + break; + } + + if( Field->m_Attributs & TEXT_NO_VISIBLE ) color = DARKGRAY; + Field->m_Pos.x = GetScreen()->m_Curseur.x; + Field->m_Pos.y = - GetScreen()->m_Curseur.y; + DrawGraphicText(DrawPanel, DC, wxPoint(Field->m_Pos.x, - Field->m_Pos.y), + color, Field->m_Text, + Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, + Field->m_HJustify, Field->m_VJustify); + + Field->m_Flags = 0; + + m_CurrentScreen->SetModify(); + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + CurrentDrawItem = NULL; +} + + +/******************************************************************/ +void WinEDA_LibeditFrame::EditField(wxDC * DC, LibDrawField *Field) +/******************************************************************/ +{ +wxString Text; +int color; +wxString title = wxT("Text:"); + + if( Field == NULL) return; + + switch (Field->m_FieldId) + { + case REFERENCE: + title = wxT("Reference:"); + color = ReturnLayerColor(LAYER_REFERENCEPART); + break; + + case VALUE: + title = wxT("Value:"); + color = ReturnLayerColor(LAYER_VALUEPART); + break; + + default: + color = ReturnLayerColor(LAYER_FIELDS); + break; + } + + if( Field->m_Attributs & TEXT_NO_VISIBLE ) color = DARKGRAY; + + Text = Field->m_Text; + Get_Message(title,Text, this); + Text.Replace( wxT(" ") , wxT("_") ); + + GRSetDrawMode(DC, g_XorMode); + DrawGraphicText(DrawPanel, DC, wxPoint(Field->m_Pos.x, - Field->m_Pos.y), + color, Field->m_Text, + Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, + Field->m_HJustify, Field->m_VJustify); + + if( ! Text.IsEmpty() ) + { + SaveCopyInUndoList(CurrentLibEntry); + Field->m_Text = Text; + } + else DisplayError(this, _("No new text: no change") ); + + if( Field->m_Flags == 0 ) GRSetDrawMode(DC, GR_DEFAULT_DRAWMODE); + + DrawGraphicText(DrawPanel, DC, wxPoint(Field->m_Pos.x, - Field->m_Pos.y), + color, Field->m_Text, + Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, + Field->m_HJustify, Field->m_VJustify); + + m_CurrentScreen->SetModify(); + + if ( Field->m_FieldId == VALUE ) ReCreateHToolbar(); +} + +/********************************************************************/ +void WinEDA_LibeditFrame::RotateField(wxDC * DC, LibDrawField *Field) +/********************************************************************/ +/* Routine de modification de l'orientation ( Horiz ou Vert. ) du champ. + si un champ est en cours d'edition, modif de celui ci. + sinon Modif du champ pointe par la souris +*/ +{ +int color; + + if( Field == NULL) return; + + m_CurrentScreen->SetModify(); + switch (Field->m_FieldId) + { + case REFERENCE: + color = ReturnLayerColor(LAYER_REFERENCEPART); + break; + + case VALUE: + color = ReturnLayerColor(LAYER_VALUEPART); + break; + + default: + color = ReturnLayerColor(LAYER_FIELDS); + break; + } + + if( Field->m_Attributs & TEXT_NO_VISIBLE ) color = DARKGRAY; + + GRSetDrawMode(DC, g_XorMode); + DrawGraphicText(DrawPanel, DC, wxPoint(Field->m_Pos.x, - Field->m_Pos.y), + color, Field->m_Text, + Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, + Field->m_HJustify, Field->m_VJustify); + + if( Field->m_Orient) Field->m_Orient = 0; + else Field->m_Orient = 1; + + if( Field->m_Flags == 0 ) GRSetDrawMode(DC, GR_DEFAULT_DRAWMODE); + + DrawGraphicText(DrawPanel, DC, wxPoint(Field->m_Pos.x, - Field->m_Pos.y), + color, Field->m_Text, + Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, + Field->m_HJustify, Field->m_VJustify); +} + + +/****************************************************************************/ +LibDrawField * WinEDA_LibeditFrame::LocateField(EDA_LibComponentStruct *LibEntry) +/****************************************************************************/ +/* Localise le champ (ref ou name) pointe par la souris + retourne: + pointeur sur le champ (NULL= Pas de champ) +*/ +{ +int x0, y0, x1, y1; /* Rectangle d'encadrement des textes a localiser */ +int dx, dy; /* Dimensions du texte */ +LibDrawField *Field; +int hjustify, vjustify; + + /* Localisation du Nom */ + x0 = LibEntry->m_Name.m_Pos.x; + y0 = - LibEntry->m_Name.m_Pos.y; + dx = LibEntry->m_Name.m_Size.x * LibEntry->m_Name.m_Text.Len(), + dy = LibEntry->m_Name.m_Size.y; + hjustify = LibEntry->m_Name.m_HJustify; vjustify = LibEntry->m_Name.m_VJustify; + if (LibEntry->m_Name.m_Orient) EXCHG(dx, dy); + if ( hjustify == GR_TEXT_HJUSTIFY_CENTER ) x0 -= dx/2; + else if ( hjustify == GR_TEXT_HJUSTIFY_RIGHT ) x0 -= dx; + if ( vjustify == GR_TEXT_VJUSTIFY_CENTER ) y0 -= dy/2; + else if ( vjustify == GR_TEXT_VJUSTIFY_BOTTOM ) y0 += dy; + x1 = x0 + dx; y1 = y0 + dy; + + if( (m_CurrentScreen->m_Curseur.x >= x0) && ( m_CurrentScreen->m_Curseur.x <= x1) && + (m_CurrentScreen->m_Curseur.y >= y0) && ( m_CurrentScreen->m_Curseur.y <= y1) ) + return &LibEntry->m_Name; + + /* Localisation du Prefix */ + x0 = LibEntry->m_Prefix.m_Pos.x; + y0 = - LibEntry->m_Prefix.m_Pos.y; + dx = LibEntry->m_Prefix.m_Size.x *LibEntry->m_Prefix.m_Text.Len(), + dy = LibEntry->m_Prefix.m_Size.y; + hjustify = LibEntry->m_Prefix.m_HJustify; vjustify = LibEntry->m_Prefix.m_VJustify; + if (LibEntry->m_Prefix.m_Orient) EXCHG(dx, dy); + if ( hjustify == GR_TEXT_HJUSTIFY_CENTER ) x0 -= dx/2; + else if ( hjustify == GR_TEXT_HJUSTIFY_RIGHT ) x0 -= dx; + if ( vjustify == GR_TEXT_VJUSTIFY_CENTER ) y0 -= dy/2; + else if ( vjustify == GR_TEXT_VJUSTIFY_BOTTOM ) y0 -= dy; + x1 = x0 + dx; y1 = y0 + dy; + + if( (m_CurrentScreen->m_Curseur.x >= x0) && ( m_CurrentScreen->m_Curseur.x <= x1) && + (m_CurrentScreen->m_Curseur.y >= y0) && ( m_CurrentScreen->m_Curseur.y <= y1) ) + return &LibEntry->m_Prefix; + + /* Localisation des autres fields */ + for (Field = LibEntry->Fields; Field != NULL; + Field = (LibDrawField*)Field->Pnext) + { + if ( Field->m_Text.IsEmpty() ) continue; + x0 = Field->m_Pos.x; y0 = - Field->m_Pos.y; + dx = Field->m_Size.x * Field->m_Text.Len(), + dy = Field->m_Size.y; + hjustify = Field->m_HJustify; vjustify = Field->m_VJustify; + if (Field->m_Orient) EXCHG(dx, dy); + if (LibEntry->m_Prefix.m_Orient) EXCHG(dx, dy); + if ( hjustify == GR_TEXT_HJUSTIFY_CENTER ) x0 -= dx/2; + else if ( hjustify == GR_TEXT_HJUSTIFY_RIGHT ) x0 -= dx; + if ( vjustify == GR_TEXT_VJUSTIFY_CENTER ) y0 -= dy/2; + else if ( vjustify == GR_TEXT_VJUSTIFY_BOTTOM ) y0 -= dy; + x1 = x0 + dx; y1 = y0 + dy; + if( (m_CurrentScreen->m_Curseur.x >= x0) && ( m_CurrentScreen->m_Curseur.x <= x1) && + (m_CurrentScreen->m_Curseur.y >= y0) && ( m_CurrentScreen->m_Curseur.y <= y1) ) + return(Field); + } + + return NULL; +} + diff --git a/eeschema/libframe.cpp b/eeschema/libframe.cpp new file mode 100644 index 0000000000..a2880fea3b --- /dev/null +++ b/eeschema/libframe.cpp @@ -0,0 +1,700 @@ + /****************************/ + /* EESchema - libframe.cpp */ + /****************************/ + +/* Gestion de la frame d'edition des composants en librairie +*/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "bitmaps.h" +#include "protos.h" + +#include "id.h" + +#include "libedit.xpm" + + /*****************************/ + /* class WinEDA_LibeditFrame */ + /*****************************/ +BEGIN_EVENT_TABLE(WinEDA_LibeditFrame, wxFrame) + COMMON_EVENTS_DRAWFRAME + + EVT_CLOSE(WinEDA_LibeditFrame::OnCloseWindow) + EVT_SIZE(WinEDA_LibeditFrame::OnSize) + + EVT_TOOL_RANGE(ID_ZOOM_PLUS_BUTT, ID_ZOOM_PAGE_BUTT, + WinEDA_LibeditFrame::Process_Zoom) + + // Tools et boutons de Libedit: + + /* Main horizontal toolbar */ + EVT_TOOL_RANGE( ID_LIBEDIT_START_H_TOOL, ID_LIBEDIT_END_H_TOOL, + WinEDA_LibeditFrame::Process_Special_Functions) + EVT_KICAD_CHOICEBOX(ID_LIBEDIT_SELECT_PART_NUMBER, + WinEDA_LibeditFrame::Process_Special_Functions) + EVT_KICAD_CHOICEBOX(ID_LIBEDIT_SELECT_ALIAS, + WinEDA_LibeditFrame::Process_Special_Functions) + + /* Right Vertical toolbar */ + EVT_TOOL( ID_NO_SELECT_BUTT,WinEDA_LibeditFrame::Process_Special_Functions) + EVT_TOOL_RANGE( ID_LIBEDIT_START_V_TOOL, ID_LIBEDIT_END_V_TOOL, + WinEDA_LibeditFrame::Process_Special_Functions) + + /* PopUp events and commands: */ + EVT_MENU_RANGE(ID_POPUP_START_RANGE, ID_POPUP_END_RANGE, + WinEDA_LibeditFrame::Process_Special_Functions ) + + // Annulation de commande en cours + EVT_MENU_RANGE(ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, + WinEDA_LibeditFrame::Process_Special_Functions ) + + // PopUp Menus pour Zooms traités dans drawpanel.cpp + + +END_EVENT_TABLE() + + +WinEDA_LibeditFrame::WinEDA_LibeditFrame(wxWindow * father, WinEDA_App *parent, + const wxString & title, const wxPoint& pos, const wxSize& size): + WinEDA_DrawFrame(father, LIBEDITOR_FRAME, parent, title, pos, size) +{ + m_FrameName = wxT("LibeditFrame"); + m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines + m_Draw_Grid = TRUE; // TRUE pour avoir la axes dessinee + + // Give an icon + SetIcon(wxIcon(libedit_xpm)); + m_CurrentScreen = ScreenLib; + GetSettings(); + SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y); + if ( DrawPanel ) DrawPanel-> m_Block_Enable = TRUE; + ReCreateHToolbar(); + ReCreateVToolbar(); + DisplayLibInfos(); + Show(TRUE); +} + +/**********************************************/ +WinEDA_LibeditFrame::~WinEDA_LibeditFrame(void) +/**********************************************/ +{ + m_Parent->LibeditFrame = NULL; + m_CurrentScreen = ScreenSch; + +} + +/***********************************************************/ +void WinEDA_LibeditFrame::OnCloseWindow(wxCloseEvent & Event) +/***********************************************************/ +{ +LibraryStruct *Lib; + + if( m_CurrentScreen->IsModify() ) + { + if( ! IsOK(this, _("LibEdit: Part modified!, Continue ?") ) ) + { + Event.Veto(); return; + } + else m_CurrentScreen->ClrModify(); + } + + for (Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext) + { + if( Lib->m_Modified ) + { + wxString msg; + msg.Printf( _("Library %s modified!, Continue ?"), Lib->m_Name.GetData()); + if( ! IsOK(this, msg) ) + { + Event.Veto(); return; + } + } + } + + SaveSettings(); + Destroy(); +} + + +/******************************************/ +void WinEDA_LibeditFrame::SetToolbars(void) +/******************************************/ +/* Enable or disable tools of the differents toolbars, + according to the current conditions or options +*/ +{ + + if( m_HToolBar == NULL ) return; + + if ( CurrentLib == NULL ) + { + if ( m_HToolBar ) m_HToolBar->EnableTool(ID_LIBEDIT_SAVE_CURRENT_LIB,FALSE); + } + else + { + if ( m_HToolBar ) m_HToolBar->EnableTool(ID_LIBEDIT_SAVE_CURRENT_LIB,TRUE); + } + + if ( CurrentLibEntry == NULL ) + { + if ( m_HToolBar ) + { + m_HToolBar->EnableTool(ID_LIBEDIT_IMPORT_PART,TRUE); + m_HToolBar->EnableTool(ID_LIBEDIT_EXPORT_PART,FALSE); + m_HToolBar->EnableTool(ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,FALSE); + m_HToolBar->EnableTool(ID_LIBEDIT_SAVE_CURRENT_PART,FALSE); + m_HToolBar->EnableTool(ID_DE_MORGAN_CONVERT_BUTT, FALSE); + m_HToolBar->EnableTool(ID_DE_MORGAN_NORMAL_BUTT, FALSE); + m_HToolBar->EnableTool(ID_LIBEDIT_EDIT_PIN_BY_PIN, FALSE); + m_HToolBar->EnableTool(ID_LIBEDIT_VIEW_DOC, FALSE); + m_HToolBar->EnableTool(ID_LIBEDIT_CHECK_PART, FALSE); + m_SelpartBox->Enable( FALSE); + m_HToolBar->EnableTool(ID_LIBEDIT_UNDO,FALSE); + m_HToolBar->EnableTool(ID_LIBEDIT_REDO,FALSE); + } + g_EditPinByPinIsOn = FALSE; + m_HToolBar->ToggleTool(ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn); + + if ( m_VToolBar ) + { + m_VToolBar->EnableTool(ID_LIBEDIT_BODY_TEXT_BUTT, FALSE); + m_VToolBar->EnableTool(ID_LIBEDIT_BODY_LINE_BUTT, FALSE); + m_VToolBar->EnableTool(ID_LIBEDIT_BODY_RECT_BUTT, FALSE); + m_VToolBar->EnableTool(ID_LIBEDIT_BODY_CIRCLE_BUTT, FALSE); + m_VToolBar->EnableTool(ID_LIBEDIT_BODY_ARC_BUTT, FALSE); + m_VToolBar->EnableTool(ID_LIBEDIT_DELETE_ITEM_BUTT, FALSE); + m_VToolBar->EnableTool(ID_LIBEDIT_ANCHOR_ITEM_BUTT, FALSE); + m_VToolBar->EnableTool(ID_LIBEDIT_IMPORT_BODY_BUTT, FALSE); + m_VToolBar->EnableTool(ID_LIBEDIT_EXPORT_BODY_BUTT, FALSE); + } + } + + else + { + if ( m_HToolBar ) + { + m_HToolBar->EnableTool(ID_LIBEDIT_IMPORT_PART,TRUE); + m_HToolBar->EnableTool(ID_LIBEDIT_EXPORT_PART,TRUE); + m_HToolBar->EnableTool(ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,TRUE); + m_HToolBar->EnableTool(ID_LIBEDIT_SAVE_CURRENT_PART,TRUE); + if ( (CurrentLibEntry->m_UnitCount > 1) || g_AsDeMorgan ) + m_HToolBar->EnableTool(ID_LIBEDIT_EDIT_PIN_BY_PIN, TRUE); + else + m_HToolBar->EnableTool(ID_LIBEDIT_EDIT_PIN_BY_PIN, FALSE); + + m_HToolBar->ToggleTool(ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn); + + m_HToolBar->EnableTool(ID_DE_MORGAN_CONVERT_BUTT, g_AsDeMorgan); + m_HToolBar->EnableTool(ID_DE_MORGAN_NORMAL_BUTT, g_AsDeMorgan); + /* Enable the "get doc" tool */ + bool enable_dtool = FALSE; + if ( ! CurrentAliasName.IsEmpty() ) + { + int AliasLocation = LocateAlias( CurrentLibEntry->m_AliasList, CurrentAliasName); + if ( AliasLocation >= 0 ) + if ( ! CurrentLibEntry->m_AliasList[AliasLocation+ALIAS_DOC_FILENAME].IsEmpty() ) + enable_dtool = TRUE; + } + else if ( ! CurrentLibEntry->m_DocFile.IsEmpty() ) enable_dtool = TRUE; + if ( enable_dtool ) m_HToolBar->EnableTool(ID_LIBEDIT_VIEW_DOC, TRUE); + else m_HToolBar->EnableTool(ID_LIBEDIT_VIEW_DOC, FALSE); + m_HToolBar->EnableTool(ID_LIBEDIT_CHECK_PART, TRUE); + m_SelpartBox->Enable( (CurrentLibEntry->m_UnitCount > 1 ) ? TRUE : FALSE); + + if ( GetScreen() ) + { + m_HToolBar->EnableTool(ID_LIBEDIT_UNDO,GetScreen()->m_UndoList); + m_HToolBar->EnableTool(ID_LIBEDIT_REDO,GetScreen()->m_RedoList); + } + } + + if ( m_VToolBar ) + { + m_VToolBar->EnableTool(ID_LIBEDIT_BODY_TEXT_BUTT, TRUE); + m_VToolBar->EnableTool(ID_LIBEDIT_BODY_LINE_BUTT, TRUE); + m_VToolBar->EnableTool(ID_LIBEDIT_BODY_RECT_BUTT, TRUE); + m_VToolBar->EnableTool(ID_LIBEDIT_BODY_CIRCLE_BUTT, TRUE); + m_VToolBar->EnableTool(ID_LIBEDIT_BODY_ARC_BUTT, TRUE); + m_VToolBar->EnableTool(ID_LIBEDIT_DELETE_ITEM_BUTT, TRUE); + m_VToolBar->EnableTool(ID_LIBEDIT_ANCHOR_ITEM_BUTT, TRUE); + m_VToolBar->EnableTool(ID_LIBEDIT_IMPORT_BODY_BUTT, TRUE); + m_VToolBar->EnableTool(ID_LIBEDIT_EXPORT_BODY_BUTT, TRUE); + } + } + + DisplayUnitsMsg(); +} + +/**************************************/ +int WinEDA_LibeditFrame::BestZoom(void) +/**************************************/ +{ +int dx, dy, ii,jj ; +int bestzoom; +wxSize size; +EDA_Rect BoundaryBox; + + if ( CurrentLibEntry ) + { + BoundaryBox = CurrentLibEntry->GetBoundaryBox(CurrentUnit, CurrentConvert); + dx = BoundaryBox.GetWidth(); + dy = BoundaryBox.GetHeight(); + } + + else + { + dx = m_CurrentScreen->m_CurrentSheet->m_Size.x; + dy = m_CurrentScreen->m_CurrentSheet->m_Size.y; + } + + size = DrawPanel->GetClientSize(); + size.x -= 60; // Pour marges haut et bas + ii = abs (dx / size.x); + jj = abs (dy / size.y); + + /* determination du zoom existant le plus proche */ + bestzoom = MAX(ii, jj) + 1; + + if ( CurrentLibEntry ) + { + m_CurrentScreen->m_Curseur = BoundaryBox.Centre(); + } + else + { + m_CurrentScreen->m_Curseur.x = 0; + m_CurrentScreen->m_Curseur.y = 0; + } + + return(bestzoom); +} + + + +/*************************************************************************/ +void WinEDA_LibeditFrame::Process_Special_Functions(wxCommandEvent& event) +/*************************************************************************/ +{ +int id = event.GetId(); +wxPoint pos; +wxClientDC dc(DrawPanel); + + DrawPanel->m_IgnoreMouseEvents = TRUE; + + DrawPanel->PrepareGraphicContext(&dc); + + wxGetMousePosition(&pos.x, &pos.y); + pos.y += 20; + + switch ( id ) // Arret de la commande de déplacement en cours + { + case ID_POPUP_LIBEDIT_END_CREATE_ITEM: + case ID_POPUP_LIBEDIT_PIN_EDIT: + case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM: + case ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM: + case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM: + case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM: + case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM: + case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM: + case ID_POPUP_LIBEDIT_CANCEL_EDITING : + case ID_POPUP_ZOOM_BLOCK: + case ID_POPUP_DELETE_BLOCK: + case ID_POPUP_COPY_BLOCK: + case ID_POPUP_SELECT_ITEMS_BLOCK: + case ID_POPUP_INVERT_BLOCK: + case ID_POPUP_PLACE_BLOCK: + case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT: + case ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT: + break; + + case ID_POPUP_LIBEDIT_DELETE_ITEM: + if ( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + break; + + default: + if ( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); + break; + } + + switch ( id ) + { + case ID_LIBEDIT_SAVE_CURRENT_LIB: + if( m_CurrentScreen->IsModify() ) + { + if( IsOK(this, _("Include last component changes") ) ) + SaveOnePartInMemory(); + } + SaveActiveLibrary(); + break; + + case ID_LIBEDIT_NEW_PART: + { + g_EditPinByPinIsOn = FALSE; + LibItemToRepeat = NULL; + CreateNewLibraryPart(); + GetScreen()->ClearUndoRedoList(); + ReDrawPanel(); + SetToolbars(); + break; + } + + case ID_LIBEDIT_SELECT_CURRENT_LIB: + SelectActiveLibrary(); + break; + + case ID_LIBEDIT_SELECT_PART: + LibItemToRepeat = NULL; + if ( LoadOneLibraryPart() ) + { + g_EditPinByPinIsOn = FALSE; + GetScreen()->ClearUndoRedoList(); + SetToolbars(); + } + ReDrawPanel(); + break; + + case ID_LIBEDIT_SAVE_CURRENT_PART: + SaveOnePartInMemory(); + break; + + case ID_LIBEDIT_GET_FRAME_EDIT_PART: + InstallLibeditFrame(pos); + break; + + case ID_LIBEDIT_DELETE_PART: + LibItemToRepeat = NULL; + DeleteOnePart(); + break; + + case ID_LIBEDIT_IMPORT_PART: + LibItemToRepeat = NULL; + ImportOnePart(); + GetScreen()->ClearUndoRedoList(); + ReDrawPanel(); + break; + + case ID_LIBEDIT_EXPORT_PART: + ExportOnePart(FALSE); + break; + + case ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART: + ExportOnePart(TRUE); + break; + + case ID_LIBEDIT_CHECK_PART : + if ( CurrentLibEntry ) + if ( TestPins(CurrentLibEntry) == FALSE ) + DisplayInfo(this, _(" Tst Pins OK!") ); + break; + + case ID_DE_MORGAN_NORMAL_BUTT: + m_HToolBar->ToggleTool(ID_DE_MORGAN_NORMAL_BUTT, TRUE); + m_HToolBar->ToggleTool(ID_DE_MORGAN_CONVERT_BUTT, FALSE); + LibItemToRepeat = NULL; + CurrentConvert = 1; + ReDrawPanel(); + break; + + case ID_DE_MORGAN_CONVERT_BUTT: + m_HToolBar->ToggleTool(ID_DE_MORGAN_NORMAL_BUTT, FALSE); + m_HToolBar->ToggleTool(ID_DE_MORGAN_CONVERT_BUTT, TRUE); + LibItemToRepeat = NULL; + CurrentConvert = 2; + ReDrawPanel(); + break; + + case ID_LIBEDIT_VIEW_DOC: + if ( CurrentLibEntry ) + { + wxString docfilename; + if ( ! CurrentAliasName.IsEmpty() ) + { + int AliasLocation = LocateAlias( CurrentLibEntry->m_AliasList, CurrentAliasName); + if ( AliasLocation >= 0 ) + docfilename = CurrentLibEntry->m_AliasList[AliasLocation+ALIAS_DOC_FILENAME]; + } + else docfilename = CurrentLibEntry->m_DocFile; + + if ( ! docfilename.IsEmpty() ) + GetAssociatedDocument(this, g_RealLibDirBuffer, docfilename); + } + break; + + case ID_LIBEDIT_EDIT_PIN_BY_PIN: + g_EditPinByPinIsOn = g_EditPinByPinIsOn ? FALSE : TRUE; + m_HToolBar->ToggleTool(ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn); + break; + + case ID_LIBEDIT_SELECT_PART_NUMBER: + { + int ii = m_SelpartBox->GetChoice(); + if ( ii < 0 ) return; + LibItemToRepeat = NULL; + CurrentUnit = ii + 1; + ReDrawPanel(); + } + break; + + case ID_LIBEDIT_SELECT_ALIAS: + { + int ii = m_SelAliasBox->GetChoice(); + if ( ii < 0 ) return; + LibItemToRepeat = NULL; + if ( ii > 0 ) CurrentAliasName = m_SelAliasBox->GetValue(); + else CurrentAliasName.Empty(); + ReDrawPanel(); + } + break; + + case ID_POPUP_LIBEDIT_PIN_EDIT: + InstallPineditFrame(this, &dc, pos); + break; + + case ID_LIBEDIT_PIN_BUTT: + if ( CurrentLibEntry ) + { + SetToolID( id, wxCURSOR_PENCIL, _("Add Pin")); + } + else + { + SetToolID( id, wxCURSOR_ARROW, _("Set Pin Opt")); + InstallPineditFrame(this, &dc, pos); + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + } + break; + + case ID_POPUP_LIBEDIT_CANCEL_EDITING : + if ( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + else + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + break; + + case ID_NO_SELECT_BUTT: + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + break; + + case ID_LIBEDIT_BODY_TEXT_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Text")); + break; + + case ID_LIBEDIT_BODY_RECT_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Rectangle")); + break; + + case ID_LIBEDIT_BODY_CIRCLE_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Circle")); + break; + + case ID_LIBEDIT_BODY_ARC_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Arc")); + break; + + case ID_LIBEDIT_BODY_LINE_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Line")); + break; + + case ID_LIBEDIT_ANCHOR_ITEM_BUTT : + SetToolID( id, wxCURSOR_HAND, _("Anchor")); + break; + + case ID_LIBEDIT_IMPORT_BODY_BUTT : + SetToolID( id, wxCURSOR_ARROW, _("Import")); + LoadOneSymbol(&dc); + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + break; + + case ID_LIBEDIT_EXPORT_BODY_BUTT : + SetToolID( id, wxCURSOR_ARROW, _("Export")); + SaveOneSymbol(); + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + break; + + case ID_POPUP_LIBEDIT_END_CREATE_ITEM: + DrawPanel->MouseToCursorSchema(); + if ( CurrentDrawItem ) + { + EndDrawGraphicItem(&dc); + } + break; + + case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM: + if ( CurrentDrawItem ) + { + DrawPanel->CursorOff(&dc); + switch ( CurrentDrawItem->m_StructType ) + { + case COMPONENT_ARC_DRAW_TYPE: + case COMPONENT_CIRCLE_DRAW_TYPE: + case COMPONENT_RECT_DRAW_TYPE: + case COMPONENT_POLYLINE_DRAW_TYPE: + case COMPONENT_LINE_DRAW_TYPE: + EditGraphicSymbol(&dc, CurrentDrawItem); + break; + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + EditSymbolText(&dc, CurrentDrawItem); + break; + } + DrawPanel->CursorOn(&dc); + } + break; + + + case ID_LIBEDIT_DELETE_ITEM_BUTT: + if ( CurrentLibEntry == NULL) { wxBell(); break; } + SetToolID( id, wxCURSOR_BULLSEYE, _("Delete item")); + break; + + + case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT: + // Delete the last created segment, while creating a polyline draw item + if ( CurrentDrawItem == NULL) break; + DrawPanel->MouseToCursorSchema(); + DeleteDrawPoly(&dc); + break; + + case ID_POPUP_LIBEDIT_DELETE_ITEM: + if ( CurrentDrawItem == NULL) break; + DrawPanel->MouseToCursorSchema(); + DrawPanel->CursorOff(&dc); + SaveCopyInUndoList(CurrentLibEntry); + if ( CurrentDrawItem->m_StructType == COMPONENT_PIN_DRAW_TYPE ) + { + DeletePin(&dc, CurrentLibEntry, (LibDrawPin*)CurrentDrawItem); + } + + else + { + if ( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur) + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + else DeleteOneLibraryDrawStruct(DrawPanel, &dc, CurrentLibEntry,CurrentDrawItem, TRUE); + } + + CurrentDrawItem = NULL; + m_CurrentScreen->SetModify(); + DrawPanel->CursorOn(&dc); + break; + + case ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST: + if ( CurrentDrawItem == NULL) break; + DrawPanel->MouseToCursorSchema(); + if ( CurrentDrawItem->m_StructType == COMPONENT_PIN_DRAW_TYPE ) + StartMovePin(&dc); + else if ( CurrentDrawItem->m_StructType == COMPONENT_FIELD_DRAW_TYPE ) + StartMoveField(&dc, (LibDrawField *) CurrentDrawItem); + else StartMoveDrawSymbol(&dc); + break; + + case ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT: + if ( CurrentDrawItem == NULL) break; + DrawPanel->CursorOff(&dc); + DrawPanel->MouseToCursorSchema(); + if ( (CurrentDrawItem->m_Flags & IS_NEW) == 0 ) + SaveCopyInUndoList(CurrentLibEntry); + RotateSymbolText(&dc); + DrawPanel->CursorOn(&dc); + break; + + case ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM: + if ( CurrentDrawItem == NULL) break; + DrawPanel->CursorOff(&dc); + DrawPanel->MouseToCursorSchema(); + if ( CurrentDrawItem->m_StructType == COMPONENT_FIELD_DRAW_TYPE ) + { + SaveCopyInUndoList(CurrentLibEntry); + RotateField(&dc, (LibDrawField *) CurrentDrawItem); + } + DrawPanel->CursorOn(&dc); + break; + + case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM: + if ( CurrentDrawItem == NULL) break; + DrawPanel->CursorOff(&dc); + if ( CurrentDrawItem->m_StructType == COMPONENT_FIELD_DRAW_TYPE ) + { + EditField(&dc, (LibDrawField *) CurrentDrawItem); + } + DrawPanel->CursorOn(&dc); + break; + + case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM: + case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM: + case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM: + if ( (CurrentDrawItem == NULL) || + (CurrentDrawItem->m_StructType != COMPONENT_PIN_DRAW_TYPE) ) + break; + SaveCopyInUndoList(CurrentLibEntry); + GlobalSetPins(&dc, (LibDrawPin *) CurrentDrawItem, id); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_ZOOM_BLOCK: + DrawPanel->m_AutoPAN_Request = FALSE; + GetScreen()->BlockLocate.m_Command = BLOCK_ZOOM; + HandleBlockEnd(&dc); + break; + + case ID_POPUP_DELETE_BLOCK: + DrawPanel->m_AutoPAN_Request = FALSE; + GetScreen()->BlockLocate.m_Command = BLOCK_DELETE; + DrawPanel->MouseToCursorSchema(); + HandleBlockEnd(&dc); + break; + + case ID_POPUP_COPY_BLOCK: + DrawPanel->m_AutoPAN_Request = FALSE; + GetScreen()->BlockLocate.m_Command = BLOCK_COPY; + DrawPanel->MouseToCursorSchema(); + HandleBlockPlace(&dc); + break; + + case ID_POPUP_SELECT_ITEMS_BLOCK: + DrawPanel->m_AutoPAN_Request = FALSE; + GetScreen()->BlockLocate.m_Command = BLOCK_SELECT_ITEMS_ONLY; + DrawPanel->MouseToCursorSchema(); + HandleBlockEnd(&dc); + break; + + case ID_POPUP_INVERT_BLOCK: + DrawPanel->m_AutoPAN_Request = FALSE; + GetScreen()->BlockLocate.m_Command = BLOCK_INVERT; + DrawPanel->MouseToCursorSchema(); + HandleBlockPlace(&dc); + break; + + case ID_POPUP_PLACE_BLOCK: + DrawPanel->m_AutoPAN_Request = FALSE; + DrawPanel->MouseToCursorSchema(); + HandleBlockPlace(&dc); + break; + + case ID_LIBEDIT_UNDO: + GetComponentFromUndoList(); + DrawPanel->Refresh(TRUE); + break; + + case ID_LIBEDIT_REDO: + GetComponentFromRedoList(); + DrawPanel->Refresh(TRUE); + break; + + default: + DisplayError(this, wxT("WinEDA_LibeditFrame::Process_Special_Functions error")); + break; + } + DrawPanel->MouseToCursorSchema(); + DrawPanel->m_IgnoreMouseEvents = FALSE; + + if ( m_ID_current_state == 0 ) LibItemToRepeat = NULL; +} + + diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp new file mode 100644 index 0000000000..8b408bc582 --- /dev/null +++ b/eeschema/load_one_schematic_file.cpp @@ -0,0 +1,969 @@ + /****************************************/ + /* Module to load/save EESchema files. */ + /****************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +#include "id.h" + +/* Format des fichiers: + - entete: +EESchema Schematic File Version n + - liste des librairies utilisees +LIBS:lib1,lib2,... + + - description des elements: + - ici Dimensions du schema, cartouche..: +$Descr A3 xx yy (format A3 (A..A0 / A..E / "user") xx yy = dims internes ) +$EndDescr + + - ici: polyline +P L 0 3 + 2208 1008 + 2208 1136 + 2128 1136 + + - ici: Segment (wire, bus) ( 1; W = segment type Wire, 2: W = Wire B = Bus + 3: L ou B = epaisseur ( L = ligne, B = bus) +W W L (W B B si bus) + 1856 1008 1856 1136 (debut X,Y fin X,Y) + + - ici: Raccord (wire, bus) +R W L + 1856 1008 1856 1136 (debut X,Y fin X,Y) + + - ici: Sheet ( Sous-feuille de hierarchie) +$Sheet +S 1856 1008 1856 1136 (debut X,Y fin X,Y) +F0 "texte" X X posx posy ; sheetname +F1 "texte" X X posx posy ; filename +Fn "label" type side posx posy size ; n lignes de label +$EndSheet + + - ici: composant +$Comp +L CAPACITOR C1 H H -30863 -14794 1968 1184 nom, ref, dir et pos + 1 2016 1136 1904 1024 2128 1248 multi, posx,y, rect encadrement + 1 0 0 -1 matrice de rotation/miroir +$EndComp +*/ + +/* Fonctions locales */ +static int ReadPartDescr(wxWindow * frame, char *Line, FILE *f, BASE_SCREEN *Window); +static int ReadSheetDescr(wxWindow * frame, char *Line, FILE *f, BASE_SCREEN * Window); +static int ReadSchemaDescr(wxWindow * frame, char *Line, FILE *f, BASE_SCREEN * Window); +static void LoadLayers(FILE *f, int * linecnt); + +/* Variables locales */ +static int LineCount; /* Decompte de num de ligne lue dans eeload() */ +static wxString MsgDiag; /* Error and log messages */ + +/************************************************************************************************/ +bool WinEDA_SchematicFrame::LoadOneEEFile(SCH_SCREEN *screen, const wxString & FullFileName) +/************************************************************************************************/ +/* Routine to load an EESchema file. +Returns TRUE if file has been loaded (at list partially.) +*/ +{ +char Line[1024], * SLine; +char Name1[256], + Name2[256]; +int ii, layer, orient, size; +wxPoint pos; +bool Failed = FALSE; +EDA_BaseStruct *Phead, *Pnext; +DrawJunctionStruct *ConnectionStruct; +DrawPolylineStruct *PolylineStruct; +EDA_DrawLineStruct * SegmentStruct; +DrawBusEntryStruct * RaccordStruct; +DrawMarkerStruct * MarkerStruct; +DrawNoConnectStruct * NoConnectStruct; + +FILE *f; + + if ( screen == NULL ) return FALSE; + if( FullFileName.IsEmpty() ) return FALSE; + + screen->m_CurrentItem = NULL; + + LineCount = 1; + if ((f = wxFopen(FullFileName, wxT("rt")) ) == NULL) + { + MsgDiag = _("Failed to open ") + FullFileName; + DisplayError(this, MsgDiag); + return FALSE; + } + + MsgDiag = _("Loading ") + FullFileName; + PrintMsg(MsgDiag); + + if (fgets(Line, 1024 - 1, f) == NULL || + strncmp(Line+9, SCHEMATIC_HEAD_STRING, sizeof(SCHEMATIC_HEAD_STRING) - 1) + != 0) + { + MsgDiag = FullFileName + _(" is NOT EESchema file"); + DisplayError(this, MsgDiag); + fclose(f); + return FALSE; + } + + LineCount++; + if(fgets(Line, 1024 - 1, f) == NULL || strncmp(Line, "LIBS:", 5) != 0) + { + MsgDiag = FullFileName + _(" is NOT EESchema file"); + DisplayError(this, MsgDiag); + fclose(f); + return FALSE; + } + + LoadLayers(f, &LineCount); + + while (!feof(f) && GetLine(f, Line, &LineCount, sizeof(Line)) != NULL) + { + SLine = Line; + while( (*SLine != ' ' ) && *SLine ) SLine++; + switch(Line[0]) + { + case '$': /* identification de bloc */ + if(Line[1] == 'C') + { + Failed = ReadPartDescr(this, Line, f, screen); + } + else if(Line[1] == 'S') + { + Failed = ReadSheetDescr(this, Line, f, screen); + } + else if(Line[1] == 'D') + { + Failed = ReadSchemaDescr(this, Line, f, screen); + } + break; + + case 'L': /* Its a library item. */ + Failed = ReadPartDescr(this, Line, f, screen); + break; /* Fin lecture 1 composant */ + + + case 'W': /* Its a Segment (WIRE or BUS) item. */ + if( sscanf(SLine, "%s %s", Name1, Name2) != 2 ) + { + MsgDiag.Printf( + wxT("EESchema file Segment struct error at line %d, aborted"), + LineCount); + Failed = TRUE; + break; + } + layer = LAYER_NOTES; + if( Name1[0] == 'W' ) layer = LAYER_WIRE; + if( Name1[0] == 'B' ) layer = LAYER_BUS; + + SegmentStruct = new EDA_DrawLineStruct(wxPoint(0,0),layer); + + LineCount++; + if (fgets(Line, 256 - 1, f) == NULL || + sscanf(Line, "%d %d %d %d ", + &SegmentStruct->m_Start.x,&SegmentStruct->m_Start.y, + &SegmentStruct->m_End.x,&SegmentStruct->m_End.y) != 4 ) + { + MsgDiag.Printf( + wxT("EESchema file Segment struct error at line %d, aborted"), + LineCount); + Failed = TRUE; + delete SegmentStruct; + break; + } + + if (!Failed) + { + SegmentStruct->Pnext = screen->EEDrawList; + screen->EEDrawList = (EDA_BaseStruct *) SegmentStruct; + } + break; + + + case 'E': /* Its a Raccord (WIRE or BUS) item. */ + if( sscanf(SLine, "%s %s", Name1, Name2) != 2 ) + { + MsgDiag.Printf( + wxT("EESchema file Raccord struct error at line %d, aborted"), + LineCount); + Failed = TRUE; + break; + } + + ii = WIRE_TO_BUS; + if( Name1[0] == 'B' ) ii = BUS_TO_BUS; + RaccordStruct = new DrawBusEntryStruct(wxPoint(0,0), '\\', ii); + LineCount++; + if (fgets(Line, 256 - 1, f) == NULL || + sscanf(Line, "%d %d %d %d ", + &RaccordStruct->m_Pos.x,&RaccordStruct->m_Pos.y, + &RaccordStruct->m_Size.x,&RaccordStruct->m_Size.y) != 4 ) + { + MsgDiag.Printf( + wxT("EESchema file Raccord struct error at line %d, aborted"), + LineCount); + Failed = TRUE; + delete RaccordStruct; + break; + } + + if (!Failed) + { + RaccordStruct->m_Size.x -= RaccordStruct->m_Pos.x; + RaccordStruct->m_Size.y -= RaccordStruct->m_Pos.y; + RaccordStruct->Pnext = screen->EEDrawList; + screen->EEDrawList = RaccordStruct; + } + break; + + case 'P': /* Its a polyline item. */ + if (sscanf(SLine, "%s %s %d", Name1, Name2, &ii) != 3 ) + { + MsgDiag.Printf( + wxT("EESchema file polyline struct error at line %d, aborted"), + LineCount); + Failed = TRUE; + break; + } + layer = LAYER_NOTES; + if( Name2[0] == 'W' ) layer = LAYER_WIRE; + if( Name2[0] == 'B' ) layer = LAYER_BUS; + + PolylineStruct = new DrawPolylineStruct(layer); + + PolylineStruct->m_NumOfPoints = ii; + PolylineStruct->m_Points = (int *) MyZMalloc(sizeof(int) * 2 * + PolylineStruct->m_NumOfPoints); + for (ii = 0; ii < PolylineStruct->m_NumOfPoints; ii++) + { + LineCount++; + if (fgets(Line, 256 - 1, f) == NULL || + sscanf(Line, "%d %d", &PolylineStruct->m_Points[ii*2], + &PolylineStruct->m_Points[ii*2+1]) != 2) + { + MsgDiag.Printf( + wxT("EESchema file polyline struct error at line %d, aborted"), + LineCount); + Failed = TRUE; + delete PolylineStruct; + break; + } + } + + if (!Failed) + { + PolylineStruct->Pnext = screen->EEDrawList; + screen->EEDrawList = (EDA_BaseStruct *) + PolylineStruct; + } + break; + + case 'C': /* Its a connection item. */ + ConnectionStruct = new DrawJunctionStruct(wxPoint(0,0)); + if (sscanf(SLine, "%s %d %d", Name1, + &ConnectionStruct->m_Pos.x, + &ConnectionStruct->m_Pos.y) != 3) + { + MsgDiag.Printf( + wxT("EESchema file connection struct error at line %d, aborted"), + LineCount); + Failed = TRUE; + delete ConnectionStruct; + } + else + { + ConnectionStruct->Pnext = screen->EEDrawList; + screen->EEDrawList = ConnectionStruct; + } + break; + + case 'N': /* Its a NoConnect item. */ + if (sscanf(SLine, "%s %d %d", Name1, &pos.x, &pos.y) != 3) + { + MsgDiag.Printf( + wxT("EESchema file NoConnect struct error at line %d, aborted"), + LineCount); + Failed = TRUE; + } + else + { + NoConnectStruct = new DrawNoConnectStruct(pos); + NoConnectStruct->Pnext = screen->EEDrawList; + screen->EEDrawList = NoConnectStruct; + } + break; + + case 'K': /* Its a MarKer item. */ + if (sscanf(SLine, "%s %d %d", Name1, &pos.x, &pos.y) != 3) + { + MsgDiag.Printf( + wxT("EESchema file marker struct error line %d, aborted"), + LineCount); + Failed = TRUE; + } + else + { + char * text; + char BufLine[1024]; + MarkerStruct = new DrawMarkerStruct(pos,wxEmptyString); + ii = ReadDelimitedText(BufLine, Line, 256 ); + MarkerStruct->m_Type = (TypeMarker)((Name1[0] & 255) - 'A'); + if( MarkerStruct->m_Type < 0 ) + MarkerStruct->m_Type = MARQ_UNSPEC; + if ( ii ) MarkerStruct->m_Comment = CONV_FROM_UTF8(BufLine); + text = strstr(Line," F="); + if (text) + { + sscanf(text+3, "%X", &ii); + MarkerStruct->m_MarkFlags = ii; + } + MarkerStruct->Pnext = screen->EEDrawList; + screen->EEDrawList = MarkerStruct; + } + break; + + case 'T': /* Its a text item. */ + { + EDA_BaseStruct * Struct = NULL; + *Name1 = *Name2 = 0; + ii = sscanf(SLine, "%s %d %d %d %d %s", + Name1, &pos.x, &pos.y, &orient, &size, Name2); + + if( ii < 4 ) + { + MsgDiag.Printf( + wxT("EESchema file text struct error line %d, aborted"), + LineCount); + Failed = TRUE; + } + else if( fgets(Line, 256 - 1, f) == NULL ) + { + LineCount++; + MsgDiag.Printf( + wxT("EESchema file text struct error line %d (No text), aborted"), + LineCount); + Failed = TRUE; + } + else + { + LineCount++; + if( size == 0 ) size = DEFAULT_SIZE_TEXT; + char * text = strtok(Line, "\n\r"); + if ( text == NULL ) break; + + if( Name1[0] == 'L' ) + { + DrawLabelStruct * TextStruct = + new DrawLabelStruct(pos, CONV_FROM_UTF8(text)); + TextStruct->m_Size.x = TextStruct->m_Size.y = size; + TextStruct->m_Orient = orient; + Struct = (EDA_BaseStruct*)TextStruct; + } + else if( Name1[0] == 'G' ) + { + DrawGlobalLabelStruct * TextStruct = + new DrawGlobalLabelStruct(pos, CONV_FROM_UTF8(text)); + Struct = (EDA_BaseStruct*)TextStruct; + TextStruct->m_Size.x = TextStruct->m_Size.y = size; + TextStruct->m_Orient = orient; + if( stricmp(Name2,SheetLabelType[NET_OUTPUT]) == 0 ) + TextStruct->m_Shape = NET_OUTPUT; + if( stricmp(Name2,SheetLabelType[NET_BIDI]) == 0 ) + TextStruct->m_Shape = NET_BIDI; + if( stricmp(Name2,SheetLabelType[NET_TRISTATE]) == 0 ) + TextStruct->m_Shape = NET_TRISTATE; + if( stricmp(Name2,SheetLabelType[NET_UNSPECIFIED]) == 0 ) + TextStruct->m_Shape = NET_UNSPECIFIED; + } + else + { + DrawTextStruct * TextStruct = + new DrawTextStruct(pos, CONV_FROM_UTF8(text)); + TextStruct->m_Size.x = TextStruct->m_Size.y = size; + TextStruct->m_Orient = orient; + Struct = (EDA_BaseStruct*)TextStruct; + } + if (Struct ) + { + Struct->Pnext = screen->EEDrawList; + screen->EEDrawList = Struct; + } + } + break; + } + + default: + Failed = FALSE; + MsgDiag.Printf( + wxT("EESchema file undef structdef at line %d, aborted"), + LineCount); + break; + } + + if (Failed) + { + DisplayError(this, MsgDiag); + break; + } + } + + /* EEDrawList was constructed in reverse order - reverse it back: */ + Phead = NULL; + while (screen->EEDrawList) + { + Pnext = screen->EEDrawList; + screen->EEDrawList = screen->EEDrawList->Pnext; + Pnext->Pnext = Phead; + Phead = Pnext; + } + screen->EEDrawList = Phead; + + fclose(f); + + TestDanglingEnds(screen->EEDrawList, NULL); + + return TRUE; /* Although it may be that file is only partially loaded. */ +} + + + +/*************************************************************/ +static int ReadPartDescr(wxWindow * frame, char *Line, FILE *f, + BASE_SCREEN * Window) +/*************************************************************/ + +/* Fonction utilisee par LoadEEFile(). + Lit les lignes relatives a la description d'un composant en schema +*/ +{ +int ii, fieldref; +char Name1[256], Name2[256], + Char1[256], Char2[256], Char3[256]; +EDA_SchComponentStruct *LibItemStruct; +int Failed = 0, newfmt = 0; +char * ptcar; + + LibItemStruct = new EDA_SchComponentStruct(); + LibItemStruct->m_Convert = 1; + + if(Line[0] == '$') + { + newfmt = 1; + LineCount++; + if( fgets(Line, 256 - 1, f) == 0) return(TRUE); + } + + /* Traitement de la 1ere ligne de description */ + if( sscanf(&Line[1], "%s %s", Name1, Name2) != 2 ) + { + MsgDiag.Printf( + wxT("EESchema Component descr error at line %d, aborted"), + LineCount); + Failed = TRUE; + return(Failed); + } + + if (strcmp(Name1, NULL_STRING) != 0) + { + for (ii = 0; ii < (int)strlen(Name1); ii++) + if (Name1[ii] == '~') Name1[ii] = ' '; + LibItemStruct->m_ChipName = CONV_FROM_UTF8(Name1); + if( !newfmt ) + LibItemStruct->m_Field[VALUE].m_Text = CONV_FROM_UTF8(Name1); + } + else + { + LibItemStruct->m_ChipName.Empty(); + LibItemStruct->m_Field[VALUE].m_Text.Empty(); + LibItemStruct->m_Field[VALUE].m_Orient = TEXT_ORIENT_HORIZ; + LibItemStruct->m_Field[VALUE].m_Attributs = TEXT_NO_VISIBLE; + } + + if (strcmp(Name2, NULL_STRING) != 0) + { + for (ii = 0; ii < (int)strlen(Name2); ii++) + if (Name2[ii] == '~') Name2[ii] = ' '; + if(!newfmt) LibItemStruct->m_Field[REFERENCE].m_Text = CONV_FROM_UTF8(Name2); + } + else + { + LibItemStruct->m_Field[REFERENCE].m_Attributs = TEXT_NO_VISIBLE; + } + + /* Traitement des autres lignes de description */ + /* Ces lignes commencent par: + "P " = position + "U " = Num Unit, et Conversion + "Fn" = Champs ( n = 0.. = numero de champ ) + */ + + /* Lecture des champs */ + for(;;) + { + LineCount++; + if( fgets(Line, 256 - 1, f) == NULL ) return(TRUE); + if( (Line[0] != 'F' ) && + (Line[0] != 'P' ) && + (Line[0] != 'U' ) ) + break; + + if( Line[0] == 'U' ) /* Lecture num multi, conversion et time stamp */ + { + sscanf(Line+1,"%d %d %lX", + &LibItemStruct->m_Multi, &LibItemStruct->m_Convert, + &LibItemStruct->m_TimeStamp); + } + + if( Line[0] == 'P' ) + { + sscanf(Line+1,"%d %d", + &LibItemStruct->m_Pos.x, &LibItemStruct->m_Pos.y); + } + + if( Line[0] == 'F' ) + { + char FieldUserName[1024]; + int hjustify = GR_TEXT_HJUSTIFY_CENTER; + int vjustify = GR_TEXT_VJUSTIFY_CENTER; + + FieldUserName[0] = 0; + + sscanf(Line+1,"%d", &fieldref); + if( fieldref >= NUMBER_OF_FIELDS) + { + MsgDiag.Printf( + wxT("Component Field number error at line %d, aborted"), + LineCount); + return(TRUE); + } + /* Lecture du champ */ + ptcar = Line; while( *ptcar && (*ptcar != '"') ) ptcar++; + if( *ptcar != '"') + { + MsgDiag.Printf( + wxT("EESchema file lib field F at line %d, aborted"), + LineCount); + return(TRUE); + } + + for(ptcar++, ii = 0; ; ii++, ptcar++ ) + { + Name1[ii] = *ptcar; + if( *ptcar == 0 ) + { + MsgDiag.Printf( + wxT("Component field F at line %d, aborted"), + LineCount); + return(TRUE); + } + if( *ptcar == '"' ) + { + Name1[ii] = 0; ptcar++; + break; + } + } + + if(LibItemStruct->m_Field[fieldref].m_Text.IsEmpty()) + LibItemStruct->m_Field[fieldref].m_Text = CONV_FROM_UTF8(Name1); + + /* Lecture des coordonnees */ + if( (ii = sscanf(ptcar, "%s %d %d %d %X %s %s", Char1, + &LibItemStruct->m_Field[fieldref].m_Pos.x, + &LibItemStruct->m_Field[fieldref].m_Pos.y, + &LibItemStruct->m_Field[fieldref].m_Size.x, + &LibItemStruct->m_Field[fieldref].m_Attributs, + Char2, Char3) ) < 4 ) + { + MsgDiag.Printf( + wxT("Component Field error line %d, aborted"), + LineCount); + DisplayError(frame, MsgDiag); + continue; + } + + ReadDelimitedText(FieldUserName,ptcar, sizeof(FieldUserName) ); + if( (LibItemStruct->m_Field[fieldref].m_Size.x == 0 ) || (ii == 4) ) + LibItemStruct->m_Field[fieldref].m_Size.x = DEFAULT_SIZE_TEXT; + LibItemStruct->m_Field[fieldref].m_Orient = TEXT_ORIENT_HORIZ; + LibItemStruct->m_Field[fieldref].m_Size.y = LibItemStruct->m_Field[fieldref].m_Size.x; + if(Char1[0] == 'V') + LibItemStruct->m_Field[fieldref].m_Orient = TEXT_ORIENT_VERT; + if ( ii >= 7 ) + { + if ( *Char2 == 'L' ) hjustify = GR_TEXT_HJUSTIFY_LEFT; + else if ( *Char2 == 'R' ) hjustify = GR_TEXT_HJUSTIFY_RIGHT; + if ( *Char3 == 'B' ) vjustify = GR_TEXT_VJUSTIFY_BOTTOM; + else if ( *Char3 == 'T' ) vjustify = GR_TEXT_VJUSTIFY_TOP; + LibItemStruct->m_Field[fieldref].m_HJustify = hjustify; + LibItemStruct->m_Field[fieldref].m_VJustify = vjustify; + } + + if ( fieldref >= FIELD1 ) + { + LibItemStruct->m_Field[fieldref].m_Name = CONV_FROM_UTF8(FieldUserName); + } + +// 27 juin 2001: A Supprimer lorsque tous les schemas auront ete traites : +if ( fieldref == REFERENCE ) + if (LibItemStruct->m_Field[fieldref].m_Text[0] == '#' ) + LibItemStruct->m_Field[fieldref].m_Attributs |= TEXT_NO_VISIBLE; + } + } + + + /* Lecture multi et position du composant */ + if( sscanf(Line, "%d %d %d", + &LibItemStruct->m_Multi, + &LibItemStruct->m_Pos.x, &LibItemStruct->m_Pos.y) != 3) + { + MsgDiag.Printf( + wxT("Component unit & pos error at line %d, aborted"), + LineCount); + Failed = TRUE; + return(Failed); + } + + /* Lecture de la matrice de miroir / rotation */ + LineCount++; + if( (fgets(Line, 256 - 1, f) == NULL) || + (sscanf(Line, "%d %d %d %d", + &LibItemStruct->m_Transform[0][0], + &LibItemStruct->m_Transform[0][1], + &LibItemStruct->m_Transform[1][0], + &LibItemStruct->m_Transform[1][1]) != 4) ) + { + MsgDiag.Printf( + wxT("Component orient error at line %d, aborted"), + LineCount); + Failed = TRUE; + return(Failed); + } + + if(newfmt) + { + LineCount++; + if( fgets(Line, 256 - 1, f) == NULL ) return(TRUE); + if( strnicmp("$End", Line,4) != 0 ) + { + MsgDiag.Printf( + wxT("Component End expected at line %d, aborted"), + LineCount); + Failed = TRUE; + } + } + + if (!Failed) + { + LibItemStruct->Pnext = Window->EEDrawList; + Window->EEDrawList = (EDA_BaseStruct *) LibItemStruct; + } + + return(Failed); /* Fin lecture 1 composant */ +} + + +/*************************************************************************************/ +static int ReadSheetDescr(wxWindow * frame, char *Line, FILE *f, BASE_SCREEN * Window) +/*************************************************************************************/ +/* Fonction utilisee par LoadEEFile(). + Lit les lignes relatives a la description d'une feuille de hierarchie +*/ +{ +int ii, fieldref, size; +char Name1[256], Char1[256], Char2[256]; +DrawSheetStruct *SheetStruct; +DrawSheetLabelStruct *SheetLabelStruct, *OldSheetLabel = NULL; +int Failed = FALSE; +char * ptcar; + + SheetStruct = new DrawSheetStruct(); + SheetStruct->m_TimeStamp = GetTimeStamp(); + SheetStruct->m_Parent = Window; + + if(Line[0] == '$') /* Ligne doit etre "$Sheet" */ + { + LineCount++; + if( fgets(Line, 256 - 1, f) == 0) + { + MsgDiag.Printf( wxT("Read File Errror") ); return(TRUE); + } + } + + /* Next line: must be "S xx yy nn mm" with xx, yy = sheet position + ( upper left corner ) et nn,mm = sheet size */ + if( (sscanf(&Line[1], "%d %d %d %d", + &SheetStruct->m_Pos.x, &SheetStruct->m_Pos.y, + &SheetStruct->m_Size.x, &SheetStruct->m_Size.y) != 4) || + (Line[0] != 'S' ) ) + { + MsgDiag.Printf( + wxT(" ** EESchema file sheet struct error at line %d, aborted"), + LineCount); + Failed = TRUE; + return(Failed); + } + + /* Lecture des champs */ + for(;;) /* Analyse des lignes "Fn "texte" .." */ + { + LineCount++; + if( fgets(Line, 256 - 1, f) == NULL ) return(TRUE); + if( Line[0] != 'F' ) break; + sscanf(Line+1,"%d", &fieldref); + /* Lecture du champ : + si fieldref >= 2 : Fn "texte" t s posx posy + sinon F0 "texte" pour sheetname + et F1 "texte" pour filename */ + + ptcar = Line; while( *ptcar && (*ptcar != '"') ) ptcar++; + if( *ptcar != '"') + { + MsgDiag.Printf( + wxT(" ** EESchema file sheet label F%d at line %d, aborted"), + fieldref, LineCount); + return(TRUE); + } + + for(ptcar++, ii = 0; ; ii++, ptcar++ ) + { + Name1[ii] = *ptcar; + if( *ptcar == 0 ) + { + MsgDiag.Printf( + wxT(" ** EESchema file sheet field F at line %d, aborted"), LineCount); + return(TRUE); + } + if( *ptcar == '"' ) + { + Name1[ii] = 0; ptcar++; + break; + } + } + + if( ( fieldref == 0 ) || ( fieldref == 1 ) ) + { + if( sscanf(ptcar, "%d", &size) != 1 ) + { + MsgDiag.Printf( + wxT(" ** EESchema file sheet Label Caract error line %d, aborted"),LineCount); + DisplayError(frame, MsgDiag); + } + if(size == 0) size = DEFAULT_SIZE_TEXT; + if ( fieldref == 0 ) + { + SheetStruct->m_SheetName = CONV_FROM_UTF8(Name1); + SheetStruct->m_SheetNameSize = size; + } + else + { + SheetStruct->m_FileName = CONV_FROM_UTF8(Name1); + SheetStruct->m_FileNameSize = size; + } + } + + if( fieldref > 1 ) + { + SheetLabelStruct = new DrawSheetLabelStruct(SheetStruct, + wxPoint(0,0), CONV_FROM_UTF8(Name1) ); + if( SheetStruct->m_Label == NULL ) + OldSheetLabel = SheetStruct->m_Label = SheetLabelStruct; + else OldSheetLabel->Pnext = (EDA_BaseStruct*)SheetLabelStruct; + OldSheetLabel = SheetLabelStruct; + + /* Lecture des coordonnees */ + if( sscanf(ptcar, "%s %s %d %d %d", Char1, Char2, + &SheetLabelStruct->m_Pos.x, &SheetLabelStruct->m_Pos.y, + &size) != 5 ) + { + MsgDiag.Printf( + wxT(" ** EESchema file Sheet Label Caract error line %d, aborted"),LineCount); + DisplayError(frame, MsgDiag); + continue; + } + + if(size == 0) size = DEFAULT_SIZE_TEXT; + SheetLabelStruct->m_Size.x = SheetLabelStruct->m_Size.y = size; + /* Mise a jour des cadrage et type */ + switch( Char1[0]) + { + case 'I': SheetLabelStruct->m_Shape = NET_INPUT; break; + case 'O': SheetLabelStruct->m_Shape = NET_OUTPUT; break; + case 'B': SheetLabelStruct->m_Shape = NET_BIDI; break; + case 'T': SheetLabelStruct->m_Shape = NET_TRISTATE; break; + case 'U': SheetLabelStruct->m_Shape = NET_UNSPECIFIED; break; + } + if( Char2[0] == 'R' ) SheetLabelStruct->m_Edge = 1; + } + } + + if( strnicmp("$End", Line,4) != 0 ) + { + MsgDiag.Printf( + wxT(" **EESchema file end_sheet struct error at line %d, aborted"), + LineCount); + Failed = TRUE; + } + + if (!Failed) + { + SheetStruct->Pnext = Window->EEDrawList; + Window->EEDrawList = (EDA_BaseStruct *) SheetStruct; + } + + return(Failed); /* Fin lecture 1 composant */ +} + + +/******************************************************************/ +static int ReadSchemaDescr(wxWindow * frame, char *Line, FILE *f, BASE_SCREEN * Window) +/******************************************************************/ +/* Analyse de l'entete du schema ( dims feuille, cartouche..) +*/ +{ +char Text[256], buf[1024]; +int ii; +Ki_PageDescr * wsheet = &g_Sheet_A4; +static Ki_PageDescr * SheetFormatList[] = { + &g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2, &g_Sheet_A1, &g_Sheet_A0, + &g_Sheet_A, &g_Sheet_B, &g_Sheet_C, &g_Sheet_D, &g_Sheet_E, + &g_Sheet_user, NULL}; +wxSize PageSize; + + sscanf(Line, "%s %s %d %d", Text, Text, & PageSize.x, & PageSize.y); + /* Recherche de la descr correspondante: */ + wxString pagename = CONV_FROM_UTF8(Text); + for(ii = 0; SheetFormatList[ii] != NULL; ii++ ) + { + wsheet = SheetFormatList[ii]; + if( wsheet->m_Name.CmpNoCase(pagename) == 0 ) + { /* Descr found ! */ + if ( wsheet == & g_Sheet_user ) // Get the user page size and make it the default + { + g_Sheet_user.m_Size = PageSize; + } + break; + } + } + + if( SheetFormatList[ii] == NULL ) + { + /* Erreur ici: descr non trouvee */ + MsgDiag.Printf( + wxT("EESchema file Dims Caract error line %d, aborted"),LineCount); + DisplayError(frame, MsgDiag); + } + + /* Ajuste ecran */ + Window->m_CurrentSheet = wsheet; + + /* Recheche suite et fin de descr */ + for( ;; ) + { + if( GetLine(f, Line, &LineCount, 1024 ) == NULL ) return(TRUE); + if( strnicmp(Line,"$End",4) == 0 ) break; + + if( strnicmp(Line,"Sheet",2) == 0 ) + sscanf( Line+5," %d %d", + &Window->m_SheetNumber,&Window->m_NumberOfSheet); + + if( strnicmp(Line,"Title",2) == 0 ) + { + ReadDelimitedText( buf, Line, 256); + Window->m_Title = CONV_FROM_UTF8(buf); + continue; + } + + if( strnicmp(Line,"Date",2) == 0 ) + { + ReadDelimitedText( buf, Line, 256); + Window->m_Date = CONV_FROM_UTF8(buf); + continue; + } + + if( strnicmp(Line,"Rev",2) == 0 ) + { + ReadDelimitedText( buf, Line, 256); + Window->m_Revision = CONV_FROM_UTF8(buf); + continue; + } + + if( strnicmp(Line,"Comp",4) == 0 ) + { + ReadDelimitedText( buf, Line, 256); + Window->m_Company = CONV_FROM_UTF8(buf); + continue; + } + + if( strnicmp(Line,"Comment1",8) == 0 ) + { + ReadDelimitedText( buf, Line, 256); + Window->m_Commentaire1 = CONV_FROM_UTF8(buf); + continue; + } + + if( strnicmp(Line,"Comment2",8) == 0 ) + { + ReadDelimitedText( buf, Line, 256); + Window->m_Commentaire2 = CONV_FROM_UTF8(buf); + continue; + } + + if( strnicmp(Line,"Comment3",8) == 0 ) + { + ReadDelimitedText( buf, Line, 256); + Window->m_Commentaire3 = CONV_FROM_UTF8(buf); + continue; + } + + if( strnicmp(Line,"Comment4",8) == 0 ) + { + ReadDelimitedText( buf, Line, 256); + Window->m_Commentaire4 = CONV_FROM_UTF8(buf); + continue; + } + } + return(FALSE); +} + +/***********************************/ +static void LoadLayers(FILE *f, int * linecnt) +/***********************************/ +/* Load the Layer Struct from a file +*/ +{ +int cnt = 0, Number; +char Line[1024]; +//int Mode,Color,Layer; +char Name[256]; + + GetLine(f, Line, NULL, sizeof(Line) ); /* read line */ + (*linecnt)++; + sscanf(Line,"%s %d %d",Name,&Number,&g_LayerDescr.CurrentLayer); + if( strcmp(Name,"EELAYER") !=0 ) + { + /* error : init par defaut */ + Number = MAX_LAYER; + } + if ( Number <= 0 ) Number = MAX_LAYER; + if ( Number > MAX_LAYER ) Number = MAX_LAYER; + + g_LayerDescr.NumberOfLayers=Number; + + while( GetLine(f, Line, NULL, sizeof(Line)) ) + { + (*linecnt)++; + if( strnicmp(Line,"EELAYER END",11) == 0 ) break; + cnt++; + } +} + + diff --git a/eeschema/locate.cpp b/eeschema/locate.cpp new file mode 100644 index 0000000000..b5b23e7672 --- /dev/null +++ b/eeschema/locate.cpp @@ -0,0 +1,1095 @@ + /******************************************************/ + /* Routines de localisation d'un element d'un schema. */ + /******************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "trigo.h" +#include "macros.h" + +#include "protos.h" + +/* Routines exportees */ +int distance(int dx, int dy, int spot_cX, int spot_cY, int seuil); + +/* Routines Locales */ +static EDA_BaseStruct *LastSnappedStruct = NULL; +static int PickedBoxMinX, PickedBoxMinY, PickedBoxMaxX, PickedBoxMaxY ; +static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1, + int StartX2, int StartY2, int EndX2, int EndY2 ); +static bool IsPointInBox( int pX, int pY, + int BoxX1, int BoxY1, int BoxX2, int BoxY2 ); +static bool IsPointOnSegment( int pX, int pY, + int SegmX1, int SegmY1, int SegmX2, int SegmY2, int seuil = 0); +static bool SnapPoint2(const wxPoint & PosRef, int SearchMask, + EDA_BaseStruct *DrawList, DrawPickedStruct *DontSnapList); + + + +/*********************************************************************/ +EDA_SchComponentStruct * LocateSmallestComponent( SCH_SCREEN * Screen ) +/*********************************************************************/ +/* Recherche du plus petit (en surface) composant pointe par la souris + Si 2 (ou plus) composants sont trouves, un pointeur sur le composant + le plus petit est retourne +*/ +{ +EDA_SchComponentStruct * DrawLibItem = NULL, * LastDrawLibItem = NULL; +EDA_BaseStruct *DrawList; +EDA_Rect BoundaryBox; +float sizeref = 0, sizecurr; + + DrawList = Screen->EEDrawList; + + while ( DrawList ) + { + if( ( SnapPoint2(Screen->m_Curseur, LIBITEM, + DrawList,NULL)) == FALSE ) break; + DrawLibItem = (EDA_SchComponentStruct *) LastSnappedStruct; + DrawList = DrawLibItem->Pnext; + if ( LastDrawLibItem == NULL ) // First time a component is located + { + LastDrawLibItem = DrawLibItem; + BoundaryBox = LastDrawLibItem->GetBoundaryBox(); + sizeref = ABS((float)BoundaryBox.GetWidth() * BoundaryBox.GetHeight()); + } + else + { + BoundaryBox = DrawLibItem->GetBoundaryBox(); + sizecurr = ABS((float)BoundaryBox.GetWidth() * BoundaryBox.GetHeight()); + if ( sizeref > sizecurr ) // a smallest component is found + { + sizeref = sizecurr; + LastDrawLibItem = DrawLibItem; + } + } + } + + return LastDrawLibItem; +} + + +/* 2 functions EDA_BaseStruct * PickStruct: + Search in block, or Search at location pos + + SearchMask = (bitwise OR): + LIBITEM + WIREITEM + BUSITEM + RACCORDITEM + JUNCTIONITEM + DRAWITEM + TEXTITEM + LABELITEM + SHEETITEM + MARKERITEM + NOCONNECTITEM + SEARCH_PINITEM + SHEETLABELITEM + FIELDCMPITEM + + if EXCLUDE_WIRE_BUS_ENDPOINTS is set, in wire ou bus search and locate, + start and end points are not included in search + if WIRE_BUS_ENDPOINTS_ONLY is set, in wire ou bus search and locate, + only start and end points are included in search + + + Return: + -Bloc searc: + pointeur sur liste de pointeurs de structures si Plusieurs + structures selectionnees. + pointeur sur la structure si 1 seule + + Positon serach: + pointeur sur la structure. + Si pas de structures selectionnees: retourne NULL + +*/ +/***********************************************************************/ +EDA_BaseStruct * PickStruct(const wxPoint & refpos, + EDA_BaseStruct *DrawList, int SearchMask ) +/************************************************************************/ +/* Search an item at pos pos +*/ +{ +bool Snapped; + + if ( DrawList == NULL ) return NULL; + + if( (Snapped = SnapPoint2(refpos, SearchMask, + DrawList,NULL)) != FALSE) + { + return( LastSnappedStruct); + } + return( NULL ); +} + +/***********************************************************************/ +EDA_BaseStruct * PickStruct( EDA_Rect & block, + EDA_BaseStruct *DrawList, int SearchMask ) +/************************************************************************/ +/* Search items in block +*/ +{ +int x, y, OrigX, OrigY; +DrawPickedStruct *PickedList = NULL, *PickedItem; +EDA_BaseStruct *DrawStruct; + + OrigX = block.GetX(); + OrigY = block.GetY(); + x = block.GetRight(); + y = block.GetBottom(); + + if (x < OrigX) EXCHG(x, OrigX); + if (y < OrigY) EXCHG(y, OrigY); + + for (DrawStruct = DrawList; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext) + { + if( DrawStructInBox(OrigX, OrigY, x, y, DrawStruct) ) + { + /* Put this structure in the picked list: */ + PickedItem = new DrawPickedStruct(DrawStruct); + PickedItem->Pnext = PickedList; + PickedList = PickedItem; + } + } + + if (PickedList && PickedList->Pnext == NULL) + { + /* Only one item was picked - convert to scalar form (no list): */ + PickedItem = PickedList; + PickedList = (DrawPickedStruct *) PickedList->m_PickedStruct; + delete PickedItem; + } + + if (PickedList != NULL) + { + PickedBoxMinX = OrigX; PickedBoxMinY = OrigY; + PickedBoxMaxX = x; PickedBoxMaxY = y; + } + + return PickedList; +} + +/***************************************************************************** +* Routine to search all objects for the closest point to a given point, in * +* drawing space, and snap it to that points if closer than SnapDistance. * +* Note we use L1 norm as distance measure, as it is the fastest. * +* This routine updates LastSnappedStruct to the last object used in to snap * +* a point. This variable is global to this module only (see above). * +* If DontSnapList is not NULL, structes in this list are skipped. * +* The routine returns TRUE if point was snapped. * +*****************************************************************************/ +bool SnapPoint2(const wxPoint & PosRef, int SearchMask, + EDA_BaseStruct *DrawList, DrawPickedStruct *DontSnapList) +{ +int i, *Points, x = PosRef.x, y = PosRef.y; +int x1, y1, x2, y2, NumOfPoints2; +DrawPickedStruct *DontSnap; +int dx, dy; + + for (; DrawList != NULL; DrawList = DrawList->Pnext) + { + /* Make sure this structure is NOT in the dont snap list: */ + DontSnap = DontSnapList; + for( ; DontSnap != NULL; DontSnap = (DrawPickedStruct *)DontSnap->Pnext) + if (DontSnap->m_PickedStruct == DrawList) break; + + if(DontSnap) if (DontSnap->m_PickedStruct == DrawList) continue; + + switch (DrawList->m_StructType) + { + case DRAW_POLYLINE_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawPolylineStruct *) DrawList) + if( !(SearchMask & (DRAWITEM|WIREITEM|BUSITEM)) ) break; + Points = STRUCT->m_Points; + NumOfPoints2 = STRUCT->m_NumOfPoints * 2; + for (i = 0; i < NumOfPoints2 - 2; i += 2) + { + x1 = Points[i]; y1 = Points[i+1]; + x2 = Points[i+2]; y2 = Points[i+3]; + if (IsPointOnSegment(x,y, x1, y1, x2, y2) ) + { + LastSnappedStruct = DrawList; + return(TRUE); + } + } + break; + + case DRAW_SEGMENT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((EDA_DrawLineStruct *) DrawList) + if( !(SearchMask & (DRAWITEM|WIREITEM|BUSITEM)) ) break; + + if (IsPointOnSegment(x,y, STRUCT->m_Start.x,STRUCT->m_Start.y , + STRUCT->m_End.x, STRUCT->m_End.y) ) + { + if( ((SearchMask & DRAWITEM) && (STRUCT->m_Layer == LAYER_NOTES)) || + ((SearchMask & WIREITEM) && (STRUCT->m_Layer == LAYER_WIRE)) || + ((SearchMask & BUSITEM) && (STRUCT->m_Layer == LAYER_BUS)) + ) + { + if (SearchMask & EXCLUDE_WIRE_BUS_ENDPOINTS) + { + if ( x == STRUCT->m_Start.x && y == STRUCT->m_Start.y ) + break; + if ( x == STRUCT->m_End.x && y == STRUCT->m_End.y ) + break; + } + + if (SearchMask & WIRE_BUS_ENDPOINTS_ONLY) + { + if ( ! STRUCT->IsOneEndPointAt(wxPoint(x, y)) ) break; + } + + LastSnappedStruct = DrawList; + return(TRUE); + } + } + break; + + + case DRAW_BUSENTRY_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawBusEntryStruct *) DrawList) + if( !(SearchMask & (RACCORDITEM)) ) break; + + if (IsPointOnSegment(x,y, STRUCT->m_Pos.x,STRUCT->m_Pos.y, + STRUCT->m_End().x, STRUCT->m_End().y) ) + { + LastSnappedStruct = DrawList; + return(TRUE); + } + break; + + case DRAW_JUNCTION_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawJunctionStruct *) DrawList) + if( !(SearchMask & JUNCTIONITEM) )break; + x1 = STRUCT->m_Pos.x - (DRAWJUNCTION_SIZE / 2); + y1 = STRUCT->m_Pos.y - (DRAWJUNCTION_SIZE / 2); + x2 = STRUCT->m_Pos.x + (DRAWJUNCTION_SIZE / 2); + y2 = STRUCT->m_Pos.y + (DRAWJUNCTION_SIZE / 2); + if(IsPointInBox(x, y, x1,y1, x2,y2) ) + { + LastSnappedStruct = DrawList; + return(TRUE); + } + break; + + + case DRAW_NOCONNECT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawNoConnectStruct *) DrawList) + if( !(SearchMask & NOCONNECTITEM) )break; + x1 = STRUCT->m_Pos.x - (DRAWNOCONNECT_SIZE / 2); + y1 = STRUCT->m_Pos.y - (DRAWNOCONNECT_SIZE / 2); + x2 = STRUCT->m_Pos.x + (DRAWNOCONNECT_SIZE / 2); + y2 = STRUCT->m_Pos.y + (DRAWNOCONNECT_SIZE / 2); + if(IsPointInBox(x, y, x1,y1, x2,y2) ) + { + LastSnappedStruct = DrawList; + return(TRUE); + } + break; + + case DRAW_MARKER_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawMarkerStruct *) DrawList) + if( !(SearchMask & MARKERITEM) )break; + x1 = STRUCT->m_Pos.x - DRAWMARKER_SIZE / 4; + y1 = STRUCT->m_Pos.y - DRAWMARKER_SIZE / 4; + x2 = STRUCT->m_Pos.x + DRAWMARKER_SIZE / 4; + y2 = STRUCT->m_Pos.y + DRAWMARKER_SIZE / 4; + if(IsPointInBox(x, y, x1,y1, x2,y2) ) + { + LastSnappedStruct = DrawList; + return(TRUE); + } + break; + + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawTextStruct *) DrawList) + if( !(SearchMask & (TEXTITEM|LABELITEM)) ) break; + dx = STRUCT->m_Size.x * STRUCT->GetLength(); + dy = STRUCT->m_Size.y; + x1 = x2 = STRUCT->m_Pos.x; + y1 = y2 = STRUCT->m_Pos.y; + switch( STRUCT->m_Orient) + { + case 0 : /* HORIZONTAL */ + x2 += dx; y2 -= dy; + break; + + case 1 : /* VERTICAL UP */ + x2 -= dy; y2 -= dx; + break; + + case 2 : /* horizontal inverse */ + x2 -= dx; y2 += dy; + break; + + case 3 : /* vertical DOWN */ + x2 += dy; y2 += dx; + break; + } + if(IsPointInBox(x, y, x1,y1, x2,y2) ) + { + LastSnappedStruct = DrawList; + return(TRUE); + } + break; + + + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawGlobalLabelStruct *) DrawList) + if( !(SearchMask & LABELITEM) ) break; + dx = STRUCT->m_Size.x * ( STRUCT->GetLength() + 1 ); /* longueur */ + dy = STRUCT->m_Size.y / 2; /* Demi hauteur */ + x1 = x2 = STRUCT->m_Pos.x; + y1 = y2 = STRUCT->m_Pos.y; + switch( STRUCT->m_Orient) + { + case 0 : /* HORIZONTAL */ + x2 -= dx; y2 += dy; y1 -= dy; + break; + + case 1 : /* VERTICAL UP */ + x1 -= dy; x2 += dy; y2 += dx; + break; + + case 2 : /* horizontal inverse */ + x2 += dx; y2 += dy; y1 -= dy; + break; + + case 3 : /* vertical DOWN */ + x1 -= dy; x2 += dy; y2 -= dx; + break; + } + if(IsPointInBox(x, y, x1,y1, x2,y2) ) + { + LastSnappedStruct = DrawList; + return(TRUE); + } + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE: + if( !(SearchMask & (LIBITEM|FIELDCMPITEM) ) ) break; + + if ( SearchMask & FIELDCMPITEM ) + { + PartTextStruct * Field; + EDA_SchComponentStruct * DrawLibItem = (EDA_SchComponentStruct *) DrawList; + for ( i = REFERENCE; i < NUMBER_OF_FIELDS; i++ ) + { + Field = &DrawLibItem->m_Field[i]; + if ( (Field->m_Attributs & TEXT_NO_VISIBLE) ) continue; + if ( Field->IsVoid() ) continue; + EDA_Rect BoundaryBox = Field->GetBoundaryBox(); + if(BoundaryBox.Inside(x, y) ) + { + LastSnappedStruct = Field; + return TRUE; + } + } + } + else + { + #undef STRUCT + #define STRUCT ((EDA_SchComponentStruct *) DrawList) + EDA_Rect BoundaryBox = STRUCT->GetBoundaryBox(); + if ( BoundaryBox.Inside(x, y) ) + { + LastSnappedStruct = DrawList; + return TRUE; + } + } + break; + + case DRAW_SHEET_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawSheetStruct *) DrawList) + if( !(SearchMask & SHEETITEM) ) break; + /* Recalcul des coordonnees de l'encadrement du composant */ + x1 = STRUCT->m_Pos.x; + y1 = STRUCT->m_Pos.y; + x2 = STRUCT->m_Pos.x + STRUCT->m_Size.x; + y2 = STRUCT->m_Pos.y + STRUCT->m_Size.y; + + if(IsPointInBox(x, y, x1, y1, x2, y2) ) + { + LastSnappedStruct = DrawList; + return TRUE; + } + break; + + case DRAW_PICK_ITEM_STRUCT_TYPE : break; + + default: + { + wxString msg; + msg.Printf(wxT("SnapPoint2() error: unexpected strct type %d ("), DrawList->m_StructType); + msg << DrawList->ReturnClassName() << wxT(")"); + DisplayError(NULL, msg); + break; + } + } + } + return FALSE; +} + + +/***************************************************************************** +* Routine to test if an object has non empty intersection with the box * +* defined by x1/y1 and x2/y2 (x1 < x2, y1 < y2), and return TRUE if so. This * +* routine is used to pick all points in a given box. * +*****************************************************************************/ +bool DrawStructInBox(int x1, int y1, int x2, int y2, + EDA_BaseStruct *DrawStruct) +{ +int i, *Points, xt1, yt1, xt2, yt2, NumOfPoints2; +int dx, dy; +wxString msg; + + switch (DrawStruct->m_StructType) + { + case DRAW_POLYLINE_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawPolylineStruct *) DrawStruct) + Points = STRUCT->m_Points; + NumOfPoints2 = STRUCT->m_NumOfPoints * 2; + for (i = 0; i < NumOfPoints2; i += 2) + { + if (Points[i] >= x1 && Points[i] <= x2 && + Points[i+1] >= y1 && Points[i+1] <=y2) return TRUE; + } + break; + + case DRAW_SEGMENT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((EDA_DrawLineStruct *) DrawStruct) + if( STRUCT->m_Start.x >= x1 && STRUCT->m_Start.x <= x2 && + STRUCT->m_Start.y >= y1 && STRUCT->m_Start.y <=y2) return TRUE; + if( (STRUCT->m_End.x >= x1) && (STRUCT->m_End.x <= x2) && + (STRUCT->m_End.y >= y1) && (STRUCT->m_End.y <=y2) ) return TRUE; + break; + + case DRAW_BUSENTRY_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawBusEntryStruct *) DrawStruct) + if( STRUCT->m_Pos.x >= x1 && STRUCT->m_Pos.x <= x2 && + STRUCT->m_Pos.y >= y1 && STRUCT->m_Pos.y <=y2) + return TRUE; + if( (STRUCT->m_End().x >= x1) && ( STRUCT->m_End().x <= x2) && + ( STRUCT->m_End().y >= y1) && ( STRUCT->m_End().y <=y2) ) + return TRUE; + break; + + case DRAW_JUNCTION_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawJunctionStruct *) DrawStruct) + if( (STRUCT->m_Pos.x >= x1) && (STRUCT->m_Pos.x <= x2) && + (STRUCT->m_Pos.y >= y1) && (STRUCT->m_Pos.y <= y2) ) + return TRUE; + break; + + + case DRAW_NOCONNECT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawNoConnectStruct *) DrawStruct) + if( (STRUCT->m_Pos.x >= x1) && (STRUCT->m_Pos.x <= x2) && + (STRUCT->m_Pos.y >= y1) && (STRUCT->m_Pos.y <= y2) ) + return TRUE; + break; + + + case DRAW_MARKER_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawMarkerStruct *) DrawStruct) + if( (STRUCT->m_Pos.x >= x1) && (STRUCT->m_Pos.x <= x2) && + (STRUCT->m_Pos.y >= y1) && (STRUCT->m_Pos.y <= y2) ) + return TRUE; + break; + + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawTextStruct *) DrawStruct) + dx = STRUCT->m_Size.x * STRUCT->GetLength(); + dy = STRUCT->m_Size.y; + xt1 = xt2 = STRUCT->m_Pos.x; + yt1 = yt2 = STRUCT->m_Pos.y; + switch( STRUCT->m_Orient) + { + case 0 : /* HORIZONTAL */ + xt2 += dx; yt2 -= dy; + break; + + case 1 : /* VERTICAL UP */ + xt2 -= dy; yt2 -= dx; + break; + + case 2 : /* horizontal inverse */ + xt2 -= dx; yt2 += dy; + break; + + case 3 : /* vertical DOWN */ + xt2 += dy; yt2 += dx; + break; + } + if( IsBox1InBox2(xt1,yt1, xt2, yt2, x1, y1, x2, y2) ) return TRUE; + break; + + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawGlobalLabelStruct *) DrawStruct) + dx = STRUCT->m_Size.x * ( STRUCT->GetLength() + 1); /* longueur totale */ + dy = STRUCT->m_Size.y / 2; /* Demi hauteur */ + xt1 = xt2 = STRUCT->m_Pos.x; + yt1 = yt2 = STRUCT->m_Pos.y; + switch( STRUCT->m_Orient) + { + case 0 : /* HORIZONTAL */ + xt2 -= dx; yt2 += dy; yt1 -= dy; + break; + + case 1 : /* VERTICAL UP */ + xt1 -= dy; xt2 += dy; yt2 += dx; + break; + + case 2 : /* horizontal inverse */ + xt2 += dx; yt2 += dy; yt1 -= dy; + break; + + case 3 : /* vertical DOWN */ + xt1 -= dy; xt2 += dy; yt2 -= dx; + break; + } + if( IsBox1InBox2(xt1,yt1, xt2, yt2, x1, y1, x2, y2) ) return TRUE; + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE: + { + #undef STRUCT + #define STRUCT ((EDA_SchComponentStruct *) DrawStruct) + EDA_Rect BoundaryBox = STRUCT->GetBoundaryBox(); + xt1 = BoundaryBox.GetX(); + yt1 = BoundaryBox.GetY(); + xt2 = BoundaryBox.GetRight(); + yt2 = BoundaryBox.GetBottom(); + if( IsBox1InBox2(xt1,yt1, xt2, yt2, x1, y1, x2, y2) ) return TRUE; + break; + } + + case DRAW_SHEET_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((DrawSheetStruct *) DrawStruct) + /* Recalcul des coordonnees de l'encadrement du composant */ + xt1 = STRUCT->m_Pos.x; + yt1 = STRUCT->m_Pos.y; + xt2 = STRUCT->m_Pos.x + STRUCT->m_Size.x; + yt2 = STRUCT->m_Pos.y + STRUCT->m_Size.y; + + if( IsBox1InBox2(xt1,yt1, xt2, yt2, x1, y1, x2, y2) ) + return TRUE; + break; + + case DRAW_SHEETLABEL_STRUCT_TYPE : break; + case DRAW_PICK_ITEM_STRUCT_TYPE : break; + + default: + msg.Printf( + wxT("DrawStructInBox() Err: unexpected StructType %d ("), + DrawStruct->m_StructType ); + msg << DrawStruct->ReturnClassName() << wxT(")"); + DisplayError(NULL, msg ); + break; + } + + return FALSE; +} + +/****************************************************************************/ +static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1, + int StartX2, int StartY2, int EndX2, int EndY2 ) +/****************************************************************************/ +/* Routine detectant que le rectangle 1 (Box1) et le rectangle 2 (Box2) se +recouvrent. + Retourne TRUE ou FALSE. + + On Considere ici qu'il y a recouvrement si l'un au moins des coins + d'un 'Box' est compris dans l'autre +*/ +{ +int cX, cY; + + if(StartX1 > EndX1) EXCHG(StartX1, EndX1); + if(StartX2 > EndX2) EXCHG(StartX2, EndX2); + if(StartY1 > EndY1) EXCHG(StartY1, EndY1); + if(StartY2 > EndY2) EXCHG(StartY2, EndY2); + + /* Tst des 4 coins du rectangle 1 */ + cX = StartX1; cY = StartY1; /* 1er coin */ + if( (cX >= StartX2) && (cX <= EndX2) && (cY >= StartY2) && (cY <= EndY2) ) + return(TRUE); + + cX = EndX1; cY = StartY1; /* 2er coin */ + if( (cX >= StartX2) && (cX <= EndX2) && (cY >= StartY2) && (cY <= EndY2) ) + return(TRUE); + + cX = EndX1; cY = EndY1; /* 3eme coin */ + if( (cX >= StartX2) && (cX <= EndX2) && (cY >= StartY2) && (cY <= EndY2) ) + return(TRUE); + + cX = StartX1; cY = EndY1; /* 4eme coin */ + if( (cX >= StartX2) && (cX <= EndX2) && (cY >= StartY2) && (cY <= EndY2) ) + return(TRUE); + + /* Tst des 4 coins du rectangle 2 */ + cX = StartX2; cY = StartY2; /* 1er coin */ + if( (cX >= StartX1) && (cX <= EndX1) && (cY >= StartY1) && (cY <= EndY1) ) + return(TRUE); + + cX = EndX2; cY = StartY2; /* 2er coin */ + if( (cX >= StartX1) && (cX <= EndX1) && (cY >= StartY1) && (cY <= EndY1) ) + return(TRUE); + + cX = EndX2; cY = EndY2; /* 3er coin */ + if( (cX >= StartX1) && (cX <= EndX1) && (cY >= StartY1) && (cY <= EndY1) ) + return(TRUE); + + cX = StartX2; cY = EndY2; /* 4er coin */ + if( (cX >= StartX1) && (cX <= EndX1) && (cY >= StartY1) && (cY <= EndY1) ) + return(TRUE); + + + return(FALSE); +} + + +/**********************************************************************/ +static bool IsPointInBox( int pX, int pY, + int BoxX1, int BoxY1, int BoxX2, int BoxY2 ) +/**********************************************************************/ +/* Routine detectant que le point pX,pY est dans le rectangle (Box) + Retourne TRUE ou FALSE. + +*/ +{ + if(BoxX1 > BoxX2) EXCHG(BoxX1, BoxX2); + if(BoxY1 > BoxY2) EXCHG(BoxY1, BoxY2); + + if( (pX >= BoxX1) && (pX <= BoxX2) && (pY >= BoxY1) && (pY <= BoxY2) ) + return(TRUE); + + else return(FALSE); +} + + +/********************************************************************************/ +static bool IsPointOnSegment( int pX, int pY, + int SegmX1, int SegmY1, int SegmX2, int SegmY2, int seuil ) +/********************************************************************************/ +/* Routine detectant que le point pX,pY est sur le Segment X1,Y1 a X2,Y2 + Retourne TRUE ou FALSE. +*/ +{ + /* Recalcul des coord avec SegmX1, SegmX2 comme origine */ + pX -= SegmX1; pY -= SegmY1; + SegmX2 -= SegmX1; SegmY2 -= SegmY1; + + if( distance( SegmX2, SegmY2, pX, pY, seuil ) ) return(TRUE); + + else return(FALSE); +} + +/****************************************************************/ +LibEDA_BaseStruct * LocateDrawItem(SCH_SCREEN * Screen, EDA_LibComponentStruct * LibEntry, + int Unit, int Convert, int masque) +/****************************************************************/ +/* Routine de localisation d'un element de dessin de symbole( sauf pins ) + Unit = Unite d'appartenance (si Unit = 0, recherche sur toutes unites) + Convert = Conversion d'appartenance (si Convert = 0, recherche sur + toutes variantes) +*/ +{ +int x, y, dx, dy, ii, *ptpoly; +int px, py; +LibEDA_BaseStruct * DrawItem; +int seuil; + + if( LibEntry == NULL ) return(NULL); + + if ( LibEntry->Type != ROOT ) + { + DisplayError(NULL, wxT("Error in LocateDrawItem: Entry is ALIAS")); + return(NULL); + } + + DrawItem = LibEntry->m_Drawings; + + seuil = 3; /* Tolerance: 1/2 pas de petite grille */ + px = Screen->m_Curseur.x; + py = Screen->m_Curseur.y; + + for( ; DrawItem != NULL ; DrawItem = DrawItem->Next() ) + { + if(Unit && DrawItem->m_Unit && (Unit != DrawItem->m_Unit) ) continue; + if(Convert && DrawItem->m_Convert && (Convert != DrawItem->m_Convert) ) + continue; + + switch ( DrawItem->m_StructType ) + { + case COMPONENT_ARC_DRAW_TYPE: + { + LibDrawArc * Arc = (LibDrawArc *) DrawItem; + if( (masque & LOCATE_COMPONENT_ARC_DRAW_TYPE) == 0) break; + dx = px - Arc->m_Pos.x; + dy = py + Arc->m_Pos.y; + ii = (int)sqrt( dx*dx + dy*dy); + if ( abs(ii - Arc->m_Rayon) <= seuil) return( DrawItem); + } + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + { + LibDrawCircle * Circle = (LibDrawCircle *) DrawItem; + if( (masque & LOCATE_COMPONENT_CIRCLE_DRAW_TYPE) == 0) break; + dx = px - Circle->m_Pos.x; + dy = py + Circle->m_Pos.y; + ii = (int)sqrt( dx*dx + dy*dy); + if ( abs(ii - Circle->m_Rayon) <= seuil) return( DrawItem); + } + break; + + case COMPONENT_RECT_DRAW_TYPE: + { + LibDrawSquare * Square = (LibDrawSquare *) DrawItem; + if( (masque & LOCATE_COMPONENT_RECT_DRAW_TYPE) == 0) break; + if(IsPointOnSegment(px,py, + Square->m_Start.x, - Square->m_Start.y, + Square->m_End.x, - Square->m_Start.y, seuil) ) + return(DrawItem); + if(IsPointOnSegment(px, py, + Square->m_End.x, - Square->m_Start.y, + Square->m_End.x, - Square->m_End.y, seuil) ) + return(DrawItem); + if(IsPointOnSegment(px, py, + Square->m_End.x, - Square->m_End.y, + Square->m_Start.x, - Square->m_End.y, seuil) ) + return(DrawItem); + if(IsPointOnSegment(px, py, + Square->m_Start.x, - Square->m_End.y, + Square->m_Start.x, - Square->m_Start.y, seuil) ) + return(DrawItem); + } + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + { + LibDrawPolyline * polyline = (LibDrawPolyline *) DrawItem; + if( (masque & LOCATE_COMPONENT_POLYLINE_DRAW_TYPE) == 0) break; + ptpoly = polyline->PolyList; + for( ii = polyline->n-1; ii > 0; ii--, ptpoly += 2) + { + if(IsPointOnSegment(px, py, + ptpoly[0], - ptpoly[1], ptpoly[2], - ptpoly[3], seuil) ) + return(DrawItem); + } + } + break; + + case COMPONENT_LINE_DRAW_TYPE: + { + LibDrawSegment * Segment = (LibDrawSegment *) DrawItem; + if( (masque & LOCATE_COMPONENT_LINE_DRAW_TYPE) == 0) break; + if(IsPointOnSegment(px, py, + Segment->m_Start.x, - Segment->m_Start.y, + Segment->m_End.x, - Segment->m_End.y, seuil) ) + return(DrawItem); + } + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + { + LibDrawText * Text = (LibDrawText *) DrawItem; + if( (masque & LOCATE_COMPONENT_GRAPHIC_TEXT_DRAW_TYPE) == 0) break; + ii = Text->m_Text.Len(); if ( ii < 2 ) ii = 2; + dx = (Text->m_Size.x * ii) / 2; + dy = Text->m_Size.y / 2; + if(Text->m_Horiz == TEXT_ORIENT_VERT) + { + EXCHG(dx,dy); + } + x = px - Text->m_Pos.x; + y = py + Text->m_Pos.y; + if( (abs(x) <= dx) && (abs(y) <= dy) ) + return(DrawItem); /* Texte trouve */ + } + break; + } + } + return(NULL); +} + + +/****************************************************************/ +int distance(int dx, int dy, int spot_cX, int spot_cY, int seuil) +/****************************************************************/ +/* + Calcul de la distance du point spot_cx,spot_cy a un segment de droite, + d'origine 0,0 et d'extremite dx, dy; + retourne: + 0 si distance > seuil + 1 si distance <= seuil + Variables utilisees ( sont ramenees au repere centre sur l'origine du segment) + dx, dy = coord de l'extremite segment. + spot_cX,spot_cY = coord du curseur souris + la recherche se fait selon 4 cas: + segment horizontal + segment vertical + segment quelconque +*/ +{ +int cXrot, cYrot , /* coord du point (souris) dans le repere tourne */ + segX, segY; /* coord extremite segment tj >= 0 */ +int pointX, pointY; /* coord point a tester dans repere modifie dans lequel + segX et segY sont >=0 */ + + segX = dx ; segY = dy; pointX = spot_cX ; pointY = spot_cY ; + + /*Recalcul coord pour que le segment soit dans 1er quadrant (coord >= 0)*/ + if (segX < 0) /* mise en0 par symetrie par rapport a l'axe Y */ + { + segX = -segX ; pointX = - pointX ; + } + if (segY < 0) /* mise en > 0 par symymetrie par rapport a l'axe X */ + { + segY = -segY ; pointY = -pointY ; + } + + + if ( segY == 0 ) /* piste Horizontale */ + { + if(abs(pointY) <= seuil ) + { + if((pointX >= 0) && (pointX <= segX) ) return(1); + /* Etude des extremites : cercle de rayon seuil */ + if( (pointX < 0) && (pointX >= -seuil) ) + { + if( ((pointX * pointX) + (pointY*pointY)) <= (seuil*seuil) ) + return(1); + } + if( (pointX > segX) && (pointX <= (segX+seuil)) ) + { + if( (((pointX-segX) * (pointX-segX)) + (pointY*pointY)) <= (seuil*seuil) ) + return(1); + } + } + } + + else if ( segX == 0 ) /* piste verticale */ + { + if( abs(pointX) <= seuil) + { + if((pointY >= 0 ) && (pointY <= segY) ) return(1); + if( (pointY < 0) && (pointY >= -seuil) ) + { + if( ((pointY * pointY) + (pointX*pointX)) <= (seuil*seuil) ) + return(1); + } + if( (pointY > segY) && (pointY <= (segY+seuil)) ) + { + if( ( ((pointY-segY) * (pointY-segY)) + (pointX*pointX)) <= (seuil*seuil) ) + return(1); + } + } + } + + else /* orientation quelconque */ + { + /* On fait un changement d'axe (rotation) de facon a ce que le segment + de piste soit horizontal dans le nouveau repere */ + int angle; + + angle = (int)( atan2((float)segY, (float)segX) * 1800 / M_PI) ; + cXrot = pointX; cYrot = pointY; + RotatePoint(&cXrot, &cYrot, angle); /* Rotation du point a tester */ + RotatePoint(&segX, &segY, angle) ; /* Rotation du segment */ + + /*la piste est Horizontale , par suite des modifs de coordonnes + et d'axe, donc segX = longueur du segment */ + + if ( abs(cYrot) <= seuil ) /* ok sur axe vertical) */ + { + if ((cXrot >= 0) && (cXrot <= segX) ) return(1) ; + /* Etude des extremites : cercle de rayon seuil */ + if( (cXrot < 0) && (cXrot >= -seuil) ) + { + if( ((cXrot * cXrot) + (cYrot*cYrot)) <= (seuil*seuil) ) + return(1); + } + if( (cXrot > segX) && (cXrot <= (segX+seuil)) ) + { + if( (((cXrot-segX) * (cXrot-segX)) + (cYrot*cYrot)) <= (seuil*seuil) ) + return(1); + } + } + } + return(0) ; +} + + + +/*******************************************************************/ +LibEDA_BaseStruct * LocatePin( const wxPoint & RefPos, + EDA_LibComponentStruct * Entry, + int Unit, int convert, EDA_SchComponentStruct * DrawLibItem) +/*******************************************************************/ +/* Routine de localisation d'une PIN de la PartLib pointee par Entry + retourne un pointeur sur la pin, ou NULL si pas trouve + Si Unit = 0, le numero d'unite n'est pas teste + Si convert = 0, le numero convert n'est pas teste + + m_Transform = matrice de transformation. + Si NULL: matrice de transformation " normale" [1 , 0 , 0 , -1] + (la matrice de transformation " normale" etant [1 , 0 , 0 , -1] + la coord dy doit etre inversee). + PartX, PartY: coordonnees de positionnement du composant +*/ +{ +LibEDA_BaseStruct * DrawItem; +LibDrawPin * Pin; +int x1, y1, x2, y2; + + if ( Entry == NULL ) return(NULL); + + if ( Entry->Type != ROOT ) + { + DisplayError(NULL, wxT("LocatePin() error: Entry is ALIAS")); + return(NULL); + } + + DrawItem = Entry->m_Drawings; + for ( ; DrawItem != NULL; DrawItem = DrawItem->Next()) + { + if(DrawItem->m_StructType == COMPONENT_PIN_DRAW_TYPE) /* Pin Trouvee */ + { + Pin = (LibDrawPin *) DrawItem; + + if( Unit && DrawItem->m_Unit && (DrawItem->m_Unit != Unit) ) + continue; + + if( convert && DrawItem->m_Convert && (DrawItem->m_Convert != convert) ) + continue; + + x2 = Pin->m_Pos.x; + y2 = Pin->m_Pos.y; + x1 = Pin->ReturnPinEndPoint().x; + y1 = Pin->ReturnPinEndPoint().y; + + if(DrawLibItem == NULL ) + { + y1 = -y1; y2 = -y2; + } + else + { + int x = x1, y = y1; + x1 = DrawLibItem->m_Pos.x + DrawLibItem->m_Transform[0][0] * x + + DrawLibItem->m_Transform[0][1] * y; + y1 = DrawLibItem->m_Pos.y + DrawLibItem->m_Transform[1][0] * x + + DrawLibItem->m_Transform[1][1] * y; + x = x2; y = y2; + x2 = DrawLibItem->m_Pos.x + DrawLibItem->m_Transform[0][0] * x + + DrawLibItem->m_Transform[0][1] * y; + y2 = DrawLibItem->m_Pos.y + DrawLibItem->m_Transform[1][0] * x + + DrawLibItem->m_Transform[1][1] * y; + } + + if (x1 > x2 ) EXCHG(x1,x2); if (y1 > y2 ) EXCHG(y1,y2); + + if( (RefPos.x >= x1) && (RefPos.x <= x2) && + (RefPos.y >= y1) && (RefPos.y <= y2) ) + return(DrawItem); + } + } + return(NULL); +} + +/***********************************************************************************/ +DrawSheetLabelStruct * LocateSheetLabel(DrawSheetStruct *Sheet, const wxPoint & pos) +/***********************************************************************************/ +{ +int size , dy, minx, maxx; +DrawSheetLabelStruct * SheetLabel; + + SheetLabel = Sheet->m_Label; + while((SheetLabel) && (SheetLabel->m_StructType==DRAW_SHEETLABEL_STRUCT_TYPE)) + { + size = ( SheetLabel->GetLength()+1 ) * SheetLabel->m_Size.x; + if (SheetLabel->m_Edge) size = -size ; + minx = SheetLabel->m_Pos.x; maxx = SheetLabel->m_Pos.x + size; + if( maxx < minx ) EXCHG(maxx,minx); + dy = SheetLabel->m_Size.x / 2; + if( (ABS(pos.y - SheetLabel->m_Pos.y) <= dy ) && + (pos.x <= maxx) && + (pos.x >= minx) ) + return(SheetLabel); + SheetLabel = (DrawSheetLabelStruct *) SheetLabel->Pnext; + } + return(NULL); +} + +/**************************************************************************/ +LibDrawPin * LocateAnyPin(EDA_BaseStruct *DrawList, const wxPoint & RefPos, + EDA_SchComponentStruct ** libpart) +/**************************************************************************/ +{ +EDA_BaseStruct *DrawStruct; +EDA_LibComponentStruct * Entry; +EDA_SchComponentStruct * LibItem = NULL; +LibDrawPin * Pin = NULL; + + for(DrawStruct = DrawList; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) + { + if( DrawStruct->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + continue; + LibItem = (EDA_SchComponentStruct *) DrawStruct; + Entry = FindLibPart( LibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if( Entry == NULL ) continue; + Pin = (LibDrawPin *) LocatePin(RefPos, Entry, LibItem->m_Multi, + LibItem->m_Convert, LibItem); + if( Pin ) break; + } + if ( libpart ) *libpart = LibItem; + return Pin; +} + +/***************************************************************/ +DrawSheetLabelStruct * LocateAnyPinSheet(const wxPoint & RefPos, + EDA_BaseStruct *DrawList) +/***************************************************************/ +{ +EDA_BaseStruct *DrawStruct; +DrawSheetLabelStruct * PinSheet = NULL; + + for( DrawStruct = DrawList; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) + { + if( DrawStruct->m_StructType != DRAW_SHEET_STRUCT_TYPE ) + continue; + PinSheet = LocateSheetLabel( (DrawSheetStruct *) DrawStruct, + RefPos); + if( PinSheet ) break; + } + return PinSheet; +} + diff --git a/eeschema/makefile.g95 b/eeschema/makefile.g95 new file mode 100644 index 0000000000..b9e6516bb0 --- /dev/null +++ b/eeschema/makefile.g95 @@ -0,0 +1,32 @@ +# File: makefile for eeschema, mingw + + +TARGET=eeschema + +WXDIR = $(WXWIN) +include ../libs.win + + +all: $(TARGET).exe + +include makefile.include + + +$(TARGET).exe: $(OBJECTS) $(TARGET)_resources.o $(EDALIBS) + $(CXX) $(ALL_LDFLAGS) -o $(TARGET).exe $(OBJECTS)\ + $(TARGET)_resources.o $(EDALIBS) $(SYSWXLIB) + +install: + cp -v $(TARGET).exe $(KICAD_BIN) + + +$(TARGET)_resources.o: $(TARGET).rc + $(RESCOMP) $(RCINPUTSWITCH) $(TARGET).rc $(RCOUTPUTSWITCH) $(TARGET)_resources.o $(RESFLAGS) + +clean : + -$(RM) *.o + -$(RM) *.rsc + -$(RM) *.res + -$(RM) *.exe + -$(RM) *.bak + diff --git a/eeschema/makefile.gtk b/eeschema/makefile.gtk new file mode 100644 index 0000000000..010bf78e50 --- /dev/null +++ b/eeschema/makefile.gtk @@ -0,0 +1,47 @@ +## Makefile for eeschema +CC = gcc +#LD = c++ pour utiliser libstdc++ dynamique +LD = gcc + +FINAL = 1 + + +LDFLAGS = -s + +include ../libs.linux + +TARGET = eeschema + + +CPPFLAGS = -Wall -O2 `wx-config --cxxflags` + + +all: $(TARGET) + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + +$(TARGET): $(OBJECTS) makefile.gtk makefile.include $(EXTRALIBS) ../libs.linux + $(LD) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $(TARGET) + +netlist_form_pads-pcb: plugins/netlist_form_pads-pcb.cpp makefile.gtk + gcc -D__UNIX__ -Wall plugins/netlist_form_pads-pcb.cpp $(LIBSTDC) -o netlist_form_pads-pcb + + +install: + cp $(TARGET) $(KICAD_BIN) + + +clean: + rm -f *.o; rm -f *~; rm core; rm *.bak + rm -f $(TARGET) + + + + + + + + diff --git a/eeschema/makefile.include b/eeschema/makefile.include new file mode 100644 index 0000000000..5fa6c7ea38 --- /dev/null +++ b/eeschema/makefile.include @@ -0,0 +1,187 @@ +# File: makefile.include + +FINAL = 1 + +EESCHEMA_FLAGS= -DEESCHEMA +EXTRACPPFLAGS=$(KICAD_FLAGS) $(EESCHEMA_FLAGS) -I./ -Ibitmaps -I../include -I../eeschema +EXTRALIBS = ../common/common.a + +# DEPEND = program.h general.h + +OBJECTS = eeschema.o\ + schedit.o\ + load_one_schematic_file.o\ + libedit_undo_redo.o\ + schematic_undo_redo.o\ + dialog_create_component.o\ + libedit_onrightclick.o\ + libedit_onleftclick.o\ + dangling_ends.o\ + setpage.o\ + cmpclass.o\ + class_hierarchy_sheet.o\ + class_text-label.o\ + component_class.o\ + libclass.o\ + dialog_options.o\ + tool_lib.o\ + tool_sch.o\ + tool_viewlib.o\ + drawframe.o\ + schframe.o\ + viewlib_frame.o\ + drawpanel.o\ + wxprint.o\ + lib_export.o \ + busentry.o \ + bus-wire-junction.o \ + eelibs1.o eelibs2.o \ + eeload.o\ + block.o\ + block_libedit.o\ + eeredraw.o\ + dialog_eeschema_config.o\ + eestring.o eelayer.o \ + priorque.o eeconfig.o \ + affiche.o \ + zoom.o \ + getpart.o\ + netlist.o\ + netlist_control.o\ + edit_label.o\ + edit_component_in_schematic.o\ + locate.o \ + save_schemas.o sheet.o \ + viewlibs.o \ + libedit.o \ + libframe.o \ + symbedit.o \ + pinedit.o \ + libfield.o \ + edit_component_in_lib.o \ + menubar.o \ + savelib.o symbtext.o \ + symbdraw.o \ + hierarch.o files-io.o \ + annotate.o plothpgl.o \ + plot.o libalias.o \ + plotps.o netform.o \ + delsheet.o \ + infospgm.o \ + delete.o dialog_build_BOM.o \ + erc.o\ + dialog_erc.o\ + selpart.o \ + libarch.o \ + cleanup.o\ + sheetlab.o \ + class_screen.o \ + database.o\ + onrightclick.o \ + onleftclick.o \ + find.o \ + controle.o\ + hotkeys.o\ + svg_print.o + +eeschema.o: eeschema.cpp program.h general.h $(DEPEND) + +edit_component_in_lib.o: edit_component_in_lib.cpp\ + dialog_edit_component_in_lib.cpp dialog_edit_component_in_lib.h $(DEPEND) + +edit_component_in_schematic.o: edit_component_in_schematic.cpp\ + dialog_edit_component_in_schematic.cpp dialog_edit_component_in_schematic.h $(DEPEND) + +edit_label.o: edit_label.cpp dialog_edit_label.cpp dialog_edit_label.h $(DEPEND) + +dialog_create_component.o: dialog_create_component.cpp dialog_create_component.h $(DEPEND) + +busentry.o: busentry.cpp $(DEPEND) + +symbdraw.o: symbdraw.cpp dialog_cmp_graphic_properties.cpp\ + dialog_cmp_graphic_properties.h $(DEPEND) + +component_class.o: component_class.cpp component_class.h + +menubar.o: menubar.cpp $(DEPEND) + +find.o:find.cpp dialog_find.cpp dialog_find.h $(DEPEND) + +eeconfig.o: eeconfig.cpp eeconfig.h $(DEPEND) + +annotate.o: annotate.cpp annotate_dialog.cpp annotate_dialog.h $(DEPEND) netlist.h + +netlist.o: netlist.cpp $(DEPEND) netlist.h + +netlist_control.o: netlist_control.cpp $(DEPEND) netlist.h + +netform.o: netform.cpp $(DEPEND) netlist.h + +erc.o: erc.cpp dialog_erc.h $(DEPEND) netlist.h + +dialog_erc.o: dialog_erc.cpp dialog_erc.h $(DEPEND) + +setpage.o: ../share/setpage.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +svg_print.o: ../share/svg_print.cpp ../share/svg_print.h $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +zoom.o: ../share/zoom.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +treeprj.o: ../share/treeprj.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +drawpanel.o: ../share/drawpanel.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +mdiframe.o: ../share/mdiframe.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +buildmnu.o: ../share/buildmnu.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +pinedit.o: pinedit.cpp pinedit-dialog.cpp pinedit-dialog.h $(DEPEND) + +tool_lib.o: tool_lib.cpp $(DEPEND) + +controle.o: controle.cpp $(DEPEND) ../include/eda_dde.h + +wxprint.o: ../share/wxprint.cpp ../share/dialog_print.cpp ../share/dialog_print.h $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +bus-wire-junction.o: bus-wire-junction.cpp $(DEPEND) + +drawframe.o: ../share/drawframe.cpp + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +eelibs1.o: eelibs1.cpp $(DEPEND) + +eelibs2.o: eelibs2.cpp $(DEPEND) + +eeload.o: eeload.cpp $(DEPEND) + +block.o: block.cpp $(DEPEND) + +block_libedit.o: block_libedit.cpp $(DEPEND) + +onrightclick.o: onrightclick.cpp $(DEPEND) + +libedit_undo_redo.o: libedit_undo_redo.cpp $(DEPEND) + +libedit_onrightclick.o: libedit_onrightclick.cpp $(DEPEND) + +libedit_onleftclick.o: libedit_onleftclick.cpp $(DEPEND) + +onleftclick.o: onleftclick.cpp $(DEPEND) + +eeredraw.o: eeredraw.cpp $(DEPEND) + +dialog_eeschema_config.o: dialog_eeschema_config.cpp dialog_eeschema_config.h $(DEPEND) + +libedit.o: libedit.cpp $(DEPEND) + +infospgm.o: ../share/infospgm.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + diff --git a/eeschema/makefile.macosx b/eeschema/makefile.macosx new file mode 100644 index 0000000000..5b4215838c --- /dev/null +++ b/eeschema/makefile.macosx @@ -0,0 +1,50 @@ +## Makefile for eeschema +CC = gcc +LD = g++ + +FINAL = 1 + + +LDFLAGS = + +include ../libs.macosx + +TARGET = eeschema + + +CPPFLAGS = -Wall -O2 `wx-config --cxxflags` + + +all: $(TARGET) netlist_form_pads-pcb + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + +$(TARGET): $(OBJECTS) $(TARGET).r makefile.macosx makefile.include $(EXTRALIBS) ../libs.macosx + $(LD) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $(TARGET) + $(RESCOMP) -o $(TARGET) Carbon.r $(TARGET).r + $(SETFILE) -a C $(TARGET) + + +netlist_form_pads-pcb: plugins/netlist_form_pads-pcb.cpp + gcc -Wall plugins/netlist_form_pads-pcb.cpp -o netlist_form_pads-pcb + + +install: + cp $(TARGET) $(KICAD_BIN) + cp netlist_form_pads-pcb $(KICAD_BIN) + + +clean: + rm -f *.o; rm -f *~; rm core; rm *.bak + rm -f $(TARGET) + + + + + + + + diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp new file mode 100644 index 0000000000..5406a9be4c --- /dev/null +++ b/eeschema/menubar.cpp @@ -0,0 +1,186 @@ + /*************************************************************/ + /* menubar.cpp - create the menubar for the schematic frame */ + /*************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" +#include "common.h" + +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "bitmaps.h" +#include "protos.h" +#include "id.h" + + +/************************************************/ +void WinEDA_SchematicFrame::ReCreateMenuBar(void) +/************************************************/ +/* create or update the menubar for the schematic frame +*/ +{ +int ii; +wxMenuBar * menuBar = GetMenuBar(); + + if( menuBar == NULL ) + { + menuBar = new wxMenuBar(); + + m_FilesMenu = new wxMenu; + + wxMenuItem *item = new wxMenuItem(m_FilesMenu, ID_LOAD_PROJECT, + _("&Load Schematic Project"), + _("Load a schematic project (Schematic, libraries...)") ); + item->SetBitmap(open_xpm); + m_FilesMenu->Append(item); + + m_FilesMenu->AppendSeparator(); + item = new wxMenuItem(m_FilesMenu,ID_SAVE_PROJECT, + _("&Save Schematic Project"), + _("Save all") ); + item->SetBitmap(save_project_xpm); + m_FilesMenu->Append(item); + + m_FilesMenu->AppendSeparator(); + item = new wxMenuItem(m_FilesMenu, ID_SAVE_ONE_SHEET, + _("Save &Current sheet"), + _("Save current sheet only") ); + item->SetBitmap(save_xpm); + m_FilesMenu->Append(item); + + item = new wxMenuItem(m_FilesMenu, ID_SAVE_ONE_SHEET_AS, + _("Save Current sheet &as.."), + _("Save current sheet as..") ); + item->SetBitmap(save_as_xpm); + m_FilesMenu->Append(item); + + /* Plot Menu */ + item = new wxMenuItem(m_FilesMenu, ID_GEN_PRINT, + _("P&rint"), _("Print on current printer") ); + item->SetBitmap(print_button); + m_FilesMenu->Append(item); + + wxMenu *choice_plot_fmt = new wxMenu; + item = new wxMenuItem(choice_plot_fmt, ID_GEN_PLOT_PS, + _("Plot Postscript"), _("Plotting in Postscript format") ); + item->SetBitmap(plot_PS_xpm); + choice_plot_fmt->Append(item); + + item = new wxMenuItem(choice_plot_fmt, ID_GEN_PLOT_HPGL, + _("Plot HPGL"), _("Plotting in HPGL format") ); + item->SetBitmap(plot_HPG_xpm); + choice_plot_fmt->Append(item); + + item = new wxMenuItem(choice_plot_fmt, ID_GEN_PLOT_SVG, + _("Plot SVG"), _("Plotting in SVG format") ); + item->SetBitmap(plot_xpm); + choice_plot_fmt->Append(item); + +#ifdef __WINDOWS__ + /* Under windows, one can draw to the clipboard */ + item = new wxMenuItem(choice_plot_fmt, ID_GEN_COPY_SHEET_TO_CLIPBOARD, + _("Plot to Clipboard"), _("Export drawings to clipboard") ); + item->SetBitmap(copy_button); + choice_plot_fmt->Append(item); +#endif + + m_FilesMenu->AppendSeparator(); + ADD_MENUITEM_WITH_HELP_AND_SUBMENU(m_FilesMenu, choice_plot_fmt, + ID_GEN_PLOT, _("&Plot"), _("Plot Hplg, Postscript, SVG"), plot_xpm); + + m_FilesMenu->AppendSeparator(); + item = new wxMenuItem(m_FilesMenu, ID_EXIT, _("E&xit"), _("Quit Eeschema") ); + item->SetBitmap(exit_xpm); + m_FilesMenu->Append(item); + + // Create the list of last edited schematic files + m_FilesMenu->AppendSeparator(); + int max_file = m_Parent->m_LastProjectMaxCount; + for ( ii = 0; ii < max_file; ii++ ) + { + if ( GetLastProject(ii).IsEmpty() ) break; + item = new wxMenuItem(m_FilesMenu, ID_LOAD_FILE_1 + ii, + GetLastProject(ii)); + m_FilesMenu->Append(item); + } + + // Menu Configuration: + wxMenu * configmenu = new wxMenu; + item = new wxMenuItem(configmenu, ID_CONFIG_REQ, + _("&Libs and Dir"), + _("Setting Libraries, Directories and others...") ); + item->SetBitmap(library_xpm); + configmenu->Append(item); + + item = new wxMenuItem(configmenu, ID_COLORS_SETUP, + _("&Colors"), + _("Setting colors ...") ); + item->SetBitmap(palette_xpm); + configmenu->Append(item); + + ADD_MENUITEM(configmenu, ID_OPTIONS_SETUP, _("&Options"), preference_xpm); + + // Font selection and setup + AddFontSelectionMenu(configmenu); + + m_Parent->SetLanguageList(configmenu); + + configmenu->AppendSeparator(); + item = new wxMenuItem(configmenu, ID_CONFIG_SAVE, _("&Save Eeschema Setup"), + _("Save options in .pro") ); + item->SetBitmap(save_setup_xpm); + configmenu->Append(item); + item = new wxMenuItem(configmenu, ID_CONFIG_READ, _("&Read Setup"), + _("Read options from a selected config file")); + item->SetBitmap(read_setup_xpm); + configmenu->Append(item); + + // Menu Help: + wxMenu *helpMenu = new wxMenu; + item = new wxMenuItem(helpMenu , ID_GENERAL_HELP, + _("Kicad &Help"), _("On line doc")); + item->SetBitmap(help_xpm); + helpMenu->Append(item); + + item = new wxMenuItem(helpMenu , ID_KICAD_ABOUT, + _("Eeschema &About"), _("Eeschema Infos")); + item->SetBitmap(info_xpm); + helpMenu->Append(item); + + + menuBar->Append(m_FilesMenu, _("&Files") ); + menuBar->Append(configmenu, _("&Preferences") ); + menuBar->Append(helpMenu, _("&Help") ); + + // Associate the menu bar with the frame + SetMenuBar(menuBar); + } + + else // Update the list of last edited schematic files + { + wxMenuItem * item; + int max_file = m_Parent->m_LastProjectMaxCount; + for ( ii = max_file-1; ii >=0 ; ii-- ) + { + if( m_FilesMenu->FindItem(ID_LOAD_FILE_1 + ii) ) + { + item = m_FilesMenu->Remove(ID_LOAD_FILE_1 + ii); + if ( item ) delete item; + } + } + for ( ii = 0; ii < max_file; ii++ ) + { + if ( GetLastProject(ii).IsEmpty() ) break; + item = new wxMenuItem(m_FilesMenu, ID_LOAD_FILE_1 + ii, + GetLastProject(ii)); + m_FilesMenu->Append(item); + } + } +} + + diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp new file mode 100644 index 0000000000..7eddd53df1 --- /dev/null +++ b/eeschema/netform.cpp @@ -0,0 +1,1013 @@ + /*******************************************************/ + /* Module de generation de la Netliste , selon Formats */ + /*******************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "netlist.h" + +#include "protos.h" + + +/* Routines locales */ +static void Write_GENERIC_NetList(WinEDA_SchematicFrame * frame, const wxString & FullFileName); +static void WriteNetListPCBNEW(WinEDA_SchematicFrame * frame, FILE *f, + bool with_pcbnew); +static void WriteNetListCADSTAR(WinEDA_SchematicFrame * frame, FILE *f); +static void WriteListOfNetsCADSTAR( FILE * f, ObjetNetListStruct *ObjNet ); +static void WriteNetListPspice(WinEDA_SchematicFrame * frame, FILE *f, bool use_netnames); + +static void WriteGENERICListOfNets( FILE * f, ObjetNetListStruct *ObjNet ); +static void AddPinToComponentPinList(EDA_SchComponentStruct *Component, + LibDrawPin *PinEntry); +static void FindOthersUnits(EDA_SchComponentStruct *Component ); +static int SortPinsByNum(ObjetNetListStruct **Pin1, ObjetNetListStruct **Pin2); +static void EraseDuplicatePins(ObjetNetListStruct **TabPin, int NbrPin); + +static void ClearUsedFlags(WinEDA_SchematicFrame * frame); + + + +/* Variable locales */ +static int s_SortedPinCount; +static ObjetNetListStruct **s_SortedComponentPinList; + + + + +/******************************************************************************/ +void WriteNetList(WinEDA_SchematicFrame * frame, const wxString & FileNameNL, + bool use_netnames) +/*******************************************************************************/ +/* Create the netlist file ( Format is given by g_NetFormat ) + bool use_netnames is used only for Spice netlist +*/ +{ +FILE *f = NULL; + + if ( g_NetFormat < NET_TYPE_CUSTOM1 ) + { + if ((f = wxFopen(FileNameNL, wxT("wt"))) == NULL) + { + wxString msg = _("Failed to create file ") + FileNameNL; + DisplayError(frame, msg); + return; + } + } + +wxBusyCursor Busy; + + switch ( g_NetFormat ) + { + case NET_TYPE_PCBNEW : + WriteNetListPCBNEW(frame, f, TRUE); + fclose(f); + break; + + case NET_TYPE_ORCADPCB2 : + WriteNetListPCBNEW(frame, f, FALSE); + fclose(f); + break; + + case NET_TYPE_CADSTAR : + WriteNetListCADSTAR(frame, f); + fclose(f); + break; + + case NET_TYPE_SPICE : + WriteNetListPspice(frame, f, use_netnames); + fclose(f); + break; + + case NET_TYPE_CUSTOM1 : + case NET_TYPE_CUSTOM2 : + case NET_TYPE_CUSTOM3 : + case NET_TYPE_CUSTOM4 : + case NET_TYPE_CUSTOM5 : + case NET_TYPE_CUSTOM6 : + case NET_TYPE_CUSTOM7 : + case NET_TYPE_CUSTOM8 : + Write_GENERIC_NetList(frame, FileNameNL); + break; + + default: + DisplayError(frame, wxT("WriteNetList() err: Unknown Netlist Format")); + break; + } +} + + +/****************************************************************************/ +static EDA_SchComponentStruct * FindNextComponentAndCreatPinList( + EDA_BaseStruct * DrawList) +/****************************************************************************/ +/* Find a "suitable" component from the DrawList + build its pin list s_SortedComponentPinList. + The list is sorted by pin num + A suitable component is a "new" real component (power symbols are not considered) + + alloc memory for s_SortedComponentPinList if s_SortedComponentPinList == NULL + Must be deallocated by the user +*/ +{ +EDA_SchComponentStruct * Component = NULL; +EDA_LibComponentStruct *Entry; +LibEDA_BaseStruct *DEntry; + + s_SortedPinCount = 0; + + for ( ; DrawList != NULL; DrawList = DrawList->Next() ) + { + if ( DrawList->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) continue; + Component = (EDA_SchComponentStruct *) DrawList; + + /* already tested ? : */ + if( Component->m_FlagControlMulti == 1 ) continue; /* yes */ + + Entry = FindLibPart(Component->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if( Entry == NULL) continue; + + /* Power symbol and other component which have the reference starting by + "#" are not included in netlist (pseudo components) */ + if( Component->m_Field[REFERENCE].m_Text[0] == '#' ) continue; + + /* Create the pin table for this component */ + int ii = sizeof(ObjetNetListStruct) * MAXPIN; + if ( s_SortedComponentPinList == NULL ) + s_SortedComponentPinList = (ObjetNetListStruct **) MyMalloc(ii); + memset(s_SortedComponentPinList, 0 , ii); + + DEntry = Entry->m_Drawings; + for ( ;DEntry != NULL; DEntry = DEntry->Next()) + { + if ( DEntry->m_StructType != COMPONENT_PIN_DRAW_TYPE) continue; + if( DEntry->m_Unit && + (DEntry->m_Unit != Component->m_Multi) ) continue; + if( DEntry->m_Convert && + (DEntry->m_Convert != Component->m_Convert)) continue; + { + AddPinToComponentPinList(Component, (LibDrawPin*)DEntry); + } + } + + Component->m_FlagControlMulti = 1; + + if (Entry->m_UnitCount > 1) FindOthersUnits(Component); + + /* Tri sur le numero de Pin de TabListePin */ + qsort(s_SortedComponentPinList, s_SortedPinCount, sizeof(ObjetNetListStruct*), + (int (*)(const void *, const void *)) SortPinsByNum); + + /* Elimination des Pins redondantes du s_SortedComponentPinList */ + EraseDuplicatePins(s_SortedComponentPinList, s_SortedPinCount); + + return Component; + } + + return NULL; +} + +/**************************************************************************************/ +static wxString ReturnPinNetName(ObjetNetListStruct *Pin, + const wxString& DefaultFormatNetname) +/**************************************************************************************/ +/* Return the net name for the pin Pin. + Net name is: + "?" if pin not connected + "netname" for global net (like gnd, vcc .. + "netname_sheetnumber" for the usual nets +*/ +{ +int netcode = Pin->m_NetCode; +wxString NetName; + + if( (netcode == 0 ) || ( Pin->m_FlagOfConnection != CONNECT ) ) + { + return NetName; + } + else + { + int jj; + for (jj = 0; jj < g_NbrObjNet; jj++) + { + if( g_TabObjNet[jj].m_NetCode != netcode) continue; + if( ( g_TabObjNet[jj].m_Type != NET_GLOBLABEL) && + ( g_TabObjNet[jj].m_Type != NET_LABEL) && + ( g_TabObjNet[jj].m_Type != NET_PINLABEL) ) continue; + + NetName = * g_TabObjNet[jj].m_Label; + break; + } + + if( ! NetName.IsEmpty() ) + { + if( g_TabObjNet[jj].m_Type != NET_PINLABEL ) + NetName << wxT("_") << g_TabObjNet[jj].m_SheetNumber; + } + else + { + NetName.Printf(DefaultFormatNetname.GetData(), netcode); + } + } + return NetName; +} + +/***********************************************************************/ +void Write_GENERIC_NetList(WinEDA_SchematicFrame * frame, + const wxString & FullFileName) +/***********************************************************************/ +/* Create a generic netlist, and call an external netlister + to change the netlist syntax and create the file +*/ +{ +wxString Line, FootprintName; +BASE_SCREEN *CurrScreen; +EDA_BaseStruct *DrawList; +EDA_SchComponentStruct *Component; +wxString netname; +int ii; +FILE * tmpfile; +wxString TmpFullFileName = FullFileName; + + ChangeFileNameExt(TmpFullFileName, wxT(".tmp")); + + if ((tmpfile = wxFopen(TmpFullFileName, wxT("wt"))) == NULL) + { + wxString msg = _("Failed to create file ") + TmpFullFileName; + DisplayError(frame, msg); + return; + } + + ClearUsedFlags(frame); /* Reset the flags FlagControlMulti in all schematic files*/ + fprintf( tmpfile, "$BeginNetlist\n" ); + + /* Create netlist module section */ + fprintf( tmpfile, "$BeginComponentList\n" ); + for(CurrScreen = ScreenSch; CurrScreen != NULL; CurrScreen = (BASE_SCREEN*)CurrScreen->Pnext ) + { + for ( DrawList = CurrScreen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext ) + { + DrawList = Component = FindNextComponentAndCreatPinList(DrawList); + if ( Component == NULL ) break; // No component left + + FootprintName.Empty(); + if( ! Component->m_Field[FOOTPRINT].IsVoid() ) + { + FootprintName = Component->m_Field[FOOTPRINT].m_Text; + FootprintName.Replace(wxT(" "), wxT("_")); + } + + fprintf( tmpfile, "\n$BeginComponent\n" ); + fprintf(tmpfile, "TimeStamp=%8.8lX\n", Component->m_TimeStamp); + fprintf(tmpfile, "Footprint=%s\n", CONV_TO_UTF8(FootprintName)); + Line = wxT("Reference=") + Component->m_Field[REFERENCE].m_Text + wxT("\n"); + Line.Replace(wxT(" "), wxT("_")); + fprintf(tmpfile, CONV_TO_UTF8(Line)); + + Line = Component->m_Field[VALUE].m_Text; + Line.Replace( wxT(" "), wxT("_")); + fprintf(tmpfile, "Value=%s\n", CONV_TO_UTF8(Line)); + + Line = Component->m_ChipName; + Line.Replace(wxT(" "), wxT("_")); + fprintf(tmpfile, "Libref=%s\n", CONV_TO_UTF8(Line)); + + // Write pin list: + fprintf( tmpfile, "$BeginPinList\n" ); + for (ii = 0; ii < s_SortedPinCount; ii++) + { + ObjetNetListStruct *Pin = s_SortedComponentPinList[ii]; + if( ! Pin ) continue; + netname = ReturnPinNetName(Pin, wxT("$-%.6d")); + if ( netname.IsEmpty() ) netname = wxT("?"); + fprintf( tmpfile,"%.4s=%s\n",(char *)&Pin->m_PinNum, + CONV_TO_UTF8(netname)); + } + + fprintf( tmpfile, "$EndPinList\n" ); + fprintf( tmpfile, "$EndComponent\n" ); + } + } + + MyFree(s_SortedComponentPinList); + s_SortedComponentPinList = NULL; + + fprintf( tmpfile, "$EndComponentList\n" ); + + fprintf( tmpfile, "\n$BeginNets\n" ); + WriteGENERICListOfNets( tmpfile, g_TabObjNet ); + fprintf( tmpfile, "$EndNets\n" ); + fprintf( tmpfile, "\n$EndNetlist\n" ); + fclose(tmpfile); + + // Call the external module (plug in ) + + if ( g_NetListerCommandLine.IsEmpty() ) return; + +wxString CommandFile; + if ( wxIsAbsolutePath(g_NetListerCommandLine) ) + CommandFile = g_NetListerCommandLine; + else CommandFile = FindKicadFile(g_NetListerCommandLine); + + CommandFile += wxT(" ") + TmpFullFileName; + CommandFile += wxT(" ") + FullFileName; + + wxExecute(CommandFile, wxEXEC_SYNC); + +} + + +/********************************************************/ +static void ClearUsedFlags(WinEDA_SchematicFrame * frame) +/********************************************************/ +/* Clear flag FlagControlMulti, used in netlist generation */ +{ +SCH_SCREEN *screen; +EDA_BaseStruct *DrawList; + + EDA_ScreenList ScreenList(NULL); + for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + DrawList = screen->EEDrawList; + while ( DrawList ) + { + if( DrawList->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE) + { + EDA_SchComponentStruct * Component = (EDA_SchComponentStruct *) DrawList; + Component->m_FlagControlMulti = 0; + } + DrawList = DrawList->Pnext; + } + } +} + +/*************************************************************/ +static void WriteNetListPspice(WinEDA_SchematicFrame * frame, FILE *f, + bool use_netnames) +/*************************************************************/ +/* Routine de generation du fichier netliste ( Format PSPICE ) + si use_netnames = TRUE + les nodes sont identifies par le netname + sinon les nodes sont identifies par le netnumber + + tous les textes graphiques commençant par [.-+]pspice ou [.-+]gnucap + sont considérés comme des commandes a placer dans la netliste + [.-]pspice ou gnucap sont en debut + +pspice et +gnucap sont en fin de netliste +*/ +{ +char Line[1024]; +SCH_SCREEN *screen; +EDA_BaseStruct *DrawList; +EDA_SchComponentStruct *Component; +int ii, nbitems; +wxString text; +wxArrayString SpiceCommandAtBeginFile, SpiceCommandAtEndFile; +wxString msg; +#define BUFYPOS_LEN 4 +wxChar bufnum[BUFYPOS_LEN+1]; + + DateAndTime(Line); + fprintf( f, "* %s (Spice format) creation date: %s\n\n", NETLIST_HEAD_STRING, Line ); + + /* Create text list starting by [.-]pspice , or [.-]gnucap (simulator commands) */ + /* and create text list starting by [+]pspice , or [+]gnucap (simulator commands) */ + bufnum[BUFYPOS_LEN] = 0; + EDA_ScreenList ScreenList(NULL); + for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + for ( DrawList = screen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext ) + { + wxChar ident; + if ( DrawList->m_StructType != DRAW_TEXT_STRUCT_TYPE ) continue; + #define DRAWTEXT ((DrawTextStruct *) DrawList) + text = DRAWTEXT->m_Text; if ( text.IsEmpty() ) continue; + ident = text.GetChar(0); + if ( ident != '.' && ident != '-' && ident != '+' ) continue; + text.Remove(0,1); //Remove the first char. + text.Remove(6); //text contains 6 char. + if( ( text == wxT("pspice") ) || ( text == wxT("gnucap") ) ) + { + /* Put the Y position as an ascii string, for sort by vertical position, + using usual sort string by alphabetic value */ + int ypos = DRAWTEXT->m_Pos.y; + for ( ii = 0; ii < BUFYPOS_LEN; ii++ ) + { + bufnum[BUFYPOS_LEN-1-ii] = (ypos & 63) + ' '; ypos >>= 6; + } + text = DRAWTEXT->m_Text.AfterFirst( ' '); + msg.Printf( wxT("%s %s"),bufnum, text.GetData()); // First BUFYPOS_LEN char are the Y position + if ( ident == '+' ) SpiceCommandAtEndFile.Add(msg); + else SpiceCommandAtBeginFile.Add(msg); + } + } + } + + /* Print texts starting by [.-]pspice , ou [.-]gnucap (of course, without the Y position string)*/ + nbitems = SpiceCommandAtBeginFile.GetCount(); + if ( nbitems ) + { + SpiceCommandAtBeginFile.Sort(); + for(ii= 0; ii < nbitems; ii++ ) + { + SpiceCommandAtBeginFile[ii].Remove(0, BUFYPOS_LEN); + SpiceCommandAtBeginFile[ii].Trim(TRUE); + SpiceCommandAtBeginFile[ii].Trim(FALSE); + fprintf( f, "%s\n", CONV_TO_UTF8(SpiceCommandAtBeginFile[ii]) ); + } + } + fprintf( f, "\n" ); + + + /* Create component list */ + ClearUsedFlags(frame); /* Reset the flags FlagControlMulti in all schematic files*/ + for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + for( DrawList = screen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext ) + { + DrawList = Component = FindNextComponentAndCreatPinList(DrawList); + if ( Component == NULL ) break; + + fprintf(f, "%s ", CONV_TO_UTF8(Component->m_Field[REFERENCE].m_Text)); + + // Write pin list: + for (ii = 0; ii < s_SortedPinCount; ii++) + { + ObjetNetListStruct *Pin = s_SortedComponentPinList[ii]; + if( ! Pin ) continue; + wxString NetName = ReturnPinNetName(Pin, wxT("N-%.6d")); + if ( NetName.IsEmpty() ) NetName = wxT("?"); + if( use_netnames) fprintf( f," %s", CONV_TO_UTF8(NetName)); + else // Use number for net names (with net number = 0 for "GND" + { + // NetName = "0" is "GND" net for Spice + if( NetName == wxT("0") || NetName == wxT("GND") ) + fprintf( f," 0"); + else fprintf( f," %d", Pin->m_NetCode); + } + } + fprintf(f, " %s\n", CONV_TO_UTF8(Component->m_Field[VALUE].m_Text)); + } + } + + MyFree(s_SortedComponentPinList); + s_SortedComponentPinList = NULL; + + /* Print texts starting by [+]pspice , ou [+]gnucap */ + nbitems = SpiceCommandAtEndFile.GetCount(); + if ( nbitems ) + { + fprintf( f, "\n" ); + SpiceCommandAtEndFile.Sort(); + for(ii= 0; ii < nbitems; ii++ ) + { + SpiceCommandAtEndFile[ii].Remove(0, + BUFYPOS_LEN); + SpiceCommandAtEndFile[ii].Trim(TRUE); + SpiceCommandAtEndFile[ii].Trim(FALSE); + fprintf( f, "%s\n", CONV_TO_UTF8(SpiceCommandAtEndFile[ii])); + } + } + + fprintf( f, "\n.end\n" ); +} + +/*****************************************************************************************/ +static void WriteNetListPCBNEW(WinEDA_SchematicFrame * frame, FILE *f, bool with_pcbnew) +/*****************************************************************************************/ +/* Routine de generation du fichier netliste ( Format ORCAD PCB 2 ameliore ) + si with_pcbnew = FALSE + format PCBNEW (OrcadPcb2 + commentaires et liste des nets) + si with_pcbnew = FALSE + Format ORCADPCB2 strict +*/ +{ +wxString Line, FootprintName; +char Buf[256]; +SCH_SCREEN *CurrScreen; +EDA_BaseStruct *DrawList; +EDA_SchComponentStruct *Component; +int ii; +EDA_SchComponentStruct ** CmpList = NULL; +int CmpListCount = 0, CmpListSize = 1000; + + DateAndTime(Buf); + if ( with_pcbnew ) + fprintf( f, "# %s created %s\n(\n", NETLIST_HEAD_STRING, Buf); + else fprintf( f, "( { %s created %s }\n", NETLIST_HEAD_STRING, Buf ); + + + /* Create netlist module section */ + ClearUsedFlags(frame); /* Reset the flags FlagControlMulti in all schematic files*/ + + EDA_ScreenList ScreenList(NULL); + for ( CurrScreen = ScreenList.GetFirst(); CurrScreen != NULL; CurrScreen = ScreenList.GetNext() ) + { + for ( DrawList = CurrScreen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext ) + { + DrawList = Component = FindNextComponentAndCreatPinList(DrawList); + if ( Component == NULL ) break; + + /* Get the Component FootprintFilter and put the component in CmpList if filter is not void */ + EDA_LibComponentStruct *Entry; + if( (Entry = FindLibPart(Component->m_ChipName.GetData(),wxEmptyString,FIND_ROOT)) != NULL) + { + if ( Entry->m_FootprintList.GetCount() != 0 ) /* Put in list */ + { + if ( CmpList == NULL ) + CmpList = (EDA_SchComponentStruct **) MyZMalloc(sizeof(EDA_SchComponentStruct *) * CmpListSize); + if ( CmpListCount >= CmpListSize ) + { + CmpListSize += 1000; + CmpList = (EDA_SchComponentStruct **) realloc(CmpList, sizeof(EDA_SchComponentStruct *) * CmpListSize); + } + CmpList[CmpListCount] = Component; + CmpListCount++; + } + } + + if( ! Component->m_Field[FOOTPRINT].IsVoid() ) + { + FootprintName = Component->m_Field[FOOTPRINT].m_Text; + FootprintName.Replace( wxT(" "), wxT("_") ); + } + else FootprintName = wxT("$noname"); + + Line = Component->m_Field[REFERENCE].m_Text; + Line.Replace( wxT(" "), wxT("_") ); + fprintf(f, " ( %8.8lX %s", + Component->m_TimeStamp, + CONV_TO_UTF8(FootprintName)); + fprintf(f, " %s", CONV_TO_UTF8(Line)); + + Line = Component->m_Field[VALUE].m_Text; + Line.Replace( wxT(" "), wxT("_") ); + fprintf(f, " %s", CONV_TO_UTF8(Line)); + + if ( with_pcbnew ) // Add the lib name for this component + { + Line = Component->m_ChipName; + Line.Replace( wxT(" "), wxT("_") ); + fprintf(f, " {Lib=%s}", CONV_TO_UTF8(Line)); + } + fprintf(f, "\n"); + + // Write pin list: + for (ii = 0; ii < s_SortedPinCount; ii++) + { + ObjetNetListStruct *Pin = s_SortedComponentPinList[ii]; + if( ! Pin ) continue; + wxString netname = ReturnPinNetName(Pin, wxT("N-%.6d")); + if ( netname.IsEmpty() ) netname = wxT(" ?"); + fprintf( f," ( %4.4s %s )\n",(char *)&Pin->m_PinNum, + CONV_TO_UTF8(netname)); + } + + fprintf(f, " )\n"); + } + } + fprintf( f, ")\n*\n"); + + MyFree(s_SortedComponentPinList); + s_SortedComponentPinList = NULL; + + /* Write the allowed footprint list for each component */ + if ( with_pcbnew && CmpList) + { + fprintf( f, "{ Allowed footprints by component:\n" ); + EDA_LibComponentStruct *Entry; + for ( ii = 0; ii < CmpListCount; ii ++ ) + { + Component = CmpList[ii]; + Entry = FindLibPart(Component->m_ChipName.GetData(),wxEmptyString,FIND_ROOT); + Line = Component->m_Field[REFERENCE].m_Text; + Line.Replace( wxT(" "), wxT("_") ); + fprintf(f, "$component %s\n", CONV_TO_UTF8(Line)); + /* Write the footprint list */ + for ( unsigned int jj = 0; jj < Entry->m_FootprintList.GetCount(); jj ++ ) + { + fprintf(f, " %s\n", CONV_TO_UTF8(Entry->m_FootprintList[jj])); + } + fprintf(f, "$endlist\n"); + } + fprintf(f, "$endfootprintlist\n}\n"); + } + if ( CmpList ) free(CmpList); + + if ( with_pcbnew ) + { + fprintf( f, "{ Pin List by Nets\n" ); + WriteGENERICListOfNets( f, g_TabObjNet ); + fprintf( f, "}\n" ); + fprintf( f, "#End\n" ); + } +} + + +/*************************************************************************************/ +static void AddPinToComponentPinList( EDA_SchComponentStruct *Component, LibDrawPin *Pin) +/*************************************************************************************/ +/* Add a new pin description in the pin list s_SortedComponentPinList + a pin description is a pointer to the corresponding structure + created by BuildNetList() in the table g_TabObjNet +*/ +{ +int ii; + + /* Search the PIN description for Pin in g_TabObjNet*/ + for (ii = 0; ii < g_NbrObjNet; ii++) + { + if ( g_TabObjNet[ii].m_Type != NET_PIN) continue; + if ( g_TabObjNet[ii].m_Link != Component) continue; + if ( g_TabObjNet[ii].m_PinNum != Pin->m_PinNum) continue; + { + s_SortedComponentPinList[s_SortedPinCount] = & g_TabObjNet[ii]; + s_SortedPinCount++; + if (s_SortedPinCount >= MAXPIN) + { + /* Log message for Internal error */ + DisplayError(NULL, wxT("AddPinToComponentPinList err: MAXPIN reached")); return; + } + } + } +} + + +/**********************************************************************/ +static void EraseDuplicatePins(ObjetNetListStruct **TabPin, int NbrPin) +/**********************************************************************/ +/* + Routine qui elimine les Pins de meme Numero de la liste des objets + (Liste des Pins d'un boitier) passee en entree + Ces pins redondantes proviennent des pins (alims... ) communes a plusieurs + elements d'un boitier a multiple parts. +*/ +{ +int ii, jj; + + for (ii = 0; ii < NbrPin-1; ii++) + { + if( TabPin[ii] == NULL) continue; /* Deja supprime */ + if( TabPin[ii]->m_PinNum != TabPin[ii+1]->m_PinNum) continue; + /* 2 Pins doublees */ + for( jj = ii+1; jj < NbrPin ; jj++ ) + { + if( TabPin[ii]->m_PinNum != TabPin[jj]->m_PinNum) break; + TabPin[jj] = NULL; + } + } +} + + + +/**********************************************************************/ +static void FindOthersUnits(EDA_SchComponentStruct *Component ) +/**********************************************************************/ + +/* Recherche les autres parts du boitier auquel appartient la part Component, + pour les boitiers a parts multiples. + Appelle AddPinToComponentPinList() pour classer les pins des parts trouvees +*/ +{ +EDA_BaseStruct *DrawList; +EDA_SchComponentStruct *Component2; +EDA_LibComponentStruct *Entry; +LibEDA_BaseStruct *DEntry; +SCH_SCREEN * screen; + + EDA_ScreenList ScreenList(NULL); + for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + DrawList = screen->EEDrawList; + while ( DrawList ) + { + switch( DrawList->m_StructType ) + { + case DRAW_LIB_ITEM_STRUCT_TYPE : + Component2 = (EDA_SchComponentStruct *) DrawList; + + if ( Component2->m_FlagControlMulti == 1 ) break; + + if ( Component2->m_Field[REFERENCE].m_Text.CmpNoCase( + Component->m_Field[REFERENCE].m_Text) != 0 ) + break; + + Entry = FindLibPart(Component2->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if( Entry == NULL) break; + if( Component2->m_Field[REFERENCE].m_Text[0] == '#' ) break; + + if (Entry->m_Drawings != NULL) + { + DEntry = Entry->m_Drawings; + for ( ;DEntry != NULL; DEntry = DEntry->Next()) + { + if ( DEntry->m_StructType != COMPONENT_PIN_DRAW_TYPE) continue; + if( DEntry->m_Unit && + (DEntry->m_Unit != Component2->m_Multi) ) continue; + if( DEntry->m_Convert && + (DEntry->m_Convert != Component2->m_Convert)) continue; + { + AddPinToComponentPinList(Component2, (LibDrawPin*)DEntry); + } + } + } + Component2->m_FlagControlMulti = 1; + break; + + default: break; + } + DrawList = DrawList->Pnext; + } + } +} + + +/**************************************************************************/ +static int SortPinsByNum(ObjetNetListStruct **Pin1, ObjetNetListStruct **Pin2) +/**************************************************************************/ +/* Routine de comparaison pour le tri des pins par numero croissant + du tableau des pins s_SortedComponentPinList par qsort() +*/ +{ +ObjetNetListStruct * Obj1, * Obj2; +int Num1, Num2; +char Line[5]; + + Obj1 = *Pin1; Obj2 = *Pin2; + Num1 = Obj1->m_PinNum; Num2 = Obj2->m_PinNum; + Line[4] = 0; memcpy(Line, &Num1, 4 ); Num1 = atoi(Line); + memcpy(Line, &Num2, 4 ); Num2 = atoi(Line); + return (Num1 - Num2); +} + +/*************************************************************************/ +static void WriteGENERICListOfNets( FILE * f, ObjetNetListStruct *ObjNet ) +/*************************************************************************/ +/* Ecrit dans le fichier f la liste des nets ( classee par NetCodes ), et des +elements qui y sont connectes +*/ +{ +int ii, jj; +int NetCode, LastNetCode = -1; +int SameNetcodeCount = 0; +EDA_SchComponentStruct * Cmp; +wxString NetName, CmpRef; +wxString NetcodeName; +char FirstItemInNet[1024]; + + for (ii = 0; ii < g_NbrObjNet; ii++) + { + if( (NetCode = ObjNet[ii].m_NetCode) != LastNetCode ) // New net found, write net id; + { + SameNetcodeCount = 0; // Items count for this net + NetName.Empty(); + for (jj = 0; jj < g_NbrObjNet; jj++) // Find a label (if exists) for this net + { + if( ObjNet[jj].m_NetCode != NetCode) continue; + if( ( ObjNet[jj].m_Type != NET_GLOBLABEL) && + ( ObjNet[jj].m_Type != NET_LABEL) && + ( ObjNet[jj].m_Type != NET_PINLABEL) ) continue; + + NetName = * g_TabObjNet[jj].m_Label; break; + } + + NetcodeName.Printf( wxT("Net %d "), NetCode); + NetcodeName += wxT("\""); + if( ! NetName.IsEmpty() ) + { + NetcodeName += NetName; + if( g_TabObjNet[jj].m_Type != NET_PINLABEL) // usual net name, add it the sheet number + NetcodeName << wxT("_") << g_TabObjNet[jj].m_SheetNumber; + } + NetcodeName += wxT("\""); + LastNetCode = NetCode; + } + + if ( ObjNet[ii].m_Type != NET_PIN ) continue; + + Cmp = (EDA_SchComponentStruct*) ObjNet[ii].m_Link; + CmpRef = Cmp->m_Field[REFERENCE].m_Text; + if ( CmpRef.StartsWith( wxT("#") ) ) continue; // Pseudo component (Like Power symbol) + + // Print the pin list for this net, if 2 or more items are connected: + SameNetcodeCount++; + if ( SameNetcodeCount == 1 ) /* first item for this net found, + Print this connection, when a second item will be found */ + { + sprintf(FirstItemInNet, " %s %.4s\n", CONV_TO_UTF8(CmpRef), + (const char*) & ObjNet[ii].m_PinNum); + } + if ( SameNetcodeCount == 2 ) // Second item for this net found, Print the Net name, and the first item + { + fprintf( f, "%s\n", CONV_TO_UTF8(NetcodeName)); + fputs( FirstItemInNet, f); + } + + if ( SameNetcodeCount >= 2 ) + fprintf( f, " %s %.4s\n", CONV_TO_UTF8(CmpRef), + (const char*) & ObjNet[ii].m_PinNum); + } +} + + + +/* Generation des netlistes au format CadStar */ +wxString StartLine( wxT(".")); + +/*********************************************************/ +static void WriteNetListCADSTAR(WinEDA_SchematicFrame * frame, FILE *f) +/*********************************************************/ +/* Routine de generation du fichier netliste ( Format CADSTAR ) +Entete: +..HEA +..TIM 2004 07 29 16 22 17 +..APP "Cadstar RINF Output - Version 6.0.2.3" +..UNI INCH 1000.0 in +..TYP FULL + +liste des composants: +..ADD_COM X1 "CNT D41612 (48PTS MC CONTOUR)" +..ADD_COM U2 "74HCT245D" "74HCT245D" + +Connexions: +..ADD_TER RR2 6 "$42" +..TER U1 100 + CA 6 + +..ADD_TER U2 6 "$59" +..TER U7 39 + U6 17 + U1 122 + +..ADD_TER P2 1 "$9" +..TER T3 1 + U1 14 +*/ +{ +wxString StartCmpDesc = StartLine + wxT("ADD_COM"); +wxString msg; +wxString FootprintName; +char Line[1024]; +BASE_SCREEN *CurrScreen; +EDA_BaseStruct *DrawList; +EDA_SchComponentStruct *Component; + wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); + + fprintf( f, "%sHEA\n", CONV_TO_UTF8(StartLine)); + DateAndTime(Line); + fprintf( f, "%sTIM %s\n", CONV_TO_UTF8(StartLine), Line ); + fprintf( f, "%sAPP ", CONV_TO_UTF8(StartLine) ); + fprintf( f, "\"%s\"\n", CONV_TO_UTF8(Title) ); + fprintf( f, "\n"); + + /* Create netlist module section */ + ClearUsedFlags(frame); /* Reset the flags FlagControlMulti in all schematic files*/ + EDA_ScreenList ScreenList(NULL); + for ( CurrScreen = ScreenList.GetFirst(); CurrScreen != NULL; CurrScreen = ScreenList.GetNext() ) + { + for ( DrawList = CurrScreen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext ) + { + DrawList = Component = FindNextComponentAndCreatPinList(DrawList); + if ( Component == NULL ) break; + + if( ! Component->m_Field[FOOTPRINT].IsVoid() ) + { + FootprintName = Component->m_Field[FOOTPRINT].m_Text; + FootprintName.Replace(wxT(" "), wxT("_")); + } + else FootprintName = wxT("$noname"); + + msg = Component->m_Field[REFERENCE].m_Text; + msg.Replace( wxT(" "), wxT("_")); + fprintf(f, "%s ", CONV_TO_UTF8(StartCmpDesc)); + fprintf(f, "%s", CONV_TO_UTF8(msg)); + + msg = Component->m_Field[VALUE].m_Text; + msg.Replace(wxT(" "), wxT("_")); + fprintf(f, " \"%s\"", CONV_TO_UTF8(msg)); + fprintf(f, "\n"); + + } + } + fprintf( f, "\n"); + + MyFree(s_SortedComponentPinList); + s_SortedComponentPinList = NULL; + + WriteListOfNetsCADSTAR( f, g_TabObjNet ); + + fprintf( f, "\n%sEND\n", CONV_TO_UTF8(StartLine) ); +} + +/*************************************************************************/ +static void WriteListOfNetsCADSTAR( FILE * f, ObjetNetListStruct *ObjNet ) +/*************************************************************************/ +/* Ecrit dans le fichier f la liste des nets ( classee par NetCodes ), et des +pins qui y sont connectes +format: +.ADD_TER RR2 6 "$42" +.TER U1 100 + CA 6 +*/ +{ +wxString InitNetDesc = StartLine + wxT("ADD_TER"); +wxString StartNetDesc = StartLine + wxT("TER"); +wxString NetcodeName, InitNetDescLine; +int ii, jj, print_ter = 0; +int NetCode, LastNetCode = -1; +EDA_SchComponentStruct * Cmp; +wxString NetName; + + for (ii = 0; ii < g_NbrObjNet; ii++) ObjNet[ii].m_Flag = 0; + + for (ii = 0; ii < g_NbrObjNet; ii++) + { + // Get the NetName of the current net : + if( (NetCode = ObjNet[ii].m_NetCode) != LastNetCode ) + { + NetName.Empty(); + for (jj = 0; jj < g_NbrObjNet; jj++) + { + if( ObjNet[jj].m_NetCode != NetCode) continue; + if( ( ObjNet[jj].m_Type != NET_GLOBLABEL) && + ( ObjNet[jj].m_Type != NET_LABEL) && + ( ObjNet[jj].m_Type != NET_PINLABEL) ) continue; + + NetName = * ObjNet[jj].m_Label; break; + } + NetcodeName = wxT("\""); + if( ! NetName.IsEmpty() ) + { + NetcodeName += NetName; + if( g_TabObjNet[jj].m_Type != NET_PINLABEL) + NetcodeName << wxT("_") << g_TabObjNet[jj].m_SheetNumber; + } + else // this net has no name: create a default name $ + NetcodeName << wxT("$") << NetCode; + NetcodeName += wxT("\""); + LastNetCode = NetCode; + print_ter = 0; + } + + + if ( ObjNet[ii].m_Type != NET_PIN ) continue; + + if ( ObjNet[ii].m_Flag != 0 ) continue; + + Cmp = (EDA_SchComponentStruct*) ObjNet[ii].m_Link; + + if ( Cmp->m_Field[REFERENCE].m_Text[0] == '#' ) + continue; // Pseudo composant (symboles d'alims) + + switch ( print_ter ) + { + case 0: + { + char buf[5]; + wxString str_pinnum; + strncpy(buf, (char*) & ObjNet[ii].m_PinNum,4); buf[4] = 0; + str_pinnum = CONV_FROM_UTF8(buf); + InitNetDescLine.Printf( wxT("\n%s %s %.4s %s"), + InitNetDesc.GetData(), + Cmp->m_Field[REFERENCE].m_Text.GetData(), + str_pinnum.GetData(), NetcodeName.GetData()); + } + print_ter++; + break; + + case 1: + fprintf( f, "%s\n", CONV_TO_UTF8(InitNetDescLine)); + fprintf( f, "%s %s %.4s\n", + CONV_TO_UTF8(StartNetDesc), + CONV_TO_UTF8(Cmp->m_Field[REFERENCE].m_Text), + (char*) & ObjNet[ii].m_PinNum ); + print_ter++; + break; + + default: + fprintf( f, " %s %.4s\n", + CONV_TO_UTF8(Cmp->m_Field[REFERENCE].m_Text), + (char*) & ObjNet[ii].m_PinNum ); + break; + } + + ObjNet[ii].m_Flag = 1; + // Recherche des pins redondantes et mise a 1 de m_Flag, + // pour ne pas generer plusieurs fois la connexion + for (jj = ii + 1; jj < g_NbrObjNet; jj++) + { + if( ObjNet[jj].m_NetCode != NetCode) break; + if( ObjNet[jj].m_Type != NET_PIN ) continue; + EDA_SchComponentStruct * tstcmp = + (EDA_SchComponentStruct *) ObjNet[jj].m_Link; + if( Cmp->m_Field[REFERENCE].m_Text != tstcmp->m_Field[REFERENCE].m_Text ) continue; + + if ( ObjNet[jj].m_PinNum == ObjNet[ii].m_PinNum ) ObjNet[jj].m_Flag = 1; + } + } +} + diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp new file mode 100644 index 0000000000..ff81fa589d --- /dev/null +++ b/eeschema/netlist.cpp @@ -0,0 +1,1044 @@ + /***********************************/ + /* Module de calcul de la Netliste */ + /***********************************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "netlist.h" /* Definitions generales liees au calcul de netliste */ +#include "protos.h" + + + +/* Routines locales */ +static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus ); +static void SheetLabelConnection(ObjetNetListStruct *SheetLabel); +static int ListeObjetConnection(WinEDA_SchematicFrame * frame, SCH_SCREEN *screen, ObjetNetListStruct *ObjNet); +static int ConvertBusToMembers(ObjetNetListStruct *ObjNet); +static void PointToPointConnect(ObjetNetListStruct *RefObj, int IsBus, + int start); +static void SegmentToPointConnect(ObjetNetListStruct *Jonction, int IsBus, + int start); +static void LabelConnection(ObjetNetListStruct *Label); +static int TriNetCode(ObjetNetListStruct *Objet1, ObjetNetListStruct *Objet2); +static void ConnectBusLabels( ObjetNetListStruct *Label, int NbItems ); +static void SetUnconnectedFlag( ObjetNetListStruct *ObjNet, int NbItems ); +static int TriBySheet(ObjetNetListStruct *Objet1, ObjetNetListStruct *Objet2); + +/* Variable locales */ +static int FirstNumWireBus, LastNumWireBus, RootBusNameLength; +static int LastNetCode, LastBusNetCode; +static int s_PassNumber; + + + +/***********************************************************************/ +void FreeTabNetList(ObjetNetListStruct * TabNetItems, int NbrNetItems) +/***********************************************************************/ +/* + Routine de liberation memoire des tableaux utilises pour le calcul + de la netliste + TabNetItems = pointeur sur le tableau principal (liste des items ) + NbrNetItems = nombre d'elements +*/ +{ +int i; + + /* Liberation memoire des strings du champ Label reserve par ConvertBusToMembers */ + for (i = 0; i < NbrNetItems; i++) + { + switch( TabNetItems[i].m_Type ) + { + case NET_PIN: + case NET_SHEETLABEL: + case NET_SEGMENT: + case NET_JONCTION: + case NET_BUS: + case NET_LABEL: + case NET_GLOBLABEL: + case NET_PINLABEL: + case NET_NOCONNECT: + break; + case NET_GLOBBUSLABELMEMBER: + case NET_SHEETBUSLABELMEMBER: + case NET_BUSLABELMEMBER: + delete TabNetItems[i].m_Label; + break; + } + } + + MyFree(TabNetItems); +} + +/*****************************************************/ +void * WinEDA_SchematicFrame::BuildNetListBase(void) +/*****************************************************/ +/* Routine qui construit le tableau des elements connectes du projet + met a jour: + g_TabObjNet + g_NbrObjNet +*/ +{ +int NetNumber, SheetNumber; +int i, istart, NetCode; +SCH_SCREEN * screen; +ObjetNetListStruct * BaseTabObjNet; +wxString msg; +wxBusyCursor Busy; + + NetNumber = 1; + s_PassNumber = 0; + MsgPanel->EraseMsgBox(); + Affiche_1_Parametre(this, 1,_("List"), wxEmptyString, LIGHTRED); + + /* Build the screen list */ + EDA_ScreenList ScreenList(NULL); + + /* 1ere passe : Comptage du nombre d'objet de Net */ + g_NbrObjNet = 0; + g_TabObjNet = NULL; /* Init pour le 1er passage dans ListeObjetConnection */ + + /* Update the sheet number, sheet count and date and count nelist items */ + ScreenSch->SetModify(); + int kk = 1; + for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + screen->m_SheetNumber = kk++; + screen->m_NumberOfSheet = ScreenList.GetCount(); + screen->m_Date = GenDate(); + g_NbrObjNet += ListeObjetConnection(this, screen, NULL); + } + + if( g_NbrObjNet == 0 ) + { + DisplayError(this, _("No component"), 20); + return(NULL); + } + + i = sizeof(ObjetNetListStruct) * g_NbrObjNet; + BaseTabObjNet = g_TabObjNet = (ObjetNetListStruct *) MyZMalloc(i); + if( BaseTabObjNet == NULL ) return(NULL); + + /* 2eme passe : Remplissage des champs des structures des objets de Net */ + + s_PassNumber ++; + Affiche_1_Parametre(this, 1,_("List"), wxEmptyString,RED); + for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + g_TabObjNet += ListeObjetConnection(this, screen, g_TabObjNet ); + } + + Affiche_1_Parametre(this, -1, wxEmptyString,_("Done"),RED); + + msg.Printf( wxT("%d"), g_NbrObjNet); + Affiche_1_Parametre(this, 8, _("NbItems"),msg,GREEN); + + /* Recherche des connections pour les Segments et les Pins */ + /* Tri du Tableau des objets de Net par Sheet */ + + qsort(BaseTabObjNet, g_NbrObjNet, sizeof(ObjetNetListStruct), + (int (*)(const void *, const void *)) TriBySheet); + + Affiche_1_Parametre(this, 18,_("Conn"), wxEmptyString,CYAN); + + g_TabObjNet = BaseTabObjNet; + SheetNumber = g_TabObjNet[0].m_SheetNumber; + LastNetCode = LastBusNetCode = 1; + for (i = istart = 0; i < g_NbrObjNet; i++) + { + if(g_TabObjNet[i].m_SheetNumber != SheetNumber ) + { + SheetNumber = g_TabObjNet[i].m_SheetNumber; istart = i; + } + + switch( g_TabObjNet[i].m_Type ) + { + case NET_PIN: + case NET_PINLABEL: + case NET_SHEETLABEL: + case NET_NOCONNECT: + if ( g_TabObjNet[i].m_NetCode != 0 ) break; /* Deja connecte */ + case NET_SEGMENT: + /* Controle des connexions type point a point ( Sans BUS ) */ + if( g_TabObjNet[i].m_NetCode == 0 ) + { + g_TabObjNet[i].m_NetCode = LastNetCode; + LastNetCode++; + } + PointToPointConnect(g_TabObjNet+i, 0, istart); + break; + + case NET_JONCTION: + /* Controle des jonction , hors BUS */ + if( g_TabObjNet[i].m_NetCode == 0 ) + { + g_TabObjNet[i].m_NetCode = LastNetCode; + LastNetCode++; + } + SegmentToPointConnect( g_TabObjNet+i, 0, istart); + + /* Controle des jonction , sur BUS */ + if( g_TabObjNet[i].m_BusNetCode == 0 ) + { + g_TabObjNet[i].m_BusNetCode = LastBusNetCode; + LastBusNetCode++; + } + SegmentToPointConnect( g_TabObjNet+i, ISBUS, istart ); + break; + + case NET_LABEL: + case NET_GLOBLABEL: + /* Controle des connexions type jonction ( Sans BUS ) */ + if( g_TabObjNet[i].m_NetCode == 0 ) + { + g_TabObjNet[i].m_NetCode = LastNetCode; + LastNetCode++; + } + SegmentToPointConnect( g_TabObjNet+i, 0, istart ); + break; + + case NET_SHEETBUSLABELMEMBER: + if ( g_TabObjNet[i].m_BusNetCode != 0 ) break; /* Deja connecte */ + case NET_BUS: + /* Controle des connexions type point a point mode BUS */ + if( g_TabObjNet[i].m_BusNetCode == 0 ) + { + g_TabObjNet[i].m_BusNetCode = LastBusNetCode; + LastBusNetCode++; + } + PointToPointConnect(g_TabObjNet+i, ISBUS, istart); + break; + + case NET_BUSLABELMEMBER: + case NET_GLOBBUSLABELMEMBER: + /* Controle des connexions semblables a des sur BUS */ + if( g_TabObjNet[i].m_NetCode == 0 ) + { + g_TabObjNet[i].m_BusNetCode = LastBusNetCode; + LastBusNetCode++; + } + SegmentToPointConnect( g_TabObjNet+i, ISBUS, istart); + break; + + } + } + Affiche_1_Parametre(this, -1, wxEmptyString,_("Done"),CYAN); + + /* Mise a jour des NetCodes des Bus Labels connectes par les Bus */ + ConnectBusLabels( g_TabObjNet, g_NbrObjNet); + + Affiche_1_Parametre(this, 26,_("Labels"), wxEmptyString,CYAN); + + /* Connections des groupes d'objets par labels identiques */ + for (i = 0; i < g_NbrObjNet; i++) + { + switch( g_TabObjNet[i].m_Type ) + { + case NET_PIN: + case NET_SHEETLABEL: + case NET_SEGMENT: + case NET_JONCTION: + case NET_BUS: + case NET_NOCONNECT: + break; + + case NET_LABEL: + case NET_GLOBLABEL: + case NET_PINLABEL: + case NET_BUSLABELMEMBER: + case NET_GLOBBUSLABELMEMBER: + LabelConnection( g_TabObjNet+i ); + break; + case NET_SHEETBUSLABELMEMBER: + break; + } + } + + Affiche_1_Parametre(this, -1, wxEmptyString,_("Done"),CYAN); + + + /* Connexion des hierarchies */ + Affiche_1_Parametre(this, 36,_("Hierar."), wxEmptyString,LIGHTRED); + + for (i = 0; i < g_NbrObjNet; i++) + { + if( (g_TabObjNet[i].m_Type == NET_SHEETLABEL ) || + ( g_TabObjNet[i].m_Type == NET_SHEETBUSLABELMEMBER ) ) + SheetLabelConnection(g_TabObjNet + i); + } + + /* Tri du Tableau des objets de Net par NetCode */ + qsort(g_TabObjNet, g_NbrObjNet, sizeof(ObjetNetListStruct), + (int (*)(const void *, const void *)) TriNetCode); + + Affiche_1_Parametre(this, -1, wxEmptyString,_("Done"),RED); + + /* Compression des numeros de NetCode a des valeurs consecutives */ + Affiche_1_Parametre(this, 46,_("Sorting"), wxEmptyString,GREEN); + LastNetCode = NetCode = 0; + for (i = 0; i < g_NbrObjNet; i++) + { + if(g_TabObjNet[i].m_NetCode != LastNetCode) + { + NetCode++; LastNetCode = g_TabObjNet[i].m_NetCode; + } + g_TabObjNet[i].m_NetCode = NetCode; + } + + Affiche_1_Parametre(this, -1, wxEmptyString,_("Done"),GREEN); + + /* Affectation du m_FlagOfConnection en fonction de connection ou non */ + SetUnconnectedFlag( BaseTabObjNet, g_NbrObjNet); + + return( (void*) BaseTabObjNet); +} + +/************************************************************* +* Routine qui connecte les sous feuilles par les sheetLabels * +**************************************************************/ +static void SheetLabelConnection(ObjetNetListStruct *SheetLabel) +{ +int i; +ObjetNetListStruct *ObjetNet; + + if( SheetLabel->m_NetCode == 0 ) return; + + /* Calcul du numero de sous feuille correspondante au sheetlabel */ + + /* Comparaison du SheetLabel avec les GLABELS de la sous feuille + pour regroupement des NetCodes */ + for (i = 0, ObjetNet = g_TabObjNet; i < g_NbrObjNet; i++) + { + if( ObjetNet[i].m_SheetNumber != SheetLabel->m_NumInclude ) continue; + if( (ObjetNet[i].m_Type != NET_GLOBLABEL ) && + (ObjetNet[i].m_Type != NET_GLOBBUSLABELMEMBER ) ) + continue; + if( ObjetNet[i].m_NetCode == SheetLabel->m_NetCode ) continue; + if( ObjetNet[i].m_Label->CmpNoCase(*SheetLabel->m_Label) != 0) continue; + + /* Propagation du Netcode a tous les Objets de meme NetCode */ + if( ObjetNet[i].m_NetCode ) + PropageNetCode(ObjetNet[i].m_NetCode, SheetLabel->m_NetCode, 0); + else ObjetNet[i].m_NetCode = SheetLabel->m_NetCode; + } +} + +/*****************************************************************************/ +static int ListeObjetConnection(WinEDA_SchematicFrame * frame, SCH_SCREEN *screen, + ObjetNetListStruct *ObjNet) +/*****************************************************************************/ +/* Routine generant la liste des objets relatifs aux connection + entree: + screen: pointeur sur l'ecran a traiter + ObjNet: + si NULL: la routine compte seulement le nombre des objets + sinon: pointe le tableau a remplir +*/ +{ +int ii, NbrItem = 0, NumSheet; +EDA_BaseStruct *DrawList; +EDA_SchComponentStruct *DrawLibItem; +int TransMat[2][2], PartX, PartY, x2, y2; +EDA_LibComponentStruct *Entry; +LibEDA_BaseStruct *DEntry; +DrawSheetLabelStruct *SheetLabel; +int NumInclude; + + NumSheet = screen->m_SheetNumber; + DrawList = screen->EEDrawList; + + while ( DrawList ) + { + switch( DrawList->m_StructType ) + { + case DRAW_SEGMENT_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((EDA_DrawLineStruct *) DrawList) + if( ObjNet) + { + if ( (STRUCT->m_Layer != LAYER_BUS) && + (STRUCT->m_Layer != LAYER_WIRE) ) + break; + + ObjNet[NbrItem].m_Comp = STRUCT; + ObjNet[NbrItem].m_Screen = screen; + ObjNet[NbrItem].m_SheetNumber = NumSheet; + ObjNet[NbrItem].m_Start = STRUCT->m_Start; + ObjNet[NbrItem].m_End = STRUCT->m_End; + if (STRUCT->m_Layer == LAYER_BUS) + { + ObjNet[NbrItem].m_Type = NET_BUS; + } + else /* Cas des WIRE */ + { + ObjNet[NbrItem].m_Type = NET_SEGMENT; + } + } + NbrItem++; + break; + + case DRAW_JUNCTION_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((DrawJunctionStruct *) DrawList) + if( ObjNet) + { + ObjNet[NbrItem].m_Comp = STRUCT; + ObjNet[NbrItem].m_Screen = screen; + ObjNet[NbrItem].m_Type = NET_JONCTION; + ObjNet[NbrItem].m_SheetNumber = NumSheet; + ObjNet[NbrItem].m_Start = STRUCT->m_Pos; + ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; + } + NbrItem++; + break; + + case DRAW_NOCONNECT_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((DrawNoConnectStruct *) DrawList) + if( ObjNet) + { + ObjNet[NbrItem].m_Comp = STRUCT; + ObjNet[NbrItem].m_Screen = screen; + ObjNet[NbrItem].m_Type = NET_NOCONNECT; + ObjNet[NbrItem].m_SheetNumber = NumSheet; + ObjNet[NbrItem].m_Start = STRUCT->m_Pos; + ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; + } + NbrItem++; + break; + + case DRAW_LABEL_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((DrawLabelStruct *) DrawList) + ii = IsBusLabel( STRUCT->m_Text); + if( ObjNet) + { + ObjNet[NbrItem].m_Comp = STRUCT; + ObjNet[NbrItem].m_Screen = screen; + ObjNet[NbrItem].m_Type = NET_LABEL; + if (STRUCT->m_Layer == LAYER_GLOBLABEL) + ObjNet[NbrItem].m_Type = NET_GLOBLABEL; + ObjNet[NbrItem].m_Label = & STRUCT->m_Text; + ObjNet[NbrItem].m_SheetNumber = NumSheet; + ObjNet[NbrItem].m_Start = STRUCT->m_Pos; + ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; + /* Si c'est un Bus, eclatement en Label */ + if ( ii ) ConvertBusToMembers(ObjNet + NbrItem); + } + NbrItem += ii+1; + break; + + case DRAW_GLOBAL_LABEL_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((DrawGlobalLabelStruct *) DrawList) + ii = IsBusLabel( STRUCT->m_Text); + if( ObjNet) + { + ObjNet[NbrItem].m_Comp = STRUCT; + ObjNet[NbrItem].m_Screen = screen; + ObjNet[NbrItem].m_Type = NET_LABEL; + if (STRUCT->m_Layer == LAYER_GLOBLABEL) + ObjNet[NbrItem].m_Type = NET_GLOBLABEL; + ObjNet[NbrItem].m_Label = & STRUCT->m_Text; + ObjNet[NbrItem].m_SheetNumber = NumSheet; + ObjNet[NbrItem].m_Start = STRUCT->m_Pos; + ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; + /* Si c'est un Bus, eclatement en Label */ + if ( ii ) ConvertBusToMembers(ObjNet + NbrItem); + } + NbrItem += ii+1; + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE : + DrawLibItem = (EDA_SchComponentStruct *) DrawList; + memcpy(TransMat, DrawLibItem->m_Transform, sizeof(TransMat)); + PartX = DrawLibItem->m_Pos.x; PartY = DrawLibItem->m_Pos.y; + Entry = FindLibPart(DrawLibItem->m_ChipName, wxEmptyString, FIND_ROOT); + + if( Entry == NULL) break; + if(Entry->m_Drawings == NULL) break ; + DEntry = Entry->m_Drawings; + for ( ;DEntry != NULL; DEntry = DEntry->Next()) + { + LibDrawPin * Pin = (LibDrawPin *) DEntry; + if( DEntry->m_StructType != COMPONENT_PIN_DRAW_TYPE) continue; + if( DEntry->m_Unit && + (DEntry->m_Unit != DrawLibItem->m_Multi) ) continue; + if( DEntry->m_Convert && + (DEntry->m_Convert != DrawLibItem->m_Convert)) continue; + + x2 = PartX + TransMat[0][0] * Pin->m_Pos.x + + TransMat[0][1] * Pin->m_Pos.y; + y2 = PartY + TransMat[1][0] * Pin->m_Pos.x + + TransMat[1][1] * Pin->m_Pos.y; + + if( ObjNet) + { + ObjNet[NbrItem].m_Comp = DEntry; + ObjNet[NbrItem].m_Type = NET_PIN; + ObjNet[NbrItem].m_Link = DrawLibItem; + ObjNet[NbrItem].m_Screen = screen; + ObjNet[NbrItem].m_ElectricalType = Pin->m_PinType; + ObjNet[NbrItem].m_PinNum = Pin->m_PinNum; + ObjNet[NbrItem].m_Label = & Pin->m_PinName; + ObjNet[NbrItem].m_SheetNumber = NumSheet; + ObjNet[NbrItem].m_Start.x = x2; + ObjNet[NbrItem].m_Start.y = y2; + ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; + } + NbrItem++; + + if( ( (int) Pin->m_PinType == (int) PIN_POWER_IN ) && + ( Pin->m_Attributs & PINNOTDRAW ) ) + { /* Il y a un PIN_LABEL Associe */ + if( ObjNet) + { + ObjNet[NbrItem].m_Comp = NULL; + ObjNet[NbrItem].m_Type = NET_PINLABEL; + ObjNet[NbrItem].m_Screen = screen; + ObjNet[NbrItem].m_SheetNumber = NumSheet; + ObjNet[NbrItem].m_Label = & Pin->m_PinName; + ObjNet[NbrItem].m_Start.x = x2; + ObjNet[NbrItem].m_Start.y = y2; + ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; + } + NbrItem++; + } + } + break; + + case DRAW_PICK_ITEM_STRUCT_TYPE : + case DRAW_POLYLINE_STRUCT_TYPE : + case DRAW_BUSENTRY_STRUCT_TYPE : + case DRAW_MARKER_STRUCT_TYPE : + case DRAW_TEXT_STRUCT_TYPE : + break; + + case DRAW_SHEET_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((DrawSheetStruct *) DrawList) + NumInclude = STRUCT->m_SheetNumber; + + SheetLabel = STRUCT->m_Label; + for ( ; SheetLabel != NULL; + SheetLabel = (DrawSheetLabelStruct*) SheetLabel->Pnext) + { + ii = IsBusLabel(SheetLabel->m_Text); + if( ObjNet) + { + ObjNet[NbrItem].m_Comp = SheetLabel; + ObjNet[NbrItem].m_Link = DrawList; + ObjNet[NbrItem].m_Type = NET_SHEETLABEL; + ObjNet[NbrItem].m_Screen = screen; + ObjNet[NbrItem].m_ElectricalType = SheetLabel->m_Shape; + ObjNet[NbrItem].m_Label = & SheetLabel->m_Text; + ObjNet[NbrItem].m_SheetNumber = NumSheet; + ObjNet[NbrItem].m_NumInclude = NumInclude; + ObjNet[NbrItem].m_Start = SheetLabel->m_Pos; + ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; + /* Si c'est un Bus, eclatement en Label */ + if ( ii ) ConvertBusToMembers(ObjNet + NbrItem); + } + NbrItem += ii+1; + } + break; + + case DRAW_SHEETLABEL_STRUCT_TYPE : + DisplayError(frame, wxT("Netlist: Type DRAW_SHEETLABEL inattendu")); + break; + + default: + { + wxString msg; + msg.Printf( wxT("Netlist: unexpected type struct %d"), + DrawList->m_StructType); + DisplayError(frame, msg); + break; + } + } + + DrawList = DrawList->Pnext; + } + +return(NbrItem); +} + + +/************************************************************************/ +static void ConnectBusLabels( ObjetNetListStruct *Label, int NbItems ) +/************************************************************************/ +/* Routine qui analyse les labels type xxBUSLABELMEMBER + Propage les Netcodes entre labels correspondants ( c'est a dire lorsque + leur numero de membre est identique) lorsqu'ils sont connectes + globalement par leur BusNetCode + Utilise et met a jour la variable LastNetCode +*/ +{ +ObjetNetListStruct *LabelInTst, *Lim; + + Lim = Label + NbItems; + + for ( ; Label < Lim; Label++) + { + if( (Label->m_Type == NET_SHEETBUSLABELMEMBER) || + (Label->m_Type == NET_BUSLABELMEMBER) || + (Label->m_Type == NET_GLOBBUSLABELMEMBER) ) + { + if( Label->m_NetCode == 0 ) + { + Label->m_NetCode = LastNetCode; LastNetCode++; + } + for ( LabelInTst = Label+1; LabelInTst < Lim; LabelInTst++) + { + if( (LabelInTst->m_Type == NET_SHEETBUSLABELMEMBER) || + (LabelInTst->m_Type == NET_BUSLABELMEMBER) || + (LabelInTst->m_Type == NET_GLOBBUSLABELMEMBER) ) + { + if( LabelInTst->m_BusNetCode != Label->m_BusNetCode ) continue; + if( LabelInTst->m_Member != Label->m_Member ) continue; + if( LabelInTst->m_NetCode == 0 ) + LabelInTst->m_NetCode = Label->m_NetCode; + else + PropageNetCode( LabelInTst->m_NetCode, Label->m_NetCode,0); + } + } + } + } +} + + +/**************************************************/ +int IsBusLabel( const wxString & LabelDrawList ) +/**************************************************/ + +/* Routine qui verifie si le Label a une notation de type Bus + Retourne 0 si non + nombre de membres si oui + met a jour FirstNumWireBus, LastNumWireBus et RootBusNameLength +*/ + +{ +unsigned Num; +int ii; +wxString BufLine; +long tmp; +bool error = FALSE; + + /* Search for '[' because a bus label is like "busname[nn..mm]" */ + ii = LabelDrawList.Find('['); + if ( ii < 0 ) return(0); + Num = (unsigned) ii; + + FirstNumWireBus = LastNumWireBus = 9; + RootBusNameLength = Num; + Num++; + while ( LabelDrawList[Num] != '.' && Num < LabelDrawList.Len()) + { + BufLine.Append(LabelDrawList[Num]); + Num++; + } + + if ( ! BufLine.ToLong(&tmp) ) error = TRUE;; + FirstNumWireBus = tmp; + while ( LabelDrawList[Num] == '.' && Num < LabelDrawList.Len() ) + Num++; + BufLine.Empty(); + while ( LabelDrawList[Num] != ']' && Num < LabelDrawList.Len()) + { + BufLine.Append(LabelDrawList[Num]); + Num++; + } + if ( ! BufLine.ToLong(&tmp) ) error = TRUE;; + LastNumWireBus = tmp; + + if( FirstNumWireBus < 0 ) FirstNumWireBus = 0; + if( LastNumWireBus < 0 ) LastNumWireBus = 0; + if( FirstNumWireBus > LastNumWireBus ) + { + EXCHG( FirstNumWireBus, LastNumWireBus); + } + + if ( error && (s_PassNumber == 0) ) + { + wxString msg = _("Bad Bus Label: ") + LabelDrawList; + DisplayError(NULL, msg); + } + return(LastNumWireBus - FirstNumWireBus + 1 ); +} + + +/***************************************************************/ +static int ConvertBusToMembers(ObjetNetListStruct * BusLabel) +/***************************************************************/ +/* Routine qui eclate un label type Bus en autant de Label qu'il contient de membres, + et qui cree les structures avec le type NET_GLOBBUSLABELMEMBER, NET_BUSLABELMEMBER + ou NET_SHEETBUSLABELMEMBER + entree = pointeur sur l'ObjetNetListStruct initialise corresp au buslabel + suppose que FirstNumWireBus, LastNumWireBus et RootBusNameLength sont a jour + modifie l'ObjetNetListStruct de base et remplit les suivants + m_Label is a pointer to a new wxString + m_Label must be deallocated by the user (only for a NET_GLOBBUSLABELMEMBER, + NET_BUSLABELMEMBER or a NET_SHEETBUSLABELMEMBER object type) +*/ +{ +int NumItem, BusMember; +wxString BufLine; + + if( BusLabel->m_Type == NET_GLOBLABEL ) + BusLabel->m_Type = NET_GLOBBUSLABELMEMBER; + else if (BusLabel->m_Type == NET_SHEETLABEL) + BusLabel->m_Type = NET_SHEETBUSLABELMEMBER; + else BusLabel->m_Type = NET_BUSLABELMEMBER; + + /* Convertion du BusLabel en la racine du Label + le numero du fil */ + BufLine = BusLabel->m_Label->Left(RootBusNameLength); + BusMember = FirstNumWireBus; + BufLine << BusMember; + BusLabel->m_Label = new wxString(BufLine); + BusLabel->m_Member = BusMember; + NumItem = 1; + + for ( BusMember++; BusMember <= LastNumWireBus; BusMember++) + { + *(BusLabel+1) = *BusLabel; BusLabel ++; NumItem++; + /* Convertion du BusLabel en la racine du Label + le numero du fil */ + BufLine = BusLabel->m_Label->Left(RootBusNameLength); + BufLine << BusMember; + BusLabel->m_Label = new wxString(BufLine); + BusLabel->m_Member = BusMember; + } + return( NumItem); +} + +/**********************************************************************/ +static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus ) +/**********************************************************************/ +/* PropageNetCode propage le netcode NewNetCode sur tous les elements + appartenant a l'ancien netcode OldNetCode + Si IsBus == 0; c'est le membre NetCode qui est propage + Si IsBus != 0; c'est le membre BusNetCode qui est propage +*/ + +{ +int jj; +ObjetNetListStruct * Objet = g_TabObjNet; + + if( OldNetCode == NewNetCode ) return; + + if( IsBus == 0 ) /* Propagation du NetCode */ + { + for (jj = 0; jj < g_NbrObjNet; jj++, Objet++) + { + if ( Objet->m_NetCode == OldNetCode ) + { + Objet->m_NetCode = NewNetCode; + } + } + } + + else /* Propagation du BusNetCode */ + { + for (jj = 0; jj < g_NbrObjNet; jj++, Objet++) + { + if ( Objet->m_BusNetCode == OldNetCode ) + { + Objet->m_BusNetCode = NewNetCode; + } + } + } +} + +/***************************************************************************/ +static void PointToPointConnect(ObjetNetListStruct *Ref, int IsBus, int start) +/***************************************************************************/ +/* Routine qui verifie si l'element *Ref est connecte a + d'autres elements de la liste des objets du schema, selon le mode Point + a point ( Extremites superposees ) + + si IsBus: + la connexion ne met en jeu que des elements type bus + ( BUS ou BUSLABEL ou JONCTION ) + sinon + la connexion ne met en jeu que des elements type non bus + ( autres que BUS ou BUSLABEL ) + + L'objet Ref doit avoir un NetCode valide. + + La liste des objets est supposee classe par NumSheet Croissants, + et la recherche se fait a partir de l'element start, 1er element + de la feuille de schema +( il ne peut y avoir connexion physique entre elements de differentes sheets) +*/ +{ +int i, NetCode; +ObjetNetListStruct *Point = g_TabObjNet; + +if ( IsBus == 0 ) /* Objets autres que BUS et BUSLABELS */ + { + NetCode = Ref->m_NetCode; + for (i = start; i < g_NbrObjNet; i++) + { + if( Point[i].m_SheetNumber > Ref->m_SheetNumber ) break; + + switch( Point[i].m_Type ) + { + case NET_SEGMENT: + case NET_PIN: + case NET_LABEL: + case NET_GLOBLABEL: + case NET_SHEETLABEL: + case NET_PINLABEL: + case NET_JONCTION: + case NET_NOCONNECT: + if( (((Ref->m_Start.x == Point[i].m_Start.x) && (Ref->m_Start.y == Point[i].m_Start.y))) || + (((Ref->m_Start.x == Point[i].m_End.x) && (Ref->m_Start.y == Point[i].m_End.y))) || + (((Ref->m_End.x == Point[i].m_Start.x) && (Ref->m_End.y == Point[i].m_Start.y))) || + (((Ref->m_End.x == Point[i].m_End.x) && (Ref->m_End.y == Point[i].m_End.y))) ) + { + if( Point[i].m_NetCode == 0 ) Point[i].m_NetCode = NetCode; + else PropageNetCode( Point[i].m_NetCode, NetCode , 0); + } + break; + case NET_BUS: + case NET_BUSLABELMEMBER: + case NET_SHEETBUSLABELMEMBER: + case NET_GLOBBUSLABELMEMBER: + break; + } + } + } +else /* Objets type BUS et BUSLABELS ( et JONCTIONS )*/ + { + NetCode = Ref->m_BusNetCode; + for (i = start; i < g_NbrObjNet; i++) + { + if( Point[i].m_SheetNumber > Ref->m_SheetNumber ) break; + + switch( Point[i].m_Type ) + { + case NET_SEGMENT: + case NET_PIN: + case NET_LABEL: + case NET_GLOBLABEL: + case NET_SHEETLABEL: + case NET_PINLABEL: + case NET_NOCONNECT: + break; + + case NET_BUS: + case NET_BUSLABELMEMBER: + case NET_SHEETBUSLABELMEMBER: + case NET_GLOBBUSLABELMEMBER: + case NET_JONCTION: + if( (((Ref->m_Start.x == Point[i].m_Start.x) && (Ref->m_Start.y == Point[i].m_Start.y))) || + (((Ref->m_Start.x == Point[i].m_End.x) && (Ref->m_Start.y == Point[i].m_End.y))) || + (((Ref->m_End.x == Point[i].m_Start.x) && (Ref->m_End.y == Point[i].m_Start.y))) || + (((Ref->m_End.x == Point[i].m_End.x) && (Ref->m_End.y == Point[i].m_End.y))) ) + { + if( Point[i].m_BusNetCode == 0 ) + Point[i].m_BusNetCode = NetCode; + else PropageNetCode( Point[i].m_BusNetCode, NetCode,1 ); + } + break; + } + } + } +} + + +/**************************************************************/ +static void SegmentToPointConnect(ObjetNetListStruct *Jonction, + int IsBus, int start) +/***************************************************************/ +/* +Routine qui recherche si un point (jonction) est connecte a des segments, +et regroupe les NetCodes des objets connectes a la jonction. +Le point de jonction doit avoir un netcode valide + La liste des objets est supposee classe par NumSheet Croissants, + et la recherche se fait a partir de l'element start, 1er element + de la feuille de schema +( il ne peut y avoir connexion physique entre elements de differentes sheets) +*/ +{ +int i; +ObjetNetListStruct *Segment = g_TabObjNet; + + for (i = start; i < g_NbrObjNet; i++) + { + if( Segment[i].m_SheetNumber > Jonction->m_SheetNumber ) break; + + if( IsBus == 0) + { + if ( Segment[i].m_Type != NET_SEGMENT ) continue; + } + else + { + if ( Segment[i].m_Type != NET_BUS ) continue; + } + + if ( SegmentIntersect(Segment[i].m_Start.x, Segment[i].m_Start.y, + Segment[i].m_End.x, Segment[i].m_End.y, + Jonction->m_Start.x, Jonction->m_Start.y) ) + { + /* Propagation du Netcode a tous les Objets de meme NetCode */ + if( IsBus == 0 ) + { + if( Segment[i].m_NetCode ) + PropageNetCode(Segment[i].m_NetCode, + Jonction->m_NetCode, IsBus); + else Segment[i].m_NetCode = Jonction->m_NetCode; + } + else + { + if( Segment[i].m_BusNetCode ) + PropageNetCode(Segment[i].m_BusNetCode, + Jonction->m_BusNetCode, IsBus); + else Segment[i].m_BusNetCode = Jonction->m_BusNetCode; + } + } + } +} + +/***************************************************************** +* Routine qui connecte les groupes d'objets si labels identiques * +*******************************************************************/ +static void LabelConnection(ObjetNetListStruct *LabelRef) +{ +int i, NetCode; +ObjetNetListStruct *ObjetNet; + + if( LabelRef->m_NetCode == 0 ) return; + + ObjetNet = g_TabObjNet; + + for (i = 0; i < g_NbrObjNet; i++) + { + NetCode = ObjetNet[i].m_NetCode; + if( NetCode == LabelRef->m_NetCode ) continue; + + if( ObjetNet[i].m_SheetNumber != LabelRef->m_SheetNumber ) + { + if (ObjetNet[i].m_Type != NET_PINLABEL ) continue; + } + + if( (ObjetNet[i].m_Type == NET_LABEL ) || + (ObjetNet[i].m_Type == NET_GLOBLABEL ) || + (ObjetNet[i].m_Type == NET_BUSLABELMEMBER ) || + (ObjetNet[i].m_Type == NET_GLOBBUSLABELMEMBER ) || + (ObjetNet[i].m_Type == NET_PINLABEL ) ) + { + if( ObjetNet[i].m_Label->CmpNoCase(*LabelRef->m_Label) != 0) continue; + + /* Ici 2 labels identiques */ + + /* Propagation du Netcode a tous les Objets de meme NetCode */ + if( ObjetNet[i].m_NetCode ) + PropageNetCode(ObjetNet[i].m_NetCode, LabelRef->m_NetCode, 0); + else ObjetNet[i].m_NetCode = LabelRef->m_NetCode; + } + } +} + + + +/****************************************************************************/ +static int TriNetCode(ObjetNetListStruct *Objet1, ObjetNetListStruct *Objet2) +/****************************************************************************/ +/* Routine de comparaison pour le tri par NetCode croissant + du tableau des elements connectes ( TabPinSort ) par qsort() +*/ +{ + return (Objet1->m_NetCode - Objet2->m_NetCode); +} + +/*****************************************************************************/ +static int TriBySheet(ObjetNetListStruct *Objet1, ObjetNetListStruct *Objet2) +/*****************************************************************************/ +/* Routine de comparaison pour le tri par NumSheet + du tableau des elements connectes ( TabPinSort ) par qsort() */ + +{ + return (Objet1->m_SheetNumber - Objet2->m_SheetNumber); +} + + +/**********************************************************************/ +static void SetUnconnectedFlag( ObjetNetListStruct *ListObj, int NbItems ) +/**********************************************************************/ +/* Routine positionnant le membre .FlagNoConnect des elements de + la liste des objets netliste, tries par ordre de NetCode +*/ +{ +ObjetNetListStruct * NetItemRef, * NetItemTst, *ItemPtr; +ObjetNetListStruct * NetStart, * NetEnd, * Lim; +int Nb; +IsConnectType StateFlag; + + + NetStart = NetEnd = ListObj; + Lim = ListObj + NbItems; + NetItemRef = NetStart; + Nb = 0; StateFlag = UNCONNECT; + + for ( ; NetItemRef < Lim; NetItemRef++ ) + { + if( NetItemRef->m_Type == NET_NOCONNECT ) + if( StateFlag != CONNECT ) StateFlag = NOCONNECT; + + /* Analyse du net en cours */ + NetItemTst = NetItemRef + 1; + + if( (NetItemTst >= Lim) || + (NetItemRef->m_NetCode != NetItemTst->m_NetCode) ) + { /* Net analyse: mise a jour de m_FlagOfConnection */ + NetEnd = NetItemTst; + + for( ItemPtr = NetStart; ItemPtr < NetEnd; ItemPtr++ ) + { + ItemPtr->m_FlagOfConnection = StateFlag; + } + if(NetItemTst >= Lim) return; + + /* Start Analyse Nouveau Net */ + StateFlag = UNCONNECT; + NetStart = NetItemTst; + continue; + } + + for ( ; ; NetItemTst ++) + { + if( (NetItemTst >= Lim) || + (NetItemRef->m_NetCode != NetItemTst->m_NetCode) ) + break; + + switch( NetItemTst->m_Type ) + { + case NET_SEGMENT: + case NET_LABEL: + case NET_GLOBLABEL: + case NET_SHEETLABEL: + case NET_PINLABEL: + case NET_BUS: + case NET_BUSLABELMEMBER: + case NET_SHEETBUSLABELMEMBER: + case NET_GLOBBUSLABELMEMBER: + case NET_JONCTION: + break; + + case NET_PIN: + if( NetItemRef->m_Type == NET_PIN ) + StateFlag = CONNECT; + break; + + case NET_NOCONNECT: + if( StateFlag != CONNECT ) StateFlag = NOCONNECT; + break; + } + } + } +} + diff --git a/eeschema/netlist.h b/eeschema/netlist.h new file mode 100644 index 0000000000..3cb9de946b --- /dev/null +++ b/eeschema/netlist.h @@ -0,0 +1,111 @@ + /**********************************************/ + /* Module de calcul de la Netliste: netlist.h */ + /**********************************************/ + +#ifndef _NETLIST_H_ +#define _NETLIST_H_ + +#ifndef eda_global +#define eda_global extern +#endif + +#define NETLIST_HEAD_STRING "EESchema Netlist Version 1.1" + +#define ISBUS 1 + + +/* Indicateurs de type de netliste generee */ +typedef enum + { + NET_TYPE_NOT_INIT = 0, + NET_TYPE_PCBNEW, + NET_TYPE_ORCADPCB2, + NET_TYPE_CADSTAR, + NET_TYPE_SPICE, + NET_TYPE_CUSTOM1, + NET_TYPE_CUSTOM2, + NET_TYPE_CUSTOM3, + NET_TYPE_CUSTOM4, + NET_TYPE_CUSTOM5, + NET_TYPE_CUSTOM6, + NET_TYPE_CUSTOM7, + NET_TYPE_CUSTOM8, + NET_TYPE_MAX + } TypeNetForm ; + + +/* Max pin number per component and footprint */ +#define MAXPIN 5000 + +typedef enum { /* Type des objets de Net */ + NET_SEGMENT, + NET_BUS, + NET_JONCTION, + NET_LABEL, + NET_GLOBLABEL, + NET_BUSLABELMEMBER, + NET_GLOBBUSLABELMEMBER, + NET_SHEETBUSLABELMEMBER, + NET_SHEETLABEL, + NET_PINLABEL, + NET_PIN, + NET_NOCONNECT +} NetObjetType; + +typedef enum { /* Valeur du Flag de connection */ + UNCONNECT, /* Pin ou Label non connecte */ + NOCONNECT, /* Pin volontairement non connectee (Symb. NoConnect utilise) */ + CONNECT /* connexion normale */ +} IsConnectType; + +/* Structure decrivant 1 element de connexion (pour netlist ) */ +class ObjetNetListStruct +{ +public: + void * m_Comp; /* Pointeur sur la definition de l'objet */ + void * m_Link; /* Pour SheetLabelStruct: Pointeur sur la feuille de hierarchie + Pour les Pins: pointeur sur le composant */ + int m_Flag; /* flag pour calculs internes */ + SCH_SCREEN * m_Screen; /* Ecran d'appartenance */ + NetObjetType m_Type; + int m_ElectricalType; /* Pour Pins et sheet labels: type electrique */ + int m_NetCode; /* pour elements simples */ + int m_BusNetCode; /* pour connexions type bus */ + int m_Member; /* pour les labels type BUSWIRE ( labels de bus eclate ) + numero de membre */ + IsConnectType m_FlagOfConnection; + int m_SheetNumber; /* Sheet number for this item */ + int m_NumInclude; /* Numero de sous schema correpondant a la sheet (Gestion des GLabels et Pin Sheet)*/ + long m_PinNum; /* numero de pin( 4 octets -> 4 codes ascii) */ + const wxString * m_Label; /* Tous types Labels:pointeur sur la wxString definissant le label */ + wxPoint m_Start, m_End; +}; + +/* Structure decrivant 1 composant de la schematique (pour annotation ) */ +struct CmpListStruct +{ +public: + EDA_SchComponentStruct * m_Cmp; /* Pointeur sur le composant */ + int m_NbParts; /* Nombre de parts par boitier */ + bool m_PartsLocked; // For multi part components: True if the part cannot be changed + int m_Unit; /* Numero de part */ + int m_Sheet; /* Numero de hierarchie */ + int m_TimeStamp; /* Signature temporelle */ + int m_IsNew; /* != 0 pour composants non annotes */ + char m_TextValue[32]; /* Valeur */ + char m_TextRef[32]; /* Reference ( hors numero ) */ + int m_NumRef; /* Numero de reference */ + int m_Flag; /* flag pour calculs internes */ +}; + + +/* Global Variables */ +eda_global int g_NbrObjNet; +eda_global ObjetNetListStruct *g_TabObjNet; + +/* Prototypes: */ +void WriteNetList(WinEDA_SchematicFrame * frame, const wxString & FileNameNL, bool use_netnames); +void FreeTabNetList(ObjetNetListStruct * TabNetItems, int NbrNetItems); + + +#endif diff --git a/eeschema/netlist_control.cpp b/eeschema/netlist_control.cpp new file mode 100644 index 0000000000..5ebcc8a7c1 --- /dev/null +++ b/eeschema/netlist_control.cpp @@ -0,0 +1,549 @@ + /**********************************/ + /* Dilaog box for netlist outputs */ + /**********************************/ + +#include "fctsys.h" + +//#include "gr_basic.h" +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "netlist.h" /* Definitions generales liees au calcul de netliste */ +#include "protos.h" + + +// ID for configuration: +#define CUSTOM_NETLIST_TITLE wxT("CustomNetlistTitle") +#define CUSTOM_NETLIST_COMMAND wxT("CustomNetlistCommand") + +/* Routines locales */ + +/* Variable locales */ + +enum id_netlist { + ID_CREATE_NETLIST = 1550, + ID_CURRENT_FORMAT_IS_DEFAULT, + ID_CLOSE_NETLIST, + ID_RUN_SIMULATOR, + ID_SETUP_PLUGIN, + ID_NETLIST_NOTEBOOK +}; + +enum panel_netlist_index { + PANELPCBNEW = 0, // Create Netlist format Pcbnew + PANELORCADPCB2, // Create Netlis format OracdPcb2 + PANELCADSTAR, // Create Netlis format OracdPcb2 + PANELSPICE, // Create Netlis format Pspice + PANELCUSTOMBASE // Start auxiliary panels (custom netlists) +}; + +/* wxPanels for creating the NoteBook pages for each netlist format: +*/ +class EDA_NoteBookPage: public wxPanel +{ +public: + int m_IdNetType; + wxCheckBox * m_IsCurrentFormat; + WinEDA_EnterText * m_CommandStringCtrl; + WinEDA_EnterText * m_TitleStringCtrl; + wxButton * m_ButtonCancel; + wxBoxSizer * m_LeftBoxSizer; + wxBoxSizer * m_RightBoxSizer; + wxBoxSizer * m_LowBoxSizer; + + EDA_NoteBookPage(wxNotebook* parent, const wxString & title, + int id_NetType, int idCheckBox, int idCreateFile); + ~EDA_NoteBookPage(void) {}; +}; + + +/*****************************************************************************/ +EDA_NoteBookPage::EDA_NoteBookPage(wxNotebook* parent, const wxString & title, + int id_NetType, int idCheckBox, int idCreateFile) : + wxPanel(parent, -1 ) +/*****************************************************************************/ +/* Contructor to create a setup page for one netlist format. + Used in Netlist format Dialog box creation +*/ +{ + SetFont(*g_DialogFont); + m_IdNetType = id_NetType; + m_CommandStringCtrl = NULL; + m_TitleStringCtrl = NULL; + m_IsCurrentFormat = NULL; + m_ButtonCancel = NULL; + + parent->AddPage(this, title, g_NetFormat == m_IdNetType); + + wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxVERTICAL); + SetSizer(MainBoxSizer); + wxBoxSizer * UpperBoxSizer = new wxBoxSizer(wxHORIZONTAL); + m_LowBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(UpperBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(m_LowBoxSizer, 0, wxGROW|wxALL, 5); + + m_LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + m_RightBoxSizer = new wxBoxSizer(wxVERTICAL); + UpperBoxSizer->Add(m_LeftBoxSizer, 0, wxGROW|wxALL, 5); + UpperBoxSizer->Add(m_RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + if ( idCheckBox ) + { + wxStaticText * text = new wxStaticText(this, -1, _("Options:")); + m_LeftBoxSizer->Add(text, 0, wxGROW|wxALL, 5); + + m_IsCurrentFormat = new wxCheckBox(this, idCheckBox, + _("Default format")); + m_LeftBoxSizer->Add(m_IsCurrentFormat, 0, wxGROW|wxALL, 5); + + if ( g_NetFormat == m_IdNetType ) + m_IsCurrentFormat->SetValue(TRUE); + + } + + if ( idCreateFile ) // Create the 2 standard buttons: Create File ans Cancel + { + wxButton * Button; + if ( idCreateFile == ID_SETUP_PLUGIN ) + { + Button = new wxButton(this, idCreateFile, + _("&Browse Plugin")); + } + else + { + Button = new wxButton(this, idCreateFile, + _("&Netlist")); + } + Button->SetForegroundColour(*wxRED); + m_RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + m_ButtonCancel = + Button = new wxButton(this, ID_CLOSE_NETLIST, + _("&Close")); + Button->SetForegroundColour(*wxBLUE); + m_RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + } +} + +#define CUSTOMPANEL_COUNTMAX 8 +/* Dialog frame for creating netlists */ +class WinEDA_NetlistFrame: public wxDialog +{ +public: + WinEDA_SchematicFrame * m_Parent; + wxNotebook* m_NoteBook; + EDA_NoteBookPage * m_PanelNetType[4+CUSTOMPANEL_COUNTMAX]; + + wxRadioBox * m_UseNetNamesInNetlist; + +public: + // Constructor and destructor + WinEDA_NetlistFrame(WinEDA_SchematicFrame *parent, wxPoint& pos); + ~WinEDA_NetlistFrame(void) {}; + +private: + void InstallCustomPages(void); + void InstallPageSpice(void); + void GenNetlist(wxCommandEvent& event); + void RunSimulator(wxCommandEvent& event); + void NetlistUpdateOpt(void); + void NetlistExit(wxCommandEvent& event); + void SelectNetlistType(wxCommandEvent& event); + void SetupPlugin(wxCommandEvent& event); + DECLARE_EVENT_TABLE()}; + +BEGIN_EVENT_TABLE(WinEDA_NetlistFrame, wxDialog) + EVT_BUTTON(ID_CLOSE_NETLIST, WinEDA_NetlistFrame::NetlistExit) + EVT_BUTTON(ID_CREATE_NETLIST, WinEDA_NetlistFrame::GenNetlist) + EVT_BUTTON(ID_SETUP_PLUGIN, WinEDA_NetlistFrame::SetupPlugin) + EVT_CHECKBOX(ID_CURRENT_FORMAT_IS_DEFAULT, WinEDA_NetlistFrame::SelectNetlistType) + EVT_BUTTON(ID_RUN_SIMULATOR, WinEDA_NetlistFrame::RunSimulator) +END_EVENT_TABLE() + + +/****************************************************************/ +void InstallNetlistFrame(WinEDA_SchematicFrame *parent, wxPoint & pos) +/****************************************************************/ +/* Installator for the netlist generation dialog box + */ +{ + WinEDA_NetlistFrame * frame = new WinEDA_NetlistFrame(parent, pos); + frame->ShowModal(); frame->Destroy(); +} + +#define H_SIZE 370 +#define V_SIZE 260 + +/*************************************************************************************/ +WinEDA_NetlistFrame::WinEDA_NetlistFrame(WinEDA_SchematicFrame *parent, wxPoint& framepos): + wxDialog(parent, -1, _("Netlist"), framepos, wxSize(H_SIZE, V_SIZE), + DIALOG_STYLE|wxRESIZE_BORDER) +/*************************************************************************************/ +/* Constructor for the netlist generation dialog box +*/ +{ +int ii; + + m_Parent = parent; + SetFont(*g_DialogFont); + if ( g_NetFormat == NET_TYPE_NOT_INIT ) + g_NetFormat = NET_TYPE_PCBNEW; + + for ( ii = 0; ii < PANELCUSTOMBASE+CUSTOMPANEL_COUNTMAX; ii ++ ) + { + m_PanelNetType[ii] = NULL; + } + + if ( (framepos.x == -1) && (framepos.x == -1) ) Centre(); + + wxBoxSizer * GeneralBoxSizer = new wxBoxSizer(wxVERTICAL); + SetSizer(GeneralBoxSizer); + + m_NoteBook = new wxNotebook(this, ID_NETLIST_NOTEBOOK, + wxDefaultPosition,wxSize(H_SIZE-6, V_SIZE - 28)); + m_NoteBook->SetFont(*g_DialogFont); + GeneralBoxSizer->Add(m_NoteBook, 0, wxGROW|wxALL, 5); + + // Add panels + + // Add Panel FORMAT PCBNEW + m_PanelNetType[PANELPCBNEW] = new EDA_NoteBookPage(m_NoteBook, wxT("Pcbnew"), NET_TYPE_PCBNEW, + ID_CURRENT_FORMAT_IS_DEFAULT, ID_CREATE_NETLIST); + + // Add Panel FORMAT ORCADPCB2 + m_PanelNetType[PANELORCADPCB2] = new EDA_NoteBookPage(m_NoteBook, wxT("OrcadPCB2"), NET_TYPE_ORCADPCB2, + ID_CURRENT_FORMAT_IS_DEFAULT, ID_CREATE_NETLIST); + + // Add Panel FORMAT CADSTAR + m_PanelNetType[PANELCADSTAR] = new EDA_NoteBookPage(m_NoteBook, wxT("CadStar"), NET_TYPE_CADSTAR, + ID_CURRENT_FORMAT_IS_DEFAULT, ID_CREATE_NETLIST); + + // Add Panel spice + InstallPageSpice(); + + // Add custom panels: + InstallCustomPages(); + + // Problem in wxMSV >= 2.7.1 : we must call GetSizer for one notebook page + // to have a proper sizer commutation of all pages + m_PanelNetType[PANELPCBNEW]->GetSizer()->Fit(this); + m_PanelNetType[PANELPCBNEW]->GetSizer()->SetSizeHints(this); + + + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); +} + + +/*************************************************/ +void WinEDA_NetlistFrame::InstallPageSpice(void) +/*************************************************/ +/* Create the spice page +*/ +{ +wxButton * Button; +EDA_NoteBookPage * page; + + page = m_PanelNetType[PANELSPICE] = new EDA_NoteBookPage(m_NoteBook, wxT("Spice"), NET_TYPE_SPICE, 0, 0); + + page->m_IsCurrentFormat = new wxCheckBox(page,ID_CURRENT_FORMAT_IS_DEFAULT, + _("Default format")); + page->m_IsCurrentFormat->SetValue( g_NetFormat == NET_TYPE_SPICE); + page->m_LeftBoxSizer->Add(page->m_IsCurrentFormat, 0, wxGROW|wxALL, 5); + +wxString netlist_opt[2] = { _("Use Net Names"), _("Use Net Numbers") }; + m_UseNetNamesInNetlist = new wxRadioBox(page,-1, _("Netlist Options:"), + wxDefaultPosition, wxDefaultSize, + 2, netlist_opt, 1, wxRA_SPECIFY_COLS); + if ( ! g_OptNetListUseNames ) m_UseNetNamesInNetlist->SetSelection(1); + page->m_LeftBoxSizer->Add(m_UseNetNamesInNetlist, 0, wxGROW|wxALL, 5); + + page->m_CommandStringCtrl = new WinEDA_EnterText(page, + _("Simulator command:"), g_SimulatorCommandLine, + page->m_LowBoxSizer, wxSize(H_SIZE- 10, -1) ); + // Add buttons + Button = new wxButton(page, ID_CREATE_NETLIST, _("Netlist") ); + Button->SetForegroundColour(*wxRED); + page->m_RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Button = new wxButton(page, ID_RUN_SIMULATOR, _("&Run Simulator")); + Button->SetForegroundColour(wxColour(0,100,0)); + page->m_RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Button = new wxButton(page, ID_CLOSE_NETLIST, _("&Close")); + Button->SetForegroundColour(*wxBLUE); + page->m_RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); +} + +/*************************************************/ +void WinEDA_NetlistFrame::InstallCustomPages(void) +/*************************************************/ +/* create the pages for custom netlist format selection: +*/ +{ +int ii, CustomCount; +wxString title, previoustitle, msg; +EDA_NoteBookPage * CurrPage; + + CustomCount = CUSTOMPANEL_COUNTMAX; + previoustitle = wxT("dummy_title"); + for ( ii = 0; ii < CustomCount; ii++ ) + { + msg = CUSTOM_NETLIST_TITLE; msg << ii+1; + title = m_Parent->m_Parent->m_EDA_Config->Read(msg); + + // Install the panel only if it is the first panel not initialised + if ( (title.IsEmpty()) && ( previoustitle.IsEmpty() ) ) break; + + previoustitle = title; + if ( title.IsEmpty() ) + CurrPage = m_PanelNetType[PANELCUSTOMBASE + ii] = + new EDA_NoteBookPage(m_NoteBook, _("Add Plugin"), + NET_TYPE_CUSTOM1 + ii, + ID_CURRENT_FORMAT_IS_DEFAULT , ID_SETUP_PLUGIN); + else + CurrPage = m_PanelNetType[PANELCUSTOMBASE + ii] = + new EDA_NoteBookPage(m_NoteBook, title, + NET_TYPE_CUSTOM1 + ii, + ID_CURRENT_FORMAT_IS_DEFAULT , ID_CREATE_NETLIST); + + msg = CUSTOM_NETLIST_COMMAND; msg << ii+1; + wxString Command = m_Parent->m_Parent->m_EDA_Config->Read(msg); + CurrPage->m_CommandStringCtrl = new WinEDA_EnterText(CurrPage, + _("Netlist command:"), Command, + CurrPage->m_LowBoxSizer, wxSize(H_SIZE- 10, -1) ); + + CurrPage->m_TitleStringCtrl = new WinEDA_EnterText(CurrPage, + _("Title:"), title, + CurrPage->m_LowBoxSizer, wxSize(H_SIZE- 10, -1) ); + } +} + + +/***********************************************************/ +void WinEDA_NetlistFrame::SetupPlugin(wxCommandEvent& event) +/***********************************************************/ +/* Browse the plugin files and set the m_CommandStringCtrl field +*/ +{ +wxString FullFileName, Mask, Path; + Mask = wxT("*"); + Path = EDA_Appl->m_BinDir; + FullFileName = EDA_FileSelector( _("Plugin files:"), + Path, /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + wxEmptyString, /* extension par defaut */ + Mask, /* Masque d'affichage */ + this, + wxFD_OPEN, + TRUE + ); + if ( FullFileName.IsEmpty() ) return; + +EDA_NoteBookPage * CurrPage; + CurrPage = (EDA_NoteBookPage *) m_NoteBook->GetCurrentPage(); + if ( CurrPage == NULL ) return; + + CurrPage->m_CommandStringCtrl->SetValue(FullFileName); + + /* Get a title for thgis page */ + wxString title = CurrPage->m_TitleStringCtrl->GetValue(); + if ( title.IsEmpty() ) + DisplayInfo(this, _("Now, you must choose a title for this netlist control page\nand close the dialog box")); +} + + +// Fonctions de positionnement des variables d'option +/*****************************************************************/ +void WinEDA_NetlistFrame::SelectNetlistType(wxCommandEvent& event) +/*****************************************************************/ +{ +int ii; +EDA_NoteBookPage * CurrPage; + + for ( ii = 0; ii < PANELCUSTOMBASE+CUSTOMPANEL_COUNTMAX; ii++ ) + if ( m_PanelNetType[ii] ) + m_PanelNetType[ii]->m_IsCurrentFormat->SetValue(FALSE); + + CurrPage = (EDA_NoteBookPage *) m_NoteBook->GetCurrentPage(); + if ( CurrPage == NULL ) return; + + g_NetFormat = CurrPage->m_IdNetType; + CurrPage->m_IsCurrentFormat->SetValue(TRUE); + +} + +/***********************************************/ +void WinEDA_NetlistFrame::NetlistUpdateOpt(void) +/***********************************************/ +{ +int ii; + + g_SimulatorCommandLine = + m_PanelNetType[PANELSPICE]->m_CommandStringCtrl->GetValue(); + g_NetFormat = NET_TYPE_PCBNEW; + + for ( ii = 0; ii < PANELCUSTOMBASE+CUSTOMPANEL_COUNTMAX; ii++ ) + { + if ( m_PanelNetType[ii] == NULL ) break; + if ( m_PanelNetType[ii]->m_IsCurrentFormat->GetValue() == TRUE ) + g_NetFormat = m_PanelNetType[ii]->m_IdNetType; + } + + g_OptNetListUseNames = TRUE; // Used for pspice, gnucap + if ( m_UseNetNamesInNetlist->GetSelection() == 1 ) + g_OptNetListUseNames = FALSE; +} + +/**********************************************************/ +void WinEDA_NetlistFrame::GenNetlist(wxCommandEvent& event) +/**********************************************************/ +{ +wxString FullFileName, FileExt, Mask; +int netformat_tmp = g_NetFormat; + + NetlistUpdateOpt(); + +EDA_NoteBookPage * CurrPage; + + CurrPage = (EDA_NoteBookPage *) m_NoteBook->GetCurrentPage(); + g_NetFormat = CurrPage->m_IdNetType; + + /* Calcul du nom du fichier netlist */ + FullFileName = ScreenSch->m_FileName; + + switch ( g_NetFormat ) + { + case NET_TYPE_SPICE: + FileExt = wxT(".cir"); + break; + case NET_TYPE_CADSTAR: + FileExt = wxT(".frp"); + break; + default: + FileExt = g_NetExtBuffer; + break; + } + + Mask = wxT("*") + FileExt + wxT("*"); + ChangeFileNameExt(FullFileName, FileExt); + + FullFileName = EDA_FileSelector( _("Netlist files:"), + wxEmptyString, /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + FileExt, /* extension par defaut */ + Mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + TRUE + ); + if ( FullFileName.IsEmpty() ) return; + + m_Parent->MsgPanel->EraseMsgBox(); + + ReAnnotatePowerSymbolsOnly(); + if( CheckAnnotate(m_Parent, 0) ) + { + if( !IsOK( this, _("Must be Annotated, Continue ?")) ) + return; + } + + /* Cleanup the entire hierarchy */ + EDA_ScreenList ScreenList(NULL); + for ( SCH_SCREEN * screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + bool ModifyWires; + ModifyWires = screen->SchematicCleanUp(NULL); + /* if wire list has changed, delete the Undo Redo list to avoid + pointer problems with deleted data */ + if ( ModifyWires ) + screen->ClearUndoRedoList(); + } + + m_Parent->BuildNetListBase(); + if ( CurrPage->m_CommandStringCtrl) + g_NetListerCommandLine = CurrPage->m_CommandStringCtrl->GetValue(); + else g_NetListerCommandLine.Empty(); + + switch (g_NetFormat) + { + default: + WriteNetList(m_Parent, FullFileName, TRUE); + break; + + case NET_TYPE_CADSTAR: + case NET_TYPE_ORCADPCB2: + WriteNetList(m_Parent, FullFileName, FALSE); + + case NET_TYPE_SPICE: + g_OptNetListUseNames = TRUE; // Used for pspice, gnucap + if ( m_UseNetNamesInNetlist->GetSelection() == 1 ) + g_OptNetListUseNames = FALSE; + WriteNetList(m_Parent, FullFileName, g_OptNetListUseNames); + break; + } + FreeTabNetList(g_TabObjNet, g_NbrObjNet ); + g_NetFormat = netformat_tmp; + + NetlistExit(event); +} + +/***********************************************************/ +void WinEDA_NetlistFrame::NetlistExit(wxCommandEvent& event) +/***********************************************************/ +{ +wxString msg, Command; + + NetlistUpdateOpt(); + // Update the new titles + for ( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ ) + { + EDA_NoteBookPage * CurrPage = m_PanelNetType[ii + PANELCUSTOMBASE]; + if ( CurrPage == NULL ) break; + msg = wxT("Custom"); msg << ii+1; + if ( CurrPage->m_TitleStringCtrl ) + { + wxString title = CurrPage->m_TitleStringCtrl->GetValue(); + if ( msg != title ) // Title has changed, Update config + { + msg = CUSTOM_NETLIST_TITLE; msg << ii+1; + m_Parent->m_Parent->m_EDA_Config->Write(msg, title); + } + } + + if ( CurrPage->m_CommandStringCtrl ) + { + Command = CurrPage->m_CommandStringCtrl->GetValue(); + msg = CUSTOM_NETLIST_COMMAND; msg << ii+1; + m_Parent->m_Parent->m_EDA_Config->Write(msg, Command); + } + } + Close(); +} + + +/***********************************************************/ +void WinEDA_NetlistFrame::RunSimulator(wxCommandEvent& event) +/***********************************************************/ +{ +wxString NetlistFullFileName, ExecFile, CommandLine; + + g_SimulatorCommandLine = + m_PanelNetType[PANELSPICE]->m_CommandStringCtrl->GetValue(); + g_SimulatorCommandLine.Trim(FALSE); + g_SimulatorCommandLine.Trim(TRUE); + ExecFile = g_SimulatorCommandLine.BeforeFirst(' '); + + CommandLine = g_SimulatorCommandLine.AfterFirst(' '); + + /* Calcul du nom du fichier netlist */ + NetlistFullFileName = ScreenSch->m_FileName; + ChangeFileNameExt(NetlistFullFileName, wxT(".cir")); + AddDelimiterString(NetlistFullFileName); + CommandLine += wxT(" ") + NetlistFullFileName; + + ExecuteFile(this, ExecFile, CommandLine); +} + diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp new file mode 100644 index 0000000000..4b47fe7f8c --- /dev/null +++ b/eeschema/onleftclick.cpp @@ -0,0 +1,350 @@ + /******************************************************/ + /* schedit.cpp: fonctions generales de la schematique */ + /******************************************************/ + +#include "fctsys.h" + +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "id.h" + +#include "protos.h" + +static wxArrayString s_CmpNameList; +static wxArrayString s_PowerNameList; + +/**********************************************************************************/ +void WinEDA_SchematicFrame::OnLeftClick(wxDC * DC, const wxPoint& MousePos) +/**********************************************************************************/ +/* Traite les commandes declenchée par le bouton gauche de la souris, + quand un outil est deja selectionné +*/ +{ +EDA_BaseStruct * DrawStruct = m_CurrentScreen->m_CurrentItem; + + if ( (m_ID_current_state == 0) || ( DrawStruct && DrawStruct->m_Flags ) ) + { + DrawPanel->m_AutoPAN_Request = FALSE; + g_ItemToRepeat = NULL; + + if ( DrawStruct && DrawStruct->m_Flags ) // Commande "POPUP" en cours + { + switch (DrawStruct->m_StructType ) + { + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + case DRAW_SHEETLABEL_STRUCT_TYPE: + case DRAW_SHEET_STRUCT_TYPE: + case DRAW_BUSENTRY_STRUCT_TYPE: + case DRAW_JUNCTION_STRUCT_TYPE: + case DRAW_LIB_ITEM_STRUCT_TYPE: + case DRAW_PART_TEXT_STRUCT_TYPE: + DrawStruct->Place( this, DC); + m_CurrentScreen->m_CurrentItem = NULL; + TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); + return; + + case SCREEN_STRUCT_TYPE: + case DRAW_PICK_ITEM_STRUCT_TYPE: + DisplayError(this, + wxT("OnLeftClick err: unexpected type for Place")); + DrawStruct->m_Flags = 0; + break; + + case DRAW_SEGMENT_STRUCT_TYPE: // Segment peut-etre en cours de trace + break; + + default: + DisplayError(this, + wxT("WinEDA_SchematicFrame::OnLeftClick err: m_Flags != 0")); + DrawStruct->m_Flags = 0; + break; + } + } + else + { + DrawStruct = SchematicGeneralLocateAndDisplay(); + } + } + + switch ( m_ID_current_state ) + { + case 0: + break; + + case ID_NO_SELECT_BUTT: + break; + + case ID_HIERARCHY_PUSH_POP_BUTT: + if ( DrawStruct && DrawStruct->m_Flags ) break; + DrawStruct = SchematicGeneralLocateAndDisplay(); + if ( DrawStruct && (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) ) + { + InstallNextScreen((DrawSheetStruct *) DrawStruct); + } + else InstallPreviousScreen(); + break; + + case ID_NOCONN_BUTT: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->m_CurrentItem = + g_ItemToRepeat = CreateNewNoConnectStruct(DC); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place(this, DC); + DrawPanel->m_AutoPAN_Request = FALSE; + } + TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); + break; + + case ID_JUNCTION_BUTT: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->m_CurrentItem = g_ItemToRepeat + = CreateNewJunctionStruct(DC, m_CurrentScreen->m_Curseur, TRUE); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place(this, DC); + DrawPanel->m_AutoPAN_Request = FALSE; + } + TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); + break; + + case ID_WIRETOBUS_ENTRY_BUTT: + case ID_BUSTOBUS_ENTRY_BUTT: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->m_CurrentItem = DrawStruct = + CreateBusEntry(DC, + (m_ID_current_state == ID_WIRETOBUS_ENTRY_BUTT) ? + WIRE_TO_BUS : BUS_TO_BUS); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place(this, DC); + m_CurrentScreen->m_CurrentItem = NULL; + TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); + DrawPanel->m_AutoPAN_Request = FALSE; + } + break; + + case ID_SCHEMATIC_DELETE_ITEM_BUTT: + LocateAndDeleteItem(this, DC); + m_CurrentScreen->SetModify(); + m_CurrentScreen->m_CurrentItem = NULL; + TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); + break; + + case ID_WIRE_BUTT: + BeginSegment(DC, LAYER_WIRE); + DrawPanel->m_AutoPAN_Request = TRUE; + break; + + case ID_BUS_BUTT: + BeginSegment(DC, LAYER_BUS); + DrawPanel->m_AutoPAN_Request = TRUE; + break; + + case ID_LINE_COMMENT_BUTT: + BeginSegment(DC, LAYER_NOTES); + DrawPanel->m_AutoPAN_Request = TRUE; + break; + + case ID_TEXT_COMMENT_BUTT: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->m_CurrentItem = + CreateNewText(DC, LAYER_NOTES); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place(this, DC); + DrawPanel->m_AutoPAN_Request = FALSE; + } + break; + + case ID_LABEL_BUTT: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->m_CurrentItem = + CreateNewText(DC, LAYER_LOCLABEL); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place( this, DC); + DrawPanel->m_AutoPAN_Request = FALSE; + TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); + } + break; + + case ID_GLABEL_BUTT: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->m_CurrentItem = + CreateNewText(DC, LAYER_GLOBLABEL); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place(this, DC); + DrawPanel->m_AutoPAN_Request = FALSE; + TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); + } + break; + + case ID_SHEET_SYMBOL_BUTT: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->m_CurrentItem = CreateSheet(DC); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place( this, DC); + DrawPanel->m_AutoPAN_Request = FALSE; + TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); + } + break; + + case ID_IMPORT_GLABEL_BUTT: + case ID_SHEET_LABEL_BUTT: + if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + DrawStruct = SchematicGeneralLocateAndDisplay(); + + if ( DrawStruct == NULL) break; + + if( (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) && + (DrawStruct->m_Flags == 0) ) + { + if ( m_ID_current_state == ID_IMPORT_GLABEL_BUTT ) + m_CurrentScreen->m_CurrentItem = + Import_PinSheet( (DrawSheetStruct *) DrawStruct, DC); + else + m_CurrentScreen->m_CurrentItem = + Create_PinSheet( (DrawSheetStruct *) DrawStruct, DC); + } + else if( (DrawStruct->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE) && + (DrawStruct->m_Flags != 0) ) + { + DrawStruct->Place(this, DC); + TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); + } + break; + + case ID_COMPONENT_BUTT: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->m_CurrentItem = Load_Component(DC, wxEmptyString, + s_CmpNameList, TRUE); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place( this, DC); + DrawPanel->m_AutoPAN_Request = FALSE; + TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); + } + break; + + case ID_PLACE_POWER_BUTT: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->m_CurrentItem = + Load_Component(DC, wxT("power"),s_PowerNameList, FALSE); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else + { + DrawStruct->Place( this, DC); + DrawPanel->m_AutoPAN_Request = FALSE; + TestDanglingEnds(m_CurrentScreen->EEDrawList, DC); + } + break; + + default : + { + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + wxString msg( wxT("WinEDA_SchematicFrame::OnLeftClick error state ")); + msg << m_ID_current_state; + DisplayError(this, msg); + break; + } + } +} + +/***************************************************************************/ +void WinEDA_SchematicFrame::OnLeftDClick(wxDC * DC, const wxPoint& MousePos) +/***************************************************************************/ +/* Appelé sur un double click: + pour un élément editable (textes, composant): + appel de l'editeur correspondant. + pour une connexion en cours: + termine la connexion +*/ +{ +EDA_BaseStruct * DrawStruct = m_CurrentScreen->m_CurrentItem; +wxPoint pos = GetPosition(); + + switch ( m_ID_current_state ) + { + case 0: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + DrawStruct = SchematicGeneralLocateAndDisplay(); + } + + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) ) + break; + + // Element localisé + switch ( DrawStruct->m_StructType ) + { + case DRAW_SHEET_STRUCT_TYPE: + InstallNextScreen((DrawSheetStruct *) DrawStruct); + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE: + InstallCmpeditFrame(this, pos, (EDA_SchComponentStruct *) DrawStruct); + DrawPanel->MouseToCursorSchema(); + break; + + case DRAW_TEXT_STRUCT_TYPE: + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + EditSchematicText( (DrawTextStruct*)DrawStruct, DC); + break; + + case DRAW_PART_TEXT_STRUCT_TYPE: + EditCmpFieldText( (PartTextStruct *)DrawStruct, DC); + DrawPanel->MouseToCursorSchema(); + break; + + default: + break; + } + break; // end case 0 + + case ID_BUS_BUTT: + case ID_WIRE_BUTT: + case ID_LINE_COMMENT_BUTT: + if ( DrawStruct && (DrawStruct->m_Flags & IS_NEW) ) + EndSegment(DC); + break; + } +} + + diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp new file mode 100644 index 0000000000..75fbdbad7c --- /dev/null +++ b/eeschema/onrightclick.cpp @@ -0,0 +1,557 @@ + /******************************************************************/ + /* onrightclick.cpp - creation du menu popup appele par le bouton */ + /* droit de la souris */ + /******************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" +#include "common.h" + +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" +#include "id.h" + +#include "bitmaps.h" + +#include "Enter_Sheet.xpm" +#include "Leave_Sheet.xpm" +#include "Delete_Sheet.xpm" +#include "Resize_Sheet.xpm" +#include "Edit_Sheet.xpm" +#include "Move_Sheet.xpm" +#include "Options_Pinsheet.xpm" +#include "Delete_Pinsheet.xpm" +#include "Delete_Bus.xpm" +#include "Delete_Node.xpm" +#include "Delete_Connection.xpm" +#include "Label2Text.xpm" +#include "Label2GLabel.xpm" +#include "GLabel2Text.xpm" +#include "GLabel2Label.xpm" +#include "Rotate_GLabel.xpm" +#include "GL_Change.xpm" +#include "Edit_Component.xpm" +#include "Break_Line.xpm" +#include "Break_Bus.xpm" +#include "Normal.xpm" +#include "Edit_Comp_Ref.xpm" +#include "Edit_Comp_Value.xpm" + +/* functions to add commands and submenus depending on the item */ +static void AddMenusForBlock(wxMenu * PopMenu, WinEDA_SchematicFrame * frame); +static void AddMenusForWire(wxMenu * PopMenu, EDA_DrawLineStruct * Wire, + WinEDA_SchematicFrame * frame); +static void AddMenusForBus(wxMenu * PopMenu, EDA_DrawLineStruct * Bus, + WinEDA_SchematicFrame * frame); +static void AddMenusForHierchicalSheet(wxMenu * PopMenu, DrawSheetStruct * Sheet); +static void AddMenusForPinSheet(wxMenu * PopMenu, DrawSheetLabelStruct * PinSheet); +static void AddMenusForText(wxMenu * PopMenu, DrawTextStruct * Text ); +static void AddMenusForLabel(wxMenu * PopMenu, DrawLabelStruct * Label ); +static void AddMenusForGLabel(wxMenu * PopMenu, DrawGlobalLabelStruct * GLabel ); +static void AddMenusForComponent(wxMenu * PopMenu, EDA_SchComponentStruct * Component ); +static void AddMenusForComponentField(wxMenu * PopMenu, PartTextStruct * Field ); +static void AddMenusForJunction(wxMenu * PopMenu, DrawJunctionStruct * Junction, + WinEDA_SchematicFrame * frame); + + +/***********************************************************************/ +void WinEDA_SchematicFrame::ToolOnRightClick(wxCommandEvent& event) +/***********************************************************************/ +{ +int id = event.GetId(); + + switch ( id ) + { + default: + DisplayError(this, wxT("ToolOnRightClick() error")); + break; + } +} + + +/*****************************************************************/ +void WinEDA_SchematicFrame::OnRightClick(const wxPoint& MousePos, + wxMenu * PopMenu) +/*****************************************************************/ +/* Prepare le menu PullUp affiché par un click sur le bouton droit +de la souris. + Ce menu est ensuite complété par la liste des commandes de ZOOM +*/ +{ +EDA_BaseStruct *DrawStruct = m_CurrentScreen->m_CurrentItem; +bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE); + + + DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu + + // Simple localisation des elements si possible + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + DrawStruct = SchematicGeneralLocateAndDisplay(FALSE); + if ( DrawStruct && (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) ) + { + DrawSheetLabelStruct * slabel; + slabel = LocateSheetLabel( (DrawSheetStruct *)DrawStruct, + m_CurrentScreen->m_Curseur); + if ( slabel ) DrawStruct = slabel; + } + } + + // If Command in progress: put the menu "cancel" and "end tool" + if ( m_ID_current_state ) + { + if ( DrawStruct && DrawStruct->m_Flags ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _("Cancel"), cancel_xpm); + } + else + { + ADD_MENUITEM(PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL, _("End Tool"), cancel_tool_xpm); + } + PopMenu->AppendSeparator(); + } + + else + { + if ( (DrawStruct && DrawStruct->m_Flags) || BlockActive ) + { + if ( BlockActive ) AddMenusForBlock( PopMenu, this); + else ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _("Cancel"), cancel_xpm); + PopMenu->AppendSeparator(); + } + } + + if ( BlockActive ) return; + if ( DrawStruct == NULL ) + { + if ( m_CurrentScreen != ScreenSch ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_LEAVE_SHEET, _("Leave Sheet") , leave_sheet_xpm); + PopMenu->AppendSeparator(); + } + return; + } + + m_CurrentScreen->m_CurrentItem = DrawStruct; + +int flags = DrawStruct->m_Flags; +bool is_new = (flags & IS_NEW) ? TRUE : FALSE; + + switch ( DrawStruct->m_StructType ) + { + case DRAW_NOCONNECT_STRUCT_TYPE: +// if( !flags ) PopMenu->Append(ID_POPUP_SCH_MOVE_ITEM_REQUEST, "Move noconnect"); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("delete noconn"), delete_xpm); + break; + + case DRAW_JUNCTION_STRUCT_TYPE: + AddMenusForJunction(PopMenu, (DrawJunctionStruct *)DrawStruct, this); + break; + + case DRAW_BUSENTRY_STRUCT_TYPE: + if( !flags ) + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, + _("Move bus entry"), move_xpm); + if( GetBusEntryShape((DrawBusEntryStruct *)DrawStruct) == '\\') + PopMenu->Append(ID_POPUP_SCH_ENTRY_SELECT_SLASH, _("set bus entry /")); + else PopMenu->Append(ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH, _("set bus entry \\")); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, + _("delete bus entry"), delete_bus_xpm); + break; + + case DRAW_MARKER_STRUCT_TYPE: + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("delete Marker"), delete_xpm); + break; + + case DRAW_TEXT_STRUCT_TYPE: + AddMenusForText( PopMenu, (DrawTextStruct *) DrawStruct); + break; + + case DRAW_LABEL_STRUCT_TYPE: + AddMenusForLabel( PopMenu, (DrawLabelStruct *) DrawStruct); + break; + + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + AddMenusForGLabel(PopMenu, (DrawGlobalLabelStruct *) DrawStruct ); + break; + + case DRAW_PART_TEXT_STRUCT_TYPE: + { + AddMenusForComponentField(PopMenu, (PartTextStruct *) DrawStruct ); + if ( flags) break; + // Many fields are inside a component. If this is the case, add the component menu + EDA_SchComponentStruct * Component = LocateSmallestComponent( GetScreen() ); + if ( Component ) + { + PopMenu->AppendSeparator(); + AddMenusForComponent(PopMenu, (EDA_SchComponentStruct *) DrawStruct ); + } + } + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE: + AddMenusForComponent(PopMenu, (EDA_SchComponentStruct *) DrawStruct ); + break; + + case DRAW_SEGMENT_STRUCT_TYPE: +// if( !flags ) PopMenu->Append(ID_POPUP_SCH_MOVE_ITEM_REQUEST, "Move"); + switch ( ((EDA_DrawLineStruct*)DrawStruct)->m_Layer) + { + case LAYER_WIRE: + AddMenusForWire(PopMenu, (EDA_DrawLineStruct*)DrawStruct, this); + break; + + case LAYER_BUS: + AddMenusForBus(PopMenu, (EDA_DrawLineStruct*)DrawStruct, this); + break; + + default: + if ( is_new ) + ADD_MENUITEM(PopMenu, ID_POPUP_END_LINE, _("End drawing"), apply_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, + _("Delete drawing"), delete_xpm); + break; + } + break; + + case DRAW_SHEET_STRUCT_TYPE: + AddMenusForHierchicalSheet(PopMenu, (DrawSheetStruct *) DrawStruct); + break; + + case DRAW_SHEETLABEL_STRUCT_TYPE: + AddMenusForPinSheet(PopMenu, (DrawSheetLabelStruct *) DrawStruct); + break; + + default: + wxString msg; + msg.Printf( + wxT("WinEDA_SchematicFrame::OnRightClick Error: unknown DrawType %d"), + DrawStruct->m_StructType); + DisplayError(this, msg ); + break; + } + + PopMenu->AppendSeparator(); +} + + +/*************************************************************************/ +void AddMenusForComponentField(wxMenu * PopMenu, PartTextStruct * Field ) +/*************************************************************************/ +/* Add menu commands for a component field (like value, reference) +*/ +{ + if( ! Field->m_Flags ) + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _("Move Field"), move_text_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ROTATE_FIELD, _("Rotate Field"), rotate_field_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_FIELD, _("Edit Field"), edit_text_xpm); +} + +/**************************************************************************/ +void AddMenusForComponent(wxMenu * PopMenu, EDA_SchComponentStruct * Component ) +/**************************************************************************/ +/* Add menu commands for a component +*/ +{ +EDA_LibComponentStruct * LibEntry; + + LibEntry = FindLibPart(Component->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + + if( ! Component->m_Flags ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_CMP_REQUEST, + _("Move Component (M)"), move_xpm); + } + // add menu orient et sous menu: + wxMenu *orientmenu = new wxMenu; + ADD_MENUITEM(orientmenu, ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE, + _("Rotate + (R)"), rotate_pos_xpm); + ADD_MENUITEM(orientmenu, ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE, _("Rotate -"), rotate_neg_xpm); + ADD_MENUITEM(orientmenu, ID_POPUP_SCH_MIROR_X_CMP, _("Mirror -- (X)"), mirror_V_xpm); + ADD_MENUITEM(orientmenu, ID_POPUP_SCH_MIROR_Y_CMP, _("Mirror || (Y)"), mirror_H_xpm); + ADD_MENUITEM(orientmenu, ID_POPUP_SCH_ORIENT_NORMAL_CMP, _("Normal (N)"), normal_xpm); + ADD_MENUITEM_WITH_SUBMENU(PopMenu, orientmenu, + ID_POPUP_SCH_GENERIC_ORIENT_CMP, _("Orient Component"), orient_xpm); + + wxMenu *editmenu = new wxMenu; + ADD_MENUITEM(editmenu, ID_POPUP_SCH_EDIT_CMP, _("Edit"), edit_component_xpm); + + if ( LibEntry && LibEntry->m_Options != ENTRY_POWER ) + { + ADD_MENUITEM(editmenu, ID_POPUP_SCH_EDIT_VALUE_CMP, _("Value"), edit_comp_value_xpm); + ADD_MENUITEM(editmenu, ID_POPUP_SCH_EDIT_REF_CMP, _("Reference"), edit_comp_ref_xpm); + } + if( LibEntry && (LookForConvertPart(LibEntry) >= 2) ) + editmenu->Append(ID_POPUP_SCH_EDIT_CONVERT_CMP, _("Convert")); + if( LibEntry && (LibEntry->m_UnitCount >= 2) ) + { + wxMenu *sel_unit_menu = new wxMenu; int ii; + for( ii = 0; ii < LibEntry->m_UnitCount; ii++ ) + { + wxString num_unit; num_unit.Printf( _("Unit %d %c"), ii+1, "?ABCDEFGHIJKLMNOPQRSTUVWXYZ"[ii+1]); + sel_unit_menu->Append(ID_POPUP_SCH_SELECT_UNIT1 + ii, + num_unit); + } + editmenu->Append(ID_POPUP_SCH_SELECT_UNIT_CMP, _("Unit"), sel_unit_menu); + } + + ADD_MENUITEM_WITH_SUBMENU(PopMenu, editmenu, + ID_POPUP_SCH_GENERIC_EDIT_CMP, _("Edit Component"), edit_component_xpm); + + if( ! Component->m_Flags ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_COPY_COMPONENT_CMP, _("Copy Component"), import_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE_CMP, _("Delete Component"), delete_xpm); + } + + LibEntry = FindLibPart(Component->m_ChipName.GetData(), wxEmptyString, FIND_ALIAS); + if ( LibEntry && ! LibEntry->m_DocFile.IsEmpty() ) + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DISPLAYDOC_CMP, _("Doc"), datasheet_xpm); +} + + + +/*******************************************************************/ +void AddMenusForGLabel(wxMenu * PopMenu, DrawGlobalLabelStruct * GLabel ) +/*******************************************************************/ +/* Add menu commands for a Global Label +*/ +{ +wxMenu * menu_change_type = new wxMenu; + if( ! GLabel->m_Flags ) + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _("Move Glabel"), move_text_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _("Rotate GLabel (R)"), rotate_glabel_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_TEXT, _("Edit GLabel"), edit_text_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete Glabel"), delete_text_xpm); + + // add menu change type text (to label, glabel, text): + ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL, + _("Change to Label"), glabel2label_xpm); + ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT, + _("Change to Text"), glabel2text_xpm); + ADD_MENUITEM_WITH_SUBMENU(PopMenu, menu_change_type, + ID_POPUP_SCH_CHANGE_TYPE_TEXT, _("Change Type"), gl_change_xpm); +} + +/*****************************************************************/ +void AddMenusForLabel(wxMenu * PopMenu, DrawLabelStruct * Label ) +/*****************************************************************/ +/* Add menu commands for a Label +*/ +{ +wxMenu * menu_change_type = new wxMenu; + + if( ! Label->m_Flags ) + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _("Move Label"), move_text_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _("Rotate Label (R)"), rotate_pos_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_TEXT, _("Edit Label"), edit_text_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete Label"), delete_text_xpm); + + // add menu change type text (to label, glabel, text): + ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL, + _("Change to Glabel"), label2glabel_xpm); + ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT, + _("Change to Text"), label2text_xpm); + ADD_MENUITEM_WITH_SUBMENU(PopMenu, menu_change_type, + ID_POPUP_SCH_CHANGE_TYPE_TEXT, _("Change Type"), gl_change_xpm); +} + +/*****************************************************************/ +void AddMenusForText(wxMenu * PopMenu, DrawTextStruct * Text ) +/*****************************************************************/ +/* Add menu commands for a Text (a comment) +*/ +{ +wxMenu * menu_change_type = new wxMenu; + + if( ! Text->m_Flags ) + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _("Move Text"), move_text_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _("Rotate Text (R)"), rotate_pos_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_TEXT, _("Edit Text"), edit_text_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete Text"), delete_text_xpm); + + // add menu change type text (to label, glabel, text): + ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL, + _("Change to Label"), label2text_xpm); + ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL, + _("Change to Glabel"), label2glabel_xpm); + ADD_MENUITEM_WITH_SUBMENU(PopMenu, menu_change_type, + ID_POPUP_SCH_CHANGE_TYPE_TEXT, _("Change Type"), gl_change_xpm); +} + + + +/*****************************************************************/ +void AddMenusForJunction(wxMenu * PopMenu, DrawJunctionStruct * Junction, + WinEDA_SchematicFrame * frame) +/*****************************************************************/ +/* Add menu commands for a junction +*/ +{ +bool is_new = (Junction->m_Flags & IS_NEW) ? TRUE : FALSE; + if ( ! is_new ) + { + if ( PickStruct(frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList, + WIREITEM|BUSITEM|EXCLUDE_WIRE_BUS_ENDPOINTS) ) + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_BREAK_WIRE, _("Break Wire"), break_line_xpm); + } + + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("delete junction"), delete_xpm); + + if ( PickStruct(frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList, + WIREITEM|BUSITEM) ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE_NODE, _("Delete node"), delete_node_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _("Delete connection"), delete_connection_xpm); + } +} + +/*****************************************************************/ +void AddMenusForWire(wxMenu * PopMenu, EDA_DrawLineStruct * Wire, + WinEDA_SchematicFrame * frame) +/*****************************************************************/ +/* Add menu commands for a wire +*/ +{ +bool is_new = (Wire->m_Flags & IS_NEW) ? TRUE : FALSE; +wxPoint pos = frame->GetScreen()->m_Curseur; + + if ( is_new ) + ADD_MENUITEM(PopMenu, ID_POPUP_END_LINE, _("End Wire"), apply_xpm); + + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete Wire"), delete_xpm); + + if ( is_new ) return; + + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE_NODE, _("Delete node"), delete_node_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _("Delete connection"), delete_connection_xpm); + + if ( PickStruct(frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList, + WIREITEM|BUSITEM|EXCLUDE_WIRE_BUS_ENDPOINTS) ) + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_BREAK_WIRE, _("Break Wire"), break_line_xpm); + + PopMenu->AppendSeparator(); + + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _("Add junction") , add_junction_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_LABEL, _("Add label") , add_line_label_xpm); + + // Place Global label command only if the cursor is over one end of the Wire: + if ( ( pos.x == Wire->m_Start.x && pos.y == Wire->m_Start.y) || + ( pos.x == Wire->m_End.x && pos.y == Wire->m_End.y ) ) + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_GLABEL, _("Add global label") , add_glabel_xpm); +} + +/*****************************************************************/ +void AddMenusForBus(wxMenu * PopMenu, EDA_DrawLineStruct * Bus, + WinEDA_SchematicFrame * frame) +/*****************************************************************/ +/* Add menu commands for a Bus +*/ +{ +bool is_new = (Bus->m_Flags & IS_NEW) ? TRUE : FALSE; +wxPoint pos = frame->GetScreen()->m_Curseur; + + if ( is_new ) ADD_MENUITEM(PopMenu, ID_POPUP_END_LINE, _("End Bus"), apply_xpm); + + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, + _("Delete Bus"), delete_bus_xpm); + + if ( ! is_new ) + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_BREAK_WIRE, + _("Break Bus"), break_bus_xpm); + + PopMenu->AppendSeparator(); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _("Add junction") , add_junction_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_LABEL, _("Add label") , add_line_label_xpm); + // Place Global label command only if the cursor is over one end of the Bus: + if ( ( pos.x == Bus->m_Start.x && pos.y == Bus->m_Start.y) || + ( pos.x == Bus->m_End.x && pos.y == Bus->m_End.y ) ) + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_GLABEL, _("Add global label") , add_glabel_xpm); +} + +/************************************************************************/ +void AddMenusForHierchicalSheet(wxMenu * PopMenu, DrawSheetStruct * Sheet) +/************************************************************************/ +/* Add menu commands for a Sheet +*/ +{ + if( ! Sheet->m_Flags ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ENTER_SHEET, _("Enter Sheet"), enter_sheet_xpm); + PopMenu->AppendSeparator(); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _("Move Sheet"), move_sheet_xpm); + } + + if ( Sheet->m_Flags ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_END_SHEET, _("Place Sheet"), apply_xpm); + } + else + { + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_SHEET, _("Edit Sheet"), edit_sheet_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_RESIZE_SHEET, _("Resize Sheet"), resize_sheet_xpm); + if ( Sheet->m_Label ) // Sheet has pin labels, and can be cleaned + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_CLEANUP_SHEET, + _("Cleanup PinSheets"), options_pinsheet_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete Sheet"), delete_sheet_xpm); + } +} + + +/************************************************************************/ +void AddMenusForPinSheet(wxMenu * PopMenu, DrawSheetLabelStruct * PinSheet) +/************************************************************************/ +/* Add menu commands for a Pin Sheet (or Sheet label) +*/ +{ + if( ! PinSheet->m_Flags ) + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_PINSHEET, _("Move PinSheet"), move_xpm); + + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_PINSHEET, _("Edit PinSheet"), edit_xpm); + + if( ! PinSheet->m_Flags ) + ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete PinSheet"), delete_pinsheet_xpm); +} + +/**********************************************************************/ +void AddMenusForBlock(wxMenu * PopMenu, WinEDA_SchematicFrame * frame) +/**********************************************************************/ +/* Add menu commands for block +*/ +{ + ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _("Cancel Block"), cancel_xpm); + + PopMenu->AppendSeparator(); + + if ( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) + ADD_MENUITEM(PopMenu, ID_POPUP_ZOOM_BLOCK, + _("Win. Zoom (Midd butt drag mouse)"), zoom_selected_xpm); + + ADD_MENUITEM(PopMenu, ID_POPUP_PLACE_BLOCK, _("Place Block"), apply_xpm ); + + if ( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) + { + wxMenu * menu_other_block_commands = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU(PopMenu, menu_other_block_commands, + -1, _("Other block commands"), right_xpm); + ADD_MENUITEM(menu_other_block_commands, wxID_COPY, _("Save Block"), copy_button); + ADD_MENUITEM(menu_other_block_commands, ID_POPUP_COPY_BLOCK, + _("Copy Block (shift + drag mouse)"), copyblock_xpm); + ADD_MENUITEM(menu_other_block_commands, ID_POPUP_DRAG_BLOCK, _("Drag Block (ctrl + drag mouse)"), move_xpm ); + ADD_MENUITEM(menu_other_block_commands, ID_POPUP_DELETE_BLOCK, + _("Del. Block (shift+ctrl + drag mouse)"), delete_xpm ); + ADD_MENUITEM(menu_other_block_commands, ID_POPUP_MIRROR_Y_BLOCK, _("Mirror Block ||"), mirror_H_xpm); +#if 0 + #ifdef __WINDOWS__ + ADD_MENUITEM(menu_other_block_commands, ID_GEN_COPY_BLOCK_TO_CLIPBOARD, + _("Copy to Clipboard"), copy_button); + #endif +#endif + } +} diff --git a/eeschema/options.cpp b/eeschema/options.cpp new file mode 100644 index 0000000000..1efbf70164 --- /dev/null +++ b/eeschema/options.cpp @@ -0,0 +1,285 @@ + /*************************/ + /* eeschema: options.cpp */ + /*************************/ + +/* +Gestion de la fenetre des options generales: + Grille + Unites d'affichage + options complementaires (increments X, Y et label pour la fct de repetition +*/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "id.h" +#include "wx/spinctrl.h" + +#include "protos.h" + + +/* Variables locales */ + +/* Fonctions locales: */ + +enum options_id { + ID_OPTION_ACCEPT = 3900, + ID_OPTION_CANCEL, + ID_GRID_SIZE, + ID_SHOW_GRID, + ID_GRID_NORMAL, + ID_GRID_SMALL, + ID_GRID_VERY_SMALL, + + ID_SEL_SHOW_PINS, + ID_SEL_HV_WIRE, + ID_SEL_SHOW_PAGE_LIMITS, + ID_SEL_METRIC +}; + +/*************************************************************/ +/* classe derivee pour la frame de Configuration des options*/ +/*************************************************************/ + +class WinEDA_SetOptionsFrame: public wxDialog +{ +private: + WinEDA_DrawFrame * m_Parent; + wxCheckBox * m_ShowGridButt; + wxCheckBox * m_AutoPANOpt; + wxRadioBox * m_SelGridSize; + wxRadioBox * m_SelShowPins; + wxRadioBox * m_Selunits; + wxRadioBox * m_SelDirWires; + wxRadioBox * m_Show_Page_Limits; + WinEDA_SizeCtrl * m_DeltaStepCtrl; + wxSpinCtrl * m_DeltaLabelCtrl; + +public: + + // Constructor and destructor + WinEDA_SetOptionsFrame(WinEDA_DrawFrame *parent, const wxPoint& framepos); + ~WinEDA_SetOptionsFrame(void) {}; + +private: + void Accept(wxCommandEvent& event); + void OnCancel(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() + +}; +/* Table des evenements pour WinEDA_SetOptionsFrame */ +BEGIN_EVENT_TABLE(WinEDA_SetOptionsFrame, wxDialog) + EVT_BUTTON(ID_OPTION_ACCEPT, WinEDA_SetOptionsFrame::Accept) + EVT_BUTTON(ID_OPTION_CANCEL, WinEDA_SetOptionsFrame::OnCancel) +END_EVENT_TABLE() + +/**************************************************************************/ +void DisplayOptionFrame(WinEDA_DrawFrame * parent, const wxPoint & framepos) +/**************************************************************************/ +{ + WinEDA_SetOptionsFrame * frame = + new WinEDA_SetOptionsFrame(parent, framepos); + frame->ShowModal(); frame->Destroy(); +} + + + +/***********************************************************************/ +WinEDA_SetOptionsFrame::WinEDA_SetOptionsFrame(WinEDA_DrawFrame *parent, + const wxPoint& framepos): + wxDialog(parent, -1, _("EESchema Preferences"), framepos, + wxSize(450, 340), DIALOG_STYLE) +/***********************************************************************/ +{ +#define START_Y 10 +wxButton * Button; +wxPoint pos; +wxSize size; +int w, h; + + m_Parent = parent; + SetFont(*g_DialogFont); + + pos.x = 330; pos.y = START_Y; + Button = new wxButton(this, ID_OPTION_ACCEPT, _("OK"), pos); + Button->SetForegroundColour(*wxRED); + + pos.y += Button->GetDefaultSize().y + 5; + Button = new wxButton(this, ID_OPTION_CANCEL, _("Cancel"), pos); + Button->SetForegroundColour(*wxBLUE); + + + pos.x = 5; pos.y = START_Y; + m_ShowGridButt = new wxCheckBox( this, ID_SHOW_GRID, _("Show grid"), + pos); + m_ShowGridButt->SetValue(m_Parent->m_Draw_Grid); + + pos.x += 150; + m_AutoPANOpt = new wxCheckBox( this, ID_SHOW_GRID, _("Auto PAN"), + pos); + m_AutoPANOpt->SetValue(m_Parent->DrawPanel-> m_AutoPAN_Enable); + m_AutoPANOpt->SetForegroundColour(*wxBLUE); + + pos.x = 5; pos.y += 25; +wxString grid_choice[6] = { _("Normal (50 mils)"), + _("Small (25 mils)"), + _("Very small (10 mils)"), + _("Special (5 mils)"), + _("Special (2 mils)"), + _("Special (1 mil)"), }; + + m_SelGridSize = new wxRadioBox(this, ID_GRID_SIZE, + _("Grid Size"), pos, + wxDefaultSize, 6, grid_choice, 1, wxRA_SPECIFY_COLS); + if ( m_Parent->GetScreen() ) + { + switch( m_Parent->GetScreen()->GetGrid().x ) + { + case 50: + m_SelGridSize->SetSelection(0); + break; + + case 25: + m_SelGridSize->SetSelection(1); + break; + + case 10: + m_SelGridSize->SetSelection(2); + break; + + case 5: + m_SelGridSize->SetSelection(3); + break; + + case 2: + m_SelGridSize->SetSelection(4); + break; + + case 1: + m_SelGridSize->SetSelection(5); + break; + + default: + DisplayError(this, wxT("WinEDA_SetOptionsFrame: Grid value not handle")); + break; + } + } + + /* Choix d' l'affichage des pins invisibles */ + m_SelGridSize->GetSize(&w, &h); + pos.y += h + 20; +wxString pin_choice[2] = { _("Normal"), _("Show alls") }; + m_SelShowPins = new wxRadioBox(this, ID_SEL_SHOW_PINS, + _("Show pins"), pos, + wxDefaultSize, 2, pin_choice, 1, wxRA_SPECIFY_COLS); + m_SelShowPins->SetSelection( g_ShowAllPins ? TRUE : FALSE); + + /* Choix de l'affichage des unites */ + pos.x = 15 + w; pos.y = START_Y + 25; +wxString unit_choice[2] = { _("millimeters"), _("inches") }; + m_Selunits = new wxRadioBox(this, ID_SEL_METRIC, + _("Units"), pos, + wxDefaultSize, 2, unit_choice, 1, wxRA_SPECIFY_COLS); + m_Selunits->SetSelection( UnitMetric ? 0 : 1); + + /* Choix de l'orientation des bus et wires */ + m_Selunits->GetSize(&w, &h); + pos.y += h + 15; +wxString dir_choice[2] = { _("Horiz/Vertical"), _("Any") }; + m_SelDirWires = new wxRadioBox(this, ID_SEL_HV_WIRE, + _("Wires - Bus orient"), pos, + wxDefaultSize, 2, dir_choice, 1, wxRA_SPECIFY_COLS); + m_SelDirWires->SetSelection( g_HVLines ? 0 : 1); + + m_SelDirWires->GetSize(&w, &h); + pos.y += h + 15; +wxString show_page_limits_choice[2] = { _("Yes"), _("No") }; + m_Show_Page_Limits = new wxRadioBox(this, ID_SEL_SHOW_PAGE_LIMITS, + _("Show page limits"), pos, + wxDefaultSize, 2, show_page_limits_choice, 1, wxRA_SPECIFY_COLS); + m_Show_Page_Limits->SetSelection( g_ShowPageLimits ? 0 : 1); + + /* Choix des parametres pour la fonction de repetition */ + size.x = 100; size.y = -1; + pos.y = 90; pos.x = 320; + m_DeltaStepCtrl = new WinEDA_SizeCtrl(this, _("Delta Step"), + g_RepeatStep, + UnitMetric, pos, m_Parent->m_InternalUnits); + + pos.y += 10 + m_DeltaStepCtrl->GetDimension().y; + new wxStaticText(this, -1, _("Delta Label:"), + wxPoint(pos.x, pos.y ), + wxSize(-1,-1), 0 ); +wxString val; + pos.y += 14; + val << g_RepeatDeltaLabel; + m_DeltaLabelCtrl = new wxSpinCtrl(this, -1, val, pos); + m_DeltaLabelCtrl->SetRange(-16, +16); +} + +/**************************************************************************/ +void WinEDA_SetOptionsFrame::OnCancel(wxCommandEvent& event) +/**************************************************************************/ +{ + Close(TRUE); +} +/**************************************************************************/ +void WinEDA_SetOptionsFrame::Accept(wxCommandEvent& event) +/**************************************************************************/ +{ +wxSize grid; +bool setgrid = TRUE; + + g_RepeatStep = m_DeltaStepCtrl->GetCoord(); + + g_RepeatDeltaLabel = m_DeltaLabelCtrl->GetValue(); + + if ( m_Show_Page_Limits->GetSelection() == 0 ) g_ShowPageLimits = TRUE; + else g_ShowPageLimits = FALSE; + + if ( m_SelDirWires->GetSelection() == 0 ) g_HVLines = 1; + else g_HVLines = 0; + + if ( m_Selunits->GetSelection() == 0 ) UnitMetric = 1; + else UnitMetric = 0; + + if ( m_SelShowPins->GetSelection() == 0 ) g_ShowAllPins = FALSE; + else g_ShowAllPins = TRUE; + + g_ShowGrid = m_Parent->m_Draw_Grid = m_ShowGridButt->GetValue(); + m_Parent->DrawPanel->m_AutoPAN_Enable = m_AutoPANOpt->GetValue(); + + switch( m_SelGridSize->GetSelection() ) + { + default: + setgrid = FALSE; + break; + + case 0: + grid = wxSize(50,50); + break; + case 1: + grid = wxSize(25,25); + break; + + case 2: + grid = wxSize(10,10); + break; + } + + if ( m_Parent->m_CurrentScreen ) + { + if ( setgrid ) m_Parent->m_CurrentScreen->SetGrid(grid); + m_Parent->m_CurrentScreen->SetRefreshReq(); + } + + Close(TRUE); +} + + diff --git a/eeschema/optionsframe.cpp b/eeschema/optionsframe.cpp new file mode 100644 index 0000000000..2d49c739d7 --- /dev/null +++ b/eeschema/optionsframe.cpp @@ -0,0 +1,172 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: optionsframe.cpp +// Purpose: +// Author: jean-pierre charras +// Modified by: +// Created: 01/27/04 14:48:57 +// RCS-ID: +// Copyright: suite kicad +// Licence: +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "optionsframe.cpp" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +////@begin includes +#include "wx/wx.h" +#include "wx/valgen.h" +////@end includes + +#include "optionsframe.h" + +////@begin XPM images +////@end XPM images + +/*! + * DisplayOptionFrame type definition + */ + +IMPLEMENT_CLASS( DisplayOptionFrame, wxDialog ) + +/*! + * DisplayOptionFrame event table definition + */ + +BEGIN_EVENT_TABLE( DisplayOptionFrame, wxDialog ) + +////@begin DisplayOptionFrame event table entries +////@end DisplayOptionFrame event table entries + +END_EVENT_TABLE() + +/*! + * DisplayOptionFrame constructors + */ + +DisplayOptionFrame::DisplayOptionFrame( ) +{ +} + +DisplayOptionFrame::DisplayOptionFrame( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + Create(parent, id, caption, pos, size, style); +} + +/*! + * optionsframe creator + */ + +bool DisplayOptionFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin DisplayOptionFrame member initialisation +////@end DisplayOptionFrame member initialisation + +////@begin DisplayOptionFrame creation + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end DisplayOptionFrame creation + return TRUE; +} + +/*! + * Control creation for optionsframe + */ + +void DisplayOptionFrame::CreateControls() +{ +////@begin DisplayOptionFrame content construction + + DisplayOptionFrame* item1 = this; + + wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL); + item1->SetSizer(item2); + item1->SetAutoLayout(TRUE); + + wxBoxSizer* item3 = new wxBoxSizer(wxHORIZONTAL); + item2->Add(item3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* item4 = new wxBoxSizer(wxHORIZONTAL); + item3->Add(item4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* item5 = new wxBoxSizer(wxVERTICAL); + item4->Add(item5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxCheckBox* item6 = new wxCheckBox( item1, ID_CHECKBOX, _("Show grid"), wxDefaultPosition, wxDefaultSize, 0 ); + m_ShowGridButt = item6; + item6->SetValue(FALSE); + item5->Add(item6, 0, wxALIGN_LEFT|wxALL, 5); + + wxString item7Strings[] = { + _("&Normal (50 mils)"), + _("&Small (20 mils)"), + _("&Very small (10 mils)") + }; + wxRadioBox* item7 = new wxRadioBox( item1, ID_RADIOBOX, _("Grid Size"), wxDefaultPosition, wxDefaultSize, 3, item7Strings, 1, 0 ); + m_SelGridSize = item7; + item5->Add(item7, 0, wxALIGN_LEFT|wxALL, 5); + + wxString item8Strings[] = { + _("&Normal"), + _("&inches") + }; + wxRadioBox* item8 = new wxRadioBox( item1, ID_RADIOBOX1, _("Show pins"), wxDefaultPosition, wxDefaultSize, 2, item8Strings, 1, 0 ); + m_SelShowPins = item8; + item5->Add(item8, 0, wxALIGN_LEFT|wxALL, 5); + + wxBoxSizer* item9 = new wxBoxSizer(wxVERTICAL); + item4->Add(item9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxString item10Strings[] = { + _("&millimeters"), + _("&inches") + }; + wxRadioBox* item10 = new wxRadioBox( item1, ID_RADIOBOX3, _("Units"), wxDefaultPosition, wxDefaultSize, 2, item10Strings, 1, wxRA_SPECIFY_COLS ); + m_Selunits = item10; + item9->Add(item10, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + item9->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxString item12Strings[] = { + _("&Horiz/Vertical"), + _("&Any") + }; + wxRadioBox* item12 = new wxRadioBox( item1, ID_RADIOBOX2, _("Wire - Bus orient"), wxDefaultPosition, wxDefaultSize, 2, item12Strings, 1, wxRA_SPECIFY_COLS ); + item9->Add(item12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* item13 = new wxBoxSizer(wxVERTICAL); + item4->Add(item13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* item14 = new wxButton( item1, ID_BUTTON, _("OK"), wxDefaultPosition, wxDefaultSize, 0 ); + item14->SetForegroundColour(wxColour(255, 0, 0)); + item13->Add(item14, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxButton* item15 = new wxButton( item1, ID_BUTTON1, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + item15->SetForegroundColour(wxColour(0, 0, 255)); + item13->Add(item15, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + + // Set validators + item6->SetValidator( wxGenericValidator(& ShowGrid ) ); +////@end DisplayOptionFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool DisplayOptionFrame::ShowToolTips() +{ + return TRUE; +} diff --git a/eeschema/optionsframe.h b/eeschema/optionsframe.h new file mode 100644 index 0000000000..5233359727 --- /dev/null +++ b/eeschema/optionsframe.h @@ -0,0 +1,89 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: optionsframe.h +// Purpose: +// Author: jean-pierre charras +// Modified by: +// Created: 01/27/04 14:48:57 +// RCS-ID: +// Copyright: suite kicad +// Licence: +///////////////////////////////////////////////////////////////////////////// + +#ifndef _OPTIONSFRAME_H_ +#define _OPTIONSFRAME_H_ + +#ifdef __GNUG__ +#pragma interface "optionsframe.h" +#endif + +/*! + * Includes + */ + +////@begin includes +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define ID_CHECKBOX 10001 +#define ID_RADIOBOX 10002 +#define ID_RADIOBOX1 10003 +#define ID_RADIOBOX3 10005 +#define ID_RADIOBOX2 10004 +#define ID_BUTTON 10006 +#define ID_BUTTON1 10007 +////@end control identifiers + +/*! + * DisplayOptionFrame class declaration + */ + +class DisplayOptionFrame: public wxDialog +{ + DECLARE_CLASS( DisplayOptionFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + DisplayOptionFrame( ); + DisplayOptionFrame( wxWindow* parent, wxWindowID id = -1, const wxString& caption = _("optionsframe"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = -1, const wxString& caption = _("optionsframe"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin DisplayOptionFrame event handler declarations + +////@end DisplayOptionFrame event handler declarations + +////@begin DisplayOptionFrame member function declarations + +////@end DisplayOptionFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + +////@begin DisplayOptionFrame member variables + wxCheckBox* m_ShowGridButt; + wxRadioBox* m_SelGridSize; + wxRadioBox* m_SelShowPins; + wxRadioBox* m_Selunits; + WinEDA_DrawFrame * m_Parent; +////@end DisplayOptionFrame member variables +}; + +#endif + // _OPTIONSFRAME_H_ diff --git a/eeschema/pinedit-dialog.cpp b/eeschema/pinedit-dialog.cpp new file mode 100644 index 0000000000..16f32b0be0 --- /dev/null +++ b/eeschema/pinedit-dialog.cpp @@ -0,0 +1,392 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pinedit-dialog.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 11/02/2006 13:30:59 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 11/02/2006 13:30:59 + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes + +#include "pinedit-dialog.h" + +////@begin XPM images +////@end XPM images + +/*****************************************************************************************/ +void InstallPineditFrame(WinEDA_LibeditFrame * parent, wxDC * DC, const wxPoint & pos) +/*****************************************************************************************/ +{ +wxPoint MousePos = parent->GetScreen()->m_Curseur; +int accept = TRUE; + if ( (CurrentDrawItem == NULL) || (CurrentDrawItem->m_StructType == COMPONENT_PIN_DRAW_TYPE) ) + { + LibDrawPin * Pin = (LibDrawPin *) CurrentDrawItem; + WinEDA_PinPropertiesFrame * frame = new WinEDA_PinPropertiesFrame(parent); + accept = frame->ShowModal(); frame->Destroy(); + if ( !accept && Pin && ( Pin->m_Flags & IS_NEW ) ) // Abord create new pin + { + if ( parent->DrawPanel->ForceCloseManageCurseur && DC) + parent->DrawPanel->ForceCloseManageCurseur(parent->DrawPanel, DC); + } + } + else DisplayError(parent, wxT("Error: Not a Pin!") ); + parent->GetScreen()->m_Curseur = MousePos; + parent->DrawPanel->MouseToCursorSchema(); +} + +/*! + * WinEDA_PinPropertiesFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_PinPropertiesFrame, wxDialog ) + +/*! + * WinEDA_PinPropertiesFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_PinPropertiesFrame, wxDialog ) + +////@begin WinEDA_PinPropertiesFrame event table entries + EVT_BUTTON( wxID_OK, WinEDA_PinPropertiesFrame::OnOkClick ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_PinPropertiesFrame::OnCancelClick ) + +////@end WinEDA_PinPropertiesFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_PinPropertiesFrame constructors + */ + +WinEDA_PinPropertiesFrame::WinEDA_PinPropertiesFrame( ) +{ +} + +WinEDA_PinPropertiesFrame::WinEDA_PinPropertiesFrame( WinEDA_LibeditFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +wxString number; +LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem; +wxString msg, StringPinNum; +int tmp, ii; + + m_Parent = parent; + if ( CurrentPin ) + { + CurrentPin->ReturnPinStringNum(StringPinNum); + m_Parent->InitEditOnePin(); + } + Create(parent, id, caption, pos, size, style); + + /* Init dialog pin name and pin name size values */ + if ( CurrentPin ) msg = CurrentPin->m_PinName; + else msg = wxEmptyString; + m_PinNameCtrl->SetValue(msg); + tmp = CurrentPin ? CurrentPin->m_SizeName : LastPinNameSize; + msg = ReturnStringFromValue(g_UnitMetric, tmp, m_Parent->m_InternalUnits); + m_PinNameSizeCtrl->SetValue(msg); + msg = m_PinNameSizeText->GetLabel() + ReturnUnitSymbol(); + m_PinNameSizeText->SetLabel(msg); + /* Init dialog pin num and pin num size values */ + m_PinNumCtrl->SetValue(StringPinNum); + tmp = CurrentPin ? CurrentPin->m_SizeNum : LastPinNumSize; + msg = ReturnStringFromValue(g_UnitMetric, tmp, m_Parent->m_InternalUnits); + m_PinNumSizeCtrl->SetValue(msg); + msg = m_PinNumSizeText->GetLabel() + ReturnUnitSymbol(); + m_PinNumSizeText->SetLabel(msg); + /* init dialog pin size */ + int pinsize = CurrentPin ? CurrentPin->m_PinLen : LastPinSize; + m_PinSize->SetValue(pinsize); + /* init pin options */ + if ( CurrentPin ) + { + if ( CurrentPin->m_Unit == 0 ) m_CommonUnit->SetValue(TRUE); + } + else m_CommonUnit->SetValue(LastPinCommonUnit); + if ( CurrentPin ) + { + if ( CurrentPin->m_Convert == 0 ) m_CommonConvert->SetValue(TRUE); + } + else m_CommonConvert->SetValue(LastPinCommonConvert); + if ( CurrentPin ) + { + if ( CurrentPin->m_Attributs & PINNOTDRAW ) m_NoDraw->SetValue(TRUE); + } + else m_NoDraw->SetValue(LastPinNoDraw); + + tmp = CurrentPin ? CurrentPin->m_Orient : LastPinOrient; + switch ( tmp ) + { + case PIN_RIGHT: + m_PinOrient->SetSelection(0); + break; + + case PIN_LEFT: + m_PinOrient->SetSelection(1); + break; + + case PIN_UP: + m_PinOrient->SetSelection(2); + break; + + case PIN_DOWN: + m_PinOrient->SetSelection(3); + break; + } + + tmp = CurrentPin ? CurrentPin->m_PinShape : LastPinShape; + m_PinShape->SetSelection( 0 ); + for ( ii = 0; ii < NBSHAPES; ii++ ) + { + if ( CodeShape[ii] == tmp ) + { + m_PinShape->SetSelection( ii ); break ; + } + } + + tmp = CurrentPin ? CurrentPin->m_PinShape : LastPinShape; + m_PinShape->SetSelection( 0 ); + for ( ii = 0; ii < NBSHAPES; ii++ ) + { + if ( CodeShape[ii] == tmp ) + { + m_PinShape->SetSelection( ii ); break ; + } + } + + m_PinElectricalType->SetSelection( CurrentPin ? CurrentPin->m_PinType : LastPinType); +} + +/*! + * WinEDA_PinPropertiesFrame creator + */ + +bool WinEDA_PinPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_PinPropertiesFrame member initialisation + m_PinNameCtrl = NULL; + m_PinNumCtrl = NULL; + m_PinSize = NULL; + m_CommonUnit = NULL; + m_CommonConvert = NULL; + m_NoDraw = NULL; + m_PinNameSizeText = NULL; + m_PinNameSizeCtrl = NULL; + m_PinNumSizeText = NULL; + m_PinNumSizeCtrl = NULL; + m_PinOrient = NULL; + m_PinShape = NULL; + m_PinElectricalType = NULL; +////@end WinEDA_PinPropertiesFrame member initialisation + +////@begin WinEDA_PinPropertiesFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_PinPropertiesFrame creation + return true; +} + +/*! + * Control creation for WinEDA_PinPropertiesFrame + */ + +void WinEDA_PinPropertiesFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_PinPropertiesFrame content construction + // Generated by DialogBlocks, 23/02/2006 09:33:11 (unregistered) + + WinEDA_PinPropertiesFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5); + + wxStaticText* itemStaticText4 = new wxStaticText( itemDialog1, wxID_STATIC, _("Pin Name :"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(itemStaticText4, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_PinNameCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(m_PinNameCtrl, 0, wxGROW|wxALL, 5); + + wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, _("Pin Num :"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_PinNumCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(m_PinNumCtrl, 0, wxGROW|wxALL, 5); + + itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer9Static = new wxStaticBox(itemDialog1, wxID_ANY, _(" Pin Options :")); + wxStaticBoxSizer* itemStaticBoxSizer9 = new wxStaticBoxSizer(itemStaticBoxSizer9Static, wxVERTICAL); + itemBoxSizer3->Add(itemStaticBoxSizer9, 0, wxGROW|wxALL, 5); + + wxStaticText* itemStaticText10 = new wxStaticText( itemDialog1, wxID_STATIC, _("Pin lenght :"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer9->Add(itemStaticText10, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_PinSize = new wxSpinCtrl( itemDialog1, ID_SPINCTRL, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 2000, 0 ); + itemStaticBoxSizer9->Add(m_PinSize, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + m_CommonUnit = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Common to Units"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_CommonUnit->SetValue(false); + itemStaticBoxSizer9->Add(m_CommonUnit, 0, wxALIGN_LEFT|wxALL, 5); + + m_CommonConvert = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Common to convert"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_CommonConvert->SetValue(false); + itemStaticBoxSizer9->Add(m_CommonConvert, 0, wxALIGN_LEFT|wxALL, 5); + + m_NoDraw = new wxCheckBox( itemDialog1, ID_CHECKBOX2, _("No Draw"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_NoDraw->SetValue(false); + itemStaticBoxSizer9->Add(m_NoDraw, 0, wxALIGN_LEFT|wxALL, 5); + + wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer15, 0, wxGROW|wxALL, 5); + + m_PinNameSizeText = new wxStaticText( itemDialog1, wxID_STATIC, _("Size"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer15->Add(m_PinNameSizeText, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_PinNameSizeCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer15->Add(m_PinNameSizeCtrl, 0, wxALIGN_LEFT|wxALL, 5); + + m_PinNumSizeText = new wxStaticText( itemDialog1, wxID_STATIC, _("Size"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer15->Add(m_PinNumSizeText, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_PinNumSizeCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer15->Add(m_PinNumSizeCtrl, 0, wxALIGN_LEFT|wxALL, 5); + + itemBoxSizer15->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxString m_PinOrientStrings[] = { + _("Right"), + _("Left"), + _("Up"), + _("Down") + }; + m_PinOrient = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Pin Orient:"), wxDefaultPosition, wxDefaultSize, 4, m_PinOrientStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer15->Add(m_PinOrient, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer22 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer22, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer22->Add(itemBoxSizer23, 0, wxGROW|wxALL, 5); + + wxButton* itemButton24 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton24->SetDefault(); + itemBoxSizer23->Add(itemButton24, 0, wxGROW|wxALL, 5); + + wxButton* itemButton25 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer23->Add(itemButton25, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer26 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer22->Add(itemBoxSizer26, 0, wxGROW|wxALL, 5); + + wxString m_PinShapeStrings[] = { + _("line"), + _("invert"), + _("clock"), + _("clock inv"), + _("low in"), + _("low clock"), + _("low out") + }; + m_PinShape = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Pin Shape:"), wxDefaultPosition, wxDefaultSize, 7, m_PinShapeStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer26->Add(m_PinShape, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxString m_PinElectricalTypeStrings[] = { + _("Input"), + _("Output"), + _("Bidi"), + _("3 States"), + _("Passive"), + _("Unspecified"), + _("Power In"), + _("Power Out"), + _("Open coll"), + _("Open emit") + }; + m_PinElectricalType = new wxRadioBox( itemDialog1, ID_RADIOBOX2, _("Electrical Type:"), wxDefaultPosition, wxDefaultSize, 10, m_PinElectricalTypeStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer26->Add(m_PinElectricalType, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + +////@end WinEDA_PinPropertiesFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_PinPropertiesFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_PinPropertiesFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_PinPropertiesFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_PinPropertiesFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_PinPropertiesFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_PinPropertiesFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_PinPropertiesFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_PinPropertiesFrame::OnOkClick( wxCommandEvent& event ) +{ + PinPropertiesAccept(event); + EndModal(1); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_PinPropertiesFrame::OnCancelClick( wxCommandEvent& event ) +{ + EndModal(0); +} + + diff --git a/eeschema/pinedit-dialog.h b/eeschema/pinedit-dialog.h new file mode 100644 index 0000000000..ea85d758cd --- /dev/null +++ b/eeschema/pinedit-dialog.h @@ -0,0 +1,150 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pinedit-dialog.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 11/02/2006 13:30:59 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 11/02/2006 13:30:59 + +#ifndef _PINEDIT_DIALOG_H_ +#define _PINEDIT_DIALOG_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "pinedit-dialog.h" +#endif + +/*! + * Includes + */ +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "id.h" + +#include "protos.h" + +////@begin includes +#include "wx/spinctrl.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +class wxSpinCtrl; +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_PINPROPERTIESFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_PINPROPERTIESFRAME_TITLE _("Pin properties") +#define SYMBOL_WINEDA_PINPROPERTIESFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_PINPROPERTIESFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_PINPROPERTIESFRAME_POSITION wxDefaultPosition +#define ID_TEXTCTRL 10001 +#define ID_TEXTCTRL1 10002 +#define ID_SPINCTRL 10003 +#define ID_CHECKBOX 10004 +#define ID_CHECKBOX1 10005 +#define ID_CHECKBOX2 10006 +#define ID_TEXTCTRL2 10007 +#define ID_TEXTCTRL3 10008 +#define ID_RADIOBOX 10009 +#define ID_RADIOBOX1 10012 +#define ID_RADIOBOX2 10013 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_PinPropertiesFrame class declaration + */ + +class WinEDA_PinPropertiesFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_PinPropertiesFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_PinPropertiesFrame( ); + WinEDA_PinPropertiesFrame( WinEDA_LibeditFrame* parent, wxWindowID id = SYMBOL_WINEDA_PINPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PINPROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PINPROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PINPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_PINPROPERTIESFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PINPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PINPROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PINPROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PINPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_PINPROPERTIESFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_PinPropertiesFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + +////@end WinEDA_PinPropertiesFrame event handler declarations + +////@begin WinEDA_PinPropertiesFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_PinPropertiesFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void PinPropertiesAccept(wxCommandEvent& event); + void SetPinName(const wxString & newname, int newsize); + void SetPinNum(const wxString & newnum, int newsize); + void NewSizePin(int newsize); + void SetPinShape( int newshape); + void SetPinType(int newtype); + void SetPinOrient(int neworient); + void SetAttributsPin(bool draw, bool unit, bool convert); + +////@begin WinEDA_PinPropertiesFrame member variables + wxTextCtrl* m_PinNameCtrl; + wxTextCtrl* m_PinNumCtrl; + wxSpinCtrl* m_PinSize; + wxCheckBox* m_CommonUnit; + wxCheckBox* m_CommonConvert; + wxCheckBox* m_NoDraw; + wxStaticText* m_PinNameSizeText; + wxTextCtrl* m_PinNameSizeCtrl; + wxStaticText* m_PinNumSizeText; + wxTextCtrl* m_PinNumSizeCtrl; + wxRadioBox* m_PinOrient; + wxRadioBox* m_PinShape; + wxRadioBox* m_PinElectricalType; +////@end WinEDA_PinPropertiesFrame member variables + + WinEDA_LibeditFrame * m_Parent; +}; + +#endif + // _PINEDIT_DIALOG_H_ diff --git a/eeschema/pinedit-dialog.pjd b/eeschema/pinedit-dialog.pjd new file mode 100644 index 0000000000..86f0c6eb72 --- /dev/null +++ b/eeschema/pinedit-dialog.pjd @@ -0,0 +1,1538 @@ + + +
+ 0 + "" + "" + "" + "" + 35 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "Pin properties" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "ID_DIALOG" + 10000 + "WinEDA_PinPropertiesFrame" + "wxDialog" + "wxDialog" + "pinedit-dialog.cpp" + "pinedit-dialog.h" + "" + "Pin properties" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Horizontal" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Pin Name :" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL" + 10001 + "wxTextCtrl" + "m_PinNameCtrl" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Pin Num :" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL1" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL1" + 10002 + "wxTextCtrl" + "m_PinNumCtrl" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + "-1" + " Pin Options :" + "" + "" + "" + 0 + 1 + "Vertical" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Pin lenght :" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxSpinCtrl: ID_SPINCTRL" + "dialog-control-document" + "" + "spinctrl" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbSpinCtrlProxy" + "ID_SPINCTRL" + 10003 + "wxSpinCtrl" + "m_PinSize" + 0 + 2000 + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX" + 10004 + "wxCheckBox" + "m_CommonUnit" + "Common to Units" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX1" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX1" + 10005 + "wxCheckBox" + "m_CommonConvert" + "Common to convert" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX2" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX2" + 10006 + "wxCheckBox" + "m_NoDraw" + "No Draw" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_PinNameSizeText" + "Size" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL2" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL2" + 10007 + "wxTextCtrl" + "m_PinNameSizeCtrl" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_PinNumSizeText" + "Size" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL3" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL3" + 10008 + "wxTextCtrl" + "m_PinNumSizeCtrl" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxRadioBox: ID_RADIOBOX" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX" + 10009 + "wxRadioBox" + "m_PinOrient" + "Pin Orient:" + 1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + "Right|Left|Up|Down" + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: wxID_OK" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnOkClick" + "wxID_OK" + 5100 + "wxButton" + "" + "&OK" + 1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_CANCEL" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCancelClick" + "wxID_CANCEL" + 5101 + "wxButton" + "" + "&Cancel" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxRadioBox: ID_RADIOBOX1" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX1" + 10012 + "wxRadioBox" + "m_PinShape" + "Pin Shape:" + 1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + "line|invert|clock|clock inv|low in|low clock|low out" + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxRadioBox: ID_RADIOBOX2" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "11/5/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX2" + 10013 + "wxRadioBox" + "m_PinElectricalType" + "Electrical Type:" + 1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + "Input|Output|Bidi|3 States|Passive|Unspecified|Power In|Power Out|Open coll|Open emit" + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "pinedit-dialog.rc" + "source-editor-document" + "pinedit-dialog.rc" + "source-editor" + 0 + 0 + 1 + 0 + "11/5/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/pinedit-dialog.rc b/eeschema/pinedit-dialog.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/eeschema/pinedit-dialog.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp new file mode 100644 index 0000000000..01a2a632a4 --- /dev/null +++ b/eeschema/pinedit.cpp @@ -0,0 +1,893 @@ + /***************************/ + /* EESchema - PinEdit.cpp */ + /***************************/ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "pinedit-dialog.h" +#endif + +#include "pinedit-dialog.h" + +static int CodeOrient[4] = +{ + PIN_RIGHT, + PIN_LEFT, + PIN_UP, + PIN_DOWN +}; + +#define NBSHAPES 7 +static wxString shape_list[NBSHAPES] = +{ + _("line"), _("invert"), _("clock"), _("clock inv"), + _("low in"), _("low clock"), _("low out") +}; + +int CodeShape[NBSHAPES] = +{ +NONE, INVERT, CLOCK, CLOCK|INVERT, LOWLEVEL_IN, LOWLEVEL_IN|CLOCK, LOWLEVEL_OUT +}; + + +/* Routines locales */ +static void CreateImagePins(LibDrawPin * Pin); +static void AbortPinMove(WinEDA_DrawPanel * Panel, wxDC * DC); +static void DrawMovePin(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); + +/* Variables importees */ + +/* Variables locales */ +static wxPoint OldPos, PinPreviousPos; +static int LastPinType = PIN_INPUT, + LastPinOrient = PIN_RIGHT, + LastPinShape = NONE, + LastPinSize = 300, + LastPinNameSize = 50, + LastPinNumSize = 50, + LastPinCommonConvert = FALSE, + LastPinCommonUnit = FALSE, + LastPinNoDraw = FALSE; + + +#include "pinedit-dialog.cpp" + +/*************************************************************************/ +void WinEDA_PinPropertiesFrame::PinPropertiesAccept(wxCommandEvent& event) +/*************************************************************************/ +/* Met a jour les differents parametres pour le composant en cours d'édition +*/ +{ +wxString msg; + + LastPinType = m_PinElectricalType->GetSelection(); + LastPinShape = CodeShape[m_PinShape->GetSelection()]; + LastPinOrient = CodeOrient[m_PinOrient->GetSelection()]; + LastPinCommonConvert = m_CommonConvert->GetValue(); + LastPinCommonUnit = m_CommonUnit->GetValue(); + LastPinNoDraw = m_NoDraw->GetValue(); + LastPinSize = m_PinSize->GetValue(); + msg = m_PinNameSizeCtrl->GetValue(); + LastPinNameSize = ReturnValueFromString(g_UnitMetric, msg, m_Parent->m_InternalUnits); + msg = m_PinNumSizeCtrl->GetValue(); + LastPinNumSize = ReturnValueFromString(g_UnitMetric, msg, m_Parent->m_InternalUnits); + + if ( CurrentDrawItem ) // Set Pin Name & Num + { + if ( ! (CurrentDrawItem->m_Flags & IS_NEW) ) // if IS_NEW, copy for undo is done before place + m_Parent->SaveCopyInUndoList(CurrentLibEntry); + LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem; + wxClientDC dc(m_Parent->DrawPanel); + m_Parent->DrawPanel->PrepareGraphicContext(&dc); + if ( m_Parent->DrawPanel->ManageCurseur ) // Pin is moving + m_Parent->DrawPanel->ManageCurseur(m_Parent->DrawPanel, &dc, FALSE); + else DrawLibraryDrawStruct(m_Parent->DrawPanel, &dc, CurrentLibEntry, + 0,0, CurrentPin,CurrentUnit, g_XorMode); + + SetPinName(m_PinNameCtrl->GetValue(), LastPinNameSize); + msg = m_PinNumCtrl->GetValue(); if ( msg.IsEmpty() ) msg = wxT("~"); + SetPinNum(msg, LastPinNumSize); + NewSizePin(LastPinSize); + SetPinShape(LastPinShape); + SetPinType(LastPinType); + SetPinOrient(LastPinOrient); + SetAttributsPin(TRUE, TRUE, TRUE); + if ( m_Parent->DrawPanel->ManageCurseur ) + m_Parent->DrawPanel->ManageCurseur(m_Parent->DrawPanel, &dc, FALSE); + else DrawLibraryDrawStruct(m_Parent->DrawPanel, &dc, CurrentLibEntry, + 0,0, CurrentPin,CurrentUnit, g_XorMode); + } + + if ( CurrentDrawItem ) + CurrentDrawItem->Display_Infos_DrawEntry(m_Parent); + + Close(); +} + + + + +/*********************************************/ +void WinEDA_LibeditFrame::InitEditOnePin(void) +/*********************************************/ +/* Routine d'installation du menu d'edition d'une pin +*/ +{ +LibDrawPin * Pin; +LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem; + + if(CurrentLibEntry == NULL) return; + if(CurrentPin == NULL) return; + + /* Marquage des pins a traiter,Si edition d'une pin non deja selectionnee */ + Pin = (LibDrawPin *) CurrentLibEntry->m_Drawings; + for ( ; Pin != NULL; Pin = (LibDrawPin *) Pin->Pnext ) + { + if (Pin->m_StructType != COMPONENT_PIN_DRAW_TYPE ) continue; + if ( Pin == CurrentPin ) continue; + if( (Pin->m_Pos == CurrentPin->m_Pos) && + (Pin->m_Orient == CurrentPin->m_Orient) && + (! (CurrentPin->m_Flags & IS_NEW)) && + (g_EditPinByPinIsOn == FALSE) ) + Pin->m_Flags |= IS_LINKED | IN_EDIT; + else Pin->m_Flags = 0; + } + + CurrentPin->Display_Infos_DrawEntry(this); +} + + +/*************************************************************/ +static void AbortPinMove(WinEDA_DrawPanel * Panel, wxDC * DC) +/*************************************************************/ +/* Used to abort the move pin command. +*/ +{ +LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem; + + if( CurrentPin && ( CurrentPin->m_Flags & IS_NEW ) ) + DeleteOneLibraryDrawStruct(Panel, DC, CurrentLibEntry, CurrentPin, TRUE); + + /* clear edit flags */ + LibEDA_BaseStruct * item = CurrentLibEntry->m_Drawings; + for ( ; item != NULL; item = item->Next() ) item->m_Flags = 0; + + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + CurrentDrawItem = NULL; + LibItemToRepeat = NULL; + Panel->Refresh(true); +} + + +/********************************************/ +void WinEDA_LibeditFrame::PlacePin(wxDC * DC) +/********************************************/ +/* Routine de fin de deplacement de la pin selectionnee */ +{ +LibDrawPin * Pin; +LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem; +bool ask_for_pin = TRUE; +wxPoint newpos; +bool status; + + if( CurrentPin == NULL ) return; + + newpos.x = GetScreen()->m_Curseur.x; + newpos.y = - GetScreen()->m_Curseur.y; + + Pin = (LibDrawPin *) CurrentLibEntry->m_Drawings; + // Tst for an other pin in same new position: + for ( ; Pin != NULL; Pin = (LibDrawPin *) Pin->Pnext) + { + if ( Pin->m_StructType != COMPONENT_PIN_DRAW_TYPE ) continue; + if ( Pin == CurrentPin ) continue; + if( newpos != Pin->m_Pos ) continue; + if ( Pin->m_Flags ) continue; + if ( ask_for_pin ) + { + DrawPanel->m_IgnoreMouseEvents = TRUE; + status = IsOK(this, _("Occupied by other pin, Continue ?")); + DrawPanel->MouseToCursorSchema(); + DrawPanel->m_IgnoreMouseEvents = FALSE; + if( ! status ) + return; + else ask_for_pin = FALSE; + } + } + + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->SetModify(); + + CurrentPin->m_Pos = newpos; + if( CurrentPin->m_Flags & IS_NEW ) + { + LastPinOrient = CurrentPin->m_Orient; + LastPinType = CurrentPin->m_PinType; + LastPinShape = CurrentPin->m_PinShape; + CreateImagePins(CurrentPin); + LibItemToRepeat = CurrentPin; + } + + /* Put linked pins in new position, and clear flags */ + Pin = (LibDrawPin *)CurrentLibEntry->m_Drawings; + for ( ; Pin != NULL; Pin = (LibDrawPin *)Pin->Pnext) + { + if(Pin->m_StructType != COMPONENT_PIN_DRAW_TYPE ) continue; + if( Pin->m_Flags == 0 ) continue; + Pin->m_Pos = CurrentPin->m_Pos; + Pin->m_Flags = 0; + } + + DrawPanel->CursorOff(DC); + DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry,0,0, CurrentPin,CurrentUnit, + GR_DEFAULT_DRAWMODE); + DrawPanel->CursorOn(DC); + + CurrentDrawItem = NULL; +}; + +/***********************************************************/ +void WinEDA_PinPropertiesFrame::SetPinOrient(int neworient) +/***********************************************************/ +/* Routine de Rotation de la pin courante*/ +{ +LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem; +LibDrawPin * Pin, *RefPin = CurrentPin; + + if( CurrentLibEntry == NULL ) return; + if ( RefPin == NULL ) return; + + m_Parent->GetScreen()->SetModify(); + + /* Rotation */ + RefPin->m_Orient = neworient; + + Pin = (LibDrawPin *) CurrentLibEntry->m_Drawings; + for ( ; Pin != NULL; Pin = (LibDrawPin *) Pin->Pnext) + { + if( Pin->m_Flags == 0 ) continue; + Pin->m_Orient = RefPin->m_Orient; + if(CurrentPin == NULL ) Pin->m_Flags = 0; + } +} + + +/*************************************************/ +void WinEDA_LibeditFrame::StartMovePin(wxDC * DC) +/*************************************************/ +/* Prepare le deplacement d'une pin : + Localise la pin pointee par le curseur, et si elle existe active + la fonction de gestion curseur ( DrawMovePin() ). +*/ +{ +LibDrawPin * Pin; +LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem; +wxPoint startPos; + + /* Marquage des pins a traiter */ + Pin = (LibDrawPin *)CurrentLibEntry->m_Drawings; + for ( ; Pin != NULL; Pin = (LibDrawPin *)Pin->Pnext ) + { + Pin->m_Flags = 0; + if (Pin->m_StructType != COMPONENT_PIN_DRAW_TYPE ) continue; + if ( Pin == CurrentPin) continue; + if ( (Pin->m_Pos == CurrentPin->m_Pos) && (Pin->m_Orient == CurrentPin->m_Orient) && + (g_EditPinByPinIsOn == FALSE ) ) + Pin->m_Flags |= IS_LINKED | IS_MOVED; + } + CurrentPin->m_Flags |= IS_LINKED | IS_MOVED; + PinPreviousPos = OldPos = CurrentPin->m_Pos; + + startPos.x = OldPos.x; + startPos.y = -OldPos.y; + DrawPanel->CursorOff(DC); + m_CurrentScreen->m_Curseur = startPos; + DrawPanel->MouseToCursorSchema(); + + CurrentPin->Display_Infos_DrawEntry(this); + DrawPanel->ManageCurseur = DrawMovePin; + DrawPanel->ForceCloseManageCurseur = AbortPinMove; + + DrawPanel->CursorOn(DC); +} + + +/******************************************************************************/ +/* Routine de deplacement de la Pin courante selon position du curseur souris */ +/* Routine normalement appelee par la routine de gestion du curseur */ +/******************************************************************************/ +static void DrawMovePin(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +{ +LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem; +wxPoint pinpos = CurrentPin->m_Pos; + + /* Erase pin in old position */ + if( erase || (CurrentPin->m_Flags & IS_NEW) ) + { + CurrentPin->m_Pos = PinPreviousPos; + DrawLibraryDrawStruct(panel, DC, CurrentLibEntry,0,0, + CurrentPin,CurrentUnit, g_XorMode); + } + + /* Redraw pin in new position */ + CurrentPin->m_Pos.x = panel->m_Parent->GetScreen()->m_Curseur.x; + CurrentPin->m_Pos.y = - panel->m_Parent->GetScreen()->m_Curseur.y; + DrawLibraryDrawStruct(panel, DC, CurrentLibEntry,0,0, CurrentPin,CurrentUnit, g_XorMode); + + PinPreviousPos = CurrentPin->m_Pos; + /* Keep the original position for existing pin (for Undo command) + and the current position for a new pin */ + if ( (CurrentPin->m_Flags & IS_NEW) == 0 ) + CurrentPin->m_Pos = pinpos; +} + + + + +/**********************************************************/ +void WinEDA_PinPropertiesFrame::SetPinShape( int newshape) +/**********************************************************/ +/* Changement de la forme de la pin courante. + Le changement est egalement fait sur les autres pins correspondantes + des autres unites de la seule forme convert courante +*/ +{ +LibDrawPin* Pin; +LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem; + + if(CurrentPin) + { + CurrentPin->m_PinShape = newshape; + m_Parent->GetScreen()->SetModify(); + CurrentPin->Display_Infos_DrawEntry(m_Parent); + + Pin = (LibDrawPin *) CurrentLibEntry->m_Drawings; + for ( ; Pin != NULL; Pin = (LibDrawPin *) Pin->Pnext) + { + if(Pin->m_StructType != COMPONENT_PIN_DRAW_TYPE ) continue; + if( Pin->m_Flags == 0 ) continue; + if( Pin->m_Convert != CurrentPin->m_Convert ) continue; + Pin->m_PinShape = newshape; + } + } +} + + +/******************************************************/ +void WinEDA_PinPropertiesFrame::SetPinType(int newtype) +/******************************************************/ +/* Changement du type electrique de la pin courante. + Le changement est egalement fait sur les autres pins correspondantes + des autres unites du boitier +*/ +{ +LibDrawPin* Pin; +LibDrawPin * CurrentPin = (LibDrawPin*)CurrentDrawItem; + + if(CurrentPin == NULL) return; + + CurrentPin->m_PinType = newtype; + m_Parent->GetScreen()->SetModify(); + + Pin = (LibDrawPin*)CurrentLibEntry->m_Drawings; + for ( ; Pin != NULL; Pin = (LibDrawPin *) Pin->Pnext) + { + if(Pin->m_StructType != COMPONENT_PIN_DRAW_TYPE ) continue; + if( Pin->m_Flags == 0 ) continue; + Pin->m_PinType = newtype; + } +} + +/********************************************************************************/ +void WinEDA_PinPropertiesFrame::SetPinName(const wxString & newname, int newsize) +/********************************************************************************/ +/* Met a jour le nom et la taille de ce nom de la pin courante + si newname == NULL, pas de changement de nom + si newsize < 0 : pas de changement de taille +*/ +{ +LibDrawPin * Pin; +LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem; +wxString buf; + + buf = newname; + buf.Replace( wxT(" "), wxT("_")); + + if ( newsize >= 0 ) CurrentPin->m_SizeName = newsize; + + CurrentPin->m_PinName = buf; + + m_Parent->GetScreen()->SetModify(); + + /* Traitement des autres pins */ + Pin = (LibDrawPin *) CurrentLibEntry->m_Drawings; + for ( ; Pin != NULL; Pin = (LibDrawPin *) Pin->Pnext) + { + if (Pin->m_StructType != COMPONENT_PIN_DRAW_TYPE ) continue; + if( (Pin->m_Flags & IS_LINKED) == 0 ) continue; + if (newsize >= 0 ) Pin->m_SizeName = newsize; + Pin->m_PinName = buf; + } +} + +/******************************************************************************/ +void WinEDA_PinPropertiesFrame::SetPinNum(const wxString & newnum, int newsize) +/******************************************************************************/ +/* Changement du numero de la pin courante. + Le changement est egalement fait sur les autres pins correspondantes + a la forme convertie + Si newnum == NULL: pas de changement de numero + Si newsize < 0 ) pase de changement de taille +*/ +{ +LibDrawPin * Pin; +LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem; +wxString buf; + + buf = newnum; + buf.Replace( wxT(" "), wxT("_")); + + if(CurrentPin == NULL ) return; + + CurrentPin->m_PinNum = 0; + + if ( newsize >= 0) CurrentPin->m_SizeNum = newsize; + CurrentPin->SetPinNumFromString(buf); + m_Parent->GetScreen()->SetModify(); + + Pin = (LibDrawPin *) CurrentLibEntry->m_Drawings; + for ( ; Pin != NULL; Pin = (LibDrawPin *) Pin->Pnext) + { + if (Pin->m_StructType != COMPONENT_PIN_DRAW_TYPE ) continue; + if( (Pin->m_Flags & IS_LINKED) == 0 ) continue; + if( Pin->m_Unit != CurrentPin->m_Unit ) continue; + if ( newsize >= 0) Pin->m_SizeNum = newsize; + if ( newnum ) Pin->m_PinNum = CurrentPin->m_PinNum; + } +} + + +/*************************************************/ +void WinEDA_LibeditFrame::DeletePin(wxDC * DC, + EDA_LibComponentStruct* LibEntry, + LibDrawPin* Pin) +/*************************************************/ +/* Routine d'effacement de la pin pointee par la souris + Si g_EditPinByPinIsOn == FALSE : + toutes les pins de meme coordonnee seront effacees. + Sinon seule la pin de l'unite en convert courante sera effacee +*/ +{ +LibEDA_BaseStruct * DrawItem; +wxPoint PinPos; + + if(LibEntry == NULL ) return; + if(Pin == NULL ) return; + + PinPos = Pin->m_Pos; + DeleteOneLibraryDrawStruct(DrawPanel, DC, LibEntry, Pin, TRUE); + + /* Effacement des autres pins de meme coordonnees */ + if( g_EditPinByPinIsOn == FALSE ) + { + DrawItem = LibEntry->m_Drawings; + for ( ; DrawItem != NULL; ) + { + if (DrawItem->m_StructType != COMPONENT_PIN_DRAW_TYPE ) + { + DrawItem = DrawItem->Next(); continue; + } + Pin = (LibDrawPin*) DrawItem; + DrawItem = DrawItem->Next(); + if( Pin->m_Pos != PinPos ) continue; + DeleteOneLibraryDrawStruct(DrawPanel, DC, LibEntry, Pin, 0); + } + } + GetScreen()->SetModify(); +} + + +/*********************************************/ +void WinEDA_LibeditFrame::CreatePin(wxDC * DC) +/*********************************************/ +/* Creation d'une nouvelle pin */ +{ +LibEDA_BaseStruct * DrawItem; +LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem; + + if(CurrentLibEntry == NULL ) return; + if(CurrentPin != NULL ) return; + + /* Effacement des flags */ + DrawItem = CurrentLibEntry->m_Drawings; + for( ;DrawItem != NULL; DrawItem = DrawItem->Next()) + DrawItem->m_Flags = 0; + + CurrentPin = new LibDrawPin(); + CurrentDrawItem = CurrentPin; + if(CurrentPin == NULL ) return; + CurrentPin->m_Flags = IS_NEW; + CurrentPin->m_Unit = CurrentUnit; + CurrentPin->m_Convert = CurrentConvert; + + /* Marquage des pins a traiter */ + if( g_EditPinByPinIsOn == FALSE ) CurrentPin->m_Flags |= IS_LINKED; + + CurrentPin->m_Pos.x = GetScreen()->m_Curseur.x; + CurrentPin->m_Pos.y = - GetScreen()->m_Curseur.y; + CurrentPin->m_PinLen = LastPinSize; + CurrentPin->m_Orient = LastPinOrient; + CurrentPin->m_PinType = LastPinType; + CurrentPin->m_PinShape = LastPinShape; + CurrentPin->m_SizeName = LastPinNameSize; + CurrentPin->m_SizeNum = LastPinNumSize; + if ( LastPinCommonConvert ) CurrentPin->m_Convert = 0; + else CurrentPin->m_Convert = CurrentConvert; + if ( LastPinCommonUnit ) CurrentPin->m_Unit = 0; + else CurrentPin->m_Unit = CurrentUnit; + if( LastPinNoDraw ) CurrentPin->m_Attributs |= PINNOTDRAW; + else CurrentPin->m_Attributs &= ~PINNOTDRAW; + + CurrentPin->Pnext = CurrentLibEntry->m_Drawings; + CurrentLibEntry->m_Drawings = CurrentPin; + CurrentLibEntry->SortDrawItems(); + + if ( DC ) DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, + 0,0, CurrentPin,CurrentUnit, g_XorMode); + + DrawPanel->m_IgnoreMouseEvents = TRUE; + InstallPineditFrame(this, DC, wxPoint(-1,-1) ); + DrawPanel->MouseToCursorSchema(); + DrawPanel->m_IgnoreMouseEvents = FALSE; + + PinPreviousPos = CurrentPin->m_Pos; + + DrawPanel->ManageCurseur = DrawMovePin; + DrawPanel->ForceCloseManageCurseur = AbortPinMove; + + CurrentPin->Display_Infos_DrawEntry(this); + GetScreen()->SetModify(); +} + + + +/*********************************************************/ +void WinEDA_PinPropertiesFrame::SetAttributsPin(bool draw, + bool unit, bool convert) +/*********************************************************/ +/* si draw == TRUE + - Ajuste le flag visible / invisible (.U.Pin.Flags bit 0 ) de la pin + editee + + si unit == TRUE + - Modifie l'attribut Commun / Particulier U.Pin.Unit = 0 ou Num Unite + de la pin editee + + si convert == TRUE + - Modifie l'attribut Commun / Particulier U.Pin.Convert = 0 ou Num Unite + de la pin editee + +*/ +{ +LibEDA_BaseStruct* DrawItem; +LibDrawPin * Pin, * CurrentPin = (LibDrawPin * ) CurrentDrawItem; + + if(CurrentPin == NULL) return; + + m_Parent->GetScreen()->SetModify(); + + if( unit ) + { + if ( LastPinCommonUnit ) CurrentPin->m_Unit = 0; + else CurrentPin->m_Unit = CurrentUnit; + + Pin = (LibDrawPin *) CurrentLibEntry->m_Drawings; + + if( CurrentPin->m_Unit == 0 ) + { + DrawItem = CurrentLibEntry->m_Drawings; + for ( ; DrawItem != NULL; ) + { + Pin = (LibDrawPin *)DrawItem; + DrawItem = DrawItem->Next(); + if( Pin->m_StructType != COMPONENT_PIN_DRAW_TYPE) continue; + if( Pin->m_Flags == 0 ) continue; + if( Pin == CurrentPin) continue; + if(CurrentPin->m_Convert && (CurrentPin->m_Convert != Pin->m_Convert)) + continue; + if( CurrentPin->m_Pos != Pin->m_Pos ) continue; + if(Pin->m_Orient != CurrentPin->m_Orient) continue; + DeleteOneLibraryDrawStruct(m_Parent->DrawPanel, NULL, + CurrentLibEntry, Pin, 0); + } + } + } // end if unit + + if( convert ) + { + if ( LastPinCommonConvert ) CurrentPin->m_Convert = 0; + else CurrentPin->m_Convert = CurrentConvert; + + if( CurrentPin->m_Convert == 0 ) /* Effacement des pins redondantes */ + { + DrawItem = CurrentLibEntry->m_Drawings; + for ( ; DrawItem != NULL; ) + { + Pin = (LibDrawPin *)DrawItem; DrawItem = DrawItem->Next(); + if(Pin->m_StructType != COMPONENT_PIN_DRAW_TYPE) continue; + if( Pin->m_Flags == 0 ) continue; + if( Pin == CurrentPin) continue; + if( CurrentPin->m_Unit && (CurrentPin->m_Unit != Pin->m_Unit) ) + continue; + if( CurrentPin->m_Pos != Pin->m_Pos ) continue; + if(Pin->m_Orient != CurrentPin->m_Orient) continue; + DeleteOneLibraryDrawStruct(m_Parent->DrawPanel, NULL, + CurrentLibEntry, Pin, 0); + } + } + } // end if convert + + if( draw ) + { + if( LastPinNoDraw ) CurrentPin->m_Attributs |= PINNOTDRAW; + else CurrentPin->m_Attributs &= ~PINNOTDRAW; + + Pin = (LibDrawPin *)CurrentLibEntry->m_Drawings; + for ( ; Pin != NULL; Pin = (LibDrawPin *)Pin->Pnext) + { + if( Pin->m_Flags == 0 ) continue; + Pin->m_Attributs &= ~PINNOTDRAW; + if(CurrentPin->m_Attributs & PINNOTDRAW) + Pin->m_Attributs |= PINNOTDRAW; + } + } +} + + +/******************************************************/ +void WinEDA_PinPropertiesFrame::NewSizePin(int newsize) +/******************************************************/ +/* Fonction permettant la mise aux dimensions courantes: + - longueur, dimension des textes + de la pin courante + +*/ +{ +LibDrawPin * RefPin, * Pin = (LibDrawPin *) CurrentDrawItem; + + if(CurrentLibEntry == NULL ) return; + if(Pin == NULL ) return; + + m_Parent->GetScreen()->SetModify(); + + Pin->m_PinLen = newsize; + + Pin->Display_Infos_DrawEntry(m_Parent); + + RefPin = Pin; + + if( g_EditPinByPinIsOn == FALSE ) + { + Pin = (LibDrawPin *)CurrentLibEntry->m_Drawings; + for ( ; Pin != NULL; Pin = (LibDrawPin *)Pin->Pnext ) + { + if (Pin->m_StructType != COMPONENT_PIN_DRAW_TYPE ) continue; + if( Pin->m_Pos != RefPin->m_Pos ) continue; + if(Pin->m_Orient != RefPin->m_Orient) continue; + if( Pin->m_Convert == RefPin->m_Convert ) Pin->m_PinLen = newsize; + } + } +} + +/********************************************/ +static void CreateImagePins(LibDrawPin* Pin) +/********************************************/ +/* Creation des autres pins pour les autres unites et pour convert, apres + creation d'une pin +*/ +{ +int ii, CreateConv = FALSE; +LibDrawPin* NewPin; + + if( g_EditPinByPinIsOn ) return; + + if( g_AsDeMorgan && (Pin->m_Convert != 0 ) ) CreateConv = TRUE; + + /* Creation de la pin " convert " pour la part courante */ + if( CreateConv == TRUE) + { + NewPin = Pin->GenCopy(); + if( Pin->m_Convert > 1 ) NewPin->m_Convert = 1; + else NewPin->m_Convert = 2; + NewPin->Pnext = CurrentLibEntry->m_Drawings; + CurrentLibEntry->m_Drawings = NewPin; + } + + for ( ii = 1; ii <= CurrentLibEntry->m_UnitCount ; ii++ ) + { + if ( ii == CurrentUnit ) continue; /* Deja fait */ + if( Pin->m_Unit == 0 ) continue; /* Pin commune a toutes les unites */ + + /* Creation pour la representation "normale" */ + NewPin = Pin->GenCopy(); + if( CurrentConvert != 0 ) NewPin->m_Convert = 1; + NewPin->m_Unit = ii; + NewPin->Pnext = CurrentLibEntry->m_Drawings; + CurrentLibEntry->m_Drawings = NewPin; + + /* Creation pour la representation "Convert" */ + if( CreateConv == FALSE ) continue; + + NewPin = Pin->GenCopy(); + NewPin->m_Convert = 2; + if( Pin->m_Unit != 0 ) NewPin->m_Unit = ii; + NewPin->Pnext = CurrentLibEntry->m_Drawings; + CurrentLibEntry->m_Drawings = NewPin; + } +} + + + + +/*************************************************/ +void WinEDA_LibeditFrame::GlobalSetPins(wxDC * DC, + LibDrawPin * MasterPin, int id) +/*************************************************/ +/* Depending on "id": + - Change pin text size (name or num) (range 10 .. 1000 mil) + - Change pin lenght. + + If Pin is selected ( .m_flag == IS_SELECTED ) only the other selected pis are modified +*/ +{ +LibDrawPin * Pin; +bool selected = (MasterPin->m_Selected & IS_SELECTED) != 0; + + if( (CurrentLibEntry == NULL) || (MasterPin == NULL) ) return; + if(MasterPin->m_StructType != COMPONENT_PIN_DRAW_TYPE ) return; + + GetScreen()->SetModify(); + + Pin = (LibDrawPin *)CurrentLibEntry->m_Drawings; + for( ; Pin != NULL; Pin = (LibDrawPin *) Pin->Pnext ) + { + if ( Pin->m_StructType != COMPONENT_PIN_DRAW_TYPE ) continue; + if ( (Pin->m_Convert) && (Pin->m_Convert != CurrentConvert) ) continue; + // Is it the "selected mode" ? + if (selected && (Pin->m_Selected & IS_SELECTED) == 0 ) continue; + + DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry,0,0, Pin, CurrentUnit, g_XorMode); + + switch ( id ) + { + case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM: + Pin->m_SizeNum = MasterPin->m_SizeNum; + break; + + case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM: + Pin->m_SizeName = MasterPin->m_SizeName; + break; + + case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM: + Pin->m_PinLen = MasterPin->m_PinLen; + break; + } + + DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry,0,0, Pin, CurrentUnit, + GR_DEFAULT_DRAWMODE); + } +} + + + + +/************************************************************************/ +void WinEDA_LibeditFrame::RepeatPinItem(wxDC * DC, LibDrawPin * SourcePin) +/************************************************************************/ +/* Creation d'une nouvelle pin par copie de la précédente ( fct REPEAT) */ +{ +LibDrawPin * Pin; +wxString msg; +int ox = 0, oy = 0; + + if(CurrentLibEntry == NULL ) return; + if(SourcePin == NULL ) return; + if(SourcePin->m_StructType != COMPONENT_PIN_DRAW_TYPE ) return; + + Pin = SourcePin->GenCopy(); + Pin->Pnext = CurrentLibEntry->m_Drawings; + CurrentLibEntry->m_Drawings = Pin; + Pin->m_Flags = IS_NEW; + + Pin->m_Pos.x += g_RepeatStep.x; ox = Pin->m_Pos.x; + Pin->m_Pos.y += - g_RepeatStep.y; oy = Pin->m_Pos.y; // ici axe Y comme en math + /*** Increment du numero de label ***/ + IncrementLabelMember(Pin->m_PinName); + + Pin->ReturnPinStringNum(msg); + IncrementLabelMember(msg); + Pin->SetPinNumFromString(msg); + + CurrentDrawItem = Pin; + + /* Marquage des pins a traiter */ + if( g_EditPinByPinIsOn == FALSE ) Pin->m_Flags |= IS_LINKED; + +wxPoint savepos = GetScreen()->m_Curseur; + DrawPanel->CursorOff(DC); + GetScreen()->m_Curseur.x = Pin->m_Pos.x; + GetScreen()->m_Curseur.y = -Pin->m_Pos.y; + PlacePin(DC); + GetScreen()->m_Curseur = savepos; +// DrawPanel->MouseToCursorSchema(); + DrawPanel->CursorOn(DC); + + Pin->Display_Infos_DrawEntry(this); + GetScreen()->SetModify(); +} + +int sort_by_pin_number(const void * ref, const void * tst ) +{ +const LibDrawPin * Ref = * (LibDrawPin **) ref; +const LibDrawPin * Tst = * (LibDrawPin **) tst; + return ( Ref->m_PinNum - Tst->m_PinNum); +} +/***************************************************************/ +bool WinEDA_LibeditFrame::TestPins(EDA_LibComponentStruct* LibEntry) +/***************************************************************/ +// Test des pins ( duplicates...) +{ +int nb_pins, ii, error; +LibDrawPin * Pin, **PinList; +wxString msg; + + if( CurrentLibEntry == NULL ) return FALSE; + + // Construction de la liste des pins: + Pin = (LibDrawPin *)CurrentLibEntry->m_Drawings; + for( nb_pins = 0; Pin != NULL; Pin = (LibDrawPin *) Pin->Pnext ) + { + if ( Pin->m_StructType == COMPONENT_PIN_DRAW_TYPE ) nb_pins++; + } + PinList = (LibDrawPin **) MyZMalloc( (nb_pins+1) * sizeof(LibDrawPin *) ); + Pin = (LibDrawPin *)CurrentLibEntry->m_Drawings; + for( ii = 0; Pin != NULL; Pin = (LibDrawPin *) Pin->Pnext ) + { + if ( Pin->m_StructType == COMPONENT_PIN_DRAW_TYPE ) PinList[ii++] = Pin; + } + + // Classement des pins par numero de pin + qsort(PinList, nb_pins, sizeof(LibDrawPin *), sort_by_pin_number); + // Controle des duplicates: + error = 0; + for( ii = 1; ii < nb_pins; ii++ ) + { + wxString aux_msg, StringPinNum; + LibDrawPin * curr_pin = PinList[ii]; + Pin = PinList[ii -1]; + if ( Pin->m_PinNum != curr_pin->m_PinNum ) continue; + if ( Pin->m_Convert != curr_pin->m_Convert ) continue; + if ( Pin->m_Unit != curr_pin->m_Unit ) continue; + error ++; + curr_pin->ReturnPinStringNum(StringPinNum); + msg.Printf(_("Duplicate Pin %4.4s (Pin %s loc %d, %d, and Pin %s loc %d, %d)"), + StringPinNum.GetData(), curr_pin->m_PinName.GetData(), curr_pin->m_Pos.x, -curr_pin->m_Pos.y, + Pin->m_PinName.GetData(), Pin->m_Pos.x, -Pin->m_Pos.y); + if ( CurrentLibEntry->m_UnitCount > 1 ) + { + aux_msg.Printf( _(" Unit %d"), curr_pin->m_Unit); + msg += aux_msg; + } + if ( g_AsDeMorgan ) + { + if( curr_pin->m_Convert) msg += _(" Convert"); + else msg += _(" Normal"); + } + DisplayError(this, msg); + } + + free (PinList); + return error ? TRUE : FALSE; +} + diff --git a/eeschema/plot.cpp b/eeschema/plot.cpp new file mode 100644 index 0000000000..26b7c888df --- /dev/null +++ b/eeschema/plot.cpp @@ -0,0 +1,702 @@ + /************************************************/ + /* Routine de trace communes aux divers formats */ + /************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "plot_common.h" +#include "worksheet.h" + +#include "protos.h" + +/* Variables locales : */ +static void PlotSheetLabelStruct(DrawSheetLabelStruct *Struct); +static void PlotTextField( EDA_SchComponentStruct *DrawLibItem, + int FieldNumber, int IsMulti, int DrawMode); +static void PlotPinSymbol(int posX, int posY, int len, int orient, int Shape); +/***/ + +/* cte pour remplissage de polygones */ +#define FILL 1 +#define NOFILL 0 + +#define PLOT_SHEETREF_MARGIN 0 // margin for sheet refs + + /*******************************/ + /* Routines de base de trace : */ + /*******************************/ +/* routine de lever ou baisser de plume. + si plume = 'U' les traces suivants se feront plume levee + si plume = 'D' les traces suivants se feront plume levee +*/ +void Plume( int plume ) +{ + if ( g_PlotFormat == PLOT_FORMAT_HPGL ) Plume_HPGL(plume); +} + +/* routine de deplacement de plume de plume. +*/ +void Move_Plume( wxPoint pos, int plume ) +{ + switch ( g_PlotFormat ) + { + case PLOT_FORMAT_HPGL: + Move_Plume_HPGL(pos, plume); + break; + case PLOT_FORMAT_POST: + case PLOT_FORMAT_POST_A4: + LineTo_PS(pos, plume); + break; + } +} + + +/***************************************************************/ +void PlotArc(wxPoint centre, int StAngle, int EndAngle, int rayon) +/***************************************************************/ +/* trace d'un arc de cercle: + x, y = coord du centre + StAngle, EndAngle = angle de debut et fin + rayon = rayon de l'arc +*/ +{ + switch ( g_PlotFormat ) + { + case PLOT_FORMAT_HPGL: + PlotArcHPGL(centre, StAngle, EndAngle, rayon); + break; + case PLOT_FORMAT_POST: + PlotArcPS(centre, StAngle, EndAngle, rayon); + break; + } +} + +/**************************************************/ +void PlotCercle( wxPoint pos,int diametre ) +/**************************************************/ +{ + switch ( g_PlotFormat ) + { + case PLOT_FORMAT_HPGL: + PlotCircle_HPGL( pos, diametre); + break; + + case PLOT_FORMAT_POST: + PlotCircle_PS(pos, diametre); + break; + } +} + +/****************************************************/ +static void PlotPoly( int nb, int * coord, int fill) +/****************************************************/ +/* Trace un polygone ferme + coord = tableau des coord des sommets + nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau ) + fill : si != 0 polygone rempli +*/ +{ + if( nb <= 1 ) return; + + switch ( g_PlotFormat ) + { + case PLOT_FORMAT_HPGL: + PlotPolyHPGL( nb, coord, fill); + break; + + case PLOT_FORMAT_POST: + PlotPolyPS( nb, coord, fill); + break; + } +} + + + +/**********************************************************/ +void PlotNoConnectStruct(DrawNoConnectStruct * Struct) +/**********************************************************/ +/* Routine de dessin des symboles de "No Connexion" .. +*/ +{ +#define DELTA (DRAWNOCONNECT_SIZE/2) +int pX, pY; + + pX = Struct->m_Pos.x; pY = Struct->m_Pos.y; + + Move_Plume(wxPoint(pX - DELTA, pY - DELTA), 'U'); + Move_Plume(wxPoint(pX + DELTA, pY + DELTA), 'D'); + Move_Plume(wxPoint(pX + DELTA, pY - DELTA), 'U'); + Move_Plume(wxPoint(pX - DELTA, pY + DELTA), 'D'); + Plume('U'); +} + +/*************************************************/ +void PlotLibPart( EDA_SchComponentStruct *DrawLibItem ) +/*************************************************/ +/* Genere le trace d'un composant */ +{ +int ii, x1, y1, x2, y2, t1, t2, *Poly, orient; +LibEDA_BaseStruct *DEntry; +EDA_LibComponentStruct *Entry; +int TransMat[2][2], PartX, PartY, Multi, convert; +int CharColor = -1; +wxPoint pos; + + Entry = FindLibPart(DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); + if( Entry == NULL) return;; + memcpy(TransMat, DrawLibItem->m_Transform, sizeof(TransMat)); + PartX = DrawLibItem->m_Pos.x; PartY = DrawLibItem->m_Pos.y; + Multi = DrawLibItem->m_Multi; + convert = DrawLibItem->m_Convert; + + for( DEntry = Entry->m_Drawings; DEntry != NULL;DEntry = DEntry->Next()) + { + /* Elimination des elements non relatifs a l'unite */ + if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) ) continue; + if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) ) + continue; + + Plume('U'); + if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) + SetColorMapPS ( ReturnLayerColor(LAYER_DEVICE) ); + switch (DEntry->m_StructType) + { + case COMPONENT_ARC_DRAW_TYPE: + { + LibDrawArc * Arc = (LibDrawArc *) DEntry; + t1 = Arc->t1; t2 = Arc->t2; + pos.x = PartX + TransMat[0][0] * Arc->m_Pos.x + + TransMat[0][1] * Arc->m_Pos.y; + pos.y = PartY + TransMat[1][0] * Arc->m_Pos.x + + TransMat[1][1] * Arc->m_Pos.y; + MapAngles(&t1, &t2, TransMat); + PlotArc(pos, t1, t2, Arc->m_Rayon); + } + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + { + LibDrawCircle * Circle = (LibDrawCircle *) DEntry; + pos.x = PartX + TransMat[0][0] * Circle->m_Pos.x + + TransMat[0][1] * Circle->m_Pos.y; + pos.y = PartY + TransMat[1][0] * Circle->m_Pos.x + + TransMat[1][1] * Circle->m_Pos.y; + PlotCercle(pos, Circle->m_Rayon * 2); + } + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + { + LibDrawText * Text = (LibDrawText *) DEntry; + /* The text orientation may need to be flipped if the + transformation matrix causes xy axes to be flipped. */ + t1 = (TransMat[0][0] != 0) ^ (Text->m_Horiz != 0); + pos.x = PartX + TransMat[0][0] * Text->m_Pos.x + + TransMat[0][1] * Text->m_Pos.y; + pos.y = PartY + TransMat[1][0] * Text->m_Pos.x + + TransMat[1][1] * Text->m_Pos.y; + PlotGraphicText(g_PlotFormat, pos , CharColor, + Text->m_Text, + t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT, + Text->m_Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + } + break; + + case COMPONENT_RECT_DRAW_TYPE: + { + LibDrawSquare * Square = (LibDrawSquare *) DEntry; + x1 = PartX + TransMat[0][0] * Square->m_Start.x + + TransMat[0][1] * Square->m_Start.y; + y1 = PartY + TransMat[1][0] * Square->m_Start.x + + TransMat[1][1] * Square->m_Start.y; + x2 = PartX + TransMat[0][0] * Square->m_End.x + + TransMat[0][1] * Square->m_End.y; + y2 = PartY + TransMat[1][0] * Square->m_End.x + + TransMat[1][1] * Square->m_End.y; + + Move_Plume(wxPoint(x1, y1), 'U'); + Move_Plume(wxPoint(x1, y2), 'D'); + Move_Plume(wxPoint(x2, y2), 'D'); + Move_Plume(wxPoint(x2, y1), 'D'); + Move_Plume(wxPoint(x1, y1), 'D'); + } + break; + + case COMPONENT_PIN_DRAW_TYPE: /* Trace des Pins */ + { + LibDrawPin * Pin = (LibDrawPin *) DEntry; + if(Pin->m_Attributs & PINNOTDRAW) + { + if( ActiveScreen->m_Type == SCHEMATIC_FRAME ) + break; + } + + /* Calcul de l'orientation reelle de la Pin */ + orient = Pin->ReturnPinDrawOrient(TransMat); + /* compute Pin Pos */ + x2 = PartX + TransMat[0][0] * Pin->m_Pos.x + + TransMat[0][1] * Pin->m_Pos.y; + y2 = PartY + TransMat[1][0] * Pin->m_Pos.x + + TransMat[1][1] * Pin->m_Pos.y; + + /* Dessin de la pin et du symbole special associe */ + PlotPinSymbol(x2, y2, Pin->m_PinLen, orient, Pin->m_PinShape); + wxPoint pinpos(x2, y2); + Pin->PlotPinTexts(pinpos, orient, + Entry->m_TextInside, + Entry->m_DrawPinNum, Entry->m_DrawPinName); + } + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + { + LibDrawPolyline * polyline = (LibDrawPolyline *) DEntry; + Poly = (int *) MyMalloc(sizeof(int) * 2 * polyline->n); + for (ii = 0; ii < polyline->n; ii++) + { + Poly[ii * 2] = PartX + + TransMat[0][0] * polyline->PolyList[ii * 2] + + TransMat[0][1] * polyline->PolyList[ii * 2 + 1]; + Poly[ii * 2 + 1] = PartY + + TransMat[1][0] * polyline->PolyList[ii * 2] + + TransMat[1][1] * polyline->PolyList[ii * 2 + 1]; + } + PlotPoly(ii, Poly, polyline->m_Fill); + MyFree(Poly); + } + break; + } /* Fin Switch */ + Plume('U'); + } /* Fin Boucle de dessin */ + + /* Trace des champs, avec placement et orientation selon orient. du + composant + Si la reference commence par # elle n'est pas tracee + */ + + if( (Entry->m_Prefix.m_Attributs & TEXT_NO_VISIBLE) == 0) + { + if ( Entry->m_UnitCount > 1 ) + PlotTextField(DrawLibItem,REFERENCE,1,0); + else + PlotTextField(DrawLibItem,REFERENCE,0,0); + } + + if( (Entry->m_Name.m_Attributs & TEXT_NO_VISIBLE) == 0) + PlotTextField(DrawLibItem,VALUE,0,0); + + for( ii = 2; ii < NUMBER_OF_FIELDS; ii++ ) + { + PlotTextField(DrawLibItem,ii,0,0); + } +} + +/*************************************************************/ +static void PlotTextField( EDA_SchComponentStruct *DrawLibItem, + int FieldNumber, int IsMulti, int DrawMode) +/**************************************************************/ + +/* Routine de trace des textes type Field du composant. + entree: + DrawLibItem: pointeur sur le composant + FieldNumber: Numero du champ + IsMulti: flag Non Null si il y a plusieurs parts par boitier. + n'est utile que pour le champ reference pour ajouter a celui ci + l'identification de la part ( A, B ... ) + DrawMode: mode de trace +*/ + +{ +int posX, posY; /* Position des textes */ +int px, py, x1, y1; +PartTextStruct * Field = & DrawLibItem->m_Field[FieldNumber]; +int hjustify, vjustify; +int orient, color = -1; + + if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) + color = ReturnLayerColor(Field->m_Layer); + + DrawMode = 0; /* Unused */ + if( Field->m_Attributs & TEXT_NO_VISIBLE ) return; + if( Field->IsVoid() ) return; + + /* Calcul de la position des textes, selon orientation du composant */ + orient = Field->m_Orient; + hjustify = Field->m_HJustify; vjustify = Field->m_VJustify; + posX = DrawLibItem->m_Pos.x; posY = DrawLibItem->m_Pos.y; + x1 = Field->m_Pos.x - posX; + y1 = Field->m_Pos.y - posY; + + px = posX + (DrawLibItem->m_Transform[0][0] * x1) + + (DrawLibItem->m_Transform[0][1] * y1); + py = posY + (DrawLibItem->m_Transform[1][0] * x1) + + (DrawLibItem->m_Transform[1][1] * y1); + + /* Y a t-il rotation */ + if(DrawLibItem->m_Transform[0][1]) + { + if ( orient == TEXT_ORIENT_HORIZ) orient = TEXT_ORIENT_VERT; + else orient = TEXT_ORIENT_HORIZ; + /* Y a t-il rotation, miroir (pour les justifications)*/ + EXCHG(hjustify, vjustify); + if (DrawLibItem->m_Transform[1][0] < 0 ) vjustify = - vjustify; + if (DrawLibItem->m_Transform[1][0] > 0 ) hjustify = - hjustify; + } + else + { /* Texte horizontal: Y a t-il miroir (pour les justifications)*/ + if (DrawLibItem->m_Transform[0][0] < 0 ) + hjustify = - hjustify; + if (DrawLibItem->m_Transform[1][1] > 0 ) + vjustify = - vjustify; + } + + if( !IsMulti || (FieldNumber != REFERENCE) ) + { + PlotGraphicText( g_PlotFormat, wxPoint(px, py), color, Field->m_Text, + orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, + hjustify, vjustify); + } + + else /* Le champ est la reference, et il y a plusieurs parts par boitier */ + { /* On ajoute alors A ou B ... a la reference */ + wxString Text; + Text = Field->m_Text; + Text.Append('A' - 1 + DrawLibItem->m_Multi); + PlotGraphicText( g_PlotFormat, wxPoint(px, py), color, Text, + orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + Field->m_Size, hjustify, vjustify); + } +} + + +/**************************************************************************/ +static void PlotPinSymbol(int posX, int posY, int len, int orient, int Shape) +/**************************************************************************/ +/* Trace la pin du symbole en cours de trace +*/ +{ +int MapX1, MapY1, x1, y1; +int color; + + color = ReturnLayerColor(LAYER_PIN); + + if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) + SetColorMapPS ( color ); + + MapX1 = MapY1 = 0; x1 = posX; y1 = posY; + switch ( orient ) + { + case PIN_UP: + y1 = posY - len; MapY1 = 1; + break; + case PIN_DOWN: + y1 = posY + len; MapY1 = -1; + break; + case PIN_LEFT: + x1 = posX - len, MapX1 = 1; + break; + case PIN_RIGHT: + x1 = posX + len; MapX1 = -1; + break; + } + + if( Shape & INVERT) + { + PlotCercle( wxPoint(MapX1 * INVERT_PIN_RADIUS + x1, + MapY1 * INVERT_PIN_RADIUS + y1), + INVERT_PIN_RADIUS * 2 ); + + Move_Plume( wxPoint(MapX1 * INVERT_PIN_RADIUS * 2 + x1, + MapY1 * INVERT_PIN_RADIUS * 2 + y1), 'U' ); + Move_Plume(wxPoint(posX, posY), 'D' ); + } + else + { + Move_Plume(wxPoint(x1, y1), 'U' ); + Move_Plume(wxPoint(posX, posY), 'D' ); + } + + if(Shape & CLOCK) + { + if(MapY1 == 0 ) /* MapX1 = +- 1 */ + { + Move_Plume(wxPoint(x1, y1 + CLOCK_PIN_DIM), 'U' ); + Move_Plume(wxPoint(x1 - MapX1 * CLOCK_PIN_DIM, y1), 'D' ); + Move_Plume(wxPoint(x1, y1 - CLOCK_PIN_DIM), 'D' ); + } + else /* MapX1 = 0 */ + { + Move_Plume( wxPoint(x1 + CLOCK_PIN_DIM, y1), 'U' ); + Move_Plume( wxPoint(x1, y1 - MapY1 * CLOCK_PIN_DIM), 'D' ); + Move_Plume( wxPoint(x1 - CLOCK_PIN_DIM, y1), 'D' ); + } + } + + if(Shape & LOWLEVEL_IN) /* IEEE symbol "Active Low Input" */ + { + if(MapY1 == 0 ) /* MapX1 = +- 1 */ + { + Move_Plume(wxPoint(x1 + MapX1 * IEEE_SYMBOL_PIN_DIM*2, y1), 'U'); + Move_Plume(wxPoint(x1 + MapX1 * IEEE_SYMBOL_PIN_DIM*2, + y1 - IEEE_SYMBOL_PIN_DIM), 'D'); + Move_Plume( wxPoint(x1, y1), 'D' ); + } + else /* MapX1 = 0 */ + { + Move_Plume( wxPoint(x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM*2), 'U'); + Move_Plume(wxPoint(x1 - IEEE_SYMBOL_PIN_DIM, + y1 + MapY1 * IEEE_SYMBOL_PIN_DIM*2), 'D'); + Move_Plume(wxPoint(x1, y1), 'D'); + } + } + + + if(Shape & LOWLEVEL_OUT) /* IEEE symbol "Active Low Output" */ + { + if(MapY1 == 0 ) /* MapX1 = +- 1 */ + { + Move_Plume(wxPoint(x1, y1 - IEEE_SYMBOL_PIN_DIM), 'U' ); + Move_Plume(wxPoint(x1 + MapX1 * IEEE_SYMBOL_PIN_DIM*2, y1), 'D' ); + } + else /* MapX1 = 0 */ + { + Move_Plume(wxPoint(x1 - IEEE_SYMBOL_PIN_DIM, y1), 'U'); + Move_Plume(wxPoint(x1 , y1 + MapY1 * IEEE_SYMBOL_PIN_DIM*2),'D' ); + } + } + Plume('U'); +} + + +/*******************************************/ +void PlotTextStruct(EDA_BaseStruct *Struct) +/*******************************************/ +/* + Routine de trace des Textes, Labels et Global-Labels. + Les textes peuvent avoir 4 directions. +*/ +{ +int * Template; +int Poly[50]; +int ii, pX, pY, Shape = 0, Orient = 0, offset; +wxSize Size; +wxString Text; +int color = -1; +int HalfSize; + + switch ( Struct->m_StructType ) + { + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + Text = ((DrawTextStruct*)Struct)->m_Text; + Size = ((DrawTextStruct*)Struct)->m_Size; + Orient = ((DrawTextStruct*)Struct)->m_Orient; + Shape = ((DrawTextStruct*)Struct)->m_Shape; + pX = ((DrawTextStruct*)Struct)->m_Pos.x; + pY = ((DrawTextStruct*)Struct)->m_Pos.y; + offset = TXTMARGE; + if ( Struct->m_StructType == DRAW_GLOBAL_LABEL_STRUCT_TYPE) + offset += Size.x; // We must draw the Glabel graphoc symbol + if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) + color = ReturnLayerColor(((DrawTextStruct*)Struct)->m_Layer); + break; + + default: return; + } + + if(Size.x == 0 ) Size = wxSize(DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT); + + switch(Orient) + { + case 0: /* Orientation horiz normale */ + if( Struct->m_StructType == DRAW_GLOBAL_LABEL_STRUCT_TYPE ) + PlotGraphicText(g_PlotFormat, wxPoint(pX - offset, pY), + color, Text, TEXT_ORIENT_HORIZ, Size, + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER); + else + PlotGraphicText(g_PlotFormat, wxPoint(pX, pY - offset), + color, Text, TEXT_ORIENT_HORIZ, Size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM); + break; + + case 1: /* Orientation vert UP */ + if( Struct->m_StructType == DRAW_GLOBAL_LABEL_STRUCT_TYPE ) + PlotGraphicText(g_PlotFormat, wxPoint(pX, pY + offset), + color, Text, TEXT_ORIENT_VERT, Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP); + else + PlotGraphicText( g_PlotFormat, wxPoint(pX - offset, pY), + color, Text, TEXT_ORIENT_VERT, Size, + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM); + break; + + case 2: /* Orientation horiz inverse */ + if( Struct->m_StructType == DRAW_GLOBAL_LABEL_STRUCT_TYPE) + PlotGraphicText(g_PlotFormat, wxPoint(pX + offset, pY), + color, Text, TEXT_ORIENT_HORIZ, Size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + else + PlotGraphicText(g_PlotFormat, wxPoint(pX, pY + offset), + color, Text, 1800, Size, + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_TOP); + break; + + case 3: /* Orientation vert BOTTOM */ + if( Struct->m_StructType == DRAW_GLOBAL_LABEL_STRUCT_TYPE) + PlotGraphicText(g_PlotFormat, wxPoint(pX, pY - offset), + color, Text, 2700, Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM); + else + PlotGraphicText(g_PlotFormat, wxPoint(pX + offset, pY), + color, Text, 2700, Size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP); + break; + } + + /* Trace du symbole associe au label global */ + if( Struct->m_StructType == DRAW_GLOBAL_LABEL_STRUCT_TYPE) + { + int jj, imax; + HalfSize = Size.x / 2; + Template = TemplateShape[Shape][Orient]; + imax = *Template; Template++; + + for ( ii = 0, jj = 0; ii < imax ; ii++ ) + { + Poly[jj] = ( HalfSize * (*Template) ) + pX; + jj ++; Template++; + Poly[jj] = ( HalfSize * (*Template) ) + pY; + jj ++; Template++; + } + PlotPoly(imax,Poly,NOFILL ); + } +} + +/***********************************************************/ +static void PlotSheetLabelStruct(DrawSheetLabelStruct *Struct) +/***********************************************************/ +/* Routine de dessin des Sheet Labels type hierarchie */ +{ +int side, txtcolor = -1; +int posx , tposx, posy, size, size2; +int coord[12]; + + if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) + txtcolor = ReturnLayerColor(Struct->m_Layer); + + posx = Struct->m_Pos.x; posy = Struct->m_Pos.y; size = Struct->m_Size.x; + if( Struct->m_Edge ) + { + tposx = posx - size; + side = GR_TEXT_HJUSTIFY_RIGHT; + } + else { + tposx = posx + size + (size /8) ; + side = GR_TEXT_HJUSTIFY_LEFT; + } + PlotGraphicText(g_PlotFormat, wxPoint(tposx, posy), txtcolor, + Struct->m_Text, TEXT_ORIENT_HORIZ, wxSize(size,size), + side, GR_TEXT_VJUSTIFY_CENTER); + /* dessin du symbole de connexion */ + + if(Struct->m_Edge) size = -size; + coord[0] = posx; coord[1] = posy; size2 = size /2; + switch(Struct->m_Shape) + { + case 0: /* input |> */ + coord[2] = posx ; coord[3] = posy - size2; + coord[4] = posx + size2; coord[5] = posy - size2; + coord[6] = posx + size; coord[7] = posy; + coord[8] = posx + size2; coord[9] = posy + size2; + coord[10] = posx ; coord[11] = posy + size2; + PlotPoly(6, coord, FILL); + break; + + case 1: /* output <| */ + coord[2] = posx + size2; coord[3] = posy - size2; + coord[4] = posx + size; coord[5] = posy - size2; + coord[6] = posx + size; coord[7] = posy + size2; + coord[8] = posx + size2; coord[9] = posy + size2; + PlotPoly(5, coord, FILL); + break; + + case 2: /* bidi <> */ + case 3: /* TriSt <> */ + coord[2] = posx + size2; coord[3] = posy - size2; + coord[4] = posx + size; coord[5] = posy; + coord[6] = posx + size2; coord[7] = posy +size2; + PlotPoly(4, coord, FILL); + break; + + default: /* unsp []*/ + coord[2] = posx ; coord[3] = posy - size2; + coord[4] = posx + size; coord[5] = posy - size2; + coord[6] = posx + size; coord[7] = posy + size2; + coord[8] = posx ; coord[9] = posy + size2; + PlotPoly(5, coord, NOFILL); + break; + } +} + +/*************************************************/ +void PlotSheetStruct(DrawSheetStruct *Struct) +/*************************************************/ +/* Routine de dessin du bloc type hierarchie */ +{ +DrawSheetLabelStruct * SheetLabelStruct; +int txtcolor = -1; +wxSize size; +wxString Text; +wxPoint pos; + + if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) + SetColorMapPS ( ReturnLayerColor(Struct->m_Layer) ); + Move_Plume(Struct->m_Pos, 'U'); + pos = Struct->m_Pos; pos.x += Struct->m_Size.x; + Move_Plume(pos,'D'); + pos.y += Struct->m_Size.y; + Move_Plume(pos, 'D'); + pos = Struct->m_Pos; pos.y += Struct->m_Size.y; + Move_Plume(pos,'D'); + Move_Plume(Struct->m_Pos, 'D'); + Plume('U'); + + /* Trace des textes : SheetName */ + Text = Struct->m_SheetName; + size = wxSize(Struct->m_SheetNameSize,Struct->m_SheetNameSize); + pos = Struct->m_Pos; pos.y -= 4; + if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) + SetColorMapPS ( ReturnLayerColor(LAYER_SHEETNAME) ); + PlotGraphicText(g_PlotFormat, pos, txtcolor, + Text, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM); + + /* Trace des textes : FileName */ + Text = Struct->m_FileName; + size = wxSize(Struct->m_FileNameSize,Struct->m_FileNameSize); + if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) + SetColorMapPS ( ReturnLayerColor(LAYER_SHEETFILENAME) ); + PlotGraphicText(g_PlotFormat, wxPoint(Struct->m_Pos.x, Struct->m_Pos.y + Struct->m_Size.y + 4), + txtcolor, + Text, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP); + + /* Trace des textes : SheetLabel */ + SheetLabelStruct = Struct->m_Label; + if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) + SetColorMapPS ( ReturnLayerColor(Struct->m_Layer) ); + while( SheetLabelStruct != NULL ) + { + PlotSheetLabelStruct(SheetLabelStruct); + SheetLabelStruct = (DrawSheetLabelStruct*)(SheetLabelStruct->Pnext); + } +} + diff --git a/eeschema/plothpgl.cpp b/eeschema/plothpgl.cpp new file mode 100644 index 0000000000..07055398af --- /dev/null +++ b/eeschema/plothpgl.cpp @@ -0,0 +1,713 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: plothpgl.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 04/02/2006 16:54:19 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 04/02/2006 16:54:19 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "plothpgl.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "worksheet.h" +#include "plot_common.h" + +#include "protos.h" + +/* coeff de conversion dim en 1 mil -> dim en unite HPGL: */ +#define SCALE_HPGL 1.02041 + +#include "plothpgl.h" + +////@begin XPM images + +////@end XPM images + +extern void Move_Plume( wxPoint pos, int plume ); +extern void Plume( int plume ); + +/* Variables locales : */ +FILE * PlotOutput; /* exportee dans printps.cc */ +static double Scale_X = 1; +static double Scale_Y = 1; +int HPGL_SizeSelect; + +enum PageFormatReq { + PAGE_DEFAULT = 0, + PAGE_SIZE_A4, + PAGE_SIZE_A3, + PAGE_SIZE_A2, + PAGE_SIZE_A1, + PAGE_SIZE_A0, + PAGE_SIZE_A, + PAGE_SIZE_B, + PAGE_SIZE_C, + PAGE_SIZE_D, + PAGE_SIZE_E +}; + +static Ki_PageDescr * Plot_sheet_list[] = +{ + NULL, + &g_Sheet_A4, + &g_Sheet_A3, + &g_Sheet_A2, + &g_Sheet_A1, + &g_Sheet_A0, + &g_Sheet_A, + &g_Sheet_B, + &g_Sheet_C, + &g_Sheet_D, + &g_Sheet_E, + &g_Sheet_GERBER, + &g_Sheet_user +}; + +/* Routines Locales */ + + + + +/**************************************************************/ +void WinEDA_SchematicFrame::ToPlot_HPGL(wxCommandEvent& event) +/**************************************************************/ +{ + WinEDA_PlotHPGLFrame * HPGL_frame = new WinEDA_PlotHPGLFrame(this); + HPGL_frame->ShowModal(); + HPGL_frame->Destroy(); +} + +/*! + * WinEDA_PlotHPGLFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_PlotHPGLFrame, wxDialog ) + +/*! + * WinEDA_PlotHPGLFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_PlotHPGLFrame, wxDialog ) + +////@begin WinEDA_PlotHPGLFrame event table entries + EVT_RADIOBOX( ID_RADIOBOX, WinEDA_PlotHPGLFrame::OnRadioboxSelected ) + + EVT_SPINCTRL( ID_PEN_WIDTH_UPDATED, WinEDA_PlotHPGLFrame::OnPenWidthUpdatedUpdated ) + + EVT_SPINCTRL( ID_PEN_SPEED_UPDATED, WinEDA_PlotHPGLFrame::OnPenSpeedUpdatedUpdated ) + + EVT_SPINCTRL( ID_PEN_NUMBER_UPDATED, WinEDA_PlotHPGLFrame::OnPenNumberUpdatedUpdated ) + + EVT_BUTTON( ID_PLOT_HPGL_CURRENT_EXECUTE, WinEDA_PlotHPGLFrame::OnPlotHpglCurrentExecuteClick ) + + EVT_BUTTON( ID_PLOT_HPGL_ALL_EXECUTE, WinEDA_PlotHPGLFrame::OnPlotHpglAllExecuteClick ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_PlotHPGLFrame::OnCancelClick ) + + EVT_BUTTON( ID_PLOT_ACCEPT_OFFSET, WinEDA_PlotHPGLFrame::OnPlotAcceptOffsetClick ) + +////@end WinEDA_PlotHPGLFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_PlotHPGLFrame constructors + */ + +WinEDA_PlotHPGLFrame::WinEDA_PlotHPGLFrame( ) +{ +} + +WinEDA_PlotHPGLFrame::WinEDA_PlotHPGLFrame( WinEDA_DrawFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + Create(parent, id, caption, pos, size, style); + SetPageOffsetValue(); +} + +/*! + * WinEDA_PlotHPGLFrame creator + */ + +bool WinEDA_PlotHPGLFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_PlotHPGLFrame member initialisation + m_SizeOption = NULL; + m_ButtPenWidth = NULL; + m_ButtPenSpeed = NULL; + m_ButtPenNum = NULL; + m_PlotOrgPosition_X = NULL; + m_PlotOrgPosition_Y = NULL; + m_MsgBox = NULL; +////@end WinEDA_PlotHPGLFrame member initialisation + +////@begin WinEDA_PlotHPGLFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_PlotHPGLFrame creation + return true; +} + +/*! + * Control creation for WinEDA_PlotHPGLFrame + */ + +void WinEDA_PlotHPGLFrame::CreateControls() +{ + SetFont(*g_DialogFont); +////@begin WinEDA_PlotHPGLFrame content construction + // Generated by DialogBlocks, 04/02/2006 16:54:19 (unregistered) + + WinEDA_PlotHPGLFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer4, 0, wxGROW|wxALL, 5); + + wxString m_SizeOptionStrings[] = { + _("Sheet Size"), + _("Page Size A4"), + _("Page Size A3"), + _("Page Size A2"), + _("Page Size A1"), + _("Page Size A0"), + _("Page Size A"), + _("Page Size B"), + _("Page Size C"), + _("Page Size D"), + _("Page Size E") + }; + m_SizeOption = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Plot page size:"), wxDefaultPosition, wxDefaultSize, 11, m_SizeOptionStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer4->Add(m_SizeOption, 0, wxALIGN_LEFT|wxALL, 5); + + wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer6, 0, wxALIGN_TOP|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer7Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Pen control:")); + wxStaticBoxSizer* itemStaticBoxSizer7 = new wxStaticBoxSizer(itemStaticBoxSizer7Static, wxVERTICAL); + itemBoxSizer6->Add(itemStaticBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxStaticText* itemStaticText8 = new wxStaticText( itemDialog1, wxID_STATIC, _("Pen Width ( mils )"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer7->Add(itemStaticText8, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_ButtPenWidth = new wxSpinCtrl( itemDialog1, ID_PEN_WIDTH_UPDATED, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_WRAP, 1, 100, 0 ); + itemStaticBoxSizer7->Add(m_ButtPenWidth, 0, wxALIGN_LEFT|wxALL, 5); + + wxStaticText* itemStaticText10 = new wxStaticText( itemDialog1, wxID_STATIC, _("Pen Speed ( cm/s )"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer7->Add(itemStaticText10, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_ButtPenSpeed = new wxSpinCtrl( itemDialog1, ID_PEN_SPEED_UPDATED, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 100, 0 ); + itemStaticBoxSizer7->Add(m_ButtPenSpeed, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxStaticText* itemStaticText12 = new wxStaticText( itemDialog1, wxID_STATIC, _("Pen Number"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer7->Add(itemStaticText12, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_ButtPenNum = new wxSpinCtrl( itemDialog1, ID_PEN_NUMBER_UPDATED, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 8, 0 ); + itemStaticBoxSizer7->Add(m_ButtPenNum, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer14Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Page offset:")); + wxStaticBoxSizer* itemStaticBoxSizer14 = new wxStaticBoxSizer(itemStaticBoxSizer14Static, wxVERTICAL); + itemBoxSizer6->Add(itemStaticBoxSizer14, 0, wxALIGN_LEFT|wxALL, 5); + + wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, wxID_STATIC, _("Plot Offset X"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer14->Add(itemStaticText15, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_PlotOrgPosition_X = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer14->Add(m_PlotOrgPosition_X, 0, wxALIGN_LEFT|wxALL, 5); + + wxStaticText* itemStaticText17 = new wxStaticText( itemDialog1, wxID_STATIC, _("Plot Offset Y"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer14->Add(itemStaticText17, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_PlotOrgPosition_Y = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer14->Add(m_PlotOrgPosition_Y, 0, wxALIGN_LEFT|wxALL, 5); + + itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer20, 0, wxALIGN_TOP|wxLEFT|wxTOP|wxBOTTOM, 5); + + wxButton* itemButton21 = new wxButton( itemDialog1, ID_PLOT_HPGL_CURRENT_EXECUTE, _("&Plot CURRENT"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton21->SetForegroundColour(wxColour(0, 128, 0)); + itemBoxSizer20->Add(itemButton21, 0, wxGROW|wxALL, 5); + + wxButton* itemButton22 = new wxButton( itemDialog1, ID_PLOT_HPGL_ALL_EXECUTE, _("Plot A&LL"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton22->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer20->Add(itemButton22, 0, wxGROW|wxALL, 5); + + wxButton* itemButton23 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton23->SetForegroundColour(wxColour(128, 0, 0)); + itemBoxSizer20->Add(itemButton23, 0, wxGROW|wxALL, 5); + + itemBoxSizer20->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxButton* itemButton25 = new wxButton( itemDialog1, ID_PLOT_ACCEPT_OFFSET, _("&Accept Offset"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton25->SetForegroundColour(wxColour(101, 123, 68)); + itemBoxSizer20->Add(itemButton25, 0, wxGROW|wxALL, 5); + + m_MsgBox = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(-1, 110), wxTE_MULTILINE ); + itemBoxSizer2->Add(m_MsgBox, 0, wxGROW|wxALL, 5); + + + // Set validators + m_SizeOption->SetValidator( wxGenericValidator(& HPGL_SizeSelect) ); + m_ButtPenWidth->SetValidator( wxGenericValidator(& g_HPGL_Pen_Descr.m_Pen_Diam) ); + m_ButtPenSpeed->SetValidator( wxGenericValidator(& g_HPGL_Pen_Descr.m_Pen_Speed) ); + m_ButtPenNum->SetValidator( wxGenericValidator(& g_HPGL_Pen_Descr.m_Pen_Num) ); +////@end WinEDA_PlotHPGLFrame content construction +} + + + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PLOT_HPGL_CURRENT_EXECUTE + */ + +void WinEDA_PlotHPGLFrame::OnPlotHpglCurrentExecuteClick( wxCommandEvent& event ) +{ + HPGL_Plot(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PLOT_HPGL_ALL_EXECUTE + */ + +void WinEDA_PlotHPGLFrame::OnPlotHpglAllExecuteClick( wxCommandEvent& event ) +{ + HPGL_Plot(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_PlotHPGLFrame::OnCancelClick( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_PlotHPGLFrame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_PlotHPGLFrame. +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PLOT_ACCEPT_OFFSET + */ + +void WinEDA_PlotHPGLFrame::OnPlotAcceptOffsetClick( wxCommandEvent& event ) +{ + AcceptPlotOffset(event); +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_PlotHPGLFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_PlotHPGLFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_PlotHPGLFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_PlotHPGLFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_PlotHPGLFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_PlotHPGLFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_PlotHPGLFrame icon retrieval +} + + + +/***************************************************/ +void WinEDA_PlotHPGLFrame::SetPageOffsetValue(void) +/***************************************************/ +{ +wxString msg; + if ( HPGL_SizeSelect != PAGE_DEFAULT ) + { + msg = ReturnStringFromValue(g_UnitMetric, + Plot_sheet_list[HPGL_SizeSelect]->m_Offset.x, EESCHEMA_INTERNAL_UNIT); + m_PlotOrgPosition_X->SetValue(msg); + msg = ReturnStringFromValue(g_UnitMetric, + Plot_sheet_list[HPGL_SizeSelect]->m_Offset.y, EESCHEMA_INTERNAL_UNIT); + m_PlotOrgPosition_Y->SetValue(msg); + + m_PlotOrgPosition_X->Enable(TRUE); + m_PlotOrgPosition_Y->Enable(TRUE); + + } + else + { + m_PlotOrgPosition_X->Enable(FALSE); + m_PlotOrgPosition_Y->Enable(FALSE); + } +} + +/*****************************************************************/ +void WinEDA_PlotHPGLFrame::AcceptPlotOffset(wxCommandEvent& event) +/*****************************************************************/ +{ +int ii = m_SizeOption->GetSelection(); + + if ( ii <= 0 ) HPGL_SizeSelect = 0; + else HPGL_SizeSelect = ii; + + if ( HPGL_SizeSelect != PAGE_DEFAULT) + { + wxString msg = m_PlotOrgPosition_X->GetValue(); + Plot_sheet_list[HPGL_SizeSelect]->m_Offset.x = + ReturnValueFromString(g_UnitMetric, msg, EESCHEMA_INTERNAL_UNIT); + msg = m_PlotOrgPosition_Y->GetValue(); + Plot_sheet_list[HPGL_SizeSelect]->m_Offset.y = + ReturnValueFromString(g_UnitMetric, msg, EESCHEMA_INTERNAL_UNIT); + } +} + + +/************************************************************/ +void WinEDA_PlotHPGLFrame::SetPenWidth(wxSpinEvent & event) +/************************************************************/ +{ + g_HPGL_Pen_Descr.m_Pen_Diam = m_ButtPenWidth->GetValue(); + if ( g_HPGL_Pen_Descr.m_Pen_Diam > 100 ) g_HPGL_Pen_Descr.m_Pen_Diam = 100; + if ( g_HPGL_Pen_Descr.m_Pen_Diam < 1 ) g_HPGL_Pen_Descr.m_Pen_Diam = 1; +} + + +/*********************************************************/ +void WinEDA_PlotHPGLFrame::SetPenSpeed(wxSpinEvent& event) +/*********************************************************/ +{ + g_HPGL_Pen_Descr.m_Pen_Speed = m_ButtPenSpeed->GetValue(); + if ( g_HPGL_Pen_Descr.m_Pen_Speed > 40 ) g_HPGL_Pen_Descr.m_Pen_Speed = 40; + if ( g_HPGL_Pen_Descr.m_Pen_Speed < 1 ) g_HPGL_Pen_Descr.m_Pen_Speed = 1; +} + +/*******************************************************/ +void WinEDA_PlotHPGLFrame::SetPenNum(wxSpinEvent& event) +/*******************************************************/ +{ + g_HPGL_Pen_Descr.m_Pen_Num = m_ButtPenNum->GetValue(); + if ( g_HPGL_Pen_Descr.m_Pen_Num > 8 ) g_HPGL_Pen_Descr.m_Pen_Num = 8; + if ( g_HPGL_Pen_Descr.m_Pen_Num < 1 ) g_HPGL_Pen_Descr.m_Pen_Num = 1; +} + + +/***********************************************************/ +void WinEDA_PlotHPGLFrame::HPGL_Plot(wxCommandEvent& event) +/***********************************************************/ +{ +int Select_PlotAll = FALSE; + + if( event.GetId() == ID_PLOT_HPGL_ALL_EXECUTE ) Select_PlotAll = TRUE; + + if ( HPGL_SizeSelect ) + { + wxString msg = m_PlotOrgPosition_X->GetValue(); + Plot_sheet_list[HPGL_SizeSelect]->m_Offset.x = + ReturnValueFromString(g_UnitMetric, msg, EESCHEMA_INTERNAL_UNIT); + msg = m_PlotOrgPosition_Y->GetValue(); + Plot_sheet_list[HPGL_SizeSelect]->m_Offset.y = + ReturnValueFromString(g_UnitMetric, msg, EESCHEMA_INTERNAL_UNIT); + } + + Plot_Schematic_HPGL(Select_PlotAll, HPGL_SizeSelect); +} + +/*******************************************************************/ +void WinEDA_PlotHPGLFrame::ReturnSheetDims( BASE_SCREEN * screen, + wxSize & SheetSize, wxPoint & SheetOffset) +/*******************************************************************/ +/* Fonction calculant les dims et offsets de trace de la feuille selectionnee + retourne: +*/ +{ +Ki_PageDescr * PlotSheet; + + if( screen == NULL ) screen = ActiveScreen; + + PlotSheet = screen->m_CurrentSheet; + + SheetSize = PlotSheet->m_Size; + SheetOffset = PlotSheet->m_Offset; +} + +/***********************************************************************************/ +void WinEDA_PlotHPGLFrame::Plot_Schematic_HPGL(int Select_PlotAll, int HPGL_SheetSize) +/***********************************************************************************/ +{ +wxString PlotFileName, ShortFileName; +BASE_SCREEN *screen; +Ki_PageDescr * PlotSheet; +wxSize SheetSize; +wxPoint SheetOffset, PlotOffset; +int margin; + + g_PlotFormat = PLOT_FORMAT_HPGL; + + screen = ActiveScreen; + if ( Select_PlotAll == TRUE ) + { + screen = ScreenSch; + } + while( screen ) + { + ReturnSheetDims(screen, SheetSize, SheetOffset); + /* Calcul des echelles de conversion */ + g_PlotScaleX = Scale_X * SCALE_HPGL ; + g_PlotScaleY = Scale_Y * SCALE_HPGL ; + + margin = 400; // Margin in mils + PlotSheet = screen->m_CurrentSheet; + g_PlotScaleX = g_PlotScaleX * (SheetSize.x - 2 * margin)/ PlotSheet->m_Size.x; + g_PlotScaleY = g_PlotScaleY * (SheetSize.y - 2 * margin) / PlotSheet->m_Size.y; + + /* calcul des offsets */ + PlotOffset.x = - (int)(SheetOffset.x * SCALE_HPGL); + PlotOffset.y = (int)( (SheetOffset.y + SheetSize.y) * SCALE_HPGL); + PlotOffset.x -= (int)(margin * SCALE_HPGL); + PlotOffset.y += (int)(margin * SCALE_HPGL); + + wxSplitPath(screen->m_FileName.GetData(), (wxString*) NULL, + &ShortFileName, (wxString*) NULL); + wxString dirbuf = wxGetCwd() + STRING_DIR_SEP; + if( ! ShortFileName.IsEmpty() ) + PlotFileName = MakeFileName(dirbuf, ShortFileName, wxT(".plt")); + else PlotFileName = MakeFileName(dirbuf, g_DefaultSchematicFileName, wxT(".plt")); + + InitPlotParametresHPGL(PlotOffset, g_PlotScaleX, g_PlotScaleY); + Plot_1_Page_HPGL(PlotFileName,screen); + screen = (BASE_SCREEN*)screen->Pnext; + if ( Select_PlotAll == FALSE ) screen = NULL; + } + + m_MsgBox->AppendText(_("** Plot End **\n")); +} + + +/**************************************************************************/ +void WinEDA_PlotHPGLFrame::Plot_1_Page_HPGL(const wxString & FullFileName, + BASE_SCREEN * screen) +/**************************************************************************/ + +/* Trace en format HPGL. d'une feuille de dessin + 1 unite HPGL = 0.98 mils ( 1 mil = 1.02041 unite HPGL ) . +*/ +{ +EDA_BaseStruct *DrawList; +EDA_SchComponentStruct *DrawLibItem; +int x1=0, y1=0, x2=0, y2=0, layer; +wxString msg; + + PlotOutput = wxFopen(FullFileName, wxT("wt")); + if (PlotOutput == 0) + { + msg = _("Unable to create ") + FullFileName; + DisplayError(this, msg); return ; + } + + msg = _("Plot ") + FullFileName + wxT("\n"); + m_MsgBox->AppendText(msg); + + /* Init : */ + PrintHeaderHPGL(PlotOutput, g_HPGL_Pen_Descr.m_Pen_Speed, g_HPGL_Pen_Descr.m_Pen_Num); + + PlotWorkSheet(PLOT_FORMAT_HPGL, screen); + + DrawList = screen->EEDrawList; + while ( DrawList ) /* tracage */ + { + Plume('U'); + layer = LAYER_NOTES; + switch( DrawList->m_StructType ) + { + case DRAW_BUSENTRY_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((DrawBusEntryStruct*)DrawList) + x1 = STRUCT->m_Pos.x; y1 = STRUCT->m_Pos.y; + x2 = STRUCT->m_End().x; y2 = STRUCT->m_End().y; + layer = STRUCT->m_Layer; + case DRAW_SEGMENT_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((EDA_DrawLineStruct*)DrawList) + if ( DrawList->m_StructType == DRAW_SEGMENT_STRUCT_TYPE) + { + x1 = STRUCT->m_Start.x; y1 = STRUCT->m_Start.y; + x2 = STRUCT->m_End.x; y2 = STRUCT->m_End.y; + layer = STRUCT->m_Layer; + } + switch (layer) + { + case LAYER_NOTES: /* Trace en pointilles */ + Move_Plume( wxPoint(x1,y1),'U'); + fprintf(PlotOutput,"LT 2;\n"); + Move_Plume( wxPoint(x2,y2),'D'); + fprintf(PlotOutput,"LT;\n"); + break; + + case LAYER_BUS: /* Trait large */ + { + int deltaX = 0, deltaY = 0; double angle; + if( (x2 - x1) == 0 ) deltaX = 8; + else if( (y2 - y1) == 0 ) deltaY = 8; + else + { + angle = atan2( (double)(x2-x1), (double)(y1-y2) ); + deltaX = (int)( 8 * sin(angle) ); + deltaY = (int)( 8 * cos(angle) ); + } + Move_Plume( wxPoint(x1 + deltaX, y1 - deltaY), 'U'); + Move_Plume( wxPoint(x1 - deltaX,y1 + deltaY), 'D'); + Move_Plume( wxPoint(x2 - deltaX,y2 + deltaY), 'D'); + Move_Plume( wxPoint(x2 + deltaX,y2 - deltaY), 'D'); + Move_Plume( wxPoint(x1 + deltaX,y1 - deltaY), 'D'); + } + break; + + default: + Move_Plume( wxPoint(x1,y1), 'U'); + Move_Plume( wxPoint(x2,y2), 'D'); + break; + } + break; + + case DRAW_JUNCTION_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((DrawJunctionStruct*)DrawList) + x1 = STRUCT->m_Pos.x; y1 = STRUCT->m_Pos.y; + PlotCercle( wxPoint(x1,y1), DRAWJUNCTION_SIZE * 2); + break; + + case DRAW_TEXT_STRUCT_TYPE : + case DRAW_LABEL_STRUCT_TYPE : + case DRAW_GLOBAL_LABEL_STRUCT_TYPE : + PlotTextStruct(DrawList); + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE : + DrawLibItem = (EDA_SchComponentStruct *) DrawList; + PlotLibPart( DrawLibItem ); + break; + + case DRAW_PICK_ITEM_STRUCT_TYPE : break; + case DRAW_POLYLINE_STRUCT_TYPE : break; + case DRAW_SHEETLABEL_STRUCT_TYPE : break; + case DRAW_MARKER_STRUCT_TYPE : break; + + case DRAW_SHEET_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((DrawSheetStruct*)DrawList) + PlotSheetStruct(STRUCT); + break; + + case DRAW_NOCONNECT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawNoConnectStruct*)DrawList) + PlotNoConnectStruct(STRUCT); + break; + + default : + break; + } + + Plume('U'); + DrawList = DrawList->Pnext; + } + + /* fin */ + CloseFileHPGL(PlotOutput); +} + +/*! + * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX + */ + +void WinEDA_PlotHPGLFrame::OnRadioboxSelected( wxCommandEvent& event ) +{ + HPGL_SizeSelect = m_SizeOption->GetSelection(); + SetPageOffsetValue(); +} + + + + +/*! + * wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_PEN_WIDTH_UPDATED + */ + +void WinEDA_PlotHPGLFrame::OnPenWidthUpdatedUpdated( wxSpinEvent& event ) +{ + SetPenWidth(event); +} + +/*! + * wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_PEN_SPEED_UPDATED + */ + +void WinEDA_PlotHPGLFrame::OnPenSpeedUpdatedUpdated( wxSpinEvent& event ) +{ + SetPenSpeed(event); +} + +/*! + * wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_PEN_NUMBER_UPDATED + */ + +void WinEDA_PlotHPGLFrame::OnPenNumberUpdatedUpdated( wxSpinEvent& event ) +{ + SetPenNum(event); +} + diff --git a/eeschema/plothpgl.h b/eeschema/plothpgl.h new file mode 100644 index 0000000000..a6c8e2e60f --- /dev/null +++ b/eeschema/plothpgl.h @@ -0,0 +1,151 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: plothpgl.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 04/02/2006 16:54:19 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 04/02/2006 16:54:19 + +#ifndef _PLOTHPGL_H_ +#define _PLOTHPGL_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "plothpgl.h" +#endif + +/*! + * Includes + */ + +////@begin includes +#include "wx/valgen.h" +#include "wx/spinctrl.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +class wxSpinCtrl; +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_PLOTHPGLFRAME_STYLE wxDEFAULT_DIALOG_STYLE|wxCAPTION|wxSYSTEM_MENU|wxSTAY_ON_TOP|wxCLOSE_BOX +#define SYMBOL_WINEDA_PLOTHPGLFRAME_TITLE _("EESchema Plot HPGL") +#define SYMBOL_WINEDA_PLOTHPGLFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_PLOTHPGLFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_PLOTHPGLFRAME_POSITION wxDefaultPosition +#define ID_RADIOBOX 10001 +#define ID_PEN_WIDTH_UPDATED 10002 +#define ID_PEN_SPEED_UPDATED 10003 +#define ID_PEN_NUMBER_UPDATED 10004 +#define ID_TEXTCTRL1 10010 +#define ID_TEXTCTRL2 10009 +#define ID_PLOT_HPGL_CURRENT_EXECUTE 10005 +#define ID_PLOT_HPGL_ALL_EXECUTE 10006 +#define ID_PLOT_ACCEPT_OFFSET 10008 +#define ID_TEXTCTRL 10007 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_PlotHPGLFrame class declaration + */ + +class WinEDA_PlotHPGLFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_PlotHPGLFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_PlotHPGLFrame( ); + WinEDA_PlotHPGLFrame( WinEDA_DrawFrame* parent, wxWindowID id = SYMBOL_WINEDA_PLOTHPGLFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PLOTHPGLFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PLOTHPGLFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PLOTHPGLFRAME_SIZE, long style = SYMBOL_WINEDA_PLOTHPGLFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PLOTHPGLFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PLOTHPGLFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PLOTHPGLFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PLOTHPGLFRAME_SIZE, long style = SYMBOL_WINEDA_PLOTHPGLFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_PlotHPGLFrame event handler declarations + /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX + void OnRadioboxSelected( wxCommandEvent& event ); + + /// wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_PEN_WIDTH_UPDATED + void OnPenWidthUpdatedUpdated( wxSpinEvent& event ); + + /// wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_PEN_SPEED_UPDATED + void OnPenSpeedUpdatedUpdated( wxSpinEvent& event ); + + /// wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_PEN_NUMBER_UPDATED + void OnPenNumberUpdatedUpdated( wxSpinEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PLOT_HPGL_CURRENT_EXECUTE + void OnPlotHpglCurrentExecuteClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PLOT_HPGL_ALL_EXECUTE + void OnPlotHpglAllExecuteClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PLOT_ACCEPT_OFFSET + void OnPlotAcceptOffsetClick( wxCommandEvent& event ); + +////@end WinEDA_PlotHPGLFrame event handler declarations + +////@begin WinEDA_PlotHPGLFrame member function declarations + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_PlotHPGLFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void HPGL_Plot(wxCommandEvent& event); + void SetSizeOption(wxCommandEvent& event); + void AcceptPlotOffset(wxCommandEvent& event); + void SetPenWidth(wxSpinEvent& event); + void SetPenSpeed(wxSpinEvent& event); + void SetPenNum(wxSpinEvent& event); + void Plot_1_Page_HPGL(const wxString & FullFileName,BASE_SCREEN * screen); + void Plot_Schematic_HPGL(int Select_PlotAll, int HPGL_SheetSize); + void ReturnSheetDims( BASE_SCREEN * screen, wxSize & SheetSize, wxPoint & SheetOffset); + void SetPageOffsetValue(void); + +////@begin WinEDA_PlotHPGLFrame member variables + wxRadioBox* m_SizeOption; + wxSpinCtrl* m_ButtPenWidth; + wxSpinCtrl* m_ButtPenSpeed; + wxSpinCtrl* m_ButtPenNum; + wxTextCtrl* m_PlotOrgPosition_X; + wxTextCtrl* m_PlotOrgPosition_Y; + wxTextCtrl* m_MsgBox; +////@end WinEDA_PlotHPGLFrame member variables + WinEDA_DrawFrame * m_Parent; +}; + +#endif + // _PLOTHPGL_H_ diff --git a/eeschema/plothpgl.pjd b/eeschema/plothpgl.pjd new file mode 100644 index 0000000000..0690738ce0 --- /dev/null +++ b/eeschema/plothpgl.pjd @@ -0,0 +1,1446 @@ + + +
+ 0 + "" + "" + "" + "" + 33 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "EESchema Plot HPGL" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "ID_DIALOG" + 10000 + "WinEDA_PlotHPGLFrame" + "wxDialog" + "wxDialog" + "plothpgl.cpp" + "plothpgl.h" + "" + "EESchema Plot HPGL" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 1 + 1 + 0 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbBoxSizerProxy" + "Vertical" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxRadioBox: ID_RADIOBOX" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbRadioBoxProxy" + "wxEVT_COMMAND_RADIOBOX_SELECTED|OnRadioboxSelected" + "ID_RADIOBOX" + 10001 + "wxRadioBox" + "m_SizeOption" + "Plot page size:" + 1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "HPGL_SizeSelect" + "wxGenericValidator(& %VARIABLE%)" + 0 + 1 + "Sheet Size|Page Size A4|Page Size A3|Page Size A2|Page Size A1|Page Size A0|Page Size A|Page Size B|Page Size C|Page Size D|Page Size E" + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Top" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + "-1" + "Pen control:" + "" + "" + "" + 0 + 1 + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Pen Width ( mils )" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxSpinCtrl: ID_PEN_WIDTH_UPDATED" + "dialog-control-document" + "" + "spinctrl" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbSpinCtrlProxy" + "wxEVT_COMMAND_SPINCTRL_UPDATED|OnPenWidthUpdatedUpdated" + "ID_PEN_WIDTH_UPDATED" + 10002 + "wxSpinCtrl" + "m_ButtPenWidth" + 1 + 100 + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "g_HPGL_Pen_Descr.m_Pen_Diam" + "wxGenericValidator(& %VARIABLE%)" + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Pen Speed ( cm/s )" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxSpinCtrl: ID_PEN_SPEED_UPDATED" + "dialog-control-document" + "" + "spinctrl" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbSpinCtrlProxy" + "wxEVT_COMMAND_SPINCTRL_UPDATED|OnPenSpeedUpdatedUpdated" + "ID_PEN_SPEED_UPDATED" + 10003 + "wxSpinCtrl" + "m_ButtPenSpeed" + 1 + 100 + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "g_HPGL_Pen_Descr.m_Pen_Speed" + "wxGenericValidator(& %VARIABLE%)" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Pen Number" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxSpinCtrl: ID_PEN_NUMBER_UPDATED" + "dialog-control-document" + "" + "spinctrl" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbSpinCtrlProxy" + "wxEVT_COMMAND_SPINCTRL_UPDATED|OnPenNumberUpdatedUpdated" + "ID_PEN_NUMBER_UPDATED" + 10004 + "wxSpinCtrl" + "m_ButtPenNum" + 1 + 8 + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "g_HPGL_Pen_Descr.m_Pen_Num" + "wxGenericValidator(& %VARIABLE%)" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "4/9/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + "Page offset:" + "" + "" + "" + 0 + 1 + "Vertical" + "" + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "4/9/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Plot Offset X" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL1" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "4/9/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL1" + 10010 + "wxTextCtrl" + "m_PlotOrgPosition_X" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "4/9/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Plot Offset Y" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL2" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "4/9/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL2" + 10009 + "wxTextCtrl" + "m_PlotOrgPosition_Y" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Top" + 0 + 5 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: ID_PLOT_HPGL_CURRENT_EXECUTE" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnPlotHpglCurrentExecuteClick" + "ID_PLOT_HPGL_CURRENT_EXECUTE" + 10005 + "wxButton" + "" + "&Plot CURRENT" + 0 + "" + "" + "" + "008000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: ID_PLOT_HPGL_ALL_EXECUTE" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnPlotHpglAllExecuteClick" + "ID_PLOT_HPGL_ALL_EXECUTE" + 10006 + "wxButton" + "" + "Plot A&LL" + 0 + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_CANCEL" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCancelClick" + "wxID_CANCEL" + 5101 + "wxButton" + "" + "&Cancel" + 0 + "" + "" + "" + "800000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxButton: ID_PLOT_ACCEPT_OFFSET" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnPlotAcceptOffsetClick" + "ID_PLOT_ACCEPT_OFFSET" + 10008 + "wxButton" + "" + "&Accept Offset" + 0 + "" + "" + "" + "657B44" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + "wxTextCtrl: ID_TEXTCTRL" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "4/12/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL" + 10007 + "wxTextCtrl" + "m_MsgBox" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + 110 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "plothpgl.rc" + "source-editor-document" + "plothpgl.rc" + "source-editor" + 0 + 0 + 1 + 0 + "4/12/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/plothpgl.rc b/eeschema/plothpgl.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/eeschema/plothpgl.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/eeschema/plotps.cpp b/eeschema/plotps.cpp new file mode 100644 index 0000000000..37f9db418d --- /dev/null +++ b/eeschema/plotps.cpp @@ -0,0 +1,503 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: plotps.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 01/02/2006 08:37:24 +// RCS-ID: +// Copyright: GNU License +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 01/02/2006 08:37:24 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "plotps.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "worksheet.h" +#include "plot_common.h" +#include "protos.h" + + +/* coeff de conversion dim en 1 mil -> dim en unite PS: */ +#define SCALE_PS 0.001 + +extern void Move_Plume( wxPoint pos, int plume ); +extern void Plume( int plume ); + +enum PageFormatReq { + PAGE_SIZE_AUTO, + PAGE_SIZE_A4, + PAGE_SIZE_A +}; + + +/* Variables locales : */ +static int s_DefaultPenWidth = 6; /* default pen width for drawings in 1/1000 inch */ +static int PS_SizeSelect = PAGE_SIZE_AUTO; +extern FILE * PlotOutput; +static bool Plot_Sheet_Ref = TRUE; + + +////@begin includes +////@end includes + +#include "plotps.h" + +////@begin XPM images +////@end XPM images + + +/***********************************************************/ +void WinEDA_SchematicFrame::ToPlot_PS(wxCommandEvent& event) +/***********************************************************/ +/* fonction relai de creation de la frame de dialogue pour trace Postscript +*/ +{ +wxPoint pos; + + pos = GetPosition(); + pos.x += 10; pos.y += 20; + WinEDA_PlotPSFrame * Ps_frame = new WinEDA_PlotPSFrame(this); + Ps_frame->ShowModal(); Ps_frame->Destroy(); +} + + + +/*! + * WinEDA_PlotPSFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_PlotPSFrame, wxDialog ) + +/*! + * WinEDA_PlotPSFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_PlotPSFrame, wxDialog ) + +////@begin WinEDA_PlotPSFrame event table entries + EVT_BUTTON( ID_PLOT_PS_CURRENT_EXECUTE, WinEDA_PlotPSFrame::OnPlotPsCurrentExecuteClick ) + + EVT_BUTTON( ID_PLOT_PS_ALL_EXECUTE, WinEDA_PlotPSFrame::OnPlotPsAllExecuteClick ) + + EVT_BUTTON( wxID_CLOSE, WinEDA_PlotPSFrame::OnCloseClick ) + +////@end WinEDA_PlotPSFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_PlotPSFrame constructors + */ + +WinEDA_PlotPSFrame::WinEDA_PlotPSFrame( ) +{ +} + +WinEDA_PlotPSFrame::WinEDA_PlotPSFrame( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + Create(parent, id, caption, pos, size, style); +} + +/*! + * WinEDA_PlotPSFrame creator + */ + +bool WinEDA_PlotPSFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_PlotPSFrame member initialisation + m_SizeOption = NULL; + m_PlotPSColorOption = NULL; + m_Plot_Sheet_Ref = NULL; + m_MsgBox = NULL; +////@end WinEDA_PlotPSFrame member initialisation + +////@begin WinEDA_PlotPSFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_PlotPSFrame creation + return true; +} + +/*! + * Control creation for WinEDA_PlotPSFrame + */ + +void WinEDA_PlotPSFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_PlotPSFrame content construction + // Generated by DialogBlocks, 04/02/2006 17:30:50 (unregistered) + + WinEDA_PlotPSFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxString m_SizeOptionStrings[] = { + _("Auto"), + _("Page Size A4"), + _("Page Size A") + }; + m_SizeOption = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Plot page size:"), wxDefaultPosition, wxDefaultSize, 3, m_SizeOptionStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer3->Add(m_SizeOption, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxString m_PlotPSColorOptionStrings[] = { + _("B/W"), + _("Color") + }; + m_PlotPSColorOption = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Plot Color:"), wxDefaultPosition, wxDefaultSize, 2, m_PlotPSColorOptionStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer3->Add(m_PlotPSColorOption, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton9 = new wxButton( itemDialog1, ID_PLOT_PS_CURRENT_EXECUTE, _("&Plot CURRENT"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton9->SetForegroundColour(wxColour(0, 128, 0)); + itemBoxSizer8->Add(itemButton9, 0, wxGROW|wxALL, 5); + + wxButton* itemButton10 = new wxButton( itemDialog1, ID_PLOT_PS_ALL_EXECUTE, _("Plot A&LL"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton10->SetForegroundColour(wxColour(179, 0, 0)); + itemBoxSizer8->Add(itemButton10, 0, wxGROW|wxALL, 5); + + wxButton* itemButton11 = new wxButton( itemDialog1, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton11->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer8->Add(itemButton11, 0, wxGROW|wxALL, 5); + + m_Plot_Sheet_Ref = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Print Sheet Ref"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_Plot_Sheet_Ref->SetValue(false); + itemBoxSizer2->Add(m_Plot_Sheet_Ref, 0, wxALIGN_LEFT|wxALL, 5); + + wxStaticText* itemStaticText13 = new wxStaticText( itemDialog1, wxID_STATIC, _("Messages :"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add(itemStaticText13, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_MsgBox = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(-1, 200), wxTE_MULTILINE ); + itemBoxSizer2->Add(m_MsgBox, 0, wxGROW|wxALL|wxFIXED_MINSIZE, 5); + + // Set validators + m_SizeOption->SetValidator( wxGenericValidator(& PS_SizeSelect) ); + m_PlotPSColorOption->SetValidator( wxGenericValidator(& g_PlotPSColorOpt) ); + m_Plot_Sheet_Ref->SetValidator( wxGenericValidator(& Plot_Sheet_Ref) ); +////@end WinEDA_PlotPSFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_PlotPSFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_PlotPSFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_PlotPSFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_PlotPSFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_PlotPSFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_PlotPSFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_PlotPSFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON + */ + +void WinEDA_PlotPSFrame::OnPlotPsCurrentExecuteClick( wxCommandEvent& event ) +{ +int Select_PlotAll = FALSE; + + InitOptVars(); + CreatePSFile(Select_PlotAll, PS_SizeSelect); + m_MsgBox->AppendText( wxT("*****\n")); +} + + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1 + */ + +void WinEDA_PlotPSFrame::OnPlotPsAllExecuteClick( wxCommandEvent& event ) +{ +int Select_PlotAll = TRUE; + + InitOptVars(); + CreatePSFile(Select_PlotAll, PS_SizeSelect); + m_MsgBox->AppendText( wxT("*****\n")); +} + + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + */ + +void WinEDA_PlotPSFrame::OnCloseClick( wxCommandEvent& event ) +{ + InitOptVars(); + Close(TRUE); +} + + +/*****************************************/ +void WinEDA_PlotPSFrame::InitOptVars(void) +/*****************************************/ +{ + Plot_Sheet_Ref = m_Plot_Sheet_Ref->GetValue(); + g_PlotPSColorOpt = m_PlotPSColorOption->GetSelection(); + PS_SizeSelect = m_SizeOption->GetSelection(); +} + + +/*************************************************************/ +void WinEDA_PlotPSFrame::CreatePSFile(int AllPages, int pagesize) +/*************************************************************/ +{ +wxString PlotFileName, ShortFileName; +BASE_SCREEN *screen; +Ki_PageDescr * PlotSheet, * RealSheet; +int BBox[4]; +wxPoint plot_offset; + + g_PlotFormat = PLOT_FORMAT_POST; + + screen = ActiveScreen; + if ( AllPages == TRUE ) + { + screen = ScreenSch; + } + while( screen ) + { + PlotSheet = screen->m_CurrentSheet; + RealSheet = &g_Sheet_A4; + if ( pagesize == PAGE_SIZE_AUTO ) RealSheet = PlotSheet; + else if ( pagesize == PAGE_SIZE_A ) RealSheet = &g_Sheet_A; + + /* Calcul des limites de trace en 1/1000 pouce */ + BBox[0] = BBox[1] = g_PlotMargin; // Plot margin in 1/1000 inch + BBox[2] = RealSheet->m_Size.x - g_PlotMargin; + BBox[3] = RealSheet->m_Size.y - g_PlotMargin; + + /* Calcul des echelles de conversion */ + g_PlotScaleX = SCALE_PS * + (float) (BBox[2] - BBox[0]) / + PlotSheet->m_Size.x; + g_PlotScaleY = SCALE_PS * + (float) (BBox[3] - BBox[1]) / + PlotSheet->m_Size.y; + + plot_offset.x = 0; + plot_offset.y = PlotSheet->m_Size.y; + + wxSplitPath(screen->m_FileName.GetData(), (wxString*) NULL, + &ShortFileName, (wxString*) NULL); + wxString dirbuf = wxGetCwd() + STRING_DIR_SEP; + if( ! ShortFileName.IsEmpty() ) + PlotFileName = MakeFileName(dirbuf, ShortFileName, wxT(".ps")); + else PlotFileName = MakeFileName(dirbuf, g_DefaultSchematicFileName, wxT(".ps")); + + PlotOneSheetPS(PlotFileName,screen, RealSheet, BBox, plot_offset); + screen = (BASE_SCREEN*)screen->Pnext; + if (AllPages == FALSE ) screen = NULL; + } +} + + +/**********************************************************/ +void WinEDA_PlotPSFrame::PlotOneSheetPS(const wxString & FileName, + BASE_SCREEN * screen, Ki_PageDescr * sheet, int BBox[4], wxPoint plot_offset) +/**********************************************************/ +/* Trace en format PS. d'une feuille de dessin +*/ +{ +wxString Line; +EDA_BaseStruct *DrawList; +EDA_SchComponentStruct *DrawLibItem; +int x1=0, y1=0, x2=0, y2=0, layer; + + PlotOutput = wxFopen(FileName, wxT("wt")); + if (PlotOutput == NULL) + { + Line = wxT("\n** "); + Line += _("Unable to create ") + FileName + wxT(" **\n\n"); + m_MsgBox->AppendText(Line); + wxBell(); + return ; + } + + Line.Printf(_("Plot: %s\n"), FileName.GetData()) ; + m_MsgBox->AppendText(Line); + + InitPlotParametresPS(plot_offset, sheet, g_PlotScaleX, g_PlotScaleY); + SetDefaultLineWidthPS( s_DefaultPenWidth); + + /* Init : */ + PrintHeaderPS(PlotOutput, wxT("EESchema-PS"), FileName, BBox); + InitPlotParametresPS(plot_offset, sheet, 1.0, 1.0); + + if ( m_Plot_Sheet_Ref->GetValue() ) + { + if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) + SetColorMapPS ( BLACK ); + PlotWorkSheet(PLOT_FORMAT_POST, screen); + } + + DrawList = screen->EEDrawList; + while ( DrawList ) /* tracage */ + { + Plume('U'); + layer = LAYER_NOTES; + switch( DrawList->m_StructType ) + { + case DRAW_BUSENTRY_STRUCT_TYPE : /* Struct Raccord et Segment sont identiques */ + #undef STRUCT + #define STRUCT ((DrawBusEntryStruct*)DrawList) + x1 = STRUCT->m_Pos.x; y1 = STRUCT->m_Pos.y; + x2 = STRUCT->m_End().x; y2 = STRUCT->m_End().y; + layer = STRUCT->m_Layer; + case DRAW_SEGMENT_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((EDA_DrawLineStruct*)DrawList) + if ( DrawList->m_StructType == DRAW_SEGMENT_STRUCT_TYPE) + { + x1 = STRUCT->m_Start.x; y1 = STRUCT->m_Start.y; + x2 = STRUCT->m_End.x; y2 = STRUCT->m_End.y; + layer = STRUCT->m_Layer; + } + if ( g_PlotPSColorOpt ) + SetColorMapPS ( ReturnLayerColor(layer) ); + switch (layer) + { + case LAYER_NOTES: /* Trace en pointilles */ + fprintf(PlotOutput,"[50 50] 0 setdash\n"); + Move_Plume( wxPoint(x1,y1), 'U'); + Move_Plume( wxPoint(x2,y2), 'D'); + fprintf(PlotOutput,"[] 0 setdash\n"); + break; + + case LAYER_BUS: /* Trait large */ + { + fprintf(PlotOutput,"%d setlinewidth\n", s_DefaultPenWidth * 3); + Move_Plume( wxPoint(x1,y1),'U'); + Move_Plume( wxPoint(x2,y2),'D'); + fprintf(PlotOutput,"%d setlinewidth\n", s_DefaultPenWidth); + } + break; + + default: + Move_Plume( wxPoint(x1,y1),'U'); + Move_Plume( wxPoint(x2,y2),'D'); + break; + } + break; + + case DRAW_JUNCTION_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((DrawJunctionStruct*)DrawList) + if ( g_PlotPSColorOpt ) + SetColorMapPS (ReturnLayerColor(STRUCT->m_Layer) ); + PlotCercle( STRUCT->m_Pos, DRAWJUNCTION_SIZE); + break; + + case DRAW_TEXT_STRUCT_TYPE : + case DRAW_LABEL_STRUCT_TYPE : + case DRAW_GLOBAL_LABEL_STRUCT_TYPE : + PlotTextStruct(DrawList); + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE : + DrawLibItem = (EDA_SchComponentStruct *) DrawList; + PlotLibPart( DrawLibItem ); + break; + + case DRAW_PICK_ITEM_STRUCT_TYPE : break; + case DRAW_POLYLINE_STRUCT_TYPE : break; + case DRAW_SHEETLABEL_STRUCT_TYPE: break; + case DRAW_MARKER_STRUCT_TYPE : break; + + case DRAW_SHEET_STRUCT_TYPE : + #undef STRUCT + #define STRUCT ((DrawSheetStruct*)DrawList) + PlotSheetStruct(STRUCT); + break; + + case DRAW_NOCONNECT_STRUCT_TYPE: + #undef STRUCT + #define STRUCT ((DrawNoConnectStruct*)DrawList) + if ( g_PlotPSColorOpt ) + SetColorMapPS (ReturnLayerColor(LAYER_NOCONNECT) ); + PlotNoConnectStruct(STRUCT); + break; + + default: + break; + } + + Plume('U'); + DrawList = DrawList->Pnext; + } + + /* fin */ + CloseFilePS(PlotOutput); + + m_MsgBox->AppendText( wxT("Ok\n")); +} + + + + + + + + + + + + diff --git a/eeschema/plotps.h b/eeschema/plotps.h new file mode 100644 index 0000000000..962cc46496 --- /dev/null +++ b/eeschema/plotps.h @@ -0,0 +1,122 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: plotps.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 01/02/2006 08:37:24 +// RCS-ID: +// Copyright: GNU License +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 01/02/2006 08:37:24 + +#ifndef _PLOTPS_H_ +#define _PLOTPS_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "plotps.h" +#endif + +/*! + * Includes + */ + +////@begin includes +#include "wx/valgen.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_PLOTPSFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxSTAY_ON_TOP|wxCLOSE_BOX +#define SYMBOL_WINEDA_PLOTPSFRAME_TITLE _("EESchema Plot PS") +#define SYMBOL_WINEDA_PLOTPSFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_PLOTPSFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_PLOTPSFRAME_POSITION wxDefaultPosition +#define ID_RADIOBOX1 10002 +#define ID_RADIOBOX 10001 +#define ID_PLOT_PS_CURRENT_EXECUTE 10003 +#define ID_PLOT_PS_ALL_EXECUTE 10004 +#define ID_CHECKBOX 10005 +#define ID_TEXTCTRL 10006 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_PlotPSFrame class declaration + */ + +class WinEDA_PlotPSFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_PlotPSFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_PlotPSFrame( ); + WinEDA_PlotPSFrame( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PLOTPSFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PLOTPSFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PLOTPSFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PLOTPSFRAME_SIZE, long style = SYMBOL_WINEDA_PLOTPSFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PLOTPSFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PLOTPSFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PLOTPSFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PLOTPSFRAME_SIZE, long style = SYMBOL_WINEDA_PLOTPSFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_PlotPSFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PLOT_PS_CURRENT_EXECUTE + void OnPlotPsCurrentExecuteClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PLOT_PS_ALL_EXECUTE + void OnPlotPsAllExecuteClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + void OnCloseClick( wxCommandEvent& event ); + +////@end WinEDA_PlotPSFrame event handler declarations + +////@begin WinEDA_PlotPSFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_PlotPSFrame member function declarations + + void InitOptVars(void); + void CreatePSFile(int AllPages, int pagesize); + void PlotOneSheetPS(const wxString & FileName, + BASE_SCREEN * screen, Ki_PageDescr * sheet, int BBox[4], wxPoint plot_offset); + + /// Should we show tooltips? + static bool ShowToolTips(); + +////@begin WinEDA_PlotPSFrame member variables + wxRadioBox* m_SizeOption; + wxRadioBox* m_PlotPSColorOption; + wxCheckBox* m_Plot_Sheet_Ref; + wxTextCtrl* m_MsgBox; +////@end WinEDA_PlotPSFrame member variables +}; + +#endif + // _PLOTPS_H_ diff --git a/eeschema/plotps.pjd b/eeschema/plotps.pjd new file mode 100644 index 0000000000..320108e3b9 --- /dev/null +++ b/eeschema/plotps.pjd @@ -0,0 +1,842 @@ + + +
+ 0 + "" + "" + "" + "" + 21 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "GNU License" + "" + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "EESchema Plot PS" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "1/5/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "ID_DIALOG" + 10000 + "WinEDA_PlotPSFrame" + "wxDialog" + "wxDialog" + "plotps.cpp" + "plotps.h" + "" + "EESchema Plot PS" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Vertical" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "1/5/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxRadioBox: ID_RADIOBOX1" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "1/5/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX1" + 10002 + "wxRadioBox" + "m_SizeOption" + "Plot page size:" + 1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "PS_SizeSelect" + "wxGenericValidator(& %VARIABLE%)" + 0 + 1 + "Auto|Page Size A4|Page Size A" + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "1/5/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxRadioBox: ID_RADIOBOX" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "1/5/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX" + 10001 + "wxRadioBox" + "m_PlotPSColorOption" + "Plot Color:" + 1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "g_PlotPSColorOpt" + "wxGenericValidator(& %VARIABLE%)" + 0 + 1 + "B/W|Color" + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "1/5/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "1/5/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: ID_PLOT_PS_CURRENT_EXECUTE" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "1/5/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnPlotPsCurrentExecuteClick" + "ID_PLOT_PS_CURRENT_EXECUTE" + 10003 + "wxButton" + "" + "&Plot CURRENT" + 0 + "" + "" + "" + "008000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: ID_PLOT_PS_ALL_EXECUTE" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "1/5/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnPlotPsAllExecuteClick" + "ID_PLOT_PS_ALL_EXECUTE" + 10004 + "wxButton" + "" + "Plot A&LL" + 0 + "" + "" + "" + "B30000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_CLOSE" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "1/5/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCloseClick" + "wxID_CLOSE" + 5001 + "wxButton" + "" + "&Close" + 0 + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + "wxCheckBox: ID_CHECKBOX" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "1/5/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX" + 10005 + "wxCheckBox" + "m_Plot_Sheet_Ref" + "Print Sheet Ref" + 0 + "" + "" + "Plot_Sheet_Ref" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "1/5/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Messages :" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "1/5/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL" + 10006 + "wxTextCtrl" + "m_MsgBox" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + 200 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + "" + "" + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "plotps.rc" + "source-editor-document" + "plotps.rc" + "source-editor" + 0 + 0 + 1 + 0 + "1/5/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/plotps.rc b/eeschema/plotps.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/eeschema/plotps.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/eeschema/plugins/makefile.g95 b/eeschema/plugins/makefile.g95 new file mode 100644 index 0000000000..3aa614eed3 --- /dev/null +++ b/eeschema/plugins/makefile.g95 @@ -0,0 +1,19 @@ +# File: makefile for eeschema, mingw + +#used only to define (KICAD_BIN) : +include ../../libs.win + + +all: netlist_form_pads-pcb.exe + +netlist_form_pads-pcb.exe: netlist_form_pads-pcb.cpp + gcc -Wall netlist_form_pads-pcb.cpp -o netlist_form_pads-pcb.exe + +install: + cp -v *.exe $(KICAD_BIN)/plugins/ + +clean : + -$(RM) *.o + -$(RM) *.exe + -$(RM) *.bak + diff --git a/eeschema/plugins/makefile.gtk b/eeschema/plugins/makefile.gtk new file mode 100644 index 0000000000..468fce7ef5 --- /dev/null +++ b/eeschema/plugins/makefile.gtk @@ -0,0 +1,31 @@ +# File: makefile for eeschema, mingw + +#used only to define (KICAD_BIN) : +include ../../libs.linux + +# Use static link for libsupc++ (locate libstdc++.a and copy it in kicad_dev/syslibs) +ifdef KICAD_STATIC_LINK +#define path for a copy of libstdc++.a or/and libsupc++.a: +LIBSTDC = ../../syslibs/libstdc++.a +else +# Or Use static link for libsupc++ or libstdc++ +LIBSTDC = -lstdc++ +endif + + +all: netlist_form_pads-pcb + +netlist_form_pads-pcb: netlist_form_pads-pcb.cpp makefile.gtk + gcc -D__UNIX__ -Wall netlist_form_pads-pcb.cpp -o netlist_form_pads-pcb $(LIBSTDC) + +install: + cp -v netlist_form_pads-pcb $(KICAD_BIN)/plugins/ + +clean : + rm -f netlist_form_pads-pcb + rm -f *.o + rm -f *.rsc + rm -f *.res + rm -f *.exe + rm -f *.bak + diff --git a/eeschema/plugins/makefile.macosx b/eeschema/plugins/makefile.macosx new file mode 100644 index 0000000000..67a903c7b9 --- /dev/null +++ b/eeschema/plugins/makefile.macosx @@ -0,0 +1,21 @@ +# File: makefile for eeschema, mingw + +#used only to define (KICAD_BIN) : +include ../../libs.macosx + + +all: netlist_form_pads-pcb + +netlist_form_pads-pcb: netlist_form_pads-pcb.cpp + g++ -D__UNIX__ -Wall netlist_form_pads-pcb.cpp -o netlist_form_pads-pcb + +install: + cp -v all $(KICAD_BIN)/plugins/ + +clean : + rm -f *.o + rm -f *.rsc + rm -f *.res + rm -f *.exe + rm -f *.bak + diff --git a/eeschema/plugins/netlist_form_pads-pcb.cpp b/eeschema/plugins/netlist_form_pads-pcb.cpp new file mode 100644 index 0000000000..6909b3754a --- /dev/null +++ b/eeschema/plugins/netlist_form_pads-pcb.cpp @@ -0,0 +1,319 @@ +/**********************************/ +/* Netlist generator for pads-pcb */ +/**********************************/ + +/* read the generic netlist created by eeschema and convert it to a pads-pcb form +*/ +#include +#include +#include +#include + +#ifdef __UNIX__ +#define stricmp strcasecmp +#define strnicmp strncasecmp +#endif + +/* Pads-pcb sample: +*PADS-PCB* +*PART* +C1 CHIP_D +C2 C1206 +C3 CHIP_B +C4 CHIP_B +D1 CHIP_B +JP1 unknown + +*NET* +*SIGNAL* N03791 +C3.1 R1.1 JP2.7 U1.3 +*SIGNAL* VCC + U2.14 Y1.8 JP5.2 U3.2 C1.1 U1.20 JP1.8 JP1.3 + C5.2 C6.1 C7.2 U1.7 Y1.7 +*SIGNAL* N01384 + JP5.1 U1.1 +*SIGNAL* N02594 +*END* +*/ + + +/* Generic netlist sample: +$BeginNetlist +$BeginComponentList + +$BeginComponent +TimeStamp=32568D1E +Footprint= +Reference=JP1 +Value=CONN_8X2 +Libname=CONN_8X2 +$BeginPinList +1=GND +2=REF10_1 +3=GND +4=REF11_1 +5=GND +6=REF7_1 +7=GND +8=REF9_1 +9=GND +10=REF6_1 +11=GND +12=REF8_1 +13=GND +14=REF4_1 +15=GND +16=REF5_1 +$EndPinList +$EndComponent + +$BeginComponent +TimeStamp=325679C1 +Footprint= +Reference=RR1 +Value=9x1K +Libref=RR9 +$BeginPinList +1=VCC +2=REF5_1 +3=REF4_1 +4=REF8_1 +5=REF6_1 +6=REF9_1 +7=REF7_1 +8=REF11_1 +9=REF10_1 +10=? +$EndPinList +$EndComponent +$EndComponentList + +$BeginNets +Net 0 "" +Net 1 "GND" + BUS1 31 + U3 19 + U3 10 + U3 1 +Net 172 "" + BUS1 32 +Net 173 "" + BUS1 30 +$EndNets + +$EndNetlist +*/ + +char * GetLine(FILE *File, char *Line, int *LineNum, int SizeLine); +int ReadAndWriteComponentDataSection(FILE * InFile, FILE * OutFile, int *LineNumber); +int ReadAndWriteNetsDataSection(FILE * InFile, FILE * OutFile, int * LineNumber); + + + +class ComponentDataClass +{ +public: + char m_Reference[256]; + char m_Value[256]; + char m_Footprint[256]; + char m_LibRef[256]; + long m_TimeStamp; + +public: + ComponentDataClass(void) + { + InitData(); + } + void InitData(void) + { + m_TimeStamp = 0; + m_Reference[0] = 0; + m_Value[0] = 0; + m_Footprint[0] = 0; + m_LibRef[0] = 0; + } +}; + + +/********************************/ +int main(int argc, char ** argv ) +/********************************/ +{ +char * InputfileName, * OutputFilename; +FILE * InFile, * OutFile; +int LineNumber; +char Line[1024]; + + if ( argc < 3 ) + { + printf("\nUsage; netlist_form_pads-pcb infile outfile\n"); + return -1; + } + + InputfileName = argv[1]; + OutputFilename = argv[2]; + + if ( (InFile = fopen(InputfileName, "rt")) == NULL) + { + printf ( "Failed to open file %s", InputfileName); + return -2; + } + if ( (OutFile = fopen(OutputFilename, "wt")) == NULL) + { + printf ( "Failed to create file %s", OutputFilename); + return -3; + } + + + /* Write header: */ + fprintf( OutFile, "*PADS-PCB*\n*PART*\n" ); + + /* Read and write data lines */ + while( GetLine(InFile, Line, &LineNumber, sizeof(Line) ) ) + { + if ( stricmp(Line, "$BeginComponent") == 0 ) + { + ReadAndWriteComponentDataSection(InFile, OutFile, &LineNumber); + continue; + } + if ( stricmp(Line, "$BeginNets") == 0 ) + { + fprintf( OutFile, "\n*NET*\n" ); + ReadAndWriteNetsDataSection(InFile, OutFile, &LineNumber); + continue; + } + } + + + fprintf( OutFile, "*END*\n" ); + + fclose(InFile); + fclose(OutFile); + + return 0; +} + + +/****************************************************************/ +int ReadAndWriteComponentDataSection(FILE * InFile, FILE * OutFile, int *LineNumber) +/****************************************************************/ +/* Read the Components Section from the Generic Netlist and create Components section in Pads-Pcb format + For the component section only reference and footprint are used. + Create lines like: + C1 CHIP_D + C2 unknown +*/ +{ +char Line[1024]; +class ComponentDataClass ComponentData; +char * ident, *data; + + while( GetLine(InFile, Line, LineNumber, sizeof(Line) ) ) + { + if ( stricmp(Line, "$BeginPinList") == 0 ) + { + while( GetLine(InFile, Line, LineNumber, sizeof(Line) ) ) + if ( stricmp(Line, "$EndPinList") == 0 ) break; + continue; + } + + if ( stricmp(Line, "$EndComponent") == 0 ) // Create the output for the component: + { + /* Create the line like: C2 unknown */ + + fprintf(OutFile, "%s ", ComponentData.m_Reference ); + fprintf(OutFile, "%s\n", + strlen(ComponentData.m_Footprint) ? ComponentData.m_Footprint : "unknown"); + return 0; + } + ident = strtok(Line,"=\n\r"); + data = strtok(NULL,"=\n\r"); + if ( data == NULL ) continue; + if ( stricmp(Line, "TimeStamp") == 0 ) + { + ComponentData.m_TimeStamp = atol(data); + continue; + } + if ( stricmp(Line, "Footprint") == 0 ) + { + strncpy(ComponentData.m_Footprint, data, 255); + continue; + } + if ( stricmp(Line, "Reference") == 0 ) + { + strncpy(ComponentData.m_Reference, data, 255); + continue; + } + if ( stricmp(Line, "Value") == 0 ) + { + strncpy(ComponentData.m_Value, data, 255); + continue; + } + if ( stricmp(Line, "Libref") == 0 ) + { + strncpy(ComponentData.m_LibRef, data, 255); + continue; + } + } + + return 1; +} + +/****************************************************************/ +int ReadAndWriteNetsDataSection(FILE * InFile, FILE * OutFile, int *LineNumber) +/****************************************************************/ +/* Read the Nets Section from the Generic Netlist and create Nets section in Pads-Pcb format + create info type: + *SIGNAL* N03791 + C3.1 R1.1 JP2.7 U1.3 +*/ +{ +char Line[1024]; +char * ident, *netnum, *netname, * pin; + + while( GetLine(InFile, Line, LineNumber, sizeof(Line) ) ) + { + if ( stricmp(Line, "$EndNets") == 0 ) return 0; + ident = strtok(Line," \n\r"); + if ( stricmp(ident, "Net") == 0 ) + { + netnum = strtok(NULL," \n\r"); + netname = strtok(NULL," \"\n\r"); + if ( (netname == NULL) || strlen(netname) == 0 ) + { // Create the line like: *SIGNAL* N03791 + int num = atoi(netnum); + sprintf(Line, "N-%6.6d", num); + netname = Line; + } + fprintf(OutFile, "*SIGNAL* %s\n", netname); + } + else + { // Create the line like: C3.1 R1.1 JP2.7 U1.3 + pin = strtok(NULL," \n\r"); + fprintf(OutFile, " %s.%s\n", ident, pin); + } + } + + return 1; +} + + +/*****************************************************************/ +char * GetLine(FILE *File, char *Line, int *LineNum, int SizeLine) +/*****************************************************************/ +/* Return a non empty line + increment *LineNum for each read line + Comment lines (starting by '#') are skipped +*/ +{ + do { + if (fgets(Line, SizeLine, File) == NULL) return NULL; + if( LineNum ) *LineNum += 1; + } while (Line[0] == '#' || Line[0] == '\n' || Line[0] == '\r' || + Line[0] == 0); + + strtok(Line,"\n\r"); + return Line; +} + + diff --git a/eeschema/priorque.cpp b/eeschema/priorque.cpp new file mode 100644 index 0000000000..e76d0e14f2 --- /dev/null +++ b/eeschema/priorque.cpp @@ -0,0 +1,312 @@ +/***************************************************************************** +* PriorQue.c - implement priority queue, using regular binary trees * +* (that guarantees only average time of NlogN...) and with the following * +* operations: * +* 1. PQInit(&PQ) - initialize the queue, must be called before usage. * +* 2. PQEmpty(PQ) - returns TRUE iff PQ is empty. * +* 3. PQCompFunc(&CompFunc) - sets (a pointer to) the function that is * +* used to compere two items in the queue. the function should get two * +* item pointers, and should return >1, 0, <1 as comparison result for * +* greater than, equal, or less than respectively. * +* 4. PQFirst(&PQ, Delete) - returns the first element of the priority * +* queue, and delete it from queue if delete is TRUE. * +* 5. PQInsert(&PQ, NewItem) - insert NewItem into the queue * +* (NewItem is a pointer to it), using the comparison function CompFunc. * +* 6. PQDelete(&PQ, OldItem) - Delete old item from the queue * +* again using the comparison function CompFunc. * +* 7. PQFind(PQ, OldItem) - Find old item in queue, again using the * +* comparison function CompFunc. * +* 8. PQNext(PQ, CmpItem, NULL) - returns the smallest item which is bigger * +* than given item CmpItem. PQ is not modified. Return NULL if none. * +* 9. PQPrint(PQ, &PrintFunc) - print the queue in order using the given * +* printing function PrintFunc. * +*10. PQFree(&PQ, FreeItems) - Free the queue. The items are also freed if * +* FreeItems is TRUE. * +* * +* Written by Gershon Elber, Dec 88 * +*****************************************************************************/ + +#include +#include + + +#include "priorque.h" + +/* Definition des fonction MyFree() ( free() ) et MyMalloc() (malloc() */ +void * MyMalloc( size_t ); +void MyFree(void*); + +#define SIGN(x) ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) + +#define PQ_NEW_NODE(PQ) { \ + PQ = (PriorQue *) MyMalloc(sizeof(PriorQue)); \ + (PQ) -> Right = (PQ) -> Left = NULL; \ + (PQ) -> Data = NULL; } +#define PQ_FREE_NODE(PQ) { MyFree((char *) (PQ)); PQ = NULL; } + +static PQCompFuncType CompFunc; // = (PQCompFuncType) strcmp; + +/****************************************************************************** +* PQEmpty - initialize the queue... * +******************************************************************************/ +void PQInit(PriorQue **PQ) +{ + *PQ = NULL; +} + +/****************************************************************************** +* PQEmpty - returns TRUE iff PQ priority queue is empty. * +******************************************************************************/ +int PQEmpty(PriorQue *PQ) +{ + return PQ == NULL; +} + +/****************************************************************************** +* PQCompFunc - sets (a pointer to) the function that is used to compere two * +* items in the queue. The function should get two item pointers, and should * +* return >1, 0, <1 as comparison result for greater than, equal, or less than * +* respectively. * +******************************************************************************/ +void PQCompFunc(PQCompFuncType NewCompFunc) +{ + CompFunc = NewCompFunc; +} + +/****************************************************************************** +* PQFirst - returns the first element of the priority queue, and delete it * +* from queue if Delete is TRUE. return NULL if empty queue * +******************************************************************************/ +void * PQFirst(PriorQue **PQ, int Delete) +{ + void * Data; + PriorQue *Ptemp = (*PQ); + + if (*PQ == NULL) return NULL; + + while (Ptemp -> Right != NULL) + Ptemp = Ptemp -> Right; /* Find smallest item. */ + Data = Ptemp -> Data; + + if (Delete) PQDelete(PQ, Data); + + return Data; +} + +/****************************************************************************** +* PQInsert - insert new item into the queue (NewItem is a pointer to it), * +* using given compare function CompFunc. CompFunc should return >1, 0, <1 * +* as two item comparison result for greater than, equal, or less than * +* respectively. * +* Insert is always as a leaf of the tree. * +* Return pointer to old data if was replaced or NULL if the item is new. * +******************************************************************************/ +void * PQInsert(PriorQue **PQ, void * NewItem) +{ + int Compare; + void * Data; + + if ((*PQ) == NULL) { + PQ_NEW_NODE(*PQ); + (*PQ) -> Data = NewItem; + return NULL; + } + else { + Compare = (*CompFunc)(NewItem, (*PQ) -> Data); + Compare = SIGN(Compare); + switch (Compare) { + case -1: + return PQInsert(&((*PQ) -> Right), NewItem); + case 0: + Data = (*PQ) -> Data; + (*PQ) -> Data = NewItem; + return Data; + case 1: + return PQInsert(&((*PQ) -> Left), NewItem); + } + } + return NULL; /* Makes warning silent. */ +} + +/****************************************************************************** +* PQDelete - Delete old item from the queue, again using the comparison * +* function CompFunc. * +* Returns pointer to Deleted item if was fould and deleted, NULL otherwise. * +******************************************************************************/ +void * PQDelete(PriorQue **PQ, void * OldItem) +{ +int Compare; +PriorQue *Ptemp; +void * Data; +void * OldData; + + if ((*PQ) == NULL) return NULL; + else + { + Compare = (*CompFunc)(OldItem, (*PQ) -> Data); + Compare = SIGN(Compare); + switch (Compare) + { + case -1: + return PQDelete(&((*PQ) -> Right), OldItem); + case 0: + OldData = (*PQ) -> Data; /* The returned deleted item. */ + + if ((*PQ) -> Right == NULL && (*PQ) -> Left == NULL) + { + /* Thats easy - we delete a leaf: */ + Data = (*PQ) -> Data; + PQ_FREE_NODE(*PQ); /* Note *PQ is also set to NULL here. */ + } + else if ((*PQ) -> Right != NULL) + { + /* replace this node by the biggest in the Right branch: */ + /* move once to the Right and then Left all the time... */ + Ptemp = (*PQ) -> Right; + if (Ptemp -> Left != NULL) + { + while (Ptemp -> Left -> Left != NULL) + Ptemp = Ptemp -> Left; + Data = Ptemp -> Left -> Data;/*Save the data pointer.*/ + PQDelete(&(Ptemp -> Left), Data); /* Delete recurs. */ + (*PQ) -> Data = Data; /* And put that data instead...*/ + } + else + { + Data = Ptemp -> Data; /* Save the data pointer. */ + PQDelete(&((*PQ) -> Right), Data); /* Delete recurs. */ + (*PQ) -> Data = Data; /* And put that data instead...*/ + } + } + else /* Left != NULL. */ + { + /* replace this node by the biggest in the Left branch: */ + /* move once to the Left and then Right all the time... */ + Ptemp = (*PQ) -> Left; + if (Ptemp -> Right != NULL) + { + while (Ptemp -> Right -> Right != NULL) + Ptemp = Ptemp -> Right; + Data = Ptemp -> Right -> Data; /* Save data pointer. */ + PQDelete(&(Ptemp -> Right), Data); /*Delete recurs. */ + (*PQ) -> Data = Data; /* And put that data instead...*/ + } + else + { + Data = Ptemp -> Data; /* Save the data pointer. */ + PQDelete(&((*PQ) -> Left), Data); /* Delete recurs. */ + (*PQ) -> Data = Data; /* And put that data instead...*/ + } + } + return OldData; + case 1: + return PQDelete(&((*PQ) -> Left), OldItem); + } + } + return NULL; /* Makes warning silent. */ +} + +/****************************************************************************** +* PQFind - Find old item from the queue, again using the comparison * +* function CompFunc. * +* Returns pointer to item if was fould, NULL otherwise. * +******************************************************************************/ +void * PQFind(PriorQue *PQ, void * OldItem) +{ + int Compare; + + if (PQ == NULL) { + return NULL; + } + else { + Compare = (*CompFunc)(OldItem, PQ -> Data); + Compare = SIGN(Compare); + switch (Compare) { + case -1: + return PQFind(PQ -> Right, OldItem); + case 0: + return PQ -> Data; + case 1: + return PQFind(PQ -> Left, OldItem); + } + } + return NULL; /* Makes warning silent. */ +} + +/****************************************************************************** +* PQNext - returns the smallest item which is bigger than given item CmpItem. * +* PQ is not modified. Return NULL if none was found. * +* BiggerThan will allways hold the smallest Item bigger than current one. * +******************************************************************************/ +void * PQNext(PriorQue *PQ, void * CmpItem, void * BiggerThan) +{ + int Compare; + PriorQue *Ptemp; + + if (PQ == NULL) + return BiggerThan; + else { + Compare = (*CompFunc)(CmpItem, PQ -> Data); + Compare = SIGN(Compare); + switch (Compare) { + case -1: + return PQNext(PQ -> Right, CmpItem, PQ -> Data); + case 0: + /* Found it - if its right tree is not empty, returns its */ + /* smallest, else returns BiggerThan... */ + if (PQ -> Left != NULL) { + Ptemp = PQ -> Left; + while (Ptemp -> Right != NULL) Ptemp = Ptemp -> Right; + return Ptemp -> Data; + } + else + return BiggerThan; + case 1: + return PQNext(PQ -> Left, CmpItem, BiggerThan); + } + } + return NULL; /* Makes warning silent. */ +} + +/****************************************************************************** +* PQPrint - print the queue in order using the given printing functionq * +* PrintFunc. * +******************************************************************************/ +void PQPrint(PriorQue *PQ, void (*PrintFunc)(void *)) +{ + if (PQ == NULL) return; + + PQPrint(PQ -> Right, PrintFunc); + + (*PrintFunc)(PQ -> Data); + + PQPrint(PQ -> Left, PrintFunc); +} + +/****************************************************************************** +* PQFree - Free the queue. The items are also freed if FreeItems is TRUE. * +******************************************************************************/ +void PQFree(PriorQue *PQ, int FreeItem) +{ + if (PQ == NULL) return; + + PQFree(PQ -> Right, FreeItem); + PQFree(PQ -> Left, FreeItem); + + if (FreeItem) MyFree((char *) PQ -> Data); + MyFree((char *) PQ); +} + +/****************************************************************************** +* PQFreeFunc - Free queue. Items are also freed by calling FreeFunc on them. * +******************************************************************************/ +void PQFreeFunc(PriorQue *PQ, void (*FreeFunc)(void *)) +{ + if (PQ == NULL) return; + + PQFreeFunc(PQ -> Right, FreeFunc); + PQFreeFunc(PQ -> Left, FreeFunc); + + (FreeFunc)(PQ -> Data); + MyFree((char *) PQ); +} diff --git a/eeschema/priorque.h b/eeschema/priorque.h new file mode 100644 index 0000000000..7cab29bf4d --- /dev/null +++ b/eeschema/priorque.h @@ -0,0 +1,29 @@ +/***************************************************************************** +* Definitions, visible to others, of Priority Queue module: * +*****************************************************************************/ + +#ifndef PRIOR_Q_GH +#define PRIOR_Q_GH + +typedef struct PriorQue + { + struct PriorQue *Right, *Left; /* Pointers to two sons of this node. */ + void * Data; /* Pointers to the data itself. */ + } PriorQue; + +typedef int (*PQCompFuncType)( void *, void *); /* Comparison function. */ + +/* And global function prototypes: */ +void PQInit(PriorQue **PQ); +int PQEmpty(PriorQue *PQ); +void PQCompFunc(PQCompFuncType NewCompFunc); +void * PQFirst(PriorQue **PQ, int Delete); +void * PQInsert(PriorQue **PQ, void * NewItem); +void * PQDelete(PriorQue **PQ, void * NewItem); +void * PQFind(PriorQue *PQ, void * OldItem); +void * PQNext(PriorQue *PQ, void * CmpItem, void * BiggerThan); +void PQPrint(PriorQue *PQ, void (*PrintFunc)()); +void PQFree(PriorQue *PQ, int FreeItems); +void PQFreeFunc(PriorQue *PQ, void (*FreeFunc)(void *)); + +#endif /* PRIOR_Q_GH */ diff --git a/eeschema/program.h b/eeschema/program.h new file mode 100644 index 0000000000..6a0fc8847e --- /dev/null +++ b/eeschema/program.h @@ -0,0 +1,200 @@ + /********************************************/ + /* Definitions for the EESchema program: */ + /********************************************/ + +#ifndef PROGRAM_H +#define PROGRAM_H + +#ifndef eda_global +#define eda_global extern +#endif + +#include "macros.h" +#include "base_struct.h" + +#include "component_class.h" +#include "class_screen.h" + +#define DRAWJUNCTION_SIZE 16 /* Rayon du symbole connexion */ +#define DRAWMARKER_SIZE 16 /* Rayon du symbole marqueur */ +#define DRAWNOCONNECT_SIZE 48 /* Rayon du symbole No Connexion */ + +#define HIGHLIGHT_COLOR WHITE + + +#define TEXT_NO_VISIBLE 1 + +/* flags pour BUS ENTRY (bus to bus ou wire to bus */ +#define WIRE_TO_BUS 0 +#define BUS_TO_BUS 1 + + +typedef enum { /* Type des Marqueurs */ + MARQ_UNSPEC, + MARQ_ERC, + MARQ_PCB, + MARQ_SIMUL, + MARQ_NMAX /* Derniere valeur: fin de tableau */ +} TypeMarker; + +/* Messages correspondants aux types des marqueurs */ +#ifdef MAIN +const wxChar * NameMarqueurType[] = + { + wxT(""), + wxT("ERC"), + wxT("PCB"), + wxT("SIMUL"), + wxT("?????") + }; +#else +extern const wxChar * NameMarqueurType[]; +#endif + + +/* Forward declarations */ +class DrawSheetStruct; + +class EDA_DrawLineStruct: public EDA_BaseLineStruct /* Segment decription + base class to describe items which have 2 end points (track, wire, draw line ...) */ +{ +public: + bool m_StartIsDangling, m_EndIsDangling; // TRUE si Start ou End not connected (wires, tracks...) + +public: + EDA_DrawLineStruct(const wxPoint & pos, int layer ); + ~EDA_DrawLineStruct(void) {} + bool IsOneEndPointAt(const wxPoint & pos); + EDA_DrawLineStruct * GenCopy(void); + bool IsNull(void) + { + return (m_Start == m_End); + } + virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); +}; + + +class DrawMarkerStruct: public EDA_BaseStruct /* marqueurs */ +{ +public: + wxPoint m_Pos; /* XY coordinates of marker. */ + TypeMarker m_Type; + int m_MarkFlags; // complements d'information + wxString m_Comment; /* Texte (commentaireassocie eventuel */ + +public: + DrawMarkerStruct(const wxPoint & pos, const wxString & text); + ~DrawMarkerStruct(void); + DrawMarkerStruct * GenCopy(void); + wxString GetComment(void); + virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); +}; + +class DrawNoConnectStruct: public EDA_BaseStruct /* Symboles de non connexion */ +{ +public: + wxPoint m_Pos; /* XY coordinates of NoConnect. */ + +public: + DrawNoConnectStruct(const wxPoint & pos); + ~DrawNoConnectStruct(void) {} + DrawNoConnectStruct * GenCopy(void); + virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); +}; + +class DrawBusEntryStruct: public EDA_BaseStruct /* Struct de descr 1 raccord + a 45 degres de BUS ou WIRE */ +{ +public: + int m_Layer; + int m_Width; + wxPoint m_Pos; + wxSize m_Size; + +public: + DrawBusEntryStruct(const wxPoint & pos, int shape, int id ); + ~DrawBusEntryStruct(void) {} + DrawBusEntryStruct * GenCopy(void); + wxPoint m_End(void); // retourne la coord de fin du raccord + virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); +}; + +class DrawPolylineStruct: public EDA_BaseStruct /* Polyligne (serie de segments) */ +{ +public: + int m_Layer; + int m_Width; + int m_NumOfPoints; /* Number of XY pairs in Points array. */ + int *m_Points; /* XY pairs that forms the polyline. */ + +public: + DrawPolylineStruct(int layer); + ~DrawPolylineStruct(void); + DrawPolylineStruct * GenCopy(void); + virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); +}; + +class DrawJunctionStruct: public EDA_BaseStruct +{ +public: + int m_Layer; + wxPoint m_Pos; /* XY coordinates of connection. */ + +public: + DrawJunctionStruct(const wxPoint & pos); + ~DrawJunctionStruct(void){} + DrawJunctionStruct * GenCopy(void); + virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); +}; + +class DrawTextStruct: public EDA_BaseStruct, public EDA_TextStruct +{ +public: + int m_Shape; + bool m_IsDangling; // TRUE si non connecté + +public: + DrawTextStruct(const wxPoint & pos = wxPoint(0,0), const wxString & text = wxEmptyString); + ~DrawTextStruct(void) {} + DrawTextStruct * GenCopy(void); + virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); + void SwapData(DrawTextStruct * copyitem); + virtual void Place(WinEDA_DrawFrame * frame, wxDC * DC); +private: + void DrawAsText(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color); + void DrawAsLabel(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color); + void DrawAsGlobalLabel(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color); +}; + +class DrawLabelStruct: public DrawTextStruct +{ +public: + DrawLabelStruct(const wxPoint & pos = wxPoint(0,0), const wxString & text = wxEmptyString); + ~DrawLabelStruct(void) {} +}; + +class DrawGlobalLabelStruct: public DrawTextStruct +{ +public: + DrawGlobalLabelStruct(const wxPoint & pos = wxPoint(0,0), const wxString & text = wxEmptyString); + ~DrawGlobalLabelStruct(void) {} +}; + + +#define MAX_LAYERS 44 +class LayerStruct +{ +public: + char LayerNames[MAX_LAYERS+1][8]; + int LayerColor[MAX_LAYERS+1]; + char LayerStatus[MAX_LAYERS+1]; + int NumberOfLayers; + int CurrentLayer; + int CurrentWidth; + int CommonColor; + int Flags; +}; + + +#endif /* PROGRAM_H */ + diff --git a/eeschema/protos.h b/eeschema/protos.h new file mode 100644 index 0000000000..b0e1d5aa42 --- /dev/null +++ b/eeschema/protos.h @@ -0,0 +1,463 @@ +/*****************************************/ +/* prototypage des fonctions de EESchema */ +/*****************************************/ +void FreeLibraryEntry(LibCmpEntry * Entry); + +LibEDA_BaseStruct * LocatePin(const wxPoint & RefPos, + EDA_LibComponentStruct * Entry, + int Unit, int Convert, EDA_SchComponentStruct * DrawItem = NULL); + /* Routine de localisation d'une PIN de la PartLib pointee par Entry */ + +wxString ReturnDefaultFieldName(int FieldNumber); + + +/***************/ +/* FILE_IO.CPP */ +/***************/ +void SaveProject(WinEDA_SchematicFrame * frame); + + +/****************/ +/* DATABASE.CPP */ +/****************/ +void DisplayCmpDoc(wxString & Name); +bool DataBaseGetName(WinEDA_DrawFrame * frame, + wxString & Keys, wxString & BufName); + +/*********************/ +/* DANGLING_ENDS.CPP */ +/*********************/ +bool SegmentIntersect(int Sx1, int Sy1, int Sx2, int Sy2, int Px1, int Py1); + +/****************/ +/* BUS_WIRE_JUNCTION.CPP */ +/****************/ +void IncrementLabelMember(wxString & name); + +/****************/ +/* EDITPART.CPP */ +/****************/ +void InstallCmpeditFrame(WinEDA_SchematicFrame * parent, wxPoint & pos, + EDA_SchComponentStruct * m_Cmp); + + + /**************/ + /* EELIBS2.CPP */ + /**************/ + +/* Functions common to all EELibs?.c modules: */ +int LibraryEntryCompare(EDA_LibComponentStruct *LE1, EDA_LibComponentStruct *LE2); +int NumOfLibraries(void); +EDA_LibComponentStruct *FindLibPart(const wxChar *Name, const wxString & LibName, int Alias); + +void DrawingLibInGhost(WinEDA_DrawPanel * panel, wxDC * DC, EDA_LibComponentStruct *LibEntry, + EDA_SchComponentStruct * DrawLibItem, int PartX, int PartY, + int Multi, int convert, + int Color, bool DrawPinText); + +void DrawLibEntry(WinEDA_DrawPanel * panel, wxDC * DC, + EDA_LibComponentStruct *LibEntry, int posX, int posY, + int Multi, int convert, + int DrawMode, int Color = -1); + +void DrawPinSymbol(WinEDA_DrawPanel * panel, wxDC * DC, + int posX, int posY, int len, int orient, int SymbolType, + int DrawMode, int Color = -1); + +void DrawLibraryDrawStruct(WinEDA_DrawPanel * panel, wxDC * DC, + EDA_LibComponentStruct *LibEntry, int PartX, int PartY, + LibEDA_BaseStruct *DrawItem, int Multi, + int DrawMode, int Color = -1); + +bool MapAngles(int *Angle1, int *Angle2, int TransMat[2][2]); + + + /**************/ + /* EELIBS1.CPP */ + /**************/ +EDA_LibComponentStruct * Read_Component_Definition(WinEDA_DrawFrame * frame, char * Line, + FILE *f, int *LineNum); +/* Routine to Read a DEF/ENDDEF part entry from given open file. */ + +LibraryStruct *FindLibrary(const wxString & Name); +int LoadDocLib(WinEDA_DrawFrame * frame, const wxString & FullDocLibName, const wxString & Libname); +PriorQue *LoadLibraryAux(WinEDA_DrawFrame * frame, LibraryStruct * library, + FILE *f, int *NumOfParts); +LibraryStruct * LoadLibraryName(WinEDA_DrawFrame * frame, + const wxString & FullLibName, const wxString & LibName); +void LoadLibraries(WinEDA_DrawFrame * frame); +void FreeCmpLibrary(wxWindow * frame, const wxString & LibName); +const wxChar **GetLibNames(void); + +void SnapLibItemPoint(int OrigX, int OrigY, int *ClosestX, int *ClosestY, + EDA_SchComponentStruct *DrawLibItem); +bool LibItemInBox(int x1, int y1, int x2, int y2, + EDA_SchComponentStruct *DrawLibItem); +void DrawTextField(WinEDA_DrawPanel * panel, wxDC * DC, PartTextStruct * Field, int IsMulti, int DrawMode); + /* Routine de trace des textes type Field du composant. + entree: + Field: champ + IsMulti: flag Non Null si il y a plusieurs parts par boitier. + n'est utile que pour le champ reference pour ajouter a celui ci + l'identification de la part ( A, B ... ) + DrawMode: mode de trace */ + +char * StrPurge(char * text); + /* Supprime les caracteres Space en debut de la ligne text + retourne un pointeur sur le 1er caractere non Space de text */ + + /************/ + /* BLOCK.CPP */ + /************/ +EDA_BaseStruct * DuplicateStruct(EDA_BaseStruct *DrawStruct); +void MoveOneStruct(EDA_BaseStruct *DrawStructs, const wxPoint & move_vector); + /* Given a structure move it by move_vector.x, move_vector.y. */ + +bool PlaceStruct(BASE_SCREEN * screen, EDA_BaseStruct *DrawStruct); +bool MoveStruct(WinEDA_DrawPanel * panel, wxDC * DC, EDA_BaseStruct *DrawStruct); +void DeleteStruct(WinEDA_DrawPanel * panel, wxDC * DC, EDA_BaseStruct *DrawStruct); +bool DrawStructInBox(int x1, int y1, int x2, int y2, + EDA_BaseStruct *DrawStruct); + + /*************/ + /* LOCATE.CPP */ + /*************/ + +EDA_SchComponentStruct * LocateSmallestComponent( SCH_SCREEN * Screen ); +/* Recherche du plus petit (en surface) composant pointe par la souris */ + +EDA_BaseStruct * PickStruct(EDA_Rect & block, + EDA_BaseStruct *DrawList, int SearchMask ); +EDA_BaseStruct * PickStruct(const wxPoint & refpos, + EDA_BaseStruct *DrawList, int SearchMask ); +/* 2 functions EDA_BaseStruct * PickStruct: + Search in block, or Serach at location pos + + SearchMask = (bitwise OR): + LIBITEM + WIREITEM + BUSITEM + RACCORDITEM + JUNCTIONITEM + DRAWITEM + TEXTITEM + LABELITEM + SHEETITEM + MARKERITEM + NOCONNECTITEM + SEARCH_PINITEM + SHEETLABELITEM + FIELDCMPITEM + + if EXCLUDE_WIRE_BUS_ENDPOINTS is set, in wire ou bus search and locate, + start and end points are not included in search + if WIRE_BUS_ENDPOINTS_ONLY is set, in wire ou bus search and locate, + only start and end points are included in search + + + Return: + -Bloc searc: + pointeur sur liste de pointeurs de structures si Plusieurs + structures selectionnees. + pointeur sur la structure si 1 seule + + Positon serach: + pointeur sur la structure. + Si pas de structures selectionnees: retourne NULL */ + + + +LibEDA_BaseStruct * LocateDrawItem(SCH_SCREEN * Screen, + EDA_LibComponentStruct* LibEntry, int Unit, int Convert, int masque); + +DrawSheetLabelStruct * LocateSheetLabel(DrawSheetStruct *Sheet, const wxPoint & pos); +LibDrawPin * LocateAnyPin(EDA_BaseStruct *DrawList, const wxPoint & RefPos, + EDA_SchComponentStruct ** libpart = NULL ); + +DrawSheetLabelStruct * LocateAnyPinSheet(const wxPoint & RefPos, + EDA_BaseStruct *DrawList); + +int distance(int dx, int dy, int spot_cX, int spot_cY, int seuil); + /* Calcul de la distance du point spot_cx,spot_cy a un segment de droite, + d'origine 0,0 et d'extremite dx, dy; + retourne: + 0 si distance > seuil + 1 si distance <= seuil + Variables utilisees ( sont ramenees au repere centre sur l'origine du segment) + dx, dy = coord de l'extremite segment. + spot_cX,spot_cY = coord du curseur souris + la recherche se fait selon 4 cas: + segment horizontal + segment vertical + segment quelconque */ + +/***************/ +/* EEREDRAW.CPP */ +/***************/ +void DrawDanglingSymbol(WinEDA_DrawPanel * panel,wxDC * DC, + const wxPoint & pos, int Color); + +void Draw_Marqueur(WinEDA_DrawPanel * panel, wxDC * DC, + wxPoint pos, char* pt_bitmap, int DrawMode, int Color); + +void DrawStructsInGhost(WinEDA_DrawPanel * panel, wxDC * DC, + EDA_BaseStruct * DrawStruct, int dx, int dy ); +void SetHighLightStruct(EDA_BaseStruct *HighLight); +void RedrawActiveWindow(WinEDA_DrawPanel * panel, wxDC * DC); +void RedrawStructList(WinEDA_DrawPanel * panel, wxDC * DC, EDA_BaseStruct *Structs, int DrawMode, + int Color = -1); +void RedrawOneStruct(WinEDA_DrawPanel * panel, wxDC * DC, EDA_BaseStruct *Struct, int DrawMode, + int Color = -1); + +/**************/ +/* EELAYER.CPP */ +/**************/ +void SeedLayers(void); +int ReturnLayerColor(int Layer); +void DisplayColorSetupFrame(WinEDA_DrawFrame * parent, const wxPoint & pos); + +/*************/ +/* EELOAD.CPP */ +/*************/ +int CountCmpNumber(void); + + +/***************/ +/* EESTRING.CPP */ +/***************/ + +void PutTextInfo(WinEDA_DrawPanel * panel, wxDC * DC, int Orient, const wxPoint & PosX, + const wxSize& size, + const wxString & Str, int DrawMode, int color); + +/***************/ +/* EECONFIG.CPP */ +/***************/ +bool Read_Config( const wxString & CfgFileName, bool ForceRereadConfig ); + + +/**************/ +/* SAVELIB.CPP */ +/**************/ + +LibEDA_BaseStruct * CopyDrawEntryStruct( wxWindow * frame, LibEDA_BaseStruct * DrawItem); + /* Routine de Duplication d'une structure DrawLibItem d'une partlib + Parametres d'entree: + DrawEntry = pointeur sur la structure a dupliquer + La structure nouvelle est creee, mais n'est pas inseree dans le + chainage + Retourne: + Pointeur sur la structure creee (ou NULL si impossible) */ + +int WriteOneLibEntry(wxWindow * frame, FILE * ExportFile, EDA_LibComponentStruct * LibEntry); + /* Routine d'ecriture du composant pointe par LibEntry + dans le fichier ExportFile( qui doit etre deja ouvert) + return: FALSE si Ok, TRUE si err write */ + +EDA_LibComponentStruct * CopyLibEntryStruct (wxWindow * frame, EDA_LibComponentStruct * OldEntry); + /* Routine de copie d'une partlib + Parametres d'entree: pointeur sur la structure de depart + Parametres de sortie: pointeur sur la structure creee */ + +int WriteOneDocLibEntry(FILE * ExportFile, EDA_LibComponentStruct * LibEntry); + /* Routine d'ecriture de la doc du composant pointe par LibEntry + dans le fichier ExportFile( qui doit etre deja ouvert) + return: 0 si Ok + 1 si err write */ + + +int SaveOneLibrary(wxWindow * frame, const wxString & FullFileName, LibraryStruct * Library); + /* Sauvegarde en fichier la librairie pointee par Library, sous le nom + FullFileName. + 2 fichiers sont crees + - La librarie + - le fichier de documentation + + une sauvegarde .bak de l'ancien fichier librairie est cree + une sauvegarde .bck de l'ancien fichier documentation est cree + + return: + 0 si OK + 1 si erreur */ + + +/***************/ +/* SYMBEDIT.CPP */ +/***************/ +void SuppressDuplicateDrawItem(EDA_LibComponentStruct * LibEntry); + /* Routine de suppression des elements de trace dupliques, situation + frequente lorsque l'on charge des symboles predessines plusieurs fois + pour definir un composant */ + +/***************/ +/* SYMBTEXT.CPP */ +/***************/ + + +/**************/ +/* NETLIST.CPP */ +/**************/ +int IsBusLabel(const wxString & LabelDrawList); +void InstallNetlistFrame(WinEDA_SchematicFrame *parent, wxPoint &pos); + +/***************/ +/* ANNOTATE.CPP */ +/***************/ +void ReAnnotatePowerSymbolsOnly( void ); + +void InstallAnnotateFrame(WinEDA_SchematicFrame * parent, wxPoint &pos); +int CheckAnnotate(WinEDA_SchematicFrame * frame, bool OneSheetOnly); + /* Retourne le nombre de composants non annotes ou erronés + Si OneSheetOnly : recherche sur le schema courant + else: recherche sur toute la hierarchie */ + + +/************/ +/* PLOT.CPP */ +/************/ +void PlotArc(wxPoint centre, int StAngle, int EndAngle, int rayon); +void PlotCercle(wxPoint centre, int diametre ); + +void PlotNoConnectStruct(DrawNoConnectStruct * Struct); +void PlotLibPart( EDA_SchComponentStruct *DrawLibItem ); + /* Genere le trace d'un composant */ +void PlotSheetStruct(DrawSheetStruct *Struct); + /* Routine de dessin du bloc type hierarchie */ +void PlotTextStruct(EDA_BaseStruct *Struct); + +/***************/ +/* DELSHEET.CPP */ +/***************/ +void DeleteSubHierarchy(DrawSheetStruct * Sheet, bool confirm_deletion); +void ClearDrawList(EDA_BaseStruct *DrawList, bool confirm_deletion); /* free the draw list DrawList and the subhierarchies */ +bool ClearProjectDrawList(SCH_SCREEN * FirstWindow, bool confirm_deletion); +/* free the draw list screen->EEDrawList and the subhierarchies + clear the screen datas (filenames ..) +*/ + +/*************/ +/* DELETE.CPP */ +/*************/ + +void LocateAndDeleteItem(WinEDA_SchematicFrame * frame, wxDC * DC); +void EraseStruct(EDA_BaseStruct *DrawStruct, SCH_SCREEN * Window); +void DeleteAllMarkers(int type); + /* Effacement des marqueurs du type "type" */ + +void DeleteOneLibraryDrawStruct(WinEDA_DrawPanel * panel, + wxDC *DC, EDA_LibComponentStruct * LibEntry, + LibEDA_BaseStruct * DrawItem, int Affiche); + /* Routine d'effacement d'un "LibraryDrawStruct" + (d'un element de dessin d'un composant ) + Parametres d'entree + Pointeur sur le composant comportant la structure + (Si NULL la structure a effacer est supposee non rattachee + a un composant) + Pointeur sur la structure a effacer + Affiche (si != 0 Efface le graphique correspondant de l'ecran) */ + + +/**********/ +/* ERC.CPP */ +/**********/ +void InstallErcFrame(WinEDA_SchematicFrame *parent, wxPoint & pos); + + +/**************/ +/* GETPART.CPP */ +/**************/ + +int LookForConvertPart( EDA_LibComponentStruct * LibEntry ); + /* Retourne la plus grande valeur trouvee dans la liste des elements + "drawings" du composant LibEntry, pour le membre .Convert + Si il n'y a pas de representation type "convert", la valeur + retournee est 0 ou 1 + Si il y a une representation type "convert", + la valeur retournee est > 1 (typiquement 2) */ + + +/**************/ +/* PINEDIT.CPP */ +/**************/ +void InstallPineditFrame(WinEDA_LibeditFrame * parent, wxDC * DC, const wxPoint & pos); + + +/**************/ +/* SELPART.CPP */ +/**************/ + +int DisplayComponentsNamesInLib(WinEDA_DrawFrame * frame, + LibraryStruct *Library, wxString & Buffer, wxString & OldName); +LibraryStruct * SelectLibraryFromList(WinEDA_DrawFrame * frame); + /* Routine pour selectionner une librairie a partir d'une liste */ + +int GetNameOfPartToLoad(WinEDA_DrawFrame * frame, LibraryStruct * Lib, + wxString & BufName); + /* Routine de selection du nom d'un composant en librairie pour chargement, + dans la librairie Library. + Si Library == NULL, il y aura demande de selection d'une librairie + Retourne + 1 si composant selectionne + 0 si commande annulee + place le nom du composant a charger, selectionne a partir d'une liste dans + BufName */ + + /**************/ + /* LIBARCH.CPP */ + /**************/ + +bool LibArchive(wxWindow * frame, const wxString & ArchFullFileName); + + /***************/ + /* GENLISTE.CPP */ + /***************/ +void InstallToolsFrame(WinEDA_DrawFrame *parent, wxPoint &pos); +int GenListeCmp( EDA_BaseStruct ** List ); + + /**************/ + /* CLEANUP.CPP */ + /**************/ + +void SchematicCleanUp(SCH_SCREEN * screen, wxDC * DC); + /* Routine de nettoyage: + - regroupe les segments de fils (ou de bus) alignes en 1 seul segment + - Detecte les objets identiques superposes + */ + +void BreakSegmentOnJunction( SCH_SCREEN * Screen ); + /* Routine creant des debuts / fin de segment (BUS ou WIRES) sur les jonctions + et les raccords */ +DrawPickedStruct * BreakSegment(SCH_SCREEN * screen, wxPoint breakpoint, + bool PutInUndoList = FALSE); + /* Coupe un segment ( BUS, WIRE ) en 2 au point breakpoint, + - si ce point est sur le segment + - extremites non comprises */ + + /**************/ + /* EECLASS.CPP */ + /**************/ + +void SetStructFather(EDA_BaseStruct * Struct, BASE_SCREEN * Screen); + + /***************/ + /* LIBALIAS.CPP */ + /***************/ + +bool BuildAliasData(LibraryStruct * Lib, EDA_LibComponentStruct * component); + /* Create the alias data for the lib component to edit */ +int LocateAlias( const wxArrayString & AliasData, const wxString & Name); + /* Return an index in alias data list ( -1 if not found ) */ + + +/************/ +/* FIND.CPP */ +/************/ +void InstallFindFrame(WinEDA_SchematicFrame *parent, wxPoint &pos); + + +/***************/ +/* OPTIONS.CPP */ +/***************/ +void DisplayOptionFrame(WinEDA_DrawFrame * parent, const wxPoint & framepos); + + diff --git a/eeschema/save_schemas.cpp b/eeschema/save_schemas.cpp new file mode 100644 index 0000000000..9eeeed3a66 --- /dev/null +++ b/eeschema/save_schemas.cpp @@ -0,0 +1,510 @@ + /*********************************************/ + /* eesave.cpp Module to Save EESchema files */ + /*********************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "macros.h" + +#include "protos.h" + +/* Format des fichiers: Voir EELOAD.CC */ + +/* Fonctions externes */ + +/* Fonctions Locales */ +static int SavePartDescr( FILE *f, EDA_SchComponentStruct * LibItemStruct); +static int SaveSheetDescr( FILE *f, DrawSheetStruct * SheetStruct); +static void SaveLayers(FILE *f); + +/* Variables locales */ + +/***************************************************************************** +* Routine to save an EESchema file. * +* FileSave controls how the file is to be saved - under what name. * +* Returns TRUE if the file has been saved. * +*****************************************************************************/ +bool WinEDA_SchematicFrame::SaveEEFile(SCH_SCREEN *screen, int FileSave) +{ +wxString msg; +wxString Name, BakName; +const wxChar **LibNames; +char * layer, *width; +int ii, shape; +bool Failed = FALSE; +EDA_BaseStruct *Phead; +Ki_PageDescr * PlotSheet; +FILE *f; +wxString dirbuf; + + if ( screen == NULL ) screen = (SCH_SCREEN*) ActiveScreen; + + /* If no name exists in the window yet - save as new. */ + if( screen->m_FileName.IsEmpty() ) FileSave = FILE_SAVE_NEW; + + switch (FileSave) + { + case FILE_SAVE_AS: + dirbuf = wxGetCwd() + STRING_DIR_SEP; + Name = MakeFileName(dirbuf, screen->m_FileName, g_SchExtBuffer); + /* Rename the old file to a '.bak' one: */ + BakName = Name; + if ( wxFileExists(Name) ) + { + ChangeFileNameExt(BakName, wxT(".bak")); + wxRemoveFile(BakName); /* delete Old .bak file */ + if( ! wxRenameFile(Name, BakName) ) + { + DisplayError(this, wxT("Warning: unable to rename old file"), 10); + } + } + break; + + case FILE_SAVE_NEW: + { + wxString mask = wxT("*") + g_SchExtBuffer; + Name = EDA_FileSelector(_("Schematic files:"), + wxEmptyString, /* Chemin par defaut */ + screen->m_FileName, /* nom fichier par defaut, et resultat */ + g_SchExtBuffer, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + FALSE + ); + if ( Name.IsEmpty() ) return FALSE; + + screen->m_FileName = Name; + dirbuf = wxGetCwd() + STRING_DIR_SEP; + Name = MakeFileName(dirbuf, Name, g_SchExtBuffer); + + break; + } + + default: break; + } + + if ((f = wxFopen(Name, wxT("wt"))) == NULL) + { + msg = _("Failed to create file ") + Name; + DisplayError(this, msg); + return FALSE; + } + + msg = _("Save file ") + Name; + Affiche_Message(msg); + + LibNames = GetLibNames(); + BakName.Empty(); // temporary buffer! + for (ii = 0; LibNames[ii] != NULL; ii++) + { + if (ii > 0) BakName += wxT(","); + BakName += LibNames[ii]; + } + MyFree( LibNames); + + if (fprintf(f, "%s %s %d\n", EESCHEMA_FILE_STAMP, + SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION) == EOF || + fprintf(f, "LIBS:%s\n", CONV_TO_UTF8(BakName)) == EOF) + { + DisplayError(this, _("File write operation failed.")); + fclose(f); + return FALSE; + } + + screen->ClrModify(); + + SaveLayers(f); + /* Sauvegarde des dimensions du schema, des textes du cartouche.. */ + + PlotSheet = screen->m_CurrentSheet; + fprintf(f,"$Descr %s %d %d\n",CONV_TO_UTF8(PlotSheet->m_Name), + PlotSheet->m_Size.x, PlotSheet->m_Size.y); + + fprintf(f,"Sheet %d %d\n",screen->m_SheetNumber, screen->m_NumberOfSheet); + fprintf(f,"Title \"%s\"\n",CONV_TO_UTF8(screen->m_Title)); + fprintf(f,"Date \"%s\"\n",CONV_TO_UTF8(screen->m_Date)); + fprintf(f,"Rev \"%s\"\n",CONV_TO_UTF8(screen->m_Revision)); + fprintf(f,"Comp \"%s\"\n",CONV_TO_UTF8(screen->m_Company)); + fprintf(f,"Comment1 \"%s\"\n", CONV_TO_UTF8(screen->m_Commentaire1)); + fprintf(f,"Comment2 \"%s\"\n", CONV_TO_UTF8(screen->m_Commentaire2)); + fprintf(f,"Comment3 \"%s\"\n", CONV_TO_UTF8(screen->m_Commentaire3)); + fprintf(f,"Comment4 \"%s\"\n", CONV_TO_UTF8(screen->m_Commentaire4)); + + fprintf(f,"$EndDescr\n"); + + /* Sauvegarde des elements du dessin */ + Phead = screen->EEDrawList; + while (Phead) + { + switch(Phead->m_StructType) + { + case DRAW_LIB_ITEM_STRUCT_TYPE: /* Its a library item. */ + SavePartDescr( f, (EDA_SchComponentStruct *) Phead); + break; + + case DRAW_SHEET_STRUCT_TYPE: /* Its a Sheet item. */ + SaveSheetDescr( f, (DrawSheetStruct *) Phead); + break; + + case DRAW_SEGMENT_STRUCT_TYPE: /* Its a Segment item. */ + #undef STRUCT + #define STRUCT ((EDA_DrawLineStruct *) Phead) + layer = "Notes"; width = "Line"; + if (STRUCT->m_Layer == LAYER_WIRE) layer = "Wire"; + if (STRUCT->m_Layer == LAYER_BUS) layer = "Bus"; + if( STRUCT->m_Width != GR_NORM_WIDTH) layer = "Bus"; + if (fprintf(f, "Wire %s %s\n", layer, width ) == EOF) + { + Failed = TRUE; break; + } + if (fprintf(f, "\t%-4d %-4d %-4d %-4d\n", + STRUCT->m_Start.x,STRUCT->m_Start.y, + STRUCT->m_End.x,STRUCT->m_End.y) == EOF) + { + Failed = TRUE; break; + } + break; + + case DRAW_BUSENTRY_STRUCT_TYPE: /* Its a Raccord item. */ + #undef STRUCT + #define STRUCT ((DrawBusEntryStruct *) Phead) + layer = "Wire"; width = "Line"; + if (STRUCT->m_Layer == LAYER_BUS) + { + layer = "Bus"; width = "Bus"; + } + + if (fprintf(f, "Entry %s %s\n", layer, width) == EOF) + { + Failed = TRUE; break; + } + if( fprintf(f, "\t%-4d %-4d %-4d %-4d\n", + STRUCT->m_Pos.x,STRUCT->m_Pos.y, + STRUCT->m_End().x,STRUCT->m_End().y) == EOF) + { + Failed = TRUE; break; + } + break; + + case DRAW_POLYLINE_STRUCT_TYPE: /* Its a polyline item. */ + #undef STRUCT + #define STRUCT ((DrawPolylineStruct *) Phead) + layer = "Notes"; width = "Line"; + if (STRUCT->m_Layer == LAYER_WIRE) layer = "Wire"; + if (STRUCT->m_Layer == LAYER_BUS) layer = "Bus"; + if( STRUCT->m_Width != GR_NORM_WIDTH) width = "Bus"; + if (fprintf(f, "Poly %s %s %d\n", + width, layer, STRUCT->m_NumOfPoints) == EOF) + { + Failed = TRUE; break; + } + for (ii = 0; ii < STRUCT->m_NumOfPoints; ii++) + { + if (fprintf(f, "\t%-4d %-4d\n", + STRUCT->m_Points[ii*2], + STRUCT->m_Points[ii*2+1]) == EOF) + { + Failed = TRUE; + break; + } + } + break; + + case DRAW_JUNCTION_STRUCT_TYPE: /* Its a connection item. */ + #undef STRUCT + #define STRUCT ((DrawJunctionStruct *) Phead) + if (fprintf(f, "Connection ~ %-4d %-4d\n", + STRUCT->m_Pos.x, STRUCT->m_Pos.y) == EOF) + { + Failed = TRUE; + } + break; + + case DRAW_NOCONNECT_STRUCT_TYPE: /* Its a NoConnection item. */ + #undef STRUCT + #define STRUCT ((DrawNoConnectStruct *) Phead) + if (fprintf(f, "NoConn ~ %-4d %-4d\n", + STRUCT->m_Pos.x, STRUCT->m_Pos.y) == EOF) + { + Failed = TRUE; + } + break; + + case DRAW_TEXT_STRUCT_TYPE: /* Its a text item. */ + #undef STRUCT + #define STRUCT ((DrawTextStruct *) Phead) + if (fprintf(f, "Text Notes %-4d %-4d %-4d %-4d ~\n%s\n", + STRUCT->m_Pos.x, STRUCT->m_Pos.y, + STRUCT->m_Orient, STRUCT->m_Size.x, + CONV_TO_UTF8(STRUCT->m_Text)) == EOF) + Failed = TRUE; + break; + + + case DRAW_LABEL_STRUCT_TYPE: /* Its a label item. */ + #undef STRUCT + #define STRUCT ((DrawLabelStruct *) Phead) + shape = '~'; + if (fprintf(f, "Text Label %-4d %-4d %-4d %-4d %c\n%s\n", + STRUCT->m_Pos.x, STRUCT->m_Pos.y, + STRUCT->m_Orient, STRUCT->m_Size.x, shape, + CONV_TO_UTF8(STRUCT->m_Text)) == EOF) + Failed = TRUE; + break; + + + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: /* Its a Global label item. */ + #undef STRUCT + #define STRUCT ((DrawGlobalLabelStruct *) Phead) + shape = STRUCT->m_Shape; + if (fprintf(f, "Text GLabel %-4d %-4d %-4d %-4d %s\n%s\n", + STRUCT->m_Pos.x, STRUCT->m_Pos.y, + STRUCT->m_Orient, STRUCT->m_Size.x, + SheetLabelType[shape], + CONV_TO_UTF8(STRUCT->m_Text)) == EOF) + Failed = TRUE; + break; + + case DRAW_MARKER_STRUCT_TYPE: /* Its a marker item. */ + #undef STRUCT + #define STRUCT ((DrawMarkerStruct *) Phead) + if( STRUCT->GetComment() ) msg = STRUCT->GetComment(); + else msg.Empty(); + if (fprintf(f, "Kmarq %c %-4d %-4d \"%s\" F=%X\n", + (int) STRUCT->m_Type + 'A', + STRUCT->m_Pos.x, STRUCT->m_Pos.y, + CONV_TO_UTF8(msg), STRUCT->m_MarkFlags) == EOF) + { + Failed = TRUE; + } + break; + + case DRAW_SHEETLABEL_STRUCT_TYPE : + case DRAW_PICK_ITEM_STRUCT_TYPE : + break; + + default: + break; + } + + if (Failed) + { + DisplayError(this, _("File write operation failed.")); + break; + } + + Phead = Phead->Pnext; + } + if (fprintf(f, "$EndSCHEMATC\n") == EOF) Failed = TRUE; + + fclose(f); + + if (FileSave == FILE_SAVE_NEW) screen->m_FileName = Name; + + return !Failed; +} + + +/*******************************************************************/ +static int SavePartDescr( FILE *f, EDA_SchComponentStruct * LibItemStruct) +/*******************************************************************/ +/* Routine utilisee dans la routine precedente. + Assure la sauvegarde de la structure LibItemStruct +*/ +{ +int ii, Failed = FALSE; +char Name1[256], Name2[256]; +int hjustify, vjustify; + + strcpy(Name1, CONV_TO_UTF8(LibItemStruct->m_Field[REFERENCE].m_Text)); + for (ii = 0; ii < (int)strlen(Name1); ii++) + if (Name1[ii] <= ' ') Name1[ii] = '~'; + + if ( ! LibItemStruct->m_ChipName.IsEmpty() ) + { + strcpy(Name2, CONV_TO_UTF8(LibItemStruct->m_ChipName)); + for (ii = 0; ii < (int)strlen(Name2); ii++) + if (Name2[ii] <= ' ') Name2[ii] = '~'; + } + + else strcpy(Name2, NULL_STRING); + + fprintf(f, "$Comp\n"); + + if(fprintf (f, "L %s %s\n", Name2, Name1) == EOF) + { + Failed = TRUE; + return(Failed); + } + + /* Generation de numero d'unit, convert et Time Stamp*/ + if(fprintf(f, "U %d %d %8.8lX\n", + LibItemStruct->m_Multi, + LibItemStruct->m_Convert, + LibItemStruct->m_TimeStamp) == EOF) + { + Failed = TRUE; return(Failed); + } + + /* Sortie de la position */ + if(fprintf(f, "P %d %d\n", + LibItemStruct->m_Pos.x, LibItemStruct->m_Pos.y) == EOF) + { + Failed = TRUE; return(Failed); + } + + for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ ) + { + PartTextStruct * field = & LibItemStruct->m_Field[ii]; + if( field->m_Text.IsEmpty() ) continue; + hjustify = 'C'; + if ( field->m_HJustify == GR_TEXT_HJUSTIFY_LEFT) + hjustify = 'L'; + else if ( field->m_HJustify == GR_TEXT_HJUSTIFY_RIGHT) + hjustify = 'R'; + vjustify = 'C'; + if ( field->m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM) + vjustify = 'B'; + else if ( field->m_VJustify == GR_TEXT_VJUSTIFY_TOP) + vjustify = 'T'; + if( fprintf(f,"F %d \"%s\" %c %-3d %-3d %-3d %4.4X %c %c", ii, + CONV_TO_UTF8(field->m_Text), + field->m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V', + field->m_Pos.x, field->m_Pos.y, + field->m_Size.x, + field->m_Attributs, + hjustify, vjustify) == EOF) + { + Failed = TRUE; break; + } + // Save field name, if necessary + if ( ii >= FIELD1 && ! field->m_Name.IsEmpty() ) + { + wxString fieldname = ReturnDefaultFieldName(ii); + if ( fieldname != field->m_Name ) + if( fprintf(f," \"%s\"", CONV_TO_UTF8(field->m_Name) ) == EOF) + { + Failed = TRUE; break; + } + } + if( fprintf(f,"\n") == EOF) + { + Failed = TRUE; break; + } + } + + if (Failed) return(Failed); + + /* Generation du num unit, position, box ( ancienne norme )*/ + if(fprintf(f, "\t%-4d %-4d %-4d\n", + LibItemStruct->m_Multi, + LibItemStruct->m_Pos.x, LibItemStruct->m_Pos.y) == EOF) + { + Failed = TRUE; return(Failed); + } + + if( fprintf(f, "\t%-4d %-4d %-4d %-4d\n", + LibItemStruct->m_Transform[0][0], + LibItemStruct->m_Transform[0][1], + LibItemStruct->m_Transform[1][0], + LibItemStruct->m_Transform[1][1]) == EOF) + { + Failed = TRUE; return(Failed); + } + + fprintf(f, "$EndComp\n"); + return(Failed); +} + +/*******************************************************************/ +static int SaveSheetDescr( FILE *f, DrawSheetStruct * SheetStruct) +/*******************************************************************/ +/* Routine utilisee dans la routine precedente. + Assure la sauvegarde de la structure LibItemStruct +*/ +{ +int ii; +int Failed = FALSE; +DrawSheetLabelStruct * SheetLabel; + + fprintf(f, "$Sheet\n"); + + if (fprintf(f, "S %-4d %-4d %-4d %-4d\n", + SheetStruct->m_Pos.x,SheetStruct->m_Pos.y, + SheetStruct->m_Size.x,SheetStruct->m_Size.y) == EOF) + { + Failed = TRUE; return(Failed); + } + + /* Generation de la liste des 2 textes (sheetname et filename) */ + if ( ! SheetStruct->m_SheetName.IsEmpty()) + { + if(fprintf(f,"F0 \"%s\" %d\n", CONV_TO_UTF8(SheetStruct->m_SheetName), + SheetStruct->m_SheetNameSize) == EOF) + { + Failed = TRUE; return(Failed); + } + } + + if( ! SheetStruct->m_FileName.IsEmpty()) + { + if(fprintf(f,"F1 \"%s\" %d\n", + CONV_TO_UTF8(SheetStruct->m_FileName), + SheetStruct->m_FileNameSize) == EOF) + { + Failed = TRUE; return(Failed); + } + } + + /* Generation de la liste des labels (entrees) de la sous feuille */ + ii = 2; + SheetLabel = SheetStruct->m_Label; + while( SheetLabel != NULL ) + { + int type = 'U', side = 'L'; + + if( SheetLabel->m_Text.IsEmpty() ) continue; + if( SheetLabel->m_Edge ) side = 'R'; + + switch(SheetLabel->m_Shape) + { + case NET_INPUT: type = 'I'; break; + case NET_OUTPUT: type = 'O'; break; + case NET_BIDI: type = 'B'; break; + case NET_TRISTATE: type = 'T'; break; + case NET_UNSPECIFIED: type = 'U'; break; + } + + if(fprintf(f,"F%d \"%s\" %c %c %-3d %-3d %-3d\n", ii, + CONV_TO_UTF8(SheetLabel->m_Text), type, side, + SheetLabel->m_Pos.x, SheetLabel->m_Pos.y, + SheetLabel->m_Size.x) == EOF) + { + Failed = TRUE; break; + } + ii++; + SheetLabel = (DrawSheetLabelStruct*)SheetLabel->Pnext; + } + + fprintf(f, "$EndSheet\n"); + return(Failed); +} + +/****************************/ +static void SaveLayers(FILE *f) +/****************************/ +/* Save a Layer Structure to a file +theses infos are not used in eeschema +*/ +{ + fprintf(f,"EELAYER %2d %2d\n", g_LayerDescr.NumberOfLayers,g_LayerDescr.CurrentLayer); + fprintf(f,"EELAYER END\n"); +} + + diff --git a/eeschema/savelib.cpp b/eeschema/savelib.cpp new file mode 100644 index 0000000000..ab1622f1e6 --- /dev/null +++ b/eeschema/savelib.cpp @@ -0,0 +1,603 @@ + /****************************/ + /* EESchema - eesavlib.cpp */ + /****************************/ + +/* Write Routines to save schematic libraries and library components (::WriteDescr() members) +*/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +/* Routines locales */ + +/* Variables locales */ + + +static bool WriteLibEntryDateAndTime(FILE * ExportFile, + EDA_LibComponentStruct * LibEntry); + + +static int fill_tab[3] = { 'N', 'F', 'f' }; + +/***********************************************/ +bool LibDrawArc::WriteDescr( FILE * ExportFile ) +/***********************************************/ +/* format +A centre_posx centre_posy rayon start_angle end_angle unit convert fill('N', 'F' ou 'f') startx starty endx endy +*/ +{ +int x1 = t1; if(x1 > 1800) x1 -= 3600; +int x2 = t2; if(x2 > 1800) x2 -= 3600; + + fprintf(ExportFile,"A %d %d %d %d %d %d %d %d %c %d %d %d %d\n", + m_Pos.x, m_Pos.y, + m_Rayon, x1, x2, + m_Unit,m_Convert, + m_Width, fill_tab[m_Fill], + m_Start.x, m_Start.y, m_End.x, m_End.y); + return FALSE; +} + +/***************************************************/ +bool LibDrawCircle::WriteDescr( FILE * ExportFile ) +/***************************************************/ +{ + fprintf(ExportFile,"C %d %d %d %d %d %d %c\n", + m_Pos.x, m_Pos.y, + m_Rayon, + m_Unit,m_Convert, + m_Width, fill_tab[m_Fill]); + return FALSE; +} + +/************************************************/ +bool LibDrawText::WriteDescr( FILE * ExportFile ) +/************************************************/ +{ +wxString text = m_Text; + + text.Replace( wxT(" "), wxT("~") ); // Spaces are not allowed: changed to '~' + + fprintf(ExportFile,"T %d %d %d %d %d %d %d %s\n", + m_Horiz, + m_Pos.x, m_Pos.y, + m_Size.x, m_Type, + m_Unit,m_Convert, + CONV_TO_UTF8(text) ); + return FALSE; +} + +/***************************************************/ +bool LibDrawSquare::WriteDescr( FILE * ExportFile ) +/***************************************************/ +{ + fprintf(ExportFile,"S %d %d %d %d %d %d %d %c\n", + m_Start.x, m_Start.y, m_End.x, m_End.y, + m_Unit,m_Convert, + m_Width, fill_tab[m_Fill]); + return FALSE; +} + + +/************************************************/ +bool LibDrawPin::WriteDescr( FILE * ExportFile ) +/************************************************/ +{ +int Etype = 'I'; +wxString StringPinNum; + + switch(m_PinType) + { + case PIN_INPUT: Etype = 'I'; break; + case PIN_OUTPUT: Etype = 'O'; break; + case PIN_BIDI: Etype = 'B'; break; + case PIN_TRISTATE: Etype = 'T'; break; + case PIN_PASSIVE: Etype = 'P'; break; + case PIN_UNSPECIFIED: Etype = 'U'; break; + case PIN_POWER_IN: Etype = 'W'; break; + case PIN_POWER_OUT: Etype = 'w'; break; + case PIN_OPENCOLLECTOR: Etype = 'C'; break; + case PIN_OPENEMITTER: Etype = 'E'; break; + } + + ReturnPinStringNum(StringPinNum); + if ( StringPinNum.IsEmpty() ) StringPinNum = wxT("~"); + + if( ! m_PinName.IsEmpty() ) + fprintf(ExportFile,"X %s", CONV_TO_UTF8(m_PinName) ); + else fprintf(ExportFile,"X ~"); + + fprintf(ExportFile," %s %d %d %d %c %d %d %d %d %c", + CONV_TO_UTF8(StringPinNum), + m_Pos.x, m_Pos.y, + (int)m_PinLen, (int)m_Orient, + m_SizeNum, m_SizeName, + m_Unit,m_Convert, Etype); + + if( (m_PinShape) || (m_Attributs & PINNOTDRAW) ) + fprintf(ExportFile," "); + if (m_Attributs & PINNOTDRAW) fprintf(ExportFile,"N"); + if (m_PinShape & INVERT) fprintf(ExportFile,"I"); + if (m_PinShape & CLOCK) fprintf(ExportFile,"C"); + if (m_PinShape & LOWLEVEL_IN) fprintf(ExportFile,"L"); + if (m_PinShape & LOWLEVEL_OUT) fprintf(ExportFile,"V"); + + fprintf(ExportFile,"\n"); + return FALSE; +} + +/****************************************************/ +bool LibDrawPolyline::WriteDescr( FILE * ExportFile ) +/****************************************************/ +{ +int ii, *ptpoly; + + fprintf(ExportFile,"P %d %d %d %d", + n, + m_Unit,m_Convert, + m_Width); + ptpoly = PolyList; + for( ii = n ; ii > 0; ii-- ) + { + fprintf(ExportFile," %d %d", *ptpoly, *(ptpoly+1) ); + ptpoly += 2; + } + fprintf(ExportFile," %c\n", fill_tab[m_Fill]); + return FALSE; +} + + +/**************************************************/ +bool LibDrawField::WriteDescr( FILE * ExportFile ) +/**************************************************/ +{ +int hjustify, vjustify; +wxString text = m_Text; + + hjustify = 'C'; + if ( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) hjustify = 'L'; + else if ( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) hjustify = 'R'; + vjustify = 'C'; + if ( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM) vjustify = 'B'; + else if ( m_VJustify == GR_TEXT_VJUSTIFY_TOP) vjustify = 'T'; + if ( text.IsEmpty() ) text = wxT("~"); + fprintf(ExportFile,"F%d \"%s\" %d %d %d %c %c %c %c", + m_FieldId, CONV_TO_UTF8(text), + m_Pos.x, m_Pos.y, + m_Size.x, + m_Orient == 0 ? 'H' : 'V', + (m_Attributs & TEXT_NO_VISIBLE )? 'I' : 'V', + hjustify, vjustify ); + // Save field name, if necessary + if ( m_FieldId >= FIELD1 && ! m_Name.IsEmpty() ) + fprintf(ExportFile," \"%s\"", CONV_TO_UTF8(m_Name) ); + + fprintf(ExportFile,"\n"); + return FALSE; +} + +/**********************************************************/ +LibEDA_BaseStruct * CopyDrawEntryStruct( wxWindow * frame, + LibEDA_BaseStruct * DrawItem) +/**********************************************************/ +/* Routine de Duplication d'une structure DrawLibItem d'une partlib + Parametres d'entree: + DrawEntry = pointeur sur la structure a dupliquer + La structure nouvelle est creee, mais n'est pas inseree dans le + chainage + Retourne: + Pointeur sur la structure creee +*/ +{ +LibEDA_BaseStruct * NewDrawItem = NULL; +wxString msg; + + switch(DrawItem->m_StructType) + { + case COMPONENT_ARC_DRAW_TYPE: + NewDrawItem = ((LibDrawArc*)DrawItem)->GenCopy(); + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + NewDrawItem = ((LibDrawCircle*)DrawItem)->GenCopy(); + break; + + case COMPONENT_RECT_DRAW_TYPE: + NewDrawItem = ((LibDrawSquare*)DrawItem)->GenCopy(); + break; + + case COMPONENT_PIN_DRAW_TYPE: + NewDrawItem = ((LibDrawPin*)DrawItem)->GenCopy(); + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + NewDrawItem = ((LibDrawText*)DrawItem)->GenCopy(); + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + NewDrawItem = ((LibDrawPolyline*)DrawItem)->GenCopy(); + break; + + default: + msg.Printf( wxT("CopyDrawLibEntryStruct: unknown Draw Type %d"), + DrawItem->m_StructType); + DisplayError(frame, msg); + break; + } + + return(NewDrawItem); +} + +/*************************************************************************************************/ +EDA_LibComponentStruct * CopyLibEntryStruct ( wxWindow * frame, EDA_LibComponentStruct * OldEntry) +/*************************************************************************************************/ +/* Routine de copie d'une partlib + Parametres d'entree: pointeur sur la structure de depart + Parametres de sortie: pointeur sur la structure creee + Do not copy new items ( i.e. with m_Flag & IS_NEW) +*/ +{ +EDA_LibComponentStruct * NewStruct; +LibEDA_BaseStruct * NewDrawings, * OldDrawings; +LibEDA_BaseStruct * LastItem; +LibDrawField * OldField, * NewField; + + if( OldEntry->Type != ROOT ) + { + DisplayError(frame, wxT("CopyLibEntryStruct(): Type != ROOT")); + return(NULL); + } + + NewStruct = new EDA_LibComponentStruct(NULL); + OldEntry->m_Prefix.Copy(&NewStruct->m_Prefix); + OldEntry->m_Name.Copy(&NewStruct->m_Name); + + NewStruct->m_UnitCount = OldEntry->m_UnitCount; + NewStruct->m_TextInside = OldEntry->m_TextInside; + NewStruct->m_DrawPinNum = OldEntry->m_DrawPinNum; + NewStruct->m_DrawPinName = OldEntry->m_DrawPinName; + NewStruct->m_Options = OldEntry->m_Options; + NewStruct->m_UnitSelectionLocked = OldEntry->m_UnitSelectionLocked; + + /* Copie des sous structures: */ + NewStruct->m_AliasList = OldEntry->m_AliasList; + NewStruct->m_Doc = OldEntry->m_Doc; + NewStruct->m_KeyWord = OldEntry->m_KeyWord; + NewStruct->m_DocFile = OldEntry->m_DocFile; + + /* Copie des champs */ + for(OldField = OldEntry->Fields; OldField != NULL; + OldField = (LibDrawField*)OldField->Pnext) + { + NewField = OldField->GenCopy(); + NewField->Pnext = NewStruct->Fields; + NewStruct->Fields = NewField; + } + + /* Copie des elements type Drawing */ + LastItem = NULL; + for(OldDrawings = OldEntry->m_Drawings; OldDrawings != NULL; OldDrawings = OldDrawings->Next()) + { + if ( ( OldDrawings->m_Flags & IS_NEW) != 0 ) continue; + NewDrawings = CopyDrawEntryStruct(frame, OldDrawings); + if ( NewDrawings ) + { + if (LastItem == NULL ) NewStruct->m_Drawings = NewDrawings; + else LastItem->Pnext = NewDrawings; + LastItem = NewDrawings; + NewDrawings->Pnext = NULL; + } + else // Probleme rencontré: arret de copie + { + OldDrawings->m_StructType = TYPE_NOT_INIT; + DisplayError(frame, wxT("CopyLibEntryStruct(): error: aborted")); + break; + } + } + + /* Copy the footprint filter list */ + for ( unsigned ii = 0 ; ii < OldEntry->m_FootprintList.GetCount(); ii++ ) + NewStruct->m_FootprintList.Add(OldEntry->m_FootprintList[ii]); + + return(NewStruct); +} + + +/********************************************************/ +int WriteOneLibEntry(wxWindow * frame, FILE * ExportFile, + EDA_LibComponentStruct * LibEntry) +/********************************************************/ + +/* Routine d'ecriture du composant pointe par LibEntry + dans le fichier ExportFile( qui doit etre deja ouvert) + return: 0 si Ok + -1 si err write + 1 si composant non ecrit ( type ALIAS ) +*/ +#define UNUSED 0 +{ +LibEDA_BaseStruct *DrawEntry; +LibDrawField * Field; + + if( LibEntry->Type != ROOT ) return(1); + + /* Creation du commentaire donnant le nom du composant */ + fprintf(ExportFile,"#\n# %s\n#\n", CONV_TO_UTF8(LibEntry->m_Name.m_Text)); + + /* Generation des lignes utiles */ + fprintf(ExportFile,"DEF"); + if( (LibEntry->m_Name.m_Attributs & TEXT_NO_VISIBLE) == 0) + fprintf(ExportFile," %s", CONV_TO_UTF8(LibEntry->m_Name.m_Text)); + else fprintf(ExportFile," ~%s", CONV_TO_UTF8(LibEntry->m_Name.m_Text)); + + if( ! LibEntry->m_Prefix.m_Text.IsEmpty()) + fprintf(ExportFile," %s", CONV_TO_UTF8(LibEntry->m_Prefix.m_Text)); + else fprintf(ExportFile," ~"); + fprintf(ExportFile," %d %d %c %c %d %c %c\n", + UNUSED, LibEntry->m_TextInside, + LibEntry->m_DrawPinNum ? 'Y' : 'N', + LibEntry->m_DrawPinName ? 'Y' : 'N', + LibEntry->m_UnitCount, LibEntry->m_UnitSelectionLocked ? 'L' : 'F', + LibEntry->m_Options == ENTRY_POWER ? 'P' : 'N'); + + WriteLibEntryDateAndTime(ExportFile, LibEntry); + + /* Position / orientation / visibilite des champs */ + LibEntry->m_Prefix.WriteDescr( ExportFile ); + LibEntry->m_Name.WriteDescr( ExportFile ); + + for ( Field = LibEntry->Fields; Field!= NULL; + Field = (LibDrawField*)Field->Pnext ) + { + if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() ) continue; + Field->WriteDescr( ExportFile ); + } + + /* Sauvegarde de la ligne "ALIAS" */ + if( LibEntry->m_AliasList.GetCount() != 0) + { + fprintf(ExportFile,"ALIAS"); + unsigned ii; + for ( ii = 0; ii < LibEntry->m_AliasList.GetCount(); ii++ ) + fprintf(ExportFile," %s", CONV_TO_UTF8(LibEntry->m_AliasList[ii])); + fprintf(ExportFile,"\n"); + } + + /* Write the footprint filter list */ + if( LibEntry->m_FootprintList.GetCount() != 0) + { + fprintf(ExportFile,"$FPLIST\n"); + unsigned ii; + for ( ii = 0; ii < LibEntry->m_FootprintList.GetCount(); ii++ ) + fprintf(ExportFile," %s\n", CONV_TO_UTF8(LibEntry->m_FootprintList[ii])); + fprintf(ExportFile,"$ENDFPLIST\n"); + } + + /* Sauvegarde des elements de trace */ + DrawEntry = LibEntry->m_Drawings; + if(LibEntry->m_Drawings) + { + /* we sort the draw items, in order to have an edition more easy, + when a file editing "by hand" is made */ + LibEntry->SortDrawItems(); + + fprintf(ExportFile,"DRAW\n"); + DrawEntry = LibEntry->m_Drawings; + while( DrawEntry ) + { + switch( DrawEntry->m_StructType) + { + case COMPONENT_ARC_DRAW_TYPE: + #define DRAWSTRUCT ((LibDrawArc *) DrawEntry) + DRAWSTRUCT->WriteDescr( ExportFile ); + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + #undef DRAWSTRUCT + #define DRAWSTRUCT ((LibDrawCircle *) DrawEntry) + DRAWSTRUCT->WriteDescr( ExportFile ); + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + #undef DRAWSTRUCT + #define DRAWSTRUCT ((LibDrawText *) DrawEntry) + DRAWSTRUCT->WriteDescr( ExportFile ); + break; + + case COMPONENT_RECT_DRAW_TYPE: + #undef DRAWSTRUCT + #define DRAWSTRUCT ((LibDrawSquare *) DrawEntry) + DRAWSTRUCT->WriteDescr( ExportFile ); + break; + + case COMPONENT_PIN_DRAW_TYPE: + #undef DRAWSTRUCT + #define DRAWSTRUCT ((LibDrawPin *) DrawEntry) + DRAWSTRUCT->WriteDescr( ExportFile ); + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + #undef DRAWSTRUCT + #define DRAWSTRUCT ((LibDrawPolyline *) DrawEntry) + DRAWSTRUCT->WriteDescr( ExportFile ); + break; + + default: DisplayError(frame, wxT("Save Lib: Unknown Draw Type")); + break; + } + + DrawEntry = DrawEntry->Next(); + } + fprintf(ExportFile,"ENDDRAW\n"); + } + + fprintf(ExportFile,"ENDDEF\n"); + + return(0); +} + +/*************************************************************************/ +int WriteOneDocLibEntry(FILE * ExportFile, EDA_LibComponentStruct * LibEntry) +/*************************************************************************/ + +/* Routine d'ecriture de la doc du composant pointe par LibEntry + dans le fichier ExportFile( qui doit etre deja ouvert) + return: 0 si Ok + 1 si err write + Cependant, si i tous les Pointeurs sur textes sont nulls ( pas de Doc ) + rien ne sera ecrit. +*/ +{ + + if( (LibEntry->m_Doc.IsEmpty() ) && + (LibEntry->m_KeyWord.IsEmpty() ) && + (LibEntry->m_DocFile.IsEmpty() ) ) + return(0); + + /* Generation des lignes utiles */ + fprintf(ExportFile,"#\n$CMP %s\n", CONV_TO_UTF8(LibEntry->m_Name.m_Text)); + + if( ! LibEntry->m_Doc.IsEmpty()) + fprintf(ExportFile,"D %s\n", CONV_TO_UTF8(LibEntry->m_Doc)); + + if( ! LibEntry->m_KeyWord.IsEmpty()) + fprintf(ExportFile,"K %s\n", CONV_TO_UTF8(LibEntry->m_KeyWord)); + + if( ! LibEntry->m_DocFile.IsEmpty()) + fprintf(ExportFile,"F %s\n", CONV_TO_UTF8(LibEntry->m_DocFile)); + + fprintf(ExportFile,"$ENDCMP\n"); + return(0); +} + +/*********************************************************************************/ +int SaveOneLibrary(wxWindow * frame, const wxString & FullFileName, LibraryStruct * Library) +/*********************************************************************************/ +/* Sauvegarde en fichier la librairie pointee par Library, sous le nom + FullFileName. + 2 fichiers sont crees + - La librarie + - le fichier de documentation + + une sauvegarde .bak de l'ancien fichier librairie est cree + une sauvegarde .bck de l'ancien fichier documentation est cree + + return: + 0 si OK + 1 si erreur +*/ +{ +FILE * SaveFile, * SaveDocFile; +EDA_LibComponentStruct *LibEntry; +char Line[1024]; +int err = 1; +wxString Name,DocName,BakName, msg; + + if(Library == NULL) return(err); + + Name = FullFileName; + + /* L'ancien fichier lib est renomme en .bak */ + if( wxFileExists(Name) ) + { + BakName = Name; ChangeFileNameExt(BakName, wxT(".bak")); + wxRemoveFile(BakName); + if( ! wxRenameFile(Name, BakName) ) + { + msg = wxT("Failed to rename old lib file ") + BakName; + DisplayError(frame, msg, 20); + } + } + + + DocName = Name; ChangeFileNameExt(DocName,DOC_EXT); + /* L'ancien fichier doc lib est renomme en .bck */ + if( wxFileExists(DocName) ) + { + BakName = DocName; ChangeFileNameExt(BakName, wxT(".bck") ); + wxRemoveFile(BakName); + if( ! wxRenameFile(DocName, BakName) ) + { + msg = wxT("Failed to save old doc lib file ") + BakName; + DisplayError(frame, msg, 20); + } + } + + + SaveFile = wxFopen(Name, wxT("wt") ); + if (SaveFile == NULL) + { + msg = wxT("Failed to create Lib File ") + Name; + DisplayError(frame, msg, 20); + return(err); + } + + SaveDocFile = wxFopen(DocName, wxT("wt") ); + if (SaveDocFile == NULL) + { + msg = wxT("Failed to create DocLib File ") + DocName; + DisplayError(frame, msg, 20); + return(err); + } + + Library->m_Modified = 0; + + /* Creation de l'entete de la librairie */ + Library->m_TimeStamp = GetTimeStamp(); + Library->WriteHeader(SaveFile); + fprintf(SaveDocFile,"%s Date: %s\n", DOCFILE_IDENT, + DateAndTime(Line) ); + + + /* Sauvegarde des composant: */ + PQCompFunc((PQCompFuncType) LibraryEntryCompare); + LibEntry = (EDA_LibComponentStruct *) PQFirst(&Library->m_Entries, FALSE); + + while( LibEntry ) + { + err = WriteOneLibEntry(frame, SaveFile, LibEntry); + err = WriteOneDocLibEntry(SaveDocFile, LibEntry); + + LibEntry = (EDA_LibComponentStruct *) + PQNext(Library->m_Entries, LibEntry, NULL); + } + + fprintf(SaveFile,"#\n#End Library\n"); + fprintf(SaveDocFile,"#\n#End Doc Library\n"); + fclose(SaveFile); + fclose(SaveDocFile); + return(err); +} + + +/*************************************************************************************/ +static bool WriteLibEntryDateAndTime(FILE * ExportFile, EDA_LibComponentStruct * LibEntry) +/*************************************************************************************/ +/* lit date et time de modif composant sous le format: + "Ti yy/mm/jj hh:mm:ss" +*/ +{ +int year,mon,day,hour,min,sec; + + if ( LibEntry->m_LastDate == 0 ) return TRUE; + + sec = LibEntry->m_LastDate & 63; + min = (LibEntry->m_LastDate >> 6) & 63 ; + hour = (LibEntry->m_LastDate >> 12) & 31; + day = (LibEntry->m_LastDate >> 17) & 31; + mon = (LibEntry->m_LastDate >> 22) & 15; + year = (LibEntry->m_LastDate >> 26) + 1990; + + fprintf(ExportFile,"Ti %d/%d/%d %d:%d:%d\n",year,mon,day,hour,min,sec); + + return TRUE; +} + + diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp new file mode 100644 index 0000000000..b89cab7b7e --- /dev/null +++ b/eeschema/schedit.cpp @@ -0,0 +1,787 @@ + /******************************************************/ + /* schedit.cpp: fonctions generales de la schematique */ + /******************************************************/ + +#include "fctsys.h" + +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "id.h" + +#include "protos.h" + +/********************************************************************************/ +void WinEDA_SchematicFrame::Process_Special_Functions(wxCommandEvent& event) +/********************************************************************************/ +/* Traite les selections d'outils et les commandes appelees du menu POPUP +*/ +{ +int id = event.GetId(); +wxPoint pos; +wxClientDC dc(DrawPanel); +wxPoint defaultpos(-1,-1); + + DrawPanel->PrepareGraphicContext(&dc); + + pos = wxGetMousePosition(); + + pos.y += 20; + + // If needed, stop the current command and deselect current tool + switch ( id ) + { + case ID_POPUP_SCH_ENTRY_SELECT_SLASH: // Do nothing: + case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH: + case ID_POPUP_END_LINE: + case ID_POPUP_SCH_EDIT_TEXT: + case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL: + case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL: + case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT: + case ID_POPUP_SCH_SET_SHAPE_TEXT: + case ID_POPUP_SCH_ROTATE_TEXT: + case ID_POPUP_SCH_EDIT_SHEET: + case ID_POPUP_SCH_CLEANUP_SHEET: + case ID_POPUP_SCH_END_SHEET: + case ID_POPUP_SCH_RESIZE_SHEET: + case ID_POPUP_SCH_EDIT_PINSHEET: + case ID_POPUP_SCH_MOVE_PINSHEET: + case ID_POPUP_SCH_MOVE_ITEM_REQUEST: + case ID_POPUP_SCH_MOVE_CMP_REQUEST: + case ID_POPUP_SCH_EDIT_CMP: + case ID_POPUP_SCH_MIROR_X_CMP: + case ID_POPUP_SCH_MIROR_Y_CMP: + case ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE: + case ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE: + case ID_POPUP_SCH_ORIENT_NORMAL_CMP: + case ID_POPUP_SCH_INIT_CMP: + case ID_POPUP_SCH_DISPLAYDOC_CMP: + case ID_POPUP_SCH_EDIT_VALUE_CMP: + case ID_POPUP_SCH_EDIT_REF_CMP: + case ID_POPUP_SCH_EDIT_CONVERT_CMP: + case ID_POPUP_SCH_SELECT_UNIT_CMP: + case ID_POPUP_SCH_SELECT_UNIT1: + case ID_POPUP_SCH_SELECT_UNIT2: + case ID_POPUP_SCH_SELECT_UNIT3: + case ID_POPUP_SCH_SELECT_UNIT4: + case ID_POPUP_SCH_SELECT_UNIT5: + case ID_POPUP_SCH_SELECT_UNIT6: + case ID_POPUP_SCH_SELECT_UNIT7: + case ID_POPUP_SCH_SELECT_UNIT8: + case ID_POPUP_SCH_SELECT_UNIT9: + case ID_POPUP_SCH_SELECT_UNIT10: + case ID_POPUP_SCH_SELECT_UNIT11: + case ID_POPUP_SCH_SELECT_UNIT12: + case ID_POPUP_SCH_SELECT_UNIT13: + case ID_POPUP_SCH_SELECT_UNIT14: + case ID_POPUP_SCH_SELECT_UNIT15: + case ID_POPUP_SCH_SELECT_UNIT16: + case ID_POPUP_SCH_SELECT_UNIT17: + case ID_POPUP_SCH_SELECT_UNIT18: + case ID_POPUP_SCH_SELECT_UNIT19: + case ID_POPUP_SCH_SELECT_UNIT20: + case ID_POPUP_SCH_SELECT_UNIT21: + case ID_POPUP_SCH_SELECT_UNIT22: + case ID_POPUP_SCH_SELECT_UNIT23: + case ID_POPUP_SCH_SELECT_UNIT24: + case ID_POPUP_SCH_SELECT_UNIT25: + case ID_POPUP_SCH_SELECT_UNIT26: + case ID_POPUP_SCH_ROTATE_FIELD: + case ID_POPUP_SCH_EDIT_FIELD: + case ID_POPUP_DELETE_BLOCK: + case ID_POPUP_PLACE_BLOCK: + case ID_POPUP_ZOOM_BLOCK: + case ID_POPUP_DRAG_BLOCK: + case ID_POPUP_COPY_BLOCK: + case ID_POPUP_ROTATE_BLOCK: + case ID_POPUP_MIRROR_X_BLOCK: + case ID_POPUP_MIRROR_Y_BLOCK: + case ID_POPUP_SCH_DELETE_NODE: + case ID_POPUP_SCH_DELETE_CONNECTION: + case wxID_CUT: + case wxID_COPY: + case ID_POPUP_SCH_ENTER_SHEET: + case ID_POPUP_SCH_LEAVE_SHEET: + case ID_POPUP_SCH_ADD_JUNCTION: + case ID_POPUP_SCH_ADD_LABEL: + break; // Do nothing: + + case ID_POPUP_CANCEL_CURRENT_COMMAND: + if (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE) + DrawPanel->SetCursor(wxCursor(DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor) ); + + if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + /* ne devrait pas etre execute, sauf bug: */ + if (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE) + { + m_CurrentScreen->BlockLocate.m_Command = BLOCK_IDLE; + m_CurrentScreen->BlockLocate.m_State = STATE_NO_BLOCK; + m_CurrentScreen->BlockLocate.m_BlockDrawStruct = NULL; + } + break; + + case ID_POPUP_SCH_DELETE_CMP: + case ID_POPUP_SCH_DELETE: // Stop the, current command, keep the current tool + if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + break; + + default: // Stop the current command, and deselect the current tool + if(DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor = wxCURSOR_ARROW; + SetToolID(0, DrawPanel->m_PanelCursor, wxEmptyString); + break; + } // End switch commande en cours + + switch ( id ) // Command execution: + { + case ID_EXIT : + Close(TRUE); + break; + + case ID_NEW_PROJECT: /* New EED Project */ + LoadOneEEProject( wxEmptyString, TRUE); + break; + + case ID_LOAD_PROJECT: + LoadOneEEProject( wxEmptyString, FALSE); + break; + + case ID_LOAD_FILE_1: + case ID_LOAD_FILE_2: + case ID_LOAD_FILE_3: + case ID_LOAD_FILE_4: + case ID_LOAD_FILE_5: + case ID_LOAD_FILE_6: + case ID_LOAD_FILE_7: + case ID_LOAD_FILE_8: + case ID_LOAD_FILE_9: + case ID_LOAD_FILE_10: + LoadOneEEProject(GetLastProject(id - ID_LOAD_FILE_1).GetData(), FALSE); + break; + + case ID_TO_LIBRARY : + if ( m_Parent->LibeditFrame ) + { + m_Parent->LibeditFrame->Show(TRUE); + } + else + { + m_Parent->LibeditFrame = new + WinEDA_LibeditFrame(m_Parent->SchematicFrame, + m_Parent, + wxT("Library Editor"), + wxPoint(-1,-1), wxSize(600,400) ); + ActiveScreen = ScreenLib; + m_Parent->LibeditFrame->AdjustScrollBars(); + } + break; + + case ID_TO_PCB: + { + wxString Line; + if( ScreenSch->m_FileName != wxEmptyString ) + { + Line = ScreenSch->m_FileName; + AddDelimiterString(Line); + ChangeFileNameExt( Line,wxEmptyString); + ExecuteFile(this, PCBNEW_EXE, Line); + } + + else ExecuteFile(this, PCBNEW_EXE); + break; + } + + case ID_TO_CVPCB: + { + wxString Line; + if( ScreenSch->m_FileName != wxEmptyString ) + { + Line = ScreenSch->m_FileName; + AddDelimiterString(Line); + ChangeFileNameExt( Line,wxEmptyString); + ExecuteFile(this, CVPCB_EXE, Line); + } + + else ExecuteFile(this, CVPCB_EXE); + break; + } + + case ID_TO_LIBVIEW : + if ( m_Parent->ViewlibFrame ) + { + m_Parent->ViewlibFrame->Show(TRUE); + } + else + { + m_Parent->ViewlibFrame = new + WinEDA_ViewlibFrame(m_Parent->SchematicFrame, m_Parent); + m_Parent->ViewlibFrame->AdjustScrollBars(); + } + break; + + case ID_HIERARCHY: + InstallHierarchyFrame(&dc, pos); + g_ItemToRepeat = NULL; + break; + + case wxID_CUT: + if ( m_CurrentScreen->BlockLocate.m_Command != BLOCK_MOVE ) + break; + HandleBlockEndByPopUp(BLOCK_DELETE, &dc); + g_ItemToRepeat = NULL; + break; + + + case wxID_PASTE: + HandleBlockBegin(&dc, BLOCK_PASTE,m_CurrentScreen->m_Curseur); + break; + + case ID_GET_ANNOTATE: + InstallAnnotateFrame(this, defaultpos); + break; + + case ID_GET_ERC: + InstallErcFrame(this, defaultpos); + break; + + case ID_GET_NETLIST: + InstallNetlistFrame(this, defaultpos); + break; + + case ID_GET_TOOLS: + InstallToolsFrame(this, defaultpos ); + break; + + case ID_FIND_ITEMS: + InstallFindFrame(this, pos); + break; + + case ID_HIERARCHY_PUSH_POP_BUTT: + SetToolID( id, wxCURSOR_HAND, _("Push/Pop Hierarchy") ); + break; + + case ID_NOCONN_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add NoConnect Flag")); + break; + + case ID_WIRE_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Wire")); + break; + + case ID_BUS_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Bus")); + break; + + case ID_LINE_COMMENT_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Drawing")); + break; + + case ID_JUNCTION_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Junction")); + break; + + case ID_LABEL_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Label")); + break; + + case ID_GLABEL_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Global label")); + break; + + case ID_TEXT_COMMENT_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Text")); + break; + + case ID_WIRETOBUS_ENTRY_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Wire to Bus Entry")); + break; + + case ID_BUSTOBUS_ENTRY_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Bus to Bus entry")); + break; + + case ID_SHEET_SYMBOL_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Sheet")); + break; + + case ID_SHEET_LABEL_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add PinSheet")); + break; + + case ID_IMPORT_GLABEL_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Import PinSheet")); + break; + + case ID_COMPONENT_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Component")); + break; + + case ID_PLACE_POWER_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Power")); + break; + + case ID_POPUP_SCH_ENTRY_SELECT_SLASH: + DrawPanel->MouseToCursorSchema(); + SetBusEntryShape(&dc, + (DrawBusEntryStruct*)m_CurrentScreen->m_CurrentItem, '/'); + break; + + case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH: + DrawPanel->MouseToCursorSchema(); + SetBusEntryShape(&dc, + (DrawBusEntryStruct*)m_CurrentScreen->m_CurrentItem, '\\'); + break; + + case ID_NO_SELECT_BUTT: + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + break; + + case ID_POPUP_CANCEL_CURRENT_COMMAND: + if (m_ID_current_state == 0) + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + break; + + case ID_POPUP_END_LINE: + DrawPanel->MouseToCursorSchema(); + EndSegment(&dc); + break; + + case ID_POPUP_SCH_EDIT_TEXT: + EditSchematicText( + (DrawTextStruct*)m_CurrentScreen->m_CurrentItem, &dc); + break; + + case ID_POPUP_SCH_ROTATE_TEXT: + DrawPanel->MouseToCursorSchema(); + ChangeTextOrient( + (DrawTextStruct*)m_CurrentScreen->m_CurrentItem, &dc); + break; + + case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL: + DrawPanel->MouseToCursorSchema(); + ConvertTextType( (DrawTextStruct*)m_CurrentScreen->m_CurrentItem, + &dc, DRAW_LABEL_STRUCT_TYPE); + break; + + case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL: + DrawPanel->MouseToCursorSchema(); + ConvertTextType( (DrawTextStruct*)m_CurrentScreen->m_CurrentItem, + &dc, DRAW_GLOBAL_LABEL_STRUCT_TYPE); + break; + + case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT: + DrawPanel->MouseToCursorSchema(); + ConvertTextType( (DrawTextStruct*)m_CurrentScreen->m_CurrentItem, + &dc, DRAW_TEXT_STRUCT_TYPE); + break; + + case ID_POPUP_SCH_SET_SHAPE_TEXT: + // Non utilisé + break; + + case ID_POPUP_SCH_ROTATE_FIELD: + DrawPanel->MouseToCursorSchema(); + RotateCmpField( (PartTextStruct *)m_CurrentScreen->m_CurrentItem, &dc); + break; + + case ID_POPUP_SCH_EDIT_FIELD: + EditCmpFieldText( (PartTextStruct *)m_CurrentScreen->m_CurrentItem, &dc); + break; + + case ID_POPUP_SCH_DELETE_NODE: + case ID_POPUP_SCH_DELETE_CONNECTION: + DrawPanel->MouseToCursorSchema(); + DeleteConnection(&dc, id == ID_POPUP_SCH_DELETE_CONNECTION ? TRUE : FALSE); + m_CurrentScreen->m_CurrentItem = NULL; + g_ItemToRepeat = NULL; + TestDanglingEnds(m_CurrentScreen->EEDrawList, &dc); + break; + + case ID_POPUP_SCH_BREAK_WIRE: + { + DrawPickedStruct * ListForUndo; + DrawPanel->MouseToCursorSchema(); + ListForUndo = BreakSegment((SCH_SCREEN*)m_CurrentScreen, + m_CurrentScreen->m_Curseur, TRUE); + if ( ListForUndo ) SaveCopyInUndoList(ListForUndo, IS_NEW|IS_CHANGED); + TestDanglingEnds(m_CurrentScreen->EEDrawList, &dc); + } + break; + + case ID_POPUP_SCH_DELETE_CMP: + if ( m_CurrentScreen->m_CurrentItem == NULL) break; + // Ensure the struct is a component (could be a struct of a component, like Field, text..) + if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); + case ID_POPUP_SCH_DELETE: + if ( m_CurrentScreen->m_CurrentItem == NULL) break; + DeleteStruct(this->DrawPanel, &dc, m_CurrentScreen->m_CurrentItem); + m_CurrentScreen->m_CurrentItem = NULL; + g_ItemToRepeat = NULL; + TestDanglingEnds(m_CurrentScreen->EEDrawList, &dc); + m_CurrentScreen->SetModify(); + break; + + case ID_SCHEMATIC_DELETE_ITEM_BUTT: + SetToolID( id, wxCURSOR_BULLSEYE, _("Delete item")); + break; + + case ID_POPUP_SCH_END_SHEET: + DrawPanel->MouseToCursorSchema(); + m_CurrentScreen->m_CurrentItem->Place(this, &dc); + break; + + case ID_POPUP_SCH_RESIZE_SHEET: + DrawPanel->MouseToCursorSchema(); + ReSizeSheet((DrawSheetStruct *) + m_CurrentScreen->m_CurrentItem, &dc); + TestDanglingEnds(m_CurrentScreen->EEDrawList, &dc); + break; + + case ID_POPUP_SCH_EDIT_SHEET: + EditSheet((DrawSheetStruct *) + m_CurrentScreen->m_CurrentItem, &dc); + break; + case ID_POPUP_SCH_CLEANUP_SHEET: + ((DrawSheetStruct *) + m_CurrentScreen->m_CurrentItem)->CleanupSheet(this, &dc); + break; + + case ID_POPUP_SCH_EDIT_PINSHEET: + Edit_PinSheet((DrawSheetLabelStruct *) + m_CurrentScreen->m_CurrentItem, &dc); + break; + + case ID_POPUP_SCH_MOVE_PINSHEET: + DrawPanel->MouseToCursorSchema(); + StartMove_PinSheet((DrawSheetLabelStruct *) + m_CurrentScreen->m_CurrentItem, &dc); + break; + + case ID_POPUP_SCH_MOVE_CMP_REQUEST: + // Ensure the struct is a component (could be a struct of a component, like Field, text..) + if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); + if ( m_CurrentScreen->m_CurrentItem == NULL ) break; + case ID_POPUP_SCH_MOVE_ITEM_REQUEST: + DrawPanel->MouseToCursorSchema(); + Process_Move_Item(m_CurrentScreen->m_CurrentItem, &dc); + break; + + case ID_POPUP_SCH_EDIT_CMP: + // Ensure the struct is a component (could be a struct of a component, like Field, text..) + if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); + if ( m_CurrentScreen->m_CurrentItem == NULL ) break; + InstallCmpeditFrame(this, pos, + (EDA_SchComponentStruct *) m_CurrentScreen->m_CurrentItem); + break; + + case ID_POPUP_SCH_MIROR_X_CMP: + case ID_POPUP_SCH_MIROR_Y_CMP: + case ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE: + case ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE: + case ID_POPUP_SCH_ORIENT_NORMAL_CMP: + // Ensure the struct is a component (could be a struct of a component, like Field, text..) + if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); + if ( m_CurrentScreen->m_CurrentItem == NULL ) break; + { + int option; + switch (id) + { + case ID_POPUP_SCH_MIROR_X_CMP: + option = CMP_MIROIR_X; break; + + case ID_POPUP_SCH_MIROR_Y_CMP: + option = CMP_MIROIR_Y; break; + + case ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE: + option = CMP_ROTATE_COUNTERCLOCKWISE; break; + + case ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE: + option = CMP_ROTATE_CLOCKWISE; break; + + default: + case ID_POPUP_SCH_ORIENT_NORMAL_CMP: + option = CMP_NORMAL; break; + } + DrawPanel->MouseToCursorSchema(); + CmpRotationMiroir( + (EDA_SchComponentStruct *) m_CurrentScreen->m_CurrentItem, + &dc, option ); + break; + } + + case ID_POPUP_SCH_INIT_CMP: + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_SCH_EDIT_VALUE_CMP: + // Ensure the struct is a component (could be a struct of a component, like Field, text..) + if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); + if ( m_CurrentScreen->m_CurrentItem == NULL ) break; + EditComponentValue( + (EDA_SchComponentStruct *) m_CurrentScreen->m_CurrentItem, &dc); + break; + + case ID_POPUP_SCH_EDIT_REF_CMP: + // Ensure the struct is a component (could be a struct of a component, like Field, text..) + if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); + if ( m_CurrentScreen->m_CurrentItem == NULL ) break; + EditComponentReference( + (EDA_SchComponentStruct *) m_CurrentScreen->m_CurrentItem, &dc); + break; + + case ID_POPUP_SCH_EDIT_CONVERT_CMP: + // Ensure the struct is a component (could be a struct of a component, like Field, text..) + if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); + if ( m_CurrentScreen->m_CurrentItem == NULL ) break; + DrawPanel->MouseToCursorSchema(); + ConvertPart( + (EDA_SchComponentStruct *) m_CurrentScreen->m_CurrentItem, + &dc); + break; + + case ID_POPUP_SCH_COPY_COMPONENT_CMP: + DrawPanel->MouseToCursorSchema(); + { + EDA_SchComponentStruct * olditem, * newitem; + if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); + olditem = (EDA_SchComponentStruct *) m_CurrentScreen->m_CurrentItem; + if ( olditem == NULL ) break; + newitem = olditem->GenCopy(); + newitem->m_TimeStamp = GetTimeStamp(); + newitem->ClearAnnotation(); + newitem->m_Flags = IS_NEW; + StartMovePart(newitem, &dc); + /* Redraw the original part, because StartMovePart() has erase it from screen */ + RedrawOneStruct(DrawPanel, &dc, olditem, GR_DEFAULT_DRAWMODE); + } + break; + + case ID_POPUP_SCH_SELECT_UNIT1: + case ID_POPUP_SCH_SELECT_UNIT2: + case ID_POPUP_SCH_SELECT_UNIT3: + case ID_POPUP_SCH_SELECT_UNIT4: + case ID_POPUP_SCH_SELECT_UNIT5: + case ID_POPUP_SCH_SELECT_UNIT6: + case ID_POPUP_SCH_SELECT_UNIT7: + case ID_POPUP_SCH_SELECT_UNIT8: + case ID_POPUP_SCH_SELECT_UNIT9: + case ID_POPUP_SCH_SELECT_UNIT10: + case ID_POPUP_SCH_SELECT_UNIT11: + case ID_POPUP_SCH_SELECT_UNIT12: + case ID_POPUP_SCH_SELECT_UNIT13: + case ID_POPUP_SCH_SELECT_UNIT14: + case ID_POPUP_SCH_SELECT_UNIT15: + case ID_POPUP_SCH_SELECT_UNIT16: + case ID_POPUP_SCH_SELECT_UNIT17: + case ID_POPUP_SCH_SELECT_UNIT18: + case ID_POPUP_SCH_SELECT_UNIT19: + case ID_POPUP_SCH_SELECT_UNIT20: + case ID_POPUP_SCH_SELECT_UNIT21: + case ID_POPUP_SCH_SELECT_UNIT22: + case ID_POPUP_SCH_SELECT_UNIT23: + case ID_POPUP_SCH_SELECT_UNIT24: + case ID_POPUP_SCH_SELECT_UNIT25: + case ID_POPUP_SCH_SELECT_UNIT26: + // Ensure the struct is a component (could be a struct of a component, like Field, text..) + if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); + if ( m_CurrentScreen->m_CurrentItem == NULL ) break; + DrawPanel->MouseToCursorSchema(); + SelPartUnit( + (EDA_SchComponentStruct *) m_CurrentScreen->m_CurrentItem, + id + 1 - ID_POPUP_SCH_SELECT_UNIT1, + &dc); + break; + + case ID_POPUP_SCH_DISPLAYDOC_CMP: + // Ensure the struct is a component (could be a piece of a component, like Field, text..) + if ( m_CurrentScreen->m_CurrentItem->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE ) + m_CurrentScreen->m_CurrentItem = LocateSmallestComponent( GetScreen() ); + if ( m_CurrentScreen->m_CurrentItem == NULL ) break; + { + EDA_LibComponentStruct * LibEntry; + LibEntry = FindLibPart(((EDA_SchComponentStruct *) + m_CurrentScreen->m_CurrentItem)->m_ChipName, + wxEmptyString, FIND_ALIAS); + if ( LibEntry && LibEntry->m_DocFile != wxEmptyString ) + GetAssociatedDocument(this, g_RealLibDirBuffer, LibEntry->m_DocFile); + } + break; + + case ID_POPUP_SCH_ENTER_SHEET: + { + EDA_BaseStruct *DrawStruct = m_CurrentScreen->m_CurrentItem; + if ( DrawStruct && (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) ) + { + InstallNextScreen((DrawSheetStruct *) DrawStruct); + } + } + break; + + case ID_POPUP_SCH_LEAVE_SHEET: + InstallPreviousScreen(); + break; + + case ID_POPUP_CLOSE_CURRENT_TOOL: + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + break; + + case wxID_COPY: // really this is a Save block for paste + HandleBlockEndByPopUp(BLOCK_SAVE, &dc); + break; + + case ID_POPUP_PLACE_BLOCK: + DrawPanel->m_AutoPAN_Request = FALSE; + DrawPanel->MouseToCursorSchema(); + HandleBlockPlace(&dc); + break; + + case ID_POPUP_ZOOM_BLOCK: + HandleBlockEndByPopUp(BLOCK_ZOOM, &dc); + break; + + case ID_POPUP_DELETE_BLOCK: + DrawPanel->MouseToCursorSchema(); + HandleBlockEndByPopUp(BLOCK_DELETE, &dc); + break; + + case ID_POPUP_ROTATE_BLOCK: + DrawPanel->MouseToCursorSchema(); + HandleBlockEndByPopUp(BLOCK_ROTATE, &dc); + break; + + case ID_POPUP_MIRROR_X_BLOCK: + case ID_POPUP_MIRROR_Y_BLOCK: + DrawPanel->MouseToCursorSchema(); + HandleBlockEndByPopUp(BLOCK_MIRROR_Y, &dc); + break; + + case ID_POPUP_COPY_BLOCK: + DrawPanel->MouseToCursorSchema(); + HandleBlockEndByPopUp(BLOCK_COPY, &dc); + break; + + case ID_POPUP_DRAG_BLOCK: + DrawPanel->MouseToCursorSchema(); + HandleBlockEndByPopUp(BLOCK_DRAG, &dc); + break; + + case ID_POPUP_SCH_ADD_JUNCTION: + DrawPanel->MouseToCursorSchema(); + m_CurrentScreen->m_CurrentItem = + CreateNewJunctionStruct(&dc, m_CurrentScreen->m_Curseur, TRUE); + TestDanglingEnds(m_CurrentScreen->EEDrawList, &dc); + m_CurrentScreen->m_CurrentItem = NULL; + break; + + case ID_POPUP_SCH_ADD_LABEL: + case ID_POPUP_SCH_ADD_GLABEL: + m_CurrentScreen->m_CurrentItem = CreateNewText(&dc, + id == ID_POPUP_SCH_ADD_LABEL ? LAYER_LOCLABEL : LAYER_GLOBLABEL); + if ( m_CurrentScreen->m_CurrentItem ) + { + m_CurrentScreen->m_CurrentItem->Place( this, &dc); + TestDanglingEnds(m_CurrentScreen->EEDrawList, &dc); + m_CurrentScreen->m_CurrentItem = NULL; + } + break; + + case ID_SCHEMATIC_UNDO: + GetSchematicFromUndoList(); + DrawPanel->Refresh(TRUE); + break; + + case ID_SCHEMATIC_REDO: + GetSchematicFromRedoList(); + DrawPanel->Refresh(TRUE); + break; + + default: // Log error: + DisplayError(this, wxT("WinEDA_SchematicFrame::Process_Special_Functions error") ); + break; + } // End switch ( id ) (Command execution) + + if ( m_ID_current_state == 0 ) g_ItemToRepeat = NULL; + SetToolbars(); + + dc.SetBrush(wxNullBrush); + dc.SetPen(wxNullPen); +} + + +/********************************************************************************/ +void WinEDA_SchematicFrame::Process_Move_Item(EDA_BaseStruct *DrawStruct, + wxDC * DC) +/********************************************************************************/ +{ + + if ( DrawStruct == NULL ) return; + + DrawPanel->MouseToCursorSchema(); + switch ( DrawStruct->m_StructType ) + { + case DRAW_JUNCTION_STRUCT_TYPE: + break; + + case DRAW_BUSENTRY_STRUCT_TYPE: + StartMoveBusEntry((DrawBusEntryStruct *) DrawStruct, DC); + break; + + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + StartMoveTexte( (DrawTextStruct *) DrawStruct, DC); + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE: + StartMovePart( (EDA_SchComponentStruct *) DrawStruct, DC); + break; + + case DRAW_SEGMENT_STRUCT_TYPE: + break; + + case DRAW_SHEET_STRUCT_TYPE: + StartMoveSheet( (DrawSheetStruct*) DrawStruct, DC); + break; + + case DRAW_NOCONNECT_STRUCT_TYPE: + break; + + case DRAW_PART_TEXT_STRUCT_TYPE: + StartMoveCmpField( (PartTextStruct *) DrawStruct, DC); + break; + + case DRAW_MARKER_STRUCT_TYPE: + case DRAW_SHEETLABEL_STRUCT_TYPE: + default: + wxString msg; + msg.Printf( + wxT("WinEDA_SchematicFrame::Move_Item Error: Bad DrawType %d"), + DrawStruct->m_StructType); + DisplayError(this, msg ); + break; + } +} + + diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp new file mode 100644 index 0000000000..341f79a1ce --- /dev/null +++ b/eeschema/schematic_undo_redo.cpp @@ -0,0 +1,636 @@ + /********************************************/ + /* library editor: undo and redo functions */ + /********************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "id.h" + +#include "protos.h" + +/* Functions to undo and redo edit commands. +commmands to undo are in CurrentScreen->m_UndoList +commmands to redo are in CurrentScreen->m_RedoList + +m_UndoList and m_RedoList are a linked list of DrawPickedStruct. +each DrawPickedStruct has its .m_Son member pointing to an item to undo or redo, +or to a list of DrawPickedStruct which points (.m_PickedStruct membre) +the items to undo or redo + +there are 3 cases: + - delete item(s) command + - change item(s) command + - add item(s) command + +Undo command +- delete item(s) command: + deleted items are moved in undo list + +- change item(s) command + A copy of item(s) is made (a DrawPickedStruct list of wrappers) + the .m_Image member of each wrapper points the modified item. + +- add item(s) command + A list of item(s) is made + the .m_Image member of each wrapper points the new item. + +Redo command +- delete item(s) old command: + deleted items are moved in EEDrawList list + +- change item(s) command + the copy of item(s) is moved in Undo list + +- add item(s) command + The list of item(s) is used to create a deleted list in undo list + (same as a delete command) + +A problem is the hierarchical sheet handling. + the data associated (subhierarchy, uno/redo list) is deleted only + when the sheet is really deleted (i.e. when deleted from undo or redo list) + and not when it is a copy. +*/ + + +/************************************/ +void SwapData(EDA_BaseStruct * Item) +/************************************/ +/* Used if undo / redo command: + swap data between Item and its copy, pointed by its .m_Image member +*/ +{ + if ( Item == NULL ) return; + EDA_BaseStruct * image = Item->m_Image; + if (image == NULL ) return; + + switch ( Item->m_StructType ) + { + case DRAW_POLYLINE_STRUCT_TYPE: + #undef SOURCE + #undef DEST + #define SOURCE ((DrawPolylineStruct*)Item) + #define DEST ((DrawPolylineStruct*)image) + break; + + case DRAW_JUNCTION_STRUCT_TYPE: + #undef SOURCE + #undef DEST + #define SOURCE ((DrawJunctionStruct*)Item) + #define DEST ((DrawJunctionStruct*)image) + EXCHG(SOURCE->m_Pos, DEST->m_Pos); + break; + + case DRAW_LABEL_STRUCT_TYPE: + case DRAW_GLOBAL_LABEL_STRUCT_TYPE: + case DRAW_TEXT_STRUCT_TYPE: + #undef SOURCE + #undef DEST + #define SOURCE ((DrawTextStruct*)Item) + #define DEST ((DrawTextStruct*)image) + DEST->SwapData(SOURCE); + break; + + case DRAW_LIB_ITEM_STRUCT_TYPE: + #undef SOURCE + #undef DEST + #define SOURCE ((EDA_SchComponentStruct*)Item) + #define DEST ((EDA_SchComponentStruct*)image) + DEST->SwapData(SOURCE); + break; + + case DRAW_SEGMENT_STRUCT_TYPE: + #undef SOURCE + #undef DEST + #define SOURCE ((EDA_DrawLineStruct*)Item) + #define DEST ((EDA_DrawLineStruct*)image) + EXCHG(SOURCE->m_Start, DEST->m_Start); + EXCHG(SOURCE->m_End, DEST->m_End); + break; + + case DRAW_BUSENTRY_STRUCT_TYPE: + #undef SOURCE + #undef DEST + #define SOURCE ((DrawBusEntryStruct*)Item) + #define DEST ((DrawBusEntryStruct*)image) + EXCHG(SOURCE->m_Pos, DEST->m_Pos); + EXCHG(SOURCE->m_Size, DEST->m_Size); + break; + + case DRAW_SHEET_STRUCT_TYPE: + #undef SOURCE + #undef DEST + #define SOURCE ((DrawSheetStruct*)Item) + #define DEST ((DrawSheetStruct*)image) + DEST->SwapData(SOURCE); + break; + + case DRAW_MARKER_STRUCT_TYPE: + #undef SOURCE + #undef DEST + #define SOURCE ((DrawMarkerStruct*)Item) + #define DEST ((DrawMarkerStruct*)image) + EXCHG(SOURCE->m_Pos, DEST->m_Pos); + break; + + case DRAW_SHEETLABEL_STRUCT_TYPE: + #undef SOURCE + #undef DEST + #define SOURCE ((DrawSheetLabelStruct*)Item) + #define DEST ((DrawSheetLabelStruct*)image) + EXCHG(SOURCE->m_Edge, DEST->m_Edge); + EXCHG(SOURCE->m_Shape, DEST->m_Shape); + break; + + case DRAW_NOCONNECT_STRUCT_TYPE: + #undef SOURCE + #undef DEST + #define SOURCE ((DrawNoConnectStruct*)Item) + #define DEST ((DrawNoConnectStruct*)image) + EXCHG(SOURCE->m_Pos, DEST->m_Pos); + break; + + case DRAW_PART_TEXT_STRUCT_TYPE: + #undef SOURCE + #undef DEST + #define SOURCE ((DrawPolylineStruct*)Item) + #define DEST ((DrawPolylineStruct*)image) + break; + + // not directly used in schematic: + default: + DisplayInfo(NULL, wxT("SwapData() error: unexpected type")); + break; + } +} +/***********************************************************************/ +void WinEDA_SchematicFrame::SaveCopyInUndoList(EDA_BaseStruct * ItemToCopy, + int flag_type_command) +/***********************************************************************/ +/* Create a copy of the current schematic draw list, and put it in the undo list. + A DrawPickedStruct wrapper is created to handle the draw list. + the .m_Son of this wrapper points the list of items + + flag_type_command = + 0 (unspecified) + IS_CHANGED + IS_NEW + IS_DELETED + IS_WIRE_IMAGE + + for 0: only a wrapper is created. The used must init the .Flags member of the + wrapper, and add the item list to the wrapper + If it is a delete command, items are put on list with the .Flags member set to IS_DELETED. + When it will be really deleted, the EEDrawList and the subhierarchy will be deleted. + If it is only a copy, the EEDrawList and the subhierarchy must NOT be deleted. + + Note: + Edit wires and busses is a bit complex. + because when a new wire is added, modifications in wire list + (wire concatenation) there are modified items, deleted items and new items + so flag_type_command is IS_WIRE_IMAGE: the struct ItemToCopy is a list of wires + saved in Undo List (for Undo or Redo commands, saved wires will be exchanged with current wire list +*/ +{ +EDA_BaseStruct * CopyItem; + + DrawPickedStruct * NewList = new DrawPickedStruct(NULL); + NewList->m_Flags = flag_type_command; + + if ( ItemToCopy ) + { + switch ( flag_type_command ) + { + case 0: + break; + + case IS_CHANGED: /* Create a copy of schematic */ + NewList->m_Son = CopyItem = DuplicateStruct(ItemToCopy); + if ( ItemToCopy->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + DrawPickedStruct * PickedList = (DrawPickedStruct *) CopyItem; + while (PickedList) + { + CopyItem = PickedList->m_PickedStruct; + CopyItem->m_Flags = flag_type_command; + PickedList->m_Image = CopyItem->m_Image; + PickedList = (DrawPickedStruct *)PickedList->Pnext; + } + } + else + { + CopyItem->m_Flags = flag_type_command; + CopyItem->m_Image = ItemToCopy; + } + break; + + case IS_NEW: + if ( ItemToCopy->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + NewList->m_Son = ItemToCopy; + DrawPickedStruct * PickedList = (DrawPickedStruct *) ItemToCopy; + while (PickedList) + { + CopyItem = PickedList->m_PickedStruct; + PickedList->m_Image = CopyItem; + PickedList->m_PickedStruct = NULL; + PickedList->m_Flags = flag_type_command; + PickedList = (DrawPickedStruct *)PickedList->Pnext; + } + } + else + { + NewList->m_Image = ItemToCopy; + } + break; + + case IS_NEW|IS_CHANGED: + case IS_WIRE_IMAGE: + NewList->m_Son = ItemToCopy; + break; + + case IS_DELETED: + NewList->m_Son = ItemToCopy; + ItemToCopy->m_Flags = flag_type_command; + if ( ItemToCopy->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE ) + { + DrawPickedStruct * PickedList = (DrawPickedStruct *) ItemToCopy; + while (PickedList) + { + CopyItem = PickedList->m_PickedStruct; + CopyItem->m_Flags = flag_type_command; + PickedList->m_Flags = flag_type_command; + PickedList = (DrawPickedStruct *)PickedList->Pnext; + } + } + break; + + default: + DisplayError(this, wxT("SaveCopyInUndoList() error")); + break; + } + } + /* Save the copy in undo list */ + GetScreen()->AddItemToUndoList(NewList); + + /* Clear redo list, because after new save there is no redo to do */ + GetScreen()->ClearUndoORRedoList(GetScreen()->m_RedoList); + GetScreen()->m_RedoList = NULL; +} + +/**********************************************************/ +void WinEDA_SchematicFrame::GetSchematicFromRedoList(void) +/**********************************************************/ +/* Redo the last edition: + - Save the current schematic in undo list + - Get the old version +*/ +{ + if ( GetScreen()->m_RedoList == NULL ) return; + + /* Get the old wrapper and put it in UndoList */ + DrawPickedStruct * List = (DrawPickedStruct *)GetScreen()->GetItemFromRedoList(); + GetScreen()->AddItemToUndoList(List); + /* Redo the command: */ + PutDataInPreviousState(List); + + CurrentDrawItem = NULL; + GetScreen()->SetModify(); + ReCreateHToolbar(); + SetToolbars(); +} + + +/***************************************************************************/ +void WinEDA_SchematicFrame::PutDataInPreviousState(DrawPickedStruct * List) +/***************************************************************************/ +/* Used in undo or redo command. + Put data pointed by List in the previous state, i.e. the state memorised by List +*/ +{ +EDA_BaseStruct * FirstItem = List->m_Son; +EDA_BaseStruct * item; +DrawPickedStruct * PickedList; + + switch ( List->m_Flags ) + { + case IS_CHANGED: /* Exchange old and new data for each item */ + if ( FirstItem == NULL ) + { + DisplayError(this, wxT("PutDataInPreviousState() error : Null item")); + break; + } + if ( FirstItem->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + DrawPickedStruct * PickedList = (DrawPickedStruct *) FirstItem; + while ( PickedList ) + { + SwapData(PickedList->m_PickedStruct); + PickedList = PickedList->Next(); + } + } + else + { + SwapData(FirstItem); + } + break; + + case IS_NEW: /* new items are deleted */ + List->m_Flags = IS_DELETED; + if ( FirstItem && FirstItem->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + PickedList = (DrawPickedStruct *) FirstItem; + while ( PickedList ) + { + item = PickedList->m_Image; + GetScreen()->RemoveFromDrawList(item); + item->m_Flags = IS_DELETED; + PickedList->m_PickedStruct = item; + PickedList->m_Flags = IS_DELETED; + PickedList = PickedList->Next(); + } + } + else + { + FirstItem = List->m_Image; + GetScreen()->RemoveFromDrawList(FirstItem); + FirstItem->m_Flags = IS_DELETED; + List->m_Son = FirstItem; + } + break; + + case IS_DELETED: /* deleted items are put in EEdrawList, as new items */ + List->m_Flags = IS_NEW; + if ( FirstItem->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE) + { + PickedList = (DrawPickedStruct *) FirstItem; + while ( PickedList ) + { + item = PickedList->m_PickedStruct; + item->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = item; + item->m_Flags = 0; + PickedList->m_PickedStruct = NULL; + PickedList->m_Image = item; + PickedList->m_Flags = IS_NEW; + PickedList = PickedList->Next(); + } + } + else + { + FirstItem->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = FirstItem; + FirstItem->m_Flags = 0; + List->m_Image = List->m_Son; + List->m_Son = NULL; + } + break; + + case IS_WIRE_IMAGE: + /* Exchange the current wires and the oild wires */ + List->m_Son = GetScreen()->ExtractWires(FALSE); + while ( FirstItem ) + { + EDA_BaseStruct * nextitem = FirstItem->Pnext; + FirstItem->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = FirstItem; + FirstItem->m_Flags = 0; + FirstItem = nextitem; + } + break; + + case IS_NEW|IS_CHANGED: + case IS_DELETED|IS_CHANGED: + if ( !FirstItem || FirstItem->m_StructType != DRAW_PICK_ITEM_STRUCT_TYPE) + { + DisplayError(this, wxT("GetSchematicFromUndoList() error: Pickstruct expected")); + break; + } + PickedList = (DrawPickedStruct *) FirstItem; + while ( PickedList ) + { + switch (PickedList->m_Flags) + { + case IS_CHANGED: + SwapData(PickedList->m_PickedStruct); + break; + + case IS_NEW: + item = PickedList->m_Image; + GetScreen()->RemoveFromDrawList(item); + item->m_Flags = IS_DELETED; + PickedList->m_PickedStruct = item; + PickedList->m_Flags = IS_DELETED; + break; + + case IS_DELETED: + item = PickedList->m_PickedStruct; + item->Pnext = GetScreen()->EEDrawList; + GetScreen()->EEDrawList = item; + item->m_Flags = 0; + PickedList->m_PickedStruct = NULL; + PickedList->m_Image = item; + PickedList->m_Flags = IS_NEW; + break; + } + PickedList = PickedList->Next(); + } + break; + + default: + DisplayError(this, wxT("GetSchematicFromUndoList() error: Unknown cmd")); + break; + } +} + +/**********************************************************/ +void WinEDA_SchematicFrame::GetSchematicFromUndoList(void) +/**********************************************************/ +/* Undo the last edition: + - Save the current schematic in Redo list + - Get an old version of the schematic +*/ +{ + if ( GetScreen()->m_UndoList == NULL ) return; + + /* Get the old wrapper and put it in RedoList (the real data list is the m_Son member) */ + DrawPickedStruct * List = (DrawPickedStruct *)GetScreen()->GetItemFromUndoList(); + GetScreen()->AddItemToRedoList(List); + /* Undo the command */ + PutDataInPreviousState(List); + + CurrentDrawItem = NULL; + GetScreen()->SetModify(); + ReCreateHToolbar(); + SetToolbars(); +} + + +/*********************************************************/ +void SCH_SCREEN::ClearUndoORRedoList(EDA_BaseStruct *List) +/*********************************************************/ +/* free the undo or redo list from List element + Wrappers are deleted. + datas pointed by wrappers are deleted if not flagged IS_NEW + because they are copy of used data or they are not in use (DELETED) +*/ +{ +EDA_BaseStruct *nextitem; +EDA_BaseStruct * FirstItem; +int CmdType; + + if ( List == NULL ) return; + + for ( ; List != NULL; List = nextitem ) + { + nextitem = List->Pnext; + FirstItem = List->m_Son; + CmdType = List->m_Flags; + + delete List; + + if (FirstItem == NULL ) continue; + + if ( FirstItem->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE ) + { + EDA_BaseStruct * item; + DrawPickedStruct * PickedList = (DrawPickedStruct *) FirstItem; + while ( PickedList ) // delete wrapper list and copies + { + item = PickedList->m_PickedStruct; + if ( item ) + { + if ( item->m_StructType == DRAW_SHEET_STRUCT_TYPE ) + { + DrawSheetStruct * sheet = (DrawSheetStruct*)item; + /* Delete sub hierarchy if the sheet must be deleted */ + if ( (sheet->m_Flags & IS_DELETED) != 0 ) + DeleteSubHierarchy(sheet, FALSE); + else /* EEDrawList, UndoList and Redo list are shared, and are deleted + only if sheet is deleted */ + { + if ( (item->m_Flags & IS_NEW) == 0 ) + { + sheet->EEDrawList = NULL; + sheet->m_UndoList = NULL; + sheet->m_RedoList = NULL; + } + } + } + if ( (item->m_Flags & IS_NEW) == 0 ) delete item; + } + DrawPickedStruct * wrapper = PickedList; + PickedList = PickedList->Next(); + delete wrapper; + } + } + else // This is a single item: deleted copy + { + if ( CmdType == IS_WIRE_IMAGE ) + { + while ( FirstItem ) + { + EDA_BaseStruct * nextitem = FirstItem->Pnext; + delete FirstItem; + FirstItem = nextitem; + } + } + else + { + if ( FirstItem->m_StructType == DRAW_SHEET_STRUCT_TYPE ) + { + DrawSheetStruct * sheet = (DrawSheetStruct*)FirstItem; + /* Delete hierarchy if the sheet must be deleted */ + if ( (sheet->m_Flags & IS_DELETED) == IS_DELETED ) + DeleteSubHierarchy(sheet, FALSE); + else + { + if ( (FirstItem->m_Flags & IS_NEW) == 0 ) + { + sheet->EEDrawList = NULL; + sheet->m_UndoList = NULL; + sheet->m_RedoList = NULL; + } + } + } + if ( (FirstItem->m_Flags & IS_NEW) == 0 ) delete FirstItem; + } + } + } +} + +/*****************************************/ +void SCH_SCREEN::ClearUndoRedoList(void) +/*****************************************/ +/* free the undo and the redo lists +*/ +{ + ClearUndoORRedoList(m_UndoList); m_UndoList = NULL; + ClearUndoORRedoList(m_RedoList); m_RedoList = NULL; +} + +/***********************************************************/ +void SCH_SCREEN::AddItemToUndoList(EDA_BaseStruct * newitem) +/************************************************************/ +/* Put newitem in head of undo list + Deletes olds items if > count max. +*/ +{ +int ii; +EDA_BaseStruct * item, *nextitem; + + if ( newitem == NULL ) return; + + if ( m_UndoList ) m_UndoList->Pback = newitem; + newitem->Pnext = m_UndoList; + newitem->Pback = NULL; + m_UndoList = newitem; + + /* Free oldest items, if count max reached */ + for ( ii = 0, item = m_UndoList; ii < m_UndoRedoCountMax; ii++ ) + { + if ( item->Pnext == NULL ) return; + item = item->Pnext; + } + + if ( item == NULL ) return; + + nextitem = item->Pnext; + item->Pnext = NULL; // Set end of chain + + // Delete the extra items + ClearUndoORRedoList(nextitem); +} + +/***********************************************************/ +void SCH_SCREEN::AddItemToRedoList(EDA_BaseStruct * newitem) +/***********************************************************/ +{ +int ii; +EDA_BaseStruct * item, *nextitem; + + if ( newitem == NULL ) return; + + newitem->Pback = NULL; + newitem->Pnext = m_RedoList; + m_RedoList = newitem; + /* Free first items, if count max reached */ + for ( ii = 0, item = m_RedoList; ii < m_UndoRedoCountMax; ii++ ) + { + if ( item->Pnext == NULL ) break; + item = item->Pnext; + } + + if ( item == NULL ) return; + + nextitem = item->Pnext; + item->Pnext = NULL; // Set end of chain + + // Delete the extra items + ClearUndoORRedoList(nextitem); +} + diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp new file mode 100644 index 0000000000..e44456786e --- /dev/null +++ b/eeschema/schframe.cpp @@ -0,0 +1,294 @@ + /******************************************************************/ + /* schframe.cpp - fonctions des classes du type WinEDA_DrawFrame */ + /******************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" +#include "common.h" + +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "bitmaps.h" +#include "protos.h" +#include "id.h" + + + + /*******************************/ + /* class WinEDA_SchematicFrame */ + /*******************************/ + +BEGIN_EVENT_TABLE(WinEDA_SchematicFrame, wxFrame) + COMMON_EVENTS_DRAWFRAME + + EVT_CLOSE(WinEDA_SchematicFrame::OnCloseWindow) + EVT_SIZE(WinEDA_SchematicFrame::OnSize) + + EVT_MENU_RANGE(ID_LOAD_PROJECT,ID_LOAD_FILE_10, + WinEDA_SchematicFrame::Process_Special_Functions) + + EVT_TOOL(ID_NEW_PROJECT, WinEDA_SchematicFrame::Process_Special_Functions) + EVT_TOOL(ID_LOAD_PROJECT, WinEDA_SchematicFrame::Process_Special_Functions) + EVT_TOOL_RANGE(ID_SCHEMATIC_MAIN_TOOLBAR_START, ID_SCHEMATIC_MAIN_TOOLBAR_END, + WinEDA_SchematicFrame::Process_Special_Functions) + + + EVT_MENU_RANGE(ID_PREFERENCES_FONT_INFOSCREEN, ID_PREFERENCES_FONT_END, + WinEDA_DrawFrame::ProcessFontPreferences) + + EVT_MENU(ID_SAVE_PROJECT, WinEDA_SchematicFrame::Save_File) + EVT_MENU(ID_SAVE_ONE_SHEET, WinEDA_SchematicFrame::Save_File) + EVT_MENU(ID_SAVE_ONE_SHEET_AS, WinEDA_SchematicFrame::Save_File) + EVT_TOOL(ID_SAVE_PROJECT, WinEDA_SchematicFrame::Save_File) + EVT_MENU(ID_GEN_PRINT, WinEDA_SchematicFrame::ToPrinter) + EVT_MENU(ID_GEN_PLOT_PS, WinEDA_SchematicFrame::ToPlot_PS) + EVT_MENU(ID_GEN_PLOT_HPGL, WinEDA_SchematicFrame::ToPlot_HPGL) + EVT_MENU(ID_GEN_PLOT_SVG, WinEDA_DrawFrame::SVG_Print) + EVT_MENU(ID_GEN_COPY_SHEET_TO_CLIPBOARD, WinEDA_DrawFrame::CopyToClipboard) + EVT_MENU(ID_GEN_COPY_BLOCK_TO_CLIPBOARD, WinEDA_DrawFrame::CopyToClipboard) + EVT_MENU(ID_EXIT, WinEDA_SchematicFrame::Process_Special_Functions) + + EVT_MENU(ID_CONFIG_REQ, WinEDA_SchematicFrame::Process_Config) + EVT_MENU(ID_CONFIG_READ, WinEDA_SchematicFrame::Process_Config) + EVT_MENU(ID_CONFIG_SAVE, WinEDA_SchematicFrame::Process_Config) + EVT_MENU(ID_COLORS_SETUP, WinEDA_SchematicFrame::Process_Config) + EVT_MENU(ID_OPTIONS_SETUP, WinEDA_SchematicFrame::Process_Config) + + EVT_MENU_RANGE(ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, + WinEDA_DrawFrame::SetLanguage) + + EVT_TOOL_RANGE(ID_ZOOM_PLUS_BUTT, ID_ZOOM_PAGE_BUTT, + WinEDA_SchematicFrame::Process_Zoom) + + EVT_TOOL(ID_NEW_PROJECT, WinEDA_SchematicFrame::Process_Special_Functions) + EVT_TOOL(ID_LOAD_PROJECT, WinEDA_SchematicFrame::Process_Special_Functions) + + EVT_TOOL(ID_TO_LIBRARY, WinEDA_SchematicFrame::Process_Special_Functions) + EVT_TOOL(ID_TO_LIBVIEW, WinEDA_SchematicFrame::Process_Special_Functions) + + EVT_TOOL(ID_TO_PCB, WinEDA_SchematicFrame::Process_Special_Functions) + EVT_TOOL(ID_TO_CVPCB, WinEDA_SchematicFrame::Process_Special_Functions) + + EVT_TOOL(ID_SHEET_SET, WinEDA_DrawFrame::Process_PageSettings) + EVT_TOOL(ID_HIERARCHY, WinEDA_SchematicFrame::Process_Special_Functions) + EVT_TOOL(wxID_CUT, WinEDA_SchematicFrame::Process_Special_Functions) + EVT_TOOL(wxID_COPY, WinEDA_SchematicFrame::Process_Special_Functions) + EVT_TOOL(wxID_PASTE, WinEDA_SchematicFrame::Process_Special_Functions) + EVT_TOOL(ID_UNDO_BUTT, WinEDA_SchematicFrame::Process_Special_Functions) + EVT_TOOL(ID_GEN_PRINT, WinEDA_SchematicFrame::ToPrinter) + EVT_TOOL_RANGE(ID_GET_ANNOTATE,ID_FIND_ITEMS, + WinEDA_SchematicFrame::Process_Special_Functions) + + EVT_MENU(ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp) + EVT_MENU(ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout) + + // Tools et boutons de Schematique, Vertical toolbar: + EVT_TOOL_RANGE(ID_SCHEMATIC_VERTICAL_TOOLBAR_START, + ID_SCHEMATIC_VERTICAL_TOOLBAR_END, + WinEDA_SchematicFrame::Process_Special_Functions) + + EVT_TOOL_RCLICKED(ID_LABEL_BUTT, WinEDA_SchematicFrame::ToolOnRightClick) + EVT_TOOL_RCLICKED(ID_GLABEL_BUTT, WinEDA_SchematicFrame::ToolOnRightClick) + + EVT_MENU_RANGE(ID_POPUP_START_RANGE, ID_POPUP_END_RANGE, + WinEDA_SchematicFrame::Process_Special_Functions ) + + // Tools et boutons de Schematique, Options toolbar: + EVT_TOOL_RANGE(ID_TB_OPTIONS_START,ID_TB_OPTIONS_END, + WinEDA_SchematicFrame::OnSelectOptionToolbar) + + EVT_MENU_RANGE(ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, + WinEDA_SchematicFrame::Process_Special_Functions ) + +END_EVENT_TABLE() + + + + + /****************/ + /* Constructeur */ + /****************/ + +WinEDA_SchematicFrame:: WinEDA_SchematicFrame(wxWindow * father, WinEDA_App *parent, + const wxString & title, const wxPoint& pos, const wxSize& size) : + WinEDA_DrawFrame(father, SCHEMATIC_FRAME, parent, title, pos, size) +{ + m_FrameName = wxT("SchematicFrame"); + m_Draw_Axis = FALSE; // TRUE pour avoir les axes dessines + m_Draw_Grid = g_ShowGrid; // TRUE pour avoir la grille dessinee + m_Draw_Sheet_Ref = TRUE; // TRUE pour avoir le cartouche dessiné + + // Give an icon + #ifdef __WINDOWS__ + SetIcon(wxICON(a_icon_eeschema)); + #else + SetIcon(wxICON(icon_eeschema)); + #endif + + m_CurrentScreen = ScreenSch; + g_ItemToRepeat = NULL; + GetSettings(); + SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y); + if ( DrawPanel ) DrawPanel->m_Block_Enable = TRUE; + ReCreateMenuBar(); + ReCreateHToolbar(); + ReCreateVToolbar(); + ReCreateOptToolbar(); +} + + + /***************/ + /* Destructeur */ + /***************/ + +WinEDA_SchematicFrame::~WinEDA_SchematicFrame(void) +{ + m_Parent->SchematicFrame = NULL; + m_CurrentScreen = ScreenSch; +} + +/**************************************************************/ +void WinEDA_SchematicFrame::OnCloseWindow(wxCloseEvent & Event) +/**************************************************************/ +{ +SCH_SCREEN * screen; + + if ( m_Parent->LibeditFrame ) // Can close component editor ? + { + if ( ! m_Parent->LibeditFrame->Close() ) return; + } + + screen = ScreenSch ; + while( screen ) + { + if(screen->IsModify()) break; + screen = (SCH_SCREEN*)screen->Pnext; + } + + if ( screen ) + { + unsigned ii; + wxMessageDialog dialog(this, _("Schematic modified, Save before exit ?"), + _("Confirmation"), wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT); + ii = dialog.ShowModal(); + switch ( ii ) + { + case wxID_CANCEL: + Event.Veto(); + return; + + case wxID_NO: + break; + + case wxID_OK: + case wxID_YES: + SaveProject(this); + break; + } + } + + screen = ScreenSch ; + while( screen ) // suppression flag modify pour eviter d'autres message + { + screen->ClrModify(); + screen = (SCH_SCREEN*)screen->Pnext; + } + + if ( ! ScreenSch->m_FileName.IsEmpty() && (ScreenSch->EEDrawList != NULL) ) + SetLastProject(ScreenSch->m_FileName); + + ClearProjectDrawList(ScreenSch, TRUE); + + /* Tous les autres SCREEN sont effaces, aussi reselection de + l'ecran de base, pour les evenements de refresh générés par wxWindows */ + m_CurrentScreen = ActiveScreen = ScreenSch; + + SaveSettings(); + + Destroy(); +} + + +/********************************************/ +void WinEDA_SchematicFrame::SetToolbars(void) +/********************************************/ +/* Active ou desactive les tools du toolbar horizontal, en fonction des commandes +en cours +*/ +{ + if( m_HToolBar ) + { + if ( m_CurrentScreen->BlockLocate.m_Command == BLOCK_MOVE ) + { + m_HToolBar->EnableTool(wxID_CUT,TRUE); + m_HToolBar->EnableTool(wxID_COPY,TRUE); + } + else + { + m_HToolBar->EnableTool(wxID_CUT,FALSE); + m_HToolBar->EnableTool(wxID_COPY,FALSE); + } + + if ( g_BlockSaveDataList ) m_HToolBar->EnableTool(wxID_PASTE,TRUE); + else m_HToolBar->EnableTool(wxID_PASTE,FALSE); + + if ( GetScreen()->m_RedoList ) + m_HToolBar->EnableTool(ID_SCHEMATIC_REDO,TRUE); + else m_HToolBar->EnableTool(ID_SCHEMATIC_REDO,FALSE); + if ( GetScreen()->m_UndoList ) + m_HToolBar->EnableTool(ID_SCHEMATIC_UNDO,TRUE); + else m_HToolBar->EnableTool(ID_SCHEMATIC_UNDO,FALSE); + } + + if ( m_OptionsToolBar ) + { + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_GRID,m_Draw_Grid); + m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_GRID, + m_Draw_Grid ? _("Grid not show") : _("Show Grid")); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_MM, + g_UnitMetric == MILLIMETRE ? TRUE : FALSE); + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_INCH, + g_UnitMetric == INCHES ? TRUE : FALSE); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_CURSOR,g_CursorShape); + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_HIDDEN_PINS,g_ShowAllPins); + m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_HIDDEN_PINS, + g_ShowAllPins ? _("No show Hidden Pins") : _("Show Hidden Pins") ); + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_BUS_WIRES_ORIENT, g_HVLines); + m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_BUS_WIRES_ORIENT, + g_HVLines ? _("Draw lines at any direction") : + _("Draw lines H, V or 45 deg only") ); + } + + DisplayUnitsMsg(); +} + +/******************************************/ +int WinEDA_SchematicFrame::BestZoom(void) +/******************************************/ +{ +int dx, dy, ii,jj ; +int bestzoom; +wxSize size; + + dx = m_CurrentScreen->m_CurrentSheet->m_Size.x; + dy = m_CurrentScreen->m_CurrentSheet->m_Size.y; + + size = DrawPanel->GetClientSize(); + ii = dx / size.x; + jj = dy / size.y; + bestzoom = MAX(ii, jj) + 1; + + m_CurrentScreen->SetZoom(ii); + m_CurrentScreen->m_Curseur.x = dx / 2; + m_CurrentScreen->m_Curseur.y = dy / 2; + + return(bestzoom); +} + diff --git a/eeschema/selpart.cpp b/eeschema/selpart.cpp new file mode 100644 index 0000000000..24aeb68550 --- /dev/null +++ b/eeschema/selpart.cpp @@ -0,0 +1,142 @@ + /**************************/ + /* EESchema - selpart.cpp */ + /**************************/ + +/* Routine de selection d'un composant en librairie +*/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + + +/* Routines locales */ + +/* Variables locales */ + + +/***************************************************************/ +LibraryStruct * SelectLibraryFromList(WinEDA_DrawFrame * frame) +/***************************************************************/ +/* Routine pour selectionner une librairie a partir d'une liste +*/ +{ +int ii, NumOfLibs = NumOfLibraries(); +LibraryStruct *Lib = NULL; +static wxString OldLibName; +WinEDAListBox * ListBox; +wxString LibName; +const wxChar ** ListNames; + + if (NumOfLibs == 0) + { + DisplayError(frame, _("No libraries are loaded")); + return(NULL) ; + } + + ListNames = GetLibNames(); + ListBox = new WinEDAListBox(frame, + _("Select Lib"), ListNames, OldLibName, NULL, + wxColour(150,255,255)); + ListBox->MoveMouseToOrigin(); + + ii = ListBox->ShowModal(); ListBox->Destroy(); + + if (ii >= 0) /* Recherche de la librairie */ + { + Lib = FindLibrary(ListNames[ii]); + } + + free (ListNames); + return(Lib); +} + + +/******************************************************************************************/ +int DisplayComponentsNamesInLib( WinEDA_DrawFrame * frame, + LibraryStruct *Library, wxString & Buffer, wxString & OldName) +/******************************************************************************************/ +/* Routine de selection d'un composant en librairie, par affichage de la + liste des composants de cette librairie + Si Library == NULL, selection de librairie demandee + sinon recherche uniquement dans library + Retourne + 1 si composant selectionne + 0 si commande annulee +*/ +{ +int ii; +wxString msg; +EDA_LibComponentStruct *LibEntry; +WinEDAListBox * ListBox; +const wxChar ** ListNames; + + if(Library == NULL) Library = SelectLibraryFromList(frame); + if(Library == NULL) return(0); + + PQCompFunc((PQCompFuncType) LibraryEntryCompare); + LibEntry = (EDA_LibComponentStruct *) PQFirst(&Library->m_Entries, FALSE); + + ii = 0; + while( LibEntry ) + { + ii++; + LibEntry = (EDA_LibComponentStruct *) PQNext(Library->m_Entries, LibEntry, NULL); + } + ListNames = (const wxChar**) MyZMalloc( (ii+1) * sizeof(wxChar*)); + + msg.Printf( _("Select component (%d items)"), ii ); + + ii = 0; + LibEntry = (EDA_LibComponentStruct *) PQFirst(&Library->m_Entries, FALSE); + while( LibEntry ) + { + ListNames[ii++] = LibEntry->m_Name.m_Text.GetData(); + LibEntry = (EDA_LibComponentStruct *) PQNext(Library->m_Entries, LibEntry, NULL); + } + +// Qsort(ListNames,StrNumICmp); + + ListBox = new WinEDAListBox(frame, msg, + ListNames, OldName, DisplayCmpDoc, + wxColour(255,255,200)); + ListBox->MoveMouseToOrigin(); + + ii = ListBox->ShowModal(); ListBox->Destroy(); + if ( ii >= 0 ) Buffer = ListNames[ii]; + + free (ListNames); + + if ( ii < 0 ) return 0; + return 1; +} + +/************************************************************/ +int GetNameOfPartToLoad(WinEDA_DrawFrame * frame, + LibraryStruct *Library, wxString & BufName) +/************************************************************/ +/* + Routine de selection du nom d'un composant en librairie pour chargement, + dans la librairie Library. + Si Library == NULL, il y aura demande de selection d'une librairie + Retourne + 1 si composant selectionne + 0 si commande annulee + place le nom du composant a charger, selectionne a partir d'une liste dans + BufName +*/ +{ +int ii; +static wxString OldCmpName; + + ii = DisplayComponentsNamesInLib(frame, Library, BufName, OldCmpName); + if( ii <= 0 ) return 0; + OldCmpName = BufName; + return( 1 ); +} diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp new file mode 100644 index 0000000000..5447a3f450 --- /dev/null +++ b/eeschema/sheet.cpp @@ -0,0 +1,563 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: sheet.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 08/02/2006 18:37:02 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 08/02/2006 18:37:02 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "sheet.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +/* Routines Locales */ +static void ExitSheet(WinEDA_DrawPanel * Panel, wxDC * DC); +static void DeplaceSheet(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); + +/* Variables locales */ +static int s_SheetMindx, s_SheetMindy; +static wxPoint s_OldPos; /* Ancienne pos pour annulation ReSize ou move */ + + +#include "sheet.h" + +////@begin XPM images +////@end XPM images + +/*! + * WinEDA_SheetPropertiesFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_SheetPropertiesFrame, wxDialog ) + +/*! + * WinEDA_SheetPropertiesFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_SheetPropertiesFrame, wxDialog ) + +////@begin WinEDA_SheetPropertiesFrame event table entries + EVT_BUTTON( wxID_CANCEL, WinEDA_SheetPropertiesFrame::OnCancelClick ) + + EVT_BUTTON( wxID_OK, WinEDA_SheetPropertiesFrame::OnOkClick ) + +////@end WinEDA_SheetPropertiesFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_SheetPropertiesFrame constructors + */ + +WinEDA_SheetPropertiesFrame::WinEDA_SheetPropertiesFrame( ) +{ +} + +WinEDA_SheetPropertiesFrame::WinEDA_SheetPropertiesFrame( WinEDA_SchematicFrame* parent, + DrawSheetStruct * currentsheet, + wxWindowID id, const wxString& caption, + const wxPoint & pos, const wxSize& size, long style ) +{ + m_Parent = parent; + m_CurrentSheet = currentsheet; + Create(parent, id, caption, pos, size, style); + + AddUnitSymbol(*m_SheetNameTextSize); + PutValueInLocalUnits(*m_SheetNameSize,m_CurrentSheet->m_SheetNameSize, + m_Parent->m_InternalUnits); + + AddUnitSymbol(*m_FileNameTextSize); + PutValueInLocalUnits(*m_FileNameSize, m_CurrentSheet->m_FileNameSize, + m_Parent->m_InternalUnits); +} + +/*! + * WinEDA_SheetPropertiesFrame creator + */ + +bool WinEDA_SheetPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint & pos, const wxSize& size, long style ) +{ +////@begin WinEDA_SheetPropertiesFrame member initialisation + m_FileNameWin = NULL; + m_SheetNameWin = NULL; + m_FileNameTextSize = NULL; + m_FileNameSize = NULL; + m_SheetNameTextSize = NULL; + m_SheetNameSize = NULL; +////@end WinEDA_SheetPropertiesFrame member initialisation + +////@begin WinEDA_SheetPropertiesFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_SheetPropertiesFrame creation + return true; +} + +/*! + * Control creation for WinEDA_SheetPropertiesFrame + */ + +void WinEDA_SheetPropertiesFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_SheetPropertiesFrame content construction + // Generated by DialogBlocks, 27/02/2006 14:12:10 (unregistered) + + WinEDA_SheetPropertiesFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("Filename:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer4->Add(itemStaticText5, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_FileNameWin = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxSize(300, -1), wxTE_PROCESS_ENTER ); + itemBoxSizer4->Add(m_FileNameWin, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _("Sheetname:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer4->Add(itemStaticText7, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_SheetNameWin = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(300, -1), 0 ); + itemBoxSizer4->Add(m_SheetNameWin, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + m_FileNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _("Size"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer9->Add(m_FileNameTextSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_FileNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer9->Add(m_FileNameSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_SheetNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _("Size"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer9->Add(m_SheetNameTextSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_SheetNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer9->Add(m_SheetNameSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer2->Add(itemBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxButton* itemButton16 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton16->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer15->Add(itemButton16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton17 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton17->SetForegroundColour(wxColour(196, 0, 0)); + itemBoxSizer15->Add(itemButton17, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + // Set validators + m_FileNameWin->SetValidator( wxTextValidator(wxFILTER_NONE, & m_CurrentSheet->m_FileName) ); + m_SheetNameWin->SetValidator( wxTextValidator(wxFILTER_NONE, & m_CurrentSheet->m_SheetName) ); +////@end WinEDA_SheetPropertiesFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_SheetPropertiesFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_SheetPropertiesFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_SheetPropertiesFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_SheetPropertiesFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_SheetPropertiesFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_SheetPropertiesFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_SheetPropertiesFrame icon retrieval +} + + + +/*****************************************************************************/ +void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept(wxCommandEvent& event) +/*****************************************************************************/ +{ +wxString FileName, msg; + + FileName = m_FileNameWin->GetValue(); + FileName.Trim(FALSE); FileName.Trim(TRUE); + + if ( FileName.IsEmpty() ) + { + DisplayError(this, _("No Filename! Aborted") ); + EndModal (FALSE); + return; + } + + ChangeFileNameExt( FileName,g_SchExtBuffer ); + + m_CurrentSheet->m_FileName = FileName; + msg = m_FileNameSize->GetValue(); + m_CurrentSheet->m_FileNameSize = + ReturnValueFromString(g_UnitMetric, + msg, m_Parent->m_InternalUnits); + + m_CurrentSheet->m_SheetName = m_SheetNameWin->GetValue(); + msg = m_SheetNameSize->GetValue(); + m_CurrentSheet->m_SheetNameSize = + ReturnValueFromString(g_UnitMetric, + msg, m_Parent->m_InternalUnits); + + if( (m_CurrentSheet->m_SheetName.IsEmpty() ) ) + m_CurrentSheet->m_SheetName = m_CurrentSheet->m_FileName; + + + EndModal(TRUE); +} + +/*************************************************************************/ +bool WinEDA_SchematicFrame::EditSheet(DrawSheetStruct * Sheet, wxDC * DC) +/*************************************************************************/ +/* Routine de modification des textes (Name et FileName) de la Sheet */ +{ +BASE_SCREEN * ScreenSheet = NULL; +WinEDA_SheetPropertiesFrame * frame; +bool edit = TRUE; + + if ( Sheet == NULL ) return FALSE; + + ScreenSheet = Sheet; + + /* Demande du nouveau texte */ + RedrawOneStruct(DrawPanel, DC, Sheet, g_XorMode); + + DrawPanel->m_IgnoreMouseEvents = TRUE; + frame = new WinEDA_SheetPropertiesFrame(this, Sheet); + edit = frame->ShowModal(); frame->Destroy(); + DrawPanel->MouseToCursorSchema(); + DrawPanel->m_IgnoreMouseEvents = FALSE; + + if ( edit ) + { + /* Correction du nom fichier dans la structure SCREEN correspondante */ + if( ScreenSheet ) + { + ScreenSheet->m_FileName = Sheet->m_FileName; + } + GetScreen()->SetModify(); + } + + RedrawOneStruct(DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE); + return edit; +} + + +#define SHEET_MIN_WIDTH 500 +#define SHEET_MIN_HEIGHT 150 +/****************************************************************/ +DrawSheetStruct * WinEDA_SchematicFrame::CreateSheet(wxDC * DC) +/****************************************************************/ +/* Routine de Creation d'une feuille de hierarchie (Sheet) */ +{ + g_ItemToRepeat = NULL; + + DrawSheetStruct * Sheet = new DrawSheetStruct(m_CurrentScreen->m_Curseur); + + Sheet->m_Flags = IS_NEW | IS_RESIZED; + Sheet->m_TimeStamp = GetTimeStamp(); + Sheet->m_Parent = m_CurrentScreen; + s_SheetMindx = SHEET_MIN_WIDTH; + s_SheetMindy = SHEET_MIN_HEIGHT; + + m_CurrentScreen->m_CurrentItem = Sheet; + + DrawPanel->ManageCurseur = DeplaceSheet; + DrawPanel->ForceCloseManageCurseur = ExitSheet; + + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + + return Sheet; +} + + +/*******************************************************************************/ +void WinEDA_SchematicFrame::ReSizeSheet(DrawSheetStruct * Sheet, wxDC * DC) +/*******************************************************************************/ +{ +DrawSheetLabelStruct* sheetlabel; + + if ( Sheet == NULL ) return; + if( Sheet->m_Flags & IS_NEW) return; + + if( Sheet->m_StructType != DRAW_SHEET_STRUCT_TYPE) + { + DisplayError(this, wxT("WinEDA_SchematicFrame::ReSizeSheet: Bad SructType")); + return; + } + + GetScreen()->SetModify(); + Sheet->m_Flags |= IS_RESIZED; + + /* sauvegarde des anciennes valeurs */ + s_OldPos.x = Sheet->m_Size.x; + s_OldPos.y = Sheet->m_Size.y; + + /* Recalcul des dims min de la sheet */ + s_SheetMindx = SHEET_MIN_WIDTH; + s_SheetMindy = SHEET_MIN_HEIGHT; + sheetlabel = Sheet->m_Label; + while(sheetlabel) + { + s_SheetMindx = MAX(s_SheetMindx, + (int)((sheetlabel->GetLength()+1) * sheetlabel->m_Size.x) ); + s_SheetMindy = MAX(s_SheetMindy,sheetlabel->m_Pos.y - Sheet->m_Pos.y); + sheetlabel = (DrawSheetLabelStruct *) sheetlabel->Pnext; + } + DrawPanel->ManageCurseur = DeplaceSheet ; + DrawPanel->ForceCloseManageCurseur = ExitSheet; + DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); +} + + +/*********************************************************************************/ +void WinEDA_SchematicFrame::StartMoveSheet(DrawSheetStruct* Sheet, wxDC * DC) +/*********************************************************************************/ +{ + if ( (Sheet == NULL) || ( Sheet->m_StructType != DRAW_SHEET_STRUCT_TYPE) ) + return; + + DrawPanel->CursorOff(DC); + m_CurrentScreen->m_Curseur = Sheet->m_Pos; + DrawPanel->MouseToCursorSchema(); + + s_OldPos = Sheet->m_Pos; + Sheet->m_Flags |= IS_MOVED; + DrawPanel->ManageCurseur = DeplaceSheet ; + DrawPanel->ForceCloseManageCurseur = ExitSheet; + DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); + + DrawPanel->CursorOn(DC); +} + +/********************************************************/ +/*** Routine de deplacement Sheet, lie au curseur. */ +/* Appele par GeneralControle grace a ManageCurseur. */ +/********************************************************/ +static void DeplaceSheet(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +{ +wxPoint move_vector; +DrawSheetLabelStruct * SheetLabel; +BASE_SCREEN * screen = panel->m_Parent->m_CurrentScreen; + +DrawSheetStruct * Sheet = (DrawSheetStruct *) + screen->m_CurrentItem; + + /* Effacement du composant: tj apres depl curseur */ + if( erase ) + RedrawOneStruct(panel, DC, Sheet, g_XorMode); + + if( Sheet->m_Flags & IS_RESIZED) + { + Sheet->m_Size.x = MAX(s_SheetMindx, + screen->m_Curseur.x - Sheet->m_Pos.x); + Sheet->m_Size.y = MAX(s_SheetMindy, + screen->m_Curseur.y - Sheet->m_Pos.y); + SheetLabel = Sheet->m_Label; + while(SheetLabel) + { + if( SheetLabel->m_Edge) + SheetLabel->m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x; + SheetLabel = (DrawSheetLabelStruct *) SheetLabel->Pnext; + } + } + else /* Move Sheet */ + { + move_vector.x = screen->m_Curseur.x - Sheet->m_Pos.x; + move_vector.y = screen->m_Curseur.y - Sheet->m_Pos.y; + MoveOneStruct(Sheet, move_vector); + } + + RedrawOneStruct(panel, DC, Sheet, g_XorMode); +} + + +/****************************************************************/ +void DrawSheetStruct::Place( WinEDA_DrawFrame * frame, wxDC * DC) +/****************************************************************/ +{ + /* Placement en liste des structures si nouveau composant:*/ + if(m_Flags & IS_NEW) + { + if ( ! ((WinEDA_SchematicFrame*)frame)->EditSheet(this, DC) ) + { + frame->m_CurrentScreen->m_CurrentItem = NULL; + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; + RedrawOneStruct(frame->DrawPanel, DC, this, g_XorMode); + delete this; + return; + } + + + if ( wxFileExists(m_FileName) ) + { + ((WinEDA_SchematicFrame*)frame)->LoadOneSheet( + this, m_FileName); + } + } + + EDA_BaseStruct::Place(frame, DC); +} + +/****************************************/ +/* Routine de sortie du Menu de Sheet */ +/****************************************/ +static void ExitSheet(WinEDA_DrawPanel * Panel, wxDC * DC) +{ +SCH_SCREEN *Screen = (SCH_SCREEN *) Panel->m_Parent->m_CurrentScreen; +DrawSheetStruct * Sheet = (DrawSheetStruct *) Screen->m_CurrentItem; + + if ( Sheet == NULL) return; + + /* Deplacement composant en cours */ + if ( Sheet->m_Flags & IS_NEW ) /* Nouveau Placement en cours, on l'efface */ + { + RedrawOneStruct(Panel, DC, Sheet, g_XorMode); + delete Sheet; + } + else if ( Sheet->m_Flags & IS_RESIZED )/* resize en cours: on l'annule */ + { + RedrawOneStruct(Panel, DC, Sheet, g_XorMode); + Sheet->m_Size.x = s_OldPos.x; + Sheet->m_Size.y = s_OldPos.y; + RedrawOneStruct(Panel, DC, Sheet, GR_DEFAULT_DRAWMODE); + Sheet->m_Flags = 0; + } + + else if ( Sheet->m_Flags & IS_MOVED )/* move en cours: on l'annule */ + { + wxPoint curspos = Screen->m_Curseur; + Panel->m_Parent->m_CurrentScreen->m_Curseur = s_OldPos; + DeplaceSheet(Panel, DC, TRUE); + RedrawOneStruct(Panel, DC, Sheet, GR_DEFAULT_DRAWMODE); + Sheet->m_Flags = 0; + Screen->m_Curseur = curspos; + } + + else Sheet->m_Flags = 0; + + Screen->m_CurrentItem = NULL; + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur =NULL; +} + + + +/********************************************************************/ +void DrawSheetStruct::CleanupSheet(WinEDA_SchematicFrame * frame, wxDC *DC) +/********************************************************************/ +/* Delete pinsheets which are not corresponding to a Global label + if DC != NULL, redraw Sheet +*/ +{ +DrawSheetLabelStruct* Pinsheet, * NextPinsheet; + + if( ! IsOK(frame, _("Ok to cleanup this sheet") ) ) return; + + Pinsheet = m_Label; + while(Pinsheet) + { + /* Search Glabel corresponding to this Pinsheet */ + + EDA_BaseStruct *DrawStruct = EEDrawList; + DrawGlobalLabelStruct * GLabel = NULL; + for (; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) + { + if( DrawStruct->m_StructType != DRAW_GLOBAL_LABEL_STRUCT_TYPE ) + continue; + GLabel = (DrawGlobalLabelStruct *) DrawStruct; + if( Pinsheet->m_Text.CmpNoCase(GLabel->m_Text) == 0 ) + break; // Found! + GLabel = NULL; + } + + NextPinsheet = (DrawSheetLabelStruct *) Pinsheet->Pnext; + if ( GLabel == NULL ) // Glabel not found: delete pinsheet + { + frame->GetScreen()->SetModify(); + frame->DeleteSheetLabel(DC, Pinsheet); + } + Pinsheet = NextPinsheet; + } +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_SheetPropertiesFrame::OnCancelClick( wxCommandEvent& event ) +{ + EndModal(0); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_SheetPropertiesFrame::OnOkClick( wxCommandEvent& event ) +{ + SheetPropertiesAccept(event); + EndModal(1); +} diff --git a/eeschema/sheet.h b/eeschema/sheet.h new file mode 100644 index 0000000000..07f6c9b49f --- /dev/null +++ b/eeschema/sheet.h @@ -0,0 +1,124 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: sheet.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 08/02/2006 18:37:02 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 08/02/2006 18:37:02 + +#ifndef _SHEET_H_ +#define _SHEET_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "sheet.h" +#endif + +/*! + * Includes + */ + +////@begin includes +#include "wx/valtext.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_SHEETPROPERTIESFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_SHEETPROPERTIESFRAME_TITLE _("Sheet properties") +#define SYMBOL_WINEDA_SHEETPROPERTIESFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_SHEETPROPERTIESFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_SHEETPROPERTIESFRAME_POSITION wxDefaultPosition +#define ID_TEXTCTRL1 10002 +#define ID_TEXTCTRL 10001 +#define ID_TEXTCTRL2 10003 +#define ID_TEXTCTRL3 10004 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_SheetPropertiesFrame class declaration + */ + +class WinEDA_SheetPropertiesFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_SheetPropertiesFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_SheetPropertiesFrame( ); + WinEDA_SheetPropertiesFrame( WinEDA_SchematicFrame* parent, + DrawSheetStruct * currentsheet, + wxWindowID id = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_IDNAME, + const wxString& caption = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_TITLE, + const wxPoint& pos = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_POSITION, + const wxSize& size = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_SIZE, + long style = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_SheetPropertiesFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + +////@end WinEDA_SheetPropertiesFrame event handler declarations + +////@begin WinEDA_SheetPropertiesFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_SheetPropertiesFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + void SheetPropertiesAccept(wxCommandEvent& event); + +////@begin WinEDA_SheetPropertiesFrame member variables + wxTextCtrl* m_FileNameWin; + wxTextCtrl* m_SheetNameWin; + wxStaticText* m_FileNameTextSize; + wxTextCtrl* m_FileNameSize; + wxStaticText* m_SheetNameTextSize; + wxTextCtrl* m_SheetNameSize; +////@end WinEDA_SheetPropertiesFrame member variables + + WinEDA_SchematicFrame * m_Parent; + DrawSheetStruct * m_CurrentSheet; +}; + +#endif + // _SHEET_H_ diff --git a/eeschema/sheet.pjd b/eeschema/sheet.pjd new file mode 100644 index 0000000000..469578d613 --- /dev/null +++ b/eeschema/sheet.pjd @@ -0,0 +1,1037 @@ + + +
+ 0 + "" + "" + "" + "" + 24 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "Sheet properties" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "8/11/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "ID_DIALOG" + 10000 + "WinEDA_SheetPropertiesFrame" + "wxDialog" + "wxDialog" + "sheet.cpp" + "sheet.h" + "" + "Sheet properties" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Vertical" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "8/11/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "8/11/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "8/11/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Filename:" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Top" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL1" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "8/5/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL1" + 10002 + "wxTextCtrl" + "m_FileNameWin" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "m_CurrentSheet->m_Field[SHEET_FILENAME].m_Text" + "wxTextValidator(wxFILTER_NONE, & %VARIABLE%)" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 300 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "8/11/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Sheetname:" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Top" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "8/5/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL" + 10001 + "wxTextCtrl" + "m_SheetNameWin" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "m_CurrentSheet->m_Field[VALUE].m_Text" + "wxTextValidator(wxFILTER_NONE, & %VARIABLE%)" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 300 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "8/11/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "8/11/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_FileNameTextSize" + "Size" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Top" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL2" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "8/11/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL2" + 10003 + "wxTextCtrl" + "m_FileNameSize" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "8/11/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_SheetNameTextSize" + "Size" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Top" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL3" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "8/11/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL3" + 10004 + "wxTextCtrl" + "m_SheetNameSize" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "8/11/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "8/11/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: wxID_CANCEL" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "8/11/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCancelClick" + "wxID_CANCEL" + 5101 + "wxButton" + "" + "&Cancel" + 0 + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_OK" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "8/11/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnOkClick" + "wxID_OK" + 5100 + "wxButton" + "" + "&OK" + 0 + "" + "" + "" + "C40000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "sheet.rc" + "source-editor-document" + "sheet.rc" + "source-editor" + 0 + 0 + 1 + 0 + "8/11/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/sheet.rc b/eeschema/sheet.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/eeschema/sheet.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp new file mode 100644 index 0000000000..a7a0adcffd --- /dev/null +++ b/eeschema/sheetlab.cpp @@ -0,0 +1,445 @@ + /****************************************************************/ + /* sheetlab.cpp module pour creation /editin des Sheet labels */ + /****************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +/* Routines Locales */ +static void ExitPinSheet(WinEDA_DrawPanel * Panel, wxDC * DC ); +static void Move_PinSheet(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); + +/* Variables locales */ +static int CurrentTypeLabel = NET_INPUT; +static wxSize NetSheetTextSize(DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT); + + /****************************************/ + /* class WinEDA_PinSheetPropertiesFrame */ + /****************************************/ + +#define NBSHAPES 5 +static wxString shape_list[NBSHAPES] = +{ + wxT("Input"), wxT("Output"), wxT("Bidi"), wxT("TriState"), wxT("Passive") +}; + +enum id_Textdit +{ + ID_ACCEPT_PINSHEET_PROPERTIES = 1970, + ID_CANCEL_PINSHEET_PROPERTIES +}; + + +/*****************************************************/ +class WinEDA_PinSheetPropertiesFrame: public wxDialog +/*****************************************************/ +{ +private: + + WinEDA_SchematicFrame * m_Parent; + DrawSheetLabelStruct * m_CurrentPinSheet; + wxRadioBox * m_PinSheetType; + wxRadioBox * m_PinSheetShape; + WinEDA_GraphicTextCtrl * m_TextWin; + +public: + // Constructor and destructor + WinEDA_PinSheetPropertiesFrame(WinEDA_SchematicFrame *parent, + DrawSheetLabelStruct * curr_pinsheet, + const wxPoint & framepos = wxPoint(-1,-1) ); + ~WinEDA_PinSheetPropertiesFrame(void){}; + +private: + void PinSheetPropertiesAccept(wxCommandEvent& event); + void OnQuit(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(WinEDA_PinSheetPropertiesFrame, wxDialog) + EVT_BUTTON(ID_ACCEPT_PINSHEET_PROPERTIES, WinEDA_PinSheetPropertiesFrame::PinSheetPropertiesAccept) + EVT_BUTTON(ID_CANCEL_PINSHEET_PROPERTIES, WinEDA_PinSheetPropertiesFrame::OnQuit) +END_EVENT_TABLE() + + +/**********************************************************************************/ +WinEDA_PinSheetPropertiesFrame::WinEDA_PinSheetPropertiesFrame( + WinEDA_SchematicFrame *parent, + DrawSheetLabelStruct * curr_pinsheet, + const wxPoint & framepos): + wxDialog(parent, -1, _("PinSheet Properties:"), framepos, wxSize(340, 220), + DIALOG_STYLE) +/**********************************************************************************/ +{ +wxPoint pos; +wxString number; +wxButton * Button; + + m_Parent = parent; + Centre(); + + wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(MainBoxSizer); + wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + m_CurrentPinSheet = curr_pinsheet; + + /* Creation des boutons de commande */ + Button = new wxButton(this, ID_ACCEPT_PINSHEET_PROPERTIES, + _("Ok")); + Button->SetForegroundColour(*wxRED); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Button = new wxButton(this, ID_CANCEL_PINSHEET_PROPERTIES, + _("Cancel")); + Button->SetForegroundColour(*wxBLUE); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + m_TextWin = new WinEDA_GraphicTextCtrl(this, _("Text:"), + m_CurrentPinSheet->m_Text, m_CurrentPinSheet->m_Size.x, + g_UnitMetric , LeftBoxSizer, 200); + + // Selection de la forme : + m_PinSheetShape = new wxRadioBox(this, -1, _("PinSheet Shape:"), + wxDefaultPosition, wxSize(-1,-1), + NBSHAPES, shape_list, 1); + m_PinSheetShape->SetSelection( m_CurrentPinSheet->m_Shape ); + LeftBoxSizer->Add(m_PinSheetShape, 0, wxGROW|wxALL, 5); + + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); +} + + +/************************************************************************/ +void WinEDA_PinSheetPropertiesFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/************************************************************************/ +{ + // true is to force the frame to close + Close(true); +} + + +/***********************************************************************************/ +void WinEDA_PinSheetPropertiesFrame::PinSheetPropertiesAccept(wxCommandEvent& event) +/***********************************************************************************/ +{ + m_CurrentPinSheet->m_Text = m_TextWin->GetText(); + m_CurrentPinSheet->m_Size.x = m_CurrentPinSheet->m_Size.y = m_TextWin->GetTextSize(); + + m_CurrentPinSheet->m_Shape = m_PinSheetShape->GetSelection(); + Close(TRUE); +} + +/*****************************************************************/ +static void ExitPinSheet(WinEDA_DrawPanel * Panel, wxDC * DC) +/*****************************************************************/ +/* Routine de sortie du Menu d'Edition Des NETS (Labels) SHEET +*/ +{ +DrawSheetLabelStruct * SheetLabel = (DrawSheetLabelStruct *) + Panel->GetScreen()->m_CurrentItem; + + if ( SheetLabel == NULL ) return; + + if ( SheetLabel->m_Flags & IS_NEW ) + { /* Nouveau Placement en cours, on l'efface */ + RedrawOneStruct(Panel, DC, SheetLabel, g_XorMode); + delete SheetLabel; + } + else + { + RedrawOneStruct(Panel, DC, SheetLabel, GR_DEFAULT_DRAWMODE); + SheetLabel->m_Flags = 0; + } + + Panel->GetScreen()->m_CurrentItem = NULL; + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; +} + +/* Cette routine place un nouveau NetSheet ou place un ancien en cours +de deplacement + Si le NetSheet est nouveau, il est pointe par NewSheetLabel +*/ +void DrawSheetLabelStruct::Place( WinEDA_DrawFrame * frame, wxDC * DC) +{ +DrawSheetStruct * Sheet = (DrawSheetStruct *) m_Parent; + + if( m_Flags & IS_NEW ) /* ajout a la liste des structures */ + { + if(Sheet->m_Label == NULL ) Sheet->m_Label = this; + else + { + DrawSheetLabelStruct * pinsheet = Sheet->m_Label; + while(pinsheet) + { + if( pinsheet->Pnext == NULL ) + { + pinsheet->Pnext = this; + break; + } + pinsheet = (DrawSheetLabelStruct*)pinsheet->Pnext; + } + } + } + + m_Flags = 0; + m_Pos.x = Sheet->m_Pos.x; + m_Edge = 0; + if( frame->GetScreen()->m_Curseur.x > (Sheet->m_Pos.x + (Sheet->m_Size.x/2)) ) + { + m_Edge = 1; + m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x; + } + + m_Pos.y = frame->GetScreen()->m_Curseur.y; + if( m_Pos.y < Sheet->m_Pos.y ) m_Pos.y = Sheet->m_Pos.y; + if( m_Pos.y > (Sheet->m_Pos.y+Sheet->m_Size.y) ) + m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y; + + RedrawOneStruct(frame->DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE); + + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; +} + + +/*******************************************************************************/ +void WinEDA_SchematicFrame::StartMove_PinSheet(DrawSheetLabelStruct * SheetLabel, + wxDC * DC) +/*******************************************************************************/ +/* Initialise un deplacement de NetSheet */ +{ + NetSheetTextSize = SheetLabel->m_Size; + CurrentTypeLabel = SheetLabel->m_Shape; + SheetLabel->m_Flags |= IS_MOVED; + + DrawPanel->ManageCurseur = Move_PinSheet; + DrawPanel->ForceCloseManageCurseur = ExitPinSheet; + DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); +} + +/**********************************************************************/ +/* Routine de deplacement du NetSheet actif selon la position souris */ +/**********************************************************************/ + +static void Move_PinSheet(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +{ +DrawSheetLabelStruct * SheetLabel = (DrawSheetLabelStruct *) + panel->m_Parent->GetScreen()->m_CurrentItem; + + if ( SheetLabel == NULL ) return; + +DrawSheetStruct * Sheet = (DrawSheetStruct *) SheetLabel->m_Parent; + + if ( Sheet == NULL ) return; + if( erase ) + RedrawOneStruct(panel, DC, SheetLabel, g_XorMode); + + SheetLabel->m_Edge = 0; + SheetLabel->m_Pos.x = Sheet->m_Pos.x; + if( panel->m_Parent->GetScreen()->m_Curseur.x > (Sheet->m_Pos.x + (Sheet->m_Size.x/2)) ) + { + SheetLabel->m_Edge = 1; + SheetLabel->m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x; + } + + SheetLabel->m_Pos.y = panel->m_Parent->GetScreen()->m_Curseur.y; + if( SheetLabel->m_Pos.y < Sheet->m_Pos.y ) + SheetLabel->m_Pos.y = Sheet->m_Pos.y; + if( SheetLabel->m_Pos.y > (Sheet->m_Pos.y+Sheet->m_Size.y) ) + SheetLabel->m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y; + + RedrawOneStruct(panel, DC, SheetLabel, g_XorMode); +} + + +/***************************************************************************/ +void WinEDA_SchematicFrame::Edit_PinSheet(DrawSheetLabelStruct * SheetLabel, + wxDC * DC) +/***************************************************************************/ +/* Modification du texte d'un net sheet */ +{ + if( SheetLabel == NULL) return; + + RedrawOneStruct(DrawPanel, DC, SheetLabel, g_XorMode); + +WinEDA_PinSheetPropertiesFrame * frame = + new WinEDA_PinSheetPropertiesFrame(this, SheetLabel); + + frame->ShowModal(); frame->Destroy(); + + RedrawOneStruct(DrawPanel, DC, SheetLabel, GR_DEFAULT_DRAWMODE); +} + + +/***************************************************************/ +DrawSheetLabelStruct * WinEDA_SchematicFrame::Create_PinSheet( + DrawSheetStruct * Sheet, wxDC * DC) +/**************************************************************/ +/* Addition d'un nouveau PinSheet sur la feuille selectionnee, a l'endroit + pointe par la souris +*/ +{ +wxString Line, Text; +DrawSheetLabelStruct * NewSheetLabel; + + switch(CurrentTypeLabel) + { + default: CurrentTypeLabel = NET_INPUT; + case NET_INPUT: Text = wxT("Pin Input: "); + break; + + case NET_OUTPUT: Text = wxT("Pin Output: "); + break; + + case NET_BIDI: Text = wxT("Pin BiDi: "); + break; + + case NET_TRISTATE: Text = wxT("Pin TriStat: "); + break; + + case NET_UNSPECIFIED: Text = wxT("Pin Unspec.: "); + break; + + } + + Get_Message(Text,Line, this); + if( Line.IsEmpty() ) return NULL; + + GetScreen()->SetModify(); + + /* Creation en memoire */ + NewSheetLabel = new DrawSheetLabelStruct(Sheet, wxPoint(0,0), Line); + NewSheetLabel->m_Flags = IS_NEW; + NewSheetLabel->m_Size = NetSheetTextSize; + NewSheetLabel->m_Shape = CurrentTypeLabel; + + GetScreen()->m_CurrentItem = NewSheetLabel; + + DrawPanel->ManageCurseur = Move_PinSheet; + DrawPanel->ForceCloseManageCurseur = ExitPinSheet; + DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); + + return NewSheetLabel; +} + + +/*****************************************************************************/ +DrawSheetLabelStruct * + WinEDA_SchematicFrame::Import_PinSheet(DrawSheetStruct * Sheet, wxDC * DC) +/*****************************************************************************/ +/* Permet de creer automatiquement les Sheet Labels a partir des Labels Globaux +de la feuille de sous hierarchie correspondante +*/ +{ +EDA_BaseStruct *DrawStruct; +DrawSheetLabelStruct * NewSheetLabel, * SheetLabel = NULL; +DrawGlobalLabelStruct * GLabel = NULL; + + DrawStruct = Sheet->EEDrawList; + GLabel = NULL; + for (; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext ) + { + if( DrawStruct->m_StructType != DRAW_GLOBAL_LABEL_STRUCT_TYPE ) + continue; + GLabel = (DrawGlobalLabelStruct *) DrawStruct; + + /* Ici un G-Label a ete trouve: y a t-il un SheetLabel correspondant */ + SheetLabel = Sheet->m_Label; + for( ;SheetLabel != NULL; SheetLabel = (DrawSheetLabelStruct*) SheetLabel->Pnext ) + { + if( SheetLabel->m_Text.CmpNoCase(GLabel->m_Text) == 0 ) + { + break; + } + } + /* Ici si SheetLabel == NULL le G-Label n'a pas de SheetLabel corresp */ + if( SheetLabel == NULL ) break; + } + + if( (GLabel == NULL ) || SheetLabel ) + { + DisplayError(this, _("No New Global Label found"), 10); + return NULL; + } + + /* Ici G-Label n'a pas de SheetLabel corresp, on va le creer */ + + GetScreen()->SetModify(); + /* Creation en memoire */ + NewSheetLabel = new DrawSheetLabelStruct(Sheet, wxPoint(0,0), GLabel->m_Text); + NewSheetLabel->m_Flags = IS_NEW; + NewSheetLabel->m_Size = NetSheetTextSize; + CurrentTypeLabel = NewSheetLabel->m_Shape = GLabel->m_Shape; + + GetScreen()->m_CurrentItem = NewSheetLabel; + DrawPanel->ManageCurseur = Move_PinSheet; + DrawPanel->ForceCloseManageCurseur = ExitPinSheet; + Move_PinSheet(DrawPanel, DC, FALSE); + + return NewSheetLabel; +} + + +/**************************************************************/ +void WinEDA_SchematicFrame::DeleteSheetLabel(wxDC * DC, + DrawSheetLabelStruct * SheetLabelToDel) +/**************************************************************/ +/* + Routine de suppression de 1 Structure type (DrawSheetLabelStruct. +Cette Structure ne peut etre mise en pile "undelete" car il ne serait pas +possible de la ratacher a la 'DrawSheetStruct' d'origine +si DC != NULL, effacement a l'ecran du dessin +*/ +{ +EDA_BaseStruct * DrawStruct; +DrawSheetLabelStruct* SheetLabel, *NextLabel; + + if ( DC ) RedrawOneStruct(DrawPanel, DC, SheetLabelToDel, g_XorMode); + + /* Recherche de la DrawSheetStruct d'origine */ + DrawStruct = SheetLabelToDel->m_Parent; + + if (DrawStruct) // Modification du chainage + { + if (DrawStruct->m_StructType != DRAW_SHEET_STRUCT_TYPE) + { + DisplayError(this, wxT("DeleteSheetLabel error: m_Parent != DRAW_SHEET_STRUCT_TYPE")); + return; + } + + /* suppression chainage */ + SheetLabel = ((DrawSheetStruct *) DrawStruct)->m_Label; + if( SheetLabel == SheetLabelToDel ) + ((DrawSheetStruct *) DrawStruct)->m_Label = + (DrawSheetLabelStruct *)SheetLabel->Pnext; + + else while( SheetLabel )/* Examen de la liste dependante et suppression chainage */ + { + NextLabel = (DrawSheetLabelStruct *)SheetLabel->Pnext; + if( NextLabel == SheetLabelToDel ) + { + SheetLabel->Pnext = NextLabel->Pnext; + break;; + } + SheetLabel = NextLabel; + } + } + + delete SheetLabelToDel; +} + + + diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp new file mode 100644 index 0000000000..1b112bdbcf --- /dev/null +++ b/eeschema/symbdraw.cpp @@ -0,0 +1,793 @@ + /********************************************************************/ + /* EESchema - symbdraw.cpp */ + /* Menus et Routines de dessin des elements graphiques des symboles */ + /********************************************************************/ + + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "trigo.h" + +#include "protos.h" + +#include "id.h" + +/* Routines importees */ + +/* Routines locales */ +static void SymbolDisplayDraw(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void ComputeArc(LibDrawArc * DrawItem, wxPoint ArcCentre); +static void RedrawWhileMovingCursor(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void MoveLibDrawItemAt(LibEDA_BaseStruct * DrawItem, wxPoint newpos); + +/* Variables locales */ +static int StateDrawArc, ArcStartX, ArcStartY, ArcEndX, ArcEndY; +static wxPoint InitPosition, StartCursor, ItemPreviousPos; +static int FlSymbol_Fill = NO_FILL; + + + /************************************/ + /* class WinEDA_PartPropertiesFrame */ + /************************************/ +#include "dialog_cmp_graphic_properties.cpp" + + +/************************************************************/ +void WinEDA_bodygraphics_PropertiesFrame:: + bodygraphics_PropertiesAccept(wxCommandEvent& event) +/************************************************************/ +/* Update the current draw item +*/ +{ + g_FlDrawSpecificConvert = m_CommonConvert->GetValue() ? FALSE : TRUE; + g_FlDrawSpecificUnit = m_CommonUnit->GetValue() ? FALSE : TRUE; + if ( m_Filled ) + FlSymbol_Fill = m_Filled->GetSelection(); + + if ( CurrentDrawItem ) + { + if ( ! (CurrentDrawItem->m_Flags & IS_NEW) ) // if IS_NEW, copy for undo is done before place + m_Parent->SaveCopyInUndoList(CurrentLibEntry); + wxClientDC dc(m_Parent->DrawPanel); + m_Parent->DrawPanel->PrepareGraphicContext(&dc); + + DrawLibraryDrawStruct(m_Parent->DrawPanel, &dc, CurrentLibEntry, 0 , 0, + CurrentDrawItem, CurrentUnit, g_XorMode); + + if( g_FlDrawSpecificUnit ) CurrentDrawItem->m_Unit = CurrentUnit; + else CurrentDrawItem->m_Unit = 0; + if( g_FlDrawSpecificConvert ) CurrentDrawItem->m_Convert = CurrentConvert; + else CurrentDrawItem->m_Convert = 0; + if ( m_Filled ) + { + switch(CurrentDrawItem->m_StructType) + { + case COMPONENT_ARC_DRAW_TYPE: + ((LibDrawArc*)CurrentDrawItem)->m_Fill = FlSymbol_Fill; + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + ((LibDrawCircle*)CurrentDrawItem)->m_Fill = FlSymbol_Fill; + break; + + case COMPONENT_RECT_DRAW_TYPE: + ((LibDrawSquare*)CurrentDrawItem)->m_Fill = FlSymbol_Fill; + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + ((LibDrawPolyline*)CurrentDrawItem)->m_Fill = FlSymbol_Fill; + break; + + default: break; + } + } + CurrentLibEntry->SortDrawItems(); + + m_Parent->m_CurrentScreen->SetModify(); + + DrawLibraryDrawStruct(m_Parent->DrawPanel, &dc, CurrentLibEntry, 0 , 0, + CurrentDrawItem, CurrentUnit, g_XorMode); + } + + Close(); + + if ( CurrentDrawItem ) + CurrentDrawItem->Display_Infos_DrawEntry(m_Parent); + m_Parent->ReDrawPanel(); +} + +/**********************************************************/ +void WinEDA_LibeditFrame::EditGraphicSymbol(wxDC * DC, + LibEDA_BaseStruct * DrawItem) +/**********************************************************/ +/* Install the dialog box for editing a graphical item properties +*/ +{ + if ( DrawItem == NULL ) return; + + WinEDA_bodygraphics_PropertiesFrame * frame = new + WinEDA_bodygraphics_PropertiesFrame(this); + frame->ShowModal(); frame->Destroy(); +} + + +/****************************************************************/ +static void AbortSymbolTraceOn(WinEDA_DrawPanel * Panel, wxDC * DC) +/****************************************************************/ +{ + + StateDrawArc = 0; + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + if(CurrentDrawItem == NULL) return; + + if(CurrentDrawItem->m_Flags & IS_NEW) + { + if ( CurrentDrawItem->m_StructType == COMPONENT_ARC_DRAW_TYPE ) + { + Panel->m_Parent->RedrawActiveWindow( DC,TRUE); + } + else DrawLibraryDrawStruct(Panel, DC, CurrentLibEntry, 0 , 0, + CurrentDrawItem, CurrentUnit, g_XorMode); + delete CurrentDrawItem; + } + + else + { + wxPoint curpos; + curpos = Panel->GetScreen()->m_Curseur; + Panel->GetScreen()->m_Curseur = StartCursor; + RedrawWhileMovingCursor(Panel, DC, TRUE); + Panel->GetScreen()->m_Curseur = curpos; + DrawLibraryDrawStruct(Panel, DC, CurrentLibEntry, 0 , 0, + CurrentDrawItem, CurrentUnit, GR_DEFAULT_DRAWMODE); + + CurrentDrawItem->m_Flags = 0; + } + + CurrentDrawItem = NULL; +} + + + +/*********************************************************************/ +LibEDA_BaseStruct * WinEDA_LibeditFrame::CreateGraphicItem(wxDC * DC) +/*********************************************************************/ +/* Routine de creation d'un nouvel element type LibraryDrawStruct + POLYLINE + ARC + CIRCLE + RECTANGLE +*/ +{ +int DrawType; +int * ptpoly; + + if(CurrentDrawItem) return NULL; + + DrawPanel->m_IgnoreMouseEvents = TRUE; + // Creation du nouvel element + switch ( m_ID_current_state ) + { + case ID_LIBEDIT_BODY_LINE_BUTT: + DrawType = COMPONENT_POLYLINE_DRAW_TYPE; + break; + + case ID_LIBEDIT_BODY_ARC_BUTT: + DrawType = COMPONENT_ARC_DRAW_TYPE; + break; + + case ID_LIBEDIT_BODY_CIRCLE_BUTT: + DrawType = COMPONENT_CIRCLE_DRAW_TYPE; + break; + + case ID_LIBEDIT_BODY_RECT_BUTT: + DrawType = COMPONENT_RECT_DRAW_TYPE; + break; + + case ID_LIBEDIT_BODY_TEXT_BUTT: + DrawType = COMPONENT_GRAPHIC_TEXT_DRAW_TYPE; + break; + + default: + DisplayError(this, wxT("SymbolBeginDrawItem Internal err: Id error")); + return NULL; + } + + DrawPanel->ManageCurseur = SymbolDisplayDraw; + DrawPanel->ForceCloseManageCurseur = AbortSymbolTraceOn; + + switch ( DrawType ) + { + case COMPONENT_ARC_DRAW_TYPE: + { + LibDrawArc * Arc = new LibDrawArc(); + CurrentDrawItem = Arc; + ArcStartX = ArcEndX = m_CurrentScreen->m_Curseur.x; + ArcStartY = ArcEndY = - m_CurrentScreen->m_Curseur.y; + StateDrawArc = 1; + Arc->m_Fill = FlSymbol_Fill; + } + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + { + LibDrawCircle * Circle = new LibDrawCircle(); + CurrentDrawItem = Circle; + Circle->m_Pos.x = m_CurrentScreen->m_Curseur.x; + Circle->m_Pos.y = - m_CurrentScreen->m_Curseur.y; + Circle->m_Fill = FlSymbol_Fill; + } + break; + + case COMPONENT_RECT_DRAW_TYPE: + { + LibDrawSquare * Square = new LibDrawSquare(); + CurrentDrawItem = Square; + Square->m_Start.x = m_CurrentScreen->m_Curseur.x; + Square->m_Start.y = - m_CurrentScreen->m_Curseur.y; + Square->m_End = Square->m_Start; + Square->m_Fill = FlSymbol_Fill; + } + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + { + LibDrawPolyline* polyline = new LibDrawPolyline(); + CurrentDrawItem = polyline; + polyline->n = 2; + ptpoly = (int*)MyZMalloc( 4 * sizeof(int)); + polyline->PolyList = ptpoly; + ptpoly[0] = ptpoly[2] = m_CurrentScreen->m_Curseur.x; + ptpoly[1] = ptpoly[3] = - m_CurrentScreen->m_Curseur.y; + polyline->m_Fill = FlSymbol_Fill; + } + break; + + case COMPONENT_LINE_DRAW_TYPE: + { + LibDrawSegment* Segment = new LibDrawSegment(); + CurrentDrawItem = Segment; + Segment->m_Start.x = m_CurrentScreen->m_Curseur.x; + Segment->m_Start.y = -m_CurrentScreen->m_Curseur.y; + Segment->m_End = Segment->m_Start; + } + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + { + LibDrawText* Text = new LibDrawText(); + CurrentDrawItem = Text; + Text->m_Size.x = Text->m_Size.y = g_LastTextSize; + Text->m_Horiz = g_LastTextOrient; + Text->m_Pos.x = m_CurrentScreen->m_Curseur.x; + Text->m_Pos.y = - m_CurrentScreen->m_Curseur.y; + EditSymbolText(NULL, Text); + if ( Text->m_Text.IsEmpty() ) + { + delete Text; + CurrentDrawItem = NULL; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + } + else + { + StartMoveDrawSymbol(DC); + DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, 0 , 0, + Text, CurrentUnit, g_XorMode); + } + } + break; + } + + if ( CurrentDrawItem ) + { + CurrentDrawItem->m_Flags |= IS_NEW; + if(g_FlDrawSpecificUnit) CurrentDrawItem->m_Unit = CurrentUnit; + if(g_FlDrawSpecificConvert) CurrentDrawItem->m_Convert = CurrentConvert; + } + + DrawPanel->MouseToCursorSchema(); + DrawPanel->m_IgnoreMouseEvents = FALSE; + + return CurrentDrawItem; +} + + +/********************************************************/ +void WinEDA_LibeditFrame::GraphicItemBeginDraw(wxDC * DC) +/********************************************************/ +/* Routine de creation d'un nouvel element type LibraryDrawStruct +*/ +{ + if(CurrentDrawItem == NULL) return; + + switch ( CurrentDrawItem->m_StructType ) + { + case COMPONENT_ARC_DRAW_TYPE: + if(StateDrawArc == 1) + { + SymbolDisplayDraw(DrawPanel,DC, FALSE); + StateDrawArc = 2; + SymbolDisplayDraw(DrawPanel,DC, FALSE); + break; + } + if(StateDrawArc > 1) + { + EndDrawGraphicItem(DC); + return; + } + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + case COMPONENT_RECT_DRAW_TYPE: + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + EndDrawGraphicItem(DC); + return; + + case COMPONENT_POLYLINE_DRAW_TYPE: + { + wxPoint pos = m_CurrentScreen->m_Curseur; + ((LibDrawPolyline*)CurrentDrawItem)->AddPoint(pos); + } + break; + + case COMPONENT_LINE_DRAW_TYPE: + break; + } + +} + +/**************************************************************************/ +static void RedrawWhileMovingCursor(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/**************************************************************************/ +/* Redessine le "Draw Symbol" en cours de deplacement +*/ +{ +BASE_SCREEN * Screen = panel->m_Parent->m_CurrentScreen; +int mx, my; + + /* Effacement ancien dessin */ + if( erase ) + { + mx = ItemPreviousPos.x - StartCursor.x , + my = ItemPreviousPos.y - StartCursor.y ; + + DrawLibraryDrawStruct(panel, DC, CurrentLibEntry, mx, my, + CurrentDrawItem, CurrentUnit, g_XorMode); + } + + /* Redraw moved item */ + mx = Screen->m_Curseur.x - StartCursor.x , + my = Screen->m_Curseur.y - StartCursor.y ; + DrawLibraryDrawStruct(panel, DC, CurrentLibEntry, mx , my, + CurrentDrawItem, CurrentUnit, g_XorMode); + ItemPreviousPos = Screen->m_Curseur; +} + + + +/*****************************************************************/ +void MoveLibDrawItemAt(LibEDA_BaseStruct * DrawItem, wxPoint newpos) +/*****************************************************************/ +{ +int mx = newpos.x, my = newpos.y; +wxSize size; + + switch ( DrawItem->m_StructType ) + { + case COMPONENT_ARC_DRAW_TYPE: + { + int dx = mx - ((LibDrawArc*)CurrentDrawItem)->m_Pos.x; + int dy = - my - ((LibDrawArc*)CurrentDrawItem)->m_Pos.y; + ((LibDrawArc*)CurrentDrawItem)->m_Pos.x = mx; + ((LibDrawArc*)CurrentDrawItem)->m_Pos.y = - my; + ((LibDrawArc*)CurrentDrawItem)->m_Start.x += dx; + ((LibDrawArc*)CurrentDrawItem)->m_Start.y += dy; + ((LibDrawArc*)CurrentDrawItem)->m_End.x += dx; + ((LibDrawArc*)CurrentDrawItem)->m_End.y += dy; + break; + } + + case COMPONENT_CIRCLE_DRAW_TYPE: + ((LibDrawCircle*)CurrentDrawItem)->m_Pos.x = mx; + ((LibDrawCircle*)CurrentDrawItem)->m_Pos.y = - my; + break; + + case COMPONENT_RECT_DRAW_TYPE: + size.x = ((LibDrawSquare*)CurrentDrawItem)->m_End.x - + ((LibDrawSquare*)CurrentDrawItem)->m_Start.x; + size.y = ((LibDrawSquare*)CurrentDrawItem)->m_End.y - + ((LibDrawSquare*)CurrentDrawItem)->m_Start.y; + ((LibDrawSquare*)CurrentDrawItem)->m_Start.x = mx; + ((LibDrawSquare*)CurrentDrawItem)->m_Start.y = - my; + ((LibDrawSquare*)CurrentDrawItem)->m_End.x = mx + size.x; + ((LibDrawSquare*)CurrentDrawItem)->m_End.y = - my + size.y; + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + { + int ii , imax = ((LibDrawPolyline*)CurrentDrawItem)->n * 2; + int * ptpoly = ((LibDrawPolyline*)CurrentDrawItem)->PolyList; + int dx = mx - ptpoly[0]; + int dy = - my - ptpoly[1]; + for ( ii = 0; ii < imax; ii += 2) + { + ptpoly[ii] += dx; + ptpoly[ii + 1] += dy; + } + } + break; + + case COMPONENT_LINE_DRAW_TYPE: + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + ((LibDrawText*)CurrentDrawItem)->m_Pos.x = mx; + ((LibDrawText*)CurrentDrawItem)->m_Pos.y = - my; + break; + } +} + +/************************************************************/ +void WinEDA_LibeditFrame::StartMoveDrawSymbol(wxDC * DC) +/************************************************************/ +{ + if(CurrentDrawItem == NULL) return; + + SetCursor(wxCURSOR_HAND); + + CurrentDrawItem->m_Flags |= IS_MOVED; + StartCursor = m_CurrentScreen->m_Curseur; + + switch ( CurrentDrawItem->m_StructType ) + { + case COMPONENT_ARC_DRAW_TYPE: + InitPosition = ((LibDrawArc*)CurrentDrawItem)->m_Pos; + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + InitPosition = ((LibDrawCircle*)CurrentDrawItem)->m_Pos; + break; + + case COMPONENT_RECT_DRAW_TYPE: + InitPosition = ((LibDrawSquare*)CurrentDrawItem)->m_Start; + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + InitPosition.x = * ((LibDrawPolyline*)CurrentDrawItem)->PolyList; + InitPosition.y = * (((LibDrawPolyline*)CurrentDrawItem)->PolyList + 1); + break; + + case COMPONENT_LINE_DRAW_TYPE: + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + InitPosition = ((LibDrawText*)CurrentDrawItem)->m_Pos; + break; + } + + ItemPreviousPos = m_CurrentScreen->m_Curseur; + DrawPanel->ManageCurseur = RedrawWhileMovingCursor; + DrawPanel->ForceCloseManageCurseur = AbortSymbolTraceOn; + DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); +} + + + +/****************************************************************/ +/* Routine de Gestion des evenements souris lors de la creation */ +/* d'un nouvel element type LibraryDrawStruct */ +/****************************************************************/ +static void SymbolDisplayDraw(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +{ +int DrawMode = g_XorMode; +int * ptpoly; +int dx, dy; +BASE_SCREEN * Screen = panel->m_Parent->m_CurrentScreen; +int mx = Screen->m_Curseur.x, + my = Screen->m_Curseur.y; + + GRSetDrawMode(DC, DrawMode); + + if( erase ) + { + if( StateDrawArc == 1 ) + { + int Color = ReturnLayerColor(LAYER_DEVICE); + GRLine(&panel->m_ClipBox, DC, ArcStartX, - ArcStartY, ArcEndX, - ArcEndY, Color); + } + else + { + DrawLibraryDrawStruct(panel, DC, CurrentLibEntry, 0 , 0, + CurrentDrawItem, CurrentUnit, DrawMode); + if(CurrentDrawItem->m_StructType == COMPONENT_ARC_DRAW_TYPE) + { + int Color = ReturnLayerColor(LAYER_DEVICE); + GRDashedLine(&panel->m_ClipBox, DC, ArcStartX, - ArcStartY, + ((LibDrawArc*)CurrentDrawItem)->m_Pos.x, + - ((LibDrawArc*)CurrentDrawItem)->m_Pos.y, + Color); + GRDashedLine(&panel->m_ClipBox, DC, ArcEndX, - ArcEndY, + ((LibDrawArc*)CurrentDrawItem)->m_Pos.x, + - ((LibDrawArc*)CurrentDrawItem)->m_Pos.y, + Color); + } + } + } + + switch ( CurrentDrawItem->m_StructType ) + { + case COMPONENT_ARC_DRAW_TYPE: + if( StateDrawArc == 1) + { + ArcEndX = mx; ArcEndY = - my; + } + + if( StateDrawArc == 2) + { + ComputeArc((LibDrawArc*)CurrentDrawItem, Screen->m_Curseur); + } + ((LibDrawArc*)CurrentDrawItem)->m_Fill = FlSymbol_Fill; + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + dx = ((LibDrawCircle*)CurrentDrawItem)->m_Pos.x - mx; + dy = ((LibDrawCircle*)CurrentDrawItem)->m_Pos.y + my; + ((LibDrawCircle*)CurrentDrawItem)->m_Rayon = (int)sqrt( (dx*dx) + (dy*dy) ); + ((LibDrawCircle*)CurrentDrawItem)->m_Fill = FlSymbol_Fill; + break; + + case COMPONENT_RECT_DRAW_TYPE: + ((LibDrawSquare*)CurrentDrawItem)->m_End.x = mx; + ((LibDrawSquare*)CurrentDrawItem)->m_End.y = - my; + ((LibDrawSquare*)CurrentDrawItem)->m_Fill = FlSymbol_Fill; + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + ptpoly = ((LibDrawPolyline*)CurrentDrawItem)->PolyList; + ptpoly += 2 * (((LibDrawPolyline*)CurrentDrawItem)->n - 1); + ptpoly[0] = mx; + ptpoly[1] = - my; + ((LibDrawPolyline*)CurrentDrawItem)->m_Fill = FlSymbol_Fill; + break; + + case COMPONENT_LINE_DRAW_TYPE: + ((LibDrawSegment*)CurrentDrawItem)->m_End.x = mx; + ((LibDrawSegment*)CurrentDrawItem)->m_End.y = - my; + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: /* Traite par des routines specifiques */ + break; + } + + if( StateDrawArc == 1 ) + { + int Color = ReturnLayerColor(LAYER_DEVICE); + GRLine(&panel->m_ClipBox, DC, ArcStartX, - ArcStartY, ArcEndX, - ArcEndY, Color); + } + else + { + DrawLibraryDrawStruct(panel, DC, CurrentLibEntry, 0 , 0, + CurrentDrawItem, CurrentUnit, DrawMode); + if(CurrentDrawItem->m_StructType == COMPONENT_ARC_DRAW_TYPE) + { + int Color = ReturnLayerColor(LAYER_DEVICE); + GRDashedLine(&panel->m_ClipBox, DC, ArcStartX, - ArcStartY, + ((LibDrawArc*)CurrentDrawItem)->m_Pos.x, + - ((LibDrawArc*)CurrentDrawItem)->m_Pos.y, + Color); + GRDashedLine(&panel->m_ClipBox, DC, ArcEndX, - ArcEndY, + ((LibDrawArc*)CurrentDrawItem)->m_Pos.x, + - ((LibDrawArc*)CurrentDrawItem)->m_Pos.y, + Color); + } + } +} + + +/******************************************************/ +void WinEDA_LibeditFrame::EndDrawGraphicItem(wxDC * DC) +/******************************************************/ +/* Place la structure courante en liste des structures du composant + courant, si elle existe et redessine toujours celle ci + Parametres: (tous globaux) + CurrentDrawItem + CurrentLibEntry +*/ +{ + if(CurrentLibEntry == NULL) return; + if(CurrentDrawItem == NULL) return; + + if( CurrentDrawItem->m_StructType == COMPONENT_ARC_DRAW_TYPE ) + { + if (StateDrawArc == 1 ) /* Trace d'arc en cours: doit etre termine */ + { + DisplayError(this, wxT("Arc in progress.."), 10 ); return; + } + else + { + if ( (CurrentDrawItem->m_Flags & IS_MOVED) == 0 ) + SymbolDisplayDraw(DrawPanel, DC, FALSE); + } + } + + StateDrawArc = 0; + + if ( CurrentDrawItem->m_Flags & IS_NEW ) + { + SaveCopyInUndoList(CurrentLibEntry); + CurrentDrawItem->Pnext = CurrentLibEntry->m_Drawings; + CurrentLibEntry->m_Drawings = CurrentDrawItem; + switch ( CurrentDrawItem->m_StructType ) + { + case COMPONENT_ARC_DRAW_TYPE: + ((LibDrawArc*)CurrentDrawItem)->m_Fill = FlSymbol_Fill; + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + ((LibDrawCircle*)CurrentDrawItem)->m_Fill = FlSymbol_Fill; + break; + + case COMPONENT_RECT_DRAW_TYPE: + ((LibDrawSquare*)CurrentDrawItem)->m_Fill = FlSymbol_Fill; + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + ((LibDrawPolyline*)CurrentDrawItem)->m_Fill = FlSymbol_Fill; + break; + + case COMPONENT_PIN_DRAW_TYPE: + case COMPONENT_LINE_DRAW_TYPE: + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + break; + } + CurrentLibEntry->SortDrawItems(); + } + + if ( m_ID_current_state ) SetCursor(wxCURSOR_PENCIL); + else SetCursor(wxCURSOR_ARROW); + + if ( (CurrentDrawItem->m_Flags & IS_MOVED) ) + { + wxPoint pos; + pos.x = GetScreen()->m_Curseur.x + InitPosition.x - StartCursor.x , + pos.y = GetScreen()->m_Curseur.y - InitPosition.y - StartCursor.y ; + MoveLibDrawItemAt(CurrentDrawItem, pos ); + } + + DrawLibEntry(DrawPanel, DC, CurrentLibEntry, 0, 0, CurrentUnit, + CurrentConvert, GR_DEFAULT_DRAWMODE ); + + CurrentDrawItem->m_Flags = 0; + CurrentDrawItem = NULL; + + m_CurrentScreen->SetModify(); + + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; +} + + + +/***************************************************************/ +static void ComputeArc(LibDrawArc * DrawItem, wxPoint ArcCentre) +/***************************************************************/ +/* routine d'ajustage des parametres de l'arc en cours de trace + calcule le centre, rayon, angles pour que l'arc en cours + passe par les points ArcStartX,Y et ArcEndX,Y avec le centre le plus proche + de la pos souris + Remarque: le centre n'est evidemment pas sur la grille +*/ +{ +int dx, dy; +int cX, cY; /* Coord centre de l'arc */ +int angle; + + cX = ArcCentre.x; cY = ArcCentre.y; + + cY = -cY; /* Attention a l'orientation de l'axe Y */ + + /* calcul de cX et cY pour que l'arc passe par ArcStartX,Y et ArcEndX,Y */ + dx = ArcEndX - ArcStartX; dy = ArcEndY - ArcStartY; + cX -= ArcStartX; cY -= ArcStartY; + angle = (int)(atan2(dy, dx) *1800 /M_PI); + RotatePoint( &dx, &dy, angle); /* Le segment dx, dy est horizontal */ + /* -> dx = longueur, dy = 0 */ + RotatePoint( &cX, &cY, angle); + cX = dx / 2; /* cX, cY est sur la mediane du segment 0,0 a dx,0 */ + + RotatePoint( &cX, &cY, -angle); + cX += ArcStartX; cY += ArcStartY; + + DrawItem->m_Pos.x = cX; DrawItem->m_Pos.y = cY; + + dx = ArcStartX - DrawItem->m_Pos.x; + dy = ArcStartY - DrawItem->m_Pos.y; + + DrawItem->m_Rayon = (int)sqrt( (dx*dx) + (dy*dy) ); + + DrawItem->t1 = (int)(atan2(dy, dx) *1800 /M_PI); + + dx = ArcEndX - DrawItem->m_Pos.x; + dy = ArcEndY - DrawItem->m_Pos.y; + + DrawItem->t2 = (int)(atan2(dy, dx) *1800 /M_PI); + + DrawItem->m_Start.x = ArcStartX; + DrawItem->m_Start.y = ArcStartY; + DrawItem->m_End.x = ArcEndX; + DrawItem->m_End.y = ArcEndY; + + NORMALIZE_ANGLE(DrawItem->t1); + NORMALIZE_ANGLE(DrawItem->t2); // angles = 0 .. 3600 + + // limitation val abs a < 1800 (1/2 cercle) pour eviter Pbs d'affichage en miroir + // car en trace on suppose que l'arc fait moins de 180 deg pour trouver + // son orientation apres rot, miroir... + if ( (DrawItem->t2 - DrawItem->t1) > 1800 ) DrawItem->t2 -= 3600; + else if ( (DrawItem->t2 - DrawItem->t1) <= -1800 ) DrawItem->t2 += 3600; + +wxString msg; + angle = DrawItem->t2 - DrawItem->t1; + msg.Printf(_("Arc %.1f deg"), (float)angle/10 ); + EDA_Appl->LibeditFrame->PrintMsg(msg); + + while ( (DrawItem->t2 - DrawItem->t1) >= 1800 ) + { + DrawItem->t2--; + DrawItem->t1++; + } + while ( (DrawItem->t1 - DrawItem->t2) >= 1800 ) + { + DrawItem->t2++; + DrawItem->t1--; + } + + NORMALIZE_ANGLE(DrawItem->t1); + NORMALIZE_ANGLE(DrawItem->t2); + +} + +/***************************************************/ +void WinEDA_LibeditFrame::DeleteDrawPoly(wxDC * DC) +/**************************************************/ +/* Used for deleting last entered segment while creating a Polyline +*/ +{ + + if ( CurrentDrawItem == NULL ) return; + if( CurrentDrawItem->m_StructType != COMPONENT_POLYLINE_DRAW_TYPE ) + return; + +int * ptpoly; +LibDrawPolyline * Poly = (LibDrawPolyline*)CurrentDrawItem; + + DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, 0 , 0, + CurrentDrawItem, CurrentUnit, g_XorMode); + + while( Poly->n > 2 ) // First segment is kept, only its end point is changed + { + Poly->n --; + ptpoly = Poly->PolyList + (2 * (Poly->n - 1)); + if ( (ptpoly[0] != m_CurrentScreen->m_Curseur.x) || + (ptpoly[1] != - m_CurrentScreen->m_Curseur.y) ) + { + ptpoly[0] = m_CurrentScreen->m_Curseur.x; + ptpoly[1] = - m_CurrentScreen->m_Curseur.y; + break; + } + } + + int allocsize = 2 * sizeof(int) * Poly->n; + Poly->PolyList = (int*)realloc(Poly->PolyList, allocsize ); + + DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, 0 , 0, + CurrentDrawItem, CurrentUnit, g_XorMode); +} + diff --git a/eeschema/symbedit.cpp b/eeschema/symbedit.cpp new file mode 100644 index 0000000000..dc01affd39 --- /dev/null +++ b/eeschema/symbedit.cpp @@ -0,0 +1,472 @@ + /*************************************************/ + /* Routines d'edition de symboles de composants */ + /*************************************************/ + + /* fichier symbedit.cpp */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + + +/* Routines locales */ +static bool CompareSymbols(LibEDA_BaseStruct *DEntryRef, + LibEDA_BaseStruct *DEntryCompare); + +/* Variables locales */ + + + + +/***************************************************/ +void WinEDA_LibeditFrame::LoadOneSymbol(wxDC * DC) +/***************************************************/ +/* Cette routine lit un fichier type librairie symbole et +ajoute au symbole courant les elements de trace du nouveau symbole graphique + Si il n'y a pas de symbole courant, le nouveau symbole devient le + symbole courant +*/ +{ +int NumOfParts; +PriorQue *Entries; +EDA_LibComponentStruct *LibEntry = NULL; +LibEDA_BaseStruct *DrawEntry; +wxString FullFileName, mask; +FILE * ImportFile; +wxString msg; + + if(CurrentDrawItem) return; + if( CurrentLibEntry == NULL) return; + + DrawPanel->m_IgnoreMouseEvents = TRUE; + + mask = wxT("*") + g_SymbolExtBuffer; + FullFileName = EDA_FileSelector( _("Import symbol drawings:"), + g_RealLibDirBuffer, /* Chemin par defaut */ + wxEmptyString, /* nom fichier par defaut */ + g_SymbolExtBuffer, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + 0, + TRUE + ); + + GetScreen()->m_Curseur = wxPoint(0,0); + DrawPanel->MouseToCursorSchema(); + DrawPanel->m_IgnoreMouseEvents = FALSE; + + if ( FullFileName.IsEmpty() ) return; + + + /* Chargement de 1 symbole */ + ImportFile = wxFopen(FullFileName, wxT("rt")); + if (ImportFile == NULL) + { + msg.Printf( _("Failed to open Symbol File <%s>"), FullFileName.GetData()); + DisplayError(this, msg, 20); + return; + } + + + Entries = LoadLibraryAux(this, NULL, ImportFile, &NumOfParts); + fclose(ImportFile); + + if( Entries == NULL) return; + + if(NumOfParts > 1 ) + DisplayError(this, _("Warning: more than 1 part in Symbol File"), 20); + + LibEntry = (EDA_LibComponentStruct *)PQFirst(&Entries,FALSE); + + if(LibEntry == NULL ) + DisplayError(this, _("Symbol File is void"), 20); + + else /* Ajout des elements graphiques */ + { + DrawEntry = LibEntry->m_Drawings; + while(DrawEntry) + { + if(DrawEntry->m_Unit) DrawEntry->m_Unit = CurrentUnit; + if(DrawEntry->m_Convert) DrawEntry->m_Convert = CurrentConvert; + DrawEntry->m_Flags = IS_NEW; + DrawEntry->m_Selected = IS_SELECTED; + + if(DrawEntry->Pnext == NULL) + { /* Fin de liste trouvee */ + DrawEntry->Pnext = CurrentLibEntry->m_Drawings; + CurrentLibEntry->m_Drawings = LibEntry->m_Drawings; + LibEntry->m_Drawings = NULL; + break; + } + DrawEntry = DrawEntry->Next(); + } + SuppressDuplicateDrawItem(CurrentLibEntry); + m_CurrentScreen->SetModify(); + // Move (and place ) the new draw items: + HandleBlockBegin(DC, -1, GetScreen()->m_Curseur); + HandleBlockEnd(DC); + RedrawActiveWindow( DC,TRUE); + } + + PQFreeFunc(Entries, (void(*)(void*))FreeLibraryEntry); +} + + +/********************************************/ +void WinEDA_LibeditFrame::SaveOneSymbol(void) +/********************************************/ +/* Routine de sauvegarde du symbole courant edite + Le format est identique aux librairies standards + Les pins invisibles et les elements + non relativ a la forme courante ne sont pas sauves +*/ +{ +EDA_LibComponentStruct *LibEntry = CurrentLibEntry; +int Unit = CurrentUnit, convert = CurrentConvert; +int SymbUnit, SymbConvert; +LibEDA_BaseStruct *DrawEntry; +wxString FullFileName, mask; +wxString msg; +FILE * ExportFile; + + if( LibEntry->m_Drawings == NULL ) return; + + /* Creation du fichier symbole */ + mask = wxT("*") + g_SymbolExtBuffer; + FullFileName = EDA_FileSelector( _("Export symbol drawings:"), + g_RealLibDirBuffer, /* Chemin par defaut */ + wxEmptyString, /* nom fichier par defaut */ + g_SymbolExtBuffer, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + TRUE + ); + if ( FullFileName.IsEmpty() ) return; + + ExportFile = wxFopen(FullFileName, wxT("wt") ); + if ( ExportFile == NULL ) + { + msg.Printf(_("Unable to create <%s>"), FullFileName.GetData()); + DisplayError(this, msg); + return; + } + + msg.Printf(_("Save Symbol in [%s]"), FullFileName.GetData()); + Affiche_Message(msg); + + /* Creation de l'entete de la librairie */ + char Line[256]; + fprintf(ExportFile,"%s %d.%d %s Date: %s\n",LIBFILE_IDENT, + LIB_VERSION_MAJOR, LIB_VERSION_MINOR, + "SYMBOL",DateAndTime(Line)); + + /* Creation du commentaire donnant le nom du composant */ + fprintf(ExportFile,"# SYMBOL %s\n#\n", + (const char*) LibEntry->m_Name.m_Text.GetData()); + + /* Generation des lignes utiles */ + fprintf(ExportFile,"DEF %s", (const char*)LibEntry->m_Name.m_Text.GetData()); + if( ! LibEntry->m_Prefix.m_Text.IsEmpty()) + fprintf(ExportFile," %s", (const char*)LibEntry->m_Prefix.m_Text.GetData()); + else fprintf(ExportFile," ~"); + + fprintf(ExportFile," %d %d %c %c %d %d %c\n", + 0, /* unused */ + LibEntry->m_TextInside, + LibEntry->m_DrawPinNum ? 'Y' : 'N', + LibEntry->m_DrawPinName ? 'Y' : 'N', + 1, 0 /* unused */, 'N'); + + /* Position / orientation / visibilite des champs */ + LibEntry->m_Prefix.WriteDescr( ExportFile ); + LibEntry->m_Name.WriteDescr( ExportFile ); + + DrawEntry = LibEntry->m_Drawings; + if(DrawEntry) + { + fprintf(ExportFile,"DRAW\n"); + for( ; DrawEntry != NULL ; DrawEntry = DrawEntry->Next()) + { + /* Elimination des elements non relatifs a l'unite */ + if( Unit && DrawEntry->m_Unit && (DrawEntry->m_Unit != Unit) ) + continue; + if( convert && DrawEntry->m_Convert && (DrawEntry->m_Convert != convert) ) + continue; + + /* .Unit , . Convert est laisse a 0 ou mis a 1 */ + SymbUnit = DrawEntry->m_Unit; if ( SymbUnit > 1) SymbUnit = 1; + SymbConvert = DrawEntry->m_Convert; + if ( SymbConvert > 1) SymbConvert = 1; + switch( DrawEntry->m_StructType) + { + case COMPONENT_ARC_DRAW_TYPE: + #define DRAWSTRUCT ((LibDrawArc *) DrawEntry) + DRAWSTRUCT->WriteDescr( ExportFile ); + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + #undef DRAWSTRUCT + #define DRAWSTRUCT ((LibDrawCircle *) DrawEntry) + DRAWSTRUCT->WriteDescr( ExportFile ); + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + #undef DRAWSTRUCT + #define DRAWSTRUCT ((LibDrawText *) DrawEntry) + DRAWSTRUCT->WriteDescr( ExportFile ); + break; + + case COMPONENT_RECT_DRAW_TYPE: + #undef DRAWSTRUCT + #define DRAWSTRUCT ((LibDrawSquare *) DrawEntry) + DRAWSTRUCT->WriteDescr( ExportFile ); + break; + + case COMPONENT_PIN_DRAW_TYPE: + #undef DRAWSTRUCT + #define DRAWSTRUCT ((LibDrawPin *) DrawEntry) + if(DRAWSTRUCT->m_Attributs & PINNOTDRAW) break; + DRAWSTRUCT->WriteDescr( ExportFile ); + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + #undef DRAWSTRUCT + #define DRAWSTRUCT ((LibDrawPolyline *) DrawEntry) + DRAWSTRUCT->WriteDescr( ExportFile ); + break; + } + } + fprintf(ExportFile,"ENDDRAW\n"); + } + fprintf(ExportFile,"ENDDEF\n"); + fclose(ExportFile); +} + + + +/*****************************************************************/ +void SuppressDuplicateDrawItem(EDA_LibComponentStruct * LibEntry) +/*****************************************************************/ +/* Routine de suppression des elements de trace dupliques, situation +frequente lorsque l'on charge des symboles predessines plusieurs fois +pour definir un composant +*/ +{ +LibEDA_BaseStruct *DEntryRef, *DEntryCompare; +bool deleted; +wxDC * DC = NULL; + + DEntryRef = LibEntry->m_Drawings; + while( DEntryRef) + { + if( DEntryRef->Pnext == NULL ) return; + DEntryCompare = DEntryRef->Next(); + if( DEntryCompare == NULL ) return; + deleted = 0; + while( DEntryCompare ) + { + if( CompareSymbols(DEntryRef,DEntryCompare) == TRUE) + { + DeleteOneLibraryDrawStruct(NULL, DC, LibEntry,DEntryRef, 1); + deleted = TRUE; + break; + } + DEntryCompare = DEntryCompare->Next(); + } + if ( ! deleted ) DEntryRef = DEntryRef->Next(); + else DEntryRef = LibEntry->m_Drawings; + } +} + + + +/********************************************************************/ +static bool CompareSymbols(LibEDA_BaseStruct *DEntryRef, + LibEDA_BaseStruct *DEntryCompare) + /********************************************************************/ +/* Routine de comparaison de 2 DrawEntryStruct. + retourne FALSE si differentes + TRUE si egales +*/ +{ +int ii; +int * ptref, *ptcomp; + + /* Comparaison des proprietes generales */ + if( DEntryRef->m_StructType != DEntryCompare->m_StructType) return(FALSE); + if( DEntryRef->m_Unit != DEntryCompare->m_Unit) return(FALSE); + if( DEntryRef->m_Convert != DEntryCompare->m_Convert) return(FALSE); + + switch( DEntryRef->m_StructType) + { + case COMPONENT_ARC_DRAW_TYPE: + #undef REFSTRUCT + #undef CMPSTRUCT + #define REFSTRUCT ((LibDrawArc *) DEntryRef) + #define CMPSTRUCT ((LibDrawArc *) DEntryCompare) + if( REFSTRUCT->m_Pos.x != CMPSTRUCT->m_Pos.x) return(FALSE); + if( REFSTRUCT->m_Pos.y != CMPSTRUCT->m_Pos.y) return(FALSE); + if( REFSTRUCT->t1 != CMPSTRUCT->t1) return(FALSE); + if( REFSTRUCT->t2 != CMPSTRUCT->t2) return(FALSE); + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + #undef REFSTRUCT + #undef CMPSTRUCT + #define REFSTRUCT ((LibDrawCircle *) DEntryRef) + #define CMPSTRUCT ((LibDrawCircle *) DEntryCompare) + if( REFSTRUCT->m_Pos.x != CMPSTRUCT->m_Pos.x) return(FALSE); + if( REFSTRUCT->m_Pos.y != CMPSTRUCT->m_Pos.y) return(FALSE); + if( REFSTRUCT->m_Rayon != CMPSTRUCT->m_Rayon) return(FALSE); + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + #undef REFSTRUCT + #undef CMPSTRUCT + #define REFSTRUCT ((LibDrawText *) DEntryRef) + #define CMPSTRUCT ((LibDrawText *) DEntryCompare) + if( REFSTRUCT->m_Pos.x != CMPSTRUCT->m_Pos.x) return(FALSE); + if( REFSTRUCT->m_Pos.y != CMPSTRUCT->m_Pos.y) return(FALSE); + if( REFSTRUCT->m_Size != CMPSTRUCT->m_Size) return(FALSE); + if( REFSTRUCT->m_Text != CMPSTRUCT->m_Text ) + return(FALSE); + break; + + case COMPONENT_RECT_DRAW_TYPE: + #undef REFSTRUCT + #undef CMPSTRUCT + #define REFSTRUCT ((LibDrawSquare *) DEntryRef) + #define CMPSTRUCT ((LibDrawSquare *) DEntryCompare) + if( REFSTRUCT->m_Start.x != CMPSTRUCT->m_Start.x) return(FALSE); + if( REFSTRUCT->m_Start.y != CMPSTRUCT->m_Start.y) return(FALSE); + if( REFSTRUCT->m_End.x != CMPSTRUCT->m_End.x) return(FALSE); + if( REFSTRUCT->m_End.y != CMPSTRUCT->m_End.y) return(FALSE); + break; + + case COMPONENT_PIN_DRAW_TYPE: + #undef REFSTRUCT + #undef CMPSTRUCT + #define REFSTRUCT ((LibDrawPin *) DEntryRef) + #define CMPSTRUCT ((LibDrawPin *) DEntryCompare) + if( REFSTRUCT->m_Pos.x != CMPSTRUCT->m_Pos.x) return(FALSE); + if( REFSTRUCT->m_Pos.y != CMPSTRUCT->m_Pos.y) return(FALSE); + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + #undef REFSTRUCT + #undef CMPSTRUCT + #define REFSTRUCT ((LibDrawPolyline *) DEntryRef) + #define CMPSTRUCT ((LibDrawPolyline *) DEntryCompare) + if( REFSTRUCT->n != CMPSTRUCT->n) return(FALSE); + ptref = REFSTRUCT->PolyList; + ptcomp = CMPSTRUCT->PolyList; + for( ii = 2 * REFSTRUCT->n ; ii > 0; ii-- ) + { + if( *ptref != *ptcomp) return(FALSE); + ptref++; ptcomp++; + } + break; + } + return(TRUE); +} + + + +/***************************************************************************/ +/* Routine de placement du point d'ancrage ( reference des coordonnes pour */ +/* le trace) du composant courant */ +/* Toutes les coord apparaissant dans les structures sont modifiees */ +/* pour repositionner le point repere par le curseur souris au point */ +/* d'ancrage ( coord 0,0 ). */ +/***************************************************************************/ + +void WinEDA_LibeditFrame::PlaceAncre(void) +{ +int ii, *ptsegm; +int dx, dy; /* Offsets de deplacement */ +EDA_LibComponentStruct * LibEntry; +LibEDA_BaseStruct * DrawEntry; + + dx = - m_CurrentScreen->m_Curseur.x; + dy = m_CurrentScreen->m_Curseur.y; + + LibEntry = CurrentLibEntry; + if( LibEntry == NULL ) return; + + m_CurrentScreen->SetModify(); + + LibEntry->m_Name.m_Pos.x += dx; LibEntry->m_Name.m_Pos.y += dy; + LibEntry->m_Prefix.m_Pos.x += dx; LibEntry->m_Prefix.m_Pos.y += dy; + + DrawEntry = LibEntry->m_Drawings; + while(DrawEntry) + { + switch(DrawEntry->m_StructType) + { + case COMPONENT_ARC_DRAW_TYPE: + #undef STRUCT + #define STRUCT ((LibDrawArc *) DrawEntry) + STRUCT->m_Pos.x += dx; + STRUCT->m_Pos.y += dy; + STRUCT->m_Start.x += dx; + STRUCT->m_Start.y += dy; + STRUCT->m_End.x += dx; + STRUCT->m_End.y += dy; + break; + + case COMPONENT_CIRCLE_DRAW_TYPE: + #undef STRUCT + #define STRUCT ((LibDrawCircle *) DrawEntry) + STRUCT->m_Pos.x += dx; + STRUCT->m_Pos.y += dy; + break; + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + #undef STRUCT + #define STRUCT ((LibDrawText *) DrawEntry) + STRUCT->m_Pos.x += dx; + STRUCT->m_Pos.y += dy; + break; + + case COMPONENT_RECT_DRAW_TYPE: + #undef STRUCT + #define STRUCT ((LibDrawSquare *) DrawEntry) + STRUCT->m_Start.x += dx; + STRUCT->m_Start.y += dy; + STRUCT->m_End.x += dx; + STRUCT->m_End.y += dy; + break; + + case COMPONENT_PIN_DRAW_TYPE: + #undef STRUCT + #define STRUCT ((LibDrawPin *) DrawEntry) + STRUCT->m_Pos.x += dx; + STRUCT->m_Pos.y += dy; + break; + + case COMPONENT_POLYLINE_DRAW_TYPE: + #undef STRUCT + #define STRUCT ((LibDrawPolyline *) DrawEntry) + ptsegm = STRUCT->PolyList; + for( ii = STRUCT->n ; ii > 0; ii-- ) + { + *ptsegm += dx; ptsegm++; + *ptsegm += dy;ptsegm++; + } + break; + } + DrawEntry = DrawEntry->Next(); + } + /* Reaffichage du symbole */ + m_CurrentScreen->m_Curseur.x = m_CurrentScreen->m_Curseur.y = 0; + Recadre_Trace(TRUE); + m_CurrentScreen->SetRefreshReq(); +} + diff --git a/eeschema/symbtext.cpp b/eeschema/symbtext.cpp new file mode 100644 index 0000000000..8ed7a1dc83 --- /dev/null +++ b/eeschema/symbtext.cpp @@ -0,0 +1,341 @@ + /**********************************************/ + /* EESchema - symbtext.cpp for Library Editor */ + /**********************************************/ + +/* Menu et routines de creation, modification, suppression de textes + du type symbole + (textes autres que Fields) +*/ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "symbtext.h" +#endif + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "symbtext.h" + +#include "protos.h" + + + +/*! + * WinEDA_bodytext_PropertiesFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_bodytext_PropertiesFrame, wxDialog ) + +/*! + * WinEDA_bodytext_PropertiesFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_bodytext_PropertiesFrame, wxDialog ) + +////@begin WinEDA_bodytext_PropertiesFrame event table entries + EVT_BUTTON( wxID_OK, WinEDA_bodytext_PropertiesFrame::OnOkClick ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_bodytext_PropertiesFrame::OnCancelClick ) + +////@end WinEDA_bodytext_PropertiesFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_bodytext_PropertiesFrame constructors + */ + +WinEDA_bodytext_PropertiesFrame::WinEDA_bodytext_PropertiesFrame( ) +{ +} + +WinEDA_bodytext_PropertiesFrame::WinEDA_bodytext_PropertiesFrame( WinEDA_LibeditFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +LibDrawText * CurrentText = (LibDrawText *) CurrentDrawItem; +wxString msg; + + m_Parent = parent; + Create(parent, id, caption, pos, size, style); + + if ( CurrentText ) + { + msg = ReturnStringFromValue(g_UnitMetric, CurrentText->m_Size.x, m_Parent->m_InternalUnits); + m_Size->SetValue(msg); + m_NewText->SetValue(CurrentText->m_Text); + if ( CurrentText->m_Unit == 0 ) m_CommonUnit->SetValue(TRUE); + if ( CurrentText->m_Convert == 0 ) m_CommonConvert->SetValue(TRUE); + if ( CurrentText->m_Horiz == TEXT_ORIENT_VERT ) m_Orient->SetValue(TRUE); + } + else + { + msg = ReturnStringFromValue(g_UnitMetric, g_LastTextSize, m_Parent->m_InternalUnits); + m_Size->SetValue(msg); + if ( ! g_FlDrawSpecificUnit ) m_CommonUnit->SetValue(TRUE); + if ( ! g_FlDrawSpecificConvert ) m_CommonConvert->SetValue(TRUE); + if ( g_LastTextOrient == TEXT_ORIENT_VERT ) m_Orient->SetValue(TRUE); + } + + msg = m_SizeText->GetLabel() + ReturnUnitSymbol(); + m_SizeText->SetLabel(msg); +} + +/*! + * WinEDA_bodytext_PropertiesFrame creator + */ + +bool WinEDA_bodytext_PropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_bodytext_PropertiesFrame member initialisation + m_NewText = NULL; + m_SizeText = NULL; + m_Size = NULL; + m_CommonUnit = NULL; + m_CommonConvert = NULL; + m_Orient = NULL; +////@end WinEDA_bodytext_PropertiesFrame member initialisation + +////@begin WinEDA_bodytext_PropertiesFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_bodytext_PropertiesFrame creation + return true; +} + +/*! + * Control creation for WinEDA_bodytext_PropertiesFrame + */ + +void WinEDA_bodytext_PropertiesFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_bodytext_PropertiesFrame content construction + // Generated by DialogBlocks, 12/02/2006 15:02:01 (unregistered) + + WinEDA_bodytext_PropertiesFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemDialog1, wxID_ANY, _(" Text : ")); + wxStaticBoxSizer* itemStaticBoxSizer3 = new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxVERTICAL); + itemBoxSizer2->Add(itemStaticBoxSizer3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL); + itemStaticBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer4->Add(itemBoxSizer5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, _("Name:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_NewText = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(250, -1), 0 ); + itemBoxSizer5->Add(m_NewText, 0, wxALIGN_LEFT|wxALL, 5); + + wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer4->Add(itemBoxSizer8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + m_SizeText = new wxStaticText( itemDialog1, wxID_STATIC, _("Size:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer8->Add(m_SizeText, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_Size = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer8->Add(m_Size, 0, wxALIGN_LEFT|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer11Static = new wxStaticBox(itemDialog1, wxID_ANY, _(" Text Options : ")); + wxStaticBoxSizer* itemStaticBoxSizer11 = new wxStaticBoxSizer(itemStaticBoxSizer11Static, wxVERTICAL); + itemStaticBoxSizer3->Add(itemStaticBoxSizer11, 0, wxALIGN_LEFT|wxALL, 5); + + m_CommonUnit = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Common to Units"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_CommonUnit->SetValue(false); + itemStaticBoxSizer11->Add(m_CommonUnit, 0, wxALIGN_LEFT|wxALL, 5); + + m_CommonConvert = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Common to convert"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_CommonConvert->SetValue(false); + itemStaticBoxSizer11->Add(m_CommonConvert, 0, wxALIGN_LEFT|wxALL, 5); + + m_Orient = new wxCheckBox( itemDialog1, ID_CHECKBOX2, _("Vertical"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_Orient->SetValue(false); + itemStaticBoxSizer11->Add(m_Orient, 0, wxALIGN_LEFT|wxALL, 5); + + wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton16 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton16->SetForegroundColour(wxColour(206, 0, 0)); + itemBoxSizer15->Add(itemButton16, 0, wxGROW|wxALL, 5); + + wxButton* itemButton17 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton17->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer15->Add(itemButton17, 0, wxGROW|wxALL, 5); + +////@end WinEDA_bodytext_PropertiesFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_bodytext_PropertiesFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_bodytext_PropertiesFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_bodytext_PropertiesFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_bodytext_PropertiesFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_bodytext_PropertiesFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_bodytext_PropertiesFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_bodytext_PropertiesFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_bodytext_PropertiesFrame::OnOkClick( wxCommandEvent& event ) +{ + bodytext_PropertiesAccept(event); + Close(); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_bodytext_PropertiesFrame::OnCancelClick( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_bodytext_PropertiesFrame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_bodytext_PropertiesFrame. +} + + +/***************************************************************************/ +void WinEDA_bodytext_PropertiesFrame::bodytext_PropertiesAccept(wxCommandEvent& event) +/***************************************************************************/ +/* Met a jour les differents parametres pour le composant en cours d'edition +*/ +{ +LibDrawText* Text = (LibDrawText*) CurrentDrawItem; +wxString Line; + + Line = m_NewText->GetValue(); + g_LastTextOrient = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; + wxString msg = m_Size->GetValue(); + g_LastTextSize = ReturnValueFromString(g_UnitMetric, msg, m_Parent->m_InternalUnits); + g_FlDrawSpecificConvert = m_CommonConvert->GetValue() ? FALSE : TRUE; + g_FlDrawSpecificUnit = m_CommonUnit->GetValue() ? FALSE : TRUE; + + if ( Text ) // Set Pin Name & Num + { + if ( ! Line.IsEmpty() ) Text->m_Text = Line; + else Text->m_Text = wxT("[null]"); // **** A REVOIR *** + Text->m_Size.x = Text->m_Size.y = g_LastTextSize; + Text->m_Horiz = g_LastTextOrient; + if( g_FlDrawSpecificUnit ) Text->m_Unit = CurrentUnit; + else Text->m_Unit = 0; + if( g_FlDrawSpecificConvert ) Text->m_Convert = CurrentConvert; + else Text->m_Convert = 0; + } + Close(); + + if ( CurrentDrawItem ) + CurrentDrawItem->Display_Infos_DrawEntry(m_Parent); +} + + + +/*******************************************************/ +void WinEDA_LibeditFrame::EditSymbolText(wxDC * DC, + LibEDA_BaseStruct * DrawItem) +/*******************************************************/ +{ +int DrawMode = g_XorMode; + + if ( DrawItem == NULL ) return; + if ( DrawItem->m_StructType != COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ) return; + + /* Effacement ancien texte */ + if( ((LibDrawText*)DrawItem)->m_Text && DC) + DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, 0 , 0, + DrawItem, CurrentUnit, DrawMode); + + + WinEDA_bodytext_PropertiesFrame * frame = + new WinEDA_bodytext_PropertiesFrame(this); + frame->ShowModal(); frame->Destroy(); + + m_CurrentScreen->SetModify(); + + /* Affichage nouveau texte */ + if( ((LibDrawText*)DrawItem)->m_Text && DC) + { + if ( (DrawItem->m_Flags & IS_MOVED) == 0 ) + DrawMode = GR_DEFAULT_DRAWMODE; + DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, 0 , 0, + DrawItem, CurrentUnit, DrawMode); + } +} + + +/****************************************************/ +void WinEDA_LibeditFrame::RotateSymbolText(wxDC * DC) +/****************************************************/ +/* + 90 deg Graphic text Rotation . +*/ +{ +LibDrawText * DrawItem = (LibDrawText *) CurrentDrawItem; + + if(DrawItem == NULL) return; + + /* Erase drawing (can be within a move command) */ + if ( DrawPanel->ManageCurseur == NULL) + DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, 0 , 0, + DrawItem, CurrentUnit, g_XorMode); + else DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + + if( DrawItem->m_Horiz == TEXT_ORIENT_HORIZ) + DrawItem->m_Horiz = TEXT_ORIENT_VERT; + else DrawItem->m_Horiz = TEXT_ORIENT_HORIZ; + + m_CurrentScreen->SetModify(); + + /* Redraw item with new orient */ + if ( DrawPanel->ManageCurseur == NULL) + DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, 0 , 0, + DrawItem, CurrentUnit, GR_DEFAULT_DRAWMODE); + else DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + +} + + diff --git a/eeschema/symbtext.h b/eeschema/symbtext.h new file mode 100644 index 0000000000..6d5cc825d9 --- /dev/null +++ b/eeschema/symbtext.h @@ -0,0 +1,117 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: symbtext.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 12/02/2006 14:04:59 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 12/02/2006 14:04:59 + +#ifndef _SYMBTEXT_H_ +#define _SYMBTEXT_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "symbtext.h" +#endif + +/*! + * Includes + */ + +////@begin includes +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_TITLE _("Graphic text properties") +#define SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_POSITION wxDefaultPosition +#define ID_TEXTCTRL 10001 +#define ID_TEXTCTRL1 10002 +#define ID_CHECKBOX 10003 +#define ID_CHECKBOX1 10004 +#define ID_CHECKBOX2 10005 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_bodytext_PropertiesFrame class declaration + */ + +class WinEDA_bodytext_PropertiesFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_bodytext_PropertiesFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_bodytext_PropertiesFrame( ); + WinEDA_bodytext_PropertiesFrame( WinEDA_LibeditFrame* parent, wxWindowID id = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_bodytext_PropertiesFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + +////@end WinEDA_bodytext_PropertiesFrame event handler declarations + +////@begin WinEDA_bodytext_PropertiesFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_bodytext_PropertiesFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + void bodytext_PropertiesAccept(wxCommandEvent& event); + +////@begin WinEDA_bodytext_PropertiesFrame member variables + wxTextCtrl* m_NewText; + wxStaticText* m_SizeText; + wxTextCtrl* m_Size; + wxCheckBox* m_CommonUnit; + wxCheckBox* m_CommonConvert; + wxCheckBox* m_Orient; +////@end WinEDA_bodytext_PropertiesFrame member variables + + WinEDA_LibeditFrame * m_Parent; +}; + +#endif + // _SYMBTEXT_H_ diff --git a/eeschema/symbtext.pjd b/eeschema/symbtext.pjd new file mode 100644 index 0000000000..7d6a7d1de0 --- /dev/null +++ b/eeschema/symbtext.pjd @@ -0,0 +1,984 @@ + + +
+ 0 + "" + "" + "" + "" + 24 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "Graphic text properties" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "12/5/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "ID_DIALOG" + 10000 + "WinEDA_bodytext_PropertiesFrame" + "wxDialog" + "wxDialog" + "symbtext.cpp" + "symbtext.h" + "" + "Graphic text properties" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Horizontal" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "12/5/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + " Text : " + "" + "" + "" + 0 + 1 + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "12/5/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "12/5/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "12/5/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Name:" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "12/5/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL" + 10001 + "wxTextCtrl" + "m_NewText" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 250 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "12/5/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "12/5/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_SizeText" + "Size:" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL1" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "12/5/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL1" + 10002 + "wxTextCtrl" + "m_Size" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "12/5/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + " Text Options : " + "" + "" + "" + 0 + 1 + "Vertical" + "" + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxCheckBox: ID_CHECKBOX" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "12/5/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX" + 10003 + "wxCheckBox" + "m_CommonUnit" + "Common to Units" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX1" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "12/5/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX1" + 10004 + "wxCheckBox" + "m_CommonConvert" + "Common to convert" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX2" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "12/5/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX2" + 10005 + "wxCheckBox" + "m_Orient" + "Vertical" + 0 + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "12/5/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: wxID_OK" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "12/5/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnOkClick" + "wxID_OK" + 5100 + "wxButton" + "" + "&OK" + 0 + "" + "" + "" + "CE0000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_CANCEL" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "12/5/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCancelClick" + "wxID_CANCEL" + 5101 + "wxButton" + "" + "&Cancel" + 0 + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "symbtext.rc" + "source-editor-document" + "symbtext.rc" + "source-editor" + 0 + 0 + 1 + 0 + "12/5/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/eeschema/symbtext.rc b/eeschema/symbtext.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/eeschema/symbtext.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/eeschema/tool_lib.cpp b/eeschema/tool_lib.cpp new file mode 100644 index 0000000000..0ddb388089 --- /dev/null +++ b/eeschema/tool_lib.cpp @@ -0,0 +1,274 @@ + /********************************************/ + /* tool_lib.cpp: construction des toolbars */ + /********************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +#define BITMAP wxBitmap + +#ifdef __UNIX__ +#define LISTBOX_WIDTH 140 +#else +#define LISTBOX_WIDTH 120 +#endif + +// ---------------------------------------------------------------------------- +// resources +// ---------------------------------------------------------------------------- + +// USE_XPM_BITMAPS +#include "bitmaps.h" +#include "part_properties.xpm" +#include "pin2pin.xpm" +#include "new_component.xpm" + +#include "id.h" + + +/****************************************************/ +void WinEDA_LibeditFrame::ReCreateVToolbar(void) +/****************************************************/ +{ + if( m_VToolBar == NULL ) + { + m_VToolBar = new WinEDA_Toolbar(TOOLBAR_TOOL, this, ID_V_TOOLBAR, FALSE); + + // Set up toolbar + m_VToolBar->AddTool(ID_NO_SELECT_BUTT, wxEmptyString, + BITMAP(cursor_xpm), + _("deselect current tool"), wxITEM_CHECK ); + m_VToolBar->ToggleTool(ID_NO_SELECT_BUTT, TRUE); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_LIBEDIT_PIN_BUTT, wxEmptyString, + BITMAP(pin_xpm), + _("Add Pins"), wxITEM_CHECK ); + + m_VToolBar->AddTool(ID_LIBEDIT_BODY_TEXT_BUTT, wxEmptyString, + BITMAP(add_text_xpm), + _("Add graphic text"), wxITEM_CHECK ); + + m_VToolBar->AddTool(ID_LIBEDIT_BODY_RECT_BUTT, wxEmptyString, + BITMAP(add_rectangle_xpm), + _("Add rectangles"), wxITEM_CHECK ); + + m_VToolBar->AddTool(ID_LIBEDIT_BODY_CIRCLE_BUTT, wxEmptyString, + BITMAP(add_circle_xpm), + _("Add circles"), wxITEM_CHECK ); + + m_VToolBar->AddTool(ID_LIBEDIT_BODY_ARC_BUTT, wxEmptyString, + BITMAP(add_arc_xpm), + _("Add arcs"), wxITEM_CHECK ); + + m_VToolBar->AddTool(ID_LIBEDIT_BODY_LINE_BUTT, wxEmptyString, + BITMAP(add_polygon_xpm), + _( "Add lines and polygons"), wxITEM_CHECK ); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_LIBEDIT_ANCHOR_ITEM_BUTT, wxEmptyString, + BITMAP(anchor_xpm), + _("Move part anchor"), wxITEM_CHECK ); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_LIBEDIT_IMPORT_BODY_BUTT, wxEmptyString, + BITMAP(import_xpm), + _("Import existing drawings"), wxITEM_CHECK ); + + m_VToolBar->AddTool(ID_LIBEDIT_EXPORT_BODY_BUTT, wxEmptyString, + BITMAP(export_xpm), + _("Export current drawing"), wxITEM_CHECK ); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_LIBEDIT_DELETE_ITEM_BUTT, wxEmptyString, + BITMAP(delete_body_xpm), + _("Delete items"), wxITEM_CHECK ); + + m_VToolBar->Realize(); + } + + SetToolbars(); +} + + + +/*************************************************/ +void WinEDA_LibeditFrame::ReCreateHToolbar(void) +/*************************************************/ +{ +int ii; + + // Create the toolbar if not exists + if ( m_HToolBar == NULL ) + { + m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE); + SetToolBar(m_HToolBar); + + // Set up toolbar + m_HToolBar->AddTool(ID_LIBEDIT_SAVE_CURRENT_LIB, wxEmptyString, BITMAP(save_library_xpm), + _("Save current loaded library on disk (file update)") ); + + m_HToolBar->AddTool(ID_LIBEDIT_SELECT_CURRENT_LIB, wxEmptyString, BITMAP(library_xpm), + _("Select working library") ); + + m_HToolBar->AddTool(ID_LIBEDIT_DELETE_PART, wxEmptyString, BITMAP(delete_xpm), + _("Delete part in current library") ); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_LIBEDIT_NEW_PART, wxEmptyString, BITMAP(new_component_xpm), + _("New part") ); + + m_HToolBar->AddTool(ID_LIBEDIT_SELECT_PART, BITMAP(add_component_xpm), + _("Select part to edit") ); + + m_HToolBar->AddTool(ID_LIBEDIT_SAVE_CURRENT_PART, wxEmptyString, + BITMAP(save_part_in_mem_xpm), + _("Save current part into current loaded library (in memory)") ); + + m_HToolBar->AddTool(ID_LIBEDIT_IMPORT_PART, wxEmptyString, BITMAP(import_xpm), + _("import part")); + + m_HToolBar->AddTool(ID_LIBEDIT_EXPORT_PART, wxEmptyString, BITMAP(export_xpm), + _("export part")); + + m_HToolBar->AddTool(ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, + wxEmptyString, BITMAP(new_library_xpm), + _("Create a new library an save current part into")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_LIBEDIT_UNDO, wxEmptyString, BITMAP(undo_xpm), + _("Undo last edition")); + m_HToolBar->AddTool(ID_LIBEDIT_REDO, wxEmptyString, BITMAP(redo_xpm), + _("Redo the last undo command")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_LIBEDIT_GET_FRAME_EDIT_PART, BITMAP(part_properties_xpm), + wxNullBitmap, + FALSE, + -1, -1, (wxObject *) NULL, + _("Edit Part Properties")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_LIBEDIT_CHECK_PART, BITMAP(erc_xpm), + wxNullBitmap, + FALSE, + -1, -1, (wxObject *) NULL, + _("Test duplicate pins")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_ZOOM_PLUS_BUTT, BITMAP(zoom_in_xpm), + wxNullBitmap, + FALSE, + -1, -1, (wxObject *) NULL, + _("zoom + (F1)")); + + m_HToolBar->AddTool(ID_ZOOM_MOINS_BUTT, wxEmptyString, + BITMAP(zoom_out_xpm), + _("zoom - (F2)")); + + m_HToolBar->AddTool(ID_ZOOM_REDRAW_BUTT, wxEmptyString, + BITMAP(repaint_xpm), + _("redraw (F3)")); + + m_HToolBar->AddTool(ID_ZOOM_PAGE_BUTT, wxEmptyString, + BITMAP(zoom_optimal_xpm), + _("auto zoom") ); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_DE_MORGAN_NORMAL_BUTT, wxEmptyString, + BITMAP(morgan1_xpm), + _("show as \"De Morgan\" normal part"), wxITEM_CHECK); + m_HToolBar->ToggleTool(ID_DE_MORGAN_NORMAL_BUTT, + (CurrentConvert <= 1) ? TRUE : FALSE); + + m_HToolBar->AddTool(ID_DE_MORGAN_CONVERT_BUTT, wxEmptyString, + BITMAP(morgan2_xpm), + _("show as \"De Morgan\" convert part"), wxITEM_CHECK); + m_HToolBar->ToggleTool(ID_DE_MORGAN_CONVERT_BUTT, + (CurrentConvert >= 2) ? TRUE : FALSE ); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_LIBEDIT_VIEW_DOC, BITMAP(datasheet_xpm), + wxNullBitmap, + FALSE, + -1, -1, (wxObject *) NULL, + _("Documents")); + m_HToolBar->EnableTool(ID_LIBEDIT_VIEW_DOC, FALSE); + + m_HToolBar->AddSeparator(); + m_SelpartBox = new WinEDAChoiceBox(m_HToolBar, ID_LIBEDIT_SELECT_PART_NUMBER, + wxDefaultPosition, wxSize(LISTBOX_WIDTH, -1)); + m_HToolBar->AddControl(m_SelpartBox); + + m_SelAliasBox = new WinEDAChoiceBox(m_HToolBar, ID_LIBEDIT_SELECT_ALIAS, + wxDefaultPosition, wxSize(LISTBOX_WIDTH, -1)); + m_HToolBar->AddControl(m_SelAliasBox); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_LIBEDIT_EDIT_PIN_BY_PIN, BITMAP(pin2pin_xpm), + wxNullBitmap, + TRUE, + -1, -1, (wxObject *) NULL, + _("Edit pins part per part (Carefully use!)")); + m_HToolBar->ToggleTool(ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn); + + // after adding the buttons to the toolbar, must call Realize() to reflect + // the changes + m_HToolBar->Realize(); + } + + else /* Toolbar deja créé, mise a jour des affichages */ + { + m_SelAliasBox->Clear(); + m_SelpartBox->Clear(); + } + + /* Update the part selection box */ + int jj = 1; + if( CurrentLibEntry ) jj = CurrentLibEntry->m_UnitCount; + for ( ii = 0; ii < jj ; ii ++ ) + { + wxString msg; + msg.Printf(_("Part %c"), 'A' + ii); + m_SelpartBox->Append(msg); + } + m_SelpartBox->SetSelection( ( CurrentUnit > 0 ) ? CurrentUnit-1 : 0); + + if( CurrentLibEntry) + { + if ( CurrentLibEntry->m_UnitCount > 1 ) m_SelpartBox->Enable(TRUE); + else m_SelpartBox->Enable(FALSE); + m_SelAliasBox->Append(CurrentLibEntry->m_Name.m_Text); + m_SelAliasBox->SetSelection( 0 ); + int count = CurrentLibEntry->m_AliasList.GetCount(); + if ( count > 0 ) /* Update the part selection box */ + { + m_SelAliasBox->Enable(TRUE); + for ( ii = 0, jj = 1; ii < count; ii += ALIAS_NEXT, jj++ ) + { + m_SelAliasBox->Append(CurrentLibEntry->m_AliasList[ii]); + if ( CurrentAliasName == CurrentLibEntry->m_AliasList[ii]) + m_SelAliasBox->SetSelection( jj ); + } + } + else m_SelAliasBox->Enable(FALSE); + } + else + { + m_SelAliasBox->Enable(FALSE); + m_SelpartBox->Enable(FALSE); + } + + // Doit etre placé apres Realize(): + SetToolbars(); + +} + + diff --git a/eeschema/tool_sch.cpp b/eeschema/tool_sch.cpp new file mode 100644 index 0000000000..639b1262c2 --- /dev/null +++ b/eeschema/tool_sch.cpp @@ -0,0 +1,327 @@ + /*****************************************************/ + /* toolsch.cpp; vreate toolbars for schematic frame */ + /*****************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +#define BITMAP wxBitmap + +#include "bitmaps.h" /* general bitmaps */ + +/* Specific bitmaps */ +#include "cvpcb.xpm" +#include "Hierarchy_Nav.xpm" +#include "Hierarchy_cursor.xpm" +#include "Add_Power.xpm" +#include "Lines90.xpm" +#include "Hidden_Pin.xpm" +#include "Add_Bus2Bus.xpm" +#include "Add_Line2Bus.xpm" +#include "add_bus.xpm" +#include "library_browse.xpm" +#include "libedit.xpm" +#include "add_hierar_pin.xpm" +#include "add_hierar_symbol.xpm" +#include "Import_GLabel.xpm" + +#include "id.h" + + +/**************************************************************/ +void WinEDA_SchematicFrame::ReCreateHToolbar(void) +/**************************************************************/ +/* Create Horizontal (main) Toolbar +*/ +{ + if ( m_HToolBar != NULL ) return; + + m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE); + SetToolBar(m_HToolBar); + + // Set up toolbar + m_HToolBar->AddTool(ID_NEW_PROJECT, wxEmptyString, BITMAP(new_xpm), + _("New schematic project")); + + m_HToolBar->AddTool(ID_LOAD_PROJECT, wxEmptyString, BITMAP(open_xpm), + _("Open schematic project")); + + m_HToolBar->AddTool(ID_SAVE_PROJECT, wxEmptyString, BITMAP(save_project_xpm), + _("Save schematic project")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_SHEET_SET, wxEmptyString, BITMAP(sheetset_xpm), + _("page settings (size, texts)") ); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_TO_LIBRARY, wxEmptyString, BITMAP(libedit_xpm), + _("go to library editor") ); + + m_HToolBar->AddTool(ID_TO_LIBVIEW, wxEmptyString, BITMAP(library_browse_xpm), + _("go to library browse") ); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_HIERARCHY, wxEmptyString, BITMAP(hierarchy_nav_xpm), + _("Schematic Hierarchy Navigator") ); + + m_HToolBar->AddSeparator(); + + m_HToolBar->AddTool(wxID_CUT, wxEmptyString, BITMAP(cut_button), + _("Cut selected item") ); + + m_HToolBar->AddTool(wxID_COPY, wxEmptyString, BITMAP(copy_button), + _("Copy selected item") ); + + m_HToolBar->AddTool(wxID_PASTE, wxEmptyString, BITMAP(paste_xpm), + _("Paste") ); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_SCHEMATIC_UNDO, wxEmptyString, BITMAP(undo_xpm), + _("Undo last edition")); + m_HToolBar->AddTool(ID_SCHEMATIC_REDO, wxEmptyString, BITMAP(redo_xpm), + _("Redo the last undo command")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_GEN_PRINT, wxEmptyString, BITMAP(print_button), + _("Print schematic") ); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_TO_CVPCB, wxEmptyString, BITMAP(cvpcb_xpm), + _("Run Cvpcb") ); + + m_HToolBar->AddTool(ID_TO_PCB, wxEmptyString, BITMAP(pcbnew_xpm), + _("Run Pcbnew") ); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP(zoom_in_xpm), + _("zoom + (F1)")); + + m_HToolBar->AddTool(ID_ZOOM_MOINS_BUTT, wxEmptyString, BITMAP(zoom_out_xpm), + _("zoom - (F2)")); + + m_HToolBar->AddTool(ID_ZOOM_REDRAW_BUTT, wxEmptyString, BITMAP(repaint_xpm), + _("redraw (F3)") ); + + m_HToolBar->AddTool(ID_ZOOM_PAGE_BUTT, wxEmptyString, BITMAP(zoom_optimal_xpm), + _("auto zoom") ); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_FIND_ITEMS, wxEmptyString, BITMAP(find_xpm), + _("Find components and texts") ); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_GET_NETLIST, wxEmptyString, BITMAP(netlist_xpm), + _("Netlist generation") ); + + m_HToolBar->AddTool(ID_GET_ANNOTATE, wxEmptyString, BITMAP(annotate_xpm), + _("Schematic Annotation") ); + + m_HToolBar->AddTool(ID_GET_ERC, wxEmptyString, BITMAP(erc_xpm), + _("Schematic Electric Rules Check") ); + + m_HToolBar->AddTool(ID_GET_TOOLS, wxEmptyString, BITMAP(tools_xpm), + _("Bill of material and/or Crossreferences") ); + + + // after adding the buttons to the toolbar, must call Realize() to reflect + // the changes + m_HToolBar->Realize(); + SetToolbars(); +} + +/*************************************************/ +void WinEDA_SchematicFrame::ReCreateVToolbar(void) +/*************************************************/ +/* Create Vertical Right Toolbar +*/ +{ + if( m_VToolBar ) return; + m_VToolBar = new WinEDA_Toolbar(TOOLBAR_TOOL, this, ID_V_TOOLBAR, FALSE); + + // Set up toolbar + m_VToolBar->AddTool(ID_NO_SELECT_BUTT, wxEmptyString, + BITMAP(cursor_xpm), wxEmptyString, wxITEM_CHECK ); + m_VToolBar->ToggleTool(ID_NO_SELECT_BUTT, TRUE); + + m_VToolBar->AddTool(ID_HIERARCHY_PUSH_POP_BUTT, wxEmptyString, + BITMAP(hierarchy_cursor_xpm), + _("Hierarchy Push/Pop"), wxITEM_CHECK ); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_COMPONENT_BUTT, wxEmptyString, + BITMAP(add_component_xpm), + _("Add components"), wxITEM_CHECK ); + + m_VToolBar->AddTool(ID_PLACE_POWER_BUTT, wxEmptyString, + BITMAP(add_power_xpm), + _("Add powers"), wxITEM_CHECK ); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_WIRE_BUTT, wxEmptyString, + BITMAP(add_line_xpm), + _("Add wires"), wxITEM_CHECK ); + + m_VToolBar->AddTool(ID_BUS_BUTT, wxEmptyString, + BITMAP(add_bus_xpm), + _("Add bus"), wxITEM_CHECK ); + + m_VToolBar->AddTool(ID_WIRETOBUS_ENTRY_BUTT, wxEmptyString, + BITMAP(add_line2bus_xpm), + _("Add wire to bus entry"), wxITEM_CHECK ); + + m_VToolBar->AddTool(ID_BUSTOBUS_ENTRY_BUTT, wxEmptyString, + BITMAP(add_bus2bus_xpm), + _("Add bus to bus entry"), wxITEM_CHECK ); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_NOCONN_BUTT, wxEmptyString, + BITMAP(noconn_button), + _("Add no connect flag"), wxITEM_CHECK ); + + m_VToolBar->AddTool(ID_LABEL_BUTT, wxEmptyString, + BITMAP(add_line_label_xpm), + _("Add wire or bus label"), wxITEM_CHECK ); + + m_VToolBar->AddTool(ID_GLABEL_BUTT, wxEmptyString, + BITMAP(add_glabel_xpm), + _("Add global label"), wxITEM_CHECK ); + + m_VToolBar->AddTool(ID_JUNCTION_BUTT, wxEmptyString, + BITMAP(add_junction_xpm), + _("Add junction"), wxITEM_CHECK ); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_SHEET_SYMBOL_BUTT, wxEmptyString, + BITMAP(add_hierar_symbol_xpm), + _("Add hierarchical symbol (sheet)") , wxITEM_CHECK); + + m_VToolBar->AddTool(ID_IMPORT_GLABEL_BUTT, wxEmptyString, + BITMAP(import_glabel_xpm), + _("import glabel from sheet & create pinsheet"), wxITEM_CHECK ); + + m_VToolBar->AddTool(ID_SHEET_LABEL_BUTT, wxEmptyString, + BITMAP(add_hierar_pin_xpm), + _("Add hierachical pin to sheet"), wxITEM_CHECK ); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_LINE_COMMENT_BUTT, wxEmptyString, + BITMAP(add_dashed_line_xpm), + _("Add graphic line or polygon") , wxITEM_CHECK); + + m_VToolBar->AddTool(ID_TEXT_COMMENT_BUTT, wxEmptyString, + BITMAP(add_text_xpm), + _("Add graphic text (comment)"), wxITEM_CHECK ); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_SCHEMATIC_DELETE_ITEM_BUTT, wxEmptyString, + BITMAP(delete_body_xpm), + _("Delete items"), wxITEM_CHECK ); + + m_VToolBar->Realize(); + SetToolbars(); +} + + +/****************************************************************/ +void WinEDA_SchematicFrame::ReCreateOptToolbar(void) +/****************************************************************/ +/* Create Vertical Left Toolbar (Option Toolbar) +*/ +{ + + if ( m_OptionsToolBar ) return; + + // creation du tool bar options + m_OptionsToolBar = new WinEDA_Toolbar(TOOLBAR_OPTION, this, ID_OPT_TOOLBAR, FALSE); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, + BITMAP(grid_xpm), + _("Display Grid OFF"), wxITEM_CHECK ); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString, + BITMAP(unit_inch_xpm), + _("Units = Inch"), wxITEM_CHECK ); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString, + BITMAP(unit_mm_xpm), + _("Units = mm"), wxITEM_CHECK ); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString, + BITMAP(cursor_shape_xpm), + _("Change Cursor Shape"), wxITEM_CHECK ); + + m_OptionsToolBar->AddSeparator(); + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_HIDDEN_PINS, wxEmptyString, + BITMAP(hidden_pin_xpm), + _("Show Hidden Pins"), wxITEM_CHECK ); + + m_OptionsToolBar->AddSeparator(); + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_BUS_WIRES_ORIENT, wxEmptyString, + BITMAP(lines90_xpm), + _("HV orientation for Wires and Bus"), wxITEM_CHECK ); + + m_OptionsToolBar->Realize(); + + SetToolbars(); +} + + +/*******************************************************************************************/ +void WinEDA_SchematicFrame::OnSelectOptionToolbar(wxCommandEvent& event) +/*******************************************************************************************/ +{ + if ( DrawPanel == NULL ) return; + +int id = event.GetId(); +wxClientDC dc(DrawPanel); + + DrawPanel->PrepareGraphicContext(&dc); + switch ( id ) + { + case ID_TB_OPTIONS_SHOW_GRID: + g_ShowGrid = m_Draw_Grid = m_OptionsToolBar->GetToolState(id); + ReDrawPanel(); + break; + + case ID_TB_OPTIONS_SELECT_UNIT_MM: + g_UnitMetric = MILLIMETRE; + Affiche_Status_Box(); /* Reaffichage des coord curseur */ + break; + + case ID_TB_OPTIONS_SELECT_UNIT_INCH: + g_UnitMetric = INCHES; + Affiche_Status_Box(); /* Reaffichage des coord curseur */ + break; + + case ID_TB_OPTIONS_SELECT_CURSOR: + DrawPanel->CursorOff(&dc); + g_CursorShape = m_OptionsToolBar->GetToolState(id); + DrawPanel->CursorOn(&dc); + break; + + case ID_TB_OPTIONS_HIDDEN_PINS: + g_ShowAllPins = m_OptionsToolBar->GetToolState(id); + DrawPanel->ReDraw(&dc, TRUE); + break; + + case ID_TB_OPTIONS_BUS_WIRES_ORIENT: + g_HVLines = m_OptionsToolBar->GetToolState(id); + break; + + default: + DisplayError(this, wxT("OnSelectOptionToolbar() error") ); + break; + } + + SetToolbars(); +} + + + diff --git a/eeschema/tool_viewlib.cpp b/eeschema/tool_viewlib.cpp new file mode 100644 index 0000000000..c6a06725dc --- /dev/null +++ b/eeschema/tool_viewlib.cpp @@ -0,0 +1,152 @@ +/****************************************************************/ +/* tool_viewlib.cpp: Build the toolbars for the library browser */ +/****************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "wx/spinctrl.h" + +#include "protos.h" + +#define BITMAP wxBitmap + +#include "bitmaps.h" + +#include "id.h" + +#include "Lib_previous.xpm" +#include "Lib_next.xpm" + +/****************************************************/ +void WinEDA_ViewlibFrame::ReCreateHToolbar(void) +/****************************************************/ +{ +int ii; +EDA_LibComponentStruct * RootLibEntry = NULL, * CurrentLibEntry = NULL; +bool asdeMorgan = FALSE, state; + + if ( (g_CurrentViewLibraryName != wxEmptyString) && (g_CurrentViewComponentName != wxEmptyString) ) + { + RootLibEntry = FindLibPart(g_CurrentViewComponentName.GetData(), + g_CurrentViewLibraryName.GetData(), FIND_ROOT); + if ( RootLibEntry && LookForConvertPart(RootLibEntry) > 1 ) + asdeMorgan = TRUE; + CurrentLibEntry = FindLibPart(g_CurrentViewComponentName.GetData(), + g_CurrentViewLibraryName.GetData(), FIND_ALIAS); + } + + if ( m_HToolBar == NULL ) + { + m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE); + SetToolBar(m_HToolBar); + + // Set up toolbar + m_HToolBar->AddTool(ID_LIBVIEW_SELECT_LIB, wxEmptyString, + BITMAP(library_xpm), + _("Select library to browse")); + + m_HToolBar->AddTool(ID_LIBVIEW_SELECT_PART, wxEmptyString, + BITMAP(add_component_xpm), + _("Select part to browse")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_LIBVIEW_PREVIOUS, wxEmptyString, + BITMAP(lib_previous_xpm), + _("Display previous part")); + + m_HToolBar->AddTool(ID_LIBVIEW_NEXT, wxEmptyString, + BITMAP(lib_next_xpm), + _("Display next part")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_ZOOM_PLUS_BUTT, wxEmptyString, + BITMAP(zoom_in_xpm), + _("zoom + (F1)")); + + m_HToolBar->AddTool(ID_ZOOM_MOINS_BUTT, wxEmptyString, + BITMAP(zoom_out_xpm), + _("zoom - (F2)")); + + m_HToolBar->AddTool(ID_ZOOM_REDRAW_BUTT, wxEmptyString, + BITMAP(repaint_xpm), + _("redraw (F3)")); + + m_HToolBar->AddTool(ID_ZOOM_PAGE_BUTT, wxEmptyString, + BITMAP(zoom_optimal_xpm), + _("1:1 zoom")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, wxEmptyString, + BITMAP(morgan1_xpm), + _("Show as \"De Morgan\" normal part"), wxITEM_CHECK); + + m_HToolBar->AddTool(ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, wxEmptyString, + BITMAP(morgan2_xpm), + _("Show as \"De Morgan\" convert part"), wxITEM_CHECK); + + m_HToolBar->AddSeparator(); + + SelpartBox = new WinEDAChoiceBox(m_HToolBar, ID_LIBVIEW_SELECT_PART_NUMBER, + wxDefaultPosition, wxSize(150,-1)); + m_HToolBar->AddControl(SelpartBox); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_LIBVIEW_VIEWDOC, wxEmptyString, BITMAP(datasheet_xpm), + _("View component documents") ); + m_HToolBar->EnableTool(ID_LIBVIEW_VIEWDOC, FALSE); + + if ( m_Semaphore ) // The lib browser is called from a "load component" command + { + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC, wxEmptyString, + BITMAP(export_xpm), + _("Export to schematic") ); + } + + // after adding the buttons to the toolbar, must call Realize() to reflect + // the changes + m_HToolBar->Realize(); + } + + // Must be AFTER Realize(): + m_HToolBar->ToggleTool(ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, + (g_ViewConvert <= 1) ? TRUE : FALSE); + m_HToolBar->ToggleTool(ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, + (g_ViewConvert >= 2) ? TRUE : FALSE ); + m_HToolBar->EnableTool(ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, asdeMorgan); + m_HToolBar->EnableTool(ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, asdeMorgan); + + int jj = 1; + if( RootLibEntry ) jj = MAX(RootLibEntry->m_UnitCount, 1); + SelpartBox->Clear(); + for ( ii = 0; ii < jj ; ii ++ ) + { + wxString msg; + msg.Printf( _("Part %c"), 'A' + ii); + SelpartBox->Append(msg); + } + SelpartBox->SetSelection(0); + state = FALSE; + if ( CurrentLibEntry && jj > 1 ) state = TRUE; + SelpartBox->Enable(state); + + state = FALSE; + if( CurrentLibEntry && (CurrentLibEntry->m_DocFile != wxEmptyString) ) + state = TRUE; + m_HToolBar->EnableTool(ID_LIBVIEW_VIEWDOC, state); +} + + + +/****************************************************/ +void WinEDA_ViewlibFrame::ReCreateVToolbar(void) +/****************************************************/ +{ +} + diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp new file mode 100644 index 0000000000..9b416a0208 --- /dev/null +++ b/eeschema/viewlib_frame.cpp @@ -0,0 +1,321 @@ +/*************************************************************************/ +/* viewlib_frame.cpp - fonctions des classes du type WinEDA_ViewlibFrame */ +/*************************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" + +#include "common.h" + +#include "program.h" +#include "libcmp.h" +#include "general.h" +#include "bitmaps.h" + +#include "protos.h" + +#include "id.h" + +#include "library_browse.xpm" + + /*****************************/ + /* class WinEDA_ViewlibFrame */ + /*****************************/ +BEGIN_EVENT_TABLE(WinEDA_ViewlibFrame, wxFrame) + COMMON_EVENTS_DRAWFRAME + + EVT_CLOSE(WinEDA_ViewlibFrame::OnCloseWindow) + EVT_SIZE(WinEDA_ViewlibFrame::OnSize) + EVT_ACTIVATE(WinEDA_DrawFrame::OnActivate) + + EVT_TOOL_RANGE(ID_LIBVIEW_START_H_TOOL, ID_LIBVIEW_END_H_TOOL, + WinEDA_ViewlibFrame::Process_Special_Functions) + + EVT_TOOL_RANGE(ID_ZOOM_PLUS_BUTT, ID_ZOOM_PAGE_BUTT, + WinEDA_DrawFrame::Process_Zoom) + + EVT_TOOL(ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC, + WinEDA_ViewlibFrame::ExportToSchematicLibraryPart) + + EVT_KICAD_CHOICEBOX(ID_LIBVIEW_SELECT_PART_NUMBER, + WinEDA_ViewlibFrame::Process_Special_Functions) + + EVT_LISTBOX(ID_LIBVIEW_LIB_LIST, WinEDA_ViewlibFrame::ClickOnLibList) + EVT_LISTBOX(ID_LIBVIEW_CMP_LIST, WinEDA_ViewlibFrame::ClickOnCmpList) + +END_EVENT_TABLE() + + + /****************/ + /* Constructeur */ + /****************/ +WinEDA_ViewlibFrame::WinEDA_ViewlibFrame(wxWindow * father, WinEDA_App *parent, + LibraryStruct * Library, wxSemaphore * semaphore ): + WinEDA_DrawFrame(father, VIEWER_FRAME, parent, _("Library browser"), + wxDefaultPosition, wxDefaultSize) +{ + m_FrameName = wxT("ViewlibFrame"); + + m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines + m_Draw_Grid = TRUE; // TRUE pour avoir la axes dessinee + + // Give an icon + SetIcon(wxIcon(library_browse_xpm)); + + m_CmpList = NULL; + m_LibList = NULL; + m_Semaphore = semaphore; + if ( m_Semaphore ) SetWindowStyle( GetWindowStyle() | wxSTAY_ON_TOP); + + m_CurrentScreen = new SCH_SCREEN(VIEWER_FRAME); + m_CurrentScreen->SetZoom(16); + + if ( Library == NULL ) + { + m_LibListSize.x = 90; + m_LibListSize.y = -1; + m_LibList = new wxListBox(this, ID_LIBVIEW_LIB_LIST,wxPoint(0,0), + m_LibListSize, 0, NULL, wxLB_HSCROLL ); + m_LibList->SetFont(*g_DialogFont); + m_LibList->SetBackgroundColour(wxColour(150,255,255)); + m_LibList->SetForegroundColour(wxColour(0,0,0)); + } + else g_CurrentViewLibraryName = Library->m_Name; + + m_CmpListSize.x = 150; + m_CmpListSize.y = -1; + m_CmpList = new wxListBox(this, ID_LIBVIEW_CMP_LIST,wxPoint(m_LibListSize.x,0), + m_CmpListSize, 0, NULL, wxLB_HSCROLL ); + m_CmpList->SetFont(*g_DialogFont); + m_CmpList->SetBackgroundColour(wxColour(255,255,200)); + m_CmpList->SetForegroundColour(wxColour(0,0,0)); + + GetSettings(); + SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y); + ReCreateHToolbar(); + ReCreateVToolbar(); + if ( m_LibList) ReCreateListLib(); + DisplayLibInfos(); + Show(TRUE); +} + + /***************/ + /* Destructeur */ + /***************/ + +WinEDA_ViewlibFrame::~WinEDA_ViewlibFrame(void) +{ + delete m_CurrentScreen; + m_Parent->ViewlibFrame = NULL; +} + +/*****************************************************************/ +void WinEDA_ViewlibFrame::OnCloseWindow(wxCloseEvent & Event) +/*****************************************************************/ +{ + SaveSettings(); + if ( m_Semaphore ) m_Semaphore->Post(); + Destroy(); +} + + +/*****************************************************/ +void WinEDA_ViewlibFrame::OnSize(wxSizeEvent & SizeEv) +/*****************************************************/ +{ +wxSize size; +wxSize maintoolbar_size; +wxSize Vtoolbar_size; + + GetClientSize(&size.x, &size.y); + m_FrameSize = size; + size.y -= m_MsgFrameHeight; + + if( m_HToolBar ) + { + maintoolbar_size = m_HToolBar->GetSize(); + } + + if( m_VToolBar ) + { + Vtoolbar_size = m_VToolBar->GetSize(); + m_VToolBar->SetSize(size.x - maintoolbar_size.y, 0,-1, size.y); + } + + if ( MsgPanel ) + { + MsgPanel->SetSize(0, size.y, size.x, m_MsgFrameHeight); + } + + if ( DrawPanel ) + { + DrawPanel->SetSize(m_LibListSize.x + m_CmpListSize.x, 0, + size.x - Vtoolbar_size.x - m_LibListSize.x - m_CmpListSize.x, + size.y); + } + + if ( m_LibList ) + { + m_LibListSize.y = size.y; + m_LibList->SetSize(0, 0, m_LibListSize.x, m_LibListSize.y); + } + + if ( m_CmpList ) + { + m_CmpListSize.y = size.y; + m_CmpList->SetSize(m_LibListSize.x, 0, m_CmpListSize.x, m_CmpListSize.y); + } +} + + +/*******************************************/ +int WinEDA_ViewlibFrame::BestZoom(void) +/*******************************************/ +{ +int bestzoom, ii, jj; +wxSize size, itemsize; +EDA_LibComponentStruct * CurrentLibEntry = NULL; + + CurrentLibEntry = FindLibPart(g_CurrentViewComponentName.GetData(), + g_CurrentViewLibraryName.GetData(), FIND_ROOT); + + if( CurrentLibEntry == NULL ) + { + bestzoom = 16; + m_CurrentScreen->m_Curseur.x = 0; + m_CurrentScreen->m_Curseur.y = 0; + return(bestzoom); + } + + EDA_Rect BoundaryBox = CurrentLibEntry->GetBoundaryBox(g_ViewUnit, g_ViewConvert); + itemsize = BoundaryBox.GetSize(); + + size = DrawPanel->GetClientSize(); + size.x -= 60; // Pour marges haut et bas + ii = itemsize.x / size.x; + jj = itemsize.y / size.y; + ii = MAX(ii, jj); + + /* determination du zoom existant le plus proche */ + for ( bestzoom = 1 ; bestzoom < 512 ; bestzoom <<= 1 ) + { + if(bestzoom > ii ) break; + } + + m_CurrentScreen->m_Curseur = BoundaryBox.Centre(); + m_CurrentScreen->m_Curseur.y = - m_CurrentScreen->m_Curseur.y; + + return(bestzoom); +} + +/***************************************************/ +void WinEDA_ViewlibFrame::ReCreateListLib(void) +/***************************************************/ +{ +const wxChar ** ListNames, ** names; +int ii; +bool found = FALSE; + + if ( m_LibList == NULL ) return; + + ListNames = GetLibNames(); + + m_LibList->Clear(); + for ( names = ListNames, ii = 0; *names != NULL; names++, ii++ ) + { + m_LibList->Append(*names); + if ( g_CurrentViewLibraryName.Cmp(*names) == 0) + { + m_LibList->SetSelection(ii, TRUE); + found = TRUE; + } + } + + free (ListNames); + + /* Librairie courante peut etre non retrouvée en liste + (peut etre effacée lors d'une modification de configuration) */ + if ( ! found ) + { + g_CurrentViewLibraryName.Empty(); + g_CurrentViewComponentName.Empty(); + } + + ReCreateListCmp(); + ReCreateHToolbar(); + DisplayLibInfos(); + ReDrawPanel(); +} + +/***********************************************/ +void WinEDA_ViewlibFrame::ReCreateListCmp(void) +/***********************************************/ +{ +int ii; +EDA_LibComponentStruct *LibEntry = NULL; +LibraryStruct *Library = FindLibrary(g_CurrentViewLibraryName.GetData()); + + m_CmpList->Clear(); + ii = 0; + g_CurrentViewComponentName.Empty(); + g_ViewConvert = 1; /* Vue normal / convert */ + g_ViewUnit = 1; /* unité a afficher (A, B ..) */ + if ( Library ) + LibEntry = (EDA_LibComponentStruct *) PQFirst(&Library->m_Entries, FALSE); + while( LibEntry ) + { + m_CmpList->Append(LibEntry->m_Name.m_Text); + LibEntry = (EDA_LibComponentStruct *) PQNext(Library->m_Entries, LibEntry, NULL); + } +} + + +/********************************************************************/ +void WinEDA_ViewlibFrame::ClickOnLibList(wxCommandEvent & event) +/********************************************************************/ +{ +int ii = m_LibList->GetSelection(); + if ( ii < 0 ) return; + +wxString name = m_LibList->GetString(ii); + if ( g_CurrentViewLibraryName == name ) return; + g_CurrentViewLibraryName = name; + ReCreateListCmp(); + ReDrawPanel(); + DisplayLibInfos(); + ReCreateHToolbar(); +} + + +/****************************************************************/ +void WinEDA_ViewlibFrame::ClickOnCmpList(wxCommandEvent & event) +/****************************************************************/ +{ +int ii = m_CmpList->GetSelection(); + if ( ii < 0 ) return; + +wxString name = m_CmpList->GetString(ii); + g_CurrentViewComponentName = name; + DisplayLibInfos(); + g_ViewUnit = 1; + g_ViewConvert = 1; + Zoom_Automatique(FALSE); + ReCreateHToolbar(); + ReDrawPanel(); +} + + +/****************************************************************************/ +void WinEDA_ViewlibFrame::ExportToSchematicLibraryPart(wxCommandEvent& event) +/****************************************************************************/ +/* Export to schematic the current viewed component, and close the library browser +*/ +{ +int ii = m_CmpList->GetSelection(); + if ( ii >= 0 ) g_CurrentViewComponentName = m_CmpList->GetString(ii); + else g_CurrentViewComponentName.Empty(); + Close(TRUE); +} diff --git a/eeschema/viewlibs.cpp b/eeschema/viewlibs.cpp new file mode 100644 index 0000000000..c465e53e6b --- /dev/null +++ b/eeschema/viewlibs.cpp @@ -0,0 +1,344 @@ + /****************************/ + /* EESchema - viewlibs.cpp */ + /****************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + +#include "id.h" + +#define NEXT_PART 1 +#define NEW_PART 0 +#define PREVIOUS_PART -1 + + +/* Routines locales */ + +/* Variables locales */ + +/*************************************************************************/ +void WinEDA_ViewlibFrame::Process_Special_Functions(wxCommandEvent& event) +/*************************************************************************/ +{ +EDA_LibComponentStruct * LibEntry; +int ii, id = event.GetId(); +wxPoint pos; + + wxGetMousePosition(&pos.x, &pos.y); + pos.y += 20; + + switch ( id ) + { + case ID_LIBVIEW_SELECT_LIB: + SelectCurrentLibrary(); + break; + + case ID_LIBVIEW_SELECT_PART: + SelectAndViewLibraryPart(NEW_PART); + break; + + case ID_LIBVIEW_NEXT: + SelectAndViewLibraryPart(NEXT_PART); + break; + + case ID_LIBVIEW_PREVIOUS: + SelectAndViewLibraryPart(PREVIOUS_PART); + break; + + case ID_LIBVIEW_VIEWDOC: + LibEntry = FindLibPart(g_CurrentViewComponentName.GetData(), + g_CurrentViewLibraryName.GetData(), FIND_ALIAS); + if( LibEntry && ( !LibEntry->m_DocFile.IsEmpty()) ) + GetAssociatedDocument(this, g_RealLibDirBuffer, LibEntry->m_DocFile ); + break; + + case ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT: + m_HToolBar->ToggleTool(ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, TRUE); + m_HToolBar->ToggleTool(ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, FALSE); + g_ViewConvert = 1; + ReDrawPanel(); + break; + + case ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT: + m_HToolBar->ToggleTool(ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, FALSE); + m_HToolBar->ToggleTool(ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, TRUE); + g_ViewConvert = 2; + ReDrawPanel(); + break; + + case ID_LIBVIEW_SELECT_PART_NUMBER: + ii = SelpartBox->GetChoice(); + if ( ii < 0 ) return; + g_ViewUnit = ii + 1; + ReDrawPanel(); + break; + + default: + { + wxString msg; + msg << wxT("WinEDA_ViewlibFrame::Process_Special_Functions error: id = ") << id; + DisplayError( this, msg); + break; + } + } + +} + + +/*************************************************************************/ +void WinEDA_ViewlibFrame::OnLeftClick(wxDC * DC, const wxPoint& MousePos) +/*************************************************************************/ +{ +} + +/********************************************************************************/ +void WinEDA_ViewlibFrame::OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu) +/********************************************************************************/ +{ +} + + +/**********************************************/ +void WinEDA_ViewlibFrame::DisplayLibInfos(void) +/**********************************************/ +/* Affiche en Ligne d'info la librairie en cours de visualisation */ +{ +wxString msg; +LibraryStruct * Lib; + + Lib = FindLibrary(g_CurrentViewLibraryName); + msg = _("Browse library: "); + if ( Lib ) msg += g_CurrentViewLibraryName; + else msg += _("None"); + SetTitle(msg); +} + + + /*****************************************/ + /* Routine to Select Current library */ + /*****************************************/ +void WinEDA_ViewlibFrame::SelectCurrentLibrary(void) +{ +LibraryStruct * Lib; + + Lib = SelectLibraryFromList(this); + if ( Lib ) + { + g_CurrentViewComponentName.Empty(); + g_CurrentViewLibraryName = Lib->m_Name; + DisplayLibInfos(); + if ( m_LibList ) + { + ReCreateListCmp(); + ReDrawPanel(); + DisplayLibInfos(); + ReCreateHToolbar(); + int id = m_LibList->FindString(g_CurrentViewLibraryName.GetData()); + if ( id >= 0 ) m_LibList->SetSelection(id); + } + } +} + +/**************************************************************/ +void WinEDA_ViewlibFrame::SelectAndViewLibraryPart(int option) +/**************************************************************/ +/* Routine to select and view library Part (NEW, NEXT or PREVIOUS) */ +{ +LibraryStruct * Lib; + + if(g_CurrentViewLibraryName.IsEmpty() ) SelectCurrentLibrary(); + if(g_CurrentViewLibraryName.IsEmpty() ) return; + + Lib = FindLibrary(g_CurrentViewLibraryName); + if ( Lib == NULL ) return; + + if ( (g_CurrentViewComponentName.IsEmpty()) || ( option == NEW_PART ) ) + { + ViewOneLibraryContent(Lib, NEW_PART); + return; + } + + EDA_LibComponentStruct * LibEntry = FindLibPart(g_CurrentViewComponentName.GetData(), + g_CurrentViewLibraryName, FIND_ALIAS); + + if ( LibEntry == NULL ) return; + + if (option == NEXT_PART ) + ViewOneLibraryContent(Lib, NEXT_PART); + + if (option == PREVIOUS_PART ) + ViewOneLibraryContent(Lib, PREVIOUS_PART); + +} + +/*************************************************/ +/* Routine to view one selected library content. */ +/*************************************************/ +void WinEDA_ViewlibFrame::ViewOneLibraryContent(LibraryStruct *Lib, int Flag) +{ +int NumOfParts = 0; +EDA_LibComponentStruct *LibEntry, * PreviousLibEntry; +wxString CmpName; +wxClientDC dc(DrawPanel); + + + DrawPanel->PrepareGraphicContext(&dc); + + if (Lib) NumOfParts = Lib->m_NumOfParts; + + if (NumOfParts == 0) + { + DisplayError(this, wxT("No Library or Library is empty!")); + return; + } + + if ( Lib == NULL ) return; + + PQCompFunc((PQCompFuncType) LibraryEntryCompare); + LibEntry = (EDA_LibComponentStruct *) PQFirst(&Lib->m_Entries, FALSE); + + if( Flag == NEW_PART ) + { + DisplayComponentsNamesInLib(this, Lib, CmpName, g_CurrentViewComponentName); + } + + if( Flag == NEXT_PART ) + { + LibEntry = (EDA_LibComponentStruct *) PQFirst(&Lib->m_Entries, FALSE); + while ( LibEntry ) + { + if( LibEntry->m_Name.m_Text == g_CurrentViewComponentName ) + { + LibEntry = (EDA_LibComponentStruct *) + PQNext(Lib->m_Entries, LibEntry, NULL); + break; + } + LibEntry = (EDA_LibComponentStruct *) + PQNext(Lib->m_Entries, LibEntry, NULL); + } + if(LibEntry == NULL) + LibEntry = (EDA_LibComponentStruct *) PQFirst(&Lib->m_Entries, FALSE); + if( LibEntry ) CmpName = LibEntry->m_Name.m_Text; + } + + if( Flag == PREVIOUS_PART ) + { + PreviousLibEntry = NULL; + LibEntry = (EDA_LibComponentStruct *) PQFirst(&Lib->m_Entries, FALSE); + while ( LibEntry ) + { + if( LibEntry->m_Name.m_Text == g_CurrentViewComponentName ) + { + if( PreviousLibEntry ) break; + /* else : pointage sur 1er element : + balayage de la liste et Previous pointera dernier element */ + } + + PreviousLibEntry = LibEntry; + LibEntry = (EDA_LibComponentStruct *) + PQNext(Lib->m_Entries, LibEntry, NULL); + } + if( PreviousLibEntry ) + CmpName = PreviousLibEntry->m_Name.m_Text; + } + + g_ViewUnit = 1; + g_ViewConvert = 1; + + LibEntry = FindLibPart(CmpName,Lib->m_Name, FIND_ALIAS); + g_CurrentViewComponentName = CmpName; + DisplayLibInfos(); + Zoom_Automatique(FALSE); + RedrawActiveWindow(&dc, TRUE); + + if ( m_CmpList ) + { + int id = m_CmpList->FindString(g_CurrentViewComponentName.GetData()); + if ( id >= 0 ) m_CmpList->SetSelection(id); + } + ReCreateHToolbar(); +} + + + +/*****************************************************************************/ +/* Routine d'affichage du composant selectionne */ +/* Si Le composant est un alias, le composant ROOT est recherche et affiche */ +/*****************************************************************************/ +void WinEDA_ViewlibFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg) +{ +EDA_LibComponentStruct * LibEntry = NULL; +LibCmpEntry * ViewCmpEntry = NULL; +const wxChar * RootName, * CmpName; +wxString Msg; + + ActiveScreen = GetScreen(); + + if ( * g_CurrentViewComponentName ) + { + LibEntry = FindLibPart(g_CurrentViewComponentName.GetData(), + g_CurrentViewLibraryName, FIND_ALIAS); + ViewCmpEntry = (LibCmpEntry * ) LibEntry; + } + + /* Forcage de la reinit de la brosse et plume courante */ + GRResetPenAndBrush(DC); + DC->SetBackground(*wxBLACK_BRUSH ); + DC->SetBackgroundMode(wxTRANSPARENT); + + if ( EraseBg ) DrawPanel->EraseScreen(DC); + + DrawPanel->DrawBackGround(DC); + + if( LibEntry) + { + CmpName = LibEntry->m_Name.m_Text.GetData(); + if( LibEntry->Type != ROOT) + { + RootName = ((EDA_LibCmpAliasStruct*)LibEntry)->m_RootName.GetData(); + Msg.Printf( _("Current Part: <%s> (is Alias of <%s>)"), + CmpName, RootName); + LibEntry = FindLibPart(RootName,g_CurrentViewLibraryName,FIND_ROOT); + + if( LibEntry == NULL) + { + Msg.Printf( _("Error: Root Part <%s> not found"), RootName); + DisplayError(this, Msg); + } + else + { + /* Affichage du composant ROOT, avec nom de l'alias */ + wxString RealName; + RealName = LibEntry->m_Name.m_Text; + LibEntry->m_Name.m_Text = CmpName; + if ( g_ViewUnit < 1 ) g_ViewUnit = 1; + if ( g_ViewConvert < 1 ) g_ViewConvert = 1; + DrawLibEntry(DrawPanel, DC, LibEntry, 0, 0, + g_ViewUnit, g_ViewConvert, GR_DEFAULT_DRAWMODE); + LibEntry->m_Name.m_Text = RealName; + } + } + + else + { + Msg.Printf( _("Current Part: <%s>"), ViewCmpEntry->m_Name.m_Text.GetData()); + DrawLibEntry(DrawPanel, DC, LibEntry, 0, 0, + g_ViewUnit, g_ViewConvert, GR_DEFAULT_DRAWMODE); + } + AfficheDoc(this, ViewCmpEntry->m_Doc, ViewCmpEntry->m_KeyWord); + } + + SetStatusText(Msg,0); + + DrawPanel->Trace_Curseur(DC); +} + + + diff --git a/eeschema/viewlibs_icon.ico b/eeschema/viewlibs_icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..ee2ad25ddb130fbfbb59a12abb813335dbe6c728 GIT binary patch literal 3262 zcmeHKZA?>F7{121?FSh@+>9auf}&($z!K4+P&WfkWKk#u1ks6agah&Q@#pf&)!R2!;*=ZxF1V=d*7SW_nh-Q z@7F!I#jqvtadN`oz7o4`gJCN$4BH3_CTu$>ZpS4P=03>(BLfb0c3V9>omSib7w&%L z?oJI0PmYXA2qk^7Zr%H(@b~xE>-DLLiAVQE0tMW^*|f>l=DqcvLZLtiO&AQPna8Pf z6u=U*XRoi9*M_xgA(oGqEn91EztzJ7a`>*H(dl#mM=xKZv9ZT@?^a#Cnj8}Y_|_|d z7-~r!SSX~hZC+k0SK!avV#LqSZ)|J~nav#vMY&ka&*7h79{(*Xi<^>?dN`IE9${sH z0pu-l&f?*^VKLya=FXivxbr4cnMf48XOA=C;Fj<-tyU|{&K5A4@?Us)%;RioB8x&j z`BMs;o|;T10};vJe=+#+@$rB?Gdam-Fpkk^VMj7Cnhr~T5faA+`}Fj5X>lrd-G>6Bl1}rB8tdvBBoetyW;7acwuuQ=$>Z^&qV|8bHI9;=gIneaH6v$t=pj;2P`y;z_v8sa zGc|?udNeqQdV0iJSxhpS8nypNVkm$E9XW(ZCWU>u(aqi6U8B*oDU}u1uNUU$dxz37 z#;k2jL%}uKJa{xdK7N+Pn(FJjT~UGCXJ(MWfSx}`z}3-#T3S$Tt*NHweo09Qk9YI( z<<^>-PNmYt#l^wFL9JE~4-7;`L~Ptf#E$AMXZb=YHq?I>{iz@|! zS1OgVtPBszU^vNUTZ;>WlT4z6m-j6+99_E=gwv1NqiFu zM)d}vPzbb>lao)>>e^ekpe|G@)e88g0X!W+1VVUV;7$Tzy|eRy0|($xf*u0*kVa!_ zZ!h3*Bqb%Pwzhls?p2hRU%hnc_iNW6v?`hGO_&SV-Q3)s_4cCCQKZ#Ex1$FSP;>LR zOx7h5@fnPt>2x#L_4?sw&pbUn7r#@!e#=1oInWIf0w@i05@f8 literal 0 HcmV?d00001 diff --git a/eeschema/wxprint.h b/eeschema/wxprint.h new file mode 100644 index 0000000000..80ff984549 --- /dev/null +++ b/eeschema/wxprint.h @@ -0,0 +1,89 @@ +/* + * File: printing.h + * Purpose: Printing demo for wxWindows class library +*/ + +#ifdef __GNUG__ +#pragma interface +#endif + +// Define a new application +class MyApp: public wxApp +{ + public: + MyApp() ; + bool OnInit(); + int OnExit(); + + wxFont* m_testFont; +}; + +DECLARE_APP(MyApp) + +class MyCanvas; + +// Define a new canvas and frame +class MyFrame: public wxFrame +{ + public: + MyCanvas *canvas; + MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size); + + void Draw(wxDC& dc); + + void OnSize(wxSizeEvent& event); + void OnPrint(wxCommandEvent& event); + void OnPrintPreview(wxCommandEvent& event); + void OnPrintSetup(wxCommandEvent& event); + void OnPageSetup(wxCommandEvent& event); +#if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW + void OnPrintPS(wxCommandEvent& event); + void OnPrintPreviewPS(wxCommandEvent& event); + void OnPrintSetupPS(wxCommandEvent& event); + void OnPageSetupPS(wxCommandEvent& event); +#endif + + void OnExit(wxCommandEvent& event); + void OnPrintAbout(wxCommandEvent& event); +DECLARE_EVENT_TABLE() +}; + +// Define a new canvas which can receive some events +class MyCanvas: public wxScrolledWindow +{ + public: + MyCanvas(wxFrame *frame, const wxPoint& pos, const wxSize& size, long style = wxRETAINED); + ~MyCanvas(void) ; + + virtual void OnDraw(wxDC& dc); + void OnEvent(wxMouseEvent& event); + +DECLARE_EVENT_TABLE() +}; + +class MyPrintout: public wxPrintout +{ + public: + MyPrintout(char *title = "My printout"):wxPrintout(title) {} + bool OnPrintPage(int page); + bool HasPage(int page); + bool OnBeginDocument(int startPage, int endPage); + void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo); + + void DrawPageOne(wxDC *dc); + void DrawPageTwo(wxDC *dc); +}; + +#define WXPRINT_QUIT 100 +#define WXPRINT_PRINT 101 +#define WXPRINT_PRINT_SETUP 102 +#define WXPRINT_PAGE_SETUP 103 +#define WXPRINT_PREVIEW 104 + +#define WXPRINT_PRINT_PS 105 +#define WXPRINT_PRINT_SETUP_PS 106 +#define WXPRINT_PAGE_SETUP_PS 107 +#define WXPRINT_PREVIEW_PS 108 + +#define WXPRINT_ABOUT 109 + diff --git a/eeschema/xx.cpp b/eeschema/xx.cpp new file mode 100644 index 0000000000..8cda18f0a1 --- /dev/null +++ b/eeschema/xx.cpp @@ -0,0 +1,139 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xx.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 02/03/2006 09:16:35 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 02/03/2006 09:16:35 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "xx.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes + +#include "xx.h" + +////@begin XPM images + +////@end XPM images + +/*! + * xx type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( xx, wxDialog ) + +/*! + * xx event table definition + */ + +BEGIN_EVENT_TABLE( xx, wxDialog ) + +////@begin xx event table entries +////@end xx event table entries + +END_EVENT_TABLE() + +/*! + * xx constructors + */ + +xx::xx( ) +{ +} + +xx::xx( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + Create(parent, id, caption, pos, size, style); +} + +/*! + * xx creator + */ + +bool xx::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin xx member initialisation +////@end xx member initialisation + +////@begin xx creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end xx creation + return true; +} + +/*! + * Control creation for xx + */ + +void xx::CreateControls() +{ +////@begin xx content construction + // Generated by DialogBlocks, 02/03/2006 09:16:35 (unregistered) + + xx* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + +////@end xx content construction +} + +/*! + * Should we show tooltips? + */ + +bool xx::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap xx::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin xx bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end xx bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon xx::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin xx icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end xx icon retrieval +} diff --git a/eeschema/xx.h b/eeschema/xx.h new file mode 100644 index 0000000000..e78353f3cc --- /dev/null +++ b/eeschema/xx.h @@ -0,0 +1,95 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xx.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 02/03/2006 09:16:35 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 02/03/2006 09:16:35 + +#ifndef _XX_H_ +#define _XX_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "xx.h" +#endif + +/*! + * Includes + */ + +////@begin includes +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10015 +#define SYMBOL_XX_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_XX_TITLE _("xx") +#define SYMBOL_XX_IDNAME ID_DIALOG +#define SYMBOL_XX_SIZE wxSize(400, 300) +#define SYMBOL_XX_POSITION wxDefaultPosition +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * xx class declaration + */ + +class xx: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( xx ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + xx( ); + xx( wxWindow* parent, wxWindowID id = SYMBOL_XX_IDNAME, const wxString& caption = SYMBOL_XX_TITLE, const wxPoint& pos = SYMBOL_XX_POSITION, const wxSize& size = SYMBOL_XX_SIZE, long style = SYMBOL_XX_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_XX_IDNAME, const wxString& caption = SYMBOL_XX_TITLE, const wxPoint& pos = SYMBOL_XX_POSITION, const wxSize& size = SYMBOL_XX_SIZE, long style = SYMBOL_XX_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin xx event handler declarations +////@end xx event handler declarations + +////@begin xx member function declarations + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end xx member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + +////@begin xx member variables +////@end xx member variables +}; + +#endif + // _XX_H_ diff --git a/gerbview/affiche.cpp b/gerbview/affiche.cpp new file mode 100644 index 0000000000..9324d04d4f --- /dev/null +++ b/gerbview/affiche.cpp @@ -0,0 +1,108 @@ + /**********************************************************/ + /* Routines d'affichage de parametres et caracteristiques */ + /**********************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" + +#include "protos.h" + +/* Routines locales */ + +/****************************************************************************/ +void Affiche_Infos_PCB_Texte(WinEDA_BasePcbFrame * frame, TEXTE_PCB* pt_texte) +/****************************************************************************/ +/* Affiche en bas d'ecran les caract du texte sur PCB + Entree : + pointeur de la description du texte +*/ +{ +wxString Line; + + frame->MsgPanel->EraseMsgBox(); + + if( pt_texte->m_StructType == TYPECOTATION ) + Affiche_1_Parametre(frame, 1,_("COTATION"),pt_texte->m_Text, DARKGREEN); + + else + Affiche_1_Parametre(frame, 1,_("PCB Text"),pt_texte->m_Text, DARKGREEN); + + Line = _("Layer "); Line << pt_texte->m_Layer + 1; + Affiche_1_Parametre(frame, 28, _("Layer:"), Line, g_DesignSettings.m_LayerColor[pt_texte->m_Layer] ); + + Affiche_1_Parametre(frame, 36, _("Mirror"),wxEmptyString,GREEN) ; + if( (pt_texte->m_Miroir & 1) ) + Affiche_1_Parametre(frame, -1,wxEmptyString, _("No"), DARKGREEN) ; + else Affiche_1_Parametre(frame, -1,wxEmptyString, _("Yes"), DARKGREEN) ; + + + Line.Printf( wxT("%.1f"),(float)pt_texte->m_Orient/10 ); + Affiche_1_Parametre(frame, 43,_("Orient"), Line, DARKGREEN) ; + + valeur_param(pt_texte->m_Width,Line) ; + Affiche_1_Parametre(frame, 50,_("Width"), Line,MAGENTA) ; + + valeur_param(pt_texte->m_Size.x,Line) ; + Affiche_1_Parametre(frame, 60,_("H Size"), Line,RED) ; + + valeur_param(pt_texte->m_Size.y,Line); + Affiche_1_Parametre(frame, 70,_("V Size"), Line,RED) ; + +} + + + +/*********************************************************************/ +void Affiche_Infos_Piste(WinEDA_BasePcbFrame * frame, TRACK * pt_piste) +/*********************************************************************/ +/* Affiche les caract principales d'un segment de piste en bas d'ecran */ +{ +int d_index, ii = -1; +D_CODE * pt_D_code; +int layer = frame->GetScreen()->m_Active_Layer; +wxString msg; + + frame->MsgPanel->EraseMsgBox(); + + d_index = pt_piste->m_NetCode; + pt_D_code = ReturnToolDescr(layer, d_index, &ii); + + switch(pt_piste->m_StructType) + { + case TYPETRACK: + if ( pt_piste->m_Shape < S_SPOT_CIRCLE ) msg = wxT("LINE"); + else msg = wxT("FLASH"); + break; + + case TYPEZONE: + msg = wxT("ZONE"); break; + + default: + msg = wxT("????"); break; + } + Affiche_1_Parametre(frame, 1, _("Type"), msg, DARKCYAN); + + msg.Printf( wxT("%d"), ii+1); + Affiche_1_Parametre(frame, 10, _("Tool"), msg, RED); + + if ( pt_D_code ) + { + msg.Printf( wxT("D%d"), d_index); + Affiche_1_Parametre(frame, 20, _("D CODE"),msg, BLUE); + + Affiche_1_Parametre(frame, 30, _("D type"), + pt_D_code ? g_GERBER_Tool_Type[pt_D_code->m_Shape] : _("????"), + BLUE); + } + + msg.Printf( wxT("%d"),pt_piste->m_Layer + 1); + Affiche_1_Parametre(frame, 40, _("Layer"), msg, BROWN) ; + + /* Affiche Epaisseur */ + valeur_param((unsigned)(pt_piste->m_Width), msg) ; + Affiche_1_Parametre(frame, 50, _("Width"), msg, DARKCYAN) ; +} + diff --git a/gerbview/block.cpp b/gerbview/block.cpp new file mode 100644 index 0000000000..3b86cefab9 --- /dev/null +++ b/gerbview/block.cpp @@ -0,0 +1,430 @@ + /*****************************************************************/ + /* Operations sur Blocks : deplacement, rotation, effacement ... */ + /*****************************************************************/ + + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "gerbview.h" +#include "trigo.h" + +#include "protos.h" + + +#define BLOCK_COLOR BROWN + +/* Routines Locales */ + +static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); + +static TRACK * IsSegmentInBox(DrawBlockStruct & blocklocate, TRACK * PtSegm ); + +/* Variables locales :*/ + +/*************************************************/ +int WinEDA_GerberFrame::ReturnBlockCommand(int key) +/*************************************************/ +/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to + the key (ALT, SHIFT ALT ..) +*/ +{ +int cmd = 0; + + switch ( key ) + { + default: + cmd = key & 0x255; + break; + + case 0: + cmd = BLOCK_MOVE; + break; + + case GR_KB_SHIFT: + break; + + case GR_KB_CTRL : + break; + + case GR_KB_SHIFTCTRL : + cmd = BLOCK_DELETE; + break; + + case GR_KB_ALT : + cmd = BLOCK_COPY; + break; + + case MOUSE_MIDDLE: + cmd = BLOCK_ZOOM; + break; + } + + return cmd ; +} + + +/*****************************************************/ +void WinEDA_GerberFrame::HandleBlockPlace(wxDC * DC) +/*****************************************************/ +/* Routine to handle the BLOCK PLACE commande */ +{ +bool err = FALSE; + + if(DrawPanel->ManageCurseur == NULL) + { + err = TRUE; + DisplayError(this, wxT("Error in HandleBlockPLace : ManageCurseur = NULL") ); + } + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + + switch(GetScreen()->BlockLocate.m_Command ) + { + case BLOCK_IDLE: + err = TRUE; + break; + + case BLOCK_DRAG: /* Drag */ + case BLOCK_MOVE: /* Move */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + if ( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur(DrawPanel,DC, FALSE); + Block_Move(DC); + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + break; + + case BLOCK_COPY: /* Copy */ + if ( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + Block_Duplicate(DC); + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + break; + + case BLOCK_PASTE: + break; + + case BLOCK_ZOOM: // Handle by HandleBlockEnd() + case BLOCK_ROTATE: + case BLOCK_INVERT: + case BLOCK_DELETE: + case BLOCK_SAVE: + case BLOCK_ABORT: + case BLOCK_SELECT_ITEMS_ONLY: + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: + break; + } + + GetScreen()->SetModify(); + + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->BlockLocate.m_Flags = 0; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + if ( GetScreen()->BlockLocate.m_BlockDrawStruct ) + { + DisplayError(this, wxT("Error in HandleBlockPLace DrawStruct != NULL") ); + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + } + + DisplayToolMsg(wxEmptyString); +} + +/**********************************************/ +int WinEDA_GerberFrame::HandleBlockEnd(wxDC * DC) +/**********************************************/ +/* Routine de gestion de la commande BLOCK END + returne : + 0 si aucun compos ant selectionne + 1 sinon + -1 si commande terminée et composants trouvés (block delete, block save) +*/ +{ +int endcommande = TRUE; +bool zoom_command = FALSE; + +if(DrawPanel->ManageCurseur ) + + switch( GetScreen()->BlockLocate.m_Command ) + { + case BLOCK_IDLE: + DisplayError(this, wxT("Error in HandleBlockPLace")); + break; + + case BLOCK_DRAG: /* Drag (not used, for future enhancements)*/ + case BLOCK_MOVE: /* Move */ + case BLOCK_COPY: /* Copy */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; + endcommande = FALSE; + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + DrawPanel->ManageCurseur(DrawPanel,DC, FALSE); + break; + + case BLOCK_DELETE: /* Delete */ + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + DrawPanel->ManageCurseur(DrawPanel,DC, FALSE); + Block_Delete(DC); + break; + + case BLOCK_ROTATE: /* Unused */ + break; + + case BLOCK_INVERT: /* Fip */ + break; + + case BLOCK_SAVE: /* Save (not used)*/ + break; + + case BLOCK_PASTE: break; + + case BLOCK_ZOOM: /* Window Zoom */ + zoom_command = TRUE; + break; + + case BLOCK_ABORT: + case BLOCK_SELECT_ITEMS_ONLY: + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: + break; + } + + if ( endcommande == TRUE ) + { + GetScreen()->BlockLocate.m_Flags = 0; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + DisplayToolMsg(wxEmptyString); + } + + if ( zoom_command ) + Window_Zoom( GetScreen()->BlockLocate ); + + return(endcommande); +} + + +/**************************************************************************/ +static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/**************************************************************************/ +/* Retrace le contour du block de repositionnement des structures a déplacer + */ +{ +int Color; +BASE_SCREEN * screen = panel->GetScreen(); + + Color = YELLOW; GRSetDrawMode(DC, g_XorMode); + + /* Effacement ancien cadre */ + if( erase ) + { + screen->BlockLocate.Draw(panel, DC); + if ( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y ) + { + screen->BlockLocate.Offset(screen->BlockLocate.m_MoveVector); + screen->BlockLocate.Draw(panel, DC); + screen->BlockLocate.Offset(-screen->BlockLocate.m_MoveVector.x, -screen->BlockLocate.m_MoveVector.y); + } + } + + if ( panel->m_Parent->GetScreen()->BlockLocate.m_State != STATE_BLOCK_STOP ) + { + screen->BlockLocate.m_MoveVector.x = screen->m_Curseur.x - screen->BlockLocate.GetRight(); + screen->BlockLocate.m_MoveVector.y = screen->m_Curseur.y - screen->BlockLocate.GetBottom(); + } + + screen->BlockLocate.Draw(panel, DC); + if ( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y ) + { + screen->BlockLocate.Offset(screen->BlockLocate.m_MoveVector); + screen->BlockLocate.Draw(panel, DC); + screen->BlockLocate.Offset(-screen->BlockLocate.m_MoveVector.x, -screen->BlockLocate.m_MoveVector.y); + } +} + + + +/************************************************/ +void WinEDA_BasePcbFrame::Block_Delete(wxDC *DC) +/************************************************/ +/* + routine d'effacement du block deja selectionne +*/ +{ + if ( !IsOK(this, _("Ok to delete block ?") ) ) return; + + GetScreen()->SetModify(); + GetScreen()->BlockLocate.Normalize(); + GetScreen()->m_CurrentItem = NULL; + + /* Effacement des Pistes */ + TRACK * pt_segm, * NextS; + for ( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = NextS) + { + NextS = pt_segm->Next(); + if( IsSegmentInBox(GetScreen()->BlockLocate, pt_segm ) ) + { /* la piste est ici bonne a etre efface */ + pt_segm->Draw(DrawPanel, DC, GR_XOR) ; + DeleteStructure(pt_segm); + } + } + + + /* Effacement des Zones */ + for ( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS) + { + NextS = pt_segm->Next(); + if( IsSegmentInBox(GetScreen()->BlockLocate, pt_segm ) ) + {/* la piste est ici bonne a etre efface */ + pt_segm->Draw(DrawPanel, DC, GR_XOR) ; + DeleteStructure(pt_segm); + } + } + + /* Rafraichissement de l'ecran : */ + RedrawActiveWindow(DC, TRUE); +} + + +/************************************************/ +void WinEDA_BasePcbFrame::Block_Move(wxDC * DC) +/************************************************/ +/* + routine de deplacement des elements du block deja selectionne +*/ +{ +int deltaX, deltaY; +wxPoint oldpos; + + oldpos = GetScreen()->m_Curseur; + DrawPanel->ManageCurseur = NULL; + + GetScreen()->m_Curseur = oldpos; + DrawPanel->MouseToCursorSchema(); + GetScreen()->SetModify(); + GetScreen()->BlockLocate.Normalize(); + + /* calcul du vecteur de deplacement pour les deplacements suivants */ + deltaX = GetScreen()->BlockLocate.m_MoveVector.x ; + deltaY = GetScreen()->BlockLocate.m_MoveVector.y ; + +/* Deplacement des Segments de piste */ + TRACK * track; + track = m_Pcb->m_Track; + while( track ) + { + if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + m_Pcb->m_Status_Pcb = 0 ; + track->Draw(DrawPanel, DC, GR_XOR) ; // effacement + track->m_Start.x += deltaX ; track->m_Start.y += deltaY ; + track->m_End.x += deltaX ; track->m_End.y += deltaY ; + track->m_Param += deltaX ; track->m_Sous_Netcode += deltaY ; + track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage + } + track = (TRACK*) track->Pnext; + } + + /* Deplacement des Segments de Zone */ + track = (TRACK*)m_Pcb->m_Zone; + while( track ) + { + if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + track->Draw(DrawPanel, DC, GR_XOR) ; // effacement + track->m_Start.x += deltaX ; track->m_Start.y += deltaY ; + track->m_End.x += deltaX ; track->m_End.y += deltaY ; + track->m_Param += deltaX ; track->m_Sous_Netcode += deltaY ; + track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage + } + track = (TRACK*) track->Pnext; + } + + DrawPanel->Refresh(TRUE); +} + + +/**************************************************/ +void WinEDA_BasePcbFrame::Block_Duplicate(wxDC * DC) +/**************************************************/ +/* + routine de duplication des elements du block deja selectionne +*/ +{ +int deltaX, deltaY; +wxPoint oldpos; + + oldpos = GetScreen()->m_Curseur; + DrawPanel->ManageCurseur = NULL; + + GetScreen()->m_Curseur = oldpos; + DrawPanel->MouseToCursorSchema(); + GetScreen()->SetModify(); + GetScreen()->BlockLocate.Normalize(); + + + /* calcul du vecteur de deplacement pour les deplacements suivants */ + deltaX = GetScreen()->BlockLocate.m_MoveVector.x ; + deltaY = GetScreen()->BlockLocate.m_MoveVector.y ; + + /* Deplacement des Segments de piste */ + TRACK * track, *next_track, *new_track; + + track = m_Pcb->m_Track; + while( track ) + { + next_track = track->Next(); + if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + m_Pcb->m_Status_Pcb = 0 ; + new_track = track->Copy(1); + new_track->Insert(m_Pcb,NULL); + new_track->m_Start.x += deltaX ; new_track->m_Start.y += deltaY ; + new_track->m_End.x += deltaX ; new_track->m_End.y += deltaY ; + new_track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage + } + track = next_track; + } + + /* Deplacement des Segments de Zone */ + track = (TRACK*)m_Pcb->m_Zone; + while( track ) + { + next_track = track->Next(); + if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + new_track = new TRACK(m_Pcb); + new_track = track->Copy(1); + new_track->Insert(m_Pcb,NULL); + new_track->m_Start.x += deltaX ; new_track->m_Start.y += deltaY ; + new_track->m_End.x += deltaX ; new_track->m_End.y += deltaY ; + new_track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage + } + track = next_track; + } +} + + +/**************************************************************************/ +static TRACK * IsSegmentInBox( DrawBlockStruct & blocklocate, TRACK * PtSegm ) +/**************************************************************************/ +/* Teste si la structure PtStruct est inscrite dans le block selectionne + Retourne PtSegm si oui + NULL si non +*/ +{ + if ( blocklocate.Inside(PtSegm->m_Start.x ,PtSegm->m_Start.y) ) + return ( PtSegm ); + + if ( blocklocate.Inside(PtSegm->m_End.x, PtSegm->m_End.y) ) + return ( PtSegm ); + + return ( NULL ); +} + diff --git a/gerbview/cfg.cpp b/gerbview/cfg.cpp new file mode 100644 index 0000000000..8d9c525e04 --- /dev/null +++ b/gerbview/cfg.cpp @@ -0,0 +1,113 @@ + /******************************************/ + /** cfg.cpp : configuration pour Gerbview */ + /******************************************/ + +/* lit ou met a jour la configuration de PCBNEW */ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" +#include "cfg.h" +#include "id.h" + +#include "protos.h" + +/* Routines Locales */ + +/* Variables locales */ + +/*************************************************************/ +void WinEDA_GerberFrame::Process_Config(wxCommandEvent& event) +/*************************************************************/ +{ +int id = event.GetId(); +wxPoint pos; + + pos = GetPosition(); + pos.x += 20; pos.y += 20; + + switch( id ) + { + case ID_COLORS_SETUP : + DisplayColorSetupFrame(this, pos); + break; + + case ID_CONFIG_REQ : // Creation de la fenetre de configuration + { + InstallConfigFrame(pos); + break; + } + + case ID_PCB_TRACK_SIZE_SETUP: + case ID_PCB_LOOK_SETUP: + case ID_OPTIONS_SETUP: + InstallPcbOptionsFrame(pos, id); + break; + + case ID_CONFIG_SAVE: + Update_config(); + break; + + default: + DisplayError(this, wxT("WinEDA_GerberFrame::Process_Config internal error")); + } +} + + +/*****************************************************/ +bool Read_Config(void) +/*****************************************************/ +/* lit la configuration, si elle n'a pas deja etee lue + 1 - lit gerbview.cnf + 2 - si non trouve lit /gerbview.cnf + 3 - si non trouve: init des variables aux valeurs par defaut + + Retourne un pointeur su le message d'erreur a afficher +*/ +{ + g_Prj_Config_Filename_ext = wxT(".cnf"); + EDA_Appl->ReadProjectConfig( wxT("gerbview"), GROUP, ParamCfgList, FALSE); + + /* Inits autres variables */ + if (ScreenPcb) ScreenPcb->SetGrid(TmpGrid); + if ( g_PhotoFilenameExt.IsEmpty() ) g_PhotoFilenameExt = wxT(".pho"); + if ( g_DrillFilenameExt.IsEmpty() ) g_DrillFilenameExt = wxT(".drl"); + if ( g_PenFilenameExt.IsEmpty() ) g_PenFilenameExt = wxT(".pen"); + + return TRUE; +} + + + +/******************************************/ +void WinEDA_GerberFrame::Update_config(void) +/******************************************/ +/* + creation du fichier de config +*/ +{ +wxString FullFileName; +wxString mask( wxT("*") ), + + g_Prj_Config_Filename_ext = wxT(".cnf";) + mask += g_Prj_Config_Filename_ext; + FullFileName = wxT("gerbview"); + ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); + + FullFileName = EDA_FileSelector(_("Save config file"), + wxEmptyString, /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + g_Prj_Config_Filename_ext, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + TRUE + ); + if ( FullFileName.IsEmpty() ) return; + + /* ecriture de la configuration */ + EDA_Appl->WriteProjectConfig(FullFileName, GROUP, ParamCfgList); +} + diff --git a/gerbview/cfg.h b/gerbview/cfg.h new file mode 100644 index 0000000000..fbcfc587e3 --- /dev/null +++ b/gerbview/cfg.h @@ -0,0 +1,590 @@ + /**********************************************************/ + /** cfg.h : configuration: definition des structures **/ + /**********************************************************/ +#define GROUP wxT("/gerbview") +#define GROUPLIB wxT("libraries") + +#define INSETUP TRUE + +static int Pcbdiv_grille; /* memorisation temporaire */ +static wxSize TmpGrid; /* memorisation temporaire */ + +/* Liste des parametres */ + +static PARAM_CFG_WXSTRING PhotoExtBufCfg +( + wxT("PhoExt"), /* identification */ + &g_PhotoFilenameExt /* Adresse du parametre */ +); + +static PARAM_CFG_WXSTRING PenExtBufCfg +( + wxT("PenExt"), /* identification */ + &g_PenFilenameExt /* Adresse du parametre */ +); + +static PARAM_CFG_WXSTRING DrillExtBufCfg +( + wxT("DrilExt"), /* identification */ + &g_DrillFilenameExt /* Adresse du parametre */ +); + +static PARAM_CFG_INT UnitCfg // Unites; 0 inche, 1 mm +( + wxT("Unite"), /* identification */ + &g_UnitMetric, /* Adresse du parametre */ + FALSE /* Valeur par defaut */ +); + +static PARAM_CFG_INT GerberScaleCfg // default scale; 0 2.3, 1 3.4 +( + wxT("Def_fmt"), /* identification */ + &g_Default_GERBER_Format, /* Adresse du parametre */ + 23, /* Valeur par defaut */ + 23, 66 /* Valeurs extremes */ +); + +static PARAM_CFG_BOOL SegmFillCfg +( + INSETUP, + wxT("SegFill"), /* identification */ + &DisplayOpt.DisplayPcbTrackFill, /* Adresse du parametre */ + TRUE /* Valeur par defaut */ +); + + +static PARAM_CFG_BOOL PadFillCfg +( + INSETUP, + wxT("PadFill"), /* identification */ + &DisplayOpt.DisplayPadFill, /* Adresse du parametre */ + TRUE /* Valeur par defaut */ +); + +static PARAM_CFG_BOOL PadShowNumCfg // Affiche DCodes +( + INSETUP, + wxT("PadSNum"), /* identification */ + &DisplayOpt.DisplayPadNum, /* Adresse du parametre */ + TRUE /* Valeur par defaut */ +); + +static PARAM_CFG_INT AfficheTextePcbCfg +( + wxT("PcbAffT"), /* identification */ + &DisplayOpt.DisplayDrawItems, /* Adresse du parametre */ + FILAIRE, /* Valeur par defaut */ + 0, 2 /* Valeurs extremes */ +); + +static PARAM_CFG_INT PcbTextWidthCfg +( + wxT("TxtLar"), /* identification */ + &g_DesignSettings.m_PcbTextWidth, /* Adresse du parametre */ + 120, /* Valeur par defaut */ + 0,0xFFFF /* Valeurs extremes */ +); + +static PARAM_CFG_INT TextePcbDimVCfg +( + wxT("TxtPcbV"), /* identification */ + &g_DesignSettings.m_PcbTextSize.y, /* Adresse du parametre */ + 800, /* Valeur par defaut */ + 0, 0x7FFF /* Valeurs extremes */ +); + +static PARAM_CFG_INT TextePcbDimHCfg +( + wxT("TxtPcbH"), /* identification */ + &g_DesignSettings.m_PcbTextSize.x, /* Adresse du parametre */ + 600, /* Valeur par defaut */ + 0, 0x7FFF /* Valeurs extremes */ +); + +static PARAM_CFG_INT ScreenPcbGrilleXCfg +( + wxT("PcbGridX"), /* identification */ + &TmpGrid.x, /* Adresse du parametre */ + 500, /* Valeur par defaut */ + 1,10000 /* Valeurs extremes */ +); + +static PARAM_CFG_INT ScreenPcbGrilleYCfg +( + wxT("PcbGridY"), /* identification */ + &TmpGrid.y, /* Adresse du parametre */ + 500, /* Valeur par defaut */ + 1,10000 /* Valeurs extremes */ +); + +static PARAM_CFG_SETCOLOR ColorLayer0Cfg +( + INSETUP, + wxT("ColLay0"), /* identification */ + &g_DesignSettings.m_LayerColor[0], /* Adresse du parametre */ + GREEN /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer1Cfg +( + INSETUP, + wxT("ColLay1"), /* identification */ + &g_DesignSettings.m_LayerColor[1], /* Adresse du parametre */ + BLUE /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer2Cfg +( + INSETUP, + wxT("ColLay2"), /* identification */ + &g_DesignSettings.m_LayerColor[2], /* Adresse du parametre */ + LIGHTGRAY /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer3Cfg +( + INSETUP, + wxT("ColLay3"), /* identification */ + &g_DesignSettings.m_LayerColor[3], /* Adresse du parametre */ + 5 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer4Cfg +( + INSETUP, + wxT("ColLay4"), /* identification */ + &g_DesignSettings.m_LayerColor[4], /* Adresse du parametre */ + 4 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer5Cfg +( + INSETUP, + wxT("ColLay5"), /* identification */ + &g_DesignSettings.m_LayerColor[5], /* Adresse du parametre */ + 5 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer6Cfg +( + INSETUP, + wxT("ColLay6"), /* identification */ + &g_DesignSettings.m_LayerColor[6], /* Adresse du parametre */ + 6 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer7Cfg +( + INSETUP, + wxT("ColLay7"), /* identification */ + &g_DesignSettings.m_LayerColor[7], /* Adresse du parametre */ + 5 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer8Cfg +( + INSETUP, + wxT("ColLay8"), /* identification */ + &g_DesignSettings.m_LayerColor[8], /* Adresse du parametre */ + 7 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer9Cfg +( + INSETUP, + wxT("ColLay9"), /* identification */ + &g_DesignSettings.m_LayerColor[9], /* Adresse du parametre */ + 1 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer10Cfg +( + INSETUP, + wxT("ColLayA"), /* identification */ + &g_DesignSettings.m_LayerColor[10], /* Adresse du parametre */ + 2 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer11Cfg +( + INSETUP, + wxT("ColLayB"), /* identification */ + &g_DesignSettings.m_LayerColor[11], /* Adresse du parametre */ + 3 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer12Cfg +( + INSETUP, + wxT("ColLayC"), /* identification */ + &g_DesignSettings.m_LayerColor[12], /* Adresse du parametre */ + 12 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer13Cfg +( + INSETUP, + wxT("ColLayD"), /* identification */ + &g_DesignSettings.m_LayerColor[13], /* Adresse du parametre */ + 13 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer14Cfg +( + INSETUP, + wxT("ColLayE"), /* identification */ + &g_DesignSettings.m_LayerColor[14], /* Adresse du parametre */ + 14 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer15Cfg +( + INSETUP, + wxT("ColLayF"), /* identification */ + &g_DesignSettings.m_LayerColor[15], /* Adresse du parametre */ + RED /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer16Cfg +( + INSETUP, + wxT("ColLayG"), /* identification */ + &g_DesignSettings.m_LayerColor[16], /* Adresse du parametre */ + 1 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer17Cfg +( + INSETUP, + wxT("ColLayH"), /* identification */ + &g_DesignSettings.m_LayerColor[17], /* Adresse du parametre */ + 5 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer18Cfg +( + INSETUP, + wxT("ColLayI"), /* identification */ + &g_DesignSettings.m_LayerColor[18], /* Adresse du parametre */ + 11 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer19Cfg +( + INSETUP, + wxT("ColLayJ"), /* identification */ + &g_DesignSettings.m_LayerColor[19], /* Adresse du parametre */ + 4 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer20Cfg +( + INSETUP, + wxT("ColLayK"), /* identification */ + &g_DesignSettings.m_LayerColor[20], /* Adresse du parametre */ + 5 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer21Cfg +( + INSETUP, + wxT("ColLayL"), /* identification */ + &g_DesignSettings.m_LayerColor[21], /* Adresse du parametre */ + 3 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer22Cfg +( + INSETUP, + wxT("ColLayM"), /* identification */ + &g_DesignSettings.m_LayerColor[22], /* Adresse du parametre */ + 6 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer23Cfg +( + INSETUP, + wxT("ColLayN"), /* identification */ + &g_DesignSettings.m_LayerColor[23], /* Adresse du parametre */ + 5 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer24Cfg +( + INSETUP, + wxT("ColLayO"), /* identification */ + &g_DesignSettings.m_LayerColor[24], /* Adresse du parametre */ + LIGHTGRAY /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer25Cfg +( + INSETUP, + wxT("ColLayP"), /* identification */ + &g_DesignSettings.m_LayerColor[25], /* Adresse du parametre */ + 1 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer26Cfg +( + INSETUP, + wxT("ColLayQ"), /* identification */ + &g_DesignSettings.m_LayerColor[26], /* Adresse du parametre */ + 2 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer27Cfg +( + INSETUP, + wxT("ColLayR"), /* identification */ + &g_DesignSettings.m_LayerColor[27], /* Adresse du parametre */ + 14 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer28Cfg +( + INSETUP, + wxT("ColLayS"), /* identification */ + &g_DesignSettings.m_LayerColor[28], /* Adresse du parametre */ + YELLOW /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer29Cfg +( + INSETUP, + wxT("ColLayT"), /* identification */ + &g_DesignSettings.m_LayerColor[29], /* Adresse du parametre */ + 13 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer30Cfg +( + INSETUP, + wxT("ColLayU"), /* identification */ + &g_DesignSettings.m_LayerColor[30], /* Adresse du parametre */ + 14 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer31Cfg +( + INSETUP, + wxT("ColLayV"), /* identification */ + &g_DesignSettings.m_LayerColor[31], /* Adresse du parametre */ + 7 /* Valeur par defaut */ +); + + +static PARAM_CFG_SETCOLOR ColorpcbGrilleCfg +( + INSETUP, + wxT("CoPcbGr"), /* identification */ + &g_DesignSettings.m_PcbGridColor, /* Adresse du parametre */ + DARKGRAY /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorDCodesCfg +( + INSETUP, + wxT("CoDCode"), /* identification */ + &g_DCodesColor, /* Adresse du parametre */ + WHITE /* Valeur par defaut */ +); + +static PARAM_CFG_INT HPGLpenNumCfg +( + wxT("HPGLnum"), /* identification */ + &HPGL_Pen_Num, /* Adresse du parametre */ + 1, /* Valeur par defaut */ + 1, 16 /* Valeurs extremes */ +); + +static PARAM_CFG_INT HPGLdiamCfg +( + wxT("HPGdiam"), /* identification */ + &HPGL_Pen_Diam, /* Adresse du parametre */ + 15, /* Valeur par defaut */ + 0,0xFFFF /* Valeurs extremes */ +); + +static PARAM_CFG_INT HPGLspeedCfg +( + wxT("HPGLSpd"), /* identification */ + &HPGL_Pen_Speed, /* Adresse du parametre */ + 25, /* Valeur par defaut */ + 0,100 /* Valeurs extremes */ +); + +static PARAM_CFG_INT HPGLrecouvrementCfg +( + wxT("HPGLrec"), /* identification */ + &HPGL_Pen_Recouvrement, /* Adresse du parametre */ + 2, /* Valeur par defaut */ + 0, 100 /* Valeurs extremes */ +); + +static PARAM_CFG_INT GERBERSpotMiniCfg +( + wxT("GERBmin"), /* identification */ + &g_Plot_Spot_Mini, /* Adresse du parametre */ + 15, /* Valeur par defaut */ + 2,0xFFFF /* Valeurs extremes */ +); + +static PARAM_CFG_INT DrawSegmLargeurCfg +( + wxT("DrawLar"), /* identification */ + &g_DesignSettings.m_DrawSegmentWidth, /* Adresse du parametre */ + 120, /* Valeur par defaut */ + 0,10000 /* Valeurs extremes */ +); + +static PARAM_CFG_INT EdgeSegmLargeurCfg +( + wxT("EdgeLar"), /* identification */ + &g_DesignSettings.m_EdgeSegmentWidth, /* Adresse du parametre */ + 120, /* Valeur par defaut */ + 0,10000 /* Valeurs extremes */ +); + +static PARAM_CFG_INT FormatPlotCfg +( + wxT("ForPlot"), /* identification */ + &format_plot, /* Adresse du parametre */ + 1, /* Valeur par defaut */ + 0,3 /* Valeurs extremes */ +); + +static PARAM_CFG_INT WTraitSerigraphiePlotCfg // Epaiss Trait Serigraphie(mils) +( + wxT("WpenSer"), /* identification */ + &W_Trait_Serigraphie, /* Adresse du parametre */ + 12, /* Valeur par defaut */ + 0,1000 /* Valeurs extremes */ +); + +static PARAM_CFG_DOUBLE UserGrilleXCfg +( + wxT("UserGrX"), /* identification */ + &g_UserGrid.x, /* Adresse du parametre */ + 100.0, /* Valeur par defaut */ + 0.0,10000.0 /* Valeurs extremes */ +); + +static PARAM_CFG_DOUBLE UserGrilleYCfg +( + wxT("UserGrY"), /* identification */ + &g_UserGrid.y, /* Adresse du parametre */ + 100.0, /* Valeur par defaut */ + 0.0,10000.0 /* Valeurs extremes */ +); + +static PARAM_CFG_INT UserGrilleUnitCfg // USER Grid Unit (inches/mm) +( + wxT("UserGrU"), /* identification */ + &g_UserGrid_Unit, /* Adresse du parametre */ + 1, /* Valeur par defaut */ + 0, 1 /* Valeurs extremes */ +); + +static PARAM_CFG_INT DivGrillePcbCfg +( + wxT("DivGrPc"), /* identification */ + &Pcbdiv_grille, /* Adresse du parametre */ + 1, /* Valeur par defaut */ + 1,10 /* Valeurs extremes */ +); + +static PARAM_CFG_INT TimeOutCfg +( + wxT("TimeOut"), /* identification */ + &g_TimeOut, /* Adresse du parametre */ + 600, /* Valeur par defaut */ + 0,60000 /* Valeurs extremes */ +); + +static PARAM_CFG_BOOL DisplPolairCfg +( + INSETUP, + wxT("DPolair"), /* identification */ + &DisplayOpt.DisplayPolarCood, /* Adresse du parametre */ + FALSE /* Valeur par defaut */ +); + +static PARAM_CFG_INT CursorShapeCfg +( + INSETUP, + wxT("CuShape"), /* identification */ + &g_CursorShape, /* Adresse du parametre */ + 0, /* Valeur par defaut */ + 0, 1 /* Valeurs extremes */ +); + +static PARAM_CFG_BASE * ParamCfgList[] = +{ + & PhotoExtBufCfg, + & PenExtBufCfg, + & DrillExtBufCfg, + & UnitCfg, + & GerberScaleCfg, + & SegmFillCfg, + & PadFillCfg, + & PadShowNumCfg, + & AfficheTextePcbCfg, + & TextePcbDimVCfg, + & PcbTextWidthCfg, + & TextePcbDimHCfg, + & ScreenPcbGrilleXCfg, + & ScreenPcbGrilleYCfg, + & ColorLayer0Cfg, + & ColorLayer1Cfg, + & ColorLayer2Cfg, + & ColorLayer3Cfg, + & ColorLayer4Cfg, + & ColorLayer5Cfg, + & ColorLayer6Cfg, + & ColorLayer7Cfg, + & ColorLayer8Cfg, + & ColorLayer9Cfg, + & ColorLayer10Cfg, + & ColorLayer11Cfg, + & ColorLayer12Cfg, + & ColorLayer13Cfg, + & ColorLayer14Cfg, + & ColorLayer15Cfg, + & ColorLayer16Cfg, + & ColorLayer17Cfg, + & ColorLayer18Cfg, + & ColorLayer19Cfg, + & ColorLayer20Cfg, + & ColorLayer21Cfg, + & ColorLayer22Cfg, + & ColorLayer23Cfg, + & ColorLayer24Cfg, + & ColorLayer25Cfg, + & ColorLayer26Cfg, + & ColorLayer27Cfg, + & ColorLayer28Cfg, + & ColorLayer29Cfg, + & ColorLayer30Cfg, + & ColorLayer31Cfg, + & ColorpcbGrilleCfg, + & ColorDCodesCfg, + & HPGLpenNumCfg, + & HPGLdiamCfg, + & HPGLspeedCfg, + & HPGLrecouvrementCfg, + & GERBERSpotMiniCfg, + & DrawSegmLargeurCfg, + & EdgeSegmLargeurCfg, + & FormatPlotCfg, + & WTraitSerigraphiePlotCfg, + & UserGrilleXCfg, + & UserGrilleYCfg, + & UserGrilleUnitCfg, + & DivGrillePcbCfg, + & TimeOutCfg, + & DisplPolairCfg, + & CursorShapeCfg, + NULL +}; + diff --git a/gerbview/controle.cpp b/gerbview/controle.cpp new file mode 100644 index 0000000000..64284bdc5e --- /dev/null +++ b/gerbview/controle.cpp @@ -0,0 +1,198 @@ + /********************************************************/ + /* Routines generales de gestion des commandes usuelles */ + /********************************************************/ + + /* fichier controle.cpp */ +/* + Routines d'affichage grille, Boite de coordonnees, Curseurs, marqueurs ... +*/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" + +#include "id.h" +#include "protos.h" + +/* Routines Locales : */ + +/* Variables Locales */ + + +/**********************************************************************/ +EDA_BaseStruct * WinEDA_GerberFrame::GerberGeneralLocateAndDisplay(void) +/**********************************************************************/ +{ + return Locate(CURSEUR_OFF_GRILLE); +} + + + +/****************************************************************/ +void WinEDA_BasePcbFrame::GeneralControle(wxDC *DC, wxPoint Mouse) +/****************************************************************/ +/* traitement des touches de fonctions utilisees ds tous les menus + Zoom + Redessin d'ecran + Cht Unites + Cht couches + Remise a 0 de l'origine des coordonnees relatives +*/ +{ +wxSize delta; +wxPoint curpos, oldpos; +int hotkey = 0; + + if( GetScreen()->IsRefreshReq() ) + { + RedrawActiveWindow(DC, TRUE); + // We must return here, instead of proceeding. + // If we let the cursor move during a refresh request, + // the cursor be displayed in the wrong place + // during delayed repaint events that occur when + // you move the mouse when a message dialog is on + // the screen, and then you dismiss the dialog by + // typing the Enter key. + return; + } + + curpos = DrawPanel->CursorRealPosition(Mouse); + oldpos = GetScreen()->m_Curseur; + + delta.x = GetScreen()->GetGrid().x / GetScreen()->GetZoom(); + delta.y = GetScreen()->GetGrid().y / GetScreen()->GetZoom(); + if( delta.x == 0 ) delta.x = 1; + if( delta.y == 0 ) delta.y = 1; + + switch(g_KeyPressed) + { + case WXK_NUMPAD_SUBTRACT : + case WXK_SUBTRACT : + case '-' : + if(GetScreen()->m_Active_Layer > 0) + GetScreen()->m_Active_Layer--; + break ; + + case WXK_NUMPAD_ADD : + case WXK_ADD : + case '+' : + if(GetScreen()->m_Active_Layer < 31) + GetScreen()->m_Active_Layer ++; + break ; + + case 'F' | GR_KB_CTRL : + case 'f' | GR_KB_CTRL : + DisplayOpt.DisplayPcbTrackFill ^= 1; DisplayOpt.DisplayPcbTrackFill &= 1 ; + GetScreen()->SetRefreshReq(); + break ; + + case ' ' : /* Mise a jour de l'origine des coord relatives */ + GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; + break ; + + + case 'U' | GR_KB_CTRL : + case 'u' | GR_KB_CTRL : + if (g_UnitMetric == INCHES ) g_UnitMetric = MILLIMETRE ; + else g_UnitMetric = INCHES ; + break ; + + case EDA_PANNING_UP_KEY : + OnZoom(ID_ZOOM_PANNING_UP); + curpos = m_CurrentScreen->m_Curseur; + break; + + case EDA_PANNING_DOWN_KEY : + OnZoom(ID_ZOOM_PANNING_DOWN); + curpos = m_CurrentScreen->m_Curseur; + break; + + case EDA_PANNING_LEFT_KEY : + OnZoom(ID_ZOOM_PANNING_LEFT); + curpos = m_CurrentScreen->m_Curseur; + break; + + case EDA_PANNING_RIGHT_KEY : + OnZoom(ID_ZOOM_PANNING_RIGHT); + curpos = m_CurrentScreen->m_Curseur; + break; + + case WXK_F1 : + OnZoom(ID_ZOOM_PLUS_KEY); + curpos = GetScreen()->m_Curseur; + break; + + case WXK_F2 : + OnZoom(ID_ZOOM_MOINS_KEY); + curpos = GetScreen()->m_Curseur; + break; + + case WXK_F3 : + OnZoom(ID_ZOOM_REDRAW_KEY); + break; + + case WXK_F4 : + OnZoom(ID_ZOOM_CENTER_KEY); + curpos = GetScreen()->m_Curseur; + break; + + case WXK_NUMPAD8 : /* Deplacement curseur vers le haut */ + case WXK_UP : + Mouse.y -= delta.y; + DrawPanel->MouseTo(Mouse); + break ; + + case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ + case WXK_DOWN: + Mouse.y += delta.y; + DrawPanel->MouseTo(Mouse); + break ; + + case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ + case WXK_LEFT : + Mouse.x -= delta.x; + DrawPanel->MouseTo(Mouse); + break ; + + case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ + case WXK_RIGHT : + Mouse.x += delta.x; + DrawPanel->MouseTo(Mouse); + break ; + + default: hotkey = g_KeyPressed; + break; + } + + /* Recalcul de la position du curseur schema */ + GetScreen()->m_Curseur = curpos; + /* Placement sur la grille generale */ + PutOnGrid( & GetScreen()->m_Curseur); + + if ( (oldpos.x != GetScreen()->m_Curseur.x) || + (oldpos.y != GetScreen()->m_Curseur.y) ) + { + curpos = GetScreen()->m_Curseur; + GetScreen()->m_Curseur = oldpos; + DrawPanel->CursorOff(DC); + + GetScreen()->m_Curseur = curpos; + DrawPanel->CursorOn(DC); + + if(DrawPanel->ManageCurseur) + { + DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); + } + } + + SetToolbars(); + Affiche_Status_Box(); /* Affichage des coord curseur */ + + if ( hotkey ) + { + OnHotKey(DC, hotkey, NULL); + } +} + + diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp new file mode 100644 index 0000000000..6942b5b571 --- /dev/null +++ b/gerbview/dcode.cpp @@ -0,0 +1,481 @@ + /********************************************************/ + /**** Routine de lecture et visu d'un fichier GERBER ****/ + /********************************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" + +#include "protos.h" + +#define DEFAULT_SIZE 100 + +/* Format Gerber : NOTES : +Fonctions preparatoires: + Gn = + G01 interpolation lineaire ( trace de droites ) + G02,G20,G21 Interpolation circulaire , sens trigo < 0 + G03,G30,G31 Interpolation circulaire , sens trigo > 0 + G04 commentaire + G06 Interpolation parabolique + G07 Interpolation cubique + G10 interpolation lineaire ( echelle 10x ) + G11 interpolation lineaire ( echelle 0.1x ) + G12 interpolation lineaire ( echelle 0.01x ) + G52 plot symbole reference par Dnn code + G53 plot symbole reference par Dnn ; symbole tourne de -90 degres + G54 Selection d'outil + G55 Mode exposition photo + G56 plot symbole reference par Dnn A code + G57 affiche le symbole reference sur la console + G58 plot et affiche le symbole reference sur la console + G60 interpolation lineaire ( echelle 100x ) + G70 Unites = Inches + G71 Unites = Millimetres + G74 supprime interpolation circulaire sur 360 degre, revient a G01 + G75 Active interpolation circulaire sur 360 degre + G90 Mode Coordonnees absolues + G91 Mode Coordonnees Relatives + +Coordonnees X,Y + X,Y sont suivies de + ou - et de m+n chiffres (non separes) + m = partie entiere + n = partie apres la virgule + formats classiques : m = 2, n = 3 (format 2.3) + m = 3, n = 4 (format 3.4) + ex: + G__ X00345Y-06123 D__* + +Outils et D_CODES + numero d'outil ( identification des formes ) + 1 a 99 (classique) + 1 a 999 + D_CODES: + + D01 ... D9 = codes d'action: + D01 = activation de lumiere (baisser de plume) lors du déplacement + D02 = extinction de lumiere (lever de plume) lors du déplacement + D03 = Flash + D09 = VAPE Flash + + D10 ... = Indentification d'outils ( d'ouvertures ) +*/ + + /*********************************/ + /* class GERBER_Descr : Methodes */ + /*********************************/ + +GERBER_Descr::GERBER_Descr(int layer) +{ +int ii; + m_Layer = layer; // Layer Number + m_Selected_Tool = FIRST_DCODE; + ResetDefaultValues(); + for ( ii = 0; ii <= MAX_TOOLS; ii++ ) + m_Aperture_List[ii] = new D_CODE(ii + FIRST_DCODE); +} + + + + +GERBER_Descr::~GERBER_Descr(void) +{ +int ii; + + if (m_Aperture_List ) + { + for ( ii = 0; ii < MAX_TOOLS; ii++) + { + delete m_Aperture_List[ii]; + m_Aperture_List[ii] = NULL; + } + } +} + +/******************************************/ +void GERBER_Descr::ResetDefaultValues(void) +/******************************************/ +{ + m_Parent = NULL; + m_Pback = NULL; + m_Pnext = NULL; + m_FileName.Empty(); + m_Name = wxT("no name"); // Layer name + m_LayerNegative = FALSE; // TRUE = Negative Layer + m_ImageNegative = FALSE; // TRUE = Negative image + m_GerbMetric = FALSE; // FALSE = Inches, TRUE = metric + m_Relative = FALSE; // FALSE = absolute Coord, RUE = relative Coord + m_NoTrailingZeros = FALSE; // True: zeros a droite supprimés + m_MirorA = FALSE; // True: miror / axe A (X) + m_MirorB = FALSE; // True: miror / axe B (Y) + m_As_DCode = FALSE; // TRUE = DCodes in file (FALSE = no DCode-> + // separate DCode file + m_Offset.x = m_Offset.y = 0; // Coord Offset + + m_FmtScale.x = m_FmtScale.y = g_Default_GERBER_Format % 10; + m_FmtLen.x = m_FmtLen.y = m_FmtScale.x + (g_Default_GERBER_Format / 10); + + m_LayerScale.x = m_LayerScale.y = 1.0; // scale (X et Y) pour cette layer + m_Rotation = 0; + m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Linear, 90 arc, Circ. + m_360Arc_enbl = FALSE; // 360 deg circular interpolation disable + m_Current_Tool = 0; // Current Tool (Dcode) number selected + m_CommandState = 0; // donne l'etat de l'analyse des commandes gerber + m_CurrentPos.x = m_CurrentPos.y = 0; // current specified coord for plot + m_PreviousPos.x = m_PreviousPos.y = 0; // old current specified coord for plot + m_IJPos.x = m_IJPos.y = 0; // current centre coord for plot arcs & circles + m_Current_File = NULL; // File to read + m_FilesPtr = 0; + m_Transform[0][0] = m_Transform[1][1] = 1; + m_Transform[0][1] = m_Transform[1][0] = 0; // Rotation/mirror = Normal + m_PolygonFillMode = FALSE; + m_PolygonFillModeState = 0; +} + +/********************************************/ +int GERBER_Descr::ReturnUsedDcodeNumber(void) +/********************************************/ +{ +int ii, jj; + + jj = 0; + if (m_Aperture_List ) + { + for ( ii = 0; ii < MAX_TOOLS; ii++) + { + if( m_Aperture_List[ii]->m_InUse || m_Aperture_List[ii]->m_Defined ) + jj++; + } + } + return jj; +} + + + +/******************************/ +void GERBER_Descr::InitToolTable(void) +/******************************/ +/* Creation du tableau des MAX_TOOLS DCodes utilisables, si il n'existe pas, +et Init des DCodes à une valeur raisonnable +*/ +{ +int count; + + /* Init du buffer des D_CODES a des valeurs raisonnables */ + for (count = 0 ; count < MAX_TOOLS ; count++) + { + if (m_Aperture_List[count] == NULL ) continue; + m_Aperture_List[count]->m_Num_Dcode = count + FIRST_DCODE; + m_Aperture_List[count]->Clear_D_CODE_Data(); + } +} + + + /*************************/ + /* Class DCODE: methodes */ + /*************************/ + +/* Variables locales : */ + +/* Routines Locales */ + + +D_CODE::D_CODE(int num_dcode) +{ + m_Num_Dcode = num_dcode; + Clear_D_CODE_Data(); +} + +D_CODE::~D_CODE(void) +{ +} + +void D_CODE::Clear_D_CODE_Data(void) +{ + m_Size.x = DEFAULT_SIZE; + m_Size.y = DEFAULT_SIZE; + m_Shape= GERB_CIRCLE; + m_Drill.x = m_Drill.y = 0; + m_DrillShape = 0; + m_InUse = FALSE; + m_Defined = FALSE; +} + + +/******************************************************************************/ +int WinEDA_GerberFrame::Read_D_Code_File( const wxString & D_Code_FullFileName) +/******************************************************************************/ +/* Routine de Lecture d'un fichier de D Codes. + Accepte format standard ou ALSPCB + un ';' demarre un commentaire. + + Format Standard: + tool, Horiz, Vert, drill, vitesse, acc. ,Type ; [DCODE (commentaire)] +ex: 1, 12, 12, 0, 0, 0, 3 ; D10 + + Format: + Ver , Hor , Type , Tool [,Drill] +ex: 0.012, 0.012, L , D10 + + Classe les caract en buf_tmp sous forme de tableau de structures D_CODE. + Retourne: + < 0 si erreur: + -1 = Fichier non trouve + -2 = Erreur lecture fichier + 0 si pas de nom de fichier (inits seules) + 1 si OK +*/ +{ +int current_Dcode, ii, dcode_scale; +char* ptcar; +int dimH, dimV, drill, type_outil, dummy; +float fdimH, fdimV, fdrill; +char c_type_outil[256]; +char Line[1024]; +wxString msg; +D_CODE * pt_Dcode; +FILE * dest; +int layer = GetScreen()->m_Active_Layer; +D_CODE ** ListeDCode; + + + if ( g_GERBER_Descr_List[layer] == NULL ) + { + g_GERBER_Descr_List[layer] = new GERBER_Descr(layer); + } + + /* Mise a jour de l'echelle gerber : */ + dcode_scale = 10; /* ici unit dcode = mil, unit interne = 0.1 mil + -> 1 unite dcode = 10 unit PCB */ + current_Dcode = 0; + + if ( D_Code_FullFileName.IsEmpty() ) return 0; + + dest = wxFopen(D_Code_FullFileName, wxT("rt") ); + + if (dest == 0) + { + msg = _("File ") + D_Code_FullFileName + _(" not found"); + DisplayError(this, msg, 10); + return -1; + } + + g_GERBER_Descr_List[layer]->InitToolTable(); + + ListeDCode = g_GERBER_Descr_List[layer]->m_Aperture_List; + + while( fgets(Line,255,dest) != NULL) + { + if (*Line == ';') continue; /* Commentaire */ + if (strlen(Line) < 10 ) continue ; /* Probablemant ligne vide */ + + pt_Dcode = NULL; current_Dcode = 0; + /* Determination du type de fichier D_Code */ + ptcar = Line ; ii = 0 ; + while( *ptcar ) if (*(ptcar++) == ',') ii++ ; + + if (ii >= 6 ) /* valeurs en mils */ + { + sscanf(Line,"%d,%d,%d,%d,%d,%d,%d",&ii, + &dimH, &dimV, &drill, + &dummy,&dummy, + &type_outil); + dimH = (int)( (dimH * dcode_scale) + 0.5) ; + dimV = (int)( (dimV * dcode_scale) + 0.5) ; + drill = (int)( (drill * dcode_scale) + 0.5); + if ( ii < 1 ) ii = 1; + current_Dcode = ii-1 + FIRST_DCODE; + } + else /* valeurs en inches a convertir en mils */ + { + fdrill = 0 ; current_Dcode = 0 ; fdrill = 0 ; + sscanf(Line,"%f,%f,%1s",&fdimV, &fdimH, c_type_outil); + ptcar = Line ; + while( *ptcar ) + { + if (*ptcar == 'D') + { + sscanf(ptcar+1,"%d,%f", ¤t_Dcode,&fdrill); break ; + } + else ptcar++ ; + } + dimH = (int)( (fdimH * dcode_scale * 1000) + 0.5); + dimV = (int)( (fdimV * dcode_scale * 1000) + 0.5); + drill = (int)( (fdrill * dcode_scale * 1000) + 0.5); + type_outil = -1 ; + if(c_type_outil[0] == 'L') type_outil = GERB_LINE; + if(c_type_outil[0] == 'R') type_outil = GERB_RECT; + if(c_type_outil[0] == 'C') type_outil = GERB_CIRCLE; + if(c_type_outil[0] == 'O') type_outil = GERB_OVALE; + if(type_outil == -1) {fclose(dest); return(-2);} + + } + /* Mise a jour de la liste des d_codes si valeurs lues coherentes*/ + if (current_Dcode < FIRST_DCODE ) continue; + if (current_Dcode >= MAX_TOOLS ) continue; + pt_Dcode = ReturnToolDescr(layer, current_Dcode); + pt_Dcode->m_Size.x = dimH; + pt_Dcode->m_Size.y = dimV; + pt_Dcode->m_Shape = type_outil; + pt_Dcode->m_Drill.x = pt_Dcode->m_Drill.y = drill; + pt_Dcode->m_Defined = TRUE; + } + fclose(dest) ; + + return(1); +} + + +/***************************************************/ +void WinEDA_GerberFrame::CopyDCodesSizeToItems(void) +/***************************************************/ +/* Set Size Items (Lines, Flashes) from DCodes List +*/ +{ +TRACK * track; +D_CODE * pt_Dcode; /* Pointeur sur le D code*/ + + track = m_Pcb->m_Track; + for ( ; track != NULL ; track = (TRACK*) track->Pnext ) + { + pt_Dcode = ReturnToolDescr(track->m_Layer, track->m_NetCode); + pt_Dcode->m_InUse = TRUE; + + if ( // Line Item + (track->m_Shape == S_SEGMENT ) || /* segment rectiligne */ + (track->m_Shape == S_RECT ) || /* segment forme rect (i.e. bouts non arrondis) */ + (track->m_Shape == S_ARC ) || /* segment en arc de cercle (bouts arrondis)*/ + (track->m_Shape == S_CIRCLE ) || /* segment en cercle (anneau)*/ + (track->m_Shape == S_ARC_RECT ) /* segment en arc de cercle (bouts droits) (GERBER)*/ + ) + { + track->m_Width = pt_Dcode->m_Size.x; + } + + else // Spots ( Flashed Items ) + { + int width, len; + wxSize size = pt_Dcode->m_Size; + + width = min( size.x, size.y ); + len = max( size.x, size.y ) - width; + + track->m_Width = width; + + track->m_Start.x = (track->m_Start.x + track->m_End.x) / 2; + track->m_Start.y = (track->m_Start.y + track->m_End.y) / 2; + track->m_End = track->m_Start; // m_Start = m_End = Spot center + switch (pt_Dcode->m_Shape) + { + case GERB_LINE : // ne devrait pas etre utilisé ici + case GERB_CIRCLE : /* spot rond (for GERBER)*/ + track->m_Shape = S_SPOT_CIRCLE; + break ; + + case GERB_OVALE : /* spot ovale (for GERBER)*/ + track->m_Shape = S_SPOT_OVALE; + break ; + + default: /* spot rect (for GERBER)*/ + track->m_Shape = S_SPOT_RECT; + break ; + } + + len >>= 1; + if ( size.x > size.y ) + { + track->m_Start.x -= len; + track->m_End.x += len; + } + + else + { + track->m_Start.y -= len; + track->m_End.y += len; + } + } + } +} + + +/*********************************************************/ +D_CODE * ReturnToolDescr(int layer, int Dcode, int * index) +/*********************************************************/ + +/* Retourne un pointeur sur la description de l'outil DCode de reference Dcode + (rappel : Dcode >= 10) +*/ +{ +GERBER_Descr * DcodeList = g_GERBER_Descr_List[layer]; +D_CODE * pt_dcode = NULL; + + if (index) *index = 0; + if ( DcodeList && Dcode >= FIRST_DCODE && Dcode < MAX_TOOLS) + { + pt_dcode = DcodeList->m_Aperture_List[Dcode - FIRST_DCODE]; + if ( index ) *index = Dcode - FIRST_DCODE + 1; + } + return pt_dcode; +} + + +/************************************************/ +void WinEDA_GerberFrame::Liste_D_Codes(wxDC * DC) +/************************************************/ +{ +int ii, jj; +D_CODE * pt_D_code ; +wxString Line; +WinEDA_TextFrame * List; +int scale = 10000; +int curr_layer = GetScreen()->m_Active_Layer; +int layer; +GERBER_Descr * DcodeList; + + /* Construction de la liste des messages */ + List = new WinEDA_TextFrame(this, _("List D-Codes")); + + for (layer = 0; layer < 32; layer++ ) + { + DcodeList = g_GERBER_Descr_List[layer]; + if ( DcodeList == NULL ) continue; + if ( DcodeList->ReturnUsedDcodeNumber() == 0 ) + continue; + if (layer == curr_layer ) + Line.Printf( wxT("*** Active layer (%2.2d) ***"), layer+1); + else Line.Printf( wxT("*** layer %2.2d ***"), layer+1); + List->Append(Line); + + for ( ii = 0, jj = 1 ; ii < MAX_TOOLS ; ii++ ) + { + pt_D_code = DcodeList->m_Aperture_List[ii] ; + if ( pt_D_code == NULL ) continue; + if ( !pt_D_code->m_InUse && !pt_D_code->m_Defined ) continue; + Line.Printf( wxT( + "tool %2.2d: D%2.2d V %2.4f H %2.4f %s"), + jj, + pt_D_code->m_Num_Dcode, + (float)pt_D_code->m_Size.y /scale, + (float)pt_D_code->m_Size.x /scale, + g_GERBER_Tool_Type[pt_D_code->m_Shape] ); + if ( ! pt_D_code->m_Defined ) Line += wxT(" ?"); + if ( ! pt_D_code->m_InUse ) Line += wxT(" *"); + + List->Append(Line); + jj++; + } + } + ii = List->ShowModal(); List->Destroy(); + if (ii < 0) return; + +#if 0 + // Mise en surbrillance des éléments correspondant au DCode sélectionné + if(Etat_Surbrillance) Hight_Light(DrawPanel, DC); + net_code_Surbrillance = (GetScreen()->m_Active_Layer<< 16) + ii; + Hight_Light(DrawPanel, DC); +#endif +} + + diff --git a/gerbview/deltrack.cpp b/gerbview/deltrack.cpp new file mode 100644 index 0000000000..e553b15621 --- /dev/null +++ b/gerbview/deltrack.cpp @@ -0,0 +1,76 @@ + /*********************************************/ + /* Edition des pistes: Routines d'effacement */ + /* Effacement de segment, piste, net et zone */ + /*********************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" + +#include "protos.h" + +/* Routines externes : */ + +/* Routines Locales */ + +/* Variables locales */ + + +/*****************************************************************/ +TRACK * WinEDA_GerberFrame::Delete_Segment(wxDC * DC, TRACK *Track) +/*****************************************************************/ +/* Supprime 1 segment de piste. + 2 Cas possibles: + Si On est en trace de nouvelle piste: Effacement du segment en + cours de trace + Sinon : Effacment du segment sous le curseur. +*/ +{ + if ( Track == NULL ) return NULL; + + if(Track->m_Flags & IS_NEW) // Trace en cours, on peut effacer le dernier segment + { + if(g_TrackSegmentCount > 0 ) + { + // modification du trace + Track = g_CurrentTrackSegment; g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; + delete Track; g_TrackSegmentCount--; + + if( g_TrackSegmentCount && (g_CurrentTrackSegment->m_StructType == TYPEVIA)) + { + Track = g_CurrentTrackSegment; g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; + delete Track; + g_TrackSegmentCount-- ; + } + if( g_CurrentTrackSegment ) g_CurrentTrackSegment->Pnext = NULL; + + Affiche_Status_Box(); + + if(g_TrackSegmentCount == 0 ) + { + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + return NULL; + } + else + { + if(DrawPanel->ManageCurseur) + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + return g_CurrentTrackSegment; + } + } + return NULL; + } // Fin traitement si trace en cours + + + Trace_Segment(DrawPanel, DC, Track,GR_XOR) ; + + SaveItemEfface( Track, 1); + GetScreen()->SetModify(); + return NULL; +} + + + + diff --git a/gerbview/edit.cpp b/gerbview/edit.cpp new file mode 100644 index 0000000000..5dde9cc0f5 --- /dev/null +++ b/gerbview/edit.cpp @@ -0,0 +1,350 @@ + /******************************************************/ + /* edit.cpp: fonctions generales de l'edition du PCB */ + /******************************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" + +#include "id.h" + +#include "protos.h" + +static void Process_Move_Item(WinEDA_GerberFrame * frame, + EDA_BaseStruct *DrawStruct, wxDC * DC); + +/************************************************************************/ +void WinEDA_GerberFrame::OnLeftClick(wxDC * DC, const wxPoint& MousePos) +/************************************************************************/ +/* Traite les commandes declenchée par le bouton gauche de la souris, + quand un outil est deja selectionné +*/ +{ +EDA_BaseStruct * DrawStruct = GetScreen()->m_CurrentItem; +wxString msg; + + if ( m_ID_current_state == 0 ) + { + if ( DrawStruct && DrawStruct->m_Flags ) // Commande "POPUP" en cours + { + switch (DrawStruct->m_StructType ) + { + default: + msg.Printf( + wxT("WinEDA_GerberFrame::ProcessCommand err: Struct %d, m_Flags = %X"), + (unsigned) DrawStruct->m_StructType, + (unsigned) DrawStruct->m_Flags); + DisplayError(this, msg ); + } + } + else + { + GetScreen()->m_CurrentItem = + DrawStruct = GerberGeneralLocateAndDisplay(); + } + } + + switch ( m_ID_current_state ) + { + case 0: + break; + + case ID_NO_SELECT_BUTT: + break; + + + case ID_PCB_DELETE_ITEM_BUTT: + DrawStruct = GerberGeneralLocateAndDisplay(); + if ( DrawStruct == NULL ) break; + if ( DrawStruct->m_StructType == TYPETRACK ) + { + Delete_Segment(DC, (TRACK *) DrawStruct ); + GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetModify(); + } + break; + + default : + DisplayError(this, wxT("WinEDA_GerberFrame::ProcessCommand error")); + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + break; + } +} + + +/********************************************************************************/ +void WinEDA_GerberFrame::Process_Special_Functions(wxCommandEvent& event) +/********************************************************************************/ +/* Traite les selections d'outils et les commandes appelees du menu POPUP +*/ +{ +int id = event.GetId(); +int layer = GetScreen()->m_Active_Layer; +GERBER_Descr * gerber_layer = g_GERBER_Descr_List[layer]; +wxPoint pos; +wxClientDC dc(DrawPanel); + + DrawPanel->PrepareGraphicContext(&dc); + + wxGetMousePosition(&pos.x, &pos.y); + + pos.y += 20; + + switch ( id ) // Arret eventuel de la commande de déplacement en cours + { + case wxID_CUT: + case wxID_COPY: + case ID_POPUP_DELETE_BLOCK: + case ID_POPUP_PLACE_BLOCK: + case ID_POPUP_ZOOM_BLOCK: + case ID_POPUP_INVERT_BLOCK: + case ID_POPUP_ROTATE_BLOCK: + case ID_POPUP_COPY_BLOCK: + break; + + case ID_POPUP_CANCEL_CURRENT_COMMAND: + if( DrawPanel->ManageCurseur && + DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + /* ne devrait pas etre execute, sauf bug */ + if (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE) + { + m_CurrentScreen->BlockLocate.m_Command = BLOCK_IDLE; + m_CurrentScreen->BlockLocate.m_State = STATE_NO_BLOCK; + m_CurrentScreen->BlockLocate.m_BlockDrawStruct = NULL; + } + if (m_ID_current_state == 0 ) + SetToolID(0, wxCURSOR_ARROW, wxEmptyString); + else SetCursor(DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor); + break; + + default: // Arret dea commande de déplacement en cours + if( DrawPanel->ManageCurseur && + DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + SetToolID(0, wxCURSOR_ARROW, wxEmptyString); + break; + } + + switch ( id ) // Traitement des commandes + { + case ID_EXIT : + Close(TRUE); + break; + + case ID_NEW_PROJECT: + case ID_LOAD_PROJECT: + Files_io(event); + break; + + case ID_PCB_GLOBAL_DELETE: + Erase_Current_Layer(&dc, TRUE); + break; + + case wxID_CUT: + break; + + case wxID_COPY: + break; + + case wxID_PASTE: +// HandleBlockBegin(&dc, BLOCK_PASTE); + break; + + case ID_UNDO_BUTT: + UnDeleteItem(&dc); + break; + + case ID_GET_TOOLS: +// InstallToolsFrame(this, wxPoint(-1,-1) ); + break; + + case ID_FIND_ITEMS: +// InstallFindFrame(this, pos); + break; + + + case ID_BUS_BUTT: + SetToolID( id, wxCURSOR_PENCIL, wxT("Add Tracks")); + break; + + case ID_LINE_COMMENT_BUTT: + SetToolID( id, wxCURSOR_PENCIL, wxT("Add Drawing")); + break; + + case ID_TEXT_COMMENT_BUTT: + SetToolID( id, wxCURSOR_PENCIL, wxT("Add Text")); + break; + + case ID_NO_SELECT_BUTT: + SetToolID( 0, 0, wxEmptyString); + break; + + case ID_POPUP_CLOSE_CURRENT_TOOL: + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + break; + + case ID_POPUP_CANCEL_CURRENT_COMMAND: + break; + + case ID_POPUP_END_LINE: + DrawPanel->MouseToCursorSchema(); +// EndSegment(&dc); + break; + + case ID_POPUP_PCB_DELETE_TRACKSEG: + DrawPanel->MouseToCursorSchema(); + if ( GetScreen()->m_CurrentItem == NULL) break; + Delete_Segment(&dc, (TRACK*)GetScreen()->m_CurrentItem); + GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetModify(); + break; + + case ID_PCB_DELETE_ITEM_BUTT: + SetToolID( id, wxCURSOR_PENCIL, wxT("Delete item")); + break; + + case ID_POPUP_SCH_MOVE_ITEM_REQUEST: + DrawPanel->MouseToCursorSchema(); + Process_Move_Item(this, GetScreen()->m_CurrentItem, &dc); + break; + + case ID_TOOLBARH_PCB_SELECT_LAYER: + { + GetScreen()->m_Active_Layer = m_SelLayerBox->GetChoice(); + DrawPanel->Refresh(TRUE); + break; + } + + case ID_TOOLBARH_GERBER_SELECT_TOOL: + if ( gerber_layer ) + { + int tool = m_SelLayerTool->GetChoice(); + if ( tool > 0 ) tool = tool - 1 + FIRST_DCODE; + else tool = 0; + gerber_layer->m_Selected_Tool = tool; + DrawPanel->Refresh(TRUE); + } + else DisplayError(this, _("No layer selected") ); + break; + + case ID_GERBVIEW_SHOW_LIST_DCODES: + Liste_D_Codes(&dc); + break; + + case ID_GERBVIEW_SHOW_SOURCE: + if ( gerber_layer ) + { + wxString editorname = GetEditorName(); + if ( ! editorname.IsEmpty() ) + ExecuteFile(this, editorname, gerber_layer->m_FileName); + } + break; + + case ID_POPUP_PLACE_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_MOVE; + DrawPanel->m_AutoPAN_Request = FALSE; + HandleBlockPlace(&dc); + break; + + case ID_POPUP_COPY_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_COPY; + m_CurrentScreen->BlockLocate.SetMessageBlock(this); + DrawPanel->m_AutoPAN_Request = FALSE; + HandleBlockEnd(&dc); + break; + + case ID_POPUP_ZOOM_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_ZOOM; + m_CurrentScreen->BlockLocate.SetMessageBlock(this); + m_CurrentScreen->BlockLocate.SetMessageBlock(this); + HandleBlockEnd(&dc); + break; + + case ID_POPUP_DELETE_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_DELETE; + m_CurrentScreen->BlockLocate.SetMessageBlock(this); + HandleBlockEnd(&dc); + break; + + default: + wxMessageBox( wxT("WinEDA_GerberFrame::Process_Special_Functions error")); + break; + } + + SetToolbars(); +} + + +/****************************************************************/ +static void Process_Move_Item(WinEDA_GerberFrame * frame, + EDA_BaseStruct *DrawStruct, wxDC * DC) +/****************************************************************/ +{ + + if ( DrawStruct == NULL ) return; + + frame->DrawPanel->MouseToCursorSchema(); + switch ( DrawStruct->m_StructType ) + { + + default: + wxString msg; + msg.Printf( + wxT("WinEDA_LibeditFrame::Move_Item Error: Bad DrawType %d"), + DrawStruct->m_StructType); + DisplayError(frame, msg ); + break; + } +} + + +/**************************************************************************/ +void WinEDA_GerberFrame::OnLeftDClick(wxDC * DC, const wxPoint& MousePos) +/**************************************************************************/ +/* Appelé sur un double click: + pour un élément editable (textes, composant): + appel de l'editeur correspondant. + pour une connexion en cours: + termine la connexion +*/ +{ +EDA_BaseStruct * DrawStruct = GetScreen()->m_CurrentItem; +wxClientDC dc(DrawPanel); + + DrawPanel->PrepareGraphicContext(&dc); + + switch ( m_ID_current_state ) + { + case 0: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + DrawStruct = GerberGeneralLocateAndDisplay(); + } + + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) ) + break; + + // Element localisé + switch ( DrawStruct->m_StructType ) + { + default: + break; + } + break; // end case 0 + + case ID_BUS_BUTT: + case ID_WIRE_BUTT: +// if ( DrawStruct && (DrawStruct->m_Flags & IS_NEW) ) + // EndSegment(DC); + break; + } +} + + diff --git a/gerbview/files.cpp b/gerbview/files.cpp new file mode 100644 index 0000000000..399422e721 --- /dev/null +++ b/gerbview/files.cpp @@ -0,0 +1,225 @@ + /******************************************************/ + /* Files.cp: Lecture / Sauvegarde des fichiers gerber */ + /******************************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" +#include "protos.h" +#include "id.h" + + +/* Routines locales */ +static void LoadDCodeFile(WinEDA_GerberFrame * frame, const wxString & FullFileName, wxDC * DC); + + +/********************************************************/ +void WinEDA_GerberFrame::Files_io(wxCommandEvent& event) +/********************************************************/ +/* Gestion generale des commandes de lecture de fichiers +*/ +{ +int id = event.GetId(); +wxClientDC dc(DrawPanel); + + DrawPanel->CursorOff(&dc); + + switch (id) + { + case ID_MENU_LOAD_FILE: + case ID_LOAD_FILE: + if ( Clear_Pcb(&dc, TRUE) ) + { + LoadOneGerberFile(wxEmptyString, &dc, 0); + } + break; + + case ID_MENU_INC_LAYER_AND_APPEND_FILE: + case ID_INC_LAYER_AND_APPEND_FILE: + { + int layer = GetScreen()->m_Active_Layer; + GetScreen()->m_Active_Layer++; + if( ! LoadOneGerberFile(wxEmptyString, &dc, 0) ) + GetScreen()->m_Active_Layer = layer; + SetToolbars(); + } + break; + + case ID_MENU_APPEND_FILE: + case ID_APPEND_FILE: + LoadOneGerberFile(wxEmptyString, &dc, 0); + break; + + case ID_MENU_NEW_BOARD: + case ID_NEW_BOARD: + Clear_Pcb(&dc, TRUE); + Zoom_Automatique(FALSE); + GetScreen()->SetRefreshReq(); + break; + + case ID_LOAD_FILE_1: + case ID_LOAD_FILE_2: + case ID_LOAD_FILE_3: + case ID_LOAD_FILE_4: + case ID_LOAD_FILE_5: + case ID_LOAD_FILE_6: + case ID_LOAD_FILE_7: + case ID_LOAD_FILE_8: + case ID_LOAD_FILE_9: + case ID_LOAD_FILE_10: + if ( Clear_Pcb(&dc, TRUE) ) + { + LoadOneGerberFile( + GetLastProject(id - ID_LOAD_FILE_1).GetData(), + &dc, FALSE); + } + break; + + case ID_GERBVIEW_LOAD_DRILL_FILE: + DisplayError(this, _("Not yet available...")); + break; + + case ID_GERBVIEW_LOAD_DCODE_FILE: + LoadDCodeFile(this, wxEmptyString, &dc); + break; + + case ID_SAVE_BOARD: + case ID_MENU_SAVE_BOARD: + SaveGerberFile(GetScreen()->m_FileName, &dc); + break; + + case ID_MENU_SAVE_BOARD_AS: + SaveGerberFile(wxEmptyString, &dc); + break; + + default: + DisplayError(this, wxT("File_io Internal Error") ); + break; + } + + DrawPanel->MouseToCursorSchema(); + DrawPanel->CursorOn(&dc); +} + + + +/*******************************************************************************************/ +int WinEDA_GerberFrame::LoadOneGerberFile(const wxString & FullFileName, + wxDC * DC, int mode) +/*******************************************************************************************/ + +/* + Lecture d'un fichier PCB, le nom etant dans PcbNameBuffer.s + retourne: + 0 si fichier non lu ( annulation de commande ... ) + 1 si OK +*/ +{ +wxString filename = FullFileName; +wxString path = wxPathOnly(FullFileName); + + ActiveScreen = GetScreen(); + if( filename == wxEmptyString) + { + wxString mask = wxT("*") + g_PhotoFilenameExt; + filename = EDA_FileSelector(_("GERBER PLOT files:"), + path, /* Chemin par defaut */ + wxEmptyString, /* nom fichier par defaut */ + g_PhotoFilenameExt, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + 0, + FALSE + ); + if ( filename == wxEmptyString ) return FALSE; + } + + GetScreen()->m_FileName = filename; + wxSetWorkingDirectory(path); + ChangeFileNameExt(filename,g_PenFilenameExt); + + if ( Read_GERBER_File(DC, GetScreen()->m_FileName, filename) ) + SetLastProject(GetScreen()->m_FileName); + + Zoom_Automatique(FALSE); + GetScreen()->SetRefreshReq(); + g_SaveTime = time(NULL); + + return(1); +} + +/**********************************************************************************************/ +static void LoadDCodeFile(WinEDA_GerberFrame * frame, const wxString & FullFileName, wxDC * DC) +/**********************************************************************************************/ + +/* + Lecture d'un fichier PCB, le nom etant dans PcbNameBuffer.s + retourne: + 0 si fichier non lu ( annulation de commande ... ) + 1 si OK +*/ +{ +wxString filename = FullFileName; + + ActiveScreen = frame->GetScreen(); + + if( filename == wxEmptyString) + { + wxString penfilesmask( wxT("*") ); + penfilesmask += g_PenFilenameExt; + filename = frame->GetScreen()->m_FileName; + ChangeFileNameExt(filename,g_PenFilenameExt); + filename = EDA_FileSelector(_("D CODES files:"), + wxEmptyString, /* Chemin par defaut */ + filename, /* nom fichier par defaut */ + g_PenFilenameExt, /* extension par defaut */ + penfilesmask, /* Masque d'affichage */ + frame, + 0, + TRUE + ); + if ( filename == wxEmptyString ) return; + } + + frame->Read_D_Code_File(filename); + frame->CopyDCodesSizeToItems(); + frame->GetScreen()->SetRefreshReq(); +} + + + +/*******************************************************************************/ +bool WinEDA_GerberFrame::SaveGerberFile(const wxString & FullFileName, wxDC * DC) +/*******************************************************************************/ +/* Sauvegarde du fichier PCB en format ASCII +*/ +{ +wxString filename = FullFileName; + + if( filename == wxEmptyString ) + { + wxString mask( wxT("*")); + mask += g_PhotoFilenameExt; + filename = EDA_FileSelector(_("Gerber files:"), + wxEmptyString, /* Chemin par defaut */ + GetScreen()->m_FileName, /* nom fichier par defaut */ + g_PhotoFilenameExt, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + FALSE + ); + if ( filename.IsEmpty() ) return FALSE; + } + + GetScreen()->m_FileName = filename; + +// TODO + + return TRUE; +} + + + diff --git a/gerbview/gerberframe.cpp b/gerbview/gerberframe.cpp new file mode 100644 index 0000000000..bb49ed2fd1 --- /dev/null +++ b/gerbview/gerberframe.cpp @@ -0,0 +1,449 @@ + /******************************************************************/ + /* gerberframe.cpp - fonctions des classes du type WinEDA_GerberFrame */ + /******************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" + +#include "bitmaps.h" +#include "protos.h" +#include "id.h" + + + /****************************************/ + /* class WinEDA_GerberFrame for GerbView*/ + /****************************************/ + +BEGIN_EVENT_TABLE(WinEDA_GerberFrame, wxFrame) + COMMON_EVENTS_DRAWFRAME + + EVT_CLOSE(WinEDA_GerberFrame::OnCloseWindow) + EVT_SIZE(WinEDA_GerberFrame::OnSize) + + EVT_TOOL_RANGE(ID_ZOOM_PLUS_BUTT, ID_ZOOM_PAGE_BUTT, + WinEDA_GerberFrame::Process_Zoom) + + EVT_TOOL(ID_LOAD_FILE, WinEDA_GerberFrame::Files_io) + EVT_TOOL(ID_APPEND_FILE, WinEDA_GerberFrame::Files_io) + EVT_TOOL(ID_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io) + EVT_TOOL(ID_GERBVIEW_LOAD_DRILL_FILE, WinEDA_GerberFrame::Files_io) + EVT_TOOL(ID_GERBVIEW_LOAD_DCODE_FILE, WinEDA_GerberFrame::Files_io) + EVT_TOOL(ID_NEW_BOARD, WinEDA_GerberFrame::Files_io) + EVT_TOOL(ID_SAVE_BOARD, WinEDA_GerberFrame::Files_io) + + EVT_MENU_RANGE(ID_PREFERENCES_FONT_INFOSCREEN, ID_PREFERENCES_FONT_END, + WinEDA_DrawFrame::ProcessFontPreferences) + + // Menu Files: + EVT_MENU(ID_MENU_LOAD_FILE, WinEDA_GerberFrame::Files_io) + EVT_MENU(ID_MENU_APPEND_FILE, WinEDA_GerberFrame::Files_io) + EVT_MENU(ID_MENU_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io) + EVT_MENU(ID_MENU_NEW_BOARD, WinEDA_GerberFrame::Files_io) + EVT_MENU(ID_MENU_SAVE_BOARD, WinEDA_GerberFrame::Files_io) + EVT_MENU(ID_MENU_SAVE_BOARD_AS, WinEDA_GerberFrame::Files_io) + EVT_MENU(ID_GEN_PLOT, WinEDA_GerberFrame::ToPlotter) + + EVT_MENU_RANGE(ID_LOAD_FILE_1,ID_LOAD_FILE_10, + WinEDA_GerberFrame::Files_io) + + EVT_MENU(ID_EXIT, WinEDA_GerberFrame::Process_Special_Functions) + + // menu Config + EVT_MENU(ID_CONFIG_REQ, WinEDA_GerberFrame::Process_Config) + EVT_MENU(ID_COLORS_SETUP, WinEDA_GerberFrame::Process_Config) + EVT_MENU(ID_OPTIONS_SETUP, WinEDA_GerberFrame::Process_Config) + EVT_MENU(ID_PCB_LOOK_SETUP, WinEDA_GerberFrame::Process_Config) + EVT_MENU(ID_CONFIG_SAVE, WinEDA_GerberFrame::Process_Config) + EVT_MENU_RANGE(ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, + WinEDA_DrawFrame::SetLanguage) + + // menu Postprocess + EVT_MENU(ID_GERBVIEW_SHOW_LIST_DCODES, WinEDA_GerberFrame::Process_Special_Functions) + + // menu Miscellaneous + EVT_MENU(ID_PCB_GLOBAL_DELETE, WinEDA_GerberFrame::Process_Special_Functions) + EVT_MENU(ID_GERBVIEW_SHOW_SOURCE, + WinEDA_GerberFrame::Process_Special_Functions ) + + // Menu Help + EVT_MENU(ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp) + EVT_MENU(ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout) + + EVT_TOOL(ID_SHEET_SET, WinEDA_DrawFrame::Process_PageSettings) + EVT_TOOL(wxID_CUT, WinEDA_GerberFrame::Process_Special_Functions) + EVT_TOOL(wxID_COPY, WinEDA_GerberFrame::Process_Special_Functions) + EVT_TOOL(wxID_PASTE, WinEDA_GerberFrame::Process_Special_Functions) + EVT_TOOL(ID_UNDO_BUTT, WinEDA_GerberFrame::Process_Special_Functions) + EVT_TOOL(ID_GEN_PRINT, WinEDA_GerberFrame::ToPrinter) + EVT_TOOL(ID_FIND_ITEMS, WinEDA_GerberFrame::Process_Special_Functions) + EVT_TOOL(ID_DRC_CONTROL, WinEDA_GerberFrame::Process_Special_Functions) + EVT_KICAD_CHOICEBOX(ID_TOOLBARH_PCB_SELECT_LAYER, + WinEDA_GerberFrame::Process_Special_Functions) + + EVT_KICAD_CHOICEBOX(ID_TOOLBARH_GERBER_SELECT_TOOL, + WinEDA_GerberFrame::Process_Special_Functions) + + + // Vertical toolbar: + EVT_TOOL(ID_NO_SELECT_BUTT, WinEDA_GerberFrame::Process_Special_Functions) + EVT_TOOL(ID_TRACK_BUTT, WinEDA_GerberFrame::Process_Special_Functions) + EVT_TOOL(ID_PCB_ZONES_BUTT, WinEDA_GerberFrame::Process_Special_Functions) + EVT_TOOL(ID_PCB_DELETE_ITEM_BUTT, WinEDA_GerberFrame::Process_Special_Functions) + + // Annulation de commande en cours + EVT_MENU_RANGE(ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, + WinEDA_PcbFrame::Process_Special_Functions ) + + // Option toolbar + EVT_TOOL_RANGE(ID_TB_OPTIONS_START,ID_TB_OPTIONS_END, + WinEDA_GerberFrame::OnSelectOptionToolbar) + + + // PopUp Menu traités dans drawpanel.cpp + +END_EVENT_TABLE() + + + /****************/ + /* Constructeur */ + /****************/ + +WinEDA_GerberFrame::WinEDA_GerberFrame(wxWindow * father, WinEDA_App *parent, + const wxString & title, const wxPoint& pos, const wxSize& size) : + WinEDA_BasePcbFrame(father, parent, GERBER_FRAME, title, pos, size) +{ + m_FrameName = wxT("GerberFrame"); + m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines + m_Draw_Grid = TRUE; // TRUE pour avoir la axes dessinee + m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessiné + m_Ident = GERBER_FRAME; + m_ZoomMaxValue = 1024; + if ( DrawPanel ) DrawPanel->m_Block_Enable = TRUE; + // Give an icon + #ifdef __WINDOWS__ + SetIcon( wxICON(a_icon_gerbview)); + #else + SetIcon( wxICON(icon_gerbview)); + #endif + + m_CurrentScreen = ActiveScreen = ScreenPcb; + + GetSettings(); + SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y); + ReCreateMenuBar(); + ReCreateHToolbar(); + ReCreateVToolbar(); + ReCreateOptToolbar(); +} + + +WinEDA_GerberFrame::~WinEDA_GerberFrame(void) +{ + m_Parent->m_GerberFrame = NULL; + m_CurrentScreen = ScreenPcb; +} + + +/***********************************************************/ +void WinEDA_GerberFrame::OnCloseWindow(wxCloseEvent & Event) +/***********************************************************/ +{ +PCB_SCREEN * screen; + + screen = ScreenPcb ; + while( screen ) + { + if(screen->IsModify()) break; + screen = screen->Next(); + } + + if ( screen ) + { + if( ! IsOK(this, _("Layer modified, Continue ?")) ) + { + Event.Veto(); + return; + } + } + + while( screen ) // suppression flag modify pour eviter d'autres message + { + screen->ClrModify(); + screen = screen->Next(); + } + + /* Reselection de l'ecran de base, + pour les evenements de refresh générés par wxWindows */ + m_CurrentScreen = ActiveScreen = ScreenPcb; + + SaveSettings(); + Destroy(); +} + + +/***********************************************/ +void WinEDA_GerberFrame::ReCreateMenuBar(void) +/***********************************************/ +/* Cree ou reinitialise le menu du haut d'ecran +*/ +{ +int ii; +wxMenuBar * menuBar = GetMenuBar(); + + if( menuBar == NULL ) + { + menuBar = new wxMenuBar(); + + m_FilesMenu = new wxMenu; + m_FilesMenu->Append(ID_MENU_LOAD_FILE, + _("Clear and Load gerber file"), + _("Clear all layers and Load new gerber file"), + FALSE); + + m_FilesMenu->Append(ID_MENU_APPEND_FILE, + _("Load gerber file"), + _("Load new gerber file on currrent layer"), + FALSE); + + m_FilesMenu->Append(ID_MENU_INC_LAYER_AND_APPEND_FILE, + _("Inc Layer and load gerber file"), + _("Increment layer number, and Load gerber file"), + FALSE); + + m_FilesMenu->Append(ID_GERBVIEW_LOAD_DCODE_FILE, + _("Load DCodes"), + _("Load D-Codes File"), + FALSE); + + m_FilesMenu->Append(ID_GERBVIEW_LOAD_DRILL_FILE, + _("Load Drill"), + _("Load Drill File (EXCELLON Format)"), + FALSE); + + m_FilesMenu->Append(ID_MENU_NEW_BOARD, + _("&New"), + _("Clear all layers"), + FALSE); + + m_FilesMenu->AppendSeparator(); + m_FilesMenu->Append(ID_MENU_SAVE_BOARD, + _("&Save layers"), + _("Save current layers (GERBER format)"), + FALSE); + + m_FilesMenu->Append(ID_MENU_SAVE_BOARD_AS, + _("Save layers as.."), + _("Save current layers as.."), + FALSE); + + m_FilesMenu->AppendSeparator(); + + m_FilesMenu->Append(ID_GEN_PRINT, _("P&rint"), _("Print on current printer")); + m_FilesMenu->Append(ID_GEN_PLOT, + _("Plot"), _("Plotting in various formats") ); + + m_FilesMenu->AppendSeparator(); + m_FilesMenu->Append(ID_EXIT,_("E&xit"), _("Quit Gerbview") ); + + // Creation des selections des anciens fichiers + m_FilesMenu->AppendSeparator(); + for ( int ii = 0; ii < 10; ii++ ) + { + if ( GetLastProject(ii).IsEmpty() ) break; + m_FilesMenu->Append(ID_LOAD_FILE_1 + ii, GetLastProject(ii) ); + } + + // Configuration: + wxMenu * configmenu = new wxMenu; + configmenu->Append(ID_CONFIG_REQ, _("&Files and Dir"), + _("Setting Files extension, Directories and others...")); + configmenu->Append(ID_COLORS_SETUP, _("&Colors"), + _("Select Colors and Display for layers")); + configmenu->Append(ID_OPTIONS_SETUP, _("&Options"), + _(" Select general options")); + + configmenu->Append(ID_PCB_LOOK_SETUP, _("Display"), + _(" Select how items are displayed")); + + // Font selection and setup + AddFontSelectionMenu(configmenu); + + m_Parent->SetLanguageList(configmenu); + + configmenu->AppendSeparator(); + configmenu->Append(ID_CONFIG_SAVE, _("&Save Gerbview Setup"), + _("Save options in current directory")); + + // Menu drill ( generation fichiers percage) +/* wxMenu *drill_menu = new wxMenu; + postprocess_menu->Append(ID_PCB_GEN_DRILL_FILE, "Create &Drill file", + "Gen Drill (EXCELLON] file and/or Drill sheet"); +*/ + // Menu d'outils divers + wxMenu *miscellaneous_menu = new wxMenu; + miscellaneous_menu->Append(ID_GERBVIEW_SHOW_LIST_DCODES, _("&List DCodes"), + _("List and Edit DCodes") ); + miscellaneous_menu->Append(ID_GERBVIEW_SHOW_SOURCE,_("&Show source"), + _("Show source file for the current layer") ); + miscellaneous_menu->AppendSeparator(); + miscellaneous_menu->Append(ID_PCB_GLOBAL_DELETE, _("&Delete Layer"), + _("Delete current layer") ); + + // Menu Help: + wxMenu *helpMenu = new wxMenu; + helpMenu->Append(ID_GENERAL_HELP, _("&Help"), _("On line doc") ); + helpMenu->Append(ID_KICAD_ABOUT, _("&About"), _("Gerbview Infos") ); + + menuBar->Append(m_FilesMenu, _("&Files")); + menuBar->Append(configmenu, _("&Preferences")); + menuBar->Append(miscellaneous_menu, _("&Miscellaneous")); +// menuBar->Append(drill_menu, _("&Drill")); + menuBar->Append(helpMenu, _("&Help")); + + // Associate the menu bar with the frame + SetMenuBar(menuBar); + } + + else // simple mise a jour de la liste des fichiers anciens + { + wxMenuItem * item; + int max_file = m_Parent->m_LastProjectMaxCount; + for ( ii = max_file-1; ii >=0 ; ii-- ) + { + if( m_FilesMenu->FindItem(ID_LOAD_FILE_1 + ii) ) + { + item = m_FilesMenu->Remove(ID_LOAD_FILE_1 + ii); + if ( item ) delete item; + } + } + for ( ii = 0; ii < max_file; ii++ ) + { + if ( GetLastProject(ii).IsEmpty() ) break; + m_FilesMenu->Append(ID_LOAD_FILE_1 + ii, GetLastProject(ii) ); + } + } +} + +/*******************************************/ +void WinEDA_GerberFrame::SetToolbars(void) +/*******************************************/ +/* Active ou desactive les tools du toolbar horizontal, en fonction des commandes +en cours +*/ +{ +int layer = GetScreen()->m_Active_Layer; +GERBER_Descr * Gerber_layer_descr = g_GERBER_Descr_List[layer]; + + if( m_HToolBar == NULL ) return; + + if ( GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) + { + m_HToolBar->EnableTool(wxID_CUT,TRUE); + m_HToolBar->EnableTool(wxID_COPY,TRUE); + } + else + { + m_HToolBar->EnableTool(wxID_CUT,FALSE); + m_HToolBar->EnableTool(wxID_COPY,FALSE); + } + + if ( g_UnDeleteStackPtr ) + { + m_HToolBar->EnableTool(wxID_PASTE,TRUE); + m_HToolBar->EnableTool(ID_UNDO_BUTT,TRUE); + } + else + { + m_HToolBar->EnableTool(wxID_PASTE,FALSE); + m_HToolBar->EnableTool(ID_UNDO_BUTT,FALSE); + } + + + if ( m_SelLayerBox->GetSelection() != GetScreen()->m_Active_Layer ) + { + m_SelLayerBox->SetSelection( GetScreen()->m_Active_Layer ); + } + + if ( Gerber_layer_descr ) + { + int sel_index; + m_SelLayerTool->Enable(TRUE); + if ( Gerber_layer_descr->m_Selected_Tool < FIRST_DCODE ) // No tool selected + sel_index = 0; + else + sel_index = Gerber_layer_descr->m_Selected_Tool - FIRST_DCODE + 1; + + if ( sel_index != m_SelLayerTool->GetSelection() ) + { + m_SelLayerTool->SetSelection(sel_index); + } + } + else + { + m_SelLayerTool->SetSelection(0); + m_SelLayerTool->Enable(FALSE); + } + + if ( m_OptionsToolBar ) + { + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_MM, + g_UnitMetric == MILLIMETRE ? TRUE : FALSE); + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_INCH, + g_UnitMetric == INCHES ? TRUE : FALSE); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_POLAR_COORD, + DisplayOpt.DisplayPolarCood); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_GRID, + m_Draw_Grid); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_CURSOR, + g_CursorShape); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_PADS_SKETCH, + ! m_DisplayPadFill); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, + ! m_DisplayPcbTrackFill); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_DCODES, + DisplayOpt.DisplayPadNum); + } + + DisplayUnitsMsg(); +} + +/*************************************/ +int WinEDA_GerberFrame::BestZoom(void) +/*************************************/ +{ +int ii,jj ; +int bestzoom; +wxSize size; + + /* calcul du zoom montrant tout le dessim */ + m_Pcb->ComputeBoundaryBox(); + size = DrawPanel->GetClientSize(); + ii = m_Pcb->m_BoundaryBox.GetWidth() / size.x; + jj = m_Pcb->m_BoundaryBox.GetHeight() / size.y; + bestzoom = MAX(ii, jj) + 1; + + /* determination du zoom existant le plus proche */ + for (ii = 1 ; ii < 2048 ; ii <<= 1 ) + { + if(ii >= bestzoom) break; + } + bestzoom = ii; + + GetScreen()->m_Curseur = m_Pcb->m_BoundaryBox.Centre(); + + return(bestzoom); +} + diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp new file mode 100644 index 0000000000..80878bd3ff --- /dev/null +++ b/gerbview/gerbview.cpp @@ -0,0 +1,76 @@ + /************************************************/ + /* GERBVIEW main file */ + /************************************************/ + +#define MAIN +#define eda_global + +#include "fctsys.h" + +#include +#include + +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" +#include "trigo.h" +#include "bitmaps.h" +#include "protos.h" + + +wxString g_Main_Title = wxT("GERBVIEW"); + +IMPLEMENT_APP(WinEDA_App) + +bool WinEDA_App::OnInit(void) +{ +wxString FFileName; + + EDA_Appl = this; + InitEDA_Appl( wxT("gerbview") ); + + if(argc > 1) FFileName = MakeFileName(wxEmptyString, argv[1], g_PhotoFilenameExt); + + ScreenPcb = new PCB_SCREEN(PCB_FRAME); + ActiveScreen = ScreenPcb; + GetSettings(); + if ( m_Checker && m_Checker->IsAnotherRunning() ) + { + if ( ! IsOK(NULL, _("Gerbview is already running, Continue?") ) ) + return false; + } + + + g_DrawBgColor = BLACK; + + m_GerberFrame = new WinEDA_GerberFrame(NULL, this, wxT("GerbView"), + wxPoint(0,0), wxSize(600,400) ); + wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); + m_GerberFrame->SetTitle(Title); + m_GerberFrame->m_Pcb = new BOARD(NULL, m_GerberFrame); + + SetTopWindow(m_GerberFrame); + m_GerberFrame->Show(TRUE); + + m_GerberFrame->m_Pcb = new BOARD(NULL, m_GerberFrame); + m_GerberFrame->Zoom_Automatique(TRUE); + + /* Load file specified in the command line. */ + if( ! FFileName.IsEmpty() ) + { + wxString path = wxPathOnly(FFileName); + wxSetWorkingDirectory(path); + Read_Config(); + if ( wxFileExists(FFileName) ) + { + wxClientDC dc(m_GerberFrame->DrawPanel); + m_GerberFrame->DrawPanel->PrepareGraphicContext(&dc); + m_GerberFrame->LoadOneGerberFile(FFileName, &dc, FALSE); + } + } + else Read_Config(); + + return TRUE; +} + + diff --git a/gerbview/gerbview.h b/gerbview/gerbview.h new file mode 100644 index 0000000000..3c4a288825 --- /dev/null +++ b/gerbview/gerbview.h @@ -0,0 +1,199 @@ + /*******************************************************/ + /* Menu General de Trace (PLOT): Fichier inclus PLOT.H */ + /*******************************************************/ + +#ifndef GERBVIEW_H +#define GERBVIEW_H + +#ifndef eda_global +#define eda_global extern +#endif + +// Type d'action du phototraceur: +#define GERB_ACTIVE_DRAW 1 // activation de lumiere ( baisser de plume) +#define GERB_STOP_DRAW 2 // extinction de lumiere ( lever de plume) +#define GERB_FLASH 3 // Flash + + +typedef enum { + FORMAT_HPGL, + FORMAT_GERBER, + FORMAT_POST + } PlotFormat; + + +//eda_global wxString g_Plot_FileName; +eda_global wxString g_PhotoFilenameExt; +eda_global wxString g_DrillFilenameExt; +eda_global wxString g_PenFilenameExt; + +eda_global int g_DCodesColor; +eda_global int g_Default_GERBER_Format; + + +/* Gestion des ouvertures GERBER */ +eda_global int g_Plot_Spot_Mini; /* Diametre mini de l'ouverture pour trace GERBER */ + + + + /*************************************/ + /* Constantes utiles en trace GERBER */ + /*************************************/ + +/* codes de type de forme d'outils */ +enum Gerb_StandardShape +{ + GERB_CIRCLE = 1, + GERB_RECT, + GERB_LINE, + GERB_OVALE, + GERB_SPECIAL_SHAPE +}; + +// Interpolation type +enum Gerb_Interpolation +{ + GERB_INTERPOL_LINEAR_1X = 0, + GERB_INTERPOL_LINEAR_10X, + GERB_INTERPOL_LINEAR_01X, + GERB_INTERPOL_LINEAR_001X, + GERB_INTERPOL_ARC_NEG, + GERB_INTERPOL_ARC_POS, +}; + + +// Command Type (GCodes) +enum Gerb_GCommand +{ + GC_MOVE = 0, + GC_LINEAR_INTERPOL_1X = 1, + GC_CIRCLE_NEG_INTERPOL = 2, + GC_CIRCLE_POS_INTERPOL = 3, + GC_COMMENT = 4, + GC_LINEAR_INTERPOL_10X = 10, + GC_LINEAR_INTERPOL_0P1X = 11, + GC_LINEAR_INTERPOL_0P01X = 12, + GC_TURN_ON_POLY_FILL = 36, + GC_TURN_OFF_POLY_FILL = 37, + GC_SELECT_TOOL = 54, + GC_SPECIFY_INCHES = 70, + GC_SPECIFY_MILLIMETERS = 71, + GC_TURN_OFF_360_INTERPOL = 74, + GC_TURN_ON_360_INTERPOL = 75, + GC_SPECIFY_ABSOLUES_COORD = 90, + GC_SPECIFY_RELATIVEES_COORD = 91 +}; + + +#define MAX_TOOLS 512 +#define FIRST_DCODE 10 + +enum Gerb_Analyse_Cmd +{ + CMD_IDLE = 0, + END_BLOCK, + ENTER_RS274X_CMD +}; + + +class D_CODE; + +/* Structure de Description d'option d'une layer GERBER : */ +class GERBER_Descr +{ +public: + GERBER_Descr * m_Parent; // Pointeur sur la racine pour layers imbriquées + GERBER_Descr * m_Pback; // Pointeur de chainage arriere pour layers imbriquées + GERBER_Descr * m_Pnext; // Pointeur de chainage avant pour layers imbriquées + wxString m_FileName; // Full File Name for this layer + wxString m_Name; // Layer name + int m_Layer; // Layer Number + bool m_LayerNegative; // TRUE = Negative Layer + bool m_GerbMetric; // FALSE = Inches, TRUE = metric + bool m_Relative; // FALSE = absolute Coord, RUE = relative Coord + bool m_NoTrailingZeros; // True: zeros a droite supprimés + bool m_MirorA; // True: miror / axe A (X) + bool m_MirorB; // True: miror / axe B (Y) + bool m_As_DCode; // TRUE = DCodes in file (FALSE = no DCode-> + // separate DCode file + wxPoint m_Offset; // Coord Offset + wxSize m_FmtScale; // Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4 + wxSize m_FmtLen; // Nb chars per coord. ex fmt 2.3, m_FmtLen = 5 + wxRealPoint m_LayerScale; // scale (X et Y) pour cette layer + int m_Rotation; + int m_Iterpolation; // Linear, 90 arc, Circ. + bool m_ImageNegative; // TRUE = Negative image + int m_Current_Tool; // Current Tool (Dcode) number selected + int m_CommandState; // donne l'etat de l'analyse des commandes gerber + wxPoint m_CurrentPos; // current specified coord for plot + wxPoint m_PreviousPos; // old current specified coord for plot + wxPoint m_IJPos; // IJ coord (for arcs & circles ) + D_CODE * m_Aperture_List[MAX_TOOLS+FIRST_DCODE+1]; // Dcode (Aperture) List for this layer + + FILE * m_Current_File; // Current file to read + FILE * m_FilesList[12]; // Files list + int m_FilesPtr; // Stack pointer for files list + + int m_Selected_Tool; // Pour editions: Tool (Dcode) selectionné + + int m_Transform[2][2]; // The rotation/mirror transformation matrix. + bool m_360Arc_enbl; // Enbl 360 deg circular interpolation + bool m_PolygonFillMode; // Enbl polygon mode (read coord as a polygone descr) + int m_PolygonFillModeState; // In polygon mode: 0 = first segm, 1 = next segm + +public: + GERBER_Descr(int layer); + ~GERBER_Descr(void); + void Clear_GERBER_Descr(void); + int ReturnUsedDcodeNumber(void); + void ResetDefaultValues(void); + void InitToolTable(void); + + // Routines utilisées en lecture de ficher gerber + wxPoint ReadXYCoord(char * &Text); + wxPoint ReadIJCoord(char * &Text); + int ReturnGCodeNumber(char * &Text); + int ReturnDCodeNumber(char * &Text); + bool Execute_G_Command(char * &text, int G_commande); + bool Execute_DCODE_Command(WinEDA_GerberFrame * frame, wxDC * DC, + char * &text, int D_commande); + bool ReadRS274XCommand(WinEDA_GerberFrame * frame, wxDC * DC, + char * buff, char * &text); + bool ExecuteRS274XCommand(int command, char * buff, char * &text); +}; + + +/* Structure de Description d'un D_CODE GERBER : */ + +class D_CODE +{ +public: + wxSize m_Size; /* Dimensions horiz et Vert */ + int m_Shape ; /* shape ( Line, rect , circulaire , ovale .. ) */ + int m_Num_Dcode; /* numero de code ( >= 10 ) */ + wxSize m_Drill ; /* dimension du trou central (s'il existe) */ + int m_DrillShape; /* forme du trou central ( rond = 1, rect = 2 ) */ + bool m_InUse; /* FALSE si non utilisé */ + bool m_Defined; /* FALSE si non defini */ + wxString m_SpecialDescr; + +public: + D_CODE(int num_dcode); + ~D_CODE(); + void Clear_D_CODE_Data(void); +}; + +eda_global wxChar *g_GERBER_Tool_Type[6] +#ifdef MAIN + = { wxT("????"), wxT("Rond"), wxT("Rect"), wxT("Line"), wxT("Oval"), wxT("Macro") + } +#endif +; + +eda_global GERBER_Descr * g_GERBER_Descr_List[32]; + + +#include "pcbnew.h" + +#endif // ifndef GERBVIEW_H + diff --git a/gerbview/gerbview.ico b/gerbview/gerbview.ico new file mode 100644 index 0000000000000000000000000000000000000000..b4e547348678caa748ffc244c9c4b960525fafe5 GIT binary patch literal 3262 zcmds3eN0nV6n_O&3>AoN{a~mt1)X(%tqkUb0h=FL5H}LG$*h?%lK2(f#&-)XDn_No z6o_WN*u@$AnCJkV%u1Xlft|IU1PZtZ-NL{tEX752qE&w z5lmTGm<}H%4;>;89>kQHNlK-pM1ma-{T8uYW-p|GM^?N^m^3QWp~twPS;UUQBzoWOQFb@$?~(aZ;@n8K|x1p>4-*S zKW@d<4!qyk8!T`C9nsMP1qJxH8yhjs;2^SCtoQ~4VyI{>FHeY%-xL|SeDPwh88d)@ z*%T46CoV2eEWRX@_1wNqt7tD#3O@Ms-GBgfP7du5dcxu}t@ypY=5B*R z_58i;q4_a#w&%>CkhSafo(?}$d-diWl}aU-%j4tYgM)*)-rfn@w?ka0&z(D&lr)FS zJ+^!Ih*D{F2pDNJ0&u%gf{Oc#$C?OBXKO92VA@pN}s;?U3is5k;9yCaF|9ZJImWPaI+N{p{}-oHP?} zt@&uv*0-~aG_t*4kY%#La74f<5=<@#6^2f_8|>1ZFFh%D}+D_xXId|9^|$ zfq{9Sod^hy;$@lvmMb-1xUB>7${4Y0abSEu`F1IP^$48fm_rN(!uTxTx)EiVre z2$;>pZ`Wu%*q+~Pj=gwD< zE^2F?@nbh{-oJmp{8wu*I@>=rjdB-J&`(LD+|n#AsTNj>B_OeOk-xt{AP5r(nhFc; zmlo2XgZ;C4JaC=5x?!dS`^SMm2(Oq&K=ZJK?cuTZ<1bbo?iXagQWSQXH8>4Ire)&m z^?DA6Lodm>+2)o?G4WvtLT7MV0t<=oY+_d@y#!RiE+CmR@r#R#LqkLD2nFTZ@Z3Rg z5fCsiw7+s@U?H)3?A_g9q?r`nNTQnUh6EW(bVs|(6i*|&~(x0JI98S zfA0Qz>o#I>?70h7C1p56V*JKNC`tcdzcVZ?0r1r)UNT(=JU==S?8kvQc4~_2Jy4Py z@R|Of3>@TOxdS*1z31`cc4Y}Oo;;+7EFz%Xg8x$eIwGL97y62nc_C zR$AEv{T%6#C!4K0e}25MLQZaOcE*p5iQy+yPKr$5SQ|co!*-yL`0jGhiWPrAb!OIX ztrk8H9PDq`YNz@~jN#+haZR;A5W&rafSM-4ku_aRfsi(Uwtv?TnyDTf;wzPdRggNJ z@sZg)|I1U$mMzn0G?N{HIpR~4d3f~nofosh_Cb1wBtM}F z5N-k78MmqB$BA8sJUYe7#M;OUNI(4$};W8{F|V$0%NlP W2Dswb9&7QL@Q=lqXPf`p|9=59qb&vi literal 0 HcmV?d00001 diff --git a/gerbview/gerbview.r b/gerbview/gerbview.r new file mode 100644 index 0000000000..79cbe6622c --- /dev/null +++ b/gerbview/gerbview.r @@ -0,0 +1,7 @@ +data 'vers' (2) { +$"0100 2000 0000 0531 2E30 6430 0531 2E30" +$"6430"} ; + +data 'vers' (1) { +$"0100 2000 0000 0531 2E30 6430 0531 2E30" +$"6430"} ; diff --git a/gerbview/gerbview.rc b/gerbview/gerbview.rc new file mode 100644 index 0000000000..713c96f36f --- /dev/null +++ b/gerbview/gerbview.rc @@ -0,0 +1,2 @@ +a_icon_gerbview ICON "gerbview.ico" +#include "wx/msw/wx.rc" diff --git a/gerbview/initpcb.cpp b/gerbview/initpcb.cpp new file mode 100644 index 0000000000..279d662622 --- /dev/null +++ b/gerbview/initpcb.cpp @@ -0,0 +1,218 @@ + /**********************************************/ + /* GERBVIEW : Routines d'initialisation globale */ + /******* Fichier INITPCB.C ********************/ + /**********************************************/ + + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" + +#include "protos.h" + +/* Routines Locales */ + + + +/********************************************************/ +bool WinEDA_GerberFrame::Clear_Pcb(wxDC * DC, bool query) +/********************************************************/ +/* Realise les init des pointeurs et variables + Si Item == NULL, il n'y aura pas de confirmation +*/ +{ +int layer; + + if( m_Pcb == NULL ) return FALSE; + + if ( query ) + { + if (m_Pcb->m_Drawings || m_Pcb->m_Track || m_Pcb->m_Zone ) + { + if( ! IsOK(this, _("Current Data will be lost ?")) ) return FALSE; + } + } + + DeleteStructList(m_Pcb->m_Drawings); + m_Pcb->m_Drawings = NULL; + + DeleteStructList(m_Pcb->m_Track); + m_Pcb->m_Track = NULL; + m_Pcb->m_NbSegmTrack = 0; + + DeleteStructList(m_Pcb->m_Zone); + m_Pcb->m_Zone = NULL; + m_Pcb->m_NbSegmZone = 0; + + for ( ; g_UnDeleteStackPtr != 0; ) + { + g_UnDeleteStackPtr--; + DeleteStructList(g_UnDeleteStack[ g_UnDeleteStackPtr]); + } + + /* init pointeurs et variables */ + for ( layer = 0; layer < 32; layer++ ) + { + if ( g_GERBER_Descr_List[layer] ) + g_GERBER_Descr_List[layer]->InitToolTable(); + } + + /* remise a 0 ou a une valeur initiale des variables de la structure */ + m_Pcb->m_BoundaryBox.SetOrigin(0,0); + m_Pcb->m_BoundaryBox.SetSize(0,0); + m_Pcb->m_Status_Pcb = 0; + m_Pcb->m_NbLoclinks = 0; + m_Pcb->m_NbLinks = 0; + m_Pcb->m_NbPads = 0; + m_Pcb->m_NbNets = 0; + m_Pcb->m_NbNodes = 0; + m_Pcb->m_NbNoconnect = 0; + m_Pcb->m_NbSegmTrack = 0; + m_Pcb->m_NbSegmZone = 0; + + /* Init parametres de gestion des ecrans PAD et PCB */ + m_CurrentScreen = ActiveScreen = ScreenPcb; + GetScreen()->Init(); + + return TRUE; +} + +/*********************************************************/ +void WinEDA_GerberFrame::Erase_Zones(wxDC * DC, bool query) +/*********************************************************/ +{ + + if( query && !IsOK(this, _("Delete zones ?") ) ) return ; + + if( m_Pcb->m_Zone ) + { + DeleteStructList(m_Pcb->m_Zone); + m_Pcb->m_Zone = NULL; + m_Pcb->m_NbSegmZone = 0; + } + ScreenPcb->SetModify(); +} + + +/*****************************************************/ +void WinEDA_GerberFrame::Erase_Segments_Pcb(wxDC * DC, + bool all_layers, bool query) +/*****************************************************/ +{ +EDA_BaseStruct * PtStruct, *PtNext; +int layer = GetScreen()->m_Active_Layer; + + if ( all_layers ) layer = -1; + + PtStruct = (EDA_BaseStruct *) m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtNext) + { + PtNext = PtStruct->Pnext; + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + if( (((DRAWSEGMENT*)PtStruct)->m_Layer == layer) + || layer < 0) + DeleteStructure(PtStruct); + break; + + case TYPETEXTE: + if( (((TEXTE_PCB*)PtStruct)->m_Layer == layer) + || layer < 0) + DeleteStructure(PtStruct); + break; + + case TYPECOTATION: + if( (((COTATION*)PtStruct)->m_Layer == layer) + || layer < 0) + DeleteStructure(PtStruct); + break; + + case TYPEMIRE: + if( (((MIREPCB*)PtStruct)->m_Layer == layer) + || layer < 0) + DeleteStructure(PtStruct); + break; + + default: + DisplayError(this, wxT("Type Draw inconnu/inattendu")); + break; + } + } + + ScreenPcb->SetModify(); +} + + +/****************************************************************/ +void WinEDA_GerberFrame::Erase_Pistes(wxDC * DC, int masque_type, + bool query) +/****************************************************************/ +/* Efface les segments de piste, selon les autorisations affichees +masque_type = masque des options de selection: +SEGM_FIXE, SEGM_AR + Si un des bits est a 1, il n'y a pas effacement du segment de meme bit a 1 +*/ +{ +TRACK * pt_segm; +EDA_BaseStruct * PtNext; + + if( query && ! IsOK(this, _("Delete Tracks?")) ) return; + + /* Marquage des pistes a effacer */ + for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext) + { + PtNext = pt_segm->Pnext; + if( pt_segm->GetState(SEGM_FIXE|SEGM_AR) & masque_type) continue; + DeleteStructure(pt_segm); + } + + ScreenPcb->SetModify(); +} + + +/*****************************************************************/ +void WinEDA_GerberFrame::Erase_Textes_Pcb(wxDC * DC, bool query) +/*****************************************************************/ +{ +EDA_BaseStruct * PtStruct, *PtNext; + + if( query && ! IsOK(this, _("Delete Pcb Texts") ) ) return; + + PtStruct = (EDA_BaseStruct*) m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtNext) + { + PtNext = PtStruct->Pnext; + if(PtStruct->m_StructType == TYPETEXTE ) DeleteStructure(PtStruct); + } + + ScreenPcb->SetModify(); +} + +/*******************************************************************/ +void WinEDA_GerberFrame::Erase_Current_Layer(wxDC * DC, bool query) +/*******************************************************************/ +{ +TRACK * pt_segm; +EDA_BaseStruct * PtNext; +int layer = GetScreen()->m_Active_Layer; +wxString msg; + + msg.Printf( _("Delete Layer %d"), layer+1); + if( query && ! IsOK(this, msg) ) return; + + /* Marquage des pistes a effacer */ + for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext) + { + PtNext = pt_segm->Pnext; + if( pt_segm->m_Layer != layer) continue; + DeleteStructure(pt_segm); + } + + ScreenPcb->SetModify(); + ScreenPcb->SetRefreshReq(); +} + + + diff --git a/gerbview/lay2plot.cpp b/gerbview/lay2plot.cpp new file mode 100644 index 0000000000..eddfb6a37d --- /dev/null +++ b/gerbview/lay2plot.cpp @@ -0,0 +1,59 @@ + /**********************************************/ + /* Routine de selection de couches pour trace */ + /**********************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" + +#include "protos.h" + + +/* Variables locales : */ + +/* Routines Locales */ + /****************************/ + /* int GetLayerNumber(void) */ + /****************************/ +/* retourne le nombre de couches a tracer +*/ +int GetLayerNumber(void) +{ +int ii = 0; +//TO REDO +return ii; +} + + +/*******************************************************************************/ +void Print_PcbItems(BOARD * Pcb, wxDC *DC, int drawmode, int printmasklayer) +/*******************************************************************************/ +/* routine de trace du pcb, avec selection des couches */ +{ +DISPLAY_OPTIONS save_opt; +TRACK * pt_piste; + + save_opt = DisplayOpt; + DisplayOpt.DisplayPadFill = FILLED; + DisplayOpt.DisplayPadNum = 0; + DisplayOpt.DisplayPadNoConn = 0; + DisplayOpt.DisplayPadIsol = 0; + DisplayOpt.DisplayPcbTrackFill = FILLED; + DisplayOpt.DisplayTrackIsol = 0; + DisplayOpt.DisplayDrawItems = FILLED; + DisplayOpt.DisplayZones = 1; + + /* trace des pistes */ + pt_piste = Pcb->m_Track; + for ( ; pt_piste != NULL ; pt_piste = (TRACK*) pt_piste->Pnext ) + { +// if( (printmasklayer & ReturnMaskLayer(pt_piste) ) == 0 ) continue; + Trace_Segment(NULL, DC, pt_piste, drawmode); + } + + DisplayOpt = save_opt; +} + + + diff --git a/gerbview/locate.cpp b/gerbview/locate.cpp new file mode 100644 index 0000000000..7fa1649a42 --- /dev/null +++ b/gerbview/locate.cpp @@ -0,0 +1,448 @@ + /***************************************************/ + /* Localisation des elements pointes par la souris */ + /***************************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" +#include "trigo.h" + +#include "protos.h" + + +/* variables locales */ +int ux0 , uy0 ,dx, dy, spot_cX, spot_cY; /* Variables utilisees pour + la localisation des segments */ +/* fonctions locales */ +static TRACK * Locate_Zone(TRACK * start_adresse,int layer, int typeloc ); +static TRACK * Locate_Zone(TRACK * start_adresse, wxPoint ref, int layer); +static TRACK * Locate_Pistes(TRACK * start_adresse,int Layer, int typeloc ); +static TRACK * Locate_Pistes(TRACK * start_adresse, wxPoint ref,int Layer); +static DRAWSEGMENT * Locate_Segment_Pcb(BOARD * Pcb, int typeloc); +static TEXTE_PCB * Locate_Texte_Pcb(TEXTE_PCB* pt_txt_pcb, int typeloc); +static int distance(int seuil); +/**/ + +/* Macro de calcul de la coord de pointage selon le curseur +(ON/OFF grille) choisi +A REVOIR +*/ +#define SET_REF_POS(ref) if(typeloc == CURSEUR_ON_GRILLE) \ + { ref = ActiveScreen->m_Curseur;} \ + else { ref = ActiveScreen->m_Curseur; } + + + + +/*************************************************************/ +EDA_BaseStruct * WinEDA_GerberFrame::Locate( int typeloc ) +/*************************************************************/ +/* Fonction de localisation generale + Affiche les caract de la stucture localisée et retourne un pointeur + sur celle-ci +*/ +{ +TEXTE_PCB * pt_texte_pcb; +TRACK * Track , * TrackLocate ; +DRAWSEGMENT * DrawSegm; +int layer; + + /* Localistion des pistes et vias, avec priorite aux vias */ + layer = GetScreen()->m_Active_Layer; + Track = Locate_Pistes( m_Pcb->m_Track, NO_TST_LAYER,typeloc ); + if ( Track != NULL ) + { + TrackLocate = Track ; /* Reperage d'une piste ou via */ + /* recherche de 1 via eventuelle */ + while((TrackLocate = Locate_Pistes(TrackLocate, layer,typeloc)) != NULL ) + { + Track = TrackLocate; + if(TrackLocate->m_StructType == TYPEVIA) break ; + TrackLocate = (TRACK*) TrackLocate->Pnext; + } + Affiche_Infos_Piste(this, Track) ; + return Track; + } + + + pt_texte_pcb = Locate_Texte_Pcb((TEXTE_PCB*) m_Pcb->m_Drawings, typeloc); + if(pt_texte_pcb ) // texte type PCB localise + { + Affiche_Infos_PCB_Texte(this, pt_texte_pcb); return pt_texte_pcb; + } + + if ( (DrawSegm = Locate_Segment_Pcb(m_Pcb, typeloc)) != NULL) + { + return DrawSegm; + } + + if( (TrackLocate = Locate_Zone((TRACK*)m_Pcb->m_Zone, + GetScreen()->m_Active_Layer,typeloc)) != NULL ) + { + Affiche_Infos_Piste(this, TrackLocate) ; return TrackLocate; + } + + MsgPanel->EraseMsgBox(); + return NULL; +} + + + +/********************************************************/ +DRAWSEGMENT * Locate_Segment_Pcb(BOARD * Pcb, int typeloc) +/********************************************************/ +/* Localisation de segments de contour du type edge pcb ou draw + (selon couche active) + Retourne: + Pointeur sur DEBUT du segment localise + NULL si rien trouve +*/ +{ +EDA_BaseStruct * PtStruct; +DRAWSEGMENT * pts; +wxPoint ref; +PCB_SCREEN * screen = (PCB_SCREEN *) ActiveScreen; + SET_REF_POS(ref); + + PtStruct = Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; + pts = ( DRAWSEGMENT * ) PtStruct; + ux0 = pts->m_Start.x ; uy0 = pts->m_Start.y; + /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ + dx = pts->m_End.x - ux0 ; dy = pts->m_End.y - uy0 ; + spot_cX = ref.x - ux0; spot_cY = ref.y - uy0 ; + + /* detection : */ + if(pts->m_Layer != screen->m_Active_Layer) continue; + + if( (pts->m_Shape == S_CIRCLE) || (pts->m_Shape == S_ARC) ) + { + int rayon, dist, StAngle, EndAngle, MouseAngle; + rayon = (int) hypot((double)(dx),(double)(dy) ); + dist = (int) hypot((double)(spot_cX),(double)(spot_cY) ); + if( abs(rayon-dist) <= (pts->m_Width/2) ) + { + if(pts->m_Shape == S_CIRCLE) return(pts); + /* pour un arc, controle complementaire */ + MouseAngle = (int) ArcTangente(spot_cY, spot_cX); + StAngle = (int) ArcTangente(dy, dx); + EndAngle = StAngle + pts->m_Angle; + + if( EndAngle > 3600 ) + { + StAngle -= 3600; EndAngle -= 3600; + } + if( (MouseAngle >= StAngle) && (MouseAngle <= EndAngle) ) + return(pts); + } + } + + else + { + if( distance( pts->m_Width /2 ) ) return( pts ) ; + } + } + return(NULL) ; +} + + +/****************************************************************************/ +/* TRACK *Locate_Pistes(TRACK * start_adresse, int MasqueLayer,int typeloc) */ +/* TRACK *Locate_Pistes(TRACK * start_adresse, wxPoint ref, int MasqueLayer)*/ +/****************************************************************************/ + +/* +1 - routine de localisation du segment de piste pointe par la souris. +2 - routine de localisation du segment de piste pointe par le point + ref_pX , ref_pY.r + + La recherche commence a l'adresse start_adresse +*/ + +TRACK * Locate_Pistes(TRACK * start_adresse,int Layer, int typeloc ) +{ +wxPoint ref; + + SET_REF_POS(ref); + + return( Locate_Pistes(start_adresse, ref, Layer) ); +} + + +TRACK * Locate_Pistes(TRACK * start_adresse, wxPoint ref, int Layer) +{ +TRACK * Track; /* pointeur sur les pistes */ +int l_piste ; /* demi-largeur de la piste */ + + for( Track = start_adresse; Track != NULL; Track = (TRACK*) Track->Pnext) + { + if( Track->GetState(BUSY|DELETED) ) continue; + /* calcul des coordonnees du segment teste */ + l_piste = Track->m_Width >> 1; /* l_piste = demi largeur piste */ + ux0 = Track->m_Start.x ; uy0 = Track->m_Start.y ; /* coord de depart */ + dx = Track->m_End.x ; dy = Track->m_End.y ; /* coord d'arrivee */ + + /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ + dx -= ux0 ; dy -= uy0 ; + spot_cX = ref.x - ux0 ; spot_cY = ref.y - uy0 ; + + if ( Track->m_StructType == TYPEVIA ) /* VIA rencontree */ + { + if ((abs(spot_cX) <= l_piste ) && (abs(spot_cY) <=l_piste)) + { + return(Track) ; + } + continue ; + } + + if(Layer >= 0) + if( Track->m_Layer != Layer ) + continue; /* Segments sur couches differentes */ + if( distance(l_piste) ) return(Track) ; + } + return(NULL) ; +} + + /****************************************************************/ + /* TRACK * Locate_Zone(TRACK * start_adresse, int layer, */ + /* int typeloc) */ + /* TRACK * Locate_Zone(TRACK * start_adresse,wxPoint ref, int layer) */ + /****************************************************************/ + +/* +1 - routine de localisation du segment de zone pointe par la souris. +2 - routine de localisation du segment de zone pointe par le point + ref_pX , ref_pY.r + + Si layer == -1 , le tst de la couche n'est pas fait + + La recherche commence a l'adresse start_adresse +*/ + +TRACK * Locate_Zone(TRACK * start_adresse,int layer, int typeloc ) +{ +wxPoint ref; + + SET_REF_POS(ref); + + return( Locate_Zone(start_adresse, ref, layer) ); +} + + +TRACK * Locate_Zone(TRACK * start_adresse, wxPoint ref, int layer) +{ +TRACK * Zone; /* pointeur sur les pistes */ +int l_segm ; /* demi-largeur de la piste */ + + for( Zone = start_adresse; Zone != NULL; Zone = (TRACK *) Zone->Pnext) + { + /* calcul des coordonnees du segment teste */ + l_segm = Zone->m_Width >> 1; /* l_piste = demi largeur piste */ + ux0 = Zone->m_Start.x ; uy0 = Zone->m_Start.y ; /* coord de depart */ + dx = Zone->m_End.x ; dy = Zone->m_End.y ; /* coord d'arrivee */ + + /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ + dx -= ux0 ; dy -= uy0 ; + spot_cX = ref.x - ux0 ; spot_cY = ref.y - uy0 ; + + if((layer != -1) && (Zone->m_Layer != layer)) continue; + if( distance(l_segm) ) return(Zone) ; + } + return(NULL) ; +} + + + + /***************************************************************/ + /* TEXTE_PCB * Locate_Texte_Pcb(char * pt_txt_pcb,int typeloc) */ + /***************************************************************/ + +/* localisation des inscriptions sur le Pcb: + entree : char pointeur sur le debut de la zone de recherche + retour : pointeur sur la description du texte localise +*/ + +TEXTE_PCB * Locate_Texte_Pcb(TEXTE_PCB* pt_txt_pcb, int typeloc) +{ +int angle ; +EDA_BaseStruct * PtStruct; +wxPoint ref; + + SET_REF_POS(ref); + PtStruct = (EDA_BaseStruct *) pt_txt_pcb ; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if( PtStruct->m_StructType != TYPETEXTE ) continue; + pt_txt_pcb = (TEXTE_PCB *) PtStruct; + + angle = pt_txt_pcb->m_Orient; + ux0 = pt_txt_pcb->m_Pos.x; uy0 = pt_txt_pcb->m_Pos.y; + dx = (pt_txt_pcb->m_Size.x * pt_txt_pcb->GetLength()) / 2; + dy = pt_txt_pcb->m_Size.y /2 ; + + dx *= 13; dx /= 9; /* Facteur de forme des lettres : 13/9 */ + + /* la souris est-elle dans ce rectangle autour du centre */ + spot_cX = ref.x - ux0 ; spot_cY = ref.y - uy0 ; + RotatePoint(&spot_cX, &spot_cY, -angle); + if( (abs(spot_cX) <= abs(dx) ) && ( abs(spot_cY) <= abs(dy) ) ) + return(pt_txt_pcb) ; + } + return(NULL) ; +} + + + + /*****************************/ + /* int distance(int seuil) */ + /*****************************/ + +/* + Calcul de la distance du curseur souris a un segment de droite : + ( piste, edge, contour module .. + retourne: + 0 si distance > seuil + 1 si distance <= seuil + Variables utilisees ( doivent etre initialisees avant appel , et + sont ramenees au repere centre sur l'origine du segment) + dx, dy = coord de l'extremite segment. + spot_cX,spot_cY = coord du curseur souris + la recherche se fait selon 4 cas: + segment horizontal + segment vertical + segment 45 + segment quelconque +*/ + +int distance(int seuil) +{ +int cXrot, cYrot , /* coord du point (souris) dans le repere tourne */ + segX, segY; /* coord extremite segment tj >= 0 */ +int pointX, pointY; /* coord point a tester dans repere modifie dans lequel + segX et segY sont >=0 */ + + segX = dx ; segY = dy; pointX = spot_cX ; pointY = spot_cY ; + + /*Recalcul coord pour que le segment soit dans 1er quadrant (coord >= 0)*/ + if (segX < 0) /* mise en >0 par symetrie par rapport a l'axe Y */ + { + segX = -segX ; pointX = - pointX ; + } + if (segY < 0) /* mise en > 0 par symetrie par rapport a l'axe X */ + { + segY = -segY ; pointY = -pointY ; + } + + + if ( segY == 0 ) /* piste Horizontale */ + { + if(abs(pointY) <= seuil ) + { + if((pointX >= 0) && (pointX <= segX) ) return(1); + /* Etude des extremites : cercle de rayon seuil */ + if( (pointX < 0) && (pointX >= -seuil) ) + { + if( ((pointX * pointX) + (pointY*pointY)) <= (seuil*seuil) ) + return(1); + } + if( (pointX > segX) && (pointX <= (segX+seuil)) ) + { + if( (((pointX-segX) * (pointX-segX)) + (pointY*pointY)) <= (seuil*seuil) ) + return(1); + } + } + } + + else if ( segX == 0 ) /* piste verticale */ + { + if( abs(pointX) <= seuil) + { + if((pointY >= 0 ) && (pointY <= segY) ) return(1); + if( (pointY < 0) && (pointY >= -seuil) ) + { + if( ((pointY * pointY) + (pointX*pointX)) <= (seuil*seuil) ) + return(1); + } + if( (pointY > segY) && (pointY <= (segY+seuil)) ) + { + if( ( ((pointY-segY) * (pointY-segY)) + (pointX*pointX)) <= (seuil*seuil) ) + return(1); + } + } + } + + else if ( segX == segY ) /* piste a 45 degre */ + { + /* on fait tourner les axes de 45 degre. la souris a alors les + coord : x1 = x*cos45 + y*sin45 + y1 = y*cos45 - x*sin45 + et le segment de piste est alors horizontal. + recalcul des coord de la souris ( sin45 = cos45 = .707 = 7/10 + remarque : sin ou cos45 = .707, et lors du recalcul des coord + dx45 et dy45, lec coeff .707 est neglige, dx et dy sont en fait .707 fois + trop grands. (c.a.d trop petits) + spot_cX,Y doit etre * par .707 * .707 = 0.5 */ + + cXrot = (pointX + pointY) >> 1 ; + cYrot = (pointY - pointX) >> 1 ; + + /* recalcul des coord de l'extremite du segment , qui sera vertical + suite a l'orientation des axes sur l'ecran : dx45 = pointX (ou pointY) + et est en fait 1,414 plus grand , et dy45 = 0 */ + + // seuil doit etre * .707 pour tenir compte du coeff de reduction sur dx,dy + seuil *= 7 ; seuil /= 10 ; + if ( abs(cYrot) <= seuil) /* ok sur axe vertical) */ + { + if ((cXrot >= 0) && (cXrot <= segX) ) return(1) ; + + /* Etude des extremites : cercle de rayon seuil */ + if( (cXrot < 0) && (cXrot >= -seuil) ) + { + if( ((cXrot * cXrot) + (cYrot*cYrot)) <= (seuil*seuil) ) + return(1); + } + if( (cXrot > segX) && (cXrot <= (segX+seuil)) ) + { + if( (((cXrot-segX) * (cXrot-segX)) + (cYrot*cYrot)) <= (seuil*seuil) ) + return(1); + } + } + } + else /* orientation quelconque */ + { + /* On fait un changement d'axe (rotation) de facon a ce que le segment + de piste soit horizontal dans le nouveau repere */ + int angle; + + angle = (int)( atan2((float)segY, (float)segX) * 1800 / M_PI) ; + cXrot = pointX; cYrot = pointY; + RotatePoint(&cXrot, &cYrot, angle); /* Rotation du point a tester */ + RotatePoint(&segX, &segY, angle) ; /* Rotation du segment */ + + /*la piste est Horizontale , par suite des modifs de coordonnes + et d'axe, donc segX = longueur du segment */ + + if ( abs(cYrot) <= seuil ) /* ok sur axe vertical) */ + { + if ((cXrot >= 0) && (cXrot <= segX) ) return(1) ; + /* Etude des extremites : cercle de rayon seuil */ + if( (cXrot < 0) && (cXrot >= -seuil) ) + { + if( ((cXrot * cXrot) + (cYrot*cYrot)) <= (seuil*seuil) ) + return(1); + } + if( (cXrot > segX) && (cXrot <= (segX+seuil)) ) + { + if( (((cXrot-segX) * (cXrot-segX)) + (cYrot*cYrot)) <= (seuil*seuil) ) + return(1); + } + } + } + return(0) ; +} + + diff --git a/gerbview/makefile.g95 b/gerbview/makefile.g95 new file mode 100644 index 0000000000..c83dbca06d --- /dev/null +++ b/gerbview/makefile.g95 @@ -0,0 +1,31 @@ +# Makefile for gerbview, Windows + +WXDIR = $(WXWIN) +include ../libs.win + +TARGET=gerbview + +all: $(TARGET).exe + +include makefile.include + +$(TARGET).exe: $(OBJECTS) $(TARGET)_resources.o $(EDALIB) + $(CXX) $(ALL_LDFLAGS) -o $(TARGET).exe $(OBJECTS)\ + $(TARGET)_resources.o $(EDALIBS) $(SYSWXLIB) + +install: + cp $(TARGET).exe $(KICAD_BIN) + + +$(TARGET)_resources.o: $(TARGET).rc + $(RESCOMP) $(RCINPUTSWITCH) $(TARGET).rc $(RCOUTPUTSWITCH) $(TARGET)_resources.o $(RESFLAGS) + + +clean : + rm -f *.o + rm -f core + rm -f *.rsc + rm -f *.res + rm -f *.bak + rm -f *.exe + diff --git a/gerbview/makefile.gtk b/gerbview/makefile.gtk new file mode 100644 index 0000000000..42d5f0cf94 --- /dev/null +++ b/gerbview/makefile.gtk @@ -0,0 +1,38 @@ +## Makefile for GERBVIEW et wxGTK +CC = gcc +LD = gcc + +# Compiler flags. +CPPFLAGS = -Wall -O2 `wx-config --cxxflags` + +LDFLAGS = -s + +include ../libs.linux + + +TARGET = gerbview + +all: $(TARGET) + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + + +$(TARGET): $(OBJECTS) makefile.gtk makefile.include $(EXTRALIBS) ../libs.linux + $(LD) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $(TARGET) + +install: + cp $(TARGET) $(KICAD_BIN) + + +clean: + rm -f *.o + rm -f *.exe + rm -f *.res + rm -f *.map + rm -f $(TARGET) + + + diff --git a/gerbview/makefile.include b/gerbview/makefile.include new file mode 100644 index 0000000000..5c42ca83b1 --- /dev/null +++ b/gerbview/makefile.include @@ -0,0 +1,169 @@ +EXTRALIBS = ../common/common.a +EXTRACPPFLAGS= -DGERBVIEW -DPCBNEW -I./ -I../gerbview -I../include\ + -I../share -I../pcbnew -I../3d-viewer + +#COMMON = pcbnew.h struct.h + +OBJECTS= \ + $(TARGET).o\ + classpcb.o\ + lay2plot.o\ + wxprint.o \ + edit.o \ + setpage.o \ + tool_gerber.o \ + gerberframe.o\ + onrightclick.o\ + class_board.o\ + class_track.o \ + drawframe.o\ + drawpanel.o\ + set_color.o \ + cfg.o \ + cursors.o \ + affiche.o \ + tracepcb.o \ + class_pcb_text.o\ + trpiste.o \ + zoom.o\ + reglage.o \ + options.o \ + initpcb.o\ + locate.o\ + deltrack.o\ + pcbplot.o\ + readgerb.o\ + rs274d.o\ + rs274x.o\ + dcode.o\ + undelete.o\ + infospgm.o \ + struct.o \ + files.o\ + block.o\ + controle.o\ + basepcbframe.o + +setpage.o: ../share/setpage.cpp + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +drawpanel.o: ../share/drawpanel.cpp + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +drawframe.o: ../share/drawframe.cpp + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +controle.o: controle.cpp $(COMMON) + +set_color.o: set_color.cpp set_color.h $(COMMON) + +files.o: files.cpp $(COMMON) + +cursors.o: ../pcbnew/cursors.cpp $(COMMON) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +wxprint.o: ../share/wxprint.cpp ../share/dialog_print.cpp ../share/dialog_print.h $(COMMON) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +lay2plot.o: lay2plot.cpp $(COMMON) + +classpcb.o: ../pcbnew/classpcb.cpp $(COMMON) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +class_pcb_text.o: ../pcbnew/class_pcb_text.cpp ../pcbnew/class_pcb_text.h $(COMMON) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +class_board.o: ../pcbnew/class_board.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +basepcbframe.o: ../pcbnew/basepcbframe.cpp $(COMMON) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +class_track.o: ../pcbnew/class_track.cpp $(COMMON) + $(CC) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp + +$(TARGET).o: $(TARGET).cpp $(COMMON) + +cfg.o: cfg.cpp cfg.h $(COMMON) + +tracepcb.o: tracepcb.cpp $(COMMON) + +block.o: block.cpp $(COMMON) + +trpiste.o: trpiste.cpp $(COMMON) + +surbrill.o: surbrill.cpp $(COMMON) + +pcbtexte.o: pcbtexte.cpp $(COMMON) + +zoom.o: ../share/zoom.cpp $(COMMON) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +infospgm.o: ../share/infospgm.cpp $(COMMON) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +affiche.o: affiche.cpp $(COMMON) + +reglage.o: reglage.cpp $(COMMON) + +editrack.o: editrack.cpp $(COMMON) + +deltrack.o: deltrack.cpp $(COMMON) + +track.o: track.cpp $(COMMON) + +editrout.o: editrout.cpp autorout.h $(COMMON) + +editmod.o: editmod.cpp autorout.h $(COMMON) + +editpads.o: editpads.cpp $(COMMON) + +editedge.o: editedge.cpp $(COMMON) + +cotation.o: cotation.cpp $(COMMON) + +editexte.o: editexte.cpp $(COMMON) + +clean.o: clean.cpp autorout.h $(COMMON) + +pcbplot.o: pcbplot.cpp $(COMMON) + +plothpgl.o: plothpgl.cpp $(COMMON) + +plotgerb.o: plotgerb.cpp pcbplot.h $(COMMON) + +printps.o: printps.cpp pcbplot.h $(COMMON) + +readgerb.o: readgerb.cpp pcbplot.h $(COMMON) + +plot_rtn.o: plot_rtn.cpp pcbplot.h $(COMMON) + +gendrill.o: gendrill.cpp pcbplot.h $(COMMON) + +librairi.o: librairi.cpp autorout.h librairi.h $(COMMON) + +docedit.o: docedit.cpp $(COMMON) + +edgemod.o: edgemod.cpp $(COMMON) + +autorout.o: autorout.cpp cell.h autorout.fct autorout.h $(COMMON) + +setlayer.o: setlayer.cpp $(COMMON) + +dist.o: dist.cpp cell.h autorout.fct $(COMMON) + +zones.o: zones.cpp cell.h autorout.fct $(COMMON) + +undelete.o: undelete.cpp $(COMMON) + +ioascii.o: ioascii.cpp $(COMMON) + +chrono.o: chrono.cpp pcbnew.h + +struct.o: struct.cpp $(COMMON) + +coordbox.o: coordbox.cpp $(COMMON) + +mirepcb.o: mirepcb.cpp $(COMMON) + +dragsegm.o: dragsegm.cpp drag.h $(COMMON) diff --git a/gerbview/makefile.macosx b/gerbview/makefile.macosx new file mode 100644 index 0000000000..fb91ed839e --- /dev/null +++ b/gerbview/makefile.macosx @@ -0,0 +1,42 @@ +## Makefile for GERBVIEW et wxGTK +CC = gcc +LD = g++ + +# Compiler flags. +CPPFLAGS = -Wall -O2 `wx-config --cxxflags` + +LDFLAGS = + +EXTRALIBS = ../common/common.a +include ../libs.macosx + + +TARGET = gerbview + +all: $(TARGET) + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + + +$(TARGET): $(OBJECTS) $(TARGET).r makefile.macosx makefile.include $(EXTRALIBS) ../libs.macosx + $(LD) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $(TARGET) + $(RESCOMP) -o $(TARGET) Carbon.r $(TARGET).r + $(SETFILE) -a C $(TARGET) + + +install: + cp $(TARGET) $(KICAD_BIN) + + +clean: + rm -f *.o + rm -f *.exe + rm -f *.res + rm -f *.map + rm -f $(TARGET) + + + diff --git a/gerbview/onrightclick.cpp b/gerbview/onrightclick.cpp new file mode 100644 index 0000000000..3254eebb4b --- /dev/null +++ b/gerbview/onrightclick.cpp @@ -0,0 +1,86 @@ + /******************************************************/ + /* edit.cpp: fonctions generales de l'edition du PCB */ + /******************************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" + +#include "id.h" + +#include "protos.h" + +/********************************************************************************/ +void WinEDA_GerberFrame::OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu) +/********************************************************************************/ +/* Prepare le menu PullUp affiché par un click sur le bouton droit +de la souris. + Ce menu est ensuite complété par la liste des commandes de ZOOM +*/ +{ +EDA_BaseStruct *DrawStruct = GetScreen()->m_CurrentItem; +wxString msg; +bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE); + + DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu + + // Simple localisation des elements si possible + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + DrawStruct = GerberGeneralLocateAndDisplay(); + } + + // Si commande en cours: affichage fin de commande + if ( m_ID_current_state ) + { + if ( DrawStruct && DrawStruct->m_Flags ) + PopMenu->Append(ID_POPUP_CANCEL_CURRENT_COMMAND, _("Cancel")); + else PopMenu->Append(ID_POPUP_CLOSE_CURRENT_TOOL, _("End Tool")); + PopMenu->AppendSeparator(); + } + + else + { + if ( (DrawStruct && DrawStruct->m_Flags) || BlockActive ) + { + if ( BlockActive ) + { + PopMenu->Append(ID_POPUP_CANCEL_CURRENT_COMMAND, _("Cancel Block") ); + PopMenu->Append(ID_POPUP_ZOOM_BLOCK, _("Zoom Block (Midd butt drag)") ); + PopMenu->AppendSeparator(); + PopMenu->Append(ID_POPUP_PLACE_BLOCK, _("Place Block") ); + PopMenu->Append(ID_POPUP_COPY_BLOCK, _("Copy Block (shift mouse)") ); + PopMenu->Append(ID_POPUP_DELETE_BLOCK, _("Delete Block (ctrl + drag mouse)") ); + } + else PopMenu->Append(ID_POPUP_CANCEL_CURRENT_COMMAND, _("Cancel")); + PopMenu->AppendSeparator(); + } + } + + if ( BlockActive ) return; + + if ( DrawStruct == NULL ) return; + + GetScreen()->m_CurrentItem = DrawStruct; + + switch ( DrawStruct->m_StructType ) + { + + case TYPETRACK: +// PopMenu->Append(ID_POPUP_PCB_EDIT_TRACK, _("Edit")); +// PopMenu->Append(ID_POPUP_PCB_DELETE_TRACKSEG, _("Delete")); + break; + + + default: + msg.Printf( + wxT("WinEDA_GerberFrame::OnRightClick Error: iilegal or unknown DrawType %d"), + DrawStruct->m_StructType); + DisplayError(this, msg ); + break; + } + PopMenu->AppendSeparator(); +} + diff --git a/gerbview/options.cpp b/gerbview/options.cpp new file mode 100644 index 0000000000..e6ae4bb710 --- /dev/null +++ b/gerbview/options.cpp @@ -0,0 +1,403 @@ + /********************************************/ + /* GERBVIEW - Gestion des Options et Reglages */ + /********************************************/ + + /* Fichier options.cpp */ + +/* + Affichage et modifications des parametres de travail Gerbview +*/ + + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" + +#include "id.h" + +#include "protos.h" +#include + +/* Fonctions locales */ + +/* variables locales */ + +/*****************************************************************/ +void WinEDA_GerberFrame::OnSelectOptionToolbar(wxCommandEvent& event) +/*****************************************************************/ +{ +int id = event.GetId(); +wxClientDC dc(DrawPanel); + + DrawPanel->PrepareGraphicContext(&dc); + switch ( id ) + { + case ID_TB_OPTIONS_SHOW_GRID: + m_Draw_Grid = g_ShowGrid = m_OptionsToolBar->GetToolState(id); + DrawPanel->ReDraw(&dc, TRUE); + break; + + case ID_TB_OPTIONS_SELECT_UNIT_MM: + g_UnitMetric = MILLIMETRE; + Affiche_Status_Box(); /* Reaffichage des coord curseur */ + break; + + case ID_TB_OPTIONS_SELECT_UNIT_INCH: + g_UnitMetric = INCHES; + Affiche_Status_Box(); /* Reaffichage des coord curseur */ + break; + + case ID_TB_OPTIONS_SHOW_POLAR_COORD: + Affiche_Message(wxEmptyString); + DisplayOpt.DisplayPolarCood = m_OptionsToolBar->GetToolState(id); + Affiche_Status_Box(); /* Reaffichage des coord curseur */ + break; + + case ID_TB_OPTIONS_SELECT_CURSOR: + DrawPanel->CursorOff(&dc); + g_CursorShape = m_OptionsToolBar->GetToolState(id); + DrawPanel->CursorOn(&dc); + break; + + case ID_TB_OPTIONS_SHOW_PADS_SKETCH: + if ( m_OptionsToolBar->GetToolState(id) ) + { + m_DisplayPadFill = FALSE; + DisplayOpt.DisplayPadFill = FALSE; + } + else + { + m_DisplayPadFill = TRUE; + DisplayOpt.DisplayPadFill = TRUE; + } + DrawPanel->ReDraw(&dc, TRUE); + break; + + case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH: + if( m_OptionsToolBar->GetToolState(id) ) + { + m_DisplayPcbTrackFill = FALSE; + DisplayOpt.DisplayPcbTrackFill = FALSE; + } + else + { + m_DisplayPcbTrackFill = TRUE; + DisplayOpt.DisplayPcbTrackFill = TRUE; + } + DrawPanel->ReDraw(&dc, TRUE); + break; + + case ID_TB_OPTIONS_SHOW_DCODES: + DisplayOpt.DisplayPadNum = m_OptionsToolBar->GetToolState(id); + DrawPanel->ReDraw(&dc, TRUE); + break; + + + default: + DisplayError(this, wxT("WinEDA_PcbFrame::OnSelectOptionToolbar error")); + break; + } + + SetToolbars(); +} + + +enum id_optpcb +{ + ID_ACCEPT_OPT = 1000, + ID_CANCEL_OPT +}; + /*************************************************/ + /* classe derivee pour la frame de Configuration */ + /*************************************************/ + +class WinEDA_GerberGeneralOptionsFrame: public wxDialog +{ +private: + + WinEDA_BasePcbFrame * m_Parent; + wxRadioBox * m_PolarDisplay; + wxRadioBox * m_BoxUnits; + wxRadioBox * m_CursorShape; + wxRadioBox * m_GerberDefaultScale; + + + + // Constructor and destructor +public: + WinEDA_GerberGeneralOptionsFrame(WinEDA_BasePcbFrame *parent,const wxPoint& pos); + ~WinEDA_GerberGeneralOptionsFrame(void) {}; + +private: + void AcceptPcbOptions(wxCommandEvent& event); + void OnQuit(wxCommandEvent & event); + + DECLARE_EVENT_TABLE() + +}; +/* Construction de la table des evenements pour WinEDA_GerberGeneralOptionsFrame */ +BEGIN_EVENT_TABLE(WinEDA_GerberGeneralOptionsFrame, wxDialog) + EVT_BUTTON(ID_ACCEPT_OPT, WinEDA_GerberGeneralOptionsFrame::AcceptPcbOptions) + EVT_BUTTON(ID_CANCEL_OPT, WinEDA_GerberGeneralOptionsFrame::OnQuit) +END_EVENT_TABLE() + + + + + /*************************************************/ + /* Constructeur de WinEDA_GerberGeneralOptionsFrame */ + /************************************************/ + +WinEDA_GerberGeneralOptionsFrame::WinEDA_GerberGeneralOptionsFrame(WinEDA_BasePcbFrame *parent, + const wxPoint& framepos): + wxDialog(parent, -1, _("Gerbview Options"), + framepos, wxSize(300, 240), + wxDEFAULT_DIALOG_STYLE|wxFRAME_FLOAT_ON_PARENT ) +{ + m_Parent = parent; + SetFont(*g_DialogFont); + + wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(MainBoxSizer); + wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * MiddleBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(MiddleBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton * Button = new wxButton(this, ID_ACCEPT_OPT, _("Accept")); + Button->SetForegroundColour(*wxRED); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Button = new wxButton(this, ID_CANCEL_OPT, _("Cancel")); + Button->SetForegroundColour(*wxBLUE); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + /* Display Selection affichage des coordonnées polaires */ +wxString list_coord[2] = + { _("No Display"), + _("Display") }; + m_PolarDisplay = new wxRadioBox(this, -1, _("Display Polar Coord"), + wxDefaultPosition, wxDefaultSize, + 2, list_coord, 1); + m_PolarDisplay->SetSelection(DisplayOpt.DisplayPolarCood ? 1 : 0); + LeftBoxSizer->Add(m_PolarDisplay, 0, wxGROW|wxALL, 5); + + /* Selection choix des unités d'affichage */ +wxString list_units[2] = { + _("Inches"), + _("millimeters") }; + m_BoxUnits = new wxRadioBox(this, -1, _("Units"), wxDefaultPosition, wxDefaultSize, + 2, list_units, 1); + m_BoxUnits->SetSelection( g_UnitMetric ? 1 : 0); + LeftBoxSizer->Add(m_BoxUnits, 0, wxGROW|wxALL, 5); + + /* Selection forme du curseur */ +wxString list_cursors[2] = { _("Small"), _("Big") }; + m_CursorShape = new wxRadioBox(this, -1, _("Cursor"), wxDefaultPosition, wxDefaultSize, + 2, list_cursors, 1); + m_CursorShape->SetSelection( g_CursorShape ? 1 : 0); + MiddleBoxSizer->Add(m_CursorShape, 0, wxGROW|wxALL, 5); + + /* Selection Default Scale (i.e. format 2.3 ou 3.4) */ +wxString list_scales[2] = { _("format: 2.3"), _("format 3.4") }; + m_GerberDefaultScale = new wxRadioBox(this, -1, _("Default format"), + wxDefaultPosition, wxDefaultSize, + 2, list_scales, 1); + m_GerberDefaultScale->SetSelection( (g_Default_GERBER_Format == 23) ? 0 : 1); + MiddleBoxSizer->Add(m_GerberDefaultScale, 0, wxGROW|wxALL, 5); + + + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); +} + +/************************************************************************/ +void WinEDA_GerberGeneralOptionsFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/************************************************************************/ +{ + // true is to force the frame to close + Close(true); +} + + + +/*****************************************************************************/ +void WinEDA_GerberGeneralOptionsFrame::AcceptPcbOptions(wxCommandEvent& event) +/*****************************************************************************/ +{ + DisplayOpt.DisplayPolarCood = + (m_PolarDisplay->GetSelection() == 0) ? FALSE : TRUE; + g_UnitMetric = (m_BoxUnits->GetSelection() == 0) ? 0 : 1; + g_CursorShape = m_CursorShape->GetSelection(); + g_Default_GERBER_Format = + (m_GerberDefaultScale->GetSelection() == 0) ? 23 : 34; + + EndModal(1); +} + + + +/******************************************************************/ +/* classe derivee pour la frame de Configuration WinEDA_LookFrame */ +/******************************************************************/ + +class WinEDA_LookFrame: public wxDialog +{ +private: +protected: +public: + + WinEDA_BasePcbFrame * m_Parent; + + wxRadioBox * m_OptDisplayLines; + + wxRadioBox * m_OptDisplayFlashes; + wxCheckBox * m_OptDisplayDCodes; + + wxRadioBox * m_OptDisplayDrawings; + + + // Constructor and destructor + WinEDA_LookFrame(WinEDA_BasePcbFrame *parent,const wxPoint& pos); + ~WinEDA_LookFrame(void) {}; + + void AcceptPcbOptions(wxCommandEvent& event); + void OnQuit(wxCommandEvent & event); + + DECLARE_EVENT_TABLE() + +}; +/* Construction de la table des evenements pour WinEDA_LookFrame */ +BEGIN_EVENT_TABLE(WinEDA_LookFrame, wxDialog) + EVT_BUTTON(ID_ACCEPT_OPT, WinEDA_LookFrame::AcceptPcbOptions) + EVT_BUTTON(ID_CANCEL_OPT, WinEDA_LookFrame::OnQuit) +END_EVENT_TABLE() + + + +/*******************************************************************************/ +WinEDA_LookFrame::WinEDA_LookFrame(WinEDA_BasePcbFrame *parent, + const wxPoint& framepos): + wxDialog(parent, -1, _("Gerbview Draw Options"), framepos, wxSize(350, 200), + wxDEFAULT_DIALOG_STYLE|wxFRAME_FLOAT_ON_PARENT ) +/*******************************************************************************/ +{ + m_Parent = parent; + SetFont(*g_DialogFont); + + wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(MainBoxSizer); + wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * MiddleBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(MiddleBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton * Button = new wxButton(this, ID_ACCEPT_OPT, _("Accept")); + Button->SetForegroundColour(*wxRED); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Button = new wxButton(this, ID_CANCEL_OPT, _("Cancel")); + Button->SetForegroundColour(*wxBLUE); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + // Show Option Draw Tracks +wxString list_opt2[2] = { _("Sketch"), _("Filled") }; + m_OptDisplayLines = new wxRadioBox(this, -1, _("Lines:"), + wxDefaultPosition, wxDefaultSize, + 2, list_opt2, 1); + if ( DisplayOpt.DisplayPcbTrackFill ) m_OptDisplayLines->SetSelection(1); + LeftBoxSizer->Add(m_OptDisplayLines, 0, wxGROW|wxALL, 5); + + m_OptDisplayFlashes = new wxRadioBox(this, -1, _("Spots:"), + wxDefaultPosition, wxDefaultSize, + 2, list_opt2, 1); + if ( DisplayOpt.DisplayPadFill ) m_OptDisplayFlashes->SetSelection(1); + LeftBoxSizer->Add(m_OptDisplayFlashes, 0, wxGROW|wxALL, 5); + +wxString list_opt3[3] = { _("Sketch"), _("Filled"), _("Line") }; + m_OptDisplayDrawings = new wxRadioBox(this, -1, _("Display other items:"), + wxDefaultPosition, wxDefaultSize, + 3, list_opt3, 1); + m_OptDisplayDrawings->SetSelection(DisplayOpt.DisplayDrawItems); + MiddleBoxSizer->Add(m_OptDisplayDrawings, 0, wxGROW|wxALL, 5); + + m_OptDisplayDCodes = new wxCheckBox(this, -1, _("Show D-Codes")); + if ( DisplayOpt.DisplayPadNum ) m_OptDisplayDCodes->SetValue(TRUE); + MiddleBoxSizer->Add(m_OptDisplayDCodes, 0, wxGROW|wxALL, 5); + + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); +} + + +/**************************************************************/ +void WinEDA_LookFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/**************************************************************/ +{ + // true is to force the frame to close + Close(true); +} + + +/*************************************************************/ +void WinEDA_LookFrame::AcceptPcbOptions(wxCommandEvent& event) +/*************************************************************/ +/* Met a jour les options +*/ +{ + if ( m_OptDisplayLines->GetSelection() == 1) + DisplayOpt.DisplayPcbTrackFill = TRUE; + else DisplayOpt.DisplayPcbTrackFill = FALSE; + + if (m_OptDisplayFlashes->GetSelection() == 1 ) + DisplayOpt.DisplayPadFill = TRUE; + else DisplayOpt.DisplayPadFill = FALSE; + + DisplayOpt.DisplayPadNum = m_OptDisplayDCodes->GetValue(); + + DisplayOpt.DisplayDrawItems = m_OptDisplayDrawings->GetSelection(); + + m_Parent->m_DisplayPadFill = DisplayOpt.DisplayPadFill; + m_Parent->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; + + m_Parent->GetScreen()->SetRefreshReq(); + + EndModal(1); +} + + + + + +/***************************************************************************/ +void WinEDA_GerberFrame::InstallPcbOptionsFrame(const wxPoint & pos, int id) +/***************************************************************************/ +{ + + switch ( id ) + { + case ID_PCB_LOOK_SETUP: + { + WinEDA_LookFrame * OptionsFrame = + new WinEDA_LookFrame(this, pos); + OptionsFrame->ShowModal(); OptionsFrame->Destroy(); + } + break; + + case ID_OPTIONS_SETUP: + { + WinEDA_GerberGeneralOptionsFrame * OptionsFrame = + new WinEDA_GerberGeneralOptionsFrame(this, pos); + OptionsFrame->ShowModal(); OptionsFrame->Destroy(); + } + break; + } +} + + diff --git a/gerbview/pcbplot.cpp b/gerbview/pcbplot.cpp new file mode 100644 index 0000000000..217acb661c --- /dev/null +++ b/gerbview/pcbplot.cpp @@ -0,0 +1,31 @@ + /************************************************/ + /* Menu General de Trace (PLOT) fichier PLOT.CC */ + /************************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" +#include "id.h" + +#include "protos.h" + +/* variables locale : */ + +/* Routines Locales */ + + /**************************************************************/ + /* void WinEDA_BasePcbFrame::ToPlotter(wxCommandEvent& event) */ + /***************************************************************/ + +void WinEDA_BasePcbFrame::ToPlotter(wxCommandEvent& event) +{ +// WinEDA_PlotFrame * frame = new WinEDA_PlotFrame(this); +// frame->ShowModal(); frame->Destroy(); +} + +void Plume(int state) +{ +} + diff --git a/gerbview/pcbplot.h b/gerbview/pcbplot.h new file mode 100644 index 0000000000..cdb66fe7b1 --- /dev/null +++ b/gerbview/pcbplot.h @@ -0,0 +1,26 @@ + /*******************************************************/ + /* Menu General de Trace (PLOT): Fichier inclus PLOT.H */ + /*******************************************************/ + +#ifndef PCBPLOT_H +#define PCBPLOT_H + +#ifndef eda_global +#define eda_global extern +#endif + +/* Gestion des plumes en plot format HPGL */ +eda_global int HPGL_Pen_Num, /* num de plume a charger */ + HPGL_Pen_Speed, /* vitesse en cm/s */ + HPGL_Pen_Diam, /* diametre en mils */ + HPGL_Pen_Recouvrement; /* recouvrement en mils ( pour remplissages */ + +eda_global float Scale_X, Scale_Y ; /* coeff d'agrandissement en X et Y demandes */ + +eda_global int W_Trait_Serigraphie; /* Largeur du trait utilise en serigraphie + pour trace de pads (traces en mode sketch) */ +eda_global int format_plot; /* numero de code du format de sortie */ +eda_global int PlotMarge; + +#endif // ifndef PCBPLOT_H + diff --git a/gerbview/pcbtexte.cpp b/gerbview/pcbtexte.cpp new file mode 100644 index 0000000000..77e7837863 --- /dev/null +++ b/gerbview/pcbtexte.cpp @@ -0,0 +1,399 @@ + /****************************************/ + /* traitement des textes sur empreintes */ + /****************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" + +#include "protos.h" + +#define L_MIN_DESSIN 1 /* seuil de largeur des segments pour trace autre que filaire */ + +/* Fonctions externe: */ + +/* Routines Locales */ +static void Move_Texte_Pcb(WinEDA_DrawPanel * panel, wxDC * DC, int flag) ; +static void Exit_Texte_Pcb(WinEDA_DrawFrame * frame, wxDC *DC) ; + +/* variables exportees */ +int Angle_Rot_Fin = 50; /* Valeur par defaut de l'angle de rotation fine */ + +/* Variables locales : */ +static int LocalOrient; +static int LocalDimH; +static int LocalDimV; +static int LocalWidth; + +static wxPoint old_pos; // position originelle du texte selecte + + + /**************************************/ + /* void Exit_Texte_Pcb(COMMAND * Cmd) */ + /**************************************/ + +/* + Routine de sortie du menu edit texte Pcb +Si un texte est selectionne, ses coord initiales sont regenerees +*/ +void Exit_Texte_Pcb(WinEDA_DrawFrame * frame, wxDC * DC) +{ +TEXTE_PCB * TextePcb; + + TextePcb = (TEXTE_PCB *) frame->CurrentScreen->m_CurrentPcbItem; + + if ( TextePcb ) + { + Trace_1_texte_pcb(frame->DrawPanel, DC, TextePcb, 0, 0, GR_XOR) ; + TextePcb->m_Pos = old_pos; + Trace_1_texte_pcb(frame->DrawPanel, DC, TextePcb, 0, 0, GR_OR) ; + } + + frame->CurrentScreen->ManageCurseur = NULL; + frame->CurrentScreen->ForceCloseManageCurseur = NULL; + frame->CurrentScreen->m_CurrentPcbItem = NULL; +} + + /******************************************/ + /* void Place_Texte_Pcb(MTOOL_EDA * Menu) */ + /******************************************/ + +/* Routine de placement du texte en cours de deplacement +*/ +void WinEDA_PcbFrame::Place_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC) +{ + + if( TextePcb == NULL ) return; + + Trace_1_texte_pcb(DrawPanel, DC, TextePcb,0, 0, GR_XOR) ; + TextePcb->m_Layer = CurrentScreen->m_Active_Layer; + Trace_1_texte_pcb(DrawPanel, DC, TextePcb,0, 0, GR_OR) ; + CurrentScreen->ManageCurseur = NULL; + CurrentScreen->ForceCloseManageCurseur = NULL; + CurrentScreen->m_CurrentPcbItem = NULL; + CurrentScreen->SetModify(); +} + + /*****************************************/ + /* void StartMoveTextePcb(COMMAND * Cmd) */ + /*****************************************/ + +/* Routine de preparation du deplacement d'un texte +*/ + +void WinEDA_PcbFrame::StartMoveTextePcb(TEXTE_PCB * TextePcb, wxDC * DC) +{ + if( TextePcb == NULL ) return; + + old_pos = TextePcb->m_Pos; + Affiche_Infos_PCB_Texte(this, TextePcb); + CurrentScreen->ManageCurseur = Move_Texte_Pcb; + CurrentScreen->ForceCloseManageCurseur = Exit_Texte_Pcb; + CurrentScreen->m_CurrentPcbItem = TextePcb; +} + + /*****************************/ + /* void Move_Texte_Pcb(void) */ + /*****************************/ + +/* Routine deplacant le texte PCB suivant le curseur de la souris */ + +static void Move_Texte_Pcb(WinEDA_DrawPanel * panel, wxDC *DC, int flag ) +{ +TEXTE_PCB * TextePcb = (TEXTE_PCB *) + panel->m_Parent->CurrentScreen->m_CurrentPcbItem; + + if (TextePcb == NULL ) return ; + + /* effacement du texte : */ + + if ( flag == CURSEUR_MOVED) + Trace_1_texte_pcb(panel, DC, TextePcb,0, 0, GR_XOR) ; + + TextePcb->m_Pos = panel->m_Parent->CurrentScreen->m_Curseur; + TextePcb->m_Layer = panel->m_Parent->CurrentScreen->m_Active_Layer; + + /* Redessin du Texte */ + Trace_1_texte_pcb(panel, DC, TextePcb,0, 0, GR_XOR) ; +} + + + /********************************/ + /* void Delete_Texte_Pcb(COMMAND * Cmd) */ + /********************************/ + +void WinEDA_PcbFrame::Delete_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC) +{ + + if( TextePcb == NULL ) return; + + Trace_1_texte_pcb(DrawPanel, DC, TextePcb,0, 0, GR_XOR); + + /* Suppression du texte en Memoire*/ + DeleteStructure(TextePcb); + CurrentScreen->ManageCurseur = NULL; + CurrentScreen->ForceCloseManageCurseur = NULL; + CurrentScreen->m_CurrentPcbItem = NULL; +} + + + /****************************/ + /* void Add_Texte_Pcb(COMMAND * Cmd) */ + /****************************/ + +TEXTE_PCB * WinEDA_PcbFrame::Create_Texte_Pcb( wxDC * DC) +{ +char buf_new_texte[256]; +TEXTE_PCB * TextePcb; + + buf_new_texte[0]= 0 ; + Get_Message("Texte:",buf_new_texte, this); + if(*buf_new_texte <=' ') return NULL; + + CurrentScreen->SetModify(); + /* placement du texte en memoire */ + TextePcb = new TEXTE_PCB(pt_pcb); + + /* Chainage de la nouvelle structure en debut de liste */ + TextePcb->Pnext = pt_pcb->m_Drawings; + TextePcb->Pback = (EDA_BaseStruct * )pt_pcb; + if( pt_pcb->m_Drawings) pt_pcb->m_Drawings->Pback = (EDA_BaseStruct*) TextePcb; + pt_pcb->m_Drawings = (EDA_BaseStruct*) TextePcb; + + /* Mise a jour des caracteristiques */ + TextePcb->m_Layer = CurrentScreen->m_Active_Layer; + TextePcb->m_Miroir = 1; + if(CurrentScreen->m_Active_Layer == CUIVRE_N) TextePcb->m_Miroir = 0; + + TextePcb->m_Size.y = Texte_Pcb_DimV ; + TextePcb->m_Size.x = Texte_Pcb_DimH ; + TextePcb->m_Pos = CurrentScreen->m_Curseur; + TextePcb->m_Width = Texte_Segment_Largeur; + TextePcb->m_Layer = CurrentScreen->m_Active_Layer; + + /* Copie du texte */ + TextePcb->SetText(buf_new_texte); + + /* Dessin du Texte */ + Trace_1_texte_pcb(DrawPanel, DC, TextePcb,0, 0, GR_XOR) ; + Affiche_Infos_PCB_Texte(this, TextePcb); + + StartMoveTextePcb(TextePcb, DC); + + return TextePcb; +} + + /*******************************/ + /* void Rotate_Texte_Pcb(COMMAND * Cmd) */ + /*******************************/ + +void WinEDA_PcbFrame::Rotate_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC) +{ +int angle = 900; +int drawmode = GR_XOR; + + if( TextePcb == NULL ) return; + + /* effacement du texte : */ + Trace_1_texte_pcb(DrawPanel, DC, TextePcb,0, 0, GR_XOR) ; + + + TextePcb->m_Orient += angle; + if(TextePcb->m_Orient >= 3600) TextePcb->m_Orient -= 3600 ; + if(TextePcb->m_Orient < 0) TextePcb->m_Orient += 3600 ; + + /* Redessin du Texte */ + Trace_1_texte_pcb(DrawPanel, DC, TextePcb, 0, 0, drawmode); + Affiche_Infos_PCB_Texte(this, TextePcb); + + CurrentScreen->SetModify(); +} + + /***************************************************************/ + /* void Trace_1_texte(char * ptr,int ox,int oy),int mode_color */ + /***************************************************************/ + +/* + Trace de 1 texte : + ptr = pointeur sur le debut de la description du texte + ox, oy = Offsets de trace + mode_color = GR_OR, GR_XOR.. +*/ + +void Trace_1_texte_pcb(WinEDA_DrawPanel * panel, wxDC * DC, + TEXTE_PCB * pt_texte,int ox,int oy, int DrawMode) +{ +int zoom = panel->m_Parent->CurrentScreen->GetZoom(); +int cX, cY; +int screen_epais, gcolor ; +int size_h , size_v , width ; +char *ptr; +int orient; + + if( pt_texte->GetText() == NULL ) return; + + /* lecture des caracteristiques du texte */ + size_h = pt_texte->m_Size.x; size_v = pt_texte->m_Size.y ; + orient = pt_texte->m_Orient; + width = pt_texte->m_Width; + screen_epais = width / zoom; + + if( (DisplayOpt.DisplayDrawItems == FILAIRE) || ( screen_epais < L_MIN_DESSIN) ) + width = 0; + + /* calcul de la position du texte */ + cX = pt_texte->m_Pos.x - ox; + cY = pt_texte->m_Pos.y - oy; + + if ( pt_texte->m_Miroir == 0 ) size_h = -size_h; + + /* choix de la couleur du texte : */ + gcolor = color_layer[pt_texte->m_Layer]; + + ptr = pt_texte->GetText(); /* ptr pointe 1er caractere du texte */ + + GRSetDrawMode(DC, DrawMode); + /* trace ancre du texte */ + if((E_ancre_color&ITEM_NON_VISIBLE) == 0 ) + { + GRLine(panel, DC, cX - (2*zoom), cY, + cX + (2*zoom), cY, E_ancre_color); + GRLine(panel, DC, cX, cY - (2*zoom) , + cX, cY + (2*zoom) , E_ancre_color); + } + + /* trace du texte */ + Display_1_Texte(panel, DC, ptr, strlen(ptr), cX, cY, + size_h, size_v, width, orient, gcolor); +} + + /*********************************************/ + /* void InstallEditCaractMenu(COMMAND * Cmd) */ + /*********************************************/ + +static void InstallEditCaractMenu(COMMAND * Cmd) +{ +#if 0 +TEXTE_PCB * TextePcb = PtTextePcbSelecte; +wxDC * DC = Cmd->DC; + + if( TextePcb == NULL ) + { + TextePcb = (TEXTE_PCB*)pt_pcb->Drawings; + while( (TextePcb = Locate_Texte_Pcb(TextePcb,CURSEUR_OFF_GRILLE)) != 0 ) + { + if( TextePcb->Layer == CurrentScreen->Active_Layer ) break; + // le Texte n'est pas sur la couche active + TextePcb = (TEXTE_PCB*) TextePcb->Pnext; + } + } + + TextePcbEdite = TextePcb; + + if( TextePcb == NULL ) + { + DisplayError("Texte non trouve sur cette couche",10); + Cmd->Menu->State = WAIT; DisplayMenu(DC, Cmd->Menu, NULL, ON); + return; + } + + Affiche_Infos_PCB_Texte(Cmd, TextePcb); + + if(TextePcb->orient >= 3600) TextePcb->orient -= 3600 ; + if(TextePcb->orient < 0) TextePcb->orient += 3600 ; + + /* Init des variables */ + strncpy(BufNameTxt.s, TextePcb->GetText(), sizeof(BufNameTxt.s) - 1); + if( TextePcb->miroir ) Texte_Pcb_Miroir_Item.State = WAIT; + else Texte_Pcb_Miroir_Item.State = RUN; + + * (int*) Param_OrientText.param = TextePcb->orient; + * (int*) Param_DimHText.param = TextePcb->Size.x; + * (int*) Param_DimVText.param = TextePcb->Size.y; + * (int*) Param_EpaisText.param = TextePcb->width; + + InstallNewList(Cmd); +#endif +} + + /*****************************************/ + /* void ChangeCaractTexte(COMMAND * Cmd) */ + /*****************************************/ + +/* Change les caracteristiques du texte en cours d'edition +*/ +void WinEDA_PcbFrame::EditTextePcb(TEXTE_PCB * TextePcb, wxDC * DC) +{ +int drawmode = GR_OR; +char buf_new_texte[1024]; + + if( TextePcb == NULL) return; + + if( PtTextePcbSelecte ) drawmode = GR_XOR; + + buf_new_texte[0]= 0 ; + Get_Message("Texte:",buf_new_texte, this); + if(*buf_new_texte <=' ') return; + + /* effacement du texte : */ + Trace_1_texte_pcb(DrawPanel, DC, TextePcb, 0, 0, GR_XOR) ; + + if( strcmp( TextePcb->GetText(), buf_new_texte) && strlen(buf_new_texte) ) + { + TextePcb->SetText(buf_new_texte); + CurrentScreen->SetModify(); + } + + while(LocalOrient >= 3600) LocalOrient -= 3600 ; + while(LocalOrient < 0) LocalOrient += 3600 ; + + if( CurrentScreen->m_Active_Layer != TextePcb->m_Layer ) + { + TextePcb->m_Layer = CurrentScreen->m_Active_Layer; + CurrentScreen->SetModify(); + } + + if( LocalOrient != TextePcb->m_Orient ) + { + TextePcb->m_Orient = LocalOrient; + CurrentScreen->SetModify(); + } + + if( LocalDimV != TextePcb->m_Size.y ) + { + TextePcb->m_Size.y = LocalDimV; + CurrentScreen->SetModify(); + } + + if( LocalDimH != TextePcb->m_Size.x ) + { + TextePcb->m_Size.x = LocalDimH; + CurrentScreen->SetModify(); + } + + if( LocalWidth != TextePcb->m_Width ) + { + TextePcb->m_Width = LocalWidth; + CurrentScreen->SetModify(); + } + +/* if( (Texte_Pcb_Miroir_Item.State == WAIT) && (TextePcb->miroir == 0) ) + { + TextePcb->miroir = 1; + CurrentScreen->SetModify(); + } + + if( (Texte_Pcb_Miroir_Item.State == RUN) && TextePcb->miroir ) + { + TextePcb->miroir = 0; + CurrentScreen->SetModify(); + } +*/ + + /* Redessin du Texte */ + Trace_1_texte_pcb(DrawPanel, DC, TextePcb, 0, 0, drawmode); + + Affiche_Infos_PCB_Texte(this, TextePcb); +} + diff --git a/gerbview/protos.h b/gerbview/protos.h new file mode 100644 index 0000000000..63f9497c7b --- /dev/null +++ b/gerbview/protos.h @@ -0,0 +1,142 @@ +/* declarations prototype */ + +/****************/ +/* undelete.cpp */ +/****************/ +EDA_BaseStruct * SaveItemEfface(EDA_BaseStruct * PtItem, int nbitems); + + +/***********/ +/* cfg.cpp */ +/***********/ +bool Read_Config(void); + + +/* pcbplot.cpp */ +void Plume(int state); + +/****************/ +/* lay2plot.cpp */ + +int GetLayerNumber(void); +void Print_PcbItems(BOARD * Pcb, wxDC *DC, int drawmode, int printmasklayer); + +/*****************/ +/* set_color.cpp */ +/*****************/ +void DisplayColorSetupFrame(WinEDA_DrawFrame * parent, const wxPoint & framepos); + +/***************/ +/* affiche.cpp */ +/***************/ +void valeur_param(int valeur,char * buf_texte); +void Affiche_Infos_PCB_Texte(WinEDA_BasePcbFrame * frame, TEXTE_PCB* pt_texte); +void Affiche_Infos_Piste(WinEDA_BasePcbFrame * frame, TRACK * pt_piste); + +/* PLOT_RTN.CC */ +void ComputePlotFileName( char * FullFileName, char * Ext ); +void calcule_coord_plot(int * dx, int * dy ) ; +void calcule_dim_plot(int * dx, int * dy ) ; +void Trace_Un_TextePcb( TEXTE_PCB * pt_texte,int format_plot,int masque_layer); + /* Trace 1 Texte type PCB , c.a.d autre que les textes sur modules, + prepare les parametres de trace de Plot_1_texte */ +void trace_1_arc(int format_plot,int cx,int cy,int start,int end, + int rayon,int epaisseur); +void trace_1_cercle(int format_plot,int epaisseur,int cx, int cy, int rayon); +void Plot_1_texte( int format_plot, + char * ptr,int t_nbcodes, int t_orient, + int epaisseur, int ox,int oy,int size_h,int size_v); + /* Routine de base de trace de 1 chaine de caracteres */ + +void Trace_Un_DrawSegment( DRAWSEGMENT* PtSegm, int format_plot,int masque_layer ); + +void Trace_Une_MirePcb( MIREPCB* PtMire, int format_plot,int masque_layer ); + +/* PLOTGERB.CC */ +void trace_1_segment_GERBER(int pos_X0,int pos_Y0,int pos_X1,int pos_Y1, + int hauteur); +void trace_1_cercle_GERBER( int cx, int cy, int rayon, int epaisseur); +void trace_1_contour_GERBER(int cX,int cY, int dimX,int dimY, + int deltaX, int deltaY, + int dim_trait, int orient); + /* Trace 1 contour rectangulaire ou trapezoidal d'orientation quelconque + donne par son centre cX, cY, ses dimensions dimX et dimY, + ses variations deltaX et deltaY et son orientation orient */ + +/* PLOTHPGL.CC */ +void Init_Trace_HPGL(void); +void Fin_Trace_HPGL(void); +void trace_1_segment_HPGL(int pos_X0,int pos_Y0,int pos_X1,int pos_Y1, + int hauteur); + +void trace_1_pad_TRAPEZE_HPGL(int cX,int cY, + int dimX,int dimY,int deltaX, int deltaY, + int orient,int modetrace); + +void trace_1_pastille_RONDE_HPGL(int pos_X,int pos_Y,int diametre,int modetrace) ; + +void trace_1_pastille_OVALE_HPGL(int pos_X,int pos_Y,int dx,int dy, + int orient,int modetrace) ; +void trace_1_pad_rectangulaire_HPGL(int cX,int cY,int dimX,int dimY, + int orient,int modetrace) ; +void Move_Plume_HPGL( int x,int y,int plume); + /* deplace la plume levee (plume = 'U') ou baissee (plume = 'D') + en position x,y */ + +void Plume_HPGL( int plume ); + /* leve (plume = 'U') ou baisse (plume = 'D') la plume */ + +/**************/ +/* PRINTPS.CC */ +/**************/ +void trace_1_pastille_OVALE_POST(int pos_X,int pos_Y, + int dx, int dy, int orient, int modetrace); +void trace_1_pastille_RONDE_POST(int pos_X,int pos_Y,int diametre, + int modetrace); +void trace_1_pad_rectangulaire_POST(int cX,int cY, + int dimX,int dimY,int orient, + int modetrace); +void trace_1_contour_POST(int cX,int cY, int dimX,int dimY, + int deltaX, int deltaY, + int dim_trait, int orient); +void trace_1_pad_TRAPEZE_POST(int cX,int cY, + int dimX,int dimY,int deltaX, int deltaY, + int orient,int modetrace); +void trace_1_segment_POST(int pos_X0,int pos_Y0,int pos_X1,int pos_Y1, + int large); +void trace_1_Cercle_POST(int pos_X,int pos_Y,int diametre, int width); +void PlotArcPS(int x, int y, int StAngle, int EndAngle, int rayon, int width); + + +/***************/ +/* trpiste.cpp */ +/***************/ +void Trace_Pistes(WinEDA_DrawPanel * panel, wxDC * DC, BOARD * Pcb, int drawmode); +void Trace_Segment(WinEDA_DrawPanel * panel, wxDC * DC, TRACK* pt_piste, int draw_mode); +void Trace_DrawSegmentPcb(WinEDA_DrawPanel * panel, wxDC * DC, + DRAWSEGMENT * PtDrawSegment, int draw_mode); +void Trace_1_texte_pcb(WinEDA_DrawPanel * panel, wxDC * DC, + TEXTE_PCB * pt_texte,int ox,int oy, int DrawMode); + +void Affiche_DCodes_Pistes(WinEDA_DrawPanel * panel, wxDC * DC, + BOARD * Pcb, int drawmode); + +/**************/ +/* struct.cpp */ +/**************/ +void DeleteStructure(EDA_BaseStruct * Struct); +void DeleteStructList( EDA_BaseStruct * Struct); + +/*************/ +/* dcode.cpp */ +/*************/ +class D_CODE; + +D_CODE * ReturnToolDescr(int layer, int Dcode, int * index = NULL); + +/**************/ +/* rs274x.cpp */ +/**************/ +bool GetEndOfBlock( char * buff, char * &text, FILE *gerber_file); + + diff --git a/gerbview/readgerb.cpp b/gerbview/readgerb.cpp new file mode 100644 index 0000000000..0af784f871 --- /dev/null +++ b/gerbview/readgerb.cpp @@ -0,0 +1,269 @@ + /********************************************************/ + /**** Routine de lecture et visu d'un fichier GERBER ****/ + /********************************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" + +#include "protos.h" + +/* Format Gerber : NOTES : +Fonctions preparatoires: + Gn = + G01 interpolation lineaire ( trace de droites ) + G02,G20,G21 Interpolation circulaire , sens trigo < 0 + G03,G30,G31 Interpolation circulaire , sens trigo > 0 + G04 commentaire + G06 Interpolation parabolique + G07 Interpolation cubique + G10 interpolation lineaire ( echelle 10x ) + G11 interpolation lineaire ( echelle 0.1x ) + G12 interpolation lineaire ( echelle 0.01x ) + G52 plot symbole reference par Dnn code + G53 plot symbole reference par Dnn ; symbole tourne de -90 degres + G54 Selection d'outil + G55 Mode exposition photo + G56 plot symbole reference par Dnn A code + G57 affiche le symbole reference sur la console + G58 plot et affiche le symbole reference sur la console + G60 interpolation lineaire ( echelle 100x ) + G70 Unites = Inches + G71 Unites = Millimetres + G74 supprime interpolation circulaire sur 360 degre, revient a G01 + G75 Active interpolation circulaire sur 360 degre + G90 Mode Coordonnees absolues + G91 Mode Coordonnees Relatives + +Coordonnees X,Y + X,Y sont suivies de + ou - et de m+n chiffres (non separes) + m = partie entiere + n = partie apres la virgule + formats classiques : m = 2, n = 3 (format 2.3) + m = 3, n = 4 (format 3.4) + ex: + G__ X00345Y-06123 D__* + +Outils et D_CODES + numero d'outil ( identification des formes ) + 1 a 99 (classique) + 1 a 999 + D_CODES: + + D01 ... D9 = codes d'action: + D01 = activation de lumiere (baisser de plume) lors du déplacement + D02 = extinction de lumiere (lever de plume) lors du déplacement + D03 = Flash + D09 = VAPE Flash + D51 = precede par G54 -> Select VAPE + + D10 ... D255 = Indentification d'outils ( d'ouvertures ) + Ne sont pas tj dans l'ordre ( voir tableau dans PCBPLOT.H) +*/ + + +/* Variables locales : */ + +/* Routines Locales */ + + + +/* Routine de Lecture d'un fichier de D Codes. + Accepte format standard ou ALSPCB + un ';' demarre un commentaire. + + Format Standard: + tool, Horiz, Vert, drill, vitesse, acc. ,Type ; [DCODE (commentaire)] +ex: 1, 12, 12, 0, 0, 0, 3 ; D10 + + Format ALSPCB: + Ver , Hor , Type , Tool [,Drill] +ex: 0.012, 0.012, L , D10 + + Classe les caract en buf_tmp sous forme de tableau de structures D_CODE. + Retourne: + < 0 si erreur: + -1 = Fichier non trouve + -2 = Erreur lecture fichier + Rang de D_code maxi lu ( nbr de dcodes ) + + +Representation interne: + + Les lignes sont représentées par des TRACKS standards + Les Flash sont représentées par des DRAWSEGMENTS + - ronds ou ovales: DRAWSEGMENTS + - rectangles: DRAWSEGMENTS + la reference aux D-CODES est placée dans le membre m_NetCode +*/ + + +/********************************************************/ +bool WinEDA_GerberFrame::Read_GERBER_File(wxDC * DC, + const wxString & GERBER_FullFileName, + const wxString & D_Code_FullFileName) +/********************************************************/ + +/* Lecture de 1 fichier gerber. + Format + Imperial + 2.3 + Absolu + fin de bloc = * + CrLf apres chaque commande + G codes repetes + */ +{ +int G_commande = 0, D_commande = 0 ; /* Numero de commande G et D codes */ +char Line[1024]; // Buffer des lignes du fichier gerber en cours +wxString msg; +char * text; +int layer = GetScreen()->m_Active_Layer; +GERBER_Descr * gerber_layer; +wxPoint pos; +int error = 0; + + + if ( g_GERBER_Descr_List[layer] == NULL ) + { + g_GERBER_Descr_List[layer] = new GERBER_Descr(layer); + } + + gerber_layer = g_GERBER_Descr_List[layer]; + /* Mise a jour de l'echelle gerber : */ + gerber_layer->ResetDefaultValues(); + + /* Lecture du fichier de Trace */ + gerber_layer->m_Current_File = wxFopen(GERBER_FullFileName, wxT("rt") ); + if (gerber_layer->m_Current_File == 0) + { + msg = _("File ") + GERBER_FullFileName + _(" not found"); + DisplayError(this, msg, 10); return FALSE; + } + + gerber_layer->m_FileName = GERBER_FullFileName; + + wxSetWorkingDirectory(wxPathOnly(GERBER_FullFileName)); + +wxBusyCursor show_wait; + + while( TRUE ) + { + if ( fgets(Line,255,gerber_layer->m_Current_File) == NULL ) // E.O.F + { + if ( gerber_layer->m_FilesPtr == 0 ) break; + fclose(gerber_layer->m_Current_File); + gerber_layer->m_FilesPtr --; + gerber_layer->m_Current_File = + gerber_layer->m_FilesList[gerber_layer->m_FilesPtr]; + continue; + } + text = StrPurge(Line); + + while ( text && *text ) + { + switch( *text ) + { + case '\r': + case '\n': + text ++; + break; + + case '*': // End commande + gerber_layer->m_CommandState = END_BLOCK; + text ++; + break; + + case 'M': // End file + gerber_layer->m_CommandState = CMD_IDLE; + while ( *text ) text ++; + break; + + case 'G': /* Ligne type Gxx : commande */ + G_commande = gerber_layer->ReturnGCodeNumber(text); + gerber_layer->Execute_G_Command(text, G_commande); + break ; + + case 'D': /* Ligne type Dxx : Selection d'un outil */ + D_commande = gerber_layer->ReturnDCodeNumber(text); + gerber_layer->Execute_DCODE_Command(this, DC, + text, D_commande); + break ; + + case 'X': + case 'Y': /* Commande de deplacement ou de Trace */ + pos = gerber_layer->ReadXYCoord(text); + break; + + case 'I': + case 'J': /* Commande de deplacement ou de Trace */ + pos = gerber_layer->ReadIJCoord(text); + break; + + case '%': + if (gerber_layer->m_CommandState != ENTER_RS274X_CMD ) + { + gerber_layer->m_CommandState = ENTER_RS274X_CMD; + gerber_layer->ReadRS274XCommand(this, DC, Line, text); + } + else //Error + { + wxBell(); error++; + gerber_layer->m_CommandState = CMD_IDLE; + text++; + } + break; + + default: + text ++; error++; + break; + } // end switch (*text) + } // end while (text + } // end while (TRUE) + + if ( error ) + { + msg.Printf( _("%d errors while reading gerber file [%s]"), + error, GERBER_FullFileName.GetData()); + DisplayError(this, msg); + } + fclose(gerber_layer->m_Current_File) ; + + /* Init tableau des DCodes et Lecture fichier DCODES */ + if ( !gerber_layer->m_As_DCode ) + { + wxString DCodeFileName; + if( D_Code_FullFileName.IsEmpty()) + { + wxString mask; + DCodeFileName = GERBER_FullFileName; + ChangeFileNameExt(DCodeFileName, g_PenFilenameExt); + mask = wxT("*") + g_PenFilenameExt; + DCodeFileName = EDA_FileSelector( _("D CODES files:"), + wxEmptyString, /* Chemin par defaut */ + DCodeFileName, /* nom fichier par defaut */ + g_PenFilenameExt, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + 0, + TRUE + ); + } + else DCodeFileName = D_Code_FullFileName; + + if ( ! DCodeFileName.IsEmpty() ) + { + Read_D_Code_File(DCodeFileName); + CopyDCodesSizeToItems(); + } + } + + + return TRUE; +} + + + + diff --git a/gerbview/reglage.cpp b/gerbview/reglage.cpp new file mode 100644 index 0000000000..8bd749c39b --- /dev/null +++ b/gerbview/reglage.cpp @@ -0,0 +1,165 @@ + /********************************************/ + /* PCBNEW - Gestion des Options et Reglages */ + /********************************************/ + + /* Fichier reglage.cpp */ + +/* + Affichage et modifications des parametres de travail de PcbNew + Parametres = dimensions des via, pistes, isolements, options... +*/ + + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" + +#include "protos.h" + +/* Fonctions locales */ + +/* variables locales */ + +/***********/ + +enum { + ID_SAVE_CFG = 1000, + ID_EXIT_CFG + }; + +/* Routines Locales */ + + /*************************************************/ + /* classe derivee pour la frame de Configuration */ + /*************************************************/ + +class WinEDA_ConfigFrame: public wxDialog +{ +private: + + WinEDA_GerberFrame * m_Parent; + wxListBox * ListLibr; + int LibModified; + + WinEDA_EnterText * TextDrillExt; + WinEDA_EnterText * TextPhotoExt; + WinEDA_EnterText * TextPenExt; + + // Constructor and destructor +public: + WinEDA_ConfigFrame(WinEDA_GerberFrame *parent,const wxPoint& pos); + ~WinEDA_ConfigFrame(void) {}; + +private: + void SaveCfg(wxCommandEvent & event); + void OnQuit(wxCommandEvent & event); + void OnCloseWindow(wxCloseEvent & event); + + DECLARE_EVENT_TABLE() + +}; +/* Construction de la table des evenements pour WinEDA_ConfigFrame */ +BEGIN_EVENT_TABLE(WinEDA_ConfigFrame, wxDialog) + EVT_BUTTON(ID_SAVE_CFG, WinEDA_ConfigFrame::SaveCfg) + EVT_BUTTON(ID_EXIT_CFG, WinEDA_ConfigFrame::OnQuit) + EVT_CLOSE(WinEDA_ConfigFrame::OnCloseWindow) +END_EVENT_TABLE() + + + + /*****************************************************************/ + /* void WinEDA_GerberFrame::InstallConfigFrame(const wxPoint & pos) */ + /*****************************************************************/ + +void WinEDA_GerberFrame::InstallConfigFrame(const wxPoint & pos) +{ +WinEDA_ConfigFrame * CfgFrame = new WinEDA_ConfigFrame(this, pos); + CfgFrame->ShowModal(); CfgFrame->Destroy(); +} + + + /************************************************************/ + /* Constructeur de WinEDA_ConfigFrame: la fenetre de config */ + /************************************************************/ + +WinEDA_ConfigFrame::WinEDA_ConfigFrame(WinEDA_GerberFrame *parent, + const wxPoint& framepos): + wxDialog(parent, -1, wxEmptyString, framepos, wxSize(300, 180), + wxDEFAULT_DIALOG_STYLE|wxFRAME_FLOAT_ON_PARENT ) +{ +#define LEN_EXT 100 +wxString title; + + m_Parent = parent; + SetFont(* g_DialogFont); + + title = _("from ") + EDA_Appl->m_CurrentOptionFile; + SetTitle(title); + + LibModified = FALSE; + wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(MainBoxSizer); + wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + /* Creation des boutons de commande */ + wxButton * Button = new wxButton(this, ID_SAVE_CFG, _("Save Cfg")); + Button->SetForegroundColour(*wxRED); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Button = new wxButton(this, ID_EXIT_CFG, _("Exit")); + Button->SetForegroundColour(*wxBLUE); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + wxSize size; + size.x = LEN_EXT; size.y = -1; + TextDrillExt = new WinEDA_EnterText(this, + _("Drill File Ext:"), g_DrillFilenameExt, + LeftBoxSizer, size); + + TextPhotoExt = new WinEDA_EnterText(this, + _("Gerber File Ext:"), g_PhotoFilenameExt, + LeftBoxSizer, size); + + TextPenExt = new WinEDA_EnterText(this, + _("DCode File Ext:"), g_PenFilenameExt, + LeftBoxSizer, size); + + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); +} + + + /*****************************************************************/ + /* Fonctions de base de WinEDA_ConfigFrame: la fenetre de config */ + /*****************************************************************/ + +void WinEDA_ConfigFrame::OnCloseWindow(wxCloseEvent & event) +{ + g_DrillFilenameExt = TextDrillExt->GetValue(); + g_PhotoFilenameExt = TextPhotoExt->GetValue(); + g_PenFilenameExt = TextPenExt->GetValue(); + EndModal(0); +} + +/******************************************************************/ +void WinEDA_ConfigFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/******************************************************************/ +{ + // true is to force the frame to close + Close(true); +} + + +/******************************************************/ +void WinEDA_ConfigFrame::SaveCfg(wxCommandEvent& event) +/******************************************************/ +{ + m_Parent->Update_config(); +} + + diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp new file mode 100644 index 0000000000..a2a1c44b1d --- /dev/null +++ b/gerbview/rs274d.cpp @@ -0,0 +1,762 @@ + /********************************************************/ + /**** Routine de lecture et visu d'un fichier GERBER ****/ + /********************************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" + +#include "protos.h" + +#define IsNumber(x) ( ( ((x) >= '0') && ((x) <='9') ) ||\ + ((x) == '-') || ((x) == '+') || ((x) == '.')) +/* Format Gerber : NOTES : +Fonctions preparatoires: + Gn = + G01 interpolation lineaire ( trace de droites ) + G02,G20,G21 Interpolation circulaire , sens trigo < 0 + G03,G30,G31 Interpolation circulaire , sens trigo > 0 + G04 commentaire + G06 Interpolation parabolique + G07 Interpolation cubique + G10 interpolation lineaire ( echelle 10x ) + G11 interpolation lineaire ( echelle 0.1x ) + G12 interpolation lineaire ( echelle 0.01x ) + G52 plot symbole reference par Dnn code + G53 plot symbole reference par Dnn ; symbole tourne de -90 degres + G54 Selection d'outil + G55 Mode exposition photo + G56 plot symbole reference par Dnn A code + G57 affiche le symbole reference sur la console + G58 plot et affiche le symbole reference sur la console + G60 interpolation lineaire ( echelle 100x ) + G70 Unites = Inches + G71 Unites = Millimetres + G74 supprime interpolation circulaire sur 360 degre, revient a G01 + G75 Active interpolation circulaire sur 360 degre + G90 Mode Coordonnees absolues + G91 Mode Coordonnees Relatives + +Coordonnees X,Y + X,Y sont suivies de + ou - et de m+n chiffres (non separes) + m = partie entiere + n = partie apres la virgule + formats classiques : m = 2, n = 3 (format 2.3) + m = 3, n = 4 (format 3.4) + ex: + G__ X00345Y-06123 D__* + +Outils et D_CODES + numero d'outil ( identification des formes ) + 1 a 99 (classique) + 1 a 999 + D_CODES: + + D01 ... D9 = codes d'action: + D01 = activation de lumiere (baisser de plume) lors du déplacement + D02 = extinction de lumiere (lever de plume) lors du déplacement + D03 = Flash + D09 = VAPE Flash + D51 = precede par G54 -> Select VAPE + + D10 ... D255 = Indentification d'outils ( d'ouvertures ) + Ne sont pas tj dans l'ordre ( voir tableau dans PCBPLOT.H) +*/ + +// Type d'action du phototraceur: +#define GERB_ACTIVE_DRAW 1 // activation de lumiere ( baisser de plume) +#define GERB_STOP_DRAW 2 // extinction de lumiere ( lever de plume) +#define GERB_FLASH 3 // Flash + +#define NEGATE(nb) (nb) = -(nb) + +/* Variables locales : */ +static wxPoint LastPosition; + +/* Routines Locales */ + +static void Append_1_Line_GERBER(int Dcode_index, WinEDA_GerberFrame * frame, wxDC * DC, + const wxPoint & startpoint,const wxPoint & endpoint, + int largeur); +static void Append_1_Flash_GERBER(int Dcode_index, WinEDA_GerberFrame * frame, wxDC * DC, + const wxPoint & pos,const wxSize & size, int forme); +static void Append_1_Flash_ROND_GERBER(int Dcode_index, WinEDA_GerberFrame * frame, wxDC * DC, + const wxPoint & pos, int diametre); +static void Append_1_SEG_ARC_GERBER(int Dcode_index, + WinEDA_GerberFrame * frame, wxDC * DC, + const wxPoint & startpoint, const wxPoint & endpoint, + const wxPoint & rel_center, int largeur, + bool trigo_sens, bool multiquadrant); + + + +/****************************************************************/ +static void Append_1_Flash_ROND_GERBER(int Dcode_tool, + WinEDA_GerberFrame * frame, + wxDC * DC, const wxPoint & pos,int diametre) +/****************************************************************/ +/* Trace 1 flash ROND en position pos +*/ +{ +TRACK * track; + + track = new TRACK(frame->m_Pcb); + track->Insert(frame->m_Pcb, NULL); + + track->m_Layer = frame->GetScreen()->m_Active_Layer; + track->m_Width = diametre ; + track->m_Start = track->m_End = pos; + NEGATE(track->m_Start.y); + NEGATE(track->m_End.y); + track->m_NetCode = Dcode_tool; + track->m_Shape = S_SPOT_CIRCLE; + + Trace_Segment(frame->DrawPanel, DC, track, GR_OR) ; +} + +/**********************************************************************/ +static void Append_1_Flash_GERBER(int Dcode_index, + WinEDA_GerberFrame * frame, wxDC * DC, + const wxPoint & pos,const wxSize & size,int forme) +/*********************************************************************/ +/* + Trace 1 flash rectangulaire ou ovale vertical ou horizontal + donne par son centre et ses dimensions X et Y +*/ +{ +TRACK * track; +int width, len; + + width = min( size.x, size.y ); + len = max( size.x, size.y ) - width; + + track = new TRACK(frame->m_Pcb); + track->Insert(frame->m_Pcb, NULL); + + track->m_Layer = frame->GetScreen()->m_Active_Layer; + track->m_Width = width; + track->m_Start = track->m_End = pos; + NEGATE(track->m_Start.y); + NEGATE(track->m_End.y); + track->m_NetCode = Dcode_index; + + if ( forme == OVALE ) + track->m_Shape = S_SPOT_OVALE; + else + track->m_Shape = S_SPOT_RECT; // donc rectangle ou carré + + len >>= 1; + if ( size.x > size.y ) // ovale / rect horizontal + { + track->m_Start.x -= len ; + track->m_End.x += len; + } + + else // ovale / rect vertical + { + track->m_Start.y -= len; + track->m_End.y += len; + } + + Trace_Segment(frame->DrawPanel, DC, track, GR_OR) ; +} + + +/******************************************************************/ +static void Append_1_Line_GERBER(int Dcode_index, + WinEDA_GerberFrame * frame, wxDC * DC, + const wxPoint & startpoint, const wxPoint & endpoint, + int largeur) +/********************************************************************/ +{ +TRACK * track; + + track = new TRACK( frame->m_Pcb ); + track->Insert(frame->m_Pcb, NULL); + + track->m_Layer = frame->GetScreen()->m_Active_Layer ; + track->m_Width = largeur ; + track->m_Start = startpoint; + NEGATE(track->m_Start.y); + track->m_End = endpoint; + NEGATE(track->m_End.y); + track->m_NetCode = Dcode_index; + + Trace_Segment(frame->DrawPanel, DC, track,GR_OR) ; +} + +/*****************************************************************/ +static void Append_1_SEG_ARC_GERBER(int Dcode_index, + WinEDA_GerberFrame * frame, wxDC * DC, + const wxPoint & startpoint, const wxPoint & endpoint, + const wxPoint & rel_center, int largeur, + bool trigo_sens, bool multiquadrant) +/*****************************************************************/ + +/* creation d'un arc: + si multiquadrant == TRUE arc de 0 a 360 degres + et rel_center est la coordonnée du centre relativement au startpoint + + si multiquadrant == FALSE arc de 0 à 90 entierement contenu dans le meme quadrant + et rel_center est la coordonnée du centre relativement au startpoint, + mais en VALEUR ABSOLUE et le signe des valeurs x et y de rel_center doit + etre deduit de cette limite de 90 degres + +*/ +{ +TRACK * track; +wxPoint center, delta; + + track = new TRACK( frame->m_Pcb ); + track->Insert(frame->m_Pcb, NULL); + + track->m_Shape = S_ARC; + track->m_Layer = frame->GetScreen()->m_Active_Layer ; + track->m_Width = largeur ; + + if ( multiquadrant ) + { + center.x = startpoint.x + rel_center.x; + center.y = startpoint.y - rel_center.y; + + if ( !trigo_sens ) + { + track->m_Start = startpoint; + track->m_End = endpoint; + } + else + { + track->m_Start = endpoint; + track->m_End = startpoint; + } + } + else + { + center = rel_center; + delta.x = endpoint.x - startpoint.x; + delta.y = endpoint.y - startpoint.y; + // il faut corriger de signe de rel_center.x et rel_center.y + // selon le quadrant ou on se trouve + if ( (delta.x >= 0) && (delta.y >= 0) ) // 1er quadrant + { + center.x = - center.x; + } + + else if ( (delta.x < 0) && (delta.y >= 0) ) // 2eme quadrant + { + center.x = - center.x; + center.y = - center.y; + } + + else if ( (delta.x < 0) && (delta.y < 0) ) // 3eme quadrant + { + center.y = - center.y; + } + else // 4eme qadrant: les 2 coord sont >= 0! + { + } + + center.x += startpoint.x; + center.y = startpoint.y + center.y ; + + if ( trigo_sens ) + { + track->m_Start = startpoint; + track->m_End = endpoint; + } + else + { + track->m_Start = endpoint; + track->m_End = startpoint; + } + } + + track->m_NetCode = Dcode_index; + track->m_Param = center.x; + track->m_Sous_Netcode = center.y; + + NEGATE(track->m_Start.y); + NEGATE(track->m_End.y); + NEGATE(track->m_Sous_Netcode); + + Trace_Segment(frame->DrawPanel, DC, track,GR_OR); +} + + + /**************************************************/ + /* Routines utilisées en lecture de ficher gerber */ + /**************************************************/ +/* ces routines lisent la chaine de texte pointée par Text. + Apres appel, Text pointe le debut de la sequence non lue +*/ + +/***********************************************/ +wxPoint GERBER_Descr::ReadXYCoord(char * &Text) +/***********************************************/ +/* Retourne la coord courante pointee par Text (XnnnnYmmmm) +*/ +{ +wxPoint pos = m_CurrentPos; +int type_coord = 0, current_coord, nbchar; +bool is_float = FALSE; +char * text; +char line[256]; + + + if ( m_Relative ) pos.x = pos.y = 0; + else pos = m_CurrentPos; + + if ( Text == NULL ) return pos; + + text = line; + while ( * Text ) + { + if ( (* Text == 'X') || (* Text == 'Y') ) + { + type_coord = * Text; + Text++; + text = line; nbchar = 0; + while( IsNumber(*Text) ) + { + if ( *Text == '.' ) is_float = TRUE; + *(text++) = *(Text++); + if ( (*Text >= '0') && (*Text <='9') ) nbchar++; + } + *text = 0; + if ( is_float ) + { + if ( m_GerbMetric ) + current_coord = (int) round(atof(line) / 0.00254); + else + current_coord = (int) round(atof(line) * PCB_INTERNAL_UNIT); + } + else + { + int fmt_scale = (type_coord == 'X') ? m_FmtScale.x : m_FmtScale.y; + if ( m_NoTrailingZeros ) + { + int min_digit = (type_coord == 'X') ? m_FmtLen.x : m_FmtLen.y; + while (nbchar < min_digit) { *(text++) ='0'; nbchar++; } + *text=0; + } + current_coord = atoi(line); + double real_scale = 1.0; + switch( fmt_scale) + { + case 0: real_scale = 10000.0; + break; + case 1: real_scale = 1000.0; + break; + case 2: real_scale = 100.0; + break; + case 3: real_scale = 10.0; + break; + case 4: + break; + case 5: real_scale = 0.1; + break; + case 6: real_scale = 0.01; + break; + case 7: real_scale = 0.001; + break; + case 8: real_scale = 0.0001; + break; + case 9: real_scale = 0.00001; + break; + } + if ( m_GerbMetric ) real_scale = real_scale / 25.4; + current_coord = (int) round(current_coord * real_scale); + } + if ( type_coord == 'X' ) pos.x = current_coord; + else if ( type_coord == 'Y' ) pos.y = current_coord; + continue; + } + else break; + } + + if ( m_Relative ) + { + pos.x += m_CurrentPos.x; + pos.y += m_CurrentPos.y; + } + + m_CurrentPos = pos; + return pos; +} + +/************************************************/ +wxPoint GERBER_Descr::ReadIJCoord(char * &Text) +/************************************************/ +/* Retourne la coord type InnJnn courante pointee par Text (InnnnJmmmm) + Ces coordonnées sont relatives, donc si une coord est absente, sa valeur + par defaut est 0 +*/ +{ +wxPoint pos(0,0); +int type_coord = 0, current_coord, nbchar; +bool is_float = FALSE; +char * text; +char line[256]; + + if ( Text == NULL ) return pos; + + text = line; + while ( * Text ) + { + if ( (* Text == 'I') || (* Text == 'J') ) + { + type_coord = * Text; + Text++; + text = line; nbchar = 0; + while( IsNumber(*Text) ) + { + if ( *Text == '.' ) is_float = TRUE; + *(text++) = *(Text++); + if ( (*Text >= '0') && (*Text <='9') ) nbchar++; + } + *text = 0; + if ( is_float ) + { + if ( m_GerbMetric ) + current_coord = (int) round(atof(line) / 0.00254); + else + current_coord = (int) round(atof(line) * PCB_INTERNAL_UNIT); + } + else + { + int fmt_scale = (type_coord == 'I') ? m_FmtScale.x : m_FmtScale.y; + if ( m_NoTrailingZeros ) + { + int min_digit = (type_coord == 'I') ? m_FmtLen.x : m_FmtLen.y; + while (nbchar < min_digit) { *(text++) ='0'; nbchar++; } + *text=0; + } + current_coord = atoi(line); + double real_scale = 1.0; + switch( fmt_scale) + { + case 0: real_scale = 10000.0; + break; + case 1: real_scale = 1000.0; + break; + case 2: real_scale = 100.0; + break; + case 3: real_scale = 10.0; + break; + case 4: + break; + case 5: real_scale = 0.1; + break; + case 6: real_scale = 0.01; + break; + case 7: real_scale = 0.001; + break; + case 8: real_scale = 0.0001; + break; + case 9: real_scale = 0.00001; + break; + } + if ( m_GerbMetric ) real_scale = real_scale / 25.4; + current_coord = (int) round(current_coord * real_scale); + } + if ( type_coord == 'I' ) pos.x = current_coord; + else if ( type_coord == 'J' ) pos.y = current_coord; + continue; + } + else break; + } + m_IJPos = pos; + return pos; +} + +/*****************************************************/ +int GERBER_Descr::ReturnGCodeNumber(char * &Text) +/*****************************************************/ +/* Lit la sequence Gnn et retourne la valeur nn +*/ +{ +int ii = 0; +char * text; +char line[1024]; + + if ( Text == NULL ) return 0; + Text++; + text = line; + while( IsNumber(*Text) ) + { + *(text++) = *(Text++); + } + *text = 0; + ii = atoi(line); + return ii; +} + + + +/**************************************************/ +int GERBER_Descr::ReturnDCodeNumber(char * &Text) +/**************************************************/ +/* Lit la sequence Dnn et retourne la valeur nn +*/ +{ +int ii = 0; +char * text; +char line[1024]; + + if ( Text == NULL ) return 0; + Text ++; + text = line; + while( IsNumber(*Text) ) *(text++) = *(Text++); + *text = 0; + ii = atoi(line); + return ii; +} + +/******************************************************************/ +bool GERBER_Descr::Execute_G_Command(char * &text, int G_commande) +/******************************************************************/ + +{ + switch (G_commande) + { + case GC_LINEAR_INTERPOL_1X: + m_Iterpolation = GERB_INTERPOL_LINEAR_1X; + break; + + case GC_CIRCLE_NEG_INTERPOL: + m_Iterpolation = GERB_INTERPOL_ARC_NEG; + break; + + case GC_CIRCLE_POS_INTERPOL: + m_Iterpolation = GERB_INTERPOL_ARC_POS; + break; + + case GC_COMMENT: + text = NULL; + break ; + + case GC_LINEAR_INTERPOL_10X: + m_Iterpolation = GERB_INTERPOL_LINEAR_10X; + break; + + case GC_LINEAR_INTERPOL_0P1X: + m_Iterpolation = GERB_INTERPOL_LINEAR_01X; + break; + + case GC_LINEAR_INTERPOL_0P01X: + m_Iterpolation = GERB_INTERPOL_LINEAR_001X; + break; + + case GC_SELECT_TOOL: + { + int D_commande = ReturnDCodeNumber(text); + if ( D_commande < FIRST_DCODE) return FALSE; + if (D_commande > (MAX_TOOLS-1)) D_commande = MAX_TOOLS-1; + m_Current_Tool = D_commande; + D_CODE * pt_Dcode = ReturnToolDescr(m_Layer, D_commande); + if ( pt_Dcode ) pt_Dcode->m_InUse = TRUE; + break; + } + + case GC_SPECIFY_INCHES: + m_GerbMetric = FALSE; // FALSE = Inches, TRUE = metric + break; + + case GC_SPECIFY_MILLIMETERS: + m_GerbMetric = TRUE; // FALSE = Inches, TRUE = metric + break; + + case GC_TURN_OFF_360_INTERPOL: + m_360Arc_enbl = FALSE; + break; + + case GC_TURN_ON_360_INTERPOL: + m_360Arc_enbl = TRUE; + break; + + case GC_SPECIFY_ABSOLUES_COORD: + m_Relative = FALSE; // FALSE = absolute Coord, RUE = relative Coord + break; + + case GC_SPECIFY_RELATIVEES_COORD: + m_Relative = TRUE; // FALSE = absolute Coord, RUE = relative Coord + break; + + case GC_TURN_ON_POLY_FILL: + m_PolygonFillMode = TRUE; + break; + + case GC_TURN_OFF_POLY_FILL: + m_PolygonFillMode = FALSE; + m_PolygonFillModeState = 0; + break; + + case GC_MOVE: // Non existant + default: + { + wxString msg; msg.Printf( wxT("G%.2d command not handled"),G_commande); + DisplayError(NULL, msg); + return FALSE; + } + } + + + return TRUE; +} + +/*****************************************************************************/ +bool GERBER_Descr::Execute_DCODE_Command(WinEDA_GerberFrame * frame, wxDC * DC, + char * &text, int D_commande) +/*****************************************************************************/ +{ +wxSize size(15, 15); +int shape = 1, dcode = 0; +D_CODE * pt_Tool = NULL; +wxString msg; + + if(D_commande >= FIRST_DCODE ) + { + if (D_commande > (MAX_TOOLS-1)) D_commande = MAX_TOOLS-1; + m_Current_Tool = D_commande; + D_CODE * pt_Dcode = ReturnToolDescr(m_Layer, D_commande); + if ( pt_Dcode ) pt_Dcode->m_InUse = TRUE; + return TRUE; + } + + if ( m_PolygonFillMode ) // Enter a plygon description: + { + switch ( D_commande ) + { + case 1: //code D01 Draw line, exposure ON + { + SEGZONE * edge_poly, *last; + + edge_poly = new SEGZONE( frame->m_Pcb ); + last = (SEGZONE*)frame->m_Pcb->m_Zone; + if ( last ) while (last->Pnext ) last = (SEGZONE*)last->Pnext; + edge_poly->Insert(frame->m_Pcb, last); + + edge_poly->m_Layer = frame->GetScreen()->m_Active_Layer ; + edge_poly->m_Width = 1; + edge_poly->m_Start = m_PreviousPos; + NEGATE(edge_poly->m_Start.y); + edge_poly->m_End = m_CurrentPos; + NEGATE(edge_poly->m_End.y); + edge_poly->m_NetCode = m_PolygonFillModeState; + m_PreviousPos = m_CurrentPos; + m_PolygonFillModeState = 1; + break; + } + + case 2: //code D2: exposure OFF (i.e. "move to") + m_PreviousPos = m_CurrentPos; + m_PolygonFillModeState = 0; + break; + + default: + return FALSE; + } + } + + + else switch ( D_commande ) + { + case 1: //code D01 Draw line, exposure ON + pt_Tool = ReturnToolDescr(m_Layer, m_Current_Tool); + if ( pt_Tool ) + { + size = pt_Tool->m_Size; + dcode = pt_Tool->m_Num_Dcode; + shape = pt_Tool->m_Shape; + } + switch ( m_Iterpolation ) + { + case GERB_INTERPOL_LINEAR_1X: + Append_1_Line_GERBER(dcode, + frame, DC, + m_PreviousPos, m_CurrentPos, + size.x); + break; + + case GERB_INTERPOL_LINEAR_01X: + case GERB_INTERPOL_LINEAR_001X: + case GERB_INTERPOL_LINEAR_10X: + wxBell(); + break; + + case GERB_INTERPOL_ARC_NEG: + Append_1_SEG_ARC_GERBER(dcode, + frame, DC, + m_PreviousPos, m_CurrentPos, m_IJPos, + size.x, FALSE, m_360Arc_enbl); + break; + + case GERB_INTERPOL_ARC_POS: + Append_1_SEG_ARC_GERBER(dcode, + frame, DC, + m_PreviousPos, m_CurrentPos, m_IJPos, + size.x, TRUE, m_360Arc_enbl); + break; + + default: + msg.Printf( wxT("Execute_DCODE_Command: interpol error (type %X)"), + m_Iterpolation); + DisplayError(frame, msg); + break; + } + m_PreviousPos = m_CurrentPos; + break; + + case 2: //code D2: exposure OFF (i.e. "move to") + m_PreviousPos = m_CurrentPos; + break; + + case 3: // code D3: flash aperture + pt_Tool = ReturnToolDescr(m_Layer, m_Current_Tool); + if ( pt_Tool ) + { + size = pt_Tool->m_Size; + dcode = pt_Tool->m_Num_Dcode; + shape = pt_Tool->m_Shape; + } + + switch (shape) + { + case GERB_LINE: + case GERB_CIRCLE : + Append_1_Flash_ROND_GERBER(dcode, + frame, DC, + m_CurrentPos, + size.x); + break ; + + case GERB_OVALE : + Append_1_Flash_GERBER( dcode, + frame, DC, m_CurrentPos, + size, + OVALE); + break ; + + case GERB_RECT: + Append_1_Flash_GERBER( dcode, + frame, DC, m_CurrentPos, + size, + RECT); + break ; + + default: // Special (Macro) : Non implanté + break; + + } + m_PreviousPos = m_CurrentPos; + break; + + default: + return FALSE; + } + + return TRUE; +} + diff --git a/gerbview/rs274x.cpp b/gerbview/rs274x.cpp new file mode 100644 index 0000000000..bd53a02893 --- /dev/null +++ b/gerbview/rs274x.cpp @@ -0,0 +1,461 @@ + /********************************************************/ + /* Routine de lecture d'un fichier GERBER format RS274X */ + /********************************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" + +#include "protos.h" + +#define IsNumber(x) ( ( ((x) >= '0') && ((x) <='9') ) ||\ + ((x) == '-') || ((x) == '+') || ((x) == '.') || ((x) == ',')) + +#define CODE(x,y) ((x<<8) + (y)) +enum rs274x_parameters +{ + FORMAT_STATEMENT_COMMAND = CODE('F','S'), + AXIS_SELECT = CODE('A','S'), + MIRROR_IMAGE = CODE('M','I'), + MODE_OF_UNITS = CODE('M','O'), + INCH = CODE('I','N'), + MILLIMETER = CODE('M','M'), + OFFSET = CODE('O','F'), + SCALE_FACTOR = CODE('S','F'), + + IMAGE_NAME = CODE('I','N'), + IMAGE_JUSTIFY = CODE('I','J'), + IMAGE_OFFSET = CODE('I','O'), + IMAGE_POLARITY = CODE('I','P'), + IMAGE_ROTATION = CODE('I','R'), + PLOTTER_FILM = CODE('P','M'), + INCLUDE_FILE = CODE('I','F'), + + APERTURE_DESCR = CODE('A','D'), + APERTURE_MACRO = CODE('A','M'), + LAYER_NAME = CODE('L','N'), + LAYER_POLARITY = CODE('L','P'), + KNOCKOUT = CODE('K','O'), + STEP_AND_REPEAT = CODE('S','P'), + ROTATE = CODE('R','O') + +}; + +/* Variables locales : */ + +/* Routines Locales */ +static bool ReadApertureMacro( char * buff, char * &text, FILE *gerber_file); + +/* Lit 2 codes ascii du texte pointé par text +retourne le code correspondant ou -1 si erreur +*/ +static int ReadXCommand(char * &text) +{ +int result; + + if ( text && *text ) + { + result = (*text) << 8; text ++; + } + else return -1; + if ( text && *text ) + { + result += (*text) & 255; text ++; + } + else return -1; + return result; +} + + +/********************************/ +static int ReadInt(char * &text) +/********************************/ +{ +int nb = 0; + while ( text && *text) + { + if ( (*text >= '0') && (*text <='9') ) + { + nb *= 10; nb += *text & 0x0F; + text++; + } + else break; + } + return nb; +} + + +/************************************/ +static double ReadDouble(char * &text) +/************************************/ +{ +double nb = 0.0; +char buf[256], * ptchar; + + ptchar = buf; + while ( text && *text) + { + if ( IsNumber(*text) ) + { + * ptchar = * text; + + if ( * ptchar =='.' || *ptchar == ',' ) * ptchar = g_FloatSeparator; + + text++; ptchar ++; + } + else break; + } + *ptchar = 0; + + nb = atof(buf); + return nb; +} + +/****************************************************************************/ +bool GERBER_Descr::ReadRS274XCommand(WinEDA_GerberFrame * frame, wxDC * DC, + char * buff, char * &text) +/****************************************************************************/ +/* Lit toutes les commandes RS274X jusqu'a trouver de code de fin % + appelle ExecuteRS274XCommand() pour chaque commande trouvée +*/ +{ +int code_command; +bool eof = FALSE; + + text++; + + do + { + while ( *text ) + { + switch( *text ) + { + case '%': // End commande + text ++; + m_CommandState = CMD_IDLE; + return TRUE; + + case ' ': + case '\r': + case '\n': + text++; + break; + + case '*': + text++; + break; + + default: + code_command = ReadXCommand ( text ); + ExecuteRS274XCommand(code_command, + buff, text); + break; + } + } + // End of current line + if ( fgets(buff,255,m_Current_File) == NULL ) eof = TRUE; + text = buff; + } while( !eof ); + + return FALSE; +} + + +/*******************************************************************************/ +bool GERBER_Descr::ExecuteRS274XCommand(int command, char * buff, char * &text) +/*******************************************************************************/ +/* Execute 1 commande RS274X +*/ +{ +int code; +int xy_seq_len, xy_seq_char; +char ctmp; +bool ok = TRUE; +D_CODE * dcode; +char Line[1024]; +wxString msg; +double fcoord; +double conv_scale = m_GerbMetric ? PCB_INTERNAL_UNIT/25.4 : PCB_INTERNAL_UNIT; + + + switch( command ) + { + case FORMAT_STATEMENT_COMMAND: + xy_seq_len = 2; + while ( *text != '*' ) + { + switch ( *text ) + { + case'L': // No Leading 0 + m_NoTrailingZeros = FALSE; + text ++; + break; + case'T': // No trailing 0 + m_NoTrailingZeros = TRUE; + text ++; + break; + case 'A': // Absolute coord + m_Relative = FALSE; text++; + break; + case 'I': // Absolute coord + m_Relative = TRUE; text++; + break; + case 'N': // Sequence code (followed by the number of digits for the X,Y command + text++; + xy_seq_char = * text; text++; + if ( (xy_seq_char >= '0') && (xy_seq_char <= '9') ) + xy_seq_len = - '0'; + break; + + case 'X': + case 'Y': // Valeurs transmises :2 (really xy_seq_len : FIX ME) digits + code = *(text ++); ctmp = *(text++) - '0'; + if ( code == 'X' ) + { + m_FmtScale.x = * text - '0'; // = nb chiffres apres la virgule + m_FmtLen.x = ctmp + m_FmtScale.x; // = nb total de chiffres + } + else { + m_FmtScale.y = * text - '0'; + m_FmtLen.y = ctmp + m_FmtScale.y; + } + text++; + break; + + case'*': + break; + + default: + GetEndOfBlock( buff, text, m_Current_File ); + ok = FALSE; + break; + } + } + break; + + case AXIS_SELECT: + case MIRROR_IMAGE: + ok = FALSE; + break; + + case MODE_OF_UNITS: + code = ReadXCommand ( text ); + if ( code == INCH ) m_GerbMetric = FALSE; + else if ( code == MILLIMETER ) m_GerbMetric = TRUE; + conv_scale = m_GerbMetric ? PCB_INTERNAL_UNIT/25.4 : PCB_INTERNAL_UNIT; + break; + + case OFFSET: // command: OFAnnBnn (nn = float number) + m_Offset.x = m_Offset.y = 0; + while ( *text != '*' ) + { + switch ( *text ) + { + case'A': // A axis offset in current unit (inch ou mm) + text ++; + fcoord = ReadDouble(text); + m_Offset.x = (int) round(fcoord * conv_scale); + break; + + case'B': // B axis offset in current unit (inch ou mm) + text ++; + fcoord = ReadDouble(text); + m_Offset.y = (int) round(fcoord * conv_scale); + break; + } + } + break; + + case SCALE_FACTOR: + case IMAGE_JUSTIFY: + case IMAGE_ROTATION : + case IMAGE_OFFSET: + case PLOTTER_FILM: + case LAYER_NAME: + case KNOCKOUT: + case STEP_AND_REPEAT: + case ROTATE: + msg.Printf(_("Command <%c%c> ignored by Gerbview"), + (command>>8) & 0xFF, command & 0xFF); + wxMessageBox(msg); + break; + + case IMAGE_NAME: + m_Name.Empty(); + while ( *text != '*' ) + { + m_Name.Append(*text); text++; + } + break; + + case IMAGE_POLARITY: + if ( strnicmp(text, "NEG", 3 ) == 0 ) m_ImageNegative = TRUE; + else m_ImageNegative = FALSE; + break; + + case LAYER_POLARITY: + if ( * text == 'C' ) m_LayerNegative = TRUE; + else m_LayerNegative = FALSE; + break; + + case APERTURE_MACRO: + ReadApertureMacro( buff, text, m_Current_File ); + break; + + case INCLUDE_FILE: + if ( m_FilesPtr >= 10 ) + { + ok = FALSE; + DisplayError(NULL, _("Too many include files!!") ); + break; + } + strcpy(Line, text); + strtok(Line,"*%%\n\r"); + m_FilesList[m_FilesPtr] = m_Current_File; + m_Current_File = fopen(Line,"rt"); + if (m_Current_File == 0) + { + wxString msg; + msg.Printf( wxT("fichier <%s> non trouve"),Line); + DisplayError(NULL, msg, 10); + ok = FALSE; + m_Current_File = m_FilesList[m_FilesPtr]; + break; + } + m_FilesPtr ++; + break; + + case APERTURE_DESCR: + if ( *text != 'D' ) + { + ok = FALSE; break; + } + m_As_DCode = TRUE; + text++; + code = ReadInt(text); + ctmp = *text; + dcode = ReturnToolDescr(m_Layer, code); + if ( dcode == NULL ) break; + if ( text[1] == ',' ) // Tool usuel (C,R,O,P) + { + text += 2; // text pointe size ( 1er modifier) + dcode->m_Size.x = dcode->m_Size.y = + (int) round(ReadDouble(text) * conv_scale); + switch (ctmp ) + { + case 'C': // Circle + dcode->m_Shape = GERB_CIRCLE; + if ( * text == 'X' ) + { + text++; + dcode->m_Drill.x = dcode->m_Drill.y = + (int) round(ReadDouble(text) * conv_scale); + dcode->m_DrillShape = 1; + } + if ( * text == 'X' ) + { + text++; + dcode->m_Drill.y = + (int) round(ReadDouble(text) * conv_scale); + dcode->m_DrillShape = 2; + } + dcode->m_Defined = TRUE; + break; + + case 'O': // ovale + case 'R': // rect + dcode->m_Shape = (ctmp == 'O') ? GERB_OVALE : GERB_RECT; + if ( * text == 'X' ) + { + text++; + dcode->m_Size.y = + (int) round(ReadDouble(text) * conv_scale); + } + if ( * text == 'X' ) + { + text++; + dcode->m_Drill.x = dcode->m_Drill.y = + (int) round(ReadDouble(text) * conv_scale); + dcode->m_DrillShape = 1; + } + if ( * text == 'Y' ) + { + text++; + dcode->m_Drill.y = + (int) round(ReadDouble(text) * conv_scale); + dcode->m_DrillShape = 2; + } + dcode->m_Defined = TRUE; + break; + + case 'P': // Polygone +// A modifier: temporairement la forme ronde est utilisée + dcode->m_Shape = GERB_CIRCLE; + dcode->m_Defined = TRUE; + break; + } + } + break; + + default: + ok = FALSE; + break; + } + + GetEndOfBlock( buff, text, m_Current_File ); + return ok; +} + +/*****************************************************************/ +bool GetEndOfBlock( char * buff, char * &text, FILE *gerber_file) +/*****************************************************************/ +{ +bool eof = FALSE; + + do { + while ( (text < buff+255) && *text ) + { + if ( *text == '*' ) return TRUE; + if ( *text == '%' ) return TRUE; + text ++; + } + if ( fgets(buff,255,gerber_file) == NULL ) eof = TRUE; + text = buff; + } while( ! eof); + + return FALSE; +} + + +/*******************************************************************/ +bool ReadApertureMacro( char * buff, char * &text, FILE *gerber_file) +/*******************************************************************/ +{ +wxString macro_name; +int macro_type = 0; + + // Read macro name + while ( (text < buff+255) && *text ) + { + if ( *text == '*' ) break; + macro_name.Append(*text); + text ++; + } + +wxMessageBox(macro_name, wxT("macro name")); + text = buff; + fgets(buff,255,gerber_file); + + // Read parameters + macro_type = ReadInt(text); + + while ( (text < buff+255) && *text ) + { + if ( *text == '*' ) return TRUE; + text ++; + } + return FALSE; +} + diff --git a/gerbview/set_color.cpp b/gerbview/set_color.cpp new file mode 100644 index 0000000000..a98035860d --- /dev/null +++ b/gerbview/set_color.cpp @@ -0,0 +1,344 @@ + /* Set up the basic primitives for Layer control */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "gerbview.h" +#include "pcbnew.h" + +#include "protos.h" + +#define BUTT_SIZE_X 20 +#define BUTT_SIZE_Y 16 + +/* Variables locales */ +int CurrentColor; + +/* Fonctions locales: */ + +/* Macro utile : */ +#define ADR(numlayer) &g_DesignSettings.m_LayerColor[(numlayer)] + +enum col_sel_id { + ID_COLOR_RESET_SHOW_LAYER_ON = 1800, + ID_COLOR_RESET_SHOW_LAYER_OFF, + ID_COLOR_EXIT, + ID_COLOR_CHECKBOX_ONOFF, + ID_COLOR_SETUP +}; + + /**********************************/ + /* Liste des menus de Menu_Layers */ + /**********************************/ +struct ColorButton + { + wxString m_Name; + int * m_Color; // Pointeur sur la variable couleur + bool m_NoDisplayIsColor; // TRUE si bit ITEM_NON_VISIBLE de la variable Color + bool * m_NoDisplay; // Pointeur sur la variable Display on/off si ce n'est pas la var + // Color + int m_Id; + wxBitmapButton * m_Button; + int m_State; + wxCheckBox * m_CheckBox; // Option Display ON/OFF +}; + +#include "set_color.h" /* include description and list of tools and buttons */ + + +/*************************************************************/ +/* classe derivee pour la frame de Configuration des couleurs*/ +/*************************************************************/ + +class WinEDA_SetColorsFrame: public wxDialog +{ +private: + WinEDA_DrawFrame *m_Parent; + +public: + + // Constructor and destructor + WinEDA_SetColorsFrame(WinEDA_DrawFrame *parent, const wxPoint& framepos); + ~WinEDA_SetColorsFrame(void) {}; + +private: + void SetColor(wxCommandEvent& event); + void OnQuit(wxCommandEvent& event); + void SetDisplayOnOff(wxCommandEvent& event); + void ResetDisplayLayersCu(wxCommandEvent& event); + DECLARE_EVENT_TABLE() + +}; +/* Table des evenements pour WinEDA_SetColorsFrame */ +BEGIN_EVENT_TABLE(WinEDA_SetColorsFrame, wxDialog) + EVT_BUTTON(ID_COLOR_RESET_SHOW_LAYER_OFF, WinEDA_SetColorsFrame::ResetDisplayLayersCu) + EVT_BUTTON(ID_COLOR_RESET_SHOW_LAYER_ON, WinEDA_SetColorsFrame::ResetDisplayLayersCu) + EVT_BUTTON(ID_COLOR_EXIT, WinEDA_SetColorsFrame::OnQuit) + EVT_CHECKBOX(ID_COLOR_CHECKBOX_ONOFF, WinEDA_SetColorsFrame::SetDisplayOnOff) + EVT_BUTTON(ID_COLOR_SETUP, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+1, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+2, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+3, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+4, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+5, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+6, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+7, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+8, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+9, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+10, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+11, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+12, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+13, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+14, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+15, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+16, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+17, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+18, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+19, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+20, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+21, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+22, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+23, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+24, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+25, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+26, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+27, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+28, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+29, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+30, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+31, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+32, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+33, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+34, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+35, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+36, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+37, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+38, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+39, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+40, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+41, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+42, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+43, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+44, WinEDA_SetColorsFrame::SetColor) +END_EVENT_TABLE() + +/**************************************************************/ +/* void DisplayColorSetupFrame(WinEDA_DrawFrame * parent, */ +/* const wxPoint & pos) */ +/**************************************************************/ + +void DisplayColorSetupFrame(WinEDA_DrawFrame * parent, + const wxPoint & framepos) +{ + WinEDA_SetColorsFrame * frame = + new WinEDA_SetColorsFrame(parent, framepos); + frame->ShowModal(); frame->Destroy(); +} + + + +/**********************************************************************/ +WinEDA_SetColorsFrame::WinEDA_SetColorsFrame(WinEDA_DrawFrame *parent, + const wxPoint& framepos): + wxDialog(parent, -1, _("Gerbview Layer Colors:"), framepos, + wxSize(390, 380), + wxDEFAULT_DIALOG_STYLE|wxFRAME_FLOAT_ON_PARENT ) +/**********************************************************************/ +{ +wxBitmapButton * ButtonB; +int ii, butt_ID, buttcolor; +wxString msg; +wxStaticText * text; +wxBoxSizer * CurrBoxSizer = NULL; + + m_Parent = parent; + SetFont(*g_DialogFont); + + wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(MainBoxSizer); + + for ( ii = 0; laytool_list[ii] != NULL; ii++ ) + { + if( ! CurrBoxSizer || ! laytool_list[ii]->m_Color && ! laytool_list[ii]->m_NoDisplay ) + { + CurrBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(CurrBoxSizer, 0, wxGROW|wxALL, 5); + msg = wxGetTranslation(laytool_list[ii]->m_Name.GetData()); + text = new wxStaticText(this,-1, msg ); + CurrBoxSizer->Add(text, 0, wxGROW|wxALL, 5); + continue; + } + + if ( laytool_list[ii]->m_Id == 0 ) + laytool_list[ii]->m_Id = ID_COLOR_SETUP + ii; + butt_ID = laytool_list[ii]->m_Id; + + wxBoxSizer * LineBoxSizer = new wxBoxSizer(wxHORIZONTAL); + wxCheckBox * Checkb; + CurrBoxSizer->Add(LineBoxSizer, 0, wxGROW|wxALL, 0); + laytool_list[ii]->m_CheckBox = Checkb = new wxCheckBox(this, + ID_COLOR_CHECKBOX_ONOFF, wxEmptyString ); + LineBoxSizer->Add(Checkb, 0, wxGROW|wxALL, 1); + + if ( laytool_list[ii]->m_NoDisplayIsColor ) + { + if ( *laytool_list[ii]->m_Color & ITEM_NOT_SHOW ) + laytool_list[ii]->m_CheckBox->SetValue(FALSE); + else laytool_list[ii]->m_CheckBox->SetValue(TRUE); + } + + else if ( laytool_list[ii]->m_NoDisplay ) + laytool_list[ii]->m_CheckBox->SetValue(*laytool_list[ii]->m_NoDisplay); + + if( laytool_list[ii]->m_Color ) + { + wxMemoryDC iconDC; int w = BUTT_SIZE_X, h = BUTT_SIZE_Y; + wxBitmap ButtBitmap(w,h); + iconDC.SelectObject( ButtBitmap ); + buttcolor = *laytool_list[ii]->m_Color & MASKCOLOR; + wxBrush Brush; + iconDC.SelectObject( ButtBitmap ); + iconDC.SetPen(*wxBLACK_PEN); + Brush.SetColour( + ColorRefs[buttcolor].m_Red, + ColorRefs[buttcolor].m_Green, + ColorRefs[buttcolor].m_Blue + ); + Brush.SetStyle(wxSOLID); + + iconDC.SetBrush(Brush); + iconDC.DrawRectangle(0,0, w, h); + + ButtonB = new wxBitmapButton(this, butt_ID, + ButtBitmap, wxDefaultPosition, + wxSize(w,h) ); + laytool_list[ii]->m_Button = ButtonB; + LineBoxSizer->Add(ButtonB, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); + } + + msg = wxGetTranslation(laytool_list[ii]->m_Name.GetData()); + text = new wxStaticText(this,-1, msg); + LineBoxSizer->Add(text, 0, wxGROW|wxALL, 1); + } + + CurrBoxSizer->AddSpacer(20); + wxButton * Button = new wxButton(this,ID_COLOR_RESET_SHOW_LAYER_ON, + _("Show All")); + Button->SetForegroundColour(*wxBLUE); + CurrBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Button = new wxButton(this,ID_COLOR_RESET_SHOW_LAYER_OFF, + _("Show None")); + Button->SetForegroundColour(*wxRED); + CurrBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Button = new wxButton(this,ID_COLOR_EXIT, + _("Exit")); + Button->SetForegroundColour(*wxBLACK); + CurrBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); +} + +/*******************************************************************/ +void WinEDA_SetColorsFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/*******************************************************************/ +{ + // true is to force the frame to close + Close(true); +} + + + +/***********************************************************/ +void WinEDA_SetColorsFrame::SetColor(wxCommandEvent& event) +/***********************************************************/ +{ +int ii; +int id = event.GetId(); +int color; +int w = BUTT_SIZE_X, h = BUTT_SIZE_Y; + + + color = DisplayColorFrame(this); + if ( color < 0) return; + + for ( ii = 0; laytool_list[ii] != NULL; ii++ ) + { + if( laytool_list[ii]->m_Id != id) continue; + if( laytool_list[ii]->m_Color == NULL) continue; + + if( *laytool_list[ii]->m_Color == color) break; + + *laytool_list[ii]->m_Color = color; + wxMemoryDC iconDC; + + wxBitmapButton * Button = laytool_list[ii]->m_Button; + + wxBitmap ButtBitmap = Button->GetBitmapLabel(); + iconDC.SelectObject( ButtBitmap ); + int buttcolor = *laytool_list[ii]->m_Color; + wxBrush Brush; + iconDC.SelectObject( ButtBitmap ); + iconDC.SetPen(*wxBLACK_PEN); + Brush.SetColour( + ColorRefs[buttcolor].m_Red, + ColorRefs[buttcolor].m_Green, + ColorRefs[buttcolor].m_Blue + ); + Brush.SetStyle(wxSOLID); + + iconDC.SetBrush(Brush); + iconDC.DrawRectangle(0,0, w, h); + SetDisplayOnOff(event); + m_Parent->GetScreen()->SetRefreshReq(); + } + Refresh(FALSE); +} + + +/******************************************************************/ +void WinEDA_SetColorsFrame::SetDisplayOnOff(wxCommandEvent& event) +/******************************************************************/ +{ + for ( int ii = 0; laytool_list[ii] != NULL; ii++ ) + { + if ( laytool_list[ii]->m_CheckBox == NULL ) continue; + if ( ! laytool_list[ii]->m_NoDisplayIsColor && + (laytool_list[ii]->m_NoDisplay == NULL) ) continue; + + if ( laytool_list[ii]->m_NoDisplayIsColor ) + { + if ( laytool_list[ii]->m_CheckBox->GetValue() ) + *laytool_list[ii]->m_Color &= ~ITEM_NOT_SHOW; + else *laytool_list[ii]->m_Color |= ITEM_NOT_SHOW; + } + + else + { + *laytool_list[ii]->m_NoDisplay = laytool_list[ii]->m_CheckBox->GetValue(); + } + + } + m_Parent->GetScreen()->SetRefreshReq(); +} + + + +/***********************************************************************/ +void WinEDA_SetColorsFrame::ResetDisplayLayersCu(wxCommandEvent& event) +/***********************************************************************/ +{ +bool NewState = (event.GetId() == ID_COLOR_RESET_SHOW_LAYER_ON) ? TRUE : FALSE; + + for ( int ii = 1; ii < 34; ii++ ) + { + if ( laytool_list[ii]->m_CheckBox == NULL ) continue; + laytool_list[ii]->m_CheckBox->SetValue(NewState); + } + + SetDisplayOnOff(event); +} + diff --git a/gerbview/set_color.h b/gerbview/set_color.h new file mode 100644 index 0000000000..b20f41c6d5 --- /dev/null +++ b/gerbview/set_color.h @@ -0,0 +1,302 @@ + /* Set up the button list for the color selection for gerbview layers */ + +static ColorButton Msg_Layers_Cu= +{ + _("Layers 1-16") /* Title */ +}; + +static ColorButton Msg_Layers_Tech= +{ + _("Layers 17-32") /* Title */ +}; + +static ColorButton Layer_1_Butt= +{ + _("Layer 1"), /* Title */ + ADR(0), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_2_Butt= +{ + _("Layer 2"), /* Title */ + ADR(1), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_3_Butt= +{ + _("Layer 3"), /* Title */ + ADR(2), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_4_Butt= +{ + _("Layer 4"), /* Title */ + ADR(3), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_5_Butt= +{ + _("Layer 5"), /* Title */ + ADR(4), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_6_Butt= +{ + _("Layer 6"), /* Title */ + ADR(5), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_7_Butt= +{ + _("Layer 7"), /* Title */ + ADR(6), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_8_Butt= +{ + _("Layer 8"), /* Title */ + ADR(7), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_9_Butt= +{ + _("Layer 9"), /* Title */ + ADR(8), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_10_Butt= +{ + _("Layer 10"), /* Title */ + ADR(9), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_11_Butt= +{ + _("Layer 11"), /* Title */ + ADR(10), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_12_Butt= +{ + _("Layer 12"), /* Title */ + ADR(11), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_13_Butt= +{ + _("Layer 13"), /* Title */ + ADR(12), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_14_Butt= +{ + _("Layer 14"), /* Title */ + ADR(13), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_15_Butt= +{ + _("Layer 15"), /* Title */ + ADR(14), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_16_Butt= +{ + _("Layer 16"), /* Title */ + ADR(15), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_17_Butt= +{ + _("Layer 17"), /* Title */ + ADR(16), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_18_Butt= +{ + _("Layer 18"), /* Title */ + ADR(17), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_19_Butt= +{ + _("Layer 19"), /* Title */ + ADR(18), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_20_Butt= +{ + _("Layer 20"), /* Title */ + ADR(19), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_21_Butt= +{ + _("Layer 21"), /* Title */ + ADR(20), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_22_Butt= +{ + _("Layer 22"), /* Title */ + ADR(21), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_23_Butt= +{ + _("Layer 23"), /* Title */ + ADR(22), /* adr du parametre optionnel */ + TRUE /* adr du parametre display on/off */ +}; + +static ColorButton Layer_24_Butt= +{ + _("Layer 24"), /* Title */ + ADR(23), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_25_Butt= +{ + _("Layer 25"), /* Title */ + ADR(24), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_26_Butt= +{ + _("Layer 26"), /* Title */ + ADR(25), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_27_Butt= +{ + _("Layer 27"), /* Title */ + ADR(26), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_28_Butt= +{ + _("Layer 28"), /* Title */ + ADR(27), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_29_Butt= +{ + _("Layer 29"), /* Title */ + ADR(28), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_30_Butt= +{ + _("Layer 30"), /* Title */ + ADR(29), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_31_Butt= +{ + _("Layer 31"), /* Title */ + ADR(30), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Layer_32_Butt= +{ + _("Layer 32"), /* Title */ + ADR(31), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + + +static ColorButton Msg_Others_Items= +{ + _("Others") /* Title */ +}; + + +static ColorButton Grid_Butt= +{ + _("Grid"), /* Title */ + &g_DesignSettings.m_PcbGridColor, /* adr du parametre optionnel */ + FALSE, + &g_ShowGrid /* parametre display on/off = bool */ +}; + +static ColorButton Show_DCodes_Butt= +{ + _("DCodes id."), /* Title */ + &g_DCodesColor, /* adr du parametre optionnel */ + FALSE, + &DisplayOpt.DisplayPadNum /* parametre display on/off = bool*/ +}; + +static ColorButton * laytool_list[] = { + &Msg_Layers_Cu, + &Layer_1_Butt, + &Layer_2_Butt, + &Layer_3_Butt, + &Layer_4_Butt, + &Layer_5_Butt, + &Layer_6_Butt, + &Layer_7_Butt, + &Layer_8_Butt, + &Layer_9_Butt, + &Layer_10_Butt, + &Layer_11_Butt, + &Layer_12_Butt, + &Layer_13_Butt, + &Layer_14_Butt, + &Layer_15_Butt, + &Layer_16_Butt, + + &Msg_Layers_Tech, + &Layer_17_Butt, + &Layer_18_Butt, + &Layer_19_Butt, + &Layer_20_Butt, + &Layer_21_Butt, + &Layer_22_Butt, + &Layer_23_Butt, + &Layer_24_Butt, + &Layer_25_Butt, + &Layer_26_Butt, + &Layer_27_Butt, + &Layer_28_Butt, + &Layer_29_Butt, + &Layer_30_Butt, + &Layer_31_Butt, + &Layer_32_Butt, + + &Msg_Others_Items, + &Grid_Butt, + &Show_DCodes_Butt, + + NULL +}; diff --git a/gerbview/struct.cpp b/gerbview/struct.cpp new file mode 100644 index 0000000000..1ebf96aabc --- /dev/null +++ b/gerbview/struct.cpp @@ -0,0 +1,93 @@ + /***********************************************/ + /* Routines d'effacement et copie de structures*/ + /***********************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" + +/* Variables locales */ + + +/***************************************************/ +void DeleteStructure( EDA_BaseStruct * PtStruct ) +/***************************************************/ +/* Supprime de la liste chainee la stucture pointee par GenericStructure + et libere la memoire correspondante +*/ +{ +EDA_BaseStruct *PtNext, *PtBack; +int IsDeleted; +wxString msg; + + if( PtStruct == NULL) return ; + + IsDeleted = PtStruct->GetState(DELETED); + + PtNext = PtStruct->Pnext; + PtBack = PtStruct->Pback; + + switch( PtStruct->m_StructType ) + { + case TYPE_NOT_INIT: + DisplayError(NULL, wxT("DeleteStruct: Type NOT_INIT")); + break; + + + case TYPEDRAWSEGMENT: + #undef Struct + #define Struct ((DRAWSEGMENT*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPETEXTE: + #undef Struct + #define Struct ((TEXTE_PCB*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + + case TYPEVIA: + case TYPETRACK: + case TYPEZONE: + #undef Struct + #define Struct ((TRACK*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEMARQUEUR: + #undef Struct + #define Struct ((MARQUEUR*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEPCB: + default: + msg.Printf( wxT("DeleteStructure: unexpected %d type"), + PtStruct->m_StructType); + DisplayError(NULL, msg); + break; + } +} + +/*************************************************/ +void DeleteStructList( EDA_BaseStruct * PtStruct ) +/*************************************************/ +/* Supprime la liste chainee pointee par PtStruct + et libere la memoire correspondante +*/ +{ +EDA_BaseStruct *PtNext; + while (PtStruct) + { + PtNext = PtStruct->Pnext; + delete PtStruct; + PtStruct = PtNext; + } +} + diff --git a/gerbview/tool_gerber.cpp b/gerbview/tool_gerber.cpp new file mode 100644 index 0000000000..94b3cf1f60 --- /dev/null +++ b/gerbview/tool_gerber.cpp @@ -0,0 +1,285 @@ + /***********************************************/ + /* buildmnu.h: construction du menu principal */ + /***********************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" + +#include "protos.h" + +#define BITMAP wxBitmap + +#include "bitmaps.h" + +#include "id.h" + + +/***********************************************/ +void WinEDA_GerberFrame::ReCreateHToolbar(void) +/***********************************************/ +{ +int layer = 0; +GERBER_Descr * gerber_layer = NULL; +int ii; + + // delete and recreate the toolbar + if ( m_HToolBar != NULL ) return; + + if ( GetScreen() ) + { + layer = GetScreen()->m_Active_Layer; + gerber_layer = g_GERBER_Descr_List[layer]; + } + + m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE); + SetToolBar(m_HToolBar); + + // Set up toolbar + m_HToolBar->AddTool(ID_NEW_BOARD, BITMAP(new_xpm), + wxNullBitmap, FALSE, + -1, -1, (wxObject *) NULL, + _("New World") ); + + m_HToolBar->AddTool(ID_LOAD_FILE, BITMAP(open_xpm), + wxNullBitmap, FALSE, + -1, -1, (wxObject *) NULL, + _("Open existing Layer")); + +#if 0 + m_HToolBar->AddTool(ID_SAVE_PROJECT, BITMAP(save_button), + wxNullBitmap, FALSE, + -1, -1, (wxObject *) NULL, + _("Save World")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_SHEET_SET, BITMAP(sheetset_xpm), + wxNullBitmap, + FALSE, + -1, -1, (wxObject *) NULL, + _("page settings (size, texts)")); + +#endif + + m_HToolBar->AddSeparator(); + +#if 0 + m_HToolBar->AddTool(wxID_CUT, BITMAP(cut_button), + wxNullBitmap, + FALSE, + -1, -1, (wxObject *) NULL, + _("Cut selected item")); + + m_HToolBar->AddTool(wxID_COPY, BITMAP(copy_button), + wxNullBitmap, FALSE, + -1, -1, (wxObject *) NULL, + _("Copy selected item")); + + m_HToolBar->AddTool(wxID_PASTE, BITMAP(paste_xpm), + wxNullBitmap, + FALSE, + -1, -1, (wxObject *) NULL, + _("Paste")); +#endif + + m_HToolBar->AddTool(ID_UNDO_BUTT, BITMAP(undelete_xpm), + wxNullBitmap, + FALSE, + -1, -1, (wxObject *) NULL, + _("Undelete")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_GEN_PRINT, BITMAP(print_button), + wxNullBitmap, + FALSE, + -1, -1, (wxObject *) NULL, + _("Print World")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_ZOOM_PLUS_BUTT, BITMAP(zoom_in_xpm), + wxNullBitmap, + FALSE, + -1, -1, (wxObject *) NULL, + _("zoom + (F1)")); + + m_HToolBar->AddTool(ID_ZOOM_MOINS_BUTT, BITMAP(zoom_out_xpm), + wxNullBitmap, + FALSE, + -1, -1, (wxObject *) NULL, + _("zoom - (F2)")); + + m_HToolBar->AddTool(ID_ZOOM_REDRAW_BUTT, BITMAP(repaint_xpm), + wxNullBitmap, + FALSE, + -1, -1, (wxObject *) NULL, + _("redraw (F3)")); + + m_HToolBar->AddTool(ID_ZOOM_PAGE_BUTT, BITMAP(zoom_optimal_xpm), + wxNullBitmap, + FALSE, + -1, -1, (wxObject *) NULL, + _("auto zoom")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_FIND_ITEMS, BITMAP(find_xpm), + wxNullBitmap, + FALSE, + -1, -1, (wxObject *) NULL, + _("Find D Codes")); + +wxArrayString choices; + m_HToolBar->AddSeparator(); + for ( ii = 0; ii < 32 ; ii ++ ) + { + wxString msg; + msg = _("Layer "); msg << ii+1; + choices.Add(msg); + } + m_SelLayerBox = new WinEDAChoiceBox(m_HToolBar, ID_TOOLBARH_PCB_SELECT_LAYER, + wxDefaultPosition, wxSize(150, -1), choices); + m_SelLayerBox->SetSelection( GetScreen()->m_Active_Layer ); + m_HToolBar->AddControl(m_SelLayerBox); + + m_HToolBar->AddSeparator(); + choices.Clear(); + choices.Add( _("No tool")); + for ( ii = 0; ii < MAX_TOOLS ; ii ++ ) + { + wxString msg; + msg = _("Tool "); msg << ii + FIRST_DCODE; + choices.Add(msg); + } + m_SelLayerTool = new WinEDAChoiceBox(m_HToolBar, ID_TOOLBARH_GERBER_SELECT_TOOL, + wxDefaultPosition, wxSize(150, -1), choices); + m_HToolBar->AddControl(m_SelLayerTool); + + + // after adding the buttons to the toolbar, must call Realize() to reflect + // the changes + m_HToolBar->Realize(); + SetToolbars(); +} + + +/**********************************************/ +void WinEDA_GerberFrame::ReCreateVToolbar(void) +/**********************************************/ +{ + if( m_VToolBar ) return; + + m_VToolBar = new WinEDA_Toolbar(TOOLBAR_TOOL, this, ID_V_TOOLBAR, FALSE); + + // Set up toolbar + m_VToolBar->AddTool(ID_NO_SELECT_BUTT, + BITMAP(cursor_xpm), + wxNullBitmap, TRUE, + -1, -1, (wxObject *) NULL ); + m_VToolBar->ToggleTool(ID_NO_SELECT_BUTT,TRUE); + +#if 0 + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_COMPONENT_BUTT, + BITMAP(component_button), + wxNullBitmap, TRUE, + -1, -1, (wxObject *) NULL, + _("Add Flashes")); + + m_VToolBar->AddTool(ID_BUS_BUTT, + BITMAP(bus_button), + wxNullBitmap, TRUE, + -1, -1, (wxObject *) NULL, + _("Add Lines")); + + m_VToolBar->AddTool(ID_JUNCTION_BUTT, + BITMAP(junction_xpm), + wxNullBitmap, TRUE, + -1, -1, (wxObject *) NULL, + _("Add Mires")); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_TEXT_COMMENT_BUTT, + BITMAP(tool_text_xpm), + wxNullBitmap, TRUE, + -1, -1, (wxObject *) NULL, + _("Add Text")); + +#endif + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_PCB_DELETE_ITEM_BUTT, + BITMAP(delete_body_xpm), + wxNullBitmap, TRUE, + -1, -1, (wxObject *) NULL, + _("Delete items")); + + m_VToolBar->Realize(); + SetToolbars(); +} + + +/************************************************/ +void WinEDA_GerberFrame::ReCreateOptToolbar(void) +/************************************************/ +{ + if ( m_OptionsToolBar ) return; + + // creation du tool bar options + m_OptionsToolBar = new WinEDA_Toolbar(TOOLBAR_OPTION, this, ID_OPT_TOOLBAR, FALSE); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_GRID, BITMAP(grid_xpm), + wxNullBitmap, + TRUE, + -1, -1, (wxObject *) NULL, + _("Display Grid OFF")); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_POLAR_COORD, BITMAP(polar_coord_xpm), + wxNullBitmap, + TRUE, + -1, -1, (wxObject *) NULL, + _("Display Polar Coord ON")); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString, + BITMAP(unit_inch_xpm), + _("Units = Inch"), wxITEM_CHECK ); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString, + BITMAP(unit_mm_xpm), + _("Units = mm"), wxITEM_CHECK ); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_CURSOR, BITMAP(cursor_shape_xpm), + wxNullBitmap, + TRUE, + -1, -1, (wxObject *) NULL, + _("Change Cursor Shape")); + + m_OptionsToolBar->AddSeparator(); + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_PADS_SKETCH, + BITMAP(pad_sketch_xpm), + wxNullBitmap, + TRUE, + -1, -1, (wxObject *) NULL, + _("Show Spots Sketch")); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, + BITMAP(showtrack_xpm), + wxNullBitmap, + TRUE, + -1, -1, (wxObject *) NULL, + _("Show Lines Sketch")); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_DCODES, + BITMAP(show_dcodenumber_xpm), + wxNullBitmap, + TRUE, + -1, -1, (wxObject *) NULL, + _("Show dcode number")); + + m_OptionsToolBar->Realize(); + + SetToolbars(); +} + + + + diff --git a/gerbview/tracepcb.cpp b/gerbview/tracepcb.cpp new file mode 100644 index 0000000000..d24cd24e0e --- /dev/null +++ b/gerbview/tracepcb.cpp @@ -0,0 +1,143 @@ + /*****************************************/ + /* Routines generales d'affichage du PCB */ + /*****************************************/ + + /* fichier TRACEPCB.CPP */ +/* + Routines d'affichage grille, Boite de coordonnees, Curseurs, marqueurs ... +*/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" + +#include "protos.h" + + +/* Externes */ + +/* Variables Locales */ + + +/**********************************************************************************/ +void WinEDA_DrawPanel::PrintPage(wxDC *DC, bool Print_Sheet_Ref, int printmasklayer) +/**********************************************************************************/ +/* routine de trace du pcb, avec selection des couches */ +{ +DISPLAY_OPTIONS save_opt; + + save_opt = DisplayOpt; + if( printmasklayer & ALL_CU_LAYERS ) DisplayOpt.DisplayPadFill = FILLED; + else DisplayOpt.DisplayPadFill = SKETCH; + DisplayOpt.DisplayPadNum = 0; + DisplayOpt.DisplayPadNoConn = 0; + DisplayOpt.DisplayPadIsol = 0; + DisplayOpt.DisplayModEdge = FILLED; + DisplayOpt.DisplayModText = FILLED; + DisplayOpt.DisplayPcbTrackFill = FILLED; + DisplayOpt.DisplayTrackIsol = 0; + DisplayOpt.DisplayDrawItems = FILLED; + DisplayOpt.DisplayZones = 1; + + ((WinEDA_GerberFrame*)m_Parent)->Trace_Gerber(DC, GR_COPY); + + if ( Print_Sheet_Ref ) + m_Parent->TraceWorkSheet(DC, GetScreen()); + + DisplayOpt = save_opt; +} + +/*******************************************************************/ +void WinEDA_GerberFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg) +/*******************************************************************/ +/* Trace le PCB, et les elements complementaires ( axes, grille .. ) +*/ +{ +PCB_SCREEN * screen = GetScreen(); + + if ( ! m_Pcb ) return; + ActiveScreen = screen; + GRSetDrawMode(DC, GR_COPY); + + if ( EraseBg ) DrawPanel->EraseScreen(DC); + + DrawPanel->DrawBackGround(DC); + + Trace_Gerber(DC, GR_OR); + TraceWorkSheet(DC, screen); + Affiche_Status_Box(); + + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + + DrawPanel->Trace_Curseur(DC); +} + +/********************************************************/ +void WinEDA_GerberFrame::Trace_Gerber(wxDC * DC, int mode) +/********************************************************/ +/* Trace l'ensemble des elements du PCB sur l'ecran actif*/ +{ + + if ( ! m_Pcb ) return; + + // Draw tracks and flashes + Trace_Pistes(DrawPanel, DC, m_Pcb, mode); + + // Draw filled polygons + #define NBMAX 2000 + TRACK * track; + int nbpoints = 0; + int nbpointsmax = NBMAX; + int * coord = (int*) malloc(nbpointsmax * sizeof (int) * 2); + int * ptcoord = coord; + track = m_Pcb->m_Zone; + for ( ; track != NULL ; track = track->Next() ) + { + if ( track->m_NetCode == 0 ) // StartPoint + { + if ( nbpoints ) + { + int Color = g_DesignSettings.m_LayerColor[track->m_Layer]; + GRClosedPoly(&DrawPanel->m_ClipBox, DC, nbpoints, coord, + 1, Color, Color); + } + nbpoints = 2; + ptcoord = coord; + * ptcoord = track->m_Start.x; ptcoord++; + * ptcoord = track->m_Start.y; ptcoord++; + * ptcoord = track->m_End.x; ptcoord++; + * ptcoord = track->m_End.y; ptcoord++; + } + else + { + if ( nbpoints >= nbpointsmax ) + { + nbpointsmax *= 2; + coord = (int*) realloc(coord, nbpointsmax * sizeof (int) * 2); + ptcoord = coord + nbpointsmax; + } + nbpoints++; + * ptcoord = track->m_End.x; ptcoord++; + * ptcoord = track->m_End.y; ptcoord++; + } + if ( track->Next() == NULL ) // Last point + { + int Color = g_DesignSettings.m_LayerColor[track->m_Layer]; + GRClosedPoly(&DrawPanel->m_ClipBox, DC, nbpoints, coord, + 1, Color, Color); + } + } + + free(coord); + + if ( DisplayOpt.DisplayPadNum ) + Affiche_DCodes_Pistes(DrawPanel, DC, m_Pcb, GR_COPY); + + GetScreen()->ClrRefreshReq(); +} + + + diff --git a/gerbview/trpiste.cpp b/gerbview/trpiste.cpp new file mode 100644 index 0000000000..940856979e --- /dev/null +++ b/gerbview/trpiste.cpp @@ -0,0 +1,349 @@ + /*****************************************************************/ + /* Routines de tracage des pistes ( Toutes, 1 piste, 1 segment ) */ + /*****************************************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" +#include "pcbplot.h" +#include "trigo.h" + +#include "protos.h" + +/* Definition des cas ou l'on force l'affichage en SKETCH (membre .flags) */ +#define FORCE_SKETCH (DRAG | EDIT ) + +/* variables locales : */ + +/********************************************************************************/ +void Trace_Pistes(WinEDA_DrawPanel * panel, wxDC * DC, BOARD * Pcb, int drawmode) +/********************************************************************************/ +/* Routine de trace des pistes et zones */ +{ +TRACK * pt_piste; +int layer = ((PCB_SCREEN*)panel->GetScreen())->m_Active_Layer; +GERBER_Descr * gerber_layer = g_GERBER_Descr_List[layer]; +int dcode_hightlight = 0; + + if ( gerber_layer ) + dcode_hightlight = gerber_layer->m_Selected_Tool; + + pt_piste = Pcb->m_Track; + for ( ; pt_piste != NULL ; pt_piste = (TRACK*) pt_piste->Pnext ) + { + if ( (dcode_hightlight == pt_piste->m_NetCode) && + (pt_piste->m_Layer == layer) ) + Trace_Segment(panel, DC, pt_piste, drawmode | GR_SURBRILL); + else Trace_Segment(panel, DC, pt_piste, drawmode ); + } +} + + +/***********************************************************************************/ +void Trace_Segment(WinEDA_DrawPanel * panel, wxDC * DC, TRACK* track, int draw_mode) +/***********************************************************************************/ +/* routine de trace de 1 segment de piste. +Parametres : + pt_piste = adresse de la description de la piste en buflib + draw_mode = mode ( GR_XOR, GR_OR..) +*/ +{ +int l_piste; +int color; +int zoom; +int rayon; +int fillopt; +static bool show_err; + + color = g_DesignSettings.m_LayerColor[track->m_Layer]; + if(color & ITEM_NOT_SHOW ) return ; + + zoom = panel->GetZoom(); + + GRSetDrawMode(DC, draw_mode); + if( draw_mode & GR_SURBRILL) + { + if( draw_mode & GR_AND) color &= ~HIGHT_LIGHT_FLAG; + else color |= HIGHT_LIGHT_FLAG; + } + if ( color & HIGHT_LIGHT_FLAG) + color = ColorRefs[color & MASKCOLOR].m_LightColor; + + rayon = l_piste = track->m_Width >> 1; + + fillopt = DisplayOpt.DisplayPcbTrackFill ? FILLED : SKETCH; + + switch (track->m_Shape) + { + case S_CIRCLE: + rayon = (int)hypot((double)(track->m_End.x-track->m_Start.x), + (double)(track->m_End.y-track->m_Start.y) ); + if ( (l_piste/zoom) < L_MIN_DESSIN) + { + GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + rayon , color) ; + } + + if( fillopt == SKETCH) + { + GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + rayon-l_piste, color); + GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + rayon+l_piste, color); + } + else + { + GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + rayon, track->m_Width,color); + } + break; + + case S_ARC: + { + if( fillopt == SKETCH) + { + GRArc1(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, + track->m_Param, track->m_Sous_Netcode, color); + } + else + { + GRArc1(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, + track->m_Param,track->m_Sous_Netcode, + track->m_Width, color); + } + } + break; + + case S_SPOT_CIRCLE: + fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; + if ( (rayon/zoom) < L_MIN_DESSIN) + { + GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + rayon , color) ; + } + + else if( fillopt == SKETCH ) + { + GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + rayon, color); + } + else + { + GRFilledCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + rayon, color, color); + } + break; + + case S_SPOT_RECT: + case S_RECT: + fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; + if ( (l_piste/zoom) < L_MIN_DESSIN) + { + GRLine(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, color); + } + else if( fillopt == SKETCH ) + { + GRRect(&panel->m_ClipBox, DC, + track->m_Start.x - l_piste, + track->m_Start.y - l_piste, + track->m_End.x + l_piste, + track->m_End.y + l_piste, + color) ; + } + else + { + GRFilledRect(&panel->m_ClipBox, DC, + track->m_Start.x - l_piste, + track->m_Start.y - l_piste, + track->m_End.x + l_piste, + track->m_End.y + l_piste, + color, color) ; + } + break; + + case S_SPOT_OVALE: + fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; + case S_SEGMENT: + if ( (l_piste/zoom) < L_MIN_DESSIN) + { + GRLine(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, color); + break; + } + + if( fillopt == SKETCH ) + { + GRCSegm(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, + track->m_Width, color) ; + } + else + { + GRFillCSegm(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, + track->m_Width, color) ; + } + break; + + default: + if ( ! show_err ) + { + DisplayError(panel, wxT("Trace_Segment() type error")); + show_err = TRUE; + } + break; + } +} + +/**************************************************************************/ +void Trace_DrawSegmentPcb(WinEDA_DrawPanel * panel, wxDC * DC, + DRAWSEGMENT * PtDrawSegment, int draw_mode) +/**************************************************************************/ +/* Affichage d'un segment type drawing PCB: + Entree : ox, oy = offset de trace + draw_mode = mode de trace ( GR_OR, GR_XOR, GrAND) + Les contours sont de differents type: + segment + cercle + arc +*/ +{ +int ux0, uy0, dx, dy; +int l_piste; +int color, mode; +int zoom = panel->GetZoom(); +int rayon; + + color = g_DesignSettings.m_LayerColor[PtDrawSegment->m_Layer]; + if(color & ITEM_NOT_SHOW ) return ; + + GRSetDrawMode(DC, draw_mode); + l_piste = PtDrawSegment->m_Width >> 1; /* l_piste = demi largeur piste */ + + /* coord de depart */ + ux0 = PtDrawSegment->m_Start.x; + uy0 = PtDrawSegment->m_Start.y; + /* coord d'arrivee */ + dx = PtDrawSegment->m_End.x; + dy = PtDrawSegment->m_End.y; + + + mode = DisplayOpt.DisplayPcbTrackFill ? FILLED : SKETCH; + if(PtDrawSegment->m_Flags & FORCE_SKETCH) mode = SKETCH; + if ( l_piste < (L_MIN_DESSIN * zoom) ) mode = FILAIRE; + + switch (PtDrawSegment->m_Shape) + { + case S_CIRCLE: + rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) ); + if ( mode == FILAIRE) + { + GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon, color) ; + } + else if( mode == SKETCH) + { + GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon-l_piste, color); + GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon+l_piste, color); + } + else + { + GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon, PtDrawSegment->m_Width,color); + } + break; + + case S_ARC: + { + int StAngle, EndAngle; + rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) ); + StAngle = (int) ArcTangente(dy-uy0, dx-ux0); + EndAngle = StAngle + PtDrawSegment->m_Angle; + if ( mode == FILAIRE) + GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon, color); + else if( mode == SKETCH) + { + GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, + rayon - l_piste, color); + GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, + rayon + l_piste, color); + } + else + { + GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, + rayon, PtDrawSegment->m_Width,color); + } + } + break; + + + default: + if( mode == FILAIRE) + GRLine(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, color) ; + else if( mode == SKETCH) + { + GRCSegm(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, + PtDrawSegment->m_Width, color) ; + } + else + { + GRFillCSegm(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, + PtDrawSegment->m_Width, color) ; + } + break; + } +} + + +/*****************************************************************************************/ +void Affiche_DCodes_Pistes(WinEDA_DrawPanel * panel, wxDC * DC, BOARD * Pcb, int drawmode) +/*****************************************************************************************/ +{ +TRACK * track; +wxPoint pos; +int width, orient; +wxString Line; + + GRSetDrawMode(DC, drawmode); + track = Pcb->m_Track; + for ( ; track != NULL ; track = (TRACK*) track->Pnext ) + { + if ( (track->m_Shape == S_ARC) || + (track->m_Shape == S_CIRCLE) || + (track->m_Shape == S_ARC_RECT) ) + { + pos.x = track->m_Start.x; + pos.y = track->m_Start.y; + } + + else + { + pos.x = (track->m_Start.x + track->m_End.x) / 2; + pos.y = (track->m_Start.y + track->m_End.y) / 2; + } + Line.Printf( wxT("D%d"), track->m_NetCode); + width = track->m_Width; + orient = TEXT_ORIENT_HORIZ; + if ( track->m_Shape >= S_SPOT_CIRCLE) // forme flash + { + width /= 3; + } + + else // lines + { + int dx, dy; + dx = track->m_Start.x - track->m_End.x; + dy = track->m_Start.y - track->m_End.y; + if ( abs(dx) < abs(dy) ) orient = TEXT_ORIENT_VERT; + width /= 2; + } + + DrawGraphicText(panel, DC, + pos, g_DCodesColor, Line, + orient, wxSize(width, width), + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + } +} + diff --git a/gerbview/undelete.cpp b/gerbview/undelete.cpp new file mode 100644 index 0000000000..389df39242 --- /dev/null +++ b/gerbview/undelete.cpp @@ -0,0 +1,108 @@ + /********************************************************/ + /* Effacements : Routines de sauvegarde et d'effacement */ + /********************************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "gerbview.h" + +#include "protos.h" + +/* Routines externes : */ + +/* Routines Locales */ + +/***********************************************/ +void WinEDA_GerberFrame::UnDeleteItem(wxDC * DC) +/***********************************************/ +/* Restitution d'un element (MODULE ou TRACK ) Efface +*/ +{ +EDA_BaseStruct * PtStruct, *PtNext; +TRACK * pt_track; +int net_code; + + if( ! g_UnDeleteStackPtr ) return; + + g_UnDeleteStackPtr --; + PtStruct = g_UnDeleteStack[g_UnDeleteStackPtr]; + if ( PtStruct == NULL ) return; // Ne devrait pas se produire + + switch(PtStruct->m_StructType) + { + case TYPEVIA: + case TYPETRACK: + for( ; PtStruct != NULL; PtStruct = PtNext) + { + PtNext = PtStruct->Pnext; + PtStruct->SetState(DELETED,OFF); /* Effacement du bit DELETED */ + Trace_Segment(DrawPanel, DC, (TRACK*) PtStruct, GR_OR); + } + + PtStruct = g_UnDeleteStack[g_UnDeleteStackPtr]; + net_code = ((TRACK*)PtStruct)->m_NetCode; + pt_track = ( (TRACK*) PtStruct)->GetBestInsertPoint(m_Pcb); + ((TRACK*)PtStruct)->Insert(m_Pcb, pt_track); + + g_UnDeleteStack[g_UnDeleteStackPtr] = NULL; + break; + + default: + DisplayError(this, wxT("Undelete struct: type Struct inattendu")); + break; + } +} + + +/********************************************************************/ +EDA_BaseStruct * SaveItemEfface(EDA_BaseStruct * PtItem, int nbitems) +/********************************************************************/ +/* Sauvegarde d'un element aux fins de restitution par Undelete + Supporte actuellement : Module et segments de piste +*/ +{ +EDA_BaseStruct * NextS, * PtStruct = PtItem; +int ii; + if( (PtItem == NULL) || (nbitems == 0) ) return NULL; + + if (g_UnDeleteStackPtr >= UNDELETE_STACK_SIZE ) + { + /* Delete last deleted item, and shift stack. */ + DeleteStructure(g_UnDeleteStack[0]); + for (ii = 0; ii < (g_UnDeleteStackPtr-1); ii++) + { + g_UnDeleteStack[ii] = g_UnDeleteStack[ii + 1]; + } + g_UnDeleteStackPtr--;; + } + g_UnDeleteStack[g_UnDeleteStackPtr++] = PtItem; + + switch ( PtStruct->m_StructType ) + { + case TYPEVIA: + case TYPETRACK: + { + EDA_BaseStruct * Back = NULL; + g_UnDeleteStack[g_UnDeleteStackPtr-1] = PtStruct; + + for ( ; nbitems > 0; nbitems--, PtStruct = NextS) + { + NextS = PtStruct->Pnext; + ((TRACK*)PtStruct)->UnLink(); + PtStruct->SetState(DELETED, ON); + if( nbitems <= 1 ) NextS = NULL; /* fin de chaine */ + PtStruct->Pnext = NextS; + PtStruct->Pback = Back; Back = PtStruct; + if(NextS == NULL) break; + } + } + break; + + default: break; + } + + return(g_UnDeleteStack[g_UnDeleteStackPtr-1]); +} + + diff --git a/how-to-build-kicad.txt b/how-to-build-kicad.txt new file mode 100644 index 0000000000..2b76964a0b --- /dev/null +++ b/how-to-build-kicad.txt @@ -0,0 +1,125 @@ +How to build kicad: + +kicad do not use configure (not yet...) +it is compiled with make. + +kicad needs wxWidgets (the multi platform G.U.I.) + +unzip sources in a working directory. +This will create the directory "kicad-dev". + +First you must install wxWidgets (see www.wxWidgets.org) +See mybuild_wxWidgets_linux.txt and mybuild_wxWidgets_windows.txt +(in kicad-dev ) which are scripts running configure for both systems. + +Linux compilation: +You must have: +wxWidgets ( I suggest you install wxWidgets in /usr/local). +(you can copy mybuild_wxWidgets_linux.txt in wxWidgets directory an run +sh mybuild_wxWidgets_linux.txt +and make and make install) + +Mesa: pcbnew and cvpcv need openGL or mesa. +(you must install mesa devel if libGL et libGLU are not found). +GTK 2 (install development libraries). + +Because old version of Mesa has problem under a recent linux distrib (mandarke 10.1), +I am using Mesa version 6.2.1, statically compiled, installed in /usr/local +Mesa installation: +Get MesaLib-6.2.1.tar.gz from http://www.mesa3d.org/ +in /usr/local : tar zxvf MesaLib-6.2.1.tar.gz +in /usr/local/Mesa-6.2.1 : +make linux-x86-static +make install ( libGL.a et libGLU.a are copied in /usr/local/lib, and header in /usr/local/include) + +kicad compilation: +in kicad-dev: + Have a look to libs.linux (you can edit this file if you have problems) + Currently libs.linux uses wxWidgets 2.7.1 build with script "mybuild_wxWidgets_linux.txt" + run make -f makefile.gtk + +Windows compilation: + +kicad is build with mingw and msys. +Currently libs.linux uses wxWidgets 2.8.1 build with script "mybuild_wxWidgets_windows.txt" + +install mingw and msys ( see mingw.org ) +(opengl libs are included in mingw or windows) + +Under msys: + (Warning: make.exe utility is sometime renamed mingw32-make.exe in install process + of msys.) + +Build wxWidgets (currently version 2.8.1) + you can copy mybuild_wxWidgets_windows.txt in wxWidgets directory an run + ./mybuild_wxWidgets_windows.txt and make + + In include/wx/msw/setup.h, check (and edit if needed) the defines : + #define wxUSE_GLCANVAS 1 + #define WXWIN_COMPATIBILITY_2_4 0 + #define wxUSE_MOUSEWHEEL 1 // Include mouse wheel support + #define wxUSE_HOTKEY 0 // Hotkey support (currently Windows only) + + +Exit msys. +Set environment variable WXWIN ( something as wxwin=/d/wxWidgets-2.8.1 +for a wxWidget installed in d:\wxWidgets-2.8.1) + +Have a look to libs.win (Currently this file handle wxWidgets 2.8.1) + +Under msys: + in kicad-dev: + run make -f makefile.g95 + +************************************************************************************* +Patch wxWidgets +************************************************************************************* +************************************************************************************* +wxGTK version: +************************************************************************************* +Patch for printing wide traces that were showing missing rounded end caps: +wxGTK-2.8.1/src/generic/dcpsg.cpp +line 1634 + PsPrint( "%%EndProlog\n" ); + +must be + PsPrint( "%%EndProlog\n" ); + PsPrint("%%BeginSetup\n"); + PsPrint( "1 setlinecap\n" ); + PsPrint("%%EndSetup\n"); + + +patch for Arcs drawings (NOT NEEDED for wxWidgets 2.7.1, needed for versions prior to 2.7.1) +wxGTK-2.x.y/src/gtk/dcclient.cpp +in function WindowDC::DoDrawArc +line 572 for wxWidgets 2.7.0-1: + if (m_pen.GetStyle() != wxTRANSPARENT) + { + gdk_draw_arc( m_window, m_penGC, FALSE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); + + gdk_draw_line( m_window, m_penGC, xx1, yy1, xxc, yyc ); + gdk_draw_line( m_window, m_penGC, xxc, yyc, xx2, yy2 ); + } +must be + if (m_pen.GetStyle() != wxTRANSPARENT) + { + gdk_draw_arc( m_window, m_penGC, FALSE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); + + if (m_brush.GetStyle() != wxTRANSPARENT) + { + gdk_draw_line( m_window, m_penGC, xx1, yy1, xxc, yyc ); + gdk_draw_line( m_window, m_penGC, xxc, yyc, xx2, yy2 ); + } + } + + +************************************************************************************* +wxMSW version: for wxWMSW 2.8.1 only +************************************************************************************* + +wxMSW.2.8.1/src/msw/menu.cpp +line 410 + if ( !pItem->IsOwnerDrawn() ) +must be + if ( !pItem->IsOwnerDrawn() && !pItem->IsSeparator() ) + diff --git a/include/appl_wxstruct.h b/include/appl_wxstruct.h new file mode 100644 index 0000000000..996af6389d --- /dev/null +++ b/include/appl_wxstruct.h @@ -0,0 +1,92 @@ + /************************************************************/ + /* appl_wxstruct.h: */ + /* descriptions des principales classes derivees utilisees: */ + /* Class "EDA_Appl: classe de l'application generale */ + /************************************************************/ + +/* Ce fichier doit etre inclus dans "wxstruct.h" +*/ + +#ifndef APPL_WXSTRUCT_H +#define APPL_WXSTRUCT_H + +#ifndef eda_global +#define eda_global extern +#endif + + + /**********************************************/ + /* Class representing the entire Application */ + /**********************************************/ +eda_global WinEDA_App * EDA_Appl; /* application representant le programme */ + + +class WinEDA_App: public wxApp +{ +public: + wxString m_Project; + wxSingleInstanceChecker * m_Checker; + WinEDA_MainFrame * m_MainFrame; + WinEDA_PcbFrame * m_PcbFrame; + WinEDA_ModuleEditFrame * m_ModuleEditFrame; + WinEDA_GerberFrame * m_GerberFrame; + WinEDA_SchematicFrame * SchematicFrame; // Edition des Schemas + WinEDA_LibeditFrame * LibeditFrame; // Edition des composants + WinEDA_ViewlibFrame * ViewlibFrame; // Visualisation des composants + WinEDA_CvpcbFrame * m_CvpcbFrame; + + wxPoint m_HelpPos; + wxSize m_HelpSize; + wxHtmlHelpController * m_HtmlCtrl; + wxConfig * m_EDA_Config; // Config courante (tailles et positions fenetres ...*/ + wxConfig * m_EDA_CommonConfig; // common setup (language ...) */ + wxString m_HelpFileName; + wxString m_CurrentOptionFile; // dernier fichier .cnf utilisé + wxString m_CurrentOptionFileDateAndTime; + + wxString m_BinDir; /* Chemin ou reside l'executable + (utilisé si KICAD non défini)*/ + wxArrayString m_LastProject; /* liste des derniers projets chargés */ + unsigned int m_LastProjectMaxCount; /* Max histhory file length */ + wxString m_KicadEnv; /* Chemin de kicad défini dans la variable + d'environnement KICAD, + typiquement /usr/local/kicad ou c:\kicad */ + bool m_Env_Defined; // TRUE si variable d'environnement KICAD definie + + wxLocale * m_Locale; // Gestion de la localisation + int m_LanguageId; // indicateur de choix du langage ( 0 = defaut) + wxMenu * m_Language_Menu; // List menu for languages + wxString m_PdfBrowser; // Name of the selected browser, for browsing pdf datasheets + bool m_PdfBrowserIsDefault; // True if the pdf browser is the default (m_PdfBrowser not used) + +public: + WinEDA_App(void); + ~WinEDA_App(void); + bool OnInit(void); + + bool SetBinDir(void); + void InitEDA_Appl(const wxString & name); + bool SetLanguage(bool first_time = FALSE); + wxMenu * SetLanguageList(wxMenu * MasterMenu); + void SetLanguageIdentifier(int menu_id); + void InitOnLineHelp(void); + + // Sauvegarde de configurations et options: + void GetSettings(void); + void SaveSettings(void); + void SetLastProject(const wxString & FullFileName); + void WriteProjectConfig(const wxString & local_config_filename, + const wxString & GroupName, PARAM_CFG_BASE ** List); + + bool ReadProjectConfig(const wxString & local_config_filename, + const wxString & GroupName, PARAM_CFG_BASE ** List, + bool Load_Only_if_New); + + void ReadPdfBrowserInfos(void); + void WritePdfBrowserInfos(void); + +}; + + +#endif /* APPL_WXSTRUCT_H */ + diff --git a/include/base_struct.h b/include/base_struct.h new file mode 100644 index 0000000000..84f19d4854 --- /dev/null +++ b/include/base_struct.h @@ -0,0 +1,258 @@ +/*********************************************************************/ +/* base_struct.h : Basic classes for most kicad item descriptions */ +/*********************************************************************/ + +#ifndef BASE_STRUCT_H +#define BASE_STRUCT_H + + +/* Id for class identification, at run time */ +enum DrawStructureType { + TYPE_NOT_INIT = 0, + TYPEPCB, + // Items in pcb + PCB_EQUIPOT_STRUCT_TYPE, + TYPEMODULE, + TYPEPAD, + TYPEDRAWSEGMENT, + TYPETEXTE, + TYPETEXTEMODULE, + TYPEEDGEMODULE, + TYPETRACK, + TYPEZONE, + TYPEVIA, + TYPEMARQUEUR, + TYPECOTATION, + TYPEMIRE, + TYPESCREEN, + TYPEBLOCK, + TYPEEDGEZONE, + // Draw Items in schematic + DRAW_POLYLINE_STRUCT_TYPE, + DRAW_JUNCTION_STRUCT_TYPE, + DRAW_TEXT_STRUCT_TYPE, + DRAW_LABEL_STRUCT_TYPE, + DRAW_GLOBAL_LABEL_STRUCT_TYPE, + DRAW_LIB_ITEM_STRUCT_TYPE, + DRAW_PICK_ITEM_STRUCT_TYPE, + DRAW_SEGMENT_STRUCT_TYPE, + DRAW_BUSENTRY_STRUCT_TYPE, + DRAW_SHEET_STRUCT_TYPE, + DRAW_SHEETLABEL_STRUCT_TYPE, + DRAW_MARKER_STRUCT_TYPE, + DRAW_NOCONNECT_STRUCT_TYPE, + DRAW_PART_TEXT_STRUCT_TYPE, + // General + SCREEN_STRUCT_TYPE, + BLOCK_LOCATE_STRUCT_TYPE, + // Draw Items in library component + LIBCOMPONENT_STRUCT_TYPE, + COMPONENT_ARC_DRAW_TYPE, + COMPONENT_CIRCLE_DRAW_TYPE, + COMPONENT_GRAPHIC_TEXT_DRAW_TYPE, + COMPONENT_RECT_DRAW_TYPE, + COMPONENT_POLYLINE_DRAW_TYPE, + COMPONENT_LINE_DRAW_TYPE, + COMPONENT_PIN_DRAW_TYPE, + COMPONENT_FIELD_DRAW_TYPE, + // End value + MAX_STRUCT_TYPE_ID +}; + + +/********************************************************************/ +/* Classes de base: servent a deriver les classes reellement utiles */ +/********************************************************************/ + +class EDA_BaseStruct /* Basic class, not directly used */ +{ +public: + int m_StructType; /* Struct ident for run time identification */ + EDA_BaseStruct * Pnext; /* Linked list: Link (next struct) */ + EDA_BaseStruct * Pback; /* Linked list: Link (previous struct) */ + EDA_BaseStruct * m_Parent; /* Linked list: Link (parent struct) */ + EDA_BaseStruct *m_Son; /* Linked list: Link (son struct) */ + EDA_BaseStruct *m_Image; /* Link to an image copy for undelete or abort command */ + int m_Flags; // flags for editions and other + long m_TimeStamp; // Time stamp used for logical links + int m_Selected; /* Used by block commands, and selective editing */ + +private: + int m_Status; + +private: + void InitVars(void); + +public: + + EDA_BaseStruct(EDA_BaseStruct * parent, int idType); + EDA_BaseStruct(int struct_type); + virtual ~EDA_BaseStruct() {}; + EDA_BaseStruct * Next(void) { return Pnext; } + /* Gestion de l'etat (status) de la structure (active, deleted..) */ + int GetState(int type); + void SetState(int type, int state ); + int ReturnStatus(void) const + { + return(m_Status); + } + void SetStatus(int new_status) + { + m_Status = new_status; + } + wxString ReturnClassName(void); + /* addition d'une nouvelle struct a la liste chainée */ + void AddToChain(EDA_BaseStruct * laststruct); + /* fonction de placement */ + virtual void Place(WinEDA_DrawFrame * frame, wxDC * DC); + virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); + +}; + +// Text justify: +// Values -1,0,1 are used in computations, do not change them +typedef enum { + GR_TEXT_HJUSTIFY_LEFT = -1, + GR_TEXT_HJUSTIFY_CENTER = 0, + GR_TEXT_HJUSTIFY_RIGHT = 1 +} GRTextHorizJustifyType; + +typedef enum { + GR_TEXT_VJUSTIFY_TOP = -1, + GR_TEXT_VJUSTIFY_CENTER = 0, + GR_TEXT_VJUSTIFY_BOTTOM = 1 +} GRTextVertJustifyType; + +/* controle des remplissages a l'ecran (Segments textes...)*/ +#define FILAIRE 0 +#define FILLED 1 +#define SKETCH 2 + + +#define DEFAULT_SIZE_TEXT 60 /* Hauteur (en 1/000" par defaut des textes */ + +/* classe de gestion des textes (labels, textes composants ..) + (Non utilisee seule) */ +class EDA_TextStruct +{ +public: + wxString m_Text; /* text! */ + int m_Layer; /* couche d'appartenance */ + wxPoint m_Pos; /* XY position of anchor text. */ + wxSize m_Size; /* XY size of text */ + int m_Width; /* epaisseur du trait */ + int m_Orient; /* Orient in 0.1 degrees */ + int m_Miroir; // Display Normal / mirror + int m_Attributs; /* controle visibilite */ + int m_CharType; /* normal, bold, italic ... */ + int m_HJustify, m_VJustify; /* Justifications Horiz et Vert du texte */ + int m_ZoomLevelDrawable; /* Niveau de zoom acceptable pour affichage normal */ + int * m_TextDrawings; /* pointeur sur la liste des segments de dessin */ + int m_TextDrawingsSize; /* nombre de segments a dessiner */ + + +public: + EDA_TextStruct(const wxString & text = wxEmptyString); + virtual ~EDA_TextStruct(void); + void CreateDrawData(void); + int GetLength(void) { return m_Text.Length(); }; + int Pitch(void); /* retourne le pas entre 2 caracteres */ + void Draw(WinEDA_DrawPanel * panel, wxDC * DC, + const wxPoint & offset, int color, + int draw_mode, int display_mode = FILAIRE, int anchor_color = -1); + /* locate functions */ + int Locate(const wxPoint & posref); + int Len_Size(void); // Return the text lenght in internal units +}; + + + +/* Basic class for build items like lines, which have 1 start point and 1 end point. + Arc and circles can use this class. +*/ +class EDA_BaseLineStruct: public EDA_BaseStruct +{ +public: + int m_Layer; // Layer number + int m_Width; // 0 = line, > 0 = tracks, bus ... + wxPoint m_Start; // Line start point + wxPoint m_End; // Line end point + +public: + EDA_BaseLineStruct(EDA_BaseStruct * StructFather, DrawStructureType idtype); +}; + + + /**************************/ + /* class DrawPickedStruct */ + /**************************/ + +/* Class to hold structures picked by pick events (like block selection) + This class has only one useful member: .m_PickedStruct, used as a link. + It does not describe really an item. + It is used to create a linked list of selected items (in block selection). + Each DrawPickedStruct item has is member: .m_PickedStruct pointing the + real selected item +*/ +class DrawPickedStruct: public EDA_BaseStruct +{ +public: + EDA_BaseStruct *m_PickedStruct; + +public: + DrawPickedStruct(EDA_BaseStruct *pickedstruct = NULL); + ~DrawPickedStruct(void); + void Place(WinEDA_DrawFrame * frame, wxDC * DC) {}; + void DeleteWrapperList(void); + DrawPickedStruct * Next(void) { return (DrawPickedStruct*) Pnext; } +}; + + +/* class to handle component boundary box. + This class is similar to wxRect, but some wxRect functions are very curious, + so I prefer this suitable class +*/ +class EDA_Rect +{ +public: + wxPoint m_Pos; // Rectangle Origin + wxSize m_Size; // Rectangle Size + +public: + EDA_Rect(void) {}; + wxPoint Centre(void) + { + return wxPoint(m_Pos.x + (m_Size.x>>1), m_Pos.y + (m_Size.y>>1) ); + } + + void Normalize(void); // Ensure the height ant width are >= 0 + bool Inside(const wxPoint & point); // Return TRUE if point is in Rect + bool Inside(int x, int y) { return Inside(wxPoint(x,y)); } + wxSize GetSize(void) { return m_Size; } + int GetX(void) { return m_Pos.x;} + int GetY(void) { return m_Pos.y;} + wxPoint GetOrigin(void) { return m_Pos;} + wxPoint GetPosition(void) { return m_Pos;} + wxPoint GetEnd(void) { return wxPoint(GetRight(),GetBottom());} + int GetWidth(void) { return m_Size.x; } + int GetHeight(void) { return m_Size.y; } + int GetRight(void) {return m_Pos.x + m_Size.x; } + int GetBottom(void) {return m_Pos.y + m_Size.y; } + void SetOrigin(const wxPoint & pos) { m_Pos = pos; } + void SetOrigin(int x, int y) { m_Pos.x = x; m_Pos.y = y; } + void SetSize(const wxSize & size) { m_Size = size; } + void SetSize(int w, int h) { m_Size.x = w; m_Size.y = h; } + void Offset(int dx, int dy) { m_Pos.x += dx; m_Pos.y += dy; } + void Offset(const wxPoint & offset) { m_Pos.x += offset.x; m_Pos.y += offset.y; } + void SetX(int val) { m_Pos.x = val; } + void SetY(int val) { m_Pos.y = val; } + void SetWidth(int val) { m_Size.x = val; } + void SetHeight(int val) { m_Size.y = val; } + void SetEnd(const wxPoint & pos) + { + m_Size.x = pos.x - m_Pos.x; m_Size.y = pos.y - m_Pos.y; + } + EDA_Rect& Inflate(wxCoord dx, wxCoord dy); +}; + +#endif /* BASE_STRUCT_H */ diff --git a/include/bitmaps.h b/include/bitmaps.h new file mode 100644 index 0000000000..44a01bfab1 --- /dev/null +++ b/include/bitmaps.h @@ -0,0 +1,180 @@ + /****************************/ + /* Used bitmaps in Kicad */ + /****************************/ + + #include "../bitmaps/Cancel.xpm" + #include "../bitmaps/cancel_tool.xpm" + #include "../bitmaps/Apply.xpm" + + #include "../bitmaps/Fonts.xpm" + + #include "../bitmaps/save.xpm" + #include "../bitmaps/save_as.xpm" + #include "../bitmaps/Save_Project.xpm" + #include "../bitmaps/Save_CmpStuff.xpm" + #include "../bitmaps/Save_NetList.xpm" + #include "../bitmaps/Save_SetUp.xpm" + #include "../bitmaps/Read_SetUp.xpm" + + #include "../bitmaps/Open_Library.xpm" + #include "../bitmaps/New_Library.xpm" + #include "../bitmaps/Save_Library.xpm" + + #include "../bitmaps/Edit.xpm" + #include "../bitmaps/Edit_Text.xpm" + + #include "../bitmaps/plot.xpm" + #include "../bitmaps/plot_PS.xpm" + #include "../bitmaps/plot_HPG.xpm" + + #include "../bitmaps/Add_Circle.xpm" + #include "../bitmaps/Add_Line.xpm" + #include "../bitmaps/Add_Arc.xpm" + #include "../bitmaps/Add_Dashed_Line.xpm" + #include "../bitmaps/Add_Entry.xpm" + #include "../bitmaps/Add_Polygon.xpm" + #include "../bitmaps/Add_Rectangle.xpm" + #include "../bitmaps/Add_Text.xpm" + #include "../bitmaps/Add_Line_Label.xpm" + #include "../bitmaps/Add_GLabel.xpm" + #include "../bitmaps/Add_Junction.xpm" + + #include "../bitmaps/general_deletions.xpm" + #include "../bitmaps/Delete_Text.xpm" + #include "../bitmaps/Delete_Cotation.xpm" + #include "../bitmaps/Delete_Arc.xpm" + #include "../bitmaps/Delete_Circle.xpm" + #include "../bitmaps/Delete_Field.xpm" + #include "../bitmaps/Delete_Line.xpm" + #include "../bitmaps/Delete_Segment.xpm" + #include "../bitmaps/Delete_Polygon.xpm" + #include "../bitmaps/Delete_Rectangle.xpm" + + #include "../bitmaps/Move.xpm" + #include "../bitmaps/Move_Text.xpm" + #include "../bitmaps/Move_Arc.xpm" + #include "../bitmaps/Move_Circle.xpm" + #include "../bitmaps/Move_Field.xpm" + #include "../bitmaps/Move_Line.xpm" + #include "../bitmaps/Move_Polygon.xpm" + #include "../bitmaps/Move_Rectangle.xpm" + + #include "../bitmaps/Options_Text.xpm" + #include "../bitmaps/Options_Arc.xpm" + #include "../bitmaps/Options_Circle.xpm" + #include "../bitmaps/Options_Segment.xpm" + #include "../bitmaps/Options_Rectangle.xpm" + #include "../bitmaps/Display_Options.xpm" + + #include "../bitmaps/Mirror_V.xpm" + #include "../bitmaps/Mirror_H.xpm" + #include "../bitmaps/Orient.xpm" + #include "../bitmaps/Rotate+.xpm" + #include "../bitmaps/Rotate-.xpm" + #include "../bitmaps/Rotate_Field.xpm" + #include "../bitmaps/Exit.xpm" + #include "../bitmaps/Datasheet.xpm" + #include "../bitmaps/CopyBlock.xpm" + #include "../bitmaps/new.xpm" + #include "../bitmaps/open.xpm" + #include "../bitmaps/polar.xpm" + #include "../bitmaps/copy.xpm" + #include "../bitmaps/cut.xpm" + #include "../bitmaps/paste.xpm" + #include "../bitmaps/print.xpm" + #include "../bitmaps/find.xpm" + #include "../bitmaps/Cursor_Shape.xpm" + #include "../bitmaps/Add_Component.xpm" + #include "../bitmaps/noconn.xpm" + + #include "../bitmaps/zoom.xpm" + #include "../bitmaps/Zoom_Center.xpm" + #include "../bitmaps/Zoom_Out.xpm" + #include "../bitmaps/Zoom_In.xpm" + #include "../bitmaps/Zoom_Optimal.xpm" + #include "../bitmaps/Zoom_Select.xpm" + #include "../bitmaps/Zoom_Selected.xpm" + #include "../bitmaps/Repaint.xpm" + + #include "../bitmaps/left.xpm" + #include "../bitmaps/right.xpm" + #include "../bitmaps/up.xpm" + #include "../bitmaps/down.xpm" + + #include "../bitmaps/File_FootPrint.xpm" + + #include "../bitmaps/Options_Pad.xpm" + #include "../bitmaps/Options_New_Pad.xpm" + + #include "../bitmaps/sheetset.xpm" + #include "../bitmaps/library.xpm" + #include "../bitmaps/dashline.xpm" + #include "../bitmaps/annotate.xpm" + #include "../bitmaps/netlist.xpm" + #include "../bitmaps/erc.xpm" + #include "../bitmaps/tools.xpm" + #include "../bitmaps/libview.xpm" + #include "../bitmaps/libedprt.xpm" + #include "../bitmaps/export.xpm" + #include "../bitmaps/import.xpm" + #include "../bitmaps/delete.xpm" + #include "../bitmaps/schematic.xpm" + #include "../bitmaps/pin.xpm" + #include "../bitmaps/Morgan1.xpm" + #include "../bitmaps/Morgan2.xpm" + #include "../bitmaps/anchor.xpm" + #include "../bitmaps/del_body.xpm" + #include "../bitmaps/libsavem.xpm" + #include "../bitmaps/label.xpm" + #include "../bitmaps/undelete.xpm" + #include "../bitmaps/undo.xpm" + #include "../bitmaps/redo.xpm" + #include "../bitmaps/eeschema.xpm" + #include "../bitmaps/pcbnew.xpm" + #include "../bitmaps/treensel.xpm" + #include "../bitmaps/book.xpm" + #include "../bitmaps/module.xpm" + #include "../bitmaps/modedit.xpm" + #include "../bitmaps/config.xpm" + #include "../bitmaps/auto_associe.xpm" + #include "../bitmaps/icon_cvpcb.xpm" + #include "../bitmaps/icon_eeschema.xpm" + #include "../bitmaps/icon_gerbview.xpm" + #include "../bitmaps/icon_kicad.xpm" + #include "../bitmaps/icon_pcbnew.xpm" + #include "../bitmaps/icon_modedit.xpm" + #include "../bitmaps/Info.xpm" + #include "../bitmaps/mirepcb.xpm" + #include "../bitmaps/icon_3d.xpm" + #include "../bitmaps/drc_off.xpm" + #include "../bitmaps/grid.xpm" + #include "../bitmaps/grid_select.xpm" + #include "../bitmaps/unit_mm.xpm" + #include "../bitmaps/unit_inch.xpm" + #include "../bitmaps/cursor.xpm" + #include "../bitmaps/ratsnest.xpm" + #include "../bitmaps/modratsnest.xpm" + #include "../bitmaps/del_track.xpm" + #include "../bitmaps/pad.xpm" + #include "../bitmaps/Pad_Sketch.xpm" + #include "../bitmaps/Text_Sketch.xpm" + #include "../bitmaps/showtrack.xpm" + #include "../bitmaps/showmodedge.xpm" + #include "../bitmaps/showdcode.xpm" + #include "../bitmaps/palette.xpm" + #include "../bitmaps/help.xpm" + #include "../bitmaps/green.xpm" + #include "../bitmaps/red.xpm" + #include "../bitmaps/preference.xpm" + #include "../bitmaps/3d.xpm" + #include "../bitmaps/hammer.xpm" + #include "../bitmaps/jigsaw.xpm" + #include "../bitmaps/library_update.xpm" + #include "../bitmaps/transistor.xpm" + #include "../bitmaps/kicad_icon_small.xpm" + +// Largeur du toolbar vertical +#define VTOOLBAR_WIDTH 26 +// dimension d'un tool vertical +#define TOOL_SIZE 23 + diff --git a/include/build_version.h b/include/build_version.h new file mode 100644 index 0000000000..d18745186b --- /dev/null +++ b/include/build_version.h @@ -0,0 +1,12 @@ +/* Date for kicad build version */ + +#ifndef KICAD_BUILD_VERSION +#define KICAD_BUILD_VERSION + +COMMON_GLOBL wxString g_BuildVersion +#ifdef EDA_BASE + (wxT("(2007-01-15)")) +#endif +; + +#endif // KICAD_BUILD_VERSION diff --git a/include/colors.h b/include/colors.h new file mode 100644 index 0000000000..2c716c69b2 --- /dev/null +++ b/include/colors.h @@ -0,0 +1,93 @@ +/********************/ +/* Fichier colors.h */ +/********************/ + +#ifndef _COLORS_H +#define _COLORS_H + +#ifndef COMMON_GLOBL +#define COMMON_GLOBL extern +#endif + +/* Definitions des Numeros des Couleurs ( palette de 32) */ +#define NBCOLOR 32 +#define MASKCOLOR 31 // masque pour bits significatifs + +/* bit indicateur d'affichage (vu / non vu) des items : (defini dans les valeurs des couleurs*/ +#define ITEM_NOT_SHOW 0x40000 +/* Definition du bit de surbrillance */ +#define HIGHT_LIGHT_FLAG 0x80000 + +enum EDA_Colors +{ + BLACK = 0, + BLUE, + GREEN, + CYAN, + RED, + MAGENTA, + BROWN, + LIGHTGRAY, + DARKGRAY, + LIGHTBLUE, + LIGHTGREEN, + LIGHTCYAN, + LIGHTRED, + LIGHTMAGENTA, + YELLOW, + WHITE, + DARKDARKGRAY, + DARKBLUE, + DARKGREEN, + DARKCYAN, + DARKRED, + DARKMAGENTA, + DARKBROWN, + LIGHTYELLOW, +LASTCOLOR +}; + +class StructColors +{ +public: + unsigned char m_Blue, m_Green, m_Red, m_Numcolor; + wxChar* m_Name; + int m_LightColor; +}; + +extern StructColors ColorRefs[NBCOLOR]; +#ifdef MAIN +StructColors ColorRefs[NBCOLOR] = +{ + { 0, 0, 0, BLACK, wxT("BLACK"), DARKDARKGRAY}, + { 192, 0, 0, BLUE, wxT("BLUE"), LIGHTBLUE}, + { 0, 160, 0, GREEN, wxT("GREEN"), LIGHTGREEN }, + { 160, 160, 0, CYAN, wxT("CYAN"), LIGHTCYAN }, + { 0, 0, 160, RED, wxT("RED"), LIGHTRED }, + { 160, 0, 160, MAGENTA, wxT("MAGENTA"), LIGHTMAGENTA }, + { 0, 128, 128, BROWN, wxT("BROWN"), YELLOW }, + { 192, 192, 192, LIGHTGRAY, wxT("GRAY"), WHITE }, + { 128, 128, 128, DARKGRAY, wxT("DARKGRAY"), LIGHTGRAY }, + { 255, 0, 0, LIGHTBLUE, wxT("LIGHTBLUE"), LIGHTBLUE }, + { 0, 255, 0, LIGHTGREEN, wxT("LIGHTGREEN"), LIGHTGREEN }, + { 255, 255, 0, LIGHTCYAN, wxT("LIGHTCYAN"), LIGHTCYAN }, + { 0, 0, 255, LIGHTRED, wxT("LIGHTRED"), LIGHTRED }, + { 255, 0, 255, LIGHTMAGENTA, wxT("LIGHTMAGENTA"), LIGHTMAGENTA }, + { 0, 255, 255, YELLOW, wxT("YELLOW"), YELLOW }, + { 255, 255, 255, WHITE, wxT("WHITE"), WHITE }, + { 64, 64, 64, DARKDARKGRAY, wxT("DARKDARKGRAY"), DARKGRAY }, + { 64, 0, 0, DARKBLUE, wxT("DARKBLUE"), BLUE }, + { 0, 64, 0, DARKGREEN, wxT("DARKGREEN"), GREEN }, + { 64, 64, 0, DARKCYAN, wxT("DARKCYAN"), CYAN }, + { 0, 0, 80, DARKRED, wxT("DARKRED"), RED }, + { 64, 0, 64, DARKMAGENTA, wxT("DARKMAGENTA"), MAGENTA }, + { 0, 64, 64, DARKBROWN, wxT("DARKBROWN"), BROWN }, + { 128, 255, 255, LIGHTYELLOW, wxT("LIGHTYELLOW"), LIGHTYELLOW } + }; +#endif /* ifdef MAIN */ + + +COMMON_GLOBL wxPen * DrawPen; +COMMON_GLOBL wxBrush * DrawBrush; + +#endif /* ifndef _COLORS_H */ diff --git a/include/common.h b/include/common.h new file mode 100644 index 0000000000..90512dc783 --- /dev/null +++ b/include/common.h @@ -0,0 +1,632 @@ + /****************************/ + /* common.h */ + /****************************/ + +#ifndef COMMON_H +#define COMMON_H + +#include "wx/confbase.h" +#include "wx/fileconf.h" + +#ifndef COMMON_GLOBL +#define COMMON_GLOBL extern +#endif + +/* Numero de ports TCP/IP utilisés par KICAD */ +#define KICAD_PCB_PORT_SERVICE_NUMBER 4242 + + +/* Etat des touches speciales du clavier */ + +#define GR_KB_RIGHTSHIFT 0x0100 /* Keybd states: right shift key depressed */ +#define GR_KB_LEFTSHIFT 0x0200 /* left shift key depressed */ +#define GR_KB_CTRL 0x0400 /* CTRL depressed */ +#define GR_KB_ALT 0x0800 /* ALT depressed */ +#define GR_KB_SCROLLOCK 0x1000 /* SCROLL LOCK active */ +#define GR_KB_NUMLOCK 0x2000 /* NUM LOCK active */ +#define GR_KB_CAPSLOCK 0x4000 /* CAPS LOCK active */ +#define GR_KB_INSERT 0x8000 /* INSERT state active */ +#define GR_KB_SHIFT (GR_KB_LEFTSHIFT | GR_KB_RIGHTSHIFT) +#define GR_KB_SHIFTCTRL (GR_KB_SHIFT | GR_KB_CTRL) +#define MOUSE_MIDDLE 0x10000 /* flag indiquant bouton central souris */ + +/* Pseudo key codes for commands liske panning */ + +enum pseudokeys { + EDA_PANNING_UP_KEY = 2000, + EDA_PANNING_DOWN_KEY, + EDA_PANNING_LEFT_KEY, + EDA_PANNING_RIGHT_KEY +}; + +#define ESC 27 + +#ifdef __WINDOWS__ +#define CVPCB_EXE wxT("cvpcb.exe") +#define PCBNEW_EXE wxT("pcbnew.exe") +#define EESCHEMA_EXE wxT("eeschema.exe") +#define GERBVIEW_EXE wxT("gerbview.exe") + +#else +#define CVPCB_EXE wxT("cvpcb") +#define PCBNEW_EXE wxT("pcbnew") +#define EESCHEMA_EXE wxT("eeschema") +#define GERBVIEW_EXE wxT("gerbview") +#endif + + + +/* Orientation des textes graphiques en 0.1 degre*/ +#define TEXT_ORIENT_HORIZ 0 +#define TEXT_ORIENT_VERT 900 + +/* Affichage ou Effacement d'Item */ +#define ON 1 /* Affichage */ +#define OFF 0 /* Effacement */ + +/* unites d'affichage sur ecran et autres */ +#define INCHES 0 +#define MILLIMETRE 1 +#define CENTIMETRE 2 + +/* forward declarations: */ +class LibNameList; + +/* definifition des types de parametre des files de configuration */ +enum paramcfg_id /* type du parametre dans la structure ParamConfig */ +{ + PARAM_INT, + PARAM_SETCOLOR, + PARAM_DOUBLE, + PARAM_BOOL, + PARAM_LIBNAME_LIST, + PARAM_WXSTRING, + PARAM_COMMAND_ERASE +}; + +#define MAX_COLOR 0x8001F +#define INT_MINVAL 0x80000000 +#define INT_MAXVAL 0x7FFFFFFF + +class PARAM_CFG_BASE +{ +public: + const wxChar * m_Ident; /* Abreviation de reperage des debuts de lignes */ + paramcfg_id m_Type; /* flag type des parametres */ + const wxChar * m_Group; /* Nom du groupe (rubrique) de classement */ + bool m_Setup; /* TRUE -> inscription en setup (registration base)*/ + +public: + PARAM_CFG_BASE(const wxChar * ident, const paramcfg_id type, const wxChar * group = NULL); + ~PARAM_CFG_BASE() {}; +}; + +class PARAM_CFG_INT : public PARAM_CFG_BASE +{ +public: + int * m_Pt_param; /* pointeur sur le parametre a configurer */ + int m_Min, m_Max; /* valeurs extremes du parametre */ + int m_Default; /* valeur par defaut */ + +public: + PARAM_CFG_INT(const wxChar * ident, int * ptparam, + int default_val = 0, int min = INT_MINVAL, int max = INT_MAXVAL, + const wxChar * group = NULL); + PARAM_CFG_INT(bool Insetup, const wxChar * ident, int * ptparam, + int default_val = 0, int min = INT_MINVAL, int max = INT_MAXVAL, + const wxChar * group = NULL); +}; + +class PARAM_CFG_SETCOLOR : public PARAM_CFG_BASE +{ +public: + int * m_Pt_param; /* pointeur sur le parametre a configurer */ + int m_Default; /* valeur par defaut */ + +public: + PARAM_CFG_SETCOLOR(const wxChar * ident, int * ptparam, + int default_val, const wxChar * group = NULL); + PARAM_CFG_SETCOLOR(bool Insetup, const wxChar * ident, int * ptparam, + int default_val, const wxChar * group = NULL); +}; + +class PARAM_CFG_DOUBLE : public PARAM_CFG_BASE +{ +public: + double * m_Pt_param; /* pointeur sur le parametre a configurer */ + double m_Default; /* valeur par defaut */ + double m_Min, m_Max; /* valeurs extremes du parametre */ + +public: + PARAM_CFG_DOUBLE(const wxChar * ident, double * ptparam, + double default_val = 0.0, double min = 0.0, double max = 10000.0, + const wxChar * group = NULL); + PARAM_CFG_DOUBLE(bool Insetup, const wxChar * ident, double * ptparam, + double default_val = 0.0, double min = 0.0, double max = 10000.0, + const wxChar * group = NULL); +}; + +class PARAM_CFG_BOOL : public PARAM_CFG_BASE +{ +public: + bool * m_Pt_param; /* pointeur sur le parametre a configurer */ + int m_Default; /* valeur par defaut */ + +public: + PARAM_CFG_BOOL(const wxChar * ident, bool * ptparam, + int default_val = FALSE,const wxChar * group = NULL); + PARAM_CFG_BOOL(bool Insetup, const wxChar * ident, bool * ptparam, + int default_val = FALSE,const wxChar * group = NULL); +}; + + +class PARAM_CFG_WXSTRING : public PARAM_CFG_BASE +{ +public: + wxString * m_Pt_param; /* pointeur sur le parametre a configurer */ + +public: + PARAM_CFG_WXSTRING(const wxChar * ident, wxString * ptparam, const wxChar * group = NULL); + PARAM_CFG_WXSTRING(bool Insetup, const wxChar * ident, wxString * ptparam, const wxChar * group = NULL); +}; + +class PARAM_CFG_LIBNAME_LIST : public PARAM_CFG_BASE +{ +public: + wxArrayString * m_Pt_param; /* pointeur sur le parametre a configurer */ + +public: + PARAM_CFG_LIBNAME_LIST(const wxChar * ident, wxArrayString * ptparam, const wxChar * group = NULL); +}; + + + /***********************************/ + /* Classe pour affichage de textes */ + /***********************************/ +class WinEDA_TextFrame: public wxDialog +{ +private: + wxWindow * m_Parent; + wxListBox * m_List; + +public: + WinEDA_TextFrame(wxWindow * parent, const wxString & title); + void Append( const wxString & text); +private: + void D_ClickOnList(wxCommandEvent& event); + void OnClose(wxCloseEvent& event); + + DECLARE_EVENT_TABLE() +}; + + +/* Gestion des feuilles de tracé: +*/ +class Ki_PageDescr +{ +// All sizes are in 1/1000 inch +public: + wxSize m_Size ; /* page size in 1/1000 inch */ + wxPoint m_Offset; /* plot offset in 1/1000 inch */ + wxString m_Name; + int m_LeftMargin; + int m_RightMargin; + int m_TopMargin; + int m_BottomMargin; + +public: + Ki_PageDescr(const wxSize & size, const wxPoint & offset, const wxString & name); +}; + + +/* Standard page sizes in 1/1000 inch */ +#if defined EDA_BASE +Ki_PageDescr g_Sheet_A4(wxSize(11700,8267), wxPoint(0,0), wxT("A4") ); +Ki_PageDescr g_Sheet_A3(wxSize(16535,11700),wxPoint(0,0),wxT("A3") ); +Ki_PageDescr g_Sheet_A2(wxSize(23400,16535),wxPoint(0,0),wxT("A2") ); +Ki_PageDescr g_Sheet_A1(wxSize(33070,23400),wxPoint(0,0),wxT("A1") ); +Ki_PageDescr g_Sheet_A0(wxSize(46800,33070),wxPoint(0,0),wxT("A0") ); +Ki_PageDescr g_Sheet_A(wxSize(11000,8500),wxPoint(0,0),wxT("A") ); +Ki_PageDescr g_Sheet_B(wxSize(17000,11000),wxPoint(0,0),wxT("B") ); +Ki_PageDescr g_Sheet_C(wxSize(22000,17000),wxPoint(0,0),wxT("C") ); +Ki_PageDescr g_Sheet_D(wxSize(34000,22000),wxPoint(0,0),wxT("D") ); +Ki_PageDescr g_Sheet_E(wxSize(44000,34000),wxPoint(0,0),wxT("E") ); +Ki_PageDescr g_Sheet_GERBER(wxSize(32000,32000),wxPoint(0,0),wxT("GERBER") ); +Ki_PageDescr g_Sheet_user(wxSize(17000,11000),wxPoint(0,0),wxT("User") ); +#else +extern Ki_PageDescr g_Sheet_A4 ; +extern Ki_PageDescr g_Sheet_A3 ; +extern Ki_PageDescr g_Sheet_A2 ; +extern Ki_PageDescr g_Sheet_A1 ; +extern Ki_PageDescr g_Sheet_A0 ; +extern Ki_PageDescr g_Sheet_A ; +extern Ki_PageDescr g_Sheet_B ; +extern Ki_PageDescr g_Sheet_C ; +extern Ki_PageDescr g_Sheet_D ; +extern Ki_PageDescr g_Sheet_E ; +extern Ki_PageDescr g_Sheet_GERBER ; +extern Ki_PageDescr g_Sheet_user ; +#endif + + +COMMON_GLOBL int g_LastKey; /* code de la derniere touche actionnéé */ +COMMON_GLOBL wxString g_ProductName +#ifdef EDA_BASE += wxT("KiCad E.D.A. ") +#endif +; + +/* Gestion des librairies */ +COMMON_GLOBL wxString g_RealLibDirBuffer; // Chemin reel des librairies de module + // = UserLibDirBuffer si non vide + // = chemin par defaut sinon +COMMON_GLOBL wxString g_UserLibDirBuffer; // Chemin des librairies de module donne par + // le file de config + +/* variables globales generales */ + +COMMON_GLOBL int g_FloatSeparator; // = '.' ou = ',' selon locale pour l'ecriture des nombres flotttant +COMMON_GLOBL int g_DebugLevel; // 0= Pas de debug */ +COMMON_GLOBL int g_MouseOldButtons; +COMMON_GLOBL int g_KeyPressed; +// Font used by kicad. +// these font have a size which do not depend on default size system font +COMMON_GLOBL wxFont * g_StdFont; /* Standard font used for status display ,in message panel */ +COMMON_GLOBL wxFont * g_DialogFont; /* Normal font used in dialog box */ +COMMON_GLOBL wxFont * g_ItalicFont; /* Italic font used in dialog box */ +COMMON_GLOBL wxFont * g_MsgFont; /* Italic font used in msg panel (lower window) */ +COMMON_GLOBL wxFont * g_FixedFont; /* Affichage de Texte en fenetres de dialogue, + fonte a pas fixe)*/ +COMMON_GLOBL int g_StdFontPointSize; /* taille de la fonte */ +COMMON_GLOBL int g_DialogFontPointSize; /* taille de la fonte */ +COMMON_GLOBL int g_FixedFontPointSize; /* taille de la fonte */ +COMMON_GLOBL int g_MsgFontPointSize; /* taille de la fonte */ +COMMON_GLOBL int g_FontMinPointSize; /* taille minimum des fontes */ + +COMMON_GLOBL bool g_IsPrinting; // TRUE si impression au lieu de trace a l'ecran +COMMON_GLOBL bool g_ShowPageLimits // TRUE to display the page limits +#ifdef EDA_BASE += TRUE +#endif +; + +/* Gloabl variables for project handling */ +COMMON_GLOBL wxString g_Prj_Config_Filename_ext +#ifdef EDA_BASE += wxT(".pro" ) +#endif +; +COMMON_GLOBL wxFileConfig * g_Prj_Config; // Configuration locale, propre au projet +COMMON_GLOBL wxString g_Prj_Default_Config_FullFilename; // Nom (full file name) du file Configuration par defaut (kicad.pro) +COMMON_GLOBL wxString g_Prj_Config_LocalFilename; // Nom du file Configuration local (.pro) + +// Handle the preferd editor for browsing report files: +COMMON_GLOBL wxString g_EditorName; + + +// Gestion de la grille "utilisateur" (User Grid) +#ifdef EDA_BASE +wxRealPoint g_UserGrid(0.01, 0.01); +int g_UserGrid_Unit = INCHES; +#else +extern wxRealPoint g_UserGrid; +extern int g_UserGrid_Unit; +#endif + +COMMON_GLOBL int g_UnitMetric; // display units mm = 1, inches = 0, cm = 2 + + +// shape selector for cursor screen +COMMON_GLOBL int g_CursorShape; + +/* Draw color for moving objects: */ +COMMON_GLOBL int g_GhostColor; + +/* Draw color for grid: */ +COMMON_GLOBL int g_GridColor +#ifdef EDA_BASE + = DARKGRAY +#endif +; + +/* Current used screen: */ +COMMON_GLOBL BASE_SCREEN * ActiveScreen; + + + +/**************************************/ +/* Prototypage des Fonctions Usuelles */ +/**************************************/ + +class WinEDA_DrawFrame; +class WinEDAListBox; +class WinEDA_DrawPanel; + + +/* COMMON.CPP */ +wxString ReturnPcbLayerName(int layer_number, bool is_filename = FALSE); +/* Return the name of the layer number "layer_number". + if "is_filename" == TRUE, the name can be used for a file name + (not internatinalized, no space)*/ + + +/*********************/ +/* PROJET_CONFIG.CPP */ +/*********************/ + +/**************/ +/* DRAWTXT.CPP */ +/**************/ +void DrawGraphicText(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & pos, + int mode_color, const wxString & Text, + int orient , const wxSize & char_size, + int h_justify, int v_justify, int width = 0); + +void PlotGraphicText(int format_plot, const wxPoint & Pos, int gcolor, + const wxString & Text, + int orient, const wxSize & Size, int h_justify, int v_justify); + +/***************/ +/* CONFIRM.CPP */ +/***************/ +void DisplayError(wxWindow * parent, const wxString & msg, int displaytime = 0); +void DisplayInfo(wxWindow * parent, const wxString & msg, int displaytime = 0); + /* Routines d'affichage messages ( disparait au bout de displaytime 0.1 secondes) */ + +bool IsOK(wxWindow * parent, const wxString & msg) ; + /* Routine affichant la fenetre "CONFIRMATION" + Retourne 1 ou 0 selon reponse Yes / No */ + +int Get_Message(const wxString & titre, wxString & buffer, wxWindow * frame) ; + /* Fonction d'installation du menu de Dialogue + entree: titre = titre a afficher + entree/sortie :buffer : contient la reponse + si a l'appel buffer n'est pas vide, son contenu est aussi + affiche, mais disparait a la 1ere correction */ + +/************************/ +/* file GESTFICH.CPP */ +/************************/ + +wxString GetEditorName(void); // Return the prefered editor name + + +bool EDA_DirectorySelector(const wxString & Title, /* Titre de la fenetre */ + wxString & Path, /* Chemin par defaut */ + int flag, /* reserve */ + wxWindow * Frame, /* parent frame */ + const wxPoint & Pos); + +wxString EDA_FileSelector(const wxString & Title, /* Window title */ + const wxString & Path, /* default path */ + const wxString & FileName, /* default filename */ + const wxString & Ext, /* default extension */ + const wxString & Mask, /* Display filename mask */ + wxWindow * Frame, /* parent frame */ + int flag, /* wxSAVE, wxOPEN ..*/ + const bool keep_working_directory, /* true = do not change the C.W.D. */ + const wxPoint & Pos = wxPoint(-1, -1) + ); + +wxString MakeFileName( const wxString & dir, + const wxString & shortname, const wxString & ext); +/* Calcule le nom complet d'un file d'apres les chaines + dir = prefixe (chemin) + shortname = nom avec ou sans chemin ou extension + ext = extension + + si la chaine name possede deja un chemin ou une extension, elles + ne seront pas modifiees + + retourne la chaine calculee */ + +wxString MakeReducedFileName( const wxString & fullfilename, + const wxString & default_path, + const wxString & default_ext); +/* Calcule le nom "reduit" d'un file d'apres les chaines + fullfilename = nom complet + default_path = prefixe (chemin) par defaut + default_ext = extension par defaut + + retourne le nom reduit, c'est a dire: + sans le chemin si le chemin est default_path + avec ./ si si le chemin est le chemin courant + sans l'extension si l'extension est default_ext + + Renvoie un chemin en notation unix ('/' en separateur de repertoire) +*/ + +WinEDAListBox * GetFileNames(char *Directory, char *Mask); + +void ChangeFileNameExt( wxString & FullFileName, const wxString & NewExt ); + /* Change l'extension du "filename FullFileName" en NewExt. + Retourne FullFileName */ + +int ExecuteFile(wxWindow * frame, const wxString & ExecFile, + const wxString & param = wxEmptyString); +void AddDelimiterString( wxString & string ); + +void SetRealLibraryPath(const wxString & shortlibname); /* met a jour + le chemin des librairies RealLibDirBuffer (global) +a partir de UserLibDirBuffer (global): + Si UserLibDirBuffer non vide RealLibDirBuffer = UserLibDirBuffer. + Sinon si variable d'environnement KICAD definie (KICAD = chemin pour kicad), + UserLibDirBuffer = /shortlibname; + Sinon UserLibDirBuffer = ../shortlibname/ +*/ +wxString FindKicadHelpPath(void); +/* Find absolute path for kicad/help (or kicad/help/) */ + +wxString ReturnKicadDatasPath(void); + /* Retourne le chemin des donnees communes de kicad. */ + +wxString FindKicadFile(const wxString & shortname); +/* Search the executable file shortname in kicad binary path and return +full file name if found or shortname */ + + +/*************/ +/* STRING.CPP */ +/*************/ +char * strupper(char * Text); + +int ReadDelimitedText(char * dest, char * source, int NbMaxChar ); + /* lit et place dans dest la chaine de caractere trouvee dans source, + delimitee par " . + transfere NbMaxChar max + retourne le nombre de codes lus dans source + dest est termine par NULL */ + +char * GetLine(FILE *File, char *Line, int *LineNum = NULL, int SizeLine = 255); + /* Routine de lecture de 1 ligne utile + retourne la 1ere ligne utile lue. + elimine lignes vides et commentaires */ +char * StrPurge(char * text); + /* Supprime les caracteres Space en debut de la ligne text + retourne un pointeur sur le 1er caractere non Space de text */ + +char * DateAndTime(char * line); +wxString DateAndTime(void); + /* Retourne la chaine de caractere donnant date+heure */ + +int StrLenNumCmp(const wxChar *str1,const wxChar *str2, int NbMax); + /* + routine (compatible qsort() ) de comparaision pour classement alphab‚tique + Analogue a strncmp() mais les nombres sont compar‚s selon leur valeur num‚rique + et non pas par leur code ascii */ + +int StrNumICmp(const wxChar *str1,const wxChar *str2); + /* routine (compatible qsort() ) de comparaison pour classement alphab‚tique, + avec lower case == upper case. + Analogue a stricmp() mais les nombres sont compar‚s selon leur valeur num‚rique + et non pas par leur code ascii */ + +int StrLenNumICmp(const wxChar *str1,const wxChar *str2, int NbMax); + /* routine (compatible qsort() ) de comparaison pour classement alphab‚tique, + avec lower case == upper case. + Analogue a stricmp() mais les nombres sont compar‚s selon leur valeur num‚rique + et non pas par leur code ascii */ + +bool WildCompareString(const wxString & pattern, const wxString & string_to_tst, + bool case_sensitive = TRUE); + /* compare 2 noms de composants, selon regles usuelles + ( Jokers * , ? , autoris‚s). + la chaine de reference est "pattern" + si case_sensitive == TRUE (default), comparaison exacte + retourne TRUE si match FALSE si differences */ + +char * to_point(char * Text); + /* convertit les , en . dans une chaine. utilisé pour compenser un defaut de la fct printf sous linux-mandrake + qui genere les flottants avec une virgule au lieu du point */ + +char * from_point(char * Text); + /* convertit les . en , dans une chaine. utilisé pour compenser + la francisation imbecile de la fct scanf sous linux-mandrake ou mingw + qui lit les flottants avec une virgule au lieu du point */ + +/****************/ +/* infospgm.cpp */ +/****************/ +void Print_Kicad_Infos(wxWindow * frame); + +/**************/ +/* common.cpp */ +/**************/ +wxString GetBuildVersion(void); /* Return the build date */ + +void Affiche_1_Parametre(WinEDA_DrawFrame * frame , + int pos_X,const wxString& texte_H,const wxString& texte_L,int color); +/* + Routine d'affichage d'un parametre. + pos_X = cadrage horizontal + si pos_X < 0 : la position horizontale est la derniere + valeur demandee >= 0 + texte_H = texte a afficher en ligne superieure. + si "", par d'affichage sur cette ligne + texte_L = texte a afficher en ligne inferieure. + si "", par d'affichage sur cette ligne + color = couleur d'affichage +*/ + +void AfficheDoc(WinEDA_DrawFrame * frame, const wxString & Doc, const wxString & KeyW); + /* Routine d'affichage de la documentation associee a un composant */ + +int GetTimeStamp(void); + /* Retoure une identification temporelle (Time stamp) differente a chaque appel */ +int DisplayColorFrame(wxWindow * parent); +int GetCommandOptions(const int argc, const char **argv, const char * stringtst, + const char ** optarg, int * optind); + + +void valeur_param(int valeur,wxString & buf_texte); +/* Retourne pour affichage la valeur d'un parametre, selon type d'unites choisies + entree : valeur en mils , buffer de texte + retourne en buffer : texte : valeur exprimee en pouces ou millimetres + suivie de " ou mm +*/ + +wxString ReturnUnitSymbol(int Units = g_UnitMetric); +int ReturnValueFromString(int Units, const wxString & TextValue, int Internal_Unit); +wxString ReturnStringFromValue(int Units, int Value, int Internal_Unit); +void AddUnitSymbol(wxStaticText & Stext, int Units = g_UnitMetric); + /* Add string " (mm):" or " ("):" to the static text Stext. + Used in dialog boxes for entering values depending on selected units */ +void PutValueInLocalUnits(wxTextCtrl & TextCtr, int Value, int Internal_Unit); + /* Convert the number Value in a string according to the internal units + and the selected unit (g_UnitMetric) and put it in the wxTextCtrl TextCtrl */ +int ReturnValueFromTextCtrl(const wxTextCtrl & TextCtr, int Internal_Unit); + /* Convert the Value in the wxTextCtrl TextCtrl in an integer, + according to the internal units and the selected unit (g_UnitMetric) */ + +double To_User_Unit(bool is_metric, int val,int internal_unit_value); +int From_User_Unit(bool is_metric, double val,int internal_unit_value); +wxString GenDate(void); +void MyFree (void * pt_mem); +void * MyZMalloc (size_t nb_octets); +void * MyMalloc (size_t nb_octets); + + +/****************/ +/* eda_doc.cpp */ +/****************/ +int KeyWordOk(const wxString & KeyList, const wxString & Database ); +/* Recherche si dans le texte Database on retrouve tous les mots + cles donnes dans KeyList ( KeyList = suite de mots cles + separes par des espaces + Retourne: + 0 si aucun mot cle trouvé + 1 si mot cle trouvé +*/ +bool GetAssociatedDocument(wxFrame * frame, const wxString & LibPath, + const wxString & DocName); + + +/****************************/ +/* get_component_dialog.cpp */ +/****************************/ +wxString GetComponentName(WinEDA_DrawFrame * frame, + wxArrayString & HistoryList, const wxString & Title, + wxString(*AuxTool)(WinEDA_DrawFrame *parent) ); + /* Dialog frame to choose a component name */ +void AddHistoryComponentName(wxArrayString & HistoryList, const wxString & Name); + /* Add the string "Name" to the history list */ + + +/**********************/ +/* block_commande.cpp */ +/**********************/ +void AbortBlockCurrentCommand(WinEDA_DrawPanel * Panel, wxDC * DC); + /* Cancel Current block operation. */ +void InitBlockLocateDatas( WinEDA_DrawPanel * Panel,const wxPoint & startpos ); + /* Init the initial values of a BlockLocate, before starting a block command */ +void DrawAndSizingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase ); + /* Redraw the outlines of the block which shows the search area for block commands + The first point of the rectangle showing the area is initialised + by InitBlockLocateDatas(). + The other point of the rectangle is the mouse cursor */ + + + +#endif // COMMON_H + + diff --git a/include/dcsvg.h b/include/dcsvg.h new file mode 100644 index 0000000000..23530f9e14 --- /dev/null +++ b/include/dcsvg.h @@ -0,0 +1,315 @@ +#ifndef __DCSVG_H +#define __DCSVG_H +#include "wx/wfstream.h" +#include "wx/string.h" + +#ifdef WXMAKINGDLL_SVG + #define WXDLLIMPEXP_SVG WXEXPORT +#elif defined(WXUSINGDLL) + #define WXDLLIMPEXP_SVG WXIMPORT +#else // not making nor using DLL + #define WXDLLIMPEXP_SVG +#endif + +#define wxSVGVersion wxT("v0101") +#ifdef __BORLANDC__ +#pragma warn -rch +#pragma warn -ccc +#endif + +class WXDLLIMPEXP_SVG wxSVGFileDC : public wxDC +{ + + private: + wxFileOutputStream * m_outfile ; + wxString m_filename ; + //holds number of png format images we have + int m_sub_images ; + bool m_OK, m_graphics_changed ; + int m_width, m_height ; + + double + m_logicalScaleX, + m_logicalScaleY, + m_userScaleX, + m_userScaleY, + m_scaleX, + m_scaleY, + m_OriginX, + m_OriginY, + m_mm_to_pix_x, + m_mm_to_pix_y; + + bool + m_needComputeScaleX, + m_needComputeScaleY; // not yet used + + + bool DoGetPixel(wxCoord, wxCoord, class wxColour *) const + { wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoGetPixel Call not implemented")); return true; }; + + virtual bool DoBlit(wxCoord, wxCoord, wxCoord, wxCoord, class wxDC *, + wxCoord, wxCoord, int = wxCOPY, bool = 0, int = -1, int = -1) ; + + void DoCrossHair(wxCoord, wxCoord) + { wxASSERT_MSG (false, wxT("wxSVGFILEDC::CrossHair Call not implemented")); return ; }; + + void DoDrawArc(wxCoord, wxCoord, wxCoord, wxCoord, wxCoord, wxCoord); + + void DoDrawBitmap(const class wxBitmap &, wxCoord, wxCoord, bool = 0) ; + + void DoDrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height) ; + + void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) ; + + void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) ; + + void DoDrawIcon(const class wxIcon &, wxCoord, wxCoord) ; + + void DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) ; + + void DoDrawPoint(wxCoord, wxCoord) ; + + void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int fillStyle) ; + + void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) ; + + void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) ; + + void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20) ; + + void DoDrawText(const wxString& text, wxCoord x, wxCoord y); + + bool DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour& WXUNUSED(col), + int WXUNUSED(style) = wxFLOOD_SURFACE) + { wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoFloodFill Call not implemented")); return false ; }; + + void DoGetSize(int * x, int *y) const { *x = m_width; *y = m_height ; return ; } ; + + void DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent = NULL, wxCoord *externalLeading = NULL, wxFont *font = NULL) const ; + + void DoSetClippingRegionAsRegion(const class wxRegion &) + { wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoSetClippingRegionAsRegion Call not yet implemented")); return ; }; + + void Init (wxString f, int Width, int Height, float dpi); + + void NewGraphics () ; + +#ifdef XDEV2LOG +#undef XDEV2LOG +#endif + wxCoord XDEV2LOG(wxCoord x) const + { + wxCoord new_x = x - m_deviceOriginX; + if (new_x > 0) + return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; + else + return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; + } +#ifdef XDEV2LOGREL +#undef XDEV2LOGREL +#endif + wxCoord XDEV2LOGREL(wxCoord x) const + { + if (x > 0) + return (wxCoord)((double)(x) / m_scaleX + 0.5); + else + return (wxCoord)((double)(x) / m_scaleX - 0.5); + } +#ifdef YDEV2LOG +#undef YDEV2LOG +#endif + wxCoord YDEV2LOG(wxCoord y) const + { + wxCoord new_y = y - m_deviceOriginY; + if (new_y > 0) + return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; + else + return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; + } +#ifdef YDEV2LOGREL +#undef YDEV2LOGREL +#endif + wxCoord YDEV2LOGREL(wxCoord y) const + { + if (y > 0) + return (wxCoord)((double)(y) / m_scaleY + 0.5); + else + return (wxCoord)((double)(y) / m_scaleY - 0.5); + } +#ifdef XLOG2DEV +#undef XLOG2DEV +#endif + wxCoord XLOG2DEV(wxCoord x) const + { + wxCoord new_x = x - m_logicalOriginX; + if (new_x > 0) + return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; + else + return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; + } +#ifdef XLOG2DEVREL +#undef XLOG2DEVREL +#endif + wxCoord XLOG2DEVREL(wxCoord x) const + { + if (x > 0) + return (wxCoord)((double)(x) * m_scaleX + 0.5); + else + return (wxCoord)((double)(x) * m_scaleX - 0.5); + } +#ifdef YLOG2DEV +#undef YLOG2DEV +#endif + wxCoord YLOG2DEV(wxCoord y) const + { + wxCoord new_y = y - m_logicalOriginY; + if (new_y > 0) + return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; + else + return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; + } +#ifdef YLOG2DEVREL +#undef YLOG2DEVREL +#endif + wxCoord YLOG2DEVREL(wxCoord y) const + { + if (y > 0) + return (wxCoord)((double)(y) * m_scaleY + 0.5); + else + return (wxCoord)((double)(y) * m_scaleY - 0.5); + } + + void write(const wxString &s); + + public: + + wxSVGFileDC (wxString f); + wxSVGFileDC (wxString f, int Width, int Height); + wxSVGFileDC (wxString f, int Width, int Height, float dpi); + ~wxSVGFileDC(); + + + bool CanDrawBitmap() const { return true; }; + + bool CanGetTextExtent() const { return true; }; + + int GetDepth() const + { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetDepth Call not implemented")); return -1 ; }; + + void BeginDrawing() { return;}; + + bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC* source, wxCoord xsrc, wxCoord ysrc, int logicalFunc = wxCOPY, bool useMask = false) + { return DoBlit(xdest, ydest, width, height, source, xsrc, ysrc, logicalFunc, useMask); }; + + void Clear() + { wxASSERT_MSG (false, wxT("wxSVGFILEDC::Clear() Call not implemented \nNot sensible for an output file?")); return ; }; + + void CrossHair(wxCoord x, wxCoord y) + { DoCrossHair (x,y); return; }; + + virtual void ComputeScaleAndOrigin(); + + void DestroyClippingRegion() + { wxASSERT_MSG (false, wxT("wxSVGFILEDC::void Call not yet implemented")); return ; }; + + wxCoord DeviceToLogicalX(wxCoord x) const ; + + wxCoord DeviceToLogicalXRel(wxCoord x) const ; + + wxCoord DeviceToLogicalY(wxCoord y) const ; + + wxCoord DeviceToLogicalYRel(wxCoord y) const ; + + void DrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y, bool transparent) + { DoDrawBitmap ( bitmap, x, y, transparent ) ; return ;}; + + void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) + {DoDrawIcon(icon, x, y) ; return ; }; + + void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0) ; + + void EndDoc() + { return ; }; + + void EndDrawing() + { return ; }; + + void EndPage() + { return ; }; + + void FloodFill(wxCoord x, wxCoord y, wxColour *colour, int style=wxFLOOD_SURFACE) + { DoFloodFill (x, y, *colour, style); return ;} ; + + wxCoord GetCharHeight() const; + + wxCoord GetCharWidth() const; + + void GetClippingBox(wxCoord *WXUNUSED(x), wxCoord *WXUNUSED(y), wxCoord * WXUNUSED(width), wxCoord * WXUNUSED(height)) + { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetClippingBox Call not yet implemented")); return ; }; + + int GetLogicalFunction() + { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetLogicalFunction() Call not implemented")); return wxCOPY ; }; + + int GetMapMode() ; + + bool GetPixel(wxCoord x, wxCoord y, wxColour *colour) + { return DoGetPixel (x, y, colour) ; } ; + + void GetUserScale(double *x, double *y) const ; + + wxCoord LogicalToDeviceX(wxCoord x) const ; + + wxCoord LogicalToDeviceXRel(wxCoord x) const ; + + wxCoord LogicalToDeviceY(wxCoord y) const ; + + wxCoord LogicalToDeviceYRel(wxCoord y) const ; + + bool Ok() const {return m_OK;}; + + void SetAxisOrientation( bool xLeftRight, bool yBottomUp ) ; + + void SetClippingRegion(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxCoord WXUNUSED(width), wxCoord WXUNUSED(height)) + { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetClippingRegion Call not yet implemented")); return ; }; + + void SetPalette(const wxPalette& WXUNUSED(palette)) + { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetPalette Call not yet implemented")); return ; }; + + void SetBackground( const wxBrush &brush ) ; + + void SetBackgroundMode( int mode ) ; + + void SetBrush(const wxBrush& brush) ; + + void SetFont(const wxFont& font) ; + + void SetLogicalFunction(int WXUNUSED(function)) + { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetLogicalFunction Call implemented")); return ; }; + + void SetLogicalScale( double x, double y ) ; + + void SetLogicalOrigin( wxCoord x, wxCoord y ) ; + + void SetDeviceOrigin( wxCoord x, wxCoord y ) ; + + void SetMapMode(int anint) ; + + void SetPen(const wxPen& pen) ; + + void SetUserScale(double xScale, double yScale) ; + + bool StartDoc(const wxString& WXUNUSED(message)) + { return false; }; + + void StartPage() + { return ; }; + + +}; + +#ifdef __BORLANDC__ +#pragma warn .rch +#pragma warn .ccc +#endif +#endif diff --git a/include/drawpanel_wxstruct.h b/include/drawpanel_wxstruct.h new file mode 100644 index 0000000000..0b9a719ee0 --- /dev/null +++ b/include/drawpanel_wxstruct.h @@ -0,0 +1,271 @@ + /****************************************************/ + /* drawpanel_wxstruct.h: */ + /* descriptions des principales classes utilisees: */ + /* ici classe: "WinEDA_DrawPanel", "BASE_SCREEN" */ + /*****************************************************/ + +/* Doit etre inclus dans "wxstruch.h" +*/ + +#ifndef PANEL_WXSTRUCT_H +#define PANEL_WXSTRUCT_H + + +#ifndef eda_global +#define eda_global extern +#endif + +#include "colors.h" + + /****************************************************/ + /* classe representant un ecran graphique de dessin */ + /****************************************************/ + +class WinEDA_DrawPanel: public EDA_DRAW_PANEL +{ +public: + int m_Ident; + WinEDA_DrawFrame * m_Parent; + EDA_Rect m_ClipBox; /* position et taille de la fenetre de trace + pour les "RePaint" d'ecran */ + wxPoint m_CursorStartPos; // utile dans controles du mouvement curseur + int m_Scroll_unit; // Valeur de l'unite de scroll en pixels pour les barres de scroll + int m_ScrollButt_unit; // Valeur de l'unite de scroll en pixels pour les boutons de scroll + + bool m_AbortRequest; // Flag d'arret de commandes longues + bool m_AbortEnable; // TRUE si menu ou bouton Abort doit etre affiche + + bool m_AutoPAN_Enable; // TRUE pour autoriser auto pan (autorisation générale) + bool m_AutoPAN_Request; // TRUE pour auto pan (lorsque auto pan nécessaire) + + bool m_IgnoreMouseEvents; // TRUE pour ne par traiter les evenements souris + + bool m_Block_Enable; // TRUE pour autoriser Bloc Commandes (autorisation générale) + int m_CanStartBlock; // >= 0 (ou >= n) si un bloc peut demarrer + // (filtrage des commandes de debut de bloc ) + int m_PanelDefaultCursor; // Current mouse cursor default shape id for this window + int m_PanelCursor; // Current mouse cursor shape id for this window + int m_CursorLevel; // Index for cursor redraw in XOR mode + + /* Cursor management (used in editing functions) */ + void (*ManageCurseur)(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); /* Fonction d'affichage sur deplacement souris + si erase : effacement ancien affichage */ + void (*ForceCloseManageCurseur)(WinEDA_DrawPanel * panel, wxDC * DC); /* Fonction de fermeture forcée + de la fonction ManageCurseur */ + +public: + // Constructor and destructor + WinEDA_DrawPanel(WinEDA_DrawFrame *parent, int id, const wxPoint& pos, const wxSize& size); + ~WinEDA_DrawPanel(void){} + /****************************/ + BASE_SCREEN * GetScreen(void) { return m_Parent->m_CurrentScreen; } + + void PrepareGraphicContext(wxDC * DC); + wxPoint CalcAbsolutePosition(const wxPoint & rel_pos); + bool IsPointOnDisplay(wxPoint ref_pos); + void OnPaint(wxPaintEvent & event); + void OnSize(wxSizeEvent & event); + void SetBoundaryBox(void); + void ReDraw(wxDC * DC, bool erasebg = TRUE); + void PrintPage(wxDC * DC, bool Print_Sheet_Ref, int PrintMask); + void DrawBackGround(wxDC * DC); + void m_Draw_Auxiliary_Axis(wxDC * DC, int drawmode); + void OnEraseBackground(wxEraseEvent& event); + void OnActivate(wxActivateEvent& event); + + /* Mouse and keys events */ + void OnMouseEvent(wxMouseEvent& event); + void OnMouseLeaving(wxMouseEvent& event); + void OnKeyEvent(wxKeyEvent& event); + /*************************/ + + void EraseScreen(wxDC * DC); + void OnScrollWin( wxCommandEvent &event ); + void OnScroll( wxScrollWinEvent &event ); + + void SetZoom(int mode); + int GetZoom(void); + void SetGrid(const wxSize & size); + wxSize GetGrid(void); + + void AddMenuZoom( wxMenu * MasterMenu ); + void OnRightClick(wxMouseEvent& event); + void Process_Popup_Zoom( wxCommandEvent &event ); + void Process_Special_Functions(wxCommandEvent& event); + wxPoint CursorRealPosition(const wxPoint & ScreenPos); + wxPoint CursorScreenPosition(void); + wxPoint GetScreenCenterRealPosition(void); + void MouseToCursorSchema(void); + void MouseTo(const wxPoint & Mouse); + + /* Cursor functions */ + void Trace_Curseur(wxDC * DC, int color = WHITE); // Draw the user cursor (grid cursor) + void CursorOff(wxDC * DC); // remove the grid cursor from the display + void CursorOn(wxDC * DC); // display the grid cursor + + DECLARE_EVENT_TABLE() +}; + +/**************************/ +/* class DrawBlockStruct */ +/**************************/ +/* Definition d'un block pour les fonctions sur block (block move, ..) */ +typedef enum { /* definition de l'etat du block */ + STATE_NO_BLOCK, /* Block non initialise */ + STATE_BLOCK_INIT, /* Block initialise: 1er point defini */ + STATE_BLOCK_END, /* Block initialise: 2eme point defini */ + STATE_BLOCK_MOVE, /* Block en deplacement */ + STATE_BLOCK_STOP /* Block fixe (fin de deplacement) */ + } BlockState; + +/* codes des differentes commandes sur block: */ +typedef enum { + BLOCK_IDLE, + BLOCK_MOVE, + BLOCK_COPY, + BLOCK_SAVE, + BLOCK_DELETE, + BLOCK_PASTE, + BLOCK_DRAG, + BLOCK_ROTATE, + BLOCK_INVERT, + BLOCK_ZOOM, + BLOCK_ABORT, + BLOCK_PRESELECT_MOVE, + BLOCK_SELECT_ITEMS_ONLY, + BLOCK_MIRROR_X, + BLOCK_MIRROR_Y +} CmdBlockType; + +class DrawBlockStruct: public EDA_BaseStruct, public EDA_Rect +{ +public: + BlockState m_State; /* Etat (enum BlockState) du block */ + CmdBlockType m_Command; /* Type (enum CmdBlockType) d'operation */ + EDA_BaseStruct *m_BlockDrawStruct; /* pointeur sur la structure + selectionnee dans le bloc */ + int m_Color; /* Block Color */ + wxPoint m_MoveVector; /* Move distance in move, drag, copy ... command */ + wxPoint m_BlockLastCursorPosition; /* Last Mouse position in block command + = last cursor position in move commands + = 0,0 in block paste */ + +public: + DrawBlockStruct(void); + ~DrawBlockStruct(void); + void SetMessageBlock(WinEDA_DrawFrame * frame); + void Draw(WinEDA_DrawPanel * panel, wxDC * DC); +}; + + +/*******************************************************************/ +/* Class to handle how to draw a screen (a board, a schematic ...) */ +/*******************************************************************/ +class BASE_SCREEN: public EDA_BaseStruct +{ +public: + int m_Type; /* indicateur: type d'ecran */ + wxPoint m_DrawOrg; /* offsets pour tracer le circuit sur l'ecran */ + wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user units. */ + wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user units. */ + wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) in user units. + (coordinates from last reset position)*/ + wxPoint m_ScrollbarPos; // Position effective des Curseurs de scroll + wxSize m_ScrollbarNumber; /* Valeur effective des Nombres de Scrool + c.a.d taille en unites de scroll de la surface totale affichable */ + wxPoint m_StartVisu; // Coord absolues du 1er pixel visualisé a l'ecran (en nombre de pixels) + wxSize m_SizeVisu; /* taille en pixels de l'ecran (fenetre de visu + Utile pour recadrer les affichages lors de la + navigation dans la hierarchie */ + bool m_Center; // TRUE: coord algebriques, FALSE: coord >= 0 + bool m_FirstRedraw; + + /* Gestion des editions */ + EDA_BaseStruct *EEDrawList; /* Object list (main data) for schematic */ + EDA_BaseStruct * m_UndoList; /* Object list for the undo command (old data) */ + EDA_BaseStruct * m_RedoList; /* Object list for the redo command (old data) */ + int m_UndoRedoCountMax; /* undo/Redo command Max depth */ + EDA_BaseStruct * m_CurrentItem; /* Current selected object */ + + /* block control */ + DrawBlockStruct BlockLocate; /* Bock description for block commands */ + + /* Page description */ + Ki_PageDescr * m_CurrentSheet; + int m_SheetNumber, m_NumberOfSheet; /* gestion hierarchie: numero de sousfeuille + et nombre de feuilles. Root: SheetNumber = 1 */ + wxString m_FileName; + wxString m_Title; /* titre de la feuille */ + wxString m_Date; /* date de mise a jour */ + wxString m_Revision; /* code de revision */ + wxString m_Company; /* nom du proprietaire */ + wxString m_Commentaire1; + wxString m_Commentaire2; + wxString m_Commentaire3; + wxString m_Commentaire4; + +private: + /* indicateurs divers */ + char m_FlagRefreshReq; /* indique que l'ecran doit redessine */ + char m_FlagModified; // indique modif du PCB,utilise pour eviter une sortie sans sauvegarde + char m_FlagSave; // indique sauvegarde auto faite + + /* Valeurs du pas de grille et du zoom */ +public: + wxSize m_Grid ; /* pas de la grille (peut differer en X et Y) */ + wxSize * m_GridList; /* Liste des valeurs standard de grille */ + wxRealPoint m_UserGrid; /* pas de la grille utilisateur */ + int m_UserGridUnit; /* unité grille utilisateur (0 = inch, 1 = mm */ + int m_Diviseur_Grille ; + bool m_UserGridIsON; + int * m_ZoomList; /* Liste des coefficients standard de zoom */ + int m_Zoom ; /* coeff de ZOOM */ + +public: + BASE_SCREEN(int idscreen); + ~BASE_SCREEN(void); + + void InitDatas(void); /* Inits completes des variables */ + wxSize ReturnPageSize(void); + int GetInternalUnits(void); + + /* general Undo/Redo command control */ + virtual void ClearUndoRedoList(void); + virtual void AddItemToUndoList(EDA_BaseStruct * item); + virtual void AddItemToRedoList(EDA_BaseStruct * item); + virtual EDA_BaseStruct * GetItemFromUndoList(void); + virtual EDA_BaseStruct * GetItemFromRedoList(void); + + /* Manipulation des flags */ + void SetRefreshReq(void) { m_FlagRefreshReq = 1; } + void ClrRefreshReq(void) { m_FlagRefreshReq = 0; } + void SetModify(void) { m_FlagModified = 1; m_FlagSave = 0; } + void ClrModify(void) { m_FlagModified = 0; m_FlagSave = 1; } + void SetSave(void) { m_FlagSave = 1; } + void ClrSave(void) { m_FlagSave = 0; } + int IsModify(void) { return (m_FlagModified & 1); } + int IsRefreshReq(void) { return (m_FlagRefreshReq & 1); } + int IsSave(void) { return (m_FlagSave & 1); } + + /* fonctions relatives au zoom */ + int GetZoom(void); /* retourne le coeff de zoom */ + void SetZoom(int coeff) ; /* ajuste le coeff de zoom a coeff */ + void SetZoomList(int * zoomlist); /* init liste des zoom (NULL terminated) */ + void SetNextZoom(void); /* ajuste le prochain coeff de zoom */ + void SetPreviousZoom(void); /* ajuste le precedent coeff de zoom */ + void SetFirstZoom(void); /* ajuste le coeff de zoom a 1*/ + void SetLastZoom(void); /* ajuste le coeff de zoom au max */ + + /* fonctions relatives a la grille */ + wxSize GetGrid(void); /* retourne la grille */ + void SetGrid(const wxSize & size); + void SetGridList(wxSize * sizelist); /* init liste des grilles (NULL terminated) */ + void SetNextGrid(void); /* ajuste le prochain coeff de grille */ + void SetPreviousGrid(void); /* ajuste le precedent coeff de grille */ + void SetFirstGrid(void); /* ajuste la grille au mini*/ + void SetLastGrid(void); /* ajuste la grille au max */ +}; + + +#endif /* PANEL_WXSTRUCT_H */ + diff --git a/include/eda_dde.h b/include/eda_dde.h new file mode 100644 index 0000000000..7014c11183 --- /dev/null +++ b/include/eda_dde.h @@ -0,0 +1,27 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: eda_dde.h +// Purpose: DDE server & client +///////////////////////////////////////////////////////////////////////////// + +#define wxServer wxSocketServer +#define wxClient wxSocketClient + +#include + +#define WinEDA_Server wxSocketServer + + + /********************/ + /* autres fonctions */ + /********************/ + +WinEDA_Server * CreateServer(wxWindow * window, int service); +bool SendCommand( int service, char * cmdline); +void SetupServerFunction(void (* remotefct)(char * remotecmd) ); + + + + + + + diff --git a/include/fctsys.h b/include/fctsys.h new file mode 100644 index 0000000000..a7cdcde33c --- /dev/null +++ b/include/fctsys.h @@ -0,0 +1,79 @@ + /********************/ + /* includes systeme */ + /********************/ +#ifndef FCTSYS_H +#define FCTSYS_H + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWindows headers +#ifndef WX_PRECOMP +#include +#endif + +#include +#ifdef __FreeBSD__ +#include +#else +# ifndef __DARWIN__ +# include // MacOSX (DARWIN): malloc() and free() are in stdlib.h +#endif +#endif +#include +#include +#include +#include + +#ifdef __WXMAC__ +#include +#endif + +#ifndef M_PI +#define M_PI 3.141592653 +#endif + +#define PCB_INTERNAL_UNIT 10000 // PCBNEW internal unit = 1/10000 inch +#define EESCHEMA_INTERNAL_UNIT 1000 // EESCHEMA internal unit = 1/1000 inch + +#include "wxstruct.h" +#include "gr_basic.h" + +// Old wxWidget compatibility (prior to wxWidget 2.7): +#if ( (wxMAJOR_VERSION < 2) || ((wxMAJOR_VERSION == 2)&& (wxMINOR_VERSION < 7)) ) +#define wxFD_OPEN wxOPEN +#define wxFD_SAVE wxSAVE +#define WXK_PAGEUP WXK_PRIOR +#define WXK_PAGEDOWN WXK_NEXT +#endif + +#ifdef __UNIX__ +#define stricmp strcasecmp +#define strnicmp strncasecmp +#endif + +#ifdef __WINDOWS__ +#define DIR_SEP '\\' +#define STRING_DIR_SEP wxT("\\") +#else +#define DIR_SEP '/' +#define STRING_DIR_SEP wxT("/") +#endif + +#define UNIX_STRING_DIR_SEP wxT("/") +#define WIN_STRING_DIR_SEP wxT("\\") + +#ifndef TRUE +#define TRUE ((bool)1) +#define FALSE ((bool)0) +#endif + + +#endif /* FCTSYS_H */ + + diff --git a/include/gr_basic.h b/include/gr_basic.h new file mode 100644 index 0000000000..aa7b718fd3 --- /dev/null +++ b/include/gr_basic.h @@ -0,0 +1,163 @@ + /**************/ + /* gr_basic.h */ + /**************/ + +#ifndef GR_BASIC +#define GR_BASIC + +#ifndef COMMON_GLOBL +#define COMMON_GLOBL extern +#endif + +#include "colors.h" + +/* Constantes utiles */ + +#define GR_COPY 0 +#define GR_OR 0x1000000 +#define GR_XOR 0x2000000 +#define GR_AND 0x4000000 +#define GR_NXOR 0x8000000 + +#define GR_SURBRILL 0x80000000 + +#define GR_M_LEFT_DOWN 0x10000000 +#define GR_M_RIGHT_DOWN 0x20000000 +#define GR_M_MIDDLE_DOWN 0x40000000 +#define GR_M_DCLICK 0x80000000 + + +/* variables generales */ +COMMON_GLOBL int g_XorMode // = GR_XOR ou GR_NXOR selon couleur de fond +#ifdef EDA_BASE // pour les tracés en mode XOR += GR_NXOR +#endif +; +COMMON_GLOBL int g_DrawBgColor // couleur de fond de la frame de dessin +#ifdef EDA_BASE + = WHITE +#endif +; + + +typedef enum { /* Line styles for Get/SetLineStyle. */ + GR_SOLID_LINE = 0, + GR_DOTTED_LINE = 1, + GR_DASHED_LINE = 3 +} GRLineStypeType; + +typedef enum { /* Line widths for Get/SetLineStyle. */ + GR_NORM_WIDTH = 1, + GR_THICK_WIDTH = 3 +} GRLineWidthType; + + +/*******************************************************/ +/* Prototypage des fonctions definies dans gr_basic.cc */ +/*******************************************************/ +int GRMapX(int x); +int GRMapY(int y); + +class WinEDA_DrawPanel; +void GRMouseWarp(WinEDA_DrawPanel * panel, const wxPoint& pos); /* positionne la souris au point de coord pos */ + +/* routines generales */ +void GRSetDrawMode(wxDC * DC, int mode); +int GRGetDrawMode(wxDC * DC); +void GRResetPenAndBrush(wxDC * DC); +void GRSetColorPen(wxDC * DC, int Color , int width = 1); +void GRSetBrush(wxDC * DC, int Color , int fill = 0); +void GRForceBlackPen(bool flagforce ); +void SetPenMinWidth(int minwidth); /* ajustage de la largeur mini de plume */ + +void GRLine(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, int x2, int y2, int Color); +void GRMixedLine(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, int x2, int y2, int Color); +void GRSMixedLine(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, int x2, int y2, int Color); +void GRDashedLine(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, int x2, int y2, int Color); +void GRSDashedLine(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, int x2, int y2, int Color); +void GRDashedLineTo(EDA_Rect * ClipBox,wxDC * DC, int x2, int y2, int Color); +void GRSDashedLineTo(EDA_Rect * ClipBox,wxDC * DC, int x2, int y2, int Color); +void GRBusLine(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, int x2, int y2, int Color); +void GRSBusLine(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, int x2, int y2, int Color); +void GRSLine(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, int x2, int y2, int Color); +void GRMoveTo(int x, int y); +void GRSMoveTo(int x, int y); +void GRLineTo(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int Color); +void GRBusLineTo(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int Color); +void GRSLineTo(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int Color); +void GRMoveRel(int x, int y); +void GRSMoveRel(int x, int y); +void GRLineRel(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int Color); +void GRSLineRel(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int Color); +void GRPoly(EDA_Rect * ClipBox, wxDC * DC, int n, int *Points, + int Fill, int Color, int BgColor); +void GRPolyLines(EDA_Rect * ClipBox, wxDC * DC, int n, int *Points, + int Color, int BgColor, int width); +void GRClosedPoly(EDA_Rect * ClipBox, wxDC * DC, int n, int *Points, + int Fill, int Color, int BgColor); +void GRSPoly(EDA_Rect * ClipBox, wxDC * DC, int n, int *Points, + int Fill, int Color, int BgColor); +void GRSPolyLines(EDA_Rect * ClipBox, wxDC * DC, int n, int *Points, + int Color, int BgColor, int width); +void GRSClosedPoly(EDA_Rect * ClipBox, wxDC * DC, int n, int *Points, + int Fill, int Color, int BgColor); +void GRCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r, int Color); +void GRCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r, int width, int Color); +void GRFilledCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r, + int Color, int BgColor); +void GRSCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r, int Color); +void GRSCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r, int width, int Color); +void GRSFilledCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r, + int Color, int BgColor); +void GRArc(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int StAngle, int EndAngle, int r, int Color); +void GRArc(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int StAngle, int EndAngle, int r, int width, int Color); +void GRArc1(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int xc, int yc, int Color); +void GRArc1(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int xc, int yc, int width, int Color); +void GRSArc1(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int xc, int yc, int Color); +void GRSArc1(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int xc, int yc, int width, int Color); +void GRSArc(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int StAngle, int EndAngle, int r, int Color); +void GRSArc(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int StAngle, int EndAngle, int r, int width, int Color); +void GRFilledArc(EDA_Rect * ClipBox, wxDC * DC, int x, int y, + int StAngle, int EndAngle, int r, int Color, int BgColor); +void GRSFilledArc(EDA_Rect * ClipBox, wxDC * DC, int x, int y, + int StAngle, int EndAngle, int r, int Color, int BgColor); +void GRCSegm(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, int x2, int y2, int width, int Color); +void GRFillCSegm(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, int x2, int y2, int width, int Color); +void GRSCSegm(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, int x2, int y2, int width, int Color); +void GRSFillCSegm(EDA_Rect * ClipBox, wxDC * DC, + int x1, int y1, int x2, int y2, int width, int Color); + +void GRSetColor(int Color); +void GRSetDefaultPalette(void); +int GRGetColor(void); +void GRPutPixel(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int color); +void GRSPutPixel(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int color); +int GRGetPixel(wxDC * DC, int x, int y); +void GRFilledRect(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, + int x2, int y2, int Color, int BgColor); +void GRSFilledRect(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, + int x2, int y2, int Color, int BgColor); +void GRSFilledRect(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int Color, int BgColor); +void GRRect(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, + int x2, int y2, int Color); +void GRSRect(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, + int x2, int y2, int Color); + +/* Routines relatives a l'affichage des textes */ +void GRSetFont(wxDC * DC, wxFont * Font); +void GRResetTextFgColor(wxDC * DC); +void GRSetTextFgColor(wxDC * DC, int Color); +void GRSetTextFgColor(wxDC * DC, wxFont * Font, int Color); +int GRGetTextFgColor(wxDC * DC, wxFont * Font); +void GRSetTextBgColor(wxDC * DC, int Color); +void GRSetTextBgColor(wxDC * DC, wxFont * Font, int Color); +int GRGetTextBgColor(wxDC * DC, wxFont * Font); +void GRGetTextExtent(wxDC * DC, const wxChar * Text, long * width, long * height); + +#endif /* define GR_BASIC */ + diff --git a/include/grfonte.h b/include/grfonte.h new file mode 100644 index 0000000000..4a84fb2444 --- /dev/null +++ b/include/grfonte.h @@ -0,0 +1,270 @@ + /* grfonte.h : codage de la fonte de caracteres utilisee en trace de + textes graphiques */ +/* +formes des caracteres : definies sur matrice 10 x 13 sour forme de vecteurs +d'origine le debut du caractere (poSH_CODE matrice 0,0) sous forme d'une sequence +ascii .les lignes au dessous de 0,0 sont notees a,b,c. +conventions : + coord 0...9 : ascii '0'...'9' (2 octets successifs = 1 coord) + 'U' montee de plume + 'D' descente de plume + 'X' fin de trace + +la matrice totale du caractere est ici 12x9. et l'espacement est de 13 points + -2..0 = jambage au dessous de la ligne + 0..9 = cadre matrice +Version actuelle: + en X : dim 0..6 a ramener en 0..9 ( espacement = 13 ) +Matrice: + + 9 ---------- + 8 ---------- + 7 ---------- + 6 ---------- + 5 ---------- + 4 ---------- + 3 ---------- + 2 ---------- + 1 ---------- +___ 0 ---------- + -1 ---------- + -2 ---------- + -3 ---------- + 0123456789--- + + dans les descr ci dessous: + X = fin de descr + U = plume Up + D = plume Down + n, n = 2 nombres = coord X et Y ( ici = -3 ... +9 ) +*/ + +#ifndef _GRFONTE_H_ +#define _GRFONTE_H_ + +#define SH_CODE signed char +extern const SH_CODE *graphic_fonte_shape[256]; + +#ifdef EDA_DRAWBASE + +#define U (SH_CODE)'U' +#define X (SH_CODE)'X' +#define D (SH_CODE)'D' + +const SH_CODE noshape[] = {X}; //code non inscriptible +const SH_CODE char_shape_space[] = {U,X}; /* space */ +const SH_CODE char_shape_ipoint[] = {U,0,4,D,1,4,U,4,4,D,9,4,U,X}; /*!*/ +const SH_CODE char_shape_openacc[] = {U,8,3,D,9,4,U,8,5,D,9,6,U,X}; /*{*/ +const SH_CODE char_shape_dieze[] = {U,3,1,D,3,7,U,5,2,D,5,8,U,1,3,D,7,4,U,1,5,D,7,6,U,X}; /*#*/ +const SH_CODE char_shape_dollar[] = {U,0,4,D,9,4,U,0,5,D,9,5,U,0,2,D,0,7,1,8,3,8,4,7,4,2,5,1,7,1,8,2,8,7,U,X}; /*$*/ +const SH_CODE char_shape_percent[] = {U,0,1,D,9,8,U,9,1,D,7,1,7,3,9,3,9,1,U,0,6,D,0,8,2,8,2,6,0,6,U,X}; /*%*/ +const SH_CODE char_shape_and[] = {U,0,7,D,7,2,8,2,9,4,8,6,7,6,2,1,1,1,0,3,0,4,1,6,2,7,U,X}; /*&*/ +const SH_CODE char_shape_el[] = {U,9,4,D,7,3,U,X}; /*'*/ +const SH_CODE char_shape_openpar[] = {U,0,4,D,2,3,7,3,9,4,U,X}; /*(*/ +const SH_CODE char_shape_closepar[] = {U,0,4,D,2,5,7,5,9,4,U,X}; /*)*/ +const SH_CODE char_shape_star[] = {U,1,4,D,7,4,U,4,1,D,4,7,U,2,2,D,6,6,U,6,2,D,2,6,U,X}; /***/ +const SH_CODE char_shape_plus[] = {U,4,1,D,4,7,U,1,4,D,7,4,U,X}; /*+*/ +const SH_CODE char_shape_comma[] = {U,1,4,D,0,4,-3,3,U,X}; /*,*/ +const SH_CODE char_shape_minus[] = {U,4,2,D,4,7,U,X}; /*-*/ +const SH_CODE char_shape_point[] = {U,0,4,D,1,4,U,X}; /*.*/ +const SH_CODE char_shape_slash[] = {U,0,2,D,9,6,U,X}; /* / */ + +const SH_CODE char_shape_0[] = {U,0,1,D,9,8,U,1,1,D,8,1,9,2,9,7,8,8,1,8,0,7,0,2,1,1,U,X}; /*0*/ +const SH_CODE char_shape_1[] = {U,0,3,D,0,7,U,0,5,D,9,5,U,8,5,D,6,3,U,X}; /*1*/ +const SH_CODE char_shape_2[] = {U,0,8,D,0,1,3,1,4,2,4,7,5,8,8,8,9,7,9,2,8,1,U,X}; /*2*/ +const SH_CODE char_shape_3[] = {U,9,1,D,9,8,8,8,5,4,5,7,4,8,1,8,0,7,0,2,1,1,U,X}; /*3*/ +const SH_CODE char_shape_4[] = {U,0,6,D,9,6,2,1,2,8,U,X}; /*4*/ +const SH_CODE char_shape_5[] = {U,2,1,D,1,1,0,2,0,7,1,8,4,8,6,6,6,1,9,1,9,8,U,X}; /*5*/ +const SH_CODE char_shape_6[] = {U,8,8,D,9,7,9,2,8,1,1,1,0,2,0,7,1,8,4,8,5,7,5,2,4,1,U,X}; /*6*/ +const SH_CODE char_shape_7[] = {U,9,1,D,9,8,0,1,U,X}; /*7*/ +const SH_CODE char_shape_8[] = {U,0,2,D,1,1,4,1,5,2,5,7,6,8,8,8,9,7,9,2,8,1,6,1,5,2,U,5,7,D,4,8,1,8,0,7,0,2,U,X}; /*8*/ +const SH_CODE char_shape_9[] = {U,0,2,D,0,7,1,8,8,8,9,7,9,2,8,1,5,1,4,2,4,7,5,8,U,X}; /*9*/ + +const SH_CODE char_shape_dbpoint[] = {U,6,4,D,5,4,U,3,4,D,2,4,U,X}; /*:*/ +const SH_CODE char_shape_vpoint[] = {U,5,4,D,4,4,U,2,4,D,1,4,-2,3,U,X}; /*;*/ +const SH_CODE char_shape_less[] = {U,0,7,D,4,2,9,7,U,X}; /*<*/ +const SH_CODE char_shape_egal[] = {U,2,2,D,2,7,U,5,2,D,5,7,U,X}; /*=*/ +const SH_CODE char_shape_more[] = {U,0,2,D,4,7,9,2,U,X}; /*>*/ +const SH_CODE char_shape_intpoint[] = {U,0,4,D,1,4,U,3,4,D,4,4,5,6,6,7,8,7,9,6,9,2,8,1,U,X}; /*?*/ +const SH_CODE char_shape_arond[] = {U,0,8,D,0,3,2,1,6,1,8,3,8,6,6,8,3,8,3,5,4,4,5,5,5,8,U,X}; /*@*/ + +const SH_CODE char_shape_A[] = {U,0,1,D,7,1,9,3,9,6,7,8,0,8,U,5,1,D,5,8,U,X}; /*A*/ +const SH_CODE char_shape_B[] = {U,0,1,D,9,1,9,7,8,8,6,8,5,7,5,1,U,5,7,D,3,8,1,8,0,7,0,1,U,X}; /*B*/ +const SH_CODE char_shape_C[] = {U,1,8,D,0,7,0,2,1,1,8,1,9,2,9,7,8,8,U,X}; /*C*/ +const SH_CODE char_shape_D[] = {U,0,2,D,9,2,U,9,1,D,9,7,8,8,1,8,0,7,0,1,U,X}; /*D*/ +const SH_CODE char_shape_E[] = {U,0,8,D,0,1,9,1,9,8,U,5,1,D,5,5,U,X}; /*E*/ +const SH_CODE char_shape_F[] = {U,0,1,D,9,1,9,8,U,5,1,D,5,5,U,X}; /*F*/ +const SH_CODE char_shape_G[] = {U,8,7,D,9,7,9,2,8,1,1,1,0,2,0,7,1,8,4,8,4,5,U,X}; /*G*/ +const SH_CODE char_shape_H[] = {U,0,1,D,9,1,U,0,8,D,9,8,U,4,1,D,4,8,U,X}; /*H*/ +const SH_CODE char_shape_I[] = {U,0,2,D,0,6,U,0,4,D,9,4,U,9,2,D,9,6,U,X}; /*I*/ +const SH_CODE char_shape_J[] = {U,2,1,D,0,2,0,4,1,5,9,5,U,9,3,D,9,7,U,X}; /*J*/ +const SH_CODE char_shape_K[] = {U,0,1,D,9,1,U,9,7,D,5,1,0,8,U,X}; /*K*/ +const SH_CODE char_shape_L[] = {U,9,1,D,0,1,0,9,U,X}; /*L*/ +const SH_CODE char_shape_M[] = {U,0,1,D,9,1,5,5,9,9,0,9,U,X}; /*M*/ +const SH_CODE char_shape_N[] = {U,0,1,D,9,1,0,8,9,8,U,X}; /*N*/ +const SH_CODE char_shape_O[] = {U,0,2,D,1,1,8,1,9,2,9,7,8,8,1,8,0,7,0,2,U,X}; /*O*/ +const SH_CODE char_shape_P[] = {U,0,1,D,9,1,9,7,8,8,5,8,4,7,4,1,U,X}; /*P*/ +const SH_CODE char_shape_Q[] = {U,1,1,D,8,1,9,2,9,7,8,8,1,8,0,7,0,2,1,1,U,4,6,D,0,8,U,X}; /*Q*/ +const SH_CODE char_shape_R[] = {U,0,1,D,9,1,9,7,8,8,5,8,4,7,4,1,U,4,4,D,0,8,U,X}; /*R*/ +const SH_CODE char_shape_S[] = {U,1,1,D,0,2,0,7,1,8,4,8,5,7,5,2,6,1,8,1,9,2,9,7,8,8,U,X}; /*S*/ +const SH_CODE char_shape_T[] = {U,9,1,D,9,9,U,9,5,D,0,5,U,X}; /*T*/ +const SH_CODE char_shape_U[] = {U,9,1,D,1,1,0,2,0,7,1,8,9,8,U,X}; /*U,*/ +const SH_CODE char_shape_V[] = {U,9,1,D,0,5,9,9,U,X}; /*V*/ +const SH_CODE char_shape_W[] = {U,9,1,D,0,3,3,5,0,7,9,9,U,X}; /*W*/ +const SH_CODE char_shape_X[] = {U,0,1,D,9,8,U,9,1,D,0,8,U,X}; /*X*/ +const SH_CODE char_shape_Y[] = {U,9,1,D,4,5,9,9,U,4,5,D,0,5,U,X}; /*Y*/ +const SH_CODE char_shape_Z[] = {U,9,1,D,9,8,0,1,0,8,U,X}; /*Z*/ + +const SH_CODE char_shape_opencr[] = {U,0,5,D,0,3,9,3,9,5,U,X}; /*[*/ +const SH_CODE char_shape_backslash[] = {U,9,1,D,0,7,U,X}; /*\*/ +const SH_CODE char_shape_closecr[] = {U,0,3,D,0,5,9,5,9,3,U,X}; /*]*/ +const SH_CODE char_shape_xor[] = {U,7,1,D,9,5,7,8,U,X}; /*^*/ +const SH_CODE char_shape_underscore[] = {U,0,1,D,0,8,U,X}; /*_*/ +const SH_CODE char_shape_altel[] = {U,9,4,D,7,5,U,X}; /*`*/ + +const SH_CODE char_shape_a[] = {U,6,1,D,6,7,5,8,0,8,0,2,1,1,2,1,3,2,3,8,U,X}; /*a*/ +const SH_CODE char_shape_b[] = {U,9,1,D,0,1,0,8,4,8,5,7,5,1,U,X}; /*b*/ +const SH_CODE char_shape_c[] = {U,1,8,D,0,7,0,2,1,1,5,1,6,2,6,7,5,8,U,X}; /*c*/ +const SH_CODE char_shape_d[] = {U,9,8,D,0,8,0,2,1,1,5,1,6,2,6,8,U,X}; /*d*/ +const SH_CODE char_shape_e[] = {U,3,1,D,3,8,5,8,6,7,6,2,5,1,1,1,0,2,0,7,1,8,U,X}; /*e*/ +const SH_CODE char_shape_f[] = {U,0,2,D,8,2,9,3,9,7,8,8,U,5,1,D,5,4,U,X}; /*f*/ +const SH_CODE char_shape_g[] = {U,-2,1,D,-3,2,-3,7,-2,8,5,8,6,7,6,2,5,1,1,1,0,2,0,7,1,8,U,X}; /*g*/ +const SH_CODE char_shape_h[] = {U,0,1,D,9,1,U,5,1,D,6,2,6,7,5,8,0,8,U,X}; /*h*/ +const SH_CODE char_shape_i[] = {U,9,4,D,8,4,U,5,4,D,1,4,0,5,0,6,U,X}; /*i*/ +const SH_CODE char_shape_j[] = {U,9,4,D,8,4,U,5,4,D,-2,4,-3,3,-2,2,U,X}; /*j*/ +const SH_CODE char_shape_k[] = {U,0,2,D,9,2,U,3,2,D,3,3,6,8,U,3,3,D,0,8,U,X}; /*k*/ +const SH_CODE char_shape_l[] = {U,9,3,D,9,4,0,4,U,0,3,D,0,5,U,X}; /*l*/ +const SH_CODE char_shape_m[] = {U,0,1,D,6,1,U,5,1,D,6,2,6,4,5,5,0,5,U,5,5,D,6,6,6,8,5,9,0,9,U,X}; /*m*/ +const SH_CODE char_shape_n[] = {U,0,1,D,6,1,U,5,1,D,6,2,6,6,5,7,0,7,U,X}; /*n*/ +const SH_CODE char_shape_o[] = {U,0,2,D,1,1,5,1,6,2,6,7,5,8,1,8,0,7,0,2,U,X}; /*o*/ +const SH_CODE char_shape_p[] = {U,-3,1,D,6,1,U,5,1,D,6,2,6,7,5,8,1,8,0,7,0,2,1,1,U,X}; /*p*/ +const SH_CODE char_shape_q[] = {U,-3,8,D,6,8,U,5,8,D,6,7,6,2,5,1,1,1,0,2,0,7,1,8,U,X}; /*q*/ +const SH_CODE char_shape_r[] = {U,0,1,D,6,1,U,4,1,D,6,3,6,6,4,8,U,X}; /*r*/ +const SH_CODE char_shape_s[] = {U,1,1,D,0,2,0,7,1,8,2,8,3,7,3,2,4,1,5,1,6,2,6,7,5,8,U,X}; /*s*/ +const SH_CODE char_shape_t[] = {U,1,7,D,0,6,0,3,1,2,9,2,U,6,2,D,6,5,U,X}; /*t*/ +const SH_CODE char_shape_u[] = {U,6,1,D,2,1,0,3,0,6,2,8,6,8,U,X}; /*u*/ +const SH_CODE char_shape_v[] = {U,6,1,D,3,1,0,4,3,7,6,7,U,X}; /*v*/ +const SH_CODE char_shape_w[] = {U,6,1,D,2,1,0,3,2,5,0,7,2,9,6,9,U,X}; /*w*/ +const SH_CODE char_shape_x[] = {U,0,1,D,6,8,U,6,1,D,0,8,U,X}; /*x*/ +const SH_CODE char_shape_y[] = {U,6,1,D,2,1,0,3,0,6,2,8,U,6,8,D,-2,8,-3,7,-3,2,-2,1,U,X}; /*y*/ +const SH_CODE char_shape_z[] = {U,6,1,D,6,8,0,1,0,8,U,X}; /*z*/ + +const SH_CODE char_shape_opbrack[] = {U,9,5,D,8,4,6,4,5,3,4,3,3,4,1,4,0,5,U,X}; /*{*/ +const SH_CODE char_shape_or[] = {U,9,4,D,0,4,U,X}; /*|*/ +const SH_CODE char_shape_closebr[] = {U,9,3,D,8,4,6,4,5,5,4,5,3,4,1,4,0,3,U,X}; /*}*/ +const SH_CODE char_shape_tilda[] = {U,8,1,D,9,2,9,3,7,5,7,6,8,7,U,X}; /*~*/ +const SH_CODE char_shape_del[] = {X}; /**/ + +/* codes utiles >= 128 */ +const SH_CODE char_shape_C_Cedille[] = {U,1,8,D,0,7,0,2,1,1,8,1,9,2,9,7,8,8,U,X}; /* C cedille*/ +const SH_CODE char_shape_c_cedille[] = {U,1,8,D,0,7,0,2,1,1,5,1,6,2,6,7,5,8,U,0,4,D,-3,2,U,X}; /* ç */ +const SH_CODE char_shape_a_grave[] = {U,6,1,D,6,7,5,8,0,8,0,2,1,1,2,1,3,2,3,8,U,7,4,D,9,2,U,X}; +const SH_CODE char_shape_a_aigu[] = {U,6,1,D,6,7,5,8,0,8,0,2,1,1,2,1,3,2,3,8,U,7,2,D,9,4,U,X}; +const SH_CODE char_shape_a_circ[] = {U,6,1,D,6,7,5,8,0,8,0,2,1,1,2,1,3,2,3,8,U,7,1,D,9,4,7,7,U,X}; +const SH_CODE char_shape_a_trema[] = {U,6,1,D,6,7,5,8,0,8,0,2,1,1,2,1,3,2,3,8,U,9,2,D,9,3,U,9,5,D,9,6,U,X}; +const SH_CODE char_shape_e_grave[] = {U,3,1,D,3,8,5,8,6,7,6,2,5,1,1,1,0,2,0,7,1,8,U,7,4,D,9,2,U,X}; +const SH_CODE char_shape_e_aigu[] = {U,3,1,D,3,8,5,8,6,7,6,2,5,1,1,1,0,2,0,7,1,8,U,7,3,D,9,5,U,X}; +const SH_CODE char_shape_e_circ[] = {U,3,1,D,3,8,5,8,6,7,6,2,5,1,1,1,0,2,0,7,1,8,U,7,1,D,9,4,7,7,U,X}; +const SH_CODE char_shape_e_trema[] = {U,3,1,D,3,8,5,8,6,7,6,2,5,1,1,1,0,2,0,7,1,8,U,9,2,D,9,3,U,9,5,D,9,6,U,X}; +const SH_CODE char_shape_i_trema[] = {U,5,4,D,1,4,0,5,0,6,U,9,2,D,9,3,U,9,5,D,9,6,U,X}; +const SH_CODE char_shape_i_circ[] = {U,5,4,D,1,4,0,5,0,6,U,7,1,D,9,4,7,7,U,X}; +const SH_CODE char_shape_u_grave[] = {U,6,1,D,2,1,0,3,0,6,2,8,6,8,U,7,4,D,9,2,U,X}; +const SH_CODE char_shape_o_trema[] = {U,0,2,D,1,1,5,1,6,2,6,7,5,8,1,8,0,7,0,2,U,9,2,D,9,3,U,9,5,D,9,6,U,X}; +const SH_CODE char_shape_o_circ[] = {U,0,2,D,1,1,5,1,6,2,6,7,5,8,1,8,0,7,0,2,U,7,2,D,9,4,7,7,U,X}; +const SH_CODE char_shape_u_circ[] = {U,6,1,D,2,1,0,3,0,6,2,8,6,8,U,7,1,D,9,4,7,7,U,X}; +const SH_CODE char_shape_u_trema[] = {U,6,1,D,2,1,0,3,0,6,2,8,6,8,U,9,2,D,9,3,U,9,5,D,9,6,U,X}; + +const SH_CODE *graphic_fonte_shape[256] = + { + // codes 0..31: + noshape, noshape, noshape, noshape, noshape, noshape, noshape, noshape, + noshape, noshape, noshape, noshape, noshape, noshape, noshape, noshape, + noshape, noshape, noshape, noshape, noshape, noshape, noshape, noshape, + noshape, noshape, noshape, noshape, noshape, noshape, noshape, noshape, + // codes 32 .. 127: + char_shape_space, /* space */ + char_shape_ipoint, /*!*/ + char_shape_openacc, + char_shape_dieze, + char_shape_dollar, + char_shape_percent, + char_shape_and, + char_shape_el, + char_shape_openpar, + char_shape_closepar, + char_shape_star, + char_shape_plus, + char_shape_comma, + char_shape_minus, + char_shape_point, + char_shape_slash, + char_shape_0, char_shape_1, char_shape_2, char_shape_3, char_shape_4, char_shape_5, char_shape_6, char_shape_7, char_shape_8, char_shape_9, + char_shape_dbpoint, + char_shape_vpoint, + char_shape_less, + char_shape_egal, + char_shape_more, + char_shape_intpoint, + char_shape_arond, + + char_shape_A, char_shape_B, char_shape_C, char_shape_D, char_shape_E, char_shape_F, char_shape_G, char_shape_H, char_shape_I, + char_shape_J, char_shape_K, char_shape_L, char_shape_M, char_shape_N, char_shape_O, char_shape_P, char_shape_Q, char_shape_R, + char_shape_S, char_shape_T, char_shape_U, char_shape_V, char_shape_W, char_shape_X, char_shape_Y, char_shape_Z, + + char_shape_opencr, + char_shape_backslash, + char_shape_closecr, + char_shape_xor, + char_shape_underscore, + char_shape_altel, + + char_shape_a, char_shape_b, char_shape_c, char_shape_d, char_shape_e, char_shape_f, char_shape_g, char_shape_h, char_shape_i, + char_shape_j, char_shape_k, char_shape_l, char_shape_m, char_shape_n, char_shape_o, char_shape_p, char_shape_q, char_shape_r, + char_shape_s, char_shape_t, char_shape_u, char_shape_v, char_shape_w, char_shape_x, char_shape_y, char_shape_z, + + char_shape_opbrack, + char_shape_or, + char_shape_closebr, + char_shape_tilda, + char_shape_del, + // codes >= 128: + noshape, noshape, noshape, noshape, // 128..131 + noshape, noshape, noshape, noshape, // 132..135 + noshape, noshape, noshape, noshape, //136..139 + noshape, noshape, noshape, noshape, //140..143 + noshape, noshape, noshape, noshape, //144..147 + noshape, noshape, noshape, noshape, //148..151 + noshape, noshape, noshape, noshape, //152..155 + noshape, noshape, noshape, noshape, //156..159 + + noshape, noshape, noshape, noshape, //160..163 + noshape, noshape, noshape, noshape, //164..167 + noshape, noshape, noshape, noshape, // 168..171 + noshape, noshape, noshape, noshape, //172..175 + noshape, noshape, noshape, noshape, //176..179 + noshape, noshape, noshape, noshape, //180..183 + noshape, noshape, noshape, noshape, //184..187 + noshape, noshape, noshape, noshape, //188..191 + + noshape, noshape, noshape, noshape, //192..195 + noshape, noshape, noshape, char_shape_C_Cedille, //196..199 + noshape, noshape, noshape, noshape, // 200..203 + noshape, noshape, noshape, noshape, //204..207 + noshape, noshape, noshape, noshape, //208..211 + noshape, noshape, noshape, noshape, //212..215 + noshape, noshape, noshape, noshape, //216..219 + noshape, noshape, noshape, noshape, //220..223 + + char_shape_a_grave, char_shape_a_aigu, char_shape_a_circ, noshape, //224..227 + char_shape_a_trema, noshape, noshape, char_shape_c_cedille, //228..231 + char_shape_e_grave, char_shape_e_aigu, char_shape_e_circ, char_shape_e_trema, //232..235 + noshape, noshape, char_shape_i_circ, char_shape_i_trema, //236..239 + noshape, noshape, noshape, noshape, //240..243 + char_shape_o_circ, noshape, char_shape_o_trema, noshape, //244..247 + noshape, char_shape_u_grave, noshape, char_shape_u_circ, //248..251 + char_shape_u_trema, noshape, noshape, noshape, //252..255 + + } ; +#endif +#endif // ifndef _GRFONTE_H_ + diff --git a/include/id.h b/include/id.h new file mode 100644 index 0000000000..93b88b60e2 --- /dev/null +++ b/include/id.h @@ -0,0 +1,840 @@ +/* Liste des identificateurs des boutons et menus */ +#ifndef ID_H +#define ID_H + +enum main_id { + ID_MAIN_FRAME = 100, + ID_LEFT_FRAME, + ID_BOTTOM_FRAME, + ID_MAIN_DIALOG, + ID_PROJECT_TREE, + ID_MAIN_COMMAND, + ID_TO_EDITOR, + ID_TO_EESCHEMA, + ID_TO_GERBVIEW, + ID_TO_PCB, + ID_TO_CVPCB, + ID_MAIN_MENUBAR, + ID_ON_ZOOM_SELECT, + ID_ON_GRID_SELECT, + ID_BROWSE_AN_SELECT_FILE, + ID_SELECT_PREFERED_EDITOR, + ID_SELECT_PREFERED_PDF_BROWSER_NAME, + ID_SELECT_PREFERED_PDF_BROWSER, + ID_SELECT_DEFAULT_PDF_BROWSER, + ID_SAVE_AND_ZIP_FILES, + ID_READ_ZIP_ARCHIVE, + + // ID du menu general + ID_LOAD_PROJECT, + ID_LOAD_ONE_SHEET, + ID_NEW_PROJECT, + ID_LOAD_FILE_1, + ID_LOAD_FILE_2, + ID_LOAD_FILE_3, + ID_LOAD_FILE_4, + ID_LOAD_FILE_5, + ID_LOAD_FILE_6, + ID_LOAD_FILE_7, + ID_LOAD_FILE_8, + ID_LOAD_FILE_9, + ID_LOAD_FILE_10, + + ID_SAVE_PROJECT, + ID_SAVE_ONE_SHEET, + ID_SAVE_ONE_SHEET_AS, + + ID_CONFIG_REQ, + ID_CONFIG_SAVE, + ID_CONFIG_READ, + + ID_GEN_PRINT, + ID_GEN_PLOT, + ID_GEN_PLOT_PS, + ID_GEN_PLOT_HPGL, + ID_GEN_PLOT_GERBER, + ID_GEN_PLOT_SVG, + ID_GEN_COPY_SHEET_TO_CLIPBOARD, + ID_GEN_COPY_BLOCK_TO_CLIPBOARD, + ID_GEN_UNUSED0, + ID_GEN_UNUSED1, + ID_GEN_UNUSED2, + ID_GEN_UNUSED3, + ID_GEN_UNUSED4, + + ID_GEN_EXPORT_FILE, + ID_GEN_EXPORT_FILE_GENCADFORMAT, + ID_GEN_EXPORT_FILE_MODULE_REPORT, + ID_GEN_EXPORT_FILE_FORMAT_2, // Not used + ID_GEN_EXPORT_FILE_FORMAT_3, // Not used + ID_GEN_EXPORT_FILE_FORMAT_4, // Not used + + ID_EXIT, + ID_OPTIONS_SETUP, + + ID_PREFERENCES_FONT, + ID_PREFERENCES_FONT_INFOSCREEN, + ID_PREFERENCES_FONT_DIALOG, + ID_PREFERENCES_FONT_STATUS, + ID_PREFERENCES_UNUSED3, + ID_PREFERENCES_UNUSED4, + ID_PREFERENCES_UNUSED5, + ID_PREFERENCES_UNUSED6, + ID_PREFERENCES_UNUSED7, + ID_PREFERENCES_FONT_END, + + // Find id menu + ID_H_TOOLBAR, + ID_V_TOOLBAR, + ID_OPT_TOOLBAR, + ID_AUX_TOOLBAR, + ID_AUX_V_TOOLBAR, + ID_TOOLBAR_UNUSED, + + ID_GENERAL_HELP, + ID_LOCAL_HELP, + ID_KICAD_ABOUT, + + ID_EDIT, + + ID_SEL_BG_COLOR, + + ID_COLORS_SETUP, + + ID_REPEAT_BUTT, + ID_UNDO_BUTT, + ID_REDO_BUTT, + + ID_LANGUAGE_CHOICE, + ID_LANGUAGE_DEFAULT, + ID_LANGUAGE_ENGLISH, + ID_LANGUAGE_FRENCH, + ID_LANGUAGE_SPANISH, + ID_LANGUAGE_GERMAN, + ID_LANGUAGE_RUSSIAN, + ID_LANGUAGE_PORTUGUESE, + ID_LANGUAGE_ITALIAN, + ID_LANGUAGE_SLOVENIAN, + ID_LANGUAGE_HUNGARIAN, + ID_LANGUAGE_POLISH, + ID_LANGUAGE_KOREAN, + ID_LANGUAGE_UNUSED2, + ID_LANGUAGE_UNUSED3, + ID_LANGUAGE_UNUSED4, + ID_LANGUAGE_CHOICE_END, + + + // ID du Main Toolbar de Schematique + + ID_SCHEMATIC_MAIN_TOOLBAR_START, + ID_SCHEMATIC_UNDO, + ID_SCHEMATIC_REDO, + ID_SCHEMATIC_MAIN_TOOLBAR_END, + + // ID du Vertical Toolbar de Schematique + ID_SCHEMATIC_VERTICAL_TOOLBAR_START, + ID_NO_SELECT_BUTT, + ID_HIERARCHY_PUSH_POP_BUTT, + ID_COMPONENT_BUTT, + ID_PLACE_POWER_BUTT, + ID_BUS_BUTT, + ID_WIRE_BUTT, + ID_BUSTOBUS_ENTRY_BUTT, + ID_WIRETOBUS_ENTRY_BUTT, + ID_LABEL_BUTT, + ID_GLABEL_BUTT, + ID_IMPORT_GLABEL_BUTT, + ID_SHEET_LABEL_BUTT, + ID_NOCONN_BUTT, + ID_JUNCTION_BUTT, + ID_SHEET_SYMBOL_BUTT, + ID_TEXT_COMMENT_BUTT, + ID_LINE_COMMENT_BUTT, + ID_SCHEMATIC_DELETE_ITEM_BUTT, + ID_SCHEMATIC_UNUSED0, + ID_SCHEMATIC_UNUSED1, + ID_SCHEMATIC_UNUSED2, + ID_SCHEMATIC_VERTICAL_TOOLBAR_END, + // end ID Vertical Toolbar de Schematique + + ID_SET_REPEAT_OPTION, + + // Popup Menu (mouse Right button) (id consecutifs) + + ID_POPUP_GENERAL_START_RANGE, // first number + ID_POPUP_CANCEL_CURRENT_COMMAND, // ID general annulation commande en cours + ID_POPUP_CLOSE_CURRENT_TOOL, + ID_POPUP_MOVE_BLOCK, + ID_POPUP_DRAG_BLOCK, + ID_POPUP_COPY_BLOCK, + ID_POPUP_ROTATE_BLOCK, + ID_POPUP_DELETE_BLOCK, + ID_POPUP_INVERT_BLOCK, + ID_POPUP_PLACE_BLOCK, + ID_POPUP_ZOOM_BLOCK, + ID_POPUP_SELECT_ITEMS_BLOCK, + ID_POPUP_MIRROR_X_BLOCK, + ID_POPUP_MIRROR_Y_BLOCK, + ID_POPUP_MIRROR_UNUSED0, + ID_POPUP_MIRROR_UNUSED1, + ID_POPUP_MIRROR_UNUSED2, + ID_POPUP_MIRROR_UNUSED3, + ID_POPUP_OTHER_COMMANDS, + ID_POPUP_GENERAL_END_RANGE, // last number + + ID_POPUP_ENTER_MENU, + + ID_POPUP_ZOOM_START_RANGE, // first number + ID_POPUP_CANCEL, + ID_POPUP_ZOOM_PLUS, + ID_POPUP_ZOOM_MOINS, + ID_POPUP_ZOOM_SELECT, + ID_POPUP_ZOOM_CENTER, + ID_POPUP_ZOOM_AUTO, + ID_POPUP_ZOOM_REDRAW, + ID_POPUP_ZOOM_LEVEL_1, + ID_POPUP_ZOOM_LEVEL_2, + ID_POPUP_ZOOM_LEVEL_4, + ID_POPUP_ZOOM_LEVEL_8, + ID_POPUP_ZOOM_LEVEL_16, + ID_POPUP_ZOOM_LEVEL_32, + ID_POPUP_ZOOM_LEVEL_64, + ID_POPUP_ZOOM_LEVEL_128, + ID_POPUP_ZOOM_LEVEL_256, + ID_POPUP_ZOOM_LEVEL_512, + ID_POPUP_ZOOM_LEVEL_1024, + ID_POPUP_ZOOM_LEVEL_2048, + ID_POPUP_GRID_PLUS, + ID_POPUP_GRID_MOINS, + ID_POPUP_GRID_SELECT, + ID_POPUP_GRID_LEVEL_1000, + ID_POPUP_GRID_LEVEL_500, + ID_POPUP_GRID_LEVEL_250, + ID_POPUP_GRID_LEVEL_200, + ID_POPUP_GRID_LEVEL_100, + ID_POPUP_GRID_LEVEL_50, + ID_POPUP_GRID_LEVEL_25, + ID_POPUP_GRID_LEVEL_20, + ID_POPUP_GRID_LEVEL_10, + ID_POPUP_GRID_LEVEL_5, + ID_POPUP_GRID_LEVEL_2, + ID_POPUP_GRID_LEVEL_1, + ID_POPUP_GRID_USER, + ID_POPUP_ZOOM_UNUSED0, + ID_POPUP_ZOOM_UNUSED1, + ID_POPUP_ZOOM_END_RANGE, // last number + + + ID_POPUP_START_RANGE, // first number + ID_POPUP_LIBEDIT_PIN_EDIT, // Id pour menu PopUp de Libedit + ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_ITEM, + ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM, + ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM, + ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM, + ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, // Id pour menu PopUp de Libedit + ID_POPUP_LIBEDIT_DELETE_ITEM, + ID_POPUP_LIBEDIT_END_CREATE_ITEM, + ID_POPUP_LIBEDIT_CANCEL_EDITING, + ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, + ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM, + ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM, + + ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT, + ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT, + ID_POPUP_LIBEDIT_UNUSED2, // En attente d'affectation + ID_POPUP_LIBEDIT_UNUSED3, // En attente d'affectation + ID_POPUP_LIBEDIT_UNUSED4, // En attente d'affectation + ID_POPUP_LIBEDIT_UNUSED5, // En attente d'affectation + + ID_POPUP_SCH_DELETE, + ID_POPUP_SCH_BREAK_WIRE, + ID_POPUP_SCH_DELETE_CONNECTION, + ID_POPUP_SCH_MOVE_ITEM_REQUEST, + ID_POPUP_SCH_DELETE_NODE, + ID_POPUP_SCH_MOVE_CMP_REQUEST, + ID_POPUP_SCH_DELETE_CMP, + ID_POPUP_SCH_UNUSED_0, + ID_POPUP_SCH_UNUSED_1, + ID_POPUP_SCH_UNUSED_2, + ID_POPUP_SCH_ENTRY_SELECT_SLASH, + ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH, + + ID_POPUP_SCH_EDIT_CMP, + ID_POPUP_SCH_MIROR_X_CMP, + ID_POPUP_SCH_MIROR_Y_CMP, + ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE, + ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE, + ID_POPUP_SCH_ORIENT_NORMAL_CMP, + ID_POPUP_SCH_INIT_CMP, + + ID_POPUP_SCH_EDIT_TEXT, + ID_POPUP_SCH_ROTATE_TEXT, + ID_POPUP_SCH_SET_SHAPE_TEXT, + ID_POPUP_END_LINE, + ID_POPUP_SCH_END_SHEET, + ID_POPUP_SCH_EDIT_SHEET, + ID_POPUP_SCH_RESIZE_SHEET, + ID_POPUP_SCH_CLEANUP_SHEET, + ID_POPUP_SCH_EDIT_PINSHEET, + ID_POPUP_SCH_MOVE_PINSHEET, + ID_POPUP_SCH_GENERIC_ORIENT_CMP, + ID_POPUP_SCH_GENERIC_EDIT_CMP, + ID_POPUP_SCH_EDIT_VALUE_CMP, + ID_POPUP_SCH_EDIT_REF_CMP, + ID_POPUP_SCH_EDIT_CONVERT_CMP, + ID_POPUP_SCH_COPY_COMPONENT_CMP, + ID_POPUP_SCH_SELECT_UNIT_CMP, + ID_POPUP_SCH_SELECT_UNIT1, + ID_POPUP_SCH_SELECT_UNIT2, + ID_POPUP_SCH_SELECT_UNIT3, + ID_POPUP_SCH_SELECT_UNIT4, + ID_POPUP_SCH_SELECT_UNIT5, + ID_POPUP_SCH_SELECT_UNIT6, + ID_POPUP_SCH_SELECT_UNIT7, + ID_POPUP_SCH_SELECT_UNIT8, + ID_POPUP_SCH_SELECT_UNIT9, + ID_POPUP_SCH_SELECT_UNIT10, + ID_POPUP_SCH_SELECT_UNIT11, + ID_POPUP_SCH_SELECT_UNIT12, + ID_POPUP_SCH_SELECT_UNIT13, + ID_POPUP_SCH_SELECT_UNIT14, + ID_POPUP_SCH_SELECT_UNIT15, + ID_POPUP_SCH_SELECT_UNIT16, + ID_POPUP_SCH_SELECT_UNIT17, + ID_POPUP_SCH_SELECT_UNIT18, + ID_POPUP_SCH_SELECT_UNIT19, + ID_POPUP_SCH_SELECT_UNIT20, + ID_POPUP_SCH_SELECT_UNIT21, + ID_POPUP_SCH_SELECT_UNIT22, + ID_POPUP_SCH_SELECT_UNIT23, + ID_POPUP_SCH_SELECT_UNIT24, + ID_POPUP_SCH_SELECT_UNIT25, + ID_POPUP_SCH_SELECT_UNIT26, + ID_POPUP_SCH_ROTATE_FIELD, + ID_POPUP_SCH_EDIT_FIELD, + ID_POPUP_SCH_CHANGE_TYPE_TEXT, + ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL, + ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL, + ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT, + ID_POPUP_SCH_DISPLAYDOC_CMP, + ID_POPUP_SCH_ENTER_SHEET, + ID_POPUP_SCH_LEAVE_SHEET, + ID_POPUP_SCH_ADD_JUNCTION, + ID_POPUP_SCH_ADD_LABEL, + ID_POPUP_SCH_ADD_GLABEL, + ID_POPUP_SCH_UNUSED0, + ID_POPUP_SCH_UNUSED1, + ID_POPUP_SCH_UNUSED2, + ID_POPUP_SCH_UNUSED3, + + ID_POPUP_END_RANGE, // last number + + // Horizontal Toolbar de schematique + ID_SHEET_SET, + ID_HIERARCHY, + ID_TO_LIBRARY, + ID_TO_LIBVIEW, + + ID_ZOOM_PLUS_BUTT, // Gestion zoom: id consecutifs + ID_ZOOM_MOINS_BUTT, + ID_ZOOM_REDRAW_BUTT, + ID_ZOOM_PAGE_BUTT, + ID_ZOOM_WINDOW_BUTT, + ID_ZOOM_PLUS_KEY, + ID_ZOOM_MOINS_KEY, + ID_ZOOM_REDRAW_KEY, + ID_ZOOM_CENTER_KEY, + ID_ZOOM_AUTO, + ID_ZOOM_PANNING_UP, + ID_ZOOM_PANNING_DOWN, + ID_ZOOM_PANNING_LEFT, + ID_ZOOM_PANNING_RIGHT, + ID_ZOOM_UNUSED0, + ID_ZOOM_UNUSED1, + ID_ZOOM_UNUSED2, + ID_ZOOM_UNUSED3, + ID_ZOOM_ENDLIST, + + ID_GET_ANNOTATE, // Gestion fonctions : id consecutifs + ID_GET_ERC, + ID_GET_NETLIST, + ID_GET_TOOLS, + ID_FIND_ITEMS, + + // Id pour HToolBar de Libview (Process_Special_Functions) + ID_LIBVIEW_START_H_TOOL, + ID_LIBVIEW_NEXT, + ID_LIBVIEW_PREVIOUS, + ID_LIBVIEW_SELECT_PART, + ID_LIBVIEW_SELECT_LIB, + ID_LIBVIEW_VIEWDOC, + ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, + ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, + ID_LIBVIEW_TOOL_UNUSED0, + ID_LIBVIEW_TOOL_UNUSED1, + ID_LIBVIEW_END_H_TOOL, + ID_LIBVIEW_SELECT_PART_NUMBER, + ID_LIBVIEW_LIB_LIST, + ID_LIBVIEW_CMP_LIST, + ID_LIBVIEW_UNUSED0, + ID_LIBVIEW_UNUSED1, + ID_LIBVIEW_UNUSED3, + ID_LIBVIEW_UNUSED4, + ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC, // Used in Htoolbar, specific function + + /* LibEdit: */ + /* Id for HToolBar Tools( buttons) for Libedit (Process_Special_Functions) */ + ID_LIBEDIT_START_H_TOOL, + ID_LIBEDIT_SELECT_PART, + ID_LIBEDIT_SELECT_CURRENT_LIB, + ID_LIBEDIT_SAVE_CURRENT_LIB, + ID_LIBEDIT_SAVE_CURRENT_PART, + ID_LIBEDIT_NEW_PART, + ID_LIBEDIT_GET_FRAME_EDIT_PART, + ID_LIBEDIT_DELETE_PART, + ID_LIBEDIT_IMPORT_PART, + ID_LIBEDIT_EXPORT_PART, + ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, + ID_LIBEDIT_UNDO, + ID_LIBEDIT_REDO, + ID_DE_MORGAN_NORMAL_BUTT, + ID_DE_MORGAN_CONVERT_BUTT, + ID_LIBEDIT_EDIT_PIN_BY_PIN, + ID_LIBEDIT_VIEW_DOC, + ID_LIBEDIT_CHECK_PART, + ID_LIBEDIT_END_H_TOOL, // End Id for HToolBar (Libedit) + ID_LIBEDIT_SELECT_PART_NUMBER, // Id selection unit of part (HToolBar, combo box) + ID_LIBEDIT_SELECT_ALIAS, // Id selection alias of part (HToolBar, combo box) + ID_LIBEDIT_HTOOL_UNUSED1, + ID_LIBEDIT_HTOOL_UNUSED2, + ID_LIBEDIT_HTOOL_UNUSED3, + ID_LIBEDIT_HTOOL_UNUSED4, + + /* Id pour VToolBar de Libedit */ + ID_LIBEDIT_START_V_TOOL, + ID_LIBEDIT_PIN_BUTT, + ID_LIBEDIT_BODY_LINE_BUTT, + ID_LIBEDIT_BODY_ARC_BUTT, + ID_LIBEDIT_BODY_CIRCLE_BUTT, + ID_LIBEDIT_BODY_RECT_BUTT, + ID_LIBEDIT_BODY_TEXT_BUTT, + ID_LIBEDIT_DELETE_ITEM_BUTT, + ID_LIBEDIT_ANCHOR_ITEM_BUTT, + ID_LIBEDIT_IMPORT_BODY_BUTT, + ID_LIBEDIT_EXPORT_BODY_BUTT, + ID_LIBEDIT_VTOOL_UNUSED0, + ID_LIBEDIT_VTOOL_UNUSED1, + ID_LIBEDIT_VTOOL_UNUSED2, + ID_LIBEDIT_VTOOL_UNUSED3, + ID_LIBEDIT_VTOOL_UNUSED4, + ID_LIBEDIT_END_V_TOOL, // End Id pour VToolBar de Libedit + + // ID pour CVPCB + ID_CVPCB_START_TOOL, + ID_CVPCB_QUIT, + ID_CVPCB_READ_INPUT_NETLIST, + ID_CVPCB_SAVEQUITCVPCB, + ID_CVPCB_CREATE_CONFIGWINDOW, + ID_CVPCB_CREATE_SCREENCMP, + ID_CVPCB_GOTO_FIRSTNA, + ID_CVPCB_GOTO_PREVIOUSNA, + ID_CVPCB_DEL_ASSOCIATIONS, + ID_CVPCB_AUTO_ASSOCIE, + ID_CVPCB_DISPLAY_HELP, + ID_CVPCB_DISPLAY_LICENCE, + ID_CVPCB_END_TOOL, + ID_CVPCB_COMPONENT_LIST, + ID_CVPCB_FOOTPRINT_LIST, + ID_CVPCB_CREATE_STUFF_FILE, + ID_CVPCB_SHOW3D_FRAME, + ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, + ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, + ID_CVPCB_UNUSED0, + ID_CVPCB_UNUSED1, + ID_CVPCB_UNUSED2, + ID_CVPCB_UNUSED3, + + // id specifiques pcbnew + ID_LOAD_FILE, + ID_APPEND_FILE, + ID_NEW_BOARD, + ID_OPEN_MODULE_EDITOR, + ID_UNNUSED_BUTT, + ID_TRACK_BUTT, + ID_PCB_ZONES_BUTT, + ID_PCB_DELETE_ITEM_BUTT, + ID_READ_NETLIST, + ID_DRC_CONTROL, + ID_PCB_CIRCLE_BUTT, + ID_PCB_ARC_BUTT, + ID_PCB_HIGHLIGHT_BUTT, + ID_PCB_MIRE_BUTT, + ID_PCB_SHOW_1_RATSNEST_BUTT, + ID_PCB_PLACE_OFFSET_COORD_BUTT, + ID_PCB_UNUSED_BUTT0, + ID_PCB_UNUSED_BUTT1, + ID_PCB_UNUSED_BUTT2, + ID_PCB_UNUSED_BUTT3, + + ID_POPUP_PCB_START_RANGE, + ID_POPUP_PCB_MOVE_MODULE_REQUEST, + ID_POPUP_PCB_DRAG_MODULE_REQUEST, + ID_POPUP_PCB_EDIT_MODULE, + ID_POPUP_PCB_CHANGE_SIDE_MODULE, + ID_POPUP_PCB_DELETE_MODULE, + ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE, + ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE, + + + ID_POPUP_PCB_EDIT_PAD, + ID_POPUP_PCB_EDIT_MORE_PAD, + ID_POPUP_PCB_EDIT_PADS_ON_MODULE, + ID_POPUP_PCB_DELETE_PAD, + ID_POPUP_PCB_ADD_PAD, + ID_POPUP_PCB_NEWSIZE_PAD, + ID_POPUP_PCB_ROTATE_PAD, + ID_POPUP_PCB_MOVE_PAD_REQUEST, + ID_POPUP_PCB_DRAG_PAD_REQUEST, + + ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST, + ID_POPUP_PCB_ROTATE_TEXTMODULE, + ID_POPUP_PCB_EDIT_TEXTMODULE, + ID_POPUP_PCB_DELETE_TEXTMODULE, + + ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST, + ID_POPUP_PCB_ROTATE_TEXTEPCB, + ID_POPUP_PCB_EDIT_TEXTEPCB, + ID_POPUP_PCB_DELETE_TEXTEPCB, + + ID_POPUP_PCB_MOVE_DRAWING_REQUEST, + ID_POPUP_PCB_EDIT_DRAWING, + ID_POPUP_PCB_DELETE_DRAWING, + ID_POPUP_PCB_DELETE_DRAWING_LAYER, + + ID_POPUP_PCB_EDIT_TRACK, + ID_POPUP_PCB_DELETE_TRACKSEG, + ID_POPUP_PCB_DELETE_TRACK, + ID_POPUP_PCB_DELETE_TRACKNET, + ID_POPUP_PCB_DELETE_TRACK_MNU, + ID_POPUP_PCB_EDIT_ZONE, + ID_POPUP_PCB_DELETE_ZONE, + + ID_POPUP_PCB_DELETE_MARKER, + ID_POPUP_PCB_DELETE_COTATION, + + ID_POPUP_PCB_MOVE_MIRE_REQUEST, + ID_POPUP_PCB_DELETE_MIRE, + ID_POPUP_PCB_EDIT_MIRE, + + ID_POPUP_PCB_STOP_CURRENT_DRAWING, + + ID_POPUP_PCB_EDIT_COTATION, + ID_POPUP_PCB_END_TRACK, + ID_POPUP_PCB_PLACE_VIA, + + ID_POPUP_PCB_IMPORT_PAD_SETTINGS, + ID_POPUP_PCB_EXPORT_PAD_SETTINGS, + + ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE, + ID_POPUP_PCB_DELETE_EDGE_ZONE, + ID_POPUP_PCB_DELETE_ZONE_LIMIT, + ID_POPUP_PCB_FILL_ZONE, + ID_POPUP_PCB_SELECT_NET_ZONE, + + ID_POPUP_PCB_SELECT_WIDTH, + ID_POPUP_PCB_SELECT_WIDTH1, + ID_POPUP_PCB_SELECT_WIDTH2, + ID_POPUP_PCB_SELECT_WIDTH3, + ID_POPUP_PCB_SELECT_WIDTH4, + ID_POPUP_PCB_SELECT_WIDTH5, + ID_POPUP_PCB_SELECT_WIDTH6, + ID_POPUP_PCB_SELECT_WIDTH7, + ID_POPUP_PCB_SELECT_WIDTH8, + ID_POPUP_PCB_SELECT_VIASIZE, + ID_POPUP_PCB_SELECT_VIASIZE1, + ID_POPUP_PCB_SELECT_VIASIZE2, + ID_POPUP_PCB_SELECT_VIASIZE3, + ID_POPUP_PCB_SELECT_VIASIZE4, + ID_POPUP_PCB_SELECT_VIASIZE5, + ID_POPUP_PCB_SELECT_VIASIZE6, + ID_POPUP_PCB_SELECT_VIASIZE7, + ID_POPUP_PCB_SELECT_VIASIZE8, + ID_POPUP_PCB_EDIT_TRACKSEG, + ID_POPUP_PCB_EDIT_TRACK_MNU, + ID_POPUP_PCB_EDIT_NET, + ID_POPUP_PCB_SELECT_LAYER, + ID_POPUP_PCB_SELECT_CU_LAYER, + ID_POPUP_PCB_SELECT_NO_CU_LAYER, + ID_POPUP_PCB_SELECT_LAYER_PAIR, + ID_POPUP_PCB_EDIT_EDGE, + ID_POPUP_PCB_DELETE_EDGE, + ID_POPUP_PCB_MOVE_EDGE, + ID_POPUP_PCB_PLACE_EDGE, + ID_POPUP_PCB_END_EDGE, + ID_POPUP_PCB_LOCK_ON_TRACKSEG, + ID_POPUP_PCB_LOCK_OFF_TRACKSEG, + ID_POPUP_PCB_LOCK_ON_TRACK, + ID_POPUP_PCB_LOCK_OFF_TRACK, + ID_POPUP_PCB_LOCK_ON_NET, + ID_POPUP_PCB_LOCK_OFF_NET, + ID_POPUP_PCB_SETFLAGS_TRACK_MNU, + + ID_POPUP_PCB_AUTOROUTE_GET_AUTOROUTER, + ID_POPUP_PCB_AUTOROUTE_GET_AUTOROUTER_DATA, + ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE, + ID_POPUP_PCB_EDIT_WIDTH_ALL_EDGE, + ID_POPUP_PCB_EDIT_LAYER_CURRENT_EDGE, + ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE, + ID_POPUP_PCB_ENTER_EDGE_WIDTH, + ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS, + ID_POPUP_PCB_EDIT_ALL_VIAS_AND_TRACK_SIZE, + ID_POPUP_PCB_EDIT_ALL_VIAS_SIZE, + ID_POPUP_PCB_EDIT_ALL_TRACK_SIZE, + ID_POPUP_PCB_DISPLAY_FOOTPRINT_DOC, + ID_POPUP_PCB_MOVE_TRACK_NODE, + ID_POPUP_PCB_BREAK_TRACK, + ID_POPUP_PCB_PLACE_MOVED_TRACK_NODE, + ID_POPUP_PCB_VIA_EDITING, + ID_POPUP_PCB_VIA_HOLE_TO_DEFAULT, + ID_POPUP_PCB_VIA_HOLE_TO_VALUE, + ID_POPUP_PCB_VIA_HOLE_ENTER_VALUE, + ID_POPUP_PCB_VIA_HOLE_EXPORT, + ID_POPUP_PCB_VIA_HOLE_RESET_TO_DEFAULT, + ID_POPUP_PCB_VIA_HOLE_EXPORT_TO_OTHERS, + ID_POPUP_PCB_UNUSED1, + ID_POPUP_PCB_UNUSED2, + ID_POPUP_PCB_UNUSED3, + ID_POPUP_PCB_UNUSED4, + ID_POPUP_PCB_UNUSED5, + ID_POPUP_PCB_UNUSED6, + ID_POPUP_PCB_UNUSED7, + ID_POPUP_PCB_UNUSED8, + + ID_POPUP_PCB_END_RANGE, + + ID_POPUP_PCB_AUTOPLACE_START_RANGE, + + ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE, + ID_POPUP_PCB_AUTOPLACE_FREE_MODULE, + ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES, + ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES, + ID_POPUP_PCB_AUTOPLACE_CURRENT_MODULE, + ID_POPUP_PCB_AUTOMOVE_ALL_MODULES, + ID_POPUP_PCB_AUTOMOVE_NEW_MODULES, + ID_POPUP_PCB_AUTOPLACE_COMMANDS, + + ID_POPUP_PCB_REORIENT_ALL_MODULES, + + ID_POPUP_PCB_AUTOPLACE_ALL_MODULES, + ID_POPUP_PCB_AUTOPLACE_NEW_MODULES, + ID_POPUP_PCB_AUTOPLACE_NEXT_MODULE, + + ID_POPUP_PCB_AUTOPLACE_UNUSED0, + ID_POPUP_PCB_AUTOPLACE_UNUSED1, + ID_POPUP_PCB_AUTOPLACE_UNUSED2, + ID_POPUP_PCB_AUTOPLACE_UNUSED3, + + ID_POPUP_PCB_AUTOROUTE_COMMANDS, + ID_POPUP_PCB_AUTOROUTE_ALL_MODULES, + ID_POPUP_PCB_AUTOROUTE_MODULE, + ID_POPUP_PCB_AUTOROUTE_PAD, + ID_POPUP_PCB_AUTOROUTE_NET, + + ID_POPUP_PCB_AUTOROUTE_RESET_UNROUTED, + + ID_POPUP_PCB_AUTOROUTE_SELECT_LAYERS, + ID_POPUP_PCB_AUTOROUTE_UNUSED1, + ID_POPUP_PCB_AUTOROUTE_UNUSED2, + ID_POPUP_PCB_AUTOROUTE_UNUSED3, + ID_POPUP_PCB_AUTOROUTE_UNUSED4, + ID_POPUP_PCB_AUTOROUTE_UNUSED5, + ID_POPUP_PCB_AUTOROUTE_UNUSED6, + ID_POPUP_PCB_AUTOROUTE_UNUSED7, + + ID_POPUP_PCB_AUTOPLACE_END_RANGE, + + ID_SAVE_BOARD, + ID_MENU_SAVE_BOARD, + ID_MENU_SAVE_BOARD_AS, + ID_MENU_LOAD_FILE, + ID_MENU_APPEND_FILE, + ID_MENU_NEW_BOARD, + ID_MENU_RECOVER_BOARD, + ID_MENU_READ_LAST_SAVED_VERSION_BOARD, + ID_MENU_ARCHIVE_MODULES, + ID_MENU_ARCHIVE_NEW_MODULES, + ID_MENU_ARCHIVE_ALL_MODULES, + ID_MENU_MICELLANOUS, + ID_MENU_LIST_NETS, + ID_MENU_PCB_CLEAN, + ID_MENU_PCB_SWAP_LAYERS, + ID_MENU_PCB_UNUSED0, + ID_MENU_PCB_UNUSED1, + ID_MENU_PCB_UNUSED2, + ID_MENU_PCB_UNUSED3, + ID_MENU_PCB_UNUSED4, + + ID_TOOLBARH_PCB_SELECT_LAYER, + ID_TOOLBARH_PCB_AUTOPLACE, + ID_TOOLBARH_PCB_AUTOROUTE, + ID_TOOLBARH_PCB_UNUSED, + + ID_AUX_TOOLBAR_PCB_VIA_SIZE, + ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, + ID_AUX_TOOLBAR_PCB_UNUSED1, + ID_AUX_TOOLBAR_PCB_UNUSED2, + ID_AUX_TOOLBAR_PCB_UNUSED3, + ID_AUX_TOOLBAR_PCB_UNUSED4, + ID_AUX_TOOLBAR_PCB_UNUSED5, + ID_AUX_TOOLBAR_PCB_UNUSED6, + ID_AUX_TOOLBAR_PCB_UNUSED7, + + ID_PCB_GEN_POS_MODULES_FILE, + ID_PCB_GEN_DRILL_FILE, + + ID_PCB_LOOK_SETUP, + ID_PCB_TRACK_SIZE_SETUP, + ID_PCB_PAD_SETUP, + + ID_PCB_GLOBAL_DELETE, + ID_PCB_COTATION_BUTT, + ID_PCB_DRAWINGS_WIDTHS_SETUP, + + ID_PCB_GEN_CMP_FILE, + ID_MENU_PCB_SHOW_3D_FRAME, + ID_PCB_USER_GRID_SETUP, + ID_PCB_DISPLAY_FOOTPRINT_DOC, + ID_PCBUNUSED2, + ID_PCBUNUSED3, + ID_PCBUNUSED4, + ID_PCBUNUSED5, + ID_PCBUNUSED6, + ID_PCBUNUSED7, + + ID_MODEDIT_CHECK, + ID_MODEDIT_SAVE_LIBMODULE, + ID_MODEDIT_NEW_MODULE, + ID_MODEDIT_SHEET_SET, + ID_MODEDIT_LOAD_MODULE, + ID_MODEDIT_ADD_PAD, + ID_MODEDIT_PLACE_ANCHOR, + ID_MODEDIT_DELETE_ITEM_BUTT, + ID_MODEDIT_PAD_SETTINGS, + ID_MODEDIT_LOAD_MODULE_FROM_BOARD, + ID_MODEDIT_SAVE_MODULE_IN_BOARD, + ID_MODEDIT_EDIT_MODULE_PROPERTIES, + ID_MODEDIT_TRANSFORM_MODULE, + ID_MODEDIT_MODULE_ROTATE, + ID_MODEDIT_MODULE_MIRROR, + ID_MODEDIT_MODULE_SCALE, + ID_MODEDIT_MODULE_SCALEX, + ID_MODEDIT_MODULE_SCALEY, + ID_MODEDIT_UNDO, + ID_MODEDIT_REDO, + ID_MODEDIT_UNUSED6, + ID_MODEDIT_UNUSED7, + ID_MODEDIT_UNUSED8, + + // For GERBVIEW only + ID_GERBVIEW_SHOW_LIST_DCODES, + ID_GERBVIEW_LOAD_DRILL_FILE, + ID_GERBVIEW_LOAD_DCODE_FILE, + ID_TOOLBARH_GERBER_SELECT_TOOL, + ID_MENU_INC_LAYER_AND_APPEND_FILE, + ID_INC_LAYER_AND_APPEND_FILE, + ID_GERBVIEW_SHOW_SOURCE, + ID_GERBVIEW_UNUSED0, + ID_GERBVIEW_UNUSED1, + ID_GERBVIEW_UNUSED2, + ID_GERBVIEW_UNUSED3, + ID_GERBVIEW_UNUSED4, + ID_GERBVIEW_UNUSED5, + ID_GERBVIEW_UNUSED6, + ID_GERBVIEW_UNUSED7, + ID_GERBVIEW_UNUSED8, + + //////////////////// + + ID_EDA_SOCKET_EVENT_SERV, + ID_EDA_SOCKET_EVENT, + + ID_TB_OPTIONS_START, + + ID_TB_OPTIONS_DRC_OFF, + ID_TB_OPTIONS_SELECT_UNIT_MM, + ID_TB_OPTIONS_SELECT_UNIT_INCH, + ID_TB_OPTIONS_SELECT_CURSOR, + ID_TB_OPTIONS_SHOW_POLAR_COORD, + ID_TB_OPTIONS_SHOW_GRID, + ID_TB_OPTIONS_SHOW_RATSNEST, + ID_TB_OPTIONS_SHOW_MODULE_RATSNEST, + ID_TB_OPTIONS_AUTO_DEL_TRACK, + ID_TB_OPTIONS_SHOW_ZONES, + + ID_TB_OPTIONS_HIDDEN_PINS, + ID_TB_OPTIONS_BUS_WIRES_ORIENT, + ID_TB_OPTIONS_SHOW_PADS_SKETCH, + ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, + ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, + ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, + ID_TB_OPTIONS_SHOW_DCODES, + ID_TB_OPTIONS_SHOW_HIGHT_CONTRAST_MODE, + ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1, + ID_TB_OPTIONS_UNUSED5, + ID_TB_OPTIONS_UNUSED6, + ID_TB_OPTIONS_UNUSED7, + ID_TB_OPTIONS_UNUSED8, + + ID_TB_OPTIONS_END, + + + ID_START_COMMAND_3D, + ID_ROTATE3D_X_NEG, + ID_ROTATE3D_X_POS, + ID_ROTATE3D_Y_NEG, + ID_ROTATE3D_Y_POS, + ID_ROTATE3D_Z_NEG, + ID_ROTATE3D_Z_POS, + ID_RELOAD3D_BOARD, + ID_TOOL_SCREENCOPY_TOCLIBBOARD, + ID_MOVE3D_LEFT, + ID_MOVE3D_RIGHT, + ID_MOVE3D_UP, + ID_MOVE3D_DOWN, + ID_MENU3D_BGCOLOR_SELECTION, + ID_3D_UNUSED0, + ID_3D_UNUSED1, + ID_3D_UNUSED2, + ID_3D_UNUSED3, + ID_3D_UNUSED4, + ID_3D_UNUSED5, + ID_3D_UNUSED6, + ID_END_COMMAND_3D, + + ID_MENU_SCREENCOPY_PNG, + ID_MENU_SCREENCOPY_JPEG, + ID_MENU_SCREENCOPY_TOCLIBBOARD, + ID_MENU_COMMAND3D_UNUSED2, + ID_MENU_COMMAND3D_UNUSED3, + ID_MENU_COMMAND3D_UNUSED4, + ID_MENU_COMMAND3D_UNUSED5, + ID_MENU_COMMAND3D_UNUSED6, + + + ID_PCB_MUWAVE_START_CMD, + ID_PCB_MUWAVE_TOOL_DISPLAY_TOOLS, + ID_PCB_MUWAVE_TOOL_SELF_CMD, + ID_PCB_MUWAVE_TOOL_GAP_CMD, + ID_PCB_MUWAVE_TOOL_STUB_CMD, + ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD, + ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD, + ID_PCB_MUWAVE_UNUSED0, + ID_PCB_MUWAVE_UNUSED1, + ID_PCB_MUWAVE_UNUSED2, + ID_PCB_MUWAVE_END_CMD, + + ID_END_LIST + +}; + +#endif /* define ID_H */ diff --git a/include/macros.h b/include/macros.h new file mode 100644 index 0000000000..cd89a81755 --- /dev/null +++ b/include/macros.h @@ -0,0 +1,93 @@ +/* Macros utiles */ + +#ifndef MACROS_H +#define MACROS_H + +#if wxUSE_UNICODE +#define CONV_TO_UTF8(wxstring) ((const char*) wxConvCurrent->cWX2MB(wxstring)) +#define CONV_FROM_UTF8(utf8string) ( wxConvCurrent->cMB2WC(utf8string)) +#else +#define CONV_TO_UTF8(wxstring) ((const char*)(wxstring.c_str())) +#define CONV_FROM_UTF8(utf8string) (utf8string) +#endif + +#ifndef min +#define min(x, y) ((x) > (y) ? (y) : (x)) +#endif +#ifndef max +#define max(x, y) ((x) > (y) ? (x) : (y)) +#endif + +#ifndef MIN +#define MIN(x, y) ((x) > (y) ? (y) : (x)) +#endif +#ifndef MAX +#define MAX(x, y) ((x) > (y) ? (x) : (y)) +#endif + +#ifndef ABS +#define ABS(y) ((y) >= 0 ? (y) : (-(y))) +#endif + +#define DEG2RAD(Deg) ((Deg) * M_PI / 180.0) +#define RAD2DEG(Rad) ((Rad) * 180.0 / M_PI) + +/* Normalize angle to be in the -360.0 .. 360.0 range or 0 .. 360.0: */ +#define NORMALIZE_ANGLE(Angle) { while (Angle < 0) Angle += 3600; \ + while (Angle > 3600) Angle -= 3600; } + +/* Normalize angle to be in the 0.0 .. 360.0 range: */ +#define NORMALIZE_ANGLE_POS(Angle) { while (Angle < 0) Angle += 3600; while (Angle >= 3600) Angle -= 3600; } +#define NEGATE_AND_NORMALIZE_ANGLE_POS(Angle) \ + { Angle = - Angle; while (Angle < 0) Angle += 3600; while (Angle >= 3600) Angle -= 3600; } + + +/* exchange 2 donnees */ +#define EXCHG(a,b) { typeof(a) __temp__ = (a); (a) = (b); (b) = __temp__; } + +/* macro for insert menuitems with a icon: */ +#define ADD_MENUITEM(menu, id, text, icon) {\ + wxMenuItem * l_item;\ + l_item = new wxMenuItem(menu, id, text);\ + l_item->SetBitmap(icon); menu->Append(l_item);} + +#ifdef __WINDOWS__ +#define ADD_MENUITEM_WITH_SUBMENU(menu, submenu, id, text, icon) {\ + wxMenuItem * l_item;\ + l_item = new wxMenuItem(menu, id, text);\ + l_item->SetSubMenu(submenu);\ + l_item->SetBitmap(icon);\ + l_item->SetFont(* g_ItalicFont);\ + menu->Append(l_item);} + +#define ADD_MENUITEM_WITH_HELP_AND_SUBMENU(menu, submenu, id, text, help, icon) {\ + wxMenuItem * l_item;\ + l_item = new wxMenuItem(menu, id, text, help);\ + l_item->SetSubMenu(submenu);\ + l_item->SetBitmap(icon);\ + l_item->SetFont(*g_ItalicFont);\ + menu->Append(l_item);} +#else +#define ADD_MENUITEM_WITH_SUBMENU(menu, submenu, id, text, icon) {\ + wxMenuItem * l_item;\ + l_item = new wxMenuItem(menu, id, text);\ + l_item->SetSubMenu(submenu);\ + l_item->SetBitmap(icon);\ + menu->Append(l_item);} + +#define ADD_MENUITEM_WITH_HELP_AND_SUBMENU(menu, submenu, id, text, help, icon) {\ + wxMenuItem * l_item;\ + l_item = new wxMenuItem(menu, id, text, help);\ + l_item->SetSubMenu(submenu);\ + l_item->SetBitmap(icon);\ + menu->Append(l_item);} +#endif + +#ifdef __WINDOWS__ +#define SETBITMAPS(icon) item->SetBitmaps(apply_xpm, (icon)) +#else +#define SETBITMAPS(icon) +#endif + +#endif /* ifdef MACRO_H */ + diff --git a/include/pcbstruct.h b/include/pcbstruct.h new file mode 100644 index 0000000000..7c587c8a0f --- /dev/null +++ b/include/pcbstruct.h @@ -0,0 +1,357 @@ + /**************************************************************/ + /* pcbstruct.h : definition des structures de donnees type PCB */ + /**************************************************************/ + +#ifndef PCBSTRUCT_H +#define PCBSTRUCT_H + +#include "base_struct.h" + +// Definitions relatives aux libariries +#define ENTETE_LIBRAIRIE "PCBNEW-LibModule-V1" +#define ENTETE_LIBDOC "PCBNEW-LibDoc----V1" +#define L_ENTETE_LIB 18 +#define EXT_CMP wxT(".emp") +#define EXT_CMP_MASK wxT("*.emp") +#define EXT_DOC wxT(".mdc") + + +/* Bits indicateurs du membre .Status, pour pistes, modules... */ +#define FLAG1 0x2000 /* flag libre pour calculs locaux */ +#define FLAG0 0x1000 /* flag libre pour calculs locaux */ +#define BEGIN_ONPAD 0x800 /* flag indiquant un debut de segment sur pad */ +#define END_ONPAD 0x400 /* flag indiquant une fin de segment sur pad */ +#define BUSY 0x0200 /* flag indiquant que la structure a deja + ete examinee, dans certaines routines */ +#define DELETED 0x0100 /* Bit flag de Status pour structures effacee + et mises en chaine "DELETED" */ +#define NO_TRACE 0x80 /* l'element ne doit pas etre affiche */ +#define SURBRILL 0x20 /* element en surbrillance */ +#define DRAG 0x10 /* segment en mode drag */ +#define EDIT 0x8 /* element en cours d'edition */ +#define SEGM_FIXE 0x04 /* segment FIXE ( pas d'effacement global ) */ +#define SEGM_AR 0x02 /* segment Auto_Route */ +#define CHAIN 0x01 /* segment marque */ + + + /*************************************/ + /* constantes de gestion des couches */ + /*************************************/ +#define CUIVRE_LAYER 0x00000001 /* Bit layer cuivre */ +#define LAYER_2 0x00000002 /* Bit layer 2 */ +#define LAYER_3 0x00000004 /* Bit layer 3 */ +#define LAYER_4 0x00000008 /* Bit layer 4 */ +#define LAYER_5 0x00000010 /* Bit layer 5 */ +#define LAYER_6 0x00000020 /* Bit layer 6 */ +#define LAYER_7 0x00000040 /* Bit layer 7 */ +#define LAYER_8 0x00000080 /* Bit layer 8 */ +#define LAYER_9 0x00000100 /* Bit layer 9 */ +#define LAYER_10 0x00000200 /* Bit layer 10 */ +#define LAYER_11 0x00000400 /* Bit layer 11 */ +#define LAYER_12 0x00000800 /* Bit layer 12 */ +#define LAYER_13 0x00001000 /* Bit layer 13 */ +#define LAYER_14 0x00002000 /* Bit layer 14 */ +#define LAYER_15 0x00004000 /* Bit layer 15 */ +#define CMP_LAYER 0x00008000 /* Bit layer cmp */ +#define ADHESIVE_LAYER_CU 0x00010000 +#define ADHESIVE_LAYER_CMP 0x00020000 +#define SOLDERPASTE_LAYER_CU 0x00040000 +#define SOLDERPASTE_LAYER_CMP 0x00080000 +#define SILKSCREEN_LAYER_CU 0x00100000 +#define SILKSCREEN_LAYER_CMP 0x00200000 +#define SOLDERMASK_LAYER_CU 0x00400000 +#define SOLDERMASK_LAYER_CMP 0x00800000 +#define DRAW_LAYER 0x01000000 +#define COMMENT_LAYER 0x02000000 +#define ECO1_LAYER 0x04000000 +#define ECO2_LAYER 0x08000000 +#define EDGE_LAYER 0x10000000 +#define intS_LAYER 0xE0000000 /* 4 bits MSB = autres flags */ +/* masques generaux : */ +#define ALL_LAYERS 0x1FFFFFFF +#define ALL_NO_CU_LAYERS 0x1FFF0000 +#define ALL_CU_LAYERS 0x0000FFFF +#define INTERNAL_LAYERS 0x00007FFE /* Bits layers internes */ +#define EXTERNAL_LAYERS 0x00008001 +/* Flags pour les couches cuivres */ +#define LAYER_is_PLAN 0x80000000 + +/* numero des couches particulieres */ +#define LAYER_CUIVRE_N 0 +#define CUIVRE_N 0 +#define LAYER_N_2 1 /* Numero layer 2 */ +#define LAYER_N_3 2 /* Numero layer 3 */ +#define LAYER_N_4 3 /* Numero layer 4 */ +#define LAYER_N_5 4 /* Numero layer 5 */ +#define LAYER_N_6 5 /* Numero layer 6 */ +#define LAYER_N_7 6 /* Numero layer 7 */ +#define LAYER_N_8 7 /* Numero layer 8 */ +#define LAYER_N_9 8 /* Numero layer 9 */ +#define LAYER_N_10 9 /* Numero layer 10 */ +#define LAYER_N_11 10 /* Numero layer 11 */ +#define LAYER_N_12 11 /* Numero layer 12 */ +#define LAYER_N_13 12 /* Numero layer 13 */ +#define LAYER_N_14 13 /* Numero layer 14 */ +#define LAYER_N_15 14 /* Numero layer 15 */ +#define LAYER_CMP_N 15 +#define CMP_N 15 +#define NB_COPPER_LAYERS (CMP_N+1) +#define FIRST_NO_COPPER_LAYER 16 +#define ADHESIVE_N_CU 16 +#define ADHESIVE_N_CMP 17 +#define SOLDERPASTE_N_CU 18 +#define SOLDERPASTE_N_CMP 19 +#define SILKSCREEN_N_CU 20 +#define SILKSCREEN_N_CMP 21 +#define SOLDERMASK_N_CU 22 +#define SOLDERMASK_N_CMP 23 +#define DRAW_N 24 +#define COMMENT_N 25 +#define ECO1_N 26 +#define ECO2_N 27 +#define EDGE_N 28 +#define LAST_NO_COPPER_LAYER 28 +#define NB_LAYERS (EDGE_N+1) +#define LAYER_COUNT 32 + +/* Forme des segments (pistes, contours ..) ( parametre .shape ) */ +enum Track_Shapes { + S_SEGMENT = 0, /* segment rectiligne */ + S_RECT, /* segment forme rect (i.e. bouts non arrondis) */ + S_ARC, /* segment en arc de cercle (bouts arrondis)*/ + S_CIRCLE, /* segment en cercle (anneau)*/ + S_ARC_RECT, /* segment en arc de cercle (bouts droits) (GERBER)*/ + S_SPOT_OVALE, /* spot ovale (for GERBER)*/ + S_SPOT_CIRCLE, /* spot rond (for GERBER)*/ + S_SPOT_RECT, /* spot rect (for GERBER)*/ + S_POLYGON /* polygon shape */ +}; + + +/* Forward declaration */ +class MODULE; +class EQUIPOT; +class MARQUEUR; +class TRACK; +class D_PAD; +struct CHEVELU; +class Ki_PageDescr; +class DrawBlockStruct; + +// Class for handle current printed board design settings +#define HIST0RY_NUMBER 8 +class EDA_BoardDesignSettings +{ +public: + int m_CopperLayerCount; // Number of copper layers for this design + int m_ViaDrill; // via drill (for the entire board) + int m_CurrentViaSize; // Current via size + int m_ViaSizeHistory[HIST0RY_NUMBER]; // Last HIST0RY_NUMBER used via sizes + int m_CurrentViaType; /* via type (BLIND, TROUGHT ...), bits 1 and 2 (not 0 and 1)*/ + int m_CurrentTrackWidth; // current track width + int m_TrackWidhtHistory[HIST0RY_NUMBER]; // Last HIST0RY_NUMBER used track widths + int m_DrawSegmentWidth; // current graphic line width (not EDGE layer) + int m_EdgeSegmentWidth; // current graphic line width (EDGE layer only) + int m_PcbTextWidth; // current Pcb (not module) Text width + wxSize m_PcbTextSize; // current Pcb (not module) Text size + int m_TrackClearence; // track to track and track to pads clearance + int m_ZoneClearence; // zone to track and zone to pads clearance + int m_MaskMargin; // Solder mask margin + /* Color options for screen display of the Printed Board: */ + int m_PcbGridColor; // Grid color + int m_LayerColor[32] ; // Layer colors (tracks and graphic items) + int m_ViaColor[4]; // Via color (depending on is type) + int m_ModuleTextCMPColor; // Text module color for modules on the COMPONENT layer + int m_ModuleTextCUColor; // Text module color for modules on the COPPER layer + int m_ModuleTextNOVColor; // Text module color for "invisible" texts (must be BLACK if really not displayed) + int m_AnchorColor; // Anchor color for modules and texts + int m_PadCUColor; // Pad color for the COMPONENT side of the pad + int m_PadCMPColor; // Pad color for the COPPER side of the pad + // Pad color for the pads of both sides is m_PadCUColor OR m_PadCMPColor (in terms of colors) + int m_RatsnestColor; // Ratsnest color + +public: + EDA_BoardDesignSettings(void); +}; + +// Values for m_DisplayViaMode member: +enum DisplayViaMode { + VIA_HOLE_NOT_SHOW = 0, + VIA_SPECIAL_HOLE_SHOW, + ALL_VIA_HOLE_SHOW, + OPT_VIA_HOLE_END +}; + +class BOARD: public EDA_BaseStruct +{ + public: + WinEDA_BasePcbFrame * m_PcbFrame; // Window de visualisation + EDA_Rect m_BoundaryBox; // Limites d'encadrement du PCB + int m_Unused; // + int m_Status_Pcb; // Mot d'etat: Bit 1 = Chevelu calcule + EDA_BoardDesignSettings * m_BoardSettings; // Link to current design settings + int m_NbNets; // Nombre de nets (equipotentielles) + int m_NbNodes; // nombre de pads connectes + int m_NbLinks; // nombre de chevelus + int m_NbLoclinks; // nombre de chevelus dans Local ratsnest + // minimal de pistes a tracer + int m_NbNoconnect; // nombre de chevelus actifs + int m_NbSegmTrack; // nombre d'elements de type segments de piste + int m_NbSegmZone; // nombre d'elements de type segments de zone + + EDA_BaseStruct * m_Drawings; // pointeur sur liste drawings + MODULE * m_Modules; // pointeur sur liste zone modules + EQUIPOT * m_Equipots; // pointeur liste zone equipot + TRACK * m_Track; // pointeur relatif zone piste + TRACK * m_Zone; // pointeur tableau zone zones de cuivre + D_PAD ** m_Pads; // pointeur liste d'acces aux pads + int m_NbPads; // nombre total de pads + CHEVELU * m_Ratsnest; // pointeur liste des chevelus + CHEVELU * m_LocalRatsnest; // pointeur liste des chevelus d'un module + + EDGE_ZONE * m_CurrentLimitZone; /* pointeur sur la liste des segments + de delimitation de la zone en cours de trace */ + + BOARD(EDA_BaseStruct * StructFather, WinEDA_BasePcbFrame * frame); + ~BOARD(void); + + /* supprime du chainage la structure Struct */ + void UnLink( void ); + + /* Routines de calcul des nombres de segments pistes et zones */ + int GetNumSegmTrack(void); + int GetNumSegmZone(void); + int GetNumNoconnect(void); // retourne le nombre de connexions manquantes + int GetNumRatsnests(void); // retourne le nombre de chevelus + int GetNumNodes(void); // retourne le nombre de pads a netcode > 0 + + // Calcul du rectangle d'encadrement: + bool ComputeBoundaryBox(void); +}; + + +/* Description d'un ecran */ +class PCB_SCREEN : public BASE_SCREEN +{ +public: + int m_Active_Layer; /* ref couche active */ + int m_Route_Layer_TOP; /* ref couches actives */ + int m_Route_Layer_BOTTOM; /* pour placement vias et routage 2 couches */ + +public: + PCB_SCREEN(int idscreen); + ~PCB_SCREEN(void); + PCB_SCREEN * Next(void) { return (PCB_SCREEN *) Pnext;} + void Init(void); + void SetNextZoom(void); + void SetPreviousZoom(void); + void SetLastZoom(void); +}; + + /***************************/ + /* Description des Modules */ + /***************************/ + +#include "class_pad.h" /* Description des Pastilles :*/ +#include "class_edge_mod.h" +#include "class_text_mod.h" +#include "class_module.h" +#include "class_equipot.h" + + + /***********************************/ + /* Description des elements du PCB */ + /***********************************/ + +class DRAWSEGMENT: public EDA_BaseLineStruct +{ +public: + int m_Shape; // forme: Segment , Cercle.. + int m_Type; // numero de sous type ( cotation.. ) + int m_Angle; // pour les arcs: "longueur" de l'arc en 1/10 deg + +public: + DRAWSEGMENT(EDA_BaseStruct * StructFather, DrawStructureType idtype = TYPEDRAWSEGMENT); + ~DRAWSEGMENT(void); + + // Read/write data + bool WriteDrawSegmentDescr(FILE * File); + bool ReadDrawSegmentDescr(FILE * File, int * LineNum); + + /* supprime du chainage la structure Struct */ + void UnLink( void ); + + void Copy(DRAWSEGMENT * source); +}; + + +#include "class_pcb_text.h" +#include "class_cotation.h" +#include "class_mire.h" +#include "class_track.h" + + /*******************/ + /* class EDGE_ZONE */ + /*******************/ + +class EDGE_ZONE: public DRAWSEGMENT +{ +public: + EDGE_ZONE(EDA_BaseStruct * StructFather); + EDGE_ZONE(const EDGE_ZONE & edgezone); + ~EDGE_ZONE(void); +}; + + + /************************************/ + /* Gestion des marqueurs sur le PCB */ + /************************************/ + +class MARQUEUR: public EDA_BaseStruct +{ /* Description d'un marqueur */ +public: + wxPoint m_Pos; + char * m_Bitmap; /* Shape (bitmap) */ + int m_Type; + int m_Color; /* couleur */ + wxString m_Diag; /* Associated text (comment) */ + +public: + MARQUEUR(EDA_BaseStruct * StructFather); + ~MARQUEUR(void); + void UnLink( void ); + void Draw( WinEDA_DrawPanel * panel, wxDC * DC, int DrawMode); +}; + + +class DISPLAY_OPTIONS +{ +public: + bool DisplayPadFill; + bool DisplayPadNum; + bool DisplayPadNoConn; + bool DisplayPadIsol; + + int DisplayModEdge; + int DisplayModText; + bool DisplayPcbTrackFill; /* FALSE = sketch , TRUE = filled */ + bool DisplayTrackIsol; + int m_DisplayViaMode; /* 0 do not show via hole, + 1 show via hole for non default value + 2 show all via hole */ + + bool DisplayPolarCood; + bool DisplayZones; + bool Show_Modules_Cmp; + bool Show_Modules_Cu; + + int DisplayDrawItems; + bool ContrastModeDisplay; + +public: + DISPLAY_OPTIONS(void); +}; + + + +#endif /* PCBSTRUCT_H */ diff --git a/include/plot_common.h b/include/plot_common.h new file mode 100644 index 0000000000..d5cb992281 --- /dev/null +++ b/include/plot_common.h @@ -0,0 +1,70 @@ + /********************/ + /* plot_common.h */ + /********************/ + +#ifndef PLOT_COMMON_H +#define PLOT_COMMON_H + +#ifndef EDA_BASE +#define COMMON_GLOBL extern +#else +#define COMMON_GLOBL +#endif + + +typedef enum { + PLOT_FORMAT_HPGL, + PLOT_FORMAT_POST, + PLOT_FORMAT_GERBER, + PLOT_FORMAT_POST_A4 + } PlotFormat; + +#define PLOT_MIROIR 1 + + +/*******************************/ +/* common_plot_functions.cpp */ +/*******************************/ +void SetPlotScale(double xscale, double yscale); /* Set the plot scale for the current plotting) */ +void SetPlotOffset(wxPoint offset); /* Set the plot offset for the current plotting) */ +void InitPlotParametresGERBER(wxPoint offset, double xscale, double yscale); +void PlotWorkSheet(int format_plot, BASE_SCREEN * screen); +void UserToDeviceCoordinate(wxPoint & pos ); + /* modifie les coord pos.x et pos.y pour le trace selon l'orientation, l'echelle, les offsets de trace */ +void UserToDeviceSize(wxSize & size ); + /* modifie les dimension size.x et size.y pour le trace selon l'echelle */ + + +/*******************************/ +/* common_plotPS_functions.cpp */ +/*******************************/ +void InitPlotParametresPS( wxPoint offset, Ki_PageDescr * sheet, double xscale, double yscale, int orient = 0); +void SetDefaultLineWidthPS( int width); +void PlotCircle_PS(wxPoint pos, int diametre, int width = -1); +void PlotArcPS(wxPoint centre, int StAngle, int EndAngle, int rayon); +void PlotArcPS(wxPoint centre, int StAngle, int EndAngle, int rayon, int width); + /* Plot an arc: StAngle, EndAngle = start and end arc in 0.1 degree */ +void PlotPolyPS( int nb_segm, int * coord, int fill); +void PlotFilledSegmentPS(wxPoint start , wxPoint end, int width); +void LineTo_PS(wxPoint pos, int plume); +void PrintHeaderPS(FILE * file, const wxString & Creator, const wxString & FileName, int BBox[4]); +bool CloseFilePS(FILE * plot_file); +void SetColorMapPS(int color); + + + +/*********************************/ +/* common_plotHPGL_functions.cpp */ +/*********************************/ +void InitPlotParametresHPGL(wxPoint offset, double xscale, double yscale, int orient = 0); +bool PrintHeaderHPGL(FILE * plot_file, int pen_speed, int pen_num); +bool CloseFileHPGL(FILE * plot_file); +void PlotCircle_HPGL(wxPoint centre, int diameter, int width = -1); +void PlotArcHPGL(wxPoint centre, int StAngle, int EndAngle, int rayon); +void PlotPolyHPGL( int nb, int * coord, int fill); +void Move_Plume_HPGL( wxPoint pos, int plume ); +void Plume_HPGL( int plume ); + +#endif // PLOT_COMMON_H + + diff --git a/include/trigo.h b/include/trigo.h new file mode 100644 index 0000000000..d8b4538dde --- /dev/null +++ b/include/trigo.h @@ -0,0 +1,1531 @@ + /****************************************************/ + /* TRIGO.H : Tables de fonctions trigonometriques */ + /* utilisees dans les rotations d'axes */ + /****************************************************/ + +#ifndef TRIGO_H +#define TRIGO_H + + +/* Prototype des fonctions de TRIGO.CC */ +void RotatePoint(int *pX, int *pY, int angle); +void RotatePoint(int *pX, int *pY, int cx, int cy, int angle); +void RotatePoint(wxPoint *point, const wxPoint & centre, int angle); +void RotatePoint(double *pX, double *pY, int angle); +void RotatePoint(double *pX, double *pY, double cx, double cy, int angle); +int ArcTangente(int dy, int dx); + /* Retourne l'arc tangente en 0.1 degres du vecteur de coord dx, dy + entre -1800 et 1800 + Analogue a atan2 ( mais plus rapide pour les caculs si + l'angle est souvent 0, -1800, ou +- 900 */ + + + + + /*************************************************/ + /* Table lookup de 1/COS(X) en fonction de tg(X) */ + /*************************************************/ +eda_global float invcostab[17] +#if defined MAIN + = { 1.0, 1/0.998, 1/0.9923, 1/0.9829, 1/0.97014, 1/0.9545, + 1/0.93633, 1/0.91615, 1/0.8944, 1/0.8715, 1/0.848, 1/0.82404, + 1/0.8, 1/0.7761, 1/0.75257, 1/0.7295, 1/0.707 } +#endif +; + /***************************************************/ + /* Table lookup de 256*COS(X) en fonction de tg(X) */ + /***************************************************/ +eda_global long costab[17] +#if defined MAIN + = { 256, 255, 253, 251, 248, 244, 240, 234, 229, + 223, 217, 211, 205, 198, 192, 187, 181 } +#endif +; + /***************************************************/ + /* Table lookup de 256*SIN(X) en fonction de tg(X) */ + /***************************************************/ +eda_global long sintab[17] +#if defined MAIN + = { 0, 16, 32, 47, 62, 76, 90, 103, 114, + 125, 136, 145, 154, 161, 168, 175, 181 } +#endif +; + + + /*******************/ + /* Macro NEW_COORD */ + /*******************/ + +/* Macro de calcul de novelles coordonnees par rotation d'axe + coord : xrot = y*sin + x*cos + yrot = y*cos - x*sin + soit : xrot = (y*tg + x)*cos + yrot = (y - x*tg)*cos + + les coeffs COS sont tabules en fct de tg sur 16 valeurs. +*/ +#define NEW_COORD(x0,y0) \ + do { \ + int itmp ; \ + itmp = x0 ; x0 = x0 + (int)( y0 * tg ) ; y0 = y0 - (int)( itmp * tg ) ; \ + x0 = (x0*cosinus) >> 8 ; y0 = (y0*cosinus) >> 8 ; \ + } while(0); + + +eda_global float fsinus[3600] +#if defined MAIN + = { + 0.0000000000,0.0017453284,0.0034906514,0.0052359638, + 0.0069812603,0.0087265355,0.0104717841,0.0122170008,0.0139621803, + 0.0157073173,0.0174524064,0.0191974424,0.0209424199,0.0226873336, + 0.0244321782,0.0261769483,0.0279216387,0.0296662441,0.0314107591, + 0.0331551784,0.0348994967,0.0366437087,0.0383878091,0.0401317925, + 0.0418756537,0.0436193874,0.0453629881,0.0471064507,0.0488497698, + 0.0505929401,0.0523359562,0.0540788130,0.0558215050,0.0575640270, + 0.0593063736,0.0610485395,0.0627905195,0.0645323083,0.0662739004, + 0.0680152907,0.0697564737,0.0714974443,0.0732381971,0.0749787268, + 0.0767190281,0.0784590957,0.0801989243,0.0819385086,0.0836778433, + 0.0854169231,0.0871557427,0.0888942969,0.0906325802,0.0923705874, + 0.0941083133,0.0958457525,0.0975828998,0.0993197497,0.1010562972, + 0.1027925368,0.1045284633,0.1062640713,0.1079993557,0.1097343111, + 0.1114689322,0.1132032138,0.1149371505,0.1166707371,0.1184039683, + 0.1201368388,0.1218693434,0.1236014767,0.1253332336,0.1270646086, + 0.1287955966,0.1305261922,0.1322563903,0.1339861854,0.1357155724, + 0.1374445460,0.1391731010,0.1409012319,0.1426289337,0.1443562010, + 0.1460830286,0.1478094111,0.1495353434,0.1512608202,0.1529858363, + 0.1547103863,0.1564344650,0.1581580673,0.1598811877,0.1616038211, + 0.1633259622,0.1650476059,0.1667687467,0.1684893796,0.1702094992, + 0.1719291003,0.1736481777,0.1753667261,0.1770847403,0.1788022151, + 0.1805191453,0.1822355255,0.1839513506,0.1856666154,0.1873813146, + 0.1890954430,0.1908089954,0.1925219665,0.1942343512,0.1959461442, + 0.1976573404,0.1993679344,0.2010779211,0.2027872954,0.2044960518, + 0.2062041854,0.2079116908,0.2096185629,0.2113247965,0.2130303863, + 0.2147353272,0.2164396139,0.2181432414,0.2198462044,0.2215484976, + 0.2232501160,0.2249510543,0.2266513074,0.2283508701,0.2300497372, + 0.2317479035,0.2334453639,0.2351421131,0.2368381461,0.2385334576, + 0.2402280425,0.2419218956,0.2436150118,0.2453073859,0.2469990127, + 0.2486898872,0.2503800041,0.2520693582,0.2537579446,0.2554457579, + 0.2571327932,0.2588190451,0.2605045086,0.2621891786,0.2638730500, + 0.2655561175,0.2672383761,0.2689198206,0.2706004460,0.2722802470, + 0.2739592187,0.2756373558,0.2773146533,0.2789911060,0.2806667089, + 0.2823414568,0.2840153447,0.2856883674,0.2873605198,0.2890317969, + 0.2907021936,0.2923717047,0.2940403252,0.2957080500,0.2973748741, + 0.2990407923,0.3007057995,0.3023698908,0.3040330609,0.3056953050, + 0.3073566178,0.3090169944,0.3106764296,0.3123349185,0.3139924560, + 0.3156490369,0.3173046564,0.3189593093,0.3206129906,0.3222656952, + 0.3239174182,0.3255681545,0.3272178990,0.3288666467,0.3305143927, + 0.3321611319,0.3338068592,0.3354515698,0.3370952584,0.3387379202, + 0.3403795502,0.3420201433,0.3436596946,0.3452981990,0.3469356516, + 0.3485720473,0.3502073813,0.3518416484,0.3534748438,0.3551069624, + 0.3567379993,0.3583679495,0.3599968081,0.3616245701,0.3632512305, + 0.3648767843,0.3665012267,0.3681245527,0.3697467573,0.3713678356, + 0.3729877826,0.3746065934,0.3762242631,0.3778407868,0.3794561595, + 0.3810703764,0.3826834324,0.3842953227,0.3859060423,0.3875155865, + 0.3891239501,0.3907311285,0.3923371166,0.3939419096,0.3955455026, + 0.3971478906,0.3987490689,0.4003490326,0.4019477767,0.4035452964, + 0.4051415868,0.4067366431,0.4083304604,0.4099230338,0.4115143586, + 0.4131044298,0.4146932427,0.4162807923,0.4178670738,0.4194520824, + 0.4210358134,0.4226182617,0.4241994227,0.4257792916,0.4273578634, + 0.4289351334,0.4305110968,0.4320857488,0.4336590846,0.4352310994, + 0.4368017884,0.4383711468,0.4399391699,0.4415058528,0.4430711908, + 0.4446351792,0.4461978131,0.4477590878,0.4493189986,0.4508775407, + 0.4524347093,0.4539904997,0.4555449072,0.4570979271,0.4586495545, + 0.4601997848,0.4617486132,0.4632960351,0.4648420457,0.4663866403, + 0.4679298143,0.4694715628,0.4710118812,0.4725507649,0.4740882090, + 0.4756242091,0.4771587603,0.4786918579,0.4802234974,0.4817536741, + 0.4832823833,0.4848096202,0.4863353804,0.4878596591,0.4893824517, + 0.4909037536,0.4924235601,0.4939418666,0.4954586684,0.4969739610, + 0.4984877398,0.5000000000,0.5015107372,0.5030199466,0.5045276238, + 0.5060337641,0.5075383630,0.5090414158,0.5105429179,0.5120428649, + 0.5135412521,0.5150380749,0.5165333289,0.5180270094,0.5195191119, + 0.5210096318,0.5224985647,0.5239859060,0.5254716511,0.5269557955, + 0.5284383347,0.5299192642,0.5313985795,0.5328762761,0.5343523494, + 0.5358267950,0.5372996083,0.5387707850,0.5402403205,0.5417082103, + 0.5431744500,0.5446390350,0.5461019610,0.5475632235,0.5490228180, + 0.5504807401,0.5519369853,0.5533915492,0.5548444274,0.5562956155, + 0.5577451090,0.5591929035,0.5606389946,0.5620833779,0.5635260489, + 0.5649670034,0.5664062369,0.5678437451,0.5692795234,0.5707135677, + 0.5721458734,0.5735764364,0.5750052520,0.5764323162,0.5778576244, + 0.5792811723,0.5807029557,0.5821229702,0.5835412114,0.5849576750, + 0.5863723567,0.5877852523,0.5891963574,0.5906056676,0.5920131788, + 0.5934188866,0.5948227868,0.5962248750,0.5976251470,0.5990235985, + 0.6004202253,0.6018150232,0.6032079877,0.6045991149,0.6059884003, + 0.6073758397,0.6087614290,0.6101451639,0.6115270402,0.6129070537, + 0.6142852001,0.6156614753,0.6170358751,0.6184083954,0.6197790318, + 0.6211477803,0.6225146366,0.6238795967,0.6252426563,0.6266038114, + 0.6279630576,0.6293203910,0.6306758074,0.6320293027,0.6333808726, + 0.6347305132,0.6360782203,0.6374239897,0.6387678175,0.6401096995, + 0.6414496316,0.6427876097,0.6441236298,0.6454576877,0.6467897795, + 0.6481199011,0.6494480483,0.6507742173,0.6520984038,0.6534206040, + 0.6547408137,0.6560590290,0.6573752458,0.6586894601,0.6600016680, + 0.6613118653,0.6626200482,0.6639262127,0.6652303547,0.6665324702, + 0.6678325555,0.6691306064,0.6704266190,0.6717205893,0.6730125135, + 0.6743023876,0.6755902076,0.6768759697,0.6781596699,0.6794413043, + 0.6807208690,0.6819983601,0.6832737737,0.6845471059,0.6858183529, + 0.6870875108,0.6883545757,0.6896195437,0.6908824111,0.6921431739, + 0.6934018283,0.6946583705,0.6959127966,0.6971651029,0.6984152854, + 0.6996633405,0.7009092643,0.7021530530,0.7033947028,0.7046342100, + 0.7058715707,0.7071067812,0.7083398377,0.7095707365,0.7107994739, + 0.7120260460,0.7132504492,0.7144726796,0.7156927337,0.7169106077, + 0.7181262978,0.7193398003,0.7205511117,0.7217602281,0.7229671459, + 0.7241718614,0.7253743710,0.7265746710,0.7277727577,0.7289686274, + 0.7301622766,0.7313537016,0.7325428988,0.7337298645,0.7349145951, + 0.7360970871,0.7372773368,0.7384553406,0.7396310950,0.7408045963, + 0.7419758410,0.7431448255,0.7443115462,0.7454759997,0.7466381823, + 0.7477980905,0.7489557208,0.7501110696,0.7512641335,0.7524149089, + 0.7535633923,0.7547095802,0.7558534692,0.7569950557,0.7581343362, + 0.7592713073,0.7604059656,0.7615383075,0.7626683297,0.7637960286, + 0.7649214009,0.7660444431,0.7671651518,0.7682835236,0.7693995550, + 0.7705132428,0.7716245834,0.7727335735,0.7738402097,0.7749444887, + 0.7760464071,0.7771459615,0.7782431485,0.7793379649,0.7804304073, + 0.7815204724,0.7826081569,0.7836934573,0.7847763705,0.7858568932, + 0.7869350220,0.7880107536,0.7890840848,0.7901550124,0.7912235330, + 0.7922896434,0.7933533403,0.7944146205,0.7954734809,0.7965299180, + 0.7975839288,0.7986355100,0.7996846585,0.8007313709,0.8017756442, + 0.8028174752,0.8038568606,0.8048937974,0.8059282822,0.8069603121, + 0.8079898839,0.8090169944,0.8100416404,0.8110638190,0.8120835269, + 0.8131007610,0.8141155184,0.8151277957,0.8161375901,0.8171448983, + 0.8181497174,0.8191520443,0.8201518759,0.8211492091,0.8221440410, + 0.8231363685,0.8241261886,0.8251134983,0.8260982945,0.8270805743, + 0.8280603346,0.8290375726,0.8300122851,0.8309844693,0.8319541221, + 0.8329212407,0.8338858221,0.8348478633,0.8358073614,0.8367643135, + 0.8377187166,0.8386705679,0.8396198645,0.8405666035,0.8415107819, + 0.8424523970,0.8433914458,0.8443279255,0.8452618332,0.8461931661, + 0.8471219214,0.8480480962,0.8489716876,0.8498926930,0.8508111094, + 0.8517269341,0.8526401644,0.8535507973,0.8544588301,0.8553642602, + 0.8562670846,0.8571673007,0.8580649057,0.8589598969,0.8598522716, + 0.8607420270,0.8616291604,0.8625136692,0.8633955506,0.8642748020, + 0.8651514206,0.8660254038,0.8668967489,0.8677654534,0.8686315144, + 0.8694949295,0.8703556959,0.8712138111,0.8720692724,0.8729220773, + 0.8737722230,0.8746197071,0.8754645270,0.8763066800,0.8771461637, + 0.8779829754,0.8788171127,0.8796485729,0.8804773535,0.8813034521, + 0.8821268660,0.8829475929,0.8837656301,0.8845809752,0.8853936258, + 0.8862035792,0.8870108332,0.8878153851,0.8886172327,0.8894163733, + 0.8902128046,0.8910065242,0.8917975296,0.8925858185,0.8933713883, + 0.8941542368,0.8949343616,0.8957117602,0.8964864304,0.8972583697, + 0.8980275758,0.8987940463,0.8995577790,0.9003187714,0.9010770213, + 0.9018325264,0.9025852843,0.9033352929,0.9040825497,0.9048270525, + 0.9055687990,0.9063077870,0.9070440143,0.9077774785,0.9085081775, + 0.9092361090,0.9099612709,0.9106836608,0.9114032766,0.9121201162, + 0.9128341772,0.9135454576,0.9142539552,0.9149596678,0.9156625933, + 0.9163627296,0.9170600744,0.9177546257,0.9184463813,0.9191353393, + 0.9198214973,0.9205048535,0.9211854056,0.9218631516,0.9225380895, + 0.9232102171,0.9238795325,0.9245460336,0.9252097184,0.9258705848, + 0.9265286309,0.9271838546,0.9278362539,0.9284858269,0.9291325715, + 0.9297764859,0.9304175680,0.9310558159,0.9316912276,0.9323238012, + 0.9329535348,0.9335804265,0.9342044743,0.9348256764,0.9354440308, + 0.9360595357,0.9366721892,0.9372819895,0.9378889346,0.9384930228, + 0.9390942521,0.9396926208,0.9402881270,0.9408807690,0.9414705448, + 0.9420574528,0.9426414911,0.9432226579,0.9438009516,0.9443763702, + 0.9449489122,0.9455185756,0.9460853588,0.9466492601,0.9472102777, + 0.9477684100,0.9483236552,0.9488760116,0.9494254776,0.9499720515, + 0.9505157316,0.9510565163,0.9515944039,0.9521293927,0.9526614813, + 0.9531906678,0.9537169507,0.9542403285,0.9547607995,0.9552783621, + 0.9557930148,0.9563047560,0.9568135841,0.9573194975,0.9578224948, + 0.9583225745,0.9588197349,0.9593139745,0.9598052920,0.9602936857, + 0.9607791542,0.9612616959,0.9617413095,0.9622179935,0.9626917464, + 0.9631625668,0.9636304532,0.9640954042,0.9645574185,0.9650164945, + 0.9654726309,0.9659258263,0.9663760793,0.9668233886,0.9672677528, + 0.9677091705,0.9681476404,0.9685831611,0.9690157314,0.9694453499, + 0.9698720153,0.9702957263,0.9707164816,0.9711342799,0.9715491200, + 0.9719610006,0.9723699204,0.9727758782,0.9731788728,0.9735789029, + 0.9739759673,0.9743700648,0.9747611942,0.9751493543,0.9755345439, + 0.9759167619,0.9762960071,0.9766722783,0.9770455744,0.9774158943, + 0.9777832368,0.9781476007,0.9785089851,0.9788673888,0.9792228106, + 0.9795752496,0.9799247046,0.9802711746,0.9806146585,0.9809551553, + 0.9812926640,0.9816271834,0.9819587127,0.9822872507,0.9826127965, + 0.9829353491,0.9832549076,0.9835714708,0.9838850379,0.9841956080, + 0.9845031800,0.9848077530,0.9851093262,0.9854078985,0.9857034691, + 0.9859960371,0.9862856015,0.9865721616,0.9868557164,0.9871362651, + 0.9874138068,0.9876883406,0.9879598658,0.9882283814,0.9884938868, + 0.9887563810,0.9890158634,0.9892723330,0.9895257891,0.9897762309, + 0.9900236577,0.9902680687,0.9905094632,0.9907478405,0.9909831997, + 0.9912155403,0.9914448614,0.9916711624,0.9918944426,0.9921147013, + 0.9923319379,0.9925461516,0.9927573419,0.9929655081,0.9931706495, + 0.9933727656,0.9935718557,0.9937679192,0.9939609555,0.9941509640, + 0.9943379441,0.9945218954,0.9947028171,0.9948807088,0.9950555700, + 0.9952274000,0.9953961984,0.9955619646,0.9957246982,0.9958843986, + 0.9960410654,0.9961946981,0.9963452962,0.9964928592,0.9966373868, + 0.9967788785,0.9969173337,0.9970527522,0.9971851335,0.9973144772, + 0.9974407829,0.9975640503,0.9976842788,0.9978014683,0.9979156183, + 0.9980267284,0.9981347984,0.9982398279,0.9983418166,0.9984407642, + 0.9985366703,0.9986295348,0.9987193572,0.9988061373,0.9988898750, + 0.9989705698,0.9990482216,0.9991228301,0.9991943951,0.9992629164, + 0.9993283938,0.9993908270,0.9994502159,0.9995065604,0.9995598601, + 0.9996101150,0.9996573250,0.9997014898,0.9997426093,0.9997806835, + 0.9998157121,0.9998476952,0.9998766325,0.9999025240,0.9999253697, + 0.9999451694,0.9999619231,0.9999756307,0.9999862922,0.9999939077, + 0.9999984769,1.0000000000,0.9999984769,0.9999939077,0.9999862922, + 0.9999756307,0.9999619231,0.9999451694,0.9999253697,0.9999025240, + 0.9998766325,0.9998476952,0.9998157121,0.9997806835,0.9997426093, + 0.9997014898,0.9996573250,0.9996101150,0.9995598601,0.9995065604, + 0.9994502159,0.9993908270,0.9993283938,0.9992629164,0.9991943951, + 0.9991228301,0.9990482216,0.9989705698,0.9988898750,0.9988061373, + 0.9987193572,0.9986295348,0.9985366703,0.9984407642,0.9983418166, + 0.9982398279,0.9981347984,0.9980267284,0.9979156183,0.9978014683, + 0.9976842788,0.9975640503,0.9974407829,0.9973144772,0.9971851335, + 0.9970527522,0.9969173337,0.9967788785,0.9966373868,0.9964928592, + 0.9963452962,0.9961946981,0.9960410654,0.9958843986,0.9957246982, + 0.9955619646,0.9953961984,0.9952274000,0.9950555700,0.9948807088, + 0.9947028171,0.9945218954,0.9943379441,0.9941509640,0.9939609555, + 0.9937679192,0.9935718557,0.9933727656,0.9931706495,0.9929655081, + 0.9927573419,0.9925461516,0.9923319379,0.9921147013,0.9918944426, + 0.9916711624,0.9914448614,0.9912155403,0.9909831997,0.9907478405, + 0.9905094632,0.9902680687,0.9900236577,0.9897762309,0.9895257891, + 0.9892723330,0.9890158634,0.9887563810,0.9884938868,0.9882283814, + 0.9879598658,0.9876883406,0.9874138068,0.9871362651,0.9868557164, + 0.9865721616,0.9862856015,0.9859960371,0.9857034691,0.9854078985, + 0.9851093262,0.9848077530,0.9845031800,0.9841956080,0.9838850379, + 0.9835714708,0.9832549076,0.9829353491,0.9826127965,0.9822872507, + 0.9819587127,0.9816271834,0.9812926640,0.9809551553,0.9806146585, + 0.9802711746,0.9799247046,0.9795752496,0.9792228106,0.9788673888, + 0.9785089851,0.9781476007,0.9777832368,0.9774158943,0.9770455744, + 0.9766722783,0.9762960071,0.9759167619,0.9755345439,0.9751493543, + 0.9747611942,0.9743700648,0.9739759673,0.9735789029,0.9731788728, + 0.9727758782,0.9723699204,0.9719610006,0.9715491200,0.9711342799, + 0.9707164816,0.9702957263,0.9698720153,0.9694453499,0.9690157314, + 0.9685831611,0.9681476404,0.9677091705,0.9672677528,0.9668233886, + 0.9663760793,0.9659258263,0.9654726309,0.9650164945,0.9645574185, + 0.9640954042,0.9636304532,0.9631625668,0.9626917464,0.9622179935, + 0.9617413095,0.9612616959,0.9607791542,0.9602936857,0.9598052920, + 0.9593139745,0.9588197349,0.9583225745,0.9578224948,0.9573194975, + 0.9568135841,0.9563047560,0.9557930148,0.9552783621,0.9547607995, + 0.9542403285,0.9537169507,0.9531906678,0.9526614813,0.9521293927, + 0.9515944039,0.9510565163,0.9505157316,0.9499720515,0.9494254776, + 0.9488760116,0.9483236552,0.9477684100,0.9472102777,0.9466492601, + 0.9460853588,0.9455185756,0.9449489122,0.9443763702,0.9438009516, + 0.9432226579,0.9426414911,0.9420574528,0.9414705448,0.9408807690, + 0.9402881270,0.9396926208,0.9390942521,0.9384930228,0.9378889346, + 0.9372819895,0.9366721892,0.9360595357,0.9354440308,0.9348256764, + 0.9342044743,0.9335804265,0.9329535348,0.9323238012,0.9316912276, + 0.9310558159,0.9304175680,0.9297764859,0.9291325715,0.9284858269, + 0.9278362539,0.9271838546,0.9265286309,0.9258705848,0.9252097184, + 0.9245460336,0.9238795325,0.9232102171,0.9225380895,0.9218631516, + 0.9211854056,0.9205048535,0.9198214973,0.9191353393,0.9184463813, + 0.9177546257,0.9170600744,0.9163627296,0.9156625933,0.9149596678, + 0.9142539552,0.9135454576,0.9128341772,0.9121201162,0.9114032766, + 0.9106836608,0.9099612709,0.9092361090,0.9085081775,0.9077774785, + 0.9070440143,0.9063077870,0.9055687990,0.9048270525,0.9040825497, + 0.9033352929,0.9025852843,0.9018325264,0.9010770213,0.9003187714, + 0.8995577790,0.8987940463,0.8980275758,0.8972583697,0.8964864304, + 0.8957117602,0.8949343616,0.8941542368,0.8933713883,0.8925858185, + 0.8917975296,0.8910065242,0.8902128046,0.8894163733,0.8886172327, + 0.8878153851,0.8870108332,0.8862035792,0.8853936258,0.8845809752, + 0.8837656301,0.8829475929,0.8821268660,0.8813034521,0.8804773535, + 0.8796485729,0.8788171127,0.8779829754,0.8771461637,0.8763066800, + 0.8754645270,0.8746197071,0.8737722230,0.8729220773,0.8720692724, + 0.8712138111,0.8703556959,0.8694949295,0.8686315144,0.8677654534, + 0.8668967489,0.8660254038,0.8651514206,0.8642748020,0.8633955506, + 0.8625136692,0.8616291604,0.8607420270,0.8598522716,0.8589598969, + 0.8580649057,0.8571673007,0.8562670846,0.8553642602,0.8544588301, + 0.8535507973,0.8526401644,0.8517269341,0.8508111094,0.8498926930, + 0.8489716876,0.8480480962,0.8471219214,0.8461931661,0.8452618332, + 0.8443279255,0.8433914458,0.8424523970,0.8415107819,0.8405666035, + 0.8396198645,0.8386705679,0.8377187166,0.8367643135,0.8358073614, + 0.8348478633,0.8338858221,0.8329212407,0.8319541221,0.8309844693, + 0.8300122851,0.8290375726,0.8280603346,0.8270805743,0.8260982945, + 0.8251134983,0.8241261886,0.8231363685,0.8221440410,0.8211492091, + 0.8201518759,0.8191520443,0.8181497174,0.8171448983,0.8161375901, + 0.8151277957,0.8141155184,0.8131007610,0.8120835269,0.8110638190, + 0.8100416404,0.8090169944,0.8079898839,0.8069603121,0.8059282822, + 0.8048937974,0.8038568606,0.8028174752,0.8017756442,0.8007313709, + 0.7996846585,0.7986355100,0.7975839288,0.7965299180,0.7954734809, + 0.7944146205,0.7933533403,0.7922896434,0.7912235330,0.7901550124, + 0.7890840848,0.7880107536,0.7869350220,0.7858568932,0.7847763705, + 0.7836934573,0.7826081569,0.7815204724,0.7804304073,0.7793379649, + 0.7782431485,0.7771459615,0.7760464071,0.7749444887,0.7738402097, + 0.7727335735,0.7716245834,0.7705132428,0.7693995550,0.7682835236, + 0.7671651518,0.7660444431,0.7649214009,0.7637960286,0.7626683297, + 0.7615383075,0.7604059656,0.7592713073,0.7581343362,0.7569950557, + 0.7558534692,0.7547095802,0.7535633923,0.7524149089,0.7512641335, + 0.7501110696,0.7489557208,0.7477980905,0.7466381823,0.7454759997, + 0.7443115462,0.7431448255,0.7419758410,0.7408045963,0.7396310950, + 0.7384553406,0.7372773368,0.7360970871,0.7349145951,0.7337298645, + 0.7325428988,0.7313537016,0.7301622766,0.7289686274,0.7277727577, + 0.7265746710,0.7253743710,0.7241718614,0.7229671459,0.7217602281, + 0.7205511117,0.7193398003,0.7181262978,0.7169106077,0.7156927337, + 0.7144726796,0.7132504492,0.7120260460,0.7107994739,0.7095707365, + 0.7083398377,0.7071067812,0.7058715707,0.7046342100,0.7033947028, + 0.7021530530,0.7009092643,0.6996633405,0.6984152854,0.6971651029, + 0.6959127966,0.6946583705,0.6934018283,0.6921431739,0.6908824111, + 0.6896195437,0.6883545757,0.6870875108,0.6858183529,0.6845471059, + 0.6832737737,0.6819983601,0.6807208690,0.6794413043,0.6781596699, + 0.6768759697,0.6755902076,0.6743023876,0.6730125135,0.6717205893, + 0.6704266190,0.6691306064,0.6678325555,0.6665324702,0.6652303547, + 0.6639262127,0.6626200482,0.6613118653,0.6600016680,0.6586894601, + 0.6573752458,0.6560590290,0.6547408137,0.6534206040,0.6520984038, + 0.6507742173,0.6494480483,0.6481199011,0.6467897795,0.6454576877, + 0.6441236298,0.6427876097,0.6414496316,0.6401096995,0.6387678175, + 0.6374239897,0.6360782203,0.6347305132,0.6333808726,0.6320293027, + 0.6306758074,0.6293203910,0.6279630576,0.6266038114,0.6252426563, + 0.6238795967,0.6225146366,0.6211477803,0.6197790318,0.6184083954, + 0.6170358751,0.6156614753,0.6142852001,0.6129070537,0.6115270402, + 0.6101451639,0.6087614290,0.6073758397,0.6059884003,0.6045991149, + 0.6032079877,0.6018150232,0.6004202253,0.5990235985,0.5976251470, + 0.5962248750,0.5948227868,0.5934188866,0.5920131788,0.5906056676, + 0.5891963574,0.5877852523,0.5863723567,0.5849576750,0.5835412114, + 0.5821229702,0.5807029557,0.5792811723,0.5778576244,0.5764323162, + 0.5750052520,0.5735764364,0.5721458734,0.5707135677,0.5692795234, + 0.5678437451,0.5664062369,0.5649670034,0.5635260489,0.5620833779, + 0.5606389946,0.5591929035,0.5577451090,0.5562956155,0.5548444274, + 0.5533915492,0.5519369853,0.5504807401,0.5490228180,0.5475632235, + 0.5461019610,0.5446390350,0.5431744500,0.5417082103,0.5402403205, + 0.5387707850,0.5372996083,0.5358267950,0.5343523494,0.5328762761, + 0.5313985795,0.5299192642,0.5284383347,0.5269557955,0.5254716511, + 0.5239859060,0.5224985647,0.5210096318,0.5195191119,0.5180270094, + 0.5165333289,0.5150380749,0.5135412521,0.5120428649,0.5105429179, + 0.5090414158,0.5075383630,0.5060337641,0.5045276238,0.5030199466, + 0.5015107372,0.5000000000,0.4984877398,0.4969739610,0.4954586684, + 0.4939418666,0.4924235601,0.4909037536,0.4893824517,0.4878596591, + 0.4863353804,0.4848096202,0.4832823833,0.4817536741,0.4802234974, + 0.4786918579,0.4771587603,0.4756242091,0.4740882090,0.4725507649, + 0.4710118812,0.4694715628,0.4679298143,0.4663866403,0.4648420457, + 0.4632960351,0.4617486132,0.4601997848,0.4586495545,0.4570979271, + 0.4555449072,0.4539904997,0.4524347093,0.4508775407,0.4493189986, + 0.4477590878,0.4461978131,0.4446351792,0.4430711908,0.4415058528, + 0.4399391699,0.4383711468,0.4368017884,0.4352310994,0.4336590846, + 0.4320857488,0.4305110968,0.4289351334,0.4273578634,0.4257792916, + 0.4241994227,0.4226182617,0.4210358134,0.4194520824,0.4178670738, + 0.4162807923,0.4146932427,0.4131044298,0.4115143586,0.4099230338, + 0.4083304604,0.4067366431,0.4051415868,0.4035452964,0.4019477767, + 0.4003490326,0.3987490689,0.3971478906,0.3955455026,0.3939419096, + 0.3923371166,0.3907311285,0.3891239501,0.3875155865,0.3859060423, + 0.3842953227,0.3826834324,0.3810703764,0.3794561595,0.3778407868, + 0.3762242631,0.3746065934,0.3729877826,0.3713678356,0.3697467573, + 0.3681245527,0.3665012267,0.3648767843,0.3632512305,0.3616245701, + 0.3599968081,0.3583679495,0.3567379993,0.3551069624,0.3534748438, + 0.3518416484,0.3502073813,0.3485720473,0.3469356516,0.3452981990, + 0.3436596946,0.3420201433,0.3403795502,0.3387379202,0.3370952584, + 0.3354515698,0.3338068592,0.3321611319,0.3305143927,0.3288666467, + 0.3272178990,0.3255681545,0.3239174182,0.3222656952,0.3206129906, + 0.3189593093,0.3173046564,0.3156490369,0.3139924560,0.3123349185, + 0.3106764296,0.3090169944,0.3073566178,0.3056953050,0.3040330609, + 0.3023698908,0.3007057995,0.2990407923,0.2973748741,0.2957080500, + 0.2940403252,0.2923717047,0.2907021936,0.2890317969,0.2873605198, + 0.2856883674,0.2840153447,0.2823414568,0.2806667089,0.2789911060, + 0.2773146533,0.2756373558,0.2739592187,0.2722802470,0.2706004460, + 0.2689198206,0.2672383761,0.2655561175,0.2638730500,0.2621891786, + 0.2605045086,0.2588190451,0.2571327932,0.2554457579,0.2537579446, + 0.2520693582,0.2503800041,0.2486898872,0.2469990127,0.2453073859, + 0.2436150118,0.2419218956,0.2402280425,0.2385334576,0.2368381461, + 0.2351421131,0.2334453639,0.2317479035,0.2300497372,0.2283508701, + 0.2266513074,0.2249510543,0.2232501160,0.2215484976,0.2198462044, + 0.2181432414,0.2164396139,0.2147353272,0.2130303863,0.2113247965, + 0.2096185629,0.2079116908,0.2062041854,0.2044960518,0.2027872954, + 0.2010779211,0.1993679344,0.1976573404,0.1959461442,0.1942343512, + 0.1925219665,0.1908089954,0.1890954430,0.1873813146,0.1856666154, + 0.1839513506,0.1822355255,0.1805191453,0.1788022151,0.1770847403, + 0.1753667261,0.1736481777,0.1719291003,0.1702094992,0.1684893796, + 0.1667687467,0.1650476059,0.1633259622,0.1616038211,0.1598811877, + 0.1581580673,0.1564344650,0.1547103863,0.1529858363,0.1512608202, + 0.1495353434,0.1478094111,0.1460830286,0.1443562010,0.1426289337, + 0.1409012319,0.1391731010,0.1374445460,0.1357155724,0.1339861854, + 0.1322563903,0.1305261922,0.1287955966,0.1270646086,0.1253332336, + 0.1236014767,0.1218693434,0.1201368388,0.1184039683,0.1166707371, + 0.1149371505,0.1132032138,0.1114689322,0.1097343111,0.1079993557, + 0.1062640713,0.1045284633,0.1027925368,0.1010562972,0.0993197497, + 0.0975828998,0.0958457525,0.0941083133,0.0923705874,0.0906325802, + 0.0888942969,0.0871557427,0.0854169231,0.0836778433,0.0819385086, + 0.0801989243,0.0784590957,0.0767190281,0.0749787268,0.0732381971, + 0.0714974443,0.0697564737,0.0680152907,0.0662739004,0.0645323083, + 0.0627905195,0.0610485395,0.0593063736,0.0575640270,0.0558215050, + 0.0540788130,0.0523359562,0.0505929401,0.0488497698,0.0471064507, + 0.0453629881,0.0436193874,0.0418756537,0.0401317925,0.0383878091, + 0.0366437087,0.0348994967,0.0331551784,0.0314107591,0.0296662441, + 0.0279216387,0.0261769483,0.0244321782,0.0226873336,0.0209424199, + 0.0191974424,0.0174524064,0.0157073173,0.0139621803,0.0122170008, + 0.0104717841,0.0087265355,0.0069812603,0.0052359638,0.0034906514, + 0.0017453284,0.0000000000,-0.0017453284,-0.0034906514,-0.0052359638, + -0.0069812603,-0.0087265355,-0.0104717841,-0.0122170008,-0.0139621803, + -0.0157073173,-0.0174524064,-0.0191974424,-0.0209424199,-0.0226873336, + -0.0244321782,-0.0261769483,-0.0279216387,-0.0296662441,-0.0314107591, + -0.0331551784,-0.0348994967,-0.0366437087,-0.0383878091,-0.0401317925, + -0.0418756537,-0.0436193874,-0.0453629881,-0.0471064507,-0.0488497698, + -0.0505929401,-0.0523359562,-0.0540788130,-0.0558215050,-0.0575640270, + -0.0593063736,-0.0610485395,-0.0627905195,-0.0645323083,-0.0662739004, + -0.0680152907,-0.0697564737,-0.0714974443,-0.0732381971,-0.0749787268, + -0.0767190281,-0.0784590957,-0.0801989243,-0.0819385086,-0.0836778433, + -0.0854169231,-0.0871557427,-0.0888942969,-0.0906325802,-0.0923705874, + -0.0941083133,-0.0958457525,-0.0975828998,-0.0993197497,-0.1010562972, + -0.1027925368,-0.1045284633,-0.1062640713,-0.1079993557,-0.1097343111, + -0.1114689322,-0.1132032138,-0.1149371505,-0.1166707371,-0.1184039683, + -0.1201368388,-0.1218693434,-0.1236014767,-0.1253332336,-0.1270646086, + -0.1287955966,-0.1305261922,-0.1322563903,-0.1339861854,-0.1357155724, + -0.1374445460,-0.1391731010,-0.1409012319,-0.1426289337,-0.1443562010, + -0.1460830286,-0.1478094111,-0.1495353434,-0.1512608202,-0.1529858363, + -0.1547103863,-0.1564344650,-0.1581580673,-0.1598811877,-0.1616038211, + -0.1633259622,-0.1650476059,-0.1667687467,-0.1684893796,-0.1702094992, + -0.1719291003,-0.1736481777,-0.1753667261,-0.1770847403,-0.1788022151, + -0.1805191453,-0.1822355255,-0.1839513506,-0.1856666154,-0.1873813146, + -0.1890954430,-0.1908089954,-0.1925219665,-0.1942343512,-0.1959461442, + -0.1976573404,-0.1993679344,-0.2010779211,-0.2027872954,-0.2044960518, + -0.2062041854,-0.2079116908,-0.2096185629,-0.2113247965,-0.2130303863, + -0.2147353272,-0.2164396139,-0.2181432414,-0.2198462044,-0.2215484976, + -0.2232501160,-0.2249510543,-0.2266513074,-0.2283508701,-0.2300497372, + -0.2317479035,-0.2334453639,-0.2351421131,-0.2368381461,-0.2385334576, + -0.2402280425,-0.2419218956,-0.2436150118,-0.2453073859,-0.2469990127, + -0.2486898872,-0.2503800041,-0.2520693582,-0.2537579446,-0.2554457579, + -0.2571327932,-0.2588190451,-0.2605045086,-0.2621891786,-0.2638730500, + -0.2655561175,-0.2672383761,-0.2689198206,-0.2706004460,-0.2722802470, + -0.2739592187,-0.2756373558,-0.2773146533,-0.2789911060,-0.2806667089, + -0.2823414568,-0.2840153447,-0.2856883674,-0.2873605198,-0.2890317969, + -0.2907021936,-0.2923717047,-0.2940403252,-0.2957080500,-0.2973748741, + -0.2990407923,-0.3007057995,-0.3023698908,-0.3040330609,-0.3056953050, + -0.3073566178,-0.3090169944,-0.3106764296,-0.3123349185,-0.3139924560, + -0.3156490369,-0.3173046564,-0.3189593093,-0.3206129906,-0.3222656952, + -0.3239174182,-0.3255681545,-0.3272178990,-0.3288666467,-0.3305143927, + -0.3321611319,-0.3338068592,-0.3354515698,-0.3370952584,-0.3387379202, + -0.3403795502,-0.3420201433,-0.3436596946,-0.3452981990,-0.3469356516, + -0.3485720473,-0.3502073813,-0.3518416484,-0.3534748438,-0.3551069624, + -0.3567379993,-0.3583679495,-0.3599968081,-0.3616245701,-0.3632512305, + -0.3648767843,-0.3665012267,-0.3681245527,-0.3697467573,-0.3713678356, + -0.3729877826,-0.3746065934,-0.3762242631,-0.3778407868,-0.3794561595, + -0.3810703764,-0.3826834324,-0.3842953227,-0.3859060423,-0.3875155865, + -0.3891239501,-0.3907311285,-0.3923371166,-0.3939419096,-0.3955455026, + -0.3971478906,-0.3987490689,-0.4003490326,-0.4019477767,-0.4035452964, + -0.4051415868,-0.4067366431,-0.4083304604,-0.4099230338,-0.4115143586, + -0.4131044298,-0.4146932427,-0.4162807923,-0.4178670738,-0.4194520824, + -0.4210358134,-0.4226182617,-0.4241994227,-0.4257792916,-0.4273578634, + -0.4289351334,-0.4305110968,-0.4320857488,-0.4336590846,-0.4352310994, + -0.4368017884,-0.4383711468,-0.4399391699,-0.4415058528,-0.4430711908, + -0.4446351792,-0.4461978131,-0.4477590878,-0.4493189986,-0.4508775407, + -0.4524347093,-0.4539904997,-0.4555449072,-0.4570979271,-0.4586495545, + -0.4601997848,-0.4617486132,-0.4632960351,-0.4648420457,-0.4663866403, + -0.4679298143,-0.4694715628,-0.4710118812,-0.4725507649,-0.4740882090, + -0.4756242091,-0.4771587603,-0.4786918579,-0.4802234974,-0.4817536741, + -0.4832823833,-0.4848096202,-0.4863353804,-0.4878596591,-0.4893824517, + -0.4909037536,-0.4924235601,-0.4939418666,-0.4954586684,-0.4969739610, + -0.4984877398,-0.5000000000,-0.5015107372,-0.5030199466,-0.5045276238, + -0.5060337641,-0.5075383630,-0.5090414158,-0.5105429179,-0.5120428649, + -0.5135412521,-0.5150380749,-0.5165333289,-0.5180270094,-0.5195191119, + -0.5210096318,-0.5224985647,-0.5239859060,-0.5254716511,-0.5269557955, + -0.5284383347,-0.5299192642,-0.5313985795,-0.5328762761,-0.5343523494, + -0.5358267950,-0.5372996083,-0.5387707850,-0.5402403205,-0.5417082103, + -0.5431744500,-0.5446390350,-0.5461019610,-0.5475632235,-0.5490228180, + -0.5504807401,-0.5519369853,-0.5533915492,-0.5548444274,-0.5562956155, + -0.5577451090,-0.5591929035,-0.5606389946,-0.5620833779,-0.5635260489, + -0.5649670034,-0.5664062369,-0.5678437451,-0.5692795234,-0.5707135677, + -0.5721458734,-0.5735764364,-0.5750052520,-0.5764323162,-0.5778576244, + -0.5792811723,-0.5807029557,-0.5821229702,-0.5835412114,-0.5849576750, + -0.5863723567,-0.5877852523,-0.5891963574,-0.5906056676,-0.5920131788, + -0.5934188866,-0.5948227868,-0.5962248750,-0.5976251470,-0.5990235985, + -0.6004202253,-0.6018150232,-0.6032079877,-0.6045991149,-0.6059884003, + -0.6073758397,-0.6087614290,-0.6101451639,-0.6115270402,-0.6129070537, + -0.6142852001,-0.6156614753,-0.6170358751,-0.6184083954,-0.6197790318, + -0.6211477803,-0.6225146366,-0.6238795967,-0.6252426563,-0.6266038114, + -0.6279630576,-0.6293203910,-0.6306758074,-0.6320293027,-0.6333808726, + -0.6347305132,-0.6360782203,-0.6374239897,-0.6387678175,-0.6401096995, + -0.6414496316,-0.6427876097,-0.6441236298,-0.6454576877,-0.6467897795, + -0.6481199011,-0.6494480483,-0.6507742173,-0.6520984038,-0.6534206040, + -0.6547408137,-0.6560590290,-0.6573752458,-0.6586894601,-0.6600016680, + -0.6613118653,-0.6626200482,-0.6639262127,-0.6652303547,-0.6665324702, + -0.6678325555,-0.6691306064,-0.6704266190,-0.6717205893,-0.6730125135, + -0.6743023876,-0.6755902076,-0.6768759697,-0.6781596699,-0.6794413043, + -0.6807208690,-0.6819983601,-0.6832737737,-0.6845471059,-0.6858183529, + -0.6870875108,-0.6883545757,-0.6896195437,-0.6908824111,-0.6921431739, + -0.6934018283,-0.6946583705,-0.6959127966,-0.6971651029,-0.6984152854, + -0.6996633405,-0.7009092643,-0.7021530530,-0.7033947028,-0.7046342100, + -0.7058715707,-0.7071067812,-0.7083398377,-0.7095707365,-0.7107994739, + -0.7120260460,-0.7132504492,-0.7144726796,-0.7156927337,-0.7169106077, + -0.7181262978,-0.7193398003,-0.7205511117,-0.7217602281,-0.7229671459, + -0.7241718614,-0.7253743710,-0.7265746710,-0.7277727577,-0.7289686274, + -0.7301622766,-0.7313537016,-0.7325428988,-0.7337298645,-0.7349145951, + -0.7360970871,-0.7372773368,-0.7384553406,-0.7396310950,-0.7408045963, + -0.7419758410,-0.7431448255,-0.7443115462,-0.7454759997,-0.7466381823, + -0.7477980905,-0.7489557208,-0.7501110696,-0.7512641335,-0.7524149089, + -0.7535633923,-0.7547095802,-0.7558534692,-0.7569950557,-0.7581343362, + -0.7592713073,-0.7604059656,-0.7615383075,-0.7626683297,-0.7637960286, + -0.7649214009,-0.7660444431,-0.7671651518,-0.7682835236,-0.7693995550, + -0.7705132428,-0.7716245834,-0.7727335735,-0.7738402097,-0.7749444887, + -0.7760464071,-0.7771459615,-0.7782431485,-0.7793379649,-0.7804304073, + -0.7815204724,-0.7826081569,-0.7836934573,-0.7847763705,-0.7858568932, + -0.7869350220,-0.7880107536,-0.7890840848,-0.7901550124,-0.7912235330, + -0.7922896434,-0.7933533403,-0.7944146205,-0.7954734809,-0.7965299180, + -0.7975839288,-0.7986355100,-0.7996846585,-0.8007313709,-0.8017756442, + -0.8028174752,-0.8038568606,-0.8048937974,-0.8059282822,-0.8069603121, + -0.8079898839,-0.8090169944,-0.8100416404,-0.8110638190,-0.8120835269, + -0.8131007610,-0.8141155184,-0.8151277957,-0.8161375901,-0.8171448983, + -0.8181497174,-0.8191520443,-0.8201518759,-0.8211492091,-0.8221440410, + -0.8231363685,-0.8241261886,-0.8251134983,-0.8260982945,-0.8270805743, + -0.8280603346,-0.8290375726,-0.8300122851,-0.8309844693,-0.8319541221, + -0.8329212407,-0.8338858221,-0.8348478633,-0.8358073614,-0.8367643135, + -0.8377187166,-0.8386705679,-0.8396198645,-0.8405666035,-0.8415107819, + -0.8424523970,-0.8433914458,-0.8443279255,-0.8452618332,-0.8461931661, + -0.8471219214,-0.8480480962,-0.8489716876,-0.8498926930,-0.8508111094, + -0.8517269341,-0.8526401644,-0.8535507973,-0.8544588301,-0.8553642602, + -0.8562670846,-0.8571673007,-0.8580649057,-0.8589598969,-0.8598522716, + -0.8607420270,-0.8616291604,-0.8625136692,-0.8633955506,-0.8642748020, + -0.8651514206,-0.8660254038,-0.8668967489,-0.8677654534,-0.8686315144, + -0.8694949295,-0.8703556959,-0.8712138111,-0.8720692724,-0.8729220773, + -0.8737722230,-0.8746197071,-0.8754645270,-0.8763066800,-0.8771461637, + -0.8779829754,-0.8788171127,-0.8796485729,-0.8804773535,-0.8813034521, + -0.8821268660,-0.8829475929,-0.8837656301,-0.8845809752,-0.8853936258, + -0.8862035792,-0.8870108332,-0.8878153851,-0.8886172327,-0.8894163733, + -0.8902128046,-0.8910065242,-0.8917975296,-0.8925858185,-0.8933713883, + -0.8941542368,-0.8949343616,-0.8957117602,-0.8964864304,-0.8972583697, + -0.8980275758,-0.8987940463,-0.8995577790,-0.9003187714,-0.9010770213, + -0.9018325264,-0.9025852843,-0.9033352929,-0.9040825497,-0.9048270525, + -0.9055687990,-0.9063077870,-0.9070440143,-0.9077774785,-0.9085081775, + -0.9092361090,-0.9099612709,-0.9106836608,-0.9114032766,-0.9121201162, + -0.9128341772,-0.9135454576,-0.9142539552,-0.9149596678,-0.9156625933, + -0.9163627296,-0.9170600744,-0.9177546257,-0.9184463813,-0.9191353393, + -0.9198214973,-0.9205048535,-0.9211854056,-0.9218631516,-0.9225380895, + -0.9232102171,-0.9238795325,-0.9245460336,-0.9252097184,-0.9258705848, + -0.9265286309,-0.9271838546,-0.9278362539,-0.9284858269,-0.9291325715, + -0.9297764859,-0.9304175680,-0.9310558159,-0.9316912276,-0.9323238012, + -0.9329535348,-0.9335804265,-0.9342044743,-0.9348256764,-0.9354440308, + -0.9360595357,-0.9366721892,-0.9372819895,-0.9378889346,-0.9384930228, + -0.9390942521,-0.9396926208,-0.9402881270,-0.9408807690,-0.9414705448, + -0.9420574528,-0.9426414911,-0.9432226579,-0.9438009516,-0.9443763702, + -0.9449489122,-0.9455185756,-0.9460853588,-0.9466492601,-0.9472102777, + -0.9477684100,-0.9483236552,-0.9488760116,-0.9494254776,-0.9499720515, + -0.9505157316,-0.9510565163,-0.9515944039,-0.9521293927,-0.9526614813, + -0.9531906678,-0.9537169507,-0.9542403285,-0.9547607995,-0.9552783621, + -0.9557930148,-0.9563047560,-0.9568135841,-0.9573194975,-0.9578224948, + -0.9583225745,-0.9588197349,-0.9593139745,-0.9598052920,-0.9602936857, + -0.9607791542,-0.9612616959,-0.9617413095,-0.9622179935,-0.9626917464, + -0.9631625668,-0.9636304532,-0.9640954042,-0.9645574185,-0.9650164945, + -0.9654726309,-0.9659258263,-0.9663760793,-0.9668233886,-0.9672677528, + -0.9677091705,-0.9681476404,-0.9685831611,-0.9690157314,-0.9694453499, + -0.9698720153,-0.9702957263,-0.9707164816,-0.9711342799,-0.9715491200, + -0.9719610006,-0.9723699204,-0.9727758782,-0.9731788728,-0.9735789029, + -0.9739759673,-0.9743700648,-0.9747611942,-0.9751493543,-0.9755345439, + -0.9759167619,-0.9762960071,-0.9766722783,-0.9770455744,-0.9774158943, + -0.9777832368,-0.9781476007,-0.9785089851,-0.9788673888,-0.9792228106, + -0.9795752496,-0.9799247046,-0.9802711746,-0.9806146585,-0.9809551553, + -0.9812926640,-0.9816271834,-0.9819587127,-0.9822872507,-0.9826127965, + -0.9829353491,-0.9832549076,-0.9835714708,-0.9838850379,-0.9841956080, + -0.9845031800,-0.9848077530,-0.9851093262,-0.9854078985,-0.9857034691, + -0.9859960371,-0.9862856015,-0.9865721616,-0.9868557164,-0.9871362651, + -0.9874138068,-0.9876883406,-0.9879598658,-0.9882283814,-0.9884938868, + -0.9887563810,-0.9890158634,-0.9892723330,-0.9895257891,-0.9897762309, + -0.9900236577,-0.9902680687,-0.9905094632,-0.9907478405,-0.9909831997, + -0.9912155403,-0.9914448614,-0.9916711624,-0.9918944426,-0.9921147013, + -0.9923319379,-0.9925461516,-0.9927573419,-0.9929655081,-0.9931706495, + -0.9933727656,-0.9935718557,-0.9937679192,-0.9939609555,-0.9941509640, + -0.9943379441,-0.9945218954,-0.9947028171,-0.9948807088,-0.9950555700, + -0.9952274000,-0.9953961984,-0.9955619646,-0.9957246982,-0.9958843986, + -0.9960410654,-0.9961946981,-0.9963452962,-0.9964928592,-0.9966373868, + -0.9967788785,-0.9969173337,-0.9970527522,-0.9971851335,-0.9973144772, + -0.9974407829,-0.9975640503,-0.9976842788,-0.9978014683,-0.9979156183, + -0.9980267284,-0.9981347984,-0.9982398279,-0.9983418166,-0.9984407642, + -0.9985366703,-0.9986295348,-0.9987193572,-0.9988061373,-0.9988898750, + -0.9989705698,-0.9990482216,-0.9991228301,-0.9991943951,-0.9992629164, + -0.9993283938,-0.9993908270,-0.9994502159,-0.9995065604,-0.9995598601, + -0.9996101150,-0.9996573250,-0.9997014898,-0.9997426093,-0.9997806835, + -0.9998157121,-0.9998476952,-0.9998766325,-0.9999025240,-0.9999253697, + -0.9999451694,-0.9999619231,-0.9999756307,-0.9999862922,-0.9999939077, + -0.9999984769,-1.0000000000,-0.9999984769,-0.9999939077,-0.9999862922, + -0.9999756307,-0.9999619231,-0.9999451694,-0.9999253697,-0.9999025240, + -0.9998766325,-0.9998476952,-0.9998157121,-0.9997806835,-0.9997426093, + -0.9997014898,-0.9996573250,-0.9996101150,-0.9995598601,-0.9995065604, + -0.9994502159,-0.9993908270,-0.9993283938,-0.9992629164,-0.9991943951, + -0.9991228301,-0.9990482216,-0.9989705698,-0.9988898750,-0.9988061373, + -0.9987193572,-0.9986295348,-0.9985366703,-0.9984407642,-0.9983418166, + -0.9982398279,-0.9981347984,-0.9980267284,-0.9979156183,-0.9978014683, + -0.9976842788,-0.9975640503,-0.9974407829,-0.9973144772,-0.9971851335, + -0.9970527522,-0.9969173337,-0.9967788785,-0.9966373868,-0.9964928592, + -0.9963452962,-0.9961946981,-0.9960410654,-0.9958843986,-0.9957246982, + -0.9955619646,-0.9953961984,-0.9952274000,-0.9950555700,-0.9948807088, + -0.9947028171,-0.9945218954,-0.9943379441,-0.9941509640,-0.9939609555, + -0.9937679192,-0.9935718557,-0.9933727656,-0.9931706495,-0.9929655081, + -0.9927573419,-0.9925461516,-0.9923319379,-0.9921147013,-0.9918944426, + -0.9916711624,-0.9914448614,-0.9912155403,-0.9909831997,-0.9907478405, + -0.9905094632,-0.9902680687,-0.9900236577,-0.9897762309,-0.9895257891, + -0.9892723330,-0.9890158634,-0.9887563810,-0.9884938868,-0.9882283814, + -0.9879598658,-0.9876883406,-0.9874138068,-0.9871362651,-0.9868557164, + -0.9865721616,-0.9862856015,-0.9859960371,-0.9857034691,-0.9854078985, + -0.9851093262,-0.9848077530,-0.9845031800,-0.9841956080,-0.9838850379, + -0.9835714708,-0.9832549076,-0.9829353491,-0.9826127965,-0.9822872507, + -0.9819587127,-0.9816271834,-0.9812926640,-0.9809551553,-0.9806146585, + -0.9802711746,-0.9799247046,-0.9795752496,-0.9792228106,-0.9788673888, + -0.9785089851,-0.9781476007,-0.9777832368,-0.9774158943,-0.9770455744, + -0.9766722783,-0.9762960071,-0.9759167619,-0.9755345439,-0.9751493543, + -0.9747611942,-0.9743700648,-0.9739759673,-0.9735789029,-0.9731788728, + -0.9727758782,-0.9723699204,-0.9719610006,-0.9715491200,-0.9711342799, + -0.9707164816,-0.9702957263,-0.9698720153,-0.9694453499,-0.9690157314, + -0.9685831611,-0.9681476404,-0.9677091705,-0.9672677528,-0.9668233886, + -0.9663760793,-0.9659258263,-0.9654726309,-0.9650164945,-0.9645574185, + -0.9640954042,-0.9636304532,-0.9631625668,-0.9626917464,-0.9622179935, + -0.9617413095,-0.9612616959,-0.9607791542,-0.9602936857,-0.9598052920, + -0.9593139745,-0.9588197349,-0.9583225745,-0.9578224948,-0.9573194975, + -0.9568135841,-0.9563047560,-0.9557930148,-0.9552783621,-0.9547607995, + -0.9542403285,-0.9537169507,-0.9531906678,-0.9526614813,-0.9521293927, + -0.9515944039,-0.9510565163,-0.9505157316,-0.9499720515,-0.9494254776, + -0.9488760116,-0.9483236552,-0.9477684100,-0.9472102777,-0.9466492601, + -0.9460853588,-0.9455185756,-0.9449489122,-0.9443763702,-0.9438009516, + -0.9432226579,-0.9426414911,-0.9420574528,-0.9414705448,-0.9408807690, + -0.9402881270,-0.9396926208,-0.9390942521,-0.9384930228,-0.9378889346, + -0.9372819895,-0.9366721892,-0.9360595357,-0.9354440308,-0.9348256764, + -0.9342044743,-0.9335804265,-0.9329535348,-0.9323238012,-0.9316912276, + -0.9310558159,-0.9304175680,-0.9297764859,-0.9291325715,-0.9284858269, + -0.9278362539,-0.9271838546,-0.9265286309,-0.9258705848,-0.9252097184, + -0.9245460336,-0.9238795325,-0.9232102171,-0.9225380895,-0.9218631516, + -0.9211854056,-0.9205048535,-0.9198214973,-0.9191353393,-0.9184463813, + -0.9177546257,-0.9170600744,-0.9163627296,-0.9156625933,-0.9149596678, + -0.9142539552,-0.9135454576,-0.9128341772,-0.9121201162,-0.9114032766, + -0.9106836608,-0.9099612709,-0.9092361090,-0.9085081775,-0.9077774785, + -0.9070440143,-0.9063077870,-0.9055687990,-0.9048270525,-0.9040825497, + -0.9033352929,-0.9025852843,-0.9018325264,-0.9010770213,-0.9003187714, + -0.8995577790,-0.8987940463,-0.8980275758,-0.8972583697,-0.8964864304, + -0.8957117602,-0.8949343616,-0.8941542368,-0.8933713883,-0.8925858185, + -0.8917975296,-0.8910065242,-0.8902128046,-0.8894163733,-0.8886172327, + -0.8878153851,-0.8870108332,-0.8862035792,-0.8853936258,-0.8845809752, + -0.8837656301,-0.8829475929,-0.8821268660,-0.8813034521,-0.8804773535, + -0.8796485729,-0.8788171127,-0.8779829754,-0.8771461637,-0.8763066800, + -0.8754645270,-0.8746197071,-0.8737722230,-0.8729220773,-0.8720692724, + -0.8712138111,-0.8703556959,-0.8694949295,-0.8686315144,-0.8677654534, + -0.8668967489,-0.8660254038,-0.8651514206,-0.8642748020,-0.8633955506, + -0.8625136692,-0.8616291604,-0.8607420270,-0.8598522716,-0.8589598969, + -0.8580649057,-0.8571673007,-0.8562670846,-0.8553642602,-0.8544588301, + -0.8535507973,-0.8526401644,-0.8517269341,-0.8508111094,-0.8498926930, + -0.8489716876,-0.8480480962,-0.8471219214,-0.8461931661,-0.8452618332, + -0.8443279255,-0.8433914458,-0.8424523970,-0.8415107819,-0.8405666035, + -0.8396198645,-0.8386705679,-0.8377187166,-0.8367643135,-0.8358073614, + -0.8348478633,-0.8338858221,-0.8329212407,-0.8319541221,-0.8309844693, + -0.8300122851,-0.8290375726,-0.8280603346,-0.8270805743,-0.8260982945, + -0.8251134983,-0.8241261886,-0.8231363685,-0.8221440410,-0.8211492091, + -0.8201518759,-0.8191520443,-0.8181497174,-0.8171448983,-0.8161375901, + -0.8151277957,-0.8141155184,-0.8131007610,-0.8120835269,-0.8110638190, + -0.8100416404,-0.8090169944,-0.8079898839,-0.8069603121,-0.8059282822, + -0.8048937974,-0.8038568606,-0.8028174752,-0.8017756442,-0.8007313709, + -0.7996846585,-0.7986355100,-0.7975839288,-0.7965299180,-0.7954734809, + -0.7944146205,-0.7933533403,-0.7922896434,-0.7912235330,-0.7901550124, + -0.7890840848,-0.7880107536,-0.7869350220,-0.7858568932,-0.7847763705, + -0.7836934573,-0.7826081569,-0.7815204724,-0.7804304073,-0.7793379649, + -0.7782431485,-0.7771459615,-0.7760464071,-0.7749444887,-0.7738402097, + -0.7727335735,-0.7716245834,-0.7705132428,-0.7693995550,-0.7682835236, + -0.7671651518,-0.7660444431,-0.7649214009,-0.7637960286,-0.7626683297, + -0.7615383075,-0.7604059656,-0.7592713073,-0.7581343362,-0.7569950557, + -0.7558534692,-0.7547095802,-0.7535633923,-0.7524149089,-0.7512641335, + -0.7501110696,-0.7489557208,-0.7477980905,-0.7466381823,-0.7454759997, + -0.7443115462,-0.7431448255,-0.7419758410,-0.7408045963,-0.7396310950, + -0.7384553406,-0.7372773368,-0.7360970871,-0.7349145951,-0.7337298645, + -0.7325428988,-0.7313537016,-0.7301622766,-0.7289686274,-0.7277727577, + -0.7265746710,-0.7253743710,-0.7241718614,-0.7229671459,-0.7217602281, + -0.7205511117,-0.7193398003,-0.7181262978,-0.7169106077,-0.7156927337, + -0.7144726796,-0.7132504492,-0.7120260460,-0.7107994739,-0.7095707365, + -0.7083398377,-0.7071067812,-0.7058715707,-0.7046342100,-0.7033947028, + -0.7021530530,-0.7009092643,-0.6996633405,-0.6984152854,-0.6971651029, + -0.6959127966,-0.6946583705,-0.6934018283,-0.6921431739,-0.6908824111, + -0.6896195437,-0.6883545757,-0.6870875108,-0.6858183529,-0.6845471059, + -0.6832737737,-0.6819983601,-0.6807208690,-0.6794413043,-0.6781596699, + -0.6768759697,-0.6755902076,-0.6743023876,-0.6730125135,-0.6717205893, + -0.6704266190,-0.6691306064,-0.6678325555,-0.6665324702,-0.6652303547, + -0.6639262127,-0.6626200482,-0.6613118653,-0.6600016680,-0.6586894601, + -0.6573752458,-0.6560590290,-0.6547408137,-0.6534206040,-0.6520984038, + -0.6507742173,-0.6494480483,-0.6481199011,-0.6467897795,-0.6454576877, + -0.6441236298,-0.6427876097,-0.6414496316,-0.6401096995,-0.6387678175, + -0.6374239897,-0.6360782203,-0.6347305132,-0.6333808726,-0.6320293027, + -0.6306758074,-0.6293203910,-0.6279630576,-0.6266038114,-0.6252426563, + -0.6238795967,-0.6225146366,-0.6211477803,-0.6197790318,-0.6184083954, + -0.6170358751,-0.6156614753,-0.6142852001,-0.6129070537,-0.6115270402, + -0.6101451639,-0.6087614290,-0.6073758397,-0.6059884003,-0.6045991149, + -0.6032079877,-0.6018150232,-0.6004202253,-0.5990235985,-0.5976251470, + -0.5962248750,-0.5948227868,-0.5934188866,-0.5920131788,-0.5906056676, + -0.5891963574,-0.5877852523,-0.5863723567,-0.5849576750,-0.5835412114, + -0.5821229702,-0.5807029557,-0.5792811723,-0.5778576244,-0.5764323162, + -0.5750052520,-0.5735764364,-0.5721458734,-0.5707135677,-0.5692795234, + -0.5678437451,-0.5664062369,-0.5649670034,-0.5635260489,-0.5620833779, + -0.5606389946,-0.5591929035,-0.5577451090,-0.5562956155,-0.5548444274, + -0.5533915492,-0.5519369853,-0.5504807401,-0.5490228180,-0.5475632235, + -0.5461019610,-0.5446390350,-0.5431744500,-0.5417082103,-0.5402403205, + -0.5387707850,-0.5372996083,-0.5358267950,-0.5343523494,-0.5328762761, + -0.5313985795,-0.5299192642,-0.5284383347,-0.5269557955,-0.5254716511, + -0.5239859060,-0.5224985647,-0.5210096318,-0.5195191119,-0.5180270094, + -0.5165333289,-0.5150380749,-0.5135412521,-0.5120428649,-0.5105429179, + -0.5090414158,-0.5075383630,-0.5060337641,-0.5045276238,-0.5030199466, + -0.5015107372,-0.5000000000,-0.4984877398,-0.4969739610,-0.4954586684, + -0.4939418666,-0.4924235601,-0.4909037536,-0.4893824517,-0.4878596591, + -0.4863353804,-0.4848096202,-0.4832823833,-0.4817536741,-0.4802234974, + -0.4786918579,-0.4771587603,-0.4756242091,-0.4740882090,-0.4725507649, + -0.4710118812,-0.4694715628,-0.4679298143,-0.4663866403,-0.4648420457, + -0.4632960351,-0.4617486132,-0.4601997848,-0.4586495545,-0.4570979271, + -0.4555449072,-0.4539904997,-0.4524347093,-0.4508775407,-0.4493189986, + -0.4477590878,-0.4461978131,-0.4446351792,-0.4430711908,-0.4415058528, + -0.4399391699,-0.4383711468,-0.4368017884,-0.4352310994,-0.4336590846, + -0.4320857488,-0.4305110968,-0.4289351334,-0.4273578634,-0.4257792916, + -0.4241994227,-0.4226182617,-0.4210358134,-0.4194520824,-0.4178670738, + -0.4162807923,-0.4146932427,-0.4131044298,-0.4115143586,-0.4099230338, + -0.4083304604,-0.4067366431,-0.4051415868,-0.4035452964,-0.4019477767, + -0.4003490326,-0.3987490689,-0.3971478906,-0.3955455026,-0.3939419096, + -0.3923371166,-0.3907311285,-0.3891239501,-0.3875155865,-0.3859060423, + -0.3842953227,-0.3826834324,-0.3810703764,-0.3794561595,-0.3778407868, + -0.3762242631,-0.3746065934,-0.3729877826,-0.3713678356,-0.3697467573, + -0.3681245527,-0.3665012267,-0.3648767843,-0.3632512305,-0.3616245701, + -0.3599968081,-0.3583679495,-0.3567379993,-0.3551069624,-0.3534748438, + -0.3518416484,-0.3502073813,-0.3485720473,-0.3469356516,-0.3452981990, + -0.3436596946,-0.3420201433,-0.3403795502,-0.3387379202,-0.3370952584, + -0.3354515698,-0.3338068592,-0.3321611319,-0.3305143927,-0.3288666467, + -0.3272178990,-0.3255681545,-0.3239174182,-0.3222656952,-0.3206129906, + -0.3189593093,-0.3173046564,-0.3156490369,-0.3139924560,-0.3123349185, + -0.3106764296,-0.3090169944,-0.3073566178,-0.3056953050,-0.3040330609, + -0.3023698908,-0.3007057995,-0.2990407923,-0.2973748741,-0.2957080500, + -0.2940403252,-0.2923717047,-0.2907021936,-0.2890317969,-0.2873605198, + -0.2856883674,-0.2840153447,-0.2823414568,-0.2806667089,-0.2789911060, + -0.2773146533,-0.2756373558,-0.2739592187,-0.2722802470,-0.2706004460, + -0.2689198206,-0.2672383761,-0.2655561175,-0.2638730500,-0.2621891786, + -0.2605045086,-0.2588190451,-0.2571327932,-0.2554457579,-0.2537579446, + -0.2520693582,-0.2503800041,-0.2486898872,-0.2469990127,-0.2453073859, + -0.2436150118,-0.2419218956,-0.2402280425,-0.2385334576,-0.2368381461, + -0.2351421131,-0.2334453639,-0.2317479035,-0.2300497372,-0.2283508701, + -0.2266513074,-0.2249510543,-0.2232501160,-0.2215484976,-0.2198462044, + -0.2181432414,-0.2164396139,-0.2147353272,-0.2130303863,-0.2113247965, + -0.2096185629,-0.2079116908,-0.2062041854,-0.2044960518,-0.2027872954, + -0.2010779211,-0.1993679344,-0.1976573404,-0.1959461442,-0.1942343512, + -0.1925219665,-0.1908089954,-0.1890954430,-0.1873813146,-0.1856666154, + -0.1839513506,-0.1822355255,-0.1805191453,-0.1788022151,-0.1770847403, + -0.1753667261,-0.1736481777,-0.1719291003,-0.1702094992,-0.1684893796, + -0.1667687467,-0.1650476059,-0.1633259622,-0.1616038211,-0.1598811877, + -0.1581580673,-0.1564344650,-0.1547103863,-0.1529858363,-0.1512608202, + -0.1495353434,-0.1478094111,-0.1460830286,-0.1443562010,-0.1426289337, + -0.1409012319,-0.1391731010,-0.1374445460,-0.1357155724,-0.1339861854, + -0.1322563903,-0.1305261922,-0.1287955966,-0.1270646086,-0.1253332336, + -0.1236014767,-0.1218693434,-0.1201368388,-0.1184039683,-0.1166707371, + -0.1149371505,-0.1132032138,-0.1114689322,-0.1097343111,-0.1079993557, + -0.1062640713,-0.1045284633,-0.1027925368,-0.1010562972,-0.0993197497, + -0.0975828998,-0.0958457525,-0.0941083133,-0.0923705874,-0.0906325802, + -0.0888942969,-0.0871557427,-0.0854169231,-0.0836778433,-0.0819385086, + -0.0801989243,-0.0784590957,-0.0767190281,-0.0749787268,-0.0732381971, + -0.0714974443,-0.0697564737,-0.0680152907,-0.0662739004,-0.0645323083, + -0.0627905195,-0.0610485395,-0.0593063736,-0.0575640270,-0.0558215050, + -0.0540788130,-0.0523359562,-0.0505929401,-0.0488497698,-0.0471064507, + -0.0453629881,-0.0436193874,-0.0418756537,-0.0401317925,-0.0383878091, + -0.0366437087,-0.0348994967,-0.0331551784,-0.0314107591,-0.0296662441, + -0.0279216387,-0.0261769483,-0.0244321782,-0.0226873336,-0.0209424199, + -0.0191974424,-0.0174524064,-0.0157073173,-0.0139621803,-0.0122170008, + -0.0104717841,-0.0087265355,-0.0069812603,-0.0052359638,-0.0034906514, + -0.0017453284} +#endif + ; + +eda_global float fcosinus[3600] +#if defined MAIN + = { + 1.0000000000,0.9999984769,0.9999939077,0.9999862922, + 0.9999756307,0.9999619231,0.9999451694,0.9999253697,0.9999025240, + 0.9998766325,0.9998476952,0.9998157121,0.9997806835,0.9997426093, + 0.9997014898,0.9996573250,0.9996101150,0.9995598601,0.9995065604, + 0.9994502159,0.9993908270,0.9993283938,0.9992629164,0.9991943951, + 0.9991228301,0.9990482216,0.9989705698,0.9988898750,0.9988061373, + 0.9987193572,0.9986295348,0.9985366703,0.9984407642,0.9983418166, + 0.9982398279,0.9981347984,0.9980267284,0.9979156183,0.9978014683, + 0.9976842788,0.9975640503,0.9974407829,0.9973144772,0.9971851335, + 0.9970527522,0.9969173337,0.9967788785,0.9966373868,0.9964928592, + 0.9963452962,0.9961946981,0.9960410654,0.9958843986,0.9957246982, + 0.9955619646,0.9953961984,0.9952274000,0.9950555700,0.9948807088, + 0.9947028171,0.9945218954,0.9943379441,0.9941509640,0.9939609555, + 0.9937679192,0.9935718557,0.9933727656,0.9931706495,0.9929655081, + 0.9927573419,0.9925461516,0.9923319379,0.9921147013,0.9918944426, + 0.9916711624,0.9914448614,0.9912155403,0.9909831997,0.9907478405, + 0.9905094632,0.9902680687,0.9900236577,0.9897762309,0.9895257891, + 0.9892723330,0.9890158634,0.9887563810,0.9884938868,0.9882283814, + 0.9879598658,0.9876883406,0.9874138068,0.9871362651,0.9868557164, + 0.9865721616,0.9862856015,0.9859960371,0.9857034691,0.9854078985, + 0.9851093262,0.9848077530,0.9845031800,0.9841956080,0.9838850379, + 0.9835714708,0.9832549076,0.9829353491,0.9826127965,0.9822872507, + 0.9819587127,0.9816271834,0.9812926640,0.9809551553,0.9806146585, + 0.9802711746,0.9799247046,0.9795752496,0.9792228106,0.9788673888, + 0.9785089851,0.9781476007,0.9777832368,0.9774158943,0.9770455744, + 0.9766722783,0.9762960071,0.9759167619,0.9755345439,0.9751493543, + 0.9747611942,0.9743700648,0.9739759673,0.9735789029,0.9731788728, + 0.9727758782,0.9723699204,0.9719610006,0.9715491200,0.9711342799, + 0.9707164816,0.9702957263,0.9698720153,0.9694453499,0.9690157314, + 0.9685831611,0.9681476404,0.9677091705,0.9672677528,0.9668233886, + 0.9663760793,0.9659258263,0.9654726309,0.9650164945,0.9645574185, + 0.9640954042,0.9636304532,0.9631625668,0.9626917464,0.9622179935, + 0.9617413095,0.9612616959,0.9607791542,0.9602936857,0.9598052920, + 0.9593139745,0.9588197349,0.9583225745,0.9578224948,0.9573194975, + 0.9568135841,0.9563047560,0.9557930148,0.9552783621,0.9547607995, + 0.9542403285,0.9537169507,0.9531906678,0.9526614813,0.9521293927, + 0.9515944039,0.9510565163,0.9505157316,0.9499720515,0.9494254776, + 0.9488760116,0.9483236552,0.9477684100,0.9472102777,0.9466492601, + 0.9460853588,0.9455185756,0.9449489122,0.9443763702,0.9438009516, + 0.9432226579,0.9426414911,0.9420574528,0.9414705448,0.9408807690, + 0.9402881270,0.9396926208,0.9390942521,0.9384930228,0.9378889346, + 0.9372819895,0.9366721892,0.9360595357,0.9354440308,0.9348256764, + 0.9342044743,0.9335804265,0.9329535348,0.9323238012,0.9316912276, + 0.9310558159,0.9304175680,0.9297764859,0.9291325715,0.9284858269, + 0.9278362539,0.9271838546,0.9265286309,0.9258705848,0.9252097184, + 0.9245460336,0.9238795325,0.9232102171,0.9225380895,0.9218631516, + 0.9211854056,0.9205048535,0.9198214973,0.9191353393,0.9184463813, + 0.9177546257,0.9170600744,0.9163627296,0.9156625933,0.9149596678, + 0.9142539552,0.9135454576,0.9128341772,0.9121201162,0.9114032766, + 0.9106836608,0.9099612709,0.9092361090,0.9085081775,0.9077774785, + 0.9070440143,0.9063077870,0.9055687990,0.9048270525,0.9040825497, + 0.9033352929,0.9025852843,0.9018325264,0.9010770213,0.9003187714, + 0.8995577790,0.8987940463,0.8980275758,0.8972583697,0.8964864304, + 0.8957117602,0.8949343616,0.8941542368,0.8933713883,0.8925858185, + 0.8917975296,0.8910065242,0.8902128046,0.8894163733,0.8886172327, + 0.8878153851,0.8870108332,0.8862035792,0.8853936258,0.8845809752, + 0.8837656301,0.8829475929,0.8821268660,0.8813034521,0.8804773535, + 0.8796485729,0.8788171127,0.8779829754,0.8771461637,0.8763066800, + 0.8754645270,0.8746197071,0.8737722230,0.8729220773,0.8720692724, + 0.8712138111,0.8703556959,0.8694949295,0.8686315144,0.8677654534, + 0.8668967489,0.8660254038,0.8651514206,0.8642748020,0.8633955506, + 0.8625136692,0.8616291604,0.8607420270,0.8598522716,0.8589598969, + 0.8580649057,0.8571673007,0.8562670846,0.8553642602,0.8544588301, + 0.8535507973,0.8526401644,0.8517269341,0.8508111094,0.8498926930, + 0.8489716876,0.8480480962,0.8471219214,0.8461931661,0.8452618332, + 0.8443279255,0.8433914458,0.8424523970,0.8415107819,0.8405666035, + 0.8396198645,0.8386705679,0.8377187166,0.8367643135,0.8358073614, + 0.8348478633,0.8338858221,0.8329212407,0.8319541221,0.8309844693, + 0.8300122851,0.8290375726,0.8280603346,0.8270805743,0.8260982945, + 0.8251134983,0.8241261886,0.8231363685,0.8221440410,0.8211492091, + 0.8201518759,0.8191520443,0.8181497174,0.8171448983,0.8161375901, + 0.8151277957,0.8141155184,0.8131007610,0.8120835269,0.8110638190, + 0.8100416404,0.8090169944,0.8079898839,0.8069603121,0.8059282822, + 0.8048937974,0.8038568606,0.8028174752,0.8017756442,0.8007313709, + 0.7996846585,0.7986355100,0.7975839288,0.7965299180,0.7954734809, + 0.7944146205,0.7933533403,0.7922896434,0.7912235330,0.7901550124, + 0.7890840848,0.7880107536,0.7869350220,0.7858568932,0.7847763705, + 0.7836934573,0.7826081569,0.7815204724,0.7804304073,0.7793379649, + 0.7782431485,0.7771459615,0.7760464071,0.7749444887,0.7738402097, + 0.7727335735,0.7716245834,0.7705132428,0.7693995550,0.7682835236, + 0.7671651518,0.7660444431,0.7649214009,0.7637960286,0.7626683297, + 0.7615383075,0.7604059656,0.7592713073,0.7581343362,0.7569950557, + 0.7558534692,0.7547095802,0.7535633923,0.7524149089,0.7512641335, + 0.7501110696,0.7489557208,0.7477980905,0.7466381823,0.7454759997, + 0.7443115462,0.7431448255,0.7419758410,0.7408045963,0.7396310950, + 0.7384553406,0.7372773368,0.7360970871,0.7349145951,0.7337298645, + 0.7325428988,0.7313537016,0.7301622766,0.7289686274,0.7277727577, + 0.7265746710,0.7253743710,0.7241718614,0.7229671459,0.7217602281, + 0.7205511117,0.7193398003,0.7181262978,0.7169106077,0.7156927337, + 0.7144726796,0.7132504492,0.7120260460,0.7107994739,0.7095707365, + 0.7083398377,0.7071067812,0.7058715707,0.7046342100,0.7033947028, + 0.7021530530,0.7009092643,0.6996633405,0.6984152854,0.6971651029, + 0.6959127966,0.6946583705,0.6934018283,0.6921431739,0.6908824111, + 0.6896195437,0.6883545757,0.6870875108,0.6858183529,0.6845471059, + 0.6832737737,0.6819983601,0.6807208690,0.6794413043,0.6781596699, + 0.6768759697,0.6755902076,0.6743023876,0.6730125135,0.6717205893, + 0.6704266190,0.6691306064,0.6678325555,0.6665324702,0.6652303547, + 0.6639262127,0.6626200482,0.6613118653,0.6600016680,0.6586894601, + 0.6573752458,0.6560590290,0.6547408137,0.6534206040,0.6520984038, + 0.6507742173,0.6494480483,0.6481199011,0.6467897795,0.6454576877, + 0.6441236298,0.6427876097,0.6414496316,0.6401096995,0.6387678175, + 0.6374239897,0.6360782203,0.6347305132,0.6333808726,0.6320293027, + 0.6306758074,0.6293203910,0.6279630576,0.6266038114,0.6252426563, + 0.6238795967,0.6225146366,0.6211477803,0.6197790318,0.6184083954, + 0.6170358751,0.6156614753,0.6142852001,0.6129070537,0.6115270402, + 0.6101451639,0.6087614290,0.6073758397,0.6059884003,0.6045991149, + 0.6032079877,0.6018150232,0.6004202253,0.5990235985,0.5976251470, + 0.5962248750,0.5948227868,0.5934188866,0.5920131788,0.5906056676, + 0.5891963574,0.5877852523,0.5863723567,0.5849576750,0.5835412114, + 0.5821229702,0.5807029557,0.5792811723,0.5778576244,0.5764323162, + 0.5750052520,0.5735764364,0.5721458734,0.5707135677,0.5692795234, + 0.5678437451,0.5664062369,0.5649670034,0.5635260489,0.5620833779, + 0.5606389946,0.5591929035,0.5577451090,0.5562956155,0.5548444274, + 0.5533915492,0.5519369853,0.5504807401,0.5490228180,0.5475632235, + 0.5461019610,0.5446390350,0.5431744500,0.5417082103,0.5402403205, + 0.5387707850,0.5372996083,0.5358267950,0.5343523494,0.5328762761, + 0.5313985795,0.5299192642,0.5284383347,0.5269557955,0.5254716511, + 0.5239859060,0.5224985647,0.5210096318,0.5195191119,0.5180270094, + 0.5165333289,0.5150380749,0.5135412521,0.5120428649,0.5105429179, + 0.5090414158,0.5075383630,0.5060337641,0.5045276238,0.5030199466, + 0.5015107372,0.5000000000,0.4984877398,0.4969739610,0.4954586684, + 0.4939418666,0.4924235601,0.4909037536,0.4893824517,0.4878596591, + 0.4863353804,0.4848096202,0.4832823833,0.4817536741,0.4802234974, + 0.4786918579,0.4771587603,0.4756242091,0.4740882090,0.4725507649, + 0.4710118812,0.4694715628,0.4679298143,0.4663866403,0.4648420457, + 0.4632960351,0.4617486132,0.4601997848,0.4586495545,0.4570979271, + 0.4555449072,0.4539904997,0.4524347093,0.4508775407,0.4493189986, + 0.4477590878,0.4461978131,0.4446351792,0.4430711908,0.4415058528, + 0.4399391699,0.4383711468,0.4368017884,0.4352310994,0.4336590846, + 0.4320857488,0.4305110968,0.4289351334,0.4273578634,0.4257792916, + 0.4241994227,0.4226182617,0.4210358134,0.4194520824,0.4178670738, + 0.4162807923,0.4146932427,0.4131044298,0.4115143586,0.4099230338, + 0.4083304604,0.4067366431,0.4051415868,0.4035452964,0.4019477767, + 0.4003490326,0.3987490689,0.3971478906,0.3955455026,0.3939419096, + 0.3923371166,0.3907311285,0.3891239501,0.3875155865,0.3859060423, + 0.3842953227,0.3826834324,0.3810703764,0.3794561595,0.3778407868, + 0.3762242631,0.3746065934,0.3729877826,0.3713678356,0.3697467573, + 0.3681245527,0.3665012267,0.3648767843,0.3632512305,0.3616245701, + 0.3599968081,0.3583679495,0.3567379993,0.3551069624,0.3534748438, + 0.3518416484,0.3502073813,0.3485720473,0.3469356516,0.3452981990, + 0.3436596946,0.3420201433,0.3403795502,0.3387379202,0.3370952584, + 0.3354515698,0.3338068592,0.3321611319,0.3305143927,0.3288666467, + 0.3272178990,0.3255681545,0.3239174182,0.3222656952,0.3206129906, + 0.3189593093,0.3173046564,0.3156490369,0.3139924560,0.3123349185, + 0.3106764296,0.3090169944,0.3073566178,0.3056953050,0.3040330609, + 0.3023698908,0.3007057995,0.2990407923,0.2973748741,0.2957080500, + 0.2940403252,0.2923717047,0.2907021936,0.2890317969,0.2873605198, + 0.2856883674,0.2840153447,0.2823414568,0.2806667089,0.2789911060, + 0.2773146533,0.2756373558,0.2739592187,0.2722802470,0.2706004460, + 0.2689198206,0.2672383761,0.2655561175,0.2638730500,0.2621891786, + 0.2605045086,0.2588190451,0.2571327932,0.2554457579,0.2537579446, + 0.2520693582,0.2503800041,0.2486898872,0.2469990127,0.2453073859, + 0.2436150118,0.2419218956,0.2402280425,0.2385334576,0.2368381461, + 0.2351421131,0.2334453639,0.2317479035,0.2300497372,0.2283508701, + 0.2266513074,0.2249510543,0.2232501160,0.2215484976,0.2198462044, + 0.2181432414,0.2164396139,0.2147353272,0.2130303863,0.2113247965, + 0.2096185629,0.2079116908,0.2062041854,0.2044960518,0.2027872954, + 0.2010779211,0.1993679344,0.1976573404,0.1959461442,0.1942343512, + 0.1925219665,0.1908089954,0.1890954430,0.1873813146,0.1856666154, + 0.1839513506,0.1822355255,0.1805191453,0.1788022151,0.1770847403, + 0.1753667261,0.1736481777,0.1719291003,0.1702094992,0.1684893796, + 0.1667687467,0.1650476059,0.1633259622,0.1616038211,0.1598811877, + 0.1581580673,0.1564344650,0.1547103863,0.1529858363,0.1512608202, + 0.1495353434,0.1478094111,0.1460830286,0.1443562010,0.1426289337, + 0.1409012319,0.1391731010,0.1374445460,0.1357155724,0.1339861854, + 0.1322563903,0.1305261922,0.1287955966,0.1270646086,0.1253332336, + 0.1236014767,0.1218693434,0.1201368388,0.1184039683,0.1166707371, + 0.1149371505,0.1132032138,0.1114689322,0.1097343111,0.1079993557, + 0.1062640713,0.1045284633,0.1027925368,0.1010562972,0.0993197497, + 0.0975828998,0.0958457525,0.0941083133,0.0923705874,0.0906325802, + 0.0888942969,0.0871557427,0.0854169231,0.0836778433,0.0819385086, + 0.0801989243,0.0784590957,0.0767190281,0.0749787268,0.0732381971, + 0.0714974443,0.0697564737,0.0680152907,0.0662739004,0.0645323083, + 0.0627905195,0.0610485395,0.0593063736,0.0575640270,0.0558215050, + 0.0540788130,0.0523359562,0.0505929401,0.0488497698,0.0471064507, + 0.0453629881,0.0436193874,0.0418756537,0.0401317925,0.0383878091, + 0.0366437087,0.0348994967,0.0331551784,0.0314107591,0.0296662441, + 0.0279216387,0.0261769483,0.0244321782,0.0226873336,0.0209424199, + 0.0191974424,0.0174524064,0.0157073173,0.0139621803,0.0122170008, + 0.0104717841,0.0087265355,0.0069812603,0.0052359638,0.0034906514, + 0.0017453284,0.0000000000,-0.0017453284,-0.0034906514,-0.0052359638, + -0.0069812603,-0.0087265355,-0.0104717841,-0.0122170008,-0.0139621803, + -0.0157073173,-0.0174524064,-0.0191974424,-0.0209424199,-0.0226873336, + -0.0244321782,-0.0261769483,-0.0279216387,-0.0296662441,-0.0314107591, + -0.0331551784,-0.0348994967,-0.0366437087,-0.0383878091,-0.0401317925, + -0.0418756537,-0.0436193874,-0.0453629881,-0.0471064507,-0.0488497698, + -0.0505929401,-0.0523359562,-0.0540788130,-0.0558215050,-0.0575640270, + -0.0593063736,-0.0610485395,-0.0627905195,-0.0645323083,-0.0662739004, + -0.0680152907,-0.0697564737,-0.0714974443,-0.0732381971,-0.0749787268, + -0.0767190281,-0.0784590957,-0.0801989243,-0.0819385086,-0.0836778433, + -0.0854169231,-0.0871557427,-0.0888942969,-0.0906325802,-0.0923705874, + -0.0941083133,-0.0958457525,-0.0975828998,-0.0993197497,-0.1010562972, + -0.1027925368,-0.1045284633,-0.1062640713,-0.1079993557,-0.1097343111, + -0.1114689322,-0.1132032138,-0.1149371505,-0.1166707371,-0.1184039683, + -0.1201368388,-0.1218693434,-0.1236014767,-0.1253332336,-0.1270646086, + -0.1287955966,-0.1305261922,-0.1322563903,-0.1339861854,-0.1357155724, + -0.1374445460,-0.1391731010,-0.1409012319,-0.1426289337,-0.1443562010, + -0.1460830286,-0.1478094111,-0.1495353434,-0.1512608202,-0.1529858363, + -0.1547103863,-0.1564344650,-0.1581580673,-0.1598811877,-0.1616038211, + -0.1633259622,-0.1650476059,-0.1667687467,-0.1684893796,-0.1702094992, + -0.1719291003,-0.1736481777,-0.1753667261,-0.1770847403,-0.1788022151, + -0.1805191453,-0.1822355255,-0.1839513506,-0.1856666154,-0.1873813146, + -0.1890954430,-0.1908089954,-0.1925219665,-0.1942343512,-0.1959461442, + -0.1976573404,-0.1993679344,-0.2010779211,-0.2027872954,-0.2044960518, + -0.2062041854,-0.2079116908,-0.2096185629,-0.2113247965,-0.2130303863, + -0.2147353272,-0.2164396139,-0.2181432414,-0.2198462044,-0.2215484976, + -0.2232501160,-0.2249510543,-0.2266513074,-0.2283508701,-0.2300497372, + -0.2317479035,-0.2334453639,-0.2351421131,-0.2368381461,-0.2385334576, + -0.2402280425,-0.2419218956,-0.2436150118,-0.2453073859,-0.2469990127, + -0.2486898872,-0.2503800041,-0.2520693582,-0.2537579446,-0.2554457579, + -0.2571327932,-0.2588190451,-0.2605045086,-0.2621891786,-0.2638730500, + -0.2655561175,-0.2672383761,-0.2689198206,-0.2706004460,-0.2722802470, + -0.2739592187,-0.2756373558,-0.2773146533,-0.2789911060,-0.2806667089, + -0.2823414568,-0.2840153447,-0.2856883674,-0.2873605198,-0.2890317969, + -0.2907021936,-0.2923717047,-0.2940403252,-0.2957080500,-0.2973748741, + -0.2990407923,-0.3007057995,-0.3023698908,-0.3040330609,-0.3056953050, + -0.3073566178,-0.3090169944,-0.3106764296,-0.3123349185,-0.3139924560, + -0.3156490369,-0.3173046564,-0.3189593093,-0.3206129906,-0.3222656952, + -0.3239174182,-0.3255681545,-0.3272178990,-0.3288666467,-0.3305143927, + -0.3321611319,-0.3338068592,-0.3354515698,-0.3370952584,-0.3387379202, + -0.3403795502,-0.3420201433,-0.3436596946,-0.3452981990,-0.3469356516, + -0.3485720473,-0.3502073813,-0.3518416484,-0.3534748438,-0.3551069624, + -0.3567379993,-0.3583679495,-0.3599968081,-0.3616245701,-0.3632512305, + -0.3648767843,-0.3665012267,-0.3681245527,-0.3697467573,-0.3713678356, + -0.3729877826,-0.3746065934,-0.3762242631,-0.3778407868,-0.3794561595, + -0.3810703764,-0.3826834324,-0.3842953227,-0.3859060423,-0.3875155865, + -0.3891239501,-0.3907311285,-0.3923371166,-0.3939419096,-0.3955455026, + -0.3971478906,-0.3987490689,-0.4003490326,-0.4019477767,-0.4035452964, + -0.4051415868,-0.4067366431,-0.4083304604,-0.4099230338,-0.4115143586, + -0.4131044298,-0.4146932427,-0.4162807923,-0.4178670738,-0.4194520824, + -0.4210358134,-0.4226182617,-0.4241994227,-0.4257792916,-0.4273578634, + -0.4289351334,-0.4305110968,-0.4320857488,-0.4336590846,-0.4352310994, + -0.4368017884,-0.4383711468,-0.4399391699,-0.4415058528,-0.4430711908, + -0.4446351792,-0.4461978131,-0.4477590878,-0.4493189986,-0.4508775407, + -0.4524347093,-0.4539904997,-0.4555449072,-0.4570979271,-0.4586495545, + -0.4601997848,-0.4617486132,-0.4632960351,-0.4648420457,-0.4663866403, + -0.4679298143,-0.4694715628,-0.4710118812,-0.4725507649,-0.4740882090, + -0.4756242091,-0.4771587603,-0.4786918579,-0.4802234974,-0.4817536741, + -0.4832823833,-0.4848096202,-0.4863353804,-0.4878596591,-0.4893824517, + -0.4909037536,-0.4924235601,-0.4939418666,-0.4954586684,-0.4969739610, + -0.4984877398,-0.5000000000,-0.5015107372,-0.5030199466,-0.5045276238, + -0.5060337641,-0.5075383630,-0.5090414158,-0.5105429179,-0.5120428649, + -0.5135412521,-0.5150380749,-0.5165333289,-0.5180270094,-0.5195191119, + -0.5210096318,-0.5224985647,-0.5239859060,-0.5254716511,-0.5269557955, + -0.5284383347,-0.5299192642,-0.5313985795,-0.5328762761,-0.5343523494, + -0.5358267950,-0.5372996083,-0.5387707850,-0.5402403205,-0.5417082103, + -0.5431744500,-0.5446390350,-0.5461019610,-0.5475632235,-0.5490228180, + -0.5504807401,-0.5519369853,-0.5533915492,-0.5548444274,-0.5562956155, + -0.5577451090,-0.5591929035,-0.5606389946,-0.5620833779,-0.5635260489, + -0.5649670034,-0.5664062369,-0.5678437451,-0.5692795234,-0.5707135677, + -0.5721458734,-0.5735764364,-0.5750052520,-0.5764323162,-0.5778576244, + -0.5792811723,-0.5807029557,-0.5821229702,-0.5835412114,-0.5849576750, + -0.5863723567,-0.5877852523,-0.5891963574,-0.5906056676,-0.5920131788, + -0.5934188866,-0.5948227868,-0.5962248750,-0.5976251470,-0.5990235985, + -0.6004202253,-0.6018150232,-0.6032079877,-0.6045991149,-0.6059884003, + -0.6073758397,-0.6087614290,-0.6101451639,-0.6115270402,-0.6129070537, + -0.6142852001,-0.6156614753,-0.6170358751,-0.6184083954,-0.6197790318, + -0.6211477803,-0.6225146366,-0.6238795967,-0.6252426563,-0.6266038114, + -0.6279630576,-0.6293203910,-0.6306758074,-0.6320293027,-0.6333808726, + -0.6347305132,-0.6360782203,-0.6374239897,-0.6387678175,-0.6401096995, + -0.6414496316,-0.6427876097,-0.6441236298,-0.6454576877,-0.6467897795, + -0.6481199011,-0.6494480483,-0.6507742173,-0.6520984038,-0.6534206040, + -0.6547408137,-0.6560590290,-0.6573752458,-0.6586894601,-0.6600016680, + -0.6613118653,-0.6626200482,-0.6639262127,-0.6652303547,-0.6665324702, + -0.6678325555,-0.6691306064,-0.6704266190,-0.6717205893,-0.6730125135, + -0.6743023876,-0.6755902076,-0.6768759697,-0.6781596699,-0.6794413043, + -0.6807208690,-0.6819983601,-0.6832737737,-0.6845471059,-0.6858183529, + -0.6870875108,-0.6883545757,-0.6896195437,-0.6908824111,-0.6921431739, + -0.6934018283,-0.6946583705,-0.6959127966,-0.6971651029,-0.6984152854, + -0.6996633405,-0.7009092643,-0.7021530530,-0.7033947028,-0.7046342100, + -0.7058715707,-0.7071067812,-0.7083398377,-0.7095707365,-0.7107994739, + -0.7120260460,-0.7132504492,-0.7144726796,-0.7156927337,-0.7169106077, + -0.7181262978,-0.7193398003,-0.7205511117,-0.7217602281,-0.7229671459, + -0.7241718614,-0.7253743710,-0.7265746710,-0.7277727577,-0.7289686274, + -0.7301622766,-0.7313537016,-0.7325428988,-0.7337298645,-0.7349145951, + -0.7360970871,-0.7372773368,-0.7384553406,-0.7396310950,-0.7408045963, + -0.7419758410,-0.7431448255,-0.7443115462,-0.7454759997,-0.7466381823, + -0.7477980905,-0.7489557208,-0.7501110696,-0.7512641335,-0.7524149089, + -0.7535633923,-0.7547095802,-0.7558534692,-0.7569950557,-0.7581343362, + -0.7592713073,-0.7604059656,-0.7615383075,-0.7626683297,-0.7637960286, + -0.7649214009,-0.7660444431,-0.7671651518,-0.7682835236,-0.7693995550, + -0.7705132428,-0.7716245834,-0.7727335735,-0.7738402097,-0.7749444887, + -0.7760464071,-0.7771459615,-0.7782431485,-0.7793379649,-0.7804304073, + -0.7815204724,-0.7826081569,-0.7836934573,-0.7847763705,-0.7858568932, + -0.7869350220,-0.7880107536,-0.7890840848,-0.7901550124,-0.7912235330, + -0.7922896434,-0.7933533403,-0.7944146205,-0.7954734809,-0.7965299180, + -0.7975839288,-0.7986355100,-0.7996846585,-0.8007313709,-0.8017756442, + -0.8028174752,-0.8038568606,-0.8048937974,-0.8059282822,-0.8069603121, + -0.8079898839,-0.8090169944,-0.8100416404,-0.8110638190,-0.8120835269, + -0.8131007610,-0.8141155184,-0.8151277957,-0.8161375901,-0.8171448983, + -0.8181497174,-0.8191520443,-0.8201518759,-0.8211492091,-0.8221440410, + -0.8231363685,-0.8241261886,-0.8251134983,-0.8260982945,-0.8270805743, + -0.8280603346,-0.8290375726,-0.8300122851,-0.8309844693,-0.8319541221, + -0.8329212407,-0.8338858221,-0.8348478633,-0.8358073614,-0.8367643135, + -0.8377187166,-0.8386705679,-0.8396198645,-0.8405666035,-0.8415107819, + -0.8424523970,-0.8433914458,-0.8443279255,-0.8452618332,-0.8461931661, + -0.8471219214,-0.8480480962,-0.8489716876,-0.8498926930,-0.8508111094, + -0.8517269341,-0.8526401644,-0.8535507973,-0.8544588301,-0.8553642602, + -0.8562670846,-0.8571673007,-0.8580649057,-0.8589598969,-0.8598522716, + -0.8607420270,-0.8616291604,-0.8625136692,-0.8633955506,-0.8642748020, + -0.8651514206,-0.8660254038,-0.8668967489,-0.8677654534,-0.8686315144, + -0.8694949295,-0.8703556959,-0.8712138111,-0.8720692724,-0.8729220773, + -0.8737722230,-0.8746197071,-0.8754645270,-0.8763066800,-0.8771461637, + -0.8779829754,-0.8788171127,-0.8796485729,-0.8804773535,-0.8813034521, + -0.8821268660,-0.8829475929,-0.8837656301,-0.8845809752,-0.8853936258, + -0.8862035792,-0.8870108332,-0.8878153851,-0.8886172327,-0.8894163733, + -0.8902128046,-0.8910065242,-0.8917975296,-0.8925858185,-0.8933713883, + -0.8941542368,-0.8949343616,-0.8957117602,-0.8964864304,-0.8972583697, + -0.8980275758,-0.8987940463,-0.8995577790,-0.9003187714,-0.9010770213, + -0.9018325264,-0.9025852843,-0.9033352929,-0.9040825497,-0.9048270525, + -0.9055687990,-0.9063077870,-0.9070440143,-0.9077774785,-0.9085081775, + -0.9092361090,-0.9099612709,-0.9106836608,-0.9114032766,-0.9121201162, + -0.9128341772,-0.9135454576,-0.9142539552,-0.9149596678,-0.9156625933, + -0.9163627296,-0.9170600744,-0.9177546257,-0.9184463813,-0.9191353393, + -0.9198214973,-0.9205048535,-0.9211854056,-0.9218631516,-0.9225380895, + -0.9232102171,-0.9238795325,-0.9245460336,-0.9252097184,-0.9258705848, + -0.9265286309,-0.9271838546,-0.9278362539,-0.9284858269,-0.9291325715, + -0.9297764859,-0.9304175680,-0.9310558159,-0.9316912276,-0.9323238012, + -0.9329535348,-0.9335804265,-0.9342044743,-0.9348256764,-0.9354440308, + -0.9360595357,-0.9366721892,-0.9372819895,-0.9378889346,-0.9384930228, + -0.9390942521,-0.9396926208,-0.9402881270,-0.9408807690,-0.9414705448, + -0.9420574528,-0.9426414911,-0.9432226579,-0.9438009516,-0.9443763702, + -0.9449489122,-0.9455185756,-0.9460853588,-0.9466492601,-0.9472102777, + -0.9477684100,-0.9483236552,-0.9488760116,-0.9494254776,-0.9499720515, + -0.9505157316,-0.9510565163,-0.9515944039,-0.9521293927,-0.9526614813, + -0.9531906678,-0.9537169507,-0.9542403285,-0.9547607995,-0.9552783621, + -0.9557930148,-0.9563047560,-0.9568135841,-0.9573194975,-0.9578224948, + -0.9583225745,-0.9588197349,-0.9593139745,-0.9598052920,-0.9602936857, + -0.9607791542,-0.9612616959,-0.9617413095,-0.9622179935,-0.9626917464, + -0.9631625668,-0.9636304532,-0.9640954042,-0.9645574185,-0.9650164945, + -0.9654726309,-0.9659258263,-0.9663760793,-0.9668233886,-0.9672677528, + -0.9677091705,-0.9681476404,-0.9685831611,-0.9690157314,-0.9694453499, + -0.9698720153,-0.9702957263,-0.9707164816,-0.9711342799,-0.9715491200, + -0.9719610006,-0.9723699204,-0.9727758782,-0.9731788728,-0.9735789029, + -0.9739759673,-0.9743700648,-0.9747611942,-0.9751493543,-0.9755345439, + -0.9759167619,-0.9762960071,-0.9766722783,-0.9770455744,-0.9774158943, + -0.9777832368,-0.9781476007,-0.9785089851,-0.9788673888,-0.9792228106, + -0.9795752496,-0.9799247046,-0.9802711746,-0.9806146585,-0.9809551553, + -0.9812926640,-0.9816271834,-0.9819587127,-0.9822872507,-0.9826127965, + -0.9829353491,-0.9832549076,-0.9835714708,-0.9838850379,-0.9841956080, + -0.9845031800,-0.9848077530,-0.9851093262,-0.9854078985,-0.9857034691, + -0.9859960371,-0.9862856015,-0.9865721616,-0.9868557164,-0.9871362651, + -0.9874138068,-0.9876883406,-0.9879598658,-0.9882283814,-0.9884938868, + -0.9887563810,-0.9890158634,-0.9892723330,-0.9895257891,-0.9897762309, + -0.9900236577,-0.9902680687,-0.9905094632,-0.9907478405,-0.9909831997, + -0.9912155403,-0.9914448614,-0.9916711624,-0.9918944426,-0.9921147013, + -0.9923319379,-0.9925461516,-0.9927573419,-0.9929655081,-0.9931706495, + -0.9933727656,-0.9935718557,-0.9937679192,-0.9939609555,-0.9941509640, + -0.9943379441,-0.9945218954,-0.9947028171,-0.9948807088,-0.9950555700, + -0.9952274000,-0.9953961984,-0.9955619646,-0.9957246982,-0.9958843986, + -0.9960410654,-0.9961946981,-0.9963452962,-0.9964928592,-0.9966373868, + -0.9967788785,-0.9969173337,-0.9970527522,-0.9971851335,-0.9973144772, + -0.9974407829,-0.9975640503,-0.9976842788,-0.9978014683,-0.9979156183, + -0.9980267284,-0.9981347984,-0.9982398279,-0.9983418166,-0.9984407642, + -0.9985366703,-0.9986295348,-0.9987193572,-0.9988061373,-0.9988898750, + -0.9989705698,-0.9990482216,-0.9991228301,-0.9991943951,-0.9992629164, + -0.9993283938,-0.9993908270,-0.9994502159,-0.9995065604,-0.9995598601, + -0.9996101150,-0.9996573250,-0.9997014898,-0.9997426093,-0.9997806835, + -0.9998157121,-0.9998476952,-0.9998766325,-0.9999025240,-0.9999253697, + -0.9999451694,-0.9999619231,-0.9999756307,-0.9999862922,-0.9999939077, + -0.9999984769,-1.0000000000,-0.9999984769,-0.9999939077,-0.9999862922, + -0.9999756307,-0.9999619231,-0.9999451694,-0.9999253697,-0.9999025240, + -0.9998766325,-0.9998476952,-0.9998157121,-0.9997806835,-0.9997426093, + -0.9997014898,-0.9996573250,-0.9996101150,-0.9995598601,-0.9995065604, + -0.9994502159,-0.9993908270,-0.9993283938,-0.9992629164,-0.9991943951, + -0.9991228301,-0.9990482216,-0.9989705698,-0.9988898750,-0.9988061373, + -0.9987193572,-0.9986295348,-0.9985366703,-0.9984407642,-0.9983418166, + -0.9982398279,-0.9981347984,-0.9980267284,-0.9979156183,-0.9978014683, + -0.9976842788,-0.9975640503,-0.9974407829,-0.9973144772,-0.9971851335, + -0.9970527522,-0.9969173337,-0.9967788785,-0.9966373868,-0.9964928592, + -0.9963452962,-0.9961946981,-0.9960410654,-0.9958843986,-0.9957246982, + -0.9955619646,-0.9953961984,-0.9952274000,-0.9950555700,-0.9948807088, + -0.9947028171,-0.9945218954,-0.9943379441,-0.9941509640,-0.9939609555, + -0.9937679192,-0.9935718557,-0.9933727656,-0.9931706495,-0.9929655081, + -0.9927573419,-0.9925461516,-0.9923319379,-0.9921147013,-0.9918944426, + -0.9916711624,-0.9914448614,-0.9912155403,-0.9909831997,-0.9907478405, + -0.9905094632,-0.9902680687,-0.9900236577,-0.9897762309,-0.9895257891, + -0.9892723330,-0.9890158634,-0.9887563810,-0.9884938868,-0.9882283814, + -0.9879598658,-0.9876883406,-0.9874138068,-0.9871362651,-0.9868557164, + -0.9865721616,-0.9862856015,-0.9859960371,-0.9857034691,-0.9854078985, + -0.9851093262,-0.9848077530,-0.9845031800,-0.9841956080,-0.9838850379, + -0.9835714708,-0.9832549076,-0.9829353491,-0.9826127965,-0.9822872507, + -0.9819587127,-0.9816271834,-0.9812926640,-0.9809551553,-0.9806146585, + -0.9802711746,-0.9799247046,-0.9795752496,-0.9792228106,-0.9788673888, + -0.9785089851,-0.9781476007,-0.9777832368,-0.9774158943,-0.9770455744, + -0.9766722783,-0.9762960071,-0.9759167619,-0.9755345439,-0.9751493543, + -0.9747611942,-0.9743700648,-0.9739759673,-0.9735789029,-0.9731788728, + -0.9727758782,-0.9723699204,-0.9719610006,-0.9715491200,-0.9711342799, + -0.9707164816,-0.9702957263,-0.9698720153,-0.9694453499,-0.9690157314, + -0.9685831611,-0.9681476404,-0.9677091705,-0.9672677528,-0.9668233886, + -0.9663760793,-0.9659258263,-0.9654726309,-0.9650164945,-0.9645574185, + -0.9640954042,-0.9636304532,-0.9631625668,-0.9626917464,-0.9622179935, + -0.9617413095,-0.9612616959,-0.9607791542,-0.9602936857,-0.9598052920, + -0.9593139745,-0.9588197349,-0.9583225745,-0.9578224948,-0.9573194975, + -0.9568135841,-0.9563047560,-0.9557930148,-0.9552783621,-0.9547607995, + -0.9542403285,-0.9537169507,-0.9531906678,-0.9526614813,-0.9521293927, + -0.9515944039,-0.9510565163,-0.9505157316,-0.9499720515,-0.9494254776, + -0.9488760116,-0.9483236552,-0.9477684100,-0.9472102777,-0.9466492601, + -0.9460853588,-0.9455185756,-0.9449489122,-0.9443763702,-0.9438009516, + -0.9432226579,-0.9426414911,-0.9420574528,-0.9414705448,-0.9408807690, + -0.9402881270,-0.9396926208,-0.9390942521,-0.9384930228,-0.9378889346, + -0.9372819895,-0.9366721892,-0.9360595357,-0.9354440308,-0.9348256764, + -0.9342044743,-0.9335804265,-0.9329535348,-0.9323238012,-0.9316912276, + -0.9310558159,-0.9304175680,-0.9297764859,-0.9291325715,-0.9284858269, + -0.9278362539,-0.9271838546,-0.9265286309,-0.9258705848,-0.9252097184, + -0.9245460336,-0.9238795325,-0.9232102171,-0.9225380895,-0.9218631516, + -0.9211854056,-0.9205048535,-0.9198214973,-0.9191353393,-0.9184463813, + -0.9177546257,-0.9170600744,-0.9163627296,-0.9156625933,-0.9149596678, + -0.9142539552,-0.9135454576,-0.9128341772,-0.9121201162,-0.9114032766, + -0.9106836608,-0.9099612709,-0.9092361090,-0.9085081775,-0.9077774785, + -0.9070440143,-0.9063077870,-0.9055687990,-0.9048270525,-0.9040825497, + -0.9033352929,-0.9025852843,-0.9018325264,-0.9010770213,-0.9003187714, + -0.8995577790,-0.8987940463,-0.8980275758,-0.8972583697,-0.8964864304, + -0.8957117602,-0.8949343616,-0.8941542368,-0.8933713883,-0.8925858185, + -0.8917975296,-0.8910065242,-0.8902128046,-0.8894163733,-0.8886172327, + -0.8878153851,-0.8870108332,-0.8862035792,-0.8853936258,-0.8845809752, + -0.8837656301,-0.8829475929,-0.8821268660,-0.8813034521,-0.8804773535, + -0.8796485729,-0.8788171127,-0.8779829754,-0.8771461637,-0.8763066800, + -0.8754645270,-0.8746197071,-0.8737722230,-0.8729220773,-0.8720692724, + -0.8712138111,-0.8703556959,-0.8694949295,-0.8686315144,-0.8677654534, + -0.8668967489,-0.8660254038,-0.8651514206,-0.8642748020,-0.8633955506, + -0.8625136692,-0.8616291604,-0.8607420270,-0.8598522716,-0.8589598969, + -0.8580649057,-0.8571673007,-0.8562670846,-0.8553642602,-0.8544588301, + -0.8535507973,-0.8526401644,-0.8517269341,-0.8508111094,-0.8498926930, + -0.8489716876,-0.8480480962,-0.8471219214,-0.8461931661,-0.8452618332, + -0.8443279255,-0.8433914458,-0.8424523970,-0.8415107819,-0.8405666035, + -0.8396198645,-0.8386705679,-0.8377187166,-0.8367643135,-0.8358073614, + -0.8348478633,-0.8338858221,-0.8329212407,-0.8319541221,-0.8309844693, + -0.8300122851,-0.8290375726,-0.8280603346,-0.8270805743,-0.8260982945, + -0.8251134983,-0.8241261886,-0.8231363685,-0.8221440410,-0.8211492091, + -0.8201518759,-0.8191520443,-0.8181497174,-0.8171448983,-0.8161375901, + -0.8151277957,-0.8141155184,-0.8131007610,-0.8120835269,-0.8110638190, + -0.8100416404,-0.8090169944,-0.8079898839,-0.8069603121,-0.8059282822, + -0.8048937974,-0.8038568606,-0.8028174752,-0.8017756442,-0.8007313709, + -0.7996846585,-0.7986355100,-0.7975839288,-0.7965299180,-0.7954734809, + -0.7944146205,-0.7933533403,-0.7922896434,-0.7912235330,-0.7901550124, + -0.7890840848,-0.7880107536,-0.7869350220,-0.7858568932,-0.7847763705, + -0.7836934573,-0.7826081569,-0.7815204724,-0.7804304073,-0.7793379649, + -0.7782431485,-0.7771459615,-0.7760464071,-0.7749444887,-0.7738402097, + -0.7727335735,-0.7716245834,-0.7705132428,-0.7693995550,-0.7682835236, + -0.7671651518,-0.7660444431,-0.7649214009,-0.7637960286,-0.7626683297, + -0.7615383075,-0.7604059656,-0.7592713073,-0.7581343362,-0.7569950557, + -0.7558534692,-0.7547095802,-0.7535633923,-0.7524149089,-0.7512641335, + -0.7501110696,-0.7489557208,-0.7477980905,-0.7466381823,-0.7454759997, + -0.7443115462,-0.7431448255,-0.7419758410,-0.7408045963,-0.7396310950, + -0.7384553406,-0.7372773368,-0.7360970871,-0.7349145951,-0.7337298645, + -0.7325428988,-0.7313537016,-0.7301622766,-0.7289686274,-0.7277727577, + -0.7265746710,-0.7253743710,-0.7241718614,-0.7229671459,-0.7217602281, + -0.7205511117,-0.7193398003,-0.7181262978,-0.7169106077,-0.7156927337, + -0.7144726796,-0.7132504492,-0.7120260460,-0.7107994739,-0.7095707365, + -0.7083398377,-0.7071067812,-0.7058715707,-0.7046342100,-0.7033947028, + -0.7021530530,-0.7009092643,-0.6996633405,-0.6984152854,-0.6971651029, + -0.6959127966,-0.6946583705,-0.6934018283,-0.6921431739,-0.6908824111, + -0.6896195437,-0.6883545757,-0.6870875108,-0.6858183529,-0.6845471059, + -0.6832737737,-0.6819983601,-0.6807208690,-0.6794413043,-0.6781596699, + -0.6768759697,-0.6755902076,-0.6743023876,-0.6730125135,-0.6717205893, + -0.6704266190,-0.6691306064,-0.6678325555,-0.6665324702,-0.6652303547, + -0.6639262127,-0.6626200482,-0.6613118653,-0.6600016680,-0.6586894601, + -0.6573752458,-0.6560590290,-0.6547408137,-0.6534206040,-0.6520984038, + -0.6507742173,-0.6494480483,-0.6481199011,-0.6467897795,-0.6454576877, + -0.6441236298,-0.6427876097,-0.6414496316,-0.6401096995,-0.6387678175, + -0.6374239897,-0.6360782203,-0.6347305132,-0.6333808726,-0.6320293027, + -0.6306758074,-0.6293203910,-0.6279630576,-0.6266038114,-0.6252426563, + -0.6238795967,-0.6225146366,-0.6211477803,-0.6197790318,-0.6184083954, + -0.6170358751,-0.6156614753,-0.6142852001,-0.6129070537,-0.6115270402, + -0.6101451639,-0.6087614290,-0.6073758397,-0.6059884003,-0.6045991149, + -0.6032079877,-0.6018150232,-0.6004202253,-0.5990235985,-0.5976251470, + -0.5962248750,-0.5948227868,-0.5934188866,-0.5920131788,-0.5906056676, + -0.5891963574,-0.5877852523,-0.5863723567,-0.5849576750,-0.5835412114, + -0.5821229702,-0.5807029557,-0.5792811723,-0.5778576244,-0.5764323162, + -0.5750052520,-0.5735764364,-0.5721458734,-0.5707135677,-0.5692795234, + -0.5678437451,-0.5664062369,-0.5649670034,-0.5635260489,-0.5620833779, + -0.5606389946,-0.5591929035,-0.5577451090,-0.5562956155,-0.5548444274, + -0.5533915492,-0.5519369853,-0.5504807401,-0.5490228180,-0.5475632235, + -0.5461019610,-0.5446390350,-0.5431744500,-0.5417082103,-0.5402403205, + -0.5387707850,-0.5372996083,-0.5358267950,-0.5343523494,-0.5328762761, + -0.5313985795,-0.5299192642,-0.5284383347,-0.5269557955,-0.5254716511, + -0.5239859060,-0.5224985647,-0.5210096318,-0.5195191119,-0.5180270094, + -0.5165333289,-0.5150380749,-0.5135412521,-0.5120428649,-0.5105429179, + -0.5090414158,-0.5075383630,-0.5060337641,-0.5045276238,-0.5030199466, + -0.5015107372,-0.5000000000,-0.4984877398,-0.4969739610,-0.4954586684, + -0.4939418666,-0.4924235601,-0.4909037536,-0.4893824517,-0.4878596591, + -0.4863353804,-0.4848096202,-0.4832823833,-0.4817536741,-0.4802234974, + -0.4786918579,-0.4771587603,-0.4756242091,-0.4740882090,-0.4725507649, + -0.4710118812,-0.4694715628,-0.4679298143,-0.4663866403,-0.4648420457, + -0.4632960351,-0.4617486132,-0.4601997848,-0.4586495545,-0.4570979271, + -0.4555449072,-0.4539904997,-0.4524347093,-0.4508775407,-0.4493189986, + -0.4477590878,-0.4461978131,-0.4446351792,-0.4430711908,-0.4415058528, + -0.4399391699,-0.4383711468,-0.4368017884,-0.4352310994,-0.4336590846, + -0.4320857488,-0.4305110968,-0.4289351334,-0.4273578634,-0.4257792916, + -0.4241994227,-0.4226182617,-0.4210358134,-0.4194520824,-0.4178670738, + -0.4162807923,-0.4146932427,-0.4131044298,-0.4115143586,-0.4099230338, + -0.4083304604,-0.4067366431,-0.4051415868,-0.4035452964,-0.4019477767, + -0.4003490326,-0.3987490689,-0.3971478906,-0.3955455026,-0.3939419096, + -0.3923371166,-0.3907311285,-0.3891239501,-0.3875155865,-0.3859060423, + -0.3842953227,-0.3826834324,-0.3810703764,-0.3794561595,-0.3778407868, + -0.3762242631,-0.3746065934,-0.3729877826,-0.3713678356,-0.3697467573, + -0.3681245527,-0.3665012267,-0.3648767843,-0.3632512305,-0.3616245701, + -0.3599968081,-0.3583679495,-0.3567379993,-0.3551069624,-0.3534748438, + -0.3518416484,-0.3502073813,-0.3485720473,-0.3469356516,-0.3452981990, + -0.3436596946,-0.3420201433,-0.3403795502,-0.3387379202,-0.3370952584, + -0.3354515698,-0.3338068592,-0.3321611319,-0.3305143927,-0.3288666467, + -0.3272178990,-0.3255681545,-0.3239174182,-0.3222656952,-0.3206129906, + -0.3189593093,-0.3173046564,-0.3156490369,-0.3139924560,-0.3123349185, + -0.3106764296,-0.3090169944,-0.3073566178,-0.3056953050,-0.3040330609, + -0.3023698908,-0.3007057995,-0.2990407923,-0.2973748741,-0.2957080500, + -0.2940403252,-0.2923717047,-0.2907021936,-0.2890317969,-0.2873605198, + -0.2856883674,-0.2840153447,-0.2823414568,-0.2806667089,-0.2789911060, + -0.2773146533,-0.2756373558,-0.2739592187,-0.2722802470,-0.2706004460, + -0.2689198206,-0.2672383761,-0.2655561175,-0.2638730500,-0.2621891786, + -0.2605045086,-0.2588190451,-0.2571327932,-0.2554457579,-0.2537579446, + -0.2520693582,-0.2503800041,-0.2486898872,-0.2469990127,-0.2453073859, + -0.2436150118,-0.2419218956,-0.2402280425,-0.2385334576,-0.2368381461, + -0.2351421131,-0.2334453639,-0.2317479035,-0.2300497372,-0.2283508701, + -0.2266513074,-0.2249510543,-0.2232501160,-0.2215484976,-0.2198462044, + -0.2181432414,-0.2164396139,-0.2147353272,-0.2130303863,-0.2113247965, + -0.2096185629,-0.2079116908,-0.2062041854,-0.2044960518,-0.2027872954, + -0.2010779211,-0.1993679344,-0.1976573404,-0.1959461442,-0.1942343512, + -0.1925219665,-0.1908089954,-0.1890954430,-0.1873813146,-0.1856666154, + -0.1839513506,-0.1822355255,-0.1805191453,-0.1788022151,-0.1770847403, + -0.1753667261,-0.1736481777,-0.1719291003,-0.1702094992,-0.1684893796, + -0.1667687467,-0.1650476059,-0.1633259622,-0.1616038211,-0.1598811877, + -0.1581580673,-0.1564344650,-0.1547103863,-0.1529858363,-0.1512608202, + -0.1495353434,-0.1478094111,-0.1460830286,-0.1443562010,-0.1426289337, + -0.1409012319,-0.1391731010,-0.1374445460,-0.1357155724,-0.1339861854, + -0.1322563903,-0.1305261922,-0.1287955966,-0.1270646086,-0.1253332336, + -0.1236014767,-0.1218693434,-0.1201368388,-0.1184039683,-0.1166707371, + -0.1149371505,-0.1132032138,-0.1114689322,-0.1097343111,-0.1079993557, + -0.1062640713,-0.1045284633,-0.1027925368,-0.1010562972,-0.0993197497, + -0.0975828998,-0.0958457525,-0.0941083133,-0.0923705874,-0.0906325802, + -0.0888942969,-0.0871557427,-0.0854169231,-0.0836778433,-0.0819385086, + -0.0801989243,-0.0784590957,-0.0767190281,-0.0749787268,-0.0732381971, + -0.0714974443,-0.0697564737,-0.0680152907,-0.0662739004,-0.0645323083, + -0.0627905195,-0.0610485395,-0.0593063736,-0.0575640270,-0.0558215050, + -0.0540788130,-0.0523359562,-0.0505929401,-0.0488497698,-0.0471064507, + -0.0453629881,-0.0436193874,-0.0418756537,-0.0401317925,-0.0383878091, + -0.0366437087,-0.0348994967,-0.0331551784,-0.0314107591,-0.0296662441, + -0.0279216387,-0.0261769483,-0.0244321782,-0.0226873336,-0.0209424199, + -0.0191974424,-0.0174524064,-0.0157073173,-0.0139621803,-0.0122170008, + -0.0104717841,-0.0087265355,-0.0069812603,-0.0052359638,-0.0034906514, + -0.0017453284,-0.0000000000,0.0017453284,0.0034906514,0.0052359638, + 0.0069812603,0.0087265355,0.0104717841,0.0122170008,0.0139621803, + 0.0157073173,0.0174524064,0.0191974424,0.0209424199,0.0226873336, + 0.0244321782,0.0261769483,0.0279216387,0.0296662441,0.0314107591, + 0.0331551784,0.0348994967,0.0366437087,0.0383878091,0.0401317925, + 0.0418756537,0.0436193874,0.0453629881,0.0471064507,0.0488497698, + 0.0505929401,0.0523359562,0.0540788130,0.0558215050,0.0575640270, + 0.0593063736,0.0610485395,0.0627905195,0.0645323083,0.0662739004, + 0.0680152907,0.0697564737,0.0714974443,0.0732381971,0.0749787268, + 0.0767190281,0.0784590957,0.0801989243,0.0819385086,0.0836778433, + 0.0854169231,0.0871557427,0.0888942969,0.0906325802,0.0923705874, + 0.0941083133,0.0958457525,0.0975828998,0.0993197497,0.1010562972, + 0.1027925368,0.1045284633,0.1062640713,0.1079993557,0.1097343111, + 0.1114689322,0.1132032138,0.1149371505,0.1166707371,0.1184039683, + 0.1201368388,0.1218693434,0.1236014767,0.1253332336,0.1270646086, + 0.1287955966,0.1305261922,0.1322563903,0.1339861854,0.1357155724, + 0.1374445460,0.1391731010,0.1409012319,0.1426289337,0.1443562010, + 0.1460830286,0.1478094111,0.1495353434,0.1512608202,0.1529858363, + 0.1547103863,0.1564344650,0.1581580673,0.1598811877,0.1616038211, + 0.1633259622,0.1650476059,0.1667687467,0.1684893796,0.1702094992, + 0.1719291003,0.1736481777,0.1753667261,0.1770847403,0.1788022151, + 0.1805191453,0.1822355255,0.1839513506,0.1856666154,0.1873813146, + 0.1890954430,0.1908089954,0.1925219665,0.1942343512,0.1959461442, + 0.1976573404,0.1993679344,0.2010779211,0.2027872954,0.2044960518, + 0.2062041854,0.2079116908,0.2096185629,0.2113247965,0.2130303863, + 0.2147353272,0.2164396139,0.2181432414,0.2198462044,0.2215484976, + 0.2232501160,0.2249510543,0.2266513074,0.2283508701,0.2300497372, + 0.2317479035,0.2334453639,0.2351421131,0.2368381461,0.2385334576, + 0.2402280425,0.2419218956,0.2436150118,0.2453073859,0.2469990127, + 0.2486898872,0.2503800041,0.2520693582,0.2537579446,0.2554457579, + 0.2571327932,0.2588190451,0.2605045086,0.2621891786,0.2638730500, + 0.2655561175,0.2672383761,0.2689198206,0.2706004460,0.2722802470, + 0.2739592187,0.2756373558,0.2773146533,0.2789911060,0.2806667089, + 0.2823414568,0.2840153447,0.2856883674,0.2873605198,0.2890317969, + 0.2907021936,0.2923717047,0.2940403252,0.2957080500,0.2973748741, + 0.2990407923,0.3007057995,0.3023698908,0.3040330609,0.3056953050, + 0.3073566178,0.3090169944,0.3106764296,0.3123349185,0.3139924560, + 0.3156490369,0.3173046564,0.3189593093,0.3206129906,0.3222656952, + 0.3239174182,0.3255681545,0.3272178990,0.3288666467,0.3305143927, + 0.3321611319,0.3338068592,0.3354515698,0.3370952584,0.3387379202, + 0.3403795502,0.3420201433,0.3436596946,0.3452981990,0.3469356516, + 0.3485720473,0.3502073813,0.3518416484,0.3534748438,0.3551069624, + 0.3567379993,0.3583679495,0.3599968081,0.3616245701,0.3632512305, + 0.3648767843,0.3665012267,0.3681245527,0.3697467573,0.3713678356, + 0.3729877826,0.3746065934,0.3762242631,0.3778407868,0.3794561595, + 0.3810703764,0.3826834324,0.3842953227,0.3859060423,0.3875155865, + 0.3891239501,0.3907311285,0.3923371166,0.3939419096,0.3955455026, + 0.3971478906,0.3987490689,0.4003490326,0.4019477767,0.4035452964, + 0.4051415868,0.4067366431,0.4083304604,0.4099230338,0.4115143586, + 0.4131044298,0.4146932427,0.4162807923,0.4178670738,0.4194520824, + 0.4210358134,0.4226182617,0.4241994227,0.4257792916,0.4273578634, + 0.4289351334,0.4305110968,0.4320857488,0.4336590846,0.4352310994, + 0.4368017884,0.4383711468,0.4399391699,0.4415058528,0.4430711908, + 0.4446351792,0.4461978131,0.4477590878,0.4493189986,0.4508775407, + 0.4524347093,0.4539904997,0.4555449072,0.4570979271,0.4586495545, + 0.4601997848,0.4617486132,0.4632960351,0.4648420457,0.4663866403, + 0.4679298143,0.4694715628,0.4710118812,0.4725507649,0.4740882090, + 0.4756242091,0.4771587603,0.4786918579,0.4802234974,0.4817536741, + 0.4832823833,0.4848096202,0.4863353804,0.4878596591,0.4893824517, + 0.4909037536,0.4924235601,0.4939418666,0.4954586684,0.4969739610, + 0.4984877398,0.5000000000,0.5015107372,0.5030199466,0.5045276238, + 0.5060337641,0.5075383630,0.5090414158,0.5105429179,0.5120428649, + 0.5135412521,0.5150380749,0.5165333289,0.5180270094,0.5195191119, + 0.5210096318,0.5224985647,0.5239859060,0.5254716511,0.5269557955, + 0.5284383347,0.5299192642,0.5313985795,0.5328762761,0.5343523494, + 0.5358267950,0.5372996083,0.5387707850,0.5402403205,0.5417082103, + 0.5431744500,0.5446390350,0.5461019610,0.5475632235,0.5490228180, + 0.5504807401,0.5519369853,0.5533915492,0.5548444274,0.5562956155, + 0.5577451090,0.5591929035,0.5606389946,0.5620833779,0.5635260489, + 0.5649670034,0.5664062369,0.5678437451,0.5692795234,0.5707135677, + 0.5721458734,0.5735764364,0.5750052520,0.5764323162,0.5778576244, + 0.5792811723,0.5807029557,0.5821229702,0.5835412114,0.5849576750, + 0.5863723567,0.5877852523,0.5891963574,0.5906056676,0.5920131788, + 0.5934188866,0.5948227868,0.5962248750,0.5976251470,0.5990235985, + 0.6004202253,0.6018150232,0.6032079877,0.6045991149,0.6059884003, + 0.6073758397,0.6087614290,0.6101451639,0.6115270402,0.6129070537, + 0.6142852001,0.6156614753,0.6170358751,0.6184083954,0.6197790318, + 0.6211477803,0.6225146366,0.6238795967,0.6252426563,0.6266038114, + 0.6279630576,0.6293203910,0.6306758074,0.6320293027,0.6333808726, + 0.6347305132,0.6360782203,0.6374239897,0.6387678175,0.6401096995, + 0.6414496316,0.6427876097,0.6441236298,0.6454576877,0.6467897795, + 0.6481199011,0.6494480483,0.6507742173,0.6520984038,0.6534206040, + 0.6547408137,0.6560590290,0.6573752458,0.6586894601,0.6600016680, + 0.6613118653,0.6626200482,0.6639262127,0.6652303547,0.6665324702, + 0.6678325555,0.6691306064,0.6704266190,0.6717205893,0.6730125135, + 0.6743023876,0.6755902076,0.6768759697,0.6781596699,0.6794413043, + 0.6807208690,0.6819983601,0.6832737737,0.6845471059,0.6858183529, + 0.6870875108,0.6883545757,0.6896195437,0.6908824111,0.6921431739, + 0.6934018283,0.6946583705,0.6959127966,0.6971651029,0.6984152854, + 0.6996633405,0.7009092643,0.7021530530,0.7033947028,0.7046342100, + 0.7058715707,0.7071067812,0.7083398377,0.7095707365,0.7107994739, + 0.7120260460,0.7132504492,0.7144726796,0.7156927337,0.7169106077, + 0.7181262978,0.7193398003,0.7205511117,0.7217602281,0.7229671459, + 0.7241718614,0.7253743710,0.7265746710,0.7277727577,0.7289686274, + 0.7301622766,0.7313537016,0.7325428988,0.7337298645,0.7349145951, + 0.7360970871,0.7372773368,0.7384553406,0.7396310950,0.7408045963, + 0.7419758410,0.7431448255,0.7443115462,0.7454759997,0.7466381823, + 0.7477980905,0.7489557208,0.7501110696,0.7512641335,0.7524149089, + 0.7535633923,0.7547095802,0.7558534692,0.7569950557,0.7581343362, + 0.7592713073,0.7604059656,0.7615383075,0.7626683297,0.7637960286, + 0.7649214009,0.7660444431,0.7671651518,0.7682835236,0.7693995550, + 0.7705132428,0.7716245834,0.7727335735,0.7738402097,0.7749444887, + 0.7760464071,0.7771459615,0.7782431485,0.7793379649,0.7804304073, + 0.7815204724,0.7826081569,0.7836934573,0.7847763705,0.7858568932, + 0.7869350220,0.7880107536,0.7890840848,0.7901550124,0.7912235330, + 0.7922896434,0.7933533403,0.7944146205,0.7954734809,0.7965299180, + 0.7975839288,0.7986355100,0.7996846585,0.8007313709,0.8017756442, + 0.8028174752,0.8038568606,0.8048937974,0.8059282822,0.8069603121, + 0.8079898839,0.8090169944,0.8100416404,0.8110638190,0.8120835269, + 0.8131007610,0.8141155184,0.8151277957,0.8161375901,0.8171448983, + 0.8181497174,0.8191520443,0.8201518759,0.8211492091,0.8221440410, + 0.8231363685,0.8241261886,0.8251134983,0.8260982945,0.8270805743, + 0.8280603346,0.8290375726,0.8300122851,0.8309844693,0.8319541221, + 0.8329212407,0.8338858221,0.8348478633,0.8358073614,0.8367643135, + 0.8377187166,0.8386705679,0.8396198645,0.8405666035,0.8415107819, + 0.8424523970,0.8433914458,0.8443279255,0.8452618332,0.8461931661, + 0.8471219214,0.8480480962,0.8489716876,0.8498926930,0.8508111094, + 0.8517269341,0.8526401644,0.8535507973,0.8544588301,0.8553642602, + 0.8562670846,0.8571673007,0.8580649057,0.8589598969,0.8598522716, + 0.8607420270,0.8616291604,0.8625136692,0.8633955506,0.8642748020, + 0.8651514206,0.8660254038,0.8668967489,0.8677654534,0.8686315144, + 0.8694949295,0.8703556959,0.8712138111,0.8720692724,0.8729220773, + 0.8737722230,0.8746197071,0.8754645270,0.8763066800,0.8771461637, + 0.8779829754,0.8788171127,0.8796485729,0.8804773535,0.8813034521, + 0.8821268660,0.8829475929,0.8837656301,0.8845809752,0.8853936258, + 0.8862035792,0.8870108332,0.8878153851,0.8886172327,0.8894163733, + 0.8902128046,0.8910065242,0.8917975296,0.8925858185,0.8933713883, + 0.8941542368,0.8949343616,0.8957117602,0.8964864304,0.8972583697, + 0.8980275758,0.8987940463,0.8995577790,0.9003187714,0.9010770213, + 0.9018325264,0.9025852843,0.9033352929,0.9040825497,0.9048270525, + 0.9055687990,0.9063077870,0.9070440143,0.9077774785,0.9085081775, + 0.9092361090,0.9099612709,0.9106836608,0.9114032766,0.9121201162, + 0.9128341772,0.9135454576,0.9142539552,0.9149596678,0.9156625933, + 0.9163627296,0.9170600744,0.9177546257,0.9184463813,0.9191353393, + 0.9198214973,0.9205048535,0.9211854056,0.9218631516,0.9225380895, + 0.9232102171,0.9238795325,0.9245460336,0.9252097184,0.9258705848, + 0.9265286309,0.9271838546,0.9278362539,0.9284858269,0.9291325715, + 0.9297764859,0.9304175680,0.9310558159,0.9316912276,0.9323238012, + 0.9329535348,0.9335804265,0.9342044743,0.9348256764,0.9354440308, + 0.9360595357,0.9366721892,0.9372819895,0.9378889346,0.9384930228, + 0.9390942521,0.9396926208,0.9402881270,0.9408807690,0.9414705448, + 0.9420574528,0.9426414911,0.9432226579,0.9438009516,0.9443763702, + 0.9449489122,0.9455185756,0.9460853588,0.9466492601,0.9472102777, + 0.9477684100,0.9483236552,0.9488760116,0.9494254776,0.9499720515, + 0.9505157316,0.9510565163,0.9515944039,0.9521293927,0.9526614813, + 0.9531906678,0.9537169507,0.9542403285,0.9547607995,0.9552783621, + 0.9557930148,0.9563047560,0.9568135841,0.9573194975,0.9578224948, + 0.9583225745,0.9588197349,0.9593139745,0.9598052920,0.9602936857, + 0.9607791542,0.9612616959,0.9617413095,0.9622179935,0.9626917464, + 0.9631625668,0.9636304532,0.9640954042,0.9645574185,0.9650164945, + 0.9654726309,0.9659258263,0.9663760793,0.9668233886,0.9672677528, + 0.9677091705,0.9681476404,0.9685831611,0.9690157314,0.9694453499, + 0.9698720153,0.9702957263,0.9707164816,0.9711342799,0.9715491200, + 0.9719610006,0.9723699204,0.9727758782,0.9731788728,0.9735789029, + 0.9739759673,0.9743700648,0.9747611942,0.9751493543,0.9755345439, + 0.9759167619,0.9762960071,0.9766722783,0.9770455744,0.9774158943, + 0.9777832368,0.9781476007,0.9785089851,0.9788673888,0.9792228106, + 0.9795752496,0.9799247046,0.9802711746,0.9806146585,0.9809551553, + 0.9812926640,0.9816271834,0.9819587127,0.9822872507,0.9826127965, + 0.9829353491,0.9832549076,0.9835714708,0.9838850379,0.9841956080, + 0.9845031800,0.9848077530,0.9851093262,0.9854078985,0.9857034691, + 0.9859960371,0.9862856015,0.9865721616,0.9868557164,0.9871362651, + 0.9874138068,0.9876883406,0.9879598658,0.9882283814,0.9884938868, + 0.9887563810,0.9890158634,0.9892723330,0.9895257891,0.9897762309, + 0.9900236577,0.9902680687,0.9905094632,0.9907478405,0.9909831997, + 0.9912155403,0.9914448614,0.9916711624,0.9918944426,0.9921147013, + 0.9923319379,0.9925461516,0.9927573419,0.9929655081,0.9931706495, + 0.9933727656,0.9935718557,0.9937679192,0.9939609555,0.9941509640, + 0.9943379441,0.9945218954,0.9947028171,0.9948807088,0.9950555700, + 0.9952274000,0.9953961984,0.9955619646,0.9957246982,0.9958843986, + 0.9960410654,0.9961946981,0.9963452962,0.9964928592,0.9966373868, + 0.9967788785,0.9969173337,0.9970527522,0.9971851335,0.9973144772, + 0.9974407829,0.9975640503,0.9976842788,0.9978014683,0.9979156183, + 0.9980267284,0.9981347984,0.9982398279,0.9983418166,0.9984407642, + 0.9985366703,0.9986295348,0.9987193572,0.9988061373,0.9988898750, + 0.9989705698,0.9990482216,0.9991228301,0.9991943951,0.9992629164, + 0.9993283938,0.9993908270,0.9994502159,0.9995065604,0.9995598601, + 0.9996101150,0.9996573250,0.9997014898,0.9997426093,0.9997806835, + 0.9998157121,0.9998476952,0.9998766325,0.9999025240,0.9999253697, + 0.9999451694,0.9999619231,0.9999756307,0.9999862922,0.9999939077, + 0.9999984769} +#endif + ; + +#endif + + diff --git a/include/worksheet.h b/include/worksheet.h new file mode 100644 index 0000000000..f7fab0e29b --- /dev/null +++ b/include/worksheet.h @@ -0,0 +1,252 @@ + /***************************************************/ + /* WORKSHEET.H: constantes pour trace du cartouche */ + /***************************************************/ + + /****************************/ + /* Description du cartouche */ + /****************************/ +#define GRID_REF_W 70 /* hauteur de la bande de reference grille */ +#define SIZETEXT 60 /* Dimension des textes du cartouche */ +#define SIZETEXT_REF 50 /* Dimension des lettres du marquage des reperes */ +#define PAS_REF 2000 /* pas des marquages de reference des reperes */ +#define TEXT_VTAB_HEIGHT SIZETEXT*2 + +/* Les coord ci dessous sont relatives au coin bas - droit de la feuille, et +seront soustraires de cette origine +*/ +#define BLOCK_OX 4200 +#define BLOCK_LICENCE_X BLOCK_OX - SIZETEXT +#define BLOCK_LICENCE_Y SIZETEXT +#define BLOCK_REV_X 820 +#define BLOCK_REV_Y (SIZETEXT*3) +#define BLOCK_DATE_X BLOCK_OX - (SIZETEXT*15) +#define BLOCK_DATE_Y (SIZETEXT*3) +#define BLOCK_ID_SHEET_X 820 +#define BLOCK_ID_SHEET_Y SIZETEXT +#define BLOCK_SIZE_SHEET_X BLOCK_OX - SIZETEXT +#define BLOCK_SIZE_SHEET_Y (SIZETEXT*3) +#define BLOCK_TITLE_X BLOCK_OX - SIZETEXT +#define BLOCK_TITLE_Y (SIZETEXT*5) +#define BLOCK_COMMENT_X BLOCK_OX - SIZETEXT +#define VARIABLE_BLOCK_START_POSITION (SIZETEXT * 6) +#define BLOCK_COMPANY_Y (SIZETEXT*7) +#define BLOCK_COMMENT1_Y (SIZETEXT*9) +#define BLOCK_COMMENT2_Y (SIZETEXT*11) +#define BLOCK_COMMENT3_Y (SIZETEXT*13) +#define BLOCK_COMMENT4_Y (SIZETEXT*15) + +struct Ki_WorkSheetData +{ +public: + int m_Type; /* nombre permettant de reconnaitre la description */ + Ki_WorkSheetData * Pnext; + int m_Posx, m_Posy; /* position de l'element ou point de depart du segment */ + int m_Endx, m_Endy; /* extremite d'un element type segment ou cadre */ + wxChar * m_Legende; /* Pour m_Textes: texte a afficher avant le texte lui meme */ + wxChar * m_Text; /* Pour m_Textes:pointeur sur le texte a afficher */ +}; + +/* Type des descriptions Ki_WorkSheetData */ +enum TypeKi_WorkSheetData +{ + WS_DATE, + WS_REV, + WS_LICENCE, + WS_SIZESHEET, + WS_IDENTSHEET, + WS_TITLE, + WS_COMPANY_NAME, + WS_COMMENT1, + WS_COMMENT2, + WS_COMMENT3, + WS_COMMENT4, + WS_SEGMENT, + WS_UPPER_SEGMENT, + WS_LEFT_SEGMENT, + WS_CADRE +}; + +extern Ki_WorkSheetData WS_Date; +extern Ki_WorkSheetData WS_Revision; +extern Ki_WorkSheetData WS_Licence; +extern Ki_WorkSheetData WS_SizeSheet; +extern Ki_WorkSheetData WS_IdentSheet; +extern Ki_WorkSheetData WS_Title; +extern Ki_WorkSheetData WS_Company; +extern Ki_WorkSheetData WS_Comment1; +extern Ki_WorkSheetData WS_Comment2; +extern Ki_WorkSheetData WS_Comment3; +extern Ki_WorkSheetData WS_Comment4; +extern Ki_WorkSheetData WS_MostLeftLine; +extern Ki_WorkSheetData WS_MostUpperLine; +extern Ki_WorkSheetData WS_Segm3; +extern Ki_WorkSheetData WS_Segm4; +extern Ki_WorkSheetData WS_Segm5; +extern Ki_WorkSheetData WS_Segm6; +extern Ki_WorkSheetData WS_Segm7; + +#ifdef EDA_BASE + +Ki_WorkSheetData WS_Date = + { + WS_DATE, + &WS_Licence, + BLOCK_DATE_X, BLOCK_DATE_Y, + 0,0, + wxT("Date: "), NULL + }; + +Ki_WorkSheetData WS_Licence = + { + WS_LICENCE, + &WS_Revision, + BLOCK_LICENCE_X, BLOCK_LICENCE_Y, + 0,0, + NULL, NULL + }; + +Ki_WorkSheetData WS_Revision = + { + WS_REV, + &WS_SizeSheet, + BLOCK_REV_X, BLOCK_REV_Y, + 0,0, + wxT("Rev: "), NULL + }; + +Ki_WorkSheetData WS_SizeSheet = + { + WS_SIZESHEET, + &WS_IdentSheet, + BLOCK_SIZE_SHEET_X, BLOCK_SIZE_SHEET_Y, + 0,0, + wxT("Size: "),NULL + }; + +Ki_WorkSheetData WS_IdentSheet = + { + WS_IDENTSHEET, + &WS_Title, + BLOCK_ID_SHEET_X, BLOCK_ID_SHEET_Y, + 0,0, + wxT("Sheet: "),NULL + }; + +Ki_WorkSheetData WS_Title = + { + WS_TITLE, + &WS_Company, + BLOCK_TITLE_X, BLOCK_TITLE_Y, + 0,0, + wxT("Title: "),NULL + }; + +Ki_WorkSheetData WS_Company = + { + WS_COMPANY_NAME, + &WS_Comment1, + BLOCK_COMMENT_X, BLOCK_COMPANY_Y, + 0,0, + NULL,NULL, + }; + +Ki_WorkSheetData WS_Comment1 = + { + WS_COMMENT1, + &WS_Comment2, + BLOCK_COMMENT_X, BLOCK_COMMENT1_Y, + 0,0, + NULL,NULL + }; + +Ki_WorkSheetData WS_Comment2 = + { + WS_COMMENT2, + &WS_Comment3, + BLOCK_COMMENT_X, BLOCK_COMMENT2_Y, + 0,0, + NULL,NULL + }; + +Ki_WorkSheetData WS_Comment3 = + { + WS_COMMENT3, + &WS_Comment4, + BLOCK_COMMENT_X, BLOCK_COMMENT3_Y, + 0,0, + NULL,NULL + }; + +Ki_WorkSheetData WS_Comment4 = + { + WS_COMMENT4, + &WS_MostLeftLine, + BLOCK_COMMENT_X, BLOCK_COMMENT4_Y, + 0,0, + NULL,NULL + }; + +Ki_WorkSheetData WS_MostLeftLine = /* segment vertical gauche */ + { + WS_LEFT_SEGMENT, + &WS_MostUpperLine, + BLOCK_OX, SIZETEXT * 16, + BLOCK_OX, 0, + NULL,NULL + }; + +Ki_WorkSheetData WS_MostUpperLine = /* segment horizontal superieur */ + { + WS_UPPER_SEGMENT, + &WS_Segm3, + BLOCK_OX, SIZETEXT * 16, + 0, SIZETEXT * 16, + NULL,NULL + }; + +Ki_WorkSheetData WS_Segm3 = /* segment horizontal au dessus de NAME COMPANY */ + { + WS_SEGMENT, + &WS_Segm4, + BLOCK_OX, SIZETEXT * 6, + 0, SIZETEXT * 6, + NULL,NULL + }; + +Ki_WorkSheetData WS_Segm4 = /* segment vertical a gauche de SHEET et REV */ + { + WS_SEGMENT, + &WS_Segm5, + BLOCK_REV_X + SIZETEXT, SIZETEXT * 4, + BLOCK_REV_X + SIZETEXT, 0, + NULL,NULL + }; + +Ki_WorkSheetData WS_Segm5 = /* 1er segment horizontal */ + { + WS_SEGMENT, + &WS_Segm6, + BLOCK_OX, SIZETEXT * 2, + 0, SIZETEXT * 2, + NULL,NULL + }; + +Ki_WorkSheetData WS_Segm6 = /* 2eme segment horizontal */ + { + WS_SEGMENT, + &WS_Segm7, + BLOCK_OX, SIZETEXT * 4, + 0, SIZETEXT * 4, + NULL,NULL + }; + +Ki_WorkSheetData WS_Segm7 = /* segment vertical apres SIZE */ + { + WS_SEGMENT, + NULL, + BLOCK_OX - (SIZETEXT * 11), SIZETEXT * 4, + BLOCK_OX - (SIZETEXT * 11), SIZETEXT * 2, + NULL,NULL + }; + +#endif diff --git a/include/wxstruct.h b/include/wxstruct.h new file mode 100644 index 0000000000..088d4c9ede --- /dev/null +++ b/include/wxstruct.h @@ -0,0 +1,1509 @@ + /***********************************************************/ + /* wxstruct.h: */ + /* descriptions des principales classes derivees utilisees */ + /***********************************************************/ + +#ifndef WXSTRUCT_H +#define WXSTRUCT_H + + +#ifndef eda_global +#define eda_global extern +#endif + +#include +#include "wx/log.h" +#include "wx/config.h" +#include +#include +#include + + +#define INTERNAL_UNIT_TYPE 0 // Internal unit = inch + +#ifndef EESCHEMA_INTERNAL_UNIT +#define EESCHEMA_INTERNAL_UNIT 1000 +#endif + +#ifndef PCB_INTERNAL_UNIT +#define PCB_INTERNAL_UNIT 10000 +#endif + +// Option d'affichage des fenetres de dialogue +//#define DIALOG_STYLE wxDEFAULT_DIALOG_STYLE|wxFRAME_FLOAT_ON_PARENT|wxSTAY_ON_TOP +#define DIALOG_STYLE wxDEFAULT_DIALOG_STYLE|wxFRAME_FLOAT_ON_PARENT + +#define EDA_DRAW_PANEL wxScrolledWindow + +class wxMyDialogModalData; + +/* Forward declarations of classes. */ +class WinEDA_DrawPanel; +class WinEDA_DrawFrame; + +#include "base_struct.h" + +class WinEDA_App; +class WinEDA_MsgPanel; +class COMMAND; +class WinEDA_MainFrame; +class BASE_SCREEN; +class SCH_SCREEN; +class PCB_SCREEN; +class WinEDA_SchematicFrame; // Edition des Schemas +class WinEDA_LibeditFrame; // Edition des composants +class WinEDA_ViewlibFrame; // Visualisation des composants +class WinEDA_GerberFrame; // Visualisation des fichiers GERBER +class WinEDA_Toolbar; +class WinEDA_CvpcbFrame; +class WinEDA_PcbFrame; +class WinEDA_ModuleEditFrame; +class WinEDAChoiceBox; +#define WinEDA_MenuBar wxMenuBar +#define WinEDA_Menu wxMenu +#define WinEDA_MenuItem wxMenuItem + +// Utilisées mais non definies ici : +class LibraryStruct; +class EDA_LibComponentStruct; +class LibEDA_BaseStruct; +class EDA_BaseStruct; +class DrawBusEntryStruct; +class DrawGlobalLabelStruct; +class DrawTextStruct; +class EDA_DrawLineStruct; +class DrawSheetStruct; +class DrawSheetLabelStruct; +class EDA_SchComponentStruct; +class LibDrawField; +class PartTextStruct; +class LibDrawPin; +class DrawJunctionStruct; +class BOARD; +class TEXTE_PCB; +class MODULE; +class TRACK; +class SEGZONE; +class SEGVIA; +class EDGE_ZONE; +class D_PAD; +class TEXTE_MODULE; +class MIREPCB; +class DRAWSEGMENT; +class COTATION; +class EDGE_MODULE; +class WinEDA3D_DrawFrame; +class PARAM_CFG_BASE; +class Ki_PageDescr; + + +enum id_librarytype +{ + LIBRARY_TYPE_EESCHEMA, + LIBRARY_TYPE_PCBNEW, + LIBRARY_TYPE_DOC +}; + +enum id_drawframe { + NOT_INIT_FRAME = 0, + SCHEMATIC_FRAME, + LIBEDITOR_FRAME, + VIEWER_FRAME, + PCB_FRAME, + MODULE_EDITOR_FRAME, + CVPCB_FRAME, + CVPCB_DISPLAY_FRAME, + GERBER_FRAME, + TEXT_EDITOR_FRAME, + DISPLAY3D_FRAME, + KICAD_MAIN_FRAME +}; + +enum id_toolbar { + TOOLBAR_MAIN = 1, // Toolbar horizontal (main) + TOOLBAR_TOOL, // Toolbar vertical tools + TOOLBAR_OPTION, // Toolbar vertical options + TOOLBAR_AUX +}; + + /**********************/ + /* Classes pour WXWIN */ + /**********************/ + +#define MSG_PANEL_DEFAULT_HEIGHT ( 28 ) // hauteur de la zone d'affichage des infos en bas d'ecran + + /**********************************************/ + /* Class representing the entire Application */ + /**********************************************/ +#include "appl_wxstruct.h" + + + /********************************************/ + /* classe pour la Fenetre generale de trace */ + /********************************************/ + +class WinEDA_BasicFrame: public wxFrame +{ +public: + int m_Ident; // Id Type (pcb, schematic, library..) + WinEDA_App * m_Parent; + wxPoint m_FramePos; + wxSize m_FrameSize; + int m_MsgFrameHeight; + + WinEDA_MenuBar * m_MenuBar; // menu du haut d'ecran + WinEDA_Toolbar * m_HToolBar; // Standard horizontal Toolbar + bool m_FrameIsActive; + wxString m_FrameName; // name used for writting and reading setup + // It is "SchematicFrame", "PcbFrame" .... + +public: + // Constructor and destructor + WinEDA_BasicFrame( wxWindow * father, int idtype, WinEDA_App *parent, + const wxString & title, + const wxPoint& pos, const wxSize& size); + + ~WinEDA_BasicFrame(void); + void GetKicadHelp(wxCommandEvent& event); + void GetKicadAbout(wxCommandEvent& event); + void PrintMsg(const wxString & text); + void GetSettings(void); + void SaveSettings(void); + void SetLanguage(wxCommandEvent& event); + void ProcessFontPreferences(int id); + + wxString GetLastProject(int rang); + void SetLastProject(const wxString & FullFileName); + void DisplayActivity(int PerCent, const wxString & Text); + virtual void ReCreateMenuBar(void); +}; + + + /********************************************/ + /* classe pour la Fenetre generale de trace */ + /********************************************/ + +class WinEDA_DrawFrame: public WinEDA_BasicFrame +{ +public: + WinEDA_DrawPanel * DrawPanel; // surface de dessin + WinEDA_MsgPanel * MsgPanel; // Zone d'affichage de caracteristiques + WinEDA_Toolbar * m_VToolBar; // Vertical (right side) Toolbar + WinEDA_Toolbar * m_AuxVToolBar; // Auxiliary Vertical (right side) Toolbar + WinEDA_Toolbar * m_OptionsToolBar; // Options Toolbar (left side) + WinEDA_Toolbar * m_AuxiliaryToolBar; // Toolbar auxiliaire (utilisé dans pcbnew) + + WinEDAChoiceBox * m_SelGridBox; // Dialog box to choose the grid size + WinEDAChoiceBox * m_SelZoomBox; // Dialog box to choose the Zoom value + int m_ZoomMaxValue; // Max zoom value: Draw min scale is 1/m_ZoomMaxValue + + BASE_SCREEN * m_CurrentScreen; // SCREEN en cours + + int m_CurrentCursorShape; // shape for cursor (0 = default cursor) + int m_ID_current_state; // Id du bouton actif du tool bar vertical + int m_HTOOL_current_state; // Id du bouton actif du tool bar horizontal + + int m_InternalUnits; // nombre d'unites internes pour 1 pouce + // = 1000 pour schema, = 10000 pour PCB + int m_UnitType; // Internal Unit type (0 = inch) + bool m_Draw_Axis; // TRUE pour avoir les axes dessines + bool m_Draw_Grid; // TRUE pour avoir la grille dessinee + bool m_Draw_Sheet_Ref; // TRUE pour avoir le cartouche dessiné + + bool m_Print_Sheet_Ref; // TRUE pour avoir le cartouche imprimé + bool m_Draw_Auxiliary_Axis; // TRUE pour avoir les axes auxiliaires dessines + wxPoint m_Auxiliary_Axis_Position; /* origine de l'axe auxiliaire (app: + dans la generation les fichiers de positionnement + des composants) */ + +public: + // Constructor and destructor + WinEDA_DrawFrame( wxWindow * father, int idtype, WinEDA_App *parent, + const wxString & title, + const wxPoint& pos, const wxSize& size); + + ~WinEDA_DrawFrame(void); + BASE_SCREEN * GetScreen(void) { return m_CurrentScreen; } + + void OnMenuOpen(wxMenuEvent& event); + void OnMouseEvent(wxMouseEvent& event); + virtual void OnHotKey(wxDC * DC, int hotkey, EDA_BaseStruct * DrawStruct); + void AddFontSelectionMenu(wxMenu * main_menu); + void ProcessFontPreferences(wxCommandEvent& event); + + void Affiche_Message(const wxString & message); + void EraseMsgBox(void); + void Process_PageSettings(wxCommandEvent& event); + void SetDrawBgColor(int color_num); + virtual void SetToolbars(void); + void SetLanguage(wxCommandEvent& event); + virtual void ReCreateHToolbar(void) = 0; + virtual void ReCreateVToolbar(void) = 0; + virtual void ReCreateMenuBar(void); + virtual void ReCreateAuxiliaryToolbar(void); + void SetToolID(int id, int new_cursor_id, const wxString & title); + + virtual void OnSelectGrid(wxCommandEvent& event); + virtual void OnSelectZoom(wxCommandEvent& event); + + virtual void GeneralControle(wxDC *DC, wxPoint Mouse); + virtual void OnSize(wxSizeEvent& event); + void OnEraseBackground(wxEraseEvent& SizeEvent); +// void OnChar(wxKeyEvent& event); + void SetToolbarBgColor(int color_num); + void OnZoom(int zoom_type); + void OnPanning(int direction); + void OnGrid(int grid_type); + void Recadre_Trace(bool ToMouse); + void PutOnGrid(wxPoint * coord); /* corrige la valeur de la coordonnee coord + pour etre sur le point de grille le plus proche */ + void Zoom_Automatique(bool move_mouse_cursor); + /* Affiche le schema au meilleur zoom au meilleur centrage pour le dessin + de facon a avoir tout le circuit affiche a l'ecran */ + + void Window_Zoom(EDA_Rect &Rect); + /* Recalcule le zoom et les offsets pour que l'affichage se fasse dans la + fenetre de coord x0, y0 a x1, y1 */ + virtual int BestZoom(void) = 0; // Retourne le meilleur zoom + + void ToPrinter(wxCommandEvent& event); + void SVG_Print(wxCommandEvent& event); + + void OnActivate(wxActivateEvent& event); + void ReDrawPanel(void); + void TraceWorkSheet(wxDC * DC, BASE_SCREEN * screen); + void DisplayToolMsg(const wxString msg); + void Process_Zoom(wxCommandEvent& event); + void Process_Grid(wxCommandEvent& event); + virtual void RedrawActiveWindow(wxDC * DC, bool EraseBg) = 0; + virtual void Process_Special_Functions(wxCommandEvent& event) = 0; + virtual void OnLeftClick(wxDC * DC, const wxPoint& MousePos) = 0; + virtual void OnLeftDClick(wxDC * DC, const wxPoint& MousePos); + virtual void OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu) = 0; + virtual void ToolOnRightClick(wxCommandEvent& event); + void AdjustScrollBars(void); + void Affiche_Status_Box(void); /* Affichage des coord curseur, zoom .. */ + void DisplayUnitsMsg(void); + + /* Gestion generale des operations sur block */ + virtual int ReturnBlockCommand(int key); + virtual void InitBlockPasteInfos(); + virtual bool HandleBlockBegin(wxDC * DC, int cmd_type, const wxPoint & startpos); + virtual void HandleBlockPlace(wxDC * DC); + virtual int HandleBlockEnd(wxDC * DC); + + void CopyToClipboard(wxCommandEvent& event); + + /* interprocess communication */ + void OnSockRequest(wxSocketEvent &evt); + void OnSockRequestServer (wxSocketEvent &evt); +}; + +#define COMMON_EVENTS_DRAWFRAME \ + EVT_MOUSEWHEEL(WinEDA_DrawFrame::OnMouseEvent)\ + EVT_MENU_OPEN(WinEDA_DrawFrame::OnMenuOpen)\ + EVT_ACTIVATE(WinEDA_DrawFrame::OnActivate) + + + +/**************************************************************/ +/* class WinEDA_BasePcbFrame: classe de base commune */ +/* aux classes d'affichage de PCB, et de l'editeur de Modules */ +/**************************************************************/ + +class WinEDA_BasePcbFrame: public WinEDA_DrawFrame +{ +public: + BOARD * m_Pcb; + + bool m_DisplayPadFill; // How show pads + bool m_DisplayPadNum; // show pads number + + int m_DisplayModEdge; // How show module drawings + int m_DisplayModText; // How show module texts + bool m_DisplayPcbTrackFill; /* FALSE = sketch , TRUE = rempli */ + WinEDA3D_DrawFrame * m_Draw3DFrame; + +public: + WinEDA_BasePcbFrame( wxWindow * father, WinEDA_App *parent, int idtype, + const wxString &title, + const wxPoint& pos, const wxSize& size); + + ~WinEDA_BasePcbFrame(void); + + // General + virtual void OnCloseWindow(wxCloseEvent & Event) = 0; + virtual void Process_Special_Functions(wxCommandEvent& event) = 0; + virtual void RedrawActiveWindow(wxDC * DC, bool EraseBg) = 0; + virtual void ReCreateHToolbar(void) = 0; + virtual void ReCreateVToolbar(void) = 0; + virtual void OnLeftClick(wxDC * DC, const wxPoint& MousePos) = 0; + virtual void OnLeftDClick(wxDC * DC, const wxPoint& MousePos) = 0; + virtual void OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu) = 0; + virtual void ReCreateMenuBar(void); + + PCB_SCREEN * GetScreen(void) { return (PCB_SCREEN *) m_CurrentScreen;} + int BestZoom(void); // Retourne le meilleur zoom + + void Show3D_Frame(wxCommandEvent& event); + + virtual void GeneralControle(wxDC *DC, wxPoint Mouse); + + // Undo and redo functions +public: + virtual void SaveCopyInUndoList(EDA_BaseStruct * ItemToCopy, + int flag_type_command = 0); +private: + virtual void GetComponentFromUndoList(void); + virtual void GetComponentFromRedoList(void); + +public: + // Read/write fonctions: + EDA_BaseStruct * ReadDrawSegmentDescr(FILE * File, int * LineNum); + int ReadListeSegmentDescr(wxDC * DC, FILE * File, + TRACK * PtSegm,int StructType, + int * LineNum, int NumSegm); + int ReadSetup(FILE * File, int * LineNum); + int ReadGeneralDescrPcb(wxDC * DC, FILE * File, int * LineNum); + + // Gestion du PCB + bool Clear_Pcb(wxDC * DC, bool query); + EDA_BaseStruct * PcbGeneralLocateAndDisplay(void); + EDA_BaseStruct * Locate(int typeloc ); + + // Gestion du curseur + void place_marqueur( wxDC * DC, const wxPoint & pos, char* pt_bitmap, + int DrawMode, int color, int type); + /* Place un repere sur l'ecran au point de coordonnees PCB pos */ + + + // Gestion des modules + void InstallModuleOptionsFrame(MODULE * Module, + wxDC * DC, const wxPoint & pos); + MODULE * Copie_Module(MODULE * module); + MODULE * Exchange_Module(wxWindow * winaff, MODULE * old_module, MODULE * new_module); + int Save_1_Module(const wxString & LibName, MODULE* Module, + bool Overwrite, bool DisplayDialog); + void Archive_Modules(const wxString & LibName, bool NewModulesOnly); + MODULE * Select_1_Module_From_BOARD(BOARD * Pcb); + + // Modules + MODULE * Create_1_Module(wxDC * DC, const wxString & module_name); + void Edit_Module(MODULE * module, wxDC * DC); + void Rotate_Module(wxDC * DC, MODULE * module, int angle, bool incremental); + void Change_Side_Module(MODULE * Module, wxDC * DC); + void Place_Module(MODULE * module, wxDC * DC); + void InstallExchangeModuleFrame(MODULE * ExchangeModuleModule, + wxDC * DC, const wxPoint & pos); + + // Textes sur modules + void RotateTextModule(TEXTE_MODULE * Text, wxDC * DC); + void DeleteTextModule(TEXTE_MODULE * Text, wxDC * DC); + void PlaceTexteModule(TEXTE_MODULE * Text, wxDC * DC); + void StartMoveTexteModule(TEXTE_MODULE * Text, wxDC * DC); + TEXTE_MODULE * CreateTextModule(MODULE * Module, wxDC * DC); + + void InstallPadOptionsFrame(D_PAD * pad, wxDC * DC, const wxPoint & pos); + void InstallTextModOptionsFrame(TEXTE_MODULE * TextMod, + wxDC * DC, const wxPoint & pos); + + // Pads sur modules + void AddPad(MODULE * Module, wxDC * DC); + void DeletePad(D_PAD* Pad, wxDC * DC); + void StartMovePad(D_PAD * Pad, wxDC * DC); + void RotatePad(D_PAD * Pad, wxDC * DC); + void PlacePad(D_PAD * Pad, wxDC * DC); + void Export_Pad_Settings( D_PAD * pt_pad); + void Import_Pad_Settings( D_PAD * pt_pad, wxDC * DC); + void Global_Import_Pad_Settings( D_PAD * Pad, wxDC * DC); + + + // Chargement de modules + MODULE * Get_Librairie_Module(wxWindow * winaff, const wxString & library, + const wxString & ModuleName, bool show_msg_err); + wxString Select_1_Module_From_List( + wxWindow * active_window, const wxString & Library, + const wxString & Mask, const wxString & KeyWord); + MODULE * Load_Module_From_Library(const wxString & library, wxDC * DC); + + // Gestion des chevelus (ratsnest) + void Compile_Ratsnest(wxDC * DC, bool affiche); /* Recalcul complet du chevelu */ + void ReCompile_Ratsnest_After_Changes(wxDC * DC ); + int Test_1_Net_Ratsnest(wxDC * DC, int net_code); + char * build_ratsnest_module(wxDC * DC, MODULE *Module); + void trace_ratsnest_module(wxDC * DC); + void Build_Board_Ratsnest(wxDC * DC); + void DrawGeneralRatsnest(wxDC * DC, int net_code = 0); + void trace_ratsnest_pad(wxDC * DC); + void recalcule_pad_net_code(void); /* Routine de + calcul et de mise a jour des net_codes des PADS */ + void build_liste_pads(void); + int * build_ratsnest_pad(EDA_BaseStruct * ref, const wxPoint & refpos, bool init); + + void Tst_Ratsnest(wxDC * DC, int ref_netcode ); + void Recalcule_all_net_connexion(wxDC * DC); + void test_connexions(wxDC * DC) ; + void test_1_net_connexion(wxDC * DC, int net_code ); + void reattribution_reference_piste(int affiche); + + // Plotting + void ToPlotter(wxCommandEvent& event); + void Plot_Serigraphie(int format_plot, FILE * File, int masque_layer); + void Genere_GERBER(const wxString & FullFileName, int Layer, + bool PlotOriginIsAuxAxis); + void Genere_HPGL(const wxString & FullFileName, int Layer); + void Genere_PS(const wxString & FullFileName, int Layer); + void Plot_Layer_HPGL(FILE * File,int masque_layer, + int garde, int tracevia, int modetrace); + void Plot_Layer_GERBER(FILE * File,int masque_layer, + int garde, int tracevia); + int Gen_D_CODE_File(FILE * file); + void Plot_Layer_PS(FILE * File,int masque_layer, + int garde, int tracevia, int modetrace); + + /* Block operations: */ + void Block_Delete(wxDC *DC); + void Block_Rotate(wxDC *DC); + void Block_Invert(wxDC * DC); + void Block_Move(wxDC * DC); + void Block_Duplicate(wxDC * DC); + + // Gestion des zones: + void DelLimitesZone(wxDC *DC, bool Redraw); + + // Gestion des layers: + int SelectLayer(int default_layer, int min_layer, int max_layer); + void SelectLayerPair(void); + + // divers + void AddHistory(int value, DrawStructureType type); // Add value in data list history + void InstallGridFrame(const wxPoint & pos); +}; + + + + /*****************************************************/ + /* class WinEDA_PcbFrame: public WinEDA_BasePcbFrame */ + /*****************************************************/ +class WinEDA_PcbFrame: public WinEDA_BasePcbFrame +{ +public: + WinEDAChoiceBox * m_SelLayerBox; + WinEDAChoiceBox * m_SelTrackWidthBox; + WinEDAChoiceBox * m_SelViaSizeBox; + +private: + bool m_SelTrackWidthBox_Changed; + bool m_SelViaSizeBox_Changed; + wxMenu * m_FilesMenu; + +public: + WinEDA_PcbFrame( wxWindow * father, WinEDA_App *parent, const wxString & title, + const wxPoint& pos, const wxSize& size); + + ~WinEDA_PcbFrame(void); + + // Configurations: + void InstallConfigFrame(const wxPoint & pos); + void Process_Config(wxCommandEvent& event); + void Update_config(wxWindow * displayframe); + void OnHotKey(wxDC * DC, int hotkey, EDA_BaseStruct * DrawStruct); + bool OnHotkeyDeleteItem(wxDC * DC, EDA_BaseStruct * DrawStruct); + + void OnCloseWindow(wxCloseEvent & Event); + void Process_Special_Functions(wxCommandEvent& event); + void ProcessMuWaveFunctions(wxCommandEvent& event); + void MuWaveCommand(wxDC * DC, const wxPoint& MousePos); + + void RedrawActiveWindow(wxDC * DC, bool EraseBg); + void ReCreateHToolbar(void); + void ReCreateAuxiliaryToolbar(void); + void ReCreateVToolbar(void); + void ReCreateAuxVToolbar(void); + void ReCreateOptToolbar(void); + void ReCreateMenuBar(void); + WinEDAChoiceBox * ReCreateLayerBox( WinEDA_Toolbar * parent); + void OnLeftClick(wxDC * DC, const wxPoint& MousePos); + void OnLeftDClick(wxDC * DC, const wxPoint& MousePos); + void OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu); + void OnSelectOptionToolbar(wxCommandEvent& event); + void ToolOnRightClick(wxCommandEvent& event); + + /* Gestion generale des operations sur block */ + int ReturnBlockCommand(int key); + void HandleBlockPlace(wxDC * DC); + int HandleBlockEnd(wxDC * DC); + + void SetToolbars(void); + void Process_Settings(wxCommandEvent& event); + void InstallPcbOptionsFrame(const wxPoint & pos, wxDC * DC, int id); + void InstallPcbGlobalDeleteFrame(const wxPoint & pos); + + void GenModulesPosition(wxCommandEvent& event); + void GenModuleReport(wxCommandEvent& event); + void InstallDrillFrame(wxCommandEvent& event); + void ToPostProcess(wxCommandEvent& event); + + void Files_io(wxCommandEvent& event); + int LoadOnePcbFile(const wxString & FileName, wxDC * DC, bool Append); + int ReadPcbFile(wxDC * DC, FILE * File, bool Append); + bool SavePcbFile(const wxString & FileName); + int SavePcbFormatAscii(FILE * File); + bool WriteGeneralDescrPcb(FILE * File); + bool RecreateCmpFileFromBoard(void); + + void ExportToGenCAD(wxCommandEvent& event); + + /* Fonctions specifiques */ + MODULE * ListAndSelectModuleName(void); + void Liste_Equipot(wxCommandEvent & event); + void Swap_Layers(wxCommandEvent & event); + int Test_DRC(wxDC * DC); + void Install_Test_DRC_Frame(wxDC * DC); + void Trace_Pcb(wxDC * DC, int mode); + void Trace_PcbEdges(wxDC * DC, int mode_color); + + // Gestion des textes sur pcb + void Rotate_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC); + TEXTE_PCB * Create_Texte_Pcb( wxDC * DC); + void Delete_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC); + void StartMoveTextePcb(TEXTE_PCB * TextePcb, wxDC * DC); + void Place_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC); + void InstallTextPCBOptionsFrame(TEXTE_PCB * TextPCB, + wxDC * DC, const wxPoint & pos); + + // Gestion des Segments type DRAWITEM + void Start_Move_DrawItem(DRAWSEGMENT * drawitem, wxDC * DC); + void Place_DrawItem(DRAWSEGMENT * drawitem, wxDC * DC); + + // Gestion des modules (voir egalement WinEDA_BasePcbFrame) + void StartMove_Module(MODULE * module, wxDC * DC); + bool Delete_Module(MODULE * module, wxDC * DC); + + // Chargement de modules: voir WinEDA_BasePcbFrame + + // Gestion du PCB + void Erase_Zones(wxDC * DC, bool query); + void Erase_Segments_Pcb(wxDC * DC, bool is_edges, bool query); + void Erase_Pistes(wxDC * DC, int masque_type, bool query); + void Erase_Modules(wxDC * DC, bool query); + void Erase_Textes_Pcb(wxDC * DC, bool query); + void Erase_Marqueurs(wxDC * DC, bool query); + void UnDeleteItem(wxDC * DC); + void RemoveStruct(EDA_BaseStruct * Item, wxDC * DC); + void Via_Edit_Control(wxDC * DC, int command_type, SEGVIA * via); + + // Mise en surbrillance des nets: + int Select_High_Light(wxDC * DC); + void Hight_Light(wxDC * DC); + void DrawHightLight(wxDC * DC, int NetCode); + + // Edition des pistes: + void DisplayTrackSettings(void); + void Other_Layer_Route(TRACK * track, wxDC * DC); + void Affiche_PadsNoConnect(wxDC * DC); + void Affiche_Status_Net(wxDC * DC); + TRACK * Delete_Segment(wxDC * DC, TRACK *Track); + void Delete_Track(wxDC * DC, TRACK *Track); + void Delete_net(wxDC * DC, TRACK *Track); + void Delete_Zone(wxDC * DC, SEGZONE *Track); + void Supprime_Une_Piste(wxDC * DC, TRACK* pt_segm); + bool Resize_Pistes_Vias(wxDC * DC, bool Track, bool Via); + void Edit_Zone_Width(wxDC * DC, SEGZONE * pt_ref); + void Edit_Net_Width(wxDC * DC, int Netcode); + void Edit_Track_Width(wxDC * DC, TRACK *Track); + int Edit_TrackSegm_Width(wxDC * DC, TRACK * segm); + TRACK * Begin_Route(TRACK * track, wxDC * DC); + void End_Route(TRACK * track, wxDC * DC); + void ExChange_Track_Layer(TRACK *pt_segm, wxDC * DC); + void Attribut_Segment(TRACK * track, wxDC * DC, bool Flag_On); + void Attribut_Track(TRACK * track, wxDC * DC, bool Flag_On); + void Attribut_net(wxDC * DC, int net_code, bool Flag_On); + void Start_MoveOneTrackSegment(TRACK * track, wxDC * DC, bool Drag); + bool PlaceDraggedTrackSegment(TRACK * Track, wxDC * DC); + + // Edition des zones + EDGE_ZONE * Del_SegmEdgeZone(wxDC * DC, EDGE_ZONE * edge_zone); + void CaptureNetName(wxDC * DC); + EDGE_ZONE * Begin_Zone(void); + void End_Zone(wxDC * DC); + void Fill_Zone(wxDC * DC); + + // Edition des mires de centrage + MIREPCB * Create_Mire( wxDC *DC); + void Delete_Mire(MIREPCB * MirePcb, wxDC * DC); + void StartMove_Mire(MIREPCB * MirePcb, wxDC * DC); + void Place_Mire(MIREPCB * MirePcb, wxDC * DC); + void InstallMireOptionsFrame(MIREPCB * MirePcb, wxDC * DC, const wxPoint & pos); + + // Gestion des segments de dessin type DRAWSEGMENT: + DRAWSEGMENT * Begin_DrawSegment(DRAWSEGMENT * Segment, int shape, wxDC * DC); + void End_Edge(DRAWSEGMENT * Segment, wxDC * DC); + void Drawing_SetNewWidth(DRAWSEGMENT *DrawSegm, wxDC * DC); + void Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC * DC); + void Delete_Drawings_All_Layer(DRAWSEGMENT *Segment, wxDC * DC); + + // Gestion des cotations: + void Install_Edit_Cotation(COTATION * Cotation, wxDC * DC, const wxPoint & pos); + COTATION * Begin_Cotation(COTATION * Cotation, wxDC * DC); + void Delete_Cotation(COTATION * Cotation, wxDC * DC); + + + // Gestion des netlistes: + void InstallNetlistFrame( wxDC * DC, const wxPoint & pos); + + // Autoplacement: + void AutoPlace(wxCommandEvent& event); + void ReOrientModules(const wxString & ModuleMask, int Orient, + bool include_fixe, wxDC * DC); + void FixeModule(MODULE * Module, bool Fixe); + void AutoMoveModulesOnPcb(wxDC * DC, bool PlaceModulesHorsPcb); + bool SetBoardBoundaryBoxFromEdgesOnly(void); + void AutoPlaceModule(MODULE * Module, int place_mode, wxDC * DC); + int RecherchePlacementModule(MODULE * Module, wxDC * DC); + void GenModuleOnBoard(MODULE * Module); + float Compute_Ratsnest_PlaceModule(wxDC * DC); + int GenPlaceBoard(void); + void DrawInfoPlace(wxDC * DC); + + // Autoroutage: + int Solve(wxDC * DC, int two_sides); + void Reset_Noroutable(wxDC * DC); + void Autoroute(wxDC * DC, int mode); + void ReadAutoroutedTracks(wxDC * DC); + void GlobalRoute(wxDC * DC); + + // fonctions generales + void Show_1_Ratsnest(EDA_BaseStruct * item, wxDC * DC); + void Ratsnest_On_Off(wxDC * DC); + void Clean_Pcb(wxDC * DC); + EDA_BaseStruct * SaveItemEfface(EDA_BaseStruct * PtItem, int nbitems); + + // divers + void InstallFindFrame(const wxPoint & pos, wxDC * DC); + + /* Special micro_ondes */ + void Edit_Gap(wxDC * DC, MODULE * Module); + MODULE * Create_MuWaveBasicShape(wxDC * DC, const wxString & name, int pad_count); + MODULE * Create_MuWaveComponent(wxDC * DC, int shape_type); + MODULE * Create_MuWavePolygonShape(wxDC * DC); + void Begin_Self( wxDC *DC); + MODULE * Genere_Self( wxDC *DC); + + DECLARE_EVENT_TABLE() +}; + + /****************************************************/ + /* class WinEDA_GerberFrame: public WinEDA_PcbFrame */ + /****************************************************/ + +class WinEDA_GerberFrame: public WinEDA_BasePcbFrame +{ +public: + WinEDAChoiceBox * m_SelLayerBox; + WinEDAChoiceBox * m_SelLayerTool; +private: + wxMenu * m_FilesMenu; + +public: + WinEDA_GerberFrame( wxWindow * father, WinEDA_App *parent, const wxString & title, + const wxPoint& pos, const wxSize& size); + + ~WinEDA_GerberFrame(void); + + void Update_config(void); + void OnCloseWindow(wxCloseEvent & Event); + void Process_Special_Functions(wxCommandEvent& event); + void RedrawActiveWindow(wxDC * DC, bool EraseBg); + void ReCreateHToolbar(void); + void ReCreateVToolbar(void); + void ReCreateOptToolbar(void); + void ReCreateMenuBar(void); + void OnLeftClick(wxDC * DC, const wxPoint& MousePos); + void OnLeftDClick(wxDC * DC, const wxPoint& MousePos); + void OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu); + int BestZoom(void); // Retourne le meilleur zoom + void OnSelectOptionToolbar(wxCommandEvent& event); + + EDA_BaseStruct * GerberGeneralLocateAndDisplay(void); + EDA_BaseStruct * Locate(int typeloc ); + + void SetToolbars(void); + void Process_Settings(wxCommandEvent& event); + void Process_Config(wxCommandEvent& event); + void InstallConfigFrame(const wxPoint & pos); + void InstallPcbOptionsFrame(const wxPoint & pos, int id); + void InstallPcbGlobalDeleteFrame(const wxPoint & pos); + + /* Gestion generale des operations sur block */ + int ReturnBlockCommand(int key); + virtual void HandleBlockPlace(wxDC * DC); + virtual int HandleBlockEnd(wxDC * DC); + + + void InstallDrillFrame(wxCommandEvent& event); + void ToPostProcess(wxCommandEvent& event); + void Genere_HPGL(const wxString & FullFileName, int Layers); + void Genere_GERBER(const wxString & FullFileName, int Layers); + void Genere_PS(const wxString & FullFileName, int Layers); + void Plot_Layer_HPGL(FILE * File,int masque_layer, + int garde, int tracevia, int modetrace); + void Plot_Layer_GERBER(FILE * File,int masque_layer, + int garde, int tracevia); + int Gen_D_CODE_File(const wxString & Name_File); + void Plot_Layer_PS(FILE * File,int masque_layer, + int garde, int tracevia, int modetrace); + + void Files_io(wxCommandEvent& event); + int LoadOneGerberFile(const wxString &FileName, wxDC * DC, int mode); + int ReadGerberFile(wxDC * DC, FILE * File, bool Append); + bool Read_GERBER_File(wxDC * DC, + const wxString & GERBER_FullFileName, + const wxString & D_Code_FullFileName); + bool SaveGerberFile(const wxString & FileName, wxDC * DC); + int Read_D_Code_File( const wxString & D_Code_FullFileName); + void CopyDCodesSizeToItems(void); + void Liste_D_Codes(wxDC * DC); + + /* Fonctions specifiques */ + void Trace_Gerber(wxDC * DC, int mode); + + // Gestion des textes sur pcb + void Rotate_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC); + TEXTE_PCB * Create_Texte_Pcb( wxDC * DC); + void Delete_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC); + void StartMoveTextePcb(TEXTE_PCB * TextePcb, wxDC * DC); + void Place_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC); + + // Gestion du PCB + bool Clear_Pcb(wxDC * DC, bool query); + void Erase_Current_Layer(wxDC * DC, bool query); + void Erase_Zones(wxDC * DC, bool query); + void Erase_Segments_Pcb(wxDC * DC, bool is_edges, bool query); + void Erase_Pistes(wxDC * DC, int masque_type, bool query); + void Erase_Textes_Pcb(wxDC * DC, bool query); + void UnDeleteItem(wxDC * DC); + + TRACK * Begin_Route(TRACK * track, wxDC * DC); + void End_Route(TRACK * track, wxDC * DC); + TRACK * Delete_Segment(wxDC * DC, TRACK *Track); + int Edit_TrackSegm_Width(wxDC * DC, TRACK * segm); + + DECLARE_EVENT_TABLE() +}; + + +/*********************************************************/ +/* class WinEDA_ModuleEditFrame: public WinEDA_DrawFrame */ +/* Class de la fenetre d'édition des modules pour PCB */ +/*********************************************************/ + +class WinEDA_ModuleEditFrame: public WinEDA_BasePcbFrame +{ +public: + MODULE * CurrentModule; + wxString m_CurrentLib; + +public: + WinEDA_ModuleEditFrame( wxWindow * father, WinEDA_App *parent, + const wxString & title, + const wxPoint& pos, const wxSize& size); + + ~WinEDA_ModuleEditFrame(void); + + void InstallOptionsFrame(const wxPoint & pos); + + void OnCloseWindow(wxCloseEvent & Event); + void Process_Special_Functions(wxCommandEvent& event); + void RedrawActiveWindow(wxDC * DC, bool EraseBg); + void ReCreateHToolbar(void); + void ReCreateVToolbar(void); + void ReCreateOptToolbar(void); + void ReCreateAuxiliaryToolbar(void); + void OnLeftClick(wxDC * DC, const wxPoint& MousePos); + void OnLeftDClick(wxDC * DC, const wxPoint& MousePos); + void OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu); + void SetToolbars(void); + void ReCreateMenuBar(void); + void ToolOnRightClick(wxCommandEvent& event); + void OnSelectOptionToolbar(wxCommandEvent& event); + void OnHotKey(wxDC * DC, int hotkey, EDA_BaseStruct * DrawStruct); + + /* Gestion generale des operations sur block */ + int ReturnBlockCommand(int key); + virtual void HandleBlockPlace(wxDC * DC); + virtual int HandleBlockEnd(wxDC * DC); + + EDA_BaseStruct * ModeditLocateAndDisplay(void); + +public: + void SaveCopyInUndoList(EDA_BaseStruct * ItemToCopy, int flag_type_command = 0); +private: + void GetComponentFromUndoList(void); + void GetComponentFromRedoList(void); + +public: + // Gestion des modules + void Place_Ancre(MODULE* module, wxDC * DC); + void RemoveStruct(EDA_BaseStruct * Item, wxDC * DC); + void Transform(MODULE* module, wxDC * DC, int transform); + + // Chargement de modules + MODULE * Import_Module(wxDC * DC); + void Export_Module(MODULE* ptmod, bool createlib); + void Load_Module_Module_From_BOARD( MODULE * Module ); + + // Gestion des contours + void Edit_Edge_Width(EDGE_MODULE * Edge, wxDC * DC); + void Edit_Edge_Layer(EDGE_MODULE * Edge, wxDC * DC); + void Delete_Edge_Module(EDGE_MODULE * Edge, wxDC * DC); + EDGE_MODULE * Begin_Edge_Module(EDGE_MODULE * Edge, wxDC * DC, int type_edge); + void End_Edge_Module(EDGE_MODULE * Edge,wxDC * DC); + void Enter_Edge_Width(EDGE_MODULE * Edge, wxDC * DC); + void Start_Move_EdgeMod(EDGE_MODULE * drawitem, wxDC * DC); + void Place_EdgeMod(EDGE_MODULE * drawitem, wxDC * DC); + + // Gestion des librairies: + void Delete_Module_In_Library(const wxString & libname); + int Create_Librairie(const wxString & LibName); + void Select_Active_Library(void); + + DECLARE_EVENT_TABLE() +}; + + + /*******************************/ + /* class WinEDA_SchematicFrame */ + /*******************************/ + +/* enum utilisé dans RotationMiroir() */ +enum fl_rot_cmp +{ + CMP_NORMAL, // orientation normale (O, pas de miroir) + CMP_ROTATE_CLOCKWISE, // nouvelle rotation de -90 + CMP_ROTATE_COUNTERCLOCKWISE, // nouvelle rotation de +90 + CMP_ORIENT_0, // orientation 0, pas de miroir, id CMP_NORMAL + CMP_ORIENT_90, // orientation 90, pas de miroir + CMP_ORIENT_180, // orientation 180, pas de miroir + CMP_ORIENT_270, // orientation -90, pas de miroir + CMP_MIROIR_X = 0x100, // miroir selon axe X + CMP_MIROIR_Y = 0x200 // miroir selon axe Y +}; + +class WinEDA_SchematicFrame: public WinEDA_DrawFrame +{ +public: + WinEDAChoiceBox * m_SelPartBox; +private: + wxMenu * m_FilesMenu; + +public: + WinEDA_SchematicFrame( wxWindow * father, WinEDA_App *parent, + const wxString & title, + const wxPoint& pos, const wxSize& size); + + ~WinEDA_SchematicFrame(void); + + void OnCloseWindow(wxCloseEvent & Event); + void Process_Special_Functions(wxCommandEvent& event); + void Process_Config(wxCommandEvent& event); + void Save_Config(wxWindow * displayframe); + + void RedrawActiveWindow(wxDC * DC, bool EraseBg); + + void ReCreateHToolbar(void); + void ReCreateVToolbar(void); + void ReCreateOptToolbar(void); + void ReCreateMenuBar(void); + void SetToolbars(void); + SCH_SCREEN * GetScreen(void) { return (SCH_SCREEN *) m_CurrentScreen;} + + void InstallConfigFrame(const wxPoint & pos); + + void OnLeftClick(wxDC * DC, const wxPoint& MousePos); + void OnLeftDClick(wxDC * DC, const wxPoint& MousePos); + void OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu); + void OnSelectOptionToolbar(wxCommandEvent& event); + void ToolOnRightClick(wxCommandEvent& event); + int BestZoom(void); // Retourne le meilleur zoom + + EDA_BaseStruct * SchematicGeneralLocateAndDisplay(bool IncludePin = TRUE); + + /* netlist generation */ + void * BuildNetListBase(void); + + // FUnctions used for hierarchy handling + void InstallPreviousScreen(void); + void InstallNextScreen(DrawSheetStruct * Sheet); + + void ToPlot_PS(wxCommandEvent& event); + void ToPlot_HPGL(wxCommandEvent& event); + void ToPostProcess(wxCommandEvent& event); + + void Save_File(wxCommandEvent& event); + int LoadOneEEProject(const wxString & FileName, bool IsNew); + bool LoadOneEEFile(SCH_SCREEN * screen, const wxString & FullFileName); + bool SaveEEFile(SCH_SCREEN *screen, int FileSave); + bool LoadOneSheet(SCH_SCREEN * screen, const wxString & FullFileName); + + // General search: + EDA_BaseStruct * FindSchematicItem(const wxString & pattern, int SearchType); + EDA_BaseStruct * FindMarker(int SearchType); + +private: + void Process_Move_Item(EDA_BaseStruct *DrawStruct, wxDC * DC); + + // Bus Entry + DrawBusEntryStruct * CreateBusEntry(wxDC * DC, int entry_type); + void SetBusEntryShape(wxDC * DC, DrawBusEntryStruct *BusEntry, int entry_type); + int GetBusEntryShape( DrawBusEntryStruct *BusEntry); + void StartMoveBusEntry(DrawBusEntryStruct * DrawLibItem, wxDC * DC); + + // NoConnect + EDA_BaseStruct *CreateNewNoConnectStruct(wxDC * DC); + + // Junction + DrawJunctionStruct * CreateNewJunctionStruct(wxDC * DC, + const wxPoint & pos, bool PutInUndoList = FALSE); + + // Text ,label, glabel + EDA_BaseStruct * CreateNewText(wxDC * DC, int type); + void EditSchematicText(DrawTextStruct * TextStruct, wxDC * DC); + void ChangeTextOrient(DrawTextStruct * TextStruct, wxDC * DC); + void StartMoveTexte(DrawTextStruct * TextStruct, wxDC *DC); + void ConvertTextType(DrawTextStruct * Text, wxDC * DC, int newtype); + + // Wire, Bus + void BeginSegment(wxDC * DC, int type); + void EndSegment(wxDC *DC); + void DeleteCurrentSegment(wxDC * DC); + void DeleteConnection(wxDC * DC, bool DeleteFullConnection); + + // graphic lines + void Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC * DC); + void Drawing_SetNewWidth(DRAWSEGMENT *DrawSegm, wxDC * DC); + void Delete_Drawings_All_Layer(DRAWSEGMENT *Segment, wxDC * DC); + DRAWSEGMENT * Begin_Edge(DRAWSEGMENT * Segment, wxDC * DC); + + // Hierarchical Sheet & PinSheet + void InstallHierarchyFrame(wxDC * DC, wxPoint &pos); + DrawSheetStruct * CreateSheet(wxDC * DC); + void ReSizeSheet(DrawSheetStruct * Sheet, wxDC * DC); +public: + bool EditSheet(DrawSheetStruct * Sheet, wxDC * DC); +private: + void StartMoveSheet(DrawSheetStruct* sheet, wxDC * DC); + DrawSheetLabelStruct * Create_PinSheet(DrawSheetStruct * Sheet, wxDC * DC); + void Edit_PinSheet(DrawSheetLabelStruct * SheetLabel, wxDC * DC); + void StartMove_PinSheet(DrawSheetLabelStruct * SheetLabel, wxDC * DC); + void Place_PinSheet(DrawSheetLabelStruct * SheetLabel, wxDC * DC); + DrawSheetLabelStruct * Import_PinSheet(DrawSheetStruct * Sheet, wxDC * DC); +public: + void DeleteSheetLabel(wxDC * DC, DrawSheetLabelStruct * SheetLabelToDel); +private: + + // Component + EDA_SchComponentStruct * Load_Component(wxDC * DC, + const wxString & libname, wxArrayString & List, bool UseLibBrowser ); + void StartMovePart(EDA_SchComponentStruct * DrawLibItem, wxDC * DC); +public: + void CmpRotationMiroir( + EDA_SchComponentStruct * DrawComponent, wxDC * DC, int type_rotate ); +private: + void SelPartUnit(EDA_SchComponentStruct *DrawComponent, int unit, wxDC * DC); + void ConvertPart(EDA_SchComponentStruct *DrawComponent, wxDC * DC); + void SetInitCmp(EDA_SchComponentStruct * DrawComponent, wxDC * DC); + void EditComponentReference(EDA_SchComponentStruct * DrawLibItem, wxDC * DC); + void EditComponentValue(EDA_SchComponentStruct * DrawLibItem, wxDC * DC); + void StartMoveCmpField(PartTextStruct * Field, wxDC * DC); + void EditCmpFieldText(PartTextStruct * Field, wxDC *DC); + void RotateCmpField(PartTextStruct * Field, wxDC * DC); + + /* Operations sur bloc */ + void PasteStruct(wxDC * DC); + /* Undo - redo */ +public: + void SaveCopyInUndoList(EDA_BaseStruct * ItemToCopy, int flag_type_command = 0); +private: + void PutDataInPreviousState(DrawPickedStruct * List); + void GetSchematicFromRedoList(void); + void GetSchematicFromUndoList(void); + + +public: + void OnHotKey(wxDC * DC, int hotkey, EDA_BaseStruct * DrawStruct); + + /* Gestion generale des operations sur block */ + int ReturnBlockCommand(int key); + void InitBlockPasteInfos(); + void HandleBlockPlace(wxDC * DC); + int HandleBlockEnd(wxDC * DC); + void HandleBlockEndByPopUp(int Command, wxDC * DC); + + // Repetition automatique de placements + void RepeatDrawItem(wxDC *DC); + + // Test des points de connexion en l'air (dangling ends) + void TestDanglingEnds(EDA_BaseStruct *DrawList, wxDC *DC); + LibDrawPin * LocatePinEnd(EDA_BaseStruct *DrawList, const wxPoint & pos); + + DECLARE_EVENT_TABLE() +}; + + + + /*****************************/ + /* class WinEDA_LibeditFrame */ + /*****************************/ + +class WinEDA_LibeditFrame: public WinEDA_DrawFrame +{ +public: + WinEDAChoiceBox * m_SelpartBox; + WinEDAChoiceBox * m_SelAliasBox; + +public: + WinEDA_LibeditFrame( wxWindow * father, WinEDA_App *parent, + const wxString & title, + const wxPoint& pos, const wxSize& size); + + ~WinEDA_LibeditFrame(void); + + void Process_Special_Functions(wxCommandEvent& event); + void DisplayLibInfos(void); + void RedrawActiveWindow(wxDC * DC, bool EraseBg); + void OnCloseWindow(wxCloseEvent & Event); + void ReCreateHToolbar(void); + void ReCreateVToolbar(void); + void OnLeftClick(wxDC * DC, const wxPoint& MousePos); + void OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu); + int BestZoom(void); // Retourne le meilleur zoom + void SetToolbars(void); + void OnLeftDClick(wxDC * DC, const wxPoint& MousePos); + SCH_SCREEN * GetScreen(void) { return (SCH_SCREEN *) m_CurrentScreen;} + + +private: + // General: + void CreateNewLibraryPart(void); + void DeleteOnePart(void); + void SaveOnePartInMemory(void); + void SelectActiveLibrary(void); + bool LoadOneLibraryPart(void); + void SaveActiveLibrary(void); + void ImportOnePart(void); + void ExportOnePart(bool create_lib); + int LoadOneLibraryPartAux(EDA_LibComponentStruct *LibEntry, + LibraryStruct *Library, int noMsg = 0); + + void DisplayCmpDoc(const wxString & Name); + void InstallLibeditFrame(const wxPoint & pos); + + // General editing +public: + void SaveCopyInUndoList(EDA_BaseStruct * ItemToCopy, int flag_type_command = 0); +private: + void GetComponentFromUndoList(void); + void GetComponentFromRedoList(void); + + // Edition des Pins: + void CreatePin(wxDC * DC); + void DeletePin(wxDC * DC, + EDA_LibComponentStruct* LibEntry, + LibDrawPin* Pin); + void StartMovePin(wxDC * DC); + + // Test des pins ( duplicates...) + bool TestPins(EDA_LibComponentStruct* LibEntry); + + // Edition de l'ancre + void PlaceAncre(void); + + // Edition des graphismes: + LibEDA_BaseStruct * CreateGraphicItem(wxDC * DC); + void GraphicItemBeginDraw(wxDC * DC); + void StartMoveDrawSymbol(wxDC * DC); + void EndDrawGraphicItem(wxDC * DC); + void LoadOneSymbol(wxDC * DC); + void SaveOneSymbol(void); + void EditGraphicSymbol(wxDC * DC, LibEDA_BaseStruct * DrawItem); + void EditSymbolText(wxDC * DC, LibEDA_BaseStruct * DrawItem); + void RotateSymbolText(wxDC * DC); + void DeleteDrawPoly(wxDC * DC); + LibDrawField * LocateField(EDA_LibComponentStruct *LibEntry); + void RotateField(wxDC * DC, LibDrawField *Field); + void PlaceField(wxDC * DC, LibDrawField *Field); + void EditField(wxDC * DC, LibDrawField *Field); + void StartMoveField(wxDC * DC, LibDrawField *field); + +public: + /* Block commands: */ + int ReturnBlockCommand(int key); + void HandleBlockPlace(wxDC * DC); + int HandleBlockEnd(wxDC * DC); + + void DeletePartInLib( LibraryStruct * Library, EDA_LibComponentStruct *Entry); + void PlacePin(wxDC * DC); + void InitEditOnePin(void); + void GlobalSetPins(wxDC * DC, LibDrawPin * MasterPin, int id); + // Repetition automatique de placement de pins + void RepeatPinItem(wxDC *DC, LibDrawPin * Pin); + + DECLARE_EVENT_TABLE() +}; + + + +class LibraryStruct; +class WinEDA_ViewlibFrame: public WinEDA_DrawFrame +{ +public: + WinEDAChoiceBox *SelpartBox; + + wxListBox * m_LibList; + wxSize m_LibListSize; + + wxListBox * m_CmpList; + wxSize m_CmpListSize; + + wxSemaphore * m_Semaphore; // != NULL if the frame must emulate a modal dialog + +public: + WinEDA_ViewlibFrame( wxWindow * father, WinEDA_App *parent, + LibraryStruct * Library = NULL, + wxSemaphore * semaphore= NULL); + + ~WinEDA_ViewlibFrame(void); + + void OnSize(wxSizeEvent& event); + void ReCreateListLib(void); + void ReCreateListCmp(void); + void Process_Special_Functions(wxCommandEvent& event); + void DisplayLibInfos(void); + void RedrawActiveWindow(wxDC * DC, bool EraseBg); + void OnCloseWindow(wxCloseEvent & Event); + void ReCreateHToolbar(void); + void ReCreateVToolbar(void); + void OnLeftClick(wxDC * DC, const wxPoint& MousePos); + int BestZoom(void); // Retourne le meilleur zoom + void ClickOnLibList(wxCommandEvent& event); + void ClickOnCmpList(wxCommandEvent & event); + SCH_SCREEN * GetScreen(void) { return (SCH_SCREEN *) m_CurrentScreen;} + +private: + void SelectCurrentLibrary(void); + void SelectAndViewLibraryPart(int option); + void ExportToSchematicLibraryPart(wxCommandEvent& event); + void ViewOneLibraryContent(LibraryStruct *Lib, int Flag); + void OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu); + + DECLARE_EVENT_TABLE() +}; + + + + /****************************************************/ + /* classe representant un ecran graphique de dessin */ + /****************************************************/ + +#include "drawpanel_wxstruct.h" + + + + + /*********************************************************/ + /* classe representant un ecran d'affichage des messages */ + /*********************************************************/ + +class WinEDA_MsgPanel: public wxPanel +{ +public: + WinEDA_DrawFrame * m_Parent; + int m_BgColor; // couleur de fond + +public: + // Constructor and destructor + WinEDA_MsgPanel(WinEDA_DrawFrame *parent, int id, const wxPoint& pos, const wxSize& size); + ~WinEDA_MsgPanel(void); + + void OnPaint(wxPaintEvent & event); + void EraseMsgBox(void); + void EraseMsgBox(wxDC * DC); + void Affiche_1_Parametre(int pos_X,const wxString & texte_H, + const wxString & texte_L,int color); + + + DECLARE_EVENT_TABLE() +}; + + +/******************************************************************/ +/* Classe pour editer une ligne de texte dans les menus de config */ +/******************************************************************/ +class WinEDA_EnterText +{ +public: + bool m_Modify; + +private: + wxString m_NewText; + wxTextCtrl * m_FrameText; + wxStaticText * m_Title; + +public: + // Constructor and destructor + WinEDA_EnterText(wxWindow *parent, const wxString & Title, + const wxString & TextToEdit, wxBoxSizer * BoxSizer, + const wxSize & Size ); + + ~WinEDA_EnterText(void) + { + } + + wxString GetValue(void); + void GetValue(char * buffer, int lenmax); + void SetValue(const wxString & new_text); + void Enable(bool enbl); + void SetFocus(void) { m_FrameText->SetFocus(); } + void SetInsertionPoint(int n) { m_FrameText->SetInsertionPoint(n); } + void SetSelection(int n, int m) { + m_FrameText->SetSelection(n, m); } +}; + +/*********************************************************************/ +/* Classe pour editer un texte graphique + dimension en INCHES ou MM */ +/*********************************************************************/ +class WinEDA_GraphicTextCtrl +{ +public: + int m_Units, m_Internal_Unit; + + wxTextCtrl * m_FrameText; + wxTextCtrl * m_FrameSize; +private: + wxStaticText * m_Title; + +public: + // Constructor and destructor + WinEDA_GraphicTextCtrl(wxWindow *parent, const wxString & Title, + const wxString & TextToEdit, int textsize, + int units, wxBoxSizer * BoxSizer, int framelen = 200, + int internal_unit = EESCHEMA_INTERNAL_UNIT); + + ~WinEDA_GraphicTextCtrl(void); + + wxString GetText(void); + int GetTextSize(void); + void Enable(bool state); + void SetTitle(const wxString & title); + void SetFocus(void) { m_FrameText->SetFocus(); } + void SetValue(const wxString & value); + void SetValue(int value); +}; + + +/*****************************************************************/ +/* Classe pour afficher et editer une coordonnée en INCHES ou MM */ +/*****************************************************************/ +class WinEDA_PositionCtrl +{ +public: + int m_Units, m_Internal_Unit; + wxPoint m_Pos_To_Edit; + + wxTextCtrl * m_FramePosX; + wxTextCtrl * m_FramePosY; +private: + wxStaticText * m_TextX, * m_TextY; + +public: + // Constructor and destructor + WinEDA_PositionCtrl(wxWindow *parent, const wxString & title, + const wxPoint & pos_to_edit, + int units, wxBoxSizer * BoxSizer, + int internal_unit = EESCHEMA_INTERNAL_UNIT ); + + ~WinEDA_PositionCtrl(void); + + void Enable(bool x_win_on, bool y_win_on); + void SetValue(int x_value, int y_value); + wxPoint GetValue(void); +}; + +/*****************************************************************/ +/* Classe pour afficher et editer une coordonnée en INCHES ou MM */ +/*****************************************************************/ +class WinEDA_SizeCtrl: public WinEDA_PositionCtrl +{ +public: + // Constructor and destructor + WinEDA_SizeCtrl(wxWindow *parent, const wxString & title, + const wxSize & size_to_edit, + int units, wxBoxSizer * BoxSizer, + int internal_unit = EESCHEMA_INTERNAL_UNIT ); + + ~WinEDA_SizeCtrl(void) {} + wxSize GetValue(void); +}; + + +/*****************************************************************/ +/* Classe pour afficher et editer une valeur en INCHES ou MM */ +/*****************************************************************/ +/* internal_unit est le nombre d'unites internes par inch + - 1000 sur EESchema + - 10000 sur PcbNew +*/ +class WinEDA_ValueCtrl +{ +public: + int m_Units; + int m_Value; + wxTextCtrl * m_ValueCtrl; +private: + int m_Internal_Unit; + wxStaticText * m_Text; + +public: + // Constructor and destructor + WinEDA_ValueCtrl(wxWindow *parent, const wxString & title, int value, + int units, wxBoxSizer * BoxSizer, + int internal_unit = EESCHEMA_INTERNAL_UNIT ); + + ~WinEDA_ValueCtrl(void); + + int GetValue(void); + void SetValue(int new_value); + void Enable(bool enbl); + void SetToolTip(const wxString & text) + { + m_ValueCtrl->SetToolTip(text); + } +}; + +/*****************************************************************/ +/* Classe pour afficher et editer une valeur double flottant */ +/*****************************************************************/ +class WinEDA_DFloatValueCtrl +{ +public: + double m_Value; + wxTextCtrl * m_ValueCtrl; +private: + wxStaticText * m_Text; + +public: + // Constructor and destructor + WinEDA_DFloatValueCtrl(wxWindow *parent, const wxString & title, + double value, wxBoxSizer * BoxSizer); + + ~WinEDA_DFloatValueCtrl(void); + + double GetValue(void); + void SetValue(double new_value); + void Enable(bool enbl); + void SetToolTip(const wxString & text) + { + m_ValueCtrl->SetToolTip(text); + } +}; + + + /*************************/ + /* class WinEDA_Toolbar */ + /*************************/ + +class WinEDA_Toolbar: public wxToolBar +{ +public: + wxWindow * m_Parent; + id_toolbar m_Ident; + WinEDA_Toolbar * Pnext; + bool m_Horizontal; + int m_Size; + +public: + WinEDA_Toolbar(id_toolbar type, wxWindow * parent, + wxWindowID id, bool horizontal); + WinEDA_Toolbar * Next(void) { return Pnext;} +}; + + + /***********************/ + /* class WinEDAListBox */ + /***********************/ + +class WinEDAListBox : public wxDialog +{ +public: + wxWindow * m_Parent; + wxListBox * m_List; + wxTextCtrl * m_WinMsg; + const wxChar ** m_ItemList; + +private: + void(* m_MoveFct)(wxString & Text); + +public: + WinEDAListBox( wxWindow * parent, const wxString & title, + const wxChar ** ItemList, + const wxString & RefText, + void(* movefct)(wxString & Text) = NULL, + const wxColour & colour = wxNullColour, + wxPoint dialog_position = wxDefaultPosition); + ~WinEDAListBox(void); + + void SortList( void ); + void Append(const wxString & item); + void InsertItems(const wxArrayString & itemlist, int position=0); + void MoveMouseToOrigin(void); + wxString GetTextSelection(void); + +private: + void OnClose(wxCloseEvent& event); + void Cancel(wxCommandEvent& event); + void Ok(wxCommandEvent& event); + void ClickOnList(wxCommandEvent& event); + void D_ClickOnList(wxCommandEvent& event); + DECLARE_EVENT_TABLE() +}; + + +/*************************/ +/* class WinEDAChoiceBox */ +/*************************/ +/* class to display a choice list. +This is a wrapper to wxComboBox (or wxChoice) +but because they have some problems, WinEDAChoiceBox uses workarounds: + - in wxGTK 2.6.2 wxGetSelection() does not work properly, + - and wxChoice crashes if compiled in non unicode mode and uses utf8 codes +*/ + +#define EVT_KICAD_CHOICEBOX EVT_COMBOBOX +class WinEDAChoiceBox : public wxComboBox +{ +public: + WinEDAChoiceBox(wxWindow* parent, wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + int n = 0, const wxString choices[] = NULL) : + wxComboBox(parent, id, wxEmptyString, pos, size, + n, choices, wxCB_READONLY) + { + } + + WinEDAChoiceBox(wxWindow* parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, + const wxArrayString & choices) : + wxComboBox(parent, id, wxEmptyString, pos, size, + choices, wxCB_READONLY) + { + } + + int GetChoice(void){ + return GetCurrentSelection(); + } +}; + +#endif /* WXSTRUCT_H */ + diff --git a/install.txt b/install.txt new file mode 100644 index 0000000000..3e90e5a582 --- /dev/null +++ b/install.txt @@ -0,0 +1,161 @@ +/*****************************/ +/***** English version *******/ +/*****************************/ + +Kicad binaries exists for Linux and Windows (XP, 2000) +Files (schematic, boards, libraries) created on both systems are totally compatibles. + +Used language: +Doc files are in french, but kicad user interface is internationalized: +User interface is in English for most countries. +User interface is in French **only** if you run kicad from a french version of Linux or Windows. +It is easy to add a new translation with poedit. +Kicad can use this translation without any change. +(poedit is used to create the french translation). +See http://poedit.sourceforge.net. +Contact me for more details. + +Installation form archives: +(both have binary file for Linux and Windows XP and 2000 (not Window 98) ) +kicad.zip +or +kicad.tgz + +Untar or unzip kicad +this create the kicad tree in the current directory. + +**Under Windows: +Goto C:\ or D:\ (or other prefered directory). +Examples are for an install on C:\. +Unzip kicad.zip +You must have created c:\kicad. +Windows executables are in c:\kicad\winexe. +The main program is kicad.exe and from it you can run other programs +(schematic, pcb, utilities: cvpcb, gerbview and other) ) +I suggest you create a shortcut to c:\kicad\winexe\kicad.exe + + +** Under Linux: +You do must have libc.so.6 (do not work with libc.so.5) +You must be "root". +goto /usr/local +Untar kicad.tgz : tar zxvf kicad.tgz (ou unzip kicad.zip) +(It is possible to unzip kicad.zip: unzip kicad.zip, +and goto /usr/local/kicad/linux and run chmod 755 *) +The main program is /usr/local/kicad/linux/kicad +If you use KDE, users can copy the shortcut /usr/local/kicad/linux/kicad.desktop +in /Desktop and use it to run kicad. + +3D modeler wings3D: +(Usefull only if you plan to create 3D shapes for Printed board modules) +Archive and doc files (Linux and windows ) are in ../kicad/wing3d +goto www.wings3d.org to have more details. +Pcbnew use the exported files in wrml (.wrl) format from wings3d (not the native .wings format). + +Documentation: +Currenty only in french. +"On line" in html format. +source files (200 sheets) are in OpenOffice (www.openoffice.org) format. +Can be read, printed and/or modified with OpenOffice. +See files in kicad/help/doc_src/* + +Kicad tree: +kicad/winexe: windows (XP et 2000 compatible) binaries. +kicad/linux: linux binaries (Mandrake 9.2 and 10.0 tested, + probably work fine for distributions who have an recent libc) +kicad/library: libraries for schematic +kicad/library/doc: documentation files for schematic components (.pdf) + (readable from schematic if you have acrobat ou Xpdf) +kicad/modules: module libraries for printed boards. + files *.mod are the libraries, + and files *.brd are printed board you can see with pcbnew + files *.brd show the existing modules (and 3D shapes) in libraries. +kicad/modules/packages3d: many 3D shapes (.wrl et .wings format) for existing modules + +kicad/demos: Usefull... +kicad/internat: dictionnaires des langues (actuellement anglais->francais) pour les menus +kicad/help: On line help (in french) +kicad/help/doc_src: Documentation (in french) (source doc, 200 sheets) under OpenOffice. + +Warning: +Do not change the kicad tree, or the location of binary files, +or kicad will **not** be able to found other kicad files (configuration, libraries...) + + +/*******************************/ +/***** version Francaise *******/ +/*******************************/ + +Les executable kicad existent pour Linux et Windows (XP, 2000) +Les fichiers crees (Schematique, circuits imprimes, librairies) sous ces 2 systemes sont +totalement compatibles. + +Installation a partir des archives +(toutes les 2 contiennent **tous** les executables): +kicad.zip +ou +kicad.tgz (s'il est disponible) + +Le decompactage cree le repertoire kicad (et ses sous repertoires) a partir +du repertoire courant. + +**Sous Windows: +se placer dans C:\ (ou D:\ ou tout disque et repertoire de son choix) +On supposera ici que l'on s'est placé dans c:\ +Decompacter kicad.zip +Créer un raccourci vers c:\kicad\winexe\kicad.exe +On pourra alors lancer le gestionnaire de projets kicad.exe + +Sous Linux +On se placera de préférence en /usr/local +Il faudra sans doute aussi etre "root" +Decompacter kicad.tgz ou kicad.zip + - kicad.tgz: faire tar zxvf /kicad.tgz + - kicad.zip (unzip /kicad.zip). Il faudra alors dans ce + cas rendre executable kicad, cvpcb, eeschema, gerbview et pcbnew: + se placer dans /usr/local/kicad/linux et faire la commande chmod 755 nom_fichier + pour ces 5 fichiers. +On lancera kicad par /usr/local/kicad/linux/kicad +Sous KDE on pourra copier /usr/local/kicad/linux/kicad.desktop sur le bureau +de KDE comme raccourci. + +Installation du modeleur 3D wings3D pour créer les formes 3D des modules du PCB: +Il est fourni dans ..kicad/wings3d pour Windows et Linux. +Se reporter au site du créateur pour tous détails (www.wings3d.org) +Se reporter aussi a la doc de pcbnew pour la génération des fichiers 3d + +Documentation: +L'impression de la documentation (environ 200 pages) peut se faire +sous OpenOffice (www.openoffice.org) (magnifique logiciel libre de traitement de texte). + +Principaux repertoires de Kicad: +kicad/winexe: executables sous windows (teste sous XP et 2000) +kicad/linux: executables sous linux (testes sous Mandrake 9.2 et 10.0) +kicad/library: fichiers libraires de composants schematiques +kicad/library/doc: fichiers documentation des composants schematiques (.pdf) + (accessibles directement de la schematique si l'on a installé acrobat ou Xpdf) +kicad/modules: fichiers de composants (modules) pour le circuit imprimé +kicad/modules/packages3d: fichiers de formes 3D des modules + +kicad/demos: C'est toujours utile... +kicad/internat: dictionnaires des langues (actuellement anglais->francais) pour les menus +kicad/help: fichiers d'aides en ligne +kicad/help/doc_src: fichiers d'aides (doc source, 200 pages) sous OpenOffice, + a lire avant de se plaindre. + + +Complements: +-En cas de difficulté: +Un problème peut surgir pour kicad lors de la recherche des fichiers utiles +comme fichiers de config, librairies, dictionnaire anglais->français, docs... +Sous Windows: + La recherche se fait là ou sont lus les executables. + Il ne faut donc pas recopier les executables ailleurs que là ou ils sont. + Toutefois, si cela ne marche pas, kicad cherche le repertoire c:\kicad +Sous linux: + La recherche se fait sur /usr/local/kicad (installation conseillée), + ou dans le chemin des executables si /usr/local/kicad n'est pas trouvé. + +Uniquement en cas d'installation non standard (et en cas de difficulté), +definir la variable d'environnement KICAD = +ex: KICAD=/usr/local/cao/kicad diff --git a/kicad/bitmaps/Browse_Files.xpm b/kicad/bitmaps/Browse_Files.xpm new file mode 100644 index 0000000000..56a60adfc4 --- /dev/null +++ b/kicad/bitmaps/Browse_Files.xpm @@ -0,0 +1,85 @@ +/* XPM */ +static char * browse_files_xpm[] = { +"16 16 66 1", +" c None", +". c #000000", +"+ c #E4E5DE", +"@ c #D3D5CA", +"# c #A5A797", +"$ c #F3F4F0", +"% c #ABAE99", +"& c #BDC0AD", +"* c #BCBEAA", +"= c #B1B49F", +"- c #6E715C", +"; c #E6E7DD", +"> c #F5F6F3", +", c #818181", +"' c #E2E4D9", +") c #E1E3D8", +"! c #DFE1D6", +"~ c #C4C6B6", +"{ c #F7F7F6", +"] c #D3D6C5", +"^ c #808080", +"/ c #636363", +"( c #D2D2D2", +"_ c #F2F2F2", +": c #CACDB9", +"< c #C8CBB6", +"[ c #C6C9B3", +"} c #C4C8B1", +"| c #93967C", +"1 c #F0F0EB", +"2 c #C5C5C5", +"3 c #F5F5F5", +"4 c #FEFEFE", +"5 c #F0F1EC", +"6 c #D2D4C2", +"7 c #AEAEAE", +"8 c #E5E5E5", +"9 c #F8F8F8", +"0 c #E0E0E0", +"a c #C3C6AF", +"b c #C1C4AD", +"c c #909478", +"d c #EFF0EB", +"e c #CED1BD", +"f c #7B7B7B", +"g c #5D5D5D", +"h c #ADADAD", +"i c #BCBCBC", +"j c #626262", +"k c #666666", +"l c #BFC2AB", +"m c #BDC1A8", +"n c #8E9175", +"o c #EDEEE8", +"p c #7C7C7C", +"q c #525252", +"r c #BBBEA5", +"s c #BABDA3", +"t c #8B8F72", +"u c #ECEEE7", +"v c #B7BAA0", +"w c #E8E8E0", +"x c #C6C9BA", +"y c #8E9276", +"z c #8C9073", +"A c #646751", +" ", +" ", +" .... ", +" .+@@#. ", +" .$%&*=-....... ", +" .;>;,..,''))!~.", +" .{]^/(_/^:<[}|.", +" .1].234_.:<[}|.", +" .56.7890.[}abc.", +" .defghijkablmn.", +" .o: c #767676", +", c #5D5D5D", +"' c #404040", +") c #F0F0F0", +"! c #E2E2E2", +"~ c #858585", +"{ c #4B4B49", +"] c #FBE73B", +"^ c #F2B64D", +"/ c #CACACA", +"( c #EFEFEF", +"_ c #C9C9C9", +": c #FCEB3D", +"< c #F7B544", +"[ c #61542E", +"} c #EEEEEE", +"| c #FCE93B", +"1 c #F7B545", +"2 c #6C5F34", +"3 c #F9DF39", +"4 c #F4B244", +"5 c #665D3E", +"6 c #EDEDED", +"7 c #ECECEC", +"8 c #EBEBEB", +"9 c #F6D236", +"0 c #EFB44D", +"a c #5C4F2B", +"b c #C4C4C4", +"c c #E8E8E8", +"d c #D7AE74", +"e c #655930", +"f c #C0C0C0", +"g c #EAEAEA", +"h c #E9E9E9", +"i c #4F4115", +"j c #E7E7E7", +"k c #BFBFBF", +"l c #C2C2C2", +"m c #E6E6E6", +"n c #E5E5E5", +"o c #BEBEBE", +"p c #E4E4E4", +"q c #BDBDBD", +"r c #E3E3E3", +"s c #BBBBBB", +"t c #BCBCBC", +"u c #A0A0A0", +" ......... ", +" .++++++@#$. ", +" .+%%%%%%&*=. ", +" .+%---%%;>,'.. ", +" .+%%%%%)!~{.]^.", +" .+%////(/_.:<[.", +" .+(((}}}}.|12. ", +" .@}__}__.345. ", +" .@67778.90a.. ", +" .@8bbbc.de.f. ", +" .@gghh.i..jk. ", +" .@clml..mmno. ", +" .@jjmmmnnppq. ", +" .@mnnnpprrrs. ", +" .lqqqttssssu. ", +" ........... "}; diff --git a/kicad/bitmaps/Fonts.xpm b/kicad/bitmaps/Fonts.xpm new file mode 100644 index 0000000000..93a93c46ee --- /dev/null +++ b/kicad/bitmaps/Fonts.xpm @@ -0,0 +1,65 @@ +/* XPM */ +static char * fonts_xpm[] = { +"16 16 46 1", +" c None", +". c #70653B", +"+ c #463F24", +"@ c #6B6139", +"# c #1B180D", +"$ c #2C2818", +"% c #595030", +"& c #252112", +"* c #292516", +"= c #70643B", +"- c #827544", +"; c #3D3721", +"> c #37311D", +", c #3E3721", +"' c #302B1A", +") c #5C5331", +"! c #010101", +"~ c #1A170E", +"{ c #1E1A10", +"] c #403922", +"^ c #584F2F", +"/ c #16140C", +"( c #1E1B10", +"_ c #312B1A", +": c #0F0D07", +"< c #2D2818", +"[ c #322D1A", +"} c #231F11", +"| c #3C3620", +"1 c #5A5230", +"2 c #332E1B", +"3 c #12100A", +"4 c #4F472A", +"5 c #413A23", +"6 c #302B19", +"7 c #342E1B", +"8 c #4A4227", +"9 c #6E633A", +"0 c #080704", +"a c #2F2919", +"b c #4C4529", +"c c #51472B", +"d c #242113", +"e c #322D1B", +"f c #5E5432", +"g c #211E12", +" ", +" .+ ", +" @ # ", +" $ ", +" %&* ", +" = * -;> ", +" , ' )!~ ", +" { !] ^!/ (_ ", +" :<[ }| 1!2 c #F0F0F0", +", c #707070", +"' c #3D3D3D", +") c #C3C3C3", +"! c #0E0E0E", +"~ c #171717", +"{ c #4B4B4B", +"] c #616161", +"^ c #131313", +"/ c #6F6F6F", +"( c #C6C6C6", +"_ c #1B1B1B", +": c #4A4A4A", +"< c #1A1A1A", +"[ c #090909", +"} c #121212", +"| c #B1B1B1", +"1 c #111111", +" ", +" ......+ ", +" .@#$$$%& ", +" ......*=$-;. ", +" .>#$$$,')$=! ", +"......~=${]^$=! ", +".>#$$$/')$(_$=! ", +".>#$$$:]^$(_$=! ", +".>#$$$$(<$(_$=! ", +".>#$$$$(<$(_$=! ", +".>#$$$$(<$(_))[ ", +".>#$$$$(<$(_.. ", +".>#$$$$(<))} ", +".>#$$$$(<... ", +".|))))))1 ", +"......... "}; diff --git a/kicad/bitmaps/Open_Project.xpm b/kicad/bitmaps/Open_Project.xpm new file mode 100644 index 0000000000..239dbd1b98 --- /dev/null +++ b/kicad/bitmaps/Open_Project.xpm @@ -0,0 +1,86 @@ +/* XPM */ +static const char * open_project_xpm[] = { +"16 16 67 1", +" c None", +"! c black", +"# c #020202", +"$ c #F8F8F8", +"% c #ECECEC", +"& c #EBEBEB", +"' c #6B6B6B", +"( c #2D2D2D", +") c #181818", +"* c #C5C5C5", +"+ c #434343", +", c #5E5E5E", +"- c #F0F0F0", +". c #707070", +"0 c #3D3D3D", +"1 c #C3C3C3", +"2 c #0E0E0E", +"3 c #171717", +"4 c #4B4B4B", +"5 c #616161", +"6 c #131313", +"7 c #E4E5DF", +"8 c #6F6F6F", +"9 c #C6C6C6", +": c #1B1B1B", +"; c #8D907B", +"< c #4A4A4A", +"= c #A6A6A6", +"> c #8A8C7D", +"? c #1A1A1A", +"@ c #878A75", +"A c #666858", +"B c #4B4D3F", +"C c #4D4F40", +"D c #404135", +"E c #424337", +"F c #434437", +"G c #404236", +"H c #3C3D32", +"I c #48493C", +"J c #1A1A16", +"K c #848672", +"L c #25261F", +"M c #F1F2E9", +"N c #DDE0C7", +"O c #D6DABB", +"P c #CDD2AC", +"Q c #C7CCA7", +"R c #989C80", +"S c #090909", +"T c #5F6152", +"U c #888980", +"V c #A7AB8C", +"W c #878A70", +"X c #EFF0E5", +"Y c #9EA284", +"Z c #0C0C0C", +"[ c #96968D", +"] c #E3E5D1", +"^ c #83866D", +"_ c #EDEFE2", +"` c #A2A688", +"a c #E7E9DA", +"b c #D1D3BD", +"c c #BBBF9D", +"d c #989B80", +"e c #6E715C", +" !!!!!!# ", +" !$%&&&'( ", +" !!!!!!)*&+,!", +" !-%&&&.01&*2", +"!!!!!!!3*&456&*2", +"7!-%&&&801&9:&*2", +";!-%&&&<56=9:&*2", +">!-%&&&&9?&9:&*2", +"@ABCDEEFGHIJ6&*2", +"KLMNOPPPPPQR!11S", +"TUNPPPPPPPVW!!! ", +"LXOPPPPPPPY!Z ", +"[]PPPPPPPP^!! ", +"_PPPPPPPP`!! ", +"abccccccde! ", +"!!!!!!!!!!! "}; diff --git a/kicad/bitmaps/Save_Project.xpm b/kicad/bitmaps/Save_Project.xpm new file mode 100644 index 0000000000..fa6d524267 --- /dev/null +++ b/kicad/bitmaps/Save_Project.xpm @@ -0,0 +1,82 @@ +/* XPM */ +static char * save_project_xpm[] = { +"16 16 63 1", +" c None", +". c #000000", +"+ c #020202", +"@ c #F8F8F8", +"# c #ECECEC", +"$ c #EBEBEB", +"% c #6B6B6B", +"& c #2D2D2D", +"* c #181818", +"= c #C5C5C5", +"- c #434343", +"; c #5E5E5E", +"> c #F0F0F0", +", c #707070", +"' c #3D3D3D", +") c #C3C3C3", +"! c #0E0E0E", +"~ c #9C9C9C", +"{ c #4B4B4B", +"] c #616161", +"^ c #131313", +"/ c #D18F84", +"( c #D19084", +"_ c #D39186", +": c #BFD5E8", +"< c #C6C6C6", +"[ c #1B1B1B", +"} c #C77467", +"| c #C77466", +"1 c #C87668", +"2 c #CD867A", +"3 c #8DA9BE", +"4 c #54697C", +"5 c #FEFEFE", +"6 c #F9F9F9", +"7 c #84A0B5", +"8 c #4F6475", +"9 c #D7D7D7", +"0 c #D6D6D6", +"a c #F1F1F1", +"b c #819AAE", +"c c #496072", +"d c #FCFCFC", +"e c #F4F4F4", +"f c #090909", +"g c #D4D4D4", +"h c #F2F2F2", +"i c #EEEEEE", +"j c #121212", +"k c #BFCBD6", +"l c #A1B6C4", +"m c #7E99AD", +"n c #7D97AC", +"o c #CECECE", +"p c #9C9D9D", +"q c #2F4656", +"r c #80868C", +"s c #183042", +"t c #33495A", +"u c #B9B9B9", +"v c #132D3C", +"w c #586D80", +"x c #97A5B0", +" ......+ ", +" .@#$$$%& ", +" ......*=$-;.", +" .>#$$$,')$=!", +".........~{]^$=!", +"////(/_::.$<[$=!", +"}}}|}1234.$<[$=!", +"555555678.$<[$=!", +"999990abc.$<[$=!", +"55de$$abc.$<[))f", +"9g====abc.$<[.. ", +"h$$$$$ibc.))j ", +"kkkkkklbc.... ", +"bbbbmnbbc. ", +"=o$9pqrbc. ", +"st0=uvwxc. "}; diff --git a/kicad/bitmaps/unzip.xpm b/kicad/bitmaps/unzip.xpm new file mode 100644 index 0000000000..fdb2792407 --- /dev/null +++ b/kicad/bitmaps/unzip.xpm @@ -0,0 +1,35 @@ +/* XPM */ +static char * unzip_xpm[] = { +"16 16 16 1", +" c none", +". c #060304", +"X c #1c2824", +"o c #043e50", +"O c #045b72", +"+ c #047796", +"@ c #048cb0", +"# c #2e1806", +"$ c #4a2204", +"% c #833b04", +"& c #a04904", +"* c #0a2e36", +"= c #eb6d04", +"- c #5d2b04", +"; c #fcb472", +": c #cc925c", +" ..... ", +" ..XoO++. ", +" .o@@@O. ", +" ....+@@O. ", +" ...#$$O@++o. ", +" ..$%&%*@@X#*. ", +" .=-%&%%*X==#.. ", +" .==&%&&-%--&&..", +" #====%$-&=&==$.", +" .====;%=&==&=%.", +" .====;-&==%$.. ", +" .====;&#$.... ", +" .$===;&$..-$. ", +" ...%=;&&%%#.. ", +" ..#:%$.... ", +" ..... "}; diff --git a/kicad/bitmaps/zip.xpm b/kicad/bitmaps/zip.xpm new file mode 100644 index 0000000000..343f75b528 --- /dev/null +++ b/kicad/bitmaps/zip.xpm @@ -0,0 +1,35 @@ +/* XPM */ +static char * zip_xpm[] = { +"16 16 16 1", +" c none", +". c #060304", +"X c #1a1804", +"o c #074d04", +"O c #04ca04", +"+ c #2f2704", +"@ c #047e04", +"# c #046704", +"$ c #572704", +"% c #9f4904", +"& c #7d3904", +"* c #049a04", +"= c #fc7604", +"- c #d56204", +"; c #fcb472", +": c #cc925c", +" . .X. ", +" ...oO+. ", +" o@oOOo. ", +" ..oOOO#. ", +" ...X$oOOOX. ", +" ..$%%&#OOO*.. ", +" .%$&%&o#o&&$.. ", +" .==&&&$$%$$%%..", +" .===-$$&%----$.", +" .====;&------&.", +" .====;$%--&$.. ", +" .====;%X$.... ", +" .$-==;%$..$$. ", +" ...&=;%%&&X.. ", +" ..X:&$.... ", +" ..... "}; diff --git a/kicad/bitmaps/zip_tool.xpm b/kicad/bitmaps/zip_tool.xpm new file mode 100644 index 0000000000..9411e7a396 --- /dev/null +++ b/kicad/bitmaps/zip_tool.xpm @@ -0,0 +1,37 @@ +/* XPM */ +static char *zip_tool_xpm[] = { +/* width height num_colors chars_per_pixel */ +"16 15 16 1", +"A c #040604", +"B c #9C9A04", +"C c #FCCE9C", +"D c #DCDEDC", +"E c #FCFE9C", +"F c #FCFAFC", +"G c #0402FC", +"H c #CCCE64", +"I c #FCFECC", +"J c #FCFEFC", +"K c #150016", +"L c #000000", +"M c #20CC00", +"N c #1CEB00", +"O c #161200", +"P c #000000", +"FFFFFFGGGGGGGGGG", +"FFBBBBGJJJJJJJJG", +"FBDIIEGJJGGGGGJG", +"BHHHHHGJJJJJGGJG", +"BIIIIIGJJJJGGJJG", +"BIEEEEGJJJGGJJJG", +"BIEEEEGJJGGJJJJG", +"BIEEEEGJJGGGGGJG", +"BIEEEEGJJJJJJJJG", +"BIEEEEGGGGGGGGGG", +"BIEEECECECECCHAF", +"BICECECECECCCHAF", +"BHHHHHHHHHHHHHAF", +"FAAAAAAAAAAAAAAF", +"FFFFFFFFFFFFFFFF" +}; + diff --git a/kicad/buildmnu.cpp b/kicad/buildmnu.cpp new file mode 100644 index 0000000000..546718a1a4 --- /dev/null +++ b/kicad/buildmnu.cpp @@ -0,0 +1,309 @@ + /***********************************************/ + /* buildmnu.h: construction du menu principal */ + /***********************************************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" + +#include "wx/spinctrl.h" + +#include "kicad.h" +#include "macros.h" + +#define BITMAP wxBitmap + +// ---------------------------------------------------------------------------- +// resources +// ---------------------------------------------------------------------------- + +// USE_XPM_BITMAPS +#include "bitmaps.h" // Common bitmaps + +#include "zip.xpm" +#include "unzip.xpm" +#include "Browse_Files.xpm" +#include "Editor.xpm" +#include "New_Project.xpm" +#include "Open_Project.xpm" + +#include "id.h" + +/* Fonctions locales */ + +/* Variables locales */ + + +BEGIN_EVENT_TABLE(WinEDA_MainFrame, WinEDA_BasicFrame) + EVT_SIZE(WinEDA_MainFrame::OnSize) + EVT_CLOSE(WinEDA_MainFrame::OnCloseWindow) + EVT_SASH_DRAGGED(ID_LEFT_FRAME, WinEDA_MainFrame::OnSashDrag) + EVT_SASH_DRAGGED(ID_BOTTOM_FRAME, WinEDA_MainFrame::OnSashDrag) + EVT_SASH_DRAGGED(ID_MAIN_COMMAND, WinEDA_MainFrame::OnSashDrag) + + EVT_MENU_RANGE(ID_LOAD_PROJECT,ID_LOAD_FILE_10, + WinEDA_MainFrame::Process_Files) + EVT_MENU(ID_SAVE_PROJECT, WinEDA_MainFrame::Process_Files) + + EVT_TOOL(ID_NEW_PROJECT, WinEDA_MainFrame::Process_Files) + EVT_TOOL(ID_LOAD_PROJECT, WinEDA_MainFrame::Process_Files) + EVT_TOOL(ID_SAVE_PROJECT, WinEDA_MainFrame::Process_Files) + EVT_TOOL(ID_SAVE_AND_ZIP_FILES, WinEDA_MainFrame::Process_Files) + + EVT_MENU(ID_EXIT, WinEDA_MainFrame::Process_Special_Functions) + + EVT_MENU(ID_TO_EDITOR, WinEDA_MainFrame::Process_Fct) + EVT_MENU(ID_BROWSE_AN_SELECT_FILE, WinEDA_MainFrame::Process_Fct) + EVT_MENU(ID_SELECT_PREFERED_EDITOR, WinEDA_MainFrame::Process_Preferences) + EVT_MENU(ID_SELECT_DEFAULT_PDF_BROWSER, WinEDA_MainFrame::Process_Preferences) + EVT_MENU(ID_SELECT_PREFERED_PDF_BROWSER, WinEDA_MainFrame::Process_Preferences) + EVT_MENU(ID_SELECT_PREFERED_PDF_BROWSER_NAME, WinEDA_MainFrame::Process_Preferences) + EVT_MENU(ID_SAVE_AND_ZIP_FILES, WinEDA_MainFrame::Process_Files) + EVT_MENU(ID_READ_ZIP_ARCHIVE, WinEDA_MainFrame::Process_Files) + + EVT_MENU(ID_PREFERENCES_FONT_INFOSCREEN, WinEDA_MainFrame::Process_Preferences) + + EVT_MENU_RANGE(ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, + WinEDA_MainFrame::SetLanguage) + + + EVT_MENU(ID_GENERAL_HELP, WinEDA_MainFrame::GetKicadHelp) + EVT_MENU(ID_KICAD_ABOUT, WinEDA_MainFrame::GetKicadAbout) + + EVT_BUTTON(ID_TO_PCB, WinEDA_MainFrame::Process_Fct) + EVT_BUTTON(ID_TO_CVPCB, WinEDA_MainFrame::Process_Fct) + EVT_BUTTON(ID_TO_EESCHEMA, WinEDA_MainFrame::Process_Fct) + EVT_BUTTON(ID_TO_GERBVIEW, WinEDA_MainFrame::Process_Fct) + +END_EVENT_TABLE() + + +/*******************************************/ +void WinEDA_MainFrame::ReCreateMenuBar(void) +/*******************************************/ +{ +int ii, jj; +wxMenuBar * menuBar = GetMenuBar() ; + + if( menuBar == NULL ) + { + m_MenuBar = menuBar = new wxMenuBar(); + + m_FilesMenu = new wxMenu; + wxMenuItem *item = new wxMenuItem(m_FilesMenu, ID_LOAD_PROJECT, + _("&Open Project Descr"), + _("Select an existing project descriptor") ); + item->SetBitmap(open_project_xpm); + m_FilesMenu->Append(item); + + item = new wxMenuItem(m_FilesMenu, ID_NEW_PROJECT, + _("&New Project Descr"), + _("Create new project descriptor") ); + item->SetBitmap(new_project_xpm); + m_FilesMenu->Append(item); + + item = new wxMenuItem(m_FilesMenu, ID_SAVE_PROJECT, + _("&Save Project Descr"), + _("Save current project descriptor") ); + item->SetBitmap(save_project_xpm); + m_FilesMenu->Append(item); + + m_FilesMenu->AppendSeparator(); + item = new wxMenuItem(m_FilesMenu, ID_SAVE_AND_ZIP_FILES, + _("Save &Project Files"), + _("Save and Zip all project files") ); + item->SetBitmap(zip_xpm); + m_FilesMenu->Append(item); + item = new wxMenuItem(m_FilesMenu, ID_READ_ZIP_ARCHIVE, + _("&Unzip Archive"), + _("UnZip archive file") ); + item->SetBitmap(unzip_xpm); + m_FilesMenu->Append(item); + + m_FilesMenu->AppendSeparator(); + item = new wxMenuItem(m_FilesMenu, ID_EXIT, _("E&xit"), _("Quit Kicad") ); + item->SetBitmap(exit_xpm); + m_FilesMenu->Append(item); + + // Creation des selections des anciens fichiers + m_FilesMenu->AppendSeparator(); + for ( ii = 0; ii < 10; ii++ ) + { + if ( GetLastProject(ii).IsEmpty() ) break; + m_FilesMenu->Append(ID_LOAD_FILE_1 + ii, GetLastProject(ii) ); + } + + // Menu Browse + wxMenu *browseMenu = new wxMenu(); + item = new wxMenuItem(browseMenu, ID_TO_EDITOR, + _("&Editor"), _("Text editor") ); + item->SetBitmap(editor_xpm); + browseMenu->Append(item); + item = new wxMenuItem(browseMenu, ID_BROWSE_AN_SELECT_FILE, + _("&Browse Files"), _("Read or edit files") ); + item->SetBitmap(browse_files_xpm); + browseMenu->Append(item); + browseMenu->AppendSeparator(); + item = new wxMenuItem(browseMenu, ID_SELECT_PREFERED_EDITOR, + _("&Select Editor"), _("Select your prefered editor for file browsing") ); + item->SetBitmap(editor_xpm); + browseMenu->Append(item); + + // Preferences menu: + wxMenu *PreferencesMenu = new wxMenu; + item = new wxMenuItem(PreferencesMenu , ID_PREFERENCES_FONT_INFOSCREEN, + _("Select Fonts"), _("Select Fonts and Font sizes")); + item->SetBitmap(fonts_xpm); + PreferencesMenu->Append(item); + + // Submenu Pdf Browser selection: system browser or user selected browser (and its name) + wxMenu *SubMenuPdfBrowserChoice = new wxMenu; + item = new wxMenuItem(SubMenuPdfBrowserChoice , ID_SELECT_DEFAULT_PDF_BROWSER, + _("Default Pdf Viewer"), _("Use the default (system) PDF viewer used to browse datasheets"), + wxITEM_CHECK); + SETBITMAPS(datasheet_xpm); + SubMenuPdfBrowserChoice->Append(item); + SubMenuPdfBrowserChoice->Check(ID_SELECT_DEFAULT_PDF_BROWSER, + EDA_Appl->m_PdfBrowserIsDefault); + item = new wxMenuItem(SubMenuPdfBrowserChoice , ID_SELECT_PREFERED_PDF_BROWSER, + _("Favourite Pdf Viewer"), _("Use your favourite PDF viewer used to browse datasheets"), + wxITEM_CHECK); + SETBITMAPS(preference_xpm); + SubMenuPdfBrowserChoice->Append(item); + SubMenuPdfBrowserChoice->AppendSeparator(); + SubMenuPdfBrowserChoice->Check(ID_SELECT_PREFERED_PDF_BROWSER, + !EDA_Appl->m_PdfBrowserIsDefault); + item = new wxMenuItem(SubMenuPdfBrowserChoice , ID_SELECT_PREFERED_PDF_BROWSER_NAME, + _("Select Pdf Viewer"), _("Select your favourite PDF viewer used to browse datasheets")); + item->SetBitmap(datasheet_xpm); + SubMenuPdfBrowserChoice->Append(item); + ADD_MENUITEM_WITH_HELP_AND_SUBMENU(PreferencesMenu, SubMenuPdfBrowserChoice, + -1, _("Pdf Browser"), + wxT("Pdf Browser choice: default or user selection"), + datasheet_xpm); + + PreferencesMenu->AppendSeparator(); + m_Parent->SetLanguageList(PreferencesMenu); + + + // Menu Help: + wxMenu *helpMenu = new wxMenu; + item = new wxMenuItem(helpMenu , ID_GENERAL_HELP, + _("Kicad &Help"), _("On line doc")); + item->SetBitmap(help_xpm); + helpMenu->Append(item); + + item = new wxMenuItem(helpMenu , ID_KICAD_ABOUT, + _("Kicad &About"), _("Kicad Infos")); + item->SetBitmap(info_xpm); + helpMenu->Append(item); + + + menuBar->Append(m_FilesMenu, _("&Projects")); + menuBar->Append(browseMenu, _("&Browse")); + menuBar->Append(PreferencesMenu, _("&Preferences")); + menuBar->Append(helpMenu, _("&Help")); + + // Associate the menu bar with the frame + SetMenuBar(menuBar); + } + else // simple mise a jour de la liste des fichiers anciens + { + wxMenuItem * item; + int max_file = m_Parent->m_LastProjectMaxCount; + for ( ii = max_file-1; ii >=0 ; ii-- ) + { + if( m_FilesMenu->FindItem(ID_LOAD_FILE_1 + ii) ) + { + item = m_FilesMenu->Remove(ID_LOAD_FILE_1 + ii); + if ( item ) delete item; + } + } + for ( jj = 0, ii = 0; ii < max_file; ii++ ) + { + if (GetLastProject(ii).IsEmpty() ) break; + m_FilesMenu->Append(ID_LOAD_FILE_1 + jj, GetLastProject(ii) ); + jj++; + } + } +} + + +/***************************************************/ +void WinEDA_MainFrame::RecreateBaseHToolbar(void) +/***************************************************/ +{ + if ( m_HToolBar != NULL ) return; + + m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE); + SetToolBar(m_HToolBar); + + // Set up toolbar + m_HToolBar->AddTool(ID_NEW_PROJECT, BITMAP(new_project_xpm), + wxNullBitmap, FALSE, + -1, -1, (wxObject *) NULL, + _("Create new project descriptor")); + + m_HToolBar->AddTool(ID_LOAD_PROJECT, BITMAP(open_project_xpm), + wxNullBitmap, FALSE, + -1, -1, (wxObject *) NULL, + _("Select an existing project descriptor")); + + m_HToolBar->AddTool(ID_SAVE_PROJECT, BITMAP(save_project_xpm), + wxNullBitmap, FALSE, + -1, -1, (wxObject *) NULL, + _("Save current project descriptor")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_SAVE_AND_ZIP_FILES, BITMAP(zip_xpm), + wxNullBitmap, FALSE, + -1, -1, (wxObject *) NULL, + _("Archive all project files")); + + + // after adding the buttons to the toolbar, must call Realize() to reflect + // the changes + m_HToolBar->Realize(); +} + +/*************************************************/ +void WinEDA_MainFrame::CreateCommandToolbar(void) +/*************************************************/ +{ +#define SEPAR 20 +int sizex, sizey,width; +wxBitmapButton * Butt; +wxPoint pos; + + // delete and recreate the toolbar + if( m_VToolBar ) return; + + m_CommandWin->GetClientSize(&sizex, &sizey); + width = 300; + + // Set up toolbar + width = 32; + pos.x = 20; pos.y = 20; + + Butt = new wxBitmapButton(m_CommandWin, ID_TO_EESCHEMA, + BITMAP(icon_eeschema_xpm), pos ); + Butt->SetToolTip(_("EeSchema (Schematic editor)")); + + pos.x += width + SEPAR; + Butt = new wxBitmapButton(m_CommandWin,ID_TO_CVPCB, + BITMAP(icon_cvpcb_xpm), pos ); + Butt->SetToolTip(_("Cvpcb (Componants to modules)")); + + pos.x += width + SEPAR; + Butt = new wxBitmapButton(m_CommandWin, ID_TO_PCB, + BITMAP(a_icon_pcbnew_xpm), pos ); + Butt->SetToolTip(_("Pcbnew ( board editor )")); + + pos.x += width + SEPAR; + Butt = new wxBitmapButton(m_CommandWin, ID_TO_GERBVIEW, + BITMAP(icon_gerbview_xpm), pos ); + Butt->SetToolTip(_("GerbView ( Gerber viewer )")); + +} + + diff --git a/kicad/files-io.cpp b/kicad/files-io.cpp new file mode 100644 index 0000000000..40d363bc55 --- /dev/null +++ b/kicad/files-io.cpp @@ -0,0 +1,282 @@ + /****************/ + /* files-io.cpp */ + /****************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" +#include +#include +#include +#include + +#include "common.h" + +#include "bitmaps.h" +#include "protos.h" + +#include "id.h" + +#include "kicad.h" +#include "prjconfig.h" + +#define ZIP_EXT wxT(".zip") +#define ZIP_MASK wxT("*.zip") + +static void Create_NewPrj_Config( const wxString PrjFullFileName); + +/***********************************************************/ +void WinEDA_MainFrame::Process_Files(wxCommandEvent& event) +/***********************************************************/ +/* Gestion generale des commandes de sauvegarde +*/ +{ +int id = event.GetId(); +wxString path = wxGetCwd(); +wxString fullfilename; +bool IsNew = FALSE; + + switch (id) + { + case ID_SAVE_PROJECT: /* Update project File */ + Save_Prj_Config(); + break; + + case ID_LOAD_FILE_1: + case ID_LOAD_FILE_2: + case ID_LOAD_FILE_3: + case ID_LOAD_FILE_4: + case ID_LOAD_FILE_5: + case ID_LOAD_FILE_6: + case ID_LOAD_FILE_7: + case ID_LOAD_FILE_8: + case ID_LOAD_FILE_9: + case ID_LOAD_FILE_10: + m_PrjFileName = GetLastProject( id - ID_LOAD_FILE_1); + SetLastProject(m_PrjFileName); + ReCreateMenuBar(); + Load_Prj_Config(); + break; + + case ID_NEW_PROJECT: + IsNew = TRUE; + case ID_LOAD_PROJECT: + SetLastProject(m_PrjFileName); + fullfilename = EDA_FileSelector( IsNew ? _("Create Project files:") : _("Load Project files:"), + path, /* Chemin par defaut */ + wxEmptyString, /* nom fichier par defaut */ + g_Prj_Config_Filename_ext, /* extension par defaut */ + wxT("*") + g_Prj_Config_Filename_ext, /* Masque d'affichage */ + this, + IsNew ? wxFD_SAVE : wxFD_OPEN, + FALSE + ); + if ( fullfilename.IsEmpty() ) break; + + ChangeFileNameExt(fullfilename, g_Prj_Config_Filename_ext); + m_PrjFileName = fullfilename; + if ( IsNew ) Create_NewPrj_Config( m_PrjFileName); + SetLastProject(m_PrjFileName); + Load_Prj_Config(); + break; + + + case ID_SAVE_AND_ZIP_FILES: + CreateZipArchive(wxEmptyString); + break; + + case ID_READ_ZIP_ARCHIVE: + UnZipArchive(wxEmptyString); + break; + + default: DisplayError(this, wxT("WinEDA_MainFrame::Process_Files error")); + break; + } +} + + +/**************************************************************/ +static void Create_NewPrj_Config(const wxString PrjFullFileName) +/**************************************************************/ +/* Cree un nouveau fichier projet a partir du modele +*/ +{ +wxString msg; + // Init default config filename + g_Prj_Config_LocalFilename.Empty(); + g_Prj_Default_Config_FullFilename = + ReturnKicadDatasPath() + + wxT("template/kicad") + + g_Prj_Config_Filename_ext; + + if ( ! wxFileExists(g_Prj_Default_Config_FullFilename) ) + { + msg = _("Template file non found ") + g_Prj_Default_Config_FullFilename; + DisplayInfo(NULL, msg); + } + + else + { + if ( wxFileExists(PrjFullFileName) ) + { + msg = _("File ") + PrjFullFileName + + _(" exists! OK to continue?"); + if ( IsOK(NULL, msg) ) + { + wxCopyFile(g_Prj_Default_Config_FullFilename, + PrjFullFileName); + } + } + } + + g_SchematicRootFileName = wxFileNameFromPath(PrjFullFileName); + ChangeFileNameExt(g_SchematicRootFileName, g_SchExtBuffer); + g_BoardFileName = wxFileNameFromPath(PrjFullFileName); + ChangeFileNameExt(g_BoardFileName, g_BoardExtBuffer); + + EDA_Appl->WriteProjectConfig(PrjFullFileName, wxT("/general"), CfgParamList); +} + + +/**********************************************************************/ +void WinEDA_MainFrame::UnZipArchive(const wxString FullFileName) +/**********************************************************************/ +/* Lit un fichier archive .zip et le decompresse dans le repertoire courant +*/ +{ +wxString filename = FullFileName; +wxString msg; +wxString old_cwd = wxGetCwd(); + + if ( filename.IsEmpty() ) + filename = EDA_FileSelector( _("Unzip Project:"), + wxEmptyString, /* Chemin par defaut */ + wxEmptyString, /* nom fichier par defaut */ + ZIP_EXT, /* extension par defaut */ + ZIP_MASK, /* Masque d'affichage */ + this, + wxFD_OPEN, + TRUE + ); + if ( filename.IsEmpty() ) return; + + msg = _("\nOpen ") + filename + wxT("\n"); + PrintMsg( msg ); + +wxString target_dirname = wxDirSelector ( _("Target Directory"), + wxEmptyString, 0, wxDefaultPosition, this); + if ( target_dirname.IsEmpty() ) return; + + wxSetWorkingDirectory(target_dirname); + msg = _("Unzip in ") + target_dirname + wxT("\n"); + PrintMsg( msg ); + +wxFileSystem zipfilesys; + zipfilesys.AddHandler(new wxZipFSHandler); + filename += wxT("#zip:"); + zipfilesys.ChangePathTo(filename); + +wxFSFile * zipfile = NULL; +wxString localfilename = zipfilesys.FindFirst( wxT("*.*") ); + + while ( !localfilename.IsEmpty() ) + { + zipfile = zipfilesys.OpenFile(localfilename); + if (zipfile == NULL) + { + DisplayError(this, wxT("Zip file read error")); + break; + } + wxString unzipfilename = localfilename.AfterLast(':'); + msg = _("Extract file ") + unzipfilename; + PrintMsg(msg); + wxInputStream * stream = zipfile->GetStream(); + wxFFileOutputStream * ofile = new wxFFileOutputStream(unzipfilename); + if ( ofile->Ok() ) + { + ofile->Write(*stream); + PrintMsg( _(" OK\n") ); + } + else PrintMsg( _(" *ERROR*\n") ); + + delete ofile; + delete zipfile; + localfilename = zipfilesys.FindNext(); + } + PrintMsg( wxT("** end **\n") ); + + wxSetWorkingDirectory(old_cwd); +} + +/********************************************************************/ +void WinEDA_MainFrame::CreateZipArchive(const wxString FullFileName) +/********************************************************************/ +{ +wxString filename = FullFileName; +wxString zip_file_fullname; +wxString msg; +wxString curr_path = wxGetCwd(); + + if ( filename.IsEmpty() ) + { + filename = m_PrjFileName; + ChangeFileNameExt(filename, wxT(".zip")); + filename = EDA_FileSelector( _("Archive Project files:"), + wxEmptyString, /* Chemin par defaut */ + filename, /* nom fichier par defaut */ + ZIP_EXT, /* extension par defaut */ + ZIP_MASK, /* Masque d'affichage */ + this, + wxFD_SAVE, + FALSE + ); + } + if ( filename.IsEmpty() ) return; + + +wxFileName zip_name(filename); + zip_file_fullname = zip_name.GetFullName(); + AddDelimiterString( zip_file_fullname ); + +wxChar * Ext_to_arch[] = { /* Liste des extensions des fichiers à sauver */ + wxT("*.sch"), wxT("*.lib"), wxT("*.cmp"), wxT("*.brd"), + wxT("*.net"), wxT("*.pro"), wxT("*.pho"), + NULL}; +int ii = 0; +wxString zip_cmd = wxT("-O ") + zip_file_fullname; + filename = wxFindFirstFile(Ext_to_arch[ii]); + while ( !filename.IsEmpty() ) + { + wxFileName name(filename); + wxString fullname = name.GetFullName(); + AddDelimiterString( fullname ); + zip_cmd += wxT(" ") + fullname; + msg = _("Compress file ") + fullname + wxT("\n"); + PrintMsg(msg); + + filename = wxFindNextFile(); + while (filename.IsEmpty() ) + { + ii++; + if (Ext_to_arch[ii]) filename = wxFindFirstFile(Ext_to_arch[ii]); + else break; + } + } + +#ifdef __WINDOWS__ +#define ZIPPER wxT("minizip.exe") +#else +#define ZIPPER wxT("minizip") +#endif + if ( ExecuteFile(this, ZIPPER, zip_cmd) >= 0 ) + { + msg = _("\nCreate Zip Archive ") + zip_file_fullname; + PrintMsg( msg ); + PrintMsg( wxT("\n** end **\n") ); + } + else PrintMsg( wxT("Minizip command error, abort\n") ); + + wxSetWorkingDirectory(curr_path); +} diff --git a/kicad/kicad.cpp b/kicad/kicad.cpp new file mode 100644 index 0000000000..f9d21667e9 --- /dev/null +++ b/kicad/kicad.cpp @@ -0,0 +1,92 @@ + /********************************/ + /* kicad.cpp - module principal */ + /********************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#define MAIN +#define eda_global + +#include "fctsys.h" + +#include + +//#define SPLASH_OK + +#ifdef SPLASH_OK +#include +#endif + +#include "wxstruct.h" +#include "common.h" +#include "bitmaps.h" +#include "kicad.h" +#include "macros.h" + +/* Routines exportees */ + +/* fonctions importees */ +char *GetFileName(char *FullPathName); +void ShowLogo(char * FonteFileName); + +/* Routines locales */ + + /************************************/ + /* Called to initialize the program */ + /************************************/ + +// Create a new application object +IMPLEMENT_APP(WinEDA_App) + +bool WinEDA_App::OnInit(void) +{ + EDA_Appl = this; + InitEDA_Appl( wxT("kicad")); + + /* init kicad */ + GetSettings(); // read current setup + + m_MainFrame = new WinEDA_MainFrame(this, NULL, wxT("KiCad"), + wxPoint(0,0), wxSize(600,400) ); + if(argc > 1 ) m_MainFrame->m_PrjFileName = argv[1]; + else if ( m_EDA_Config ) + { + m_MainFrame->m_PrjFileName = m_EDA_Config->Read(wxT("LastProject"), + wxT("noname.pro") ); + } + else m_MainFrame->m_PrjFileName = wxT("noname.pro"); + + wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); + Title += wxT(" ") + m_MainFrame->m_PrjFileName; + m_MainFrame->SetTitle(Title); + m_MainFrame->ReCreateMenuBar(); + m_MainFrame->RecreateBaseHToolbar(); + + m_MainFrame->m_LeftWin->ReCreateTreePrj(); + SetTopWindow(m_MainFrame); + m_MainFrame->Show(TRUE); + + /* Preparation Affichage du logo */ +#ifdef SPLASH_OK +wxString logoname( wxString(m_BinDir) + wxT("logokicad.png") ); +wxBitmap image; + if ( image.LoadFile( logoname, wxBITMAP_TYPE_PNG ) ) + { + wxSplashScreen * logoscreen = new wxSplashScreen( image, + wxSPLASH_CENTRE_ON_PARENT | wxSPLASH_TIMEOUT, + 500, m_MainFrame, -1, + wxDefaultPosition, wxDefaultSize, + wxSIMPLE_BORDER | wxSTAY_ON_TOP); + } +#endif + + if ( wxFileExists(m_MainFrame->m_PrjFileName) ) + { + m_MainFrame->Load_Prj_Config(); + } + + return TRUE; +} + diff --git a/kicad/kicad.h b/kicad/kicad.h new file mode 100644 index 0000000000..01078eed73 --- /dev/null +++ b/kicad/kicad.h @@ -0,0 +1,117 @@ + /***********/ + /* kicad.h */ + /***********/ + +#ifndef KICAD_H +#define KICAD_H + +#include + +/* Message de presentation */ +eda_global wxString g_Main_Title +#ifdef MAIN + = wxT("KiCad") +#endif +; + +#define WinEDA_CommandFrame wxSashLayoutWindow + +class WinEDA_TreePrj; +class WinEDA_PrjFrame; + + /*******************************************/ + /* classe pour la Fenetre generale de kicad*/ + /*******************************************/ + +class WinEDA_MainFrame: public WinEDA_BasicFrame +{ +public: + + WinEDA_CommandFrame * m_CommandWin; + WinEDA_PrjFrame * m_LeftWin; + wxSashLayoutWindow * m_BottomWin; + wxTextCtrl * m_DialogWin; + WinEDA_Toolbar * m_VToolBar; // Toolbar Vertical bord d'ecran + wxString m_PrjFileName; + int m_LeftWin_Width; + int m_CommandWin_Height; + +private: + wxMenu * m_FilesMenu; + +public: + // Constructor and destructor + WinEDA_MainFrame(WinEDA_App * eda_app, wxWindow *parent, const wxString & title, + const wxPoint& pos, const wxSize& size); + + ~WinEDA_MainFrame(void); + + void OnCloseWindow(wxCloseEvent & Event); + void OnSize(wxSizeEvent& event); + void OnPaint(wxPaintEvent & event); + void ReDraw(wxDC * DC); + void OnSashDrag(wxSashEvent& event); + void Load_Prj_Config(void); + void Save_Prj_Config(void); + void Process_Fct(wxCommandEvent& event); + void Process_Files(wxCommandEvent& event); + void Process_Config(wxCommandEvent& event); + void Process_Special_Functions(wxCommandEvent& event); + void Process_Preferences(wxCommandEvent& event); + void ReCreateMenuBar(void); + void RecreateBaseHToolbar(void); + void CreateCommandToolbar(void); + void PrintMsg(const wxString & text); + void SetLanguage(wxCommandEvent& event); + + void CreateZipArchive(const wxString FullFileName); + void UnZipArchive(const wxString FullFileName); + + DECLARE_EVENT_TABLE() +}; + +/* Fenetre d'affichage des fichiers du projet */ +class WinEDA_PrjFrame : public wxSashLayoutWindow +{ +public: + WinEDA_MainFrame * m_Parent; + WinEDA_TreePrj * m_TreeProject; + +public: + WinEDA_PrjFrame(WinEDA_MainFrame * parent, + const wxPoint & pos, const wxSize & size ); + ~WinEDA_PrjFrame(void) {} + void OnSelect(wxTreeEvent & Event); + void ReCreateTreePrj(void); + DECLARE_EVENT_TABLE() +}; + + +/** Classe TreeCtrl des fichiers projets **/ +class WinEDA_TreePrj : public wxTreeCtrl +{ +private: + WinEDA_PrjFrame * m_Parent; + wxImageList * m_ImageList; + +public: + WinEDA_TreePrj(WinEDA_PrjFrame *parent); + ~WinEDA_TreePrj(); +}; + +eda_global wxString g_SchematicRootFileName; +eda_global wxString g_BoardFileName; + +#ifdef MAIN +wxString g_SchExtBuffer(wxT(".sch")); +wxString g_BoardExtBuffer(wxT(".brd")); +wxString g_NetlistExtBuffer(wxT(".net")); +wxString g_GerberExtBuffer(wxT(".pho")); +#else +eda_global wxString g_SchExtBuffer; +eda_global wxString g_BoardExtBuffer; +eda_global wxString g_NetlistExtBuffer; +eda_global wxString g_GerberExtBuffer; +#endif + +#endif diff --git a/kicad/kicad.ico b/kicad/kicad.ico new file mode 100644 index 0000000000000000000000000000000000000000..79f577f7d5c1dad13e4ae9b34bb178230b214364 GIT binary patch literal 3262 zcmcJRdr(tX9>?#_?2PQp&bUK6?fzry+U;~Z?rwb*OIsdN1p^9Lh)RG&lve~3^B^G! zg+vk(h$g`V5*{Hz9w87Cl0wkP!zKurNMnjG3Mx=&k!hjYE}&HIo*2xAEQM&t zVM!lFrd=PN7?^-9_uvad@CEY#c#tistg^wJE|_rv7PQ=oj*bou4aG@&!sKv(4E8UD zckIQy41X&!cU$34D6+8S^4(X&|3C!qlsrK(n~Ibdz5Cz!WR?DxF8;3mJNYGWP#KI8 zSV`O}W4G0npX$Dc9sRc}j5j>aTgK&b zs~hyqy^}xB!ClrNLCZ}7fq=zg@ls1|`@jzm;JBim!02NE0Ret~ew#LJTJ=RZ91akV z&z5=eqtC&IYaiv7=+%acg7Z_USX@byg{K>F5r}d-McP@{*8d52M4|6-1tTINR`B2W zz-MR1Ye9s-BwiH0#P1-(i+`vd#x%lTDEl!~F_AmEu1F0M9Zd!CT0V^(P)%cRyz4lzt0!(U*GKW zPKfV65uYEUrcwDpiA*nk2_OkOMskX@~m$^v|OadDeoFXeDjK1cfd2WDjAOp0;HLqB0o#JRad zb_@nXB9Vsg+->c+++yt9w{M>(*6jnnn8&M1OYKE&{PFi_##IpJj21$z&h| z#=^tnpU)W3YV^9vYh-pLu-$!QzAYC-)|&J^5Kt zQEu!Yli8ie9AvTX8QUGo+DoJ#=YsG z@gMJgKRY@;>E@fw=G^`JUHo1yPs7O3Q7AJ_O^Z+4uX=;6OwqAYMUN+H>r~w)6P-ko z)ieXXWAe8ul^(26V9U$P%g@hu^Lu-HsR#t%n>YpBqsh|b6czS(JDD=0taeF&{Vy&0 zYt^c*oLtYbsIn*`3N;g(X|fEooWBH?HaFAL0q^(to;_dZ=Z|%C8j4PHld&b(6Sc(b zZzM7|e|ap;TC1qUL?pRYWN3_Dt98*{@c%jz9)7=}!3k+@o@;CSv9akt{a1kR#a~vb zS2-k-i{vbzLWqi{dTYA&x%0E{d+Xl% z=r8XEC1lXDSfbC4EYHt@vZat@DJC+pol5s&x=t-jCORValjHTEet6ORycN5SI=?<= z{!Qlm+wA$xF{ixd=e=1ihoh2|*o?;tg^O&?WzsPiOAJ?rAWVKos z78X#HQcpfu-$`tl-G0sHxLtc`e0=Ibw{56Ud&_RO+ibRzFo#|!!i1@iM>*>E@Next~~ zQX2Yq@kh6Z#c$ZK!PnQ<$H!*{cjXDF-<*8$Z}EBRLWRk@zUp|qN_{1s`(5?b_QL6S zlEBbA`YP(fZK0T*`;%|n`TiBvw;TWV4uiqCeP{gU-6{Lf#Fgt~^;#oHA??%|P3JXb ztF=^fnO~ucjEn^Jb9#;>>68jdtKN$%-}0RLe8C6G^R`h4T0aGC!9!0C0!Iix_0;}2 f3yyZ@bzqQ}Ib--|HU)fe%d%~8#+}#Kdu#m{PMk2u literal 0 HcmV?d00001 diff --git a/kicad/kicad.r b/kicad/kicad.r new file mode 100644 index 0000000000..79cbe6622c --- /dev/null +++ b/kicad/kicad.r @@ -0,0 +1,7 @@ +data 'vers' (2) { +$"0100 2000 0000 0531 2E30 6430 0531 2E30" +$"6430"} ; + +data 'vers' (1) { +$"0100 2000 0000 0531 2E30 6430 0531 2E30" +$"6430"} ; diff --git a/kicad/kicad.rc b/kicad/kicad.rc new file mode 100644 index 0000000000..a230c258c6 --- /dev/null +++ b/kicad/kicad.rc @@ -0,0 +1,2 @@ +a_kicad_icon ICON kicad.ico +#include "wx/msw/wx.rc" diff --git a/kicad/mainframe.rc b/kicad/mainframe.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/kicad/mainframe.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/kicad/makefile.g95 b/kicad/makefile.g95 new file mode 100644 index 0000000000..670c440468 --- /dev/null +++ b/kicad/makefile.g95 @@ -0,0 +1,34 @@ +WXDIR = $(WXWIN) +EXTRALIBS = ../common/common.a +EXTRACPPFLAGS= -DKICAD -I./ -I../include -I../kicad -I../common +TARGET=kicad + +include ../libs.win + +all: $(TARGET).exe + +include makefile.include + + +$(TARGET).exe: $(OBJECTS) $(TARGET)_resources.o $(EDALIBS) + $(CXX) $(ALL_LDFLAGS)\ + -o $(TARGET).exe $(OBJECTS)\ + $(TARGET)_resources.o $(EDALIBS) $(SYSWXLIB) + +install: + cp -f $(TARGET).exe $(KICAD_BIN) + + +$(TARGET)_resources.o: $(TARGET).rc + $(RESCOMP) $(RCINPUTSWITCH) $(TARGET).rc $(RCOUTPUTSWITCH) $(TARGET)_resources.o $(RESFLAGS) + + +$(TARGET).o: $(TARGET).cpp $(DEPEND) $(TARGET).h + +clean : + -$(RM) *.o + -$(RM) *.exe + -$(RM) *.rsc + -$(RM) *.res + -$(RM) *.bak + diff --git a/kicad/makefile.gtk b/kicad/makefile.gtk new file mode 100644 index 0000000000..436a1632bc --- /dev/null +++ b/kicad/makefile.gtk @@ -0,0 +1,43 @@ +# File: makefile for kicad, wxGTK + +# Compiler flags. +CC = gcc +LD = gcc + +FINAL = 1 + +# Compiler flags. +CPPFLAGS = -Wall -O2 `wx-config --cxxflags` +LDFLAGS = -s + +include ../libs.linux + +TARGET = kicad + +all: $(TARGET) + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + + +$(TARGET): $(OBJECTS) makefile.gtk $(EXTRALIBS) ../libs.linux + $(LD) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $(TARGET) + +install: + cp -f $(TARGET) $(KICAD_BIN) + +clean: + rm -f *.o; + rm -f *~; + rm -f core; + rm -f *.bak + rm -f $(TARGET) + + + + + + + diff --git a/kicad/makefile.include b/kicad/makefile.include new file mode 100644 index 0000000000..1d0f9eefd4 --- /dev/null +++ b/kicad/makefile.include @@ -0,0 +1,29 @@ +EXTRALIBS = ../common/common.a +EXTRACPPFLAGS= -DKICAD -I./ -Ibitmaps -I../include -I../kicad -I../share + +DEPEND = + +OBJECTS = kicad.o\ + treeprj.o\ + buildmnu.o\ + infospgm.o\ + mdiframe.o\ + prjconfig.o\ + preferences.o\ + files-io.o + + +$(TARGET).o: $(TARGET).cpp $(DEPEND) $(TARGET).h + +treeprj.o: treeprj.cpp $(DEPEND) kicad.h + +prjconfig.o: prjconfig.cpp $(DEPEND) prjconfig.h + +files-io.o: files-io.cpp $(DEPEND) kicad.h + +mdiframe.o: mdiframe.cpp $(DEPEND) kicad.h + +buildmnu.o: buildmnu.cpp $(DEPEND) kicad.h + +infospgm.o: ../share/infospgm.cpp $(DEPEND) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp diff --git a/kicad/makefile.macosx b/kicad/makefile.macosx new file mode 100644 index 0000000000..7a6b33b2c8 --- /dev/null +++ b/kicad/makefile.macosx @@ -0,0 +1,45 @@ +# File: makefile for kicad, wxGTK + +# Compiler flags. +CC = gcc +LD = g++ + +FINAL = 1 + +# Compiler flags. +CPPFLAGS = -Wall -O2 `wx-config --cxxflags` +LDFLAGS = + +include ../libs.macosx + +TARGET = kicad + +all: $(TARGET) + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + + +$(TARGET): $(OBJECTS) $(TARGET).r makefile.macosx $(EXTRALIBS) ../libs.macosx + $(LD) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $(TARGET) + $(RESCOMP) -o $(TARGET) Carbon.r $(TARGET).r + $(SETFILE) -a C $(TARGET) + +install: + cp -f $(TARGET) $(KICAD_BIN) + +clean: + rm -f *.o; + rm -f *~; + rm -f core; + rm -f *.bak + rm -f $(TARGET) + + + + + + + diff --git a/kicad/mdiframe.cpp b/kicad/mdiframe.cpp new file mode 100644 index 0000000000..fe5789ef04 --- /dev/null +++ b/kicad/mdiframe.cpp @@ -0,0 +1,352 @@ + /******************************************************************/ + /* mdiframe.cpp - fonctions de la classe du type WinEDA_MainFrame */ + /******************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" + +#include "common.h" + +#include "bitmaps.h" +#include "protos.h" + +#include "id.h" + +#include "kicad.h" + + + /****************/ + /* Constructeur */ + /****************/ + +WinEDA_MainFrame::WinEDA_MainFrame(WinEDA_App * eda_app, + wxWindow *parent, const wxString & title, + const wxPoint& pos, const wxSize& size): + WinEDA_BasicFrame(parent, KICAD_MAIN_FRAME, eda_app, title, pos, size ) +{ +wxString msg; +wxSize clientsize; + + m_FrameName = wxT("KicadFrame"); + m_VToolBar = NULL; + m_LeftWin = NULL; + m_BottomWin = NULL; + m_CommandWin = NULL; + m_LeftWin_Width = 200; + m_CommandWin_Height = 82; + + GetSettings(); + if( m_Parent->m_EDA_Config ) + { + m_Parent->m_EDA_Config->Read(wxT("LeftWinWidth"), &m_LeftWin_Width); + m_Parent->m_EDA_Config->Read(wxT("CommandWinWidth"), &m_CommandWin_Height); + } + + SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y); + + // ajuste la ligne de status +int dims[3] = { -1, -1, 100}; + CreateStatusBar(3); + SetStatusWidths(3,dims); + + // Give an icon + #ifdef __WINDOWS__ + SetIcon(wxICON(a_kicad_icon)); + #else + SetIcon(wxICON(kicad_icon)); + #endif + + clientsize = GetClientSize(); + + // Left window: is the box which display tree project + m_LeftWin = new WinEDA_PrjFrame(this, wxDefaultPosition, wxDefaultSize); + m_LeftWin->SetDefaultSize(wxSize(m_LeftWin_Width, clientsize.y)); + m_LeftWin->SetOrientation(wxLAYOUT_VERTICAL); + m_LeftWin->SetAlignment(wxLAYOUT_LEFT); + m_LeftWin->SetSashVisible(wxSASH_RIGHT, TRUE); + m_LeftWin->SetExtraBorderSize(2); + + // Bottom Window: box to display messages + m_BottomWin = new wxSashLayoutWindow(this, ID_BOTTOM_FRAME, + wxDefaultPosition, wxDefaultSize, + wxNO_BORDER|wxSW_3D); + m_BottomWin->SetDefaultSize(wxSize(clientsize.x, 150)); + m_BottomWin->SetOrientation(wxLAYOUT_HORIZONTAL); + m_BottomWin->SetAlignment(wxLAYOUT_BOTTOM); + m_BottomWin->SetSashVisible(wxSASH_TOP, TRUE); + m_BottomWin->SetSashVisible(wxSASH_LEFT, TRUE); + m_BottomWin->SetExtraBorderSize(2); + + m_DialogWin = new wxTextCtrl(m_BottomWin, ID_MAIN_DIALOG, wxEmptyString, + wxDefaultPosition, wxDefaultSize, + wxTE_MULTILINE| + wxNO_BORDER| + wxTE_READONLY); + m_DialogWin->SetFont(* g_StdFont); + + // m_CommandWin is the box with buttons which launch eechema, pcbnew ... + m_CommandWin = new WinEDA_CommandFrame(this, ID_MAIN_COMMAND, + wxPoint(m_LeftWin_Width, 0), wxSize(clientsize.x, m_CommandWin_Height), + wxNO_BORDER|wxSW_3D); + m_CommandWin->SetDefaultSize(wxSize(clientsize.x, 100)); + m_CommandWin->SetOrientation(wxLAYOUT_HORIZONTAL); + m_CommandWin->SetAlignment(wxLAYOUT_TOP); + m_CommandWin->SetSashVisible(wxSASH_BOTTOM, TRUE); + m_CommandWin->SetSashVisible(wxSASH_LEFT, TRUE); + m_CommandWin->SetExtraBorderSize(2); + m_CommandWin->SetFont(* g_StdFont); + + CreateCommandToolbar(); + +wxString line; + msg = wxGetCwd(); + line.Printf( _("Ready\nWorking dir: %s\n"), msg.GetData()); + PrintMsg(line); +} + + /***************/ + /* Destructeur */ + /***************/ + +WinEDA_MainFrame::~WinEDA_MainFrame(void) +{ + if( m_Parent->m_EDA_Config ) + { + m_LeftWin_Width = m_LeftWin->GetSize().x; + m_CommandWin_Height = m_CommandWin->GetSize().y; + m_Parent->m_EDA_Config->Write(wxT("LeftWinWidth"), m_LeftWin_Width); + m_Parent->m_EDA_Config->Write(wxT("CommandWinWidth"), m_CommandWin_Height); + } +} + + +/*******************************************************/ +void WinEDA_MainFrame::PrintMsg(const wxString & text) +/*******************************************************/ +/* +imprime le message dans la fenetre des messages +*/ +{ + m_DialogWin->SetFont(* g_StdFont); + m_DialogWin->AppendText(text); +} + +/****************************************************/ +void WinEDA_MainFrame::OnSashDrag(wxSashEvent& event) +/****************************************************/ +/* Resize windows when dragging window borders +*/ +{ +int w, h; +wxSize newsize; + + if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE) + return; + + GetClientSize(&w, &h); + + switch (event.GetId()) + { + case ID_LEFT_FRAME: + { + m_LeftWin->SetDefaultSize(wxSize(event.GetDragRect().width, -1)); + break; + } + + case ID_BOTTOM_FRAME: + { + newsize = event.GetDragRect().GetSize(); + m_LeftWin->SetDefaultSize(wxSize(w-newsize.x, -1)); + m_BottomWin->SetDefaultSize(wxSize(-1, newsize.y)); + m_CommandWin->SetDefaultSize(wxSize(-1, h - newsize.y)); + break; + } + + case ID_MAIN_COMMAND: + { + newsize = event.GetDragRect().GetSize(); + m_LeftWin->SetDefaultSize(wxSize(w-newsize.x, -1)); + m_CommandWin->SetDefaultSize(wxSize(-1, newsize.y)); + m_BottomWin->SetDefaultSize(wxSize(-1, h - newsize.y)); + break; + } + } + wxLayoutAlgorithm layout; + layout.LayoutFrame(this); +} + +/************************************************/ +void WinEDA_MainFrame::OnSize(wxSizeEvent& event) +/************************************************/ +{ + if (m_CommandWin && m_BottomWin) + { + int w, h, dy; + wxSize bsize, hsize; + GetClientSize(&w, &h); + bsize = m_BottomWin->GetSize(); + hsize = m_CommandWin->GetSize(); + dy = h - hsize.y; + if ( dy < 50 ) + { + dy = 50; + hsize.y = h - dy; + } + m_CommandWin->SetDefaultSize(wxSize(-1, hsize.y)); + m_BottomWin->SetDefaultSize(wxSize(-1, dy)); + }; + + wxLayoutAlgorithm layout; + layout.LayoutFrame(this); + if ( m_CommandWin ) m_CommandWin->Refresh(TRUE); +} + + +/**********************************************************/ +void WinEDA_MainFrame::OnCloseWindow(wxCloseEvent & Event) +/**********************************************************/ +{ +int px, py; + + SetLastProject(m_PrjFileName); + + if ( ! IsIconized() ) + { + /* Memorisation position sur l'ecran */ + GetPosition(&px, &py); + m_FramePos.x = px; + m_FramePos.y = py; + + /* Memorisation dimension de la fenetre */ + GetSize(&px, &py); + m_FrameSize.x = px; + m_FrameSize.y = py; + } + + Event.SetCanVeto(TRUE); + + SaveSettings(); + + // Close the help frame + if ( m_Parent->m_HtmlCtrl ) + { + if ( m_Parent->m_HtmlCtrl->GetFrame() ) // returns NULL if no help frame active + m_Parent->m_HtmlCtrl->GetFrame()->Close(TRUE); + m_Parent->m_HtmlCtrl = NULL; + } + + Destroy(); +} + + +/**********************************************************/ +void WinEDA_MainFrame::OnPaint(wxPaintEvent & event) +/**********************************************************/ +{ + event.Skip(); +} + +/*******************************************/ +void WinEDA_MainFrame::ReDraw(wxDC * DC) +/*******************************************/ +{ +} + + + +/**********************************************************************/ +void WinEDA_MainFrame::Process_Special_Functions(wxCommandEvent& event) +/**********************************************************************/ +{ +int id = event.GetId(); + + switch ( id ) + { + case ID_EXIT : + Close(TRUE); + break; + + default: + DisplayError(this, wxT("WinEDA_MainFrame::Process_Special_Functions error")); + break; + } +} + + +/********************************************************/ +void WinEDA_MainFrame::Process_Fct(wxCommandEvent& event) +/*********************************************************/ +{ +int id = event.GetId(); +wxString FullFileName = m_PrjFileName; + + + switch (id) + { + case ID_TO_PCB: + ChangeFileNameExt(FullFileName, g_BoardExtBuffer); + AddDelimiterString(FullFileName); + ExecuteFile(this, PCBNEW_EXE, FullFileName); + break; + + case ID_TO_CVPCB: + ChangeFileNameExt(FullFileName, g_NetlistExtBuffer); + AddDelimiterString(FullFileName); + ExecuteFile(this, CVPCB_EXE, FullFileName); + break; + + case ID_TO_EESCHEMA: + ChangeFileNameExt(FullFileName, g_SchExtBuffer); + AddDelimiterString(FullFileName); + ExecuteFile(this, EESCHEMA_EXE, FullFileName); + break; + + case ID_TO_GERBVIEW: + FullFileName = wxGetCwd() + STRING_DIR_SEP; + AddDelimiterString(FullFileName); + ExecuteFile(this, GERBVIEW_EXE, FullFileName); + break; + + case ID_TO_EDITOR: + { + wxString editorname = GetEditorName(); + if ( !editorname.IsEmpty() ) + ExecuteFile(this, editorname, wxEmptyString); + } + break; + + case ID_BROWSE_AN_SELECT_FILE: + { + wxString mask(wxT("*")), extension; +#ifdef __WINDOWS__ + mask += wxT(".*"); + extension = wxT(".*"); +#endif + FullFileName = EDA_FileSelector( _("Load file:"), + wxGetCwd(), /* Default path */ + wxEmptyString, /* default filename */ + extension, /* default ext. */ + mask, /* mask for filename filter */ + this, + wxFD_OPEN, + TRUE + ); + if ( ! FullFileName.IsEmpty() ) + { + AddDelimiterString(FullFileName); + wxString editorname = GetEditorName(); + if ( ! editorname.IsEmpty() ) + ExecuteFile(this, editorname, FullFileName); + } + } + break; + + break; + default: DisplayError(this, wxT("WinEDA_MainFrame::Process_Fct Internal Error")); + break; + } +} + diff --git a/kicad/minizip/crypt.h b/kicad/minizip/crypt.h new file mode 100644 index 0000000000..8c956795ea --- /dev/null +++ b/kicad/minizip/crypt.h @@ -0,0 +1,132 @@ +/* crypt.h -- base code for crypt/uncrypt ZIPfile + + + Version 1.00, September 10th, 2003 + + Copyright (C) 1998-2003 Gilles Vollant + + This code is a modified version of crypting code in Infozip distribution + + The encryption/decryption parts of this source code (as opposed to the + non-echoing password parts) were originally written in Europe. The + whole source package can be freely distributed, including from the USA. + (Prior to January 2000, re-export from the US was a violation of US law.) + + This encryption code is a direct transcription of the algorithm from + Roger Schlafly, described by Phil Katz in the file appnote.txt. This + file (appnote.txt) is distributed with the PKZIP program (even in the + version without encryption capabilities). + + If you don't need crypting in your application, just define symbols + NOCRYPT and NOUNCRYPT. + + This code support the "Traditional PKWARE Encryption". + + The new AES encryption added on Zip format by Winzip (see the page + http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong + Encryption is not supported. +*/ + +#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) + +/*********************************************************************** + * Return the next byte in the pseudo-random sequence + */ +static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) +{ + unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an + * unpredictable manner on 16-bit systems; not a problem + * with any known compiler so far, though */ + + temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; + return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); +} + +/*********************************************************************** + * Update the encryption keys with the next byte of plain text + */ +static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) +{ + (*(pkeys+0)) = CRC32((*(pkeys+0)), c); + (*(pkeys+1)) += (*(pkeys+0)) & 0xff; + (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; + { + register int keyshift = (int)((*(pkeys+1)) >> 24); + (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); + } + return c; +} + + +/*********************************************************************** + * Initialize the encryption keys and the random header according to + * the given password. + */ +static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) +{ + *(pkeys+0) = 305419896L; + *(pkeys+1) = 591751049L; + *(pkeys+2) = 878082192L; + while (*passwd != '\0') { + update_keys(pkeys,pcrc_32_tab,(int)*passwd); + passwd++; + } +} + +#define zdecode(pkeys,pcrc_32_tab,c) \ + (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) + +#define zencode(pkeys,pcrc_32_tab,c,t) \ + (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) + +#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED + +#define RAND_HEAD_LEN 12 + /* "last resort" source for second part of crypt seed pattern */ +# ifndef ZCR_SEED2 +# define ZCR_SEED2 3141592654UL /* use PI as default pattern */ +# endif + +static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) + const char *passwd; /* password string */ + unsigned char *buf; /* where to write header */ + int bufSize; + unsigned long* pkeys; + const unsigned long* pcrc_32_tab; + unsigned long crcForCrypting; +{ + int n; /* index in random header */ + int t; /* temporary */ + int c; /* random byte */ + unsigned char header[RAND_HEAD_LEN-2]; /* random header */ + static unsigned calls = 0; /* ensure different random header each time */ + + if (bufSize> 7) & 0xff; + header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); + } + /* Encrypt random header (last two bytes is high word of crc) */ + init_keys(passwd, pkeys, pcrc_32_tab); + for (n = 0; n < RAND_HEAD_LEN-2; n++) + { + buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); + } + buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); + buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); + return n; +} + +#endif diff --git a/kicad/minizip/ioapi.c b/kicad/minizip/ioapi.c new file mode 100644 index 0000000000..894fc83ebd --- /dev/null +++ b/kicad/minizip/ioapi.c @@ -0,0 +1,177 @@ +/* ioapi.c -- IO base function header for compress/uncompress .zip + files using zlib + zip or unzip API + + Version 1.00, September 10th, 2003 + + Copyright (C) 1998-2003 Gilles Vollant +*/ + +#include +#include +#include + +#include "zlib.h" +#include "ioapi.h" + + + +/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ + +#ifndef SEEK_CUR +#define SEEK_CUR 1 +#endif + +#ifndef SEEK_END +#define SEEK_END 2 +#endif + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif + +voidpf ZCALLBACK fopen_file_func OF(( + voidpf opaque, + const char* filename, + int mode)); + +uLong ZCALLBACK fread_file_func OF(( + voidpf opaque, + voidpf stream, + void* buf, + uLong size)); + +uLong ZCALLBACK fwrite_file_func OF(( + voidpf opaque, + voidpf stream, + const void* buf, + uLong size)); + +long ZCALLBACK ftell_file_func OF(( + voidpf opaque, + voidpf stream)); + +long ZCALLBACK fseek_file_func OF(( + voidpf opaque, + voidpf stream, + uLong offset, + int origin)); + +int ZCALLBACK fclose_file_func OF(( + voidpf opaque, + voidpf stream)); + +int ZCALLBACK ferror_file_func OF(( + voidpf opaque, + voidpf stream)); + + +voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) + voidpf opaque; + const char* filename; + int mode; +{ + FILE* file = NULL; + const char* mode_fopen = NULL; + if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) + mode_fopen = "rb"; + else + if (mode & ZLIB_FILEFUNC_MODE_EXISTING) + mode_fopen = "r+b"; + else + if (mode & ZLIB_FILEFUNC_MODE_CREATE) + mode_fopen = "wb"; + + if ((filename!=NULL) && (mode_fopen != NULL)) + file = fopen(filename, mode_fopen); + return file; +} + + +uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) + voidpf opaque; + voidpf stream; + void* buf; + uLong size; +{ + uLong ret; + ret = fread(buf, 1, (size_t)size, (FILE *)stream); + return ret; +} + + +uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size) + voidpf opaque; + voidpf stream; + const void* buf; + uLong size; +{ + uLong ret; + ret = fwrite(buf, 1, (size_t)size, (FILE *)stream); + return ret; +} + +long ZCALLBACK ftell_file_func (opaque, stream) + voidpf opaque; + voidpf stream; +{ + long ret; + ret = ftell((FILE *)stream); + return ret; +} + +long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) + voidpf opaque; + voidpf stream; + uLong offset; + int origin; +{ + int fseek_origin=0; + long ret; + switch (origin) + { + case ZLIB_FILEFUNC_SEEK_CUR : + fseek_origin = SEEK_CUR; + break; + case ZLIB_FILEFUNC_SEEK_END : + fseek_origin = SEEK_END; + break; + case ZLIB_FILEFUNC_SEEK_SET : + fseek_origin = SEEK_SET; + break; + default: return -1; + } + ret = 0; + fseek((FILE *)stream, offset, fseek_origin); + return ret; +} + +int ZCALLBACK fclose_file_func (opaque, stream) + voidpf opaque; + voidpf stream; +{ + int ret; + ret = fclose((FILE *)stream); + return ret; +} + +int ZCALLBACK ferror_file_func (opaque, stream) + voidpf opaque; + voidpf stream; +{ + int ret; + ret = ferror((FILE *)stream); + return ret; +} + +void fill_fopen_filefunc (pzlib_filefunc_def) + zlib_filefunc_def* pzlib_filefunc_def; +{ + pzlib_filefunc_def->zopen_file = fopen_file_func; + pzlib_filefunc_def->zread_file = fread_file_func; + pzlib_filefunc_def->zwrite_file = fwrite_file_func; + pzlib_filefunc_def->ztell_file = ftell_file_func; + pzlib_filefunc_def->zseek_file = fseek_file_func; + pzlib_filefunc_def->zclose_file = fclose_file_func; + pzlib_filefunc_def->zerror_file = ferror_file_func; + pzlib_filefunc_def->opaque = NULL; +} diff --git a/kicad/minizip/ioapi.h b/kicad/minizip/ioapi.h new file mode 100644 index 0000000000..bd29cb704a --- /dev/null +++ b/kicad/minizip/ioapi.h @@ -0,0 +1,75 @@ +/* ioapi.h -- IO base function header for compress/uncompress .zip + files using zlib + zip or unzip API + + Version 1.00, September 10th, 2003 + + Copyright (C) 1998-2003 Gilles Vollant +*/ + +#ifndef _ZLIBIOAPI_H +#define _ZLIBIOAPI_H + + +#define ZLIB_FILEFUNC_SEEK_CUR (1) +#define ZLIB_FILEFUNC_SEEK_END (2) +#define ZLIB_FILEFUNC_SEEK_SET (0) + +#define ZLIB_FILEFUNC_MODE_READ (1) +#define ZLIB_FILEFUNC_MODE_WRITE (2) +#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) + +#define ZLIB_FILEFUNC_MODE_EXISTING (4) +#define ZLIB_FILEFUNC_MODE_CREATE (8) + + +#ifndef ZCALLBACK + +#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) +#define ZCALLBACK CALLBACK +#else +#define ZCALLBACK +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); +typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); +typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); +typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); +typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); +typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); +typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); + +typedef struct zlib_filefunc_def_s +{ + open_file_func zopen_file; + read_file_func zread_file; + write_file_func zwrite_file; + tell_file_func ztell_file; + seek_file_func zseek_file; + close_file_func zclose_file; + testerror_file_func zerror_file; + voidpf opaque; +} zlib_filefunc_def; + + + +void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); + +#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) +#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) +#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) +#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) +#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) +#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/kicad/minizip/iowin32.c b/kicad/minizip/iowin32.c new file mode 100644 index 0000000000..7c670ab436 --- /dev/null +++ b/kicad/minizip/iowin32.c @@ -0,0 +1,270 @@ +/* iowin32.c -- IO base function header for compress/uncompress .zip + files using zlib + zip or unzip API + This IO API version uses the Win32 API (for Microsoft Windows) + + Version 1.00, September 10th, 2003 + + Copyright (C) 1998-2003 Gilles Vollant +*/ + +#include + +#include "zlib.h" +#include "ioapi.h" +#include "iowin32.h" + +#ifndef INVALID_HANDLE_VALUE +#define INVALID_HANDLE_VALUE (0xFFFFFFFF) +#endif + +#ifndef INVALID_SET_FILE_POINTER +#define INVALID_SET_FILE_POINTER ((DWORD)-1) +#endif + +voidpf ZCALLBACK win32_open_file_func OF(( + voidpf opaque, + const char* filename, + int mode)); + +uLong ZCALLBACK win32_read_file_func OF(( + voidpf opaque, + voidpf stream, + void* buf, + uLong size)); + +uLong ZCALLBACK win32_write_file_func OF(( + voidpf opaque, + voidpf stream, + const void* buf, + uLong size)); + +long ZCALLBACK win32_tell_file_func OF(( + voidpf opaque, + voidpf stream)); + +long ZCALLBACK win32_seek_file_func OF(( + voidpf opaque, + voidpf stream, + uLong offset, + int origin)); + +int ZCALLBACK win32_close_file_func OF(( + voidpf opaque, + voidpf stream)); + +int ZCALLBACK win32_error_file_func OF(( + voidpf opaque, + voidpf stream)); + +typedef struct +{ + HANDLE hf; + int error; +} WIN32FILE_IOWIN; + +voidpf ZCALLBACK win32_open_file_func (opaque, filename, mode) + voidpf opaque; + const char* filename; + int mode; +{ + const char* mode_fopen = NULL; + DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; + HANDLE hFile = 0; + voidpf ret=NULL; + + dwDesiredAccess = dwShareMode = dwFlagsAndAttributes = 0; + + if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) + { + dwDesiredAccess = GENERIC_READ; + dwCreationDisposition = OPEN_EXISTING; + dwShareMode = FILE_SHARE_READ; + } + else + if (mode & ZLIB_FILEFUNC_MODE_EXISTING) + { + dwDesiredAccess = GENERIC_WRITE | GENERIC_READ; + dwCreationDisposition = OPEN_EXISTING; + } + else + if (mode & ZLIB_FILEFUNC_MODE_CREATE) + { + dwDesiredAccess = GENERIC_WRITE | GENERIC_READ; + dwCreationDisposition = CREATE_ALWAYS; + } + + if ((filename!=NULL) && (dwDesiredAccess != 0)) + hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, + dwCreationDisposition, dwFlagsAndAttributes, NULL); + + if (hFile == INVALID_HANDLE_VALUE) + hFile = NULL; + + if (hFile != NULL) + { + WIN32FILE_IOWIN w32fiow; + w32fiow.hf = hFile; + w32fiow.error = 0; + ret = malloc(sizeof(WIN32FILE_IOWIN)); + if (ret==NULL) + CloseHandle(hFile); + else *((WIN32FILE_IOWIN*)ret) = w32fiow; + } + return ret; +} + + +uLong ZCALLBACK win32_read_file_func (opaque, stream, buf, size) + voidpf opaque; + voidpf stream; + void* buf; + uLong size; +{ + uLong ret=0; + HANDLE hFile = NULL; + if (stream!=NULL) + hFile = ((WIN32FILE_IOWIN*)stream) -> hf; + if (hFile != NULL) + if (!ReadFile(hFile, buf, size, &ret, NULL)) + { + DWORD dwErr = GetLastError(); + if (dwErr == ERROR_HANDLE_EOF) + dwErr = 0; + ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; + } + + return ret; +} + + +uLong ZCALLBACK win32_write_file_func (opaque, stream, buf, size) + voidpf opaque; + voidpf stream; + const void* buf; + uLong size; +{ + uLong ret=0; + HANDLE hFile = NULL; + if (stream!=NULL) + hFile = ((WIN32FILE_IOWIN*)stream) -> hf; + + if (hFile !=NULL) + if (!WriteFile(hFile, buf, size, &ret, NULL)) + { + DWORD dwErr = GetLastError(); + if (dwErr == ERROR_HANDLE_EOF) + dwErr = 0; + ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; + } + + return ret; +} + +long ZCALLBACK win32_tell_file_func (opaque, stream) + voidpf opaque; + voidpf stream; +{ + long ret=-1; + HANDLE hFile = NULL; + if (stream!=NULL) + hFile = ((WIN32FILE_IOWIN*)stream) -> hf; + if (hFile != NULL) + { + DWORD dwSet = SetFilePointer(hFile, 0, NULL, FILE_CURRENT); + if (dwSet == INVALID_SET_FILE_POINTER) + { + DWORD dwErr = GetLastError(); + ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; + ret = -1; + } + else + ret=(long)dwSet; + } + return ret; +} + +long ZCALLBACK win32_seek_file_func (opaque, stream, offset, origin) + voidpf opaque; + voidpf stream; + uLong offset; + int origin; +{ + DWORD dwMoveMethod=0xFFFFFFFF; + HANDLE hFile = NULL; + + long ret=-1; + if (stream!=NULL) + hFile = ((WIN32FILE_IOWIN*)stream) -> hf; + switch (origin) + { + case ZLIB_FILEFUNC_SEEK_CUR : + dwMoveMethod = FILE_CURRENT; + break; + case ZLIB_FILEFUNC_SEEK_END : + dwMoveMethod = FILE_END; + break; + case ZLIB_FILEFUNC_SEEK_SET : + dwMoveMethod = FILE_BEGIN; + break; + default: return -1; + } + + if (hFile != NULL) + { + DWORD dwSet = SetFilePointer(hFile, offset, NULL, dwMoveMethod); + if (dwSet == INVALID_SET_FILE_POINTER) + { + DWORD dwErr = GetLastError(); + ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; + ret = -1; + } + else + ret=0; + } + return ret; +} + +int ZCALLBACK win32_close_file_func (opaque, stream) + voidpf opaque; + voidpf stream; +{ + int ret=-1; + + if (stream!=NULL) + { + HANDLE hFile; + hFile = ((WIN32FILE_IOWIN*)stream) -> hf; + if (hFile != NULL) + { + CloseHandle(hFile); + ret=0; + } + free(stream); + } + return ret; +} + +int ZCALLBACK win32_error_file_func (opaque, stream) + voidpf opaque; + voidpf stream; +{ + int ret=-1; + if (stream!=NULL) + { + ret = ((WIN32FILE_IOWIN*)stream) -> error; + } + return ret; +} + +void fill_win32_filefunc (pzlib_filefunc_def) + zlib_filefunc_def* pzlib_filefunc_def; +{ + pzlib_filefunc_def->zopen_file = win32_open_file_func; + pzlib_filefunc_def->zread_file = win32_read_file_func; + pzlib_filefunc_def->zwrite_file = win32_write_file_func; + pzlib_filefunc_def->ztell_file = win32_tell_file_func; + pzlib_filefunc_def->zseek_file = win32_seek_file_func; + pzlib_filefunc_def->zclose_file = win32_close_file_func; + pzlib_filefunc_def->zerror_file = win32_error_file_func; + pzlib_filefunc_def->opaque=NULL; +} diff --git a/kicad/minizip/iowin32.h b/kicad/minizip/iowin32.h new file mode 100644 index 0000000000..17d459ac59 --- /dev/null +++ b/kicad/minizip/iowin32.h @@ -0,0 +1,21 @@ +/* iowin32.h -- IO base function header for compress/uncompress .zip + files using zlib + zip or unzip API + This IO API version uses the Win32 API (for Microsoft Windows) + + Version 1.00, September 10th, 2003 + + Copyright (C) 1998-2003 Gilles Vollant +*/ + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); + +#ifdef __cplusplus +} +#endif diff --git a/kicad/minizip/makefile b/kicad/minizip/makefile new file mode 100644 index 0000000000..beaeac4463 --- /dev/null +++ b/kicad/minizip/makefile @@ -0,0 +1,14 @@ +WXDIR = $(WXWIN) + +CC=gcc +LD=gcc +CFLAGS=-O2 -Wall -I$(WXDIR)/src/zlib +EXTRALIBS= $(WXDIR)/lib/libwxzlib.a + +ZIP_OBJS = minizip.o zip.o ioapi.o + +.c.o: + $(CC) -c $(CFLAGS) $*.c + +minizip: $(ZIP_OBJS) + $(LD) $(LFLAGS) -o $@ $(ZIP_OBJS) $(EXTRALIBS) diff --git a/kicad/minizip/makefile.unx b/kicad/minizip/makefile.unx new file mode 100644 index 0000000000..57663ebd88 --- /dev/null +++ b/kicad/minizip/makefile.unx @@ -0,0 +1,15 @@ +WXDIR = /usr/local/wxGTK2-2.5.1 + +CC=gcc +LD=gcc +CFLAGS=-O2 -Wall -I$(WXDIR)/src/zlib +#EXTRALIBS= $(WXDIR)/lib/libwxzlib.a +EXTRALIBS= -lz + +ZIP_OBJS = minizip.o zip.o ioapi.o + +.c.o: + $(CC) -c $(CFLAGS) $*.c + +minizip: $(ZIP_OBJS) + $(LD) $(LFLAGS) -o $@ $(ZIP_OBJS) $(EXTRALIBS) diff --git a/kicad/minizip/makefile.win b/kicad/minizip/makefile.win new file mode 100644 index 0000000000..beaeac4463 --- /dev/null +++ b/kicad/minizip/makefile.win @@ -0,0 +1,14 @@ +WXDIR = $(WXWIN) + +CC=gcc +LD=gcc +CFLAGS=-O2 -Wall -I$(WXDIR)/src/zlib +EXTRALIBS= $(WXDIR)/lib/libwxzlib.a + +ZIP_OBJS = minizip.o zip.o ioapi.o + +.c.o: + $(CC) -c $(CFLAGS) $*.c + +minizip: $(ZIP_OBJS) + $(LD) $(LFLAGS) -o $@ $(ZIP_OBJS) $(EXTRALIBS) diff --git a/kicad/minizip/minizip.c b/kicad/minizip/minizip.c new file mode 100644 index 0000000000..af64766f83 --- /dev/null +++ b/kicad/minizip/minizip.c @@ -0,0 +1,378 @@ +/* MiniZip 1.00, demo of zLib + Zip package written by Gilles Vollant + Modifie le 2 juin 2004 JPC +*/ +#include +#include +#include +#include +#include +#include + +#ifdef unix +# include +# include +# include +# include +#else +# include +# include +#endif + +#include "zip.h" + +#ifdef WIN32 +//#define USEWIN32IOAPI +#include "iowin32.h" +#endif + + + +#define WRITEBUFFERSIZE (16384) +#define MAXFILENAME (1024) + +int g_Verbose = 1; + + +/*****************************/ +uLong filetime( + const char *filename, /* name of file to get info on */ + tm_zip *tmzip, /* return value: access, modific. and creation times */ + uLong *dt) /* dostime */ +/*****************************/ +#ifdef WIN32 +{ + int ret = 0; + { + FILETIME ftLocal; + HANDLE hFind; + WIN32_FIND_DATA ff32; + + hFind = FindFirstFile(filename,&ff32); + if (hFind != INVALID_HANDLE_VALUE) + { + FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal); + FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0); + FindClose(hFind); + ret = 1; + } + } + return ret; +} +#else +#ifdef unix +{ +int ret=0; +struct stat s; /* results of stat() */ +struct tm* filedate; +time_t tm_t=0; + + if (strcmp(filename,"-")!=0) + { + char name[MAXFILENAME+10]; + int len = strlen(filename); + + strncpy(name, filename,MAXFILENAME); + /* strncpy doesnt append the trailing NULL, of the string is too long. */ + name[ MAXFILENAME ] = '\0'; + + if (name[len - 1] == '/') + name[len - 1] = '\0'; + /* not all systems allow stat'ing a file with / appended */ + if (stat(name,&s)==0) + { + tm_t = s.st_mtime; + ret = 1; + } + } + filedate = localtime(&tm_t); + + tmzip->tm_sec = filedate->tm_sec; + tmzip->tm_min = filedate->tm_min; + tmzip->tm_hour = filedate->tm_hour; + tmzip->tm_mday = filedate->tm_mday; + tmzip->tm_mon = filedate->tm_mon ; + tmzip->tm_year = filedate->tm_year; + + return ret; +} +#else +{ + return 0; +} +#endif +#endif + + + +/*******************************************/ +int check_exist_file( const char* filename) +/*******************************************/ +{ + FILE* ftestexist; + int ret = 1; + ftestexist = fopen(filename,"rb"); + if (ftestexist == NULL) ret = 0; + else fclose(ftestexist); + return ret; +} + +/* calculate the CRC32 of a file, + because to encrypt a file, we need known the CRC32 of the file before */ +int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc) +{ +unsigned long calculate_crc=0; +int err=ZIP_OK; +FILE * fin = fopen(filenameinzip,"rb"); +unsigned long size_read = 0; +unsigned long total_read = 0; + + if (fin==NULL) + { + err = ZIP_ERRNO; + } + + if (err == ZIP_OK) + do + { + err = ZIP_OK; + size_read = (int)fread(buf,1,size_buf,fin); + if (size_read < size_buf) + if (feof(fin)==0) + { + printf("error in reading %s\n",filenameinzip); + err = ZIP_ERRNO; + } + + if (size_read>0) + calculate_crc = crc32(calculate_crc,buf,size_read); + total_read += size_read; + + } while ((err == ZIP_OK) && (size_read>0)); + + if (fin) + fclose(fin); + + *result_crc=calculate_crc; + if ( g_Verbose ) printf("file %s crc %lx\n",filenameinzip,calculate_crc); + return err; +} + +/********************************/ +int main( int argc, char *argv[]) +/********************************/ +{ +int i; +int opt_overwrite=0; +int opt_compress_level=Z_DEFAULT_COMPRESSION; +int zipfilenamearg = 0; +char filename_try[MAXFILENAME+16]; +int zipok; +int err=0; +int size_buf=0; +void* buf=NULL; +const char* password=NULL; + + if (argc <= 1) + { + printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] file.zip [files_to_add]\n\n" \ + " -o Overwrite existing file.zip\n" \ + " -a Append to existing file.zip\n" \ + " -0 Store only, -1 Compress faster, -9 Compress better [5]\n\n"); + return 0; + } + + for (i = 1; i < argc; i++) + { + if ((*argv[i])=='-') /* Find options */ + { + const char *p=argv[i]+1; + + while ((*p)!='\0') + { + char c=*(p++); + if ((c=='o') || (c=='O')) + opt_overwrite = 1; + else if ((c=='a') || (c=='A')) + opt_overwrite = 2; + else if ((c>='0') && (c<='9')) + opt_compress_level = c-'0'; + + else if (((c=='p') || (c=='P')) && (i+1='a') && (rep<='z')) + rep -= 0x20; + } + while ((rep!='Y') && (rep!='N') && (rep!='A')); + if (rep=='N') zipok = 0; + if (rep=='A') opt_overwrite = 2; + } + } + + if (zipok==1) + { + zipFile zf; + int errclose; +#ifdef USEWIN32IOAPI + zlib_filefunc_def ffunc; + fill_win32_filefunc(&ffunc); + zf = zipOpen2(filename_try,(opt_overwrite==2) ? 2 : 0,NULL,&ffunc); +#else + zf = zipOpen(filename_try,(opt_overwrite==2) ? 2 : 0); +#endif + + if (zf == NULL) + { + printf("error opening %s\n",filename_try); + err= ZIP_ERRNO; + } + else + if ( g_Verbose ) printf("creating %s\n",filename_try); + + for (i=zipfilenamearg+1; (i0) + { + err = zipWriteInFileInZip (zf,buf,size_read); + if (err<0) + { + printf("error in writing %s in the zipfile\n", + filenameinzip); + } + + } + } while ((err == ZIP_OK) && (size_read>0)); + + if (fin) fclose(fin); + + if (err<0) err=ZIP_ERRNO; + else + { + err = zipCloseFileInZip(zf); + if (err!=ZIP_OK) + printf("error in closing %s in the zipfile\n", + filenameinzip); + } + } + } + errclose = zipClose(zf,NULL); + if (errclose != ZIP_OK) + printf("error in closing %s\n",filename_try); + } + + free(buf); + return 0; +} diff --git a/kicad/minizip/zip.c b/kicad/minizip/zip.c new file mode 100644 index 0000000000..54f724e1aa --- /dev/null +++ b/kicad/minizip/zip.c @@ -0,0 +1,1170 @@ +/* zip.c -- IO on .zip files using zlib + Version 1.00, September 10th, 2003 + + Copyright (C) 1998-2003 Gilles Vollant + + Read zip.h for more info +*/ + + +#include +#include +#include +#include +#include "zlib.h" +#include "zip.h" + +#ifdef STDC +# include +# include +# include +#endif +#ifdef NO_ERRNO_H + extern int errno; +#else +# include +#endif + + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + +#ifndef VERSIONMADEBY +# define VERSIONMADEBY (0x0) /* platform depedent */ +#endif + +#ifndef Z_BUFSIZE +#define Z_BUFSIZE (16384) +#endif + +#ifndef Z_MAXFILENAMEINZIP +#define Z_MAXFILENAMEINZIP (256) +#endif + +#ifndef ALLOC +# define ALLOC(size) (malloc(size)) +#endif +#ifndef TRYFREE +# define TRYFREE(p) {if (p) free(p);} +#endif + +/* +#define SIZECENTRALDIRITEM (0x2e) +#define SIZEZIPLOCALHEADER (0x1e) +*/ + +/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ + +#ifndef SEEK_CUR +#define SEEK_CUR 1 +#endif + +#ifndef SEEK_END +#define SEEK_END 2 +#endif + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif + +#ifndef DEF_MEM_LEVEL +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif +#endif +const char zip_copyright[] = + " zip 1.00 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; + + +#define SIZEDATA_INDATABLOCK (4096-(4*4)) + +#define LOCALHEADERMAGIC (0x04034b50) +#define CENTRALHEADERMAGIC (0x02014b50) +#define ENDHEADERMAGIC (0x06054b50) + +#define FLAG_LOCALHEADER_OFFSET (0x06) +#define CRC_LOCALHEADER_OFFSET (0x0e) + +#define SIZECENTRALHEADER (0x2e) /* 46 */ + +typedef struct linkedlist_datablock_internal_s +{ + struct linkedlist_datablock_internal_s* next_datablock; + uLong avail_in_this_block; + uLong filled_in_this_block; + uLong unused; /* for future use and alignement */ + unsigned char data[SIZEDATA_INDATABLOCK]; +} linkedlist_datablock_internal; + +typedef struct linkedlist_data_s +{ + linkedlist_datablock_internal* first_block; + linkedlist_datablock_internal* last_block; +} linkedlist_data; + + +typedef struct +{ + z_stream stream; /* zLib stream structure for inflate */ + int stream_initialised; /* 1 is stream is initialised */ + uInt pos_in_buffered_data; /* last written byte in buffered_data */ + + uLong pos_local_header; /* offset of the local header of the file + currenty writing */ + char* central_header; /* central header data for the current file */ + uLong size_centralheader; /* size of the central header for cur file */ + uLong flag; /* flag of the file currently writing */ + + int method; /* compression method of file currenty wr.*/ + int raw; /* 1 for directly writing raw data */ + Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ + uLong dosDate; + uLong crc32; + int encrypt; +#ifndef NOCRYPT + unsigned long keys[3]; /* keys defining the pseudo-random sequence */ + const unsigned long* pcrc_32_tab; + int crypt_header_size; +#endif +} curfile_info; + +typedef struct +{ + zlib_filefunc_def z_filefunc; + voidpf filestream; /* io structore of the zipfile */ + linkedlist_data central_dir;/* datablock with central dir in construction*/ + int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ + curfile_info ci; /* info on the file curretly writing */ + + uLong begin_pos; /* position of the beginning of the zipfile */ + uLong add_position_when_writting_offset; + uLong number_entry; +} zip_internal; + + + +#ifndef NOCRYPT +#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED +#include "crypt.h" +#endif + +local linkedlist_datablock_internal* allocate_new_datablock() +{ + linkedlist_datablock_internal* ldi; + ldi = (linkedlist_datablock_internal*) + ALLOC(sizeof(linkedlist_datablock_internal)); + if (ldi!=NULL) + { + ldi->next_datablock = NULL ; + ldi->filled_in_this_block = 0 ; + ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ; + } + return ldi; +} + +local void free_datablock(ldi) + linkedlist_datablock_internal* ldi; +{ + while (ldi!=NULL) + { + linkedlist_datablock_internal* ldinext = ldi->next_datablock; + TRYFREE(ldi); + ldi = ldinext; + } +} + +local void init_linkedlist(ll) + linkedlist_data* ll; +{ + ll->first_block = ll->last_block = NULL; +} + +local void free_linkedlist(ll) + linkedlist_data* ll; +{ + free_datablock(ll->first_block); + ll->first_block = ll->last_block = NULL; +} + + +local int add_data_in_datablock(ll,buf,len) + linkedlist_data* ll; + const void* buf; + uLong len; +{ + linkedlist_datablock_internal* ldi; + const unsigned char* from_copy; + + if (ll==NULL) + return ZIP_INTERNALERROR; + + if (ll->last_block == NULL) + { + ll->first_block = ll->last_block = allocate_new_datablock(); + if (ll->first_block == NULL) + return ZIP_INTERNALERROR; + } + + ldi = ll->last_block; + from_copy = (unsigned char*)buf; + + while (len>0) + { + uInt copy_this; + uInt i; + unsigned char* to_copy; + + if (ldi->avail_in_this_block==0) + { + ldi->next_datablock = allocate_new_datablock(); + if (ldi->next_datablock == NULL) + return ZIP_INTERNALERROR; + ldi = ldi->next_datablock ; + ll->last_block = ldi; + } + + if (ldi->avail_in_this_block < len) + copy_this = (uInt)ldi->avail_in_this_block; + else + copy_this = (uInt)len; + + to_copy = &(ldi->data[ldi->filled_in_this_block]); + + for (i=0;ifilled_in_this_block += copy_this; + ldi->avail_in_this_block -= copy_this; + from_copy += copy_this ; + len -= copy_this; + } + return ZIP_OK; +} + + + +/****************************************************************************/ + +#ifndef NO_ADDFILEINEXISTINGZIP +/* =========================================================================== + Inputs a long in LSB order to the given file + nbByte == 1, 2 or 4 (byte, short or long) +*/ + +local int ziplocal_putValue OF((const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, uLong x, int nbByte)); +local int ziplocal_putValue (pzlib_filefunc_def, filestream, x, nbByte) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; + uLong x; + int nbByte; +{ + unsigned char buf[4]; + int n; + for (n = 0; n < nbByte; n++) { + buf[n] = (unsigned char)(x & 0xff); + x >>= 8; + } + if (ZWRITE(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte) + return ZIP_ERRNO; + else + return ZIP_OK; +} + +local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte)); +local void ziplocal_putValue_inmemory (dest, x, nbByte) + void* dest; + uLong x; + int nbByte; +{ + unsigned char* buf=(unsigned char*)dest; + int n; + for (n = 0; n < nbByte; n++) { + buf[n] = (unsigned char)(x & 0xff); + x >>= 8; + } +} +/****************************************************************************/ + + +local uLong ziplocal_TmzDateToDosDate(ptm,dosDate) + const tm_zip* ptm; + uLong dosDate; +{ + uLong year = (uLong)ptm->tm_year; + if (year>1980) + year-=1980; + else if (year>80) + year-=80; + return + (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) | + ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); +} + + +/****************************************************************************/ + +local int ziplocal_getByte OF(( + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, + int *pi)); + +local int ziplocal_getByte(pzlib_filefunc_def,filestream,pi) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; + int *pi; +{ + unsigned char c; + int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); + if (err==1) + { + *pi = (int)c; + return ZIP_OK; + } + else + { + if (ZERROR(*pzlib_filefunc_def,filestream)) + return ZIP_ERRNO; + else + return ZIP_EOF; + } +} + + +/* =========================================================================== + Reads a long in LSB order from the given gz_stream. Sets +*/ +local int ziplocal_getShort OF(( + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, + uLong *pX)); + +local int ziplocal_getShort (pzlib_filefunc_def,filestream,pX) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; + uLong *pX; +{ + uLong x ; + int i; + int err; + + err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + x = (uLong)i; + + if (err==ZIP_OK) + err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<8; + + if (err==ZIP_OK) + *pX = x; + else + *pX = 0; + return err; +} + +local int ziplocal_getLong OF(( + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, + uLong *pX)); + +local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; + uLong *pX; +{ + uLong x ; + int i; + int err; + + err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + x = (uLong)i; + + if (err==ZIP_OK) + err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<8; + + if (err==ZIP_OK) + err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<16; + + if (err==ZIP_OK) + err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<24; + + if (err==ZIP_OK) + *pX = x; + else + *pX = 0; + return err; +} + +#ifndef BUFREADCOMMENT +#define BUFREADCOMMENT (0x400) +#endif +/* + Locate the Central directory of a zipfile (at the end, just before + the global comment) +*/ +local uLong ziplocal_SearchCentralDir OF(( + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream)); + +local uLong ziplocal_SearchCentralDir(pzlib_filefunc_def,filestream) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; +{ + unsigned char* buf; + uLong uSizeFile; + uLong uBackRead; + uLong uMaxBack=0xffff; /* maximum size of global comment */ + uLong uPosFound=0; + + if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) + return 0; + + + uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); + + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; + + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; + + uBackRead = 4; + while (uBackReaduMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); + if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) + break; + + if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) + break; + + for (i=(int)uReadSize-3; (i--)>0;) + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && + ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) + { + uPosFound = uReadPos+i; + break; + } + + if (uPosFound!=0) + break; + } + TRYFREE(buf); + return uPosFound; +} +#endif /* !NO_ADDFILEINEXISTINGZIP*/ + +/************************************************************/ +extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc_def) + const char *pathname; + int append; + zipcharpc* globalcomment; + zlib_filefunc_def* pzlib_filefunc_def; +{ + zip_internal ziinit; + zip_internal* zi; + int err=ZIP_OK; + + + if (pzlib_filefunc_def==NULL) + fill_fopen_filefunc(&ziinit.z_filefunc); + else + ziinit.z_filefunc = *pzlib_filefunc_def; + + ziinit.filestream = (*(ziinit.z_filefunc.zopen_file)) + (ziinit.z_filefunc.opaque, + pathname, + (append == APPEND_STATUS_CREATE) ? + (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) : + (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING)); + + if (ziinit.filestream == NULL) + return NULL; + ziinit.begin_pos = ZTELL(ziinit.z_filefunc,ziinit.filestream); + ziinit.in_opened_file_inzip = 0; + ziinit.ci.stream_initialised = 0; + ziinit.number_entry = 0; + ziinit.add_position_when_writting_offset = 0; + init_linkedlist(&(ziinit.central_dir)); + + + zi = (zip_internal*)ALLOC(sizeof(zip_internal)); + if (zi==NULL) + { + ZCLOSE(ziinit.z_filefunc,ziinit.filestream); + return NULL; + } + + /* now we add file in a zipfile */ +# ifndef NO_ADDFILEINEXISTINGZIP + if (append == APPEND_STATUS_ADDINZIP) + { + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + + uLong size_central_dir; /* size of the central directory */ + uLong offset_central_dir; /* offset of start of central directory */ + uLong central_pos,uL; + + uLong number_disk; /* number of the current dist, used for + spaning ZIP, unsupported, always 0*/ + uLong number_disk_with_CD; /* number the the disk with central dir, used + for spaning ZIP, unsupported, always 0*/ + uLong number_entry; + uLong number_entry_CD; /* total number of entries in + the central dir + (same than number_entry on nospan) */ + uLong size_comment; + + central_pos = ziplocal_SearchCentralDir(&ziinit.z_filefunc,ziinit.filestream); + if (central_pos==0) + err=ZIP_ERRNO; + + if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, + central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) + err=ZIP_ERRNO; + + /* the signature, already checked */ + if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&uL)!=ZIP_OK) + err=ZIP_ERRNO; + + /* number of this disk */ + if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk)!=ZIP_OK) + err=ZIP_ERRNO; + + /* number of the disk with the start of the central directory */ + if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk_with_CD)!=ZIP_OK) + err=ZIP_ERRNO; + + /* total number of entries in the central dir on this disk */ + if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry)!=ZIP_OK) + err=ZIP_ERRNO; + + /* total number of entries in the central dir */ + if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry_CD)!=ZIP_OK) + err=ZIP_ERRNO; + + if ((number_entry_CD!=number_entry) || + (number_disk_with_CD!=0) || + (number_disk!=0)) + err=ZIP_BADZIPFILE; + + /* size of the central directory */ + if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&size_central_dir)!=ZIP_OK) + err=ZIP_ERRNO; + + /* offset of start of central directory with respect to the + starting disk number */ + if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&offset_central_dir)!=ZIP_OK) + err=ZIP_ERRNO; + + /* zipfile comment length */ + if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&size_comment)!=ZIP_OK) + err=ZIP_ERRNO; + + if ((central_pos0) && (err==ZIP_OK)) + { + uLong read_this = SIZEDATA_INDATABLOCK; + if (read_this > size_central_dir_to_read) + read_this = size_central_dir_to_read; + if (ZREAD(ziinit.z_filefunc, ziinit.filestream,buf_read,read_this) != read_this) + err=ZIP_ERRNO; + + if (err==ZIP_OK) + err = add_data_in_datablock(&ziinit.central_dir,buf_read, + (uLong)read_this); + size_central_dir_to_read-=read_this; + } + TRYFREE(buf_read); + } + ziinit.begin_pos = byte_before_the_zipfile; + ziinit.number_entry = number_entry_CD; + + if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, + offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) + err=ZIP_ERRNO; + } +# endif /* !NO_ADDFILEINEXISTINGZIP*/ + + if (err != ZIP_OK) + { + TRYFREE(zi); + return NULL; + } + else + { + *zi = ziinit; + return (zipFile)zi; + } +} + +extern zipFile ZEXPORT zipOpen (pathname, append) + const char *pathname; + int append; +{ + return zipOpen2(pathname,append,NULL,NULL); +} + +extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + windowBits, memLevel, strategy, + password, crcForCrypting) + zipFile file; + const char* filename; + const zip_fileinfo* zipfi; + const void* extrafield_local; + uInt size_extrafield_local; + const void* extrafield_global; + uInt size_extrafield_global; + const char* comment; + int method; + int level; + int raw; + int windowBits; + int memLevel; + int strategy; + const char* password; + uLong crcForCrypting; +{ + zip_internal* zi; + uInt size_filename; + uInt size_comment; + uInt i; + int err = ZIP_OK; + +# ifdef NOCRYPT + if (password != NULL) + return ZIP_PARAMERROR; +# endif + + if (file == NULL) + return ZIP_PARAMERROR; + if ((method!=0) && (method!=Z_DEFLATED)) + return ZIP_PARAMERROR; + + zi = (zip_internal*)file; + + if (zi->in_opened_file_inzip == 1) + { + err = zipCloseFileInZip (file); + if (err != ZIP_OK) + return err; + } + + + if (filename==NULL) + filename="-"; + + if (comment==NULL) + size_comment = 0; + else + size_comment = strlen(comment); + + size_filename = strlen(filename); + + if (zipfi == NULL) + zi->ci.dosDate = 0; + else + { + if (zipfi->dosDate != 0) + zi->ci.dosDate = zipfi->dosDate; + else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate); + } + + zi->ci.flag = 0; + if ((level==8) || (level==9)) + zi->ci.flag |= 2; + if ((level==2)) + zi->ci.flag |= 4; + if ((level==1)) + zi->ci.flag |= 6; + if (password != NULL) + zi->ci.flag |= 1; + + zi->ci.crc32 = 0; + zi->ci.method = method; + zi->ci.encrypt = 0; + zi->ci.stream_initialised = 0; + zi->ci.pos_in_buffered_data = 0; + zi->ci.raw = raw; + zi->ci.pos_local_header = ZTELL(zi->z_filefunc,zi->filestream) ; + zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + + size_extrafield_global + size_comment; + zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader); + + ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4); + /* version info */ + ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2); + ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2); + ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2); + ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2); + ziplocal_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4); + ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/ + ziplocal_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/ + ziplocal_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/ + ziplocal_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2); + ziplocal_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2); + ziplocal_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2); + ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/ + + if (zipfi==NULL) + ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); + else + ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); + + if (zipfi==NULL) + ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); + else + ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4); + + ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header- zi->add_position_when_writting_offset,4); + + for (i=0;ici.central_header+SIZECENTRALHEADER+i) = *(filename+i); + + for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+i) = + *(((const char*)extrafield_global)+i); + + for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+ + size_extrafield_global+i) = *(comment+i); + if (zi->ci.central_header == NULL) + return ZIP_INTERNALERROR; + + /* write the local header */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC,4); + + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */ + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2); + + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2); + + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4); + + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */ + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */ + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */ + + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2); + + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield_local,2); + + if ((err==ZIP_OK) && (size_filename>0)) + if (ZWRITE(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename) + err = ZIP_ERRNO; + + if ((err==ZIP_OK) && (size_extrafield_local>0)) + if (ZWRITE(zi->z_filefunc,zi->filestream,extrafield_local,size_extrafield_local) + !=size_extrafield_local) + err = ZIP_ERRNO; + + zi->ci.stream.avail_in = (uInt)0; + zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.stream.next_out = zi->ci.buffered_data; + zi->ci.stream.total_in = 0; + zi->ci.stream.total_out = 0; + + if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) + { + zi->ci.stream.zalloc = (alloc_func)0; + zi->ci.stream.zfree = (free_func)0; + zi->ci.stream.opaque = (voidpf)0; + + if (windowBits>0) + windowBits = -windowBits; + + err = deflateInit2(&zi->ci.stream, level, + Z_DEFLATED, windowBits, memLevel, strategy); + + if (err==Z_OK) + zi->ci.stream_initialised = 1; + } +# ifndef NOCRYPT + zi->ci.crypt_header_size = 0; + if ((err==Z_OK) && (password != NULL)) + { + unsigned char bufHead[RAND_HEAD_LEN]; + unsigned int sizeHead; + zi->ci.encrypt = 1; + zi->ci.pcrc_32_tab = get_crc_table(); + /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/ + + sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting); + zi->ci.crypt_header_size = sizeHead; + + if (ZWRITE(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead) + err = ZIP_ERRNO; + } +# endif + + if (err==Z_OK) + zi->in_opened_file_inzip = 1; + return err; +} + +extern int ZEXPORT zipOpenNewFileInZip2(file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw) + zipFile file; + const char* filename; + const zip_fileinfo* zipfi; + const void* extrafield_local; + uInt size_extrafield_local; + const void* extrafield_global; + uInt size_extrafield_global; + const char* comment; + int method; + int level; + int raw; +{ + return zipOpenNewFileInZip3 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0); +} + +extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level) + zipFile file; + const char* filename; + const zip_fileinfo* zipfi; + const void* extrafield_local; + uInt size_extrafield_local; + const void* extrafield_global; + uInt size_extrafield_global; + const char* comment; + int method; + int level; +{ + return zipOpenNewFileInZip2 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, 0); +} + +local int zipFlushWriteBuffer(zi) + zip_internal* zi; +{ + int err=ZIP_OK; + + if (zi->ci.encrypt != 0) + { +#ifndef NOCRYPT + uInt i; + int t; + for (i=0;ici.pos_in_buffered_data;i++) + zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, + zi->ci.buffered_data[i],t); +#endif + } + if (ZWRITE(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data) + !=zi->ci.pos_in_buffered_data) + err = ZIP_ERRNO; + zi->ci.pos_in_buffered_data = 0; + return err; +} + +extern int ZEXPORT zipWriteInFileInZip (file, buf, len) + zipFile file; + const void* buf; + unsigned len; +{ + zip_internal* zi; + int err=ZIP_OK; + + if (file == NULL) + return ZIP_PARAMERROR; + zi = (zip_internal*)file; + + if (zi->in_opened_file_inzip == 0) + return ZIP_PARAMERROR; + + zi->ci.stream.next_in = (void*)buf; + zi->ci.stream.avail_in = len; + zi->ci.crc32 = crc32(zi->ci.crc32,buf,len); + + while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) + { + if (zi->ci.stream.avail_out == 0) + { + if (zipFlushWriteBuffer(zi) == ZIP_ERRNO) + err = ZIP_ERRNO; + zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.stream.next_out = zi->ci.buffered_data; + } + + + if(err != ZIP_OK) + break; + + if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) + { + uLong uTotalOutBefore = zi->ci.stream.total_out; + err=deflate(&zi->ci.stream, Z_NO_FLUSH); + zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; + + } + else + { + uInt copy_this,i; + if (zi->ci.stream.avail_in < zi->ci.stream.avail_out) + copy_this = zi->ci.stream.avail_in; + else + copy_this = zi->ci.stream.avail_out; + for (i=0;ici.stream.next_out)+i) = + *(((const char*)zi->ci.stream.next_in)+i); + { + zi->ci.stream.avail_in -= copy_this; + zi->ci.stream.avail_out-= copy_this; + zi->ci.stream.next_in+= copy_this; + zi->ci.stream.next_out+= copy_this; + zi->ci.stream.total_in+= copy_this; + zi->ci.stream.total_out+= copy_this; + zi->ci.pos_in_buffered_data += copy_this; + } + } + } + + return err; +} + +extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32) + zipFile file; + uLong uncompressed_size; + uLong crc32; +{ + zip_internal* zi; + uLong compressed_size; + int err=ZIP_OK; + + if (file == NULL) + return ZIP_PARAMERROR; + zi = (zip_internal*)file; + + if (zi->in_opened_file_inzip == 0) + return ZIP_PARAMERROR; + zi->ci.stream.avail_in = 0; + + if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) + while (err==ZIP_OK) + { + uLong uTotalOutBefore; + if (zi->ci.stream.avail_out == 0) + { + if (zipFlushWriteBuffer(zi) == ZIP_ERRNO) + err = ZIP_ERRNO; + zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.stream.next_out = zi->ci.buffered_data; + } + uTotalOutBefore = zi->ci.stream.total_out; + err=deflate(&zi->ci.stream, Z_FINISH); + zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; + } + + if (err==Z_STREAM_END) + err=ZIP_OK; /* this is normal */ + + if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK)) + if (zipFlushWriteBuffer(zi)==ZIP_ERRNO) + err = ZIP_ERRNO; + + if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) + { + err=deflateEnd(&zi->ci.stream); + zi->ci.stream_initialised = 0; + } + + if (!zi->ci.raw) + { + crc32 = (uLong)zi->ci.crc32; + uncompressed_size = (uLong)zi->ci.stream.total_in; + } + compressed_size = (uLong)zi->ci.stream.total_out; +# ifndef NOCRYPT + compressed_size += zi->ci.crypt_header_size; +# endif + + ziplocal_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/ + ziplocal_putValue_inmemory(zi->ci.central_header+20, + compressed_size,4); /*compr size*/ + if (zi->ci.stream.data_type == Z_ASCII) + ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2); + ziplocal_putValue_inmemory(zi->ci.central_header+24, + uncompressed_size,4); /*uncompr size*/ + + if (err==ZIP_OK) + err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header, + (uLong)zi->ci.size_centralheader); + free(zi->ci.central_header); + + if (err==ZIP_OK) + { + long cur_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); + if (ZSEEK(zi->z_filefunc,zi->filestream, + zi->ci.pos_local_header + 14,ZLIB_FILEFUNC_SEEK_SET)!=0) + err = ZIP_ERRNO; + + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */ + + if (err==ZIP_OK) /* compressed size, unknown */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4); + + if (err==ZIP_OK) /* uncompressed size, unknown */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,uncompressed_size,4); + + if (ZSEEK(zi->z_filefunc,zi->filestream, + cur_pos_inzip,ZLIB_FILEFUNC_SEEK_SET)!=0) + err = ZIP_ERRNO; + } + + zi->number_entry ++; + zi->in_opened_file_inzip = 0; + + return err; +} + +extern int ZEXPORT zipCloseFileInZip (file) + zipFile file; +{ + return zipCloseFileInZipRaw (file,0,0); +} + +extern int ZEXPORT zipClose (file, global_comment) + zipFile file; + const char* global_comment; +{ + zip_internal* zi; + int err = 0; + uLong size_centraldir = 0; + uLong centraldir_pos_inzip ; + uInt size_global_comment; + if (file == NULL) + return ZIP_PARAMERROR; + zi = (zip_internal*)file; + + if (zi->in_opened_file_inzip == 1) + { + err = zipCloseFileInZip (file); + } + + if (global_comment==NULL) + size_global_comment = 0; + else + size_global_comment = strlen(global_comment); + + + centraldir_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); + if (err==ZIP_OK) + { + linkedlist_datablock_internal* ldi = zi->central_dir.first_block ; + while (ldi!=NULL) + { + if ((err==ZIP_OK) && (ldi->filled_in_this_block>0)) + if (ZWRITE(zi->z_filefunc,zi->filestream, + ldi->data,ldi->filled_in_this_block) + !=ldi->filled_in_this_block ) + err = ZIP_ERRNO; + + size_centraldir += ldi->filled_in_this_block; + ldi = ldi->next_datablock; + } + } + free_datablock(zi->central_dir.first_block); + + if (err==ZIP_OK) /* Magic End */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4); + + if (err==ZIP_OK) /* number of this disk */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); + + if (err==ZIP_OK) /* number of the disk with the start of the central directory */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); + + if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); + + if (err==ZIP_OK) /* total number of entries in the central dir */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); + + if (err==ZIP_OK) /* size of the central directory */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4); + + if (err==ZIP_OK) /* offset of start of central directory with respect to the + starting disk number */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream, + (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4); + + if (err==ZIP_OK) /* zipfile comment length */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_global_comment,2); + + if ((err==ZIP_OK) && (size_global_comment>0)) + if (ZWRITE(zi->z_filefunc,zi->filestream, + global_comment,size_global_comment) != size_global_comment) + err = ZIP_ERRNO; + + if (ZCLOSE(zi->z_filefunc,zi->filestream) != 0) + if (err == ZIP_OK) + err = ZIP_ERRNO; + + TRYFREE(zi); + + return err; +} diff --git a/kicad/minizip/zip.h b/kicad/minizip/zip.h new file mode 100644 index 0000000000..dd13b57121 --- /dev/null +++ b/kicad/minizip/zip.h @@ -0,0 +1,235 @@ +/* zip.h -- IO for compress .zip files using zlib + Version 1.00, September 10th, 2003 + + Copyright (C) 1998-2003 Gilles Vollant + + This unzip package allow creates .ZIP file, compatible with PKZip 2.04g + WinZip, InfoZip tools and compatible. + Encryption and multi volume ZipFile (span) are not supported. + Old compressions used by old PKZip 1.x are not supported + + For uncompress .zip file, look at unzip.h + + + I WAIT FEEDBACK at mail info@winimage.com + Visit also http://www.winimage.com/zLibDll/unzip.html for evolution + + Condition of use and distribution are the same than zlib : + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + +*/ + +/* for more info about .ZIP format, see + http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip + http://www.info-zip.org/pub/infozip/doc/ + PkWare has also a specification at : + ftp://ftp.pkware.com/probdesc.zip +*/ + +#ifndef _zip_H +#define _zip_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ZLIB_H +#include "zlib.h" +#endif + +#ifndef _ZLIBIOAPI_H +#include "ioapi.h" +#endif + +#if defined(STRICTZIP) || defined(STRICTZIPUNZIP) +/* like the STRICT of WIN32, we define a pointer that cannot be converted + from (void*) without cast */ +typedef struct TagzipFile__ { int unused; } zipFile__; +typedef zipFile__ *zipFile; +#else +typedef voidp zipFile; +#endif + +#define ZIP_OK (0) +#define ZIP_EOF (0) +#define ZIP_ERRNO (Z_ERRNO) +#define ZIP_PARAMERROR (-102) +#define ZIP_BADZIPFILE (-103) +#define ZIP_INTERNALERROR (-104) + +#ifndef DEF_MEM_LEVEL +# if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +# else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +# endif +#endif +/* default memLevel */ + +/* tm_zip contain date/time info */ +typedef struct tm_zip_s +{ + uInt tm_sec; /* seconds after the minute - [0,59] */ + uInt tm_min; /* minutes after the hour - [0,59] */ + uInt tm_hour; /* hours since midnight - [0,23] */ + uInt tm_mday; /* day of the month - [1,31] */ + uInt tm_mon; /* months since January - [0,11] */ + uInt tm_year; /* years - [1980..2044] */ +} tm_zip; + +typedef struct +{ + tm_zip tmz_date; /* date in understandable format */ + uLong dosDate; /* if dos_date == 0, tmu_date is used */ +/* uLong flag; */ /* general purpose bit flag 2 bytes */ + + uLong internal_fa; /* internal file attributes 2 bytes */ + uLong external_fa; /* external file attributes 4 bytes */ +} zip_fileinfo; + +typedef const char* zipcharpc; + + +#define APPEND_STATUS_CREATE (0) +#define APPEND_STATUS_CREATEAFTER (1) +#define APPEND_STATUS_ADDINZIP (2) + +extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); +/* + Create a zipfile. + pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on + an Unix computer "zlib/zlib113.zip". + if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip + will be created at the end of the file. + (useful if the file contain a self extractor code) + if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will + add files in existing zip (be sure you don't add file that doesn't exist) + If the zipfile cannot be opened, the return value is NULL. + Else, the return value is a zipFile Handle, usable with other function + of this zip package. +*/ + +/* Note : there is no delete function into a zipfile. + If you want delete file into a zipfile, you must open a zipfile, and create another + Of couse, you can use RAW reading and writing to copy the file you did not want delte +*/ + +extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, + int append, + zipcharpc* globalcomment, + zlib_filefunc_def* pzlib_filefunc_def)); + +extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level)); +/* + Open a file in the ZIP for writing. + filename : the filename in zip (if NULL, '-' without quote will be used + *zipfi contain supplemental information + if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local + contains the extrafield data the the local header + if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global + contains the extrafield data the the local header + if comment != NULL, comment contain the comment string + method contain the compression method (0 for store, Z_DEFLATED for deflate) + level contain the level of compression (can be Z_DEFAULT_COMPRESSION) +*/ + + +extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw)); + +/* + Same than zipOpenNewFileInZip, except if raw=1, we write raw file + */ + +extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCtypting)); + +/* + Same than zipOpenNewFileInZip2, except + windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 + password : crypting password (NULL for no crypting) + crcForCtypting : crc of file to compress (needed for crypting) + */ + + +extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, + const void* buf, + unsigned len)); +/* + Write data in the zipfile +*/ + +extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); +/* + Close the current file in the zipfile +*/ + + +extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, + uLong uncompressed_size, + uLong crc32)); +/* + Close the current file in the zipfile, for fiel opened with + parameter raw=1 in zipOpenNewFileInZip2 + uncompressed_size and crc32 are value for the uncompressed size +*/ + +extern int ZEXPORT zipClose OF((zipFile file, + const char* global_comment)); +/* + Close the zipfile +*/ + +#ifdef __cplusplus +} +#endif + +#endif /* _zip_H */ diff --git a/kicad/preferences.cpp b/kicad/preferences.cpp new file mode 100644 index 0000000000..3415e2d6a4 --- /dev/null +++ b/kicad/preferences.cpp @@ -0,0 +1,121 @@ + /******************************************************************/ + /* mdiframe.cpp - fonctions de la classe du type WinEDA_MainFrame */ + /******************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" + +#include "common.h" + +#include "bitmaps.h" +#include "protos.h" + +#include "id.h" + +#include "kicad.h" + +#include + +/****************************************************************/ +void WinEDA_MainFrame::Process_Preferences(wxCommandEvent& event) +/*****************************************************************/ +{ +int id = event.GetId(); +wxString FullFileName; +wxString mask(wxT("*")); +#ifdef __WINDOWS__ +mask += wxT(".exe"); +#endif + + switch (id) + { + case ID_SELECT_DEFAULT_PDF_BROWSER: + EDA_Appl->m_PdfBrowserIsDefault = TRUE; + GetMenuBar()->Check(ID_SELECT_DEFAULT_PDF_BROWSER, EDA_Appl->m_PdfBrowserIsDefault); + GetMenuBar()->Check(ID_SELECT_PREFERED_PDF_BROWSER, !EDA_Appl->m_PdfBrowserIsDefault); + EDA_Appl->WritePdfBrowserInfos(); + break; + + case ID_SELECT_PREFERED_PDF_BROWSER: + if ( EDA_Appl->m_PdfBrowser.IsEmpty() ) + { + DisplayError(this, _("You must choose a PDF wiever before use this option")); + break; + } + EDA_Appl->m_PdfBrowserIsDefault = FALSE; + GetMenuBar()->Check(ID_SELECT_DEFAULT_PDF_BROWSER, EDA_Appl->m_PdfBrowserIsDefault); + GetMenuBar()->Check(ID_SELECT_PREFERED_PDF_BROWSER, !EDA_Appl->m_PdfBrowserIsDefault); + EDA_Appl->WritePdfBrowserInfos(); + break; + + case ID_SELECT_PREFERED_PDF_BROWSER_NAME: + EDA_Appl->ReadPdfBrowserInfos(); + FullFileName = EDA_Appl->m_PdfBrowser; + FullFileName = EDA_FileSelector( _("Prefered Pdf Browser:"), + wxPathOnly(FullFileName), /* Default path */ + FullFileName, /* default filename */ + wxEmptyString, /* default filename extension */ + mask, /* filter for filename list */ + this, /* parent frame */ + wxFD_OPEN, /* wxFD_SAVE, wxFD_OPEN ..*/ + TRUE /* true = keep the current path */ + ); + if ( ! FullFileName.IsEmpty() && (EDA_Appl->m_PdfBrowser != FullFileName) ) + { + EDA_Appl->m_PdfBrowser = FullFileName; + EDA_Appl->WritePdfBrowserInfos(); + } + break; + + case ID_SELECT_PREFERED_EDITOR: + FullFileName = EDA_FileSelector( _("Prefered Editor:"), + wxPathOnly(g_EditorName), /* Default path */ + g_EditorName, /* default filename */ + wxEmptyString, /* default filename extension */ + mask, /* filter for filename list */ + this, /* parent frame */ + wxFD_OPEN, /* wxFD_SAVE, wxFD_OPEN ..*/ + TRUE /* true = keep the current path */ + ); + if ( ( !FullFileName.IsEmpty() ) && EDA_Appl->m_EDA_CommonConfig) + { + g_EditorName = FullFileName; + EDA_Appl->m_EDA_CommonConfig->Write(wxT("Editor"), g_EditorName); + } + break; + + case ID_PREFERENCES_FONT_INFOSCREEN: + { + wxFont font = wxGetFontFromUser(this, *g_StdFont); + if ( font.Ok() ) + { + int pointsize = font.GetPointSize(); + *g_StdFont = font; + g_StdFontPointSize = pointsize; + g_DialogFontPointSize = pointsize; + g_FixedFontPointSize = pointsize; + m_LeftWin->ReCreateTreePrj(); + m_DialogWin->SetFont(* g_StdFont); + m_DialogWin->Refresh(); + } + break; + } + + default: DisplayError(this, wxT("WinEDA_MainFrame::Process_Preferences Internal Error") ); + break; + } +} + +/********************************************************/ +void WinEDA_MainFrame::SetLanguage(wxCommandEvent& event) +/********************************************************/ +{ +int id = event.GetId(); + + m_Parent->SetLanguageIdentifier(id ); + m_Parent->SetLanguage(); +} + diff --git a/kicad/prjconfig.cpp b/kicad/prjconfig.cpp new file mode 100644 index 0000000000..d3c95bd419 --- /dev/null +++ b/kicad/prjconfig.cpp @@ -0,0 +1,64 @@ + /*************************************************************/ + /** prjconfig.cpp : load and save configuration (file *.pro) */ + /*************************************************************/ + + +#include "fctsys.h" +#include "common.h" +#include "kicad.h" +#include "protos.h" +#include "prjconfig.h" + +/* Variables locales */ + + +/*******************************************/ +void WinEDA_MainFrame::Load_Prj_Config(void) +/*******************************************/ +{ + + if ( ! wxFileExists(m_PrjFileName) ) + { + wxString msg = _("Project File <") + m_PrjFileName + _("> not found"); + DisplayError(this, msg); + return; + } + + wxSetWorkingDirectory(wxPathOnly(m_PrjFileName) ); + SetTitle(g_Main_Title + wxT(" ") + GetBuildVersion() + wxT(" ") + m_PrjFileName); + ReCreateMenuBar(); + m_LeftWin->ReCreateTreePrj(); + + wxString msg = _("\nWorking dir: ") + wxGetCwd(); + msg << _("\nProject: ") << m_PrjFileName << wxT("\n"); + PrintMsg(msg); +} + + +/*********************************************/ +void WinEDA_MainFrame::Save_Prj_Config(void) +/*********************************************/ +{ +wxString FullFileName; +wxString mask( wxT("*")); + + g_Prj_Config_Filename_ext = wxT(".pro"); + mask += g_Prj_Config_Filename_ext; + FullFileName = m_PrjFileName; + ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext); + + FullFileName = EDA_FileSelector(_("Save config file"), + wxGetCwd(), /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + g_Prj_Config_Filename_ext, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + TRUE + ); + if ( FullFileName.IsEmpty() ) return; + + /* ecriture de la configuration */ + EDA_Appl->WriteProjectConfig(FullFileName, wxT("/general"), CfgParamList); +} + diff --git a/kicad/prjconfig.h b/kicad/prjconfig.h new file mode 100644 index 0000000000..450165a132 --- /dev/null +++ b/kicad/prjconfig.h @@ -0,0 +1,28 @@ + /**********************************************************/ + /* prjconfig.h : configuration: definition des structures */ + /**********************************************************/ + + + +/* Liste des parametres */ + +static PARAM_CFG_WXSTRING SchematicRootFileNameCfg +( + wxT("RootSch"), /* identification */ + &g_SchematicRootFileName /* Adresse du parametre */ +); + +static PARAM_CFG_WXSTRING BoardFileNameCfg +( + wxT("BoardNm"), /* identification */ + &g_BoardFileName /* Adresse du parametre */ +); + + +static PARAM_CFG_BASE * CfgParamList[] = +{ + & SchematicRootFileNameCfg, + & BoardFileNameCfg, + NULL +}; + diff --git a/kicad/protos.h b/kicad/protos.h new file mode 100644 index 0000000000..ace699050f --- /dev/null +++ b/kicad/protos.h @@ -0,0 +1,2 @@ +/* prototypes de fonctions */ + diff --git a/kicad/treeprj.cpp b/kicad/treeprj.cpp new file mode 100644 index 0000000000..6a1cb39677 --- /dev/null +++ b/kicad/treeprj.cpp @@ -0,0 +1,169 @@ +/***************/ +/* treeprj.cpp */ +/***************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" + +#include "kicad.h" +#include "protos.h" + +#include "wx/image.h" +#include "wx/imaglist.h" +#include "wx/treectrl.h" + +#include "bitmaps.h" + +#include "id.h" + +enum { + TREE_PROJECT = 1, + TREE_SCHEMA, + TREE_PCB +}; + +/***********************************************************/ +/* Classes pour l'arbre de hierarchie de gestion du projet */ +/***********************************************************/ +class TreePrjItemData: public wxTreeItemData +{ +public: + int m_Id; + wxString m_FileName; + +public: + TreePrjItemData(int tree_id, const wxString & data) :wxTreeItemData() + { + m_Id = tree_id; + if ( data ) m_FileName = data; + } +}; + + + +/**********************************************************************/ +/* Methodes de la Frame de l'arbre de hierarchie de gestion du projet */ +/**********************************************************************/ + +WinEDA_PrjFrame::WinEDA_PrjFrame(WinEDA_MainFrame * parent, + const wxPoint & pos, + const wxSize & size ) : + wxSashLayoutWindow(parent, ID_LEFT_FRAME, pos, size, + wxNO_BORDER|wxSW_3D) +{ + m_Parent = parent; + m_TreeProject = NULL; + ReCreateTreePrj(); +} + +BEGIN_EVENT_TABLE(WinEDA_PrjFrame, wxSashLayoutWindow) + EVT_TREE_ITEM_ACTIVATED(ID_PROJECT_TREE, WinEDA_PrjFrame::OnSelect) +END_EVENT_TABLE() + + +/******************************************/ +void WinEDA_PrjFrame::ReCreateTreePrj(void) +/******************************************/ +/* Create or modify the tree showing root schematic and pcb file names +*/ +{ +wxTreeItemId rootcellule; +wxTreeItemId cellule; +wxString Text; +int id; + + if ( ! m_TreeProject ) m_TreeProject = new WinEDA_TreePrj(this); + else m_TreeProject->DeleteAllItems(); + + m_TreeProject->SetFont(* g_StdFont); + if (m_Parent->m_PrjFileName.IsEmpty() ) Text = wxT("noname"); + else Text = wxFileNameFromPath(m_Parent->m_PrjFileName); + + id = 0; + rootcellule = m_TreeProject->AddRoot(Text, id, id); + m_TreeProject->SetItemBold(rootcellule, TRUE); + m_TreeProject->SetItemData( rootcellule, new TreePrjItemData(TREE_PROJECT, wxEmptyString) ); + m_TreeProject->SetItemFont(rootcellule, *g_StdFont); + + ChangeFileNameExt(Text, wxEmptyString); + + id++; + cellule = m_TreeProject->AppendItem(rootcellule,Text + g_SchExtBuffer, id, id); + m_TreeProject->SetItemData( cellule, new TreePrjItemData(TREE_SCHEMA, wxEmptyString) ); + m_TreeProject->SetItemFont(cellule, *g_StdFont); + g_SchematicRootFileName = m_TreeProject->GetItemText(cellule); + + id++; + cellule = m_TreeProject->AppendItem(rootcellule,Text + g_BoardExtBuffer, id, id); + m_TreeProject->SetItemData( cellule, new TreePrjItemData(TREE_PCB, wxEmptyString) ); + m_TreeProject->SetItemFont(cellule, *g_StdFont); + g_BoardFileName = m_TreeProject->GetItemText(cellule); + + m_TreeProject->Expand(rootcellule); +} + +/**************************************************/ +void WinEDA_PrjFrame::OnSelect(wxTreeEvent & Event) +/**************************************************/ +{ +int tree_id; +TreePrjItemData * tree_data; +wxString FullFileName; + + tree_data = (TreePrjItemData*) + m_TreeProject->GetItemData(m_TreeProject->GetSelection()); + + tree_id = tree_data->m_Id; + FullFileName = m_Parent->m_PrjFileName; + + switch ( tree_id ) + { + case TREE_PROJECT: + break; + + case TREE_SCHEMA: + { + ChangeFileNameExt(FullFileName, g_SchExtBuffer); + AddDelimiterString( FullFileName ); + ExecuteFile(this, EESCHEMA_EXE, FullFileName); + break; + } + + case TREE_PCB: + ChangeFileNameExt(FullFileName, g_BoardExtBuffer); + AddDelimiterString( FullFileName ); + ExecuteFile(this, PCBNEW_EXE, FullFileName); + break; + } +} + + +/********************************************/ +/* Methodes pour l'arbre gestion du projet */ +/********************************************/ + +WinEDA_TreePrj::WinEDA_TreePrj(WinEDA_PrjFrame * parent) : + wxTreeCtrl(parent, ID_PROJECT_TREE, + wxDefaultPosition, wxDefaultSize, + wxTR_HAS_BUTTONS, wxDefaultValidator, wxT("EDATreeCtrl")) +{ + m_Parent = parent; + // Make an image list containing small icons + m_ImageList = new wxImageList(16, 16, TRUE, 2); + + m_ImageList->Add(wxBitmap(kicad_icon_small_xpm)); + m_ImageList->Add(wxBitmap(eeschema_xpm)); + m_ImageList->Add(wxBitmap(pcbnew_xpm)); + + SetImageList(m_ImageList); + +} + +/********************************/ +WinEDA_TreePrj::~WinEDA_TreePrj() +/********************************/ +{ +} + + diff --git a/libs.linux b/libs.linux new file mode 100644 index 0000000000..201c0702d8 --- /dev/null +++ b/libs.linux @@ -0,0 +1,79 @@ + +#Configuration for build kicad +KICAD_BIN = /usr/local/kicad/linux + + +SRCSUFF = .cpp +OBJSUFF = .o +FINAL = 1 + + +# You must comment or uncomment this line for dynamic or static link +# dynamic link is less difficult than static link +# choose it if you have problems (libs not found, or unresolved references) ), or if kicad is running only on YOUR system. +KICAD_STATIC_LINK = 1 + +# path and version definition for wxWidgets and mesa libs +MESALIBSPATH = /usr/local/lib +WXPATH = `wx-config --prefix`/lib +PREFIX_WX_LIBS = lib`wx-config --basename` +SUFFIX_WX_LIBSTD = `wx-config --utility=` +SUFFIX_WX_LIBGL = _gl-$(LIBVERSION).a + +# Use static link for libstdc++.a (sometimes also libsupc++.a) +# locate libstdc++.a and copy it in kicad_dev/syslibs +ifdef KICAD_STATIC_LINK +#define path for a copy of libstdc++.a or/and libsupc++.a: +LIBSTDC = ../syslibs/libstdc++.a +else +# Or Use static link for libsupc++ or libstdc++ (more easy!!) +LIBSTDC = -lstdc++ +endif + +LIBVERSION=`wx-config --release` + +# use link static for wxWidgets +ifdef KICAD_STATIC_LINK +LIBS3D = $(WXPATH)/$(PREFIX_WX_LIBS)$(SUFFIX_WX_LIBGL)\ + $(MESALIBSPATH)/libGL.a $(MESALIBSPATH)/libGLU.a + +WXSYSLIB= $(WXPATH)/$(PREFIX_WX_LIBS)-$(LIBVERSION).a \ + $(WXPATH)/libwxpng-$(LIBVERSION).a\ + $(WXPATH)/libwxjpeg-$(LIBVERSION).a\ + $(WXPATH)/libwxzlib-$(LIBVERSION).a\ + /usr/X11R6/lib/libXinerama.a \ + /usr/X11R6/lib/libXxf86vm.a \ + -lgtk-x11-2.0 -lgdk-x11-2.0 \ + -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lgthread-2.0\ + -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl\ + -lglib-2.0 -lpangoft2-1.0 -lSM\ + -L/usr/lib + + +WXSYSLIB_WITH_GL= $(WXPATH)/$(PREFIX_WX_LIBS)-$(LIBVERSION).a \ + $(WXPATH)/libwxpng-$(LIBVERSION).a\ + $(WXPATH)/libwxjpeg-$(LIBVERSION).a\ + $(WXPATH)/libwxzlib-$(LIBVERSION).a\ + $(LIBS3D)\ + /usr/X11R6/lib/libXinerama.a \ + /usr/X11R6/lib/libXxf86vm.a \ + -lgtk-x11-2.0 -lgdk-x11-2.0 \ + -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lgthread-2.0\ + -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl\ + -lglib-2.0 -lpangoft2-1.0 -lSM\ + -L/usr/lib +else +#or use "standard command" for wxWidgets +WXSYSLIB= `wx-config --libs std` +WXSYSLIB_WITH_GL= `wx-config --libs std,gl` +endif + + +# attention à l'ordre des libairies +LIBS = -L/usr/local/lib -L/usr/X11R6/lib\ + $(EXTRALIBS) $(WXSYSLIB)\ + $(LIBSTDC) + +LIBS_WITH_GL = -L/usr/local/lib -L/usr/X11R6/lib\ + $(EXTRALIBS) $(WXSYSLIB_WITH_GL)\ + $(LIBSTDC) diff --git a/libs.macosx b/libs.macosx new file mode 100644 index 0000000000..e41bb39198 --- /dev/null +++ b/libs.macosx @@ -0,0 +1,13 @@ +#Configuration for build kicad +KICAD_BIN = /usr/local/kicad/macosx + +RESCOMP = /Developer/Tools/Rez -d __DARWIN__ -t APPL -d __WXMAC__ -i . +SETFILE = /Developer/Tools/SetFile + +SRCSUFF = .cpp +OBJSUFF = .o +FINAL = 1 + +LIBS = ../common/common.a `wx-config --libs` +LIBS3D = ../common/common.a `wx-config --libs std,gl` + diff --git a/libs.win b/libs.win new file mode 100644 index 0000000000..0141975258 --- /dev/null +++ b/libs.win @@ -0,0 +1,58 @@ +# File: winmake.env +#binaries path: +KICAD_BIN = /f/kicad/winexe + + + +# Target WXMAKINGDLL WXUSINGDLL WXBUILDDLL +# wxWin DLL 1 0 1 +# wxWin STATIC 0 0 0 +# App use wxWin DLL 0 1 0 +# DLL use wxWin DLL 0 1 1 +# DLL use wxWin STATIC 0 0 1 +# + +#Define the wxWidget path (if not found in environment variables): +ifndef WXWIN +WXWIN=/f/wxMSW-2.8.1 +endif +LIBVERSION = 2.8 + + +#comment this for static wxWidgets link +#WXUSINGDLL = 1 + +FINAL = 1 + +ALL_CPPFLAGS = `$(WXWIN)/wx-config --cppflags` + +EDACPPFLAGS = $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $(EXTRACPPFLAGS) + +EDALIBS = $(EXTRALIBS) + +SYSWXLIB = `$(WXWIN)/wx-config --libs gl`\ + -lwxpng-$(LIBVERSION) -lwxjpeg-$(LIBVERSION) -lwxzlib-$(LIBVERSION) + +.cpp.o: + gcc -c -Wall $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $(EXTRACPPFLAGS) -o $@ $*.cpp + + +# Settings for Cyginw/Mingw32 +# Some versions of windres cannot cope with the --preprocessor +# option. Uncomment the RCPREPROCESSOR line below if yours can. +ifndef WINE +RESCOMP=$(CROSS)windres $(_USE_TEMP_FILE_IF_SUPPORTED) +else +RESCOMP=wrc +endif +RCINPUTSWITCH=-i +RCOUTPUTSWITCH=-o +RCINCSWITCH=--include-dir +RCDEFSWITCH=--define +# Note that this can cause windres to fail (Win95/98 problem?) +# but commenting out RCPREPROCESSOR then does the trick. +#RCPREPROCESSOR=--preprocessor "$(CXX) -c -E -xc-header -DRC_INVOKED" + +# Don't make this too long (e.g. by adding contrib/include/wx) because it will +# truncate the command line +RESFLAGS=$(RCPREPROCESSOR) $(RCINCSWITCH) $(WXDIR)/include $(RCEXTRAINC) $(RCDEFSWITCH) __WIN32__ $(RCDEFSWITCH) __WIN95__ $(RCDEFSWITCH) __GNUWIN32__ diff --git a/make_static.linux b/make_static.linux new file mode 100644 index 0000000000..03650b8a99 --- /dev/null +++ b/make_static.linux @@ -0,0 +1,17 @@ +KICAD_SUBDIRS = common 3d-viewer eeschema eeschema/plugins pcbnew cvpcb kicad gerbview +KICAD_SUBDIRS_BIN = eeschema eeschema/plugins pcbnew cvpcb kicad gerbview + +# How to invoke make: +MAKE = make -k -f makefile.gtk KICAD_STATIC_LINK=1 +MAKE_INSTALL = make -f makefile.gtk install + +ERASE = rm -f *.o + +all: + @for d in $(KICAD_SUBDIRS); do (cd $$d && $(MAKE)); done + +install: + @for d in $(KICAD_SUBDIRS_BIN); do (cd $$d && $(MAKE_INSTALL)); done + +clean: + @for d in $(KICAD_SUBDIRS); do (cd $$d && $(ERASE)); done diff --git a/makefile.g95 b/makefile.g95 new file mode 100644 index 0000000000..f0f4e9ee76 --- /dev/null +++ b/makefile.g95 @@ -0,0 +1,16 @@ +KICAD_SUBDIRS = common 3d-viewer eeschema eeschema/plugins pcbnew kicad cvpcb gerbview +KICAD_SUBDIRS_BIN = eeschema eeschema/plugins pcbnew cvpcb kicad gerbview +# How to invoke make: +MAKE = make -k -f makefile.g95 +MAKE_INSTALL = make -f makefile.g95 install +MAKE_CLEAN = make -f makefile.g95 clean + +all: + @for d in $(KICAD_SUBDIRS); do (cd $$d && $(MAKE)); done + +install: + @for d in $(KICAD_SUBDIRS_BIN); do (cd $$d && $(MAKE_INSTALL)); done + +clean: + @for d in $(KICAD_SUBDIRS); do (cd $$d && $(MAKE_CLEAN)); done + \ No newline at end of file diff --git a/makefile.gtk b/makefile.gtk new file mode 100644 index 0000000000..0acd553ee5 --- /dev/null +++ b/makefile.gtk @@ -0,0 +1,15 @@ +KICAD_SUBDIRS = common 3d-viewer eeschema eeschema/plugins pcbnew cvpcb kicad gerbview +KICAD_SUBDIRS_BIN = eeschema eeschema/plugins pcbnew cvpcb kicad gerbview +# How to invoke make: +MAKE = make -k -f makefile.gtk +MAKE_INSTALL = make -f makefile.gtk install +MAKE_CLEAN = make -f makefile.gtk clean + +all: + @for d in $(KICAD_SUBDIRS); do (cd $$d && $(MAKE)); done + +install: + @for d in $(KICAD_SUBDIRS_BIN); do (cd $$d && $(MAKE_INSTALL)); done + +clean: + @for d in $(KICAD_SUBDIRS); do (cd $$d && $(MAKE_CLEAN)); done diff --git a/makefile.macosx b/makefile.macosx new file mode 100644 index 0000000000..ec5cbeaf6c --- /dev/null +++ b/makefile.macosx @@ -0,0 +1,16 @@ +KICAD_SUBDIRS = common 3d-viewer eeschema eeschema/plugins pcbnew cvpcb kicad gerbview +KICAD_SUBDIRS_BIN = eeschema eeschema/plugins pcbnew cvpcb kicad gerbview +# How to invoke make: +MAKE = make -k -f makefile.macosx +MAKE_INSTALL = make -f makefile.macosx install +MAKE_CLEAN = make -f makefile.macosx clean + + +all: + @for d in $(KICAD_SUBDIRS); do (cd $$d && $(MAKE)); done + +install: + @for d in $(KICAD_SUBDIRS_BIN); do (cd $$d && $(MAKE_INSTALL)); done + +clean: + @for d in $(KICAD_SUBDIRS); do (cd $$d && $(MAKE_CLEAN)); done diff --git a/mybuild_wxWidgets_linux.txt b/mybuild_wxWidgets_linux.txt new file mode 100644 index 0000000000..6fdf415ca2 --- /dev/null +++ b/mybuild_wxWidgets_linux.txt @@ -0,0 +1,2 @@ +rm *.cache +./configure --enable-monolithic --enable-unicode=no --enable-shared=no --with-opengl --disable-compat24 --with-libpng=builtin --with-libjpeg=builtin --with-libtiff=builtin --with-zlib=builtin --with-regex=builtin diff --git a/mybuild_wxWidgets_linux_unicode.txt b/mybuild_wxWidgets_linux_unicode.txt new file mode 100644 index 0000000000..8804540664 --- /dev/null +++ b/mybuild_wxWidgets_linux_unicode.txt @@ -0,0 +1,2 @@ +rm *.cache +./configure --enable-monolithic --enable-unicode=yes --enable-shared=no --with-opengl --disable-compat24 --with-libpng=builtin --with-libjpeg=builtin --with-libtiff=builtin --with-zlib=builtin --with-regex=builtin diff --git a/mybuild_wxWidgets_macosX.txt b/mybuild_wxWidgets_macosX.txt new file mode 100644 index 0000000000..a23fb25b14 --- /dev/null +++ b/mybuild_wxWidgets_macosX.txt @@ -0,0 +1,2 @@ +rm *.cache +./configure --enable-unicode=yes --enable-shared=no --enable-monolithic --with-opengl --disable-universal --disable-compat24 diff --git a/mybuild_wxWidgets_macosX_unicode.txt b/mybuild_wxWidgets_macosX_unicode.txt new file mode 100644 index 0000000000..a23fb25b14 --- /dev/null +++ b/mybuild_wxWidgets_macosX_unicode.txt @@ -0,0 +1,2 @@ +rm *.cache +./configure --enable-unicode=yes --enable-shared=no --enable-monolithic --with-opengl --disable-universal --disable-compat24 diff --git a/mybuild_wxWidgets_windows.txt b/mybuild_wxWidgets_windows.txt new file mode 100644 index 0000000000..45e208a2fb --- /dev/null +++ b/mybuild_wxWidgets_windows.txt @@ -0,0 +1,2 @@ +rm *.cache +./configure --enable-unicode=no --enable-shared=no --enable-monolithic --with-msw --disable-compat24 --with-opengl --with-odbc diff --git a/mybuild_wxWidgets_windows_unicode.txt b/mybuild_wxWidgets_windows_unicode.txt new file mode 100644 index 0000000000..604ca16290 --- /dev/null +++ b/mybuild_wxWidgets_windows_unicode.txt @@ -0,0 +1,2 @@ +rm *.cache +./configure --enable-unicode=yes --enable-shared=no --enable-monolithic --with-msw --disable-compat24 --with-opengl --with-odbc diff --git a/nsis_win_installer/English.nsh b/nsis_win_installer/English.nsh new file mode 100644 index 0000000000..3ead92f332 --- /dev/null +++ b/nsis_win_installer/English.nsh @@ -0,0 +1,28 @@ +;Additional text definitions for English + +;File name of license file +LicenseLangString MUILicense ${LANG_ENGLISH} "..\licendoc.txt" + +;Component option +LangString TITLE_SEC01 ${LANG_ENGLISH} "Main application" +LangString TITLE_SEC02 ${LANG_ENGLISH} "Libraries and components" +LangString TITLE_SEC03 ${LANG_ENGLISH} "Demonstration projects" +LangString TITLE_SEC04 ${LANG_ENGLISH} "Help files" + +;Component option descriptions +LangString DESC_SEC01 ${LANG_ENGLISH} "Main application files." +LangString DESC_SEC02 ${LANG_ENGLISH} "Libraries and components are required unless they have been previously installed." +LangString DESC_SEC03 ${LANG_ENGLISH} "Some demonstration projects and tutorials." +LangString DESC_SEC04 ${LANG_ENGLISH} "Help files." + +;General messages +LangString WINGS3D_PROMPT ${LANG_ENGLISH} "To edit or create 3D object models you need to install Wings3D. \ +Wings3D and user manual can be download free from the Wings3D web page Check this box to open the Wings3D web page" + +LangString UNINST_PROMPT ${LANG_ENGLISH} "Are you sure you want to completely remove $(^Name) and all of its components? $\n\ +This will also remove all modified and new files, libraries and modules in the program directory" + +LangString UNINST_SUCCESS ${LANG_ENGLISH} "$(^Name) was successfully removed from your computer." +LangString INSTALLER_RUNNING ${LANG_ENGLISH} "The installer is already running." +LangString UNINSTALLER_RUNNING ${LANG_ENGLISH} "The uninstaller is already running." +LangString ALREADY_INSTALLED ${LANG_ENGLISH} "${PRODUCT_NAME} is already installed. Install this package will overwrite existing files. Do you want to continue?" \ No newline at end of file diff --git a/nsis_win_installer/French.nsh b/nsis_win_installer/French.nsh new file mode 100644 index 0000000000..57e8a9c4c8 --- /dev/null +++ b/nsis_win_installer/French.nsh @@ -0,0 +1,31 @@ +;Additional text definitions for French +;These text definition have been translated from English using an automated translation tool +;Please correct as required + +;file name of license file +LicenseLangString MUILicense ${LANG_FRENCH} "..\licendoc.txt" + +;Component options +LangString TITLE_SEC01 ${LANG_FRENCH} "Application principale" +LangString TITLE_SEC02 ${LANG_FRENCH} "Bibliothèques et composants" +LangString TITLE_SEC03 ${LANG_FRENCH} "Demos" +LangString TITLE_SEC04 ${LANG_FRENCH} "Dossiers d'aide" + +;Component option descriptions +LangString DESC_SEC01 ${LANG_FRENCH} "Dossiers de base." +LangString DESC_SEC02 ${LANG_FRENCH} "Les bibliothèques sont nécessaires à moins d'avoir été précédemment installées." +LangString DESC_SEC03 ${LANG_FRENCH} "Quelques dossiers de demonstration." +LangString DESC_SEC04 ${LANG_FRENCH} "Dossiers d'aide." + +;General messages +LangString WINGS3D_PROMPT ${LANG_FRENCH} "Pour éditer ou créer des modèles 3D des modules PCB, vous devez installer Wings3D. \ +Wings3D et manuel d'utilisateur peuvent être téléchargement librement de la page Web de Wings3D.\ +Cochez cette boîte pour acceder à la page Web de Wings3D." + +LangString UNINST_PROMPT ${LANG_FRENCH} "Êtes-vous sûr de vouloir enlever complètement ${PRODUCT_NAME} et tous ses composants ? $\n\ +Ceci enlèvera également tous les dossiers, bibliothèques et modules modifiés et nouveaux dans le repertoire $(^name)" + +LangString UNINST_SUCCESS ${LANG_FRENCH} "$(^Name) a été avec succès enlevé à partir de votre ordinateur." +LangString INSTALLER_RUNNING ${LANG_FRENCH} "L'installateur fonctionne déjà." +LangString UNINSTALLER_RUNNING ${LANG_FRENCH} "Le desinstalleur fonctionne déjà." +LangString ALREADY_INSTALLED ${LANG_FRENCH} "${PRODUCT_NAME} est déjà installé. Installer ce paquet remplacera les dossiers existants. Voulez-vous continuer ?" \ No newline at end of file diff --git a/nsis_win_installer/Installer Docs.odt b/nsis_win_installer/Installer Docs.odt new file mode 100644 index 0000000000000000000000000000000000000000..0e439dbe43bf49859f700449179231684dfb7007 GIT binary patch literal 30110 zcmagG1yEhV(=T|@-~?;gS%eb-QC?CF79r@-Q5XJaEImpeeZ4U+kIPa zs-|krIX!xMrn~1iJ@Qge(3pV#g!3XQHr+qWNK~Kc|3tXYXl-t7405wG{%vPxWp4Nz zWNvH2;A~?=Z~NQP+>zea&e+Dt*3ik?*ak!oGIj;Y|1X7o=KsIL*UyxYt&NGfsguKh z730Xv@V`<^{VPT;;RgWz6X`yw<;@L2P7cP73`~swkHEyj`Cm^=%xcnF{QkR`;06#)PU&d*2*2l@HNtrve00N}Tg5dNj?nt9#{pGjbx_3@$X za_1#G<#mvrX(Y%@4uL)i(16kYg$CL7tO=w16$0(5d#wCLZN+It1pWk7VW)%|!J&1X z^lNM?6gs*fWx`APh|xvYCAYVnij$g}nu^-PEoe$w&SwiLtGp!J{iN*V`S#&ueSczW zZ5$oiZ@SuL`Kw^?;#1&+0mrGdNk<5+yKs73lE`o*Eh~0DRjXVU%7OoH2O>z{u!5_L z34P8Lcp!yExrbnJ9M)5Lg29AMP9JGg5_rOBeG+7&OyfJ+2PM%H^$u%NSEd_3LAcF9Kia4{ z!yn2?{O$mG_Ss}6uEjE83!wN|bORO{jWeB1|2tP|fn*V7|#epR#iDU^>Sph}6iSCSV^j(4Jy<-+A_VU-*Z6r@yfISD-xmvIS^G9Fv)ZN;N$?lx#84DUu}#I)Xa+ zMQzHX8?#yfvZ#{URB*0Vgho=Oz!VZ-9E917L&%_{EiibPIDgpzs&X}3h>$y`jY2Z- zU4vc({#aHdS7sW~l7%n5h8dMe(o{yW6yPSC#Rz40s45bbEz-&1Cly^Kux#B95_8Iy zRj7de#_q=)q=;tc?&qMCldh1Ftd?lwRYe_ z1AH;c!LYc`IoM1^=oCeQwG{J9I z%PeaKvtM5&w1=|ZBQkWBz)T)z&-~V5R<6@(`p^IX^wLrwQpd7z2`T$@yRF!k-+6p0 z>hPpCbB5QX+f50_TliJw;S@z+U;mtoo2rl71BzY%Yu(+((EDpj`%;d%?qgWW>CsNg zN6XGJ0|nS?T-_BKP-;@AqoM{LpdaCO<3yYp~| zY-yH!C|P2j)$RR}ui`?)k7qA2)k8XvQ{sHV-SN!Q$U(q->9ufVA(3fszJmtHwTOdT zFcU6LJRM^sd#vxQ;8jsnNj8dkkk1amU^OTZ(yrDk6r=rSQU3d|75jnLOKq&&C!)rr z#Pv@cM0r7&=h6F^t$XdaGzHK^ijl-&6ab)t7#8Ua9$hj!^i)e{C^o2fz9s9Nv2t$A zOI5pT@H0ERZP%)-Ro>DE_ob45O*#>Aec`QsKcCS0c(y*N%R$@yq36bWd%HBw;q86U z=9I_qk?ihR?YS3gpc&_f$u5##JH0O3)h|R_?0_EB!8Gsazx_AwE=kF0q<;`^(Jm7e#6 z^Bk=5UK7qkH?E}?DX$0*BtV}tLEbAi6jRwk7}KvZQ*z4Zt-3p-^YCb6Yntx{vD%u1 zKqhddH$Jmx`OF_`>;wAsns>=qO0>GO<(n=4E6m&|*TBi8lB1j6aCS}CK)`AUkn-uDLIYqmhKhjAKzv* z>Ju2N1SY>FA|1n5Y7bmvRDXqzcsx$zBu=4-?Uh|kH_OW633ADHf-U^Ov-G~;qpxFP zk-s?0S;ASD8G;Iq;g`me7N+m55s1AJc9HE}eM z0A((RDRg`(LJ`LVe+1sB+faS=1qA!a+1*fDshj&`sUI8MLb3XAehzu8PzwUd@+;(Y z%AE-PGUfwEwUSQSYF<08K)j5Z-;zbt1+yof(Exc>=sc4@iFLJ{RaAGh{2b`UxiUxw zaGi`ELW)*D1_f0W$i^JR;9=b{A&diyD{6-V2J(aZhXbK*m*Zzyw~8fasU=UMX6Daw z+&hg9e~}g7bd6DJ_&1l(iepieEgaPq1)U(0aR>&G4G*i_BD~WYZU@&-YumG8MIDTS z-L)BIvVu5{DtD=+gpM%*l5)<*@o_FdbsG|-ceNDh2V&_p1%)8oDYfNY*n(mXKyGG@ z#UL0LHS7&e>E{l2J3ZqWp?COYdWJO_R>@aS>I|pM;mo1Yd=n~R@sAyvqUHHk?a)Uo zqcNRqyZax3=a57(k8tj*?d*xf!)gUNC=QJ?jB4s8UwI^2v^g#|_wu4BaQWUMl z{7Cgo*$lR?z%*e(_6(4kO0vIp7P}UScA;4odN0rUy*~ARPfl;_y#_|_Zx?YFsJxzm zIS_ZIpFY3`Hh@B$Zir%iR>#Ng`cTM)i`P4BHA{A?FwAF_nJ)rwpVqYadmKw4g|#P2 zAw^=vnlM)+aM7ZbrwB%<*AqE^k4&E3OOoC%X@r|_SUMjr?-kis-yu$Zu>~V8!tM~~fq#h{-b!~|3=IgFCDG%T1 zt$@CQ^9@H_Yt%Shjd^?cW0dl{(D&~@V-Z~7B>VCG_fCn}gc5#Y*Q@lZqwQKu%Y#9}% zgIxnfE83r3bNhv9;aH^IN62{y-5lJ&!&OtKe$8o76Ccpp_T`7;m=DiheW~IlN9y_Q zu24Q-(b^v5sr>TSpIR3oB$#OK*j)95djgvIdlUz!#r%U`4#daeW35sUN(Nq#p}C9= zybxxc3J0q>2eIIuf~r;RKu^dixe^i-ZFshafHEP8e+b$LE_}BE^|X55?i_N= z3EMK+aPO|yFj|4mE(hP~<$CxjJ5J~)aVHaHp}f8EKVG>k-`>+SEC{<#GhVL75Nbuf zrp}&_&g73m)^bfylt7{xr(M`5Q|Rys_LvXBOzN*@9*R?G6UR1` zR3ZqP52^q2hDp#$H=6sFRMI9nVQel&w|bXFAl%KN2Hkr%=yPlUF{frx@&tI1LJr*VP%t< zB#C1qmP6%Aj`+5&Iw5KuUM=WyDig`7c(jgQeMX*WJxvUtGE7PHTOINWd-GU(*U!Q3 zj?BGLNf)Ig2@N!Ih{#dS zrUi(upxi6LQt^`oE5DQ?dFdHgPuV#&4nHe4U_v+n-d83V#q(2No{KZ3Y>(DCh#dtm ziB#E^d+Ua#mLRBToMzP9Hty0ZrbsRI)W`26b9D*Ty0ftm2x|IOjt8FI-hOx6Kl3tH zX(biWu>E0PRekLz(QP-P1!w%h4Jy!cZ7(|J;lG) zW!3qz&fV$8>3m{zbTp&?;PTM%#K7~>t%be*d|tFgZ|z(XxHlwsdw-7`DJmB=WYf&S z#?C~G0SCQX`&er@)c$bS(9}q)-O^)FEA71rS=&=3w-ucH=feGFlK<>+uYc*Ia$`fc z*piU<#OvmqEVy`evVy^3VHJrIYO%_N+`05+|DFG=^(>z2{QTmz3?QNqDX(|mDC_xQQE|jIqsL((XD$YhL%c+p%v)tym|9jvo*i0%sk%F^;D@Dt$xor#Qc6` z5pB!wu3Oz_=xM9v;I%sORWJlK%6ppE^PohPA@lsoVCIiJb(plx-nzS?wd3D+-m0mt z+szViDu;)&h6xJ|{H9BF+(p~cyI#ISW|uwU9csT%%in*zAC24mhxl58R}enCAQGnC z7}UUog1muHoT@>CcAIzq=IDp_Jt?&=y8{|o!@-|uXqB@Y#Akn=GduO2nbSf=3r3)m zEq?aC5u2ugs`>owTD3(3?AI30bxfTmvUx3M9UdJXDr}Kni@SUQ(aNW~6tw z&mQrn&-D&6|GCvM?Lv^Kr~&cW1Gr6pWOrr#)<7&+0XpwDaX3ZnLih=u{L)D}@AJY` z_rGSXE>G|bDo>Uwc=5yygt&2JBah%W794GeqaM25cd=)oYdLNgcQ&Uw9r`2GI?0=; z#}Xzu62Ox6?UFGt#-RqZKF(wyaIsmf($N#Eb+^QxE($mQzLCoP-^KVh6ogXslsDoz_Wxp+ zW)yiW!663n{=ecl5io`ggjDfokL5XiK{gEyV;H!ZA1O=sZ+lcJ#=JI-lf(w0b!%0c z#IO=22BbXs%+?Yi$mGYR0p{w@a_%>Luk``bzXHEa*ZQ1%oDRj}(WP|dr*j;$sgG0? zWtPzMBpm-cGuGJ;1G+y+5^q0xzuFwP9vmJ{xqEfdEN7Xe>6lF+%m)DvHc6GZMx`XR!PM2)M;Atj3`ycMC&y5n*ieDu>UfjzY zyavqi{LiOvR737Q-Wx&~9rD!TQNg9bSd9g&+-L$`-k1{ktD3^`!}{Cr|2!~bzSl!d zXtMw9FS*}&bRN28DQ_t?_~|e2BnkBv$yN17>0|lj%+i( z{Jq51k8tjlwYAk*yeN@c_ygWe==;E{@9Fu0ob2t^$Fs6&s#&s2wT5DHStqvE)^u)Q zb>Q~KHH`g3QD+7(8{4GtmrcHbi_Y74H}#@rRDNgLx|?LEV@FB54LeTUu(?Ib7qi3! z>RGa8D6UL6j~4fLm_F>r^!~o>B4(H-%@`V0&pOCVUjl!e&+yOz>c5_n#26^YXr}t*9mK-QTKTs;{C0!GcdU`rpNKB$oX@3S7tl?bZF$wcZvp}pV zgi8Ee{}S1Ll?NtfjYbmH)Fe+`6H2^(I`pl)6Z6lF)@qXHKl5Ur5NLo(nHZk|s(xIGB?|V&3BK>?AL- z*MOn~0Y*TP!{cxq;#e%rS=)khX3*`Aq4ASry9KA{t~>jVw+$Mwm*=*Zr}^ui;`Qln z4vGIXg<;}~KHPCD1QvO<;;X5Ima>&ut%wXcHDSInjaf0Wes+4OL%*FM@^{M2&}a2z zrd3(}UWAZJHb;!Ak4PWONH(LFS2uTzF`oXe?7v;rS(Hstv&J{Jc-F6?t1nJ4sH58g{MBs?&J`8>< zMnwIo@9^Iuu1TG!#o>tD4D%7x22M!r$S?n4sQ6vKlI-N{{kRi?nK2+ZI9Z}wf=@tT zWo4zDO;O|H(+qOC+ARv&51+=3y&xNTM{@~TC>Yw>^R@yFF^7PL)^FC;(_SaP1W}d-o0%BD zSFO#F#vDsLY5V^GU)jkrU*bGS#JJA|yAyz`<0zC>!p-aH`g}%}NRb+y_I0c@aar1% zKgf)si)aUt^Eku#y*%OKoK$~FJ;RrjG!NCnNm66hm82LtwXUC^Td!W7JHMojrCe?{ zBDRk#Ls5?Wl*6J?nz!%+imc~WksBCAOxsCuO^2CX7H?6YBdL}}H<#Z1U60`>oWQ>H z9_M~Y--Mi-3K}!6bc_`e>zEWR+19{#&CwS|qNdQSTep4n zeq>bov90~yLMv1D5OEjmBI0FY?V;&u_{!dE@S`}o7%Pjinv?x;&oaB<432f3oNcv^=YsBy}iqk7Zm#D z>8jl0%+OWzn(G=Z9O85K`$J&UMW6}V$M*EQ%PND%#^YI#deJwUC7#ilj&Jr@sYPX- z1K;YZ20^Y%sRfN-<7m2g0n7j#ozcC)=Y|^xF-Zqg zkee6T&<`RwJ7{atF&4wIhh4d@8!_9Lym-yRRweRVsE~=~O~hDxST~@{w&Rhemfi$2fvdCbM+& zzK-N>Sl5t?q1cGJzx5S!u?J*(U>m$vyF{kwFXO+j@$k~I6}LKCAhx<_l&NUORVZ6Y z=;I<(fQ$-q0tiFmnQG4iSK8&IJ#}A!9Pu5LwV-3?FMWMS@e_{=fy9Ur_X3-!MbCm@g!c~AJA?3{@cK|NX|i#paM2;Cl0E+ z>iD&q*;pFnWo*~gFmPgmn1t1~D&AIFIJjwJo@SlRh90)4p`Gdr_1D$T+ z-5(}Ws&FhNM`CxD4^VAH)L}gYqn!cM-UGbJ6EEhJkb@%~3GTxT!|g{i z1Nx)S%*=V%Ap6qgr+BsA`XHKHM(U({E+cgN+_y&^$P6SAx2>KZ=EwnEE>0~mjtH~*Q_J3J>Uqd zSc`33>RZllc5+Z*eIzBTuD=p#UWYvv7#J&d-+ujw#7U~wV4@>?-;J-WO%LM8Uxt`m zlbY_z6FOJxDCF3M6a@cKBp{N7M*aH7EpT(ROz2|1WXtf~fzP&D-Qv#OV?~(~cT3&Y z*%*Cd$O_A_m`Ab5DxjT`t+J29Ilf!zf;3ZJBWb9j59?gbhWl=x0&%r9oB9#UI8CUx z^P}t3aqINCGYYiZOPmqTSH2tu`@=k z;FhaIP;o8oV!+#{bulxW#dNXDi9gDq^eeL>SEa-$3n6|Hshg65|$+wjs zgg6>U6C6zyUt8E~*f2w#mPquxbJ%>*^^nl*xgX`hpnb`n0NO3A-*a@g%;sja9v92u zcxJEn+rGN!Df?b;8CTL+wPL~4+}H{W3n>B1k5E5iMvAj~Kzi;h1O~bOI7Ceh{KwE) zt>?|EgOW%TFER&+VA+y2-(9+xf=v}xREh!?vP}Es*DaS*|L#H)ZFNq*xP*F|o^v>PV!h+K_ z*_Pyh14o-)rYupi4D(C4V6*{g92k6XFpTxh;wM_uR2#w|Dk(R8@W2OQ8;~1`Q#bc|j)-o$70rRw6IQI~#>aQWu$0qkaW$HF;zKQr;0GR@fwmw;+jOv7D!>-~z?xIL(@#{F(o zP0wq?h&g@Y5Hyl#Xk}H|iL3>@e|zAHNs;-H=%`tPzrMESalus)C2GjkrFzyL6yTN3 z(iPUH;eENc*8G5!>3uf0r0w+w9W#OgQaf(y2-vV77WVWnCo=CL&gFKwYx^SaUSLD> z?{0njqzx0^kQxSGRnJy@nzL!VDtmcph#a6Y-tUa3JfEc}pR5%2!c1TLRtRj>vhS2vknU#}IgLwd zkz80cnpHYFG)=Z!o3pbPta#9u*ghME1qHU9cggxDO3sPZCX$q8WMa`E(0IRT5`)@K zX>(X%90w`#Yu{{9cc&`_E|=TC^NF~g+)3pv&l%!~uE3|^diA2f+}YlH{f*Y>pud@p zx)mF`&wO$T<5$hy%4=>Zrg!`~?l0~}=1lPln8k@RM@F>h1V~X?w|AF@GLD)$rqbT3 zNs;Y0w?5kLdL&05Yl};N=^WEC-8G8P)Di~NZYXOdUC1o(pP%UX+h5nioTJmw4<|AL zj9Z*eo6_-O*3SF5vC92f4it1NkuI<9@3YU2jvkkX7E{=y{yei$*L)e=W5q&!e)fOw zimi6hu$v}6ZJ4iaq34I-*JGs{EzXGHHAS)!Gb9^&2;#%ZBn0!UHR(^dVK-~g zV)0LmzMhhcNLuM=Ef#ExQ72z}VAKkbvtknP_}zu6Sd?p6lf+udh8A9-{8!ZT!P- z=%~@9y0><(#xq z8NfT9yI^j%W^vU)XD+-^wAF{_JW}dv4|Z+iod0zm)yMS?wf*J(S@2z%j53P*lT9?U z=KiTt_4NhaTmPgw~vO4nD&S#*YBn2Fl*i8fuKJ#E-D48>{(NW*VJl zCj}KY<7(`#h&jGH*NisICr^_h2Ok!T9xLQUv3V8S@c>t3Ol3Bs$m`40heRk0>x3}4 zdrYXZS2bH|pgtr>sXeUrTY@d7(9a|HQ=7>}7H?8I@bS7oCO`mIeJj6F1;+tdK;AwRg?$-%!_=! z)O!von}h^NGhuxKj{l7}DyPc3yn%(*owFX6ii?XKXd|Ejb5WA$KvnalzcHchT0RTR zHMeP4G^)O;ez>UoI!DldqWKi2LGtY|_)_^-_!YP4DW~b%OTS zS1Wii785G1;sL+%{CI6WO#Gvb=7P%}XNhU3I%+AC`u+_5dVJn`=X1?ZV6{ySZ#3>i zvaA6TV@6!tJwLUMR>NNH?#Pt^VH{w@^3%vfPMQw2w+@x}ac}MNm2%Vj-_XO>dsKU% zEi3eJSeO zKEy8_YPy<4lBcfIB)!Cj<&zgzBTSKC*W zC{&C$|Hq*gJe*-o7M7)U`lNi?=q8;c3R0_5O&#OiZ6qiWdC?^`Ocp`h2;lWxL*yXb zkE+AN`I(qo(fXBzV1tv>7Gz<=lC2Gcs37H-Z<8&7%DFj}S^kRWFhnrrfjGOFoz8(8$<(2Ey z$v}!hDM6$-6pMsp{Ls;Cs3&3hkJf=(@|5uD!3LCvI~vB0e4D{V^Yb^GN8QH{%9opcY{1NvNeGud8YHyW%0?UTgwa%+vJ6#(HvRsYBNQH>46h*=B^vPBoj&%kuY*z=d*`qGZD<4+ z5%7t&MWdj~sqnErJ`CyRoX`S#FcT=|vH9Xt6d(YpD8rUszeo82slofU+3+v{P+nAq zGbF#h!Uhz9%UX+@P}~;)Jx2Ky^Jc7VcU2t0P`pu&y!3LN{p%)$=VGYNApw3YYB_3q zWmyf{kOD~wN~J;pLe;z<`+fCVlX^}`VIY$9nK)6xSsubH37}i4hpEoZncEGvjEOEp zu7v_Nu&Jo}=ZDqbAVmD&<;M{niDnwye+l3436Ts-I8F#pTTWIl2s75%8naj1Bqo^v z%HK}}H(u|zkZ&M~T)eF8^iS`tClJ5EiiH@&wan-S+u@Rv7*qNE0wm!=<&vsdSf+^MTL;g%atLZd4ckJFDzQ4M@ zvxJ>-e=IMX(b*~|1&AX|L5Cs$8Whk@rnmp`nH-6?ID?Fiq*sqgHu5+zidT$4fmaXY z3an=_PX+V2Ib3}DEsc2(eGLy<4a)*WfZV8Xd9t|Dp{#}s-1tZo$}a&{nKLV7k!g}h z&u?ULIKTD`fE7}ypoTO;f{1-dO(zm#u)s=3YI%DQRrUi2P)e&DIOR)=OPxJ++6|NZ9cj7Cu%N->NH{Co5jzKw>o1R1 zzG8GuM27C1(6t$CCEK?RAA$i}VN5$MiHht*cMYB3?URWoO@blSz{WXqN@g&Ec)4Hu(8NLXQ?M*nk+Y7a){r5tOQWBxxmnUF% za8``h+}?mYn|()9JrO9;?~5B2E`Jr_J<^8g;eA7;_j!KRtoBGIA}Vf;pZf$gkZ-Yh z!r)j^{`N?mm55RMDb2B{e3%DWO&84~GXuMn8`6aFgpf#^ehE28`{Q%QJ_kp#slJsz zS>q>&eLSR@b~*mF4yAy7mPJMWQ~eZzxNei;D(S}p8UZF0)`uLFBPjCfcp%himp};w z#n)F~uD3ectlBNCWi;QOo!>XHH?y_bbUzjQ&Gn*PhW7t%d7o3$XTrAUt?>ZJLu(e8 z{v?`O$Z6?2y~{qij1kTc6=AEoUod5`Yu^w_f%=v6N#ypY-~`mBnLRRs3;>k(^w@tM z`O)9z{1p3)b_4(*0EZI=fYpPEO0WcYeuMNKZurj&U-mhJPa42#qRVy*DAf$CupvHE zEsy&JHX2GrRs%MgEKJ!5fA$w>@`9q_yWj<`|q{_1vhGM>^A3At1|V1#{q!c=r$3r9P4O>V$FcfO0sb{4X0t* z{CA1EYugf(KvDty z{7&zjk>Upkq%a`?L^t)4*zn~)#`)>4+g>pD`)A`Vao5YnP}j#BgM{1PK z?x+H`1+n!xVk_8M9Ew3nTn%p3%+TDf;!OxnBd#Bm1@cdY*n95%Lf;o29 z{EF(isY}kwi}uU+oR25sY{2%)|n zl~9;XR(L?R)5&5>BSMY-6jT?A486|K)xdVi#;Odhg9efN)d7JmS>Foww(|RRwDmTA zBADJ!R5UhhW`T!5=B}_k+e967B+p2IVyP!!__KMOT=rHKpnn*zR7xwfA}%x)R}j)c z<#CkFwdm*`A|KK22Cm9$QnhVzu;1Lg4ephfSCX;cYwgX00r+JK65tyC2dq!*b$MX9d zF?m84ugAT#gEK@f_sH?{rpIL`$ENGv^0K;^n3#}Ir#{zZ*NaV-te)BsSj(lUQUw;^ zd!5H-_c|j+oD}5C3861Z4H~@KJ5$sqYDk^I1^-?N-!t{Hmf~{cwBdVvTK$iHo`@q` z+6pwvpE+{W^7m+KKBgNs;)G==sk5a_D!K`tdjU|(8u^_=tFR$p;RabIp3iHmH$oLUE@;c8e z#rAB^-D3?`-xx%O9B-=`=1wczY`>vk%sk2Zi4R z!Si$P3RTv!f0Ig=Hu0CC+zo4_;YQT9*H-nU`%3Kw>FXOV5AXjt54`U8YV?YOvu42o z8D;T3o#b*5$$_Ask&G}VYU0FaZOWheo|-zyx{Vh^@(r#;?N4BQf#iR~_nLk34@|33 zT*q z^X3Wls51mLh8$hC{b@akhHQs?7R@xX_BOp9`M>$vO_ktdmm;!R%B8&9XSxO{gjMN9 zQ!9hUeb9d4M<0ZKI?E>3&=j>x@MySIym#us*HTObLQbLx*egqGM)i~QbYrL?s(L{) z(kxsfM?}N~9H82+z{<_T7^LGMv~S)2Nw?*=fsG!ctqOjE$v~23)`S|;^LQT#GHuT6 zJ^^AJ3$PZDMR6CpaC0XpU&}vCwjHi4FxquENbU7Vlm6|wQp@&fy6Fo-7P5NX2N$j- zAw5b&M4<#J83&vKSax106&F0EJi9yDWcQOnh(b~qU-uyZLeR|S~DAiIt~G0 zxX7-k2XeS5tXMGrM;Y?X&+LuMuC|MEAH3>`G@y%uCbbAxa{tI+3n`SqhypR^dv9J= z)!!4L5%HJuq#VsoN&>_`r8U1yn~ro|GbTy4V$+13vwW?x(|M~>k3E+z8KmWgk~%6{=XdiK~^ z3S9k{p0-$#!09T)D>Hbfut|AJ79EIY)y4}%& zgzo6i)Bb=tg3pYbhQfU|vrB8S6B0N-ckKG~8zW&fkMr`tBH8-0moZ8K@J0qt5TO#g|UZfqh8!0WT7W5@+zSlb~mNCuWJZ$N@9y-DH2{V)ZBDKhK zdhM~NYe>Ng5gGaviSu8g_2w7uUa#Veq-|&FO~~451Yza!mtx5N)b?CPaAwl`!-qij zCe>#k5ODJS%7ywWe^81_&~3C4#M}Lpz`&Sk)u4V`Josn$oS5+Liy-monn^8)g4!KK zj)#f^ejRVk$Hioa7QyPOe00So{Nj5;{>e}He68=tOYC>ZxR#aADmQEFlris@EK{C; zC)d78A>C#X;YI4*pkj-EiMFhS(cP}w#iR1)f+;7c^4sIEZaMjMR&l>~_Rz{$!_#Tr z@|^2A-VSvc*kRQEIHu9xZUM9$^pMAzZa@C-)K_1>Jp;v{LXuPOQY!(`6%pT#^O2w} zK`=pIjMO00r>>bKW3D$HMqV@?)?k?;%14v`f-UbL`8gXDrx_Xgg6m2WEk1zep_SE1 zx21_!_tgXpqtT0XavGCyeUnggnHI#H^p?X(s-Pd|8KNma7C@}>&uuV7Do*ii%w$r+ zZVUn<0H`6U;HH#3*7Ch`4UO$EIAKl)Qtd@70Uxzzc;kAMdn5OYzp zs03m`E6G0yIO#VQ=xIi&!OCS>n4{pz+0yqBCxh=Ps)QJN`l^1%0wb`|1!Xwds?cs? zAvEnm<}Uf8YhL9&U8;CqtqnKT_BMVgP{sV8LPE}SyT#Yyt;rIZ_AM{c zh8j|c{)T9t8~m?$=U?;aTUzOQCKPEA0jI9`cVt~W0JZ-ozkWf36i6$L{8Xgn4-&1m zTjC)-Mn+b}6aPvIWxHL+?OtF2fawm%1Zv3h%L^Bu=*G{Nc?QHz7C`DRI6;-#aK{q& zZPy}c1^)ikC`q8Rfcb1JrUj@WWA2&BU}jnH_x|NBj%o$G#B&QPaTiBI6&XFUI*SIu>;L*^H2*XQi#`G3lvhNcO>-<< zf&}j8#ArYW{f=i%RL+!FZL5*S`nP^I?X^U?&Tp?A?5~`|{8F%S7*|p5i16~PdU47F z&Qu$*R-JBymgKV27BV3XN}1m&Ap{7IcI~!crcKO;{%~^n1qLuyeU9{6n*$)#NU~$M zMF3o0&=QUP+(y*c*q|{n1nHFO2&%@=*UH*pvarpXC1RVfvpzX8dd`+x_t% zeOO<3i$?i8gD?bqKVeAA1*^sl`yoPn4jbC%zPW@e6l56RzO><&Ph*FlSds!8P9*wP z^eT8HcMd-?F{}ru!xWOKBWDG?@K=hmC_#)RW`viX&#zlKV5^+1=N=$gTa~Tg2o&{S zm(7A=Ycr8Wg*Ns=r~XEbVa!l~cPCtcxUl>xHgvC8dHSc@`*h~6n&{#+sT;8%kipL=1^&QTH=Q1y1ajb3mfvrovIUS0?0!_K(I_R@x`yNQPT;wvGfQ(BNWe!nhi zP;2^xJ@t4Wv)PW7p>#nI5WZExO<3T{Y8w!8!f3yMwhxdGDuuf{ffN>Qo*aLu?pobDpw~& z>DldKKf#CR?GGaH*8B;5tpjUt7&hPHr%A_nBKRhla^B_A51U0nL`5rVqgp7GV;t!& zO9h|qbrrUiL`K6XO#pC+^N@%zeP6h{L`_Gc&Niy4K1I&Mu9ONWRG$PR7>Z6_s;a)2kHe>{BB#mxqc;jk z&hKk2KX>kZ$)p6ZdkZa3kmz-V*c!N^)!*t^6^cngfAcZKgJmi@^4&6%L^_0{&3g z838d%adc`N4G5GppG~QZZKF;j%Q_{*>PN&DKr6xY!rqev+OkHamX}2}XCn!)NR+w_ zrd6zxskPkaT~SuVwKOs0W`&SmdD)W zL+2ej5E@rG1LRxn1Sz&vV117#q-#n6jC&COaq$8O{+E{o_lm#*t30#{)qK25#0*i0 zPVr`_0E|MsZFgHB_Y(%5FCPT!6HT-lYh6eYFA7+>KTC?4njjTITE0SsTp3yUO~pKv zIr>&R%6@rN%8VRl+=}wrDL{U~&t6Ml1R_Gyy=NMt2xhc2D1NMDq4?jgsskc46lHq( zQyxBtsPJT%Z=9}ep{M@76|wQ2#|sq7%FElf#^N)3HA8IFpPZ=R^w~^F=s*M$2k%*z7VhErDLcT%; zB#}Tt0pz8=z{PtfbJBj6!Sosb|7$_~{Ay@x1NzT>1+Las=h|Afdo5Vrm(}`F&P-a$ z4xSRbu2dT1%t1tIL*O`i1F+&=IyOqeKp_%s$?9|)aUKda2yZD|LELSdX ze4T`F3z;zfAQm$Iw(`C*Z8HMl+UZV7=BZ zbMxaM9RHQq;B=UoJQ@wKBvWbqOg3JyjurnpZvSR`EnnRenL zWVvvwmW`vf*jxHFu1u~&bkRU@R>+99#xe?nSNEb}*qcCdjd-6fOr_M%IIno@7@5w# zP9i7H=Bfz=E8dRo^mpT_>$))KrmJdXx~qC5M|~M$$zu|ifW^yvwXiv&*mU?wZZaqS z2W1b68uh6mwTEy{=2$}n9zDu7flKD`Eb$l1)$2m|mY^(cw?&vL)I`+#t%=xh!#-mm z`6e2cm#&2v%o`dxOEr&kI;9lF)i3&-Pi8)zJ_M{RrXsn~`utlgDPdlclqA#4$QpR- z4YWA~kW!;X#w3yEK-#yNv{tYr4o8+VuMGtIsfh=YxN(P8JW1C4Xw`a>Da@^F4I`c= zCKsC21T(DE)j1ci@~k}_M#lK;)cMkwwovbiKyBu$Vo>S1kZAOcnWC|b9a))Gd4YgT zJu*Y?TVf5OL1C^)X3cH2kWKW3LdjFX2&#l~tB~@*ZyMZ7ITBtkOvCRu?F>M5Bo1Yy zDPLNd{HtA42($uL1I&BrDFz?-skc3Hk{GervfiU&D};E!agu$jLi@CS(?&*~W#c$be1S9X;bOh6KO4RI<0L1`rGOeB>1{rF*af)zJHFa}XoEkp7N4|E`D0BSkXUo6B?%A7 zz56iH2@g7!w8|v)Hgw%&?CQ0MT(3Gx!*PT>sujP8E@RzAE}PawW#gB=0~Ab; zs_3{O4xFD8txl{a{nfEd`;68REmIeDw?dJ@#rkdSWhE?@NBztnK1%2+VWo4@n(48g zJV;)DTDIn#K};TDDX5s1^&!4<#QLnM;LWGmG3J&CJe7p8HW)^*f$x2rcq;*>{a?HPR}E@AkS~lYp93=N=7iIhk)ezvp4d!hXKX6l2L2+(u}e|7Zkj=|Z3lt4-ZOaLUD_ z+d3UGIJ0E`)Ai}H1trnWuWMt^y1^TcklDaw3k=QVqFKZ@oX1s=D2c&Q!_^B)2>AM1 zF64NKxNPUN+U5I^Q#-%!*X^&hw6>vjPs_zu47+0pBzosB3&$9YE9$~o-6b_BN!BnN zm-KuXUjeao%XMk52vXjFYVsfITk{Ego&3&lrabi}?$?E$db(r8d`0yj5v?`9ZGOpH z;-J-gzwYkq!&9Ue3#m6?dAbfobMj%ZSAX8_v(Ssg-DdCOgB$+zVa>^o!QQ3vw&iPN zUBr*)a#G8m9s>)V6r`8Gi{1comql+z+wgpZJHwkn@W?Jez7%@2p05;mdD%JUHun%M8p8SKtr3Yd-2T z$yDRBNXeToKDK!4Jbg3~jfL{%%8w(ZLr}f zd)Dx$U+%NF6`a?qtn|{Noklj<2(X=smZ5Cj-wG^S4I?iX65j{3<&g7zm5Wv}<&tFH zpOSQxm5|M`&R;$4C^%FCq;6`xr0(KuM=%SK-wYMEQLrV^Ma6e8KCMnVgr%uU94-uK z$n0Khp}2ndVysj1q0$RC_wqf@j?=X{=Z}sLEAzA1u#~JX*~DfF!VDqpRk&y*H=V#7 zUEXnbVd2VAoE_58_}%{7RoqOMH8|9Jr558lEBL)qVXBcVyE56@-B7Xp>B?Zko7O!4 zI7c}+WIvKvjG3;ONl*v<4Q8(x-{OrV(ewmkKI}zA13so?ne3W4BF)ggF>a%pQ&oCu zU5=VEV~52SWSQCC*{g%Ts|w2-;Aot2z)gGbkTS#aLh8a*!11zI(Okh!m;_qNOedQyNKpSn39lDwy!8U zXu7UtRb=1DqzGK^n+BLx?mj?H8?LzXi7RvTR?{K7CWdq%9MKn7YN=r;8p~$s}%YrZ(LCW2j?UlgXsQ^&Ay5F8y?W?K-=Ve8pbf3f~?+ zo^|kUWg2tOgwU+bnmaRyFuzlTn!qqf4FyB)@^BO{<(g8#1hrUPib(M zBzvaeWNwbeUFci0{z-H4D>Z0Fr*{ijmxJWli`W+=1fRN89ZJ7tAY~pMAuuykXWmN! z1?QUy+ngxkjI3=RE+Qi%-a}TWC8Ls+^S;lNpe9{*%m9}IUnlffl!iT*zz_%M#4X@_ z{*{@5jfktgAxl07y+e}>M>10>%7N*S`yGU!c41jtPPa^Vp&7I)@F-di0;h6nROo(B z@9IXkKOmd!CvK{ZvVNNr{MOB+ugP0oVuOqyCG|r>kLPxA)E(dmaPh)6zWl`Yg9J?g z;Pn?!;XR#{A?}425ga>Qsr+CP2Ekf(u9IiBVJ{SZ->!L#kM6GM7@}?;yviv0;p>!6 z&yiLvJ$cpTvmbR*tL{xqv=Ji*oaQ#44R84<<7dJOtx4ts{g%5>VXM49g{Sq`yz2WP zR+%GqHR3DrK4YkeTwH9=o!9UcZZ#PSWBaWv^^wBMFSAf|I!qf?U}oCDgGe{2gW(wp za*+D1Y_UU1cQ9i}To9qA?1vF<&Z1G00q!9Fm_?MPg*=5`R=i21yGx1&zJvP=pPZ!|UyU4B zVvc#$nI4oS4GUM1RuC71NRuiF^q&EBfCFki%vcLHo2L*iNYQKAM$f>lBZG6zzu z)+JseAoDDz(HwLyRS&bY%AIJ11(YvyKZP=X>fP=^S`(UOn0>#xxjn@|w>KK}KEz`NSO+8A_ zHz2?rRVWQ~e7Y}ejy$lw-dGbgG2T!+1M2YeAcVt%MfBPr#>}kx&*~1#_^!!I+SZ6VM zofF+}tD-P)1z6&LDe;*5lh<;gylVQ7w}m1_rm z*~8b#Ts17|4z;9=rS2UCt=9>WIG}eFOVzw!a4^-5wgVmf{TBT|Ug>nroNrskVWQes zw;Izrong*8HeQ?S;uO3TMmh6__BZToa{2v3Cka~FRhRVo%TzjvghNtIurkh=8Yj(! zk?*z^{jI(cos7?p4J{rs*PN{CnYCJnnS#(`d*>>ICm-)`T6>^adPnly`O9VbiX>Sk z>~Bvas=lgI8)B-bHYJUcnr(jWZ4nx5-4ZuGtST^{Q&Z24?A6A1Bsiw#Sb29+6KKg< zMV+fwztl)j2UgCgr|WSDnGkLEvZ|ayRvNO~$SK%_8@4MivkrAa+jEz!p8ADjHMykgbC43#;r-Vyz&fZ}RG_5D@L&CkLU4%!hJ!!%M zvI$0t{7g6>>4jb8Phce{(Dg_H7Fzy1hMDR2_zu~{`@GSp{O7n+ z(2i1#4ySMy*>CrDPa^GspKr>!5BQ(-QW}ci`cA$tJM?5h*~_#$yb;n3CjwiOzV+=ZxIV@nE*Pwh5bZXJhA*NwnVq+1 zVuBOq8|{U8Lda9;{839x8%FIWp<@dQaKUEQZ-*hb6*v_0U&z6 z9Q&>;=GoLe?UKHLAFCW$kyDcidG({0p%+_+Tyh->th{Mr6Il&Op&Mg{Kv|_R#Tj3x z(g4S9Jyz-J-v>VC8|%goz|MUWWBSECwl;Y@*c=AcW?~Hy*&~aPZu4`te36Si!cpKO zfa2l~r4*`ZaZhww3fq+{3ymX6PQ1`IoM;-CR$c>eN-~J@Gc(%Q*MXrD4aZ4!p0#|X zq7sG+-(NLTmTqMU=rA8JW3>ZeR0bEhNm7OprXlQoNMwGlO@`pn@QPj@dANpT0ytZd2hZsCh> z;nnxYRdkD!^!aKdjVs_mwOniU1bFJ_fyQ}13IEU0ZYeVcqG zc}uiNyq%(Kve{Wl7sj#8KeHoeNMiL+9YQJ1xrtx^YZ#Gnl%e4Hm&npQ$T|-xWPlMk zO9wv@od}d~Zx1Mjl4AUA5fzc`p*)TDZ}3fVO^OsZrm9e^?6$jZ?4ln|z0VV`@a{J> z#@m>OJ_n!FleL5{-4PsRoY-cmM=iwN+={U;osuf&=?rRGtGBC1={GoiohHqX^9zhPL4!MLE3Pd#*9dj;y^6 z=(Q?BPnY>#;XO#prWJYLZYP#2vR&}eg60|BnG?Y$41i|KWvR=O^zb8+hb{9j(}%%7 zh1sETI30i`*)Vr^)PTJ!7ZpQ2&f$_k_}=kK1y6xtgh?S?-Sf=HpmCR#-H1n65|H;5 zOb=mOn%Wp^nf_W+#t_bF7{8=0*Iu^-=P-WsMpfscxcgEW8gBXSQO@maD-JyU2f?tW zACZjtH}J30(HnM26jjSwq_|_~sXlp9^JiUlD-q>tu6xFhB^?^G98H#o^4IMRr+>egdO9wi z4)+4rvct)8(}zdGY3iTTsx(#pf(f?$<(oH$KHt!d=Z9_ZV|U&9j=NpIY>uDfiK@y!n=Dyl2(l+QV ze`SM(ej26m%`>b0wWVcHzOJ8g-ka>J^76X6(Vblh2xrlXHTd$TC6U^3jO_Ux|6=wq zD1jCdUA0RpwG2|g=0v>qJIWuIp2k%vzAk2Au9(M}5m_7od1QoEUsr?VO(*TH;6~b8 zj5cy(MQjxaJaP5~bqFE8QUf_lR8U^uZUlkR8yt5dcs3_IPG=R@RGF6w)nYd_1^NXL zjxzzARwB4@_j*W{**2_(U$Y{uI>+>jzRwJdZrx+~)vrE}PHt1RJ62Z- zZ&oYR77Y{6$w?kYWl$i7xQq^I9R`RCwqMnbc9MQm8$C}51caVWWUgRGrzel8f)s4btQ2HmTN67|OIve6 z3JrBh0563Q2vNY!%*@gR4E*gx74YP3)rjng)Yb|3N0K0gi=!>@m%CM&z@bMJg_pevHZq9*YN*Zsb}opt7KU|aB$H(5JJkkV6bO22sdM{dllRGOBy9PDKOOfax_ zw0i?Kac1G>Wwl|W5_Pe(HU;qV@v#c9{42vh3b3@bbhb3I2ADX4e-$HQZRF%^Wa&sI zZTB?w`;+M3pg%}|kvw%iz|_bY40>uFH-ME7z{;)8&H?0P1G4=t@}D>XQxo8SE9`Gc z&#-^y%cIWD2IS-cvU3Zt{7!sESsU4!yBL{+L10^el<2Rt|3v*!QLyP#8*R-2CLShF zvsn<&pRM{=^gpqte>(96DXVkxDR6SB{fp>7>3@*9IDs7jreHHmTd*nFFGfE<%7PR! zwq|x@Y!obicIW>JWB9JCg0sNIT=_N9uR%Z>as>knDdV?Ts9b%pHyFEq;SJdH+mtvvV~49m&D> zI}a0!Cjt}aC+7WG4|YzzU+nsGqyV2Q1rqpu_n)TxivI6Xke5#{FLetS8)I7|OKT?< z=iislj+A}0+&GDbniRGBi><`Y=}KbJ5y%JLlza}N(@r4s6nCCxz-Vz3WokuFw-|S$ z6pvi$DrPjEdRNbM=zEp6+;UaHzcn;O>a;0%)I7>RdOIX8G(MA=XPooJaRad|foAA~ zKvS$2=or=`ZrvTO&2i&Z1Frnf1DiTrQuE5&o8L2HcNq8KwgWV`Qjgg!tq4iN(3Mhdykkam=UTlY_;3!23d-<^BKH8 z56o_-lYK{H4@E%MVgX2ADQS=okeYK4jlu+ly0|5{W{Kar{NR$tkRj^lzo{nlPR5Us z1|AZ3+(^63>RBj*C!x5qoDaiGq5@y1nH7?>V@!iN&M0whbe=RQ)}#nExx7|47(+B} zIyEgchx`N9Jaj&7jhQTQg&@Fwz7)e+slYnKO{d%KX{5P|E<@nicK|Gj7pyH9U~JNQ z)7|hZ_K&Sx=q`VkJ(DC=c$*^PU8Yjv-QLrU< z!cD6b0qCwq)>k}*AFgjrj1LT>oEhnZ?8j-7uGqP`>pil#I?6=|C0#TQypYlg1i8ki zX9M;3zVX|?Ec4g0TW{S0=>;e47i>S;6hW{wMFVJnpUX>c&b|74$EBE)5)>0Yk$S_| zQUPH37?LK?U`(v>dP6mahlW0paRcsy`!a_*1*wz-1O-!9k5;FoS7O#?B};kD%v67* zVe!#%-Jjm3#v^U+M7-z?SI|H*NV{4e_zEavh@6yfS-)sDyfq3oK{7cJP8K6PpXi1S z#`s85)`!#|>*$kkO-KG-N3%sS>&?vR`{6+Egt+Q@n&xNnnV z@{&||ds49%jLMD0%O8IfpEt$9w$45hMu19}wMlnA42gid2X;B_gaM{CDu_)E3aR`R z*;XFMqH^x`zbHFSaIUoI6@@;W?<6hpbX6uN-`e>Y`;NBQw(w|L6_^xRX)Rr~qmS+$ z8znm^kC>P6?7^`>IkDzby0T0Gm{7PKIWckKi3=25co2oeiQlYs7t|l;$6hwJ1=NSz zX>iI?3#;j`>7?1t$WhJ-%Rs(EtP`AgyG0HwZ&$0?&q*~QYgYB8Am%piZH~6ec^5@| zP7>x0G+`>$O_1%&{rtz=svUxwJOdHkAKqLo$#9HL7&@DLE0uCYPN&h~tQyYWp~4j` zZ+zy){NpV|&X0;6)wL zA@p*8SM+GSUd93^sszMV=&n_ia||o9lx`X3{6)(XE@rV5t2gE=Y=^+>##W>w7zaZ4 zW9Y6E)RE@8ZrvNPpqpkIq=IVEQ>rQog)=~?EI6YRAPNoe0we?d5U*scm)pKvb+pb7 zc5o0bf+y*#SPaB?ToiVs-{{bU`Bve(I@om|36xD=GdZ>h>CM!(@;xK)r|5R{bVW^^@ML1&t^*ITJgRNOO4U z+x6!Uv1e@vJN+t0Wig%Xn!&DVn^^q#B%fI>-&zxJDz@fg z6(!H1*|n;SyfR^d7u(z0%l6EqF3%1v^P|-^5)Nu1h021yR4Qd5DmMDjmRIK2ma8zz>HAoRFmZO9N7rw8etH$U zIEF3w!f8)N_yLSdrgK~{_;U-k`JCFhYqns>)x)BVE9 zY|vGc~9 zP5#Sh9akBB@PY3e(UtAyoa$7%;p`{JyiGuJEQ)!^ri0{$%o-aL?&I%igwsuX`1#Ai z7A`v*O5e)VmDR&??}Wt`KkP${)HdcrAh#}_I_CSk#;gMvtI4H5vccYZF!q{c86R9j{$TL^A5-2AYTvbUIB-m&c(=LO)JcfO5OlI&O1k+8hz8~O#-^O zPtHhXJx1n>GXI%X9k)X0QpFMTM z5$~gW22;eE`^Dj+0Z4Q_XDe%~ET5>rtz__=XTLV5f5+mYk8_nL`IUU!#yCBt=40g4 z$vDe>$kWaa`7iL-!Sl-}^SuawhF9xBb(^kO?nZWX;x!V0lF2?H@^*0J&Wx#1j*Ifo zo=MVAH5!K~OG*eLA*?9MiE?b-iq1VhrQ{mrSAFna5b|8?CXxu$WH5Zjsw?0RzPf!R zj{8cTL%6Bg#$DJ&(7jnZTA-i&hy+uf6=<;04(5K%#Tmm`*bhIj(0UG0SU2o^fkl)lzwy!^1pObZ~gQ8k5*mr}9n-0KZen^i}k!en@NUeL=q_4Y^`3Z=eJ->30d@!~*S zV5_V-R#e8tbSgl5O2#NFOARx_uh2+#1Mdxpxq!9bGkyOkjJ0dMiT}$4Kp*1wn^eag zh_+p)+pN@!ehB{Pw22MWiXW^@St!}X+aG9ml)lako{sz>EdcmriNJMsiX(~f6LgTA zCMLckq5fugwdF_99Iv}|+c&mM=L?*wcOUh3ZK8cO+ZAgviL|$bY%CrG9t0a^Ntrrk zh`l-Ygqb*)SzepD1~E3RR(8xzQ#v;1c)3+m;tDEe*y5c9-LCnzlvXVT4)b^c&p(t3 z;FhHk@DJjkDay^hCR*UjGr&VEc|oLSLPfMJD>UeHzUv(McD=^og_nQKtA;AA1O%7< zl!n@ZsTO@4CdEib*;cMbq71R~5nL;)|b*ZV)RF124ZqcDoe z7@DHdM(h&k<_`j4WuRj|P|hEArwdz0te$+OolbQoYQZz57@1@-pN=n)Miz1-Y(p$3 ze1GS?+si9(Qs#dyOpd%*Pdg`nA?WT5oYDiSI;A60hIq_Ca``D>*78sBkSCqbCL| z%D;WZmz%9v|Kn&wdcDx}Zds~Nv-v~S=47iayaJ&H3Mx{#S`aLdt@c69pdi{WXOd_mI)ycA}yDZ~$7-gaB3L*o(j zLJHYQ3`>Jl`gc}#9zgB-Hk4G(0LzsYVV=mNPwk{dLTEe%(3zrX_W|KnoMVt5-&H}v z2sY^t&fB4baO%3aiUPu;-?w-Rsu>)mVzSf9f2<5lqS@j1i$VT^lbaHW%CPS>_ z8gKG5rmQY43B$A3%0(XJ_JgkK2lTWTv0zB!rz#y$8kg*Cy@nb zhYFQMfm-}Zk{DsyGYjV<{j3@)7!a(eLhigT zzu@MA*{W-J$+q}dTTp1xqPF z5hXT73u^Ku@UncN69Up)Gr=q`Ah_M}}l z3E6HSHd+?#bQP=X2R-~+nLjZS8!W+ufM|U>{`-R0vvRQ$*!g*x^Ov~3PFuz4J1@F# zn?c8Qy0G*-x>DwgAKT;K+M&MTk*z#l2ljN&C2CfmV}yq;KZzDq`$T_1=7+7qITKTi!&ij%MIN zpIcBr9dxwBJ$?KB`58qA5#+z9kVs_v#BGbXKx3x3Ph~_d?EC} z&zF7Wo$(<@FGW9I@L}CpoK3y!(O?$S5^KmP=~|J^$f{OOU1tZuyVVy*QvC3=315%t zuXhdicU!!hWwNWwlrB$sGIlPU@TOVWcZtyvbWs8(u?QeA-wkdCSCFh??3`n#d_IhJ}v)68`o*b6ny23%q4q@c2RV2pS8SAfJ9f zHBy*y$oalfZXs5PN&ajc1~v^F5))clI(4r&%O+&$LMQW8Tu%ShrBqlIlMof!ngJ@s zd3qdLzIyOt>sXXJ`E<+z zR3Pg5v6K^)(a&TvmvNw}yh>E8R@VOpHdT*BzN-LDk2(3fdmZKHwCcFG_umOv)4L5r zD5Rig#Z+Hlqh4mDz`3A*0G}>=#8i0lkb|rlgAmf!31>(yTLl+(HW?LPquZaKM3E2I zDKXtYvuq{XWNIvp!KX5!NEAMt1MAX@%-{C26-O?yJ);uu`lG@ei3|J55`~l@@XOfrOrf4TM|1 z4sjSS>WtCQAoqE4e^6Nd;g#3^LPyozr1@TK1Ui-#NnlFncL93b=pPoBLV0uXllkkZ zlx4)*EPE^X=JKr>_M%>!A;ZnNS0+beoi|OwXc)>aFz&A?8->=Vl325mc8(Iu|DC3bzRNdTf4kYQ4JvNlE-xOxQUm`v1) z*wGk2Z-MFo>f*(8CtoY}oCG-%3eMD0c%|rShvJlAYn6zUDUkBs`&1+8FCrw5dQKEf znc;ie%qR}TM+oO=qNN?!o;=h$zZ;yTfvXFnp!YYE7@B3!;v=masm6cphZ#C4$JzZs z>l!ejFS|21Nt>^%|Fv%N(;B@6T5zIv1uGT}Oz@Iji)Jv}9-pQ?6_$NjB^@E8FkNFf z7!|bY@kzR4oF;%+LwZ!d)=~sRQM$Zi=@Bi^V-!n z0a7sqn`dFGP&2gL2sKd*O$`*q6opifR0slh*<@8f zHdzEgWE)@r0S9mx5eC^A5Qbf5=61e8%IE3#C;ZOyoVnjQ@45Gz@7#0WbAcfkim_v% z6wBejOnOpRAFxB-1zgEDi%c$ra}NPINmdR~4g)`LJqP=xqouJ`>1Q1b%{5J^DXE0L z-DyZuo+B$T0kWh*)bWbII(i_?D+H5vqrIvI^2dBIelb{7B3OJf_`!F-^1wtD zkd%wib0-um=01|0&XYeEnchBV;S*l*0?fx7%-0vp&lfTuA29#hVBukiwzH!-F_6W@ zfu$rP$;Aa{cJIbd#>Q~ow+}2U3-Rvm@H%x0>sPD*D=0vIU?ALVY|zi=<5yEt*jZR$ z`ND-*wqOC6Pzcu4gp%}h2uKwY2^6iZU~O#>Jb41v-;Y+pC5?^Pv3)z3LV?%(T%-mC zBIc|E*pqzlA|sF!5e`uvA6ZWJkYuEyp<0ak$UyLeyblkLQ+!=Cg6c}NnyR$ z9KBtgki`2V(fD5^V+>ie zzbPpx%9`}>@PMnUD=uBSgmdT4;S}xpv17+@T%JjyVj?1dhADooiTe^;PNFA2rzNEcIB^+rhPbaRA8WP90E37 zynfYU!e{TV9kXrcH}MEC{Nsk#duyhQ_;Iq%>Mvsv;ArK2d&m}pVegJr|3WPSr%(QR z=(mkS16Pjwbo%FW0NZ1y>>Q5l9zOcxg|j$f^L2JQf9CfS2Y=o^Z$9_;{Pyn{y2|>} zg>z@Oawfjr`@ONoB-Iam{BJ5v=i@e(=B69ITlQ7-eGaxidSKrkv(4*1F$xOi?6-uA z7oP`G-vJzm4;{$9<&k*8SIv-uq4s;N|vd(Tuf+L}LDn!C1H&l3DBfc#F6Td{F zuOHYgFYt(`Wx*j}cSDJnh(prSk?wh!IH&~d`gJgG;t+4*SwD&o4nq8i6R7nfUsNPm zbTs6oEG`z2r%xl$))t31ZUjqwfYz`uT&45%Iw2l$j*dzm=6JW6IJuP0v5~GWayahJ zBQ7s2L_dvomX=^;WyJj=@Ipgz|HcjUmzQJ1>ea}PjfFOyN!HMSavl%T%1X@D&;Wb& z3L@g*8k*BUzNf_Bwsf{xUmx0tlPih4&pJ4uq^Jn{Y5o4*UKA1E8yXl8|HvVi$?&40 z0>y;qUZL;KNT(d-qB}PS#TT5=k&%YpQUTfv3lM$Gn)oyaC5iEfvO9``TbGe>>k8!j zG;}3%Ysly8fuYs!4%!;w0HS|D5iC@9hTE~SE1=;1^K8i zG)`FmjQ*xF zC?4)db%;6f`7!$blT-tw#op+9kqlOsjSi}F7WEC}38u8Sd(aqZPWkabPiYur6>(5> zQ$M_;0g2ZLGt}zx(^(HG}i@LX-N=f+(h}4M3g<{ zBaferlP5P3r@TgeeI112FcekZL(Ypx6jUcd-%b;e!a&TsF$oU5;mES^4eN;Y9l!x5-E8em(G2LkVe;5OBijCiW4xf!D8&ta5Xgqr#Ww7hCVlcWXW znmVir>w|OLb1ZO^f|r|*q~u5FeJw**PaniDYf&zG4k6t`%AN_)*dj%DpB$Cq8VE{- z5Wc8GYljRuc|};Y$saPA0zzTAk{cW8E>K-vjdH4AA=RKjAV6_(F$$^H3#k71RHu(0 zKSq3fJlx#el>Nxc$_i#?W*pC8$&w|QIdkS9&jKd0eyu@X_#dOmy8cZDMw|LyE3u6$ zb#x5m{r|>o%>Q%L*6!YoGP#jLwselxXWEN2=IAIkzKQ4+wc96>9Jaq?b7juwa~Cew zQ#Jg0`5dE70|BD$p5q}QA%{0RdU+k$F>#irn(ib$L&P}MKELpE*#QmWT(J;bOGD*@bK2e{n3@|g4NF>H{6dc|yZgzD{$>L>Y zrcR$VjRL04(ERaR!X@K%`Uvl8t#rMb%**CwK2Xz~F>S)+kt!;x94uKsN3O(+Tz!(W zb9k9HA8`R=hrjpU@DUOTb#@!071-99w3YCj-0aMsCz+|uS}S?q6=O z0@9A88dvX!xw$#~MU!;R)E1BUw7`4zs8LQ%PABzs2;bK7!X@}&US6?qoUX2}*|MS9 z`9T(ARp;&8{?j4C+ogq1U4r6@%gTiB(grRw95H;6`G=zyPMfJ|rp@8C0w))*vqE8+ zaGj;<=*^OMhO3Mmt~y11;!HJD%3yo^?Qj?83!-Pw${O{RpEX)VW#q&Ol&CK>)&aG# zz5yi|f+_98kh%ei^xPAnBQ1pD0y z<;3syZHM{qe_*Jpx8%$DE4bM}+cr^oQ0P@#m!Oz?;h}f#+&y>nmvQs8-k^kwTVDqI zJb7MGUtgW%dMYv^I_&PJXv`kBNPpESW8>DXuf(-g-T$=8uC1kUM=dNgW|PdH|JkDNN(3!Q`GcziB0+Va zzq{w}c6Pt+-D_%Ux@Q0A)vJebm8X=1!k4x;-94S1&zwF@cf$kwcIoM^9=di(8Zr&KuDWvwKU%gT8nQ;p84=UOAEOi(A8(^=)8~^|S literal 0 HcmV?d00001 diff --git a/nsis_win_installer/install.nsi b/nsis_win_installer/install.nsi new file mode 100644 index 0000000000..68aa8cd1ca --- /dev/null +++ b/nsis_win_installer/install.nsi @@ -0,0 +1,273 @@ +; Installation script for KiCad generated by Alastair Hoyle +; +; This installation script requires NSIS (Nullsoft Scriptable Install System) version 2.18 http://nsis.sourceforge.net/Main_Page +; This script was created with HM NIS Edit version 2.0.3 http://hmne.sourceforge.net/ +; +; This script is provided as is with no warranties and has only been tested on Windows XP. +; Copyright (C) 2006 Alastair Hoyle +; This program is free software; you can redistribute it and/or modify it under the terms of the +; GNU General Public License as published by the Free Software Foundation. This program is distributed +; in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +; +; This script should be in a subdirectory of the full build directory (Kicad/NSIS by default) +; When the build is updated the product and installer versions should be updated before recompiling the installation file +; +; This script expects the install.ico, uninstall.ico, language and license files to be in the same directory as this script + +; General Product Description Definitions +!define PRODUCT_NAME "KiCad" +!define PRODUCT_VERSION "2006.09.17" +!define PRODUCT_WEB_SITE "http://www.lis.inpg.fr/realise_au_lis/kicad/" +!define COMPANY_NAME "" +!define TRADE_MARKS "" +!define COPYRIGHT "Jean-Pierre Charras" +!define COMMENTS "" +!define HELP_WEB_SITE "http://groups.yahoo.com/group/kicad-users/" +!define WINGS3D_WEB_SITE "http://www.wings3d.com" + +!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" +!define UNINST_ROOT "HKLM" + +;Comment out the following SetCompressor command while testing this script +SetCompressor /final /solid lzma +CRCCheck force +XPStyle on +Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" +OutFile "${PRODUCT_NAME}.exe" +InstallDir "$PROGRAMFILES\KiCad" +ShowInstDetails hide +ShowUnInstDetails hide + +; MUI 1.67 compatible ------ +!include "MUI.nsh" + +; MUI Settings +!define MUI_ABORTWARNING +!define MUI_ICON "install.ico" +!define MUI_UNICON "uninstall.ico" + +; Language Selection Dialog Settings +!define MUI_LANGDLL_REGISTRY_ROOT "${UNINST_ROOT}" +!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}" +!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language" + +; Installer pages +!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit +!define MUI_CUSTOMFUNCTION_UNGUIINIT un.myGuiInit +!insertmacro MUI_PAGE_WELCOME +!insertmacro MUI_PAGE_LICENSE $(MUILicense) +!insertmacro MUI_PAGE_COMPONENTS +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES +!define MUI_FINISHPAGE_SHOWREADME ${WINGS3D_WEB_SITE} +!define MUI_FINISHPAGE_SHOWREADME_TEXT "text" +!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED +!define MUI_PAGE_CUSTOMFUNCTION_PRE ModifyFinishPage +!insertmacro MUI_PAGE_FINISH + +; Uninstaller pages +!insertmacro MUI_UNPAGE_INSTFILES + +; Language files +; - To add another language; add an insert macro line here and inlcude a language file as below +; - This must be after all page macros have been inserted +!insertmacro MUI_LANGUAGE "English" ;first language is the default language +!insertmacro MUI_LANGUAGE "French" + +!include "English.nsh" +!include "French.nsh" + +; MUI end ------ + +Function .onInit + ReserveFile "install.ico" + ReserveFile "uninstall.ico" + ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll" + ReserveFile "${NSISDIR}\Plugins\LangDLL.dll" + ReserveFile "${NSISDIR}\Plugins\System.dll" + ReserveFile "${NSISDIR}\Contrib\Modern UI\ioSpecial.ini" + !insertmacro MUI_LANGDLL_DISPLAY +FunctionEnd + +Function myGuiInit + Call PreventMultiInstances + Call CheckAlreadyInstalled +FunctionEnd + +Function ModifyFinishPage + !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Text" $(WINGS3D_PROMPT) + !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Bottom" 168 ;make more space for prompt + !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Settings" "CancelShow" "0" ;hide cancel button - already installed!! +FunctionEnd + +Section $(TITLE_SEC01) SEC01 + SectionIn RO + SetOverwrite try + SetOutPath "$INSTDIR" + File /nonfatal "..\author.txt" + File /nonfatal "..\contrib.txt" + File /nonfatal "..\copyright.txt" + File /nonfatal "..\gpl.txt" + File /nonfatal "..\licendoc.txt" + File /nonfatal "..\news.txt" + File /nonfatal "..\version.txt" + File /nonfatal "..\doc_conv_orcad_to_kicad.txt" + File /nonfatal "..\doc_conv_orcad_to_kicad_spanish.txt" + SetOutPath "$INSTDIR\template" + File /nonfatal /r "..\template\*" + SetOutPath "$INSTDIR\winexe" + File /r "..\winexe\*" + SetOutPath "$INSTDIR\internat" + File /r "..\internat\*" +SectionEnd + +Section $(TITLE_SEC02) SEC02 + SetOverwrite try + SetOutPath "$INSTDIR\library" + File /nonfatal /r "..\library\*" + SetOutPath "$INSTDIR\modules" + File /nonfatal /r "..\modules\*" +SectionEnd + +Section $(TITLE_SEC03) SEC03 + SetOverwrite try + SetOutPath "$INSTDIR\demos" + File /nonfatal /r "..\demos\*" + SetOutPath "$INSTDIR\tutorial" + File /nonfatal /r "..\tutorial\*" +SectionEnd + +Section $(TITLE_SEC04) SEC04 + SetOverwrite try + SetOutPath "$INSTDIR\help" + File /nonfatal /r "..\help\*" +SectionEnd + +Section -CreateShortcuts + SetOutPath $INSTDIR + WriteIniStr "$INSTDIR\HomePage.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" + WriteIniStr "$INSTDIR\UserGroup.url" "InternetShortcut" "URL" "${HELP_WEB_SITE}" + WriteIniStr "$INSTDIR\Wings3D.url" "InternetShortcut" "URL" "${WINGS3D_WEB_SITE}" + SetShellVarContext all + CreateDirectory "$SMPROGRAMS\KiCad" + CreateShortCut "$SMPROGRAMS\KiCad\Home Page.lnk" "$INSTDIR\HomePage.url" + CreateShortCut "$SMPROGRAMS\KiCad\User Group.lnk" "$INSTDIR\UserGroup.url" + CreateShortCut "$SMPROGRAMS\KiCad\Uninstall.lnk" "$INSTDIR\uninstaller.exe" + CreateShortCut "$SMPROGRAMS\KiCad\KiCad.lnk" "$INSTDIR\winexe\kicad.exe" + CreateShortCut "$SMPROGRAMS\KiCad\Wings3D.lnk" "$INSTDIR\Wings3D.url" + CreateShortCut "$DESKTOP\KiCad.lnk" "$INSTDIR\winexe\kicad.exe" +SectionEnd + +Section -CreateAddRemoveEntry + WriteRegStr ${UNINST_ROOT} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" + WriteRegStr ${UNINST_ROOT} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" + WriteRegStr ${UNINST_ROOT} "${PRODUCT_UNINST_KEY}" "Publisher" "${COMPANY_NAME}" + WriteRegStr ${UNINST_ROOT} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninstaller.exe" + WriteRegStr ${UNINST_ROOT} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" + WriteRegStr ${UNINST_ROOT} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\winexe\kicad.exe" + WriteRegDWORD ${UNINST_ROOT} "${PRODUCT_UNINST_KEY}" "NoModify" "1" + WriteRegDWORD ${UNINST_ROOT} "${PRODUCT_UNINST_KEY}" "NoRepair" "1" + WriteRegStr ${UNINST_ROOT} "${PRODUCT_UNINST_KEY}" "Comments" "${COMMENTS}" + WriteRegStr ${UNINST_ROOT} "${PRODUCT_UNINST_KEY}" "HelpLink" "${HELP_WEB_SITE}" + WriteRegStr ${UNINST_ROOT} "${PRODUCT_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_WEB_SITE}" + WriteRegStr ${UNINST_ROOT} "${PRODUCT_UNINST_KEY}" "InstallLocation" "$INSTDIR" + + WriteUninstaller "$INSTDIR\uninstaller.exe" +SectionEnd + +!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN + !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} $(DESC_SEC01) + !insertmacro MUI_DESCRIPTION_TEXT ${SEC02} $(DESC_SEC02) + !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} $(DESC_SEC03) + !insertmacro MUI_DESCRIPTION_TEXT ${SEC04} $(DESC_SEC04) +!insertmacro MUI_FUNCTION_DESCRIPTION_END + +Function un.onInit + !insertmacro MUI_UNGETLANGUAGE +FunctionEnd + +Function un.myGuiInit + Call un.PreventMultiInstances + MessageBox MB_ICONEXCLAMATION|MB_YESNO|MB_DEFBUTTON2 $(UNINST_PROMPT) /SD IDYES IDYES +2 + Abort +FunctionEnd + +Function un.onUninstSuccess + HideWindow + MessageBox MB_ICONINFORMATION|MB_OK $(UNINST_SUCCESS) /SD IDOK +FunctionEnd + +Section Uninstall + ;delete uninstaller first + Delete "$INSTDIR\uninstaller.exe" + + ;remove start menu shortcuts and web page links + SetShellVarContext all + Delete "$SMPROGRAMS\KiCad\Home Page.lnk" + Delete "$SMPROGRAMS\KiCad\User Group.lnk" + Delete "$SMPROGRAMS\KiCad\Uninstall.lnk" + Delete "$SMPROGRAMS\KiCad\KiCad.lnk" + Delete "$SMPROGRAMS\KiCad\Wings3D.lnk" + Delete "$DESKTOP\KiCad.lnk" + Delete "$INSTDIR\Wings3D.url" + Delete "$INSTDIR\HomePage.url" + Delete "$INSTDIR\UserGroup.url" + RMDir "$SMPROGRAMS\KiCad" + + ;remove all program files now + RMDir /r "$INSTDIR\library" + RMDir /r "$INSTDIR\modules" + RMDir /r "$INSTDIR\template" + RMDir /r "$INSTDIR\winexe" + RMDir /r "$INSTDIR\internat" + RMDir /r "$INSTDIR\demos" + RMDir /r "$INSTDIR\tutorial" + RMDir /r "$INSTDIR\help" + RMDir /r "$INSTDIR\wings3d" + ;don't remove $INSTDIR recursively just in case the user has installed it in c:\ or + ;c:\program files as this would attempt to delete a lot more than just this package + Delete "$INSTDIR\*.txt" + RMDir "$INSTDIR" + + ;Note - application registry keys are stored in the users individual registry hive (HKCU\Software\kicad". + ;It might be possible to remove these keys as well but it would require a lot of testing of permissions + ;and access to other people's registry entries. So for now we will leave the application registry keys. + + ;remove installation registary keys + DeleteRegKey ${UNINST_ROOT} "${PRODUCT_UNINST_KEY}" + SetAutoClose true +SectionEnd + +;Setup.exe file version information + VIProductVersion "${PRODUCT_VERSION}.01" ;must be in x.x.x.x format - product version plus last digit for installer version number + VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${PRODUCT_NAME}" + VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "${COMMENTS}" + VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "${COMPANY_NAME}" + VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "${TRADE_MARKS}" + VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "© ${COPYRIGHT}" + VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "${PRODUCT_NAME} Installer" + VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${PRODUCT_VERSION}" + +Function PreventMultiInstances + System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e' + Pop $R0 + StrCmp $R0 0 +3 + MessageBox MB_OK|MB_ICONEXCLAMATION $(INSTALLER_RUNNING) /SD IDOK + Abort +FunctionEnd + +Function un.PreventMultiInstances + System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e' + Pop $R0 + StrCmp $R0 0 +3 + MessageBox MB_OK|MB_ICONEXCLAMATION $(UNINSTALLER_RUNNING) /SD IDOK + Abort +FunctionEnd + +Function CheckAlreadyInstalled + ReadRegStr $R0 ${UNINST_ROOT} "${PRODUCT_UNINST_KEY}" "DisplayName" + StrCmp $R0 "" +3 + MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION $(ALREADY_INSTALLED) /SD IDOK IDOK +2 + Abort +FunctionEnd \ No newline at end of file diff --git a/nsis_win_installer/uninstall.ico b/nsis_win_installer/uninstall.ico new file mode 100644 index 0000000000000000000000000000000000000000..84cce22f3deabdf38cc0e5c0415d2469307a0eb3 GIT binary patch literal 3638 zcmeHJT})GF7=Ga3Im>eBF{z-nmHxQWX0BWeiFh%=N`)m3!!DNHO{q}I61TW4!(~(E zR20oJ44cZ>rZ}BpQwI)z5edUZh%yBHnIHodB}hw=AC;^XQ5HBS!^hH%WD4H-GJfLOZH>HP80mw>Nm%}k+`A}xo37758=^4Fvf(c2Br)B6~7 zKY-iS2j5sb#E}m8Mq1!`)=s>RVNWYOgH0IfZ-dX>2w!gg{;9=53^%Nh79UN#$b9IXnkA0IXlXe$t#~f|&{Y-zFf6B2uTpN>XvszPTFMeI> zpi&bemqjF5txBnZY91jfdD$|XHBydw3Ca|k%{pt5r27wnGbycjH5fexDBY=z`|$vQM8pc?idjeJ^`; z)sMSSTKYBi?c0sQ!Y?sYvk8OeK0$xw=Ww6ifWG4!WiNklbOY{{y^qe4Ox)PJ7ERye zqIqi?t`xq5rY~%=zaQE80rv0Mh@veYA+K>mh~GXi3eEtg@8@*R<#;9`A$670`QGy>&X;*XP-`@5foJEYI-OH9EWCo`7+p+^ zMnfqHIg>Li3WXqObUK~DlP*xk8*K~@misRc4_9T+H<^OE$r6OX(9=1xBRI}x)0=YwQ!#|`4QOLDTCGlNoRHJw;w)w%sE7QRb(RdOmSlo1P#>a8`-uz4X0y@X zf3lvNtCg$GW>eDidTy@HVjMsgPanel->EraseMsgBox(); + if ( pt_texte == NULL ) return; + + if( pt_texte->m_StructType == TYPECOTATION ) + Affiche_1_Parametre(frame, 1,_("COTATION"),pt_texte->m_Text, DARKGREEN); + + else + Affiche_1_Parametre(frame, 1,_("PCB Text"),pt_texte->m_Text, DARKGREEN); + + Affiche_1_Parametre(frame, 28,_("Layer"), + ReturnPcbLayerName(pt_texte->m_Layer), + g_DesignSettings.m_LayerColor[pt_texte->m_Layer] & MASKCOLOR); + + Affiche_1_Parametre(frame, 36,_("Mirror"),wxEmptyString,GREEN) ; + if( (pt_texte->m_Miroir & 1) ) + Affiche_1_Parametre(frame, -1,wxEmptyString,_("No"), DARKGREEN) ; + else Affiche_1_Parametre(frame, -1,wxEmptyString,_("Yes"), DARKGREEN) ; + + + msg.Printf( wxT("%.1f"),(float)pt_texte->m_Orient/10 ); + Affiche_1_Parametre(frame, 43,_("Orient"),msg, DARKGREEN) ; + + valeur_param(pt_texte->m_Width, msg) ; + Affiche_1_Parametre(frame, 50,_("Width"),msg,MAGENTA) ; + + valeur_param(pt_texte->m_Size.x, msg) ; + Affiche_1_Parametre(frame, 60, _("H Size"),msg,RED) ; + + valeur_param(pt_texte->m_Size.y, msg); + Affiche_1_Parametre(frame, 70,_("V Size"),msg,RED) ; +} + +/************************************************************************/ +void Affiche_Infos_E_Texte(WinEDA_BasePcbFrame * frame, MODULE* Module, + TEXTE_MODULE* pt_texte) +/************************************************************************/ +/* Affiche en bas d'ecran les caract du texte sur empreinte + Entree : + pointeur de description sur le module + pointeur de la description du texte +*/ +{ +wxString text_type_msg[3] = {_("Ref."),_("Value"),_("Text")}; +wxString msg, Line; +int ii; + + frame->MsgPanel->EraseMsgBox(); + + Line = Module->m_Reference->m_Text; + Affiche_1_Parametre(frame, 1, _("Module"), Line, DARKCYAN) ; + + Line = pt_texte->m_Text; + Affiche_1_Parametre(frame, 10,_("Text"),Line,YELLOW) ; + + ii = pt_texte->m_Type; if (ii > 2) ii = 2; + Affiche_1_Parametre(frame, 20,_("Type"),text_type_msg[ii], DARKGREEN) ; + + Affiche_1_Parametre(frame, 25,_("Display"),wxEmptyString, DARKGREEN); + if(pt_texte->m_NoShow) + Affiche_1_Parametre(frame, -1,wxEmptyString, _("No"), DARKGREEN); + else Affiche_1_Parametre(frame, -1,wxEmptyString, _("Yes"), DARKGREEN); + + ii = pt_texte->m_Layer; + if ( ii <= 28) + Affiche_1_Parametre(frame, 28,_("Layer"),ReturnPcbLayerName(ii), DARKGREEN); + else + { + msg.Printf( wxT("%d"), ii); + Affiche_1_Parametre(frame, 28,_("Layer"), msg, DARKGREEN) ; + } + + msg = wxT(" Yes"); + if( (pt_texte->m_Miroir & 1) ) msg = wxT(" No"); + Affiche_1_Parametre(frame, 36,_("Mirror"),msg, DARKGREEN) ; + + msg.Printf( wxT("%.1f"),(float)pt_texte->m_Orient / 10 ); + Affiche_1_Parametre(frame, 42,_("Orient"),msg, DARKGREEN) ; + + valeur_param(pt_texte->m_Width, msg) ; + Affiche_1_Parametre(frame, 48,_("Width"),msg, DARKGREEN) ; + + valeur_param(pt_texte->m_Size.x,msg) ; + Affiche_1_Parametre(frame, 56,_("H Size"),msg,RED) ; + + valeur_param(pt_texte->m_Size.y,msg); + Affiche_1_Parametre(frame, 64,_("V Size"),msg,RED) ; + +} + + + +/*********************************************************************/ +void Affiche_Infos_Piste(WinEDA_BasePcbFrame * frame, TRACK * pt_piste) +/********************************************************************/ +/* Affiche les caract principales d'un segment de piste en bas d'ecran +*/ +{ +wxString msg; +int text_pos; + + frame->MsgPanel->EraseMsgBox(); + + switch(pt_piste->m_StructType) + { + case TYPEVIA: + msg = g_ViaType_Name[pt_piste->m_Shape & 255]; + break; + + case TYPETRACK: + msg = _("Track") ; + break; + + case TYPEZONE: + msg = _("Zone"); break; + + default: + msg = wxT("????"); break; + } + text_pos = 1; + Affiche_1_Parametre(frame, text_pos,_("Type"),msg, DARKCYAN); + + /* Affiche NetName pour les segments de piste type cuivre */ + text_pos += 15; + if( ( pt_piste->m_StructType == TYPETRACK ) || + ( pt_piste->m_StructType == TYPEZONE ) || + ( pt_piste->m_StructType == TYPEVIA ) ) + { + EQUIPOT * equipot = GetEquipot( frame->m_Pcb, pt_piste->m_NetCode); + if ( equipot ) + { + msg = equipot->m_Netname; + } + else msg = wxT(""); + Affiche_1_Parametre(frame, text_pos,_("NetName"),msg,RED) ; + + /* Affiche net code :*/ + msg.Printf( wxT("%d .%d"),pt_piste->m_NetCode, pt_piste->m_Sous_Netcode); + text_pos += 18; + Affiche_1_Parametre(frame, text_pos,_("NetCode"),msg,RED) ; + } + + else + { + Affiche_1_Parametre(frame, text_pos, _("Segment"),wxEmptyString,RED) ; + if(pt_piste->m_Shape == S_CIRCLE) + Affiche_1_Parametre(frame, -1,wxEmptyString,_("Circle"),RED) ; + else Affiche_1_Parametre(frame, -1,wxEmptyString,_("Standard"),RED) ; + } + + + /* Affiche les flags Status piste */ + msg = wxT(". . "); + if(pt_piste->GetState(SEGM_FIXE) ) msg[0] = 'F'; + if(pt_piste->GetState(SEGM_AR) ) msg[2] = 'A'; + text_pos = 42; + Affiche_1_Parametre(frame, text_pos,_("Stat"), msg,MAGENTA); + + /* Affiche Layer(s) */ + if ( pt_piste->m_StructType == TYPEVIA) + { + SEGVIA * Via = (SEGVIA *) pt_piste; + int top_layer, bottom_layer; + Via->ReturnLayerPair(&top_layer, &bottom_layer); + msg = ReturnPcbLayerName(top_layer, TRUE) + wxT("/") + ReturnPcbLayerName(bottom_layer, TRUE); + } + else msg = ReturnPcbLayerName(pt_piste->m_Layer); + + text_pos += 5; + Affiche_1_Parametre(frame, text_pos, _("Layer"), msg, BROWN) ; + + /* Affiche Epaisseur */ + valeur_param((unsigned)(pt_piste->m_Width), msg) ; + text_pos += 11; + if (pt_piste->m_StructType == TYPEVIA ) // Display Diam and Drill values + { + Affiche_1_Parametre(frame, text_pos,_("Diam"), msg, DARKCYAN); + + int drill_value = (pt_piste->m_Drill >= 0 ) ? + pt_piste->m_Drill : g_DesignSettings.m_ViaDrill; + valeur_param((unsigned)drill_value, msg); + text_pos += 8; + wxString title = _("Drill"); + if ( g_DesignSettings.m_ViaDrill >= 0 ) title += wxT("*"); + Affiche_1_Parametre(frame, text_pos,_("Drill"),msg, RED); + } + else Affiche_1_Parametre(frame, text_pos,_("Width"),msg, DARKCYAN) ; +} + +/************************************************************/ +void Affiche_Infos_DrawSegment(WinEDA_BasePcbFrame * frame, + DRAWSEGMENT * DrawSegment) +/************************************************************/ +/* Affiche les caract principales d'un segment type drawind PCB en bas d'ecran */ +{ +int itype; +wxString msg; + + frame->MsgPanel->EraseMsgBox(); + + itype = DrawSegment->m_Type & 0x0F; + + msg = wxT("DRAWING"); + if( DrawSegment->m_StructType == TYPECOTATION ) msg = wxT("COTATION"); + + Affiche_1_Parametre(frame, 1,_("Type"),msg, DARKCYAN) ; + + Affiche_1_Parametre(frame, 16,_("Shape"),wxEmptyString,RED) ; + if(DrawSegment->m_Shape == S_CIRCLE) + Affiche_1_Parametre(frame, -1,wxEmptyString,_("Circle"),RED) ; + else if (DrawSegment->m_Shape == S_ARC) + { + Affiche_1_Parametre(frame, -1,wxEmptyString, _(" Arc "),RED) ; + msg.Printf( wxT("%d"),DrawSegment->m_Angle); + Affiche_1_Parametre(frame, 32, wxT(" l.arc "), msg,RED) ; + } + else Affiche_1_Parametre(frame, -1, wxEmptyString, _("Segment"),RED) ; + + Affiche_1_Parametre(frame, 48, _("Layer"),ReturnPcbLayerName(DrawSegment->m_Layer),BROWN) ; + + /* Affiche Epaisseur */ + valeur_param((unsigned)(DrawSegment->m_Width), msg) ; + Affiche_1_Parametre(frame, 60,_("Width"), msg, DARKCYAN) ; +} + + +/*****************************************************************************/ +void Affiche_Infos_Segment_Module(WinEDA_BasePcbFrame * frame, + MODULE* Module,EDGE_MODULE* pt_edge) +/*****************************************************************************/ +/* Affiche en bas d'ecran les caract du Segment contour d'un module + Les parametres du module doivent etre a jour*/ +{ +wxString bufcar; + + if(Module == NULL) return; + + frame->MsgPanel->EraseMsgBox(); + + Affiche_1_Parametre(frame, 1,_("Seg"),wxEmptyString, DARKCYAN) ; + Affiche_1_Parametre(frame, 5 ,_("Module"),Module->m_Reference->m_Text, DARKCYAN) ; + + Affiche_1_Parametre(frame, 14,_("Value"),Module->m_Value->m_Text, BLUE) ; + + bufcar.Printf( wxT("%8.8lX"), Module->m_TimeStamp) ; + Affiche_1_Parametre(frame, 24,_("TimeStamp"),bufcar,BROWN) ; + + Affiche_1_Parametre(frame, 34,_("Mod Layer"),ReturnPcbLayerName(Module->m_Layer),RED); + + Affiche_1_Parametre(frame, 44,_("Seg Layer"), + ReturnPcbLayerName(Module->m_Layer),RED) ; + + valeur_param(pt_edge->m_Width,bufcar); + Affiche_1_Parametre(frame, 54,_("Width"), bufcar,BLUE); +} + + +/*********************************************************/ +void Affiche_Infos_Status_Pcb(WinEDA_BasePcbFrame * frame) +/*********************************************************/ +/* Affiche l'etat du PCB : nb de pads, nets , connexions.. */ +#define POS_AFF_NBPADS 1 +#define POS_AFF_NBVIAS 8 +#define POS_AFF_NBNODES 16 +#define POS_AFF_NBLINKS 24 +#define POS_AFF_NBNETS 32 +#define POS_AFF_NBCONNECT 40 +#define POS_AFF_NBNOCONNECT 48 +{ +int nb_vias = 0, ii; +EDA_BaseStruct * Struct; +wxString txt; + + frame->MsgPanel->EraseMsgBox(); + + txt.Printf( wxT("%d"),frame->m_Pcb->m_NbPads); + Affiche_1_Parametre(frame, POS_AFF_NBPADS,_("Pads"),txt, DARKGREEN) ; + + for( ii= 0, Struct = frame->m_Pcb->m_Track; Struct != NULL; Struct = Struct->Pnext) + { + ii++; + if(Struct->m_StructType == TYPEVIA) nb_vias++ ; + } + + txt.Printf( wxT("%d"),nb_vias); + Affiche_1_Parametre(frame, POS_AFF_NBVIAS,_("Vias"),txt, DARKGREEN) ; + + txt.Printf( wxT("%d"),frame->m_Pcb->GetNumNodes() ); + Affiche_1_Parametre(frame, POS_AFF_NBNODES,_("Nodes"),txt, DARKCYAN) ; + + txt.Printf( wxT("%d"),frame->m_Pcb->m_NbLinks); + Affiche_1_Parametre(frame, POS_AFF_NBLINKS,_("Links"),txt, DARKGREEN) ; + + txt.Printf( wxT("%d"),frame->m_Pcb->m_NbNets); + Affiche_1_Parametre(frame, POS_AFF_NBNETS,_("Nets"),txt,RED) ; + + txt.Printf( wxT("%d"),frame->m_Pcb->m_NbLinks - frame->m_Pcb->GetNumNoconnect()); + Affiche_1_Parametre(frame, POS_AFF_NBCONNECT,_("Connect"),txt, DARKGREEN) ; + + txt.Printf( wxT("%d"),frame->m_Pcb->GetNumNoconnect()); + Affiche_1_Parametre(frame, POS_AFF_NBNOCONNECT,_("NoConn"),txt,BLUE) ; +} + +/*******************************************************************/ +void Affiche_Infos_Equipot(int netcode, WinEDA_BasePcbFrame * frame) +/*******************************************************************/ +/* Affiche les infos relatives a une equipot: nb de pads, nets , connexions.. */ +{ +int nb_vias = 0, ii; +EDA_BaseStruct * Struct; +wxString txt; +MODULE * module; +D_PAD * pad; +EQUIPOT * equipot; + + frame->MsgPanel->EraseMsgBox(); + + equipot = GetEquipot(frame->m_Pcb, netcode); + if ( equipot ) + Affiche_1_Parametre(frame, 1,_("Net Name"),equipot->m_Netname,RED) ; + else + Affiche_1_Parametre(frame, 1,_("No Net (not connected)"), wxEmptyString, RED) ; + + txt.Printf( wxT("%d"), netcode); + Affiche_1_Parametre(frame, 30,_("Net Code"),txt,RED) ; + + for ( ii = 0, module = frame->m_Pcb->m_Modules; module != 0; + module = (MODULE*)module->Pnext) + { + for ( pad = module->m_Pads;pad != 0; pad = (D_PAD*) pad->Pnext) + { + if ( pad->m_NetCode == netcode ) ii++; + } + } + + txt.Printf( wxT("%d"),ii); + Affiche_1_Parametre(frame, 40,_("Pads"),txt, DARKGREEN) ; + + for( ii= 0, Struct = frame->m_Pcb->m_Track; Struct != NULL; Struct = Struct->Pnext) + { + ii++; + if( Struct->m_StructType == TYPEVIA ) + if ( ((SEGVIA*)Struct)->m_NetCode == netcode ) nb_vias++ ; + } + + txt.Printf( wxT("%d"),nb_vias); + Affiche_1_Parametre(frame, 50,_("Vias"),txt, BLUE) ; +} + + diff --git a/pcbnew/ar_protos.h b/pcbnew/ar_protos.h new file mode 100644 index 0000000000..3fd6b728cb --- /dev/null +++ b/pcbnew/ar_protos.h @@ -0,0 +1,85 @@ + /*************************************/ + /* ar-proto.h: Fichier entete pour l'autorouteur */ + /*************************************/ + +/**************/ +/* AUTOROUT.H */ +/**************/ + +MODULE ** GenListeModules( BOARD * Pcb, int * NbModules ); + +/***************/ +/* GRAPHPCB.CPP */ +/***************/ +/* Rem: op_logique done le type d'ecriture ( WRITE, OR , XOR , AND ) */ + +void Place_1_Pad_Board(BOARD * Pcb, D_PAD * pt_pad, int type, int marge, int op_logique); + /* Initialise a la valeur type, les cellules du Board comprises dans la + surface du pad pointe par pt_pad, avec la marge reservee pour l'isolement */ + +void TraceSegmentPcb(BOARD * Pcb, TRACK * pt_segm, int type, int marge, int op_logique); + /* trace un Segment de piste sur le BOARD */ + +void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int type, int op_logique ); + +void TraceFilledRectangle(BOARD * Pcb, int ux0, int uy0, int ux1, int uy1 ,int side, + int color, int op_logique); + /* Met a la valeur color l'ensemble des cellules du board inscrites dans + le rectangle de coord ux0,uy0 ( angle haut a droite ) + a ux1,uy1 ( angle bas a gauche ) (coord PCB) + Le rectangle est horizontal ( ou vertical ) + masque_layer = masque des couches; + op_logique = WRITE_CELL, WRITE_OR_CELL, WRITE_XOR_CELL, WRITE_AND_CELL + */ + +/* fonction surchargee: */ +void TraceFilledRectangle(BOARD * Pcb, int ux0, int uy0, int ux1, int uy1, int angle, + int masque_layer, int color, int op_logique); + /* Identique a precedemment, mais le rectangle est + incline de l'angle angle */ + + +void TraceArc(int ux0,int uy0,int ux1,int uy1, int ArcAngle, int lg,int layer, + int color, int op_logique); +/* Remplit toutes les cellules du BOARD contenues dans l'arc de "longueur" angle + de demi-largeur lg, centre ux,y0 commencant en ux,y1 a la valeur color . + coord en unites PCB (0.1 mil) relatives a l'origine pt_pcb->Pcb_oX,Y du board. +*/ + +/* SOLVE.CPP */ + +/* QUEUE.CPP */ +void FreeQueue(void); /* Libere la memoire de la queue de recherche */ +void InitQueue( void ); +void GetQueue( int *, int *, int *, int *, int * ); +int SetQueue( int, int, int, int, int, int, int ); +void ReSetQueue( int, int, int, int, int, int, int ); + + +/* WORK.CPP */ +void InitWork( void ); +void ReInitWork( void ); +int SetWork( int, int, int , int, int, CHEVELU *, int ); +void GetWork( int *, int *, int *, int *, int *, CHEVELU ** ); +void SortWork( void ); /* order the work items; shortest first */ + +/* DIST.CPP */ +int GetApxDist( int, int, int, int ); +int CalcDist( int, int, int ,int ); + +/* BOARD.CPP */ +bool ComputeMatriceSize(WinEDA_BasePcbFrame * frame, int pas_route); +int Build_Work(BOARD * Pcb, CHEVELU* pt_chevelus); +void PlaceCells(BOARD * Pcb, int net_code, int flag = 0); + +BoardCell GetCell( int, int, int ); +void SetCell( int, int, int, BoardCell ); +void OrCell( int, int, int, BoardCell ); +void XorCell( int, int, int, BoardCell ); +void AndCell( int, int, int, BoardCell ); +void AddCell( int, int, int, BoardCell ); +DistCell GetDist( int, int, int ); +void SetDist( int, int, int, DistCell ); +int GetDir( int, int, int ); +void SetDir( int, int, int, int ); + diff --git a/pcbnew/attribut.cpp b/pcbnew/attribut.cpp new file mode 100644 index 0000000000..a00d5d09ce --- /dev/null +++ b/pcbnew/attribut.cpp @@ -0,0 +1,90 @@ + /******************************************/ + /* Track editing: attribute flags edition */ + /******************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "protos.h" + + +/*****************************************************************************/ +void WinEDA_PcbFrame::Attribut_Segment(TRACK * track, wxDC * DC, bool Flag_On) +/*****************************************************************************/ +/* Attribute change for 1 track segment. +Attributes are +SEGM_FIXE protection against global delete +SEGM_AR AutoRouted segment +*/ +{ + if ( track == NULL ) return; + + GetScreen()->SetModify(); + DrawPanel->CursorOff(DC); // Erase cursor shape + track->SetState(SEGM_FIXE, Flag_On); + track->Draw(DrawPanel, DC, GR_OR | GR_SURBRILL) ; + DrawPanel->CursorOn(DC); // Display cursor shape + Affiche_Infos_Piste(this, track); +} + + +/***************************************************************************/ +void WinEDA_PcbFrame::Attribut_Track(TRACK * track, wxDC * DC, bool Flag_On) +/***************************************************************************/ +/* Attribute change for an entire track */ +{ +TRACK *Track ; +int nb_segm; + + if( (track == NULL ) || (track->m_StructType == TYPEZONE) ) return; + + DrawPanel->CursorOff(DC); // Erase cursor shape + Track = Marque_Une_Piste(this, DC, track, & nb_segm, GR_OR | GR_SURBRILL) ; + + for( ; (Track != NULL) && (nb_segm > 0) ; nb_segm-- ) + { + Track->SetState(SEGM_FIXE, Flag_On); + Track->SetState(BUSY,OFF); + Track = (TRACK*)Track->Pnext; + } + DrawPanel->CursorOn(DC); // Display cursor shape + + GetScreen()->SetModify(); +} + +/***********************************************************************/ +void WinEDA_PcbFrame::Attribut_net(wxDC * DC, int net_code, bool Flag_On) +/***********************************************************************/ +/* Modify the flag SEGM_FIXE according to Flag_On value, + for all the segments related to net_code. + if net_code < 0 all the segments are modified. +*/ +{ +TRACK *Track = m_Pcb->m_Track; + + /* search the first segment for the selected net_code */ + if ( net_code >= 0 ) + { + for ( ;Track != NULL; Track = (TRACK*) Track->Pnext ) + { + if ( net_code == Track->m_NetCode ) break; + } + } + + DrawPanel->CursorOff(DC); // Erase cursor shape + while ( Track ) /* Flag change */ + { + if ( (net_code >= 0 ) && (net_code != Track->m_NetCode) ) break; + GetScreen()->SetModify(); + Track->SetState(SEGM_FIXE, Flag_On); + Track->Draw(DrawPanel, DC, GR_OR | GR_SURBRILL); + Track = Track->Next(); + } + DrawPanel->CursorOn(DC); // Display cursor shape + GetScreen()->SetModify(); +} + + diff --git a/pcbnew/automove.cpp b/pcbnew/automove.cpp new file mode 100644 index 0000000000..1114498089 --- /dev/null +++ b/pcbnew/automove.cpp @@ -0,0 +1,405 @@ + /****************************************************************/ + /* Routines de deplacement automatique et rotation des MODULES */ + /* routines et menu d'autoplacement */ + /****************************************************************/ + + /* Fichier automove.cpp */ + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "cell.h" +#include "id.h" + +#include "protos.h" + + +/* variables locales */ + +typedef enum { + FIXE_MODULE, + FREE_MODULE, + FIXE_ALL_MODULES, + FREE_ALL_MODULES + } SelectFixeFct; + + +/* Fonctions locales */ +static int tri_modules(MODULE ** pt_ref, MODULE ** pt_compare); + +/* Variables locales */ +wxString ModulesMaskSelection = wxT("*"); +int ModulesNewOrient; + + +/******************************************************/ +void WinEDA_PcbFrame::AutoPlace(wxCommandEvent& event) +/******************************************************/ +/* Traite les selections d'outils et les commandes appelees du menu POPUP +*/ +{ +int id = event.GetId(); +wxPoint pos; +wxClientDC dc(DrawPanel); +bool on_state; + + if ( m_HToolBar == NULL ) return; + + DrawPanel->PrepareGraphicContext(&dc); + + wxGetMousePosition(&pos.x, &pos.y); + + switch ( id ) // Arret eventuel de la commande de déplacement en cours + { + case ID_POPUP_CANCEL_CURRENT_COMMAND: + if( DrawPanel->ManageCurseur && + DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + break; + + default: // Arret de la commande de déplacement en cours + if( DrawPanel->ManageCurseur && + DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + m_ID_current_state = 0; + DisplayToolMsg(wxEmptyString); + DrawPanel->SetCursor(wxCursor(wxCURSOR_ARROW) ); + break; + } + + /* Erase rastnest if needed */ + if(g_Show_Ratsnest) DrawGeneralRatsnest(&dc); + m_Pcb->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST; + + switch ( id ) // Traitement des commandes + { + case ID_TOOLBARH_PCB_AUTOPLACE: + on_state = m_HToolBar->GetToolState(ID_TOOLBARH_PCB_AUTOPLACE); + if ( on_state ) + { + m_HToolBar->ToggleTool(ID_TOOLBARH_PCB_AUTOROUTE, FALSE); + m_HTOOL_current_state = ID_TOOLBARH_PCB_AUTOPLACE; + } + else m_HTOOL_current_state = 0; + break; + + case ID_TOOLBARH_PCB_AUTOROUTE: + on_state = m_HToolBar->GetToolState(ID_TOOLBARH_PCB_AUTOROUTE); + if ( on_state ) + { + m_HToolBar->ToggleTool(ID_TOOLBARH_PCB_AUTOPLACE, FALSE); + m_HTOOL_current_state = ID_TOOLBARH_PCB_AUTOROUTE; + } + else m_HTOOL_current_state = 0; + break; + + case ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE: + FixeModule((MODULE *) m_CurrentScreen->m_CurrentItem, TRUE); + break; + + case ID_POPUP_PCB_AUTOPLACE_FREE_MODULE: + FixeModule((MODULE *) m_CurrentScreen->m_CurrentItem, FALSE); + break; + + case ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES: + FixeModule(NULL, FALSE); + break; + + case ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES: + FixeModule(NULL, TRUE); + break; + + case ID_POPUP_PCB_AUTOPLACE_CURRENT_MODULE: + AutoPlaceModule((MODULE *) m_CurrentScreen->m_CurrentItem, + PLACE_1_MODULE, &dc); + break; + + case ID_POPUP_PCB_AUTOPLACE_ALL_MODULES: + AutoPlaceModule(NULL, PLACE_ALL, &dc); + break; + + case ID_POPUP_PCB_AUTOPLACE_NEW_MODULES: + AutoPlaceModule(NULL, PLACE_OUT_OF_BOARD, &dc); + break; + + case ID_POPUP_PCB_AUTOPLACE_NEXT_MODULE: + AutoPlaceModule(NULL, PLACE_INCREMENTAL, &dc); + break; + + case ID_POPUP_PCB_AUTOMOVE_ALL_MODULES: + AutoMoveModulesOnPcb(&dc, FALSE); + break; + + case ID_POPUP_PCB_AUTOMOVE_NEW_MODULES: + AutoMoveModulesOnPcb(&dc, TRUE); + break; + + case ID_POPUP_PCB_REORIENT_ALL_MODULES: + ReOrientModules(ModulesMaskSelection, ModulesNewOrient, FALSE, &dc); + break; + + case ID_POPUP_PCB_AUTOROUTE_ALL_MODULES: + Autoroute(&dc, ROUTE_ALL); + break; + + case ID_POPUP_PCB_AUTOROUTE_MODULE: + Autoroute(&dc, ROUTE_MODULE); + break; + + case ID_POPUP_PCB_AUTOROUTE_PAD: + Autoroute(&dc, ROUTE_PAD); + break; + + case ID_POPUP_PCB_AUTOROUTE_NET: + Autoroute(&dc, ROUTE_NET); + break; + + case ID_POPUP_PCB_AUTOROUTE_RESET_UNROUTED: + Reset_Noroutable(&dc); + break; + + case ID_POPUP_PCB_AUTOROUTE_SELECT_LAYERS: + break; + + default: + DisplayError(this, wxT("AutoPlace command error") ); + break; + } + m_Pcb->m_Status_Pcb &= ~DO_NOT_SHOW_GENERAL_RASTNEST; + ReCompile_Ratsnest_After_Changes( &dc ); + SetToolbars(); +} + +/*****************************************************************************/ +void WinEDA_PcbFrame::AutoMoveModulesOnPcb(wxDC * DC, bool PlaceModulesHorsPcb) +/*****************************************************************************/ +/* Routine de repartition des composants dans un rectangle de format 4 / 3, + partant du curseur souris + Les composants ayant le status FIXE ne sont normalement pas bouges + Selon les flags: + Tous les modules (non fixes) seront repartis + Seuls les modules Hors PCB seront repartis +*/ +{ +MODULE ** pt_Dmod, ** BaseListeModules; +MODULE * Module; +wxPoint start, current; +int Ymax_size, Xsize_allowed; +int pas_grille = m_CurrentScreen->GetGrid().x; +bool EdgeExists; +float surface; + + if( m_Pcb->m_Modules == NULL ) + { + DisplayError(this, _("No Modules!"), 10);return; + } + + /* Confirmation */ + if( ! IsOK(this, _("Move Modules ?") ) ) return; + + EdgeExists = SetBoardBoundaryBoxFromEdgesOnly(); + + if( PlaceModulesHorsPcb && ! EdgeExists ) + { + DisplayError(this, + _("Autoplace modules: No boad edges detected, unable to place modules"), 20); + return; + } + + Module = m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*)Module->Pnext) // remise a jour du rect d'encadrement + { + Module->Set_Rectangle_Encadrement(); + Module->SetRectangleExinscrit(); + } + BaseListeModules = GenListeModules(m_Pcb, NULL); + + /* Si repartition de modules Hors PCB, le curseur est mis au dessous + du PCB, pour eviter de placer des composants dans la zone PCB + */ + if( PlaceModulesHorsPcb && EdgeExists ) + { + if( m_CurrentScreen->m_Curseur.y < (m_Pcb->m_BoundaryBox.GetBottom() + 2000) ) + m_CurrentScreen->m_Curseur.y = m_Pcb->m_BoundaryBox.GetBottom() + 2000; + } + + /* calcul de la surface occupee par les circuits */ + surface = 0.0; + for( pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++) + { + Module = *pt_Dmod; + if( PlaceModulesHorsPcb && EdgeExists ) + { + if( m_Pcb->m_BoundaryBox.Inside(Module->m_Pos) ) + continue; + } + surface += Module->m_Surface; + } + Xsize_allowed = (int)(sqrt(surface) * 4.0 /3.0); + + /* Placement des modules */ + start = current = m_CurrentScreen->m_Curseur; + Ymax_size = 0; + + for( pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++) + { + Module = *pt_Dmod; + if( Module->m_ModuleStatus & MODULE_is_LOCKED ) continue; + + if( PlaceModulesHorsPcb && EdgeExists ) + { + if( m_Pcb->m_BoundaryBox.Inside(Module->m_Pos) ) + continue; + } + + if( current.x > (Xsize_allowed + start.x) ) + { + current.x = start.x; + current.y += Ymax_size + pas_grille; + Ymax_size = 0; + } + + m_CurrentScreen->m_Curseur.x = + current.x + Module->m_Pos.x - Module->m_RealBoundaryBox.GetX(); + m_CurrentScreen->m_Curseur.y = + current.y + Module->m_Pos.y - Module->m_RealBoundaryBox.GetY(); + Ymax_size = MAX(Ymax_size, Module->m_RealBoundaryBox.GetHeight()); + + PutOnGrid(&m_CurrentScreen->m_Curseur); + + Module->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); + Place_Module(Module, DC); /* positionne Module et recalcule cadre */ + + current.x += Module->m_RealBoundaryBox.GetWidth ()+ pas_grille; + } + + MyFree( BaseListeModules); + m_CurrentScreen->SetRefreshReq(); +} + + +/***********************************************************/ +void WinEDA_PcbFrame::FixeModule(MODULE * Module, bool Fixe) +/***********************************************************/ +/* Met a jour (FALSE ou TRUE) l'attribut FIXE sur le module Module, +ou sur tous les modules si Modulle == NULL +*/ +{ + if ( Module) /* Traitement du module */ + { + if ( Fixe ) Module->m_ModuleStatus |= MODULE_is_LOCKED; + else Module->m_ModuleStatus &= ~MODULE_is_LOCKED; + Module->Display_Infos(this); + GetScreen()->SetModify(); + } + + else + { + Module = m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*)Module->Pnext) + { + if( WildCompareString(ModulesMaskSelection, Module->m_Reference->m_Text) ) + { + if ( Fixe ) Module->m_ModuleStatus |= MODULE_is_LOCKED; + else Module->m_ModuleStatus &= ~MODULE_is_LOCKED; + GetScreen()->SetModify(); + } + } + } +} + +/*******************************************************************/ +void WinEDA_PcbFrame::ReOrientModules(const wxString & ModuleMask, + int Orient, bool include_fixe, wxDC * DC) +/*******************************************************************/ +/* + Reoriente tous les modules selon masque et attribut, avec la nouvelle + orientation selectionnee +*/ +{ +MODULE * Module; +wxString line; + + line.Printf( _("Ok to set module orientation to %d degrees ?"), Orient/10); + if( !IsOK(this, line ) )return; + + Module = m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*)Module->Pnext) + { + if( (Module->m_ModuleStatus & MODULE_is_LOCKED ) && ! include_fixe ) + continue; + + if( WildCompareString(ModuleMask, Module->m_Reference->m_Text, FALSE ) ) + { + m_CurrentScreen->SetModify(); + Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); + Rotate_Module( NULL, Module, Orient, FALSE ); + Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); + } + } +} + + +/*********************************************************/ +MODULE ** GenListeModules( BOARD * Pcb, int * NbModules ) +/*********************************************************/ +/* Cree par allocation memoire la liste ordonnee des structures D_MODULES + decrivant les modules a deplacer + la fin de la liste est signalee par NULL + Retourne egalement le nombre de modules par *NbModules + Penser a desallouer la memoire apres usage +*/ +{ +MODULE * Module; +MODULE ** ListeMod, ** PtList; +int NbMod; + + /* Reservation de la memoire pour description des modules que l'on + peut deplacer */ + Module = Pcb->m_Modules; + NbMod = 0; + for( ; Module != NULL; Module = (MODULE*)Module->Pnext) NbMod++; + + ListeMod = (MODULE**) MyZMalloc( (NbMod+1) * sizeof(MODULE*) ); + if(ListeMod == NULL ) + { + if( NbModules != NULL ) *NbModules = 0; + return(NULL); + } + + PtList = ListeMod; + Module = Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*)Module->Pnext) + { + *PtList = Module; PtList++; + Module->SetRectangleExinscrit(); + } + + /* Tri par surface decroissante des modules ( on place les plus gros en 1er) */ + qsort(ListeMod, NbMod, sizeof(MODULE**), + (int(*)(const void *, const void * ))tri_modules); + + if( NbModules != NULL ) *NbModules = NbMod; + return( ListeMod ); +} + + /**************************************************/ + /* Routine de tri de modules, utilisee par qsort: */ + /**************************************************/ + +static int tri_modules(MODULE ** pt_ref, MODULE ** pt_compare) +{ +float ff ; + + ff = (*pt_ref)->m_Surface - (*pt_compare)->m_Surface ; + if( ff < 0 ) return(1) ; + if( ff > 0 ) return(-1) ; + return( 0 ); +} + diff --git a/pcbnew/autoplac.cpp b/pcbnew/autoplac.cpp new file mode 100644 index 0000000000..aa93c66003 --- /dev/null +++ b/pcbnew/autoplac.cpp @@ -0,0 +1,1157 @@ + /*************************************************/ + /* Routines de placement automatique des MODULES */ + /*************************************************/ + + /* Fichier autoplac.cpp */ + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "cell.h" + +#include "protos.h" + + + /************************************************************/ + /* Menu et Routines de placement automatique des composants */ + /************************************************************/ + +#define GAIN 16 +#define PENALITE 500 + + /* Penalite pour orientation donnee par CntRot90 et CntRot180: + gradue de 0 ( rotation interdite ) a 10 ( rotation a cout null ) + Le cout est ici donne en majoration + */ +static float OrientPenality[11] = { + 2.0, /* CntRot = 0 en fait rotation interdite */ + 1.9, /* CntRot = 1 */ + 1.8, /* CntRot = 2 */ + 1.7, /* CntRot = 3 */ + 1.6, /* CntRot = 4 */ + 1.5, /* CntRot = 5 */ + 1.4, /* CntRot = 5 */ + 1.3, /* CntRot = 7 */ + 1.2, /* CntRot = 8 */ + 1.1, /* CntRot = 9 */ + 1.0}; /* CntRot = 10 rotation autorisee, penalite nulle */ + + +/* Etat d'une cellule */ +#define OUT_OF_BOARD -2 +#define OCCUPED_By_MODULE -1 + +/* variables locales */ +static wxPoint CurrPosition; // position courante du module en cours de placement +static bool AutoPlaceShowAll = TRUE; + +float MinCout; + +/* Fonctions locales */ +static int TstModuleOnBoard(BOARD * Pcb, MODULE * Module, bool TstOtherSide); +static void Build_PlacedPads_List(BOARD * Pcb); +static int Tri_PlaceModules(MODULE ** pt_ref, MODULE ** pt_compare); + +static void TracePenaliteRectangle(BOARD * Pcb, int ux0, int uy0, int ux1, int uy1, + int marge, int Penalite, int masque_layer); +static MODULE * PickModule( WinEDA_PcbFrame * pcbframe, wxDC * DC ); + +/* variables importees */ +extern CHEVELU * local_liste_chevelu; // adresse de base du buffer des chevelus locaux +extern int nb_local_chevelu; // nbr de links du module en deplacement + + +/********************************************************************************/ +void WinEDA_PcbFrame::AutoPlaceModule(MODULE * Module, int place_mode, wxDC * DC) +/********************************************************************************/ + +/* Routine de Placement Automatique des composants dans le contour du PCB + Les composants ayant le status FIXE ne sont pas bouges + Si le menu appelant est le placement de 1 module, il sera replace +*/ + +{ +int ii, activ; +MODULE * ThisModule = NULL; +MODULE ** BaseListeModules; +wxPoint PosOK; +wxPoint memopos; +int error; +int NbModules = 0; +int NbTotalModules = 0; +float Pas; +int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute; + + if( m_Pcb->m_Modules == NULL ) return; + + DrawPanel->m_AbortRequest = FALSE; + DrawPanel->m_AbortEnable = TRUE; + + switch( place_mode ) + { + case PLACE_1_MODULE: + ThisModule = Module; + if(ThisModule == NULL) return; + ThisModule->m_ModuleStatus &= ~(MODULE_is_PLACED|MODULE_to_PLACE); + break; + + case PLACE_OUT_OF_BOARD: + break; + + case PLACE_ALL: + if( ! IsOK(this, _("Footprints NOT LOCKED will be moved") )) + return; + break; + + case PLACE_INCREMENTAL: + if( ! IsOK(this, _("Footprints NOT PLACED will be moved")) ) + return; + break; + } + + memopos = CurrPosition; + lay_tmp_BOTTOM = Route_Layer_BOTTOM; + lay_tmp_TOP = Route_Layer_TOP; + OldPasRoute = g_GridRoutingSize; + + g_GridRoutingSize = m_CurrentScreen->GetGrid().x; + // Ensure g_GridRoutingSize has a reasonnable value: + if ( g_GridRoutingSize < 10 ) g_GridRoutingSize = 10; // Min value = 1/1000 inch + + /* Compute module parmeters used in auto place */ + Module = m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*)Module->Pnext) // remise a jour du rect d'encadrement + { + Module->Set_Rectangle_Encadrement(); + Module->SetRectangleExinscrit(); + } + + /* Generation du plan de placement */ + if( GenPlaceBoard() == 0) return; + + /* Mise a jour des parametres modules utiles au placement */ + BaseListeModules = GenListeModules(m_Pcb, &NbTotalModules ); + MyFree(BaseListeModules); + + /* Placement des modules fixes sur le plan de placement */ + Module = m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*)Module->Pnext ) + { + Module->m_ModuleStatus &= ~MODULE_to_PLACE; + + switch( place_mode ) + { + case PLACE_1_MODULE: + if( ThisModule == Module ) + Module->m_ModuleStatus |= MODULE_to_PLACE; + break; + + case PLACE_OUT_OF_BOARD: + Module->m_ModuleStatus &= ~MODULE_is_PLACED; + if( Module->m_ModuleStatus & MODULE_is_LOCKED ) break; + if( ! m_Pcb->m_BoundaryBox.Inside(Module->m_Pos) ) + Module->m_ModuleStatus |= MODULE_to_PLACE; + break; + + case PLACE_ALL: + Module->m_ModuleStatus &= ~MODULE_is_PLACED; + if( Module->m_ModuleStatus & MODULE_is_LOCKED ) break; + Module->m_ModuleStatus |= MODULE_to_PLACE; + break; + + case PLACE_INCREMENTAL: + if( Module->m_ModuleStatus & MODULE_is_LOCKED ) + { + Module->m_ModuleStatus &= ~MODULE_is_PLACED; break; + } + if( ! (Module->m_ModuleStatus & MODULE_is_PLACED) ) + Module->m_ModuleStatus |= MODULE_to_PLACE; + break; + } + + + if( Module->m_ModuleStatus & MODULE_to_PLACE ) // Erase from screen + { + NbModules++; + Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); + } + + else + { + GenModuleOnBoard(Module); + } + } + + /* Placement des modules */ + activ = 0; Pas = 100.0; + if( NbModules ) Pas = 100.0 / (float)NbModules; + while( (Module = PickModule(this, DC) ) != NULL ) + { + float BestScore; + DisplayActivity((int)(activ * Pas) , wxEmptyString ); activ++; + + /* Affichage du remplissage: surface de placement, obstacles, penalites */ + DrawInfoPlace(DC); + + /* Recherche du placement: orientation 0 */ + error = RecherchePlacementModule(Module, DC); + BestScore = MinCout; + PosOK = CurrPosition; + if ( error == ESC ) goto end_of_tst; + + /* Recherche du placement: orientation 180 */ + ii = Module->m_CntRot180 & 0x0F; + if( ii != 0 ) + { + int Angle_Rot_Module = 1800; + Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); + Module->SetRectangleExinscrit(); + error = RecherchePlacementModule(Module, DC ); + MinCout *= OrientPenality[ii]; + if( BestScore > MinCout ) /* Cette orientation est meilleure */ + { + PosOK = CurrPosition; + BestScore = MinCout; + } + else + { + Angle_Rot_Module = -1800; + Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); + } + if ( error == ESC ) goto end_of_tst; + } + + /* Recherche du placement: orientation 90 */ + ii = Module->m_CntRot90 & 0x0F; + if( ii != 0 ) + { + int Angle_Rot_Module = 900; + Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); + error = RecherchePlacementModule(Module, DC ); + MinCout *= OrientPenality[ii]; + if( BestScore > MinCout ) /* Cette orientation est meilleure */ + { + PosOK = CurrPosition; + BestScore = MinCout; + } + else + { + Angle_Rot_Module = -900; + Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); + } + if ( error == ESC ) goto end_of_tst; + } + + /* Recherche du placement: orientation -90 (ou 270 degres) */ + ii = (Module->m_CntRot90 >> 4 ) & 0x0F; + if( ii != 0 ) + { + int Angle_Rot_Module = 2700; + Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); + error = RecherchePlacementModule(Module, DC ); + MinCout *= OrientPenality[ii]; + if( BestScore > MinCout ) /* Cette orientation est meilleure */ + { + PosOK = CurrPosition; + BestScore = MinCout; + } + else + { + Angle_Rot_Module = -2700; + Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); + } + if ( error == ESC ) goto end_of_tst; + } + +end_of_tst: + + if ( error == ESC ) break; + + /* placement du module */ + CurrPosition = m_CurrentScreen->m_Curseur; + m_CurrentScreen->m_Curseur = PosOK; + Place_Module(Module, DC); + m_CurrentScreen->m_Curseur = CurrPosition; + + Module->Set_Rectangle_Encadrement(); + Module->SetRectangleExinscrit(); + + GenModuleOnBoard(Module); + Module->m_ModuleStatus |= MODULE_is_PLACED; + Module->m_ModuleStatus &= ~MODULE_to_PLACE; + } + + CurrPosition = memopos; + + /* Liberation de la memoire */ + Board.UnInitBoard(); + + Route_Layer_TOP = lay_tmp_TOP; + Route_Layer_BOTTOM = lay_tmp_BOTTOM; + g_GridRoutingSize = OldPasRoute; + + Module = m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*)Module->Pnext ) + { + Module->Set_Rectangle_Encadrement(); + } + + /* Recalcul de la liste des pads, detruite par les calculs precedents */ + m_Pcb->m_Status_Pcb = 0; build_liste_pads(); + + DrawPanel->ReDraw(DC, TRUE); + + DrawPanel->m_AbortEnable = FALSE; + +} + +/**********************************************/ +void WinEDA_PcbFrame::DrawInfoPlace(wxDC * DC) +/**********************************************/ +/* Affiche a l'ecran les infos de placement +*/ +{ +int color, ii, jj; +int ox, oy, top_state, bottom_state; + + GRSetDrawMode(DC, GR_COPY); + for ( ii = 0; ii < Nrows; ii ++ ) + { + oy = m_Pcb->m_BoundaryBox.m_Pos.y + (ii * g_GridRoutingSize); + + for (jj = 0; jj < Ncols ; jj ++ ) + { + ox = m_Pcb->m_BoundaryBox.m_Pos.x + (jj * g_GridRoutingSize); + /* surface de placement : */ + color = BLACK; + + top_state = GetCell(ii, jj , TOP); + bottom_state = GetCell(ii, jj , BOTTOM); + + if( (top_state & CELL_is_ZONE) ) color = BLUE; + + /* obstacles */ + if( (top_state & CELL_is_EDGE) || (bottom_state & CELL_is_EDGE)) color = WHITE; + + else if( top_state & (HOLE|CELL_is_MODULE) ) color = LIGHTRED; + else if( bottom_state & (HOLE|CELL_is_MODULE) ) color = LIGHTGREEN; + + else /* Affichage du remplissage: Penalites */ + { + if( GetDist(ii, jj , TOP ) || GetDist(ii, jj , BOTTOM ) ) + color = DARKGRAY; + } + + GRPutPixel(&DrawPanel->m_ClipBox, DC, ox, oy, color); + } + } +} + + +/***************************************/ +int WinEDA_PcbFrame::GenPlaceBoard(void) +/***************************************/ + +/* Routine de generation du board ( cote composant + cote cuivre ) : + Alloue la memoire necessaire pour representer en "bitmap" sur la grille + courante: + - la surface de placement des composant ( le board ) + - le bitmap des penalites + et initialise les cellules du board a + - HOLE pour les cellules occupees par un segment EDGE + - CELL_is_ZONE pour les cellules internes au contour EDGE (s'il est ferme) + + la surface de placement (board) donne les cellules internes au contour + du pcb, et parmi celle-ci les cellules libres et les cellules deja occupees + + le bitmap des penalites donnent les cellules occupes par les modules, + augmentes d'une surface de penalite liee au nombre de pads du module + + le bitmap des penalites est mis a 0 + l'occupation des cellules est laisse a 0 +*/ +{ +int jj, ii; +int NbCells; +EDA_BaseStruct * PtStruct; +wxString msg; + + Board.UnInitBoard(); + + if( ! SetBoardBoundaryBoxFromEdgesOnly() ) + { + DisplayError(this, _("No edge PCB, Unknown board size!"), 30); + return(0); + } + + /* The boundary box must have its start point on placing grid: */ + m_Pcb->m_BoundaryBox.m_Pos.x -= m_Pcb->m_BoundaryBox.m_Pos.x % g_GridRoutingSize; + m_Pcb->m_BoundaryBox.m_Pos.y -= m_Pcb->m_BoundaryBox.m_Pos.y % g_GridRoutingSize; + /* The boundary box must have its end point on placing grid: */ + wxPoint end = m_Pcb->m_BoundaryBox.GetEnd(); + end.x -= end.x % g_GridRoutingSize; end.x += g_GridRoutingSize; + end.y -= end.y % g_GridRoutingSize; end.y += g_GridRoutingSize; + m_Pcb->m_BoundaryBox.SetEnd(end); + + Nrows = m_Pcb->m_BoundaryBox.GetHeight() / g_GridRoutingSize; + Ncols = m_Pcb->m_BoundaryBox.GetWidth() / g_GridRoutingSize; + /* get a small margin for memory allocation: */ + Ncols += 2; Nrows += 2; + NbCells = Ncols * Nrows; + + MsgPanel->EraseMsgBox(); + msg.Printf( wxT("%d"),Ncols); + Affiche_1_Parametre(this, 1, _("Cols"),msg,GREEN); + msg.Printf( wxT("%d"),Nrows); + Affiche_1_Parametre(this, 7, _("Lines"),msg,GREEN); + msg.Printf( wxT("%d"),NbCells); + Affiche_1_Parametre(this, 14, _("Cells."),msg,YELLOW); + + /* Choix du nombre de faces de placement */ + Nb_Sides = TWO_SIDES; + + Affiche_1_Parametre(this, 22, wxT("S"), ( Nb_Sides == TWO_SIDES ) ? wxT("2") : wxT("1"), WHITE); + + /* Creation du mapping du board */ + Board.InitBoard(); + + /* Affichage de la memoire utilisee */ + msg.Printf( wxT("%d"), Board.m_MemSize / 1024 ); + Affiche_1_Parametre(this, 24, wxT("Mem(Ko)"),msg,CYAN); + + Route_Layer_BOTTOM = CMP_N; + if( Nb_Sides == TWO_SIDES ) Route_Layer_BOTTOM = CUIVRE_N; + Route_Layer_TOP = CMP_N; + + /* Place the edge layer segments */ + PtStruct = m_Pcb->m_Drawings; + TRACK TmpSegm(NULL); + TmpSegm.m_Layer = -1; + TmpSegm.m_NetCode = -1; + TmpSegm.m_Width = g_GridRoutingSize/2; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + DRAWSEGMENT * DrawSegm; + switch( PtStruct->m_StructType) + { + case TYPEDRAWSEGMENT: + DrawSegm = (DRAWSEGMENT *) PtStruct; + if(DrawSegm->m_Layer != EDGE_N) break; + + TmpSegm.m_Start = DrawSegm->m_Start; + TmpSegm.m_End = DrawSegm->m_End; + TmpSegm.m_Shape = DrawSegm->m_Shape; + TmpSegm.m_Param = DrawSegm->m_Angle; + + TraceSegmentPcb(m_Pcb, &TmpSegm, HOLE|CELL_is_EDGE, g_GridRoutingSize, WRITE_CELL ); + break; + + case TYPETEXTE: + default: break; + } + } + + + /* Init du point d'accrochage de la zone */ + OrCell(Nrows/2, Ncols/2, BOTTOM, CELL_is_ZONE); + + /* Remplissage des cellules de la couche BOTTOM */ + ii = 1; jj = 1; + + while( ii ) + { + msg.Printf( wxT("%d"), jj++ ); + Affiche_1_Parametre(this, 50, _("Loop"),msg,CYAN); + ii = Propagation(this); + } + + /* Init de la couche TOP */ + if( Board.m_BoardSide[TOP] ) + memcpy( Board.m_BoardSide[TOP], Board.m_BoardSide[BOTTOM],NbCells * sizeof(BoardCell)); + + return(1); +} + + +/******************************************************/ +void WinEDA_PcbFrame::GenModuleOnBoard(MODULE * Module) +/******************************************************/ +/* initialise sur le board de placement les cellules correspondantes au + module Module +*/ +{ +int ox, oy, fx, fy, Penalite; +int marge = g_GridRoutingSize / 2; +int masque_layer; +D_PAD * Pad; + + ox = Module->m_RealBoundaryBox.m_Pos.x - marge; + fx = Module->m_RealBoundaryBox.GetRight() + marge; + oy = Module->m_RealBoundaryBox.m_Pos.y - marge; + fy = Module->m_RealBoundaryBox.GetBottom() + marge; + + if( ox < m_Pcb->m_BoundaryBox.m_Pos.x) + ox = m_Pcb->m_BoundaryBox.m_Pos.x; + if( ox > m_Pcb->m_BoundaryBox.GetRight()) + ox = m_Pcb->m_BoundaryBox.GetRight(); + + if( fx < m_Pcb->m_BoundaryBox.m_Pos.x) fx = m_Pcb->m_BoundaryBox.m_Pos.x; + if( fx > m_Pcb->m_BoundaryBox.GetRight()) + fx = m_Pcb->m_BoundaryBox.GetRight(); + + if( oy < m_Pcb->m_BoundaryBox.m_Pos.y) oy = m_Pcb->m_BoundaryBox.m_Pos.y; + if( oy > m_Pcb->m_BoundaryBox.GetBottom()) + oy = m_Pcb->m_BoundaryBox.GetBottom(); + + if( fy < m_Pcb->m_BoundaryBox.m_Pos.y) fy = m_Pcb->m_BoundaryBox.m_Pos.y; + if( fy > m_Pcb->m_BoundaryBox.GetBottom()) + fy = m_Pcb->m_BoundaryBox.GetBottom(); + + masque_layer = 0; + if( Module->m_Layer == CMP_N ) masque_layer = CMP_LAYER; + if( Module->m_Layer == CUIVRE_N ) masque_layer = CUIVRE_LAYER; + + TraceFilledRectangle(m_Pcb, ox, oy, fx, fy, masque_layer, + CELL_is_MODULE, WRITE_OR_CELL); + + /* Trace des pads et leur surface de securite */ + marge = g_DesignSettings.m_TrackClearence + g_DesignSettings.m_CurrentTrackWidth; + + for(Pad = Module->m_Pads ; Pad != NULL; Pad = (D_PAD *) Pad->Pnext ) + { + Place_1_Pad_Board( m_Pcb, Pad, CELL_is_MODULE, marge, WRITE_OR_CELL); + } + + /* Trace de la penalite */ + marge = (g_GridRoutingSize * Module->m_PadNum ) / GAIN; + Penalite = PENALITE; + TracePenaliteRectangle(m_Pcb, ox, oy, fx, fy, marge, Penalite, + masque_layer); +} + + +/************************************************************************/ +int WinEDA_PcbFrame::RecherchePlacementModule(MODULE * Module, wxDC * DC) +/************************************************************************/ +/* + Routine Principale de recherche de la position optimale du module + Entree: + Module pointe la struct MODULE du module a placer. + Retourne: + 1 si placement impossible, 0 si OK + et MinCout = variable externe = cout du meilleur placement +*/ +{ +int cx, cy; +int ox, oy, fx, fy; /* cadre d'occupation du module centre sur le curseur */ +int error = 1; +int DisplayChevelu = 0; +wxPoint LastPosOK; +float mincout, cout, Score; +int Penalite; +bool TstOtherSide; + + Module->Display_Infos(this); + + Build_PlacedPads_List(m_Pcb); + + LastPosOK.x = m_Pcb->m_BoundaryBox.m_Pos.x; + LastPosOK.y = m_Pcb->m_BoundaryBox.m_Pos.y; + + cx = Module->m_Pos.x; cy = Module->m_Pos.y; + ox = Module->m_RealBoundaryBox.m_Pos.x - cx; + fx = Module->m_RealBoundaryBox.m_Size.x + ox; + oy = Module->m_RealBoundaryBox.m_Pos.y - cy; + fy = Module->m_RealBoundaryBox.m_Size.y + oy; + + CurrPosition.x = m_Pcb->m_BoundaryBox.m_Pos.x - ox; + CurrPosition.y = m_Pcb->m_BoundaryBox.m_Pos.y - oy; + /* remise sur la grille de placement: */ + CurrPosition.x -= CurrPosition.x % g_GridRoutingSize; + CurrPosition.y -= CurrPosition.y % g_GridRoutingSize; + + g_Offset_Module.x = cx - CurrPosition.x; + g_Offset_Module.y = cy - CurrPosition.y; + m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; + + /* tst des pastilles traversantes, qui pour un circuit imprime ayant des + composants des 2 cotes, peuvent tomber sur un composant de cote oppose: + s'il y a au moins 1 pastille apparaissant sur l'autre cote, ce cote + est teste */ + + TstOtherSide = FALSE; + if( Nb_Sides == TWO_SIDES ) + { + D_PAD * Pad; int masque_otherlayer; + masque_otherlayer = CUIVRE_LAYER; + if ( Module->m_Layer == CUIVRE_N ) masque_otherlayer = CMP_LAYER; + + for(Pad = Module->m_Pads ; Pad != NULL; Pad = (D_PAD *) Pad->Pnext ) + { + if( (Pad->m_Masque_Layer & masque_otherlayer) == 0 ) continue; + TstOtherSide = TRUE; + break; + } + } + + + DrawModuleOutlines(DrawPanel, DC, Module); + + mincout = -1.0; + Affiche_Message(wxT("Score ??, pos ??") ); + + for ( ; CurrPosition.x < m_Pcb->m_BoundaryBox.GetRight() - fx; + CurrPosition.x += g_GridRoutingSize ) + { + wxYield(); + if ( DrawPanel->m_AbortRequest ) + { + if ( IsOK(this, _("Ok to abort ?")) ) return ESC; + else DrawPanel->m_AbortRequest = FALSE; + } + + cx = Module->m_Pos.x; cy = Module->m_Pos.y; + Module->m_RealBoundaryBox.m_Pos.x = ox + CurrPosition.x; + Module->m_RealBoundaryBox.m_Pos.y = oy + CurrPosition.y; + + DrawModuleOutlines(DrawPanel, DC, Module); + + g_Offset_Module.x = cx - CurrPosition.x; + CurrPosition.y = m_Pcb->m_BoundaryBox.m_Pos.y - oy; + /* remise sur la grille de placement: */ + CurrPosition.y -= CurrPosition.y % g_GridRoutingSize; + + DrawModuleOutlines(DrawPanel, DC, Module); + + for ( ; CurrPosition.y < m_Pcb->m_BoundaryBox.GetBottom() - fy; + CurrPosition.y += g_GridRoutingSize ) + { + /* effacement des traces */ + DrawModuleOutlines(DrawPanel, DC, Module); + if (DisplayChevelu) Compute_Ratsnest_PlaceModule(DC); + DisplayChevelu = 0; + Module->m_RealBoundaryBox.m_Pos.x = ox + CurrPosition.x; + Module->m_RealBoundaryBox.m_Pos.y = oy + CurrPosition.y; + + g_Offset_Module.y = cy - CurrPosition.y; + DrawModuleOutlines(DrawPanel, DC, Module); + Penalite = TstModuleOnBoard(m_Pcb, Module, TstOtherSide ); + if( Penalite >= 0 ) /* c a d si le module peut etre place */ + { + error = 0; + build_ratsnest_module(DC, Module); + cout = Compute_Ratsnest_PlaceModule(DC); + DisplayChevelu = 1; + Score = cout + (float) Penalite; + + if( (mincout >= Score ) || (mincout < 0 ) ) + { + LastPosOK = CurrPosition; + mincout = Score; + wxString msg; + msg.Printf( wxT("Score %d, pos %3.4f, %3.4f"), + (int)mincout, + (float)LastPosOK.x /10000, (float)LastPosOK.y /10000); + Affiche_Message(msg); + } + } + if( DisplayChevelu ) Compute_Ratsnest_PlaceModule(DC); + DisplayChevelu = 0; + } + } + + DrawModuleOutlines(DrawPanel, DC, Module); /* effacement du dernier trace */ + if (DisplayChevelu) Compute_Ratsnest_PlaceModule(DC); + + /* Regeneration des variables modifiees */ + Module->m_RealBoundaryBox.m_Pos.x = ox + cx; + Module->m_RealBoundaryBox.m_Pos.y = oy + cy; + CurrPosition = LastPosOK; + + m_Pcb->m_Status_Pcb &= ~(CHEVELU_LOCAL_OK | LISTE_PAD_OK ); + + MinCout = mincout; + return(error); +} + + + +/**************************************************************************/ +int TstRectangle(BOARD * Pcb, int ux0, int uy0, int ux1, int uy1, int side) +/**************************************************************************/ +/* tst si la surface rectangulaire (ux,y0 .. ux,y1): + - est sur une zone libre ( retourne OCCUPED_By_MODULE sinon) + - est sur la surface utile du board ( retourne OUT_OF_BOARD sinon) + + retourne 0 si OK +*/ +{ +int row, col; +int row_min, row_max, col_min, col_max; +unsigned int data; + + ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y; + ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y; + + /* Calcul des coord limites des cellules appartenant au rectangle */ + row_max = uy1 / g_GridRoutingSize; + col_max = ux1 / g_GridRoutingSize; + row_min = uy0 / g_GridRoutingSize; if (uy0 > row_min*g_GridRoutingSize ) row_min++; + col_min = ux0 / g_GridRoutingSize; if (ux0 > col_min*g_GridRoutingSize ) col_min++; + + if( row_min < 0 ) row_min = 0; + if( row_max >= (Nrows-1)) row_max = Nrows-1; + if( col_min < 0 ) col_min = 0; + if( col_max >= (Ncols-1)) col_max = Ncols-1; + + for( row = row_min ;row <= row_max ; row++) + { + for(col = col_min;col <= col_max; col++) + { + data = GetCell(row,col,side); + if( (data & CELL_is_ZONE) == 0 ) /* Cellule non autorisee */ + return(OUT_OF_BOARD); + if( data & CELL_is_MODULE ) /* Deja utilisee */ + return(OCCUPED_By_MODULE); + } + } + return( 0 ); +} + + +/******************************************************************************/ +unsigned int CalculePenaliteRectangle(BOARD * Pcb, int ux0, int uy0, + int ux1, int uy1, int side) +/******************************************************************************/ +/* calcule et retourne la penalite de la surface rectangulaire (ux,y0 .. ux,y1): + ( somme des valeurs des cellules du plan des Distances ) +*/ +{ +int row, col; +int row_min, row_max, col_min, col_max; +unsigned int Penalite; + + ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y; + ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y; + + /* Calcul des coord limites des cellules appartenant au rectangle */ + row_max = uy1 / g_GridRoutingSize; + col_max = ux1 / g_GridRoutingSize; + row_min = uy0 / g_GridRoutingSize; if (uy0 > row_min*g_GridRoutingSize ) row_min++; + col_min = ux0 / g_GridRoutingSize; if (ux0 > col_min*g_GridRoutingSize ) col_min++; + + if( row_min < 0 ) row_min = 0; + if( row_max >= (Nrows-1)) row_max = Nrows-1; + if( col_min < 0 ) col_min = 0; + if( col_max >= (Ncols-1)) col_max = Ncols-1; + + Penalite = 0; + for( row = row_min ;row <= row_max ; row++) + { + for(col = col_min;col <= col_max; col++) + { + Penalite += (int) GetDist(row, col, side ); + } + } + return( Penalite ); +} + +/**********************************************************************/ +int TstModuleOnBoard(BOARD * Pcb, MODULE * Module, bool TstOtherSide) +/**********************************************************************/ +/* Teste si le module peut etre place sur le board. + retourne de diagnostic de TstRectangle(). + le module est connu par son rectangle d'encadrement +*/ +{ +int ox, oy, fx, fy; +int error, Penalite, marge, side, otherside; + + side = TOP; otherside = BOTTOM; + if ( Module->m_Layer == CUIVRE_N ) + { + side = BOTTOM; otherside = TOP; + } + + ox = Module->m_RealBoundaryBox.m_Pos.x; + fx = Module->m_RealBoundaryBox.GetRight(); + oy = Module->m_RealBoundaryBox.m_Pos.y; + fy = Module->m_RealBoundaryBox.GetBottom(); + + error = TstRectangle(Pcb, ox, oy, fx, fy, side ); + if( error < 0 ) return (error); + + if( TstOtherSide ) + { + error = TstRectangle(Pcb, ox, oy, fx, fy, otherside ); + if( error < 0 ) return (error); + } + + marge = (g_GridRoutingSize * Module->m_PadNum ) / GAIN; + + Penalite = CalculePenaliteRectangle(Pcb, ox - marge, oy - marge, + fx + marge, fy + marge, side ); + return( Penalite ); +} + + +/************************************************************/ +float WinEDA_PcbFrame::Compute_Ratsnest_PlaceModule(wxDC * DC) +/************************************************************/ + +/* Routine affichant le chevelu du module en cours de deplacement, et + evaluant le "cout" de la position. + Le cout est la longueur des chevelus en distance de manhattan, avec + penalite pour les inclinaisons se rapprochant de 45 degre +*/ +{ +CHEVELU* pt_local_chevelu ; +int ii; +float cout, icout; +int ox, oy, fx, fy, dx , dy; + + if((m_Pcb->m_Status_Pcb & CHEVELU_LOCAL_OK) == 0) + return(-1); + + pt_local_chevelu = local_liste_chevelu; + ii = nb_local_chevelu; cout = 0; + + while( ii-- > 0 ) + { + if(pt_local_chevelu->status & LOCAL_CHEVELU) + { // Non Affiché + } + else + { + ox = pt_local_chevelu->pad_start->m_Pos.x - g_Offset_Module.x; + oy = pt_local_chevelu->pad_start->m_Pos.y - g_Offset_Module.y; + fx = pt_local_chevelu->pad_end->m_Pos.x; + fy = pt_local_chevelu->pad_end->m_Pos.y; + + if ( AutoPlaceShowAll ) + { + GRLine(&DrawPanel->m_ClipBox, DC, ox, oy, fx, fy, g_DesignSettings.m_RatsnestColor|GR_XOR) ; + } + + /* Evaluation du cout du chevelu: */ + dx = fx - ox; dy = fy - oy; + dx = abs(dx); dy = abs( dy ); + if( dx < dy ) EXCHG(dx,dy); /* dx >= dy */ + /* cout de la distance: */ + icout = (float) dx * dx; + /* cout de l'inclinaison */ + icout += 3 * (float) dy * dy; + icout = sqrt(icout); + cout += icout; /* cout total = somme des couts de chaque chevelu */ + } + pt_local_chevelu++; + } + return (cout); +} + +/********************************************/ +void Build_PlacedPads_List(BOARD * Pcb) +/********************************************/ +/* + construction de la liste ( sous forme d'une liste de stucture ) + des caract utiles des pads du PCB pour Placement Automatique ) + Cette liste est restreinte a la liste des pads des modules deja places sur + la carte. + + parametres: + adresse du buffer de classement = Pcb->ptr_pads; + +Variables globales mise a jour: + pointeur ptr_pads (adr de classement de la liste des pads) + nb_pads = nombre utile de pastilles classes + m_Status_Pcb |= LISTE_PAD_OK +*/ +{ +LISTE_PAD* pt_liste_pad; +MODULE * Module; +D_PAD * PtPad; + + if( Pcb->m_Pads ) MyFree( Pcb->m_Pads ); + + pt_liste_pad = Pcb->m_Pads = NULL; + Pcb->m_NbPads = Pcb->m_NbNodes = 0; + + /* Calcul du nombre de pads utiles */ + Module = Pcb->m_Modules; + for( ; Module != NULL ; Module = (MODULE*) Module->Pnext) + { + if( Module->m_ModuleStatus & MODULE_to_PLACE ) continue; + PtPad = (D_PAD*) Module->m_Pads; + for(; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) + { + Pcb->m_NbPads++; + } + } + + /* Allocation memoire du buffer */ + if ( Pcb->m_NbPads > 0) + { + pt_liste_pad = Pcb->m_Pads + = (D_PAD**) MyMalloc(Pcb->m_NbPads * sizeof(D_PAD*) ); + } + + /* Initialisation du buffer et des variables de travail */ + Module = Pcb->m_Modules; + for( ;(Module != NULL) && (pt_liste_pad != NULL); Module = (MODULE*) Module->Pnext) + { + if( Module->m_ModuleStatus & MODULE_to_PLACE ) continue; + PtPad = (D_PAD*) Module->m_Pads; + for(; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) + { + *pt_liste_pad = PtPad; + PtPad->m_physical_connexion = 0; + PtPad->m_logical_connexion = 0; + PtPad->m_Parent = Module; + if(PtPad->m_NetCode) Pcb->m_NbNodes++; + pt_liste_pad++; + } + } + + Pcb->m_Status_Pcb |= LISTE_PAD_OK; + Pcb->m_Status_Pcb &= ~(LISTE_CHEVELU_OK | CHEVELU_LOCAL_OK); + adr_lowmem = buf_work; +} + + +/*****************************************************************/ +/* Construction de la zone de penalite ( rectangle ) d'un module */ +/*****************************************************************/ + +/* les cellules ( du plan des Distances ) du rectangle x0,y0 a x1,y1 sont + incrementees de la valeur Penalite + celles qui sont externes au rectangle, mais internes au rectangle + x0,y0 -marge a x1,y1 + marge sont incrementees d'une valeur + (Penalite ... 0) decroissante en fonction de leur eloignement +*/ +static void TracePenaliteRectangle(BOARD * Pcb, int ux0, int uy0, int ux1, int uy1 , + int marge, int Penalite, int masque_layer) +{ +int row, col; +int row_min, row_max, col_min, col_max, pmarge; +int trace = 0; +DistCell data, LocalPenalite; +int lgain, cgain; + + if(masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM]) + trace = 1; /* Trace sur BOTTOM */ + + if( (masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) && Nb_Sides) + trace |= 2; /* Trace sur TOP */ + + if(trace == 0) return; + + ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y; + ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y; + + ux0 -= marge; ux1 += marge; + uy0 -= marge; uy1 += marge; + + pmarge = marge / g_GridRoutingSize; if (pmarge < 1 ) pmarge = 1; + + /* Calcul des coord limites des cellules appartenant au rectangle */ + row_max = uy1 / g_GridRoutingSize; + col_max = ux1 / g_GridRoutingSize; + row_min = uy0 / g_GridRoutingSize; if (uy0 > row_min*g_GridRoutingSize ) row_min++; + col_min = ux0 / g_GridRoutingSize; if (ux0 > col_min*g_GridRoutingSize ) col_min++; + + if( row_min < 0 ) row_min = 0; + if( row_max >= (Nrows-1)) row_max = Nrows-1; + if( col_min < 0 ) col_min = 0; + if( col_max >= (Ncols-1)) col_max = Ncols-1; + + for( row = row_min ;row <= row_max ; row++) + { + lgain = 256; + if ( row < pmarge ) + lgain = (256 * row) / pmarge; + else if( row > row_max - pmarge ) + lgain = (256 * (row_max - row) ) / pmarge; + + for(col = col_min;col <= col_max; col++) + { + cgain = 256; + LocalPenalite = Penalite; + if ( col < pmarge ) + cgain = (256 * col) / pmarge; + else if( col > col_max - pmarge ) + cgain = (256 * (col_max - col) ) / pmarge; + + cgain = (cgain * lgain) / 256; + if( cgain != 256 ) LocalPenalite = (LocalPenalite * cgain) / 256; + if(trace & 1) + { + data = GetDist(row,col,BOTTOM) + LocalPenalite; + SetDist(row,col,BOTTOM, data); + } + if(trace & 2) + { + data = GetDist(row,col,TOP); + data = max( data, LocalPenalite); + SetDist(row,col,TOP, data); + } + } + } +} + + /***************************************************/ + /* Routines de tri de modules, utilisee par qsort: */ + /***************************************************/ + +static int Tri_PlaceModules(MODULE ** pt_ref, MODULE ** pt_compare) +{ +float ff, ff1, ff2 ; + + ff1 = (*pt_ref)->m_Surface * (*pt_ref)->m_PadNum ; + ff2 = (*pt_compare)->m_Surface * (*pt_compare)->m_PadNum ; + ff = ff1 - ff2 ; + if( ff < 0 ) return(1) ; + if( ff > 0 ) return(-1) ; + return( 0 ); +} + +static int Tri_RatsModules(MODULE ** pt_ref, MODULE ** pt_compare) +{ +float ff, ff1, ff2 ; + + ff1 = (*pt_ref)->m_Surface * (*pt_ref)->flag; + ff2 = (*pt_compare)->m_Surface * (*pt_compare)->flag; + ff = ff1 - ff2 ; + if( ff < 0 ) return(1) ; + if( ff > 0 ) return(-1) ; + return( 0 ); +} + + +/***************************************************************/ +static MODULE * PickModule(WinEDA_PcbFrame * pcbframe, wxDC * DC) +/***************************************************************/ + +/* Recherche le "meilleur" module a placer + les criteres de choix sont: + - maximum de chevelus avec les modules deja places + - taille max, et nombre de pads max +*/ +{ +MODULE ** BaseListeModules, ** pt_Dmod; +MODULE * Module = NULL, * AltModule = NULL; +CHEVELU* pt_local_chevelu; +int NbModules, ii; + + BaseListeModules = GenListeModules(pcbframe->m_Pcb, &NbModules ); + if( BaseListeModules == NULL ) return(NULL); + + Build_PlacedPads_List(pcbframe->m_Pcb); + + /* Tri par surface decroissante des modules + (on place les plus gros en 1er), surface ponderee par le nombre de pads */ + + qsort(BaseListeModules, NbModules, sizeof(MODULE**), + (int(*)(const void *, const void * ))Tri_PlaceModules); + + for(pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++) + { + (*pt_Dmod)->flag = 0; + if( ! ((*pt_Dmod)->m_ModuleStatus & MODULE_to_PLACE) ) continue; + pcbframe->m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; + adr_lowmem = buf_work; + (*pt_Dmod)->Display_Infos(pcbframe); + pcbframe->build_ratsnest_module(DC, *pt_Dmod); + + /* calcul du nombre de chevelus externes */ + pt_local_chevelu = local_liste_chevelu; + ii = nb_local_chevelu; + while( ii-- > 0 ) + { + if( (pt_local_chevelu->status & LOCAL_CHEVELU) == 0 ) + (*pt_Dmod)->flag++; + pt_local_chevelu++; + } + } + pcbframe->m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; + + qsort(BaseListeModules, NbModules, sizeof(MODULE**), + (int(*)(const void *, const void * ))Tri_RatsModules); + + + /* Recherche du "meilleur" module */ + Module = NULL; + for(pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++) + { + if( ! ((*pt_Dmod)->m_ModuleStatus & MODULE_to_PLACE) ) continue; + AltModule = *pt_Dmod; + if( (*pt_Dmod)->flag == 0 ) continue; + Module = *pt_Dmod; break; + } + + MyFree(BaseListeModules); + if ( Module ) return(Module); + else return(AltModule); +} + + +/*******************************************************/ +bool WinEDA_PcbFrame::SetBoardBoundaryBoxFromEdgesOnly(void) +/*******************************************************/ + +/* Determine le rectangle d'encadrement du pcb, selon les contours + (couche EDGE) uniquement + Sortie: + m_Pcb->m_BoundaryBox mis a jour + Retourne FALSE si pas de contour +*/ +{ +int rayon, cx, cy, d; +int xmax, ymax; +EDA_BaseStruct * PtStruct; +DRAWSEGMENT* ptr; +bool succes = FALSE; + + if (m_Pcb == NULL) return FALSE; + + m_Pcb->m_BoundaryBox.m_Pos.x = m_Pcb->m_BoundaryBox.m_Pos.y = 0x7FFFFFFFl ; + xmax = ymax = -0x7FFFFFFFl ; + + /* Analyse des Contours PCB */ + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; + succes = TRUE; + ptr = (DRAWSEGMENT*) PtStruct; + d = (ptr->m_Width /2) + 1; + if(ptr->m_Shape == S_CIRCLE) + { + cx = ptr->m_Start.x; cy = ptr->m_Start.y; + rayon = (int)hypot((double)(ptr->m_End.x-cx),(double)(ptr->m_End.y-cy) ); + rayon += d; + m_Pcb->m_BoundaryBox.m_Pos.x = min(m_Pcb->m_BoundaryBox.m_Pos.x,cx-rayon); + m_Pcb->m_BoundaryBox.m_Pos.y = min(m_Pcb->m_BoundaryBox.m_Pos.y,cy-rayon); + xmax = max(xmax,cx+rayon); + ymax = max(ymax,cy+rayon); + } + else + { + cx = min(ptr->m_Start.x, ptr->m_End.x ); + cy = min(ptr->m_Start.y, ptr->m_End.y); + m_Pcb->m_BoundaryBox.m_Pos.x = min(m_Pcb->m_BoundaryBox.m_Pos.x,cx - d); + m_Pcb->m_BoundaryBox.m_Pos.y = min(m_Pcb->m_BoundaryBox.m_Pos.y,cy - d); + cx = max(ptr->m_Start.x, ptr->m_End.x ); + cy = max(ptr->m_Start.y, ptr->m_End.y); + xmax = max(xmax,cx + d); + ymax = max(ymax,cy + d); + } + } + + m_Pcb->m_BoundaryBox.SetWidth(xmax - m_Pcb->m_BoundaryBox.m_Pos.x); + m_Pcb->m_BoundaryBox.SetHeight(ymax - m_Pcb->m_BoundaryBox.m_Pos.y); + return(succes); +} + + diff --git a/pcbnew/autorout.cpp b/pcbnew/autorout.cpp new file mode 100644 index 0000000000..4eb0808e10 --- /dev/null +++ b/pcbnew/autorout.cpp @@ -0,0 +1,212 @@ + /***************************************/ + /* PCBNEW: Autorouting command control */ + /***************************************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "cell.h" + +#include "protos.h" + +/* routines internes */ + +/* Variables locales */ + +/********************************************************/ +void WinEDA_PcbFrame::Autoroute(wxDC * DC, int mode) +/********************************************************/ +/* init board, route traces*/ +{ +int ii, start, stop; +CHEVELU* ptmp; +MODULE * Module = NULL; +D_PAD * Pad = NULL; +int autoroute_net_code = -1; +wxString msg; + + + Route_Layer_TOP = GetScreen()->m_Route_Layer_TOP; + Route_Layer_BOTTOM = GetScreen()->m_Route_Layer_BOTTOM; + + switch ( mode ) + { + case ROUTE_NET: + if ( GetScreen()->m_CurrentItem ) + { + switch ( GetScreen()->m_CurrentItem->m_StructType ) + { + case TYPEPAD: + Pad = (D_PAD*) GetScreen()->m_CurrentItem; + autoroute_net_code = Pad->m_NetCode; + break; + + default: + break; + } + } + if( autoroute_net_code <= 0) + { + DisplayError(this, _("Net not selected")); return; + } + break; + + case ROUTE_MODULE: + Module = (MODULE*) GetScreen()->m_CurrentItem; + if( (Module == NULL) || (Module->m_StructType != TYPEMODULE) ) + { + DisplayError(this, _("Module not selected") ); return; + } + break; + + case ROUTE_PAD: + Pad = (D_PAD*) GetScreen()->m_CurrentItem; + if( (Pad == NULL) || (Pad->m_StructType != TYPEPAD) ) + { + DisplayError(this, _("Pad not selected") ); return; + } + break; + + } + if( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK ) == 0 ) + Compile_Ratsnest(DC, TRUE); + + /* Placement du flag CH_ROUTE_REQ sur les chevelus demandes */ + ptmp = (CHEVELU*) m_Pcb->m_Ratsnest; + for ( ii = m_Pcb->GetNumRatsnests(); ii > 0; ii--, ptmp ++ ) + { + ptmp->status &= ~CH_ROUTE_REQ; + switch ( mode ) + { + case ROUTE_ALL: + ptmp->status |= CH_ROUTE_REQ; break; + + case ROUTE_NET: + if( autoroute_net_code == ptmp->m_NetCode) + ptmp->status |= CH_ROUTE_REQ; + break; + + case ROUTE_MODULE: + { + D_PAD * pt_pad = (D_PAD *) Module->m_Pads; + for( ; pt_pad != NULL; pt_pad = (D_PAD *)pt_pad->Pnext) + { + if( ptmp->pad_start == pt_pad ) + ptmp->status |= CH_ROUTE_REQ; + if( ptmp->pad_end == pt_pad ) + ptmp->status |= CH_ROUTE_REQ; + } + break; + } + case ROUTE_PAD: + if( (ptmp->pad_start == Pad) || (ptmp->pad_end == Pad)) + ptmp->status |= CH_ROUTE_REQ; + break; + } + } + ptmp = (CHEVELU*)m_Pcb->m_Ratsnest; + + start = time( NULL ); + + /* Calcul du pas de routage fixe a 5 mils et plus */ + g_GridRoutingSize = GetScreen()->GetGrid().x; + if (g_GridRoutingSize < 50 ) g_GridRoutingSize = 50 ; + E_scale = g_GridRoutingSize / 50 ; if (E_scale < 1 ) E_scale = 1 ; + + /* calcule de Ncols et Nrow, taille de la matrice de routage */ + ComputeMatriceSize(this, g_GridRoutingSize); + + MsgPanel->EraseMsgBox(); + + /* Creation du mapping du board */ + Nb_Sides = ONE_SIDE; + if(Route_Layer_TOP != Route_Layer_BOTTOM ) Nb_Sides = TWO_SIDES; + + if ( Board.InitBoard() < 0 ) + { + DisplayError(this, _("No memory for autorouting") ); + Board.UnInitBoard(); /* Libere la memoire BitMap */ + return; + } + + Affiche_Message( _("Place Cells") ); + PlaceCells(m_Pcb, -1, FORCE_PADS); + + /* Construction de la liste des pistes a router */ + Build_Work(m_Pcb, ptmp); + + // DisplayBoard(DrawPanel, DC); + + if( Nb_Sides == TWO_SIDES ) + Solve(DC, TWO_SIDES); /* double face */ + else Solve(DC, ONE_SIDE); /* simple face */ + + /* Liberation de la memoire */ + FreeQueue(); /* Libere la memoire de routage */ + InitWork(); /* Libere la memoire de la liste des connexions a router */ + Board.UnInitBoard(); /* Libere la memoire BitMap */ + stop = time( NULL ) - start; + msg.Printf( wxT("time = %d second%s"), stop, (stop == 1) ? wxT("") : wxT("s") ); + Affiche_Message(msg); +} + +/************************************************/ +void WinEDA_PcbFrame::Reset_Noroutable(wxDC * DC) +/*************************************************/ + /* Remet a 0 le flag CH_NOROUTABLE qui est positionne a 1 par Solve() + lorsque un chevelu n'a pas ete route. + Si ce flag est a 1 il n'est pas reroute +*/ +{ +int ii; +CHEVELU* pt_rats; + + if( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK )== 0 ) + Compile_Ratsnest(DC, TRUE); + + pt_rats = (CHEVELU*)m_Pcb->m_Ratsnest; + if( pt_rats == NULL ) return; + + for ( ii = m_Pcb->GetNumRatsnests(); ii > 0 ; ii-- , pt_rats++) + { + pt_rats->status &= ~CH_UNROUTABLE ; + } +} + +/*****************************************************/ +void DisplayBoard(WinEDA_DrawPanel * panel, wxDC * DC) +/****************************************************/ +/* Fonction de DEBUG : affiche le remplissage des cellules TOP et BOTTOM */ +{ +int row, col, i , j; +int dcell0, dcell1 = 0, color; +int maxi; + + maxi = (/*ActiveScreen->Lim_XD - 20*/ 500) / Ncols; + maxi = (maxi * 3 ) / 4; + if (!maxi) maxi = 1; + + for ( col = 0; col < Ncols; col++) + { + for(row = 0; row < Nrows; row++) + { + color = 0; + dcell0 = GetCell(row,col,BOTTOM); if (dcell0 & HOLE) color = GREEN; + if(Nb_Sides) dcell1 = GetCell(row,col,TOP); + if ( dcell1 & HOLE ) color |= RED; + dcell0 |= dcell1; + if( !color && (dcell0 & VIA_IMPOSSIBLE)) color = BLUE ; + if(color) + { + for (i = 0; i < maxi; i++) + for (j = 0; j < maxi; j++) + GRSPutPixel(&panel->m_ClipBox, DC, + (col*maxi)+i + 10,(row*maxi) + 60 + j, color); + } + } + } +} + + diff --git a/pcbnew/autorout.h b/pcbnew/autorout.h new file mode 100644 index 0000000000..62ac901edf --- /dev/null +++ b/pcbnew/autorout.h @@ -0,0 +1,163 @@ + /****************************************************/ + /* AUTOROUT.H */ + /* d‚clarations communes relative au routage, DRC */ + /* et placement automatique des composants */ + /****************************************************/ + +#ifndef AUTOROUT_H +#define AUTOROUT_H + + +#define TOP 0 +#define BOTTOM 1 +#define EMPTY 0 +#define ILLEGAL -1 + + + /*****************************************************/ + /* Structures de representation des pads et chevelus */ + /* pour etablissement du chevelu general complet */ + /*****************************************************/ + + + + /***********************************************/ + /* description d'un segment de chevelu general */ + /***********************************************/ + /****************************/ + /* bits d'etat du chevelu : */ + /****************************/ +#define CH_VISIBLE 1 /* affichage permanent demande */ +#define CH_UNROUTABLE 2 /* non route par l'autorouteur */ +#define CH_ROUTE_REQ 4 /* doit etre route par l'autorouteur */ +#define CH_ACTIF 8 /* chevelu non encore routé */ +#define LOCAL_CHEVELU 0x8000 /* indique un chevelu reliant 2 pins d'un meme + module pour le calcul des chevelus relatifs a 1 seul module */ + +class CHEVELU +{ +public: + int m_NetCode; // numero de code du net ( = 0.. n , avec 0 si non connecte) + int status; // etat: voir defines précédents (CH_ ...) + D_PAD * pad_start; // pointeur sur le pad de depart + D_PAD * pad_end ; // pointeur sur le pad de fin + int dist; // longeur du chevelu +}; + + /****************************************************************/ + /* description d'un point de piste pour le suivi des connexions */ + /****************************************************************/ +#define START_SUR_PAD 0x10 +#define END_SUR_PAD 0x20 +#define START_SUR_TRACK 0x40 +#define END_SUR_TRACK 0x80 + +#define START_EQU_VIA 0x10 +#define END_EQU_VIA 0x20 + + +/* Status bit (OR'ed bits) for class BOARD member .m_Status_Pcb */ +enum StatusPcbFlags +{ + LISTE_PAD_OK = 1, /* Pad list is Ok */ + LISTE_CHEVELU_OK = 2, /* General Rastnest is Ok */ + CHEVELU_LOCAL_OK = 4, /* current MODULE rastnest is Ok */ + CONNEXION_OK = 8, /* Bit indicant que la liste des connexions existe */ + NET_CODES_OK = 0x10, /* Bit indicant que les netcodes sont OK ( pas de modif + de noms de net */ + DO_NOT_SHOW_GENERAL_RASTNEST = 0x20 /* Do not display the general rastnest (used in module moves) */ +}; + +#define OK_DRC 0 +#define BAD_DRC 1 + + +/* Commandes d'autoplacement / autorouage possibles */ +enum CommandOpt +{ + PLACE_ALL, + PLACE_OUT_OF_BOARD, + PLACE_INCREMENTAL, + PLACE_1_MODULE, + + ROUTE_ALL, + ROUTE_NET, + ROUTE_MODULE, + ROUTE_PAD + }; + +/* parametre Pas de routage pour routage automatique et generation des zones */ + +#if defined MAIN +int g_GridRoutingSize = 250; +#else +extern int g_GridRoutingSize; +#endif + +/* Variables et structures d'autoroutage */ + +eda_global int E_scale; /* facteur d'echelle des tables de distance */ + +#define ONE_SIDE 0 +#define TWO_SIDES 1 +eda_global int Nb_Sides; /* Nombre de couches pour autoroutage (0 ou 1) */ + +/* Bits Flags de gestion de remplissage du BOARD */ +#define FORCE_PADS 1 /* pour forcage placement pads quel que soit le netcode */ + +/* board dimensions */ +extern int Nrows, Ncols; +#if defined MAIN +int Nrows = ILLEGAL; +int Ncols = ILLEGAL; +#endif + +eda_global int Ntotal; + +/* search statistics */ +eda_global int OpenNodes; /* total number of nodes opened */ +eda_global int ClosNodes; /* total number of nodes closed */ +eda_global int MoveNodes; /* total number of nodes moved */ +eda_global int MaxNodes; /* maximum number of nodes opened at one time */ + +/* Structures utiles a la generation du board en Bit Map */ + + +typedef char BoardCell; +typedef int DistCell; + +class BOARDHEAD /* header of blocks of BoardCell */ +{ +public: + BoardCell * m_BoardSide[2]; /* ptr to block of memory: 2-sided board */ + DistCell * m_DistSide[2]; /* ptr to block of memory: path distance to cells */ + char * m_DirSide[2]; /* header of blocks of chars:pointers back to source */ + bool m_InitBoardDone; + int m_Layers; + int m_Nrows, m_Ncols; + int m_MemSize; + +public: + BOARDHEAD(void); + ~BOARDHEAD(void); + int InitBoard(void); + void UnInitBoard(void); + +}; + +eda_global BOARDHEAD Board ; /* 2-sided board */ + + +/* Constantes utilisees pour le trace des cellules sur le BOARD */ +#define WRITE_CELL 0 +#define WRITE_OR_CELL 1 +#define WRITE_XOR_CELL 2 +#define WRITE_AND_CELL 3 +#define WRITE_ADD_CELL 4 + + +#include "ar_protos.h" + + +#endif /* AUTOROUT_H */ + diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp new file mode 100644 index 0000000000..70193088e7 --- /dev/null +++ b/pcbnew/basepcbframe.cpp @@ -0,0 +1,124 @@ + /************************************************************************/ + /* basepcbframe.cpp - fonctions des classes du type WinEDA_BasePcbFrame */ + /************************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" +#include "common.h" + +#include "pcbnew.h" + +#include "bitmaps.h" +#include "protos.h" +#include "id.h" + + + + /*******************************/ + /* class WinEDA_BasePcbFrame */ + /*******************************/ + + /****************/ + /* Constructeur */ + /****************/ + +WinEDA_BasePcbFrame::WinEDA_BasePcbFrame(wxWindow * father, WinEDA_App *parent, + int idtype, + const wxString & title, const wxPoint& pos, const wxSize& size) : + WinEDA_DrawFrame(father, idtype, parent, title, pos, size) +{ + m_InternalUnits = 10000; // Internal unit = 1/10000 inch + m_CurrentScreen = NULL; + m_Pcb = NULL; + + m_DisplayPadFill = TRUE; // How to draw pads + m_DisplayPadNum = TRUE; // show pads number + + m_DisplayModEdge = FILLED; // How to show module drawings + m_DisplayModText = FILLED; // How to show module texts + m_DisplayPcbTrackFill = TRUE; /* FALSE = sketch , TRUE = filled */ + m_Draw3DFrame = NULL; // Display Window in 3D mode (OpenGL) +} + +WinEDA_BasePcbFrame::~WinEDA_BasePcbFrame(void) +{ +} + + +/**************************************/ +int WinEDA_BasePcbFrame::BestZoom(void) +/**************************************/ +{ +int dx, dy, ii,jj ; +int bestzoom; +wxSize size; + + if ( m_Pcb == NULL ) return 32; + + m_Pcb->ComputeBoundaryBox(); + + /* calcul du zoom montrant tout le dessim */ + dx = m_Pcb->m_BoundaryBox.GetWidth(); + dy = m_Pcb->m_BoundaryBox.GetHeight(); + + size = DrawPanel->GetClientSize(); + ii = (dx + (size.x/2)) / size.x; + jj = (dy + (size.y/2)) / size.y; + bestzoom = MAX(ii, jj) + 1; + + m_CurrentScreen->m_Curseur = m_Pcb->m_BoundaryBox.Centre(); + + return(bestzoom); +} + + +void WinEDA_BasePcbFrame::ReCreateMenuBar(void) // fonction virtuelle +{ +} + +#include "3d_viewer.h" + +/***********************************************************/ +void WinEDA_BasePcbFrame::Show3D_Frame(wxCommandEvent& event) +/***********************************************************/ +/* Ouvre la frame d'affichage 3D +*/ +{ +#ifndef GERBVIEW + // Create the main frame window + if ( m_Draw3DFrame ) + { + DisplayInfo(this, _("3D Frame already opened") ); + return; + } + m_Draw3DFrame = new WinEDA3D_DrawFrame(this, m_Parent, _("3D Viewer") ); + + // Show the frame + m_Draw3DFrame->Show(TRUE); +#endif +} + + +/* Virtual functions: Do nothing for WinEDA_BasePcbFrame window */ + +/***********************************************************************************/ +void WinEDA_BasePcbFrame::SaveCopyInUndoList(EDA_BaseStruct * ItemToCopy, int flag) +/***********************************************************************************/ +{ +} + +/********************************************************/ +void WinEDA_BasePcbFrame::GetComponentFromUndoList(void) +/********************************************************/ +{ +} + +/********************************************************/ +void WinEDA_BasePcbFrame::GetComponentFromRedoList(void) +/********************************************************/ +{ +} + diff --git a/pcbnew/bitmaps/Add_Mires.xpm b/pcbnew/bitmaps/Add_Mires.xpm new file mode 100644 index 0000000000..982952ed2b --- /dev/null +++ b/pcbnew/bitmaps/Add_Mires.xpm @@ -0,0 +1,83 @@ +/* XPM */ +static const char * add_mires_xpm[] = { +"16 16 64 1", +" c None", +"! c black", +"# c #1F1F1F", +"$ c #414141", +"% c #C4BD94", +"& c #F2EFC1", +"' c #A9A9A9", +"( c #939288", +") c #6C6642", +"* c #4B4B4B", +"+ c #E8DDA6", +", c #FFF8B5", +"- c #FFF8B3", +". c #949494", +"0 c #929292", +"1 c #8F8F8F", +"2 c #635E45", +"3 c #BDB384", +"4 c #FFF39E", +"5 c #FFF49D", +"6 c #FFF49C", +"7 c #7B7B7B", +"8 c #797979", +"9 c #767676", +": c #6C6C6C", +"; c #3F3606", +"< c #E8D97C", +"= c #FFEF86", +"> c #FFEF85", +"? c #FFEF83", +"@ c #626262", +"A c #5F5F5F", +"B c #5D5D5D", +"C c #545454", +"D c #201C04", +"E c #282827", +"F c #505050", +"G c #4E4E4E", +"H c #494949", +"I c #464646", +"J c #444444", +"K c #020200", +"L c #201B03", +"M c #141414", +"N c #292929", +"O c #313131", +"P c #2E2E2E", +"Q c #FFDF3C", +"R c #FFDA26", +"S c #FFD615", +"T c #D9B611", +"U c #3F3504", +"V c #FFD513", +"W c #FFD410", +"X c #FFD20C", +"Y c #7F6907", +"Z c #2D2502", +"[ c #FFD009", +"] c #FFCF07", +"^ c #AE8F08", +"_ c #3F3403", +"` c #201A00", +"a c #D9B005", +"b c #7F6806", +" # ", +" # ", +" !!#!! ", +" $%&'()! ", +" *+,-.012! ", +" !3456789:;! ", +" !<=>?@ABCD! ", +"##!EFG*HIJ#K!## ", +" !LMNOPQRST! ", +" !U!!!!VWXY! ", +" !Z!!![]^! ", +" !_`Kab! ", +" !!#!! ", +" # ", +" # ", +" "}; diff --git a/pcbnew/bitmaps/Add_Tracks.xpm b/pcbnew/bitmaps/Add_Tracks.xpm new file mode 100644 index 0000000000..f921fd2ad2 --- /dev/null +++ b/pcbnew/bitmaps/Add_Tracks.xpm @@ -0,0 +1,35 @@ +/* XPM */ +static char * add_tracks_xpm[] = { +"16 16 16 1", +" c None", +". c #007D00", +"+ c #006100", +"@ c #004400", +"# c #007800", +"$ c #007B00", +"% c #004000", +"& c #007C00", +"* c #006500", +"= c #007A00", +"- c #004600", +"; c #D72E2E", +"> c #A32222", +", c #C22929", +"' c #D22D2D", +") c #6D1717", +" ", +"........ ", +"........+ ", +" @.# ", +" $.% ", +" &.* ", +" .= ", +" $.- ", +" ;;; ........", +" ;;;;; .......", +";;> >;, ", +";; ;' ", +";;> ;;, ", +" ;;;;;) ", +" ,',) ", +" "}; diff --git a/pcbnew/bitmaps/Add_Zone.xpm b/pcbnew/bitmaps/Add_Zone.xpm new file mode 100644 index 0000000000..b2945f4a77 --- /dev/null +++ b/pcbnew/bitmaps/Add_Zone.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static char * add_zone_xpm[] = { +"16 16 3 1", +" c None", +". c #007D00", +"+ c #007E00", +"................", +".... ........", +"... .......", +".. ++ .....", +". .... ...", +". +. ..... ..", +". +. ...... ..", +". .... .. .", +".. ++ .. ", +"... .. ... ", +".... .... ...", +"............ ..", +"............. .", +".............. .", +"............... ", +"............... "}; diff --git a/pcbnew/bitmaps/Break_Line.xpm b/pcbnew/bitmaps/Break_Line.xpm new file mode 100644 index 0000000000..e19e907d46 --- /dev/null +++ b/pcbnew/bitmaps/Break_Line.xpm @@ -0,0 +1,53 @@ +/* XPM */ +static char * Break_Line_xpm[] = { +"16 16 34 1", +" c None", +". c #D72E2E", +"+ c #D82E2E", +"@ c #D43232", +"# c #9B9B9B", +"$ c #D82F2F", +"% c #CF3A3A", +"& c #C45050", +"* c #D62D2D", +"= c #A98080", +"- c #B66868", +"; c #9C9C9C", +"> c #007D00", +", c #017D01", +"' c #077E07", +") c #568D56", +"! c #0E7F0E", +"~ c #158115", +"{ c #418941", +"] c #8F988F", +"^ c #4C8B4C", +"/ c #0A7F0A", +"( c #1A821A", +"_ c #268426", +": c #819681", +"< c #3A883A", +"[ c #057E05", +"} c #118011", +"| c #6C916C", +"1 c #699169", +"2 c #0D7F0D", +"3 c #8B978B", +"4 c #969A96", +"5 c #809580", +" ", +" . ", +" +@ .# $ ", +" %& .# *= ", +" - #$=; ", +" ", +" > , ", +" >>')!>~ ", +" >,{] ^/,( ", +" >>_:# <,'( ", +"[}|# 1_23", +" 4 5 ", +" ", +" ", +" ", +" "}; diff --git a/pcbnew/bitmaps/Delete_Line.xpm b/pcbnew/bitmaps/Delete_Line.xpm new file mode 100644 index 0000000000..4a3330ce68 --- /dev/null +++ b/pcbnew/bitmaps/Delete_Line.xpm @@ -0,0 +1,150 @@ +/* XPM */ +static char * Delete_Line_xpm[] = { +"16 16 131 2", +" c None", +". c #007D00", +"+ c #4D8B4D", +"@ c #9B9B9B", +"# c #060606", +"$ c #202020", +"% c #242424", +"& c #1E1E1E", +"* c #151515", +"= c #000000", +"- c #48473F", +"; c #97968B", +"> c #9C9C98", +", c #94948F", +"' c #787872", +") c #292822", +"! c #080808", +"~ c #605F51", +"{ c #5F5E51", +"] c #7E7D6B", +"^ c #9A988A", +"/ c #8B8A85", +"( c #908F87", +"_ c #A5A494", +": c #787766", +"< c #504F44", +"[ c #515045", +"} c #161616", +"| c #706F65", +"1 c #CDCBB3", +"2 c #CFCDB8", +"3 c #989683", +"4 c #55534C", +"5 c #2F2F2D", +"6 c #383830", +"7 c #737161", +"8 c #9B9984", +"9 c #ABA991", +"0 c #AAA990", +"a c #515044", +"b c #DBD8C5", +"c c #E6E3D4", +"d c #E8E6D7", +"e c #CFCEBC", +"f c #A3A095", +"g c #858379", +"h c #7E7D6C", +"i c #868572", +"j c #ABA992", +"k c #BDBBA2", +"l c #B4B298", +"m c #8D8B77", +"n c #B7B5A2", +"o c #F0EDDB", +"p c #F4F2E4", +"q c #EFEDE1", +"r c #ECEADE", +"s c #E4E2D3", +"t c #DAD8C4", +"u c #CBC9B5", +"v c #CDCBB6", +"w c #B0AE99", +"x c #8C8A77", +"y c #676657", +"z c #6D6C5C", +"A c #B0AD9A", +"B c #CBC8BB", +"C c #ECE9D8", +"D c #EEECDC", +"E c #EBE9D9", +"F c #E1E0D6", +"G c #BBBAAA", +"H c #A8A796", +"I c #817F6F", +"J c #525145", +"K c #3F3F35", +"L c #383730", +"M c #525149", +"N c #747269", +"O c #A4A293", +"P c #ABA899", +"Q c #A5A496", +"R c #9E9D92", +"S c #727164", +"T c #565649", +"U c #3F3E36", +"V c #2E2D26", +"W c #23221D", +"X c #24241E", +"Y c #696961", +"Z c #4B4A41", +"` c #4E4D48", +" . c #4C4B45", +".. c #4C4C46", +"+. c #3E3D34", +"@. c #313029", +"#. c #2A2926", +"$. c #262620", +"%. c #21201B", +"&. c #2A2A23", +"*. c #A1A095", +"=. c #808076", +"-. c #52524A", +";. c #64645B", +">. c #505045", +",. c #272720", +"'. c #393931", +"). c #24241D", +"!. c #39392F", +"~. c #24241F", +"{. c #2B2B24", +"]. c #A7A79C", +"^. c #C6C5BE", +"/. c #7D7C72", +"(. c #BAB9AE", +"_. c #7D7C6E", +":. c #7D7D70", +"<. c #404035", +"[. c #6F6F64", +"}. c #46463A", +"|. c #ABABA1", +"1. c #D7D7D0", +"2. c #8B8B7F", +"3. c #D7D7CF", +"4. c #989888", +"5. c #59594F", +"6. c #98988B", +"7. c #4A4A3E", +"8. c #77776A", +"9. c #4F4F41", +"0. c #282821", +" ", +". . . . . . . . . . . . . . . ", +". + + + + + + + + + + + + + + @ ", +" @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ ", +" # $ % & * = ", +" = = - ; > , ' ) = = ", +" ! ~ { ] ^ / ( _ : < [ = ", +" } | 1 2 3 4 5 6 7 8 9 0 a = ", +" * b c d e f g h i j k l m = ", +" = n o p q r s t u v w x y = ", +" = z A B C D E F G H I J K = ", +" L M N O P Q R S T U V W ", +" X Y Z ` ...+.@.X #.$.%. ", +" &.*.=.-.;.>.,.'.).-.!.~. ", +" {.].^./.(._.Z :.<.[.}.,. ", +" {.|.1.2.3.4.5.6.7.8.9.0. "}; diff --git a/pcbnew/bitmaps/Delete_Module.xpm b/pcbnew/bitmaps/Delete_Module.xpm new file mode 100644 index 0000000000..71919755ac --- /dev/null +++ b/pcbnew/bitmaps/Delete_Module.xpm @@ -0,0 +1,148 @@ +/* XPM */ +static char * Delete_Module_xpm[] = { +"16 16 129 2", +" c None", +". c #000000", +"+ c #C0C0C0", +"@ c #B8B8C0", +"# c #D72E2E", +"$ c #FFFFFF", +"% c #F5F4FF", +"& c #EBEAFF", +"* c #F5F5FF", +"= c #EBEBFF", +"- c #E1E1FF", +"; c #F6F5FF", +"> c #ECEBFF", +", c #E2E1FF", +"' c #D8D7FF", +") c #ECECFF", +"! c #E2E2FF", +"~ c #CECDFF", +"{ c #D5D4EF", +"] c #9B9AB6", +"^ c #0E0E0E", +"/ c #424242", +"( c #494949", +"_ c #3E3D3D", +": c #2B2B2B", +"< c #010101", +"[ c #848271", +"} c #EFECD7", +"| c #F0EFE7", +"1 c #ECEBE2", +"2 c #C5C4B8", +"3 c #525145", +"4 c #A52424", +"5 c #0F0F0F", +"6 c #C1BFA4", +"7 c #C0BEA4", +"8 c #7A7967", +"9 c #484740", +"0 c #262624", +"a c #36342D", +"b c #858371", +"c c #9E9C86", +"d c #A19F88", +"e c #A3A18A", +"f c #2B2A2A", +"g c #D1CFBA", +"h c #DBD9C3", +"i c #E1DFCE", +"j c #B8B6A1", +"k c #64625B", +"l c #383735", +"m c #3C3B32", +"n c #605F52", +"o c #989681", +"p c #B5B399", +"q c #B1B096", +"r c #A2A089", +"s c #E6E2D1", +"t c #F2EFE7", +"u c #F0EFE2", +"v c #E8E7D8", +"w c #E3E0D0", +"x c #D3D0BC", +"y c #C1BFA5", +"z c #ADAB92", +"A c #BEBCA2", +"B c #C4C2AA", +"C c #B6B49A", +"D c #787665", +"E c #888774", +"F c #EFEBD0", +"G c #F9F6E7", +"H c #F7F3EB", +"I c #F6F5EC", +"J c #F6F5EA", +"K c #F3F1E4", +"L c #EAE8D7", +"M c #DCDBC9", +"N c #9B9987", +"O c #626153", +"P c #575649", +"Q c #515045", +"R c #727064", +"S c #9D9B8F", +"T c #E2DFC6", +"U c #E7E3CD", +"V c #E0DEC9", +"W c #CFCFC9", +"X c #8C8B7E", +"Y c #757463", +"Z c #676657", +"` c #424137", +" . c #282721", +".. c #1E1E1A", +"+. c #33332F", +"@. c #4A4843", +"#. c #676661", +"$. c #6F6E65", +"%. c #6A6A63", +"&. c #6D6B5C", +"*. c #57564A", +"=. c #383830", +"-. c #161514", +";. c #191915", +">. c #1E1D18", +",. c #292922", +"'. c #9E9E93", +"). c #4C4C3F", +"!. c #35352F", +"~. c #292925", +"{. c #2E2E29", +"]. c #0E0E0C", +"^. c #0A0A08", +"/. c #0F0F0C", +"(. c #3D3D37", +"_. c #33332A", +":. c #23231E", +"<. c #2A2A23", +"[. c #A3A297", +"}. c #B5B4AC", +"|. c #706F66", +"1. c #9F9F90", +"2. c #737262", +"3. c #3F3F34", +"4. c #68685A", +"5. c #38382E", +"6. c #68685E", +"7. c #3E3E33", +"8. c #25251F", +" . . . . ", +" . + . . @ . ", +" # . $ $ % & . # ", +" # . $ * = - . # ", +" . ; > , ' . ", +" # . ) ! ' ~ . # ", +" # . { ] ^ / ( _ : . ", +" < < < [ } | 1 2 3 . . ", +" 4 5 6 7 8 9 0 a b c d e . ", +" f g h i j k l m n o p q r . ", +" . s t u v w x y z A B C D . ", +" . E F G H I J K L M N O P . ", +" . Q R S T U V W X Y Z ` .. ", +" ..+.@.#.$.%.&.*.=.-.;.>. ", +" ,.'.).!.~.{.].^./.(._.:. ", +" <.[.}.|.1.2.3.4.5.6.7.8. "}; diff --git a/pcbnew/bitmaps/Delete_Net.xpm b/pcbnew/bitmaps/Delete_Net.xpm new file mode 100644 index 0000000000..f29627eac3 --- /dev/null +++ b/pcbnew/bitmaps/Delete_Net.xpm @@ -0,0 +1,147 @@ +/* XPM */ +static char * Delete_Net_xpm[] = { +"16 16 128 2", +" c None", +". c #005900", +"+ c #007D00", +"@ c #003500", +"# c #002C00", +"$ c #004000", +"% c #005200", +"& c #595959", +"* c #E4CBB6", +"= c #594534", +"- c #006500", +"; c #004E00", +"> c #9D8570", +", c #FFBC80", +"' c #9D622E", +") c #151608", +"! c #643A15", +"~ c #141C00", +"{ c #006700", +"] c #0D0D0D", +"^ c #414141", +"/ c #494949", +"( c #3D3D3D", +"_ c #2B2B2B", +": c #000000", +"< c #838170", +"[ c #EEEBD6", +"} c #F0EFE7", +"| c #ECEBE2", +"1 c #C5C4B8", +"2 c #525145", +"3 c #0F0F0F", +"4 c #C0BEA3", +"5 c #BFBDA3", +"6 c #797866", +"7 c #47463F", +"8 c #262624", +"9 c #35342D", +"0 c #858371", +"a c #9E9C86", +"b c #A19F88", +"c c #A3A18A", +"d c #006D00", +"e c #2A2A2A", +"f c #D1CFBA", +"g c #DAD8C2", +"h c #E0DECD", +"i c #B7B5A0", +"j c #63615A", +"k c #383735", +"l c #3B3B32", +"m c #605F52", +"n c #989681", +"o c #B5B399", +"p c #B1B096", +"q c #A2A089", +"r c #E6E2D1", +"s c #F2EFE7", +"t c #F0EFE2", +"u c #E8E7D8", +"v c #E3E0D0", +"w c #D3D0BC", +"x c #C1BFA5", +"y c #ADAB92", +"z c #BEBCA2", +"A c #C4C2AA", +"B c #B6B49A", +"C c #787665", +"D c #888774", +"E c #EFEBD0", +"F c #F9F6E7", +"G c #F7F3EB", +"H c #F6F5EC", +"I c #F6F5EA", +"J c #F3F1E4", +"K c #EAE8D7", +"L c #DCDBC9", +"M c #9B9987", +"N c #626153", +"O c #575649", +"P c #515045", +"Q c #727064", +"R c #9D9B8F", +"S c #E2DFC6", +"T c #E7E3CD", +"U c #E0DEC9", +"V c #CFCFC9", +"W c #8C8B7E", +"X c #757463", +"Y c #676657", +"Z c #424137", +"` c #282721", +" . c #1E1E1A", +".. c #33332F", +"+. c #4A4843", +"@. c #676661", +"#. c #6F6E65", +"$. c #6A6A63", +"%. c #6D6B5C", +"&. c #57564A", +"*. c #383830", +"=. c #161514", +"-. c #191915", +";. c #1E1D18", +">. c #292922", +",. c #9E9E93", +"'. c #4C4C3F", +"). c #35352F", +"!. c #292925", +"~. c #2E2E29", +"{. c #0E0E0C", +"]. c #0A0A08", +"^. c #0F0F0C", +"/. c #3D3D37", +"(. c #33332A", +"_. c #23231E", +":. c #2A2A23", +"<. c #A3A297", +"[. c #B5B4AC", +"}. c #706F66", +"|. c #9F9F90", +"1. c #737262", +"2. c #3F3F34", +"3. c #68685A", +"4. c #38382E", +"5. c #68685E", +"6. c #3E3E33", +"7. c #25251F", +" . + + ", +" @ # $ ", +"+ + + + + + + % & * = - + + + + ", +"+ + + + + + + ; > , ' ; + + + + ", +" ) ! ~ ", +" { + ", +" ] ^ / ( _ : ", +" : : < [ } | 1 2 : : ", +" 3 4 5 6 7 8 9 0 a b c : d ", +" e f g h i j k l m n o p q : ", +" : r s t u v w x y z A B C : ", +" : D E F G H I J K L M N O : ", +" : P Q R S T U V W X Y Z ` : ", +" ...+.@.#.$.%.&.*.=.-.;. ", +" >.,.'.).!.~.{.].^./.(._. ", +" :.<.[.}.|.1.2.3.4.5.6.7. "}; diff --git a/pcbnew/bitmaps/Delete_Node.xpm b/pcbnew/bitmaps/Delete_Node.xpm new file mode 100644 index 0000000000..517a655103 --- /dev/null +++ b/pcbnew/bitmaps/Delete_Node.xpm @@ -0,0 +1,151 @@ +/* XPM */ +static char * Delete_Node_xpm[] = { +"16 16 132 2", +" c None", +". c #007D00", +"+ c #4D8B4D", +"@ c #ABABAB", +"# c #001900", +"$ c #0F1C0F", +"% c #545454", +"& c #3C3C3C", +"* c #C9C8C8", +"= c #C9BBAE", +"- c #3C342C", +"; c #2E2E2E", +"> c #C9C3BE", +", c #FFE6D0", +"' c #FFD4AE", +") c #C9996E", +"! c #0D1A0D", +"~ c #C9B099", +"{ c #FFCDA1", +"] c #FFBB7F", +"^ c #C98549", +"/ c #091609", +"( c #448244", +"_ c #9B9B9B", +": c #555555", +"< c #3C2F23", +"[ c #C98E5A", +"} c #C9803F", +"| c #3C220B", +"1 c #4C4C4C", +"2 c #9C9C9C", +"3 c #0C0C0C", +"4 c #1A1A1A", +"5 c #020E02", +"6 c #000000", +"7 c #838170", +"8 c #DFDDC9", +"9 c #2E6C2B", +"0 c #7A7972", +"a c #4D4C41", +"b c #0F0F0F", +"c c #C0BEA3", +"d c #BFBDA3", +"e c #797866", +"f c #47463F", +"g c #0F4E0D", +"h c #6B6A5B", +"i c #9E9C86", +"j c #A19F88", +"k c #A3A18A", +"l c #2A2A2A", +"m c #D1CFBA", +"n c #DAD8C2", +"o c #E0DECD", +"p c #B7B5A0", +"q c #63615A", +"r c #11500F", +"s c #4D4D42", +"t c #989681", +"u c #B5B399", +"v c #B1B096", +"w c #A2A089", +"x c #E6E2D1", +"y c #F2EFE7", +"z c #F0EFE2", +"A c #E8E7D8", +"B c #E3E0D0", +"C c #3A7831", +"D c #8B8A76", +"E c #BEBCA2", +"F c #C4C2AA", +"G c #B6B49A", +"H c #787665", +"I c #888774", +"J c #EFEBD0", +"K c #F9F6E7", +"L c #F7F3EB", +"M c #F6F5EC", +"N c #498745", +"O c #BCBBAD", +"P c #DCDBC9", +"Q c #9B9987", +"R c #626153", +"S c #575649", +"T c #515045", +"U c #727064", +"V c #9D9B8F", +"W c #E2DFC6", +"X c #E7E3CD", +"Y c #E0DEC9", +"Z c #7E7E7A", +"` c #717066", +" . c #757463", +".. c #676657", +"+. c #424137", +"@. c #282721", +"#. c #1E1E1A", +"$. c #33332F", +"%. c #4A4843", +"&. c #676661", +"*. c #6F6E65", +"=. c #6A6A63", +"-. c #6D6B5C", +";. c #57564A", +">. c #383830", +",. c #161514", +"'. c #191915", +"). c #1E1D18", +"!. c #292922", +"~. c #9E9E93", +"{. c #4C4C3F", +"]. c #35352F", +"^. c #292925", +"/. c #2E2E29", +"(. c #0E0E0C", +"_. c #0A0A08", +":. c #0F0F0C", +"<. c #3D3D37", +"[. c #33332A", +"}. c #23231E", +"|. c #2A2A23", +"1. c #A3A297", +"2. c #B5B4AC", +"3. c #706F66", +"4. c #9F9F90", +"5. c #737262", +"6. c #3F3F34", +"7. c #68685A", +"8. c #38382E", +"9. c #68685E", +"0. c #3E3E33", +"a. c #25251F", +" . + @ ", +" # $ % ", +" & * = - ; ", +". . . . . # > , ' ) # . . . . ", +". + + + + ! ~ { ] ^ / ( + + + _ ", +" @ @ @ @ : < [ } | 1 2 @ @ @ @ ", +" 3 4 # 5 3 6 ", +" 6 6 7 8 . 9 0 a 6 6 ", +" b c d e f . g h i j k 6 ", +" l m n o p q . r s t u v w 6 ", +" 6 x y z A B . C D E F G H 6 ", +" 6 I J K L M . N O P Q R S 6 ", +" 6 T U V W X Y Z ` ...+.@.6 ", +" #.$.%.&.*.=.-.;.>.,.'.). ", +" !.~.{.].^./.(._.:.<.[.}. ", +" |.1.2.3.4.5.6.7.8.9.0.a. "}; diff --git a/pcbnew/bitmaps/Delete_Pad.xpm b/pcbnew/bitmaps/Delete_Pad.xpm new file mode 100644 index 0000000000..73b48ff6b8 --- /dev/null +++ b/pcbnew/bitmaps/Delete_Pad.xpm @@ -0,0 +1,139 @@ +/* XPM */ +static char * Delete_Pad_xpm[] = { +"16 16 120 2", +" c None", +". c #000000", +"+ c #000200", +"@ c #003B00", +"# c #006400", +"$ c #007700", +"% c #005F00", +"& c #007D00", +"* c #007600", +"= c #006100", +"- c #006E00", +"; c #0D0D0D", +"> c #414141", +", c #494949", +"' c #3D3D3D", +") c #2B2B2B", +"! c #016201", +"~ c #838170", +"{ c #EEEBD6", +"] c #F0EFE7", +"^ c #ECEBE2", +"/ c #C5C4B8", +"( c #525145", +"_ c #014901", +": c #0F0F0F", +"< c #C0BEA3", +"[ c #BFBDA3", +"} c #797866", +"| c #47463F", +"1 c #262624", +"2 c #35342D", +"3 c #858371", +"4 c #9E9C86", +"5 c #A19F88", +"6 c #A3A18A", +"7 c #2A2A2A", +"8 c #D1CFBA", +"9 c #DAD8C2", +"0 c #E0DECD", +"a c #B7B5A0", +"b c #63615A", +"c c #383735", +"d c #3B3B32", +"e c #605F52", +"f c #989681", +"g c #B5B399", +"h c #B1B096", +"i c #A2A089", +"j c #E6E2D1", +"k c #F2EFE7", +"l c #F0EFE2", +"m c #E8E7D8", +"n c #E3E0D0", +"o c #D3D0BC", +"p c #C1BFA5", +"q c #ADAB92", +"r c #BEBCA2", +"s c #C4C2AA", +"t c #B6B49A", +"u c #787665", +"v c #888774", +"w c #EFEBD0", +"x c #F9F6E7", +"y c #F7F3EB", +"z c #F6F5EC", +"A c #F6F5EA", +"B c #F3F1E4", +"C c #EAE8D7", +"D c #DCDBC9", +"E c #9B9987", +"F c #626153", +"G c #575649", +"H c #515045", +"I c #727064", +"J c #9D9B8F", +"K c #E2DFC6", +"L c #E7E3CD", +"M c #E0DEC9", +"N c #CFCFC9", +"O c #8C8B7E", +"P c #757463", +"Q c #676657", +"R c #424137", +"S c #282721", +"T c #1E1E1A", +"U c #33332F", +"V c #4A4843", +"W c #676661", +"X c #6F6E65", +"Y c #6A6A63", +"Z c #6D6B5C", +"` c #57564A", +" . c #383830", +".. c #161514", +"+. c #191915", +"@. c #1E1D18", +"#. c #292922", +"$. c #9E9E93", +"%. c #4C4C3F", +"&. c #35352F", +"*. c #292925", +"=. c #2E2E29", +"-. c #0E0E0C", +";. c #0A0A08", +">. c #0F0F0C", +",. c #3D3D37", +"'. c #33332A", +"). c #23231E", +"!. c #2A2A23", +"~. c #A3A297", +"{. c #B5B4AC", +"]. c #706F66", +"^. c #9F9F90", +"/. c #737262", +"(. c #3F3F34", +"_. c #68685A", +":. c #38382E", +"<. c #68685E", +"[. c #3E3E33", +"}. c #25251F", +" . . . . . ", +" + @ # $ # @ + ", +" + % & & & & & % + ", +". @ & & * = * & & @ . ", +". # & * $ & # . ", +". $ & = - & $ . ", +". # & * ; > , ' ) . ", +". @ & ! . . ~ { ] ^ / ( . . ", +" + _ : < [ } | 1 2 3 4 5 6 . ", +" 7 8 9 0 a b c d e f g h i . ", +" . j k l m n o p q r s t u . ", +" . v w x y z A B C D E F G . ", +" . H I J K L M N O P Q R S . ", +" T U V W X Y Z ` ...+.@. ", +" #.$.%.&.*.=.-.;.>.,.'.). ", +" !.~.{.].^./.(._.:.<.[.}. "}; diff --git a/pcbnew/bitmaps/Delete_Track.xpm b/pcbnew/bitmaps/Delete_Track.xpm new file mode 100644 index 0000000000..798607deb7 --- /dev/null +++ b/pcbnew/bitmaps/Delete_Track.xpm @@ -0,0 +1,134 @@ +/* XPM */ +static char * Delete_Track_xpm[] = { +"16 16 115 2", +" c None", +". c #007D00", +"+ c #003600", +"@ c #007300", +"# c #005100", +"$ c #0D0D0D", +"% c #414141", +"& c #494949", +"* c #3D3D3D", +"= c #2B2B2B", +"- c #000000", +"; c #838170", +"> c #EEEBD6", +", c #F0EFE7", +"' c #ECEBE2", +") c #C5C4B8", +"! c #525145", +"~ c #015A01", +"{ c #0F0F0F", +"] c #C0BEA3", +"^ c #BFBDA3", +"/ c #797866", +"( c #47463F", +"_ c #262624", +": c #35342D", +"< c #858371", +"[ c #9E9C86", +"} c #A19F88", +"| c #A3A18A", +"1 c #006D00", +"2 c #2A2A2A", +"3 c #D1CFBA", +"4 c #DAD8C2", +"5 c #E0DECD", +"6 c #B7B5A0", +"7 c #63615A", +"8 c #383735", +"9 c #3B3B32", +"0 c #605F52", +"a c #989681", +"b c #B5B399", +"c c #B1B096", +"d c #A2A089", +"e c #E6E2D1", +"f c #F2EFE7", +"g c #F0EFE2", +"h c #E8E7D8", +"i c #E3E0D0", +"j c #D3D0BC", +"k c #C1BFA5", +"l c #ADAB92", +"m c #BEBCA2", +"n c #C4C2AA", +"o c #B6B49A", +"p c #787665", +"q c #888774", +"r c #EFEBD0", +"s c #F9F6E7", +"t c #F7F3EB", +"u c #F6F5EC", +"v c #F6F5EA", +"w c #F3F1E4", +"x c #EAE8D7", +"y c #DCDBC9", +"z c #9B9987", +"A c #626153", +"B c #575649", +"C c #515045", +"D c #727064", +"E c #9D9B8F", +"F c #E2DFC6", +"G c #E7E3CD", +"H c #E0DEC9", +"I c #CFCFC9", +"J c #8C8B7E", +"K c #757463", +"L c #676657", +"M c #424137", +"N c #282721", +"O c #1E1E1A", +"P c #33332F", +"Q c #4A4843", +"R c #676661", +"S c #6F6E65", +"T c #6A6A63", +"U c #6D6B5C", +"V c #57564A", +"W c #383830", +"X c #161514", +"Y c #191915", +"Z c #1E1D18", +"` c #292922", +" . c #9E9E93", +".. c #4C4C3F", +"+. c #35352F", +"@. c #292925", +"#. c #2E2E29", +"$. c #0E0E0C", +"%. c #0A0A08", +"&. c #0F0F0C", +"*. c #3D3D37", +"=. c #33332A", +"-. c #23231E", +";. c #2A2A23", +">. c #A3A297", +",. c #B5B4AC", +"'. c #706F66", +"). c #9F9F90", +"!. c #737262", +"~. c #3F3F34", +"{. c #68685A", +"]. c #38382E", +"^. c #68685E", +"/. c #3E3E33", +"(. c #25251F", +" ", +". . . . . . . . . . ", +". . . . . . . . . . . ", +" + . . ", +" @ . . ", +" # . . ", +" $ % & * = - ", +" - - ; > , ' ) ! - - ~ . ", +" { ] ^ / ( _ : < [ } | - 1 ", +" 2 3 4 5 6 7 8 9 0 a b c d - ", +" - e f g h i j k l m n o p - ", +" - q r s t u v w x y z A B - ", +" - C D E F G H I J K L M N - ", +" O P Q R S T U V W X Y Z ", +" ` ...+.@.#.$.%.&.*.=.-. ", +" ;.>.,.'.).!.~.{.].^./.(. "}; diff --git a/pcbnew/bitmaps/Drag_Module.xpm b/pcbnew/bitmaps/Drag_Module.xpm new file mode 100644 index 0000000000..f554fc679a --- /dev/null +++ b/pcbnew/bitmaps/Drag_Module.xpm @@ -0,0 +1,82 @@ +/* XPM */ +static char * Drag_Module_xpm[] = { +"16 16 63 1", +" c None", +". c #000000", +"+ c #C0C0C0", +"@ c #B8B8C0", +"# c #007D00", +"$ c #D72E2E", +"% c #FFFFFF", +"& c #F5F4FF", +"* c #EBEAFF", +"= c #F5F5FF", +"- c #EBEBFF", +"; c #E1E1FF", +"> c #2A0909", +", c #005E00", +"' c #F6F5FF", +") c #ECEBFF", +"! c #E2E1FF", +"~ c #9796B3", +"{ c #30303B", +"] c #DCDCEF", +"^ c #31313C", +"/ c #ECECFF", +"( c #E2E2FF", +"_ c #7B7B92", +": c #020202", +"< c #84849B", +"[ c #003D00", +"} c #E3E2FF", +"| c #7C7B92", +"1 c #BDBCE9", +"2 c #9E9DCD", +"3 c #005800", +"4 c #006400", +"5 c #004000", +"6 c #9897B3", +"7 c #BBBAFF", +"8 c #F1F1FF", +"9 c #353542", +"0 c #E7E5FF", +"a c #646489", +"b c #232532", +"c c #005B00", +"d c #FBFBFF", +"e c #EAEAFF", +"f c #DBDBFF", +"g c #D5D3FF", +"h c #CDCDFF", +"i c #C8C6FF", +"j c #C1C1FF", +"k c #9F9DDB", +"l c #001000", +"m c #2F2F3B", +"n c #7A7A96", +"o c #D2D0FF", +"p c #5A5981", +"q c #20202F", +"r c #C8C8FF", +"s c #C0BFFF", +"t c #5C5C82", +"u c #B8B8FF", +"v c #56557D", +"w c #9493D6", +"x c #1D1D2C", +" .. .. ", +" .+..@. ", +"##$.%%&*.$######", +"##$.%=-;.>,#####", +" .')!~{]^ ", +"##$./(_:<%<.[###", +"##$.}|12.%.345##", +" .6:27.8. . ", +"##$.9<...0...abc", +"##$.]d8e!fghijkl", +" .mn...o...pq ", +" . .r. .. ", +" . .s. . ", +" .tuv.. ", +" qwx. ", +" . "}; diff --git a/pcbnew/bitmaps/Drag_Pad.xpm b/pcbnew/bitmaps/Drag_Pad.xpm new file mode 100644 index 0000000000..af51caca92 --- /dev/null +++ b/pcbnew/bitmaps/Drag_Pad.xpm @@ -0,0 +1,67 @@ +/* XPM */ +static char * drag_pad_xpm[] = { +"16 16 48 1", +" c None", +". c #000000", +"+ c #000200", +"@ c #003B00", +"# c #006400", +"$ c #007700", +"% c #005F00", +"& c #007D00", +"* c #007600", +"= c #006100", +"- c #006500", +"; c #000B00", +"> c #005200", +", c #30343B", +"' c #DCDCEF", +") c #30303B", +"! c #003C00", +"~ c #84849B", +"{ c #FFFFFF", +"] c #003D00", +"^ c #003700", +"/ c #004000", +"( c #005300", +"_ c #F1F1FF", +": c #E7E5FF", +"< c #646489", +"[ c #232332", +"} c #FBFBFF", +"| c #EAEAFF", +"1 c #E2E1FF", +"2 c #DBDBFF", +"3 c #D5D3FF", +"4 c #CDCDFF", +"5 c #C8C6FF", +"6 c #C1C1FF", +"7 c #9F9DDB", +"8 c #2F2F3B", +"9 c #7A7A96", +"0 c #D2D0FF", +"a c #5A5981", +"b c #20202F", +"c c #C8C8FF", +"d c #C0BFFF", +"e c #5C5C82", +"f c #B8B8FF", +"g c #56557D", +"h c #9493D6", +"i c #1D1D2C", +" ..... ", +" +@#$#@+ ", +" +%&&&&&%+ ", +".@&&*=*&-;. ", +".#&* >,')!&&&&", +".$&= .~{~.]&&&", +".#&* %.{.^#/&&", +".@&&(.%&._. . ", +" +%-,~...:...<[ ", +" +;'}_|1234567.", +" .89...0...ab ", +" .. .c. .. ", +" . .d. . ", +" .efg.. ", +" bhi. ", +" . "}; diff --git a/pcbnew/bitmaps/Edges_Sketch.xpm b/pcbnew/bitmaps/Edges_Sketch.xpm new file mode 100644 index 0000000000..b23685fd3f --- /dev/null +++ b/pcbnew/bitmaps/Edges_Sketch.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static char * Edges_Sketch_xpm[] = { +"16 16 3 1", +" c None", +". c #D72E2E", +"+ c #00009B", +"...+++ +++... ", +". .+ +++ +. . ", +"...+ +... ", +" + + ", +"...+ +... ", +". .+ +. . ", +"...+ +... ", +" + + ", +"...+ +... ", +". .+ +. . ", +"...+ +... ", +" + + ", +"...+ +... ", +". .+ +. . ", +"...+++++++++... ", +" "}; diff --git a/pcbnew/bitmaps/Edit_Module.xpm b/pcbnew/bitmaps/Edit_Module.xpm new file mode 100644 index 0000000000..c4b986d074 --- /dev/null +++ b/pcbnew/bitmaps/Edit_Module.xpm @@ -0,0 +1,67 @@ +/* XPM */ +static char * Edit_Module_xpm[] = { +"16 16 48 1", +" c None", +". c #000000", +"+ c #F9E53A", +"@ c #F0B44C", +"# c #FAE93C", +"$ c #F5B343", +"% c #635632", +"& c #FAE73A", +"* c #F5B344", +"= c #6B5E33", +"- c #C0C0C0", +"; c #B8B8C0", +"> c #F8E239", +", c #F2B043", +"' c #615739", +") c #D72E2E", +"! c #FFFFFF", +"~ c #F5F4FF", +"{ c #EBEAFF", +"] c #F8DD38", +"^ c #F1AD41", +"/ c #615637", +"( c #F5F5FF", +"_ c #EBEBFF", +": c #010101", +"< c #F7DA37", +"[ c #EEB24C", +"} c #655931", +"| c #F6F5FF", +"1 c #ECEBFF", +"2 c #F7D737", +"3 c #EEA73E", +"4 c #64582F", +"5 c #ECECFF", +"6 c #F5D136", +"7 c #ECA33E", +"8 c #5B512F", +"9 c #010000", +"0 c #E3E2FF", +"a c #D6AD74", +"b c #61562F", +"c c #4F4115", +"d c #BCBAFF", +"e c #B2B0FF", +"f c #C6C5FF", +"g c #BCBBFF", +"h c #B3B1FF", +"i c #AFADFF", +" ...", +" .+@.", +" .#$%.", +" .. .. .&*=. ", +" .-..;..>,'. ", +" ).!!~{.]^/. ", +" ).!(_:<[}. ", +" .|1:234. ", +" ).5:6789 ", +" ).0:ab.) ", +" .:c::. ", +" ).::de.) ", +" ).fghi.) ", +" ...... ", +" ", +" "}; diff --git a/pcbnew/bitmaps/Export_Module.xpm b/pcbnew/bitmaps/Export_Module.xpm new file mode 100644 index 0000000000..e9e1c7143d --- /dev/null +++ b/pcbnew/bitmaps/Export_Module.xpm @@ -0,0 +1,105 @@ +/* XPM */ +static char * export_module_xpm[] = { +"16 16 86 1", +" c None", +". c #000000", +"+ c #F3F3F3", +"@ c #1B1B1B", +"# c #1A1A1B", +"$ c #E7E7F3", +"% c #002000", +"& c #D72E2E", +"* c #FFFFFF", +"= c #E0E0E0", +"- c #C8C8C8", +"; c #C3C3C8", +"> c #D4D4E0", +", c #E7E6FB", +"' c #350B0B", +") c #110802", +"! c #000E00", +"~ c #00AB00", +"{ c #001E00", +"] c #FDFDFF", +"^ c #F7F7FF", +"/ c #F0F0FF", +"( c #D9D8ED", +"_ c #292A2F", +": c #005800", +"< c #009A00", +"[ c #00BC00", +"} c #00B700", +"| c #00BD00", +"1 c #009200", +"2 c #FCFCFF", +"3 c #F6F6FF", +"4 c #EFEFFF", +"5 c #E8E8FF", +"6 c #61616E", +"7 c #007900", +"8 c #004400", +"9 c #001700", +"0 c #000100", +"a c #00A000", +"b c #001600", +"c c #F5F4FF", +"d c #EEEEFF", +"e c #E7E7FF", +"f c #D2D1EE", +"g c #031403", +"h c #005D00", +"i c #2A0808", +"j c #651515", +"k c #001000", +"l c #EDECFF", +"m c #E6E6FF", +"n c #E0DFFF", +"o c #ABABCA", +"p c #004000", +"q c #002200", +"r c #7D1A1A", +"s c #8B1D1D", +"t c #E5E5FF", +"u c #DFDEFF", +"v c #D8D7FF", +"w c #8989A8", +"x c #DDDDFF", +"y c #D7D6FF", +"z c #D0CFFF", +"A c #CAC8FF", +"B c #8180A9", +"C c #72719B", +"D c #C02929", +"E c #D6D5FF", +"F c #CFCEFF", +"G c #C8C7FF", +"H c #C2C0FF", +"I c #9796CF", +"J c #918FCD", +"K c #D52D2D", +"L c #CECDFF", +"M c #C7C6FF", +"N c #C1BFFF", +"O c #BAB8FF", +"P c #B4B2FF", +"Q c #AFADFF", +"R c #C6C5FF", +"S c #C0BEFF", +"T c #B9B7FF", +"U c #B2B1FF", +" ", +" ... ... . ", +" .+@..#$. .% ", +"&&.*=-;>,.')!~{ ", +"&&.*]^/(_:<[}|1.", +" .234567}890ab ", +"&&.cdefg|hij.k. ", +"&&.lmnop|qrs.. ", +" .tuvw.... . ", +"&&.xyzABC.D& ", +"&&.EFGHIJ.K& ", +" .LMNOPQ. ", +" .RSTUQQ. ", +" ........ ", +" ", +" "}; diff --git a/pcbnew/bitmaps/Export_Options_Pad.xpm b/pcbnew/bitmaps/Export_Options_Pad.xpm new file mode 100644 index 0000000000..028c9c4e65 --- /dev/null +++ b/pcbnew/bitmaps/Export_Options_Pad.xpm @@ -0,0 +1,90 @@ +/* XPM */ +static char * Export_Options_Pad_xpm[] = { +"16 16 71 1", +" c None", +". c #000000", +"+ c #000200", +"@ c #003B00", +"# c #006400", +"$ c #007700", +"% c #005F00", +"& c #007D00", +"* c #007600", +"= c #006100", +"- c #003A00", +"; c #005B00", +"> c #000E00", +", c #002400", +"' c #004D00", +") c #005800", +"! c #00BD00", +"~ c #005500", +"{ c #004E00", +"] c #001800", +"^ c #009E00", +"/ c #00AA00", +"( c #008800", +"_ c #006C00", +": c #006F00", +"< c #00A800", +"[ c #009900", +"} c #000A00", +"| c #006E00", +"1 c #006800", +"2 c #002300", +"3 c #004300", +"4 c #002B00", +"5 c #007000", +"6 c #000D00", +"7 c #F0F0F0", +"8 c #DEDEDE", +"9 c #AEAEAE", +"0 c #3E3E3E", +"a c #363636", +"b c #555555", +"c c #B7B7B7", +"d c #DFDFDF", +"e c #9D9D9D", +"f c #989898", +"g c #DADADA", +"h c #BFBFBF", +"i c #7A7A7A", +"j c #737373", +"k c #B3B3B3", +"l c #C0C0C0", +"m c #A4A4A4", +"n c #B9B9B9", +"o c #979797", +"p c #E3E3E3", +"q c #DDDDDD", +"r c #C8C8C8", +"s c #656565", +"t c #838383", +"u c #878787", +"v c #888888", +"w c #AFAFAF", +"x c #A3A3A3", +"y c #F1F1F1", +"z c #CECECE", +"A c #ABABAB", +"B c #EEEEEE", +"C c #EDEDED", +"D c #E9E9E9", +"E c #D9D9D9", +"F c #C1C1C1", +" ..... ", +" +@#$#@+ . ", +" +%&&&&&%+ .. ", +".@&&*=*&&-. .;. ", +".#&* $%>,')!~.", +".$&= {]^/(_!:.", +".#&* ]<[}..#. ", +".@&&$|12!3.... ", +" +%&...456......", +" +.7890abcdefgd", +" .dhhijjklmnll", +" .dho...flllll", +" .dh.pqr.stuvw", +" .dh.qlx.....y", +" .dh.zxo.ABCDE", +" .dlf...stFFFF"}; diff --git a/pcbnew/bitmaps/Flag.xpm b/pcbnew/bitmaps/Flag.xpm new file mode 100644 index 0000000000..25a6d3f8d0 --- /dev/null +++ b/pcbnew/bitmaps/Flag.xpm @@ -0,0 +1,43 @@ +/* XPM */ +static char * Flag_xpm[] = { +"16 16 24 1", +" c None", +". c #000000", +"+ c #FE0204", +"@ c #FE4B4C", +"# c #E90103", +"$ c #DB3A3B", +"% c #DB6061", +"& c #D70002", +"* c #C9292A", +"= c #D35354", +"- c #ED6465", +"; c #FE3335", +"> c #FE7071", +", c #E51C1E", +"' c #B20001", +") c #343434", +"! c #FE5E5F", +"~ c #C90002", +"{ c #E22F30", +"] c #C95253", +"^ c #ED7374", +"/ c #1C1C1C", +"( c #CC5456", +"_ c #E96364", +" ", +" .. ", +" +@. ", +" +#$%. ", +" +#&*=-. ", +" ;>,'*=-) ", +" !,~*=-) ", +" {]^/ ", +" (_. ", +" .. ", +" .. ", +" .. ", +" .. ", +" ..... ", +" .......... ", +" "}; diff --git a/pcbnew/bitmaps/Global_Options_Pad.xpm b/pcbnew/bitmaps/Global_Options_Pad.xpm new file mode 100644 index 0000000000..18b423afbb --- /dev/null +++ b/pcbnew/bitmaps/Global_Options_Pad.xpm @@ -0,0 +1,100 @@ +/* XPM */ +static char * global_options_pad_xpm[] = { +"16 16 81 1", +" c None", +". c #000000", +"+ c #000200", +"@ c #003B00", +"# c #006400", +"$ c #007700", +"% c #005F00", +"& c #007D00", +"* c #007600", +"= c #006100", +"- c #F0F0F0", +"; c #DEDEDE", +"> c #DFDFDF", +", c #000100", +"' c #030303", +") c #BFBFBF", +"! c #C0C0C0", +"~ c #000300", +"{ c #DBDAD8", +"] c #070707", +"^ c #9A9A9A", +"/ c #080808", +"( c #989898", +"_ c #B0B0AE", +": c #474540", +"< c #9D9B94", +"[ c #484641", +"} c #0A0A0A", +"| c #86857F", +"1 c #353535", +"2 c #0C0C0C", +"3 c #C8C8C8", +"4 c #656565", +"5 c #838383", +"6 c #878787", +"7 c #888888", +"8 c #AFAFAF", +"9 c #8F8E88", +"0 c #8F8D85", +"a c #96948D", +"b c #7F7C73", +"c c #0B0B0B", +"d c #A3A3A3", +"e c #F1F1F1", +"f c #585753", +"g c #5F5D56", +"h c #888782", +"i c #807D74", +"j c #75736A", +"k c #979797", +"l c #ABABAB", +"m c #EEEEEE", +"n c #EDEDED", +"o c #E9E9E9", +"p c #D9D9D9", +"q c #42413E", +"r c #272623", +"s c #363430", +"t c #9E9C95", +"u c #6D6B63", +"v c #C1C1C1", +"w c #201F1D", +"x c #090807", +"y c #181816", +"z c #E5E5E3", +"A c #64625B", +"B c #777777", +"C c #878681", +"D c #35332F", +"E c #151513", +"F c #8B8A88", +"G c #DEDDDB", +"H c #65635C", +"I c #717171", +"J c #E3E3E3", +"K c #DDDDDD", +"L c #AEADA7", +"M c #B4B3AD", +"N c #E4E4E2", +"O c #D4D3D0", +"P c #92908A", +" ..... ", +" +@#$#@+ ", +" +%&&&&&%+ ", +".@&&*=*&&@. ", +".#&* $&#. ", +".$&=............", +".#&.-;>>>>>>>>>>", +".@,.'))))))!!!!!", +".+~{]^/...(!!!!!", +"_.:<[}|123.45678", +"9<<<0ab[cd.....e", +"< c #002300", +", c #000800", +"' c #006E00", +") c #004A00", +"! c #262626", +"~ c #C3C3C8", +"{ c #D4D4E0", +"] c #EBEAFF", +"^ c #D72E2E", +"/ c #002800", +"( c #008600", +"_ c #00B400", +": c #00BD00", +"< c #00B800", +"[ c #82828A", +"} c #EAE9FF", +"| c #E3E2FF", +"1 c #000200", +"2 c #000B00", +"3 c #007600", +"4 c #005B00", +"5 c #19191B", +"6 c #A1A1B2", +"7 c #E2E1FF", +"8 c #DBDAFF", +"9 c #A62323", +"0 c #8F1E1E", +"a c #002000", +"b c #0E0E0F", +"c c #8B8B9A", +"d c #CCCBE8", +"e c #DAD9FF", +"f c #D3D2FF", +"g c #070708", +"h c #828292", +"i c #C3C3DF", +"j c #D9D8FF", +"k c #D2D1FF", +"l c #CCCAFF", +"m c #777785", +"n c #BAB9D5", +"o c #D8D7FF", +"p c #D1D0FF", +"q c #CBC9FF", +"r c #C4C3FF", +"s c #AFAFCA", +"t c #D7D6FF", +"u c #D0CFFF", +"v c #CAC8FF", +"w c #C3C2FF", +"x c #BCBBFF", +"y c #D6D5FF", +"z c #CFCEFF", +"A c #C8C7FF", +"B c #C2C0FF", +"C c #BBBAFF", +"D c #B5B3FF", +"E c #CECDFF", +"F c #C7C6FF", +"G c #C1BFFF", +"H c #BAB8FF", +"I c #B4B2FF", +"J c #AFADFF", +"K c #C6C5FF", +"L c #C0BEFF", +"M c #B9B7FF", +"N c #B2B1FF", +"... . ", +".+@. ... ... ", +".#+$..%&..*=. ", +" -;#>,')!~{].^^ ", +" ./(_:<:/[}|.^^ ", +" ..12345678. ", +" 90.abcdef.^^ ", +" ^^.ghijkl.^^ ", +" .mnopqr. ", +" ^^.stuvwx.^^ ", +" ^^.yzABCD.^^ ", +" .EFGHIJ. ", +" .KLMNJJ. ", +" ........ ", +" ", +" "}; diff --git a/pcbnew/bitmaps/Invert_Module.xpm b/pcbnew/bitmaps/Invert_Module.xpm new file mode 100644 index 0000000000..4c75634c0d --- /dev/null +++ b/pcbnew/bitmaps/Invert_Module.xpm @@ -0,0 +1,50 @@ +/* XPM */ +static char * invert_module_xpm[] = { +"16 16 31 1", +" c None", +". c #000000", +"+ c #696969", +"@ c #C0C0C0", +"# c #B8B8C0", +"$ c #D72E2E", +"% c #FFFFFF", +"& c #F5F4FF", +"* c #EBEAFF", +"= c #F5F5FF", +"- c #EBEBFF", +"; c #E1E1FF", +"> c #F6F5FF", +", c #ECEBFF", +"' c #E2E1FF", +") c #D8D7FF", +"! c #ECECFF", +"~ c #E2E2FF", +"{ c #CECDFF", +"] c #E3E2FF", +"^ c #D9D8FF", +"/ c #CFCEFF", +"( c #C5C4FF", +"_ c #BBBAFF", +": c #D0CFFF", +"< c #C6C5FF", +"[ c #BCBAFF", +"} c #B2B0FF", +"| c #BCBBFF", +"1 c #B3B1FF", +"2 c #AFADFF", +" . ", +" ", +" . ", +" ++ ++. .. .. ", +" ++++++ .@..#. ", +".++++++.$.%%&*.$", +".++++++.$.%=-;.$", +" ++++++ .>,'). ", +".++++++.$.!~){.$", +".++++++.$.]^/(.$", +" ++++++ .^/(_. ", +".++++++.$.:<[}.$", +".++++++.$.<|12.$", +" ++++++ ...... ", +" . ", +" . "}; diff --git a/pcbnew/bitmaps/Load_Module_Board.xpm b/pcbnew/bitmaps/Load_Module_Board.xpm new file mode 100644 index 0000000000..9ed76c9ced --- /dev/null +++ b/pcbnew/bitmaps/Load_Module_Board.xpm @@ -0,0 +1,99 @@ +/* XPM */ +static char * load_module_board_xpm[] = { +"16 16 80 1", +" c None", +". c #000000", +"+ c #FEFEFF", +"@ c #F9AB7F", +"# c #F55A00", +"$ c #FFFFFF", +"% c #002100", +"& c #FBFBFC", +"* c #8C8C8D", +"= c #404041", +"- c #161B17", +"; c #000D00", +"> c #00AA00", +", c #002200", +"' c #F0F0F1", +") c #33231A", +"! c #005500", +"~ c #009900", +"{ c #00BC00", +"] c #00B900", +"^ c #00BD00", +"/ c #009C00", +"( c #000100", +"_ c #712900", +": c #007400", +"< c #00BA00", +"[ c #004800", +"} c #001800", +"| c #009F00", +"1 c #001B00", +"2 c #F3F3F4", +"3 c #050F05", +"4 c #006900", +"5 c #2B1E16", +"6 c #6F6F75", +"7 c #001000", +"8 c #D1D1D2", +"9 c #003600", +"0 c #012F01", +"a c #898990", +"b c #9A9AA5", +"c c #A93E00", +"d c #250D00", +"e c #B54200", +"f c #E8E8FD", +"g c #030303", +"h c #F9F9FF", +"i c #A5A5AC", +"j c #92929B", +"k c #90909B", +"l c #CDCDE0", +"m c #E6E6FF", +"n c #050506", +"o c #FCFCFF", +"p c #F8F8FF", +"q c #F5F5FF", +"r c #C4C4D0", +"s c #C18366", +"t c #C44800", +"u c #E99C7D", +"v c #E2E2FF", +"w c #060607", +"x c #DEDEFF", +"y c #070708", +"z c #FBFBFF", +"A c #F7F7FF", +"B c #F4F4FF", +"C c #F0F0FF", +"D c #ECECFF", +"E c #E9E9FF", +"F c #ED9F7F", +"G c #E99B7F", +"H c #DADAFF", +"I c #F3F3FF", +"J c #E8E8FF", +"K c #E4E4FF", +"L c #E1E1FF", +"M c #DDDDFF", +"N c #D9D9FF", +"O c #D5D5FF", +"............ ", +".+@#@++++++.. ", +".+#$######+.% ", +".+@#@++&*=-;>, ", +".+++++')!~{]^/( ", +".+####_:<[}(|1. ", +".++++23{456.7. ", +".+@#@89^0ab.. ", +".+#$#c..defg. ", +".+@#@hijklmn ", +".++opqrstuvw ", +".+######$#xy ", +".zABCDEF#GHy ", +".AICDJKLMNOy ", +"............ ", +" "}; diff --git a/pcbnew/bitmaps/Load_Module_Lib.xpm b/pcbnew/bitmaps/Load_Module_Lib.xpm new file mode 100644 index 0000000000..4047f53439 --- /dev/null +++ b/pcbnew/bitmaps/Load_Module_Lib.xpm @@ -0,0 +1,162 @@ +/* XPM */ +static char * Load_Module_Lib_xpm[] = { +"16 16 143 2", +" c None", +". c #050607", +"+ c #313437", +"@ c #1C1C1D", +"# c #090B0C", +"$ c #E3E5E6", +"% c #F4F4F4", +"& c #7D7F81", +"* c #030304", +"= c #000000", +"- c #FFFFFF", +"; c #F5F5F5", +"> c #D6D6D6", +", c #D5D6D7", +"' c #1E1F20", +") c #001700", +"! c #040507", +"~ c #E1E4E5", +"{ c #D6D7D7", +"] c #D0D0D0", +"^ c #E0E0E0", +"/ c #909193", +"( c #040404", +"_ c #005900", +": c #006200", +"< c #06090B", +"[ c #E2E4E6", +"} c #F7F7F7", +"| c #D3D3D3", +"1 c #BBBBBB", +"2 c #CBCBCB", +"3 c #898989", +"4 c #0A1A0A", +"5 c #006900", +"6 c #009A00", +"7 c #00B300", +"8 c #00BC00", +"9 c #00BD00", +"0 c #003E00", +"a c #010203", +"b c #9C9C9D", +"c c #F2F2F3", +"d c #CDCDCD", +"e c #CECECE", +"f c #A9A9A9", +"g c #0C240C", +"h c #00A400", +"i c #009800", +"j c #003800", +"k c #001C00", +"l c #005D00", +"m c #007200", +"n c #070807", +"o c #050505", +"p c #808383", +"q c #ADB1B4", +"r c #DCDCDC", +"s c #B6B6B6", +"t c #C7C7C7", +"u c #636363", +"v c #051905", +"w c #444444", +"x c #001900", +"y c #1F1F1F", +"z c #848484", +"A c #19191A", +"B c #161616", +"C c #949597", +"D c #BABABA", +"E c #C2C2C2", +"F c #383838", +"G c #009100", +"H c #009200", +"I c #393939", +"J c #878889", +"K c #5E5F5F", +"L c #171717", +"M c #7B7B7C", +"N c #7C7E7E", +"O c #787B7D", +"P c #AFB2B4", +"Q c #DEDEDE", +"R c #BEBEBE", +"S c #161717", +"T c #001000", +"U c #000A00", +"V c #6D6E6E", +"W c #DDDFE0", +"X c #A2A3A4", +"Y c #848585", +"Z c #8A8B8C", +"` c #81878D", +" . c #68727A", +".. c #B8B8B8", +"+. c #C4C4C4", +"@. c #7A7C7E", +"#. c #7C7C7C", +"$. c #959696", +"%. c #F8F9FA", +"&. c #F6F7F8", +"*. c #949595", +"=. c #ACAFB3", +"-. c #171A1D", +";. c #404346", +">. c #7F8589", +",. c #97999A", +"'. c #C1C1C1", +"). c #C0C0C0", +"!. c #D7D8D8", +"~. c #F8F9F9", +"{. c #F8F8F9", +"]. c #C1C3C6", +"^. c #737B83", +"/. c #535962", +"(. c #7F8081", +"_. c #E4E4E4", +":. c #E9E9E9", +"<. c #FCFDFD", +"[. c #FBFCFC", +"}. c #F9FAFA", +"|. c #EEEFEF", +"1. c #A7ACB2", +"2. c #15171A", +"3. c #11151A", +"4. c #454F5B", +"5. c #BEC4CA", +"6. c #C3C7CA", +"7. c #D4D5D6", +"8. c #DADADA", +"9. c #F2F3F3", +"0. c #D0D0D1", +"a. c #797F86", +"b. c #151719", +"c. c #26292C", +"d. c #44494C", +"e. c #7C8082", +"f. c #9A9C9E", +"g. c #9EA4AA", +"h. c #90979D", +"i. c #0C0E10", +"j. c #1F262D", +"k. c #171C20", +"l. c #1D2227", +" . + @ ", +" # $ % & * = ", +"- # $ ; > , ' ) = ", +" ! ~ ; { ] ^ / ( = = _ : = ", +" < [ } | 1 2 3 4 5 6 7 8 9 0 ", +"a b c d e 2 f g h i j k l m n o ", +"= p q r s t u : 8 v w w x y z A ", +" B C D t E F G H I J K L M N = ", +" = O P Q R S T U V W X Y Z ` = ", +" S ...+.@.#.#.$.%.&.*.=.-. ", +" = ;.>.,.R '.).!.~.{.].^.= ", +" = /.(._.:.<.[.}.|.1.2. ", +" 3.4.5.6.7.8.9.0.a.= ", +" b.c.d.e.f.g.h.i. ", +" j.k.l. ", +" "}; diff --git a/pcbnew/bitmaps/Locked.xpm b/pcbnew/bitmaps/Locked.xpm new file mode 100644 index 0000000000..ddc04df0de --- /dev/null +++ b/pcbnew/bitmaps/Locked.xpm @@ -0,0 +1,109 @@ +/* XPM */ +static char * Locked_xpm[] = { +"16 16 90 1", +" c None", +". c #000000", +"+ c #1E1E1E", +"@ c #7A7A7A", +"# c #D2D2D2", +"$ c #DBDBDB", +"% c #BCBCBC", +"& c #727272", +"* c #080808", +"= c #848484", +"- c #BEBEBE", +"; c #383838", +"> c #1C1C1C", +", c #4D4D4D", +"' c #B1B1B1", +") c #2D2D2D", +"! c #C2C2C2", +"~ c #090909", +"{ c #2E2E2E", +"] c #AAAAAA", +"^ c #2B2B2B", +"/ c #C0C0C0", +"( c #161616", +"_ c #C1C0C0", +": c #13110E", +"< c #9B9794", +"[ c #201D1C", +"} c #0B0B07", +"| c #040302", +"1 c #050403", +"2 c #2F2921", +"3 c #A8A39E", +"4 c #1A130B", +"5 c #A59176", +"6 c #E0C4A0", +"7 c #DFC4A3", +"8 c #DABE9A", +"9 c #D6BA94", +"0 c #CDA676", +"a c #815A2B", +"b c #E2C5A1", +"c c #D8B58C", +"d c #CA9F68", +"e c #AC8758", +"f c #A78252", +"g c #A78253", +"h c #A37B4B", +"i c #BC8849", +"j c #AC712E", +"k c #E3C6A2", +"l c #D5AE7E", +"m c #B08D5F", +"n c #D5B284", +"o c #CFAB7C", +"p c #CFAC7B", +"q c #CBA471", +"r c #BC8746", +"s c #AA6F2B", +"t c #E1C4A0", +"u c #D0A674", +"v c #C79B64", +"w c #AA8455", +"x c #A47E4E", +"y c #A07744", +"z c #BA8442", +"A c #E1C29C", +"B c #CEA470", +"C c #AD8D64", +"D c #D2B289", +"E c #CDAC83", +"F c #CEAD83", +"G c #CCA77B", +"H c #B8803E", +"I c #AD7332", +"J c #E0C29E", +"K c #D4AC79", +"L c #CDA66E", +"M c #AF8D5E", +"N c #AB8758", +"O c #AB8858", +"P c #A8814C", +"Q c #B47E3E", +"R c #D0A874", +"S c #C6965D", +"T c #BE8D50", +"U c #BA894B", +"V c #BD8C4E", +"W c #BC8A4C", +"X c #BA8647", +"Y c #A47136", +" ", +" .... ", +" +@#$$%&* ", +" =-;>>,'= ", +" )!~ {]. ", +" ^/. (_. ", +" :<[}||1234 ", +" .567788890a. ", +" .bcdeffghij. ", +" .klmnoopqrs. ", +" .tuvwxxxyzj. ", +" .ABCDEEFGHI. ", +" .JKLMNNOPrQ. ", +" .RSTTUUVWXY. ", +" .......... ", +" "}; diff --git a/pcbnew/bitmaps/Mode_Module.xpm b/pcbnew/bitmaps/Mode_Module.xpm new file mode 100644 index 0000000000..6b1a7b49e3 --- /dev/null +++ b/pcbnew/bitmaps/Mode_Module.xpm @@ -0,0 +1,115 @@ +/* XPM */ +static char * mode_module_xpm[] = { +"16 16 96 2", +" c None", +". c #D72E2E", +"+ c #000000", +"@ c #F8F8F8", +"# c #B8B8B8", +"$ c #A9A9B8", +"% c #DAD9F8", +"& c #D42D2D", +"* c #FFFFFF", +"= c #C9C9C9", +"- c #2F2F31", +"; c #AEADBD", +"> c #E1E0FF", +", c #D7D6FF", +"' c #D12C2C", +") c #B3B3B3", +"! c #373742", +"~ c #DCDCEF", +"{ c #343441", +"] c #8887A2", +"^ c #CDCCFF", +"/ c #D62D2D", +"( c #929292", +"_ c #020202", +": c #84849B", +"< c #010101", +"[ c #605F7D", +"} c #E0E0E9", +"| c #BDBDCD", +"1 c #8A89B4", +"2 c #9594CD", +"3 c #962020", +"4 c #BEBDCD", +"5 c #E3E2FF", +"6 c #F1F1FF", +"7 c #9694CD", +"8 c #B1AFFF", +"9 c #811B1B", +"0 c #CF2C2C", +"a c #140303", +"b c #31313C", +"c c #E7E5FF", +"d c #646489", +"e c #232332", +"f c #170404", +"g c #2A0909", +"h c #FBFBFF", +"i c #EAEAFF", +"j c #E2E1FF", +"k c #DBDBFF", +"l c #D5D3FF", +"m c #CDCDFF", +"n c #C8C6FF", +"o c #C1C1FF", +"p c #9F9DDB", +"q c #1C0505", +"r c #C92B2B", +"s c #080101", +"t c #342F3B", +"u c #7A7A96", +"v c #D2D0FF", +"w c #5A5981", +"x c #241F2E", +"y c #090101", +"z c #CA2B2B", +"A c #881C1C", +"B c #8C8BB4", +"C c #9796CD", +"D c #C8C8FF", +"E c #706FA4", +"F c #8C8BCD", +"G c #5C1313", +"H c #BC2727", +"I c #9897CD", +"J c #B4B2FF", +"K c #C0BFFF", +"L c #AFADFF", +"M c #150404", +"N c #5D5C85", +"O c #010102", +"P c #5C5C82", +"Q c #B8B8FF", +"R c #56557D", +"S c #504F75", +"T c #696799", +"U c #232234", +"V c #9493D6", +"W c #1F1F31", +"X c #4B4A6E", +"Y c #9694DB", +"Z c #050508", +"` c #030305", +" . c #000001", +".. c #020204", +"+. c #040407", +"@. c #CE2C2C", +". . . + + + + + + . . . ", +". . + @ # + + + $ % + . . ", +". & . + * * = - ; > , + . ' . ", +" + * ) ! ~ { ] ^ + ", +". / / + ( _ : * : < [ + ' / / ", +". . + } | + * + 1 2 + . . ", +". ' 3 + 4 5 + 6 + 7 8 + 9 0 . ", +" a b : + + + c + + + d e f ", +". g ~ h 6 i j k l m n o p q r ", +". s t u + + + v + + + w x y z ", +". & A + B C + D + E F + G H . ", +" + I J + K + F L + M ", +". / / + N O P Q R O S + ' / / ", +". . + L T U V W X Y + . . ", +". ' . + Z Z ` ...+.Z + . @.. ", +" "}; diff --git a/pcbnew/bitmaps/Mode_Track.xpm b/pcbnew/bitmaps/Mode_Track.xpm new file mode 100644 index 0000000000..4dc97029e0 --- /dev/null +++ b/pcbnew/bitmaps/Mode_Track.xpm @@ -0,0 +1,61 @@ +/* XPM */ +static char * mode_track_xpm[] = { +"16 16 42 1", +" c None", +". c #007D00", +"+ c #007C00", +"@ c #122A12", +"# c #122910", +"$ c #000500", +"% c #D72E2E", +"& c #3B1A1A", +"* c #F2D7C1", +"= c #F2BD8E", +"- c #3A150F", +"; c #057A01", +"> c #C9322B", +", c #D62D2D", +"' c #3B1715", +") c #F2B279", +"! c #F29747", +"~ c #3A1209", +"{ c #090101", +"] c #122204", +"^ c #122000", +"/ c #050300", +"( c #0B0202", +"_ c #007B00", +": c #090D01", +"< c #000600", +"[ c #067A01", +"} c #102910", +"| c #142912", +"1 c #070B01", +"2 c #3F1818", +"3 c #EFD5BE", +"4 c #F5BF90", +"5 c #37170F", +"6 c #3F1614", +"7 c #EFB078", +"8 c #F59948", +"9 c #371408", +"0 c #000000", +"a c #102203", +"b c #141F00", +"c c #000D00", +" .. .. ", +" .. +. ", +" @#$ +. ", +"%%&*=-%%%%%;.>%%", +",%')!~%%%%%;.>%%", +" {]^/( _.: ", +" ..< +. ", +" .. +. ", +" .. +. ", +" .. +. ", +" [[ }|1 ", +"%%%%%%%%%%2345%%", +",%%%%%%%%%6789%%", +" ..< 0ab<0 ", +" .. +.c ", +" .. +. "}; diff --git a/pcbnew/bitmaps/Modul_Edit.xpm b/pcbnew/bitmaps/Modul_Edit.xpm new file mode 100644 index 0000000000..f50b64980a --- /dev/null +++ b/pcbnew/bitmaps/Modul_Edit.xpm @@ -0,0 +1,56 @@ +/* XPM */ +static char * Modul_Edit_xpm[] = { +"16 16 37 1", +" c None", +". c #FF7800", +"+ c #010000", +"@ c #000000", +"# c #FAE53A", +"$ c #F0B44C", +"% c #FFFFFF", +"& c #FBEA3D", +"* c #F6B343", +"= c #635632", +"- c #010101", +"; c #FBE73A", +"> c #F6B344", +", c #6C5E33", +"' c #F9E33A", +") c #F3B043", +"! c #625739", +"~ c #F8DE39", +"{ c #F2AE42", +"] c #625738", +"^ c #F0F0F0", +"/ c #7B7B7B", +"( c #F8DB38", +"_ c #EEB34D", +": c #665A32", +"< c #FCFCFC", +"[ c #1E1E1E", +"} c #F7D737", +"| c #EFA83F", +"1 c #655930", +"2 c #B1B1B1", +"3 c #F5D136", +"4 c #ECA33E", +"5 c #5C5230", +"6 c #D6AD74", +"7 c #61562F", +"8 c #4F4115", +" ... ... ..+@@", +" ... ... .+#$@", +"@.%.@@.%.@@+&*=@", +"@...%%...%-;>,-@", +"@...%%...-')!+%@", +"@%%%%%%%-~{]-^/@", +"@%%%%%%-(_:-<[ ", +"@%%%%%-}|1-%2@ ", +"@%%%%-345-%%2@ ", +"@%%%%-67-%%%<[ ", +"@%%%-8--%%%%%^/@", +"@...--...%%...%@", +"@...%%...%%...%@", +"@.%.@@.%.@@.%.@@", +" ... ... ... ", +" ... ... ... "}; diff --git a/pcbnew/bitmaps/Module_Check.xpm b/pcbnew/bitmaps/Module_Check.xpm new file mode 100644 index 0000000000..44e7c73325 --- /dev/null +++ b/pcbnew/bitmaps/Module_Check.xpm @@ -0,0 +1,148 @@ +/* XPM */ +static char * module_check_xpm[] = { +"16 16 129 2", +" c None", +". c #D72E2E", +"+ c #000000", +"@ c #691717", +"# c #380C0C", +"$ c #F8F8F8", +"% c #B8B8B8", +"& c #A9A9B8", +"* c #DAD9F8", +"= c #3B0D0D", +"- c #353F4D", +"; c #477096", +"> c #D42D2D", +", c #FFFFFF", +"' c #EEEDF8", +") c #E5E4F8", +"! c #E1E0FF", +"~ c #D7D6FF", +"{ c #536980", +"] c #8EACC8", +"^ c #0D1217", +"/ c #FCFCFC", +"( c #FEFEFE", +"_ c #F5F5FF", +": c #EBEBFF", +"< c #E1E1FF", +"[ c #696983", +"} c #253341", +"| c #BFD0E0", +"1 c #31506C", +"2 c #050101", +"3 c #D62D2D", +"4 c #CD2B2B", +"5 c #3D6283", +"6 c #2D353B", +"7 c #C9C8D0", +"8 c #E7E6FA", +"9 c #E2E1FF", +"0 c #D8D7FF", +"a c #8685A6", +"b c #3F4557", +"c c #96AFC7", +"d c #628BB3", +"e c #5D1414", +"f c #C72B2B", +"g c #16222D", +"h c #D6E1EB", +"i c #26384A", +"j c #9191A4", +"k c #CFCEF4", +"l c #CECDFF", +"m c #23222D", +"n c #638AB1", +"o c #A2BBD3", +"p c #355573", +"q c #911F1F", +"r c #D12C2C", +"s c #D52E2E", +"t c #5885B0", +"u c #B1C6DA", +"v c #273C51", +"w c #777793", +"x c #52516A", +"y c #3E495E", +"z c #131D27", +"A c #470F0F", +"B c #B32626", +"C c #373B44", +"D c #7A9EC0", +"E c #769BBE", +"F c #233649", +"G c #41445C", +"H c #8AAAC8", +"I c #7298BC", +"J c #3B5F7F", +"K c #020100", +"L c #1B0505", +"M c #BAB9D9", +"N c #253849", +"O c #779CBF", +"P c #638DB5", +"Q c #33506A", +"R c #5482AE", +"S c #1B2C3C", +"T c #330B0B", +"U c #A42323", +"V c #D12D2D", +"W c #CCCBFA", +"X c #48495E", +"Y c #48739A", +"Z c #668FB6", +"` c #ACC2D7", +" . c #42698C", +".. c #05090B", +"+. c #6D1717", +"@. c #D62E2E", +"#. c #C7C6FF", +"$. c #B1AFEF", +"%. c #202A38", +"&. c #5D89B3", +"*. c #49749B", +"=. c #426A8E", +"-. c #263C51", +";. c #962020", +">. c #C82A2A", +",. c #BEBCFF", +"'. c #B2B0FC", +"). c #7372A8", +"!. c #243A4F", +"~. c #294158", +"{. c #0C141B", +"]. c #190505", +"^. c #B4B2FF", +"/. c #AFADFF", +"(. c #A8A6F5", +"_. c #2A2D41", +":. c #1B2B3A", +"<. c #0C0C11", +"[. c #C32929", +"}. c #AEACFE", +"|. c #9B99E2", +"1. c #060609", +"2. c #373650", +"3. c #D32D2D", +"4. c #050508", +"5. c #040407", +"6. c #020204", +"7. c #030305", +"8. c #CE2C2C", +". . . + + + + + + . @ # ", +". . + $ % + + + & * + = - ; + ", +". > . + , , $ ' ) ! ~ + { ] ^ + ", +" + / ( _ : < ~ [ } | 1 2 + ", +". 3 4 5 6 7 8 9 0 a b c d ^ e ", +". f g h i j k l m n o p 2 q ", +". r s + t u v w x y o t z A B ", +" + C D E F G H I J K L ", +". . . + M N O P Q u R S T U V ", +". . + W X Y Z ` P ...+. @. ", +". > . + #.$.%.&.*.=.-.+ ;.>.. ", +" + ,.'.).!.5 ~.{.+ ]. ", +". 3 3 + ^./.(._.:.{.<.+ [.3 3 ", +". . + /./.}.|.1.<.2.+ 3. . ", +". r . + 4.4.4.4.5.6.7.+ . 8.. ", +" + "}; diff --git a/pcbnew/bitmaps/Module_Ratsnet.xpm b/pcbnew/bitmaps/Module_Ratsnet.xpm new file mode 100644 index 0000000000..ec83e967a7 --- /dev/null +++ b/pcbnew/bitmaps/Module_Ratsnet.xpm @@ -0,0 +1,58 @@ +/* XPM */ +static char * Module_Ratsnet_xpm[] = { +"16 16 39 1", +" c None", +". c #FFFFFF", +"+ c #000000", +"@ c #040404", +"# c #030304", +"$ c #C3C3C3", +"% c #080808", +"& c #070708", +"* c #BABAC3", +"= c #FF7800", +"- c #F5F4FF", +"; c #EBEAFF", +"> c #F5F5FF", +", c #EBEBFF", +"' c #E1E1FF", +") c #F6F5FF", +"! c #ECEBFF", +"~ c #E2E1FF", +"{ c #D8D7FF", +"] c #ECECFF", +"^ c #E2E2FF", +"/ c #CECDFF", +"( c #E3E2FF", +"_ c #D9D8FF", +": c #CFCEFF", +"< c #C5C4FF", +"[ c #BBBAFF", +"} c #D0CFFF", +"| c #C6C5FF", +"1 c #BCBAFF", +"2 c #B2B0FF", +"3 c #C0BFF8", +"4 c #B6B5F8", +"5 c #AEACF8", +"6 c #AAA8F8", +"7 c #BCBCE4", +"8 c #00009B", +"9 c #7171C7", +"0 c #4444B5", +".. +@ #+ ..", +"... +$%&*+ ...", +" ..=+..-;+=.. ", +" .=+.>,'+=. ", +" +)!~{+ ", +"....=+]^{/+=....", +"....=+(_:<+=....", +" +_:<[+ ", +" .=+}|12+=. ", +" ...=+3456+=7.. ", +"... ++++++889..", +".. 8 8 0.", +" 88888 ", +" 8 8 8 ", +" 888 ", +" "}; diff --git a/pcbnew/bitmaps/Move_Field.xpm b/pcbnew/bitmaps/Move_Field.xpm new file mode 100644 index 0000000000..7b69fc774f --- /dev/null +++ b/pcbnew/bitmaps/Move_Field.xpm @@ -0,0 +1,81 @@ +/* XPM */ +static char * Move_Field_xpm[] = { +"16 16 62 1", +" c None", +". c #D2D2D2", +"+ c #9D9D9D", +"@ c #DEDEDE", +"# c #E0E0E0", +"$ c #5C5C5C", +"% c #000000", +"& c #EDEDED", +"* c #939393", +"= c #FDFDFD", +"- c #E4E4E4", +"; c #F1F1F1", +"> c #C3C3C3", +", c #272727", +"' c #E7E7E7", +") c #F4F4F4", +"! c #30303B", +"~ c #DCDCEF", +"{ c #33333E", +"] c #9A9A9A", +"^ c #E9E9E9", +"/ c #8C8C8C", +"( c #84849B", +"_ c #FFFFFF", +": c #010101", +"< c #7C7C7C", +"[ c #FAFAFA", +"} c #B0B0B0", +"| c #7A7A7A", +"1 c #848484", +"2 c #999999", +"3 c #F0F0F0", +"4 c #B1B1B1", +"5 c #020202", +"6 c #CBCBCB", +"7 c #F1F1FF", +"8 c #989898", +"9 c #7F7F7F", +"0 c #343440", +"a c #E7E5FF", +"b c #646489", +"c c #262635", +"d c #FBFBFF", +"e c #EAEAFF", +"f c #E2E1FF", +"g c #DBDBFF", +"h c #D5D3FF", +"i c #CDCDFF", +"j c #C8C6FF", +"k c #C1C1FF", +"l c #9F9DDB", +"m c #7A7A96", +"n c #D2D0FF", +"o c #5A5981", +"p c #20202F", +"q c #C8C8FF", +"r c #C0BFFF", +"s c #5C5C82", +"t c #B8B8FF", +"u c #56557D", +"v c #9493D6", +"w c #1D1D2C", +".++++++++++++++.", +"+.@@@@@@@@@@@@@+", +"+#$%%$&%%%*&===+", +"+-%;;%;%>,%;===+", +"+'%))%)%!~{]===+", +"+^%%%%/%(_(:<==+", +"+&%[[%-%%_%}|12+", +"+3==456=%7%6=58+", +".++90(%%%a%%%bc]", +" %~d7efghijkl%", +" !m%%%n%%%op ", +" % %q% %% ", +" % %r% % ", +" %stu%% ", +" pvw% ", +" % "}; diff --git a/pcbnew/bitmaps/Move_Module.xpm b/pcbnew/bitmaps/Move_Module.xpm new file mode 100644 index 0000000000..aa784a8705 --- /dev/null +++ b/pcbnew/bitmaps/Move_Module.xpm @@ -0,0 +1,74 @@ +/* XPM */ +static char * Move_Module_xpm[] = { +"16 16 55 1", +" c None", +". c #000000", +"+ c #C0C0C0", +"@ c #B8B8C0", +"# c #D72E2E", +"$ c #FFFFFF", +"% c #F5F4FF", +"& c #EBEAFF", +"* c #F5F5FF", +"= c #EBEBFF", +"- c #E1E1FF", +"; c #2A0909", +"> c #F6F5FF", +", c #ECEBFF", +"' c #E2E1FF", +") c #9796B3", +"! c #30303B", +"~ c #DCDCEF", +"{ c #31313C", +"] c #ECECFF", +"^ c #E2E2FF", +"/ c #7B7B92", +"( c #020202", +"_ c #84849B", +": c #E3E2FF", +"< c #7C7B92", +"[ c #BDBCE9", +"} c #9E9DCD", +"| c #9897B3", +"1 c #BBBAFF", +"2 c #F1F1FF", +"3 c #353542", +"4 c #E7E5FF", +"5 c #646489", +"6 c #232332", +"7 c #FBFBFF", +"8 c #EAEAFF", +"9 c #DBDBFF", +"0 c #D5D3FF", +"a c #CDCDFF", +"b c #C8C6FF", +"c c #C1C1FF", +"d c #9F9DDB", +"e c #2F2F3B", +"f c #7A7A96", +"g c #D2D0FF", +"h c #5A5981", +"i c #20202F", +"j c #C8C8FF", +"k c #C0BFFF", +"l c #5C5C82", +"m c #B8B8FF", +"n c #56557D", +"o c #9493D6", +"p c #1D1D2C", +" .. .. ", +" .+..@. ", +" #.$$%&.# ", +" #.$*=-.; ", +" .>,')!~{ ", +" #.]^/(_$_.. ", +" #.:<[}.$. ", +" .|(}1.2. . ", +" #.3_...4...56 ", +" #.~728'90abcd.", +" .ef...g...hi ", +" . .j. .. ", +" . .k. . ", +" .lmn.. ", +" iop. ", +" . "}; diff --git a/pcbnew/bitmaps/Move_Pad.xpm b/pcbnew/bitmaps/Move_Pad.xpm new file mode 100644 index 0000000000..0803bc212a --- /dev/null +++ b/pcbnew/bitmaps/Move_Pad.xpm @@ -0,0 +1,63 @@ +/* XPM */ +static char * move_pad_xpm[] = { +"16 16 44 1", +" c None", +". c #000000", +"+ c #000200", +"@ c #003B00", +"# c #006400", +"$ c #007700", +"% c #005F00", +"& c #007D00", +"* c #007600", +"= c #006100", +"- c #006500", +"; c #000B00", +"> c #005200", +", c #30343B", +"' c #DCDCEF", +") c #30303C", +"! c #84849B", +"~ c #FFFFFF", +"{ c #005300", +"] c #F1F1FF", +"^ c #E7E5FF", +"/ c #646489", +"( c #232332", +"_ c #FBFBFF", +": c #EAEAFF", +"< c #E2E1FF", +"[ c #DBDBFF", +"} c #D5D3FF", +"| c #CDCDFF", +"1 c #C8C6FF", +"2 c #C1C1FF", +"3 c #9F9DDB", +"4 c #2F2F3B", +"5 c #7A7A96", +"6 c #D2D0FF", +"7 c #5A5981", +"8 c #20202F", +"9 c #C8C8FF", +"0 c #C0BFFF", +"a c #5C5C82", +"b c #B8B8FF", +"c c #56557D", +"d c #9493D6", +"e c #1D1D2C", +" ..... ", +" +@#$#@+ ", +" +%&&&&&%+ ", +".@&&*=*&-;. ", +".#&* >,'). ", +".$&= .!~!.. ", +".#&* %.~.. ", +".@&&{.%&.]. . ", +" +%-,!...^.../( ", +" +;'_]:<[}|123.", +" .45...6...78 ", +" .. .9. .. ", +" . .0. . ", +" .abc.. ", +" 8de. ", +" . "}; diff --git a/pcbnew/bitmaps/Move_Pin.xpm b/pcbnew/bitmaps/Move_Pin.xpm new file mode 100644 index 0000000000..641e958433 --- /dev/null +++ b/pcbnew/bitmaps/Move_Pin.xpm @@ -0,0 +1,75 @@ +/* XPM */ +static char * Move_Pin_xpm[] = { +"16 16 56 1", +" c None", +". c #D72E2E", +"+ c #DE676B", +"@ c #DA636B", +"# c #D62E2E", +"$ c #E5E5FF", +"% c #D7D7FF", +"& c #D25B6B", +"* c #D23535", +"= c #CACAFF", +"- c #CE576B", +"; c #D03939", +"> c #B96464", +", c #965151", +"' c #241313", +") c #8D4C4C", +"! c #9B9B9B", +"~ c #C35151", +"{ c #B17171", +"] c #535353", +"^ c #32323E", +"/ c #DCDCEF", +"( c #484848", +"_ c #B36E6E", +": c #CA4444", +"< c #9C9898", +"[ c #000000", +"} c #84849B", +"| c #FFFFFF", +"1 c #1B1B1B", +"2 c #F1F1FF", +"3 c #31313D", +"4 c #E7E5FF", +"5 c #646489", +"6 c #232332", +"7 c #FBFBFF", +"8 c #EAEAFF", +"9 c #E2E1FF", +"0 c #DBDBFF", +"a c #D5D3FF", +"b c #CDCDFF", +"c c #C8C6FF", +"d c #C1C1FF", +"e c #9F9DDB", +"f c #30303B", +"g c #7A7A96", +"h c #D2D0FF", +"i c #5A5981", +"j c #20202F", +"k c #C8C8FF", +"l c #C0BFFF", +"m c #5C5C82", +"n c #B8B8FF", +"o c #56557D", +"p c #9493D6", +"q c #1D1D2C", +" .. ", +" .+@. ", +"#+$%&......... ", +"*@%=-;>>,')>>>! ", +"~.&-.{!]^/^(!!! ", +" _::{< [}|}[[ ", +" !!!1 [|[ ", +" [ [2[ [ ", +" 3}[[[4[[[56 ", +" [/72890abcde[", +" fg[[[h[[[ij ", +" [ [k[ [[ ", +" [ [l[ [ ", +" [mno[[ ", +" jpq[ ", +" [ "}; diff --git a/pcbnew/bitmaps/Net_HighLight.xpm b/pcbnew/bitmaps/Net_HighLight.xpm new file mode 100644 index 0000000000..5fea9e14b2 --- /dev/null +++ b/pcbnew/bitmaps/Net_HighLight.xpm @@ -0,0 +1,93 @@ +/* XPM */ +static char * Net_HighLight_xpm[] = { +"16 16 74 1", +" c None", +". c #46FF00", +"+ c #9B0000", +"@ c #1F4412", +"# c #1F4310", +"$ c #FF0000", +"% c #441212", +"& c #F2D7C1", +"* c #F2BD8E", +"= c #440C07", +"- c #440F0D", +"; c #F2B279", +"> c #492D15", +", c #3B0700", +"' c #1F3A04", +") c #212320", +"! c #404040", +"~ c #A00000", +"{ c #2A3A24", +"] c #FEFEFE", +"^ c #939393", +"/ c #0E0E0E", +"( c #1E3715", +"_ c #FFFFFF", +": c #CECEDD", +"< c #383841", +"[ c #123705", +"} c #F7F7FF", +"| c #E6E6FF", +"1 c #D5D5FE", +"2 c #54546D", +"3 c #000000", +"4 c #8B0000", +"5 c #114000", +"6 c #F6F6F6", +"7 c #EFEFFE", +"8 c #CCCCE9", +"9 c #2D2D39", +"0 c #154E00", +"a c #D6D6DB", +"b c #4C4C53", +"c c #9D9DBA", +"d c #4A4A5F", +"e c #000100", +"f c #987D74", +"g c #A0847A", +"h c #195D00", +"i c #1D211F", +"j c #002600", +"k c #373844", +"l c #B5B5F2", +"m c #181E23", +"n c #858874", +"o c #D6853E", +"p c #919782", +"q c #299A00", +"r c #003700", +"s c #004700", +"t c #001400", +"u c #9494CD", +"v c #8282C6", +"w c #2C2D28", +"x c #D68C4A", +"y c #D69D6A", +"z c #919A88", +"A c #3BD800", +"B c #37374F", +"C c #494974", +"D c #0A0A0C", +"E c #937C77", +"F c #A08A86", +"G c #44FA00", +"H c #8C0000", +"I c #980000", +" .. ++ ", +" .. ++ ", +" @# ++ ", +"$$%&*=$$$$$$$$$$", +"$$-;>,$$$$$$$$$$", +" ')! ~~ ", +" .{]^/ ++ ", +" .(__:< ++ ", +" .[_}|1234+ ", +" .567893 ++ ", +" .0abcde fg ", +" .hijklmnoop ", +" .qrstuvwxyz ", +" .A BCDEF ", +" .G 33 H+ ", +" .. I+ "}; diff --git a/pcbnew/bitmaps/Net_Locked.xpm b/pcbnew/bitmaps/Net_Locked.xpm new file mode 100644 index 0000000000..c7e082cae9 --- /dev/null +++ b/pcbnew/bitmaps/Net_Locked.xpm @@ -0,0 +1,109 @@ +/* XPM */ +static char * Net_Locked_xpm[] = { +"16 16 90 1", +" c None", +". c #007D00", +"+ c #007000", +"@ c #333533", +"# c #A4A3A3", +"$ c #33322D", +"% c #004B00", +"& c #FFE3CB", +"* c #A48060", +"= c #332D24", +"- c #A47952", +"; c #33210F", +"> c #004800", +", c #003B00", +"' c #000000", +") c #007600", +"! c #114611", +"~ c #777877", +"{ c #D0D0D0", +"] c #D9D9D9", +"^ c #B9B9B9", +"/ c #6A6A6A", +"( c #040404", +"_ c #094909", +": c #818381", +"< c #B6B6B6", +"[ c #343434", +"} c #1B1B1B", +"| c #4B4B4B", +"1 c #AFAFAF", +"2 c #7E7E7E", +"3 c #293329", +"4 c #BEBFBE", +"5 c #070707", +"6 c #2D2D2D", +"7 c #A8A8A8", +"8 c #2A2C2A", +"9 c #BCBDBC", +"0 c #151515", +"a c #BFBEBE", +"b c #12100D", +"c c #999592", +"d c #1F1C1B", +"e c #0A0A06", +"f c #030201", +"g c #040302", +"h c #2E2820", +"i c #A6A19C", +"j c #19120A", +"k c #A38F75", +"l c #DEC29E", +"m c #DDC2A1", +"n c #D8BC98", +"o c #D4B892", +"p c #CBA475", +"q c #7F592A", +"r c #E0C39F", +"s c #D6B38A", +"t c #C89D67", +"u c #AA8557", +"v c #A58051", +"w c #A58052", +"x c #A17A4A", +"y c #BA8648", +"z c #AA702D", +"A c #E1C4A0", +"B c #D3AC7D", +"C c #AE8B5E", +"D c #D3B082", +"E c #CDA97B", +"F c #CDAA7A", +"G c #C9A270", +"H c #BA8545", +"I c #A86E2A", +"J c #DFC29E", +"K c #CEA473", +"L c #C59963", +"M c #A88254", +"N c #A27D4D", +"O c #9E7643", +"P c #B88241", +"Q c #DFC09A", +"R c #CCA26F", +"S c #AB8B63", +"T c #D0B087", +"U c #CBAA81", +"V c #CCAB81", +"W c #CAA57A", +"X c #B67F3D", +"Y c #AB7231", +" ", +".....+@#$+......", +".....%#&*%......", +" =-; ", +" +> ", +" ..,'''' ", +" )!~{]]^/( ", +" _:<[}}|12 ", +".....345 67' ", +".....89' 0a' ", +" 'bcdeffghij ", +" 'klmmnnnopq'", +" 'rstuvvwxyz'", +" 'ABCDEEFGHI'", +" 'JKLMNNNOPz'", +" 'QRSTUUVWXY'"}; diff --git a/pcbnew/bitmaps/Net_UnLocked.xpm b/pcbnew/bitmaps/Net_UnLocked.xpm new file mode 100644 index 0000000000..b494293de6 --- /dev/null +++ b/pcbnew/bitmaps/Net_UnLocked.xpm @@ -0,0 +1,109 @@ +/* XPM */ +static char * Net_UnLocked_xpm[] = { +"16 16 90 1", +" c None", +". c #007D00", +"+ c #007000", +"@ c #333533", +"# c #A4A3A3", +"$ c #33322D", +"% c #004B00", +"& c #FFE3CB", +"* c #A48060", +"= c #332D24", +"- c #A47952", +"; c #33210F", +"> c #004800", +", c #000000", +"' c #006100", +") c #006300", +"! c #111111", +"~ c #777777", +"{ c #D0D0D0", +"] c #D9D9D9", +"^ c #6A716A", +"/ c #044004", +"( c #003900", +"_ c #818181", +": c #B6B6B6", +"< c #353535", +"[ c #1C1C1C", +"} c #AFAFAF", +"| c #7E837E", +"1 c #000100", +"2 c #293329", +"3 c #BEBFBE", +"4 c #071807", +"5 c #2D2F2D", +"6 c #A8A9A8", +"7 c #2A2C2A", +"8 c #BCBEBC", +"9 c #001200", +"0 c #151815", +"a c #BFBEBE", +"b c #12100D", +"c c #999592", +"d c #1F1C1B", +"e c #0A0A06", +"f c #030201", +"g c #040302", +"h c #0C0B08", +"i c #272523", +"j c #19120A", +"k c #A38F75", +"l c #DEC29E", +"m c #DDC2A1", +"n c #D8BC98", +"o c #D4B892", +"p c #CBA475", +"q c #7F592A", +"r c #E0C39F", +"s c #D6B38A", +"t c #C89D67", +"u c #AA8557", +"v c #A58051", +"w c #A58052", +"x c #A17A4A", +"y c #BA8648", +"z c #AA702D", +"A c #E1C4A0", +"B c #D3AC7D", +"C c #AE8B5E", +"D c #D3B082", +"E c #CDA97B", +"F c #CDAA7A", +"G c #C9A270", +"H c #BA8545", +"I c #A86E2A", +"J c #DFC29E", +"K c #CEA473", +"L c #C59963", +"M c #A88254", +"N c #A27D4D", +"O c #9E7643", +"P c #B88241", +"Q c #DFC09A", +"R c #CCA26F", +"S c #AB8B63", +"T c #D0B087", +"U c #CBAA81", +"V c #CCAB81", +"W c #CAA57A", +"X c #B67F3D", +"Y c #AB7231", +" ", +".....+@#$+......", +".....%#&*%......", +" =-; ", +" +> ", +" ,,'.) ", +" !~{]^/( ", +" _:<[}|1 ", +"234..56, ", +"789..0a, ", +" ,bcdeffghij ", +" ,klmmnnnopq,", +" ,rstuvvwxyz,", +" ,ABCDEEFGHI,", +" ,JKLMNNNOPz,", +" ,QRSTUUVWXY,"}; diff --git a/pcbnew/bitmaps/New_FootPrint.xpm b/pcbnew/bitmaps/New_FootPrint.xpm new file mode 100644 index 0000000000..6d832a3945 --- /dev/null +++ b/pcbnew/bitmaps/New_FootPrint.xpm @@ -0,0 +1,35 @@ +/* XPM */ +static char * new_footprint_xpm[] = { +"16 16 15 1", +" c None", +". c #FFF500", +"+ c #787300", +"@ c #000000", +"# c #625E00", +"$ c #EFE600", +"% c #F6ED00", +"& c #2F2D00", +"* c #D72E2E", +"= c #581212", +"- c #716C00", +"; c #FAE503", +"> c #925011", +", c #F5E402", +"' c #821B1B", +" . ", +" . .+. ", +" @@@ #$.% ", +" @ @@...&... ", +"**= -%.;> ", +"**= . .>, ", +" @ . ", +"**= ='* ", +"**= =** ", +" @ @ ", +"**= =** ", +"**= =** ", +" @ @ ", +" @ @ ", +" @@@@@@@@ ", +" "}; + diff --git a/pcbnew/bitmaps/New_Module.xpm b/pcbnew/bitmaps/New_Module.xpm new file mode 100644 index 0000000000..d6a6125d58 --- /dev/null +++ b/pcbnew/bitmaps/New_Module.xpm @@ -0,0 +1,92 @@ +/* XPM */ +static char * New_Module_xpm[] = { +"16 16 73 1", +" c None", +". c #FFF500", +"+ c #787300", +"@ c #000000", +"# c #474400", +"$ c #EBE100", +"% c #F6ED00", +"& c #F3F3F3", +"* c #1B1B1B", +"= c #242300", +"- c #D72E2E", +"; c #FFFFFF", +"> c #E0E0E0", +", c #C8C8C8", +"' c #C3C3C8", +") c #A09D64", +"! c #F6ED0C", +"~ c #FAE503", +"{ c #925011", +"] c #FDFDFF", +"^ c #F7F7FF", +"/ c #F1F0E1", +"( c #FDF414", +"_ c #D8D4A9", +": c #F5E402", +"< c #393700", +"[ c #FCFCFF", +"} c #F6F6FF", +"| c #EFEFFF", +"1 c #E8E8FF", +"2 c #DBD9D6", +"3 c #8B8BA3", +"4 c #F5F4FF", +"5 c #EEEEFF", +"6 c #E7E7FF", +"7 c #E1E0FF", +"8 c #DAD9FF", +"9 c #C9C8F3", +"0 c #821B1B", +"a c #EDECFF", +"b c #E6E6FF", +"c c #E0DFFF", +"d c #D9D8FF", +"e c #D2D1FF", +"f c #CCCAFF", +"g c #E5E5FF", +"h c #DFDEFF", +"i c #D8D7FF", +"j c #D1D0FF", +"k c #CBC9FF", +"l c #C4C3FF", +"m c #DDDDFF", +"n c #D7D6FF", +"o c #D0CFFF", +"p c #CAC8FF", +"q c #C3C2FF", +"r c #BCBBFF", +"s c #D6D5FF", +"t c #CFCEFF", +"u c #C8C7FF", +"v c #C2C0FF", +"w c #BBBAFF", +"x c #B5B3FF", +"y c #CECDFF", +"z c #C7C6FF", +"A c #C1BFFF", +"B c #BAB8FF", +"C c #B4B2FF", +"D c #AFADFF", +"E c #C6C5FF", +"F c #C0BEFF", +"G c #B9B7FF", +"H c #B2B1FF", +" . ", +" . .+. ", +" @@@ #$.% ", +" @&*@...=... ", +"--@;>,')!.~{ ", +"--@;]^/(_.{:< ", +" @[}|123.@<@ ", +"--@456789@0- ", +"--@abcdef@-- ", +" @ghijkl@ ", +"--@mnopqr@-- ", +"--@stuvwx@-- ", +" @yzABCD@ ", +" @EFGHDD@ ", +" @@@@@@@@ ", +" "}; diff --git a/pcbnew/bitmaps/Options_All_Tracks&Vias.xpm b/pcbnew/bitmaps/Options_All_Tracks&Vias.xpm new file mode 100644 index 0000000000..72ef0d74ef --- /dev/null +++ b/pcbnew/bitmaps/Options_All_Tracks&Vias.xpm @@ -0,0 +1,68 @@ +/* XPM */ +static char * options_all_tracks_and_vias_xpm[] = { +"16 16 49 1", +" c None", +". c #007D00", +"+ c #D62D2D", +"@ c #BC2828", +"# c #D02C2C", +"$ c #B82727", +"% c #004000", +"& c #D72E2E", +"* c #007700", +"= c #8A1D1D", +"- c #C52A2A", +"; c #CA2B2B", +"> c #005800", +", c #007C00", +"' c #004900", +") c #006900", +"! c #000000", +"~ c #F0F0F0", +"{ c #DEDEDE", +"] c #DFDFDF", +"^ c #010000", +"/ c #BFBFBF", +"( c #C0C0C0", +"_ c #C42929", +": c #BB2828", +"< c #979797", +"[ c #989898", +"} c #E3E3E3", +"| c #DDDDDD", +"1 c #C8C8C8", +"2 c #656565", +"3 c #838383", +"4 c #878787", +"5 c #888888", +"6 c #AFAFAF", +"7 c #A3A3A3", +"8 c #F1F1F1", +"9 c #CECECE", +"0 c #ABABAB", +"a c #EEEEEE", +"b c #EDEDED", +"c c #E9E9E9", +"d c #D9D9D9", +"e c #881D1D", +"f c #C1C1C1", +"g c #B5B5B5", +"h c #757575", +"i c #6B6B6B", +"j c #777777", +".......... +@ ", +"........... #$ ", +" %.. +#&", +" *. =-;", +"....... >.. ", +"........ ,. ", +" '.. ).....", +" !!!!!!!!!!!!", +" !~{]]]]]]]]]]", +"&& ^]//////(((((", +"_:+^]/ c #BFBFBF", +", c #C0C0C0", +"' c #006D00", +") c #979797", +"! c #989898", +"~ c #004500", +"{ c #E3E3E3", +"] c #DDDDDD", +"^ c #C8C8C8", +"/ c #656565", +"( c #838383", +"_ c #878787", +": c #888888", +"< c #AFAFAF", +"[ c #A3A3A3", +"} c #F1F1F1", +"| c #CECECE", +"1 c #ABABAB", +"2 c #EEEEEE", +"3 c #EDEDED", +"4 c #E9E9E9", +"5 c #D9D9D9", +"6 c #C1C1C1", +"7 c #B5B5B5", +"8 c #757575", +"9 c #6B6B6B", +"0 c #777777", +".......... ", +"........... ", +" +.. ", +" @. ", +"....... #.. ", +"........ $. ", +" %.. &.....", +" ************", +"...*=-;;;;;;;;;;", +"...*;>>>>>>,,,,,", +" '*;>)***!,,,,,", +" ~*;>*{]^*/(_:<", +" *;>*],[*****}", +" *;>*|[)*12345", +" *;,!***/(6666", +" *;,789/0:***!"}; diff --git a/pcbnew/bitmaps/Options_All_Vias.xpm b/pcbnew/bitmaps/Options_All_Vias.xpm new file mode 100644 index 0000000000..6de5137c2b --- /dev/null +++ b/pcbnew/bitmaps/Options_All_Vias.xpm @@ -0,0 +1,75 @@ +/* XPM */ +static char * Options_All_Vias_xpm[] = { +"16 16 56 1", +" c None", +". c #D72E2E", +"+ c #D62D2D", +"@ c #C42929", +"# c #BB2828", +"$ c #BC2828", +"% c #C52A2A", +"& c #D32D2D", +"* c #B22626", +"= c #CF2C2C", +"- c #D22D2D", +"; c #D02C2C", +"> c #B82727", +", c #C32929", +"' c #541212", +") c #831C1C", +"! c #7A1A1A", +"~ c #8A1D1D", +"{ c #CA2B2B", +"] c #881D1D", +"^ c #CD2C2C", +"/ c #CE2C2C", +"( c #A82424", +"_ c #010000", +": c #000000", +"< c #F0F0F0", +"[ c #DEDEDE", +"} c #DFDFDF", +"| c #BFBFBF", +"1 c #C0C0C0", +"2 c #979797", +"3 c #989898", +"4 c #E3E3E3", +"5 c #DDDDDD", +"6 c #C8C8C8", +"7 c #656565", +"8 c #838383", +"9 c #878787", +"0 c #888888", +"a c #AFAFAF", +"b c #E0DFDF", +"c c #C0BFBF", +"d c #A3A3A3", +"e c #F1F1F1", +"f c #CECECE", +"g c #ABABAB", +"h c #EEEEEE", +"i c #EDEDED", +"j c #E9E9E9", +"k c #D9D9D9", +"l c #C1C0C0", +"m c #C1C1C1", +"n c #B5B5B5", +"o c #757575", +"p c #6B6B6B", +"q c #777777", +" .. ", +" +@#+ ", +" ... +$ #% ", +" +&*=- ;> ;, ", +" .' . +;.+) ", +" . .! ~%{] ", +" ^;../ ", +" (;_:::::::::::", +" :<[}}}}}}}}}}", +" :}||||||11111", +" :}|2:::311111", +" :}|:456:7890a", +" ._bc:51d:::::e", +" +@_bc:fd2:ghijk", +"+$ :bl3:::78mmmm", +";> :blnop7q0:::3"}; diff --git a/pcbnew/bitmaps/Options_Module.xpm b/pcbnew/bitmaps/Options_Module.xpm new file mode 100644 index 0000000000..e435fd9c39 --- /dev/null +++ b/pcbnew/bitmaps/Options_Module.xpm @@ -0,0 +1,72 @@ +/* XPM */ +static char * Options_Module_xpm[] = { +"16 16 53 1", +" c None", +". c #000000", +"+ c #C0C0C0", +"@ c #B8B8C0", +"# c #D72E2E", +"$ c #FFFFFF", +"% c #F5F4FF", +"& c #EBEAFF", +"* c #F5F5FF", +"= c #EBEBFF", +"- c #E1E1FF", +"; c #F6F5FF", +"> c #ECEBFF", +", c #E2E1FF", +"' c #D8D7FF", +") c #ECECFF", +"! c #E2E2FF", +"~ c #CECDFF", +"{ c #E3E2FF", +"] c #D9D8FF", +"^ c #CFCEFF", +"/ c #C5C4FF", +"( c #010101", +"_ c #D0CFFF", +": c #F1F1F1", +"< c #DFDFDF", +"[ c #E0DFDF", +"} c #C6C5FF", +"| c #E0E0E0", +"1 c #BFBFBF", +"2 c #C0BFBF", +"3 c #979797", +"4 c #989898", +"5 c #E3E3E3", +"6 c #DDDDDD", +"7 c #C8C8C8", +"8 c #656565", +"9 c #838383", +"0 c #878787", +"a c #888888", +"b c #AFAFAF", +"c c #A3A3A3", +"d c #CECECE", +"e c #ABABAB", +"f c #EEEEEE", +"g c #EDEDED", +"h c #E9E9E9", +"i c #D9D9D9", +"j c #C1C1C1", +"k c #B5B5B5", +"l c #757575", +"m c #6B6B6B", +"n c #777777", +" .. .. ", +" .+..@. ", +"#.$$%&.# ", +"#.$*=-.# ", +" .;>,'. ", +"#.)!'~.# ", +"#.{]^/.# ", +" .]^((..........", +"#._(:<<[<<<<<<<<", +"#.}(|+12111+++++", +" ...<13...4+++++", +" .<1.567.890ab", +" .<1.6+c.....:", +" .<1.dc3.efghi", +" .<+4...89jjjj", +" .<+klm8na...4"}; diff --git a/pcbnew/bitmaps/Options_Track.xpm b/pcbnew/bitmaps/Options_Track.xpm new file mode 100644 index 0000000000..5723c9fcec --- /dev/null +++ b/pcbnew/bitmaps/Options_Track.xpm @@ -0,0 +1,64 @@ +/* XPM */ +static char * Options_Track_xpm[] = { +"16 16 45 1", +" c None", +". c #007D00", +"+ c #006100", +"@ c #004400", +"# c #007800", +"$ c #007B00", +"% c #004000", +"& c #007C00", +"* c #006500", +"= c #D72E2E", +"- c #007A00", +"; c #004600", +"> c #010000", +", c #000000", +"' c #F1F0F0", +") c #DFDEDE", +"! c #E0DFDF", +"~ c #DFDFDF", +"{ c #C0BFBF", +"] c #BFBFBF", +"^ c #C0C0C0", +"/ c #989797", +"( c #989898", +"_ c #E3E3E3", +": c #DDDDDD", +"< c #C8C8C8", +"[ c #656565", +"} c #838383", +"| c #878787", +"1 c #888888", +"2 c #AFAFAF", +"3 c #A3A3A3", +"4 c #F1F1F1", +"5 c #CECECE", +"6 c #979797", +"7 c #ABABAB", +"8 c #EEEEEE", +"9 c #EDEDED", +"0 c #E9E9E9", +"a c #D9D9D9", +"b c #C1C1C1", +"c c #B5B5B5", +"d c #757575", +"e c #6B6B6B", +"f c #777777", +"........ ", +"........+ ", +" @.# ", +" $.% ", +" &.* ", +" === .- ", +" ===== $.; ", +"=== >>>,,,,,,,,,", +"== ,')!~~~~~~~~~", +"===>!{{]]]]^^^^^", +" ==>!{/,,,(^^^^^", +" =>!{,_:<,[}|12", +" ,~],:^3,,,,,4", +" ,~],536,7890a", +" ,~^(,,,[}bbbb", +" ,~^cde[f1,,,("}; diff --git a/pcbnew/bitmaps/Options_Tracks.xpm b/pcbnew/bitmaps/Options_Tracks.xpm new file mode 100644 index 0000000000..ed96a19660 --- /dev/null +++ b/pcbnew/bitmaps/Options_Tracks.xpm @@ -0,0 +1,55 @@ +/* XPM */ +static char * Options_Tracks_xpm[] = { +"16 16 36 1", +" c None", +". c #007D00", +"+ c #004000", +"@ c #007700", +"# c #005800", +"$ c #007C00", +"% c #006900", +"& c #000000", +"* c #F0F0F0", +"= c #DEDEDE", +"- c #DFDFDF", +"; c #BFBFBF", +"> c #C0C0C0", +", c #979797", +"' c #989898", +") c #E3E3E3", +"! c #DDDDDD", +"~ c #C8C8C8", +"{ c #656565", +"] c #838383", +"^ c #878787", +"/ c #888888", +"( c #AFAFAF", +"_ c #A3A3A3", +": c #F1F1F1", +"< c #CECECE", +"[ c #ABABAB", +"} c #EEEEEE", +"| c #EDEDED", +"1 c #E9E9E9", +"2 c #D9D9D9", +"3 c #C1C1C1", +"4 c #B5B5B5", +"5 c #757575", +"6 c #6B6B6B", +"7 c #777777", +".......... ", +"........... ", +" +.. ", +" @. ", +" #.. ", +" $. ", +" %.....", +" &&&&&&&&&&&&", +" &*=----------", +" &-;;;;;;>>>>>", +" &-;,&&&'>>>>>", +" &-;&)!~&{]^/(", +" &-;&!>_&&&&&:", +" &-;&<_,&[}|12", +" &->'&&&{]3333", +" &->456{7/&&&'"}; diff --git a/pcbnew/bitmaps/Options_Vias.xpm b/pcbnew/bitmaps/Options_Vias.xpm new file mode 100644 index 0000000000..270a002dd7 --- /dev/null +++ b/pcbnew/bitmaps/Options_Vias.xpm @@ -0,0 +1,63 @@ +/* XPM */ +static char * Options_Vias_xpm[] = { +"16 16 44 1", +" c None", +". c #000000", +"+ c #030101", +"@ c #661616", +"# c #AD2525", +"$ c #CD2C2C", +"% c #A32323", +"& c #D72E2E", +"* c #CD2B2B", +"= c #A82424", +"- c #CE2B2B", +"; c #BD2929", +"> c #010000", +", c #F1F0F0", +"' c #DFDEDE", +") c #E0DFDF", +"! c #DFDFDF", +"~ c #C0BFBF", +"{ c #BFBFBF", +"] c #C0C0C0", +"^ c #979797", +"/ c #989898", +"( c #E3E3E3", +"_ c #DDDDDD", +": c #C8C8C8", +"< c #656565", +"[ c #838383", +"} c #878787", +"| c #888888", +"1 c #A3A3A3", +"2 c #CECECE", +"3 c #ABABAB", +"4 c #EEEEEE", +"5 c #EDEDED", +"6 c #E9E9E9", +"7 c #C1C1C1", +"8 c #B5B5B5", +"9 c #757575", +"0 c #6B6B6B", +"a c #777777", +"b c #A7A7A7", +"c c #7B7B7B", +"d c #747474", +"e c #717171", +" ..... ", +" +@#$#@+ ", +" +%&&&&&%+ ", +".@&&*=*&&@. ", +".#&* -&#. ", +".$&= ;&$. ", +".#&* .>>>>......", +".@&&>,'))!!!!!!!", +" +%&>)~~~{{{]]]]", +" +@>)~^.../]]]]", +" ..!{.(_:.<[}|", +" .!{._]1.....", +" .!{.21^.3456", +" .!]/...<[777", +" .!]890 c #EBEBEB", +", c #B5B5B5", +"' c #BEBEBE", +") c #424242", +"! c #454545", +"~ c #C9C9C9", +"{ c #A5A5A5", +"] c #B8B8B8", +"^ c #282828", +"/ c #050505", +"( c #6E6E6E", +"_ c #DFDFDF", +": c #D3D3D3", +"< c #B1B1B1", +"[ c #838383", +"} c #BABABA", +"| c #2E2E30", +"1 c #181818", +"2 c #989898", +"3 c #DCDCDC", +"4 c #CDCDCD", +"5 c #AFAFAF", +"6 c #F4F4FF", +"7 c #E9E9FE", +"8 c #8E8EA2", +"9 c #1A1A1F", +"0 c #373737", +"a c #919191", +"b c #313131", +"c c #B3B3B3", +"d c #EAEAFF", +"e c #E0DFFF", +"f c #D6D5FF", +"g c #C6C4F8", +"h c #6A698B", +"i c #020203", +"j c #A4A3B4", +"k c #242424", +"l c #575757", +"m c #E0E0FF", +"n c #CCCBFF", +"o c #BDBBF8", +"p c #64638B", +"q c #A8A7B8", +"r c #9494B4", +"s c #CBCAFE", +"t c #7B7AA2", +"u c #16161F", +"v c #9594BA", +"w c #252430", +"........... ", +".+@#$%&*=-;. ", +".+>>>>>>>,'). ", +".+!~>>>>>,{]^. ", +".+./(_>>>:<<[. ", +"...}|12>>3445. ", +".@.67890abbc5. ", +".@.defghi]jkl. ", +".@.mfnopiqrkl. ", +".#.fstu0abbc5. ", +"...vw12>>>>>5. ", +".#./(_>>>>>>5. ", +".#!~>>>>>>>>5. ", +".#>>>>>>>>>>5. ", +".555555555555. ", +".............. "}; diff --git a/pcbnew/bitmaps/Post_Drill.xpm b/pcbnew/bitmaps/Post_Drill.xpm new file mode 100644 index 0000000000..5254fea14e --- /dev/null +++ b/pcbnew/bitmaps/Post_Drill.xpm @@ -0,0 +1,54 @@ +/* XPM */ +static char * post_drill_xpm[] = { +"16 16 35 1", +" c None", +". c #000000", +"+ c #FFFFFF", +"@ c #FEFEFE", +"# c #FDFDFD", +"$ c #FCFCFC", +"% c #FBFBFB", +"& c #696969", +"* c #F9F9F9", +"= c #F8F8F8", +"- c #7C7C7C", +"; c #232323", +"> c #EBEBEB", +", c #9E9E9E", +"' c #B5B5B5", +") c #BEBEBE", +"! c #424242", +"~ c #A5A5A5", +"{ c #B8B8B8", +"] c #282828", +"^ c #A6A6A6", +"/ c #303030", +"( c #0B0B0B", +"_ c #D3D3D3", +": c #B1B1B1", +"< c #838383", +"[ c #1A1A1A", +"} c #8C8C8C", +"| c #9C9C9C", +"1 c #CDCDCD", +"2 c #AFAFAF", +"3 c #AAAAAA", +"4 c #5E5E5E", +"5 c #7A7A7A", +"6 c #101010", +"........... ", +".+@#$%&*=-;. ", +".+>>>>&,>')!. ", +".+>>>>>,>'~{]. ", +".+>>^/(/^_::<. ", +".@>^[}_}[|112. ", +".@>/}>&>}/>>2. ", +"&&>(_&&&_(>&&. ", +".3,/}>&,4/>>56 ", +".#>^[}_4[^>>2. ", +".#>>^/(/^>>>2. ", +".#>>>>>>>>>>2. ", +".#>>>>&>>>>>2. ", +".#>>>>&,>>>>2. ", +".222222522222. ", +".............. "}; diff --git a/pcbnew/bitmaps/Post_Module.xpm b/pcbnew/bitmaps/Post_Module.xpm new file mode 100644 index 0000000000..fe3ec5774d --- /dev/null +++ b/pcbnew/bitmaps/Post_Module.xpm @@ -0,0 +1,71 @@ +/* XPM */ +static char * Post_Module_xpm[] = { +"16 16 52 1", +" c None", +". c #000000", +"+ c #FFFFFF", +"@ c #FEFEFE", +"# c #FDFDFD", +"$ c #FCFCFC", +"% c #FBFBFB", +"& c #FAFAFA", +"* c #F9F9F9", +"= c #F8F8F8", +"- c #7C7C7C", +"; c #232323", +"> c #EBEBEB", +", c #B5B5B5", +"' c #BEBEBE", +") c #424242", +"! c #B0B0B0", +"~ c #A5A5A5", +"{ c #B8B8B8", +"] c #282828", +"^ c #C0C0C0", +"/ c #B8B8C0", +"( c #D3D3D3", +"_ c #B1B1B1", +": c #838383", +"< c #FF7800", +"[ c #F5F4FF", +"} c #EBEAFF", +"| c #CDCDCD", +"1 c #AFAFAF", +"2 c #F5F5FF", +"3 c #EBEBFF", +"4 c #E1E1FF", +"5 c #F6F5FF", +"6 c #ECEBFF", +"7 c #E2E1FF", +"8 c #D8D7FF", +"9 c #ECECFF", +"0 c #E2E2FF", +"a c #CECDFF", +"b c #E3E2FF", +"c c #D9D8FF", +"d c #CFCEFF", +"e c #C5C4FF", +"f c #BBBAFF", +"g c #D0CFFF", +"h c #C6C5FF", +"i c #BCBAFF", +"j c #B2B0FF", +"k c #BCBBFF", +"l c #B3B1FF", +"m c #AFADFF", +"........... ", +".+@#$%&*=-;. ", +".+>>>>>>>,'). ", +".+>..!!..,~{]. ", +".+>.^../.(__:. ", +".@<.++[}.<||1. ", +".@<.+234.<>>1. ", +".@>.5678.>>>1. ", +".@<.908a.<>>1. ", +".#<.bcde.<>>1. ", +".#>.cdef.>>>1. ", +".#<.ghij.<>>1. ", +".#<.hklm.<>>1. ", +".#>......>>>1. ", +".111111111111. ", +".............. "}; diff --git a/pcbnew/bitmaps/Repl_Module_Board.xpm b/pcbnew/bitmaps/Repl_Module_Board.xpm new file mode 100644 index 0000000000..ee98f10bd2 --- /dev/null +++ b/pcbnew/bitmaps/Repl_Module_Board.xpm @@ -0,0 +1,100 @@ +/* XPM */ +static char * repl_module_board_xpm[] = { +"16 16 81 1", +" c None", +". c #000000", +"+ c #FEFEFF", +"@ c #F9AB7F", +"# c #F55A00", +"$ c #EFEFF0", +"% c #AFAFB0", +"& c #080808", +"* c #FFFFFF", +"= c #ED5700", +"- c #3B1500", +"; c #7E7E7F", +"> c #070707", +", c #008100", +"' c #009F00", +") c #FBFBFC", +"! c #4E4E4F", +"~ c #001000", +"{ c #535353", +"] c #030303", +"^ c #000700", +"/ c #00B400", +"( c #006F00", +"_ c #5F4130", +": c #005800", +"< c #005E00", +"[ c #000A00", +"} c #002500", +"| c #008700", +"1 c #00B100", +"2 c #002700", +"3 c #AA3E00", +"4 c #003400", +"5 c #00BD00", +"6 c #00B800", +"7 c #008200", +"8 c #001F00", +"9 c #FDFDFE", +"0 c #503628", +"a c #006A00", +"b c #006600", +"c c #010B02", +"d c #000100", +"e c #F5F5FA", +"f c #313133", +"g c #002000", +"h c #4C4C52", +"i c #040404", +"j c #E65400", +"k c #210C00", +"l c #4B4B52", +"m c #050506", +"n c #F9F9FF", +"o c #F5F5FF", +"p c #F1F1FF", +"q c #EEEEFF", +"r c #CFCFE2", +"s c #676773", +"t c #FCFCFF", +"u c #F8F8FF", +"v c #F1A37F", +"w c #ED9F7F", +"x c #DADAF7", +"y c #060606", +"z c #DEDEFF", +"A c #070708", +"B c #FBFBFF", +"C c #F7F7FF", +"D c #F4F4FF", +"E c #F0F0FF", +"F c #ECECFF", +"G c #E9E9FF", +"H c #E99B7F", +"I c #DADAFF", +"J c #F3F3FF", +"K c #E8E8FF", +"L c #E4E4FF", +"M c #E1E1FF", +"N c #DDDDFF", +"O c #D9D9FF", +"P c #D5D5FF", +"............ ", +".+@#@++++$%& ...", +".+#*####=-;>.,'.", +".+@#@++)!~{]^/(.", +".++++++_:<[}|12 ", +".+####34565178. ", +".+++++90abcd.. ", +".+@#@++efghi. ", +".+#*####jklm ", +".+@#@nopqrsm ", +".++tuopv#wxy ", +".+######*#zA ", +".BCDEFGw#HIA ", +".CJEFKLMNOPA ", +"............ ", +" "}; diff --git a/pcbnew/bitmaps/Rotate_Field.xpm b/pcbnew/bitmaps/Rotate_Field.xpm new file mode 100644 index 0000000000..fd675862c7 --- /dev/null +++ b/pcbnew/bitmaps/Rotate_Field.xpm @@ -0,0 +1,95 @@ +/* XPM */ +static char * Rotate_Field_xpm[] = { +"16 16 76 1", +" c None", +". c #D2D2D2", +"+ c #9D9D9D", +"@ c #DEDEDE", +"# c #E0E0E0", +"$ c #5C5C5C", +"% c #000000", +"& c #EDEDED", +"* c #939393", +"= c #FDFDFD", +"- c #E4E4E4", +"; c #F1F1F1", +"> c #CFCFCF", +", c #C7C7C7", +"' c #E7E7E7", +") c #F4F4F4", +"! c #8F8F8F", +"~ c #E9E9E9", +"{ c #B1B1B1", +"] c #373737", +"^ c #67676A", +"/ c #3B3B3B", +"( c #A3A3A3", +"_ c #D1D1D1", +": c #FAFAFA", +"< c #636363", +"[ c #F7F7F8", +"} c #F8F8FF", +"| c #EBEBF9", +"1 c #E0E0F3", +"2 c #BFBFD6", +"3 c #8B8BA0", +"4 c #4F4F57", +"5 c #B6B6B6", +"6 c #F0F0F0", +"7 c #9F9F9F", +"8 c #F1F1FF", +"9 c #EBEBFF", +"0 c #E4E4FF", +"a c #DDDDFF", +"b c #CECEF4", +"c c #393945", +"d c #777777", +"e c #606060", +"f c #3A3A3A", +"g c #69696C", +"h c #353536", +"i c #3B3B3E", +"j c #3F3F45", +"k c #777789", +"l c #D4D4FC", +"m c #8888A7", +"n c #2E2E2E", +"o c #9494B0", +"p c #B8B8E2", +"q c #A1A1CC", +"r c #A0A0C4", +"s c #757594", +"t c #CFCFFE", +"u c #7D7D94", +"v c #383842", +"w c #2F2F34", +"x c #1D1D1F", +"y c #5C5C61", +"z c #434345", +"A c #2B2B37", +"B c #C2C2EE", +"C c #D7D7FF", +"D c #F5F5FC", +"E c #6F6F6F", +"F c #22222A", +"G c #83839B", +"H c #B5B5D1", +"I c #D8D8F2", +"J c #E5E5F9", +"K c #59595E", +".++++++++++++++.", +"+.@@@@@@@@@@@@@+", +"+#$%%$&%%%*&===+", +"+-%;;%;%>,%;===+", +"+'%))%)%%%!)===+", +"+~%%%%{]^/%(_==+", +"+&%::%<[}|12345+", +"+6===7<[}890abcd", +".+++++efghijklmn", +" %%% % %op%", +" %qr% % %%%", +" %stuvwxyz ", +" ABCa098DE ", +" FGHIJ8DE% ", +" %%%Kz% ", +" %% "}; diff --git a/pcbnew/bitmaps/Rotate_Module+.xpm b/pcbnew/bitmaps/Rotate_Module+.xpm new file mode 100644 index 0000000000..6bbdf3e6e5 --- /dev/null +++ b/pcbnew/bitmaps/Rotate_Module+.xpm @@ -0,0 +1,108 @@ +/* XPM */ +static char * rotate_module_pos_xpm[] = { +"16 16 89 1", +" c None", +". c #000000", +"+ c #C0C0C0", +"@ c #B8B8C0", +"# c #D72E2E", +"$ c #FFFFFF", +"% c #F5F4FF", +"& c #EBEAFF", +"* c #CD2C2C", +"= c #F5F5FF", +"- c #EBEBFF", +"; c #C4C4DF", +"> c #B62626", +", c #F6F5FF", +"' c #ECEBFF", +") c #B9B8D1", +"! c #36363A", +"~ c #717172", +"{ c #ECECFF", +"] c #AAAAC0", +"^ c #505052", +"/ c #EEEEEF", +"( c #FBFBFC", +"_ c #EEEEF5", +": c #E4E4F2", +"< c #C9C9DB", +"[ c #9393A5", +"} c #3D3D46", +"| c #E3E2FF", +"1 c #8F8FA9", +"2 c #585859", +"3 c #F3F3F4", +"4 c #FEFEFF", +"5 c #F8F8FF", +"6 c #F1F1FF", +"7 c #E4E4FF", +"8 c #D8D8FA", +"9 c #4A4A58", +"0 c #D9D8FF", +"a c #CFCEFF", +"b c #8180A7", +"c c #323234", +"d c #838384", +"e c #19191A", +"f c #2B2B2D", +"g c #37373C", +"h c #6E6E7B", +"i c #D3D3F4", +"j c #A7A7C7", +"k c #616077", +"l c #5C5B77", +"m c #ADABEB", +"n c #8685C1", +"o c #6D1616", +"p c #7C7C90", +"q c #D1D1F9", +"r c #060608", +"s c #5B5B73", +"t c #4C4C5D", +"u c #686795", +"v c #AFADFF", +"w c #831C1C", +"x c #8989AE", +"y c #C2C2EE", +"z c #1D1D22", +"A c #252527", +"B c #070707", +"C c #595971", +"D c #D0D0FF", +"E c #D3D3FA", +"F c #A7A7C1", +"G c #9C9CAE", +"H c #8F8F9B", +"I c #B6B6C1", +"J c #BEBEC3", +"K c #191919", +"L c #020202", +"M c #71718B", +"N c #D7D7FF", +"O c #DDDDFF", +"P c #B8B8B9", +"Q c #141418", +"R c #44444F", +"S c #63636F", +"T c #6A6A73", +"U c #AAAAB4", +"V c #B1B1B6", +"W c #111111", +"X c #1F1F21", +" .. .. ", +" .+..@. ", +" #.$$%&.* ", +" #.$=-;.> ", +" .,')!~. ", +" #.{]^/(_:<[} ", +" #.|123456-789 ", +" .0abcdefghij.", +" #.klmn.o .pqr", +" #.stuv.w. ...", +" .xyz.. AB ", +" CDEFGHIJK ", +" LMNO7-65P. ", +" .QRSTUVW ", +" XL ", +" . "}; diff --git a/pcbnew/bitmaps/Rotate_Module-.xpm b/pcbnew/bitmaps/Rotate_Module-.xpm new file mode 100644 index 0000000000..2780624aa6 --- /dev/null +++ b/pcbnew/bitmaps/Rotate_Module-.xpm @@ -0,0 +1,96 @@ +/* XPM */ +static char * rotate_module_neg_xpm[] = { +"16 16 77 1", +" c None", +". c #000000", +"+ c #C0C0C0", +"@ c #B8B8C0", +"# c #D72E2E", +"$ c #FFFFFF", +"% c #F5F4FF", +"& c #EBEAFF", +"* c #F5F5FF", +"= c #EBEBFF", +"- c #E1E1FF", +"; c #D22D2D", +"> c #F6F5FF", +", c #ECEBFF", +"' c #E2E1FF", +") c #D8D7FF", +"! c #1E1E1F", +"~ c #EBEBFE", +"{ c #A4A4BA", +"] c #595969", +"^ c #636272", +"/ c #616169", +"( c #6B676D", +"_ c #B9B9BE", +": c #9C9C9D", +"< c #090909", +"[ c #3C3B44", +"} c #86869F", +"| c #DDDDFF", +"1 c #E4E4FF", +"2 c #F1F1FF", +"3 c #F8F8FF", +"4 c #FEFEFF", +"5 c #9F9FA0", +"6 c #71718A", +"7 c #D7D7FF", +"8 c #D3D3F4", +"9 c #ABABBF", +"0 c #A1A1AF", +"a c #96969F", +"b c #C9C9CF", +"c c #B6B6B7", +"d c #131313", +"e c #B02525", +"f c #A6A6CC", +"g c #B7B7D9", +"h c #23232C", +"i c #494869", +"j c #691616", +"k c #2F2F30", +"l c #030303", +"m c #962020", +"n c #67677E", +"o c #3F3F4B", +"p c #7F7EB6", +"q c #A1A0EC", +"r c #7A1919", +"s c #9494B0", +"t c #B8B8E2", +"u c #383838", +"v c #69696C", +"w c #1C1C1D", +"x c #2E2E32", +"y c #393940", +"z c #777789", +"A c #D4D4FC", +"B c #8888A7", +"C c #616161", +"D c #F7F7F8", +"E c #CECEF4", +"F c #353541", +"G c #EBEBF9", +"H c #E0E0F3", +"I c #BFBFD6", +"J c #8B8BA0", +"K c #2D2D36", +"L c #67676A", +" .. .. ", +" .+..@. ", +" #.$$%&.# ", +" #.$*=-.; ", +" .>,'). !. ", +" #.~{]^/(_:< ", +" #.[}|1=2345. ", +" .67890abcd ", +" e.fghi.jkl ", +" m.nopq.r. ...", +" ...... .st.", +" uvwxyzAB.", +" CD32=1|EF ", +" .CD3GHIJK ", +" .uL... ", +" .. "}; diff --git a/pcbnew/bitmaps/Select_Layer_Pair.xpm b/pcbnew/bitmaps/Select_Layer_Pair.xpm new file mode 100644 index 0000000000..b6449f977e --- /dev/null +++ b/pcbnew/bitmaps/Select_Layer_Pair.xpm @@ -0,0 +1,94 @@ +/* XPM */ +static char * select_layer_pair_xpm[] = { +"16 16 75 1", +" c None", +". c #000000", +"+ c #590000", +"@ c #9F0000", +"# c #A50000", +"$ c #AC0000", +"% c #B10000", +"& c #BD0000", +"* c #C30000", +"= c #A60000", +"- c #0D0000", +"; c #070707", +"> c #0A0A0A", +", c #050505", +"' c #730000", +") c #8F0000", +"! c #020000", +"~ c #1D1D1D", +"{ c #D0D0D0", +"] c #EDECFF", +"^ c #69687B", +"/ c #B00000", +"( c #140000", +"_ c #191919", +": c #C9C9DA", +"< c #C5C5EA", +"[ c #585773", +"} c #72727F", +"| c #383842", +"1 c #020202", +"2 c #B9B9CA", +"3 c #8A89A4", +"4 c #15141B", +"5 c #35344D", +"6 c #030303", +"7 c #B6B6DA", +"8 c #A2A1CD", +"9 c #010101", +"0 c #5F5E68", +"a c #B4B4D9", +"b c #08070A", +"c c #4B4A61", +"d c #BAB9FF", +"e c #14131D", +"f c #8A89A7", +"g c #807FAB", +"h c #303044", +"i c #AEACFE", +"j c #030305", +"k c #8785B6", +"l c #9C9BE4", +"m c #050507", +"n c #7574AB", +"o c #6F6EA3", +"p c #2F2E44", +"q c #AFADFF", +"r c #3A3954", +"s c #008100", +"t c #00B900", +"u c #040406", +"v c #7371A7", +"w c #505076", +"x c #9C9AE4", +"y c #0F0F17", +"z c #424160", +"A c #011402", +"B c #009A00", +"C c #09090E", +"D c #A9A7F7", +"E c #1B1B28", +"F c #000200", +"G c #008900", +"H c #7A79B3", +"I c #7E7CB8", +"J c #464567", +" ", +"............ ", +" .+@#$%&***=- ", +" .;>,.'****)! ", +" ~{]^'****/(. ", +" _:<[......}|.", +" 12345 6789", +" 0ab.. cde", +" .fg. . hij", +"..klm......m.no.", +" .pqrsttttuvwxy ", +" .zABttttCqDE ", +" FGtttttCHIJ. ", +" ............", +" ", +" "}; diff --git a/pcbnew/bitmaps/Select_W_Layer.xpm b/pcbnew/bitmaps/Select_W_Layer.xpm new file mode 100644 index 0000000000..986c6a16dc --- /dev/null +++ b/pcbnew/bitmaps/Select_W_Layer.xpm @@ -0,0 +1,43 @@ +/* XPM */ +static char * Select_W_Layer_xpm[] = { +"16 16 24 1", +" c None", +". c #000000", +"+ c #959595", +"@ c #FFFFFF", +"# c #D9D9D9", +"$ c #111111", +"% c #040404", +"& c #BBBBBB", +"* c #720000", +"= c #630000", +"- c #030000", +"; c #8F0000", +"> c #A10000", +", c #760000", +"' c #560000", +") c #010000", +"! c #0D0000", +"~ c #A60000", +"{ c #C30000", +"] c #828282", +"^ c #D3D3D3", +"/ c #9B9B9B", +"( c #717171", +"_ c #020202", +"............ ", +" .+@@@@@@@@#$ ", +" %&@@@@@@@@&% ", +"...$#@@@@@@@@+. ", +" .*=............", +" -;>,,,,,,,') ", +"...!~{{{{{{{{*. ", +" .+]............", +" %&^///////(_ ", +"...$#@@@@@@@@+. ", +" .+]............", +" %&^///////(_ ", +" $#@@@@@@@@+. ", +" ............", +" ", +" "}; diff --git a/pcbnew/bitmaps/Show_Zone.xpm b/pcbnew/bitmaps/Show_Zone.xpm new file mode 100644 index 0000000000..22c7f8c581 --- /dev/null +++ b/pcbnew/bitmaps/Show_Zone.xpm @@ -0,0 +1,90 @@ +/* XPM */ +static char * show_zone_xpm[] = { +"16 16 71 1", +" c None", +". c #007D00", +"+ c #007E00", +"@ c #004100", +"# c #002700", +"$ c #000900", +"% c #000400", +"& c #000000", +"* c #007100", +"= c #040404", +"- c #716F7F", +"; c #A7A3DA", +"> c #A9A4E2", +", c #8E8CA2", +"' c #191919", +") c #000600", +"! c #006400", +"~ c #000F00", +"{ c #2F2F2F", +"] c #CBCBD0", +"^ c #A8A0FF", +"/ c #6D67AC", +"( c #615B98", +"_ c #A198FD", +": c #EAE8F8", +"< c #515151", +"[ c #000100", +"} c #006E00", +"| c #000800", +"1 c #2D2D2D", +"2 c #F5F5F5", +"3 c #DCD9FF", +"4 c #928AE5", +"5 c #000001", +"6 c #7972BE", +"7 c #CEC9FF", +"8 c #FBFBFB", +"9 c #484848", +"0 c #007C00", +"a c #003300", +"b c #030303", +"c c #939393", +"d c #F1F0FE", +"e c #A39AFE", +"f c #403C65", +"g c #333050", +"h c #9A91F1", +"i c #E5E2FF", +"j c #B8B8B8", +"k c #0B0B0B", +"l c #001D00", +"m c #005300", +"n c #000B00", +"o c #383838", +"p c #B4B0DA", +"q c #B0A9FE", +"r c #ACA4FF", +"s c #C1BCF1", +"t c #757575", +"u c #050505", +"v c #002300", +"w c #007800", +"x c #007500", +"y c #003400", +"z c #0A0A0A", +"A c #0C0C0D", +"B c #001700", +"C c #004F00", +"D c #007B00", +"E c #006500", +"F c #006C00", +"................", +".... ........", +"... .......", +".. ++ .....", +". .... ...", +". +. ..... ..", +". +. ...... ..", +". .... .. .", +".. @#$%& .. ", +"..*&=-;>,') ... ", +".!~{]^/(_:<[ ...", +"}|12345&6789& ..", +"0abcdefghijkl .", +"..mnopqrstuvw. .", +"...xy|zA&BCD... ", +".....0E!F...... "}; diff --git a/pcbnew/bitmaps/Swap_Layer.xpm b/pcbnew/bitmaps/Swap_Layer.xpm new file mode 100644 index 0000000000..65d465805b --- /dev/null +++ b/pcbnew/bitmaps/Swap_Layer.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static char * swap_layer_xpm[] = { +"16 16 6 1", +" c None", +". c #B70000", +"+ c #000000", +"@ c #9B0000", +"# c #008F00", +"$ c #007900", +".......... ", +".......... + ", +".........@++++ ", +".........@+++++ ", +".......... + +++", +".......... ++", +"......##########", +"......##########", +"......##########", +"......##########", +"++ ##########", +"+++ + ##########", +" +++++$#########", +" ++++$#########", +" + ##########", +" ##########"}; diff --git a/pcbnew/bitmaps/Track_Locked.xpm b/pcbnew/bitmaps/Track_Locked.xpm new file mode 100644 index 0000000000..6800c2abde --- /dev/null +++ b/pcbnew/bitmaps/Track_Locked.xpm @@ -0,0 +1,108 @@ +/* XPM */ +static char * Track_Locked_xpm[] = { +"16 16 89 1", +" c None", +". c #007D00", +"+ c #006100", +"@ c #004400", +"# c #007800", +"$ c #007B00", +"% c #004000", +"& c #007C00", +"* c #006500", +"= c #004A00", +"- c #002200", +"; c #001C00", +"> c #000300", +", c #000000", +"' c #111111", +") c #777977", +"! c #D0D0D0", +"~ c #D9D9D9", +"{ c #B9B9B9", +"] c #6A6A6A", +"^ c #040404", +"/ c #818181", +"( c #B6B6B6", +"_ c #343B34", +": c #1B1E1B", +"< c #4B4D4B", +"[ c #AFAFAF", +"} c #7E837E", +"| c #004700", +"1 c #292929", +"2 c #BEBEBE", +"3 c #070707", +"4 c #2D2F2D", +"5 c #A8A9A8", +"6 c #002100", +"7 c #2A2A2A", +"8 c #BCBCBC", +"9 c #151515", +"0 c #BFBEBE", +"a c #12100D", +"b c #999592", +"c c #1F1C1B", +"d c #0A0A06", +"e c #030201", +"f c #040302", +"g c #2E2820", +"h c #A6A19C", +"i c #19120A", +"j c #A38F75", +"k c #DEC29E", +"l c #DDC2A1", +"m c #D8BC98", +"n c #D4B892", +"o c #CBA475", +"p c #7F592A", +"q c #E0C39F", +"r c #D6B38A", +"s c #C89D67", +"t c #AA8557", +"u c #A58051", +"v c #A58052", +"w c #A17A4A", +"x c #BA8648", +"y c #AA702D", +"z c #E1C4A0", +"A c #D3AC7D", +"B c #AE8B5E", +"C c #D3B082", +"D c #CDA97B", +"E c #CDAA7A", +"F c #C9A270", +"G c #BA8545", +"H c #A86E2A", +"I c #DFC29E", +"J c #CEA473", +"K c #C59963", +"L c #A88254", +"M c #A27D4D", +"N c #9E7643", +"O c #B88241", +"P c #DFC09A", +"Q c #CCA26F", +"R c #AB8B63", +"S c #D0B087", +"T c #CBAA81", +"U c #CCAB81", +"V c #CAA57A", +"W c #B67F3D", +"X c #AB7231", +"........ ", +"........+ ", +" @.# ", +" $.% ", +" &.* ", +" =-;>, ", +" ')!~~{]^ ", +" /(_::<[}|.", +" 123 ...456.", +" 78, 90, ", +" abcdeefghi ", +" ,jkllmmmnop,", +" ,qrstuuvwxy,", +" ,zABCDDEFGH,", +" ,IJKLMMMNOy,", +" ,PQRSTTUVWX,"}; diff --git a/pcbnew/bitmaps/Track_Sketch.xpm b/pcbnew/bitmaps/Track_Sketch.xpm new file mode 100644 index 0000000000..bb72025ffa --- /dev/null +++ b/pcbnew/bitmaps/Track_Sketch.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char * Track_Sketch_xpm[] = { +"16 16 5 1", +" c None", +". c #007D00", +"+ c #D72E2E", +"@ c #6B5517", +"# c #8F481E", +" .. .. ", +"++++++ .. .. ", +"+++++++ .. .. ", +" ++ .. .. ", +"++++ ++ .. .. ", +"+++++ ++ .. .. ", +" ++ + .. .. ", +" ++ ++ .. .. ", +" ++ + .. .. ", +" + ++++++++", +" ++ +@#+@#+", +" + .. .. ", +" ++++++++++", +" +++@#+@#+", +" .. .. ", +" .. .. "}; diff --git a/pcbnew/bitmaps/Track_UnLocked.xpm b/pcbnew/bitmaps/Track_UnLocked.xpm new file mode 100644 index 0000000000..143611c6ab --- /dev/null +++ b/pcbnew/bitmaps/Track_UnLocked.xpm @@ -0,0 +1,100 @@ +/* XPM */ +static char * Track_UnLocked_xpm[] = { +"16 16 81 1", +" c None", +". c #007D00", +"+ c #004C00", +"@ c #007B00", +"# c #006800", +"$ c #000000", +"% c #004300", +"& c #111111", +"* c #777777", +"= c #D0D0D0", +"- c #D9D9D9", +"; c #6A6A6A", +"> c #040404", +", c #007900", +"' c #818181", +") c #B6B6B6", +"! c #353535", +"~ c #1C1C1C", +"{ c #AFAFAF", +"] c #7E7E7E", +"^ c #006300", +"/ c #292929", +"( c #BEBEBE", +"_ c #070707", +": c #2D2D2D", +"< c #A8A8A8", +"[ c #003700", +"} c #2A2A2A", +"| c #BCBCBC", +"1 c #151515", +"2 c #BFBEBE", +"3 c #12100D", +"4 c #999592", +"5 c #1F1C1B", +"6 c #0A0A06", +"7 c #030201", +"8 c #040302", +"9 c #0C0B08", +"0 c #272523", +"a c #19120A", +"b c #A38F75", +"c c #DEC29E", +"d c #DDC2A1", +"e c #D8BC98", +"f c #D4B892", +"g c #CBA475", +"h c #7F592A", +"i c #E0C39F", +"j c #D6B38A", +"k c #C89D67", +"l c #AA8557", +"m c #A58051", +"n c #A58052", +"o c #A17A4A", +"p c #BA8648", +"q c #AA702D", +"r c #E1C4A0", +"s c #D3AC7D", +"t c #AE8B5E", +"u c #D3B082", +"v c #CDA97B", +"w c #CDAA7A", +"x c #C9A270", +"y c #BA8545", +"z c #A86E2A", +"A c #DFC29E", +"B c #CEA473", +"C c #C59963", +"D c #A88254", +"E c #A27D4D", +"F c #9E7643", +"G c #B88241", +"H c #DFC09A", +"I c #CCA26F", +"J c #AB8B63", +"K c #D0B087", +"L c #CBAA81", +"M c #CCAB81", +"N c #CAA57A", +"O c #B67F3D", +"P c #AB7231", +".......... ", +"........... ", +" +.. ", +" @. ", +" #.. ", +" $$ %.. ", +" &*=-;> ,. ", +" ')!~{] ^.....", +"/(_ :<$ [.....", +"}|$ 12$ ", +" 345677890a ", +" $bcddeeefgh$", +" $ijklmmnopq$", +" $rstuvvwxyz$", +" $ABCDEEEFGq$", +" $HIJKLLMNOP$"}; diff --git a/pcbnew/bitmaps/Unlocked.xpm b/pcbnew/bitmaps/Unlocked.xpm new file mode 100644 index 0000000000..0ee4462be6 --- /dev/null +++ b/pcbnew/bitmaps/Unlocked.xpm @@ -0,0 +1,107 @@ +/* XPM */ +static char * Unlocked_xpm[] = { +"16 16 88 1", +" c None", +". c #000000", +"+ c #1E1E1E", +"@ c #7A7A7A", +"# c #D2D2D2", +"$ c #DBDBDB", +"% c #727272", +"& c #080808", +"* c #848484", +"= c #BEBEBE", +"- c #363636", +"; c #1D1D1D", +"> c #B1B1B1", +", c #2D2D2D", +"' c #C2C2C2", +") c #090909", +"! c #2E2E2E", +"~ c #AAAAAA", +"{ c #2B2B2B", +"] c #C0C0C0", +"^ c #161616", +"/ c #C1C0C0", +"( c #13110E", +"_ c #9B9794", +": c #201D1C", +"< c #0B0B07", +"[ c #040302", +"} c #050403", +"| c #0D0C09", +"1 c #282624", +"2 c #1A130B", +"3 c #A59176", +"4 c #E0C4A0", +"5 c #DFC4A3", +"6 c #DABE9A", +"7 c #D6BA94", +"8 c #CDA676", +"9 c #815A2B", +"0 c #E2C5A1", +"a c #D8B58C", +"b c #CA9F68", +"c c #AC8758", +"d c #A78252", +"e c #A78253", +"f c #A37B4B", +"g c #BC8849", +"h c #AC712E", +"i c #E3C6A2", +"j c #D5AE7E", +"k c #B08D5F", +"l c #D5B284", +"m c #CFAB7C", +"n c #CFAC7B", +"o c #CBA471", +"p c #BC8746", +"q c #AA6F2B", +"r c #E1C4A0", +"s c #D0A674", +"t c #C79B64", +"u c #AA8455", +"v c #A47E4E", +"w c #A07744", +"x c #BA8442", +"y c #E1C29C", +"z c #CEA470", +"A c #AD8D64", +"B c #D2B289", +"C c #CDAC83", +"D c #CEAD83", +"E c #CCA77B", +"F c #B8803E", +"G c #AD7332", +"H c #E0C29E", +"I c #D4AC79", +"J c #CDA66E", +"K c #AF8D5E", +"L c #AB8758", +"M c #AB8858", +"N c #A8814C", +"O c #B47E3E", +"P c #D0A874", +"Q c #C6965D", +"R c #BE8D50", +"S c #BA894B", +"T c #BD8C4E", +"U c #BC8A4C", +"V c #BA8647", +"W c #A47136", +" ", +" .. ", +" +@#$%& ", +" *=-;>* ", +",') !~. ", +"{]. ^/. ", +" (_:<[[}|12 ", +" .3455666789.", +" .0abcddefgh.", +" .ijklmmnopq.", +" .rstuvvvwxh.", +" .yzABCCDEFG.", +" .HIJKLLMNpO.", +" .PQRRSSTUVW.", +" .......... ", +" "}; diff --git a/pcbnew/bitmaps/Width_Net.xpm b/pcbnew/bitmaps/Width_Net.xpm new file mode 100644 index 0000000000..67124e3b25 --- /dev/null +++ b/pcbnew/bitmaps/Width_Net.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static const char * width_net_xpm[] = { +"16 16 6 1", +" c None", +"! c black", +"# c #3CBA00", +"$ c #BABA00", +"% c #FF0000", +"& c #00BA00", +" ! ## ", +" ! $$ ", +" ! ! ! %%%$$$$%%", +" !!!!! %%%$$$$%%", +" !!! %% $$ ", +" !!!!! %% ## ", +" &%%&&##&&&", +" &%%&&##&&&", +" !!!!! %% ## ", +" !!! %% ## ", +" !!!!! %% ## ", +" ! ! ! %% ## ", +" ! %% ## ", +" ! %% ## ", +" ! %% ## ", +" %% ##"}; diff --git a/pcbnew/bitmaps/Width_Segment.xpm b/pcbnew/bitmaps/Width_Segment.xpm new file mode 100644 index 0000000000..7ca45ada9d --- /dev/null +++ b/pcbnew/bitmaps/Width_Segment.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * width_segment_xpm[] = { +"16 16 3 1", +" c None", +"! c black", +"# c #00BA00", +" ! ", +" ! ", +" ! ! ! ", +" !!!!! ", +" !!! ", +" !!!!! ", +" ##########", +" ##########", +" !!!!! ", +" !!! ", +" !!!!! ", +" ! ! ! ", +" ! ", +" ! ", +" ! ", +" "}; diff --git a/pcbnew/bitmaps/Width_Track.xpm b/pcbnew/bitmaps/Width_Track.xpm new file mode 100644 index 0000000000..25b33d34dc --- /dev/null +++ b/pcbnew/bitmaps/Width_Track.xpm @@ -0,0 +1,28 @@ +/* XPM */ +static char * width_track_xpm[] = { +"16 16 9 1", +" c None", +". c #000000", +"+ c #007D00", +"@ c #007100", +"# c #004D00", +"$ c #007A00", +"% c #006100", +"& c #002B00", +"* c #006F00", +" . ", +" . ", +" . . . ", +" ..... ", +" ... ", +" ..... ", +" +++++ ", +" +++++ ", +" ..... @++ ", +" ... #++ ", +" ..... $+ ", +" . . . %++ ", +" . &+++++", +" . *++++", +" . ", +" "}; diff --git a/pcbnew/bitmaps/Width_Track_Via.xpm b/pcbnew/bitmaps/Width_Track_Via.xpm new file mode 100644 index 0000000000..65461ec130 --- /dev/null +++ b/pcbnew/bitmaps/Width_Track_Via.xpm @@ -0,0 +1,29 @@ +/* XPM */ +static const char * width_track_via_xpm[] = { +"16 16 10 1", +" c None", +"! c black", +"# c #FF0000", +"$ c #007D00", +"% c #007100", +"& c #004D00", +"' c #007A00", +"( c #006100", +") c #002B00", +"* c #006F00", +" ! ### ", +" ! # # ", +" ! ! ! # # ", +" !!!!! # # ", +" !!! ### ", +" !!!!! ", +" $$$$$ ", +" $$$$$ ", +" !!!!! %$$ ", +" !!! &$$ ", +" !!!!! '$ ", +" ! ! ! ($$ ", +" ! )$$$$$", +" ! *$$$$", +" ! ", +" "}; diff --git a/pcbnew/bitmaps/Width_Vias.xpm b/pcbnew/bitmaps/Width_Vias.xpm new file mode 100644 index 0000000000..fe91048ec3 --- /dev/null +++ b/pcbnew/bitmaps/Width_Vias.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static const char * width_vias_xpm[] = { +"16 16 5 1", +" c None", +"! c black", +"# c #FF0000", +"$ c #0046D9", +"% c #00FF00", +" ! ### ", +" ! # # ", +" ! ! ! # # ", +" !!!!! # # ", +" !!! ### ", +" !!!!! ", +" ", +" $$$ ", +" !!!!!$ $ ", +" !!! $ $ ", +" !!!!!$ $ %% ", +" ! ! ! $$$ % % ", +" ! % %", +" ! % %", +" ! % % ", +" %% "}; diff --git a/pcbnew/bitmaps/add_cotation.xpm b/pcbnew/bitmaps/add_cotation.xpm new file mode 100644 index 0000000000..6fc73616b8 --- /dev/null +++ b/pcbnew/bitmaps/add_cotation.xpm @@ -0,0 +1,33 @@ +/* XPM */ +static char * add_cotation_xpm[] = { +"16 16 14 1", +" c None", +". c #000000", +"+ c #00009B", +"@ c #000097", +"# c #000099", +"$ c #00008B", +"% c #000095", +"& c #000088", +"* c #000072", +"= c #000066", +"- c #000093", +"; c #00008F", +"> c #000082", +", c #00009C", +" ", +" . . ", +" .. . ", +" .... ", +" . . ", +"+ +@ . . # + ", +"+$@ %+ ", +"+#+++++++++++++ ", +"+&* =-+.", +"+ ;> , + ", +"+ + ", +"+ + ", +"+ + ", +"+ + ", +"+ + ", +" "}; diff --git a/pcbnew/bitmaps/general_ratsnet.xpm b/pcbnew/bitmaps/general_ratsnet.xpm new file mode 100644 index 0000000000..c87a1e6fc4 --- /dev/null +++ b/pcbnew/bitmaps/general_ratsnet.xpm @@ -0,0 +1,60 @@ +/* XPM */ +static char * general_ratsnet_xpm[] = { +"16 16 41 1", +" c None", +". c #FFFFFF", +"+ c #2F2F2F", +"@ c #444342", +"# c #AEAEAE", +"$ c #1D1D1D", +"% c #F2D7C1", +"& c #F2BD8E", +"* c #3C3631", +"= c #403D3B", +"- c #F2B279", +"; c #F29747", +"> c #443B33", +", c #B1B1B1", +"' c #444444", +") c #333231", +"! c #C3C3C3", +"~ c #372E28", +"{ c #3C3129", +"] c #413B36", +"^ c #423F3D", +"/ c #382F29", +"( c #1C1006", +"_ c #323232", +": c #161514", +"< c #181818", +"[ c #3B3A39", +"} c #3F3F3F", +"| c #171009", +"1 c #F2D7C0", +"2 c #F2BC8E", +"3 c #3D3731", +"4 c #1D1917", +"5 c #2A1F16", +"6 c #413E3C", +"7 c #F29647", +"8 c #1B1007", +"9 c #261D16", +"0 c #443A32", +"a c #BBBBBB", +"b c #1A1109", +" ... ... ", +" .. .. ", +" +@# ... ", +" $%&* .. ", +" =-;>.....,') ", +"..!~{!.....'%&].", +".. ... ^-;>.", +". ... .!/( ", +" ..... ", +" ... ", +" ..... ", +" ... .!_: ", +" <[!. }%&| ", +"...'123 4-;5 ", +"...6-78 90a ", +" b( .. "}; diff --git a/pcbnew/bitmaps/local_ratsnet.xpm b/pcbnew/bitmaps/local_ratsnet.xpm new file mode 100644 index 0000000000..a7dfbd71af --- /dev/null +++ b/pcbnew/bitmaps/local_ratsnet.xpm @@ -0,0 +1,80 @@ +/* XPM */ +static char * local_ratsnet_xpm[] = { +"16 16 61 1", +" c None", +". c #FFFFFF", +"+ c #000000", +"@ c #040404", +"# c #C3C3C3", +"$ c #080808", +"% c #BBBBC3", +"& c #FF7800", +"* c #F5F4FF", +"= c #EBEAFF", +"- c #747479", +"; c #DADAED", +"> c #E1E1FF", +", c #F6F5FF", +"' c #323135", +") c #3D3D3F", +"! c #9493AF", +"~ c #ECECFF", +"{ c #323237", +"] c #F9F9F9", +"^ c #7B7B7B", +"/ c #EC6F00", +"( c #E3E2FF", +"_ c #2F2F37", +": c #BFBFCD", +"< c #382F2D", +"[ c #A8A8A8", +"} c #D9D8FF", +"| c #363542", +"1 c #F4F4F4", +"2 c #F7F7FF", +"3 c #E6E6FF", +"4 c #D1D1F9", +"5 c #5A5A74", +"6 c #D0CFFF", +"7 c #3E3E50", +"8 c #E5E5E5", +"9 c #F0F0FF", +"0 c #D3D3F1", +"a c #4F4F62", +"b c #2C2C30", +"c c #C1C0F8", +"d c #43435B", +"e c #D2D2D7", +"f c #7F7F8C", +"g c #9999B6", +"h c #444457", +"i c #737373", +"j c #A4A4A4", +"k c #E2E2E2", +"l c #363639", +"m c #33333E", +"n c #B2B2EE", +"o c #1A1A24", +"p c #EBEBEB", +"q c #9090C8", +"r c #7C7CBD", +"s c #010101", +"t c #393952", +"u c #6969A7", +"v c #09090E", +" ", +" ", +". +@ @+ .", +"... +#$$%+ ...", +" ...&+..*=+&... ", +" .&+.-;>+&. ", +" +,')!+ ", +"....&+~{]^@/....", +"....&+(_..:<[...", +" +}|12345+ ", +" .&+67890ab ", +" ...&+cdefghijk ", +"... +++l+mnop..", +". + +qrs .", +" tuv ", +" ++ "}; diff --git a/pcbnew/bitmaps/module_options.xpm b/pcbnew/bitmaps/module_options.xpm new file mode 100644 index 0000000000..e80a6e06a1 --- /dev/null +++ b/pcbnew/bitmaps/module_options.xpm @@ -0,0 +1,84 @@ +/* XPM */ +static char * module_options_xpm[] = { +"16 16 65 1", +" c None", +". c #D72E2E", +"+ c #000000", +"@ c #010000", +"# c #F8F8F8", +"$ c #B8B8B8", +"% c #A9A9B8", +"& c #DAD9F8", +"* c #F9E53A", +"= c #F1B44C", +"- c #D42D2D", +"; c #FFFFFF", +"> c #EEEDF8", +", c #E5E4F8", +"' c #E1E0FF", +") c #D7D6FF", +"! c #FBE93C", +"~ c #F6B343", +"{ c #645632", +"] c #F5F5FF", +"^ c #EBEBFF", +"/ c #E1E1FF", +"( c #010101", +"_ c #FAE73A", +": c #F5B344", +"< c #6B5E33", +"[ c #D62D2D", +"} c #F6F5FF", +"| c #ECEBFF", +"1 c #E2E1FF", +"2 c #D8D7FF", +"3 c #F9E33A", +"4 c #F2B043", +"5 c #625739", +"6 c #F6F6FF", +"7 c #ECECFF", +"8 c #E2E2FF", +"9 c #F8DE39", +"0 c #F2AE42", +"a c #615637", +"b c #D12C2C", +"c c #EDECFF", +"d c #E3E2FF", +"e c #D9D8FF", +"f c #F8DB38", +"g c #EEB34D", +"h c #665A32", +"i c #CF2C2C", +"j c #E3E3FF", +"k c #F7D737", +"l c #EFA83F", +"m c #655930", +"n c #DAD9FF", +"o c #F5D136", +"p c #ECA33E", +"q c #5C5230", +"r c #AFADFF", +"s c #D62E2E", +"t c #D0CFFF", +"u c #D6AD74", +"v c #61562F", +"w c #4F4115", +"x c #B4B2FF", +"y c #050508", +"z c #CE2C2C", +"...+++ +++.@@+", +". .+#$+++%&+@*=+", +".-.+;;#>,')+!~{+", +" +;;]^/)(_:<+ ", +".[[+;}|12(345@[ ", +". .+6782(90a@ . ", +".b.+cde(fgh+.i. ", +" +je(klm(+ ", +"...+n(opq(r+-ss ", +". .+t(uv(rr+. . ", +".-.+(w((rrr+.b. ", +" +((rrrrr+ ", +".[[+xrrrrrr+b[[ ", +". .+rrrrrrr+. . ", +".b.+yyyyyyy+.z. ", +" "}; diff --git a/pcbnew/bitmaps/mw_Add_Gap.xpm b/pcbnew/bitmaps/mw_Add_Gap.xpm new file mode 100644 index 0000000000..7c4d7b8429 --- /dev/null +++ b/pcbnew/bitmaps/mw_Add_Gap.xpm @@ -0,0 +1,32 @@ +/* XPM */ +static char * mw_Add_Gap_xpm[] = { +"16 16 13 1", +" c None", +". c #D72E2E", +"+ c #9B9B9B", +"@ c #3737FF", +"# c #000000", +"$ c #9A9A9A", +"% c #080808", +"& c #3B3B3B", +"* c #0F0F0F", +"= c #818181", +"- c #828282", +"; c #5E5E5E", +"> c #434343", +" ", +" ", +".... .... ", +"....+ @ ....+", +"....+ @@@ ....+", +"....+ @ ....+", +"....+ ....+", +" ++++ ++++", +" ", +" ", +" # # ", +" # $ %& ", +" ######### ", +" *=+++-*;$ ", +" &> # + ", +" + + "}; diff --git a/pcbnew/bitmaps/mw_Add_Line.xpm b/pcbnew/bitmaps/mw_Add_Line.xpm new file mode 100644 index 0000000000..e2b0aa0aec --- /dev/null +++ b/pcbnew/bitmaps/mw_Add_Line.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static char * mw_Add_Line_xpm[] = { +"16 16 6 1", +" c None", +". c #D72E2E", +"+ c #9B9B9B", +"@ c #000000", +"# c #2E2E2E", +"$ c #5F5F5F", +" ... ... ... ", +" .+.+.+.+.+.+ ", +" .+.+.+.+.+.+ ", +" .+.+.+.+.+.+ ", +" .+.+.+.+.+.+ ", +"..+.+.+.+.+.+...", +"+++.+.+.+.+.+.++", +" .+.+.+.+.+.+ ", +" .+.+.+.+.+.+ ", +" .+.+.+.+.+.+ ", +" ...+...+...+ ", +" @+++ +++ #$+ ", +" @ @ ", +" @@@@@@@@@@@@@@ ", +" @ @ ", +" @ @ "}; diff --git a/pcbnew/bitmaps/mw_Add_Shape.xpm b/pcbnew/bitmaps/mw_Add_Shape.xpm new file mode 100644 index 0000000000..2c81ef5b63 --- /dev/null +++ b/pcbnew/bitmaps/mw_Add_Shape.xpm @@ -0,0 +1,40 @@ +/* XPM */ +static char * mw_Add_Shape_xpm[] = { +"16 16 21 1", +" c None", +". c #D72E2E", +"+ c #C54D4D", +"@ c #D62F2F", +"# c #B96262", +"$ c #D53131", +"% c #9B9B9B", +"& c #C84848", +"* c #AA7E7E", +"= c #BD5B5B", +"- c #B66969", +"; c #B86565", +"> c #D13737", +", c #CA4545", +"' c #9C9797", +") c #D23535", +"! c #AE7777", +"~ c #BA6262", +"{ c #C74A4A", +"] c #D03939", +"^ c #9B9999", +" ", +" .. ", +" ...+ ", +" .. ....@ ", +" ..#$...... ", +" .. ........... ", +"...............%", +"...............%", +" &&*=..........%", +" %% ..-;......%", +" >,' )...@!%", +" %% ...~% ", +" {]=^% ", +" %% ", +" ", +" "}; diff --git a/pcbnew/bitmaps/mw_Add_Stub.xpm b/pcbnew/bitmaps/mw_Add_Stub.xpm new file mode 100644 index 0000000000..cb0b70d0e3 --- /dev/null +++ b/pcbnew/bitmaps/mw_Add_Stub.xpm @@ -0,0 +1,33 @@ +/* XPM */ +static char * mw_Add_Stub_xpm[] = { +"16 16 14 1", +" c None", +". c #D72E2E", +"+ c #070707", +"@ c #9B9B9B", +"# c #121212", +"$ c #747474", +"% c #565656", +"& c #8D8D8D", +"* c #0B0B0B", +"= c #060606", +"- c #1E1E1E", +"; c #131313", +"> c #404040", +", c #505050", +" ", +" .... + ", +" ....@ ++# ", +" ....@ +$% ", +" ....@ +@ ", +" ....@ +@ ", +" ....@ +@ ", +" ....@ +@ ", +" ....@ +@ ", +" ....@ +@ ", +" ....@ +@ ", +" ....@ +&+ ", +" ....@ *=-;@", +" ....@ >=,@@", +" @@@@ @@ ", +" "}; diff --git a/pcbnew/bitmaps/mw_Add_stub_arc.xpm b/pcbnew/bitmaps/mw_Add_stub_arc.xpm new file mode 100644 index 0000000000..6b14b24ef7 --- /dev/null +++ b/pcbnew/bitmaps/mw_Add_stub_arc.xpm @@ -0,0 +1,74 @@ +/* XPM */ +static char * mw_Add_stub_arc_xpm[] = { +"16 16 55 1", +" c None", +". c #000000", +"+ c #393939", +"@ c #141414", +"# c #050505", +"$ c #101010", +"% c #030303", +"& c #020202", +"* c #0D0D0D", +"= c #080808", +"- c #343434", +"; c #949494", +"> c #9B9B9B", +", c #767676", +"' c #292929", +") c #626262", +"! c #333333", +"~ c #373737", +"{ c #0F0F0F", +"] c #1B1B1B", +"^ c #474747", +"/ c #8F8F8F", +"( c #070707", +"_ c #CD4040", +": c #D53030", +"< c #D72E2E", +"[ c #D72D2D", +"} c #D53131", +"| c #AF7676", +"1 c #151515", +"2 c #353535", +"3 c #D62E2E", +"4 c #CA4343", +"5 c #727272", +"6 c #818181", +"7 c #484848", +"8 c #D62F2F", +"9 c #D63030", +"0 c #A48A8A", +"a c #9C9C9C", +"b c #CE3E3E", +"c c #BC5E5E", +"d c #D33333", +"e c #D23636", +"f c #9E9494", +"g c #B36F6F", +"h c #D13838", +"i c #CB4141", +"j c #9C9A9A", +"k c #AB7D7D", +"l c #0C0C0C", +"m c #060606", +"n c #2F2F2F", +"o c #4F4F4F", +"p c #5E5E5E", +" . ", +".+@.#$#%&* ", +".=-;>>>,'.) ", +"!~{ %]^/ ( ", +" _:<<[}| ((12 ", +" 3<<<<<<4 (5(67 ", +" 8<<<<90a a(> ", +" b<<< (> ", +" d< (> ", +" < (> ", +" hij (6( ", +" k> lm@n ", +" <<<< o(p> ", +" <<<<> > ", +" <<<<> ", +" >>>> "}; diff --git a/pcbnew/bitmaps/mw_toolbar.xpm b/pcbnew/bitmaps/mw_toolbar.xpm new file mode 100644 index 0000000000..602b41e157 --- /dev/null +++ b/pcbnew/bitmaps/mw_toolbar.xpm @@ -0,0 +1,86 @@ +/* XPM */ +static char * mw_toolbar_xpm[] = { +"16 16 67 1", +" c None", +". c #000000", +"+ c #E3BF40", +"@ c #EACF71", +"# c #EBD074", +"$ c #EDD78A", +"% c #F1F1F0", +"& c #EBEBEA", +"* c #ECECEB", +"= c #DDDCDA", +"- c #F3E4B0", +"; c #F2E2A9", +"> c #E8CA61", +", c #D6D5D3", +"' c #D7D6D4", +") c #D8D7D5", +"! c #B6B4AF", +"~ c #F3E4B2", +"{ c #B7B5B0", +"] c #D9D8D6", +"^ c #EEC593", +"/ c #E57054", +"( c #E88C69", +"_ c #DABEBC", +": c #D86A69", +"< c #D98685", +"[ c #DAD9D7", +"} c #1B0000", +"| c #D90000", +"1 c #EDD686", +"2 c #DB1910", +"3 c #CA6522", +"4 c #D61717", +"5 c #B25F5C", +"6 c #9F9D96", +"7 c #BE0000", +"8 c #6D0000", +"9 c #A10000", +"0 c #B44746", +"a c #BDBDBC", +"b c #AF4241", +"c c #B34646", +"d c #B1B0AF", +"e c #9C0000", +"f c #AD403F", +"g c #ACABAA", +"h c #A33634", +"i c #ABABA9", +"j c #AE4040", +"k c #92908C", +"l c #ADACAB", +"m c #A43634", +"n c #93918D", +"o c #AEADAB", +"p c #AE4140", +"q c #DBDAD8", +"r c #CE605E", +"s c #974341", +"t c #D60E0E", +"u c #BB1716", +"v c #9A3F3D", +"w c #BE1A1A", +"x c #AC3E3B", +"y c #8B0000", +"z c #480000", +"A c #B10000", +"B c #040000", +"............... ", +".+@@@#$.%&***=. ", +".@---;>.&,,')!. ", +".@--~;>.*,')){. ", +".@---;>.&,,]]{. ", +".#^//(>._::<[{}|", +".12|||3.4|||567|", +"..|8.|8.|8.|8.|9", +".%|0a|b.|ca|0d|e", +".&|fg|h.|fi|jk|e", +".*|fl|m.|fg|jn|e", +".&|fo|m.|fi|pn|e", +".q|jo|m.|jl|pn|e", +"8r|sntu8|vntwx|y", +"||8..z||AB.z||A ", +" "}; diff --git a/pcbnew/bitmaps/net_hightlight.xpm b/pcbnew/bitmaps/net_hightlight.xpm new file mode 100644 index 0000000000..db210390e4 --- /dev/null +++ b/pcbnew/bitmaps/net_hightlight.xpm @@ -0,0 +1,26 @@ +/* XPM bitmap */ +char *net_hightlight_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 16 3 1", +"- c #008000", +". c #00FF00", +"X c None", +/* pixels */ +"XXXXXXXXXXXXXXXX", +"XXXXXX-XXXXXXXXX", +"XXXXXX-XXXXXXXXX", +"XXXXXX-XXXXXXXXX", +"XXXXXX-XXXXXXXXX", +"XXXXX...XXXXXXXX", +"XXXX.....XXXXXXX", +"----.....------X", +"XXXX.....XXXXXXX", +"XXXXX...XXXXXXXX", +"XXXXXX-XXXXXXXXX", +"XXXXXX-XXXXXXXXX", +"XXXXXX-XXXXXXXXX", +"XXXXXX-XXXXXXXXX", +"XXXXXX-XXXXXXXXX", +"XXXXXXXXXXXXXXXX" +}; + diff --git a/pcbnew/bitmaps/tool_ratsnet.xpm b/pcbnew/bitmaps/tool_ratsnet.xpm new file mode 100644 index 0000000000..1146bbd5bf --- /dev/null +++ b/pcbnew/bitmaps/tool_ratsnet.xpm @@ -0,0 +1,72 @@ +/* XPM */ +static char * tool_ratsnet_xpm[] = { +"16 16 53 1", +" c None", +". c #FFFFFF", +"+ c #161616", +"@ c #161513", +"# c #3E3E3E", +"$ c #D9C1AD", +"% c #CCA078", +"& c #443E39", +"* c #3F3C3A", +"= c #CC9666", +"- c #0E0B09", +"; c #211C18", +"> c #FAFAFA", +", c #C3C3C3", +"' c #362F29", +") c #636363", +"! c #9A9A9A", +"~ c #111112", +"{ c #F6F6F6", +"] c #555555", +"^ c #D5D5E4", +"/ c #42424C", +"( c #474747", +"_ c #F7F7FF", +": c #E6E6FF", +"< c #D6D6FF", +"[ c #7F7FA4", +"} c #0F0F17", +"| c #404040", +"1 c #F0F0FF", +"2 c #DFDFFF", +"3 c #C3C3F2", +"4 c #75759D", +"5 c #232334", +"6 c #3A3A3B", +"7 c #E8E8FF", +"8 c #9898B4", +"9 c #9E9ECB", +"0 c #040405", +"a c #353536", +"b c #656572", +"c c #000000", +"d c #8787B4", +"e c #5B5B85", +"f c #2C2C3E", +"g c #A6A6FD", +"h c #25253D", +"i c #BBBBBB", +"j c #7C7CC5", +"k c #6C6CB1", +"l c #E0E0E0", +"m c #12121D", +"n c #020203", +" ", +" ", +".. ...", +".... +@ .......", +" ..#$%&..... ", +" .*=-;> ", +" .,')!~ ", +" ...{].^/ ", +".... .(_:<[} ", +"... .|12345 ", +". .67890 ", +" .abcdec ", +" .|c fgh ", +" .i cjkc ", +" .l mn ", +" .. c "}; diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp new file mode 100644 index 0000000000..729f79e455 --- /dev/null +++ b/pcbnew/block.cpp @@ -0,0 +1,1397 @@ + /*****************************************************************/ + /* Operations sur Blocks : deplacement, rotation, effacement ... */ + /*****************************************************************/ + + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "pcbplot.h" +#include "trigo.h" + +#include "protos.h" + + +#define BLOCK_COLOR BROWN + +/* Routines Locales */ + +static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); + +static EDA_BaseStruct * IsStructInBox(DrawBlockStruct &blocklocate, EDA_BaseStruct * PtStruct ); +static TRACK * IsSegmentInBox(DrawBlockStruct & blocklocate, TRACK * PtSegm ); +static MODULE * IsModuleInBox(DrawBlockStruct& blocklocate, MODULE * Module ); + +/* Variables locales :*/ +static bool Block_Include_Modules = TRUE; +static bool Block_Include_Tracks = TRUE; +static bool Block_Include_Zones = TRUE; +static bool Block_Include_Draw_Items = TRUE; +static bool Block_Include_Edges_Items = TRUE; +static bool Block_Include_PcbTextes = TRUE; + +enum id_block_cmd +{ + ID_ACCEPT_BLOCK_COMMAND = 8000, + ID_CANCEL_BLOCK_COMMAND +}; + + /************************************/ + /* class WinEDA_ExecBlockCmdFrame */ + /************************************/ + +class WinEDA_ExecBlockCmdFrame: public wxDialog +{ +private: + + WinEDA_BasePcbFrame * m_Parent; + wxCheckBox * m_Include_Modules; + wxCheckBox * m_Include_Tracks; + wxCheckBox * m_Include_Zones; + wxCheckBox * m_Include_Draw_Items; + wxCheckBox * m_Include_Edges_Items; + wxCheckBox * m_Include_PcbTextes; + +public: + // Constructor and destructor + WinEDA_ExecBlockCmdFrame(WinEDA_BasePcbFrame *parent, + const wxString & title); + ~WinEDA_ExecBlockCmdFrame(void) + { + } + +private: + void ExecuteCommand(wxCommandEvent& event); + void Cancel(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(WinEDA_ExecBlockCmdFrame, wxDialog) + EVT_BUTTON(ID_ACCEPT_BLOCK_COMMAND, WinEDA_ExecBlockCmdFrame::ExecuteCommand) + EVT_BUTTON(ID_CANCEL_BLOCK_COMMAND, WinEDA_ExecBlockCmdFrame::Cancel) +END_EVENT_TABLE() + + +/**************************************************************/ +static bool InstallBlockCmdFrame(WinEDA_BasePcbFrame * parent, + const wxString & title) +/**************************************************************/ +{ +int nocmd; +wxPoint oldpos = parent->GetScreen()->m_Curseur; + + parent->DrawPanel->m_IgnoreMouseEvents = TRUE; + WinEDA_ExecBlockCmdFrame * frame = new WinEDA_ExecBlockCmdFrame(parent, title); + nocmd = frame->ShowModal(); frame->Destroy(); + parent->GetScreen()->m_Curseur = oldpos; + parent->DrawPanel->MouseToCursorSchema(); + parent->DrawPanel->m_IgnoreMouseEvents = FALSE; + + parent->DrawPanel->SetCursor(parent->DrawPanel->m_PanelCursor = parent->DrawPanel->m_PanelDefaultCursor); + + return ( nocmd ? FALSE : TRUE ); +} + + +/******************************************************************************/ +WinEDA_ExecBlockCmdFrame::WinEDA_ExecBlockCmdFrame(WinEDA_BasePcbFrame *parent, + const wxString & title): + wxDialog(parent, -1, title, wxPoint(-1,-1), wxSize(280, 220), + DIALOG_STYLE) +/******************************************************************************/ +{ +wxPoint pos; +wxButton * Button; + + m_Parent = parent; + SetFont(*g_DialogFont); + Centre(); + + /* Creation des boutons de commande */ + pos.x = 170; pos.y = 10; + Button = new wxButton(this, ID_ACCEPT_BLOCK_COMMAND, + _("Ok"), pos); + Button->SetForegroundColour(*wxRED); + + pos.y += Button->GetDefaultSize().y + 20; + Button = new wxButton(this, ID_CANCEL_BLOCK_COMMAND, + _("Cancel"), pos); + Button->SetForegroundColour(*wxBLUE); + + pos.x = 5; pos.y = 20; + + // Selection des options : + m_Include_Modules = new wxCheckBox(this, -1, _("Include Modules"), pos); + m_Include_Modules->SetValue(Block_Include_Modules); + + pos.y += 20; + m_Include_Tracks = new wxCheckBox(this, -1, _("Include tracks"), pos); + m_Include_Tracks->SetValue(Block_Include_Tracks); + + pos.y += 20; + m_Include_Zones = new wxCheckBox(this, -1, _("Include zones"), pos); + m_Include_Zones->SetValue(Block_Include_Zones); + + pos.y += 20; + m_Include_PcbTextes = new wxCheckBox(this, -1, + _("Include Text on copper layers"), pos); + m_Include_PcbTextes->SetValue(Block_Include_PcbTextes); + + pos.y += 20; + m_Include_Draw_Items = new wxCheckBox(this, -1, _("Include drawings"), pos); + m_Include_Draw_Items->SetValue(Block_Include_Draw_Items); + + pos.y += 20; + m_Include_Edges_Items = new wxCheckBox(this, -1, _("Include egde layer"), pos); + m_Include_Edges_Items->SetValue(Block_Include_Edges_Items); + +} + +/**********************************************************************/ +void WinEDA_ExecBlockCmdFrame::Cancel(wxCommandEvent& WXUNUSED(event)) +/**********************************************************************/ +{ + EndModal(1); +} + + + +/*******************************************************************/ +void WinEDA_ExecBlockCmdFrame::ExecuteCommand(wxCommandEvent& event) +/*******************************************************************/ +{ + Block_Include_Modules = m_Include_Modules->GetValue(); + Block_Include_Tracks = m_Include_Tracks->GetValue(); + Block_Include_Zones = m_Include_Zones->GetValue(); + Block_Include_Draw_Items = m_Include_Draw_Items->GetValue(); + Block_Include_Edges_Items = m_Include_Edges_Items->GetValue(); + Block_Include_PcbTextes = m_Include_PcbTextes->GetValue(); + + EndModal(0); +} + + +/*************************************************/ +int WinEDA_PcbFrame::ReturnBlockCommand(int key) +/*************************************************/ +/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to + the key (ALT, SHIFT ALT ..) +*/ +{ +int cmd = 0; + + switch ( key ) + { + default: + cmd = key & 0x255; + break; + + case 0: + cmd = BLOCK_MOVE; + break; + + case GR_KB_SHIFT: + cmd = BLOCK_COPY; + break; + + case GR_KB_CTRL : + cmd = BLOCK_ROTATE; + break; + + case GR_KB_SHIFTCTRL : + cmd = BLOCK_DELETE; + break; + + case GR_KB_ALT : + cmd = BLOCK_INVERT; + break; + + case MOUSE_MIDDLE: + cmd = BLOCK_ZOOM; + break; + } + + return cmd ; +} + + +/*****************************************************/ +void WinEDA_PcbFrame::HandleBlockPlace(wxDC * DC) +/*****************************************************/ +/* Routine to handle the BLOCK PLACE commande */ +{ +bool err = FALSE; + + if(DrawPanel->ManageCurseur == NULL) + { + err = TRUE; + DisplayError(this, wxT("Error in HandleBlockPLace : ManageCurseur = NULL") ); + } + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + + switch(GetScreen()->BlockLocate.m_Command ) + { + case BLOCK_IDLE: + err = TRUE; + break; + + case BLOCK_DRAG: /* Drag */ + case BLOCK_MOVE: /* Move */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + if ( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + Block_Move(DC); + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + break; + + case BLOCK_COPY: /* Copy */ + if ( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + Block_Duplicate(DC); + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + break; + + case BLOCK_PASTE: + break; + + case BLOCK_ZOOM: // Handled by HandleBlockEnd() + default: + break; + } + + GetScreen()->SetModify(); + + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->BlockLocate.m_Flags = 0; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + if ( GetScreen()->BlockLocate.m_BlockDrawStruct ) + { + DisplayError(this, wxT("Error in HandleBlockPLace DrawStruct != NULL") ); + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + } + + DisplayToolMsg(wxEmptyString); +} + +/**********************************************/ +int WinEDA_PcbFrame::HandleBlockEnd(wxDC * DC) +/**********************************************/ +/* Routine de gestion de la commande BLOCK END + returne : + 0 si aucun compos ant selectionne + 1 sinon + -1 si commande terminée et composants trouvés (block delete, block save) +*/ +{ +int endcommande = TRUE; + + if(DrawPanel->ManageCurseur ) + switch( GetScreen()->BlockLocate.m_Command ) + { + case BLOCK_IDLE: + DisplayError(this, wxT("Error in HandleBlockPLace") ); + break; + + case BLOCK_DRAG: /* Drag (not used, for future enhancements)*/ + case BLOCK_MOVE: /* Move */ + case BLOCK_COPY: /* Copy */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; + endcommande = FALSE; + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + break; + + case BLOCK_DELETE: /* Delete */ + // Turn off the block rectangle now so it is not redisplayed + DrawPanel->ManageCurseur = NULL; + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + DrawAndSizingBlockOutlines(DrawPanel, DC, FALSE); + Block_Delete(DC); + break; + + case BLOCK_ROTATE: /* Rotation */ + // Turn off the block rectangle now so it is not redisplayed + DrawPanel->ManageCurseur = NULL; + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + DrawAndSizingBlockOutlines(DrawPanel, DC, FALSE); + Block_Rotate(DC); + break; + + case BLOCK_INVERT: /* Flip */ + // Turn off the block rectangle now so it is not redisplayed + DrawPanel->ManageCurseur = NULL; + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + DrawAndSizingBlockOutlines(DrawPanel, DC, FALSE); + Block_Invert(DC); + break; + + case BLOCK_SAVE: /* Save (not used, for future enhancements)*/ + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + if( GetScreen()->BlockLocate.m_BlockDrawStruct != NULL) + { + DrawAndSizingBlockOutlines(DrawPanel, DC, FALSE); +// SaveStruct(GetScreen()->BlockLocate.m_BlockDrawStruct); + } + break; + + case BLOCK_PASTE: break; + + case BLOCK_ZOOM: /* Window Zoom */ + //Turn off the redraw block routine now so it is not displayed + // with one corner at the new center of the screen + DrawPanel->ManageCurseur = NULL; + Window_Zoom( GetScreen()->BlockLocate ); + break; + + default: + break; + } + + if ( endcommande == TRUE ) + { + GetScreen()->BlockLocate.m_Flags = 0; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + DisplayToolMsg(wxEmptyString); + } + + return(endcommande); +} + + + +/**************************************************************************/ +static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/**************************************************************************/ +/* Retrace le contour du block de repositionnement des structures a déplacer + */ +{ +int Color; +BASE_SCREEN * screen = panel->GetScreen(); + + Color = YELLOW; GRSetDrawMode(DC, g_XorMode); + + /* Effacement ancien cadre */ + if( erase ) + { + screen->BlockLocate.Draw(panel, DC); + if ( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y ) + { + screen->BlockLocate.Offset(screen->BlockLocate.m_MoveVector); + screen->BlockLocate.Draw(panel, DC); + screen->BlockLocate.Offset(-screen->BlockLocate.m_MoveVector.x, -screen->BlockLocate.m_MoveVector.y); + } + } + + if ( panel->m_Parent->GetScreen()->BlockLocate.m_State != STATE_BLOCK_STOP ) + { + screen->BlockLocate.m_MoveVector.x = screen->m_Curseur.x - screen->BlockLocate.GetRight(); + screen->BlockLocate.m_MoveVector.y = screen->m_Curseur.y - screen->BlockLocate.GetBottom(); + } + + screen->BlockLocate.Draw(panel, DC); + if ( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y ) + { + screen->BlockLocate.Offset(screen->BlockLocate.m_MoveVector); + screen->BlockLocate.Draw(panel, DC); + screen->BlockLocate.Offset(-screen->BlockLocate.m_MoveVector.x, -screen->BlockLocate.m_MoveVector.y); + } +} + + +/************************************************/ +void WinEDA_BasePcbFrame::Block_Delete(wxDC *DC) +/************************************************/ +/* + routine d'effacement du block deja selectionne +*/ +{ +EDA_BaseStruct * PtStruct, * NextS; +int masque_layer; + + if( ! InstallBlockCmdFrame(this, _("Delete Block")) ) return ; + + GetScreen()->SetModify(); + GetScreen()->BlockLocate.Normalize(); + GetScreen()->m_CurrentItem = NULL; + + /* Effacement des modules */ + if ( Block_Include_Modules ) + { + MODULE * module; + Affiche_Message( _("Delete Footprints") ) ; + module = m_Pcb->m_Modules; + for ( ; module != NULL; module = (MODULE*) NextS) + { + NextS = module->Pnext; + if( IsModuleInBox(GetScreen()->BlockLocate, module) == NULL ) continue; + /* le module est ici bon a etre efface */ + module->m_Flags = 0; + module->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR) ; + DeleteStructure(module); + m_Pcb->m_Status_Pcb = 0 ; + } + } + + /* Effacement des Pistes */ + if( Block_Include_Tracks ) + { + TRACK * pt_segm; + + Affiche_Message( _("Delete tracks" )) ; + for ( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) NextS) + { + NextS = pt_segm->Pnext; + if( IsSegmentInBox(GetScreen()->BlockLocate, pt_segm ) ) + { /* la piste est ici bonne a etre efface */ + pt_segm->Draw(DrawPanel, DC, GR_XOR) ; + DeleteStructure(pt_segm); + } + } + } + + /* Effacement des Elements De Dessin */ + masque_layer = EDGE_LAYER; + if( Block_Include_Draw_Items ) masque_layer = ALL_LAYERS; + if( ! Block_Include_Edges_Items ) masque_layer &= ~EDGE_LAYER; + + Affiche_Message( _("Delete draw layers") ); + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = NextS ) + { + NextS = PtStruct->Pnext; + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + #undef STRUCT + #define STRUCT ((DRAWSEGMENT*)PtStruct) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* l'element est ici bon a etre efface */ + Trace_DrawSegmentPcb(DrawPanel, DC, (DRAWSEGMENT*)PtStruct,GR_XOR) ; + DeleteStructure(PtStruct); + break; + + case TYPETEXTE: + if( ! Block_Include_PcbTextes ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* le texte est ici bon a etre efface */ + ((TEXTE_PCB*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); + /* Suppression du texte en Memoire*/ + DeleteStructure(PtStruct); + break; + + case TYPEMIRE: + #undef STRUCT + #define STRUCT ((MIREPCB*) PtStruct) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* l'element est ici bon a etre efface */ + ((MIREPCB*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR) ; + DeleteStructure(PtStruct); + break; + + case TYPECOTATION: + #undef STRUCT + #define STRUCT ((COTATION*) PtStruct) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* l'element est ici bon a etre efface */ + ((COTATION*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR) ; + DeleteStructure(PtStruct); + break; + + default: break; + } + } + + /* Effacement des Zones */ + if(Block_Include_Zones) + { + TRACK * pt_segm; + + Affiche_Message( _("Delete zones") ); + for ( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = (TRACK*) NextS) + { + NextS = pt_segm->Pnext; + if( IsSegmentInBox(GetScreen()->BlockLocate, pt_segm ) ) + {/* la piste est ici bonne a etre efface */ + pt_segm->Draw(DrawPanel, DC, GR_XOR) ; + DeleteStructure(pt_segm); + } + } + } + + /* Rafraichissement de l'ecran : */ + RedrawActiveWindow(DC, TRUE); +} + + +/****************************************************/ +void WinEDA_BasePcbFrame::Block_Rotate(wxDC *DC) +/****************************************************/ +/* + routine de Rotation de 90 deg du block deja selectionne + les elements sont tournes autour du centre du block +*/ +{ +MODULE * module; +EDA_BaseStruct * PtStruct; +int masque_layer; +wxPoint oldpos; +int Nx, Ny, centerX, centerY; /* centre de rotation de l'ensemble des elements */ + + if( ! InstallBlockCmdFrame(this, _("Rotate Block") ) ) return ; + + oldpos = GetScreen()->m_Curseur; + GetScreen()->BlockLocate.Normalize(); + + /* calcul du centre de Rotation */ + centerX = GetScreen()->BlockLocate.Centre().x; + centerY = GetScreen()->BlockLocate.Centre().y; + + GetScreen()->SetModify(); + + /* Rotation des modules */ + if ( Block_Include_Modules ) + { + Affiche_Message( _("Footprint rotation") ); + int Angle_Rot_Module = 900; + module = m_Pcb->m_Modules; + for ( ; module != NULL; module = (MODULE*) module->Pnext) + { + if( IsModuleInBox(GetScreen()->BlockLocate, module) == NULL ) continue; + /* le module est ici bon a etre modifie */ + m_Pcb->m_Status_Pcb = 0 ; + module->m_Flags = 0; + module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ; + + /* calcul de la nouvelle position du Module */ + Nx = module->m_Pos.x; Ny = module->m_Pos.y; + RotatePoint(&Nx, &Ny, centerX, centerY, 900 ); + GetScreen()->m_Curseur.x = Nx ; + GetScreen()->m_Curseur.y = Ny ; + Place_Module(module, DC); + + /* Rotation du module autour de son ancre */ + Rotate_Module(DC, module, Angle_Rot_Module, TRUE); + + } + /* regeneration des valeurs originelles */ + GetScreen()->m_Curseur = oldpos; + } + + /* Deplacement des Segments de piste */ + if(Block_Include_Tracks ) + { + TRACK * track; + + Affiche_Message( _("Track rotation") ); + track = m_Pcb->m_Track; + while( track ) + { + if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + m_Pcb->m_Status_Pcb = 0 ; + track->Draw(DrawPanel, DC, GR_XOR) ; // effacement + RotatePoint( &track->m_Start.x, &track->m_Start.y, centerX, centerY, 900); + RotatePoint( &track->m_End.x, &track->m_End.y, centerX, centerY, 900); + track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage + } + track = track->Next(); + } + } + + /* Deplacement des Segments de Zone */ + if( Block_Include_Zones ) + { + TRACK * track; + + Affiche_Message( _("Zone rotation") ); + track = (TRACK*) m_Pcb->m_Zone; + while( track ) + { + if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + track->Draw(DrawPanel, DC, GR_XOR) ; // effacement + RotatePoint( &track->m_Start.x, &track->m_Start.y, centerX, centerY, 900); + RotatePoint( &track->m_End.x, &track->m_End.y, centerX, centerY, 900); + track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage + } + track = track->Next(); + } + } + + masque_layer = EDGE_LAYER; + if( Block_Include_Draw_Items ) masque_layer = ALL_LAYERS; + if( ! Block_Include_Edges_Items ) masque_layer &= ~EDGE_LAYER; + + Affiche_Message( _("Draw layers rotation") ); + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + #undef STRUCT + #define STRUCT ((DRAWSEGMENT*)PtStruct) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* l'element est ici bon a etre efface */ + Trace_DrawSegmentPcb(DrawPanel, DC, (DRAWSEGMENT*)PtStruct,GR_XOR) ; + RotatePoint( &STRUCT->m_Start.x, &STRUCT->m_Start.y, centerX, centerY, 900); + RotatePoint( &STRUCT->m_End.x, &STRUCT->m_End.y, centerX, centerY, 900); + Trace_DrawSegmentPcb(DrawPanel, DC, (DRAWSEGMENT*)PtStruct,GR_OR) ; + break; + + case TYPETEXTE: + #undef STRUCT + #define STRUCT ((TEXTE_PCB*) PtStruct) + if( ! Block_Include_PcbTextes ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* le texte est ici bon a etre deplace */ + ((TEXTE_PCB*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); + /* Redessin du Texte */ + RotatePoint( &STRUCT->m_Pos.x, &STRUCT->m_Pos.y, centerX, centerY, 900); + STRUCT->m_Orient += 900; + if( STRUCT->m_Orient >= 3600) STRUCT->m_Orient -= 3600; + + STRUCT->CreateDrawData(); + ((TEXTE_PCB*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR); + break; + + case TYPEMIRE: + #undef STRUCT + #define STRUCT ((MIREPCB*) PtStruct) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* l'element est ici bon a etre modifie */ + ((MIREPCB*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR) ; + RotatePoint(&STRUCT->m_Pos.x, &STRUCT->m_Pos.y, centerX, centerY, 900 ); + ((MIREPCB*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_OR) ; + break; + + case TYPECOTATION: + #undef STRUCT + #define STRUCT ((COTATION*) PtStruct) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* l'element est ici bon a etre modifie */ + ((COTATION*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR) ; + + RotatePoint(&STRUCT->m_Pos.x, &STRUCT->m_Pos.y, centerX, centerY, 900 ); + + RotatePoint(&STRUCT->m_Text->m_Pos.x, &STRUCT->m_Text->m_Pos.y, + centerX, centerY, 900 ); + STRUCT->m_Text->m_Orient += 900; + if( STRUCT->m_Text->m_Orient >= 3600 ) + STRUCT->m_Text->m_Orient -= 3600; + if( (STRUCT->m_Text->m_Orient > 900) && + (STRUCT->m_Text->m_Orient <2700) ) + STRUCT->m_Text->m_Orient -= 1800; + + RotatePoint(&STRUCT->Barre_ox, &STRUCT->Barre_oy, centerX, centerY, 900 ); + RotatePoint(&STRUCT->Barre_fx, &STRUCT->Barre_fy, centerX, centerY, 900 ); + RotatePoint(&STRUCT->TraitG_ox, &STRUCT->TraitG_oy, centerX, centerY, 900 ); + RotatePoint(&STRUCT->TraitG_fx, &STRUCT->TraitG_fy, centerX, centerY, 900 ); + RotatePoint(&STRUCT->TraitD_ox, &STRUCT->TraitD_oy, centerX, centerY, 900 ); + RotatePoint(&STRUCT->TraitD_fx, &STRUCT->TraitD_fy, centerX, centerY, 900 ); + RotatePoint(&STRUCT->FlecheG1_ox, &STRUCT->FlecheG1_oy, centerX, centerY, 900 ); + RotatePoint(&STRUCT->FlecheG1_fx, &STRUCT->FlecheG1_fy, centerX, centerY, 900 ); + RotatePoint(&STRUCT->FlecheG2_ox, &STRUCT->FlecheG2_oy, centerX, centerY, 900 ); + RotatePoint(&STRUCT->FlecheG2_fx, &STRUCT->FlecheG2_fy, centerX, centerY, 900 ); + RotatePoint(&STRUCT->FlecheD1_ox, &STRUCT->FlecheD1_oy, centerX, centerY, 900 ); + RotatePoint(&STRUCT->FlecheD1_fx, &STRUCT->FlecheD1_fy, centerX, centerY, 900 ); + RotatePoint(&STRUCT->FlecheD2_ox, &STRUCT->FlecheD2_oy, centerX, centerY, 900 ); + RotatePoint(&STRUCT->FlecheD2_fx, &STRUCT->FlecheD2_fy, centerX, centerY, 900 ); + ((COTATION*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_OR) ; + break; + + default: break; + } + } + RedrawActiveWindow(DC, TRUE) ; +} + + + +/*****************************************************/ +void WinEDA_BasePcbFrame::Block_Invert(wxDC * DC) +/*****************************************************/ +/* + routine d'inversion miroir deg du block deja selectionne + les elements sont inverse / axe horizontal, + l'axe d'inversion est la mediane horizontale du block +*/ +#define INVERT(pos) (pos) = centerY - ((pos) - centerY) +#define INVERT_ANGLE(phi) (phi) = -(phi) +{ +MODULE * module; +EDA_BaseStruct * PtStruct; +int masque_layer; +wxPoint memo; +int Ny, centerY; /* position de l'axe d'inversion de l'ensemble des elements */ + + if( ! InstallBlockCmdFrame(this, _("Block mirroring")) ) return ; + + memo = GetScreen()->m_Curseur; + GetScreen()->BlockLocate.Normalize(); + + /* calcul du centre d'inversion */ + centerY = GetScreen()->BlockLocate.Centre().y; + + GetScreen()->SetModify(); + + /* Inversion des modules */ + if ( Block_Include_Modules ) + { + Affiche_Message( _("Footprint mirroring") ); + module = m_Pcb->m_Modules; + for ( ; module != NULL; module = (MODULE*) module->Pnext) + { + if( IsModuleInBox(GetScreen()->BlockLocate, module) == NULL ) continue; + /* le module est ici bon a etre efface */ + m_Pcb->m_Status_Pcb = 0 ; + module->m_Flags = 0; + module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ; + + /* calcul de la nouvelle position du Module */ + Ny = module->m_Pos.y; + INVERT(Ny); + GetScreen()->m_Curseur.x = module->m_Pos.x; + GetScreen()->m_Curseur.y = Ny ; + Place_Module(module, DC); + + /* inversion du module */ + Change_Side_Module(module, DC); + + /* regeneration des valeurs originelles */ + GetScreen()->m_Curseur = memo; + } + } + + /* Deplacement des Segments de piste */ + if(Block_Include_Tracks ) + { + TRACK * track; + + Affiche_Message( _("Track mirroring") ); + track = m_Pcb->m_Track; + while( track ) + { + if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + m_Pcb->m_Status_Pcb = 0 ; + track->Draw(DrawPanel, DC, GR_XOR) ; // effacement + INVERT(track->m_Start.y); + INVERT(track->m_End.y); + if( track->m_StructType != TYPEVIA ) + { + track->m_Layer = ChangeSideNumLayer(track->m_Layer); + } + + track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage + } + track = (TRACK*) track->Pnext; + } + } + + /* Deplacement des Segments de Zone */ + if( Block_Include_Zones ) + { + TRACK * track; + + Affiche_Message( _("Zone mirroring") ); + track = (TRACK*)m_Pcb->m_Zone; + while( track ) + { + if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + track->Draw(DrawPanel, DC, GR_XOR) ; // effacement + INVERT(track->m_Start.y); + INVERT(track->m_End.y); + track->m_Layer = ChangeSideNumLayer(track->m_Layer); + track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage + } + track = (TRACK*) track->Pnext; + } + } + + masque_layer = EDGE_LAYER; + if( Block_Include_Draw_Items ) masque_layer = ALL_LAYERS; + if( ! Block_Include_Edges_Items ) masque_layer &= ~EDGE_LAYER; + + Affiche_Message( _("Draw layers mirroring") ); + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + #undef STRUCT + #define STRUCT ((DRAWSEGMENT*)PtStruct) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* l'element est ici bon a etre selectionne */ + Trace_DrawSegmentPcb(DrawPanel, DC, (DRAWSEGMENT*)PtStruct,GR_XOR) ; + if ( STRUCT->m_Shape == S_ARC ) + { + INVERT_ANGLE(STRUCT->m_Angle); + } + INVERT(STRUCT->m_Start.y); + INVERT(STRUCT->m_End.y); + STRUCT->m_Layer = ChangeSideNumLayer(STRUCT->m_Layer); + Trace_DrawSegmentPcb(DrawPanel, DC, (DRAWSEGMENT*)PtStruct,GR_OR) ; + break; + + case TYPETEXTE: + #undef STRUCT + #define STRUCT ((TEXTE_PCB*) PtStruct) + if( ! Block_Include_PcbTextes ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* le texte est ici bon a etre selectionne*/ + ((TEXTE_PCB*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); + /* Redessin du Texte */ + INVERT(STRUCT->m_Pos.y); + INVERT_ANGLE(STRUCT->m_Orient); + if( (STRUCT->m_Layer == CUIVRE_N) || (STRUCT->m_Layer == CMP_N) ) + { + STRUCT->m_Miroir ^= 1; /* inverse miroir */ + } + STRUCT->m_Layer = ChangeSideNumLayer(STRUCT->m_Layer); + STRUCT->CreateDrawData(); + ((TEXTE_PCB*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR); + break; + + case TYPEMIRE: + #undef STRUCT + #define STRUCT ((MIREPCB*) PtStruct) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* l'element est ici bon a etre modifie */ + ((MIREPCB*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0),GR_XOR) ; + INVERT(STRUCT->m_Pos.y); + STRUCT->m_Layer = ChangeSideNumLayer(STRUCT->m_Layer); + ((MIREPCB*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0),GR_OR) ; + break; + + case TYPECOTATION: + #undef STRUCT + #define STRUCT ((COTATION*) PtStruct) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* l'element est ici bon a etre modifie */ + ((COTATION*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR) ; + + INVERT(STRUCT->m_Pos.y); + INVERT(STRUCT->m_Text->m_Pos.y); + INVERT_ANGLE(STRUCT->m_Text->m_Orient); + if( STRUCT->m_Text->m_Orient >= 3600 ) + STRUCT->m_Text->m_Orient -= 3600; + if( (STRUCT->m_Text->m_Orient > 900) && + (STRUCT->m_Text->m_Orient <2700) ) + STRUCT->m_Text->m_Orient -= 1800; + + INVERT(STRUCT->Barre_oy); + INVERT(STRUCT->Barre_fy); + INVERT(STRUCT->TraitG_oy); + INVERT(STRUCT->TraitG_fy); + INVERT(STRUCT->TraitD_oy); + INVERT(STRUCT->TraitD_fy); + INVERT(STRUCT->FlecheG1_oy); + INVERT(STRUCT->FlecheG1_fy); + INVERT(STRUCT->FlecheG2_oy); + INVERT(STRUCT->FlecheG2_fy); + INVERT(STRUCT->FlecheD1_oy); + INVERT(STRUCT->FlecheD1_fy); + INVERT(STRUCT->FlecheD2_oy); + INVERT(STRUCT->FlecheD2_fy); + + STRUCT->m_Layer = ChangeSideNumLayer(STRUCT->m_Layer); + + ((COTATION*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ; + break; + + default: break; + } + } + RedrawActiveWindow(DC, TRUE) ; +} + + + +/************************************************/ +void WinEDA_BasePcbFrame::Block_Move(wxDC * DC) +/************************************************/ +/* + routine de deplacement des elements du block deja selectionne +*/ +{ +MODULE * module; +EDA_BaseStruct * PtStruct; +int masque_layer; +int deltaX, deltaY; +wxPoint oldpos; + + oldpos = GetScreen()->m_Curseur; + DrawPanel->ManageCurseur = NULL; + + if( ! InstallBlockCmdFrame(this, _("Move Block") ) ) return ; + + GetScreen()->m_Curseur = oldpos; + DrawPanel->MouseToCursorSchema(); + GetScreen()->SetModify(); + GetScreen()->BlockLocate.Normalize(); + + /* Deplacement des modules */ + if ( Block_Include_Modules ) + { + Affiche_Message( _("Move footprints") ); + module = m_Pcb->m_Modules; + oldpos = GetScreen()->m_Curseur; + + for ( ; module != NULL; module = (MODULE*) module->Pnext) + { + if( IsModuleInBox(GetScreen()->BlockLocate, module) == NULL ) continue; + /* le module est ici bon a etre deplace */ + m_Pcb->m_Status_Pcb = 0 ; + module->m_Flags = 0; + module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ; + + /* calcul du deplacement pour la routine Place_Module */ + /* calcul du vecteur de deplacement */ + GetScreen()->m_Curseur.x = module->m_Pos.x + GetScreen()->BlockLocate.m_MoveVector.x; + GetScreen()->m_Curseur.y = module->m_Pos.y + GetScreen()->BlockLocate.m_MoveVector.y; + Place_Module(module, DC); + } + GetScreen()->m_Curseur = oldpos; + } + + /* calcul du vecteur de deplacement pour les deplacements suivants */ + deltaX = GetScreen()->BlockLocate.m_MoveVector.x ; + deltaY = GetScreen()->BlockLocate.m_MoveVector.y ; + + /* Deplacement des Segments de piste */ + if(Block_Include_Tracks ) + { + TRACK * track; + + Affiche_Message( _("Move tracks") ); + track = m_Pcb->m_Track; + while( track ) + { + if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + m_Pcb->m_Status_Pcb = 0 ; + track->Draw(DrawPanel, DC, GR_XOR) ; // effacement + track->m_Start.x += deltaX ; track->m_Start.y += deltaY ; + track->m_End.x += deltaX ; track->m_End.y += deltaY ; + track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage + } + track = (TRACK*) track->Pnext; + } + } + + /* Deplacement des Segments de Zone */ + if( Block_Include_Zones ) + { + TRACK * track; + + Affiche_Message( _("Move zones") ); + track = (TRACK*)m_Pcb->m_Zone; + while( track ) + { + if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + track->Draw(DrawPanel, DC, GR_XOR) ; // effacement + track->m_Start.x += deltaX ; track->m_Start.y += deltaY ; + track->m_End.x += deltaX ; track->m_End.y += deltaY ; + track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage + } + track = (TRACK*) track->Pnext; + } + } + + masque_layer = EDGE_LAYER; + if( Block_Include_Draw_Items ) masque_layer = ALL_LAYERS; + if( ! Block_Include_Edges_Items ) masque_layer &= ~EDGE_LAYER; + + Affiche_Message( _("Move draw layers") ); + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + #undef STRUCT + #define STRUCT ((DRAWSEGMENT*)PtStruct) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* l'element est ici bon a etre efface */ + Trace_DrawSegmentPcb(DrawPanel, DC, STRUCT,GR_XOR) ; + STRUCT->m_Start.x += deltaX; STRUCT->m_Start.y += deltaY; + STRUCT->m_End.x += deltaX; STRUCT->m_End.y += deltaY; + Trace_DrawSegmentPcb(DrawPanel, DC, STRUCT,GR_OR) ; + break; + + case TYPETEXTE: + #undef STRUCT + #define STRUCT ((TEXTE_PCB*) PtStruct) + if( ! Block_Include_PcbTextes ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* le texte est ici bon a etre deplace */ + STRUCT->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); + /* Redessin du Texte */ + STRUCT->m_Pos.x += deltaX; STRUCT->m_Pos.y += deltaY; + ((TEXTE_PCB*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR); + break; + + case TYPEMIRE: + #undef STRUCT + #define STRUCT ((MIREPCB*) PtStruct) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* l'element est ici bon a etre efface */ + ((MIREPCB*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0),GR_XOR) ; + STRUCT->m_Pos.x += deltaX; STRUCT->m_Pos.y += deltaY; + ((MIREPCB*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0, 0),GR_OR) ; + break; + + case TYPECOTATION: + #undef STRUCT + #define STRUCT ((COTATION*) PtStruct) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* l'element est ici bon a etre efface */ + ((COTATION*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR) ; + STRUCT->m_Pos.x += deltaX; + STRUCT->m_Pos.y += deltaY; + STRUCT->m_Text->m_Pos.x += deltaX; + STRUCT->m_Text->m_Pos.y += deltaY; + STRUCT->Barre_ox += deltaX; STRUCT->Barre_oy += deltaY; + STRUCT->Barre_fx += deltaX; STRUCT->Barre_fy += deltaY; + STRUCT->TraitG_ox += deltaX; STRUCT->TraitG_oy += deltaY; + STRUCT->TraitG_fx += deltaX; STRUCT->TraitG_fy += deltaY; + STRUCT->TraitD_ox += deltaX; STRUCT->TraitD_oy += deltaY; + STRUCT->TraitD_fx += deltaX; STRUCT->TraitD_fy += deltaY; + STRUCT->FlecheG1_ox += deltaX; STRUCT->FlecheG1_oy += deltaY; + STRUCT->FlecheG1_fx += deltaX; STRUCT->FlecheG1_fy += deltaY; + STRUCT->FlecheG2_ox += deltaX; STRUCT->FlecheG2_oy += deltaY; + STRUCT->FlecheG2_fx += deltaX; STRUCT->FlecheG2_fy += deltaY; + STRUCT->FlecheD1_ox += deltaX; STRUCT->FlecheD1_oy += deltaY; + STRUCT->FlecheD1_fx += deltaX; STRUCT->FlecheD1_fy += deltaY; + STRUCT->FlecheD2_ox += deltaX; STRUCT->FlecheD2_oy += deltaY; + STRUCT->FlecheD2_fx += deltaX; STRUCT->FlecheD2_fy += deltaY; + ((COTATION*)PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0),GR_OR) ; + break; + + default: break; + } + } + DrawPanel->Refresh(TRUE);; +} + + +/**************************************************/ +void WinEDA_BasePcbFrame::Block_Duplicate(wxDC * DC) +/**************************************************/ +/* + routine de duplication des elements du block deja selectionne +*/ +{ +MODULE * module; +EDA_BaseStruct * PtStruct; +int masque_layer; +int deltaX, deltaY; +wxPoint oldpos; + + oldpos = GetScreen()->m_Curseur; + DrawPanel->ManageCurseur = NULL; + + if( ! InstallBlockCmdFrame(this, _("Copy Block") ) ) return ; + + GetScreen()->m_Curseur = oldpos; + DrawPanel->MouseToCursorSchema(); + GetScreen()->SetModify(); + GetScreen()->BlockLocate.Normalize(); + + /* Module copy */ + if ( Block_Include_Modules ) + { + Affiche_Message( _("Module copy") ); + module = m_Pcb->m_Modules; + oldpos = GetScreen()->m_Curseur; + + for ( ; module != NULL; module = (MODULE*) module->Pnext) + { + MODULE * new_module; + if( IsModuleInBox(GetScreen()->BlockLocate, module) == NULL ) continue; + /* le module est ici bon a etre deplace */ + m_Pcb->m_Status_Pcb = 0 ; + module->m_Flags = 0; + new_module = new MODULE(m_Pcb); + new_module->Copy(module); + new_module->m_TimeStamp = GetTimeStamp(); + new_module->Pnext = m_Pcb->m_Modules; + new_module->Pback = m_Pcb; + m_Pcb->m_Modules->Pback = new_module; + m_Pcb->m_Modules = new_module; + /* calcul du deplacement pour la routine Place_Module */ + /* calcul du vecteur de deplacement */ + GetScreen()->m_Curseur.x = module->m_Pos.x + GetScreen()->BlockLocate.m_MoveVector.x; + GetScreen()->m_Curseur.y = module->m_Pos.y + GetScreen()->BlockLocate.m_MoveVector.y; + Place_Module(new_module, DC); + } + GetScreen()->m_Curseur = oldpos; + } + + /* calcul du vecteur de deplacement pour les deplacements suivants */ + deltaX = GetScreen()->BlockLocate.m_MoveVector.x ; + deltaY = GetScreen()->BlockLocate.m_MoveVector.y ; + + /* Deplacement des Segments de piste */ + if(Block_Include_Tracks ) + { + TRACK * track, *next_track, *new_track; + + Affiche_Message( _("Track copy") ); + track = m_Pcb->m_Track; + while( track ) + { + next_track = track->Next(); + if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + m_Pcb->m_Status_Pcb = 0 ; + new_track = track->Copy(1); + new_track->Insert(m_Pcb,NULL); + new_track->m_Start.x += deltaX ; new_track->m_Start.y += deltaY ; + new_track->m_End.x += deltaX ; new_track->m_End.y += deltaY ; + new_track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage + } + track = next_track; + } + } + + /* Deplacement des Segments de Zone */ + if( Block_Include_Zones ) + { + TRACK * track, *next_track, *new_track; + + Affiche_Message( _("Zone copy") ); + track = (TRACK*)m_Pcb->m_Zone; + while( track ) + { + next_track = track->Next(); + if( IsSegmentInBox(GetScreen()->BlockLocate, track ) ) + { /* la piste est ici bonne a etre deplacee */ + new_track = new TRACK(m_Pcb); + new_track = track->Copy(1); + new_track->Insert(m_Pcb,NULL); + new_track->m_Start.x += deltaX ; new_track->m_Start.y += deltaY ; + new_track->m_End.x += deltaX ; new_track->m_End.y += deltaY ; + new_track->Draw(DrawPanel, DC, GR_OR) ; // reaffichage + } + track = next_track; + } + } + + masque_layer = EDGE_LAYER; + if( Block_Include_Draw_Items ) masque_layer = ALL_LAYERS; + if( ! Block_Include_Edges_Items ) masque_layer &= ~EDGE_LAYER; + + Affiche_Message( _("Draw layers copy") ); + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + { + #undef STRUCT + #define STRUCT ((DRAWSEGMENT*)PtStruct) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* l'element est ici bon a etre copie */ + DRAWSEGMENT * new_drawsegment = new DRAWSEGMENT (m_Pcb); + new_drawsegment->Copy(STRUCT); + new_drawsegment->Pnext = m_Pcb->m_Drawings; + new_drawsegment->Pback = m_Pcb; + m_Pcb->m_Drawings->Pback = new_drawsegment; + m_Pcb->m_Drawings = new_drawsegment; + new_drawsegment->m_Start.x += deltaX; new_drawsegment->m_Start.y += deltaY; + new_drawsegment->m_End.x += deltaX; new_drawsegment->m_End.y += deltaY; + Trace_DrawSegmentPcb(DrawPanel, DC, new_drawsegment,GR_OR) ; + break; + } + + case TYPETEXTE: + { + #undef STRUCT + #define STRUCT ((TEXTE_PCB*) PtStruct) + if( ! Block_Include_PcbTextes ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* le texte est ici bon a etre deplace */ + TEXTE_PCB * new_pcbtext = new TEXTE_PCB(m_Pcb); + new_pcbtext->Copy(STRUCT); + new_pcbtext->Pnext = m_Pcb->m_Drawings; + new_pcbtext->Pback = m_Pcb; + m_Pcb->m_Drawings->Pback = new_pcbtext; + m_Pcb->m_Drawings = new_pcbtext; + /* Redessin du Texte */ + new_pcbtext->m_Pos.x += deltaX; new_pcbtext->m_Pos.y += deltaY; + new_pcbtext->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR); + break; + } + + case TYPEMIRE: + { + #undef STRUCT + #define STRUCT ((MIREPCB*) PtStruct) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* l'element est ici bon a etre efface */ + MIREPCB * new_mire = new MIREPCB(m_Pcb); + new_mire->Copy(STRUCT); + new_mire->Pnext = m_Pcb->m_Drawings; + new_mire->Pback = m_Pcb; + m_Pcb->m_Drawings->Pback = new_mire; + m_Pcb->m_Drawings = new_mire; + new_mire->m_Pos.x += deltaX; new_mire->m_Pos.y += deltaY; + new_mire->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR) ; + break; + } + + case TYPECOTATION: + { + #undef STRUCT + #define STRUCT ((COTATION*) PtStruct) + if( (g_TabOneLayerMask[STRUCT->m_Layer] & masque_layer) == 0 ) break; + if(IsStructInBox(GetScreen()->BlockLocate, PtStruct ) == NULL ) break; + /* l'element est ici bon a etre copie */ + COTATION * new_cotation = new COTATION(m_Pcb); + new_cotation->Copy(STRUCT); + new_cotation->Pnext = m_Pcb->m_Drawings; + new_cotation->Pback = m_Pcb; + m_Pcb->m_Drawings->Pback = new_cotation; + m_Pcb->m_Drawings = new_cotation; + new_cotation->m_Pos.x += deltaX; + new_cotation->m_Pos.y += deltaY; + new_cotation->m_Text->m_Pos.x += deltaX; + new_cotation->m_Text->m_Pos.y += deltaY; + new_cotation->Barre_ox += deltaX; new_cotation->Barre_oy += deltaY; + new_cotation->Barre_fx += deltaX; new_cotation->Barre_fy += deltaY; + new_cotation->TraitG_ox += deltaX; new_cotation->TraitG_oy += deltaY; + new_cotation->TraitG_fx += deltaX; new_cotation->TraitG_fy += deltaY; + new_cotation->TraitD_ox += deltaX; new_cotation->TraitD_oy += deltaY; + new_cotation->TraitD_fx += deltaX; new_cotation->TraitD_fy += deltaY; + new_cotation->FlecheG1_ox += deltaX; new_cotation->FlecheG1_oy += deltaY; + new_cotation->FlecheG1_fx += deltaX; new_cotation->FlecheG1_fy += deltaY; + new_cotation->FlecheG2_ox += deltaX; new_cotation->FlecheG2_oy += deltaY; + new_cotation->FlecheG2_fx += deltaX; new_cotation->FlecheG2_fy += deltaY; + new_cotation->FlecheD1_ox += deltaX; new_cotation->FlecheD1_oy += deltaY; + new_cotation->FlecheD1_fx += deltaX; new_cotation->FlecheD1_fy += deltaY; + new_cotation->FlecheD2_ox += deltaX; new_cotation->FlecheD2_oy += deltaY; + new_cotation->FlecheD2_fx += deltaX; new_cotation->FlecheD2_fy += deltaY; + new_cotation->Draw(DrawPanel, DC, wxPoint(0,0),GR_OR) ; + break; + } + + default: break; + } + } +} + + +/*******************************************************************/ +static EDA_BaseStruct * IsStructInBox(DrawBlockStruct & blocklocate, + EDA_BaseStruct * PtStruct ) +/******************************************************************/ +/* Teste si la structure PtStruct est inscrite dans le block selectionne +*/ +{ + switch ( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + #undef STRUCT + #define STRUCT ((DRAWSEGMENT*)PtStruct) + if( ! blocklocate.Inside( STRUCT->m_Start.x, STRUCT->m_Start.y) ) return(NULL); + if( ! blocklocate.Inside(STRUCT->m_End.x, STRUCT->m_End.y) ) return(NULL); + return(PtStruct); + + case TYPETEXTE: + #undef STRUCT + #define STRUCT ((TEXTE_PCB*) PtStruct) + if ( ! blocklocate.Inside(STRUCT->m_Pos.x, STRUCT->m_Pos.y) ) return(NULL); + return(PtStruct); + + case TYPEMIRE: + #undef STRUCT + #define STRUCT ((MIREPCB*) PtStruct) + if( ! blocklocate.Inside( STRUCT->m_Pos.x, STRUCT->m_Pos.y) ) return(NULL); + return(PtStruct); + + case TYPECOTATION: + #undef STRUCT + #define STRUCT ((COTATION*) PtStruct) + if ( ! blocklocate.Inside( STRUCT->m_Pos.x, STRUCT->m_Pos.y) ) return(NULL); + return(PtStruct); + + default: return(NULL); + } + return(NULL); +} + + +/**************************************************************************/ +static TRACK * IsSegmentInBox( DrawBlockStruct & blocklocate, TRACK * PtSegm ) +/**************************************************************************/ +/* Teste si la structure PtStruct est inscrite dans le block selectionne + Retourne PtSegm si oui + NULL si non +*/ +{ + if ( blocklocate.Inside(PtSegm->m_Start.x ,PtSegm->m_Start.y) ) + return ( PtSegm ); + + if ( blocklocate.Inside(PtSegm->m_End.x, PtSegm->m_End.y) ) + return ( PtSegm ); + + return ( NULL ); +} + +/****************************************************************************/ +static MODULE * IsModuleInBox( DrawBlockStruct& blocklocate, MODULE * Module ) +/****************************************************************************/ +/* Teste si le Module est inscrit dans le block selectionne + Retourne Module si oui + NULL si non +*/ +{ +bool is_out_of_box = FALSE; + + Module->SetRectangleExinscrit(); + + if ( Module->m_RealBoundaryBox.m_Pos.x < blocklocate.GetX() ) + is_out_of_box = TRUE; + if ( Module->m_RealBoundaryBox.m_Pos.y < blocklocate.GetY() ) + is_out_of_box = TRUE; + if ( Module->m_RealBoundaryBox.GetRight() > blocklocate.GetRight() ) + is_out_of_box = TRUE; + if ( Module->m_RealBoundaryBox.GetBottom() > blocklocate.GetBottom() ) + is_out_of_box = TRUE; + + if (is_out_of_box) return ( NULL ); + return ( Module ); +} + diff --git a/pcbnew/block_module_editor.cpp b/pcbnew/block_module_editor.cpp new file mode 100644 index 0000000000..114e99afb8 --- /dev/null +++ b/pcbnew/block_module_editor.cpp @@ -0,0 +1,680 @@ +/****************************************************/ +/* block_module_editor.cpp */ +/* Handle block commands for the footprint editor */ +/****************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "pcbplot.h" +#include "trigo.h" + +#include "protos.h" + + +#define BLOCK_COLOR BROWN +#define IS_SELECTED 1 + +/* Variables Locales */ + +/* Fonctions exportees */ + +/* Fonctions Locales */ +static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static int MarkItemsInBloc(MODULE * module, + EDA_Rect & Rect); + +static void ClearMarkItems(MODULE * module); +static void CopyMarkedItems(MODULE *module, wxPoint offset); +static void MoveMarkedItems(MODULE *module, wxPoint offset); +static void MirrorMarkedItems(MODULE *module, wxPoint offset); +static void RotateMarkedItems(MODULE *module, wxPoint offset); +static void DeleteMarkedItems(MODULE *module); + + +/*************************************************************************/ +int WinEDA_ModuleEditFrame::ReturnBlockCommand(int key) +/*************************************************************************/ +/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to + the key (ALT, SHIFT ALT ..) pressed when dragging mouse and left or middle button + pressed +*/ +{ +int cmd; + + switch ( key ) + { + default: + cmd = key & 0x255; + break; + + case -1: + cmd = BLOCK_PRESELECT_MOVE; + break; + + case 0: + cmd = BLOCK_MOVE; + break; + + case GR_KB_ALT: + cmd = BLOCK_MIRROR_Y; + break; + + case GR_KB_SHIFTCTRL: + cmd = BLOCK_DELETE; + break; + + case GR_KB_SHIFT: + cmd = BLOCK_COPY; + break; + + case GR_KB_CTRL: + cmd = BLOCK_ROTATE; + break; + + case MOUSE_MIDDLE: + cmd = BLOCK_ZOOM; + break; + } + + return cmd; +} + + +/****************************************************/ +int WinEDA_ModuleEditFrame::HandleBlockEnd(wxDC * DC) +/****************************************************/ +/* Command BLOCK END (end of block sizing) + return : + 0 if command finished (zoom, delete ...) + 1 if HandleBlockPlace must follow (items found, and a block place command must follow) +*/ +{ +int ItemsCount = 0, MustDoPlace = 0; +MODULE * Currentmodule = m_Pcb->m_Modules; + + if ( GetScreen()->BlockLocate.m_BlockDrawStruct ) + { + BlockState state = GetScreen()->BlockLocate.m_State; + CmdBlockType command = GetScreen()->BlockLocate.m_Command; + DrawPanel->ForceCloseManageCurseur(DrawPanel, DC); + GetScreen()->BlockLocate.m_State = state; + GetScreen()->BlockLocate.m_Command = command; + DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines; + DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand; + GetScreen()->m_Curseur.x = GetScreen()->BlockLocate.GetRight(); + GetScreen()->m_Curseur.y = GetScreen()->BlockLocate.GetBottom(); + DrawPanel->MouseToCursorSchema(); + } + + switch( GetScreen()->BlockLocate.m_Command ) + { + case BLOCK_IDLE: + DisplayError(this, wxT("Error in HandleBlockPLace") ); + break; + + case BLOCK_DRAG: /* Drag */ + case BLOCK_MOVE: /* Move */ + case BLOCK_COPY: /* Copy */ + ItemsCount = MarkItemsInBloc(Currentmodule, GetScreen()->BlockLocate); + if ( ItemsCount ) + { + MustDoPlace = 1; + if(DrawPanel->ManageCurseur != NULL) + { + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + } + GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; + DrawPanel->Refresh(TRUE); + } + break; + + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + MustDoPlace = 1; + DrawPanel->ManageCurseur = DrawMovingBlockOutlines; + GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; + break; + + case BLOCK_DELETE: /* Delete */ + ItemsCount = MarkItemsInBloc(Currentmodule, GetScreen()->BlockLocate); + if ( ItemsCount ) SaveCopyInUndoList(Currentmodule); + DeleteMarkedItems(Currentmodule); + break; + + case BLOCK_SAVE: /* Save */ + case BLOCK_PASTE: + break; + + case BLOCK_ROTATE: + ItemsCount = MarkItemsInBloc(Currentmodule, GetScreen()->BlockLocate); + if ( ItemsCount ) SaveCopyInUndoList(Currentmodule); + RotateMarkedItems(Currentmodule, GetScreen()->BlockLocate.Centre()); + break; + + + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: + case BLOCK_INVERT: /* mirror */ + ItemsCount = MarkItemsInBloc(Currentmodule, GetScreen()->BlockLocate); + if ( ItemsCount ) SaveCopyInUndoList(Currentmodule); + MirrorMarkedItems(Currentmodule, GetScreen()->BlockLocate.Centre()); + break; + + case BLOCK_ZOOM: /* Window Zoom */ + Window_Zoom( GetScreen()->BlockLocate ); + break; + + case BLOCK_ABORT: + break; + + case BLOCK_SELECT_ITEMS_ONLY: + break; + } + + if ( MustDoPlace <= 0 ) + { + if ( GetScreen()->BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY ) + { + ClearMarkItems(Currentmodule); + } + GetScreen()->BlockLocate.m_Flags = 0; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->m_CurrentItem = NULL; + SetToolID(m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); + DrawPanel->Refresh(TRUE); + } + + + return(MustDoPlace); +} + + +/******************************************************/ +void WinEDA_ModuleEditFrame::HandleBlockPlace(wxDC * DC) +/******************************************************/ +/* Routine to handle the BLOCK PLACE commande + Last routine for block operation for: + - block move & drag + - block copie & paste +*/ +{ +bool err = FALSE; +MODULE * Currentmodule = m_Pcb->m_Modules; + + if(DrawPanel->ManageCurseur == NULL) + { + err = TRUE; + DisplayError(this, wxT("HandleBlockPLace : ManageCurseur = NULL") ); + } + + GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; + + switch(GetScreen()->BlockLocate.m_Command ) + { + case BLOCK_IDLE: + err = TRUE; + break; + + case BLOCK_DRAG: /* Drag */ + case BLOCK_MOVE: /* Move */ + case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + SaveCopyInUndoList(Currentmodule); + MoveMarkedItems(Currentmodule, GetScreen()->BlockLocate.m_MoveVector); + DrawPanel->Refresh(TRUE); + break; + + case BLOCK_COPY: /* Copy */ + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + SaveCopyInUndoList(Currentmodule); + CopyMarkedItems(Currentmodule, GetScreen()->BlockLocate.m_MoveVector); + break; + + case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */ + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + break; + + case BLOCK_MIRROR_X: + case BLOCK_MIRROR_Y: + case BLOCK_INVERT: /* Mirror by popup menu, from block move */ + SaveCopyInUndoList(Currentmodule); + MirrorMarkedItems(Currentmodule, GetScreen()->BlockLocate.Centre()); + break; + + case BLOCK_ROTATE: + SaveCopyInUndoList(Currentmodule); + RotateMarkedItems(Currentmodule, GetScreen()->BlockLocate.Centre()); + break; + + case BLOCK_ZOOM: // Handled by HandleBlockEnd + case BLOCK_DELETE: + case BLOCK_SAVE: + case BLOCK_ABORT: + default: + break; + } + + GetScreen()->SetModify(); + + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->BlockLocate.m_Flags = 0; + GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; + GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; + GetScreen()->m_CurrentItem = NULL; + DrawPanel->Refresh(TRUE); + + SetToolID(m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); +} + + +/************************************************************************/ +static void DrawMovingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, + bool erase ) +/************************************************************************/ +/* Retrace le contour du block de recherche de structures + L'ensemble du block suit le curseur +*/ +{ +DrawBlockStruct * PtBlock; +BASE_SCREEN * screen = panel->m_Parent->GetScreen(); +EDA_BaseStruct * item; +wxPoint move_offset; +MODULE * Currentmodule = EDA_Appl->m_ModuleEditFrame->m_Pcb->m_Modules; + + PtBlock = &panel->GetScreen()->BlockLocate; + GRSetDrawMode(DC, g_XorMode); + + /* Effacement ancien cadre */ + if( erase ) + { + PtBlock->Offset(PtBlock->m_MoveVector); + PtBlock->Draw(panel, DC); + PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y); + + if ( Currentmodule ) + { + move_offset.x = - PtBlock->m_MoveVector.x; + move_offset.y = - PtBlock->m_MoveVector.y; + item = Currentmodule->m_Drawings; + for ( ; item != NULL; item = item->Next() ) + { + if ( item->m_Selected == 0 ) continue; + switch( item->m_StructType ) + { + case TYPETEXTEMODULE: + ((TEXTE_MODULE *) item)->Draw(panel, DC, move_offset, g_XorMode); + break; + + case TYPEEDGEMODULE: + ((EDGE_MODULE *) item)->Draw(panel, DC, move_offset, g_XorMode); + break; + + default: break; + } + } + D_PAD* pad = Currentmodule->m_Pads; + for ( ; pad != NULL; pad = pad->Next() ) + { + if ( pad->m_Selected == 0 ) continue; + pad->Draw(panel, DC, move_offset, g_XorMode); + } + } + } + + /* Redessin nouvel affichage */ + PtBlock->m_MoveVector.x = screen->m_Curseur.x - PtBlock->m_BlockLastCursorPosition.x; + PtBlock->m_MoveVector.y = screen->m_Curseur.y - PtBlock->m_BlockLastCursorPosition.y; + + GRSetDrawMode(DC, g_XorMode); + PtBlock->Offset(PtBlock->m_MoveVector); + PtBlock->Draw(panel, DC); + PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y); + + + if ( Currentmodule ) + { + item = Currentmodule->m_Drawings; + move_offset.x = - PtBlock->m_MoveVector.x; + move_offset.y = - PtBlock->m_MoveVector.y; + for ( ; item != NULL; item = item->Next() ) + { + if ( item->m_Selected == 0 ) continue; + switch( item->m_StructType ) + { + case TYPETEXTEMODULE: + ((TEXTE_MODULE *) item)->Draw(panel, DC, move_offset, g_XorMode); + break; + + case TYPEEDGEMODULE: + ((EDGE_MODULE *) item)->Draw(panel, DC, move_offset, g_XorMode); + break; + + default: break; + } + } + D_PAD* pad = Currentmodule->m_Pads; + for ( ; pad != NULL; pad = pad->Next() ) + { + if ( pad->m_Selected == 0 ) continue; + pad->Draw(panel, DC, move_offset, g_XorMode); + } + } +} + +/****************************************************************************/ +void CopyMarkedItems(MODULE *module, wxPoint offset) +/****************************************************************************/ +/* Copy marked items, at new position = old position + offset +*/ +{ +EDA_BaseStruct * item; +EDA_BaseStruct* NewStruct; + + if ( module == NULL ) return; + + D_PAD * pad = module->m_Pads; + for ( ; pad != NULL; pad = pad->Next() ) + { + if ( pad->m_Selected == 0 ) continue; + pad->m_Selected = 0; + D_PAD * NewPad = new D_PAD( module ); + NewPad->Copy(pad); + NewPad->m_Selected = IS_SELECTED; + NewPad->Pnext = module->m_Pads; + NewPad->Pback = module; + module->m_Pads->Pback = NewPad; + module->m_Pads = NewPad; + } + + item = module->m_Drawings; + for ( ; item != NULL; item = item->Next() ) + { + if ( item->m_Selected == 0 ) continue; + item->m_Selected = 0; + NewStruct = NULL; + switch(item->m_StructType) + { + case TYPETEXTEMODULE: + NewStruct = new TEXTE_MODULE( module ); + ((TEXTE_MODULE*)NewStruct)->Copy((TEXTE_MODULE*)item); + break; + + case TYPEEDGEMODULE: + NewStruct = new EDGE_MODULE( module ); + ((EDGE_MODULE*)NewStruct)->Copy((EDGE_MODULE*)item); + break; + default: + DisplayError(NULL, wxT("Internal Err: CopyMarkedItems: type indefini")); + break; + } + if( NewStruct == NULL) break; + NewStruct->m_Selected = IS_SELECTED; + NewStruct->Pnext = module->m_Drawings; + NewStruct->Pback = module; + module->m_Drawings->Pback = module; + module->m_Drawings = NewStruct; + } + + MoveMarkedItems(module, offset); +} + +/****************************************************/ +void MoveMarkedItems(MODULE *module, wxPoint offset) +/****************************************************/ +/* Move marked items, at new position = old position + offset +*/ +{ +EDA_BaseStruct * item; + + if ( module == NULL ) return; + + D_PAD * pad = module->m_Pads; + for ( ; pad != NULL; pad = pad->Next() ) + { + if ( pad->m_Selected == 0 ) continue; + pad->m_Pos.x += offset.x; + pad->m_Pos.y += offset.y; + pad->m_Pos0.x += offset.x; + pad->m_Pos0.y += offset.y; + } + + item = module->m_Drawings; + for ( ; item != NULL; item = item->Next() ) + { + if ( item->m_Selected == 0 ) continue; + + switch ( item->m_StructType ) + { + case TYPETEXTEMODULE: + ((TEXTE_MODULE*)item)->m_Pos.x += offset.x; + ((TEXTE_MODULE*)item)->m_Pos.y += offset.y; + ((TEXTE_MODULE*)item)->m_Pos0.x += offset.x; + ((TEXTE_MODULE*)item)->m_Pos0.y += offset.y; + break; + + case TYPEEDGEMODULE : + ((EDGE_MODULE*)item)->m_Start.x += offset.x; + ((EDGE_MODULE*)item)->m_Start.y += offset.y; + ((EDGE_MODULE*)item)->m_End.x += offset.x; + ((EDGE_MODULE*)item)->m_End.y += offset.y; + ((EDGE_MODULE*)item)->m_Start0.x += offset.x; + ((EDGE_MODULE*)item)->m_Start0.y += offset.y; + ((EDGE_MODULE*)item)->m_End0.x += offset.x; + ((EDGE_MODULE*)item)->m_End0.y += offset.y; + break; + } + item->m_Flags = item->m_Selected = 0; + } +} + +/******************************************************/ +void DeleteMarkedItems(MODULE *module) +/******************************************************/ +/* Delete marked items +*/ +{ +EDA_BaseStruct * item, * next_item; +D_PAD * pad, * next_pad; + + if ( module == NULL ) return; + + pad = module->m_Pads; + for ( ; pad != NULL; pad = next_pad ) + { + next_pad = pad->Next(); + if ( pad->m_Selected == 0 ) continue; + DeleteStructure(pad); + } + + item = module->m_Drawings; + for ( ; item != NULL; item = next_item ) + { + next_item = item->Next(); + if ( item->m_Selected == 0 ) continue; + DeleteStructure(item); + } +} + + +/******************************************************/ +void MirrorMarkedItems(MODULE *module, wxPoint offset) +/******************************************************/ +/* Mirror marked items, refer to a Vertical axis at position offset +*/ +{ +#define SETMIRROR(z) (z) -= offset.x; (z) = -(z); (z) += offset.x; +EDA_BaseStruct * item; + + if ( module == NULL ) return; + + D_PAD * pad = module->m_Pads; + for ( ; pad != NULL; pad = pad->Next() ) + { + if ( pad->m_Selected == 0 ) continue; + SETMIRROR(pad->m_Pos.x); + pad->m_Pos0.x = pad->m_Pos.x; + pad->m_Offset.x = -pad->m_Offset.x; + pad->m_DeltaSize.x = -pad->m_DeltaSize.x; + pad->m_Orient = 1800 - pad->m_Orient; + NORMALIZE_ANGLE(pad->m_Orient); + } + + item = module->m_Drawings; + for ( ; item != NULL; item = item->Next() ) + { + if ( item->m_Selected == 0 ) continue; + + switch ( item->m_StructType ) + { + case TYPEEDGEMODULE: + SETMIRROR(((EDGE_MODULE*)item)->m_Start.x); + ((EDGE_MODULE*)item)->m_Start0.x = ((EDGE_MODULE*)item)->m_Start.x; + SETMIRROR(((EDGE_MODULE*)item)->m_End.x); + ((EDGE_MODULE*)item)->m_End0.x = ((EDGE_MODULE*)item)->m_End.x; + ((EDGE_MODULE*)item)->m_Angle = - ((EDGE_MODULE*)item)->m_Angle; + break; + + case TYPETEXTEMODULE: + SETMIRROR(((TEXTE_MODULE*)item)->m_Pos.x); + ((TEXTE_MODULE*)item)->m_Pos0.x = ((TEXTE_MODULE*)item)->m_Pos.x; + break; + } + item->m_Flags = item->m_Selected = 0; + } +} + +/******************************************************/ +void RotateMarkedItems(MODULE *module, wxPoint offset) +/******************************************************/ +/* Rotate marked items, refer to a Vertical axis at position offset +*/ +{ +#define ROTATE(z) RotatePoint((&z), offset, 900) +EDA_BaseStruct * item; + + if ( module == NULL ) return; + + D_PAD * pad = module->m_Pads; + for ( ; pad != NULL; pad = pad->Next() ) + { + if ( pad->m_Selected == 0 ) continue; + ROTATE(pad->m_Pos); + pad->m_Pos0 = pad->m_Pos; + pad->m_Orient += 900; + NORMALIZE_ANGLE(pad->m_Orient); + } + + item = module->m_Drawings; + for ( ; item != NULL; item = item->Next() ) + { + if ( item->m_Selected == 0 ) continue; + + switch ( item->m_StructType ) + { + case TYPEEDGEMODULE: + ROTATE(((EDGE_MODULE*)item)->m_Start); + ((EDGE_MODULE*)item)->m_Start0 = ((EDGE_MODULE*)item)->m_Start; + ROTATE(((EDGE_MODULE*)item)->m_End); + ((EDGE_MODULE*)item)->m_End0 = ((EDGE_MODULE*)item)->m_End; + break; + + case TYPETEXTEMODULE: + ROTATE(((TEXTE_MODULE*)item)->m_Pos); + ((TEXTE_MODULE*)item)->m_Pos0 = ((TEXTE_MODULE*)item)->m_Pos; + ((TEXTE_MODULE*)item)->m_Orient += 900; + break; + } + item->m_Flags = item->m_Selected = 0; + } +} + +/*********************************************************/ +void ClearMarkItems(MODULE * module) +/*********************************************************/ +{ +EDA_BaseStruct * item; + + if ( module == NULL ) return; + + item = module->m_Drawings; + for ( ; item != NULL; item = item->Next() ) + item->m_Flags = item->m_Selected = 0; + + item = module->m_Pads; + for ( ; item != NULL; item = item->Next() ) + item->m_Flags = item->m_Selected = 0; +} + +/***************************************************************/ +int MarkItemsInBloc(MODULE * module, EDA_Rect & Rect) +/***************************************************************/ +/* Mark items inside rect. + Items are inside rect when an end point is inside rect +*/ +{ +EDA_BaseStruct * item; +int ItemsCount = 0; +wxPoint pos; +D_PAD * pad; + + if ( module == NULL ) return 0; + + pad = module->m_Pads; + for ( ; pad != NULL; pad = pad->Next() ) + { + pad->m_Selected = 0; + pos = pad->m_Pos; + if ( Rect.Inside(pos) ) + { + pad->m_Selected = IS_SELECTED; + ItemsCount++; + } + } + + item = module->m_Drawings; + for ( ; item != NULL; item = item->Next() ) + { + item->m_Selected = 0; + switch( item->m_StructType ) + { + case TYPEEDGEMODULE: + pos = ((EDGE_MODULE*)item)->m_Start; + if ( Rect.Inside(pos) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + pos = ((EDGE_MODULE*)item)->m_End; + if ( Rect.Inside(pos) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + break; + + case TYPETEXTEMODULE: + pos = ((TEXTE_MODULE*)item)->m_Pos; + if ( Rect.Inside(pos) ) + { + item->m_Selected = IS_SELECTED; + ItemsCount++; + } + break; + + default: + break; + } + + } + return ItemsCount; + +} diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp new file mode 100644 index 0000000000..bb547c48e6 --- /dev/null +++ b/pcbnew/board.cpp @@ -0,0 +1,520 @@ + /************************************************/ + /* EDITEUR de PCB: AUTOROUTAGE: routines d'init */ + /************************************************/ + + /* Fichier BOARD.CC */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "cell.h" + +#include "protos.h" + +/* routines externes : */ + +/* Routines definies ici: */ +int Build_Work(BOARD * Pcb, CHEVELU* pt_base_chevelu); +void PlaceCells(BOARD * Pcb, int net_code, int flag); +int InitBoard( void ); +BoardCell GetCell( int, int, int ); +void SetCell(int row,int col,int side,BoardCell x ); +void OrCell( int, int, int, BoardCell ); +void AndCell( int, int, int, BoardCell ); +void AddCell( int, int, int, BoardCell ); +void XorCell( int, int, int, BoardCell ); +void AddCell( int, int, int, BoardCell ); +DistCell GetDist( int, int, int ); +void SetDist( int, int, int, DistCell ); +int GetDir( int, int, int ); +void SetDir( int, int, int, int ); + +/*****************************************************************/ +bool ComputeMatriceSize(WinEDA_BasePcbFrame * frame, int g_GridRoutingSize) +/*****************************************************************/ +/* +Calcule Nrows et Ncols, dimensions de la matrice de representation du BOARD +pour les routages automatiques et calculs de zone +*/ +{ +BOARD * pcb = frame->m_Pcb; + + pcb->ComputeBoundaryBox(); + + /* The boundary box must have its start point on routing grid: */ + pcb->m_BoundaryBox.m_Pos.x -= pcb->m_BoundaryBox.m_Pos.x % g_GridRoutingSize; + pcb->m_BoundaryBox.m_Pos.y -= pcb->m_BoundaryBox.m_Pos.y % g_GridRoutingSize; + /* The boundary box must have its end point on routing grid: */ + wxPoint end = pcb->m_BoundaryBox.GetEnd(); + end.x -= end.x % g_GridRoutingSize; end.x += g_GridRoutingSize; + end.y -= end.y % g_GridRoutingSize; end.y += g_GridRoutingSize; + pcb->m_BoundaryBox.SetEnd(end); + + Nrows = pcb->m_BoundaryBox.m_Size.y / g_GridRoutingSize ; + Ncols = pcb->m_BoundaryBox.m_Size.x / g_GridRoutingSize ; + /* get a small margin for memory allocation: */ + Ncols += 2; Nrows += 2; + + return TRUE; +} + + /*******************/ + /* class BOARDHEAD */ + /*******************/ + +BOARDHEAD::BOARDHEAD(void) +{ + m_BoardSide[0] = m_BoardSide[1] = NULL; + m_DistSide[0] = m_DistSide[1] = NULL; + m_DirSide[0] = m_DirSide[1] = NULL; + m_InitBoardDone = FALSE; + m_Layers = 2; + m_Nrows = m_Ncols = 0; + m_MemSize = 0; +} + +BOARDHEAD::~BOARDHEAD(void) +{ +} + +/******************************/ +int BOARDHEAD::InitBoard (void) +/*****************************/ + /* initialize the data structures + retourne la taille RAM utilisee, ou -1 si defaut +*/ +{ +int ii, kk; + + if (Nrows <= 0 || Ncols <= 0) return(0); + m_Nrows = Nrows; + m_Ncols = Ncols; + + m_InitBoardDone = TRUE; /* we have been called */ + + ii = (Nrows+1) * (Ncols+1); + + for ( kk = 0; kk < m_Layers; kk++ ) + { + m_BoardSide[kk] = NULL; + m_DistSide[kk] = NULL; + m_DirSide[kk] = NULL; + + /* allocate Board & initialize everything to empty */ + m_BoardSide[kk] = (BoardCell*)MyZMalloc( ii * sizeof (BoardCell) ); + if( m_BoardSide[kk] == NULL) return(-1); + + /***** allocate Distances *****/ + m_DistSide[kk] = (DistCell *)MyZMalloc( ii * sizeof(DistCell) ); + if (m_DistSide[kk] == NULL) return(-1); + + /***** allocate Dir (chars) *****/ + m_DirSide[kk] = (char *)MyZMalloc( ii ); + if (m_DirSide[kk] == NULL) return( -1 ); + } + + m_MemSize = m_Layers * ii * ( sizeof(BoardCell) + sizeof(DistCell) + sizeof(char) ); + + return(m_MemSize); +} + +/*********************************/ +void BOARDHEAD::UnInitBoard(void) +/*********************************/ +/* deallocation de la memoire */ +{ +int ii; + + m_InitBoardDone = FALSE; + + for ( ii = 0; ii < 2; ii++ ) + { + /***** de-allocate Dir (chars) *****/ + if( m_DirSide[ii] ) + { + MyFree(m_DirSide[ii]); m_DirSide[ii] = NULL; + } + + /***** de-allocate Distances *****/ + if( m_DistSide[ii] ) + { + MyFree(m_DistSide[ii]); m_DistSide[ii] = NULL; + } + + /**** de-allocate Board *****/ + if( m_BoardSide[ii] ) + { + MyFree(m_BoardSide[ii]); m_BoardSide[ii] = NULL; + } + } + + m_Nrows = m_Ncols = 0; +} + + + +/*****************************************************/ +void PlaceCells(BOARD * Pcb, int net_code, int flag) +/*****************************************************/ +/* Initialise les cellules du board a la valeur HOLE et VIA_IMPOSSIBLE + selon les marges d'isolement + les elements de net_code = net_code ne seront pas places comme occupe + mais en VIA_IMPOSSIBLE uniquement + Pour Routage 1 seule face: + le plan BOTTOM est utilise + et Route_Layer_BOTTOM = Route_Layer_TOP + + Selon les bits = 1 du parametre flag: + si FORCE_PADS : tous les pads seront places meme ceux de meme net_code +*/ +{ +int ii; +LISTE_PAD* ptr; +TRACK * pt_segm; +TEXTE_PCB * PtText; +DRAWSEGMENT * DrawSegm; +EDA_BaseStruct * PtStruct; +int ux0 = 0 , uy0 = 0, ux1, uy1, dx, dy; +int marge, via_marge; +int masque_layer; + + marge = g_DesignSettings.m_TrackClearence + (g_DesignSettings.m_CurrentTrackWidth /2); + via_marge = g_DesignSettings.m_TrackClearence + (g_DesignSettings.m_CurrentViaSize /2); + + ///////////////////////////////////// + // Placement des PADS sur le board // + ///////////////////////////////////// + ptr = (LISTE_PAD*)Pcb->m_Pads; ii = Pcb->m_NbPads; + for( ; ii > 0 ; ii-- , ptr++) + { + if( (net_code != (*ptr)->m_NetCode ) || (flag & FORCE_PADS) ) + { + Place_1_Pad_Board(Pcb, *ptr, HOLE, marge, WRITE_CELL); + } + Place_1_Pad_Board(Pcb, *ptr, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL); + } + + /////////////////////////////////////////////// + // Placement des elements de modules sur PCB // + /////////////////////////////////////////////// + PtStruct = Pcb->m_Modules; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + EDA_BaseStruct * PtModStruct = ((MODULE*)PtStruct)->m_Drawings; + for( ;PtModStruct != NULL; PtModStruct = PtModStruct->Pnext ) + { + switch( PtModStruct->m_StructType ) + { + case TYPEEDGEMODULE: + { + TRACK * TmpSegm = new TRACK(NULL); + TmpSegm->m_Layer = ((EDGE_MODULE *) PtModStruct)->m_Layer; + if(TmpSegm->m_Layer == EDGE_N) TmpSegm->m_Layer = -1; + + TmpSegm->m_Start = ((EDGE_MODULE *) PtModStruct)->m_Start; + TmpSegm->m_End = ((EDGE_MODULE *) PtModStruct)->m_End; + TmpSegm->m_Shape = ((EDGE_MODULE *) PtModStruct)->m_Shape; + TmpSegm->m_Width = ((EDGE_MODULE *) PtModStruct)->m_Width; + TmpSegm->m_Param = ((EDGE_MODULE *) PtModStruct)->m_Angle; + TmpSegm->m_NetCode = -1; + + TraceSegmentPcb(Pcb, TmpSegm, HOLE, marge,WRITE_CELL ); + TraceSegmentPcb(Pcb, TmpSegm, VIA_IMPOSSIBLE, via_marge, + WRITE_OR_CELL ); + delete TmpSegm; + break; + } + + default: break; + } + } + } + + //////////////////////////////////////////// + // Placement des contours et segments PCB // + //////////////////////////////////////////// + PtStruct = Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType) + { + case TYPEDRAWSEGMENT: + { + int type_cell = HOLE; + TRACK * TmpSegm = new TRACK(NULL); + DrawSegm = (DRAWSEGMENT *) PtStruct; + TmpSegm->m_Layer = DrawSegm->m_Layer; + if(DrawSegm->m_Layer == EDGE_N) + { + TmpSegm->m_Layer = -1; + type_cell |= CELL_is_EDGE; + } + + TmpSegm->m_Start = DrawSegm->m_Start; + TmpSegm->m_End = DrawSegm->m_End; + TmpSegm->m_Shape = DrawSegm->m_Shape; + TmpSegm->m_Width = DrawSegm->m_Width; + TmpSegm->m_Param = DrawSegm->m_Angle; + TmpSegm->m_NetCode = -1; + + TraceSegmentPcb(Pcb, TmpSegm, type_cell, marge,WRITE_CELL ); +// TraceSegmentPcb(Pcb, TmpSegm, VIA_IMPOSSIBLE, via_marge,WRITE_OR_CELL ); + delete TmpSegm; + break; + } + + case TYPETEXTE: + PtText = (TEXTE_PCB*) PtStruct; + if(PtText->GetLength() == 0 ) break; + ux0 = PtText->m_Pos.x; uy0 = PtText->m_Pos.y; + + dx = PtText->Pitch()* PtText->GetLength(); + dy = PtText->m_Size.y + PtText->m_Width; + + /* Calcul du rectangle d'encadrement */ + dx /= 2; dy /= 2; /* dx et dy = demi dimensionx X et Y */ + ux1 = ux0 + dx; uy1 = uy0 + dy; + ux0 -= dx; uy0 -= dy; + + masque_layer = g_TabOneLayerMask[PtText->m_Layer]; + + TraceFilledRectangle(Pcb, ux0-marge, uy0-marge, ux1+marge, uy1+marge, + (int)(PtText->m_Orient), + masque_layer, HOLE, WRITE_CELL); + TraceFilledRectangle(Pcb, ux0-via_marge, uy0-via_marge, + ux1+via_marge, uy1+via_marge, + (int)(PtText->m_Orient), + masque_layer, VIA_IMPOSSIBLE, WRITE_OR_CELL); + break; + + default: break; + } + } + + /* Placement des PISTES */ + pt_segm = Pcb->m_Track; + for( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext) + { + if(net_code == pt_segm->m_NetCode) continue; + TraceSegmentPcb(Pcb, pt_segm, HOLE, marge, WRITE_CELL ); + TraceSegmentPcb(Pcb, pt_segm, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); + } + + /* Placement des ZONES */ + pt_segm = (TRACK*) Pcb->m_Zone; + for( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext) + { + if(net_code == pt_segm->m_NetCode) continue; + TraceSegmentPcb(Pcb, pt_segm, HOLE, marge, WRITE_CELL ); + TraceSegmentPcb(Pcb, pt_segm, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); + } +} + +/******************************************************/ +int Build_Work(BOARD * Pcb, CHEVELU* pt_base_chevelu) +/*****************************************************/ + /* Build liste conn */ +{ +int ii; +CHEVELU* pt_rats = pt_base_chevelu; +D_PAD * pt_pad; +int r1,r2, c1,c2, current_net_code; +CHEVELU * pt_ch; +int demi_pas = g_GridRoutingSize /2; +wxString msg; + + InitWork(); /* clear work list */ + Ntotal = 0; + for ( ii = Pcb->GetNumRatsnests(); ii > 0 ; ii-- , pt_rats++) + { + /* On ne route que les chevelus actifs et routables */ + if( (pt_rats->status & CH_ACTIF) == 0) continue; + if( pt_rats->status & CH_UNROUTABLE) continue; + if( (pt_rats->status & CH_ROUTE_REQ) == 0 ) continue; + pt_pad = pt_rats->pad_start; + + current_net_code = pt_pad->m_NetCode; + pt_ch = pt_rats; + + r1 = (pt_pad->m_Pos.y - Pcb->m_BoundaryBox.m_Pos.y + demi_pas ) / g_GridRoutingSize; + if( r1 < 0 || r1 >= Nrows) + { + msg.Printf( wxT("erreur : row = %d ( padY %d pcbY %d) "), r1, + pt_pad->m_Pos.y, Pcb->m_BoundaryBox.m_Pos.y); + DisplayError(NULL, msg); + return(0); + } + c1 = (pt_pad->m_Pos.x - Pcb->m_BoundaryBox.m_Pos.x + demi_pas ) / g_GridRoutingSize; + if( c1 < 0 || c1 >= Ncols) + { + msg.Printf( wxT("erreur : col = %d ( padX %d pcbX %d) "), c1, + pt_pad->m_Pos.x, Pcb->m_BoundaryBox.m_Pos.x); + DisplayError(NULL, msg); + return(0); + } + + pt_pad = pt_rats->pad_end; + + r2 = (pt_pad->m_Pos.y - Pcb->m_BoundaryBox.m_Pos.y + demi_pas ) / g_GridRoutingSize; + if( r2 < 0 || r2 >= Nrows) + { + msg.Printf( wxT("erreur : row = %d ( padY %d pcbY %d) "), r2, + pt_pad->m_Pos.y, Pcb->m_BoundaryBox.m_Pos.y); + DisplayError(NULL, msg); + return(0); + } + c2 = (pt_pad->m_Pos.x - Pcb->m_BoundaryBox.m_Pos.x + demi_pas ) / g_GridRoutingSize; + if( c2 < 0 || c2 >= Ncols) + { + msg.Printf( wxT("erreur : col = %d ( padX %d pcbX %d) "), c2, + pt_pad->m_Pos.x, Pcb->m_BoundaryBox.m_Pos.x); + DisplayError(NULL, msg); + return(0); + } + + SetWork( r1, c1, current_net_code, r2, c2, pt_ch, 0 ); Ntotal++; + } + + SortWork(); + return(Ntotal); +} + + + +/*******************************************/ +BoardCell GetCell(int row,int col,int side ) +/*******************************************/ + /* fetch board cell : +*/ +{ +BoardCell *p; + + p = Board.m_BoardSide[side]; + return( p[row*Ncols +col] ); +} + + +/************************************************/ +/* void SetCell(int r,int c,int s,BoardCell x ) */ +/************************************************/ + +/* store board cell */ +void SetCell(int row,int col,int side,BoardCell x ) +{ +BoardCell *p; + + p = Board.m_BoardSide[side]; + p[row*Ncols+col] = x; +} + + + /******************************************/ + /* void OrCell(int r,int c,int s,BoardCell x ) */ + /******************************************/ + +void OrCell(int r,int c,int s,BoardCell x ) +{ +BoardCell *p; + + p = Board.m_BoardSide[s]; + p[r*Ncols+c] |= x; +} + + /******************************************/ + /* void XorCell(int r,int c,int s,BoardCell x ) */ + /******************************************/ + +void XorCell(int r,int c,int s,BoardCell x ) +{ +BoardCell *p; + + p = Board.m_BoardSide[s]; + p[r*Ncols+c] ^= x; +} + + + /************************************************/ + /* void AndCell(int r,int c,int s,BoardCell x ) */ + /************************************************/ + +void AndCell(int r,int c,int s,BoardCell x ) +{ +BoardCell *p; + + p = Board.m_BoardSide[s]; + p[r*Ncols+c] &= x; +} + + /************************************************/ + /* void AddCell(int r,int c,int s,BoardCell x ) */ + /************************************************/ + +void AddCell(int r,int c,int s,BoardCell x ) +{ +BoardCell *p; + + p = Board.m_BoardSide[s]; + p[r*Ncols+c] += x; +} + + + + /****************************************/ + /* DistCell GetDist(int r,int c,int s ) */ + /****************************************/ + +/* fetch distance cell */ +DistCell GetDist(int r,int c,int s ) /* fetch distance cell */ +{ +DistCell *p; + + p = Board.m_DistSide[s]; + return( p[r*Ncols+c] ); +} + + + /***********************************************/ + /* void SetDist(int r,int c,int s,DistCell x ) */ + /***********************************************/ + +/* store distance cell */ +void SetDist(int r,int c,int s,DistCell x ) +{ +DistCell *p; + + p = Board.m_DistSide[s]; + p[r*Ncols+c] = x; +} + + + /**********************************/ + /* int GetDir(int r,int c,int s ) */ + /**********************************/ + +/* fetch direction cell */ +int GetDir(int r,int c,int s ) +{ +char *p; + + p = Board.m_DirSide[s]; + return( (int)(p[r*Ncols+c]) ); +} + + + /*****************************************/ + /* void SetDir(int r,int c,int s,int x ) */ + /*****************************************/ + +/* store direction cell */ + +void SetDir(int r,int c,int s,int x ) +{ +char *p; + + p = Board.m_DirSide[s]; + p[r*Ncols+c] = (char)x; +} + diff --git a/pcbnew/cell.h b/pcbnew/cell.h new file mode 100644 index 0000000000..9fe3bd3308 --- /dev/null +++ b/pcbnew/cell.h @@ -0,0 +1,75 @@ +/* Bits caracterisant une cellule */ +#define HOLE 0x00000001L /* a conducting hole, ou obstacle */ +#define CELL_is_MODULE 2 /* autoplacement: occupe par un module */ +#define CELL_is_EDGE 0x20 /* zone et autoplacement: cellule limitant un contour (Board, Zone) */ +#define CELL_is_FRIEND 0x40 /* zone et autoplacement: cellule faisant partie du net */ +#define CELL_is_ZONE 0x80 /* zone et autoplacement: cellule disponible */ + +/* Bits Masques de presence d'obstacles pour autoroutage */ +#define OCCUPE 1 /* autoroutage : obstacle pour pistes et vias */ +#define VIA_IMPOSSIBLE 2 /* autoroutage : obsacle pour vias */ +#define CURRENT_PAD 4 + + +/* traces radiating outward from a hole to a side or corner */ +#define HOLE_NORTH 0x00000002L /* upward */ +#define HOLE_NORTHEAST 0x00000004L /* upward and right */ +#define HOLE_EAST 0x00000008L /* to the right */ +#define HOLE_SOUTHEAST 0x00000010L /* downward and right */ +#define HOLE_SOUTH 0x00000020L /* downward */ +#define HOLE_SOUTHWEST 0x00000040L /* downward and left */ +#define HOLE_WEST 0x00000080L /* to the left */ +#define HOLE_NORTHWEST 0x00000100L /* upward and left */ + +/* straight lines through the center */ +#define LINE_HORIZONTAL 0x00000002L /* left-to-right line */ +#define LINE_VERTICAL 0x00000004L /* top-to-bottom line */ + +/* lines cutting across a corner, connecting adjacent sides */ +#define CORNER_NORTHEAST 0x00000008L /* upper right corner */ +#define CORNER_SOUTHEAST 0x00000010L /* lower right corner */ +#define CORNER_SOUTHWEST 0x00000020L /* lower left corner */ +#define CORNER_NORTHWEST 0x00000040L /* upper left corner */ + +/* diagonal lines through the center */ +#define DIAG_NEtoSW 0x00000080L /* northeast to southwest */ +#define DIAG_SEtoNW 0x00000100L /* southeast to northwest */ + +/* 135 degree angle side-to-far-corner lines */ +#define BENT_NtoSE 0x00000200L /* north to southeast */ +#define BENT_NtoSW 0x00000400L /* north to southwest */ +#define BENT_EtoSW 0x00000800L /* east to southwest */ +#define BENT_EtoNW 0x00001000L /* east to northwest */ +#define BENT_StoNW 0x00002000L /* south to northwest */ +#define BENT_StoNE 0x00004000L /* south to northeast */ +#define BENT_WtoNE 0x00008000L /* west to northeast */ +#define BENT_WtoSE 0x00010000L /* west to southeast */ + +/* 90 degree corner-to-adjacent-corner lines */ +#define ANGLE_NEtoSE 0x00020000L /* northeast to southeast */ +#define ANGLE_SEtoSW 0x00040000L /* southeast to southwest */ +#define ANGLE_SWtoNW 0x00080000L /* southwest to northwest */ +#define ANGLE_NWtoNE 0x00100000L /* northwest to northeast */ + +/* 45 degree angle side-to-near-corner lines */ +#define SHARP_NtoNE 0x00200000L /* north to northeast */ +#define SHARP_EtoNE 0x00400000L /* east to northeast */ +#define SHARP_EtoSE 0x00800000L /* east to southeast */ +#define SHARP_StoSE 0x01000000L /* south to southeast */ +#define SHARP_StoSW 0x02000000L /* south to southwest */ +#define SHARP_WtoSW 0x04000000L /* west to southwest */ +#define SHARP_WtoNW 0x08000000L /* west to northwest */ +#define SHARP_NtoNW 0x10000000L /* north to northwest */ + +/* directions the cell can be reached from (point to previous cell) */ +#define FROM_NOWHERE 0 +#define FROM_NORTH 1 +#define FROM_NORTHEAST 2 +#define FROM_EAST 3 +#define FROM_SOUTHEAST 4 +#define FROM_SOUTH 5 +#define FROM_SOUTHWEST 6 +#define FROM_WEST 7 +#define FROM_NORTHWEST 8 +#define FROM_OTHERSIDE 9 + diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp new file mode 100644 index 0000000000..8a1de29c52 --- /dev/null +++ b/pcbnew/class_board.cpp @@ -0,0 +1,245 @@ + /*******************************************/ + /* class_board.cpp - BOARD class functions */ + /*******************************************/ +#include "fctsys.h" +#include "common.h" + +#include "pcbnew.h" + +#include "bitmaps.h" + + + + /*****************/ + /* Class BOARD: */ + /*****************/ + +/* Constructor */ +BOARD::BOARD(EDA_BaseStruct * parent, WinEDA_BasePcbFrame * frame): + EDA_BaseStruct(parent, TYPEPCB) +{ + m_PcbFrame = frame; + m_Status_Pcb = 0; // Mot d'etat: Bit 1 = Chevelu calcule + m_NbNets = 0; // Nombre de nets (equipotentielles) + m_BoardSettings = &g_DesignSettings; + m_NbPads = 0; // nombre total de pads + m_NbNodes = 0; // nombre de pads connectes + m_NbLinks = 0; // nombre de chevelus (donc aussi nombre + // minimal de pistes a tracer + m_NbSegmTrack = 0; // nombre d'elements de type segments de piste + m_NbSegmZone = 0; // nombre d'elements de type segments de zone + m_NbNoconnect=0; // nombre de chevelus actifs + m_NbLoclinks = 0; // nb ratsnest local + + m_Drawings = NULL; // pointeur sur liste drawings + m_Modules = NULL; // pointeur sur liste zone modules + m_Equipots = NULL; // pointeur liste zone equipot + m_Track = NULL; // pointeur relatif zone piste + m_Zone = NULL; // pointeur tableau zone zones de cuivre + m_Pads = NULL; // pointeur liste d'acces aux pads + m_Ratsnest = NULL; // pointeur liste rats + m_LocalRatsnest = NULL; // pointeur liste rats local + m_CurrentLimitZone = NULL; // pointeur liste des EDEGE_ZONES + // de determination des contours de zone +} + + /***************/ + /* Destructeur */ + /***************/ +BOARD::~BOARD(void) +{ +} + + +void BOARD::UnLink( void ) +{ + /* Modification du chainage arriere */ + if( Pback ) + { + if( Pback->m_StructType == TYPEPCB) + { + Pback->Pnext = Pnext; + } + + else /* Le chainage arriere pointe sur la structure "Pere" */ + { +// Pback-> = Pnext; + } + } + + /* Modification du chainage avant */ + if( Pnext) Pnext->Pback = Pback; + + Pnext = Pback = NULL; +} + +/* Routines de calcul des nombres de segments pistes et zones */ +int BOARD::GetNumSegmTrack(void) +{ +TRACK * CurTrack = m_Track; +int ii = 0; + + for ( ;CurTrack != NULL; CurTrack = (TRACK*)CurTrack->Pnext ) ii++; + m_NbSegmTrack = ii; + return(ii); +} +int BOARD::GetNumSegmZone(void) +{ +TRACK * CurTrack = m_Zone; +int ii = 0; + + for ( ;CurTrack != NULL; CurTrack = (TRACK*)CurTrack->Pnext ) ii++; + m_NbSegmZone = ii; + return(ii); +} + + + // retourne le nombre de connexions manquantes +int BOARD::GetNumNoconnect(void) +{ + return(m_NbNoconnect); +} + + // retourne le nombre de chevelus +int BOARD::GetNumRatsnests(void) +{ + return(m_NbLinks); +} + + // retourne le nombre de pads a netcode > 0 +int BOARD::GetNumNodes(void) +{ + return(m_NbNodes); +} + + +/***********************************/ +bool BOARD::ComputeBoundaryBox(void) +/***********************************/ + +/* Determine le rectangle d'encadrement du pcb + Ce rectangle englobe les contours pcb, pads , vias et piste + Sortie: + m_PcbBox + + retourne: + 0 si aucun element utile + 1 sinon +*/ +{ +int rayon, cx, cy, d, xmin, ymin, xmax, ymax; +bool Has_Items = FALSE; +EDA_BaseStruct * PtStruct; +DRAWSEGMENT* ptr; +TRACK * Track; + + xmin = ymin = 0x7FFFFFFFl ; + xmax = ymax = -0x7FFFFFFFl ; + + /* Analyse des Contours PCB */ + PtStruct = m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; + ptr = (DRAWSEGMENT*) PtStruct; + d = (ptr->m_Width /2) + 1; + if(ptr->m_Shape == S_CIRCLE) + { + cx = ptr->m_Start.x; cy = ptr->m_Start.y; + rayon = (int)hypot((double)(ptr->m_End.x-cx),(double)(ptr->m_End.y-cy) ); + rayon += d; + xmin = min(xmin,cx-rayon); + ymin = min(ymin,cy-rayon); + xmax = max(xmax,cx+rayon); + ymax = max(ymax,cy+rayon); + Has_Items = TRUE; + } + else + { + cx = min(ptr->m_Start.x, ptr->m_End.x ); + cy = min(ptr->m_Start.y, ptr->m_End.y); + xmin = min(xmin,cx - d); + ymin = min(ymin,cy - d); + cx = max(ptr->m_Start.x, ptr->m_End.x ); + cy = max(ptr->m_Start.y, ptr->m_End.y); + xmax = max(xmax,cx + d); + ymax = max(ymax,cy + d); + Has_Items = TRUE; + } + } + + /* Analyse des Modules */ + MODULE * module = m_Modules; + for( ; module != NULL; module = (MODULE *) module->Pnext ) + { + Has_Items = TRUE; + xmin = min(xmin,(module->m_Pos.x + module->m_BoundaryBox.GetX())); + ymin = min(ymin,(module->m_Pos.y + module->m_BoundaryBox.GetY())); + xmax = max(xmax,module->m_Pos.x + module->m_BoundaryBox.GetRight()); + ymax = max(ymax,module->m_Pos.y + module->m_BoundaryBox.GetBottom()); + + D_PAD * pt_pad = module->m_Pads; + for ( ;pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + { + d = pt_pad->m_Rayon; + xmin = min(xmin,pt_pad->m_Pos.x - d); + ymin = min(ymin,pt_pad->m_Pos.y - d); + xmax = max(xmax,pt_pad->m_Pos.x + d); + ymax = max(ymax,pt_pad->m_Pos.y + d); + } + } + + /* Analyse des segments de piste et zone*/ + for( Track = m_Track; Track != NULL; Track = (TRACK*) Track->Pnext) + { + d = (Track->m_Width /2) + 1; + cx = min(Track->m_Start.x, Track->m_End.x ); + cy = min(Track->m_Start.y, Track->m_End.y); + xmin = min(xmin,cx - d); + ymin = min(ymin,cy - d); + cx = max(Track->m_Start.x, Track->m_End.x ); + cy = max(Track->m_Start.y, Track->m_End.y); + xmax = max(xmax,cx + d); + ymax = max(ymax,cy + d); + Has_Items = TRUE; + } + + for( Track = m_Zone; Track != NULL; Track = (TRACK*) Track->Pnext) + { + d = (Track->m_Width /2) + 1; + cx = min(Track->m_Start.x, Track->m_End.x ); + cy = min(Track->m_Start.y, Track->m_End.y); + xmin = min(xmin,cx - d); + ymin = min(ymin,cy - d); + cx = max(Track->m_Start.x, Track->m_End.x ); + cy = max(Track->m_Start.y, Track->m_End.y); + xmax = max(xmax,cx + d); + ymax = max(ymax,cy + d); + Has_Items = TRUE; + } + + if ( ! Has_Items && m_PcbFrame ) + { + if ( m_PcbFrame->m_Draw_Sheet_Ref ) + { + xmin = ymin = 0; + xmax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().x; + ymax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().y; + } + else + { + xmin = - m_PcbFrame->m_CurrentScreen->ReturnPageSize().x/2; + ymin = - m_PcbFrame->m_CurrentScreen->ReturnPageSize().y/2; + xmax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().x/2; + ymax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().y/2; + } + } + + m_BoundaryBox.SetX(xmin); + m_BoundaryBox.SetY(ymin); + m_BoundaryBox.SetWidth(xmax - xmin); + m_BoundaryBox.SetHeight(ymax - ymin); + + return(Has_Items); +} + diff --git a/pcbnew/class_cotation.cpp b/pcbnew/class_cotation.cpp new file mode 100644 index 0000000000..c782c8c091 --- /dev/null +++ b/pcbnew/class_cotation.cpp @@ -0,0 +1,383 @@ +/************************************/ +/* fonctions de la classe COTATION */ +/************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + + + +COTATION::COTATION(EDA_BaseStruct * StructFather): + EDA_BaseStruct( StructFather, TYPECOTATION) +{ + m_Layer = DRAW_LAYER; + m_Width = 50; + m_Value = 0; + m_Shape = 0; + m_Unit = INCHES; + m_Text = new TEXTE_PCB(this); +} + +/* Effacement memoire de la structure */ +COTATION::~COTATION(void) +{ + delete m_Text; +} + +/* supprime du chainage la structure Struct + les structures arrieres et avant sont chainees directement + */ +void COTATION::UnLink( void ) +{ + /* Modification du chainage arriere */ + if( Pback ) + { + if( Pback->m_StructType != TYPEPCB) + { + Pback->Pnext = Pnext; + } + + else /* Le chainage arriere pointe sur la structure "Pere" */ + { + ((BOARD*)Pback)->m_Drawings = Pnext; + } + } + + /* Modification du chainage avant */ + if( Pnext) Pnext->Pback = Pback; + + Pnext = Pback = NULL; +} + +/* Changement du texte de la cotation */ +void COTATION:: SetText(const wxString & NewText) +{ + m_Text->m_Text = NewText; +} + + +/*************************************/ +void COTATION::Copy(COTATION * source) +/*************************************/ +{ + m_Value = source->m_Value; + m_Layer = source->m_Layer; + m_Width = source->m_Width; + m_Pos = source->m_Pos; + m_Shape = source->m_Shape; + m_Unit = source->m_Unit; + m_TimeStamp = GetTimeStamp(); + m_Text->Copy(source->m_Text); + + Barre_ox = source->Barre_ox; Barre_oy = source->Barre_oy; + Barre_fx = source->Barre_fx; Barre_fy = source->Barre_fy; + TraitG_ox = source->TraitG_ox; TraitG_oy = source->TraitG_oy; + TraitG_fx = source->TraitG_fx; TraitG_fy = source->TraitG_fy; + TraitD_ox = source->TraitD_ox; TraitD_oy = source->TraitD_oy; + TraitD_fx = source->TraitD_fx; TraitD_fy = source->TraitD_fy; + FlecheD1_ox = source->FlecheD1_ox; FlecheD1_oy = source->FlecheD1_oy; + FlecheD1_fx = source->FlecheD1_fx; FlecheD1_fy = source->FlecheD1_fy; + FlecheD2_ox = source->FlecheD2_ox; FlecheD2_oy = source->FlecheD2_oy; + FlecheD2_fx = source->FlecheD2_fx; FlecheD2_fy = source->FlecheD2_fy; + FlecheG1_ox = source->FlecheG1_ox; FlecheG1_oy = source->FlecheG1_oy; + FlecheG1_fx = source->FlecheG1_fx; FlecheG1_fy = source->FlecheG1_fy; + FlecheG2_ox = source->FlecheG2_ox; FlecheG2_oy = source->FlecheG2_oy; + FlecheG2_fx = source->FlecheG2_fx; FlecheG2_fy = source->FlecheG2_fy; +} + + +/***************************************************************/ +bool COTATION::ReadCotationDescr(FILE * File, int * LineNum) +/***************************************************************/ +{ +char Line[2048], Text[2048]; + + while( GetLine(File, Line, LineNum ) != NULL ) + { + if(strnicmp(Line,"$EndCOTATION",4) == 0) return TRUE; + + if(Line[0] == 'V') + { + sscanf( Line+2," %d",&m_Value); + continue; + } + + if(Line[0] == 'G') + { + sscanf( Line+2," %d %d %lX",&m_Shape, &m_Layer, &m_TimeStamp); + + /* Mise a jour des param .layer des sous structures */ + if ( m_Layer < FIRST_NO_COPPER_LAYER ) + m_Layer = FIRST_NO_COPPER_LAYER; + if ( m_Layer > LAST_NO_COPPER_LAYER ) + m_Layer = LAST_NO_COPPER_LAYER; + + m_Text->m_Layer = m_Layer; + continue; + } + + if(Line[0] == 'T') + { + ReadDelimitedText(Text, Line+2, sizeof(Text) ); + m_Text->m_Text = CONV_FROM_UTF8(Text); + continue; + } + + if(Line[0] == 'P') + { + sscanf( Line+2," %d %d %d %d %d %d %d", + &m_Text->m_Pos.x, &m_Text->m_Pos.y, + &m_Text->m_Size.x, &m_Text->m_Size.y, + &m_Text->m_Width,&m_Text->m_Orient, + &m_Text->m_Miroir); + + m_Pos = m_Text->m_Pos; + continue; + } + + if( Line[0] == 'S') + { + switch( Line[1] ) + { + int Dummy; + case 'b' : + sscanf( Line+2," %d %d %d %d %d %d", + &Dummy, + &Barre_ox, &Barre_oy, + &Barre_fx, &Barre_fy, + &m_Width ); + break; + + case 'd': + sscanf( Line+2," %d %d %d %d %d %d", + &Dummy, + &TraitD_ox, &TraitD_oy, + &TraitD_fx, &TraitD_fy, + &Dummy ); + break; + + case 'g': + sscanf( Line+2," %d %d %d %d %d %d", + &Dummy, + &TraitG_ox, &TraitG_oy, + &TraitG_fx, &TraitG_fy, + &Dummy ); + break; + + case '1': + sscanf( Line+2," %d %d %d %d %d %d", + &Dummy, + &FlecheD1_ox, &FlecheD1_oy, + &FlecheD1_fx, &FlecheD1_fy, + &Dummy ); + break; + + case '2': + sscanf( Line+2," %d %d %d %d %d %d", + &Dummy, + &FlecheD2_ox, &FlecheD2_oy, + &FlecheD2_fx, &FlecheD2_fy, + &Dummy ); + break; + + case '3': + sscanf( Line+2," %d %d %d %d %d %d\n", + &Dummy, + &FlecheG1_ox, &FlecheG1_oy, + &FlecheG1_fx, &FlecheG1_fy, + &Dummy); + break; + + case '4': + sscanf( Line+2," %d %d %d %d %d %d", + &Dummy, + &FlecheG2_ox, &FlecheG2_oy, + &FlecheG2_fx, &FlecheG2_fy, + &Dummy ); + break; + } + + continue; + } + } + return FALSE; +} + + +/**************************************************/ +bool COTATION::WriteCotationDescr(FILE * File) +/**************************************************/ +{ + if( GetState(DELETED) ) return FALSE; + + fprintf( File, "$COTATION\n"); + + fprintf( File,"Ge %d %d %lX\n",m_Shape, + m_Layer, m_TimeStamp); + + fprintf( File,"Va %d\n",m_Value); + + if( ! m_Text->m_Text.IsEmpty() ) + fprintf( File,"Te \"%s\"\n",CONV_TO_UTF8(m_Text->m_Text)); + else fprintf( File,"Te \"?\"\n"); + + fprintf( File,"Po %d %d %d %d %d %d %d\n", + m_Text->m_Pos.x, m_Text->m_Pos.y, + m_Text->m_Size.x, m_Text->m_Size.y, + m_Text->m_Width,m_Text->m_Orient, + m_Text->m_Miroir); + + fprintf( File,"Sb %d %d %d %d %d %d\n",S_SEGMENT, + Barre_ox, Barre_oy, + Barre_fx, Barre_fy, m_Width ); + + fprintf( File,"Sd %d %d %d %d %d %d\n",S_SEGMENT, + TraitD_ox, TraitD_oy, + TraitD_fx, TraitD_fy, m_Width ); + + fprintf( File,"Sg %d %d %d %d %d %d\n",S_SEGMENT, + TraitG_ox, TraitG_oy, + TraitG_fx, TraitG_fy, m_Width ); + + fprintf( File,"S1 %d %d %d %d %d %d\n",S_SEGMENT, + FlecheD1_ox, FlecheD1_oy, + FlecheD1_fx, FlecheD1_fy, m_Width ); + + fprintf( File,"S2 %d %d %d %d %d %d\n",S_SEGMENT, + FlecheD2_ox, FlecheD2_oy, + FlecheD2_fx, FlecheD2_fy, m_Width ); + + + fprintf( File,"S3 %d %d %d %d %d %d\n",S_SEGMENT, + FlecheG1_ox, FlecheG1_oy, + FlecheG1_fx, FlecheG1_fy, m_Width ); + + fprintf( File,"S4 %d %d %d %d %d %d\n",S_SEGMENT, + FlecheG2_ox, FlecheG2_oy, + FlecheG2_fx, FlecheG2_fy, m_Width ); + + fprintf( File, "$EndCOTATION\n"); + + return(1); +} + + + + +/************************************************************************/ +void COTATION::Draw(WinEDA_DrawPanel * panel , wxDC * DC, + const wxPoint & offset, int mode_color) +/************************************************************************/ +/* impression de 1 cotation : serie de n segments + 1 texte +*/ +{ +int ox, oy, typeaff, width, gcolor; +int zoom = panel->GetScreen()->GetZoom(); + + ox = offset.x; + oy = offset.y; + + m_Text->Draw(panel, DC, offset, mode_color ); + + gcolor = g_DesignSettings.m_LayerColor[m_Layer]; + if( (gcolor & ITEM_NOT_SHOW) != 0 ) return ; + + GRSetDrawMode(DC, mode_color); + typeaff = DisplayOpt.DisplayDrawItems; + width = m_Width; + if( width/zoom < 2 ) typeaff = FILAIRE; + + switch( typeaff ) + { + case FILAIRE: + GRLine(&panel->m_ClipBox, DC, + Barre_ox - ox, Barre_oy - oy, + Barre_fx - ox, Barre_fy- oy, gcolor); + GRLine(&panel->m_ClipBox, DC, + TraitG_ox - ox, TraitG_oy - oy, + TraitG_fx - ox, TraitG_fy- oy, gcolor); + GRLine(&panel->m_ClipBox, DC, + TraitD_ox - ox, TraitD_oy - oy, + TraitD_fx - ox, TraitD_fy- oy, gcolor); + GRLine(&panel->m_ClipBox, DC, + FlecheD1_ox - ox, FlecheD1_oy - oy, + FlecheD1_fx - ox, FlecheD1_fy- oy, gcolor); + GRLine(&panel->m_ClipBox, DC, + FlecheD2_ox - ox, FlecheD2_oy - oy, + FlecheD2_fx - ox, FlecheD2_fy- oy, gcolor); + GRLine(&panel->m_ClipBox, DC, + FlecheG1_ox - ox, FlecheG1_oy - oy, + FlecheG1_fx - ox, FlecheG1_fy- oy, gcolor); + GRLine(&panel->m_ClipBox, DC, + FlecheG2_ox - ox, FlecheG2_oy - oy, + FlecheG2_fx - ox, FlecheG2_fy- oy, gcolor); + break; + + case FILLED: + GRFillCSegm(&panel->m_ClipBox, DC, + Barre_ox - ox, Barre_oy - oy, + Barre_fx - ox, Barre_fy- oy, + width, gcolor); + GRFillCSegm(&panel->m_ClipBox, DC, + TraitG_ox - ox, TraitG_oy - oy, + TraitG_fx - ox, TraitG_fy- oy, + width, gcolor); + GRFillCSegm(&panel->m_ClipBox, DC, + TraitD_ox - ox, TraitD_oy - oy, + TraitD_fx - ox, TraitD_fy- oy, + width, gcolor); + GRFillCSegm(&panel->m_ClipBox, DC, + FlecheD1_ox - ox, FlecheD1_oy - oy, + FlecheD1_fx - ox, FlecheD1_fy- oy, + width, gcolor); + GRFillCSegm(&panel->m_ClipBox, DC, + FlecheD2_ox - ox, FlecheD2_oy - oy, + FlecheD2_fx - ox, FlecheD2_fy- oy, + width, gcolor); + GRFillCSegm(&panel->m_ClipBox, DC, + FlecheG1_ox - ox, FlecheG1_oy - oy, + FlecheG1_fx - ox, FlecheG1_fy- oy, + width, gcolor); + GRFillCSegm(&panel->m_ClipBox, DC, + FlecheG2_ox - ox, FlecheG2_oy - oy, + FlecheG2_fx - ox, FlecheG2_fy- oy, + width, gcolor); + break; + + case SKETCH: + GRCSegm(&panel->m_ClipBox, DC, + Barre_ox - ox, Barre_oy - oy, + Barre_fx - ox, Barre_fy- oy, + width, gcolor); + GRCSegm(&panel->m_ClipBox, DC, + TraitG_ox - ox, TraitG_oy - oy, + TraitG_fx - ox, TraitG_fy- oy, + width, gcolor); + GRCSegm(&panel->m_ClipBox, DC, + TraitD_ox - ox, TraitD_oy - oy, + TraitD_fx - ox, TraitD_fy- oy, + width, gcolor); + GRCSegm(&panel->m_ClipBox, DC, + FlecheD1_ox - ox, FlecheD1_oy - oy, + FlecheD1_fx - ox, FlecheD1_fy- oy, + width, gcolor); + GRCSegm(&panel->m_ClipBox, DC, + FlecheD2_ox - ox, FlecheD2_oy - oy, + FlecheD2_fx - ox, FlecheD2_fy- oy, + width, gcolor); + GRCSegm(&panel->m_ClipBox, DC, + FlecheG1_ox - ox, FlecheG1_oy - oy, + FlecheG1_fx - ox, FlecheG1_fy- oy, + width, gcolor); + GRCSegm(&panel->m_ClipBox, DC, + FlecheG2_ox - ox, FlecheG2_oy - oy, + FlecheG2_fx - ox, FlecheG2_fy - oy, + width, gcolor); + break; + } +} + + diff --git a/pcbnew/class_cotation.h b/pcbnew/class_cotation.h new file mode 100644 index 0000000000..7298c87abc --- /dev/null +++ b/pcbnew/class_cotation.h @@ -0,0 +1,47 @@ +/************************************/ +/* fonctions de la classe COTATION */ +/************************************/ +#ifndef COTATION_H +#define COTATION_H + +#include "base_struct.h" + +class COTATION: public EDA_BaseStruct +{ + public: + int m_Layer; // 0.. 32 ( NON bit a bit) + int m_Width; + wxPoint m_Pos; + int m_Shape; + int m_Unit; /* 0 = inches, 1 = mm */ + int m_Value; /* valeur en unites PCB de la cote */ + + TEXTE_PCB * m_Text; /* pour affichage du texte */ + int Barre_ox, Barre_oy, Barre_fx, Barre_fy; + int TraitG_ox, TraitG_oy, TraitG_fx, TraitG_fy; + int TraitD_ox, TraitD_oy, TraitD_fx, TraitD_fy; + int FlecheD1_ox, FlecheD1_oy, FlecheD1_fx, FlecheD1_fy; + int FlecheD2_ox, FlecheD2_oy, FlecheD2_fx, FlecheD2_fy; + int FlecheG1_ox, FlecheG1_oy, FlecheG1_fx, FlecheG1_fy; + int FlecheG2_ox, FlecheG2_oy, FlecheG2_fx, FlecheG2_fy; + + public: + COTATION(EDA_BaseStruct * StructFather); + ~COTATION(void); + + bool ReadCotationDescr(FILE * File, int * LineNum); + bool WriteCotationDescr(FILE * File); + + /* supprime du chainage la structure Struct */ + void UnLink( void ); + + /* Modification du texte de la cotation */ + void SetText(const wxString & NewText); + + void Copy(COTATION * source); + + void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int mode_color); + +}; + +#endif // #define COTATION_H diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp new file mode 100644 index 0000000000..35d4e6f16e --- /dev/null +++ b/pcbnew/class_edge_mod.cpp @@ -0,0 +1,402 @@ + /****************************************************/ + /* class_module.cpp : fonctions de la classe MODULE */ + /****************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "wxstruct.h" +#include "common.h" +#include "trigo.h" + +#ifdef PCBNEW +#include "pcbnew.h" +#include "autorout.h" +#include "drag.h" +#endif + +#ifdef CVPCB +#include "cvpcb.h" + +#endif + +#include "protos.h" + +#define MAX_WIDTH 10000 // Epaisseur (en 1/10000 ") max raisonnable des traits, textes... + + /******************************************/ + /* class EDGE_MODULE ( contour de module ) */ + /******************************************/ + +EDGE_MODULE::EDGE_MODULE(MODULE * parent): EDA_BaseLineStruct( parent, TYPEEDGEMODULE) +{ + m_Shape = S_SEGMENT; + m_Angle = 0; + m_Width = 120; + m_PolyCount = 0; // For polygons : number of points (> 2) + m_PolyList = NULL; // For polygons: coord list (1 point = 2 coord) +} + +EDGE_MODULE::~EDGE_MODULE() +{ + if ( m_PolyList ) free (m_PolyList); + m_PolyList = NULL; + m_PolyCount = 0; +} + +/********************************************/ +void EDGE_MODULE:: Copy(EDGE_MODULE * source) // copy structure +/********************************************/ +{ + if (source == NULL) return; + + m_Start = source->m_Start; + m_End = source->m_End; + m_Shape = source->m_Shape; + m_Start0 = source->m_Start0; // coord relatives a l'ancre du point de depart(Orient 0) + m_End0 = source->m_End0; // coord relatives a l'ancre du point de fin (Orient 0) + m_Angle = source->m_Angle; // pour les arcs de cercle: longueur de l'arc en 0,1 degres + m_Layer = source->m_Layer; + m_Width = source->m_Width; + if ( m_PolyList ) free (m_PolyList); + m_PolyCount = 0; + m_PolyList = NULL; + if ( source->m_PolyCount && source->m_PolyList ) + { + int size; + m_PolyCount = source->m_PolyCount; // For polygons : number of points + size = m_PolyCount * 2 * sizeof(int); // For polygons: 1 point = 2 coord + m_PolyList = (int*) MyMalloc( size ); + memcpy (m_PolyList, source->m_PolyList, size); + } + +} + + +void EDGE_MODULE::UnLink( void ) +{ + /* Modification du chainage arriere */ + if( Pback ) + { + if( Pback->m_StructType != TYPEMODULE) + { + Pback->Pnext = Pnext; + } + + else /* Le chainage arriere pointe sur la structure "Pere" */ + { + ((MODULE*) Pback)->m_Drawings = Pnext; + } + } + + /* Modification du chainage avant */ + if( Pnext) Pnext->Pback = Pback; + + Pnext = Pback = NULL; +} + + +/***********************************/ +void EDGE_MODULE::SetDrawCoord(void) +/***********************************/ +{ +MODULE * Module = (MODULE*) m_Parent; + m_Start = m_Start0; + m_End = m_End0; + + if ( Module ) + { + RotatePoint( &m_Start.x, &m_Start.y, Module->m_Orient); + RotatePoint( &m_End.x, &m_End.y, Module->m_Orient); + m_Start.x += Module->m_Pos.x; + m_Start.y += Module->m_Pos.y; + m_End.x += Module->m_Pos.x; + m_End.y += Module->m_Pos.y; + } +} + + +/********************************************************************************/ +void EDGE_MODULE::Draw(WinEDA_DrawPanel * panel, wxDC * DC, + const wxPoint & offset, int draw_mode) +/********************************************************************************/ + +/* Affichage d'un segment contour de module : + Entree : ox, oy = offset de trace + draw_mode = mode de trace ( GR_OR, GR_XOR, GR_AND) + Les contours sont de differents type: + - Segment + - Cercles + - Arcs +*/ +{ +int ux0, uy0, dx, dy,rayon, StAngle, EndAngle; +int color , type_trace; +int zoom; +int typeaff; +PCB_SCREEN * screen; +WinEDA_BasePcbFrame * frame; +MODULE * Module = NULL; + + if ( m_Parent && (m_Parent->m_StructType == TYPEMODULE) ) + Module = (MODULE*) m_Parent; + + color = g_DesignSettings.m_LayerColor[m_Layer]; + if ( (color & ITEM_NOT_SHOW) != 0 ) return; + + if ( panel ) screen = (PCB_SCREEN *) panel->m_Parent->m_CurrentScreen; + else screen = (PCB_SCREEN *) ActiveScreen; + + frame = ( WinEDA_BasePcbFrame * ) panel->m_Parent; + + zoom = screen->GetZoom(); + + type_trace = m_Shape; + ux0 = m_Start.x - offset.x; uy0 = m_Start.y - offset.y; + dx = m_End.x - offset.x ; + dy = m_End.y - offset.y ; + + GRSetDrawMode(DC, draw_mode); + typeaff = frame->m_DisplayModEdge; + if( m_Layer <= CMP_N ) + typeaff = frame->m_DisplayPcbTrackFill; + if( (m_Width /zoom) < L_MIN_DESSIN ) typeaff = FILAIRE; + + switch (type_trace ) + { + case S_SEGMENT: + if( typeaff == FILAIRE) + GRLine(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, color); + else Affiche_1_Segment(panel, DC, ux0,uy0,dx,dy,m_Width, + typeaff,color); + break ; + + case S_CIRCLE: + rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) ); + if( typeaff == FILAIRE) + { + GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon, color) ; + } + else + { + if(typeaff == FILLED ) + { + GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon, m_Width, color); + } + else + { + GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon + (m_Width/2), color) ; + GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon - (m_Width/2), color) ; + } + } + break; + + case S_ARC: + rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) ); + StAngle = (int)ArcTangente( dy-uy0, dx-ux0 ); + EndAngle = StAngle + m_Angle; + if ( StAngle > EndAngle) EXCHG (StAngle, EndAngle); + if( typeaff == FILAIRE) + { + GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon, color) ; + } + else if(typeaff == FILLED ) + { + GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon, + m_Width, color); + } + else + { + GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, + rayon + (m_Width/2), color) ; + GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, + rayon - (m_Width/2), color) ; + } + break; + + case S_POLYGON: + { + // We must compute true coordinates from m_PolyList + // which are relative to module position, orientation 0 + int ii, * source, * ptr, * ptr_base; + ptr = ptr_base = (int*) MyMalloc( 2 * m_PolyCount * sizeof(int) ); + source = m_PolyList; + for (ii = 0; ii < m_PolyCount; ii++ ) + { + int x, y; + x = *source; source++; y = *source; source++; + if ( Module ) + { + RotatePoint (&x, &y, Module->m_Orient); + x += Module->m_Pos.x; + y += Module->m_Pos.y; + } + x += m_Start0.x - offset.x; + y += m_Start0.y - offset.y; + *ptr = x; ptr++; *ptr = y; ptr++; + } + GRPoly(&panel->m_ClipBox, DC, m_PolyCount, ptr_base, + TRUE, color, color); + free ( ptr_base); + break; + } + } +} + + +/*****************************************/ +int EDGE_MODULE::WriteDescr( FILE * File ) +/*****************************************/ +/* Write one EDGE_MODULE description + File must be opened. +*/ +{ +int NbLigne = 0, ii, *ptr; + + switch(m_Shape ) + { + case S_SEGMENT: + fprintf(File,"DS %d %d %d %d %d %d\n", + m_Start0.x, m_Start0.y, + m_End0.x, m_End0.y, + m_Width, m_Layer); + NbLigne++; + break; + + case S_CIRCLE: + fprintf(File,"DC %d %d %d %d %d %d\n", + m_Start0.x, m_Start0.y, + m_End0.x, m_End0.y, + m_Width, m_Layer); + NbLigne++; + break; + + case S_ARC: + fprintf(File,"DA %d %d %d %d %d %d %d\n", + m_Start0.x, m_Start0.y, + m_End0.x, m_End0.y, + m_Angle, + m_Width, m_Layer); + NbLigne++; + break; + + case S_POLYGON: + fprintf(File,"DP %d %d %d %d %d %d %d\n", + m_Start0.x, m_Start0.y, + m_End0.x, m_End0.y, + m_PolyCount, + m_Width, m_Layer); + NbLigne++; + for ( ii = 0, ptr = m_PolyList; ii < m_PolyCount; ii++ ) + { + fprintf(File,"Dl %d %d\n", + *ptr, *(ptr+1)); + NbLigne++; ptr += 2; + } + break; + + default: + DisplayError(NULL, wxT("Type Edge Module inconnu") ); + break; + } + + return(NbLigne); +} + + +/****************************************************************/ +int EDGE_MODULE::ReadDescr(char * Line, FILE * File, + int * LineNum) +/***************************************************************/ +/* Read a description line like: +DS 2600 0 2600 -600 120 21 +this description line is in Line +EDGE_MODULE type can be: + - Circle, + - Segment (line) + - Arc + - Polygon + +*/ +{ +int ii, *ptr; +int error = 0; +char Buf[1024]; + + + switch ( Line[1] ) + { + case 'S': + m_Shape = S_SEGMENT; + break; + case 'C': + m_Shape = S_CIRCLE; + break; + case 'A': + m_Shape = S_ARC; + break; + case 'P': + m_Shape = S_POLYGON; + break; + default: + wxString msg; + msg.Printf( wxT("Unknown EDGE_MODULE type <%s>") , Line); + DisplayError(NULL, msg); + error = 1; + break; + } + + switch ( m_Shape ) + { + case S_ARC: + sscanf(Line+3,"%d %d %d %d %d %d %d", + &m_Start0.x, &m_Start0.y, + &m_End0.x, &m_End0.y, + &m_Angle, &m_Width, &m_Layer); + break; + + case S_SEGMENT: + case S_CIRCLE: + sscanf(Line+3,"%d %d %d %d %d %d", + &m_Start0.x, &m_Start0.y, + &m_End0.x, &m_End0.y, + &m_Width, &m_Layer); + break; + + case S_POLYGON: + sscanf(Line+3,"%d %d %d %d %d %d %d", + &m_Start0.x, &m_Start0.y, + &m_End0.x, &m_End0.y, + &m_PolyCount, &m_Width, &m_Layer); + (*LineNum)++; + m_PolyList = (int*) MyZMalloc( 2 * m_PolyCount * sizeof(int) ); + for ( ii = 0, ptr = m_PolyList; ii < m_PolyCount; ii++ ) + { + if( GetLine(File, Buf, LineNum , sizeof(Buf) -1) != NULL ) + { + if( strncmp(Buf, "Dl", 2) != 0 ) { error = 1; break;} + sscanf(Buf+3,"%d %d\n", ptr, ptr+1); + (*LineNum)++; ptr += 2; + } + else { + error = 1; break; + } + } + break; + + default: + sscanf(Line+3,"%d %d %d %d %d %d", + &m_Start0.x, &m_Start0.y, + &m_End0.x, &m_End0.y, + &m_Width, &m_Layer); + break; + } + + // Controle d'epaisseur raisonnable: + if( m_Width <= 1 ) m_Width = 1; + if( m_Width > MAX_WIDTH ) m_Width = MAX_WIDTH; + + return error; + +} + diff --git a/pcbnew/class_edge_mod.h b/pcbnew/class_edge_mod.h new file mode 100644 index 0000000000..240b0263d0 --- /dev/null +++ b/pcbnew/class_edge_mod.h @@ -0,0 +1,43 @@ + /**************************************************************/ + /* class_edge_module.h : description des contours d'un module */ + /**************************************************************/ + +class Pcb3D_GLCanvas; + + +/* description des contours (empreintes ) et TYPES des CONTOURS : */ + +class EDGE_MODULE: public EDA_BaseLineStruct + { + public: + int m_Shape ; // voir "enum Track_Shapes" + wxPoint m_Start0; // coord relatives a l'ancre du point de depart(Orient 0) + wxPoint m_End0; // coord relatives a l'ancre du point de fin (Orient 0) + int m_Angle; // pour les arcs de cercle: longueur de l'arc en 0,1 degres + int m_PolyCount; // For polygons : number of points (> 2) + int * m_PolyList; // For polygons: coord list (1 point = 2 coord) + // Coord are relative to Origine, orient 0 + + public: + EDGE_MODULE(MODULE * parent ); + EDGE_MODULE(EDGE_MODULE * edge ); + ~EDGE_MODULE(); + + /* supprime du chainage la structure Struct */ + void UnLink( void ); + + void Copy(EDGE_MODULE * source); // copy structure + + /* Readind and writing data on files */ + int WriteDescr( FILE * File ); + int ReadDescr( char * Line, FILE * File, int * LineNum = NULL); + + // Mise a jour des coordonées pour l'affichage + void SetDrawCoord(void); + + /* drawing functions */ + void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, + int draw_mode); + void Draw3D(Pcb3D_GLCanvas * glcanvas); +}; + diff --git a/pcbnew/class_equipot.cpp b/pcbnew/class_equipot.cpp new file mode 100644 index 0000000000..cf3f84e6db --- /dev/null +++ b/pcbnew/class_equipot.cpp @@ -0,0 +1,141 @@ +/*****************************************************************/ +/* fonctions membres de la classe EQUIPOT et fonctions associées */ +/*****************************************************************/ + +#include "fctsys.h" +#include "wxstruct.h" + +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#ifdef CVPCB +#include "cvpcb.h" +#endif + +#include "protos.h" + + + /*********************************************************/ + /* classe EQUIPOT: gestion des listes d'equipotentielles */ + /*********************************************************/ + +/* Constructeur de la classe EQUIPOT */ +EQUIPOT::EQUIPOT(EDA_BaseStruct * StructFather): + EDA_BaseStruct( StructFather, PCB_EQUIPOT_STRUCT_TYPE) +{ + m_NetCode = 0; + m_NbNodes = m_NbLink = m_NbNoconn = 0; + m_Masque_Layer = 0; + m_Masque_Plan = 0; + m_ForceWidth = 0; + m_PadzoneStart = NULL;// pointeur sur debut de liste pads du net + m_PadzoneEnd = NULL; // pointeur sur fin de liste pads du net + m_RatsnestStart = NULL; // pointeur sur debut de liste ratsnests du net + m_RatsnestEnd = NULL; // pointeur sur fin de liste ratsnests du net + +} + + /* destructeut */ + +EQUIPOT::~EQUIPOT(void) +{ +} + +void EQUIPOT::UnLink( void ) +{ + /* Modification du chainage arriere */ + if( Pback ) + { + if( Pback->m_StructType != TYPEPCB) + { + Pback->Pnext = Pnext; + } + + else /* Le chainage arriere pointe sur la structure "Pere" */ + { + ((BOARD*)Pback)->m_Equipots = (EQUIPOT*)Pnext; + } + } + + /* Modification du chainage avant */ + if( Pnext) Pnext->Pback = Pback; + + Pnext = Pback = NULL; +} + + +/*************************************************/ +EQUIPOT * GetEquipot(BOARD * pcb, int netcode) +/**************************************************/ +/* + retourne un pointeur sur la structure EQUIPOT de numero netcode +*/ +{ +EQUIPOT * Equipot ; + + if( netcode <= 0 ) return NULL; + + Equipot = (EQUIPOT*)pcb->m_Equipots; + while ( Equipot ) + { + if(Equipot->m_NetCode == netcode ) break; + Equipot = (EQUIPOT*) Equipot->Pnext; + } + + return(Equipot); +} + + +/*********************************************************/ +int EQUIPOT:: ReadEquipotDescr(FILE * File, int * LineNum) +/*********************************************************/ +/* Routine de lecture de 1 descr Equipotentielle. + retourne 0 si OK + 1 si lecture incomplete +*/ +{ +char Line[1024], Ltmp[1024]; +int tmp; + + while( GetLine(File, Line, LineNum ) ) + { + if( strnicmp(Line,"$End",4) == 0 )return 0; + + if( strncmp(Line,"Na", 2) == 0 ) /* Texte */ + { + sscanf(Line+2," %d", &tmp); + m_NetCode = tmp; + + ReadDelimitedText(Ltmp, Line + 2, sizeof(Ltmp) ); + m_Netname = CONV_FROM_UTF8(Ltmp); + continue; + } + + if( strncmp(Line,"Lw", 2) == 0 ) /* Texte */ + { + sscanf(Line+2," %d", &tmp); + m_ForceWidth = tmp; + continue; + } + } + return 1; +} + + +/********************************************/ +int EQUIPOT:: WriteEquipotDescr(FILE * File) +/********************************************/ +{ + if( GetState(DELETED) ) return(0); + + fprintf( File,"$EQUIPOT\n"); + fprintf( File,"Na %d \"%.16s\"\n", m_NetCode, CONV_TO_UTF8(m_Netname) ); + fprintf( File,"St %s\n","~"); + if( m_ForceWidth) fprintf( File,"Lw %d\n",m_ForceWidth ); + fprintf( File,"$EndEQUIPOT\n"); + return(1); +} + + diff --git a/pcbnew/class_equipot.h b/pcbnew/class_equipot.h new file mode 100644 index 0000000000..faea92a85d --- /dev/null +++ b/pcbnew/class_equipot.h @@ -0,0 +1,36 @@ + /*************************************************************************/ + /* classe EQUIPOT: definition des elements relatifs aux equipotentielles */ + /*************************************************************************/ + + +/* Representation des descriptions des equipotentielles */ + +class EQUIPOT: public EDA_BaseStruct +{ +public: + wxString m_Netname; // nom du net + int status; // no route, hight light... + int m_NetCode; // numero de code interne du net + int m_NbNodes; // nombre de pads appartenant au net + int m_NbLink; // nombre de chevelus + int m_NbNoconn; // nombre de chevelus actifs + int m_Masque_Layer; // couches interdites (bit 0 = layer 0...) + int m_Masque_Plan; // couches mises en plan de cuivre + int m_ForceWidth; // specific width (O = default width) + LISTE_PAD * m_PadzoneStart;// pointeur sur debut de liste pads du net + LISTE_PAD * m_PadzoneEnd; // pointeur sur fin de liste pads du net + CHEVELU * m_RatsnestStart; // pointeur sur debut de liste ratsnests du net + CHEVELU * m_RatsnestEnd; // pointeur sur fin de liste ratsnests du net + + EQUIPOT(EDA_BaseStruct * StructFather); + ~EQUIPOT(void); + + /* Effacement memoire de la structure */ + void UnLink( void ); + + /* Readind and writing data on files */ + int ReadEquipotDescr(FILE * File, int * LineNum); + int WriteEquipotDescr(FILE * File); +}; + + diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp new file mode 100644 index 0000000000..e45d414ca9 --- /dev/null +++ b/pcbnew/class_mire.cpp @@ -0,0 +1,196 @@ +/****************************************************/ +/* fonctions de la classe MIRE (targets for photos) */ +/****************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + + + +MIREPCB::MIREPCB(EDA_BaseStruct * StructFather): + EDA_BaseStruct( StructFather, TYPEMIRE) +{ + m_Shape = 0; + m_Size = 5000; +} + +MIREPCB::~MIREPCB(void) +{ +} + + +/***************************/ +void MIREPCB::UnLink( void ) +/***************************/ +/* supprime du chainage la structure Struct + les structures arrieres et avant sont chainees directement + */ +{ + /* Modification du chainage arriere */ + if( Pback ) + { + if( Pback->m_StructType != TYPEPCB) + { + Pback->Pnext = Pnext; + } + + else /* Le chainage arriere pointe sur la structure "Pere" */ + { + ((BOARD*)Pback)->m_Drawings = Pnext; + } + } + + /* Modification du chainage avant */ + if( Pnext) Pnext->Pback = Pback; + + Pnext = Pback = NULL; +} + + +/**********************************/ +void MIREPCB::Copy(MIREPCB * source) +/**********************************/ +{ + m_Layer = source->m_Layer; + m_Width = source->m_Width; + m_Pos = source->m_Pos; + m_Shape = source->m_Shape; + m_Size = source->m_Size; + m_TimeStamp = GetTimeStamp(); +} + + +/**************************************************************/ +bool MIREPCB::ReadMirePcbDescr(FILE * File, int * LineNum) +/**************************************************************/ +/* Lecture de la description de 1 segment type Drawing PCB +*/ +{ +char Line[256]; + + while( GetLine(File, Line, LineNum ) != NULL ) + { + if(strnicmp(Line,"$End",4 ) == 0 ) return TRUE; /* fin de liste */ + if(Line[0] == 'P') + { + sscanf( Line+2," %X %d %d %d %d %d %lX", + &m_Shape, &m_Layer, + &m_Pos.x, &m_Pos.y, + &m_Size, &m_Width, &m_TimeStamp ); + if ( m_Layer < FIRST_NO_COPPER_LAYER ) + m_Layer = FIRST_NO_COPPER_LAYER; + if ( m_Layer > LAST_NO_COPPER_LAYER ) + m_Layer = LAST_NO_COPPER_LAYER; + + } + } + return FALSE; +} + + +/************************************************/ +bool MIREPCB::WriteMirePcbDescr(FILE * File) +/************************************************/ +{ + if( GetState(DELETED) ) return FALSE; + + fprintf( File, "$MIREPCB\n"); + fprintf( File,"Po %X %d %d %d %d %d %8.8lX\n", + m_Shape, m_Layer, + m_Pos.x, m_Pos.y, + m_Size, m_Width, m_TimeStamp ); + fprintf( File, "$EndMIREPCB\n"); + return TRUE; +} + + +/**********************************************************/ +void MIREPCB::Draw(WinEDA_DrawPanel * panel, wxDC * DC, + const wxPoint & offset, int mode_color) +/**********************************************************/ +/* Affichage de 1 mire : 2 segments + 1 cercle + le cercle a pour rayon le demi rayon de la mire + les 2 traits ont pour longueur le diametre de la mire +*/ +{ +int rayon, ox, oy, gcolor, width; +int dx1,dx2, dy1, dy2; +int typeaff; +int zoom; + + ox = m_Pos.x + offset.x; + oy = m_Pos.y + offset.y; + + gcolor = g_DesignSettings.m_LayerColor[m_Layer]; + if ( (gcolor & ITEM_NOT_SHOW) != 0 ) return; + + zoom = panel->GetZoom(); + + GRSetDrawMode(DC, mode_color); + typeaff = DisplayOpt.DisplayDrawItems; + width = m_Width; + if( width/zoom < 2 ) typeaff = FILAIRE; + + /* Trace du cercle: */ + rayon = m_Size / 4; + switch( typeaff ) + { + case FILAIRE: + GRCircle(&panel->m_ClipBox, DC, ox, oy, rayon, gcolor) ; + break; + + default: + case FILLED: + GRCircle(&panel->m_ClipBox, DC, ox, oy, rayon, width, gcolor); + break; + + case SKETCH: + GRCircle(&panel->m_ClipBox, DC, ox, oy, rayon + (width/2), gcolor) ; + GRCircle(&panel->m_ClipBox, DC, ox, oy, rayon - (width/2), gcolor) ; + break; + } + + + /* Trace des 2 traits */ + rayon = m_Size/2; + dx1 = rayon, dy1 = 0; + dx2 = 0, dy2 = rayon; + + if( m_Shape) /* Forme X */ + { + dx1 = dy1 = (rayon * 7)/5; + dx2 = dx1; dy2 = -dy1; + } + + switch( typeaff ) + { + case FILAIRE: + GRLine(&panel->m_ClipBox, DC, ox - dx1, oy - dy1, + ox + dx1, oy + dy1, gcolor); + GRLine(&panel->m_ClipBox, DC, ox - dx2, oy - dy2, + ox + dx2, oy + dy2, gcolor); + break; + + case FILLED: + GRFillCSegm(&panel->m_ClipBox, DC, ox - dx1, oy - dy1, + ox + dx1, oy + dy1, + width, gcolor); + GRFillCSegm(&panel->m_ClipBox, DC, ox - dx2, oy - dy2, + ox + dx2, oy + dy2, + width, gcolor); + break; + + case SKETCH: + GRCSegm(&panel->m_ClipBox, DC, ox - dx1, oy - dy1, + ox + dx1, oy + dy1, + width, gcolor); + GRCSegm(&panel->m_ClipBox, DC, ox - dx2, oy - dy2, + ox + dx2, oy + dy2, + width, gcolor); + break; + } +} + diff --git a/pcbnew/class_mire.h b/pcbnew/class_mire.h new file mode 100644 index 0000000000..cef43e26f3 --- /dev/null +++ b/pcbnew/class_mire.h @@ -0,0 +1,37 @@ +/****************************************************/ +/* fonctions de la classe MIRE (targets for photos) */ +/****************************************************/ +#ifndef MIRE_H +#define MIRE_H + +#include "base_struct.h" + + +class MIREPCB: public EDA_BaseStruct + { + public: + int m_Layer; // 0.. 32 ( NON bit a bit) + int m_Width; + wxPoint m_Pos; + int m_Shape; // bit 0 : 0 = forme +, 1 = forme X + int m_Size; + + public: + MIREPCB(EDA_BaseStruct * StructFather); + ~MIREPCB(void); + + bool WriteMirePcbDescr(FILE * File); + bool ReadMirePcbDescr(FILE * File, int * LineNum); + + /* supprime du chainage la structure Struct */ + void UnLink( void ); + + void Copy(MIREPCB * source); + + void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int mode_color); + +}; + + + +#endif // #define MIRE_H diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp new file mode 100644 index 0000000000..40cf7a874f --- /dev/null +++ b/pcbnew/class_module.cpp @@ -0,0 +1,1072 @@ + /****************************************************/ + /* class_module.cpp : fonctions de la classe MODULE */ + /****************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "wxstruct.h" +#include "common.h" +#include "plot_common.h" +#include "pcbnew.h" +#include "trigo.h" + +#ifdef PCBNEW +#include "autorout.h" +#include "drag.h" +#endif + +#ifdef CVPCB +#include "cvpcb.h" +#endif + +#include "3d_struct.h" +#include "protos.h" + +#define MAX_WIDTH 10000 // Epaisseur (en 1/10000 ") max raisonnable des traits, textes... + +/*********************************************************************************/ +void MODULE::DrawAncre(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, + int dim_ancre, int draw_mode) +/*********************************************************************************/ +/* trace de l'ancre (croix verticale) +(doit etre fait apres les pads, +car le trace du trou efface tout donc peut etre l'ancre */ +{ +int zoom = panel->GetZoom(); +int anchor_size = dim_ancre * zoom; + + GRSetDrawMode(DC, draw_mode); + + if((g_AnchorColor & ITEM_NOT_SHOW) == 0 ) + { + GRLine(&panel->m_ClipBox, DC, + m_Pos.x - offset.x - anchor_size, m_Pos.y - offset.y, + m_Pos.x -offset.x + anchor_size,m_Pos.y - offset.y, + g_AnchorColor); + GRLine(&panel->m_ClipBox, DC, + m_Pos.x - offset.x, m_Pos.y - offset.y - anchor_size , + m_Pos.x - offset.x, m_Pos.y - offset.y + anchor_size , + g_AnchorColor); + } +} + + + /*************************************************/ + /* Class MODULE : description d'un composant pcb */ + /*************************************************/ + +/* Constructeur de la classe MODULE */ +MODULE::MODULE(BOARD * parent): EDA_BaseStruct( parent, TYPEMODULE) +{ + m_Pads = NULL; + m_Drawings = NULL; + m_3D_Drawings = NULL; + m_Attributs = MOD_DEFAULT; + m_Layer = CMP_N; + m_Orient = 0; + m_ModuleStatus = 0; + flag = 0; + m_CntRot90 = m_CntRot180 = 0; + m_Surface = 0; + m_Link = 0; + m_LastEdit_Time = time(NULL); + m_Reference = new TEXTE_MODULE(this, TEXT_is_REFERENCE); + m_Reference->Pback = this; + m_Value = new TEXTE_MODULE(this, TEXT_is_VALUE); + m_Value->Pback = this; + m_3D_Drawings = new Struct3D_Master(this); +} + + /* Destructeur */ +MODULE::~MODULE(void) +{ +D_PAD * Pad; +EDA_BaseStruct * Struct, * NextStruct; + + delete m_Reference; + delete m_Value; + for ( Struct = m_3D_Drawings; Struct != NULL; Struct = NextStruct) + { + NextStruct = Struct->Pnext; + delete Struct; + } + + /* effacement des pads */ + for( Pad = m_Pads; Pad != NULL; Pad = (D_PAD*)NextStruct ) + { + NextStruct = Pad->Pnext; + delete Pad; + } + + /* effacement des elements de trace */ + for ( Struct = m_Drawings; Struct != NULL; Struct = NextStruct ) + { + NextStruct = Struct->Pnext; + switch( (Struct->m_StructType) ) + { + case TYPEEDGEMODULE: + delete (EDGE_MODULE*)Struct; + break; + + case TYPETEXTEMODULE: + delete (TEXTE_MODULE*)Struct; + break; + + default: + DisplayError(NULL, wxT("Warn: ItemType not handled in delete MODULE")); + NextStruct = NULL; + break; + } + } +} + +/*********************************/ +void MODULE::Copy(MODULE * Module) +/*********************************/ +{ +D_PAD * pad,* lastpad; + + m_Pos = Module->m_Pos; + m_Layer = Module->m_Layer; + m_LibRef = Module->m_LibRef; + m_Attributs = Module->m_Attributs; + m_Orient = Module->m_Orient; + m_BoundaryBox = Module->m_BoundaryBox; + m_PadNum = Module->m_PadNum; + m_CntRot90 = Module->m_CntRot90; + m_CntRot180 = Module->m_CntRot180; + m_LastEdit_Time = Module->m_LastEdit_Time; + m_TimeStamp = GetTimeStamp(); + + /* Copy des structures auxiliaires: Reference et value */ + m_Reference->Copy(Module->m_Reference); + m_Value->Copy(Module->m_Value); + + /* Copie des structures auxiliaires: Pads */ + lastpad = NULL; pad = Module->m_Pads; + for( ;pad != NULL ; pad = (D_PAD*)pad->Pnext) + { + D_PAD * newpad = new D_PAD (this); + newpad->Copy(pad); + + if(m_Pads == NULL) + { + newpad->Pback = this; + m_Pads = (D_PAD*)newpad; + } + else + { + newpad->Pback = lastpad; + lastpad->Pnext = newpad; + } + lastpad = newpad; + } + + /* Copy des structures auxiliaires: Drawings */ + EDA_BaseStruct* OldStruct = (EDA_BaseStruct*) Module->m_Drawings; + EDA_BaseStruct* NewStruct, *LastStruct = NULL; + for( ;OldStruct ; OldStruct = OldStruct->Pnext) + { + NewStruct = NULL; + switch(OldStruct->m_StructType) + { + case TYPETEXTEMODULE: + NewStruct = new TEXTE_MODULE( this ); + ((TEXTE_MODULE*)NewStruct)->Copy((TEXTE_MODULE*)OldStruct); + break; + + case TYPEEDGEMODULE: + NewStruct = new EDGE_MODULE( this ); + ((EDGE_MODULE*)NewStruct)->Copy((EDGE_MODULE*)OldStruct); + break; + default: + DisplayError(NULL, wxT("Internal Err: CopyModule: type indefini")); + break; + } + if( NewStruct == NULL) break; + if(m_Drawings == NULL) + { + NewStruct->Pback = this; + m_Drawings = NewStruct; + } + else + { + NewStruct->Pback = LastStruct; + LastStruct->Pnext = NewStruct; + } + LastStruct = NewStruct; + } + + /* Copy des elements complementaires Drawings 3D */ + m_3D_Drawings->Copy(Module->m_3D_Drawings); +Struct3D_Master * Struct3D, *NewStruct3D, *CurrStruct3D; + Struct3D = (Struct3D_Master *) Module->m_3D_Drawings->Pnext; + CurrStruct3D = m_3D_Drawings; + for ( ; Struct3D != NULL; Struct3D = (Struct3D_Master*) Struct3D->Pnext) + { + NewStruct3D = new Struct3D_Master(this); + NewStruct3D->Copy(Struct3D); + CurrStruct3D->Pnext = NewStruct3D; + NewStruct3D->Pback = CurrStruct3D; + CurrStruct3D = NewStruct3D; + } + + /* Copie des elements complementaires */ + m_Doc = Module->m_Doc; + m_KeyWord = Module->m_KeyWord; + +} + +/* supprime du chainage la structure Struct + les structures arrieres et avant sont chainees directement + */ +void MODULE::UnLink( void ) +{ + /* Modification du chainage arriere */ + if( Pback ) + { + if( Pback->m_StructType != TYPEPCB) + { + Pback->Pnext = Pnext; + } + + else /* Le chainage arriere pointe sur la structure "Pere" */ + { + if ( GetState(DELETED) ) // A REVOIR car Pback = NULL si place en undelete + { + if( g_UnDeleteStack ) g_UnDeleteStack[g_UnDeleteStackPtr-1] = Pnext; + } + else ((BOARD*)Pback)->m_Modules = (MODULE *) Pnext; + } + } + + /* Modification du chainage avant */ + if( Pnext) Pnext->Pback = Pback; + + Pnext = Pback = NULL; +} + + +/**********************************************************/ +void MODULE::Draw(WinEDA_DrawPanel * panel, wxDC * DC, + const wxPoint & offset, int draw_mode) +/**********************************************************/ +/* Dessin d'une empreinte sur l'ecran actif: + Entree : + Module: pointeur sur le module + ox, oy = offset de trace + draw_mode = mode de trace ( GR_OR, GR_XOR, GR_AND) + Utilise par ailleur: + Description des parametres de l'empreinte calcules par caract() ; +*/ +{ +D_PAD * pt_pad ; +EDA_BaseStruct * PtStruct; +TEXTE_MODULE * PtTexte; + + /* trace des pastilles */ + pt_pad = m_Pads; + for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + { + if ( pt_pad->m_Flags & IS_MOVED ) continue; + pt_pad->Draw(panel, DC, offset,draw_mode); + } + + /* Impression de l'ancre du module */ + DrawAncre(panel, DC, offset, DIM_ANCRE_MODULE, draw_mode) ; + + /* impression des graphismes */ + if ( ! (m_Reference->m_Flags & IS_MOVED) ) + m_Reference->Draw(panel, DC, offset, draw_mode); + if ( ! (m_Value->m_Flags & IS_MOVED) ) + m_Value->Draw(panel, DC, offset, draw_mode); + + PtStruct = m_Drawings; + for( ;PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if ( PtStruct->m_Flags & IS_MOVED ) continue; + + switch( PtStruct->m_StructType ) + { + case TYPETEXTEMODULE: + PtTexte = (TEXTE_MODULE *) PtStruct; + PtTexte->Draw(panel, DC, offset, draw_mode); + break; + + case TYPEEDGEMODULE: + ((EDGE_MODULE *) PtStruct)->Draw(panel, DC, offset, draw_mode); + break; + + default: break; + } + } +} + + +/**************************************************************/ +void MODULE::DrawEdgesOnly(WinEDA_DrawPanel * panel, wxDC * DC, + const wxPoint & offset, int draw_mode) +/**************************************************************/ +{ +EDA_BaseStruct * PtStruct; + + /* impression des graphismes */ + PtStruct = m_Drawings; + for( ;PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEEDGEMODULE: + ((EDGE_MODULE *) PtStruct)->Draw(panel, DC, offset, draw_mode); + break; + + default: break; + } + } +} + + +/*************************************/ +int MODULE::WriteDescr( FILE * File ) +/*************************************/ +/* Sauvegarde de la description d'un MODULE +*/ +{ +char StringStat[20]; +TEXTE_MODULE * PtText; +EDGE_MODULE * PtEdge; +D_PAD * ptpad; +EDA_BaseStruct * PtStruct; +int ii, NbLigne = 0; +wxString msg; + + if( GetState(DELETED) ) return(NbLigne); + + /* Generation du fichier module: */ + fprintf( File,"$MODULE %s\n", CONV_TO_UTF8(m_LibRef)); + NbLigne++; + + /* Generation des coord et caracteristiques */ + memset(StringStat, 0, sizeof(StringStat) ); + if( m_ModuleStatus & MODULE_is_LOCKED) + StringStat[0] = 'F'; + else StringStat[0] = '~'; + if( m_ModuleStatus & MODULE_is_PLACED) + StringStat[1] = 'P'; + else StringStat[1] = '~'; + + fprintf( File,"Po %d %d %d %d %8.8lX %8.8lX %s\n", + m_Pos.x, m_Pos.y, + m_Orient, m_Layer,m_LastEdit_Time, + m_TimeStamp, StringStat); + NbLigne++; + + fprintf(File,"Li %s\n", CONV_TO_UTF8(m_LibRef)); + NbLigne++; + + if ( ! m_Doc.IsEmpty()) + { + fprintf(File,"Cd %s\n", CONV_TO_UTF8(m_Doc)); + NbLigne++; + } + + if ( ! m_KeyWord.IsEmpty()) + { + fprintf(File,"Kw %s\n", CONV_TO_UTF8(m_KeyWord)); + NbLigne++; + } + + fprintf(File,"Sc %8.8lX\n", m_TimeStamp); + NbLigne++; + + fprintf(File,"Op %X %X 0\n", m_CntRot90, m_CntRot180); + NbLigne++; + + /* Attributs du module */ + if( m_Attributs != MOD_DEFAULT ) + { + fprintf(File,"At "); + if( m_Attributs & MOD_CMS ) fprintf(File,"SMD "); + if( m_Attributs & MOD_VIRTUAL ) fprintf(File,"VIRTUAL "); + fprintf(File,"\n"); + } + + /* Texte Reference du module */ + fprintf(File,"T%d %d %d %d %d %d %d %c %c %d \"%.16s\"\n", + m_Reference->m_Type, + m_Reference->m_Pos0.x, m_Reference->m_Pos0.y, + m_Reference->m_Size.y,m_Reference->m_Size.x, + m_Reference->m_Orient + m_Orient, m_Reference->m_Width, + m_Reference->m_Miroir ? 'N' : 'M', m_Reference->m_NoShow ? 'I' : 'V', + m_Reference->m_Layer, + CONV_TO_UTF8(m_Reference->m_Text) ); + NbLigne++; + + /* Texte Value du module */ + fprintf(File,"T%d %d %d %d %d %d %d %c %c %d \"%.16s\"\n", + m_Value->m_Type, + m_Value->m_Pos0.x, m_Value->m_Pos0.y, + m_Value->m_Size.y,m_Value->m_Size.x, + m_Value->m_Orient + m_Orient, m_Value->m_Width, + m_Value->m_Miroir ? 'N' : 'M', m_Value->m_NoShow ? 'I' : 'V', + m_Value->m_Layer, + CONV_TO_UTF8(m_Value->m_Text) ); + NbLigne++; + + /* Generation des elements Drawing modules */ + PtStruct = m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext) + { + switch(PtStruct->m_StructType ) + { + case TYPETEXTEMODULE: + PtText = ((TEXTE_MODULE *) PtStruct); + fprintf(File,"T%d %d %d %d %d %d %d %c %c %d \"%s\"\n", + PtText->m_Type, + PtText->m_Pos0.x, PtText->m_Pos0.y, + PtText->m_Size.y,PtText->m_Size.x, + PtText->m_Orient + m_Orient, PtText->m_Width, + PtText->m_Miroir ? 'N' : 'M', + PtText->m_NoShow ? 'I' : 'V', + PtText->m_Layer, CONV_TO_UTF8(PtText->m_Text) ); + NbLigne++; + break; + + case TYPEEDGEMODULE: + PtEdge = (EDGE_MODULE*) PtStruct; + PtEdge->WriteDescr( File ); + break; + + default: + msg.Printf( wxT("Type (%d) Draw Module inconnu"), + PtStruct->m_StructType); + DisplayError(NULL, msg); + break; + } /* Fin switch gestion des Items draw */ + } + + /* Generation de la liste des pads */ + ptpad = m_Pads; + for( ; ptpad != NULL; ptpad = (D_PAD*)ptpad->Pnext) + { + ii = ptpad->WriteDescr(File); + NbLigne += ii; + } + + /* Generation des informations de tracé 3D */ + Write_3D_Descr( File ); + + /* Fin de description: */ + fprintf( File,"$EndMODULE %s\n", CONV_TO_UTF8(m_LibRef)); + NbLigne++; + return(NbLigne); +} + +/***************************************/ +int MODULE::Write_3D_Descr( FILE * File ) +/***************************************/ +/* Sauvegarde de la description 3D du MODULE +*/ +{ +char buf[512]; +Struct3D_Master * Struct3D = m_3D_Drawings; + + for ( ; Struct3D != NULL; Struct3D = (Struct3D_Master *) Struct3D->Pnext) + { + if ( ! Struct3D->m_Shape3DName.IsEmpty() ) + { + fprintf( File,"$SHAPE3D\n"); + + fprintf( File,"Na \"%s\"\n", CONV_TO_UTF8(Struct3D->m_Shape3DName)); + + sprintf( buf,"Sc %lf %lf %lf\n", + Struct3D->m_MatScale.x, + Struct3D->m_MatScale.y, + Struct3D->m_MatScale.z); + fprintf( File, to_point(buf) ); + + sprintf( buf,"Of %lf %lf %lf\n", + Struct3D->m_MatPosition.x, + Struct3D->m_MatPosition.y, + Struct3D->m_MatPosition.z); + fprintf( File, to_point(buf) ); + + sprintf( buf,"Ro %lf %lf %lf\n", + Struct3D->m_MatRotation.x, + Struct3D->m_MatRotation.y, + Struct3D->m_MatRotation.z); + fprintf( File, to_point(buf) ); + + fprintf( File,"$EndSHAPE3D\n"); + } + } + + return 0; +} + +/****************************************************/ +int MODULE::Read_3D_Descr( FILE * File, int * LineNum) +/****************************************************/ +/* Lecture de la description d'un MODULE (format Ascii) + la 1ere ligne de descr ($MODULE) est supposee etre deja lue + retourne 0 si OK +*/ +{ +char Line[1024]; +char * text = Line + 3; +Struct3D_Master * Struct3D = m_3D_Drawings; + + if ( ! Struct3D->m_Shape3DName.IsEmpty() ) + { + Struct3D_Master * NewStruct3D; + while ( Struct3D->Pnext ) + Struct3D = (Struct3D_Master *)Struct3D->Pnext; + Struct3D->Pnext = NewStruct3D = new Struct3D_Master(this); + NewStruct3D->Pback = Struct3D; + Struct3D = NewStruct3D; + } + + while( GetLine(File, Line, LineNum , sizeof(Line) -1) != NULL ) + { + switch( Line[0] ) + { + case '$': // Fin de description + if( Line[1] == 'E' ) return 0; + return 1; + + case 'N': // Shape File Name + { + char buf[512]; + ReadDelimitedText( buf, text, 512); + Struct3D->m_Shape3DName = CONV_FROM_UTF8(buf); + break; + } + + case 'S': // Scale + sscanf( from_point(text),"%lf %lf %lf\n", + &Struct3D->m_MatScale.x, + &Struct3D->m_MatScale.y, + &Struct3D->m_MatScale.z); + break; + + case 'O': // Offset + sscanf( from_point(text),"%lf %lf %lf\n", + &Struct3D->m_MatPosition.x, + &Struct3D->m_MatPosition.y, + &Struct3D->m_MatPosition.z); + break; + + case 'R': // Rotation + sscanf( from_point(text),"%lf %lf %lf\n", + &Struct3D->m_MatRotation.x, + &Struct3D->m_MatRotation.y, + &Struct3D->m_MatRotation.z); + break; + + default: + break; + } + } + return 1; +} + +/**************************************************/ +int MODULE::ReadDescr( FILE * File, int * LineNum) +/**************************************************/ +/* Lecture de la description d'un MODULE (format Ascii) + la 1ere ligne de descr ($MODULE) est supposee etre deja lue + retourne 0 si OK +*/ +{ +D_PAD * LastPad = NULL, * ptpad; +EDA_BaseStruct * LastModStruct = NULL; +EDGE_MODULE * DrawSegm; +TEXTE_MODULE * DrawText; +char Line[256], BufLine[256], BufCar1[128], BufCar2[128], *PtLine; +int itmp1, itmp2; + + while( GetLine(File, Line, LineNum , sizeof(Line) -1) != NULL ) + { + if( Line[0] == '$' ) + { + if( Line[1] == 'E' ) break; + if( Line[1] == 'P' ) + { + ptpad = new D_PAD(this); + ptpad->ReadDescr(File, LineNum ); + RotatePoint( &ptpad->m_Pos.x, &ptpad->m_Pos.y, m_Orient ); + ptpad->m_Pos.x += m_Pos.x; + ptpad->m_Pos.y += m_Pos.y; + + if(LastPad == NULL ) + { + ptpad->Pback = (EDA_BaseStruct *) this; + m_Pads = ptpad; + } + else + { + ptpad->Pback = (EDA_BaseStruct *) LastPad; + LastPad->Pnext = (EDA_BaseStruct *)ptpad; + } + LastPad = ptpad; + continue; + } + if( Line[1] == 'S' ) Read_3D_Descr(File, LineNum ); + } + + + if ( strlen(Line) < 4 ) continue; + PtLine = Line + 3; /* Pointe 1er code utile de la ligne */ + switch( Line[0] ) + { + case 'P': + memset(BufCar1, 0, sizeof(BufCar1) ); + sscanf( PtLine,"%d %d %d %d %lX %lX %s", + &m_Pos.x, &m_Pos.y, + &m_Orient, &m_Layer , + &m_LastEdit_Time, &m_TimeStamp,BufCar1); + + m_ModuleStatus = 0; + if(BufCar1[0] == 'F') m_ModuleStatus |= MODULE_is_LOCKED; + if(BufCar1[1] == 'P') m_ModuleStatus |= MODULE_is_PLACED; + break; + + case 'L': /* Li = Lecture du nom librairie du module */ + *BufLine = 0; + sscanf(PtLine," %s",BufLine); + m_LibRef = CONV_FROM_UTF8(BufLine); + break; + + case 'S': + sscanf(PtLine," %lX", &m_TimeStamp); + break; + + case 'O': /* (Op)tions de placement auto */ + itmp1 = itmp2 = 0; + sscanf(PtLine," %X %X", &itmp1, &itmp2); + + m_CntRot180 = itmp2 & 0x0F; + if( m_CntRot180 > 10 ) m_CntRot180 = 10; + + m_CntRot90 = itmp1 & 0x0F; + if( m_CntRot90 > 10 ) m_CntRot90 = 0; + itmp1 = (itmp1 >> 4) & 0x0F; + if( itmp1 > 10 ) itmp1 = 0; + m_CntRot90 |= itmp1 << 4; + break; + + case 'A': /* At = (At)tributs du module */ + if ( strstr(PtLine, "SMD") ) m_Attributs |= MOD_CMS; + if ( strstr(PtLine, "VIRTUAL") ) m_Attributs |= MOD_VIRTUAL; + break; + + case 'T': /* lecture des textes modules */ + sscanf(Line+1,"%d", &itmp1); + if ( itmp1 == TEXT_is_REFERENCE ) + DrawText = m_Reference; + else if ( itmp1 == TEXT_is_VALUE ) + DrawText = m_Value; + else /* text is a drawing */ + {DrawText = new TEXTE_MODULE(this); + if(LastModStruct == NULL ) + { + DrawText->Pback = this; + m_Drawings = (EDA_BaseStruct*) DrawText; + } + else + { + DrawText->Pback = LastModStruct; + LastModStruct->Pnext = DrawText; + } + LastModStruct = (EDA_BaseStruct*) DrawText; + } + + sscanf(Line+1,"%d %d %d %d %d %d %d %s %s %d", + &itmp1, + &DrawText->m_Pos0.x, &DrawText->m_Pos0.y, + &DrawText->m_Size.y, &DrawText->m_Size.x, + &DrawText->m_Orient, &DrawText->m_Width, + BufCar1, BufCar2, &DrawText->m_Layer); + + DrawText->m_Type = itmp1; + DrawText->m_Orient -= m_Orient; // m_Orient texte relative au module + if( BufCar1[0] == 'M') DrawText->m_Miroir = 0; + else DrawText->m_Miroir = 1; + if( BufCar2[0] == 'I') DrawText->m_NoShow = 1; + else DrawText->m_NoShow = 0; + + if(m_Layer == CUIVRE_N) DrawText->m_Layer = SILKSCREEN_N_CU; + if(m_Layer == CMP_N) DrawText->m_Layer = SILKSCREEN_N_CMP; + + /* calcul de la position vraie */ + DrawText->SetDrawCoord(); + /* Lecture de la chaine "text" */ + ReadDelimitedText(BufLine, Line , sizeof(BufLine) ); + DrawText->m_Text = CONV_FROM_UTF8(BufLine); + // Controle d'epaisseur raisonnable: + if( DrawText->m_Width <= 1 ) DrawText->m_Width = 1; + if( DrawText->m_Width > MAX_WIDTH ) DrawText->m_Width = MAX_WIDTH; + break; + + case 'D': /* lecture du contour */ + DrawSegm = new EDGE_MODULE(this); + + if(LastModStruct == NULL ) + { + DrawSegm->Pback = this; + m_Drawings = DrawSegm; + } + else + { + DrawSegm->Pback = LastModStruct; + LastModStruct->Pnext = DrawSegm; + } + + LastModStruct = DrawSegm; + DrawSegm->ReadDescr( Line, File, LineNum); + DrawSegm->SetDrawCoord(); + break; + + case 'C': /* Lecture de la doc */ + m_Doc = CONV_FROM_UTF8(StrPurge(PtLine)); + break; + + case 'K': /* Lecture de la liste des mots cle */ + m_KeyWord = CONV_FROM_UTF8(StrPurge(PtLine)); + break; + + default: + break; + } + } + /* Recalcul de l'encadrement */ + Set_Rectangle_Encadrement(); + return(0); +} + +/****************************************************/ +void MODULE::SetPosition(const wxPoint & newpos) +/****************************************************/ +// replace le module en position newpos +{ +int deltaX = newpos.x - m_Pos.x; +int deltaY = newpos.y - m_Pos.y; + + /* deplacement de l'ancre */ + m_Pos.x += deltaX ; m_Pos.y += deltaY ; + + /* deplacement de la reference */ + m_Reference->m_Pos.x += deltaX ; m_Reference->m_Pos.y += deltaY; + + /* deplacement de la Valeur */ + m_Value->m_Pos.x += deltaX ; m_Value->m_Pos.y += deltaY; + + /* deplacement des pastilles */ + D_PAD * pad = m_Pads; + for ( ; pad != NULL; pad = (D_PAD*) pad->Pnext ) + { + pad->m_Pos.x += deltaX ; pad->m_Pos.y += deltaY ; + } + + /* deplacement des dessins de l'empreinte : */ + EDA_BaseStruct * PtStruct = m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext) + { + switch( PtStruct->m_StructType) + { + case TYPEEDGEMODULE: + { + EDGE_MODULE * pt_edgmod = (EDGE_MODULE*) PtStruct; + pt_edgmod->SetDrawCoord(); + break; + } + + case TYPETEXTEMODULE: + { + TEXTE_MODULE * pt_texte = (TEXTE_MODULE*) PtStruct; + pt_texte->m_Pos.x += deltaX ; pt_texte->m_Pos.y += deltaY; + break; + } + + default: DisplayError(NULL, wxT("Type Draw Indefini")); break; + } + } + + Set_Rectangle_Encadrement(); +} + + + +/*********************************************/ +void MODULE::SetOrientation(int newangle) +/*********************************************/ +/* Tourne de newangle (en 0.1 degres) le module +*/ +{ +int px ,py; + + newangle -= m_Orient; // = delta de rotation + + m_Orient += newangle; + NORMALIZE_ANGLE_POS(m_Orient); + + /* deplacement et rotation des pastilles */ + D_PAD * pad = m_Pads; + for (; pad != NULL; pad = (D_PAD*) pad->Pnext ) + { + px = pad->m_Pos0.x; + py = pad->m_Pos0.y; + + pad->m_Orient += newangle ; /* change m_Orientation */ + NORMALIZE_ANGLE_POS(pad->m_Orient); + + RotatePoint( &px, &py, (int) m_Orient ); + pad->m_Pos.x = m_Pos.x + px; + pad->m_Pos.y = m_Pos.y + py; + } + + /* mise a jour de la reference et de la valeur*/ + m_Reference->SetDrawCoord(); + m_Value->SetDrawCoord(); + + /* deplacement des contours et textes de l'empreinte : */ + EDA_BaseStruct * PtStruct = m_Drawings; + for(; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if( PtStruct->m_StructType == TYPEEDGEMODULE ) + { + EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) PtStruct ; + pt_edgmod->SetDrawCoord(); + } + if( PtStruct->m_StructType == TYPETEXTEMODULE ) + { + /* deplacement des inscriptions : */ + TEXTE_MODULE * pt_texte = (TEXTE_MODULE*) PtStruct; + pt_texte->SetDrawCoord(); + } + } + + /* Recalcul du rectangle d'encadrement */ + Set_Rectangle_Encadrement(); +} + +/************************************************/ +void MODULE::Set_Rectangle_Encadrement(void) +/************************************************/ +/* Mise a jour du rectangle d'encadrement du module + Entree : pointeur sur module + Le rectangle d'encadrement est le rectangle comprenant les contours et les + pads. + Le rectangle est calcule: + pour orient 0 + en coord relatives / position ancre +*/ +{ +EDGE_MODULE* pt_edge_mod; +D_PAD * pad; +int width; +int cx, cy, uxf, uyf, rayon; +int xmax, ymax; + + + /* Init des pointeurs */ + pt_edge_mod = (EDGE_MODULE*) m_Drawings; + + /* Init des coord du cadre a une valeur limite non nulle */ + m_BoundaryBox.m_Pos.x = -500; xmax = 500; + m_BoundaryBox.m_Pos.y = -500; ymax = 500; + + /* Contours: Recherche des coord min et max et mise a jour du cadre */ + for( ;pt_edge_mod != NULL; pt_edge_mod = (EDGE_MODULE*)pt_edge_mod->Pnext ) + { + if( pt_edge_mod->m_StructType != TYPEEDGEMODULE) continue; + width = pt_edge_mod->m_Width / 2; + switch(pt_edge_mod->m_Shape) + { + case S_ARC: + case S_CIRCLE: + { + cx = pt_edge_mod->m_Start0.x; cy = pt_edge_mod->m_Start0.y ; // centre + uxf = pt_edge_mod->m_End0.x; uyf = pt_edge_mod->m_End0.y ; + rayon = (int)hypot((double)(cx-uxf),(double)(cy - uyf) ); + rayon += width; + m_BoundaryBox.m_Pos.x = min(m_BoundaryBox.m_Pos.x,cx - rayon); + m_BoundaryBox.m_Pos.y = min(m_BoundaryBox.m_Pos.y,cy - rayon); + xmax = max(xmax, cx + rayon); + ymax = max(ymax, cy + rayon); + break; + } + + default: + m_BoundaryBox.m_Pos.x = min(m_BoundaryBox.m_Pos.x,pt_edge_mod->m_Start0.x - width); + m_BoundaryBox.m_Pos.x = min(m_BoundaryBox.m_Pos.x,pt_edge_mod->m_End0.x - width); + m_BoundaryBox.m_Pos.y = min(m_BoundaryBox.m_Pos.y,pt_edge_mod->m_Start0.y - width); + m_BoundaryBox.m_Pos.y = min(m_BoundaryBox.m_Pos.y,pt_edge_mod->m_End0.y - width); + xmax = max(xmax, pt_edge_mod->m_Start0.x + width); + xmax = max(xmax, pt_edge_mod->m_End0.x + width); + ymax = max(ymax, pt_edge_mod->m_Start0.y + width); + ymax = max(ymax, pt_edge_mod->m_End0.y + width); + break; + } + } + + /* Pads: Recherche des coord min et max et mise a jour du cadre */ + for( pad = m_Pads; pad != NULL; pad = (D_PAD*)pad->Pnext ) + { + rayon = pad->m_Rayon; + cx = pad->m_Pos0.x; cy = pad->m_Pos0.y; + m_BoundaryBox.m_Pos.x = min(m_BoundaryBox.m_Pos.x,cx - rayon); + m_BoundaryBox.m_Pos.y = min(m_BoundaryBox.m_Pos.y,cy - rayon); + xmax = max(xmax, cx + rayon); + ymax = max(ymax, cy + rayon); + } + + m_BoundaryBox.SetWidth(xmax - m_BoundaryBox.m_Pos.x); + m_BoundaryBox.SetHeight(ymax - m_BoundaryBox.m_Pos.y); +} + + + + +/****************************************/ +void MODULE::SetRectangleExinscrit(void) +/****************************************/ + +/* Analogue a MODULE::Set_Rectangle_Encadrement() mais en coord reelles: + Mise a jour du rectangle d'encadrement reel du module c.a.d en coord PCB + Entree : pointeur sur module + Le rectangle d'encadrement est le rectangle comprenant les contours et les + pads. + Met egalement a jour la surface (.m_Surface) du module. +*/ +{ +EDGE_MODULE* EdgeMod; +D_PAD * Pad; +int width; +int cx, cy, uxf, uyf, rayon; +int xmax, ymax; + + m_RealBoundaryBox.m_Pos.x = xmax = m_Pos.x; + m_RealBoundaryBox.m_Pos.y = ymax = m_Pos.y; + + /* Contours: Recherche des coord min et max et mise a jour du cadre */ + EdgeMod = (EDGE_MODULE*)m_Drawings; + for( ;EdgeMod != NULL; EdgeMod = (EDGE_MODULE*)EdgeMod->Pnext ) + { + if( EdgeMod->m_StructType != TYPEEDGEMODULE) continue; + width = EdgeMod->m_Width / 2; + switch(EdgeMod->m_Shape) + { + case S_ARC: + case S_CIRCLE: + { + cx = EdgeMod->m_Start.x; cy = EdgeMod->m_Start.y ; // centre + uxf = EdgeMod->m_End.x; uyf = EdgeMod->m_End.y ; + rayon = (int)hypot((double)(cx-uxf),(double)(cy - uyf) ); + rayon += width; + m_RealBoundaryBox.m_Pos.x = min(m_RealBoundaryBox.m_Pos.x,cx - rayon); + m_RealBoundaryBox.m_Pos.y = min(m_RealBoundaryBox.m_Pos.y,cy - rayon); + xmax = max(xmax,cx + rayon); + ymax = max(ymax,cy + rayon); + break; + } + + default: + m_RealBoundaryBox.m_Pos.x = min(m_RealBoundaryBox.m_Pos.x,EdgeMod->m_Start.x - width); + m_RealBoundaryBox.m_Pos.x = min(m_RealBoundaryBox.m_Pos.x,EdgeMod->m_End.x - width); + m_RealBoundaryBox.m_Pos.y = min(m_RealBoundaryBox.m_Pos.y,EdgeMod->m_Start.y - width); + m_RealBoundaryBox.m_Pos.y = min(m_RealBoundaryBox.m_Pos.y,EdgeMod->m_End.y - width); + xmax = max(xmax,EdgeMod->m_Start.x + width); + xmax = max(xmax,EdgeMod->m_End.x + width); + ymax = max(ymax,EdgeMod->m_Start.y + width); + ymax = max(ymax,EdgeMod->m_End.y + width); + break; + } + } + + /* Pads: Recherche des coord min et max et mise a jour du cadre */ + for( Pad = m_Pads; Pad != NULL; Pad = (D_PAD*)Pad->Pnext ) + { + rayon = Pad->m_Rayon; + cx = Pad->m_Pos.x; cy = Pad->m_Pos.y; + m_RealBoundaryBox.m_Pos.x = min(m_RealBoundaryBox.m_Pos.x,cx - rayon); + m_RealBoundaryBox.m_Pos.y = min(m_RealBoundaryBox.m_Pos.y,cy - rayon); + xmax = max(xmax,cx + rayon); + ymax = max(ymax,cy + rayon); + } + m_RealBoundaryBox.SetWidth(xmax - m_RealBoundaryBox.m_Pos.x); + m_RealBoundaryBox.SetHeight(ymax - m_RealBoundaryBox.m_Pos.y); + m_Surface = ABS((float) m_RealBoundaryBox.GetWidth() * m_RealBoundaryBox.GetHeight()); +} + + +/*******************************************************/ +void MODULE::Display_Infos(WinEDA_BasePcbFrame * frame) +/*******************************************************/ +{ +int nbpad; +char bufcar[512], Line[512]; +int pos; +bool flag = FALSE; +wxString msg; + + frame->MsgPanel->EraseMsgBox() ; /* Effacement de la zone message */ + if ( frame->m_Ident != PCB_FRAME ) flag = TRUE; + pos = 1; + Affiche_1_Parametre(frame, pos, m_Reference->m_Text, m_Value->m_Text, DARKCYAN); + + /* Affiche signature temporelle ou date de modif (en edition de modules) */ + pos += 14; + if ( flag ) // Affichage date de modification (utile en Module Editor) + { + strcpy(Line, ctime(&m_LastEdit_Time)); + strtok(Line," \n\r"); + strcpy( bufcar, strtok(NULL," \n\r") ); strcat(bufcar," "); + strcat( bufcar, strtok(NULL," \n\r") ); strcat(bufcar,", "); + strtok(NULL," \n\r"); + strcat( bufcar, strtok(NULL," \n\r") ); + msg = CONV_FROM_UTF8(bufcar); + Affiche_1_Parametre(frame, pos, _("Last Change"), msg, BROWN); + pos += 4; + } + else + { + msg.Printf( wxT("%8.8lX"), m_TimeStamp); + Affiche_1_Parametre(frame, pos, _("TimeStamp"), msg,BROWN); + } + + pos += 6; + Affiche_1_Parametre(frame, pos,_("Layer"),ReturnPcbLayerName(m_Layer),RED) ; + + pos += 6; + EDA_BaseStruct * PtStruct = m_Pads; + nbpad = 0; + while( PtStruct ) { nbpad ++; PtStruct = PtStruct->Pnext; } + msg.Printf( wxT("%d"),nbpad); + Affiche_1_Parametre(frame, pos,_("Pads"), msg,BLUE); + + pos += 4; + msg = wxT(".."); + if( m_ModuleStatus & MODULE_is_LOCKED ) msg[0] = 'F'; + if( m_ModuleStatus & MODULE_is_PLACED ) msg[1] = 'P'; + Affiche_1_Parametre(frame, pos,_("Stat"), msg, MAGENTA); + + pos += 4; + msg.Printf( wxT("%.1f"),(float)m_Orient / 10 ); + Affiche_1_Parametre(frame, pos,_("Orient"), msg, BROWN); + + pos += 5; + Affiche_1_Parametre(frame, pos,_("Module"), m_LibRef, BLUE); + + pos += 9; + Affiche_1_Parametre(frame, pos, _("3D-Shape"), + m_3D_Drawings->m_Shape3DName, RED); + + pos += 14; + wxString doc = _("Doc: ") + m_Doc; + wxString keyword = _("KeyW: ") + m_KeyWord; + Affiche_1_Parametre(frame, pos, doc, keyword, BLACK); + +} + diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h new file mode 100644 index 0000000000..86803b4c8b --- /dev/null +++ b/pcbnew/class_module.h @@ -0,0 +1,108 @@ + /*******************************************************/ + /* class_module.h : module description (excepted pads) */ + /*******************************************************/ + + +class Pcb3D_GLCanvas; +class Struct3D_Master; + + /************************************/ + /* Modules (footprints) description */ + /* pad are in class_pad.xx */ + /************************************/ + +/* Format des modules: + Description generale + Description segments contour + Description textes + Description pastilles +*/ + +/* Flags :*/ + +enum Mod_Attribut /* Attributs d'un module */ + { + MOD_DEFAULT = 0, /* Type default */ + MOD_CMS = 1, /* Pour module apparaissant dans les + fichiers de placement automatique (principalement modules CMS */ + MOD_VIRTUAL = 2 /* Module virtuel constitue par un dessin sur circuit + (connecteur, trou de percage..) */ + }; + +/* flags for autoplace and autoroute (.m_ModuleStatus member) */ +#define MODULE_is_LOCKED 0x01 /* module LOCKED: no autoplace allowed */ +#define MODULE_is_PLACED 0x02 /* In autoplace: module automatically placed */ +#define MODULE_to_PLACE 0x04 /* In autoplace: module waiting fot autoplace */ + +class MODULE: public EDA_BaseStruct +{ +public: + int m_Layer; // layer number + wxPoint m_Pos; // Real coord on board + D_PAD * m_Pads; /* Pad list (linked list) */ + EDA_BaseStruct * m_Drawings; /* Graphic items list (linked list) */ + Struct3D_Master * m_3D_Drawings; /* Pointeur sur la liste des elements de trace 3D*/ + TEXTE_MODULE * m_Reference; // texte reference du composant (U34, R18..) + TEXTE_MODULE * m_Value; // texte valeur du composant (74LS00, 22K..) + wxString m_LibRef; /* nom du module en librairie */ + + int m_Attributs; /* Flags bits a bit ( voir enum Mod_Attribut ) */ + int m_Orient ; /* orientation en 1/10 degres */ + int flag ; /* flag utilise en trace rastnest et routage auto */ + int m_ModuleStatus; /* For autoplace: flags (LOCKED, AUTOPLACED) */ + EDA_Rect m_BoundaryBox ; /* position/taille du cadre de reperage (coord locales)*/ + EDA_Rect m_RealBoundaryBox ; /* position/taille du module (coord relles) */ + int m_PadNum; // Nombre total de pads + int m_AltPadNum; // en placement auto Nombre de pads actifs pour + // les calculs + int m_CntRot90; // Placement auto: cout ( 0..10 ) de la rotation 90 degre + int m_CntRot180; // Placement auto: cout ( 0..10 ) de la rotation 180 degre + wxSize m_Ext; // marges de "garde": utilise en placement auto. + float m_Surface; // surface du rectangle d'encadrement + + long m_Link; // variable temporaire ( pour editions, ...) + long m_LastEdit_Time; // Date de la derniere modification du module (gestion de librairies) + + wxString m_Doc; // Texte de description du module + wxString m_KeyWord; // Liste des mots cles relatifs au module + +public: + MODULE(BOARD * parent); + MODULE(MODULE * module); + ~MODULE(void); + + void Copy(MODULE * Module); // Copy structure + MODULE * Next(void) { return (MODULE *) Pnext; } + + void Set_Rectangle_Encadrement(void); /* mise a jour du rect d'encadrement + en coord locales (orient 0 et origine = pos module) */ + void SetRectangleExinscrit(void); /* mise a jour du rect d'encadrement + et de la surface en coord reelles */ + + + // deplacements + void SetPosition(const wxPoint & newpos); + void SetOrientation(int newangle); + + /* supprime du chainage la structure Struct */ + void UnLink( void ); + + /* Readind and writing data on files */ + int WriteDescr( FILE * File ); + int Write_3D_Descr( FILE * File ); + int ReadDescr( FILE * File, int * LineNum = NULL); + int Read_3D_Descr( FILE * File, int * LineNum = NULL); + + /* drawing functions */ + void Draw(WinEDA_DrawPanel * panel, wxDC * DC, + const wxPoint & offset, int draw_mode); + void Draw3D(Pcb3D_GLCanvas * glcanvas); + void DrawEdgesOnly(WinEDA_DrawPanel * panel, wxDC * DC, + const wxPoint & offset,int draw_mode); + void DrawAncre(WinEDA_DrawPanel * panel, wxDC * DC, + const wxPoint & offset, int dim_ancre, int draw_mode); + + /* miscellaneous */ + void Display_Infos(WinEDA_BasePcbFrame * frame); +}; + diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp new file mode 100644 index 0000000000..1f704222e7 --- /dev/null +++ b/pcbnew/class_pad.cpp @@ -0,0 +1,819 @@ + /************************************************/ + /* class_pad.cpp : fonctions de la classe D_PAD */ + /************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "wxstruct.h" +#include "common.h" +#include "pcbnew.h" +#include "trigo.h" + +#ifdef PCBNEW +#include "drag.h" +#endif + +#ifdef CVPCB +#include "cvpcb.h" + +#endif + +#include "protos.h" + + /*******************************/ + /* classe D_PAD : constructeur */ + /*******************************/ + +D_PAD::D_PAD(MODULE * parent): EDA_BaseStruct( parent, TYPEPAD) +{ + m_NumPadName = 0; + m_Masque_Layer = CUIVRE_LAYER; + m_NetCode = 0; /* Numero de net pour comparaisons rapides */ + m_DrillShape = CIRCLE; // Drill shape = circle + m_Size.x = m_Size.y = 500; + if (m_Parent && (m_Parent->m_StructType == TYPEMODULE) ) + { + m_Pos = ((MODULE*)m_Parent)->m_Pos; + } + + m_PadShape = CIRCLE; // forme CERCLE, RECT OVALE TRAPEZE ou libre + m_Attribut = STANDARD; // NORMAL, SMD, CONN, Bit 7 = STACK + m_Orient = 0; // en 1/10 degres + + m_logical_connexion = 0; + m_physical_connexion = 0; // variables utilisee lors du calcul du chevelu + ComputeRayon(); +} + + +D_PAD::~D_PAD(void) +{ +} + +/****************************/ +void D_PAD::ComputeRayon(void) +/****************************/ +/* met a jour m_Rayon, rayon du cercle exinscrit +*/ +{ + switch (m_PadShape & 0x7F) + { + case CIRCLE : + m_Rayon = m_Size.x/2; + break; + + case OVALE : + m_Rayon = MAX(m_Size.x, m_Size.y) / 2; + break; + + case RECT : + case SPECIAL_PAD: + case TRAPEZE: + m_Rayon = (int)(sqrt((float)m_Size.y * m_Size.y + + (float)m_Size.x * m_Size.x) / 2); + break; + } + +} + +/*********************************************/ +const wxPoint D_PAD::ReturnShapePos(void) const +/*********************************************/ +// retourne la position de la forme (pastilles excentrees) +{ + if ( (m_Offset.x == 0) && (m_Offset.y == 0) ) return m_Pos; +wxPoint shape_pos; +int dX, dY; + dX = m_Offset.x; dY = m_Offset.y; + RotatePoint(&dX, &dY, m_Orient ); + shape_pos.x = m_Pos.x + dX; shape_pos.y = m_Pos.y + dY; + + return shape_pos; +} + + +/****************************************/ +wxString D_PAD::ReturnStringPadName(void) +/****************************************/ +/* Return pad name as string in a wxString +*/ +{ +wxString name; + + ReturnStringPadName(name); + return name; +} + +/********************************************/ +void D_PAD::ReturnStringPadName(wxString & text) +/********************************************/ +/* Return pad name as string in a buffer +*/ +{ +int ii; + + text.Empty(); + for ( ii = 0; ii < 4; ii++ ) + { + if ( m_Padname[ii] == 0 ) break; + text.Append(m_Padname[ii]); + } +} + + +/********************************************/ +void D_PAD::SetPadName(const wxString & name) +/********************************************/ +// Change pad name +{ +int ii, len; + len = name.Length(); + if ( len > 4 ) len = 4; + for (ii = 0; ii < len; ii ++ ) m_Padname[ii] = name.GetChar(ii); + for (ii = len; ii < 4; ii ++ ) m_Padname[ii] = 0; +} + + +/********************************/ +void D_PAD::Copy(D_PAD * source) +/********************************/ +{ + if (source == NULL) return; + + m_Pos = source->m_Pos; + m_Masque_Layer = source->m_Masque_Layer; + + memcpy(m_Padname,source->m_Padname, sizeof(m_Padname));/* nom de la pastille */ + m_NetCode = source->m_NetCode; /* Numero de net pour comparaisons rapides */ + m_Drill = source->m_Drill; // Diametre de percage + m_DrillShape = source->m_DrillShape; + m_Offset = source->m_Offset; // Offset de la forme + m_Size = source->m_Size; // Dimension ( pour orient 0 ) + m_DeltaSize = source->m_DeltaSize; // delta sur formes rectangle -> trapezes + m_Pos0 = source->m_Pos0; // Coord relatives a l'ancre du pad en + // orientation 0 + m_Rayon = source->m_Rayon; // rayon du cercle exinscrit du pad + m_PadShape = source->m_PadShape; // forme CERCLE, RECT OVALE TRAPEZE ou libre + m_Attribut = source->m_Attribut; // NORMAL, SMD, CONN, Bit 7 = STACK + m_Orient = source->m_Orient; // en 1/10 degres + + m_logical_connexion = 0; // variable utilisee lors du calcul du chevelu + m_physical_connexion = 0; // variable utilisee lors du calcul de la connexité + + m_Netname = source->m_Netname; +} + +/**************************/ +void D_PAD::UnLink( void ) +/**************************/ +/* supprime du chainage la structure Struct + les structures arrieres et avant sont chainees directement + */ +{ + /* Modification du chainage arriere */ + if( Pback ) + { + if( Pback->m_StructType != TYPEMODULE) + { + Pback->Pnext = Pnext; + } + + else /* Le chainage arriere pointe sur la structure "Pere" */ + { + ((MODULE*)Pback)->m_Pads = (D_PAD *) Pnext; + } + } + + /* Modification du chainage avant */ + if( Pnext) Pnext->Pback = Pback; + + Pnext = Pback = NULL; +} + + +/*******************************************************************************************/ +void D_PAD::Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode) +/*******************************************************************************************/ +/* Tracé a l'écran d'un pad: + Entree : + ptr_pad = pointeur sur le pad du module + offset = offset de trace + draw_mode = mode de trace ( GR_OR, GR_XOR, GR_AND) +*/ +{ +int ii; +int color = 0; +int ux0,uy0, + dx,dx0,dy,dy0, + rotdx, + delta_cx, delta_cy, + xc, yc; +int angle; +wxPoint coord[4]; +int zoom; +int fillpad = 0; +PCB_SCREEN * screen; +WinEDA_BasePcbFrame * frame; +wxPoint shape_pos; + + screen = panel ? (PCB_SCREEN *) panel->m_Parent->m_CurrentScreen : (PCB_SCREEN *) ActiveScreen; + frame = ( WinEDA_BasePcbFrame * ) panel->m_Parent; + + /* Calcul de l'aspect du pad */ + if( frame->m_DisplayPadFill == FILLED) fillpad = 1; + + zoom = screen->GetZoom(); + +#ifdef PCBNEW + if( m_Flags & IS_MOVED) fillpad = 0; +#endif + if ( m_Masque_Layer & CMP_LAYER ) color = g_PadCMPColor ; + if ( m_Masque_Layer & CUIVRE_LAYER ) color |= g_PadCUColor ; + + if( color == 0) /* Not on copper layer */ + { + switch ( m_Masque_Layer & ~ALL_CU_LAYERS ) + { + case ADHESIVE_LAYER_CU: + color = g_DesignSettings.m_LayerColor[ADHESIVE_N_CU]; + break; + case ADHESIVE_LAYER_CMP: + color = g_DesignSettings.m_LayerColor[ADHESIVE_N_CMP]; + break; + case SOLDERPASTE_LAYER_CU: + color = g_DesignSettings.m_LayerColor[SOLDERPASTE_N_CU]; + break; + case SOLDERPASTE_LAYER_CMP: + color = g_DesignSettings.m_LayerColor[SOLDERPASTE_N_CMP]; + break; + case SILKSCREEN_LAYER_CU: + color = g_DesignSettings.m_LayerColor[SILKSCREEN_N_CU]; + break; + case SILKSCREEN_LAYER_CMP: + color = g_DesignSettings.m_LayerColor[SILKSCREEN_N_CMP]; + break; + case SOLDERMASK_LAYER_CU: + color = g_DesignSettings.m_LayerColor[SOLDERMASK_N_CU]; + break; + case SOLDERMASK_LAYER_CMP: + color = g_DesignSettings.m_LayerColor[SOLDERMASK_N_CMP]; + break; + case DRAW_LAYER : + color = g_DesignSettings.m_LayerColor[DRAW_N]; + break; + case COMMENT_LAYER: + color = g_DesignSettings.m_LayerColor[COMMENT_N]; + break; + case ECO1_LAYER: + color = g_DesignSettings.m_LayerColor[ECO1_N]; + break; + case ECO2_LAYER : + color = g_DesignSettings.m_LayerColor[ECO2_N]; + break; + case EDGE_LAYER: + color = g_DesignSettings.m_LayerColor[EDGE_N]; + break; + + default: + color = DARKGRAY; + break; + } + } + + if ( draw_mode & GR_SURBRILL ) + { + if(draw_mode & GR_AND) color &= ~HIGHT_LIGHT_FLAG; + else color |= HIGHT_LIGHT_FLAG; + } + if ( color & HIGHT_LIGHT_FLAG) + color = ColorRefs[color & MASKCOLOR].m_LightColor; + + GRSetDrawMode(DC, draw_mode); /* mode de trace */ + + /* calcul du centre des pads en coordonnees Ecran : */ + shape_pos = ReturnShapePos(); + ux0 = shape_pos.x - offset.x; + uy0 = shape_pos.y - offset.y; + xc = ux0; + yc = uy0; + + /* le trace depend de la rotation de l'empreinte */ + + dx = dx0 = m_Size.x >> 1 ; + dy = dy0 = m_Size.y >> 1 ; /* demi dim dx et dy */ + + angle = m_Orient; + bool DisplayIsol = DisplayOpt.DisplayPadIsol; + if ( ( m_Masque_Layer & ALL_CU_LAYERS ) == 0 ) DisplayIsol = FALSE; + + switch (m_PadShape & 0x7F) + { + case CIRCLE : + if ( fillpad) + GRFilledCircle(&panel->m_ClipBox, DC, xc, yc, dx, color, color); + else GRCircle(&panel->m_ClipBox, DC, xc, yc, dx, color); + + if(DisplayIsol) + { + GRCircle(&panel->m_ClipBox, DC, xc, yc, dx + g_DesignSettings.m_TrackClearence, color ); + } + break; + + case OVALE : + /* calcul de l'entraxe de l'ellipse */ + if( dx > dy ) /* ellipse horizontale */ + { + delta_cx = dx - dy; delta_cy = 0; + rotdx = m_Size.y; + } + else /* ellipse verticale */ + { + delta_cx = 0; delta_cy = dy - dx; + rotdx = m_Size.x; + } + RotatePoint(&delta_cx, &delta_cy, angle); + + if (fillpad) + { + GRFillCSegm(&panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, + ux0 - delta_cx, uy0 - delta_cy, + rotdx, color); + } + + else + { + GRCSegm(&panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, + ux0 - delta_cx, uy0 - delta_cy, + rotdx, color); + } + + /* Trace de la marge d'isolement */ + if(DisplayIsol) + { + rotdx = rotdx + g_DesignSettings.m_TrackClearence + g_DesignSettings.m_TrackClearence; + GRCSegm(&panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, + ux0 - delta_cx, uy0 - delta_cy, + rotdx, color); + } + break; + + case RECT : + case SPECIAL_PAD: + case TRAPEZE: + { + int ddx, ddy ; + ddx = m_DeltaSize.x >> 1 ; + ddy = m_DeltaSize.y >> 1 ; /* demi dim dx et dy */ + + coord[0].x = - dx - ddy; + coord[0].y = + dy + ddx; + + coord[1].x = - dx + ddy; + coord[1].y = - dy - ddx; + + coord[2].x = + dx - ddy; + coord[2].y = - dy + ddx; + + coord[3].x = + dx + ddy; + coord[3].y = + dy - ddx; + + for (ii = 0; ii < 4; ii++) + { + RotatePoint(&coord[ii].x,&coord[ii].y, angle); + coord[ii].x = coord[ii].x + ux0; + coord[ii].y = coord[ii].y + uy0; + } + + GRClosedPoly(&panel->m_ClipBox, DC, 4, (int*) coord, fillpad, color, color); + + if(DisplayIsol) + { + dx += g_DesignSettings.m_TrackClearence; dy += g_DesignSettings.m_TrackClearence; + coord[0].x = -dx - ddy; + coord[0].y = dy + ddx; + + coord[1].x = -dx + ddy; + coord[1].y = -dy - ddx; + + coord[2].x = dx - ddy; + coord[2].y = -dy + ddx; + + coord[3].x = dx + ddy; + coord[3].y = dy - ddx; + + for (ii = 0; ii < 4; ii++) + { + RotatePoint(&coord[ii].x,&coord[ii].y, angle); + coord[ii].x = coord[ii].x + ux0; + coord[ii].y = coord[ii].y + uy0; + } + + GRClosedPoly(&panel->m_ClipBox, DC, 4, (int*)coord, 0, color, color); + } + break; + + default: + break; + } + } + + /* Draw the pad hole */ + int cx0 = m_Pos.x - offset.x; + int cy0 = m_Pos.y - offset.y; + int hole = m_Drill.x >> 1 ; + + if( fillpad && hole ) + { + color = g_IsPrinting ? WHITE : BLACK; // ou DARKGRAY; + if(draw_mode != GR_XOR) GRSetDrawMode(DC, GR_COPY); + else GRSetDrawMode(DC, GR_XOR); + switch ( m_DrillShape ) + { + case CIRCLE: + if( (hole/zoom) > 1 ) /* C.a.d si le diametre est suffisant */ + GRFilledCircle(&panel->m_ClipBox, DC, cx0, cy0, hole, color, color); + break; + + case OVALE: + dx = m_Drill.x >> 1 ; + dy = m_Drill.y >> 1 ; /* demi dim dx et dy */ + /* calcul de l'entraxe de l'ellipse */ + if( m_Drill.x > m_Drill.y ) /* ellipse horizontale */ + { + delta_cx = dx - dy; delta_cy = 0; + rotdx = m_Drill.y; + } + else /* ellipse verticale */ + { + delta_cx = 0; delta_cy = dy - dx; + rotdx = m_Drill.x; + } + RotatePoint(&delta_cx, &delta_cy, angle); + + GRFillCSegm(&panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, + ux0 - delta_cx, uy0 - delta_cy, + rotdx, color); + break; + + default: + break; + } + } + + GRSetDrawMode(DC, draw_mode); + /* Trace du symbole "No connect" ( / ou \ ou croix en X) si necessaire : */ + if( m_Netname.IsEmpty() && DisplayOpt.DisplayPadNoConn ) + { + dx0 = min(dx0,dy0); + int nc_color = BLUE; + if(m_Masque_Layer & CMP_LAYER) /* Trace forme \ */ + GRLine(&panel->m_ClipBox, DC, cx0 - dx0, cy0 - dx0, + cx0 + dx0, cy0 + dx0, nc_color ); + + if(m_Masque_Layer & CUIVRE_LAYER) /* Trace forme / */ + GRLine(&panel->m_ClipBox, DC, cx0 + dx0, cy0 - dx0, + cx0 - dx0, cy0 + dx0, nc_color ); + } + /* Trace de la reference */ + if( ! frame->m_DisplayPadNum) return; + dx = min(m_Size.x, m_Size.y); /* dx = taille du texte */ + if( (dx / zoom) > 12 ) /* Si taille suffisante pour 2 lettres */ + { + wxString buffer; + ReturnStringPadName(buffer); + dy = buffer.Len(); + if ( dy < 2 ) dy = 2; /* alignement sur textes a 2 lettres */ + dx = (dx * 9 ) / (dy * 13 ); /* le texte est ajuste pour + tenir entierement dans la pastille */ + DrawGraphicText(panel, DC, wxPoint(ux0, uy0), + WHITE, buffer, angle, wxSize(dx, dx), + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + } +} + +/*************************************************/ +int D_PAD::ReadDescr( FILE * File, int * LineNum) +/*************************************************/ +/* Routine de lecture de descr de pads + la 1ere ligne de descr ($PAD) est supposee etre deja lue +syntaxe: +$PAD +Sh "N1" C 550 550 0 0 1800 +Dr 310 0 0 +At STD N 00C0FFFF +Ne 3 "netname" +Po 6000 -6000 +$EndPAD +*/ +{ +char Line[1024], BufLine[1024], BufCar[256]; +char * PtLine; +int nn, ll, dx, dy, drill_shape; + + while( GetLine(File, Line, LineNum ) != NULL ) + { + if( Line[0] == '$' ) return( 0 ); + + PtLine = Line + 3; /* Pointe 1er code utile de la ligne */ + switch( Line[0] ) + { + case 'S': /* Ligne de description de forme et dims*/ + /* Lecture du nom pad */ + nn = 0; + while( (*PtLine != '"') && *PtLine ) PtLine++; + if ( *PtLine ) PtLine++; + memset(m_Padname,0 ,sizeof(m_Padname) ); + while( (*PtLine != '"') && *PtLine ) + { + if(nn < (int) sizeof(m_Padname)) + { + if( * PtLine > ' ' ) + { + m_Padname[nn] = *PtLine; nn++; + } + } + PtLine++; + } + + if ( *PtLine == '"' ) PtLine++; + + nn = sscanf(PtLine," %s %d %d %d %d %d", + BufCar, &m_Size.x, &m_Size.y, + &m_DeltaSize.x, &m_DeltaSize.y, + &m_Orient); + + ll = 0xFF & BufCar[0]; + + /* Mise a jour de la forme */ + m_PadShape = CIRCLE; + switch(ll) + { + case 'C': m_PadShape = CIRCLE; break; + case 'R': m_PadShape = RECT; break; + case 'O': m_PadShape = OVALE; break; + case 'T': m_PadShape = TRAPEZE; break; + } + ComputeRayon(); + break; + + case 'D': + drill_shape = 0; + nn = sscanf(PtLine,"%d %d %d %c %d %d", &m_Drill.x, + &m_Offset.x, &m_Offset.y, &drill_shape, &dx, &dy ); + m_Drill.y = m_Drill.x; + m_DrillShape = CIRCLE; + if (nn >= 6 ) // Drill shape = OVAL ? + { + if (drill_shape == 'O' ) + { + m_Drill.x = dx; m_Drill.y = dy; + m_DrillShape = OVALE; + } + } + break; + + case 'A': + nn = sscanf(PtLine,"%s %s %X", BufLine, BufCar, + &m_Masque_Layer); + /* Contenu de BufCar non encore utilise ( reserve pour evolutions + ulterieures */ + /* Mise a jour de l'attribut */ + m_Attribut = STANDARD; + if( strncmp(BufLine,"SMD",3) == 0 ) m_Attribut = SMD; + if( strncmp(BufLine,"CONN",4) == 0 ) m_Attribut = CONN; + if( strncmp(BufLine,"HOLE",4) == 0 ) m_Attribut = P_HOLE; + if( strncmp(BufLine,"MECA",4) == 0 ) m_Attribut = MECA; + break; + + case 'N': /* Lecture du netname */ + nn = sscanf(PtLine,"%d", &m_NetCode); + /* Lecture du netname */ + ReadDelimitedText(BufLine, PtLine, sizeof(BufLine)); + m_Netname = CONV_FROM_UTF8(StrPurge(BufLine)); + break; + + case 'P': + nn = sscanf(PtLine,"%d %d", &m_Pos0.x, &m_Pos0.y ); + m_Pos = m_Pos0; + break; + + default: + DisplayError(NULL, wxT("Err Pad: Id inconnu")); + return(1); + } + } + return(2); /* error : EOF */ +} + +/***********************************/ +int D_PAD::WriteDescr( FILE * File ) +/***********************************/ +/* Sauvegarde de la description d'un PAD +*/ +{ +int cshape, NbLigne = 0;; +char * texttype; + + if( GetState(DELETED) ) return(NbLigne); + + /* Generation du fichier pad: */ + fprintf( File,"$PAD\n"); NbLigne++; + switch(m_PadShape) + { + case CIRCLE: cshape = 'C'; break; + case RECT: cshape = 'R'; break; + case OVALE: cshape = 'O'; break; + case TRAPEZE: cshape = 'T'; break; + default: cshape = 'C'; + DisplayError(NULL, _("Unknown Pad shape")); + break; + } + fprintf(File,"Sh \"%.4s\" %c %d %d %d %d %d\n", + m_Padname, cshape, m_Size.x, m_Size.y, + m_DeltaSize.x, m_DeltaSize.y,m_Orient); + NbLigne++; + fprintf(File,"Dr %d %d %d", m_Drill.x, m_Offset.x, m_Offset.y ); + if ( m_DrillShape == OVALE ) + { + fprintf(File," %c %d %d", 'O', m_Drill.x, m_Drill.y ); + } + fprintf(File,"\n"); + + NbLigne++; + switch(m_Attribut) + { + case STANDARD: texttype = "STD"; break; + case SMD: texttype = "SMD"; break; + case CONN: texttype = "CONN"; break; + case P_HOLE: texttype = "HOLE"; break; + case MECA: texttype = "MECA"; break; + default: + texttype = "STD"; + DisplayError(NULL, wxT("attribut Pad inconnu")); + break; + } + fprintf(File,"At %s N %8.8X\n", texttype, m_Masque_Layer); + NbLigne++; + + fprintf(File,"Ne %d \"%s\"\n", m_NetCode,CONV_TO_UTF8(m_Netname)); + NbLigne++; + + fprintf(File,"Po %d %d\n", m_Pos0.x, m_Pos0.y ); + NbLigne++; + + fprintf( File,"$EndPAD\n"); + NbLigne++; + return(NbLigne); +} + +/******************************************************/ +void D_PAD::Display_Infos(WinEDA_BasePcbFrame * frame) +/******************************************************/ +/* Affiche en bas d'ecran les caract de la pastille demandee */ +{ +int ii; +MODULE* Module; +wxString Line; +int pos = 1; +/* Pad messages */ +wxString Msg_Pad_Shape[6] = + { wxT("??? "), wxT("Circ"), wxT("Rect"), wxT("Oval"), wxT("trap"), wxT("spec") } ; + +wxString Msg_Pad_Layer[9] = + { wxT("??? "), wxT("cmp "), wxT("cu "), wxT("cmp+cu "), wxT("int "), + wxT("cmp+int "), wxT("cu+int "), wxT("all "), wxT("No copp") } ; +wxString Msg_Pad_Attribut[5] = + { wxT("norm"), wxT("smd "), wxT("conn"), wxT("hole"), wxT("????")} ; + + + frame->MsgPanel->EraseMsgBox(); + + /* Recherche du module correspondant */ + Module = (MODULE *) m_Parent; + if(Module) + { + wxString msg = Module->m_Reference->m_Text; + Affiche_1_Parametre(frame, pos,_("Module"), msg, DARKCYAN) ; + ReturnStringPadName(Line); + pos += 8; + Affiche_1_Parametre(frame, pos,_("RefP"),Line,BROWN) ; + } + pos += 4; + Affiche_1_Parametre(frame, pos,_("Net"),m_Netname, DARKCYAN); + + /* pour mise au point (peut etre supprimé) : Affichage du numero de Net et sous net */ + pos += 10; +#if 0 + Line.Printf( wxT("%d.%d "),m_logical_connexion, m_physical_connexion); + Affiche_1_Parametre(frame, pos,"L.P",Line,WHITE); +#endif + + wxString LayerInfo; + ii = 0; + if(m_Masque_Layer & CUIVRE_LAYER) ii = 2; + if(m_Masque_Layer & CMP_LAYER) ii += 1; + if((m_Masque_Layer & ALL_CU_LAYERS) == ALL_CU_LAYERS) ii = 7; + + LayerInfo = Msg_Pad_Layer[ii]; + if((m_Masque_Layer & ALL_CU_LAYERS) == 0) + { + if(m_Masque_Layer) LayerInfo = Msg_Pad_Layer[8]; + switch ( m_Masque_Layer & ~ALL_CU_LAYERS ) + { + case ADHESIVE_LAYER_CU: + LayerInfo = ReturnPcbLayerName(ADHESIVE_N_CU); + break; + case ADHESIVE_LAYER_CMP: + LayerInfo = ReturnPcbLayerName(ADHESIVE_N_CMP); + break; + case SOLDERPASTE_LAYER_CU: + LayerInfo = ReturnPcbLayerName(SOLDERPASTE_N_CU); + break; + case SOLDERPASTE_LAYER_CMP: + LayerInfo = ReturnPcbLayerName(SOLDERPASTE_N_CMP); + break; + case SILKSCREEN_LAYER_CU: + LayerInfo = ReturnPcbLayerName(SILKSCREEN_N_CU); + break; + case SILKSCREEN_LAYER_CMP: + LayerInfo = ReturnPcbLayerName(SILKSCREEN_N_CMP); + break; + case SOLDERMASK_LAYER_CU: + LayerInfo = ReturnPcbLayerName(SOLDERMASK_N_CU); + break; + case SOLDERMASK_LAYER_CMP: + LayerInfo = ReturnPcbLayerName(SOLDERMASK_N_CMP); + break; + case DRAW_LAYER : + LayerInfo = ReturnPcbLayerName(DRAW_N); + break; + case COMMENT_LAYER: + LayerInfo = ReturnPcbLayerName(COMMENT_N); + break; + case ECO1_LAYER: + LayerInfo = ReturnPcbLayerName(ECO1_N); + break; + case ECO2_LAYER : + LayerInfo = ReturnPcbLayerName(ECO2_N); + break; + case EDGE_LAYER: + LayerInfo = ReturnPcbLayerName(EDGE_N); + break; + + default: + break; + } + } + pos += 3; + Affiche_1_Parametre(frame, pos,_("Layer"),LayerInfo, DARKGREEN) ; + + pos += 6; + Affiche_1_Parametre(frame, pos,Msg_Pad_Shape[m_PadShape],wxEmptyString, DARKGREEN); + /* Affichage en couleur diff si pad stack ou non */ + + if (m_Attribut & PAD_STACK) + Affiche_1_Parametre(frame, -1,wxEmptyString,Msg_Pad_Attribut[m_Attribut&15],RED); + else Affiche_1_Parametre(frame, -1,wxEmptyString,Msg_Pad_Attribut[m_Attribut&15], DARKGREEN); + + valeur_param(m_Size.x,Line) ; + pos += 6; + Affiche_1_Parametre(frame, pos,_("H Size"),Line,RED) ; + + valeur_param(m_Size.y,Line) ; + pos += 7; + Affiche_1_Parametre(frame, pos,_("V Size"),Line,RED) ; + + pos += 7; + valeur_param((unsigned)m_Drill.x,Line) ; + if ( m_DrillShape == CIRCLE ) + { + Affiche_1_Parametre(frame, pos,_("Drill"),Line,RED); + } + else + { + valeur_param((unsigned)m_Drill.x,Line); + wxString msg; + valeur_param((unsigned)m_Drill.x,msg); + Line += wxT(" ") + msg; + Affiche_1_Parametre(frame, pos,_("Drill X / Y"),Line,RED); + } + + + int module_orient = Module ? Module->m_Orient : 0; + if( module_orient ) + Line.Printf( wxT("%3.1f(+%3.1f)"), + (float)(m_Orient - module_orient) /10, (float)module_orient /10); + else + Line.Printf( wxT("%3.1f"), (float) m_Orient /10); + pos += 8; + Affiche_1_Parametre(frame, pos,_("Orient"),Line,BLUE); + + valeur_param(m_Pos.x,Line); + pos += 8; + Affiche_1_Parametre(frame, pos,_("X Pos"),Line,BLUE) ; + + valeur_param(m_Pos.y,Line); + pos += 6; + Affiche_1_Parametre(frame, pos,_("Y pos"),Line,BLUE) ; +} diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h new file mode 100644 index 0000000000..d5375bf977 --- /dev/null +++ b/pcbnew/class_pad.h @@ -0,0 +1,85 @@ + /**********************************/ + /* class_pad.h : Pads description */ + /**********************************/ + +class Pcb3D_GLCanvas; + +/* forme des pastilles : (parametre .forme) */ +#define CIRCLE 1 +#define RECT 2 +#define OVALE 3 +#define TRAPEZE 4 // trapeze: traversante ou surfacique +#define SPECIAL_PAD 5 // description libre + +/* Attributs des PADS */ +#define STANDARD 0 // pad classique +#define SMD 1 // surfacique, generation d'un masque d'empatement +#define CONN 2 // surfacique, peut etre dore +#define P_HOLE 3 // trou simple, utile sur pad stack +#define MECA 4 // PAD "mecanique" (fixation, zone cuivre...) +#define PAD_STACK 0x80 // bit 7 de .attrib (flag) + +/* Definition type Structure d'un pad */ +class D_PAD: public EDA_BaseStruct +{ +public: + union { + unsigned long m_NumPadName; + char m_Padname[4] ; /* nom (numero) de la pastille (assimilatble a un long)*/ + }; + wxString m_Netname; /* Net Name */ + int m_Masque_Layer; // (Bit a Bit :1= cuivre, 15= cmp, + // 2..14 = interne + // 16 .. 31 = couches non cuivre + int m_PadShape; // forme CERCLE, RECT, OVALE, TRAPEZE ou libre + int m_DrillShape; // forme CERCLE, OVAL + wxPoint m_Pos; // Position de reference du pad + wxSize m_Drill; // Drill diam (drill shape = CIRCLE) or drill size(shape = OVAL) + // for drill shape = CIRCLE, drill diam = m_Drill.x + wxSize m_Offset; // Offset de la forme (pastilles excentrees) + wxSize m_Size; // Dimensions X et Y ( si orient 0 x = axe X + // y = axe Y + wxSize m_DeltaSize; // delta sur formes rectangle -> trapezes + wxPoint m_Pos0; // Coord relatives a l'ancre du pad en orientation 0 + int m_Rayon; // rayon du cercle exinscrit du pad + int m_Attribut; // NORMAL, SMD, CONN, Bit 7 = STACK + int m_Orient ; // en 1/10 degres + + int m_NetCode; /* Numero de net pour comparaisons rapides */ + int m_logical_connexion; // variable utilisee lors du calcul du chevelu: + // contient de numero de block pour une connexion type ratsnet + int m_physical_connexion; // variable utilisee lors du calcul de la connexité: + // contient de numero de block pour une connexion type piste + +public: + D_PAD(MODULE * parent); + D_PAD(D_PAD * pad); + ~D_PAD(void); + + void Copy(D_PAD * source); + D_PAD * Next(void) + { return (D_PAD *) Pnext; } + + /* supprime du chainage la structure Struct */ + void UnLink( void ); + + /* Readind and writing data on files */ + int ReadDescr( FILE * File, int * LineNum = NULL); + int WriteDescr( FILE * File ); + + /* drawing functions */ + void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode); + void Draw3D(Pcb3D_GLCanvas * glcanvas); + + // autres + void SetPadName(const wxString & name); // Change pade name + wxString ReturnStringPadName(void); // Return pad name as string in a wxString + void ReturnStringPadName(wxString & text); // Return pad name as string in a buffer + void ComputeRayon(void); // met a jour m_Rayon, rayon du cercle exinscrit + const wxPoint ReturnShapePos(void) const; // retourne la position + // de la forme (pastilles excentrees) + void Display_Infos(WinEDA_BasePcbFrame * frame); +}; + +typedef class D_PAD * LISTE_PAD; + diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp new file mode 100644 index 0000000000..b0599ac0b9 --- /dev/null +++ b/pcbnew/class_pcb_text.cpp @@ -0,0 +1,140 @@ +/************************************/ +/* fonctions de la classe TEXTE_PCB */ +/************************************/ + +#include "fctsys.h" +#include "wxstruct.h" + +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + + + /*******************/ + /* class TEXTE_PCB */ + /*******************/ + +TEXTE_PCB::TEXTE_PCB(EDA_BaseStruct * parent): + EDA_BaseStruct(parent, TYPETEXTE), EDA_TextStruct() +{ +} + +/* Destructeur */ +TEXTE_PCB:: ~TEXTE_PCB(void) +{ +} + +/* copie de stucture */ +void TEXTE_PCB::Copy(TEXTE_PCB * source) +{ + m_Parent = source->m_Parent; + Pback = Pnext = NULL; + m_Miroir = source->m_Miroir; + m_Size = source->m_Size; + m_Orient = source->m_Orient; + m_Pos = source->m_Pos; + m_Layer = source->m_Layer; + m_Width = source->m_Width; + m_Attributs = source->m_Attributs; + m_CharType = source->m_CharType; + m_HJustify = source->m_HJustify; + m_VJustify = source->m_VJustify; + + m_Text = source->m_Text; +} + +void TEXTE_PCB::UnLink( void ) +{ + /* Modification du chainage arriere */ + if( Pback ) + { + if( Pback->m_StructType != TYPEPCB) + { + Pback->Pnext = Pnext; + } + + else /* Le chainage arriere pointe sur la structure "Pere" */ + { + ((BOARD*)Pback)->m_Drawings = Pnext; + } + } + + /* Modification du chainage avant */ + if( Pnext) Pnext->Pback = Pback; + + Pnext = Pback = NULL; +} + +/****************************************************************/ +int TEXTE_PCB::ReadTextePcbDescr(FILE * File, int * LineNum) +/****************************************************************/ +{ +char text[1024], Line[1024]; +int dummy; + + while( GetLine(File, Line, LineNum ) != NULL ) + { + if(strnicmp(Line,"$EndTEXTPCB",11) == 0) return 0; + if( strncmp(Line,"Te", 2) == 0 ) /* Texte */ + { + ReadDelimitedText(text, Line+2, sizeof(text) ); + m_Text = CONV_FROM_UTF8(text); + continue; + } + if( strncmp(Line,"Po", 2) == 0 ) + { + sscanf( Line+2," %d %d %d %d %d %d", + &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Size.y, + &m_Width, &m_Orient); + continue; + } + if( strncmp(Line,"De", 2) == 0 ) + { + sscanf( Line+2," %d %d %lX %d\n",&m_Layer, &m_Miroir, + &m_TimeStamp, &dummy); + if ( m_Layer < LAYER_CUIVRE_N ) + m_Layer = LAYER_CUIVRE_N; + if ( m_Layer > LAST_NO_COPPER_LAYER ) + m_Layer = LAST_NO_COPPER_LAYER; + + continue; + } + } + return(1); +} + + +/**************************************************/ +int TEXTE_PCB::WriteTextePcbDescr(FILE * File) +/**************************************************/ +{ + if( GetState(DELETED) ) return(0); + + if(m_Text.IsEmpty() ) return(0); + fprintf( File,"$TEXTPCB\n"); + fprintf( File,"Te \"%s\"\n",CONV_TO_UTF8(m_Text)); + fprintf( File,"Po %d %d %d %d %d %d\n", + m_Pos.x, m_Pos.y, m_Size.x, m_Size.y, m_Width, m_Orient ); + fprintf( File,"De %d %d %lX %d\n", m_Layer, m_Miroir, m_TimeStamp, 0); + fprintf( File,"$EndTEXTPCB\n"); + return(1); +} + +/**********************************************************************/ +void TEXTE_PCB::Draw(WinEDA_DrawPanel * panel, wxDC * DC, + const wxPoint & offset, int DrawMode) +/**********************************************************************/ +/* + DrawMode = GR_OR, GR_XOR.., -1 si mode courant. +*/ +{ +int color = g_DesignSettings.m_LayerColor[m_Layer]; + if(color & ITEM_NOT_SHOW ) return ; + + EDA_TextStruct::Draw(panel, DC, offset, color, + DrawMode, DisplayOpt.DisplayDrawItems, + (g_AnchorColor & ITEM_NOT_SHOW) ? -1 : (g_AnchorColor & MASKCOLOR)); + +} + diff --git a/pcbnew/class_pcb_text.h b/pcbnew/class_pcb_text.h new file mode 100644 index 0000000000..e8d22c6d51 --- /dev/null +++ b/pcbnew/class_pcb_text.h @@ -0,0 +1,30 @@ +/************************************/ +/* fonctions de la classe TEXTE_PCB */ +/************************************/ +#ifndef CLASS_PCB_TEXT_H +#define CLASS_PCB_TEXT_H + +#include "base_struct.h" + +class TEXTE_PCB: public EDA_BaseStruct, public EDA_TextStruct +{ +public: + TEXTE_PCB(EDA_BaseStruct * parent); + TEXTE_PCB(TEXTE_PCB * textepcb); + ~TEXTE_PCB(void); + + /* supprime du chainage la structure Struct */ + void UnLink( void ); + + /* duplicate structure */ + void Copy(TEXTE_PCB * source); + + void Draw(WinEDA_DrawPanel * panel, wxDC * DC, + const wxPoint & offset, int DrawMode); + + // File Operations: + int ReadTextePcbDescr(FILE * File, int * LineNum); + int WriteTextePcbDescr(FILE * File); +}; + +#endif // #define CLASS_PCB_TEXT_H diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp new file mode 100644 index 0000000000..cdb5e1d41f --- /dev/null +++ b/pcbnew/class_text_mod.cpp @@ -0,0 +1,267 @@ + /****************************************************/ + /* class_module.cpp : fonctions de la classe MODULE */ + /****************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "wxstruct.h" +#include "common.h" +#include "pcbnew.h" +#include "trigo.h" + +#ifdef PCBNEW +#include "autorout.h" +#include "drag.h" +#endif + +#ifdef CVPCB +#include "cvpcb.h" + +#endif + +#include "protos.h" + + /************************************************************************/ + /* Class TEXTE_MODULE classe de base des elements type Texte sur module */ + /************************************************************************/ + +/* Constructeur de TEXTE_MODULE */ +TEXTE_MODULE::TEXTE_MODULE(MODULE * parent, int text_type ): + EDA_BaseStruct( parent, TYPETEXTEMODULE) +{ +MODULE * Module = (MODULE*) m_Parent; + + m_NoShow = 0; /* visible */ + m_Type = text_type; /* Reference */ + if( (m_Type != TEXT_is_REFERENCE) && (m_Type != TEXT_is_VALUE) ) + m_Type = TEXT_is_DIVERS; + + m_Size.x = m_Size.y = 400; m_Width = 120; /* dimensions raisonnables par defaut */ + m_Orient = 0; /* en 1/10 degre */ + m_Miroir = 1; // Mode normal (pas de miroir) + m_Unused = 0; + m_Layer = SILKSCREEN_N_CMP; + if( Module && (Module->m_StructType == TYPEMODULE) ) + { + m_Pos = Module->m_Pos; + m_Layer = Module->m_Layer; + if( Module->m_Layer == CUIVRE_N) m_Layer = SILKSCREEN_N_CU; + if(Module->m_Layer == CMP_N) m_Layer = SILKSCREEN_N_CMP; + if((Module->m_Layer == SILKSCREEN_N_CU) || + (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N)) + m_Miroir = 0; + } +} + +TEXTE_MODULE:: ~TEXTE_MODULE(void) +{ +} + + +void TEXTE_MODULE::Copy(TEXTE_MODULE * source) // copy structure +{ + if (source == NULL) return; + + m_Pos = source->m_Pos; + m_Layer = source->m_Layer; + + m_Miroir = source->m_Miroir; // vue normale / miroir + m_NoShow = source->m_NoShow; // 0: visible 1: invisible + m_Type = source->m_Type; // 0: ref,1: val, autre = 2..255 + m_Orient = source->m_Orient; // orientation en 1/10 degre + m_Pos0 = source->m_Pos0; // coord du debut du texte /ancre, orient 0 + + m_Size = source->m_Size; + m_Width = source->m_Width; + + m_Text = source->m_Text; +} + +/* supprime du chainage la structure Struct + les structures arrieres et avant sont chainees directement + */ +void TEXTE_MODULE::UnLink( void ) +{ + /* Modification du chainage arriere */ + if( Pback ) + { + if( Pback->m_StructType != TYPEMODULE) + { + Pback->Pnext = Pnext; + } + + else /* Le chainage arriere pointe sur la structure "Pere" */ + { + ((MODULE*)Pback)->m_Drawings = Pnext; + } + } + + /* Modification du chainage avant */ + if( Pnext) Pnext->Pback = Pback; + + Pnext = Pback = NULL; +} + + +/******************************************/ +int TEXTE_MODULE:: GetLength(void) +/******************************************/ +{ + return m_Text.Len(); +} + +/******************************************/ +void TEXTE_MODULE:: SetWidth(int new_width) +/******************************************/ +{ + m_Width = new_width; +} + +// mise a jour des coordonnées absolues pour affichage +void TEXTE_MODULE:: SetDrawCoord(void) +{ +MODULE * Module = (MODULE *) m_Parent; + + m_Pos = m_Pos0; + + if ( Module == NULL ) return; + + int angle = Module->m_Orient; + NORMALIZE_ANGLE_POS(angle); + + RotatePoint( &m_Pos.x, &m_Pos.y, angle); + m_Pos.x += Module->m_Pos.x; + m_Pos.y += Module->m_Pos.y; +} + +// mise a jour des coordonnées relatives au module +void TEXTE_MODULE:: SetLocalCoord(void) +{ +MODULE * Module = (MODULE *) m_Parent; + + if ( Module == NULL ) return; + + m_Pos0.x = m_Pos.x - Module->m_Pos.x; + m_Pos0.y = m_Pos.y - Module->m_Pos.y; + + int angle = Module->m_Orient; + NORMALIZE_ANGLE_POS(angle); + + RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle); +} + + /* locate functions */ +int TEXTE_MODULE:: Locate(const wxPoint & posref) +{ +int mX, mY, dx, dy; +MODULE * Module = (MODULE *) m_Parent; +int angle = m_Orient; + + if (Module) angle += Module->m_Orient; + + dx = (m_Size.x * GetLength()) /2; + dy = m_Size.y / 2 ; + dx = ((dx * 10) / 9) + m_Width; /* Facteur de forme des lettres : 10/9 */ + + /* le point de reference est tourné de - angle + pour se ramener a un rectangle de reference horizontal */ + mX = posref.x - m_Pos.x; mY = posref.y - m_Pos.y; + RotatePoint(&mX, &mY, - angle); + /* le point de reference est-il dans ce rectangle */ + if( ( abs(mX) <= abs(dx) ) && ( abs(mY) <= abs(dy)) ) + { + return 1; + } + return 0; +} + + +/******************************************************************************************/ +void TEXTE_MODULE::Draw(WinEDA_DrawPanel * panel, wxDC * DC, wxPoint offset, int draw_mode) +/******************************************************************************************/ +/* trace 1 texte de module + Utilise la police definie dans grfonte.h + (Se reporter a ce fichier pour les explications complementaires) + offset = offset de trace ( reference au centre du texte) + draw_mode = GR_OR, GR_XOR.. +*/ +{ +int zoom; +int width, color, orient, miroir; +wxSize size; +wxPoint pos; // Centre du texte +PCB_SCREEN * screen; +WinEDA_BasePcbFrame * frame; +MODULE * Module = (MODULE *) m_Parent; + + + if ( panel == NULL ) return; + + screen = (PCB_SCREEN *) panel->GetScreen(); + frame = ( WinEDA_BasePcbFrame * ) panel->m_Parent; + zoom = screen->GetZoom(); + + pos.x = m_Pos.x - offset.x; + pos.y = m_Pos.y - offset.y; + + size = m_Size; + orient = GetDrawRotation(); + miroir = m_Miroir & 1 ; // = 0 si vu en miroir + width = m_Width; + if( (frame->m_DisplayModText == FILAIRE) || ( (width/zoom) < L_MIN_DESSIN) ) + width = 0; + else if ( frame->m_DisplayModText == SKETCH ) width = -width; + + GRSetDrawMode(DC, draw_mode); + + /* trace du centre du texte */ + if((g_AnchorColor & ITEM_NOT_SHOW) == 0 ) + { + int anchor_size = 2*zoom; + GRLine(&panel->m_ClipBox, DC, + pos.x - anchor_size, pos.y, + pos.x + anchor_size, pos.y, g_AnchorColor); + GRLine(&panel->m_ClipBox, DC, + pos.x, pos.y - anchor_size, + pos.x, pos.y + anchor_size, g_AnchorColor); + } + + color = g_DesignSettings.m_LayerColor[Module->m_Layer]; + + if( Module && Module->m_Layer == CUIVRE_N) color = g_ModuleTextCUColor; + if( Module && Module->m_Layer == CMP_N) color = g_ModuleTextCMPColor; + + if ( (color & ITEM_NOT_SHOW) != 0 ) return; + + if(m_NoShow) color = g_ModuleTextNOVColor; + if ( (color & ITEM_NOT_SHOW) != 0 ) return; + + /* Si le texte doit etre mis en miroir: modif des parametres */ + if( miroir == 0 ) size.x = - size.x; + + /* Trace du texte */ + DrawGraphicText(panel, DC, pos , color, m_Text, + orient, size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width); +} + + +/******************************************/ +int TEXTE_MODULE::GetDrawRotation(void) +/******************************************/ +/* Return text rotation for drawings and plotting +*/ +{ +int rotation; +MODULE * Module = (MODULE *) m_Parent; + + rotation = m_Orient; + if ( Module ) rotation += Module->m_Orient; + + NORMALIZE_ANGLE_POS(rotation); +// if( (rotation > 900 ) && (rotation < 2700 ) ) rotation -= 1800; // For angle = 0 .. 180 deg + while ( rotation > 900 ) rotation -= 1800; // For angle = -90 .. 90 deg + + return rotation; +} + diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h new file mode 100644 index 0000000000..ab2da4e222 --- /dev/null +++ b/pcbnew/class_text_mod.h @@ -0,0 +1,56 @@ + /***************************************************/ + /* class_text_module.h : texts module description */ + /***************************************************/ + +/* Description des Textes sur Modules : */ +#define TEXT_is_REFERENCE 0 +#define TEXT_is_VALUE 1 +#define TEXT_is_DIVERS 2 + + +class TEXTE_MODULE: public EDA_BaseStruct +{ +public: + int m_Layer; // layer number + int m_Width; + wxPoint m_Pos; // Real coord + wxPoint m_Pos0; // coord du debut du texte /ancre, orient 0 + char m_Unused; // unused (reserved for future extensions) + char m_Miroir ; // vue normale / miroir + char m_NoShow; // 0: visible 1: invisible (bool) + char m_Type; // 0: ref,1: val, autre = 2..255 + int m_Orient; // orientation en 1/10 degre + wxSize m_Size; // dimensions (en X et Y) du texte + wxString m_Text; + + public: + TEXTE_MODULE(MODULE * parent, int text_type = TEXT_is_DIVERS ); + ~TEXTE_MODULE(void); + + /* supprime du chainage la structure Struct */ + void UnLink( void ); + + void Copy(TEXTE_MODULE * source); // copy structure + + /* Gestion du texte */ + void SetWidth(int new_width); + int GetLength(void); /* text length */ + int Pitch(void); /* retourne le pas entre 2 caracteres */ + int GetDrawRotation(void); // Return text rotation for drawings and plotting + + void SetDrawCoord(void); // mise a jour des coordonnées absolues de tracé + // a partir des coord relatives + void SetLocalCoord(void); // mise a jour des coordonnées relatives + // a partir des coord absolues de tracé + + /* Reading and writing data on files */ + int WriteDescr( FILE * File ); + int ReadDescr( FILE * File, int * LineNum = NULL); + + /* drawing functions */ + void Draw(WinEDA_DrawPanel * panel, wxDC * DC, wxPoint offset, int draw_mode); + + /* locate functions */ + int Locate(const wxPoint & posref); +}; + diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp new file mode 100644 index 0000000000..1e3d7eaf86 --- /dev/null +++ b/pcbnew/class_track.cpp @@ -0,0 +1,562 @@ +/******************************************************************/ +/* fonctions membres des classes TRACK et derivees (voir struct.h */ +/******************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#ifdef CVPCB +#include "cvpcb.h" +#endif + + + + /**************************************/ + /* Classes pour Pistes, Vias et Zones */ + /**************************************/ + +/* Constructeur des classes type pistes, vias et zones */ + +TRACK::TRACK(EDA_BaseStruct * StructFather, DrawStructureType idtype): + EDA_BaseLineStruct( StructFather, idtype) +{ + m_Shape = S_SEGMENT; + start = end = NULL; + m_NetCode = 0; + m_Sous_Netcode = 0; + m_Drill = -1; + m_Param = 0; +} + +SEGZONE::SEGZONE(EDA_BaseStruct * StructFather): + TRACK( StructFather, TYPEZONE) +{ +} + +SEGVIA::SEGVIA(EDA_BaseStruct * StructFather): + TRACK( StructFather, TYPEVIA) +{ +} + +/* Copy constructor */ +TRACK::TRACK(const TRACK & Source): + EDA_BaseLineStruct( Source.m_Parent, (DrawStructureType)Source.m_StructType) +{ + m_StructType = Source.m_StructType; + m_Shape = Source.m_Shape; + m_NetCode = Source.m_NetCode; + m_Flags = Source.m_Flags; + m_TimeStamp = Source.m_TimeStamp; + SetStatus(Source.ReturnStatus() ); + m_Layer = Source.m_Layer; + m_Start = Source.m_Start; + m_End = Source.m_End; + m_Width = Source.m_Width; + m_Drill = Source.m_Drill; + m_Sous_Netcode = Source.m_Sous_Netcode; + m_Param = Source.m_Param; + +} + + +/***********************/ +bool TRACK::IsNull(void) +/***********************/ +// return TRUE if segment lenght = 0 +{ + if ( ( m_StructType != TYPEVIA ) && ( m_Start == m_End ) ) + return TRUE; + else return FALSE; +} + +/*************************************************************/ +int TRACK::IsPointOnEnds(const wxPoint & point, int min_dist) +/*************************************************************/ +/* Return: + STARTPOINT if point if near (dist = min_dist) star point + ENDPOINT if point if near (dist = min_dist) end point + STARTPOINT|ENDPOINT if point if near (dist = min_dist) both ends + 0 if no + if min_dist < 0: min_dist = track_width/2 +*/ +{ +int dx, dy; +int result = 0; + + if ( min_dist < 0 ) min_dist = m_Width / 2; + + dx = m_Start.x - point.x; + dy = m_Start.y - point.y; + if ( min_dist == 0 ) + { + if( (dx == 0) && (dy == 0 ) ) result |= STARTPOINT; + } + else + { + double dist = ((double)dx *dx) + ((double)dy*dy); + dist = sqrt(dist); + if ( min_dist >= (int) dist ) result |= STARTPOINT; + } + + dx = m_End.x - point.x; + dy = m_End.y - point.y; + if ( min_dist == 0 ) + { + if( (dx == 0) && (dy == 0 ) ) result |= ENDPOINT; + } + else + { + double dist = ((double)dx *dx) + ((double)dy*dy); + dist = sqrt(dist); + if ( min_dist >= (int) dist ) result |= ENDPOINT; + } + + return result; +} + +/******************************************/ +bool SEGVIA::IsViaOnLayer(int layer_number ) +/******************************************/ +/* Retoune TRUE si Via sur layer layer_number +*/ +{ +int via_type = Shape(); + + if( via_type == VIA_NORMALE ) + { + if ( layer_number <= LAYER_CMP_N ) return TRUE; + else return FALSE; + } + + // VIA_BORGNE ou VIA_ENTERREE: + +int bottom_layer, top_layer; + ReturnLayerPair(& top_layer, & bottom_layer); + if ( (bottom_layer <= layer_number) && (top_layer >= layer_number) ) + return TRUE; + else return FALSE; +} + + +/***********************************/ +int TRACK::ReturnMaskLayer(void) +/***********************************/ +/* Retourne le masque (liste bit a bit ) des couches occupees par le segment + de piste pointe par PtSegm. + Si PtSegm pointe une via, il y a plusieurs couches occupees +*/ +{ + if( m_StructType == TYPEVIA ) + { + int via_type = m_Shape & 15; + if( via_type == VIA_NORMALE ) return (ALL_CU_LAYERS); + // VIA_BORGNE ou VIA_ENTERREE: + int bottom_layer = (m_Layer >> 4) & 15; + int top_layer = m_Layer & 15; + if ( bottom_layer > top_layer ) EXCHG (bottom_layer, top_layer); + int layermask = 0; + while ( bottom_layer <= top_layer ) + { + layermask |= g_TabOneLayerMask[bottom_layer++]; + } + return (layermask); + } + else return(g_TabOneLayerMask[m_Layer]); +} + + + +/*********************************************************/ +void SEGVIA::SetLayerPair(int top_layer, int bottom_layer) +/*********************************************************/ +/* Met a jour .m_Layer pour une via: + m_Layer code les 2 couches limitant la via +*/ +{ +int via_type = m_Shape & 255; + + if( via_type == VIA_NORMALE ) + { + top_layer = LAYER_CMP_N; bottom_layer = LAYER_CUIVRE_N; + } + + if ( bottom_layer > top_layer ) EXCHG (bottom_layer, top_layer); + m_Layer = (top_layer & 15) + ( (bottom_layer & 15) << 4 ); +} + +/***************************************************************/ +void SEGVIA::ReturnLayerPair(int * top_layer, int * bottom_layer) +/***************************************************************/ +/* Retourne les 2 couches limitant la via + les pointeurs top_layer et bottom_layer peuvent etre NULLs +*/ +{ +int b_layer = (m_Layer >> 4) & 15; +int t_layer = m_Layer & 15; + + if ( b_layer > t_layer ) EXCHG (b_layer, t_layer); + if ( top_layer ) * top_layer = t_layer; + if ( bottom_layer ) * bottom_layer = b_layer; +} + + +/************************/ +TRACK * TRACK::Next(void) +/************************/ +{ + return (TRACK *) Pnext; +} + + + +/* supprime du chainage la structure Struct + les structures arrieres et avant sont chainees directement + */ +void TRACK::UnLink( void ) +{ + /* Modification du chainage arriere */ + if( Pback ) + { + if( Pback->m_StructType != TYPEPCB) + { + Pback->Pnext = Pnext; + } + + else /* Le chainage arriere pointe sur la structure "Pere" */ + { + if ( GetState(DELETED) ) // A REVOIR car Pback = NULL si place en undelete + { + if( g_UnDeleteStack ) g_UnDeleteStack[g_UnDeleteStackPtr-1] = Pnext; + } + else + { + if (m_StructType == TYPEZONE) + { + ((BOARD*)Pback)->m_Zone = (TRACK*)Pnext; + } + else + { + ((BOARD*)Pback)->m_Track = (TRACK*)Pnext; + } + } + } + } + + /* Modification du chainage avant */ + if( Pnext) Pnext->Pback = Pback; + + Pnext = Pback = NULL; +} + +/************************************************************/ +void TRACK::Insert(BOARD * Pcb, EDA_BaseStruct * InsertPoint) +/************************************************************/ +/* Ajoute un element ou une liste a une liste de base + Si Insertpoint == NULL: insertion en debut de + liste Pcb->Track ou Pcb->Zone + Insertion a la suite de InsertPoint + Si InsertPoint == NULL, insertion en tete de liste +*/ +{ +TRACK* track, *NextS; + /* Insertion du debut de la chaine a greffer */ + if (InsertPoint == NULL) + { + Pback = Pcb; + if (m_StructType == TYPEZONE) + { + NextS = Pcb->m_Zone; Pcb->m_Zone = this; + } + else + { + NextS = Pcb->m_Track; Pcb->m_Track = this; + } + } + + else + { + NextS = (TRACK*)InsertPoint->Pnext; + Pback = InsertPoint; + InsertPoint->Pnext = this; + } + + /* Chainage de la fin de la liste a greffer */ + track = this; + while ( track->Pnext ) track = (TRACK*) track->Pnext; + /* Track pointe la fin de la chaine a greffer */ + track->Pnext = NextS; + if ( NextS ) NextS->Pback = track; +} + + +/***********************************************/ +TRACK * TRACK::GetBestInsertPoint( BOARD * Pcb ) +/***********************************************/ +/* Recherche du meilleur point d'insertion pour le nouveau segment de piste + Retourne + un pointeur sur le segment de piste APRES lequel l'insertion + doit se faire ( dernier segment du net d'apartenance ) + NULL si pas de piste ( liste vide ); +*/ +{ +TRACK * track, * NextTrack; + + if( m_StructType == TYPEZONE ) track = Pcb->m_Zone; + else track = Pcb->m_Track; + + /* Traitement du debut de liste */ + if ( track == NULL ) return(NULL); /* pas de piste ! */ + if ( m_NetCode < track->m_NetCode ) /* insertion en tete de liste */ + return(NULL); + + while( (NextTrack = (TRACK*)track->Pnext) != NULL ) + { + if ( NextTrack->m_NetCode > this->m_NetCode ) break; + track = NextTrack; + } + return ( track); +} + +/* Recherche du debut du net + ( les elements sont classes par net_code croissant ) + la recherche se fait a partir de this + si net_code == -1 le netcode de this sera utilise + Retourne un pointeur sur le debut du net, ou NULL si net non trouve +*/ +TRACK * TRACK::GetStartNetCode(int NetCode ) +{ +TRACK * Track = this; +int ii = 0; + + if( NetCode == -1 ) NetCode = m_NetCode; + + while( Track != NULL) + { + if ( Track->m_NetCode > NetCode ) break; + if ( Track->m_NetCode == NetCode ) + { + ii++; break; + } + Track = (TRACK*) Track->Pnext; + } + if ( ii ) return(Track); + else return (NULL); +} + +/* Recherche de la fin du net + Retourne un pointeur sur la fin du net, ou NULL si net non trouve +*/ +TRACK * TRACK::GetEndNetCode(int NetCode) +{ +TRACK * NextS, * Track = this; +int ii = 0; + + if( Track == NULL ) return(NULL); + + if( NetCode == -1 ) NetCode = m_NetCode; + + while( Track != NULL) + { + NextS = (TRACK*)Track->Pnext; + if(Track->m_NetCode == NetCode) ii++; + if ( NextS == NULL ) break; + if ( NextS->m_NetCode > NetCode) break; + Track = NextS; + } + if ( ii ) return(Track); + else return (NULL); +} + + +/**********************************/ +TRACK * TRACK:: Copy( int NbSegm ) +/**********************************/ +/* Copie d'un Element ou d'une chaine de n elements + Retourne un pointeur sur le nouvel element ou le debut de la + nouvelle chaine +*/ +{ +TRACK * NewTrack, * FirstTrack, *OldTrack, * Source = this; +int ii; + + FirstTrack = NewTrack = new TRACK(*Source); + + for( ii = 1; ii < NbSegm; ii++ ) + { + Source = Source->Next(); + if( Source == NULL ) break; + OldTrack = NewTrack; + NewTrack = new TRACK(*Source); + NewTrack->Insert(NULL, OldTrack); + } + + return (FirstTrack); +} + +/********************************************/ +bool TRACK::WriteTrackDescr(FILE * File) +/********************************************/ +{ +int type; + + type = 0; + if( m_StructType == TYPEVIA ) type = 1; + + if( GetState(DELETED) ) return FALSE; + + fprintf( File,"Po %d %d %d %d %d %d %d\n",m_Shape, + m_Start.x, m_Start.y, m_End.x, m_End.y, m_Width, m_Drill); + + fprintf( File,"De %d %d %d %lX %X\n", + m_Layer, type ,m_NetCode, + m_TimeStamp, ReturnStatus()); + return TRUE; +} + +/**********************************************************************/ +void TRACK::Draw(WinEDA_DrawPanel * panel, wxDC * DC, int draw_mode) +/*********************************************************************/ + /* routine de trace de 1 segment de piste. +Parametres : + draw_mode = mode ( GR_XOR, GR_OR..) +*/ +{ +int l_piste; +int color; +int zoom; +int rayon; +int curr_layer = ((PCB_SCREEN*)panel->GetScreen())->m_Active_Layer; + + if(m_StructType == TYPEZONE && (! DisplayOpt.DisplayZones) ) + return; + + GRSetDrawMode(DC, draw_mode); + + if ( m_StructType == TYPEVIA ) /* VIA rencontree */ + color = g_DesignSettings.m_ViaColor[m_Shape]; + else color = g_DesignSettings.m_LayerColor[m_Layer]; + + if( (color & (ITEM_NOT_SHOW | HIGHT_LIGHT_FLAG)) == ITEM_NOT_SHOW) return ; + + if ( DisplayOpt.ContrastModeDisplay ) + { + if ( m_StructType == TYPEVIA ) + { + if ( ! ((SEGVIA*)this)->IsViaOnLayer(curr_layer) ) + { + color &= ~MASKCOLOR; + color |= DARKDARKGRAY; + } + } + else if ( m_Layer != curr_layer) + { + color &= ~MASKCOLOR; + color |= DARKDARKGRAY; + } + } + + if( draw_mode & GR_SURBRILL) + { + if( draw_mode & GR_AND) color &= ~HIGHT_LIGHT_FLAG; + else color |= HIGHT_LIGHT_FLAG; + } + if ( color & HIGHT_LIGHT_FLAG) + color = ColorRefs[color & MASKCOLOR].m_LightColor; + + zoom = panel->GetZoom(); + + l_piste = m_Width >> 1; + + if ( m_StructType == TYPEVIA ) /* VIA rencontree */ + { + rayon = l_piste; if( rayon < zoom ) rayon = zoom; + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color) ; + if ( rayon > (4*zoom) ) + { + int drill_rayon, inner_rayon = rayon-(2*zoom); + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, + inner_rayon, color); + // Draw the via hole if the display option request it + if ( DisplayOpt.m_DisplayViaMode != VIA_HOLE_NOT_SHOW) + { + if ( (DisplayOpt.m_DisplayViaMode == ALL_VIA_HOLE_SHOW) + || ( m_Drill > 0 ) ) + { + if ( m_Drill > 0 ) drill_rayon = m_Drill / 2; + else drill_rayon = g_DesignSettings.m_ViaDrill / 2; + if( drill_rayon < inner_rayon ) // We can show the via hole + { + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, + drill_rayon , color); + } + } + } + + if(DisplayOpt.DisplayTrackIsol) + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, + rayon + g_DesignSettings.m_TrackClearence, color); + } + return; + } + + if(m_Shape == S_CIRCLE) + { + rayon = (int)hypot((double)(m_End.x - m_Start.x), + (double)(m_End.y - m_Start.y) ); + if ( (l_piste/zoom) < L_MIN_DESSIN) + { + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon , color) ; + } + + else + { + if(l_piste <= zoom) /* trace simplifie si l_piste/zoom <= 1 */ + { + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color); + } + else if( ( ! DisplayOpt.DisplayPcbTrackFill) || GetState(FORCE_SKETCH)) + { + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon-l_piste, color); + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon+l_piste, color); + } + else + { + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, + m_Width, color); + } + } + return; + } + + if ( (l_piste/zoom) < L_MIN_DESSIN) + { + GRLine(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, + m_End.x, m_End.y, color); + return; + } + + if( (! DisplayOpt.DisplayPcbTrackFill) || GetState(FORCE_SKETCH) ) + { + GRCSegm(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, + m_End.x, m_End.y, m_Width, color) ; + } + else + { + GRFillCSegm(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, + m_End.x, m_End.y, m_Width, color) ; + } + + /* Trace de l'isolation (pour segments type CUIVRE et TRACK uniquement */ + if( (DisplayOpt.DisplayTrackIsol) && (m_Layer <= CMP_N ) + && ( m_StructType == TYPETRACK) ) + { + GRCSegm(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, + m_End.x, m_End.y, + m_Width + (g_DesignSettings.m_TrackClearence*2), color) ; + } +} + + diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h new file mode 100644 index 0000000000..21500b9927 --- /dev/null +++ b/pcbnew/class_track.h @@ -0,0 +1,93 @@ +/*******************************************************************/ +/* class_track.h: definition des structures de donnees type track */ +/*******************************************************************/ + +#ifndef CLASS_TRACK_H +#define CLASS_TRACK_H + +#include "base_struct.h" + +/* Type des Vias (shape)*/ + +/* Forme des Vias ( parametre .shape ) */ +#define VIA_NORMALE 3 /* type via : traversante (throught via) */ +#define VIA_ENTERREE 2 /* type via : enterree ou aveugle (blind via) */ +#define VIA_BORGNE 1 /* type via : borgne ou demi-traversante (buried via) */ +#define VIA_NOT_DEFINED 0 /* reserved */ +#define SQUARE_VIA 0x80000000 /* Flag pour forme carree */ + + +/***/ + +class TRACK: public EDA_BaseLineStruct +{ +public: + int m_Shape; // vias: shape and type, Track = shape.. + int m_Drill; // for vias: via drill (- 1 for default value) + EDA_BaseStruct * start,* end; // pointers on a connected item (pad or track) + int m_NetCode; // Net number + int m_Sous_Netcode; /* In rastnest routines : for the current net, + block number (number common to the current connected items found) */ + // chain = 0 indique une connexion non encore traitee + int m_Param; // Auxiliary variable ( used in some computations ) + +public: + TRACK(EDA_BaseStruct * StructFather, DrawStructureType idtype = TYPETRACK); + TRACK(const TRACK & track); + + TRACK * Next(void); // Retourne le chainage avant + TRACK * Back(void) // Retourne le chainage avant + { + return (TRACK*) Pback; + } + + /* supprime du chainage la structure Struct */ + void UnLink( void ); + + // Read/write data + bool WriteTrackDescr(FILE * File); + + /* Ajoute un element a la liste */ + void Insert(BOARD * Pcb, EDA_BaseStruct * InsertPoint); + + /* Recherche du meilleur point d'insertion */ + TRACK * GetBestInsertPoint( BOARD * Pcb); + + /* Copie d'un Element d'une chaine de n elements */ + TRACK * Copy( int NbSegm = 1 ); + + /* Recherche du debut du net + ( les elements sont classes par net_code croissant ) */ + TRACK * GetStartNetCode(int NetCode ); + /* Recherche de la fin du net */ + TRACK * GetEndNetCode(int NetCode); + + /* Display on screen: */ + void Draw(WinEDA_DrawPanel * panel, wxDC * DC, int draw_mode); + + /* divers */ + int Shape(void) { return m_Shape & 0xFF; } + + int ReturnMaskLayer(void); + int IsPointOnEnds(const wxPoint & point, int min_dist = 0); + bool IsNull(void); // return TRUE if segment lenght = 0 +}; + +class SEGZONE: public TRACK +{ +public: + SEGZONE(EDA_BaseStruct * StructFather); +}; + +class SEGVIA: public TRACK +{ +public: + SEGVIA(EDA_BaseStruct * StructFather); + bool IsViaOnLayer(int layer); + void SetLayerPair(int top_layer, int bottom_layer); + void ReturnLayerPair(int * top_layer, int * bottom_layer); +}; + + + +#endif /* CLASS_TRACK_H */ diff --git a/pcbnew/classpcb.cpp b/pcbnew/classpcb.cpp new file mode 100644 index 0000000000..1a28e24630 --- /dev/null +++ b/pcbnew/classpcb.cpp @@ -0,0 +1,323 @@ +/**********************************************************************/ +/* fonctions membres des classes utilisees dans pcbnew (voir pcbstruct.h */ +/* sauf routines relatives aux pistes (voir class_track.cpp) */ +/**********************************************************************/ + +#include "fctsys.h" +#include "wxstruct.h" + +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#ifdef CVPCB +#include "cvpcb.h" +#endif + +#include "protos.h" + + +/**************************************************************/ +void EDA_BaseStruct::Place(WinEDA_DrawFrame * frame, wxDC * DC) +/**************************************************************/ +/* fonction virtuelle de placement: non utilisee en pcbnew (utilisee eeschema) +---- A mieux utiliser (TODO...) +*/ +{ +} + + + + /**********************/ + /* Classe EDGE_ZONE */ + /**********************/ + +/* Classe EDGE_ZONE: constructeur */ +EDGE_ZONE::EDGE_ZONE(EDA_BaseStruct * parent): + DRAWSEGMENT( parent, TYPEEDGEZONE) +{ +} + +/* Effacement memoire de la structure */ +EDGE_ZONE:: ~EDGE_ZONE(void) +{ +} + + /**********************/ + /* Classe DRAWSEGMENT */ + /**********************/ + +/* Classe DRAWSEGMENT: constructeur */ +DRAWSEGMENT::DRAWSEGMENT(EDA_BaseStruct * StructFather, DrawStructureType idtype): + EDA_BaseLineStruct( StructFather, idtype) +{ + m_Flags = m_Shape = m_Type = m_Angle = 0; +} + +/* Effacement memoire de la structure */ +DRAWSEGMENT:: ~DRAWSEGMENT(void) +{ +} + +void DRAWSEGMENT::UnLink( void ) +{ + /* Modification du chainage arriere */ + if( Pback ) + { + if( Pback->m_StructType != TYPEPCB) + { + Pback->Pnext = Pnext; + } + + else /* Le chainage arriere pointe sur la structure "Pere" */ + { + ((BOARD*)Pback)->m_Drawings = Pnext; + } + } + + /* Modification du chainage avant */ + if( Pnext) Pnext->Pback = Pback; + + Pnext = Pback = NULL; +} + + +/*******************************************/ +void DRAWSEGMENT::Copy(DRAWSEGMENT * source) +/*******************************************/ +{ + m_Type = source->m_Type; + m_Layer = source->m_Layer; + m_Width = source->m_Width; + m_Start = source->m_Start; + m_End = source->m_End; + m_Shape = source->m_Shape; + m_Angle = source->m_Angle; + m_TimeStamp = source->m_TimeStamp; +} + + +/********************************************************/ +bool DRAWSEGMENT::WriteDrawSegmentDescr(FILE * File) +/********************************************************/ +{ + if( GetState(DELETED) ) return FALSE; + + fprintf( File, "$DRAWSEGMENT\n"); + fprintf( File,"Po %d %d %d %d %d %d\n", + m_Shape, + m_Start.x, m_Start.y, + m_End.x, m_End.y, m_Width ); + fprintf( File,"De %d %d %d %lX %X\n", + m_Layer, m_Type, m_Angle, + m_TimeStamp, ReturnStatus()); + fprintf( File, "$EndDRAWSEGMENT\n"); + return TRUE; +} + +/******************************************************************/ +bool DRAWSEGMENT::ReadDrawSegmentDescr(FILE * File, int * LineNum) +/******************************************************************/ +/* Lecture de la description de 1 segment type Drawing PCB +*/ +{ +char Line[2048]; + + + while( GetLine(File, Line, LineNum ) != NULL ) + { + if(strnicmp(Line,"$End",4 ) == 0 ) return TRUE; /* fin de liste */ + if(Line[0] == 'P') + { + sscanf( Line+2," %d %d %d %d %d %d", + &m_Shape, &m_Start.x, &m_Start.y, + &m_End.x, &m_End.y, &m_Width ); + if ( m_Width < 0 ) m_Width = 0; + } + + if(Line[0] == 'D') + { + int status; + sscanf( Line+2," %d %d %d %lX %X", + &m_Layer, &m_Type, &m_Angle, + &m_TimeStamp, &status); + + if ( m_Layer < FIRST_NO_COPPER_LAYER ) + m_Layer = FIRST_NO_COPPER_LAYER; + if ( m_Layer > LAST_NO_COPPER_LAYER ) + m_Layer = LAST_NO_COPPER_LAYER; + + SetState(status, ON); + } + + } + return FALSE; +} + + + + /*******************/ + /* Classe MARQUEUR */ + /*******************/ + +MARQUEUR::MARQUEUR(EDA_BaseStruct * StructFather): + EDA_BaseStruct( StructFather, TYPEMARQUEUR) +{ + m_Bitmap = NULL; + m_Type = 0; + m_Color = RED; +} + +/* Effacement memoire de la structure */ +MARQUEUR:: ~MARQUEUR(void) +{ +} + + +/* supprime du chainage la structure Struct + les structures arrieres et avant sont chainees directement + */ +void MARQUEUR::UnLink( void ) +{ + /* Modification du chainage arriere */ + if( Pback ) + { + if( Pback->m_StructType != TYPEPCB) + { + Pback->Pnext = Pnext; + } + + else /* Le chainage arriere pointe sur la structure "Pere" */ + { + ((BOARD*)Pback)->m_Drawings = Pnext; + } + } + + /* Modification du chainage avant */ + if( Pnext) Pnext->Pback = Pback; + + Pnext = Pback = NULL; +} + + + + /**************************************************/ + /* Class SCREEN: classe de gestion d'un affichage */ + /***************************************************/ +/* Constructeur de SCREEN */ +PCB_SCREEN::PCB_SCREEN(int idscreen): BASE_SCREEN(TYPESCREEN) +{ +int zoom_list[] = {1,2,4,8,16,32,64,128,256,512,1024,2048,0}; + m_Type = idscreen; + SetGridList(g_GridList); + SetZoomList(zoom_list); + Init(); +} + +/***************************/ +PCB_SCREEN::~PCB_SCREEN(void) +/***************************/ +{ +} + + +/*************************/ +void PCB_SCREEN::Init(void) +/*************************/ +{ + InitDatas(); + m_Active_Layer = CUIVRE_N; /* ref couche active 0.. 31 */ + m_Route_Layer_TOP = CMP_N; /* ref couches par defaut pour vias (Cu.. Cmp) */ + m_Route_Layer_BOTTOM = CUIVRE_N; + m_Zoom = 128; /* valeur */ + m_Grid = wxSize(500,500); /* pas de la grille en 1/10000 "*/ +} + + +/*************************/ +/* class DISPLAY_OPTIONS */ +/*************************/ +/* +Options diverses d'affichage à l'écran: +*/ + +DISPLAY_OPTIONS::DISPLAY_OPTIONS(void) +{ + DisplayPadFill = TRUE; + DisplayPadNum = TRUE; + DisplayPadNoConn = TRUE; + DisplayPadIsol = TRUE; + + DisplayModEdge = TRUE; + DisplayModText = TRUE; + DisplayPcbTrackFill = TRUE; /* FALSE = sketch , TRUE = rempli */ + DisplayTrackIsol = FALSE; + m_DisplayViaMode = VIA_HOLE_NOT_SHOW; + + DisplayPolarCood = TRUE; + DisplayZones = TRUE; + Show_Modules_Cmp = TRUE; + Show_Modules_Cu = TRUE; + + DisplayDrawItems = TRUE; + ContrastModeDisplay = FALSE; +} + + +/*****************************************************/ +EDA_BoardDesignSettings::EDA_BoardDesignSettings(void) +/*****************************************************/ +// Default values for designing boards +{ +int ii; +int default_layer_color[32]= { + GREEN, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, + LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, + LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, + LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, RED, + LIGHTGRAY, LIGHTGRAY, + LIGHTGRAY, LIGHTGRAY, + MAGENTA, CYAN, + LIGHTGRAY, LIGHTGRAY, + LIGHTGRAY, + LIGHTGRAY, + LIGHTGRAY, LIGHTGRAY, + LIGHTGRAY, + LIGHTGRAY, + LIGHTGRAY, + LIGHTGRAY }; + + m_CopperLayerCount = 2; // Default design is a double sided board + m_ViaDrill = 250; // via drill (for the entire board) + m_CurrentViaSize = 450; // Current via size + m_CurrentViaType = VIA_NORMALE; /* via type (BLIND, TROUGHT ...), bits 1 and 2 (not 0 and 1)*/ + m_CurrentTrackWidth = 170; // current track width + for ( ii = 0; ii < HIST0RY_NUMBER; ii ++ ) + { + m_TrackWidhtHistory[ii] = 0; // Last HIST0RY_NUMBER used track widths + m_ViaSizeHistory[ii] = 0; // Last HIST0RY_NUMBER used via sizes + } + m_DrawSegmentWidth = 100; // current graphic line width (not EDGE layer) + m_EdgeSegmentWidth = 100; // current graphic line width (EDGE layer only) + m_PcbTextWidth = 100; // current Pcb (not module) Text width + m_PcbTextSize = wxSize(500,500); // current Pcb (not module) Text size + m_TrackClearence = 100; // track to track and track to pads clearance + m_ZoneClearence = 150; // zone to track and zone to pads clearance + m_MaskMargin = 150; // Solder mask margin + /* Color options for screen display of the Printed Board: */ + m_PcbGridColor = DARKGRAY; // Grid color + for ( ii = 0; ii < 32; ii ++ ) + m_LayerColor[ii] = default_layer_color[ii]; // Layer colors (tracks and graphic items) + m_ViaColor[VIA_BORGNE] = CYAN; + m_ViaColor[VIA_ENTERREE] = BROWN; + m_ViaColor[VIA_NORMALE] = WHITE; + m_ModuleTextCMPColor = LIGHTGRAY; // Text module color for modules on the COMPONENT layer + m_ModuleTextCUColor = MAGENTA; // Text module color for modules on the COPPER layer + m_ModuleTextNOVColor = DARKGRAY; // Text module color for "invisible" texts (must be BLACK if really not displayed) + m_AnchorColor = BLUE; // Anchor color for modules and texts + m_PadCUColor = GREEN; // Pad color for the COMPONENT side of the pad + m_PadCMPColor = RED; // Pad color for the COPPER side of the pad + m_RatsnestColor = WHITE; // Ratsnest color +} + diff --git a/pcbnew/classtrc.cpp b/pcbnew/classtrc.cpp new file mode 100644 index 0000000000..f598c461b9 --- /dev/null +++ b/pcbnew/classtrc.cpp @@ -0,0 +1,460 @@ +/******************************************************************/ +/* fonctions membres des classes TRACK et derivees (voir struct.h */ +/******************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#ifdef CVPCB +#include "cvpcb.h" +#endif + + + + /**************************************/ + /* Classes pour Pistes, Vias et Zones */ + /**************************************/ + +/* Constructeur des classes type pistes, vias et zones */ + +TRACK::TRACK(EDA_BaseStruct * StructFather, DrawStructureType idtype): + SEGDRAW_Struct( StructFather, idtype) +{ + m_Shape = S_SEGMENT; + start = end = NULL; + m_NetCode = 0; + m_Sous_Netcode = 0; +} + +SEGZONE::SEGZONE(EDA_BaseStruct * StructFather): + TRACK( StructFather, TYPEZONE) +{ +} + +SEGVIA::SEGVIA(EDA_BaseStruct * StructFather): + TRACK( StructFather, TYPEVIA) +{ +} + +/******************************************/ +bool SEGVIA::IsViaOnLayer(int layer_number ) +/******************************************/ +/* Retoune TRUE si Via sur layer layer_number +*/ +{ +int via_type = Shape(); + + if( via_type == VIA_NORMALE ) + { + if ( layer_number <= LAYER_CMP_N ) return TRUE; + else return FALSE; + } + + // VIA_BORGNE ou VIA_ENTERREE: + +int bottom_layer, top_layer; + ReturnLayerPair(& top_layer, & bottom_layer); + if ( (bottom_layer <= layer_number) && (top_layer >= layer_number) ) + return TRUE; + else return FALSE; +} + + +/*********************************************************/ +void SEGVIA::SetLayerPair(int top_layer, int bottom_layer) +/*********************************************************/ +/* Met a jour .m_Layer pour une via: + m_Layer code les 2 couches limitant la via +*/ +{ +int via_type = m_Shape & 255; + + if( via_type == VIA_NORMALE ) + { + top_layer = LAYER_CMP_N; bottom_layer = LAYER_CUIVRE_N; + } + + if ( bottom_layer > top_layer ) EXCHG (bottom_layer, top_layer); + m_Layer = (top_layer & 15) + ( (bottom_layer & 15) << 4 ); +} + +/***************************************************************/ +void SEGVIA::ReturnLayerPair(int * top_layer, int * bottom_layer) +/***************************************************************/ +/* Retourne les 2 couches limitant la via + les pointeurs top_layer et bottom_layer peuvent etre NULLs +*/ +{ +int b_layer = (m_Layer >> 4) & 15; +int t_layer = m_Layer & 15; + + if ( b_layer > t_layer ) EXCHG (b_layer, t_layer); + if ( top_layer ) * top_layer = t_layer; + if ( bottom_layer ) * bottom_layer = b_layer; +} + + +/************************/ +TRACK * TRACK::Next(void) +/************************/ +{ + return (TRACK *) Pnext; +} + + + +/* supprime du chainage la structure Struct + les structures arrieres et avant sont chainees directement + */ +void TRACK::UnLink( void ) +{ + /* Modification du chainage arriere */ + if( Pback ) + { + if( Pback->m_StructType != TYPEPCB) + { + Pback->Pnext = Pnext; + } + + else /* Le chainage arriere pointe sur la structure "Pere" */ + { + if ( GetState(DELETED) ) // A REVOIR car Pback = NULL si place en undelete + { + if( g_UnDeleteStack ) g_UnDeleteStack[g_UnDeleteStackPtr-1] = Pnext; + } + else + { + if (m_StructType == TYPEZONE) + { + ((BOARD*)Pback)->m_Zone = (TRACK*)Pnext; + } + else + { + ((BOARD*)Pback)->m_Track = (TRACK*)Pnext; + } + } + } + } + + /* Modification du chainage avant */ + if( Pnext) Pnext->Pback = Pback; + + Pnext = Pback = NULL; +} + +/************************************************************/ +void TRACK::Insert(BOARD * Pcb, EDA_BaseStruct * InsertPoint) +/************************************************************/ +/* Ajoute un element ou une liste a une liste de base + Si Insertpoint == NULL: insertion en debut de + liste Pcb->Track ou Pcb->Zone + Insertion a la suite de InsertPoint + Si InsertPoint == NULL, insertion en tete de liste +*/ +{ +TRACK* track, *NextS; + /* Insertion du debut de la chaine a greffer */ + if (InsertPoint == NULL) + { + Pback = Pcb; + if (m_StructType == TYPEZONE) + { + NextS = Pcb->m_Zone; Pcb->m_Zone = this; + } + else + { + NextS = Pcb->m_Track; Pcb->m_Track = this; + } + } + + else + { + NextS = (TRACK*)InsertPoint->Pnext; + Pback = InsertPoint; + InsertPoint->Pnext = this; + } + + /* Chainage de la fin de la liste a greffer */ + track = this; + while ( track->Pnext ) track = (TRACK*) track->Pnext; + /* Track pointe la fin de la chaine a greffer */ + track->Pnext = NextS; + if ( NextS ) NextS->Pback = track; +} + + +/***********************************************/ +TRACK * TRACK::GetBestInsertPoint( BOARD * Pcb ) +/***********************************************/ +/* Recherche du meilleur point d'insertion pour le nouveau segment de piste + Retourne + un pointeur sur le segment de piste APRES lequel l'insertion + doit se faire ( dernier segment du net d'apartenance ) + NULL si pas de piste ( liste vide ); +*/ +{ +TRACK * track, * NextTrack; + + if( m_StructType == TYPEZONE ) track = Pcb->m_Zone; + else track = Pcb->m_Track; + + /* Traitement du debut de liste */ + if ( track == NULL ) return(NULL); /* pas de piste ! */ + if ( m_NetCode < track->m_NetCode ) /* insertion en tete de liste */ + return(NULL); + + while( (NextTrack = (TRACK*)track->Pnext) != NULL ) + { + if ( NextTrack->m_NetCode > this->m_NetCode ) break; + track = NextTrack; + } + return ( track); +} + +/* Recherche du debut du net + ( les elements sont classes par net_code croissant ) + la recherche se fait a partir de this + si net_code == -1 le netcode de this sera utilise + Retourne un pointeur sur le debut du net, ou NULL si net non trouve +*/ +TRACK * TRACK::GetStartNetCode(int NetCode ) +{ +TRACK * Track = this; +int ii = 0; + + if( NetCode == -1 ) NetCode = m_NetCode; + + while( Track != NULL) + { + if ( Track->m_NetCode > NetCode ) break; + if ( Track->m_NetCode == NetCode ) + { + ii++; break; + } + Track = (TRACK*) Track->Pnext; + } + if ( ii ) return(Track); + else return (NULL); +} + +/* Recherche de la fin du net + Retourne un pointeur sur la fin du net, ou NULL si net non trouve +*/ +TRACK * TRACK::GetEndNetCode(int NetCode) +{ +TRACK * NextS, * Track = this; +int ii = 0; + + if( Track == NULL ) return(NULL); + + if( NetCode == -1 ) NetCode = m_NetCode; + + while( Track != NULL) + { + NextS = (TRACK*)Track->Pnext; + if(Track->m_NetCode == NetCode) ii++; + if ( NextS == NULL ) break; + if ( NextS->m_NetCode > NetCode) break; + Track = NextS; + } + if ( ii ) return(Track); + else return (NULL); +} + + +/**********************************/ +TRACK * TRACK:: Copy( int NbSegm ) +/**********************************/ +/* Copie d'un Element ou d'une chaine de n elements + Retourne un pointeur sur le nouvel element ou le debut de la + nouvelle chaine +*/ +{ +TRACK * NewTrack, * FirstTrack, *OldTrack, * Source = this; +int ii; + + FirstTrack = NewTrack = new TRACK(NULL); + *NewTrack = * Source; + + /* correction du chainage */ + NewTrack->Pback = NewTrack->Pnext = NULL; + + /* reset des pointeurs auxiliaires */ + NewTrack->start = NewTrack->end = NULL; + + if( NbSegm <=1 ) return (FirstTrack); + + for( ii = 1; ii < NbSegm; ii++ ) + { + Source = (TRACK*) Source->Pnext; + if( Source == NULL ) break; + OldTrack = NewTrack; + NewTrack = new TRACK(m_Parent); + if ( NewTrack == NULL ) break; + NewTrack->m_StructType = Source->m_StructType; + NewTrack->m_Shape = Source->m_Shape; + NewTrack->m_NetCode = Source->m_NetCode; + NewTrack->m_Flags = Source->m_Flags; + NewTrack->m_TimeStamp = Source->m_TimeStamp; + NewTrack->SetStatus(Source->ReturnStatus() ); + NewTrack->m_Layer = Source->m_Layer; + NewTrack->m_Start = Source->m_Start; + NewTrack->m_End = Source->m_End; + NewTrack->m_Width = Source->m_Width; + + NewTrack->Insert(NULL, OldTrack); + } + + return (FirstTrack); +} + +/********************************************/ +bool TRACK::WriteTrackDescr(FILE * File) +/********************************************/ +{ +int type; + + type = 0; + if( m_StructType == TYPEVIA ) type = 1; + + if( GetState(DELETED) ) return FALSE; + + fprintf( File,"Po %d %d %d %d %d %d\n",m_Shape, + m_Start.x, m_Start.y, m_End.x, m_End.y, m_Width ); + + fprintf( File,"De %d %d %d %lX %X\n", + m_Layer, type ,m_NetCode, + m_TimeStamp, ReturnStatus()); + return TRUE; +} + +/**********************************************************************/ +void TRACK::Draw(WinEDA_DrawPanel * panel, wxDC * DC, int draw_mode) +/*********************************************************************/ + /* routine de trace de 1 segment de piste. +Parametres : + draw_mode = mode ( GR_XOR, GR_OR..) +*/ +{ +int l_piste; +int color; +int zoom; +int rayon; +int curr_layer = ((PCB_SCREEN*)panel->GetScreen())->m_Active_Layer; + + if(m_StructType == TYPEZONE && (! DisplayOpt.DisplayZones) ) + return; + + GRSetDrawMode(DC, draw_mode); + + if ( m_StructType == TYPEVIA ) /* VIA rencontree */ + color = g_DesignSettings.m_ViaColor[m_Shape]; + else color = g_DesignSettings.m_LayerColor[m_Layer]; + + if( (color & (ITEM_NOT_SHOW | HIGHT_LIGHT_FLAG)) == ITEM_NOT_SHOW) return ; + + if ( DisplayOpt.ContrastModeDisplay ) + { + if ( m_StructType == TYPEVIA ) + { + if ( ! ((SEGVIA*)this)->IsViaOnLayer(curr_layer) ) + { + color &= ~MASKCOLOR; + color |= DARKDARKGRAY; + } + } + else if ( m_Layer != curr_layer) + { + color &= ~MASKCOLOR; + color |= DARKDARKGRAY; + } + } + + if( draw_mode & GR_SURBRILL) + { + if( draw_mode & GR_AND) color &= ~HIGHT_LIGHT_FLAG; + else color |= HIGHT_LIGHT_FLAG; + } + if ( color & HIGHT_LIGHT_FLAG) + color = ColorRefs[color & MASKCOLOR].m_LightColor; + + zoom = panel->GetZoom(); + + l_piste = m_Width >> 1; + + if ( m_StructType == TYPEVIA ) /* VIA rencontree */ + { + rayon = l_piste; if( rayon < zoom ) rayon = zoom; + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color) ; + if ( rayon > (4*zoom) ) + { + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, + rayon-(2*zoom) , color); + + if(DisplayOpt.DisplayTrackIsol) + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, + rayon + g_DesignSettings.m_TrackClearence, color); + } + return; + } + + if(m_Shape == S_CIRCLE) + { + rayon = (int)hypot((double)(m_End.x - m_Start.x), + (double)(m_End.y - m_Start.y) ); + if ( (l_piste/zoom) < L_MIN_DESSIN) + { + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon , color) ; + } + + else + { + if(l_piste <= zoom) /* trace simplifie si l_piste/zoom <= 1 */ + { + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color); + } + else if( ( ! DisplayOpt.DisplayPcbTrackFill) || GetState(FORCE_SKETCH)) + { + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon-l_piste, color); + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon+l_piste, color); + } + else + { + GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, + m_Width, color); + } + } + return; + } + + if ( (l_piste/zoom) < L_MIN_DESSIN) + { + GRLine(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, + m_End.x, m_End.y, color); + return; + } + + if( (! DisplayOpt.DisplayPcbTrackFill) || GetState(FORCE_SKETCH) ) + { + GRCSegm(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, + m_End.x, m_End.y, m_Width, color) ; + } + else + { + GRFillCSegm(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, + m_End.x, m_End.y, m_Width, color) ; + } + + /* Trace de l'isolation (pour segments type CUIVRE et TRACK uniquement */ + if( (DisplayOpt.DisplayTrackIsol) && (m_Layer <= CMP_N ) + && ( m_StructType == TYPETRACK) ) + { + GRCSegm(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, + m_End.x, m_End.y, + m_Width + (g_DesignSettings.m_TrackClearence*2), color) ; + } +} + diff --git a/pcbnew/clean.cpp b/pcbnew/clean.cpp new file mode 100644 index 0000000000..6084175492 --- /dev/null +++ b/pcbnew/clean.cpp @@ -0,0 +1,831 @@ + /******************************************************/ + /* editeur de PCB PCBNEW */ + /* Fonctions de Nettoyage et reorganisation de Pistes */ + /******************************************************/ + + /* Fichier CLEAN.CPP */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "protos.h" + +/* Constantes de controle de l'affichage des messages */ +#define AFFICHE 1 +#define POS_AFF_PASSE 40 +#define POS_AFF_VAR 50 +#define POS_AFF_MAX 60 +#define POS_AFF_NUMSEGM 70 + +/* Routines locales : */ +#if 0 +static void raccord_track_a_centre(WinEDA_PcbFrame * frame); +static void Gen_Raccord_Track(WinEDA_PcbFrame * frame, wxDC * DC); +#endif +static int clean_segments(WinEDA_PcbFrame * frame, wxDC * DC); +static void suppression_piste_non_connectee(WinEDA_PcbFrame * frame, wxDC * DC); +static TRACK * AlignSegment(BOARD * Pcb, TRACK * pt_ref, TRACK * pt_segm, int extremite); + +/* Variables locales : */ +static int a_color; /* couleur du message */ + + +/*****************************************/ +void WinEDA_PcbFrame::Clean_Pcb(wxDC * DC) +/*****************************************/ +/* Regroupement des segments de meme piste. + Suppression des points inutiles + - via sur pad + - points de couche et coord identiques + - points align‚s (supp du pt milieu) +*/ +{ + MsgPanel->EraseMsgBox(); + m_Pcb->GetNumSegmTrack(); /* Met a jour le compte */ + /* construction de la liste des coordonnées des pastilles */ + m_Pcb->m_Status_Pcb = 0; + build_liste_pads(); + recalcule_pad_net_code(); + +#if 0 + if( Raccords_Auto) /* Creation de points de connexion */ + { + /* Raccordement des extremites de piste au centre des pastilles : */ + raccord_track_a_centre(this); + + /* Creation de points de raccordements aux intersections de pistes */ + Gen_Raccord_Track(this); + } +#endif + + /* suppression des segments de longueur nulle et des points intermediaires + alignes */ + clean_segments(this, DC); + + /* suppression des pistes non connectees ( c.a.d dont 1 extremite est en l'air) */ + suppression_piste_non_connectee(this, DC); + + Compile_Ratsnest(DC, AFFICHE); + + m_CurrentScreen->SetModify(); +} + + + +/*****************************************************************************/ +static void suppression_piste_non_connectee(WinEDA_PcbFrame * frame, wxDC * DC) +/*****************************************************************************/ +/* + Supprime les segments de piste ayant 1 ou 2 extremites non connectees + Cas des vias: + si une extremite de segment est connectee uniquement a une via, la via + et le segment seront supprimes +*/ +{ +TRACK * PtSegm, * pt_other, * pt_via; +TRACK * PtStartNetCode; +EDA_BaseStruct * NextS; +D_PAD * ptr_pad; +int nbpoints_supprimes = 0; +int masklayer, oldnetcode; +int type_end,flag_erase; +int ii, percent, oldpercent; +wxString msg; + + frame->Affiche_Message( _("Delete unconnected tracks:") ); + frame->DrawPanel->m_AbortRequest = FALSE; + + /* Correction des defauts des vias et recalcul du nombre de segm */ + frame->m_Pcb->m_NbSegmTrack = 0; ii = 0; + for(PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*)NextS) + { + frame->m_Pcb->m_NbSegmTrack++; + NextS = PtSegm->Pnext; + if(PtSegm->m_StructType == TYPEVIA) + { + if( (PtSegm->m_Start.x != PtSegm->m_End.x ) || (PtSegm->m_Start.y != PtSegm->m_End.y ) ) + { + PtSegm->m_End.x = PtSegm->m_Start.x; + PtSegm->m_End.y = PtSegm->m_Start.y; + ii++; + msg.Printf( wxT("%d "), ii); + Affiche_1_Parametre(frame, POS_AFF_PASSE,_("ViaDef"),msg,LIGHTRED); + } + continue; + } + } + + /* Suppression des pistes en l'air */ + PtSegm = frame->m_Pcb->m_Track; ii = 0; + percent = 0; oldpercent = -1; + oldnetcode = 0; PtStartNetCode = frame->m_Pcb->m_Track; + for( ; PtSegm != NULL; PtSegm = (TRACK*) NextS, ii++) + { + NextS = PtSegm->Pnext; + /* Affiche activite */ + percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; + if( percent != oldpercent) + { + oldpercent = percent; + frame->DisplayActivity(percent, wxT("No Conn: ") ); + + msg.Printf( wxT("%d "), frame->m_Pcb->m_NbSegmTrack ); + Affiche_1_Parametre(frame,POS_AFF_MAX, wxT("Max"), msg,GREEN); + msg.Printf( wxT("%d "),ii ); + Affiche_1_Parametre(frame,POS_AFF_NUMSEGM, wxT("Segm"), msg,CYAN); + } + + if( frame->DrawPanel->m_AbortRequest ) break; + + if( PtSegm->m_NetCode != oldnetcode) + { + PtStartNetCode = PtSegm; oldnetcode = PtSegm->m_NetCode; + } + + flag_erase = 0; type_end = 0; + /* y a t-il une pastille sur chaque extremite */ + + masklayer = PtSegm->ReturnMaskLayer(); + + ptr_pad = Fast_Locate_Pad_Connecte(frame->m_Pcb, PtSegm->m_Start, masklayer); + + if( ptr_pad != NULL) + { + PtSegm->start = ptr_pad; + type_end |= START_SUR_PAD; + } + + ptr_pad = Fast_Locate_Pad_Connecte(frame->m_Pcb, PtSegm->m_End, masklayer); + + if( ptr_pad != NULL) + { + PtSegm->end = ptr_pad; + type_end |= END_SUR_PAD; + } + + /* Test si une extremite est connectee sur une piste */ + if ( (type_end & START_SUR_PAD ) == 0 ) + { + pt_other = Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, + NULL, START); + + if(pt_other == NULL) flag_erase |= 1; + + else /* Segment ou via connectee a cette extremite */ + { + PtSegm->start = pt_other; + if(pt_other->m_StructType == TYPEVIA) /* recherche d'un autre segment */ + { + PtSegm->SetState(BUSY,ON); + pt_via = pt_other; + pt_other = Locate_Piste_Connectee(pt_via,frame->m_Pcb->m_Track, + NULL,START); + if(pt_other == NULL) flag_erase |= 2; + PtSegm->SetState(BUSY,OFF); + } + } + } + + if ( (type_end & END_SUR_PAD ) == 0 ) + { + pt_other = Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, + NULL, END); + if(pt_other == NULL) flag_erase |= 0x10; + else /* Segment ou via connectee a cette extremite */ + { + PtSegm->end = pt_other; + if(pt_other->m_StructType == TYPEVIA) /* recherche d'un autre segment */ + { + PtSegm->SetState(BUSY,ON); + pt_via = pt_other; + + pt_other = Locate_Piste_Connectee(pt_via,frame->m_Pcb->m_Track, + NULL, END); + if(pt_other == NULL) flag_erase |= 0x20; + PtSegm->SetState(BUSY,OFF); + } + } + } + + if(flag_erase) + { + oldpercent = -1; /* force affichage activite */ + nbpoints_supprimes++; ii--; + msg.Printf( wxT("%d "),nbpoints_supprimes); + Affiche_1_Parametre(frame,POS_AFF_VAR, wxT("NoConn."), msg,LIGHTRED); + + /* rectification du pointeur PtSegm pour repartir en debut + du block des segments de meme net_code */ + if( PtSegm == PtStartNetCode ) + { + NextS = PtSegm->Pnext; + PtStartNetCode = (TRACK*)NextS; + } + else NextS = PtStartNetCode; + + /* Suppression du segment */ + PtSegm->Draw(frame->DrawPanel, DC, GR_XOR); + DeleteStructure(PtSegm); + if ( NextS == NULL ) break; + } + } +} + + + +/************************************************************/ +static int clean_segments(WinEDA_PcbFrame * frame, wxDC * DC) +/************************************************************/ +/* Supprime segments nulls, points inutiles .. */ +{ +TRACK * PtSegm, * pt_aux; +EDA_BaseStruct * NextS; +int ii, nbpoints_supprimes = 0; +int flag, no_inc, percent, oldpercent; +wxString msg; + + frame->DrawPanel->m_AbortRequest = FALSE; + + /**********************************************/ + /* suppression des segments de longueur nulle */ + /**********************************************/ + + a_color = GREEN; + nbpoints_supprimes = 0; PtSegm = frame->m_Pcb->m_Track; + percent = 0; oldpercent = -1; + frame->MsgPanel->EraseMsgBox(); + frame->Affiche_Message( _("Clean Null Segments") ); + + Affiche_1_Parametre(frame,POS_AFF_VAR, wxT("NullSeg"), wxT("0"),a_color); + for(PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*)NextS ) + { + NextS = PtSegm->Pnext; + if( ! PtSegm->IsNull() ) continue; + + /* Lenght segment = 0; delete it */ + PtSegm->Draw(frame->DrawPanel, DC, GR_XOR); + DeleteStructure(PtSegm); + nbpoints_supprimes++; + + msg.Printf( wxT(" %d"),nbpoints_supprimes); + Affiche_1_Parametre(frame,POS_AFF_VAR,wxEmptyString, msg,a_color); + } + + /**************************************/ + /* suppression des segments confondus */ + /**************************************/ + + Affiche_1_Parametre(frame,POS_AFF_VAR, wxT("Ident"), wxT("0"),a_color); + percent = 0; oldpercent = -1; + PtSegm = frame->m_Pcb->m_Track; + for( ii = 0; PtSegm != NULL; PtSegm = (TRACK*) PtSegm->Pnext , ii++) + { + /* affichage activite */ + percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; + if( percent != oldpercent) + { + frame->DisplayActivity(percent, wxT("Id segm: ") ); + oldpercent = percent; + + msg.Printf( wxT("%d"), frame->m_Pcb->m_NbSegmTrack); + Affiche_1_Parametre(frame,POS_AFF_MAX, wxT("Max"), msg,GREEN); + msg.Printf( wxT("%d"), ii ); + Affiche_1_Parametre(frame,POS_AFF_NUMSEGM, wxT("Segm"), msg,CYAN); + + if( frame->DrawPanel->m_AbortRequest ) return(-1); + } + + for( pt_aux = (TRACK*)PtSegm->Pnext; pt_aux != NULL; pt_aux = (TRACK*)NextS ) + { + int erase = 0; + NextS = pt_aux->Pnext; + + if( PtSegm->m_StructType != pt_aux->m_StructType ) continue; + if( PtSegm->m_Layer != pt_aux->m_Layer ) continue; + if( PtSegm->m_NetCode != pt_aux->m_NetCode ) break; + + if( (PtSegm->m_Start.x == pt_aux->m_Start.x ) && (PtSegm->m_Start.y == pt_aux->m_Start.y) ) + { + if( (PtSegm->m_End.x == pt_aux->m_End.x ) && (PtSegm->m_End.y==pt_aux->m_End.y) ) + erase = 1; + } + + if( (PtSegm->m_Start.x==pt_aux->m_End.x ) && (PtSegm->m_Start.y == pt_aux->m_End.y) ) + { + if( (PtSegm->m_End.x==pt_aux->m_Start.x ) && (PtSegm->m_End.y==pt_aux->m_Start.y) ) + erase = 1; + } + + /* suppression du point en trop */ + if( erase ) + { + ii--; + pt_aux->Draw(frame->DrawPanel, DC, GR_OR); + DeleteStructure(pt_aux); + nbpoints_supprimes++; + + msg.Printf( wxT(" %d"),nbpoints_supprimes); + Affiche_1_Parametre(frame,50, wxEmptyString, msg,a_color); + } + } + } + + /**************************************************************/ + /* suppression des points intermediaires ( segments alignes ) */ + /**************************************************************/ + + PtSegm = frame->m_Pcb->m_Track; nbpoints_supprimes = 0; + percent = 0; oldpercent = -1; + frame->Affiche_Message( _("Merging Segments:") ); + + Affiche_1_Parametre(frame,POS_AFF_VAR, _("Merge"), _("0"),a_color); + + ii = 0; + for( PtSegm = frame->m_Pcb->m_Track; PtSegm!= NULL; PtSegm = (TRACK*) NextS) + { + TRACK * pt_segm_s, * pt_segm_e, *pt_segm_delete; + + NextS = PtSegm->Pnext; + /* affichage activite */ + ii++; + percent = (100 * ii)/ frame->m_Pcb->m_NbSegmTrack; + if( percent != oldpercent) + { + frame->DisplayActivity(percent, _("Merge: ") ); + oldpercent = percent; + msg.Printf( wxT("%d"), frame->m_Pcb->m_NbSegmTrack); + Affiche_1_Parametre(frame, POS_AFF_MAX, wxT("Max"), msg,GREEN); + msg.Printf( wxT("%d"), ii ); + Affiche_1_Parametre(frame, POS_AFF_NUMSEGM, wxT("Segm"), msg,CYAN); + + if( frame->DrawPanel->m_AbortRequest ) return(-1); + } + + if(PtSegm->m_StructType != TYPETRACK) continue; + + flag = no_inc = 0; + + /* Recherche d'un point possible raccorde sur DEBUT de segment: */ + for( pt_segm_s = (TRACK*)PtSegm->Pnext; ; ) + { + pt_segm_s = Locate_Piste_Connectee(PtSegm, pt_segm_s, + NULL, START); + if(pt_segm_s) + { + /* les 2 segments doivent avoir meme largeur */ + if(PtSegm->m_Width != pt_segm_s->m_Width ) break; + /* Ce ne peut etre une via */ + if(pt_segm_s->m_StructType != TYPETRACK) break; + + /* On ne peut avoir que 1 seul segment connecte */ + pt_segm_s->SetState(BUSY,ON); + pt_aux = Locate_Piste_Connectee(PtSegm, frame->m_Pcb->m_Track, + NULL,START); + pt_segm_s->SetState(BUSY,OFF); + + if(pt_aux == NULL) flag = 1; /* OK */ + break; + } + break; + } + + if(flag) /* debut de segment raccorde a un autre segment */ + { + pt_segm_delete = AlignSegment(frame->m_Pcb, PtSegm,pt_segm_s,START); + if ( pt_segm_delete ) + { + nbpoints_supprimes++; no_inc = 1; + DeleteStructure(pt_segm_delete); + } + } + + /* Recherche d'un point possible raccorde sur FIN de segment: */ + for( pt_segm_e = (TRACK*)PtSegm->Pnext; ; ) + { + pt_segm_e = Locate_Piste_Connectee(PtSegm, pt_segm_e, + NULL, END); + if(pt_segm_e) + { + /* les 2 segments doivent avoir meme largeur */ + if(PtSegm->m_Width != pt_segm_e->m_Width ) break; + /* Ce ne peut etre une via */ + if(pt_segm_e->m_StructType != TYPETRACK) break; + + /* On ne peut avoir que 1 seul segment connecte */ + pt_segm_e->SetState(BUSY,ON); + pt_aux = Locate_Piste_Connectee(PtSegm, frame->m_Pcb->m_Track, + NULL,END) ; + pt_segm_e->SetState(BUSY,OFF); + if (pt_aux == NULL) flag |= 2;/* Ok */ + break; + } + else break; + } + + if(flag & 2) /* FIN de segment raccorde a un autre segment */ + { + pt_segm_delete = AlignSegment(frame->m_Pcb, PtSegm,pt_segm_e,END); + if ( pt_segm_delete ) + { + nbpoints_supprimes++; no_inc = 1; + DeleteStructure(pt_segm_delete); + } + } + + if(no_inc) /* Le segment en cours a ete modifie, il faut le reexaminer */ + { + msg.Printf( wxT("%d "),nbpoints_supprimes); + Affiche_1_Parametre(frame,POS_AFF_VAR,wxEmptyString, msg,a_color); + NextS = PtSegm->Pnext; + } + } + return (0) ; +} + +/****************************************************************************/ +static TRACK * AlignSegment(BOARD * Pcb, TRACK * pt_ref, TRACK * pt_segm, int extremite) +/****************************************************************************/ +/* Routine utilisee par clean_segments. + Verifie l'alignement de pt_segm / pt_ref. et verifie que le point commun + a faire disparaitre n'est pas sur un pad. + l'extremite testee est debut (extremite == START) ou fin (extremite == FIN) + si il y a alignement, modifie les coord d'extremite de pt_ref et retourne + pt_segm. + sinon retourne NULL +*/ +{ +int refdx,refdy, segmdx, segmdy; /* projections des segments */ +int flag = 0; + + refdx = pt_ref->m_End.x - pt_ref->m_Start.x; refdy = pt_ref->m_End.y - pt_ref->m_Start.y; + segmdx = pt_segm->m_End.x - pt_segm->m_Start.x; segmdy = pt_segm->m_End.y - pt_segm->m_Start.y; + + /* Tst alignement vertical possible: */ + if(refdx == 0) + { + if (segmdx != 0) return(NULL); + else flag = 1; + } + /* Tst alignement horizontal possible: */ + if(refdy == 0) + { + if (segmdy != 0) return(NULL); + else flag = 2; + } + + /* tst si il y a alignement d'angle qcq + il faut que refdy/refdx == (+/-)segmdy/segmdx, c.a.d meme direction */ + if (flag == 0) + { + if( (refdy * segmdx != refdx * segmdy) && + (refdy * segmdx != -refdx * segmdy) ) return(NULL); + flag = 4; + } + + /* Ici il y a alignement: il faut determiner les positions relatives + pour supprimer le point commun et le remplacer */ + if (extremite == START) + { + /* Ce ne doit pas etre sur un pad */ + if(Fast_Locate_Pad_Connecte(Pcb, pt_ref->m_Start, + g_TabOneLayerMask[pt_ref->m_Layer])) + return(NULL); + + if( (pt_ref->m_Start.x == pt_segm->m_Start.x) && (pt_ref->m_Start.y == pt_segm->m_Start.y) ) + { + pt_ref->m_Start.x = pt_segm->m_End.x; pt_ref->m_Start.y = pt_segm->m_End.y; + return(pt_segm); + } + else /* connexion par la fin de pt_segm */ + { + pt_ref->m_Start.x = pt_segm->m_Start.x; pt_ref->m_Start.y = pt_segm->m_Start.y; + return(pt_segm); + } + } + else /* extremite == END */ + { + /* Ce ne doit pas etre sur un pad */ + if(Fast_Locate_Pad_Connecte(Pcb, pt_ref->m_End, g_TabOneLayerMask[pt_ref->m_Layer])) + return(NULL); + + if( pt_ref->m_End == pt_segm->m_Start ) + { + pt_ref->m_End = pt_segm->m_End; + return(pt_segm); + } + else /* connexion par la fin de pt_segm */ + { + pt_ref->m_End = pt_segm->m_Start; + return(pt_segm); + } + } + return(NULL); +} + + + /**********************************************/ + /* Netliste Controle: Controle des connexions */ + /**********************************************/ +/* + verification des connexions. + Supprime les segments mal connectes, c.a.d. interconnectant des segments + de net_code differents +*/ +int Netliste_Controle_piste(WinEDA_PcbFrame * frame, wxDC * DC, int affiche) +{ +TRACK * PtSegm, * pt_aux; +EDA_BaseStruct * NextS; +int net_code_s, net_code_e; +int nbpoints_modifies = 0; +int flag = 0; +int ii, percent, oldpercent; +wxString msg; + + a_color = RED; + percent = 0; oldpercent = -1; + + frame->Affiche_Message( _("DRC Control:") ); + + frame->DrawPanel->m_AbortRequest = FALSE; + + if(affiche) Affiche_1_Parametre(frame,POS_AFF_VAR, _("NetCtr"), wxT("0 "),a_color); + + ii = 0; + for(PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*)PtSegm->Pnext) + { + /* affichage activite */ + ii++; + percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; + if( percent != oldpercent) + { + frame->DisplayActivity(percent, wxT("Drc: ") ); + oldpercent = percent; + msg.Printf( wxT("%d"), frame->m_Pcb->m_NbSegmTrack); + Affiche_1_Parametre(frame, POS_AFF_MAX, wxT("Max"),msg,GREEN); + msg.Printf( wxT("%d"), frame->m_Pcb->m_NbSegmTrack); + Affiche_1_Parametre(frame, POS_AFF_NUMSEGM, wxT("Segm"),msg,CYAN); + + if( frame->DrawPanel->m_AbortRequest ) return(flag); + } + + PtSegm->SetState(FLAG0,OFF); + + /* Calcul du net_code des elements raccordes sur le point de debut */ + net_code_s = -1; + if( (PtSegm->start != NULL) && + ( ((EDA_BaseStruct*)(PtSegm->start))->m_StructType == TYPEPAD) ) + net_code_s = ((D_PAD*)(PtSegm->start))->m_NetCode; + + else + { + pt_aux = Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, + NULL, START); + if(pt_aux) net_code_s = pt_aux->m_NetCode; + } + if(net_code_s < 0 ) continue ; /* Extremite en l'air */ + + /* Calcul du net_code des elements raccordes sur le point de fin */ + net_code_e = -1; + if( (PtSegm->end != NULL) && + ( ((EDA_BaseStruct*)(PtSegm->end))->m_StructType == TYPEPAD) ) + net_code_e = ((D_PAD*)(PtSegm->end))->m_NetCode; + + else + { + pt_aux = Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, + NULL,END); + if(pt_aux) net_code_e = pt_aux->m_NetCode; + } + + if(net_code_e < 0 ) continue ; /* Extremite en l'air */ + + /* Marquage des segments a supprimer */ + if(net_code_s != net_code_e) + { + PtSegm->SetState(FLAG0,ON); + } + } + + /* Suppression effective des segments */ + + for(PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) NextS) + { + NextS = PtSegm->Pnext; + if( PtSegm->GetState(FLAG0) ) /* Connexion erronee : a supprimer */ + { + PtSegm->SetState(FLAG0,OFF); + flag = 1; oldpercent = -1; + frame->m_Pcb->m_Status_Pcb = 0; + frame->Supprime_Une_Piste( DC, PtSegm); + NextS = frame->m_Pcb->m_Track; /* NextS a peut etre ete efface */ + if(affiche) + { + nbpoints_modifies++; + msg.Printf( wxT("%d "),nbpoints_modifies); + Affiche_1_Parametre(frame,POS_AFF_VAR,wxEmptyString,msg,a_color); + } + } + } + return(flag); +} + + +#if 0 + +/***************************************************************/ +static void Gen_Raccord_Track(WinEDA_PcbFrame * frame, wxDC * DC) +/***************************************************************/ + +/* Teste les extremites de segments : + si une extremite est sur un segment de piste, mais pas sur une extremite, + le segment est coupe en 2, le point de coupure etant l'extremite du segment + Ceci est fait pour que les tests de connexion qui ne testent que les extremites + de segments voient la connexion +*/ +{ +TRACK * PtSegm, *pt_aux, * NewTrack; +EDA_BaseStruct * NextS; +int nn = 0; +int masquelayer; +int ii, percent, oldpercent; +wxString msg; + + frame->Affiche_Message( wxT("Gen Raccords sur Pistes:") ); + if( frame->m_Pcb->GetNumSegmTrack() == 0 ) return; + + frame->DrawPanel->m_AbortRequest = FALSE; + + oldpercent = -1; ii = 0; + for( PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) NextS) + { + NextS = PtSegm->Pnext; + /* affichage activite */ + ii++; + percent = (100 * ii)/ frame->m_Pcb->m_NbSegmTrack; + if( percent != oldpercent) + { + frame->DisplayActivity(percent, wxT("Tracks: ") ); + oldpercent = percent; + msg.Printf( wxT("%d"),frame->m_Pcb->m_NbSegmTrack ); + Affiche_1_Parametre(frame,POS_AFF_MAX, wxT("Max"),msg,GREEN); + msg.Printf( wxT("%d"), ii); + Affiche_1_Parametre(frame,POS_AFF_NUMSEGM, wxT("Segm"),msg,CYAN); + } + + if( frame->DrawPanel->m_AbortRequest ) return; + + masquelayer = PtSegm->ReturnMaskLayer(); + + /* examen du point de depart du segment de reference */ + for(pt_aux = frame->m_Pcb->m_Track; ; pt_aux = (TRACK*) pt_aux->Pnext) + { + if (pt_aux == NULL) break; + pt_aux = Locate_Pistes(pt_aux, PtSegm->m_Start, masquelayer); + if (pt_aux == NULL) break; + if(pt_aux == PtSegm) continue; + if(pt_aux->m_StructType == TYPEVIA) continue; + if( PtSegm->m_Start == pt_aux->m_Start ) continue; + if( PtSegm->m_Start == pt_aux->m_End ) continue; + + // Test si autre extremite du segment ne serait pas deja connectee + if( PtSegm->m_End == pt_aux->m_Start ) continue; + if( PtSegm->m_End == pt_aux->m_End ) continue; + + pt_aux->Draw(frame->DrawPanel, DC, GR_XOR); + NewTrack = pt_aux->Copy(); + NewTrack->Insert(frame->m_Pcb, pt_aux); + nn++; + frame->m_Pcb->m_NbSegmTrack++; + msg.Printf( wxT("%d"),nn); + Affiche_1_Parametre(frame,POS_AFF_VAR, wxT("New <"),msg,YELLOW); + pt_aux->m_End = PtSegm->m_Start; + NewTrack->m_Start = PtSegm->m_Start; + Trace_Une_Piste(frame->DrawPanel, DC, pt_aux, 2, GR_OR); + pt_aux = NewTrack; + } + + /* examen du point de fin du segment de reference */ + for(pt_aux = frame->m_Pcb->m_Track; pt_aux != NULL; pt_aux = (TRACK*) pt_aux->Pnext) + { + pt_aux = Locate_Pistes(pt_aux, PtSegm->m_End, masquelayer); + if(pt_aux == NULL) break; + if(pt_aux == PtSegm) continue; + if(pt_aux->m_StructType == TYPEVIA) continue; + + if( (PtSegm->m_End.x == pt_aux->m_Start.x) && (PtSegm->m_End.y == pt_aux->m_Start.y)) continue; + if( (PtSegm->m_End.x == pt_aux->m_End.x) && (PtSegm->m_End.y == pt_aux->m_End.y)) continue; + + if( (PtSegm->m_Start.x == pt_aux->m_Start.x) && (PtSegm->m_Start.y == pt_aux->m_Start.y)) continue; + if( (PtSegm->m_Start.x == pt_aux->m_End.x) && (PtSegm->m_Start.y == pt_aux->m_End.y)) continue; + + pt_aux->Draw(frame->DrawPanel, DC, GR_XOR); + + NewTrack = pt_aux->Copy(); + NewTrack->Insert(frame->m_Pcb, pt_aux); + + frame->m_Pcb->m_NbSegmTrack++; + nn++; msg.Printf( wxT("%d"),nn); + Affiche_1_Parametre(frame,POS_AFF_VAR, wxT("New >"),msg,YELLOW); + pt_aux->m_End.x = PtSegm->m_End.x; pt_aux->m_End.y = PtSegm->m_End.y; + NewTrack->m_Start.x = PtSegm->m_End.x; NewTrack->m_Start.y = PtSegm->m_End.y; + Trace_Une_Piste(frame->DrawPanel, DC, pt_aux,2,GR_OR); + pt_aux = NewTrack; + } + } +} + +/*****************************************************/ +void raccord_track_a_centre(WinEDA_PcbFrame * frame) +/****************************************************/ +/* + rajoute eventuellement un segment a une extremite de piste connectee + a un pad si cette extremite n'est pas exactement connectee au centre + du pad. + Ceci permet un controle plus rapide des connexions +*/ +{ +TRACK * PtSegm; +EDA_BaseStruct * NextS; +D_PAD * ptr_pad; +int nb_new_piste = 0 , ii; +int percent, oldpercent; +wxString msg; + + a_color = GREEN; + percent = 0; oldpercent = -1; + + frame->DrawPanel->m_AbortRequest = FALSE; + + Affiche_1_Parametre(frame, POS_AFF_VAR, wxT("Centre"), wxT("0 "),a_color); + + ii = 0; + for(PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*)NextS) + { + NextS = PtSegm->Pnext; + /* affichage activite */ + ii++; + percent = (100 * ii)/ frame->m_Pcb->m_NbSegmTrack; + if( percent != oldpercent) + { + frame->DisplayActivity(percent, _("Pads: ")); + oldpercent = percent; + msg.Printf( wxT("%d"), frame->m_Pcb->m_NbSegmTrack ); + Affiche_1_Parametre(frame, POS_AFF_MAX, wxT("Max"),msg,GREEN); + msg.Printf( wxT("%d"), ii); + Affiche_1_Parametre(frame, POS_AFF_NUMSEGM, wxT("Segm"),msg,CYAN); + + if( frame->DrawPanel->m_AbortRequest ) return; + } + + ptr_pad = Locate_Pad_Connecte(frame->m_Pcb, PtSegm,START); + if( ptr_pad != NULL ) + { /* Test si point piste non deja connecte a un autre segment */ + if( (PtSegm->m_Start.x != ptr_pad->m_Pos.x) || + (PtSegm->m_Start.y != ptr_pad->m_Pos.y) ) + { + if(Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, + NULL, START) == NULL) + { + TRACK * NewTrack = PtSegm->Copy(); + NewTrack->Insert(frame->m_Pcb, PtSegm); + NewTrack->m_End.x = ptr_pad->m_Pos.x; + NewTrack->m_End.y = ptr_pad->m_Pos.y; + NewTrack->start = PtSegm; + NewTrack->end = ptr_pad; + nb_new_piste++; + + Affiche_1_Parametre(frame,POS_AFF_VAR,wxEmptyString,msg,a_color); + } + } + } + + ptr_pad = Locate_Pad_Connecte(frame->m_Pcb, PtSegm,END); + if( ptr_pad != NULL ) + { /* Test si point piste "en l'air" */ + if( (PtSegm->m_End.x != ptr_pad->m_Pos.x) || + (PtSegm->m_End.y != ptr_pad->m_Pos.y) ) + { + if(Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, + NULL,END) == NULL) + { + TRACK * NewTrack = PtSegm->Copy(); + NewTrack->Insert(frame->m_Pcb, PtSegm); + NewTrack->m_Start.x = ptr_pad->m_Pos.x; + NewTrack->m_Start.y = ptr_pad->m_Pos.y; + NewTrack->start = ptr_pad; + NewTrack->end = PtSegm; + nb_new_piste++; + + msg.Printf( wxT("e %d"),nb_new_piste); + Affiche_1_Parametre(frame, POS_AFF_VAR,wxEmptyString,msg,a_color); + } + } + } + } +} + +#endif diff --git a/pcbnew/connect.cpp b/pcbnew/connect.cpp new file mode 100644 index 0000000000..d9d3add886 --- /dev/null +++ b/pcbnew/connect.cpp @@ -0,0 +1,757 @@ + /*************************************************************/ + /******************* editeur de PCB **************************/ + /* traitement du Chevelu: routines de calcul des connexions */ + /*************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "protos.h" + + +/* variables locales */ + +/* routines exportees */ +void Recalcule_all_net_connexion(wxDC * DC); + +/* Routines locales */ +static void propage_equipot(TRACK* pt_start_conn,TRACK* pt_end_conn) ; +static void calcule_connexite_1_net(TRACK* pt_start_conn,TRACK* pt_end_conn); +static void RebuildTrackChain(BOARD * pcb); +static int tri_par_netcode(TRACK ** pt_ref, TRACK ** pt_compare); + +/*..*/ + + +/*****************************************************************/ +static int change_equipot(TRACK* pt_start_conn,TRACK* pt_end_conn, + int old_val, int new_val) +/*****************************************************************/ +/* + Change les num locaux d'equipot old valeur en new valeur + retourne le nombre de changements + si pt_end_conn = NULL: recherche jusqu'a fin de chaine +*/ +{ +TRACK * pt_conn; +int nb_change = 0 ; +D_PAD * pt_pad; + + if( old_val == new_val) return(0) ; + + if(old_val < new_val) EXCHG(old_val,new_val) ; + + pt_conn = pt_start_conn; + for ( ; pt_conn != NULL; pt_conn= (TRACK*) pt_conn->Pnext) + { + if( pt_conn->m_Sous_Netcode != old_val) + { + if(pt_conn == pt_end_conn) break; + continue; + } + + nb_change++; + pt_conn->m_Sous_Netcode = new_val ; + + if( pt_conn->start && ( pt_conn->start->m_StructType == TYPEPAD) ) + { + pt_pad = (D_PAD*)(pt_conn->start); + if(pt_pad->m_physical_connexion == old_val) + pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; + } + + if( pt_conn->end && (pt_conn->end->m_StructType == TYPEPAD) ) + { + pt_pad = (D_PAD*)(pt_conn->end); + if(pt_pad->m_physical_connexion == old_val) + pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; + } + if(pt_conn == pt_end_conn) break; + } + return(nb_change); +} + +/******************************************************************/ +static void propage_equipot(TRACK* pt_start_conn,TRACK* pt_end_conn) +/******************************************************************/ +/* balaye la liste des SEGMENTS de PISTE + - debut = pt_start_conn + - fin = pt_end_conn (pointe le dernier segment a analyser) + pour attribuer ou propager un numero d'equipotentielle par + blocs de connexions existantes + la zone balayee est supposee appartenir au meme net, c'est a dire que + les segments de pistes sont tries par net_code +*/ +{ +TRACK * pt_conn; +int sous_net_code ; +D_PAD * pt_pad; +TRACK * pt_autre_piste; +EDA_BaseStruct * PtStruct; + + /* Initialisations prealables */ + pt_conn = pt_start_conn; + for ( ; pt_conn != NULL; pt_conn= (TRACK*) pt_conn->Pnext) + { + pt_conn->m_Sous_Netcode = 0; + PtStruct = pt_conn->start; + if( PtStruct && (PtStruct->m_StructType == TYPEPAD) ) + ((D_PAD*)PtStruct)->m_physical_connexion = 0; + + PtStruct = pt_conn->end; + if( PtStruct && (PtStruct->m_StructType == TYPEPAD) ) + ((D_PAD*)PtStruct)->m_physical_connexion = 0; + + if (pt_conn == pt_end_conn) break; + } + sous_net_code = 1 ; pt_start_conn->m_Sous_Netcode = sous_net_code; + + /* debut du calcul de propagation */ + pt_conn = pt_start_conn; + for ( ; pt_conn != NULL; pt_conn= (TRACK*) pt_conn->Pnext) + { + /* Traitement des connexions a pads */ + PtStruct = pt_conn->start; + if( PtStruct && (PtStruct->m_StructType == TYPEPAD) ) + /* la connexion debute sur 1 pad */ + { + pt_pad = (D_PAD*) PtStruct; + if( pt_conn->m_Sous_Netcode) /* la connexion fait deja partie d'une chaine */ + { + if(pt_pad->m_physical_connexion > 0) /* le pad fait aussi partie d'une chaine */ + { + change_equipot(pt_start_conn,pt_end_conn, + pt_pad->m_physical_connexion,pt_conn->m_Sous_Netcode); + } + else pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; + } + else /* la connexion ne fait pas partie encore d'une chaine */ + { + if(pt_pad->m_physical_connexion > 0) + { + pt_conn->m_Sous_Netcode = pt_pad->m_physical_connexion; + } + else + { + sous_net_code++ ; pt_conn->m_Sous_Netcode = sous_net_code; + pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; + } + } + } + + PtStruct = pt_conn->end; + if( PtStruct && (PtStruct->m_StructType == TYPEPAD) ) + /* la connexion finit sur 1 pad */ + { + pt_pad = (D_PAD*)PtStruct; + if( pt_conn->m_Sous_Netcode) + { + if(pt_pad->m_physical_connexion > 0) + { + change_equipot(pt_start_conn,pt_end_conn, + pt_pad->m_physical_connexion,pt_conn->m_Sous_Netcode); + } + else pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; + } + else + { + if(pt_pad->m_physical_connexion > 0) + { + pt_conn->m_Sous_Netcode = pt_pad->m_physical_connexion; + } + else + { + sous_net_code++ ; pt_conn->m_Sous_Netcode = sous_net_code; + pt_pad->m_physical_connexion = pt_conn->m_Sous_Netcode; + } + } + } + + + /* traitement des connexions entre segments */ + PtStruct = pt_conn->start; + if( PtStruct && (PtStruct->m_StructType != TYPEPAD) ) + { /* debut sur une autre piste */ + pt_autre_piste = (TRACK*)PtStruct; + + if(pt_conn->m_Sous_Netcode) /* La connexion fait deja partie d'un block */ + { + if(pt_autre_piste->m_Sous_Netcode) + { + change_equipot(pt_start_conn,pt_end_conn, + pt_autre_piste->m_Sous_Netcode,pt_conn->m_Sous_Netcode); + } + else + { + pt_autre_piste->m_Sous_Netcode = pt_conn->m_Sous_Netcode; + } + } + + else /* La connexion ne fait partie d'aucun block */ + { + if(pt_autre_piste->m_Sous_Netcode) + { + pt_conn->m_Sous_Netcode = pt_autre_piste->m_Sous_Netcode; + } + else + { + sous_net_code++ ; pt_conn->m_Sous_Netcode = sous_net_code; + pt_autre_piste->m_Sous_Netcode = pt_conn->m_Sous_Netcode; + } + } + } + + PtStruct = pt_conn->end; + if( PtStruct && (PtStruct->m_StructType != TYPEPAD) ) + { /* fin connectee a une autre piste */ + pt_autre_piste = (TRACK*) PtStruct; + if(pt_conn->m_Sous_Netcode) /* La connexion fait deja partie d'un block */ + { + if(pt_autre_piste->m_Sous_Netcode) + { + change_equipot(pt_start_conn,pt_end_conn, + pt_autre_piste->m_Sous_Netcode,pt_conn->m_Sous_Netcode); + } + else pt_autre_piste->m_Sous_Netcode = pt_conn->m_Sous_Netcode; + } + else /* La connexion ne fait partie d'aucun block */ + { + if(pt_autre_piste->m_Sous_Netcode) + { + pt_conn->m_Sous_Netcode = pt_autre_piste->m_Sous_Netcode; + } + else + { + sous_net_code++ ; pt_conn->m_Sous_Netcode = sous_net_code; + pt_autre_piste->m_Sous_Netcode = pt_conn->m_Sous_Netcode; + } + } + } + if (pt_conn == pt_end_conn) break; + } +} + +/***************************************************/ +void WinEDA_BasePcbFrame::test_connexions(wxDC * DC ) +/***************************************************/ +/* +Routine recherchant les connexions deja faites et mettant a jour +le status du chevelu ( Bit CH_ACTIF mis a 0 si connexion trouvee +Les pistes sont supposees etre triees par ordre de net_code croissant +*/ +{ +TRACK * pt_start_conn, * pt_end_conn; +int ii ; +LISTE_PAD * pt_pad; +int current_net_code; + + /* Etablissement des equipotentielles vraies */ + pt_pad = m_Pcb->m_Pads; + for( ii = 0; ii < m_Pcb->m_NbPads; ii++ , pt_pad++) + { + (*pt_pad)->m_physical_connexion = 0 ; + } + + //////////////////////////// + // Calcul de la connexite // + //////////////////////////// + + /* Les pointeurs .start et .end sont mis a jour, si la + connexion est du type segment a segment + */ + + pt_start_conn = m_Pcb->m_Track; + while(pt_start_conn != NULL) + { + current_net_code = pt_start_conn->m_NetCode; + pt_end_conn = pt_start_conn->GetEndNetCode(current_net_code); + + /* Calcul des connexions type segment du net courant */ + calcule_connexite_1_net(pt_start_conn, pt_end_conn); + + pt_start_conn = (TRACK*)pt_end_conn->Pnext; + } + + return; +} + +/**************************************************************/ +void WinEDA_BasePcbFrame::Recalcule_all_net_connexion(wxDC * DC) +/**************************************************************/ +/* + Routine Recalculant les pointeurs sur connexions types piste a piste + relatives a tous les nets. + Cette routine est utilisee apres reclassement des segments de piste par + ordre de net_code, puisque des pointeurs sur connexions deviennent faux + ( les pointeurs type pad restent bons ) +*/ +{ +TRACK * EndConn; +int net_code, net_code_max; + + if(m_Pcb->m_Track == NULL ) return; + + /* calcul du net_code max */ + EndConn = m_Pcb->m_Track; + while( EndConn->Pnext) EndConn = (TRACK*)EndConn->Pnext; + net_code_max = EndConn->m_NetCode; + + for ( net_code = 0; net_code <= net_code_max; net_code++ ) + { + test_1_net_connexion(DC, net_code); + } +} + +/*************************************************************************/ +void WinEDA_BasePcbFrame::test_1_net_connexion(wxDC * DC, int net_code) +/*************************************************************************/ +/* +Routine recherchant les connexions deja faites relatives a 1 net +*/ +{ +TRACK * pt_start_conn, * pt_end_conn; +int ii, nb_net_noconnect = 0; +LISTE_PAD * pt_pad; +wxString msg; + + if(net_code == 0) return; + + if ( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 ) + Compile_Ratsnest( DC, TRUE ); + + pt_pad = (LISTE_PAD*)m_Pcb->m_Pads; + for( ii = 0; ii < m_Pcb->m_NbPads; ii++ , pt_pad++) + { + int pad_net_code = (*pt_pad)->m_NetCode; + if(pad_net_code < net_code) continue; + if(pad_net_code > net_code) break; + (*pt_pad)->m_physical_connexion = 0 ; + } + + /* Determination des limites du net */ + if( m_Pcb->m_Track ) + { + pt_end_conn = NULL; + pt_start_conn = m_Pcb->m_Track->GetStartNetCode(net_code); + + if( pt_start_conn ) + pt_end_conn = pt_start_conn->GetEndNetCode(net_code); + + if( pt_start_conn && pt_end_conn ) // c.a.d. s'il y a des segments + { + calcule_connexite_1_net(pt_start_conn, pt_end_conn); + } + } + + /* Test des chevelus */ + nb_net_noconnect = Test_1_Net_Ratsnest(DC, net_code); + + /* Affichage des resultats */ + msg.Printf( wxT("links %d nc %d net:nc %d"), + m_Pcb->m_NbLinks, m_Pcb->GetNumNoconnect(), + nb_net_noconnect); + + Affiche_Message(msg); + return; +} + + + +/***************************************************************************/ +static void calcule_connexite_1_net(TRACK* pt_start_conn,TRACK* pt_end_conn) +/***************************************************************************/ +/* calcule la connexite d'un net constitue de segments de piste consecutifs. + Entree: + pt_start_conn = adresse du 1er segment ( debut du net ) + pt_end_conn = adr de fin (dernier segment) + Les connexions relatives aux pads doivent etre deja calculees, car elles + ne sont pas ici recalculees ( pour des raisons de temps de calcul, et + du fait que lors des modif de pistes, les pads ne sont pas touches +*/ +{ +TRACK * Track; + + /* Les pointeurs .start et .end sont mis a jour, si la + connexion est du type segment a segment. + la connexion sur pads est supposee etre deja calculee */ + + /* Raz des pointeurs sur pistes */ + for( Track = pt_start_conn; Track != NULL; Track = (TRACK*) Track->Pnext) + { + Track->m_Sous_Netcode = 0; + + if( Track->GetState(BEGIN_ONPAD) == 0 ) Track->start = NULL; + if( Track->GetState(END_ONPAD) == 0 ) Track->end = NULL; + + if (Track == pt_end_conn) break; + } + + /* calcul des connexions */ + for( Track = pt_start_conn; Track != NULL; Track = (TRACK*) Track->Pnext) + { + if(Track->m_StructType == TYPEVIA) + { + TRACK* pt_segm; + int layermask = Track->ReturnMaskLayer(); + for( pt_segm = pt_start_conn; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext) + { + int curlayermask = pt_segm->ReturnMaskLayer(); + if( !pt_segm->start && (pt_segm->m_Start == Track->m_Start) && + ( layermask & curlayermask ) ) + { + pt_segm->start = Track; + } + if( !pt_segm->end && (pt_segm->m_End == Track->m_Start) && + (layermask & curlayermask) ) + { + pt_segm->end = Track; + } + if( pt_segm == pt_end_conn ) break; + } + } + + if( Track->start == NULL ) + { + Track->start = Locate_Piste_Connectee(Track, Track,pt_end_conn,START); + } + + if( Track->end == NULL ) + { + Track->end = Locate_Piste_Connectee(Track, Track,pt_end_conn,END); + } + if (Track == pt_end_conn) break; + } + + /* Generation des sous equipots du net */ + propage_equipot(pt_start_conn,pt_end_conn); + +} + + + + /********************************************/ + /* Reattribution des net_codes de reference */ + /********************************************/ +/* + reattribution des net_codes aux segments de pistes. + Routine utilisee apres modification generale des noms de nets (apres + lecrure netliste ou edition de nets sur pads, effacement /ajout de + modules...) + + Elle se fait en 2 passes: + 1 - reattribution des segments commencant ( et/ou finissant ) sur 1 pad + les autres segments sont mis a reference NULLE + 2 - reattribution des segments restantes a ref NULLE +*/ + +#define POS_AFF_CHREF 62 +/* recherche le pad connecte a l'extremite de la piste de coord px, py + parametres d'appel: + px, py = coord du point tst + masque_layer = couche(s) de connexion + pt_liste = adresse de la liste des pointeurs de pads, tels que + apparaissant apres build_liste_pad, mais classee par position X + de pads croissantes. + retourne : pointeur sur le pad connecte + la routine travaille par dichotomie sur la liste des pads tries par pos X +croissante, elle est donc beaucoup plus rapide que Fast_Locate_Pad_connecte, +mais implique le calcul de cette liste. + +(la liste placee en m_Pcb->m_Pads et elle triee par netcodes croissants) +*/ + +static D_PAD * SuperFast_Locate_Pad_Connecte( BOARD * pcb, LISTE_PAD * pt_liste, + int px, int py, int masque_layer) +{ +D_PAD * pad ; +LISTE_PAD * ptr_pad , * lim; +int nb_pad = pcb->m_NbPads; +int ii; + lim = pt_liste + (pcb->m_NbPads - 1 ); + ptr_pad = pt_liste; + while(nb_pad) + { + pad = * ptr_pad; + ii = nb_pad; + nb_pad >>= 1; if( (ii & 1) && ( ii > 1 ) ) nb_pad++; + if( pad->m_Pos.x < px ) /* on doit chercher plus loin */ + { + ptr_pad += nb_pad; if(ptr_pad > lim) ptr_pad = lim; + continue; + } + if( pad->m_Pos.x > px ) /* on doit chercher moins loin */ + { + ptr_pad -= nb_pad; + if(ptr_pad < pt_liste) ptr_pad = pt_liste; + continue; + } + + if( pad->m_Pos.x == px ) /* zone de classement trouvee */ + { + /* recherche du debut de la zone */ + while( ptr_pad >= pt_liste) + { + pad = * ptr_pad; + if(pad->m_Pos.x == px) ptr_pad--; + else break; + } + ptr_pad++; /* pointe depart de zone a pad->m_Pos.x = px */ + + for( ; ; ptr_pad++ ) + { + if(ptr_pad > lim) return(NULL); /* hors zone */ + pad = *ptr_pad; + if( pad->m_Pos.x != px ) return(NULL); /* hors zone */ + if( pad->m_Pos.y != py ) continue ; + /* Pad peut-etre trouve ici: il doit etre sur la bonne couche */ + if (pad->m_Masque_Layer & masque_layer) return(pad) ; + } + } + } + return(NULL); +} + + +static int SortPadsByXCoord( void * pt_ref, void * pt_comp) +/* used to Sort a pad list by x coordinate value +*/ +{ +D_PAD * ref = *(LISTE_PAD*) pt_ref; +D_PAD * comp = *(LISTE_PAD*) pt_comp; + return( ref->m_Pos.x - comp->m_Pos.x ); +} + +/****************************************************/ +LISTE_PAD* CreateSortedPadListByXCoord(BOARD * pcb ) +/****************************************************/ +/* Create a sorted list of pointers to pads. + This list is sorted by X ccordinate value. + The list must be freed bu user +*/ +{ +LISTE_PAD* pad_list = (LISTE_PAD*) MyMalloc( pcb->m_NbPads * sizeof( D_PAD *) ); + memcpy(pad_list, pcb->m_Pads, pcb->m_NbPads* sizeof( D_PAD *) ); + qsort(pad_list, pcb->m_NbPads, sizeof( D_PAD *), + (int(*)(const void *, const void *)) SortPadsByXCoord); + return pad_list; +} + +/******************************************************************/ +void WinEDA_BasePcbFrame::reattribution_reference_piste(int affiche) +/******************************************************************/ +{ +TRACK * pt_piste, + * pt_next; +int a_color; +char new_passe_request = 1, flag; +LISTE_PAD * pt_mem; +EDA_BaseStruct * PtStruct; +int masque_layer; + + + if( m_Pcb->m_NbPads == 0 ) return; + a_color = CYAN; + if(affiche) + Affiche_1_Parametre(this, POS_AFF_CHREF, wxT("DataBase"), wxT("Netcodes"),a_color); + + recalcule_pad_net_code(); + + if(affiche) Affiche_1_Parametre(this, -1,wxEmptyString, wxT("Gen Pads "),a_color); + + ////////////////////////////////////////////////////// + // Connexion des pistes accrochees a 1 pad au moins // + ////////////////////////////////////////////////////// + pt_mem = CreateSortedPadListByXCoord(m_Pcb); + + if(affiche) + Affiche_1_Parametre(this, -1,wxEmptyString, wxT("Conn Pads"),a_color); + + /* Raz des flags particuliers des segments de piste */ + pt_piste = m_Pcb->m_Track; + for ( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext) + { + pt_piste->SetState(BUSY|EDIT|BEGIN_ONPAD|END_ONPAD, OFF); + pt_piste->m_NetCode = 0; + } + + pt_piste = m_Pcb->m_Track; + for ( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext) + { + flag = 0; + masque_layer = g_TabOneLayerMask[pt_piste->m_Layer]; + + /* y a t-il une pastille sur une extremite */ + pt_piste->start = SuperFast_Locate_Pad_Connecte(m_Pcb, pt_mem, + pt_piste->m_Start.x, pt_piste->m_Start.y, masque_layer); + if( pt_piste->start != NULL) + { + pt_piste->SetState( BEGIN_ONPAD, ON); + pt_piste->m_NetCode = ((D_PAD*)(pt_piste->start))->m_NetCode; + } + + pt_piste->end = SuperFast_Locate_Pad_Connecte(m_Pcb, pt_mem, + pt_piste->m_End.x, pt_piste->m_End.y, masque_layer); + + if( pt_piste->end != NULL) + { + pt_piste->SetState(END_ONPAD, ON); + pt_piste->m_NetCode = ((D_PAD*)(pt_piste->end))->m_NetCode; + } + + } + MyFree(pt_mem); + + //////////////////////////////////////////////////// + // Calcul de la connexite entre segments de piste // + //////////////////////////////////////////////////// + + /* Les pointeurs .start et .end sont mis a jour, s'ils etaient NULLs. + La connexion est alors du type segment a segment + */ + if(affiche) + Affiche_1_Parametre(this, POS_AFF_CHREF,wxEmptyString, wxT("Conn Segm"), a_color); + + for ( pt_piste = m_Pcb->m_Track; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext) + { + if ( pt_piste->start == NULL ) + { + pt_piste->start = Locate_Piste_Connectee(pt_piste, + m_Pcb->m_Track,NULL,START); + } + + if ( pt_piste->end == NULL ) + { + pt_piste->end = Locate_Piste_Connectee(pt_piste, + m_Pcb->m_Track,NULL,END); + } + } + + //////////////////////////////// + // Reattribution des net_code // + //////////////////////////////// + + a_color = YELLOW; + if(affiche) + Affiche_1_Parametre(this, POS_AFF_CHREF,wxEmptyString, wxT("Net->Segm"),a_color); + + while(new_passe_request) + { + new_passe_request = 0; + + for ( pt_piste = m_Pcb->m_Track; pt_piste != NULL; + pt_piste = (TRACK*) pt_piste->Pnext) + { + /* Traitement du point de debut */ + PtStruct = (EDA_BaseStruct*)pt_piste->start; + if( PtStruct && (PtStruct->m_StructType != TYPEPAD) ) + { // start sur piste + pt_next = (TRACK*)PtStruct; + if(pt_piste->m_NetCode) + { + if(pt_next->m_NetCode == 0) + { + new_passe_request = 1; + pt_next->m_NetCode = pt_piste->m_NetCode; + } + } + + else + { + if(pt_next->m_NetCode != 0) + { + pt_piste->m_NetCode = pt_next->m_NetCode; + new_passe_request = 1; + } + } + } + + /* Localisation du point de fin */ + PtStruct = pt_piste->end; + if( PtStruct &&(PtStruct->m_StructType != TYPEPAD) ) + { // End sur piste + pt_next = (TRACK*)PtStruct; + if(pt_piste->m_NetCode) + { + if(pt_next->m_NetCode == 0) + { + new_passe_request = 1; + pt_next->m_NetCode = pt_piste->m_NetCode; + } + } + else + { + if(pt_next->m_NetCode != 0) + { + pt_piste->m_NetCode = pt_next->m_NetCode; + new_passe_request = 1; + } + } + } + } + } + + if( affiche ) Affiche_1_Parametre(this, -1,wxEmptyString, wxT("Reorder "),a_color); + + /* Reclassemment des pistes par numero de net: */ + RebuildTrackChain(m_Pcb); + + if( affiche ) Affiche_1_Parametre(this, -1,wxEmptyString, wxT(" "),a_color); +} + +/* + routine de tri de connexion utilisee par la fonction QSORT + le tri est fait par numero de net +*/ +int tri_par_netcode(TRACK ** pt_ref, TRACK ** pt_compare) +{ +int ii ; + ii = (*pt_ref)->m_NetCode -(* pt_compare)->m_NetCode ; + return(ii) ; +} + + + +/*****************************************/ +static void RebuildTrackChain(BOARD * pcb) +/*****************************************/ +/* Recalcule le chainage des pistes pour que le chainage soit fait par + netcodes croissants +*/ +{ +TRACK * Track, ** Liste; +int ii, nbsegm; + + /* Count segments */ + nbsegm = pcb->GetNumSegmTrack(); + if( pcb->m_Track == NULL ) return; + + Liste = (TRACK ** ) MyZMalloc( (nbsegm+1) * sizeof(TRACK*) ); + + ii = 0; Track = pcb->m_Track; + for( ; Track != NULL; ii++, Track = (TRACK*) Track->Pnext) + { + Liste[ii] = Track; + } + + qsort(Liste, nbsegm, sizeof(TRACK*), + (int(*)(const void *, const void *)) tri_par_netcode); + + /* Update the linked list pointers */ + + Track = Liste[0]; + Track->Pback = pcb; Track->Pnext = Liste[1]; + pcb->m_Track = Track; + for( ii = 1; ii < nbsegm; ii++ ) + { + Track = Liste[ii]; + Track->Pback = Liste[ii-1]; + Track->Pnext = Liste[ii+1]; + } + + MyFree(Liste); +} + diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp new file mode 100644 index 0000000000..cc52ab5a9d --- /dev/null +++ b/pcbnew/controle.cpp @@ -0,0 +1,348 @@ + /********************************************************/ + /* Routines generales de gestion des commandes usuelles */ + /********************************************************/ + + /* fichier controle.cpp */ +/* + Routines d'affichage grille, Boite de coordonnees, Curseurs, marqueurs ... +*/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "id.h" +#include "protos.h" + +/* Routines Locales : */ + +/* Variables Locales */ + +/**********************************/ +void RemoteCommand(char * cmdline) +/**********************************/ +/* Read a remote command send by eeschema via a socket, + port KICAD_PCB_PORT_SERVICE_NUMBER (currently 4242) +*/ +{ +char Line[1024]; +wxString msg; +char *idcmd, * text; +WinEDA_PcbFrame * frame = EDA_Appl->m_PcbFrame; + + strncpy(Line, cmdline, sizeof(Line) -1 ); + frame->Affiche_Message( CONV_FROM_UTF8(Line)); + + idcmd = strtok(Line," \n\r"); + text = strtok(NULL," \n\r"); + if ( (idcmd == NULL) || (text == NULL) ) return; + + if( strcmp(idcmd,"$PART:") == 0 ) + { + MODULE * Module; + msg = CONV_FROM_UTF8(text); + Module = ReturnModule(frame->m_Pcb, msg); + msg.Printf(_("Locate module %s %s"),msg.GetData(), Module ? wxT("Ok") : wxT("not found")); + frame->SetStatusText(msg); + if ( Module ) + { + wxClientDC dc(frame->DrawPanel); + frame->DrawPanel->PrepareGraphicContext(&dc); + frame->DrawPanel->CursorOff(&dc); + frame->GetScreen()->m_Curseur = Module->m_Pos; + frame->DrawPanel->CursorOn(&dc); + } + } + + if(idcmd && strcmp(idcmd,"$PIN:") == 0) + { + wxString PinName, ModName; + MODULE * Module; + D_PAD * Pad = NULL; + int netcode = -1; + PinName = CONV_FROM_UTF8(text); + text = strtok(NULL," \n\r"); + if(text && strcmp(text, "$PART:") == 0 ) text = strtok(NULL,"\n\r"); + +wxClientDC dc(frame->DrawPanel); + frame->DrawPanel->PrepareGraphicContext(&dc); + + ModName = CONV_FROM_UTF8(text); + Module = ReturnModule(frame->m_Pcb, ModName); + if( Module ) Pad = ReturnPad(Module, PinName); + if( Pad ) netcode = Pad->m_NetCode; + if ( netcode > 0 ) + { + /* effacement surbrillance ancienne */ + if(g_HightLigt_Status) frame->Hight_Light(&dc); + g_HightLigth_NetCode = netcode; + frame->Hight_Light(&dc); + frame->DrawPanel->CursorOff(&dc); + frame->GetScreen()->m_Curseur = Pad->m_Pos; + frame->DrawPanel->CursorOn( &dc); + } + + if ( Module == NULL ) + msg.Printf( _("module %s not found"), text); + else if ( Pad == NULL ) + msg.Printf( _("Pin %s (module %s) not found"), PinName.GetData(), ModName.GetData()); + else + msg.Printf( _("Locate Pin %s (module %s)"), PinName.GetData(),ModName.GetData()); + frame->Affiche_Message(msg); + } +} + + +/***********************************************************************/ +EDA_BaseStruct * WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay(void) +/***********************************************************************/ +{ + return Locate(CURSEUR_OFF_GRILLE); +} + + +/****************************************************************/ +void WinEDA_BasePcbFrame::GeneralControle(wxDC *DC, wxPoint Mouse) +/*****************************************************************/ +{ +int ll; +wxSize delta; +int zoom = GetScreen()->GetZoom(); +wxPoint curpos, oldpos; +int hotkey = 0; + + ActiveScreen = GetScreen(); + + // Save the board after the time out : +int CurrentTime = time(NULL); + if( !GetScreen()->IsModify() || GetScreen()->IsSave() ) + { /* If no change, reset the time out */ + g_SaveTime = CurrentTime; + } + + if ( (CurrentTime - g_SaveTime) > g_TimeOut) + { + wxString tmpFileName = GetScreen()->m_FileName; + wxString filename = g_SaveFileName + PcbExtBuffer; + ((WinEDA_PcbFrame*)this)->SavePcbFile(filename); + GetScreen()->m_FileName = tmpFileName; + SetTitle(GetScreen()->m_FileName); + } + + curpos = DrawPanel->CursorRealPosition(Mouse); + oldpos = GetScreen()->m_Curseur; + + delta.x = (int) round((double)GetScreen()->GetGrid().x / zoom); + delta.y = (int) round((double)GetScreen()->GetGrid().y / zoom); + if( delta.x <= 0 ) delta.x = 1; + if( delta.y <= 0 ) delta.y = 1; + + switch(g_KeyPressed) + { + case WXK_NUMPAD_SUBTRACT : + case WXK_SUBTRACT : + case '-' : + ll = GetScreen()->m_Active_Layer; + if(ll > CMP_N) break; + if(ll <= CUIVRE_N) break; + if ( m_Pcb->m_BoardSettings->m_CopperLayerCount <= 1) // Single layer + ll = CUIVRE_N; + if ( ll == CMP_N ) + ll = MAX(CUIVRE_N, m_Pcb->m_BoardSettings->m_CopperLayerCount-2); + else if ( ll > CUIVRE_N) ll--; + GetScreen()->m_Active_Layer = ll; + if ( DisplayOpt.ContrastModeDisplay ) DrawPanel->Refresh(TRUE); + break ; + + case WXK_NUMPAD_ADD : + case WXK_ADD : + case '+' : + ll = GetScreen()->m_Active_Layer; + if(ll >= CMP_N) break; + ll++; + if ( ll >= m_Pcb->m_BoardSettings->m_CopperLayerCount-1 ) + ll = CMP_N; + if ( m_Pcb->m_BoardSettings->m_CopperLayerCount <= 1) // Single layer + ll = CUIVRE_N; + GetScreen()->m_Active_Layer = ll; + if ( DisplayOpt.ContrastModeDisplay ) DrawPanel->Refresh(TRUE); + break ; + case WXK_NUMPAD0 : + case WXK_PAGEUP : + if ( GetScreen()->m_Active_Layer != CMP_N ) + { + GetScreen()->m_Active_Layer = CMP_N; + if ( DisplayOpt.ContrastModeDisplay ) + GetScreen()->SetRefreshReq(); + } + break ; + + case WXK_NUMPAD9 : + case WXK_PAGEDOWN : + if ( GetScreen()->m_Active_Layer != CUIVRE_N ) + { + GetScreen()->m_Active_Layer = CUIVRE_N; + if ( DisplayOpt.ContrastModeDisplay ) + GetScreen()->SetRefreshReq(); + } + break ; + + case 'F' | GR_KB_CTRL : + case 'f' | GR_KB_CTRL: + DisplayOpt.DisplayPcbTrackFill ^= 1; DisplayOpt.DisplayPcbTrackFill &= 1 ; + GetScreen()->SetRefreshReq(); + break ; + + case ' ' : /* Mise a jour de l'origine des coord relatives */ + GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; + break ; + + + case 'U' | GR_KB_CTRL : + case 'u' | GR_KB_CTRL : + g_UnitMetric = (g_UnitMetric == INCHES ) ? MILLIMETRE : INCHES; + break ; + + case EDA_PANNING_UP_KEY : + OnZoom(ID_ZOOM_PANNING_UP); + curpos = m_CurrentScreen->m_Curseur; + break; + + case EDA_PANNING_DOWN_KEY : + OnZoom(ID_ZOOM_PANNING_DOWN); + curpos = m_CurrentScreen->m_Curseur; + break; + + case EDA_PANNING_LEFT_KEY : + OnZoom(ID_ZOOM_PANNING_LEFT); + curpos = m_CurrentScreen->m_Curseur; + break; + + case EDA_PANNING_RIGHT_KEY : + OnZoom(ID_ZOOM_PANNING_RIGHT); + curpos = m_CurrentScreen->m_Curseur; + break; + + case WXK_F1 : + OnZoom(ID_ZOOM_PLUS_KEY); + oldpos = curpos = GetScreen()->m_Curseur; + break; + + case WXK_F2 : + OnZoom(ID_ZOOM_MOINS_KEY); + oldpos = curpos = GetScreen()->m_Curseur; + break; + + case WXK_F3 : + OnZoom(ID_ZOOM_REDRAW_KEY); + break; + + case WXK_F4 : + OnZoom(ID_ZOOM_CENTER_KEY); + oldpos = curpos = GetScreen()->m_Curseur; + break; + + case WXK_F5 : /* unused */ + break; + + case WXK_NUMPAD8 : /* Deplacement curseur vers le haut */ + case WXK_UP : + Mouse.y -= delta.y; + DrawPanel->MouseTo(Mouse); + break ; + + case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ + case WXK_DOWN: + Mouse.y += delta.y; + DrawPanel->MouseTo(Mouse); + break ; + + case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ + case WXK_LEFT : + Mouse.x -= delta.x; + DrawPanel->MouseTo(Mouse); + break ; + + case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ + case WXK_RIGHT: + Mouse.x += delta.x; + DrawPanel->MouseTo(Mouse); + break ; + + default: hotkey = g_KeyPressed; + break; + } + + /* Put cursor in new position, according to the zoom keys (if any) */ + GetScreen()->m_Curseur = curpos; + + /* Put cursor on grid or a pad centre if requested + But if the tool DELETE is active the cursor is left off grid + this is better to reach items to delete off grid + */ + D_PAD * pad; + bool keep_on_grid = TRUE; + if (m_ID_current_state == ID_PCB_DELETE_ITEM_BUTT) keep_on_grid = FALSE; + /* Cursor is left off grid if no block in progress and no moving object */ + if ( GetScreen()->BlockLocate.m_State != STATE_NO_BLOCK) + keep_on_grid = TRUE; + EDA_BaseStruct *DrawStruct = GetScreen()->m_CurrentItem; + if ( DrawStruct && DrawStruct->m_Flags ) keep_on_grid = TRUE; + + switch ( g_MagneticPadOption ) + { + case capture_cursor_in_track_tool: + case capture_always: + pad = Locate_Any_Pad(m_Pcb,CURSEUR_OFF_GRILLE, TRUE); + if ( (m_ID_current_state != ID_TRACK_BUTT ) && + (g_MagneticPadOption == capture_cursor_in_track_tool) ) + pad = NULL; + if (keep_on_grid) + { + if (pad) // Put cursor on the pad + GetScreen()->m_Curseur = curpos = pad->m_Pos; + else // Put cursor on grid + PutOnGrid( & GetScreen()->m_Curseur); + } + break; + + case no_effect: + default: + // If we are not in delete function, put cursor on grid + if (keep_on_grid) + PutOnGrid( & GetScreen()->m_Curseur); + break; + } + + if ( oldpos != GetScreen()->m_Curseur ) + { + curpos = GetScreen()->m_Curseur; + GetScreen()->m_Curseur = oldpos; + DrawPanel->CursorOff(DC); + + GetScreen()->m_Curseur = curpos; + DrawPanel->CursorOn(DC); + + if(DrawPanel->ManageCurseur) + { + DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); + } + } + + if( GetScreen()->IsRefreshReq() ) + { + RedrawActiveWindow(DC, TRUE); + } + + SetToolbars(); + Affiche_Status_Box(); /* Affichage des coord curseur */ + + if ( hotkey ) + { + OnHotKey(DC, hotkey, NULL); + } +} + + diff --git a/pcbnew/cotation.cpp b/pcbnew/cotation.cpp new file mode 100644 index 0000000000..23a2a349e8 --- /dev/null +++ b/pcbnew/cotation.cpp @@ -0,0 +1,477 @@ + /*****************************************/ + /* Edition du pcb: Gestion des cotations */ + /*****************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + +/* Routines Locales */ +static void Exit_EditCotation(WinEDA_DrawPanel * Panel, wxDC *DC); +static void Montre_Position_New_Cotation(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void Ajuste_Details_Cotation(COTATION * pts); + +/* Variables "locales" : */ +static int status_cotation; /* = 0 : pas de cotation en cours + = 1 : debut place, fin a placer + = 2 : fin placee, texte a ajuster */ + +/* + Les routines generent une cotation de la forme + - cote usuelle: + + | | + | dist | + |<---------->| + | | + +*/ + +#define MAX_CHAR 40 /* longueur maxi de la cotation */ +/* Dimension des fleches */ +#define FLECHE_L 500 + + +enum id_Cotation_properties +{ + ID_ACCEPT_COTATION_PROPERTIES = 1900, + ID_CLOSE_COTATION_PROPERTIES, + ID_TEXTPCB_SELECT_LAYER +}; + + /************************************/ + /* class WinEDA_CotationPropertiesFrame */ + /************************************/ + +class WinEDA_CotationPropertiesFrame: public wxDialog +{ +private: + + WinEDA_PcbFrame * m_Parent; + wxDC * m_DC; + COTATION * CurrentCotation; + WinEDA_EnterText * m_Name; + WinEDA_SizeCtrl * m_TxtSizeCtrl; + WinEDA_ValueCtrl * m_TxtWidthCtrl; + wxRadioBox * m_Mirror; + WinEDAChoiceBox * m_SelLayerBox; + +public: + // Constructor and destructor + WinEDA_CotationPropertiesFrame(WinEDA_PcbFrame *parent, + COTATION * Cotation, wxDC * DC, const wxPoint & pos); + ~WinEDA_CotationPropertiesFrame(void) + { + } + +private: + void OnQuit(wxCommandEvent& event); + void CotationPropertiesAccept(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(WinEDA_CotationPropertiesFrame, wxDialog) + EVT_BUTTON(ID_ACCEPT_COTATION_PROPERTIES, + WinEDA_CotationPropertiesFrame::CotationPropertiesAccept) + EVT_BUTTON(ID_CLOSE_COTATION_PROPERTIES, + WinEDA_CotationPropertiesFrame::OnQuit) +END_EVENT_TABLE() + + +WinEDA_CotationPropertiesFrame::WinEDA_CotationPropertiesFrame(WinEDA_PcbFrame *parent, + COTATION * Cotation,wxDC * DC, + const wxPoint & framepos): + wxDialog(parent, -1, _("Cotation properties"), framepos, wxSize(340, 270), + DIALOG_STYLE) +{ +wxButton * Button; + + m_Parent = parent; + SetFont(*g_DialogFont); + m_DC = DC; + Centre(); + + CurrentCotation = Cotation; + + wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(MainBoxSizer); + wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + /* Creation des boutons de commande */ + Button = new wxButton(this, ID_ACCEPT_COTATION_PROPERTIES, + _("Ok")); + Button->SetForegroundColour(*wxRED); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Button = new wxButton(this, ID_CLOSE_COTATION_PROPERTIES, + _("Cancel")); + Button->SetForegroundColour(*wxBLUE); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + +wxString display_msg[2] = { _("Normal"), _("Mirror") }; + m_Mirror = new wxRadioBox(this, -1, _("Display"), + wxDefaultPosition, wxSize(-1,-1), 2, display_msg, + 1, wxRA_SPECIFY_COLS ); + if ( ! Cotation->m_Text->m_Miroir ) m_Mirror->SetSelection(1);; + RightBoxSizer->Add(m_Mirror, 0, wxGROW|wxALL, 5); + + m_Name = new WinEDA_EnterText(this, wxT("Text:"), + Cotation->m_Text->m_Text, + LeftBoxSizer, wxSize( 200, -1) ); + + m_TxtSizeCtrl = new WinEDA_SizeCtrl(this, _("Size"), + Cotation->m_Text->m_Size, + g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits); + + m_TxtWidthCtrl = new WinEDA_ValueCtrl(this, _("Width"), + Cotation->m_Width, + g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits); + + wxStaticText * text = new wxStaticText(this, -1, _("Layer:")); + LeftBoxSizer->Add(text, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); + m_SelLayerBox = new WinEDAChoiceBox(this, ID_TEXTPCB_SELECT_LAYER, + wxDefaultPosition, wxDefaultSize); + LeftBoxSizer->Add(m_SelLayerBox, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + int ii; + for ( ii = CMP_N + 1; ii < 29 ; ii ++ ) + { + m_SelLayerBox->Append(ReturnPcbLayerName(ii)); + } + m_SelLayerBox->SetSelection( Cotation->m_Layer - (CMP_N + 1) ); + + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); +} + +/**********************************************************************/ +void WinEDA_CotationPropertiesFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/**********************************************************************/ +{ + Close(true); // true is to force the frame to close +} + + + +/***********************************************************************************/ +void WinEDA_CotationPropertiesFrame::CotationPropertiesAccept(wxCommandEvent& event) +/***********************************************************************************/ +{ + if ( m_DC ) // Effacement ancien texte + { + CurrentCotation->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0), GR_XOR); + } + + if ( m_Name->GetValue() != wxEmptyString ) + { + CurrentCotation->SetText( m_Name->GetValue()); + } + + CurrentCotation->m_Text->m_Size = m_TxtSizeCtrl->GetValue(); + CurrentCotation->m_Text->m_Width = CurrentCotation->m_Width = + m_TxtWidthCtrl->GetValue(); + CurrentCotation->m_Text->m_Miroir = (m_Mirror->GetSelection() == 0) ? 1 : 0; + CurrentCotation->m_Layer = CurrentCotation->m_Text->m_Layer = + m_SelLayerBox->GetChoice() + CMP_N + 1; + + CurrentCotation->m_Text->CreateDrawData(); + + if ( m_DC ) // Affichage nouveau texte + { + /* Redessin du Texte */ + CurrentCotation->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0), GR_OR); + } + + m_Parent->m_CurrentScreen->SetModify(); + Close(TRUE); +} + + +/**************************************************************/ +static void Exit_EditCotation(WinEDA_DrawPanel * Panel, wxDC *DC) +/**************************************************************/ +{ +COTATION * Cotation = (COTATION*) Panel->GetScreen()->m_CurrentItem; + + if( Cotation ) + { + if ( Cotation->m_Flags & IS_NEW) + { + Cotation->Draw(Panel, DC,wxPoint(0,0),GR_XOR) ; + DeleteStructure( Cotation); + } + else + { + Cotation->Draw(Panel, DC,wxPoint(0,0),GR_OR) ; + } + } + + status_cotation = 0; + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + Panel->GetScreen()->m_CurrentItem = NULL; + +} + +/*************************************************************************/ +COTATION * WinEDA_PcbFrame::Begin_Cotation(COTATION * Cotation, wxDC * DC) +/*************************************************************************/ +{ +wxPoint pos ; + + if(Cotation == NULL ) /* debut reel du trace */ + { + status_cotation = 1; + pos = m_CurrentScreen->m_Curseur; + + Cotation = new COTATION(m_Pcb); + Cotation->m_Flags = IS_NEW; + + Cotation->m_Layer = GetScreen()->m_Active_Layer; + Cotation->m_Width = g_DesignSettings.m_DrawSegmentWidth; + Cotation->m_Text->m_Width = Cotation->m_Width; + + Cotation->Barre_ox = Cotation->Barre_fx = pos.x ; + Cotation->Barre_oy = Cotation->Barre_fy = pos.y ; + + Cotation->TraitD_ox = Cotation->TraitD_fx = pos.x ; + Cotation->TraitD_oy = Cotation->TraitD_fy = pos.y ; + + Cotation->TraitG_ox = Cotation->TraitG_fx = pos.x ; + Cotation->TraitG_oy = Cotation->TraitG_fy = pos.y ; + + Cotation->FlecheG1_ox = Cotation->FlecheG1_fx = pos.x ; + Cotation->FlecheG1_oy = Cotation->FlecheG1_fy = pos.y ; + + Cotation->FlecheG2_ox = Cotation->FlecheG2_fx = pos.x ; + Cotation->FlecheG2_oy = Cotation->FlecheG2_fy = pos.y ; + + Cotation->FlecheD1_ox = Cotation->FlecheD1_fx = pos.x ; + Cotation->FlecheD1_oy = Cotation->FlecheD1_fy = pos.y ; + + Cotation->FlecheD2_ox = Cotation->FlecheD2_fx = pos.x ; + Cotation->FlecheD2_oy = Cotation->FlecheD2_fy = pos.y ; + + Cotation->m_Text->m_Miroir = 1; + Cotation->m_Text->m_Size = g_DesignSettings.m_PcbTextSize; + Cotation->m_Text->m_Width = g_DesignSettings.m_PcbTextWidth; + + Ajuste_Details_Cotation(Cotation); + + Cotation->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); + + DrawPanel->ManageCurseur = Montre_Position_New_Cotation; + DrawPanel->ForceCloseManageCurseur = Exit_EditCotation; + return Cotation; + } + + // Cotation != NULL + if( status_cotation == 1 ) + { + status_cotation = 2; + return Cotation; + } + + Cotation->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); + Cotation->m_Flags = 0; + + /* Insertion de la structure dans le Chainage .Drawings du PCB */ + Cotation->Pback = m_Pcb; + Cotation->Pnext = m_Pcb->m_Drawings; + if( m_Pcb->m_Drawings) m_Pcb->m_Drawings->Pback = Cotation; + m_Pcb->m_Drawings = Cotation; + + m_CurrentScreen->SetModify(); + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + + return NULL; +} + + +/************************************************************************************/ +static void Montre_Position_New_Cotation(WinEDA_DrawPanel * panel, wxDC * DC, bool erase ) +/************************************************************************************/ +/* redessin du contour de la piste lors des deplacements de la souris */ +{ +PCB_SCREEN * screen = (PCB_SCREEN *)panel->GetScreen(); +COTATION * Cotation = (COTATION *) screen->m_CurrentItem; +wxPoint pos = screen->m_Curseur; + + if( Cotation == NULL ) return ; + + /* efface ancienne position */ + if( erase) + { + Cotation->Draw(panel, DC, wxPoint(0,0),GR_XOR) ; + } + + Cotation->m_Layer = screen->m_Active_Layer; + if( status_cotation == 1) + { + Cotation->TraitD_ox = pos.x; + Cotation->TraitD_oy = pos.y; + Cotation->Barre_fx = Cotation->TraitD_ox; + Cotation->Barre_fy = Cotation->TraitD_oy; + Ajuste_Details_Cotation(Cotation); + } + + else + { + int deltax, deltay, dx , dy; + float angle, depl; + deltax = Cotation->TraitD_ox - Cotation->TraitG_ox; + deltay = Cotation->TraitD_oy - Cotation->TraitG_oy; + /* Calcul de la direction de deplacement + ( perpendiculaire a l'axe de la cote ) */ + angle = atan2(deltay,deltax) + (M_PI / 2); + + deltax = pos.x - Cotation->TraitD_ox; + deltay = pos.y - Cotation->TraitD_oy; + depl = (deltax * cos(angle)) + (deltay * sin(angle)); + dx = (int)(depl * cos(angle)); + dy = (int)(depl * sin(angle)); + Cotation->Barre_ox = Cotation->TraitG_ox + dx; + Cotation->Barre_oy = Cotation->TraitG_oy + dy ; + Cotation->Barre_fx = Cotation->TraitD_ox + dx; + Cotation->Barre_fy = Cotation->TraitD_oy + dy ; + + Ajuste_Details_Cotation(Cotation); + } + + Cotation->Draw(panel, DC, wxPoint(0,0),GR_XOR) ; +} + + +/***************************************************************/ +void WinEDA_PcbFrame::Install_Edit_Cotation(COTATION * Cotation, + wxDC * DC, const wxPoint & pos) +/***************************************************************/ +{ + if( Cotation == NULL) return; + + WinEDA_CotationPropertiesFrame * frame = new WinEDA_CotationPropertiesFrame(this, + Cotation, DC, pos); + frame->ShowModal(); frame->Destroy(); +} + +/*******************************************************************/ +void WinEDA_PcbFrame::Delete_Cotation(COTATION * Cotation, wxDC * DC) +/*******************************************************************/ +{ + if( Cotation == NULL) return; + + if ( DC ) Cotation->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR ); + DeleteStructure( Cotation); + m_CurrentScreen->SetModify(); +} + + +/*****************************************************/ +static void Ajuste_Details_Cotation(COTATION * Cotation) +/*****************************************************/ +/* Calcule les details des coordonnees des differents segments constitutifs +de la cotation +*/ +{ +int ii; +int mesure, deltax, deltay; /* valeur de la mesure sur les axes X et Y */ +int fleche_up_X=0, fleche_up_Y=0; /* coord des fleches : barre / */ +int fleche_dw_X=0, fleche_dw_Y=0; /* coord des fleches : barre \ */ +int hx, hy; /* coord des traits de rappel de cote */ +float angle, angle_f; +wxString msg; + + /* Init des couches : */ + Cotation->m_Text->m_Layer = Cotation->m_Layer; + + /* calcul de la hauteur du texte + trait de cotation */ + ii = Cotation->m_Text->m_Size.y + + Cotation->m_Text->m_Width + (Cotation->m_Width * 3); + + deltax = Cotation->TraitD_ox - Cotation->TraitG_ox; + deltay = Cotation->TraitD_oy - Cotation->TraitG_oy; + + /* Calcul de la cote */ + mesure = (int)(hypot( (float)deltax, (float)deltay ) + 0.5 ) ; + + if( deltax || deltay) angle = atan2( (float)deltay,(float)deltax); + else angle = 0.0; + + /* Calcul des parametre dimensions X et Y des fleches et traits de cotes */ + hx = hy = ii; + + /* On tient compte de l'inclinaison de la cote */ + if(mesure) + { + hx = (abs)((int)( ( (float)deltay * hx) / mesure)); + hy = (abs)((int)( ( (float)deltax * hy) / mesure)); + + if( Cotation->TraitG_ox > Cotation->Barre_ox ) hx = -hx; + if( Cotation->TraitG_ox == Cotation->Barre_ox ) hx = 0; + if( Cotation->TraitG_oy > Cotation->Barre_oy ) hy = -hy; + if( Cotation->TraitG_oy == Cotation->Barre_oy ) hy = 0; + + angle_f = angle + (M_PI * 27.5 /180); + fleche_up_X = (int)(FLECHE_L * cos(angle_f)); + fleche_up_Y = (int)(FLECHE_L * sin(angle_f)); + angle_f = angle - (M_PI * 27.5 /180); + fleche_dw_X = (int)(FLECHE_L * cos(angle_f)); + fleche_dw_Y = (int)(FLECHE_L * sin(angle_f)); + } + + + Cotation->FlecheG1_ox = Cotation->Barre_ox; + Cotation->FlecheG1_oy = Cotation->Barre_oy; + Cotation->FlecheG1_fx = Cotation->Barre_ox + fleche_up_X ; + Cotation->FlecheG1_fy = Cotation->Barre_oy + fleche_up_Y; + + Cotation->FlecheG2_ox = Cotation->Barre_ox ; + Cotation->FlecheG2_oy = Cotation->Barre_oy ; + Cotation->FlecheG2_fx = Cotation->Barre_ox + fleche_dw_X; + Cotation->FlecheG2_fy = Cotation->Barre_oy + fleche_dw_Y; + + /*la fleche de droite est symetrique a celle de gauche: + / = -\ et \ = -/ + */ + Cotation->FlecheD1_ox = Cotation->Barre_fx ; + Cotation->FlecheD1_oy = Cotation->Barre_fy ; + Cotation->FlecheD1_fx = Cotation->Barre_fx - fleche_dw_X; + Cotation->FlecheD1_fy = Cotation->Barre_fy - fleche_dw_Y; + + Cotation->FlecheD2_ox = Cotation->Barre_fx ; + Cotation->FlecheD2_oy = Cotation->Barre_fy ; + Cotation->FlecheD2_fx = Cotation->Barre_fx - fleche_up_X; + Cotation->FlecheD2_fy = Cotation->Barre_fy - fleche_up_Y; + + + Cotation->TraitG_fx = Cotation->Barre_ox + hx; + Cotation->TraitG_fy = Cotation->Barre_oy + hy; + + Cotation->TraitD_fx = Cotation->Barre_fx + hx; + Cotation->TraitD_fy = Cotation->Barre_fy + hy; + + /* Calcul de la position du centre du texte et son orientation: */ + Cotation->m_Pos.x = Cotation->m_Text->m_Pos.x + = (Cotation->Barre_fx + Cotation->TraitG_fx) / 2; + Cotation->m_Pos.y = Cotation->m_Text->m_Pos.y + = (Cotation->Barre_fy + Cotation->TraitG_fy) / 2; + + Cotation->m_Text->m_Orient = - (int)(angle * 1800 / M_PI); + if(Cotation->m_Text->m_Orient < 0) Cotation->m_Text->m_Orient += 3600; + if(Cotation->m_Text->m_Orient >= 3600) Cotation->m_Text->m_Orient -= 3600; + if( (Cotation->m_Text->m_Orient > 900) && (Cotation->m_Text->m_Orient <2700) ) + Cotation->m_Text->m_Orient -= 1800; + + Cotation->m_Value = mesure; + valeur_param(Cotation->m_Value,msg); + Cotation->SetText( msg); + Cotation->m_Text->CreateDrawData(); +} + diff --git a/pcbnew/cursors.cpp b/pcbnew/cursors.cpp new file mode 100644 index 0000000000..0ac7afd4ce --- /dev/null +++ b/pcbnew/cursors.cpp @@ -0,0 +1,70 @@ + /****************************************************************/ + /* Routines generales d'affichage des curseurs et des marqueurs */ + /****************************************************************/ + + /* fichier curseurs.cpp */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + + +/* Routines Locales : */ + + + /* Forme (bit_map) du marqueur */ +static char Default_MarkerBitmap[]= + { + 12, 12, /* Dimensions x et y du dessin de marqueurs*/ + 1,1,1,1,1,1,1,1,0,0,0,0, /* bitmap: 1 = color, 0 = notrace */ + 1,1,1,0,1,0,1,1,0,0,0,0, + 1,1,1,1,0,0,0,1,0,0,0,0, + 1,0,1,1,1,0,0,0,0,0,0,0, + 1,1,0,1,1,1,0,0,0,0,0,0, + 1,1,0,0,1,1,1,0,0,0,0,0, + 1,1,1,0,0,1,1,1,0,0,0,0, + 0,0,0,0,0,0,1,1,1,0,0,0, + 0,0,0,0,0,0,0,1,1,1,0,0, + 0,0,0,0,0,0,0,0,1,1,1,0, + 0,0,0,0,0,0,0,0,0,1,1,1, + 0,0,0,0,0,0,0,0,0,0,1,0 + }; + + +/**********************************************************************/ +void MARQUEUR::Draw( WinEDA_DrawPanel * panel, wxDC * DC, int DrawMode) +/**********************************************************************/ +/* + Trace un repere sur l'ecran au point de coordonnees PCB pos + Le marqueur est defini par un tableau de 2 + (lig*col) elements: + 1er element: dim nbre ligne + 2er element: dim nbre col + suite: lig * col elements a 0 ou 1 : si 1 mise a color du pixel +*/ +{ +int px, py; +int ii, ii_max, jj, jj_max; +char * pt_bitmap = m_Bitmap; + + if ( pt_bitmap == NULL ) pt_bitmap = Default_MarkerBitmap; + + GRSetDrawMode(DC, DrawMode); + + px = GRMapX(m_Pos.x); py = GRMapY(m_Pos.y); + + /* Lecture des dimensions */ + ii_max = *(pt_bitmap++); jj_max = *(pt_bitmap++); + + /* Trace du bitmap */ + for( ii = 0; ii < ii_max; ii++) + { + for( jj = 0; jj < jj_max; jj++, pt_bitmap++) + { + if(*pt_bitmap) GRSPutPixel(&panel->m_ClipBox, DC, + px+ii , py+jj , m_Color); + } + } +} + diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp new file mode 100644 index 0000000000..a81b86b3ff --- /dev/null +++ b/pcbnew/deltrack.cpp @@ -0,0 +1,199 @@ + /*********************************************/ + /* Edition des pistes: Routines d'effacement */ + /* Effacement de segment, piste, net et zone */ + /*********************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + +/* Routines Locales */ + +/* Variables locales */ + + +/***************************************************************/ +TRACK * WinEDA_PcbFrame::Delete_Segment(wxDC * DC, TRACK *Track) +/***************************************************************/ +/* Supprime 1 segment de piste. + 2 Cas possibles: + Si On est en trace de nouvelle piste: Effacement du segment en + cours de trace + Sinon : Effacment du segment sous le curseur. +*/ +{ +int current_net_code; + + if ( Track == NULL ) return NULL; + + if(Track->m_Flags & IS_NEW) // Trace en cours, on peut effacer le dernier segment + { + if(g_TrackSegmentCount > 0 ) + { + int previous_layer = GetScreen()->m_Active_Layer; + // effacement de la piste en cours + ShowNewTrackWhenMovingCursor(DrawPanel, DC, FALSE); + + // modification du trace + Track = g_CurrentTrackSegment; + g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; + delete Track; + g_TrackSegmentCount--; + + if ( g_TwoSegmentTrackBuild ) + { // g_CurrentTrackSegment->Pback must not be a via, or we want delete also the via + if ( (g_TrackSegmentCount >= 2) && + (g_CurrentTrackSegment->m_StructType != TYPEVIA) && + (g_CurrentTrackSegment->Pback->m_StructType == TYPEVIA) ) + { + Track = g_CurrentTrackSegment; + g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; + delete Track; + g_TrackSegmentCount--; + } + } + + while( g_TrackSegmentCount && g_CurrentTrackSegment && + (g_CurrentTrackSegment->m_StructType == TYPEVIA) ) + { + Track = g_CurrentTrackSegment; + g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback; + delete Track; + g_TrackSegmentCount--; + if (g_CurrentTrackSegment && (g_CurrentTrackSegment->m_StructType != TYPEVIA) ) + previous_layer = g_CurrentTrackSegment->m_Layer; + } + if( g_CurrentTrackSegment ) g_CurrentTrackSegment->Pnext = NULL; + + // Rectification couche active qui a pu changer si une via + // a ete effacee + GetScreen()->m_Active_Layer = previous_layer; + + Affiche_Status_Box(); + if ( g_TwoSegmentTrackBuild ) // We must have 2 segments or more, or 0 + { + if( ( g_TrackSegmentCount == 1 ) && + (g_CurrentTrackSegment->m_StructType != TYPEVIA) ) + { + delete g_CurrentTrackSegment; + g_TrackSegmentCount = 0; + } + } + if(g_TrackSegmentCount == 0 ) + { + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + if(g_HightLigt_Status) Hight_Light(DC); + g_CurrentTrackSegment = NULL; + g_FirstTrackSegment = NULL; + GetScreen()->m_CurrentItem = NULL; + return NULL; + } + else + { + if(DrawPanel->ManageCurseur) + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + return g_CurrentTrackSegment; + } + } + return NULL; + } // Fin traitement si trace en cours + + + current_net_code = Track->m_NetCode; + Track->Draw(DrawPanel, DC, GR_XOR) ; + + SaveItemEfface( Track, 1); + GetScreen()->SetModify(); + + test_1_net_connexion(DC, current_net_code); + Affiche_Infos_Status_Pcb(this); + return NULL; +} + + + +/**********************************************************/ +void WinEDA_PcbFrame::Delete_Track(wxDC * DC, TRACK *Track) +/**********************************************************/ +{ + if( Track != NULL ) + { + int current_net_code = Track->m_NetCode; + Supprime_Une_Piste(DC, Track) ; + GetScreen()->SetModify(); + test_1_net_connexion(DC, current_net_code); + Affiche_Infos_Status_Pcb(this); + } +} + + +/********************************************************/ +void WinEDA_PcbFrame::Delete_net(wxDC * DC, TRACK *Track) +/********************************************************/ +{ +TRACK *pt_segm, * pt_start; +int ii ; +int net_code_delete; + + pt_segm = Track; + + if ( pt_segm == NULL ) return; + + if ( IsOK(this, _("Delete NET ?") ) ) + { + net_code_delete = pt_segm->m_NetCode; + /* Recherche du debut de la zone des pistes du net_code courant */ + pt_start = m_Pcb->m_Track->GetStartNetCode(net_code_delete); + + /* Decompte du nombre de segments de la sous-chaine */ + pt_segm = pt_start; + for ( ii = 0 ; pt_segm != NULL; pt_segm = (TRACK*)pt_segm->Pnext ) + { + if( pt_segm->m_NetCode != net_code_delete ) break; + ii++; + } + + Trace_Une_Piste(DrawPanel, DC, pt_start,ii,GR_XOR); + + SaveItemEfface( pt_start, ii); + GetScreen()->SetModify(); + test_1_net_connexion(DC, net_code_delete); + Affiche_Infos_Status_Pcb(this); + } +} + + +/********************************************************************/ +void WinEDA_PcbFrame::Supprime_Une_Piste(wxDC * DC, TRACK* pt_segm) +/********************************************************************/ +/* Routine de suppression de 1 piste: + le segment pointe est supprime puis les segments adjacents + jusqu'a un pad ou un point de jonction de plus de 2 segments +*/ +{ +TRACK * pt_track, * Struct; +int ii, nb_segm; + + if (pt_segm == NULL ) return ; + + pt_track = Marque_Une_Piste(this, DC, pt_segm, + & nb_segm, GR_OR | GR_SURBRILL); + + if(nb_segm) /* Il y a nb_segm segments de piste a effacer */ + { + Trace_Une_Piste(DrawPanel, DC, pt_track,nb_segm,GR_XOR | GR_SURBRILL); + /* Effacement flag BUSY */ + Struct = pt_track; ii = 0; + for ( ; ii < nb_segm; ii++, Struct = (TRACK*) Struct->Pnext ) + { + Struct->SetState(BUSY,OFF); + } + SaveItemEfface( pt_track, nb_segm); + } +} + diff --git a/pcbnew/dialog_display_options.cpp b/pcbnew/dialog_display_options.cpp new file mode 100644 index 0000000000..3938984739 --- /dev/null +++ b/pcbnew/dialog_display_options.cpp @@ -0,0 +1,354 @@ + /****************************************************************/ + /* dialog_display_options.cpp - Gestion des Options d'affichage */ + /****************************************************************/ +/* + Affichage et modifications des parametres de travail de PcbNew + Parametres = mode d'affichage des textes et elements graphiques +*/ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "dialog_display_options.h" +#endif + + +#include "fctsys.h" +#include "gr_basic.h" +#include "macros.h" + +#include "common.h" +#include "pcbnew.h" +#include "pcbplot.h" +#include "autorout.h" + +#include "id.h" + +#include "protos.h" +#include + +#include "dialog_display_options.h" + +/* Fonctions locales */ + +/* variables locales */ + + +/*************************************************************************/ +void WinEDA_DisplayOptionsDialog::AcceptPcbOptions(wxCommandEvent& event) +/*************************************************************************/ +/* Met a jour les options +*/ +{ + if ( m_Show_Page_Limits->GetSelection() == 0 ) g_ShowPageLimits = TRUE; + else g_ShowPageLimits = FALSE; + + if ( m_OptDisplayTracks->GetSelection() == 1) + DisplayOpt.DisplayPcbTrackFill = TRUE; + else DisplayOpt.DisplayPcbTrackFill = FALSE; + + m_Parent->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; + DisplayOpt.m_DisplayViaMode = m_OptDisplayViaHole->GetSelection(); + + switch ( m_OptDisplayTracksClearance->GetSelection() ) + { + case 0: + DisplayOpt.DisplayTrackIsol = TRUE; + g_ShowIsolDuringCreateTrack = TRUE; + break; + case 1: + DisplayOpt.DisplayTrackIsol = FALSE; + g_ShowIsolDuringCreateTrack = TRUE; + break; + case 2: + DisplayOpt.DisplayTrackIsol = FALSE; + g_ShowIsolDuringCreateTrack = FALSE; + break; + } + + m_Parent->m_DisplayModText = DisplayOpt.DisplayModText = + m_OptDisplayModTexts->GetSelection(); + m_Parent->m_DisplayModEdge = DisplayOpt.DisplayModEdge = + m_OptDisplayModEdges->GetSelection(); + + if (m_OptDisplayPads->GetSelection() == 1 ) + DisplayOpt.DisplayPadFill = TRUE; + else DisplayOpt.DisplayPadFill = FALSE; + + m_Parent->m_DisplayPadFill = DisplayOpt.DisplayPadFill; + + DisplayOpt.DisplayPadIsol = m_OptDisplayPadClearence->GetValue(); + + m_Parent->m_DisplayPadNum = DisplayOpt.DisplayPadNum = m_OptDisplayPadNumber->GetValue(); + + DisplayOpt.DisplayPadNoConn = m_OptDisplayPadNoConn->GetValue(); + + DisplayOpt.DisplayDrawItems = m_OptDisplayDrawings->GetSelection(); + + m_Parent->DrawPanel->Refresh(TRUE); + + EndModal(1); +} + + +/*! + * WinEDA_DisplayOptionsDialog type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_DisplayOptionsDialog, wxDialog ) + +/*! + * WinEDA_DisplayOptionsDialog event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_DisplayOptionsDialog, wxDialog ) + +////@begin WinEDA_DisplayOptionsDialog event table entries + EVT_BUTTON( wxID_OK, WinEDA_DisplayOptionsDialog::OnOkClick ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_DisplayOptionsDialog::OnCancelClick ) + +////@end WinEDA_DisplayOptionsDialog event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_DisplayOptionsDialog constructors + */ + +WinEDA_DisplayOptionsDialog::WinEDA_DisplayOptionsDialog( ) +{ +} + +WinEDA_DisplayOptionsDialog::WinEDA_DisplayOptionsDialog( WinEDA_BasePcbFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + + Create(parent, id, caption, pos, size, style); + + if ( DisplayOpt.DisplayPcbTrackFill ) + m_OptDisplayTracks->SetSelection(1); + if ( DisplayOpt.DisplayTrackIsol ) + m_OptDisplayTracksClearance->SetSelection(0); + else if ( g_ShowIsolDuringCreateTrack ) + m_OptDisplayTracksClearance->SetSelection(1); + else m_OptDisplayTracksClearance->SetSelection(2); + + if ( DisplayOpt.DisplayPadFill ) + m_OptDisplayPads->SetSelection(1); + + m_Show_Page_Limits->SetSelection( g_ShowPageLimits ? 0 : 1); +} + +/*! + * WinEDA_DisplayOptionsDialog creator + */ + +bool WinEDA_DisplayOptionsDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_DisplayOptionsDialog member initialisation + m_OptDisplayTracks = NULL; + m_OptDisplayTracksClearance = NULL; + m_OptDisplayViaHole = NULL; + m_OptDisplayModTexts = NULL; + m_OptDisplayModEdges = NULL; + m_OptDisplayPads = NULL; + m_OptDisplayPadClearence = NULL; + m_OptDisplayPadNumber = NULL; + m_OptDisplayPadNoConn = NULL; + m_OptDisplayDrawings = NULL; + m_Show_Page_Limits = NULL; +////@end WinEDA_DisplayOptionsDialog member initialisation + +////@begin WinEDA_DisplayOptionsDialog creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_DisplayOptionsDialog creation + return true; +} + +/*! + * Control creation for WinEDA_DisplayOptionsDialog + */ + +void WinEDA_DisplayOptionsDialog::CreateControls() +{ + SetFont(*g_DialogFont); +////@begin WinEDA_DisplayOptionsDialog content construction + // Generated by DialogBlocks, 26/02/2006 15:47:05 (unregistered) + + WinEDA_DisplayOptionsDialog* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Tracks and vias")); + wxStaticBoxSizer* itemStaticBoxSizer3 = new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxVERTICAL); + itemBoxSizer2->Add(itemStaticBoxSizer3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxString m_OptDisplayTracksStrings[] = { + _("Sketch"), + _("Filled") + }; + m_OptDisplayTracks = new wxRadioBox( itemDialog1, ID_RADIOBOX_OPT_TRACK, _("Tracks:"), wxDefaultPosition, wxDefaultSize, 2, m_OptDisplayTracksStrings, 1, wxRA_SPECIFY_COLS ); + itemStaticBoxSizer3->Add(m_OptDisplayTracks, 0, wxGROW|wxALL, 5); + + wxString m_OptDisplayTracksClearanceStrings[] = { + _("Always"), + _("New track"), + _("Never") + }; + m_OptDisplayTracksClearance = new wxRadioBox( itemDialog1, ID_RADIOBOX_SHOWCLR, _("Show Track Clearance"), wxDefaultPosition, wxDefaultSize, 3, m_OptDisplayTracksClearanceStrings, 1, wxRA_SPECIFY_COLS ); + itemStaticBoxSizer3->Add(m_OptDisplayTracksClearance, 0, wxGROW|wxALL, 5); + + wxString m_OptDisplayViaHoleStrings[] = { + _("Never"), + _("defined holes"), + _("Always") + }; + m_OptDisplayViaHole = new wxRadioBox( itemDialog1, ID_RADIOBOX_SHOW_VIAS, _("Show Via Holes"), wxDefaultPosition, wxDefaultSize, 3, m_OptDisplayViaHoleStrings, 1, wxRA_SPECIFY_COLS ); + itemStaticBoxSizer3->Add(m_OptDisplayViaHole, 0, wxGROW|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer7Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Modules")); + wxStaticBoxSizer* itemStaticBoxSizer7 = new wxStaticBoxSizer(itemStaticBoxSizer7Static, wxHORIZONTAL); + itemBoxSizer2->Add(itemStaticBoxSizer7, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL); + itemStaticBoxSizer7->Add(itemBoxSizer8, 0, wxGROW|wxALL, 5); + + wxString m_OptDisplayModTextsStrings[] = { + _("Line"), + _("Filled"), + _("Sketch") + }; + m_OptDisplayModTexts = new wxRadioBox( itemDialog1, ID_RADIOBOX_MODTXT, _("Module Texts"), wxDefaultPosition, wxDefaultSize, 3, m_OptDisplayModTextsStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer8->Add(m_OptDisplayModTexts, 0, wxGROW|wxALL, 5); + + wxString m_OptDisplayModEdgesStrings[] = { + _("Line"), + _("Filled"), + _("Sketch") + }; + m_OptDisplayModEdges = new wxRadioBox( itemDialog1, ID_RADIOBOX_MOD_EDGES, _("Module Edges:"), wxDefaultPosition, wxDefaultSize, 3, m_OptDisplayModEdgesStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer8->Add(m_OptDisplayModEdges, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL); + itemStaticBoxSizer7->Add(itemBoxSizer11, 0, wxGROW|wxALL, 5); + + wxString m_OptDisplayPadsStrings[] = { + _("Sketch"), + _("Filled") + }; + m_OptDisplayPads = new wxRadioBox( itemDialog1, ID_RADIOBOX_SHOWPADS, _("Pads:"), wxDefaultPosition, wxDefaultSize, 2, m_OptDisplayPadsStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer11->Add(m_OptDisplayPads, 0, wxGROW|wxALL, 5); + + m_OptDisplayPadClearence = new wxCheckBox( itemDialog1, ID_CHECKBOX_PAD_CLR, _("Show Pad Clearance"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_OptDisplayPadClearence->SetValue(false); + itemBoxSizer11->Add(m_OptDisplayPadClearence, 0, wxGROW|wxALL, 5); + + m_OptDisplayPadNumber = new wxCheckBox( itemDialog1, ID_CHECKBOX_PADNUM, _("Show Pad Number"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_OptDisplayPadNumber->SetValue(false); + itemBoxSizer11->Add(m_OptDisplayPadNumber, 0, wxGROW|wxALL, 5); + + m_OptDisplayPadNoConn = new wxCheckBox( itemDialog1, ID_CHECKBOX_PADNC, _("Show Pad NoConnect"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_OptDisplayPadNoConn->SetValue(false); + itemBoxSizer11->Add(m_OptDisplayPadNoConn, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer16 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer16, 0, wxGROW|wxALL, 5); + + wxString m_OptDisplayDrawingsStrings[] = { + _("Line"), + _("Filled"), + _("Sketch") + }; + m_OptDisplayDrawings = new wxRadioBox( itemDialog1, ID_RADIOBOX_SHOW_OTHERS, _("Display other items:"), wxDefaultPosition, wxDefaultSize, 3, m_OptDisplayDrawingsStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer16->Add(m_OptDisplayDrawings, 0, wxGROW|wxALL, 5); + + wxString m_Show_Page_LimitsStrings[] = { + _("Yes"), + _("No") + }; + m_Show_Page_Limits = new wxRadioBox( itemDialog1, ID_RADIOBOX_PAGE_LIMITS, _("Show page limits"), wxDefaultPosition, wxDefaultSize, 2, m_Show_Page_LimitsStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer16->Add(m_Show_Page_Limits, 0, wxGROW|wxALL, 5); + + itemBoxSizer16->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxButton* itemButton20 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton20->SetForegroundColour(wxColour(202, 0, 0)); + itemBoxSizer16->Add(itemButton20, 0, wxGROW|wxALL, 5); + + wxButton* itemButton21 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton21->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer16->Add(itemButton21, 0, wxGROW|wxALL, 5); + + // Set validators + m_OptDisplayViaHole->SetValidator( wxGenericValidator(& DisplayOpt.m_DisplayViaMode) ); + m_OptDisplayModTexts->SetValidator( wxGenericValidator(& DisplayOpt.DisplayModText) ); + m_OptDisplayModEdges->SetValidator( wxGenericValidator(& DisplayOpt.DisplayModEdge) ); + m_OptDisplayPadClearence->SetValidator( wxGenericValidator(& DisplayOpt.DisplayPadIsol) ); + m_OptDisplayPadNumber->SetValidator( wxGenericValidator(& DisplayOpt.DisplayPadNum) ); + m_OptDisplayPadNoConn->SetValidator( wxGenericValidator(& DisplayOpt.DisplayPadNoConn) ); + m_OptDisplayDrawings->SetValidator( wxGenericValidator(& DisplayOpt.DisplayDrawItems) ); +////@end WinEDA_DisplayOptionsDialog content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_DisplayOptionsDialog::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_DisplayOptionsDialog::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_DisplayOptionsDialog bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_DisplayOptionsDialog bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_DisplayOptionsDialog::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_DisplayOptionsDialog icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_DisplayOptionsDialog icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_DisplayOptionsDialog::OnOkClick( wxCommandEvent& event ) +{ + AcceptPcbOptions(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_DisplayOptionsDialog::OnCancelClick( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_DisplayOptionsDialog. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_DisplayOptionsDialog. +} + + diff --git a/pcbnew/dialog_display_options.h b/pcbnew/dialog_display_options.h new file mode 100644 index 0000000000..852dc776b3 --- /dev/null +++ b/pcbnew/dialog_display_options.h @@ -0,0 +1,128 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_display_options.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 25/02/2006 18:43:49 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 25/02/2006 18:43:49 + +#ifndef _DIALOG_DISPLAY_OPTIONS_H_ +#define _DIALOG_DISPLAY_OPTIONS_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "dialog_display_options.h" +#endif + +/*! + * Includes + */ + +////@begin includes +#include "wx/valgen.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_DISPLAYOPTIONSDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_DISPLAYOPTIONSDIALOG_TITLE _("Display Options") +#define SYMBOL_WINEDA_DISPLAYOPTIONSDIALOG_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_DISPLAYOPTIONSDIALOG_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_DISPLAYOPTIONSDIALOG_POSITION wxDefaultPosition +#define ID_RADIOBOX_OPT_TRACK 10001 +#define ID_RADIOBOX_SHOWCLR 10002 +#define ID_RADIOBOX_SHOW_VIAS 10003 +#define ID_RADIOBOX_MODTXT 10004 +#define ID_RADIOBOX_MOD_EDGES 10005 +#define ID_RADIOBOX_SHOWPADS 10007 +#define ID_CHECKBOX_PAD_CLR 10008 +#define ID_CHECKBOX_PADNUM 10009 +#define ID_CHECKBOX_PADNC 10010 +#define ID_RADIOBOX_SHOW_OTHERS 10011 +#define ID_RADIOBOX_PAGE_LIMITS 10006 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_DisplayOptionsDialog class declaration + */ + +class WinEDA_DisplayOptionsDialog: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_DisplayOptionsDialog ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_DisplayOptionsDialog( ); + WinEDA_DisplayOptionsDialog( WinEDA_BasePcbFrame* parent, wxWindowID id = SYMBOL_WINEDA_DISPLAYOPTIONSDIALOG_IDNAME, const wxString& caption = SYMBOL_WINEDA_DISPLAYOPTIONSDIALOG_TITLE, const wxPoint& pos = SYMBOL_WINEDA_DISPLAYOPTIONSDIALOG_POSITION, const wxSize& size = SYMBOL_WINEDA_DISPLAYOPTIONSDIALOG_SIZE, long style = SYMBOL_WINEDA_DISPLAYOPTIONSDIALOG_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_DISPLAYOPTIONSDIALOG_IDNAME, const wxString& caption = SYMBOL_WINEDA_DISPLAYOPTIONSDIALOG_TITLE, const wxPoint& pos = SYMBOL_WINEDA_DISPLAYOPTIONSDIALOG_POSITION, const wxSize& size = SYMBOL_WINEDA_DISPLAYOPTIONSDIALOG_SIZE, long style = SYMBOL_WINEDA_DISPLAYOPTIONSDIALOG_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_DisplayOptionsDialog event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + +////@end WinEDA_DisplayOptionsDialog event handler declarations + +////@begin WinEDA_DisplayOptionsDialog member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_DisplayOptionsDialog member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + void AcceptPcbOptions(wxCommandEvent& event); + +////@begin WinEDA_DisplayOptionsDialog member variables + wxRadioBox* m_OptDisplayTracks; + wxRadioBox* m_OptDisplayTracksClearance; + wxRadioBox* m_OptDisplayViaHole; + wxRadioBox* m_OptDisplayModTexts; + wxRadioBox* m_OptDisplayModEdges; + wxRadioBox* m_OptDisplayPads; + wxCheckBox* m_OptDisplayPadClearence; + wxCheckBox* m_OptDisplayPadNumber; + wxCheckBox* m_OptDisplayPadNoConn; + wxRadioBox* m_OptDisplayDrawings; + wxRadioBox* m_Show_Page_Limits; +////@end WinEDA_DisplayOptionsDialog member variables + WinEDA_BasePcbFrame * m_Parent; +}; + +#endif + // _DIALOG_DISPLAY_OPTIONS_H_ diff --git a/pcbnew/dialog_display_options.rc b/pcbnew/dialog_display_options.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/pcbnew/dialog_display_options.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/pcbnew/dialog_drc.cpp b/pcbnew/dialog_drc.cpp new file mode 100644 index 0000000000..dc8a5565a5 --- /dev/null +++ b/pcbnew/dialog_drc.cpp @@ -0,0 +1,258 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_drc.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 27/02/2006 20:42:00 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 27/02/2006 20:42:00 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "dialog_drc.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes + +#include "dialog_drc.h" + +////@begin XPM images +////@end XPM images + +/*! + * WinEDA_DrcFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_DrcFrame, wxDialog ) + +/*! + * WinEDA_DrcFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_DrcFrame, wxDialog ) + +////@begin WinEDA_DrcFrame event table entries + EVT_BUTTON( ID_DRC_RUN, WinEDA_DrcFrame::OnDrcRunClick ) + + EVT_BUTTON( ID_STOP_CONTROL_DRC, WinEDA_DrcFrame::OnStopControlDrcClick ) + + EVT_BUTTON( ID_ERASE_DRC_MARKERS, WinEDA_DrcFrame::OnEraseDrcMarkersClick ) + + EVT_BUTTON( ID_LIST_UNCONNECTED_PADS, WinEDA_DrcFrame::OnListUnconnectedPadsClick ) + + EVT_BUTTON( wxID_CLOSE, WinEDA_DrcFrame::OnCloseClick ) + +////@end WinEDA_DrcFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_DrcFrame constructors + */ + +WinEDA_DrcFrame::WinEDA_DrcFrame( ) +{ +} + +WinEDA_DrcFrame::WinEDA_DrcFrame( WinEDA_PcbFrame* parent, wxDC * panelDC, + wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + m_DC = panelDC; + AbortDrc = FALSE; + + Create(parent, id, caption, pos, size, style); + + PutValueInLocalUnits(*m_SetClearance, g_DesignSettings.m_TrackClearence, + m_Parent->m_InternalUnits); +} + +/*! + * WinEDA_DrcFrame creator + */ + +bool WinEDA_DrcFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_DrcFrame member initialisation + m_MainSizer = NULL; + m_CommandSizer = NULL; + m_ClearenceTitle = NULL; + m_SetClearance = NULL; + m_logWindow = NULL; +////@end WinEDA_DrcFrame member initialisation + +////@begin WinEDA_DrcFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_DrcFrame creation + return true; +} + +/*! + * Control creation for WinEDA_DrcFrame + */ + +void WinEDA_DrcFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_DrcFrame content construction + // Generated by DialogBlocks, 27/02/2006 21:15:33 (unregistered) + + WinEDA_DrcFrame* itemDialog1 = this; + + m_MainSizer = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(m_MainSizer); + + m_CommandSizer = new wxBoxSizer(wxHORIZONTAL); + m_MainSizer->Add(m_CommandSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL); + m_CommandSizer->Add(itemBoxSizer4, 0, wxGROW|wxALL, 5); + + m_ClearenceTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Clearance"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer4->Add(m_ClearenceTitle, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_SetClearance = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer4->Add(m_SetClearance, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxHORIZONTAL); + m_CommandSizer->Add(itemBoxSizer7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer7->Add(itemBoxSizer8, 0, wxGROW|wxALL, 5); + + wxButton* itemButton9 = new wxButton( itemDialog1, ID_DRC_RUN, _("Test Drc"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton9->SetForegroundColour(wxColour(202, 0, 0)); + itemBoxSizer8->Add(itemButton9, 0, wxGROW|wxALL, 5); + + wxButton* itemButton10 = new wxButton( itemDialog1, ID_STOP_CONTROL_DRC, _("Stop Drc"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton10->SetForegroundColour(wxColour(0, 128, 128)); + itemBoxSizer8->Add(itemButton10, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer7->Add(itemBoxSizer11, 0, wxGROW|wxALL, 5); + + wxButton* itemButton12 = new wxButton( itemDialog1, ID_ERASE_DRC_MARKERS, _("Del Markers"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton12->SetForegroundColour(wxColour(0, 128, 0)); + itemBoxSizer11->Add(itemButton12, 0, wxGROW|wxALL, 5); + + wxButton* itemButton13 = new wxButton( itemDialog1, ID_LIST_UNCONNECTED_PADS, _("List Unconn"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton13->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer11->Add(itemButton13, 0, wxGROW|wxALL, 5); + + wxButton* itemButton14 = new wxButton( itemDialog1, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer11->Add(itemButton14, 0, wxGROW|wxALL, 5); + + wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, wxID_STATIC, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_MainSizer->Add(itemStaticText15, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_logWindow = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(-1, 200), wxTE_MULTILINE|wxTE_READONLY ); + m_MainSizer->Add(m_logWindow, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + +////@end WinEDA_DrcFrame content construction + + AddUnitSymbol(*m_ClearenceTitle); +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_DrcFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_DrcFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_DrcFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_DrcFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_DrcFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_DrcFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_DrcFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DRC_RUN + */ + +void WinEDA_DrcFrame::OnDrcRunClick( wxCommandEvent& event ) +{ + TestDrc(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_STOP_CONTROL_DRC + */ + +void WinEDA_DrcFrame::OnStopControlDrcClick( wxCommandEvent& event ) +{ + if ( DrcInProgress ) AbortDrc = TRUE; + else wxBell(); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERASE_DRC_MARKERS + */ + +void WinEDA_DrcFrame::OnEraseDrcMarkersClick( wxCommandEvent& event ) +{ + DelDRCMarkers(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_LIST_UNCONNECTED_PADS + */ + +void WinEDA_DrcFrame::OnListUnconnectedPadsClick( wxCommandEvent& event ) +{ + ListUnconnectedPads(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + */ + +void WinEDA_DrcFrame::OnCloseClick( wxCommandEvent& event ) +{ + Close(); +} + + diff --git a/pcbnew/dialog_drc.h b/pcbnew/dialog_drc.h new file mode 100644 index 0000000000..c519a0395a --- /dev/null +++ b/pcbnew/dialog_drc.h @@ -0,0 +1,131 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_drc.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 27/02/2006 20:42:00 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 27/02/2006 20:42:00 + +#ifndef _DIALOG_DRC_H_ +#define _DIALOG_DRC_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "dialog_drc.h" +#endif + +/*! + * Includes + */ + +////@begin includes +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +class wxBoxSizer; +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_DRCFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_DRCFRAME_TITLE _("DRC Control") +#define SYMBOL_WINEDA_DRCFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_DRCFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_DRCFRAME_POSITION wxDefaultPosition +#define ID_TEXTCTRL1 10002 +#define ID_DRC_RUN 10003 +#define ID_STOP_CONTROL_DRC 10004 +#define ID_ERASE_DRC_MARKERS 10005 +#define ID_LIST_UNCONNECTED_PADS 10006 +#define ID_TEXTCTRL 10001 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_DrcFrame class declaration + */ + +class WinEDA_DrcFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_DrcFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_DrcFrame( ); + WinEDA_DrcFrame( WinEDA_PcbFrame* parent, wxDC * panelDC, + wxWindowID id = SYMBOL_WINEDA_DRCFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_DRCFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_DRCFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_DRCFRAME_SIZE, long style = SYMBOL_WINEDA_DRCFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_DRCFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_DRCFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_DRCFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_DRCFRAME_SIZE, long style = SYMBOL_WINEDA_DRCFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_DrcFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DRC_RUN + void OnDrcRunClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_STOP_CONTROL_DRC + void OnStopControlDrcClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERASE_DRC_MARKERS + void OnEraseDrcMarkersClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_LIST_UNCONNECTED_PADS + void OnListUnconnectedPadsClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + void OnCloseClick( wxCommandEvent& event ); + +////@end WinEDA_DrcFrame event handler declarations + +////@begin WinEDA_DrcFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_DrcFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void TestDrc(wxCommandEvent & event); + void DelDRCMarkers(wxCommandEvent & event); + void ListUnconnectedPads(wxCommandEvent & event); + +////@begin WinEDA_DrcFrame member variables + wxBoxSizer* m_MainSizer; + wxBoxSizer* m_CommandSizer; + wxStaticText* m_ClearenceTitle; + wxTextCtrl* m_SetClearance; + wxTextCtrl* m_logWindow; +////@end WinEDA_DrcFrame member variables + WinEDA_PcbFrame * m_Parent; + wxDC * m_DC; +}; + +#endif + // _DIALOG_DRC_H_ diff --git a/pcbnew/dialog_edit_mod_text.cpp b/pcbnew/dialog_edit_mod_text.cpp new file mode 100644 index 0000000000..c600c61cb4 --- /dev/null +++ b/pcbnew/dialog_edit_mod_text.cpp @@ -0,0 +1,390 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: edtxtmod.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 09/02/2006 18:17:15 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 09/02/2006 18:17:15 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "edtxtmod.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "dialog_edit_mod_text.h" + +extern wxPoint MoveVector; // Move vector for move edge, imported from dialog_edit mod_text.cpp + +////@begin XPM images +////@end XPM images + +/***************************************************************************/ +void WinEDA_BasePcbFrame::InstallTextModOptionsFrame(TEXTE_MODULE * TextMod, + wxDC * DC, const wxPoint & pos) +/***************************************************************************/ +{ + DrawPanel->m_IgnoreMouseEvents = TRUE; + WinEDA_TextModPropertiesFrame * frame = new WinEDA_TextModPropertiesFrame(this, + TextMod, DC); + frame->ShowModal(); frame->Destroy(); + DrawPanel->MouseToCursorSchema(); + DrawPanel->m_IgnoreMouseEvents = FALSE; +} + +/*! + * WinEDA_TextModPropertiesFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_TextModPropertiesFrame, wxDialog ) + +/*! + * WinEDA_TextModPropertiesFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_TextModPropertiesFrame, wxDialog ) + +////@begin WinEDA_TextModPropertiesFrame event table entries + EVT_BUTTON( wxID_OK, WinEDA_TextModPropertiesFrame::OnOkClick ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_TextModPropertiesFrame::OnCancelClick ) + +////@end WinEDA_TextModPropertiesFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_TextModPropertiesFrame constructors + */ + +WinEDA_TextModPropertiesFrame::WinEDA_TextModPropertiesFrame( ) +{ +} + +WinEDA_TextModPropertiesFrame::WinEDA_TextModPropertiesFrame( WinEDA_BasePcbFrame* parent, + TEXTE_MODULE * TextMod,wxDC * DC, + wxWindowID id, const wxString& caption, const wxPoint& pos, + const wxSize& size, long style ) +{ + m_Parent = parent; + m_DC = DC; + m_Module = NULL; + m_CurrentTextMod = TextMod; + if ( m_CurrentTextMod ) + { + m_Module = (MODULE*)m_CurrentTextMod->m_Parent; + } + + Create(parent, id, caption, pos, size, style); + +} + +/*! + * WinEDA_TextModPropertiesFrame creator + */ + +bool WinEDA_TextModPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_TextModPropertiesFrame member initialisation + m_ModuleInfoText = NULL; + m_TextDataTitle = NULL; + m_Name = NULL; + m_SizeXTitle = NULL; + m_TxtSizeCtrlX = NULL; + m_SizeYTitle = NULL; + m_TxtSizeCtrlY = NULL; + m_PosXTitle = NULL; + m_TxtPosCtrlX = NULL; + m_PosYTitle = NULL; + m_TxtPosCtrlY = NULL; + m_WidthTitle = NULL; + m_TxtWidthCtlr = NULL; + m_Orient = NULL; + m_Show = NULL; +////@end WinEDA_TextModPropertiesFrame member initialisation + +////@begin WinEDA_TextModPropertiesFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_TextModPropertiesFrame creation + return true; +} + +/*! + * Control creation for WinEDA_TextModPropertiesFrame + */ + +void WinEDA_TextModPropertiesFrame::CreateControls() +{ + SetFont(*g_DialogFont); +////@begin WinEDA_TextModPropertiesFrame content construction + // Generated by DialogBlocks, 09/02/2006 19:51:49 (unregistered) + + WinEDA_TextModPropertiesFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + + m_ModuleInfoText = new wxStaticText( itemDialog1, wxID_STATIC, _("Module %s (%s) orient %.1f"), wxDefaultPosition, wxDefaultSize, 0 ); + m_ModuleInfoText->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer2->Add(m_ModuleInfoText, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxADJUST_MINSIZE, 5); + + wxStaticLine* itemStaticLine4 = new wxStaticLine( itemDialog1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + itemBoxSizer2->Add(itemStaticLine4, 0, wxGROW|wxALL, 5); + + m_TextDataTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Reference:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add(m_TextDataTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_Name = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add(m_Name, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer2->Add(itemBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer7->Add(itemBoxSizer8, 0, wxGROW|wxALL, 5); + + m_SizeXTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Size X"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer8->Add(m_SizeXTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_TxtSizeCtrlX = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer8->Add(m_TxtSizeCtrlX, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_SizeYTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Size Y"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer8->Add(m_SizeYTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_TxtSizeCtrlY = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer8->Add(m_TxtSizeCtrlY, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + itemBoxSizer8->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + m_PosXTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Offset X"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer8->Add(m_PosXTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_TxtPosCtrlX = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer8->Add(m_TxtPosCtrlX, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_PosYTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Offset Y"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer8->Add(m_PosYTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_TxtPosCtrlY = new wxTextCtrl( itemDialog1, ID_TEXTCTRL4, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer8->Add(m_TxtPosCtrlY, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer7->Add(itemBoxSizer18, 0, wxGROW|wxALL, 5); + + m_WidthTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Width"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer18->Add(m_WidthTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_TxtWidthCtlr = new wxTextCtrl( itemDialog1, ID_TEXTCTRL5, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer18->Add(m_TxtWidthCtlr, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer21 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer7->Add(itemBoxSizer21, 0, wxGROW|wxALL, 5); + + wxButton* itemButton22 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton22->SetForegroundColour(wxColour(198, 0, 0)); + itemBoxSizer21->Add(itemButton22, 0, wxGROW|wxALL, 5); + + wxButton* itemButton23 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton23->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer21->Add(itemButton23, 0, wxGROW|wxALL, 5); + + wxString m_OrientStrings[] = { + _("horiz"), + _("vertical") + }; + m_Orient = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Orientation"), wxDefaultPosition, wxDefaultSize, 2, m_OrientStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer21->Add(m_Orient, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxString m_ShowStrings[] = { + _("show"), + _("no show") + }; + m_Show = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Display"), wxDefaultPosition, wxDefaultSize, 2, m_ShowStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer21->Add(m_Show, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + +////@end WinEDA_TextModPropertiesFrame content construction + + /* Setup titles and datas */ + SetDisplayValue(); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_TextModPropertiesFrame::OnOkClick( wxCommandEvent& event ) +{ + TextModPropertiesAccept(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_TextModPropertiesFrame::OnCancelClick( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_TextModPropertiesFrame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_TextModPropertiesFrame. +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_TextModPropertiesFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_TextModPropertiesFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_TextModPropertiesFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_TextModPropertiesFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_TextModPropertiesFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_TextModPropertiesFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_TextModPropertiesFrame icon retrieval +} + +/********************************************************/ +void WinEDA_TextModPropertiesFrame::SetDisplayValue(void) +/********************************************************/ +{ +wxString msg; + + if ( m_Module ) + { + wxString format = m_ModuleInfoText->GetLabel(); + msg.Printf( format, + m_Module->m_Reference->m_Text.GetData(), + m_Module->m_Value->m_Text.GetData(), + (float)(m_Module->m_Orient/10) ); + m_ModuleInfoText->SetLabel(msg); + } + + if(m_CurrentTextMod->m_Type == TEXT_is_VALUE) m_TextDataTitle->SetLabel(_("Value:")); + else if(m_CurrentTextMod->m_Type == TEXT_is_DIVERS) m_TextDataTitle->SetLabel(_("Text:")); + else if(m_CurrentTextMod->m_Type != TEXT_is_REFERENCE) m_TextDataTitle->SetLabel(wxT("???")); + + m_Name->SetValue(m_CurrentTextMod->m_Text); + + AddUnitSymbol(*m_SizeXTitle); + PutValueInLocalUnits(*m_TxtSizeCtrlX, m_CurrentTextMod->m_Size.x, + m_Parent->m_InternalUnits); + + AddUnitSymbol(*m_SizeYTitle); + PutValueInLocalUnits(*m_TxtSizeCtrlY, m_CurrentTextMod->m_Size.y, + m_Parent->m_InternalUnits); + + AddUnitSymbol(*m_PosXTitle); + PutValueInLocalUnits(*m_TxtPosCtrlX, m_CurrentTextMod->m_Pos0.x, + m_Parent->m_InternalUnits); + + AddUnitSymbol(*m_PosYTitle); + PutValueInLocalUnits(*m_TxtPosCtrlY, m_CurrentTextMod->m_Pos0.y, + m_Parent->m_InternalUnits); + + AddUnitSymbol(*m_WidthTitle); + PutValueInLocalUnits(*m_TxtWidthCtlr, m_CurrentTextMod->m_Width, + m_Parent->m_InternalUnits); + + if ( (m_CurrentTextMod->m_Orient != 0) && (m_CurrentTextMod->m_Orient != 1800) && + (m_CurrentTextMod->m_Orient != -1800) ) + m_Orient->SetSelection(1);; + + if ( m_CurrentTextMod->m_NoShow ) m_Show->SetSelection(1);; +} + +/*********************************************************************************/ +void WinEDA_TextModPropertiesFrame::TextModPropertiesAccept(wxCommandEvent& event) +/*********************************************************************************/ +{ +wxString msg; + + m_Parent->SaveCopyInUndoList(m_Parent->m_Pcb->m_Modules); + if ( m_DC ) // Effacement ancien texte + { + m_CurrentTextMod->Draw(m_Parent->DrawPanel, m_DC, + (m_CurrentTextMod->m_Flags & IS_MOVED) ? MoveVector : wxPoint(0,0), GR_XOR ); + } + m_CurrentTextMod->m_Text = m_Name->GetValue(); + + msg = m_TxtPosCtrlX->GetValue(); + m_CurrentTextMod->m_Pos0.x = ReturnValueFromString(g_UnitMetric, msg, + m_Parent->m_InternalUnits); + msg = m_TxtPosCtrlY->GetValue(); + m_CurrentTextMod->m_Pos0.y = ReturnValueFromString(g_UnitMetric, msg, + m_Parent->m_InternalUnits); + + msg = m_TxtSizeCtrlX->GetValue(); + m_CurrentTextMod->m_Size.x = ReturnValueFromString(g_UnitMetric, msg, + m_Parent->m_InternalUnits); + msg = m_TxtSizeCtrlY->GetValue(); + m_CurrentTextMod->m_Size.y = ReturnValueFromString(g_UnitMetric, msg, + m_Parent->m_InternalUnits); + + msg = m_TxtWidthCtlr->GetValue(); + m_CurrentTextMod->SetWidth( ReturnValueFromString(g_UnitMetric, msg, + m_Parent->m_InternalUnits) ); + + m_CurrentTextMod->m_NoShow = (m_Show->GetSelection() == 0) ? 0 : 1; + m_CurrentTextMod->m_Orient = (m_Orient->GetSelection() == 0) ? 0 : 900; + m_CurrentTextMod->SetDrawCoord(); + if ( m_DC ) // Affichage nouveau texte + { + m_CurrentTextMod->Draw(m_Parent->DrawPanel, m_DC, + (m_CurrentTextMod->m_Flags & IS_MOVED) ? MoveVector : wxPoint(0,0), GR_XOR ); + } + m_Parent->GetScreen()->SetModify(); + ((MODULE*)m_CurrentTextMod->m_Parent)->m_LastEdit_Time = time(NULL); + Close(TRUE); +} + diff --git a/pcbnew/dialog_edit_mod_text.h b/pcbnew/dialog_edit_mod_text.h new file mode 100644 index 0000000000..aa0b6589ef --- /dev/null +++ b/pcbnew/dialog_edit_mod_text.h @@ -0,0 +1,136 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: edtxtmod.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 09/02/2006 18:17:15 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 09/02/2006 18:17:15 + +#ifndef _EDTXTMOD_H_ +#define _EDTXTMOD_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "edtxtmod.h" +#endif + +/*! + * Includes + */ + +////@begin includes +#include "wx/statline.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_TEXTMODPROPERTIESFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_TEXTMODPROPERTIESFRAME_TITLE _("TextMod properties") +#define SYMBOL_WINEDA_TEXTMODPROPERTIESFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_TEXTMODPROPERTIESFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_TEXTMODPROPERTIESFRAME_POSITION wxDefaultPosition +#define ID_TEXTCTRL 10003 +#define ID_TEXTCTRL1 10004 +#define ID_TEXTCTRL2 10005 +#define ID_TEXTCTRL3 10006 +#define ID_TEXTCTRL4 10007 +#define ID_TEXTCTRL5 10008 +#define ID_RADIOBOX 10001 +#define ID_RADIOBOX1 10002 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_TextModPropertiesFrame class declaration + */ + +class WinEDA_TextModPropertiesFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_TextModPropertiesFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_TextModPropertiesFrame( ); + WinEDA_TextModPropertiesFrame( WinEDA_BasePcbFrame* parent, + TEXTE_MODULE * TextMod,wxDC * DC, + wxWindowID id = SYMBOL_WINEDA_TEXTMODPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_TEXTMODPROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_TEXTMODPROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_TEXTMODPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_TEXTMODPROPERTIESFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_TEXTMODPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_TEXTMODPROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_TEXTMODPROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_TEXTMODPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_TEXTMODPROPERTIESFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_TextModPropertiesFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + +////@end WinEDA_TextModPropertiesFrame event handler declarations + +////@begin WinEDA_TextModPropertiesFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_TextModPropertiesFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + void TextModPropertiesAccept(wxCommandEvent& event); + void SetDisplayValue(void); + +////@begin WinEDA_TextModPropertiesFrame member variables + wxStaticText* m_ModuleInfoText; + wxStaticText* m_TextDataTitle; + wxTextCtrl* m_Name; + wxStaticText* m_SizeXTitle; + wxTextCtrl* m_TxtSizeCtrlX; + wxStaticText* m_SizeYTitle; + wxTextCtrl* m_TxtSizeCtrlY; + wxStaticText* m_PosXTitle; + wxTextCtrl* m_TxtPosCtrlX; + wxStaticText* m_PosYTitle; + wxTextCtrl* m_TxtPosCtrlY; + wxStaticText* m_WidthTitle; + wxTextCtrl* m_TxtWidthCtlr; + wxRadioBox* m_Orient; + wxRadioBox* m_Show; +////@end WinEDA_TextModPropertiesFrame member variables + + WinEDA_BasePcbFrame * m_Parent; + wxDC * m_DC; + MODULE * m_Module; + TEXTE_MODULE * m_CurrentTextMod; +}; + +#endif + // _EDTXTMOD_H_ diff --git a/pcbnew/dialog_edit_module.cpp b/pcbnew/dialog_edit_module.cpp new file mode 100644 index 0000000000..a200d05415 --- /dev/null +++ b/pcbnew/dialog_edit_module.cpp @@ -0,0 +1,751 @@ + /************************************************/ + /* Module editor: Dialog box for editing module */ + /* properties and carateristics */ + /* include in modedit.cpp */ + /************************************************/ + +#include "dialog_edit_module.h" + + /**************************************/ + /* class WinEDA_ModulePropertiesFrame */ + /**************************************/ + +BEGIN_EVENT_TABLE(WinEDA_ModulePropertiesFrame, wxDialog) + EVT_BUTTON(ID_ACCEPT_MODULE_PROPERTIES, + WinEDA_ModulePropertiesFrame::ModulePropertiesAccept) + EVT_BUTTON(ID_CLOSE_MODULE_PROPERTIES, WinEDA_ModulePropertiesFrame::OnQuit) + EVT_BUTTON(ID_MODULE_EDIT_ADD_TEXT, WinEDA_ModulePropertiesFrame::CreateTextModule) + EVT_BUTTON(ID_MODULE_EDIT_EDIT_TEXT, WinEDA_ModulePropertiesFrame::EditOrDelTextModule) + EVT_BUTTON(ID_MODULE_EDIT_DELETE_TEXT, WinEDA_ModulePropertiesFrame::EditOrDelTextModule) + EVT_BUTTON(ID_MODULE_PROPERTIES_EXCHANGE, WinEDA_ModulePropertiesFrame::ExchangeModule) + EVT_KICAD_CHOICEBOX(ID_MODULE_LISTBOX_SELECT, WinEDA_ModulePropertiesFrame::SelectTextListBox) + EVT_RADIOBOX(ID_LISTBOX_ORIENT_SELECT, WinEDA_ModulePropertiesFrame::ModuleOrientEvent) + EVT_BUTTON(ID_GOTO_MODULE_EDITOR, WinEDA_ModulePropertiesFrame::GotoModuleEditor) + +END_EVENT_TABLE() + +/**********************/ +/* class Panel3D_Ctrl */ +/**********************/ +BEGIN_EVENT_TABLE(Panel3D_Ctrl, wxPanel) + EVT_BUTTON(ID_BROWSE_3D_LIB, Panel3D_Ctrl::Browse3DLib) + EVT_BUTTON(ID_ADD_3D_SHAPE, Panel3D_Ctrl::AddOrRemove3DShape) + EVT_BUTTON(ID_REMOVE_3D_SHAPE, Panel3D_Ctrl::AddOrRemove3DShape) +END_EVENT_TABLE() + + +#define H_SIZE 430 +#define V_SIZE 530 +/**************************************************************************************/ +WinEDA_ModulePropertiesFrame::WinEDA_ModulePropertiesFrame(WinEDA_BasePcbFrame *parent, + MODULE * Module,wxDC * DC, + const wxPoint & framepos): + wxDialog(parent, -1, _("Module properties"), framepos, + wxSize(H_SIZE, V_SIZE), DIALOG_STYLE) +/**************************************************************************************/ +{ +wxString number; + + SetIcon( wxICON(icon_modedit) ); // Give an icon + + m_Parent = parent; + SetFont(*g_DialogFont); + m_DC = DC; + + m_LayerCtrl = NULL; + m_OrientCtrl = NULL; + m_OrientValue = NULL; + m_Doc = m_Keyword = NULL; + + m_CurrentModule = Module; + m_DeleteFieddButton = NULL; + + if ( m_CurrentModule ) + { + } + + CreateControls(); + + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +} + +/*****************************************************/ +void WinEDA_ModulePropertiesFrame::CreateControls(void) +/*****************************************************/ +{ +wxPoint pos; +wxButton * Button; +wxSize usize; +bool FullOptions = FALSE; + + if ( m_Parent->m_Ident == PCB_FRAME ) FullOptions = TRUE; + + usize = GetClientSize(); + + m_GeneralBoxSizer = new wxBoxSizer(wxVERTICAL); + SetSizer(m_GeneralBoxSizer); + + m_NoteBook = new wxNotebook(this, ID_NOTEBOOK, + wxDefaultPosition,wxSize(usize.x,usize.y - 34) ); + m_NoteBook->SetFont(*g_DialogFont); + + m_GeneralBoxSizer->Add(m_NoteBook, 0, wxGROW|wxALL, 5); + + // Add panels + m_PanelProperties = new wxPanel(m_NoteBook, -1); + m_PanelProperties->SetFont(*g_DialogFont); + m_PanelPropertiesBoxSizer = new wxBoxSizer(wxHORIZONTAL); + m_PanelProperties->SetSizer(m_PanelPropertiesBoxSizer); + BuildPanelModuleProperties(FullOptions); + m_NoteBook->AddPage(m_PanelProperties, _("Properties"), TRUE); + + m_Panel3D = new Panel3D_Ctrl(this, m_NoteBook, -1, + m_CurrentModule->m_3D_Drawings); + m_NoteBook->AddPage(m_Panel3D, _("3D settings"), FALSE); + + /* creation des autres formes 3D */ + Panel3D_Ctrl * panel3D = m_Panel3D, * nextpanel3D; + Struct3D_Master *draw3D = m_CurrentModule->m_3D_Drawings; + draw3D = (Struct3D_Master *) draw3D->Pnext; + for ( ; draw3D != NULL; draw3D = (Struct3D_Master *) draw3D->Pnext) + { + nextpanel3D = new Panel3D_Ctrl(this, m_NoteBook, -1, draw3D); + m_NoteBook->AddPage(nextpanel3D, _("3D settings"), FALSE); + panel3D->m_Pnext = nextpanel3D; + nextpanel3D->m_Pback = panel3D; + panel3D = nextpanel3D; + } + + + /* Creation des boutons de commande */ + wxBoxSizer* ButtonsBoxSizer = new wxBoxSizer(wxHORIZONTAL); + m_GeneralBoxSizer->Add(ButtonsBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + Button = new wxButton(this, ID_ACCEPT_MODULE_PROPERTIES, + _("Ok")); + Button->SetForegroundColour(*wxRED); + ButtonsBoxSizer->Add(Button, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + Button = new wxButton(this, ID_CLOSE_MODULE_PROPERTIES, + _("Cancel")); + Button->SetForegroundColour(*wxBLUE); + ButtonsBoxSizer->Add(Button, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); +} + +/***********************************************************/ +void Panel3D_Ctrl::AddOrRemove3DShape(wxCommandEvent& event) +/***********************************************************/ +{ + if( event.GetId() == ID_ADD_3D_SHAPE) + { + Panel3D_Ctrl * panel3D = new Panel3D_Ctrl(m_ParentFrame, m_Parent, + -1, NULL); + m_Parent->InsertPage(m_Parent->GetSelection()+1, + panel3D, _("3D settings"), TRUE); + panel3D->m_Pback = this; + panel3D->m_Pnext = m_Pnext; + if ( m_Pnext ) m_Pnext->m_Pback = panel3D; + m_Pnext = panel3D; + } + + if( event.GetId() == ID_REMOVE_3D_SHAPE) + { + if ( m_Pback ) + { + m_Pback->m_Pnext = m_Pnext; + if ( m_Pnext ) m_Pnext->m_Pback = m_Pback; + m_Parent->DeletePage(m_Parent->GetSelection()); + m_ParentFrame->Refresh(TRUE); + } + } +} + +/***************************************************************************/ +void WinEDA_ModulePropertiesFrame::BuildPanelModuleProperties(bool FullOptions) +/***************************************************************************/ +/* creation du panel d'edition des proprietes du module +*/ +{ +wxButton * Button; +wxStaticText* StaticText; +wxBoxSizer* PropLeftSizer; +wxBoxSizer* PropRightSizer; +wxString msg; + + /* Create a sizer for controls in the left column */ + PropLeftSizer = new wxBoxSizer(wxVERTICAL); + m_PanelPropertiesBoxSizer->Add(PropLeftSizer, 0, wxGROW|wxALL, 5); + /* Create a sizer for controls in the right column */ + PropRightSizer = new wxBoxSizer(wxVERTICAL); + m_PanelPropertiesBoxSizer->Add(PropRightSizer, 0, wxGROW|wxALL, 5); + + if ( FullOptions ) // Edition du module su le C.I. + { + Button = new wxButton(m_PanelProperties, ID_MODULE_PROPERTIES_EXCHANGE, + _("Change module(s)")); + Button->SetForegroundColour(wxColor(80,40,0)); + PropRightSizer->Add(Button, 0, wxGROW|wxALL, 5); + Button = new wxButton(m_PanelProperties, ID_GOTO_MODULE_EDITOR, + _("Goto Module Editor")); + Button->SetForegroundColour(wxColor(0,128,80) ); + PropRightSizer->Add(Button, 0, wxGROW|wxALL, 5); + } + else // Edition du module en librairie + { + StaticText = new wxStaticText( m_PanelProperties, wxID_STATIC, _("Doc"), wxDefaultPosition, wxDefaultSize, 0 ); + PropLeftSizer->Add(StaticText, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + m_Doc = new wxTextCtrl(m_PanelProperties, -1, + m_CurrentModule->m_Doc); + PropLeftSizer->Add(m_Doc, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + StaticText = new wxStaticText( m_PanelProperties, wxID_STATIC, _("Keywords"), wxDefaultPosition, wxDefaultSize, 0 ); + PropLeftSizer->Add(StaticText, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + m_Keyword = new wxTextCtrl(m_PanelProperties, -1, + m_CurrentModule->m_KeyWord ); + PropLeftSizer->Add(m_Keyword, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + } + + wxStaticBox * box = new wxStaticBox(m_PanelProperties, -1, _("Fields:")); + m_TextListBox = new WinEDAChoiceBox(m_PanelProperties, ID_MODULE_LISTBOX_SELECT ); + ReCreateFieldListBox(); + m_TextListBox->SetSelection(0); + + wxStaticBoxSizer* StaticBoxSizer = new wxStaticBoxSizer(box, wxVERTICAL); + PropLeftSizer->Add(StaticBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + StaticBoxSizer->Add(m_TextListBox, 0, wxGROW|wxALL, 5); + + Button = new wxButton(m_PanelProperties, ID_MODULE_EDIT_ADD_TEXT, + _("Add Field")); + Button->SetForegroundColour(*wxBLACK); + StaticBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); + + Button = new wxButton(m_PanelProperties, ID_MODULE_EDIT_EDIT_TEXT, + _("Edit Field")); + Button->SetForegroundColour(*wxBLACK); + StaticBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT, 5); + + m_DeleteFieddButton = Button = new wxButton(m_PanelProperties, ID_MODULE_EDIT_DELETE_TEXT, + _("Delete Field")); + m_DeleteFieddButton->SetForegroundColour(*wxBLACK); + m_DeleteFieddButton->Enable(FALSE); // Enable pour fields autres que ref et valeur + StaticBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + if ( FullOptions ) + { + wxString layer_list[2] = { _("Componant"), _("Copper") }; + m_LayerCtrl = new wxRadioBox( m_PanelProperties, -1, _("Layer"), wxDefaultPosition, + wxSize(-1,-1), 2, layer_list, 1); + m_LayerCtrl->SetSelection( (m_CurrentModule->m_Layer == CUIVRE_N) ? 1 : 0); + PropLeftSizer->Add(m_LayerCtrl, 0, wxGROW|wxALL, 5); + + bool select = FALSE; + wxString orient_list[5] = { + _("Normal"), wxT("+ 90.0"), wxT("- 90.0"), wxT("180.0"), _("User") }; + m_OrientCtrl = new wxRadioBox( m_PanelProperties, ID_LISTBOX_ORIENT_SELECT, _("Orient"), + wxDefaultPosition, wxSize(-1,-1), 5, orient_list, 1); + PropLeftSizer->Add(m_OrientCtrl, 0, wxGROW|wxALL, 5); + + switch (m_CurrentModule->m_Orient) + { + case 0: + m_OrientCtrl->SetSelection( 0 ); + break; + + case 900: + case -2700: + m_OrientCtrl->SetSelection( 1 ); + break; + + case -900: + case 2700: + m_OrientCtrl->SetSelection( 2 ); + break; + + case -1800: + case 1800: + m_OrientCtrl->SetSelection( 3 ); + break; + + default: + m_OrientCtrl->SetSelection( 4 ); + select = TRUE; + break; + } + + StaticText = new wxStaticText( m_PanelProperties, + wxID_STATIC, _("Orient (0.1 deg)"), wxDefaultPosition, wxDefaultSize, 0 ); + PropLeftSizer->Add(StaticText, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + msg << m_CurrentModule->m_Orient; + m_OrientValue = new wxTextCtrl(m_PanelProperties, -1, msg); + m_OrientValue->Enable(select); + PropLeftSizer->Add(m_OrientValue, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + } + + /* Controls on right side of the dialog */ +wxString attribut_list[3] = { _("Normal"), _("Normal+Insert"), _("Virtual") }; + m_AttributsCtrl = new wxRadioBox( m_PanelProperties, -1, _("Attributs"), wxDefaultPosition, + wxSize(-1,-1), 3, attribut_list, 1); + PropRightSizer->Add(m_AttributsCtrl, 0, wxGROW|wxALL, 5); + + switch (m_CurrentModule->m_Attributs & 255) + { + case 0: + m_AttributsCtrl->SetSelection( 0 ); + break; + + case MOD_CMS: + m_AttributsCtrl->SetSelection( 1 ); + break; + + case MOD_VIRTUAL: + m_AttributsCtrl->SetSelection( 2 ); + break; + + default: + m_AttributsCtrl->SetSelection( 0 ); + break; + } + + +wxString autoplace_list[2] = { _("Free"), _("Locked")}; + m_AutoPlaceCtrl = new wxRadioBox( m_PanelProperties, -1, _("Auto Place"), wxDefaultPosition, + wxSize(-1,-1), 2, autoplace_list, 1); + m_AutoPlaceCtrl->SetSelection( + (m_CurrentModule->m_ModuleStatus & MODULE_is_LOCKED) ? 1 : 0); + PropRightSizer->Add(m_AutoPlaceCtrl, 0, wxGROW|wxALL, 5); + + StaticText = new wxStaticText(m_PanelProperties, -1, _("Rot 90")); + PropRightSizer->Add(StaticText, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + m_CostRot90Ctrl = new wxSlider(m_PanelProperties, -1, + m_CurrentModule->m_CntRot90, 0, 10, wxDefaultPosition, wxSize(100, -1), + wxSL_HORIZONTAL + wxSL_AUTOTICKS + wxSL_LABELS) ; + PropRightSizer->Add(m_CostRot90Ctrl, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + StaticText = new wxStaticText(m_PanelProperties, -1, _("Rot 180")); + PropRightSizer->Add(StaticText, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + m_CostRot180Ctrl= new wxSlider(m_PanelProperties, -1, + m_CurrentModule->m_CntRot180, 0, 10, wxDefaultPosition, wxSize(100, -1), + wxSL_HORIZONTAL + wxSL_AUTOTICKS + wxSL_LABELS) ; + PropRightSizer->Add(m_CostRot180Ctrl, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); +} + +/**************************************************************/ +Panel3D_Ctrl::Panel3D_Ctrl(WinEDA_ModulePropertiesFrame * parentframe, + wxNotebook * parent, + int id, Struct3D_Master * struct3D): + wxPanel(parent, id) +/**************************************************************/ +/* create the dialog panel managing 3D shape infos +*/ +{ +wxButton * button; +S3D_Vertex dummy_vertex; +wxBoxSizer* PropLeftSizer; +wxBoxSizer* PropRightSizer; + + m_Pnext = m_Pback = NULL; + + m_Parent = parent; + m_ParentFrame = parentframe; + SetFont(*g_DialogFont); + wxBoxSizer * Panel3DBoxSizer = new wxBoxSizer(wxVERTICAL); + SetSizer(Panel3DBoxSizer); + + wxStaticText* StaticText = new wxStaticText( this, wxID_STATIC, _("3D Shape Name"), + wxDefaultPosition, wxDefaultSize, 0 ); + Panel3DBoxSizer->Add(StaticText, 0, wxGROW|wxALL|wxADJUST_MINSIZE, 5); + m_3D_ShapeName = new wxTextCtrl(this, -1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + if ( struct3D ) m_3D_ShapeName->SetValue(struct3D->m_Shape3DName); + Panel3DBoxSizer->Add(m_3D_ShapeName, 0, wxGROW|wxALL, 5); + + wxBoxSizer * LowerBoxSizer = new wxBoxSizer(wxHORIZONTAL); + Panel3DBoxSizer->Add(LowerBoxSizer, 0, wxGROW|wxALL, 5); + /* Create a sizer for controls in the left column */ + PropLeftSizer = new wxBoxSizer(wxVERTICAL); + LowerBoxSizer->Add(PropLeftSizer, 0, wxGROW|wxALL, 5); + /* Create a sizer for controls in the right column */ + PropRightSizer = new wxBoxSizer(wxVERTICAL); + LowerBoxSizer->Add(PropRightSizer, 0, wxGROW|wxALL, 5); + + button = new wxButton(this, ID_BROWSE_3D_LIB, _("Browse")); + button->SetForegroundColour(*wxBLUE); + PropRightSizer->Add(button, 0, wxGROW|wxLEFT|wxRIGHT, 5); + + button = new wxButton(this, ID_ADD_3D_SHAPE, _("Add 3D Shape")); + button->SetForegroundColour(*wxRED); + PropRightSizer->Add(button, 0, wxGROW|wxLEFT|wxRIGHT, 5); + + if ( (struct3D == NULL) || (struct3D->Pback != NULL) ) + { + button = new wxButton(this, ID_REMOVE_3D_SHAPE, _("Remove 3D Shape")); + button->SetForegroundColour(*wxRED); + PropRightSizer->Add(button, 0, wxGROW|wxLEFT|wxRIGHT, 5); + } + + wxBoxSizer * BoxSizer = new wxBoxSizer(wxVERTICAL); + m_3D_Scale = new WinEDA_VertexCtrl(this, _("Shape Scale:"), BoxSizer, + 2, 1); + if ( struct3D ) m_3D_Scale->SetValue(struct3D->m_MatScale); + PropLeftSizer->Add(BoxSizer, 0, wxGROW|wxALL, 5); + + BoxSizer = new wxBoxSizer(wxVERTICAL); + m_3D_Offset = new WinEDA_VertexCtrl(this, _("Shape Offset:"), BoxSizer, + 2, 1); + if ( struct3D ) m_3D_Offset->SetValue(struct3D->m_MatPosition); + else m_3D_Offset->SetValue(dummy_vertex); + PropLeftSizer->Add(BoxSizer, 0, wxGROW|wxALL, 5); + + BoxSizer = new wxBoxSizer(wxVERTICAL); + m_3D_Rotation = new WinEDA_VertexCtrl(this, _("Shape Rotation:"), BoxSizer, + 2, 1); + if ( struct3D ) m_3D_Rotation->SetValue(struct3D->m_MatRotation); + else m_3D_Rotation->SetValue(dummy_vertex); + PropLeftSizer->Add(BoxSizer, 0, wxGROW|wxALL, 5); + + if ( struct3D == NULL ) + { + dummy_vertex.x = dummy_vertex.y = dummy_vertex.z = 1.0; + m_3D_Scale->SetValue(dummy_vertex); + } +} + +/********************************/ +Panel3D_Ctrl::~Panel3D_Ctrl(void) +/********************************/ +{ + delete m_3D_ShapeName; + delete m_3D_Scale; + delete m_3D_Offset; + delete m_3D_Rotation; +} + + +/***************************************************/ +void Panel3D_Ctrl::Browse3DLib(wxCommandEvent& event) +/***************************************************/ +{ +wxString fullfilename, shortfilename; +wxString fullpath = g_RealLibDirBuffer; +wxString mask = wxT("*"); + + fullpath += LIB3D_PATH; + mask += g_Shapes3DExtBuffer; +#ifdef __WINDOWS__ + fullpath.Replace( wxT("/"), wxT("\\") ); +#endif + fullfilename = EDA_FileSelector( _("3D Shape:"), + fullpath, /* Chemin par defaut */ + wxEmptyString, /* nom fichier par defaut */ + g_Shapes3DExtBuffer, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_OPEN, + TRUE + ); + + if ( fullfilename == wxEmptyString ) return; + + shortfilename = MakeReducedFileName( fullfilename, + fullpath, wxEmptyString); + m_3D_ShapeName->SetValue(shortfilename); +} + + +/**********************************************************************/ +void WinEDA_ModulePropertiesFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/**********************************************************************/ +{ + Close(true); // true is to force the frame to close +} + + +/******************************************************************************/ +void WinEDA_ModulePropertiesFrame::ModulePropertiesAccept(wxCommandEvent& event) +/******************************************************************************/ +{ +bool change_layer = FALSE; + + if ( m_DC ) m_Parent->DrawPanel->CursorOff(m_DC); + + if ( m_DC ) + m_CurrentModule->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0), GR_XOR); + + if ( m_OrientValue ) + { + long orient = 0; wxString msg = m_OrientValue->GetValue(); + msg.ToLong(&orient); + if( m_CurrentModule->m_Orient != orient) + m_Parent->Rotate_Module(m_DC, m_CurrentModule, + orient, FALSE); + } + + if ( m_LayerCtrl ) + { + if ( m_LayerCtrl->GetSelection() == 0 ) // layer req = COMPONENT + { + if( m_CurrentModule->m_Layer == CUIVRE_N) change_layer = TRUE; + } + else if( m_CurrentModule->m_Layer == CMP_N ) change_layer = TRUE; + } + + if ( change_layer ) + { + m_Parent->Change_Side_Module(m_CurrentModule, m_DC); + } + + if (m_AutoPlaceCtrl->GetSelection() == 1) + m_CurrentModule->m_ModuleStatus |= MODULE_is_LOCKED; + else m_CurrentModule->m_ModuleStatus &= ~MODULE_is_LOCKED; + + switch (m_AttributsCtrl->GetSelection()) + { + case 0: + m_CurrentModule->m_Attributs = 0; + break; + + case 1: + m_CurrentModule->m_Attributs = MOD_CMS; + break; + + case 2: + m_CurrentModule->m_Attributs = MOD_VIRTUAL; + break; + } + + m_CurrentModule->m_CntRot90 = m_CostRot90Ctrl->GetValue(); + m_CurrentModule->m_CntRot180 = m_CostRot180Ctrl->GetValue(); + if ( m_Doc ) m_CurrentModule->m_Doc = m_Doc->GetValue(); + if ( m_Keyword ) m_CurrentModule->m_KeyWord = m_Keyword->GetValue(); + + /* Mise a jour des parametres 3D */ + Panel3D_Ctrl * panel3D = m_Panel3D; + Struct3D_Master *draw3D = m_CurrentModule->m_3D_Drawings, + * nextdraw3D; + for ( ; panel3D != NULL; panel3D = panel3D->m_Pnext ) + { + draw3D->m_Shape3DName = panel3D->m_3D_ShapeName->GetValue(); + draw3D->m_MatScale = panel3D->m_3D_Scale->GetValue(); + draw3D->m_MatRotation = panel3D->m_3D_Rotation->GetValue(); + draw3D->m_MatPosition = panel3D->m_3D_Offset->GetValue(); + if ( (draw3D->m_Shape3DName.IsEmpty() ) && + (draw3D != m_CurrentModule->m_3D_Drawings) ) + continue; + if ( (draw3D->Pnext == NULL) && panel3D->m_Pnext ) + { + nextdraw3D = new Struct3D_Master(draw3D); + nextdraw3D->Pback = draw3D; + draw3D->Pnext = nextdraw3D; + } + draw3D = (Struct3D_Master *) draw3D->Pnext; + } + + for ( ; draw3D != NULL; draw3D = nextdraw3D ) + { + nextdraw3D = (Struct3D_Master *)draw3D->Pnext; + (draw3D->Pback)->Pnext = NULL; + delete draw3D; + } + + + m_CurrentModule->Set_Rectangle_Encadrement(); + + m_Parent->GetScreen()->SetModify(); + + Close(TRUE); + + if ( m_DC ) + m_CurrentModule->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0), GR_OR); + if ( m_DC ) m_Parent->DrawPanel->CursorOn(m_DC); +} + + +/************************************************************************/ +void WinEDA_ModulePropertiesFrame::GotoModuleEditor(wxCommandEvent& event) +/************************************************************************/ +{ + GoToEditor = TRUE; + if ( m_CurrentModule->m_TimeStamp == 0 ) // Module Editor needs a non null timestamp + { + m_CurrentModule->m_TimeStamp = GetTimeStamp(); + m_Parent->GetScreen()->SetModify(); + } + + Close(TRUE); +} + + +/**********************************************************************/ +void WinEDA_ModulePropertiesFrame::ExchangeModule(wxCommandEvent& event) +/**********************************************************************/ +{ + m_Parent->InstallExchangeModuleFrame( m_CurrentModule, + m_DC, wxPoint(-1,-1) ); + // Attention: si il y a eu echange, m_CurrentModule a été delete! + m_Parent->GetScreen()->m_CurrentItem = NULL; + Close(TRUE); +} + + +/*************************************************************************/ +void WinEDA_ModulePropertiesFrame::ModuleOrientEvent(wxCommandEvent& event) +/*************************************************************************/ +{ + switch ( m_OrientCtrl->GetSelection() ) + { + case 0: + m_OrientValue->Enable(FALSE); + m_OrientValue->SetValue( wxT("0") ); + break; + + case 1: + m_OrientValue->Enable(FALSE); + m_OrientValue->SetValue( wxT("900") ); + break; + + case 2: + m_OrientValue->Enable(FALSE); + m_OrientValue->SetValue( wxT("2700") ); + break; + + case 3: + m_OrientValue->Enable(FALSE); + m_OrientValue->SetValue( wxT("1800") ); + break; + + default: + m_OrientValue->Enable(FALSE); + m_OrientValue->Enable(TRUE); + break; + } +} + + +/*************************************************************************/ +void WinEDA_ModulePropertiesFrame::SelectTextListBox(wxCommandEvent& event) +/*************************************************************************/ +{ + SetTextListButtons(); +} + +/*************************************************************************/ +void WinEDA_ModulePropertiesFrame::SetTextListButtons(void) +/*************************************************************************/ +{ +int choice = m_TextListBox->GetChoice(); + + if ( m_DeleteFieddButton == NULL ) return; + + if ( choice > 1 ) // Texte autre que ref ou valeur selectionne + { + m_DeleteFieddButton->Enable(TRUE); + } + else m_DeleteFieddButton->Enable(FALSE); +} + + +/***********************************************************/ +void WinEDA_ModulePropertiesFrame::ReCreateFieldListBox(void) +/***********************************************************/ +{ + m_TextListBox->Clear(); + + m_TextListBox->Append(m_CurrentModule->m_Reference->m_Text); + m_TextListBox->Append(m_CurrentModule->m_Value->m_Text); + + EDA_BaseStruct * item = m_CurrentModule->m_Drawings; + while ( item ) + { + if( item->m_StructType == TYPETEXTEMODULE ) + m_TextListBox->Append( ((TEXTE_MODULE*)item)->m_Text ); + item = item->Pnext; + } + + SetTextListButtons(); +} + + +/************************************************************************/ +void WinEDA_ModulePropertiesFrame::CreateTextModule(wxCommandEvent& event) +/************************************************************************/ +/* Cree un nouveau texte sur le module actif + Le texte sera mis en fonction Move +*/ +{ +TEXTE_MODULE * Text; + + /* Creation de la place en memoire : */ + Text = m_Parent->CreateTextModule(m_CurrentModule, m_DC); + + ReCreateFieldListBox(); + m_TextListBox->SetSelection(2); + SetTextListButtons(); +} + + +/****************************************************************************/ +void WinEDA_ModulePropertiesFrame::EditOrDelTextModule(wxCommandEvent& event) +/****************************************************************************/ +{ +int TextType = m_TextListBox->GetChoice(); +TEXTE_MODULE * Text = NULL; + + if ( TextType < 0 ) return; //No selection + + + if ( m_DC ) m_Parent->DrawPanel->CursorOff(m_DC); + + + // Get a pointer on the field + if ( TextType == 0 ) Text = m_CurrentModule->m_Reference; + else if ( TextType == 1 ) Text = m_CurrentModule->m_Value; + else // Search the field 2 or more, because field 0 and 1 are ref and value + { + EDA_BaseStruct * item = m_CurrentModule->m_Drawings; + int jj = 2; + while ( item ) + { + if( item->m_StructType == TYPETEXTEMODULE ) + { + if ( jj == TextType ) // Texte trouvé + { + Text = (TEXTE_MODULE*)item; + break; + } + } + item = item->Pnext; jj++; + } + } + + if ( Text ) + { + if ( event.GetId() == ID_MODULE_EDIT_DELETE_TEXT ) + { + if ( TextType < 2 ) // Ref or Value cannot be deleted + { + DisplayError(this, _("Reference or Value cannot be deleted") ); + goto out; + } + wxString Line; + Line.Printf( _("Delete [%s]"), Text->m_Text.GetData() ); + if ( !IsOK(this, Line ) ) goto out; + m_Parent->DeleteTextModule(Text, m_DC); + ReCreateFieldListBox(); + m_TextListBox->SetSelection(0); + } + else // Edition du champ + { + m_Parent->InstallTextModOptionsFrame(Text, m_DC, wxPoint(-1,-1) ); + ReCreateFieldListBox(); + m_TextListBox->SetSelection(TextType); + } + } + + else DisplayError(this, + wxT("WinEDA_ModulePropertiesFrame::EditOrDelTextModule() error: Field not found")); + + out: + if ( m_DC ) m_Parent->DrawPanel->CursorOn(m_DC); + SetTextListButtons(); +} diff --git a/pcbnew/dialog_edit_module.h b/pcbnew/dialog_edit_module.h new file mode 100644 index 0000000000..755a3b8c07 --- /dev/null +++ b/pcbnew/dialog_edit_module.h @@ -0,0 +1,97 @@ + /************************************************/ + /* Module editor: Dialog box for editing module */ + /* properties and carateristics */ + /************************************************/ + +enum id_Module_properties +{ + ID_ACCEPT_MODULE_PROPERTIES = 1900, + ID_CLOSE_MODULE_PROPERTIES, + ID_GOTO_MODULE_EDITOR, + ID_MODULE_PROPERTIES_EXCHANGE, + ID_MODULE_EDIT_ADD_TEXT, + ID_MODULE_EDIT_EDIT_TEXT, + ID_MODULE_EDIT_DELETE_TEXT, + ID_MODULE_LISTBOX_SELECT, + ID_LISTBOX_ORIENT_SELECT, + ID_BROWSE_3D_LIB, + ID_ADD_3D_SHAPE, + ID_REMOVE_3D_SHAPE, + ID_NOTEBOOK +}; + +class Panel3D_Ctrl; + + /**************************************/ + /* class WinEDA_ModulePropertiesFrame */ + /**************************************/ + +class WinEDA_ModulePropertiesFrame: public wxDialog +{ +private: + + WinEDA_BasePcbFrame * m_Parent; + wxDC * m_DC; + MODULE * m_CurrentModule; + wxNotebook* m_NoteBook; + wxPanel * m_PanelProperties; + Panel3D_Ctrl * m_Panel3D; + WinEDAChoiceBox * m_TextListBox; + wxRadioBox * m_LayerCtrl; + wxRadioBox * m_OrientCtrl; + wxTextCtrl * m_OrientValue; + wxRadioBox * m_AttributsCtrl; + wxRadioBox * m_AutoPlaceCtrl; + wxSlider * m_CostRot90Ctrl, * m_CostRot180Ctrl; + wxButton * m_DeleteFieddButton; + wxTextCtrl *m_Doc, *m_Keyword; + wxBoxSizer * m_GeneralBoxSizer; + wxBoxSizer* m_PanelPropertiesBoxSizer; + + +public: + // Constructor and destructor + WinEDA_ModulePropertiesFrame(WinEDA_BasePcbFrame *parent, + MODULE * Module, wxDC * DC, const wxPoint & pos); + ~WinEDA_ModulePropertiesFrame(void) + { + } + +private: + void CreateControls(); + void OnQuit(wxCommandEvent& event); + void ModulePropertiesAccept(wxCommandEvent& event); + void CreateTextModule(wxCommandEvent& event); + void EditOrDelTextModule(wxCommandEvent& event); + void SelectTextListBox(wxCommandEvent& event); + void ReCreateFieldListBox(void); + void SetTextListButtons(void); + void BuildPanelModuleProperties(bool FullOptions); + void ModuleOrientEvent(wxCommandEvent& event); + void ExchangeModule(wxCommandEvent& event); + void GotoModuleEditor(wxCommandEvent& event); + DECLARE_EVENT_TABLE() +}; + + +/*********************************/ +class Panel3D_Ctrl: public wxPanel +/*********************************/ +/* panel d'entree des caract 3D */ +{ +public: + Panel3D_Ctrl * m_Pnext, * m_Pback; // Chainage + wxNotebook * m_Parent; + WinEDA_ModulePropertiesFrame * m_ParentFrame; + wxBoxSizer* m_Panel3DBoxSizer; + wxTextCtrl * m_3D_ShapeName; + WinEDA_VertexCtrl *m_3D_Scale, *m_3D_Offset, *m_3D_Rotation; +public: + Panel3D_Ctrl(WinEDA_ModulePropertiesFrame * parentframe, + wxNotebook * parent, int id, Struct3D_Master * struct3D); + ~Panel3D_Ctrl(void); + void Browse3DLib(wxCommandEvent& event); + void AddOrRemove3DShape(wxCommandEvent& event); + DECLARE_EVENT_TABLE() +}; + diff --git a/pcbnew/dialog_general_options.cpp b/pcbnew/dialog_general_options.cpp new file mode 100644 index 0000000000..65e7193f97 --- /dev/null +++ b/pcbnew/dialog_general_options.cpp @@ -0,0 +1,536 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_general_options.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 21/01/2006 18:28:47 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 21/01/2006 18:28:47 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "dialog_general_options.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes +#include "fctsys.h" +#include "common.h" +#include "pcbnew.h" + +#include "id.h" + +#include "dialog_general_options.h" + +////@begin XPM images +////@end XPM images + + + +/*****************************************************************/ +void WinEDA_PcbFrame::OnSelectOptionToolbar(wxCommandEvent& event) +/*****************************************************************/ +/* Mises a jour de differentes variables de gestion d'options apres action sur +le toolbar d'options +*/ +{ +int id = event.GetId(); +wxClientDC dc(DrawPanel); + + DrawPanel->CursorOff(&dc); + DrawPanel->PrepareGraphicContext(&dc); + switch ( id ) + { + case ID_TB_OPTIONS_DRC_OFF: + Drc_On = m_OptionsToolBar->GetToolState(id) ? FALSE : TRUE; + break; + + case ID_TB_OPTIONS_SHOW_GRID: + m_Draw_Grid = g_ShowGrid = m_OptionsToolBar->GetToolState(id); + DrawPanel->ReDraw(&dc, TRUE); + break; + + case ID_TB_OPTIONS_SHOW_RATSNEST: + g_Show_Ratsnest = m_OptionsToolBar->GetToolState(id); + Ratsnest_On_Off(&dc); + break; + + case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST: + g_Show_Module_Ratsnest = m_OptionsToolBar->GetToolState(id); + break; + + case ID_TB_OPTIONS_SELECT_UNIT_MM: + g_UnitMetric = MILLIMETRE; + case ID_TB_OPTIONS_SELECT_UNIT_INCH: + if ( id == ID_TB_OPTIONS_SELECT_UNIT_INCH ) + g_UnitMetric = INCHES; + m_SelTrackWidthBox_Changed = TRUE; + Affiche_Status_Box(); /* Reaffichage des coord curseur */ + ReCreateAuxiliaryToolbar(); + DisplayUnitsMsg(); + break; + + case ID_TB_OPTIONS_SHOW_POLAR_COORD: + Affiche_Message(wxEmptyString); + DisplayOpt.DisplayPolarCood = m_OptionsToolBar->GetToolState(id); + Affiche_Status_Box(); /* Reaffichage des coord curseur */ + break; + + case ID_TB_OPTIONS_SELECT_CURSOR: + g_CursorShape = m_OptionsToolBar->GetToolState(id); + break; + + case ID_TB_OPTIONS_AUTO_DEL_TRACK: + g_AutoDeleteOldTrack = m_OptionsToolBar->GetToolState(id); + break; + + case ID_TB_OPTIONS_SHOW_ZONES: + DisplayOpt.DisplayZones = m_OptionsToolBar->GetToolState(id); + DrawPanel->ReDraw(&dc, TRUE); + break; + + case ID_TB_OPTIONS_SHOW_PADS_SKETCH: + m_DisplayPadFill = DisplayOpt.DisplayPadFill = + ! m_OptionsToolBar->GetToolState(id); + DrawPanel->ReDraw(&dc, TRUE); + break; + + case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH: + m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = + ! m_OptionsToolBar->GetToolState(id); + DrawPanel->ReDraw(&dc, TRUE); + break; + + case ID_TB_OPTIONS_SHOW_HIGHT_CONTRAST_MODE: + DisplayOpt.ContrastModeDisplay = + m_OptionsToolBar->GetToolState(id); + DrawPanel->ReDraw(&dc, TRUE); + break; + + case ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1: + if ( m_OptionsToolBar->GetToolState(id) ) // show aux V toolbar (Microwave tool) + ReCreateAuxVToolbar(); + else + { + delete m_AuxVToolBar; + m_AuxVToolBar = NULL; + } + { + wxSizeEvent SizeEv(GetSize()); + OnSize(SizeEv); + } + break; + + default: + DisplayError(this, wxT("WinEDA_PcbFrame::OnSelectOptionToolbar error")); + break; + } + + SetToolbars(); + DrawPanel->CursorOn(&dc); +} + + +/*! + * WinEDA_PcbGeneralOptionsFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_PcbGeneralOptionsFrame, wxDialog ) + +/*! + * WinEDA_PcbGeneralOptionsFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_PcbGeneralOptionsFrame, wxDialog ) + +////@begin WinEDA_PcbGeneralOptionsFrame event table entries + EVT_BUTTON( wxID_OK, WinEDA_PcbGeneralOptionsFrame::OnOkClick ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_PcbGeneralOptionsFrame::OnCancelClick ) + +////@end WinEDA_PcbGeneralOptionsFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_PcbGeneralOptionsFrame constructors + */ + +WinEDA_PcbGeneralOptionsFrame::WinEDA_PcbGeneralOptionsFrame( ) +{ +} + +WinEDA_PcbGeneralOptionsFrame::WinEDA_PcbGeneralOptionsFrame( WinEDA_PcbFrame* parent, wxDC * DC, + wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + m_DC = DC; + + Create(parent, id, caption, pos, size, style); + + /* Set display options */ + m_PolarDisplay->SetSelection(DisplayOpt.DisplayPolarCood ? 1 : 0); + m_BoxUnits->SetSelection( g_UnitMetric ? 1 : 0); + m_CursorShape->SetSelection( g_CursorShape ? 1 : 0); + +wxString timevalue; + timevalue << g_TimeOut / 60; + m_SaveTime->SetValue(timevalue); + m_LayerNumber->SetValue(g_DesignSettings.m_CopperLayerCount); + m_MaxShowLinks->SetValue(g_MaxLinksShowed); + + m_DrcOn->SetValue(Drc_On ); + m_ShowModuleRatsnest->SetValue(g_Show_Module_Ratsnest); + m_ShowGlobalRatsnest->SetValue(g_Show_Ratsnest); + m_TrackAutodel->SetValue(g_AutoDeleteOldTrack); + m_Track_45_Only_Ctrl->SetValue(Track_45_Only); + m_Segments_45_Only_Ctrl->SetValue(Segments_45_Only); + m_AutoPANOpt->SetValue(m_Parent->DrawPanel-> m_AutoPAN_Enable); + m_Segments_45_Only_Ctrl->SetValue(Segments_45_Only); + m_Track_DoubleSegm_Ctrl->SetValue(g_TwoSegmentTrackBuild); +} + +/*! + * WinEDA_PcbGeneralOptionsFrame creator + */ + +bool WinEDA_PcbGeneralOptionsFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_PcbGeneralOptionsFrame member initialisation + m_PolarDisplay = NULL; + m_BoxUnits = NULL; + m_CursorShape = NULL; + m_LayerNumber = NULL; + m_MaxShowLinks = NULL; + m_SaveTime = NULL; + m_DrcOn = NULL; + m_ShowGlobalRatsnest = NULL; + m_ShowModuleRatsnest = NULL; + m_TrackAutodel = NULL; + m_Track_45_Only_Ctrl = NULL; + m_Segments_45_Only_Ctrl = NULL; + m_AutoPANOpt = NULL; + m_Track_DoubleSegm_Ctrl = NULL; + m_MagneticPadOptCtrl = NULL; +////@end WinEDA_PcbGeneralOptionsFrame member initialisation + +////@begin WinEDA_PcbGeneralOptionsFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_PcbGeneralOptionsFrame creation + SetFont(*g_DialogFont); + return true; +} + +/*! + * Control creation for WinEDA_PcbGeneralOptionsFrame + */ + +void WinEDA_PcbGeneralOptionsFrame::CreateControls() +{ +////@begin WinEDA_PcbGeneralOptionsFrame content construction + // Generated by DialogBlocks, 13/04/2006 22:32:02 (unregistered) + + WinEDA_PcbGeneralOptionsFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5); + + wxString m_PolarDisplayStrings[] = { + _("No Display"), + _("Display") + }; + m_PolarDisplay = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Display Polar Coord"), wxDefaultPosition, wxDefaultSize, 2, m_PolarDisplayStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer3->Add(m_PolarDisplay, 0, wxALIGN_LEFT|wxALL, 5); + + wxString m_BoxUnitsStrings[] = { + _("Inches"), + _("millimeters") + }; + m_BoxUnits = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Units"), wxDefaultPosition, wxDefaultSize, 2, m_BoxUnitsStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer3->Add(m_BoxUnits, 0, wxALIGN_LEFT|wxALL, 5); + + wxString m_CursorShapeStrings[] = { + _("Small"), + _("Big") + }; + m_CursorShape = new wxRadioBox( itemDialog1, ID_RADIOBOX2, _("Cursor"), wxDefaultPosition, wxDefaultSize, 2, m_CursorShapeStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer3->Add(m_CursorShape, 0, wxALIGN_LEFT|wxALL, 5); + + wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer7, 0, wxGROW|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer8Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Number of Layers:")); + wxStaticBoxSizer* itemStaticBoxSizer8 = new wxStaticBoxSizer(itemStaticBoxSizer8Static, wxVERTICAL); + itemBoxSizer7->Add(itemStaticBoxSizer8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + m_LayerNumber = new wxSpinCtrl( itemDialog1, ID_SPINCTRL1, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 16, 0 ); + itemStaticBoxSizer8->Add(m_LayerNumber, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer10Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Max Links:")); + wxStaticBoxSizer* itemStaticBoxSizer10 = new wxStaticBoxSizer(itemStaticBoxSizer10Static, wxVERTICAL); + itemBoxSizer7->Add(itemStaticBoxSizer10, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + m_MaxShowLinks = new wxSpinCtrl( itemDialog1, ID_SPINCTRL2, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 5, 0 ); + itemStaticBoxSizer10->Add(m_MaxShowLinks, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer12Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Auto Save (minuts):")); + wxStaticBoxSizer* itemStaticBoxSizer12 = new wxStaticBoxSizer(itemStaticBoxSizer12Static, wxVERTICAL); + itemBoxSizer7->Add(itemStaticBoxSizer12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + m_SaveTime = new wxSpinCtrl( itemDialog1, ID_SPINCTRL3, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 60, 0 ); + itemStaticBoxSizer12->Add(m_SaveTime, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer14, 0, wxGROW|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer15Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Options:")); + wxStaticBoxSizer* itemStaticBoxSizer15 = new wxStaticBoxSizer(itemStaticBoxSizer15Static, wxVERTICAL); + itemBoxSizer14->Add(itemStaticBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + m_DrcOn = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Drc ON"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_DrcOn->SetValue(false); + m_DrcOn->SetForegroundColour(wxColour(198, 0, 0)); + itemStaticBoxSizer15->Add(m_DrcOn, 0, wxALIGN_LEFT|wxALL, 5); + + m_ShowGlobalRatsnest = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Show Ratsnest"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_ShowGlobalRatsnest->SetValue(false); + itemStaticBoxSizer15->Add(m_ShowGlobalRatsnest, 0, wxALIGN_LEFT|wxALL, 5); + + m_ShowModuleRatsnest = new wxCheckBox( itemDialog1, ID_CHECKBOX2, _("Show Mod Ratsnest"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_ShowModuleRatsnest->SetValue(false); + itemStaticBoxSizer15->Add(m_ShowModuleRatsnest, 0, wxALIGN_LEFT|wxALL, 5); + + m_TrackAutodel = new wxCheckBox( itemDialog1, ID_CHECKBOX3, _("Tracks Auto Del"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_TrackAutodel->SetValue(false); + itemStaticBoxSizer15->Add(m_TrackAutodel, 0, wxALIGN_LEFT|wxALL, 5); + + m_Track_45_Only_Ctrl = new wxCheckBox( itemDialog1, ID_CHECKBOX4, _("Track 45 Only"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_Track_45_Only_Ctrl->SetValue(false); + itemStaticBoxSizer15->Add(m_Track_45_Only_Ctrl, 0, wxALIGN_LEFT|wxALL, 5); + + m_Segments_45_Only_Ctrl = new wxCheckBox( itemDialog1, ID_CHECKBOX5, _("Segments 45 Only"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_Segments_45_Only_Ctrl->SetValue(false); + itemStaticBoxSizer15->Add(m_Segments_45_Only_Ctrl, 0, wxALIGN_LEFT|wxALL, 5); + + m_AutoPANOpt = new wxCheckBox( itemDialog1, ID_CHECKBOX6, _("Auto PAN"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_AutoPANOpt->SetValue(false); + m_AutoPANOpt->SetForegroundColour(wxColour(0, 0, 255)); + itemStaticBoxSizer15->Add(m_AutoPANOpt, 0, wxALIGN_LEFT|wxALL, 5); + + m_Track_DoubleSegm_Ctrl = new wxCheckBox( itemDialog1, ID_CHECKBOX7, _("Double Segm Track"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_Track_DoubleSegm_Ctrl->SetValue(false); + m_Track_DoubleSegm_Ctrl->SetForegroundColour(wxColour(0, 144, 0)); + itemStaticBoxSizer15->Add(m_Track_DoubleSegm_Ctrl, 0, wxALIGN_LEFT|wxALL, 5); + + wxString m_MagneticPadOptCtrlStrings[] = { + _("Never"), + _("When creating tracks"), + _("Always") + }; + m_MagneticPadOptCtrl = new wxRadioBox( itemDialog1, ID_MAGNETIC_PAD_CTRL, _("Magnetic Pads"), wxDefaultPosition, wxDefaultSize, 3, m_MagneticPadOptCtrlStrings, 1, wxRA_SPECIFY_COLS ); + if (ShowToolTips()) + m_MagneticPadOptCtrl->SetToolTip(_("control the capture of the pcb cursor when the mouse cursor enters a pad area")); + itemStaticBoxSizer15->Add(m_MagneticPadOptCtrl, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer25 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer25, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton26 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton26->SetForegroundColour(wxColour(221, 0, 0)); + itemBoxSizer25->Add(itemButton26, 0, wxGROW|wxALL, 5); + + wxButton* itemButton27 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton27->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer25->Add(itemButton27, 0, wxGROW|wxALL, 5); + + // Set validators + m_MagneticPadOptCtrl->SetValidator( wxGenericValidator(& g_MagneticPadOption) ); +////@end WinEDA_PcbGeneralOptionsFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_PcbGeneralOptionsFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_PcbGeneralOptionsFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_PcbGeneralOptionsFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_PcbGeneralOptionsFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_PcbGeneralOptionsFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_PcbGeneralOptionsFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_PcbGeneralOptionsFrame icon retrieval +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_PcbGeneralOptionsFrame::OnCancelClick( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK in WinEDA_PcbGeneralOptionsFrame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK in WinEDA_PcbGeneralOptionsFrame. +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_PcbGeneralOptionsFrame::OnOkClick( wxCommandEvent& event ) +{ + AcceptPcbOptions(event); +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK in WinEDA_PcbGeneralOptionsFrame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK in WinEDA_PcbGeneralOptionsFrame. +} + + + +/**************************************************************************/ +void WinEDA_PcbGeneralOptionsFrame::AcceptPcbOptions(wxCommandEvent& event) +/**************************************************************************/ +{ +int ii; + + DisplayOpt.DisplayPolarCood = + (m_PolarDisplay->GetSelection() == 0) ? FALSE : TRUE; + ii = g_UnitMetric; + g_UnitMetric = (m_BoxUnits->GetSelection() == 0) ? 0 : 1; + if ( ii != g_UnitMetric ) m_Parent->ReCreateAuxiliaryToolbar(); + + g_CursorShape = m_CursorShape->GetSelection(); + g_TimeOut = 60 * m_SaveTime->GetValue(); + + /* Mise a jour de la combobox d'affichage de la couche active */ + g_DesignSettings.m_CopperLayerCount = m_LayerNumber->GetValue(); + m_Parent->ReCreateLayerBox(NULL); + + g_MaxLinksShowed = m_MaxShowLinks->GetValue(); + Drc_On = m_DrcOn->GetValue(); + if ( g_Show_Ratsnest != m_ShowGlobalRatsnest->GetValue() ) + { + g_Show_Ratsnest = m_ShowGlobalRatsnest->GetValue(); + m_Parent->Ratsnest_On_Off(m_DC); + } + g_Show_Module_Ratsnest = m_ShowModuleRatsnest->GetValue(); + g_AutoDeleteOldTrack = m_TrackAutodel->GetValue(); + Segments_45_Only = m_Segments_45_Only_Ctrl->GetValue(); + Track_45_Only = m_Track_45_Only_Ctrl->GetValue(); + m_Parent->DrawPanel->m_AutoPAN_Enable = m_AutoPANOpt->GetValue(); + g_TwoSegmentTrackBuild = m_Track_DoubleSegm_Ctrl->GetValue(); + + EndModal(1); +} + + +enum id_optpcb +{ + ID_ACCEPT_OPT = 1000, + ID_CANCEL_OPT +}; + +#include "dialog_track_options.cpp" +#include "dialog_display_options.cpp" +#include "dialog_graphic_items_options.cpp" + +/*****************************************************************/ +void WinEDA_PcbFrame::InstallPcbOptionsFrame(const wxPoint & pos, + wxDC * DC, int id) +/*****************************************************************/ +{ + + switch ( id ) + { + case ID_PCB_TRACK_SIZE_SETUP: + { + WinEDA_PcbTracksDialog * OptionsFrame = + new WinEDA_PcbTracksDialog(this); + OptionsFrame->ShowModal(); OptionsFrame->Destroy(); + } + break; + + case ID_PCB_DRAWINGS_WIDTHS_SETUP: + { + WinEDA_GraphicItemsOptionsDialog * OptionsFrame = + new WinEDA_GraphicItemsOptionsDialog(this); + OptionsFrame->ShowModal(); OptionsFrame->Destroy(); + } + break; + + case ID_PCB_LOOK_SETUP: + { + WinEDA_DisplayOptionsDialog * OptionsFrame = + new WinEDA_DisplayOptionsDialog(this); + OptionsFrame->ShowModal(); OptionsFrame->Destroy(); + } + break; + + case ID_OPTIONS_SETUP: + { + WinEDA_PcbGeneralOptionsFrame * OptionsFrame = + new WinEDA_PcbGeneralOptionsFrame(this, DC); + OptionsFrame->ShowModal(); OptionsFrame->Destroy(); + } + break; + } +} + + +/*******************************************************************/ +void WinEDA_ModuleEditFrame::InstallOptionsFrame(const wxPoint & pos) +/*******************************************************************/ +{ +WinEDA_GraphicItemsOptionsDialog OptionsFrame (this); + OptionsFrame.ShowModal(); +} + + + diff --git a/pcbnew/dialog_general_options.h b/pcbnew/dialog_general_options.h new file mode 100644 index 0000000000..2ac4c1e193 --- /dev/null +++ b/pcbnew/dialog_general_options.h @@ -0,0 +1,140 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_general_options.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 21/01/2006 18:28:47 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 21/01/2006 18:28:47 + +#ifndef _DIALOG_GENERAL_OPTIONS_H_ +#define _DIALOG_GENERAL_OPTIONS_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "dialog_general_options.h" +#endif + +/*! + * Includes + */ + +////@begin includes +#include "wx/spinctrl.h" +#include "wx/valgen.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +class wxSpinCtrl; +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_TITLE _("General Options") +#define SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_IDNAME wxID_CANCEL +#define SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_POSITION wxDefaultPosition +#define ID_RADIOBOX 10001 +#define ID_RADIOBOX1 10002 +#define ID_RADIOBOX2 10003 +#define ID_SPINCTRL1 10005 +#define ID_SPINCTRL2 10006 +#define ID_SPINCTRL3 10004 +#define ID_CHECKBOX 10007 +#define ID_CHECKBOX1 10008 +#define ID_CHECKBOX2 10009 +#define ID_CHECKBOX3 10010 +#define ID_CHECKBOX4 10011 +#define ID_CHECKBOX5 10012 +#define ID_CHECKBOX6 10013 +#define ID_CHECKBOX7 10014 +#define ID_MAGNETIC_PAD_CTRL 10000 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_PcbGeneralOptionsFrame class declaration + */ + +class WinEDA_PcbGeneralOptionsFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_PcbGeneralOptionsFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_PcbGeneralOptionsFrame( ); + WinEDA_PcbGeneralOptionsFrame( WinEDA_PcbFrame* parent, wxDC * DC, + wxWindowID id = SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_SIZE, long style = SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_SIZE, long style = SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_PcbGeneralOptionsFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + +////@end WinEDA_PcbGeneralOptionsFrame event handler declarations + + void AcceptPcbOptions(wxCommandEvent& event); + +////@begin WinEDA_PcbGeneralOptionsFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_PcbGeneralOptionsFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + +////@begin WinEDA_PcbGeneralOptionsFrame member variables + wxRadioBox* m_PolarDisplay; + wxRadioBox* m_BoxUnits; + wxRadioBox* m_CursorShape; + wxSpinCtrl* m_LayerNumber; + wxSpinCtrl* m_MaxShowLinks; + wxSpinCtrl* m_SaveTime; + wxCheckBox* m_DrcOn; + wxCheckBox* m_ShowGlobalRatsnest; + wxCheckBox* m_ShowModuleRatsnest; + wxCheckBox* m_TrackAutodel; + wxCheckBox* m_Track_45_Only_Ctrl; + wxCheckBox* m_Segments_45_Only_Ctrl; + wxCheckBox* m_AutoPANOpt; + wxCheckBox* m_Track_DoubleSegm_Ctrl; + wxRadioBox* m_MagneticPadOptCtrl; +////@end WinEDA_PcbGeneralOptionsFrame member variables + WinEDA_PcbFrame * m_Parent; + wxDC * m_DC; +}; + +#endif + // _DIALOG_GENERAL_OPTIONS_H_ diff --git a/pcbnew/dialog_general_options.rc b/pcbnew/dialog_general_options.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/pcbnew/dialog_general_options.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/pcbnew/dialog_graphic_items_options.cpp b/pcbnew/dialog_graphic_items_options.cpp new file mode 100644 index 0000000000..815500917f --- /dev/null +++ b/pcbnew/dialog_graphic_items_options.cpp @@ -0,0 +1,328 @@ + /*************************************************/ + /* dialog_graphic_items_options.cpp - Gestion des Options et Reglages */ + /*************************************************/ +/* + Affichage et modifications des parametres de travail de PcbNew + +*/ + + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "pcbplot.h" +#include "autorout.h" + +#include "id.h" + +#include "protos.h" + +#include "dialog_graphic_items_options.h" + +#include + + +/**************************************************************/ +void WinEDA_GraphicItemsOptionsDialog::SetDisplayValue( void ) +/**************************************************************/ +{ + /* Drawings width */ + AddUnitSymbol(*m_GraphicSegmWidthTitle); + PutValueInLocalUnits(*m_OptPcbSegmWidth, + g_DesignSettings.m_DrawSegmentWidth, PCB_INTERNAL_UNIT ); + /* Edges width */ + AddUnitSymbol(*m_BoardEdgesWidthTitle); + PutValueInLocalUnits(*m_OptPcbEdgesWidth, + g_DesignSettings.m_EdgeSegmentWidth, PCB_INTERNAL_UNIT ); + + /* Pcb Textes (Size & Width) */ + AddUnitSymbol(*m_CopperTextWidthTitle); + PutValueInLocalUnits(*m_OptPcbTextWidth, + g_DesignSettings.m_PcbTextWidth, PCB_INTERNAL_UNIT ); + + AddUnitSymbol(*m_TextSizeVTitle); + PutValueInLocalUnits(*m_OptPcbTextVSize, + g_DesignSettings.m_PcbTextSize.y, PCB_INTERNAL_UNIT ); + + AddUnitSymbol(*m_TextSizeHTitle); + PutValueInLocalUnits(*m_OptPcbTextHSize, + g_DesignSettings.m_PcbTextSize.x, PCB_INTERNAL_UNIT ); + + + /* Modules: Edges width */ + AddUnitSymbol(*m_EdgeModWidthTitle); + PutValueInLocalUnits(*m_OptModuleEdgesWidth, + ModuleSegmentWidth, PCB_INTERNAL_UNIT ); + + /* Modules: Texts: Size & width */ + AddUnitSymbol(*m_TextModWidthTitle); + PutValueInLocalUnits(*m_OptModuleTextWidth, + ModuleTextWidth, PCB_INTERNAL_UNIT ); + + AddUnitSymbol(*m_TextModSizeVTitle); + PutValueInLocalUnits(*m_OptModuleTextVSize, + ModuleTextSize.y, PCB_INTERNAL_UNIT ); + + AddUnitSymbol(*m_TextModSizeHTitle); + PutValueInLocalUnits(*m_OptModuleTextHSize, + ModuleTextSize.x, PCB_INTERNAL_UNIT ); + +} + + +/*********************************************************************/ +void WinEDA_GraphicItemsOptionsDialog::AcceptOptions(wxCommandEvent& event) +/*********************************************************************/ +{ + g_DesignSettings.m_DrawSegmentWidth = + ReturnValueFromTextCtrl( *m_OptPcbSegmWidth, PCB_INTERNAL_UNIT ); + g_DesignSettings.m_EdgeSegmentWidth = + ReturnValueFromTextCtrl( *m_OptPcbEdgesWidth, PCB_INTERNAL_UNIT ); + g_DesignSettings.m_PcbTextWidth = + ReturnValueFromTextCtrl( *m_OptPcbTextWidth, PCB_INTERNAL_UNIT ); + g_DesignSettings.m_PcbTextSize.y = + ReturnValueFromTextCtrl( *m_OptPcbTextVSize, PCB_INTERNAL_UNIT ); + g_DesignSettings.m_PcbTextSize.x = + ReturnValueFromTextCtrl( *m_OptPcbTextHSize, PCB_INTERNAL_UNIT ); + + ModuleSegmentWidth = + ReturnValueFromTextCtrl( *m_OptModuleEdgesWidth, PCB_INTERNAL_UNIT ); + ModuleTextWidth = + ReturnValueFromTextCtrl( *m_OptModuleTextWidth, PCB_INTERNAL_UNIT ); + ModuleTextSize.y = + ReturnValueFromTextCtrl( *m_OptModuleTextVSize, PCB_INTERNAL_UNIT ); + ModuleTextSize.x = + ReturnValueFromTextCtrl( *m_OptModuleTextHSize, PCB_INTERNAL_UNIT ); + + EndModal(1); +} + + +/*! + * WinEDA_GraphicItemsOptionsDialog type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_GraphicItemsOptionsDialog, wxDialog ) + +/*! + * WinEDA_GraphicItemsOptionsDialog event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_GraphicItemsOptionsDialog, wxDialog ) + +////@begin WinEDA_GraphicItemsOptionsDialog event table entries + EVT_BUTTON( wxID_OK, WinEDA_GraphicItemsOptionsDialog::OnOkClick ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_GraphicItemsOptionsDialog::OnCancelClick ) + +////@end WinEDA_GraphicItemsOptionsDialog event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_GraphicItemsOptionsDialog constructors + */ + +WinEDA_GraphicItemsOptionsDialog::WinEDA_GraphicItemsOptionsDialog( ) +{ +} + +WinEDA_GraphicItemsOptionsDialog::WinEDA_GraphicItemsOptionsDialog( WinEDA_BasePcbFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + Create(parent, id, caption, pos, size, style); +} + +/*! + * WinEDA_GraphicItemsOptionsDialog creator + */ + +bool WinEDA_GraphicItemsOptionsDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_GraphicItemsOptionsDialog member initialisation + m_GraphicSegmWidthTitle = NULL; + m_OptPcbSegmWidth = NULL; + m_BoardEdgesWidthTitle = NULL; + m_OptPcbEdgesWidth = NULL; + m_CopperTextWidthTitle = NULL; + m_OptPcbTextWidth = NULL; + m_TextSizeVTitle = NULL; + m_OptPcbTextVSize = NULL; + m_TextSizeHTitle = NULL; + m_OptPcbTextHSize = NULL; + m_EdgeModWidthTitle = NULL; + m_OptModuleEdgesWidth = NULL; + m_TextModWidthTitle = NULL; + m_OptModuleTextWidth = NULL; + m_TextModSizeVTitle = NULL; + m_OptModuleTextVSize = NULL; + m_TextModSizeHTitle = NULL; + m_OptModuleTextHSize = NULL; +////@end WinEDA_GraphicItemsOptionsDialog member initialisation + +////@begin WinEDA_GraphicItemsOptionsDialog creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_GraphicItemsOptionsDialog creation + return true; +} + +/*! + * Control creation for WinEDA_GraphicItemsOptionsDialog + */ + +void WinEDA_GraphicItemsOptionsDialog::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_GraphicItemsOptionsDialog content construction + // Generated by DialogBlocks, 25/02/2006 10:43:53 (unregistered) + + WinEDA_GraphicItemsOptionsDialog* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Graphics:")); + wxStaticBoxSizer* itemStaticBoxSizer3 = new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxVERTICAL); + itemBoxSizer2->Add(itemStaticBoxSizer3, 0, wxGROW|wxALL, 5); + + m_GraphicSegmWidthTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Graphic segm Width"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer3->Add(m_GraphicSegmWidthTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptPcbSegmWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_SEGW, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer3->Add(m_OptPcbSegmWidth, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_BoardEdgesWidthTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Board Edges Width"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer3->Add(m_BoardEdgesWidthTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptPcbEdgesWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_EDGES, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer3->Add(m_OptPcbEdgesWidth, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_CopperTextWidthTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Copper Text Width"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer3->Add(m_CopperTextWidthTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptPcbTextWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TEXTW, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer3->Add(m_OptPcbTextWidth, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_TextSizeVTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Text Size V"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer3->Add(m_TextSizeVTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptPcbTextVSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TEXTV, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer3->Add(m_OptPcbTextVSize, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_TextSizeHTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Text Size H"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer3->Add(m_TextSizeHTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptPcbTextHSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TEXTH, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer3->Add(m_OptPcbTextHSize, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer15Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Modules:")); + wxStaticBoxSizer* itemStaticBoxSizer15 = new wxStaticBoxSizer(itemStaticBoxSizer15Static, wxVERTICAL); + itemBoxSizer2->Add(itemStaticBoxSizer15, 0, wxGROW|wxALL, 5); + + m_EdgeModWidthTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Edges Module Width"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer15->Add(m_EdgeModWidthTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptModuleEdgesWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_EDGEMOD_W, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer15->Add(m_OptModuleEdgesWidth, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_TextModWidthTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Text Module Width"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer15->Add(m_TextModWidthTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptModuleTextWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TXTMOD_W, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer15->Add(m_OptModuleTextWidth, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_TextModSizeVTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Text Module Size V"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer15->Add(m_TextModSizeVTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptModuleTextVSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TXTMOD_V, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer15->Add(m_OptModuleTextVSize, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_TextModSizeHTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Text Module Size H"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer15->Add(m_TextModSizeHTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptModuleTextHSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_TXTMOD_H, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticBoxSizer15->Add(m_OptModuleTextHSize, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer25 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer25, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton26 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton26->SetForegroundColour(wxColour(206, 0, 0)); + itemBoxSizer25->Add(itemButton26, 0, wxGROW|wxALL, 5); + + wxButton* itemButton27 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton27->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer25->Add(itemButton27, 0, wxGROW|wxALL, 5); + +////@end WinEDA_GraphicItemsOptionsDialog content construction + SetDisplayValue(); +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_GraphicItemsOptionsDialog::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_GraphicItemsOptionsDialog::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_GraphicItemsOptionsDialog bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_GraphicItemsOptionsDialog bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_GraphicItemsOptionsDialog::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_GraphicItemsOptionsDialog icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_GraphicItemsOptionsDialog icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_GraphicItemsOptionsDialog::OnOkClick( wxCommandEvent& event ) +{ + AcceptOptions(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_GraphicItemsOptionsDialog::OnCancelClick( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_GraphicItemsOptionsDialog. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_GraphicItemsOptionsDialog. +} + + diff --git a/pcbnew/dialog_graphic_items_options.h b/pcbnew/dialog_graphic_items_options.h new file mode 100644 index 0000000000..c75170674b --- /dev/null +++ b/pcbnew/dialog_graphic_items_options.h @@ -0,0 +1,129 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_graphic_items_options.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 25/02/2006 09:53:27 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 25/02/2006 09:53:27 + +#ifndef _DIALOG_GRAPHIC_ITEMS_OPTIONS_H_ +#define _DIALOG_GRAPHIC_ITEMS_OPTIONS_H_ + +/*! + * Includes + */ + +////@begin includes +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_GRAPHICITEMSOPTIONSDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_GRAPHICITEMSOPTIONSDIALOG_TITLE _("Texts and Drawings") +#define SYMBOL_WINEDA_GRAPHICITEMSOPTIONSDIALOG_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_GRAPHICITEMSOPTIONSDIALOG_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_GRAPHICITEMSOPTIONSDIALOG_POSITION wxDefaultPosition +#define ID_TEXTCTRL_SEGW 10001 +#define ID_TEXTCTRL_EDGES 10002 +#define ID_TEXTCTRL_TEXTW 10003 +#define ID_TEXTCTRL_TEXTV 10004 +#define ID_TEXTCTRL_TEXTH 10005 +#define ID_TEXTCTRL_EDGEMOD_W 10006 +#define ID_TEXTCTRL_TXTMOD_W 10007 +#define ID_TEXTCTRL_TXTMOD_V 10008 +#define ID_TEXTCTRL_TXTMOD_H 10009 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_GraphicItemsOptionsDialog class declaration + */ + +class WinEDA_GraphicItemsOptionsDialog: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_GraphicItemsOptionsDialog ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_GraphicItemsOptionsDialog( ); + WinEDA_GraphicItemsOptionsDialog( WinEDA_BasePcbFrame* parent, wxWindowID id = SYMBOL_WINEDA_GRAPHICITEMSOPTIONSDIALOG_IDNAME, const wxString& caption = SYMBOL_WINEDA_GRAPHICITEMSOPTIONSDIALOG_TITLE, const wxPoint& pos = SYMBOL_WINEDA_GRAPHICITEMSOPTIONSDIALOG_POSITION, const wxSize& size = SYMBOL_WINEDA_GRAPHICITEMSOPTIONSDIALOG_SIZE, long style = SYMBOL_WINEDA_GRAPHICITEMSOPTIONSDIALOG_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_GRAPHICITEMSOPTIONSDIALOG_IDNAME, const wxString& caption = SYMBOL_WINEDA_GRAPHICITEMSOPTIONSDIALOG_TITLE, const wxPoint& pos = SYMBOL_WINEDA_GRAPHICITEMSOPTIONSDIALOG_POSITION, const wxSize& size = SYMBOL_WINEDA_GRAPHICITEMSOPTIONSDIALOG_SIZE, long style = SYMBOL_WINEDA_GRAPHICITEMSOPTIONSDIALOG_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_GraphicItemsOptionsDialog event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + +////@end WinEDA_GraphicItemsOptionsDialog event handler declarations + +////@begin WinEDA_GraphicItemsOptionsDialog member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_GraphicItemsOptionsDialog member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + void AcceptOptions(wxCommandEvent& event); + void SetDisplayValue( void ); + +////@begin WinEDA_GraphicItemsOptionsDialog member variables + wxStaticText* m_GraphicSegmWidthTitle; + wxTextCtrl* m_OptPcbSegmWidth; + wxStaticText* m_BoardEdgesWidthTitle; + wxTextCtrl* m_OptPcbEdgesWidth; + wxStaticText* m_CopperTextWidthTitle; + wxTextCtrl* m_OptPcbTextWidth; + wxStaticText* m_TextSizeVTitle; + wxTextCtrl* m_OptPcbTextVSize; + wxStaticText* m_TextSizeHTitle; + wxTextCtrl* m_OptPcbTextHSize; + wxStaticText* m_EdgeModWidthTitle; + wxTextCtrl* m_OptModuleEdgesWidth; + wxStaticText* m_TextModWidthTitle; + wxTextCtrl* m_OptModuleTextWidth; + wxStaticText* m_TextModSizeVTitle; + wxTextCtrl* m_OptModuleTextVSize; + wxStaticText* m_TextModSizeHTitle; + wxTextCtrl* m_OptModuleTextHSize; +////@end WinEDA_GraphicItemsOptionsDialog member variables + WinEDA_BasePcbFrame * m_Parent; +}; + +#endif + // _DIALOG_GRAPHIC_ITEMS_OPTIONS_H_ diff --git a/pcbnew/dialog_graphic_items_options.rc b/pcbnew/dialog_graphic_items_options.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/pcbnew/dialog_graphic_items_options.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/pcbnew/dialog_initpcb.cpp b/pcbnew/dialog_initpcb.cpp new file mode 100644 index 0000000000..1c1e663c58 --- /dev/null +++ b/pcbnew/dialog_initpcb.cpp @@ -0,0 +1,225 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_initpcb.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 15/02/2006 21:42:41 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 15/02/2006 21:42:41 + + +////@begin includes +////@end includes + +#include "dialog_initpcb.h" + +////@begin XPM images +////@end XPM images + +/*! + * WinEDA_PcbGlobalDeleteFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_PcbGlobalDeleteFrame, wxDialog ) + +/*! + * WinEDA_PcbGlobalDeleteFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_PcbGlobalDeleteFrame, wxDialog ) + +////@begin WinEDA_PcbGlobalDeleteFrame event table entries + EVT_BUTTON( wxID_OK, WinEDA_PcbGlobalDeleteFrame::OnOkClick ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_PcbGlobalDeleteFrame::OnCancelClick ) + +////@end WinEDA_PcbGlobalDeleteFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_PcbGlobalDeleteFrame constructors + */ + +WinEDA_PcbGlobalDeleteFrame::WinEDA_PcbGlobalDeleteFrame( ) +{ +} + +WinEDA_PcbGlobalDeleteFrame::WinEDA_PcbGlobalDeleteFrame( WinEDA_PcbFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + Create(parent, id, caption, pos, size, style); +} + +/*! + * WinEDA_PcbGlobalDeleteFrame creator + */ + +bool WinEDA_PcbGlobalDeleteFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_PcbGlobalDeleteFrame member initialisation + m_DelZones = NULL; + m_DelTexts = NULL; + m_DelEdges = NULL; + m_DelDrawings = NULL; + m_DelModules = NULL; + m_DelTracks = NULL; + m_DelMarkers = NULL; + m_DelAlls = NULL; + m_TrackFilterAR = NULL; + m_TrackFilterLocked = NULL; +////@end WinEDA_PcbGlobalDeleteFrame member initialisation + +////@begin WinEDA_PcbGlobalDeleteFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_PcbGlobalDeleteFrame creation + return true; +} + +/*! + * Control creation for WinEDA_PcbGlobalDeleteFrame + */ + +void WinEDA_PcbGlobalDeleteFrame::CreateControls() +{ + + SetFont(*g_DialogFont); +////@begin WinEDA_PcbGlobalDeleteFrame content construction + // Generated by DialogBlocks, 15/02/2006 22:10:20 (unregistered) + + WinEDA_PcbGlobalDeleteFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Items to delete")); + wxStaticBoxSizer* itemStaticBoxSizer3 = new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxVERTICAL); + itemBoxSizer2->Add(itemStaticBoxSizer3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + m_DelZones = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Delete Zones"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_DelZones->SetValue(false); + itemStaticBoxSizer3->Add(m_DelZones, 0, wxALIGN_LEFT|wxALL, 5); + + m_DelTexts = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Delete Texts"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_DelTexts->SetValue(false); + itemStaticBoxSizer3->Add(m_DelTexts, 0, wxALIGN_LEFT|wxALL, 5); + + m_DelEdges = new wxCheckBox( itemDialog1, ID_CHECKBOX2, _("Delete Edges"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_DelEdges->SetValue(false); + itemStaticBoxSizer3->Add(m_DelEdges, 0, wxALIGN_LEFT|wxALL, 5); + + m_DelDrawings = new wxCheckBox( itemDialog1, ID_CHECKBOX3, _("Delete Drawings"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_DelDrawings->SetValue(false); + itemStaticBoxSizer3->Add(m_DelDrawings, 0, wxALIGN_LEFT|wxALL, 5); + + m_DelModules = new wxCheckBox( itemDialog1, ID_CHECKBOX4, _("Delete Modules"), wxDefaultPosition, wxDefaultSize, 0 ); + m_DelModules->SetValue(false); + itemStaticBoxSizer3->Add(m_DelModules, 0, wxALIGN_LEFT|wxALL, 5); + + m_DelTracks = new wxCheckBox( itemDialog1, ID_CHECKBOX5, _("Delete Tracks"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_DelTracks->SetValue(false); + itemStaticBoxSizer3->Add(m_DelTracks, 0, wxALIGN_LEFT|wxALL, 5); + + m_DelMarkers = new wxCheckBox( itemDialog1, ID_CHECKBOX6, _("Delete Markers"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_DelMarkers->SetValue(false); + itemStaticBoxSizer3->Add(m_DelMarkers, 0, wxALIGN_LEFT|wxALL, 5); + + m_DelAlls = new wxCheckBox( itemDialog1, ID_CHECKBOX7, _("Clear Board"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_DelAlls->SetValue(false); + itemStaticBoxSizer3->Add(m_DelAlls, 0, wxALIGN_LEFT|wxALL, 5); + + wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer13Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Track Filter")); + wxStaticBoxSizer* itemStaticBoxSizer13 = new wxStaticBoxSizer(itemStaticBoxSizer13Static, wxVERTICAL); + itemBoxSizer12->Add(itemStaticBoxSizer13, 0, wxGROW|wxALL, 5); + + m_TrackFilterAR = new wxCheckBox( itemDialog1, ID_CHECKBOX8, _("Include AutoRouted Tracks"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_TrackFilterAR->SetValue(false); + itemStaticBoxSizer13->Add(m_TrackFilterAR, 0, wxALIGN_LEFT|wxALL, 5); + + m_TrackFilterLocked = new wxCheckBox( itemDialog1, ID_CHECKBOX9, _("Include Locked Tracks"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_TrackFilterLocked->SetValue(false); + itemStaticBoxSizer13->Add(m_TrackFilterLocked, 0, wxALIGN_LEFT|wxALL, 5); + + itemBoxSizer12->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer12->Add(itemBoxSizer17, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxButton* itemButton18 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer17->Add(itemButton18, 0, wxGROW|wxALL, 5); + + wxButton* itemButton19 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer17->Add(itemButton19, 0, wxGROW|wxALL, 5); + +////@end WinEDA_PcbGlobalDeleteFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_PcbGlobalDeleteFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_PcbGlobalDeleteFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_PcbGlobalDeleteFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_PcbGlobalDeleteFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_PcbGlobalDeleteFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_PcbGlobalDeleteFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_PcbGlobalDeleteFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_PcbGlobalDeleteFrame::OnOkClick( wxCommandEvent& event ) +{ + AcceptPcbDelete(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_PcbGlobalDeleteFrame::OnCancelClick( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_PcbGlobalDeleteFrame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_PcbGlobalDeleteFrame. +} + + diff --git a/pcbnew/dialog_initpcb.h b/pcbnew/dialog_initpcb.h new file mode 100644 index 0000000000..6ff6705826 --- /dev/null +++ b/pcbnew/dialog_initpcb.h @@ -0,0 +1,123 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_initpcb.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 15/02/2006 21:42:41 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 15/02/2006 21:42:41 + +#ifndef _DIALOG_INITPCB_H_ +#define _DIALOG_INITPCB_H_ + +/*! + * Includes + */ + +////@begin includes +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_PCBGLOBALDELETEFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_PCBGLOBALDELETEFRAME_TITLE _("Global Delete") +#define SYMBOL_WINEDA_PCBGLOBALDELETEFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_PCBGLOBALDELETEFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_PCBGLOBALDELETEFRAME_POSITION wxDefaultPosition +#define ID_CHECKBOX 10001 +#define ID_CHECKBOX1 10002 +#define ID_CHECKBOX2 10003 +#define ID_CHECKBOX3 10004 +#define ID_CHECKBOX4 10005 +#define ID_CHECKBOX5 10006 +#define ID_CHECKBOX6 10007 +#define ID_CHECKBOX7 10008 +#define ID_CHECKBOX8 10009 +#define ID_CHECKBOX9 10010 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_PcbGlobalDeleteFrame class declaration + */ + +class WinEDA_PcbGlobalDeleteFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_PcbGlobalDeleteFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_PcbGlobalDeleteFrame( ); + WinEDA_PcbGlobalDeleteFrame( WinEDA_PcbFrame* parent, wxWindowID id = SYMBOL_WINEDA_PCBGLOBALDELETEFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PCBGLOBALDELETEFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PCBGLOBALDELETEFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PCBGLOBALDELETEFRAME_SIZE, long style = SYMBOL_WINEDA_PCBGLOBALDELETEFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PCBGLOBALDELETEFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PCBGLOBALDELETEFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PCBGLOBALDELETEFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PCBGLOBALDELETEFRAME_SIZE, long style = SYMBOL_WINEDA_PCBGLOBALDELETEFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_PcbGlobalDeleteFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + +////@end WinEDA_PcbGlobalDeleteFrame event handler declarations + +////@begin WinEDA_PcbGlobalDeleteFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_PcbGlobalDeleteFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + void AcceptPcbDelete(wxCommandEvent& event); + +////@begin WinEDA_PcbGlobalDeleteFrame member variables + wxCheckBox* m_DelZones; + wxCheckBox* m_DelTexts; + wxCheckBox* m_DelEdges; + wxCheckBox* m_DelDrawings; + wxCheckBox* m_DelModules; + wxCheckBox* m_DelTracks; + wxCheckBox* m_DelMarkers; + wxCheckBox* m_DelAlls; + wxCheckBox* m_TrackFilterAR; + wxCheckBox* m_TrackFilterLocked; +////@end WinEDA_PcbGlobalDeleteFrame member variables + + WinEDA_PcbFrame * m_Parent; + +}; + +#endif + // _DIALOG_INITPCB_H_ diff --git a/pcbnew/dialog_initpcb.rc b/pcbnew/dialog_initpcb.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/pcbnew/dialog_initpcb.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/pcbnew/dialog_module_edit.rc b/pcbnew/dialog_module_edit.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/pcbnew/dialog_module_edit.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/pcbnew/dialog_netlist.cpp b/pcbnew/dialog_netlist.cpp new file mode 100644 index 0000000000..c5b9b1bb54 --- /dev/null +++ b/pcbnew/dialog_netlist.cpp @@ -0,0 +1,269 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_netlist.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 26/02/2006 17:42:19 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 26/02/2006 17:42:19 + + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes + +#include "dialog_netlist.h" + +////@begin XPM images +////@end XPM images + +/*! + * WinEDA_NetlistFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_NetlistFrame, wxDialog ) + +/*! + * WinEDA_NetlistFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_NetlistFrame, wxDialog ) + +////@begin WinEDA_NetlistFrame event table entries + EVT_BUTTON( ID_OPEN_NELIST, WinEDA_NetlistFrame::OnOpenNelistClick ) + + EVT_BUTTON( ID_READ_NETLIST_FILE, WinEDA_NetlistFrame::OnReadNetlistFileClick ) + + EVT_BUTTON( ID_TEST_NETLIST, WinEDA_NetlistFrame::OnTestNetlistClick ) + + EVT_BUTTON( ID_COMPILE_RATSNEST, WinEDA_NetlistFrame::OnCompileRatsnestClick ) + + EVT_BUTTON( wxID_CLOSE, WinEDA_NetlistFrame::OnCloseClick ) + +////@end WinEDA_NetlistFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_NetlistFrame constructors + */ + +WinEDA_NetlistFrame::WinEDA_NetlistFrame( ) +{ +} + +WinEDA_NetlistFrame::WinEDA_NetlistFrame( WinEDA_PcbFrame* parent, wxDC * DC, + wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + m_DC = DC; + /* Setup the NETLIST file name according to the board file name */ + NetNameBuffer = m_Parent->m_CurrentScreen->m_FileName; + ChangeFileNameExt(NetNameBuffer, NetExtBuffer); + + Create(parent, id, caption, pos, size, style); + + wxString title = GetTitle() + NetNameBuffer; + SetTitle(title); + +} + +/*! + * WinEDA_NetlistFrame creator + */ + +bool WinEDA_NetlistFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_NetlistFrame member initialisation + m_Select_By_Timestamp = NULL; + m_DeleteBadTracks = NULL; + m_ChangeExistantModuleCtrl = NULL; + m_DisplayWarningCtrl = NULL; + m_MessageWindow = NULL; +////@end WinEDA_NetlistFrame member initialisation + +////@begin WinEDA_NetlistFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_NetlistFrame creation + return true; +} + +/*! + * Control creation for WinEDA_NetlistFrame + */ + +void WinEDA_NetlistFrame::CreateControls() +{ + SetFont(*g_DialogFont); +////@begin WinEDA_NetlistFrame content construction + // Generated by DialogBlocks, 26/02/2006 18:24:19 (unregistered) + + WinEDA_NetlistFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxString m_Select_By_TimestampStrings[] = { + _("Reference"), + _("Timestamp") + }; + m_Select_By_Timestamp = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Module Selection:"), wxDefaultPosition, wxDefaultSize, 2, m_Select_By_TimestampStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer4->Add(m_Select_By_Timestamp, 0, wxGROW|wxALL, 5); + + wxString m_DeleteBadTracksStrings[] = { + _("Keep"), + _("Delete") + }; + m_DeleteBadTracks = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Bad Tracks Deletion:"), wxDefaultPosition, wxDefaultSize, 2, m_DeleteBadTracksStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer4->Add(m_DeleteBadTracks, 0, wxGROW|wxALL, 5); + + wxString m_ChangeExistantModuleCtrlStrings[] = { + _("Keep"), + _("Change") + }; + m_ChangeExistantModuleCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX2, _("Exchange Module:"), wxDefaultPosition, wxDefaultSize, 2, m_ChangeExistantModuleCtrlStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer4->Add(m_ChangeExistantModuleCtrl, 0, wxGROW|wxALL, 5); + + m_DisplayWarningCtrl = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Display Warnings"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_DisplayWarningCtrl->SetValue(false); + itemBoxSizer4->Add(m_DisplayWarningCtrl, 0, wxGROW|wxALL, 5); + + itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton11 = new wxButton( itemDialog1, ID_OPEN_NELIST, _("Select"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton11->SetForegroundColour(wxColour(217, 0, 0)); + itemBoxSizer10->Add(itemButton11, 0, wxGROW|wxALL, 5); + + wxButton* itemButton12 = new wxButton( itemDialog1, ID_READ_NETLIST_FILE, _("Read"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton12->SetForegroundColour(wxColour(0, 128, 0)); + itemBoxSizer10->Add(itemButton12, 0, wxGROW|wxALL, 5); + + wxButton* itemButton13 = new wxButton( itemDialog1, ID_TEST_NETLIST, _("Module Test"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton13->SetForegroundColour(wxColour(0, 128, 128)); + itemBoxSizer10->Add(itemButton13, 0, wxGROW|wxALL, 5); + + wxButton* itemButton14 = new wxButton( itemDialog1, ID_COMPILE_RATSNEST, _("Compile"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton14->SetForegroundColour(wxColour(0, 0, 132)); + itemBoxSizer10->Add(itemButton14, 0, wxGROW|wxALL, 5); + + wxButton* itemButton15 = new wxButton( itemDialog1, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton15->SetForegroundColour(wxColour(128, 0, 128)); + itemBoxSizer10->Add(itemButton15, 0, wxGROW|wxALL, 5); + + m_MessageWindow = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(-1, 120), wxTE_MULTILINE|wxTE_READONLY ); + itemBoxSizer2->Add(m_MessageWindow, 0, wxGROW|wxALL, 5); + + // Set validators + m_DisplayWarningCtrl->SetValidator( wxGenericValidator(& DisplayWarning) ); +////@end WinEDA_NetlistFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_NetlistFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_NetlistFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_NetlistFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_NetlistFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_NetlistFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_NetlistFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_NetlistFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_OPEN_NELIST + */ + +void WinEDA_NetlistFrame::OnOpenNelistClick( wxCommandEvent& event ) +{ + Set_NetlisteName(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_READ_NETLIST_FILE + */ + +void WinEDA_NetlistFrame::OnReadNetlistFileClick( wxCommandEvent& event ) +{ + ReadPcbNetlist(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_TEST_NETLIST + */ + +void WinEDA_NetlistFrame::OnTestNetlistClick( wxCommandEvent& event ) +{ + ModulesControle(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_COMPILE_RATSNEST + */ + +void WinEDA_NetlistFrame::OnCompileRatsnestClick( wxCommandEvent& event ) +{ + m_Parent->Compile_Ratsnest(m_DC, TRUE); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + */ + +void WinEDA_NetlistFrame::OnCloseClick( wxCommandEvent& event ) +{ + Close(); +} + + diff --git a/pcbnew/dialog_netlist.h b/pcbnew/dialog_netlist.h new file mode 100644 index 0000000000..961ef878d0 --- /dev/null +++ b/pcbnew/dialog_netlist.h @@ -0,0 +1,139 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_netlist.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 26/02/2006 17:42:19 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 26/02/2006 17:42:19 + +#ifndef _DIALOG_NETLIST_H_ +#define _DIALOG_NETLIST_H_ + + +/*! + * Includes + */ + +////@begin includes +#include "wx/valgen.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_NETLISTFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_NETLISTFRAME_TITLE _("Netlist: ") +#define SYMBOL_WINEDA_NETLISTFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_NETLISTFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_NETLISTFRAME_POSITION wxDefaultPosition +#define ID_RADIOBOX 10005 +#define ID_RADIOBOX1 10006 +#define ID_RADIOBOX2 10007 +#define ID_CHECKBOX 10008 +#define ID_OPEN_NELIST 10001 +#define ID_READ_NETLIST_FILE 10002 +#define ID_TEST_NETLIST 10003 +#define ID_COMPILE_RATSNEST 10004 +#define ID_TEXTCTRL 10009 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_NetlistFrame class declaration + */ + +class WinEDA_NetlistFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_NetlistFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_NetlistFrame( ); + WinEDA_NetlistFrame( WinEDA_PcbFrame* parent,wxDC * DC, + wxWindowID id = SYMBOL_WINEDA_NETLISTFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_NETLISTFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_NETLISTFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_NETLISTFRAME_SIZE, long style = SYMBOL_WINEDA_NETLISTFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_NETLISTFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_NETLISTFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_NETLISTFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_NETLISTFRAME_SIZE, long style = SYMBOL_WINEDA_NETLISTFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_NetlistFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_OPEN_NELIST + void OnOpenNelistClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_READ_NETLIST_FILE + void OnReadNetlistFileClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_TEST_NETLIST + void OnTestNetlistClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_COMPILE_RATSNEST + void OnCompileRatsnestClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + void OnCloseClick( wxCommandEvent& event ); + +////@end WinEDA_NetlistFrame event handler declarations + +////@begin WinEDA_NetlistFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_NetlistFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void ReadPcbNetlist(wxCommandEvent& event); + void Set_NetlisteName(wxCommandEvent& event); + bool OpenNetlistFile(wxCommandEvent& event); + int BuildListeNetModules(wxCommandEvent& event, wxArrayString & BufName); + void ModulesControle(wxCommandEvent& event); + int ReadListeModules(const wxString * RefCmp, long TimeStamp, wxString & NameModule); + int SetPadNetName( char * Line, MODULE * Module); + MODULE * ReadNetModule( char * Text, + int * UseFichCmp, int TstOnly); + void AddToList(const wxString & NameLibCmp, const wxString & NameCmp,int TimeStamp ); + void LoadListeModules(wxDC *DC); + +////@begin WinEDA_NetlistFrame member variables + wxRadioBox* m_Select_By_Timestamp; + wxRadioBox* m_DeleteBadTracks; + wxRadioBox* m_ChangeExistantModuleCtrl; + wxCheckBox* m_DisplayWarningCtrl; + wxTextCtrl* m_MessageWindow; +////@end WinEDA_NetlistFrame member variables + WinEDA_PcbFrame * m_Parent; + wxDC * m_DC; +}; + +#endif + // _DIALOG_NETLIST_H_ diff --git a/pcbnew/dialog_netlist.rc b/pcbnew/dialog_netlist.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/pcbnew/dialog_netlist.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/pcbnew/dialog_pad_edit.cpp b/pcbnew/dialog_pad_edit.cpp new file mode 100644 index 0000000000..ef791438ed --- /dev/null +++ b/pcbnew/dialog_pad_edit.cpp @@ -0,0 +1,420 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_pad_edit.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 28/02/2006 13:34:48 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 28/02/2006 13:34:48 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "dialog_pad_edit.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes + +#include "dialog_pad_edit.h" + +////@begin XPM images +////@end XPM images + +/*! + * WinEDA_PadPropertiesFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_PadPropertiesFrame, wxDialog ) + +/*! + * WinEDA_PadPropertiesFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_PadPropertiesFrame, wxDialog ) + +////@begin WinEDA_PadPropertiesFrame event table entries + EVT_RADIOBOX( ID_RADIOBOX_DRILL_SHAPE, WinEDA_PadPropertiesFrame::OnRadioboxDrillShapeSelected ) + + EVT_RADIOBOX( ID_LISTBOX_ORIENT_PAD, WinEDA_PadPropertiesFrame::OnListboxOrientPadSelected ) + + EVT_RADIOBOX( ID_LISTBOX_SHAPE_PAD, WinEDA_PadPropertiesFrame::OnListboxShapePadSelected ) + + EVT_RADIOBOX( ID_LISTBOX_TYPE_PAD, WinEDA_PadPropertiesFrame::OnListboxTypePadSelected ) + + EVT_BUTTON( wxID_OK, WinEDA_PadPropertiesFrame::OnOkClick ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_PadPropertiesFrame::OnCancelClick ) + +////@end WinEDA_PadPropertiesFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_PadPropertiesFrame constructors + */ + +WinEDA_PadPropertiesFrame::WinEDA_PadPropertiesFrame( ) +{ +} + +WinEDA_PadPropertiesFrame::WinEDA_PadPropertiesFrame( WinEDA_BasePcbFrame* parent, + D_PAD * Pad,wxDC * DC, + wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + m_DC = DC; + m_Module = NULL; + CurrentPad = Pad; + + if ( CurrentPad ) + { + Current_PadNetName = CurrentPad->m_Netname; + g_Current_PadName = CurrentPad->ReturnStringPadName(); + m_Module = (MODULE*) CurrentPad->m_Parent; + } + + Create(parent, id, caption, pos, size, style); +} + +/*! + * WinEDA_PadPropertiesFrame creator + */ + +bool WinEDA_PadPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_PadPropertiesFrame member initialisation + m_LeftBoxSizer = NULL; + m_PadNumCtrl = NULL; + m_PadNetNameCtrl = NULL; + m_PadPositionBoxSizer = NULL; + m_DrillShapeBoxSizer = NULL; + m_DrillShapeCtrl = NULL; + m_PadOptSizer = NULL; + m_PadOrient = NULL; + m_PadShape = NULL; + m_PadType = NULL; + m_PadLayerCu = NULL; + m_PadLayerCmp = NULL; + m_PadLayerAdhCmp = NULL; + m_PadLayerAdhCu = NULL; + m_PadLayerPateCmp = NULL; + m_PadLayerPateCu = NULL; + m_PadLayerSilkCmp = NULL; + m_PadLayerSilkCu = NULL; + m_PadLayerMaskCmp = NULL; + m_PadLayerMaskCu = NULL; + m_PadLayerECO1 = NULL; + m_PadLayerECO2 = NULL; + m_PadLayerDraft = NULL; +////@end WinEDA_PadPropertiesFrame member initialisation + +////@begin WinEDA_PadPropertiesFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + if (GetSizer()) + { + GetSizer()->SetSizeHints(this); + } + Centre(); +////@end WinEDA_PadPropertiesFrame creation + return true; +} + +/*! + * Control creation for WinEDA_PadPropertiesFrame + */ + +void WinEDA_PadPropertiesFrame::CreateControls() +{ + SetFont(*g_DialogFont); +////@begin WinEDA_PadPropertiesFrame content construction + // Generated by DialogBlocks, 03/08/2006 10:35:29 (unregistered) + + WinEDA_PadPropertiesFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + m_LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(m_LeftBoxSizer, 0, wxGROW|wxALL, 5); + + wxStaticText* itemStaticText4 = new wxStaticText( itemDialog1, wxID_STATIC, _("Pad Num :"), wxDefaultPosition, wxDefaultSize, 0 ); + m_LeftBoxSizer->Add(itemStaticText4, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_PadNumCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_PADNUM, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + m_LeftBoxSizer->Add(m_PadNumCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, _("Pad Net Name :"), wxDefaultPosition, wxDefaultSize, 0 ); + m_LeftBoxSizer->Add(itemStaticText6, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_PadNetNameCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_NETNAME, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + m_LeftBoxSizer->Add(m_PadNetNameCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_PadPositionBoxSizer = new wxBoxSizer(wxVERTICAL); + m_LeftBoxSizer->Add(m_PadPositionBoxSizer, 0, wxGROW|wxTOP, 5); + + m_DrillShapeBoxSizer = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(m_DrillShapeBoxSizer, 0, wxGROW|wxTOP, 5); + + wxString m_DrillShapeCtrlStrings[] = { + _("Circle"), + _("Oval") + }; + m_DrillShapeCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX_DRILL_SHAPE, _("Drill Shape:"), wxDefaultPosition, wxDefaultSize, 2, m_DrillShapeCtrlStrings, 1, wxRA_SPECIFY_COLS ); + m_DrillShapeCtrl->SetSelection(0); + m_DrillShapeBoxSizer->Add(m_DrillShapeCtrl, 0, wxGROW|wxALL, 5); + + m_PadOptSizer = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(m_PadOptSizer, 0, wxGROW|wxALL, 5); + + wxString m_PadOrientStrings[] = { + _("0"), + _("90"), + _("-90"), + _("180"), + _("User") + }; + m_PadOrient = new wxRadioBox( itemDialog1, ID_LISTBOX_ORIENT_PAD, _("Pad Orient:"), wxDefaultPosition, wxDefaultSize, 5, m_PadOrientStrings, 1, wxRA_SPECIFY_COLS ); + m_PadOrient->SetSelection(0); + m_PadOptSizer->Add(m_PadOrient, 0, wxGROW|wxALL, 5); + + wxString m_PadShapeStrings[] = { + _("Circle"), + _("Oval"), + _("Rect"), + _("Trapezoidal") + }; + m_PadShape = new wxRadioBox( itemDialog1, ID_LISTBOX_SHAPE_PAD, _("Pad Shape:"), wxDefaultPosition, wxDefaultSize, 4, m_PadShapeStrings, 1, wxRA_SPECIFY_COLS ); + m_PadShape->SetSelection(0); + m_PadOptSizer->Add(m_PadShape, 0, wxGROW|wxALL, 5); + + wxString m_PadTypeStrings[] = { + _("Standard"), + _("SMD"), + _("Conn"), + _("Hole"), + _("Mechanical") + }; + m_PadType = new wxRadioBox( itemDialog1, ID_LISTBOX_TYPE_PAD, _("Pad Type:"), wxDefaultPosition, wxDefaultSize, 5, m_PadTypeStrings, 1, wxRA_SPECIFY_COLS ); + m_PadType->SetSelection(0); + m_PadOptSizer->Add(m_PadType, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer15, 0, wxGROW|wxALL, 5); + + wxButton* itemButton16 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton16->SetForegroundColour(wxColour(204, 0, 0)); + itemBoxSizer15->Add(itemButton16, 0, wxGROW|wxALL, 5); + + wxButton* itemButton17 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton17->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer15->Add(itemButton17, 0, wxGROW|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer18Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Layers:")); + wxStaticBoxSizer* itemStaticBoxSizer18 = new wxStaticBoxSizer(itemStaticBoxSizer18Static, wxVERTICAL); + itemBoxSizer15->Add(itemStaticBoxSizer18, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + m_PadLayerCu = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Copper layer"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_PadLayerCu->SetValue(false); + itemStaticBoxSizer18->Add(m_PadLayerCu, 0, wxGROW|wxALL, 5); + + m_PadLayerCmp = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Comp layer"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_PadLayerCmp->SetValue(false); + itemStaticBoxSizer18->Add(m_PadLayerCmp, 0, wxGROW|wxALL, 5); + + itemStaticBoxSizer18->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + m_PadLayerAdhCmp = new wxCheckBox( itemDialog1, ID_CHECKBOX2, _("Adhesive Cmp"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_PadLayerAdhCmp->SetValue(false); + itemStaticBoxSizer18->Add(m_PadLayerAdhCmp, 0, wxGROW|wxALL, 5); + + m_PadLayerAdhCu = new wxCheckBox( itemDialog1, ID_CHECKBOX3, _("Adhesive Copper"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_PadLayerAdhCu->SetValue(false); + itemStaticBoxSizer18->Add(m_PadLayerAdhCu, 0, wxGROW|wxALL, 5); + + m_PadLayerPateCmp = new wxCheckBox( itemDialog1, ID_CHECKBOX4, _("Solder paste Cmp"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_PadLayerPateCmp->SetValue(false); + itemStaticBoxSizer18->Add(m_PadLayerPateCmp, 0, wxGROW|wxALL, 5); + + m_PadLayerPateCu = new wxCheckBox( itemDialog1, ID_CHECKBOX5, _("Solder paste Copper"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_PadLayerPateCu->SetValue(false); + itemStaticBoxSizer18->Add(m_PadLayerPateCu, 0, wxGROW|wxALL, 5); + + m_PadLayerSilkCmp = new wxCheckBox( itemDialog1, ID_CHECKBOX6, _("Silkscreen Cmp"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_PadLayerSilkCmp->SetValue(false); + itemStaticBoxSizer18->Add(m_PadLayerSilkCmp, 0, wxGROW|wxALL, 5); + + m_PadLayerSilkCu = new wxCheckBox( itemDialog1, ID_CHECKBOX7, _("Silkscreen Copper"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_PadLayerSilkCu->SetValue(false); + itemStaticBoxSizer18->Add(m_PadLayerSilkCu, 0, wxGROW|wxALL, 5); + + m_PadLayerMaskCmp = new wxCheckBox( itemDialog1, ID_CHECKBOX8, _("Solder mask Cmp"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_PadLayerMaskCmp->SetValue(false); + itemStaticBoxSizer18->Add(m_PadLayerMaskCmp, 0, wxGROW|wxALL, 5); + + m_PadLayerMaskCu = new wxCheckBox( itemDialog1, ID_CHECKBOX9, _("Solder mask Copper"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_PadLayerMaskCu->SetValue(false); + itemStaticBoxSizer18->Add(m_PadLayerMaskCu, 0, wxGROW|wxALL, 5); + + m_PadLayerECO1 = new wxCheckBox( itemDialog1, ID_CHECKBOX10, _("E.C.O.1 layer"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_PadLayerECO1->SetValue(false); + itemStaticBoxSizer18->Add(m_PadLayerECO1, 0, wxGROW|wxALL, 5); + + m_PadLayerECO2 = new wxCheckBox( itemDialog1, ID_CHECKBOX11, _("E.C.O.2 layer"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_PadLayerECO2->SetValue(false); + itemStaticBoxSizer18->Add(m_PadLayerECO2, 0, wxGROW|wxALL, 5); + + m_PadLayerDraft = new wxCheckBox( itemDialog1, ID_CHECKBOX12, _("Draft layer"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_PadLayerDraft->SetValue(false); + itemStaticBoxSizer18->Add(m_PadLayerDraft, 0, wxGROW|wxALL, 5); + +////@end WinEDA_PadPropertiesFrame content construction + + SetOthersControls(); +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_PadPropertiesFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_PadPropertiesFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_PadPropertiesFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_PadPropertiesFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_PadPropertiesFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_PadPropertiesFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_PadPropertiesFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_PadPropertiesFrame::OnOkClick( wxCommandEvent& event ) +{ + PadPropertiesAccept(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_PadPropertiesFrame::OnCancelClick( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_PadPropertiesFrame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_PadPropertiesFrame. +} + + +/*! + * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_LISTBOX_ORIENT_PAD + */ + +void WinEDA_PadPropertiesFrame::OnListboxOrientPadSelected( wxCommandEvent& event ) +{ + PadOrientEvent(event); +} + +/*! + * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_LISTBOX_SHAPE_PAD + */ + +void WinEDA_PadPropertiesFrame::OnListboxShapePadSelected( wxCommandEvent& event ) +{ + switch (m_PadShape->GetSelection() ) + { + case 0: //CIRCLE: + m_PadDeltaSizeCtrl->Enable(FALSE, FALSE); + m_PadSizeCtrl->Enable(TRUE, FALSE); + break; + + case 1: //OVALE: + m_PadDeltaSizeCtrl->Enable(FALSE, FALSE); + m_PadSizeCtrl->Enable(TRUE, TRUE); + break; + + case 2: // RECT: + m_PadDeltaSizeCtrl->Enable(FALSE, FALSE); + m_PadSizeCtrl->Enable(TRUE, TRUE); + break; + + case 3: //TRAPEZE: + m_PadDeltaSizeCtrl->Enable(TRUE, TRUE); + m_PadSizeCtrl->Enable(TRUE, TRUE); + break; + + case 4: //SPECIAL_PAD: + m_PadDeltaSizeCtrl->Enable(FALSE, FALSE); + m_PadSizeCtrl->Enable(TRUE, TRUE); + break; + } +} + +/*! + * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_LISTBOX_TYPE_PAD + */ + +void WinEDA_PadPropertiesFrame::OnListboxTypePadSelected( wxCommandEvent& event ) +{ + PadTypeSelectedEvent(event); +} + + +/*! + * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX_DRILL_SHAPE + */ + +void WinEDA_PadPropertiesFrame::OnRadioboxDrillShapeSelected( wxCommandEvent& event ) +{ + switch ( m_DrillShapeCtrl->GetSelection() ) + { + case 0: //CIRCLE: + m_PadDrillCtrl->Enable(TRUE,FALSE); + break; + + case 1: //OVALE: + m_PadDrillCtrl->Enable(TRUE, TRUE); + break; + } +} + + diff --git a/pcbnew/dialog_pad_edit.h b/pcbnew/dialog_pad_edit.h new file mode 100644 index 0000000000..5e0f489f20 --- /dev/null +++ b/pcbnew/dialog_pad_edit.h @@ -0,0 +1,179 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_pad_edit.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 28/02/2006 13:34:48 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 28/02/2006 13:34:48 + +#ifndef _DIALOG_PAD_EDIT_H_ +#define _DIALOG_PAD_EDIT_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "dialog_pad_edit.h" +#endif + +/*! + * Includes + */ + +////@begin includes +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +class wxBoxSizer; +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_PADPROPERTIESFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_PADPROPERTIESFRAME_TITLE _("Pad properties") +#define SYMBOL_WINEDA_PADPROPERTIESFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_PADPROPERTIESFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_PADPROPERTIESFRAME_POSITION wxDefaultPosition +#define ID_TEXTCTRL_PADNUM 10001 +#define ID_TEXTCTRL_NETNAME 10002 +#define ID_RADIOBOX_DRILL_SHAPE 10019 +#define ID_LISTBOX_ORIENT_PAD 10003 +#define ID_LISTBOX_SHAPE_PAD 10004 +#define ID_LISTBOX_TYPE_PAD 10005 +#define ID_CHECKBOX 10006 +#define ID_CHECKBOX1 10007 +#define ID_CHECKBOX2 10008 +#define ID_CHECKBOX3 10009 +#define ID_CHECKBOX4 10010 +#define ID_CHECKBOX5 10011 +#define ID_CHECKBOX6 10012 +#define ID_CHECKBOX7 10013 +#define ID_CHECKBOX8 10014 +#define ID_CHECKBOX9 10015 +#define ID_CHECKBOX10 10016 +#define ID_CHECKBOX11 10017 +#define ID_CHECKBOX12 10018 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_PadPropertiesFrame class declaration + */ + +class WinEDA_PadPropertiesFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_PadPropertiesFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_PadPropertiesFrame( ); + WinEDA_PadPropertiesFrame( WinEDA_BasePcbFrame* parent, + D_PAD * Pad,wxDC * DC, + wxWindowID id = SYMBOL_WINEDA_PADPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PADPROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PADPROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PADPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_PADPROPERTIESFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PADPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PADPROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PADPROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PADPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_PADPROPERTIESFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_PadPropertiesFrame event handler declarations + + /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX_DRILL_SHAPE + void OnRadioboxDrillShapeSelected( wxCommandEvent& event ); + + /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_LISTBOX_ORIENT_PAD + void OnListboxOrientPadSelected( wxCommandEvent& event ); + + /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_LISTBOX_SHAPE_PAD + void OnListboxShapePadSelected( wxCommandEvent& event ); + + /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_LISTBOX_TYPE_PAD + void OnListboxTypePadSelected( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + +////@end WinEDA_PadPropertiesFrame event handler declarations + +////@begin WinEDA_PadPropertiesFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_PadPropertiesFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void PadPropertiesAccept(wxCommandEvent& event); + void PadTypeSelected(void); + void PadTypeSelectedEvent(wxCommandEvent& event); + void PadOrientEvent(wxCommandEvent& event); + void SetPadLayersList(long layer_mask); + void SetOthersControls(void); + +////@begin WinEDA_PadPropertiesFrame member variables + wxBoxSizer* m_LeftBoxSizer; + wxTextCtrl* m_PadNumCtrl; + wxTextCtrl* m_PadNetNameCtrl; + wxBoxSizer* m_PadPositionBoxSizer; + wxBoxSizer* m_DrillShapeBoxSizer; + wxRadioBox* m_DrillShapeCtrl; + wxBoxSizer* m_PadOptSizer; + wxRadioBox* m_PadOrient; + wxRadioBox* m_PadShape; + wxRadioBox* m_PadType; + wxCheckBox* m_PadLayerCu; + wxCheckBox* m_PadLayerCmp; + wxCheckBox* m_PadLayerAdhCmp; + wxCheckBox* m_PadLayerAdhCu; + wxCheckBox* m_PadLayerPateCmp; + wxCheckBox* m_PadLayerPateCu; + wxCheckBox* m_PadLayerSilkCmp; + wxCheckBox* m_PadLayerSilkCu; + wxCheckBox* m_PadLayerMaskCmp; + wxCheckBox* m_PadLayerMaskCu; + wxCheckBox* m_PadLayerECO1; + wxCheckBox* m_PadLayerECO2; + wxCheckBox* m_PadLayerDraft; +////@end WinEDA_PadPropertiesFrame member variables + WinEDA_BasePcbFrame * m_Parent; + wxDC * m_DC; + MODULE * m_Module; + D_PAD * CurrentPad; + + WinEDA_SizeCtrl * m_PadSizeCtrl; + WinEDA_PositionCtrl * m_PadPositionCtrl; + WinEDA_SizeCtrl * m_PadDeltaSizeCtrl; + WinEDA_SizeCtrl * m_PadOffsetCtrl; + WinEDA_SizeCtrl * m_PadDrillCtrl; + WinEDA_ValueCtrl * m_PadOrientCtrl; // Pour orientation a 0.1 degre pres + +}; + +#endif + // _DIALOG_PAD_EDIT_H_ diff --git a/pcbnew/dialog_pad_edit.rc b/pcbnew/dialog_pad_edit.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/pcbnew/dialog_pad_edit.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/pcbnew/dialog_setup_libs.cpp b/pcbnew/dialog_setup_libs.cpp new file mode 100644 index 0000000000..874aaeff77 --- /dev/null +++ b/pcbnew/dialog_setup_libs.cpp @@ -0,0 +1,392 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_pcbnew_config.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 18/02/2006 16:41:57 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +/* Handle the pcbnew libary config (library list, and default lib path) +*/ +// Generated by DialogBlocks (unregistered), 18/02/2006 16:41:57 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "dialog_pcbnew_config.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +////@begin includes +////@end includes + +#include "dialog_setup_libs.h" + +////@begin XPM images +////@end XPM images + +/*****************************************************************/ +void WinEDA_PcbFrame::InstallConfigFrame(const wxPoint & pos) +/*****************************************************************/ +{ +KiConfigPcbnewFrame * CfgFrame = new KiConfigPcbnewFrame(this); + CfgFrame->ShowModal(); CfgFrame->Destroy(); +} + + +/*! + * KiConfigPcbnewFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( KiConfigPcbnewFrame, wxDialog ) + +/*! + * KiConfigPcbnewFrame event table definition + */ + +BEGIN_EVENT_TABLE( KiConfigPcbnewFrame, wxDialog ) + +////@begin KiConfigPcbnewFrame event table entries + EVT_CLOSE( KiConfigPcbnewFrame::OnCloseWindow ) + + EVT_BUTTON( SAVE_CFG, KiConfigPcbnewFrame::OnSaveCfgClick ) + + EVT_BUTTON( DEL_LIB, KiConfigPcbnewFrame::OnDelLibClick ) + + EVT_BUTTON( ADD_LIB, KiConfigPcbnewFrame::OnAddLibClick ) + + EVT_BUTTON( INSERT_LIB, KiConfigPcbnewFrame::OnInsertLibClick ) + +////@end KiConfigPcbnewFrame event table entries + +END_EVENT_TABLE() + +/*! + * KiConfigPcbnewFrame constructors + */ + +KiConfigPcbnewFrame::KiConfigPcbnewFrame( ) +{ +} + +KiConfigPcbnewFrame::KiConfigPcbnewFrame( WinEDA_PcbFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +wxString title; + + m_Parent = parent; + m_LibModified = FALSE; + + Create(parent, id, caption, pos, size, style); + + title = _("from ") + EDA_Appl->m_CurrentOptionFile; + SetTitle(title); + m_ListLibr->InsertItems(g_LibName_List, 0); + wxString DocModuleFileName = + EDA_Appl->m_EDA_CommonConfig->Read( wxT("module_doc_file"), + wxT("pcbnew/footprints.pdf")); + m_TextHelpModulesFileName->SetValue(DocModuleFileName); +} + +/*! + * KiConfigPcbnewFrame creator + */ + +bool KiConfigPcbnewFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin KiConfigPcbnewFrame member initialisation + m_FileExtList = NULL; + m_ListLibr = NULL; + m_TextLibDir = NULL; + m_TextHelpModulesFileName = NULL; +////@end KiConfigPcbnewFrame member initialisation + +////@begin KiConfigPcbnewFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end KiConfigPcbnewFrame creation + return true; +} + +/*! + * Control creation for KiConfigPcbnewFrame + */ + +void KiConfigPcbnewFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin KiConfigPcbnewFrame content construction + // Generated by DialogBlocks, 18/02/2006 17:19:54 (unregistered) + + KiConfigPcbnewFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer4, 0, wxGROW|wxALL, 5); + + wxButton* itemButton5 = new wxButton( itemDialog1, SAVE_CFG, _("Save Cfg"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton5->SetForegroundColour(wxColour(204, 0, 0)); + itemBoxSizer4->Add(itemButton5, 0, wxGROW|wxALL, 5); + + itemBoxSizer4->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer7Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Files ext:")); + m_FileExtList = new wxStaticBoxSizer(itemStaticBoxSizer7Static, wxVERTICAL); + itemBoxSizer4->Add(m_FileExtList, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer8, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer8->Add(itemBoxSizer9, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer9->Add(itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL, 5); + + wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer10->Add(itemBoxSizer11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxButton* itemButton12 = new wxButton( itemDialog1, DEL_LIB, _("Del"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton12->SetForegroundColour(wxColour(204, 0, 0)); + itemBoxSizer11->Add(itemButton12, 0, wxGROW|wxALL, 5); + + wxButton* itemButton13 = new wxButton( itemDialog1, ADD_LIB, _("Add"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton13->SetForegroundColour(wxColour(0, 128, 0)); + itemBoxSizer11->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton14 = new wxButton( itemDialog1, INSERT_LIB, _("Ins"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton14->SetDefault(); + itemButton14->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer11->Add(itemButton14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer10->Add(itemBoxSizer15, 0, wxGROW|wxALL, 5); + + wxStaticText* itemStaticText16 = new wxStaticText( itemDialog1, wxID_STATIC, _("Libraries"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticText16->SetForegroundColour(wxColour(204, 0, 0)); + itemBoxSizer15->Add(itemStaticText16, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + + wxString* m_ListLibrStrings = NULL; + m_ListLibr = new wxListBox( itemDialog1, ID_LIST_LIBS, wxDefaultPosition, wxSize(-1, 200), 0, m_ListLibrStrings, wxLB_SINGLE|wxSUNKEN_BORDER ); + itemBoxSizer15->Add(m_ListLibr, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxStaticText* itemStaticText18 = new wxStaticText( itemDialog1, wxID_STATIC, _("Lib Modules Dir:"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); + itemStaticText18->SetForegroundColour(wxColour(204, 0, 0)); + itemBoxSizer2->Add(itemStaticText18, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + + m_TextLibDir = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add(m_TextLibDir, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxStaticText* itemStaticText20 = new wxStaticText( itemDialog1, wxID_STATIC, _("Module Doc File:"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); + itemStaticText20->SetForegroundColour(wxColour(204, 0, 0)); + itemBoxSizer2->Add(itemStaticText20, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + + m_TextHelpModulesFileName = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add(m_TextHelpModulesFileName, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + // Set validators + m_TextLibDir->SetValidator( wxTextValidator(wxFILTER_NONE, & g_UserLibDirBuffer) ); +////@end KiConfigPcbnewFrame content construction +wxString msg = _("Board ext: ") + PcbExtBuffer; + wxStaticText * text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); + m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + + msg = _("Cmp ext: ") + NetCmpExtBuffer; + text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); + m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + + msg = _("Lib ext: ") + LibExtBuffer; + text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); + m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + + msg = _("Net ext: ") + NetExtBuffer; + text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); + m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); +} + +/*! + * wxEVT_CLOSE_WINDOW event handler for ID_DIALOG + */ + +void KiConfigPcbnewFrame::OnCloseWindow( wxCloseEvent& event ) +{ + SetNewOptions(); + EndModal(0); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for SAVE_CFG + */ + +void KiConfigPcbnewFrame::OnSaveCfgClick( wxCommandEvent& event ) +{ + SetNewOptions(); + m_Parent->Update_config(this); +} + + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for DEL_LIB + */ + +void KiConfigPcbnewFrame::OnDelLibClick( wxCommandEvent& event ) +{ + LibDelFct(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ADD_LIB + */ + +void KiConfigPcbnewFrame::OnAddLibClick( wxCommandEvent& event ) +{ + LibInsertFct(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for INSERT_LIB + */ + +void KiConfigPcbnewFrame::OnInsertLibClick( wxCommandEvent& event ) +{ + LibInsertFct(event); +} + +/*! + * Should we show tooltips? + */ + +bool KiConfigPcbnewFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap KiConfigPcbnewFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin KiConfigPcbnewFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end KiConfigPcbnewFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon KiConfigPcbnewFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin KiConfigPcbnewFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end KiConfigPcbnewFrame icon retrieval +} + +/********************************************/ +void KiConfigPcbnewFrame::SetNewOptions(void) +/********************************************/ +{ + g_UserLibDirBuffer = m_TextLibDir->GetValue(); + EDA_Appl->m_EDA_CommonConfig->Write( wxT("module_doc_file"), + m_TextHelpModulesFileName->GetValue()); + SetRealLibraryPath( wxT("modules") ); +} + + +/********************************************************/ +void KiConfigPcbnewFrame::LibDelFct(wxCommandEvent& event) +/********************************************************/ +{ +int ii; + + ii = m_ListLibr->GetSelection(); + if ( ii < 0 ) return; + + g_LibName_List.RemoveAt(ii); + + m_ListLibr->Clear(); + m_ListLibr->InsertItems(g_LibName_List, 0); + m_LibModified = TRUE; +} + + +/*************************************************************/ +void KiConfigPcbnewFrame::LibInsertFct(wxCommandEvent& event) +/*************************************************************/ +/* Insert or add a library to the existing library list: + New library is put in list before (insert) or after (add) + the selection +*/ +{ +int ii; +wxString fullfilename, ShortLibName; +wxString mask = wxT("*"); + + ii = m_ListLibr->GetSelection(); + if ( ii < 0 ) ii = 0; + if( event.GetId() == ADD_LIB) + { + if( g_LibName_List.GetCount() != 0 ) ii ++; /* Add after selection */ + } + + SetNewOptions(); + mask += LibExtBuffer; + g_RealLibDirBuffer.Replace( wxT("\\"), wxT("/")); + + fullfilename = EDA_FileSelector( _("library files:"), + g_RealLibDirBuffer, /* Chemin par defaut */ + wxEmptyString, /* nom fichier par defaut */ + LibExtBuffer, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + 0, + TRUE + ); + + if ( fullfilename.IsEmpty() ) return; + + ShortLibName = + MakeReducedFileName(fullfilename, g_RealLibDirBuffer, LibExtBuffer); + + //Add or insert new library name + if ( g_LibName_List.Index(ShortLibName) == wxNOT_FOUND) + { + m_LibModified = TRUE; + g_LibName_List.Insert(ShortLibName, ii); + m_ListLibr->Clear(); + m_ListLibr->InsertItems(g_LibName_List, 0); + } + else DisplayError(this, _("Library exists! No Change")); +} + diff --git a/pcbnew/dialog_setup_libs.h b/pcbnew/dialog_setup_libs.h new file mode 100644 index 0000000000..24c85c9172 --- /dev/null +++ b/pcbnew/dialog_setup_libs.h @@ -0,0 +1,133 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_pcbnew_config.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 18/02/2006 16:41:57 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 18/02/2006 16:41:57 + +#ifndef _DIALOG_PCBNEW_CONFIG_H_ +#define _DIALOG_PCBNEW_CONFIG_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "dialog_pcbnew_config.h" +#endif + +/*! + * Includes + */ + +////@begin includes +#include "wx/valtext.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_KICONFIGPCBNEWFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_KICONFIGPCBNEWFRAME_TITLE _("Dialog") +#define SYMBOL_KICONFIGPCBNEWFRAME_IDNAME ID_DIALOG +#define SYMBOL_KICONFIGPCBNEWFRAME_SIZE wxSize(400, 300) +#define SYMBOL_KICONFIGPCBNEWFRAME_POSITION wxDefaultPosition +#define SAVE_CFG 10001 +#define DEL_LIB 10002 +#define ADD_LIB 10003 +#define INSERT_LIB 10004 +#define ID_LIST_LIBS 10005 +#define ID_TEXTCTRL 10007 +#define ID_TEXTCTRL1 10008 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * KiConfigPcbnewFrame class declaration + */ + +class KiConfigPcbnewFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( KiConfigPcbnewFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + KiConfigPcbnewFrame( ); + KiConfigPcbnewFrame( WinEDA_PcbFrame* parent, wxWindowID id = SYMBOL_KICONFIGPCBNEWFRAME_IDNAME, const wxString& caption = SYMBOL_KICONFIGPCBNEWFRAME_TITLE, const wxPoint& pos = SYMBOL_KICONFIGPCBNEWFRAME_POSITION, const wxSize& size = SYMBOL_KICONFIGPCBNEWFRAME_SIZE, long style = SYMBOL_KICONFIGPCBNEWFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_KICONFIGPCBNEWFRAME_IDNAME, const wxString& caption = SYMBOL_KICONFIGPCBNEWFRAME_TITLE, const wxPoint& pos = SYMBOL_KICONFIGPCBNEWFRAME_POSITION, const wxSize& size = SYMBOL_KICONFIGPCBNEWFRAME_SIZE, long style = SYMBOL_KICONFIGPCBNEWFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin KiConfigPcbnewFrame event handler declarations + + /// wxEVT_CLOSE_WINDOW event handler for ID_DIALOG + void OnCloseWindow( wxCloseEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for SAVE_CFG + void OnSaveCfgClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for DEL_LIB + void OnDelLibClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ADD_LIB + void OnAddLibClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for INSERT_LIB + void OnInsertLibClick( wxCommandEvent& event ); + +////@end KiConfigPcbnewFrame event handler declarations + +////@begin KiConfigPcbnewFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end KiConfigPcbnewFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void SaveCfg(wxCommandEvent& event); + void LibDelFct(wxCommandEvent& event); + void LibInsertFct(wxCommandEvent& event); + void SetNewOptions(void); + +////@begin KiConfigPcbnewFrame member variables + wxStaticBoxSizer* m_FileExtList; + wxListBox* m_ListLibr; + wxTextCtrl* m_TextLibDir; + wxTextCtrl* m_TextHelpModulesFileName; +////@end KiConfigPcbnewFrame member variables + + WinEDA_PcbFrame * m_Parent; + bool m_LibModified; + +}; + +#endif + // _DIALOG_PCBNEW_CONFIG_H_ diff --git a/pcbnew/dialog_track_options.cpp b/pcbnew/dialog_track_options.cpp new file mode 100644 index 0000000000..830565770e --- /dev/null +++ b/pcbnew/dialog_track_options.cpp @@ -0,0 +1,373 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_track_options.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 24/02/2006 20:58:54 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 24/02/2006 20:58:54 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "dialog_track_options.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes + +#include "dialog_track_options.h" + +////@begin XPM images +////@end XPM images + +/*! + * WinEDA_PcbTracksDialog type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_PcbTracksDialog, wxDialog ) + +/*! + * WinEDA_PcbTracksDialog event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_PcbTracksDialog, wxDialog ) + +////@begin WinEDA_PcbTracksDialog event table entries + EVT_BUTTON( wxID_OK, WinEDA_PcbTracksDialog::OnOkClick ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_PcbTracksDialog::OnCancelClick ) + +////@end WinEDA_PcbTracksDialog event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_PcbTracksDialog constructors + */ + +WinEDA_PcbTracksDialog::WinEDA_PcbTracksDialog( ) +{ +} + +WinEDA_PcbTracksDialog::WinEDA_PcbTracksDialog( WinEDA_PcbFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + Create(parent, id, caption, pos, size, style); +} + +/*! + * WinEDA_PcbTracksDialog creator + */ + +bool WinEDA_PcbTracksDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_PcbTracksDialog member initialisation + m_ViaSizeTitle = NULL; + m_OptViaSize = NULL; + m_ViaDefaultDrillValueTitle = NULL; + m_OptViaDrill = NULL; + m_ViaAltDrillValueTitle = NULL; + m_OptCustomViaDrill = NULL; + m_OptViaType = NULL; + m_TrackWidthTitle = NULL; + m_OptTrackWidth = NULL; + m_TrackClearanceTitle = NULL; + m_OptTrackClearance = NULL; + m_MaskClearanceTitle = NULL; + m_OptMaskMargin = NULL; +////@end WinEDA_PcbTracksDialog member initialisation + +////@begin WinEDA_PcbTracksDialog creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_PcbTracksDialog creation + return true; +} + +/*! + * Control creation for WinEDA_PcbTracksDialog + */ + +void WinEDA_PcbTracksDialog::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_PcbTracksDialog content construction + // Generated by DialogBlocks, 25/02/2006 08:02:26 (unregistered) + + WinEDA_PcbTracksDialog* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5); + + m_ViaSizeTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Via Size"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(m_ViaSizeTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptViaSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(m_OptViaSize, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_ViaDefaultDrillValueTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Default Via Drill"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(m_ViaDefaultDrillValueTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptViaDrill = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(m_OptViaDrill, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_ViaAltDrillValueTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Alternate Via Drill"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(m_ViaAltDrillValueTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptCustomViaDrill = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(m_OptCustomViaDrill, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxString m_OptViaTypeStrings[] = { + _("Blind Via"), + _("Buried Via"), + _("Standard Via") + }; + m_OptViaType = new wxRadioBox( itemDialog1, ID_VIA_TYPE_SELECTION, _("Via Type"), wxDefaultPosition, wxDefaultSize, 3, m_OptViaTypeStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer3->Add(m_OptViaType, 0, wxGROW|wxALL, 5); + + itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer13, 0, wxGROW|wxALL, 5); + + m_TrackWidthTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Track Width"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer13->Add(m_TrackWidthTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptTrackWidth = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer13->Add(m_OptTrackWidth, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_TrackClearanceTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Clearance"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer13->Add(m_TrackClearanceTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptTrackClearance = new wxTextCtrl( itemDialog1, ID_TEXTCTRL4, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer13->Add(m_OptTrackClearance, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_MaskClearanceTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Mask clearance"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer13->Add(m_MaskClearanceTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptMaskMargin = new wxTextCtrl( itemDialog1, ID_TEXTCTRL5, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer13->Add(m_OptMaskMargin, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + itemBoxSizer13->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer21 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer13->Add(itemBoxSizer21, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxButton* itemButton22 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton22->SetForegroundColour(wxColour(210, 0, 0)); + itemBoxSizer21->Add(itemButton22, 0, wxGROW|wxALL, 5); + + wxButton* itemButton23 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, wxBU_LEFT ); + itemButton23->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer21->Add(itemButton23, 0, wxGROW|wxALL, 5); + +////@end WinEDA_PcbTracksDialog content construction + SetDisplayValue(); +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_PcbTracksDialog::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_PcbTracksDialog::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_PcbTracksDialog bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_PcbTracksDialog bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_PcbTracksDialog::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_PcbTracksDialog icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_PcbTracksDialog icon retrieval +} + +/*************************************************/ +void WinEDA_PcbTracksDialog::SetDisplayValue(void) +/*************************************************/ +{ + AddUnitSymbol(*m_ViaSizeTitle); + AddUnitSymbol(*m_ViaDefaultDrillValueTitle); + AddUnitSymbol(*m_ViaAltDrillValueTitle); + AddUnitSymbol(*m_TrackWidthTitle); + AddUnitSymbol(*m_TrackClearanceTitle); + AddUnitSymbol(*m_MaskClearanceTitle); + + int Internal_Unit = m_Parent->m_InternalUnits; + PutValueInLocalUnits(*m_OptViaSize, g_DesignSettings.m_CurrentViaSize, Internal_Unit); + PutValueInLocalUnits(*m_OptViaDrill, g_DesignSettings.m_ViaDrill, Internal_Unit); + PutValueInLocalUnits(*m_OptCustomViaDrill, g_ViaHoleLastValue, Internal_Unit); + PutValueInLocalUnits(*m_OptTrackWidth, g_DesignSettings.m_CurrentTrackWidth, Internal_Unit); + PutValueInLocalUnits(*m_OptTrackClearance, g_DesignSettings.m_TrackClearence, Internal_Unit); + PutValueInLocalUnits(*m_OptMaskMargin, g_DesignSettings.m_MaskMargin, Internal_Unit); + m_OptViaType->SetSelection(g_DesignSettings.m_CurrentViaType - 1); +} + +/*******************************************************************/ +void WinEDA_PcbTracksDialog::AcceptPcbOptions(wxCommandEvent& event) +/*******************************************************************/ +{ + g_DesignSettings.m_CurrentViaType = m_OptViaType->GetSelection() + 1; + if ( g_DesignSettings.m_CurrentViaType != VIA_NORMALE ) + { + if( ! IsOK(this, + _("You have selected VIA Blind or VIA Buried\nWARNING: this feature is EXPERIMENTAL!!! Accept ?") ) ) + g_DesignSettings.m_CurrentViaType = VIA_NORMALE; + } + + g_DesignSettings.m_CurrentViaSize = + ReturnValueFromTextCtrl(*m_OptViaSize, m_Parent->m_InternalUnits); + g_DesignSettings.m_ViaDrill = + ReturnValueFromTextCtrl(*m_OptViaDrill, m_Parent->m_InternalUnits); + g_ViaHoleLastValue = + ReturnValueFromTextCtrl(*m_OptCustomViaDrill, m_Parent->m_InternalUnits); + g_DesignSettings.m_CurrentTrackWidth = + ReturnValueFromTextCtrl(*m_OptTrackWidth, m_Parent->m_InternalUnits); + g_DesignSettings.m_TrackClearence = + ReturnValueFromTextCtrl(*m_OptTrackClearance, m_Parent->m_InternalUnits); + + g_DesignSettings.m_MaskMargin = + ReturnValueFromTextCtrl(*m_OptMaskMargin, m_Parent->m_InternalUnits); + + m_Parent->DisplayTrackSettings(); + + m_Parent->AddHistory(g_DesignSettings.m_CurrentViaSize, TYPEVIA); + m_Parent->AddHistory(g_DesignSettings.m_CurrentTrackWidth, TYPETRACK); + EndModal(1); +} + + +/*********************************************************************/ +void WinEDA_BasePcbFrame::AddHistory(int value, DrawStructureType type) +/**********************************************************************/ +// Mise a jour des listes des dernieres epaisseurs de via et track utilisées +{ +bool addhistory = TRUE; +int ii; + + switch ( type ) + { + case TYPETRACK: + for ( ii = 0; ii < HIST0RY_NUMBER; ii++) + { + if ( g_DesignSettings.m_TrackWidhtHistory[ii] == value ) + { + addhistory = FALSE; break; + } + } + if ( ! addhistory ) break; + for ( ii = HIST0RY_NUMBER -1; ii > 0 ; ii--) + { + g_DesignSettings.m_TrackWidhtHistory[ii] = g_DesignSettings.m_TrackWidhtHistory[ii-1]; + } + g_DesignSettings.m_TrackWidhtHistory[0] = value; + + // Reclassement par valeur croissante + for ( ii = 0; ii < HIST0RY_NUMBER -1; ii++) + { + if ( g_DesignSettings.m_TrackWidhtHistory[ii+1] == 0 ) break; // Fin de liste + if ( g_DesignSettings.m_TrackWidhtHistory[ii] > g_DesignSettings.m_TrackWidhtHistory[ii+1] ) + { + EXCHG(g_DesignSettings.m_TrackWidhtHistory[ii], g_DesignSettings.m_TrackWidhtHistory[ii+1]); + } + } + break; + + case TYPEVIA: + for ( ii = 0; ii < HIST0RY_NUMBER; ii++) + { + if (g_DesignSettings.m_ViaSizeHistory[ii] == value) + { + addhistory = FALSE; break; + } + } + if ( ! addhistory ) break; + + for ( ii = HIST0RY_NUMBER -1; ii > 0 ; ii--) + { + g_DesignSettings.m_ViaSizeHistory[ii] = g_DesignSettings.m_ViaSizeHistory[ii-1]; + } + g_DesignSettings.m_ViaSizeHistory[0] = value; + + // Reclassement par valeur croissante + for ( ii = 0; ii < HIST0RY_NUMBER -1; ii++) + { + if ( g_DesignSettings.m_ViaSizeHistory[ii+1] == 0 ) break; // Fin de liste + if ( g_DesignSettings.m_ViaSizeHistory[ii] > g_DesignSettings.m_ViaSizeHistory[ii+1] ) + { + EXCHG(g_DesignSettings.m_ViaSizeHistory[ii], g_DesignSettings.m_ViaSizeHistory[ii+1]); + } + } + break; + + default: + break; + } +} + + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_PcbTracksDialog::OnOkClick( wxCommandEvent& event ) +{ + AcceptPcbOptions(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_PcbTracksDialog::OnCancelClick( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_PcbTracksDialog. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_PcbTracksDialog. +} + + diff --git a/pcbnew/dialog_track_options.h b/pcbnew/dialog_track_options.h new file mode 100644 index 0000000000..c7d79e08db --- /dev/null +++ b/pcbnew/dialog_track_options.h @@ -0,0 +1,127 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_track_options.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 24/02/2006 20:58:54 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 24/02/2006 20:58:54 + +#ifndef _DIALOG_TRACK_OPTIONS_H_ +#define _DIALOG_TRACK_OPTIONS_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "dialog_track_options.h" +#endif + +/*! + * Includes + */ + +////@begin includes +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_PCBTRACKSDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_PCBTRACKSDIALOG_TITLE _("Tracks and Vias Sizes") +#define SYMBOL_WINEDA_PCBTRACKSDIALOG_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_PCBTRACKSDIALOG_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_PCBTRACKSDIALOG_POSITION wxDefaultPosition +#define ID_TEXTCTRL 10001 +#define ID_TEXTCTRL1 10002 +#define ID_TEXTCTRL2 10003 +#define ID_VIA_TYPE_SELECTION 10004 +#define ID_TEXTCTRL3 10005 +#define ID_TEXTCTRL4 10006 +#define ID_TEXTCTRL5 10007 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_PcbTracksDialog class declaration + */ + +class WinEDA_PcbTracksDialog: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_PcbTracksDialog ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_PcbTracksDialog( ); + WinEDA_PcbTracksDialog( WinEDA_PcbFrame* parent, wxWindowID id = SYMBOL_WINEDA_PCBTRACKSDIALOG_IDNAME, const wxString& caption = SYMBOL_WINEDA_PCBTRACKSDIALOG_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PCBTRACKSDIALOG_POSITION, const wxSize& size = SYMBOL_WINEDA_PCBTRACKSDIALOG_SIZE, long style = SYMBOL_WINEDA_PCBTRACKSDIALOG_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PCBTRACKSDIALOG_IDNAME, const wxString& caption = SYMBOL_WINEDA_PCBTRACKSDIALOG_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PCBTRACKSDIALOG_POSITION, const wxSize& size = SYMBOL_WINEDA_PCBTRACKSDIALOG_SIZE, long style = SYMBOL_WINEDA_PCBTRACKSDIALOG_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_PcbTracksDialog event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + +////@end WinEDA_PcbTracksDialog event handler declarations + +////@begin WinEDA_PcbTracksDialog member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_PcbTracksDialog member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + void AcceptPcbOptions(wxCommandEvent& event); + void SetDisplayValue(void); + +////@begin WinEDA_PcbTracksDialog member variables + wxStaticText* m_ViaSizeTitle; + wxTextCtrl* m_OptViaSize; + wxStaticText* m_ViaDefaultDrillValueTitle; + wxTextCtrl* m_OptViaDrill; + wxStaticText* m_ViaAltDrillValueTitle; + wxTextCtrl* m_OptCustomViaDrill; + wxRadioBox* m_OptViaType; + wxStaticText* m_TrackWidthTitle; + wxTextCtrl* m_OptTrackWidth; + wxStaticText* m_TrackClearanceTitle; + wxTextCtrl* m_OptTrackClearance; + wxStaticText* m_MaskClearanceTitle; + wxTextCtrl* m_OptMaskMargin; +////@end WinEDA_PcbTracksDialog member variables + WinEDA_PcbFrame * m_Parent; + +}; + +#endif + // _DIALOG_TRACK_OPTIONS_H_ diff --git a/pcbnew/dialog_track_options.rc b/pcbnew/dialog_track_options.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/pcbnew/dialog_track_options.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/pcbnew/dist.cpp b/pcbnew/dist.cpp new file mode 100644 index 0000000000..fa0872f436 --- /dev/null +++ b/pcbnew/dist.cpp @@ -0,0 +1,156 @@ + /***************************************************************/ + /* EDITEUR de PCB: AUTOROUTAGE: routine de calcul de distances */ + /***************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "cell.h" + +/* Routines exportees : */ +int GetApxDist( int, int, int, int ); +int CalcDist( int, int, int ); + +/* Les tables de distances et penalites sont etablies sur la base du pas +de routage de 50 unites(le pas entre les cellules est 50 unites) +La distance vraie est calculee par un facteur d'echelle +*/ + + + /************************************************/ + /* int GetApxDist(int r1,int c1,int r2,int c2 ) */ + /************************************************/ + + /* calculate approximate distance */ + +int GetApxDist(int r1,int c1,int r2,int c2 ) +{ +int d1, d2; /* row and column deltas */ + + if ((d1 = r1-r2) < 0) /* get absolute row delta */ + d1 = -d1; + if ((d2 = c1-c2) < 0) /* get absolute column delta */ + d2 = -d2; + +return( (d1+d2) * 50 * E_scale); + + if (!d1) /* in same row? */ + return( (d2*50*E_scale) ); /* 50 mils per cell */ + + if (!d2) /* in same column? */ + return( (d1*50*E_scale) ); /* 50 mils per cell */ + + if (d1 > d2) /* get smaller into d1 */ + { + EXCHG(d1,d2); + } + d2 -= d1; /* get non-diagonal part of approximate "route" */ + return( ((d1*71)+(d2*50))*E_scale ); /* 71 mils diagonally per cell */ + } + +/* distance to go thru a cell (en mils) */ +static int dist[10][10] = { /* OT=Otherside, OR=Origin (source) cell */ +/*..........N, NE, E, SE, S, SW, W, NW, OT, OR */ +/* N */ { 50, 60, 35, 60, 99, 60, 35, 60, 12, 12 }, +/* NE */ { 60, 71, 60, 71, 60, 99, 60, 71, 23, 23 }, +/* E */ { 35, 60, 50, 60, 35, 60, 99, 60, 12, 12 }, +/* SE */ { 60, 71, 60, 71, 60, 71, 60, 99, 23, 23 }, +/* S */ { 99, 60, 35, 60, 50, 60, 35, 60, 12, 12 }, +/* SW */ { 60, 99, 60, 71, 60, 71, 60, 71, 23, 23 }, +/* W */ { 35, 60, 99, 60, 35, 60, 50, 60, 12, 12 }, +/* NW */ { 60, 71, 60, 99, 60, 71, 60, 71, 23, 23 }, + +/* OT */ { 12, 23, 12, 23, 12, 23, 12, 23, 99, 99 }, +/* OR */ { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 } + }; + +/* penalty for extraneous holes and corners, scaled by sharpness of turn */ +static int penalty[10][10] = { /* OT=Otherside, OR=Origin (source) cell */ +/*......... N, NE, E, SE, S, SW, W, NW, OT, OR */ +/* N */ { 0, 5, 10, 15, 20, 15, 10, 5, 50, 0 }, +/* NE */ { 5, 0, 5, 10, 15, 20, 15, 10, 50, 0 }, +/* E */ { 10, 5, 0, 5, 10, 15, 20, 15, 50, 0 }, +/* SE */ { 15, 10, 5, 0, 5, 10, 15, 20, 50, 0 }, +/* S */ { 20, 15, 10, 5, 0, 5, 10, 15, 50, 0 }, +/* SW */ { 15, 20, 15, 10, 5, 0, 5, 10, 50, 0 }, +/* W */ { 10, 15, 20, 15, 10, 5, 0, 5, 50, 0 }, +/* NW */ { 5, 10, 15, 20, 15, 10, 5, 0, 50, 0 }, + +/* OT */ { 50, 50, 50, 50, 50, 50, 50, 50, 100, 0 }, +/* OR */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + }; + +/* penalty pour directions preferencielles */ +#define PN 20 +static int dir_penalty_TOP[10][10] = { +/* OT=Otherside, OR=Origin (source) cell */ +/*......... N, NE, E, SE, S, SW, W, NW, OT, OR */ +/* N */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 }, +/* NE */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 }, +/* E */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 }, +/* SE */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 }, +/* S */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 }, +/* SW */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 }, +/* W */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 }, +/* NW */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 }, + +/* OT */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 }, +/* OR */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 } + }; + +static int dir_penalty_BOTTOM[10][10] = { +/* OT=Otherside, OR=Origin (source) cell */ +/*......... N, NE, E, SE, S, SW, W, NW, OT, OR */ +/* N */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 }, +/* NE */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 }, +/* E */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 }, +/* SE */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 }, +/* S */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 }, +/* SW */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 }, +/* W */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 }, +/* NW */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 }, + +/* OT */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 }, +/* OR */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 } + }; + +/* +** x is the direction to enter the cell of interest. +** y is the direction to exit the cell of interest. +** z is the direction to really exit the cell, if y=FROM_OTHERSIDE. +** +** return the distance of the trace through the cell of interest. +** the calculation is driven by the tables above. +*/ + + /************************************/ + /* int CalcDist(int x,int y,int z ) */ + /************************************/ + + /* calculate distance of a trace through a cell */ +int CalcDist(int x,int y,int z ,int side ) +{ +int adjust, ldist; + + adjust = 0; /* set if hole is encountered */ + if (x == EMPTY) x = 10; + if (y == EMPTY) y = 10; + else if (y == FROM_OTHERSIDE) + { + if (z == EMPTY) z = 10; + adjust = penalty[x-1][z-1]; + } + ldist = dist[x-1][y-1] + penalty[x-1][y-1] + adjust ; + + if(Nb_Sides) + { + if(side == BOTTOM) ldist += dir_penalty_TOP[x-1][y-1]; + if(side == TOP) ldist += dir_penalty_BOTTOM[x-1][y-1]; + } + return(ldist * 10); +} + + diff --git a/pcbnew/docedit.cpp b/pcbnew/docedit.cpp new file mode 100644 index 0000000000..b162fb7c79 --- /dev/null +++ b/pcbnew/docedit.cpp @@ -0,0 +1,54 @@ + /****************************/ + /* PcbNew - docedit.cppp */ + /****************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + + +/*******************************************************************/ +int KeyWordOk(const wxString & KeyList, const wxString & Database ) +/*******************************************************************/ +/* Recherche si dans le texte Database on retrouve tous les mots + cles donnes dans KeyList ( KeyList = suite de mots cles + separes par des espaces +*/ +{ +char * Keys, *Token, *Data, * TLoc = NULL; + + if(*KeyList < ' ' ) return(0); + + Keys = strdup(KeyList.GetData()); strupper(Keys); + Data = strdup(Database.GetData()); strupper(Data); + + Token = strtok(Keys," \n\r"); + while (Token) + { + TLoc = strstr( Data, Token); + if( TLoc == NULL) break; + /* Verification que la chaine trouvee ne soit pas un morceau de mot */ + if( TLoc > Data ) + { + if ( *(TLoc-1) != ' ' ) + { + TLoc = NULL; break; + } + } + TLoc += strlen(Token); + if( *TLoc > ' ' ) { TLoc = NULL; break; } + Token = strtok(NULL," \n\r"); + } + + free( Keys ); + free( Data ); + + if ( TLoc ) return (1); + return(0); +} + + diff --git a/pcbnew/drag.h b/pcbnew/drag.h new file mode 100644 index 0000000000..a38182194a --- /dev/null +++ b/pcbnew/drag.h @@ -0,0 +1,41 @@ + /***************************************************************/ + /* Edition des Modules: Structures et variables de gestion des */ + /* fonctions de "DRAG" des segments de piste */ + /***************************************************************/ + +class DRAG_SEGM +{ +public: + + DRAG_SEGM * Pnext; /* Pointeur de chainage */ + TRACK * m_Segm; /* pointeur sur le segment a "dragger */ + D_PAD * m_Pad_Start; /* pointeur sur le Pad origine si origine segment sur pad */ + D_PAD * m_Pad_End; /* pointeur sur le Pad fin si fin segment sur pad */ + int m_Flag; /* indicateur divers */ + +private: + wxPoint m_StartInitialValue; + wxPoint m_EndInitialValue; /* For abort: initial m_Start and m_End values for m_Segm */ + + +public: + + DRAG_SEGM(TRACK * segm); + ~DRAG_SEGM(); + + void SetInitialValues(void); + +}; + + /* Variables */ + +eda_global DRAG_SEGM * g_DragSegmentList; /* pointe le debut de la liste + des structures DRAG_SEGM */ + +/* routines specifiques */ +void Dessine_Segments_Dragges(WinEDA_DrawPanel * panel, wxDC * DC); +void Build_Drag_Liste(WinEDA_DrawPanel * panel, wxDC * DC, MODULE * Module); +void Build_1_Pad_SegmentsToDrag(WinEDA_DrawPanel * panel, wxDC * DC, D_PAD * PtPad ); +void Collect_TrackSegmentsToDrag(WinEDA_DrawPanel * panel, wxDC * DC, + wxPoint & point, int MasqueLayer, int net_code); +void EraseDragListe(void); diff --git a/pcbnew/dragsegm.cpp b/pcbnew/dragsegm.cpp new file mode 100644 index 0000000000..813da6c6f0 --- /dev/null +++ b/pcbnew/dragsegm.cpp @@ -0,0 +1,213 @@ + /*********************************************************/ + /* Routines relatives a la gestions des pistes en "DRAG" */ + /*********************************************************/ + + /* Fichier dragsegm.cpp */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "trigo.h" + +#include "protos.h" + +#include "drag.h" + +/* fonctions locales */ + +DRAG_SEGM::DRAG_SEGM(TRACK * segm) +{ + m_Segm = segm; + m_StartInitialValue = m_Segm->m_Start; + m_EndInitialValue = m_Segm->m_End; + + m_Pad_Start = m_Pad_End = NULL; + m_Flag = 0; +} + + +DRAG_SEGM::~DRAG_SEGM() +{ +} + + +void DRAG_SEGM::SetInitialValues(void) +{ + m_Segm->m_Start = m_StartInitialValue; + m_Segm->m_End = m_EndInitialValue; +} + +/*******************************************************************/ +void Dessine_Segments_Dragges(WinEDA_DrawPanel * panel, wxDC * DC) +/*******************************************************************/ +/* trace les segments dragges en mode EDIT */ +{ +D_PAD* pt_pad; +TRACK * Track; +DRAG_SEGM * pt_drag; + + if(g_DragSegmentList == NULL ) return; + + pt_drag = g_DragSegmentList; + for( ; pt_drag; pt_drag = pt_drag->Pnext) + { + int px, py; + + Track = pt_drag->m_Segm; + + Track->Draw(panel, DC, GR_XOR); /* effacement */ + + pt_pad = pt_drag->m_Pad_Start; + if( pt_pad) + { + px = pt_pad->m_Pos.x - g_Offset_Module.x; + py = pt_pad->m_Pos.y - g_Offset_Module.y; + Track->m_Start.x = px; Track->m_Start.y = py; + } + pt_pad = pt_drag->m_Pad_End; + if( pt_pad) + { + px = pt_pad->m_Pos.x - g_Offset_Module.x; + py = pt_pad->m_Pos.y - g_Offset_Module.y; + Track->m_End.x = px; Track->m_End.y = py; + } + Track->Draw(panel, DC, GR_XOR); + } +} + + +/*************************************************************************/ +void Build_Drag_Liste(WinEDA_DrawPanel * panel, wxDC * DC, MODULE * Module) +/*************************************************************************/ +/* Construit la liste des segments connectes aus pads du module Module + pour le drag de ces segments + la liste est mise a l'adresse pointee par pt_drag. + la variable globale nb_drag_segment est incrementee du nombre de segments + Met l'attribut EDIT sur les segments selectionnes + et les affiche en mode EDIT (sketch) +*/ +{ +D_PAD * pt_pad; + + pt_pad = Module->m_Pads; + for( ; pt_pad != NULL ; pt_pad = (D_PAD *) pt_pad->Pnext) + { + Build_1_Pad_SegmentsToDrag(panel, DC, pt_pad); + } + return; +} + + +/**********************************************************************************/ +void Build_1_Pad_SegmentsToDrag(WinEDA_DrawPanel * panel, wxDC * DC, D_PAD * PtPad) +/**********************************************************************************/ +/* Routine construisant la liste les segments de piste connectes au pad PtPad + Les net_codes sont supposes a jour. +*/ +{ +TRACK * Track; +DRAG_SEGM * pt_drag; +int net_code = PtPad->m_NetCode; +int pX, pY, MasqueLayer; +BOARD * pcb = ((WinEDA_BasePcbFrame*)(panel->m_Parent))->m_Pcb; + + Track = pcb->m_Track->GetStartNetCode(net_code); + + pX = PtPad->m_Pos.x; pY = PtPad->m_Pos.y; + MasqueLayer = PtPad->m_Masque_Layer; + for( ; Track != NULL; Track = (TRACK*)Track->Pnext ) + { + if( Track->m_NetCode != net_code ) break; /* hors zone */ + if( (MasqueLayer & Track->ReturnMaskLayer()) == 0 ) continue; /* couches differentes */ + if( (pX == Track->m_Start.x) && (pY == Track->m_Start.y) ) + { + pt_drag = new DRAG_SEGM(Track); + pt_drag->Pnext = g_DragSegmentList; + g_DragSegmentList = pt_drag; + pt_drag->m_Pad_Start = PtPad; + Track->Draw(panel, DC, GR_XOR); + Track->SetState(EDIT,ON); + Track->Draw(panel, DC, GR_XOR); + } + if( (pX == Track->m_End.x) && (pY == Track->m_End.y) ) + { + pt_drag = new DRAG_SEGM(Track); + pt_drag->Pnext = g_DragSegmentList; + g_DragSegmentList = pt_drag; + pt_drag->m_Pad_End = PtPad; + Track->Draw(panel, DC, GR_XOR); + Track->SetState(EDIT,ON); + Track->Draw(panel, DC, GR_XOR); + } + } +} + + +/**********************************************************************************/ +void Collect_TrackSegmentsToDrag(WinEDA_DrawPanel * panel, wxDC * DC, + wxPoint & point, int MasqueLayer, int net_code) +/**********************************************************************************/ +/* Routine construisant la liste les segments de piste connectes a la via Via + Les net_codes sont supposes a jour. +*/ +{ +TRACK * Track; +DRAG_SEGM * pt_drag; +int pX, pY; +BOARD * pcb = ((WinEDA_BasePcbFrame*)(panel->m_Parent))->m_Pcb; + + Track = pcb->m_Track->GetStartNetCode(net_code); + + pX = point.x; pY = point.y; + for( ; Track != NULL; Track = (TRACK*)Track->Pnext ) + { + if( Track->m_NetCode != net_code ) break; /* hors zone */ + if( (MasqueLayer & Track->ReturnMaskLayer()) == 0 ) continue; /* couches differentes */ + if ( Track->m_Flags & IS_DRAGGED) continue; // already in list + if( (pX == Track->m_Start.x) && (pY == Track->m_Start.y) ) + { + pt_drag = new DRAG_SEGM(Track); + pt_drag->Pnext = g_DragSegmentList; + g_DragSegmentList = pt_drag; + pt_drag->m_Flag |= 1; + Track->Draw(panel, DC, GR_XOR); + Track->SetState(EDIT,ON); + Track->m_Flags |= STARTPOINT; + Track->Draw(panel, DC, GR_XOR); + } + if( (pX == Track->m_End.x) && (pY == Track->m_End.y) ) + { + pt_drag = new DRAG_SEGM(Track); + pt_drag->Pnext = g_DragSegmentList; + g_DragSegmentList = pt_drag; + pt_drag->m_Flag |= 2; + Track->m_Flags |= ENDPOINT; + Track->Draw(panel, DC, GR_XOR); + Track->SetState(EDIT,ON); + Track->Draw(panel, DC, GR_XOR); + } + } +} + + +/*****************************/ +void EraseDragListe(void) +/*****************************/ +/* Routine de liberation memoire de la liste des structures DRAG_SEGM + remet a zero le pointeur global g_DragSegmentList +*/ +{ +DRAG_SEGM * pt_drag, * NextStruct; + + if( g_DragSegmentList == NULL ) return; + + pt_drag = g_DragSegmentList; + for( ; pt_drag != NULL; pt_drag = NextStruct) + { + NextStruct = pt_drag->Pnext; delete pt_drag; + } + g_DragSegmentList = NULL; +} diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp new file mode 100644 index 0000000000..8a2cb69828 --- /dev/null +++ b/pcbnew/drc.cpp @@ -0,0 +1,1103 @@ + /*******************************/ + /* Edition des pistes */ + /* Routines DRC */ + /*******************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "trigo.h" + +#include "protos.h" + +/* variables locales */ +class WinEDA_DrcFrame; +WinEDA_DrcFrame * DrcFrame; + +int NumberOfErrors; +static MARQUEUR * current_marqueur; /* Pour gestion des marqueurs sur pcb */ + +bool AbortDrc, DrcInProgress = FALSE; +static int spot_cX, spot_cY; /* position d'elements a tester */ +static int finx, finy; // coord relatives de l'extremite du segm de reference +static int segm_angle; // angle d'inclinaison du segment de reference en 0,1 degre +static int segm_long; // longueur du segment de reference +static int xcliplo,ycliplo,xcliphi,ycliphi ; /* coord de la surface de securite du segment a comparer */ + +/* Routines Locales */ +static int Pad_to_Pad_Isol(const D_PAD * pad_ref, const D_PAD * pad, const int dist_min); +static bool TestPadDrc(WinEDA_BasePcbFrame *frame, wxDC * DC, D_PAD * pad_ref, + LISTE_PAD * start_buffer, LISTE_PAD * end_buffer, int max_size, bool show_err); +static int distance_a_pad(const D_PAD* pad_to_test, int seg_width, int isol); +static int distance_a_rond(int cx, int cy, int rayon, int longueur); +static int Tst_Ligne(int x1,int y1,int x2,int y2); +static void Affiche_Erreur_DRC(WinEDA_DrawPanel * panel, wxDC * DC, BOARD * Pcb, + TRACK * pt_ref, void * pt_item, int errnumber); +static void Affiche_Erreur_DRC(WinEDA_DrawPanel * panel, wxDC * DC, + BOARD * Pcb, const D_PAD * pad1, const D_PAD * pad2); + + + + /*******************************************/ + /* Frame d'option et execution DRC general */ + /*******************************************/ +#include "dialog_drc.cpp" + +/***************************************************************/ +void WinEDA_DrcFrame::ListUnconnectedPads(wxCommandEvent & event) +/***************************************************************/ +{ + if( (m_Parent->m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 ) + { + m_Parent->Compile_Ratsnest( m_DC, TRUE); + } + if( m_Parent->m_Pcb->m_Ratsnest == NULL ) return; + +CHEVELU* Ratsnest = m_Parent->m_Pcb->m_Ratsnest; +int draw_mode = GR_SURBRILL | GR_OR; +WinEDA_DrawPanel * panel = m_Parent->DrawPanel; +int ii; +wxString msg; +float convert = 0.0001; +int unconnect = 0; + for( ii = m_Parent->m_Pcb->GetNumRatsnests() ;ii > 0; Ratsnest++, ii--) + { + if( (Ratsnest->status & CH_ACTIF) == 0) continue; + unconnect++; + Ratsnest->pad_start->Draw(panel, m_DC, wxPoint(0,0),draw_mode); + Ratsnest->pad_end->Draw(panel, m_DC, wxPoint(0,0),draw_mode); + msg.Printf(_("Unconnected:\nPad @ %.4f,%.4f and\nPad @ %.4f,%.4f\n"), + Ratsnest->pad_start->m_Pos.x * convert, Ratsnest->pad_start->m_Pos.y * convert, + Ratsnest->pad_end->m_Pos.x * convert, Ratsnest->pad_end->m_Pos.y * convert); + m_logWindow->AppendText(msg); + } + + if ( unconnect ) msg.Printf(_("Active routes: %d\n"), unconnect); + else msg = _("OK! (No unconnect)\n"); + m_logWindow->AppendText(msg); + m_logWindow->AppendText(_("End tst")); +} + + +/****************************************************/ +void WinEDA_DrcFrame::TestDrc(wxCommandEvent & event) +/****************************************************/ +{ +int errors; +wxString msg; + if ( ! DrcInProgress ) + { + AbortDrc = FALSE; + m_logWindow->Clear(); + g_DesignSettings.m_TrackClearence = + ReturnValueFromTextCtrl(*m_SetClearance, m_Parent->m_InternalUnits); + errors = m_Parent->Test_DRC(m_DC); + if ( errors ) + msg.Printf(_("** End Drc: %d errors **\n"),errors); + else msg = _("** End Drc: No Error **\n"); + m_logWindow->AppendText(msg); + } + else wxBell(); +} + +/*********************************************************/ +void WinEDA_DrcFrame::DelDRCMarkers(wxCommandEvent & event) +/*********************************************************/ +{ + if ( ! DrcInProgress ) + { + m_Parent->Erase_Marqueurs(m_DC, FALSE); + m_Parent->DrawPanel->ReDraw(m_DC,TRUE); + } + else wxBell(); +} + +/******************************************************/ +void WinEDA_PcbFrame::Install_Test_DRC_Frame(wxDC * DC) +/******************************************************/ +/* Test des isolements : teste les isolements des pistes et place un + marqueur sur les divers segments en defaut + Principe: + Appelle la routine drc() pour chaque segment de piste existant +*/ +{ + AbortDrc = FALSE; + DrcFrame = new WinEDA_DrcFrame(this, DC); + DrcFrame->ShowModal(); DrcFrame->Destroy(); + DrcFrame = NULL; +} + + +/***************************************/ +int WinEDA_PcbFrame::Test_DRC(wxDC * DC) +/***************************************/ +/* Test des isolements : teste les isolements des pistes et place un + marqueur sur les divers segments en defaut + Principe: + Appelle la routine drc() pour chaque segment de piste existant +*/ +{ +int ii, old_net; +int flag_err_Drc; +TRACK * pt_segm; +D_PAD * pad; +MARQUEUR * Marqueur; +EDA_BaseStruct * PtStruct, *PtNext; +wxString Line; +#define PRINT_NB_PAD_POS 42 +#define PRINT_PAD_ERR_POS 48 +#define PRINT_TST_POS 20 +#define PRINT_NB_SEGM_POS 26 +#define PRINT_TRACK_ERR_POS 32 + + DrcInProgress = TRUE; + NumberOfErrors = 0; + Compile_Ratsnest(DC, TRUE); + + MsgPanel->EraseMsgBox(); + + m_CurrentScreen->SetRefreshReq(); + + /* Effacement des anciens marqueurs */ + PtStruct = (EDA_BaseStruct*) m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtNext) + { + PtNext = PtStruct->Pnext; + if(PtStruct->m_StructType == TYPEMARQUEUR ) DeleteStructure(PtStruct); + } + + /* Test DRC des pads entre eux */ + Line.Printf( wxT("%d"),m_Pcb->m_NbPads) ; + Affiche_1_Parametre(this, PRINT_NB_PAD_POS, wxT("NbPad"),Line,RED) ; + Affiche_1_Parametre(this, PRINT_PAD_ERR_POS, wxT("Pad Err"), wxT("0"), LIGHTRED); + Line = wxT("Tst Pad to Pad\n"); + if ( DrcFrame ) DrcFrame->m_logWindow->AppendText(Line); + LISTE_PAD * pad_list_start = CreateSortedPadListByXCoord(m_Pcb); + LISTE_PAD * pad_list_limit = &pad_list_start[m_Pcb->m_NbPads]; + int max_size = 0; + LISTE_PAD * pad_list; + /* Compute the max size of the pads ( used to stop the test) */ + for ( pad_list = pad_list_start; pad_list < pad_list_limit; pad_list++) + { + pad = * pad_list; + if ( pad->m_Rayon > max_size ) max_size = pad->m_Rayon; + } + /* Test the pads */ + for ( pad_list = pad_list_start; pad_list < pad_list_limit; pad_list++) + { + pad = * pad_list; + if ( TestPadDrc(this, DC, pad, pad_list, pad_list_limit, max_size, TRUE) == BAD_DRC ) + { + Marqueur = current_marqueur; + current_marqueur = NULL; + if( Marqueur == NULL ) + { + DisplayError(this, wxT("Test_Drc(): internal err")); + return NumberOfErrors; + } + Line.Printf( wxT("%d"),NumberOfErrors) ; + Affiche_1_Parametre(this, PRINT_PAD_ERR_POS,wxEmptyString,Line, LIGHTRED); + Marqueur->Pnext = m_Pcb->m_Drawings; + Marqueur->Pback = m_Pcb; + + PtStruct = m_Pcb->m_Drawings; + if(PtStruct) PtStruct->Pback = Marqueur; + m_Pcb->m_Drawings = Marqueur; + } + } + free(pad_list_start); + + /* Test des segments de piste */ + Line.Printf( wxT("%d"),m_Pcb->m_NbSegmTrack) ; + Affiche_1_Parametre(this, PRINT_NB_SEGM_POS,_("SegmNb"),Line,RED) ; + Affiche_1_Parametre(this, PRINT_TRACK_ERR_POS,_("Track Err"), wxT("0"), LIGHTRED); + pt_segm = (TRACK*)m_Pcb->m_Track; + + if ( DrcFrame ) DrcFrame->m_logWindow->AppendText( _("Tst Tracks\n") ); + for( ii = 0, old_net = -1; pt_segm != NULL; pt_segm = (TRACK*)pt_segm->Pnext, ii++) + { + wxYield(); + if(AbortDrc) + { + AbortDrc = FALSE; break; + } + if( pt_segm->Pnext == NULL) break; + g_HightLigth_NetCode = pt_segm->m_NetCode; + flag_err_Drc = Drc(this, DC, pt_segm,(TRACK*)pt_segm->Pnext, 1); + Line.Printf( wxT("%d"),ii); + Affiche_1_Parametre(this, PRINT_TST_POS, wxT("Test"),Line,CYAN) ; + if ( old_net != pt_segm->m_NetCode) + { + wxString msg; + EQUIPOT * equipot = GetEquipot(m_Pcb, pt_segm->m_NetCode); + if ( equipot ) msg = equipot->m_Netname + wxT(" "); + else msg = wxT(""); + Affiche_1_Parametre(this, 0,_("Netname"),msg, YELLOW); + old_net = pt_segm->m_NetCode; + } + if(flag_err_Drc == BAD_DRC) + { + Marqueur = current_marqueur; + current_marqueur = NULL; + if( Marqueur == NULL ) + { + DisplayError(this, wxT("Test_Drc(): internal err")); + return NumberOfErrors; + } + Marqueur->Pnext = m_Pcb->m_Drawings; + Marqueur->Pback = m_Pcb; + + PtStruct = m_Pcb->m_Drawings; + if(PtStruct) PtStruct->Pback = Marqueur; + m_Pcb->m_Drawings = Marqueur; + + GRSetDrawMode(DC, GR_OR); + pt_segm->Draw(DrawPanel, DC, RED^LIGHTRED ); + Line.Printf( wxT("%d"),NumberOfErrors); + Affiche_1_Parametre(this, PRINT_TRACK_ERR_POS,wxEmptyString,Line, LIGHTRED); + Line.Printf( wxT("%d"),m_Pcb->m_NbSegmTrack); + Affiche_1_Parametre(this, PRINT_NB_SEGM_POS,wxEmptyString,Line,RED) ; + } + } + + AbortDrc = FALSE; + DrcInProgress = FALSE; + return NumberOfErrors; +} + + +/***********************************************************************/ +int Drc(WinEDA_BasePcbFrame *frame, wxDC * DC, + TRACK * pt_segment, TRACK * StartBuffer, int show_err) +/***********************************************************************/ +/* +Teste le segment en cours de trace: + pt_segment = pointeur sur segment a controler + StartBuffer = adresse de la zone des pistes a controler + (typiquement m_Pcb->m_Track) + show_err (flag) si 0 pas d'affichage d'erreur sur ecran + retourne : + BAD_DRC (1) si Violation DRC + OK_DRC (0) si OK +*/ +{ +int ii ; +TRACK * pttrack; +int x0,y0,xf,yf ; // coord des extremites du segment teste dans le repere modifie +int dx, dy; // utilise pour calcul des dim x et dim y des segments +int w_dist; +int MaskLayer ; +int net_code_ref; +int org_X, org_Y; // Origine sur le PCB des axes du repere centre sur + // l'origine du segment de reference +wxPoint shape_pos; + + org_X = pt_segment->m_Start.x; org_Y = pt_segment->m_Start.y ; + finx = dx = pt_segment->m_End.x - org_X ; + finy = dy = pt_segment->m_End.y - org_Y ; + MaskLayer = pt_segment->ReturnMaskLayer(); + net_code_ref = pt_segment->m_NetCode; + + segm_angle = 0; + if( dx || dy) + { + /* calcul de l'angle d'inclinaison en 0,1 degre */ + segm_angle = ArcTangente(dy,dx); + /* Calcul de la longueur du segment en segm_long : dx = longueur */ + RotatePoint(&dx, &dy, segm_angle); /* segm_long = longueur, yf = 0 */ + } + + /* Ici le segment a ete tourne de segm_angle, et est horizontal, dx > 0 */ + segm_long = dx; + + /******************************************/ + /* Phase 1 : test DRC avec les pastilles :*/ + /******************************************/ + + /* calcul de la distance min aux pads : */ + w_dist = (unsigned)(pt_segment->m_Width >> 1 ) ; + for ( ii = 0 ; ii < frame->m_Pcb->m_NbPads ; ii++) + { + D_PAD * pt_pad = frame->m_Pcb->m_Pads[ii]; + + /* Pas de probleme si les pads sont en surface autre que la couche, + sauf si le trou de percage gene (cas des pastilles percées simple + face sur CI double face */ + if( (pt_pad->m_Masque_Layer & MaskLayer ) == 0 ) + { + /* We must test the pad hole. In order to use the function "distance_a_pad", + a pseudo pad is used, with a shape and a size like the hole */ + if ( pt_pad->m_Drill.x == 0 ) continue; + D_PAD pseudo_pad((MODULE*)NULL); + pseudo_pad.m_Size = pt_pad->m_Drill; + pseudo_pad.m_Pos = pt_pad->m_Pos; + pseudo_pad.m_PadShape = pt_pad->m_DrillShape; + pseudo_pad.m_Orient = pt_pad->m_Orient; + pseudo_pad.ComputeRayon(); + spot_cX = pseudo_pad.m_Pos.x - org_X; + spot_cY = pseudo_pad.m_Pos.y - org_Y; + if( distance_a_pad(&pseudo_pad, w_dist, g_DesignSettings.m_TrackClearence) != OK_DRC ) + { + NumberOfErrors++; + if( show_err ) + Affiche_Erreur_DRC(frame->DrawPanel, DC, + frame->m_Pcb, pt_segment,pt_pad,0); + return(BAD_DRC); + } + continue; + } + + /* Le pad doit faire partie d'un net mais pas de probleme + si le pad est du meme net */ + if( pt_pad->m_NetCode && (net_code_ref == pt_pad->m_NetCode) ) + continue ; + + /* Test DRC pour les pads */ + shape_pos = pt_pad->ReturnShapePos(); + spot_cX = shape_pos.x - org_X; + spot_cY = shape_pos.y - org_Y; + if( distance_a_pad(pt_pad, w_dist, g_DesignSettings.m_TrackClearence) == OK_DRC ) continue ; + + /* extremite sur pad ou defaut d'isolation trouve */ + else + { + NumberOfErrors++; + if( show_err ) + Affiche_Erreur_DRC(frame->DrawPanel, DC, + frame->m_Pcb, pt_segment,pt_pad,1); + return(BAD_DRC); + } + } + + /**********************************************/ + /* Phase 2 : test DRC avec les autres pistes :*/ + /**********************************************/ + + /* Ici le segment de reference est sur l'axe X */ + + /* Comparaison du segment de reference aux autres segments de piste */ + pttrack = StartBuffer ; + for ( ;pttrack != NULL ; pttrack = (TRACK*) pttrack->Pnext ) + { + //pas de probleme si le segment a tester est du meme net: + if( net_code_ref == pttrack->m_NetCode ) continue ; + //pas de probleme si le segment a tester est sur une autre couche : + if( (MaskLayer & pttrack->ReturnMaskLayer() ) == 0 ) continue ; + + /* calcul de la Distance mini = Isol+ rayon ou demi largeur seg ref + + rayon ou demi largeur seg a comparer */ + w_dist = pt_segment->m_Width >> 1; + w_dist += pttrack->m_Width >> 1; + w_dist += g_DesignSettings.m_TrackClearence; + + /* si le segment de reference est une via, le traitement est ici */ + if ( pt_segment->m_StructType == TYPEVIA ) + { + int orgx, orgy; // origine du repere d'axe X = segment a comparer + int angle = 0; // angle du segment a tester; + orgx = pttrack->m_Start.x; orgy = pttrack->m_Start.y; + dx = pttrack->m_End.x - orgx ; dy = pttrack->m_End.y - orgy; + x0 = pt_segment->m_Start.x - orgx ; y0 = pt_segment->m_Start.y - orgy ; + + if( pttrack->m_StructType == TYPEVIA) /* Tst distance entre 2 vias */ + { + if( (int)hypot((float)x0,(float)y0) < w_dist ) + { + NumberOfErrors++; + if( show_err) + Affiche_Erreur_DRC(frame->DrawPanel, DC, frame->m_Pcb, pt_segment,pttrack,21); + return(BAD_DRC) ; + } + } + else /* Tst distance de via a segment */ + { + /* calcul de l'angle */ + angle = ArcTangente(dy,dx); + + /* Calcul des coord dans le nouveau repere */ + RotatePoint(&dx, &dy, angle); + RotatePoint(&x0, &y0, angle); + + if( distance_a_rond(x0, y0, w_dist, dx) == BAD_DRC ) + { + NumberOfErrors++; + if(show_err) + Affiche_Erreur_DRC(frame->DrawPanel, DC, frame->m_Pcb, pt_segment,pttrack,20); + return(BAD_DRC) ; + } + } + continue; + } + + /* calcule x0,y0, xf,yf = coord de debut et fin du segment de piste + a tester, dans le repere axe X = segment de reference */ + x0 = pttrack->m_Start.x - org_X ; y0 = pttrack->m_Start.y - org_Y ; + xf = pttrack->m_End.x - org_X ; yf = pttrack->m_End.y - org_Y ; + + RotatePoint(&x0, &y0, segm_angle); RotatePoint(&xf, &yf, segm_angle); + + if ( pttrack->m_StructType == TYPEVIA ) + { + if( distance_a_rond(x0, y0,w_dist,segm_long) == OK_DRC) continue; + NumberOfErrors++; + if(show_err) + Affiche_Erreur_DRC(frame->DrawPanel, DC, frame->m_Pcb, pt_segment,pttrack,21); + return(BAD_DRC) ; + } + + + /* + le segment de reference est Horizontal, par suite des modifs d'axe. + 3 cas : segment a comparer parallele, perp ou incline + */ + if ( y0 == yf ) // segments paralleles + { + if ( abs(y0) >= w_dist ) continue ; + if ( x0 > xf) EXCHG (x0,xf) ; /* pour que x0 <= xf */ + + if ( x0 > (-w_dist) && x0 < (segm_long + w_dist)) /* Risque de defaut */ + { + /* test fin tenant compte des formes arrondies des extremites */ + if ( x0 >= 0 && x0 <= segm_long ) + { + NumberOfErrors++; + if ( show_err ) + Affiche_Erreur_DRC(frame->DrawPanel, DC, frame->m_Pcb, pt_segment,pttrack,2); + return(BAD_DRC) ; + } + if( distance_a_rond(x0, y0, w_dist,segm_long) == BAD_DRC) + { + NumberOfErrors++; + if(show_err) + Affiche_Erreur_DRC(frame->DrawPanel, DC, frame->m_Pcb, pt_segment,pttrack,2); + return(BAD_DRC) ; + } + } + if ( xf > (-w_dist) && xf < (segm_long + w_dist)) + { + /* test fin tenant compte des formes arrondies des extremites */ + if ( xf >= 0 && xf <= segm_long ) + { + NumberOfErrors++; + if(show_err) + Affiche_Erreur_DRC(frame->DrawPanel, DC, frame->m_Pcb, pt_segment,pttrack,3); + return(BAD_DRC) ; + } + if( distance_a_rond(xf, yf, w_dist,segm_long) == BAD_DRC) + { + NumberOfErrors++; + if(show_err) + Affiche_Erreur_DRC(frame->DrawPanel, DC, frame->m_Pcb, pt_segment,pttrack,3); + return(BAD_DRC) ; + } + } + + if ( x0 <=0 && xf >= 0 ) + { + NumberOfErrors++; + if(show_err) + Affiche_Erreur_DRC(frame->DrawPanel, DC, frame->m_Pcb, pt_segment,pttrack,4); + return(BAD_DRC) ; + } + } + + else if ( x0 == xf ) // segments perpendiculaires + { + if ( (x0 <= (-w_dist)) || (x0 >= (segm_long + w_dist))) continue ; + + /* test si les segments se croisent */ + if( y0 > yf ) EXCHG(y0, yf); + if( (y0 < 0) && (yf > 0) ) + { + NumberOfErrors++; + if( show_err) + Affiche_Erreur_DRC(frame->DrawPanel, DC, frame->m_Pcb, pt_segment,pttrack,6); + return(BAD_DRC); + } + + /* ici l'erreur est due a une extremite pres d'une extremite du segm + de reference */ + if(distance_a_rond(x0,y0,w_dist,segm_long) == BAD_DRC) + { + NumberOfErrors++; + if(show_err) + Affiche_Erreur_DRC(frame->DrawPanel, DC, frame->m_Pcb, pt_segment,pttrack,7); + return(BAD_DRC) ; + } + if(distance_a_rond(xf,yf,w_dist,segm_long) == BAD_DRC) + { + NumberOfErrors++; + if(show_err) + Affiche_Erreur_DRC(frame->DrawPanel, DC, frame->m_Pcb, pt_segment,pttrack,8); + return(BAD_DRC) ; + } + } + else // segments quelconques entre eux */ + { + int bflag = OK_DRC; + /* calcul de la "surface de securite du segment de reference */ + /* premiere passe : la piste est assimilee a un rectangle */ + + xcliplo = ycliplo = -w_dist; + xcliphi = segm_long + w_dist; ycliphi = w_dist; + + bflag = Tst_Ligne(x0,y0,xf,yf); + if (bflag == BAD_DRC) + { + /* 2eme passe : la piste a des extremites arrondies. + Si le defaut de drc est du a une extremite : le calcul + est affine pour tenir compte de cet arrondi */ + + xcliplo = 0 ; xcliphi = segm_long ; + bflag = Tst_Ligne(x0,y0,xf,yf) ; + + if(bflag == BAD_DRC) + { + NumberOfErrors++; + if(show_err) + Affiche_Erreur_DRC(frame->DrawPanel, DC, frame->m_Pcb, pt_segment,pttrack,9); + return(BAD_DRC) ; + } + + else // L'erreur est due a une extremite du segment de reference: + { // il faut tester les extremites de ce segment + int angle, rx0,ry0,rxf,ryf; + x0 = pttrack->m_Start.x; y0 = pttrack->m_Start.y; + xf = pttrack->m_End.x; yf = pttrack->m_End.y; + dx = xf - x0; dy = yf - y0; + /* calcul de l'angle d'inclinaison en 0,1 degre */ + angle = ArcTangente(dy,dx); + /* Calcul de la longueur du segment: dx = longueur */ + RotatePoint(&dx, &dy, angle); + + /* calcul des coord du segment de reference ds le repere + d'axe X = segment courant en tst */ + rx0 = pt_segment->m_Start.x - x0; + ry0 = pt_segment->m_Start.y - y0; + rxf = pt_segment->m_End.x - x0; + ryf = pt_segment->m_End.y - y0; + + RotatePoint(&rx0,&ry0, angle); + RotatePoint(&rxf,&ryf, angle); + if(distance_a_rond(rx0,ry0,w_dist,dx) == BAD_DRC) + { + NumberOfErrors++; + if(show_err) + Affiche_Erreur_DRC(frame->DrawPanel, DC, frame->m_Pcb, pt_segment,pttrack,10); + return(BAD_DRC) ; + } + if(distance_a_rond(rxf,ryf,w_dist,dx) == BAD_DRC) + { + NumberOfErrors++; + if(show_err) + Affiche_Erreur_DRC(frame->DrawPanel, DC, frame->m_Pcb, pt_segment,pttrack,11); + return(BAD_DRC) ; + } + } + } + } + } + return(OK_DRC) ; +} + +/*****************************************************************************/ +static bool TestPadDrc(WinEDA_BasePcbFrame *frame, wxDC * DC, D_PAD * pad_ref, + LISTE_PAD * start_buffer, LISTE_PAD * end_buffer, int max_size, bool show_err) +/*****************************************************************************/ +/* Teste l'isolation de pad_ref avec les autres pads. + end_buffer = upper limit of the pad list. + max_size = size of the biggest pad (used to stop the test when the X distance is > max_size) +*/ +{ +int MaskLayer; +D_PAD * pad; +LISTE_PAD * pad_list = start_buffer; + + MaskLayer = pad_ref->m_Masque_Layer & ALL_CU_LAYERS; + int x_limite = max_size + g_DesignSettings.m_TrackClearence + + pad_ref->m_Rayon + pad_ref->m_Pos.x; + for ( ; pad_list < end_buffer ; pad_list++) + { + pad = * pad_list; + if ( pad == pad_ref ) continue; + + /* We can stop the test when pad->m_Pos.x > x_limite + because the list is sorted by X values */ + if ( pad->m_Pos.x > x_limite ) break; + + /* Pas de probleme si les pads ne sont pas sur les memes couches cuivre*/ + if( (pad->m_Masque_Layer & MaskLayer ) == 0 ) continue; + + /* Le pad doit faire partie d'un net, + mais pas de probleme si les pads sont du meme net */ + if( pad->m_NetCode && (pad_ref->m_NetCode == pad->m_NetCode) ) + continue ; + + /* pas de pb si les pads sont du meme module et + de la meme reference ( pads multiples ) */ + if ( (pad->m_Parent == pad_ref->m_Parent) && + (strncmp(pad->m_Padname, pad_ref->m_Padname, 4 ) == 0) ) + continue; + + if( Pad_to_Pad_Isol(pad_ref, pad, g_DesignSettings.m_TrackClearence) == OK_DRC ) continue ; + else /* defaut d'isolation trouve */ + { + NumberOfErrors++; + if( show_err ) + Affiche_Erreur_DRC(frame->DrawPanel, DC, frame->m_Pcb, pad_ref, pad); + return(BAD_DRC); + } + } + return OK_DRC; +} + +/**************************************************************************************/ +static int Pad_to_Pad_Isol(const D_PAD * pad_ref, const D_PAD * pad, const int dist_min) +/***************************************************************************************/ +/* Return OK_DRC si distance entre pad_ref et pas >= dist_min +et BAD_DRC sinon */ +{ +wxPoint rel_pos; +int dist, diag; +wxPoint shape_pos; + + rel_pos = pad->ReturnShapePos(); + shape_pos = pad_ref->ReturnShapePos(); + rel_pos.x -= shape_pos.x; + rel_pos.y -= shape_pos.y; + dist = (int) hypot( (double) rel_pos.x, (double) rel_pos.y); + + /* tst rapide: si les cercles exinscrits sont distants de dist_min au moins, + il n'y a pas de risque: */ + if ( (dist - pad_ref->m_Rayon - pad->m_Rayon) >= dist_min ) + return OK_DRC; + + /* Ici les pads sont proches et les cercles exinxcrits sont trop proches + Selon les formes relatives il peut y avoir ou non erreur */ + if ( (pad_ref->m_PadShape != CIRCLE) && (pad->m_PadShape == CIRCLE) ) + { + EXCHG (pad_ref, pad); + rel_pos.x = - rel_pos.x; + rel_pos.y = - rel_pos.y; + } + + switch (pad_ref->m_PadShape) + { + case CIRCLE: // pad_ref est assimile a un segment de longeur nulle + segm_long = 0; + segm_angle = 0; + finx = finy = 0; + spot_cX = rel_pos.x; + spot_cY = rel_pos.y; + diag = distance_a_pad(pad, pad_ref->m_Rayon, dist_min ); + break; + + case RECT: + case OVALE : + default: + /* TODO...*/ + diag = OK_DRC; + break; + } + return diag; +} + +/***************************************************************************/ +static int distance_a_pad(const D_PAD* pad_to_test, int w_segm, int dist_min) +/****************************************************************************/ +/* + Routine adaptee de la "distance()" (LOCATE.CC) + teste la distance du pad au segment de droite en cours + + retourne: + 0 si distance >= dist_min + 1 si distance < dist_min + Parametres d'appel: + pad_to_test = pointeur sur le pad a tester + w_segm = demi largeur du segment a tester + dist_min = marge a respecter + + en variables globales + segm_long = longueur du segment en test + segm_angle = angle d'inclinaison du segment; + finx, finy = coord fin du segment / origine + spot_cX, spot_cY = position du pad / origine du segment +*/ +{ +int p_dimx, p_dimy ; /* demi - dimensions X et Y du pad a controler */ +int bflag; +int orient; +int x0, y0, xf, yf ; +int seuil; +int deltay; + + seuil = w_segm + dist_min; + p_dimx = pad_to_test->m_Size.x >> 1 ; + p_dimy = pad_to_test->m_Size.y >> 1 ; + + if (pad_to_test->m_PadShape == CIRCLE ) + { + /* calcul des coord centre du pad dans le repere axe X confondu + avec le segment en tst */ + RotatePoint(&spot_cX, &spot_cY, segm_angle); + return (distance_a_rond(spot_cX, spot_cY, seuil+p_dimx, segm_long)); + } + else + { + /* calcul de la "surface de securite" du pad de reference */ + xcliplo = spot_cX - seuil - p_dimx ; + ycliplo = spot_cY - seuil - p_dimy; + xcliphi = spot_cX + seuil + p_dimx; + ycliphi = spot_cY + seuil + p_dimy; + x0 = y0 = 0 ; xf = finx; yf = finy ; + orient = pad_to_test->m_Orient; + RotatePoint(&x0,&y0,spot_cX, spot_cY, -orient); + RotatePoint(&xf,&yf,spot_cX, spot_cY, -orient); + + bflag = Tst_Ligne(x0,y0,xf,yf) ; + + if (bflag == OK_DRC) return (OK_DRC); + /* Erreur DRC : analyse fine de la forme de la pastille */ + + switch (pad_to_test->m_PadShape ) + { + default: return(BAD_DRC); + + case OVALE : + /* test de la pastille ovale ramenee au type ovale vertical */ + if (p_dimx > p_dimy) + { + EXCHG(p_dimx,p_dimy); orient += 900; + if(orient >= 3600) orient -=3600; + } + deltay = p_dimy - p_dimx; + /* ici: p_dimx = rayon, + delta = dist centre cercles a centre pad */ + + /* Test du rectangle separant les 2 demi cercles */ + xcliplo = spot_cX - seuil - p_dimx; + ycliplo = spot_cY - w_segm - deltay; + xcliphi = spot_cX + seuil + p_dimx; + ycliphi = spot_cY + w_segm + deltay; + + bflag = Tst_Ligne(x0,y0,xf,yf); + if (bflag == BAD_DRC) return(BAD_DRC); + + /* test des 2 cercles */ + x0 = spot_cX; /* x0,y0 = centre du cercle superieur du pad ovale */ + y0 = spot_cY + deltay; + RotatePoint(&x0,&y0, spot_cX, spot_cY, orient); + RotatePoint(&x0,&y0, segm_angle); + bflag = distance_a_rond(x0,y0,p_dimx + seuil, segm_long); + if( bflag == BAD_DRC) return(BAD_DRC); + + x0 = spot_cX; /* x0,y0 = centre du cercle inferieur du pad ovale */ + y0 = spot_cY - deltay; + RotatePoint(&x0,&y0, spot_cX, spot_cY, orient); + RotatePoint(&x0,&y0, segm_angle); + bflag = distance_a_rond(x0,y0,p_dimx + seuil, segm_long); + if( bflag == BAD_DRC) return(BAD_DRC); + break; + + case RECT: /* 2 rectangle + 4 1/4 cercles a tester */ + /* Test du rectangle dimx + seuil, dimy */ + xcliplo = spot_cX - p_dimx - seuil; + ycliplo = spot_cY - p_dimy; + xcliphi = spot_cX + p_dimx + seuil; + ycliphi = spot_cY + p_dimy; + + bflag = Tst_Ligne(x0,y0,xf,yf); + if (bflag == BAD_DRC) + { + return(BAD_DRC); + } + + /* Test du rectangle dimx , dimy + seuil */ + xcliplo = spot_cX - p_dimx; + ycliplo = spot_cY - p_dimy - seuil; + xcliphi = spot_cX + p_dimx; + ycliphi = spot_cY + p_dimy + seuil; + + bflag = Tst_Ligne(x0,y0,xf,yf); + if (bflag == BAD_DRC) + { + return(BAD_DRC); + } + + /* test des 4 cercles ( surface d'solation autour des sommets */ + /* test du coin sup. gauche du pad */ + x0 = spot_cX - p_dimx; + y0 = spot_cY - p_dimy; + RotatePoint(&x0,&y0, spot_cX, spot_cY, orient); + RotatePoint(&x0,&y0, segm_angle); + bflag = distance_a_rond(x0, y0, seuil, segm_long); + if( bflag == BAD_DRC) + { + return(BAD_DRC); + } + + /* test du coin sup. droit du pad */ + x0 = spot_cX + p_dimx; + y0 = spot_cY - p_dimy; + RotatePoint(&x0,&y0, spot_cX, spot_cY, orient); + RotatePoint(&x0,&y0, segm_angle); + bflag = distance_a_rond(x0, y0, seuil, segm_long); + if( bflag == BAD_DRC) + { + return(BAD_DRC); + } + + /* test du coin inf. gauche du pad */ + x0 = spot_cX - p_dimx; + y0 = spot_cY + p_dimy; + RotatePoint(&x0,&y0, spot_cX, spot_cY, orient); + RotatePoint(&x0,&y0, segm_angle); + bflag = distance_a_rond(x0, y0, seuil, segm_long); + if( bflag == BAD_DRC) + { + return(BAD_DRC); + } + + /* test du coin inf. droit du pad */ + x0 = spot_cX + p_dimx; + y0 = spot_cY + p_dimy; + RotatePoint(&x0,&y0, spot_cX, spot_cY, orient); + RotatePoint(&x0,&y0, segm_angle); + bflag = distance_a_rond(x0, y0, seuil, segm_long); + if( bflag == BAD_DRC) + { + return(BAD_DRC); + } + + break; + + } + } + return(OK_DRC) ; +} + +/*******************************************************************/ +static int distance_a_rond(int cx, int cy, int rayon, int longueur ) +/*******************************************************************/ +/* + Routine analogue a distance_a_pad. + Calcul de la distance d'un cercle (via ronde, extremite de piste) + au segment de droite en cours de controle (segment de reference dans + son repere ) + parametres: + cx, cy: centre du cercle (surface ronde) a tester, dans le repere + segment de reference + rayon = rayon du cercle + longueur = longueur du segment dans son repere (i.e. coord de fin) + retourne: + OK_DRC si distance >= rayon + BAD_DRC si distance < rayon +*/ +{ + if ( abs(cy) > rayon) return(OK_DRC); + + if ( (cx >= -rayon ) && (cx <= (longueur+rayon) ) ) + { + if( (cx >= 0) && (cx <= longueur) ) return(BAD_DRC) ; + if( cx > longueur) cx -= longueur ; + if( hypot((double)cx, (double)cy) < rayon ) return(BAD_DRC); + } + + return(OK_DRC) ; +} + + +/******************************************************************************/ +static void Affiche_Erreur_DRC(WinEDA_DrawPanel * panel, wxDC * DC, BOARD * Pcb, + TRACK * pt_ref, void * pt_item, int errnumber) +/******************************************************************************/ + +/* affiche les erreurs de DRC : + Message d'erreur + + + Marqueur + number = numero d'identification +*/ +{ +int ercx, ercy; +D_PAD * pt_pad; +TRACK * pt_segm; +wxString msg; + + if( ((EDA_BaseStruct*)pt_item)->m_StructType == TYPEPAD ) + { + pt_pad = (D_PAD*) pt_item; + ercx = pt_pad->m_Pos.x; ercy = pt_pad->m_Pos.y; + msg.Printf(_("%d Err type %d sur PAD @ %d,%d\n"), + NumberOfErrors, errnumber, ercx,ercy); + } + else /* erreur sur segment de piste */ + { + pt_segm = (TRACK *) pt_item; + ercx = pt_segm->m_Start.x; ercy = pt_segm->m_Start.y; + if(pt_segm->m_StructType == TYPEVIA) + { + msg.Printf(_("%d Err type %d: sur VIA @ %d,%d\n"), + NumberOfErrors, errnumber,ercx,ercy); + } + else + { + int ercfx = pt_segm->m_End.x, ercfy = pt_segm->m_End.y; + if(hypot( (double)(ercfx - pt_ref->m_End.x),(double)(ercfy - pt_ref->m_End.y) ) + < hypot( (double)(ercx - pt_ref->m_End.x),(double)(ercy - pt_ref->m_End.y) ) ) + { + EXCHG(ercfx, ercx); EXCHG(ercfy, ercy); + } + msg.Printf(_("%d Err type %d: sur SEGMENT @ %d,%d\n"), + NumberOfErrors, errnumber,ercx,ercy); + } + } + + if ( DrcFrame ) DrcFrame->m_logWindow->AppendText(msg); + else panel->m_Parent->Affiche_Message(msg); + + if(current_marqueur == NULL) current_marqueur = new MARQUEUR(Pcb); + current_marqueur->m_Pos = wxPoint(ercx, ercy); + current_marqueur->m_Color = WHITE; + current_marqueur->m_Diag = msg; + current_marqueur->Draw(panel, DC, GR_OR); +} + + +/******************************************************************************/ +static void Affiche_Erreur_DRC(WinEDA_DrawPanel * panel, wxDC * DC, BOARD * Pcb, + const D_PAD * pad1, const D_PAD * pad2) +/******************************************************************************/ + +/* affiche les erreurs de DRC : + Message d'erreur + + + Marqueur + number = numero d'identification +*/ +{ +int ercx, ercy; +wxString msg; + + ercx = pad1->m_Pos.x; ercy = pad1->m_Pos.y; + msg.Printf( _("%d Err pad to pad (PAD @ %d,%d and PAD @ %d,%d\n"), + NumberOfErrors, ercx,ercy, + pad2->m_Pos.x, pad2->m_Pos.y); + if ( DrcFrame ) DrcFrame->m_logWindow->AppendText(msg); + else panel->m_Parent->Affiche_Message(msg); + + if(current_marqueur == NULL) current_marqueur = new MARQUEUR(Pcb); + current_marqueur->m_Pos = wxPoint(ercx, ercy); + current_marqueur->m_Color = WHITE; + current_marqueur->m_Diag = msg; + current_marqueur->Draw(panel, DC, GR_OR); +} + + + /**********************************************/ + /* int Tst_Ligne(int x1,int y1,int x2,int y2) */ + /**********************************************/ + +/* Routine utilisee pour tester si une piste est en contact avec une autre piste. + + Cette routine controle si la ligne (x1,y1 x2,y2) a une partie s'inscrivant + dans le cadre (xcliplo,ycliplo xcliphi,ycliphi) (variables globales, + locales a ce fichier) + + Retourne OK_DRC si aucune partie commune + Retourne BAD_DRC si partie commune +*/ +#define us unsigned int +static inline int USCALE(us arg, us num, us den) + { + int ii; + + ii = (int)( ((float) arg * num) / den); + return( ii ); + } + +#define WHEN_OUTSIDE return(OK_DRC) +#define WHEN_INSIDE + +static int Tst_Ligne(int x1,int y1,int x2,int y2) +{ +int temp; + +do { + if(x1 > x2) { EXCHG(x1,x2); EXCHG(y1,y2); } + if((x2 < xcliplo) || (x1 > xcliphi)) { WHEN_OUTSIDE; } + if(y1 < y2) + { + if((y2 < ycliplo) || (y1 > ycliphi)) { WHEN_OUTSIDE;} + if(y1 < ycliplo) + { + temp = USCALE((x2 - x1),(ycliplo - y1),(y2 - y1)); + if((x1 += temp) > xcliphi) { WHEN_OUTSIDE; } + y1 = ycliplo; + WHEN_INSIDE; + } + if(y2 > ycliphi) + { + temp = USCALE((x2 - x1),(y2 - ycliphi),(y2 - y1)); + if((x2 -= temp) < xcliplo) { WHEN_OUTSIDE; } + y2 = ycliphi; + WHEN_INSIDE; + } + if(x1 < xcliplo) + { + temp = USCALE((y2 - y1),(xcliplo - x1),(x2 - x1)); + y1 += temp; x1 = xcliplo; + WHEN_INSIDE; + } + if(x2 > xcliphi) + { + temp = USCALE((y2 - y1),(x2 - xcliphi),(x2 - x1)); + y2 -= temp; x2 = xcliphi; + WHEN_INSIDE; + } + } + else + { + if((y1 < ycliplo) || (y2 > ycliphi)) { WHEN_OUTSIDE; } + if(y1 > ycliphi) + { + temp = USCALE((x2 - x1),(y1 - ycliphi),(y1 - y2)); + if((x1 += temp) > xcliphi) { WHEN_OUTSIDE; } + y1 = ycliphi; + WHEN_INSIDE; + } + if(y2 < ycliplo) + { + temp = USCALE((x2 - x1),(ycliplo - y2),(y1 - y2)); + if((x2 -= temp) < xcliplo) { WHEN_OUTSIDE; } + y2 = ycliplo; + WHEN_INSIDE; + } + if(x1 < xcliplo) + { + temp = USCALE((y1 - y2),(xcliplo - x1),(x2 - x1)); + y1 -= temp; x1 = xcliplo; + WHEN_INSIDE; + } + if(x2 > xcliphi) + { + temp = USCALE((y1 - y2),(x2 - xcliphi),(x2 - x1)); + y2 += temp; x2 = xcliphi; + WHEN_INSIDE; + } + } + } while(0); + + if ( ((x2 + x1)/2 <= xcliphi ) && ((x2+x1)/2 >= xcliplo) \ + && ((y2 + y1)/2 <= ycliphi ) && ((y2+y1)/2 >= ycliplo) ) + { + return(BAD_DRC) ; + } + + else return(OK_DRC); +} + + diff --git a/pcbnew/dupltrac.cpp b/pcbnew/dupltrac.cpp new file mode 100644 index 0000000000..0168e139b0 --- /dev/null +++ b/pcbnew/dupltrac.cpp @@ -0,0 +1,520 @@ + /****************************************************/ + /* Edition des pistes */ + /* Routines de duplication et deplacement de pistes */ + /****************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "protos.h" + + +#define COPY_ROUTE 1 +#define MOVE_ROUTE 2 + +extern char marq_bitmap[]; // dans TRACEPCB : bitmap du marqueur "DRC" + +/* Routines externes */ + +#if 0 +/* Routines Locales */ +static void Exit_DuplicTrack(COMMAND * Cmd); +static void Start_CopieMove_Route(COMMAND * Cmd) ; +static void Duplic_Track(COMMAND * Cmd); +static void Place_Dupl_Route(COMMAND * Cmd); +static void Show_Move_Piste(wxDC * DC, int flag); + +/* variables locales */ +static int startX, startY; +static int PosInitX, PosInitY; +static TRACK * NewTrack; /* Nouvelle piste creee ou piste deplacee */ +static int NbPtNewTrack; +static int FlagState; /* memoire de la commande (COPY_ROUTE ou MOVE_ROUTE) */ +/* variables externes */ + + +/**************************************************************/ +static void Exit_DuplicTrack(WinEDA_DrawFrame * frame, wxDC *DC) +/***************************************************************/ +/* routine d'annulation de la Commande Begin_Route si une piste est en cours + de tracage, ou de sortie de l'application EDITRACK. + Appel par la touche ESC + */ +{ +TRACK * NextS; +int ii; +wxDC * DC = Cmd->DC; + + frame->DrawPanel->ManageCurseur = NULL; + + if( NewTrack ) + { + /* Effacement du trace en cours */ + DisplayOpt.DisplayPcbTrackFill = SKETCH ; + Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_XOR); + DisplayOpt.DisplayPcbTrackFill = Track_fill_copy ; + + if (FlagState == COPY_ROUTE ) + { + for( ii = 0; ii < NbPtNewTrack; ii++, NewTrack = NextS) + { + if(NewTrack == NULL) break; + NextS = (TRACK*) NewTrack->Pnext; + delete NewTrack; + } + } + else /* Move : remise en ancienne position */ + { + TRACK * Track = NewTrack; + PosInitX -= Track->m_Start.x; + PosInitY -= Track->m_Start.y; + for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext) + { + if( Track == NULL ) break; + Track->m_Start.x += PosInitX; + Track->m_Start.y += PosInitY; + Track->m_End.x += PosInitX; + Track->m_End.y += PosInitY; + } + Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_OR); + } + + if(Etat_Surbrillance) Hight_Light(DC); + EraseMsgBox(); + NewTrack = NULL; + } + else + { + EraseMsgBox(); + } +} + + +/******************************************/ +static void Place_Dupl_Route(COMMAND * Cmd) +/******************************************/ +/* + Routine de placement d'une piste (succession de segments) +*/ +{ +D_PAD * pt_pad; +TRACK * pt_track, *Track, * pt_classe, *NextS; +int masquelayer; +EDA_BaseStruct * LockPoint; +int ii, old_net_code, new_net_code, DRC_error = 0; +wxDC * DC = Cmd->DC; + + ActiveDrawPanel->ManageCurseur = NULL; + + if( NewTrack == NULL ) return ; + + old_net_code = NewTrack->net_code; + + /* Placement du flag BUSY de la piste originelle, qui ne doit + pas etre vue dans les recherches de raccordement suivantes */ + ii = NbPtNewTrack; pt_track = NewTrack; + for ( ; ii > 0; ii --, pt_track = (TRACK*) pt_track->Pnext) + { + pt_track->SetState(BUSY, ON); + } + + /* Detection du nouveau net_code */ + ii = NbPtNewTrack; pt_track = NewTrack; + for ( ; ii > 0; ii --, pt_track = (TRACK*) pt_track->Pnext) + { + pt_track->net_code = 0; + } + + new_net_code = 0; + ii = 0; pt_track = NewTrack; + for( ; ii < NbPtNewTrack ; ii++, pt_track = (TRACK*)pt_track->Pnext) + { + /* Localisation de la pastille ou segment en debut de segment: */ + masquelayer = tab_layer[pt_track->Layer]; + LockPoint = LocateLockPoint(pt_track->m_Start.x,pt_track->m_Start.y,masquelayer); + if( LockPoint ) + { + if ( LockPoint->m_StructType == TYPEPAD ) + { + pt_pad = (D_PAD*) LockPoint; + new_net_code = pt_pad->net_code; + if ( new_net_code > 0 ) break; + } + else /* debut de piste sur un segment de piste */ + { + Track = (TRACK *) LockPoint; + new_net_code = Track->net_code; + if ( new_net_code > 0 ) break; + } + } + LockPoint = LocateLockPoint(pt_track->m_End.x,pt_track->m_End.y,masquelayer); + if( LockPoint ) + { + if ( LockPoint->m_StructType == TYPEPAD ) + { + pt_pad = (D_PAD*) LockPoint; + new_net_code = pt_pad->net_code; + if ( new_net_code > 0 ) break; + } + else /* debut de piste sur un segment de piste */ + { + Track = (TRACK *) LockPoint; + new_net_code = Track->net_code; + if ( new_net_code > 0 ) break; + } + } + } + + /* Mise a jour du nouveau net code de la piste */ + ii = 0; pt_track = NewTrack; + for( ; ii < NbPtNewTrack; ii++, pt_track = (TRACK*)pt_track->Pnext) + { + pt_track->net_code = new_net_code; + } + + /* Controle DRC de la nouvelle piste */ + ii = 0; pt_track = NewTrack; + for( ; ii < NbPtNewTrack; ii++, pt_track = pt_track->Next() ) + { + if( Drc_On == RUN ) + if( drc(DC, pt_track, pt_pcb->Track, 1) == BAD_DRC ) + { + if( confirmation(" Erreur DRC, Place piste:") == YES ) continue; + else { DRC_error = 1; break; } + } + } + + if( DRC_error == 0) + { + if(FlagState == MOVE_ROUTE) + { + /* copie nouvelle piste */ + pt_track = NewTrack; + NewTrack = pt_track->Copy(NbPtNewTrack); + /* effacement ancienne ( chainage et liens mauvais */ + ii = NbPtNewTrack; + for ( ; ii > 0; ii --, pt_track = NextS) + { + NextS = (TRACK*) pt_track->Pnext; + DeleteStructure(pt_track); + } + test_1_net_connexion(DC, old_net_code ); + } + + pt_classe = NewTrack->GetBestInsertPoint(); + NewTrack->Insert(pt_classe); + + Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_OR) ; + + /* Mise a jour des connexions sur pads et sur pistes */ + ii = 0; pt_track = NewTrack; + for( ; ii < NbPtNewTrack; ii++, pt_track = NextS) + { + NextS = (TRACK*)pt_track->Pnext; + pt_track->SetState(BEGIN_ONPAD|END_ONPAD, OFF); + masquelayer = tab_layer[pt_track->Layer]; + + /* Localisation de la pastille ou segment sur debut segment: */ + LockPoint = LocateLockPoint(pt_track->m_Start.x,pt_track->m_Start.y,masquelayer); + if( LockPoint ) + { + pt_track->start = LockPoint; + if ( LockPoint->m_StructType == TYPEPAD ) + { /* fin de piste sur un pad */ + pt_pad = (D_PAD*) LockPoint; + pt_track->SetState(BEGIN_ONPAD, ON); + } + else /* debut de piste sur un segment de piste */ + { + Track = (TRACK *) LockPoint; + CreateLockPoint(&pt_track->m_Start.x,&pt_track->m_Start.y,Track,pt_track); + } + } + + /* Localisation de la pastille ou segment sur fin de segment: */ + LockPoint = LocateLockPoint(pt_track->m_End.x,pt_track->m_End.y,masquelayer); + if( LockPoint ) + { + pt_track->end = LockPoint; + if ( LockPoint->m_StructType == TYPEPAD ) + { /* fin de piste sur un pad */ + pt_pad = (D_PAD*) LockPoint; + pt_track->SetState(END_ONPAD, ON); + } + else /* debut de piste sur un segment de piste */ + { + Track = (TRACK *) LockPoint; + CreateLockPoint(&pt_track->m_Start.x,&pt_track->m_Start.y,Track,pt_track); + } + } + } + + /* Suppression du flag BUSY */ + ii = NbPtNewTrack; pt_track = NewTrack; + for ( ; ii > 0; ii --, pt_track = (TRACK*) pt_track->Pnext) + { + pt_track->SetState(BUSY, OFF); + } + + test_1_net_connexion(DC, new_net_code ); + ActiveScreen->SetModify(); + } + + else /* Erreur DRC: Annulation commande */ + { + DisplayOpt.DisplayPcbTrackFill = SKETCH ; + Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_XOR); + DisplayOpt.DisplayPcbTrackFill = Track_fill_copy ; + + if(FlagState == MOVE_ROUTE) + { /* Remise en position de la piste deplacee */ + Track = NewTrack; + PosInitX -= Track->m_Start.x; PosInitY -= Track->m_Start.y; + for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext) + { + if( Track == NULL ) break; + Track->m_Start.x += PosInitX; Track->m_Start.y += PosInitY; + Track->m_End.x += PosInitX; Track->m_End.y += PosInitY; + Track->SetState(BUSY,OFF); + } + Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_OR); + } + + if (FlagState == COPY_ROUTE ) + { /* Suppression copie */ + for( ii = 0; ii < NbPtNewTrack; NewTrack = NextS) + { + if(NewTrack == NULL) break; + NextS = (TRACK*) NewTrack->Pnext; + delete NewTrack; + } + } + } + NewTrack = NULL; + Affiche_Infos_Status_Pcb(Cmd); + if(Etat_Surbrillance) Hight_Light(DC); +} + + +/***********************************************/ +static void Show_Move_Piste(wxDC * DC, int flag) +/***********************************************/ +/* redessin du contour de la piste lors des deplacements de la souris */ +{ +int ii, dx, dy; +TRACK * ptsegm; + + if ( NewTrack == NULL ) return ; /* Pas de piste en cours (Erreur ) */ + + /* efface ancienne position si elle a ete deja dessinee */ + if( (flag == CURSEUR_MOVED ) && (FlagState == COPY_ROUTE ) ) + { + DisplayOpt.DisplayPcbTrackFill = SKETCH ; + Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_XOR) ; + } + + if( FlagState == MOVE_ROUTE ) + { + if( flag == CURSEUR_MOVED) DisplayOpt.DisplayPcbTrackFill = SKETCH ; + Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_XOR) ; + } + + /* mise a jour des coordonnees des segments de la piste */ + dx = ActiveScreen->Curseur_X - startX ; + dy = ActiveScreen->Curseur_Y - startY ; + startX = ActiveScreen->Curseur_X; + startY = ActiveScreen->Curseur_Y; + ii = NbPtNewTrack, ptsegm = NewTrack; + for( ; ii > 0; ii--, ptsegm = (TRACK*)ptsegm->Pnext ) + { + ptsegm->m_Start.x += dx; ptsegm->m_Start.y += dy; + ptsegm->m_End.x += dx; ptsegm->m_End.y += dy; + } + + /* dessin de la nouvelle piste */ + DisplayOpt.DisplayPcbTrackFill = SKETCH ; + Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_XOR) ; + DisplayOpt.DisplayPcbTrackFill = Track_fill_copy ; +} + + + /************************************************/ + /* void Start_CopieMove_Route(COMMAND * Cmd) */ + /************************************************/ + +/* Routine permettant la recopie d'une piste deja tracee +*/ +static void Start_CopieMove_Route(COMMAND * Cmd) +{ +int ii; +TRACK *pt_segm, *pt_track; +int masquelayer = tab_layer[ActiveScreen->Active_Layer]; +wxDC * DC = Cmd->DC; + + if( NewTrack ) return; + + FlagState = (int)Cmd->Menu->param_inf; + + /* Recherche de la piste sur la couche active (non zone) */ + for(pt_segm = pt_pcb->Track; pt_segm != NULL; pt_segm = (TRACK*)pt_segm->Pnext) + { + pt_segm = Locate_Pistes(pt_segm,masquelayer, CURSEUR_OFF_GRILLE); + if( pt_segm == NULL ) break ; + break ; + } + + if( pt_segm != NULL ) + { + if (FlagState == COPY_ROUTE ) + pt_track = Marque_Une_Piste(DC, pt_segm, &NbPtNewTrack, 0); + else pt_track = Marque_Une_Piste(DC, pt_segm, &NbPtNewTrack, GR_XOR); + + if(NbPtNewTrack) /* Il y a NbPtNewTrack segments de piste a traiter */ + { + /* effacement du flag BUSY de la piste originelle */ + ii = NbPtNewTrack; pt_segm = pt_track; + for ( ; ii > 0; ii --, pt_segm = (TRACK*) pt_segm->Pnext) + { + pt_segm->SetState(BUSY, OFF); + } + + if (FlagState == COPY_ROUTE ) + NewTrack = pt_track->Copy(NbPtNewTrack); + else NewTrack = pt_track; + + Affiche_Infos_Piste(Cmd, pt_track) ; + + startX = ActiveScreen->Curseur_X; + startY = ActiveScreen->Curseur_Y; + Place_Dupl_Route_Item.State = WAIT; + ActiveDrawPanel->ManageCurseur = Show_Move_Piste; + DisplayOpt.DisplayPcbTrackFill = SKETCH ; + Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_XOR) ; + DisplayOpt.DisplayPcbTrackFill = Track_fill_copy ; + PosInitX = NewTrack->m_Start.x; PosInitY = NewTrack->m_Start.y; + } + } +} + + +#endif + +/************************************************************************/ +EDA_BaseStruct * LocateLockPoint(BOARD * Pcb, wxPoint pos, int LayerMask) +/************************************************************************/ +/* Routine trouvant le point " d'accrochage " d'une extremite de piste. + Ce point peut etre un PAD ou un autre segment de piste + Retourne: + - pointeur sur ce PAD ou: + - pointeur sur le segment ou: + - NULL + Parametres d'appel: + coord pX, pY du point tst + masque des couches a tester +*/ +{ +D_PAD * pt_pad; +TRACK * ptsegm; +MODULE * Module; + + /* detection du point type PAD */ + pt_pad = NULL; + Module = Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*)Module->Pnext ) + { + pt_pad = Locate_Pads(Module,pos.x, pos.y, LayerMask); + if (pt_pad) return(pt_pad); + } + + /* ici aucun pad n'a ete localise: detection d'un segment de piste */ + + ptsegm = Fast_Locate_Piste( Pcb->m_Track, NULL, pos.x, pos.y, LayerMask); + if( ptsegm == NULL ) + ptsegm = Locate_Pistes( Pcb->m_Track, pos.x, pos.y, LayerMask); + return(ptsegm); +} + + +/******************************************************************************/ +TRACK * CreateLockPoint(int *pX, int *pY, TRACK * ptsegm, TRACK * refsegm) +/******************************************************************************/ + +/* Routine de creation d'un point intermediaire sur un segment + le segment ptsegm est casse en 2 segments se raccordant au point pX, pY + retourne: + NULL si pas de nouveau point ( c.a.d si pX, pY correspondait deja + a une extremite ou: + pointeur sur le segment cree + si refsegm != NULL refsegm est pointeur sur le segment incident, + et le point cree est l'intersection des 2 axes des segments ptsegm et + refsegm + retourne la valeur exacte de pX et pY + Si ptsegm pointe sur une via: + retourne la valeur exacte de pX et pY et ptsegm, + mais ne cree pas de point supplementaire + +*/ +{ +int cX, cY; +int dx, dy; /* Coord de l'extremite du segm ptsegm / origine */ +int ox, oy, fx , fy; /* coord de refsegm / origine de prsegm */ +TRACK * NewTrack; + + if( (ptsegm->m_Start.x == *pX) && (ptsegm->m_Start.y == *pY) ) return(NULL); + if( (ptsegm->m_End.x == *pX) && (ptsegm->m_End.y == *pY) ) return(NULL); + + /* le point n'est pas sur une extremite de piste */ + if(ptsegm->m_StructType == TYPEVIA ) + { + *pX = ptsegm->m_Start.x; *pY = ptsegm->m_Start.y; + return(ptsegm); + } + /* calcul des coord vraies du point intermediaire dans le repere d'origine + = origine de ptsegm */ + cX = *pX - ptsegm->m_Start.x; + cY = *pY - ptsegm->m_Start.y; + dx = ptsegm->m_End.x - ptsegm->m_Start.x; + dy = ptsegm->m_End.y - ptsegm->m_Start.y; + +// ***** A COMPLETER : non utilise + if ( refsegm ) + { + ox = refsegm->m_Start.x - ptsegm->m_Start.x; + oy = refsegm->m_Start.y - ptsegm->m_Start.y; + fx = refsegm->m_End.x - ptsegm->m_Start.x; + fy = refsegm->m_End.y - ptsegm->m_Start.y; + } + + /* pour que le point soit sur le segment ptsegm: cY/cX = dy/dx */ + if ( dx == 0 ) cX = 0; /* segm horizontal */ + else cY = (cX * dy) / dx; + + /* creation du point intermediaire ( c'est a dire creation d'un nouveau + segment, debutant au point intermediaire */ + + cX += ptsegm->m_Start.x; cY += ptsegm->m_Start.y; + NewTrack = ptsegm->Copy(); + + NewTrack->Insert(NULL, ptsegm); + /* correction du pointeur de fin du nouveau segment */ + NewTrack->end = ptsegm->end; + + /* le segment primitif finit au nouveau point : */ + ptsegm->m_End.x = cX; ptsegm->m_End.y = cY; + ptsegm->SetState(END_ONPAD, OFF); + + /* le nouveau segment debute au nouveau point : */ + ptsegm = NewTrack;; + ptsegm->m_Start.x = cX; ptsegm->m_Start.y = cY; + ptsegm->SetState(BEGIN_ONPAD, OFF); + *pX = cX; *pY = cY; + + return(ptsegm); + +} + + diff --git a/pcbnew/edgemod.cpp b/pcbnew/edgemod.cpp new file mode 100644 index 0000000000..bf115370c5 --- /dev/null +++ b/pcbnew/edgemod.cpp @@ -0,0 +1,400 @@ + /******************************************************/ + /* Edition des contours d'un module: Routines */ + /* d'effacement et d'edition de segments et contours */ + /* appartenant aux modules */ + /******************************************************/ + + + /* fichier edgemod.cpp */ + +/* Routines d'edition des contours d'un module. + La correction des Arcs de cercle n'est pas traitee ( mais + les menus en routines sont prevus +*/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "trigo.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + + +/* Routines Locales */ + +static void ShowEdgeModule(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void Exit_EditEdge_Module(WinEDA_DrawPanel * Panel, wxDC * DC); +static void Move_Segment(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); + +/* Variables locales : */ +int ArcValue = 900; +static wxPoint MoveVector; // Move vector for move edge +static wxPoint CursorInitialPosition; // Mouse cursor inital position for move command + +/****************************************************************************/ +void WinEDA_ModuleEditFrame::Start_Move_EdgeMod(EDGE_MODULE * Edge, wxDC * DC) +/****************************************************************************/ + /* Routine de preparation du deplacement d'un element graphique type DRAWSEGMENT +*/ +{ + if( Edge == NULL ) return; + Edge->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); + Edge->m_Flags |= IS_MOVED; + MoveVector.x = MoveVector.y = 0; + CursorInitialPosition = GetScreen()->m_Curseur; + DrawPanel->ManageCurseur = Move_Segment; + DrawPanel->ForceCloseManageCurseur = Exit_EditEdge_Module; + GetScreen()->m_CurrentItem = Edge; + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE); +} + +/*********************************************************************/ +void WinEDA_ModuleEditFrame::Place_EdgeMod(EDGE_MODULE * Edge, wxDC * DC) +/*********************************************************************/ +/* + Routine de placement de l'element graphique type EDGE_MODULE en cours de deplacement +*/ +{ + if( Edge == NULL ) return; + Edge->m_Start.x -= MoveVector.x; + Edge->m_Start.y -= MoveVector.y; + Edge->m_End.x -= MoveVector.x; + Edge->m_End.y -= MoveVector.y; + + Edge->m_Start0.x -= MoveVector.x; + Edge->m_Start0.y -= MoveVector.y; + Edge->m_End0.x -= MoveVector.x; + Edge->m_End0.y -= MoveVector.y; + + Edge->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR); + Edge->m_Flags = 0; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetModify(); +MODULE * Module = (MODULE*) Edge->m_Parent; + Module->Set_Rectangle_Encadrement(); +} + + +/************************************************************************/ +static void Move_Segment(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/************************************************************************/ +/* redessin du contour du Segment Edge lors des deplacements de la souris */ +{ +BASE_SCREEN * screen = panel->GetScreen(); +EDGE_MODULE * Edge = (EDGE_MODULE * ) screen->m_CurrentItem; + + if( Edge == NULL ) return; + +MODULE * Module = (MODULE*) Edge->m_Parent; + + if( erase ) + { + Edge->Draw(panel, DC, MoveVector, GR_XOR); + } + + MoveVector.x = -(screen->m_Curseur.x - CursorInitialPosition.x); + MoveVector.y = -(screen->m_Curseur.y - CursorInitialPosition.y); + + Edge->Draw(panel, DC, MoveVector, GR_XOR); + + Module->Set_Rectangle_Encadrement(); +} + + +/************************************************************************/ +static void ShowEdgeModule(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/************************************************************************/ +/* Affiche le segment Edge Module en cours de trace +*/ +{ +BASE_SCREEN * screen = panel->GetScreen(); +EDGE_MODULE * Edge = (EDGE_MODULE * ) screen->m_CurrentItem; + + if( Edge == NULL ) return; + +MODULE * Module = (MODULE*) Edge->m_Parent; + + // if( erase ) + { + Edge->Draw(panel, DC, wxPoint(0, 0), GR_XOR); + } + + Edge->m_End = screen->m_Curseur; + + /* Mise a jour des coord relatives */ + Edge->m_End0.x = Edge->m_End.x - Module->m_Pos.x; + Edge->m_End0.y = Edge->m_End.y - Module->m_Pos.y ; + RotatePoint((int*)&Edge->m_End0.x, + (int*)&Edge->m_End0.y, - Module->m_Orient); + + Edge->Draw(panel, DC, wxPoint(0, 0), GR_XOR); + + Module->Set_Rectangle_Encadrement(); +} + + +/***************************************************************************/ +void WinEDA_ModuleEditFrame::Edit_Edge_Width(EDGE_MODULE * Edge, wxDC * DC) +/***************************************************************************/ +/* change la largeur du EDGE_MODULE Edge, ou de tous si Edge == NULL +*/ +{ +MODULE* Module = m_Pcb->m_Modules; + + SaveCopyInUndoList(Module); + + if ( Edge == NULL ) + { + Edge = (EDGE_MODULE *) Module->m_Drawings; + for( ; Edge != NULL ; Edge = (EDGE_MODULE*)Edge->Pnext) + { + if(Edge->m_StructType != TYPEEDGEMODULE) continue; + Edge->m_Width = ModuleSegmentWidth; + } + } + else Edge->m_Width = ModuleSegmentWidth; + + GetScreen()->SetModify(); + DrawPanel->Refresh(TRUE); + Module->Set_Rectangle_Encadrement(); + Module->m_LastEdit_Time = time(NULL); +} + +/***************************************************************************/ +void WinEDA_ModuleEditFrame::Edit_Edge_Layer(EDGE_MODULE * Edge, wxDC * DC) +/***************************************************************************/ +/* change la couche du EDGE_MODULE Edge, ou de tous si Edge == NULL +*/ +{ +MODULE* Module = m_Pcb->m_Modules; +int new_layer = SILKSCREEN_N_CMP; + + + new_layer = SelectLayer(SILKSCREEN_N_CMP, LAYER_CUIVRE_N, LAST_NO_COPPER_LAYER); + if ( new_layer < 0 ) return; + + SaveCopyInUndoList(Module); + + if ( Edge == NULL ) + { + Edge = (EDGE_MODULE *) Module->m_Drawings; + for( ; Edge != NULL ; Edge = (EDGE_MODULE*)Edge->Pnext) + { + if(Edge->m_StructType != TYPEEDGEMODULE) continue; + Edge->m_Layer = new_layer; + } + } + else Edge->m_Layer = new_layer; + + GetScreen()->SetModify(); + Module->Set_Rectangle_Encadrement(); + Module->m_LastEdit_Time = time(NULL); + DrawPanel->Refresh(TRUE); +} + + +/*************************************************************************/ +void WinEDA_ModuleEditFrame::Enter_Edge_Width(EDGE_MODULE * Edge, wxDC * DC) +/*************************************************************************/ +/* + Entre la nouvelle valeur pour ModuleSegmentWidth. + change la largeur du EDGE_MODULE Edge si Edge != NULL +*/ +{ +wxString buffer; +long ll; + + buffer << ModuleSegmentWidth; + if ( Get_Message( _("New Width (1/10000\"):"),buffer, this) ) return; + + if ( buffer.ToLong(&ll) ) ModuleSegmentWidth = ll; + else + { + DisplayError(this,_("Incorrect number, no change")); + return; + } + if ( Edge ) + { + MODULE* Module = m_Pcb->m_Modules; + Module->DrawEdgesOnly(DrawPanel, DC,wxPoint(0, 0), GR_XOR); + Edge->m_Width = ModuleSegmentWidth; + Module->DrawEdgesOnly(DrawPanel, DC,wxPoint(0, 0),GR_XOR); + Module->Set_Rectangle_Encadrement(); + GetScreen()->SetModify(); + } + +} + +/****************************************************************************/ +void WinEDA_ModuleEditFrame::Delete_Edge_Module(EDGE_MODULE * Edge, wxDC * DC) +/****************************************************************************/ +{ + if(Edge == NULL ) return; + if ( Edge->m_StructType != TYPEEDGEMODULE ) + { + DisplayError(this, wxT("StructType error: TYPEEDGEMODULE expected")); + return; + } + +MODULE* Module = (MODULE*) Edge->m_Parent; + Edge->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR) ; + + /* suppression d'un segment */ + DeleteStructure(Edge); + Module->m_LastEdit_Time = time(NULL); + Module->Set_Rectangle_Encadrement(); + GetScreen()->SetModify(); +} + + + +/******************************************************************/ +static void Exit_EditEdge_Module(WinEDA_DrawPanel * Panel, wxDC * DC) +/******************************************************************/ +{ +EDGE_MODULE * Edge = (EDGE_MODULE * ) Panel->GetScreen()->m_CurrentItem; + + if( Edge && (Edge->m_StructType == TYPEEDGEMODULE) ) /* error si non */ + { + if (Edge->m_Flags & IS_NEW) /* effacement du nouveau contour */ + { + MODULE * Module = (MODULE *) Edge->m_Parent; + Edge->Draw(Panel, DC, MoveVector, GR_XOR); + DeleteStructure(Edge); + Module->Set_Rectangle_Encadrement(); + } + + else + { + Edge->Draw(Panel, DC, MoveVector, GR_XOR); + Edge->m_Flags = 0; + Edge->Draw(Panel, DC, wxPoint(0, 0), GR_OR); + } + } + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + Panel->GetScreen()->m_CurrentItem = NULL; +} + + +/*************************************************************************/ +EDGE_MODULE * WinEDA_ModuleEditFrame::Begin_Edge_Module(EDGE_MODULE * Edge, + wxDC * DC, int type_edge) +/*************************************************************************/ + +/* Fonction de debut de trace d'un nouveau contour. + - Cree la place en memoire du nouveau contour + - Prepare les coord des differents points + - Met a jour la variable type_edge (= S_SEGMENT,S_ARC ...) +*/ +{ +MODULE* Module = m_Pcb->m_Modules; +int angle = 0; + + if ( Module == NULL ) return NULL; + + if(Edge == NULL ) /* debut reel du trace */ + { + SaveCopyInUndoList(Module); + Edge = new EDGE_MODULE( Module ); + MoveVector.x = MoveVector.y = 0; + + /* Chainage du nouvel element, en tete de liste Drawings */ + Edge->Pback = Module; + Edge->Pnext = Module->m_Drawings; + if( Module->m_Drawings ) Module->m_Drawings->Pback = Edge; + Module->m_Drawings = Edge; + + /* Mise a jour des caracteristiques du segment ou de l'arc */ + Edge->m_Flags = IS_NEW; + Edge->m_Angle = angle; + Edge->m_Shape = type_edge; + if ( Edge->m_Shape == S_ARC ) Edge->m_Angle = ArcValue; + Edge->m_Width = ModuleSegmentWidth; + Edge->m_Layer = Module->m_Layer; + if(Module->m_Layer == CMP_N) Edge->m_Layer = SILKSCREEN_N_CMP; + if(Module->m_Layer == CUIVRE_N) Edge->m_Layer = SILKSCREEN_N_CU; + /* Mise a jour du point de depart du segment ou de l'arc */ + Edge->m_Start = GetScreen()->m_Curseur; + /* Mise a jour de la fin du segment , rectangle ou de l'arc*/ + Edge->m_End = Edge->m_Start; + + /* Mise a jour des coord relatives */ + Edge->m_Start0.x = Edge->m_Start.x - Module->m_Pos.x; + Edge->m_Start0.y = Edge->m_Start.y - Module->m_Pos.y; + RotatePoint((int*)&(Edge->m_Start0.x), + (int*)&(Edge->m_Start0.y), - Module->m_Orient); + Edge->m_End0 = Edge->m_Start0; + Module->Set_Rectangle_Encadrement(); + + DrawPanel->ManageCurseur = ShowEdgeModule; + DrawPanel->ForceCloseManageCurseur = Exit_EditEdge_Module; + } + + else /* trace en cours : les coord du point d'arrivee ont ete mises + a jour par la routine Montre_Position_New_Edge_Module*/ + { + if( type_edge == S_SEGMENT ) + { + if( (Edge->m_Start0.x) != (Edge->m_End0.x) || + (Edge->m_Start0.y) != (Edge->m_End0.y) ) + { + Edge->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR); + EDGE_MODULE * newedge = new EDGE_MODULE(Module); + newedge->Copy(Edge); + newedge->AddToChain(Edge); + Edge->m_Flags = 0; + Edge = newedge; + + Edge->m_Flags = IS_NEW; + Edge->m_Width = ModuleSegmentWidth; + Edge->m_Start = GetScreen()->m_Curseur; + Edge->m_End = Edge->m_Start; + + /* Mise a jour des coord relatives */ + Edge->m_Start0.x = Edge->m_Start.x - Module->m_Pos.x; + Edge->m_Start0.y = Edge->m_Start.y - Module->m_Pos.y; + RotatePoint((int*)&(Edge->m_Start0.x), + (int*)&(Edge->m_Start0.y), -Module->m_Orient); + Edge->m_End0 = Edge->m_Start0; + + Module->Set_Rectangle_Encadrement(); + Module->m_LastEdit_Time = time(NULL); + GetScreen()->SetModify(); + } + } + else + DisplayError(this, wxT("Begin_Edge() error")); + } + return Edge; +} + + +/*************************************************************************/ +void WinEDA_ModuleEditFrame::End_Edge_Module(EDGE_MODULE * Edge,wxDC * DC) +/*************************************************************************/ +{ +MODULE* Module = m_Pcb->m_Modules; + + /* test du dernier segment: si null: suppression */ + if(Edge) + { + if( (Edge->m_Start.x == Edge->m_End.x) + && (Edge->m_Start.y == Edge->m_End.y) ) + { + DeleteStructure( Edge); + } + } + Edge->m_Flags = 0; + Module->Set_Rectangle_Encadrement(); + Module->m_LastEdit_Time = time(NULL); + GetScreen()->SetModify(); + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; +} + + diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp new file mode 100644 index 0000000000..f25bca1e8f --- /dev/null +++ b/pcbnew/edit.cpp @@ -0,0 +1,1311 @@ + /******************************************************/ + /* edit.cpp: fonctions generales de l'edition du PCB */ + /******************************************************/ + +#include "fctsys.h" + +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "id.h" + +#include "protos.h" + +#define CURRENT_ITEM (GetScreen()->m_CurrentItem) + + +static void Process_Move_Item(WinEDA_PcbFrame * frame, + EDA_BaseStruct *DrawStruct, wxDC * DC); + +/********************************************************************/ +void WinEDA_PcbFrame::OnLeftClick(wxDC * DC, const wxPoint& MousePos) +/********************************************************************/ +/* Traite les commandes declenchée par le bouton gauche de la souris, + quand un outil est deja selectionné +*/ +{ +EDA_BaseStruct * DrawStruct = CURRENT_ITEM; + + DrawPanel->m_IgnoreMouseEvents = TRUE; + DrawPanel->CursorOff(DC); + + if ( (m_ID_current_state == 0) || ( DrawStruct && DrawStruct->m_Flags )) + { + DrawPanel->m_AutoPAN_Request = FALSE; + if ( DrawStruct && DrawStruct->m_Flags ) // Commande "POPUP" en cours + { + switch (DrawStruct->m_StructType ) + { + case TYPETRACK: + case TYPEVIA: + if ( CURRENT_ITEM->m_Flags & IS_DRAGGED ) + { + PlaceDraggedTrackSegment((TRACK *)DrawStruct, DC); + goto out; + } + break; + + case TYPETEXTE: + Place_Texte_Pcb((TEXTE_PCB *)DrawStruct, DC); + goto out; + break; + + case TYPETEXTEMODULE: + PlaceTexteModule( (TEXTE_MODULE *) DrawStruct, DC); + goto out; + break; + + case TYPEPAD: + PlacePad((D_PAD *)DrawStruct, DC); + goto out; + break; + + case TYPEMODULE: + Place_Module((MODULE *)DrawStruct, DC); + goto out; + break; + + case TYPEMIRE: + Place_Mire((MIREPCB *)DrawStruct, DC); + goto out; + break; + + case TYPEDRAWSEGMENT: + if (m_ID_current_state == 0) + { + Place_DrawItem( (DRAWSEGMENT * )DrawStruct, DC); + goto out; + } + break; + + default: + if (m_ID_current_state == 0) + { + DisplayError(this, + wxT("WinEDA_PcbFrame::OnLeftClick() err: m_Flags != 0") ); + goto out; + } + } + } + else + { + DrawStruct = PcbGeneralLocateAndDisplay(); + } + } + + switch ( m_ID_current_state ) + { + case ID_MAIN_MENUBAR: + case 0: + break; + + case ID_NO_SELECT_BUTT: + break; + + + case ID_PCB_MUWAVE_TOOL_SELF_CMD: + case ID_PCB_MUWAVE_TOOL_GAP_CMD: + case ID_PCB_MUWAVE_TOOL_STUB_CMD: + case ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD: + case ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD: + MuWaveCommand(DC, MousePos); + break; + + + case ID_PCB_HIGHLIGHT_BUTT: + { + int netcode = Select_High_Light(DC); + if ( netcode < 0 ) Affiche_Infos_Status_Pcb(this); + else Affiche_Infos_Equipot(netcode, this); + } + break; + + case ID_PCB_SHOW_1_RATSNEST_BUTT: + DrawStruct = PcbGeneralLocateAndDisplay(); + Show_1_Ratsnest(DrawStruct, DC); + break; + + case ID_PCB_MIRE_BUTT: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + GetScreen()->m_CurrentItem = Create_Mire( DC ); + DrawPanel->MouseToCursorSchema(); + } + else if (DrawStruct->m_StructType == TYPEMIRE ) + { + Place_Mire((MIREPCB *)DrawStruct, DC); + } + else DisplayError(this, wxT("Internal err: Struct not TYPEMIRE")); + break; + + case ID_PCB_CIRCLE_BUTT: + case ID_PCB_ARC_BUTT: + case ID_LINE_COMMENT_BUTT: + { + int shape = S_SEGMENT; + if ( m_ID_current_state == ID_PCB_CIRCLE_BUTT) shape = S_CIRCLE; + if ( m_ID_current_state == ID_PCB_ARC_BUTT) shape = S_ARC; + + if ( GetScreen()->m_Active_Layer <= CMP_N ) + { + DisplayError(this, _("Graphic not autorized on Copper layers")); + break; + } + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + GetScreen()->m_CurrentItem = DrawStruct = + Begin_DrawSegment(NULL, shape, DC); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else if (DrawStruct && + (DrawStruct->m_StructType == TYPEDRAWSEGMENT) && + (DrawStruct->m_Flags & IS_NEW) ) + { + GetScreen()->m_CurrentItem = DrawStruct = + Begin_DrawSegment((DRAWSEGMENT *)DrawStruct, shape, DC); + DrawPanel->m_AutoPAN_Request = TRUE; + } + break; + } + + case ID_TRACK_BUTT: + if ( GetScreen()->m_Active_Layer > CMP_N ) + { + DisplayError(this, _("Tracks on Copper layers only ")); + break; + } + + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + GetScreen()->m_CurrentItem = DrawStruct = + Begin_Route(NULL, DC); + if ( DrawStruct ) DrawPanel->m_AutoPAN_Request = TRUE; + } + else if (DrawStruct && +// (DrawStruct->m_StructType == TYPETRACK) && + (DrawStruct->m_Flags & IS_NEW) ) + { + TRACK * track = Begin_Route((TRACK *) DrawStruct, DC); + if ( track ) // c'est a dire si OK + GetScreen()->m_CurrentItem = DrawStruct = track; + DrawPanel->m_AutoPAN_Request = TRUE; + } + break; + + + case ID_PCB_ZONES_BUTT: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + GetScreen()->m_CurrentItem = DrawStruct = + Begin_Zone(); + } + else if (DrawStruct && + (DrawStruct->m_StructType == TYPEEDGEZONE) && + (DrawStruct->m_Flags & IS_NEW) ) + { + GetScreen()->m_CurrentItem = DrawStruct = + Begin_Zone(); + } + else DisplayError(this, wxT("Edit: zone internal error")); + break; + + case ID_TEXT_COMMENT_BUTT: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + GetScreen()->m_CurrentItem = Create_Texte_Pcb( DC ); + DrawPanel->MouseToCursorSchema(); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else if (DrawStruct->m_StructType == TYPETEXTE ) + { + Place_Texte_Pcb((TEXTE_PCB *)DrawStruct, DC); + DrawPanel->m_AutoPAN_Request = FALSE; + } + else DisplayError(this, wxT("Internal err: Struct not TYPETEXTE")); + break; + + case ID_COMPONENT_BUTT: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + DrawPanel->MouseToCursorSchema(); + GetScreen()->m_CurrentItem = DrawStruct = + Load_Module_From_Library(wxEmptyString, DC); + if ( DrawStruct ) + StartMove_Module((MODULE *)DrawStruct, DC); + } + else if (DrawStruct->m_StructType == TYPEMODULE ) + { + Place_Module((MODULE *)DrawStruct, DC); + DrawPanel->m_AutoPAN_Request = FALSE; + } + else DisplayError(this, wxT("Internal err: Struct not TYPEMODULE")); + break; + + case ID_PCB_COTATION_BUTT: + if ( GetScreen()->m_Active_Layer <= CMP_N ) + { + DisplayError(this, _("Cotation not autorized on Copper layers")); + break; + } + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + GetScreen()->m_CurrentItem = DrawStruct = + Begin_Cotation(NULL, DC); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else if (DrawStruct && + (DrawStruct->m_StructType == TYPECOTATION) && + (DrawStruct->m_Flags & IS_NEW) ) + { + GetScreen()->m_CurrentItem = DrawStruct = + Begin_Cotation((COTATION * )DrawStruct, DC); + DrawPanel->m_AutoPAN_Request = TRUE; + } + else DisplayError(this, wxT("Internal err: Struct not COTATION")); + break; + + case ID_PCB_DELETE_ITEM_BUTT: + if ( !DrawStruct || (DrawStruct->m_Flags == 0) ) + { + DrawStruct = PcbGeneralLocateAndDisplay(); + if ( DrawStruct && (DrawStruct->m_Flags == 0) ) + { + RemoveStruct(DrawStruct, DC); + GetScreen()->m_CurrentItem = DrawStruct = NULL; + } + } + break; + + case ID_PCB_PLACE_OFFSET_COORD_BUTT: + DrawPanel->m_Draw_Auxiliary_Axis(DC, GR_XOR); + m_Auxiliary_Axis_Position = GetScreen()->m_Curseur; + DrawPanel->m_Draw_Auxiliary_Axis( DC, GR_COPY); + GetScreen()->SetModify(); + break; + + default : + DrawPanel->SetCursor(wxCURSOR_ARROW); + DisplayError(this, wxT("WinEDA_PcbFrame::OnLeftClick() id error")); + SetToolID(0, wxCURSOR_ARROW,wxEmptyString); + break; + } + out: + DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->CursorOn(DC); +} + + +/*********************************************************************/ +void WinEDA_PcbFrame::Process_Special_Functions(wxCommandEvent& event) +/*********************************************************************/ +/* Traite les selections d'outils et les commandes appelees du menu POPUP +*/ +{ +int id = event.GetId(); +wxPoint pos; +wxClientDC dc(DrawPanel); +int itmp; + + DrawPanel->CursorOff(&dc); + DrawPanel->PrepareGraphicContext(&dc); + + wxGetMousePosition(&pos.x, &pos.y); + + pos.y += 20; + + switch ( id ) // Arret eventuel de la commande de déplacement en cours + { + case wxID_CUT: + case wxID_COPY: + case ID_AUX_TOOLBAR_PCB_TRACK_WIDTH: + case ID_AUX_TOOLBAR_PCB_VIA_SIZE: + case ID_ON_GRID_SELECT: + case ID_ON_ZOOM_SELECT: + case ID_PCB_USER_GRID_SETUP: + case ID_TOOLBARH_PCB_SELECT_LAYER: + case ID_POPUP_PCB_ROTATE_TEXTEPCB: + case ID_POPUP_PCB_EDIT_TEXTEPCB: + case ID_POPUP_PCB_EDIT_MIRE: + case ID_POPUP_PCB_ROTATE_TEXTMODULE: + case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE: + case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE: + case ID_POPUP_PCB_CHANGE_SIDE_MODULE: + case ID_POPUP_PCB_EDIT_MODULE: + case ID_POPUP_PCB_EDIT_TEXTMODULE: + case ID_POPUP_PCB_STOP_CURRENT_DRAWING: + case ID_POPUP_PCB_END_TRACK: + case ID_POPUP_PCB_PLACE_VIA: + case ID_POPUP_PCB_IMPORT_PAD_SETTINGS: + case ID_POPUP_PCB_EXPORT_PAD_SETTINGS: + case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS: + case ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE: + case ID_POPUP_PCB_DELETE_EDGE_ZONE: + case ID_POPUP_PCB_DELETE_ZONE_LIMIT: + case ID_POPUP_PCB_EDIT_ZONE: + case ID_POPUP_PCB_DELETE_ZONE: + case ID_POPUP_PCB_DELETE_TRACKSEG: + case ID_POPUP_PCB_DELETE_TRACK: + case ID_POPUP_PCB_DELETE_TRACKNET: + case ID_POPUP_PCB_FILL_ZONE: + case ID_POPUP_PCB_SELECT_NET_ZONE: + case ID_POPUP_PCB_SELECT_LAYER: + case ID_POPUP_PCB_SELECT_CU_LAYER: + case ID_POPUP_PCB_SELECT_LAYER_PAIR: + case ID_POPUP_PCB_SELECT_NO_CU_LAYER: + case ID_POPUP_PCB_SELECT_WIDTH: + case ID_POPUP_PCB_SELECT_WIDTH1: + case ID_POPUP_PCB_SELECT_WIDTH2: + case ID_POPUP_PCB_SELECT_WIDTH3: + case ID_POPUP_PCB_SELECT_WIDTH4: + case ID_POPUP_PCB_SELECT_WIDTH5: + case ID_POPUP_PCB_SELECT_WIDTH6: + case ID_POPUP_PCB_SELECT_WIDTH7: + case ID_POPUP_PCB_SELECT_WIDTH8: + case ID_POPUP_PCB_SELECT_VIASIZE: + case ID_POPUP_PCB_SELECT_VIASIZE1: + case ID_POPUP_PCB_SELECT_VIASIZE2: + case ID_POPUP_PCB_SELECT_VIASIZE3: + case ID_POPUP_PCB_SELECT_VIASIZE4: + case ID_POPUP_PCB_SELECT_VIASIZE5: + case ID_POPUP_PCB_SELECT_VIASIZE6: + case ID_POPUP_PCB_SELECT_VIASIZE7: + case ID_POPUP_PCB_SELECT_VIASIZE8: + case ID_POPUP_PCB_MOVE_TRACK_NODE: + case ID_POPUP_PCB_PLACE_MOVED_TRACK_NODE: + case ID_POPUP_PCB_BREAK_TRACK: + case ID_POPUP_PCB_EDIT_NET: + case ID_POPUP_PCB_EDIT_TRACK: + case ID_POPUP_PCB_EDIT_TRACKSEG: + case ID_POPUP_PCB_LOCK_ON_TRACKSEG: + case ID_POPUP_PCB_LOCK_OFF_TRACKSEG: + case ID_POPUP_PCB_LOCK_ON_TRACK: + case ID_POPUP_PCB_LOCK_OFF_TRACK: + case ID_POPUP_PCB_LOCK_ON_NET: + case ID_POPUP_PCB_LOCK_OFF_NET: + case ID_POPUP_DELETE_BLOCK: + case ID_POPUP_PLACE_BLOCK: + case ID_POPUP_ZOOM_BLOCK: + case ID_POPUP_INVERT_BLOCK: + case ID_POPUP_ROTATE_BLOCK: + case ID_POPUP_COPY_BLOCK: + case ID_POPUP_PCB_VIA_EDITING: + case ID_POPUP_PCB_VIA_HOLE_TO_DEFAULT: + case ID_POPUP_PCB_VIA_HOLE_TO_VALUE: + case ID_POPUP_PCB_VIA_HOLE_ENTER_VALUE: + case ID_POPUP_PCB_VIA_HOLE_EXPORT: + case ID_POPUP_PCB_VIA_HOLE_RESET_TO_DEFAULT: + case ID_POPUP_PCB_VIA_HOLE_EXPORT_TO_OTHERS: + break; + + case ID_POPUP_CANCEL_CURRENT_COMMAND: + if( DrawPanel->ManageCurseur && + DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + /* ne devrait pas etre execute, sauf bug */ + if (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE) + { + m_CurrentScreen->BlockLocate.m_Command = BLOCK_IDLE; + m_CurrentScreen->BlockLocate.m_State = STATE_NO_BLOCK; + m_CurrentScreen->BlockLocate.m_BlockDrawStruct = NULL; + } + if (m_ID_current_state == 0 ) + SetToolID(0, wxCURSOR_ARROW,wxEmptyString); + else SetCursor(DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor); + break; + + default: // Arret de la commande de déplacement en cours + if( DrawPanel->ManageCurseur && + DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + SetToolID(0, wxCURSOR_ARROW,wxEmptyString); + break; + } + + switch ( id ) // Traitement des commandes + { + case ID_EXIT : + Close(TRUE); + break; + + case ID_OPEN_MODULE_EDITOR: + if (m_Parent->m_ModuleEditFrame == NULL ) + { + m_Parent->m_ModuleEditFrame = new WinEDA_ModuleEditFrame(this, + m_Parent,_("Module Editor"), + wxPoint(-1, -1), wxSize(600,400) ); + m_Parent->m_ModuleEditFrame->Show(TRUE); + m_Parent->m_ModuleEditFrame->Zoom_Automatique(TRUE); + } + else m_Parent->m_ModuleEditFrame->Iconize(FALSE); + break; + + case ID_NEW_PROJECT: + case ID_LOAD_PROJECT: + Files_io(event); + break; + + case ID_PCB_GLOBAL_DELETE: + InstallPcbGlobalDeleteFrame(pos); + break; + + case ID_POPUP_PLACE_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_MOVE; + DrawPanel->m_AutoPAN_Request = FALSE; + HandleBlockPlace(&dc); + break; + + case ID_POPUP_COPY_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_COPY; + m_CurrentScreen->BlockLocate.SetMessageBlock(this); + DrawPanel->m_AutoPAN_Request = FALSE; + HandleBlockPlace(&dc); + break; + + case ID_POPUP_ZOOM_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_ZOOM; + m_CurrentScreen->BlockLocate.SetMessageBlock(this); + m_CurrentScreen->BlockLocate.SetMessageBlock(this); + HandleBlockEnd(&dc); + break; + + case ID_POPUP_DELETE_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_DELETE; + m_CurrentScreen->BlockLocate.SetMessageBlock(this); + HandleBlockEnd(&dc); + break; + + case ID_POPUP_ROTATE_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_ROTATE; + m_CurrentScreen->BlockLocate.SetMessageBlock(this); + HandleBlockEnd(&dc); + break; + + case ID_POPUP_INVERT_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_INVERT; + m_CurrentScreen->BlockLocate.SetMessageBlock(this); + HandleBlockEnd(&dc); + break; + + case ID_UNDO_BUTT: + UnDeleteItem(&dc); + break; + + case ID_DRC_CONTROL: + Install_Test_DRC_Frame(&dc); + break; + + case ID_GET_NETLIST: + InstallNetlistFrame(&dc, wxPoint(-1,-1)); + break; + + case ID_GET_TOOLS: +// InstallToolsFrame(this, wxPoint(-1,-1) ); + break; + + case ID_FIND_ITEMS: + InstallFindFrame(pos, &dc); + break; + + case ID_TRACK_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Tracks")); + DisplayTrackSettings(); + if ( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0) + { + Compile_Ratsnest( &dc, TRUE ); + } + break; + + case ID_PCB_ZONES_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Zones")); + if ( ! DisplayOpt.DisplayZones ) + DisplayInfo(this, _("Warning: Display Zone is OFF!!!") ); + DelLimitesZone(&dc, TRUE); + if( ! g_HightLigt_Status && (g_HightLigth_NetCode > 0 ) ) + Hight_Light(&dc); + break; + + case ID_PCB_MIRE_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Mire")); + break; + + case ID_PCB_PLACE_OFFSET_COORD_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Adjust Zero")); + break; + + case ID_LINE_COMMENT_BUTT: + case ID_PCB_ARC_BUTT: + case ID_PCB_CIRCLE_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Graphic")); + break; + + case ID_TEXT_COMMENT_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Text")); + break; + + case ID_COMPONENT_BUTT: + SetToolID( id, wxCURSOR_HAND, _("Add Modules")); + break; + + case ID_PCB_COTATION_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Cotation")); + break; + + case ID_NO_SELECT_BUTT: + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + break; + + case ID_PCB_HIGHLIGHT_BUTT: + SetToolID( id, wxCURSOR_HAND, _("Net Highlight")); + break; + + case ID_PCB_SHOW_1_RATSNEST_BUTT: + SetToolID( id, wxCURSOR_HAND, _("Local Ratsnest")); + if ( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0) + Compile_Ratsnest( &dc, TRUE ); + break; + + case ID_POPUP_CLOSE_CURRENT_TOOL: + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + break; + + + case ID_POPUP_CANCEL_CURRENT_COMMAND: + break; + + case ID_POPUP_END_LINE: + DrawPanel->MouseToCursorSchema(); +// EndSegment(&dc); + break; + + case ID_POPUP_PCB_EDIT_TRACK: + if ( CURRENT_ITEM == NULL) break; + Edit_Track_Width(&dc, (TRACK *) CURRENT_ITEM); + DrawPanel->MouseToCursorSchema(); + GetScreen()->SetModify(); + break; + + case ID_POPUP_PCB_EDIT_TRACKSEG: + if ( CURRENT_ITEM == NULL) break; + Edit_TrackSegm_Width(&dc, (TRACK *) CURRENT_ITEM); + DrawPanel->MouseToCursorSchema(); + GetScreen()->SetModify(); + break; + + case ID_POPUP_PCB_EDIT_NET: + if ( CURRENT_ITEM == NULL) break; + Edit_Net_Width(&dc, ((TRACK *) CURRENT_ITEM)->m_NetCode); + DrawPanel->MouseToCursorSchema(); + GetScreen()->SetModify(); + break; + + case ID_POPUP_PCB_EDIT_ALL_VIAS_AND_TRACK_SIZE: + case ID_POPUP_PCB_EDIT_ALL_VIAS_SIZE: + case ID_POPUP_PCB_EDIT_ALL_TRACK_SIZE: + if ( CURRENT_ITEM == NULL) break; + { + bool resize_vias = TRUE, resize_track = TRUE; + if( id == ID_POPUP_PCB_EDIT_ALL_VIAS_SIZE) resize_track = FALSE; + if( id == ID_POPUP_PCB_EDIT_ALL_TRACK_SIZE) resize_vias = FALSE; + if ( Resize_Pistes_Vias(&dc, resize_track, resize_vias)) GetScreen()->SetModify(); + } + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_END_TRACK: + DrawPanel->MouseToCursorSchema(); + End_Route( (TRACK *) CURRENT_ITEM, &dc); + break; + + case ID_POPUP_PCB_PLACE_MOVED_TRACK_NODE: + DrawPanel->MouseToCursorSchema(); + if ( CURRENT_ITEM->m_Flags & IS_DRAGGED ) + { + PlaceDraggedTrackSegment((TRACK *) CURRENT_ITEM, &dc); + } + break; + + case ID_POPUP_PCB_PLACE_VIA: + DrawPanel->MouseToCursorSchema(); + if ( CURRENT_ITEM->m_Flags & IS_DRAGGED ) + { + PlaceDraggedTrackSegment((TRACK *) CURRENT_ITEM, &dc); + } + else + { + Other_Layer_Route( (TRACK *) CURRENT_ITEM, &dc); + if ( DisplayOpt.ContrastModeDisplay ) + GetScreen()->SetRefreshReq(); + } + break; + + + case ID_POPUP_PCB_DELETE_TRACKSEG: + DrawPanel->MouseToCursorSchema(); + GetScreen()->m_CurrentItem = Delete_Segment(&dc, (TRACK*)CURRENT_ITEM); + GetScreen()->SetModify(); + break; + + case ID_POPUP_PCB_DELETE_TRACK: + DrawPanel->MouseToCursorSchema(); + Delete_Track(&dc, (TRACK*)CURRENT_ITEM); + GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetModify(); + break; + + case ID_POPUP_PCB_DELETE_TRACKNET: + DrawPanel->MouseToCursorSchema(); + Delete_net(&dc, (TRACK*)CURRENT_ITEM); + GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetModify(); + break; + + case ID_POPUP_PCB_LOCK_ON_TRACKSEG: + Attribut_Segment((TRACK*)CURRENT_ITEM, &dc, TRUE); + break; + + case ID_POPUP_PCB_LOCK_OFF_TRACKSEG: + Attribut_Segment((TRACK*)CURRENT_ITEM, &dc, FALSE); + break; + + case ID_POPUP_PCB_LOCK_ON_TRACK: + Attribut_Track((TRACK*)CURRENT_ITEM, &dc, TRUE); + break; + + case ID_POPUP_PCB_LOCK_OFF_TRACK: + Attribut_Track((TRACK*)CURRENT_ITEM, &dc, FALSE); + break; + + case ID_POPUP_PCB_LOCK_ON_NET: + Attribut_net(&dc, ((TRACK*)CURRENT_ITEM)->m_NetCode, TRUE); + break; + + case ID_POPUP_PCB_LOCK_OFF_NET: + Attribut_net(&dc, ((TRACK*)CURRENT_ITEM)->m_NetCode, FALSE); + break; + + case ID_POPUP_PCB_SETFLAGS_TRACK_MNU: + break; + + case ID_POPUP_PCB_DELETE_ZONE: + DrawPanel->MouseToCursorSchema(); + if ( CURRENT_ITEM == NULL) break; + Delete_Zone(&dc, (SEGZONE*)CURRENT_ITEM); + GetScreen()->m_CurrentItem = NULL; + break; + + case ID_POPUP_PCB_EDIT_ZONE: + DrawPanel->MouseToCursorSchema(); + if ( CURRENT_ITEM == NULL) break; + Edit_Zone_Width(&dc, (SEGZONE*)CURRENT_ITEM); + break; + + case ID_POPUP_PCB_DELETE_ZONE_LIMIT: + DrawPanel->MouseToCursorSchema(); + DelLimitesZone(&dc, TRUE); + break; + + case ID_PCB_DELETE_ITEM_BUTT: + SetToolID( id, wxCURSOR_BULLSEYE, _("Delete item")); + break; + + case ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST: + Process_Move_Item(this, CURRENT_ITEM, &dc); + DrawPanel->m_AutoPAN_Request = TRUE; + break; + + case ID_POPUP_PCB_DRAG_MODULE_REQUEST: + g_Drag_Pistes_On = TRUE; + case ID_POPUP_PCB_MOVE_MODULE_REQUEST: + // If the current Item is a pad, text module ...: Get the parent + if ( CURRENT_ITEM->m_StructType != TYPEMODULE ) + CURRENT_ITEM = (MODULE *) CURRENT_ITEM->m_Parent; + if ( !CURRENT_ITEM || CURRENT_ITEM->m_StructType != TYPEMODULE ) + { + g_Drag_Pistes_On = FALSE; + break; + } + DrawPanel->MouseToCursorSchema(); + StartMove_Module( (MODULE*)CURRENT_ITEM, &dc); + break; + + case ID_POPUP_PCB_DELETE_MODULE: + DrawPanel->MouseToCursorSchema(); + // If the current Item is a pad, text module ...: Get the parent + if ( CURRENT_ITEM->m_StructType != TYPEMODULE ) + CURRENT_ITEM = (MODULE *) CURRENT_ITEM->m_Parent; + if ( !CURRENT_ITEM || CURRENT_ITEM->m_StructType != TYPEMODULE ) + break; + if ( Delete_Module((MODULE*) CURRENT_ITEM, &dc) ) + { + GetScreen()->m_CurrentItem = NULL; + } + break; + + case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE: + DrawPanel->MouseToCursorSchema(); + // If the current Item is a pad, text module ...: Get the parent + if ( CURRENT_ITEM->m_StructType != TYPEMODULE ) + CURRENT_ITEM = (MODULE *) CURRENT_ITEM->m_Parent; + if ( !CURRENT_ITEM || CURRENT_ITEM->m_StructType != TYPEMODULE ) + break; + Rotate_Module(&dc, (MODULE*)CURRENT_ITEM, -900, TRUE); + break; + + case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE: + DrawPanel->MouseToCursorSchema(); + // If the current Item is a pad, text module ...: Get the parent + if ( CURRENT_ITEM->m_StructType != TYPEMODULE ) + CURRENT_ITEM = (MODULE *) CURRENT_ITEM->m_Parent; + if ( !CURRENT_ITEM || CURRENT_ITEM->m_StructType != TYPEMODULE ) + break; + Rotate_Module(&dc, (MODULE*)CURRENT_ITEM, 900, TRUE); + break; + + case ID_POPUP_PCB_CHANGE_SIDE_MODULE: + DrawPanel->MouseToCursorSchema(); + // If the current Item is a pad, text module ...: Get the parent + if ( CURRENT_ITEM->m_StructType != TYPEMODULE ) + CURRENT_ITEM = (MODULE *) CURRENT_ITEM->m_Parent; + if ( !CURRENT_ITEM || CURRENT_ITEM->m_StructType != TYPEMODULE ) + break; + Change_Side_Module((MODULE *) CURRENT_ITEM, &dc); + break; + + case ID_POPUP_PCB_EDIT_MODULE: + // If the current Item is a pad, text module ...: Get the parent + if ( CURRENT_ITEM->m_StructType != TYPEMODULE ) + CURRENT_ITEM = (MODULE *) CURRENT_ITEM->m_Parent; + if ( !CURRENT_ITEM || CURRENT_ITEM->m_StructType != TYPEMODULE ) + break; + InstallModuleOptionsFrame((MODULE *)CURRENT_ITEM, + &dc, pos); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_DRAG_PAD_REQUEST: + g_Drag_Pistes_On = TRUE; + case ID_POPUP_PCB_MOVE_PAD_REQUEST: + DrawPanel->MouseToCursorSchema(); + StartMovePad((D_PAD *)CURRENT_ITEM, &dc); + break; + + case ID_POPUP_PCB_EDIT_PAD: + InstallPadOptionsFrame((D_PAD *)CURRENT_ITEM, + &dc, pos); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_IMPORT_PAD_SETTINGS: + DrawPanel->MouseToCursorSchema(); + Import_Pad_Settings((D_PAD *)CURRENT_ITEM, &dc); + break; + + case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS: + DrawPanel->MouseToCursorSchema(); + Global_Import_Pad_Settings((D_PAD *)CURRENT_ITEM, &dc); + break; + + case ID_POPUP_PCB_EXPORT_PAD_SETTINGS: + DrawPanel->MouseToCursorSchema(); + Export_Pad_Settings((D_PAD *)CURRENT_ITEM); + break; + + + case ID_POPUP_PCB_DELETE_PAD: + DeletePad((D_PAD *)CURRENT_ITEM, &dc); + GetScreen()->m_CurrentItem = NULL; + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_EDIT_TEXTMODULE: + InstallTextModOptionsFrame((TEXTE_MODULE *)CURRENT_ITEM, + &dc, pos); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST: + DrawPanel->MouseToCursorSchema(); + StartMoveTexteModule( (TEXTE_MODULE *) CURRENT_ITEM, + &dc); + break; + + case ID_POPUP_PCB_ROTATE_TEXTMODULE: + RotateTextModule((TEXTE_MODULE *)CURRENT_ITEM, + &dc); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_DELETE_TEXTMODULE: + DeleteTextModule((TEXTE_MODULE *)CURRENT_ITEM, + &dc); + GetScreen()->m_CurrentItem = NULL; + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_SELECT_LAYER: + itmp = SelectLayer(GetScreen()->m_Active_Layer, -1, -1); + if ( itmp >= 0 ) GetScreen()->m_Active_Layer = itmp; + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_SELECT_NO_CU_LAYER: + itmp = SelectLayer(GetScreen()->m_Active_Layer, CMP_N+1, -1); + if ( itmp >= 0 ) GetScreen()->m_Active_Layer = itmp; + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_SELECT_CU_LAYER: + itmp = SelectLayer(GetScreen()->m_Active_Layer, -1, CMP_N); + if ( itmp >= 0 ) GetScreen()->m_Active_Layer = itmp; + break; + + case ID_POPUP_PCB_SELECT_LAYER_PAIR: + SelectLayerPair(); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_TOOLBARH_PCB_SELECT_LAYER: + itmp = m_SelLayerBox->GetChoice(); + GetScreen()->m_Active_Layer = (int)((size_t) m_SelLayerBox->GetClientData(itmp)); + if ( DisplayOpt.ContrastModeDisplay ) DrawPanel->Refresh(TRUE); + break; + + case ID_POPUP_PCB_EDIT_TEXTEPCB: + InstallTextPCBOptionsFrame((TEXTE_PCB *)CURRENT_ITEM, + &dc, pos); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_ROTATE_TEXTEPCB: + Rotate_Texte_Pcb((TEXTE_PCB *)CURRENT_ITEM, &dc); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_DELETE_TEXTEPCB: + Delete_Texte_Pcb((TEXTE_PCB *)CURRENT_ITEM, &dc); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_MOVE_MIRE_REQUEST: + StartMove_Mire((MIREPCB *)CURRENT_ITEM, &dc); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_EDIT_MIRE: + InstallMireOptionsFrame((MIREPCB *)CURRENT_ITEM, &dc, pos); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_DELETE_MIRE: + DrawPanel->MouseToCursorSchema(); + Delete_Mire((MIREPCB *)CURRENT_ITEM, &dc); + GetScreen()->m_CurrentItem = NULL; + break; + + case ID_POPUP_PCB_DELETE_COTATION: + DrawPanel->MouseToCursorSchema(); + Delete_Cotation((COTATION*)CURRENT_ITEM, &dc); + GetScreen()->m_CurrentItem = NULL; + break; + + case ID_POPUP_PCB_EDIT_COTATION: + Install_Edit_Cotation((COTATION*)CURRENT_ITEM, &dc, pos); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_DELETE_DRAWING: + Delete_Segment_Edge((DRAWSEGMENT *)CURRENT_ITEM, &dc); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_DELETE_DRAWING_LAYER: + Delete_Drawings_All_Layer((DRAWSEGMENT *)CURRENT_ITEM, &dc); + GetScreen()->m_CurrentItem = NULL; + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_EDIT_DRAWING: + Drawing_SetNewWidth((DRAWSEGMENT *)CURRENT_ITEM, &dc); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_MOVE_DRAWING_REQUEST: + DrawPanel->MouseToCursorSchema(); + Start_Move_DrawItem((DRAWSEGMENT *)CURRENT_ITEM, &dc); + break; + + case ID_POPUP_PCB_STOP_CURRENT_DRAWING: + DrawPanel->MouseToCursorSchema(); + if ( CURRENT_ITEM && (CURRENT_ITEM->m_Flags & IS_NEW) ) + { + End_Edge( (DRAWSEGMENT *)CURRENT_ITEM, &dc); + GetScreen()->m_CurrentItem = NULL; + } + break; + + case ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE: + DrawPanel->MouseToCursorSchema(); + if ( CURRENT_ITEM && (CURRENT_ITEM->m_Flags & IS_NEW) ) + { + End_Zone(&dc); + GetScreen()->m_CurrentItem = NULL; + } + break; + + case ID_POPUP_PCB_DELETE_EDGE_ZONE: + DrawPanel->MouseToCursorSchema(); + if ( CURRENT_ITEM && (CURRENT_ITEM->m_Flags & IS_NEW) ) + { + GetScreen()->m_CurrentItem = Del_SegmEdgeZone(&dc, + (EDGE_ZONE *) CURRENT_ITEM); + } + break; + + case ID_POPUP_PCB_FILL_ZONE: + DrawPanel->MouseToCursorSchema(); + Fill_Zone(&dc); + break; + + case ID_POPUP_PCB_SELECT_NET_ZONE: + DrawPanel->MouseToCursorSchema(); + CaptureNetName(&dc); + break; + + case ID_POPUP_PCB_SELECT_WIDTH: + break; + + case ID_AUX_TOOLBAR_PCB_TRACK_WIDTH: + { + int ii = m_SelTrackWidthBox->GetChoice(); + g_DesignSettings.m_CurrentTrackWidth = g_DesignSettings.m_TrackWidhtHistory[ii]; + DisplayTrackSettings(); + m_SelTrackWidthBox_Changed = FALSE; + m_SelViaSizeBox_Changed = FALSE; + } + break; + case ID_POPUP_PCB_SELECT_WIDTH1: + case ID_POPUP_PCB_SELECT_WIDTH2: + case ID_POPUP_PCB_SELECT_WIDTH3: + case ID_POPUP_PCB_SELECT_WIDTH4: + case ID_POPUP_PCB_SELECT_WIDTH5: + case ID_POPUP_PCB_SELECT_WIDTH6: + case ID_POPUP_PCB_SELECT_WIDTH7: + case ID_POPUP_PCB_SELECT_WIDTH8: + DrawPanel->MouseToCursorSchema(); + { + int ii = id - ID_POPUP_PCB_SELECT_WIDTH1; + g_DesignSettings.m_CurrentTrackWidth = g_DesignSettings.m_TrackWidhtHistory[ii]; + DisplayTrackSettings(); + } + break; + + case ID_POPUP_PCB_SELECT_VIASIZE: + break; + + case ID_AUX_TOOLBAR_PCB_VIA_SIZE: + { + int ii = m_SelViaSizeBox->GetChoice(); + g_DesignSettings.m_CurrentViaSize = g_DesignSettings.m_ViaSizeHistory[ii]; + DisplayTrackSettings(); + m_SelTrackWidthBox_Changed = FALSE; + m_SelViaSizeBox_Changed = FALSE; + } + break; + + case ID_POPUP_PCB_SELECT_VIASIZE1: + case ID_POPUP_PCB_SELECT_VIASIZE2: + case ID_POPUP_PCB_SELECT_VIASIZE3: + case ID_POPUP_PCB_SELECT_VIASIZE4: + case ID_POPUP_PCB_SELECT_VIASIZE5: + case ID_POPUP_PCB_SELECT_VIASIZE6: + case ID_POPUP_PCB_SELECT_VIASIZE7: + case ID_POPUP_PCB_SELECT_VIASIZE8: + case ID_POPUP_PCB_VIA_EDITING: + case ID_POPUP_PCB_VIA_HOLE_TO_DEFAULT: + case ID_POPUP_PCB_VIA_HOLE_TO_VALUE: + case ID_POPUP_PCB_VIA_HOLE_ENTER_VALUE: + case ID_POPUP_PCB_VIA_HOLE_EXPORT: + case ID_POPUP_PCB_VIA_HOLE_RESET_TO_DEFAULT: + case ID_POPUP_PCB_VIA_HOLE_EXPORT_TO_OTHERS: + Via_Edit_Control(&dc, id, (SEGVIA *) GetScreen()->m_CurrentItem); + break; + + case ID_POPUP_PCB_MOVE_TRACK_NODE: + DrawPanel->MouseToCursorSchema(); + Start_MoveOneTrackSegment((TRACK *) GetScreen()->m_CurrentItem, + &dc, TRUE); + break; + + case ID_POPUP_PCB_BREAK_TRACK: + DrawPanel->MouseToCursorSchema(); + { + TRACK * track = (TRACK *) GetScreen()->m_CurrentItem; + wxPoint pos = GetScreen()->m_Curseur; + track->Draw(DrawPanel, &dc, GR_XOR); + TRACK * newtrack = CreateLockPoint(&pos.x, &pos.y, track, NULL); + track->Draw(DrawPanel, &dc, GR_XOR); + newtrack->Draw(DrawPanel, &dc, GR_XOR); + } + break; + + case ID_MENU_PCB_CLEAN: + Clean_Pcb(&dc); + break; + + case ID_MENU_PCB_SWAP_LAYERS: + Swap_Layers(event); + break; + + case ID_POPUP_PCB_AUTOROUTE_GET_AUTOROUTER: + GlobalRoute(&dc); + break; + + case ID_POPUP_PCB_AUTOROUTE_GET_AUTOROUTER_DATA: + ReadAutoroutedTracks(&dc); + break; + + case ID_PCB_USER_GRID_SETUP: + InstallGridFrame(pos); + break; + + case ID_POPUP_PCB_DISPLAY_FOOTPRINT_DOC: + { + wxString msg = FindKicadHelpPath(); + msg += EDA_Appl->m_EDA_CommonConfig->Read(wxT("module_doc_file"), + wxT("pcbnew/footprints.pdf")); + GetAssociatedDocument(this, wxEmptyString, msg); + } + break; + + case ID_MENU_ARCHIVE_NEW_MODULES: + Archive_Modules(wxEmptyString, TRUE); + break; + + case ID_MENU_ARCHIVE_ALL_MODULES: + Archive_Modules(wxEmptyString, FALSE); + break; + + default: + { + DisplayError(this, wxT("WinEDA_PcbFrame::Process_Special_Functions() id error")); + break; + } + } + + SetToolbars(); + DrawPanel->CursorOn(&dc); + DrawPanel->m_IgnoreMouseEvents = FALSE; +} + + +/****************************************************************/ +static void Process_Move_Item(WinEDA_PcbFrame * frame, + EDA_BaseStruct *DrawStruct, wxDC * DC) +/****************************************************************/ +{ + + if ( DrawStruct == NULL ) return; + + frame->DrawPanel->MouseToCursorSchema(); + switch ( DrawStruct->m_StructType ) + { + case TYPETEXTE: + frame->StartMoveTextePcb((TEXTE_PCB *) DrawStruct, DC); + break; + + default: + wxString msg; + msg.Printf( + wxT("WinEDA_PcbFrame::Move_Item Error: Bad DrawType %d"), + DrawStruct->m_StructType); + DisplayError(frame, msg ); + break; + } +} + + +/********************************************************************************/ +void WinEDA_PcbFrame::OnLeftDClick(wxDC * DC, const wxPoint& MousePos) +/********************************************************************************/ +/* Appelé sur un double click: + pour un élément editable (textes, composant): + appel de l'editeur correspondant. + pour une connexion en cours: + termine la connexion +*/ +{ +EDA_BaseStruct * DrawStruct = CURRENT_ITEM; +wxPoint pos = GetPosition(); +wxClientDC dc(DrawPanel); + + DrawPanel->PrepareGraphicContext(&dc); + + switch ( m_ID_current_state ) + { + case 0: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + DrawStruct = PcbGeneralLocateAndDisplay(); + } + + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) ) + break; + + // Element localisé + GetScreen()->m_CurrentItem = DrawStruct; + switch ( DrawStruct->m_StructType ) + { + case TYPETRACK: + case TYPEVIA: + if (DrawStruct->m_Flags & IS_NEW) + { + End_Route( (TRACK *) DrawStruct, DC); + DrawPanel->m_AutoPAN_Request = FALSE; + } + else if (DrawStruct->m_Flags == 0) + { + Edit_TrackSegm_Width(DC, + (TRACK *) DrawStruct); + } + break; + + case TYPETEXTE: + InstallTextPCBOptionsFrame((TEXTE_PCB *)DrawStruct, + DC, ((TEXTE_PCB *)DrawStruct)->m_Pos); + DrawPanel->MouseToCursorSchema(); + break; + + case TYPEPAD: + InstallPadOptionsFrame( + (D_PAD *)DrawStruct, &dc, pos); + DrawPanel->MouseToCursorSchema(); + break; + + case TYPEMODULE: + InstallModuleOptionsFrame((MODULE *)DrawStruct, + &dc, pos); + DrawPanel->MouseToCursorSchema(); + break; + + case TYPEMIRE: + InstallMireOptionsFrame( (MIREPCB *)DrawStruct, &dc, pos); + DrawPanel->MouseToCursorSchema(); + break; + + case TYPETEXTEMODULE: + InstallTextModOptionsFrame((TEXTE_MODULE *)DrawStruct, + &dc, pos); + DrawPanel->MouseToCursorSchema(); + break; + + case TYPEDRAWSEGMENT: + break; + + default: + break; + } + break; // end case 0 + + case ID_TRACK_BUTT: + if ( DrawStruct && (DrawStruct->m_Flags & IS_NEW) ) + { + End_Route( (TRACK *) DrawStruct, DC); + DrawPanel->m_AutoPAN_Request = FALSE; + } + break; + + case ID_PCB_ZONES_BUTT: + End_Zone(DC); + DrawPanel->m_AutoPAN_Request = FALSE; + GetScreen()->m_CurrentItem = NULL; + break; + + case ID_LINE_COMMENT_BUTT: + case ID_PCB_ARC_BUTT: + case ID_PCB_CIRCLE_BUTT: + if ( DrawStruct == NULL ) break; + if ( DrawStruct->m_StructType != TYPEDRAWSEGMENT ) + { + DisplayError(this, wxT("DrawStruct Type error")); + DrawPanel->m_AutoPAN_Request = FALSE; + break; + } + if ( (DrawStruct->m_Flags & IS_NEW) ) + { + End_Edge( (DRAWSEGMENT *) DrawStruct, &dc); + DrawPanel->m_AutoPAN_Request = FALSE; + GetScreen()->m_CurrentItem = NULL; + } + break; + + } +} + +/***************************************************************/ +void WinEDA_PcbFrame::RemoveStruct(EDA_BaseStruct * Item, wxDC * DC) +/***************************************************************/ +{ + if ( Item == NULL ) return; + + switch( Item->m_StructType ) + { + case TYPEMODULE: + Delete_Module((MODULE *) Item, DC); + break; + + case TYPECOTATION: + Delete_Cotation((COTATION *) Item, DC); + break; + + case TYPEMIRE: + Delete_Mire((MIREPCB *) Item, DC); + break; + + case TYPEDRAWSEGMENT: + Delete_Segment_Edge((DRAWSEGMENT *)Item, DC); + break; + + case TYPETEXTE: + Delete_Texte_Pcb((TEXTE_PCB *) Item, DC); + break; + + case TYPETRACK: + Delete_Track(DC, (TRACK *)Item); + break; + + case TYPEVIA: + Delete_Segment(DC, (TRACK *)Item); + break; + + case TYPEZONE: + Delete_Zone(DC, (SEGZONE*)Item); + break; + + case TYPEMARQUEUR: + break; + + case TYPEPAD: + case TYPETEXTEMODULE: + case TYPEEDGEMODULE: + break; + + case TYPE_NOT_INIT: + case PCB_EQUIPOT_STRUCT_TYPE: + case TYPEPCB: + default: + { + wxString Line; + Line.Printf( wxT("Remove: StructType %d Inattendu"), + Item->m_StructType); + DisplayError(this, Line); + } + break; + } +} diff --git a/pcbnew/edit_track_width.cpp b/pcbnew/edit_track_width.cpp new file mode 100644 index 0000000000..15bf07577b --- /dev/null +++ b/pcbnew/edit_track_width.cpp @@ -0,0 +1,156 @@ + /***************************************************************/ + /* Edition des pistes: Routines de modification de dimensions: */ + /* Modif de largeurs de segment, piste, net , zone et diam Via */ + /***************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "protos.h" + +/* Routines Locales */ + +/*********************************************************************/ +int WinEDA_PcbFrame::Edit_TrackSegm_Width(wxDC * DC, TRACK * pt_segm) +/*********************************************************************/ +/* Routine to modify one track segment width or one via diameter. + Basic routine used by other routines when editing tracks or vias +*/ +{ +int errdrc = OK_DRC; +int old_w, consigne ; + + DrawPanel->CursorOff(DC); // Erase cursor shape + pt_segm->Draw(DrawPanel, DC, GR_XOR) ; // Erase old track shape + + /* Test DRC and width change */ + old_w = pt_segm->m_Width; + consigne = pt_segm->m_Width = g_DesignSettings.m_CurrentTrackWidth; + if( pt_segm->m_StructType == TYPEVIA ) + { + consigne = pt_segm->m_Width = g_DesignSettings.m_CurrentViaSize; + } + + if ( old_w < consigne) /* DRC utile puisque augm de dimension */ + { + if(Drc_On) errdrc = Drc(this, DC, pt_segm, m_Pcb->m_Track,1); + if(errdrc == BAD_DRC) pt_segm->m_Width = old_w; + else GetScreen()->SetModify(); + } + + else GetScreen()->SetModify(); /* Correction systematiquement faite si reduction */ + + pt_segm->Draw(DrawPanel, DC, GR_OR) ; // Display new track shape + DrawPanel->CursorOn(DC); // Display cursor shape + return(errdrc); +} + +/*****************************************************************/ +void WinEDA_PcbFrame::Edit_Track_Width(wxDC * DC,TRACK * pt_segm) +/*****************************************************************/ +{ +int ii; +TRACK * pt_track; +int errdrc; +int nb_segm, nb_segm_modifies = 0, nb_segm_non_modifies = 0; + + if( pt_segm == NULL) return; + + pt_track = Marque_Une_Piste(this, DC, pt_segm, &nb_segm, 0); + for(ii = 0; ii < nb_segm; ii++, pt_track = (TRACK*) pt_track->Pnext) + { + pt_track->SetState(BUSY,OFF); + errdrc = Edit_TrackSegm_Width(DC, pt_track); + if(errdrc == BAD_DRC) nb_segm_non_modifies++; + else nb_segm_modifies++; + } +} + + +/***********************************************************/ +void WinEDA_PcbFrame::Edit_Net_Width(wxDC * DC, int Netcode) +/***********************************************************/ +{ +TRACK *pt_segm; +int errdrc; +int nb_segm_modifies = 0; +int nb_segm_non_modifies = 0; + + if (Netcode <= 0 ) return; + + if( ! IsOK(this, _("Change track width (entire NET) ?") ) ) return; + + /* balayage des segments */ + for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext ) + { + if ( Netcode != pt_segm->m_NetCode ) /* mauvaise piste */ + continue ; + /* piste d'un net trouvee */ + errdrc = Edit_TrackSegm_Width(DC, pt_segm); + if(errdrc == BAD_DRC) nb_segm_non_modifies++; + else nb_segm_modifies++; + } +} + + + + +/*************************************************************************/ +bool WinEDA_PcbFrame::Resize_Pistes_Vias(wxDC * DC, bool Track, bool Via) +/*************************************************************************/ +/* remet a jour la largeur des pistes et/ou le diametre des vias + Si piste == 0 , pas de cht sur les pistes + Si via == 0 , pas de cht sur les vias +*/ +{ +TRACK * pt_segm ; +int errdrc; +int nb_segm_modifies = 0; +int nb_segm_non_modifies = 0; + + if ( Track && Via) + { + if( ! IsOK(this, _("Edit All Tracks and Vias Sizes")) ) return FALSE; + } + + else if ( Via ) + { + if( ! IsOK(this, _("Edit All Via Sizes")) ) return FALSE; + } + + else if( Track ) + { + if( ! IsOK(this, _("Edit All Track Sizes")) ) return FALSE; + } + + pt_segm = m_Pcb->m_Track ; + for ( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext ) + { + if( pt_segm->m_StructType == TYPEVIA ) /* mise a jour du diametre de la via */ + { + if ( Via ) + { + errdrc = Edit_TrackSegm_Width(DC, pt_segm); + if(errdrc == BAD_DRC) nb_segm_non_modifies++; + else nb_segm_modifies++; + } + } + else /* mise a jour de la largeur du segment */ + { + if ( Track ) + { + errdrc = Edit_TrackSegm_Width(DC, pt_segm); + if(errdrc == BAD_DRC) nb_segm_non_modifies++; + else nb_segm_modifies++; + } + } + } + + if ( nb_segm_modifies ) return TRUE; + return FALSE; +} + diff --git a/pcbnew/editedge.cpp b/pcbnew/editedge.cpp new file mode 100644 index 0000000000..3be638a403 --- /dev/null +++ b/pcbnew/editedge.cpp @@ -0,0 +1,378 @@ + /******************************************************/ + /* Edition des contours du pcb: Routines */ + /* d'effacement et d'edition de segments et contours */ + /* du type PCB, draw, edgePCB */ + /******************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + +/* Routines Locales */ +static void Exit_EditEdge(WinEDA_DrawPanel * Panel, wxDC * DC); +static void Montre_Position_NewSegment(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void Move_Segment(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); + +/* Variables locales : */ +static wxPoint cursor_pos; // position originelle du curseur souris (fct deplacement) +static wxPoint cursor_pos0; // position courante du curseur souris + +/****************************************************************************/ +void WinEDA_PcbFrame::Start_Move_DrawItem(DRAWSEGMENT * drawitem, wxDC * DC) +/****************************************************************************/ + /* Routine de preparation du deplacement d'un element graphique type DRAWSEGMENT +*/ +{ + if( drawitem == NULL ) return; + Trace_DrawSegmentPcb(DrawPanel, DC, drawitem,GR_XOR) ; + drawitem->m_Flags |= IS_MOVED; + cursor_pos = cursor_pos0 = GetScreen()->m_Curseur; + Affiche_Infos_DrawSegment(this, drawitem); + DrawPanel->ManageCurseur = Move_Segment; + DrawPanel->ForceCloseManageCurseur = Exit_EditEdge; + GetScreen()->m_CurrentItem = drawitem; + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE); +} + +/*********************************************************************/ +void WinEDA_PcbFrame::Place_DrawItem(DRAWSEGMENT * drawitem, wxDC * DC) +/*********************************************************************/ +/* + Routine de placement de l'element graphique type DRAWSEGMENT en cours de deplacement +*/ +{ + if( drawitem == NULL ) return; + + Trace_DrawSegmentPcb(DrawPanel, DC, drawitem,GR_OR) ; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetModify(); + drawitem->m_Flags = 0; +} + + +/************************************************************************/ +static void Move_Segment(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/************************************************************************/ +/* redessin du contour du Segment Edge lors des deplacements de la souris */ +{ +DRAWSEGMENT * Segment = ( DRAWSEGMENT * ) + panel->GetScreen()->m_CurrentItem ; +int t_fill = DisplayOpt.DisplayDrawItems; + + if(Segment == NULL) return ; + + DisplayOpt.DisplayDrawItems = SKETCH ; + + /* efface ancienne position */ + if( erase ) + Trace_DrawSegmentPcb(panel, DC, Segment, GR_XOR); + +wxPoint delta; + delta.x = panel->GetScreen()->m_Curseur.x - cursor_pos.x; + delta.y = panel->GetScreen()->m_Curseur.y - cursor_pos.y; + Segment->m_Start.x += delta.x; + Segment->m_Start.y += delta.y; + Segment->m_End.x += delta.x; + Segment->m_End.y += delta.y; + cursor_pos = panel->GetScreen()->m_Curseur; + + Trace_DrawSegmentPcb(panel, DC, Segment,GR_XOR); + DisplayOpt.DisplayDrawItems = t_fill ; +} + + + +/**************************************************************************/ +void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC * DC) +/**************************************************************************/ +{ +EDA_BaseStruct * PtStruct; +int track_fill_copy = DisplayOpt.DisplayDrawItems; + + if (Segment == NULL ) return; + + if(Segment->m_Flags & IS_NEW) // Trace en cours, on peut effacer le dernier segment + { + /* effacement du segment en cours de trace */ + DisplayOpt.DisplayDrawItems = SKETCH ; + Trace_DrawSegmentPcb(DrawPanel, DC, Segment,GR_XOR) ; + PtStruct = Segment->Pback; + DeleteStructure(Segment); + if( PtStruct && (PtStruct->m_StructType == TYPEDRAWSEGMENT ) ) + Segment = (DRAWSEGMENT*) PtStruct; + DisplayOpt.DisplayDrawItems = track_fill_copy ; + GetScreen()->m_CurrentItem = NULL; + } + + else + { + Trace_DrawSegmentPcb(DrawPanel, DC, (DRAWSEGMENT *)Segment,GR_XOR) ; + Segment->m_Flags = 0; + DeleteStructure(Segment); + GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetModify(); + } +} + + +/*************************************************************************/ +void WinEDA_PcbFrame::Drawing_SetNewWidth(DRAWSEGMENT *DrawSegm, wxDC * DC) +/*************************************************************************/ +/* Met a la largeur courante le segment pointe part la souris +*/ +{ + + if( DrawSegm == NULL ) return; + + Trace_DrawSegmentPcb(DrawPanel, DC, DrawSegm, GR_XOR); + + if(DrawSegm->m_Layer == EDGE_N) DrawSegm->m_Width = g_DesignSettings.m_EdgeSegmentWidth; + else DrawSegm->m_Width = g_DesignSettings.m_DrawSegmentWidth; + + Trace_DrawSegmentPcb(DrawPanel, DC, DrawSegm, GR_OR); + + Affiche_Infos_DrawSegment(this, DrawSegm); + + GetScreen()->SetModify(); +} + + +/******************************************************************************/ +void WinEDA_PcbFrame::Delete_Drawings_All_Layer(DRAWSEGMENT *Segment, wxDC * DC) +/******************************************************************************/ +{ +DRAWSEGMENT * pt_segm; +TEXTE_PCB* pt_txt; +EDA_BaseStruct * PtStruct, *PtNext; +COTATION * Cotation; +int layer = Segment->m_Layer; + + if(layer <= CMP_N) + { + DisplayError(this, _("Copper layer global delete not allowed!"), 20); + return; + } + + if ( Segment->m_Flags ) + { + DisplayError(this, _("Segment is being edited"), 10); + return; + } + + wxString msg = _("Delete Layer ") + ReturnPcbLayerName(layer); + if( !IsOK(this, msg) ) return ; + + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtNext ) + { + GetScreen()->SetModify(); + PtNext = PtStruct->Pnext; + switch( PtStruct->m_StructType) + { + case TYPEDRAWSEGMENT: + pt_segm = (DRAWSEGMENT*) PtStruct; + if(pt_segm->m_Layer == layer) + { + Trace_DrawSegmentPcb(DrawPanel, DC, pt_segm,GR_XOR); + DeleteStructure(PtStruct); + } + break; + + case TYPETEXTE: + pt_txt = (TEXTE_PCB*)PtStruct; + if(pt_txt->m_Layer == layer) + { + pt_txt->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); + DeleteStructure( PtStruct ); + } + break; + + + case TYPECOTATION: + Cotation = (COTATION*)PtStruct; + if(Cotation->m_Layer == layer) + { + Cotation->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); + DeleteStructure(PtStruct); + } + break; + + default: DisplayError(this, wxT("Type Drawing Inconnu") ); + break; + } + } +} + + +/*************************************************************/ +static void Exit_EditEdge(WinEDA_DrawPanel * Panel, wxDC * DC) +/*************************************************************/ +{ +DRAWSEGMENT *Segment = (DRAWSEGMENT *) Panel->GetScreen()->m_CurrentItem ; + + if (Segment == NULL) return; + + if( Segment->m_Flags & IS_NEW ) + { + Panel->ManageCurseur(Panel, DC, FALSE); + DeleteStructure(Segment); + Segment = NULL; + } + + else + { + wxPoint pos = Panel->GetScreen()->m_Curseur; + Panel->GetScreen()->m_Curseur = cursor_pos0; + Panel->ManageCurseur(Panel, DC, TRUE); + Panel->GetScreen()->m_Curseur = pos; + Segment->m_Flags = 0; + Trace_DrawSegmentPcb(Panel, DC, Segment,GR_OR) ; + } + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + Panel->GetScreen()->m_CurrentItem = NULL; +} + +/**********************************************************************/ +DRAWSEGMENT * WinEDA_PcbFrame::Begin_DrawSegment(DRAWSEGMENT * Segment, + int shape, wxDC * DC) +/**********************************************************************/ +/* Routine d'initialisation du trace d'un segment de type autre que piste +*/ +{ +int s_large; +int angle = 0; +DRAWSEGMENT * DrawItem; + + s_large = g_DesignSettings.m_DrawSegmentWidth; + if(GetScreen()->m_Active_Layer == EDGE_N) + { + s_large = g_DesignSettings.m_EdgeSegmentWidth; + } + + if ( shape == S_ARC ) angle = 900; + + if(Segment == NULL ) /* debut reel du trace */ + { + GetScreen()->m_CurrentItem = Segment = new DRAWSEGMENT( m_Pcb); + Segment->m_Flags = IS_NEW; + Segment->m_Layer = GetScreen()->m_Active_Layer; + Segment->m_Width = s_large; + Segment->m_Shape = shape; + Segment->m_Angle = 900; + Segment->m_Start = Segment->m_End = GetScreen()->m_Curseur ; + DrawPanel->ManageCurseur = Montre_Position_NewSegment; + DrawPanel->ForceCloseManageCurseur = Exit_EditEdge; + } + + else /* trace en cours : les coord du point d'arrivee ont ete mises + a jour par la routine Montre_Position_NewSegment*/ + { + if( (Segment->m_Start.x != Segment->m_End.x ) + || (Segment->m_Start.y != Segment->m_End.y ) ) + { + if ( Segment->m_Shape == S_SEGMENT ) + { + Segment->Pnext = m_Pcb->m_Drawings; + Segment->Pback = m_Pcb; + if( m_Pcb->m_Drawings ) + m_Pcb->m_Drawings->Pback = Segment; + m_Pcb->m_Drawings = Segment; + GetScreen()->SetModify(); + Segment->m_Flags = 0; + + Trace_DrawSegmentPcb(DrawPanel, DC, Segment,GR_OR); + + DrawItem = Segment; + + GetScreen()->m_CurrentItem = Segment = new DRAWSEGMENT( m_Pcb ); + + Segment->m_Flags = IS_NEW; + Segment->m_Layer = DrawItem->m_Layer; + Segment->m_Width = s_large; + Segment->m_Shape = DrawItem->m_Shape; + Segment->m_Type = DrawItem->m_Type; + Segment->m_Angle = DrawItem->m_Angle; + Segment->m_Start = Segment->m_End = DrawItem->m_End; + Montre_Position_NewSegment(DrawPanel, DC, FALSE); + } + else + { + End_Edge(Segment, DC); + Segment = NULL; + } + } + } + return Segment; +} + + +/***************************************************************/ +void WinEDA_PcbFrame::End_Edge(DRAWSEGMENT * Segment, wxDC * DC) +/***************************************************************/ +{ + + if( Segment == NULL ) return ; + Trace_DrawSegmentPcb(DrawPanel, DC, (DRAWSEGMENT *)Segment,GR_OR); + + /* Effacement si Longueur nulle */ + if( (Segment->m_Start.x == Segment->m_End.x) && + (Segment->m_Start.y == Segment->m_End.y) ) + DeleteStructure(Segment); + + else + { + Segment->m_Flags = 0; + Segment->Pnext = m_Pcb->m_Drawings; + Segment->Pback = m_Pcb; + if( m_Pcb->m_Drawings ) m_Pcb->m_Drawings->Pback = Segment; + m_Pcb->m_Drawings = Segment; + GetScreen()->SetModify(); + } + + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->m_CurrentItem = NULL; +} + + +/************************************************************/ +static void Montre_Position_NewSegment(WinEDA_DrawPanel * panel, + wxDC * DC, bool erase) +/************************************************************/ +/* redessin du contour du Segment Edge lors des deplacements de la souris */ +{ +DRAWSEGMENT * Segment = ( DRAWSEGMENT * ) + panel->GetScreen()->m_CurrentItem ; +int t_fill = DisplayOpt.DisplayDrawItems; + + if(Segment == NULL) return ; + + DisplayOpt.DisplayDrawItems = SKETCH ; + + /* efface ancienne position */ + if( erase ) + Trace_DrawSegmentPcb(panel, DC, Segment, GR_XOR); + + if( Segments_45_Only && (Segment->m_Shape == S_SEGMENT ) ) + { + Calcule_Coord_Extremite_45(Segment->m_Start.x,Segment->m_Start.y, + &Segment->m_End.x, &Segment->m_End.y); + } + + else /* ici l'angle d'inclinaison est quelconque */ + { + Segment->m_End = panel->GetScreen()->m_Curseur; + } + + Trace_DrawSegmentPcb(panel, DC, Segment,GR_XOR); + DisplayOpt.DisplayDrawItems = t_fill ; +} + + diff --git a/pcbnew/editmod.cpp b/pcbnew/editmod.cpp new file mode 100644 index 0000000000..7b0ad03cff --- /dev/null +++ b/pcbnew/editmod.cpp @@ -0,0 +1,166 @@ + /************************************************/ + /* Module editor: Dialog box for editing module */ + /* properties and carateristics */ + /************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "trigo.h" +#include "bitmaps.h" +#include "3d_struct.h" +#include "3d_viewer.h" + +#include "protos.h" + +/* Variables locales: */ +bool GoToEditor = FALSE; + /**************************************/ + /* class WinEDA_ModulePropertiesFrame */ + /**************************************/ + +#include "dialog_edit_module.cpp" + +/*******************************************************************/ +void WinEDA_BasePcbFrame::InstallModuleOptionsFrame(MODULE * Module, + wxDC * DC, const wxPoint & pos) +/*******************************************************************/ +/* Fonction relai d'installation de la frame d'édition des proprietes +du module*/ +{ + WinEDA_ModulePropertiesFrame * frame = new WinEDA_ModulePropertiesFrame(this, + Module, DC, pos); + frame->ShowModal(); frame->Destroy(); + + if ( GoToEditor && GetScreen()->m_CurrentItem ) + { + if (m_Parent->m_ModuleEditFrame == NULL ) + { + m_Parent->m_ModuleEditFrame = new WinEDA_ModuleEditFrame(this, + m_Parent,_("Module Editor"), + wxPoint(-1, -1), wxSize(600,400) ); + } + + m_Parent->m_ModuleEditFrame->Load_Module_Module_From_BOARD( + (MODULE*)GetScreen()->m_CurrentItem); + GetScreen()->m_CurrentItem = NULL; + + GoToEditor = FALSE; + m_Parent->m_ModuleEditFrame->Show(TRUE); + m_Parent->m_ModuleEditFrame->Iconize(FALSE); + } +} + + + + +/*******************************************************************/ +void WinEDA_ModuleEditFrame::Place_Ancre(MODULE* pt_mod , wxDC * DC) +/*******************************************************************/ +/* + Repositionne l'ancre sous le curseur souris + Le module doit etre d'abort selectionne +*/ +{ +int deltaX, deltaY; +EDA_BaseStruct * PtStruct; +D_PAD * pt_pad; + + if(pt_mod == NULL) return ; + + pt_mod->DrawAncre(DrawPanel, DC, wxPoint(0,0), DIM_ANCRE_MODULE, GR_XOR); + + deltaX = pt_mod->m_Pos.x - GetScreen()->m_Curseur.x; + deltaY = pt_mod->m_Pos.y - GetScreen()->m_Curseur.y; + + pt_mod->m_Pos = GetScreen()->m_Curseur; + + /* Mise a jour des coord relatives des elements: + les coordonnees relatives sont relatives a l'ancre, pour orient 0. + il faut donc recalculer deltaX et deltaY en orientation 0 */ + RotatePoint(&deltaX, &deltaY, - pt_mod->m_Orient); + + /* Mise a jour des coord relatives des pads */ + pt_pad = (D_PAD*)pt_mod->m_Pads; + for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext) + { + pt_pad->m_Pos0.x += deltaX; pt_pad->m_Pos0.y += deltaY; + } + + /* Mise a jour des coord relatives contours .. */ + PtStruct = pt_mod->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext) + { + switch( PtStruct->m_StructType) + { + case TYPEEDGEMODULE: + #undef STRUCT + #define STRUCT ((EDGE_MODULE*) PtStruct) + STRUCT->m_Start0.x += deltaX; STRUCT->m_Start0.y += deltaY; + STRUCT->m_End0.x += deltaX; STRUCT->m_End0.y += deltaY; + break; + + case TYPETEXTEMODULE: + #undef STRUCT + #define STRUCT ((TEXTE_MODULE*) PtStruct) + STRUCT->m_Pos0.x += deltaX; STRUCT->m_Pos0.y += deltaY; + break; + + default: + break; + } + } + pt_mod->Set_Rectangle_Encadrement(); + pt_mod->DrawAncre(DrawPanel, DC, wxPoint(0,0), DIM_ANCRE_MODULE, GR_OR); +} + +/**********************************************************************/ +void WinEDA_ModuleEditFrame::RemoveStruct(EDA_BaseStruct * Item, wxDC * DC) +/**********************************************************************/ +{ + if ( Item == NULL ) return; + + switch( Item->m_StructType ) + { + case TYPEPAD: + DeletePad( (D_PAD*) Item, DC); + break; + + case TYPETEXTEMODULE: + { + TEXTE_MODULE * text = (TEXTE_MODULE *) Item; + if ( text->m_Type == TEXT_is_REFERENCE ) + { + DisplayError(this, _("Text is REFERENCE!") ); + break; + } + if ( text->m_Type == TEXT_is_VALUE ) + { + DisplayError(this, _("Text is VALUE!") ); + break; + } + DeleteTextModule(text, DC); + } + break; + + case TYPEEDGEMODULE: + Delete_Edge_Module((EDGE_MODULE *) Item, DC); + break; + + case TYPEMODULE: + break; + + default: + { + wxString Line; + Line.Printf( wxT(" Remove: StructType %d Inattendu"), + Item->m_StructType); + DisplayError(this, Line); + } + break; + } +} + diff --git a/pcbnew/editpads.cpp b/pcbnew/editpads.cpp new file mode 100644 index 0000000000..61bfff1da8 --- /dev/null +++ b/pcbnew/editpads.cpp @@ -0,0 +1,452 @@ + /******************************************************/ + /* editpads.cpp: Pad editing functions and dialog box */ + /******************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "trigo.h" + +#include "drag.h" + +#include "protos.h" + +/* Routines Locales */ + +/* Variables locales */ +static wxString Current_PadNetName; + + +#define NBSHAPES 4 +int CodeShape[NBSHAPES] = /* forme des pads */ +{ + CIRCLE, OVALE, RECT, TRAPEZE +}; + + +#define NBTYPES 5 +int CodeType[NBTYPES] = +{ STANDARD, SMD, CONN, P_HOLE, MECA +}; + + +static long Std_Pad_Layers[NBTYPES] = +{ + ALL_CU_LAYERS|SILKSCREEN_LAYER_CMP|SOLDERMASK_LAYER_CU|SOLDERMASK_LAYER_CMP, + CMP_LAYER|SOLDERPASTE_LAYER_CMP|SOLDERMASK_LAYER_CMP, + CMP_LAYER|SOLDERMASK_LAYER_CMP, + ALL_CU_LAYERS|SILKSCREEN_LAYER_CU|SILKSCREEN_LAYER_CMP| + SOLDERMASK_LAYER_CU|SOLDERMASK_LAYER_CMP, + ALL_CU_LAYERS|SILKSCREEN_LAYER_CU|SILKSCREEN_LAYER_CMP| + SOLDERMASK_LAYER_CU|SOLDERMASK_LAYER_CMP +}; + + + + /************************************/ + /* class WinEDA_PadPropertiesFrame */ + /************************************/ + +#include "dialog_pad_edit.cpp" + + +/*************************************************************/ +void WinEDA_BasePcbFrame::InstallPadOptionsFrame(D_PAD * Pad, + wxDC * DC, const wxPoint & pos) +/*************************************************************/ +{ + WinEDA_PadPropertiesFrame * frame = new WinEDA_PadPropertiesFrame(this, + Pad, DC); + frame->ShowModal(); frame->Destroy(); +} + +/********************************************************/ +void WinEDA_PadPropertiesFrame::SetOthersControls(void) +/********************************************************/ +{ +int tmp; + + m_PadNumCtrl->SetValue(g_Current_PadName); + m_PadNetNameCtrl->SetValue(Current_PadNetName); + + m_PadPositionCtrl = new WinEDA_PositionCtrl(this, _("Pad Position"), + CurrentPad ? CurrentPad->m_Pos : g_Pad_Master.m_Pos, + g_UnitMetric, m_PadPositionBoxSizer, m_Parent->m_InternalUnits); + + m_PadSizeCtrl = new WinEDA_SizeCtrl(this, _("Pad Size"), + CurrentPad ? CurrentPad->m_Size : g_Pad_Master.m_Size, + g_UnitMetric, m_PadPositionBoxSizer, m_Parent->m_InternalUnits); + + m_PadDeltaSizeCtrl = new WinEDA_SizeCtrl(this, _("Delta"), + CurrentPad ? CurrentPad->m_DeltaSize : g_Pad_Master.m_DeltaSize, + g_UnitMetric, m_PadPositionBoxSizer, m_Parent->m_InternalUnits); + + m_PadOffsetCtrl = new WinEDA_SizeCtrl(this, _("Offset"), + CurrentPad ? CurrentPad->m_Offset : g_Pad_Master.m_Offset, + g_UnitMetric, m_PadPositionBoxSizer, m_Parent->m_InternalUnits); + + /* In second column */ + + m_PadDrillCtrl = new WinEDA_SizeCtrl(this, _("Pad Drill"), + CurrentPad ? CurrentPad->m_Drill : g_Pad_Master.m_Drill, + g_UnitMetric, m_DrillShapeBoxSizer, m_Parent->m_InternalUnits ); + + if ( CurrentPad ) + { + tmp = CurrentPad->m_Orient - m_Module->m_Orient; + } + else tmp = g_Pad_Master.m_Orient; + m_DrillShapeBoxSizer->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + m_PadOrientCtrl = new WinEDA_ValueCtrl(this, _("Pad Orient (0.1 deg)"), + tmp, 2, m_DrillShapeBoxSizer, 1); + + + // Pad Orient + switch ( tmp ) + { + case 0: + m_PadOrient->SetSelection(0); + m_PadOrientCtrl->Enable(FALSE); + break; + + case -2700: + case 900: + m_PadOrient->SetSelection(1); + m_PadOrientCtrl->Enable(FALSE); + break; + + case -900: + case 2700: + m_PadOrient->SetSelection(2); + m_PadOrientCtrl->Enable(FALSE); + break; + + case 1800: + case -1800: + m_PadOrient->SetSelection(3); + m_PadOrientCtrl->Enable(FALSE); + break; + + default: + m_PadOrient->SetSelection(4); + break; + } + + tmp = CurrentPad ? CurrentPad->m_PadShape : g_Pad_Master.m_PadShape; + switch ( tmp ) + { + case CIRCLE: + m_PadDeltaSizeCtrl->Enable(FALSE, FALSE); + m_PadSizeCtrl->Enable(TRUE, FALSE); + m_PadShape->SetSelection(0); + break; + + case OVALE: + m_PadDeltaSizeCtrl->Enable(FALSE, FALSE); + m_PadSizeCtrl->Enable(TRUE, TRUE); + m_PadShape->SetSelection(1); + break; + + case RECT: + m_PadDeltaSizeCtrl->Enable(FALSE, FALSE); + m_PadSizeCtrl->Enable(TRUE, TRUE); + m_PadShape->SetSelection(2); + break; + + case TRAPEZE: + m_PadDeltaSizeCtrl->Enable(TRUE, TRUE); + m_PadSizeCtrl->Enable(TRUE, TRUE); + m_PadShape->SetSelection(3); + break; + + case SPECIAL_PAD: + m_PadDeltaSizeCtrl->Enable(FALSE, FALSE); + m_PadSizeCtrl->Enable(TRUE, TRUE); + m_PadShape->SetSelection(4); + break; + } + + // Selection du type + tmp = CurrentPad ? CurrentPad->m_Attribut : g_Pad_Master.m_Attribut; + m_PadType->SetSelection( 0 ); + for ( int ii = 0; ii < NBTYPES; ii++ ) + { + if ( CodeType[ii] == tmp ) + { + m_PadType->SetSelection( ii ); break ; + } + } + + tmp = CurrentPad ? CurrentPad->m_DrillShape : g_Pad_Master.m_DrillShape; + switch ( tmp ) + { + case CIRCLE: + m_DrillShapeCtrl->SetSelection(0); + m_PadDrillCtrl->Enable(TRUE,FALSE); + break; + + case OVALE: + m_DrillShapeCtrl->SetSelection(1); + m_PadDrillCtrl->Enable(TRUE, TRUE); + break; + } + // Selection des couches cuivre : + if ( CurrentPad ) SetPadLayersList(CurrentPad->m_Masque_Layer); + else PadTypeSelected(); +} + + +/*******************************************************************/ +void WinEDA_PadPropertiesFrame::PadOrientEvent(wxCommandEvent& event) +/********************************************************************/ +{ + switch ( m_PadOrient->GetSelection() ) + { + case 0: + m_PadOrientCtrl->SetValue(0); + m_PadOrientCtrl->Enable(FALSE); + break; + + case 1: + m_PadOrientCtrl->SetValue(900); + m_PadOrientCtrl->Enable(FALSE); + break; + + case 2: + m_PadOrientCtrl->SetValue(2700); + m_PadOrientCtrl->Enable(FALSE); + break; + + case 3: + m_PadOrientCtrl->SetValue(1800); + m_PadOrientCtrl->Enable(FALSE); + break; + + default: + m_PadOrientCtrl->Enable(TRUE); + break; + } + +} + +/**************************************************************************/ +void WinEDA_PadPropertiesFrame::PadTypeSelectedEvent(wxCommandEvent& event) +/**************************************************************************/ +/* calcule un layer_mask type selon la selection du type du pad +*/ +{ + PadTypeSelected(); +} + +void WinEDA_PadPropertiesFrame::PadTypeSelected(void) +{ +long layer_mask; +int ii; + + ii = m_PadType->GetSelection(); + if ( (ii < 0) || ( ii >= NBTYPES) ) ii = 0; + + layer_mask = Std_Pad_Layers[ii]; + SetPadLayersList(layer_mask); +} + +/****************************************************************/ +void WinEDA_PadPropertiesFrame::SetPadLayersList(long layer_mask) +/****************************************************************/ +/* Met a jour l'etat des CheckBoxes de la liste des layers actives, +données bit a bit dans layer_mask +*/ +{ + if( layer_mask & CUIVRE_LAYER ) m_PadLayerCu->SetValue(TRUE); + else m_PadLayerCu->SetValue(FALSE); + + if( layer_mask & CMP_LAYER ) m_PadLayerCmp->SetValue(TRUE); + else m_PadLayerCmp->SetValue(FALSE); + + if( layer_mask & ADHESIVE_LAYER_CMP ) m_PadLayerAdhCmp->SetValue(TRUE); + else m_PadLayerAdhCmp->SetValue(FALSE); + + if( layer_mask & ADHESIVE_LAYER_CU ) m_PadLayerAdhCu->SetValue(TRUE); + else m_PadLayerAdhCu->SetValue(FALSE); + + if( layer_mask & SOLDERPASTE_LAYER_CMP ) m_PadLayerPateCmp->SetValue(TRUE); + else m_PadLayerPateCmp->SetValue(FALSE); + + if( layer_mask & SOLDERPASTE_LAYER_CU ) m_PadLayerPateCu->SetValue(TRUE); + else m_PadLayerPateCu->SetValue(FALSE); + + if( layer_mask & SILKSCREEN_LAYER_CMP ) m_PadLayerSilkCmp->SetValue(TRUE); + else m_PadLayerSilkCmp->SetValue(FALSE); + + if( layer_mask & SILKSCREEN_LAYER_CU ) m_PadLayerSilkCu->SetValue(TRUE); + else m_PadLayerSilkCu->SetValue(FALSE); + + if( layer_mask & SOLDERMASK_LAYER_CMP ) m_PadLayerMaskCmp->SetValue(TRUE); + else m_PadLayerMaskCmp->SetValue(FALSE); + + if( layer_mask & SOLDERMASK_LAYER_CU ) m_PadLayerMaskCu->SetValue(TRUE); + else m_PadLayerMaskCu->SetValue(FALSE); + + if( layer_mask & ECO1_LAYER ) m_PadLayerECO1->SetValue(TRUE); + else m_PadLayerECO1->SetValue(FALSE); + + if( layer_mask & ECO2_LAYER ) m_PadLayerECO2->SetValue(TRUE); + else m_PadLayerECO2->SetValue(FALSE); + + if( layer_mask & DRAW_LAYER ) m_PadLayerDraft->SetValue(TRUE); + else m_PadLayerDraft->SetValue(FALSE); +} + + +/*************************************************************************/ +void WinEDA_PadPropertiesFrame::PadPropertiesAccept(wxCommandEvent& event) +/*************************************************************************/ +/* Met a jour les differents parametres pour le composant en cours d'édition +*/ +{ +long PadLayerMask; +bool error = FALSE; + + if ( m_DC ) m_Parent->DrawPanel->CursorOff(m_DC); + + g_Pad_Master.m_Attribut = CodeType[m_PadType->GetSelection()]; + g_Pad_Master.m_PadShape = CodeShape[m_PadShape->GetSelection()]; + g_Pad_Master.m_Pos = m_PadPositionCtrl->GetValue(); + g_Pad_Master.m_Pos0 = g_Pad_Master.m_Pos; + g_Pad_Master.m_Size = m_PadSizeCtrl->GetValue(); + if ( g_Pad_Master.m_PadShape == CIRCLE ) + g_Pad_Master.m_Size.y = g_Pad_Master.m_Size.x; + g_Pad_Master.m_DeltaSize = m_PadDeltaSizeCtrl->GetValue(); + g_Pad_Master.m_Offset = m_PadOffsetCtrl->GetValue(); + g_Pad_Master.m_Drill = m_PadDrillCtrl->GetValue(); + if( m_DrillShapeCtrl->GetSelection() == 0 ) + { + g_Pad_Master.m_DrillShape = CIRCLE; + g_Pad_Master.m_Drill.y = g_Pad_Master.m_Drill.x; + } + else g_Pad_Master.m_DrillShape = OVALE; + g_Pad_Master.m_Orient = m_PadOrientCtrl->GetValue(); + g_Current_PadName = m_PadNumCtrl->GetValue().Left(4); + Current_PadNetName = m_PadNetNameCtrl->GetValue(); + + /* Test for incorrect values */ + if ( (g_Pad_Master.m_Size.x < g_Pad_Master.m_Drill.x) || + (g_Pad_Master.m_Size.y < g_Pad_Master.m_Drill.y) ) + { + error = TRUE; + DisplayError(this, _("Incorrect value for pad drill: pad drill bigger than pad size") ); + } + if ( (g_Pad_Master.m_Size.x/2 <= ABS(g_Pad_Master.m_Offset.x)) || + (g_Pad_Master.m_Size.y/2 <= ABS(g_Pad_Master.m_Offset.y)) ) + { + error = TRUE; + DisplayError(this, _("Incorrect value for pad offset") ); + } + + if ( error ) + { + if ( m_DC ) m_Parent->DrawPanel->CursorOn(m_DC); + return; + } + + PadLayerMask = 0; + if( m_PadLayerCu->GetValue() ) PadLayerMask |= CUIVRE_LAYER; + if( m_PadLayerCmp->GetValue() ) PadLayerMask |= CMP_LAYER; + if ( (PadLayerMask & (CUIVRE_LAYER|CMP_LAYER)) == (CUIVRE_LAYER|CMP_LAYER) ) + PadLayerMask |= ALL_CU_LAYERS; + if( m_PadLayerAdhCmp->GetValue() ) PadLayerMask |= ADHESIVE_LAYER_CMP; + if( m_PadLayerAdhCu->GetValue() ) PadLayerMask |= ADHESIVE_LAYER_CU; + if( m_PadLayerPateCmp->GetValue() ) PadLayerMask |= SOLDERPASTE_LAYER_CMP; + if( m_PadLayerPateCu->GetValue() ) PadLayerMask |= SOLDERPASTE_LAYER_CU; + if( m_PadLayerSilkCmp->GetValue() ) PadLayerMask |= SILKSCREEN_LAYER_CMP; + if( m_PadLayerSilkCu->GetValue() ) PadLayerMask |= SILKSCREEN_LAYER_CU; + if( m_PadLayerMaskCmp->GetValue() ) PadLayerMask |= SOLDERMASK_LAYER_CMP; + if( m_PadLayerMaskCu->GetValue() ) PadLayerMask |= SOLDERMASK_LAYER_CU; + if( m_PadLayerECO1->GetValue() ) PadLayerMask |= ECO1_LAYER; + if( m_PadLayerECO2->GetValue() ) PadLayerMask |= ECO2_LAYER; + if( m_PadLayerDraft->GetValue() ) PadLayerMask |= DRAW_LAYER; + + g_Pad_Master.m_Masque_Layer = PadLayerMask; + + if ( CurrentPad ) // Set Pad Name & Num + { + m_Parent->SaveCopyInUndoList(m_Parent->m_Pcb->m_Modules); + MODULE * Module; + Module = (MODULE*) CurrentPad->m_Parent; + Module->m_LastEdit_Time = time(NULL); + + if ( m_DC ) CurrentPad->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0), GR_XOR); + CurrentPad->m_PadShape = g_Pad_Master.m_PadShape; + CurrentPad->m_Attribut = g_Pad_Master.m_Attribut; + CurrentPad->m_Pos = g_Pad_Master.m_Pos; + /* compute the pos 0 value, i.e. pad position for module orient = 0 i.e. + refer to module origin (module position) */ + CurrentPad->m_Pos0 = CurrentPad->m_Pos; + CurrentPad->m_Pos0.x -= Module->m_Pos.x; + CurrentPad->m_Pos0.y -= Module->m_Pos.y; + CurrentPad->m_Orient = g_Pad_Master.m_Orient + Module->m_Orient; + RotatePoint( &CurrentPad->m_Pos0.x, &CurrentPad->m_Pos0.y, - Module->m_Orient ); + + CurrentPad->m_Size = g_Pad_Master.m_Size; + CurrentPad->m_DeltaSize = g_Pad_Master.m_DeltaSize; + CurrentPad->m_Drill = g_Pad_Master.m_Drill; + CurrentPad->m_DrillShape = g_Pad_Master.m_DrillShape; + CurrentPad->m_Offset = g_Pad_Master.m_Offset; + CurrentPad->m_Masque_Layer = g_Pad_Master.m_Masque_Layer; + CurrentPad->SetPadName(g_Current_PadName); + CurrentPad->m_Netname = Current_PadNetName; + if ( Current_PadNetName.IsEmpty() ) CurrentPad->m_NetCode = 0; + + switch ( CurrentPad->m_PadShape ) + { + case CIRCLE: + CurrentPad->m_DeltaSize = wxSize(0,0); + CurrentPad->m_Size.y = CurrentPad->m_Size.x; + break; + + case RECT: + CurrentPad->m_DeltaSize = wxSize(0,0); + break; + + case OVALE: + CurrentPad->m_DeltaSize = wxSize(0,0); + break; + + case TRAPEZE: + break; + + case SPECIAL_PAD: + break; + } + + switch ( CurrentPad->m_Attribut ) + { + case STANDARD: + break; + + case CONN: + case SMD: + CurrentPad->m_Offset = wxSize(0,0); + CurrentPad->m_Drill = wxSize(0,0); + break; + + case P_HOLE: + case MECA: + break; + } + + CurrentPad->ComputeRayon(); + + Module->Set_Rectangle_Encadrement(); + CurrentPad->Display_Infos(m_Parent); + if ( m_DC ) CurrentPad->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0), GR_OR); + m_Parent->GetScreen()->SetModify(); + } + + Close(); + + if ( m_DC ) m_Parent->DrawPanel->CursorOn(m_DC); +} + diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp new file mode 100644 index 0000000000..33038bd616 --- /dev/null +++ b/pcbnew/editrack-part2.cpp @@ -0,0 +1,384 @@ + /*******************************/ + /* Edition des pistes */ + /* Routines de trace de pistes */ + /*******************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "protos.h" + + +/* Routines Locales */ + +/* variables locales */ + +/***********************************************/ +void WinEDA_PcbFrame::DisplayTrackSettings(void) +/***********************************************/ +/* Display the current track width and via diameter +*/ +{ +wxString msg; +wxString buftrc, bufvia; + + valeur_param(g_DesignSettings.m_CurrentTrackWidth, buftrc); + valeur_param(g_DesignSettings.m_CurrentViaSize, bufvia); + msg.Printf( _("Track Width: %s Vias Size : %s"), + buftrc.GetData(), bufvia.GetData()); + Affiche_Message( msg); + m_SelTrackWidthBox_Changed = TRUE; + m_SelViaSizeBox_Changed = TRUE; +} + + +/***********************************************/ +void WinEDA_PcbFrame::Ratsnest_On_Off(wxDC * DC) +/***********************************************/ + +/* Affiche ou efface le chevelu selon l'etat du bouton d'appel */ +{ +int ii; +CHEVELU * pt_chevelu; + + if((m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 ) + { + if ( g_Show_Ratsnest ) Compile_Ratsnest( DC, TRUE ); + return; + } + + DrawGeneralRatsnest(DC, 0); /* effacement eventuel du chevelu affiche */ + + pt_chevelu = m_Pcb->m_Ratsnest; + if ( pt_chevelu == NULL ) return; + + if(g_Show_Ratsnest) + { + for( ii = m_Pcb->GetNumRatsnests(); ii > 0 ; pt_chevelu++, ii--) + { + pt_chevelu->status |= CH_VISIBLE; + } + DrawGeneralRatsnest(DC, 0); + } + + else + { + for( ii = m_Pcb->GetNumRatsnests(); ii > 0; pt_chevelu++, ii--) + { + pt_chevelu->status &= ~CH_VISIBLE; + } + } +} + + +/*************************************************************************/ +void WinEDA_PcbFrame::ExChange_Track_Layer(TRACK *pt_segm, wxDC * DC) +/*************************************************************************/ +/* + change de couche la piste pointee par la souris : + la piste doit etre sur une des couches de travail, + elle est mise sur l'autre couche de travail, si cela est possible + (ou si DRC = Off ). +*/ +{ +int ii; +TRACK *pt_track; +int l1, l2 , nb_segm; + + if ( (pt_segm == NULL ) || ( pt_segm->m_StructType == TYPEZONE ) ) + { + return; + } + + l1 = Route_Layer_TOP; l2 = Route_Layer_BOTTOM; + + pt_track = Marque_Une_Piste(this, DC, pt_segm, &nb_segm, GR_XOR); + + /* effacement du flag BUSY et sauvegarde en membre .param de la couche + initiale */ + ii = nb_segm; pt_segm = pt_track; + for (; ii > 0; ii -- , pt_segm = (TRACK*)pt_segm->Pnext) + { + pt_segm->SetState(BUSY,OFF); + pt_segm->m_Param = pt_segm->m_Layer; /* pour sauvegarde */ + } + + ii = 0; pt_segm = pt_track; + for ( ; ii < nb_segm; ii++, pt_segm = (TRACK*) pt_segm->Pnext ) + { + if( pt_segm->m_StructType == TYPEVIA) continue; + + /* inversion des couches */ + if( pt_segm->m_Layer == l1 ) pt_segm->m_Layer = l2 ; + else if(pt_segm->m_Layer == l2 ) pt_segm->m_Layer = l1 ; + + if( (Drc_On) && ( Drc(this, DC,pt_segm,m_Pcb->m_Track,1) == BAD_DRC ) ) + { /* Annulation du changement */ + ii = 0; pt_segm = pt_track; + for ( ; ii < nb_segm; ii++, pt_segm = (TRACK*) pt_segm->Pnext ) + { + pt_segm->m_Layer = pt_segm->m_Param; + } + Trace_Une_Piste(DrawPanel, DC, pt_track, nb_segm, GR_OR); + DisplayError(this, _("Drc error, cancelled"), 10); + return; + } + } + Trace_Une_Piste(DrawPanel, DC, pt_track, nb_segm, GR_OR | GR_SURBRILL); + /* controle des extremites de segments: sont-ils sur un pad */ + ii = 0; pt_segm = pt_track; + for(; ii < nb_segm; pt_segm = (TRACK*)pt_segm->Pnext, ii++) + { + pt_segm->start = Locate_Pad_Connecte(m_Pcb, pt_segm, START); + pt_segm->end = Locate_Pad_Connecte(m_Pcb, pt_segm, END); + } + test_1_net_connexion(DC, pt_track->m_NetCode ); + Affiche_Infos_Piste(this, pt_track) ; + GetScreen()->SetModify(); +} + +/****************************************************************/ +void WinEDA_PcbFrame::Other_Layer_Route(TRACK * track, wxDC * DC) +/****************************************************************/ +/* + Change de couche active pour le routage. + Si une piste est en cours de trace : placement d'une Via +*/ +{ +TRACK * pt_segm; +SEGVIA * Via; +int ii; +int itmp; + + if(track == NULL) + { + if(GetScreen()->m_Active_Layer != GetScreen()->m_Route_Layer_TOP) + GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_TOP; + else GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_BOTTOM ; + Affiche_Status_Box(); + SetToolbars(); + return; + } + + /* Les vias ne doivent pas etre inutilement empilees: */ + if( Locate_Via(m_Pcb, g_CurrentTrackSegment->m_End, g_CurrentTrackSegment->m_Layer)) + return; + pt_segm = g_FirstTrackSegment; + for ( ii = 0; ii < g_TrackSegmentCount-1 ; ii++, pt_segm = (TRACK*)pt_segm->Pnext) + { + if( (pt_segm->m_StructType == TYPEVIA) && + (g_CurrentTrackSegment->m_End == pt_segm->m_Start) ) + return; + } + /* Test si segment possible a placer */ + if ( Drc_On ) + if ( Drc(this, DC,g_CurrentTrackSegment,m_Pcb->m_Track,1) == BAD_DRC ) + return ; + + /* save etat actuel pour regeneration si via impossible a placer */ + itmp = g_TrackSegmentCount; + Begin_Route(g_CurrentTrackSegment, DC); + + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + + Via = new SEGVIA(m_Pcb); + Via->m_Flags = IS_NEW; + Via->m_Width = g_DesignSettings.m_CurrentViaSize; + Via->m_Shape = g_DesignSettings.m_CurrentViaType ; + Via->m_NetCode = g_HightLigth_NetCode ; + Via->m_Start = Via->m_End = g_CurrentTrackSegment->m_End; + + Via->m_Layer = GetScreen()->m_Active_Layer; // Provisoirement + + if( GetScreen()->m_Active_Layer != GetScreen()->m_Route_Layer_TOP) + GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_TOP ; + else GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_BOTTOM ; + + if ( (Via->m_Shape & 15) == VIA_ENTERREE ) + { + Via->m_Layer |= GetScreen()->m_Active_Layer << 4; + } + else if ( (Via->m_Shape & 15) == VIA_BORGNE ) + { // A revoir! ( la via devrait deboucher sur 1 cote ) + Via->m_Layer |= GetScreen()->m_Active_Layer << 4; + } + else Via->m_Layer = 0x0F; + + if ( Drc_On &&( Drc(this, DC,Via,m_Pcb->m_Track,1 ) == BAD_DRC ) ) + { /* Via impossible a placer ici */ + delete Via; + GetScreen()->m_Active_Layer = g_CurrentTrackSegment->m_Layer ; + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + return; + } + + /* la via est OK et est inseree apres le segment courant */ + Via->Pback = g_CurrentTrackSegment; + g_CurrentTrackSegment->Pnext = Via; + g_TrackSegmentCount++; + g_CurrentTrackSegment = new TRACK(*g_CurrentTrackSegment); + g_CurrentTrackSegment->m_Layer = GetScreen()->m_Active_Layer; + g_CurrentTrackSegment->m_Start = g_CurrentTrackSegment->m_End = Via->m_Start; + g_TrackSegmentCount++; + g_CurrentTrackSegment->Pback = Via; + Via->Pnext = g_CurrentTrackSegment; + if ( g_TwoSegmentTrackBuild ) + { // Create a second segment (we must have 2 track segments to adjust) + TRACK * track = g_CurrentTrackSegment; + g_CurrentTrackSegment = new TRACK(*track); + g_TrackSegmentCount++; + g_CurrentTrackSegment->Pback = track; + track->Pnext = g_CurrentTrackSegment; + } + + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + Affiche_Infos_Piste(this, Via); + + Affiche_Status_Box(); + SetToolbars(); +} + + +/*************************************************/ +void WinEDA_PcbFrame::Affiche_Status_Net(wxDC * DC) +/*************************************************/ +/* Affiche: + le status du net en haut d'ecran du segment pointe par la souris + ou le status PCB en bas d'ecran si pas de segment pointe +*/ +{ +TRACK * pt_segm; +int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; + + pt_segm = Locate_Pistes(m_Pcb->m_Track, masquelayer, CURSEUR_OFF_GRILLE); + if(pt_segm == NULL) Affiche_Infos_Status_Pcb(this); + else test_1_net_connexion(DC, pt_segm->m_NetCode); +} + + +/**********************************************************************/ +void WinEDA_PcbFrame::Show_1_Ratsnest(EDA_BaseStruct * item, wxDC * DC) +/**********************************************************************/ +/* Affiche le ratsnest relatif + au net du pad pointe par la souris + ou au module localise par la souris + Efface le chevelu affiche si aucun module ou pad n'est selectionne +*/ +{ +int ii; +CHEVELU * pt_chevelu; +D_PAD * pt_pad = NULL; +MODULE * Module = NULL; + + if (g_Show_Ratsnest) return; // Deja Affich� + + if((m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 ) + { + Compile_Ratsnest( DC, TRUE ); + } + + if ( item && (item->m_StructType == TYPEPAD) ) + { + pt_pad = (D_PAD*)item; + Module = (MODULE *) pt_pad->m_Parent; + } + + if ( pt_pad ) /* Affichage du chevelu du net correspondant */ + { + pt_pad->Display_Infos(this); + pt_chevelu = (CHEVELU*) m_Pcb->m_Ratsnest; + for( ii = m_Pcb->GetNumRatsnests(); ii > 0; pt_chevelu++, ii--) + { + if( pt_chevelu->m_NetCode == pt_pad->m_NetCode) + { + if( (pt_chevelu->status & CH_VISIBLE) != 0 ) continue; + pt_chevelu->status |= CH_VISIBLE; + if( (pt_chevelu->status & CH_ACTIF) == 0 ) continue; + + GRSetDrawMode(DC, GR_XOR); + GRLine( &DrawPanel->m_ClipBox, DC, pt_chevelu->pad_start->m_Pos.x, + pt_chevelu->pad_start->m_Pos.y, + pt_chevelu->pad_end->m_Pos.x, + pt_chevelu->pad_end->m_Pos.y, + g_DesignSettings.m_RatsnestColor); + } + } + } + else + { + if ( item && (item->m_StructType == TYPEMODULE) ) + { + Module = (MODULE*)item; + } + + if( Module) + { + Module->Display_Infos(this); + pt_pad = Module->m_Pads; + for( ; pt_pad != NULL; pt_pad = (D_PAD*)pt_pad->Pnext) + { + pt_chevelu = (CHEVELU*) m_Pcb->m_Ratsnest; + for( ii = m_Pcb->GetNumRatsnests(); ii > 0; pt_chevelu++, ii--) + { + if( (pt_chevelu->pad_start == pt_pad) || + (pt_chevelu->pad_end == pt_pad) ) + { + if( pt_chevelu->status & CH_VISIBLE ) continue; + pt_chevelu->status |= CH_VISIBLE; + if( (pt_chevelu->status & CH_ACTIF) == 0 ) continue; + + GRSetDrawMode(DC, GR_XOR); + GRLine(&DrawPanel->m_ClipBox, DC, pt_chevelu->pad_start->m_Pos.x, + pt_chevelu->pad_start->m_Pos.y, + pt_chevelu->pad_end->m_Pos.x, + pt_chevelu->pad_end->m_Pos.y, + g_DesignSettings.m_RatsnestColor); + } + } + } + pt_pad = NULL; + } + } + + /* Effacement complet des selections + si aucun pad ou module n'a ete localise */ + if( (pt_pad == NULL) && (Module == NULL) ) + { + MsgPanel->EraseMsgBox(); + DrawGeneralRatsnest(DC); + pt_chevelu = (CHEVELU*) m_Pcb->m_Ratsnest; + for( ii = m_Pcb->GetNumRatsnests();(ii > 0) && pt_chevelu; pt_chevelu++, ii--) + pt_chevelu->status &= ~CH_VISIBLE; + } +} + + +/*****************************************************/ +void WinEDA_PcbFrame::Affiche_PadsNoConnect(wxDC * DC) +/*****************************************************/ +/* Met en surbrillance les pads non encore connectes ( correspondants aux +chevelus actifs +*/ +{ +int ii; +CHEVELU * pt_chevelu; +D_PAD * pt_pad; + + pt_chevelu = (CHEVELU*)m_Pcb->m_Ratsnest; + for( ii = m_Pcb->GetNumRatsnests();ii > 0; pt_chevelu++, ii--) + { + if( (pt_chevelu->status & CH_ACTIF) == 0 ) continue; + pt_pad = pt_chevelu->pad_start; + + if (pt_pad) + pt_pad->Draw(DrawPanel,DC, wxPoint(0,0), GR_OR | GR_SURBRILL); + + pt_pad = pt_chevelu->pad_end; + if (pt_pad) + pt_pad->Draw(DrawPanel,DC, wxPoint(0,0), GR_OR | GR_SURBRILL); + } +} diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp new file mode 100644 index 0000000000..47b731dd72 --- /dev/null +++ b/pcbnew/editrack.cpp @@ -0,0 +1,744 @@ + /*******************************/ + /* Edition des pistes */ + /* Routines de trace de pistes */ + /*******************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "protos.h" + + +/* Routines Locales */ +static void Exit_Editrack(WinEDA_DrawPanel * panel, wxDC *DC); +void ShowNewTrackWhenMovingCursor(WinEDA_DrawPanel * panel, + wxDC * DC, bool erase); +static int Met_Coude_a_45(WinEDA_BasePcbFrame * frame, wxDC * DC, + TRACK * ptfinsegment); +static void ComputeBreakPoint( TRACK * track, int n ); +static TRACK * DeleteNullTrackSegments(BOARD * pcb, TRACK * track, int * segmcount); +static void EnsureEndTrackOnPad(D_PAD * Pad); + +/* variables locales */ +static int OldNetCodeSurbrillance; +static int OldEtatSurbrillance; + + +/************************************************************/ +static void Exit_Editrack(WinEDA_DrawPanel * Panel, wxDC *DC) +/************************************************************/ +/* routine d'annulation de la Commande Begin_Route si une piste est en cours + de tracage, ou de sortie de l'application EDITRACK. + */ +{ +WinEDA_PcbFrame * frame = (WinEDA_PcbFrame *) Panel->m_Parent; +TRACK * track = (TRACK * ) frame->GetScreen()->m_CurrentItem; + + if( track != NULL ) + { + /* Erase the current drawing */ + ShowNewTrackWhenMovingCursor(Panel, DC, FALSE); + if(g_HightLigt_Status) frame->Hight_Light(DC); + g_HightLigth_NetCode = OldNetCodeSurbrillance; + if(OldEtatSurbrillance) frame->Hight_Light(DC); + + frame->MsgPanel->EraseMsgBox(); + TRACK * previoustrack; + // Delete current (new) track + for( ;track != NULL; track = previoustrack) + { + previoustrack = (TRACK*) track->Pback; + delete track; + } + } + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + frame->GetScreen()->m_CurrentItem = NULL; +} + + +/*************************************************************/ +TRACK * WinEDA_PcbFrame::Begin_Route(TRACK * track, wxDC * DC) +/*************************************************************/ +/* +Routine d'initialisation d'un trace de piste et/ou de mise en place d'un +nouveau point piste + + Si pas de piste en cours de trace: + - Recherche de netname de la nouvelle piste ( pad de depart out netname + de la piste si depart sur une ancienne piste + - Met en surbrillance tout le net + - Initilise les divers pointeurs de trace + Si piste en cours: + - controle DRC + - si DRC OK : addition d'un nouveau point piste +*/ +{ +D_PAD * pt_pad = NULL; +TRACK * adr_buf = NULL, * Track; +int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; +EDA_BaseStruct * LockPoint; +wxPoint pos = GetScreen()->m_Curseur; + + DrawPanel->ManageCurseur = ShowNewTrackWhenMovingCursor; + DrawPanel->ForceCloseManageCurseur = Exit_Editrack; + + if(track == NULL ) /* debut reel du trace */ + { + /* effacement surbrillance ancienne */ + OldNetCodeSurbrillance = g_HightLigth_NetCode; + OldEtatSurbrillance = g_HightLigt_Status; + + if(g_HightLigt_Status) Hight_Light(DC); + + g_FirstTrackSegment = g_CurrentTrackSegment = new TRACK(m_Pcb); + g_CurrentTrackSegment->m_Flags = IS_NEW; + g_TrackSegmentCount = 1; + g_HightLigth_NetCode = 0; + + /* Localisation de la pastille de reference de la piste: */ + LockPoint = LocateLockPoint(m_Pcb, pos, masquelayer); + + if( LockPoint ) + { + if( LockPoint->m_StructType == TYPEPAD ) + { + pt_pad = (D_PAD *) LockPoint; + /* le debut de la piste est remis sur le centre du pad */ + pos = pt_pad->m_Pos; + g_HightLigth_NetCode = pt_pad->m_NetCode; + } + + else /* le point d'accrochage est un segment */ + { + adr_buf = (TRACK *) LockPoint; + g_HightLigth_NetCode = adr_buf->m_NetCode; + CreateLockPoint( &pos.x, &pos.y, adr_buf, NULL); + } + } + + build_ratsnest_pad(LockPoint, wxPoint(0,0), TRUE); + Hight_Light(DC); + + g_CurrentTrackSegment->m_Flags = IS_NEW; + g_CurrentTrackSegment->m_Layer = GetScreen()->m_Active_Layer; + g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth ; + g_CurrentTrackSegment->m_Start = pos; + g_CurrentTrackSegment->m_End = g_CurrentTrackSegment->m_Start; + g_CurrentTrackSegment->m_NetCode = g_HightLigth_NetCode ; + if(pt_pad) + { + g_CurrentTrackSegment->start = pt_pad ; + g_CurrentTrackSegment->SetState(BEGIN_ONPAD,ON); + } + else g_CurrentTrackSegment->start = adr_buf ; + + if ( g_TwoSegmentTrackBuild ) + { // Create 2 segments + g_CurrentTrackSegment = new TRACK(*g_CurrentTrackSegment); + g_TrackSegmentCount++; + g_CurrentTrackSegment->Pback = g_FirstTrackSegment; + g_FirstTrackSegment->Pnext = g_CurrentTrackSegment; + g_CurrentTrackSegment->start = g_FirstTrackSegment; + g_FirstTrackSegment->end = g_CurrentTrackSegment; + g_FirstTrackSegment->SetState(BEGIN_ONPAD|END_ONPAD,OFF); + } + Affiche_Infos_Piste(this, g_CurrentTrackSegment) ; + GetScreen()->m_CurrentItem = g_CurrentTrackSegment; + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + if( Drc_On && (Drc(this, DC,g_CurrentTrackSegment,m_Pcb->m_Track,1 ) == BAD_DRC) ) + { + return g_CurrentTrackSegment; + } + + } + + else /* Track in progress : segment coordinates are updated by ShowNewTrackWhenMovingCursor*/ + { + /* Tst for a D.R.C. error: */ + if ( Drc_On ) + { + if ( Drc(this, DC,g_CurrentTrackSegment,m_Pcb->m_Track,1 ) == BAD_DRC) + return NULL; + if ( g_TwoSegmentTrackBuild && // We must handle 2 segments + g_CurrentTrackSegment->Back() ) + { + if( Drc(this, DC,g_CurrentTrackSegment->Back(),m_Pcb->m_Track,1 ) == BAD_DRC ) + return NULL; + } + } + + /* Current track is Ok: current segment is kept, and a new one is created + unless the current segment is null, or 2 last are null if a 2 segments track build + */ + bool CanCreateNewSegment = TRUE; + if( ! g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() ) + CanCreateNewSegment = FALSE; + if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() && + g_CurrentTrackSegment->Back() && g_CurrentTrackSegment->Back()->IsNull() ) + CanCreateNewSegment = FALSE; + if ( CanCreateNewSegment ) + { + /* Erase old track on screen */ + ShowNewTrackWhenMovingCursor(DrawPanel, DC, FALSE); + + if( g_Raccord_45_Auto ) + { + if( Met_Coude_a_45(this, DC, g_CurrentTrackSegment) != 0 ) + g_TrackSegmentCount++; + } + Track = g_CurrentTrackSegment->Copy(); + Track->Insert(m_Pcb, g_CurrentTrackSegment); + + Track->SetState(BEGIN_ONPAD|END_ONPAD,OFF); + g_CurrentTrackSegment->end = Locate_Pad_Connecte(m_Pcb, g_CurrentTrackSegment, END); + if( g_CurrentTrackSegment->end ) + { + g_CurrentTrackSegment->SetState(END_ONPAD,ON); + Track->SetState(BEGIN_ONPAD,ON); + } + Track->start = g_CurrentTrackSegment->end; + + g_CurrentTrackSegment = Track; + g_CurrentTrackSegment->m_Flags = IS_NEW; + g_TrackSegmentCount++ ; + g_CurrentTrackSegment->m_Start = g_CurrentTrackSegment->m_End; + g_CurrentTrackSegment->m_Layer = GetScreen()->m_Active_Layer; + g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth ; + /* Show the new position */ + ShowNewTrackWhenMovingCursor(DrawPanel, DC, FALSE); + } + Affiche_Infos_Piste(this, g_CurrentTrackSegment) ; + } + + GetScreen()->m_CurrentItem = g_CurrentTrackSegment; + return g_CurrentTrackSegment; +} + + +/**************************************************************************/ +int Met_Coude_a_45(WinEDA_BasePcbFrame * frame, wxDC * DC, TRACK * pt_segm) +/***************************************************************************/ +/* rectifie un virage a 90 et le modifie par 2 coudes a 45 + n'opere que sur des segments horizontaux ou verticaux. + + entree : pointeur sur le segment qui vient d'etre trace + On suppose que le segment precedent est celui qui a ete + precedement trace + retourne: + 1 si ok + 0 si impossible +*/ +{ +TRACK * Previous; +TRACK *NewTrack; +int pas_45; +int dx0, dy0, dx1, dy1 ; + + if(g_TrackSegmentCount < 2 ) return(0) ; /* il faut au moins 2 segments */ + + Previous = (TRACK*)pt_segm->Pback; // pointe le segment precedent + + // Test s'il y a 2 segments consecutifs a raccorder + if( (pt_segm->m_StructType != TYPETRACK ) || + (Previous->m_StructType != TYPETRACK) ) + { + return(0) ; + } + + pas_45 = frame->GetScreen()->GetGrid().x / 2 ; + if( pas_45 < pt_segm->m_Width ) + pas_45 = frame->GetScreen()->GetGrid().x; + while(pas_45 < pt_segm->m_Width) pas_45 *= 2; + + // OK : tst si les segments sont a 90 degre et vertic ou horiz + dx0 = Previous->m_End.x - Previous->m_Start.x; + dy0 = Previous->m_End.y - Previous->m_Start.y; + dx1 = pt_segm->m_End.x - pt_segm->m_Start.x; + dy1 = pt_segm->m_End.y - pt_segm->m_Start.y; + // les segments doivent etre de longueur suffisante: + if(max(abs(dx0),abs(dy0)) < (pas_45*2) ) return(0); + if(max(abs(dx1),abs(dy1)) < (pas_45*2) ) return(0); + + /* creation du nouveau segment, raccordant des 2 segm: */ + NewTrack = pt_segm->Copy(); + + NewTrack->m_Start.x = Previous->m_End.x; + NewTrack->m_Start.y = Previous->m_End.y; + NewTrack->m_End.x = pt_segm->m_Start.x; + NewTrack->m_End.y = pt_segm->m_Start.y; + + if( dx0 == 0 ) // Segment precedent Vertical + { + if(dy1 != 0 ) // les 2 segments ne sont pas a 90 ; + { + delete NewTrack; + return(0); + } + + /* Calcul des coordonnees du point de raccord : + le nouveau segment raccorde le 1er segment Vertical + au 2eme segment Horizontal */ + + if(dy0 > 0 ) NewTrack->m_Start.y -= pas_45 ; + else NewTrack->m_Start.y += pas_45 ; + + if(dx1 > 0 ) NewTrack->m_End.x += pas_45 ; + else NewTrack->m_End.x -= pas_45 ; + + if ( Drc_On && (Drc(frame, DC, pt_segm, frame->m_Pcb->m_Track, 1) == BAD_DRC) ) + { + delete NewTrack; + return(0) ; + } + + Previous->m_End = NewTrack->m_Start; + pt_segm->m_Start = NewTrack->m_End; + NewTrack->Insert(frame->m_Pcb, Previous); + return(1) ; + } + + if (dy0 == 0 ) // Segment precedent Horizontal : dy0 = 0 + { + if (dx1 != 0 ) // les 2 segments ne sont pas a 90 ; + { + delete NewTrack; + return(0); + } + + // Segments a 90 + /* Modif des coordonnees du point de raccord : + un nouveau segment a ete cree, raccordant le 1er segment Horizontal + au 2eme segment Vertical */ + + if(dx0 > 0 ) NewTrack->m_Start.x -= pas_45 ; + else NewTrack->m_Start.x += pas_45 ; + + if(dy1 > 0 ) NewTrack->m_End.y += pas_45 ; + else NewTrack->m_End.y -= pas_45 ; + + if ( Drc_On && (Drc(frame, DC, NewTrack, frame->m_Pcb->m_Track, 1) == BAD_DRC) ) + { + delete NewTrack; + return(0); + } + + Previous->m_End = NewTrack->m_Start; + pt_segm->m_Start = NewTrack->m_End; + NewTrack->Insert(frame->m_Pcb, Previous); + return(1) ; + } + + return(0); +} + + +/**************************************************************/ +void WinEDA_PcbFrame::End_Route(TRACK * track, wxDC * DC) +/*************************************************************/ +/* + Routine de fin de trace d'une piste (succession de segments) +*/ +{ +TRACK * pt_track; +int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; +wxPoint pos; +EDA_BaseStruct * LockPoint; +TRACK * adr_buf; + + if( track == NULL ) return; + + if ( Drc_On && ( Drc(this, DC,g_CurrentTrackSegment,m_Pcb->m_Track,1 ) == BAD_DRC) ) + return ; + + /* Sauvegarde des coord du point terminal de la piste */ + pos = g_CurrentTrackSegment->m_End; + + if ( Begin_Route(track, DC) == NULL ) return; + + ShowNewTrackWhenMovingCursor(DrawPanel, DC, TRUE); /* mise a jour trace reel */ + ShowNewTrackWhenMovingCursor(DrawPanel, DC, FALSE); /* efface trace piste*/ + trace_ratsnest_pad(DC); /* efface trace chevelu*/ + + + // cleanup + if (g_CurrentTrackSegment->Pnext != NULL){ + delete g_CurrentTrackSegment->Pnext; + g_CurrentTrackSegment->Pnext = NULL; + } + + + /* La piste est ici non chainee a la liste des segments de piste. + Il faut la replacer dans la zone de net, + le plus pres possible du segment d'attache ( ou de fin ), car + ceci contribue a la reduction du temps de calcul */ + + /* Accrochage de la fin de la piste */ + LockPoint = LocateLockPoint(m_Pcb, pos, masquelayer); + + if ( LockPoint ) /* La fin de la piste est sur un PAD */ + { + if( LockPoint->m_StructType == TYPEPAD ) + { + EnsureEndTrackOnPad( (D_PAD *) LockPoint); + } + + else /* la fin de la piste est sur une autre piste: il faudra + peut-etre creer un point d'ancrage */ + { + adr_buf = (TRACK *) LockPoint; + g_HightLigth_NetCode = adr_buf->m_NetCode; + /* creation eventuelle d'un point d'accrochage */ + LockPoint = CreateLockPoint(&g_CurrentTrackSegment->m_End.x, &g_CurrentTrackSegment->m_End.y, + adr_buf, g_CurrentTrackSegment); + } + } + + + // Delete Null segments: + g_FirstTrackSegment = DeleteNullTrackSegments(m_Pcb, g_FirstTrackSegment, & g_TrackSegmentCount); + /* Test if no segment left. Can happend on a double click on the start point */ + if ( g_FirstTrackSegment != NULL ) + { + + /* Put new track in buffer: search the best insertion poinr */ + pt_track = g_FirstTrackSegment->GetBestInsertPoint(m_Pcb); + + /* Uut track in linked list */ + g_FirstTrackSegment->Insert(m_Pcb, pt_track); + + trace_ratsnest_pad(DC); + Trace_Une_Piste(DrawPanel, DC, g_FirstTrackSegment, g_TrackSegmentCount,GR_OR) ; + + // Reset flags: + TRACK * ptr = g_FirstTrackSegment; int ii; + for ( ii = 0; (ptr != NULL) && (ii < g_TrackSegmentCount) ; ii++ ) + { + ptr->m_Flags = 0; ptr = ptr->Next(); + } + + /* Delete the old track, if exists */ + if(g_AutoDeleteOldTrack) + { + EraseOldTrack(this, m_Pcb, DC, g_FirstTrackSegment, g_TrackSegmentCount); + } + + /* compute the new rastnest : */ + test_1_net_connexion(DC, g_FirstTrackSegment->m_NetCode ); + + GetScreen()->SetModify(); + Affiche_Infos_Status_Pcb(this); + } + /* Finish the work, clear used variables */ + g_FirstTrackSegment = NULL; + + if(g_HightLigt_Status) Hight_Light(DC); + + g_HightLigth_NetCode = OldNetCodeSurbrillance; + if(OldEtatSurbrillance) Hight_Light(DC); + + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->m_CurrentItem = NULL; +} + + +/****************************************************************************/ +void ShowNewTrackWhenMovingCursor(WinEDA_DrawPanel * panel,wxDC * DC, bool erase) +/****************************************************************************/ +/* redessin du contour de la piste lors des deplacements de la souris + Cette routine est utilisee comme .ManageCurseur() + si ShowIsolDuringCreateTrack_Item.State == RUN la marge d'isolation + est aussi affichee +*/ +{ +int IsolTmp, Track_fill_copy; +PCB_SCREEN * screen = (PCB_SCREEN *) panel->GetScreen(); + + Track_fill_copy = DisplayOpt.DisplayPcbTrackFill; + DisplayOpt.DisplayPcbTrackFill = SKETCH; + IsolTmp = DisplayOpt.DisplayTrackIsol; + + if ( g_ShowIsolDuringCreateTrack) + DisplayOpt.DisplayTrackIsol = TRUE; + + /* efface ancienne position si elle a ete deja dessinee */ + if( erase ) + { + Trace_Une_Piste(panel, DC, g_FirstTrackSegment,g_TrackSegmentCount,GR_XOR) ; + ((WinEDA_BasePcbFrame*)(panel->m_Parent))->trace_ratsnest_pad( DC); + } + + /* dessin de la nouvelle piste : mise a jour du point d'arrivee */ + g_CurrentTrackSegment->m_Layer = screen->m_Active_Layer; + g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; + + if (Track_45_Only) + { + if ( g_TwoSegmentTrackBuild ) + ComputeBreakPoint(g_CurrentTrackSegment, g_TrackSegmentCount); + else + { + /* Calcul de l'extremite de la piste pour orientations permises: + horiz,vertical ou 45 degre */ + Calcule_Coord_Extremite_45(g_CurrentTrackSegment->m_Start.x,g_CurrentTrackSegment->m_Start.y, + &g_CurrentTrackSegment->m_End.x, &g_CurrentTrackSegment->m_End.y); + + } + } + + else /* ici l'angle d'inclinaison est quelconque */ + { + g_CurrentTrackSegment->m_End = screen->m_Curseur; + } + + Trace_Une_Piste(panel, DC, g_FirstTrackSegment,g_TrackSegmentCount,GR_XOR) ; + + DisplayOpt.DisplayTrackIsol = IsolTmp; + DisplayOpt.DisplayPcbTrackFill = Track_fill_copy ; + + ((WinEDA_BasePcbFrame*)(panel->m_Parent))-> + build_ratsnest_pad(NULL, g_CurrentTrackSegment->m_End, FALSE); + + ((WinEDA_BasePcbFrame*)(panel->m_Parent))->trace_ratsnest_pad(DC); +} + + +/*****************************************************************/ +void Calcule_Coord_Extremite_45(int ox, int oy, int* fx, int* fy ) +/*****************************************************************/ +/* determine les parametres .fx et .fy du segment pointe par pt_segm + pour avoir un segment oriente a 0, 90 ou 45 degres, selon position + du oint d'origine et de la souris +*/ +{ +int deltax, deltay, angle; + + deltax = ActiveScreen->m_Curseur.x - ox ; + deltay = ActiveScreen->m_Curseur.y - oy ; + /* calcul de l'angle preferentiel : 0, 45 , 90 degre */ + deltax = abs(deltax) ; deltay = abs(deltay) ; angle = 45 ; + if( deltax >= deltay ) + { + if ( deltax == 0 ) angle = 0 ; + else if( ((deltay << 6 )/ deltax ) < 26 ) angle = 0 ; + } + else + { + angle = 45 ; + if (deltay == 0 ) angle = 90 ; + else if( ((deltax << 6 )/ deltay ) < 26 ) angle = 90 ; + } + + switch ( angle ) + { + case 0 : + *fx = ActiveScreen->m_Curseur.x; + *fy = oy ; + break ; + + case 45 : + deltax = min(deltax,deltay) ; deltay = deltax ; + /* recalcul des signes de deltax et deltay */ + if( (ActiveScreen->m_Curseur.x - ox) < 0 ) deltax = -deltax; + if( (ActiveScreen->m_Curseur.y - oy) < 0 ) deltay = -deltay; + *fx = ox + deltax ; + *fy = oy + deltay ; + break ; + + case 90 : + *fx = ox ; + *fy = ActiveScreen->m_Curseur.y; + break ; + } +} + + +/********************************************************/ +void ComputeBreakPoint( TRACK * track, int SegmentCount ) +/********************************************************/ +/** + * Compute new track angle based on previous track. + */ +{ + int iDx = 0; + int iDy = 0; + int iAngle = 0; + + if ( SegmentCount <= 0 ) return; + if ( track == NULL ) return; + + TRACK * NewTrack = track; + track = (TRACK*)track->Pback; + SegmentCount--; + if ( track ) + { + iDx = ActiveScreen->m_Curseur.x - track->m_Start.x; + iDy = ActiveScreen->m_Curseur.y - track->m_Start.y; + + iDx = abs(iDx); + iDy = abs(iDy); + } + + TRACK * LastTrack = track ? (TRACK*)track->Pback : NULL; + if ( LastTrack ) { + if ( (LastTrack->m_End.x == LastTrack->m_Start.x) || + (LastTrack->m_End.y == LastTrack->m_Start.y) ){ + iAngle = 45; + } + } + + if (iAngle == 0){ + if (iDx >= iDy) iAngle = 0; + else iAngle = 90; + + } + + if ( track == NULL ) iAngle = -1; + switch ( iAngle ) + { + case -1: + break; + + case 0 : + if ( (ActiveScreen->m_Curseur.x - track->m_Start.x) < 0 ) + track->m_End.x = ActiveScreen->m_Curseur.x + iDy; + else + track->m_End.x = ActiveScreen->m_Curseur.x - iDy; + track->m_End.y = track->m_Start.y; + break ; + + case 45 : + iDx = min(iDx,iDy); + iDy = iDx ; + /* recalcul des signes de deltax et deltay */ + if( (ActiveScreen->m_Curseur.x - track->m_Start.x) < 0 ) + iDx = -iDx; + if( (ActiveScreen->m_Curseur.y - track->m_Start.y) < 0 ) + iDy = -iDy; + track->m_End.x = track->m_Start.x + iDx; + track->m_End.y = track->m_Start.y + iDy; + break ; + + case 90 : + if ( (ActiveScreen->m_Curseur.y - track->m_Start.y) < 0 ) + track->m_End.y = ActiveScreen->m_Curseur.y + iDx; + else + track->m_End.y = ActiveScreen->m_Curseur.y - iDx; + track->m_End.x = track->m_Start.x; + break ; + } + + if ( track ) + { + if ( track->IsNull() ) track->m_End = ActiveScreen->m_Curseur; + NewTrack->m_Start = track->m_End; + } + NewTrack->m_End = ActiveScreen->m_Curseur; +} + + +/****************************************************************************/ +TRACK * DeleteNullTrackSegments(BOARD * pcb, TRACK * track, int * segmcount) +/****************************************************************************/ +/* Delete track segments which have len = 0; after creating a new track + return a pointer on the first segment (start of track list) +*/ +{ +TRACK * firsttrack = track; +TRACK * oldtrack; +int nn = 0; +EDA_BaseStruct * LockPoint; + + LockPoint = track->start; + while ( track != NULL ) + { + oldtrack = track; + track = track->Next(); + if ( ! oldtrack->IsNull() ) + { + nn++; + continue; + } + // NULL segment, delete it + if ( firsttrack == oldtrack ) firsttrack = track; + oldtrack->UnLink(); + delete oldtrack; + } + + if ( segmcount ) *segmcount = nn; + + if ( nn == 0 ) return NULL; // all the new track segments have been deleted + + + // we must set the pointers on connected items and the connection status + oldtrack = track = firsttrack; + firsttrack->start = NULL; + while ( track != NULL ) + { + oldtrack = track; + track = track->Next(); + oldtrack->end = track; + if ( track ) track->start = oldtrack; + oldtrack->SetStatus(0); + } + + firsttrack->start = LockPoint; + if ( LockPoint && (LockPoint->m_StructType == TYPEPAD ) ) + firsttrack->SetState(BEGIN_ONPAD,ON); + + track = firsttrack; + while ( track != NULL ) + { + TRACK * next_track = track->Next(); + LockPoint = Locate_Pad_Connecte(pcb, track, END); + if ( LockPoint ) + { + track->end = LockPoint; + track->SetState(END_ONPAD,ON); + if ( next_track ) + { + next_track->start = LockPoint; + next_track->SetState(BEGIN_ONPAD,ON); + } + } + track = next_track; + } + + return firsttrack; +} + +/************************************/ +void EnsureEndTrackOnPad(D_PAD * Pad) +/************************************/ +/* Ensure the end point of g_CurrentTrackSegment is on the pas "Pad" + if no, create a new track segment if necessary + and move current (or new) end segment on pad +*/ +{ + if( g_CurrentTrackSegment->m_End == Pad->m_Pos ) // Ok ! + { + g_CurrentTrackSegment->end = Pad; + g_CurrentTrackSegment->SetState(END_ONPAD, ON); + return; + } + + TRACK * lasttrack = g_CurrentTrackSegment; + if ( ! g_CurrentTrackSegment->IsNull() ) + { /* Must create a new segment, from track end to pad center */ + g_CurrentTrackSegment = new TRACK(*lasttrack); + g_TrackSegmentCount++; + lasttrack->Pnext = g_CurrentTrackSegment; + g_CurrentTrackSegment->Pback = lasttrack; + lasttrack->end = g_CurrentTrackSegment; + } + g_CurrentTrackSegment->m_End = Pad->m_Pos; + g_CurrentTrackSegment->SetState(END_ONPAD, OFF); + + g_CurrentTrackSegment->end = Pad; + g_CurrentTrackSegment->SetState(END_ONPAD, ON); +} diff --git a/pcbnew/editrout.cpp b/pcbnew/editrout.cpp new file mode 100644 index 0000000000..a1d3797bd6 --- /dev/null +++ b/pcbnew/editrout.cpp @@ -0,0 +1,155 @@ + /***************************************************************/ + /* Edition des pistes: Routines de modification de dimensions: */ + /* Modif de largeurs de segment, piste, net , zone et diam Via */ + /***************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "protos.h" + +/* Routines Locales */ + +/*********************************************************************/ +int WinEDA_PcbFrame::Edit_TrackSegm_Width(wxDC * DC, TRACK * pt_segm) +/*********************************************************************/ +/* Routine de modification de la largeur d'un segment ( ou via) de piste + Routine de base utilisee par les autres routines +*/ +{ +int errdrc = OK_DRC; +int old_w, consigne ; + + pt_segm->Draw(DrawPanel, DC, GR_XOR) ; // effacement a l'ecran + + /* Test DRC et mise a la largeur */ + old_w = pt_segm->m_Width; + consigne = pt_segm->m_Width = g_DesignSettings.m_CurrentTrackWidth; + if( pt_segm->m_StructType == TYPEVIA ) + { + consigne = pt_segm->m_Width = g_DesignSettings.m_CurrentViaSize; + } + + if ( old_w < consigne) /* DRC utile puisque augm de dimension */ + { + if(Drc_On) errdrc = Drc(this, DC, pt_segm, m_Pcb->m_Track,1); + if(errdrc == BAD_DRC) pt_segm->m_Width = old_w; + else GetScreen()->SetModify(); + } + + else GetScreen()->SetModify(); /* Correction systematiquement faite si reduction */ + + pt_segm->Draw(DrawPanel, DC, GR_OR) ; + return(errdrc); +} + +/*****************************************************************/ +void WinEDA_PcbFrame::Edit_Track_Width(wxDC * DC,TRACK * pt_segm) +/*****************************************************************/ +{ +int ii; +TRACK * pt_track; +int errdrc; +int nb_segm, nb_segm_modifies = 0, nb_segm_non_modifies = 0; + + if( pt_segm == NULL) return; + + pt_track = Marque_Une_Piste(this, DC, pt_segm, &nb_segm, 0); + for(ii = 0; ii < nb_segm; ii++, pt_track = (TRACK*) pt_track->Pnext) + { + pt_track->SetState(BUSY,OFF); + errdrc = Edit_TrackSegm_Width(DC, pt_track); + if(errdrc == BAD_DRC) nb_segm_non_modifies++; + else nb_segm_modifies++; + } +} + + +/***********************************************************/ +void WinEDA_PcbFrame::Edit_Net_Width(wxDC * DC, int Netcode) +/***********************************************************/ +{ +TRACK *pt_segm; +int errdrc; +int nb_segm_modifies = 0; +int nb_segm_non_modifies = 0; + + if (Netcode <= 0 ) return; + + if( ! IsOK(this, "Change largeur NET ?") ) return; + + /* balayage des segments */ + for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext ) + { + if ( Netcode != pt_segm->m_NetCode ) /* mauvaise piste */ + continue ; + /* piste d'un net trouvee */ + errdrc = Edit_TrackSegm_Width(DC, pt_segm); + if(errdrc == BAD_DRC) nb_segm_non_modifies++; + else nb_segm_modifies++; + } +} + + + + +/*************************************************************************/ +bool WinEDA_PcbFrame::Resize_Pistes_Vias(wxDC * DC, bool Track, bool Via) +/*************************************************************************/ + +/* remet a jour la largeur des pistes et/ou le diametre des vias + Si piste == 0 , pas de cht sur les pistes + Si via == 0 , pas de cht sur les vias +*/ +{ +TRACK * pt_segm ; +int errdrc; +int nb_segm_modifies = 0; +int nb_segm_non_modifies = 0; + + if ( Track && Via) + { + if( ! IsOK(this, _("Edit All Tracks and Vias Sizes")) ) return FALSE; + } + + else if ( Via ) + { + if( ! IsOK(this, _("Edit All Via Sizes")) ) return FALSE; + } + + else if( Track ) + { + if( ! IsOK(this, _("Edit All Track Sizes")) ) return FALSE; + } + + pt_segm = m_Pcb->m_Track ; + for ( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext ) + { + if( pt_segm->m_StructType == TYPEVIA ) /* mise a jour du diametre de la via */ + { + if ( Via ) + { + errdrc = Edit_TrackSegm_Width(DC, pt_segm); + if(errdrc == BAD_DRC) nb_segm_non_modifies++; + else nb_segm_modifies++; + } + } + else /* mise a jour de la largeur du segment */ + { + if ( Track ) + { + errdrc = Edit_TrackSegm_Width(DC, pt_segm); + if(errdrc == BAD_DRC) nb_segm_non_modifies++; + else nb_segm_modifies++; + } + } + } + + if ( nb_segm_modifies ) return TRUE; + return FALSE; +} + diff --git a/pcbnew/edtxtmod.cpp b/pcbnew/edtxtmod.cpp new file mode 100644 index 0000000000..f46c066254 --- /dev/null +++ b/pcbnew/edtxtmod.cpp @@ -0,0 +1,230 @@ + /*************************************************************/ + /* Edition des Modules: Routines de modification des textes */ + /* sur les MODULES */ + /*************************************************************/ + + /* Fichier EDTXTMOD.CPP */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "trigo.h" + +#include "protos.h" + + +/* Routines Locales */ +static void Show_MoveTexte_Module(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void ExitTextModule(WinEDA_DrawPanel * Panel, wxDC *DC); + +/* local variables */ +wxPoint MoveVector; // Move vector for move edge, exported to dialog_edit mod_text.cpp +static wxPoint CursorInitialPosition; // Mouse cursor inital position for move command + + +/******************************************************************************/ +TEXTE_MODULE * WinEDA_BasePcbFrame::CreateTextModule(MODULE * Module, wxDC * DC) +/******************************************************************************/ +/* Add a new graphical text to the active module (footprint) + Note there always are 2 texts: reference and value. + New texts have the member TEXTE_MODULE.m_Type set to TEXT_is_DIVERS +*/ +{ +TEXTE_MODULE * Text; + + Text = new TEXTE_MODULE(Module); + + /* Chainage de la nouvelle structure en tete de liste drawings */ + Text->Pnext = Module->m_Drawings; + Text->Pback = Module; + + if( Module->m_Drawings ) + Module->m_Drawings->Pback = Text; + Module->m_Drawings = Text; + Text->m_Flags = IS_NEW; + + Text->m_Text = wxT("text"); + + Text->m_Size = ModuleTextSize; + Text->m_Width = ModuleTextWidth; + Text->m_Pos = GetScreen()->m_Curseur; + Text->SetLocalCoord(); + + InstallTextModOptionsFrame(Text, NULL, wxPoint(-1,-1) ); + + Text->m_Flags = 0; + Text->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR ); + + Affiche_Infos_E_Texte(this, Module, Text); + + return Text; +} + +/**************************************************************************/ +void WinEDA_BasePcbFrame::RotateTextModule(TEXTE_MODULE * Text, wxDC * DC) +/**************************************************************************/ +/* Rotation de 90 du texte d'un module */ +{ +MODULE * Module; + + if ( Text == NULL ) return; + + Module = (MODULE*)Text->m_Parent; + + Text->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR ); + + Text->m_Orient += 900 ; + while (Text->m_Orient >= 1800) Text->m_Orient -= 1800 ; + + /* Redessin du Texte */ + Text->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR ); + + Affiche_Infos_E_Texte(this, Module,Text); + + ((MODULE*)Text->m_Parent)->m_LastEdit_Time = time(NULL); + GetScreen()->SetModify(); +} + +/**************************************************************************/ +void WinEDA_BasePcbFrame::DeleteTextModule(TEXTE_MODULE * Text, wxDC * DC) +/**************************************************************************/ +/* + Supprime 1 texte sur module (si ce n'est pas la référence ou la valeur) +*/ +{ +MODULE * Module; + + if (Text == NULL) return; + + Module = (MODULE*)Text->m_Parent; + + if(Text->m_Type == TEXT_is_DIVERS) + { + Text->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR ); + + /* liberation de la memoire : */ + DeleteStructure(Text); + GetScreen()->SetModify(); + Module->m_LastEdit_Time = time(NULL); + } +} + + + +/*************************************************************/ +static void ExitTextModule(WinEDA_DrawPanel * Panel, wxDC *DC) +/*************************************************************/ +/* + Routine de sortie du menu edit texte module +Si un texte est selectionne, ses coord initiales sont regenerees +*/ +{ +BASE_SCREEN * screen = Panel->GetScreen(); +TEXTE_MODULE * Text = (TEXTE_MODULE *) screen->m_CurrentItem; +MODULE * Module; + + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + + if ( Text == NULL ) return; + + Module = ( MODULE *) Text->m_Parent; + Text->Draw(Panel, DC, MoveVector, GR_XOR ); + + /* Redessin du Texte */ + Text->Draw(Panel, DC, wxPoint(0,0), GR_OR ); + + Text->m_Flags = 0; + Module->m_Flags = 0; + + screen->m_CurrentItem = NULL; +} + +/****************************************************************************/ +void WinEDA_BasePcbFrame::StartMoveTexteModule(TEXTE_MODULE * Text, wxDC * DC) +/****************************************************************************/ +/* Routine d'initialisation du deplacement d'un texte sur module +*/ +{ +MODULE * Module; + + if( Text == NULL ) return; + + Module = (MODULE*) Text->m_Parent; + + Text->m_Flags |= IS_MOVED; + Module->m_Flags |= IN_EDIT; + + MoveVector.x = MoveVector.y = 0; + CursorInitialPosition = Text->m_Pos; + + Affiche_Infos_E_Texte(this, Module, Text); + + GetScreen()->m_CurrentItem = Text; + DrawPanel->ManageCurseur = Show_MoveTexte_Module; + DrawPanel->ForceCloseManageCurseur = ExitTextModule; + + DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); +} + + +/*************************************************************************/ +void WinEDA_BasePcbFrame::PlaceTexteModule(TEXTE_MODULE * Text, wxDC * DC) +/*************************************************************************/ +/* Routine complementaire a StartMoveTexteModule(). + Place le texte en cours de deplacement ou nouvellement cree +*/ +{ + + if (Text != NULL ) + { + Text->m_Pos = GetScreen()->m_Curseur; + /* mise a jour des coordonnées relatives a l'ancre */ + MODULE * Module = ( MODULE *) Text->m_Parent; + if (Module ) + { + int px = Text->m_Pos.x - Module->m_Pos.x; + int py = Text->m_Pos.y - Module->m_Pos.y; + RotatePoint( &px, &py, - Module->m_Orient); + Text->m_Pos0.x = px; + Text->m_Pos0.y = py; + Text->m_Flags = 0; + Module->m_Flags = 0; + Module->m_LastEdit_Time = time(NULL); + GetScreen()->SetModify(); + + /* Redessin du Texte */ + Text->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR ); + } + } + + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; +} + + +/********************************************************************************/ +static void Show_MoveTexte_Module(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/********************************************************************************/ +{ +BASE_SCREEN * screen = panel->GetScreen(); +TEXTE_MODULE * Text = (TEXTE_MODULE *) screen->m_CurrentItem; +MODULE * Module; + + if (Text == NULL ) return ; + + Module = ( MODULE *) Text->m_Parent; + /* effacement du texte : */ + + if ( erase ) + Text->Draw(panel, DC, MoveVector, GR_XOR ); + + MoveVector.x = -(screen->m_Curseur.x - CursorInitialPosition.x); + MoveVector.y = -(screen->m_Curseur.y - CursorInitialPosition.y); + + /* Redessin du Texte */ + Text->Draw(panel, DC, MoveVector, GR_XOR ); +} + diff --git a/pcbnew/edtxtmod.rc b/pcbnew/edtxtmod.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/pcbnew/edtxtmod.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/pcbnew/essai.cpp b/pcbnew/essai.cpp new file mode 100644 index 0000000000..f4a4eee0c7 --- /dev/null +++ b/pcbnew/essai.cpp @@ -0,0 +1,151 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: essai.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 28/02/2006 07:46:42 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 28/02/2006 07:46:42 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "essai.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes + +#include "essai.h" + +////@begin XPM images +////@end XPM images + +/*! + * essai type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( essai, wxDialog ) + +/*! + * essai event table definition + */ + +BEGIN_EVENT_TABLE( essai, wxDialog ) + +////@begin essai event table entries +////@end essai event table entries + +END_EVENT_TABLE() + +/*! + * essai constructors + */ + +essai::essai( ) +{ +} + +essai::essai( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + Create(parent, id, caption, pos, size, style); +} + +/*! + * essai creator + */ + +bool essai::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin essai member initialisation + GridSizer = NULL; +////@end essai member initialisation + +////@begin essai creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end essai creation + return true; +} + +/*! + * Control creation for essai + */ + +void essai::CreateControls() +{ +////@begin essai content construction + // Generated by DialogBlocks, 28/02/2006 07:48:35 (unregistered) + + essai* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxStaticText* itemStaticText3 = new wxStaticText( itemDialog1, wxID_STATIC, _("Static text"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add(itemStaticText3, 0, wxGROW|wxALL|wxADJUST_MINSIZE, 5); + + GridSizer = new wxFlexGridSizer(3, 2, 0, 0); + itemBoxSizer2->Add(GridSizer, 0, wxGROW|wxALL, 5); + + wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("X:"), wxDefaultPosition, wxDefaultSize, 0 ); + GridSizer->Add(itemStaticText5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + + wxTextCtrl* itemTextCtrl6 = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + GridSizer->Add(itemTextCtrl6, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5); + +////@end essai content construction +} + +/*! + * Should we show tooltips? + */ + +bool essai::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap essai::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin essai bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end essai bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon essai::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin essai icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end essai icon retrieval +} diff --git a/pcbnew/essai.h b/pcbnew/essai.h new file mode 100644 index 0000000000..38285350e9 --- /dev/null +++ b/pcbnew/essai.h @@ -0,0 +1,100 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: essai.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 28/02/2006 07:46:42 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 28/02/2006 07:46:42 + +#ifndef _ESSAI_H_ +#define _ESSAI_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "essai.h" +#endif + +/*! + * Includes + */ + +////@begin includes +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +class wxFlexGridSizer; +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_ESSAI_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_ESSAI_TITLE _("essai") +#define SYMBOL_ESSAI_IDNAME ID_DIALOG +#define SYMBOL_ESSAI_SIZE wxSize(400, 300) +#define SYMBOL_ESSAI_POSITION wxDefaultPosition +#define ID_TEXTCTRL 10001 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * essai class declaration + */ + +class essai: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( essai ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + essai( ); + essai( wxWindow* parent, wxWindowID id = SYMBOL_ESSAI_IDNAME, const wxString& caption = SYMBOL_ESSAI_TITLE, const wxPoint& pos = SYMBOL_ESSAI_POSITION, const wxSize& size = SYMBOL_ESSAI_SIZE, long style = SYMBOL_ESSAI_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_ESSAI_IDNAME, const wxString& caption = SYMBOL_ESSAI_TITLE, const wxPoint& pos = SYMBOL_ESSAI_POSITION, const wxSize& size = SYMBOL_ESSAI_SIZE, long style = SYMBOL_ESSAI_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin essai event handler declarations + +////@end essai event handler declarations + +////@begin essai member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end essai member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + +////@begin essai member variables + wxFlexGridSizer* GridSizer; +////@end essai member variables +}; + +#endif + // _ESSAI_H_ diff --git a/pcbnew/essai.rc b/pcbnew/essai.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/pcbnew/essai.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/pcbnew/export_gencad.cpp b/pcbnew/export_gencad.cpp new file mode 100644 index 0000000000..7ff2053b1b --- /dev/null +++ b/pcbnew/export_gencad.cpp @@ -0,0 +1,820 @@ +/***************************************************/ +/* export_gencad.cpp - export en formay GenCAD 1.4 */ +/***************************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "pcbnew.h" +#include "trigo.h" + +#include "bitmaps.h" +#include "protos.h" +#include "id.h" + +bool CreateHeaderInfoData(FILE * file, WinEDA_PcbFrame * frame); +static int * CreateTracksInfoData(FILE * file, BOARD * pcb); +static void CreateBoardSection(FILE * file, BOARD * pcb); +static void CreateComponentsSection(FILE * file, BOARD * pcb); +static void CreateDevicesSection(FILE * file, BOARD * pcb); +static void CreateRoutesSection(FILE * file, BOARD * pcb); +static void CreateSignalsSection(FILE * file, BOARD * pcb); +static void CreateShapesSection(FILE * file, BOARD * pcb); +static void CreatePadsShapesSection(FILE * file, BOARD * pcb); +static void ModuleWriteShape( FILE * File, MODULE * module ); + +wxString GenCAD_Layer_Name[32] // layer name pour extensions fichiers de trace + = { + wxT("BOTTOM"), wxT("INNER1"), wxT("INNER2"), wxT("INNER3"), + wxT("INNER4"), wxT("INNER5"), wxT("INNER6"), wxT("INNER7"), + wxT("INNER8"), wxT("INNER9"), wxT("INNER10"), wxT("INNER11"), + wxT("INNER12"), wxT("INNER13"), wxT("INNER14"), wxT("TOP"), + wxT("adhecu"), wxT("adhecmp"), wxT("SOLDERPASTE_BOTTOM"), wxT("SOLDERPASTE_TOP"), + wxT("SILKSCREEN_BOTTOM"), wxT("SILKSCREEN_TOP"), wxT("SOLDERMASK_BOTTOM"), wxT("SOLDERMASK_TOP"), + wxT("drawings"), wxT("comments"), wxT("eco1"), wxT("eco2"), + wxT("edges"), wxT("--"), wxT("--"), wxT("--") + }; + +int offsetX, offsetY; +D_PAD * PadList; + +/* routines de conversion des coord ( sous GenCAD axe Y vers le haut) */ +static int mapXto(int x) +{ + return x - offsetX; +} +static int mapYto(int y) +{ + return offsetY - y; +} + + +/***********************************************************/ +void WinEDA_PcbFrame::ExportToGenCAD(wxCommandEvent& event) +/***********************************************************/ +/* +Exporte le board au format GenCAD 1.4 +*/ +{ +wxString FullFileName = GetScreen()->m_FileName; +wxString msg, std_ext, mask; +FILE * file; + + std_ext = wxT(".gcd"); + mask = wxT("*") + std_ext; + ChangeFileNameExt(FullFileName,std_ext); + FullFileName = EDA_FileSelector(_("GenCAD file:"), + wxEmptyString, /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + std_ext, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + FALSE + ); + if ( FullFileName == wxEmptyString ) return; + + if ( (file = wxFopen(FullFileName, wxT("wt") )) == NULL ) + { + msg = _("Unable to create ") + FullFileName; + DisplayError(this, msg); return; + } + + /* Mise a jour des infos PCB: */ + m_Pcb->ComputeBoundaryBox(); + + offsetX = m_Auxiliary_Axis_Position.x; + offsetY = m_Auxiliary_Axis_Position.y; +wxClientDC dc(DrawPanel); + DrawPanel->PrepareGraphicContext(&dc); + Compile_Ratsnest( &dc, TRUE ); + + /* Mise des modules vus en miroir en position "normale" + (necessaire pour decrire les formes sous GenCAD, + qui sont decrites en vue normale, orientation 0)) */ +MODULE * module; + for(module = m_Pcb->m_Modules; module != NULL; module = module->Next()) + { + module->flag = 0; + if ( module->m_Layer == CUIVRE_N ) + { + Change_Side_Module(module, NULL); + module->flag = 1; + } + } + // Creation de l'entete: + CreateHeaderInfoData(file, this); + CreateBoardSection(file, m_Pcb); + + /* Creation liste des TRACKS + (section $TRACK) id liste des outils de tracage de pistes */ + CreateTracksInfoData(file, m_Pcb); + + /* Creation de la liste des formes utilisees + (formes des composants principalement */ + CreatePadsShapesSection(file, m_Pcb); // doit etre appele avant CreateShapesSection() + CreateShapesSection( file, m_Pcb); + + /* Creation de la liste des equipotentielles: */ + CreateSignalsSection(file, m_Pcb); + + CreateDevicesSection(file, m_Pcb); + CreateComponentsSection(file, m_Pcb); + CreateRoutesSection(file, m_Pcb); + + fclose(file); + + /* Remise en place des modules vus en miroir */ + for(module = m_Pcb->m_Modules; module != NULL; module = module->Next()) + { + if ( module->flag ) + { + Change_Side_Module(module, NULL); + module->flag = 0; + } + } +} + + +/**************************************************************************/ +static int Pad_list_Sort_by_Shapes(const void * refptr, const void * objptr) +/**************************************************************************/ +/* +Routine de tri de la liste des pads par type, puis pa taille +*/ +{ +const D_PAD * padref, *padcmp; +int diff; + + padref = *((D_PAD**) refptr); + padcmp = *((D_PAD**) objptr); + if( (diff = padref->m_PadShape - padcmp->m_PadShape) ) return diff; + if( (diff = padref->m_Size.x - padcmp->m_Size.x) ) return diff; + if( (diff = padref->m_Size.y - padcmp->m_Size.y) ) return diff; + if( (diff = padref->m_Offset.x - padcmp->m_Offset.x) ) return diff; + if( (diff = padref->m_Offset.y - padcmp->m_Offset.y) ) return diff; + if( (diff = padref->m_DeltaSize.x - padcmp->m_DeltaSize.x) ) return diff; + if( (diff = padref->m_DeltaSize.y - padcmp->m_DeltaSize.y) ) return diff; + + return 0; +} + +/*****************************************************/ +void CreatePadsShapesSection(FILE * file, BOARD * pcb) +/*****************************************************/ +/* Cree la liste des formes des pads ( 1 forme par pad ) +initialise le membre .m_logical_connexion de la struct pad, la valeur 1 ..n +pour les formes de pad PAD1 a PADn +*/ +{ +D_PAD * pad, **padlist, **pad_list_base; +char * pad_type; +int memsize, ii, dx, dy; +D_PAD * old_pad = NULL; +int pad_name_number; + + fputs("$PADS\n", file); + + // Generation de la liste des pads tries par forme et dimensions: + memsize = (pcb->m_NbPads + 1) * sizeof(D_PAD*); + pad_list_base = (D_PAD**) MyZMalloc(memsize); + memcpy(pad_list_base, pcb->m_Pads, memsize); + qsort(pad_list_base, pcb->m_NbPads, sizeof(D_PAD*), Pad_list_Sort_by_Shapes); + + pad_name_number = 0; + for( padlist = pad_list_base, ii = 0; ii < pcb->m_NbPads; padlist++, ii++) + { + pad = *padlist; + pad->m_logical_connexion = pad_name_number; + + if ( old_pad && + (old_pad->m_PadShape == pad->m_PadShape) && + (old_pad->m_Size.x == pad->m_Size.x) && + (old_pad->m_Size.y == pad->m_Size.y) && + (old_pad->m_Offset.x == pad->m_Offset.x) && + (old_pad->m_Offset.y == pad->m_Offset.y) && + (old_pad->m_DeltaSize.x == pad->m_DeltaSize.x) && + (old_pad->m_DeltaSize.y == pad->m_DeltaSize.y) + ) + continue; // Forme deja generee + + old_pad = pad; + + pad_name_number ++; + pad->m_logical_connexion = pad_name_number; + + fprintf(file, "PAD PAD%d", pad->m_logical_connexion); + + dx = pad->m_Size.x / 2; dy = pad->m_Size.y / 2; + + switch( pad->m_PadShape ) + { + default: + case CIRCLE: + pad_type = "ROUND"; + fprintf(file, " %s %d\n", pad_type, pad->m_Drill.x); + fprintf(file, "CIRCLE %d %d %d\n", + pad->m_Offset.x, - pad->m_Offset.y, pad->m_Size.x/2); + break; + + case RECT: + pad_type = "RECTANGULAR"; + fprintf(file, " %s %d\n", pad_type, pad->m_Drill.x); + fprintf(file, "RECTANGLE %d %d %d %d\n", + -dx + pad->m_Offset.x, - dy - pad->m_Offset.y, + dx + pad->m_Offset.x, - pad->m_Offset.y + dy ); + break; + + case OVALE: /* description du contour par 2 linges et 2 arcs */ + { + pad_type = "FINGER"; + fprintf(file, " %s %d\n", pad_type, pad->m_Drill.x); + int dr = dx - dy; + if ( dr >= 0 ) // ovale horizontal + { + int rayon = dy; + fprintf(file, "LINE %d %d %d %d\n", + -dr + pad->m_Offset.x, - pad->m_Offset.y - rayon, + dr + pad->m_Offset.x, - pad->m_Offset.y - rayon ); + fprintf(file, "ARC %d %d %d %d %d %d\n", + dr + pad->m_Offset.x, - pad->m_Offset.y - rayon, + dr + pad->m_Offset.x, - pad->m_Offset.y + rayon, + dr + pad->m_Offset.x, - pad->m_Offset.y); + + fprintf(file, "LINE %d %d %d %d\n", + dr + pad->m_Offset.x, - pad->m_Offset.y + rayon, + -dr + pad->m_Offset.x, - pad->m_Offset.y + rayon ); + fprintf(file, "ARC %d %d %d %d %d %d\n", + -dr + pad->m_Offset.x, - pad->m_Offset.y + rayon, + -dr + pad->m_Offset.x, - pad->m_Offset.y - rayon, + -dr + pad->m_Offset.x, - pad->m_Offset.y); + } + else // ovale vertical + { + dr = -dr; + int rayon = dx; + fprintf(file, "LINE %d %d %d %d\n", + -rayon + pad->m_Offset.x, - pad->m_Offset.y - dr, + -rayon + pad->m_Offset.x, - pad->m_Offset.y + dr ); + fprintf(file, "ARC %d %d %d %d %d %d\n", + -rayon + pad->m_Offset.x, - pad->m_Offset.y + dr, + rayon + pad->m_Offset.x, - pad->m_Offset.y + dr, + pad->m_Offset.x, - pad->m_Offset.y + dr); + + fprintf(file, "LINE %d %d %d %d\n", + rayon + pad->m_Offset.x, - pad->m_Offset.y + dr, + rayon + pad->m_Offset.x, - pad->m_Offset.y - dr ); + fprintf(file, "ARC %d %d %d %d %d %d\n", + rayon + pad->m_Offset.x, - pad->m_Offset.y - dr, + - rayon + pad->m_Offset.x, - pad->m_Offset.y - dr, + pad->m_Offset.x, - pad->m_Offset.y - dr); + } + break; + } + + case TRAPEZE: + pad_type = "POLYGON"; + break; + } + } + + fputs("$ENDPADS\n\n", file); + MyFree(pad_list_base); +} + + +/**************************************************/ +void CreateShapesSection(FILE * file, BOARD * pcb) +/**************************************************/ +/* Creation de la liste des formes des composants. +Comme la forme de base (module de librairie peut etre modifiee, +une forme est creee par composant +La forme est donnee normalisee, c'est a dire orientation 0, position 0 non miroir +Il y aura donc des formes indentiques redondantes + + Syntaxe: +$SHAPES +SHAPE +shape_descr (line, arc ..) +PIN + +SHAPE +.. +$ENDSHAPES +*/ +{ +MODULE * module; +D_PAD * pad; +char * layer; +int orient; +wxString pinname; +char * mirror = "0"; + + fputs("$SHAPES\n", file); + + for(module = pcb->m_Modules; module != NULL; module = (MODULE *) module->Pnext) + { + ModuleWriteShape( file, module ); + for( pad = module->m_Pads; pad != NULL; pad = (D_PAD*) pad->Pnext) + { + layer = "ALL"; + if ( (pad->m_Masque_Layer & ALL_CU_LAYERS) == CUIVRE_LAYER ) + { + if ( module->m_Layer == CMP_N ) layer = "BOTTOM"; + else layer = "TOP"; + } + else if ( (pad->m_Masque_Layer & ALL_CU_LAYERS) == CMP_LAYER ) + { + if ( module->m_Layer == CMP_N ) layer = "TOP"; + else layer = "BOTTOM"; + } + + pad->ReturnStringPadName(pinname); + if( pinname.IsEmpty() ) pinname = wxT("noname"); + + orient = pad->m_Orient - module->m_Orient; + NORMALIZE_ANGLE_POS(orient); + fprintf(file, "PIN %s PAD%d %d %d %s %d %s", + CONV_TO_UTF8(pinname), pad->m_logical_connexion, + pad->m_Pos0.x, - pad->m_Pos0.y, + layer, orient/10, mirror ); + if ( orient % 10 ) fprintf(file, " .%d", orient % 10 ); + fprintf(file, "\n"); + } + } + + fputs("$ENDSHAPES\n\n", file); +} + +/******************************************************/ +void CreateComponentsSection(FILE * file, BOARD * pcb) +/******************************************************/ +/* Creation de la section $COMPONENTS (Placement des composants + Composants cote CUIVRE: + Les formes sont donnees avec l'option "FLIP", c.a.d.: + - ils sont decrits en vue normale (comme s'ils etaient sur cote COMPOSANT) + - leur orientation est donnée comme s'ils etaient cote composant. +*/ +{ +MODULE * module = pcb->m_Modules; +TEXTE_MODULE * PtTexte; +char * mirror; +char * flip; +int ii; + + fputs("$COMPONENTS\n", file); + + for(; module != NULL; module = (MODULE *) module->Pnext) + { + int orient = module->m_Orient; + if (module->flag) + { + mirror = "MIRRORX"; // Miroir selon axe X + flip = "FLIP"; // Description normale ( formes a afficher en miroir X) + NEGATE_AND_NORMALIZE_ANGLE_POS(orient); + } + else + { + mirror ="0"; + flip = "0"; + } + + fprintf(file, "COMPONENT %s\n", CONV_TO_UTF8(module->m_Reference->m_Text)); + fprintf(file, "DEVICE %s\n", CONV_TO_UTF8(module->m_Reference->m_Text)); + fprintf(file, "PLACE %d %d\n", mapXto(module->m_Pos.x), mapYto(module->m_Pos.y)); + fprintf(file, "LAYER %s\n", (module->flag)? "BOTTOM" : "TOP"); + + fprintf(file, "ROTATION %d", orient/10 ); + if (orient%10 ) fprintf(file, ".%d", orient%10 ); + fputs("\n",file); + + fprintf(file, "SHAPE %s %s %s\n", + CONV_TO_UTF8(module->m_Reference->m_Text), mirror, flip); + + /* Generation des elements textes (ref et valeur seulement) */ + PtTexte = module->m_Reference; + for ( ii = 0; ii < 2; ii++ ) + { + int orient = PtTexte->m_Orient; + wxString layer = GenCAD_Layer_Name[SILKSCREEN_N_CMP]; + fprintf(file, "TEXT %d %d %d %d.%d %s %s \"%s\"", + PtTexte->m_Pos0.x, - PtTexte->m_Pos0.y, + PtTexte->m_Size.x, + orient /10, orient %10, + mirror, + CONV_TO_UTF8(layer), + CONV_TO_UTF8(PtTexte->m_Text) + ); + + fprintf(file, " 0 0 %d %d\n", + (int) (PtTexte->m_Size.x * PtTexte->m_Text.Len() ), + (int) PtTexte->m_Size.y ); + + PtTexte = module->m_Value; + } + + // commentaire: + fprintf(file, "SHEET Part %s %s\n", CONV_TO_UTF8(module->m_Reference->m_Text), + CONV_TO_UTF8(module->m_Value->m_Text)); + + } + + fputs("$ENDCOMPONENTS\n\n", file); +} + +/***************************************************/ +void CreateSignalsSection(FILE * file, BOARD * pcb) +/***************************************************/ +/* Creation de la liste des equipotentielles: + $SIGNALS + SIGNAL + NODE + ... + NODE + $ENDSIGNALS +*/ +{ +wxString msg; +EQUIPOT * equipot; +D_PAD * pad; +MODULE * module; +int NbNoConn = 1; + + fputs("$SIGNALS\n", file); + + for( equipot = pcb->m_Equipots; equipot != NULL; equipot = (EQUIPOT *) equipot->Pnext ) + { + if ( equipot->m_Netname == wxEmptyString ) // dummy equipot (non connexion) + { + equipot->m_Netname << wxT("NoConnection") << NbNoConn++; + } + + if ( equipot->m_NetCode <= 0 ) // dummy equipot (non connexion) + continue; + + msg = wxT("\nSIGNAL ") + equipot->m_Netname; + fputs( CONV_TO_UTF8(msg), file); fputs("\n", file); + + for ( module = pcb->m_Modules; module != NULL; module = (MODULE *) module->Pnext ) + { + for( pad = module->m_Pads; pad != NULL; pad = (D_PAD *) pad->Pnext ) + { + wxString padname; + if ( pad->m_NetCode != equipot->m_NetCode ) continue; + pad->ReturnStringPadName(padname); + msg.Printf(wxT("NODE %s %.4s"), + module->m_Reference->m_Text.GetData(), padname.GetData()); + fputs( CONV_TO_UTF8(msg), file); fputs("\n", file); + } + } + } + + fputs("$ENDSIGNALS\n\n", file); + +} + +/*************************************************************/ +bool CreateHeaderInfoData(FILE * file, WinEDA_PcbFrame * frame) +/*************************************************************/ +/* Creation de la section $HEADER ... $ENDHEADER +*/ +{ +wxString msg; +PCB_SCREEN * screen = frame->GetScreen(); + + fputs("$HEADER\n", file); + fputs("GENCAD 1.4\n", file); + msg = wxT("USER ") + g_Main_Title + wxT(" ") + GetBuildVersion(); + fputs(CONV_TO_UTF8(msg), file); fputs("\n", file); + msg = wxT("DRAWING ") + screen->m_FileName; + fputs(CONV_TO_UTF8(msg), file); fputs("\n", file); + msg = wxT("REVISION ") + screen->m_Revision + wxT(" ") + screen->m_Date; + fputs(CONV_TO_UTF8(msg), file); fputs("\n", file); + msg.Printf(wxT("UNITS USER %d"), PCB_INTERNAL_UNIT); + fputs(CONV_TO_UTF8(msg), file); fputs("\n", file); + msg.Printf( wxT("ORIGIN %d %d"), mapXto(frame->m_Auxiliary_Axis_Position.x), + mapYto(frame->m_Auxiliary_Axis_Position.y)) ; + fputs(CONV_TO_UTF8(msg), file); fputs("\n", file); + fputs("INTERTRACK 0\n", file); + fputs("$ENDHEADER\n\n", file); + + return TRUE; +} + + +/**************************************************************************/ +static int Track_list_Sort_by_Netcode(const void * refptr, const void * objptr) +/**************************************************************************/ +/* +Routine de tri de la liste des piste par netcode, + puis par largeur puis par layer +*/ +{ +const TRACK * ref, *cmp; +int diff; + + ref = *((TRACK**) refptr); + cmp = *((TRACK**) objptr); + if( (diff = ref->m_NetCode - cmp->m_NetCode) ) return diff; + if( (diff = ref->m_Width - cmp->m_Width) ) return diff; + if( (diff = ref->m_Layer - cmp->m_Layer) ) return diff; + + return 0; +} +/*************************************************/ +void CreateRoutesSection(FILE * file, BOARD * pcb) +/*************************************************/ +/* Creation de la liste des pistes, vias et zones +section: +$ROUTE +... +$ENROUTE +Les segments de piste doivent etre regroupes par nets +*/ +{ +TRACK * track, ** tracklist; +int vianum = 1; +int old_netcode, old_width, old_layer; +int nbitems, ii; + + // Calcul du nombre de segments a ecrire + nbitems = 0; + for( track = pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) nbitems++; + for( track = pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext ) + { + if ( track->m_StructType == TYPEZONE ) nbitems++; + } + tracklist = (TRACK **) MyMalloc( (nbitems+1) * sizeof(TRACK *) ); + + nbitems = 0; + for( track = pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) + tracklist[nbitems++] = track; + for( track = pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext ) + { + if ( track->m_StructType == TYPEZONE ) tracklist[nbitems++] = track; + } + tracklist[nbitems] = NULL; + + qsort(tracklist, nbitems, sizeof(TRACK *), Track_list_Sort_by_Netcode); + + fputs("$ROUTES\n", file); + + old_netcode = -1; old_width = -1; old_layer = -1; + for( ii = 0; ii < nbitems; ii++ ) + { + track = tracklist[ii]; + if ( old_netcode != track->m_NetCode ) + { + old_netcode = track->m_NetCode; + EQUIPOT * equipot = GetEquipot( pcb, track->m_NetCode); + wxString netname; + if (equipot && (equipot->m_Netname != wxEmptyString) ) + netname = equipot->m_Netname; + else netname = wxT("_noname_" ); + fprintf(file,"\nROUTE %s\n",CONV_TO_UTF8(netname)); + } + + if ( old_width != track->m_Width ) + { + old_width = track->m_Width; + fprintf(file,"TRACK TRACK%d\n", track->m_Width); + } + + if ( (track->m_StructType == TYPETRACK) || (track->m_StructType == TYPEZONE) ) + { + if ( old_layer != track->m_Layer ) + { + old_layer = track->m_Layer; + fprintf(file,"LAYER %s\n", + CONV_TO_UTF8(GenCAD_Layer_Name[track->m_Layer & 0x1F])); + } + + fprintf(file, "LINE %d %d %d %d\n", + mapXto(track->m_Start.x), mapYto(track->m_Start.y), + mapXto(track->m_End.x), mapYto(track->m_End.y) ); + } + if ( track->m_StructType == TYPEVIA ) + { + fprintf(file, "VIA viapad%d %d %d ALL %d via%d\n", + track->m_Width, + mapXto(track->m_Start.x), mapYto(track->m_Start.y), + g_DesignSettings.m_ViaDrill, vianum++ ); + } + } + + fputs("$ENDROUTES\n\n", file); + + free(tracklist); +} + + +/***************************************************/ +void CreateDevicesSection(FILE * file, BOARD * pcb) +/***************************************************/ +/* Creation de la section de description des proprietes des composants + ( la forme des composants est dans la section shape ) +*/ +{ +MODULE * module; +D_PAD * pad; + + fputs("$DEVICES\n", file); + + for(module = pcb->m_Modules; module != NULL; module = (MODULE *) module->Pnext) + { + fprintf(file, "DEVICE %s\n", CONV_TO_UTF8(module->m_Reference->m_Text)); + fprintf(file, "PART %s\n", CONV_TO_UTF8(module->m_LibRef)); + fprintf(file, "TYPE %s\n", "UNKNOWN"); + for( pad = module->m_Pads; pad != NULL; pad = (D_PAD*) pad->Pnext) + { + fprintf(file, "PINDESCR %.4s", pad->m_Padname); + if ( pad->m_Netname == wxEmptyString ) fputs(" NoConn\n", file); + else fprintf(file, " %.4s\n", pad->m_Padname); + } + fprintf(file, "ATTRIBUTE %s\n", CONV_TO_UTF8(module->m_Value->m_Text)); + } + + fputs("$ENDDEVICES\n\n", file); +} + + +/*************************************************/ +void CreateBoardSection(FILE * file, BOARD * pcb) +/*************************************************/ +/* Creation de la section $BOARD. +On ne cree ici que le rectangle d'encadrement du Board +*/ +{ + fputs("$BOARD\n", file); + fprintf(file, "LINE %d %d %d %d\n", + mapXto(pcb->m_BoundaryBox.m_Pos.x), mapYto(pcb->m_BoundaryBox.m_Pos.y), + mapXto(pcb->m_BoundaryBox.GetRight()), mapYto(pcb->m_BoundaryBox.m_Pos.y) ); + fprintf(file, "LINE %d %d %d %d\n", + mapXto(pcb->m_BoundaryBox.GetRight()), mapYto(pcb->m_BoundaryBox.m_Pos.y), + mapXto(pcb->m_BoundaryBox.GetRight()), mapYto(pcb->m_BoundaryBox.GetBottom()) ); + fprintf(file, "LINE %d %d %d %d\n", + mapXto(pcb->m_BoundaryBox.GetRight()), mapYto(pcb->m_BoundaryBox.GetBottom()), + mapXto(pcb->m_BoundaryBox.m_Pos.x), mapYto(pcb->m_BoundaryBox.GetBottom()) ); + fprintf(file, "LINE %d %d %d %d\n", + mapXto(pcb->m_BoundaryBox.m_Pos.x), mapYto(pcb->m_BoundaryBox.GetBottom()), + mapXto(pcb->m_BoundaryBox.m_Pos.x), mapYto(pcb->m_BoundaryBox.m_Pos.y) ); + + fputs("$ENDBOARD\n\n", file); +} + + +/****************************************************/ +int * CreateTracksInfoData(FILE * file, BOARD * pcb) +/****************************************************/ +/* Creation de la section "$TRACKS" +Cette section definit les largeurs de pistes utilsees +format: +$TRACK +TRACK +$ENDTRACK + +on attribut ici comme nom l'epaisseur des traits precede de "TRACK": ex +pour une largeur de 120 : nom = "TRACK120". +*/ +{ +TRACK * track; +int * trackinfo, * ptinfo; + + /* recherche des epaisseurs utilisees pour les traces: */ + + trackinfo = (int*) adr_lowmem; + *trackinfo = -1; + + for( track = pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) + { + if ( *trackinfo != track->m_Width ) // recherche d'une epaisseur deja utilisee + { + ptinfo = (int*) adr_lowmem; + while (*ptinfo >= 0 ) + { + if ( *ptinfo != track->m_Width ) ptinfo ++; + else break; + } + trackinfo = ptinfo; + if ( *ptinfo < 0 ) + { + *ptinfo = track->m_Width; + ptinfo++; *ptinfo = -1; + } + } + } + for( track = pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext ) + { + if ( *trackinfo != track->m_Width ) // recherche d'une epaisseur deja utilisee + { + ptinfo = (int*) adr_lowmem; + while (*ptinfo >= 0 ) + { + if ( *ptinfo != track->m_Width ) ptinfo ++; + else break; + } + trackinfo = ptinfo; + if ( *ptinfo < 0 ) + { + *ptinfo = track->m_Width; + ptinfo++; *ptinfo = -1; + } + } + } + + // Write data + fputs("$TRACKS\n", file); + for( trackinfo = (int*) adr_lowmem; * trackinfo >= 0; trackinfo++ ) + { + fprintf(file,"TRACK TRACK%d %d\n", * trackinfo, * trackinfo); + } + fputs("$ENDTRACKS\n\n", file); + + return (int*) adr_lowmem; +} + + +/***************************************************/ +void ModuleWriteShape( FILE * file, MODULE * module ) +/***************************************************/ +/* Sauvegarde de la forme d'un MODULE (section SHAPE) + La forme est donnee "normalisee" (Orient 0, vue normale ( non miroir) + Syntaxe: +SHAPE + shape_descr (line, arc ..): +LINE startX startY endX endY +ARC startX startY endX endY centreX scentreY +CIRCLE centreX scentreY radius +*/ +{ +EDGE_MODULE * PtEdge; +EDA_BaseStruct * PtStruct; +int Yaxis_sign = -1; // Controle changement signe axe Y (selon module normal/miroir et conevtions d'axe) + + + /* Generation du fichier module: */ + fprintf(file, "\nSHAPE %s\n", CONV_TO_UTF8(module->m_Reference->m_Text)); + + /* Attributs du module */ + if( module->m_Attributs != MOD_DEFAULT ) + { + fprintf(file,"ATTRIBUTE"); + if( module->m_Attributs & MOD_CMS ) fprintf(file," SMD"); + if( module->m_Attributs & MOD_VIRTUAL ) fprintf(file," VIRTUAL"); + fprintf(file,"\n"); + } + + + /* Generation des elements Drawing modules */ + PtStruct = module->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext) + { + switch(PtStruct->m_StructType ) + { + case TYPETEXTEMODULE: + break; + + case TYPEEDGEMODULE: + PtEdge = (EDGE_MODULE*) PtStruct; + switch(PtEdge->m_Shape ) + { + case S_SEGMENT: + fprintf(file,"LINE %d %d %d %d\n", + PtEdge->m_Start0.x, Yaxis_sign * PtEdge->m_Start0.y, + PtEdge->m_End0.x, Yaxis_sign * PtEdge->m_End0.y); + break; + case S_CIRCLE: + { + int rayon = (int)hypot( + (double)(PtEdge->m_End0.x - PtEdge->m_Start0.x), + (double)(PtEdge->m_End0.y - PtEdge->m_Start0.y) ); + fprintf(file,"CIRCLE %d %d %d\n", + PtEdge->m_Start0.x, Yaxis_sign * PtEdge->m_Start0.y, + rayon); + break; + } + + case S_ARC: /* print ARC x,y start x,y end x,y centre */ + { + int arcendx, arcendy; + arcendx = PtEdge->m_Start0.x; + arcendy = PtEdge->m_Start0.y; + RotatePoint(& arcendx, &arcendy, PtEdge->m_Angle); + fprintf(file,"ARC %d %d %d %d %d %d\n", + PtEdge->m_End0.x, Yaxis_sign * PtEdge->m_End0.y, + arcendx, Yaxis_sign * arcendy, + PtEdge->m_Start0.x, Yaxis_sign * PtEdge->m_Start0.y); + break; + } + default: + DisplayError(NULL, wxT("Type Edge Module inconnu")); + break; + } /* Fin switch type edge */ + break; + + default: + break; + } /* Fin switch gestion des Items draw */ + } +} + diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp new file mode 100644 index 0000000000..450a4307d4 --- /dev/null +++ b/pcbnew/files.cpp @@ -0,0 +1,331 @@ + /***************************************************/ + /* Files.cpp: Lecture / Sauvegarde des fichiers PCB */ + /***************************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "pcbnew.h" +#include "protos.h" +#include "id.h" + + +/****************************************************/ +void WinEDA_PcbFrame::Files_io(wxCommandEvent& event) +/****************************************************/ +/* Gestion generale des commandes de lecture de fichiers +*/ +{ +int id = event.GetId(); +wxClientDC dc(DrawPanel); +wxString msg; + + DrawPanel->PrepareGraphicContext(&dc); + + // Arret des commandes en cours + if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + SetToolID(0, wxCURSOR_ARROW,wxEmptyString); + + switch (id) + { + case ID_MENU_LOAD_FILE: + case ID_LOAD_FILE: + Clear_Pcb(&dc, TRUE); + LoadOnePcbFile(wxEmptyString, &dc, FALSE); + ReCreateAuxiliaryToolbar(); + break; + + case ID_MENU_READ_LAST_SAVED_VERSION_BOARD: + case ID_MENU_RECOVER_BOARD: + { + wxString filename, oldfilename = GetScreen()->m_FileName; + if ( id == ID_MENU_RECOVER_BOARD) + { + filename = g_SaveFileName + PcbExtBuffer; + } + else + { + filename = oldfilename; + ChangeFileNameExt(filename, wxT(".000")); + } + if ( ! wxFileExists(filename) ) + { + msg = _("Recovery file ") + filename + _(" not found"); + DisplayInfo(this, msg); + break; + } + else + { + msg = _("Ok to load Recovery file ") + filename; + if ( ! IsOK (this, msg) ) break; + } + Clear_Pcb(&dc, TRUE); + LoadOnePcbFile(filename, &dc, FALSE); + GetScreen()->m_FileName = oldfilename; + SetTitle(GetScreen()->m_FileName); + ReCreateAuxiliaryToolbar(); + } + break; + + case ID_MENU_APPEND_FILE: + case ID_APPEND_FILE: + LoadOnePcbFile(wxEmptyString, &dc, TRUE); + break; + + case ID_MENU_NEW_BOARD: + case ID_NEW_BOARD: + Clear_Pcb(&dc, TRUE); + GetScreen()->m_FileName.Printf( wxT("%s%cnoname%s"), + wxGetCwd().GetData(), DIR_SEP, PcbExtBuffer.GetData()); + SetTitle(GetScreen()->m_FileName); + break; + + case ID_LOAD_FILE_1: + case ID_LOAD_FILE_2: + case ID_LOAD_FILE_3: + case ID_LOAD_FILE_4: + case ID_LOAD_FILE_5: + case ID_LOAD_FILE_6: + case ID_LOAD_FILE_7: + case ID_LOAD_FILE_8: + case ID_LOAD_FILE_9: + case ID_LOAD_FILE_10: + Clear_Pcb(&dc, TRUE); + wxSetWorkingDirectory(wxPathOnly(GetLastProject(id - ID_LOAD_FILE_1))); + LoadOnePcbFile( GetLastProject(id - ID_LOAD_FILE_1).GetData(), + &dc, FALSE); + ReCreateAuxiliaryToolbar(); + break; + + case ID_SAVE_BOARD: + case ID_MENU_SAVE_BOARD: + SavePcbFile(GetScreen()->m_FileName); + break; + + case ID_MENU_SAVE_BOARD_AS: + SavePcbFile(wxEmptyString); + break; + + case ID_PCB_GEN_CMP_FILE: + RecreateCmpFileFromBoard(); + break; + + default: DisplayError(this, wxT("File_io Internal Error") ); break; + } +} + + + + +/*****************************************************************************************/ +int WinEDA_PcbFrame::LoadOnePcbFile(const wxString & FullFileName, wxDC * DC, bool Append) +/******************************************************************************************/ +/* + Lecture d'un fichier PCB, le nom etant dans PcbNameBuffer.s + retourne: + 0 si fichier non lu ( annulation de commande ... ) + 1 si OK +*/ +{ +int ii; +FILE * source; +wxString msg; + + ActiveScreen = GetScreen(); + + if( GetScreen()->IsModify() && !Append ) + { + if( !IsOK(this, _("Board Modified: Continue ?")) ) + return(0); + } + + m_SelTrackWidthBox_Changed = TRUE; + m_SelViaSizeBox_Changed = TRUE; + + if( Append ) + { + GetScreen()->m_FileName = wxEmptyString; + GetScreen()->SetModify(); + m_Pcb->m_Status_Pcb = 0; + } + + if( FullFileName == wxEmptyString) + { + msg = wxT("*") + PcbExtBuffer; + wxString FileName = + EDA_FileSelector(_("Board files:"), + wxEmptyString, /* Chemin par defaut */ + GetScreen()->m_FileName, /* nom fichier par defaut */ + PcbExtBuffer, /* extension par defaut */ + msg, /* Masque d'affichage */ + this, + wxFD_OPEN, + FALSE + ); + if ( FileName == wxEmptyString ) return FALSE; + GetScreen()->m_FileName = FileName; + } + + else GetScreen()->m_FileName = FullFileName; + + ///////////////////////// + /* Lecture Fichier PCB */ + ///////////////////////// + + source = wxFopen(GetScreen()->m_FileName,wxT("rt")); + if (source == NULL) + { + msg.Printf(_("File <%s> not found"),GetScreen()->m_FileName.GetData()) ; + DisplayError(this, msg) ; + return(0); + } + + + /* Lecture de l'entete et TEST si PCB format ASCII */ + GetLine(source, cbuf, &ii ); + if( strncmp( cbuf, "PCBNEW-BOARD",12) != 0) + { + fclose(source); + DisplayError(this, wxT("Unknown file type")); + return(0); + } + + SetTitle(GetScreen()->m_FileName); + SetLastProject(GetScreen()->m_FileName); + + // Rechargement de la configuration: + wxSetWorkingDirectory( wxPathOnly(GetScreen()->m_FileName) ); + if( Append ) ReadPcbFile(DC, source, TRUE); + else + { + Read_Config(GetScreen()->m_FileName); + + // Mise a jour du toolbar d'options + m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; + m_DisplayModText = DisplayOpt.DisplayModText ; + m_DisplayModEdge = DisplayOpt.DisplayModEdge; + m_DisplayPadFill = DisplayOpt.DisplayPadFill; + + ReadPcbFile(DC, source, FALSE); + } + + fclose(source); + + GetScreen()->ClrModify(); + + if( Append ) + { + GetScreen()->SetModify(); + GetScreen()->m_FileName.Printf( wxT("%s%cnoname%s"), + wxGetCwd().GetData(), DIR_SEP, PcbExtBuffer.GetData()); + } + + + /* liste des pads recalculee avec Affichage des messages d'erreur */ + build_liste_pads(); + + Affiche_Infos_Status_Pcb(this); + + g_SaveTime = time(NULL); + return(1); +} + + + +/***********************************************************/ +bool WinEDA_PcbFrame::SavePcbFile(const wxString & FileName) +/************************************************************/ +/* Sauvegarde du fichier PCB en format ASCII +*/ +{ +wxString old_name, FullFileName, msg; +bool saveok = TRUE; +FILE * dest; + + if( FileName == wxEmptyString ) + { + msg = wxT("*") + PcbExtBuffer; + FullFileName = EDA_FileSelector(_("Board files:"), + wxEmptyString, /* Chemin par defaut */ + GetScreen()->m_FileName, /* nom fichier par defaut */ + PcbExtBuffer, /* extension par defaut */ + msg, /* Masque d'affichage */ + this, + wxFD_SAVE, + FALSE + ); + if ( FullFileName == wxEmptyString ) return FALSE; + GetScreen()->m_FileName = FullFileName; + } + else GetScreen()->m_FileName = FileName; + + /* mise a jour date si modifications */ + if ( GetScreen()->IsModify() ) + { + GetScreen()->m_Date = GenDate(); + } + + /* Calcul du nom du fichier a creer */ + FullFileName = MakeFileName(wxEmptyString, GetScreen()->m_FileName, PcbExtBuffer); + + /* Calcul du nom du fichier de sauvegarde */ + old_name = FullFileName; + ChangeFileNameExt(old_name,wxT(".000")); + + /* Changement du nom de l'ancien fichier s'il existe */ + if ( wxFileExists(FullFileName) ) + { + /* conversion en *.000 de l'ancien fichier */ + wxRemoveFile(old_name); /* S'il y a une ancienne sauvegarde */ + if( ! wxRenameFile(FullFileName,old_name) ) + { + msg = _("Warning: unable to create bakfile ") + old_name; + DisplayError(this, msg, 15) ; + saveok = FALSE; + } + } + + else + { + old_name = wxEmptyString; saveok = FALSE; + } + + /* Sauvegarde de l'ancien fichier */ + dest = wxFopen(FullFileName, wxT("wt")); + if (dest == 0) + { + msg = _("Unable to create ") + FullFileName; + DisplayError(this, msg) ; + saveok = FALSE; + } + + if( dest ) + { + GetScreen()->m_FileName = FullFileName; + SetTitle(GetScreen()->m_FileName); + SavePcbFormatAscii(dest); + fclose(dest) ; + } + + /* Affichage des fichiers crees: */ + MsgPanel->EraseMsgBox(); + + if( saveok ) + { + msg = _("Backup file: ") + old_name; + Affiche_1_Parametre(this, 1,msg, wxEmptyString, CYAN); + } + + if ( dest ) msg = _("Write Board file: "); + else msg = _("Failed to create "); + msg += FullFileName; + + Affiche_1_Parametre(this, 1,wxEmptyString,msg, CYAN); + g_SaveTime = time(NULL); /* Reset delai pour sauvegarde automatique */ + GetScreen()->ClrModify(); + return TRUE; +} + diff --git a/pcbnew/find.cpp b/pcbnew/find.cpp new file mode 100644 index 0000000000..992132b0bf --- /dev/null +++ b/pcbnew/find.cpp @@ -0,0 +1,337 @@ + /***************************************************/ + /* PCBNEW - Gestion des Recherches (fonction Find) */ + /***************************************************/ + + /* Fichier find.cpp */ + +/* + Affichage et modifications des parametres de travail de PcbNew + Parametres = dimensions des via, pistes, isolements, options... +*/ + + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "id.h" + +#include "protos.h" + +#include "find.h" + +/* Fonctions locales */ + +/* variables locales */ +static wxString s_OldStringFound; +static int s_ItemCount, s_MarkerCount; + + +/*********************************************************************/ +void WinEDA_PcbFrame::InstallFindFrame(const wxPoint & pos, wxDC * DC) +/*********************************************************************/ +{ + WinEDA_PcbFindFrame * frame = new WinEDA_PcbFindFrame(this, DC, pos); + frame->ShowModal(); frame->Destroy(); +} + + + +/*******************************************************/ +void WinEDA_PcbFindFrame::FindItem(wxCommandEvent& event) +/********************************************************/ +{ +PCB_SCREEN * screen = m_Parent->GetScreen(); +wxPoint locate_pos; +wxString msg; +bool succes = FALSE; +bool FindMarker = FALSE; +MODULE * Module; +int StartCount; + + switch ( event.GetId() ) + { + case ID_FIND_ITEM: + s_ItemCount = 0; + break; + + case ID_FIND_MARKER: s_MarkerCount = 0; + case ID_FIND_NEXT_MARKER: + FindMarker = TRUE; + break; + } + + s_OldStringFound = m_NewText->GetValue(); + + m_Parent->DrawPanel->GetViewStart(&screen->m_StartVisu.x, &screen->m_StartVisu.y); + StartCount = 0; + + if( FindMarker ) + { + MARQUEUR * Marker = (MARQUEUR *) m_Parent->m_Pcb->m_Drawings; + for( ; Marker != NULL; Marker = (MARQUEUR *)Marker->Pnext) + { + if( Marker->m_StructType != TYPEMARQUEUR ) continue; + StartCount++; + if ( StartCount > s_MarkerCount ) + { + succes = TRUE; + locate_pos = Marker->m_Pos; + s_MarkerCount++; + break; + } + } + } + + else for ( Module = m_Parent->m_Pcb->m_Modules; Module != NULL; Module = (MODULE*)Module->Pnext) + { + if( WildCompareString( s_OldStringFound, Module->m_Reference->m_Text.GetData(), FALSE ) ) + { + StartCount++; + if ( StartCount > s_ItemCount ) + { + succes = TRUE; + locate_pos = Module->m_Pos; + s_ItemCount++; + break; + } + } + if( WildCompareString( s_OldStringFound, Module->m_Value->m_Text.GetData(), FALSE ) ) + { + StartCount++; + if ( StartCount > s_ItemCount ) + { + succes = TRUE; + locate_pos = Module->m_Pos; + s_ItemCount++; + break; + } + } + } + + if ( succes ) + { /* Il y a peut-etre necessite de recadrer le dessin: */ + if( ! m_Parent->DrawPanel->IsPointOnDisplay(locate_pos) ) + { + screen->m_Curseur = locate_pos; + m_Parent->Recadre_Trace(TRUE); + } + else + { // Positionnement du curseur sur l'item + m_Parent->DrawPanel->CursorOff(m_DC); + screen->m_Curseur = locate_pos; + GRMouseWarp(m_Parent->DrawPanel, screen->m_Curseur ); + m_Parent->DrawPanel->MouseToCursorSchema(); + m_Parent->DrawPanel->CursorOn(m_DC); + } + + if( FindMarker ) msg = _("Marker found"); + else msg.Printf( _("<%s> Found"), s_OldStringFound.GetData() ); + m_Parent->Affiche_Message(msg); + EndModal(1); + } + + else + { + m_Parent->Affiche_Message(wxEmptyString); + if( FindMarker ) msg = _("Marker not found"); + else msg.Printf( _("<%s> Not Found"), s_OldStringFound.GetData()); + DisplayError(this,msg, 10); + } + EndModal(0); +} + + + + +/*! + * WinEDA_PcbFindFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_PcbFindFrame, wxDialog ) + +/*! + * WinEDA_PcbFindFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_PcbFindFrame, wxDialog ) + +////@begin WinEDA_PcbFindFrame event table entries + EVT_BUTTON( ID_FIND_ITEM, WinEDA_PcbFindFrame::OnFindItemClick ) + + EVT_BUTTON( ID_FIND_NEXT_ITEM, WinEDA_PcbFindFrame::OnFindNextItemClick ) + + EVT_BUTTON( ID_FIND_MARKER, WinEDA_PcbFindFrame::OnFindMarkerClick ) + + EVT_BUTTON( ID_FIND_NEXT_MARKER, WinEDA_PcbFindFrame::OnFindNextMarkerClick ) + +////@end WinEDA_PcbFindFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_PcbFindFrame constructors + */ + +WinEDA_PcbFindFrame::WinEDA_PcbFindFrame( ) +{ +} + +WinEDA_PcbFindFrame::WinEDA_PcbFindFrame( WinEDA_BasePcbFrame *parent, wxDC * DC, + const wxPoint& pos, + wxWindowID id, const wxString& caption, const wxSize& size, long style ) +{ + m_Parent = parent; + m_DC = DC; + + Create(parent, id, caption, pos, size, style); + + m_NewText->SetFocus(); +} + +/*! + * WinEDA_PcbFindFrame creator + */ + +bool WinEDA_PcbFindFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_PcbFindFrame member initialisation + m_NewText = NULL; +////@end WinEDA_PcbFindFrame member initialisation + +////@begin WinEDA_PcbFindFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_PcbFindFrame creation + return true; +} + +/*! + * Control creation for WinEDA_PcbFindFrame + */ + +void WinEDA_PcbFindFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_PcbFindFrame content construction + // Generated by DialogBlocks, 04/03/2006 14:04:20 (unregistered) + + WinEDA_PcbFindFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxStaticText* itemStaticText3 = new wxStaticText( itemDialog1, wxID_STATIC, _("Item to find:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add(itemStaticText3, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_NewText = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add(m_NewText, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer2->Add(itemBoxSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer5->Add(itemBoxSizer6, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5); + + wxButton* itemButton7 = new wxButton( itemDialog1, ID_FIND_ITEM, _("Find Item"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton7->SetDefault(); + itemButton7->SetForegroundColour(wxColour(102, 0, 0)); + itemBoxSizer6->Add(itemButton7, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); + + wxButton* itemButton8 = new wxButton( itemDialog1, ID_FIND_NEXT_ITEM, _("Find Next Item"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton8->SetForegroundColour(wxColour(111, 0, 0)); + itemBoxSizer6->Add(itemButton8, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer5->Add(itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5); + + wxButton* itemButton10 = new wxButton( itemDialog1, ID_FIND_MARKER, _("Find Marker"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton10->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer9->Add(itemButton10, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); + + wxButton* itemButton11 = new wxButton( itemDialog1, ID_FIND_NEXT_MARKER, _("Find Next Marker"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton11->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer9->Add(itemButton11, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + +////@end WinEDA_PcbFindFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_PcbFindFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_PcbFindFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_PcbFindFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_PcbFindFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_PcbFindFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_PcbFindFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_PcbFindFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_ITEM + */ + +void WinEDA_PcbFindFrame::OnFindItemClick( wxCommandEvent& event ) +{ + FindItem(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_NEXT_ITEM + */ + +void WinEDA_PcbFindFrame::OnFindNextItemClick( wxCommandEvent& event ) +{ + FindItem(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_MARKER + */ + +void WinEDA_PcbFindFrame::OnFindMarkerClick( wxCommandEvent& event ) +{ + FindItem(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_NEXT_MARKER + */ + +void WinEDA_PcbFindFrame::OnFindNextMarkerClick( wxCommandEvent& event ) +{ + FindItem(event); +} + + diff --git a/pcbnew/find.h b/pcbnew/find.h new file mode 100644 index 0000000000..d0230d7b9a --- /dev/null +++ b/pcbnew/find.h @@ -0,0 +1,121 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: find.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 04/03/2006 13:58:04 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 04/03/2006 13:58:04 + +#ifndef _FIND_H_ +#define _FIND_H_ + +/*! + * Includes + */ + +////@begin includes +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_PCBFINDFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_PCBFINDFRAME_TITLE _("Find") +#define SYMBOL_WINEDA_PCBFINDFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_PCBFINDFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_PCBFINDFRAME_POSITION wxDefaultPosition +#define ID_TEXTCTRL 10001 +#define ID_FIND_ITEM 10002 +#define ID_FIND_NEXT_ITEM 10003 +#define ID_FIND_MARKER 10004 +#define ID_FIND_NEXT_MARKER 10005 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_PcbFindFrame class declaration + */ + +class WinEDA_PcbFindFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_PcbFindFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_PcbFindFrame( ); + WinEDA_PcbFindFrame( WinEDA_BasePcbFrame* parent, + wxDC * DC, const wxPoint& pos = SYMBOL_WINEDA_PCBFINDFRAME_POSITION, + wxWindowID id = SYMBOL_WINEDA_PCBFINDFRAME_IDNAME, + const wxString& caption = SYMBOL_WINEDA_PCBFINDFRAME_TITLE, + const wxSize& size = SYMBOL_WINEDA_PCBFINDFRAME_SIZE, long style = SYMBOL_WINEDA_PCBFINDFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PCBFINDFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PCBFINDFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PCBFINDFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PCBFINDFRAME_SIZE, long style = SYMBOL_WINEDA_PCBFINDFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_PcbFindFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_ITEM + void OnFindItemClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_NEXT_ITEM + void OnFindNextItemClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_MARKER + void OnFindMarkerClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_NEXT_MARKER + void OnFindNextMarkerClick( wxCommandEvent& event ); + +////@end WinEDA_PcbFindFrame event handler declarations + +////@begin WinEDA_PcbFindFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_PcbFindFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void FindItem(wxCommandEvent& event); + void FindMarker(wxCommandEvent& event); + +////@begin WinEDA_PcbFindFrame member variables + wxTextCtrl* m_NewText; +////@end WinEDA_PcbFindFrame member variables + + WinEDA_BasePcbFrame * m_Parent; + wxDC * m_DC; +}; + +#endif + // _FIND_H_ diff --git a/pcbnew/find.rc b/pcbnew/find.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/pcbnew/find.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/pcbnew/gen_modules_placefile.cpp b/pcbnew/gen_modules_placefile.cpp new file mode 100644 index 0000000000..04549bf3cf --- /dev/null +++ b/pcbnew/gen_modules_placefile.cpp @@ -0,0 +1,437 @@ + /*************************************/ + /* fichier gen_modules_placefile.cpp */ + /*************************************/ + +/* + 1 - create ascii files for automatic placement of smd components + 2 - create a module report (pos and module descr) (ascii file) +*/ +#include "fctsys.h" + +#include "common.h" +#include "pcbnew.h" +#include "trigo.h" + +class LIST_MOD /* Permet de lister les elements utiles des modules */ +{ +public: + MODULE * m_Module; + const wxChar * m_Reference; + const wxChar * m_Value; +}; + + +/* variables locale : */ +static wxPoint File_Place_Offset; /* Offset des coord de placement pour le fichier généré */ + +/* Routines Locales */ +static void WriteDrawSegmentPcb(DRAWSEGMENT * PtDrawSegment, FILE * rptfile); + +/* Routine de tri utilisee par GenereModulesPosition() */ +static int ListeModCmp(LIST_MOD * Ref, LIST_MOD * Cmp) +{ + return ( StrLenNumCmp(Ref->m_Reference, Cmp->m_Reference, 16) ); +} + + + +/**************************************************************/ +void WinEDA_PcbFrame::GenModulesPosition(wxCommandEvent& event) +/**************************************************************/ +/* Routine de generation du fichier de positionnement des modules, + utilisé pour les machines de placement de composants +*/ +{ +float conv_unit; +int NbMod, ii; +bool GenCu = FALSE; +MODULE * Module; +LIST_MOD * Liste; +char Line[1024], Buff[80]; +wxString NameLayerCu, NameLayerCmp, msg; +FILE * LayerCu = NULL, *LayerCmp = NULL; + + /* Calcul des echelles de conversion */ + conv_unit = 0.0001; /* unites = INCHES */ +// if(IF_DRILL_METRIC) conv_unit = 0.000254; /* unites = mm */ + + File_Place_Offset = m_Auxiliary_Axis_Position; + + /* Calcul du nombre de modules utiles ( Attribut CMS, non VIRTUAL ) ) */ + NbMod = 0; Module = m_Pcb->m_Modules; + for ( ; Module != NULL; Module = (MODULE*) Module->Pnext) + { + if( Module->m_Attributs & MOD_VIRTUAL ) continue; + if( (Module->m_Attributs & MOD_CMS) == 0 ) continue; + if( Module->m_Layer == CUIVRE_N) GenCu = TRUE; + NbMod++; + } + if ( NbMod == 0 ) + { + DisplayError(this, _("No Modules for Automated Placement"), 20); return; + } + + + /* Init nom fichier */ + NameLayerCmp = m_CurrentScreen->m_FileName; + ChangeFileNameExt(NameLayerCmp, wxT("-cmp.pos")); + + LayerCmp = wxFopen(NameLayerCmp, wxT("wt")); + if (LayerCmp == 0) + { + msg = _("Unable to create ") + NameLayerCu; + DisplayError(this, msg); return ; + } + + if( GenCu ) + { + NameLayerCu = m_CurrentScreen->m_FileName; + ChangeFileNameExt(NameLayerCu, wxT("-copper.pos")); + LayerCu = wxFopen(NameLayerCu, wxT("wt")); + if (LayerCu == 0) + { + msg = _("Unable to create ") + NameLayerCu; + DisplayError(this, msg); + fclose(LayerCmp); + return ; + } + } + + /* Affichage du bilan : */ + MsgPanel->EraseMsgBox(); + Affiche_1_Parametre(this,0,_("Component side place file:"),NameLayerCmp,BLUE); + + if( GenCu ) + Affiche_1_Parametre(this,32,_("Copper side place file:"),NameLayerCu,BLUE); + + msg.Empty(); msg << NbMod; + Affiche_1_Parametre(this,65, _("Module count"), msg, RED); + + + /* Etablissement de la liste des modules par ordre alphabetique */ + Liste = (LIST_MOD*) MyZMalloc( NbMod * sizeof(LIST_MOD) ); + + Module = (MODULE*)m_Pcb->m_Modules; + for( ii = 0; Module != NULL; Module = Module->Next() ) + { + if( Module->m_Attributs & MOD_VIRTUAL ) continue; + if( (Module->m_Attributs & MOD_CMS) == 0 ) continue; + + Liste[ii].m_Module = Module; + Liste[ii].m_Reference = Module->m_Reference->m_Text; + Liste[ii].m_Value = Module->m_Value->m_Text; + ii++; + } + + qsort(Liste, NbMod , sizeof(LIST_MOD), + (int(*)(const void *, const void*))ListeModCmp); + + + /* Generation entete du fichier 'commentaires) */ + sprintf(Line,"### Module positions - created on %s ###\n", + DateAndTime(Buff) ); + fputs(Line,LayerCmp); + if( GenCu ) fputs(Line,LayerCu); + + wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); + sprintf(Line,"### Printed by PcbNew version %s\n", CONV_TO_UTF8(Title) ); + fputs(Line,LayerCmp); + if( GenCu ) fputs(Line,LayerCu); + + sprintf(Line,"## Unit = inches, Angle = deg.\n"); + fputs(Line,LayerCmp); + if( GenCu ) fputs(Line,LayerCu); + + sprintf(Line,"## Side : Components\n"); + fputs(Line,LayerCmp); + + if( GenCu ) + { + sprintf(Line,"## Side : Copper\n"); + fputs(Line,LayerCu); + } + + sprintf(Line, + "# Ref Val PosX PosY Rot Side\n"); + fputs(Line,LayerCmp); + if( GenCu ) fputs(Line,LayerCu); + + /* Generation lignes utiles du fichier */ + for ( ii = 0 ; ii < NbMod; ii++) + { + wxPoint module_pos; + wxString ref = Liste[ii].m_Reference; + wxString val = Liste[ii].m_Value; + sprintf(Line,"%-8.8s %-16.16s ", CONV_TO_UTF8(ref), CONV_TO_UTF8(val) ); + + module_pos = Liste[ii].m_Module->m_Pos; + module_pos.x -= File_Place_Offset.x; + module_pos.y -= File_Place_Offset.y; + + char * text = Line + strlen(Line); + sprintf( text, " %9.4f %9.4f %8.1f ", + (float) module_pos.x * conv_unit, + (float) module_pos.y * conv_unit, + (float) Liste[ii].m_Module->m_Orient / 10); + // compensation bug francisation printf (float x.y généré x,y) + to_point(text); + + if (Liste[ii].m_Module->m_Layer == CMP_N) + { + strcat(Line,"Cmp.\n"); + fputs(Line, LayerCmp); + } + + else if (Liste[ii].m_Module->m_Layer == CUIVRE_N) + { + strcat(Line,"Cu\n"); + fputs(Line, LayerCu); + } + } + + /* Generation fin du fichier */ + fputs("## End\n", LayerCmp); + fclose(LayerCmp); + if( GenCu ) + { + fputs("## End\n", LayerCu); + fclose(LayerCu); + } + MyFree(Liste); + + msg = wxT("Cmp File: ") + NameLayerCmp; + if( GenCu ) msg += wxT("\nCu File: ") + NameLayerCu; + + DisplayInfo(this, msg); +} + + + +/**************************************************************/ +void WinEDA_PcbFrame::GenModuleReport(wxCommandEvent& event) +/**************************************************************/ +/* Print a module report. +*/ +{ +float conv_unit; +MODULE * Module; +D_PAD * pad; +char Line[1024], Buff[80]; +wxString FullFileName, NameLayerCmp, msg; +FILE * rptfile; +wxPoint module_pos; + + /* Calcul des echelles de conversion */ + conv_unit = 0.0001; /* unites = INCHES */ +// if(IF_DRILL_METRIC) conv_unit = 0.000254; /* unites = mm */ + + File_Place_Offset = wxPoint(0,0); + + /* Init nom fichier */ + FullFileName = m_CurrentScreen->m_FileName; + ChangeFileNameExt(FullFileName, wxT(".rpt")); + + rptfile = wxFopen(FullFileName, wxT("wt")); + if (rptfile == NULL) + { + msg = _("Unable to create ") + FullFileName; + DisplayError(this, msg); return ; + } + + /* Generation entete du fichier 'commentaires) */ + sprintf(Line,"## Module report - date %s\n", DateAndTime(Buff) ); + fputs(Line,rptfile); + + wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); + sprintf(Line,"## Created by PcbNew version %s\n", CONV_TO_UTF8(Title) ); + fputs(Line,rptfile); + fputs("## Unit = inches, Angle = deg.\n",rptfile); + + /* Generation lignes utiles du fichier */ + fputs("##\n", rptfile); + fputs("\n$BeginDESCRIPTION\n", rptfile); + + m_Pcb->ComputeBoundaryBox(); + fputs("\n$BOARD\n", rptfile); + fputs("unit INCH\n", rptfile); + sprintf(Line,"upper_left_corner %9.6f %9.6f\n", + (float) m_Pcb->m_BoundaryBox.GetX() * conv_unit, + (float) m_Pcb->m_BoundaryBox.GetY() * conv_unit); + to_point(Line); + fputs(Line, rptfile); + + sprintf(Line,"lower_right_corner %9.6f %9.6f\n", + (float) (m_Pcb->m_BoundaryBox.GetRight() ) * conv_unit, + (float) (m_Pcb->m_BoundaryBox.GetBottom() ) * conv_unit); + to_point(Line); + fputs(Line, rptfile); + + fputs("$EndBOARD\n\n", rptfile); + + Module = (MODULE*)m_Pcb->m_Modules; + for( ; Module != NULL; Module = Module->Next() ) + { + sprintf(Line,"$MODULE \"%s\"\n", CONV_TO_UTF8(Module->m_Reference->m_Text)); + fputs(Line, rptfile); + + sprintf(Line,"reference \"%s\"\n", CONV_TO_UTF8(Module->m_Reference->m_Text)); + fputs(Line, rptfile); + sprintf(Line,"value \"%s\"\n", CONV_TO_UTF8(Module->m_Value->m_Text)); + fputs(Line, rptfile); + sprintf(Line,"footprint \"%s\"\n", CONV_TO_UTF8(Module->m_LibRef)); + fputs(Line, rptfile); + + msg = wxT("attribut"); + if ( Module->m_Attributs & MOD_VIRTUAL ) msg += wxT(" virtual"); + if ( Module->m_Attributs & MOD_CMS ) msg += wxT(" smd"); + if ( (Module->m_Attributs & (MOD_VIRTUAL|MOD_CMS)) == 0 ) + msg += wxT(" none"); + msg += wxT("\n"); + fputs(CONV_TO_UTF8(msg), rptfile); + + module_pos = Module->m_Pos; + module_pos.x -= File_Place_Offset.x; + module_pos.y -= File_Place_Offset.y; + sprintf( Line, "position %9.6f %9.6f\n", + (float) module_pos.x * conv_unit, + (float) module_pos.y * conv_unit); + to_point(Line); + fputs(Line, rptfile); + + sprintf( Line, "orientation %.2f\n", (float) Module->m_Orient / 10); + to_point(Line); + if (Module->m_Layer == CMP_N) strcat(Line,"layer component\n"); + else if (Module->m_Layer == CUIVRE_N) strcat(Line,"layer copper\n"); + else strcat(Line,"layer other\n"); + fputs(Line, rptfile); + + Module->Write_3D_Descr( rptfile ); + + for ( pad = Module->m_Pads; pad != NULL; pad = pad->Next() ) + { + fprintf( rptfile,"$PAD \"%.4s\"\n", pad->m_Padname); + sprintf( Line, "position %9.6f %9.6f\n", + (float) pad->m_Pos0.x * conv_unit, + (float) pad->m_Pos0.y * conv_unit); + to_point(Line); + fputs(Line, rptfile); + sprintf( Line, "size %9.6f %9.6f\n", + (float) pad->m_Size.x * conv_unit, + (float) pad->m_Size.y * conv_unit); + to_point(Line); + fputs(Line, rptfile); + sprintf( Line, "drill %9.6f\n", (float) pad->m_Drill.x * conv_unit); + to_point(Line); + fputs(Line, rptfile); + sprintf( Line, "shape_offset %9.6f %9.6f\n", + (float) pad->m_Offset.x * conv_unit, + (float) pad->m_Offset.y * conv_unit); + to_point(Line); + fputs(Line, rptfile); + sprintf( Line, "orientation %.2f\n", (float) (pad->m_Orient - Module->m_Orient) / 10); + to_point(Line); + fputs(Line, rptfile); +char *shape_name[6] = {"??? ","Circ","Rect","Oval","trap","spec"} ; + sprintf( Line, "Shape %s\n", shape_name[pad->m_PadShape]); + fputs(Line, rptfile); + int layer = 0; + if(pad->m_Masque_Layer & CUIVRE_LAYER) layer = 1; + if(pad->m_Masque_Layer & CMP_LAYER) layer |= 2; +char *layer_name[4] = {"??? ","copper","component","all"} ; + sprintf( Line, "Layer %s\n", layer_name[layer]); + fputs(Line, rptfile); + fprintf( rptfile,"$EndPAD\n"); + } + + fprintf( rptfile,"$EndMODULE %s\n\n", Module->m_Reference->m_Text.GetData()); + } + + /* Write board Edges */ +EDA_BaseStruct * PtStruct; + for ( PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Pnext) + { + if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; + if( ((DRAWSEGMENT *) PtStruct)->m_Layer != EDGE_N ) continue; + WriteDrawSegmentPcb( (DRAWSEGMENT *) PtStruct, rptfile); + } + + /* Generation fin du fichier */ + fputs("$EndDESCRIPTION\n", rptfile); + fclose(rptfile); +} + + +/*******************************************************************/ +void WriteDrawSegmentPcb(DRAWSEGMENT * PtDrawSegment, FILE * rptfile) +/*******************************************************************/ +/* Sortie dsur rptfile d'un segment type drawing PCB: + Les contours sont de differents type: + segment + cercle + arc +*/ +{ +double conv_unit, ux0, uy0, dx, dy; +double rayon, width; +char Line[1024]; + + /* Calcul des echelles de conversion */ + conv_unit = 0.0001; /* unites = INCHES */ + /* coord de depart */ + ux0 = PtDrawSegment->m_Start.x * conv_unit; + uy0 = PtDrawSegment->m_Start.y * conv_unit; + /* coord d'arrivee */ + dx = PtDrawSegment->m_End.x * conv_unit; + dy = PtDrawSegment->m_End.y * conv_unit; + + width = PtDrawSegment->m_Width * conv_unit; + + switch (PtDrawSegment->m_Shape) + { + case S_CIRCLE: + rayon = hypot(dx-ux0,dy-uy0); + sprintf(Line,"$CIRCLE \n"); fputs(Line, rptfile); + sprintf( Line, "centre %.6lf %.6lf\n", ux0, uy0); + to_point(Line); fputs(Line, rptfile); + sprintf( Line, "radius %.6lf\n", rayon); + to_point(Line); fputs(Line, rptfile); + sprintf( Line, "width %.6lf\n", width); + to_point(Line); fputs(Line, rptfile); + sprintf(Line,"$EndCIRCLE \n"); + fputs(Line, rptfile); + break; + + case S_ARC: + { + int endx = PtDrawSegment->m_End.x, endy = PtDrawSegment->m_End.y; + rayon = hypot(dx-ux0,dy-uy0); + RotatePoint(&endx, &endy, PtDrawSegment->m_Start.x, PtDrawSegment->m_Start.y,PtDrawSegment->m_Angle); + sprintf(Line,"$ARC \n"); fputs(Line, rptfile); + sprintf( Line, "centre %.6lf %.6lf\n", ux0, uy0); + to_point(Line); fputs(Line, rptfile); + sprintf( Line, "start %.6lf %.6lf\n", endx * conv_unit, endy * conv_unit); + to_point(Line); fputs(Line, rptfile); + sprintf( Line, "end %.6lf %.6lf\n", dx, dy); + to_point(Line); fputs(Line, rptfile); + sprintf( Line, "width %.6lf\n", width); + to_point(Line); fputs(Line, rptfile); + sprintf(Line,"$EndARC \n"); + fputs(Line, rptfile); + } + break; + + default: + sprintf(Line,"$LINE \n"); + fputs(Line, rptfile); + sprintf( Line, "start %.6lf %.6lf\n", ux0, uy0); + to_point(Line); fputs(Line, rptfile); + sprintf( Line, "end %.6lf %.6lf\n", dx, dy); + to_point(Line); fputs(Line, rptfile); + sprintf( Line, "width %.6lf\n", width); + to_point(Line); fputs(Line, rptfile); + sprintf(Line,"$EndLINE \n"); + fputs(Line, rptfile); + break; + } +} + diff --git a/pcbnew/gen_self.h b/pcbnew/gen_self.h new file mode 100644 index 0000000000..47146cc069 --- /dev/null +++ b/pcbnew/gen_self.h @@ -0,0 +1,510 @@ + /****************************************************/ + /* Gestion des composants specifiques aux microndes */ + /* Generation d'une self */ + /****************************************************/ + + /* Fichier GEN_SELF.H */ + + +/* Fonctions locales */ + +static void Exit_Self(WinEDA_DrawPanel * Panel, wxDC *DC); +static EDGE_MODULE * gen_arc(EDGE_MODULE * PtSegm, int cX, int cY, int angle); +static void ShowCadreSelf(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); + + +/* structures locales */ +class SELFPCB // Definition d'une self constituee par une piste +{ +public: + int forme; // Serpentin, spirale .. + int orient; // 0..3600 + int valeur; // Valeur de la self + wxPoint m_Start; + wxPoint m_End; // Coord du point de depart et d'arrivee + wxSize m_Size; + D_PAD * pt_pad_start, *pt_pad_end; // Pointeurs sur les pads d'extremite + int lng; // Longueur de la piste constituant la self + int m_Width; // m_Size.xur de la piste + int nbrin; // Parametres de calcul: nombre de brins + int lbrin; // longueur du brin + int rayon; // Rayon des raccords entre brins + int delta; // distance aux pads +}; + +/* Variables locales */ +static SELFPCB Mself; +static int Self_On; +static int Bl_X0, Bl_Y0 , Bl_Xf, Bl_Yf; // Coord du cadre insrcivant la self + + +/*************************************************************************/ +static void ShowCadreSelf(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/*************************************************************************/ +/* Routine d'affichage a l'ecran du cadre de la self */ +{ +int deltaX, deltaY; + + /* Calcul de l'orientation et de la taille de la fenetre: + - orient = vert ou Horiz ( dimension max) + - Size.x = Size.y / 2 + */ + + GRSetDrawMode(DC, GR_XOR); + if( erase)/* effacement du cadre */ + { + GRRect( & panel->m_ClipBox, DC, Bl_X0, Bl_Y0, Bl_Xf, Bl_Yf, YELLOW); + } + + deltaX = (panel->GetScreen()->m_Curseur.x - Mself.m_Start.x) / 4; + deltaY = (panel->GetScreen()->m_Curseur.y - Mself.m_Start.y) / 4; + + Mself.orient = 900; + if( abs(deltaX) > abs(deltaY) ) Mself.orient = 0; + + if(Mself.orient == 0) + { + Bl_X0 = Mself.m_Start.x; + Bl_Y0 = Mself.m_Start.y - deltaX; + Bl_Xf = panel->GetScreen()->m_Curseur.x; + Bl_Yf = Mself.m_Start.y + deltaX; + } + else + { + Bl_X0 = Mself.m_Start.x - deltaY; + Bl_Y0 = Mself.m_Start.y; + Bl_Xf = Mself.m_Start.x + deltaY; + Bl_Yf = panel->GetScreen()->m_Curseur.y; + } + GRRect( & panel->m_ClipBox, DC, Bl_X0, Bl_Y0, Bl_Xf, Bl_Yf,YELLOW); +} + + +/*************************************************/ +void Exit_Self(WinEDA_DrawPanel * Panel, wxDC *DC) +/*************************************************/ +/* Routine de fermeture de l'application : ferme les commandes en cours */ +{ + if(Self_On) + { + Self_On = 0; + Panel->ManageCurseur(Panel, DC, 0); /* efface cadre */ + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + } +} + + +/*******************************************/ +void WinEDA_PcbFrame::Begin_Self( wxDC *DC) +/*******************************************/ +/* +Routine d'initialisation d'un trace de self +*/ +{ + + if ( Self_On ) + { + Genere_Self(DC); + return; + } + + Mself.m_Start = GetScreen()->m_Curseur; + + Self_On = 1; + + /* Mise a jour de l'origine des coord relatives */ + GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; + Affiche_Status_Box(); + + Bl_X0 = Mself.m_Start.x; Bl_Y0 = Mself.m_Start.y; + Bl_Xf = Bl_X0; Bl_Yf = Bl_Y0; + + DrawPanel->ManageCurseur = ShowCadreSelf; + DrawPanel->ForceCloseManageCurseur = Exit_Self; + DrawPanel->ManageCurseur(DrawPanel, DC, 0); /* Affiche cadre */ +} + +/**********************************************/ +MODULE * WinEDA_PcbFrame::Genere_Self( wxDC *DC) +/**********************************************/ +/* Genere une self en forme de serpentin + - longueur Mself.lng + - Extremites Mself.m_Start et Mself.m_End + - Contrainte: m_Start.x = m_End.x ( self verticale ) + ou m_Start.y = m_End.y ( self horizontale ) + + On doit determiner: + Mself.nbrin = nombre de segments perpendiculaires a la direction + ( le serpention aura nbrin + 1 demicercles + 2 1/4 de cercle) + Mself.lbrin = longueur d'un brin + Mself.rayon = rayon des parties arrondies du serpentin + Mself.delta = segments raccord entre extremites et le serpention lui meme + + Les equations sont + Mself.m_Size.x = 2*Mself.rayon + Mself.lbrin + Mself.m_Size.y = 2*Mself.delta + 2*Mself.nbrin*Mself.rayon + Mself.lng = 2*Mself.delta // Raccords au serpentin + + (Mself.nbrin-2) * Mself.lbrin //longueur des brins sauf 1er et dernier + + (Mself.nbrin+1) * ( PI * Mself.rayon) // longueur des arrondis + + Mself.lbrin/2 - Melf.rayon*2) // longueur du 1er et dernier brin + + Les contraintes sont: + nbrin >= 2 + Mself.rayon < Mself.m_Size.x + Mself.m_Size.y = Mself.rayon*4 + 2*Mself.raccord + Mself.lbrin > Mself.rayon *2 + + Le calcul est conduit de la facon suivante: + Initialement: + nbrin = 2 + rayon = 4 * m_Size.x (valeur fixe arbitraire) + puis: + on augmente le nombre de brins jusqu'a la longueur desiree + ( le rayon est diminue si necessaire ) + +*/ +{ +EDGE_MODULE * PtSegm, * LastSegm, *FirstSegm, * newedge; +MODULE * Module; +D_PAD * PtPad; +int ii, ll, lextbrin; +float fcoeff; +bool abort = FALSE; +wxString msg; + + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); /* efface cadre */ + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + + if(Self_On == 0) + { + DisplayError(this, wxT("Starting point not init..")); return NULL; + } + + Self_On = 0; + + Mself.m_End = m_CurrentScreen->m_Curseur; + + /* Agencement des parametres pour simplifier le calcul : */ + /* le point de depart doit avoir la coord depart < celle du point de fin */ + + if(Mself.orient == 0) // Self horizontale + { + Mself.m_End.y = Mself.m_Start.y; + if(Mself.m_Start.x > Mself.m_End.x) EXCHG(Mself.m_Start.x,Mself.m_End.x); + Mself.m_Size.y = Mself.m_End.x - Mself.m_Start.x; + Mself.lng = Mself.m_Size.y; + } + + else // Self verticale + { + Mself.m_End.x = Mself.m_Start.x; + if(Mself.m_Start.y > Mself.m_End.y) EXCHG(Mself.m_Start.y,Mself.m_End.y); + Mself.m_Size.y = Mself.m_End.y - Mself.m_Start.y; + Mself.lng = Mself.m_Size.y; + } + + /* Entree de la vraie longueur desiree */ + if( ! g_UnitMetric ) + { + fcoeff = 10000.0 ; + msg.Printf( wxT("%1.4f"), Mself.lng /fcoeff); + abort = Get_Message(_("Length(inch):"),msg, this); + } + else + { + fcoeff = 10000.0/25.4 ; + msg.Printf( wxT("%2.3f"), Mself.lng /fcoeff); + abort = Get_Message( _("Length(mm):"),msg, this); + } + if ( abort ) return NULL; + + double fval; + if ( ! msg.ToDouble(&fval) ) + { + DisplayError(this, _("Incorrect number, abort")); + return NULL; + } + Mself.lng = (int) round( fval * fcoeff ); + + /* Controle des valeurs ( ii = valeur minimale de la longueur */ + if( Mself.lng < Mself.m_Size.y ) + { + DisplayError(this, _("Requested length < minimum length")); + return NULL; + } + + /* Generation du composant: calcul des elements de la self */ + Mself.m_Width = g_DesignSettings.m_CurrentTrackWidth; + Mself.m_Size.x = Mself.m_Size.y / 2 ; + // Choix d'une Valeur de depart raisonnable pour le rayon des arcs de cercle + Mself.rayon = min(Mself.m_Width * 5, Mself.m_Size.x/4); + /* Calcul des parametres */ + + for ( Mself.nbrin = 2 ; ; Mself.nbrin++) + { + Mself.delta = (Mself.m_Size.y - ( Mself.rayon * 2 * Mself.nbrin ) ) / 2 ; + if(Mself.delta < Mself.m_Size.y / 10) // C.a.d. si m_Size.yeur self > m_Size.yeur specifiee + { // Reduction du rayon des arrondis + Mself.delta = Mself.m_Size.y / 10; + Mself.rayon = (Mself.m_Size.y - 2*Mself.delta) / ( 2 * Mself.nbrin) ; + if(Mself.rayon < Mself.m_Width) + { // Rayon vraiment trop petit... + Affiche_Message(_("Unable to create line: Requested length is too big")); + return NULL; + } + } + Mself.lbrin = Mself.m_Size.x - (Mself.rayon * 2); + lextbrin = (Mself.lbrin/2) - Mself.rayon; + ll = 2 * lextbrin ; // Longueur du 1er et dernier brin + ll += 2 * Mself.delta ; // Longueur des raccord au serpentin + ll += Mself.nbrin * (Mself.lbrin - 2); // longueur des autres brins + ll += ((Mself.nbrin+1) * 314 * Mself.rayon) /100 ; + + msg.Printf( _("Segm count = %d, Lenght = "), Mself.nbrin); + wxString stlen; + valeur_param(ll, stlen); msg += stlen; + Affiche_Message(msg); + if ( ll >= Mself.lng) break; + } + + /* Generation du composant : le calcul est fait self Verticale */ + if( Create_1_Module(DC, wxEmptyString) == NULL ) return NULL; + + Module = m_Pcb->m_Modules; + Module->m_LibRef = wxT("MuSelf"); + Module->m_Attributs = MOD_VIRTUAL | MOD_CMS; + Module->m_Flags = 0; + + Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); + + /* Generation des elements speciaux: drawsegments */ + LastSegm = (EDGE_MODULE*) Module->m_Drawings; + if( LastSegm ) while( LastSegm->Pnext) LastSegm = (EDGE_MODULE*)LastSegm->Pnext; + + FirstSegm = PtSegm = new EDGE_MODULE(Module); + if (LastSegm ) + { + LastSegm->Pnext = PtSegm; + PtSegm->Pback = LastSegm; + } + else + { + Module->m_Drawings = PtSegm; PtSegm->Pback = Module; + } + PtSegm->m_Start = Mself.m_Start; + PtSegm->m_End.x = Mself.m_Start.x; + PtSegm->m_End.y = PtSegm->m_Start.y + Mself.delta; + PtSegm->m_Width = Mself.m_Width; + PtSegm->m_Layer = Module->m_Layer; + PtSegm->m_Shape = S_SEGMENT; + + newedge = new EDGE_MODULE(Module); + newedge->Copy(PtSegm); + newedge->AddToChain(PtSegm); + PtSegm = newedge; + PtSegm->m_Start = PtSegm->m_End; + PtSegm = gen_arc(PtSegm,PtSegm->m_End.x - Mself.rayon, PtSegm->m_End.y, -900); + + if(lextbrin) + { + newedge = new EDGE_MODULE(Module); + newedge->Copy(PtSegm); + newedge->AddToChain(PtSegm); + PtSegm = newedge; + PtSegm->m_Start = PtSegm->m_End; + PtSegm->m_End.x -= lextbrin; + } + + /* Trace du serpentin */ + for (ii = 1 ; ii < Mself.nbrin; ii++) + { + int arc_angle; + newedge = new EDGE_MODULE(Module); + newedge->Copy(PtSegm); + newedge->AddToChain(PtSegm); + PtSegm = newedge; + PtSegm->m_Start = PtSegm->m_End; + if( ii & 1) /* brin d'ordre impair : cercles de sens > 0 */ + arc_angle = 1800; + else arc_angle = -1800; + + PtSegm = gen_arc(PtSegm, PtSegm->m_End.x, + PtSegm->m_End.y + Mself.rayon, arc_angle); + + if( ii < Mself.nbrin-1) + { + newedge = new EDGE_MODULE(Module); + newedge->Copy(PtSegm); + newedge->AddToChain(PtSegm); + PtSegm = newedge; + PtSegm->m_Start = PtSegm->m_End; + if( ii & 1) PtSegm->m_End.x += Mself.lbrin; + else PtSegm->m_End.x -= Mself.lbrin; + } + } + + /* Trace du point final */ + + if( ii & 1) /* brin final de sens > 0 */ + { + if(lextbrin) + { + newedge = new EDGE_MODULE(Module); + newedge->Copy(PtSegm); + newedge->AddToChain(PtSegm); + PtSegm = newedge; + PtSegm->m_Start = PtSegm->m_End; + PtSegm->m_End.x -= lextbrin; + } + + newedge = new EDGE_MODULE(Module); + newedge->Copy(PtSegm); + newedge->AddToChain(PtSegm); + PtSegm = newedge; + PtSegm->m_Start.x = PtSegm->m_End.x; PtSegm->m_Start.y = PtSegm->m_End.y; + PtSegm = gen_arc(PtSegm, PtSegm->m_End.x, PtSegm->m_End.y + Mself.rayon, 900); + } + else + { + if(lextbrin) + { + newedge = new EDGE_MODULE(Module); + newedge->Copy(PtSegm); + newedge->AddToChain(PtSegm); + PtSegm = newedge; + PtSegm->m_Start = PtSegm->m_End; + PtSegm->m_End.x += lextbrin; + } + newedge = new EDGE_MODULE(Module); + newedge->Copy(PtSegm); + newedge->AddToChain(PtSegm); + PtSegm = newedge; + PtSegm->m_Start = PtSegm->m_End; + PtSegm = gen_arc(PtSegm, PtSegm->m_End.x, PtSegm->m_End.y + Mself.rayon, -900); + } + + newedge = new EDGE_MODULE(Module); + newedge->Copy(PtSegm); + newedge->AddToChain(PtSegm); + PtSegm = newedge; + PtSegm->m_Start = PtSegm->m_End; + PtSegm->m_End = Mself.m_End; + PtSegm->Pnext = NULL; + + /* Rotation de la self si le trace doit etre horizontal : */ + LastSegm = PtSegm; + if ( Mself.orient == 0) + { + for( PtSegm = FirstSegm; PtSegm != NULL; PtSegm = (EDGE_MODULE*) PtSegm->Pnext ) + { + RotatePoint(&PtSegm->m_Start.x, &PtSegm->m_Start.y, + FirstSegm->m_Start.x, FirstSegm->m_Start.y, 900 ); + if( PtSegm != LastSegm ) + RotatePoint(&PtSegm->m_End.x, &PtSegm->m_End.y, + FirstSegm->m_Start.x, FirstSegm->m_Start.y, 900 ); + } + } + + /* Modif position ancre */ + Module->m_Pos.x = LastSegm->m_End.x; Module->m_Pos.y = LastSegm->m_End.y; + + /* Placement des 2 pads sur extremite */ + PtPad = new D_PAD(Module); + + Module->m_Pads = PtPad; PtPad->Pback = Module; + PtPad->SetPadName( wxT("1") ); + PtPad->m_Pos.x = LastSegm->m_End.x; PtPad->m_Pos.y = LastSegm->m_End.y; + PtPad->m_Pos0.x = PtPad->m_Pos.x - Module->m_Pos.x; + PtPad->m_Pos0.y = PtPad->m_Pos.y - Module->m_Pos.y; + PtPad->m_Size.x = PtPad->m_Size.y = LastSegm->m_Width; + PtPad->m_Masque_Layer = g_TabOneLayerMask[LastSegm->m_Layer]; + PtPad->m_Attribut = SMD; + PtPad->m_PadShape = CIRCLE; + PtPad->m_Rayon = PtPad->m_Size.x / 2; + + D_PAD * newpad = new D_PAD(Module); + newpad->Copy(PtPad); + newpad->AddToChain(PtPad); + PtPad = newpad; + PtPad->SetPadName( wxT("2") ); + PtPad->m_Pos.x = FirstSegm->m_Start.x; PtPad->m_Pos.y = FirstSegm->m_Start.y; + PtPad->m_Pos0.x = PtPad->m_Pos.x - Module->m_Pos.x; + PtPad->m_Pos0.y = PtPad->m_Pos.y - Module->m_Pos.y; + + /* Modif des positions textes */ + Module->Display_Infos(this); + Module->m_Value->m_Pos.x = Module->m_Reference->m_Pos.x = ( FirstSegm->m_Start.x + LastSegm->m_End.x ) /2 ; + Module->m_Value->m_Pos.y = Module->m_Reference->m_Pos.y = ( FirstSegm->m_Start.y + LastSegm->m_End.y ) /2 ; + + Module->m_Reference->m_Pos.y -= Module->m_Reference->m_Size.y; + Module->m_Value->m_Pos.y += Module->m_Value->m_Size.y; + + Module->m_Reference->m_Pos0.x = Module->m_Reference->m_Pos.x - Module->m_Pos.x; + Module->m_Reference->m_Pos0.y = Module->m_Reference->m_Pos.y - Module->m_Pos.y; + Module->m_Value->m_Pos0.x = Module->m_Value->m_Pos.x - Module->m_Pos.x; + Module->m_Value->m_Pos0.y = Module->m_Value->m_Pos.y - Module->m_Pos.y; + + /* Init des Coord locales des segments */ + for( PtSegm = FirstSegm; PtSegm != NULL; PtSegm = (EDGE_MODULE*) PtSegm->Pnext ) + { + PtSegm->m_Start0.x = PtSegm->m_Start.x - Module->m_Pos.x; + PtSegm->m_Start0.y = PtSegm->m_Start.y - Module->m_Pos.y; + PtSegm->m_End0.x = PtSegm->m_End.x - Module->m_Pos.x; + PtSegm->m_End0.y = PtSegm->m_End.y - Module->m_Pos.y; + } + + Module->Set_Rectangle_Encadrement(); + + Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); + + return Module; +} + + +/**************************************************************************/ +static EDGE_MODULE * gen_arc(EDGE_MODULE * PtSegm, int cX, int cY, int angle) +/**************************************************************************/ + +/* Genere un arc de EDGE_MODULE : + de centre cX,cY + d'angle "angle" + de point de depart donne dans la structure pointee par PtSegm, qui doit + entre a jour (type,net..) + Retourne un pointeur sur la derniere structure EDGE_MODULE generee +*/ +{ +int ii, nb_seg; +float alpha, beta, fsin, fcos; +int x0, xr0, y0, yr0; +EDGE_MODULE * newedge; + + angle = -angle; + y0 = PtSegm->m_Start.x - cX; x0 = PtSegm->m_Start.y - cY; + + nb_seg = (abs(angle)) / 225 ; if(nb_seg == 0) nb_seg = 1 ; + alpha = ( (float)angle * 3.14159 / 1800 ) / nb_seg; + + for ( ii = 1 ; ii <= nb_seg ; ii++ ) + { + if( ii > 1) + { + newedge = new EDGE_MODULE( (MODULE*) NULL); + newedge->Copy(PtSegm); + newedge->m_Parent = PtSegm->m_Parent; + newedge->AddToChain(PtSegm); + PtSegm = newedge; + PtSegm->m_Start.x = PtSegm->m_End.x; PtSegm->m_Start.y = PtSegm->m_End.y; + } + + beta = (alpha * ii); + fcos = cos(beta); fsin = sin(beta); + + xr0 = (int)(x0 * fcos + y0 * fsin); + yr0 = (int)(y0 * fcos - x0 * fsin); + PtSegm->m_End.x = cX + yr0; PtSegm->m_End.y = cY + xr0 ; + } + return( PtSegm ); +} + diff --git a/pcbnew/gendrill.cpp b/pcbnew/gendrill.cpp new file mode 100644 index 0000000000..ee3a796ab7 --- /dev/null +++ b/pcbnew/gendrill.cpp @@ -0,0 +1,1373 @@ + /***********************************************/ + /* Routine de Generation du fichier de percage */ + /***********************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "plot_common.h" +#include "trigo.h" +#include "pcbnew.h" +#include "pcbplot.h" +#include "autorout.h" +#include "macros.h" + +#include "protos.h" + + +/* + Generation du fichier de percage en format EXCELLON + Variantes supportees: + - Decimal : coord flottantes en pouces + - Metric : coord entieres en 1/10000 mm + format "Trailling Zero" ( TZ ) + + On peut aussi generer le plan de percage en format HPGL ou PS +*/ + +/* Routines importees */ + +class FORET +{ +public: + int m_TotalCount; + int m_OvalCount; + int m_Diameter; +}; + +/* drill precision format */ +class DrillPrecision +{ +public: + int m_lhs; + int m_rhs; + +public: + DrillPrecision(int l, int r) {m_lhs=l; m_rhs=r;} +}; + +/* zeros format */ +enum zeros_fmt { + DECIMAL_FORMAT, + SUPPRESS_LEADING, + SUPPRESS_TRAILING, + KEEP_ZEROS +}; + +/* Routines Locales */ +static void Fin_Drill(void); +static void PlotDrillSymbol(const wxPoint & position,int diametre,int num_forme,int format); +static void PlotOvalDrillSymbol(const wxPoint & position,const wxSize & size,int orient,int format); + +/* Variables locales : */ +static int DrillToolsCount; /* Nombre de forets a utiliser */ +static float conv_unit; /* coeff de conversion des unites drill / pcb */ +static bool Unit_Drill_is_Inch = TRUE; /* INCH,LZ (2:4) */ +static int s_Zeros_Format = DECIMAL_FORMAT; +static DrillPrecision s_Precision(2,4); +static bool DrillOriginIsAuxAxis; // Axis selection (main / auxiliary) for Drill Origin coordinates +static wxPoint File_Drill_Offset; /* Offset des coord de percage pour le fichier généré */ +static bool Minimal = false; +static bool Mirror = true; + +// Keywords for read and write config +#define ZerosFormatKey wxT("DrillZerosFormat") +#define LeftPrecisionKey wxT("DrillLeftPrecisionOpt") +#define RightPrecisionKey wxT("DrillRightPrecisionOpt") +#define MirrorKey wxT("DrillMirrorYOpt") +#define MinimalKey wxT("DrillMinHeader") +#define UnitDrillInchKey wxT("DrillUnit") +#define DrillOriginIsAuxAxisKey wxT("DrillAuxAxis") + +/****************************************/ +/* Dialog box for drill file generation */ +/****************************************/ +enum id_drill { + ID_CREATE_DRILL_FILES = 1370, + ID_CLOSE_DRILL, + ID_SEL_DRILL_UNITS, + ID_SEL_DRILL_SHEET, + ID_SEL_ZEROS_FMT, + ID_SEL_PRECISION +}; + +class WinEDA_DrillFrame: public wxDialog +{ + + WinEDA_PcbFrame * m_Parent; + wxRadioBox * m_Choice_Drill_Plan; + wxRadioBox * m_Choice_Unit; + wxRadioBox * m_Choice_Drill_Offset; + WinEDA_EnterText * m_EnterFileNameDrill; + WinEDA_ValueCtrl * m_ViaDrillCtrl; + WinEDA_ValueCtrl * m_PenSpeed; + WinEDA_ValueCtrl * m_PenNum; + wxCheckBox * m_Check_Mirror; + wxCheckBox * m_Check_Minimal; + wxRadioBox * m_Choice_Zeros_Format; + wxRadioBox * m_Choice_Precision; + + // Constructor and destructor +public: + WinEDA_DrillFrame(WinEDA_PcbFrame *parent); + ~WinEDA_DrillFrame(void) {}; + +private: + void OnQuit(wxCommandEvent& event); + void SetParams(void); + void GenDrillFiles(wxCommandEvent& event); + void GenDrillMap(int format); + void UpdatePrecisionOptions(wxCommandEvent& event); + void UpdateConfig(void); + int Plot_Drill_PcbMap( FORET * buffer, int format); + int Gen_Liste_Forets( FORET * buffer,bool print_header); + int Gen_Drill_File_EXCELLON( FORET * buffer); + void Gen_Line_EXCELLON(char *line, float x, float y); + void Init_Drill(void); + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(WinEDA_DrillFrame, wxDialog) + EVT_BUTTON(ID_CLOSE_DRILL, WinEDA_DrillFrame::OnQuit) + EVT_BUTTON(ID_CREATE_DRILL_FILES, WinEDA_DrillFrame::GenDrillFiles) + EVT_RADIOBOX(ID_SEL_DRILL_UNITS, WinEDA_DrillFrame::UpdatePrecisionOptions) + EVT_RADIOBOX(ID_SEL_ZEROS_FMT, WinEDA_DrillFrame::UpdatePrecisionOptions) +END_EVENT_TABLE() + +#define H_SIZE 550 +#define V_SIZE 250 +/*************************************************************************/ +WinEDA_DrillFrame::WinEDA_DrillFrame(WinEDA_PcbFrame *parent): + wxDialog(parent, -1, _("Drill tools"), wxDefaultPosition, wxSize(H_SIZE, V_SIZE), + DIALOG_STYLE) +/*************************************************************************/ +{ + m_Parent = parent; + SetFont(*g_DialogFont); + + SetReturnCode(1); + + wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(MainBoxSizer); + wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * MiddleBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(MiddleBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + + /* first column, NC drill options */ +wxString choice_unit_msg[] = + {_("millimeters"), _("inches") }; + m_Choice_Unit = new wxRadioBox(this, ID_SEL_DRILL_UNITS, + _("Drill Units:"), + wxDefaultPosition,wxSize(-1,-1), + 2,choice_unit_msg,1,wxRA_SPECIFY_COLS); + if ( Unit_Drill_is_Inch )m_Choice_Unit->SetSelection(1); + LeftBoxSizer->Add(m_Choice_Unit, 0, wxGROW|wxALL, 5); + +wxString choice_zeros_format_msg[] = { + _("decimal format"), + _("suppress leading zeros"), _("suppress trailing zeros"), _("keep zeros") + }; + m_Choice_Zeros_Format = new wxRadioBox(this, ID_SEL_ZEROS_FMT, + _("Zeros Format"), + wxDefaultPosition,wxSize(-1,-1), + 4,choice_zeros_format_msg,1,wxRA_SPECIFY_COLS); + m_Choice_Zeros_Format->SetSelection(s_Zeros_Format); + LeftBoxSizer->Add(m_Choice_Zeros_Format, 0, wxGROW|wxALL, 5); + +wxString *choice_precision_msg; +wxString choice_precision_inch_msg[] = { _("2:3"), _("2:4")}; +wxString choice_precision_metric_msg[] = { _("3:2"), _("3:3")}; + if (Unit_Drill_is_Inch) + choice_precision_msg = choice_precision_inch_msg; + else + choice_precision_msg = choice_precision_metric_msg; + m_Choice_Precision = new wxRadioBox(this, ID_SEL_PRECISION, + _("Precision"), + wxDefaultPosition, wxSize(-1,-1), + 2,choice_precision_msg,1,wxRA_SPECIFY_COLS); + LeftBoxSizer->Add(m_Choice_Precision, 0, wxGROW|wxALL, 5); + +wxString ps; + ps << s_Precision.m_lhs << wxT(":") << s_Precision.m_rhs; + m_Choice_Precision->SetStringSelection(ps); + if (s_Zeros_Format==DECIMAL_FORMAT) m_Choice_Precision->Enable(false); + +wxString choice_drill_offset_msg[] = + {_("absolute"), _("auxiliary axis")}; + m_Choice_Drill_Offset = new wxRadioBox(this, ID_SEL_DRILL_SHEET, + _("Drill Origine:"), + wxDefaultPosition,wxSize(-1,-1), + 2,choice_drill_offset_msg,1,wxRA_SPECIFY_COLS); + if ( DrillOriginIsAuxAxis ) m_Choice_Drill_Offset->SetSelection(1); + LeftBoxSizer->Add(m_Choice_Drill_Offset, 0, wxGROW|wxALL, 5); + + /* second column */ +wxString choice_drill_plan_msg[] = + {_("none"), _("drill sheet (HPGL)"), _("drill sheet (Postscript)")}; + m_Choice_Drill_Plan = new wxRadioBox(this, ID_SEL_DRILL_SHEET, + _("Drill Sheet:"), + wxDefaultPosition,wxSize(-1,-1), + 3,choice_drill_plan_msg,1,wxRA_SPECIFY_COLS); + MiddleBoxSizer->Add(m_Choice_Drill_Plan, 0, wxGROW|wxALL, 5); + + m_ViaDrillCtrl = new WinEDA_ValueCtrl(this, _("Via Drill"), + g_DesignSettings.m_ViaDrill, g_UnitMetric, MiddleBoxSizer, + m_Parent->m_InternalUnits); + + m_PenNum = new WinEDA_ValueCtrl(this, _("Pen Number"), + g_HPGL_Pen_Num, 2, MiddleBoxSizer, 1); + + m_PenSpeed = new WinEDA_ValueCtrl(this, _("Speed(cm/s)"), + g_HPGL_Pen_Speed, CENTIMETRE, MiddleBoxSizer, 1); + + m_Check_Mirror = new wxCheckBox(this, -1, _("mirror y axis")); + m_Check_Mirror->SetValue(Mirror); + MiddleBoxSizer->Add(m_Check_Mirror, 0, wxGROW|wxALL, 5); + + m_Check_Minimal = new wxCheckBox(this, -1, _("minimal header")); + m_Check_Minimal->SetValue(Minimal); + MiddleBoxSizer->Add(m_Check_Minimal, 0, wxGROW|wxALL, 5); + + /* third column, buttons */ + wxButton * Button = new wxButton(this, ID_CREATE_DRILL_FILES, + _("&Execute")); + Button->SetForegroundColour(*wxRED); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Button = new wxButton(this, ID_CLOSE_DRILL, _("&Close")); + Button->SetForegroundColour(*wxBLUE); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Centre(); + + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); +} + + +/**************************************/ +void WinEDA_DrillFrame::SetParams(void) +/**************************************/ +{ + Unit_Drill_is_Inch = (m_Choice_Unit->GetSelection() == 0) ? FALSE : TRUE; + Minimal = m_Check_Minimal->IsChecked(); + Mirror = m_Check_Mirror->IsChecked(); + s_Zeros_Format = m_Choice_Zeros_Format->GetSelection(); + DrillOriginIsAuxAxis = m_Choice_Drill_Offset->GetSelection(); + g_DesignSettings.m_ViaDrill = m_ViaDrillCtrl->GetValue(); + Unit_Drill_is_Inch = m_Choice_Unit->GetSelection(); + g_HPGL_Pen_Speed = m_PenSpeed->GetValue(); + g_HPGL_Pen_Num = m_PenNum->GetValue(); + if ( m_Choice_Drill_Offset->GetSelection() == 0) + File_Drill_Offset = wxPoint(0,0); + else + File_Drill_Offset = m_Parent->m_Auxiliary_Axis_Position; + + /* get precision from radio box strings (this just makes it easier to + change options later)*/ + wxString ps = m_Choice_Precision->GetStringSelection(); + wxString l=ps.substr(0,1); + wxString r=ps.substr(2,1); + l.ToLong((long*)&s_Precision.m_lhs); + r.ToLong((long*)&s_Precision.m_rhs); +} + + +/*****************************************************************/ +void WinEDA_PcbFrame::InstallDrillFrame(wxCommandEvent& event) +/*****************************************************************/ +/* Thi function display and delete the dialog frame for drill tools +*/ +{ +wxConfig * Config = m_Parent->m_EDA_Config; + if( Config ) + { + Config->Read(ZerosFormatKey, & s_Zeros_Format ); + Config->Read(LeftPrecisionKey, & s_Precision.m_lhs ); + Config->Read(RightPrecisionKey, & s_Precision.m_rhs ); + Config->Read(MirrorKey, &Mirror ); + Config->Read(MinimalKey, &Minimal ); + Config->Read(UnitDrillInchKey, &Unit_Drill_is_Inch ); + Config->Read(DrillOriginIsAuxAxisKey, &DrillOriginIsAuxAxis ); + } + +WinEDA_DrillFrame * frame = new WinEDA_DrillFrame(this); + + frame->ShowModal(); frame->Destroy(); +} + + +/******************************************/ +void WinEDA_DrillFrame::UpdateConfig(void) +/******************************************/ + /* Save drill options: */ +{ + SetParams(); + +wxConfig * Config = m_Parent->m_Parent->m_EDA_Config; + if( Config ) + { + Config->Write(ZerosFormatKey, s_Zeros_Format); + Config->Write(LeftPrecisionKey, s_Precision.m_lhs ); + Config->Write(RightPrecisionKey, s_Precision.m_rhs ); + Config->Write(MirrorKey, Mirror); + Config->Write(MinimalKey, Minimal); + Config->Write(UnitDrillInchKey, Unit_Drill_is_Inch); + Config->Write(DrillOriginIsAuxAxisKey, DrillOriginIsAuxAxis); + } +} + + +/****************************************************************/ +void WinEDA_DrillFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/****************************************************************/ +{ + UpdateConfig(); /* Save drill options: */ + Close(true); // true is to force the frame to close +} + + +/*************************************************************/ +void WinEDA_DrillFrame::GenDrillFiles(wxCommandEvent& event) +/*************************************************************/ +{ +int ii; +wxString FullFileName; +wxString msg; + + UpdateConfig(); /* set params and Save drill options */ + + m_Parent->MsgPanel->EraseMsgBox(); + + /* Calcul des echelles de conversion */ + conv_unit = 0.0001; /* unites = INCHES */ + if( ! Unit_Drill_is_Inch) conv_unit = 0.000254; /* unites = mm */ + + /* Init nom fichier */ + FullFileName = m_Parent->m_CurrentScreen->m_FileName; + ChangeFileNameExt(FullFileName, wxT(".drl") ); + + FullFileName = EDA_FileSelector(_("Drill file"), + wxEmptyString, /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + wxT(".drl"), /* extension par defaut */ + wxT("*.drl"), /* Masque d'affichage */ + this, + wxFD_SAVE, + TRUE + ); + if ( FullFileName != wxEmptyString ) + { + dest = wxFopen(FullFileName, wxT("w") ); + if (dest == 0) + { + msg = _("Unable to create file ") + FullFileName; + DisplayError(this, msg); + EndModal(0); + return ; + } + + /* Init : */ + Affiche_1_Parametre(m_Parent, 0,_("File"),FullFileName,BLUE) ; + + Init_Drill(); + + ii = Gen_Liste_Forets( (FORET *) adr_lowmem,TRUE); + msg.Printf( wxT("%d"),ii); + Affiche_1_Parametre(m_Parent, 30,_("Tools"), msg, BROWN); + + ii = Gen_Drill_File_EXCELLON( (FORET *) adr_lowmem); + msg.Printf( wxT("%d"),ii); + Affiche_1_Parametre(m_Parent, 45,_("Drill"), msg, GREEN); + + Fin_Drill(); + } + + switch ( m_Choice_Drill_Plan->GetSelection() ) + { + case 0: break; + case 1: + GenDrillMap(PLOT_FORMAT_HPGL); + break; + case 2: + GenDrillMap(PLOT_FORMAT_POST); + break; + } + + EndModal(0); +} + +/********************************************************************/ +void WinEDA_DrillFrame::UpdatePrecisionOptions(wxCommandEvent& event) +/********************************************************************/ +{ + if (m_Choice_Unit->GetSelection()==1) + { /* inch options */ + m_Choice_Precision->SetString(0,_("2:3")); + m_Choice_Precision->SetString(1,_("2:4")); + } + else + { /* metric options */ + m_Choice_Precision->SetString(0,_("3:2")); + m_Choice_Precision->SetString(1,_("3:3")); + } + if (m_Choice_Zeros_Format->GetSelection()==DECIMAL_FORMAT) + m_Choice_Precision->Enable(false); + else + m_Choice_Precision->Enable(true); +} + +/***************************************************************/ +int WinEDA_DrillFrame::Gen_Drill_File_EXCELLON( FORET * buffer) +/***************************************************************/ +/* Create the drill file in EXECELLON format + Return hole count + buffer: Drill tools list +*/ +{ +FORET * foret; +TRACK * pt_piste; +D_PAD * pt_pad; +MODULE * Module; +int ii, diam, nb_trous; +int x0, y0, xf, yf, xc, yc; +float xt,yt; +char line[1024]; + + /* Create the pad drill list : */ + nb_trous = 0; + + /* Examen de la liste des forets */ + for(ii = 0, foret = buffer; ii < DrillToolsCount; ii++, foret++) + { + sprintf(line,"T%d\n",ii+1); fputs(line,dest); + /* Read the via list */ + { + pt_piste = m_Parent->m_Pcb->m_Track; + for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext) + { + if(pt_piste->m_StructType != TYPEVIA) continue; + if ( pt_piste->m_Drill == 0 ) continue; + int via_drill = ( pt_piste->m_Drill < 0 ) ? g_DesignSettings.m_ViaDrill : pt_piste->m_Drill; + if ( foret->m_Diameter != via_drill ) + continue; + + x0 = pt_piste->m_Start.x - File_Drill_Offset.x; + y0 = pt_piste->m_Start.y - File_Drill_Offset.y; +// + if (!Mirror) y0 *= -1; + + xt = float(x0) * conv_unit; yt = float(y0) * conv_unit; + if(Unit_Drill_is_Inch) + { + Gen_Line_EXCELLON(line, xt, yt); + } +// + else + { /* metric 3:3 */ + Gen_Line_EXCELLON(line, xt*10, yt*10); + } + + // si les flottants sont ecrits avec , au lieu de . + // conversion , -> . necessaire ! + to_point( line ); + fputs(line,dest); + nb_trous++; + } + } + + /* Read pad list and create Drill infos for round holes only: */ + Module = m_Parent->m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*)Module->Pnext ) + { + /* Examen des pastilles */ + pt_pad = (D_PAD*) Module->m_Pads; + for ( ; pt_pad != NULL; pt_pad = (D_PAD*)pt_pad->Pnext ) + { + if ( pt_pad->m_DrillShape != CIRCLE ) continue; + diam = pt_pad->m_Drill.x; + if ( diam == 0 ) continue; + if(diam != foret->m_Diameter) continue; + + /* Compute the hole coordinates: */ + x0 = pt_pad->m_Pos.x - File_Drill_Offset.x; + y0 = pt_pad->m_Pos.y - File_Drill_Offset.y; +// + if (!Mirror) y0 *= -1; + + xt = float(x0) * conv_unit; yt = float(y0) * conv_unit; + if(Unit_Drill_is_Inch) + Gen_Line_EXCELLON(line, xt, yt); + else + Gen_Line_EXCELLON(line, xt*10, yt*10); + + to_point( line ); // Internationalization compensation (, to . for floats) + fputs(line,dest); + nb_trous++; + } /* Fin examen 1 module */ + } /* Fin 1 passe de foret */ + + /* Read pad list and create Drill infos for oblong holes only: */ + Module = m_Parent->m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*)Module->Pnext ) + { + /* Examen des pastilles */ + pt_pad = (D_PAD*) Module->m_Pads; + for ( ; pt_pad != NULL; pt_pad = (D_PAD*)pt_pad->Pnext ) + { + if ( pt_pad->m_DrillShape != OVALE ) continue; + + diam = MIN( pt_pad->m_Drill.x, pt_pad->m_Drill.y ) ; + if ( diam == 0 ) continue; + if(diam != foret->m_Diameter) continue; + + /* Compute the hole coordinates: */ + xc = x0 = xf = pt_pad->m_Pos.x - File_Drill_Offset.x; + yc = y0 = yf = pt_pad->m_Pos.y - File_Drill_Offset.y; + + /* Compute the start and end coordinates for the shape */ + if ( pt_pad->m_Drill.x < pt_pad->m_Drill.y ) + { + int delta = (pt_pad->m_Drill.y - pt_pad->m_Drill.x) / 2; + y0 -= delta; yf += delta; + } + else + { + int delta = (pt_pad->m_Drill.x - pt_pad->m_Drill.y) / 2; + x0 -= delta; xf += delta; + } + RotatePoint(&x0, &y0, xc, yc, pt_pad->m_Orient); + RotatePoint(&xf, &yf, xc, yc, pt_pad->m_Orient); +// + if (!Mirror) { y0 *= -1; yf *= -1; } + +// sprintf(line,"T%d\n",ii+1); fputs(line,dest); + + xt = float(x0) * conv_unit; yt = float(y0) * conv_unit; + if(Unit_Drill_is_Inch) + Gen_Line_EXCELLON(line, xt, yt); + else + Gen_Line_EXCELLON(line, xt*10, yt*10); + to_point( line ); + /* remove the '\n' from end of line: */ + for ( int kk = 0; line[kk] != 0; kk++ ) + if ( line[kk] == '\n' || line[kk] =='\r' ) + line[kk] = 0; + fputs(line,dest); + + fputs("G85",dest); + + xt = float(xf) * conv_unit; yt = float(yf) * conv_unit; + if(Unit_Drill_is_Inch) + Gen_Line_EXCELLON(line, xt, yt); + else + Gen_Line_EXCELLON(line, xt*10, yt*10); + to_point( line ); fputs(line,dest); + fputs("G05\n",dest); + nb_trous++; + } /* Fin examen 1 module */ + } /* fin analyse des trous de modules pour le foret en cours*/ + } /* fin analyse des forets */ + + return(nb_trous); +} + +/**********************************************************************/ +void WinEDA_DrillFrame::Gen_Line_EXCELLON(char *line, float x, float y) +/**********************************************************************/ +{ + wxString xs, ys; + int xpad = s_Precision.m_lhs + s_Precision.m_rhs; + int ypad = xpad; + /* I need to come up with an algorithm that handles any lhs:rhs format.*/ + /* one idea is to take more inputs for xpad/ypad when metric is used. */ + + switch (s_Zeros_Format) + { + default: + case DECIMAL_FORMAT: + sprintf(line,"X%.3fY%.3f\n", x, y); + break; + + case SUPPRESS_LEADING: /* that should work now */ + for (int i=0;i< s_Precision.m_rhs;i++) + { x*=10; y*=10; } + sprintf(line,"X%dY%d\n", (int) round(x), (int) round(y) ); + break; + + case SUPPRESS_TRAILING: + { + for (int i=0;i< s_Precision.m_rhs;i++) + { x *= 10; y*=10; } + if (x<0)xpad++; + if (y<0)ypad++; + + xs.Printf( wxT("%0*d"), xpad, (int) round(x) ); + ys.Printf( wxT("%0*d"), ypad, (int) round(y) ); + + size_t j=xs.Len()-1; + while (xs[j] == '0' && j) xs.Truncate(j--); + j=ys.Len()-1; + while (ys[j] == '0' && j) ys.Truncate(j--); + + sprintf(line, "X%sY%s\n", CONV_TO_UTF8(xs), CONV_TO_UTF8(ys)); + break; + } + + case KEEP_ZEROS: + for (int i=0;i< s_Precision.m_rhs;i++) + { x *= 10; y*=10; } + if (x<0)xpad++; + if (y<0)ypad++; + xs.Printf( wxT("%0*d"), xpad, (int) round(x) ); + ys.Printf( wxT("%0*d"), ypad, (int) round(y) ); + sprintf(line, "X%sY%s\n", CONV_TO_UTF8(xs), CONV_TO_UTF8(ys)); + break; + }; +} +/***************************************************/ + +/***************************************************/ +FORET * GetOrAddForet( FORET * buffer, int diameter) +/***************************************************/ +/* Search the drill tool for the diameter "diameter" + Create a new one if not found +*/ +{ +int ii; +FORET * foret; + + if(diameter == 0) return NULL; + + /* Search for an existing tool: */ + for(ii = 0, foret = buffer ; ii < DrillToolsCount; ii++, foret++) + { + if(foret->m_Diameter == diameter) /* found */ + return foret; + } + + /* No tool found, we must create a new one */ + DrillToolsCount ++; + foret->m_TotalCount = 0; + foret->m_OvalCount = 0; + foret->m_Diameter = diameter; + return foret; +} + +/* Sort function by drill value */ +int Sort_by_Drill_Value(void * foret1, void * foret2) +{ + return( ((FORET*)foret1)->m_Diameter - ((FORET*)foret2)->m_Diameter); +} + +/*********************************************************************/ +int WinEDA_DrillFrame::Gen_Liste_Forets( FORET * buffer, bool print_header) +/**********************************************************************/ +/* Etablit la liste des forets de percage, dans l'ordre croissant des + diametres + Retourne: + Nombre de Forets + + Mise a jour: DrillToolsCount = nombre de forets differents + Genere une liste de DrillToolsCount structures FORET a partir de buffer +*/ +{ +FORET * foret; +D_PAD * pt_pad; +MODULE * Module; +int ii, diam; +char line[1024]; + + DrillToolsCount = 0; foret = buffer; + + /* Create the via tools */ + TRACK * pt_piste = m_Parent->m_Pcb->m_Track; + for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext ) + { + if(pt_piste->m_StructType != TYPEVIA) continue; + if ( pt_piste->m_Drill == 0 ) continue; + int via_drill = g_DesignSettings.m_ViaDrill; + if ( pt_piste->m_Drill > 0 ) // Drill value is not the default value + via_drill = pt_piste->m_Drill; + foret = GetOrAddForet( buffer, via_drill); + if ( foret ) foret->m_TotalCount++; + } + + /* Create the pad tools : */ + Module = m_Parent->m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*)Module->Pnext ) + { + /* Examen des pastilles */ + pt_pad = (D_PAD*) Module->m_Pads; + for ( ; pt_pad != NULL; pt_pad = (D_PAD*)pt_pad->Pnext ) + { + if ( pt_pad->m_DrillShape == CIRCLE ) + diam = pt_pad->m_Drill.x; + else diam = MIN (pt_pad->m_Drill.x, pt_pad->m_Drill.y); + + if(diam == 0) continue; + + foret = GetOrAddForet( buffer, diam); + if ( foret ) + { + foret->m_TotalCount++; + if ( pt_pad->m_DrillShape == OVALE )foret->m_OvalCount++; + } + } /* Fin examen 1 module */ + } + + /* tri des forets par ordre de diametre croissant */ + qsort(buffer,DrillToolsCount,sizeof(FORET), + (int(*)(const void *, const void * ))Sort_by_Drill_Value); + + /* Generation de la section liste des outils */ + if (print_header) + { + for(ii = 0, foret = (FORET*) buffer ; ii < DrillToolsCount; ii++, foret++) + { +// + if (Unit_Drill_is_Inch) /* does it need T01, T02 or is T1,T2 ok?*/ + sprintf(line,"T%dC%.3f\n", ii+1, + float(foret->m_Diameter) * conv_unit); + else + sprintf(line,"T%dC%.3f\n", ii+1, + float(foret->m_Diameter) * conv_unit * 10.0); +// + to_point( line ); + fputs(line,dest); + } + fputs("%\n",dest); + if (!Minimal) fputs("M47\n",dest); /* Operator message */ + fputs("G05\n",dest); /* Drill mode */ + /* Units : */ + if (Unit_Drill_is_Inch && !Minimal) fputs("M72\n",dest); /* M72 = inch mode */ + else if (!Minimal) fputs("M71\n",dest); /* M71 = metric mode */ + } + + return(DrillToolsCount); +} + + +/***************************************/ +void WinEDA_DrillFrame::Init_Drill(void) +/***************************************/ +/* Print the DRILL file header */ +{ +char Line[256]; + + fputs("M48\n",dest); + + if (!Minimal) + { + DateAndTime(Line); + wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); + fprintf(dest,";DRILL file {%s} date %s\n",CONV_TO_UTF8(Title),Line); + fputs(";FORMAT={",dest); + fprintf(dest,"%s / absolute / ", + CONV_TO_UTF8(m_Choice_Precision->GetStringSelection())); + fprintf(dest,"%s / ",CONV_TO_UTF8(m_Choice_Unit->GetStringSelection())); + fprintf(dest,"%s}\n",CONV_TO_UTF8(m_Choice_Zeros_Format->GetStringSelection())); + + fputs("R,T\nVER,1\nFMAT,2\n",dest); + } + + if( Unit_Drill_is_Inch ) fputs("INCH",dest); // Si unites en INCHES + else fputs("METRIC",dest); // Si unites en mm + + switch(s_Zeros_Format) + { + case SUPPRESS_LEADING: + case DECIMAL_FORMAT: + fputs(",TZ\n",dest); + break; + + case SUPPRESS_TRAILING: + fputs(",LZ\n",dest); + break; + + case KEEP_ZEROS: + fputs(",TZ\n",dest); // TZ is acceptable when all zeros are kept + break; + + } + + if (!Minimal) + fputs("TCST,OFF\nICI,OFF\nATC,ON\n",dest); +} + +/************************/ +void Fin_Drill(void) +/************************/ +{ + //add if minimal here + fputs("T0\nM30\n",dest) ; fclose(dest) ; +} + + +/***********************************************/ +void WinEDA_DrillFrame::GenDrillMap(int format) +/***********************************************/ +/* Genere le plan de percage (Drill map) format HPGL ou POSTSCRIPT +*/ +{ +int ii, x, y; +int plotX, plotY, TextWidth; +FORET * foret; +int intervalle = 0, CharSize = 0; +EDA_BaseStruct * PtStruct; +int old_g_PlotOrient = g_PlotOrient; +wxString FullFileName, Mask(wxT("*")), Ext; +char line[1024]; +int dX, dY; +wxPoint BoardCentre; +int PlotMarge_in_mils = 400; // Margin in 1/1000 inch +int marge = PlotMarge_in_mils * U_PCB; +wxSize SheetSize; +float fTextScale = 1.0; +double scale_x = 1.0, scale_y = 1.0; +Ki_PageDescr * SheetPS = NULL; +wxString msg; + + /* Init extension */ + switch( format ) + { + case PLOT_FORMAT_HPGL: + Ext = wxT("-drl.plt"); + break; + + case PLOT_FORMAT_POST: + Ext = wxT("-drl.ps"); + break; + + default: + DisplayError (this, wxT("WinEDA_DrillFrame::GenDrillMap() error")); + return; + } + + /* Init file name */ + FullFileName = m_Parent->m_CurrentScreen->m_FileName; + ChangeFileNameExt(FullFileName,Ext) ; + Mask += Ext; + + FullFileName = EDA_FileSelector(_("Drill Map file"), + wxEmptyString, /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + Ext, /* extension par defaut */ + Mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + TRUE + ); + if ( FullFileName.IsEmpty()) return; + + g_PlotOrient = 0; + /* calcul des dimensions et centre du PCB */ + m_Parent->m_Pcb->ComputeBoundaryBox(); + + dX = m_Parent->m_Pcb->m_BoundaryBox.GetWidth(); + dY = m_Parent->m_Pcb->m_BoundaryBox.GetHeight(); + BoardCentre = m_Parent->m_Pcb->m_BoundaryBox.Centre(); + + // Calcul de l'echelle du dessin du PCB, + // Echelle 1 en HPGL, dessin sur feuille A4 en PS, + texte description des symboles + switch( format ) + { + case PLOT_FORMAT_HPGL: /* Calcul des echelles de conversion format HPGL */ + Scale_X = Scale_Y = 1.0; + scale_x = Scale_X * SCALE_HPGL; + scale_y = Scale_Y * SCALE_HPGL; + fTextScale = SCALE_HPGL; + SheetSize = m_Parent->m_CurrentScreen->m_CurrentSheet->m_Size; + SheetSize.x *= U_PCB; + SheetSize.y *= U_PCB; + g_PlotOffset.x = 0; + g_PlotOffset.y = (int)(SheetSize.y * scale_y); + break; + + case PLOT_FORMAT_POST: + { + // calcul en unites internes des dimensions de la feuille ( connues en 1/1000 pouce ) + SheetPS = &g_Sheet_A4; + SheetSize.x = SheetPS->m_Size.x * U_PCB; + SheetSize.y = SheetPS->m_Size.y * U_PCB; + float Xscale = (float) (SheetSize.x - (marge*2)) / dX; + float Yscale = (float) (SheetSize.y * 0.6 - (marge*2)) / dY; + + scale_x = scale_y = min(Xscale, Yscale); + + g_PlotOffset.x = - (SheetSize.x/2) + + (int)(BoardCentre.x * scale_x) + marge; + g_PlotOffset.y = SheetSize.y/2 + + (int)(BoardCentre.y * scale_y) - marge; + g_PlotOffset.y += SheetSize.y / 8 ; /* decalage pour legende */ + break; + } + } + + dest = wxFopen(FullFileName, wxT("wt") ); + if (dest == 0) + { + msg.Printf( _("Unable to create file <%s>"),FullFileName.GetData()) ; + DisplayError(this, msg); return ; + } + + /* Init : */ + m_Parent->MsgPanel->EraseMsgBox(); + Affiche_1_Parametre(m_Parent, 0,_("File"), FullFileName, BLUE); + + /* Calcul de la liste des diametres de percage (liste des forets) */ + ii = Gen_Liste_Forets( (FORET *) adr_lowmem, FALSE); + msg.Printf( wxT("%d"),ii); + Affiche_1_Parametre(m_Parent, 48, _("Tools"), msg, BROWN); + + + switch( format ) + { + case PLOT_FORMAT_HPGL: + InitPlotParametresHPGL(g_PlotOffset, scale_x, scale_y); + PrintHeaderHPGL(dest, g_HPGL_Pen_Speed,g_HPGL_Pen_Num); + break; + + case PLOT_FORMAT_POST: + { + int BBox[4]; + BBox[0] = BBox[1] = PlotMarge_in_mils; + BBox[2] = SheetPS->m_Size.x - PlotMarge_in_mils; + BBox[3] = SheetPS->m_Size.y - PlotMarge_in_mils; + InitPlotParametresPS(g_PlotOffset, SheetPS, + (double) 1.0 / PCB_INTERNAL_UNIT, (double) 1.0 / PCB_INTERNAL_UNIT); + SetDefaultLineWidthPS(10); // Set line with to 10/1000 inch + PrintHeaderPS(dest, wxT("PCBNEW-PS"), FullFileName, BBox); + InitPlotParametresPS(g_PlotOffset, SheetPS, scale_x, scale_y); + } + break; + + default: + break; + } + + /* Trace du contour ( couche EDGE ) */ + PtStruct = m_Parent->m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + PlotDrawSegment( (DRAWSEGMENT*) PtStruct, format, EDGE_LAYER ); + break; + + case TYPETEXTE: + PlotTextePcb((TEXTE_PCB*) PtStruct, format, EDGE_LAYER); + break; + + case TYPECOTATION: + PlotCotation((COTATION*) PtStruct, format, EDGE_LAYER); + break; + + case TYPEMIRE: + PlotMirePcb((MIREPCB*) PtStruct, format, EDGE_LAYER); + break; + + default: + DisplayError(this, wxT("WinEDA_DrillFrame::GenDrillMap() : Unexpected Draw Type") ); + break; + } + } + + TextWidth = (int)(50 * scale_x); // Set Drill Symbols width + + if( format == PLOT_FORMAT_POST ) + { + sprintf( line, "%d setlinewidth\n", TextWidth ); + fputs(line,dest); + } + + ii = Plot_Drill_PcbMap( (FORET *) adr_lowmem, format); + msg.Printf( wxT("%d"),ii); + Affiche_1_Parametre(m_Parent, 64, _("Drill"), msg,GREEN); + + /* Impression de la liste des symboles utilises */ + CharSize = 600; /* hauteur des textes en 1/10000 mils */ + float CharScale = 1.0; + TextWidth = (int)(50 * CharScale); // Set text width + intervalle = (int)(CharSize * CharScale) + TextWidth; + + switch( format) + { + case PLOT_FORMAT_HPGL: + { + /* generation des dim: commande SI x,y; x et y = dim en cm */ + char csize[256]; + sprintf(csize, "%2.3f", (float)CharSize * CharScale * 0.000254); + to_point(csize); + sprintf(line,"SI %s, %s;\n", csize, csize); + break; + } + + case PLOT_FORMAT_POST: + /* Reglage de l'epaisseur de traits des textes */ + sprintf( line,"%d setlinewidth\n", TextWidth ); + break; + + default: *line = 0; + break; + } + fputs(line,dest); + + switch( format ) + { + default: + case PLOT_FORMAT_POST: + g_PlotOffset.x = 0; + g_PlotOffset.y = 0; + InitPlotParametresPS(g_PlotOffset, SheetPS, scale_x, scale_x); + break; + + case PLOT_FORMAT_HPGL: + InitPlotParametresHPGL(g_PlotOffset, scale_x, scale_x); + break; + } + + /* Trace des informations */ + + /* Trace de "Infos" */ + plotX = marge + 1000; + plotY = CharSize + 1000; + x = plotX ; y = plotY; + x = +g_PlotOffset.x + (int)(x * fTextScale); + y = g_PlotOffset.y - (int)(y * fTextScale); + switch( format ) + { + case PLOT_FORMAT_HPGL: + sprintf(line,"PU %d, %d; LBInfos\03;\n", + x + (int)(intervalle * CharScale * fTextScale), + y - (int)(CharSize / 2 * CharScale * fTextScale) ); + fputs(line,dest); + break; + + case PLOT_FORMAT_POST: + wxString Text = wxT("Infos"); + Plot_1_texte(format, Text, 0, TextWidth, + x, y, + (int) (CharSize * CharScale), (int) (CharSize * CharScale), + FALSE); + break; + } + + plotY += (int)( intervalle * 1.2) + 200; + + for(ii = 0, foret = (FORET*)adr_lowmem ; ii < DrillToolsCount; ii++, foret++) + { + int plot_diam; + if ( foret->m_TotalCount == 0 ) continue; + + plot_diam = (int)(foret->m_Diameter * scale_x); + x = plotX; y = plotY; + x = -g_PlotOffset.x + (int)(x * fTextScale); + y = g_PlotOffset.y - (int)(y * fTextScale); + PlotDrillSymbol(wxPoint(x,y),plot_diam,ii, format); + + intervalle = (int)(CharSize * CharScale) + TextWidth; + intervalle = (int)( intervalle * 1.2); + + if ( intervalle < (plot_diam + 200 + TextWidth) ) intervalle = plot_diam + 200 + TextWidth; + + int rayon = plot_diam/2; + x = plotX + rayon + (int)(CharSize * CharScale); y = plotY; + x = -g_PlotOffset.x + (int)(x * fTextScale); + y = g_PlotOffset.y - (int)(y * fTextScale); + + /* Trace de la legende associee */ + switch( format ) + { + case PLOT_FORMAT_HPGL: + sprintf(line,"PU %d, %d; LB%2.2fmm / %2.3f\" (%d holes)", + x + (int)(intervalle * CharScale * fTextScale), + y - (int)(CharSize / 2 * CharScale * fTextScale), + float(foret->m_Diameter) * 0.00254, + float(foret->m_Diameter) * 0.0001, + foret->m_TotalCount ); + fputs(line,dest); + if ( foret->m_OvalCount ) + { + sprintf(line," (with %d oblongs)", foret->m_OvalCount ); + fputs(line,dest); + } + fputs("\03;\n",dest); + break; + + case PLOT_FORMAT_POST: + sprintf(line,"%2.2fmm / %2.3f\" (%d holes)", + float(foret->m_Diameter) * 0.00254, + float(foret->m_Diameter) * 0.0001, + foret->m_TotalCount ); + msg = CONV_FROM_UTF8(line); + if ( foret->m_OvalCount ) + { + sprintf(line," (with %d oblongs)", foret->m_OvalCount ); + msg += CONV_FROM_UTF8(line); + } + Plot_1_texte(format, msg, 0, TextWidth, + x, y, + (int) (CharSize * CharScale), + (int) (CharSize * CharScale), + FALSE); + break; + } + + plotY += intervalle; + } + + switch( format ) + { + case PLOT_FORMAT_HPGL: + CloseFileHPGL(dest); + break; + + case PLOT_FORMAT_POST: + CloseFilePS(dest); + break; + } + g_PlotOrient = old_g_PlotOrient; +} + + +/********************************************************************/ +int WinEDA_DrillFrame::Plot_Drill_PcbMap( FORET * buffer, int format) +/*********************************************************************/ +/* Trace la liste des trous a percer en format HPGL ou POSTSCRIPT + Retourne: + Nombre de trous + Utilise: + liste des forets pointee par buffer +*/ +{ +FORET * foret; +TRACK * pt_piste; +D_PAD * pt_pad; +MODULE * Module; +int ii , diam, nb_trous; +wxPoint pos; +wxSize size; + + nb_trous = 0; + + /* create the drill list */ + if ( DrillToolsCount > 13 ) + { + DisplayInfo(this, + _(" Drill map: Too many diameter values to draw to draw one symbol per drill value (max 13)\nPlot uses circle shape for some drill values"), 10); + } + + for(ii = 0, foret = (FORET*)buffer ; ii < DrillToolsCount; ii++, foret++) + { + /* create the via drill map */ + { + pt_piste = m_Parent->m_Pcb->m_Track; + for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext) + { + if(pt_piste->m_StructType != TYPEVIA) continue; + if(pt_piste->m_Drill == 0) continue; + + int via_drill = g_DesignSettings.m_ViaDrill; + if (pt_piste->m_Drill >= 0) via_drill = pt_piste->m_Drill; + pos = pt_piste->m_Start; + PlotDrillSymbol(pos, via_drill,ii, format); + + nb_trous++; + } + } + /* create the pad drill map: */ + for(Module = m_Parent->m_Pcb->m_Modules; Module != NULL; Module = (MODULE*)Module->Pnext) + { + pt_pad = (D_PAD*) Module->m_Pads; + for ( ; pt_pad != NULL; pt_pad = (D_PAD*)pt_pad->Pnext ) + { + switch ( pt_pad->m_DrillShape ) + { + case CIRCLE: + diam = pt_pad->m_Drill.x; + if(diam != foret->m_Diameter) continue; + PlotDrillSymbol(pt_pad->m_Pos, diam,ii, format); + break; + + case OVALE: + if ( pt_pad->m_DrillShape != OVALE ) continue; + diam = MIN( pt_pad->m_Drill.x, pt_pad->m_Drill.y ); + if(diam != foret->m_Diameter) continue; + PlotOvalDrillSymbol(pt_pad->m_Pos, pt_pad->m_Drill,pt_pad->m_Orient, format); + break; + } + + nb_trous++; + } /* Fin examen 1 module */ + } /* Fin 1 passe de foret */ + } /* fin analyse des trous de modules */ + + return(nb_trous); +} + + +/************************************************************************************/ +void PlotDrillSymbol(const wxPoint & position,int diametre,int num_forme, int format) +/************************************************************************************/ +/* Trace un motif de numero de forme num_forme, aux coord x0, y0. + x0, y0 = coordonnees tables + diametre = diametre (coord table) du trou + num_forme = index ( permet de gererer des formes caract ) +*/ +{ +int rayon = diametre / 2; +void (*FctPlume)(wxPoint pos, int state); +int x0, y0; + + x0 = position.x; y0 = position.y; + FctPlume = Move_Plume_HPGL; + if(format == PLOT_FORMAT_POST) FctPlume = LineTo_PS; + + switch( num_forme) + { + case 0: /* vias : forme en X */ + FctPlume( wxPoint(x0 - rayon, y0 - rayon), 'U'); + FctPlume( wxPoint(x0 + rayon, y0 + rayon), 'D'); + FctPlume( wxPoint(x0 + rayon, y0 - rayon), 'U'); + FctPlume( wxPoint(x0 - rayon, y0 + rayon), 'D'); + break; + + case 1: /* Cercle */ + if( format == PLOT_FORMAT_HPGL ) + trace_1_pastille_RONDE_HPGL(wxPoint(x0, y0), diametre, FILAIRE); + if( format == PLOT_FORMAT_POST ) + trace_1_pastille_RONDE_POST(wxPoint(x0, y0), diametre, FILAIRE); + break; + + case 2: /* forme en + */ + FctPlume( wxPoint(x0 , y0 - rayon),'U'); + FctPlume( wxPoint(x0 , y0 + rayon),'D'); + FctPlume( wxPoint(x0 + rayon, y0), 'U'); + FctPlume( wxPoint(x0 - rayon, y0), 'D'); + break; + + case 3: /* forme en X cercle */ + FctPlume( wxPoint(x0 - rayon, y0 - rayon),'U'); + FctPlume( wxPoint(x0 + rayon, y0 + rayon),'D'); + FctPlume( wxPoint(x0 + rayon, y0 - rayon),'U'); + FctPlume( wxPoint(x0 - rayon, y0 + rayon),'D'); + if( format == PLOT_FORMAT_HPGL ) + trace_1_pastille_RONDE_HPGL(wxPoint(x0, y0), diametre, FILAIRE); + if( format == PLOT_FORMAT_POST ) + trace_1_pastille_RONDE_POST(wxPoint(x0, y0), diametre, FILAIRE); + break; + + case 4: /* forme en cercle barre de - */ + FctPlume( wxPoint(x0 - rayon, y0), 'U'); + FctPlume( wxPoint(x0 + rayon, y0), 'D'); + if( format == PLOT_FORMAT_HPGL ) + trace_1_pastille_RONDE_HPGL(wxPoint(x0, y0), diametre, FILAIRE); + if( format == PLOT_FORMAT_POST ) + trace_1_pastille_RONDE_POST(wxPoint(x0, y0), diametre, FILAIRE); + break; + + case 5: /* forme en cercle barre de | */ + FctPlume( wxPoint(x0, y0 - rayon),'U'); + FctPlume( wxPoint(x0, y0 + rayon),'D'); + if( format == PLOT_FORMAT_HPGL ) + trace_1_pastille_RONDE_HPGL(wxPoint(x0, y0), diametre, FILAIRE); + if( format == PLOT_FORMAT_POST ) + trace_1_pastille_RONDE_POST(wxPoint(x0, y0), diametre, FILAIRE); + break; + + case 6: /* forme en carre */ + if( format == PLOT_FORMAT_HPGL ) + trace_1_pad_TRAPEZE_HPGL(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 0, FILAIRE) ; + if( format == PLOT_FORMAT_POST ) + trace_1_pad_TRAPEZE_POST(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 0, FILAIRE) ; + break; + + case 7: /* forme en losange */ + if( format == PLOT_FORMAT_HPGL ) + trace_1_pad_TRAPEZE_HPGL(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 450, FILAIRE) ; + if( format == PLOT_FORMAT_POST ) + trace_1_pad_TRAPEZE_POST(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 450, FILAIRE) ; + break; + + case 8: /* forme en carre barre par un X*/ + FctPlume( wxPoint(x0 - rayon, y0 - rayon),'U'); + FctPlume( wxPoint(x0 + rayon, y0 + rayon),'D'); + FctPlume( wxPoint(x0 + rayon, y0 - rayon),'U'); + FctPlume( wxPoint(x0 - rayon, y0 + rayon),'D'); + if( format == PLOT_FORMAT_HPGL ) + trace_1_pad_TRAPEZE_HPGL(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 0, FILAIRE) ; + if( format == PLOT_FORMAT_POST ) + trace_1_pad_TRAPEZE_POST(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 0, FILAIRE) ; + break; + + case 9: /* forme en losange barre par un +*/ + FctPlume( wxPoint(x0, y0 - rayon),'U'); + FctPlume( wxPoint(x0, y0 + rayon),'D'); + FctPlume( wxPoint(x0 + rayon, y0), 'U'); + FctPlume( wxPoint(x0 - rayon, y0), 'D'); + if( format == PLOT_FORMAT_HPGL ) + trace_1_pad_TRAPEZE_HPGL(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 450, FILAIRE); + if( format == PLOT_FORMAT_POST ) + trace_1_pad_TRAPEZE_POST(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 450, FILAIRE); + break; + + case 10: /* forme en carre barre par un '/' */ + FctPlume( wxPoint(x0 - rayon, y0 - rayon),'U'); + FctPlume( wxPoint(x0 + rayon, y0 + rayon),'D'); + if( format == PLOT_FORMAT_HPGL ) + trace_1_pad_TRAPEZE_HPGL(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 0, FILAIRE) ; + if( format == PLOT_FORMAT_POST ) + trace_1_pad_TRAPEZE_POST(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 0, FILAIRE) ; + break; + + case 11: /* forme en losange barre par un |*/ + FctPlume( wxPoint(x0, y0 - rayon), 'U'); + FctPlume( wxPoint(x0, y0 + rayon), 'D'); + if( format == PLOT_FORMAT_HPGL ) + trace_1_pad_TRAPEZE_HPGL(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 450, FILAIRE) ; + if( format == PLOT_FORMAT_POST ) + trace_1_pad_TRAPEZE_POST(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 450, FILAIRE) ; + break; + + case 12: /* forme en losange barre par un -*/ + FctPlume( wxPoint(x0 - rayon, y0), 'U'); + FctPlume( wxPoint(x0 + rayon, y0), 'D'); + if( format == PLOT_FORMAT_HPGL ) + trace_1_pad_TRAPEZE_HPGL(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 450, FILAIRE) ; + if( format == PLOT_FORMAT_POST ) + trace_1_pad_TRAPEZE_POST(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 450, FILAIRE) ; + break; + + default: + if( format == PLOT_FORMAT_HPGL ) + trace_1_pastille_RONDE_HPGL(wxPoint(x0, y0), diametre, FILAIRE); + if( format == PLOT_FORMAT_POST ) + trace_1_pastille_RONDE_POST(wxPoint(x0, y0), diametre, FILAIRE); + break; + } + if( format == PLOT_FORMAT_HPGL) Plume_HPGL('U'); +} + + +/*******************************************************************************************/ +void PlotOvalDrillSymbol(const wxPoint & position,const wxSize & size,int orient,int format) +/*******************************************************************************************/ +{ + switch( format ) + { + case PLOT_FORMAT_HPGL: + trace_1_pastille_OVALE_HPGL(position, size, orient, FILAIRE); + break; + case PLOT_FORMAT_POST: + trace_1_pastille_OVALE_POST(position, size, orient, FILAIRE); + break; + } +} diff --git a/pcbnew/globaleditpad.cpp b/pcbnew/globaleditpad.cpp new file mode 100644 index 0000000000..ff0d16a15b --- /dev/null +++ b/pcbnew/globaleditpad.cpp @@ -0,0 +1,327 @@ + /*************************/ + /* Edition des Pastilles */ + /*************************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "trigo.h" + +#include "drag.h" + +#include "protos.h" + +/* Variables Locales */ +static bool Pad_Shape_Filter = TRUE; +static bool Pad_Layer_Filter = TRUE; +static bool Pad_Orient_Filter = TRUE; +static bool Pad_Size_Change = TRUE; +static bool Pad_Shape_Change = FALSE; +static bool Pad_Orient_Change = FALSE; +static bool Pad_Drill_Change = TRUE; + +enum id_pad_global_edit +{ + ID_CHANGE_CURRENT_MODULE = 1900, + ID_CHANGE_ID_MODULES, + ID_CHANGE_GET_PAD_SETTINGS, + ID_CLOSE_PAD_GLOBAL_CHANGE +}; + + + /************************************/ + /* class WinEDA_PadGlobalEditFrame */ + /************************************/ + +class WinEDA_PadGlobalEditFrame: public wxDialog +{ +private: + + WinEDA_BasePcbFrame * m_Parent; + wxDC * m_DC; + D_PAD * CurrentPad; + wxCheckBox * m_Pad_Shape_Filter; + wxCheckBox * m_Pad_Layer_Filter; + wxCheckBox * m_Pad_Orient_Filter; + wxCheckBox * m_Pad_Size_Change; + wxCheckBox * m_Pad_Shape_Change; + wxCheckBox * m_Pad_Drill_Change; + wxCheckBox * m_Pad_Orient_Change; + +public: + // Constructor and destructor + WinEDA_PadGlobalEditFrame(WinEDA_BasePcbFrame *parent, + D_PAD * Pad, wxDC * DC, const wxPoint & pos); + ~WinEDA_PadGlobalEditFrame(void) + { + } + +private: + void PadPropertiesAccept(wxCommandEvent& event); + void OnQuit(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(WinEDA_PadGlobalEditFrame, wxDialog) + EVT_BUTTON(ID_CHANGE_CURRENT_MODULE, WinEDA_PadGlobalEditFrame::PadPropertiesAccept) + EVT_BUTTON(ID_CHANGE_ID_MODULES, WinEDA_PadGlobalEditFrame::PadPropertiesAccept) + EVT_BUTTON(ID_CHANGE_GET_PAD_SETTINGS, WinEDA_PadGlobalEditFrame::PadPropertiesAccept) + EVT_BUTTON(ID_CLOSE_PAD_GLOBAL_CHANGE, WinEDA_PadGlobalEditFrame::OnQuit) +END_EVENT_TABLE() + + +/********************************************************************************/ +WinEDA_PadGlobalEditFrame::WinEDA_PadGlobalEditFrame(WinEDA_BasePcbFrame *parent, + D_PAD * Pad,wxDC * DC, const wxPoint & framepos): + wxDialog(parent, -1, _("Pads Global Edit"), framepos, wxSize(310, 235), + DIALOG_STYLE) +/********************************************************************************/ +{ +wxPoint pos; +wxButton * Button; + + m_Parent = parent; + SetFont(*g_DialogFont); + m_DC = DC; + Centre(); + + CurrentPad = Pad; + + /* Creation des boutons de commande */ + pos.x = 150; pos.y = 10; + Button = new wxButton(this, ID_CHANGE_GET_PAD_SETTINGS, + _("Pad Settings"), pos); + Button->SetForegroundColour(wxColor(0,80,0)); + + pos.y += Button->GetDefaultSize().y + 10; + Button = new wxButton(this, ID_CHANGE_CURRENT_MODULE, + _("Change Module"), pos); + Button->SetForegroundColour(*wxRED); + + pos.y += Button->GetDefaultSize().y + 10; + Button = new wxButton(this, ID_CHANGE_ID_MODULES, + _("Change Id Modules"), pos); + Button->SetForegroundColour(*wxRED); + + pos.y += Button->GetDefaultSize().y + 10; + Button = new wxButton(this, ID_CLOSE_PAD_GLOBAL_CHANGE, + _("Cancel"), pos); + Button->SetForegroundColour(*wxBLUE); + + pos.x = 5; pos.y = 5; + + // Selection des filtres de selection des pads : + new wxStaticBox(this, -1, _("Pad Filter :"), pos, wxSize(130, 75) ); + pos.x += 5; pos.y += 18; + m_Pad_Shape_Filter = new wxCheckBox(this, -1, _("Shape Filter"), pos); + m_Pad_Shape_Filter->SetValue(Pad_Shape_Filter); + + pos.y += 18; + m_Pad_Layer_Filter = new wxCheckBox(this, -1, _("Layer Filter"), pos); + m_Pad_Layer_Filter->SetValue(Pad_Layer_Filter); + + pos.y += 18; + m_Pad_Orient_Filter = new wxCheckBox(this, -1, _("Orient Filter"), pos); + m_Pad_Orient_Filter->SetValue(Pad_Orient_Filter); + + // Items a editer + pos.x -= 5; pos.y += 25; + new wxStaticBox(this, -1, _("Change Items :"), pos, wxSize(130, 95) ); + pos.x += 5; pos.y += 18; + m_Pad_Size_Change = new wxCheckBox(this, -1, _("Change Size"), pos); + m_Pad_Size_Change->SetValue(Pad_Size_Change); + + pos.y += 18; + m_Pad_Shape_Change = new wxCheckBox(this, -1, _("Change Shape"), pos); + m_Pad_Shape_Change->SetValue(Pad_Shape_Change); + + pos.y += 18; + m_Pad_Drill_Change = new wxCheckBox(this, -1, _("Change Drill"), pos); + m_Pad_Drill_Change->SetValue(Pad_Drill_Change); + + pos.y += 18; + m_Pad_Orient_Change = new wxCheckBox(this, -1, _("Change Orient"), pos); + m_Pad_Orient_Change->SetValue(Pad_Orient_Change); + +} + +/**********************************************************************/ +void WinEDA_PadGlobalEditFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/**********************************************************************/ +{ + Close(true); // true is to force the frame to close +} + + + +/*************************************************************************/ +void WinEDA_PadGlobalEditFrame::PadPropertiesAccept(wxCommandEvent& event) +/*************************************************************************/ +/* Met a jour les differents parametres pour le composant en cours d'édition +*/ +{ +int returncode = 1; + + switch ( event.GetId() ) + { + case ID_CLOSE_PAD_GLOBAL_CHANGE: + EndModal(0); + + case ID_CHANGE_GET_PAD_SETTINGS: + m_Parent->InstallPadOptionsFrame(NULL, NULL, wxPoint(-1, -1) ); + break; + + case ID_CHANGE_ID_MODULES: + returncode = -1; + case ID_CHANGE_CURRENT_MODULE: + Pad_Shape_Filter = m_Pad_Shape_Filter->GetValue(); + Pad_Layer_Filter = m_Pad_Layer_Filter->GetValue(); + Pad_Orient_Filter = m_Pad_Orient_Filter->GetValue(); + Pad_Size_Change = m_Pad_Size_Change->GetValue(); + Pad_Shape_Change = m_Pad_Shape_Change->GetValue(); + Pad_Drill_Change = m_Pad_Drill_Change->GetValue(); + Pad_Orient_Change = m_Pad_Orient_Change->GetValue(); + EndModal(returncode); + break; + + } +} + + + +/***************************************************************************/ +void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD * Pad, wxDC * DC) +/***************************************************************************/ +/* +Routine de selection et de correction des dimensions des pastilles +de tous les modules + - semblables a l'module de reference selectionnee, + c.a.d de meme nom de librairie + - ou sur l'module localisee, selon le menu d'appel +*/ +{ +D_PAD* pt_pad ; +MODULE * Module_Ref , * Module; +int diag; +bool Edit_Same_Modules = FALSE; + + if( Pad == NULL ) return ; + + Module = (MODULE *) Pad->m_Parent; + + if ( Module == NULL ) + { + DisplayError(this, wxT("Global_Import_Pad_Settings() Error: NULL module")); + return; + } + +wxString ref_name_module = Module->m_LibRef; + + Module->Display_Infos(this); + +WinEDA_PadGlobalEditFrame * frame = new WinEDA_PadGlobalEditFrame(this, Pad,DC, + wxPoint(-1,-1)); + diag = frame->ShowModal(); frame->Destroy(); + + if ( (diag != 1) && (diag != -1) ) return; + if ( diag == -1 ) Edit_Same_Modules = TRUE; + + /* Recherche et copie du nom librairie de reference: */ + Module_Ref = Module; + + /* Mise a jour des modules ou du module */ + + Module = (MODULE*) m_Pcb->m_Modules; + for ( ; Module != NULL ; Module = (MODULE*) Module->Pnext ) + { + if( ! Edit_Same_Modules ) + if (Module != Module_Ref) continue; + + if( ref_name_module != Module->m_LibRef ) + continue ; + + Module->Display_Infos(this); + + /* Effacement du module */ + Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); + + pt_pad = (D_PAD*) Module->m_Pads; + for( ; pt_pad != NULL ; pt_pad = (D_PAD*) pt_pad->Pnext) + { + /* Filtrage des modifications interdites */ + if( Pad_Shape_Filter ) + { + if (pt_pad->m_PadShape != g_Pad_Master.m_PadShape) continue; + } + + if( Pad_Orient_Filter ) + { + if ( (pt_pad->m_Orient - Module->m_Orient) != g_Pad_Master.m_Orient) + continue; + } + + if( Pad_Layer_Filter ) + { + if (pt_pad->m_Masque_Layer != g_Pad_Master.m_Masque_Layer) continue; + else m_Pcb->m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK); + } + + /* Modif des caracteristiques : */ + if( Pad_Shape_Change ) + { + pt_pad->m_Attribut = g_Pad_Master.m_Attribut ; + pt_pad->m_PadShape = g_Pad_Master.m_PadShape ; + } + + pt_pad->m_Masque_Layer = g_Pad_Master.m_Masque_Layer; + + if( Pad_Size_Change ) + { + pt_pad->m_Size = g_Pad_Master.m_Size; + pt_pad->m_DeltaSize = g_Pad_Master.m_DeltaSize; + pt_pad->m_Offset = g_Pad_Master.m_Offset; + } + + if( Pad_Drill_Change ) + { + pt_pad->m_Drill = g_Pad_Master.m_Drill; + pt_pad->m_DrillShape = g_Pad_Master.m_DrillShape; + } + + if( Pad_Orient_Change ) + { + pt_pad->m_Orient = g_Pad_Master.m_Orient + Module->m_Orient; + } + /* Traitement des cas particuliers : */ + if( g_Pad_Master.m_PadShape != TRAPEZE ) + { + pt_pad->m_DeltaSize.x = 0; + pt_pad->m_DeltaSize.y = 0; + } + if( g_Pad_Master.m_PadShape == CIRCLE ) + pt_pad->m_Size.y = pt_pad->m_Size.x; + + switch( g_Pad_Master.m_Attribut & 0x7F) + { + case SMD: + case CONN : + pt_pad->m_Drill = wxSize(0,0); + pt_pad->m_Offset.x = 0; + pt_pad->m_Offset.y = 0; + } + + pt_pad->ComputeRayon(); + } + Module->Set_Rectangle_Encadrement(); + Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); + } + + GetScreen()->SetModify(); + +} + + + diff --git a/pcbnew/graphpcb.cpp b/pcbnew/graphpcb.cpp new file mode 100644 index 0000000000..b82310177c --- /dev/null +++ b/pcbnew/graphpcb.cpp @@ -0,0 +1,754 @@ + + /* EDITEUR de PCB: AUTOROUTAGE: routines "graphiques" */ + /******************************************************/ + + /* Fichier BOARD.CC */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "trigo.h" +#include "cell.h" + + +/* Routines externes */ + +/* routines internes */ +void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color ); +void DrawSegmentQcq(int ux0,int uy0,int ux1,int uy1,int lg,int layer, + int color, int op_logique); +void DrawHVSegment(int ux0,int uy0,int ux1,int uy1,int demi_largeur,int layer, + int color, int op_logique); + +void TraceFilledCercle(BOARD * Pcb, int cx, int cy, int rayon,int masque_layer, + int color, int op_logique); +void TraceCercle(int ux0,int uy0,int ux1,int uy1,int lg,int layer, + int color, int op_logique); + +void TraceArc(int ux0,int uy0,int ux1,int uy1,int ArcAngle, int lg,int layer, + int color, int op_logique); + +/* Macro d'appel de mise a jour de cellules */ +#define OP_CELL(layer,dy,dx) {if(layer < 0) \ + { \ + WriteCell(dy,dx,BOTTOM,color); \ + if(Nb_Sides) WriteCell(dy,dx,TOP,color);\ + } \ + else { \ + if(layer == Route_Layer_BOTTOM) WriteCell(dy,dx,BOTTOM,color);\ + if(Nb_Sides) \ + if(layer == Route_Layer_TOP) WriteCell(dy,dx,TOP,color);\ + } } + + +/******************************************************************************/ +void Place_1_Pad_Board(BOARD * Pcb, D_PAD * pt_pad, int color, int marge, int op_logique) +/******************************************************************************/ +/* Initialise a la valeur color, les cellules du Board comprises dans la + surface du pad pointe par pt_pad, avec la marge reservee pour l'isolement + et la demi largeur de la piste + Parametres: + pt_pad : pointeur sur la description du pad + color : masque a ecrire dans les cellules + marge : valeur a ajouter au rayon ou demi cote du pad + op_logique: type d'ecriture dans la cellule ( WRITE, OR ) +*/ +{ +int dx , dy; +wxPoint shape_pos = pt_pad->ReturnShapePos();; + + dx = pt_pad->m_Size.x / 2 ; dx += marge; + + if(pt_pad->m_PadShape == CIRCLE) + { + TraceFilledCercle(Pcb, shape_pos.x, shape_pos.y, dx, + pt_pad->m_Masque_Layer, color, op_logique); + return; + } + + + dy = pt_pad->m_Size.y / 2; dy += marge; + + if(pt_pad->m_PadShape == TRAPEZE) + { + dx += abs(pt_pad->m_DeltaSize.y) / 2; + dy += abs(pt_pad->m_DeltaSize.x) / 2; + } + + if( (pt_pad->m_Orient % 900) == 0 ) + { /* Le pad est un rectangle horizontal ou vertical */ + + if ( (pt_pad->m_Orient == 900 ) || (pt_pad->m_Orient == 2700) ) + { /* orient tournee de 90 deg */ + EXCHG(dx, dy) ; + } + + TraceFilledRectangle(Pcb, shape_pos.x - dx, shape_pos.y - dy, + shape_pos.x + dx, shape_pos.y + dy, + pt_pad->m_Masque_Layer, color, op_logique); + } + + else + { + TraceFilledRectangle(Pcb, shape_pos.x - dx, shape_pos.y - dy, + shape_pos.x + dx, shape_pos.y + dy, + (int) pt_pad->m_Orient, + pt_pad->m_Masque_Layer, color, op_logique); + } +} + + +/************************************************************************/ +void TraceFilledCercle(BOARD * Pcb, int cx, int cy, int rayon,int masque_layer, + int color, int op_logique) +/************************************************************************/ +/* Initialise a la valeur color, les cellules du Board comprises dans la + surface du cercle de centre cx,cy. + Parametres: + rayon : valeur a ajouter au rayon ou demi cote du pad + masque_layer = couches occupees + color : masque a ecrire dans les cellules + op_logique: type d'ecriture dans la cellule ( WRITE, OR ) +*/ +{ +int row, col; +int ux0 , uy0 , ux1, uy1; +int row_max, col_max, row_min, col_min; +int trace = 0; +float fdistmin, fdistx, fdisty; +void (*WriteCell)(int,int,int,BoardCell); +int tstwrite = 0; +int distmin; + + /* Determination des couches occupees : */ + + /* routage sur 1 seule couche: + sur bitmap BOTTOM et Route_Layer_B = Route_Layer_A*/ + + if(masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM]) + trace = 1; /* Trace sur BOTTOM */ + + if(masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) + if(Nb_Sides) + trace |= 2; /* Trace sur TOP */ + + if( trace == 0) return; + + switch(op_logique) + { + default: + case WRITE_CELL: WriteCell = SetCell; break; + case WRITE_OR_CELL: WriteCell = OrCell; break; + case WRITE_XOR_CELL: WriteCell = XorCell; break; + case WRITE_AND_CELL: WriteCell = AndCell; break; + case WRITE_ADD_CELL: WriteCell = AddCell; break; + } + + cx -= Pcb->m_BoundaryBox.m_Pos.x; cy -= Pcb->m_BoundaryBox.m_Pos.y; + + distmin = rayon ; + + /* Calcul du rectangle d'encadrement du cercle*/ + ux0 = cx - rayon; uy0 = cy - rayon; + ux1 = cx + rayon; uy1 = cy + rayon; + + /* Calcul des coord limites des cellules appartenant au rectangle */ + row_max = uy1 / g_GridRoutingSize; + col_max = ux1 / g_GridRoutingSize; + row_min = uy0 / g_GridRoutingSize;// if (uy0 > row_min*g_GridRoutingSize ) row_min++; + col_min = ux0 / g_GridRoutingSize;// if (ux0 > col_min*g_GridRoutingSize ) col_min++; + + if( row_min < 0 ) row_min = 0; + if( row_max >= (Nrows-1)) row_max = Nrows-1; + if( col_min < 0 ) col_min = 0; + if( col_max >= (Ncols-1)) col_max = Ncols-1; + + /* On s'assure que l'on place toujours au moins une cellule */ + if( row_min > row_max ) row_max = row_min; + if( col_min > col_max ) col_max = col_min; + + fdistmin = (float)distmin*distmin; + + for( row = row_min ;row <= row_max ; row++) + { + fdisty = (float)(cy - (row * g_GridRoutingSize)); + fdisty *= fdisty; + for(col = col_min; col <= col_max; col++) + { + fdistx = (float)(cx - (col * g_GridRoutingSize) ); + fdistx *= fdistx; + + if( fdistmin <= (fdistx + fdisty) ) continue; + + if(trace & 1) WriteCell(row,col,BOTTOM,color); + if(trace & 2) WriteCell(row,col,TOP,color); + tstwrite = 1; + } + } + +if (tstwrite) return; + + /* Si aucune cellule n'a ete ecrite, on touche les 4 voisins diagonaux + (cas defavorable: pad hors grille, au centre des 4 voisins diagonaux) */ + + distmin = g_GridRoutingSize/2 +1; + fdistmin = ((float)distmin*distmin) * 2; /* = dist centre au point diagonal*/ + + for( row = row_min ;row <= row_max ; row++) + { + fdisty = (float)(cy - (row * g_GridRoutingSize)); + fdisty *= fdisty; + for(col = col_min; col <= col_max; col++) + { + fdistx = (float)(cx - (col * g_GridRoutingSize) ); + fdistx *= fdistx; + + if( fdistmin <= (fdistx + fdisty) ) continue; + + if(trace & 1) WriteCell(row,col,BOTTOM,color); + if(trace & 2) WriteCell(row,col,TOP,color); + } + } +} + + + +/******************************************************************************/ +void TraceSegmentPcb(BOARD * Pcb, TRACK* pt_segm, int color, int marge, int op_logique ) +/******************************************************************************/ +/* trace un Segment de piste sur le BOARD de routage +*/ +{ +int demi_pas, demi_largeur; +int ux0 , uy0 , ux1, uy1; +int layer = pt_segm->m_Layer; + + + demi_pas = g_GridRoutingSize / 2; + demi_largeur = (pt_segm->m_Width / 2) + marge; + /* Calcul du rectangle d'encadrement du segment ( si H,V ou Via) */ + ux0 = pt_segm->m_Start.x - Pcb->m_BoundaryBox.m_Pos.x; + uy0 = pt_segm->m_Start.y - Pcb->m_BoundaryBox.m_Pos.y; + ux1 = pt_segm->m_End.x - Pcb->m_BoundaryBox.m_Pos.x; + uy1 = pt_segm->m_End.y - Pcb->m_BoundaryBox.m_Pos.y; + + if ( color == VIA_IMPOSSIBLE ) layer = -1; + + /* Test si VIA (cercle plein a tracer) */ + if(pt_segm->m_StructType == TYPEVIA ) + { + TraceFilledCercle(Pcb, pt_segm->m_Start.x, pt_segm->m_Start.y, demi_largeur, + 0x0000FFFF, color, op_logique); + return; + } + + /* Le segment est ici un segment de droite ou un cercle ou un arc: */ + if( pt_segm->m_Shape == S_CIRCLE ) + { + TraceCercle(ux0,uy0,ux1,uy1,demi_largeur,layer,color,op_logique); + return; + } + + if( pt_segm->m_Shape == S_ARC ) + { + TraceArc(ux0,uy0,ux1,uy1,pt_segm->m_Param,demi_largeur,layer,color,op_logique); + return; + } + + /* Le segment est ici un segment de droite */ + if( (ux0 != ux1) && (uy0 != uy1) ) // segment incline + { + DrawSegmentQcq(ux0,uy0,ux1,uy1,demi_largeur,layer,color,op_logique); + return; + } + + // Ici le segment est HORIZONTAL ou VERTICAL +// DrawHVSegment(ux0,uy0,ux1,uy1,demi_largeur,layer,color,op_logique); //F4EXB 051018-01 + DrawSegmentQcq(ux0,uy0,ux1,uy1,demi_largeur,layer,color,op_logique); //F4EXB 051018-01 + return; //F4EXB 051018-01 + +} + + +/******************************************************************************************/ +void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op_logique ) +/******************************************************************************************/ +/* trace une ligne; si layer = -1 sur toutes les couches +*/ +{ +int dx, dy , lim; +int cumul, inc, il, delta; +void (*WriteCell)(int,int,int,BoardCell); + + switch(op_logique) + { + default: + case WRITE_CELL: WriteCell = SetCell; break; + case WRITE_OR_CELL: WriteCell = OrCell; break; + case WRITE_XOR_CELL: WriteCell = XorCell; break; + case WRITE_AND_CELL: WriteCell = AndCell; break; + case WRITE_ADD_CELL: WriteCell = AddCell; break; + } + + if( x0 == x1 ) // ligne verticale + { + if(y1 < y0 ) EXCHG (y0,y1); + dy = y0 / g_GridRoutingSize; lim = y1 / g_GridRoutingSize ; + dx = x0 / g_GridRoutingSize; + /* Clipping aux limites du board */ + if( (dx < 0) || (dx >= Ncols) ) return; + if( dy < 0 ) dy = 0; + if( lim >= Nrows ) lim = Nrows-1; + for( ; dy <= lim ; dy ++ ) + { + OP_CELL(layer,dy,dx); + } + return; + } + + if( y0 == y1 ) // ligne horizontale + { + if(x1 < x0 ) EXCHG (x0,x1); + dx = x0 / g_GridRoutingSize; lim = x1 / g_GridRoutingSize ; + dy = y0 / g_GridRoutingSize; + /* Clipping aux limites du board */ + if( (dy < 0) || (dy >= Nrows) ) return; + if( dx < 0 ) dx = 0; + if( lim >= Ncols ) lim = Ncols-1; + for( ; dx <= lim ; dx ++ ) + { + OP_CELL(layer,dy,dx); + } + return; + } + + /* Ici l'angle est quelconque: on utilise l'algorithme de LUCAS */ + if ( abs(x1-x0) >= abs(y1-y0) ) /* segment peu incline */ + { + if(x1 < x0) {EXCHG(x1,x0); EXCHG(y1,y0) ;} + + dx = x0 / g_GridRoutingSize; lim = x1 / g_GridRoutingSize ; + dy = y0 / g_GridRoutingSize; + inc = 1; if( y1 < y0) inc = -1; + il = lim - dx; cumul = il / 2; delta = abs(y1 - y0)/g_GridRoutingSize; + for( ; dx <= lim ; ) + { + if( (dx >= 0) && (dy >= 0) && + (dx < Ncols) && (dy < Nrows) ) + { + OP_CELL(layer,dy,dx); + } + dx++; cumul += delta ; + if(cumul > il ) + { + cumul -= il; dy += inc; + } + } + } + else + { + if(y1 < y0) {EXCHG(x1,x0); EXCHG(y1,y0) ;} + + dy = y0 / g_GridRoutingSize; lim = y1 / g_GridRoutingSize ; + dx = x0 / g_GridRoutingSize; + inc = 1; if( x1 < x0) inc = -1; + il = lim - dy; cumul = il /2; delta = abs(x1 - x0)/g_GridRoutingSize; + for( ; dy <= lim ; ) + { + if( (dx >= 0) && (dy >= 0) && + (dx < Ncols) && (dy < Nrows) ) + { + OP_CELL(layer,dy,dx); + } + dy++; cumul += delta ; + if(cumul > il ) + { + cumul -= il; dx += inc; + } + } + } +} + +/*****************************************************************/ +void TraceFilledRectangle(BOARD * Pcb, + int ux0, int uy0, int ux1, int uy1, + int masque_layer, int color, int op_logique) +/*****************************************************************/ +/* Fonction Surchargee. + + Met a la valeur color l'ensemble des cellules du board inscrites dans + le rectangle de coord ux0,uy0 ( angle haut a gauche ) + a ux1,uy1 ( angle bas a droite ) + Le rectangle est horizontal ( ou vertical ) + Coordonnees PCB. +*/ +{ +int row, col; +int row_min, row_max, col_min, col_max; +int trace = 0; +void (*WriteCell)(int,int,int,BoardCell); + + if(masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM]) + trace = 1; /* Trace sur BOTTOM */ + + if( (masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) && Nb_Sides) + trace |= 2; /* Trace sur TOP */ + + if(trace == 0) return; + + switch(op_logique) + { + default: + case WRITE_CELL: WriteCell = SetCell; break; + case WRITE_OR_CELL: WriteCell = OrCell; break; + case WRITE_XOR_CELL: WriteCell = XorCell; break; + case WRITE_AND_CELL: WriteCell = AndCell; break; + case WRITE_ADD_CELL: WriteCell = AddCell; break; + } + + ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y; + ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y; + + /* Calcul des coord limites des cellules appartenant au rectangle */ + row_max = uy1 / g_GridRoutingSize; + col_max = ux1 / g_GridRoutingSize; + row_min = uy0 / g_GridRoutingSize; if (uy0 > row_min*g_GridRoutingSize ) row_min++; + col_min = ux0 / g_GridRoutingSize; if (ux0 > col_min*g_GridRoutingSize ) col_min++; + + if( row_min < 0 ) row_min = 0; + if( row_max >= (Nrows-1)) row_max = Nrows-1; + if( col_min < 0 ) col_min = 0; + if( col_max >= (Ncols-1)) col_max = Ncols-1; + + for( row = row_min ;row <= row_max ; row++) + { + for(col = col_min;col <= col_max; col++) + { + if(trace & 1) WriteCell(row,col,BOTTOM,color); + if(trace & 2) WriteCell(row,col,TOP,color); + } + } +} + + +/***********************************************************************************/ +void TraceFilledRectangle(BOARD * Pcb, int ux0, int uy0, int ux1, int uy1, int angle, + int masque_layer, int color, int op_logique) +/***********************************************************************************/ + +/* Fonction Surchargee. + + Met a la valeur color l'ensemble des cellules du board inscrites dans + le rectangle de coord ux0,uy0 ( angle haut a droite ) + a ux1,uy1 ( angle bas a gauche ) + Le rectangle est tourne de la valeur angle (en 0,1 degres) + Coordonnees PCB. +*/ +{ +int row, col; +int cx, cy; /* Centre du rectangle */ +int rayon; /* rayon du cercle exinscrit */ +int row_min, row_max, col_min, col_max; +int rotrow, rotcol; +int trace = 0; +void (*WriteCell)(int,int,int,BoardCell); + + if(masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM]) + trace = 1; /* Trace sur BOTTOM */ + + if(masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) + if(Nb_Sides) + trace |= 2; /* Trace sur TOP */ + + if(trace == 0) return; + + switch(op_logique) + { + default: + case WRITE_CELL: WriteCell = SetCell; break; + case WRITE_OR_CELL: WriteCell = OrCell; break; + case WRITE_XOR_CELL: WriteCell = XorCell; break; + case WRITE_AND_CELL: WriteCell = AndCell; break; + case WRITE_ADD_CELL: WriteCell = AddCell; break; + } + + ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y; + ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y; + + cx = (ux0 + ux1) / 2; cy = (uy0 + uy1) / 2; + rayon = (int) sqrt( (float)(cx - ux0) * (cx - ux0) + + (float)(cy - uy0) * (cy - uy0) ); + + /* Calcul des coord limites des cellules appartenant au rectangle */ + row_max = (cy + rayon) / g_GridRoutingSize; + col_max = (cx + rayon) / g_GridRoutingSize; + row_min = (cy - rayon) / g_GridRoutingSize; if (uy0 > row_min*g_GridRoutingSize ) row_min++; + col_min = (cx - rayon) / g_GridRoutingSize; if (ux0 > col_min*g_GridRoutingSize ) col_min++; + + if( row_min < 0 ) row_min = 0; + if( row_max >= (Nrows-1)) row_max = Nrows-1; + if( col_min < 0 ) col_min = 0; + if( col_max >= (Ncols-1)) col_max = Ncols-1; + + for( row = row_min ;row <= row_max ; row++) + { + for(col = col_min;col <= col_max; col++) + { + rotrow = row * g_GridRoutingSize; rotcol = col * g_GridRoutingSize; + RotatePoint(&rotcol, &rotrow, cx, cy, - angle); + if( rotrow <= uy0 ) continue; + if( rotrow >= uy1 ) continue; + if( rotcol <= ux0 ) continue; + if( rotcol >= ux1 ) continue; + if(trace & 1) WriteCell(row,col,BOTTOM,color); + if(trace & 2) WriteCell(row,col,TOP,color); + } + } +} + + + +/*****************************************************************/ +void DrawSegmentQcq(int ux0,int uy0,int ux1,int uy1,int lg,int layer, + int color, int op_logique) +/*****************************************************************/ +/* Remplit toutes les cellules du BOARD contenues dans le segment + de demi-largeur lg, org ux,y0 fin ux,y1 a la valeur color . + coord en unites PCB (0.1 mil) relatives a l'origine pt_pcb->m_PcbBox.m_Xmin,Y du board. +*/ +{ +int row, col; +int inc; +int row_max, col_max, row_min, col_min; +int demi_pas; +void (*WriteCell)(int,int,int,BoardCell); +int angle; +int cx, cy, dx, dy; + + switch(op_logique) + { + default: + case WRITE_CELL: WriteCell = SetCell; break; + case WRITE_OR_CELL: WriteCell = OrCell; break; + case WRITE_XOR_CELL: WriteCell = XorCell; break; + case WRITE_AND_CELL: WriteCell = AndCell; break; + case WRITE_ADD_CELL: WriteCell = AddCell; break; + } + + /* on rend la coordonnee ux1 tj > ux0 , pour simplifier les calculs */ + if( ux1 < ux0 ) { EXCHG(ux1,ux0); EXCHG(uy1,uy0);} + + /* calcul de l'increment selon axe Y */ + inc = 1; if(uy1 < uy0) inc = -1; + + /* Calcul de l'encadrement : */ + demi_pas = g_GridRoutingSize/2; + + col_min = (ux0 - lg) / g_GridRoutingSize; + if (col_min < 0 ) col_min = 0; + col_max = (ux1 + lg + demi_pas) / g_GridRoutingSize; + if (col_max > (Ncols-1) ) col_max = Ncols-1; + + if(inc > 0) + { + row_min = (uy0 - lg) / g_GridRoutingSize; + row_max = (uy1 + lg + demi_pas) / g_GridRoutingSize; + } + else{ + row_min = (uy1 - lg) / g_GridRoutingSize; + row_max = (uy0 + lg + demi_pas) / g_GridRoutingSize; + } + + if (row_min < 0 ) row_min = 0; + if (row_min > (Nrows-1) ) row_min = Nrows-1; + if (row_max < 0 ) row_max = 0; + if (row_max > (Nrows-1) ) row_max = Nrows-1; + + + dx = ux1 - ux0; dy = uy1 - uy0; + if (dx) angle = (int)(atan2(dy,dx) * 1800 / M_PI); + else { angle = 900; if (dy < 0) angle = -900; } + + RotatePoint(&dx, &dy, angle); /* dx = longueur, dy = 0 */ + for( col = col_min; col <= col_max ; col++ ) + { + int cxr; + cxr = (col * g_GridRoutingSize) - ux0; + for(row = row_min; row <= row_max ; row ++ ) + { + cy = (row * g_GridRoutingSize) - uy0; + cx = cxr; + RotatePoint(&cx, &cy, angle); + if( abs(cy) > lg) continue; /* Le point est trop loin sur l'axe Y */ + + /* ici le point a tester est proche du segment: la position + selon l'axe X doit etre testee */ + if( (cx >= 0) && (cx <= dx) ) + { + OP_CELL(layer,row,col); + continue; + } + /* examen des extremites qui sont arrondies */ + if( (cx < 0) && (cx >= -lg) ) + { + if( ((cx * cx) + (cy*cy)) <= (lg*lg) ) + OP_CELL(layer,row,col); + continue; + } + if( (cx > dx) && (cx <= (dx+lg)) ) + { + if( (((cx-dx) * (cx-dx)) + (cy*cy)) <= (lg*lg) ) + OP_CELL(layer,row,col); + continue; + } + } + } +} + +/********************************************************************/ +void DrawHVSegment(int ux0,int uy0,int ux1,int uy1,int demi_largeur,int layer, + int color, int op_logique) +/********************************************************************/ +/* Draw a horizontal or vertical segment. +same as DrawSegmentQcq, but faster +*/ +{ +int row, col; +int row_max, col_max, row_min, col_min; +void (*WriteCell)(int,int,int,BoardCell); + + switch(op_logique) + { + default: + case WRITE_CELL: WriteCell = SetCell; break; + case WRITE_OR_CELL: WriteCell = OrCell; break; + case WRITE_XOR_CELL: WriteCell = XorCell; break; + case WRITE_AND_CELL: WriteCell = AndCell; break; + case WRITE_ADD_CELL: WriteCell = AddCell; break; + } + + // Modif des coord pour que les coord de fin soient > coord de debut + if( uy1 < uy0 ) EXCHG(uy0,uy1) ; // ceci n'est vrai que parce que + if( ux1 < ux0 ) EXCHG(ux0,ux1) ; // dx ou dy ou les 2 sonts nuls + + // Le segment est assimile a un rectangle. + // TODO: traiter correctement les extremites arrondies +// if ( ux0 == ux1 ) // Vertical Segment + { + ux0 -= demi_largeur; ux1 += demi_largeur; + } +// else // Horizontal segment + { + uy0 -= demi_largeur ;uy1 += demi_largeur; + } + + // Calcul des coord limites des cellules appartenant au rectangle + row_max = uy1 / g_GridRoutingSize; + col_max = ux1 / g_GridRoutingSize; + + row_min = uy0 / g_GridRoutingSize; + if (uy0 > row_min*g_GridRoutingSize ) row_min++; // Traitement de l'arrondi par defaut + + col_min = ux0 / g_GridRoutingSize; + if (ux0 > col_min*g_GridRoutingSize ) col_min++; + + if( row_min < 0 ) row_min = 0; + if( row_max >= (Nrows-1)) row_max = Nrows-1; + if( col_min < 0 ) col_min = 0; + if( col_max >= (Ncols-1)) col_max = Ncols-1; + + if( row_min > row_max ) row_max = row_min; + if( col_min > col_max ) col_max = col_min; + + for( row = row_min ;row <= row_max ; row++) + { + for(col = col_min;col <= col_max; col++) + { + OP_CELL(layer,row,col); + } + } +} + +/*****************************************************************/ +void TraceCercle(int ux0,int uy0,int ux1,int uy1,int lg,int layer, + int color, int op_logique) +/*****************************************************************/ +/* Remplit toutes les cellules du BOARD contenues dans le cercle + de demi-largeur lg, centre ux,y0 passant par ux,y1 a la valeur color . + coord en unites PCB (0.1 mil) relatives a l'origine pt_pcb->m_PcbBox.m_Xmin,Y du board. +*/ +{ +int rayon, nb_segm; +int x0,y0, // Point de depart du segment en cours de trace + x1,y1; // point d'arrivee +int ii; +int angle; + + rayon = (int)hypot((double)(ux1-ux0),(double)(uy1-uy0) ); + + x0 = x1 = rayon; y0 = y1 = 0; + if( lg < 1 ) lg = 1; + nb_segm = (2 * rayon) / lg; + if(nb_segm < 5) nb_segm = 5; + if(nb_segm > 100) nb_segm = 100; + for( ii = 1 ; ii < nb_segm ; ii++) + { + angle = (3600 * ii) / nb_segm; + x1 = (int)(rayon * fcosinus[angle]); + y1 = (int)(rayon * fsinus[angle]); + DrawSegmentQcq(x0+ux0,y0+uy0, x1+ux0,y1+uy0,lg,layer, color, op_logique); + x0 = x1; y0 = y1; + } + + DrawSegmentQcq(x1+ux0,y1+uy0, ux0+rayon, uy0,lg,layer, color, op_logique); +} + +/****************************************************************************/ +void TraceArc(int ux0,int uy0,int ux1,int uy1, int ArcAngle, int lg,int layer, + int color, int op_logique) +/****************************************************************************/ + +/* Remplit toutes les cellules du BOARD contenues dans l'arc de "longueur" angle + de demi-largeur lg, centre ux,y0 commencant en ux,y1 a la valeur color . + coord en unites PCB (0.1 mil) relatives a l'origine + pt_pcb->m_PcbBox.m_Xmin,Y du board. +*/ +{ +int rayon, nb_segm; +int x0,y0, // Point de depart du segment en cours de trace + x1,y1; // point d'arrivee +int ii; +int angle, StAngle; + + + rayon = (int)hypot((double)(ux1-ux0),(double)(uy1-uy0) ); + + x0 = ux1 - ux0; + y0 = uy1 - uy0; + StAngle = ArcTangente(uy1 - uy0, ux1 - ux0); + if( lg < 1 ) lg = 1; + nb_segm = (2 * rayon) / lg; + nb_segm = (nb_segm * abs(ArcAngle)) / 3600; + if(nb_segm < 5) nb_segm = 5; + if(nb_segm > 100) nb_segm = 100; + + for( ii = 1 ; ii <= nb_segm ; ii++) + { + angle = (ArcAngle * ii) / nb_segm; + angle += StAngle; + + while ( angle >= 3600 ) angle -= 3600; + while ( angle < 0 ) angle += 3600; + + x1 = (int)(rayon * fcosinus[angle]); + y1 = (int)(rayon * fsinus[angle]); + DrawSegmentQcq(x0+ux0,y0+uy0, x1+ux0,y1+uy0,lg,layer, color, op_logique); + x0 = x1; y0 = y1; + } + +// DrawSegmentQcq(x1+ux0,y1+uy0, ux0+rayon, uy0,lg,layer, color, op_logique); +} + diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp new file mode 100644 index 0000000000..94b98c213d --- /dev/null +++ b/pcbnew/hotkeys.cpp @@ -0,0 +1,207 @@ + /***************/ + /* hotkeys.cpp */ + /***************/ + +#include "fctsys.h" + +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "id.h" + +#include "protos.h" + +/* Routines locales */ + +/* variables externes */ + +/***********************************************************/ +void WinEDA_PcbFrame::OnHotKey(wxDC * DC, int hotkey, + EDA_BaseStruct * DrawStruct) +/***********************************************************/ +/* Gestion des commandes rapides (Raccourcis claviers) concernant l'element +sous le courseur souris + Les majuscules/minuscules sont indifferenciees + touche DELETE: Effacement (Module ou piste selon commande en cours) + touche V: Place via en cours de trace de piste + touche R: Rotation module + touche S: Change couche module (Composant <-> Cuivre) + touche M: Start Move module + touche G: Start Drag module +*/ +{ +bool PopupOn = GetScreen()->m_CurrentItem && + GetScreen()->m_CurrentItem->m_Flags; +bool ItemFree = (GetScreen()->m_CurrentItem == 0 ) || + (GetScreen()->m_CurrentItem->m_Flags == 0); + + if ( hotkey == 0 ) return; + +MODULE* module = NULL; + + switch (hotkey) + { + case WXK_DELETE: + case WXK_NUMPAD_DELETE: + OnHotkeyDeleteItem(DC, DrawStruct); + break; + + case 'v': // Rotation + case 'V': + if ( m_ID_current_state != ID_TRACK_BUTT ) return; + if ( ItemFree ) + { + Other_Layer_Route( NULL, DC); + break; + } + if ( GetScreen()->m_CurrentItem->m_StructType != TYPETRACK ) + return; + if ( (GetScreen()->m_CurrentItem->m_Flags & IS_NEW) == 0 ) + return; + Other_Layer_Route( (TRACK *) GetScreen()->m_CurrentItem, DC); + if ( DisplayOpt.ContrastModeDisplay ) + GetScreen()->SetRefreshReq(); + break; + + case 'r': // Rotation + case 'R': + if ( ItemFree ) + module = Locate_Prefered_Module(m_Pcb, CURSEUR_ON_GRILLE); + else if (GetScreen()->m_CurrentItem->m_StructType == TYPEMODULE) + module = (MODULE*)GetScreen()->m_CurrentItem; + if ( module ) + { + GetScreen()->m_CurrentItem = module; + module->Display_Infos(this); + Rotate_Module(DC, module, 900, TRUE); + } + break; + + case 's': // move to other side + case 'S': + if ( ItemFree ) + module = Locate_Prefered_Module(m_Pcb, CURSEUR_ON_GRILLE); + else if (GetScreen()->m_CurrentItem->m_StructType == TYPEMODULE) + module = (MODULE*)GetScreen()->m_CurrentItem; + if ( module ) + { + GetScreen()->m_CurrentItem = module; + module->Display_Infos(this); + Change_Side_Module(module, DC); + } + break; + + case 'g': + case 'G': // Start move (and drag) module + g_Drag_Pistes_On = TRUE; + case 'm': + case 'M': // Start move module + if ( PopupOn ) break; + if ( (module = Locate_Prefered_Module(m_Pcb, CURSEUR_ON_GRILLE)) != NULL) + { + GetScreen()->m_CurrentItem = module; + module->Display_Infos(this); + StartMove_Module( module, DC); + } + break; + } +} + + + + +/***********************************************************/ +void WinEDA_ModuleEditFrame::OnHotKey(wxDC * DC, int hotkey, + EDA_BaseStruct * DrawStruct) +/***********************************************************/ +/* Gestion des commandes rapides (Raccourcis claviers) concernant l'element +sous le courseur souris + Les majuscules/minuscules sont indifferenciees +*/ +{ +bool PopupOn = GetScreen()->m_CurrentItem && + GetScreen()->m_CurrentItem->m_Flags; + if ( hotkey == 0 ) return; + + switch (hotkey) + { + case WXK_DELETE: + case WXK_NUMPAD_DELETE: + if ( PopupOn ) break; + break; + + case 'r': // Rotation + case 'R': + break; + + case 'y': // Mirror Y (drawlibpart) + case 'Y': + break; + + case 'x': // Mirror X (drawlibpart) + case 'X': + break; + + case 'n': + case 'N': // Orient 0, no mirror (drawlibpart) + break; + + case 'm': + case 'M': // Start move drawlibpart + if ( PopupOn ) break; + break; + } +} + +/******************************************************************************/ +bool WinEDA_PcbFrame::OnHotkeyDeleteItem(wxDC * DC, EDA_BaseStruct * DrawStruct) +/******************************************************************************/ +/* Efface l'item pointe par la souris, en reponse a la touche "Del" + Effet dependant de l'outil selectionne: + Outil trace de pistes + Efface le segment en cours ou la piste si pas d'element + Outil module: + Efface le module. +*/ +{ +bool ItemFree = (GetScreen()->m_CurrentItem == NULL ) || + (GetScreen()->m_CurrentItem->m_Flags == 0); + + switch ( m_ID_current_state ) + { + case ID_TRACK_BUTT: + if ( GetScreen()->m_Active_Layer > CMP_N ) return FALSE; + if ( ItemFree ) + { + DrawStruct = PcbGeneralLocateAndDisplay(); + if ( DrawStruct && DrawStruct->m_StructType != TYPETRACK ) return FALSE; + Delete_Track(DC, (TRACK*)DrawStruct); + } + else if ( GetScreen()->m_CurrentItem->m_StructType == TYPETRACK ) + { + GetScreen()->m_CurrentItem = + Delete_Segment(DC, (TRACK*)GetScreen()->m_CurrentItem); + GetScreen()->SetModify(); + return TRUE; + } + break; + + case ID_COMPONENT_BUTT: + if ( ItemFree ) + { + MODULE * module = Locate_Prefered_Module(m_Pcb, CURSEUR_ON_GRILLE); + if ( module == NULL ) return FALSE; + RemoveStruct(module, DC); + } + else return FALSE; + break; + + default: + return FALSE; + } + + GetScreen()->SetModify(); + GetScreen()->m_CurrentItem = NULL; + return TRUE; +} diff --git a/pcbnew/icon_modedit.ico b/pcbnew/icon_modedit.ico new file mode 100644 index 0000000000000000000000000000000000000000..84852bf1bc5caccd2e463fa0b3ab5d9f01db1a2d GIT binary patch literal 3262 zcmeHKdrVVT7{6xObY_WBBW@1XqCk=IQsO2=D5BA+v}!1$MIIJhfLbd;3MxoDgn~*P zKA;s^UKIfw0mBv9fFg>_MWHAHh4R)4A|fqxPANS*Cr{~=B`)MPOjyZEj{}fy3EZTJCh;XoWZbucQ)*1cHN!382-2p&>;@MGT8I69~pN z(}vT1cWiL|X2ps*vUq!YL+ko4Mc<2n3Z%)!nBi1Q%LSPi_n1HQaB}>-E2&s5CY8xsr`ADRSwj>g%wXGfJBQj%Lv7(+> z$2iw`zhwqIK27%N{w@OL7%A|KFg3SXE^lmTFwVYy4MsjEZ zR)6PCqfFLRQ8C!u+)!6%YHDg>VbR&ySzKK1^1~5)Kt3fhb2@eadi(mN#Z?=EPOqlK z%nxllm6CnEtjq|m*BdmNYXt>GSy^aFNodSjHaAV0naPii*3{R7t}ZYzpc@z9F(Lrs~1_=UVJe+(J8yigUBh=Tu$2IzB!=Ha51CDIoi@yE;1| zRYt+Jg<%hg^qM+1v!LbNSZRtk;I-n>#QLNEuk~2$P_nlrqM>$8%fc}0kJp3z) z&IZT&9xg7eF#NlByNZhPjvtq%rwiiZN=3Q;%oBr(`?YepQJGh-n(OO>B9okhQlXf? zHBM(LPbh4>Qex=ofmh12-d-msr#JE8h`FgLgG|1hkkDIHWT>y7xOWdIm0h=PiG@Og z!2o54mr`wM>Bz_kq#A|!ow7<4RiY>+JJ4tX0|MR(K6`NavSlugjvmg=>l_`Io0u>d z3;^-R$Km$cs;glMT`ZM<8Qo&jRFJ4^C$(fBa$G*M2eYa8xg*D2n zRGx{CUrUW$>{nvBmA%lX^jy+eO!gk7lK8GaM((bz4{K^bM+azXdQw)FmXL5xB3nb{ zc?Bm0b2zlVJ^{O3v)Q!X zUV)w-t-D+6>e4zp1v)yk_I9nUO`x?E5CI$b>EM6@0ovQ6-CgqgX=jIgKHA!%%}v_a zp!IcHTcg!gT3MmxWm;OI#YI|Jp!s?7c*yN0my2d+X=a9|r)g@+g#YlcJ_+twVDER; z=V^eA`uWrkNFWP2{-YzROM-m}D4kRWB#?y(e=t~nr=~$uZyxVEKl_}YwlF{zm?+dj zjz1J?wijgB^34_?_{X;)an0{?q1-b6$q9u*6bzE-L~UwUi0NOH83zQpKbhpGLIPO;s0GR`995SD+Mpc&*%>91lt@rKPO%t8 zqZEly$+Ul!;2SiUPi$BH4g8a$LkfPc7h94X|HTER)09e4 zjT6PbMvcj$7TA(Z_%j)*OM?3YkWgP`0n`HJ#;%8rRgOQK<>?HY&8ctm0GrA1xWQ4U zr&S$QS#G*&ASV2|9CM5QPzEF_994@1jt6r5x~{$x4ad2bbFOAFXtEc}S~U%DHZbAm z{F;AVhXe?3yj1d4HUHdtjuQw@ICA{?JoEfE#)(>(JIcaD;SeSB7YbY#637BTEqLm( zs-ylTfuowtUo29gK>0jzPP$IH9A&d~S*L^vKhB8%^}31wj?TBBz57c{i39&4+{Z1n F{{X{pDVzWR literal 0 HcmV?d00001 diff --git a/pcbnew/icon_w3d.ico b/pcbnew/icon_w3d.ico new file mode 100644 index 0000000000000000000000000000000000000000..a446a14d489a713afbf3cfe58d40a916c5c65523 GIT binary patch literal 766 zcmcIiu?oU45IseZf}oRYJNg&(&kQ&?wrfG?uVm{Y^cM;ab??$ai0@sZHmIZ5yxiTp z%gY5SGQ*c;8|(|Y%|*5%vI8<;50IxB)V`ZR5fx*+!;Vm_weT!BUE&-g03RuA7Ykxy z7uX~fS&^|3MJA?JN<~ddeV&VYARgz;lBx=>48B4DwxSnqXh;GWOHy+Anw|-{l9ReN zf61ZgTlHqIO+DYQ^Gxa(M6V1RXZdlTmwU~p^HUaLSkHIr+)3$E|4?ea4r|2s{=-uK z1VFcBfNXqcU`D`=d3WeilQwNpw0+&UzV3lR(ZCn=aL<7?_>ShowModal(); frame->Destroy(); +} + + +/***********************************************************************/ +void WinEDA_PcbGlobalDeleteFrame::AcceptPcbDelete(wxCommandEvent& event) +/***********************************************************************/ +{ +int track_mask; +bool redraw = FALSE; +wxClientDC dc(m_Parent->DrawPanel); + + m_Parent->DrawPanel->PrepareGraphicContext(&dc); + + if ( m_DelAlls->GetValue() ) + { + m_Parent->Clear_Pcb(&dc, TRUE); + redraw = TRUE; + } + + else + { + if ( m_DelZones->GetValue() ) + { + m_Parent->Erase_Zones(&dc, TRUE); + redraw = TRUE; + } + + if ( m_DelTexts->GetValue() ) + { + m_Parent->Erase_Textes_Pcb(&dc, TRUE); + redraw = TRUE; + } + + if ( m_DelEdges->GetValue() ) + { + m_Parent->Erase_Segments_Pcb(&dc, TRUE, TRUE); + redraw = TRUE; + } + + if ( m_DelDrawings->GetValue() ) + { + m_Parent->Erase_Segments_Pcb(&dc, FALSE, TRUE); + redraw = TRUE; + } + + if ( m_DelModules->GetValue() ) + { + m_Parent->Erase_Modules(&dc, TRUE); + redraw = TRUE; + } + + if ( m_DelTracks->GetValue() ) + { + { + track_mask = 0; + if ( ! m_TrackFilterLocked->GetValue() ) track_mask |= SEGM_FIXE; + if ( ! m_TrackFilterAR->GetValue() ) track_mask |= SEGM_AR; + + m_Parent->Erase_Pistes(&dc, track_mask, TRUE); + redraw = TRUE; + } + } + + if ( m_DelMarkers->GetValue() ) + { + m_Parent->Erase_Marqueurs(&dc, FALSE); + redraw = TRUE; + } + + } + + if ( redraw ) + { + m_Parent->GetScreen()->m_CurrentItem = NULL; + m_Parent->ReDrawPanel(); + } + + EndModal(1); +} + + + + +/*********************************************************/ +bool WinEDA_BasePcbFrame::Clear_Pcb(wxDC * DC, bool query) +/*********************************************************/ +/* Realise les init des pointeurs et variables + Si Item == NULL, il n'y aura pas de confirmation +*/ +{ + + if( m_Pcb == NULL ) return FALSE; + + if ( query && GetScreen()->IsModify() ) + { + if (m_Pcb->m_Drawings ||m_Pcb->m_Modules || + m_Pcb->m_Track || m_Pcb->m_Zone ) + { + if( ! IsOK(this, _("Current Board will be lost ?")) ) return FALSE; + } + } + + /* Suppression des listes chainees */ + DeleteStructList(m_Pcb->m_Equipots); + m_Pcb->m_Equipots = NULL; + + DeleteStructList(m_Pcb->m_Drawings); + m_Pcb->m_Drawings = NULL; + + DeleteStructList(m_Pcb->m_Modules); + m_Pcb->m_Modules = NULL; + + DeleteStructList(m_Pcb->m_Track); + m_Pcb->m_Track = NULL; + m_Pcb->m_NbSegmTrack = 0; + + DeleteStructList(m_Pcb->m_Zone); + m_Pcb->m_Zone = NULL; + m_Pcb->m_NbSegmZone = 0; + DelLimitesZone(DC, FALSE); + + for ( ; g_UnDeleteStackPtr != 0; ) + { + g_UnDeleteStackPtr--; + DeleteStructList(g_UnDeleteStack[g_UnDeleteStackPtr]); + } + + /* init pointeurs et variables */ + GetScreen()->m_FileName.Empty(); + memset (buf_work, 0, BUFMEMSIZE); + adr_lowmem = adr_max = buf_work; + + if(m_Pcb->m_Pads) + { + MyFree(m_Pcb->m_Pads); + m_Pcb->m_Pads = NULL; + } + if( m_Pcb->m_Ratsnest ) MyFree(m_Pcb->m_Ratsnest); + if( m_Pcb->m_LocalRatsnest ) MyFree(m_Pcb->m_LocalRatsnest); + m_Pcb->m_Ratsnest = NULL; + m_Pcb->m_LocalRatsnest = NULL; + + /* remise a 0 ou a une valeur initiale des variables de la structure */ + m_Pcb->m_BoundaryBox.SetOrigin(wxPoint(0,0)); + m_Pcb->m_BoundaryBox.SetSize(wxSize(0,0)); + m_Pcb->m_Status_Pcb = 0; + m_Pcb->m_NbLoclinks = 0; + m_Pcb->m_NbLinks = 0; + m_Pcb->m_NbPads = 0; + m_Pcb->m_NbNets = 0; + m_Pcb->m_NbNodes = 0; + m_Pcb->m_NbNoconnect = 0; + m_Pcb->m_NbSegmTrack = 0; + m_Pcb->m_NbSegmZone = 0; + GetScreen()->m_CurrentItem = NULL; + + /* Init parametres de gestion */ + GetScreen()->Init(); + + g_HightLigt_Status = 0 ; + + for(int ii = 1; ii < HIST0RY_NUMBER; ii++) + { + g_DesignSettings.m_ViaSizeHistory[ii] = + g_DesignSettings.m_TrackWidhtHistory[ii] = 0; + } + g_DesignSettings.m_TrackWidhtHistory[0] = g_DesignSettings.m_CurrentTrackWidth; + g_DesignSettings.m_ViaSizeHistory[0] = g_DesignSettings.m_CurrentViaSize; + + Zoom_Automatique(TRUE); + DrawPanel->Refresh(TRUE); + + return TRUE; +} + +/************************************************************/ +void WinEDA_PcbFrame::Erase_Zones(wxDC * DC, bool query) +/************************************************************/ +{ + + if( query && !IsOK(this, _("Delete Zones ?") ) ) return ; + + if( m_Pcb->m_Zone ) + { + while(m_Pcb->m_Zone ) DeleteStructure(m_Pcb->m_Zone); + m_Pcb->m_NbSegmZone = 0; + } + DelLimitesZone(DC, FALSE); + + GetScreen()->SetModify(); +} + + +/*****************************************************************************/ +void WinEDA_PcbFrame::Erase_Segments_Pcb(wxDC * DC, bool is_edges, bool query) +/*****************************************************************************/ +{ +EDA_BaseStruct * PtStruct, *PtNext; +int masque_layer = (~EDGE_LAYER) & 0x1FFF0000; + + if( is_edges ) + { + masque_layer = EDGE_LAYER; + if ( query && ! IsOK(this, _("Delete Board edges ?") ) ) return; + } + else + { + if ( query && ! IsOK(this, _("Delete draw items?") ) ) return; + } + + PtStruct = (EDA_BaseStruct *) m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtNext) + { + PtNext = PtStruct->Pnext; + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + if(g_TabOneLayerMask[((DRAWSEGMENT*)PtStruct)->m_Layer] & masque_layer) + DeleteStructure(PtStruct); + break; + + case TYPETEXTE: + if(g_TabOneLayerMask[((TEXTE_PCB*)PtStruct)->m_Layer] & masque_layer) + DeleteStructure(PtStruct); + break; + + case TYPECOTATION: + if(g_TabOneLayerMask[((COTATION*)PtStruct)->m_Layer] & masque_layer) + DeleteStructure(PtStruct); + break; + + case TYPEMIRE: + if(g_TabOneLayerMask[((MIREPCB*)PtStruct)->m_Layer] & masque_layer) + DeleteStructure(PtStruct); + break; + default: + DisplayError(this, wxT("Unknown/unexpected Draw Type")); + break; + } + } + + GetScreen()->SetModify(); +} + + +/**************************************************************************/ +void WinEDA_PcbFrame::Erase_Pistes(wxDC * DC, int masque_type, bool query) +/**************************************************************************/ +/* Efface les segments de piste, selon les autorisations affichees +masque_type = masque des options de selection: +SEGM_FIXE, SEGM_AR + Si un des bits est a 1, il n'y a pas effacement du segment de meme bit a 1 +*/ +{ +TRACK * pt_segm; +EDA_BaseStruct * PtNext; + + if( query && ! IsOK(this, _("Delete Tracks?") ) ) return; + + /* Marquage des pistes a effacer */ + for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) PtNext) + { + PtNext = pt_segm->Pnext; + if( pt_segm->GetState(SEGM_FIXE|SEGM_AR) & masque_type) continue; + DeleteStructure(pt_segm); + } + + GetScreen()->SetModify(); + Compile_Ratsnest(DC, TRUE); +} + + +/**************************************************************/ +void WinEDA_PcbFrame::Erase_Modules(wxDC * DC, bool query) +/**************************************************************/ +{ + if( query && ! IsOK(this, _("Delete Modules?") ) ) return; + + while ( m_Pcb->m_Modules ) DeleteStructure(m_Pcb->m_Modules); + + m_Pcb->m_Status_Pcb = 0 ; + m_Pcb->m_NbNets = 0 ; + m_Pcb->m_NbPads = 0 ; + m_Pcb->m_NbNodes = 0 ; + m_Pcb->m_NbLinks = 0 ; + m_Pcb->m_NbNoconnect = 0 ; + + GetScreen()->SetModify(); +} + + +/************************************************************/ +void WinEDA_PcbFrame::Erase_Textes_Pcb(wxDC * DC, bool query) +/************************************************************/ +{ +EDA_BaseStruct * PtStruct, *PtNext; + + if( query && ! IsOK(this, _("Delete Pcb Texts") ) ) return; + + PtStruct = (EDA_BaseStruct*) m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtNext) + { + PtNext = PtStruct->Pnext; + if(PtStruct->m_StructType == TYPETEXTE ) DeleteStructure(PtStruct); + } + + GetScreen()->SetModify(); +} + + +/************************************************************/ +void WinEDA_PcbFrame::Erase_Marqueurs(wxDC * DC, bool query) +/************************************************************/ +{ +EDA_BaseStruct * PtStruct, *PtNext; + + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtNext) + { + PtNext = PtStruct->Pnext; + if(PtStruct->m_StructType == TYPEMARQUEUR ) DeleteStructure(PtStruct); + } + + GetScreen()->SetModify(); +} + diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp new file mode 100644 index 0000000000..81b73cbce9 --- /dev/null +++ b/pcbnew/ioascii.cpp @@ -0,0 +1,1115 @@ +/********************************************************************/ +/* Routines de lecture et sauvegarde des structures en format ASCii */ +/* Fichier common a PCBNEW et CVPCB */ +/********************************************************************/ + + /* ioascii.cpp */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#ifdef PCBNEW +#include "pcbnew.h" +#include "autorout.h" +#endif + +#ifdef CVPCB +#include "cvpcb.h" +#endif + +#include "protos.h" + +/* Format des structures de sauvegarde type ASCII : + +Structure PAD: + +$PAD +Sh "name" forme dimv dimH dV dH orient :forme generale dV, dH = delta dimensions +Dr diam, dV dH :drill : diametre offsets de percage +At type S/N layers : type standard,cms,conn,hole,meca., + Stack/Normal, + Hexadecimal 32 bits: occupation des couches +Nm net_code netname +Po posrefX posrefy : position refX,Y (= position orient 0 / ancre) +$EndPAD + +******** Structure module *********** + +$MODULE namelib +Po ax ay orient layer masquelayer m_TimeCode + ax ay = coord ancre (position module) + orient = orient en 0.1 degre + layer = numero de couche + masquelayer = couche pour serigraphie + m_TimeCode a usage interne (groupements) +Li + +Cd Description du composant (Composant Doc) +Kw Liste des mots cle + +Sc schematimestamp de reference schematique + +Op rot90 rot180 Options de placement auto (cout rot 90, 180 ) + rot90 est sur 2x4 bits: + lsb = cout rot 90, msb = cout rot -90; + +Tn px py dimv dimh orient epaisseur miroir visible "texte" + n = type (0 = ref, 1 = val, > 1 =qcq + Textes POS x,y / ancre et orient module 0 + dimv dimh orient + epaisseur miroir (Normal/miroir) + visible V/I +DS ox oy fx fy w + edge: segment coord ox,oy a fx,fy, relatives + a l'ancre et orient 0 + epaisseur w +DC ox oy fx fy w descr cercle (centre, 1 point, epaisseur) +$PAD +$EndPAD section pads s'il y en a +$EndMODULE +*/ + +extern Ki_PageDescr * SheetList[]; + +/* Variables locales, utilisees pour la lecture des fichiers PCB */ +int NbDraw,NbTrack,NbZone, NbMod, NbNets; + + +/**********************************************************************/ +int WinEDA_BasePcbFrame::ReadListeSegmentDescr(wxDC * DC, FILE * File, + TRACK * PtSegm,int StructType, + int * LineNum, int NumSegm) +/**********************************************************************/ +/* Lecture de la description d'une liste de segments (Tracks, zones) + Retourne: + si ok nombre d'items lus. + si pas de fin de block ($..) - nombre. +*/ +{ +int shape, width, layer, type, flags, net_code; +int ii = 0, PerCent, Pas; +char Line[256]; +TRACK * NewTrack; + + PerCent = 0; Pas = NumSegm / 99; +#ifdef PCBNEW + switch ( StructType ) + { + case TYPETRACK: + case TYPEVIA: + DisplayActivity(PerCent, wxT("Tracks:") ); + break; + + case TYPEZONE: + DisplayActivity(PerCent, wxT("Zones:") ); + break; + } +#endif + while( GetLine(File, Line, LineNum ) ) + { + if(Line[0] == '$') + { + return(ii); /* fin de liste OK */ + } + + switch ( StructType ) + { + default: + case TYPETRACK: NewTrack = new TRACK( m_Pcb ); + break; + case TYPEVIA: NewTrack = new SEGVIA( m_Pcb ); + break; + case TYPEZONE: NewTrack = new SEGZONE( m_Pcb ); + break; + } + NewTrack->Insert(m_Pcb, PtSegm); PtSegm = NewTrack; + + int arg_count = sscanf( Line+2," %d %d %d %d %d %d %d",&shape, + &PtSegm->m_Start.x, &PtSegm->m_Start.y, + &PtSegm->m_End.x, &PtSegm->m_End.y, &width, + & PtSegm->m_Drill); + + PtSegm->m_Width = width; PtSegm->m_Shape = shape; + if ( arg_count < 7 ) PtSegm->m_Drill = -1; + + if( GetLine(File, Line, LineNum ) == NULL ) break; + if(Line[0] == '$') break; + + sscanf( Line+2," %d %d %d %lX %X", &layer, &type,&net_code, + &PtSegm->m_TimeStamp, &flags); + if ( type == 1 ) PtSegm->m_StructType = TYPEVIA; + PtSegm->m_Layer = layer; + PtSegm->m_NetCode = net_code; PtSegm->SetState(flags, ON); +#ifdef PCBNEW + PtSegm->Draw(DrawPanel, DC, GR_OR); +#endif + ii++; + if( ( Pas && (ii % Pas ) == 0) ) + { + PerCent ++; +#ifdef PCBNEW + switch ( StructType ) + { + case TYPETRACK: + case TYPEVIA: + DisplayActivity(PerCent, wxT("Tracks:") ); + break; + + case TYPEZONE: + DisplayActivity(PerCent, wxT("Zones:") ); + break; + } +#endif + } + } + DisplayError(this, _("Error: Unexpected end of file !") ); + return(-ii); +} + + + +/**********************************************************************************/ +int WinEDA_BasePcbFrame::ReadGeneralDescrPcb(wxDC * DC, FILE * File, int * LineNum) +/**********************************************************************************/ +{ +char Line[1024], *data; +BASE_SCREEN * screen = m_CurrentScreen; + + while( GetLine(File, Line, LineNum ) != NULL ) + { + data = strtok(Line," =\n\r"); + if(strnicmp(data,"$EndGENERAL",10) == 0) break; + + if( strncmp(data, "Ly", 2) == 0 ) // Old format for Layer count + { + int Masque_Layer = 1, ii; + data = strtok(NULL," =\n\r"); + sscanf(data,"%X",&Masque_Layer); + // Setup layer count + m_Pcb->m_BoardSettings->m_CopperLayerCount = 0; + for ( ii = 0; ii < NB_COPPER_LAYERS; ii++ ) + { + if ( Masque_Layer & 1 ) m_Pcb->m_BoardSettings->m_CopperLayerCount++; + Masque_Layer >>= 1; + } + continue; + } + + if(strnicmp(data, "Links", 5) == 0) + { + data = strtok(NULL," =\n\r"); + m_Pcb->m_NbLinks = atoi(data); + continue; + } + + if(strnicmp(data, "NoConn", 6) == 0) + { + data = strtok(NULL," =\n\r"); + m_Pcb->m_NbNoconnect = atoi(data); + continue; + } + + if(strnicmp(data, "Di", 2) == 0) + { + int ii, jj, bestzoom; + wxSize pcbsize, screensize; + data = strtok(NULL," =\n\r"); + m_Pcb->m_BoundaryBox.SetX(atoi(data)); + data = strtok(NULL," =\n\r"); + m_Pcb->m_BoundaryBox.SetY(atoi(data)); + data = strtok(NULL," =\n\r"); + m_Pcb->m_BoundaryBox.SetWidth(atoi(data) - m_Pcb->m_BoundaryBox.GetX()); + data = strtok(NULL," =\n\r"); + m_Pcb->m_BoundaryBox.SetHeight(atoi(data) - m_Pcb->m_BoundaryBox.GetY()); + + /* calcul du zoom optimal */ + pcbsize = m_Pcb->m_BoundaryBox.GetSize(); + screensize = DrawPanel->GetClientSize(); + ii = pcbsize.x/screensize.x; + jj = pcbsize.y/screensize.y; + bestzoom = max(ii, jj); + screen->m_Curseur = m_Pcb->m_BoundaryBox.Centre(); + + screen->SetZoom(bestzoom); + // la position des tracés a changé: mise a jour dans le DC courant + wxPoint org; + DrawPanel->GetViewStart(&org.x, &org.y); + DrawPanel->GetScrollPixelsPerUnit(&ii, &jj); + org.x *= ii; org.y *= jj; +#ifdef WX_ZOOM + DC->SetUserScale(1.0/(double)screen->GetZoom(), 1.0/screen->GetZoom()); + org.x *= screen->GetZoom(); org.y *= screen->GetZoom(); + DC->SetDeviceOrigin(-org.x, -org.y); +#endif + DrawPanel->SetBoundaryBox(); + Recadre_Trace(TRUE); + continue; + } + + /* Lecture du nombre de segments type DRAW , TRACT, ZONE */ + if(stricmp(data, "Ndraw") == 0) + { + data = strtok(NULL," =\n\r"); + NbDraw = atoi(data);; + continue; + } + + if(stricmp(data, "Ntrack") == 0) + { + data = strtok(NULL," =\n\r"); + NbTrack = atoi(data); + continue; + } + + if(stricmp(data, "Nzone") == 0) + { + data = strtok(NULL," =\n\r"); + NbZone = atoi(data); + continue; + } + + if(stricmp(data, "Nmodule") == 0) + { + data = strtok(NULL," =\n\r"); + NbMod = atoi(data); + continue; + } + + if(stricmp(data, "Nnets") == 0) + { + data = strtok(NULL," =\n\r"); + NbNets = atoi(data); + continue; + } + + } + return(1); +} + + +/*************************************************************/ +int WinEDA_BasePcbFrame::ReadSetup(FILE * File, int * LineNum) +/*************************************************************/ +{ +char Line[1024], *data; + + while( GetLine(File, Line, LineNum ) != NULL ) + { + strtok(Line," =\n\r"); + data = strtok(NULL," =\n\r"); + + if(stricmp(Line,"$EndSETUP") == 0) + { + return 0; + } + + if(stricmp(Line, "AuxiliaryAxisOrg") == 0) + { + int gx = 0, gy =0; + gx = atoi(data); + data = strtok(NULL," =\n\r"); + if ( data ) gy = atoi(data); + m_Auxiliary_Axis_Position.x = gx; m_Auxiliary_Axis_Position.y = gy; + continue; + } +#ifdef PCBNEW + if(stricmp(Line, "Layers") == 0) + { + int tmp; + sscanf(data,"%d",&tmp); + m_Pcb->m_BoardSettings->m_CopperLayerCount = tmp; + continue; + } + + if(stricmp(Line, "TrackWidth") == 0) + { + g_DesignSettings.m_CurrentTrackWidth = atoi(data); + AddHistory(g_DesignSettings.m_CurrentTrackWidth, TYPETRACK); + continue; + } + + if(stricmp(Line, "TrackWidthHistory") == 0) + { + int tmp = atoi(data); + AddHistory(tmp, TYPETRACK); + continue; + } + + if(stricmp(Line, "TrackClearence") == 0) + { + g_DesignSettings.m_TrackClearence = atoi(data); + continue; + } + + if(stricmp(Line, "ZoneClearence") == 0) + { + g_DesignSettings.m_ZoneClearence = atoi(data); + continue; + } + + if(stricmp(Line, "GridSize") == 0) + { + wxSize Grid; + Grid.x = atoi(data); + data = strtok(NULL," =\n\r"); + if ( data ) Grid.y = atoi(data); + else Grid.y = Grid.x; + GetScreen()->SetGrid(Grid); + continue; + } + + if(stricmp(Line, "ZoneGridSize") == 0) + { + g_GridRoutingSize = atoi(data); + continue; + } + + if(stricmp(Line, "UserGridSize") == 0) + { + wxString msg; + if ( data ) + { + from_point(data); + msg = CONV_FROM_UTF8(data); + msg.ToDouble(&g_UserGrid.x); + } + else continue; + data = strtok(NULL," =\n\r"); + if ( data ) + { + from_point(data); + msg = CONV_FROM_UTF8(data); + msg.ToDouble(&g_UserGrid.y); + } + else g_UserGrid.y = g_UserGrid.x; + GetScreen()->m_UserGrid = g_UserGrid; + data = strtok(NULL," =\n\r"); + if ( data ) + { + if ( stricmp(data, "mm") == 0 ) + g_UserGrid_Unit = MILLIMETRE; + else g_UserGrid_Unit = INCHES; + GetScreen()->m_UserGridUnit = g_UserGrid_Unit; + } + continue; + } + + if(stricmp(Line, "DrawSegmWidth") == 0) + { + g_DesignSettings.m_DrawSegmentWidth = atoi(data); + continue; + } + + if(stricmp(Line, "EdgeSegmWidth") == 0) + { + g_DesignSettings.m_EdgeSegmentWidth = atoi(data); + continue; + } + + if(stricmp(Line, "ViaSize") == 0) + { + g_DesignSettings.m_CurrentViaSize = atoi(data); + AddHistory(g_DesignSettings.m_CurrentViaSize, TYPEVIA); + continue; + } + + if(stricmp(Line, "ViaSizeHistory") == 0) + { + int tmp = atoi(data); + AddHistory(tmp, TYPEVIA); + continue; + } + + if(stricmp(Line, "ViaDrill") == 0) + { + g_DesignSettings.m_ViaDrill = atoi(data); + continue; + } + + if(stricmp(Line, "TextPcbWidth") == 0) + { + g_DesignSettings.m_PcbTextWidth = atoi(data); + continue; + } + + if(stricmp(Line, "TextPcbSize") == 0) + { + g_DesignSettings.m_PcbTextSize.x = atoi(data); + data = strtok(NULL," =\n\r"); + g_DesignSettings.m_PcbTextSize.y = atoi(data); + continue; + } + + if(stricmp(Line, "EdgeModWidth") == 0) + { + ModuleSegmentWidth = atoi(data); + continue; + } + + if(stricmp(Line, "TextModWidth") == 0) + { + ModuleTextWidth = atoi(data); + continue; + } + + if(stricmp(Line, "TextModSize") == 0) + { + ModuleTextSize.x = atoi(data); + data = strtok(NULL," =\n\r"); + ModuleTextSize.y = atoi(data); + continue; + } + + if(stricmp(Line, "PadSize") == 0) + { + g_Pad_Master.m_Size.x = atoi(data); + data = strtok(NULL," =\n\r"); + g_Pad_Master.m_Size.y = atoi(data); + continue; + } + + if(stricmp(Line, "PadDrill") == 0) + { + g_Pad_Master.m_Drill.x = atoi(data); + g_Pad_Master.m_Drill.y = g_Pad_Master.m_Drill.x; + continue; + } + + if(stricmp(Line, "PadDeltaSize") == 0) + { + g_Pad_Master.m_DeltaSize.x = atoi(data); + data = strtok(NULL," =\n\r"); + g_Pad_Master.m_DeltaSize.y = atoi(data); + continue; + } + if(stricmp(Line, "PadShapeOffset") == 0) + { + g_Pad_Master.m_Offset.x = atoi(data); + data = strtok(NULL," =\n\r"); + g_Pad_Master.m_Offset.y = atoi(data); + continue; + } +#endif + } + return(1); +} + + +#ifdef PCBNEW +/***************************************************************/ +static int WriteSetup(FILE * File, WinEDA_BasePcbFrame * frame) +/***************************************************************/ +{ +char text[1024]; +int ii, jj; + + fprintf(File,"$SETUP\n"); + sprintf(text, "InternalUnit %f INCH\n", 1.0/PCB_INTERNAL_UNIT); + to_point(text); + fprintf(File, text); + + if ( frame->GetScreen()->m_UserGridIsON ) ii = jj = -1; + else + { + ii = frame->GetScreen()->GetGrid().x; + jj = frame->GetScreen()->GetGrid().y; + } + sprintf(text, "GridSize %d %d\n", ii, jj); + fprintf(File, text); + + sprintf(text, "UserGridSize %lf %lf %s\n", + frame->GetScreen()->m_UserGrid.x, frame->GetScreen()->m_UserGrid.y, + ( g_UserGrid_Unit == 0 )? "INCH" : "mm"); + to_point(text); + fprintf(File, text); + + fprintf(File, "ZoneGridSize %d\n", g_GridRoutingSize); + + fprintf(File, "Layers %d\n", g_DesignSettings.m_CopperLayerCount); + fprintf(File, "TrackWidth %d\n", g_DesignSettings.m_CurrentTrackWidth); + for ( ii = 0; ii < HIST0RY_NUMBER; ii++) + { + if ( g_DesignSettings.m_TrackWidhtHistory[ii] == 0 ) break; + fprintf(File, "TrackWidthHistory %d\n", + g_DesignSettings.m_TrackWidhtHistory[ii]); + } + fprintf(File, "TrackClearence %d\n", g_DesignSettings.m_TrackClearence); + fprintf(File, "ZoneClearence %d\n", g_DesignSettings.m_ZoneClearence); + + fprintf(File, "DrawSegmWidth %d\n", g_DesignSettings.m_DrawSegmentWidth); + fprintf(File, "EdgeSegmWidth %d\n", g_DesignSettings.m_EdgeSegmentWidth); + fprintf(File, "ViaSize %d\n", g_DesignSettings.m_CurrentViaSize); + fprintf(File, "ViaDrill %d\n", g_DesignSettings.m_ViaDrill); + for ( ii = 0; ii < HIST0RY_NUMBER; ii++) + { + if ( g_DesignSettings.m_ViaSizeHistory[ii] == 0 ) break; + fprintf(File, "ViaSizeHistory %d\n", g_DesignSettings.m_ViaSizeHistory[ii]); + } + fprintf(File, "TextPcbWidth %d\n", g_DesignSettings.m_PcbTextWidth); + fprintf(File, "TextPcbSize %d %d\n", + g_DesignSettings.m_PcbTextSize.x, g_DesignSettings.m_PcbTextSize.y); + fprintf(File, "EdgeModWidth %d\n", ModuleSegmentWidth); + fprintf(File, "TextModSize %d %d\n", ModuleTextSize.x , ModuleTextSize.y); + fprintf(File, "TextModWidth %d\n", ModuleTextWidth); + fprintf(File, "PadSize %d %d\n", g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.y); + fprintf(File, "PadDrill %d\n", g_Pad_Master.m_Drill.x); +// fprintf(File, "PadDeltaSize %d %d\n", Pad_DeltaSize.x, Pad_DeltaSize.y); +// fprintf(File, "PadDrillOffset %d %d\n", Pad_OffsetSize.x, Pad_OffsetSize.y); + + fprintf(File, "AuxiliaryAxisOrg %d %d\n", + frame->m_Auxiliary_Axis_Position.x, frame->m_Auxiliary_Axis_Position.y); + fprintf(File,"$EndSETUP\n\n"); + return(1); +} +#endif + + +/******************************************************/ +bool WinEDA_PcbFrame::WriteGeneralDescrPcb(FILE * File) +/******************************************************/ +{ +EDA_BaseStruct * PtStruct = m_Pcb->m_Modules; +int NbModules, NbDrawItem, NbLayers; + + /* Calcul du nombre des modules */ + for( NbModules = 0; PtStruct != NULL; PtStruct = PtStruct->Pnext) NbModules++; + + /* generation du masque des couches autorisees */ + NbLayers = m_Pcb->m_BoardSettings->m_CopperLayerCount; + fprintf(File,"$GENERAL\n"); + fprintf(File,"LayerCount %d\n",NbLayers); + // Write old format for Layer count (for compatibility with old versions of pcbnew + fprintf(File,"Ly %8X\n", g_TabAllCopperLayerMask[NbLayers-1] | ALL_NO_CU_LAYERS); // For compatibility with old version of pcbnew + fprintf(File,"Links %d\n",m_Pcb->m_NbLinks); + fprintf(File,"NoConn %d\n",m_Pcb->m_NbNoconnect); + + /* Generation des coord du rectangle d'encadrement */ + m_Pcb->ComputeBoundaryBox(); + fprintf(File,"Di %d %d %d %d\n", + m_Pcb->m_BoundaryBox.GetX(), m_Pcb->m_BoundaryBox.GetY(), + m_Pcb->m_BoundaryBox.GetRight(), + m_Pcb->m_BoundaryBox.GetBottom()); + + /* Generation du nombre de segments type DRAW , TRACT ZONE */ + PtStruct = m_Pcb->m_Drawings; NbDrawItem = 0; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext) NbDrawItem++; + + fprintf(File,"Ndraw %d\n", NbDrawItem); + fprintf(File,"Ntrack %d\n", m_Pcb->GetNumSegmTrack() ); + fprintf(File,"Nzone %d\n", m_Pcb->GetNumSegmZone() ); + + fprintf(File,"Nmodule %d\n",NbModules ); + fprintf(File,"Nnets %d\n",m_Pcb->m_NbNets ); + + fprintf(File,"$EndGENERAL\n\n"); + return TRUE; +} + +/******************************************************/ +bool WriteSheetDescr(BASE_SCREEN * screen, FILE * File) +/******************************************************/ +{ + /* Sauvegarde des dimensions de la feuille de dessin, des textes du cartouche.. */ + Ki_PageDescr * sheet = screen->m_CurrentSheet; + + fprintf(File,"$SHEETDESCR\n"); + fprintf(File,"Sheet %s %d %d\n", + CONV_TO_UTF8(sheet->m_Name), sheet->m_Size.x,sheet->m_Size.y); + fprintf(File,"Title \"%s\"\n", CONV_TO_UTF8(screen->m_Title)); + fprintf(File,"Date \"%s\"\n", CONV_TO_UTF8(screen->m_Date)); + fprintf(File,"Rev \"%s\"\n", CONV_TO_UTF8(screen->m_Revision)); + fprintf(File,"Comp \"%s\"\n", CONV_TO_UTF8(screen->m_Company)); + fprintf(File,"Comment1 \"%s\"\n", CONV_TO_UTF8(screen->m_Commentaire1)); + fprintf(File,"Comment2 \"%s\"\n", CONV_TO_UTF8(screen->m_Commentaire2)); + fprintf(File,"Comment3 \"%s\"\n", CONV_TO_UTF8(screen->m_Commentaire3)); + fprintf(File,"Comment4 \"%s\"\n", CONV_TO_UTF8(screen->m_Commentaire4)); + + fprintf(File,"$EndSHEETDESCR\n\n"); + return TRUE; +} + + +/***************************************************************************/ +static bool ReadSheetDescr(BASE_SCREEN * screen, FILE * File, int * LineNum) +/***************************************************************************/ +{ +char Line[1024], buf[1024], * text; + + /* Recheche suite et fin de descr */ + while( GetLine(File, Line, LineNum ) != NULL ) + { + if( strnicmp(Line,"$End",4) == 0 ) return TRUE; + + if(strnicmp(Line, "Sheet", 4) == 0) + { + text = strtok(Line, " \t\n\r"); + text = strtok(NULL, " \t\n\r"); + Ki_PageDescr * sheet = SheetList[0]; + int ii; + for( ii = 0; sheet != NULL; ii++, sheet = SheetList[ii]) + { + if( stricmp( CONV_TO_UTF8(sheet->m_Name), text) == 0 ) + { + screen->m_CurrentSheet = sheet; + if ( sheet == &g_Sheet_user ) + { + text = strtok(NULL, " \t\n\r"); + if ( text ) sheet->m_Size.x = atoi(text); + text = strtok(NULL, " \t\n\r"); + if ( text ) sheet->m_Size.y = atoi(text); + } + break; + } + } + continue; + } + + if( strnicmp(Line,"Title",2) == 0 ) + { + ReadDelimitedText( buf, Line, 256); + screen->m_Title = CONV_FROM_UTF8(buf); + continue; + } + + if( strnicmp(Line,"Date",2) == 0 ) + { + ReadDelimitedText( buf, Line, 256); + screen->m_Date = CONV_FROM_UTF8(buf); + continue; + } + + if( strnicmp(Line,"Rev",2) == 0 ) + { + ReadDelimitedText( buf, Line, 256); + screen->m_Revision = CONV_FROM_UTF8(buf); + continue; + } + + if( strnicmp(Line,"Comp",4) == 0 ) + { + ReadDelimitedText( buf, Line, 256); + screen->m_Company = CONV_FROM_UTF8(buf); + continue; + } + + if( strnicmp(Line,"Comment1",8) == 0 ) + { + ReadDelimitedText( buf, Line, 256); + screen->m_Commentaire1 = CONV_FROM_UTF8(buf); + continue; + } + + if( strnicmp(Line,"Comment2",8) == 0 ) + { + ReadDelimitedText( buf, Line, 256); + screen->m_Commentaire2 = CONV_FROM_UTF8(buf); + continue; + } + + if( strnicmp(Line,"Comment3",8) == 0 ) + { + ReadDelimitedText( buf, Line, 256); + screen->m_Commentaire3 = CONV_FROM_UTF8(buf); + continue; + } + + if( strnicmp(Line,"Comment4",8) == 0 ) + { + ReadDelimitedText( buf, Line, 256); + screen->m_Commentaire4 = CONV_FROM_UTF8(buf); + continue; + } + } + return(FALSE); +} + +/********************************************************************/ +int WinEDA_PcbFrame::ReadPcbFile(wxDC * DC, FILE * File, bool Append) +/********************************************************************/ +/* Lit un fichier PCB .brd + Si Append == 0: l'ancien pcb en memoire est supprime + Sinon il y a ajout des elements +*/ +{ +char Line[1024]; +int LineNum = 0; +int nbsegm, nbmod; +EDA_BaseStruct * LastStructPcb = NULL, * StructPcb; +MODULE * LastModule = NULL, * Module; +EQUIPOT * LastEquipot = NULL, * Equipot; + + wxBusyCursor dummy; + + NbDraw = NbTrack = NbZone = NbMod = NbNets = -1; + m_Pcb->m_NbNets = 0; + m_Pcb->m_Status_Pcb = 0; + nbmod = 0; + + if ( Append ) + { + LastModule = m_Pcb->m_Modules; + for( ; LastModule != NULL; LastModule = (MODULE*) LastModule->Pnext ) + { + if ( LastModule->Pnext == NULL ) break; + } + LastStructPcb = m_Pcb->m_Drawings; + for( ; LastStructPcb != NULL; LastStructPcb = LastStructPcb->Pnext ) + { + if ( LastStructPcb->Pnext == NULL ) break; + } + LastEquipot = m_Pcb->m_Equipots; + for( ; LastEquipot != NULL; LastEquipot = (EQUIPOT*)LastEquipot->Pnext ) + { + if ( LastEquipot->Pnext == NULL ) break; + } + } + + while( GetLine(File, Line, &LineNum ) != NULL ) + { + + if(strnicmp(Line,"$EndPCB",6) == 0) break; + + if( strnicmp(Line,"$GENERAL",8) == 0 ) + { + ReadGeneralDescrPcb(DC, File, &LineNum); + continue; + } + + if( strnicmp(Line,"$SHEETDESCR",11) == 0 ) + { + ReadSheetDescr(m_CurrentScreen, File, &LineNum); + continue; + } + + if( strnicmp(Line,"$SETUP",6) == 0 ) + { + if( ! Append) + { + ReadSetup(File, &LineNum); + } + else + { + while( GetLine(File, Line, &LineNum ) != NULL ) + if( strnicmp(Line,"$EndSETUP",6) == 0 ) break; + } + continue; + } + + if(strnicmp(Line,"$EQUIPOT",7) == 0) + { + Equipot = new EQUIPOT(m_Pcb); + Equipot->ReadEquipotDescr(File, &LineNum); + if( LastEquipot == NULL ) + { + m_Pcb->m_Equipots = Equipot; + Equipot->Pback = m_Pcb; + } + else + { + Equipot->Pback = LastEquipot; + LastEquipot->Pnext = Equipot; + } + LastEquipot = Equipot; + m_Pcb->m_NbNets++; + continue; + } + if(strnicmp(Line,"$MODULE",7) == 0) + { + float Pas; + Pas = 100.0; if( NbMod > 1) Pas /= NbMod; + + Module = new MODULE(m_Pcb); + if( Module == NULL ) continue; + Module->ReadDescr(File, &LineNum); + + if( LastModule == NULL ) + { + m_Pcb->m_Modules = Module; + Module->Pback = m_Pcb; + } + else + { + Module->Pback = LastModule; + LastModule->Pnext = Module; + } + LastModule = Module; + nbmod++; +#ifdef PCBNEW + DisplayActivity((int)( Pas * nbmod), wxT("Modules:")); +#endif + Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); + continue; + } + + if(strnicmp(Line,"$TEXTPCB",8) == 0) + { + TEXTE_PCB * pcbtxt = new TEXTE_PCB(m_Pcb); + StructPcb = (EDA_BaseStruct*) pcbtxt; + pcbtxt->ReadTextePcbDescr(File, &LineNum); + if( LastStructPcb == NULL ) + { + m_Pcb->m_Drawings = StructPcb; + StructPcb->Pback = m_Pcb; + } + else + { + StructPcb->Pback = LastStructPcb; + LastStructPcb->Pnext = StructPcb; + } + LastStructPcb = StructPcb; +#ifdef PCBNEW + ((TEXTE_PCB*)StructPcb)->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR); +#endif + continue; + } + + if( strnicmp(Line,"$DRAWSEGMENT",10) == 0) + { + DRAWSEGMENT * DrawSegm = new DRAWSEGMENT(m_Pcb); + DrawSegm->ReadDrawSegmentDescr(File, &LineNum); + if( LastStructPcb == NULL ) + { + m_Pcb->m_Drawings = DrawSegm; + DrawSegm->Pback = m_Pcb; + } + else + { + DrawSegm->Pback = LastStructPcb; + LastStructPcb->Pnext = DrawSegm; + } + LastStructPcb = DrawSegm; +#ifdef PCBNEW + Trace_DrawSegmentPcb(DrawPanel, DC, DrawSegm, GR_OR); +#endif + continue; + } + + + if( strnicmp(Line,"$COTATION",9) == 0) + { + COTATION * Cotation = new COTATION(m_Pcb); + Cotation->ReadCotationDescr(File, &LineNum); + if( LastStructPcb == NULL ) + { + m_Pcb->m_Drawings = Cotation; + Cotation->Pback = m_Pcb; + } + else + { + Cotation->Pback = LastStructPcb; + LastStructPcb->Pnext = Cotation; + } + LastStructPcb = Cotation; +#ifdef PCBNEW + Cotation->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); +#endif + continue; + } + + if( strnicmp(Line,"$MIREPCB",8) == 0) + { + MIREPCB * Mire = new MIREPCB(m_Pcb); + Mire->ReadMirePcbDescr(File, &LineNum); + + if( LastStructPcb == NULL ) + { + m_Pcb->m_Drawings = Mire; + Mire->Pback = m_Pcb; + } + else + { + Mire->Pback = LastStructPcb; + LastStructPcb->Pnext = Mire; + } + LastStructPcb = Mire; +#ifdef PCBNEW + Mire->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); +#endif + continue; + } + + if(strnicmp(Line,"$TRACK",6) == 0) + { + TRACK * StartTrack = m_Pcb->m_Track; + nbsegm = 0; + + if( Append ) + { + for( ;StartTrack != NULL; StartTrack = (TRACK*)StartTrack->Pnext) + { + if( StartTrack->Pnext == NULL ) break; + } + } + +#ifdef PCBNEW + int ii = ReadListeSegmentDescr(DC, File, StartTrack, TYPETRACK, + &LineNum, NbTrack); + m_Pcb->m_NbSegmTrack += ii; +#endif + continue; + } + + if(strnicmp(Line,"$ZONE",5) == 0) + { + TRACK * StartZone = m_Pcb->m_Zone; + + if( Append ) + { + for( ;StartZone != NULL; StartZone = (TRACK*)StartZone->Pnext) + { + if( StartZone->Pnext == NULL ) break; + } + } + +#ifdef PCBNEW + int ii = ReadListeSegmentDescr(DC, File, StartZone,TYPEZONE, + &LineNum, NbZone); + m_Pcb->m_NbSegmZone += ii; +#endif + continue; + } + } + + Affiche_Message(wxEmptyString); + +#ifdef PCBNEW + Compile_Ratsnest(DC, TRUE); +#endif + // Size est donnee en 1/1000 " + return(1); +} + + +#ifdef PCBNEW +/***************************************************/ +int WinEDA_PcbFrame::SavePcbFormatAscii(FILE * File) +/****************************************************/ +/* Routine de sauvegarde du PCB courant sous format ASCII + retourne + 1 si OK + 0 si sauvegarde non faite +*/ +{ +int ii, NbModules, nseg; +float Pas; +char Line[256]; +EQUIPOT * Equipot; +TRACK * PtSegm; +EDA_BaseStruct * PtStruct; +MODULE * Module; + + wxBeginBusyCursor(); + + m_Pcb->m_Status_Pcb &= ~CONNEXION_OK; + + /* Calcul du nombre des modules */ + PtStruct = (EDA_BaseStruct *) m_Pcb->m_Modules; + NbModules = 0; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext) NbModules++; + + /* Ecriture de l'entete PCB : */ + fprintf(File,"PCBNEW-BOARD Version %d date %s\n\n",g_CurrentVersionPCB, + DateAndTime(Line) ); + + WriteGeneralDescrPcb(File); + WriteSheetDescr(m_CurrentScreen, File); + WriteSetup(File, this); + + /* Ecriture des donnes utiles du pcb */ + + Equipot = m_Pcb->m_Equipots; + Pas = 100.0; if( m_Pcb->m_NbNets) Pas /= m_Pcb->m_NbNets; + for(ii = 0; Equipot != NULL; ii++, Equipot = (EQUIPOT*) Equipot->Pnext) + { + Equipot->WriteEquipotDescr(File); + DisplayActivity((int)( Pas * ii ), wxT("Equipot:") ); + } + + Pas = 100.0; if(NbModules) Pas /= NbModules; + Module = m_Pcb->m_Modules; + for( ii = 1 ; Module != NULL; Module = Module->Next(), ii++) + { + Module->WriteDescr(File); + DisplayActivity((int)(ii * Pas) , wxT("Modules:")); + } + + + /* sortie des inscriptions du PCB: */ + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch ( PtStruct->m_StructType ) + { + case TYPETEXTE: + ((TEXTE_PCB*)PtStruct)->WriteTextePcbDescr(File) ; + break; + + case TYPEDRAWSEGMENT: + ((DRAWSEGMENT *)PtStruct)->WriteDrawSegmentDescr(File); + break; + + + case TYPEMIRE: + ((MIREPCB *) PtStruct)->WriteMirePcbDescr(File); + break; + + + case TYPECOTATION: + ((COTATION *)PtStruct)->WriteCotationDescr(File); + break; + + case TYPEMARQUEUR: /* sauvegarde inutile */ + break; + + default: + DisplayError(this, wxT("Unknown Draw Type")); + break; + } + } + + + Pas = 100.0; + if( m_Pcb->m_NbSegmTrack) Pas /= (m_Pcb->m_NbSegmTrack); + fprintf(File,"$TRACK\n"); + PtSegm = m_Pcb->m_Track; + DisplayActivity(0, wxT("Tracks:")); + for( nseg = 0, ii = 0; PtSegm != NULL; ii++, PtSegm = (TRACK*) PtSegm->Pnext) + { + ((TRACK*) PtSegm)->WriteTrackDescr(File); + if ( nseg != (int)( ii * Pas) ) + { + nseg = (int)( ii * Pas); + DisplayActivity(nseg, wxT("Tracks:")); + } + } + fprintf(File,"$EndTRACK\n"); + + fprintf(File,"$ZONE\n"); + PtSegm = (TRACK*) m_Pcb->m_Zone; + ii = m_Pcb->m_NbSegmZone; + Pas = 100.0; if(ii) Pas /= ii; + PtSegm = m_Pcb->m_Zone; + DisplayActivity(0, wxT("Zones:")); + for( nseg = 0, ii = 0; PtSegm != NULL; ii++, PtSegm = (TRACK*) PtSegm->Pnext) + { + ((TRACK*) PtSegm)->WriteTrackDescr(File); + if ( nseg != (int)( ii * Pas) ) + { + nseg = (int)( ii * Pas); + DisplayActivity(nseg, wxT("Zones:")); + } + } + + fprintf(File,"$EndZONE\n"); + fprintf(File,"$EndBOARD\n"); + + wxEndBusyCursor(); + + Affiche_Message(wxEmptyString); + return 1; +} +#endif + diff --git a/pcbnew/lay2plot.cpp b/pcbnew/lay2plot.cpp new file mode 100644 index 0000000000..5cdbfe3b69 --- /dev/null +++ b/pcbnew/lay2plot.cpp @@ -0,0 +1,216 @@ + /**********************************************/ + /* Routine de selection de couches pour trace */ + /**********************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "pcbplot.h" + +#include "protos.h" + + +/* Variables locales : */ + +/* Routines Locales */ +static void Plot_Module(WinEDA_DrawPanel * panel, wxDC * DC, MODULE * Module, + int draw_mode, int masklayer); + + +/****************************/ +int GetLayerNumber(void) +/****************************/ +/* retourne le nombre de couches a tracer +*/ +{ +int ii = 29; +//TO REDO +return ii; +} + + +/**********************************************************************************/ +void WinEDA_DrawPanel::PrintPage(wxDC *DC, bool Print_Sheet_Ref, int printmasklayer) +/**********************************************************************************/ +/* routine de trace du pcb, avec selection des couches */ +{ +MODULE * Module; +EDA_BaseStruct * PtStruct; +int drawmode = GR_COPY; +DISPLAY_OPTIONS save_opt; +TRACK * pt_piste; +WinEDA_BasePcbFrame * frame = (WinEDA_BasePcbFrame *) m_Parent; +BOARD * Pcb = frame->m_Pcb; + + save_opt = DisplayOpt; + if( printmasklayer & ALL_CU_LAYERS ) DisplayOpt.DisplayPadFill = FILLED; + else DisplayOpt.DisplayPadFill = SKETCH; + frame->m_DisplayPadFill = DisplayOpt.DisplayPadFill; + frame->m_DisplayPadNum = DisplayOpt.DisplayPadNum = FALSE; + DisplayOpt.DisplayPadNoConn = FALSE; + DisplayOpt.DisplayPadIsol = FALSE; + DisplayOpt.DisplayModEdge = FILLED; + DisplayOpt.DisplayModText = FILLED; + frame->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = FILLED; + DisplayOpt.DisplayTrackIsol = FALSE; + DisplayOpt.DisplayDrawItems = FILLED; + DisplayOpt.DisplayZones = TRUE; + + printmasklayer |= EDGE_LAYER; + + /* Trace des elements particuliers de Drawings Pcb */ + PtStruct = Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch(PtStruct->m_StructType) + { + case TYPEDRAWSEGMENT: + if( (g_TabOneLayerMask[((DRAWSEGMENT*)PtStruct)->m_Layer] & printmasklayer) == 0 ) + break; + Trace_DrawSegmentPcb(this, DC, (DRAWSEGMENT*) PtStruct, drawmode); + break; + + case TYPECOTATION: + if( (g_TabOneLayerMask[((COTATION*)PtStruct)->m_Layer] & printmasklayer) == 0 ) + break; + ((COTATION*) PtStruct)->Draw(this, DC, wxPoint(0,0), drawmode); + break; + + case TYPETEXTE: + { + if( (g_TabOneLayerMask[((TEXTE_PCB *)PtStruct)->m_Layer] & printmasklayer) == 0 ) + break; + ((TEXTE_PCB *) PtStruct)->Draw(this, DC, wxPoint(0,0), drawmode); + break; + } + + case TYPEMIRE: + if( (g_TabOneLayerMask[((MIREPCB*)PtStruct)->m_Layer] & printmasklayer) == 0 ) break; + ((MIREPCB*) PtStruct)->Draw(this, DC, wxPoint(0,0), drawmode); + break; + + case TYPEMARQUEUR: /* Trace des marqueurs */ + break; + + default: break; + } + } + + /* trace des pistes */ + pt_piste = Pcb->m_Track; + for ( ; pt_piste != NULL ; pt_piste = (TRACK*) pt_piste->Pnext ) + { + if( (printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 ) continue; + if ( pt_piste->m_StructType == TYPEVIA ) /* VIA rencontree */ + { + int rayon = pt_piste->m_Width >> 1; + int color = g_DesignSettings.m_ViaColor[pt_piste->m_Shape]; + GRSetDrawMode(DC, drawmode); + GRFilledCircle(&m_ClipBox, DC, pt_piste->m_Start.x, pt_piste->m_Start.y, + rayon, color, color) ; + } + else pt_piste->Draw(this, DC, drawmode); + } + + pt_piste = Pcb->m_Zone; + for ( ; pt_piste != NULL ; pt_piste = (TRACK*) pt_piste->Pnext ) + { + if( (printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 ) continue ; + pt_piste->Draw(this, DC, drawmode); + } + + // Trace des modules en dernier, pour imprimer en blanc le trou des pastilles + Module = (MODULE*) Pcb->m_Modules; + for ( ; Module != NULL; Module = (MODULE *) Module->Pnext ) + { + Plot_Module(this, DC, Module, drawmode, printmasklayer); + } + + /* trace des trous des vias*/ + pt_piste = Pcb->m_Track; + int rayon = g_DesignSettings.m_ViaDrill / 2; + int color = WHITE; + for ( ; pt_piste != NULL ; pt_piste = (TRACK*) pt_piste->Pnext ) + { + if( (printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 ) continue; + if ( pt_piste->m_StructType == TYPEVIA ) /* VIA rencontree */ + { + GRSetDrawMode(DC, drawmode); + GRFilledCircle(&m_ClipBox, DC, pt_piste->m_Start.x, pt_piste->m_Start.y, + rayon, color, color) ; + } + } + + if ( Print_Sheet_Ref ) + m_Parent->TraceWorkSheet( DC, ActiveScreen); + + DisplayOpt = save_opt; + frame->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; + frame->m_DisplayPadFill = DisplayOpt.DisplayPadFill; + frame->m_DisplayPadNum = DisplayOpt.DisplayPadNum; +} + + +/***********************************************************/ +static void Plot_Module(WinEDA_DrawPanel * panel, wxDC * DC, + MODULE * Module, int draw_mode, int masklayer) +/***********************************************************/ +{ +D_PAD * pt_pad ; +EDA_BaseStruct * PtStruct; +TEXTE_MODULE * TextMod; +int mlayer; + + /* trace des pastilles */ + pt_pad = Module->m_Pads; + for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + { + if( (pt_pad->m_Masque_Layer & masklayer ) == 0 ) continue; + pt_pad->Draw(panel, DC, wxPoint(0,0), draw_mode); + } + + /* impression des graphismes */ + PtStruct = Module->m_Drawings; + mlayer = g_TabOneLayerMask[Module->m_Layer]; + if( Module->m_Layer == CUIVRE_N) mlayer = SILKSCREEN_LAYER_CU; + if( Module->m_Layer == CMP_N) mlayer = SILKSCREEN_LAYER_CMP; + if( mlayer & masklayer ) + { + /* Analyse des autorisations de trace pour les textes VALEUR et REF */ + bool trace_val, trace_ref; + trace_val = trace_ref = TRUE; // les 2 autorisations de tracer sont donnees + if(Module->m_Reference->m_NoShow) trace_ref = FALSE; + if(Module->m_Value->m_NoShow) trace_val = FALSE; + + if(trace_ref) + Module->m_Reference->Draw(panel, DC, wxPoint(0,0), draw_mode ); + if(trace_val) + Module->m_Value->Draw(panel, DC, wxPoint(0,0), draw_mode ); + } + + for( ;PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPETEXTEMODULE: + if( (mlayer & masklayer ) == 0) break; + + TextMod = (TEXTE_MODULE *) PtStruct; + TextMod->Draw(panel, DC, wxPoint(0,0), draw_mode ); + break; + + case TYPEEDGEMODULE: + { + EDGE_MODULE * edge = (EDGE_MODULE *) PtStruct; + if( (g_TabOneLayerMask[edge->m_Layer] & masklayer ) == 0) break; + edge->Draw(panel, DC, wxPoint(0,0), draw_mode); + break; + } + default: break; + } + } +} + + diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp new file mode 100644 index 0000000000..3169fb5f47 --- /dev/null +++ b/pcbnew/librairi.cpp @@ -0,0 +1,831 @@ + /***************************************/ + /* Gestion de la LIBRAIRIE des MODULES */ + /***************************************/ + + /* Fichier LIBRAIRI.CPP */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + +/* +Format de l'entete de la Librairie: +chaine ENTETE-LIBRAIRIE date-heure +$INDEX +liste des noms modules ( 1 nom par ligne) +$EndINDEX +liste des descriptions des Modules +$EndLIBRARY +*/ + +#define OLD_EXT wxT(".bak") +#define FILETMP_EXT wxT(".$$$") + + +/* Fonctions locales */ +static bool CreateDocLibrary(const wxString & LibName); + +/*********************************************************/ +MODULE * WinEDA_ModuleEditFrame::Import_Module(wxDC * DC) +/*********************************************************/ +/* + Importation de modules Hors librairie + Lit 1 fichier type Empreinte et place le module sur PCB +*/ +{ +int NbLine = 0; +char Line[1024]; +wxString CmpFullFileName; +FILE * dest; +MODULE * module = NULL; + + /* Lecture Fichier module */ + CmpFullFileName = EDA_FileSelector( _("Import Module:"), + wxEmptyString, /* Chemin par defaut */ + wxEmptyString, /* nom fichier par defaut */ + EXT_CMP, /* extension par defaut */ + EXT_CMP_MASK, /* Masque d'affichage */ + this, + wxFD_OPEN, + TRUE + ); + + if ( CmpFullFileName == wxEmptyString ) return NULL; + + if ( (dest = wxFopen(CmpFullFileName, wxT("rt")) ) == NULL ) + { + wxString msg; + msg.Printf( _("File <%s> not found"), CmpFullFileName.GetData()); + DisplayError(this, msg) ; + return NULL; + } + + /* Lecture Entete */ + GetLine(dest, Line, &NbLine); + if(strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB) != 0) + { + DisplayError(this, _("Not a module file")); + return NULL; + } + + /* Lecture du fichier: recherche du debut de la descr module */ + while( GetLine(dest, Line, &NbLine) != NULL) + { + if(strnicmp( Line,"$MODULE",7) == 0) break; + } + + module = new MODULE(m_Pcb); + module->ReadDescr(dest, &NbLine); + fclose(dest); + + /* Mise a jour du chainage */ + if( m_Pcb->m_Modules ) + { + m_Pcb->m_Modules->Pback = module; + } + module->Pnext = m_Pcb->m_Modules; + module->Pback = m_Pcb; + m_Pcb->m_Modules = module; + + /* Affichage des caracteristiques : */ + module->Display_Infos(this); + Place_Module(module, DC) ; + m_Pcb->m_Status_Pcb = 0 ; + build_liste_pads(); + + return module; +} + +/************************************************************************/ +void WinEDA_ModuleEditFrame::Export_Module(MODULE* ptmod, bool createlib) +/************************************************************************/ +/* +Genere 1 fichier type Empreinte a partir de la description du module sur PCB +*/ +{ +wxString FullFileName, Mask( wxT("*") ); +char Line[1025]; +FILE * dest; +wxString msg, path; + + if ( ptmod == NULL ) return; + + ptmod->m_LibRef = ptmod->m_Reference->m_Text; + FullFileName = ptmod->m_LibRef; + FullFileName += createlib ? LibExtBuffer : EXT_CMP; + + Mask += createlib ? LibExtBuffer : EXT_CMP; + + if ( createlib ) path = g_RealLibDirBuffer; + FullFileName = EDA_FileSelector( createlib ? _("Create lib") : _("Export Module:"), + path, /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + createlib ? LibExtBuffer : EXT_CMP, /* extension par defaut */ + Mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + TRUE + ); + + if ( FullFileName.IsEmpty() ) return; + + if ( createlib && wxFileExists(FullFileName) ) + { + msg.Printf( _("File %s exists, OK to replace ?"), + FullFileName.GetData()); + if( ! IsOK(this, msg) ) return; + } + + /* Generation du fichier Empreinte */ + if ( (dest = wxFopen(FullFileName, wxT("wt")) ) == NULL ) + { + msg.Printf( _("Unable to create <%s>"),FullFileName.GetData()) ; + DisplayError(this, msg) ; + return ; + } + + fprintf(dest,"%s %s\n", ENTETE_LIBRAIRIE, DateAndTime(Line)); + fputs("$INDEX\n",dest); + + fprintf(dest,"%s\n", CONV_TO_UTF8(ptmod->m_LibRef) ); + fputs("$EndINDEX\n",dest); + + m_Pcb->m_Modules->WriteDescr(dest); + + fputs("$EndLIBRARY\n",dest); + fclose(dest) ; + msg.Printf( _("Module exported in file <%s>"),FullFileName.GetData()) ; + DisplayInfo(this, msg) ; +} + +/**********************************************************/ +void WinEDA_ModuleEditFrame::Delete_Module_In_Library(const + wxString & libname) +/**********************************************************/ +{ +int ii, NoFound = 1, LineNum = 0; +char Line[1024], Name[256]; +wxString NewLib, OldLib; +FILE * dest, * lib_module; +wxString CmpName, msg; + + /* Demande du nom du composant a supprimer */ + CmpName = Select_1_Module_From_List( this, libname, wxEmptyString, wxEmptyString ); + if( CmpName == wxEmptyString ) return; + + /* Confirmation */ + msg.Printf( _("Ok to delete module %s in library %s"), + CmpName.GetData(), libname.GetData() ); + if( !IsOK(this, msg) ) return; + + OldLib = libname; + + if ((lib_module = wxFopen( OldLib, wxT("rt"))) == NULL ) + { + wxString msg; + msg = _("Library ") + OldLib + _(" not found"); + DisplayError(this, msg); + return; + } + + + /* lecture entete */ + GetLine(lib_module,Line, &LineNum) ; + + if(strnicmp( Line,ENTETE_LIBRAIRIE, L_ENTETE_LIB) != 0) + { + DisplayError(this, _("Not a Library file")); + fclose(lib_module); + return; + } + + /* lecture des nom des composants */ + while( GetLine(lib_module, Line, &LineNum) ) + { + if( strnicmp( Line, "$INDEX",6) == 0 ) + { + while( GetLine(lib_module, Line, &LineNum) ) + { + StrPurge(Line); + msg = CONV_FROM_UTF8(Line); + if( CmpName.CmpNoCase(msg) == 0) /* composant trouve */ + { + NoFound = 0; break; + } + if( strnicmp( Line, "$EndINDEX",9) == 0 ) break; + } + } + if( strnicmp( Line, "$EndINDEX",9) == 0 ) break; + } + + if( NoFound ) + { + fclose(lib_module); + msg.Printf( _("Module [%s] not found"), CmpName.GetData() ); + DisplayError(this, msg); + return ; + } + + /* Creation de la nouvelle librairie */ + NewLib = OldLib; + ChangeFileNameExt(NewLib,FILETMP_EXT); + if ((dest = wxFopen(NewLib, wxT("wt") )) == NULL ) + { + fclose(lib_module) ; + wxString msg; + msg = _("Unable to create ") + NewLib; + DisplayError(this, msg); + return; + } + +wxBeginBusyCursor(); + + /* Creation de l'entete avec nouvelle date */ + fprintf(dest,ENTETE_LIBRAIRIE); + fprintf(dest," %s\n$INDEX\n", DateAndTime(Line) ); + + fseek(lib_module,0,0); GetLine(lib_module, Line, &ii); + while(GetLine(lib_module,Line, &ii)) + { + if ( strnicmp(Line,"$M",2 ) == 0 ) break; + if ( strnicmp(Line,"$INDEX",6 ) == 0 ) + { + while(GetLine(lib_module,Line, &ii)) + { + if ( strnicmp(Line,"$EndINDEX",9 ) == 0 ) break; + StrPurge(Line); + msg = CONV_FROM_UTF8(Line); + if( CmpName.CmpNoCase(msg) != 0 ) + fprintf(dest,"%s\n",Line); + } + } + if ( strnicmp(Line,"$EndINDEX",9 ) == 0 ) break; + } + + fprintf(dest,"$EndINDEX\n"); + + /* Copie des modules */ + while( GetLine(lib_module, Line, &LineNum) ) + { + StrPurge(Line); + if( strnicmp( Line, "$MODULE", 7) == 0 ) + { + sscanf(Line+7," %s", Name); + msg = CONV_FROM_UTF8(Name); + if( msg.CmpNoCase(CmpName) == 0 ) + { + /* suppression ancien module */ + while( GetLine(lib_module, Line, &LineNum) ) + { + if( strnicmp( Line, "$EndMODULE", 9) == 0 ) break; + } + continue; + } + } + fprintf(dest, "%s\n", Line); + } + + fclose(lib_module); + fclose(dest) ; + +wxEndBusyCursor(); + + /* Le fichier ancienne librairie est renommee en .bak */ +wxString BakFilename = OldLib; + ChangeFileNameExt( BakFilename, OLD_EXT); + + if( wxFileExists(BakFilename) ) wxRemoveFile(BakFilename); + + if( ! wxRenameFile(OldLib, BakFilename) ) + { + DisplayError(this, wxT("Librairi.cpp: rename .bak err")); + return; + } + + /* Le fichier temporaire est renommee comme l'ancienne Lib */ + if( ! wxRenameFile(NewLib,OldLib) ) + { + DisplayError(this, wxT("Librairi.cpp: rename err 2") ); + return; + } + + msg.Printf( _("Component %s deleted in library %s"), CmpName.GetData(), OldLib.GetData() ) ; + Affiche_Message(msg) ; + + CreateDocLibrary(OldLib); +} + + +/***********************************************************************/ +void WinEDA_BasePcbFrame::Archive_Modules(const wxString & LibName, + bool NewModulesOnly) +/***********************************************************************/ +/* + Sauve en Librairie: + tous les nouveaux modules ( c.a.d. les modules + n'existant pas deja (si NewModulesOnly == TRUE) + tous les modules (si NewModulesOnly == FALSE) +*/ +{ +int ii, NbModules = 0; +float Pas; +MODULE * Module; +wxString FullFileName = LibName; + + if ( m_Pcb->m_Modules == NULL ) + { + DisplayInfo(this, _(" No modules to archive!") ); + return; + } + + if ( FullFileName.IsEmpty() ) + { + wxString Mask = wxT("*") + LibExtBuffer; + FullFileName = EDA_FileSelector( _("Library"), + g_RealLibDirBuffer, /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + LibExtBuffer, /* extension par defaut */ + Mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + TRUE + ); + + if ( FullFileName.IsEmpty() ) return; + } + + bool file_exists = wxFileExists(FullFileName); + if ( ! NewModulesOnly && file_exists ) + { + wxString msg; + msg.Printf( _("File %s exists, OK to replace ?"), FullFileName.GetData()); + if( ! IsOK(this, msg) ) return; + } + + DrawPanel->m_AbortRequest = FALSE; + + // Create a new, empty library if no old lib, or if archive all modules + if ( ! NewModulesOnly || ! file_exists ) + { + FILE * lib_module; + if ((lib_module = wxFopen(FullFileName, wxT("w+t"))) == NULL ) + { + wxString msg = _("Unable to create ") + FullFileName; + DisplayError(this, msg); + return; + } + char Line[256]; + fprintf(lib_module,"%s %s\n", ENTETE_LIBRAIRIE, DateAndTime(Line)); + fputs("$INDEX\n",lib_module); + fputs("$EndINDEX\n",lib_module); + fputs("$EndLIBRARY\n",lib_module); + fclose(lib_module) ; + } + + /* Calcul du nombre de modules */ + Module = (MODULE *) m_Pcb->m_Modules; + for( ;Module != NULL; Module = (MODULE *)Module->Pnext) NbModules++; + Pas = (float) 100 / NbModules; + DisplayActivity(0, wxEmptyString); + + Module = (MODULE *) m_Pcb->m_Modules; + for( ii = 1 ;Module != NULL; ii++, Module = (MODULE *)Module->Pnext) + { + if( Save_1_Module(FullFileName, Module, + NewModulesOnly ? FALSE : TRUE, FALSE) == 0 ) break; + DisplayActivity((int)( ii * Pas) , wxEmptyString); + /* Tst demande d'arret de sauvegarde ( key ESCAPE actionnee ) */ + if( DrawPanel->m_AbortRequest ) break; + } + + CreateDocLibrary(LibName); +} + + +/*****************************************************************/ +int WinEDA_BasePcbFrame::Save_1_Module(const wxString & LibName, + MODULE* Module, bool Overwrite, bool DisplayDialog) +/*****************************************************************/ +/* + sauve en Librairie le module Module: + si no_replace == TRUE, s'il est nouveau. + + retourne + 1 si OK + 0 si abort ou probleme +*/ +{ +int newmodule, end; +int LineNum = 0, tmp; +char Name[256], Line[1024]; +wxString Name_Cmp; +wxString NewLib, OldLib, msg; +FILE * lib_module, *dest; +bool added = TRUE; + + Module->Display_Infos(this); + + if ( ! wxFileExists(LibName) ) + { + msg.Printf( _("Library %s not found"), LibName.GetData()); + DisplayError(this, msg); + return 0; + } + + + /* Demande du nom du composant en librairie */ + Name_Cmp = Module->m_LibRef; + + if( DisplayDialog ) + { + Get_Message(_("Name:"), Name_Cmp, this ) ; + if( Name_Cmp.IsEmpty() ) return(0); + Name_Cmp.Trim(TRUE); + Name_Cmp.Trim(FALSE); + Module->m_LibRef = Name_Cmp; + } + + if ((lib_module = wxFopen(LibName, wxT("rt"))) == NULL ) + { + msg.Printf( _("Unable to open %s"), LibName.GetData()); + DisplayError(this, msg); + return 0; + } + + /* lecture entete : ENTETE_LIBRAIRIE */ + GetLine(lib_module, Line, &LineNum) ; + if(strnicmp( Line,ENTETE_LIBRAIRIE, L_ENTETE_LIB) != 0) + { + fclose(lib_module) ; + msg.Printf( _("File %s is not a eeschema library"), LibName.GetData()); + DisplayError(this, msg); + return(0); + } + + /* lecture des noms des composants - verif si le module est deja existant */ + newmodule = 1; end = 0; + while( !end && GetLine(lib_module, Line, &LineNum) ) + { + if( Line[0] != '$' ) continue; + if( strncmp( Line+1, "INDEX",5) != 0 ) continue; + + while( GetLine(lib_module, Line, &LineNum) ) + { + if( strncmp( Line, "$EndINDEX",9) == 0 ) + { + end = 1; break; + } + + StrPurge(Line); + msg = CONV_FROM_UTF8(Line); + if( Name_Cmp.CmpNoCase(msg) == 0) /* composant trouve */ + { + added = FALSE; + newmodule = 0; + if( DisplayDialog ) + { + msg = _("Module exists Line "); + msg << LineNum; + Affiche_Message(msg) ; + } + if( ! Overwrite) /* le module n'est pas a sauver car deja existant */ + { + fclose(lib_module); return(1); + } + end = 1; break; + } + } + } + fclose(lib_module); + + /* Creation de la nouvelle librairie */ + + if ((lib_module = wxFopen(LibName, wxT("rt"))) == NULL ) + { + DisplayError(this, wxT("Librairi.cpp: Error oldlib not found")); + return(0); + } + + NewLib = LibName; + ChangeFileNameExt(NewLib, FILETMP_EXT); + if ((dest = wxFopen(NewLib, wxT("w+t"))) == NULL ) + { + fclose(lib_module) ; + msg = _("Unable to create ") + NewLib; + DisplayError(this, msg); + return(0); + } + +wxBeginBusyCursor() ; + + /* Creation de l'entete avec nouvelle date */ + fprintf(dest,ENTETE_LIBRAIRIE); + fprintf(dest," %s\n$INDEX\n", DateAndTime(Line) ); + + LineNum = 0; + GetLine(lib_module, Line, &LineNum); + while(GetLine(lib_module,Line, &LineNum)) + { + StrPurge(Line); + if ( strnicmp(Line,"$M",2 ) == 0 ) break; + if ( strnicmp(Line,"$INDEX",6 ) == 0 ) + { + while(GetLine(lib_module,Line, &LineNum)) + { + if ( strnicmp(Line,"$EndINDEX",9 ) == 0 ) break; + fprintf(dest,"%s\n",Line); + } + } + if(newmodule) fprintf(dest,"%s\n",CONV_TO_UTF8(Name_Cmp) ); + if ( strnicmp(Line,"$EndINDEX",0 ) == 0 ) break; + } + + fprintf(dest,"$EndINDEX\n"); + + /* Copie des modules, jusqu'au module a supprimer */ + while( GetLine(lib_module, Line, &LineNum) ) + { + StrPurge(Line); + if( strnicmp( Line, "$EndLIBRARY", 8) == 0 ) continue; + if( strnicmp( Line, "$MODULE", 7) == 0 ) + { + sscanf(Line+7," %s", Name); + msg = CONV_FROM_UTF8(Name); + if( msg.CmpNoCase(Name_Cmp) == 0 ) + { + /* suppression ancien module */ + while( GetLine(lib_module, Line, &LineNum) ) + { + if( strnicmp( Line, "$EndMODULE", 9) == 0 ) break; + } + continue; + } + } + fprintf(dest,"%s\n",Line); + } + + /* Ecriture du module ( en fin de librairie ) */ + tmp = Module->m_TimeStamp; Module->m_TimeStamp = 0; + Module->WriteDescr(dest); + fprintf(dest,"$EndLIBRARY\n"); + Module->m_TimeStamp = tmp; + + fclose(dest) ; fclose(lib_module) ; + +wxEndBusyCursor() ; + + /* L'ancien fichier librairie est renomme en .bak */ + OldLib = LibName; + ChangeFileNameExt ( OldLib, OLD_EXT); + + if( wxFileExists(OldLib) ) wxRemoveFile(OldLib); + + if ( ! wxRenameFile(LibName, OldLib ) ) + DisplayError(this, wxT("Librairi.cpp: rename .bak err") ); + + /* Le nouveau fichier librairie est renomme */ + if ( ! wxRenameFile(NewLib,LibName) ) + { + DisplayError(this, wxT("Librairi.cpp: rename NewLib err") ); + return(0); + } + + CreateDocLibrary(OldLib); + + if ( DisplayDialog ) + { + msg = _("Component ") ; msg += Name_Cmp; + msg += added ? _(" added in ") : _(" replaced in "); + msg += LibName; + Affiche_Message(msg); + } + + return(1); +} + + +/************************************************************************************/ +MODULE * WinEDA_BasePcbFrame::Create_1_Module(wxDC * DC, const wxString & module_name) +/************************************************************************************/ + +/* Creation d'un module : On place d'office les 2ers textes : + 1er = type REF: nom du module + 2eme = type VALEUR: "VAL**" + Le module est insere en debut de liste des modules +*/ + +{ +MODULE* Module ; +wxString Line; +wxPoint newpos; + + /* Demande du nom du nouveau module */ + if ( module_name.IsEmpty() ) + { + if ( Get_Message( _("Module Reference:"), Line, this ) != 0 ) return NULL; + } + + else Line = module_name; + Line.Trim(TRUE); + Line.Trim(FALSE); + + Module = new MODULE(m_Pcb); + + Module->Pnext = m_Pcb->m_Modules; + Module->Pback = m_Pcb; + if( m_Pcb->m_Modules ) + { + m_Pcb->m_Modules->Pback = Module; + } + m_Pcb->m_Modules = Module; + + /* Creation du module : On place d'office les 2 textes ref et val : + 1er = type REF: nom du module + 2eme = type VALEUR: "VAL**" */ + + /* Mise a jour des caract du nouveau module */ + newpos = m_CurrentScreen->m_Curseur; + Module->SetPosition(newpos); + Module->m_LastEdit_Time = time(NULL); + + /* Mise a jour du nom de Librairie (reference libr) */ + Module->m_LibRef = Line; + + /* Mise a jour de la reference: */ + Module->m_Reference->m_Text = Line; + Module->m_Reference->SetWidth(ModuleTextWidth); + Module->m_Reference->m_Size = ModuleTextSize; + + /* mise a jour de la valeurs */ + Module->m_Value->m_Text = wxT("VAL**"); + Module->m_Value->SetWidth(ModuleTextWidth); + Module->m_Value->m_Size = ModuleTextSize; + + Module->Display_Infos(this); + return Module; +} + + +/*******************************************************/ +void WinEDA_ModuleEditFrame::Select_Active_Library(void) +/*******************************************************/ +{ + if ( g_LibName_List.GetCount() == 0 ) return; + +WinEDAListBox * LibListBox = new WinEDAListBox(this, _("Active Lib:"), + NULL, m_CurrentLib, NULL, wxColour(200, 200, 255) ); + + LibListBox->InsertItems(g_LibName_List); + + int ii = LibListBox->ShowModal(); + if ( ii >= 0 ) m_CurrentLib = LibListBox->GetTextSelection(); + + LibListBox->Destroy(); + + SetTitle( _("Module Editor (lib: ") + m_CurrentLib + wxT(")") ); + return; +} + + + + +/**********************************************************************/ +int WinEDA_ModuleEditFrame::Create_Librairie(const wxString & LibName) +/**********************************************************************/ +{ +FILE * lib_module; +wxString msg; + + if ( wxFileExists(LibName) ) + { + msg = _("Library exists ") + LibName; + DisplayError(this, msg); + return(0); + } + + if ((lib_module = wxFopen(LibName, wxT("wt") )) == NULL ) + { + msg = _("Unable to create ") + LibName; + DisplayError(this, msg); + return(-1); + } + + /* Ecriture de l'entete de la nouvelle librairie */ + if( fprintf(lib_module,ENTETE_LIBRAIRIE) == 0) + { + msg = _("Create error ") + LibName; + DisplayError(this, msg); + fclose(lib_module) ; return(-1); + } + + fprintf(lib_module," %s\n", DateAndTime(cbuf)); + fputs("$INDEX\n",lib_module); + fputs("$EndINDEX\n",lib_module); + fclose(lib_module) ; + + return(1); +} + + + +/******************************************************/ +static bool CreateDocLibrary(const wxString & LibName) +/*****************************************************/ +/* Creation du fichier .dcm associe a la librairie LibName + (full file name) +*/ +{ +char Line[1024]; +wxString Name, Doc, KeyWord; +wxString LibDocName; +FILE * LibMod, *LibDoc; + + LibDocName = LibName; + ChangeFileNameExt(LibDocName, EXT_DOC); + + LibMod = wxFopen( LibName, wxT("rt") ); + if ( LibMod == NULL ) return FALSE; + + /* lecture entete librairie*/ + GetLine(LibMod, Line, NULL, sizeof(Line) -1); + if(strnicmp( Line,ENTETE_LIBRAIRIE, L_ENTETE_LIB) != 0) + { + fclose(LibMod); + return FALSE; + } + + LibDoc = wxFopen( LibDocName, wxT("wt") ); + if ( LibDoc == NULL ) + { + fclose( LibMod ); + return FALSE; + } + fprintf(LibDoc,ENTETE_LIBDOC); + fprintf(LibDoc," %s\n", DateAndTime(cbuf)); + + /* Lecture de la librairie */ + Name = Doc = KeyWord = wxEmptyString; + while( GetLine(LibMod,Line, NULL, sizeof(Line) -1) ) + { + if( Line[0] != '$' ) continue; + if( strnicmp( Line, "$MODULE",6) == 0 ) + { + while( GetLine(LibMod,Line, NULL, sizeof(Line) -1) ) + { + if( Line[0] == '$' ) + { + if( Line[1] == 'E' ) break; + if( Line[1] == 'P' ) /* Pad Descr */ + { + while( GetLine(LibMod,Line, NULL, sizeof(Line) -1) ) + { + if( (Line[0] == '$') && (Line[1] == 'E') ) + break; + } + } + } + if( Line[0] == 'L' ) /* LibName */ + Name = CONV_FROM_UTF8(StrPurge(Line+3)); + + if( Line[0] == 'K' ) /* KeyWords */ + KeyWord = CONV_FROM_UTF8(StrPurge(Line+3)); + + if( Line[0] == 'C' ) /* Doc */ + Doc = CONV_FROM_UTF8(StrPurge(Line+3)); + } + + if( (Name != wxEmptyString) && ((Doc != wxEmptyString) || (KeyWord != wxEmptyString)) )/* Generation de la doc du composant */ + { + fprintf(LibDoc,"#\n$MODULE %s\n",CONV_TO_UTF8(Name)); + fprintf(LibDoc,"Li %s\n",CONV_TO_UTF8(Name)); + if( Doc != wxEmptyString) + fprintf( LibDoc,"Cd %s\n", CONV_TO_UTF8(Doc)); + + if( KeyWord != wxEmptyString) + fprintf( LibDoc,"Kw %s\n", CONV_TO_UTF8(KeyWord)); + + fprintf( LibDoc,"$EndMODULE\n"); + } + Name = Doc = KeyWord = wxEmptyString; + } /* Fin lecture desc 1 module */ + + if( strnicmp( Line,"$INDEX",6) == 0 ) + { + while( GetLine(LibMod,Line, NULL, sizeof(Line)-1) ) + { + if( strnicmp( Line,"$EndINDEX",9) == 0 ) break; + } /* Fin Lecture INDEX */ + } + } /* Fin lecture 1 Librairie */ + + fclose( LibMod ); + fprintf( LibDoc,"#\n$EndLIBDOC\n"); + fclose( LibDoc ); + return TRUE; +} + + diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp new file mode 100644 index 0000000000..420996882b --- /dev/null +++ b/pcbnew/loadcmp.cpp @@ -0,0 +1,556 @@ + /**********************************************/ + /* Footprints selection and loading functions */ + /**********************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + +class ModList +{ +public: + ModList * Next; + wxString m_Name, m_Doc, m_KeyWord; + +public: + ModList(void) + { + Next = NULL; + } + ~ModList(void) + { + } +}; + +/* Fonctions locales */ +static void DisplayCmpDoc(wxString & Name); +static void ReadDocLib(const wxString & ModLibName ); +/*****/ + +/* variables locales */ +static ModList * MList; + + +/***************************************************************************/ +void WinEDA_ModuleEditFrame::Load_Module_Module_From_BOARD( MODULE * Module ) +/***************************************************************************/ +{ +MODULE * NewModule; + + if ( Module == NULL ) + { + if (m_Parent->m_PcbFrame == NULL) return; + if (m_Parent->m_PcbFrame->m_Pcb == NULL) return; + if (m_Parent->m_PcbFrame->m_Pcb->m_Modules == NULL) return; + + Module = Select_1_Module_From_BOARD(m_Parent->m_PcbFrame->m_Pcb); + } + + if ( Module == NULL ) return; + + m_CurrentScreen->m_CurrentItem = NULL; + + Clear_Pcb(NULL, TRUE); + + m_Pcb->m_Status_Pcb = 0; + NewModule = new MODULE(m_Pcb); + NewModule->Copy(Module); + NewModule->m_Link = Module->m_TimeStamp; + + Module = NewModule; + Module->m_Parent = m_Pcb; + Module->Pback = m_Pcb->m_Modules; Module->Pnext = NULL; + m_Pcb->m_Modules = Module; + + Module->m_Flags = 0; + + build_liste_pads(); + + m_CurrentScreen->m_Curseur.x = m_CurrentScreen->m_Curseur.y = 0; + Place_Module(Module, NULL); + if( Module->m_Layer != CMP_N) Change_Side_Module(Module, NULL); + Rotate_Module(NULL, Module, 0, FALSE); + m_CurrentScreen->ClrModify(); + Zoom_Automatique(TRUE); +} + +/****************************************************************************/ +MODULE * WinEDA_BasePcbFrame::Load_Module_From_Library(const wxString & library, + wxDC * DC) +/****************************************************************************/ +/* Permet de charger un module directement a partir de la librairie */ +{ +MODULE * module; +wxPoint curspos = m_CurrentScreen->m_Curseur; +wxString ModuleName, keys; +static wxArrayString HistoryList; +bool AllowWildSeach = TRUE; + + /* Ask for a component name or key words */ + ModuleName = GetComponentName(this, HistoryList, _("Module name:"), NULL); + ModuleName.MakeUpper(); + if( ModuleName.IsEmpty() ) /* Cancel command */ + { + DrawPanel->MouseToCursorSchema(); + return NULL; + } + + + if( ModuleName[0] == '=' ) // Selection by keywords + { + AllowWildSeach = FALSE; + keys = ModuleName.AfterFirst('='); + ModuleName = Select_1_Module_From_List(this, library, wxEmptyString, keys); + if( ModuleName.IsEmpty() ) /* Cancel command */ + { + DrawPanel->MouseToCursorSchema(); + return NULL; + } + } + + else if( (ModuleName.Contains(wxT("?"))) || (ModuleName.Contains(wxT("*"))) ) // Selection wild card + { + AllowWildSeach = FALSE; + ModuleName = Select_1_Module_From_List(this, library, ModuleName, wxEmptyString); + if( ModuleName.IsEmpty() ) + { + DrawPanel->MouseToCursorSchema(); + return NULL; /* annulation de commande */ + } + } + + module = Get_Librairie_Module(this, library, ModuleName, FALSE); + + if( (module == NULL) && AllowWildSeach ) /* Attemp to search with wildcard */ + { + AllowWildSeach = FALSE; + wxString wildname = wxChar('*') + ModuleName + wxChar('*'); + ModuleName = wildname; + ModuleName = Select_1_Module_From_List(this, library, ModuleName, wxEmptyString); + if( ModuleName.IsEmpty() ) + { + DrawPanel->MouseToCursorSchema(); + return NULL; /* annulation de commande */ + } + else module = Get_Librairie_Module(this, library, ModuleName, TRUE); + } + + m_CurrentScreen->m_Curseur = curspos; + DrawPanel->MouseToCursorSchema(); + + if( module ) + { + AddHistoryComponentName(HistoryList, ModuleName); + + module->m_Flags = IS_NEW; + module->m_Link = 0; + module->m_TimeStamp = GetTimeStamp(); + m_Pcb->m_Status_Pcb = 0 ; + module->SetPosition(curspos); + build_liste_pads(); + + module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); + } + + return module; +} + +/*******************************************************************************/ +MODULE * WinEDA_BasePcbFrame::Get_Librairie_Module(wxWindow * winaff, + const wxString & library, const wxString & ModuleName, bool show_msg_err) +/*******************************************************************************/ +/* + Analyse les LIBRAIRIES pour trouver le module demande + Si ce module est trouve, le copie en memoire, et le + chaine en fin de liste des modules + - Entree: + name_cmp = nom du module + - Retour: + Pointeur sur le nouveau module. +*/ +{ +int LineNum, Found= 0; +wxString fulllibname; +char Line[512]; +wxString Name; +wxString ComponentName, msg; +MODULE * Module; +MODULE * NewModule; +FILE * lib_module = NULL; +unsigned ii; + + ComponentName = ModuleName; + + /* Calcul de l'adresse du dernier module: */ + Module = m_Pcb->m_Modules; + if( Module ) while( Module->Pnext ) Module = (MODULE*) Module->Pnext; + + for( ii = 0; ii < g_LibName_List.GetCount(); ii++) + { + fulllibname = g_LibName_List[ii]; + + /* Calcul du nom complet de la librairie */ + fulllibname = MakeFileName(g_RealLibDirBuffer,fulllibname,LibExtBuffer); + + if ((lib_module = wxFopen(fulllibname, wxT("rt"))) == NULL ) + { + msg.Printf(_("Library <%s> not found"),fulllibname.GetData()); + Affiche_Message(msg); + continue ; + } + + msg.Printf(_("Scan Lib: %s"),fulllibname.GetData()); + Affiche_Message(msg); + + /* lecture entete chaine definie par ENTETE_LIBRAIRIE */ + LineNum = 0; + GetLine(lib_module, Line, &LineNum) ; + StrPurge(Line); + if(strnicmp( Line,ENTETE_LIBRAIRIE, L_ENTETE_LIB) != 0) + { + DisplayError(winaff, _("File is Not a library") ); + return(NULL); + } + + /* Lecture de la liste des composants de la librairie */ + Found = 0; + while( !Found && GetLine(lib_module,Line, &LineNum) ) + { + if( strnicmp( Line, "$MODULE",6) == 0 ) break; + if( strnicmp( Line,"$INDEX",6) == 0 ) + { + while( GetLine(lib_module,Line, &LineNum) ) + { + if( strnicmp( Line,"$EndINDEX",9) == 0 ) break; + StrPurge(Line); + msg = CONV_FROM_UTF8(Line); + if( msg.CmpNoCase(ComponentName) == 0 ) + { + Found = 1; break; /* Trouve! */ + } + } + } + } + + /* Lecture de la librairie */ + while( Found && GetLine(lib_module,Line, &LineNum) ) + { + if( Line[0] != '$' ) continue; + if( Line[1] != 'M' ) continue; + if( strnicmp( Line, "$MODULE",7) != 0 ) continue; + /* Lecture du nom du composant */ + Name = CONV_FROM_UTF8(Line+8); + if( Name.CmpNoCase(ComponentName) == 0 ) /* composant localise */ + { + NewModule = new MODULE(m_Pcb); + NewModule->ReadDescr(lib_module, &LineNum); + if( Module == NULL ) /* 1er Module */ + { + m_Pcb->m_Modules = NewModule; + NewModule->Pback = m_Pcb; + } + + else + { + Module->Pnext = NewModule; + NewModule->Pback = Module; + } + fclose(lib_module) ; + Affiche_Message(wxEmptyString) ; + return(NewModule) ; + } + } + fclose(lib_module) ; lib_module = 0; + } + + if( lib_module ) fclose(lib_module) ; + + if ( show_msg_err ) + { + msg.Printf(_("Module <%s> not found"),ComponentName.GetData()); + DisplayError(winaff, msg); + } + return(NULL) ; +} + +/***************************************************************/ +wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( + wxWindow * active_window, + const wxString & Library, + const wxString & Mask, const wxString & KeyWord) +/***************************************************************/ +/* + Affiche la liste des modules des librairies + Recherche dans la librairie Library ou generale si Library == NULL + Mask = Filtre d'affichage( Mask = wxEmptyString pour listage non filtré ) + KeyWord = Liste de mots cles, Recherche limitee aux composants + ayant ces mots cles ( KeyWord = wxEmptyString pour listage de tous les modules ) + + retourne wxEmptyString si abort ou probleme + ou le nom du module +*/ +{ +int LineNum; +unsigned ii, NbModules; +char Line[1024]; +wxString FullLibName; +static wxString OldName; /* Memorise le nom du dernier composant charge */ +wxString CmpName; +FILE * lib_module; +wxString msg; + +WinEDAListBox * ListBox = new WinEDAListBox(active_window, wxEmptyString, + NULL, OldName, DisplayCmpDoc, wxColour(200, 200, 255) ); + + wxBeginBusyCursor(); + + /* Recherche des composants en librairies */ + NbModules = 0; + for( ii = 0; ii < g_LibName_List.GetCount(); ii++) + { + /* Calcul du nom complet de la librairie */ + if( Library.IsEmpty() ) + { + FullLibName = MakeFileName(g_RealLibDirBuffer, + g_LibName_List[ii], LibExtBuffer); + } + else + FullLibName = MakeFileName(g_RealLibDirBuffer,Library,LibExtBuffer); + + ReadDocLib(FullLibName ); + + if( ! KeyWord.IsEmpty()) /* Inutile de lire la librairie si selection + par mots cles, deja lus */ + { + if( ! Library.IsEmpty() ) break; + continue ; + } + + if ((lib_module = wxFopen(FullLibName, wxT("rt"))) == NULL ) + { + if( ! Library.IsEmpty() ) break; + continue ; + } + + msg = _("Library: "); msg << FullLibName; + Affiche_Message(msg); + + /* lecture entete */ + LineNum = 0; + GetLine(lib_module, Line, &LineNum, sizeof(Line) -1); + + if(strnicmp( Line,ENTETE_LIBRAIRIE, L_ENTETE_LIB) != 0) + { + DisplayError(this, wxT("This file is not an Eeschema libray file"), 20); continue; + } + + /* Lecture de la librairie */ + while( GetLine(lib_module,Line, &LineNum, sizeof(Line) -1) ) + { + if( Line[0] != '$' ) continue; + if( strnicmp( Line, "$MODULE",6) == 0 ) break; + if( strnicmp( Line,"$INDEX",6) == 0 ) + { + while( GetLine(lib_module,Line, &LineNum) ) + { + if( strnicmp( Line,"$EndINDEX",9) == 0 ) break; + strupper(Line); + msg = CONV_FROM_UTF8(StrPurge(Line)); + if ( Mask.IsEmpty() ) + { + ListBox->Append( msg ); + NbModules++; + } + else if ( WildCompareString(Mask, msg, FALSE) ) + { + ListBox->Append( msg ); + NbModules++; + } + } + } /* Fin Lecture INDEX */ + } /* Fin lecture 1 Librairie */ + + fclose(lib_module) ; lib_module = NULL; + if( ! Library.IsEmpty() ) break; + } + + /* creation de la liste des modules si recherche par mots-cles */ + if( ! KeyWord.IsEmpty() ) + { + ModList * ItemMod = MList; + while( ItemMod != NULL ) + { + if( KeyWordOk(KeyWord, ItemMod->m_KeyWord) ) + { + NbModules++; + ListBox->Append( ItemMod->m_Name ); + } + ItemMod = ItemMod->Next; + } + } + + wxEndBusyCursor(); + + msg.Printf( _("Modules (%d items)"), NbModules); + ListBox->SetTitle(msg); + ListBox->SortList(); + + ii = ListBox->ShowModal(); + if ( ii >= 0 ) CmpName = ListBox->GetTextSelection(); + else CmpName.Empty(); + + ListBox->Destroy(); + + /* liberation mem de la liste des textes doc module */ + while( MList != NULL ) + { + ModList * NewMod = MList->Next; + delete MList; + MList = NewMod; + } + + if( CmpName != wxEmptyString ) OldName = CmpName; + + return(CmpName); +} + +/******************************************/ +static void DisplayCmpDoc(wxString & Name) +/*******************************************/ +/* Routine de recherche et d'affichage de la doc du composant Name + La liste des doc est pointee par MList +*/ +{ +ModList * Mod = MList; + + if ( ! Mod ) + { + Name.Empty(); return; + } + + /* Recherche de la description */ + while ( Mod ) + { + if( ! Mod->m_Name.IsEmpty() && (Mod->m_Name.CmpNoCase(Name) == 0) ) break; + Mod = Mod->Next; + } + + if ( Mod ) + { + Name = ! Mod->m_Doc.IsEmpty() ? Mod->m_Doc : wxT("No Doc"); + Name += wxT("\nKeyW: "); + Name += ! Mod->m_KeyWord.IsEmpty() ? Mod->m_KeyWord : wxT("No Keyword"); + } + + else Name = wxEmptyString; +} + +/***************************************************/ +static void ReadDocLib(const wxString & ModLibName ) +/***************************************************/ +/* Routine de lecture du fichier Doc associe a la librairie ModLibName. + Cree en memoire la chaine liste des docs pointee par MList + ModLibName = full file Name de la librairie Modules +*/ +{ +ModList * NewMod; +char Line[1024]; +FILE * LibDoc; +wxString FullModLibName = ModLibName; + + ChangeFileNameExt(FullModLibName, EXT_DOC); + + if( (LibDoc = wxFopen(FullModLibName, wxT("rt"))) == NULL ) return; + + GetLine(LibDoc, Line, NULL, sizeof(Line) -1); + if(strnicmp( Line,ENTETE_LIBDOC, L_ENTETE_LIB) != 0) return; + + /* Lecture de la librairie */ + while( GetLine(LibDoc,Line, NULL, sizeof(Line) -1) ) + { + if( Line[0] != '$' ) continue; + if( Line[1] == 'E' ) break;; + if( Line[1] == 'M' ) /* Debut decription 1 module */ + { + NewMod = new ModList(); + NewMod->Next = MList; + MList = NewMod; + while( GetLine(LibDoc,Line, NULL, sizeof(Line) -1) ) + { + if( Line[0] == '$' ) /* $EndMODULE */ + break; + switch( Line[0] ) + { + case 'L': /* LibName */ + NewMod->m_Name = CONV_FROM_UTF8(StrPurge(Line+3) ); + break; + + case 'K': /* KeyWords */ + NewMod->m_KeyWord = CONV_FROM_UTF8(StrPurge(Line+3) ); + break; + + case 'C': /* Doc */ + NewMod->m_Doc = CONV_FROM_UTF8(StrPurge(Line+3) ); + break; + } + } + } /* lecture 1 descr module */ + } /* Fin lecture librairie */ + fclose(LibDoc); +} + +/********************************************************************/ +MODULE * WinEDA_BasePcbFrame::Select_1_Module_From_BOARD(BOARD * Pcb) +/********************************************************************/ +/* Affiche la liste des modules du PCB en cours + Retourne un pointeur si module selectionne + retourne NULL sinon +*/ +{ +int ii; +MODULE * Module; +static wxString OldName; /* Memorise le nom du dernier composant charge */ +wxString CmpName, msg; + +WinEDAListBox * ListBox = new WinEDAListBox(this, wxEmptyString, + NULL, wxEmptyString, NULL, wxColour(200, 200, 255) ); + + /* Recherche des composants en BOARD */ + ii = 0; + Module = Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + ii++; + ListBox->Append( Module->m_Reference->m_Text ); + } + + msg.Printf( _("Modules (%d items)"), ii); + ListBox->SetTitle(msg); + + ListBox->SortList(); + + ii = ListBox->ShowModal(); + if ( ii >= 0 ) CmpName = ListBox->GetTextSelection(); + else CmpName.Empty(); + + ListBox->Destroy(); + + if( CmpName == wxEmptyString ) return NULL; + + OldName = CmpName; + + // Recherche du pointeur sur le module + Module = Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + if ( CmpName.CmpNoCase(Module->m_Reference->m_Text) == 0 ) + break; + } + return Module; +} + + diff --git a/pcbnew/locate.cpp b/pcbnew/locate.cpp new file mode 100644 index 0000000000..1b31c8c8ff --- /dev/null +++ b/pcbnew/locate.cpp @@ -0,0 +1,1246 @@ + /*****************************/ + /* Localisation des elements */ + /*****************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "trigo.h" +#include "autorout.h" + +#include "protos.h" + + +/* variables locales */ +int ux0 , uy0 ,dx, dy, spot_cX, spot_cY; /* Variables utilisees pour + la localisation des segments */ +/* fonctions locales */ +EDA_BaseStruct * Locate_MirePcb( EDA_BaseStruct * PtStruct, int typeloc); +/**/ + +/* Macro de calcul de la coord de pointage selon le curseur +(ON/OFF grille) choisi +A REVOIR +*/ +#define SET_REF_POS(ref_pos) if(typeloc == CURSEUR_ON_GRILLE) \ + { ref_pos = ActiveScreen->m_Curseur;} \ + else { ref_pos = ActiveScreen->m_Curseur; } + + + +/*************************************************************/ +MODULE * ReturnModule(BOARD * pcb, const wxString & reference) +/*************************************************************/ +/* + Recherche d'un module par sa reference + Retourne: + un pointeur sur le module + Null si pas localisé +*/ +{ +MODULE * Module = pcb->m_Modules; + + for( ; Module != NULL ; Module = (MODULE *) Module->Pnext ) + { + if( reference.CmpNoCase(Module->m_Reference->m_Text) == 0 ) + return Module; + } + return NULL; +} + + +/********************************************************/ +D_PAD * ReturnPad(MODULE * module, const wxString & name) +/********************************************************/ +/* Recherche d'un pad par son nom, pour le module Module +*/ +{ +D_PAD * pt_pad ; +wxString buf; + + if( module == NULL ) return NULL; + + pt_pad = module->m_Pads; + + for ( ; pt_pad != NULL; pt_pad = (D_PAD*)pt_pad->Pnext ) + { + pt_pad->ReturnStringPadName(buf); + if( buf.CmpNoCase(name) == 0 ) + return pt_pad; + } + return(NULL); +} + + + + +/*********************************************************/ +EDA_BaseStruct * WinEDA_BasePcbFrame::Locate( int typeloc ) +/*********************************************************/ +/* Fonction de localisation generale + Affiche les caract de la stucture localisée et retourne un pointeur + sur celle-ci +*/ +{ +TEXTE_PCB * pt_texte_pcb; +TRACK * Track , * TrackLocate ; +DRAWSEGMENT * DrawSegm; +MODULE * module; +D_PAD* pt_pad; +int masque_layer; +EDA_BaseStruct * item; + + pt_texte_pcb = Locate_Texte_Pcb(m_Pcb->m_Drawings, typeloc); + if(pt_texte_pcb ) // texte type PCB localise + { + Affiche_Infos_PCB_Texte(this, pt_texte_pcb); + return pt_texte_pcb; + } + + if ( (DrawSegm = Locate_Segment_Pcb(m_Pcb, typeloc)) != NULL) + { + Affiche_Infos_DrawSegment(this, DrawSegm); + return DrawSegm; + } + + if ( (item = Locate_Cotation(m_Pcb, typeloc)) != NULL) return item; + + if ( (item = Locate_MirePcb(m_Pcb->m_Drawings, typeloc)) != NULL) return item; + + /* Localistion des pistes et vias, avec priorite aux vias */ + masque_layer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; + Track = Locate_Pistes( m_Pcb->m_Track, NO_TST_LAYER,typeloc ); + if ( Track != NULL ) + { + TrackLocate = Track ; /* Reperage d'une piste ou via */ + /* recherche de 1 via eventuelle */ + while((TrackLocate = Locate_Pistes(TrackLocate, + masque_layer,typeloc)) != NULL ) + { + Track = TrackLocate; + if(TrackLocate->m_StructType == TYPEVIA) break ; + TrackLocate = (TRACK*) TrackLocate->Pnext; + } + Affiche_Infos_Piste(this, Track) ; + return Track; + } + + + /* Localisation des Pads */ + if( (pt_pad = Locate_Any_Pad(m_Pcb, typeloc)) != NULL ) + { + pt_pad->Display_Infos(this); return pt_pad; + } + + /* Localisation d'un texte sur modules */ + module = NULL; + { + TEXTE_MODULE * pt_texte; + pt_texte = LocateTexteModule(m_Pcb, &module, typeloc); + if( pt_texte != NULL ) + { + Affiche_Infos_E_Texte(this, module, pt_texte); + return pt_texte; + } + } + + /* Recherche d'un module */ + if ( (module = Locate_Prefered_Module(m_Pcb, typeloc)) != NULL) + { + module->Display_Infos(this); + return module; + } + + if( (TrackLocate = Locate_Zone((TRACK*)m_Pcb->m_Zone, + GetScreen()->m_Active_Layer,typeloc)) != NULL ) + { + Affiche_Infos_Piste(this, TrackLocate) ; return TrackLocate; + } + + MsgPanel->EraseMsgBox(); + return NULL; +} + + +/*******************************************************************/ +TRACK * Locate_Via(BOARD * Pcb, const wxPoint & pos, int layer = -1) +/*******************************************************************/ + +/* Localise une via au point pX,pY + Si layer < 0 la via sera localisee quelle que soit la couche + Si layer = 0 .. 15 la via sera localisee selon son type: + - traversante : toutes couches + - aveugle = entre couches utiles + - borgnes idem + Entree : coord du point de reference, couche + Sortie: NULL si pas de via + (TRACK*) adresse de la via +*/ +{ +TRACK * Track; + + for(Track = Pcb->m_Track; Track != NULL; Track = Track->Next()) + { + if( Track->m_StructType != TYPEVIA) continue; + if( Track->m_Start != pos) continue; + if( Track->GetState(BUSY|DELETED) ) continue; + if(layer < 0 ) return(Track); + if ( ((SEGVIA *)Track)->IsViaOnLayer(layer) ) + return(Track); + } + return(NULL); +} + + +/********************************************************************/ +D_PAD * Locate_Pad_Connecte(BOARD * Pcb, TRACK * ptr_piste, int extr) +/********************************************************************/ +/* localisation de la pastille connectee au point de piste a tester + entree : ptr_piste: pointeur sur le segment de piste + extr = flag = START -> debut du segment a tester + = END -> fin du segment a tester + retourne: + un pointeur sur la description de la pastille si localisation + pointeur NULL si pastille non trouvee +*/ +{ +D_PAD * ptr_pad = NULL; +int masque_layer; +MODULE * module; +wxPoint ref_pos; + + masque_layer = g_TabOneLayerMask[ptr_piste->m_Layer]; + if( extr == START) + { + ref_pos = ptr_piste->m_Start; + } + else + { + ref_pos = ptr_piste->m_End; + } + module = Pcb->m_Modules; + for(; module != NULL; module = (MODULE*) module->Pnext) + { + ptr_pad = Locate_Pads(module, ref_pos, masque_layer) ; + if ( ptr_pad != NULL ) break ; + } + return(ptr_pad); +} + + + +/****************************************************************/ +EDGE_MODULE * Locate_Edge_Module(MODULE * module, int typeloc) +/****************************************************************/ +/* Localisation de segments de contour du type edge MODULE + Les contours sont de differents type: + simple : succession de droites + Arcs de cercles : on a alors debut arc, fin arc , centre + si debut arc = fin arc : cercle complet + + Retourne: + Pointeur sur le segment localise + NULL si rien trouve +*/ +{ +EDGE_MODULE * edge_mod; +EDA_BaseStruct * PtStruct; +int uxf, uyf, type_trace; +int rayon, dist; +wxPoint ref_pos; /* coord du point de localisation */ +int StAngle, EndAngle, MouseAngle; /* pour localisation d'arcs, + angle du point de debut, de fin et du point + de reference */ + + if ( ! module ) return NULL; + + SET_REF_POS(ref_pos); + + PtStruct = module->m_Drawings; + for ( ;PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if( PtStruct->m_StructType != TYPEEDGEMODULE ) continue; + edge_mod = (EDGE_MODULE *) PtStruct; + type_trace = edge_mod->m_Shape ; + ux0 = edge_mod->m_Start.x; uy0 = edge_mod->m_Start.y; + uxf = edge_mod->m_End.x; uyf = edge_mod->m_End.y; + + switch(type_trace) + { + case S_SEGMENT : + /* recalcul des coordonnees avec ux0,uy0 = origine des coord. */ + spot_cX = ref_pos.x - ux0; spot_cY = ref_pos.y - uy0; + dx = uxf - ux0 ; dy = uyf - uy0 ; + /* detection : */ + if( distance(edge_mod->m_Width/2) ) return( edge_mod) ; + break; + + case S_CIRCLE: + rayon = (int)hypot((double)(uxf-ux0),(double)(uyf-uy0) ); + dist = (int)hypot((double)(ref_pos.x - ux0),(double)(ref_pos.y - uy0) ); + + if(abs(rayon-dist) <= edge_mod->m_Width) return(edge_mod); + break; + + case S_ARC: + rayon = (int)hypot((double)(uxf-ux0),(double)(uyf-uy0) ); + dist = (int)hypot((double)(ref_pos.x - ux0),(double)(ref_pos.y - uy0) ); + + if(abs(rayon-dist) > edge_mod->m_Width) break; + + /* pour un arc, controle complementaire */ + MouseAngle = (int) ArcTangente(ref_pos.y - uy0, ref_pos.x - ux0); + StAngle = (int) ArcTangente(uyf - uy0, uxf - ux0); + EndAngle = StAngle + edge_mod->m_Angle; + + if( EndAngle > 3600 ) + { + StAngle -= 3600; EndAngle -= 3600; + } + + if( (MouseAngle >= StAngle) && (MouseAngle <= EndAngle) ) + return(edge_mod); + + break; + } + } + return(NULL) ; +} + + +/*********************************************************/ +EDA_BaseStruct * Locate_Cotation(BOARD * Pcb, int typeloc) +/*********************************************************/ +/* Localise un element de cotation, en priorite sur la couche active, + et a defaut sur les autres couches + retourne un pointeur sur l'element localise + sinon returne NULL +*/ +{ +EDA_BaseStruct * PtStruct; +COTATION * Cotation; +TEXTE_PCB* pt_txt; +wxPoint ref_pos; +int ux0, uy0; + + SET_REF_POS(ref_pos); + + PtStruct = Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if( PtStruct->m_StructType != TYPECOTATION ) continue; + Cotation = (COTATION*) PtStruct; + if( Cotation->m_Layer != ((PCB_SCREEN *)ActiveScreen)->m_Active_Layer ){}; + + /* Localisation du texte ? */ + pt_txt = Cotation->m_Text; + if( pt_txt ) + { + if( pt_txt->Locate(wxPoint(spot_cX, spot_cY)) ) return(PtStruct); + } + + /* Localisation des SEGMENTS ?) */ + ux0 = Cotation->Barre_ox ; uy0 = Cotation->Barre_oy; + /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ + dx =Cotation->Barre_fx - ux0 ; dy = Cotation->Barre_fy - uy0 ; + spot_cX = ref_pos.x - ux0 ; spot_cY = ref_pos.y - uy0 ; + + /* detection : */ + if( distance( Cotation->m_Width/2 )) return( PtStruct ); + + ux0 = Cotation->TraitG_ox ; uy0 = Cotation->TraitG_oy; + /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ + dx = Cotation->TraitG_fx - ux0 ; dy = Cotation->TraitG_fy - uy0 ; + spot_cX = ref_pos.x - ux0 ; spot_cY = ref_pos.y - uy0 ; + + /* detection : */ + if( distance( Cotation->m_Width/2 )) return( PtStruct ); + + ux0 = Cotation->TraitD_ox ; uy0 = Cotation->TraitD_oy; + /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ + dx = Cotation->TraitD_fx - ux0 ; dy = Cotation->TraitD_fy - uy0 ; + spot_cX = ref_pos.x - ux0 ; spot_cY = ref_pos.y - uy0 ; + + /* detection : */ + if( distance( Cotation->m_Width/2 )) return( PtStruct ); + + ux0 = Cotation->FlecheD1_ox ; uy0 = Cotation->FlecheD1_oy; + /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ + dx = Cotation->FlecheD1_fx - ux0 ; dy = Cotation->FlecheD1_fy - uy0 ; + spot_cX = ref_pos.x - ux0 ; spot_cY = ref_pos.y - uy0 ; + + /* detection : */ + if( distance( Cotation->m_Width/2 )) return( PtStruct ); + + ux0 = Cotation->FlecheD2_ox ; uy0 = Cotation->FlecheD2_oy; + /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ + dx = Cotation->FlecheD2_fx - ux0 ; dy = Cotation->FlecheD2_fy - uy0 ; + spot_cX = ref_pos.x - ux0 ; spot_cY = ref_pos.y - uy0 ; + + /* detection : */ + if( distance( Cotation->m_Width/2 )) return( PtStruct ); + + ux0 = Cotation->FlecheG1_ox ; uy0 = Cotation->FlecheG1_oy; + /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ + dx = Cotation->FlecheG1_fx - ux0 ; dy = Cotation->FlecheG1_fy - uy0 ; + spot_cX = ref_pos.x - ux0 ; spot_cY = ref_pos.y - uy0 ; + + /* detection : */ + if( distance( Cotation->m_Width/2 )) return( PtStruct ); + + ux0 = Cotation->FlecheG2_ox ; uy0 = Cotation->FlecheG2_oy; + /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ + dx = Cotation->FlecheG2_fx - ux0 ; dy = Cotation->FlecheG2_fy - uy0 ; + spot_cX = ref_pos.x - ux0 ; spot_cY = ref_pos.y - uy0 ; + + /* detection : */ + if( distance( Cotation->m_Width/2 )) return( PtStruct ); + } + + return(NULL); +} + +/*********************************************************/ +DRAWSEGMENT * Locate_Segment_Pcb(BOARD * Pcb, int typeloc) +/*********************************************************/ +/* Localisation de segments de contour du type drawing + Retourne: + Pointeur sur DEBUT du segment localise + NULL si rien trouve + Le segment sur la couche active est détecté en priorite +*/ +{ +EDA_BaseStruct * PtStruct; +DRAWSEGMENT * pts, *locate_segm = NULL; +wxPoint ref_pos; +PCB_SCREEN *screen = (PCB_SCREEN *)ActiveScreen; + + SET_REF_POS(ref_pos); + + PtStruct = Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; + pts = ( DRAWSEGMENT * ) PtStruct; + ux0 = pts->m_Start.x ; uy0 = pts->m_Start.y; + /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ + dx = pts->m_End.x - ux0 ; dy = pts->m_End.y - uy0 ; + spot_cX = ref_pos.x - ux0; spot_cY = ref_pos.y - uy0 ; + + /* detection : */ + if( (pts->m_Shape == S_CIRCLE) || (pts->m_Shape == S_ARC) ) + { + int rayon, dist, StAngle, EndAngle, MouseAngle; + rayon = (int) hypot((double)(dx),(double)(dy) ); + dist = (int) hypot((double)(spot_cX),(double)(spot_cY) ); + if( abs(rayon-dist) <= (pts->m_Width/2) ) + { + if(pts->m_Shape == S_CIRCLE) + { + if(pts->m_Layer == screen->m_Active_Layer) + return( pts ) ; + else if ( ! locate_segm ) locate_segm = pts; + } + /* pour un arc, controle complementaire */ + MouseAngle = (int) ArcTangente(spot_cY, spot_cX); + StAngle = (int) ArcTangente(dy, dx); + EndAngle = StAngle + pts->m_Angle; + + if( EndAngle > 3600 ) + { + StAngle -= 3600; EndAngle -= 3600; + } + if( (MouseAngle >= StAngle) && (MouseAngle <= EndAngle) ) + { + if(pts->m_Layer == screen->m_Active_Layer) + return( pts ) ; + else if ( ! locate_segm ) locate_segm = pts; + } + } + } + + else + { + if( distance( pts->m_Width /2 ) ) + { + if(pts->m_Layer == screen->m_Active_Layer) + return( pts ) ; + else if ( ! locate_segm ) locate_segm = pts; + } + } + } + return(locate_segm) ; +} + + + /*************************************************/ + /* D_PAD * Locate_Any_Pad(int typeloc, bool OnlyCurrentLayer) */ + /* D_PAD* Locate_Any_Pad(int ref_pos, bool OnlyCurrentLayer) */ + /*************************************************/ + +/* +localisation de la pastille pointee par la coordonnee ref_pos.x,,ref_pos.y, ou +par la souris, recherche faite sur toutes les empreintes. + entree : + - coord souris + ou ref_pos + retourne: + pointeur sur la description de la pastille si localisation + pointeur NULL si pastille non trouvee + num_empr = numero d'empreinte du pad + + la priorité est donnée a la couche active +*/ + +D_PAD * Locate_Any_Pad(BOARD * Pcb, int typeloc, bool OnlyCurrentLayer) +{ +wxPoint ref_pos; + + SET_REF_POS(ref_pos); + return(Locate_Any_Pad(Pcb, ref_pos, OnlyCurrentLayer)) ; +} + +D_PAD * Locate_Any_Pad(BOARD * Pcb, const wxPoint & ref_pos, bool OnlyCurrentLayer) +{ +D_PAD * pt_pad ; +MODULE * module; +int layer_mask = g_TabOneLayerMask[ ((PCB_SCREEN*)ActiveScreen)->m_Active_Layer]; + module = Pcb->m_Modules; + for( ; module != NULL ; module = (MODULE *) module->Pnext ) + { + /* First: Search a pad on the active layer: */ + if ( (pt_pad = Locate_Pads(module, ref_pos,layer_mask) ) != NULL ) + return(pt_pad) ; + + /* If not found, search on other layers: */ + if ( ! OnlyCurrentLayer ) + { + if ( (pt_pad = Locate_Pads(module, ref_pos,ALL_LAYERS) ) != NULL ) + return(pt_pad) ; + } + } + return(NULL) ; +} + + +/******************************************************************************/ +/* D_PAD* Locate_Pads(MODULE * module, int masque_layer,int typeloc) */ +/* D_PAD* Locate_Pads(MODULE * module, const wxPoint & ref_pos,int masque_layer) */ +/******************************************************************************/ + +/* localisation de la pastille pointee par la coordonnee ref_pos.x,,ref_pos.y, ou +par la souris, concernant l'empreinte en cours. + entree : + - parametres generaux de l'empreinte mise a jour par caract() + - masque_layer = couche(s) (bit_masque)sur laquelle doit etre la pastille + retourne: + un pointeur sur la description de la pastille si localisation + pointeur NULL si pastille non trouvee +*/ + +D_PAD * Locate_Pads(MODULE * module, int masque_layer,int typeloc) +{ +wxPoint ref_pos; + + SET_REF_POS(ref_pos); + return(Locate_Pads(module, ref_pos, masque_layer) ); +} + + +D_PAD * Locate_Pads(MODULE * module, const wxPoint & ref_pos, int masque_layer) +{ +D_PAD * pt_pad ; +int deltaX, deltaY; +wxPoint shape_pos; +double dist; + + pt_pad = module->m_Pads; + for ( ; pt_pad != NULL; pt_pad = (D_PAD*)pt_pad->Pnext ) + { + shape_pos = pt_pad->ReturnShapePos(); + ux0 = shape_pos.x; uy0 = shape_pos.y; /* pos x,y du centre du pad */ + + deltaX = ref_pos.x - ux0; deltaY = ref_pos.y - uy0; + + /* Test rapide: le point a tester doit etre a l'interieur du cercle + exinscrit ... */ + if ( (abs(deltaX) > pt_pad->m_Rayon ) || + (abs(deltaY) > pt_pad->m_Rayon) ) + continue; + + /* ... et sur la bonne couche */ + if( (pt_pad->m_Masque_Layer & masque_layer) == 0) continue ; + + /* calcul des demi dim dx et dy */ + dx = pt_pad->m_Size.x >> 1; // dx also is the radius for rounded pads + dy = pt_pad->m_Size.y >> 1; + + /* localisation ? */ + switch (pt_pad->m_PadShape & 0x7F) + { + case CIRCLE : + dist = hypot(deltaX, deltaY); + if ( (int)(round(dist)) <= dx ) return(pt_pad) ; + break; + + default: + /* calcul des coord du point test dans le repere du Pad */ + RotatePoint(&deltaX, &deltaY, - pt_pad->m_Orient); + if ( (abs(deltaX) <= dx ) && (abs(deltaY) <= dy) ) + return(pt_pad) ; + break; + } + } + return(NULL); +} + + +/********************************************************/ +MODULE * Locate_Prefered_Module(BOARD * Pcb, int typeloc) +/********************************************************/ +/* + localisation d'une empreinte par son rectangle d'encadrement + Si plusieurs empreintes sont possibles, la priorite est: + - sur la couche active + - la plus petite +*/ +{ +MODULE * pt_module; +int lx , ly; /* dimensions du rectangle d'encadrement du module */ +MODULE * module = NULL, /* module localise sur la couche active */ + * Altmodule = NULL; /* module localise sur les couches non actives */ +int min_dim = 0x7FFFFFFF, /* dim mini du module localise sur la couche active */ + alt_min_dim = 0x7FFFFFFF; /* dim mini du module localise sur les couches non actives */ +int layer; /* pour calcul de couches prioritaires */ +wxPoint ref_pos; /* coord du point de reference pour la localisation */ + + SET_REF_POS(ref_pos); + pt_module = Pcb->m_Modules; + for( ; pt_module != NULL ; pt_module = (MODULE *) pt_module->Pnext ) + { + /* calcul des dimensions du cadre :*/ + lx = pt_module->m_BoundaryBox.GetWidth(); + ly = pt_module->m_BoundaryBox.GetHeight(); + + /* Calcul des coord souris dans le repere module */ + spot_cX = ref_pos.x - pt_module->m_Pos.x; + spot_cY = ref_pos.y - pt_module->m_Pos.y; + RotatePoint(&spot_cX, &spot_cY, - pt_module->m_Orient); + + /* la souris est-elle dans ce rectangle : */ + if( ! pt_module->m_BoundaryBox.Inside(spot_cX, spot_cY) ) + continue; + + /* Localisation: test des dimensions minimales, choix du meilleur candidat */ + + /* calcul de priorite: la priorite est donnee a la couche + d'appartenance du module et a la couche cuivre si le module + est sur couche serigr,adhesive cuivre, a la couche cmp si le module + est sur couche serigr,adhesive composant */ + layer = pt_module->m_Layer; + if( (layer == ADHESIVE_N_CU) || (layer == SILKSCREEN_N_CU) ) + layer = CUIVRE_N; + if( (layer == ADHESIVE_N_CMP) || (layer == SILKSCREEN_N_CMP) ) + layer = CMP_N; + + if( ((PCB_SCREEN*)ActiveScreen)->m_Active_Layer == layer ) + { + if( min(lx,ly) <= min_dim ) + { /* meilleure empreinte localisee sur couche active */ + module = pt_module ; min_dim = min(lx,ly) ; + } + } + + else + { + if( min(lx,ly) <= alt_min_dim ) + { /* meilleure empreinte localisee sur autres couches */ + Altmodule = pt_module ; alt_min_dim = min(lx,ly) ; + } + } + } /* fin boucle d'examen des modules */ + + if(module) + { + return(module); + } + if(Altmodule) + { + return(Altmodule); + } + return(NULL); +} + +/*****************************************************************************/ +TEXTE_MODULE * LocateTexteModule(BOARD * Pcb, MODULE ** PtModule, int typeloc) +/*****************************************************************************/ +/* localisation du texte pointe par la souris (texte sur empreinte) + + si * PtModule == NULL; recherche sur tous les modules + sinon sur le module pointe par module + + retourne + - pointeur sur le texte localise ( ou NULL ) + - si Ptmodule != NULL: pointeur sur module module ( non modifie sinon ) +*/ +{ +EDA_BaseStruct * PtStruct; +TEXTE_MODULE * pt_txt_mod ; +MODULE * module; +wxPoint ref_pos; + + SET_REF_POS(ref_pos); + + module = * PtModule; + if( module == NULL ) + { + module = Pcb->m_Modules; + } + + for( ; module != NULL; module = (MODULE*)module->Pnext ) + { + pt_txt_mod = module->m_Reference; + /* la souris est-elle dans le rectangle autour du texte*/ + if( pt_txt_mod->Locate(ref_pos) ) + { + if( PtModule) *PtModule = module; + return(pt_txt_mod); + } + pt_txt_mod = module->m_Value; + /* la souris est-elle dans le rectangle autour du texte*/ + if( pt_txt_mod->Locate(ref_pos) ) + { + if( PtModule) *PtModule = module; + return(pt_txt_mod); + } + + PtStruct = module->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if( PtStruct->m_StructType != TYPETEXTEMODULE ) continue; + pt_txt_mod = (TEXTE_MODULE*) PtStruct; + /* la souris est-elle dans le rectangle autour du texte*/ + if( pt_txt_mod->Locate(ref_pos) ) + { + if( PtModule) *PtModule = module; + return(pt_txt_mod); + } + } + if( *PtModule != NULL ) break; /* Recherche limitee a 1 seul module */ + } + return(NULL) ; +} + + +/**************************************************************/ +TRACK * Locate_Piste_Connectee( TRACK * PtRefSegm, TRACK * pt_base, + TRACK * pt_lim, int extr) +/**************************************************************/ +/* recherche le segment connecte au segment pointe par + PtRefSegm: + si int = START, le point de debut du segment est utilise + si int = END, le point de fin du segment est utilise + La recherche ne se fait que sur les EXTREMITES des segments + + La recherche se fait de l'adresse : + pt_base a pt_lim (borne finale comprise) + si pt_lim = NULL, la recherche se fait jusqu'a la fin de la liste + Afin d'accelerer la recherche, une 1ere passe est faite, avec une recherche + realisee sur un ensemble de +/- 100 points autour du point courant. + Si echec: recherche generale +*/ +{ +TRACK * PtSegmB, * PtSegmN; +int x, y , Reflayer; +int ii; + + if ( extr == START) + { + x = PtRefSegm->m_Start.x; y = PtRefSegm->m_Start.y; + } + else + { + x = PtRefSegm->m_End.x; y = PtRefSegm->m_End.y; + } + + Reflayer = PtRefSegm->ReturnMaskLayer(); + + /* 1ere passe */ + PtSegmB = PtSegmN = PtRefSegm; + + for ( ii = 0; ii < 50; ii++ ) + { + if( (PtSegmN == NULL) && (PtSegmB == NULL) ) break; + if( PtSegmN ) + { + if( PtSegmN->GetState(BUSY|DELETED) ) goto suite; + if (PtSegmN == PtRefSegm) goto suite; + if( (x == PtSegmN->m_Start.x ) && (y == PtSegmN->m_Start.y) ) + { /* Test des couches */ + if(Reflayer & PtSegmN->ReturnMaskLayer() )return(PtSegmN); + } + + if( (x == PtSegmN->m_End.x ) && (y == PtSegmN->m_End.y) ) + { /* Test des couches */ + if(Reflayer & PtSegmN->ReturnMaskLayer() )return(PtSegmN); + } + suite: + if( PtSegmN == pt_lim ) PtSegmN = NULL; + else PtSegmN = (TRACK*)PtSegmN->Pnext; + } + + if( PtSegmB ) + { + if(PtSegmB->GetState(BUSY|DELETED) ) goto suite1; + if (PtSegmB == PtRefSegm) goto suite1; + if( (x == PtSegmB->m_Start.x ) && (y == PtSegmB->m_Start.y) ) + { /* Test des couches */ + if(Reflayer & PtSegmB->ReturnMaskLayer() )return(PtSegmB); + } + + if( (x == PtSegmB->m_End.x ) && (y == PtSegmB->m_End.y) ) + { /* Test des couches */ + if(Reflayer & PtSegmB->ReturnMaskLayer() )return(PtSegmB); + } + suite1: + if( PtSegmB == pt_base ) PtSegmB = NULL; + else if( PtSegmB->m_StructType != TYPEPCB) PtSegmB = (TRACK*)PtSegmB->Pback; + else PtSegmB = NULL; + } + } + + /* Recherche generale */ + for ( PtSegmN = pt_base; PtSegmN != NULL; PtSegmN = (TRACK*) PtSegmN->Pnext ) + { + if(PtSegmN->GetState(DELETED|BUSY)) + { + if (PtSegmN == pt_lim ) break; + continue; + } + if (PtSegmN == PtRefSegm) + { + if (PtSegmN == pt_lim ) break; + continue; + } + + if( (x == PtSegmN->m_Start.x ) && (y == PtSegmN->m_Start.y) ) + { /* Test des couches */ + if(Reflayer & PtSegmN->ReturnMaskLayer() )return(PtSegmN); + } + + if( (x == PtSegmN->m_End.x ) && (y == PtSegmN->m_End.y) ) + { /* Test des couches */ + if(Reflayer & PtSegmN->ReturnMaskLayer() )return(PtSegmN); + } + if (PtSegmN == pt_lim ) break; + } + return (NULL); +} + +/****************************************************************************/ +/* TRACK *Locate_Pistes(TRACK * start_adresse, int MasqueLayer,int typeloc) */ +/* TRACK *Locate_Pistes(TRACK * start_adresse, int ref_pos.x, int ref_pos.y,*/ +/* int MasqueLayer) */ +/****************************************************************************/ + +/* +1 - routine de localisation du segment de piste pointe par la souris. +2 - routine de localisation du segment de piste pointe par le point + ref_pos.x , ref_pos.y.r + + La recherche commence a l'adresse start_adresse +*/ + +TRACK * Locate_Pistes(TRACK * start_adresse,int MasqueLayer, int typeloc ) +{ +wxPoint ref_pos; + + SET_REF_POS(ref_pos); + + return( Locate_Pistes(start_adresse, ref_pos,MasqueLayer) ); +} + + +TRACK * Locate_Pistes(TRACK * start_adresse, const wxPoint & ref_pos,int MasqueLayer) +{ +TRACK * Track; /* pointeur sur les pistes */ +int l_piste ; /* demi-largeur de la piste */ + + for( Track = start_adresse; Track != NULL; Track = (TRACK*) Track->Pnext) + { + if( Track->GetState(BUSY|DELETED) ) continue; + if ( (g_DesignSettings.m_LayerColor[Track->m_Layer] & ITEM_NOT_SHOW) ) + continue; + /* calcul des coordonnees du segment teste */ + l_piste = Track->m_Width >> 1; /* l_piste = demi largeur piste */ + ux0 = Track->m_Start.x ; uy0 = Track->m_Start.y ; /* coord de depart */ + dx = Track->m_End.x ; dy = Track->m_End.y ; /* coord d'arrivee */ + + /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ + dx -= ux0 ; dy -= uy0 ; + spot_cX = ref_pos.x - ux0 ; spot_cY = ref_pos.y - uy0 ; + + if ( Track->m_StructType == TYPEVIA ) /* VIA rencontree */ + { + if ((abs(spot_cX) <= l_piste ) && (abs(spot_cY) <=l_piste)) + { + return(Track) ; + } + continue ; + } + + if(MasqueLayer != -1) + if( (g_TabOneLayerMask[Track->m_Layer] & MasqueLayer) == 0) + continue; /* Segments sur couches differentes */ + if( distance(l_piste) ) return(Track) ; + } + return(NULL) ; +} + + /****************************************************************/ + /* TRACK * Locate_Zone(TRACK * start_adresse, int layer, */ + /* int typeloc) */ + /* TRACK * Locate_Zone(TRACK * start_adresse, */ + /* const wxPoint & ref_pos, */ + /* int layer) */ + /****************************************************************/ + +/* +1 - routine de localisation du segment de zone pointe par la souris. +2 - routine de localisation du segment de zone pointe par le point + ref_pos.x , ref_pos.y.r + + Si layer == -1 , le tst de la couche n'est pas fait + + La recherche commence a l'adresse start_adresse +*/ + +TRACK * Locate_Zone(TRACK * start_adresse,int layer, int typeloc ) +{ +wxPoint ref_pos; + + SET_REF_POS(ref_pos); + + return( Locate_Zone(start_adresse, ref_pos, layer) ); +} + + +TRACK * Locate_Zone(TRACK * start_adresse, const wxPoint & ref_pos, int layer) +{ +TRACK * Zone; /* pointeur sur les pistes */ +int l_segm ; /* demi-largeur de la piste */ + + for( Zone = start_adresse; Zone != NULL; Zone = (TRACK *) Zone->Pnext) + { + /* calcul des coordonnees du segment teste */ + l_segm = Zone->m_Width >> 1; /* l_piste = demi largeur piste */ + ux0 = Zone->m_Start.x ; uy0 = Zone->m_Start.y ; /* coord de depart */ + dx = Zone->m_End.x ; dy = Zone->m_End.y ; /* coord d'arrivee */ + + /* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */ + dx -= ux0 ; dy -= uy0 ; + spot_cX = ref_pos.x - ux0 ; spot_cY = ref_pos.y - uy0 ; + + if((layer != -1) && (Zone->m_Layer != layer)) continue; + if( distance(l_segm) ) return(Zone) ; + } + return(NULL) ; +} + + + +/*******************************************************************/ +TEXTE_PCB * Locate_Texte_Pcb(EDA_BaseStruct * PtStruct, int typeloc) +/*******************************************************************/ +/* localisation des inscriptions sur le Pcb: + entree : EDA_BaseStruct pointeur sur le debut de la zone de recherche + retour : pointeur sur la description du texte localise +*/ +{ +wxPoint ref; + + SET_REF_POS(ref); + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if( PtStruct->m_StructType != TYPETEXTE ) continue; + TEXTE_PCB * pt_txt_pcb = (TEXTE_PCB *) PtStruct; + if( pt_txt_pcb->Locate(ref) ) return pt_txt_pcb; + } + return(NULL) ; +} + + + + /*****************************/ + /* int distance(int seuil) */ + /*****************************/ + +/* + Calcul de la distance du curseur souris a un segment de droite : + ( piste, edge, contour module .. + retourne: + 0 si distance > seuil + 1 si distance <= seuil + Variables utilisees ( doivent etre initialisees avant appel , et + sont ramenees au repere centre sur l'origine du segment) + dx, dy = coord de l'extremite segment. + spot_cX,spot_cY = coord du curseur souris + la recherche se fait selon 4 cas: + segment horizontal + segment vertical + segment 45 + segment quelconque +*/ + +int distance(int seuil) +{ +int cXrot, cYrot , /* coord du point (souris) dans le repere tourne */ + segX, segY; /* coord extremite segment tj >= 0 */ +int pointX, pointY; /* coord point a tester dans repere modifie dans lequel + segX et segY sont >=0 */ + + segX = dx ; segY = dy; pointX = spot_cX ; pointY = spot_cY ; + + /*Recalcul coord pour que le segment soit dans 1er quadrant (coord >= 0)*/ + if (segX < 0) /* mise en >0 par symetrie par rapport a l'axe Y */ + { + segX = -segX ; pointX = - pointX ; + } + if (segY < 0) /* mise en > 0 par symetrie par rapport a l'axe X */ + { + segY = -segY ; pointY = -pointY ; + } + + + if ( segY == 0 ) /* piste Horizontale */ + { + if(abs(pointY) <= seuil ) + { + if((pointX >= 0) && (pointX <= segX) ) return(1); + /* Etude des extremites : cercle de rayon seuil */ + if( (pointX < 0) && (pointX >= -seuil) ) + { + if( ((pointX * pointX) + (pointY*pointY)) <= (seuil*seuil) ) + return(1); + } + if( (pointX > segX) && (pointX <= (segX+seuil)) ) + { + if( (((pointX-segX) * (pointX-segX)) + (pointY*pointY)) <= (seuil*seuil) ) + return(1); + } + } + } + + else if ( segX == 0 ) /* piste verticale */ + { + if( abs(pointX) <= seuil) + { + if((pointY >= 0 ) && (pointY <= segY) ) return(1); + if( (pointY < 0) && (pointY >= -seuil) ) + { + if( ((pointY * pointY) + (pointX*pointX)) <= (seuil*seuil) ) + return(1); + } + if( (pointY > segY) && (pointY <= (segY+seuil)) ) + { + if( ( ((pointY-segY) * (pointY-segY)) + (pointX*pointX)) <= (seuil*seuil) ) + return(1); + } + } + } + + else if ( segX == segY ) /* piste a 45 degre */ + { + /* on fait tourner les axes de 45 degre. la souris a alors les + coord : x1 = x*cos45 + y*sin45 + y1 = y*cos45 - x*sin45 + et le segment de piste est alors horizontal. + recalcul des coord de la souris ( sin45 = cos45 = .707 = 7/10 + remarque : sin ou cos45 = .707, et lors du recalcul des coord + dx45 et dy45, lec coeff .707 est neglige, dx et dy sont en fait .707 fois + trop grands. (c.a.d trop petits) + spot_cX,Y doit etre * par .707 * .707 = 0.5 */ + + cXrot = (pointX + pointY) >> 1 ; + cYrot = (pointY - pointX) >> 1 ; + + /* recalcul des coord de l'extremite du segment , qui sera vertical + suite a l'orientation des axes sur l'ecran : dx45 = pointX (ou pointY) + et est en fait 1,414 plus grand , et dy45 = 0 */ + + // seuil doit etre * .707 pour tenir compte du coeff de reduction sur dx,dy + seuil *= 7 ; seuil /= 10 ; + if ( abs(cYrot) <= seuil) /* ok sur axe vertical) */ + { + if ((cXrot >= 0) && (cXrot <= segX) ) return(1) ; + + /* Etude des extremites : cercle de rayon seuil */ + if( (cXrot < 0) && (cXrot >= -seuil) ) + { + if( ((cXrot * cXrot) + (cYrot*cYrot)) <= (seuil*seuil) ) + return(1); + } + if( (cXrot > segX) && (cXrot <= (segX+seuil)) ) + { + if( (((cXrot-segX) * (cXrot-segX)) + (cYrot*cYrot)) <= (seuil*seuil) ) + return(1); + } + } + } + else /* orientation quelconque */ + { + /* On fait un changement d'axe (rotation) de facon a ce que le segment + de piste soit horizontal dans le nouveau repere */ + int angle; + + angle = (int)( atan2((float)segY, (float)segX) * 1800 / M_PI) ; + cXrot = pointX; cYrot = pointY; + RotatePoint(&cXrot, &cYrot, angle); /* Rotation du point a tester */ + RotatePoint(&segX, &segY, angle) ; /* Rotation du segment */ + + /*la piste est Horizontale , par suite des modifs de coordonnes + et d'axe, donc segX = longueur du segment */ + + if ( abs(cYrot) <= seuil ) /* ok sur axe vertical) */ + { + if ((cXrot >= 0) && (cXrot <= segX) ) return(1) ; + /* Etude des extremites : cercle de rayon seuil */ + if( (cXrot < 0) && (cXrot >= -seuil) ) + { + if( ((cXrot * cXrot) + (cYrot*cYrot)) <= (seuil*seuil) ) + return(1); + } + if( (cXrot > segX) && (cXrot <= (segX+seuil)) ) + { + if( (((cXrot-segX) * (cXrot-segX)) + (cYrot*cYrot)) <= (seuil*seuil) ) + return(1); + } + } + } + return(0) ; +} + +/*******************************************************************************/ +D_PAD * Fast_Locate_Pad_Connecte(BOARD * Pcb, const wxPoint & ref_pos, int masque_layer) +/*******************************************************************************/ +/* Routine cherchant le pad de centre px,py, + sur la couche indiquee par masque_layer (bit a bit) + ( extremite de piste ) + La liste des pads doit deja exister. + + retourne : + NULL si pas de pad localise. + pointeur sur la structure descr_pad correspondante si pad trouve + (bonne position ET bonne couche). +*/ +{ +D_PAD * pad; +LISTE_PAD * ptr_pad , * lim; + + lim = (LISTE_PAD*)Pcb->m_Pads + Pcb->m_NbPads; + for (ptr_pad = (LISTE_PAD*)Pcb->m_Pads; ptr_pad < lim ; ptr_pad++) + { + pad = * ptr_pad; + if( pad->m_Pos != ref_pos ) continue ; + + /* Pad peut-etre trouve ici : il doit etre sur la bonne couche */ + if (pad->m_Masque_Layer & masque_layer) return(pad) ; + + } + return(NULL); +} + + +/***********************************************************************************/ +TRACK * Fast_Locate_Piste(TRACK *start_adr, TRACK* end_adr, + const wxPoint & ref_pos, int MaskLayer) +/***********************************************************************************/ +/* Localiste le segment dont une extremite coincide avec le point x,y + sur les couches donnees par masklayer + la recherche se fait de l'adresse start_adr a end_adr + si end_adr = NULL, recherche jusqu'a la fin de la liste + Les segments de piste marques avec le flag DELETED ne sont pas + pris en compte +*/ +{ +TRACK * PtSegm; + + if( start_adr == NULL ) return(NULL); + for ( PtSegm = start_adr; PtSegm != NULL; PtSegm = (TRACK*) PtSegm->Pnext ) + { + if( PtSegm->GetState(DELETED|BUSY) == 0) + { + if( ref_pos == PtSegm->m_Start ) + { /* Test des couches */ + if(MaskLayer & PtSegm->ReturnMaskLayer() ) return(PtSegm); + } + + if( ref_pos == PtSegm->m_End ) + { /* Test des couches */ + if(MaskLayer & PtSegm->ReturnMaskLayer() ) return(PtSegm); + } + } + if( PtSegm == end_adr) break; + } + return (NULL); +} + +/*******************************************************************/ +TRACK * Fast_Locate_Via(TRACK *start_adr, TRACK* end_adr, + const wxPoint & pos, int MaskLayer) +/*******************************************************************/ + +/* Localise la via de centre le point x,y , sur les couches donnees + par masklayer + la recherche se fait de l'adresse start_adr a end_adr. + si end_adr = NULL, recherche jusqu'a la fin de la liste + les vias dont le parametre State a le bit DELETED ou BUSY = 1 sont ignorees +*/ +{ +TRACK * PtSegm; + + for ( PtSegm = start_adr; PtSegm != NULL; PtSegm = (TRACK*)PtSegm->Pnext ) + { + if(PtSegm->m_StructType == TYPEVIA) + { + if( pos == PtSegm->m_Start ) + { + if( PtSegm->GetState(BUSY|DELETED) == 0) + {/* Test des couches */ + if( MaskLayer & PtSegm->ReturnMaskLayer() )return(PtSegm); + } + } + } + if( PtSegm == end_adr ) break; + } + return (NULL); +} + + +/***********************************************************************/ +EDA_BaseStruct * Locate_MirePcb( EDA_BaseStruct * PtStruct, int typeloc) +/***********************************************************************/ +/* Routine d'initialisation du deplacement d'une mire +*/ +{ +wxPoint ref_pos; /* coord du point de localisation */ +int dX, dY, rayon; + + if(PtStruct == NULL ) return(NULL); + + SET_REF_POS(ref_pos); + + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext) + { + if( PtStruct->m_StructType != TYPEMIRE ) continue; + dX = ref_pos.x - ((MIREPCB*) PtStruct)->m_Pos.x; + dY = ref_pos.y - ((MIREPCB*) PtStruct)->m_Pos.y; + rayon = ((MIREPCB*) PtStruct)->m_Size / 2; + if( (abs(dX) <= rayon ) && ( abs(dY) <= rayon ) ) + break; /* Mire Localisee */ + } + return(PtStruct); +} + diff --git a/pcbnew/makefile.g95 b/pcbnew/makefile.g95 new file mode 100644 index 0000000000..7df527ab30 --- /dev/null +++ b/pcbnew/makefile.g95 @@ -0,0 +1,32 @@ +#makefile for pcbnew, Windows + +WXDIR = $(WXWIN) + +TARGET=pcbnew + +include ../libs.win + +all: $(TARGET).exe + +include makefile.include + +$(TARGET).exe: $(OBJECTS) $(TARGET)_resources.o\ + $(EDALIBS) $(LIBVIEWER3D) makefile.g95 + $(CXX) $(ALL_LDFLAGS) -o $(TARGET).exe\ + $(OBJECTS) $(LIBVIEWER3D) $(TARGET)_resources.o $(EDALIBS) $(SYSWXLIB) + +install: + cp $(TARGET).exe $(KICAD_BIN) + + +$(TARGET)_resources.o: $(TARGET).rc icon_pcbnew.ico icon_modedit.ico icon_w3d.ico + $(RESCOMP) $(RCINPUTSWITCH) $(TARGET).rc $(RCOUTPUTSWITCH) $(TARGET)_resources.o $(RESFLAGS) + + +clean : + -$(RM) *.o + -$(RM) *.exe + -$(RM) *.rsc + -$(RM) *.res + -$(RM) *.bak + diff --git a/pcbnew/makefile.gtk b/pcbnew/makefile.gtk new file mode 100644 index 0000000000..2fa460d172 --- /dev/null +++ b/pcbnew/makefile.gtk @@ -0,0 +1,39 @@ +## Makefile for PCBNEW et wxGTK +CC = gcc +LD = gcc + +# Compiler flags. + +CPPFLAGS = -Wall -O2 `wx-config --cxxflags` + +LDFLAGS = -s + +include ../libs.linux + +TARGET = pcbnew + +all: $(TARGET) + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + + + +$(TARGET): $(OBJECTS) makefile.gtk makefile.include $(LIBVIEWER3D) $(EXTRALIBS) ../libs.linux + $(LD) $(LDFLAGS) $(OBJECTS) $(LIBVIEWER3D) $(LIBS_WITH_GL)\ + -o $(TARGET) + + +install: + cp $(TARGET) $(KICAD_BIN) + + +clean: + rm -f *.o + rm -f *.map + rm -f $(TARGET) + + + diff --git a/pcbnew/makefile.include b/pcbnew/makefile.include new file mode 100644 index 0000000000..4796323d89 --- /dev/null +++ b/pcbnew/makefile.include @@ -0,0 +1,287 @@ +EXTRALIBS = ../common/common.a +EXTRACPPFLAGS= -DPCBNEW -I./ -Ibitmaps -I../include -I../share -I../pcbnew -I../3d-viewer + +#COMMON = pcbnew.h struct.h class_pad.h class_module.h class_text_mod.h \ +# class_edge_mod.h class_equipot.h + +LIBVIEWER3D = ../3d-viewer/3d-viewer.a + +OBJECTS= $(TARGET).o classpcb.o\ + lay2plot.o\ + modedit_undo_redo.o\ + block_module_editor.o\ + onrightclick.o\ + modedit_onclick.o\ + via_edit.o\ + wxprint.o \ + cursors.o\ + menubarpcb.o \ + menubarmodedit.o \ + tool_onrightclick.o\ + edit.o \ + setpage.o \ + tool_pcb.o \ + pcbframe.o \ + class_track.o \ + class_mire.o\ + class_cotation.o\ + class_pad.o \ + class_equipot.o \ + class_module.o \ + class_edge_mod.o \ + class_text_mod.o\ + class_pcb_text.o\ + class_board.o\ + drawframe.o\ + drawpanel.o\ + track.o \ + set_color.o \ + set_grid.o \ + pcbcfg.o \ + netlist.o \ + affiche.o \ + pcbpiste.o \ + tracepcb.o \ + tracemod.o \ + trpiste.o \ + surbrill.o \ + pcbtexte.o \ + locate.o \ + modules.o \ + loadcmp.o \ + zoom.o\ + dialog_setup_libs.o \ + dialog_general_options.o \ + muwave_command.o \ + initpcb.o\ + editrack.o \ + editrack-part2.o \ + deltrack.o edit_track_width.o \ + editmod.o\ + editpads.o \ + move-drag_pads.o\ + globaleditpad.o \ + editedge.o\ + edtxtmod.o \ + dialog_edit_mod_text.o\ + ratsnest.o drc.o \ + block.o\ + clean.o \ + pcbplot.o\ + plothpgl.o\ + plot_rtn.o\ + plotgerb.o\ + librairi.o edgemod.o\ + connect.o muonde.o attribut.o\ + gendrill.o\ + sel_layer.o \ + cotation.o\ + automove.o\ + tr_modif.o \ + autorout.o solve.o\ + work.o queue.o \ + board.o dist.o graphpcb.o \ + zones.o undelete.o \ + move_copy_track.o ioascii.o struct.o \ + mirepcb.o xchgmod.o\ + plotps.o\ + dragsegm.o\ + autoplac.o\ + files.o\ + infospgm.o\ + router.o\ + controle.o\ + tool_modedit.o\ + moduleframe.o\ + find.o\ + basepcbframe.o\ + modeditoptions.o\ + gen_modules_placefile.o\ + modedit.o\ + export_gencad.o\ + hotkeys.o + +setpage.o: ../share/setpage.cpp + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +drawpanel.o: ../share/drawpanel.cpp + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +drawframe.o: ../share/drawframe.cpp + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +menubarpcb.o: menubarpcb.cpp $(COMMON) + +dialog_general_options.o: dialog_general_options.cpp dialog_track_options.cpp dialog_display_options.cpp\ + dialog_graphic_items_options.cpp $(COMMON) + +menubarmodedit.o: menubarmodedit.cpp $(COMMON) + +controle.o: controle.cpp $(COMMON) + +cursors.o: cursors.cpp $(COMMON) + +tool_onrightclick.o: tool_onrightclick.cpp $(COMMON) + +files.o: files.cpp $(COMMON) + +export_gencad.o: export_gencad.cpp $(COMMON) + +wxprint.o: ../share/wxprint.cpp ../share/dialog_print.cpp ../share/dialog_print.h $(COMMON) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +lay2plot.o: lay2plot.cpp $(COMMON) + +classpcb.o: classpcb.cpp $(COMMON) + +class_track.o: class_track.cpp class_track.h $(COMMON) + +class_mire.o: class_mire.cpp class_mire.h $(COMMON) + +class_cotation.o: class_cotation.cpp class_cotation.h $(COMMON) + +class_pad.o: class_pad.cpp $(COMMON) + +class_equipot.o: class_equipot.cpp $(COMMON) + +class_module.o: class_module.cpp $(COMMON) + +class_edge_mod.o: class_edge_mod.cpp $(COMMON) + +class_text_mod.o: class_text_mod.cpp $(COMMON) + +class_pcb_text.o: class_pcb_text.cpp class_pcb_text.h $(COMMON) + +pcbnew.o: pcbnew.cpp pcbnew.h pcbplot.h drag.h $(COMMON) \ + autorout.h ../include/eda_dde.h + +pcbcfg.o: pcbcfg.cpp $(COMMON) pcbcfg.h pcbplot.h + +netlist.o: netlist.cpp dialog_netlist.cpp dialog_netlist.h $(COMMON) + +gen_modules_placefile.o: gen_modules_placefile.cpp $(COMMON) + +xchgmod.o: xchgmod.cpp $(COMMON) + +pcbpiste.o: pcbpiste.cpp $(COMMON) + +tracepcb.o: tracepcb.cpp $(COMMON) + +tracemod.o: tracemod.cpp ../include/grfonte.h $(COMMON) + +trpiste.o: trpiste.cpp $(COMMON) + +surbrill.o: surbrill.cpp $(COMMON) + +pcbtexte.o: pcbtexte.cpp $(COMMON) + +locate.o: locate.cpp $(COMMON) + +modules.o: modules.cpp drag.h $(COMMON) + +autoplac.o: autoplac.cpp autorout.h $(COMMON) + +automove.o: automove.cpp autorout.h $(COMMON) + +loadcmp.o: loadcmp.cpp $(COMMON) + +zoom.o: ../share/zoom.cpp $(COMMON) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +infospgm.o: ../share/infospgm.cpp $(COMMON) + $(CC) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp + +affiche.o: affiche.cpp $(COMMON) + +tr_modif.o: tr_modif.cpp $(COMMON) + +dialog_setup_libs.o: dialog_setup_libs.cpp $(COMMON) + +initpcb.o: initpcb.cpp dialog_initpcb.cpp dialog_initpcb.h $(COMMON) + +editrack.o: editrack.cpp $(COMMON) + +attribut.o: attribut.cpp $(COMMON) + +deltrack.o: deltrack.cpp $(COMMON) + +track.o: track.cpp $(COMMON) + +edit_track_width.o: edit_track_width.cpp $(COMMON) + +editmod.o: editmod.cpp dialog_edit_module.cpp dialog_edit_module.h $(COMMON) + +editpads.o: editpads.cpp dialog_pad_edit.cpp dialog_pad_edit.h $(COMMON) + +move-drag_pads.o: move-drag_pads.cpp drag.h $(COMMON) + +editedge.o: editedge.cpp $(COMMON) + +cotation.o: cotation.cpp $(COMMON) + +edtxtmod.o: edtxtmod.cpp $(COMMON) + +dialog_edit_mod_text.o: dialog_edit_mod_text.cpp dialog_edit_mod_text.h $(COMMON) + +ratsnest.o: ratsnest.cpp $(COMMON) + +connect.o: connect.cpp $(COMMON) + +drc.o: drc.cpp dialog_drc.cpp dialog_drc.h autorout.h $(COMMON) + +block.o: block.cpp $(COMMON) + +clean.o: clean.cpp $(COMMON) + +pcbplot.o: pcbplot.cpp pcbplot.h $(COMMON) + +plothpgl.o: plothpgl.cpp $(COMMON) + +plotgerb.o: plotgerb.cpp pcbplot.h plotgerb.h $(COMMON) + +plotps.o: plotps.cpp pcbplot.h $(COMMON) + +readgerb.o: readgerb.cpp pcbplot.h $(COMMON) + +plot_rtn.o: plot_rtn.cpp pcbplot.h $(COMMON) + +gendrill.o: gendrill.cpp pcbplot.h $(COMMON) + +librairi.o: librairi.cpp $(COMMON) + +edgemod.o: edgemod.cpp $(COMMON) + +muonde.o: muonde.cpp drag.h gen_self.h $(COMMON) + +autorout.o: autorout.cpp cell.h autorout.h $(COMMON) + +solve.o: solve.cpp cell.h autorout.h $(COMMON) + +work.o: work.cpp cell.h autorout.h $(COMMON) + +queue.o: queue.cpp cell.h autorout.h $(COMMON) + +board.o: board.cpp cell.h autorout.h $(COMMON) + +dist.o: dist.cpp cell.h autorout.h $(COMMON) + +graphpcb.o: graphpcb.cpp cell.h autorout.h $(COMMON) + +zones.o: zones.cpp cell.h $(COMMON) + +undelete.o: undelete.cpp $(COMMON) + +move_copy_track.o: move_copy_track.cpp $(COMMON) + +ioascii.o: ioascii.cpp $(COMMON) + +struct.o: struct.cpp $(COMMON) + +coordbox.o: coordbox.cpp $(COMMON) + +mirepcb.o: mirepcb.cpp $(COMMON) + +dragsegm.o: dragsegm.cpp drag.h $(COMMON) + +router.o: router.cpp $(COMMON) + diff --git a/pcbnew/makefile.macosx b/pcbnew/makefile.macosx new file mode 100644 index 0000000000..ed0849e26a --- /dev/null +++ b/pcbnew/makefile.macosx @@ -0,0 +1,39 @@ +## Makefile for PCBNEW et wxGTK +CC = gcc +LD = g++ + +# Compiler flags. + +CPPFLAGS = -Wall -O2 `wx-config --cxxflags` + +LDFLAGS = + +include ../libs.macosx + +TARGET = pcbnew + +all: $(TARGET) + +include makefile.include + +CPPFLAGS += $(EXTRACPPFLAGS) +EDACPPFLAGS = $(CPPFLAGS) + + + +$(TARGET): $(OBJECTS) $(TARGET).r makefile.macosx makefile.include $(LIBVIEWER3D) $(EXTRALIBS) ../libs.macosx + $(LD) $(LDFLAGS) $(OBJECTS) $(LIBVIEWER3D) $(LIBS3D) -o $(TARGET) + $(RESCOMP) -o $(TARGET) Carbon.r $(TARGET).r + $(SETFILE) -a C $(TARGET) + +install: + cp $(TARGET) $(KICAD_BIN) + + +clean: + rm -f *.o + rm -f *.map + rm -f $(TARGET) + + + diff --git a/pcbnew/menubarmodedit.cpp b/pcbnew/menubarmodedit.cpp new file mode 100644 index 0000000000..1d16b06a08 --- /dev/null +++ b/pcbnew/menubarmodedit.cpp @@ -0,0 +1,85 @@ +/***********************************************************************/ +/* menubarmodedit.cpp - creation du menu general de l'editeur de module*/ +/***********************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" +#include "common.h" + +#include "pcbnew.h" + +#include "bitmaps.h" +#include "protos.h" +#include "id.h" + + + +/***********************************************/ +void WinEDA_ModuleEditFrame::ReCreateMenuBar(void) +/***********************************************/ + +/* Cree ou reinitialise le menu du haut d'ecran +*/ +{ +wxMenuBar * menuBar = GetMenuBar(); +wxMenuItem * item; + + if( ! menuBar ) + { + menuBar = new wxMenuBar(); + + ///////////////////////////// + // Ajustage de dimensions: // + ///////////////////////////// + wxMenu * sizes_menu = new wxMenu; + + item = new wxMenuItem(sizes_menu, ID_PCB_DRAWINGS_WIDTHS_SETUP, + _("Sizes and Widths"), + _("Adjust width for texts and drawings")); + item->SetBitmap(options_text_xpm); + sizes_menu->Append(item); + + item = new wxMenuItem(sizes_menu, ID_PCB_PAD_SETUP, _("Pad Settings"), + _("Adjust size,shape,layers... for Pads")); + item->SetBitmap(pad_xpm); + sizes_menu->Append(item); + + item = new wxMenuItem(sizes_menu, ID_PCB_USER_GRID_SETUP, _("User Grid Size"), + _("Adjust User Grid")); + item->SetBitmap(grid_xpm); + sizes_menu->Append(item); + + + //////////////// + // Menu Help: // + //////////////// + wxMenu *helpMenu = new wxMenu; + item = new wxMenuItem(helpMenu , ID_GENERAL_HELP, _("Pcbnew &Help"), _("On line doc")); + item->SetBitmap(help_xpm); + helpMenu->Append(item); + + item = new wxMenuItem(helpMenu , ID_KICAD_ABOUT, _("Pcbnew &About"), _("Pcbnew Infos")); + item->SetBitmap(info_xpm); + helpMenu->Append(item); + + ////////////////////// + // Menu Display 3D: // + ////////////////////// + wxMenu *Display3DMenu = new wxMenu; + item = new wxMenuItem(Display3DMenu , ID_MENU_PCB_SHOW_3D_FRAME, _("3D Display"), _("Show Board in 3D Mode")); + item->SetBitmap(show_3d_xpm); + Display3DMenu->Append(item); + + menuBar->Append(sizes_menu, _("&Dimensions")); + menuBar->Append(Display3DMenu, _("&3D Display")); + menuBar->Append(helpMenu, _("&Help")); + + // Associate the menu bar with the frame + SetMenuBar(menuBar); + } +} + + diff --git a/pcbnew/menubarpcb.cpp b/pcbnew/menubarpcb.cpp new file mode 100644 index 0000000000..00e7891af7 --- /dev/null +++ b/pcbnew/menubarpcb.cpp @@ -0,0 +1,312 @@ +/******************************************************************/ +/* menubarpcb.cpp - creation du menu general de l'editeur de board*/ +/******************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" +#include "common.h" + +#include "pcbnew.h" + +#include "bitmaps.h" +#include "protos.h" +#include "id.h" + +#include "Swap_Layer.xpm" +#include "Post_Drill.xpm" +#include "Post_Compo.xpm" + +/***********************************************/ +void WinEDA_PcbFrame::ReCreateMenuBar(void) +/***********************************************/ + +/* Cree ou reinitialise le menu du haut d'ecran +*/ +{ +int ii; +wxMenuBar * menuBar = GetMenuBar(); + + if( menuBar == NULL ) + { + menuBar = new wxMenuBar(); + + ////////////////// + // Menu "Files" // + ////////////////// + m_FilesMenu = new wxMenu; + wxMenuItem *item = new wxMenuItem(m_FilesMenu, ID_MENU_LOAD_FILE, + _("Load Board"), + _("Delete old Board and Load new Board")); + item->SetBitmap(open_xpm); + m_FilesMenu->Append(item); + + item = new wxMenuItem(m_FilesMenu, ID_MENU_APPEND_FILE, + _("Append Board"), + _("Add Board to old Board")); + item->SetBitmap(import_xpm); + m_FilesMenu->Append(item); + + item = new wxMenuItem(m_FilesMenu, ID_MENU_NEW_BOARD, + _("&New board"), + _("Clear old PCB and init a new one")); + item->SetBitmap(new_xpm); + m_FilesMenu->Append(item); + + item = new wxMenuItem(m_FilesMenu, ID_MENU_RECOVER_BOARD, + _("&Rescue"), + _("Clear old board and get last rescue file")); + item->SetBitmap(hammer_xpm); + m_FilesMenu->Append(item); + + item = new wxMenuItem(m_FilesMenu, ID_MENU_READ_LAST_SAVED_VERSION_BOARD, + _("&Previous version"), + _("Clear old board and get old version of board") ); + item->SetBitmap(jigsaw_xpm); + m_FilesMenu->Append(item); + + // Add save menu + m_FilesMenu->AppendSeparator(); + item = new wxMenuItem(m_FilesMenu, ID_MENU_SAVE_BOARD, + _("&Save board"), + _("Save current board") ); + item->SetBitmap(save_xpm); + m_FilesMenu->Append(item); + + item = new wxMenuItem(m_FilesMenu, ID_MENU_SAVE_BOARD_AS, + _("Save Board as.."), + _("Save current board as..") ); + item->SetBitmap(save_as_xpm); + m_FilesMenu->Append(item); + + // Add print menu + m_FilesMenu->AppendSeparator(); + item = new wxMenuItem(m_FilesMenu, ID_GEN_PRINT, + _("P&rint"), _("Print on current printer")); + item->SetBitmap(print_button); + m_FilesMenu->Append(item); + + // Add plot menu + item = new wxMenuItem(m_FilesMenu, ID_GEN_PLOT, _("&Plot"), + _("Plot (Hplg, Postscript, or Gerber format)")); + item->SetBitmap(plot_xpm); + m_FilesMenu->Append(item); + + // Add Export menu + m_FilesMenu->AppendSeparator(); + wxMenu * submenuexport = new wxMenu(); + item = new wxMenuItem(submenuexport, ID_GEN_EXPORT_FILE_GENCADFORMAT, + _("&GenCAD"), _("Export GenCAD Format") ); + item->SetBitmap(export_xpm); + submenuexport->Append(item); + item = new wxMenuItem(submenuexport, ID_GEN_EXPORT_FILE_MODULE_REPORT, + _("&Module report"), _("Create a pcb report (footprint report)") ); + item->SetBitmap(tools_xpm); + submenuexport->Append(item); + ADD_MENUITEM_WITH_HELP_AND_SUBMENU(m_FilesMenu, submenuexport, + ID_GEN_EXPORT_FILE, _("E&xport"), _("Export board"), export_xpm); + + // Add archive footprints menu + m_FilesMenu->AppendSeparator(); + wxMenu * submenuarchive = new wxMenu(); + item = new wxMenuItem(submenuarchive, ID_MENU_ARCHIVE_NEW_MODULES, + _("Add new footprints"), + _("Archive new footprints only in a library (keep other footprints in this lib)") ); + item->SetBitmap(library_update_xpm); + submenuarchive->Append(item); + item = new wxMenuItem(submenuarchive, ID_MENU_ARCHIVE_ALL_MODULES, + _("Create footprint archive"), + _("Archive all footprints in a library(old lib will be deleted)") ); + item->SetBitmap(library_xpm); + submenuarchive->Append(item); + ADD_MENUITEM_WITH_HELP_AND_SUBMENU(m_FilesMenu, submenuarchive, + ID_MENU_ARCHIVE_MODULES, + _("Archive footprints"), + _("Archive or Add footprints in a library file"), library_xpm); + + // Add exit menu + m_FilesMenu->AppendSeparator(); + item = new wxMenuItem(m_FilesMenu, ID_EXIT, _("E&xit"), _("Quit pcbnew") ); + item->SetBitmap(exit_xpm); + m_FilesMenu->Append(item); + + + // Creation des selections des anciens fichiers + m_FilesMenu->AppendSeparator(); + int max_file = m_Parent->m_LastProjectMaxCount; + for ( ii = 0; ii < max_file; ii++ ) + { + if ( GetLastProject(ii).IsEmpty() ) break; + m_FilesMenu->Append(ID_LOAD_FILE_1 + ii, GetLastProject(ii) ); + } + + /////////////////////////////////// + // Configuration et preferences: // + /////////////////////////////////// + wxMenu * configmenu = new wxMenu; + item = new wxMenuItem(configmenu, ID_CONFIG_REQ, _("&Libs and Dir"), + _("Setting Libraries, Directories and others...")); + item->SetBitmap(library_xpm); + configmenu->Append(item); + + item = new wxMenuItem(configmenu, ID_COLORS_SETUP, _("&Colors"), + _("Select Colors and Display for PCB items")); + item->SetBitmap(palette_xpm); + configmenu->Append(item); + + item = new wxMenuItem(configmenu, ID_OPTIONS_SETUP, _("&General Options"), + _("Select general options for pcbnew")); + item->SetBitmap(preference_xpm); + configmenu->Append(item); + + item = new wxMenuItem(configmenu, ID_PCB_LOOK_SETUP, _("&Display Options"), + _("Select what items are displayed")); + item->SetBitmap(display_options_xpm); + configmenu->Append(item); + + // Font selection and setup + AddFontSelectionMenu(configmenu); + + m_Parent->SetLanguageList(configmenu); + + configmenu->AppendSeparator(); + item = new wxMenuItem(configmenu, ID_CONFIG_SAVE, _("&Save Setup"), + _("Save options in current directory")); + item->SetBitmap(save_setup_xpm); + configmenu->Append(item); + + item = new wxMenuItem(configmenu, ID_CONFIG_READ, _("&Read Setup"), + _("Read options from a selected config file")); + item->SetBitmap(read_setup_xpm); + configmenu->Append(item); + + ///////////////////////////// + // Ajustage de dimensions: // + ///////////////////////////// + wxMenu * sizes_menu = new wxMenu; + + item = new wxMenuItem(sizes_menu, ID_PCB_TRACK_SIZE_SETUP, _("Tracks and Vias"), + _("Adjust size and width for tracks, vias")); + item->SetBitmap(showtrack_xpm); + sizes_menu->Append(item); + + item = new wxMenuItem(sizes_menu, ID_PCB_USER_GRID_SETUP, _("User Grid Size"), + _("Adjust User Grid")); + item->SetBitmap(grid_xpm); + sizes_menu->Append(item); + + item = new wxMenuItem(sizes_menu, ID_PCB_DRAWINGS_WIDTHS_SETUP, _("Texts and Drawings"), + _("Adjust width for texts and drawings")); + item->SetBitmap(options_text_xpm); + sizes_menu->Append(item); + + item = new wxMenuItem(sizes_menu, ID_PCB_PAD_SETUP, _("Pad Settings"), + _("Adjust size,shape,layers... for Pads")); + item->SetBitmap(pad_xpm); + sizes_menu->Append(item); + + sizes_menu->AppendSeparator(); + item = new wxMenuItem(sizes_menu, ID_CONFIG_SAVE, _("&Save Setup"), + _("Save options in current directory")); + item->SetBitmap(save_xpm); + sizes_menu->Append(item); + + ////////////////////////////////////////////////////////////////// + // Menu postprocess ( generation fichiers percage, placement... // + ////////////////////////////////////////////////////////////////// + wxMenu *postprocess_menu = new wxMenu; + item = new wxMenuItem(postprocess_menu, ID_PCB_GEN_POS_MODULES_FILE, + _("Create &Modules Pos"), + _("Gen Position modules file")); + item->SetBitmap(post_compo_xpm); + postprocess_menu->Append(item); + + item = new wxMenuItem(postprocess_menu, ID_PCB_GEN_DRILL_FILE, _("Create &Drill file"), + _("Gen Drill (EXCELLON] file and/or Drill sheet")); + item->SetBitmap(post_drill_xpm); + postprocess_menu->Append(item); + + item = new wxMenuItem(postprocess_menu, ID_PCB_GEN_CMP_FILE, _("Create &Cmp file"), + _("Recreate .cmp file for CvPcb")); + item->SetBitmap(save_cmpstuff_xpm); + postprocess_menu->Append(item); + + ////////////////////////// + // Menu d'outils divers // + ////////////////////////// + wxMenu *miscellaneous_menu = new wxMenu; + item = new wxMenuItem(miscellaneous_menu, ID_PCB_GLOBAL_DELETE, _("Global &Deletions"), + _("Delete Tracks, Modules, Texts... on Board")); + item->SetBitmap(general_deletions_xpm); + miscellaneous_menu->Append(item); + + item = new wxMenuItem(miscellaneous_menu, ID_MENU_LIST_NETS, _("&List nets"), + _("List nets (names and id)")); + item->SetBitmap(tools_xpm); + miscellaneous_menu->Append(item); + + item = new wxMenuItem(miscellaneous_menu, ID_MENU_PCB_CLEAN, _("&Clean tracks"), + _("Clean stubs, vias, delete break points")); + item->SetBitmap(delete_body_xpm); + miscellaneous_menu->Append(item); + + item = new wxMenuItem(miscellaneous_menu, ID_MENU_PCB_SWAP_LAYERS, _("&Swap layers"), + _("Swap tracks on copper layers or drawings on others layers")); + item->SetBitmap(swap_layer_xpm); + miscellaneous_menu->Append(item); + + //////////////// + // Menu Help: // + //////////////// + wxMenu *helpMenu = new wxMenu; + item = new wxMenuItem(helpMenu , ID_GENERAL_HELP, _("Pcbnew &Help"), _("On line doc")); + item->SetBitmap(help_xpm); + helpMenu->Append(item); + + item = new wxMenuItem(helpMenu , ID_KICAD_ABOUT, _("Pcbnew &About"), _("Pcbnew Infos")); + item->SetBitmap(info_xpm); + helpMenu->Append(item); + + ////////////////////// + // Menu Display 3D: // + ////////////////////// + wxMenu *Display3DMenu = new wxMenu; + item = new wxMenuItem(Display3DMenu , ID_MENU_PCB_SHOW_3D_FRAME, _("3D Display"), _("Show Board in 3D Mode")); + item->SetBitmap(show_3d_xpm); + Display3DMenu->Append(item); + + menuBar->Append(m_FilesMenu, _("&Files")); + menuBar->Append(configmenu, _("&Preferences")); + menuBar->Append(sizes_menu, _("&Dimensions")); + menuBar->Append(miscellaneous_menu, _("&Miscellaneous")); + menuBar->Append(postprocess_menu, _("P&ostprocess")); + menuBar->Append(Display3DMenu, _("&3D Display")); + menuBar->Append(helpMenu, _("&Help")); + + // Associate the menu bar with the frame + SetMenuBar(menuBar); + } + + else // simple mise a jour de la liste des fichiers anciens + { + wxMenuItem * item; + int max_file = m_Parent->m_LastProjectMaxCount; + for ( ii = max_file-1; ii >=0 ; ii-- ) + { + if( m_FilesMenu->FindItem(ID_LOAD_FILE_1 + ii) ) + { + item = m_FilesMenu->Remove(ID_LOAD_FILE_1 + ii); + if ( item ) delete item; + } + } + for ( ii = 0; ii < max_file; ii++ ) + { + if ( GetLastProject(ii).IsEmpty() ) break; + m_FilesMenu->Append(ID_LOAD_FILE_1 + ii, GetLastProject(ii) ); + } + } +} + + diff --git a/pcbnew/mirepcb.cpp b/pcbnew/mirepcb.cpp new file mode 100644 index 0000000000..28a4c00542 --- /dev/null +++ b/pcbnew/mirepcb.cpp @@ -0,0 +1,278 @@ + /*********************************************/ + /* Routines de gestion des mires de centrage */ + /*********************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + + +/* Routines Locales */ +static void Exit_EditMire(WinEDA_DrawPanel * Panel, wxDC *DC); +static void Montre_Position_Mire(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); + +/* Variables locales : */ +static wxPoint OldPos; +static int MireDefaultSize = 5000; + +enum id_mire_properties +{ + ID_ACCEPT_MIRE_PROPERTIES = 1900, + ID_CANCEL_MIRE_PROPERTIES, + ID_SIZE_MIRE, + ID_LISTBOX_SHAPE_MIRE +}; + + /************************************/ + /* class WinEDA_MirePropertiesFrame */ + /************************************/ + +class WinEDA_MirePropertiesFrame: public wxDialog +{ +private: + + WinEDA_PcbFrame * m_Parent; + wxDC * m_DC; + MIREPCB * m_MirePcb; + WinEDA_ValueCtrl * m_MireWidthCtrl; + WinEDA_ValueCtrl * m_MireSizeCtrl; + wxRadioBox * m_MireShape; + +public: + // Constructor and destructor + WinEDA_MirePropertiesFrame(WinEDA_PcbFrame *parent, + MIREPCB * Mire, wxDC * DC, const wxPoint & pos); + ~WinEDA_MirePropertiesFrame(void) + { + } + +private: + void MirePropertiesAccept(wxCommandEvent& event); + void OnQuit(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(WinEDA_MirePropertiesFrame, wxDialog) + EVT_BUTTON(ID_ACCEPT_MIRE_PROPERTIES, WinEDA_MirePropertiesFrame::MirePropertiesAccept) + EVT_BUTTON(ID_CANCEL_MIRE_PROPERTIES, WinEDA_MirePropertiesFrame::OnQuit) +END_EVENT_TABLE() + + + +/***************************************************************/ +void WinEDA_PcbFrame::InstallMireOptionsFrame(MIREPCB * MirePcb, + wxDC * DC, const wxPoint & pos) +/***************************************************************/ +{ + WinEDA_MirePropertiesFrame * frame = new WinEDA_MirePropertiesFrame(this, + MirePcb, DC, pos); + frame->ShowModal(); frame->Destroy(); +} + + +WinEDA_MirePropertiesFrame::WinEDA_MirePropertiesFrame(WinEDA_PcbFrame *parent, + MIREPCB * Mire,wxDC * DC, + const wxPoint & framepos): + wxDialog(parent, -1, _("Mire properties"), framepos, wxSize(270, 210), + DIALOG_STYLE) +{ +wxString number; +wxButton * Button; + + m_Parent = parent; + SetFont(*g_DialogFont); + m_DC = DC; + Centre(); + + m_MirePcb = Mire; + + wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(MainBoxSizer); + wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + /* Creation des boutons de commande */ + Button = new wxButton(this, ID_ACCEPT_MIRE_PROPERTIES, _("Ok")); + Button->SetForegroundColour(*wxRED); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Button = new wxButton(this, ID_CANCEL_MIRE_PROPERTIES, _("Cancel")); + Button->SetForegroundColour(*wxBLUE); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + // Size: + m_MireSizeCtrl = new WinEDA_ValueCtrl(this, _("Size"), + m_MirePcb->m_Size, + g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits ); + + // Width: + m_MireWidthCtrl = new WinEDA_ValueCtrl(this, _("Width"), + m_MirePcb->m_Width, + g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits ); + + // Shape +wxString shape_list[2] = { _("shape +"), _("shape X") }; + m_MireShape = new wxRadioBox(this, ID_LISTBOX_SHAPE_MIRE, + _("Mire Shape:"), + wxDefaultPosition, wxSize(-1,-1), + 2, shape_list, 1); + m_MireShape->SetSelection(m_MirePcb->m_Shape ? 1 : 0); + LeftBoxSizer->Add(m_MireShape, 0, wxGROW|wxALL, 5); + + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); +} + + +/**********************************************************************/ +void WinEDA_MirePropertiesFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/**********************************************************************/ +{ + Close(true); // true is to force the frame to close +} + + + +/**************************************************************************/ +void WinEDA_MirePropertiesFrame::MirePropertiesAccept(wxCommandEvent& event) +/**************************************************************************/ +/* Met a jour les differents parametres pour le composant en cours d'édition +*/ +{ + m_MirePcb->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0), GR_XOR); + + m_MirePcb->m_Width = m_MireWidthCtrl->GetValue(); + MireDefaultSize = m_MirePcb->m_Size = m_MireSizeCtrl->GetValue(); + m_MirePcb->m_Shape = m_MireShape->GetSelection() ? 1 : 0; + + m_MirePcb->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0), GR_OR); + + m_Parent->GetScreen()->SetModify(); + Close(TRUE); +} + +/**************************************************************/ +void WinEDA_PcbFrame::Delete_Mire(MIREPCB * MirePcb, wxDC * DC) +/**************************************************************/ +{ + + if( MirePcb == NULL ) return; + + MirePcb->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); + DeleteStructure(MirePcb); +} + + +/**********************************************************/ +static void Exit_EditMire(WinEDA_DrawPanel * Panel, wxDC *DC) +/**********************************************************/ +{ +BASE_SCREEN * screen = Panel->GetScreen(); +MIREPCB * MirePcb = (MIREPCB *) screen->m_CurrentItem; + + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + + if( MirePcb ) + { + /* Effacement de la mire */ + MirePcb->Draw(Panel, DC, wxPoint(0,0), GR_XOR); + + if( MirePcb->m_Flags & IS_NEW ) + { + MirePcb->Draw(Panel, DC, wxPoint(0,0), GR_XOR); + DeleteStructure(MirePcb); + MirePcb = NULL ; + } + else /* Ancienne mire en deplacement: Remise en ancienne position */ + { + MirePcb->m_Pos = OldPos; + MirePcb->m_Flags = 0; + MirePcb->Draw(Panel, DC, wxPoint(0,0),GR_OR); + } + } +} + +/*****************************************************/ +MIREPCB * WinEDA_PcbFrame::Create_Mire( wxDC *DC) +/*****************************************************/ +/* Routine de creation d'un Draw Symbole Pcb type MIRE +*/ +{ +MIREPCB * MirePcb = new MIREPCB(m_Pcb); + + MirePcb->Pnext = m_Pcb->m_Drawings; + MirePcb->Pback = m_Pcb; + if( m_Pcb->m_Drawings ) + m_Pcb->m_Drawings->Pback = MirePcb; + m_Pcb->m_Drawings = MirePcb; + + MirePcb->m_Layer = EDGE_N; + MirePcb->m_Width = g_DesignSettings.m_EdgeSegmentWidth; + MirePcb->m_Size = MireDefaultSize; + MirePcb->m_Pos = GetScreen()->m_Curseur ; + + Place_Mire(MirePcb, DC); + + return MirePcb; +} + + +/**********************************************************************/ +void WinEDA_PcbFrame::StartMove_Mire(MIREPCB * MirePcb, wxDC * DC) +/**********************************************************************/ +/* Routine d'initialisation du deplacement d'une mire +*/ +{ + if(MirePcb == NULL ) return; + + OldPos = MirePcb->m_Pos; + MirePcb->m_Flags |= IS_MOVED; + DrawPanel->ManageCurseur = Montre_Position_Mire; + DrawPanel->ForceCloseManageCurseur = Exit_EditMire; + GetScreen()->m_CurrentItem = MirePcb; +} + + +/**************************************************************/ +void WinEDA_PcbFrame::Place_Mire(MIREPCB * MirePcb, wxDC * DC) +/**************************************************************/ +{ + if( MirePcb == NULL ) return ; + + MirePcb->Draw(DrawPanel, DC, wxPoint(0,0),GR_OR); + + MirePcb->m_Flags = 0; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->m_CurrentItem = NULL; + GetScreen()->SetModify(); +} + + +/******************************************************************************/ +static void Montre_Position_Mire(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/*********************************************************************************/ +/* redessin du contour de la piste lors des deplacements de la souris */ +{ +BASE_SCREEN * screen = panel->GetScreen(); +MIREPCB * MirePcb = (MIREPCB *) screen->m_CurrentItem; + + if(MirePcb == NULL ) return ; + + /* efface ancienne position */ + if ( erase ) MirePcb->Draw(panel, DC, wxPoint(0,0),GR_XOR); + + MirePcb->m_Pos = screen->m_Curseur; + + // Reaffichage + MirePcb->Draw(panel, DC, wxPoint(0,0),GR_XOR); +} + diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp new file mode 100644 index 0000000000..fb00a9dae1 --- /dev/null +++ b/pcbnew/modedit.cpp @@ -0,0 +1,627 @@ + /****************/ + /* modedit.cpp */ + /****************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" +#include "common.h" + +#include "pcbnew.h" +#include "trigo.h" +#include "3d_viewer.h" + +#include "bitmaps.h" +#include "protos.h" +#include "id.h" + + +/*********************************************************************/ +EDA_BaseStruct * WinEDA_ModuleEditFrame::ModeditLocateAndDisplay(void) +/*********************************************************************/ +{ +EDA_BaseStruct * DrawStruct = GetScreen()->m_CurrentItem; +MODULE * Module = m_Pcb->m_Modules; + + if ( Module == NULL ) return NULL; + + DrawStruct = Locate_Edge_Module(Module, CURSEUR_OFF_GRILLE); + if ( DrawStruct ) + { + Affiche_Infos_Segment_Module(this, Module,(EDGE_MODULE*) DrawStruct); + } + else DrawStruct = Locate( CURSEUR_OFF_GRILLE ); + + return DrawStruct; +} + + +/****************************************************************************/ +void WinEDA_ModuleEditFrame::Process_Special_Functions(wxCommandEvent& event) +/****************************************************************************/ +/* Traite les selections d'outils et les commandes appelees du menu POPUP +*/ +{ +int id = event.GetId(); +wxPoint pos; +wxClientDC dc(DrawPanel); + + DrawPanel->CursorOff(&dc); + DrawPanel->PrepareGraphicContext(&dc); + + wxGetMousePosition(&pos.x, &pos.y); + + pos.y += 20; + + switch ( id ) // Arret eventuel de la commande de déplacement en cours + { + case wxID_CUT: + case wxID_COPY: + case ID_TOOLBARH_PCB_SELECT_LAYER: + case ID_MODEDIT_PAD_SETTINGS: + case ID_PCB_USER_GRID_SETUP: + case ID_POPUP_PCB_ROTATE_TEXTEPCB: + case ID_POPUP_PCB_EDIT_TEXTEPCB: + case ID_POPUP_PCB_ROTATE_TEXTMODULE: + case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE: + case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE: + case ID_POPUP_PCB_EDIT_TEXTMODULE: + case ID_POPUP_PCB_IMPORT_PAD_SETTINGS: + case ID_POPUP_PCB_EXPORT_PAD_SETTINGS: + case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS: + case ID_POPUP_PCB_STOP_CURRENT_DRAWING: + case ID_POPUP_PCB_EDIT_EDGE: + case ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE: + case ID_POPUP_PCB_EDIT_WIDTH_ALL_EDGE: + case ID_POPUP_PCB_EDIT_LAYER_CURRENT_EDGE: + case ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE: + case ID_POPUP_PCB_ENTER_EDGE_WIDTH: + case ID_POPUP_DELETE_BLOCK: + case ID_POPUP_PLACE_BLOCK: + case ID_POPUP_ZOOM_BLOCK: + case ID_POPUP_MIRROR_Y_BLOCK: + case ID_POPUP_MIRROR_X_BLOCK: + case ID_POPUP_ROTATE_BLOCK: + case ID_POPUP_COPY_BLOCK: + break; + + case ID_POPUP_CANCEL_CURRENT_COMMAND: + if( DrawPanel->ManageCurseur && + DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + break; + + default: // Arret dea commande de déplacement en cours + if( DrawPanel->ManageCurseur && + DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + break; + } + + switch ( id ) // Traitement des commandes + { + case ID_EXIT : + Close(TRUE); + break; + + case ID_LIBEDIT_SELECT_CURRENT_LIB: + Select_Active_Library(); + break; + + case ID_LIBEDIT_DELETE_PART: + { + wxString Line; + Line = MakeFileName(g_RealLibDirBuffer, m_CurrentLib, LibExtBuffer); + Delete_Module_In_Library(Line); + } + break; + + case ID_MODEDIT_NEW_MODULE: + Clear_Pcb(&dc, TRUE); + GetScreen()->ClearUndoRedoList(); + GetScreen()->m_CurrentItem = NULL; + GetScreen()->m_Curseur = wxPoint(0,0); + Create_1_Module(& dc, wxEmptyString); + if ( m_Pcb->m_Modules ) m_Pcb->m_Modules->m_Flags = 0; + Zoom_Automatique(TRUE); + break; + + case ID_MODEDIT_SAVE_LIBMODULE: + { + wxString Line; + Line = MakeFileName(g_RealLibDirBuffer, m_CurrentLib.GetData(), LibExtBuffer); + Save_1_Module(Line, m_Pcb->m_Modules, TRUE, TRUE); + GetScreen()->ClrModify(); + } + break; + + case ID_MODEDIT_LOAD_MODULE_FROM_BOARD: + GetScreen()->ClearUndoRedoList(); + Load_Module_Module_From_BOARD(NULL); + GetScreen()->ClrModify(); + if ( m_Draw3DFrame ) + m_Draw3DFrame->NewDisplay(); + break; + + case ID_MODEDIT_SAVE_MODULE_IN_BOARD: + { + WinEDA_PcbFrame * pcbframe = m_Parent->m_PcbFrame; + BOARD * mainpcb = pcbframe->m_Pcb; + MODULE * oldmodule = NULL; + MODULE * module_in_edit = m_Pcb->m_Modules; + // creation du nouveau module sur le PCB en cours + MODULE * newmodule = new MODULE(mainpcb); + newmodule->Copy(module_in_edit); + newmodule->m_Parent = mainpcb; // modifie par la copie + newmodule->m_Link = 0; + // Recherche de l'ancien module correspondant + //(qui a pu changer ou disparaitre a la suite d'éditions) + if ( module_in_edit->m_Link ) + { + oldmodule = mainpcb->m_Modules; + for( ; oldmodule != NULL ; oldmodule = (MODULE *) oldmodule->Pnext ) + { + if( module_in_edit->m_Link == oldmodule->m_TimeStamp ) + break; + } + } + + // Placement du module dans la liste des modules du PCB. + newmodule->Pnext = mainpcb->m_Modules; + mainpcb->m_Modules = newmodule; + newmodule->Pback = mainpcb; + if ( newmodule->Pnext ) newmodule->Pnext->Pback = newmodule; + + if ( oldmodule ) + { + newmodule = pcbframe->Exchange_Module(this, + oldmodule, newmodule); + newmodule->m_TimeStamp = module_in_edit->m_Link; + } + else + { + pcbframe->Place_Module(newmodule, NULL); + newmodule->m_TimeStamp = GetTimeStamp(); + } + + newmodule->m_Flags = 0; + GetScreen()->ClrModify(); + pcbframe->GetScreen()->m_CurrentItem = NULL; + mainpcb->m_Status_Pcb = 0; + } + break; + + case ID_LIBEDIT_IMPORT_PART: + GetScreen()->ClearUndoRedoList(); + GetScreen()->m_CurrentItem = NULL; + Clear_Pcb(&dc, TRUE); + GetScreen()->m_Curseur = wxPoint(0,0); + Import_Module(&dc); + if ( m_Pcb->m_Modules ) m_Pcb->m_Modules->m_Flags = 0; + GetScreen()->ClrModify(); + Zoom_Automatique(TRUE); + if ( m_Draw3DFrame ) + m_Draw3DFrame->NewDisplay(); + break; + + case ID_LIBEDIT_EXPORT_PART: + if ( m_Pcb->m_Modules ) + Export_Module(m_Pcb->m_Modules, FALSE); + break; + + case ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART: + if ( m_Pcb->m_Modules ) + Export_Module(m_Pcb->m_Modules, TRUE); + break; + + case ID_MODEDIT_SHEET_SET: + break; + + case ID_MODEDIT_LOAD_MODULE: + GetScreen()->ClearUndoRedoList(); + GetScreen()->m_CurrentItem = NULL; + Clear_Pcb(&dc, TRUE); + GetScreen()->m_Curseur = wxPoint(0,0); + Load_Module_From_Library(m_CurrentLib, &dc); + if ( m_Pcb->m_Modules ) m_Pcb->m_Modules->m_Flags = 0; + GetScreen()->ClrModify(); + Zoom_Automatique(TRUE); + if ( m_Draw3DFrame ) + m_Draw3DFrame->NewDisplay(); + break; + + + case ID_MODEDIT_PAD_SETTINGS: + InstallPadOptionsFrame(NULL, NULL, wxPoint(-1, -1) ); + break; + + case ID_MODEDIT_CHECK: + break; + + case ID_MODEDIT_EDIT_MODULE_PROPERTIES: + if ( m_Pcb->m_Modules ) + { + GetScreen()->m_CurrentItem = m_Pcb->m_Modules; + InstallModuleOptionsFrame((MODULE *)GetScreen()->m_CurrentItem, + &dc, pos); + GetScreen()->m_CurrentItem->m_Flags = 0; + } + break; + + case ID_MODEDIT_ADD_PAD: + if ( m_Pcb->m_Modules ) + SetToolID( id, wxCURSOR_PENCIL, _("Add Pad")); + else + { + SetToolID( id, wxCURSOR_ARROW, _("Pad Settings")); + InstallPadOptionsFrame(NULL, NULL, wxPoint(-1, -1) ); + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + } + break; + + case ID_LINE_COMMENT_BUTT: + case ID_PCB_ARC_BUTT: + case ID_PCB_CIRCLE_BUTT: + case ID_TEXT_COMMENT_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _("Add Drawing")); + break; + + case ID_MODEDIT_PLACE_ANCHOR: + SetToolID( id, wxCURSOR_PENCIL, _("Place anchor")); + break; + + case ID_NO_SELECT_BUTT: + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + break; + + case ID_POPUP_CLOSE_CURRENT_TOOL: + break; + + case ID_POPUP_CANCEL_CURRENT_COMMAND: + break; + + case ID_MODEDIT_DELETE_ITEM_BUTT: + SetToolID( id, wxCURSOR_BULLSEYE, _("Delete item")); + break; + + case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE: + DrawPanel->MouseToCursorSchema(); + Rotate_Module(&dc, (MODULE*)GetScreen()->m_CurrentItem, 900, TRUE); + break; + + case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE: + DrawPanel->MouseToCursorSchema(); + Rotate_Module(&dc, (MODULE*)GetScreen()->m_CurrentItem, -900, TRUE); + break; + + case ID_POPUP_PCB_EDIT_MODULE: + InstallModuleOptionsFrame((MODULE *)GetScreen()->m_CurrentItem, + &dc, pos); + GetScreen()->m_CurrentItem->m_Flags = 0; + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_MOVE_PAD_REQUEST: + DrawPanel->MouseToCursorSchema(); + StartMovePad((D_PAD *)GetScreen()->m_CurrentItem, &dc); + break; + + case ID_POPUP_PCB_EDIT_PAD: + InstallPadOptionsFrame((D_PAD *)GetScreen()->m_CurrentItem, + &dc, pos); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_DELETE_PAD: + SaveCopyInUndoList(m_Pcb->m_Modules); + DeletePad((D_PAD *)GetScreen()->m_CurrentItem, &dc); + GetScreen()->m_CurrentItem = NULL; + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_IMPORT_PAD_SETTINGS: + SaveCopyInUndoList(m_Pcb->m_Modules); + DrawPanel->MouseToCursorSchema(); + Import_Pad_Settings((D_PAD *)GetScreen()->m_CurrentItem, &dc); + break; + + case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS: + SaveCopyInUndoList(m_Pcb->m_Modules); + Global_Import_Pad_Settings((D_PAD *)GetScreen()->m_CurrentItem, &dc); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_EXPORT_PAD_SETTINGS: + DrawPanel->MouseToCursorSchema(); + Export_Pad_Settings((D_PAD *)GetScreen()->m_CurrentItem); + break; + + case ID_POPUP_PCB_EDIT_TEXTMODULE: + InstallTextModOptionsFrame((TEXTE_MODULE *)GetScreen()->m_CurrentItem, + &dc, pos); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST: + DrawPanel->MouseToCursorSchema(); + StartMoveTexteModule( (TEXTE_MODULE *) GetScreen()->m_CurrentItem, + &dc); + break; + + case ID_POPUP_PCB_ROTATE_TEXTMODULE: + RotateTextModule((TEXTE_MODULE *)GetScreen()->m_CurrentItem, + &dc); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_DELETE_TEXTMODULE: + SaveCopyInUndoList(m_Pcb->m_Modules); + DeleteTextModule((TEXTE_MODULE *)GetScreen()->m_CurrentItem, + &dc); + GetScreen()->m_CurrentItem = NULL; + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_MOVE_EDGE: + Start_Move_EdgeMod((EDGE_MODULE *)GetScreen()->m_CurrentItem, &dc); + DrawPanel->MouseToCursorSchema(); + break; + + case ID_POPUP_PCB_STOP_CURRENT_DRAWING: + DrawPanel->MouseToCursorSchema(); + if ( (GetScreen()->m_CurrentItem->m_Flags & IS_NEW) ) + { + End_Edge_Module((EDGE_MODULE *) GetScreen()->m_CurrentItem, &dc); + GetScreen()->m_CurrentItem = NULL; + } + break; + + case ID_POPUP_PCB_ENTER_EDGE_WIDTH: + { + EDGE_MODULE * edge = NULL; + if ( GetScreen()->m_CurrentItem && + ( GetScreen()->m_CurrentItem->m_Flags & IS_NEW) && + (GetScreen()->m_CurrentItem->m_StructType == TYPEEDGEMODULE) ) + { + edge = (EDGE_MODULE *) GetScreen()->m_CurrentItem; + } + Enter_Edge_Width(edge, &dc); + DrawPanel->MouseToCursorSchema(); + } + break; + + case ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE: + DrawPanel->MouseToCursorSchema(); + Edit_Edge_Width((EDGE_MODULE *) GetScreen()->m_CurrentItem, &dc); + break; + + case ID_POPUP_PCB_EDIT_WIDTH_ALL_EDGE: + DrawPanel->MouseToCursorSchema(); + Edit_Edge_Width(NULL, &dc); + break; + + case ID_POPUP_PCB_EDIT_LAYER_CURRENT_EDGE: + DrawPanel->MouseToCursorSchema(); + Edit_Edge_Layer((EDGE_MODULE *) GetScreen()->m_CurrentItem, &dc); + break; + + case ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE: + DrawPanel->MouseToCursorSchema(); + Edit_Edge_Layer(NULL, &dc); + break; + + case ID_POPUP_PCB_DELETE_EDGE: + SaveCopyInUndoList(m_Pcb->m_Modules); + DrawPanel->MouseToCursorSchema(); + RemoveStruct(GetScreen()->m_CurrentItem, &dc); + GetScreen()->m_CurrentItem = NULL; + break; + + case ID_MODEDIT_MODULE_ROTATE: + case ID_MODEDIT_MODULE_MIRROR: + case ID_MODEDIT_MODULE_SCALE: + case ID_MODEDIT_MODULE_SCALEX: + case ID_MODEDIT_MODULE_SCALEY: + SaveCopyInUndoList(m_Pcb->m_Modules); + Transform( (MODULE*) GetScreen()->m_CurrentItem, &dc, id); + break; + + case ID_PCB_DRAWINGS_WIDTHS_SETUP: + InstallOptionsFrame(pos); + break; + + case ID_PCB_PAD_SETUP: + InstallPadOptionsFrame((D_PAD *)GetScreen()->m_CurrentItem, + &dc, pos); + break; + + case ID_PCB_USER_GRID_SETUP: + InstallGridFrame(pos); + break; + + case ID_MODEDIT_UNDO: + GetComponentFromUndoList(); + DrawPanel->Refresh(TRUE); + break; + + case ID_MODEDIT_REDO: + GetComponentFromRedoList(); + DrawPanel->Refresh(TRUE); + break; + + case ID_POPUP_PLACE_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_MOVE; + DrawPanel->m_AutoPAN_Request = FALSE; + HandleBlockPlace(&dc); + break; + + case ID_POPUP_COPY_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_COPY; + m_CurrentScreen->BlockLocate.SetMessageBlock(this); + DrawPanel->m_AutoPAN_Request = FALSE; + HandleBlockPlace(&dc); + break; + + case ID_POPUP_ZOOM_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_ZOOM; + m_CurrentScreen->BlockLocate.SetMessageBlock(this); + m_CurrentScreen->BlockLocate.SetMessageBlock(this); + HandleBlockEnd(&dc); + break; + + case ID_POPUP_DELETE_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_DELETE; + m_CurrentScreen->BlockLocate.SetMessageBlock(this); + HandleBlockEnd(&dc); + break; + + case ID_POPUP_ROTATE_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_ROTATE; + m_CurrentScreen->BlockLocate.SetMessageBlock(this); + HandleBlockEnd(&dc); + break; + + case ID_POPUP_MIRROR_X_BLOCK: + case ID_POPUP_MIRROR_Y_BLOCK: + case ID_POPUP_INVERT_BLOCK: + GetScreen()->BlockLocate.m_Command = BLOCK_INVERT; + m_CurrentScreen->BlockLocate.SetMessageBlock(this); + HandleBlockEnd(&dc); + break; + default: + DisplayError(this, + wxT("WinEDA_ModuleEditFrame::Process_Special_Functions error")); + break; + } + + SetToolbars(); + DrawPanel->CursorOn(&dc); +} + + +/******************************************************************************/ +void WinEDA_ModuleEditFrame::Transform(MODULE* module, wxDC * DC, int transform) +/******************************************************************************/ +/* Execute les transformations de la représentation des modules. + le module, apres transformation est toujours en position de reference: + position 0,0 + orientation 0, coté composant. +*/ +{ +D_PAD * pad = module->m_Pads; +EDA_BaseStruct * PtStruct = module->m_Drawings; +TEXTE_MODULE * textmod; +EDGE_MODULE* edgemod; +int angle = 900; // NECESSAIREMENT +- 900 (+- 90 degres) ) + + switch ( transform ) + { + case ID_MODEDIT_MODULE_ROTATE: + module->SetOrientation(angle); + + for (; pad != NULL; pad = (D_PAD*) pad->Pnext ) + { + pad->m_Pos0 = pad->m_Pos; + pad->m_Orient -= angle; + RotatePoint(&pad->m_Offset.x, &pad->m_Offset.y, angle); + EXCHG(pad->m_Size.x, pad->m_Size.y); + RotatePoint(&pad->m_DeltaSize.x, &pad->m_DeltaSize.y, - angle); + } + + module->m_Reference->m_Pos0 = module->m_Reference->m_Pos; + module->m_Reference->m_Orient += angle; + if ( module->m_Reference->m_Orient >= 1800 ) + module->m_Reference->m_Orient -= 1800; + module->m_Value->m_Pos0 = module->m_Value->m_Pos; + module->m_Value->m_Orient += angle; + if ( module->m_Value->m_Orient >= 1800 ) + module->m_Value->m_Orient -= 1800; + + /* Rectification des contours et textes de l'empreinte : */ + for(; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if( PtStruct->m_StructType == TYPEEDGEMODULE ) + { + edgemod = (EDGE_MODULE*) PtStruct ; + edgemod->m_Start0 = edgemod->m_Start; + edgemod->m_End0 = edgemod->m_End; + } + if( PtStruct->m_StructType == TYPETEXTEMODULE ) + { + /* deplacement des inscriptions : */ + textmod = (TEXTE_MODULE*) PtStruct; + textmod->m_Pos0 = textmod->m_Pos; + } + } + + module->m_Orient = 0; + break; + + case ID_MODEDIT_MODULE_MIRROR: + for ( ; pad != NULL; pad = (D_PAD*) pad->Pnext ) + { + pad->m_Pos.y = -pad->m_Pos.y; + pad->m_Pos0.y = -pad->m_Pos0.y; + pad->m_Offset.y = -pad->m_Offset.y; + pad->m_DeltaSize.y = -pad->m_DeltaSize.y; + if(pad->m_Orient) pad->m_Orient = 3600 - pad->m_Orient; + } + + /* Inversion miroir de la Reference */ + textmod = module->m_Reference; + textmod->m_Pos.y = -textmod->m_Pos.y; + textmod->m_Pos0.y = textmod->m_Pos0.y; + if(textmod->m_Orient) textmod->m_Orient = 3600 - textmod->m_Orient; + + /* Inversion miroir de la Valeur */ + textmod = module->m_Value; + textmod->m_Pos.y = -textmod->m_Pos.y; + textmod->m_Pos0.y = textmod->m_Pos0.y; + if(textmod->m_Orient) textmod->m_Orient = 3600 - textmod->m_Orient; + + /* Inversion miroir des dessins de l'empreinte : */ + PtStruct = module->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext) + { + switch( PtStruct->m_StructType) + { + case TYPEEDGEMODULE: + edgemod = (EDGE_MODULE *) PtStruct; + edgemod->m_Start.y = -edgemod->m_Start.y ; + edgemod->m_End.y = -edgemod->m_End.y; + /* inversion des coords locales */ + edgemod->m_Start0.y = -edgemod->m_Start0.y; + edgemod->m_End0.y = -edgemod->m_End0.y; + break; + + case TYPETEXTEMODULE: + /* Inversion miroir de la position et mise en miroir : */ + textmod = (TEXTE_MODULE*)PtStruct; + textmod->m_Pos.y = -textmod->m_Pos.y; + textmod->m_Pos0.y = textmod->m_Pos0.y; + if(textmod->m_Orient) + textmod->m_Orient = 3600 - textmod->m_Orient; + break; + + default: DisplayError(this, wxT("Type Draw Indefini")); + break; + } + } + break; + + case ID_MODEDIT_MODULE_SCALE: + case ID_MODEDIT_MODULE_SCALEX: + case ID_MODEDIT_MODULE_SCALEY: + DisplayInfo(this, wxT("Not availlable")); + break; + } + module->Set_Rectangle_Encadrement(); + DrawPanel->ReDraw(DC); +} diff --git a/pcbnew/modedit_onclick.cpp b/pcbnew/modedit_onclick.cpp new file mode 100644 index 0000000000..ba6f746b99 --- /dev/null +++ b/pcbnew/modedit_onclick.cpp @@ -0,0 +1,432 @@ + /************************/ + /* modedit_onclick.cpp */ + /************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" +#include "common.h" + +#include "pcbnew.h" + +#include "bitmaps.h" +#include "protos.h" +#include "id.h" + +#include "Edit_Module.xpm" +#include "Rotate_Module+.xpm" +#include "Move_Field.xpm" +#include "Rotate_Field.xpm" +#include "Move_Pad.xpm" +#include "Global_Options_Pad.xpm" +#include "Delete_Pad.xpm" +#include "Export_Options_Pad.xpm" +#include "Width_Segment.xpm" +#include "Select_Layer_Pair.xpm" + +/*************************************************************************/ +void WinEDA_ModuleEditFrame::OnLeftClick(wxDC * DC, const wxPoint& MousePos) +/*************************************************************************/ +/* Traite les commandes declenchée par le bouton gauche de la souris, + quand un outil est deja selectionné +*/ +{ +EDA_BaseStruct * DrawStruct = m_CurrentScreen->m_CurrentItem; + + DrawPanel->CursorOff(DC); + if ( m_ID_current_state == 0 ) + { + if ( DrawStruct && DrawStruct->m_Flags ) // Commande "POPUP" en cours + { + switch (DrawStruct->m_StructType ) + { + case TYPETEXTEMODULE: + SaveCopyInUndoList(m_Pcb->m_Modules); + PlaceTexteModule( (TEXTE_MODULE *) DrawStruct, DC); + break; + + case TYPEEDGEMODULE: + SaveCopyInUndoList(m_Pcb->m_Modules); + Place_EdgeMod( (EDGE_MODULE *) DrawStruct, DC); + break; + + case TYPEPAD: + PlacePad((D_PAD *)DrawStruct, DC); + break; + + default: + { + wxString msg; + msg.Printf( +wxT("WinEDA_ModEditFrame::ProcessCommand err: m_Flags != 0\nStruct @%p, type %d m_Flag %X") +, DrawStruct, DrawStruct->m_StructType, DrawStruct->m_Flags); + DisplayError(this, msg); + DrawStruct->m_Flags = 0; + break; + } + } + } + } + + DrawStruct = m_CurrentScreen->m_CurrentItem; + if ( ! DrawStruct || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->m_CurrentItem = DrawStruct = ModeditLocateAndDisplay(); + } + + switch ( m_ID_current_state ) + { + case 0: + break; + + case ID_NO_SELECT_BUTT: + break; + + case ID_PCB_CIRCLE_BUTT: + case ID_PCB_ARC_BUTT: + case ID_LINE_COMMENT_BUTT: + if ( ! DrawStruct || DrawStruct->m_Flags == 0) + { + int shape = S_SEGMENT; + if ( m_ID_current_state == ID_PCB_CIRCLE_BUTT) shape = S_CIRCLE; + if ( m_ID_current_state == ID_PCB_ARC_BUTT) shape = S_ARC; + + m_CurrentScreen->m_CurrentItem = + Begin_Edge_Module((EDGE_MODULE *) NULL, DC, shape); + } + + else if ( (DrawStruct->m_Flags & IS_NEW) ) + { + if ( ((EDGE_MODULE*)DrawStruct)->m_Shape == S_CIRCLE ) + { + End_Edge_Module((EDGE_MODULE *) DrawStruct, DC); + m_CurrentScreen->m_CurrentItem = NULL; + } + else if ( ((EDGE_MODULE*)DrawStruct)->m_Shape == S_ARC ) + { + End_Edge_Module((EDGE_MODULE *) DrawStruct, DC); + m_CurrentScreen->m_CurrentItem = NULL; + } + else if ( ((EDGE_MODULE*)DrawStruct)->m_Shape == S_SEGMENT ) + { + m_CurrentScreen->m_CurrentItem = + Begin_Edge_Module((EDGE_MODULE *) DrawStruct, DC, 0); + } + else DisplayError(this, wxT("ProcessCommand error: DrawStruct/ flags error")); + } + break; + + case ID_MODEDIT_DELETE_ITEM_BUTT: + if ( !DrawStruct || (DrawStruct->m_Flags == 0) ) + { + DrawStruct = ModeditLocateAndDisplay(); + if ( DrawStruct && (DrawStruct->m_Flags == 0) ) + { + SaveCopyInUndoList(m_Pcb->m_Modules); + RemoveStruct(DrawStruct, DC); + m_CurrentScreen->m_CurrentItem = DrawStruct = NULL; + } + } + break; + + case ID_MODEDIT_PLACE_ANCHOR: + SaveCopyInUndoList(m_Pcb->m_Modules); + Place_Ancre(m_Pcb->m_Modules, DC); + m_Pcb->m_Modules->m_Flags = 0; + m_CurrentScreen->m_Curseur = wxPoint(0,0); + Recadre_Trace(TRUE); + Place_Module(m_Pcb->m_Modules, DC); + RedrawActiveWindow(DC, TRUE); + SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); + m_CurrentScreen->m_CurrentItem = NULL; + break; + + case ID_TEXT_COMMENT_BUTT: + SaveCopyInUndoList(m_Pcb->m_Modules); + CreateTextModule(m_Pcb->m_Modules, DC); + break; + + case ID_MODEDIT_ADD_PAD: + if ( m_Pcb->m_Modules ) + { + SaveCopyInUndoList(m_Pcb->m_Modules); + AddPad(m_Pcb->m_Modules, DC); + } + break; + + default : + DrawPanel->SetCursor(wxCURSOR_ARROW); + DisplayError(this, wxT("WinEDA_ModuleEditFrame::ProcessCommand error")); + m_ID_current_state = 0; + break; + } + DrawPanel->CursorOn(DC); +} + + +/*********************************************************************/ +void WinEDA_ModuleEditFrame::OnRightClick(const wxPoint& MousePos, + wxMenu * PopMenu) +/*********************************************************************/ +/* Prepare le menu PullUp affiché par un click sur le bouton droit +de la souris. + Ce menu est ensuite complété par la liste des commandes de ZOOM +*/ +{ +EDA_BaseStruct *DrawStruct = m_CurrentScreen->m_CurrentItem; +wxString msg; +bool append_set_width = FALSE; +bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE); + + // Simple localisation des elements si possible + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + m_CurrentScreen->m_CurrentItem = DrawStruct = ModeditLocateAndDisplay(); + } + + // Si commande en cours: affichage fin de commande + if ( m_ID_current_state ) + { + if ( DrawStruct && DrawStruct->m_Flags ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, + _("Cancel"), cancel_xpm); + } + else + ADD_MENUITEM(PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL, + _("End Tool"), cancel_tool_xpm ); + PopMenu->AppendSeparator(); + } + + else + { + if ( (DrawStruct && DrawStruct->m_Flags) || BlockActive ) + { + if ( BlockActive ) // Put block commnands in list + { + ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, + _("Cancel Block"), cancel_xpm ); + ADD_MENUITEM(PopMenu, ID_POPUP_ZOOM_BLOCK, + _("Zoom Block (Midd butt drag)"), zoom_selected_xpm ); + PopMenu->AppendSeparator(); + ADD_MENUITEM(PopMenu, ID_POPUP_PLACE_BLOCK, + _("Place Block"), apply_xpm ); + ADD_MENUITEM(PopMenu, ID_POPUP_COPY_BLOCK, + _("Copy Block (shift + drag mouse)"), copyblock_xpm ); + ADD_MENUITEM(PopMenu, ID_POPUP_MIRROR_X_BLOCK, + _("Mirror Block (alt + drag mouse)"), mirror_H_xpm ); + ADD_MENUITEM(PopMenu, ID_POPUP_ROTATE_BLOCK, + _("Rotate Block (ctrl + drag mouse)"), rotate_pos_xpm ); + ADD_MENUITEM(PopMenu, ID_POPUP_DELETE_BLOCK, + _("Delete Block (shift+ctrl + drag mouse)"), delete_xpm ); + } + else + { + ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, + _("Cancel"), cancel_xpm); + } + PopMenu->AppendSeparator(); + } + } + + if ( DrawStruct == NULL ) return; + +int flags = DrawStruct->m_Flags; + + switch ( DrawStruct->m_StructType ) + { + case TYPEMODULE: + { + wxMenu * transform_choice = new wxMenu; + ADD_MENUITEM(transform_choice, ID_MODEDIT_MODULE_ROTATE, + _("Rotate"), rotate_module_pos_xpm); + ADD_MENUITEM(transform_choice, ID_MODEDIT_MODULE_MIRROR, + _("Mirror"), mirror_H_xpm); +#if 0 + transform_choice->Append(ID_MODEDIT_MODULE_SCALE, _("Scale")); + transform_choice->Append(ID_MODEDIT_MODULE_SCALE, _("Scale X")); + transform_choice->Append(ID_MODEDIT_MODULE_SCALE, _("Scale Y")); +#endif + ADD_MENUITEM(PopMenu,ID_POPUP_PCB_EDIT_MODULE, + _("Edit Module"), Edit_Module_xpm); + ADD_MENUITEM_WITH_SUBMENU(PopMenu, transform_choice, + ID_MODEDIT_TRANSFORM_MODULE, + _("Transform Module"), edit_xpm); + break; + } + + case TYPEPAD: + if( !flags ) + { + ADD_MENUITEM(PopMenu,ID_POPUP_PCB_MOVE_PAD_REQUEST, + _("Move Pad"), move_pad_xpm); + } + ADD_MENUITEM(PopMenu,ID_POPUP_PCB_EDIT_PAD, _("Edit Pad"), options_pad_xpm); + ADD_MENUITEM(PopMenu,ID_POPUP_PCB_IMPORT_PAD_SETTINGS, + _("New Pad Settings"), options_new_pad_xpm); + ADD_MENUITEM(PopMenu,ID_POPUP_PCB_EXPORT_PAD_SETTINGS, + _("Export Pad Settings"), Export_Options_Pad_xpm); + ADD_MENUITEM(PopMenu,ID_POPUP_PCB_DELETE_PAD, + _("delete Pad"), Delete_Pad_xpm); + if( !flags ) + { + PopMenu->AppendSeparator(); + ADD_MENUITEM(PopMenu,ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS, + _("Global Pad Settings"), global_options_pad_xpm); + } + break; + + case TYPETEXTEMODULE: + if( !flags ) + { + ADD_MENUITEM(PopMenu,ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST, + _("Move Text Mod."), Move_Field_xpm ); + } + ADD_MENUITEM(PopMenu,ID_POPUP_PCB_ROTATE_TEXTMODULE, + _("Rotate Text Mod."), Rotate_Field_xpm); + ADD_MENUITEM(PopMenu,ID_POPUP_PCB_EDIT_TEXTMODULE, + _("Edit Text Mod."), edit_text_xpm); + if ( ((TEXTE_MODULE*)DrawStruct)->m_Type == TEXT_is_DIVERS) + ADD_MENUITEM(PopMenu,ID_POPUP_PCB_DELETE_TEXTMODULE, + _("Delete Text Mod."), delete_text_xpm); + break; + + case TYPEEDGEMODULE: + { + if( (flags & IS_NEW) ) + ADD_MENUITEM(PopMenu,ID_POPUP_PCB_STOP_CURRENT_DRAWING, + _("End edge"), apply_xpm); + if( !flags ) + ADD_MENUITEM(PopMenu,ID_POPUP_PCB_MOVE_EDGE, + _("Move edge"), move_line_xpm); + if( (flags & (IS_NEW|IS_MOVED)) == IS_MOVED) + ADD_MENUITEM(PopMenu,ID_POPUP_PCB_PLACE_EDGE, + _("Place edge"), apply_xpm); + wxMenu * edit_mnu = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU(PopMenu, edit_mnu, + ID_POPUP_PCB_EDIT_EDGE, _("Edit"), edit_xpm); + ADD_MENUITEM(edit_mnu, ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE, + _("Edit Width (Current)"), width_segment_xpm); + ADD_MENUITEM(edit_mnu, ID_POPUP_PCB_EDIT_WIDTH_ALL_EDGE, + _("Edit Width (All)"), width_segment_xpm); + ADD_MENUITEM(edit_mnu, ID_POPUP_PCB_EDIT_LAYER_CURRENT_EDGE, + _("Edit Layer (Current)"), select_layer_pair_xpm); + ADD_MENUITEM(edit_mnu, ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE, + _("Edit Layer (All)"), select_layer_pair_xpm); + ADD_MENUITEM(PopMenu,ID_POPUP_PCB_DELETE_EDGE, + _("Delete edge"), delete_xpm); + append_set_width = TRUE; + } + break; + + case TYPEDRAWSEGMENT: + case TYPETEXTE: + case TYPEVIA: + case TYPETRACK: + case TYPEZONE: + case TYPEMARQUEUR: + case TYPECOTATION: + case TYPEMIRE: + break; + + case TYPESCREEN: + case TYPE_NOT_INIT: + case TYPEPCB: + case PCB_EQUIPOT_STRUCT_TYPE: + msg.Printf( + wxT("WinEDA_ModuleEditFrame::OnRightClick Error: illegal DrawType %d"), + DrawStruct->m_StructType); + DisplayError(this, msg ); + break; + + default: + msg.Printf( + wxT("WinEDA_ModuleEditFrame::OnRightClick Error: unknown DrawType %d"), + DrawStruct->m_StructType); + DisplayError(this, msg ); + break; + } + PopMenu->AppendSeparator(); + + if ( append_set_width || + ( m_ID_current_state && ((m_ID_current_state == ID_LINE_COMMENT_BUTT) || + (m_ID_current_state == ID_PCB_CIRCLE_BUTT) || + (m_ID_current_state == ID_PCB_ARC_BUTT)) ) ) + { + ADD_MENUITEM(PopMenu,ID_POPUP_PCB_ENTER_EDGE_WIDTH, + _("Set Width"), width_segment_xpm); + PopMenu->AppendSeparator(); + } + +} + + +/****************************************************************************/ +void WinEDA_ModuleEditFrame::OnLeftDClick(wxDC * DC, const wxPoint& MousePos) +/****************************************************************************/ +/* Appelé sur un double click: + pour un élément editable (textes, composant): + appel de l'editeur correspondant. +*/ +{ +EDA_BaseStruct * DrawStruct = m_CurrentScreen->m_CurrentItem; +wxPoint pos = GetPosition(); +wxClientDC dc(DrawPanel); + + DrawPanel->PrepareGraphicContext(&dc); + + switch ( m_ID_current_state ) + { + case 0: + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + DrawStruct = PcbGeneralLocateAndDisplay(); + } + + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) ) + break; + + // Element localisé + m_CurrentScreen->m_CurrentItem = DrawStruct; + switch ( DrawStruct->m_StructType ) + { + case TYPEPAD: + InstallPadOptionsFrame( + (D_PAD *)DrawStruct, &dc, pos); + DrawPanel->MouseToCursorSchema(); + break; + + case TYPEMODULE: + InstallModuleOptionsFrame((MODULE *)DrawStruct, + &dc, pos); + DrawPanel->MouseToCursorSchema(); + break; + + case TYPETEXTEMODULE: + InstallTextModOptionsFrame((TEXTE_MODULE *)DrawStruct, + &dc, pos); + DrawPanel->MouseToCursorSchema(); + break; + + default: + break; + } + break; // end case 0 + + case ID_LINE_COMMENT_BUTT: + { + if ( DrawStruct && (DrawStruct->m_Flags & IS_NEW) ) + { + End_Edge_Module((EDGE_MODULE *) DrawStruct, DC); + m_CurrentScreen->m_CurrentItem = NULL; + } + break; + } + + default: + break; + } +} + diff --git a/pcbnew/modedit_undo_redo.cpp b/pcbnew/modedit_undo_redo.cpp new file mode 100644 index 0000000000..19e49776ca --- /dev/null +++ b/pcbnew/modedit_undo_redo.cpp @@ -0,0 +1,81 @@ + /********************************************/ + /* library editor: undo and redo functions */ + /********************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "id.h" + +#include "protos.h" + + +/**************************************************************************/ +void WinEDA_ModuleEditFrame::SaveCopyInUndoList(EDA_BaseStruct * ItemToCopy, + int unused_flag) +/************************************************************************/ +{ +EDA_BaseStruct * item; +MODULE * CopyItem; + + CopyItem = new MODULE(m_Pcb); + CopyItem->Copy((MODULE*)ItemToCopy); + CopyItem->m_Parent = m_Pcb; + + GetScreen()->AddItemToUndoList((EDA_BaseStruct *)CopyItem); + /* Clear current flags (which can be temporary set by a current edit command) */ + for ( item = CopyItem->m_Drawings; item != NULL; item = item->Pnext ) + item->m_Flags = 0; + + + /* Clear redo list, because after new save there is no redo to do */ + while ( GetScreen()->m_RedoList ) + { + item = GetScreen()->m_RedoList->Pnext; + delete GetScreen()->m_RedoList; + GetScreen()->m_RedoList = item; + } +} + +/*********************************************************/ +void WinEDA_ModuleEditFrame::GetComponentFromRedoList(void) +/*********************************************************/ +/* Redo the last edition: + - Place the current edited library component in undo list + - Get old version of the current edited library component +*/ +{ + if ( GetScreen()->m_RedoList == NULL ) return; + + GetScreen()->AddItemToUndoList(m_Pcb->m_Modules); + m_Pcb->m_Modules = + (MODULE *) GetScreen()->GetItemFromRedoList(); + if ( m_Pcb->m_Modules ) m_Pcb->m_Modules->Pnext = NULL; + GetScreen()->m_CurrentItem = NULL;; + GetScreen()->SetModify(); + ReCreateHToolbar(); + SetToolbars(); +} + +/*********************************************************/ +void WinEDA_ModuleEditFrame::GetComponentFromUndoList(void) +/*********************************************************/ +/* Undo the last edition: + - Place the current edited library component in Redo list + - Get old version of the current edited library component +*/ +{ + if ( GetScreen()->m_UndoList == NULL ) return; + + GetScreen()->AddItemToRedoList(m_Pcb->m_Modules); + m_Pcb->m_Modules = + (MODULE *) GetScreen()->GetItemFromUndoList(); + + if ( m_Pcb->m_Modules ) m_Pcb->m_Modules->Pnext = NULL; + GetScreen()->SetModify(); + GetScreen()->m_CurrentItem = NULL;; + ReCreateHToolbar(); + SetToolbars(); +} diff --git a/pcbnew/modeditoptions.cpp b/pcbnew/modeditoptions.cpp new file mode 100644 index 0000000000..48b09f99aa --- /dev/null +++ b/pcbnew/modeditoptions.cpp @@ -0,0 +1,88 @@ + /*******************************************************/ + /* PCBNEW - Gestion des Options et Reglages de modeedit*/ + /*******************************************************/ + + /* Fichier modeditoptions.cpp */ + +/* + Affichage et modifications des parametres de travail de Modedit +*/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "pcbplot.h" +#include "autorout.h" + +#include "id.h" + +#include "protos.h" + +/* Fonctions locales */ + +/* variables locales */ + + +/***********************************************************************/ +void WinEDA_ModuleEditFrame::OnSelectOptionToolbar(wxCommandEvent& event) +/***********************************************************************/ +{ +int id = event.GetId(); +wxClientDC dc(DrawPanel); + + DrawPanel->CursorOff( &dc); + DrawPanel->PrepareGraphicContext(&dc); + switch ( id ) + { + case ID_TB_OPTIONS_SHOW_GRID: + m_Draw_Grid = m_OptionsToolBar->GetToolState(id); + DrawPanel->ReDraw(&dc, TRUE); + break; + + case ID_TB_OPTIONS_SELECT_UNIT_MM: + g_UnitMetric = MILLIMETRE; + case ID_TB_OPTIONS_SELECT_UNIT_INCH: + if ( id == ID_TB_OPTIONS_SELECT_UNIT_INCH ) + g_UnitMetric = INCHES; + Affiche_Status_Box(); /* Reaffichage des coord curseur */ + ReCreateAuxiliaryToolbar(); + break; + + case ID_TB_OPTIONS_SHOW_POLAR_COORD: + Affiche_Message(wxEmptyString); + DisplayOpt.DisplayPolarCood = m_OptionsToolBar->GetToolState(id); + Affiche_Status_Box(); /* Reaffichage des coord curseur */ + break; + + case ID_TB_OPTIONS_SELECT_CURSOR: + g_CursorShape = m_OptionsToolBar->GetToolState(id); + break; + + case ID_TB_OPTIONS_SHOW_PADS_SKETCH: + m_DisplayPadFill = ! m_OptionsToolBar->GetToolState(id); + DrawPanel->ReDraw(&dc, TRUE); + break; + + case ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH: + m_DisplayModText = + m_OptionsToolBar->GetToolState(id) ? SKETCH : FILLED; + DrawPanel->ReDraw(&dc, TRUE); + break; + + case ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH: + m_DisplayModEdge = + m_OptionsToolBar->GetToolState(id) ? SKETCH : FILLED; + DrawPanel->ReDraw(&dc, TRUE); + break; + + default: + DisplayError(this, wxT("WinEDA_ModuleEditFrame::OnSelectOptionToolbar error") ); + break; + } + + SetToolbars(); + DrawPanel->CursorOn(&dc); +} + diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp new file mode 100644 index 0000000000..b15899e58e --- /dev/null +++ b/pcbnew/moduleframe.cpp @@ -0,0 +1,298 @@ +/***************************************************************************/ +/* moduleframe.cpp - fonctions de base de la classe WinEDA_ModuleEditFrame */ +/***************************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" +#include "common.h" + +#include "pcbnew.h" + +#include "bitmaps.h" +#include "protos.h" +#include "id.h" + + /********************************/ + /* class WinEDA_ModuleEditFrame */ + /********************************/ +BEGIN_EVENT_TABLE(WinEDA_ModuleEditFrame, wxFrame) + COMMON_EVENTS_DRAWFRAME + + EVT_CLOSE(WinEDA_ModuleEditFrame::OnCloseWindow) + EVT_SIZE(WinEDA_ModuleEditFrame::OnSize) + + EVT_KICAD_CHOICEBOX(ID_ON_ZOOM_SELECT,WinEDA_PcbFrame::OnSelectZoom) + EVT_KICAD_CHOICEBOX(ID_ON_GRID_SELECT,WinEDA_PcbFrame::OnSelectGrid) + + EVT_TOOL_RANGE(ID_ZOOM_PLUS_BUTT, ID_ZOOM_PAGE_BUTT, + WinEDA_ModuleEditFrame::Process_Zoom) + + EVT_TOOL(ID_LIBEDIT_SELECT_CURRENT_LIB, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_MODEDIT_SAVE_LIBMODULE, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_LIBEDIT_DELETE_PART, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_MODEDIT_NEW_MODULE, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_MODEDIT_LOAD_MODULE, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_LIBEDIT_IMPORT_PART, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_LIBEDIT_EXPORT_PART, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_MODEDIT_SHEET_SET, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_GEN_PRINT, WinEDA_DrawFrame::ToPrinter) + EVT_TOOL(ID_MODEDIT_LOAD_MODULE, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_MODEDIT_CHECK, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_MODEDIT_PAD_SETTINGS, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_MODEDIT_LOAD_MODULE_FROM_BOARD, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_MODEDIT_SAVE_MODULE_IN_BOARD, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_MODEDIT_EDIT_MODULE_PROPERTIES, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_MODEDIT_UNDO, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_MODEDIT_REDO, WinEDA_ModuleEditFrame::Process_Special_Functions) + + // Vertical toolbar (left click): + EVT_TOOL(ID_NO_SELECT_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_MODEDIT_ADD_PAD, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_PCB_ARC_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_PCB_CIRCLE_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_TEXT_COMMENT_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_LINE_COMMENT_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_MODEDIT_DELETE_ITEM_BUTT, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_TOOL(ID_MODEDIT_PLACE_ANCHOR, WinEDA_ModuleEditFrame::Process_Special_Functions) + + // Vertical toolbar (right click): + EVT_TOOL_RCLICKED(ID_MODEDIT_ADD_PAD, WinEDA_ModuleEditFrame::ToolOnRightClick) + EVT_TOOL_RCLICKED(ID_TRACK_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick) + EVT_TOOL_RCLICKED(ID_PCB_CIRCLE_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick) + EVT_TOOL_RCLICKED(ID_PCB_ARC_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick) + EVT_TOOL_RCLICKED(ID_TEXT_COMMENT_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick) + EVT_TOOL_RCLICKED(ID_LINE_COMMENT_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick) + EVT_TOOL_RCLICKED(ID_PCB_COTATION_BUTT, WinEDA_ModuleEditFrame::ToolOnRightClick) + + // Options Toolbar + EVT_TOOL_RANGE(ID_TB_OPTIONS_START,ID_TB_OPTIONS_END, + WinEDA_ModuleEditFrame::OnSelectOptionToolbar) + + EVT_MENU_RANGE(ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_END_RANGE, + WinEDA_ModuleEditFrame::Process_Special_Functions) + + // Annulation de commande en cours + EVT_MENU_RANGE(ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, + WinEDA_PcbFrame::Process_Special_Functions ) + + // Transformations du module + EVT_MENU(ID_MODEDIT_MODULE_ROTATE, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_MENU(ID_MODEDIT_MODULE_MIRROR, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_MENU(ID_MODEDIT_MODULE_SCALE, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_MENU(ID_MODEDIT_MODULE_SCALEX, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_MENU(ID_MODEDIT_MODULE_SCALEY, WinEDA_ModuleEditFrame::Process_Special_Functions) + + EVT_MENU(ID_PCB_DRAWINGS_WIDTHS_SETUP, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_MENU(ID_PCB_PAD_SETUP, WinEDA_ModuleEditFrame::Process_Special_Functions) + EVT_MENU(ID_PCB_USER_GRID_SETUP, WinEDA_PcbFrame::Process_Special_Functions) + + // Menu 3D Frame + EVT_MENU(ID_MENU_PCB_SHOW_3D_FRAME, WinEDA_ModuleEditFrame::Show3D_Frame) + + // PopUp Menu Zoom traités dans drawpanel.cpp + +END_EVENT_TABLE() + + + + /****************/ + /* Constructeur */ + /****************/ + +WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame(wxWindow * father, WinEDA_App *parent, + const wxString & title, + const wxPoint& pos, const wxSize& size) : + WinEDA_BasePcbFrame(father, parent, MODULE_EDITOR_FRAME, wxEmptyString, pos, size) +{ + m_FrameName = wxT("ModEditFrame"); + m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines + m_Draw_Grid = TRUE; // TRUE pour avoir la axes dessinee + m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessiné + m_ZoomMaxValue = 1024; + // Give an icon + SetIcon(wxICON(icon_modedit)); + + SetTitle( wxT("Module Editor (lib: ") + m_CurrentLib + wxT(")") ); + + if ( ScreenModule == NULL ) + { + ScreenModule = new PCB_SCREEN(PCB_FRAME); + ActiveScreen = ScreenModule; + } + ScreenModule->m_UndoRedoCountMax = 10; + + if( g_ModuleEditor_Pcb == NULL ) g_ModuleEditor_Pcb = new BOARD(NULL, this); + m_Pcb = g_ModuleEditor_Pcb; + + m_Pcb->m_PcbFrame = this; + m_CurrentScreen = ScreenModule; + GetScreen()->m_CurrentItem = NULL; + GetSettings(); + + wxSize GridSize(500,500); + if ( m_Parent && m_Parent->m_EDA_Config ) + { + long SizeX, SizeY; + if ( m_Parent->m_EDA_Config->Read( wxT("ModEditGrid_X"), &SizeX) && + m_Parent->m_EDA_Config->Read( wxT("ModEditGrid_Y"), &SizeY) ) + { + GridSize.x = SizeX; + GridSize.y = SizeY; + } + } + GetScreen()->SetGrid(GridSize); + + SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y); + ReCreateMenuBar(); + ReCreateHToolbar(); + ReCreateAuxiliaryToolbar(); + ReCreateVToolbar(); + ReCreateOptToolbar(); + + if ( DrawPanel ) DrawPanel->m_Block_Enable = TRUE; + +} + + +/****************************************************/ +WinEDA_ModuleEditFrame::~WinEDA_ModuleEditFrame(void) +/****************************************************/ +{ + m_Parent->m_ModuleEditFrame = NULL; + m_CurrentScreen = ScreenPcb; +} + +/**************************************************************/ +void WinEDA_ModuleEditFrame::OnCloseWindow(wxCloseEvent & Event) +/**************************************************************/ +{ + if( GetScreen()->IsModify() ) + { + if( ! IsOK(this, _("Module Editor: module modified!, Continue ?") ) ) + { + Event.Veto(); return; + } + } + + SaveSettings(); + if ( m_Parent && m_Parent->m_EDA_Config ) + { + wxSize GridSize = GetScreen()->GetGrid(); + m_Parent->m_EDA_Config->Write( wxT("ModEditGrid_X"), (long)GridSize.x); + m_Parent->m_EDA_Config->Write( wxT("ModEditGrid_Y"), (long)GridSize.y); + } + Destroy(); +} + + +/*********************************************/ +void WinEDA_ModuleEditFrame::SetToolbars(void) +/*********************************************/ +{ +bool active, islib = TRUE; + + if( m_HToolBar == NULL ) return; + + if ( m_CurrentLib == wxEmptyString ) islib = FALSE; + + m_HToolBar->EnableTool(ID_MODEDIT_SAVE_LIBMODULE,islib); + m_HToolBar->EnableTool(ID_LIBEDIT_DELETE_PART,islib); + + if ( m_Pcb->m_Modules == NULL ) active = FALSE; + else active = TRUE; + + m_HToolBar->EnableTool(ID_LIBEDIT_EXPORT_PART,active); + m_HToolBar->EnableTool(ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,active); + m_HToolBar->EnableTool(ID_MODEDIT_SAVE_LIBMODULE,active && islib); + m_HToolBar->EnableTool(ID_MODEDIT_SAVE_MODULE_IN_BOARD,active); + if ( GetScreen() ) + { + m_HToolBar->EnableTool(ID_MODEDIT_UNDO,GetScreen()->m_UndoList && active); + m_HToolBar->EnableTool(ID_MODEDIT_REDO,GetScreen()->m_RedoList && active); + } + + if ( m_Parent->m_PcbFrame->m_Pcb->m_Modules ) + { + m_HToolBar->EnableTool(ID_MODEDIT_LOAD_MODULE_FROM_BOARD,TRUE); + } + else + { + m_HToolBar->EnableTool(ID_MODEDIT_LOAD_MODULE_FROM_BOARD,FALSE); + } + + + if ( m_VToolBar ) + { + m_VToolBar->EnableTool(ID_MODEDIT_ADD_PAD,active); + m_VToolBar->EnableTool(ID_LINE_COMMENT_BUTT,active); + m_VToolBar->EnableTool(ID_PCB_CIRCLE_BUTT,active); + m_VToolBar->EnableTool(ID_PCB_ARC_BUTT,active); + m_VToolBar->EnableTool(ID_TEXT_COMMENT_BUTT,active); + m_VToolBar->EnableTool(ID_MODEDIT_PLACE_ANCHOR,active); + m_VToolBar->EnableTool(ID_PCB_DELETE_ITEM_BUTT,active); + } + + if ( m_OptionsToolBar ) + { + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_MM, + g_UnitMetric == MILLIMETRE ? TRUE : FALSE); + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_INCH, + g_UnitMetric == INCHES ? TRUE : FALSE); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_POLAR_COORD, + DisplayOpt.DisplayPolarCood); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_GRID, + m_Draw_Grid); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_CURSOR, + g_CursorShape); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_PADS_SKETCH, + ! m_DisplayPadFill); + } + + if ( m_AuxiliaryToolBar ) + { + int ii, jj; + if ( m_SelZoomBox ) + { + int old_choice = m_SelZoomBox->GetChoice(); + int new_choice = 1; + int zoom; + for ( jj = 1, zoom = 1; zoom <= m_ZoomMaxValue; zoom <<= 1, jj++ ) + { + if ( m_CurrentScreen && (m_CurrentScreen->GetZoom() == zoom) ) + break; + new_choice++; + } + if ( old_choice != new_choice ) + m_SelZoomBox->SetSelection(new_choice); + } + + if ( m_SelGridBox && GetScreen() ) + { + int kk = m_SelGridBox->GetChoice(); + for ( ii = 0; g_GridList[ii].x > 0; ii++ ) + { + if ( !GetScreen()->m_UserGridIsON && + (GetScreen()->GetGrid().x == g_GridList[ii].x) && + (GetScreen()->GetGrid().y == g_GridList[ii].y)) + { + if ( kk != ii )m_SelGridBox->SetSelection(ii); + kk = ii; + break; + } + } + if ( kk != ii ) + m_SelGridBox->SetSelection(ii); /* User Grid */ + } + } + + DisplayUnitsMsg(); +} + diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp new file mode 100644 index 0000000000..81da55316d --- /dev/null +++ b/pcbnew/modules.cpp @@ -0,0 +1,672 @@ + /********************************************************/ + /* Modification de la place, orient, nombre des MODULES */ + /********************************************************/ + + /* Fichier MODULES.Cpp */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "trigo.h" + +#include "protos.h" + +#include "drag.h" + +/* fonctions externes */ + +/* Fonctions locales */ +static int ChangeSideMaskLayer(int masque); +static void Exit_Module(WinEDA_DrawPanel * Panel, wxDC *DC) ; + +/* Variables locales : */ +static int ModuleInitOrient; // Lors des moves, val init de l'orient (pour annulation) +static int ModuleInitLayer; // Lors des moves, val init de la couche (pour annulation) + +/*************************************************************************/ +void Show_Pads_On_Off(WinEDA_DrawPanel * panel, wxDC * DC, MODULE * module) +/**************************************************************************/ +/* Fonction appelee lors de l'activation/desactivation de la visualisation + des Pads du module en deplacement + Effacement ou visu des Pads selon conditions initiales +*/ +{ +D_PAD* pt_pad; +bool pad_fill_tmp; + + if(module == 0 ) return ; + + pad_fill_tmp = DisplayOpt.DisplayPadFill; + DisplayOpt.DisplayPadFill = FALSE; /* Trace en SKETCH */ + pt_pad = module->m_Pads; + for( ;pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + { + pt_pad->Draw(panel, DC, g_Offset_Module, GR_XOR) ; + } + DisplayOpt.DisplayPadFill = pad_fill_tmp; +} + +/***************************************************************************/ +/* Fonction appelee lors de l'activation/desactivation de la visualisation */ +/* du rastnest du module en deplacement */ +/* Effacement ou visu du rastnest selon conditions initiales */ +/***************************************************************************/ +void Rastnest_On_Off(WinEDA_DrawPanel * panel, wxDC * DC, MODULE * module) +{ +WinEDA_BasePcbFrame * frame = (WinEDA_BasePcbFrame *)panel->m_Parent; + frame->build_ratsnest_module(DC, module) ; + frame->trace_ratsnest_module(DC); +} + + +/**********************************************************************/ +void WinEDA_PcbFrame::StartMove_Module(MODULE * module, wxDC * DC) +/**********************************************************************/ +{ + + if (module == NULL ) return; + + m_CurrentScreen->m_CurrentItem = module; + m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; + module->m_Flags |= IS_MOVED; + ModuleInitOrient = module->m_Orient; + ModuleInitLayer = module->m_Layer; + + /* Effacement chevelu general si necessaire */ + if(g_Show_Ratsnest) DrawGeneralRatsnest(DC); + + if( g_DragSegmentList ) /* Anormal ! */ + { + EraseDragListe(); + } + + if( g_Drag_Pistes_On) + { + Build_Drag_Liste(DrawPanel, DC, module); + } + + m_Pcb->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST; + DrawPanel->ManageCurseur = Montre_Position_Empreinte; + DrawPanel->ForceCloseManageCurseur = Exit_Module; + DrawPanel->m_AutoPAN_Request = TRUE; + + // effacement module a l'ecran: + module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); + // Reaffichage + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); +} + +/**************************************************/ +void Exit_Module(WinEDA_DrawPanel * Panel, wxDC *DC) +/***************************************************/ +/* fonction de sortie de l'application */ +{ +DRAG_SEGM * pt_drag; +TRACK * pt_segm; +MODULE * module; +WinEDA_BasePcbFrame * pcbframe = (WinEDA_BasePcbFrame*)Panel->m_Parent; + + module = (MODULE *) pcbframe->m_CurrentScreen->m_CurrentItem; + pcbframe->m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; + + if (module) + { + // effacement module a l'ecran: + DrawModuleOutlines(Panel, DC, module); + /* restitution de l'empreinte si move ou effacement copie*/ + if (module->m_Flags & IS_MOVED ) + { + /* Move en cours : remise a l'etat d'origine */ + if( g_Drag_Pistes_On) + { + /* Effacement des segments dragges */ + pt_drag = g_DragSegmentList; + for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) + { + pt_segm = pt_drag->m_Segm; + pt_segm->Draw(Panel, DC, GR_XOR); + } + } + + /* Remise en etat d'origine des segments dragges */ + pt_drag = g_DragSegmentList; + for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) + { + pt_segm = pt_drag->m_Segm; pt_segm->SetState(EDIT,OFF); + pt_drag->SetInitialValues(); + pt_segm->Draw(Panel, DC, GR_OR); + } + EraseDragListe(); + module->m_Flags = 0; + } + + if (module->m_Flags & IS_NEW ) + { + DeleteStructure(module); + module = NULL; + pcbframe->m_Pcb->m_Status_Pcb = 0 ; + pcbframe->build_liste_pads() ; + } + } + + /* Reaffichage du module a l'ecran */ + if ( module ) + { + if ( ModuleInitOrient != module->m_Orient ) + pcbframe->Rotate_Module(NULL,module, ModuleInitOrient, FALSE); + if( ModuleInitLayer != module->m_Layer ) + pcbframe->Change_Side_Module(module, NULL); + module->Draw(Panel, DC, wxPoint(0,0), GR_OR); + } + g_Drag_Pistes_On = FALSE; + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + pcbframe->m_CurrentScreen->m_CurrentItem = NULL; +} + + +/**********************************************************/ +MODULE * WinEDA_BasePcbFrame::Copie_Module(MODULE * module) +/**********************************************************/ +/* copie le module "module" en position courante */ +{ +MODULE * newmodule; + + if (module == NULL ) return NULL; + + m_CurrentScreen->SetModify(); + + /* Duplication du module */ + m_Pcb->m_Status_Pcb = 0; + newmodule = new MODULE(m_Pcb); + newmodule->Copy(module); + newmodule->m_Parent = m_Pcb; + newmodule->AddToChain(module); + newmodule->m_Flags = IS_NEW; + + build_liste_pads(); + + newmodule->Display_Infos(this); + m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; + return newmodule; +} + +/**********************************************************************************/ +void Montre_Position_Empreinte(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/**********************************************************************************/ +/* redessin du contour de l'empreinte lors des deplacements de la souris +*/ +{ +MODULE * module = (MODULE *) panel->m_Parent->m_CurrentScreen->m_CurrentItem; + + if ( module == NULL ) return; + + /* efface ancienne position */ + if( erase ) + { + DrawModuleOutlines(panel, DC, module); + } + + /* Redessine le module a la nouvelle place */ + g_Offset_Module.x = module->m_Pos.x - panel->m_Parent->m_CurrentScreen->m_Curseur.x; + g_Offset_Module.y = module->m_Pos.y - panel->m_Parent->m_CurrentScreen->m_Curseur.y; + DrawModuleOutlines(panel, DC, module); + + Dessine_Segments_Dragges(panel, DC); +} + + +/**************************************************************/ +bool WinEDA_PcbFrame::Delete_Module(MODULE * module, wxDC * DC) +/**************************************************************/ +/* +Commande Delete Module : + Suppression d'une empreinte + les pointeurs divers sont mis a jour +*/ +{ +EDA_BaseStruct * PtBack, *PtNext; +wxString msg; + /* Si l'empreinte est selectee , on ne peut pas l'effacer ! */ + if ( module == NULL ) return FALSE; + + /* Confirmation de l'effacement */ + module->Display_Infos(this); + + msg << _("Delete Module") << wxT(" ") << module->m_Reference->m_Text + << wxT(" (") << _("Value ") << module->m_Value->m_Text + << wxT(") ?"); + if( !IsOK(this, msg ) ) + { + return FALSE; + } + + m_CurrentScreen->SetModify(); + + /* Erase rastnest if needed */ + if(g_Show_Ratsnest) DrawGeneralRatsnest(DC); + + /* Effacement du module a l'ecran */ + if ( DC ) module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); + + /* Suppression du chainage */ + PtBack = module->Pback; + PtNext = module->Pnext; + if( PtBack == (EDA_BaseStruct*) m_Pcb ) + { + m_Pcb->m_Modules = (MODULE*)PtNext; + } + else + { + PtBack->Pnext = PtNext; + } + if(PtNext) PtNext->Pback = PtBack; + + /* Sauvegarde en buffer des undelete */ + SaveItemEfface( module, 1); + + m_Pcb->m_Status_Pcb = 0 ; + build_liste_pads() ; + ReCompile_Ratsnest_After_Changes( DC ); + return TRUE; +} + +/**********************************************************************/ +void WinEDA_BasePcbFrame::Change_Side_Module(MODULE * Module, wxDC * DC) +/**********************************************************************/ + +/* Change de cote un composant : il y a inversion MIROIR autour de l'axe X + Le changement n'est fait que si la couche est + - CUIVRE ou CMP + Si DC == NULL, il n'y a pas de redessin du composant et du chevelu +*/ +{ +D_PAD* pt_pad ; +TEXTE_MODULE* pt_texte; +EDGE_MODULE * pt_edgmod ; +EDA_BaseStruct * PtStruct; + + if ( Module == NULL ) return; + if( (Module->m_Layer != CMP_N) && (Module->m_Layer != CUIVRE_N) ) return; + + m_CurrentScreen->SetModify(); + + if ( ! (Module->m_Flags & IS_MOVED) ) + { + m_Pcb->m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK); + if ( DC ) Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); + + /* Effacement chevelu general si necessaire */ + if ( DC && g_Show_Ratsnest) DrawGeneralRatsnest(DC); + /* Init des variables utilisees dans la routine Dessine_Drag_segment() */ + g_Offset_Module.x = 0; + g_Offset_Module.y = 0; + } + + else // Module en deplacement + { + /* efface empreinte ( vue en contours) si elle a ete deja dessinee */ + if ( DC ) + { + DrawModuleOutlines(DrawPanel, DC, Module); + Dessine_Segments_Dragges(DrawPanel, DC); + } + } + + /* mise a jour du Flag de l'empreinte et des couches des contours et textes */ + Module->m_Layer = ChangeSideNumLayer(Module->m_Layer); + + /* Inversion miroir de l'orientation */ + Module->m_Orient = - Module->m_Orient; + NORMALIZE_ANGLE_POS(Module->m_Orient); + + /* Inversion miroir + layers des pastilles */ + pt_pad = Module->m_Pads; + for ( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + { + pt_pad->m_Pos.y -= Module->m_Pos.y ; + pt_pad->m_Pos.y = -pt_pad->m_Pos.y; + pt_pad->m_Pos.y += Module->m_Pos.y; + pt_pad->m_Pos0.y = - pt_pad->m_Pos0.y; + pt_pad->m_Offset.y = -pt_pad->m_Offset.y; + pt_pad->m_DeltaSize.y = -pt_pad->m_DeltaSize.y; + NEGATE_AND_NORMALIZE_ANGLE_POS(pt_pad->m_Orient); + /* change cote pour pastilles surfaciques */ + pt_pad->m_Masque_Layer = ChangeSideMaskLayer(pt_pad->m_Masque_Layer); + } + + /* Inversion miroir de la Reference et mise en miroir : */ + pt_texte = Module->m_Reference; + pt_texte->m_Pos.y -= Module->m_Pos.y; + pt_texte->m_Pos.y = -pt_texte->m_Pos.y; + pt_texte->m_Pos.y += Module->m_Pos.y; + pt_texte->m_Pos0.y = pt_texte->m_Pos0.y; + pt_texte->m_Miroir = 1 ; + NEGATE_AND_NORMALIZE_ANGLE_POS(pt_texte->m_Orient); + pt_texte->m_Layer = Module->m_Layer; + pt_texte->m_Layer = ChangeSideNumLayer(pt_texte->m_Layer); + if( Module->m_Layer == CUIVRE_N) pt_texte->m_Layer = SILKSCREEN_N_CU; + if( Module->m_Layer == CMP_N) pt_texte->m_Layer = SILKSCREEN_N_CMP; + if( (Module->m_Layer == SILKSCREEN_N_CU) || + (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) ) + pt_texte->m_Miroir = 0 ; + + /* Inversion miroir de la Valeur et mise en miroir : */ + pt_texte = Module->m_Value; + pt_texte->m_Pos.y -= Module->m_Pos.y; + pt_texte->m_Pos.y = -pt_texte->m_Pos.y; + pt_texte->m_Pos.y += Module->m_Pos.y; + pt_texte->m_Pos0.y = pt_texte->m_Pos0.y; + pt_texte->m_Miroir = 1 ; + NEGATE_AND_NORMALIZE_ANGLE_POS(pt_texte->m_Orient); + pt_texte->m_Layer = Module->m_Layer; + pt_texte->m_Layer = ChangeSideNumLayer(pt_texte->m_Layer); + if( Module->m_Layer == CUIVRE_N) pt_texte->m_Layer = SILKSCREEN_N_CU; + if( Module->m_Layer == CMP_N) pt_texte->m_Layer = SILKSCREEN_N_CMP; + if( (Module->m_Layer == SILKSCREEN_N_CU) || + (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) ) + pt_texte->m_Miroir = 0 ; + + /* Inversion miroir des dessins de l'empreinte : */ + PtStruct = Module->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext) + { + switch( PtStruct->m_StructType) + { + case TYPEEDGEMODULE: + pt_edgmod = (EDGE_MODULE *) PtStruct; + pt_edgmod->m_Start.y -= Module->m_Pos.y; + pt_edgmod->m_Start.y = -pt_edgmod->m_Start.y ; + pt_edgmod->m_Start.y += Module->m_Pos.y; + pt_edgmod->m_End.y -= Module->m_Pos.y; + pt_edgmod->m_End.y = -pt_edgmod->m_End.y ; + pt_edgmod->m_End.y += Module->m_Pos.y; + /* inversion des coords locales */ + pt_edgmod->m_Start0.y = -pt_edgmod->m_Start0.y; + pt_edgmod->m_End0.y = -pt_edgmod->m_End0.y; + if ( pt_edgmod->m_Shape == S_ARC ) + { + pt_edgmod->m_Angle = - pt_edgmod->m_Angle; + } + + pt_edgmod->m_Layer = ChangeSideNumLayer(pt_edgmod->m_Layer); + break; + + case TYPETEXTEMODULE: + /* Inversion miroir de la position et mise en miroir : */ + pt_texte = (TEXTE_MODULE*)PtStruct; + pt_texte->m_Pos.y -= Module->m_Pos.y; + pt_texte->m_Pos.y = -pt_texte->m_Pos.y; + pt_texte->m_Pos.y += Module->m_Pos.y; + pt_texte->m_Pos0.y = pt_texte->m_Pos0.y; + pt_texte->m_Miroir = 1 ; + NEGATE_AND_NORMALIZE_ANGLE_POS(pt_texte->m_Orient); + + pt_texte->m_Layer = Module->m_Layer; + pt_texte->m_Layer = ChangeSideNumLayer(pt_texte->m_Layer); + if( Module->m_Layer == CUIVRE_N) pt_texte->m_Layer = SILKSCREEN_N_CU; + if(Module->m_Layer == CMP_N) pt_texte->m_Layer = SILKSCREEN_N_CMP; + if((Module->m_Layer == SILKSCREEN_N_CU) || + (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N)) + pt_texte->m_Miroir = 0 ; + + break; + + default: DisplayError(this, wxT("Unknown Draw Type")); break; + + } + } + + /* calcul du rectangle d'encadrement */ + Module->Set_Rectangle_Encadrement(); + + Module->Display_Infos(this); + + if( !(Module->m_Flags & IS_MOVED) ) /* Inversion simple */ + { + if ( DC ) + { + Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); + /* affichage chevelu general si necessaire */ + ReCompile_Ratsnest_After_Changes( DC ); + } + } + + else + { + if ( DC ) + { + DrawModuleOutlines(DrawPanel, DC, Module); + Dessine_Segments_Dragges(DrawPanel, DC); + } + m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; + } +} + + + +/*********************************************/ +static int ChangeSideMaskLayer(int masque) +/*********************************************/ +/* Routine de recalcul du masque-layer lors des +echanges cote cu/cmp pour les couches CU/CMP specialisees + (cuivre, serigr., pate , soudure) +*/ +{ +int newmasque; + + newmasque = masque & ~(CUIVRE_LAYER | CMP_LAYER | + SILKSCREEN_LAYER_CU | SILKSCREEN_LAYER_CMP | + ADHESIVE_LAYER_CU | ADHESIVE_LAYER_CMP | + SOLDERMASK_LAYER_CU | SOLDERMASK_LAYER_CMP | + SOLDERPASTE_LAYER_CU | SOLDERPASTE_LAYER_CMP | + ADHESIVE_LAYER_CU | ADHESIVE_LAYER_CMP); + + if( masque & CUIVRE_LAYER) newmasque |= CMP_LAYER; + if( masque & CMP_LAYER) newmasque |= CUIVRE_LAYER; + + if( masque & SILKSCREEN_LAYER_CU) newmasque |= SILKSCREEN_LAYER_CMP; + if( masque & SILKSCREEN_LAYER_CMP) newmasque |= SILKSCREEN_LAYER_CU; + + if( masque & ADHESIVE_LAYER_CU) newmasque |= ADHESIVE_LAYER_CMP; + if( masque & ADHESIVE_LAYER_CMP) newmasque |= ADHESIVE_LAYER_CU; + + if( masque & SOLDERMASK_LAYER_CU) newmasque |= SOLDERMASK_LAYER_CMP; + if( masque & SOLDERMASK_LAYER_CMP) newmasque |= SOLDERMASK_LAYER_CU; + + if( masque & SOLDERPASTE_LAYER_CU) newmasque |= SOLDERPASTE_LAYER_CMP; + if( masque & SOLDERPASTE_LAYER_CMP) newmasque |= SOLDERPASTE_LAYER_CU; + + if( masque & ADHESIVE_LAYER_CU) newmasque |= ADHESIVE_LAYER_CMP; + if( masque & ADHESIVE_LAYER_CMP) newmasque |= ADHESIVE_LAYER_CU; + + return(newmasque); +} + + +/*************************************/ +int ChangeSideNumLayer(int oldlayer) +/*************************************/ +/* Routine de recalcul du numero de couche lors des +echanges cote cu/cmp pour les couches CU/CMP specialisees + (cuivre, serigr., pate , soudure) +*/ +{ +int newlayer; + + switch ( oldlayer ) + { + case CUIVRE_N: newlayer = CMP_N; break; + case CMP_N: newlayer = CUIVRE_N; break; + + case SILKSCREEN_N_CU: newlayer = SILKSCREEN_N_CMP; break; + case SILKSCREEN_N_CMP: newlayer = SILKSCREEN_N_CU; break; + + case ADHESIVE_N_CU: newlayer = ADHESIVE_N_CMP; break; + case ADHESIVE_N_CMP: newlayer = ADHESIVE_N_CU; break; + + case SOLDERMASK_N_CU: newlayer = SOLDERMASK_N_CMP; break; + case SOLDERMASK_N_CMP: newlayer = SOLDERMASK_N_CU; break; + + case SOLDERPASTE_N_CU: newlayer = SOLDERPASTE_N_CMP; break; + case SOLDERPASTE_N_CMP: newlayer = SOLDERPASTE_N_CU; break; + + default: newlayer = oldlayer; + } + return(newlayer); +} + +/*****************************************************************/ +void WinEDA_BasePcbFrame::Place_Module(MODULE * module, wxDC * DC) +/*****************************************************************/ +/* Place a l'endroit pointe par la souris le module deja existant selectionne +auparavant. + Entree: module = num du module a replacer + DC ( si NULL: pas d'affichage a l'écran + Sortie : + mise a jour des nouvelles coord des differents elements du module + affichage a l'ecran du module +*/ +{ +TRACK * pt_segm; +DRAG_SEGM * pt_drag; +wxPoint newpos; + + if ( module == 0 ) return ; + + m_CurrentScreen->SetModify(); + m_Pcb->m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK); + + if(g_Show_Module_Ratsnest && (m_Pcb->m_Status_Pcb & LISTE_PAD_OK) && DC) + trace_ratsnest_module(DC); + + newpos = m_CurrentScreen->m_Curseur; + + module->SetPosition(newpos); + if ( DC ) module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); + + /* Tracage des segments dragges et liberation memoire */ + if( g_DragSegmentList ) + { + pt_drag = g_DragSegmentList; + for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) + { + pt_segm = pt_drag->m_Segm; + pt_segm->SetState(EDIT,OFF); + if ( DC ) pt_segm->Draw(DrawPanel, DC, GR_OR); + } + EraseDragListe(); + } + + /* affichage chevelu general si necessaire */ + ReCompile_Ratsnest_After_Changes( DC ); + + module->Display_Infos(this); + + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + module->m_Flags = 0; + g_Drag_Pistes_On = FALSE; +} + + +/***********************************************************************/ +void WinEDA_BasePcbFrame::Rotate_Module(wxDC * DC, MODULE * module, + int angle, bool incremental) +/***********************************************************************/ +/* + Fait tourner l'empreinte de angle degres, dans le sens < 0. + Si incremental == TRUE, la rotation est faite a partir de la derniere orientation, + sinon le module est mis dans l'orientation absolue angle. + Si DC == NULL, le composant n'est pas redessine. + Sinon, il est efface, tourne et redessine +*/ +{ + if ( module == NULL ) return; + + m_CurrentScreen->SetModify(); + + /* efface ancienne position */ + if( !(module->m_Flags & IS_MOVED) ) /* Rotation simple */ + { + if ( DC ) + { + module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); + /* Reaffichage chevelu general si necessaire */ + if(g_Show_Ratsnest) DrawGeneralRatsnest(DC); + } + } + else + { + /* reaffiche module en mouvement */ + if ( DC ) + { + DrawModuleOutlines(DrawPanel, DC, module); + Dessine_Segments_Dragges(DrawPanel, DC); + } + } + + m_Pcb->m_Status_Pcb &= ~(LISTE_CHEVELU_OK | CONNEXION_OK); + + if ( incremental ) + module->SetOrientation(module->m_Orient + angle); + else + module->SetOrientation(angle); + + module->Display_Infos(this); + + if ( DC ) + { + if( !(module->m_Flags & IS_MOVED) ) /* Rotation simple */ + { + module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); + /* Reaffichage chevelu general si necessaire */ + ReCompile_Ratsnest_After_Changes( DC ); + } + else + { + /* reaffiche module en mouvement */ + DrawModuleOutlines(DrawPanel, DC, module); + Dessine_Segments_Dragges(DrawPanel, DC); + } + } +} + + +/*************************************************/ +/* Redessine en mode XOR la silouhette du module */ +/*************************************************/ + +void DrawModuleOutlines(WinEDA_DrawPanel * panel, wxDC * DC, MODULE * module) +{ +int pad_fill_tmp; +D_PAD* pt_pad; + + if(module == NULL) return ; + module->DrawEdgesOnly(panel, DC, g_Offset_Module, GR_XOR); + + if(g_Show_Pads_Module_in_Move) + { + pad_fill_tmp = DisplayOpt.DisplayPadFill; + DisplayOpt.DisplayPadFill = SKETCH; /* Trace en SKETCH en deplacement */ + + pt_pad = module->m_Pads; + for ( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext) + { + pt_pad->Draw(panel, DC, g_Offset_Module, GR_XOR); + } + DisplayOpt.DisplayPadFill = pad_fill_tmp; + } + + if(g_Show_Module_Ratsnest && panel) + { + WinEDA_BasePcbFrame * frame = (WinEDA_BasePcbFrame * ) panel->m_Parent; + frame->build_ratsnest_module(DC, module); + frame->trace_ratsnest_module(DC); + } +} + + diff --git a/pcbnew/move-drag_pads.cpp b/pcbnew/move-drag_pads.cpp new file mode 100644 index 0000000000..904663de63 --- /dev/null +++ b/pcbnew/move-drag_pads.cpp @@ -0,0 +1,378 @@ + /*************************/ + /* Edition des Pastilles */ + /*************************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "trigo.h" + +#include "drag.h" + +#include "protos.h" + +/* Routines Locales */ + +/* Variables locales */ +D_PAD* pt_pad_selecte; /* pointeur sur le pad selecte pour edition */ +static wxPoint Pad_OldPos; + + + +/************************************************************/ +static void Exit_Move_Pad(WinEDA_DrawPanel * Panel, wxDC * DC) +/************************************************************/ +/* Routine de sortie du menu EDIT PADS. + Sortie simple si pad de pad en mouvement + Remise en etat des conditions initiales avant move si move en cours +*/ +{ +D_PAD * pad = pt_pad_selecte; + + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + if (pad == NULL) return; + + pad->Draw(Panel,DC, wxPoint(0,0), GR_XOR); + pad->m_Flags = 0; + pad->m_Pos = Pad_OldPos; + pad->Draw(Panel, DC, wxPoint(0,0), GR_XOR); + /* Pad Move en cours : remise a l'etat d'origine */ + if( g_Drag_Pistes_On ) + { + /* Effacement des segments dragges */ + DRAG_SEGM * pt_drag = g_DragSegmentList; + for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) + { + TRACK * Track = pt_drag->m_Segm; + Track->Draw(Panel, DC, GR_XOR); + Track->SetState(EDIT,OFF); + pt_drag->SetInitialValues(); + Track->Draw(Panel, DC, GR_OR); + } + } + + EraseDragListe(); + pt_pad_selecte = NULL; + g_Drag_Pistes_On = FALSE; +} + + +/*************************************************************************/ +static void Show_Pad_Move(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/*************************************************************************/ +/* Affiche le pad et les pistes en mode drag lors des deplacements du pad */ +{ +TRACK * Track; +DRAG_SEGM * pt_drag; +BASE_SCREEN * screen = panel->GetScreen(); +D_PAD * pad = pt_pad_selecte; + + if ( erase ) pad->Draw(panel, DC, wxPoint(0,0), GR_XOR); + pad->m_Pos = screen->m_Curseur; + pad->Draw(panel, DC, wxPoint(0,0), GR_XOR); + + if( ! g_Drag_Pistes_On ) return; + + /* Tracage des segments dragges */ + pt_drag = g_DragSegmentList; + for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) + { + Track = pt_drag->m_Segm; + if ( erase ) Track->Draw(panel, DC, GR_XOR); + if( pt_drag->m_Pad_Start) + { + Track->m_Start = pad->m_Pos; + } + if( pt_drag->m_Pad_End) + { + Track->m_End = pad->m_Pos; + } + Track->Draw(panel, DC, GR_XOR); + } +} + + +/*************************************************************/ +void WinEDA_BasePcbFrame::Export_Pad_Settings( D_PAD * pt_pad) +/*************************************************************/ +/* Charge en liste des caracteristiques par defaut celles du pad selecte +*/ +{ +MODULE * Module; + + if ( pt_pad == NULL ) return; + + Module = (MODULE*) pt_pad->m_Parent; + + pt_pad->Display_Infos(this); + + g_Pad_Master.m_PadShape = pt_pad->m_PadShape; + g_Pad_Master.m_Attribut = pt_pad->m_Attribut; + g_Pad_Master.m_Masque_Layer = pt_pad->m_Masque_Layer; + g_Pad_Master.m_Orient = pt_pad->m_Orient - + ((MODULE*)pt_pad->m_Parent)->m_Orient; + g_Pad_Master.m_Size = pt_pad->m_Size; + g_Pad_Master.m_DeltaSize = pt_pad->m_DeltaSize; + pt_pad->ComputeRayon(); + + g_Pad_Master.m_Offset = pt_pad->m_Offset; + g_Pad_Master.m_Drill = pt_pad->m_Drill; + g_Pad_Master.m_DrillShape = pt_pad->m_DrillShape; +} + + +/***********************************************************************/ +void WinEDA_BasePcbFrame::Import_Pad_Settings(D_PAD * pt_pad, wxDC * DC) +/***********************************************************************/ +/* Met a jour les nouvelles valeurs de dimensions du pad pointe par pt_pad + - Source : valeurs choisies des caracteristiques generales + - les dimensions sont modifiees + - la position et les noms ne sont pas touches +*/ +{ + if ( DC ) pt_pad->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); + + pt_pad->m_PadShape = g_Pad_Master.m_PadShape ; + pt_pad->m_Masque_Layer = g_Pad_Master.m_Masque_Layer ; + pt_pad->m_Attribut = g_Pad_Master.m_Attribut ; + pt_pad->m_Orient = g_Pad_Master.m_Orient + + ((MODULE*)pt_pad->m_Parent)->m_Orient; + pt_pad->m_Size = g_Pad_Master.m_Size; + pt_pad->m_DeltaSize = wxSize(0,0); + pt_pad->m_Offset = g_Pad_Master.m_Offset; + pt_pad->m_Drill = g_Pad_Master.m_Drill ; + pt_pad->m_DrillShape = g_Pad_Master.m_DrillShape ; + + /* Traitement des cas particuliers : */ + switch ( g_Pad_Master.m_PadShape) + { + case TRAPEZE : + pt_pad->m_DeltaSize = g_Pad_Master.m_DeltaSize; + break; + + case CIRCLE : + pt_pad->m_Size.y = pt_pad->m_Size.x; + break; + + } + + switch( g_Pad_Master.m_Attribut & 0x7F) + { + case SMD: + case CONN : + pt_pad->m_Drill = wxSize(0,0); + pt_pad->m_Offset.x = 0; + pt_pad->m_Offset.y = 0; + } + + pt_pad->ComputeRayon(); + + if ( DC ) pt_pad->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); + ((MODULE*)pt_pad->m_Parent)->m_LastEdit_Time = time(NULL); +} + + +/***********************************************************/ +void WinEDA_BasePcbFrame::AddPad(MODULE * Module, wxDC * DC) +/***********************************************************/ +/* Routine d'ajout d'un pad sur l'module selectionnee */ +{ +D_PAD * Pad, *ptliste; +int rX, rY; + + m_Pcb->m_Status_Pcb = 0 ; + Module->m_LastEdit_Time = time(NULL); + + Pad = new D_PAD( Module ); + + /* Chainage de la structure en fin de liste des pads : */ + ptliste = Module->m_Pads; + if( ptliste == NULL ) /* 1er pad */ + { + Module->m_Pads = Pad; + Pad->Pback = (EDA_BaseStruct*) Module; + } + else + { + while( ptliste ) + { + if( ptliste->Pnext == NULL ) break; + ptliste = (D_PAD *) ptliste->Pnext; + } + Pad->Pback = (EDA_BaseStruct*)ptliste; + ptliste->Pnext = (EDA_BaseStruct*)Pad; + } + + /* Mise a jour des caract de la pastille : */ + Import_Pad_Settings(Pad, NULL); + Pad->m_Netname.Empty(); + + Pad->m_Pos = GetScreen()->m_Curseur; + rX = Pad->m_Pos.x - Module->m_Pos.x; + rY = Pad->m_Pos.y - Module->m_Pos.y; + RotatePoint( &rX, &rY, - Module->m_Orient); + Pad->m_Pos0.x = rX; Pad->m_Pos0.y = rY; + + /* Increment automatique de la reference courante Current_PadName */ + long num = 0; int ponder = 1; + while ( g_Current_PadName.Last() >= '0' && g_Current_PadName.Last() <= '9') + { + num += (g_Current_PadName.Last() - '0') * ponder; + g_Current_PadName.RemoveLast(); + ponder *= 10; + } + num++; + g_Current_PadName << num; + Pad->SetPadName(g_Current_PadName); + + /* Redessin du module */ + Module->Set_Rectangle_Encadrement(); + Pad->Display_Infos(this); + Module->Draw(DrawPanel, DC, wxPoint(0,0),GR_OR); + +} + +/*********************************************************/ +void WinEDA_BasePcbFrame::DeletePad(D_PAD* Pad, wxDC * DC) +/*********************************************************/ +/* Routine de suppression d'une pastille sur le module selectionne */ +{ +MODULE * Module; +wxString line; + + if ( Pad == NULL ) return; + + Module = (MODULE*) Pad->m_Parent; + Module->m_LastEdit_Time = time(NULL); + + line.Printf( _("Delete Pad (module %s %s) "), + Module->m_Reference->m_Text.GetData(),Module->m_Value->m_Text.GetData() ); + if( ! IsOK(this, line) ) return ; + + m_Pcb->m_Status_Pcb = 0 ; + + if ( DC ) Pad->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR); + + DeleteStructure(Pad); + + /* Redessin du module */ + if ( DC ) Module->Draw(DrawPanel, DC, wxPoint(0,0),GR_OR); + Module->Set_Rectangle_Encadrement(); + GetScreen()->SetModify(); + return ; +} + +/*************************************************************/ +void WinEDA_BasePcbFrame::StartMovePad(D_PAD * Pad, wxDC * DC) +/*************************************************************/ +/* Routine de deplacement d'une pastille */ +{ +MODULE * Module; + + /* localisation d'une pastille ? */ + if(Pad == NULL ) return; + + Module = (MODULE*) Pad->m_Parent; + + pt_pad_selecte = Pad ; + Pad_OldPos = Pad->m_Pos; + Pad->Display_Infos(this); + DrawPanel->ManageCurseur = Show_Pad_Move; + DrawPanel->ForceCloseManageCurseur = Exit_Move_Pad; + + /* Affichage du pad en SKETCH */ + Pad->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR); + Pad->m_Flags |= IS_MOVED; + Pad->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR); + + /* Construction de la liste des segments a "dragger" */ + Build_1_Pad_SegmentsToDrag(DrawPanel, DC, Pad); +} + + +/*********************************************************/ +void WinEDA_BasePcbFrame::PlacePad(D_PAD * Pad, wxDC * DC) +/*********************************************************/ +/* Routine to Place a moved pad */ +{ +int dX, dY; +TRACK * Track; +DRAG_SEGM *pt_drag; +MODULE * Module; + + if(Pad == NULL ) return; + + Module = (MODULE*) Pad->m_Parent; + + /* Placement du pad */ + Pad->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR); + + /* Save old module */ + Pad->m_Pos = Pad_OldPos; SaveCopyInUndoList(m_Pcb->m_Modules); + Pad->m_Pos = GetScreen()->m_Curseur; + + /* Compute local coordinates (i.e refer to Module position and for Module orient = 0)*/ + dX = Pad->m_Pos.x - Pad_OldPos.x; + dY = Pad->m_Pos.y - Pad_OldPos.y; + RotatePoint(&dX, &dY, - Module->m_Orient ); + Pad->m_Pos0.x += dX; pt_pad_selecte->m_Pos0.y += dY; + + Pad->m_Flags = 0; + + Pad->Draw(DrawPanel, DC, wxPoint(0,0),GR_OR); + + Module->Set_Rectangle_Encadrement(); + Module->m_LastEdit_Time = time(NULL); + + /* Tracage des segments dragges */ + pt_drag = g_DragSegmentList; + for( ; pt_drag; pt_drag = pt_drag->Pnext) + { + Track = pt_drag->m_Segm; + Track->SetState(EDIT,OFF); + Track->Draw(DrawPanel, DC, GR_OR); + } + EraseDragListe(); + + GetScreen()->SetModify(); + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + m_Pcb->m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK); +} + +/**********************************************************/ +void WinEDA_BasePcbFrame::RotatePad(D_PAD * Pad, wxDC * DC) +/**********************************************************/ +/* Tourne de 90 degres le pad selectionne : + c.a.d intervertit dim X et Y et offsets + */ +{ +MODULE * Module; + if ( Pad == NULL ) return; + + Module = (MODULE*) Pad->m_Parent; + Module->m_LastEdit_Time = time(NULL); + + GetScreen()->SetModify(); + + Module->Draw(DrawPanel, DC, wxPoint(0,0),GR_XOR); + + EXCHG(Pad->m_Size.x, Pad->m_Size.y); + EXCHG(Pad->m_Drill.x, Pad->m_Drill.y); + EXCHG(Pad->m_Offset.x, Pad->m_Offset.y); + Pad->m_Offset.y = -Pad->m_Offset.y; + + EXCHG(Pad->m_DeltaSize.x,Pad->m_DeltaSize.y) ; + Pad->m_DeltaSize.x = -Pad->m_DeltaSize.x; /* ceci est la variation + de la dim Y sur l'axe X */ + + Module->Set_Rectangle_Encadrement(); + + Pad->Display_Infos(this); + Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); +} + + diff --git a/pcbnew/move_copy_track.cpp b/pcbnew/move_copy_track.cpp new file mode 100644 index 0000000000..2e0926c22c --- /dev/null +++ b/pcbnew/move_copy_track.cpp @@ -0,0 +1,645 @@ + /****************************************************/ + /* Edition des pistes */ + /* Routines de duplication et deplacement de pistes */ + /****************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "drag.h" + +#include "protos.h" + + +/* Routines externes */ + +static void Show_MoveTrack(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void Exit_MoveTrack(WinEDA_DrawPanel * Panel, wxDC *DC); + +#if 0 +/* Routines Locales */ +static void Duplic_Track(COMMAND * Cmd); +static void Place_Dupl_Route(COMMAND * Cmd); +#endif + +/* variables locales */ +static wxPoint PosInit, LastPos; +static TRACK * NewTrack; /* Nouvelle piste creee ou piste deplacee */ +static int NbPtNewTrack; +static int Old_HightLigth_NetCode; +static bool Old_HightLigt_Status; + + +/**************************************************************/ +static void Exit_MoveTrack(WinEDA_DrawPanel * Panel, wxDC *DC) +/***************************************************************/ +/* routine d'annulation de la commande drag, copy ou move track si une piste est en cours + de tracage, ou de sortie de l'application EDITRACK. + Appel par la touche ESC + */ +{ +TRACK * NextS; +int ii; + + + /* Effacement du trace en cours */ + wxPoint oldpos = Panel->GetScreen()->m_Curseur; + Panel->GetScreen()->m_Curseur = PosInit; + Panel->ManageCurseur(Panel, DC, TRUE); + Panel->GetScreen()->m_Curseur = oldpos; + g_HightLigt_Status = FALSE; + ( (WinEDA_PcbFrame *)Panel->m_Parent)->DrawHightLight( DC, g_HightLigth_NetCode) ; + + if( NewTrack ) + { + if (NewTrack->m_Flags & IS_NEW ) + { + for( ii = 0; ii < NbPtNewTrack; ii++, NewTrack = NextS) + { + if(NewTrack == NULL) break; + NextS = (TRACK*) NewTrack->Pnext; + delete NewTrack; + } + } + else /* Move : remise en ancienne position */ + { + TRACK * Track = NewTrack; + int dx = LastPos.x - PosInit.x; + int dy = LastPos.y - PosInit.y; + for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext) + { + if( Track == NULL ) break; + Track->m_Start.x -= dx; + Track->m_Start.y -= dy; + Track->m_End.x -= dx; + Track->m_End.y -= dy; + Track->m_Flags = 0; + + } + Trace_Une_Piste(Panel, DC, NewTrack,NbPtNewTrack,GR_OR); + } + + NewTrack = NULL; + } + + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + Panel->GetScreen()->m_CurrentItem = NULL; + Panel->m_Parent->EraseMsgBox(); + + /* Annulation deplacement et Redessin des segments dragges */ + DRAG_SEGM * pt_drag = g_DragSegmentList; + for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) + { + TRACK * Track = pt_drag->m_Segm; + pt_drag->SetInitialValues(); + Track->SetState(EDIT,OFF); + Track->m_Flags = 0; + Track->Draw(Panel, DC, GR_OR); + } + + g_HightLigth_NetCode = Old_HightLigth_NetCode; + g_HightLigt_Status = Old_HightLigt_Status; + if(g_HightLigt_Status) + ( (WinEDA_PcbFrame *)Panel->m_Parent)->DrawHightLight( DC, g_HightLigth_NetCode) ; + + EraseDragListe(); +} + + + +/*************************************************************************/ +static void Show_MoveTrack(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/*************************************************************************/ +/* redessin du contour de la piste lors des deplacements de la souris */ +{ +int ii, dx, dy; +TRACK * Track; +BASE_SCREEN * screen = panel->GetScreen(); +int track_fill_copy = DisplayOpt.DisplayPcbTrackFill; + + DisplayOpt.DisplayPcbTrackFill = SKETCH ; + +erase = TRUE; + + /* efface ancienne position si elle a ete deja dessinee */ + if( erase ) + { + if ( NewTrack ) Trace_Une_Piste(panel, DC, NewTrack,NbPtNewTrack,GR_XOR) ; + } + + /* mise a jour des coordonnees des segments de la piste */ + wxPoint Pos = screen->m_Curseur; + dx = Pos.x - LastPos.x; + dy = Pos.y - LastPos.y; + LastPos = Pos; + ii = NbPtNewTrack, Track = NewTrack; + for( ; ii > 0; ii--, Track = Track->Next() ) + { + if( Track->m_Flags & STARTPOINT) + { + Track->m_Start.x += dx; Track->m_Start.y += dy; + } + if( Track->m_Flags & ENDPOINT) + { + Track->m_End.x += dx; Track->m_End.y += dy; + } + } + + /* dessin de la nouvelle piste */ + Trace_Une_Piste(panel, DC, NewTrack,NbPtNewTrack,GR_XOR) ; + + /* Tracage des segments dragges */ + DRAG_SEGM * pt_drag = g_DragSegmentList; + for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) + { + Track = pt_drag->m_Segm; + if ( erase ) Track->Draw(panel, DC, GR_XOR); + if( Track->m_Flags & STARTPOINT) + { + Track->m_Start.x += dx; Track->m_Start.y += dy; + } + if( Track->m_Flags & ENDPOINT) + { + Track->m_End.x += dx; Track->m_End.y += dy; + } + Track->Draw(panel, DC, GR_XOR); + } + DisplayOpt.DisplayPcbTrackFill = track_fill_copy ; +} + + + +/***********************************************************************************/ +void WinEDA_PcbFrame::Start_MoveOneTrackSegment(TRACK * track, wxDC * DC, bool Drag) +/***********************************************************************************/ +{ + /* Change hight light net: the new one will be hightlighted */ + Old_HightLigt_Status = g_HightLigt_Status; + Old_HightLigth_NetCode = g_HightLigth_NetCode; + if(g_HightLigt_Status) Hight_Light(DC); + + if ( Drag && track->m_StructType == TYPEVIA) + { + track->m_Flags = IS_DRAGGED|STARTPOINT|ENDPOINT; + Collect_TrackSegmentsToDrag(DrawPanel, DC, track->m_Start, + track->ReturnMaskLayer(), track->m_NetCode); + NewTrack = track; + NbPtNewTrack = 1; + PosInit = track->m_Start; + } + + else + { + int diag = track->IsPointOnEnds(GetScreen()->m_Curseur, -1); + wxPoint pos = (diag & STARTPOINT) ? track->m_Start : track->m_End; + Collect_TrackSegmentsToDrag(DrawPanel, DC, pos, + track->ReturnMaskLayer(), track->m_NetCode); + track->m_Flags |= IS_DRAGGED; + NewTrack = NULL; + NbPtNewTrack = 0; + PosInit = pos; + } + LastPos = PosInit; + DrawPanel->ManageCurseur = Show_MoveTrack; + DrawPanel->ForceCloseManageCurseur = Exit_MoveTrack; + + g_HightLigth_NetCode = track->m_NetCode; + g_HightLigt_Status = TRUE; + DrawHightLight( DC, g_HightLigth_NetCode) ; + DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); +} + + + +/**********************************************************************/ +bool WinEDA_PcbFrame::PlaceDraggedTrackSegment(TRACK * Track, wxDC * DC) +/**********************************************************************/ +/* Place a dragged track segment or via */ +{ +int errdrc; +DRAG_SEGM * pt_drag; + + if(Track == NULL ) return FALSE; + + // DRC control: + if(Drc_On) + { + errdrc = Drc(this, DC, Track, m_Pcb->m_Track,1); + if(errdrc == BAD_DRC) return FALSE; + /* Tracage des segments dragges */ + pt_drag = g_DragSegmentList; + for( ; pt_drag; pt_drag = pt_drag->Pnext) + { + errdrc = Drc(this, DC, pt_drag->m_Segm, m_Pcb->m_Track,1); + if(errdrc == BAD_DRC) return FALSE; + } + } + + // DRC Ok: place track segments + Track->m_Flags = 0; + Track->Draw(DrawPanel, DC, GR_OR); + + /* Tracage des segments dragges */ + pt_drag = g_DragSegmentList; + for( ; pt_drag; pt_drag = pt_drag->Pnext) + { + Track = pt_drag->m_Segm; + Track->SetState(EDIT,OFF); + Track->m_Flags = 0; + Track->Draw(DrawPanel, DC, GR_OR); + } + EraseDragListe(); + + GetScreen()->SetModify(); + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + + return TRUE; +} + + +#if 0 + +/***********************************************/ +void WinEDA_PcbFrame::Place_Dupl_Route(Track * Track, wxDC * DC) +/******************************************/ +/* + Routine de placement d'une piste (succession de segments) +*/ +{ +D_PAD * pt_pad; +TRACK * pt_track, *Track, * pt_classe, *NextS; +int masquelayer; +EDA_BaseStruct * LockPoint; +int ii, old_net_code, new_net_code, DRC_error = 0; +wxDC * DC = Cmd->DC; + + ActiveDrawPanel->ManageCurseur = NULL; + + if( NewTrack == NULL ) return ; + + old_net_code = NewTrack->net_code; + + /* Placement du flag BUSY de la piste originelle, qui ne doit + pas etre vue dans les recherches de raccordement suivantes */ + ii = NbPtNewTrack; pt_track = NewTrack; + for ( ; ii > 0; ii --, pt_track = (TRACK*) pt_track->Pnext) + { + pt_track->SetState(BUSY, ON); + } + + /* Detection du nouveau net_code */ + ii = NbPtNewTrack; pt_track = NewTrack; + for ( ; ii > 0; ii --, pt_track = (TRACK*) pt_track->Pnext) + { + pt_track->net_code = 0; + } + + new_net_code = 0; + ii = 0; pt_track = NewTrack; + for( ; ii < NbPtNewTrack ; ii++, pt_track = (TRACK*)pt_track->Pnext) + { + /* Localisation de la pastille ou segment en debut de segment: */ + masquelayer = tab_layer[pt_track->Layer]; + LockPoint = LocateLockPoint(pt_track->m_Start.x,pt_track->m_Start.y,masquelayer); + if( LockPoint ) + { + if ( LockPoint->m_StructType == TYPEPAD ) + { + pt_pad = (D_PAD*) LockPoint; + new_net_code = pt_pad->net_code; + if ( new_net_code > 0 ) break; + } + else /* debut de piste sur un segment de piste */ + { + Track = (TRACK *) LockPoint; + new_net_code = Track->net_code; + if ( new_net_code > 0 ) break; + } + } + LockPoint = LocateLockPoint(pt_track->m_End.x,pt_track->m_End.y,masquelayer); + if( LockPoint ) + { + if ( LockPoint->m_StructType == TYPEPAD ) + { + pt_pad = (D_PAD*) LockPoint; + new_net_code = pt_pad->net_code; + if ( new_net_code > 0 ) break; + } + else /* debut de piste sur un segment de piste */ + { + Track = (TRACK *) LockPoint; + new_net_code = Track->net_code; + if ( new_net_code > 0 ) break; + } + } + } + + /* Mise a jour du nouveau net code de la piste */ + ii = 0; pt_track = NewTrack; + for( ; ii < NbPtNewTrack; ii++, pt_track = (TRACK*)pt_track->Pnext) + { + pt_track->net_code = new_net_code; + } + + /* Controle DRC de la nouvelle piste */ + ii = 0; pt_track = NewTrack; + for( ; ii < NbPtNewTrack; ii++, pt_track = pt_track->Next() ) + { + if( Drc_On == RUN ) + if( drc(DC, pt_track, pt_pcb->Track, 1) == BAD_DRC ) + { + if( confirmation(" Erreur DRC, Place piste:") == YES ) continue; + else { DRC_error = 1; break; } + } + } + + if( DRC_error == 0) + { + if(FlagState == MOVE_ROUTE) + { + /* copie nouvelle piste */ + pt_track = NewTrack; + NewTrack = pt_track->Copy(NbPtNewTrack); + /* effacement ancienne ( chainage et liens mauvais */ + ii = NbPtNewTrack; + for ( ; ii > 0; ii --, pt_track = NextS) + { + NextS = (TRACK*) pt_track->Pnext; + DeleteStructure(pt_track); + } + test_1_net_connexion(DC, old_net_code ); + } + + pt_classe = NewTrack->GetBestInsertPoint(); + NewTrack->Insert(pt_classe); + + Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_OR) ; + + /* Mise a jour des connexions sur pads et sur pistes */ + ii = 0; pt_track = NewTrack; + for( ; ii < NbPtNewTrack; ii++, pt_track = NextS) + { + NextS = (TRACK*)pt_track->Pnext; + pt_track->SetState(BEGIN_ONPAD|END_ONPAD, OFF); + masquelayer = tab_layer[pt_track->Layer]; + + /* Localisation de la pastille ou segment sur debut segment: */ + LockPoint = LocateLockPoint(pt_track->m_Start.x,pt_track->m_Start.y,masquelayer); + if( LockPoint ) + { + pt_track->start = LockPoint; + if ( LockPoint->m_StructType == TYPEPAD ) + { /* fin de piste sur un pad */ + pt_pad = (D_PAD*) LockPoint; + pt_track->SetState(BEGIN_ONPAD, ON); + } + else /* debut de piste sur un segment de piste */ + { + Track = (TRACK *) LockPoint; + CreateLockPoint(&pt_track->m_Start.x,&pt_track->m_Start.y,Track,pt_track); + } + } + + /* Localisation de la pastille ou segment sur fin de segment: */ + LockPoint = LocateLockPoint(pt_track->m_End.x,pt_track->m_End.y,masquelayer); + if( LockPoint ) + { + pt_track->end = LockPoint; + if ( LockPoint->m_StructType == TYPEPAD ) + { /* fin de piste sur un pad */ + pt_pad = (D_PAD*) LockPoint; + pt_track->SetState(END_ONPAD, ON); + } + else /* debut de piste sur un segment de piste */ + { + Track = (TRACK *) LockPoint; + CreateLockPoint(&pt_track->m_Start.x,&pt_track->m_Start.y,Track,pt_track); + } + } + } + + /* Suppression du flag BUSY */ + ii = NbPtNewTrack; pt_track = NewTrack; + for ( ; ii > 0; ii --, pt_track = (TRACK*) pt_track->Pnext) + { + pt_track->SetState(BUSY, OFF); + } + + test_1_net_connexion(DC, new_net_code ); + ActiveScreen->SetModify(); + } + + else /* Erreur DRC: Annulation commande */ + { + DisplayOpt.DisplayPcbTrackFill = SKETCH ; + Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_XOR); + DisplayOpt.DisplayPcbTrackFill = Track_fill_copy ; + + if(FlagState == MOVE_ROUTE) + { /* Remise en position de la piste deplacee */ + Track = NewTrack; + PosInitX -= Track->m_Start.x; PosInitY -= Track->m_Start.y; + for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext) + { + if( Track == NULL ) break; + Track->m_Start.x += PosInitX; Track->m_Start.y += PosInitY; + Track->m_End.x += PosInitX; Track->m_End.y += PosInitY; + Track->SetState(BUSY,OFF); + } + Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_OR); + } + + if (FlagState == COPY_ROUTE ) + { /* Suppression copie */ + for( ii = 0; ii < NbPtNewTrack; NewTrack = NextS) + { + if(NewTrack == NULL) break; + NextS = (TRACK*) NewTrack->Pnext; + delete NewTrack; + } + } + } + NewTrack = NULL; + Affiche_Infos_Status_Pcb(Cmd); + if(Etat_Surbrillance) Hight_Light(DC); +} + +/************************************************/ +void WinEDA_PcbFrame::Start_CopieMove_Route(TRACK * track, wxDC * DC, bool Drag) +/************************************************/ +/* Routine permettant la recopie d'une piste (suite de segments) deja tracee +*/ +{ +int ii; +TRACK *pt_segm, *pt_track; +int masquelayer = tab_layer[ActiveScreen->Active_Layer]; +wxDC * DC = Cmd->DC; + + if( NewTrack ) return; + + FlagState = (int)Cmd->Menu->param_inf; + + /* Recherche de la piste sur la couche active (non zone) */ + for(pt_segm = pt_pcb->Track; pt_segm != NULL; pt_segm = (TRACK*)pt_segm->Pnext) + { + pt_segm = Locate_Pistes(pt_segm,masquelayer, CURSEUR_OFF_GRILLE); + if( pt_segm == NULL ) break ; + break ; + } + + if( pt_segm != NULL ) + { + if (FlagState == COPY_ROUTE ) + pt_track = Marque_Une_Piste(DC, pt_segm, &NbPtNewTrack, 0); + else pt_track = Marque_Une_Piste(DC, pt_segm, &NbPtNewTrack, GR_XOR); + + if(NbPtNewTrack) /* Il y a NbPtNewTrack segments de piste a traiter */ + { + /* effacement du flag BUSY de la piste originelle */ + ii = NbPtNewTrack; pt_segm = pt_track; + for ( ; ii > 0; ii --, pt_segm = (TRACK*) pt_segm->Pnext) + { + pt_segm->SetState(BUSY, OFF); + } + + if (FlagState == COPY_ROUTE ) + NewTrack = pt_track->Copy(NbPtNewTrack); + else NewTrack = pt_track; + + Affiche_Infos_Piste(Cmd, pt_track) ; + + startX = ActiveScreen->Curseur_X; + startY = ActiveScreen->Curseur_Y; + Place_Dupl_Route_Item.State = WAIT; + ActiveDrawPanel->ManageCurseur = Show_Move_Piste; + DisplayOpt.DisplayPcbTrackFill = SKETCH ; + Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_XOR) ; + DisplayOpt.DisplayPcbTrackFill = Track_fill_copy ; + PosInitX = NewTrack->m_Start.x; PosInitY = NewTrack->m_Start.y; + } + } +} + + +#endif + +/************************************************************************/ +EDA_BaseStruct * LocateLockPoint(BOARD * Pcb, wxPoint pos, int LayerMask) +/************************************************************************/ +/* Routine trouvant le point " d'accrochage " d'une extremite de piste. + Ce point peut etre un PAD ou un autre segment de piste + Retourne: + - pointeur sur ce PAD ou: + - pointeur sur le segment ou: + - NULL + Parametres d'appel: + coord pX, pY du point tst + masque des couches a tester +*/ +{ +D_PAD * pt_pad; +TRACK * ptsegm; +MODULE * Module; + + /* detection du point type PAD */ + pt_pad = NULL; + Module = Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE*)Module->Pnext ) + { + pt_pad = Locate_Pads(Module, pos, LayerMask); + if (pt_pad) return(pt_pad); + } + + /* ici aucun pad n'a ete localise: detection d'un segment de piste */ + + ptsegm = Fast_Locate_Piste( Pcb->m_Track, NULL, pos, LayerMask); + if( ptsegm == NULL ) + ptsegm = Locate_Pistes( Pcb->m_Track, pos, LayerMask); + return(ptsegm); +} + + +/******************************************************************************/ +TRACK * CreateLockPoint(int *pX, int *pY, TRACK * ptsegm, TRACK * refsegm) +/******************************************************************************/ +/* Routine de creation d'un point intermediaire sur un segment + le segment ptsegm est casse en 2 segments se raccordant au point pX, pY + retourne: + NULL si pas de nouveau point ( c.a.d si pX, pY correspondait deja + a une extremite ou: + pointeur sur le segment cree + si refsegm != NULL refsegm est pointeur sur le segment incident, + et le point cree est l'intersection des 2 axes des segments ptsegm et + refsegm + retourne la valeur exacte de pX et pY + Si ptsegm pointe sur une via: + retourne la valeur exacte de pX et pY et ptsegm, + mais ne cree pas de point supplementaire + +*/ +{ +int cX, cY; +int dx, dy; /* Coord de l'extremite du segm ptsegm / origine */ +int ox, oy, fx , fy; /* coord de refsegm / origine de prsegm */ +TRACK * NewTrack; + + if( (ptsegm->m_Start.x == *pX) && (ptsegm->m_Start.y == *pY) ) return(NULL); + if( (ptsegm->m_End.x == *pX) && (ptsegm->m_End.y == *pY) ) return(NULL); + + /* le point n'est pas sur une extremite de piste */ + if(ptsegm->m_StructType == TYPEVIA ) + { + *pX = ptsegm->m_Start.x; *pY = ptsegm->m_Start.y; + return(ptsegm); + } + /* calcul des coord vraies du point intermediaire dans le repere d'origine + = origine de ptsegm */ + cX = *pX - ptsegm->m_Start.x; + cY = *pY - ptsegm->m_Start.y; + dx = ptsegm->m_End.x - ptsegm->m_Start.x; + dy = ptsegm->m_End.y - ptsegm->m_Start.y; + +// ***** A COMPLETER : non utilise + if ( refsegm ) + { + ox = refsegm->m_Start.x - ptsegm->m_Start.x; + oy = refsegm->m_Start.y - ptsegm->m_Start.y; + fx = refsegm->m_End.x - ptsegm->m_Start.x; + fy = refsegm->m_End.y - ptsegm->m_Start.y; + } + + /* pour que le point soit sur le segment ptsegm: cY/cX = dy/dx */ + if ( dx == 0 ) cX = 0; /* segm horizontal */ + else cY = (cX * dy) / dx; + + /* creation du point intermediaire ( c'est a dire creation d'un nouveau + segment, debutant au point intermediaire */ + + cX += ptsegm->m_Start.x; cY += ptsegm->m_Start.y; + NewTrack = ptsegm->Copy(); + + NewTrack->Insert(NULL, ptsegm); + /* correction du pointeur de fin du nouveau segment */ + NewTrack->end = ptsegm->end; + + /* le segment primitif finit au nouveau point : */ + ptsegm->m_End.x = cX; ptsegm->m_End.y = cY; + ptsegm->SetState(END_ONPAD, OFF); + + /* le nouveau segment debute au nouveau point : */ + ptsegm = NewTrack;; + ptsegm->m_Start.x = cX; ptsegm->m_Start.y = cY; + ptsegm->SetState(BEGIN_ONPAD, OFF); + *pX = cX; *pY = cY; + + return(ptsegm); + +} + + diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp new file mode 100644 index 0000000000..4a37d03776 --- /dev/null +++ b/pcbnew/muonde.cpp @@ -0,0 +1,707 @@ + /****************************************************/ + /* Gestion des composants specifiques aux microndes */ + /****************************************************/ + + /* Fichier MUONDE.CPP */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "trigo.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "drag.h" + +#include +#include "protos.h" + +/* fonctions importees */ + +/* Fonctions locales */ +static void Exit_Muonde(WinEDA_DrawFrame * frame, wxDC *DC); + +/* Variables locales : */ +#define COEFF_COUNT 6 +double * PolyEdges; +int PolyEdgesCount; +double ShapeScaleX, ShapeScaleY; +wxSize ShapeSize; +int PolyShapeType; + +#include "gen_self.h" + +/***************************************************************************/ +MODULE * WinEDA_PcbFrame::Create_MuWaveBasicShape(wxDC * DC, + const wxString & name, int pad_count) +/***************************************************************************/ +/* Create a footprint with pad_count pads for micro wave applications +This footprint has pad_count pads: + SMD, rectangular, H size = V size = current track width. +*/ +{ +MODULE * Module; +int pad_num = 1; +wxString Line; + + Module = Create_1_Module(DC, name); + if ( Module == NULL ) return NULL; + + Module->m_TimeStamp = GetTimeStamp(); + Module->m_Value->m_Size = wxSize(30,30); + Module->m_Value->m_Pos0.y = -30; + Module->m_Value->m_Pos.y += Module->m_Value->m_Pos0.y; + Module->m_Reference->m_Size = wxSize(30,30); + Module->m_Reference->m_Pos0.y = 30; + Module->m_Reference->m_Pos.y += Module->m_Reference->m_Pos0.y; + + /* Creation des pastilles formant le gap */ + while ( pad_count -- ) + { + D_PAD* pad; + pad = new D_PAD(Module); + pad->Pback = Module; + if ( Module->m_Pads == NULL ) + { + Module->m_Pads = pad; + } + else + { + Module->m_Pads->Pback = pad; + pad->Pnext = Module->m_Pads; + Module->m_Pads = pad; + } + pad->m_Size.x = pad->m_Size.y = g_DesignSettings.m_CurrentTrackWidth; + pad->m_Pos = Module->m_Pos; + pad->m_PadShape = RECT; + pad->m_Attribut = SMD; + pad->m_Masque_Layer = CMP_LAYER; + Line.Printf( wxT("%d"), pad_num); + pad->SetPadName(Line); + pad_num++; + } + + if (DC) Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ; + return Module; +} + + + +/**********************************************************/ +static void Exit_Muonde(WinEDA_DrawFrame * frame, wxDC *DC ) +/**********************************************************/ +{ +MODULE * Module = (MODULE*) frame->m_CurrentScreen->m_CurrentItem; + + if( Module ) + { + if ( Module->m_Flags & IS_NEW) + { + Module->Draw(frame->DrawPanel, DC, wxPoint(0,0), GR_XOR) ; + DeleteStructure( Module); + } + else + { + Module->Draw(frame->DrawPanel, DC, wxPoint(0,0), GR_XOR) ; + } + } + + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; + frame->m_CurrentScreen->m_CurrentItem = NULL; +} + + +/***************************************************************************/ +MODULE * WinEDA_PcbFrame::Create_MuWaveComponent(wxDC * DC, int shape_type) +/***************************************************************************/ +/* Create a module "GAP" or "STUB" +This a "gap" or "stub" used in micro wave designs +This modue has 2 pads: + SMD, rectangular, H size = V size = current track width. + the "gap" is isolation created between this 2 pads +*/ +{ +int gap_size, oX, ii; +float fcoeff; +D_PAD* pt_pad; +MODULE * Module; +wxString msg, cmp_name; +int pad_count = 2; +int angle = 0; +bool abort; + + /* Entree de la longueur desiree du gap*/ + gap_size = g_DesignSettings.m_CurrentTrackWidth; // Valeur raisonnable + + switch ( shape_type ) + { + case 0: + msg = _("Gap"); + cmp_name = wxT("GAP"); + break; + + case 1: + msg = _("Stub"); + cmp_name = wxT("STUB"); + pad_count = 2; + break; + + case 2: + msg = _("Arc Stub"); + cmp_name = wxT("ASTUB"); + pad_count = 1; + break; + + default: + msg = wxT("???"); + break; + } + +wxString value; + if( g_UnitMetric) + { + fcoeff = 10000.0/25.4 ; + value.Printf( wxT("%2.4f"),gap_size / fcoeff); + msg += _(" (mm):"); + abort = Get_Message(msg,value, this); + } + else + { + fcoeff = 10000.0 ; + value.Printf( wxT("%2.3f"),gap_size / fcoeff); + msg += _(" (inch):"); + abort = Get_Message(msg, value, this); + } + + double fval; + if ( ! value.ToDouble(&fval) ) + { + DisplayError(this, _("Incorrect number, abort")); + abort = TRUE; + } + gap_size = ABS( (int) round( fval * fcoeff )); + + if ( ! abort && (shape_type == 2) ) + { + fcoeff = 10.0 ; + value.Printf( wxT("%3.1f"),angle / fcoeff); + msg = _("Angle (0.1deg):"); + abort = Get_Message(msg, value, this); + if ( ! value.ToDouble(&fval) ) + { + DisplayError(this, _("Incorrect number, abort")); + abort = TRUE; + } + angle = ABS( (int) round( fval * fcoeff )); + if ( angle > 1800 ) angle = 1800; + } + + if (abort) + { + DrawPanel->MouseToCursorSchema(); + return NULL; + } + + Module = Create_MuWaveBasicShape(NULL, cmp_name, pad_count); + pt_pad = Module->m_Pads; + + switch ( shape_type ) + { + case 0: //Gap : + oX = pt_pad->m_Pos0.x = - (gap_size + pt_pad->m_Size.x) / 2; + pt_pad->m_Pos.x += pt_pad->m_Pos0.x; + + pt_pad = (D_PAD *) pt_pad->Pnext; + pt_pad->m_Pos0.x = oX + gap_size + pt_pad->m_Size.x; + pt_pad->m_Pos.x += pt_pad->m_Pos0.x; + break; + + case 1: //Stub : + pt_pad->SetPadName( wxT("1")); + pt_pad = (D_PAD *) pt_pad->Pnext; + pt_pad->m_Pos0.y = -(gap_size + pt_pad->m_Size.y) /2; + pt_pad->m_Size.y = gap_size; + pt_pad->m_Pos.y += pt_pad->m_Pos0.y; + break; + + case 2: //Arc Stub : + { + EDGE_MODULE * edge; int * ptr, theta; + ii = angle / 50; + edge = new EDGE_MODULE(Module); + Module->m_Drawings = edge; + edge->Pback = Module; + edge->m_Shape = S_POLYGON; + edge->m_Layer = LAYER_CMP_N; + edge->m_PolyCount = ii + 3; + edge->m_PolyList = (int*) MyMalloc( edge->m_PolyCount * 2 * sizeof(int) ); + ptr = edge->m_PolyList; + edge->m_Start0.y = - pt_pad->m_Size.y / 2; + + * ptr = 0; ptr++; + * ptr = 0; ptr++; + theta = - angle/2; + for ( ii = 1; ii < edge->m_PolyCount - 1; ii ++) + { + int x, y; + x = 0; y = - gap_size; + RotatePoint(&x, &y, theta); + * ptr = x; ptr++; *ptr = y; ptr++; + theta += 50; + if ( theta > angle/2) theta = angle/2; + } + *ptr = edge->m_PolyList[0]; ptr++; + *ptr = edge->m_PolyList[1]; + break; + } + + default: + break; + } + + Module->Set_Rectangle_Encadrement(); + Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ; + DrawPanel->MouseToCursorSchema(); + m_Pcb->m_Status_Pcb = 0 ; + m_CurrentScreen->SetModify(); + return Module; +} + + + + +/**************** Polygon Shapes ***********************/ + +enum id_mw_cmd +{ + ID_ACCEPT_OPT = 1000, + ID_CANCEL_OPT, + ID_READ_SHAPE_FILE +}; + +/*************************************************/ +class WinEDA_SetParamShapeFrame: public wxDialog +/*************************************************/ +/* Reglages des parametres des forme polynomiales +*/ +{ +private: + WinEDA_PcbFrame * m_Parent; + wxRadioBox * m_ShapeOptionCtrl; + WinEDA_SizeCtrl * m_SizeCtrl; + +public: + // Constructor and destructor + WinEDA_SetParamShapeFrame(WinEDA_PcbFrame *parent,const wxPoint& pos); + ~WinEDA_SetParamShapeFrame(void) {}; + +private: + void OnCloseWindow(wxCloseEvent & event); + void OnCancel(wxCommandEvent& event); + void ReadDataShapeDescr(wxCommandEvent& event); + void AcceptOptions(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() + +}; +/* Construction de la table des evenements pour WinEDA_SetParamShapeFrame */ +BEGIN_EVENT_TABLE(WinEDA_SetParamShapeFrame, wxDialog) + EVT_BUTTON(ID_ACCEPT_OPT, WinEDA_SetParamShapeFrame::AcceptOptions) + EVT_BUTTON(ID_CANCEL_OPT, WinEDA_SetParamShapeFrame::OnCancel) + EVT_BUTTON(ID_READ_SHAPE_FILE, WinEDA_SetParamShapeFrame::ReadDataShapeDescr) +END_EVENT_TABLE() + + + + /*************************************************/ + /* Constructeur de WinEDA_SetParamShapeFrame */ + /************************************************/ + +WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame(WinEDA_PcbFrame *parent, + const wxPoint& framepos): + wxDialog(parent, -1, _("Complex shape"), framepos, wxSize(350, 280), + DIALOG_STYLE ) +{ + m_Parent = parent; + SetFont(*g_DialogFont); + + if ( PolyEdges ) free(PolyEdges); + PolyEdges = NULL; + PolyEdgesCount = 0; + + wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(MainBoxSizer); + wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton * Button = new wxButton(this, ID_ACCEPT_OPT, _("Ok")); + Button->SetForegroundColour(*wxRED); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Button = new wxButton(this, ID_CANCEL_OPT, _("Cancel")); + Button->SetForegroundColour(*wxBLUE); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Button = new wxButton(this, ID_READ_SHAPE_FILE, _("Read Shape Descr File")); + Button->SetForegroundColour(wxColor(0,100,0) ); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + +wxString shapelist[3] = { _("Normal"), _("Symmetrical"), _("mirrored") }; + m_ShapeOptionCtrl = new wxRadioBox(this, -1, _("ShapeOption"), + wxDefaultPosition, wxDefaultSize, 3, shapelist, 1, wxRA_SPECIFY_COLS); + LeftBoxSizer->Add(m_ShapeOptionCtrl, 0, wxGROW|wxALL, 5); + + m_SizeCtrl = new WinEDA_SizeCtrl(this, _("Size"), + ShapeSize, + g_UnitMetric, LeftBoxSizer, PCB_INTERNAL_UNIT) ; + + + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); +} + +/**********************************************************************/ +void WinEDA_SetParamShapeFrame::OnCancel(wxCommandEvent& WXUNUSED(event)) +/**********************************************************************/ +{ + if ( PolyEdges ) free(PolyEdges); + PolyEdges = NULL; + PolyEdgesCount = 0; + EndModal(0); +} + + +/*******************************************************************/ +void WinEDA_SetParamShapeFrame::AcceptOptions(wxCommandEvent& event) +/*******************************************************************/ +{ + ShapeSize = m_SizeCtrl->GetValue(); + PolyShapeType = m_ShapeOptionCtrl->GetSelection(); + EndModal(1); +} + +/************************************************************************/ +void WinEDA_SetParamShapeFrame::ReadDataShapeDescr(wxCommandEvent& event) +/************************************************************************/ +/* Read a description shape file +File format is +Unit=MM +XScale=271.501 +YScale=1.00133 + +$COORD +0 0.6112600148417837 +0.001851851851851852 0.6104800531118608 +.... +$ENDCOORD + +Each line is the X Y coord (normalised units from 0 to 1) +*/ +{ +wxString FullFileName; +wxString ext, mask; +FILE * File; +char Line[1024]; +double unitconv = 10000; +char * param1, *param2; +int bufsize; +double * ptbuf; + + ext = wxT(".txt"); + mask = wxT("*") + ext; + FullFileName = EDA_FileSelector(_("Read descr shape file"), + wxEmptyString, /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + ext, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_OPEN, + TRUE /* ne change pas de repertoire courant */ + ); + if ( FullFileName.IsEmpty()) return; + + File = wxFopen(FullFileName, wxT("rt")); + + if ( File == NULL ) + { + DisplayError(this, _("File not found") ); + return; + } + + + bufsize = 100; + ptbuf = PolyEdges = (double*) MyZMalloc( bufsize * 2 * sizeof(double)); + + int LineNum = 0; + while( GetLine(File, Line, &LineNum , sizeof(Line) -1) != NULL ) + { + from_point(Line); + + param1 = strtok(Line," =\n\r"); + param2 = strtok(NULL," \t\n\r"); + + if ( strnicmp(param1, "Unit", 4) == 0) + { + if ( strnicmp(param2, "inch", 4) == 0) unitconv = 10000; + if ( strnicmp(param2, "mm", 2) == 0) unitconv = 10000/25.4; + } + if ( strnicmp(param1, "$ENDCOORD", 8) == 0) break; + if ( strnicmp(param1, "$COORD", 6) == 0) + { + while( GetLine(File, Line, &LineNum , sizeof(Line) -1) != NULL ) + { + from_point(Line); + param1 = strtok(Line," \t\n\r"); + param2 = strtok(NULL," \t\n\r"); + if ( strnicmp(param1, "$ENDCOORD", 8) == 0) break; + if ( bufsize <= PolyEdgesCount ) + { + int index = ptbuf - PolyEdges; + bufsize *= 2; + ptbuf = PolyEdges = (double*) realloc( PolyEdges, bufsize * 2 * sizeof(double)); + ptbuf += index; + } + * ptbuf = atof(param1); + ptbuf++; + * ptbuf = atof(param2); + ptbuf++; + PolyEdgesCount++; + } + } + if ( strnicmp(Line, "XScale", 6) == 0) + { + ShapeScaleX = atof(param2); + } + if ( strnicmp(Line, "YScale", 6) == 0) + { + ShapeScaleY = atof(param2); + } + } + + if ( PolyEdgesCount == 0 ) + { + free(PolyEdges); + PolyEdges = NULL; + } + fclose( File); + + ShapeScaleX *= unitconv; + ShapeScaleY *= unitconv; + + m_SizeCtrl->SetValue( (int) ShapeScaleX, (int) ShapeScaleY); +} + + +/*************************************************************/ +MODULE * WinEDA_PcbFrame::Create_MuWavePolygonShape(wxDC * DC) +/*************************************************************/ +{ +D_PAD * pad1, *pad2; +MODULE * Module; +wxString cmp_name; +int pad_count = 2; +EDGE_MODULE * edge; int * ptr; +int ii, npoints; + +WinEDA_SetParamShapeFrame * frame = new WinEDA_SetParamShapeFrame(this, wxPoint(-1,-1)); + int ok = frame->ShowModal(); frame->Destroy(); + + DrawPanel->MouseToCursorSchema(); + + if ( ok != 1 ) + { + if ( PolyEdges ) free(PolyEdges); + PolyEdges = NULL; + PolyEdgesCount = 0; + return NULL; + } + + if ( PolyShapeType == 2 ) // mirrored + ShapeScaleY = - ShapeScaleY; + ShapeSize.x = (int) round( ShapeScaleX); + ShapeSize.y = (int) round( ShapeScaleY); + + if ( (ShapeSize.x) == 0 || (ShapeSize.y == 0) ) + { + DisplayError(this, _("Shape has a null size!") ); + return NULL; + } + if (PolyEdgesCount == 0) + { + DisplayError(this, _("Shape has no points!") ); + return NULL; + } + + cmp_name = wxT("POLY"); + + Module = Create_MuWaveBasicShape(NULL, cmp_name, pad_count); + pad1 = Module->m_Pads; + + pad1->m_Pos0.x = - ShapeSize.x / 2; + pad1->m_Pos.x += pad1->m_Pos0.x; + + pad2 = (D_PAD *) pad1->Pnext; + pad2->m_Pos0.x = pad1->m_Pos0.x + ShapeSize.x; + pad2->m_Pos.x += pad2->m_Pos0.x; + + edge = new EDGE_MODULE(Module); + Module->m_Drawings = edge; + edge->Pback = Module; + edge->m_Shape = S_POLYGON; + edge->m_Layer = LAYER_CMP_N; + npoints = PolyEdgesCount; + switch (PolyShapeType) + { + case 0: // Single + case 2: // Single, mirrored + edge->m_PolyCount = PolyEdgesCount + 2; + break; + + case 1: // Symetric + edge->m_PolyCount = (2 * PolyEdgesCount) + 2; + break; + } + + edge->m_PolyList = (int*) MyMalloc( edge->m_PolyCount * 2 * sizeof(int) ); + + ptr = edge->m_PolyList; + // Init start point coord: + * ptr = pad1->m_Pos0.x; ptr++; + * ptr = 0; ptr++; + + double * dptr = PolyEdges; + wxPoint first_cordinate, last_cordinate; + for ( ii = 0; ii < npoints; ii ++) // Copy points + { + last_cordinate.x = * ptr = (int)round(*dptr * ShapeScaleX) + pad1->m_Pos0.x; + dptr++; ptr++; + last_cordinate.y = *ptr = - (int) round( *dptr * ShapeScaleY); + dptr++; ptr++; + } + first_cordinate.y = edge->m_PolyList[3]; + + switch (PolyShapeType) + { + int * ptr1; + case 0: // Single + case 2: // Single mirrored + // Init end point coord: + * ptr = pad2->m_Pos0.x = last_cordinate.x; ptr++; + * ptr = 0; + pad1->m_Size.x = pad1->m_Size.y = ABS(first_cordinate.y); + pad2->m_Size.x = pad2->m_Size.y = ABS(last_cordinate.y); + pad1->m_Pos0.y = first_cordinate.y/2; + pad2->m_Pos0.y = last_cordinate.y/2; + pad1->m_Pos.y = pad1->m_Pos0.y + Module->m_Pos.y; + pad2->m_Pos.y = pad2->m_Pos0.y + Module->m_Pos.y; + break; + + case 1: // Symetric + ptr1 = ptr-2; + for ( ii = 0; ii <= npoints; ii ++) + { + * ptr = * ptr1; // Copy X coord + ptr++; + *ptr = - *(ptr1+1); // Copy Y coord, mirror X axis + ptr1 -= 2; ptr++; + } + pad1->m_Size.x = pad1->m_Size.y = 2 * ABS(first_cordinate.y); + pad2->m_Size.x = pad2->m_Size.y = 2 * ABS(last_cordinate.y); + break; + } + + free(PolyEdges); + PolyEdgesCount = 0; + PolyEdges = NULL; + + Module->Set_Rectangle_Encadrement(); + Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ; + m_Pcb->m_Status_Pcb = 0 ; + m_CurrentScreen->SetModify(); + return Module; +} + + + +/***************************************************************/ +void WinEDA_PcbFrame::Edit_Gap(wxDC * DC, MODULE * Module) +/***************************************************************/ +/* +Edit le module GAP, c'est a dire modifie la position et la taille +des pastilles formant le gap pour obtenir une nouvelle valeur du gap + */ +{ +int gap_size, oX; +float fcoeff; +D_PAD* pad, * next_pad; +wxString msg; + + if( Module == NULL) return; /* Module non trouve */ + + /* Test si module = gap ( nom commence par GAP, et 2 pastilles) */ + msg = Module->m_Reference->m_Text.Left(3); + if( msg != wxT("GAP") ) return; + + pad = Module->m_Pads; + if(pad == NULL ) + { + DisplayError(this, _("No pad for this module")); return; + } + next_pad = (D_PAD*)pad->Pnext; + if(next_pad == NULL ) + { + DisplayError(this, _("Only one pad for this module")); return; + } + + /* Effacement du module: */ + Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR) ; + + /* Calcul de la dimension actuelle */ + gap_size = next_pad->m_Pos0.x - pad->m_Pos0.x - pad->m_Size.x; + + /* Entree de la longueur desiree du gap*/ + if( g_UnitMetric) + { + fcoeff = 10000.0/25.4 ; + msg.Printf( wxT("%2.3f"),gap_size / fcoeff); + Get_Message( _("Gap (mm):"),msg, this); + } + else + { + fcoeff = 10000.0 ; + msg.Printf( wxT("%2.4f"),gap_size / fcoeff); + Get_Message( _("Gap (inch):"),msg, this); + } + + if ( ! msg.IsEmpty() ) + { + double fval; + if ( msg.ToDouble(&fval) ) + gap_size = (int)( fval * fcoeff ); + } + + /* Mise a jour des tailles des pastilles formant le gap */ + pad->m_Size.x = pad->m_Size.y = g_DesignSettings.m_CurrentTrackWidth; + pad->m_Pos0.y = 0; + oX = pad->m_Pos0.x =- ((gap_size + pad->m_Size.x) /2); + pad->m_Pos.x = pad->m_Pos0.x + Module->m_Pos.x; + pad->m_Pos.y = pad->m_Pos0.y + Module->m_Pos.y; + RotatePoint(&(pad->m_Pos.x),&(pad->m_Pos.y), + Module->m_Pos.x,Module->m_Pos.y,Module->m_Orient); + + next_pad->m_Size.x = next_pad->m_Size.y = g_DesignSettings.m_CurrentTrackWidth; + next_pad->m_Pos0.y = 0; + next_pad->m_Pos0.x = oX + gap_size + next_pad->m_Size.x; + next_pad->m_Pos.x = next_pad->m_Pos0.x + Module->m_Pos.x; + next_pad->m_Pos.y = next_pad->m_Pos0.y + Module->m_Pos.y; + RotatePoint(&(next_pad->m_Pos.x), &(next_pad->m_Pos.y), + Module->m_Pos.x,Module->m_Pos.y, Module->m_Orient); + + Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ; +} + + diff --git a/pcbnew/muwave_command.cpp b/pcbnew/muwave_command.cpp new file mode 100644 index 0000000000..76f9c2d5e3 --- /dev/null +++ b/pcbnew/muwave_command.cpp @@ -0,0 +1,114 @@ + /*****************************************************/ + /* muwave_command.cpp: micro wave functions commands */ + /*****************************************************/ + +#include "fctsys.h" + +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "id.h" + +#include "protos.h" + + +/*********************************************************************/ +void WinEDA_PcbFrame::ProcessMuWaveFunctions(wxCommandEvent& event) +/*********************************************************************/ +/* Traite les selections d'outils et les commandes appelees du menu POPUP +*/ +{ +int id = event.GetId(); +wxPoint pos; +wxClientDC dc(DrawPanel); + + DrawPanel->PrepareGraphicContext(&dc); + + wxGetMousePosition(&pos.x, &pos.y); + + pos.y += 20; + + switch ( id ) // Arret eventuel de la commande de déplacement en cours + { + case ID_POPUP_COPY_BLOCK: + break; + + default: // Arret de la commande de déplacement en cours + if( DrawPanel->ManageCurseur && + DrawPanel->ForceCloseManageCurseur ) + { + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + SetToolID(0, wxCURSOR_ARROW,wxEmptyString); + break; + } + + switch ( id ) // Traitement des commandes + { + + case ID_PCB_MUWAVE_TOOL_SELF_CMD: + SetToolID( id, wxCURSOR_PENCIL, _("Add Line")); + break; + + case ID_PCB_MUWAVE_TOOL_GAP_CMD: + SetToolID( id, wxCURSOR_PENCIL, _("Add Gap")); + break; + + case ID_PCB_MUWAVE_TOOL_STUB_CMD: + SetToolID( id, wxCURSOR_PENCIL, _("Add Stub")); + break; + + case ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD: + SetToolID( id, wxCURSOR_PENCIL, _("Add Arc Stub")); + break; + + case ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD: + SetToolID( id, wxCURSOR_PENCIL, _("Add Polynomial Shape")); + break; + + default: + DisplayError(this, wxT("WinEDA_PcbFrame::ProcessMuWaveFunctions() id error")); + break; + } + + SetToolbars(); +} + + + +/***************************************************************************/ +void WinEDA_PcbFrame::MuWaveCommand(wxDC * DC, const wxPoint& MousePos) +/***************************************************************************/ +{ + switch ( m_ID_current_state ) + { + case ID_PCB_MUWAVE_TOOL_SELF_CMD: + Begin_Self(DC); + break; + + case ID_PCB_MUWAVE_TOOL_GAP_CMD: + Create_MuWaveComponent(DC, 0); + break; + + case ID_PCB_MUWAVE_TOOL_STUB_CMD: + Create_MuWaveComponent(DC, 1); + break; + + case ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD: + Create_MuWaveComponent(DC, 2); + break; + + case ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD: + Create_MuWavePolygonShape(DC); + break; + + default : + DrawPanel->SetCursor(wxCURSOR_ARROW); + DisplayError(this, wxT("WinEDA_PcbFrame::MuWaveCommand() id error")); + SetToolID(0, wxCURSOR_ARROW,wxEmptyString); + break; + } +} + diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp new file mode 100644 index 0000000000..f2016b1bb1 --- /dev/null +++ b/pcbnew/netlist.cpp @@ -0,0 +1,948 @@ + /************************************/ + /* PCBNEW: traitement des netlistes */ + /************************************/ + + /* Fichier NETLIST.CPP */ + +/* +Fonction de lecture de la netliste pour: + - Chargement modules et nouvelles connexions + - Test des modules (modules manquants ou en trop + - Recalcul du chevelu + +Remarque importante: + Lors de la lecture de la netliste pour Chargement modules + et nouvelles connexions, l'identification des modules peut se faire selon + 2 criteres: + - la reference (U2, R5 ..): c'est le mode normal + - le Time Stamp (Signature Temporelle), a utiliser apres reannotation + d'un schema, donc apres modification des references sans pourtant + avoir reellement modifie le schema +*/ +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "protos.h" + +#define TESTONLY 1 /* ctes utilisees lors de l'appel a */ +#define READMODULE 0 /* ReadNetModuleORCADPCB */ + +/* Structures locales */ +class MODULEtoLOAD : public EDA_BaseStruct +{ +public: + wxString m_LibName; + wxString m_CmpName; + +public: + MODULEtoLOAD(const wxString & libname, const wxString & cmpname, int timestamp); + ~MODULEtoLOAD(void){}; + MODULEtoLOAD * Next(void) { return (MODULEtoLOAD *) Pnext; } +}; + +/* Fonctions locales : */ +static void SortListModulesToLoadByLibname(int NbModules); + + +/* Variables locales */ +static int s_NbNewModules; +static MODULEtoLOAD * s_ModuleToLoad_List; +FILE * source; +static bool ChangeExistantModule; +static bool DisplayWarning = TRUE; +static int DisplayWarningCount ; + + /*****************************/ + /* class WinEDA_NetlistFrame */ + /*****************************/ +#include "dialog_netlist.cpp" + + + +/*************************************************************************/ +void WinEDA_PcbFrame::InstallNetlistFrame( wxDC * DC, const wxPoint & pos) +/*************************************************************************/ +{ + WinEDA_NetlistFrame * frame = new WinEDA_NetlistFrame(this, DC); + frame->ShowModal(); frame->Destroy(); +} + + + +/***************************************************************/ +bool WinEDA_NetlistFrame::OpenNetlistFile(wxCommandEvent& event) +/***************************************************************/ +/* + routine de selection et d'ouverture du fichier Netlist +*/ +{ +wxString FullFileName; +wxString msg; + + if( NetNameBuffer.IsEmpty() ) /* Pas de nom specifie */ + Set_NetlisteName(event); + + if( NetNameBuffer.IsEmpty() ) return(FALSE); /* toujours Pas de nom specifie */ + + FullFileName = NetNameBuffer; + + source = wxFopen(FullFileName, wxT("rt") ); + if (source == 0) + { + msg.Printf(_("Netlist file %s not found"),FullFileName.GetData()) ; + DisplayError(this, msg) ; + return FALSE ; + } + + msg = wxT("Netlist "); msg << FullFileName; + SetTitle(msg); + + return TRUE; +} + + +/**************************************************************/ +void WinEDA_NetlistFrame::ReadPcbNetlist(wxCommandEvent& event) +/**************************************************************/ +/* mise a jour des empreintes : + corrige les Net Names, les textes, les "TIME STAMP" + + Analyse les lignes: +# EESchema Netlist Version 1.0 generee le 18/5/2005-12:30:22 +( + ( 40C08647 $noname R20 4,7K {Lib=R} + ( 1 VCC ) + ( 2 MODB_1 ) + ) + ( 40C0863F $noname R18 4,7_k {Lib=R} + ( 1 VCC ) + ( 2 MODA_1 ) + ) +} +#End +*/ +{ +int LineNum, State, Comment; +MODULE * Module = NULL; +D_PAD * PtPad; +char Line[256], *Text; +int UseFichCmp = 1; +wxString msg; + + ChangeExistantModule = m_ChangeExistantModuleCtrl->GetSelection() == 1 ? TRUE : FALSE; + DisplayWarning = m_DisplayWarningCtrl->GetValue(); + if ( DisplayWarning ) DisplayWarningCount = 8; + else DisplayWarningCount = 0; + + if( ! OpenNetlistFile(event) ) return; + + msg = _("Read Netlist ") + NetNameBuffer; + m_MessageWindow->AppendText(msg); + + m_Parent->m_CurrentScreen->SetModify(); + m_Parent->m_Pcb->m_Status_Pcb = 0 ; State = 0; LineNum = 0; Comment = 0; + s_NbNewModules = 0; + + /* Premiere lecture de la netliste: etablissement de la liste + des modules a charger + */ + while( GetLine( source, Line, &LineNum) ) + { + Text = StrPurge(Line); + + if ( Comment ) /* Commentaires en cours */ + { + if( (Text = strchr(Text,'}') ) == NULL )continue; + Comment = 0; + } + if ( *Text == '{' ) /* Commentaires */ + { + Comment = 1; + if( (Text = strchr(Text,'}') ) == NULL ) continue; + } + + if ( *Text == '(' ) State++; + if ( *Text == ')' ) State--; + + if( State == 2 ) + { + Module = ReadNetModule(Text, & UseFichCmp, TESTONLY); + continue; + } + + if( State >= 3 ) /* la ligne de description d'un pad est ici non analysee */ + { + State--; + } + } + + /* Chargement des nouveaux modules */ + if( s_NbNewModules ) + { + LoadListeModules(m_DC); + // Free module list: + MODULEtoLOAD * item, *next_item; + for ( item = s_ModuleToLoad_List; item != NULL; item = next_item ) + { + next_item = item->Next(); + delete item; + } + s_ModuleToLoad_List = NULL; + } + + /* Relecture de la netliste, tous les modules sont ici charges */ + fseek(source, 0, SEEK_SET); LineNum = 0; + while( GetLine( source, Line, &LineNum) ) + { + Text = StrPurge(Line); + + if ( Comment ) /* Commentaires en cours */ + { + if( (Text = strchr(Text,'}') ) == NULL )continue; + Comment = 0; + } + if ( *Text == '{' ) /* Commentaires */ + { + Comment = 1; + if( (Text = strchr(Text,'}') ) == NULL ) continue; + } + + if ( *Text == '(' ) State++; + if ( *Text == ')' ) State--; + + if( State == 2 ) + { + Module = ReadNetModule(Text, & UseFichCmp, READMODULE ); + if( Module == NULL ) + { /* empreinte non trouvee dans la netliste */ + continue ; + } + else /* Raz netnames sur pads */ + { + PtPad = Module->m_Pads; + for( ; PtPad != NULL; PtPad = (D_PAD *)PtPad->Pnext ) + { + PtPad->m_Netname = wxEmptyString; + } + } + continue; + } + + if( State >= 3 ) + { + if ( Module ) + { + SetPadNetName( Text, Module); + } + State--; + } + } + + fclose(source); + + /* Mise a jour et Cleanup du circuit imprime: */ + m_Parent->Compile_Ratsnest(m_DC, TRUE); + + if( m_Parent->m_Pcb->m_Track ) + { + if( m_DeleteBadTracks->GetSelection() == 1 ) + { + wxBeginBusyCursor();; + Netliste_Controle_piste(m_Parent, m_DC, TRUE); + m_Parent->Compile_Ratsnest(m_DC, TRUE); + wxEndBusyCursor();; + } + } + + Affiche_Infos_Status_Pcb(m_Parent); +} + + +/****************************************************************************/ +MODULE * WinEDA_NetlistFrame::ReadNetModule(char * Text, int * UseFichCmp, + int TstOnly) +/****************************************************************************/ +/* charge la description d'une empreinte ,netliste type PCBNEW + et met a jour le module correspondant + + Si TstOnly == 0 si le module n'existe pas, il est charge + Si TstOnly != 0 si le module n'existe pas, il est ajoute a la liste des + modules a charger + Text contient la premiere ligne de la description + * UseFichCmp est un flag + si != 0, le fichier des composants .CMP sera utilise + est remis a 0 si le fichier n'existe pas + +Analyse les lignes type: +( 40C08647 $noname R20 4,7K {Lib=R} + ( 1 VCC ) + ( 2 MODB_1 ) +*/ +{ +MODULE * Module; +char * text; +wxString TextTimeStamp; +wxString TextNameLibMod; +wxString TextValeur; +wxString TextCmpName; +wxString NameLibCmp; +long TimeStamp = -1; +int Error = 0; +char Line[1024]; +bool Found; + + strcpy(Line,Text); + + TextValeur = wxT("~"); + if( (text = strtok(Line, " ()\t\n")) == NULL ) Error = 1; + else TextTimeStamp = CONV_FROM_UTF8(text); + if( ( text = strtok(NULL, " ()\t\n")) == NULL ) Error = 1; + else TextNameLibMod = CONV_FROM_UTF8(text); + if( (text = strtok(NULL, " ()\t\n")) == NULL ) Error = 1; + else TextCmpName = CONV_FROM_UTF8(text); + if( (text = strtok(NULL, " ()\t\n")) == NULL ) Error = -1; + else TextValeur = CONV_FROM_UTF8(text); + + if( Error > 0 ) return( NULL ); + + TextTimeStamp.ToLong( &TimeStamp, 16); + + /* Tst si composant deja charge */ + Module = (MODULE*) m_Parent->m_Pcb->m_Modules; + MODULE * NextModule; + for( Found = FALSE; Module != NULL; Module = NextModule ) + { + NextModule = (MODULE*)Module->Pnext; + if( m_Select_By_Timestamp->GetSelection() == 1 ) /* Reconnaissance par signature temporelle */ + { + if( TimeStamp == Module->m_TimeStamp) Found = TRUE; + } + else /* Reconnaissance par Reference */ + { + if( TextCmpName.CmpNoCase(Module->m_Reference->m_Text) == 0 ) + Found = TRUE; + } + if ( Found ) // Test si module (m_LibRef) et module specifie en netlist concordent + { + if( TstOnly != TESTONLY ) + { + NameLibCmp = TextNameLibMod; + if( *UseFichCmp ) + { + if( m_Select_By_Timestamp->GetSelection() == 1 ) + { /* Reconnaissance par signature temporelle */ + *UseFichCmp = ReadListeModules(NULL, TimeStamp, NameLibCmp); + } + else /* Reconnaissance par Reference */ + { + *UseFichCmp = ReadListeModules(&TextCmpName, 0l, NameLibCmp); + } + } + if (Module->m_LibRef.CmpNoCase(NameLibCmp) != 0 ) + {// Module Mismatch: Current module and module specified in netlist are diff. + if ( ChangeExistantModule ) + { + MODULE * NewModule = + m_Parent->Get_Librairie_Module(this, wxEmptyString, NameLibCmp, TRUE); + if( NewModule ) /* Nouveau module trouve : changement de module */ + Module = m_Parent->Exchange_Module(this, Module, NewModule); + } + else + { + wxString msg; + msg.Printf( + _("Cmp %s: Mismatch! module is [%s] and netlist said [%s]\n"), + TextCmpName.GetData(), Module->m_LibRef.GetData(), NameLibCmp.GetData()); + m_MessageWindow->AppendText(msg); + if ( DisplayWarningCount > 0) + { + DisplayError(this, msg, 2); + DisplayWarningCount--; + } + } + } + } + break; + } + } + + if( Module == NULL ) /* Module a charger */ + { + NameLibCmp = TextNameLibMod; + + if( *UseFichCmp ) + { + if( m_Select_By_Timestamp->GetSelection() == 1) + { /* Reconnaissance par signature temporelle */ + *UseFichCmp = ReadListeModules(NULL, TimeStamp, NameLibCmp); + } + else /* Reconnaissance par Reference */ + { + *UseFichCmp = ReadListeModules(&TextCmpName, 0l, NameLibCmp); + } + } + + + if( TstOnly == TESTONLY) + AddToList(NameLibCmp, TextCmpName, TimeStamp); + else + { + wxString msg; + msg.Printf( _("Component [%s] not found"), TextCmpName.GetData()); + m_MessageWindow->AppendText( msg + wxT("\n")); + if (DisplayWarningCount> 0) + { + DisplayError(this, msg, 2); + DisplayWarningCount--; + } + } + return(NULL); /* Le module n'avait pas pu etre charge */ + } + + /* mise a jour des reperes ( nom et ref "Time Stamp") si module charge */ + Module->m_Reference->m_Text = TextCmpName; + Module->m_Value->m_Text = TextValeur; + Module->m_TimeStamp = TimeStamp; + + return(Module) ; /* composant trouve */ +} + +/********************************************************************/ +int WinEDA_NetlistFrame::SetPadNetName( char * Text, MODULE * Module) +/********************************************************************/ +/* +Met a jour le netname de 1 pastille, Netliste ORCADPCB + entree : + Text = ligne de netliste lue ( (pad = net) ) + Module = adresse de la structure MODULE a qui appartient les pads +*/ +{ +D_PAD * pad; +char * TextPinName, * TextNetName; +int Error = 0; +bool trouve; +char Line[256]; +wxString Msg; + + if( Module == NULL ) return ( 0 ); + + strcpy( Line, Text); + + if( (TextPinName = strtok(Line, " ()\t\n")) == NULL ) Error = 1; + if( (TextNetName = strtok(NULL, " ()\t\n")) == NULL ) Error = 1; + if(Error) return(0); + + /* recherche du pad */ + pad = Module->m_Pads; trouve = FALSE; + for( ; pad != NULL; pad = (D_PAD *)pad->Pnext ) + { + if( strnicmp( TextPinName, pad->m_Padname, 4) == 0 ) + { /* trouve */ + trouve = TRUE; + if( *TextNetName != '?' ) + pad->m_Netname = CONV_FROM_UTF8(TextNetName); + else pad->m_Netname.Empty(); + } + } + + if( !trouve && (DisplayWarningCount > 0) ) + { + wxString pin_name = CONV_FROM_UTF8(TextPinName); + Msg.Printf( _("Module [%s]: Pad [%s] not found"), + Module->m_Reference->m_Text.GetData(), pin_name.GetData() ); + DisplayError(this, Msg, 1); + DisplayWarningCount--; + } + + return(trouve); +} + + +/*****************************************************/ +MODULE * WinEDA_PcbFrame::ListAndSelectModuleName(void) +/*****************************************************/ +/* liste les noms des modules du PCB + Retourne: + un pointeur sur le module selectionne + NULL si pas de selection +*/ +{ +int ii, jj, nb_empr; +MODULE * Module; +WinEDAListBox * ListBox; +const wxChar ** ListNames = NULL; + + if( m_Pcb->m_Modules == NULL ) + { + DisplayError(this, _("No Modules") ) ; return(0); + } + + /* Calcul du nombre des modules */ + nb_empr = 0; Module = (MODULE*)m_Pcb->m_Modules; + for( ;Module != NULL; Module = (MODULE*)Module->Pnext) nb_empr++; + ListNames = (const wxChar**) MyZMalloc( (nb_empr + 1) * sizeof(wxChar*) ); + Module = (MODULE*) m_Pcb->m_Modules; + for( ii = 0; Module != NULL; Module = (MODULE*)Module->Pnext, ii++) + { + ListNames[ii] = Module->m_Reference->m_Text.GetData(); + } + + ListBox = new WinEDAListBox(this, _("Components"), + ListNames, wxEmptyString); + ii = ListBox->ShowModal(); ListBox->Destroy(); + + + if( ii < 0 ) /* Pas de selection */ + { + Module = NULL; + } + + else /* Recherche du module selectionne */ + { + Module = (MODULE*) m_Pcb->m_Modules; + for( jj = 0; Module != NULL; Module = (MODULE*)Module->Pnext, jj++) + { + if( Module->m_Reference->m_Text.Cmp(ListNames[ii]) == 0 ) break; + } + } + + free(ListNames); + return(Module); +} + +/***************************************************************/ +void WinEDA_NetlistFrame::ModulesControle(wxCommandEvent& event) +/***************************************************************/ +/* donne la liste : +1 - des empreintes doublées sur le PCB +2 - des empreintes manquantes par rapport a la netliste +3 - des empreintes supplémentaires par rapport a la netliste +*/ +#define MAX_LEN_TXT 32 +{ +int ii, NbModulesPcb; +MODULE * Module, * pt_aux; +int NbModulesNetListe ,nberr = 0 ; +WinEDA_TextFrame * List; +wxArrayString ModuleListFromNetlist; + + /* determination du nombre des modules du PCB*/ + NbModulesPcb = 0; Module = (MODULE*) m_Parent->m_Pcb->m_Modules; + for( ;Module != NULL; Module = (MODULE*)Module->Pnext) + NbModulesPcb++; + + if( NbModulesPcb == 0 ) + { + DisplayError(this, _("No modules"), 10); return; + } + + /* Construction de la liste des references des modules de la netliste */ + NbModulesNetListe = BuildListeNetModules(event, ModuleListFromNetlist); + if( NbModulesNetListe < 0 ) return; /* fichier non trouve */ + + if( NbModulesNetListe == 0 ) + { + DisplayError(this, _("No modules in NetList"), 10); return; + } + + List = new WinEDA_TextFrame(this, _("Check Modules")); + + /* recherche des doubles */ + List->Append(_("Duplicates")); + + Module = (MODULE*) m_Parent->m_Pcb->m_Modules; + for( ;Module != NULL; Module = (MODULE*)Module->Pnext) + { + pt_aux = (MODULE*)Module->Pnext; + for( ; pt_aux != NULL; pt_aux = (MODULE*)pt_aux->Pnext) + { + if( Module->m_Reference->m_Text.CmpNoCase(pt_aux->m_Reference->m_Text) == 0 ) + { + List->Append(Module->m_Reference->m_Text); + nberr++ ; + break; + } + } + } + + /* recherche des manquants par rapport a la netliste*/ + List->Append(_("Lack:") ); + + for ( ii = 0 ; ii < NbModulesNetListe ; ii++ ) + { + Module = (MODULE*) m_Parent->m_Pcb->m_Modules; + for( ;Module != NULL; Module = (MODULE*)Module->Pnext) + { + if( Module->m_Reference->m_Text.CmpNoCase( + ModuleListFromNetlist[ii]) == 0 ) + { + break; + } + } + if( Module == NULL ) // Module missing, not found in board + { + List->Append(ModuleListFromNetlist[ii]); + nberr++ ; + } + } + + /* recherche des modules supplementaires (i.e. Non en Netliste) */ + List->Append( _("Not in Netlist:") ); + + Module = (MODULE*) m_Parent->m_Pcb->m_Modules; + for( ;Module != NULL; Module = Module->Next()) + { + for (ii = 0; ii < NbModulesNetListe; ii++ ) + { + if( Module->m_Reference->m_Text.CmpNoCase( + ModuleListFromNetlist[ii]) == 0 ) + { + break ;/* Module trouve en netliste */ + } + } + if( ii == NbModulesNetListe ) /* Module not found in netlist */ + { + List->Append(Module->m_Reference->m_Text); + nberr++ ; + } + } + + List->ShowModal(); List->Destroy(); +} + + +/**************************************************************************************************/ +int WinEDA_NetlistFrame::BuildListeNetModules(wxCommandEvent& event, wxArrayString & BufName) +/**************************************************************************************************/ +/* + charge en BufName la liste des noms des modules de la netliste, + retourne le nombre des modules cités dans la netliste +*/ +{ +int textlen; +int nb_modules_lus ; +int State, LineNum, Comment; +char Line[1024], *Text, * LibModName; + + if( ! OpenNetlistFile(event) ) return -1; + + State = 0; LineNum = 0; Comment = 0; + nb_modules_lus = 0; + textlen = MAX_LEN_TXT; + + while( GetLine( source, Line, &LineNum) ) + { + Text = StrPurge(Line); + if ( Comment ) /* Commentaires en cours */ + { + if( (Text = strchr(Text,'}') ) == NULL )continue; + Comment = 0; + } + if ( *Text == '{' ) /* Commentaires */ + { + Comment = 1; + if( (Text = strchr(Text,'}') ) == NULL ) continue; + } + + if ( *Text == '(' ) State++; + if ( *Text == ')' ) State--; + + if( State == 2 ) + { + int Error = 0; + if( strtok(Line, " ()\t\n") == NULL ) Error = 1; /* TimeStamp */ + if( ( LibModName = strtok(NULL, " ()\t\n")) == NULL ) Error = 1; /* nom Lib */ + /* Lecture du nom (reference) du composant: */ + if( (Text = strtok(NULL, " ()\t\n")) == NULL ) Error = 1; + nb_modules_lus++; + BufName.Add(CONV_FROM_UTF8(Text)); + continue; + } + + if( State >= 3 ) + { + State--; /* Lecture 1 ligne relative au Pad */ + } + } + + fclose(source); + return(nb_modules_lus); +} + + + +/*****************************************************************************************/ +int WinEDA_NetlistFrame::ReadListeModules(const wxString * RefCmp, long TimeStamp, + wxString & NameModule) +/*****************************************************************************************/ +/* + Lit le fichier .CMP donnant l'equivalence Modules / Composants + Retourne: + Si ce fichier existe: + 1 et le nom module dans NameModule + -1 si module non trouve en fichier + sinon 0; + + parametres d'appel: + RefCmp (NULL si selection par TimeStamp) + TimeStamp (signature temporelle si elle existe, NULL sinon) + pointeur sur le buffer recevant le nom du module + + Exemple de fichier: + +Cmp-Mod V01 Genere par PcbNew le 29/10/2003-13:11:6 + +BeginCmp +TimeStamp = 322D3011; +Reference = BUS1; +ValeurCmp = BUSPC; +IdModule = BUS_PC; +EndCmp + +BeginCmp +TimeStamp = 32307DE2; +Reference = C1; +ValeurCmp = 47uF; +IdModule = CP6; +EndCmp + +*/ +{ +wxString CmpFullFileName; +wxString refcurrcmp, idmod; +char ia[1024]; +int timestamp; +char *ptcar; +FILE * FichCmp; + + if( (RefCmp == NULL) && (TimeStamp == 0) ) return(0); + + CmpFullFileName = NetNameBuffer; + ChangeFileNameExt(CmpFullFileName,NetCmpExtBuffer) ; + + FichCmp = wxFopen(CmpFullFileName, wxT("rt") ); + if (FichCmp == NULL) + { + wxString msg; + msg.Printf( _("File <%s> not found, use Netlist for lib module selection"), + CmpFullFileName.GetData()) ; + DisplayError(this, msg, 20) ; + return(0); + } + + while( fgets(ia,sizeof(ia),FichCmp) != NULL ) + { + if( strnicmp(ia,"BeginCmp",8) != 0 ) continue; + + /* Ici une description de 1 composant commence */ + refcurrcmp.Empty(); + idmod.Empty(); + timestamp = -1; + while( fgets(ia,sizeof(ia),FichCmp) != NULL ) + { + if( strnicmp(ia,"EndCmp",6) == 0 ) break; + + if( strnicmp(ia,"Reference =",11) == 0 ) + { + ptcar = ia+11; + ptcar = strtok(ptcar," =;\t\n"); + if( ptcar ) refcurrcmp = CONV_FROM_UTF8(ptcar); + continue; + } + + if( strnicmp(ia,"IdModule =",11) == 0 ) + { + ptcar = ia+11; + ptcar = strtok(ptcar," =;\t\n"); + if( ptcar ) idmod = CONV_FROM_UTF8(ptcar); + continue; + } + if( strnicmp(ia,"TimeStamp =",11) == 0 ) + { + ptcar = ia+11; + ptcar = strtok(ptcar," =;\t\n"); + if( ptcar ) sscanf(ptcar, "%X", ×tamp); + } + }/* Fin lecture 1 descr composant */ + + /* Test du Composant lu en fichier: est-il le bon */ + if( RefCmp ) + { + if( RefCmp->CmpNoCase(refcurrcmp) == 0 ) + { + fclose(FichCmp); + NameModule = idmod; + return(1); + } + } + else if( TimeStamp != -1 ) + { + if( TimeStamp == timestamp ) + { + fclose(FichCmp); + NameModule = idmod; + return(1); + } + } + } + fclose(FichCmp); + return(-1); +} + + +/***************************************************************/ +void WinEDA_NetlistFrame::Set_NetlisteName(wxCommandEvent& event) +/***************************************************************/ +/* Selection un nouveau nom de netliste + Affiche la liste des fichiers netlistes pour selection sur liste + */ +{ +wxString fullfilename, mask( wxT("*")); + + mask += NetExtBuffer; + + fullfilename = EDA_FileSelector( _("Netlist Selection:"), + wxEmptyString, /* Chemin par defaut */ + NetNameBuffer, /* nom fichier par defaut */ + NetExtBuffer, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + 0, + TRUE + ); + + if ( fullfilename.IsEmpty()) return; + NetNameBuffer = fullfilename; + SetTitle(fullfilename); +} + +/***********************************************************************************/ +void WinEDA_NetlistFrame::AddToList(const wxString & NameLibCmp, const wxString & CmpName,int TimeStamp ) +/************************************************************************************/ +/* Fontion copiant en memoire de travail les caracteristiques + des nouveaux modules +*/ +{ +MODULEtoLOAD * NewMod; + + NewMod = new MODULEtoLOAD(NameLibCmp, CmpName, TimeStamp); + NewMod->Pnext = s_ModuleToLoad_List; + s_ModuleToLoad_List = NewMod; + s_NbNewModules++; +} + + +/***************************************************************/ +void WinEDA_NetlistFrame::LoadListeModules(wxDC * DC) +/***************************************************************/ +/* Routine de chargement des nouveaux modules en une seule lecture des + librairies + Si un module vient d'etre charge il est duplique, ce qui evite une lecture + inutile de la librairie +*/ +{ +MODULEtoLOAD * ref, *cmp; +int ii; +MODULE * Module = NULL; +wxPoint OldPos = m_Parent->m_CurrentScreen->m_Curseur; + + if( s_NbNewModules == 0 ) return; + + SortListModulesToLoadByLibname(s_NbNewModules); + ref = cmp = s_ModuleToLoad_List; + + // Calcul de la coordonnée de placement des modules: + if ( m_Parent->SetBoardBoundaryBoxFromEdgesOnly() ) + { + m_Parent->m_CurrentScreen->m_Curseur.x = m_Parent->m_Pcb->m_BoundaryBox.GetRight() + 5000; + m_Parent->m_CurrentScreen->m_Curseur.y = m_Parent->m_Pcb->m_BoundaryBox.GetBottom() + 10000; + } + else + { + m_Parent->m_CurrentScreen->m_Curseur = wxPoint(0,0); + } + + for( ii = 0; ii < s_NbNewModules; ii++, cmp = cmp->Next() ) + { + if( (ii == 0) || ( ref->m_LibName != cmp->m_LibName) ) + { /* Nouveau Module a charger */ + Module = m_Parent->Get_Librairie_Module(this, wxEmptyString, cmp->m_LibName, TRUE ); + ref = cmp; + if ( Module == NULL ) continue; + m_Parent->Place_Module(Module, DC); + /* mise a jour des reperes ( nom et ref "Time Stamp") + si module charge */ + Module->m_Reference->m_Text = cmp->m_CmpName; + Module->m_TimeStamp = cmp->m_TimeStamp; + } + + else + { /* module deja charge, on peut le dupliquer */ + MODULE * newmodule; + if ( Module == NULL ) continue; /* module non existant en libr */ + newmodule = new MODULE(m_Parent->m_Pcb); + newmodule->Copy(Module); + newmodule->AddToChain(Module); + Module = newmodule; + Module->m_Reference->m_Text = cmp->m_CmpName; + Module->m_TimeStamp = cmp->m_TimeStamp; + } + } + m_Parent->m_CurrentScreen->m_Curseur = OldPos; +} + + +/* Routine utilisee par qsort pour le tri des modules a charger +*/ +static int SortByLibName( MODULEtoLOAD ** ref, MODULEtoLOAD ** cmp ) +{ + int ii = (*ref)->m_LibName.CmpNoCase((*cmp)->m_LibName); + + return ii; +} + +/*************************************************/ +void SortListModulesToLoadByLibname(int NbModules) +/**************************************************/ +/* Rearrage la liste des modules List par ordre alphabetique des noms lib des modules +*/ +{ +MODULEtoLOAD ** base_list, * item; +int ii; + + base_list = (MODULEtoLOAD **) MyMalloc( NbModules * sizeof(MODULEtoLOAD *) ); + + for ( ii = 0, item = s_ModuleToLoad_List; ii < NbModules; ii++ ) + { + base_list[ii] = item; + item = item->Next(); + } + qsort( base_list, NbModules, sizeof(MODULEtoLOAD*), + (int(*)(const void *, const void *) )SortByLibName); + // Reconstruction du chainage: + s_ModuleToLoad_List = *base_list; + for ( ii = 0; ii < NbModules-1; ii++ ) + { + item = base_list[ii]; + item->Pnext = base_list[ii + 1]; + } + // Dernier item: Pnext = NULL: + item = base_list[ii]; + item->Pnext = NULL; + + free(base_list); +} + + +/*****************************************************************************/ +MODULEtoLOAD::MODULEtoLOAD(const wxString & libname, const wxString & cmpname, + int timestamp) : EDA_BaseStruct(TYPE_NOT_INIT) +/*****************************************************************************/ +{ + m_LibName = libname; + m_CmpName = cmpname; + m_TimeStamp = timestamp; +} diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp new file mode 100644 index 0000000000..13d90a914b --- /dev/null +++ b/pcbnew/onrightclick.cpp @@ -0,0 +1,632 @@ +/********************************************************************************/ +/* onrightclick.cpp: fonctions de l'edition du PCB appelées par le bouton droit */ +/********************************************************************************/ + +#include "fctsys.h" + +#include "gr_basic.h" +#include "macros.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "id.h" + +#include "protos.h" + +/* Bitmaps */ +#include "bitmaps.h" + + +/* Specific bitmaps */ +#include "Break_Line.xpm" +#include "Delete_Net.xpm" +#include "Delete_Line.xpm" +#include "Delete_Track.xpm" +#include "Move_Module.xpm" +#include "Drag_Module.xpm" +#include "Edit_Module.xpm" +#include "Rotate_Module+.xpm" +#include "Rotate_Module-.xpm" +#include "Delete_Module.xpm" +#include "Invert_Module.xpm" +#include "Locked.xpm" +#include "Unlocked.xpm" +#include "Move_Field.xpm" +#include "Rotate_Field.xpm" +#include "Move_Pad.xpm" +#include "Drag_Pad.xpm" +#include "Global_Options_Pad.xpm" +#include "Delete_Pad.xpm" +#include "Export_Options_Pad.xpm" +#include "Select_W_Layer.xpm" +#include "Width_Track.xpm" +#include "Width_Vias.xpm" +#include "Width_Segment.xpm" +#include "Width_Net.xpm" +#include "Width_Track_Via.xpm" +#include "Select_Layer_Pair.xpm" + +#include "Flag.xpm" + + + +/* local functions */ +static void CreatePopupMenuForTracks(TRACK * Track, wxPoint CursorPosition, + wxMenu * PopMenu); + + +/*****/ + +/*********************************************************************/ +static void AppendModuleOnRightClickMenu(wxMenu * menu, bool full_menu) +/*********************************************************************/ +/* Create the wxMenuitem list for module editing +*/ +{ + if ( full_menu ) + { + ADD_MENUITEM(menu, ID_POPUP_PCB_MOVE_MODULE_REQUEST, + _("Move Module (M)"), Move_Module_xpm) + ADD_MENUITEM(menu, ID_POPUP_PCB_DRAG_MODULE_REQUEST, + _("Drag Module (G)"), Drag_Module_xpm); + } + ADD_MENUITEM(menu, ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE, + _("Rotate Module + (R)"), rotate_module_pos_xpm); + ADD_MENUITEM(menu, ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE, + _("Rotate Module -"), rotate_module_neg_xpm); + ADD_MENUITEM(menu, ID_POPUP_PCB_CHANGE_SIDE_MODULE, + _("Invert Module (S)"), invert_module_xpm); + ADD_MENUITEM(menu, ID_POPUP_PCB_EDIT_MODULE, + _("Edit Module"), Edit_Module_xpm); +} + +/********************************************/ +static wxMenu * Append_Track_Width_List(void) +/********************************************/ +/* Ajoute au menu wxMenu * menu un sous-menu liste des epaisseurs de pistes +disponibles +*/ +{ +int ii; +wxString msg; +wxMenu * trackwidth; +double value; + + trackwidth = new wxMenu; + for ( ii = 0; ii < 6; ii++ ) + { + if ( g_DesignSettings.m_TrackWidhtHistory[ii] == 0 ) break; + value = To_User_Unit(g_UnitMetric, g_DesignSettings.m_TrackWidhtHistory[ii], PCB_INTERNAL_UNIT); + if ( g_UnitMetric == INCHES ) // Affichage en mils + msg.Printf(_("Track %.1f"), value * 1000); + else + msg.Printf(_("Track %.3f"), value); + + trackwidth->Append(ID_POPUP_PCB_SELECT_WIDTH1 + ii, msg, wxEmptyString, TRUE); + if( g_DesignSettings.m_TrackWidhtHistory[ii] == g_DesignSettings.m_CurrentTrackWidth ) + trackwidth->Check( ID_POPUP_PCB_SELECT_WIDTH1 + ii, TRUE); + } + + trackwidth->AppendSeparator(); + for ( ii = 0; ii < 4; ii++ ) + { + if ( g_DesignSettings.m_ViaSizeHistory[ii] == 0 ) break; + value = To_User_Unit(g_UnitMetric, g_DesignSettings.m_ViaSizeHistory[ii], PCB_INTERNAL_UNIT); + if ( g_UnitMetric == INCHES ) + msg.Printf(_("Via %.1f"), value * 1000); + else + msg.Printf(_("Via %.3f"), value); + trackwidth->Append( ID_POPUP_PCB_SELECT_VIASIZE1 + ii, msg, wxEmptyString, TRUE); + if( g_DesignSettings.m_ViaSizeHistory[ii] == g_DesignSettings.m_CurrentViaSize ) + trackwidth->Check( ID_POPUP_PCB_SELECT_VIASIZE1 + ii, TRUE); + } + return trackwidth; +} + + +/****************************************************************************/ +void WinEDA_PcbFrame::OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu) +/****************************************************************************/ +/* Prepare le menu PullUp affiché par un click sur le bouton droit +de la souris. + Ce menu est ensuite complété par la liste des commandes de ZOOM +*/ +{ +EDA_BaseStruct *DrawStruct = m_CurrentScreen->m_CurrentItem; +wxString msg; +int flags = 0; +bool locate_track = FALSE; +bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE); +wxClientDC dc(DrawPanel); + + DrawPanel->CursorOff(&dc); + DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu + + // Simple localisation des elements si possible + if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) + { + if (m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOPLACE) + { + DrawStruct = Locate_Prefered_Module(m_Pcb, CURSEUR_OFF_GRILLE); + if ( DrawStruct ) ((MODULE*)DrawStruct)->Display_Infos(this); + else DrawStruct = PcbGeneralLocateAndDisplay(); + } + else DrawStruct = PcbGeneralLocateAndDisplay(); + } + + // Si commande en cours: affichage fin de commande + if ( m_ID_current_state ) + { + if ( DrawStruct && DrawStruct->m_Flags ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, + _("Cancel"), cancel_xpm); + } + else + { + ADD_MENUITEM(PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL, + _("End Tool"), cancel_tool_xpm); + } + PopMenu->AppendSeparator(); + } + + else + { + if ( (DrawStruct && DrawStruct->m_Flags) || BlockActive ) + { + if ( BlockActive ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, + _("Cancel Block"), cancel_xpm ); + ADD_MENUITEM(PopMenu, ID_POPUP_ZOOM_BLOCK, + _("Zoom Block (Midd butt drag)"), zoom_selected_xpm ); + PopMenu->AppendSeparator(); + ADD_MENUITEM(PopMenu, ID_POPUP_PLACE_BLOCK, + _("Place Block"), apply_xpm ); + ADD_MENUITEM(PopMenu, ID_POPUP_COPY_BLOCK, + _("Copy Block (shift + drag mouse)"), copyblock_xpm ); + ADD_MENUITEM(PopMenu, ID_POPUP_INVERT_BLOCK, + _("Flip Block (alt + drag mouse)"), invert_module_xpm ); + ADD_MENUITEM(PopMenu, ID_POPUP_ROTATE_BLOCK, + _("Rotate Block (ctrl + drag mouse)"), rotate_pos_xpm ); + ADD_MENUITEM(PopMenu, ID_POPUP_DELETE_BLOCK, + _("Delete Block (shift+ctrl + drag mouse)"), delete_xpm ); + } + else + { + ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, + _("Cancel"), cancel_xpm); + } + PopMenu->AppendSeparator(); + } + } + + if ( BlockActive ) goto out; + + m_CurrentScreen->m_CurrentItem = DrawStruct; + + if ( DrawStruct ) + { + flags = DrawStruct->m_Flags; + switch ( DrawStruct->m_StructType ) + { + case TYPEMODULE: + if( !flags ) AppendModuleOnRightClickMenu(PopMenu, TRUE); + else AppendModuleOnRightClickMenu(PopMenu, FALSE); + + if (m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOPLACE) + { + PopMenu->AppendSeparator(); + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE, _("Fix Module"), + Locked_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_AUTOPLACE_FREE_MODULE, _("Free Module"), + Unlocked_xpm); + if( !flags ) + PopMenu->Append( ID_POPUP_PCB_AUTOPLACE_CURRENT_MODULE, + _("Auto place Module")); + } + + if (m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOROUTE) + { + if( !flags ) + PopMenu->Append( ID_POPUP_PCB_AUTOROUTE_MODULE, _("Autoroute")); + } + + if( !flags ) + { + PopMenu->AppendSeparator(); + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DELETE_MODULE, + _("Delete Module"), Delete_Module_xpm); + } + break; + + case TYPEPAD: + if( !flags ) + { + MODULE * Module = (MODULE *) DrawStruct->m_Parent; + if (Module) + { + AppendModuleOnRightClickMenu(PopMenu, TRUE); + PopMenu->AppendSeparator(); + } + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_MOVE_PAD_REQUEST, + _("Move Pad"), move_pad_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DRAG_PAD_REQUEST, + _("Drag Pad"), drag_pad_xpm); + } + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_EDIT_PAD, _("Edit Pad"), options_pad_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_IMPORT_PAD_SETTINGS, + _("New Pad Settings"), options_new_pad_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_EXPORT_PAD_SETTINGS, + _("Export Pad Settings"), Export_Options_Pad_xpm); + if (m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOROUTE) + { + if( !flags ) + { + PopMenu->Append( ID_POPUP_PCB_AUTOROUTE_PAD, _("Autoroute Pad")); + PopMenu->Append( ID_POPUP_PCB_AUTOROUTE_NET, _("Autoroute Net")); + } + } + + if( !flags ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DELETE_PAD, + _("delete Pad"), Delete_Pad_xpm); + PopMenu->AppendSeparator(); + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS, + _("Global Pad Settings"), global_options_pad_xpm); + } + break; + + case TYPETEXTEMODULE: + if( !flags ) + { + MODULE * Module = (MODULE *) DrawStruct->m_Parent; + if (Module) + { + AppendModuleOnRightClickMenu(PopMenu, TRUE); + PopMenu->AppendSeparator(); + } + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST, + _("Move Text Mod."), Move_Field_xpm); + } + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_ROTATE_TEXTMODULE, + _("Rotate Text Mod."), Rotate_Field_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_EDIT_TEXTMODULE, + _("Edit Text Mod."), edit_text_xpm); + if ( ((TEXTE_MODULE*)DrawStruct)->m_Type == TEXT_is_DIVERS) + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DELETE_TEXTMODULE, + _("Delete Text Mod."), delete_xpm); + break; + + case TYPEDRAWSEGMENT: + if( !flags ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_MOVE_DRAWING_REQUEST, + _("Move Drawing"), move_xpm); + } + if( flags & IS_NEW ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_STOP_CURRENT_DRAWING, + _("End Drawing"), apply_xpm); + } + PopMenu->Append(ID_POPUP_PCB_EDIT_DRAWING, _("Edit Drawing")); + PopMenu->Append(ID_POPUP_PCB_DELETE_DRAWING, _("Delete Drawing")); + break; + + case TYPEEDGEZONE: + if( flags & IS_NEW ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE, + _("End edge zone"), apply_xpm); + } + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DELETE_EDGE_ZONE, + _("Delete edge zone"), delete_xpm); + break; + + case TYPETEXTE: + if( !flags ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST, + _("Move Text"), move_text_xpm); + } + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_ROTATE_TEXTEPCB, + _("Rotate Text"), rotate_pos_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_EDIT_TEXTEPCB, + _("Edit Text"), edit_text_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DELETE_TEXTEPCB, + _("Delete Text"), delete_text_xpm); + break; + + case TYPETRACK: + case TYPEVIA: + locate_track = TRUE; + CreatePopupMenuForTracks( (TRACK *) DrawStruct, GetScreen()->m_Curseur, + PopMenu); + break; + + case TYPEZONE: + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_EDIT_ZONE, + _("Edit Zone"), edit_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DELETE_ZONE, + _("Delete Zone"), delete_xpm); + break; + + case TYPEMARQUEUR: + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DELETE_MARKER, + _("Delete Marker"), delete_xpm); + break; + + case TYPECOTATION: + if( !flags ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_EDIT_COTATION, + _("Edit Cotation"), edit_xpm); + } + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DELETE_COTATION, + _("Delete Cotation"), delete_xpm); + break; + + case TYPEMIRE: + if( !flags ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_MOVE_MIRE_REQUEST, + _("Move Mire"), move_xpm ); + } + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_EDIT_MIRE, + _("Edit Mire"), edit_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DELETE_MIRE, + _("Delete Mire"), delete_xpm); + break; + + case TYPEEDGEMODULE: + case TYPESCREEN: + case TYPE_NOT_INIT: + case TYPEPCB: + case PCB_EQUIPOT_STRUCT_TYPE: + msg.Printf( + wxT("WinEDA_PcbFrame::OnRightClick Error: illegal DrawType %d"), + DrawStruct->m_StructType); + DisplayError(this, msg ); + break; + + default: + msg.Printf( + wxT("WinEDA_PcbFrame::OnRightClick Error: unknown DrawType %d"), + DrawStruct->m_StructType); + DisplayError(this, msg ); + break; + } + PopMenu->AppendSeparator(); + } + + /* Traitement des fonctions specifiques */ + switch ( m_ID_current_state ) + { + case ID_PCB_ZONES_BUTT: + { + bool add_separator = FALSE; + PopMenu->Append(ID_POPUP_PCB_FILL_ZONE, _("Fill zone") ); + + if ( DrawStruct && + ( (DrawStruct->m_StructType == TYPEPAD) || + (DrawStruct->m_StructType == TYPETRACK) || + (DrawStruct->m_StructType == TYPEVIA) ) ) + { + add_separator = TRUE; + PopMenu->Append(ID_POPUP_PCB_SELECT_NET_ZONE, _("Select Net")); + } + if( m_Pcb->m_CurrentLimitZone ) + { + add_separator = TRUE; + PopMenu->Append(ID_POPUP_PCB_DELETE_ZONE_LIMIT, _("Delete Zone Limit")); + } + if ( add_separator ) PopMenu->AppendSeparator(); + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_SELECT_LAYER, + _("Select Working Layer"), Select_W_Layer_xpm); + PopMenu->AppendSeparator(); + } + break; + + case ID_TRACK_BUTT: + { + ADD_MENUITEM_WITH_SUBMENU( PopMenu, Append_Track_Width_List(), + ID_POPUP_PCB_SELECT_WIDTH, + _("Select Track Width"), width_track_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_SELECT_CU_LAYER, + _("Select Working Layer"), Select_W_Layer_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_SELECT_LAYER_PAIR, + _("Select layer pair for vias"), select_layer_pair_xpm); + PopMenu->AppendSeparator(); + } + break; + + case ID_PCB_CIRCLE_BUTT: + case ID_PCB_ARC_BUTT: + case ID_TEXT_COMMENT_BUTT: + case ID_LINE_COMMENT_BUTT: + case ID_PCB_COTATION_BUTT: + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_SELECT_NO_CU_LAYER, + _("Select Working Layer"), Select_W_Layer_xpm); + PopMenu->AppendSeparator(); + break; + + case ID_COMPONENT_BUTT: + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_DISPLAY_FOOTPRINT_DOC, + _("Footprint documentation"), book_xpm); + PopMenu->AppendSeparator(); + break; + + case 0: + if (m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOPLACE) + { + wxMenu * commands = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU(PopMenu, commands, + ID_POPUP_PCB_AUTOPLACE_COMMANDS, _("Glob Move and Place"), move_xpm); + ADD_MENUITEM(commands, ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES, + _("Free All Modules"), Unlocked_xpm); + ADD_MENUITEM(commands, ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES, + _("Fixe All Modules"), Locked_xpm); + commands->AppendSeparator(); + ADD_MENUITEM(commands, ID_POPUP_PCB_AUTOMOVE_ALL_MODULES, + _("Move All Modules"), move_xpm); + commands->Append( ID_POPUP_PCB_AUTOMOVE_NEW_MODULES, _("Move New Modules")); + commands->AppendSeparator(); + commands->Append( ID_POPUP_PCB_AUTOPLACE_ALL_MODULES, _("Autoplace All Modules")); + commands->Append( ID_POPUP_PCB_AUTOPLACE_NEW_MODULES, _("Autoplace New Modules")); + commands->Append( ID_POPUP_PCB_AUTOPLACE_NEXT_MODULE, _("Autoplace Next Module")); + commands->AppendSeparator(); + ADD_MENUITEM(commands, ID_POPUP_PCB_REORIENT_ALL_MODULES, + _("Orient All Modules"), rotate_module_pos_xpm); + PopMenu->AppendSeparator(); + } + if (m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOROUTE) + { + wxMenu * commands = new wxMenu; + PopMenu->Append(ID_POPUP_PCB_AUTOROUTE_COMMANDS, _("Global Autoroute"), commands); + ADD_MENUITEM(commands, ID_POPUP_PCB_SELECT_LAYER_PAIR, + _("Select layer pair"), select_layer_pair_xpm); + commands->AppendSeparator(); + commands->Append( ID_POPUP_PCB_AUTOROUTE_ALL_MODULES, _("Autoroute All Modules")); + commands->AppendSeparator(); + commands->Append( ID_POPUP_PCB_AUTOROUTE_RESET_UNROUTED, _("Reset Unrouted")); + if ( m_Pcb->m_Modules ) + { + commands->AppendSeparator(); + commands->Append( ID_POPUP_PCB_AUTOROUTE_GET_AUTOROUTER, + _("Global AutoRouter")); + commands->Append( ID_POPUP_PCB_AUTOROUTE_GET_AUTOROUTER_DATA, + _("Read Global AutoRouter Data")); + } + PopMenu->AppendSeparator(); + } + + if ( locate_track ) + ADD_MENUITEM_WITH_SUBMENU(PopMenu, Append_Track_Width_List(), + ID_POPUP_PCB_SELECT_WIDTH, _("Select Track Width"), + width_track_xpm); + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_SELECT_LAYER, + _("Select Working Layer"), Select_W_Layer_xpm); + PopMenu->AppendSeparator(); + break; + + } + out: + DrawPanel->CursorOn(&dc); +} + + +/********************************************************************/ +void CreatePopupMenuForTracks(TRACK * Track, wxPoint CursorPosition, + wxMenu * PopMenu) +/*******************************************************************/ +/* Create command lines for a popup menu, for track editing +*/ +{ +int flags = Track->m_Flags; + + if ( flags == 0 ) + { + if ( Track->m_StructType == TYPEVIA) + { + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_MOVE_TRACK_NODE, _("Drag Via"), move_xpm); + wxMenu * via_mnu= new wxMenu(); + ADD_MENUITEM_WITH_SUBMENU(PopMenu, via_mnu, + ID_POPUP_PCB_VIA_EDITING, _("Edit Via"), edit_xpm); + ADD_MENUITEM(via_mnu, ID_POPUP_PCB_VIA_HOLE_TO_DEFAULT, + _("Set via hole to Default"), apply_xpm); + ADD_MENUITEM(via_mnu, ID_POPUP_PCB_VIA_HOLE_TO_VALUE, _("Set via hole to alt value"), options_new_pad_xpm); + ADD_MENUITEM(via_mnu, ID_POPUP_PCB_VIA_HOLE_ENTER_VALUE, _("Set the via hole alt value"), edit_xpm); + ADD_MENUITEM(via_mnu, ID_POPUP_PCB_VIA_HOLE_EXPORT, _("Export Via hole to alt value"), Export_Options_Pad_xpm); + ADD_MENUITEM(via_mnu, ID_POPUP_PCB_VIA_HOLE_EXPORT_TO_OTHERS, _("Export via hole to others id vias"), global_options_pad_xpm); + ADD_MENUITEM(via_mnu, ID_POPUP_PCB_VIA_HOLE_RESET_TO_DEFAULT, _("Set ALL via holes to default"), apply_xpm); + if ( Track->m_Drill <= 0 ) + { + via_mnu->Enable(ID_POPUP_PCB_VIA_HOLE_EXPORT,FALSE); + } + if ( g_ViaHoleLastValue <= 0 ) + via_mnu->Enable(ID_POPUP_PCB_VIA_HOLE_TO_VALUE,FALSE); + } + else + { + if ( Track->IsPointOnEnds(CursorPosition, -1) != 0 ) + { + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_MOVE_TRACK_NODE, + _("Move Node"), move_xpm); + } + else + { + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_BREAK_TRACK, + _("Break Track"), Break_Line_xpm); + } + } + } + + else if( flags & IS_DRAGGED ) // Drag via or node in progress + { + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_PLACE_MOVED_TRACK_NODE, + _("Place Node"), apply_xpm); + return; + } + + else // Edition in progress + { + if( flags & IS_NEW ) + ADD_MENUITEM(PopMenu, ID_POPUP_PCB_END_TRACK, _("End Track"), apply_xpm); + PopMenu->Append(ID_POPUP_PCB_PLACE_VIA, _("Place Via (V)")); + } + + // track Width control : + wxMenu * track_mnu = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU(PopMenu, track_mnu, + ID_POPUP_PCB_EDIT_TRACK_MNU, _("Change Width"), width_track_xpm); + ADD_MENUITEM(track_mnu, ID_POPUP_PCB_EDIT_TRACKSEG, + _("Edit Segment"), width_segment_xpm); + if( !flags ) + { + ADD_MENUITEM(track_mnu, ID_POPUP_PCB_EDIT_TRACK, + _("Edit Track"), width_track_xpm); + ADD_MENUITEM(track_mnu, ID_POPUP_PCB_EDIT_NET, + _("Edit Net"), width_net_xpm); + ADD_MENUITEM(track_mnu, ID_POPUP_PCB_EDIT_ALL_VIAS_AND_TRACK_SIZE, + _("Edit ALL Tracks and Vias"), width_track_via_xpm); + ADD_MENUITEM(track_mnu, ID_POPUP_PCB_EDIT_ALL_VIAS_SIZE, + _("Edit ALL Vias (no track)"), width_vias_xpm); + ADD_MENUITEM(track_mnu, ID_POPUP_PCB_EDIT_ALL_TRACK_SIZE, + _("Edit ALL Tracks (no via)"), width_track_xpm); + } + + // Delete control: + track_mnu = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU( PopMenu, track_mnu, + ID_POPUP_PCB_DELETE_TRACK_MNU, _("Delete"), delete_xpm); + ADD_MENUITEM(track_mnu, ID_POPUP_PCB_DELETE_TRACKSEG, + _("Delete Segment"), Delete_Line_xpm); + if( !flags ) + { + ADD_MENUITEM(track_mnu, ID_POPUP_PCB_DELETE_TRACK, + _("Delete Track"), Delete_Track_xpm); + ADD_MENUITEM(track_mnu, ID_POPUP_PCB_DELETE_TRACKNET, + _("Delete Net"), Delete_Net_xpm); + } + track_mnu = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU( PopMenu, track_mnu, + ID_POPUP_PCB_SETFLAGS_TRACK_MNU, _("Set Flags"), Flag_xpm); + track_mnu->Append(ID_POPUP_PCB_LOCK_ON_TRACKSEG, _("Locked: Yes"), wxEmptyString, TRUE); + track_mnu->Append(ID_POPUP_PCB_LOCK_OFF_TRACKSEG, _("Locked: No"), wxEmptyString, TRUE); + if( Track->GetState(SEGM_FIXE) ) + track_mnu->Check( ID_POPUP_PCB_LOCK_ON_TRACKSEG, TRUE); + else track_mnu->Check( ID_POPUP_PCB_LOCK_OFF_TRACKSEG, TRUE); + + if( !flags ) + { + track_mnu->AppendSeparator(); + track_mnu->Append(ID_POPUP_PCB_LOCK_ON_TRACK, _("Track Locked: Yes")); + track_mnu->Append(ID_POPUP_PCB_LOCK_OFF_TRACK, _("Track Locked: No")); + track_mnu->AppendSeparator(); + track_mnu->Append(ID_POPUP_PCB_LOCK_ON_NET, _("Net Locked: Yes")); + track_mnu->Append(ID_POPUP_PCB_LOCK_OFF_NET, _("Net Locked: No")); + } +} diff --git a/pcbnew/pcbcfg.cpp b/pcbnew/pcbcfg.cpp new file mode 100644 index 0000000000..15f6465246 --- /dev/null +++ b/pcbnew/pcbcfg.cpp @@ -0,0 +1,168 @@ + /***********************************/ + /** pcbcfg() : configuration **/ + /***********************************/ + +/* lit ou met a jour la configuration de PCBNEW */ + +#include "fctsys.h" + +#include "common.h" +#include "pcbnew.h" +#include "pcbplot.h" +#include "pcbcfg.h" +#include "worksheet.h" +#include "id.h" + +#include "protos.h" + +/* Routines Locales */ + +/* Variables locales */ + + +/***********************************************************/ +void WinEDA_PcbFrame::Process_Config(wxCommandEvent& event) +/***********************************************************/ +{ +int id = event.GetId(); +wxPoint pos; +wxClientDC dc(DrawPanel); + + DrawPanel->PrepareGraphicContext(&dc); + + pos = GetPosition(); + pos.x += 20; pos.y += 20; + + switch( id ) + { + case ID_COLORS_SETUP : + DisplayColorSetupFrame(this, pos); + break; + + case ID_CONFIG_REQ : // Creation de la fenetre de configuration + { + InstallConfigFrame(pos); + break; + } + + case ID_PCB_TRACK_SIZE_SETUP: + case ID_PCB_LOOK_SETUP: + case ID_OPTIONS_SETUP: + case ID_PCB_DRAWINGS_WIDTHS_SETUP: + InstallPcbOptionsFrame(pos, &dc, id); + break; + + case ID_PCB_PAD_SETUP: + InstallPadOptionsFrame( NULL, NULL, pos); + break; + + case ID_CONFIG_SAVE: + Update_config(this); + break; + + case ID_CONFIG_READ: + { + wxString FullFileName = GetScreen()->m_FileName.AfterLast('/'); + ChangeFileNameExt(FullFileName, g_Prj_Config_Filename_ext); + FullFileName = EDA_FileSelector(_("Read config file"), + wxPathOnly(GetScreen()->m_FileName),/* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + g_Prj_Config_Filename_ext, /* extension par defaut */ + FullFileName, /* Masque d'affichage */ + this, + wxFD_OPEN, + TRUE /* ne change pas de repertoire courant */ + ); + if ( FullFileName.IsEmpty()) break; + if ( ! wxFileExists(FullFileName) ) + { + wxString msg; + msg.Printf(_("File %s not found"), FullFileName.GetData()); + DisplayError(this, msg); break; + } + Read_Config(FullFileName ); + } + break; + + default: + DisplayError(this, wxT("WinEDA_PcbFrame::Process_Config internal error")); + } +} + + +/**************************************************************************/ +bool Read_Config(const wxString & project_name) +/*************************************************************************/ +/* lit la configuration, si elle n'a pas deja ete lue + 1 - lit .pro + 2 - si non trouve lit /kicad.pro + 3 - si non trouve: init des variables aux valeurs par defaut + + Retourne TRUE si lu, FALSE si config non lue ou non modifiée +*/ +{ +wxString FullFileName; +int ii; + + g_Prj_Config_Filename_ext = wxT(".pro"); + FullFileName = project_name; + ChangeFileNameExt(FullFileName, g_Prj_Config_Filename_ext); + + /* Init des valeurs par defaut */ + g_LibName_List.Clear(); + + EDA_Appl->ReadProjectConfig( FullFileName, + GROUP, ParamCfgList, FALSE); + + /* Traitement des variables particulieres: */ + + SetRealLibraryPath( wxT("modules") ); + + if (ScreenPcb) + { + ScreenPcb->m_Diviseur_Grille = Pcbdiv_grille; + ScreenPcb->m_UserGrid = g_UserGrid; + ScreenPcb->m_UserGridUnit = g_UserGrid_Unit; + } + + g_DesignSettings.m_TrackWidhtHistory[0] = g_DesignSettings.m_CurrentTrackWidth; + g_DesignSettings.m_ViaSizeHistory[0] = g_DesignSettings.m_CurrentViaSize; + for ( ii = 1; ii < HIST0RY_NUMBER; ii++) + { + g_DesignSettings.m_TrackWidhtHistory[ii] = 0; + g_DesignSettings.m_ViaSizeHistory[ii] = 0; + } + + return TRUE; +} + +/**********************************************************/ +void WinEDA_PcbFrame::Update_config(wxWindow * displayframe) +/***********************************************************/ +/* enregistrement de la config */ +{ +wxString FullFileName; +wxString mask; + + mask = wxT("*") + g_Prj_Config_Filename_ext; + FullFileName = GetScreen()->m_FileName.AfterLast('/'); + ChangeFileNameExt(FullFileName, g_Prj_Config_Filename_ext); + + FullFileName = EDA_FileSelector(_("Save config file"), + wxPathOnly(GetScreen()->m_FileName), /* Chemin par defaut */ + FullFileName, /* nom fichier par defaut */ + g_Prj_Config_Filename_ext, /* extension par defaut */ + mask, /* Masque d'affichage */ + displayframe, + wxFD_SAVE, + TRUE + ); + if ( FullFileName.IsEmpty() ) return; + + Pcbdiv_grille = GetScreen()->m_Diviseur_Grille; + + /* ecriture de la configuration */ + EDA_Appl->WriteProjectConfig(FullFileName, wxT("/pcbnew"), ParamCfgList); +} + + diff --git a/pcbnew/pcbcfg.h b/pcbnew/pcbcfg.h new file mode 100644 index 0000000000..d17a9b2cd5 --- /dev/null +++ b/pcbnew/pcbcfg.h @@ -0,0 +1,920 @@ + /**********************************************************/ + /** pcbcfg.h : configuration: definition des structures **/ + /**********************************************************/ + +#define GROUP wxT("/pcbnew") +#define GROUPLIB wxT("/pcbnew/libraries") +#define GROUPCOMMON wxT("/common") + +// Flag for member .m_Setup +// .m_Setup = TRUE: write info in user config +// (i.e. for all project, in registry base or equivalent) +// .m_Setup = FALSE: write info in project config (i.e. only for this project, in .pro file) +#define INSETUP TRUE + + +static int Pcbdiv_grille; /* memorisation temporaire */ + +/* Liste des parametres */ + +static PARAM_CFG_WXSTRING UserLibDirBufCfg +( + wxT("LibDir"), /* identification */ + &g_UserLibDirBuffer, /* Adresse du parametre */ + GROUPLIB +); + +static PARAM_CFG_LIBNAME_LIST LibNameBufCfg +( + wxT("LibName"), /* identification */ + &g_LibName_List, /* Adresse du parametre */ + GROUPLIB +); + +static PARAM_CFG_INT PadDrillCfg +( + wxT("PadDrlX"), /* identification */ + &g_Pad_Master.m_Drill.x, /* Adresse du parametre */ + 320, /* Valeur par defaut */ + 0, 0x7FFF /* Valeurs extremes */ +); + +static PARAM_CFG_INT PadDimHCfg //Pad Diameter / H Size +( + wxT("PadDimH"), /* identification */ + &g_Pad_Master.m_Size.x,/* Adresse du parametre */ + 550, /* Valeur par defaut */ + 0, 0x7FFF /* Valeurs extremes */ +); + +static PARAM_CFG_INT PadDimVCfg +( + wxT("PadDimV"), /* identification */ + &g_Pad_Master.m_Size.y, /* Adresse du parametre */ + 550, /* Valeur par defaut */ + 0, 0x7FFF /* Valeurs extremes */ +); + + +static PARAM_CFG_INT PadFormeCfg +( + wxT("PadForm"), /* identification */ + &g_Pad_Master.m_PadShape, /* Adresse du parametre */ + CIRCLE, /* Valeur par defaut */ + 0, 0x7F /* Valeurs extremes */ +); + +static PARAM_CFG_INT PadMasqueLayerCfg +( + wxT("PadMask"), /* identification */ + &g_Pad_Master.m_Masque_Layer, /* Adresse du parametre */ + 0x0000FFFF /* Valeur par defaut */ +); + +static PARAM_CFG_INT ViaDiametreCfg +( + wxT("ViaDiam"), /* identification */ + &g_DesignSettings.m_CurrentViaSize, /* Adresse du parametre */ + 450, /* Valeur par defaut */ + 0, 0xFFFF /* Valeurs extremes */ +); + +static PARAM_CFG_INT ViaDrillCfg +( + wxT("ViaDril"), /* identification */ + &g_DesignSettings.m_ViaDrill, /* Adresse du parametre */ + 250, /* Valeur par defaut */ + 0, 0xFFFF /* Valeurs extremes */ +); +static PARAM_CFG_INT ViaShowHoleCfg +( + INSETUP, + wxT("ViaSHole"), /* identification */ + &DisplayOpt.m_DisplayViaMode, /* Adresse du parametre */ + VIA_SPECIAL_HOLE_SHOW, /* Valeur par defaut */ + VIA_HOLE_NOT_SHOW, /* Valeurs extremes */ + OPT_VIA_HOLE_END-1 /* Valeurs extremes */ +); + +static PARAM_CFG_INT TrackClearenceCfg +( + wxT("Isol"), /* identification */ + &g_DesignSettings.m_TrackClearence, /* Adresse du parametre */ + 120, /* Valeur par defaut */ + 0, 0xFFFF /* Valeurs extremes */ +); + +static PARAM_CFG_INT LayerCountCfg // Mask Working Layers +( + wxT("Countlayer"), /* identification */ + &g_DesignSettings.m_CopperLayerCount, /* Adresse du parametre */ + 2, /* Valeur par defaut */ + 1, NB_COPPER_LAYERS /* Valeurs extremes */ +); + +static PARAM_CFG_INT TrackWidthCfg +( + wxT("Lpiste"), /* identification */ + &g_DesignSettings.m_CurrentTrackWidth, /* Adresse du parametre */ + 170, /* Valeur par defaut */ + 2, 0xFFFF /* Valeurs extremes */ +); + +static PARAM_CFG_INT RouteLayTopCfg // First current working layer +( + wxT("RouteTo"), /* identification */ + &Route_Layer_TOP, /* Adresse du parametre */ + 15, /* Valeur par defaut */ + 0, 15 /* Valeurs extremes */ +); + +static PARAM_CFG_INT RouteLayBotCfg // second current working layer +( + wxT("RouteBo"), /* identification */ + &Route_Layer_BOTTOM, /* Adresse du parametre */ + 0, /* Valeur par defaut */ + 0, 15 /* Valeurs extremes */ +); + +static PARAM_CFG_INT TypeViaCfg +( + wxT("TypeVia"), /* identification */ + &g_DesignSettings.m_CurrentViaType, /* Adresse du parametre */ + VIA_NORMALE, /* Valeur par defaut */ + 0, 3 /* Valeurs extremes */ +); + +static PARAM_CFG_BOOL Segm45Cfg // Segm Pistes a 0, 45, 90 degres uniquement +( + wxT("Segm45"), /* identification */ + &Track_45_Only, /* Adresse du parametre */ + TRUE /* Valeur par defaut */ +); + +static PARAM_CFG_BOOL Raccord45Cfg // Generation automatique des Raccords a 45 degres +( + wxT("Racc45"), /* identification */ + &g_Raccord_45_Auto, /* Adresse du parametre */ + TRUE /* Valeur par defaut */ +); + +static PARAM_CFG_INT UnitCfg // Units: 0 inch, 1 mm +( + wxT("Unite"), /* identification */ + &g_UnitMetric, /* Adresse du parametre */ + FALSE /* Valeur par defaut */ +); + +static PARAM_CFG_BOOL SegmFillCfg +( + wxT("SegFill"), /* identification */ + &DisplayOpt.DisplayPcbTrackFill, /* Adresse du parametre */ + TRUE /* Valeur par defaut */ +); + +static PARAM_CFG_BOOL NewTrackAfficheGardeCfg +( + wxT("NewAffG"), /* identification */ + &g_ShowIsolDuringCreateTrack, /* Adresse du parametre */ + TRUE /* Valeur par defaut */ +); + +static PARAM_CFG_BOOL TrackAfficheGardeCfg +( + wxT("SegAffG"), /* identification */ + &DisplayOpt.DisplayTrackIsol, /* Adresse du parametre */ + FALSE /* Valeur par defaut */ +); + +static PARAM_CFG_BOOL PadFillCfg +( + wxT("PadFill"), /* identification */ + &DisplayOpt.DisplayPadFill, /* Adresse du parametre */ + TRUE /* Valeur par defaut */ +); + +static PARAM_CFG_BOOL PadAfficheGardeCfg +( + wxT("PadAffG"), /* identification */ + &DisplayOpt.DisplayPadIsol, /* Adresse du parametre */ + TRUE /* Valeur par defaut */ +); + +static PARAM_CFG_BOOL PadShowNumCfg +( + wxT("PadSNum"), /* identification */ + &DisplayOpt.DisplayPadNum, /* Adresse du parametre */ + TRUE /* Valeur par defaut */ +); + +static PARAM_CFG_INT AfficheContourModuleCfg // Module Edges: fill/line/sketch +( + wxT("ModAffC"), /* identification */ + &DisplayOpt.DisplayModEdge, /* Adresse du parametre */ + FILAIRE, /* Valeur par defaut */ + 0, 2 /* Valeurs extremes */ +); + +static PARAM_CFG_INT AfficheTexteModuleCfg // Module Texts: fill/line/sketch +( + wxT("ModAffT"), /* identification */ + &DisplayOpt.DisplayModText, /* Adresse du parametre */ + FILAIRE, /* Valeur par defaut */ + 0, 2 /* Valeurs extremes */ +); + +static PARAM_CFG_INT AfficheTextePcbCfg // PCB Texts: fill/line/sketch +( + wxT("PcbAffT"), /* identification */ + &DisplayOpt.DisplayDrawItems, /* Adresse du parametre */ + FILAIRE, /* Valeur par defaut */ + 0, 2 /* Valeurs extremes */ +); + +static PARAM_CFG_BOOL SegmPcb45Cfg // Force 45 degrees for segments +( + wxT("SgPcb45"), /* identification */ + &Segments_45_Only, /* Adresse du parametre */ + TRUE /* Valeur par defaut */ +); + +static PARAM_CFG_INT TextePcbDimVCfg +( + wxT("TxtPcbV"), /* identification */ + &g_DesignSettings.m_PcbTextSize.y, /* Adresse du parametre */ + 600, /* Valeur par defaut */ + 10, 2000 /* Valeurs extremes */ +); + +static PARAM_CFG_INT TextePcbDimHCfg +( + wxT("TxtPcbH"), /* identification */ + &g_DesignSettings.m_PcbTextSize.x, /* Adresse du parametre */ + 600, /* Valeur par defaut */ + 10, 2000 /* Valeurs extremes */ +); + +static PARAM_CFG_SETCOLOR ColorLayer0Cfg // CU Layer Color +( + INSETUP, + wxT("ColLay0"), /* identification */ + &g_DesignSettings.m_LayerColor[0], /* Adresse du parametre */ + GREEN /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer1Cfg +( + INSETUP, + wxT("ColLay1"), /* identification */ + &g_DesignSettings.m_LayerColor[1], /* Adresse du parametre */ + BLUE /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer2Cfg +( + INSETUP, + wxT("ColLay2"), /* identification */ + &g_DesignSettings.m_LayerColor[2], /* Adresse du parametre */ + LIGHTGRAY /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer3Cfg +( + INSETUP, + wxT("ColLay3"), /* identification */ + &g_DesignSettings.m_LayerColor[3], /* Adresse du parametre */ + 5 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer4Cfg +( + INSETUP, + wxT("ColLay4"), /* identification */ + &g_DesignSettings.m_LayerColor[4], /* Adresse du parametre */ + 4 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer5Cfg +( + INSETUP, + wxT("ColLay5"), /* identification */ + &g_DesignSettings.m_LayerColor[5], /* Adresse du parametre */ + 5 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer6Cfg +( + INSETUP, + wxT("ColLay6"), /* identification */ + &g_DesignSettings.m_LayerColor[6], /* Adresse du parametre */ + 6 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer7Cfg +( + INSETUP, + wxT("ColLay7"), /* identification */ + &g_DesignSettings.m_LayerColor[7], /* Adresse du parametre */ + 5 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer8Cfg +( + INSETUP, + wxT("ColLay8"), /* identification */ + &g_DesignSettings.m_LayerColor[8], /* Adresse du parametre */ + 7 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer9Cfg +( + INSETUP, + wxT("ColLay9"), /* identification */ + &g_DesignSettings.m_LayerColor[9], /* Adresse du parametre */ + 1 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer10Cfg +( + INSETUP, + wxT("ColLayA"), /* identification */ + &g_DesignSettings.m_LayerColor[10], /* Adresse du parametre */ + 2 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer11Cfg +( + INSETUP, + wxT("ColLayB"), /* identification */ + &g_DesignSettings.m_LayerColor[11], /* Adresse du parametre */ + 3 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer12Cfg +( + INSETUP, + wxT("ColLayC"), /* identification */ + &g_DesignSettings.m_LayerColor[12], /* Adresse du parametre */ + 12 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer13Cfg +( + INSETUP, + wxT("ColLayD"), /* identification */ + &g_DesignSettings.m_LayerColor[13], /* Adresse du parametre */ + 13 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer14Cfg +( + INSETUP, + wxT("ColLayE"), /* identification */ + &g_DesignSettings.m_LayerColor[14], /* Adresse du parametre */ + 14 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer15Cfg // CMP Layer Color +( + INSETUP, + wxT("ColLayF"), /* identification */ + &g_DesignSettings.m_LayerColor[15], /* Adresse du parametre */ + RED /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer16Cfg // Adhesive CU Layer Color +( + INSETUP, + wxT("ColLayG"), /* identification */ + &g_DesignSettings.m_LayerColor[16], /* Adresse du parametre */ + 1 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer17Cfg // Adhesive CMP Layer Color +( + INSETUP, + wxT("ColLayH"), /* identification */ + &g_DesignSettings.m_LayerColor[17], /* Adresse du parametre */ + 5 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer18Cfg // Solder Mask CU Layer Color +( + INSETUP, + wxT("ColLayI"), /* identification */ + &g_DesignSettings.m_LayerColor[18], /* Adresse du parametre */ + 11 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer19Cfg // Solder Mask CMP Layer Color +( + INSETUP, + wxT("ColLayJ"), /* identification */ + &g_DesignSettings.m_LayerColor[19], /* Adresse du parametre */ + 4 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer20Cfg // Silk Screen CU Layer Color +( + INSETUP, + wxT("ColLayK"), /* identification */ + &g_DesignSettings.m_LayerColor[20], /* Adresse du parametre */ + 5 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer21Cfg // Silk Screen CMP Layer Color +( + INSETUP, + wxT("ColLayL"), /* identification */ + &g_DesignSettings.m_LayerColor[21], /* Adresse du parametre */ + 3 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer22Cfg // Mask CU Layer Color +( + INSETUP, + wxT("ColLayM"), /* identification */ + &g_DesignSettings.m_LayerColor[22], /* Adresse du parametre */ + 6 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer23Cfg // Mask CMP Layer Color +( + INSETUP, + wxT("ColLayN"), /* identification */ + &g_DesignSettings.m_LayerColor[23], /* Adresse du parametre */ + 5 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer24Cfg // DRAW Layer Color +( + INSETUP, + wxT("ColLayO"), /* identification */ + &g_DesignSettings.m_LayerColor[24], /* Adresse du parametre */ + LIGHTGRAY /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer25Cfg // Comment Layer Color +( + INSETUP, + wxT("ColLayP"), /* identification */ + &g_DesignSettings.m_LayerColor[25], /* Adresse du parametre */ + 1 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer26Cfg // ECO1 Layer Color +( + INSETUP, + wxT("ColLayQ"), /* identification */ + &g_DesignSettings.m_LayerColor[26], /* Adresse du parametre */ + 2 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer27Cfg //ECO2 Layer Color +( + INSETUP, + wxT("ColLayR"), /* identification */ + &g_DesignSettings.m_LayerColor[27], /* Adresse du parametre */ + 14 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer28Cfg // EDGES Layer Color +( + INSETUP, + wxT("ColLayS"), /* identification */ + &g_DesignSettings.m_LayerColor[28], /* Adresse du parametre */ + YELLOW /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer29Cfg +( + INSETUP, + wxT("ColLayT"), /* identification */ + &g_DesignSettings.m_LayerColor[29], /* Adresse du parametre */ + 13 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer30Cfg +( + INSETUP, + wxT("ColLayU"), /* identification */ + &g_DesignSettings.m_LayerColor[30], /* Adresse du parametre */ + 14 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorLayer31Cfg +( + INSETUP, + wxT("ColLayV"), /* identification */ + &g_DesignSettings.m_LayerColor[31], /* Adresse du parametre */ + 7 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorTxtModCmpCfg +( + INSETUP, + wxT("CTxtMoC"), /* identification */ + &g_ModuleTextCMPColor, /* Adresse du parametre */ + LIGHTGRAY /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorTxtModCuCfg +( + INSETUP, + wxT("CTxtMoS"), /* identification */ + &g_ModuleTextCUColor, /* Adresse du parametre */ + 1 /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR VisibleTxtModCfg +( + INSETUP, + wxT("CTxtVis"), /* identification */ + &g_ModuleTextNOVColor, /* Adresse du parametre */ + DARKGRAY /* Valeur par defaut */ +); + +static PARAM_CFG_INT TexteModDimVCfg +( + wxT("TxtModV"), /* identification */ + &ModuleTextSize.y, /* Adresse du parametre */ + 500, /* Valeur par defaut */ + 1, 20000 /* Valeurs extremes */ +); + +static PARAM_CFG_INT TexteModDimHCfg +( + wxT("TxtModH"), /* identification */ + &ModuleTextSize.x, /* Adresse du parametre */ + 500, /* Valeur par defaut */ + 1, 20000 /* Valeurs extremes */ +); + +static PARAM_CFG_INT TexteModWidthCfg +( + wxT("TxtModW"), /* identification */ + &ModuleTextWidth, /* Adresse du parametre */ + 100, /* Valeur par defaut */ + 1, 10000 /* Valeurs extremes */ +); + +static PARAM_CFG_SETCOLOR ColorAncreModCfg +( + INSETUP, + wxT("CAncreM"), /* identification */ + &g_AnchorColor, /* Adresse du parametre */ + BLUE /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorPadCuCfg +( + INSETUP, + wxT("CoPadCu"), /* identification */ + &g_PadCUColor, /* Adresse du parametre */ + GREEN /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorPadCmpCfg +( + INSETUP, + wxT("CoPadCm"), /* identification */ + &g_PadCMPColor, /* Adresse du parametre */ + RED /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorViaNormCfg +( + INSETUP, + wxT("CoViaNo"), /* identification */ + &g_DesignSettings.m_ViaColor[VIA_NORMALE], /* Adresse du parametre */ + LIGHTGRAY /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorViaborgneCfg +( + INSETUP, + wxT("CoViaBo"), /* identification */ + &g_DesignSettings.m_ViaColor[VIA_BORGNE], /* Adresse du parametre */ + CYAN /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorViaEnterreeCfg // Buried Via Color +( + INSETUP, + wxT("CoViaEn"), /* identification */ + &g_DesignSettings.m_ViaColor[VIA_ENTERREE], /* Adresse du parametre */ + BROWN /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorpcbGrilleCfg +( + INSETUP, + wxT("CoPcbGr"), /* identification */ + &g_PcbGridColor, /* Adresse du parametre */ + DARKGRAY /* Valeur par defaut */ +); + +static PARAM_CFG_SETCOLOR ColorCheveluCfg +( + INSETUP, + wxT("CoRatsN"), /* identification */ + &g_DesignSettings.m_RatsnestColor, /* Adresse du parametre */ + WHITE /* Valeur par defaut */ +); + +static PARAM_CFG_INT HPGLpenNumCfg +( + wxT("HPGLnum"), /* identification */ + &g_HPGL_Pen_Num, /* Adresse du parametre */ + 1, /* Valeur par defaut */ + 1, 16 /* Valeurs extremes */ +); + +static PARAM_CFG_INT HPGLdiamCfg // HPGL pen size (mils) +( + wxT("HPGdiam"), /* identification */ + &g_HPGL_Pen_Diam, /* Adresse du parametre */ + 15, /* Valeur par defaut */ + 0,100 /* Valeurs extremes */ +); + +static PARAM_CFG_INT HPGLspeedCfg //HPGL pen speed (cm/s) +( + wxT("HPGLSpd"), /* identification */ + &g_HPGL_Pen_Speed, /* Adresse du parametre */ + 20, /* Valeur par defaut */ + 0,1000 /* Valeurs extremes */ +); + +static PARAM_CFG_INT HPGLrecouvrementCfg +( + wxT("HPGLrec"), /* identification */ + &g_HPGL_Pen_Recouvrement, /* Adresse du parametre */ + 2, /* Valeur par defaut */ + 0,0x100 /* Valeurs extremes */ +); + +static PARAM_CFG_BOOL HPGLcenterCfg //HPGL Org Coord ( 0 normal, 1 Centre) +( + wxT("HPGLorg"), /* identification */ + &HPGL_Org_Centre, /* Adresse du parametre */ + FALSE /* Valeur par defaut */ +); + +static PARAM_CFG_INT GERBERSpotMiniCfg //Aperture Mini (mils) +( + wxT("GERBmin"), /* identification */ + &spot_mini, /* Adresse du parametre */ + 15, /* Valeur par defaut */ + 1,100 /* Valeurs extremes */ +); + +static PARAM_CFG_INT VernisEpargneGardeCfg +( + wxT("VEgarde"), /* identification */ + &g_DesignSettings.m_MaskMargin, /* Adresse du parametre */ + 100, /* Valeur par defaut */ + 0,0xFFFF /* Valeurs extremes */ +); + +static PARAM_CFG_INT DrawSegmLargeurCfg +( + wxT("DrawLar"), /* identification */ + &g_DesignSettings.m_DrawSegmentWidth, /* Adresse du parametre */ + 120, /* Valeur par defaut */ + 0,0xFFFF /* Valeurs extremes */ +); + +static PARAM_CFG_INT EdgeSegmLargeurCfg +( + wxT("EdgeLar"), /* identification */ + &g_DesignSettings.m_EdgeSegmentWidth, /* Adresse du parametre */ + 120, /* Valeur par defaut */ + 0,0xFFFF /* Valeurs extremes */ +); + +static PARAM_CFG_INT TexteSegmLargeurCfg +( + wxT("TxtLar"), /* identification */ + &g_DesignSettings.m_PcbTextWidth, /* Adresse du parametre */ + 120, /* Valeur par defaut */ + 0,0xFFFF /* Valeurs extremes */ +); + +static PARAM_CFG_INT ModuleSegmWidthCfg +( + wxT("MSegLar"), /* identification */ + &ModuleSegmentWidth, /* Adresse du parametre */ + 120, /* Valeur par defaut */ + 0,0xFFFF /* Valeurs extremes */ +); + +static PARAM_CFG_INT FormatPlotCfg +( + wxT("ForPlot"), /* identification */ + &format_plot, /* Adresse du parametre */ + 1, /* Valeur par defaut */ + 0,3 /* Valeurs extremes */ +); + +static PARAM_CFG_INT WTraitSerigraphiePlotCfg +( + wxT("WpenSer"), /* identification */ + &g_PlotLine_Width, /* Adresse du parametre */ + 10, /* Valeur par defaut */ + 1,10000 /* Valeurs extremes */ +); + +static PARAM_CFG_DOUBLE UserGrilleXCfg +( + wxT("UserGrX"), /* identification */ + &g_UserGrid.x, /* Adresse du parametre */ + 0.01, /* Valeur par defaut */ + 0.0001, 100.0 /* Valeurs extremes (inches)*/ +); + +static PARAM_CFG_DOUBLE UserGrilleYCfg +( + wxT("UserGrY"), /* identification */ + &g_UserGrid.y, /* Adresse du parametre */ + 0.01, /* Valeur par defaut */ + 0.0001, 100.0 /* Valeurs extremes (inches)*/ +); + +static PARAM_CFG_INT UserGrilleUnitCfg +( + wxT("UserGrU"), /* identification */ + &g_UserGrid_Unit, /* Adresse du parametre */ + 1, /* Valeur par defaut */ + 0, 1 /* Valeurs extremes */ +); + +static PARAM_CFG_INT DivGrillePcbCfg +( + wxT("DivGrPc"), /* identification */ + &Pcbdiv_grille, /* Adresse du parametre */ + 1, /* Valeur par defaut */ + 1,10 /* Valeurs extremes */ +); + +static PARAM_CFG_INT TimeOutCfg //Duree entre Sauvegardes auto en secondes +( + wxT("TimeOut"), /* identification */ + &g_TimeOut, /* Adresse du parametre */ + 600, /* Valeur par defaut */ + 0,60000 /* Valeurs extremes */ +); + +static PARAM_CFG_BOOL DisplPolairCfg +( + INSETUP, + wxT("DPolair"), /* identification */ + &DisplayOpt.DisplayPolarCood, /* Adresse du parametre */ + FALSE /* Valeur par defaut */ +); + +static PARAM_CFG_INT CursorShapeCfg +( + INSETUP, + wxT("CuShape"), /* identification */ + &g_CursorShape, /* Adresse du parametre */ + 0, /* Valeur par defaut */ + 0, 1 /* Valeurs extremes */ +); + +static PARAM_CFG_INT PrmMaxLinksShowed +( + wxT("MaxLnkS"), /* identification */ + &g_MaxLinksShowed, /* Adresse du parametre */ + 3, /* Valeur par defaut */ + 0, 15 /* Valeurs extremes */ +); + +static PARAM_CFG_BOOL ShowRatsnestCfg +( + wxT("ShowRat"), /* identification */ + &g_Show_Ratsnest, /* Adresse du parametre */ + FALSE /* Valeur par defaut */ +); + +static PARAM_CFG_BOOL ShowModuleRatsnestCfg +( + wxT("ShowMRa"), /* identification */ + &g_Show_Module_Ratsnest, /* Adresse du parametre */ + TRUE /* Valeur par defaut */ +); + +static PARAM_CFG_BOOL TwoSegmentTrackBuildCfg +( + INSETUP, + wxT("TwoSegT"), /* identification */ + &g_TwoSegmentTrackBuild, /* Adresse du parametre */ + TRUE /* Valeur par defaut */ +); + +PARAM_CFG_BASE * ParamCfgList[] = +{ + & UserLibDirBufCfg, + & LibNameBufCfg, + & PadDrillCfg, + & PadDimHCfg, + & PadDimVCfg, + & PadFormeCfg, + & PadMasqueLayerCfg, + & ViaDiametreCfg, + & ViaDrillCfg, + & ViaShowHoleCfg, + & TrackClearenceCfg, + & LayerCountCfg, + & TrackWidthCfg, + & RouteLayTopCfg, + & RouteLayBotCfg, + & TypeViaCfg, + & Segm45Cfg, + & Raccord45Cfg, + & UnitCfg, + & SegmFillCfg, + & TrackAfficheGardeCfg, + & NewTrackAfficheGardeCfg, + & PadFillCfg, + & PadAfficheGardeCfg, + & PadShowNumCfg, + & AfficheContourModuleCfg, + & AfficheTexteModuleCfg, + & AfficheTextePcbCfg, + & SegmPcb45Cfg, + & TextePcbDimVCfg, + & TextePcbDimHCfg, + & ColorLayer0Cfg, + & ColorLayer1Cfg, + & ColorLayer2Cfg, + & ColorLayer3Cfg, + & ColorLayer4Cfg, + & ColorLayer5Cfg, + & ColorLayer6Cfg, + & ColorLayer7Cfg, + & ColorLayer8Cfg, + & ColorLayer9Cfg, + & ColorLayer10Cfg, + & ColorLayer11Cfg, + & ColorLayer12Cfg, + & ColorLayer13Cfg, + & ColorLayer14Cfg, + & ColorLayer15Cfg, + & ColorLayer16Cfg, + & ColorLayer17Cfg, + & ColorLayer18Cfg, + & ColorLayer19Cfg, + & ColorLayer20Cfg, + & ColorLayer21Cfg, + & ColorLayer22Cfg, + & ColorLayer23Cfg, + & ColorLayer24Cfg, + & ColorLayer25Cfg, + & ColorLayer26Cfg, + & ColorLayer27Cfg, + & ColorLayer28Cfg, + & ColorLayer29Cfg, + & ColorLayer30Cfg, + & ColorLayer31Cfg, + & ColorTxtModCmpCfg, + & ColorTxtModCuCfg, + & VisibleTxtModCfg, + & TexteModDimVCfg, + & TexteModDimHCfg, + & TexteModWidthCfg, + & ColorAncreModCfg, + & ColorPadCuCfg, + & ColorPadCmpCfg, + & ColorViaNormCfg, + & ColorViaborgneCfg, + & ColorViaEnterreeCfg, + & ColorpcbGrilleCfg, + & ColorCheveluCfg, + & HPGLpenNumCfg, + & HPGLdiamCfg, + & HPGLspeedCfg, + & HPGLrecouvrementCfg, + & HPGLcenterCfg, + & GERBERSpotMiniCfg, + & VernisEpargneGardeCfg, + & DrawSegmLargeurCfg, + & EdgeSegmLargeurCfg, + & TexteSegmLargeurCfg, + & ModuleSegmWidthCfg, + & FormatPlotCfg, + & WTraitSerigraphiePlotCfg, + & UserGrilleXCfg, + & UserGrilleYCfg, + & UserGrilleUnitCfg, + & DivGrillePcbCfg, + & TimeOutCfg, + & DisplPolairCfg, + & CursorShapeCfg, + & PrmMaxLinksShowed, + & ShowRatsnestCfg, + & ShowModuleRatsnestCfg, + & TwoSegmentTrackBuildCfg, + + NULL +}; diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp new file mode 100644 index 0000000000..6dea1f5366 --- /dev/null +++ b/pcbnew/pcbframe.cpp @@ -0,0 +1,488 @@ +/****************************************************************/ +/* pcbframe.cpp - fonctions des classes du type WinEDA_PcbFrame */ +/****************************************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "pcbnew.h" + +#include "bitmaps.h" +#include "protos.h" +#include "id.h" + + + + /*******************************/ + /* class WinEDA_PcbFrame */ + /*******************************/ + +BEGIN_EVENT_TABLE(WinEDA_PcbFrame, wxFrame) + + COMMON_EVENTS_DRAWFRAME + + EVT_SOCKET(ID_EDA_SOCKET_EVENT_SERV, WinEDA_PcbFrame::OnSockRequestServer) + EVT_SOCKET(ID_EDA_SOCKET_EVENT, WinEDA_PcbFrame::OnSockRequest) + + EVT_KICAD_CHOICEBOX(ID_ON_ZOOM_SELECT,WinEDA_PcbFrame::OnSelectZoom) + EVT_KICAD_CHOICEBOX(ID_ON_GRID_SELECT,WinEDA_PcbFrame::OnSelectGrid) + + EVT_CLOSE(WinEDA_PcbFrame::OnCloseWindow) + EVT_SIZE(WinEDA_PcbFrame::OnSize) + + EVT_TOOL_RANGE(ID_ZOOM_PLUS_BUTT, ID_ZOOM_PAGE_BUTT, + WinEDA_PcbFrame::Process_Zoom) + + EVT_TOOL(ID_LOAD_FILE, WinEDA_PcbFrame::Files_io) + EVT_TOOL(ID_MENU_READ_LAST_SAVED_VERSION_BOARD, WinEDA_PcbFrame::Files_io) + EVT_TOOL(ID_MENU_RECOVER_BOARD, WinEDA_PcbFrame::Files_io) + EVT_TOOL(ID_NEW_BOARD, WinEDA_PcbFrame::Files_io) + EVT_TOOL(ID_SAVE_BOARD, WinEDA_PcbFrame::Files_io) + EVT_TOOL(ID_OPEN_MODULE_EDITOR, WinEDA_PcbFrame::Process_Special_Functions) + + EVT_MENU_RANGE(ID_PREFERENCES_FONT_INFOSCREEN, ID_PREFERENCES_FONT_END, + WinEDA_DrawFrame::ProcessFontPreferences) + + // Menu Files: + + EVT_MENU(ID_MAIN_MENUBAR, WinEDA_PcbFrame::Process_Special_Functions) + + EVT_MENU(ID_MENU_LOAD_FILE, WinEDA_PcbFrame::Files_io) + EVT_MENU(ID_MENU_NEW_BOARD, WinEDA_PcbFrame::Files_io) + EVT_MENU(ID_MENU_SAVE_BOARD, WinEDA_PcbFrame::Files_io) + EVT_MENU(ID_MENU_APPEND_FILE, WinEDA_PcbFrame::Files_io) + EVT_MENU(ID_MENU_SAVE_BOARD_AS, WinEDA_PcbFrame::Files_io) + EVT_MENU(ID_GEN_PLOT, WinEDA_PcbFrame::ToPlotter) + EVT_MENU_RANGE(ID_LOAD_FILE_1,ID_LOAD_FILE_10, + WinEDA_PcbFrame::Files_io) + + EVT_MENU(ID_GEN_EXPORT_FILE_GENCADFORMAT, WinEDA_PcbFrame::ExportToGenCAD) + EVT_MENU(ID_GEN_EXPORT_FILE_MODULE_REPORT, WinEDA_PcbFrame::GenModuleReport) + + EVT_MENU(ID_MENU_ARCHIVE_NEW_MODULES, WinEDA_PcbFrame::Process_Special_Functions) + EVT_MENU(ID_MENU_ARCHIVE_ALL_MODULES, WinEDA_PcbFrame::Process_Special_Functions) + + EVT_MENU(ID_EXIT, WinEDA_PcbFrame::Process_Special_Functions) + + // menu Config + EVT_MENU(ID_CONFIG_REQ, WinEDA_PcbFrame::Process_Config) + EVT_MENU(ID_COLORS_SETUP, WinEDA_PcbFrame::Process_Config) + EVT_MENU(ID_OPTIONS_SETUP, WinEDA_PcbFrame::Process_Config) + EVT_MENU(ID_PCB_TRACK_SIZE_SETUP, WinEDA_PcbFrame::Process_Config) + EVT_MENU(ID_PCB_DRAWINGS_WIDTHS_SETUP, WinEDA_PcbFrame::Process_Config) + EVT_MENU(ID_PCB_PAD_SETUP, WinEDA_PcbFrame::Process_Config) + EVT_MENU(ID_PCB_LOOK_SETUP, WinEDA_PcbFrame::Process_Config) + EVT_MENU(ID_CONFIG_SAVE, WinEDA_PcbFrame::Process_Config) + EVT_MENU(ID_CONFIG_READ, WinEDA_PcbFrame::Process_Config) + EVT_MENU(ID_PCB_USER_GRID_SETUP, WinEDA_PcbFrame::Process_Special_Functions) + + EVT_MENU_RANGE(ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, + WinEDA_DrawFrame::SetLanguage) + + // menu Postprocess + EVT_MENU(ID_PCB_GEN_POS_MODULES_FILE,WinEDA_PcbFrame::GenModulesPosition) + EVT_MENU(ID_PCB_GEN_DRILL_FILE,WinEDA_PcbFrame::InstallDrillFrame) + EVT_MENU(ID_PCB_GEN_CMP_FILE,WinEDA_PcbFrame::Files_io) + + // menu Miscellaneous + EVT_MENU(ID_MENU_LIST_NETS, WinEDA_PcbFrame::Liste_Equipot) + EVT_MENU(ID_PCB_GLOBAL_DELETE, WinEDA_PcbFrame::Process_Special_Functions) + EVT_MENU(ID_MENU_PCB_CLEAN, WinEDA_PcbFrame::Process_Special_Functions) + EVT_MENU(ID_MENU_PCB_SWAP_LAYERS, WinEDA_PcbFrame::Process_Special_Functions) + + // Menu Help + EVT_MENU(ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp) + EVT_MENU(ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout) + + // Menu 3D Frame + EVT_MENU(ID_MENU_PCB_SHOW_3D_FRAME, WinEDA_PcbFrame::Show3D_Frame) + + // Horizontal toolbar + EVT_TOOL(ID_TO_LIBRARY, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_SHEET_SET, WinEDA_DrawFrame::Process_PageSettings) + EVT_TOOL(wxID_CUT, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(wxID_COPY, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(wxID_PASTE, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_UNDO_BUTT, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_GEN_PRINT, WinEDA_DrawFrame::ToPrinter) + EVT_TOOL(ID_GEN_PLOT, WinEDA_DrawFrame::Process_Special_Functions) + EVT_TOOL(ID_FIND_ITEMS, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_GET_NETLIST, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_DRC_CONTROL, WinEDA_PcbFrame::Process_Special_Functions) + EVT_KICAD_CHOICEBOX(ID_TOOLBARH_PCB_SELECT_LAYER, + WinEDA_PcbFrame::Process_Special_Functions) + EVT_KICAD_CHOICEBOX(ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, + WinEDA_PcbFrame::Process_Special_Functions) + EVT_KICAD_CHOICEBOX(ID_AUX_TOOLBAR_PCB_VIA_SIZE, + WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_TOOLBARH_PCB_AUTOPLACE, WinEDA_PcbFrame::AutoPlace) + EVT_TOOL(ID_TOOLBARH_PCB_AUTOROUTE, WinEDA_PcbFrame::AutoPlace) + + // Option toolbar + EVT_TOOL_RANGE(ID_TB_OPTIONS_START,ID_TB_OPTIONS_END, + WinEDA_PcbFrame::OnSelectOptionToolbar) + + // Vertical toolbar: + EVT_TOOL(ID_NO_SELECT_BUTT, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_PCB_HIGHLIGHT_BUTT, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_COMPONENT_BUTT, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_TRACK_BUTT, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_PCB_ZONES_BUTT, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_PCB_MIRE_BUTT, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_PCB_ARC_BUTT, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_PCB_CIRCLE_BUTT, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_TEXT_COMMENT_BUTT, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_LINE_COMMENT_BUTT, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_PCB_COTATION_BUTT, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_PCB_DELETE_ITEM_BUTT, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_PCB_SHOW_1_RATSNEST_BUTT, WinEDA_PcbFrame::Process_Special_Functions) + EVT_TOOL(ID_PCB_PLACE_OFFSET_COORD_BUTT, WinEDA_PcbFrame::Process_Special_Functions) + + EVT_TOOL_RANGE(ID_PCB_MUWAVE_START_CMD,ID_PCB_MUWAVE_END_CMD, + WinEDA_PcbFrame::ProcessMuWaveFunctions) + + EVT_TOOL_RCLICKED(ID_TRACK_BUTT, WinEDA_PcbFrame::ToolOnRightClick) + EVT_TOOL_RCLICKED(ID_PCB_CIRCLE_BUTT, WinEDA_PcbFrame::ToolOnRightClick) + EVT_TOOL_RCLICKED(ID_PCB_ARC_BUTT, WinEDA_PcbFrame::ToolOnRightClick) + EVT_TOOL_RCLICKED(ID_TEXT_COMMENT_BUTT, WinEDA_PcbFrame::ToolOnRightClick) + EVT_TOOL_RCLICKED(ID_LINE_COMMENT_BUTT, WinEDA_PcbFrame::ToolOnRightClick) + EVT_TOOL_RCLICKED(ID_PCB_COTATION_BUTT, WinEDA_PcbFrame::ToolOnRightClick) + + EVT_MENU_RANGE(ID_POPUP_PCB_AUTOPLACE_START_RANGE, + ID_POPUP_PCB_AUTOPLACE_END_RANGE, + WinEDA_PcbFrame::AutoPlace) + + EVT_MENU_RANGE(ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_END_RANGE, + WinEDA_PcbFrame::Process_Special_Functions) + + // Annulation de commande en cours + EVT_MENU_RANGE(ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, + WinEDA_PcbFrame::Process_Special_Functions ) + + // PopUp Menus pour Zooms traités dans drawpanel.cpp + +END_EVENT_TABLE() + + +///////****************************///////////: + + /****************/ + /* Constructeur */ + /****************/ + +WinEDA_PcbFrame::WinEDA_PcbFrame(wxWindow * father, WinEDA_App *parent, + const wxString & title, + const wxPoint& pos, const wxSize& size) : + WinEDA_BasePcbFrame(father, parent, PCB_FRAME, title, pos, size) +{ + m_FrameName = wxT("PcbFrame"); + m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines + m_Draw_Grid = g_ShowGrid; // TRUE pour avoir la grille dessinee + m_Draw_Sheet_Ref = TRUE; // TRUE pour avoir le cartouche dessiné + m_Draw_Auxiliary_Axis = TRUE; + m_SelTrackWidthBox = NULL; + m_SelViaSizeBox = NULL; + m_SelLayerBox = NULL; + m_ZoomMaxValue = 2048; + m_SelTrackWidthBox_Changed = FALSE; + m_SelViaSizeBox_Changed = FALSE; + + m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; + m_DisplayPadFill = DisplayOpt.DisplayPadFill; + m_DisplayPadNum = DisplayOpt.DisplayPadNum; + + m_DisplayModEdge = DisplayOpt.DisplayModEdge; + m_DisplayModText = DisplayOpt.DisplayModText; + + // Give an icon + SetIcon( wxICON(a_icon_pcbnew) ); + + m_InternalUnits = PCB_INTERNAL_UNIT; // Unites internes = 1/10000 inch + m_CurrentScreen = ScreenPcb; + GetSettings(); + SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y); + + wxSize GridSize(500,500); + if ( m_Parent && m_Parent->m_EDA_Config ) + { + long SizeX, SizeY; + if ( m_Parent->m_EDA_Config->Read( wxT("PcbEditGrid_X"), &SizeX) && + m_Parent->m_EDA_Config->Read( wxT("PcbEditGrid_Y"), &SizeY) ) + { + GridSize.x = SizeX; + GridSize.y = SizeY; + } + m_Parent->m_EDA_Config->Read( wxT("PcbMagPadOpt"), & g_MagneticPadOption); + } + GetScreen()->SetGrid(GridSize); + + if ( DrawPanel ) DrawPanel->m_Block_Enable = TRUE; + ReCreateMenuBar(); + ReCreateHToolbar(); + ReCreateAuxiliaryToolbar(); + ReCreateVToolbar(); + ReCreateOptToolbar(); +} + +WinEDA_PcbFrame::~WinEDA_PcbFrame(void) +{ + m_Parent->m_PcbFrame = NULL; + m_CurrentScreen = ScreenPcb; +} + + +/********************************************************/ +void WinEDA_PcbFrame::OnCloseWindow(wxCloseEvent & Event) +/********************************************************/ +{ +PCB_SCREEN * screen; + + DrawPanel->m_AbortRequest = TRUE; + + screen = ScreenPcb ; + while( screen ) + { + if(screen->IsModify()) break; + screen = screen->Next(); + } + + if ( screen ) + { + unsigned ii; + wxMessageDialog dialog(this, _("Board modified, Save before exit ?"), + _("Confirmation"), wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT); + ii = dialog.ShowModal(); + switch ( ii ) + { + case wxID_CANCEL: + Event.Veto(); + return; + + case wxID_NO: + break; + + case wxID_OK: + case wxID_YES: + SavePcbFile(GetScreen()->m_FileName); + break; + } + } + + while( screen ) // suppression flag modify pour eviter d'autres message + { + screen->ClrModify(); + screen = screen->Next(); + } + + /* Reselection de l'ecran de base, + pour les evenements de refresh générés par wxWindows */ + m_CurrentScreen = ActiveScreen = ScreenPcb; + + SaveSettings(); + if ( m_Parent && m_Parent->m_EDA_Config ) + { + wxSize GridSize = GetScreen()->GetGrid(); + m_Parent->m_EDA_Config->Write( wxT("PcbEditGrid_X"), (long)GridSize.x); + m_Parent->m_EDA_Config->Write( wxT("PcbEditGrid_Y"), (long)GridSize.y); + m_Parent->m_EDA_Config->Write( wxT("PcbMagPadOpt"), (long)g_MagneticPadOption); + } + Destroy(); +} + + +/***************************************/ +void WinEDA_PcbFrame::SetToolbars(void) +/***************************************/ +/* +Active ou desactive les tools des toolbars, en fonction des commandes +en cours +*/ +{ +int ii, jj; + + if ( m_ID_current_state == ID_TRACK_BUTT ) + { + if ( Drc_On ) DrawPanel->SetCursor(wxCursor(wxCURSOR_PENCIL)); + else DrawPanel->SetCursor(wxCursor(wxCURSOR_QUESTION_ARROW)); + } + + + if( m_HToolBar == NULL ) return; + + m_HToolBar->EnableTool(ID_SAVE_BOARD,m_CurrentScreen->IsModify()); + + if ( m_CurrentScreen->BlockLocate.m_Command == BLOCK_MOVE ) + { + m_HToolBar->EnableTool(wxID_CUT,TRUE); + m_HToolBar->EnableTool(wxID_COPY,TRUE); + } + else + { + m_HToolBar->EnableTool(wxID_CUT,FALSE); + m_HToolBar->EnableTool(wxID_COPY,FALSE); + } + + if ( g_UnDeleteStackPtr ) + { + m_HToolBar->EnableTool(wxID_PASTE,TRUE); + } + else + { + m_HToolBar->EnableTool(wxID_PASTE,FALSE); + } + + if ( g_UnDeleteStackPtr ) + { + m_HToolBar->EnableTool(ID_UNDO_BUTT,TRUE); + } + else m_HToolBar->EnableTool(ID_UNDO_BUTT,FALSE); + + if ( m_OptionsToolBar ) + { + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_DRC_OFF, + ! Drc_On); + m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_DRC_OFF, + Drc_On ? _("DCR Off (Disable !!!), Currently: DRC is active") : _("DRC On (Currently: DRC is DISABLE !!!)")); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_MM, + g_UnitMetric == MILLIMETRE ? TRUE : FALSE); + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_INCH, + g_UnitMetric == INCHES ? TRUE : FALSE); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_POLAR_COORD, + DisplayOpt.DisplayPolarCood); + m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_POLAR_COORD, + DisplayOpt.DisplayPolarCood ? _("Polar Coords not show") : _("Display Polar Coords")); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_GRID, + m_Draw_Grid); + m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_GRID, + m_Draw_Grid ? _("Grid not show") : _("Show Grid")); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_CURSOR, + g_CursorShape); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_RATSNEST, + g_Show_Ratsnest); + m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_RATSNEST, + g_Show_Ratsnest ? _("General ratsnest not show") : _("Show General ratsnest")); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_MODULE_RATSNEST, + g_Show_Module_Ratsnest); + m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_MODULE_RATSNEST, + g_Show_Module_Ratsnest ? _("Module ratsnest not show") : _("Show Module ratsnest")); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_AUTO_DEL_TRACK, + g_AutoDeleteOldTrack); + m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_AUTO_DEL_TRACK, + g_AutoDeleteOldTrack ? _("Disable Auto Delete old Track") : _("Enable Auto Delete old Track")); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_ZONES, + DisplayOpt.DisplayZones); + m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_ZONES, + DisplayOpt.DisplayZones ? _("Do not Show Zones") : _("Show Zones")); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_PADS_SKETCH, + ! m_DisplayPadFill); + m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_PADS_SKETCH, + m_DisplayPadFill ? _("Show Pads Sketch mode") : _("Show pads filled mode")); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, + ! m_DisplayPcbTrackFill); + m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, + m_DisplayPcbTrackFill ? _("Show Tracks Sketch mode") : _("Show Tracks filled mode")); + + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_HIGHT_CONTRAST_MODE, + DisplayOpt.ContrastModeDisplay); + m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_HIGHT_CONTRAST_MODE, + DisplayOpt.ContrastModeDisplay ? _("Normal Contrast Mode Display") : _("Hight Contrast Mode Display")); + + } + + if ( m_AuxiliaryToolBar ) + { + wxString msg; + if ( m_SelTrackWidthBox && m_SelTrackWidthBox_Changed) + { + m_SelTrackWidthBox_Changed = FALSE; + m_SelTrackWidthBox->Clear(); + wxString format = _("Track"); + if ( g_UnitMetric == INCHES ) format += wxT(" %.1f"); + else format += wxT(" %.3f"); + for ( ii = 0; ii < HIST0RY_NUMBER; ii++) + { + if ( g_DesignSettings.m_TrackWidhtHistory[ii] == 0 ) break; // Fin de liste + double value = To_User_Unit(g_UnitMetric, + g_DesignSettings.m_TrackWidhtHistory[ii], PCB_INTERNAL_UNIT); + + if ( g_UnitMetric == INCHES ) + msg.Printf(format.GetData(), value * 1000); + else + msg.Printf(format.GetData(), value); + m_SelTrackWidthBox->Append(msg); + if ( g_DesignSettings.m_TrackWidhtHistory[ii] == g_DesignSettings.m_CurrentTrackWidth ) + m_SelTrackWidthBox->SetSelection(ii); + } + } + + if ( m_SelViaSizeBox && m_SelViaSizeBox_Changed ) + { + m_SelViaSizeBox_Changed = FALSE; + m_SelViaSizeBox->Clear(); + wxString format = _("Via"); + if ( g_UnitMetric == INCHES ) format += wxT(" %.1f"); + else format += wxT(" %.3f"); + for ( ii = 0; ii < HIST0RY_NUMBER; ii++) + { + if ( g_DesignSettings.m_ViaSizeHistory[ii] == 0 ) break; // Fin de liste + double value = To_User_Unit(g_UnitMetric, + g_DesignSettings.m_ViaSizeHistory[ii], PCB_INTERNAL_UNIT); + + if ( g_UnitMetric == INCHES ) + msg.Printf(format.GetData(), value * 1000); + else + msg.Printf(format.GetData(), value); + m_SelViaSizeBox->Append(msg); + if ( g_DesignSettings.m_ViaSizeHistory[ii] == g_DesignSettings.m_CurrentViaSize ) + m_SelViaSizeBox->SetSelection(ii); + } + } + + if ( m_SelZoomBox ) + { + int old_choice = m_SelZoomBox->GetChoice(); + int new_choice = 1; + int zoom; + for ( jj = 1, zoom = 1; zoom <= m_ZoomMaxValue; zoom <<= 1, jj++ ) + { + if ( m_CurrentScreen && (m_CurrentScreen->GetZoom() == zoom) ) + break; + new_choice++; + } + if ( old_choice != new_choice ) + m_SelZoomBox->SetSelection(new_choice); + } + + if ( m_SelGridBox && m_CurrentScreen) + { + int kk = m_SelGridBox->GetChoice(); + for ( ii = 0; g_GridList[ii].x > 0; ii++ ) + { + if ( !m_CurrentScreen->m_UserGridIsON && + (m_CurrentScreen->GetGrid().x == g_GridList[ii].x) && + (m_CurrentScreen->GetGrid().y == g_GridList[ii].y) ) + { + if (kk != ii) m_SelGridBox->SetSelection(ii); + kk = ii; + break; + } + } + if ( kk != ii ) + m_SelGridBox->SetSelection(ii); /* User Grid */ + } + } + + ReCreateLayerBox(NULL); + + DisplayUnitsMsg(); +} diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp new file mode 100644 index 0000000000..3b7a3dffd0 --- /dev/null +++ b/pcbnew/pcbnew.cpp @@ -0,0 +1,101 @@ + /*************************/ + /* PCBNEW: main program */ + /*************************/ + +#define MAIN +#define eda_global + +#include "fctsys.h" + +#include +#include + +#include "common.h" +#include "pcbnew.h" +#include "pcbplot.h" +#include "autorout.h" +#include "trigo.h" +#include "cell.h" +#include "worksheet.h" + +#include "protos.h" + +#include "drag.h" + +#include "eda_dde.h" + +wxString g_Main_Title( wxT("PCBNEW") ); + +IMPLEMENT_APP(WinEDA_App) + +/****************************/ +bool WinEDA_App::OnInit(void) +/****************************/ +{ +wxString FFileName; + + EDA_Appl = this; + InitEDA_Appl( wxT("pcbnew") ); + + if ( m_Checker && m_Checker->IsAnotherRunning() ) + { + if ( ! IsOK(NULL, _("Pcbnew is already running, Continue?") ) ) + return false; + } + + /* Add image handlers for screen hardcopy */ + wxImage::AddHandler( new wxPNGHandler ); + wxImage::AddHandler( new wxJPEGHandler ); + + ScreenPcb = new PCB_SCREEN(PCB_FRAME); + GetSettings(); + + if(argc > 1) + { + FFileName = MakeFileName(wxEmptyString, argv[1], PcbExtBuffer); + wxSetWorkingDirectory( wxPathOnly(FFileName) ); + } + + Read_Config(FFileName); + g_DrawBgColor = BLACK; + + /* allocation de la memoire pour le fichier et autres buffers: */ + /* On reserve BUFMEMSIZE octets de ram pour calcul */ + buf_work = adr_lowmem = (char*)MyZMalloc(BUFMEMSIZE) ; /* adresse de la zone de calcul */ + adr_himem = adr_lowmem + BUFMEMSIZE; /* adr limite haute */ + adr_max = adr_lowmem; + + if( adr_lowmem == NULL ) + { + printf( "No Memory, Fatal err Memory alloc\n" ); + return(FALSE) ; + } + m_PcbFrame = new WinEDA_PcbFrame(NULL, this, wxT("PcbNew"), + wxPoint(0,0), wxSize(600,400) ); + wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); + m_PcbFrame->SetTitle(Title); + ActiveScreen = ScreenPcb; + m_PcbFrame->m_Pcb = new BOARD(NULL, m_PcbFrame); + + SetTopWindow(m_PcbFrame); + m_PcbFrame->Show(TRUE); + + if( CreateServer(m_PcbFrame, KICAD_PCB_PORT_SERVICE_NUMBER) ) + { + SetupServerFunction(RemoteCommand); + } + + m_PcbFrame->Zoom_Automatique(TRUE); + + /* Load file specified in the command line. */ + if ( ! FFileName.IsEmpty() ) + { + wxClientDC dc(m_PcbFrame->DrawPanel); + m_PcbFrame->DrawPanel->PrepareGraphicContext(&dc); + m_PcbFrame->LoadOnePcbFile(FFileName, &dc, FALSE); + } + + return TRUE; +} + + diff --git a/pcbnew/pcbnew.h b/pcbnew/pcbnew.h new file mode 100644 index 0000000000..b652a6d3f8 --- /dev/null +++ b/pcbnew/pcbnew.h @@ -0,0 +1,309 @@ + /**************************************/ + /* PCBNEW.H : déclarations communes */ + /**************************************/ +#ifndef PCBNEW_H +#define PCBNEW_H + +#ifndef eda_global +#define eda_global extern +#endif + +#include "pcbstruct.h" +#include "macros.h" + +#define U_PCB (PCB_INTERNAL_UNIT/EESCHEMA_INTERNAL_UNIT) + +/* valeur de flag indicant si le pointeur de reference pour une localisation +est le curseur sur grille ou le curseur a deplacement fin hors grille */ +#define CURSEUR_ON_GRILLE 0 +#define CURSEUR_OFF_GRILLE 1 + +#define START 0 /* ctes parametre dans les routines de localisation */ +#define END 1 + +#define DIM_ANCRE_MODULE 3 /* dim du symbole de l'ancre (centre) des modules */ +#define DIM_ANCRE_TEXTE 2 /* dim du symbole de l'ancre (centre) des textes */ + +/* Gestion du Menu Zoom */ +#define ZOOM_PLUS -1 +#define ZOOM_MOINS -2 +#define ZOOM_AUTO -3 +#define ZOOM_CENTER -4 +#define ZOOM_REDRAW -5 + +/* Bits Flags utilisés en édition (membre .m_Flags de EDA_BaseStruct)*/ +#define IS_LINKED 1 +#define IN_EDIT 2 +#define IS_MOVED 4 +#define IS_NEW 8 +#define IS_RESIZED 0x10 +#define IS_DRAGGED 0x20 +#define STARTPOINT 0x100 +#define ENDPOINT 0x200 +#define SELECTED 0x400 + +/* Definition des cas ou l'on force l'affichage en SKETCH (membre .flags) */ +#define FORCE_SKETCH (DRAG | EDIT ) + +/* Constantes pour options lecture fichier PCB */ +#define APPEND_PCB 1 /* pour ajout d'un nouveau circuit */ +#define NEWPCB 0 /* pour chargement normal */ + + +eda_global wxArrayString g_LibName_List; // library list to load + +eda_global wxSize g_GridList[] +#ifdef MAIN + = { + wxSize(1000,1000), wxSize(500,500), wxSize(250,250), wxSize(200,200), + wxSize(100,100), wxSize(50,50), wxSize(25,25), wxSize(20,20), + wxSize(10,10), wxSize(5,5), wxSize(2,2), wxSize(1,1), + wxSize(-1,-1), wxSize(0,0) +} +#endif +; + +#define UNDELETE_STACK_SIZE 10 +eda_global EDA_BaseStruct * g_UnDeleteStack[UNDELETE_STACK_SIZE]; //Liste des elements supprimes +eda_global int g_UnDeleteStackPtr; + +eda_global bool g_ShowGrid +#ifdef MAIN += TRUE +#endif +; + +/* Look up Table for conversion one layer number -> one bit layer mask: */ +eda_global int g_TabOneLayerMask[LAYER_COUNT] +#if defined MAIN + = { 0x00000001,0x00000002,0x00000004,0x00000008, + 0x00000010,0x00000020,0x00000040,0x00000080, + 0x00000100,0x00000200,0x00000400,0x00000800, + 0x00001000,0x00002000,0x00004000,0x00008000, + 0x00010000,0x00020000,0x00040000,0x00080000, + 0x00100000,0x00200000,0x00400000,0x00800000, + 0x01000000,0x02000000,0x04000000,0x08000000, + 0x10000000,0x20000000,0x40000000,0x80000000 + } +#endif + ; + +/* Look up Table for conversion copper layer count -> general copper layer mask: */ +eda_global int g_TabAllCopperLayerMask[NB_COPPER_LAYERS] +#if defined MAIN + = { + 0x0001, 0x8001, 0x8003, 0x8007, + 0x800F, 0x801F, 0x803F, 0x807F, + 0x80FF, 0x81FF, 0x83FF, 0x87FF, + 0x8FFF, 0x9FFF, 0xCFFF, 0xFFFF +}; +#endif + ; + +/* variables */ + +extern wxString g_Main_Title; + +eda_global bool Drc_On +#ifdef MAIN += TRUE +#endif +; +eda_global bool g_AutoDeleteOldTrack /* autorise effacement automatique + de l'ancienne piste lors des redessins de pistes */ +#ifdef MAIN += TRUE +#endif +; +eda_global bool g_No_Via_Route; +eda_global bool g_Drag_Pistes_On; +eda_global bool g_Show_Ratsnest; +eda_global bool g_Show_Module_Ratsnest; +eda_global bool g_Show_Pads_Module_in_Move +#ifdef MAIN += TRUE +#endif +; +eda_global bool g_Raccord_45_Auto +#ifdef MAIN += TRUE +#endif +; +eda_global bool g_ShowIsolDuringCreateTrack; /* .State controle l'affichage + de l'isolation en trace de piste */ + + /**************************************************************/ + /* Options d'affichages (remplissages des segments, textes..) */ + /**************************************************************/ + +eda_global DISPLAY_OPTIONS DisplayOpt; + +eda_global bool Track_45_Only; /* Flag pour limiter l'inclinaison + pistes a 45 degres seulement */ +eda_global bool Segments_45_Only ; /* Flag pour limiter l'inclinaison + edge pcb a 45 degres seulement */ +eda_global wxString PcbExtBuffer +#ifdef MAIN +( wxT(".brd")) +#endif +; +eda_global wxString g_SaveFileName // File Name for periodic saving +#ifdef MAIN +( wxT("$savepcb") ) +#endif +; +eda_global wxString NetNameBuffer; +eda_global wxString NetExtBuffer +#ifdef MAIN +( wxT(".net") ) +#endif +; +eda_global wxString NetCmpExtBuffer +#ifdef MAIN +( wxT(".cmp") ) +#endif +; + +// Gestion de la liste des librairies +eda_global wxString LibExtBuffer +#ifdef MAIN +( wxT(".mod") ) +#endif +; +eda_global wxString g_Shapes3DExtBuffer // extension des fichiers de formes 3D +#ifdef MAIN +( wxT(".wrl") ) +#endif +; + +eda_global int g_NetType; // for cvpcb: Net type identifier + +eda_global int g_CurrentVersionPCB +#ifdef MAIN += 1 +#endif +; + +#define BUFMEMSIZE 256000 /* taille du buffer de travail (en octets) */ +eda_global char *buf_work ; /* pointeur sur le buffer de travail */ +eda_global char * adr_lowmem ; /* adresse de base memoire de calcul disponible*/ +eda_global char * adr_himem ; /* adresse haute limite de la memoire disponible*/ +eda_global char * adr_max ; /* adresse haute maxi utilisee pour la memoire */ + + +/* variables génerales */ +eda_global char cbuf[1024] ; /* buffer de formatage texte */ +eda_global BOARD * g_ModuleEditor_Pcb; /* Pointeur de l'entete pcb de l'editeur de module*/ +eda_global int g_TimeOut; // Duree entre 2 sauvegardes automatiques +eda_global int g_SaveTime; // heure de la prochaine sauvegarde + + +/* Variables generales d'empreintes */ +extern int Angle_Rot_Module; +eda_global wxSize ModuleTextSize; /* dim des textes sur Modules par defaut */ +eda_global int ModuleTextWidth; +eda_global int ModuleSegmentWidth; +eda_global int Texte_Module_Type; + + + /***********************/ + /* pistes , vias , pads*/ + /***********************/ + +#define NO_TST_LAYER -1 /* parametre de Locate_Pistes(): suppression tst layer */ +#define L_MIN_DESSIN 1 /* seuil de largeur des pistes pour trace autre que filaire */ + +// Current designe settings: +eda_global class EDA_BoardDesignSettings g_DesignSettings; + +// valeurs par defaut des caract. des pads +#ifndef GERBVIEW +#ifdef MAIN +D_PAD g_Pad_Master( (MODULE *) NULL); +#else +extern D_PAD g_Pad_Master; +#endif +#endif + + +eda_global int Route_Layer_TOP ; +eda_global int Route_Layer_BOTTOM; /* couches de routage actif */ + +eda_global int g_MaxLinksShowed; // determine le nombre max de links affichés + // en routage manuel +eda_global bool g_TwoSegmentTrackBuild // FALSE = 1 segment build, TRUE = 2 45 deg segm build +#ifdef MAIN += TRUE +#endif +; + +/* How to handle magentic pad: feature to move the pcb cursor on a pad center */ +enum MagneticPadOptionValues { + no_effect, + capture_cursor_in_track_tool, + capture_always +}; +eda_global int g_MagneticPadOption +#ifdef MAIN += capture_cursor_in_track_tool +#endif +; +eda_global bool g_HightLigt_Status; +eda_global int g_HightLigth_NetCode /* pour mise en surbrillance des pistes */ +#ifdef MAIN += -1 +#endif +; /* net_code du net a mettre en surbrillance */ + +eda_global TRACK * g_CurrentTrackSegment ; // pointeur sur le segment en cours de trace +eda_global TRACK * g_FirstTrackSegment ; // pointeur sur le debut de la piste en cours +eda_global int g_TrackSegmentCount ; // nombre de points deja traces + + +eda_global wxString g_ViaType_Name[4] +#if defined MAIN + = { + wxT("???"), // Unused + _("Blind Via"), // from inner layer to external layer (TOP or BOTTOM) + _("Buried Via"), // from inner to inner layer + _("Standard Via") // Usual via (from TOP to BOTTOM layer) + } +#endif +; +eda_global int g_ViaHoleLastValue; // Last value for non default value via hole + +/* Couleur de fond affichage de bas d'ecran */ +eda_global int g_PcbGridColor; + +/* couleurs des autres items des empreintes */ +#if defined MAIN +int g_PadCMPColor = RED; +int g_PadCUColor = GREEN; +int g_AnchorColor = BLUE; +int g_ModuleTextCMPColor = LIGHTGRAY; +int g_ModuleTextCUColor = MAGENTA; +int g_ModuleTextNOVColor = DARKGRAY; +#else +eda_global int g_ModuleTextCMPColor; +eda_global int g_ModuleTextCUColor; +eda_global int g_ModuleTextNOVColor; +eda_global int g_AnchorColor; +eda_global int g_PadCUColor; +eda_global int g_PadCMPColor; +#endif + +eda_global PCB_SCREEN* ScreenPcb; /* Ecran principal */ +eda_global PCB_SCREEN* ScreenModule; /* Ecran de l'editeur de modules */ + + + /****************************************************/ + /* Gestion du deplacement des modules et des pistes */ + /****************************************************/ + +eda_global wxPoint g_Offset_Module; /* Offset de trace du modul en depl */ + +/* Pad editing */ +eda_global wxString g_Current_PadName; // Last used pad name (pad num) + + +#endif /* PCBNEW_H */ diff --git a/pcbnew/pcbnew.r b/pcbnew/pcbnew.r new file mode 100644 index 0000000000..10f6506f95 --- /dev/null +++ b/pcbnew/pcbnew.r @@ -0,0 +1,8 @@ +data 'vers' (2) { +$"0100 2000 0000 0531 2E30 6430 0531 2E30" +$"6430"} ; + +data 'vers' (1) { +$"0100 2000 0000 0531 2E30 6430 0531 2E30" +$"6430"} ; + diff --git a/pcbnew/pcbnew.rc b/pcbnew/pcbnew.rc new file mode 100644 index 0000000000..2494b509f9 --- /dev/null +++ b/pcbnew/pcbnew.rc @@ -0,0 +1,4 @@ +a_icon_pcbnew ICON "icon_pcbnew.ico" +icon_w3d ICON "icon_w3d.ico" +icon_modedit ICON "icon_modedit.ico" +#include "wx/msw/wx.rc" diff --git a/pcbnew/pcbpiste.cpp b/pcbnew/pcbpiste.cpp new file mode 100644 index 0000000000..ff9bd0626f --- /dev/null +++ b/pcbnew/pcbpiste.cpp @@ -0,0 +1,284 @@ + /******************************************************/ + /* Fonctions diverses (swap..) relatives au pistes */ + /* et fonctions de test */ + /******************************************************/ + + /* Fichier PCBPISTE.CPP */ + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "protos.h" + +/* Variables locales */ +static int New_Layer[32]; + +enum swap_layer_id { + ID_SWAP_LAYER_EXECUTE = 1800, + ID_SWAP_LAYER_CANCEL, + ID_SWAP_LAYER_BUTTON_SELECT, + ID_SWAP_LAYER_DESELECT, + ID_SWAP_LAYER_SELECT +}; + + +/***********************************************/ +/* classe pour la frame de selection de layers */ +/***********************************************/ + +class WinEDA_SwapLayerFrame: public wxDialog +{ +private: + WinEDA_BasePcbFrame *m_Parent; + wxRadioBox * m_LayerList; + +public: + + // Constructor and destructor + WinEDA_SwapLayerFrame(WinEDA_BasePcbFrame *parent); + ~WinEDA_SwapLayerFrame(void) {}; + +private: + void Sel_Layer(wxCommandEvent& event); + void Cancel(wxCommandEvent& event); + void Execute(wxCommandEvent& event); + DECLARE_EVENT_TABLE() + +}; +/* Table des evenements pour WinEDA_SwapLayerFrame */ +BEGIN_EVENT_TABLE(WinEDA_SwapLayerFrame, wxDialog) + EVT_BUTTON(ID_SWAP_LAYER_EXECUTE, WinEDA_SwapLayerFrame::Execute) + EVT_BUTTON(ID_SWAP_LAYER_CANCEL, WinEDA_SwapLayerFrame::Cancel) + EVT_BUTTON(ID_SWAP_LAYER_DESELECT, WinEDA_SwapLayerFrame::Sel_Layer) + EVT_BUTTON(ID_SWAP_LAYER_BUTTON_SELECT, WinEDA_SwapLayerFrame::Sel_Layer) + EVT_RADIOBOX(ID_SWAP_LAYER_SELECT, WinEDA_SwapLayerFrame::Sel_Layer) +END_EVENT_TABLE() + + +WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame(WinEDA_BasePcbFrame *parent): + wxDialog(parent, -1, _("Swap Layers:"),wxPoint(-1,-1), + wxSize(470, 450), DIALOG_STYLE ) +{ +#define START_Y 15 +wxButton * Button; +int ii; +wxPoint pos; +wxString g_Layer_Name_Pair[32]; +wxSize winsize; + + m_Parent = parent; + SetFont(*g_DialogFont); + + for ( ii = 0; ii < NB_LAYERS; ii++ ) + { + g_Layer_Name_Pair[ii] = ReturnPcbLayerName(ii) + wxT(" -> ") + _("No Change"); + } + pos.x = 5; pos.y = START_Y; + m_LayerList = new wxRadioBox(this, ID_SWAP_LAYER_SELECT, _("Layers"), + pos, wxSize(-1,-1), 29, g_Layer_Name_Pair, 16, wxRA_SPECIFY_ROWS); + + winsize.y = m_LayerList->GetRect().GetBottom(); + + pos.x = m_LayerList->GetRect().GetRight() + 12; + Button = new wxButton(this,ID_SWAP_LAYER_CANCEL, + _("Cancel"), pos); + Button->SetForegroundColour(*wxRED); + winsize.x = MAX(winsize.x,Button->GetRect().GetRight()); + + pos.y += Button->GetSize().y + 5; + Button = new wxButton(this,ID_SWAP_LAYER_EXECUTE, + _("OK"), pos); + Button->SetForegroundColour(*wxBLUE); + winsize.x = MAX(winsize.x,Button->GetRect().GetRight()); + + pos.y += Button->GetSize().y + 15; + Button = new wxButton(this,ID_SWAP_LAYER_DESELECT, + _("Deselect"), pos); + Button->SetForegroundColour(wxColour(0,100,0)); + winsize.x = MAX(winsize.x,Button->GetRect().GetRight()); + + pos.y += Button->GetSize().y + 5; + Button = new wxButton(this,ID_SWAP_LAYER_BUTTON_SELECT, + _("Select"), pos); + Button->SetForegroundColour(wxColour(0,100,100)); + winsize.x = MAX(winsize.x,Button->GetRect().GetRight()); + + winsize.x += 10; winsize.y += 10; + SetClientSize(winsize); + +} + + +/***************************************************************/ +void WinEDA_SwapLayerFrame::Sel_Layer(wxCommandEvent& event) +/***************************************************************/ +{ + int ii, jj; + + ii = m_LayerList->GetSelection(); + + switch ( event.GetId()) + { + case ID_SWAP_LAYER_DESELECT: + if ( New_Layer[ii] != -1 ) + { + New_Layer[ii] = -1; + m_LayerList->SetString(ii, ReturnPcbLayerName(ii) + + + wxT(" -> ") + _("No Change") ); + } + break; + + case ID_SWAP_LAYER_BUTTON_SELECT: + case ID_SWAP_LAYER_SELECT: + jj = m_Parent->SelectLayer(ii, -1, -1); + if ( (jj < 0) || (jj >= 29) ) return; + + if ( ii != jj ) + { + New_Layer[ii] = jj; + m_LayerList->SetString(ii, + ReturnPcbLayerName(ii) + wxT(" -> ") + ReturnPcbLayerName(jj) ); + } + break; + } +} + +/*********************************************************/ +void WinEDA_SwapLayerFrame::Cancel(wxCommandEvent& event) +/*********************************************************/ +{ + EndModal(-1); +} + +/*********************************************************/ +void WinEDA_SwapLayerFrame::Execute(wxCommandEvent& event) +/*********************************************************/ +{ + EndModal(1); +} + + +/********************************************************/ +void WinEDA_PcbFrame::Swap_Layers(wxCommandEvent & event) +/********************************************************/ +/* Swap layers */ +{ +int ii, jj ; +TRACK * pt_segm ; +DRAWSEGMENT * pt_drawsegm; +EDA_BaseStruct * PtStruct; + + + /* Init default values */ + for ( ii = 0 ; ii < 32 ; ii++ ) New_Layer[ii] = -1 ; + +WinEDA_SwapLayerFrame * frame = new WinEDA_SwapLayerFrame(this); + ii = frame->ShowModal(); frame->Destroy(); + + if ( ii != 1 ) return; + + /* Modifications des pistes */ + pt_segm = (TRACK*) m_Pcb->m_Track; + for ( ; pt_segm != NULL;pt_segm = (TRACK*)pt_segm->Pnext ) + { + m_CurrentScreen->SetModify(); + if( pt_segm->m_StructType == TYPEVIA ) + { + SEGVIA * Via = (SEGVIA *) pt_segm; + if ( Via->Shape() == VIA_NORMALE ) continue; + int top_layer, bottom_layer; + Via->ReturnLayerPair(&top_layer, &bottom_layer); + if( New_Layer[bottom_layer] >= 0) + bottom_layer = New_Layer[bottom_layer]; + if( New_Layer[top_layer] >= 0) + top_layer = New_Layer[top_layer]; + Via->SetLayerPair(top_layer, bottom_layer); + } + else + { + jj = pt_segm->m_Layer; + if( New_Layer[jj] >= 0) pt_segm->m_Layer = New_Layer[jj]; + } + } + + /* Modifications des zones */ + pt_segm = (TRACK*) m_Pcb->m_Zone; + for ( ; pt_segm != NULL;pt_segm = (TRACK*)pt_segm->Pnext ) + { + m_CurrentScreen->SetModify(); + jj = pt_segm->m_Layer; + if( New_Layer[jj] >= 0) pt_segm->m_Layer = New_Layer[jj]; + } + + /* Modifications des autres segments */ + PtStruct = m_Pcb->m_Drawings; + for ( ; PtStruct != NULL ; PtStruct = PtStruct->Pnext ) + { + if( PtStruct->m_StructType == TYPEDRAWSEGMENT ) + { + m_CurrentScreen->SetModify(); + pt_drawsegm = (DRAWSEGMENT *) PtStruct; + jj = pt_drawsegm->m_Layer; + if( New_Layer[jj] >= 0) pt_drawsegm->m_Layer = New_Layer[jj]; + } + } + DrawPanel->Refresh(TRUE); +} + +/*********************************************************/ +void WinEDA_PcbFrame::Liste_Equipot(wxCommandEvent & event) +/*********************************************************/ +{ +EQUIPOT * Equipot ; +wxString msg; +WinEDA_TextFrame * List; +int ii, jj; + + msg = wxT("*"); + Get_Message(_("Filter for net names:"),msg, this); + if ( msg.IsEmpty() ) return; + + List = new WinEDA_TextFrame(this, _("List Nets") ); + + Equipot = (EQUIPOT*) m_Pcb->m_Equipots; + for ( ; Equipot != NULL; Equipot = (EQUIPOT*)Equipot->Pnext ) + { + wxString Line; + /* calcul adr relative du nom de la pastille reference de la piste */ + if( ! WildCompareString(msg, Equipot->m_Netname, FALSE ) ) continue ; + + Line.Printf( wxT("net_code = %3.3d [%.16s] "),Equipot->m_NetCode, + Equipot->m_Netname.GetData()); + List->Append(Line); + } + ii = List->ShowModal(); List->Destroy(); + if (ii < 0) return; + + /* Recherche du numero de net rellement selectionné */ + Equipot = (EQUIPOT*) m_Pcb->m_Equipots; + for ( jj = 0; Equipot != NULL; Equipot = (EQUIPOT*)Equipot->Pnext ) + { + /* calcul adr relative du nom de la pastille reference de la piste */ + if( ! WildCompareString(msg, Equipot->m_Netname, FALSE) ) continue ; + if ( ii == jj ) + { + ii = Equipot->m_NetCode; + break; + } + jj++; + } + + +wxClientDC dc(DrawPanel); + DrawPanel->PrepareGraphicContext(&dc); + + if(g_HightLigt_Status) Hight_Light(&dc); + g_HightLigth_NetCode = ii; + Hight_Light(&dc); +} + + + diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp new file mode 100644 index 0000000000..297acf6c1b --- /dev/null +++ b/pcbnew/pcbplot.cpp @@ -0,0 +1,581 @@ + /***********************/ + /* fichier pcbplot.cpp */ + /***********************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "plot_common.h" +#include "pcbnew.h" +#include "pcbplot.h" +#include "worksheet.h" +#include "id.h" + +#include "protos.h" + +#define PLOT_DEFAULT_MARGE 300 // mils + +/* variables locale : */ +static long s_SelectedLayers = CUIVRE_LAYER | CMP_LAYER | + SILKSCREEN_LAYER_CMP | SILKSCREEN_LAYER_CU; +static bool s_PlotOriginIsAuxAxis = FALSE; + +/* Routines Locales */ + +enum id_plotps +{ + ID_CLOSE_PLOT = 8020, + ID_DRILL_SHAPE_OPT, + ID_SCALE_OPT, + ID_ROTATE_OPT, + ID_MIROR_OPT, + ID_EXEC_PLOT, + ID_PLOT_MODE_OPT, + ID_MASKVIA_OPT, + ID_PLOT_CENTRE_OPT, + ID_SEL_PLOT_FORMAT, + ID_SEL_GERBER_FORMAT, + ID_SAVE_OPT_PLOT, + ID_PRINT_REF, + ID_PRINT_VALUE, + ID_PRINT_MODULE_TEXTS, + ID_FORCE_PRINT_INVISIBLE_TEXT, + ID_PRINT_PAD_ON_SILKSCREEN, + ID_FORCE_PRINT_PAD, + ID_CREATE_DRILL_FILE, + ID_SEL_PLOT_OFFSET_OPTION +}; + + + /*******************************/ + /* Dialog box for plot control */ + /*******************************/ + +class WinEDA_PlotFrame: public wxDialog +{ +public: + WinEDA_BasePcbFrame * m_Parent; + wxButton * m_MergePlotButton; + wxCheckBox * m_BoxSelecLayer[32]; + wxRadioBox * m_PlotFormatOpt; + wxRadioBox * m_Choice_Plot_Offset; + wxRadioBox * m_Drill_Shape_Opt; + wxRadioBox * m_Scale_Opt; + wxRadioBox * m_PlotModeOpt; + wxCheckBox * m_PlotMirorOpt; + wxCheckBox * m_PlotNoViaOnMaskOpt; + wxCheckBox * m_HPGL_PlotCenter_Opt; + wxCheckBox * m_Plot_Sheet_Ref; + wxCheckBox * m_Plot_Invisible_Text; + wxCheckBox * m_Plot_Text_Value; + wxCheckBox * m_Plot_Text_Ref; + wxCheckBox * m_Plot_Text_Div; + wxCheckBox * m_Plot_Pads_on_Silkscreen; + wxCheckBox * m_Force_Plot_Pads; + wxCheckBox * m_Plot_PS_Negative; + WinEDA_ValueCtrl * m_GerbSpotSizeMinOpt; + WinEDA_ValueCtrl * m_LinesWidth; + WinEDA_ValueCtrl * m_HPGLPenSizeOpt; + WinEDA_ValueCtrl * m_HPGLPenSpeedOpt; + WinEDA_ValueCtrl * m_HPGLPenOverlayOpt; + WinEDA_DFloatValueCtrl * m_FineAdjustXscaleOpt, * m_FineAdjustYscaleOpt; + double m_XScaleAdjust, m_YScaleAdjust; + int m_PlotFormat; + +public: + WinEDA_PlotFrame(WinEDA_BasePcbFrame * parent); +private: + void Plot(wxCommandEvent & event); + void OnQuit(wxCommandEvent & event); + void OnClose(wxCloseEvent & event); + void SetCommands(wxCommandEvent & event); + void SaveOptPlot(wxCommandEvent & event); + void CreateDrillFile(wxCommandEvent & event); + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(WinEDA_PlotFrame, wxDialog) + EVT_CLOSE(WinEDA_PlotFrame::OnClose) + EVT_BUTTON(ID_CLOSE_PLOT, WinEDA_PlotFrame::OnQuit) + EVT_BUTTON(ID_EXEC_PLOT, WinEDA_PlotFrame::Plot) + EVT_BUTTON(ID_SAVE_OPT_PLOT, WinEDA_PlotFrame::SaveOptPlot) + EVT_BUTTON(ID_CREATE_DRILL_FILE, WinEDA_PlotFrame::CreateDrillFile) + EVT_RADIOBOX(ID_SEL_PLOT_FORMAT, WinEDA_PlotFrame::SetCommands) +END_EVENT_TABLE() + + + +#define UNITS_MILS 1000 +#define H_SIZE 640 +#define V_SIZE 430 +/********************************************************************/ +WinEDA_PlotFrame::WinEDA_PlotFrame(WinEDA_BasePcbFrame * parent): + wxDialog(parent, -1, _("Plot"), + wxPoint(-1,-1), wxSize(H_SIZE, V_SIZE), + wxDEFAULT_DIALOG_STYLE) +/********************************************************************/ +{ +wxButton * Button; +int ii; + + m_Parent = parent; + SetFont(*g_DialogFont); + Centre(); + m_PlotFormat = format_plot; + m_Plot_Sheet_Ref = NULL; + + wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(MainBoxSizer); + wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * MidRightBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * MidLeftBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(MidLeftBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(MidRightBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(RightBoxSizer, 0, wxGROW|wxALL, 5); + + wxBoxSizer * LayersBoxSizer = new wxBoxSizer(wxHORIZONTAL); + LeftBoxSizer->Add(LayersBoxSizer, 0, wxGROW|wxALL, 5); + +wxString fmtmsg[4] = { wxT("HPGL"), wxT("GERBER"), wxT("Postscript"), wxT("Postscript A4") }; + m_PlotFormatOpt = new wxRadioBox(this, ID_SEL_PLOT_FORMAT, + _("Plot Format"), wxDefaultPosition, wxSize(-1,-1), + 4, fmtmsg, 1, wxRA_SPECIFY_COLS); + MidRightBoxSizer->Add(m_PlotFormatOpt, 0, wxGROW|wxALL, 5); + switch ( m_PlotFormat ) + { + case PLOT_FORMAT_HPGL: + m_PlotFormatOpt->SetSelection(0); break; + case PLOT_FORMAT_POST: + m_PlotFormatOpt->SetSelection(2); break; + case PLOT_FORMAT_GERBER: + m_PlotFormatOpt->SetSelection(1); break; + case PLOT_FORMAT_POST_A4: + m_PlotFormatOpt->SetSelection(3); break; + } + + /* Creation des menus d'option du format GERBER */ + m_GerbSpotSizeMinOpt = new WinEDA_ValueCtrl(this, _("Spot min"), + spot_mini, g_UnitMetric, MidRightBoxSizer, UNITS_MILS); + + /* Creation des menus d'option du format HPGL */ + m_HPGLPenSizeOpt = new WinEDA_ValueCtrl(this, _("Pen Size"), + g_HPGL_Pen_Diam, g_UnitMetric, MidRightBoxSizer, UNITS_MILS); + + /* unites standards = cm pour vitesse plume en HPLG */ + m_HPGLPenSpeedOpt = new WinEDA_ValueCtrl(this, _("Pen Speed (cm/s)"), + g_HPGL_Pen_Speed, CENTIMETRE, MidRightBoxSizer, 1); + m_HPGLPenSpeedOpt->SetToolTip(_("Set pen speed in cm/s")); + + m_HPGLPenOverlayOpt = new WinEDA_ValueCtrl(this, _("Pen Ovr"), + g_HPGL_Pen_Recouvrement, g_UnitMetric, MidRightBoxSizer, UNITS_MILS); + m_HPGLPenOverlayOpt->SetToolTip(_("Set plot overlay for filling")); + + m_LinesWidth = new WinEDA_ValueCtrl(this, _("Lines Width"), + g_PlotLine_Width, g_UnitMetric, MidRightBoxSizer, PCB_INTERNAL_UNIT); + m_LinesWidth->SetToolTip(_("Set width for lines in Line plot mode")); + + /* Create the right column commands */ +wxString choice_plot_offset_msg[] = + {_("absolute"), _("auxiliary axis")}; + m_Choice_Plot_Offset = new wxRadioBox(this, ID_SEL_PLOT_OFFSET_OPTION, + _("plot Origine:"), + wxDefaultPosition,wxSize(-1,-1), + 2,choice_plot_offset_msg,1,wxRA_SPECIFY_COLS); + if ( s_PlotOriginIsAuxAxis ) m_Choice_Plot_Offset->SetSelection(1); + RightBoxSizer->Add(m_Choice_Plot_Offset, 0, wxGROW|wxALL, 5); + /* Add a spacer for a better look */ + RightBoxSizer->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 20); + + /* Create the command buttons */ + Button = new wxButton(this, ID_EXEC_PLOT, _("Plot")); + Button->SetForegroundColour(*wxRED); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Button = new wxButton(this, ID_CLOSE_PLOT, _("Close")); + Button->SetForegroundColour(*wxBLUE); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Button = new wxButton(this, ID_SAVE_OPT_PLOT, _("Save options")); + Button->SetForegroundColour(wxColour(0,80,0) ); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + Button = new wxButton(this, ID_CREATE_DRILL_FILE, _("Create Drill File")); + Button->SetForegroundColour(wxColour(0,80,80) ); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + + // Create scale adjust option + m_XScaleAdjust = m_YScaleAdjust = 1.0; + if ( m_Parent->m_Parent->m_EDA_Config ) + { + m_Parent->m_Parent->m_EDA_Config->Read(wxT("PlotXFineScaleAdj"), &m_XScaleAdjust); + m_Parent->m_Parent->m_EDA_Config->Read(wxT("PlotYFineScaleAdj"), &m_YScaleAdjust); + } + m_FineAdjustXscaleOpt = new WinEDA_DFloatValueCtrl(this, _("X Scale Adjust"), m_XScaleAdjust, RightBoxSizer); + m_FineAdjustXscaleOpt->SetToolTip(_("Set X scale adjust for exact scale plotting")); + m_FineAdjustYscaleOpt = new WinEDA_DFloatValueCtrl(this, _("Y Scale Adjust"), m_YScaleAdjust, RightBoxSizer); + m_FineAdjustYscaleOpt->SetToolTip(_("Set Y scale adjust for exact scale plotting")); + + m_Plot_PS_Negative = new wxCheckBox(this, -1, _("Plot Negative") ); + m_Plot_PS_Negative->SetValue(g_Plot_PS_Negative); + RightBoxSizer->Add(m_Plot_PS_Negative, 0, wxGROW|wxALL, 5); + + /* Creation de la liste des layers */ + int mask = 1; + wxBoxSizer * OneColonLayerBoxSizer = new wxBoxSizer(wxVERTICAL); + LayersBoxSizer->Add(OneColonLayerBoxSizer, 0, wxGROW|wxALL, 5); + for ( ii = 0; ii < NB_LAYERS; ii++, mask <<= 1 ) + { + if ( ii == 16 ) + { + OneColonLayerBoxSizer = new wxBoxSizer(wxVERTICAL); + LayersBoxSizer->Add(OneColonLayerBoxSizer, 0, wxGROW|wxALL, 5); + } + + m_BoxSelecLayer[ii] = new wxCheckBox(this, -1, + ReturnPcbLayerName(ii)); + if ( mask & s_SelectedLayers) m_BoxSelecLayer[ii]->SetValue(true); + OneColonLayerBoxSizer->Add(m_BoxSelecLayer[ii], 0, wxGROW|wxALL, 1); + } + + // Option d'impression du cartouche: + if ( m_Parent->m_Print_Sheet_Ref ) + { + m_Plot_Sheet_Ref = new wxCheckBox(this, ID_PRINT_REF, _("Print Sheet Ref") ); + m_Plot_Sheet_Ref->SetValue(Plot_Sheet_Ref); + LeftBoxSizer->Add(m_Plot_Sheet_Ref, 0, wxGROW|wxALL, 1); + } + else Plot_Sheet_Ref = false; + + // Option d'impression des pads sur toutes les couches + m_Plot_Pads_on_Silkscreen = new wxCheckBox(this, + ID_PRINT_PAD_ON_SILKSCREEN, _("Print Pads on Silkscreen") ); + m_Plot_Pads_on_Silkscreen->SetValue(PlotPadsOnSilkLayer); + m_Plot_Pads_on_Silkscreen->SetToolTip( + _("Enable/disable print/plot pads on Silkscreen layers") ); + LeftBoxSizer->Add(m_Plot_Pads_on_Silkscreen, 0, wxGROW|wxALL, 1); + + m_Force_Plot_Pads = new wxCheckBox(this, ID_FORCE_PRINT_PAD, + _("Always Print Pads") ); + m_Force_Plot_Pads->SetValue(Plot_Pads_All_Layers); + m_Force_Plot_Pads->SetToolTip(_("Force print/plot pads on ALL layers") ); + LeftBoxSizer->Add(m_Force_Plot_Pads, 0, wxGROW|wxALL, 1); + + // Options d'impression des textes modules + m_Plot_Text_Value = new wxCheckBox(this, ID_PRINT_VALUE, _("Print Module Value") ); + m_Plot_Text_Value->SetValue(Sel_Texte_Valeur); + m_Plot_Text_Value->SetToolTip( + _("Enable/disable print/plot module value on Silkscreen layers") ); + LeftBoxSizer->Add(m_Plot_Text_Value, 0, wxGROW|wxALL, 1); + + m_Plot_Text_Ref = new wxCheckBox(this, ID_PRINT_REF, _("Print Module Reference")); + m_Plot_Text_Ref->SetValue(Sel_Texte_Reference); + m_Plot_Text_Ref->SetToolTip( + _("Enable/disable print/plot module reference on Silkscreen layers") ); + LeftBoxSizer->Add(m_Plot_Text_Ref, 0, wxGROW|wxALL, 1); + + m_Plot_Text_Div = new wxCheckBox(this, ID_PRINT_MODULE_TEXTS, + _("Print other module texts") ); + m_Plot_Text_Div->SetValue(Sel_Texte_Divers); + m_Plot_Text_Div->SetToolTip( + _("Enable/disable print/plot module field texts on Silkscreen layers") ); + LeftBoxSizer->Add(m_Plot_Text_Div, 0, wxGROW|wxALL, 1); + + m_Plot_Invisible_Text = new wxCheckBox(this, + ID_FORCE_PRINT_INVISIBLE_TEXT, _("Force Print Invisible Texts") ); + m_Plot_Invisible_Text->SetValue(Sel_Texte_Invisible); + m_Plot_Invisible_Text->SetToolTip( + _("Force print/plot module invisible texts on Silkscreen layers") ); + LeftBoxSizer->Add(m_Plot_Invisible_Text, 0, wxGROW|wxALL, 1); + + +wxString drillmsg[3] = { _("No Drill mark"), _("Small mark"), _("Real Drill") }; + m_Drill_Shape_Opt = new wxRadioBox(this, ID_DRILL_SHAPE_OPT, + _("Pads Drill Opt"), wxDefaultPosition, wxSize(-1,-1), + 3, drillmsg, 1, wxRA_SPECIFY_COLS); + m_Drill_Shape_Opt->SetSelection(g_DrillShapeOpt); + MidLeftBoxSizer->Add(m_Drill_Shape_Opt, 0, wxGROW|wxALL, 5); + +wxString scalemsg[5] = + { _("Auto scale"), _("Scale 1"), _("Scale 1.5"), _("Scale 2"), _("Scale 3") }; + m_Scale_Opt = new wxRadioBox(this, ID_SCALE_OPT, + _("Scale Opt"), wxDefaultPosition, wxSize(-1,-1), + 5, scalemsg, 1, wxRA_SPECIFY_COLS); + m_Scale_Opt->SetSelection(g_PlotScaleOpt); + MidLeftBoxSizer->Add(m_Scale_Opt, 0, wxGROW|wxALL, 5); + +wxString list_opt3[3] = {_("Line"), _("Filled"), _("Sketch") }; + m_PlotModeOpt = new wxRadioBox(this, ID_PLOT_MODE_OPT, _("Plot mode"), + wxDefaultPosition, wxDefaultSize, + 3, list_opt3, 1); + m_PlotModeOpt->SetSelection(Plot_Mode); + MidLeftBoxSizer->Add(m_PlotModeOpt, 0, wxGROW|wxALL, 5); + + m_PlotMirorOpt = new wxCheckBox(this, ID_MIROR_OPT, + _("Plot Mirror")); + m_PlotMirorOpt->SetValue(Plot_Set_MIROIR); + MidLeftBoxSizer->Add(m_PlotMirorOpt, 0, wxGROW|wxALL, 5); + + m_PlotNoViaOnMaskOpt = new wxCheckBox(this, ID_MASKVIA_OPT, + _("Vias on Mask")); + m_PlotNoViaOnMaskOpt->SetValue(g_DrawViaOnMaskLayer); + m_PlotNoViaOnMaskOpt->SetToolTip( + _("Print/plot vias on mask layers. They are in this case not protected") ); + MidLeftBoxSizer->Add(m_PlotNoViaOnMaskOpt, 0, wxGROW|wxALL, 5); + + m_HPGL_PlotCenter_Opt = new wxCheckBox(this, ID_PLOT_CENTRE_OPT, + _("Org = Centre")); + m_HPGL_PlotCenter_Opt->SetValue(HPGL_Org_Centre); + m_HPGL_PlotCenter_Opt->SetToolTip(_("Draw origin ( 0,0 )in on sheet center") ); + MidLeftBoxSizer->Add(m_HPGL_PlotCenter_Opt, 0, wxGROW|wxALL, 5); + // Mise a jour des activations des menus: +wxCommandEvent event; + SetCommands(event); + + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); +} + +/***************************************************************/ +void WinEDA_PlotFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/***************************************************************/ +/* Called by the close button +*/ +{ + Close(true); // true is to force the frame to close +} + +/****************************************************/ +void WinEDA_PlotFrame::OnClose(wxCloseEvent & event) +/****************************************************/ +/* called when WinEDA_PlotFrame is closed +*/ +{ + EndModal(0); +} + + +/*********************************************************/ +void WinEDA_PlotFrame::CreateDrillFile(wxCommandEvent & event) +/*********************************************************/ +/* Create the board drill file used with gerber documents +*/ +{ + ((WinEDA_PcbFrame * )m_Parent)->InstallDrillFrame(event); +} + +/*********************************************************/ +void WinEDA_PlotFrame::SetCommands(wxCommandEvent & event) +/*********************************************************/ +/* active ou désactive les différents menus d'option selon le standard choisi +*/ +{ +int format; +int format_list[] = + {PLOT_FORMAT_HPGL, PLOT_FORMAT_GERBER, PLOT_FORMAT_POST, PLOT_FORMAT_POST_A4 + }; + + format = format_list[m_PlotFormatOpt->GetSelection()]; + + switch ( format ) + { + case PLOT_FORMAT_POST_A4: + case PLOT_FORMAT_POST: + m_Drill_Shape_Opt->Enable(true); + m_PlotModeOpt->Enable(true); + m_PlotMirorOpt->Enable(true); + m_GerbSpotSizeMinOpt->Enable(false); + m_Choice_Plot_Offset->Enable(false); + m_LinesWidth->Enable(true); + m_HPGLPenSizeOpt->Enable(false); + m_HPGLPenSpeedOpt->Enable(false); + m_HPGLPenOverlayOpt->Enable(false); + m_HPGL_PlotCenter_Opt->Enable(false); + m_Plot_Sheet_Ref->Enable(true); + m_Scale_Opt->Enable(true); + m_FineAdjustXscaleOpt->Enable(true); + m_FineAdjustYscaleOpt->Enable(true); + m_PlotFormat = PLOT_FORMAT_POST; + if ( format == PLOT_FORMAT_POST_A4 ) g_ForcePlotPS_On_A4 = true; + else g_ForcePlotPS_On_A4 = false; + m_Plot_PS_Negative->Enable(true); + break; + + case PLOT_FORMAT_GERBER: + m_Drill_Shape_Opt->Enable(false); + m_PlotModeOpt->Enable(false); + m_PlotMirorOpt->Enable(false); + m_GerbSpotSizeMinOpt->Enable(true); + m_Choice_Plot_Offset->Enable(true); + m_LinesWidth->Enable(true); + m_HPGLPenSizeOpt->Enable(false); + m_HPGLPenSpeedOpt->Enable(false); + m_HPGLPenOverlayOpt->Enable(false); + m_HPGL_PlotCenter_Opt->Enable(false); + m_Plot_Sheet_Ref->Enable(false); + m_Scale_Opt->Enable(false); + m_FineAdjustXscaleOpt->Enable(false); + m_FineAdjustYscaleOpt->Enable(false); + m_PlotFormat = PLOT_FORMAT_GERBER; + m_Plot_PS_Negative->Enable(false); + break; + + case PLOT_FORMAT_HPGL: + m_PlotMirorOpt->Enable(true); + m_Drill_Shape_Opt->Enable(false); + m_PlotModeOpt->Enable(true); + m_GerbSpotSizeMinOpt->Enable(false); + m_Choice_Plot_Offset->Enable(false); + m_LinesWidth->Enable(false); + m_HPGLPenSizeOpt->Enable(true); + m_HPGLPenSpeedOpt->Enable(true); + m_HPGLPenOverlayOpt->Enable(true); + m_HPGL_PlotCenter_Opt->Enable(true); + m_Plot_Sheet_Ref->Enable(true); + m_Scale_Opt->Enable(true); + m_FineAdjustXscaleOpt->Enable(false); + m_FineAdjustYscaleOpt->Enable(false); + m_PlotFormat = PLOT_FORMAT_HPGL; + m_Plot_PS_Negative->Enable(false); + break; + } + format_plot = m_PlotFormat; +} + +/*********************************************************/ +void WinEDA_PlotFrame::SaveOptPlot(wxCommandEvent & event) +/*********************************************************/ +{ + if ( m_Plot_Sheet_Ref ) + Plot_Sheet_Ref = m_Plot_Sheet_Ref->GetValue(); + + PlotPadsOnSilkLayer = m_Plot_Pads_on_Silkscreen->GetValue(); + Plot_Pads_All_Layers = m_Force_Plot_Pads->GetValue(); + + s_PlotOriginIsAuxAxis = (m_Choice_Plot_Offset->GetSelection() == 0) ? FALSE : TRUE; + + Sel_Texte_Valeur = m_Plot_Text_Value->GetValue(); + Sel_Texte_Reference = m_Plot_Text_Ref->GetValue(); + Sel_Texte_Divers = m_Plot_Text_Div->GetValue(); + Sel_Texte_Invisible = m_Plot_Invisible_Text->GetValue(); + + g_PlotScaleOpt = m_Scale_Opt->GetSelection(); + g_DrillShapeOpt = m_Drill_Shape_Opt->GetSelection(); + Plot_Set_MIROIR = m_PlotMirorOpt->GetValue(); + if ( Plot_Set_MIROIR ) g_PlotOrient = PLOT_MIROIR; + else g_PlotOrient = 0; + Plot_Mode = m_PlotModeOpt->GetSelection(); + g_DrawViaOnMaskLayer = m_PlotNoViaOnMaskOpt->GetValue(); + spot_mini = m_GerbSpotSizeMinOpt->GetValue(); + g_HPGL_Pen_Diam = m_HPGLPenSizeOpt->GetValue(); + g_HPGL_Pen_Speed = m_HPGLPenSpeedOpt->GetValue(); + g_HPGL_Pen_Recouvrement = m_HPGLPenOverlayOpt->GetValue(); + HPGL_Org_Centre = m_HPGL_PlotCenter_Opt->GetValue(); + g_PlotLine_Width = m_LinesWidth->GetValue(); + + m_XScaleAdjust = m_FineAdjustXscaleOpt->GetValue(); + m_YScaleAdjust = m_FineAdjustYscaleOpt->GetValue(); + if ( m_Parent->m_Parent->m_EDA_Config ) + { + m_Parent->m_Parent->m_EDA_Config->Write(wxT("PlotXFineScaleAdj"), m_XScaleAdjust); + m_Parent->m_Parent->m_EDA_Config->Write(wxT("PlotYFineScaleAdj"), m_YScaleAdjust); + } + + g_Plot_PS_Negative = m_Plot_PS_Negative->GetValue(); +} + +/***************************************************/ +void WinEDA_PlotFrame::Plot(wxCommandEvent & event) +/***************************************************/ +{ +int layer_to_plot; +wxString FullFileName, BaseFileName; +wxString ext; + + SaveOptPlot(event); + + switch ( g_PlotScaleOpt ) + { + default: + Scale_X = Scale_Y = 1; + break; + + case 2: + Scale_X = Scale_Y = 1.5; + break; + + case 3: + Scale_X = Scale_Y = 2; + break; + + case 4: + Scale_X = Scale_Y = 3; + break; + + } + + Scale_X *= m_XScaleAdjust; + Scale_Y *= m_YScaleAdjust; + + BaseFileName = m_Parent->GetScreen()->m_FileName; + ChangeFileNameExt( BaseFileName, wxT("-") ); + + switch ( m_PlotFormat) + { + case PLOT_FORMAT_POST: + ext = wxT(".ps"); + break; + + case PLOT_FORMAT_GERBER: + ext = wxT(".pho"); + break; + + case PLOT_FORMAT_HPGL: + ext = wxT(".plt"); + break; + } + + int mask = 1; + s_SelectedLayers = 0; + + for ( layer_to_plot = 0; layer_to_plot < 29; layer_to_plot++, mask <<= 1 ) + { + if ( m_BoxSelecLayer[layer_to_plot]->GetValue() ) + { + s_SelectedLayers |= mask; + /* Calcul du nom du fichier */ + FullFileName = BaseFileName +ReturnPcbLayerName(layer_to_plot, true) + ext; + switch ( m_PlotFormat) + { + case PLOT_FORMAT_POST: + m_Parent->Genere_PS(FullFileName, layer_to_plot); + break; + + case PLOT_FORMAT_GERBER: + m_Parent->Genere_GERBER(FullFileName, layer_to_plot, s_PlotOriginIsAuxAxis); + break; + + case PLOT_FORMAT_HPGL: + m_Parent->Genere_HPGL(FullFileName, layer_to_plot); + break; + + } + } + } + + Close(true); +} + + +/**************************************************************/ +void WinEDA_BasePcbFrame::ToPlotter(wxCommandEvent& event) +/***************************************************************/ +{ + WinEDA_PlotFrame * frame = new WinEDA_PlotFrame(this); + frame->ShowModal(); frame->Destroy(); +} + + diff --git a/pcbnew/pcbplot.h b/pcbnew/pcbplot.h new file mode 100644 index 0000000000..4449ca9d5a --- /dev/null +++ b/pcbnew/pcbplot.h @@ -0,0 +1,192 @@ + /************/ + /* pcbplot.h*/ + /************/ + +#ifndef PCBPLOT_H +#define PCBPLOT_H + + +#ifndef eda_global +#define eda_global extern +#endif + + +/* Constantes de conversion d'unites */ +/* coeff de conversion dim en 0.1 mil -> dim en unite PS: (unite PS = pouce) */ +#define SCALE_PS .0001 +/* coeff de conversion dim en 0,1 mil -> dim en unite HPGL: */ +#define SCALE_HPGL 0.102041 + +/* Options : */ +eda_global bool Plot_Sheet_Ref; +eda_global bool g_DrawViaOnMaskLayer; // True if vias are drawn on Mask layer (ie protected by mask) +eda_global int Plot_Mode // = FILAIRE, FILL ou SKETCH +#ifdef MAIN += FILLED +#endif +; +eda_global bool Plot_Set_MIROIR ; +eda_global bool Sel_Rotate_Window; +eda_global bool HPGL_Org_Centre; // TRUE si en HPGL, l'origine le centre de la feuille +eda_global int g_PlotPSColorOpt; // True for color Postscript output +eda_global bool g_Plot_PS_Negative; // True to create a negative board ps plot + + +/* Autorisation de trace des divers items en serigraphie */ +eda_global bool Sel_Texte_Reference +#ifdef MAIN += TRUE +#endif +; +eda_global bool Sel_Texte_Valeur +#ifdef MAIN += TRUE +#endif +; +eda_global bool Sel_Texte_Divers +#ifdef MAIN += TRUE +#endif +; +eda_global bool Sel_Texte_Invisible; +eda_global bool PlotPadsOnSilkLayer /* Plot pads sur couche serigraphie */ +#ifdef MAIN += TRUE +#endif +; +eda_global bool Plot_Pads_All_Layers; /* Plot pads meme n'appartenant pas a la + couche ( utile pour serigraphie) */ + + /* Variables utiles */ + +eda_global FILE * dest; + +/* Gestion des plumes en plot format HPGL */ +eda_global int g_HPGL_Pen_Num /* num de plume a charger */ +#ifdef MAIN += 1 +#endif +; +eda_global int g_HPGL_Pen_Speed /* vitesse en cm/s */ +#ifdef MAIN += 40 +#endif +; +eda_global int g_HPGL_Pen_Diam; /* diametre en mils */ +eda_global int g_HPGL_Pen_Recouvrement; /* recouvrement en mils ( pour remplissages */ + +/* Gestion des ouvertures GERBER */ +eda_global int spot_mini; /* Diametre mini de l'ouverture pour trace GERBER */ + +/* Gestion des cadrages et echelles de trace */ +eda_global float Scale_X, Scale_Y ; /* coeff d'agrandissement en X et Y demandes */ +eda_global wxPoint g_PlotOffset; /* Offset de trace modifies par l'echelle */ + +eda_global int nb_plot_erreur ; +eda_global int nb_items; /* utilise pour decompter les objets traces */ +eda_global int g_PlotLine_Width; /* Largeur du trait en mode filaire (utilise en serigraphie, + pour traces en mode sketch et filaire) */ +eda_global int format_plot; /* numero de code du format de sortie */ +eda_global int g_PlotOrient; /* numero de code de l'orientation du trace ( voir + defines precedents): + 0 = normal + PLOT_MIROIR = MIROIR + */ +eda_global int g_PlotScaleOpt // 0 = automatique, >=1 echelle specifiee +#ifdef MAIN += 1 +#endif +; +eda_global bool g_ForcePlotPS_On_A4; // Force la selection de la feuille A4 pour le plot POSTSCRIPT + +eda_global int g_DrillShapeOpt +#ifdef MAIN + = 1 // 0 = no drill mark, 1 = small mark, 2 = real drill +#endif +; + + + /*************************************/ + /* Constantes utiles en trace GERBER */ + /*************************************/ + +/* codes de type de forme d'outils */ +#define GERB_CIRCLE 1 +#define GERB_RECT 2 +#define GERB_LINE 3 +#define GERB_OVALE 4 +#define GERB_DONUT 5 + +/* liste des D_CODES en fonction de leur numero d'ordre (numero d'outil) + (l'ordre 0 n'est pas utilise) ; + Tools have D_CODES >= 10 + D_CODES <= 9 are used for commands only: + D01 ... D9 = command codes for photo plotting: + D01 = Light on + D02 = Light off + D03 = Flash + D04 .. D08 = ? + D09 = VAPE Flash +*/ + + + /* Routines generales de trace : */ + + +/* PLOT_RTN.CC */ +void PlotTextePcb( TEXTE_PCB * pt_texte,int format_plot,int masque_layer); + /* Trace 1 Texte type PCB , c.a.d autre que les textes sur modules, + prepare les parametres de trace de Plot_1_texte */ +void PlotArc(int format_plot, wxPoint centre, int start_angle,int end_angle, + int rayon,int width); +void PlotCircle(int format_plot,int width, wxPoint centre, int rayon); +void PlotPolygon(int format_plot, bool filled, int nbpoints, int * coord); +void Plot_1_texte( int format_plot, + const wxString & Text, int t_orient, + int width, int ox,int oy,int size_h,int size_v, + bool centreX = TRUE, bool centreY = TRUE); + /* Routine de base de trace de 1 chaine de caracteres */ + +void PlotDrawSegment( DRAWSEGMENT* PtSegm, int format_plot,int masque_layer ); + +void PlotCotation( COTATION * Cotation, int format_plot,int masque_layer ); + +void PlotMirePcb( MIREPCB* PtMire, int format_plot,int masque_layer ); + +void Plot_1_EdgeModule(int format_plot, EDGE_MODULE * PtEdge); + +/* PLOTGERB.CPP */ +void PlotGERBERLine(wxPoint start, wxPoint end, int hauteur); +void PlotCircle_GERBER( wxPoint centre, int rayon, int width); +void PlotPolygon_GERBER(int nb_segm, int * coord, bool fill); +void trace_1_contour_GERBER(wxPoint pos, wxSize size, wxSize delta, + int penwidth, int orient); + /* Trace 1 contour rectangulaire ou trapezoidal d'orientation quelconque + donne par son centre, ses dimensions, + ses variations, l'epaisseur du trait et son orientation orient */ + +/* PLOTHPGL.CC */ +void trace_1_segment_HPGL(int pos_X0,int pos_Y0,int pos_X1,int pos_Y1, + int hauteur); + +void trace_1_pad_TRAPEZE_HPGL(wxPoint padpos, wxSize size,wxSize delta, + int orient,int modetrace); + +void trace_1_pastille_RONDE_HPGL(wxPoint padpos, int diametre,int modetrace) ; +void trace_1_pastille_OVALE_HPGL(wxPoint padpos, wxSize size, int orient, int modetrace); +void PlotRectangularPad_HPGL(wxPoint padpos, wxSize padsize, int orient,int modetrace); + +/**************/ +/* PLOTPS.CPP */ +/**************/ +void trace_1_pastille_OVALE_POST(wxPoint centre, wxSize size, int orient, int modetrace); +void trace_1_pastille_RONDE_POST(wxPoint centre, int diametre, int modetrace); +void trace_1_pad_rectangulaire_POST(wxPoint centre, wxSize size,int orient, + int modetrace); +void trace_1_contour_POST(wxPoint centre, wxSize size, wxSize delta, + int dim_trait, int orient); +void trace_1_pad_TRAPEZE_POST(wxPoint centre, wxSize size, wxSize delta, + int orient,int modetrace); + + +#endif /* #define PCBPLOT_H */ diff --git a/pcbnew/pcbtexte.cpp b/pcbnew/pcbtexte.cpp new file mode 100644 index 0000000000..e069f79dee --- /dev/null +++ b/pcbnew/pcbtexte.cpp @@ -0,0 +1,388 @@ + /**************************************************/ + /* traitement des editions des textes sur modules */ + /**************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + +#define L_MIN_DESSIN 1 /* seuil de largeur des segments pour trace autre que filaire */ + +/* Routines Locales */ +static void Move_Texte_Pcb(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) ; +static void Exit_Texte_Pcb(WinEDA_DrawPanel * Panel, wxDC *DC) ; + +/* Variables locales : */ +static wxPoint old_pos; // position originelle du texte selecte + + +enum id_TextPCB_properties +{ + ID_ACCEPT_TEXTE_PCB_PROPERTIES = 1900, + ID_CLOSE_TEXTE_PCB_PROPERTIES, + ID_TEXTPCB_SELECT_LAYER +}; + + /************************************/ + /* class WinEDA_TextPCBPropertiesFrame */ + /************************************/ + +class WinEDA_TextPCBPropertiesFrame: public wxDialog +{ +private: + + WinEDA_PcbFrame * m_Parent; + wxDC * m_DC; + TEXTE_PCB * CurrentTextPCB; + WinEDA_EnterText * m_Name; + WinEDA_PositionCtrl * m_TxtPosCtrl; + WinEDA_SizeCtrl * m_TxtSizeCtrl; + WinEDA_ValueCtrl * m_TxtWidthCtlr; + wxRadioBox * m_Orient; + wxRadioBox * m_Mirror; + WinEDAChoiceBox * m_SelLayerBox; + +public: + // Constructor and destructor + WinEDA_TextPCBPropertiesFrame(WinEDA_PcbFrame *parent, + TEXTE_PCB * TextPCB, wxDC * DC, const wxPoint & pos); + ~WinEDA_TextPCBPropertiesFrame(void) + { + } + +private: + void TextPCBPropertiesAccept(wxCommandEvent& event); + void OnQuit(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(WinEDA_TextPCBPropertiesFrame, wxDialog) + EVT_BUTTON(ID_ACCEPT_TEXTE_PCB_PROPERTIES, + WinEDA_TextPCBPropertiesFrame::TextPCBPropertiesAccept) + EVT_BUTTON(ID_CLOSE_TEXTE_PCB_PROPERTIES, + WinEDA_TextPCBPropertiesFrame::OnQuit) +END_EVENT_TABLE() + + +/********************************************************************/ +void WinEDA_PcbFrame::InstallTextPCBOptionsFrame(TEXTE_PCB * TextPCB, + wxDC * DC, const wxPoint & pos) +/********************************************************************/ +{ + DrawPanel->m_IgnoreMouseEvents = TRUE; + WinEDA_TextPCBPropertiesFrame * frame = new WinEDA_TextPCBPropertiesFrame(this, + TextPCB, DC, pos); + frame->ShowModal(); frame->Destroy(); + DrawPanel->MouseToCursorSchema(); + DrawPanel->m_IgnoreMouseEvents = FALSE; +} + + +/************************************************************************************/ +WinEDA_TextPCBPropertiesFrame::WinEDA_TextPCBPropertiesFrame(WinEDA_PcbFrame *parent, + TEXTE_PCB * TextPCB,wxDC * DC, + const wxPoint & framepos): + wxDialog(parent, -1, _("TextPCB properties"), framepos, wxSize(390, 340), + DIALOG_STYLE) +/************************************************************************************/ +{ +wxButton * Button; + + m_Parent = parent; + SetFont(*g_DialogFont); + m_DC = DC; + Centre(); + + CurrentTextPCB = TextPCB; + + wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(MainBoxSizer); + wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * MiddleBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(MiddleBoxSizer, 0, wxGROW|wxALL, 5); + MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + /* Creation des boutons de commande */ + Button = new wxButton(this, ID_ACCEPT_TEXTE_PCB_PROPERTIES, _("Ok") ); + Button->SetForegroundColour(*wxRED); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + Button->SetDefault(); + + Button = new wxButton(this, ID_CLOSE_TEXTE_PCB_PROPERTIES, _("Cancel")); + Button->SetForegroundColour(*wxBLUE); + RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + m_Name = new WinEDA_EnterText(this, _("Text:"), + TextPCB->m_Text, + LeftBoxSizer, wxSize( 200, -1) ); + m_Name->SetFocus(); + m_Name->SetSelection(-1,-1); + + m_TxtSizeCtrl = new WinEDA_SizeCtrl(this, _("Size"), + TextPCB->m_Size, + g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits); + + m_TxtWidthCtlr = new WinEDA_ValueCtrl(this, _("Width"), + TextPCB->m_Width, + g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits); + + m_TxtPosCtrl = new WinEDA_PositionCtrl(this, _("Position"), + TextPCB->m_Pos, + g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits); + + m_SelLayerBox = new WinEDAChoiceBox(this, ID_TEXTPCB_SELECT_LAYER, + wxDefaultPosition, wxDefaultSize); + MiddleBoxSizer->Add(m_SelLayerBox, 0, wxGROW|wxALL, 5); + + int ii; + for ( ii = 0; ii < 29 ; ii ++ ) + { + m_SelLayerBox->Append(ReturnPcbLayerName(ii)); + } + m_SelLayerBox->SetSelection( TextPCB->m_Layer ); + +wxString orient_msg[4] = { wxT("0"), wxT("90"), wxT("180"), wxT("-90") }; + m_Orient = new wxRadioBox(this, -1, _("Orientation"), + wxDefaultPosition, wxSize(-1,-1), 4, orient_msg, + 1, wxRA_SPECIFY_COLS ); + MiddleBoxSizer->Add(m_Orient, 0, wxGROW|wxALL, 5); + switch(TextPCB->m_Orient ) + { + default: + m_Orient->SetSelection(0); + break; + + case 900: + m_Orient->SetSelection(1); + break; + + case 1800: + m_Orient->SetSelection(2); + break; + + case 2700: + m_Orient->SetSelection(3); + break; + + } + +wxString display_msg[2] = { _("Normal"), _("Mirror") }; + m_Mirror = new wxRadioBox(this, -1, _("Display"), + wxDefaultPosition, wxSize(-1,-1), 2, display_msg, + 1, wxRA_SPECIFY_COLS ); + if ( ! TextPCB->m_Miroir ) m_Mirror->SetSelection(1);; + MiddleBoxSizer->Add(m_Mirror, 0, wxGROW|wxALL, 5); + + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); +} + + +/**********************************************************************/ +void WinEDA_TextPCBPropertiesFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/**********************************************************************/ +{ + // true is to force the frame to close + Close(true); +} + + +/**************************************************************************************/ +void WinEDA_TextPCBPropertiesFrame::TextPCBPropertiesAccept(wxCommandEvent& event) +/**************************************************************************************/ +{ + if ( m_DC ) // Effacement ancien texte + { + CurrentTextPCB->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0, 0), GR_XOR); + } + + if ( ! m_Name->GetValue().IsEmpty() ) + { + CurrentTextPCB->m_Text = m_Name->GetValue(); + } + CurrentTextPCB->m_Pos = m_TxtPosCtrl->GetValue(); + CurrentTextPCB->m_Size = m_TxtSizeCtrl->GetValue(); + CurrentTextPCB->m_Width = m_TxtWidthCtlr->GetValue(); + CurrentTextPCB->m_Miroir = (m_Mirror->GetSelection() == 0) ? 1 : 0; + CurrentTextPCB->m_Orient = m_Orient->GetSelection() * 900; + CurrentTextPCB->m_Layer = m_SelLayerBox->GetChoice(); + CurrentTextPCB->CreateDrawData(); + if ( m_DC ) // Affichage nouveau texte + { + /* Redessin du Texte */ + CurrentTextPCB->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0, 0), GR_OR); + } + m_Parent->m_CurrentScreen->SetModify(); + Close(TRUE); +} + + +/******************************************************/ +void Exit_Texte_Pcb(WinEDA_DrawPanel * Panel, wxDC * DC) +/*******************************************************/ +/* + Routine de sortie du menu edit texte Pcb +Si un texte est selectionne, ses coord initiales sont regenerees +*/ +{ +TEXTE_PCB * TextePcb; + + TextePcb = (TEXTE_PCB *) Panel->GetScreen()->m_CurrentItem; + + if ( TextePcb ) + { + TextePcb->Draw(Panel, DC, wxPoint(0, 0), GR_XOR) ; + TextePcb->m_Pos = old_pos; + TextePcb->Draw(Panel, DC, wxPoint(0, 0), GR_OR) ; + TextePcb->m_Flags = 0; + } + + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + Panel->GetScreen()->m_CurrentItem = NULL; +} + +/*********************************************************************/ +void WinEDA_PcbFrame::Place_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC) +/*********************************************************************/ +/* + Routine de placement du texte en cours de deplacement +*/ +{ + if( TextePcb == NULL ) return; + + TextePcb->CreateDrawData(); + TextePcb->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR) ; + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + m_CurrentScreen->m_CurrentItem = NULL; + m_CurrentScreen->SetModify(); + TextePcb->m_Flags = 0; +} + +/***********************************************************************/ +void WinEDA_PcbFrame::StartMoveTextePcb(TEXTE_PCB * TextePcb, wxDC * DC) +/***********************************************************************/ + /* Routine de preparation du deplacement d'un texte +*/ +{ + if( TextePcb == NULL ) return; + old_pos = TextePcb->m_Pos; + TextePcb->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR) ; + TextePcb->m_Flags |= IS_MOVED; + Affiche_Infos_PCB_Texte(this, TextePcb); + DrawPanel->ManageCurseur = Move_Texte_Pcb; + DrawPanel->ForceCloseManageCurseur = Exit_Texte_Pcb; + m_CurrentScreen->m_CurrentItem = TextePcb; + DrawPanel->ManageCurseur( DrawPanel, DC, FALSE); +} + +/*************************************************************************/ +static void Move_Texte_Pcb(WinEDA_DrawPanel * panel, wxDC *DC, bool erase ) +/*************************************************************************/ +/* Routine deplacant le texte PCB suivant le curseur de la souris */ +{ +TEXTE_PCB * TextePcb = (TEXTE_PCB *) + panel->m_Parent->m_CurrentScreen->m_CurrentItem; + + if (TextePcb == NULL ) return ; + + /* effacement du texte : */ + + if ( erase ) + TextePcb->Draw(panel, DC, wxPoint(0, 0), GR_XOR) ; + + TextePcb->m_Pos = panel->m_Parent->m_CurrentScreen->m_Curseur; + + /* Redessin du Texte */ + TextePcb->Draw(panel, DC, wxPoint(0, 0), GR_XOR) ; +} + + +/**********************************************************************/ +void WinEDA_PcbFrame::Delete_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC) +/**********************************************************************/ +{ + + if( TextePcb == NULL ) return; + + TextePcb->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); + + /* Suppression du texte en Memoire*/ + DeleteStructure(TextePcb); + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + m_CurrentScreen->m_CurrentItem = NULL; +} + + +/*******************************************************/ +TEXTE_PCB * WinEDA_PcbFrame::Create_Texte_Pcb( wxDC * DC) +/*******************************************************/ +{ +TEXTE_PCB * TextePcb; + + TextePcb = new TEXTE_PCB(m_Pcb); + + /* Chainage de la nouvelle structure en debut de liste */ + TextePcb->Pnext = m_Pcb->m_Drawings; + TextePcb->Pback = (EDA_BaseStruct * )m_Pcb; + if( m_Pcb->m_Drawings) + m_Pcb->m_Drawings->Pback = (EDA_BaseStruct*) TextePcb; + m_Pcb->m_Drawings = (EDA_BaseStruct*) TextePcb; + + /* Mise a jour des caracteristiques */ + TextePcb->m_Flags = IS_NEW; + TextePcb->m_Layer = GetScreen()->m_Active_Layer; + TextePcb->m_Miroir = 1; + if(TextePcb->m_Layer == CUIVRE_N) TextePcb->m_Miroir = 0; + + TextePcb->m_Size = g_DesignSettings.m_PcbTextSize; + TextePcb->m_Pos = m_CurrentScreen->m_Curseur; + TextePcb->m_Width = g_DesignSettings.m_PcbTextWidth; + + InstallTextPCBOptionsFrame(TextePcb, DC, TextePcb->m_Pos); + if ( TextePcb->m_Text.IsEmpty() ) + { + DeleteStructure(TextePcb); + TextePcb = NULL; + } + + else StartMoveTextePcb(TextePcb, DC); + + return TextePcb; +} + +/***********************************************************************/ +void WinEDA_PcbFrame::Rotate_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC) +/***********************************************************************/ +{ +int angle = 900; +int drawmode = GR_XOR; + + if( TextePcb == NULL ) return; + + /* effacement du texte : */ + TextePcb->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR) ; + + + TextePcb->m_Orient += angle; + if(TextePcb->m_Orient >= 3600) TextePcb->m_Orient -= 3600 ; + if(TextePcb->m_Orient < 0) TextePcb->m_Orient += 3600 ; + + TextePcb->CreateDrawData(); + + /* Redessin du Texte */ + TextePcb->Draw(DrawPanel, DC, wxPoint(0, 0), drawmode); + Affiche_Infos_PCB_Texte(this, TextePcb); + + m_CurrentScreen->SetModify(); +} + diff --git a/pcbnew/plot_rtn.cpp b/pcbnew/plot_rtn.cpp new file mode 100644 index 0000000000..4009551918 --- /dev/null +++ b/pcbnew/plot_rtn.cpp @@ -0,0 +1,784 @@ + /*********************************************************/ + /* Routines de trace: fonction communes aux diff formats */ + /*********************************************************/ + +/* Fichier PLOT_RTN.CPP*/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "plot_common.h" +#include "pcbnew.h" +#include "pcbplot.h" +#include "trigo.h" + +#include "grfonte.h" + +#include "protos.h" + + +/* Fonctions locales */ +static void Plot_Edges_Modules(BOARD * pcb, int format_plot, int masque_layer); +static void PlotTextModule(TEXTE_MODULE * pt_texte); + + + +/**********************************************************/ +void WinEDA_BasePcbFrame::Plot_Serigraphie(int format_plot, + FILE * File, int masque_layer) +/***********************************************************/ + +/* Genere le trace des couches type serigraphie, en format HPGL ou GERBER*/ +{ +wxPoint pos, shape_pos; +wxSize size; +bool trace_val, trace_ref; +MODULE* Module; +D_PAD * pt_pad; +TEXTE_MODULE * pt_texte; +EDA_BaseStruct * PtStruct; +wxString msg; + + /* Trace du contour du PCB et des Elements du type Drawings Pcb */ + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + PlotDrawSegment( (DRAWSEGMENT*) PtStruct, format_plot, + EDGE_LAYER | masque_layer ); + break; + + case TYPETEXTE: + PlotTextePcb((TEXTE_PCB*) PtStruct,format_plot, + EDGE_LAYER | masque_layer); + break; + + case TYPECOTATION: + PlotCotation((COTATION*) PtStruct, format_plot, + EDGE_LAYER | masque_layer); + break; + + case TYPEMIRE: + PlotMirePcb((MIREPCB*) PtStruct, format_plot, + EDGE_LAYER | masque_layer); + break; + + case TYPEMARQUEUR: + break; + + default: + DisplayError(this, wxT("Plot_Serigraphie() error: unexpected m_StructType")); + break; + } + } + + /* trace des contours des MODULES : */ + Plot_Edges_Modules(m_Pcb, format_plot, masque_layer); + + /* Trace des MODULES : PADS */ + if(PlotPadsOnSilkLayer || Plot_Pads_All_Layers) + { + nb_items = 0 ; + Affiche_1_Parametre(this, 56, wxT("Pads"),wxEmptyString,GREEN) ; + Module = m_Pcb->m_Modules; + for( ; Module != NULL ; Module = (MODULE *) Module->Pnext ) + { + pt_pad = (D_PAD *) Module->m_Pads; + for( ; pt_pad != NULL; pt_pad = (D_PAD *) pt_pad->Pnext) + { + /* Tst si layer OK */ + if( (pt_pad->m_Masque_Layer & masque_layer) == 0) + { + if( ! Plot_Pads_All_Layers ) continue; + } + shape_pos = pt_pad->ReturnShapePos(); + pos = shape_pos; size = pt_pad->m_Size; + + switch( pt_pad->m_PadShape & 0x7F ) + { + case CIRCLE : + switch ( format_plot ) + { + case PLOT_FORMAT_GERBER: + PlotCircle(PLOT_FORMAT_GERBER, + g_PlotLine_Width ,pos, size.x / 2); + break; + + case PLOT_FORMAT_HPGL: + trace_1_pastille_RONDE_HPGL(pos, size.x ,FILAIRE); + break; + + case PLOT_FORMAT_POST: + trace_1_pastille_RONDE_POST(pos, size.x ,FILAIRE); + break; + } + break ; + + case OVALE : + switch ( format_plot ) + { + case PLOT_FORMAT_GERBER: + trace_1_contour_GERBER(pos, size, wxSize(0,0), + g_PlotLine_Width, + pt_pad->m_Orient); + break; + + case PLOT_FORMAT_HPGL: + trace_1_pastille_OVALE_HPGL(pos,size, + pt_pad->m_Orient,FILAIRE) ; + break; + + case PLOT_FORMAT_POST: + trace_1_pastille_OVALE_POST(pos,size, + pt_pad->m_Orient,FILAIRE) ; + break; + } + break ; + + case TRAPEZE : + { + wxSize delta; + delta = pt_pad->m_DeltaSize; + + switch ( format_plot ) + { + case PLOT_FORMAT_GERBER: + trace_1_contour_GERBER(pos, size, delta, + g_PlotLine_Width, + (int)pt_pad->m_Orient); + break; + + case PLOT_FORMAT_HPGL: + trace_1_pad_TRAPEZE_HPGL(pos,size, + delta, (int)pt_pad->m_Orient, + FILAIRE) ; + break; + + case PLOT_FORMAT_POST: + trace_1_pad_TRAPEZE_POST(pos,size, + delta, (int)pt_pad->m_Orient, + FILAIRE) ; + break; + } + break ; + } + + case RECT : + default: + switch ( format_plot ) + { + case PLOT_FORMAT_GERBER: + trace_1_contour_GERBER(pos, size, wxSize(0,0), + g_PlotLine_Width, + (int)pt_pad->m_Orient); + break; + + case PLOT_FORMAT_HPGL: + PlotRectangularPad_HPGL(pos,size, pt_pad->m_Orient,FILAIRE) ; + break; + + case PLOT_FORMAT_POST: + trace_1_pad_rectangulaire_POST(pos,size, + (int)pt_pad->m_Orient,FILAIRE) ; + break; + } + break ; + } + nb_items++; msg.Printf( wxT("%d"),nb_items) ; + Affiche_1_Parametre(this, 56,wxEmptyString,msg,GREEN) ; + } + } + } /* Fin Sequence de trace des Pads */ + + /* Trace Textes MODULES */ + nb_items = 0; Affiche_1_Parametre(this, 64, wxT("TxtMod"),wxEmptyString,LIGHTBLUE) ; + + Module = m_Pcb->m_Modules; + for( ; Module != NULL ; Module = (MODULE *) Module->Pnext ) + { + /* Analyse des autorisations de trace pour les textes VALEUR et REF */ + trace_val = Sel_Texte_Valeur; + trace_ref = Sel_Texte_Reference; // les 2 autorisations de tracer sont donnees + + if( (g_TabOneLayerMask[Module->m_Reference->m_Layer] & masque_layer) == 0) + trace_ref = FALSE; + if(Module->m_Reference->m_NoShow && !Sel_Texte_Invisible) + trace_ref = FALSE; + + if( (g_TabOneLayerMask[Module->m_Value->m_Layer] & masque_layer) == 0) + trace_val = FALSE; + if(Module->m_Value->m_NoShow && !Sel_Texte_Invisible) + trace_val = FALSE; + + /* Trace effectif des textes */ + if( trace_ref ) + { + PlotTextModule(Module->m_Reference); + nb_items++ ; + msg.Printf( wxT("%d"),nb_items) ; + Affiche_1_Parametre(this, 64,wxEmptyString,msg,LIGHTBLUE) ; + } + + if( trace_val ) + { + PlotTextModule(Module->m_Value); + nb_items++ ; + msg.Printf( wxT("%d"),nb_items) ; + Affiche_1_Parametre(this, 64,wxEmptyString,msg,LIGHTBLUE) ; + } + + pt_texte = (TEXTE_MODULE *) Module->m_Drawings; + for( ;pt_texte != NULL ; pt_texte = (TEXTE_MODULE*)pt_texte->Pnext) + { + if(pt_texte->m_StructType != TYPETEXTEMODULE ) continue; + + if( !Sel_Texte_Divers ) continue; + if( (pt_texte->m_NoShow) && !Sel_Texte_Invisible ) + continue; + if( (g_TabOneLayerMask[pt_texte->m_Layer] & masque_layer) == 0) + continue; + PlotTextModule(pt_texte); + nb_items++ ; + msg.Printf( wxT("%d"),nb_items) ; + Affiche_1_Parametre(this, 64,wxEmptyString,msg,LIGHTBLUE) ; + } + } +} + +/**************************************************/ +static void PlotTextModule(TEXTE_MODULE * pt_texte) +/**************************************************/ +{ +wxSize size; +wxPoint pos; +int orient, epaisseur, no_miroir; + + /* calcul des parametres du texte :*/ + size = pt_texte->m_Size; + pos = pt_texte->m_Pos; + + orient = pt_texte->GetDrawRotation(); + + no_miroir = pt_texte->m_Miroir & 1; + epaisseur = pt_texte->m_Width; + if ( Plot_Mode == FILAIRE ) epaisseur = g_PlotLine_Width; + + if ( no_miroir == 0 ) size.y = -size.y; // Text is mirrored + + Plot_1_texte(format_plot, pt_texte->m_Text, + orient, epaisseur, + pos.x, pos.y, size.x, size.y); +} + + + +/*******************************************************************************/ +void PlotCotation( COTATION * Cotation, int format_plot,int masque_layer) +/*******************************************************************************/ +{ +DRAWSEGMENT *DrawTmp; + + if( (g_TabOneLayerMask[Cotation->m_Layer] & masque_layer) == 0) return; + + DrawTmp = new DRAWSEGMENT(NULL); + + masque_layer |= EDGE_LAYER; + DrawTmp->m_Width = Cotation->m_Width; + DrawTmp->m_Layer = Cotation->m_Layer; + + PlotTextePcb( Cotation->m_Text,format_plot, masque_layer); + + DrawTmp->m_Start.x = Cotation->Barre_ox; DrawTmp->m_Start.y =Cotation->Barre_oy; + DrawTmp->m_End.x = Cotation->Barre_fx; DrawTmp->m_End.y =Cotation->Barre_fy; + PlotDrawSegment( DrawTmp, format_plot, masque_layer); + + DrawTmp->m_Start.x = Cotation->TraitG_ox; DrawTmp->m_Start.y =Cotation->TraitG_oy; + DrawTmp->m_End.x = Cotation->TraitG_fx; DrawTmp->m_End.y =Cotation->TraitG_fy; + PlotDrawSegment( DrawTmp, format_plot, masque_layer); + + DrawTmp->m_Start.x = Cotation->TraitD_ox; DrawTmp->m_Start.y =Cotation->TraitD_oy; + DrawTmp->m_End.x = Cotation->TraitD_fx; DrawTmp->m_End.y =Cotation->TraitD_fy; + PlotDrawSegment( DrawTmp, format_plot, masque_layer); + + DrawTmp->m_Start.x = Cotation->FlecheD1_ox; DrawTmp->m_Start.y =Cotation->FlecheD1_oy; + DrawTmp->m_End.x = Cotation->FlecheD1_fx; DrawTmp->m_End.y =Cotation->FlecheD1_fy; + PlotDrawSegment( DrawTmp, format_plot, masque_layer); + + DrawTmp->m_Start.x = Cotation->FlecheD2_ox; DrawTmp->m_Start.y = Cotation->FlecheD2_oy; + DrawTmp->m_End.x = Cotation->FlecheD2_fx; DrawTmp->m_End.y = Cotation->FlecheD2_fy; + PlotDrawSegment( DrawTmp, format_plot, masque_layer); + + DrawTmp->m_Start.x = Cotation->FlecheG1_ox; DrawTmp->m_Start.y =Cotation->FlecheG1_oy; + DrawTmp->m_End.x = Cotation->FlecheG1_fx; DrawTmp->m_End.y =Cotation->FlecheG1_fy; + PlotDrawSegment( DrawTmp, format_plot, masque_layer); + + DrawTmp->m_Start.x = Cotation->FlecheG2_ox; DrawTmp->m_Start.y =Cotation->FlecheG2_oy; + DrawTmp->m_End.x = Cotation->FlecheG2_fx; DrawTmp->m_End.y =Cotation->FlecheG2_fy; + PlotDrawSegment( DrawTmp, format_plot, masque_layer); + + delete DrawTmp; +} + + +/*****************************************************************/ +void PlotMirePcb( MIREPCB* Mire, int format_plot,int masque_layer) +/*****************************************************************/ +{ +DRAWSEGMENT *DrawTmp; +int dx1,dx2, dy1, dy2, rayon; + + if( (g_TabOneLayerMask[Mire->m_Layer] & masque_layer) == 0) return; + + DrawTmp = new DRAWSEGMENT(NULL); + + masque_layer |= EDGE_LAYER; + DrawTmp->m_Width = Mire->m_Width; + DrawTmp->m_Layer = Mire->m_Layer; + + DrawTmp->m_Start.x = Mire->m_Pos.x; DrawTmp->m_Start.y = Mire->m_Pos.y; + DrawTmp->m_End.x = DrawTmp->m_Start.x + (Mire->m_Size / 4); + DrawTmp->m_End.y = DrawTmp->m_Start.y; + DrawTmp->m_Shape = S_CIRCLE; + PlotDrawSegment( DrawTmp, format_plot, masque_layer); + + DrawTmp->m_Shape = S_SEGMENT; + /* Trace des 2 traits */ + rayon = Mire->m_Size/2; + dx1 = rayon, dy1 = 0; dx2 = 0, dy2 = rayon; + + if( Mire->m_Shape) /* Forme X */ + { + dx1 = dy1 = (rayon * 7)/5; dx2 = dx1; dy2 = -dy1; + } + + DrawTmp->m_Start.x = Mire->m_Pos.x - dx1; DrawTmp->m_Start.y = Mire->m_Pos.y - dy1; + DrawTmp->m_End.x = Mire->m_Pos.x + dx1; DrawTmp->m_End.y = Mire->m_Pos.y + dy1; + PlotDrawSegment( DrawTmp, format_plot, masque_layer); + + DrawTmp->m_Start.x = Mire->m_Pos.x - dx2; DrawTmp->m_Start.y = Mire->m_Pos.y - dy2; + DrawTmp->m_End.x = Mire->m_Pos.x + dx2; DrawTmp->m_End.y = Mire->m_Pos.y + dy2; + PlotDrawSegment( DrawTmp, format_plot, masque_layer); + + delete DrawTmp; +} + + +/**********************************************************************/ +void Plot_Edges_Modules(BOARD * pcb, int format_plot, int masque_layer) +/**********************************************************************/ +/* Trace les contours des modules */ +{ +int nb_items; /* Pour affichage activite: nbr modules traites */ +MODULE * Module; +EDGE_MODULE * PtEdge; +wxString msg; + + nb_items = 0 ; + Module = pcb->m_Modules; + for( ; Module != NULL ; Module = (MODULE *) Module->Pnext ) + { + PtEdge = (EDGE_MODULE*) Module->m_Drawings; + for ( ;PtEdge != NULL; PtEdge = (EDGE_MODULE*)PtEdge->Pnext) + { + if(PtEdge->m_StructType != TYPEEDGEMODULE) continue; + if( (g_TabOneLayerMask[PtEdge->m_Layer] & masque_layer) == 0) continue; + Plot_1_EdgeModule(format_plot, PtEdge); + } + /* Affichage du nombre de modules traites */ + nb_items++ ; + msg.Printf( wxT("%d"),nb_items) ; + } +} + +/**************************************************************/ +void Plot_1_EdgeModule(int format_plot, EDGE_MODULE * PtEdge) +/**************************************************************/ +/* Trace les contours des modules */ +{ +int type_trace ; /* forme a tracer (segment, cercle) */ +int epaisseur; /* epaisseur des segments */ +int rayon; /* rayon des cercles a tracer */ +int StAngle, EndAngle; +wxPoint pos, end; /* Coord des segments a tracer */ + + if(PtEdge->m_StructType != TYPEEDGEMODULE) return; + type_trace = PtEdge->m_Shape; + epaisseur = PtEdge->m_Width; + if ( Plot_Mode == FILAIRE ) epaisseur = g_PlotLine_Width; + + pos = PtEdge->m_Start; + end = PtEdge->m_End; + + switch(type_trace ) + { + case S_SEGMENT: /* segment simple */ + switch ( format_plot ) + { + case PLOT_FORMAT_GERBER: + PlotGERBERLine(pos,end, epaisseur) ; + break; + + case PLOT_FORMAT_HPGL: + trace_1_segment_HPGL(pos.x,pos.y,end.x,end.y, epaisseur) ; + break; + + case PLOT_FORMAT_POST: + PlotFilledSegmentPS(pos, end, epaisseur) ; + break; + } + break; /* Fin trace segment simple */ + + case S_CIRCLE: + rayon = (int)hypot((double)(end.x - pos.x),(double)(end.y - pos.y) ); + PlotCircle(format_plot,epaisseur, pos, rayon) ; + break; + + case S_ARC: + rayon = (int)hypot((double)(end.x - pos.x),(double)(end.y - pos.y) ); + StAngle = ArcTangente(end.y - pos.y, end.x - pos.x); + EndAngle = StAngle + PtEdge->m_Angle; + if ( StAngle > EndAngle) EXCHG (StAngle, EndAngle); + PlotArc(format_plot, pos, StAngle, EndAngle, rayon, epaisseur); + break; + + case S_POLYGON: + { + // We must compute true coordinates from m_PolyList + // which are relative to module position, orientation 0 + int ii, * source, * ptr, * ptr_base; + MODULE * Module = NULL; + if ( PtEdge->m_Parent && (PtEdge->m_Parent->m_StructType == TYPEMODULE) ) + Module = (MODULE*) PtEdge->m_Parent; + ptr = ptr_base = (int*) MyMalloc( 2 * PtEdge->m_PolyCount * sizeof(int) ); + source = PtEdge->m_PolyList; + for (ii = 0; ii < PtEdge->m_PolyCount; ii++ ) + { + int x, y; + x = *source; source++; y = *source; source++; + if ( Module ) + { + RotatePoint (&x, &y, Module->m_Orient); + x += Module->m_Pos.x; + y += Module->m_Pos.y; + } + x += PtEdge->m_Start0.x; + y += PtEdge->m_Start0.y; + *ptr = x; ptr++; *ptr = y; ptr++; + } + PlotPolygon(format_plot, TRUE, PtEdge->m_PolyCount, ptr_base); + free ( ptr_base); + break; + } + + } +} + + + +/****************************************************************************/ +void PlotTextePcb(TEXTE_PCB * pt_texte, int format_plot,int masque_layer) +/****************************************************************************/ +/* Trace 1 Texte type PCB , c.a.d autre que les textes sur modules */ +{ +int no_miroir, orient, epaisseur; +wxPoint pos; +wxSize size; + + if( pt_texte->m_Text.IsEmpty() ) return; + if( (g_TabOneLayerMask[pt_texte->m_Layer] & masque_layer) == 0 ) return ; + + /* calcul des parametres du texte :*/ + size = pt_texte->m_Size; + pos = pt_texte->m_Pos; + orient = pt_texte->m_Orient; + no_miroir = pt_texte->m_Miroir & 1; + epaisseur = pt_texte->m_Width; + + if ( no_miroir == FALSE) size.x = - size.x; + + Plot_1_texte(format_plot, pt_texte->m_Text,orient, + epaisseur, pos.x, pos.y, size.x, size.y); +} + +/**********************************************************************/ +void Plot_1_texte(int format_plot,const wxString & Text, int angle, + int epaisseur, int cX,int cY,int size_h,int size_v, + bool centreX, bool centreY) +/***********************************************************************/ +/* + Trace de 1 texte: + ptr = pointeur sur le texte + angle = angle d'orientation, dependant aussi du mode de trace (miroir..) + cX, cY = position du centre du texte + size_h , size_v = dimensions ( algebriques ); +*/ +{ +int kk = 0, k1 , k2, end ; +int espacement; +char f_cod , plume ; +const SH_CODE * ptcar; +int ox,oy,fx,fy; /* Coord de debut et fin des segments a tracer */ +int sx, sy; /* coord du debut du caractere courant */ +int nbcodes = Text.Len(); + + espacement = ((10 * size_h) / 9) + ( (size_h >= 0 ) ? epaisseur : - epaisseur); + + /* calcul de la position du debut du texte */ + if ( centreX ) sx = cX - ((espacement * nbcodes) / 2 ) + (espacement /9); + else sx = cX; + if ( centreY ) sy = cY + (size_v / 2); + else sy = cY; + + /* trace du texte */ + for( ; kk < nbcodes; kk++) + { + int code = Text.GetChar(kk) & 0xFF; + ptcar = graphic_fonte_shape[code] ; /* ptcar pointe la description + du caractere a dessiner */ + + plume = 'U'; ox = sx; oy = sy; + RotatePoint(&ox, &oy, cX, cY, angle); + fx = ox; fy = oy; + + for(end = 0; end == 0; ptcar++) + { + f_cod = * ptcar; /* get code n de la forme selectionnee */ + switch(f_cod) + { + case 'X' : end = 1;/* fin du caractere */ + break; + + case 'U' : + case 'D' : plume = f_cod ; break ; + + default : + k1 = f_cod; // Coord X + k1 = (k1 * size_v) / 9; + ptcar++ ; + k2 = *ptcar; // Coord Y + k2 = (k2 * size_h) / 8 ; + + fx = k2 + sx ; fy = -k1 + sy ; + RotatePoint(&fx, &fy, cX, cY, angle); + + /* Trace du segment */ + if ( plume == 'D' ) + { + switch ( format_plot ) + { + case PLOT_FORMAT_GERBER: + PlotGERBERLine(wxPoint(ox,oy),wxPoint(fx,fy), epaisseur) ; + break; + + case PLOT_FORMAT_HPGL: + trace_1_segment_HPGL(ox,oy,fx,fy, epaisseur) ; + break; + + case PLOT_FORMAT_POST: + PlotFilledSegmentPS(wxPoint(ox,oy), wxPoint(fx,fy), epaisseur) ; + break; + + } + } + ox = fx; oy = fy; + } /* fin switch decodade matrice de forme */ + + } /* end boucle for = end trace de 1 caractere */ + + sx += espacement; + } /* end trace du texte */ +} + + +/***********************************/ +void Affiche_erreur( int nb_err) +/***********************************/ +/* Affiche le nombre d'erreurs commises ( segments traces avec plume trop grosse + ou autres */ +{ +// sprintf(msg,"%d",nb_err) ; +// Affiche_1_Parametre(this, 30,"Err",msg,GREEN) ; +} + + +/******************************************************************************/ +void PlotDrawSegment(DRAWSEGMENT * pt_segm, int Format, int masque_layer ) +/******************************************************************************/ +/* Trace un element du type DRAWSEGMENT draw appartenant + aux couches specifiees par masque_layer +*/ +{ +wxPoint start, end; +int epaisseur; +int rayon = 0, StAngle = 0, EndAngle = 0; + + if( (g_TabOneLayerMask[pt_segm->m_Layer] & masque_layer) == 0) return; + + epaisseur = pt_segm->m_Width; + if ( Plot_Mode == FILAIRE) epaisseur = g_PlotLine_Width; + + start = pt_segm->m_Start; end = pt_segm->m_End; + + if(pt_segm->m_Shape == S_CIRCLE) + { + rayon = (int)hypot((double)(end.x - start.x),(double)(end.y - start.y) ); + } + + if(pt_segm->m_Shape == S_ARC) + { + rayon = (int)hypot((double)(end.x - start.x),(double)(end.y - start.y) ); + StAngle = ArcTangente(end.y - start.y, end.x - start.x); + EndAngle = StAngle + pt_segm->m_Angle; + if ( StAngle > EndAngle) EXCHG (StAngle, EndAngle); + } + + switch ( Format ) + { + case PLOT_FORMAT_GERBER: + if(pt_segm->m_Shape == S_CIRCLE) + PlotCircle(PLOT_FORMAT_GERBER,epaisseur, start , rayon) ; + else if(pt_segm->m_Shape == S_ARC) + PlotArc(PLOT_FORMAT_GERBER, start , + StAngle, EndAngle, rayon, epaisseur); + else PlotGERBERLine(start, end, epaisseur) ; + break; + + case PLOT_FORMAT_HPGL: + if(pt_segm->m_Shape == S_CIRCLE) + PlotCircle(PLOT_FORMAT_HPGL,epaisseur, start , rayon) ; + else if(pt_segm->m_Shape == S_ARC) + PlotArc(PLOT_FORMAT_HPGL, start , StAngle, EndAngle, rayon, epaisseur); + else trace_1_segment_HPGL(start.x,start.y, end.x,end.y, epaisseur) ; + break; + + case PLOT_FORMAT_POST: + if(pt_segm->m_Shape == S_CIRCLE) + PlotCircle(PLOT_FORMAT_POST,epaisseur, start, rayon) ; + else if(pt_segm->m_Shape == S_ARC) + PlotArc(PLOT_FORMAT_POST, start, + StAngle, EndAngle, rayon, epaisseur); + else PlotFilledSegmentPS(start, end, epaisseur) ; + break; + } +} + + +/*****************************************************************************/ +void PlotCircle( int format_plot, int epaisseur, wxPoint centre, int rayon) +/*****************************************************************************/ +/* routine de trace de 1 cercle de centre cx, cy */ +{ + switch ( format_plot ) + { + case PLOT_FORMAT_GERBER: + PlotCircle_GERBER( centre, rayon, epaisseur) ; + break; + + case PLOT_FORMAT_HPGL: + trace_1_pastille_RONDE_HPGL( centre, rayon * 2, FILAIRE) ; + break; + + case PLOT_FORMAT_POST: + PlotCircle_PS ( centre, rayon * 2, epaisseur); + break; + } +} + + +/**********************************************************************/ +void PlotPolygon(int format_plot, bool Filled, int nbpoints, int * coord) +/**********************************************************************/ +/* plot a polygon */ +{ + switch ( format_plot ) + { + case PLOT_FORMAT_GERBER: + PlotPolygon_GERBER(nbpoints, coord, Filled) ; + break; + + case PLOT_FORMAT_HPGL: + PlotPolyHPGL( nbpoints, coord, Filled); + break; + + case PLOT_FORMAT_POST: + PlotPolyPS( nbpoints, coord, Filled); + break; + } +} + +/************************************************************************/ +void PlotArc(int format_plot,wxPoint centre,int start_angle,int end_angle, + int rayon,int epaisseur) +/************************************************************************/ +/* Polt 1 arc + start, end = angles in 1/10 degree for start and stop point + */ +{ +int ii; +int ox, oy, fx, fy; +int delta; /* increment (en 0.1 degres) angulaire pour trace de cercles */ + + if ( Plot_Mode == FILAIRE) epaisseur = g_PlotLine_Width; + + if( format_plot == PLOT_FORMAT_POST ) + { + PlotArcPS(centre,start_angle,end_angle, rayon, epaisseur); + return; + } + + // change due to Y axis is negative orientation on screen + start_angle = -start_angle; + end_angle = - end_angle; + EXCHG (start_angle, end_angle); + + /* Correction pour petits cercles par rapport a l'epaisseur du trait */ + if( rayon < (epaisseur * 10) ) delta = 225; /* 16 segm pour 360 deg */ + if( rayon < (epaisseur * 5) ) delta = 300; /* 12 segm pour 360 deg */ + + if ( start_angle > end_angle ) end_angle += 3600; + ox = rayon; oy = 0; + RotatePoint(&ox, &oy, start_angle ); + + delta = 120; /* un cercle sera trace en 3600/delta = 30 segments / cercle*/ + for (ii = start_angle+delta ; ii < end_angle ; ii += delta ) + { + fx = rayon; fy = 0; + RotatePoint(&fx, &fy, ii); + switch ( format_plot ) + { + case PLOT_FORMAT_GERBER: + PlotGERBERLine(wxPoint(centre.x+ox, centre.y+oy), + wxPoint(centre.x+fx,centre.y+fy), epaisseur) ; + break; + + case PLOT_FORMAT_HPGL: + trace_1_segment_HPGL(centre.x+ox,centre.y+oy,centre.x+fx,centre.y+fy, epaisseur) ; + break; + + case PLOT_FORMAT_POST: + break; + } + ox = fx; oy = fy ; + } + + fx = rayon; fy = 0; + RotatePoint(&fx, &fy, end_angle); + switch ( format_plot ) + { + case PLOT_FORMAT_GERBER: + PlotGERBERLine(wxPoint(centre.x+ox, centre.y+oy), + wxPoint(centre.x+fx,centre.y+fy), epaisseur) ; + break; + + case PLOT_FORMAT_HPGL: + trace_1_segment_HPGL(centre.x+ox,centre.y+oy,centre.x+fx,centre.y+fy, epaisseur) ; + break; + + case PLOT_FORMAT_POST: + break; + } +} + diff --git a/pcbnew/plotgerb.cpp b/pcbnew/plotgerb.cpp new file mode 100644 index 0000000000..fa87986ffd --- /dev/null +++ b/pcbnew/plotgerb.cpp @@ -0,0 +1,841 @@ + /****************************************/ + /**** Routine de trace GERBER RS274X ****/ + /****************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "plot_common.h" +#include "pcbnew.h" +#include "pcbplot.h" +#include "trigo.h" +#include "plotgerb.h" + +#include "protos.h" + + +/* Variables locales : */ +static int s_Last_D_code ; +static float Gerb_scale_plot; /*Coeff de conversion d'unites des traces */ +static int scale_spot_mini; /* Ouverture mini (pour remplissages) */ +static D_CODE * s_DCodeList; /* Pointeur sur la zone de stockage des D_CODES */ +wxString GerberFullFileName; +static double scale_x , scale_y ; /* echelles de convertion en X et Y (compte tenu + des unites relatives du PCB et des traceurs*/ +static bool ShowDcodeError = TRUE; + +/* Routines Locales */ + +static void Init_Trace_GERBER(WinEDA_BasePcbFrame * frame, FILE * gerbfile); +static void Init_ApertureList(void); +static void Fin_Trace_GERBER(WinEDA_BasePcbFrame * frame, FILE * gerbfile); +static void Plot_1_CIRCLE_pad_GERBER(wxPoint pos,int diametre) ; +static void trace_1_pastille_OVALE_GERBER(wxPoint pos, wxSize size,int orient); +static void PlotRectangularPad_GERBER(wxPoint pos, wxSize size, int orient); + +static D_CODE * get_D_code(int dx,int dy, int type, int drill ) ; +static void trace_1_pad_TRAPEZE_GERBER(wxPoint pos, wxSize size,wxSize delta, + int orient,int modetrace); + + +/********************************************************************************/ +void WinEDA_BasePcbFrame::Genere_GERBER(const wxString & FullFileName, int Layer, + bool PlotOriginIsAuxAxis) +/********************************************************************************/ +/* Genere les divers fichiers de trace: + Pour chaque couche 1 fichier xxxc.PHO au format RS274X +*/ +{ +int tracevia = 1; + + EraseMsgBox(); + GerberFullFileName = FullFileName; + + g_PlotOrient = 0; + if (Plot_Set_MIROIR) g_PlotOrient |= PLOT_MIROIR; + + /* Calcul des echelles de conversion */ + Gerb_scale_plot = 1.0; /* pour unites gerber en 0,1 Mils, format 3.4 */ + scale_spot_mini = (int)(spot_mini * 10 * Gerb_scale_plot); + scale_x = Scale_X * Gerb_scale_plot; + scale_y = Scale_Y * Gerb_scale_plot; + g_PlotOffset.x = 0; + g_PlotOffset.y = 0; + if ( PlotOriginIsAuxAxis ) + { + g_PlotOffset = m_Auxiliary_Axis_Position; + } + + InitPlotParametresGERBER(g_PlotOffset, scale_x, scale_y); + + /* Clear the memory used for handle the D_CODE (aperture) list */ + Init_ApertureList(); + + dest = wxFopen(FullFileName, wxT("wt")); + if (dest == NULL) + { + wxString msg = _("unable to create file ") + FullFileName; + DisplayError(this, msg); return ; + } + + Affiche_1_Parametre(this, 0, _("File"),FullFileName,CYAN) ; + + Init_Trace_GERBER(this, dest) ; + + nb_plot_erreur = 0 ; + + int layer_mask = g_TabOneLayerMask[Layer]; + switch(Layer) + { + case CUIVRE_N : + case LAYER_N_2 : + case LAYER_N_3 : + case LAYER_N_4 : + case LAYER_N_5 : + case LAYER_N_6 : + case LAYER_N_7 : + case LAYER_N_8 : + case LAYER_N_9 : + case LAYER_N_10 : + case LAYER_N_11: + case LAYER_N_12: + case LAYER_N_13 : + case LAYER_N_14 : + case LAYER_N_15 : + case CMP_N : + Plot_Layer_GERBER(dest,layer_mask, 0, 1); + break; + + case SOLDERMASK_N_CU : + case SOLDERMASK_N_CMP : /* Trace du vernis epargne */ + if ( g_DrawViaOnMaskLayer ) tracevia = 1; + else tracevia = 0; + Plot_Layer_GERBER(dest, layer_mask, g_DesignSettings.m_MaskMargin, tracevia); + break; + + case SOLDERPASTE_N_CU : + case SOLDERPASTE_N_CMP : /* Trace du masque de pate de soudure */ + Plot_Layer_GERBER(dest, layer_mask, 0, 0); + break; + + default: + Plot_Serigraphie(PLOT_FORMAT_GERBER,dest, layer_mask); + break; + } + + Fin_Trace_GERBER(this, dest) ; +} + + +/***********************************************************************/ +void WinEDA_BasePcbFrame::Plot_Layer_GERBER(FILE * File,int masque_layer, + int garde, int tracevia) +/***********************************************************************/ +/* Trace en format GERBER. d'une couche cuivre ou masque +*/ +{ +wxPoint pos; +wxSize size; +MODULE * Module; +D_PAD * PtPad; +TRACK * track ; +EDA_BaseStruct * PtStruct; +wxString msg; + + masque_layer |= EDGE_LAYER; /* Les elements de la couche EDGE sont tj traces */ + + /* trace des elements type Drawings Pcb : */ + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + PlotDrawSegment( (DRAWSEGMENT*) PtStruct, PLOT_FORMAT_GERBER, + masque_layer); + break; + + case TYPETEXTE: + PlotTextePcb((TEXTE_PCB*) PtStruct,PLOT_FORMAT_GERBER, + masque_layer); + break; + + case TYPECOTATION: + PlotCotation((COTATION*) PtStruct, PLOT_FORMAT_GERBER, + masque_layer); + break; + + case TYPEMIRE: + PlotMirePcb((MIREPCB*) PtStruct, PLOT_FORMAT_GERBER, + masque_layer); + break; + + case TYPEMARQUEUR: + break; + + default: + DisplayError(this, wxT("Type Draw non gere")); + break; + } + } + + /* Trace des Elements des modules autres que pads */ + nb_items = 0 ; + Affiche_1_Parametre(this, 38, wxT("DrawMod"), wxEmptyString,GREEN) ; + Module = m_Pcb->m_Modules; + for( ; Module != NULL ;Module = (MODULE *)Module->Pnext ) + { + PtStruct = Module->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEEDGEMODULE: + if( masque_layer & g_TabOneLayerMask[((EDGE_MODULE*)PtStruct)->m_Layer] ) + Plot_1_EdgeModule(PLOT_FORMAT_GERBER, (EDGE_MODULE*) PtStruct); + break; + + default: break; + } + } + } + + /* Trace des Elements des modules : Pastilles */ + nb_items = 0 ; + Affiche_1_Parametre(this, 48, wxT("Pads"),wxEmptyString,GREEN) ; + Module = m_Pcb->m_Modules; + for( ; Module != NULL ;Module = (MODULE *)Module->Pnext ) + { + PtPad = (D_PAD*) Module->m_Pads; + for ( ; PtPad != NULL ; PtPad = (D_PAD*)PtPad->Pnext ) + { + wxPoint shape_pos; + if( (PtPad->m_Masque_Layer & masque_layer) == 0) + continue ; + shape_pos = PtPad->ReturnShapePos(); + pos = shape_pos; + + size.x = PtPad->m_Size.x + (garde * 2) ; + size.y = PtPad->m_Size.y + (garde * 2) ; + + /* Don't draw a null size item : */ + if ( (size.x == 0) || (size.y == 0) ) continue; + + nb_items++ ; + + switch (PtPad->m_PadShape) + { + case CIRCLE : + Plot_1_CIRCLE_pad_GERBER(pos,size.x) ; + break ; + + case OVALE : + { + trace_1_pastille_OVALE_GERBER(pos, size,PtPad->m_Orient); + break ; + } + + case TRAPEZE : + { + wxSize delta = PtPad->m_DeltaSize; + trace_1_pad_TRAPEZE_GERBER(pos,size, + delta, PtPad->m_Orient, FILLED) ; + break ; + } + + case RECT: + default: + PlotRectangularPad_GERBER(pos,size, PtPad->m_Orient) ; + break ; + } + msg.Printf( wxT("%d"),nb_items) ; + Affiche_1_Parametre(this, 48,wxEmptyString, msg,GREEN) ; + } + } + /* trace des VIAS : */ + if(tracevia) + { + nb_items = 0 ; + Affiche_1_Parametre(this, 56, wxT("Vias"), wxEmptyString,RED) ; + for( track = m_Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext) + { + if( track->m_StructType != TYPEVIA ) continue; + SEGVIA * Via = (SEGVIA *) track; + /* vias not plotted if not on selected layer, but if layer + == SOLDERMASK_LAYER_CU or SOLDERMASK_LAYER_CMP, vias are drawn , + if they are on a external copper layer + */ + int via_mask_layer = Via->ReturnMaskLayer(); + if ( (via_mask_layer & CUIVRE_LAYER ) ) via_mask_layer |= SOLDERMASK_LAYER_CU; + if ( (via_mask_layer & CMP_LAYER ) ) via_mask_layer |= SOLDERMASK_LAYER_CMP; + if( (via_mask_layer & masque_layer) == 0 ) continue; + + pos = Via->m_Start; + size.x = size.y = Via->m_Width + (garde * 2); + Plot_1_CIRCLE_pad_GERBER(pos,size.x) ; + nb_items++ ; msg.Printf( wxT("%d"),nb_items) ; + Affiche_1_Parametre(this, 56,wxEmptyString, msg,RED) ; + } + } + /* trace des pistes : */ + nb_items = 0 ; + Affiche_1_Parametre(this, 64, wxT("Tracks"),wxEmptyString,YELLOW) ; + + for( track = m_Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext) + { + wxPoint end; + + if ( track->m_StructType == TYPEVIA ) continue ; + if( (g_TabOneLayerMask[track->m_Layer] & masque_layer) == 0 ) continue; + + size.x = size.y = track->m_Width; + pos = track->m_Start; end = track->m_End; + + PlotGERBERLine(pos,end, size.x) ; + + nb_items++ ; msg.Printf( wxT("%d"),nb_items) ; + Affiche_1_Parametre(this, 64, wxEmptyString, msg,YELLOW) ; + } + + /* trace des zones: */ + nb_items = 0 ; + if ( m_Pcb->m_Zone ) Affiche_1_Parametre(this, 72, wxT("Zones "),wxEmptyString,YELLOW) ; + + for( track = m_Pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext) + { + wxPoint end; + + if( (g_TabOneLayerMask[track->m_Layer] & masque_layer) == 0 ) continue; + + size.x = size.y = track->m_Width; + pos = track->m_Start; end = track->m_End; + + PlotGERBERLine(pos,end, size.x) ; + + nb_items++ ; msg.Printf( wxT("%d"),nb_items) ; + Affiche_1_Parametre(this, 72, wxEmptyString,msg,YELLOW) ; + } +} + + +/**********************************************************************/ +void trace_1_pastille_OVALE_GERBER(wxPoint pos, wxSize size, int orient) +/**********************************************************************/ +/* Trace 1 pastille OVALE en position pos_X,Y: + dimensions dx,dy, + orientation orient + Pour une orientation verticale ou horizontale, la forme est flashee + Pour une orientation quelconque la forme est tracee comme un segment +*/ +{ +D_CODE * dcode_ptr; +int x0, y0, x1, y1, delta; + + if( (orient == 900) || (orient == 2700)) /* orient tournee de 90 deg */ + { + EXCHG(size.x,size.y); + } + + /* Trace de la forme flashee */ + if( (orient == 0) || (orient == 900) || + (orient == 1800) || (orient == 2700) ) + { + UserToDeviceCoordinate(pos) ; + UserToDeviceSize(size); + + dcode_ptr = get_D_code(size.x,size.y,GERB_OVALE,0) ; + if (dcode_ptr->m_NumDcode != s_Last_D_code ) + { + sprintf(cbuf,"G54D%d*\n",dcode_ptr->m_NumDcode) ; + fputs(cbuf,dest) ; + s_Last_D_code = dcode_ptr->m_NumDcode; + } + sprintf(cbuf,"X%5.5dY%5.5dD03*\n", pos.x, pos.y); + fputs(cbuf,dest) ; + } + + else /* Forme tracee comme un segment */ + { + if(size.x > size.y ) + { + EXCHG(size.x,size.y); orient += 900; + } + /* la pastille est ramenee a une pastille ovale avec dy > dx */ + delta = size.y - size.x; + x0 = 0; y0 = -delta / 2; + x1 = 0; y1 = delta / 2; + RotatePoint(&x0,&y0, orient); + RotatePoint(&x1,&y1, orient); + PlotGERBERLine( wxPoint(pos.x + x0, pos.y + y0), + wxPoint(pos.x + x1, pos.y + y1), size.x); + } +} + + +/******************************************************************/ +void Plot_1_CIRCLE_pad_GERBER(wxPoint pos,int diametre) +/******************************************************************/ +/* Plot a circulat pad or via at the user position pos +*/ +{ +D_CODE * dcode_ptr; +wxSize size(diametre, diametre); + + UserToDeviceCoordinate(pos); + UserToDeviceSize(size); + + dcode_ptr = get_D_code(size.x,size.x,GERB_CIRCLE,0) ; + if (dcode_ptr->m_NumDcode != s_Last_D_code ) + { + sprintf(cbuf,"G54D%d*\n", dcode_ptr->m_NumDcode) ; + fputs(cbuf,dest) ; + s_Last_D_code = dcode_ptr->m_NumDcode; + } + + sprintf(cbuf,"X%5.5dY%5.5dD03*\n", pos.x, pos.y); + fputs(cbuf,dest) ; +} + +/**************************************************************************/ +void PlotRectangularPad_GERBER(wxPoint pos, wxSize size, int orient) +/**************************************************************************/ +/* + Trace 1 pad rectangulaire d'orientation quelconque + donne par son centre, ses dimensions, et son orientation + Pour une orientation verticale ou horizontale, la forme est flashee + Pour une orientation quelconque la forme est tracee par 4 segments + de largeur 1/2 largeur pad +*/ +{ +D_CODE * dcode_ptr; + + /* Trace de la forme flashee */ + switch (orient) + { + case 900 : + case 2700 : /* la rotation de 90 ou 270 degres revient a permutter des dimensions */ + EXCHG(size.x,size.y); + case 1800 : + case 0 : + UserToDeviceCoordinate(pos) ; + UserToDeviceSize(size); + + dcode_ptr = get_D_code(size.x,size.y,GERB_RECT,0) ; + if (dcode_ptr->m_NumDcode != s_Last_D_code ) + { + sprintf(cbuf,"G54D%d*\n", dcode_ptr->m_NumDcode) ; + fputs(cbuf,dest) ; + s_Last_D_code = dcode_ptr->m_NumDcode; + } + sprintf(cbuf,"X%5.5dY%5.5dD03*\n", pos.x, pos.y); + fputs(cbuf,dest) ; + break; + + default: /* Forme tracee par remplissage */ + trace_1_pad_TRAPEZE_GERBER(pos, size, wxSize(0, 0), orient,FILLED); + break; + } +} + + +/*****************************************************************/ +void trace_1_contour_GERBER(wxPoint pos, wxSize size, wxSize delta, + int penwidth, int orient) +/*****************************************************************/ +/* + Trace 1 contour rectangulaire ou trapezoidal d'orientation quelconque + donne par son centre, + ses dimensions , + ses variations , + l'epaisseur du trait, + et son orientation orient +*/ +{ +int ii; +wxPoint coord[4]; + + size.x /= 2; size.y /= 2 ; + delta.x /= 2; delta.y /= 2 ; /* demi dim dx et dy */ + + coord[0].x = pos.x - size.x - delta.y; + coord[0].y = pos.y + size.y + delta.x; + + coord[1].x = pos.x - size.x + delta.y; + coord[1].y = pos.y - size.y - delta.x; + + coord[2].x = pos.x + size.x - delta.y; + coord[2].y = pos.y - size.y + delta.x; + + coord[3].x = pos.x + size.x + delta.y; + coord[3].y = pos.y + size.y - delta.x; + + for (ii = 0; ii < 4; ii++) + { + RotatePoint(&coord[ii].x, &coord[ii].y, pos.x, pos.y, orient); + } + + + PlotGERBERLine( coord[0], coord[1], penwidth); + PlotGERBERLine( coord[1], coord[2], penwidth); + PlotGERBERLine( coord[2], coord[3], penwidth); + PlotGERBERLine( coord[3], coord[0], penwidth); +} + + +/*******************************************************************/ +void trace_1_pad_TRAPEZE_GERBER(wxPoint pos, wxSize size,wxSize delta, + int orient,int modetrace) +/*******************************************************************/ + +/* + Trace 1 pad trapezoidal donne par : + son centre pos.x,pos.y + ses dimensions size.x et size.y + les variations delta.x et delta.y ( 1 des deux au moins doit etre nulle) + son orientation orient en 0.1 degres + le mode de trace (FILLED, SKETCH, FILAIRE) + + Le trace n'est fait que pour un trapeze, c.a.d que delta.x ou delta.y + = 0. + + les notation des sommets sont ( vis a vis de la table tracante ) + +" 0 ------------- 3 " +" . . " +" . O . " +" . . " +" 1 ---- 2 " + + + exemple de Disposition pour delta.y > 0, delta.x = 0 +" 1 ---- 2 " +" . . " +" . O . " +" . . " +" 0 ------------- 3 " + + + exemple de Disposition pour delta.y = 0, delta.x > 0 +" 0 " +" . . " +" . . " +" . 3 " +" . . " +" . O . " +" . . " +" . 2 " +" . . " +" . . " +" 1 " +*/ +{ +int ii , jj; +int dx,dy; +wxPoint polygone[4]; /* coord sommets */ +int coord[8]; +int ddx, ddy ; + + /* calcul des dimensions optimales du spot choisi = 1/4 plus petite dim */ + dx = size.x - abs(delta.y); + dy = size.y - abs(delta.x); + + dx = size.x / 2; dy = size.y / 2 ; + ddx = delta.x / 2; ddy = delta.y / 2 ; + + polygone[0].x = - dx - ddy; polygone[0].y = + dy + ddx; + polygone[1].x = - dx + ddy; polygone[1].y = - dy - ddx; + polygone[2].x = + dx - ddy; polygone[2].y = - dy + ddx; + polygone[3].x = + dx + ddy; polygone[3].y = + dy - ddx; + + /* Dessin du polygone et Remplissage eventuel de l'interieur */ + + for (ii = 0, jj = 0; ii < 4; ii++) + { + RotatePoint(&polygone[ii].x, &polygone[ii].y, orient); + coord[jj] = polygone[ii].x += pos.x; + jj++; + coord[jj] = polygone[ii].y += pos.y; + jj++; + } + + if(modetrace != FILLED ) + { + PlotGERBERLine( polygone[0], polygone[1], scale_spot_mini); + PlotGERBERLine( polygone[1], polygone[2], scale_spot_mini); + PlotGERBERLine( polygone[2], polygone[3], scale_spot_mini); + PlotGERBERLine( polygone[3], polygone[0], scale_spot_mini); + } + + else + PlotPolygon_GERBER(4, coord, TRUE); +} + + +/**********************************************************/ +void PlotGERBERLine(wxPoint start, wxPoint end, int large) +/**********************************************************/ +/* Trace 1 segment de piste : +*/ +{ +D_CODE * dcode_ptr; + + UserToDeviceCoordinate(start); + UserToDeviceCoordinate(end); + + dcode_ptr = get_D_code(large,large,GERB_LINE,0) ; + if (dcode_ptr->m_NumDcode != s_Last_D_code ) + { + sprintf(cbuf,"G54D%d*\n", dcode_ptr->m_NumDcode) ; + fputs(cbuf,dest) ; + s_Last_D_code = dcode_ptr->m_NumDcode; + } + sprintf(cbuf,"X%5.5dY%5.5dD02*\n",start.x,start.y) ; fputs(cbuf,dest) ; + sprintf(cbuf,"X%5.5dY%5.5dD01*\n",end.x,end.y) ; fputs(cbuf,dest) ; +} + +/********************************************************************/ +void PlotCircle_GERBER( wxPoint centre, int rayon, int epaisseur) +/********************************************************************/ +/* routine de trace de 1 cercle de centre centre par approximation de segments +*/ +{ +int ii ; +int ox, oy, fx, fy; +int delta; /* increment (en 0.1 degres) angulaire pour trace de cercles */ + + delta = 120; /* un cercle sera trace en 3600/delta segments */ + /* Correction pour petits cercles par rapport a l'epaisseur du trait */ + if( rayon < (epaisseur * 10) ) delta = 225; /* 16 segm pour 360 deg */ + if( rayon < (epaisseur * 5) ) delta = 300; /* 12 segm pour 360 deg */ + if( rayon < (epaisseur * 2) ) delta = 600; /* 6 segm pour 360 deg */ + + ox = centre.x + rayon; oy = centre.y; + for (ii = delta ; ii < 3600 ; ii += delta ) + { + fx = centre.x + (int)(rayon * fcosinus[ii]); + fy = centre.y + (int)(rayon * fsinus[ii]); + PlotGERBERLine(wxPoint(ox,oy), wxPoint(fx,fy), epaisseur) ; + ox = fx; oy = fy; + } + + fx = centre.x + rayon; fy = centre.y; + PlotGERBERLine(wxPoint(ox,oy), wxPoint(fx,fy), epaisseur) ; +} + + +/***************************************************************/ +void PlotPolygon_GERBER(int nb_segm, int * coord, bool fill) +/***************************************************************/ +{ +int ii; +wxPoint pos; + + fputs("G36*\n", dest); + pos.x = *coord; coord++; + pos.y = *coord; coord++; + UserToDeviceCoordinate(pos); + fprintf(dest, "X%5.5dY%5.5dD02*\n", pos.x, pos.y ); + for ( ii = 1; ii < nb_segm; ii++ ) + { + pos.x = *coord; coord++; + pos.y = *coord; coord++; + UserToDeviceCoordinate(pos); + fprintf(dest, "X%5.5dY%5.5dD01*\n", pos.x, pos.y ); + } + + fputs("G37*\n", dest); +} + + +/*******************************************************/ +D_CODE * get_D_code(int dx,int dy, int type, int drill ) +/*******************************************************/ +/* + Fonction Recherchant et Creant eventuellement la description + du D_CODE du type et dimensions demandees +*/ +{ +D_CODE * ptr_tool, * last_dcode_ptr; +int num_new_D_code = FIRST_DCODE_VALUE; + + + ptr_tool = last_dcode_ptr = s_DCodeList; + + while(ptr_tool && ptr_tool->m_Type >= 0 ) + { + if( ( ptr_tool->m_Size.x == dx ) && + ( ptr_tool->m_Size.y == dy ) && + ( ptr_tool->m_Type == type ) ) + return(ptr_tool); /* D_code deja existant */ + last_dcode_ptr = ptr_tool; + ptr_tool = ptr_tool->m_Pnext ; + num_new_D_code++ ; + } + + /* At this point, the requested D_CODE does not exist: It will be created */ + if ( ptr_tool == NULL ) /* We must create a new data */ + { + ptr_tool = new D_CODE(); + ptr_tool->m_NumDcode = num_new_D_code; + if ( last_dcode_ptr ) + { + ptr_tool->m_Pback = last_dcode_ptr; + last_dcode_ptr->m_Pnext = ptr_tool; + } + else s_DCodeList = ptr_tool; + } + ptr_tool->m_Size.x = dx ; + ptr_tool->m_Size.y = dy ; + ptr_tool->m_Type = type ; + return(ptr_tool); +} + + +/******************************************************************/ +void Init_Trace_GERBER(WinEDA_BasePcbFrame * frame, FILE * gerbfile) +/******************************************************************/ +{ +char Line[1024]; + + s_Last_D_code = 0 ; + + DateAndTime(Line); + wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); + fprintf(gerbfile,"G04 (Genere par %s) le %s*\n",CONV_TO_UTF8(Title), Line); + + // Specify linear interpol (G01), unit = INCH (G70), abs format (G90): + fputs("G01*\nG70*\nG90*\n", gerbfile); + fputs("%MOIN*%\n", gerbfile); // set unites = INCHES + + /* Set gerber format to 3.4 */ + strcpy(Line,"G04 Gerber Fmt 3.4, Leading zero omitted, Abs format*\n%FSLAX34Y34*%\n") ; + + fputs(Line,gerbfile); + + fputs("G04 APERTURE LIST*\n", gerbfile); +} + + +/***********************************/ +static void Init_ApertureList(void) +/***********************************/ +/* Init the memory to handle the aperture list: + the member .m_Type is used by get_D_code() to handle the end of list: + .m_Type < 0 is the first free aperture descr */ +{ +D_CODE * ptr_tool; + + ptr_tool = s_DCodeList; + while ( ptr_tool ) + { + s_DCodeList->m_Type = -1; + ptr_tool = ptr_tool->m_Pnext ; + } + ShowDcodeError = TRUE; +} + +/*****************************************************************/ +void Fin_Trace_GERBER(WinEDA_BasePcbFrame * frame, FILE * gerbfile) +/*****************************************************************/ +{ +char line[1024]; +wxString TmpFileName, msg; +FILE * outfile; + + fputs("M02*\n",gerbfile); + fclose(gerbfile); + + // Reouverture gerbfile pour ajout des Apertures + gerbfile = wxFopen(GerberFullFileName, wxT("rt") ); + if (gerbfile == NULL) + { + msg.Printf( _("unable to reopen file <%s>"),GerberFullFileName.GetData() ) ; + DisplayError(frame, msg); return ; + } + + + // Ouverture tmpfile + TmpFileName = GerberFullFileName + wxT(".$$$"); + outfile = wxFopen(TmpFileName, wxT("wt") ); + if ( outfile == NULL ) + { + fclose(gerbfile); + DisplayError(frame, wxT("Fin_Trace_GERBER(): Can't Open tmp file")); + return; + } + + // Placement des Apertures en RS274X + rewind(gerbfile); + while ( fgets(line, 1024, gerbfile) ) + { + fputs(line, outfile); + if ( strcmp(strtok(line, "\n\r"),"G04 APERTURE LIST*") == 0 ) + { + frame->Gen_D_CODE_File(outfile); + fputs("G04 APERTURE END LIST*\n", outfile); + } + } + + fclose(outfile); + fclose(gerbfile); + wxRemoveFile(GerberFullFileName); + wxRenameFile(TmpFileName, GerberFullFileName); + +} + + +/******************************************************/ +int WinEDA_BasePcbFrame::Gen_D_CODE_File(FILE * penfile) +/******************************************************/ +/* Genere la liste courante des D_CODES + Retourne le nombre de D_Codes utilises + Genere une sequence RS274X + */ +{ +D_CODE * ptr_tool; +int nb_dcodes = 0 ; + + /* Init : */ + ptr_tool = s_DCodeList; + + while(ptr_tool && (ptr_tool->m_Type >= 0 ) ) + { + float fscale = 0.0001; // For 3.4 format + char * text; + sprintf(cbuf,"%%ADD%d", ptr_tool->m_NumDcode); + text = cbuf + strlen(cbuf); + switch ( ptr_tool->m_Type ) + { + case 1: // Circle (flash ) + sprintf(text,"C,%f*%%\n", ptr_tool->m_Size.x * fscale); + break; + + case 2: // RECT + sprintf(text,"R,%fX%f*%%\n", ptr_tool->m_Size.x * fscale, + ptr_tool->m_Size.y * fscale); + break; + + case 3: // Circle ( lines ) + sprintf(text,"C,%f*%%\n", ptr_tool->m_Size.x * fscale); + break; + + case 4: // OVALE + sprintf(text,"O,%fX%f*%%\n", ptr_tool->m_Size.x * fscale, + ptr_tool->m_Size.y * fscale); + break; + + default: + DisplayError(this, wxT("Gen_D_CODE_File(): Dcode Type err") ); + break; + } + // compensation localisation printf (float x.y généré x,y) + to_point ( text + 2 ); + + fputs(cbuf,penfile) ; + ptr_tool = ptr_tool->m_Pnext; nb_dcodes++ ; + } + + return(nb_dcodes); +} + + diff --git a/pcbnew/plotgerb.h b/pcbnew/plotgerb.h new file mode 100644 index 0000000000..7b44b3e5a5 --- /dev/null +++ b/pcbnew/plotgerb.h @@ -0,0 +1,108 @@ + /************/ + /* pcbplot.h*/ + /************/ + +#ifndef PLOTGERB_H +#define PLOTGERB_H + + +/* Format Gerber : NOTES : +Fonctions preparatoires: + Gn = + G01 interpolation lineaire ( trace de droites ) + G02,G20,G21 Interpolation circulaire , sens trigo < 0 + G03,G30,G31 Interpolation circulaire , sens trigo > 0 + G04 commentaire + G06 Interpolation parabolique + G07 Interpolation cubique + G10 interpolation lineaire ( echelle 10x ) + G11 interpolation lineaire ( echelle 0.1x ) + G12 interpolation lineaire ( echelle 0.01x ) + G36 Start polygon description + G37 End polygon description + G52 plot symbole reference par Dnn code + G53 plot symbole reference par Dnn ; symbole tourne de -90 degres + G54 Selection d'outil + G55 Mode exposition photo + G56 plot symbole reference par Dnn A code + G57 affiche le symbole reference sur la console + G58 plot et affiche le symbole reference sur la console + G60 interpolation lineaire ( echelle 100x ) + G70 Unites = Inches + G71 Unites = Millimetres + G74 supprime interpolation circulaire sur 360 degre, revient a G01 + G75 Active interpolation circulaire sur 360 degre + G90 Mode Coordonnees absolues + G91 Mode Coordonnees Relatives + +Coordonnees X,Y + X,Y sont suivies de + ou - et de m+n chiffres (non separes) + m = partie entiere + n = partie apres la virgule + formats classiques : m = 2, n = 3 (format 2.3) + m = 3, n = 4 (format 3.4) + ex: + G__ X00345Y-06123 D__* + +Outils et D_CODES + numero d'outil ( identification des formes ) + 1 a 99 (classique) + 1 a 999 + D_CODES: + + D01 ... D9 = codes d'action: + D01 = activation de lumiere ( baisser de plume) + D02 = extinction de lumiere ( lever de plume) + D03 = Flash + D09 = VAPE Flash + D51 = precede par G54 -> Select VAPE + + D10 ... D255 = Indentification d'outils ( d'ouvertures ) + Ne sont pas tj dans l'ordre ( voir tableau ci dessous) +*/ + + + /*************************************/ + /* Constantes utiles en trace GERBER */ + /*************************************/ + +/* codes de type de forme d'outils */ +#define GERB_CIRCLE 1 +#define GERB_RECT 2 +#define GERB_LINE 3 +#define GERB_OVALE 4 +#define GERB_DONUT 5 + +/* liste des D_CODES en fonction de leur numero d'ordre (numero d'outil) + (l'ordre 0 n'est pas utilise) ; + Tools have D_CODES >= 10 + D_CODES <= 9 are used for commands only: + D01 ... D9 = command codes for photo plotting: + D01 = Light on + D02 = Light off + D03 = Flash + D04 .. D08 = ? + D09 = VAPE Flash +*/ + +#define FIRST_DCODE_VALUE 10 + +/* Structure de Description d'un D_CODE GERBER : */ +class D_CODE +{ +public: + D_CODE * m_Pnext, * m_Pback; /* for a linked list */ + wxSize m_Size; /* horiz and Vert size*/ + int m_Type; /* Type ( Line, rect , circulaire , ovale .. ); -1 = not used (free) descr */ + int m_NumDcode; /* code number ( >= 10 ); 0 = not in use */ + + D_CODE() + { + m_Pnext = m_Pback = NULL; + m_Type = -1; + m_NumDcode = 0; + } +} ; + + +#endif /* #define PLOTGERB_H */ diff --git a/pcbnew/plothpgl.cpp b/pcbnew/plothpgl.cpp new file mode 100644 index 0000000000..27e7385dc0 --- /dev/null +++ b/pcbnew/plothpgl.cpp @@ -0,0 +1,869 @@ + /*******************************/ + /**** Routine de trace HPGL ****/ + /*******************************/ + +#include "fctsys.h" + +#include "common.h" +#include "plot_common.h" +#include "pcbnew.h" +#include "pcbplot.h" +#include "trigo.h" + +#include "protos.h" + + +/* Variables locales : */ +static int pen_rayon; /* Rayon de la plume en unites pcb */ +static int pen_diam; /* Diametre de la plume en unites pcb */ +static int pen_recouvrement; /* recouvrement en remplissage en unites pcb */ + +/* Routines Locales */ + +/*****************************************************************************/ +void WinEDA_BasePcbFrame::Genere_HPGL(const wxString & FullFileName, int Layer) +/*****************************************************************************/ +{ +int modetrace; +wxSize SheetSize; +wxSize BoardSize; +wxPoint BoardCenter; +double scale_x, scale_y; +int marge = 0 * U_PCB; // Extra margin (set to 0) +bool Center = FALSE; + + modetrace = Plot_Mode; + + /* Calcul des echelles de conversion */ + scale_x = Scale_X * SCALE_HPGL; + scale_y = Scale_Y * SCALE_HPGL; + + // calcul en unites internes des dimensions de la feuille ( connues en 1/1000 pouce ) + SheetSize.x = m_CurrentScreen->m_CurrentSheet->m_Size.x * U_PCB; + SheetSize.y = m_CurrentScreen->m_CurrentSheet->m_Size.y * U_PCB; + + g_PlotOffset.x = 0 ; + g_PlotOffset.y = (int)(SheetSize.y * scale_y) ; + + // Compute pen_dim (from g_HPGL_Pen_Diam in mils) in pcb units, + // with plot scale (if Scale is 2, pen diametre is always g_HPGL_Pen_Diam + // so apparent pen diam is real pen diam / Scale + pen_diam = (int) round((g_HPGL_Pen_Diam * 10.0) / Scale_X); // Assume Scale_X # Scale_Y + pen_rayon = pen_diam / 2; + + nb_plot_erreur = 0 ; + // compute pen_recouvrement (from g_HPGL_Pen_Recouvrement in mils) + // with plot scale + if(g_HPGL_Pen_Recouvrement < 0 ) g_HPGL_Pen_Recouvrement = 0 ; + if(g_HPGL_Pen_Recouvrement >= g_HPGL_Pen_Diam ) + g_HPGL_Pen_Recouvrement = g_HPGL_Pen_Diam - 1 ; + pen_recouvrement = (int) round(g_HPGL_Pen_Recouvrement * 10.0/Scale_X); + + dest = wxFopen(FullFileName, wxT("wt")); + if (dest == NULL) + { + wxString msg = _("Unable to create ") + FullFileName; + DisplayError(this, msg); + return ; + } + + Affiche_1_Parametre(this, 0,_("File"),FullFileName,CYAN) ; + + PrintHeaderHPGL(dest, g_HPGL_Pen_Speed,g_HPGL_Pen_Num); + + if ( Plot_Sheet_Ref && (g_PlotScaleOpt == 1) ) + { + int tmp = g_PlotOrient; g_PlotOrient = 0; + InitPlotParametresHPGL(g_PlotOffset, scale_x, scale_y, g_PlotOrient); + PlotWorkSheet( PLOT_FORMAT_HPGL, m_CurrentScreen); + g_PlotOrient = tmp; + } + + /* calcul des dimensions et centre du PCB */ + m_Pcb->ComputeBoundaryBox(); + BoardSize = m_Pcb->m_BoundaryBox.GetSize(); + BoardCenter = m_Pcb->m_BoundaryBox.Centre(); + + if( g_PlotScaleOpt == 0 ) // Optimum scale + { + float Xscale, Yscale; + Xscale = (float) (SheetSize.x - ( 2 * marge)) / BoardSize.x; + Yscale = (float) (SheetSize.y - ( 2 * marge)) / BoardSize.y; + scale_x = scale_y = min( Xscale, Yscale) * SCALE_HPGL; + } + + BoardCenter.x = (int)(BoardCenter.x * scale_x); + BoardCenter.y = (int)(BoardCenter.y * scale_y); + + if( g_PlotScaleOpt != 1 ) Center = TRUE; // Echelle != 1 + + /* Calcul du cadrage */ + marge = (int)(marge * SCALE_HPGL); + if ( Center ) + g_PlotOffset.x = (int)(- SheetSize.x/2 * SCALE_HPGL) + + BoardCenter.x + marge; + switch ( g_PlotOrient) + { + default : + if ( Center ) + { + g_PlotOffset.y = (int)(SheetSize.y/2 * SCALE_HPGL) + + BoardCenter.y + marge; + } + break ; + + case PLOT_MIROIR : + if ( Center ) + g_PlotOffset.y = (int)(- SheetSize.y/2 * SCALE_HPGL) + BoardCenter.y; + else g_PlotOffset.y = (int)((- SheetSize.y + + m_Pcb->m_BoundaryBox.GetBottom() + m_Pcb->m_BoundaryBox.GetY()) * SCALE_HPGL); + break ; + } + + InitPlotParametresHPGL(g_PlotOffset, scale_x, scale_y, g_PlotOrient); + switch( Layer ) + { + case CUIVRE_N : + case LAYER_N_2 : + case LAYER_N_3 : + case LAYER_N_4 : + case LAYER_N_5 : + case LAYER_N_6 : + case LAYER_N_7 : + case LAYER_N_8 : + case LAYER_N_9 : + case LAYER_N_10 : + case LAYER_N_11: + case LAYER_N_12: + case LAYER_N_13 : + case LAYER_N_14 : + case LAYER_N_15 : + case CMP_N : Plot_Layer_HPGL(dest,g_TabOneLayerMask[Layer], 0, 1, modetrace); + break; + + case SILKSCREEN_N_CU : + case SILKSCREEN_N_CMP : + Plot_Serigraphie(PLOT_FORMAT_HPGL,dest, g_TabOneLayerMask[Layer]); + break; + + case SOLDERMASK_N_CU : + case SOLDERMASK_N_CMP : /* Trace du vernis epargne */ + { + int tracevia; + if (g_DrawViaOnMaskLayer) tracevia = 1; + else tracevia = 0; + Plot_Layer_HPGL(dest,g_TabOneLayerMask[Layer], + g_DesignSettings.m_MaskMargin, tracevia, modetrace); + } + break; + + case SOLDERPASTE_N_CU : + case SOLDERPASTE_N_CMP : /* Trace du masque de pate de soudure */ + Plot_Layer_HPGL(dest,g_TabOneLayerMask[Layer], 0, 0, modetrace); + break; + + default : /* Trace des autres couches (dessin, adhesives,eco,comment) */ + Plot_Serigraphie(PLOT_FORMAT_HPGL,dest, g_TabOneLayerMask[Layer]); + break; + } + /* fin */ + CloseFileHPGL(dest) ; +} + + +/*********************************************************************/ +void WinEDA_BasePcbFrame::Plot_Layer_HPGL(FILE * File,int masque_layer, + int garde, int tracevia, int modetrace) +/*********************************************************************/ + +/* Trace en format HPGL. d'une couche cuivre ou masque + 1 unite HPGL = 0.98 mils ( 1 mil = 1.02041 unite HPGL ) . +*/ +{ +wxSize size; +wxPoint start, end; +MODULE * Module; +D_PAD * PtPad; +TRACK * pts ; +EDA_BaseStruct * PtStruct; +wxString msg; + + masque_layer |= EDGE_LAYER; /* Les elements de la couche EDGE sont tj traces */ + + /* trace des elements type Drawings Pcb : */ + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + PlotDrawSegment( (DRAWSEGMENT*) PtStruct, PLOT_FORMAT_HPGL, + masque_layer); + break; + + case TYPETEXTE: + PlotTextePcb((TEXTE_PCB*) PtStruct,PLOT_FORMAT_HPGL, + masque_layer); + break; + + case TYPECOTATION: + PlotCotation((COTATION*) PtStruct, PLOT_FORMAT_HPGL, + masque_layer); + break; + + case TYPEMIRE: + PlotMirePcb((MIREPCB*) PtStruct, PLOT_FORMAT_HPGL, + masque_layer); + break; + + case TYPEMARQUEUR: + break; + + default: + DisplayError(this, wxT("Type Draw non gere")); + break; + } + } + + + /* Trace des Elements des modules autres que pads */ + nb_items = 0 ; + Affiche_1_Parametre(this, 48, wxT("DrawMod"),wxEmptyString,GREEN) ; + Module = m_Pcb->m_Modules; + for( ; Module != NULL ;Module = (MODULE *)Module->Pnext ) + { + PtStruct = Module->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEEDGEMODULE: + if( masque_layer & + g_TabOneLayerMask[((EDGE_MODULE*)PtStruct)->m_Layer] ) + Plot_1_EdgeModule(PLOT_FORMAT_HPGL, (EDGE_MODULE*) PtStruct); + break; + + default: break; + } + } + } + + /* Trace des Elements des modules : Pastilles */ + nb_items = 0 ; + Affiche_1_Parametre(this, 48, wxT("Pads "), wxEmptyString,GREEN) ; + Module = m_Pcb->m_Modules; + for( ; Module != NULL ; Module = (MODULE*) Module->Pnext) + { + PtPad = (D_PAD*) Module->m_Pads; + for ( ; PtPad != NULL ;PtPad = (D_PAD*)PtPad->Pnext ) + { + wxPoint shape_pos; + if( (PtPad->m_Masque_Layer & masque_layer) == 0) + continue ; + + shape_pos = PtPad->ReturnShapePos(); + start = shape_pos; + size = PtPad->m_Size; + size.x += garde*2; size.y += garde*2; + + nb_items++ ; + switch (PtPad->m_PadShape & 0x7F) + { + case CIRCLE : + trace_1_pastille_RONDE_HPGL(start,size.x,modetrace) ; + break ; + + case OVALE : + { + trace_1_pastille_OVALE_HPGL(start,size, PtPad->m_Orient,modetrace) ; + break ; + } + + case TRAPEZE : + { + wxSize delta; + delta = PtPad->m_DeltaSize; + trace_1_pad_TRAPEZE_HPGL(start,size,delta, + PtPad->m_Orient, modetrace) ; + break ; + } + + case RECT : + default: + PlotRectangularPad_HPGL(start,size, + PtPad->m_Orient,modetrace) ; + break ; + } + msg.Printf( wxT("%d"),nb_items) ; + Affiche_1_Parametre(this, 48, wxT("Pads"), msg,GREEN) ; + } + } + + /* trace des VIAS : */ + if(tracevia) + { + TRACK * pts ; + + nb_items = 0 ; + Affiche_1_Parametre(this, 56, wxT("Vias"), wxEmptyString, RED) ; + + for(pts = m_Pcb->m_Track ;pts != NULL; pts = (TRACK*)pts->Pnext ) + { + if( pts->m_StructType != TYPEVIA ) continue; + SEGVIA * Via = (SEGVIA *) pts; + /* vias not plotted if not on selected layer, but if layer + == SOLDERMASK_LAYER_CU or SOLDERMASK_LAYER_CMP, vias are drawn , + if they are on a external copper layer + */ + int via_mask_layer = Via->ReturnMaskLayer(); + if ( (via_mask_layer & CUIVRE_LAYER ) ) via_mask_layer |= SOLDERMASK_LAYER_CU; + if ( (via_mask_layer & CMP_LAYER ) ) via_mask_layer |= SOLDERMASK_LAYER_CMP; + if( (via_mask_layer & masque_layer) == 0 ) continue; + + start = Via->m_Start; + size.x = Via->m_Width + (garde*2); + + trace_1_pastille_RONDE_HPGL(start, size.x, modetrace) ; + nb_items++ ; msg.Printf( wxT("%d"), nb_items) ; + Affiche_1_Parametre(this, 56, wxT("Vias"), msg,RED) ; + } + fputs("PU;\n",dest) ; + } + + /* trace des segments pistes */ + nb_items = 0 ; + Affiche_1_Parametre(this, 64, wxT("Tracks "),wxEmptyString,YELLOW) ; + for(pts = m_Pcb->m_Track ;pts != NULL; pts = (TRACK*)pts->Pnext ) + { + if ( pts->m_StructType == TYPEVIA ) continue ; + + if( (g_TabOneLayerMask[pts->m_Layer] & masque_layer) == 0 ) continue; + + size.x = size.y = pts->m_Width; + start = pts->m_Start; + end = pts->m_End; + + if ( size.x > pen_diam )/* c.a.d si largeur piste > diam plume */ + trace_1_pastille_RONDE_HPGL(start, size.x, modetrace) ; + + /* Trace d'un segment de piste */ + trace_1_segment_HPGL(start.x,start.y,end.x,end.y,size.x) ; + /* Complement de Trace en mode Remplissage */ + if( (Plot_Mode == FILLED) && (pen_diam <= size.x ) ) + { + while( (size.x -= (int)((pen_rayon - pen_recouvrement)*2) ) > 0 ) + { + trace_1_segment_HPGL(start.x,start.y,end.x,end.y, + max(size.x,pen_diam) ) ; + } + } + + if ( size.x > pen_diam) + trace_1_pastille_RONDE_HPGL(end, size.x, modetrace) ; + + nb_items++ ; msg.Printf( wxT("%d"),nb_items) ; + Affiche_1_Parametre(this, 64,wxEmptyString, msg,YELLOW) ; + } + + /* trace des segments pistes et zones */ + nb_items = 0 ; + Affiche_1_Parametre(this, 64, wxT("Zones "), wxEmptyString,YELLOW) ; + for(pts = m_Pcb->m_Zone ;pts != NULL; pts = (TRACK*)pts->Pnext ) + { + if( g_TabOneLayerMask[pts->m_Layer] & masque_layer) + { + size.x = size.y = pts->m_Width; + start = pts->m_Start; + end = pts->m_End; + + if ( size.x > pen_diam )/* c.a.d si largeur piste > diam plume */ + trace_1_pastille_RONDE_HPGL(start, size.x,modetrace) ; + + /* Trace d'un segment de piste */ + trace_1_segment_HPGL(start.x,start.y,end.x,end.y,size.x) ; + /* Complement de Trace en mode Remplissage */ + if( (Plot_Mode == FILLED) && (pen_diam <= size.x ) ) + { + while( (size.x -= (int)((pen_rayon - pen_recouvrement)*2) ) > 0 ) + { + trace_1_segment_HPGL(start.x,start.y,end.x,end.y, + max(size.x,pen_diam)) ; + } + } + + if ( size.x > pen_diam) + trace_1_pastille_RONDE_HPGL(end, size.x, modetrace) ; + + nb_items++ ; msg.Printf( wxT("%d"),nb_items) ; + Affiche_1_Parametre(this, 64,wxEmptyString, msg,YELLOW) ; + } + } +} + + +/************************************************************************************/ +void trace_1_pastille_OVALE_HPGL(wxPoint pos, wxSize size, int orient, int modetrace) +/************************************************************************************/ +/* Trace 1 pastille OVALE en position pos_X,Y , de dim size.x, size.y */ +{ +int rayon, deltaxy , cx, cy; +int trace_orient = orient; + + /* la pastille est ramenee a une pastille ovale avec size.y > size.x + ( ovale vertical en orientation 0 ) */ + if(size.x > size.y ) + { + EXCHG(size.x,size.y); trace_orient += 900; + if ( orient >= 3600 ) trace_orient -= 3600; + } + deltaxy = size.y - size.x; /* = distance entre centres de l'ovale */ + rayon = size.x / 2; + + if ( modetrace == FILLED ) + { + PlotRectangularPad_HPGL(pos, wxSize(size.x,deltaxy), + orient,modetrace) ; + cx = 0; cy = deltaxy/2; + RotatePoint(&cx, &cy, trace_orient); + trace_1_pastille_RONDE_HPGL(wxPoint(cx + pos.x, cy + pos.y), size.x, modetrace) ; + Plume_HPGL('U') ; + cx = 0; cy = -deltaxy/2; + RotatePoint(&cx, &cy, trace_orient); + trace_1_pastille_RONDE_HPGL(wxPoint(cx + pos.x, cy + pos.y), size.x, modetrace) ; + } + + else /* Trace en mode FILAIRE */ + { + cx = -rayon; cy = -deltaxy / 2; + RotatePoint(&cx, &cy, trace_orient); + Move_Plume_HPGL( wxPoint(cx + pos.x, cy + pos.y), 'U'); + cx = -rayon; cy = deltaxy / 2; + RotatePoint(&cx, &cy, trace_orient); + Move_Plume_HPGL( wxPoint(cx + pos.x, cy + pos.y), 'D'); + + cx = rayon; cy = - deltaxy / 2; + RotatePoint(&cx, &cy, trace_orient); + Move_Plume_HPGL( wxPoint(cx + pos.x, cy + pos.y), 'U'); + cx = rayon; cy = deltaxy / 2; + RotatePoint(&cx, &cy, trace_orient); + Move_Plume_HPGL( wxPoint(cx + pos.x, cy + pos.y), 'D'); + Plume_HPGL('U'); + + cx = 0; cy = - deltaxy / 2; + RotatePoint(&cx, &cy, trace_orient); + PlotArc(PLOT_FORMAT_HPGL, wxPoint(cx + pos.x, cy + pos.y), + trace_orient, trace_orient + 1800, + size.x / 2, pen_diam); + cx = 0; cy = deltaxy / 2; + RotatePoint(&cx, &cy, trace_orient); + PlotArc(PLOT_FORMAT_HPGL, wxPoint(cx + pos.x, cy + pos.y), + trace_orient + 1800, trace_orient, + size.x / 2, pen_diam); + } + + Plume_HPGL('U') ; +} + + +/**************************************************************************/ +void trace_1_pastille_RONDE_HPGL(wxPoint pos, int diametre, int modetrace) +/**************************************************************************/ +/* Trace 1 pastille RONDE (via,pad rond) en position pos */ +{ +int rayon, delta; + + UserToDeviceCoordinate(pos); + + delta = pen_diam - pen_recouvrement; + rayon = diametre / 2 ; + if(modetrace != FILAIRE) + { + rayon = (diametre - pen_diam ) /2 ; + } + + if(rayon < 0 ) + { + rayon = 0 ; nb_plot_erreur++ ; Affiche_erreur(nb_plot_erreur) ; + } + wxSize rsize(rayon, rayon); + UserToDeviceSize( rsize ); + + Plume_HPGL('U'); + sprintf(cbuf,"PA %d,%d;CI %d;\n", pos.x, pos.y, rsize.x); + fputs(cbuf,dest) ; + if(modetrace == FILLED ) /* Trace en mode Remplissage */ + { + if(delta > 0 ) + { + while ( (rayon -= delta ) >= 0 ) + { + rsize.x = rsize.y = rayon; + UserToDeviceSize( rsize ); + sprintf(cbuf,"PA %d,%d; CI %d;\n", pos.x, pos.y, rsize.x); + fputs(cbuf,dest) ; + } + } + } + Plume_HPGL('U'); return ; +} + +/***************************************************************/ +void PlotRectangularPad_HPGL(wxPoint padpos, wxSize padsize, + int orient,int modetrace) +/****************************************************************/ +/* + Trace 1 pad rectangulaire vertical ou horizontal ( Pad rectangulaire ) + donne par son centre et ses dimensions X et Y + Units are user units +*/ +{ +wxSize size; +int delta; +int ox, oy, fx, fy; + + size.x = padsize.x / 2; size.y = padsize.y / 2 ; + if(modetrace != FILAIRE) + { + size.x = (padsize.x - (int)pen_diam) / 2 ; + size.y = (padsize.y - (int)pen_diam) / 2 ; + } + + if ( (size.x < 0 ) || (size.y < 0) ) + { + nb_plot_erreur++ ; Affiche_erreur(nb_plot_erreur) ; + } + if ( size.x < 0 ) size.x = 0 ; if ( size.y < 0 ) size.y = 0 ; + + /* Si une des dimensions est nulle, le trace se reduit a 1 trait */ + if(size.x == 0 ) + { + ox = padpos.x; oy = padpos.y-size.y; + RotatePoint(&ox,&oy,padpos.x,padpos.y,orient); + fx = padpos.x; fy = padpos.y+size.y; + RotatePoint(&fx,&fy,padpos.x,padpos.y,orient); + Move_Plume_HPGL( wxPoint(ox, oy), 'U'); + Move_Plume_HPGL( wxPoint(fx, fy), 'D'); + Plume_HPGL('U'); return ; + } + if(size.y == 0 ) + { + ox = padpos.x - size.x; oy = padpos.y; + RotatePoint(&ox,&oy,padpos.x,padpos.y,orient); + fx = padpos.x + size.x; fy = padpos.y; + RotatePoint(&fx,&fy,padpos.x,padpos.y,orient); + Move_Plume_HPGL( wxPoint(ox, oy), 'U'); + Move_Plume_HPGL( wxPoint(fx, fy), 'D'); + Plume_HPGL('U') ; return ; + } + + ox = padpos.x - size.x; oy = padpos.y - size.y; + RotatePoint(&ox,&oy,padpos.x,padpos.y,orient); + Move_Plume_HPGL( wxPoint(ox, oy), 'U'); + + fx = padpos.x - size.x; fy = padpos.y + size.y; + RotatePoint(&fx,&fy,padpos.x,padpos.y,orient); + Move_Plume_HPGL( wxPoint(fx, fy), 'D'); + + fx = padpos.x + size.x; fy = padpos.y + size.y; + RotatePoint(&fx,&fy,padpos.x,padpos.y,orient); + Move_Plume_HPGL( wxPoint(fx, fy), 'D'); + + fx = padpos.x + size.x; fy = padpos.y - size.y; + RotatePoint(&fx,&fy,padpos.x,padpos.y,orient); + Move_Plume_HPGL( wxPoint(fx, fy), 'D'); + + Move_Plume_HPGL( wxPoint(ox, oy), 'D'); + + if(modetrace != FILLED ) + { + Plume_HPGL('U'); return ; + } + + /* Trace en mode Remplissage */ + delta = (int)(pen_diam - pen_recouvrement) ; + if(delta > 0 ) + while( (size.x > 0) && (size.y > 0) ) + { + size.x -= delta; size.y -= delta ; + if ( size.x < 0 ) size.x = 0 ; if ( size.y < 0 ) size.y = 0 ; + + ox = padpos.x - size.x; oy = padpos.y - size.y; + RotatePoint(&ox,&oy,padpos.x,padpos.y,orient); + Move_Plume_HPGL( wxPoint(ox, oy), 'D'); + + fx = padpos.x - size.x; fy = padpos.y + size.y; + RotatePoint(&fx,&fy,padpos.x,padpos.y,orient); + Move_Plume_HPGL( wxPoint(fx, fy), 'D'); + + fx = padpos.x + size.x; fy = padpos.y + size.y; + RotatePoint(&fx,&fy,padpos.x,padpos.y,orient); + Move_Plume_HPGL( wxPoint(fx, fy), 'D'); + + fx = padpos.x + size.x; fy = padpos.y - size.y; + RotatePoint(&fx,&fy,padpos.x,padpos.y,orient); + Move_Plume_HPGL( wxPoint(fx, fy), 'D'); + + Move_Plume_HPGL( wxPoint(ox, oy), 'D'); + } + Plume_HPGL('U'); +} + + +/********************************************************************/ +void trace_1_pad_TRAPEZE_HPGL(wxPoint padpos, wxSize size,wxSize delta, + int orient,int modetrace) +/********************************************************************/ +/* + Trace 1 pad trapezoidal donne par : + son centre padpos.x,padpos.y + ses dimensions dimX et dimY + les variations deltaX et deltaY + son orientation orient et 0.1 degres + le mode de trace (FILLED, SKETCH, FILAIRE) + Le trace n'est fait que pour un trapeze, c.a.d que deltaX ou deltaY + = 0. + + les notation des sommets sont ( vis a vis de la table tracante ) + 0 ------------- 3 + . . + . . + . . + 1 --- 2 +*/ +{ +int ii , jj; +wxPoint polygone[4]; /* coord des sommets / centre du pad */ +wxPoint coord[4]; /* coord reelles des sommets du trapeze a tracer */ +float fangle; /* angle d'inclinaison des cotes du trapeze */ +int rayon; /* rayon de la plume */ +int moveX, moveY; /* variation de position plume selon axe X et Y , lors + du remplissage du trapeze */ + + rayon = (int) pen_rayon; if (modetrace == FILAIRE) rayon = 0; + moveX = moveY = rayon; + + size.x /= 2; size.y /= 2; + delta.x /= 2; delta.y /= 2; + + polygone[0].x = - size.x - delta.y; polygone[0].y = + size.y + delta.x; + polygone[1].x = - size.x + delta.y; polygone[1].y = - size.y - delta.x; + polygone[2].x = + size.x - delta.y; polygone[2].y = - size.y + delta.x; + polygone[3].x = + size.x + delta.y; polygone[3].y = + size.y - delta.x; + + /* Calcul du demi angle d'inclinaison des cotes du trapeze */ + if( delta.y ) /* Trapeze horizontal */ + { + fangle = atan2( (float)(polygone[1].y - polygone[0].y), + (float)(polygone[1].x - polygone[0].x) ) / 2 ; + } + + else + { + fangle = atan2( (float)(polygone[3].y - polygone[0].y), + (float)(polygone[3].x - polygone[0].x) ) / 2 ; + } + + /* Trace du contour */ + polygone[0].x += moveX; polygone[0].y -= moveY; + polygone[1].x += moveX; polygone[1].y += moveY; + polygone[2].x -= moveX; polygone[2].y += moveY; + polygone[3].x -= moveX; polygone[3].y -= moveY; + + for (ii = 0; ii < 4; ii++) + { + coord[ii].x = polygone[ii].x + padpos.x; + coord[ii].y = polygone[ii].y + padpos.y; + RotatePoint(&coord[ii], padpos, orient); + } + + // Plot edge: + Move_Plume_HPGL( coord[0], 'U'); + Move_Plume_HPGL( coord[1], 'D'); + Move_Plume_HPGL( coord[2], 'D'); + Move_Plume_HPGL( coord[3], 'D'); + Move_Plume_HPGL( coord[0], 'D'); + + if(modetrace != FILLED ) + { + Plume_HPGL('U'); return; + } + + /* Fill the shape */ + + moveX = moveY = pen_diam - pen_recouvrement; + /* calcul de jj = hauteur du remplissage */ + if( delta.y ) /* Trapeze horizontal */ + { + jj = size.y - (int)( pen_diam + (2 * pen_recouvrement) ); + } + else + { + jj = size.x - (int)( pen_diam + (2 * pen_recouvrement) ); + } + + /* Calcul de jj = nombre de segments a tracer pour le remplissage */ + jj = jj / (int)(pen_diam - pen_recouvrement); + + + /* Trace du contour */ + for( ; jj > 0 ; jj-- ) + { + polygone[0].x += moveX; polygone[0].y -= moveY; + polygone[1].x += moveX; polygone[1].y += moveY; + polygone[2].x -= moveX; polygone[2].y += moveY; + polygone[3].x -= moveX; polygone[3].y -= moveY; + + /* Test de limitation de variation des dimensions : + si les sommets se "croisent", il ne faut plus modifier les + coordonnees correspondantes */ + if( polygone[0].x > polygone[3].x ) + { /* croisement sur axe X des 2 sommets 0 et 3 */ + polygone[0].x = polygone[3].x = 0; + } + if( polygone[1].x > polygone[2].x ) + { /* croisement sur axe X des 2 sommets 1 et 2 */ + polygone[1].x = polygone[2].x = 0; + } + if( polygone[1].y > polygone[0].y ) + { /* croisement sur axe Y des 2 sommets 0 et 1 */ + polygone[0].y = polygone[1].y = 0; + } + if( polygone[2].y > polygone[3].y ) + { /* croisement sur axe Y des 2 sommets 2 et 3 */ + polygone[2].y = polygone[3].y = 0; + } + + for (ii = 0; ii < 4; ii++) + { + coord[ii].x = polygone[ii].x + padpos.x; + coord[ii].y = polygone[ii].y + padpos.y; + RotatePoint(&coord[ii], padpos, orient); + } + + Move_Plume_HPGL( coord[0], 'U'); + Move_Plume_HPGL( coord[1], 'D'); + Move_Plume_HPGL( coord[2], 'D'); + Move_Plume_HPGL( coord[3], 'D'); + Move_Plume_HPGL( coord[0], 'D'); + } + + Plume_HPGL('U'); +} + + +/********************************************************************/ +void trace_1_segment_HPGL(int pos_X0,int pos_Y0,int pos_X1,int pos_Y1, + int epaisseur) +/********************************************************************/ + +/* Trace 1 rectangle donne par son axe et son epaisseur (piste rectangulaire) + en mode SKETCH + */ +{ +float alpha ; /* angle de l'axe du rectangle */ +wxSize size; /* coord relatives a l'origine du segment de sa fin */ +int dh ; /* demi epaisseur du segment compte tenu de la + largeur de la plume */ +int dx_rot; /* coord du segment en repere modifie ( size.y_rot etant nul )*/ +float sin_alpha, cos_alpha ; + + size.x = pos_X1 - pos_X0; size.y = pos_Y1 - pos_Y0 ; + dh = (epaisseur - (int)pen_diam ) / 2 ; + if ( dh < 0 ) + { + dh = 0 ; nb_plot_erreur++ ; Affiche_erreur(nb_plot_erreur) ; + } + + if ( (dh == 0) || (Plot_Mode == FILAIRE) ) /* Le trace se reduit a 1 trait */ + { + Move_Plume_HPGL( wxPoint(pos_X0 , pos_Y0) , 'U'); + Move_Plume_HPGL( wxPoint(pos_X1 , pos_Y1) , 'D'); + Plume_HPGL('U'); + return ; + } + + if( size.x < 0 ) + { + EXCHG( pos_X0, pos_X1 ) ; EXCHG( pos_Y0, pos_Y1 ); + size.y = - size.y ;size.x = - size.x ; + } + + if ( size.y == 0 ) /* segment horizontal */ + { + Move_Plume_HPGL( wxPoint(pos_X0 , pos_Y0 - dh) , 'U'); + Move_Plume_HPGL( wxPoint(pos_X1 , pos_Y1 - dh) , 'D'); + Move_Plume_HPGL( wxPoint(pos_X1 , pos_Y1 + dh) , 'D'); + Move_Plume_HPGL( wxPoint(pos_X0 , pos_Y0 + dh) , 'D'); + Move_Plume_HPGL( wxPoint(pos_X0 , pos_Y0 - dh) , 'D'); + } + else if ( size.x == 0 ) /* vertical */ + { + if( size.y < 0 ) dh = -dh ; + Move_Plume_HPGL( wxPoint(pos_X0 - dh , pos_Y0) , 'U'); + Move_Plume_HPGL( wxPoint(pos_X1 - dh , pos_Y1) , 'D'); + Move_Plume_HPGL( wxPoint(pos_X1 + dh , pos_Y1) , 'D'); + Move_Plume_HPGL( wxPoint(pos_X0 + dh , pos_Y0) , 'D'); + Move_Plume_HPGL( wxPoint(pos_X0 - dh , pos_Y0) , 'D'); + } + else /* piste inclinee */ + { + /* On calcule les coord des extremites du rectangle dans le repere + a axe x confondu avec l'axe du rect. puis on revient dans le repere + de trace par 2 rotations inverses + coord : xrot = x*cos + y*sin + yrot = y*cos - x*sin + + avec ici yrot = 0 puisque le segment est horizontal dans le nouveau repere + Transformee inverse : + coord : x = xrot*cos - yrot*sin + y = yrot*cos + xrot*sin + */ + + int dx0,dy0, dx1,dy1; + + if( size.x == size.y ) /* alpah = 45 degre */ + { + sin_alpha = cos_alpha = 0.70711 ; + } + else if( size.x == -size.y ) /* alpah = -45 degre */ + { + cos_alpha = 0.70711 ; sin_alpha = -0.70711 ; + } + else + { + alpha = atan2((float)size.y,(float)size.x) ; + sin_alpha = sin(alpha) ; + cos_alpha = cos(alpha) ; + } + + dx_rot = (int)(size.x * cos_alpha + size.y * sin_alpha) ; + /* size.y_rot = (int)(size.y * cos_alpha - size.x * sin_alpha) ; doit etre NULL */ + + /* calcul du point de coord 0,-dh */ + dx0 =(int) ( dh * sin_alpha) ; + dy0 =(int) (- dh*cos_alpha ) ; + Move_Plume_HPGL( wxPoint(pos_X0 + dx0 , pos_Y0 + dy0) , 'U'); + + /* calcul du point de coord size.xrot,-dh */ + dx1 =(int) (dx_rot*cos_alpha + dh * sin_alpha) ; + dy1 =(int) (-dh*cos_alpha + dx_rot*sin_alpha ) ; + Move_Plume_HPGL( wxPoint(pos_X0 + dx1 , pos_Y0 + dy1) , 'D'); + + /* calcul du point de coord size.xrot,+dh */ + dx1 =(int) (dx_rot*cos_alpha - dh * sin_alpha) ; + dy1 =(int) (dh*cos_alpha + dx_rot*sin_alpha ) ; + Move_Plume_HPGL( wxPoint(pos_X0 + dx1 , pos_Y0 + dy1) , 'D'); + + /* calcul du point de coord 0,+dh */ + dx1 =(int) ( - dh * sin_alpha) ; + dy1 =(int) (dh*cos_alpha ) ; + Move_Plume_HPGL( wxPoint(pos_X0 + dx1 , pos_Y0 + dy1) , 'D'); + + /* retour au point de depart */ + Move_Plume_HPGL( wxPoint(pos_X0 + dx0 , pos_Y0 + dy0) , 'D'); + } + Plume_HPGL('U'); +} + + + diff --git a/pcbnew/plotps.cpp b/pcbnew/plotps.cpp new file mode 100644 index 0000000000..76e9000435 --- /dev/null +++ b/pcbnew/plotps.cpp @@ -0,0 +1,710 @@ + /*************************************/ + /**** Pcbnew: Routine de trace PS ****/ + /*************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "plot_common.h" +#include "pcbnew.h" +#include "pcbplot.h" +#include "trigo.h" + +#include "protos.h" + +/* Routines Locales */ +static void PrintDrillMark(BOARD * Pcb); +static Ki_PageDescr * SheetPS; + +/* variables locales: */ + +#define DRILL_MARK 1 + +/****************************************************************************/ +void WinEDA_BasePcbFrame::Genere_PS(const wxString & FullFileName, int Layer) +/****************************************************************************/ +/* Genere un fichier POSTSCRIPT (*.ps) de trace du circuit, couche layer + if layer < 0: all layers +*/ +{ +int modetrace, tracevia; +wxSize PcbSheetSize; +wxSize PaperSize; +wxSize BoardSize; +wxPoint BoardCenter; +bool Center = FALSE; +Ki_PageDescr * currentsheet = m_CurrentScreen->m_CurrentSheet; +double scale_format; // Facteur correctif pour conversion forlat Ax->A4 +double scale_x, scale_y; +int PlotMarge_in_mils = 0; + + MsgPanel->EraseMsgBox(); + + dest = wxFopen(FullFileName, wxT("wt") ); + if (dest == NULL) + { + wxString msg = _("Unable to create file ") + FullFileName; + DisplayError(this, msg); return ; + } + + Affiche_1_Parametre(this, 0,_("File"),FullFileName,CYAN) ; + + if( g_PlotScaleOpt != 1 ) Center = TRUE; // Echelle != 1 donc trace centree du PCB + modetrace = Plot_Mode; + scale_format = 1.0; + /* Set default line width */ + if( g_PlotLine_Width < 1 ) g_PlotLine_Width = 1; + // calcul en unites internes des dimensions des feuilles ( connues en 1/1000 pouce ) + PcbSheetSize.x = currentsheet->m_Size.x * U_PCB; + PcbSheetSize.y = currentsheet->m_Size.y * U_PCB; + if ( g_ForcePlotPS_On_A4 ) + { + SheetPS = &g_Sheet_A4; + PaperSize.x = g_Sheet_A4.m_Size.x * U_PCB; + PaperSize.y = g_Sheet_A4.m_Size.y * U_PCB; + scale_format = (float) PaperSize.x / PcbSheetSize.x; + } + else + { + SheetPS = currentsheet; + PaperSize = PcbSheetSize; + } + + // calcul de l'offset de trace: + // calcul du cadrage horizontal du mode paysage( val algebr. plus grande = decalage a gauche ) + g_PlotOffset.x = PlotMarge_in_mils * 10; + // cadrage vertical du mode paysage( val algebr. plus grande = decalage vers le haut ) + g_PlotOffset.y = PaperSize.y - (PlotMarge_in_mils*10); + + int BBox[4]; + BBox[0] = BBox[1] = PlotMarge_in_mils; + BBox[2] = SheetPS->m_Size.x - PlotMarge_in_mils; + BBox[3] = SheetPS->m_Size.y - PlotMarge_in_mils; + scale_x = scale_y = 1.0; + InitPlotParametresPS( g_PlotOffset, SheetPS, 1.0/m_InternalUnits, 1.0/m_InternalUnits); + SetDefaultLineWidthPS(g_PlotLine_Width); + PrintHeaderPS(dest, wxT("PCBNEW-PS"), FullFileName, BBox); + + if ( Plot_Sheet_Ref ) + { + int tmp = g_PlotOrient; g_PlotOrient = 0; + SetPlotScale( 1.0, 1.0); + PlotWorkSheet( PLOT_FORMAT_POST, m_CurrentScreen); + g_PlotOrient = tmp; + } + + /* calcul des dimensions et centre du PCB */ + m_Pcb->ComputeBoundaryBox(); + BoardSize = m_Pcb->m_BoundaryBox.GetSize(); + BoardCenter = m_Pcb->m_BoundaryBox.Centre(); + + scale_x = Scale_X; scale_y = Scale_Y; + if( g_PlotScaleOpt == 0 ) // Optimum scale + { + float Xscale, Yscale; + int noprint_size = 2 * PlotMarge_in_mils * U_PCB; + if ( Plot_Sheet_Ref ) noprint_size += 500 * U_PCB; + Xscale = (float) (PaperSize.x - noprint_size ) / BoardSize.x; + Yscale = (float) (PaperSize.y - noprint_size ) / BoardSize.y; + scale_x = scale_y = min( Xscale, Yscale); + } + + BoardCenter.x = (int) (BoardCenter.x * scale_x); + BoardCenter.y = (int) (BoardCenter.y * scale_y); + + /* Calcul du cadrage (echelle != 1 donc recadrage du trace) */ + if ( Center ) + { + g_PlotOffset.x -= PaperSize.x/2 - BoardCenter.x + (PlotMarge_in_mils*10); + g_PlotOffset.y = PaperSize.y/2 + BoardCenter.y; // cadrage horizontal du mode paysage + } + + if ( g_PlotOrient == PLOT_MIROIR ) + { + if ( Center ) g_PlotOffset.y = - PaperSize.y/2 + BoardCenter.y; + else g_PlotOffset.y = - PaperSize.y + + (m_Pcb->m_BoundaryBox.GetBottom() + m_Pcb->m_BoundaryBox.GetY()) + + (PlotMarge_in_mils*10) ; + } + + InitPlotParametresPS( g_PlotOffset, SheetPS, scale_x, scale_y, g_PlotOrient); + + // If plot a negative board: + // Draw a black rectangle (background for plot board in white ) + // and switch the current color to WHITE + if( g_Plot_PS_Negative) + { + int Rectangle[10]; // Put here the board corners + int margin = 500; // Add a 0.1 inch margin around the board + Rectangle[0] = m_Pcb->m_BoundaryBox.GetX() - margin; + Rectangle[1] = m_Pcb->m_BoundaryBox.GetY() - margin; + Rectangle[2] = m_Pcb->m_BoundaryBox.GetRight() + margin; + Rectangle[3] = Rectangle[1]; + Rectangle[4] = Rectangle[2]; + Rectangle[5] = m_Pcb->m_BoundaryBox.GetBottom() + margin; + Rectangle[6] = Rectangle[0]; + Rectangle[7] = Rectangle[5]; + Rectangle[8] = Rectangle[0]; + Rectangle[9] = Rectangle[1]; + SetColorMapPS(BLACK); + PlotPolyPS( 5, Rectangle, TRUE); + SetColorMapPS(WHITE); + } + + switch(Layer) + { + case -1: + Plot_Layer_PS(dest, g_TabOneLayerMask[Layer], 0, 1, modetrace); + break; + + case CUIVRE_N : + case LAYER_N_2 : + case LAYER_N_3 : + case LAYER_N_4 : + case LAYER_N_5 : + case LAYER_N_6 : + case LAYER_N_7 : + case LAYER_N_8 : + case LAYER_N_9 : + case LAYER_N_10 : + case LAYER_N_11: + case LAYER_N_12: + case LAYER_N_13 : + case LAYER_N_14 : + case LAYER_N_15 : + case CMP_N : + Plot_Layer_PS(dest, g_TabOneLayerMask[Layer], 0, 1, modetrace); + break; + + case SILKSCREEN_N_CU : + case SILKSCREEN_N_CMP : + Plot_Serigraphie(PLOT_FORMAT_POST, dest, g_TabOneLayerMask[Layer]); + break; + + case SOLDERMASK_N_CU : + case SOLDERMASK_N_CMP : /* Trace du vernis epargne */ + if (g_DrawViaOnMaskLayer) tracevia = 1; + else tracevia = 0; + Plot_Layer_PS(dest, g_TabOneLayerMask[Layer], g_DesignSettings.m_MaskMargin, + tracevia, modetrace); + break; + + case SOLDERPASTE_N_CU : + case SOLDERPASTE_N_CMP : /* Trace du masque de pate de soudure */ + Plot_Layer_PS(dest, g_TabOneLayerMask[Layer], 0, 0, modetrace); + break; + + default: + Plot_Serigraphie(PLOT_FORMAT_POST,dest, g_TabOneLayerMask[Layer]); + break; + } + /* fin */ + CloseFilePS(dest) ; +} + + +/********************************************************************/ +void WinEDA_BasePcbFrame::Plot_Layer_PS(FILE * File,int masque_layer, + int garde, int tracevia, int modetrace) +/********************************************************************/ +/* Trace en format POSTSCRIPT d'une couche cuivre ou masque */ +{ +wxPoint pos, end; +wxSize size; +MODULE * Module; +D_PAD * PtPad; +TRACK * pts ; +EDA_BaseStruct * PtStruct; +wxString msg; + + masque_layer |= EDGE_LAYER; /* Les elements de la couche EDGE sont tj traces */ + + /* trace des elements type Drawings Pcb : */ + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + PlotDrawSegment( (DRAWSEGMENT*) PtStruct, PLOT_FORMAT_POST, + masque_layer); + break; + + case TYPETEXTE: + PlotTextePcb((TEXTE_PCB*) PtStruct,PLOT_FORMAT_POST, + masque_layer); + break; + + case TYPECOTATION: + PlotCotation((COTATION*) PtStruct, PLOT_FORMAT_POST, + masque_layer); + break; + + case TYPEMIRE: + PlotMirePcb((MIREPCB*) PtStruct, PLOT_FORMAT_POST, + masque_layer); + break; + + case TYPEMARQUEUR: + break; + + default: + DisplayError(this, wxT("WinEDA_BasePcbFrame::Plot_Layer_PS() : Unexpected Draw Type")); + break; + } + } + + /* Trace des Elements des modules autres que pads */ + nb_items = 0 ; + Affiche_1_Parametre(this, 48,wxT("DrawMod"),wxEmptyString,GREEN) ; + Module = m_Pcb->m_Modules; + for( ; Module != NULL ;Module = (MODULE *)Module->Pnext ) + { + PtStruct = Module->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) + { + case TYPEEDGEMODULE: + if( masque_layer & + g_TabOneLayerMask[((EDGE_MODULE*)PtStruct)->m_Layer] ) + Plot_1_EdgeModule(PLOT_FORMAT_POST, (EDGE_MODULE*) PtStruct); + break; + + default: break; + } + } + } + + /* Trace des Elements des modules : Pastilles */ + nb_items = 0 ; + Affiche_1_Parametre(this,48,wxT("Pads "),wxEmptyString,GREEN) ; + Module = m_Pcb->m_Modules; + for( ; Module != NULL ;Module = (MODULE *)Module->Pnext ) + { + PtPad = (D_PAD*) Module->m_Pads; + for ( ; PtPad != NULL ; PtPad = (D_PAD*)PtPad->Pnext ) + { + if( (PtPad->m_Masque_Layer & masque_layer) == 0) + continue ; + wxPoint shape_pos = PtPad->ReturnShapePos(); + pos = shape_pos; + + size.x = PtPad->m_Size.x + (garde * 2) ; + size.y = PtPad->m_Size.y + (garde * 2) ; + + nb_items++ ; + + switch (PtPad->m_PadShape) + { + case CIRCLE : + trace_1_pastille_RONDE_POST(pos,size.x, modetrace) ; + break ; + + case OVALE : + { + trace_1_pastille_OVALE_POST(pos,size, PtPad->m_Orient, modetrace); + break ; + } + + case TRAPEZE : + { + wxSize delta; + delta = PtPad->m_DeltaSize; + trace_1_pad_TRAPEZE_POST(pos,size,delta, + PtPad->m_Orient, modetrace) ; + break ; + } + + case RECT: + default: + trace_1_pad_rectangulaire_POST(pos,size, PtPad->m_Orient, modetrace) ; + break ; + } + msg.Printf( wxT("%d"),nb_items) ; + Affiche_1_Parametre(this, 48, wxT("Pads"),msg,GREEN) ; + } + } + /* trace des VIAS : */ + if(tracevia) + { + nb_items = 0 ; + Affiche_1_Parametre(this, 56,_("Vias"),wxEmptyString,RED) ; + for( pts = m_Pcb->m_Track;pts != NULL; pts = pts->Next()) + { + if( pts->m_StructType != TYPEVIA ) continue; + SEGVIA * Via = (SEGVIA *) pts; + /* vias not plotted if not on selected layer, but if layer + == SOLDERMASK_LAYER_CU or SOLDERMASK_LAYER_CMP, vias are drawn , + if they are on a external copper layer + */ + int via_mask_layer = Via->ReturnMaskLayer(); + if ( (via_mask_layer & CUIVRE_LAYER ) ) via_mask_layer |= SOLDERMASK_LAYER_CU; + if ( (via_mask_layer & CMP_LAYER ) ) via_mask_layer |= SOLDERMASK_LAYER_CMP; + if( (via_mask_layer & masque_layer) == 0 ) continue; + + pos = Via->m_Start; + size.x = size.y = Via->m_Width + (garde*2); + trace_1_pastille_RONDE_POST(pos,size.x, modetrace) ; + nb_items++ ; msg.Printf( wxT("%d"),nb_items) ; + Affiche_1_Parametre(this, 56,wxEmptyString,msg,RED) ; + } + } + /* trace des pistes et zones: */ + nb_items = 0 ; + Affiche_1_Parametre(this, 64,_("Tracks"),wxEmptyString,YELLOW) ; + + for( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext) + { + if ( pts->m_StructType == TYPEVIA ) continue ; + + if( (g_TabOneLayerMask[pts->m_Layer] & masque_layer) == 0 ) continue; + size.x = size.y = pts->m_Width; + pos = pts->m_Start; end = pts->m_End; + + PlotFilledSegmentPS(pos,end, size.x); + + nb_items++ ; msg.Printf( wxT("%d"),nb_items) ; + Affiche_1_Parametre(this, 64,wxEmptyString,msg,YELLOW) ; + } + + nb_items = 0 ; + Affiche_1_Parametre(this, 64, wxT("Zones "),wxEmptyString,YELLOW) ; + + for( pts = m_Pcb->m_Zone; pts != NULL; pts = (TRACK*) pts->Pnext) + { + if( (g_TabOneLayerMask[pts->m_Layer] & masque_layer) == 0 ) continue; + size.x = size.y = pts->m_Width; + pos = pts->m_Start; end = pts->m_End; + PlotFilledSegmentPS(pos,end, size.x); + nb_items++ ; msg.Printf( wxT("%d"),nb_items) ; + Affiche_1_Parametre(this, 64,wxEmptyString,msg,YELLOW) ; + } + + /* Trace des trous de percage */ + if( modetrace == FILLED ) + { + PrintDrillMark(m_Pcb); + } +} + + +/*************************************/ +static void PrintDrillMark(BOARD * Pcb) +/*************************************/ +/* Draw a drill mark for pads and vias. + Must be called after all drawings, because it redraw the drill mark + on a pad or via +*/ +{ +#define SMALL_DRILL 150 +wxPoint pos; +wxSize diam; +MODULE * Module; +D_PAD * PtPad; +TRACK * pts ; + + if (g_DrillShapeOpt == 0 ) return; + + if ( g_Plot_PS_Negative ) fprintf(dest," 0 setgray\n"); + else fprintf(dest," 1 setgray\n"); + + diam.x = diam.y = (g_DrillShapeOpt == DRILL_MARK) ? SMALL_DRILL : + g_DesignSettings.m_ViaDrill; + + for( pts = Pcb->m_Track;pts != NULL; pts = (TRACK*)pts->Pnext) + { + if( pts->m_StructType != TYPEVIA ) continue; + pos = pts->m_Start; + if (g_DrillShapeOpt == DRILL_MARK) diam.x = diam.y = SMALL_DRILL; + else + { + if (pts->m_Drill < 0) + diam.x = diam.y = g_DesignSettings.m_ViaDrill; + else + diam.x = diam.y = pts->m_Drill; + } + trace_1_pastille_RONDE_POST(pos,diam.x, FILLED); + } + + Module = Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE *)Module->Pnext ) + { + PtPad = (D_PAD*) Module->m_Pads; + for ( ; PtPad != NULL ; PtPad = (D_PAD*)PtPad->Pnext ) + { + if( PtPad->m_Drill.x == 0 ) continue; + + /* calcul de la position des trous, selon echelle */ + pos = PtPad->m_Pos; + diam.x = diam.y = (g_DrillShapeOpt == DRILL_MARK) ? SMALL_DRILL : + PtPad->m_Drill.x; + trace_1_pastille_RONDE_POST(pos, diam.x, FILLED); + } + } + + fprintf(dest," 0 setgray\n"); +} + +/***********************************************************************************/ +void trace_1_pastille_OVALE_POST(wxPoint pos, wxSize size, int orient, int modetrace) +/************************************************************************************/ +/* Trace 1 pastille OVALE en position pos_X,Y: + dimensions dx,dy, + orientation orient + La forme est tracee comme un segment +*/ +{ +int x0, y0, x1, y1, delta; +int w, rayon; + + /* la pastille est ramenee a une pastille ovale avec dy > dx */ + if(size.x > size.y ) + { + EXCHG(size.x,size.y); orient += 900; + if ( orient >= 3600 ) orient -= 3600; + } + + delta = size.y - size.x; + x0 = 0; y0 = -delta / 2; + x1 = 0; y1 = delta / 2; + RotatePoint(&x0,&y0, orient); + RotatePoint(&x1,&y1, orient); + + if( modetrace == FILLED ) + { + PlotFilledSegmentPS(wxPoint(pos.x + x0, pos.y + y0), + wxPoint(pos.x + x1, pos.y + y1), size.x); + } + else + { + w = g_PlotLine_Width; + rayon = (size.x - w) / 2; + if(rayon < 1 ) rayon = 1 ; + if ( rayon < w ) w = rayon; + PlotArcPS( wxPoint(pos.x + x1,pos.y + y1), -orient, -orient + 1800, rayon, w); + PlotArcPS( wxPoint(pos.x + x0,pos.y + y0), -orient + 1800, -orient ,rayon, w); + + x0 = -rayon; y0 = -delta / 2; + x1 = -rayon; y1 = delta / 2; + RotatePoint(&x0, &y0, orient); + RotatePoint(&x1, &y1, orient); + PlotFilledSegmentPS( wxPoint(pos.x+x0, pos.y+y0) , + wxPoint(pos.x+x1, pos.y+y1), w); + + x0 = rayon; y0 = -delta / 2; + x1 = rayon; y1 = delta / 2; + RotatePoint(&x0, &y0, orient); + RotatePoint(&x1, &y1, orient); + PlotFilledSegmentPS( wxPoint(pos.x+x0, pos.y+y0), + wxPoint(pos.x+x1, pos.y+y1), w); + } +} + + +/*******************************************************************************/ +void trace_1_pastille_RONDE_POST(wxPoint centre, int diametre, int modetrace) +/*******************************************************************************/ +/* Trace 1 pastille RONDE (via,pad rond) en position pos_X,Y */ +{ +int rayon, w; +wxSize diam(diametre, diametre); + + UserToDeviceCoordinate(centre); + UserToDeviceSize(diam); + + if( modetrace == FILLED ) + { + fprintf(dest,"%d setlinewidth\n", g_PlotLine_Width); + rayon = (diam.x) / 2; + if(rayon < 1 ) rayon = 1 ; + fprintf(dest,"newpath %d %d %d 0 360 arc fill stroke\n", + centre.x, centre.y, rayon); + } + + else + { + w = g_PlotLine_Width; + rayon = (diam.x - w) / 2; + if(rayon < 1 ) rayon = 1 ; + if ( rayon < w ) w = rayon; + fprintf(dest,"%d setlinewidth\n", w); + fprintf(dest,"newpath %d %d %d 0 360 arc stroke\n", + centre.x, centre.y, rayon); + } +} + +/**************************************************************************/ +void trace_1_pad_rectangulaire_POST(wxPoint centre, + wxSize size, int orient, int modetrace) +/**************************************************************************/ +/* + Trace 1 pad rectangulaire d'orientation quelconque + donne par son centre, ses dimensions, + et son orientation orient +*/ +{ +int x0, y0, x1, y1, w; + + if( modetrace == FILLED ) + { + x0 = centre.x - size.x/2; x1 = centre.x + size.x/2; + y0 = y1 = centre.y; w = size.y; + + RotatePoint(&x0,&y0, centre.x, centre.y, orient); + RotatePoint(&x1,&y1, centre.x, centre.y, orient); + + fprintf(dest,"0 setlinewidth 0 setlinecap 0 setlinejoin\n"); + PlotFilledSegmentPS(wxPoint(x0, y0), wxPoint(x1, y1), w); + fprintf(dest,"%d setlinewidth 1 setlinecap 1 setlinejoin\n", g_PlotLine_Width); + } + + else { + w = g_PlotLine_Width; + size.x -= w; if ( size.x < 1 ) size.x = 1; + size.y -= w; if ( size.y < 1 ) size.y = 1; + trace_1_contour_POST(centre, size, wxSize(0, 0), w, orient); + } +} + + +/**************************************************************/ +void trace_1_contour_POST(wxPoint centre, wxSize size, wxSize delta, + int dim_trait, int orient) +/**************************************************************/ +/* + Trace 1 contour rectangulaire ou trapezoidal d'orientation quelconque + donne par son centre centre, + ses dimensions size, + ses variations delta + epaisseur de trait dim_trait + et son orientation orient (en 0.1 degres) +*/ +{ +int ii; +int dx, dy, lpen; +int ddx, ddy; +wxPoint coord[4]; + + lpen = dim_trait; + + dx = size.x / 2; dy = size.y / 2 ; + ddx = delta.x >> 1; ddy = delta.y >> 1 ; /* demi dim dx et dy */ + + coord[0].x = centre.x - dx - ddy; + coord[0].y = centre.y + dy + ddx; + + coord[1].x = centre.x - dx + ddy; + coord[1].y = centre.y - dy - ddx; + + coord[2].x = centre.x + dx - ddy; + coord[2].y = centre.y - dy + ddx; + + coord[3].x = centre.x + dx + ddy; + coord[3].y = centre.y + dy - ddx; + + for (ii = 0; ii < 4; ii++) + { + RotatePoint(&coord[ii], centre, orient); + } + + + PlotFilledSegmentPS( coord[0], coord[1], lpen); + PlotFilledSegmentPS( coord[1], coord[2], lpen); + PlotFilledSegmentPS( coord[2], coord[3], lpen); + PlotFilledSegmentPS( coord[3], coord[0], lpen); +} + + +/*******************************************************************/ +void trace_1_pad_TRAPEZE_POST(wxPoint centre, wxSize size, wxSize delta, + int orient,int modetrace) +/*******************************************************************/ +/* + Trace 1 pad trapezoidal donne par : + son centre centre + ses dimensions size + les variations delta ( 1 des deux au moins doit etre nulle) + son orientation orient en 0.1 degres + le mode de trace (FILLED, SKETCH, FILAIRE) + + Le trace n'est fait que pour un trapeze, c.a.d que deltaX ou deltaY + = 0. + + les notation des sommets sont ( vis a vis de la table tracante ) + +" 0 ------------- 3 " +" . . " +" . O . " +" . . " +" 1 ---- 2 " + + + exemple de Disposition pour deltaY > 0, deltaX = 0 +" 1 ---- 2 " +" . . " +" . O . " +" . . " +" 0 ------------- 3 " + + + exemple de Disposition pour deltaY = 0, deltaX > 0 +" 0 " +" . . " +" . . " +" . 3 " +" . . " +" . O . " +" . . " +" . 2 " +" . . " +" . . " +" 1 " +*/ +{ +int ii; +int dx,dy; +wxPoint polygone[4]; /* coord des sommets / centre du pad */ +int ddx, ddy ; +int l_pen; /* diam spot (plume) */ + + l_pen = 1; + if( (modetrace == FILAIRE) || ( Plot_Mode == FILAIRE ) ) + { + wxSize lsize(g_PlotLine_Width,g_PlotLine_Width); + UserToDeviceSize(lsize); + l_pen = lsize.x; + } + + dx = size.x / 2; dy = size.y / 2 ; + ddx = delta.x / 2; ddy = delta.y / 2 ; + + polygone[0].x = - dx - ddy; polygone[0].y = + dy + ddx; + polygone[1].x = - dx + ddy; polygone[1].y = - dy - ddx; + polygone[2].x = + dx - ddy; polygone[2].y = - dy + ddx; + polygone[3].x = + dx + ddy; polygone[3].y = + dy - ddx; + + for (ii = 0; ii < 4; ii++) + { + RotatePoint(&polygone[ii].x, &polygone[ii].y, orient); + polygone[ii].x += centre.x; polygone[ii].y += centre.y; + } + + fprintf(dest,"%d setlinewidth\n", l_pen) ; + + UserToDeviceCoordinate(polygone[0]); + fprintf(dest,"newpath %d %d moveto\n", polygone[0].x, polygone[0].y); + + for (ii = 1; ii < 4; ii++) + { + UserToDeviceCoordinate(polygone[ii]); + fprintf(dest,"%d %d lineto\n", polygone[ii].x, polygone[ii].y); + } + + fprintf(dest,"%d %d lineto ", polygone[0].x, polygone[0].y); + + if(modetrace == FILLED ) fprintf(dest, "fill ");; + fprintf(dest, "stroke\n");; +} + diff --git a/pcbnew/protos.h b/pcbnew/protos.h new file mode 100644 index 0000000000..4361029654 --- /dev/null +++ b/pcbnew/protos.h @@ -0,0 +1,458 @@ +/***************************************/ +/* prototypage des fonctions de PCBNEW */ +/***************************************/ + +#ifndef PROTO_H +#define PROTO_H + +/***************/ +/* CONNECT.CPP */ +/***************/ +LISTE_PAD* CreateSortedPadListByXCoord(BOARD * pcb); +/* Create a sorted list of pointers to pads. + This list is sorted by X ccordinate value. + The list must be freed bu user */ + +/**************/ +/* PCBCFG.CPP */ +/**************/ +bool Read_Config(const wxString & project_name); + +/*********************/ +/* CLASS_EQUIPOT.CPP */ +/*********************/ + +EQUIPOT * GetEquipot(BOARD * pcb, int netcode); + /* retourne un pointeur sur la structure EQUIPOT de numero netcode */ + + +/***************/ +/* TRACEPCB.CPP */ +/***************/ +void Trace_MirePcb(WinEDA_DrawPanel * panel, wxDC * DC, MIREPCB * MirePcb, int mode_color); + +/***************/ +/* TRPISTE.CPP */ +/***************/ + +void Trace_Pistes(WinEDA_DrawPanel * panel, BOARD * Pcb, wxDC * DC, int drawmode); +void Trace_Une_Piste(WinEDA_DrawPanel * panel, wxDC * DC, TRACK * pt_start_piste,int nbsegment, int mode_color); + /* routine de trace de n segments consecutifs en memoire. + Utile pour monter une piste en cours de trace car les segments de cette + piste sont alors contigus en memoire + Parametres : + pt_start_piste = adresse de depart de la liste des segments + nbsegment = nombre de segments a tracer + mode_color = mode ( GrXOR, GrOR..) + ATTENTION: + le point de depart d'une piste suivante DOIT exister: peut etre + donc mis a 0 avant appel a la routine si la piste a tracer est la derniere + */ + +void Trace_DrawSegmentPcb(WinEDA_DrawPanel * panel, wxDC * DC, DRAWSEGMENT * PtDrawSegment,int mode_color); + + +/****************/ +/* TRACEMOD.C : */ +/****************/ +void Trace_Pads_Only(WinEDA_DrawPanel * panel, wxDC * DC, MODULE * Module, int ox, int oy, + int MasqueLayer,int mode_color); + /* Trace les pads d'un module en mode SKETCH. + Utilisee pour afficher les pastilles d'un module lorsque celui ci n'est + pas affiche par les options d'affichage des Modules + Les pads affiches doivent apparaitre sur les couches donnees par + MasqueLayer */ + +void Affiche_1_Segment(WinEDA_DrawPanel * panel, wxDC * DC, int ux0, int uy0, int dx, int dy, + int width, int mode, int color); + +/****************/ +/* LOCATE.CPP : */ +/****************/ + +MODULE * ReturnModule(BOARD * Pcb, const wxString & name); + /* Recherche d'une empreinte par son nom */ + +D_PAD * ReturnPad(MODULE * Module, const wxString & name); + /* Recherche d'un pad par son nom, pour le module Module */ + +TRACK * Locate_Via(BOARD * Pcb, const wxPoint & pos, int layer); + +TRACK * Fast_Locate_Via(TRACK *start_adr, TRACK* end_adr, + const wxPoint & pos, int masquelayer); + /* Localise la via de centre le point x,y , sur les couches donnees + par masquelayer. + la recherche se fait de l'adresse start_adr a end_adr(non comprise) + */ + +TRACK* Fast_Locate_Piste(TRACK *start_adr, TRACK* end_adr, + const wxPoint & ref_pos, int masquelayer); + /* Localiste le segment dont une extremite coincide avec le point x,y + sur les couches donnees par masquelayer + la recherche se fait de l'adresse start_adr a end_adr(non comprise) + */ + +TRACK * Locate_Piste_Connectee( TRACK*ptr_piste, TRACK* pt_base, + TRACK* pt_lim,int extr); + /* recherche le segment connecte au segment pointe par + ptr_piste: + si int = START, le point de debut du segment est utilise + si int = END, le point de fin du segment est utilise + La recherche ne se fait que sur les EXTREMITES des segments + La recherche est limitee a la zone [pt_base...]pt_lim. + */ + +TRACK * Locate_Pistes(TRACK * start_adresse,int layer, int typeloc); +TRACK * Locate_Pistes(TRACK * start_adresse, + const wxPoint & ref_pos,int layer); + /* + 1 - routine de localisation du segment de piste pointe par la souris. + 2 - routine de localisation du segment de piste pointe par le point + ref_pX , ref_pY. + + Si layer < 0 la couche n'est pas testee. + + La recherche commence a l'adresse start_adresse + */ + +D_PAD * Locate_Pad_Connecte(BOARD * Pcb, TRACK * ptr_segment, int extr); + /* localisation de la pastille connectee au debut ou fin du segment + entree : pointeur sur le segment, et flag = START ou END + retourne: + un pointeur sur la description de la pastille si localisation + pointeur NULL si pastille non trouvee */ + +D_PAD * Locate_Any_Pad(BOARD * Pcb, int typeloc, bool OnlyCurrentLayer = FALSE); +D_PAD * Locate_Any_Pad(BOARD * Pcb, const wxPoint & ref_pos, bool OnlyCurrentLayer = FALSE); + /* + localisation de la pastille pointee par la coordonnee ref_pX,,ref_pY, ou + par la souris, recherche faite sur toutes les empreintes. + entree : (OVERHAEAD) + - coord souris (Curseur_X et Curseur_Y) + ou ref_pX, ref_pY + retourne: + pointeur sur la description de la pastille si localisation + pointeur NULL si pastille non trouvee + */ + +D_PAD * Locate_Pads(MODULE * Module, int layer, int typeloc) ; +D_PAD * Locate_Pads(MODULE * Module, const wxPoint & ref_pos,int layer) ; + /* localisation de la pastille pointee par la coordonnee ref_pX,,ref_pY, ou + par la souris, concernant l'empreinte en cours. + entree : + - parametres generaux de l'empreinte mise a jous par caract() + - layer = couche ou doit se trouver la pastille + (si layer < 0 ) la couche est ignoree) + retourne: + un pointeur sur la description de la pastille si localisation + pointeur NULL si pastille non trouvee + */ + +TEXTE_MODULE * LocateTexteModule(BOARD * Pcb, MODULE ** Module, int typeloc); + /* localisation du texte pointe par la souris (texte sur empreinte) + si Module == NULL; recherche sur tous les modules + sinon sur le module pointe par Module + retourne + - pointeur sur le texte localise ( ou NULL ) + - pointeur sur module Module ( non modifie sinon ) */ + + +MODULE * Locate_Prefered_Module(BOARD * Pcb, int typeloc); + /* localisation d'une empreinte par son rectangle d'encadrement */ + +D_PAD * Locate_Pads(MODULE * Module, int typeloc); + /* localisation de la pastille pointee par la souris, concernant l'empreinte + Module. + entree : + - parametres generaux de l'empreinte mise a jous par caract() + retourne: + un pointeur sur la description de la pastille si localisation + pointeur NULL si pastille non trouvee + */ + +EDGE_MODULE * Locate_Edge_Module(MODULE * Module, int typeloc); + /* Localisation de segments de contour du type edge MODULE + Les contours sont de differents type: + simple, Arcs de cercles, box. + Retourne: + Pointeur sur DEBUT du segment localise + NULL si rien trouve + */ + +TRACK * Locate_Pistes(TRACK * start_adresse, int typeloc); + /* routine de localisation du segment de piste pointe par la souris + La recherche commence a l'adresse start_adresse */ + +DRAWSEGMENT * Locate_Segment_Pcb(BOARD * Pcb, int typeloc) ; + +TEXTE_PCB * Locate_Texte_Pcb(EDA_BaseStruct * PtStruct, int typeloc); + /* localisation des inscriptions sur le Pcb: + la recherche se fait a partir de l'adresse pr_texte */ + + +D_PAD * Fast_Locate_Pad_Connecte(BOARD * Pcb, const wxPoint & ref_pos, int layer); + /* Routine cherchant le pad contenant le point px,py, sur la couche layer + ( extremite de piste ) + La liste des pads doit deja exister. + + retourne : + NULL si pas de pad localise. + pointeur sur le pad correspondante si pad trouve + (bonne position ET bonne couche). */ + + +int distance(int seuil); + /* + Calcul de la distance du curseur souris a un segment de droite : + ( piste, edge, contour module .. + retourne: + 0 si distance > seuil + 1 si distance <= seuil + Variables utilisees ( externes doivent etre initialisees avant appel , et + sont ramenees au repere centre sur l'origine du segment) + dx, dy = coord de l'extremite segment. + spot_cX,spot_cY = coord du curseur souris + la recherche se fait selon 4 cas: + segment horizontal + segment vertical + segment 45 + segment quelconque + */ + +TRACK * Locate_Zone(TRACK * start_adresse,int layer, int typeloc); +TRACK * Locate_Zone(TRACK * start_adresse, const wxPoint & ref_pos,int layer); + /* + 1 - routine de localisation du segment de zone pointe par la souris. + 2 - routine de localisation du segment de zone pointe par le point + ref_pX , ref_pY.r + + Si layer == -1 , le tst de la couche n'est pas fait + + La recherche commence a l'adresse start_adresse + */ + +EDA_BaseStruct * Locate_Cotation(BOARD * Pcb, int typeloc); + /* Localise un element de cotation, en priorite sur la couche active, + et a defaut sur les autres couches + retourne un pointeur sur l'element (TRACK ou TEXTE_PCB) localise + sinon retiurne NULL */ + + + /*************/ + /* MODULES.C */ + /*************/ +int ChangeSideNumLayer(int oldlayer); +void DrawModuleOutlines(WinEDA_DrawPanel * panel, wxDC * DC, MODULE * module); +void Montre_Position_Empreinte(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) ; + + +/* LOADCMP.C : */ +MODULE * Load_Module_From_Library(WinEDA_DrawFrame * frame, wxDC * DC); + +/****************/ +/* EDITRACK.C : */ +/****************/ + +void ShowNewTrackWhenMovingCursor(WinEDA_DrawPanel * panel, + wxDC * DC, bool erase); + +void Calcule_Coord_Extremite_45(int ox, int oy, int *fx, int * fy); + /* determine les coord fx et fy d'un segment + pour avoir un segment oriente a 0, 90 ou 45 degres, selon position + du point d'origine (ox,oy) et de la souris */ + +/*****************/ +/* TRACK.CPP : */ +/*****************/ +TRACK * Marque_Une_Piste(WinEDA_BasePcbFrame * frame, wxDC * DC, + TRACK* pt_segm, int * nb_segm, int flagcolor); + /* Routine de Marquage de 1 piste, a partir du segment pointe par pt_segm. + le segment pointe est marque puis les segments adjacents + jusqu'a un pad ou un point de jonction de plus de 2 segments + le marquage est la mise a 1 du bit BUSY du parametre .status + Les segments sont ensuite reclasses pour etre contigus en memoire + Retourne: + adresse du 1er segment de la chaine creee + nombre de segments */ + +int ReturnEndsTrack(TRACK* RefTrack, int NbSegm, + TRACK ** StartTrack, TRACK ** EndTrack); + /* Calcule les coordonnes des extremites d'une piste + retourne 1 si OK, 0 si piste bouclee + Les coord sont retournees en StartTrack->ox, oy + et EndTrack->fx, fy si OK + Les segments sont supposes chaines de facon consecutive */ + +void ListSetState(EDA_BaseStruct * Start, int Nbitem,int State, int onoff); + /* Met a jour le membre .state d'une chaine de structures */ + +/*****************/ +/* EDITEDGE.CPP : */ +/*****************/ +void Trace_1_Edge(WinEDA_DrawPanel * panel, wxDC * DC, TRACK * start_edge, int nbpoint, int mode_color); + +/************/ +/* DRC.CPP : */ +/************/ +int Drc(WinEDA_BasePcbFrame * frame, wxDC * DC, + TRACK * pt_segment, TRACK * pt_start_buffer, int show_err); + /* Teste le segment pointe par pt_segment: + debsegment = adresse du segment a tester + pt_start_buffer = adresse de la zone piste + show_err (flag) si 0 pas d'affichage d'erreur sur ecran + retourne : + BAD_DRC (1) si Violation DRC + OK_DRC (0) si OK */ + + +/*****************/ +/* TR_MODIF.CPP : */ +/*****************/ + +int EraseOldTrack(WinEDA_BasePcbFrame * frame, BOARD * Pcb, wxDC * DC, + TRACK * pt_new_track, int nbptnewpiste); +void Modif_Auto_Route(TRACK * pt_debut_new_piste) ; + + + /**************/ + /* CLEAN.CPP : */ + /**************/ + +int Netliste_Controle_piste(WinEDA_PcbFrame * frame, wxDC * DC, int affiche); + /* Supprime les segments mal connectes, cad interconnectant des segments + de net_code differents */ + + + /************/ + /* BLOCK.CPP */ + /************/ + +void Block_Affiche(int on_off); /* + routine de trace du cadre d'un Block en cours de delimitation + Si on_off = 0 : effacement du cadre + Si on_off = 1 : affichage du cadre */ + +void Trace_Block(WinEDA_DrawPanel * panel, wxDC * DC, int ox, int oy, int fx, int fy , int color ); + /* Routine de trace d'un rectangle symbolisant un block + (toujours en mode XOR) */ + + /***************/ + /* PLOT_RTN.CPP */ + /***************/ + +void Affiche_erreur(int nb_err) ; + + +/*****************************************************************/ +/* AFFICHE.CPP: (Fonctions d'affichage de messages, parametres... */ +/*****************************************************************/ +void Affiche_Infos_Segment_Module(WinEDA_BasePcbFrame * frame, MODULE* pt_module,EDGE_MODULE* pt_edge); + /* Affiche en bas d'ecran les caract du Segment contour d'un module */ + +void Affiche_Infos_Piste(WinEDA_BasePcbFrame * frame, TRACK* pt_piste) ; + /* Affiche les caract principales d'un segment de piste en bas d'ecran */ + +void Affiche_Infos_E_Texte(WinEDA_BasePcbFrame * frame, MODULE * adr_empreinte,TEXTE_MODULE *pt_texte) ; + /* Affiche en bas d'ecran les caract du texte sur empreinte */ +void Affiche_Infos_PCB_Texte(WinEDA_BasePcbFrame * frame, TEXTE_PCB* pt_texte); + /* Affiche en bas d'ecran les caract du texte type PCB */ + +void Affiche_Infos_Status_Pcb(WinEDA_BasePcbFrame * frame); /* Affiche l'etat du PCB: + nb de pads, nets , connexions.. */ + +void Affiche_Infos_DrawSegment(WinEDA_BasePcbFrame * frame, DRAWSEGMENT * DrawSegment); + /* Affiche les caract principales d'un segment type + drawing PCB en bas d'ecran */ +void Affiche_Infos_Equipot(int netcode, WinEDA_BasePcbFrame * frame); + + /************/ + /* ZONES.CPP */ + /************/ +int Propagation(WinEDA_PcbFrame * frame); + + /***************/ + /* ATTRIBUT.CPP */ + /***************/ + +void MasqueAttributs( int * masque_set, int * masque_clr); + /* Calcule les attributs a remettre a 0 (masque_clr) et a mettre a 1 + (masque_set), en fonction des options d'attributs + + ces attributs sont normalement le membre .flags de la structure TRACK + les pointeurs NULLs sont acceptes + */ + + +/***************/ +/* DUPLTRAC.CPP */ +/***************/ + +EDA_BaseStruct * LocateLockPoint(BOARD * Pcb, wxPoint pos, int LayerMask); + /* Routine trouvant le point " d'accrochage " d'une extremite de piste. + Ce point peut etre un PAD ou un autre segment de piste + Retourne: + - pointeur sur ce PAD ou: + - pointeur sur le segment ou: + - NULL + Parametres d'appel: + coord pX, pY du point tst + masque des couches a tester */ + + +TRACK * CreateLockPoint(int *pX, int *pY, TRACK * ptsegm, TRACK * refsegm); + /* Routine de creation d'un point intermediaire sur un segment + le segment ptsegm est casse en 2 segments se raccordant au point pX, pY + retourne: + NULL si pas de nouveau point ( c.a.d si pX, pY correspondait deja + a une extremite ou: + pointeur sur le segment cree + si refsegm != NULL refsegm est pointeur sur le segment incident, + et le point cree est l'ntersection des 2 axes des segments ptsegm et + refsegm + retourne la valeur exacte de pX et pY +*/ + +/****************/ +/* CONTROLE.CPP */ +/****************/ +void RemoteCommand(char * cmdline); + +/*************/ +/* STRUCT.CPP */ +/*************/ +void DeleteStructure(EDA_BaseStruct * Struct); +void DeleteStructList( EDA_BaseStruct * Struct); + + +/***************/ +/* AUTOPLACE.CPP */ +/***************/ +int Calcule_Encadrement_EdgeBoard(void); + +/***************/ +/* AUTOROUT.CPP */ +/***************/ +void DisplayBoard(WinEDA_DrawPanel * panel, wxDC * DC); /* routine de Debug */ + + +/**************/ +/* NETLIST.CPP */ +/**************/ +MODULE * ListAndSelectModuleName(COMMAND * Cmd); + /* liste les noms des modules du PCB + Retourne un pointeur sur le module selectionne + ( ou NULL si pas de selection ) */ + +/***************/ +/* LAY2PLOT.CPP */ +/***************/ +int GetLayerNumber(void); /* retourne le nombre de couches a tracer */ + +/*****************/ +/* SEL_COLOR.CPP */ +/*****************/ +void DisplayColorSetupFrame(WinEDA_DrawFrame * parent, + const wxPoint & framepos); + + +#endif /* #define PROTO_H */ diff --git a/pcbnew/queue.cpp b/pcbnew/queue.cpp new file mode 100644 index 0000000000..db4aeba580 --- /dev/null +++ b/pcbnew/queue.cpp @@ -0,0 +1,180 @@ + /*******************************************/ + /* EDITEUR de PCB: routines d'AUTOROUTAGE: */ + /*******************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "protos.h" + +#include "cell.h" + +struct PcbQueue /* search queue structure */ +{ + struct PcbQueue *Next; + int Row; /* current row */ + int Col; /* current column */ + int Side; /* 0=top, 1=bottom */ + int Dist; /* path distance to this cell so far */ + int ApxDist; /* approximate distance to target from here */ +}; + +static long qlen = 0; /* current queue length */ +static struct PcbQueue *Head = NULL; +static struct PcbQueue *Tail = NULL; +static struct PcbQueue *Save = NULL; /* hold empty queue structs */ + +/* Routines definies ici : */ +void InitQueue( void ); +void GetQueue( int *, int *, int *, int *, int * ); +int SetQueue( int, int, int, int, int, int, int ); +void ReSetQueue( int, int, int, int, int, int, int ); + + +/************************/ +void FreeQueue(void) +/************************/ +/* Free the memory used for storing all the queue */ +{ +struct PcbQueue *p; + + InitQueue(); + while( (p = Save) != NULL ) + { + Save = p->Next; MyFree(p); + } +} + /************************/ + /* void InitQueue(void) */ + /************************/ + +/* initialize the search queue */ +void InitQueue(void) +{ +struct PcbQueue *p; + + while( (p = Head) != NULL ) + { + Head = p->Next; + p->Next = Save; Save = p; + } + Tail = NULL; + OpenNodes = ClosNodes = MoveNodes = MaxNodes = qlen = 0; +} + + + /*********************************************************/ + /* void GetQueue(int *r, int *c, int *s, int *d, int *a) */ + /*********************************************************/ + +/* get search queue item from list */ +void GetQueue(int *r, int *c, int *s, int *d, int *a) +{ +struct PcbQueue *p; + + if( (p = Head) != NULL ) /* return first item in list */ + { + *r = p->Row; *c = p->Col; + *s = p->Side; + *d = p->Dist; *a = p->ApxDist; + if ((Head = p->Next) == NULL) Tail = NULL; + + /* put node on free list */ + p->Next = Save; Save = p; + ClosNodes++; qlen--; + } + + else /* empty list */ + { + *r = *c = *s = *d = *a = ILLEGAL; + } +} + + + +/****************************************************************/ +int SetQueue (int r,int c,int side,int d,int a,int r2,int c2 ) +/****************************************************************/ +/* add a search node to the list + Return: + 1 si OK + 0 si defaut allocation Memoire +*/ +{ +struct PcbQueue *p, *q, *t; +int i, j; + + if( (p = Save) != NULL ) /* try free list first */ + { + Save = p->Next; + } + else if ((p = (struct PcbQueue *) MyMalloc(sizeof(PcbQueue))) == NULL) + return(0); + + p->Row = r; + p->Col = c; + p->Side = side; + i = (p->Dist = d) + (p->ApxDist = a); + p->Next = NULL; + if( (q = Head) != NULL) + { /* insert in proper position in list */ + if (q->Dist + q->ApxDist > i) + { /* insert at head */ + p->Next = q; Head = p; + } + else { /* search for proper position */ + for (t = q, q = q->Next; q && i > (j = q->Dist + q->ApxDist); + t = q, q = q->Next) + ; + if (q && i == j && q->Row == r2 && q->Col == c2) + { + /* insert after q, which is a goal node */ + if ( (p->Next = q->Next) == NULL) Tail = p; + q->Next = p; + } + else + { /* insert in front of q */ + if ((p->Next = q) == NULL) Tail = p; + t->Next = p; + } + } + } + else /* empty search list */ + Head = Tail = p; + OpenNodes++; + if (++qlen > MaxNodes) MaxNodes = qlen; + return(1); +} + + +/******************************************************************/ +void ReSetQueue (int r,int c,int s,int d,int a,int r2,int c2 ) +/******************************************************************/ +/* reposition node in list */ +{ +struct PcbQueue *p, *q; + + /* first, see if it is already in the list */ + for (q = NULL, p = Head; p; q = p, p = p->Next) { + if (p->Row == r && p->Col == c && p->Side == s) { + /* old one to remove */ + if (q) + { + if ( (q->Next = p->Next) == NULL) Tail = q; + } + else if ((Head = p->Next) == NULL) Tail = NULL; + p->Next = Save; Save = p; + OpenNodes--; MoveNodes++; + qlen--; + break; + } + } + if (!p) /* not found, it has already been closed once */ + ClosNodes--; /* we will close it again, but just count once */ + /* if it was there, it's gone now; insert it at the proper position */ + SetQueue( r, c, s, d, a, r2, c2 ); +} diff --git a/pcbnew/ratsnest.cpp b/pcbnew/ratsnest.cpp new file mode 100644 index 0000000000..7915c57fd3 --- /dev/null +++ b/pcbnew/ratsnest.cpp @@ -0,0 +1,1253 @@ + /************************************/ + /**** editeur de PCB ****/ + /* traitement du Chevelu (Rastnest) */ + /************************************/ + + /* Fichier RATSNEST.CPP */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "protos.h" + +/* variables locales */ +CHEVELU * g_pt_chevelu ; +CHEVELU * local_liste_chevelu; // adresse de base du buffer des chevelus locaux +int nb_local_chevelu; // nbr de links du module en deplacement +int nb_pads_ref; // nbr de nodes du module en deplacement +int nb_pads_externes; // nbr de pads connectes au module en deplacement +bool DisplayRastnestInProgress; // autorise affichage chevelu en cours de calcul + // de celui-ci + + + +/******************************************************************************/ +void WinEDA_BasePcbFrame::Compile_Ratsnest( wxDC * DC, bool display_status_pcb ) +/******************************************************************************/ +/* + Génère le chevelu complet de la carte. + Doit etre appelé APRES le calcul de connectivité + Doit etre appelé apres changement de structure de la carte (modif + de pads, de nets, de modules). + + Si display_status_pcb : affichage des résultats en bas d'ecran +*/ +{ +wxString msg; + + DisplayRastnestInProgress = TRUE; + + /* construction de la liste des coordonnées des pastilles */ + m_Pcb->m_Status_Pcb = 0; /* réinit total du calcul */ + build_liste_pads() ; + MsgPanel->EraseMsgBox() ; /* effacement du bas d'ecran */ + msg.Printf( wxT(" %d"),m_Pcb->m_NbPads) ; + Affiche_1_Parametre(this, 1, wxT("pads"), msg,RED) ; + + msg.Printf( wxT(" %d"),m_Pcb->m_NbNets) ; + Affiche_1_Parametre(this, 8, wxT("Nets"), msg,CYAN) ; + + reattribution_reference_piste(display_status_pcb); + Build_Board_Ratsnest(DC ); /* calcul du chevelu general */ + test_connexions(DC); /* determine les blocks de pads connectés par + les pistes existantes */ + + Tst_Ratsnest(DC, 0 ); /* calcul du chevelu actif */ + + // Reaffichage des chevelus actifs + if( g_Show_Ratsnest ) DrawGeneralRatsnest( DC, 0 ); + + if ( display_status_pcb ) Affiche_Infos_Status_Pcb(this); +} + + +/*****************************************************************/ +static int tri_par_net(LISTE_PAD * pt_ref, LISTE_PAD * pt_compare) +/****************************************************************/ +/* routine utilisee par la foncion QSORT */ +{ + return( (*pt_ref)->m_NetCode - (*pt_compare)->m_NetCode ); +} + +/********************************************************/ +static int sort_by_length(CHEVELU * ref, CHEVELU * compare) +/********************************************************/ +/* routine de tri par longueur des chevelus utilisee par la foncion QSORT */ +{ + return( ref->dist - compare->dist ); +} + + +/*****************************************************************************/ +static int gen_rats_block_to_block(WinEDA_DrawPanel * DrawPanel, wxDC * DC, + LISTE_PAD * pt_liste_pad, LISTE_PAD * pt_limite, int * nblinks) +/*****************************************************************************/ +/* + Routine utilisee par Build_Board_Ratsnest() + Routine generant le chevelu entre 2 blocks ( supposes du meme net ) + la recherche est faite entre les pads du block 1 et les autres blocks + le block n ( n > 1 ) est alors connecte au block 1 par leur 2 pads + les plus proches. + Entree : + pt_chain_pad = adresse de debut de recherche + pt_limite = adresse de fin de recherche (borne non comprise) + Sortie: + liste des chevelus ( structures) + mise a jour de g_pt_chevelu a la 1ere case libre + Retourne: + nombre de blocks non connectes entre eux + */ +{ +int dist_min, current_dist ; +int current_num_block = 1 ; +LISTE_PAD * pt_liste_pad_tmp, + * pt_liste_pad_aux, + * pt_liste_pad_block1 = NULL, + * pt_start_liste ; + + pt_liste_pad_tmp = NULL ; dist_min = 0x7FFFFFFF; + pt_start_liste = pt_liste_pad ; + + if ( DC ) GRSetDrawMode(DC, GR_XOR); + + /* Recherche du pad le plus proche du block 1 */ + for ( ; pt_liste_pad < pt_limite ; pt_liste_pad++ ) + { + D_PAD * ref_pad = *pt_liste_pad; + if(ref_pad->m_logical_connexion != 1) continue ; + + for ( pt_liste_pad_aux = pt_start_liste ; ;pt_liste_pad_aux++) + { + D_PAD * curr_pad = *pt_liste_pad_aux; + if(pt_liste_pad_aux >= pt_limite ) break ; + if(curr_pad->m_logical_connexion == 1) continue ; + + /* Comparaison des distances des pastilles (calcul simplifie) */ + current_dist = + abs( curr_pad->m_Pos.x - ref_pad->m_Pos.x) + + abs( curr_pad->m_Pos.y - ref_pad->m_Pos.y) ; + + if(dist_min > current_dist) + { + current_num_block = curr_pad->m_logical_connexion ; + dist_min = current_dist; + pt_liste_pad_tmp = pt_liste_pad_aux; + pt_liste_pad_block1 = pt_liste_pad; + } + } + } + + if (current_num_block > 1) /* le block n a ete connecte au bloc 1 */ + { + /* le block n est fondu avec le bloc 1 : */ + for( pt_liste_pad = pt_start_liste; pt_liste_pad < pt_limite; pt_liste_pad++ ) + { + if( (*pt_liste_pad)->m_logical_connexion == current_num_block) + (*pt_liste_pad)->m_logical_connexion = 1; + } + + pt_liste_pad = pt_liste_pad_block1 ; + + (*nblinks)++; + g_pt_chevelu->m_NetCode = (*pt_liste_pad)->m_NetCode; + g_pt_chevelu->status = CH_ACTIF|CH_VISIBLE; + g_pt_chevelu->dist = dist_min; + g_pt_chevelu->pad_start = *pt_liste_pad; + g_pt_chevelu->pad_end = *pt_liste_pad_tmp; + + if( DisplayRastnestInProgress && DC ) + GRLine(&DrawPanel->m_ClipBox, DC, g_pt_chevelu->pad_start->m_Pos.x, + g_pt_chevelu->pad_start->m_Pos.y, + g_pt_chevelu->pad_end->m_Pos.x, + g_pt_chevelu->pad_end->m_Pos.y, + g_DesignSettings.m_RatsnestColor) ; + + g_pt_chevelu++ ; + } + return(current_num_block) ; +} + +/*****************************************************************************/ +static int gen_rats_pad_to_pad(WinEDA_DrawPanel * DrawPanel, wxDC * DC, + LISTE_PAD * pt_liste_pad, + LISTE_PAD * pt_limite,int current_num_block, int * nblinks) +/*****************************************************************************/ +/* + Routine utilisee par Build_Board_Ratsnest() + Routine generant le chevelu entre 2 pads ( supposes du meme net ) + la routine connecte 1 pad non deja connecte a un autre et crée donc un certqins nombre +de blocks de pads liées par un chevelu +Ces blocks sont donc constitués de 2 pads. + + Entree : + pt_chain_pad = adresse de debut de recherche + pt_limite = adresse de fin de recherche (borne non comprise) + current_num_block = numero du dernier block de pads (constitué par les connexions + de pistes existantes + + Sortie: + liste des chevelus ( structures) + mise a jour de g_pt_chevelu a la 1ere case libre + + Retourne: + nombre de blocks crees (paquets de pads) + */ +{ +int dist_min, current_dist ; +LISTE_PAD * pt_liste_pad_tmp; +LISTE_PAD * pt_liste_pad_aux ; +LISTE_PAD * pt_start_liste; +D_PAD * ref_pad, * pad; + + pt_start_liste = pt_liste_pad ; + + if ( DC ) GRSetDrawMode(DC, GR_XOR); + + for ( ; pt_liste_pad < pt_limite ; pt_liste_pad++ ) + { + ref_pad = *pt_liste_pad; + if(ref_pad->m_logical_connexion) continue; // Pad deja connecte + + pt_liste_pad_tmp = NULL ; dist_min = 0x7FFFFFFF; + + for ( pt_liste_pad_aux = pt_start_liste ; ;pt_liste_pad_aux++) + { + if (pt_liste_pad_aux >= pt_limite ) break ; + if(pt_liste_pad_aux == pt_liste_pad) continue ; + + pad = *pt_liste_pad_aux; + /* Comparaison des distances des pastilles (calcul simplifie) */ + current_dist = + abs( pad->m_Pos.x - ref_pad->m_Pos.x) + + abs( pad->m_Pos.y - ref_pad->m_Pos.y); + + if(dist_min > current_dist) + { + dist_min = current_dist; + pt_liste_pad_tmp = pt_liste_pad_aux; + } + } + + if (pt_liste_pad_tmp != NULL) + { + pad = *pt_liste_pad_tmp; + + /* Mise a jour du numero de block ( ou de sous graphe ) */ + /* si aucun des 2 pads n'est deja connecte : creation d'un nouveau block */ + if ( (pad->m_logical_connexion == 0) && (ref_pad->m_logical_connexion == 0) ) + { + current_num_block++ ; + pad->m_logical_connexion = current_num_block ; + ref_pad->m_logical_connexion = current_num_block ; + } + /* si 1 des 2 pads est deja connecte : mise a jour pour l'autre */ + else + { + ref_pad->m_logical_connexion = pad->m_logical_connexion; + } + (*nblinks)++; + g_pt_chevelu->m_NetCode = ref_pad->m_NetCode; + g_pt_chevelu->status = CH_ACTIF|CH_VISIBLE; + g_pt_chevelu->dist = dist_min; + g_pt_chevelu->pad_start = ref_pad; + g_pt_chevelu->pad_end = pad; + + if(DisplayRastnestInProgress) + { + GRLine(&DrawPanel->m_ClipBox, DC, g_pt_chevelu->pad_start->m_Pos.x, + g_pt_chevelu->pad_start->m_Pos.y, + g_pt_chevelu->pad_end->m_Pos.x, + g_pt_chevelu->pad_end->m_Pos.y, + g_DesignSettings.m_RatsnestColor); + } + g_pt_chevelu++ ; + } + } + + return(current_num_block) ; +} + + +/***********************************************************/ +void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC * DC ) +/***********************************************************/ +/* Routine de calcul du chevelu complet du circuit (algorithme de LEE ) + les connexions physiques (pistes) ne sont pas ici prises en compte + Il s'agit donc du chevelu de base qui ne depend que de la disposition des pads. + + - etablit la liste complete des pads si nécessaire + les pads utiles (cad appartenant a un net ) sont appeles + nodes (noeuds) + et la trie par blocs de pads homogenes ( i.e. appartenant au meme net ) + + - puis calcule le ratsnest selon l'algorithme de LEE, consistant a + a - etablir le ratsnest entre 1 pad non "connecte" et son plus proche + voisin. Ceci cree des "blocks" ou sous graphes non connectes entre + eux + b - "connecter" (par un chevelu) entre eux ces blocks en prenant le 1er block et + en le connectant a son plus proche voisin par les 2 pads les plus + proches (Iteration jusqu'a ce qu'il n'y ait plus qu'un seul block). + + les chevelus calculés montrent les connexions "logiques" + + Entree = adr du buffer de classement (usuellement buf_work) + met a jour : + nb_nodes = nombre de pads connectes a un net ( pads "utiles") + nb_links = nombre min de liens : + il y a n-1 liens par equipotentielle comportant n pads. + +*/ +{ +LISTE_PAD * pt_liste_pad, * pt_start_liste, * pt_end_liste, * pt_liste_pad_limite; +D_PAD * pad; +int ii, num_block, nbpads; +CHEVELU * pt_deb_liste_ch; +int current_net_code, noconn; +EQUIPOT * equipot; + + m_Pcb->m_NbNoconnect = 0; + m_Pcb->m_NbLinks = 0 ; + + if( m_Pcb->m_NbPads == 0 ) return; + + /* Etablissement de la liste des pads et leur net_codes si necessaire */ + if( (m_Pcb->m_Status_Pcb & NET_CODES_OK) == 0 ) recalcule_pad_net_code(); + + pt_liste_pad = m_Pcb->m_Pads; + for( ii = m_Pcb->m_NbPads ; ii > 0 ; pt_liste_pad++, ii-- ) + { + pad = *pt_liste_pad; + pad->m_logical_connexion = 0; + } + + /* classement des pointeurs sur pads par nets */ + qsort(m_Pcb->m_Pads,m_Pcb->m_NbPads,sizeof(LISTE_PAD), + (int(*)(const void *, const void *))tri_par_net) ; + + /* Allocation memoire du buffer des chevelus: il y a nb_nodes - 1 chevelu + au maximum ( 1 node = 1 pad connecte ). + on alloue donc un buffer pour nb_nodes chevelus... (+ une petite marge) + le nombre reel de chevelus est nb_links + */ + if( m_Pcb->m_Ratsnest ) MyFree(m_Pcb->m_Ratsnest); + m_Pcb->m_Ratsnest = NULL; + + if( m_Pcb->m_NbNodes == 0 ) return; /* pas de connexions utiles */ + + m_Pcb->m_Ratsnest = (CHEVELU*)MyZMalloc( (m_Pcb->m_NbNodes + 10 ) * sizeof(CHEVELU) ); + if(m_Pcb->m_Ratsnest == NULL) return; + + + /* calcul du chevelu */ + DisplayRastnestInProgress = TRUE; + g_pt_chevelu = m_Pcb->m_Ratsnest ; + pt_liste_pad = pt_start_liste = m_Pcb->m_Pads; + pt_liste_pad_limite = pt_start_liste + m_Pcb->m_NbPads; + current_net_code = 1; // 1er net_code a analyser (net_code = 0 -> no connect) + equipot = m_Pcb->m_Equipots; + noconn = 0; + + for ( ; pt_liste_pad < pt_liste_pad_limite ; ) + { + pt_deb_liste_ch = g_pt_chevelu; + pad = *pt_liste_pad; + /* saut des pads non connectes */ + if(pad->m_NetCode == 0 ) + { + pt_liste_pad++; pt_start_liste = pt_liste_pad; + continue; + } + /* Recherche de la fin de la liste des pads du net courant */ + num_block = pad->m_logical_connexion; + nbpads = 0; + for( pt_end_liste = pt_liste_pad + 1 ; ; pt_end_liste++) + { + if (pt_end_liste >= pt_liste_pad_limite ) break ; + pad = *pt_end_liste; + if (pad->m_NetCode != current_net_code ) break ; + nbpads++; + if( num_block < pad->m_logical_connexion ) + num_block = pad->m_logical_connexion; + } + m_Pcb->m_NbLinks += nbpads; + + /* fin de liste trouvee: calcul du chevelu du net "net_code" */ + equipot = GetEquipot(m_Pcb, current_net_code); + if(equipot == NULL) + DisplayError(this, wxT("Gen ratsnest err: NULL equipot") ); + else + { + equipot->m_NbNodes = nbpads; + equipot->m_NbLink = nbpads+1; + equipot->m_PadzoneStart = pt_start_liste; + equipot->m_PadzoneEnd = pt_end_liste; + equipot->m_RatsnestStart = g_pt_chevelu; + } + + /* a - connexion des pads entre eux */ + ii = gen_rats_pad_to_pad(DrawPanel, DC, pt_start_liste, + pt_end_liste, num_block, &noconn); + + /* b - connexion des blocks formes precedemment (Iteration) */ + while (ii > 1 ) + { + ii = gen_rats_block_to_block(DrawPanel, DC, pt_liste_pad, + pt_end_liste, &noconn); + } + + if( equipot ) + { + equipot->m_RatsnestEnd = g_pt_chevelu; + /* classement des chevelus par longueur croissante */ + qsort(equipot->m_RatsnestStart, + equipot->m_RatsnestEnd - equipot->m_RatsnestStart, + sizeof(CHEVELU), + (int(*)(const void *, const void *))sort_by_length) ; + } + pt_liste_pad = pt_start_liste = pt_end_liste ; + pt_deb_liste_ch = g_pt_chevelu; + if(pt_start_liste < pt_liste_pad_limite) + current_net_code = (*pt_start_liste)->m_NetCode; + } + + + m_Pcb->m_NbNoconnect = noconn; + m_Pcb->m_Status_Pcb |= LISTE_CHEVELU_OK ; + adr_lowmem = buf_work; + + // Effacement du chevelu calcule + CHEVELU * Chevelu = (CHEVELU*)m_Pcb->m_Ratsnest; + GRSetDrawMode(DC, GR_XOR); + for( ii = m_Pcb->GetNumRatsnests(); ii > 0; ii--, Chevelu++ ) + { + if( ! g_Show_Ratsnest ) Chevelu->status &= ~CH_VISIBLE; + if ( DC ) GRLine(&DrawPanel->m_ClipBox, DC, + Chevelu->pad_start->m_Pos.x, Chevelu->pad_start->m_Pos.y, + Chevelu->pad_end->m_Pos.x, Chevelu->pad_end->m_Pos.y, + g_DesignSettings.m_RatsnestColor); + } + +} + + +/**********************************************************************/ +void WinEDA_BasePcbFrame::ReCompile_Ratsnest_After_Changes(wxDC * DC ) +/**********************************************************************/ +/* recompile rastnest afet am module move, delete, .. +*/ +{ + if ( g_Show_Ratsnest && DC ) Compile_Ratsnest( DC, TRUE ); +} + + +/*********************************************************************/ +void WinEDA_BasePcbFrame::DrawGeneralRatsnest(wxDC * DC, int net_code) +/*********************************************************************/ +/* + Affiche le chevelu general du circuit + Affiche les chevelus dont le bit CH_VISIBLE du status du chevelu est a 1 + Si net_code > 0, affichage des seuls chevelus de net_code correspondant +*/ +{ +int ii; +CHEVELU * Chevelu; + + if( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 ) return; + if( (m_Pcb->m_Status_Pcb & DO_NOT_SHOW_GENERAL_RASTNEST) ) return; + if ( DC == NULL ) return; + + Chevelu = m_Pcb->m_Ratsnest; + if( Chevelu == NULL ) return; + + GRSetDrawMode(DC, GR_XOR); + for( ii = m_Pcb->GetNumRatsnests() ;ii > 0; Chevelu++, ii--) + { + if( (Chevelu->status & (CH_VISIBLE|CH_ACTIF)) != (CH_VISIBLE|CH_ACTIF) ) + continue; + if( (net_code <= 0) || (net_code == Chevelu->m_NetCode) ) + { + GRLine(&DrawPanel->m_ClipBox, DC, + Chevelu->pad_start->m_Pos.x, Chevelu->pad_start->m_Pos.y, + Chevelu->pad_end->m_Pos.x, Chevelu->pad_end->m_Pos.y, + g_DesignSettings.m_RatsnestColor); + } + } +} + + + +/*****************************************************************************/ +static int tst_rats_block_to_block(WinEDA_DrawPanel * DrawPanel, wxDC * DC, + LISTE_PAD * pt_liste_pad_start, LISTE_PAD * pt_liste_pad_end, + CHEVELU* start_rat_list, CHEVELU* end_rat_list) +/*****************************************************************************/ +/* + Routine utilisee par Tst_Ratsnest() + Routine tres proche de gen_rats_block_to_block(..) + Routine testant le chevelu entre 2 blocks ( supposes du meme net ) + la recherche est faite entre les pads du block 1 et les autres blocks + le block n ( n > 1 ) est alors connecte au block 1 par le chevelu le plus court + A la différence de gen_rats_block_to_block(..), + l'analyse n'est pas faite pads a pads mais a travers la liste générale des chevelus. + La routine active alors le chevelu le plus court reliant le block 1 au block n + (etablissement d'une connexion "logique") + + Entree : + pt_chain_pad = adresse de debut de zone pad utile + pt_limite = adresse de fin de zone (borne non comprise) + Sortie: + Membre .state du chevelu sélectionné + Retourne: + nombre de blocks non connectes entre eux + */ +{ +int current_num_block, min_block ; +LISTE_PAD * pt_liste_pad; +CHEVELU * chevelu, * min_chevelu; + + /* Recherche du chevelu le plus court d'un block a un autre block */ + min_chevelu = NULL; + for ( chevelu = start_rat_list; chevelu < end_rat_list ; chevelu++ ) + { + if( chevelu->pad_start->m_logical_connexion == chevelu->pad_end->m_logical_connexion ) + continue ; + if( min_chevelu == NULL ) min_chevelu = chevelu; + else if(min_chevelu->dist > chevelu->dist) min_chevelu = chevelu; + } + + if( min_chevelu == NULL ) return 1; + + min_chevelu->status |= CH_ACTIF; + current_num_block = min_chevelu->pad_start->m_logical_connexion; + min_block = min_chevelu->pad_end->m_logical_connexion; + if (min_block > current_num_block ) EXCHG(min_block, current_num_block); + + /* les 2 blocks vont etre fondus */ + for( pt_liste_pad = pt_liste_pad_start; pt_liste_pad < pt_liste_pad_end; pt_liste_pad++ ) + { + if( (*pt_liste_pad)->m_logical_connexion == current_num_block) + { + (*pt_liste_pad)->m_logical_connexion = min_block; + } + } + + return(current_num_block) ; +} + +/*********************************************************************/ +static int tst_rats_pad_to_pad(WinEDA_DrawPanel * DrawPanel, wxDC * DC, + int current_num_block, + CHEVELU* start_rat_list, CHEVELU* end_rat_list) +/**********************************************************************/ +/* + Routine utilisee par Tst_Ratsnest_general() + Routine Activant le chevelu entre 2 pads ( supposes du meme net ) + la routine connecte 1 pad non deja connecte a un autre et active donc + un certain nombre de blocks de pads liées par un chevelu +Ces blocks sont donc constitués de 2 pads. + + Entree : + pt_chain_pad = adresse de debut de zone pad + pt_limite = adresse de fin de recherche (borne non comprise) + current_num_block = numero du dernier block de pads (constitué par les connexions + de pistes existantes + + Sortie: + liste des chevelus ( structures) + mise a jour du membre .state du chevelu activé + + Retourne: + nombre de blocks crees (paquets de pads) +*/ +{ +D_PAD * pad_start, * pad_end; +CHEVELU * chevelu; + + for ( chevelu = start_rat_list; chevelu < end_rat_list; chevelu++ ) + { + pad_start = chevelu->pad_start; pad_end = chevelu->pad_end; + /* Mise a jour du numero de block ( ou de sous graphe ) */ + + /* si aucun des 2 pads n'est deja connecte : creation d'un nouveau block */ + if ( (pad_start->m_logical_connexion == 0) && (pad_end->m_logical_connexion == 0) ) + { + current_num_block++ ; + pad_start->m_logical_connexion = current_num_block ; + pad_end->m_logical_connexion = current_num_block; + chevelu->status |= CH_ACTIF; + } + /* si 1 des 2 pads est deja connecte : mise a jour pour l'autre */ + else if ( pad_start->m_logical_connexion == 0) + { + pad_start->m_logical_connexion = pad_end->m_logical_connexion; + chevelu->status |= CH_ACTIF; + } + else if ( pad_end->m_logical_connexion == 0) + { + pad_end->m_logical_connexion = pad_start->m_logical_connexion; + chevelu->status |= CH_ACTIF; + } + } + + return(current_num_block) ; +} + + +/******************************************************************/ +void WinEDA_BasePcbFrame::Tst_Ratsnest(wxDC * DC, int ref_netcode ) +/*******************************************************************/ + +/* calcul du chevelu actif + Le chevelu général doit etre calculé + Determite les chevelus ACTIFS dans la liste générale des chevelus +*/ +{ +LISTE_PAD * pt_liste_pad; +CHEVELU * chevelu; +D_PAD * pad; +int ii, num_block; +int net_code; +EQUIPOT * equipot; + + if( m_Pcb->m_NbPads == 0 ) return; + + for ( net_code = 1; ; net_code++) + { + equipot = GetEquipot(m_Pcb, net_code); + if(equipot == NULL ) break; + if( ref_netcode && (net_code != ref_netcode) ) continue; + + num_block = 0; + pt_liste_pad = equipot->m_PadzoneStart; + for( ;pt_liste_pad < equipot->m_PadzoneEnd; pt_liste_pad++) + { + pad = *pt_liste_pad; + pad->m_logical_connexion = pad->m_physical_connexion; + num_block = max (num_block, pad->m_logical_connexion); + } + + for ( chevelu = equipot->m_RatsnestStart; chevelu < equipot->m_RatsnestEnd; chevelu++ ) + { + chevelu->status &= ~CH_ACTIF; + } + + + /* a - tst connexion des pads entre eux */ + ii = tst_rats_pad_to_pad(DrawPanel, DC, num_block, + equipot->m_RatsnestStart, equipot->m_RatsnestEnd); + + /* b - connexion des blocks formes precedemment (Iteration) */ + while (ii > 1 ) + { + ii = tst_rats_block_to_block(DrawPanel, DC, + equipot->m_PadzoneStart, equipot->m_PadzoneEnd, + equipot->m_RatsnestStart, equipot->m_RatsnestEnd); + } + } + + + m_Pcb->m_NbNoconnect = 0; + CHEVELU * Chevelu = m_Pcb->m_Ratsnest; + for( ii = m_Pcb->GetNumRatsnests(); ii > 0; ii--, Chevelu++ ) + { + if( Chevelu->status & CH_ACTIF ) + m_Pcb->m_NbNoconnect++; + } +} + +/**************************************************************************/ +int WinEDA_BasePcbFrame::Test_1_Net_Ratsnest(wxDC * DC, int ref_netcode) +/**************************************************************************/ +/* Calcule le chevelu du net net_code */ +{ + + DisplayRastnestInProgress = FALSE; + DrawGeneralRatsnest(DC, ref_netcode); + Tst_Ratsnest(DC, ref_netcode ); + DrawGeneralRatsnest(DC, ref_netcode); + + return m_Pcb->GetNumRatsnests(); +} + +/*****************************************************/ +void WinEDA_BasePcbFrame::recalcule_pad_net_code(void) +/*****************************************************/ +/* + Calcule et met a jour les net_codes des PADS et des equipotentielles + met a jour le buffer des equipotentielles + A utiliser apres edition de nets sur un pad ou lecture d'une netliste + positionne a 1 le bit NET_CODE_OK du status_pcb; +*/ +{ +LISTE_PAD * pad_ref, *pad_courant; +int ii, jj; +EQUIPOT * pt_equipot; +EDA_BaseStruct * PtStruct; +EQUIPOT ** BufPtEquipot; + + /* construction de la liste des adr des PADS */ + build_liste_pads(); + + /* calcul des net_codes des pads */ + ii = m_Pcb->m_NbPads; + m_Pcb->m_NbNodes = 0; + m_Pcb->m_NbNets = 0; + + pad_courant = m_Pcb->m_Pads; + for( ; ii > 0 ; pad_courant++, ii-- ) + { + if( (*pad_courant)->m_Netname.IsEmpty()) // pad non connecte + { + (*pad_courant)->m_NetCode = 0 ; continue ; + } + m_Pcb->m_NbNodes++; + /* si le netname a deja ete rencontre: mise a jour , sinon nouveau net_code */ + pad_ref = m_Pcb->m_Pads ; + while (pad_ref < pad_courant ) + { + if( (*pad_ref)->m_Netname == (*pad_courant)->m_Netname ) + break; // sont du meme met + pad_ref++ ; + } + + /* si pad_ref = pad_courant: nouveau net sinon, deja net deja traite */ + if ( pad_ref == pad_courant ) + { + m_Pcb->m_NbNets++ ; (*pad_courant)->m_NetCode = m_Pcb->m_NbNets; + } + else (*pad_courant)->m_NetCode = (*pad_ref)->m_NetCode ; + } + + /* Construction ou correction de la liste des equipotentielles, + et construction d'un tableau d'adressage des equipots*/ + + BufPtEquipot = (EQUIPOT**)MyMalloc(sizeof(EQUIPOT*) * (m_Pcb->m_NbNets+1)); + pt_equipot = m_Pcb->m_Equipots; + PtStruct = (EDA_BaseStruct *) m_Pcb; + for( ii = 0 ; ii <= m_Pcb->m_NbNets ;ii++ ) + { + if(pt_equipot == NULL ) /* Creation d'une nouvelle equipot */ + { + pt_equipot = new EQUIPOT(m_Pcb); + + if( ii == 0 ) + { + m_Pcb->m_Equipots = pt_equipot; + pt_equipot->Pback = m_Pcb; + } + else + { + PtStruct->Pnext = pt_equipot; + pt_equipot->Pback = PtStruct; + } + pt_equipot->Pnext = NULL; + } + + pt_equipot->m_NetCode = ii; // Mise a jour du numero d'equipot + pt_equipot->m_NbNodes = 0; + pt_equipot->m_Netname.Empty(); + + BufPtEquipot[ii] = pt_equipot; + PtStruct = (EDA_BaseStruct *) pt_equipot; + pt_equipot = (EQUIPOT *) pt_equipot->Pnext; + } + + /* Effacement des equipots inutiles */ + + while ( pt_equipot ) + { + PtStruct = pt_equipot->Pnext; + DeleteStructure(pt_equipot); + pt_equipot = (EQUIPOT*) PtStruct; + } + + pad_courant = m_Pcb->m_Pads; + pt_equipot = m_Pcb->m_Equipots; + + /* Placement des noms de net en structure EQUIPOT */ + for( ii = m_Pcb->m_NbPads ; ii > 0 ; pad_courant++, ii-- ) + { + jj = (*pad_courant)->m_NetCode; + pt_equipot = BufPtEquipot[jj]; + pt_equipot->m_NbNodes ++; + if(pt_equipot->m_Netname.IsEmpty()) + { + pt_equipot->m_Netname = (*pad_courant)->m_Netname; + } + } + MyFree(BufPtEquipot); + m_Pcb->m_Status_Pcb |= NET_CODES_OK; +} + + + +/***********************************************/ +void WinEDA_BasePcbFrame::build_liste_pads(void) +/***********************************************/ +/* + construction de la liste ( sous forme d'une liste de stucture ) + des caract utiles des pads du PCB pour autoroutage,DRC .. ) + parametres: + adresse du buffer de classement = buf_work + retourne: + 1ere adresse disponible si OK + NULL si trop de pastilles + + +Parametres de routage calcules et mis a jour +- parametre net_code: + numero de code interne de chaque net du PCB. + permet d'accelerer les calculs de chevelu et de connexions +- parametre .link est mis a jour + pour chaque pastille, il indique le nombre d'autres pastilles du meme net + appartenant au meme module. + +Variables globales mise a jour: + pointeur base_adr_liste_pad (adr de classement de la liste des pads) + nb_pads = nombre total de pastilles du PCB + nb_nets = nombre de nets differents + status_pcb |= LISTE_PAD_OK (flag permettant d'eviter la reexecution inutile + de cette routine) +*/ +{ +LISTE_PAD* pt_liste_pad; +MODULE * Module; +D_PAD * PtPad; + + if( m_Pcb->m_Status_Pcb & LISTE_PAD_OK ) return; + + /* construction de la liste des pointeurs sur les structures D_PAD */ + if( m_Pcb->m_Pads ) MyFree(m_Pcb->m_Pads); + m_Pcb->m_Pads = NULL; + + /* Calcul du nombre de pads */ + Module = m_Pcb->m_Modules; m_Pcb->m_NbPads = 0; + for( ; Module != NULL ; Module = (MODULE*) Module->Pnext) + { + PtPad = (D_PAD*) Module->m_Pads; + for(; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) m_Pcb->m_NbPads++; + } + + if( m_Pcb->m_NbPads == 0 ) return; + + /* Allocation memoire du buffer */ + pt_liste_pad = m_Pcb->m_Pads + = (D_PAD**) MyZMalloc( (m_Pcb->m_NbPads+1) * sizeof(D_PAD*) ); + m_Pcb->m_NbNodes = 0; + + /* Initialisation du buffer et des variables de travail */ + Module = m_Pcb->m_Modules; + for( ; Module != NULL ; Module = (MODULE*) Module->Pnext) + { + PtPad = (D_PAD*) Module->m_Pads; + for(; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) + { + *pt_liste_pad = PtPad; + PtPad->m_logical_connexion = 0 ; + PtPad->m_Parent = Module; + if(PtPad->m_NetCode) m_Pcb->m_NbNodes++; + pt_liste_pad++; + } + } + + *pt_liste_pad = NULL; // fin de liste + + adr_lowmem = buf_work; + if( m_Pcb->m_Ratsnest ) MyFree(m_Pcb->m_Ratsnest); + m_Pcb->m_Ratsnest = NULL; + m_Pcb->m_Status_Pcb = LISTE_PAD_OK; +} + + +/*****************************************************************************/ +char * WinEDA_BasePcbFrame::build_ratsnest_module(wxDC * DC, MODULE * Module) +/*****************************************************************************/ +/* + construction de la liste en mode de calcul rapide pour affichage + en temps reel lors des deplacements du chevelu d'un module. + + parametres d'appel: + Module = pointeur sur module dont le ratsnest est a calculer + + retourne: adresse memoire disponible + Le chevelu calcule comporte 2 parties + - un chevelu interne relatif aux pads du module appartenant a un + meme net. Il est calcule 1 seule fois + - le chevelu externe reliant un pad interne a un pad externe au module + Ce chevelu est recalcule a chaque deplacement +*/ +{ +LISTE_PAD * pt_liste_pad, + * pt_liste_ref, + * pt_liste_generale; +D_PAD * pad_ref, + * pad_externe; +LISTE_PAD * pt_liste_pad_limite, + * pt_start_liste, + * pt_end_liste; +int ii, jj; +CHEVELU * local_chevelu; +static CHEVELU * pt_fin_int_chevelu; // pointeur sur la fin de la liste + // des chevelus internes au module +static int nb_int_chevelu; // nombre e chevelus internes +int current_net_code; +int increment, distance; // variables de calcul de ratsnest +int pad_pos_X, pad_pos_Y; // position reelle des pads du module en mouvement + + + if((m_Pcb->m_Status_Pcb & LISTE_PAD_OK) == 0 ) build_liste_pads(); + + /* construction de la liste des pads du module si necessaire */ + if((m_Pcb->m_Status_Pcb & CHEVELU_LOCAL_OK) != 0) goto calcul_chevelu_ext; + + /* calcul du chevelu "interne", c.a.d. liant les seuls pads du module */ + pt_liste_pad = (LISTE_PAD*) adr_lowmem; nb_pads_ref = 0; + pad_ref = Module->m_Pads; + for( ; pad_ref != NULL ; pad_ref = (D_PAD*)pad_ref->Pnext) + { + if(pad_ref->m_NetCode == 0) continue; + *pt_liste_pad = pad_ref; + pad_ref->m_logical_connexion = 0; + pad_ref->m_physical_connexion = 0; + pt_liste_pad++; nb_pads_ref++; + } + + if(nb_pads_ref == 0) return( (char*)pt_liste_pad); /* pas de connexions! */ + + qsort(adr_lowmem,nb_pads_ref,sizeof(D_PAD*), + (int(*)(const void *, const void *))tri_par_net) ; + + /* construction de la liste des pads connectes aux pads de ce module */ + DisplayRastnestInProgress = FALSE; + pt_liste_ref = (LISTE_PAD*) adr_lowmem; + nb_pads_externes = 0; current_net_code = 0; + for(ii = 0 ; ii < nb_pads_ref ; ii++) + { + pad_ref = pt_liste_ref[ii]; + if(pad_ref->m_NetCode == current_net_code) continue; + current_net_code = pad_ref->m_NetCode; + + pt_liste_generale = m_Pcb->m_Pads ; + for(jj = m_Pcb->m_NbPads ; jj > 0; jj--) + { + pad_externe = *pt_liste_generale ; pt_liste_generale++; + if(pad_externe->m_NetCode != current_net_code) continue; + if(pad_externe->m_Parent == Module) continue; + pad_externe->m_logical_connexion = 0; + pad_externe->m_physical_connexion = 0; + *pt_liste_pad = pad_externe ; pt_liste_pad++; + nb_pads_externes++; + } + } + /* tri par net_codes croissants de la liste des pads externes */ + qsort(pt_liste_ref+nb_pads_ref,nb_pads_externes,sizeof(D_PAD*), + (int(*)(const void *, const void *))tri_par_net) ; + + /* calcul du chevelu interne au module: + Ce calcul est identique au calcul du chevelu general, mais il est + restreint aux seuls pads du module courant */ + local_liste_chevelu = (CHEVELU*)(pt_liste_pad); // buffer chevelu a la suite de la liste des pads + nb_local_chevelu = 0; + pt_liste_ref = (LISTE_PAD*) adr_lowmem; + + g_pt_chevelu = local_liste_chevelu ; + pt_liste_pad = pt_start_liste = (LISTE_PAD *) adr_lowmem ; + pt_liste_pad_limite = pt_liste_pad + nb_pads_ref; + current_net_code = (*pt_liste_pad)->m_NetCode ; + + for ( ; pt_liste_pad < pt_liste_pad_limite ; ) + { + /* Recherche de la fin de la liste des pads du net courant */ + + for( pt_end_liste = pt_liste_pad + 1 ; ; pt_end_liste++) + { + if (pt_end_liste >= pt_liste_pad_limite ) break ; + if ((*pt_end_liste)->m_NetCode != current_net_code ) break ; + } + + /* fin de liste trouvee : */ + /* a - connexion des pads entre eux */ + ii = gen_rats_pad_to_pad(DrawPanel, DC, pt_start_liste,pt_end_liste, + 0, &nb_local_chevelu ) ; + + /* b - connexion des blocks formes precedemment (Iteration) */ + while (ii > 1 ) + { + ii = gen_rats_block_to_block(DrawPanel, DC, pt_liste_pad, + pt_end_liste, &nb_local_chevelu ) ; + } + + pt_liste_pad = pt_start_liste = pt_end_liste ; + if(pt_start_liste < pt_liste_pad_limite) + current_net_code = (*pt_start_liste)->m_NetCode ; + } + + pt_fin_int_chevelu = local_chevelu = g_pt_chevelu; + nb_int_chevelu = nb_local_chevelu; + + /* Mise a 1 du flag LOCAL */ + g_pt_chevelu = local_liste_chevelu; + while(g_pt_chevelu < pt_fin_int_chevelu) + { + g_pt_chevelu->status = LOCAL_CHEVELU; g_pt_chevelu++; + } + + m_Pcb->m_Status_Pcb |= CHEVELU_LOCAL_OK; + + ///////////////////////////////////////// + // calcul du chevelu externe au module // + ///////////////////////////////////////// +calcul_chevelu_ext: + /* Cette partie est executee a chaque deplacement du module: on calcule + pour chaque pad du module courant la + courte distance a un pad externe. + Pour chaque groupe de pad du module courant appartenant a un meme net, + on ne garde qu'un seul chevelu: le plus court. + */ + local_chevelu = pt_fin_int_chevelu; + nb_local_chevelu = nb_int_chevelu; + pt_liste_ref = (LISTE_PAD*) adr_lowmem; + pad_ref = *pt_liste_ref; + current_net_code = pad_ref->m_NetCode; + local_chevelu->dist = 0x7FFFFFFF; + local_chevelu->status = 0; + increment = 0; + for(ii = 0 ; ii < nb_pads_ref ; ii++) + { + pad_ref = *(pt_liste_ref+ii); + if(pad_ref->m_NetCode != current_net_code) + { /* un nouveau chevelu est cree (si necessaire) pour + chaque nouveau net */ + if(increment) + { + nb_local_chevelu++; local_chevelu++; + } + increment = 0; + current_net_code = pad_ref->m_NetCode; + local_chevelu->dist = 0x7FFFFFFF; + } + + pad_pos_X = pad_ref->m_Pos.x - g_Offset_Module.x; + pad_pos_Y = pad_ref->m_Pos.y - g_Offset_Module.y; + pt_liste_generale = pt_liste_ref + nb_pads_ref ; + + for(jj = nb_pads_externes ; jj > 0; jj--) + { + pad_externe = *pt_liste_generale ; pt_liste_generale++; + /* les netcodes doivent etre identiques */ + if(pad_externe->m_NetCode < pad_ref->m_NetCode) continue; + if(pad_externe->m_NetCode > pad_ref->m_NetCode) break; + distance = abs(pad_externe->m_Pos.x - pad_pos_X) + + abs(pad_externe->m_Pos.y - pad_pos_Y); + if(distance < local_chevelu->dist) + { + local_chevelu->pad_start = pad_ref; + local_chevelu->pad_end = pad_externe; + local_chevelu->m_NetCode = pad_ref->m_NetCode; + local_chevelu->dist = distance; + local_chevelu->status = 0; + increment = 1; + } + } + } + if(increment) // fin de balayage : le ratsnest courant doit etre memorise + { + nb_local_chevelu++; local_chevelu++; + } + + /* Retourne l'adr de la zone disponible */ + adr_max = max(adr_max, (char*)(local_chevelu+1)); + + return( (char*) (local_chevelu+1) ) ; /* la struct pointee par + local_chevelu est utilisee + pour des calculs temporaires */ +} + + +/***********************************************************/ +void WinEDA_BasePcbFrame::trace_ratsnest_module(wxDC * DC) +/**********************************************************/ +/* + affiche le chevelu d'un module calcule en mode rapide. + retourne: rien +*/ +{ +CHEVELU* local_chevelu; +int ii; + + if((m_Pcb->m_Status_Pcb & CHEVELU_LOCAL_OK) == 0) return ; + + local_chevelu = local_liste_chevelu; + ii = nb_local_chevelu; + + GRSetDrawMode(DC, GR_XOR); + + while( ii-- > 0 ) + { + if(local_chevelu->status & LOCAL_CHEVELU) + { + GRLine(&DrawPanel->m_ClipBox, DC, + local_chevelu->pad_start->m_Pos.x - g_Offset_Module.x, + local_chevelu->pad_start->m_Pos.y - g_Offset_Module.y, + local_chevelu->pad_end->m_Pos.x - g_Offset_Module.x, + local_chevelu->pad_end->m_Pos.y - g_Offset_Module.y, + YELLOW); + } + else + { + GRLine(&DrawPanel->m_ClipBox, DC, + local_chevelu->pad_start->m_Pos.x - g_Offset_Module.x, + local_chevelu->pad_start->m_Pos.y - g_Offset_Module.y, + local_chevelu->pad_end->m_Pos.x, + local_chevelu->pad_end->m_Pos.y, + g_DesignSettings.m_RatsnestColor); + } + local_chevelu++; + } +} + + + +/*********************************************************************************************/ +/* int * WinEDA_BasePcbFrame::build_ratsnest_pad(D_PAD * pad_ref, const wxPoint & refpos) */ +/*********************************************************************************************/ + +/* + construction de la liste en mode de calcul rapide pour affichage + en temps reel du chevelu d'un pad lors des tracés d'une piste démarrant + sur ce pad. + + parametres d'appel: + pad_ref ( si null : mise a 0 du nombre de chevelus ) + ox, oy = coord de l'extremite de la piste en trace + init (flag) + = 0 : mise a jour des chevelu + <> 0: creation de la liste + retourne: adresse memoire disponible +*/ + +/* routine locale de tri par longueur de links utilisee par la fonction QSORT */ +static int sort_by_localnetlength(int * ref, int * compare) +{ +int * org = (int*)adr_lowmem; +int ox = *org++; +int oy = *org++; +int lengthref, lengthcmp; + + lengthref = abs( *ref - ox); + ref++; + lengthref += abs( *ref - oy); // = longueur entre point origine et pad ref + lengthcmp = abs( *compare - ox); + compare++; + lengthcmp += abs( *compare - oy); // = longueur entre point origine et pad comparé + + return( lengthref - lengthcmp ); +} + +/****************************************************************************************/ +int * WinEDA_BasePcbFrame::build_ratsnest_pad(EDA_BaseStruct * ref, + const wxPoint & refpos, bool init) +/****************************************************************************************/ +{ +int ii; +int * pt_coord, * base_data; +int current_net_code = 0, conn_number = 0; +LISTE_PAD * padlist; +D_PAD * pad_ref = NULL; + + if( ((m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 ) || + ((m_Pcb->m_Status_Pcb & LISTE_PAD_OK) == 0) ) + { + nb_local_chevelu = 0; + return(NULL); + } + + + base_data = pt_coord = (int *) adr_lowmem; + local_liste_chevelu = (CHEVELU *) pt_coord; + if (init) + { + nb_local_chevelu = 0; + if(ref == NULL) return(NULL); + + switch ( ref->m_StructType ) + { + case TYPEPAD: + pad_ref = (D_PAD*) ref; + current_net_code = pad_ref->m_NetCode; + conn_number = pad_ref->m_physical_connexion; + break; + + case TYPETRACK: + case TYPEVIA: + { + TRACK *track_ref = (TRACK*) ref; + current_net_code = track_ref->m_NetCode; + conn_number = track_ref->m_Sous_Netcode; + break; + } + + } + if ( current_net_code <= 0 ) return NULL; + + *pt_coord = refpos.x; pt_coord++; + *pt_coord = refpos.y; pt_coord++; + + if( m_Pcb->m_Ratsnest == NULL ) return(NULL); + + padlist = m_Pcb->m_Pads; + for( ii = 0 ;ii < m_Pcb->m_NbPads; padlist++, ii++) + { + D_PAD * pad = *padlist; + if( pad->m_NetCode != current_net_code ) continue; + if( pad == pad_ref ) continue; + if( !pad->m_physical_connexion || (pad->m_physical_connexion != conn_number) ) + { + *pt_coord = pad->m_Pos.x; pt_coord++; + *pt_coord = pad->m_Pos.y; pt_coord++; + nb_local_chevelu++; + } + } + } /* Fin Init */ + + else if( nb_local_chevelu ) + { + *pt_coord = refpos.x; *(pt_coord+1) = refpos.y; + } + + qsort(base_data + 2,nb_local_chevelu,2*sizeof(int), + (int(*)(const void *, const void *))sort_by_localnetlength) ; + return pt_coord; +} + +/*******************************************************/ +void WinEDA_BasePcbFrame::trace_ratsnest_pad(wxDC * DC) +/*******************************************************/ +/* + affiche le "chevelu" d'un pad lors des trace de segments de piste +*/ +{ +int * pt_coord; +int ii; +int refX, refY; + + if((m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0) return; + if( nb_local_chevelu == 0 ) return; + if ( local_liste_chevelu == NULL ) return; + + pt_coord = (int*) local_liste_chevelu; + refX = *pt_coord; pt_coord++; + refY = *pt_coord; pt_coord++; + + GRSetDrawMode(DC, GR_XOR); + for( ii = 0; ii < nb_local_chevelu; ii++) + { + if ( ii >= g_MaxLinksShowed ) break; + GRLine(&DrawPanel->m_ClipBox, DC, refX, refY, *pt_coord, *(pt_coord+1), YELLOW); + pt_coord += 2; + } +} + diff --git a/pcbnew/reglage.cpp b/pcbnew/reglage.cpp new file mode 100644 index 0000000000..53ea4d1f77 --- /dev/null +++ b/pcbnew/reglage.cpp @@ -0,0 +1,281 @@ + /********************************************/ + /* PCBNEW - Gestion des Options et Reglages */ + /********************************************/ + + /* Fichier reglage.cpp */ + +/* + Affichage et modifications des parametres de travail de PcbNew + Parametres = dimensions des via, pistes, isolements, options... +*/ + + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "pcbplot.h" + +#include "protos.h" + +enum { + SAVE_CFG = 1000, + DEL_LIB, + ADD_LIB, + INSERT_LIB, + FORMAT_NETLIST + }; + +/* Routines Locales */ + + /*************************************************/ + /* classe derivee pour la frame de Configuration */ + /*************************************************/ + +class WinEDA_ConfigFrame: public wxDialog +{ +public: + + WinEDA_PcbFrame * m_Parent; + wxListBox * ListLibr; + int LibModified; + + WinEDA_EnterText * m_TextLibDir; + WinEDA_EnterText * m_TextHelpModulesFileName; + +public: + // Constructor and destructor + WinEDA_ConfigFrame(WinEDA_PcbFrame *parent,const wxPoint& pos); + ~WinEDA_ConfigFrame(void) {}; + +private: + void OnCloseWindow(wxCloseEvent & event); + void SaveCfg(wxCommandEvent& event); + void LibDelFct(wxCommandEvent& event); + void LibInsertFct(wxCommandEvent& event); + void SetNewOptions(void); + + DECLARE_EVENT_TABLE() + +}; +/* Construction de la table des evenements pour WinEDA_ConfigFrame */ +BEGIN_EVENT_TABLE(WinEDA_ConfigFrame, wxDialog) + EVT_BUTTON(SAVE_CFG, WinEDA_ConfigFrame::SaveCfg) + EVT_BUTTON(DEL_LIB, WinEDA_ConfigFrame::LibDelFct) + EVT_BUTTON(ADD_LIB, WinEDA_ConfigFrame::LibInsertFct) + EVT_BUTTON(INSERT_LIB, WinEDA_ConfigFrame::LibInsertFct) + EVT_CLOSE(WinEDA_ConfigFrame::OnCloseWindow) +END_EVENT_TABLE() + + + +/*****************************************************************/ +void WinEDA_PcbFrame::InstallConfigFrame(const wxPoint & pos) +/*****************************************************************/ +{ +WinEDA_ConfigFrame * CfgFrame = new WinEDA_ConfigFrame(this, pos); + CfgFrame->ShowModal(); CfgFrame->Destroy(); +} + + + /************************************************************/ + /* Constructeur de WinEDA_ConfigFrame: la fenetre de config */ + /************************************************************/ + +#define X_SIZE 450 +#define Y_SIZE 380 +WinEDA_ConfigFrame::WinEDA_ConfigFrame(WinEDA_PcbFrame *parent, + const wxPoint& framepos): + wxDialog(parent, -1, "", framepos, wxSize(X_SIZE, Y_SIZE), + DIALOG_STYLE ) +{ +wxPoint pos; +wxSize size; +wxString title; +wxButton * Button; + + m_Parent = parent; + SetFont(*g_DialogFont); + + title = _("from ") + EDA_Appl->m_CurrentOptionFile; + SetTitle(title); + + LibModified = FALSE; + + /* Creation des boutons de commande */ + pos.x = 10; pos.y = 5; + Button = new wxButton(this, SAVE_CFG, _("Save Cfg"), pos); + Button->SetForegroundColour(*wxRED); + + pos.x = 190; + Button = new wxButton(this, DEL_LIB, _("Del"), pos); + Button->SetForegroundColour(*wxRED); + + pos.x += Button->GetSize().x; + Button = new wxButton(this, ADD_LIB, _("Add"), pos ); + Button->SetForegroundColour(wxColor(0,80,0)); + + pos.x += Button->GetSize().x; + Button = new wxButton(this, INSERT_LIB, _("Ins"), pos ); + Button->SetForegroundColour(*wxBLUE); + + pos.x = 190; pos.y += 35; + wxStaticText * Msg = new wxStaticText(this, -1, _("Lib Modules:"), pos ); + pos.y += 15; + ListLibr = new wxListBox(this, + -1, + pos, wxSize(X_SIZE - pos.x -10,190), + 0,NULL, + wxLB_ALWAYS_SB|wxLB_SINGLE); + Msg->SetForegroundColour(wxColour(200,0,0) ); + + if ( g_LibName_List ) + { + LibNameItem * libnamestruct = g_LibName_List->FirstLib; + + for ( ; libnamestruct != NULL; libnamestruct = libnamestruct->Pnext ) + { + ListLibr->Append(libnamestruct->m_Name); + } + } + + +wxString text; +#define DELTA_VPOS 17 + size.x = 120; size.y = 90; + pos.y = 100; pos.x = 10; + new wxStaticBox(this, -1,_("Files ext:"), pos, size); + + pos.x += 5; pos.y += DELTA_VPOS; + text = _("Board ext: ") + PcbExtBuffer; + new wxStaticText(this, -1,text , pos); + + pos.x += 5; pos.y += DELTA_VPOS; + text = _("Cmp ext: ") + NetCmpExtBuffer; + new wxStaticText(this, -1,text , pos); + + pos.y += DELTA_VPOS; + text = _("Lib ext: ") + LibExtBuffer; + new wxStaticText(this, -1,text , pos); + + pos.y += DELTA_VPOS; + text = _("Net ext: ") + NetExtBuffer; + new wxStaticText(this, -1,text , pos); + + pos.x = 10; pos.y = 260; + size.x = X_SIZE - pos.x - 10; size.y = -1; + m_TextLibDir = new WinEDA_EnterText(this, + _("Lib Modules Dir:"), g_UserLibDirBuffer, + pos, size); + + pos.y += m_TextLibDir->GetDimension().y + 25; + wxString DocModuleFileName = + EDA_Appl->m_EDA_CommonConfig->Read("module_doc_file", "pcbnew/footprints.pdf"); + m_TextHelpModulesFileName = new WinEDA_EnterText(this, + _("Module Doc File:"), DocModuleFileName, + pos, size); + + size.x = X_SIZE; + size.y = pos.y + m_TextHelpModulesFileName->GetDimension().y + 10; + + SetClientSize(size); +} + + + /*****************************************************************/ + /* Fonctions de base de WinEDA_ConfigFrame: la fenetre de config */ + /*****************************************************************/ + +void WinEDA_ConfigFrame::OnCloseWindow(wxCloseEvent & event) +{ + SetNewOptions(); + EndModal(0); +} + +/********************************************/ +void WinEDA_ConfigFrame::SetNewOptions(void) +/********************************************/ +{ + g_UserLibDirBuffer = m_TextLibDir->GetData(); + EDA_Appl->m_EDA_CommonConfig->Write("module_doc_file", + m_TextHelpModulesFileName->GetData()); + SetRealLibraryPath("modules"); +} + + +/******************************************************/ +void WinEDA_ConfigFrame::SaveCfg(wxCommandEvent& event) +/******************************************************/ +{ + SetNewOptions(); + m_Parent->Update_config(this); +} + + +/********************************************************/ +void WinEDA_ConfigFrame::LibDelFct(wxCommandEvent& event) +/********************************************************/ +{ +int ii; +wxString LibNameSelected; + + ii = ListLibr->GetSelection(); + if ( ii < 0 ) return; + + LibNameSelected = ListLibr->GetStringSelection(); + + g_LibName_List->RemoveLibName(LibNameSelected); + + ListLibr->Delete(ii); + LibModified = TRUE; +} + + +/*************************************************************/ +void WinEDA_ConfigFrame::LibInsertFct(wxCommandEvent& event) +/*************************************************************/ +/* Insere ou ajoute une librairie a la liste existante: + La nouvelle librairie est mise avant (insert) ou apres (ajout) + la librairie sélectionnée +*/ +{ +int ii; +wxString fullfilename, ShortLibName; +wxString mask ="*"; + + ii = ListLibr->GetSelection(); + if ( ii < 0 ) ii = 0; + if( event.GetId() == ADD_LIB) + { + if( g_LibName_List->FirstLib != NULL ) ii ++; /* Ajout apres selection */ + } + + SetNewOptions(); + mask += LibExtBuffer; + g_RealLibDirBuffer.Replace("\\","/"); + + fullfilename = EDA_FileSelector( _("library files:"), + g_RealLibDirBuffer, /* Chemin par defaut */ + "", /* nom fichier par defaut */ + LibExtBuffer, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + 0, + TRUE + ); + + if ( fullfilename == "" ) return; + + ShortLibName = + MakeReducedFileName(fullfilename, g_RealLibDirBuffer, LibExtBuffer); + + //Addition ou insertion de la librarire + LibModified = TRUE; +wxString SList[1]; + SList[0] =wxString(ShortLibName); + if ( g_LibName_List->InsertLibName(SList[0], ii) ) + ListLibr->InsertItems(1,SList,ii); + else DisplayError(this, _("Library exists! No Change")); +} + diff --git a/pcbnew/router.cpp b/pcbnew/router.cpp new file mode 100644 index 0000000000..a81c054f36 --- /dev/null +++ b/pcbnew/router.cpp @@ -0,0 +1,568 @@ + /****************************************/ + /* EDITEUR de PCB: Menus d'AUTOROUTAGE: */ + /****************************************/ +// #define ROUTER + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "cell.h" +#include "trigo.h" + +#include "protos.h" + +#define ROUTER + +#define PSCALE 1 + +/* routines externes */ +int ReadListeSegmentDescr(wxDC * DC, FILE * File, + TRACK * PtSegm,DrawStructureType ItemType, + int * LineNum, int NumSegm); + + +/* routines internes */ +static void Out_Pads(BOARD * Pcb, FILE * outfile); +static int GenEdges(BOARD * Pcb, FILE * outfile); +static void GenExistantTracks(BOARD * Pcb, FILE *outfile, int current_net_code, int type); +static void ReturnNbViasAndTracks(BOARD * Pcb, int netcode, int * nb_vias, int *nb_tracks); + +/* variables locales */ +static int min_layer, max_layer; + + + +/******************************************/ +void WinEDA_PcbFrame::GlobalRoute(wxDC * DC) +/******************************************/ +{ +#ifdef ROUTER +FILE * outfile; +wxString FullFileName, ExecFileName, msg; +int ii; +int net_number; + +#ifdef __UNIX__ + ExecFileName = FindKicadFile(wxT("anneal")); +#else + ExecFileName = FindKicadFile(wxT("anneal.exe")); +#endif + /* test de la presence du fichier et execution si present */ + if( ! wxFileExists(ExecFileName) ) + { + msg.Printf( wxT("File <%s> not found"), ExecFileName.GetData()); + DisplayError(this, msg, 20) ; + return; + } + + /* Calcule du nom du fichier intermediaire de communication */ + FullFileName = m_CurrentScreen->m_FileName; + ChangeFileNameExt(FullFileName,wxT(".ipt")); + + if( (outfile = wxFopen(FullFileName, wxT("wt"))) == NULL ) + { + msg = _("Unable to create temporary file ") + FullFileName; + DisplayError(this, msg,20); + return; + } + + msg = _("Create temporary file ") + FullFileName; + SetStatusText(msg); + + /* calcul ratsnest */ + m_Pcb->m_Status_Pcb = 0 ; + Compile_Ratsnest(DC, TRUE); + + m_Pcb->ComputeBoundaryBox(); + + // Sortie de la dimension hors tout du pcb (dimensions + marge + g_GridRoutingSize) +#define B_MARGE 1000 // en 1/10000 inch + fprintf(outfile,"j %d %d %d %d", + (-B_MARGE - g_GridRoutingSize + m_Pcb->m_BoundaryBox.GetX() )/PSCALE, + (-B_MARGE - g_GridRoutingSize + m_Pcb->m_BoundaryBox.GetY() )/PSCALE, + (B_MARGE + g_GridRoutingSize + m_Pcb->m_BoundaryBox.GetRight() )/PSCALE, + (B_MARGE + g_GridRoutingSize + m_Pcb->m_BoundaryBox.GetBottom() )/PSCALE); + + /* calcul du nombre de couches cuivre */ + min_layer = 1; /* -> couche soudure = min layer */ + max_layer = m_Pcb->m_BoardSettings->m_CopperLayerCount; + + fprintf(outfile," %d %d", min_layer, max_layer); + + net_number = m_Pcb->m_NbNets; + + fprintf(outfile," %d", net_number); + + fprintf(outfile," %d", g_GridRoutingSize / PSCALE); + + fprintf(outfile," %d %d %d", /* isolation Pad, track, via */ + g_DesignSettings.m_TrackClearence/PSCALE, + g_DesignSettings.m_TrackClearence/PSCALE, + g_DesignSettings.m_TrackClearence/PSCALE ); + + + fprintf(outfile," 0"); /* via type */ + + fprintf(outfile," %d", g_DesignSettings.m_CurrentViaSize/PSCALE); /* via diam */ + + fprintf(outfile," n"); /* via enterree non permise */ + + fprintf(outfile," 0"); /* unused */ + + fprintf(outfile," %d", g_DesignSettings.m_CurrentTrackWidth /PSCALE); /* default track width */ + + fprintf(outfile," 0"); /* unused */ + + fprintf(outfile," 0 0 0\n"); /* unused */ + + fprintf(outfile,"k 0 0 0 0 0 0 0 0 0 0\n"); /* spare record */ + + fprintf(outfile,"m 0 0 0 0 0 0 0 0 0 0\n"); /* cost record */ + + for ( ii = min_layer; ii <= max_layer; ii++ ) + { + int dir; + dir = 3; /* horizontal */ + if (ii & 1 ) dir = 1; /* vertical */ + fprintf(outfile,"l %d %d\n", ii, dir); /* layer direction record */ + } + + Out_Pads(m_Pcb, outfile); + GenEdges(m_Pcb, outfile); + + fclose( outfile ); + + ExecFileName += wxT(" ") + FullFileName; + + Affiche_Message(ExecFileName); + + wxExecute(ExecFileName); + +#else + wxMessageBox( wxT("TODO, currently not available")); +#endif +} + + +/************************************************/ +static void Out_Pads(BOARD * Pcb, FILE * outfile) +/************************************************/ +{ +D_PAD * pt_pad ; +//MODULE * Module; +int netcode, mod_num, nb_pads, plink; +LISTE_PAD * pt_liste_pad, * pt_start_liste, + * pt_end_liste, * pt_liste_pad_limite; +int pin_min_layer, pin_max_layer; +int no_conn = Pcb->m_NbPads+1; /* valeur incrementee pour indiquer + que le pad n'est pas deja connecte a une piste*/ + + pt_liste_pad = pt_start_liste = Pcb->m_Pads; + pt_liste_pad_limite = pt_start_liste + Pcb->m_NbPads; + + if( pt_liste_pad == NULL ) return; + + netcode = (*pt_liste_pad)->m_NetCode; + nb_pads = 1; plink = 0; + for ( ; pt_liste_pad < pt_liste_pad_limite ; ) + { + /* Recherche de la fin de la liste des pads du net courant */ + for( pt_end_liste = pt_liste_pad + 1 ; ; pt_end_liste++) + { + if (pt_end_liste >= pt_liste_pad_limite ) break ; + if ((*pt_end_liste)->m_NetCode != netcode ) break ; + nb_pads++; + } + + /* fin de liste trouvee : */ + if( netcode > 0 ) + { + int nb_vias, nb_tracks; + ReturnNbViasAndTracks(Pcb, netcode, &nb_vias, &nb_tracks); + if ( nb_pads < 2 ) + { + wxString Line; + EQUIPOT * equipot = GetEquipot(Pcb, netcode); + Line.Printf( wxT("Warning: %d pad, net %s"), + nb_pads, equipot->m_Netname.GetData()); + DisplayError(NULL, Line,20); + } + fprintf(outfile,"r %d %d %d %d %d %d 1 1\n", + netcode, nb_pads, nb_vias+nb_pads, nb_tracks, 0, + g_DesignSettings.m_CurrentTrackWidth /PSCALE); + } + + for( ;pt_liste_pad < pt_end_liste ; pt_liste_pad++) + { + pt_pad = *pt_liste_pad; + netcode = pt_pad->m_NetCode; + plink = pt_pad->m_physical_connexion; + /* plink = numero unique si pad non deja connecte a une piste */ + if (plink <= 0 ) plink = no_conn++; + + if( netcode <= 0 ) /* pad non connecte */ + fprintf(outfile,"u 0"); + else + fprintf(outfile,"p %d", netcode); + /* position */ + fprintf(outfile," %d %d", + pt_pad->m_Pos.x/PSCALE, pt_pad->m_Pos.y/PSCALE); + + /* layers */ + pin_min_layer = 0; pin_max_layer = max_layer; + + if( (pt_pad->m_Masque_Layer & ALL_CU_LAYERS) == CUIVRE_LAYER ) + pin_min_layer = pin_max_layer = min_layer; + + else if( (pt_pad->m_Masque_Layer & ALL_CU_LAYERS) == CMP_LAYER ) + pin_min_layer = pin_max_layer = max_layer; + + fprintf(outfile," %d %d", pin_min_layer, pin_min_layer); + + /* link */ + fprintf(outfile," %d", plink); + + /* type of device (1 = IC, 2 = edge conn, 3 = discret, 4 = other */ + switch (pt_pad->m_Attribut) + { + case STANDARD: + case SMD: + fprintf(outfile," %d", 1); + break; + case CONN: fprintf(outfile," %d", 2); + break; + case P_HOLE: + case MECA: + fprintf(outfile," %d", 4); + break; + } + + /* pin number */ + fprintf(outfile," %ld", (long)(pt_pad->m_Padname)); + + /* layer size number (tj = 1) */ + fprintf(outfile," %d", 1); + + /* device number */ + mod_num = 1; /* A CHANGER */ + fprintf(outfile," %d", mod_num); + + /* orientations pins 1 et 2 */ + fprintf(outfile," x"); + + /* spare */ + fprintf(outfile," 0 0\n"); + + /* output layer size record */ + fprintf(outfile,"q"); + switch (pt_pad->m_PadShape) /* out type, dims */ + { + case CIRCLE: + fprintf(outfile," c 0 %d 0", + pt_pad->m_Size.x/PSCALE ); + break; + + case OVALE: + case RECT: + case TRAPEZE: + int lmax = pt_pad->m_Size.x; + int lmin = pt_pad->m_Size.y; + int angle = pt_pad->m_Orient/10; + while (angle < 0 ) angle += 180; + while (angle > 180 ) angle -= 180; + while (angle > 135 ) + { + angle -= 90; + EXCHG(lmax,lmin); + } + fprintf(outfile," r %d %d %d", + angle, + lmax /PSCALE, lmin/PSCALE ); + break; + } + /* layers */ + fprintf(outfile," %d %d\n", pin_min_layer, pin_max_layer); + + } /* fin generation liste pads pour 1 net */ + + if(netcode) + { + GenExistantTracks(Pcb, outfile, netcode, TYPEVIA); + GenExistantTracks(Pcb, outfile, netcode, TYPETRACK); + } + + nb_pads = 1; + pt_liste_pad = pt_start_liste = pt_end_liste; + if(pt_start_liste < pt_liste_pad_limite) + netcode = (*pt_start_liste)->m_NetCode ; + } +} + + +/**************************************************************************/ +static void ReturnNbViasAndTracks(BOARD * Pcb, int netcode, int * nb_vias, + int *nb_tracks) +/**************************************************************************/ +/* calcule le nombre de vias et segments de pistes pour le net netcode +*/ +{ +TRACK * track; + + *nb_vias = 0; + *nb_tracks = 0; + + track = Pcb->m_Track; + if( track == NULL ) return; + + for ( ; track != NULL ; track = (TRACK*) track->Pnext ) + { + if( track->m_NetCode > netcode ) return; + if( track->m_NetCode != netcode ) continue; + if(track->m_StructType == TYPEVIA ) (*nb_vias)++; + if(track->m_StructType == TYPETRACK ) (*nb_tracks)++; + } +} + +/*************************************************************/ +static void GenExistantTracks(BOARD * Pcb, FILE *outfile, + int current_net_code, int type) +/*************************************************************/ +/* generation des pistes existantes */ +{ +int netcode, plink; +int via_min_layer, via_max_layer; +TRACK * track; + + + track = Pcb->m_Track; + if( track == NULL ) return; + + + for ( ; track != NULL ; track = (TRACK*) track->Pnext ) + { + netcode = track->m_NetCode; + if( netcode > current_net_code ) return; + if( netcode != current_net_code ) continue; + plink = track->m_Sous_Netcode; + via_min_layer = track->m_Layer; + + if(track->m_StructType != type ) continue; + + if(track->m_StructType == TYPEVIA ) + { + via_min_layer &= 15; + via_max_layer = (track->m_Layer >> 4) & 15; + + if (via_min_layer == via_max_layer) + { + track->m_Layer = 0xF; + via_min_layer = 0; via_max_layer = 15; + } + + if( via_max_layer < via_min_layer ) + EXCHG(via_max_layer,via_min_layer); + + if(via_max_layer == CMP_N) via_max_layer = max_layer; + else via_max_layer++; + + if(via_min_layer == CUIVRE_N) via_min_layer = min_layer; + else via_min_layer++; + + fprintf(outfile,"v 0 "); + fprintf(outfile," %d %d", track->m_Start.x/PSCALE, track->m_Start.y/PSCALE); + fprintf(outfile," %d %d", via_min_layer, via_max_layer); + fprintf(outfile," %d", plink); + fprintf(outfile," %d\n", 1); + /* layer size record */ + fprintf(outfile,"q c 0 %d 0 0 0\n", track->m_Width/PSCALE ); + } + + if(track->m_StructType == TYPETRACK ) + { + fprintf(outfile,"t 0 %d", track->m_Width/PSCALE); + fprintf(outfile," %d %d", track->m_Start.x/PSCALE, track->m_Start.y/PSCALE); + fprintf(outfile," %d %d", track->m_End.x/PSCALE, track->m_End.y/PSCALE); + + if(via_min_layer == CMP_N) via_min_layer = max_layer; + else via_min_layer++; + fprintf(outfile," %d", via_min_layer); + + fprintf(outfile," %d\n", 1); /*Number of corners */ + + /* output corner */ + fprintf(outfile,"c"); + fprintf(outfile," %d %d\n", track->m_End.x/PSCALE, track->m_End.y/PSCALE); + } + } +} + +/***********************************************/ +static int GenEdges(BOARD * Pcb, FILE * outfile) +/***********************************************/ +/* Generation des contours (edges). + Il sont générés comme des segments de piste placés sur chaque couche routable. +*/ +{ +#define NB_CORNERS 4 + +EDA_BaseStruct * PtStruct; +DRAWSEGMENT * PtDrawSegment; +int ii; +int dx, dy, width, angle; +int ox, oy, fx, fy; +wxPoint lim[4]; +int NbItems = 0; + + /* impression des contours */ + for ( PtStruct = Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Pnext) + { + if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; + + PtDrawSegment = (DRAWSEGMENT *) PtStruct; + if( PtDrawSegment->m_Layer != EDGE_N) continue; + + fx = PtDrawSegment->m_End.x;ox = PtDrawSegment->m_Start.x; + fy = PtDrawSegment->m_End.y; oy = PtDrawSegment->m_Start.y; + dx = fx - ox; dy = fy - oy; + if( (dx == 0) && (dy == 0) ) continue; + + /* elimination des segments non horizontaux, verticaux ou 45 degres, + non gérés par l'autorouteur */ + if( (dx != 0) && (dy != 0) && (abs(dx) != abs(dy)) ) + continue; + + NbItems++; + if( outfile == NULL ) continue; /* car simple decompte des items */ + + + /* generation de la zone interdite */ + if( dx < 0 ) + { + EXCHG(ox,fx); EXCHG(oy,fy); dx = -dx; dy = -dy; + } + if( (dx == 0) && (dy < 0 ) ) + { + EXCHG(oy,fy);dy = -dy; + } + + width = PtDrawSegment->m_Width; + width += g_GridRoutingSize; + + angle = - ArcTangente(dy, dx); + if (angle % 450)/* not H, V or X */ + { + wxBell(); + continue; + } + + /* 1er point */ + dx = -width; dy = - width; + RotatePoint(&dx, &dy, angle); + lim[0].x = ox + dx; + lim[0].y = oy + dy; + + /* 2eme point */ + RotatePoint(&dx, &dy, -900); + lim[1].x = fx + dx; + lim[1].y = fy + dy; + + /* 3eme point */ + RotatePoint(&dx, &dy, -900); + lim[2].x = fx + dx; + lim[2].y = fy + dy; + + /* 4eme point */ + RotatePoint(&dx, &dy, -900); + lim[3].x = ox + dx; + lim[3].y = oy + dy; + + if ( angle % 900 ) + { + } + /* mise a l'echelle */ + for( ii = 0; ii < 4; ii++ ) + { + lim[ii].x = (int)( ( (double)lim[ii].x + 0.5) / PSCALE); + lim[ii].y = (int)( ( (double)lim[ii].y + 0.5) / PSCALE); + } + + /* sortie du 1er point */ + fprintf(outfile,"n %d %d %ld %ld %d\n", + 0, /* layer number, 0 = all layers */ + 0, /* -1 (no via), 0 (no via no track), 1 (no track) */ + (long)lim[0].x, (long)lim[0].y, + NB_CORNERS); + + /* sortie des autres points */ + for( ii = 1; ii < 4; ii++ ) + { + fprintf(outfile,"c %ld %ld\n", + (long)lim[ii].x, (long)lim[ii].y); + } + } + + return NbItems; +} + + +/****************************************************/ +void WinEDA_PcbFrame::ReadAutoroutedTracks(wxDC * DC) +/****************************************************/ +{ +char Line[1024]; +wxString FullFileName, msg; +int LineNum = 0, nbtracks, NbTrack = 0; +FILE * File; + + /* Calcule du nom du fichier intermediaire de communication */ + FullFileName = m_CurrentScreen->m_FileName; + ChangeFileNameExt(FullFileName, wxT(".trc")); + + if( (File = wxFopen(FullFileName, wxT("rt"))) == NULL ) + { + msg = _("Unable to find data file ") + FullFileName; + DisplayError(this, msg, 20); + return; + } + else + { + msg = _("Reading autorouter data file ") + FullFileName; + Affiche_Message(msg); + } + + nbtracks = 0; + while( GetLine(File, Line, &LineNum ) != NULL ) + { + if(strnicmp(Line,"$EndPCB",6) == 0) break; + + if(strnicmp(Line,"$TRACK",6) == 0) + { + TRACK * StartTrack = m_Pcb->m_Track; + + for( ;StartTrack != NULL; StartTrack = (TRACK*)StartTrack->Pnext) + { + if( StartTrack->Pnext == NULL ) break; + } + + nbtracks = ReadListeSegmentDescr(DC, File, StartTrack, TYPETRACK, + &LineNum, NbTrack); + m_Pcb->m_NbSegmTrack += nbtracks; + break; + } + } + + fclose(File); + + if( nbtracks == 0 ) DisplayError(this, wxT("Warning: No tracks"), 10); + else + { + m_Pcb->m_Status_Pcb = 0; + m_CurrentScreen->SetModify(); + } + + Compile_Ratsnest(DC, TRUE); + if( nbtracks ) m_CurrentScreen->SetRefreshReq(); +} + diff --git a/pcbnew/sel_layer.cpp b/pcbnew/sel_layer.cpp new file mode 100644 index 0000000000..7be0ac3e20 --- /dev/null +++ b/pcbnew/sel_layer.cpp @@ -0,0 +1,277 @@ + /* Set up the basic primitives for Layer control */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + + +/* Variables locales */ + +/* Fonctions locales: */ + +enum layer_sel_id { + ID_LAYER_OK = 1800, + ID_LAYER_CANCEL, + ID_LAYER_SELECT_TOP, + ID_LAYER_SELECT_BOTTOM, + ID_LAYER_SELECT +}; + + +/***********************************************/ +/* classe pour la frame de selection de layers */ +/***********************************************/ + +class WinEDA_SelLayerFrame: public wxDialog +{ +private: + WinEDA_BasePcbFrame *m_Parent; + wxRadioBox * m_LayerList; + int m_LayerId[NB_LAYERS]; + +public: + // Constructor and destructor + WinEDA_SelLayerFrame(WinEDA_BasePcbFrame *parent, int default_layer, + int min_layer, int max_layer); + ~WinEDA_SelLayerFrame(void) {}; + +private: + void Sel_Layer(wxCommandEvent& event); + void Cancel(wxCommandEvent& event); + DECLARE_EVENT_TABLE() + +}; +/* Table des evenements pour WinEDA_SelLayerFrame */ +BEGIN_EVENT_TABLE(WinEDA_SelLayerFrame, wxDialog) + EVT_BUTTON(ID_LAYER_OK, WinEDA_SelLayerFrame::Sel_Layer) + EVT_BUTTON(ID_LAYER_CANCEL, WinEDA_SelLayerFrame::Cancel) + EVT_RADIOBOX(ID_LAYER_SELECT, WinEDA_SelLayerFrame::Sel_Layer) +END_EVENT_TABLE() + +/***********************************************************************************/ +int WinEDA_BasePcbFrame::SelectLayer(int default_layer, int min_layer, int max_layer) +/***********************************************************************************/ +/* Install the dialog box for layer selection + default_layer = Preselection + min_layer = val min de layer selectionnable (-1 si pas de val mini) + max_layer = val max de layer selectionnable (-1 si pas de val maxi) +*/ +{ +int layer; + WinEDA_SelLayerFrame * frame = + new WinEDA_SelLayerFrame(this, default_layer,min_layer, max_layer); + layer = frame->ShowModal(); frame->Destroy(); + DrawPanel->MouseToCursorSchema(); + return layer; +} + + +/***********************************************************************/ +WinEDA_SelLayerFrame::WinEDA_SelLayerFrame(WinEDA_BasePcbFrame *parent, + int default_layer, int min_layer, int max_layer): + wxDialog(parent, -1, _("Select Layer:"),wxPoint(-1,-1), + wxSize(470, 250), + DIALOG_STYLE ) +/***********************************************************************/ +{ +wxButton * Button; +int ii, yy, xx; +wxPoint pos; +wxString LayerList[NB_LAYERS]; +int LayerCount, LayerSelect = -1; + + m_Parent = parent; + SetFont(*g_DialogFont); + + /* Construction de la liste des couches autorisées */ + LayerCount = 0; + int Masque_Layer = g_TabAllCopperLayerMask[g_DesignSettings.m_CopperLayerCount-1]; + Masque_Layer += ALL_NO_CU_LAYERS; + for ( ii = 0; ii < NB_LAYERS ; ii ++ ) + { + m_LayerId[ii] = 0; + if ( (g_TabOneLayerMask[ii] & Masque_Layer) ) + { + if ( min_layer > ii ) continue; + if ( (max_layer >= 0) && (max_layer < ii) ) break; + LayerList[LayerCount] = ReturnPcbLayerName(ii); + if ( ii == default_layer ) LayerSelect = LayerCount; + m_LayerId[LayerCount] = ii; + LayerCount++; + } + } + + pos.x = 5; pos.y = 5; + + m_LayerList = new wxRadioBox(this, ID_LAYER_SELECT, _("Layer"), + pos, wxSize(-1,-1), LayerCount, LayerList, + (LayerCount < 8) ? LayerCount : 8, wxRA_SPECIFY_ROWS); + + if ( LayerSelect >= 0 ) m_LayerList->SetSelection(LayerSelect); + + m_LayerList->GetSize(&xx, &yy); + pos.x += xx + 12; + Button = new wxButton(this,ID_LAYER_OK, + _("OK"), pos); + Button->SetForegroundColour(*wxBLUE); + + pos.y += Button->GetSize().y + 5; + Button = new wxButton(this,ID_LAYER_CANCEL, + _("Cancel"), pos); + Button->SetForegroundColour(*wxRED); + + /* Redimensionnement de la boite de dialogue: */ + pos.x += Button->GetSize().x + 10; + SetSize(-1, -1, pos.x , yy + 35); +} + + +/***************************************************************/ +void WinEDA_SelLayerFrame::Sel_Layer(wxCommandEvent& event) +/***************************************************************/ +{ +int ii = m_LayerId[m_LayerList->GetSelection()]; + EndModal(ii); +} + +/***************************************************************/ +void WinEDA_SelLayerFrame::Cancel(wxCommandEvent& event) +/***************************************************************/ +{ + EndModal(-1); +} + + +/*********************************************************/ +/* classe pour la frame de selection de paires de layers */ +/*********************************************************/ + +class WinEDA_SelLayerPairFrame: public wxDialog +{ +private: + WinEDA_BasePcbFrame *m_Parent; + wxRadioBox * m_LayerListTOP; + wxRadioBox * m_LayerListBOTTOM; + int m_LayerId[NB_COPPER_LAYERS]; + +public: + + // Constructor and destructor + WinEDA_SelLayerPairFrame(WinEDA_BasePcbFrame *parent); + ~WinEDA_SelLayerPairFrame(void) {}; + +private: + void Sel_Layer(wxCommandEvent& event); + void Cancel(wxCommandEvent& event); + DECLARE_EVENT_TABLE() + +}; +/* Table des evenements pour WinEDA_SelLayerPairFrame */ +BEGIN_EVENT_TABLE(WinEDA_SelLayerPairFrame, wxDialog) + EVT_BUTTON(ID_LAYER_OK, WinEDA_SelLayerPairFrame::Sel_Layer) + EVT_BUTTON(ID_LAYER_CANCEL, WinEDA_SelLayerPairFrame::Cancel) + EVT_RADIOBOX(ID_LAYER_SELECT, WinEDA_SelLayerPairFrame::Sel_Layer) +END_EVENT_TABLE() + +/***********************************************/ +void WinEDA_BasePcbFrame::SelectLayerPair(void) +/***********************************************/ +/* Affiche une double liste de layers cuivre pour selection d'une paire de layers + pour autorutage, vias... +*/ +{ + WinEDA_SelLayerPairFrame * frame = + new WinEDA_SelLayerPairFrame(this); + frame->ShowModal(); frame->Destroy(); + DrawPanel->MouseToCursorSchema(); +} + + +/*******************************************************************************/ +WinEDA_SelLayerPairFrame::WinEDA_SelLayerPairFrame(WinEDA_BasePcbFrame *parent): + wxDialog(parent, -1, _("Select Layer Pair:"),wxPoint(-1,-1), + wxSize(470, 250), DIALOG_STYLE ) +/*******************************************************************************/ +{ +wxButton * Button; +int ii, LayerCount; +int yy, xx; +wxPoint pos; +wxString LayerList[NB_COPPER_LAYERS]; +int LayerTopSelect = 0, LayerBottomSelect = 0 ; + + m_Parent = parent; + SetFont(*g_DialogFont); + +PCB_SCREEN * screen = (PCB_SCREEN *) m_Parent->m_CurrentScreen; + /* Construction de la liste des couches autorisées */ + int Masque_Layer = g_TabAllCopperLayerMask[g_DesignSettings.m_CopperLayerCount-1]; + Masque_Layer += ALL_NO_CU_LAYERS; + for ( ii = 0, LayerCount = 0; ii < NB_COPPER_LAYERS ; ii ++ ) + { + m_LayerId[ii] = 0; + if ( (g_TabOneLayerMask[ii] & Masque_Layer) ) + { + LayerList[LayerCount] = ReturnPcbLayerName(ii); + if ( ii == screen->m_Route_Layer_TOP ) + LayerTopSelect = LayerCount; + if ( ii == screen->m_Route_Layer_BOTTOM ) + LayerBottomSelect = LayerCount; + m_LayerId[LayerCount] = ii; + LayerCount++; + } + } + + pos.x = 5; pos.y = 5; + m_LayerListTOP = new wxRadioBox(this, ID_LAYER_SELECT_TOP, _("Top Layer"), + pos, wxSize(-1,-1), LayerCount, LayerList, + (LayerCount < 8) ? LayerCount : 8, wxRA_SPECIFY_ROWS); + m_LayerListTOP->SetSelection(LayerTopSelect); + + m_LayerListTOP->GetSize(&xx, &yy); + pos.x += xx + 12; + m_LayerListBOTTOM = new wxRadioBox(this, ID_LAYER_SELECT_BOTTOM, _("Bottom Layer"), + pos, wxSize(-1,-1), LayerCount, LayerList, + (LayerCount < 8) ? LayerCount : 8, wxRA_SPECIFY_ROWS); + m_LayerListBOTTOM->SetSelection(LayerBottomSelect); + + m_LayerListBOTTOM->GetSize(&xx, &yy); + pos.x += xx + 12; + Button = new wxButton(this,ID_LAYER_OK, + _("OK"), pos); + Button->SetForegroundColour(*wxBLUE); + + pos.y += Button->GetSize().y + 5; + Button = new wxButton(this,ID_LAYER_CANCEL, + _("Cancel"), pos); + Button->SetForegroundColour(*wxRED); + + /* Redimensionnement de la boite de dialogue: */ + pos.x += Button->GetSize().x + 10; + SetSize(-1, -1, pos.x , yy + 35); +} + + +/***************************************************************/ +void WinEDA_SelLayerPairFrame::Sel_Layer(wxCommandEvent& event) +/***************************************************************/ +{ +PCB_SCREEN * screen = (PCB_SCREEN *) m_Parent->m_CurrentScreen; + + screen->m_Route_Layer_TOP = m_LayerId[m_LayerListTOP->GetSelection()]; + screen->m_Route_Layer_BOTTOM = m_LayerId[m_LayerListBOTTOM->GetSelection()]; + EndModal(0); +} + +/***************************************************************/ +void WinEDA_SelLayerPairFrame::Cancel(wxCommandEvent& event) +/***************************************************************/ +{ + EndModal(-1); +} + + diff --git a/pcbnew/set_color.cpp b/pcbnew/set_color.cpp new file mode 100644 index 0000000000..8e44319c58 --- /dev/null +++ b/pcbnew/set_color.cpp @@ -0,0 +1,792 @@ +/* Set up the items and layer colors and show/no show options */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + + +/* Variables locales */ +int CurrentColor; +/* Fonctions locales: */ + +/* Macro utile : */ +#define ADR(numlayer) &g_DesignSettings.m_LayerColor[(numlayer)] + +#define BUTT_SIZE_X 25 +#define BUTT_SIZE_Y 15 + + +enum col_sel_id { + ID_COLOR_RESET_SHOW_LAYER_ON = 1800, + ID_COLOR_RESET_SHOW_LAYER_OFF, + ID_COLOR_EXIT, + ID_COLOR_CHECKBOX_ONOFF, + ID_COLOR_SETUP +}; + + /**********************************/ + /* Liste des menus de Menu_Layers */ + /**********************************/ +struct ColorButton + { + const wxString m_Title; + int m_LayerNumber; + int * m_Color; // Pointeur sur la variable couleur + bool m_NoDisplayIsColor; // TRUE si bit ITEM_NOT_SHOW de la variable Color + bool * m_NoDisplay; // Pointeur sur la variable Display on/off si ce n'est pas la var + // Color + int m_Id; + wxBitmapButton * m_Button; + int m_State; + wxCheckBox * m_CheckBox; // Option Display ON/OFF +}; + +static ColorButton Msg_Layers_Cu= +{ + _("Copper Layers"), -1 /* Title */ +}; + +static ColorButton Msg_Layers_Tech= +{ + _("Tech Layers"), -1 /* Title */ +}; + +static ColorButton Layer_1_Butt= +{ + wxEmptyString, + CUIVRE_N, /* Title */ + ADR(CUIVRE_N), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_2_Butt= +{ + wxEmptyString, + 1, /* Title */ + ADR(1), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_3_Butt= +{ + wxEmptyString, + 2, /* Title */ + ADR(2), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_4_Butt= +{ + wxEmptyString, + 3, /* Title */ + ADR(3), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_5_Butt= +{ + wxEmptyString, + 4, /* Title */ + ADR(4), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_6_Butt= +{ + wxEmptyString, + 5, /* Title */ + ADR(5), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_7_Butt= +{ + wxEmptyString, + 6, /* Title */ + ADR(6), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_8_Butt= +{ + wxEmptyString, + 7, /* Title */ + ADR(7), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_9_Butt= +{ + wxEmptyString, + 8, /* Title */ + ADR(8), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_10_Butt= +{ + wxEmptyString, + 9, /* Title */ + ADR(9), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_11_Butt= +{ + wxEmptyString, + 10, /* Title */ + ADR(10), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_12_Butt= +{ + wxEmptyString, + 11, /* Title */ + ADR(11), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_13_Butt= +{ + wxEmptyString, + 12, /* Title */ + ADR(12), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_14_Butt= +{ + wxEmptyString, + 13, /* Title */ + ADR(13), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_15_Butt= +{ + wxEmptyString, + 14, /* Title */ + ADR(14), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_16_Butt= +{ + wxEmptyString, + CMP_N, /* Title */ + ADR(CMP_N), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_17_Butt= +{ + wxEmptyString, + ADHESIVE_N_CU, /* Title */ + ADR(ADHESIVE_N_CU), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_18_Butt= +{ + wxEmptyString, + ADHESIVE_N_CMP, /* Title */ + ADR(ADHESIVE_N_CMP), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_19_Butt= +{ + wxEmptyString, + SOLDERPASTE_N_CU, /* Title */ + ADR(SOLDERPASTE_N_CU), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_20_Butt= +{ + wxEmptyString, + SOLDERPASTE_N_CMP, /* Title */ + ADR(SOLDERPASTE_N_CMP), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_21_Butt= +{ + wxEmptyString, + SILKSCREEN_N_CU, /* Title */ + ADR(SILKSCREEN_N_CU), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_22_Butt= +{ + wxEmptyString, + SILKSCREEN_N_CMP, /* Title */ + ADR(SILKSCREEN_N_CMP), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_23_Butt= +{ + wxEmptyString, + SOLDERMASK_N_CU, /* Title */ + ADR(SOLDERMASK_N_CU), /* adr du parametre optionnel */ + TRUE /* adr du parametre display on/off */ +}; + +static ColorButton Layer_24_Butt= +{ + wxEmptyString, + SOLDERMASK_N_CMP, /* Title */ + ADR(SOLDERMASK_N_CMP), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_25_Butt= +{ + wxEmptyString, + DRAW_N, /* Title */ + ADR(DRAW_N), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_26_Butt= +{ + wxEmptyString, + COMMENT_N, /* Title */ + ADR(COMMENT_N), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_27_Butt= +{ + wxEmptyString, + ECO1_N, /* Title */ + ADR(ECO1_N), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_28_Butt= +{ + wxEmptyString, + ECO2_N, /* Title */ + ADR(ECO2_N), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Layer_29_Butt= +{ + wxEmptyString, + EDGE_N, /* Title */ + ADR(EDGE_N), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + + +static ColorButton Msg_Others_Items= +{ + wxT("Others"), -1 /* Title */ +}; + +static ColorButton Via_Normale_Butt= +{ + wxT("*"), + VIA_NORMALE, /* Title */ + &g_DesignSettings.m_ViaColor[VIA_NORMALE], /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Via_Aveugle_Butt= +{ + wxT("*"), + VIA_ENTERREE, /* Title */ + &g_DesignSettings.m_ViaColor[VIA_ENTERREE], /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Via_Borgne_Butt= +{ + wxT("*"), + VIA_BORGNE, /* Title */ + &g_DesignSettings.m_ViaColor[VIA_BORGNE], /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Ratsnest_Butt= +{ + _("Ratsnest"), /* Title */ + -1, + &g_DesignSettings.m_RatsnestColor, /* adr du parametre optionnel */ + FALSE, &g_Show_Ratsnest /* adr du parametre avec flag ITEM_NOT_SHOW */ +}; + +static ColorButton Pad_Cu_Butt= +{ + _("Pad Cu"), /* Title */ + -1, + &g_PadCUColor, /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Pad_Cmp_Butt= +{ + _("Pad Cmp"), /* Title */ + -1, + &g_PadCMPColor, /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Text_Mod_Cu_Butt= +{ + _("Text Module Cu"), /* Title */ + -1, + &g_ModuleTextCUColor, /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Text_Mod_Cmp_Butt= +{ + _("Text Module Cmp"), /* Title */ + -1, + &g_ModuleTextCMPColor, /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Text_Mod_NoVisible_Butt= +{ + _("Text Module invisible"), /* Title */ + -1, + &g_ModuleTextNOVColor, /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Anchors_Butt= +{ + _("Anchors"), /* Title */ + -1, + &g_AnchorColor, /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Grid_Butt= +{ + _("Grid"), /* Title */ + -1, + &g_PcbGridColor, /* adr du parametre optionnel */ + FALSE, + &g_ShowGrid /* parametre display on/off = bit ITEM_NOT_SHOW */ +}; + +static ColorButton Show_Zones_Butt= +{ + _("Show Zones"), /* Title */ + -1, + NULL, /* adr du parametre optionnel */ + FALSE, + &DisplayOpt.DisplayZones /* adr du parametre avec flag ITEM_NOT_SHOW */ +}; + +static ColorButton Show_Pads_Noconnect_Butt= +{ + _("Show Noconnect"), /* Title */ + -1, + NULL, /* adr du parametre optionnel */ + FALSE, + &DisplayOpt.DisplayPadNoConn /* adr du parametre avec flag ITEM_NOT_SHOW */ +}; + +static ColorButton Show_Modules_Cmp_Butt= +{ + _("Show Modules Cmp"), /* Title */ + -1, + NULL, /* adr du parametre optionnel */ + FALSE, + &DisplayOpt.Show_Modules_Cmp /* adr du parametre avec flag ITEM_NOT_SHOW */ +}; + +static ColorButton Show_Modules_Cu_Butt= +{ + _("Show Modules Cu"), /* Title */ + -1, + NULL, /* adr du parametre optionnel */ + FALSE, + &DisplayOpt.Show_Modules_Cu /* adr du parametre avec flag ITEM_NOT_SHOW */ +}; + + +static ColorButton * laytool_list[] = { + &Msg_Layers_Cu, + &Layer_1_Butt, + &Layer_2_Butt, + &Layer_3_Butt, + &Layer_4_Butt, + &Layer_5_Butt, + &Layer_6_Butt, + &Layer_7_Butt, + &Layer_8_Butt, + &Layer_9_Butt, + &Layer_10_Butt, + &Layer_11_Butt, + &Layer_12_Butt, + &Layer_13_Butt, + &Layer_14_Butt, + &Layer_15_Butt, + &Layer_16_Butt, + + &Msg_Layers_Tech, + &Layer_17_Butt, + &Layer_18_Butt, + &Layer_19_Butt, + &Layer_20_Butt, + &Layer_21_Butt, + &Layer_22_Butt, + &Layer_23_Butt, + &Layer_24_Butt, + &Layer_25_Butt, + &Layer_26_Butt, + &Layer_27_Butt, + &Layer_28_Butt, + &Layer_29_Butt, +// &Layer_30_Butt, +// &Layer_31_Butt, + + &Msg_Others_Items, + &Via_Normale_Butt, + &Via_Aveugle_Butt, + &Via_Borgne_Butt, + &Ratsnest_Butt, + &Pad_Cu_Butt, + &Pad_Cmp_Butt, + &Text_Mod_Cu_Butt, + &Text_Mod_Cmp_Butt, + &Text_Mod_NoVisible_Butt, + &Anchors_Butt, + &Grid_Butt, + + &Show_Zones_Butt, + &Show_Pads_Noconnect_Butt, + &Show_Modules_Cmp_Butt, + &Show_Modules_Cu_Butt, + + NULL +}; + +/*************************************************************/ +/* classe derivee pour la frame de Configuration des couleurs*/ +/*************************************************************/ + +class WinEDA_SetColorsFrame: public wxDialog +{ +private: + WinEDA_DrawFrame *m_Parent; + +public: + + // Constructor and destructor + WinEDA_SetColorsFrame(WinEDA_DrawFrame *parent, const wxPoint& framepos); + ~WinEDA_SetColorsFrame(void) {}; + +private: + void OnQuit(wxCommandEvent& event); + void SetColor(wxCommandEvent& event); + void SetDisplayOnOff(wxCommandEvent& event); + void ResetDisplayLayersCu(wxCommandEvent& event); + DECLARE_EVENT_TABLE() + +}; +/* Table des evenements pour WinEDA_SetColorsFrame */ +BEGIN_EVENT_TABLE(WinEDA_SetColorsFrame, wxDialog) + EVT_BUTTON(ID_COLOR_RESET_SHOW_LAYER_OFF, WinEDA_SetColorsFrame::ResetDisplayLayersCu) + EVT_BUTTON(ID_COLOR_RESET_SHOW_LAYER_ON, WinEDA_SetColorsFrame::ResetDisplayLayersCu) + EVT_BUTTON(ID_COLOR_EXIT, WinEDA_SetColorsFrame::OnQuit) + EVT_CHECKBOX(ID_COLOR_CHECKBOX_ONOFF, WinEDA_SetColorsFrame::SetDisplayOnOff) + EVT_BUTTON(ID_COLOR_SETUP, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+1, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+2, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+3, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+4, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+5, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+6, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+7, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+8, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+9, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+10, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+11, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+12, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+13, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+14, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+15, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+16, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+17, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+18, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+19, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+20, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+21, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+22, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+23, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+24, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+25, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+26, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+27, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+28, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+29, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+30, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+31, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+32, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+33, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+34, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+35, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+36, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+37, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+38, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+39, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+40, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+41, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+42, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+43, WinEDA_SetColorsFrame::SetColor) + EVT_BUTTON(ID_COLOR_SETUP+44, WinEDA_SetColorsFrame::SetColor) +END_EVENT_TABLE() + +/*****************************************************/ +void DisplayColorSetupFrame(WinEDA_DrawFrame * parent, + const wxPoint & framepos) +/*****************************************************/ +{ + WinEDA_SetColorsFrame * frame = + new WinEDA_SetColorsFrame(parent, framepos); + frame->ShowModal(); frame->Destroy(); +} + + +/**********************************************************************/ +WinEDA_SetColorsFrame::WinEDA_SetColorsFrame(WinEDA_DrawFrame *parent, + const wxPoint& framepos): + wxDialog(parent, -1, _("Colors:"), framepos, + wxSize(-1, -1), + DIALOG_STYLE ) +/**********************************************************************/ +{ +#define START_Y 25 +wxBitmapButton * ButtonB; +int ii, yy, xx, butt_ID, buttcolor; +wxPoint pos; +wxSize winsize; +int w = BUTT_SIZE_X, h = BUTT_SIZE_Y; +wxString msg; + + m_Parent = parent; + SetFont(*g_DialogFont); + + pos.x = 5; pos.y = START_Y; + for ( ii = 0; laytool_list[ii] != NULL; ii++ ) + { + if( ! laytool_list[ii]->m_Color && ! laytool_list[ii]->m_NoDisplay ) + { + if( pos.y != START_Y ) + { + pos.x += w + 120; pos.y = START_Y; + } + if( laytool_list[ii]->m_LayerNumber >= 0 ) + { + if ( laytool_list[ii]->m_Title == wxT("*") ) + { + msg = g_ViaType_Name[laytool_list[ii]->m_LayerNumber]; + } + else msg = ReturnPcbLayerName(laytool_list[ii]->m_LayerNumber); + } + else + msg = wxGetTranslation(laytool_list[ii]->m_Title.GetData()); + + new wxStaticText(this, -1, msg , + wxPoint(pos.x + 10, pos.y - 18 ), wxSize(-1,-1), 0 ); + continue; + } + + if ( laytool_list[ii]->m_Id == 0 ) + laytool_list[ii]->m_Id = ID_COLOR_SETUP + ii; + butt_ID = laytool_list[ii]->m_Id; + + laytool_list[ii]->m_CheckBox = new wxCheckBox(this, + ID_COLOR_CHECKBOX_ONOFF, wxEmptyString, + pos); + + if ( laytool_list[ii]->m_NoDisplayIsColor ) + { + if ( *laytool_list[ii]->m_Color & ITEM_NOT_SHOW ) + laytool_list[ii]->m_CheckBox->SetValue(FALSE); + else laytool_list[ii]->m_CheckBox->SetValue(TRUE); + } + + else if ( laytool_list[ii]->m_NoDisplay ) + laytool_list[ii]->m_CheckBox->SetValue(*laytool_list[ii]->m_NoDisplay); + + xx = 3 + laytool_list[ii]->m_CheckBox->GetSize().x; + + if( laytool_list[ii]->m_Color ) + { + wxMemoryDC iconDC; + wxBitmap ButtBitmap(w,h); + iconDC.SelectObject( ButtBitmap ); + buttcolor = *laytool_list[ii]->m_Color & MASKCOLOR; + wxBrush Brush; + iconDC.SelectObject( ButtBitmap ); + iconDC.SetPen(*wxBLACK_PEN); + Brush.SetColour( + ColorRefs[buttcolor].m_Red, + ColorRefs[buttcolor].m_Green, + ColorRefs[buttcolor].m_Blue + ); + Brush.SetStyle(wxSOLID); + + iconDC.SetBrush(Brush); + iconDC.DrawRectangle(0,0, w, h); + + ButtonB = new wxBitmapButton(this, butt_ID, + ButtBitmap, + wxPoint(pos.x + xx, pos.y), + wxSize(w,h) ); + laytool_list[ii]->m_Button = ButtonB; + xx += 3 + w; + } + + if( laytool_list[ii]->m_LayerNumber >= 0 ) + { + if ( laytool_list[ii]->m_Title == wxT("*") ) + { + msg = g_ViaType_Name[laytool_list[ii]->m_LayerNumber]; + } + else msg = ReturnPcbLayerName(laytool_list[ii]->m_LayerNumber); + } + else + msg = wxGetTranslation(laytool_list[ii]->m_Title.GetData()); + + new wxStaticText(this,-1, msg, + wxPoint(pos.x + xx , pos.y + 1 ), + wxSize(-1,-1), 0 ); + + yy = h + 5; + pos.y += yy; + } + + pos.x = 150; pos.y = 300; + wxButton * Button = new wxButton(this,ID_COLOR_RESET_SHOW_LAYER_ON, + _("Show All"), pos); + Button->SetForegroundColour(wxColor(0,100,0)); + + pos.y += Button->GetSize().y + 2; + Button = new wxButton(this,ID_COLOR_RESET_SHOW_LAYER_OFF, + _("Show None"), pos); + Button->SetForegroundColour(wxColor(100,0,0)); + + pos.x += Button->GetSize().x + 50; + Button = new wxButton(this,ID_COLOR_EXIT, + _("Exit"), pos); + Button->SetForegroundColour(*wxBLUE); + winsize.x = 500; winsize.y = pos.y + Button->GetSize().y + 5; + SetClientSize(winsize); +} + + +/**********************************************************************/ +void WinEDA_SetColorsFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/**********************************************************************/ +{ + Close(true); // true is to force the frame to close +} + + +/**********************************************************/ +void WinEDA_SetColorsFrame::SetColor(wxCommandEvent& event) +/**********************************************************/ +{ +int ii; +int id = event.GetId(); +int color; +int w = BUTT_SIZE_X, h = BUTT_SIZE_Y; + + + color = DisplayColorFrame(this); + if ( color < 0) return; + + for ( ii = 0; laytool_list[ii] != NULL; ii++ ) + { + if( laytool_list[ii]->m_Id != id) continue; + if( laytool_list[ii]->m_Color == NULL) continue; + + if( *laytool_list[ii]->m_Color == color) break; + + *laytool_list[ii]->m_Color = color; + wxMemoryDC iconDC; + + wxBitmapButton * Button = laytool_list[ii]->m_Button; + + wxBitmap ButtBitmap = Button->GetBitmapLabel(); + iconDC.SelectObject( ButtBitmap ); + int buttcolor = *laytool_list[ii]->m_Color; + wxBrush Brush; + iconDC.SelectObject( ButtBitmap ); + iconDC.SetPen(*wxBLACK_PEN); + Brush.SetColour( + ColorRefs[buttcolor].m_Red, + ColorRefs[buttcolor].m_Green, + ColorRefs[buttcolor].m_Blue + ); + Brush.SetStyle(wxSOLID); + + iconDC.SetBrush(Brush); + iconDC.DrawRectangle(0,0, w, h); + Button->Refresh(); + SetDisplayOnOff(event); + m_Parent->m_CurrentScreen->SetRefreshReq(); + } + Refresh(FALSE); +} + + +/******************************************************************/ +void WinEDA_SetColorsFrame::SetDisplayOnOff(wxCommandEvent& event) +/******************************************************************/ +{ + for ( int ii = 0; laytool_list[ii] != NULL; ii++ ) + { + if ( laytool_list[ii]->m_CheckBox == NULL ) continue; + if ( ! laytool_list[ii]->m_NoDisplayIsColor && + (laytool_list[ii]->m_NoDisplay == NULL) ) continue; + + if ( laytool_list[ii]->m_NoDisplayIsColor ) + { + if ( laytool_list[ii]->m_CheckBox->GetValue() ) + *laytool_list[ii]->m_Color &= ~ITEM_NOT_SHOW; + else *laytool_list[ii]->m_Color |= ITEM_NOT_SHOW; + } + + else + { + *laytool_list[ii]->m_NoDisplay = laytool_list[ii]->m_CheckBox->GetValue(); + } + + m_Parent->m_CurrentScreen->SetRefreshReq(); + } +} + + +/**********************************************************************/ +void WinEDA_SetColorsFrame::ResetDisplayLayersCu(wxCommandEvent& event) +/**********************************************************************/ +{ +bool NewState = (event.GetId() == ID_COLOR_RESET_SHOW_LAYER_ON) ? TRUE : FALSE; + + for ( int ii = 1; ii < 17; ii++ ) + { + if ( laytool_list[ii]->m_CheckBox == NULL ) continue; + laytool_list[ii]->m_CheckBox->SetValue(NewState); + } + + SetDisplayOnOff(event); +} + diff --git a/pcbnew/set_grid.cpp b/pcbnew/set_grid.cpp new file mode 100644 index 0000000000..fb8f157d51 --- /dev/null +++ b/pcbnew/set_grid.cpp @@ -0,0 +1,238 @@ + /***************************************************/ + /* set_grid.cpp - Gestion de la grille utilisateur */ + /***************************************************/ +/* + Affichage et modifications des parametres de travail de PcbNew + Parametres = dimensions de la grille utilisateur +*/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" +#include + +#include "set_grid.h" + +/****************************************************************/ +void WinEDA_PcbGridFrame::AcceptPcbOptions(wxCommandEvent& event) +/****************************************************************/ +{ +double dtmp = 0; + + g_UserGrid_Unit = m_UnitGrid->GetSelection(); + m_OptGridSizeX->GetValue().ToDouble(&dtmp); g_UserGrid.x = dtmp; + m_OptGridSizeY->GetValue().ToDouble(&dtmp); g_UserGrid.y = dtmp; + + m_Parent->GetScreen()->m_UserGrid = g_UserGrid; + m_Parent->GetScreen()->m_UserGridUnit = g_UserGrid_Unit; + + EndModal(1); + + m_Parent->DrawPanel->Refresh(TRUE); +} + + + +/************************************************************/ +void WinEDA_BasePcbFrame::InstallGridFrame(const wxPoint & pos) +/************************************************************/ +{ + WinEDA_PcbGridFrame * GridFrame = + new WinEDA_PcbGridFrame(this, pos); + GridFrame->ShowModal(); GridFrame->Destroy(); +} + + +/*! + * WinEDA_PcbGridFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_PcbGridFrame, wxDialog ) + +/*! + * WinEDA_PcbGridFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_PcbGridFrame, wxDialog ) + +////@begin WinEDA_PcbGridFrame event table entries + EVT_BUTTON( wxID_OK, WinEDA_PcbGridFrame::OnOkClick ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_PcbGridFrame::OnCancelClick ) + +////@end WinEDA_PcbGridFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_PcbGridFrame constructors + */ + +WinEDA_PcbGridFrame::WinEDA_PcbGridFrame( ) +{ +} + +WinEDA_PcbGridFrame::WinEDA_PcbGridFrame( WinEDA_BasePcbFrame* parent, + const wxPoint& pos, + wxWindowID id, const wxString& caption, const wxSize& size, long style ) +{ +wxString msg; +PCB_SCREEN * screen; + + m_Parent = parent; + screen = m_Parent->GetScreen(); + + g_UserGrid = screen->m_UserGrid; + g_UserGrid_Unit = screen->m_UserGridUnit; + + Create(parent, id, caption, pos, size, style); + + if ( screen->m_UserGridUnit != INCHES ) + m_UnitGrid->SetSelection(1); + + msg.Printf( wxT("%.4f"), g_UserGrid.x ); + m_OptGridSizeX->SetValue(msg); + msg.Printf( wxT("%.4f"), g_UserGrid.y ); + m_OptGridSizeY->SetValue(msg); +} + +/*! + * WinEDA_PcbGridFrame creator + */ + +bool WinEDA_PcbGridFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_PcbGridFrame member initialisation + m_UnitGrid = NULL; + m_OptGridSizeX = NULL; + m_OptGridSizeY = NULL; +////@end WinEDA_PcbGridFrame member initialisation + +////@begin WinEDA_PcbGridFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + if (GetSizer()) + { + GetSizer()->SetSizeHints(this); + } +////@end WinEDA_PcbGridFrame creation + return true; +} + +/*! + * Control creation for WinEDA_PcbGridFrame + */ + +void WinEDA_PcbGridFrame::CreateControls() +{ + SetFont(*g_DialogFont); +////@begin WinEDA_PcbGridFrame content construction + // Generated by DialogBlocks, 17/08/2006 09:27:19 (unregistered) + + WinEDA_PcbGridFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5); + + wxString m_UnitGridStrings[] = { + _("Inches"), + _("mm") + }; + m_UnitGrid = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Grid Size Units"), wxDefaultPosition, wxDefaultSize, 2, m_UnitGridStrings, 1, wxRA_SPECIFY_COLS ); + m_UnitGrid->SetSelection(0); + itemBoxSizer3->Add(m_UnitGrid, 0, wxGROW|wxALL, 5); + + itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, _("User Grid Size X"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(itemStaticText6, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptGridSizeX = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(m_OptGridSizeX, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxStaticText* itemStaticText8 = new wxStaticText( itemDialog1, wxID_STATIC, _("User Grid Size Y"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(itemStaticText8, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_OptGridSizeY = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(m_OptGridSizeY, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton11 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton11->SetDefault(); + itemButton11->SetForegroundColour(wxColour(202, 0, 0)); + itemBoxSizer10->Add(itemButton11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxButton* itemButton12 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton12->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer10->Add(itemButton12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + +////@end WinEDA_PcbGridFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_PcbGridFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_PcbGridFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_PcbGridFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_PcbGridFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_PcbGridFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_PcbGridFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_PcbGridFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_PcbGridFrame::OnOkClick( wxCommandEvent& event ) +{ + AcceptPcbOptions(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_PcbGridFrame::OnCancelClick( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_PcbGridFrame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_PcbGridFrame. +} + + diff --git a/pcbnew/set_grid.h b/pcbnew/set_grid.h new file mode 100644 index 0000000000..36a5caa58a --- /dev/null +++ b/pcbnew/set_grid.h @@ -0,0 +1,110 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: set_grid.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 26/02/2006 17:24:12 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 26/02/2006 17:24:12 + +#ifndef _SET_GRID_H_ +#define _SET_GRID_H_ + + +/*! + * Includes + */ + +////@begin includes +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_PCBGRIDFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_PCBGRIDFRAME_TITLE _("User Grid Size") +#define SYMBOL_WINEDA_PCBGRIDFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_PCBGRIDFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_PCBGRIDFRAME_POSITION wxDefaultPosition +#define ID_RADIOBOX 10001 +#define ID_TEXTCTRL 10002 +#define ID_TEXTCTRL1 10003 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_PcbGridFrame class declaration + */ + +class WinEDA_PcbGridFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_PcbGridFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_PcbGridFrame( ); + WinEDA_PcbGridFrame( WinEDA_BasePcbFrame* parent, + const wxPoint& pos = SYMBOL_WINEDA_PCBGRIDFRAME_POSITION, + wxWindowID id = SYMBOL_WINEDA_PCBGRIDFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PCBGRIDFRAME_TITLE, const wxSize& size = SYMBOL_WINEDA_PCBGRIDFRAME_SIZE, long style = SYMBOL_WINEDA_PCBGRIDFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PCBGRIDFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PCBGRIDFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PCBGRIDFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PCBGRIDFRAME_SIZE, long style = SYMBOL_WINEDA_PCBGRIDFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_PcbGridFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + +////@end WinEDA_PcbGridFrame event handler declarations + +////@begin WinEDA_PcbGridFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_PcbGridFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + void AcceptPcbOptions(wxCommandEvent& event); + +////@begin WinEDA_PcbGridFrame member variables + wxRadioBox* m_UnitGrid; + wxTextCtrl* m_OptGridSizeX; + wxTextCtrl* m_OptGridSizeY; +////@end WinEDA_PcbGridFrame member variables + WinEDA_BasePcbFrame * m_Parent; +}; + +#endif + // _SET_GRID_H_ diff --git a/pcbnew/set_grid.rc b/pcbnew/set_grid.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/pcbnew/set_grid.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/pcbnew/solve.cpp b/pcbnew/solve.cpp new file mode 100644 index 0000000000..3ab7174a42 --- /dev/null +++ b/pcbnew/solve.cpp @@ -0,0 +1,998 @@ + /***************************************/ + /* AUTOROUTAGE PCB : routine de calcul */ + /***************************************/ + + /* fichier SOLVE.Cpp */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "protos.h" + +#include +#include "cell.h" + +/* Routines definies ici : */ +static int Route_1_Trace(WinEDA_PcbFrame * pcbframe, wxDC * DC, int two_sides, int row_source,int col_source, + int row_target,int col_target, CHEVELU * pt_chevelu ); +static int Retrace(WinEDA_PcbFrame * pcbframe, wxDC * DC, int, int, int, int , int, int net_code); +static void OrCell_Trace(BOARD * pcb, int col,int row,int side,int orient, int current_net_code); +static void Place_Piste_en_Buffer(WinEDA_PcbFrame * pcbframe, wxDC * DC); + +/* Variables locales : */ +static int segm_oX, segm_oY; +static int segm_fX, segm_fY; /* Origine et fin de la piste en cours de trace */ +static CHEVELU* pt_cur_ch; +static int Ncurrent; /* measures of progress */ + + +#define NOSUCCESS 0 +#define STOP_FROM_ESC -1 +#define ERR_MEMORY -2 +#define SUCCESS 1 +#define TRIVIAL_SUCCESS 2 + +/* +** visit neighboring cells like this (where [9] is on the other side): +** +** +---+---+---+ +** | 1 | 2 | 3 | +** +---+---+---+ +** | 4 |[9]| 5 | +** +---+---+---+ +** | 6 | 7 | 8 | +** +---+---+---+ +*/ + +/* for visiting neighbors on the same side: increments/decrements des coord + [][0] = row, []{1] = col a ajouter aux coord du point central pour + obtenir les coord des 8 points voisins */ +static int delta[8][2] = { + { 1, -1 }, /* northwest */ + { 1, 0 }, /* north */ + { 1, 1 }, /* northeast */ + { 0, -1 }, /* west */ + { 0, 1 }, /* east */ + { -1, -1 }, /* southwest */ + { -1, 0 }, /* south */ + { -1, 1 } /* southeast */ + }; + +static int ndir[8] = { /* for building paths back to source */ + FROM_SOUTHEAST, FROM_SOUTH, FROM_SOUTHWEST, + FROM_EAST, FROM_WEST, + FROM_NORTHEAST, FROM_NORTH, FROM_NORTHWEST + }; + +/* blocking masks for neighboring cells */ +#define BLOCK_NORTHEAST ( DIAG_NEtoSW | BENT_StoNE | BENT_WtoNE \ + | ANGLE_NEtoSE | ANGLE_NWtoNE \ + | SHARP_NtoNE | SHARP_EtoNE | HOLE ) +#define BLOCK_SOUTHEAST ( DIAG_SEtoNW | BENT_NtoSE | BENT_WtoSE \ + | ANGLE_NEtoSE | ANGLE_SEtoSW \ + | SHARP_EtoSE | SHARP_StoSE | HOLE ) +#define BLOCK_SOUTHWEST ( DIAG_NEtoSW | BENT_NtoSW | BENT_EtoSW \ + | ANGLE_SEtoSW | ANGLE_SWtoNW \ + | SHARP_StoSW | SHARP_WtoSW | HOLE ) +#define BLOCK_NORTHWEST ( DIAG_SEtoNW | BENT_EtoNW | BENT_StoNW \ + | ANGLE_SWtoNW | ANGLE_NWtoNE \ + | SHARP_WtoNW | SHARP_NtoNW | HOLE ) +#define BLOCK_NORTH ( LINE_VERTICAL | BENT_NtoSE | BENT_NtoSW \ + | BENT_EtoNW | BENT_WtoNE \ + | BENT_StoNE | BENT_StoNW \ + | CORNER_NORTHEAST | CORNER_NORTHWEST \ + | ANGLE_NEtoSE | ANGLE_SWtoNW | ANGLE_NWtoNE \ + | DIAG_NEtoSW | DIAG_SEtoNW \ + | SHARP_NtoNE | SHARP_NtoNW \ + | SHARP_EtoNE | SHARP_WtoNW | HOLE ) +#define BLOCK_EAST ( LINE_HORIZONTAL | BENT_EtoSW | BENT_EtoNW \ + | BENT_NtoSE | BENT_StoNE \ + | BENT_WtoNE | BENT_WtoSE \ + | CORNER_NORTHEAST | CORNER_SOUTHEAST \ + | ANGLE_NEtoSE | ANGLE_SEtoSW | ANGLE_NWtoNE \ + | DIAG_NEtoSW | DIAG_SEtoNW \ + | SHARP_EtoNE | SHARP_EtoSE \ + | SHARP_NtoNE | SHARP_StoSE | HOLE ) +#define BLOCK_SOUTH ( LINE_VERTICAL | BENT_StoNE | BENT_StoNW \ + | BENT_EtoSW | BENT_WtoSE \ + | BENT_NtoSE | BENT_NtoSW \ + | CORNER_SOUTHEAST | CORNER_SOUTHWEST \ + | ANGLE_NEtoSE | ANGLE_SWtoNW | ANGLE_SEtoSW \ + | DIAG_NEtoSW | DIAG_SEtoNW \ + | SHARP_StoSE | SHARP_StoSW \ + | SHARP_EtoSE | SHARP_WtoSW | HOLE ) +#define BLOCK_WEST ( LINE_HORIZONTAL | BENT_WtoNE | BENT_WtoSE \ + | BENT_NtoSW | BENT_StoNW \ + | BENT_EtoSW | BENT_EtoNW \ + | CORNER_SOUTHWEST | CORNER_NORTHWEST \ + | ANGLE_SWtoNW | ANGLE_SEtoSW | ANGLE_NWtoNE \ + | DIAG_NEtoSW | DIAG_SEtoNW \ + | SHARP_WtoSW | SHARP_WtoNW \ + | SHARP_NtoNW | SHARP_StoSW | HOLE ) + +struct block { + int r1, c1; + long b1; + int r2, c2; + long b2; + }; + +static struct block blocking[8] = { /* blocking masks for diagonal traces */ + { 0, -1, BLOCK_NORTHEAST, 1, 0, BLOCK_SOUTHWEST }, + { 0, 0, 0, 0, 0, 0 }, + { 1, 0, BLOCK_SOUTHEAST, 0, 1, BLOCK_NORTHWEST }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, -1, BLOCK_SOUTHEAST, -1, 0, BLOCK_NORTHWEST }, + { 0, 0, 0, 0, 0, 0 }, + { -1, 0, BLOCK_NORTHEAST, 0, 1, BLOCK_SOUTHWEST } + }; + +/* mask for hole-related blocking effects */ +static struct { + long trace; + int present; + } selfok2[8] = { + { HOLE_NORTHWEST, 0 }, + { HOLE_NORTH, 0 }, + { HOLE_NORTHEAST, 0 }, + { HOLE_WEST, 0 }, + { HOLE_EAST, 0 }, + { HOLE_SOUTHWEST, 0 }, + { HOLE_SOUTH, 0 }, + { HOLE_SOUTHEAST, 0 } + }; + +static long newmask[8] = { /* patterns to mask out in neighbor cells */ + 0, CORNER_NORTHWEST|CORNER_NORTHEAST, 0, + CORNER_NORTHWEST|CORNER_SOUTHWEST, CORNER_NORTHEAST|CORNER_SOUTHEAST, + 0, CORNER_SOUTHWEST|CORNER_SOUTHEAST, 0 + }; + + +/* Macro d'affichage de l'activite du routeur; */ +#define AFFICHE_ACTIVITE_ROUTE \ + msg.Printf( wxT("%5.5d"),OpenNodes); \ + Affiche_1_Parametre(pcbframe, 24,wxT("Open"),msg,WHITE); \ + msg.Printf( wxT("%5.5d"),ClosNodes); \ + Affiche_1_Parametre(pcbframe, 32,wxT("Closed"),msg,WHITE);\ + msg.Printf( wxT("%5.5d"),MoveNodes); \ + Affiche_1_Parametre(pcbframe, 40,wxT("Moved"),msg,WHITE); \ + msg.Printf( wxT("%5.5d"),MaxNodes); \ + Affiche_1_Parametre(pcbframe, 48,wxT("Max"),msg,WHITE); \ + msg.Printf( wxT("%2.2d"),(ClosNodes*50)/(Nrows*Ncols) ); \ + Affiche_1_Parametre(pcbframe, 56, wxT("%"),msg,CYAN); + + + /********************************************************/ + /* int WinEDA_PcbFrame::Solve(wxDC * DC, int two_sides) */ + /********************************************************/ + + /* route all traces + Return: 1 si OK + -1 si Escape (arret en cours de routage) demande + -2 si defaut alloc memoire +*/ + +int WinEDA_PcbFrame::Solve(wxDC * DC, int two_sides) +{ +int current_net_code; +int row_source, col_source, row_target, col_target; +int success, nbsucces = 0, nbunsucces = 0; +EQUIPOT * pt_equipot; +bool stop = FALSE; +wxString msg; + + DrawPanel->m_AbortRequest = FALSE; + DrawPanel->m_AbortEnable = TRUE; + + Ncurrent = 0; + MsgPanel->EraseMsgBox(); + msg.Printf( wxT("%d "),m_Pcb->m_NbNoconnect); + Affiche_1_Parametre(this, 72, wxT("NoConn"),msg,LIGHTCYAN); + + + /* go until no more work to do */ + GetWork( &row_source, &col_source, ¤t_net_code, + &row_target, &col_target, &pt_cur_ch ); // 1er chevelu a router + + for ( ; row_source != ILLEGAL; GetWork( &row_source, &col_source, + ¤t_net_code, &row_target, &col_target, &pt_cur_ch )) + { + /* Tst demande d'arret de routage ( key ESCAPE actionnee ) */ + wxYield(); + if( DrawPanel->m_AbortRequest ) + { + if ( IsOK(this, _("Abort routing?" )) ) + { + success = STOP_FROM_ESC; + stop = TRUE; + break; + } + else DrawPanel->m_AbortRequest = 0; + } + + Ncurrent++; + pt_equipot = GetEquipot(m_Pcb, current_net_code); + if( pt_equipot) + { + msg.Printf( wxT("[%8.8s]"),pt_equipot->m_Netname.GetData()); + Affiche_1_Parametre(this, 1, wxT("Net route"), msg,YELLOW); + msg.Printf( wxT( "%d / %d"),Ncurrent, Ntotal); + Affiche_1_Parametre(this, 12, wxT("Activity"), msg,YELLOW); + } + + pt_cur_ch = pt_cur_ch; + segm_oX = m_Pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize * col_source); + segm_oY = m_Pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * row_source); + segm_fX = m_Pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize * col_target); + segm_fY = m_Pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * row_target); + + /* Affiche Liaison */ + GRLine(&DrawPanel->m_ClipBox, DC, segm_oX, segm_oY, segm_fX, segm_fY, WHITE | GR_XOR); + pt_cur_ch->pad_start->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR | GR_SURBRILL); + pt_cur_ch->pad_end->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR|GR_SURBRILL); + + success = Route_1_Trace(this, DC, two_sides, row_source, col_source, + row_target, col_target, pt_cur_ch ); + switch (success) + { + case NOSUCCESS: + pt_cur_ch->status |= CH_UNROUTABLE; + nbunsucces++; + break; + + case STOP_FROM_ESC: + stop = TRUE; + break; + + case ERR_MEMORY: + stop = TRUE; + break; + + default: + nbsucces++; + break; + } + + msg.Printf( wxT("%d "),nbsucces); + Affiche_1_Parametre(this, 61, wxT("Ok"),msg,LIGHTGREEN); + msg.Printf( wxT("%d "),nbunsucces); + Affiche_1_Parametre(this, 66, wxT("Fail"),msg,LIGHTRED); + msg.Printf( wxT("%d "),m_Pcb->m_NbNoconnect); + Affiche_1_Parametre(this, 72, wxT("NoConn"),msg,LIGHTCYAN); + + /* Effacement des affichages de routage sur l'ecran */ + pt_cur_ch->pad_start->Draw(DrawPanel, DC, wxPoint(0,0), GR_AND); + pt_cur_ch->pad_end->Draw(DrawPanel, DC,wxPoint(0,0), GR_AND); + + if ( stop ) break; + } + + DrawPanel->m_AbortEnable = FALSE; + + return(SUCCESS); +} + + /**************************/ + /* int Route_1_Trace(xxx) */ + /**************************/ + +/* Route une piste du BOARD. + Parametres: + 1 face / 2 faces ( 0 / 1) + coord source (row,col) + coord destination (row,col) + net_code + pointeur sur le chevelu de reference + + Retourne : + SUCCESS si route trouvee + TRIVIAL_SUCCESS si pads connectes par superposition ( pas de piste a tirer) + NOSUCCESS si echec + STOP_FROM_ESC si Escape demande + ERR_MEMORY defaut alloc RAM +*/ +static int Route_1_Trace(WinEDA_PcbFrame * pcbframe, wxDC * DC, + int two_sides, int row_source,int col_source, + int row_target,int col_target, CHEVELU * pt_chevelu ) +{ +int r, c, side , d, apx_dist, nr, nc; +int result, skip; +int i; +LISTE_PAD * ptr; +long curcell, newcell, buddy, lastopen, lastclos, lastmove; +int newdist, olddir, _self; +int current_net_code; +int marge, via_marge; +int pad_masque_layer_s; /* Masque des couches appartenant au pad de depart */ +int pad_masque_layer_e; /* Masque des couches appartenant au pad d'arrivee */ +int masque_layer_TOP = g_TabOneLayerMask[Route_Layer_TOP]; +int masque_layer_BOTTOM = g_TabOneLayerMask[Route_Layer_BOTTOM]; +int masque_layers; /* Masque des 2 couches de routage */ +int tab_mask[2]; /* permet le calcul du Masque de la couche en cours + de tst (side = TOP ou BOTTOM)*/ +int start_mask_layer = 0; +wxString msg; + + result = NOSUCCESS; + + marge = g_DesignSettings.m_TrackClearence + (g_DesignSettings.m_CurrentTrackWidth / 2); + via_marge = g_DesignSettings.m_TrackClearence + (g_DesignSettings.m_CurrentViaSize / 2); + + /* clear direction flags */ + i = Nrows * Ncols * sizeof(char); + memset(Board.m_DirSide[TOP], FROM_NOWHERE, i ); + memset(Board.m_DirSide[BOTTOM], FROM_NOWHERE, i ); + + lastopen = lastclos = lastmove = 0; + + /* Init tab_masque[side] pour tests de fin de routage */ + tab_mask[TOP] = masque_layer_TOP; + tab_mask[BOTTOM] = masque_layer_BOTTOM; + /* Init masque des couches actives */ + masque_layers = masque_layer_TOP | masque_layer_BOTTOM; + + pt_cur_ch = pt_chevelu; + current_net_code = pt_chevelu->m_NetCode; + pad_masque_layer_s = pt_cur_ch->pad_start->m_Masque_Layer; + pad_masque_layer_e = pt_cur_ch->pad_end->m_Masque_Layer; + + /* Test 1 Si routage possible c.a.d si les pads sont accessibles + sur les couches de routage */ + + if( (masque_layers & pad_masque_layer_s) == 0 ) goto end_of_route; + if( (masque_layers & pad_masque_layer_e) == 0 ) goto end_of_route; + + /* Test 2 Si routage possible c.a.d si les pads sont accessibles + sur la grille de routage ( 1 point de grille doit etre dans le pad)*/ + { + int cX = (g_GridRoutingSize * col_source) + pcbframe->m_Pcb->m_BoundaryBox.m_Pos.x; + int cY = (g_GridRoutingSize * row_source) + pcbframe->m_Pcb->m_BoundaryBox.m_Pos.y; + int dx = pt_cur_ch->pad_start->m_Size.x / 2; + int dy = pt_cur_ch->pad_start->m_Size.y / 2; + int px = pt_cur_ch->pad_start->m_Pos.x; + int py = pt_cur_ch->pad_start->m_Pos.y; + + if ( ((pt_cur_ch->pad_start->m_Orient/900)&1) != 0 ) EXCHG(dx,dy) ; + if ( (abs(cX - px) > dx ) || (abs(cY - py) > dy) ) goto end_of_route; + + cX = (g_GridRoutingSize * col_target) + pcbframe->m_Pcb->m_BoundaryBox.m_Pos.x; + cY = (g_GridRoutingSize * row_target) + pcbframe->m_Pcb->m_BoundaryBox.m_Pos.y; + dx = pt_cur_ch->pad_end->m_Size.x / 2; + dy = pt_cur_ch->pad_end->m_Size.y / 2; + px = pt_cur_ch->pad_end->m_Pos.x; + py = pt_cur_ch->pad_end->m_Pos.y; + if ( ((pt_cur_ch->pad_end->m_Orient/900)&1) != 0 ) EXCHG(dx,dy) ; + + if ( (abs(cX - px) > dx ) || (abs(cY - py) > dy) ) goto end_of_route; + } + + /* Test du cas trivial: connection directe par superposition des pads */ + if( (row_source == row_target) && (col_source == col_target) + && ( pad_masque_layer_e & pad_masque_layer_s & g_TabAllCopperLayerMask[g_DesignSettings.m_CopperLayerCount-1]) ) + { + result = TRIVIAL_SUCCESS; + goto end_of_route; + } + + + + /* Placement du bit de suppression d'obstacle relative aux 2 pads a relier */ + pcbframe->Affiche_Message( wxT("Gen Cells") ); + + Place_1_Pad_Board(pcbframe->m_Pcb, pt_cur_ch->pad_start,CURRENT_PAD ,marge,WRITE_OR_CELL); + Place_1_Pad_Board(pcbframe->m_Pcb, pt_cur_ch->pad_end, CURRENT_PAD ,marge,WRITE_OR_CELL); + + /* Regenere les barrieres restantes (qui peuvent empieter sur le placement + des bits precedents) */ + ptr = (LISTE_PAD*) pcbframe->m_Pcb->m_Pads; i = pcbframe->m_Pcb->m_NbPads; + for( ; i > 0 ; i-- , ptr++) + { + if((pt_cur_ch->pad_start != *ptr) && (pt_cur_ch->pad_end != *ptr) ) + { + Place_1_Pad_Board(pcbframe->m_Pcb, *ptr, ~CURRENT_PAD,marge,WRITE_AND_CELL); + } + } + + InitQueue(); /* initialize the search queue */ + apx_dist = GetApxDist( row_source, col_source, row_target, col_target ); + + /* Init 1ere recherche */ + if(two_sides) /* orientation preferentielle */ + { + if( abs(row_target-row_source) > abs(col_target-col_source) ) + { + if( pad_masque_layer_s & masque_layer_TOP ) + { + start_mask_layer = 2; + if(SetQueue( row_source, col_source, TOP, 0, apx_dist, + row_target, col_target ) == 0) + { + return(ERR_MEMORY); + } + } + if( pad_masque_layer_s & masque_layer_BOTTOM ) + { + start_mask_layer |= 1; + + if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist, + row_target, col_target ) == 0 ) + { + return(ERR_MEMORY); + } + } + } + else + { + if( pad_masque_layer_s & masque_layer_BOTTOM ) + { + start_mask_layer = 1; + if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist, + row_target, col_target ) == 0 ) + { + return(ERR_MEMORY); + } + } + if( pad_masque_layer_s & masque_layer_TOP ) + { + start_mask_layer |= 2; + + if (SetQueue( row_source, col_source, TOP, 0, apx_dist, + row_target, col_target ) == 0 ) + { + return(ERR_MEMORY); + } + } + } + } + + else + if( pad_masque_layer_s & masque_layer_BOTTOM ) + { + start_mask_layer = 1; + + if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist, + row_target, col_target ) == 0 ) + { + return(ERR_MEMORY); + } + } + + /* search until success or we exhaust all possibilities */ + GetQueue( &r, &c, &side, &d, &apx_dist ); + for ( ; r != ILLEGAL; GetQueue( &r, &c, &side, &d, &apx_dist ) ) + { + curcell = GetCell( r, c, side ); + if(curcell & CURRENT_PAD) curcell &= ~HOLE ; + if( (r == row_target) && (c == col_target) /* success si layer OK */ + && ( tab_mask[side] & pad_masque_layer_e) ) + { + /* Efface Liaison */ + GRSetDrawMode(DC, GR_XOR); + GRLine(&pcbframe->DrawPanel->m_ClipBox, DC, segm_oX, segm_oY, segm_fX, segm_fY, WHITE); + + /* Generation de la trace */ + if( Retrace(pcbframe, DC, row_source, col_source, + row_target, col_target, side, current_net_code) ) + { + result = SUCCESS; /* Success : Route OK */ + } + break; /* Fin du routage */ + } + /* report every 300 new nodes or so */ + if( (OpenNodes-lastopen > 300) || (ClosNodes-lastclos > 300) || (MoveNodes - lastmove > 300)) + { + lastopen = (OpenNodes/300)*300; lastclos = (ClosNodes/300)*300; + lastmove = (MoveNodes/300)*300; + + if( pcbframe->DrawPanel->m_AbortRequest ) + { + result = STOP_FROM_ESC; break; + } + AFFICHE_ACTIVITE_ROUTE; + } + + _self = 0; + if (curcell & HOLE) + { + _self = 5; + /* set 'present' bits */ + for (i = 0; i < 8; i++) + { + selfok2[i].present = 0; + if( (curcell & selfok2[i].trace) ) selfok2[i].present = 1; + } + } + + for (i = 0; i < 8; i++) /* consider neighbors */ + { + nr = r+delta[i][0]; nc = c+delta[i][1]; + + /* off the edge? */ + if( nr < 0 || nr >= Nrows || nc < 0 || nc >= Ncols) + continue; /* off the edge */ + + if (_self == 5 && selfok2[i].present) continue; + newcell = GetCell( nr, nc, side ); + if(newcell & CURRENT_PAD) newcell &= ~HOLE; + + /* check for non-target hole */ + if (newcell & HOLE) + { + if (nr != row_target || nc != col_target) continue; + } + + /* check for traces */ + else if (newcell & HOLE & ~(newmask[i])) continue; + + /* check blocking on corner neighbors */ + if (delta[i][0] && delta[i][1]) + { + /* check first buddy */ + buddy = GetCell( r+blocking[i].r1, c+blocking[i].c1, side ); + if(buddy & CURRENT_PAD) buddy &= ~HOLE; + if (buddy & HOLE) continue; +// if (buddy & (blocking[i].b1)) continue; + /* check second buddy */ + buddy = GetCell( r+blocking[i].r2, c+blocking[i].c2, side ); + if(buddy & CURRENT_PAD) buddy &= ~HOLE; + if (buddy & HOLE) continue; +// if (buddy & (blocking[i].b2)) continue; + } + + olddir = GetDir( r, c, side ); + newdist = d + CalcDist( ndir[i], olddir, + (olddir == FROM_OTHERSIDE) ? GetDir( r, c, 1-side ) : 0 , side); + + /* if (a) not visited yet, or (b) we have */ + /* found a better path, add it to queue */ + if (!GetDir( nr, nc, side )) + { + SetDir( nr, nc, side, ndir[i] ); + SetDist( nr, nc, side, newdist ); + if( SetQueue( nr, nc, side, newdist, + GetApxDist( nr, nc, row_target, col_target ), + row_target, col_target ) == 0 ) + { + return(ERR_MEMORY); + } + } + + else if (newdist < GetDist( nr, nc, side )) + { + SetDir( nr, nc, side, ndir[i] ); + SetDist( nr, nc, side, newdist ); + ReSetQueue( nr, nc, side, newdist, + GetApxDist( nr, nc, row_target, col_target ), + row_target, col_target ); + } + } + + /** etude de l'autre couche **/ + if( (two_sides) && ! g_No_Via_Route ) + { + olddir = GetDir( r, c, side ); + if (olddir == FROM_OTHERSIDE) + continue; /* useless move, so don't bother */ + if (curcell) /* can't drill via if anything here */ + continue; + /* check for holes or traces on other side */ + if( (newcell = GetCell( r, c, 1-side )) != 0 ) + continue; + /* check for nearby holes or traces on both sides */ + for (skip = 0, i = 0; i < 8; i++) + { + nr = r + delta[i][0]; nc = c + delta[i][1]; + + if (nr < 0 || nr >= Nrows || nc < 0 || nc >= Ncols) + continue; /* off the edge !! */ + + if (GetCell( nr, nc, side )/* & blocking2[i]*/) + { + skip = 1; /* can't drill via here */ + break; + } + + if (GetCell( nr, nc, 1-side )/* & blocking2[i]*/) + { + skip = 1; /* can't drill via here */ + break; + } + } + + if (skip) /* neighboring hole or trace? */ + continue; /* yes, can't drill via here */ + + newdist = d + CalcDist( FROM_OTHERSIDE, olddir, 0 , side); + + /* if (a) not visited yet, + or (b) we have found a better path, + add it to queue */ + if (!GetDir( r, c, 1-side )) + { + SetDir( r, c, 1-side, FROM_OTHERSIDE ); + SetDist( r, c, 1-side, newdist ); + if( SetQueue( r, c, 1-side, newdist, apx_dist, row_target, + col_target ) == 0 ) + { + return(ERR_MEMORY); + } + } + else if (newdist < GetDist( r, c, 1-side )) + { + SetDir( r, c, 1-side, FROM_OTHERSIDE ); + SetDist( r, c, 1-side, newdist ); + ReSetQueue( r, c, 1-side, newdist, apx_dist, row_target, col_target ); + } + } /* Fin de l'exploration de l'autre couche */ + } + +end_of_route: + Place_1_Pad_Board(pcbframe->m_Pcb, pt_cur_ch->pad_start,~CURRENT_PAD ,marge,WRITE_AND_CELL); + Place_1_Pad_Board(pcbframe->m_Pcb, pt_cur_ch->pad_end, ~CURRENT_PAD ,marge,WRITE_AND_CELL); + + AFFICHE_ACTIVITE_ROUTE; + return(result); +} + +static long bit[8][9] = { /* OT=Otherside */ + /* N, NE, E, SE, S, SW, W, NW, OT */ +/* N */ { LINE_VERTICAL, BENT_StoNE, CORNER_SOUTHEAST, SHARP_StoSE, 0, + SHARP_StoSW, CORNER_SOUTHWEST, BENT_StoNW, (HOLE | HOLE_SOUTH) }, +/* NE */ { BENT_NtoSW, DIAG_NEtoSW, BENT_EtoSW, ANGLE_SEtoSW, SHARP_StoSW, + 0, SHARP_WtoSW, ANGLE_SWtoNW, (HOLE | HOLE_SOUTHWEST) }, +/* E */ { CORNER_NORTHWEST, BENT_WtoNE, LINE_HORIZONTAL, BENT_WtoSE, + CORNER_SOUTHWEST, SHARP_WtoSW, 0, SHARP_WtoNW, (HOLE | HOLE_WEST) }, +/* SE */ { SHARP_NtoNW, ANGLE_NWtoNE, BENT_EtoNW, DIAG_SEtoNW, BENT_StoNW, + ANGLE_SWtoNW, SHARP_WtoNW, 0, (HOLE | HOLE_NORTHWEST) }, +/* S */ { 0, SHARP_NtoNE, CORNER_NORTHEAST, BENT_NtoSE, LINE_VERTICAL, + BENT_NtoSW, CORNER_NORTHWEST, SHARP_NtoNW, (HOLE | HOLE_NORTH) }, +/* SW */ { SHARP_NtoNE, 0, SHARP_EtoNE, ANGLE_NEtoSE, BENT_StoNE, DIAG_NEtoSW, + BENT_WtoNE, ANGLE_NWtoNE, (HOLE | HOLE_NORTHEAST) }, +/* W */ { CORNER_NORTHEAST, SHARP_EtoNE, 0, SHARP_EtoSE, CORNER_SOUTHEAST, + BENT_EtoSW, LINE_HORIZONTAL, BENT_EtoNW, (HOLE | HOLE_EAST) }, +/* NW */ { BENT_NtoSE, ANGLE_NEtoSE, SHARP_EtoSE, 0, SHARP_StoSE, + ANGLE_SEtoSW, BENT_WtoSE, DIAG_SEtoNW, (HOLE | HOLE_SOUTHEAST) } + }; + +/*****************************************************************/ +/* int Retrace (COMMAND * Cmd, int row_source, int col_source */ +/* int row_target, int col_target, int target_side, */ +/* int current_net_code ) */ +/*****************************************************************/ + +/* work from target back to source, actually laying the traces + Parametres: + start on side target_side, aux coordonnees row_target, col_target. + arrivee sur side masque_layer_start, coord row_source, col_source + La recherche se fait en sens inverse du routage, + c.a.d du point d'arrivee (target) vers le point de depart (source) + du routeur. + + target_side = cote (TOP / BOTTOM) de depart + mask_layer_source = masque des couches d'arrivee + + Retourne: + 0 si erreur + > 0 si Ok +*/ + +static int Retrace (WinEDA_PcbFrame * pcbframe, wxDC * DC, + int row_source, int col_source, + int row_target, int col_target, int target_side, + int current_net_code ) +{ +int r0, c0, s0; +int r1, c1, s1; /* row, col, side d'ou on vient */ +int r2, c2, s2; /* row, col, side ou on va */ +int x, y = -1; +long b; + + r1 = row_target; + c1 = col_target; /* start point is target ( end point is source )*/ + s1 = target_side; + r0 = c0 = s0 = ILLEGAL; + + g_FirstTrackSegment = g_CurrentTrackSegment = NULL; + g_TrackSegmentCount = 0; + + do { + /* find where we came from to get here */ + r2 = r1; c2 = c1; s2 = s1; + x = GetDir( r1, c1, s1 ); + switch ( x ) + { + case FROM_NORTH: r2++; break; + case FROM_EAST: c2++; break; + case FROM_SOUTH: r2--; break; + case FROM_WEST: c2--; break; + case FROM_NORTHEAST: r2++; c2++; break; + case FROM_SOUTHEAST: r2--; c2++; break; + case FROM_SOUTHWEST: r2--; c2--; break; + case FROM_NORTHWEST: r2++; c2--; break; + case FROM_OTHERSIDE: s2 = 1-s2; break; + default: + DisplayError(pcbframe, wxT("Retrace: internal error: no way back")); + return(0); + } + + if (r0 != ILLEGAL) y = GetDir( r0, c0, s0 ); + + /* see if target or hole */ + if( ( (r1 == row_target) && (c1 == col_target) ) + || (s1 != s0)) + { + int p_dir; + switch (x) + { + case FROM_NORTH: + p_dir = HOLE_NORTH; break; + case FROM_EAST: + p_dir = HOLE_EAST; break; + case FROM_SOUTH: + p_dir = HOLE_SOUTH; break; + case FROM_WEST: + p_dir = HOLE_WEST; break; + case FROM_NORTHEAST: + p_dir = HOLE_NORTHEAST; break; + case FROM_SOUTHEAST: + p_dir = HOLE_SOUTHEAST; break; + case FROM_SOUTHWEST: + p_dir = HOLE_SOUTHWEST; break; + case FROM_NORTHWEST: + p_dir = HOLE_NORTHWEST; break; + + case FROM_OTHERSIDE: + default: + DisplayError(pcbframe, wxT("Retrace: error 1")); + return(0); + } + OrCell_Trace(pcbframe->m_Pcb, r1, c1, s1, p_dir, current_net_code ); + } + + else { + if( (y == FROM_NORTH || y == FROM_NORTHEAST + || y == FROM_EAST || y == FROM_SOUTHEAST + || y == FROM_SOUTH || y == FROM_SOUTHWEST + || y == FROM_WEST || y == FROM_NORTHWEST) && + (x == FROM_NORTH || x == FROM_NORTHEAST + || x == FROM_EAST || x == FROM_SOUTHEAST + || x == FROM_SOUTH || x == FROM_SOUTHWEST + || x == FROM_WEST || x == FROM_NORTHWEST + || x == FROM_OTHERSIDE) && + ((b = bit[y-1][x-1]) != 0) ) + { + OrCell_Trace(pcbframe->m_Pcb, r1, c1, s1, b, current_net_code ); + if (b & HOLE) + OrCell_Trace(pcbframe->m_Pcb, r2, c2, s2, HOLE, current_net_code ); + } + else + { + DisplayError(pcbframe, wxT("Retrace: error 2")); + return(0); + } + } + + if( (r2 == row_source) && (c2 == col_source) ) + { /* see if source */ + int p_dir; + switch (x) + { + case FROM_NORTH: p_dir = HOLE_SOUTH; break; + case FROM_EAST: p_dir = HOLE_WEST; break; + case FROM_SOUTH: p_dir = HOLE_NORTH; break; + case FROM_WEST: p_dir = HOLE_EAST; break; + case FROM_NORTHEAST: p_dir = HOLE_SOUTHWEST; break; + case FROM_SOUTHEAST: p_dir = HOLE_NORTHWEST; break; + case FROM_SOUTHWEST: p_dir = HOLE_NORTHEAST; break; + case FROM_NORTHWEST: p_dir = HOLE_SOUTHEAST; break; + + case FROM_OTHERSIDE: + default: + DisplayError(pcbframe, wxT("Retrace: error 3")); + return(0); + } + OrCell_Trace(pcbframe->m_Pcb, r2, c2, s2, p_dir, current_net_code ); + } + /* move to next cell */ + r0 = r1; c0 = c1; s0 = s1; + r1 = r2; c1 = c2; s1 = s2; + } while( !( (r2 == row_source) && (c2 == col_source) ) ); + + Place_Piste_en_Buffer(pcbframe, DC); + return(1); +} + + +/*****************************************************************************/ +static void OrCell_Trace(BOARD * pcb, int col,int row, + int side,int orient,int current_net_code) +/*****************************************************************************/ +/* appelle la routine OrCell et place la piste reelle sur le pcb */ +{ +int dx0, dy0, dx1,dy1; +TRACK * NewTrack, *OldTrack; + + if(orient == HOLE) /* Placement d'une VIA */ + { + NewTrack = new SEGVIA(pcb); + g_TrackSegmentCount++; + NewTrack->Pback = g_CurrentTrackSegment; + if( g_CurrentTrackSegment) g_CurrentTrackSegment->Pnext = NewTrack; + else g_FirstTrackSegment = NewTrack; + + g_CurrentTrackSegment = NewTrack; + + g_CurrentTrackSegment->SetState(SEGM_AR, ON); + g_CurrentTrackSegment->m_Layer = 0x0F; + g_CurrentTrackSegment->m_Start.x = g_CurrentTrackSegment->m_End.x = + pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize * row); + g_CurrentTrackSegment->m_Start.y = g_CurrentTrackSegment->m_End.y = + pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * col); + g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentViaSize; + g_CurrentTrackSegment->m_Shape = g_DesignSettings.m_CurrentViaType; + g_CurrentTrackSegment->m_NetCode = current_net_code; + } + + else /* Placement d'un segment standard */ + { + NewTrack = new TRACK(pcb); + g_TrackSegmentCount++; + NewTrack->Pback = g_CurrentTrackSegment; + if( g_CurrentTrackSegment) g_CurrentTrackSegment->Pnext = NewTrack; + else g_FirstTrackSegment = NewTrack; + + g_CurrentTrackSegment = NewTrack; + + g_CurrentTrackSegment->m_Layer = Route_Layer_BOTTOM; + if (side == TOP) g_CurrentTrackSegment->m_Layer = Route_Layer_TOP; + + g_CurrentTrackSegment->SetState(SEGM_AR,ON) ; + g_CurrentTrackSegment->m_End.x = pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize * row); + g_CurrentTrackSegment->m_End.y = pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * col); + g_CurrentTrackSegment->m_NetCode = current_net_code; + + if ( g_CurrentTrackSegment->Pback == NULL ) /* Start Piste */ + { + g_CurrentTrackSegment->m_Start.x = segm_fX; + g_CurrentTrackSegment->m_Start.y = segm_fY; + + /* Replacement sur le centre du pad si hors grille */ + dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; + dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; + dx0 = pt_cur_ch->pad_end->m_Pos.x - g_CurrentTrackSegment->m_Start.x; + dy0 = pt_cur_ch->pad_end->m_Pos.y - g_CurrentTrackSegment->m_Start.y; + + /* si aligne: modif du point origine */ + if(abs(dx0*dy1) == abs(dx1*dy0) ) /* Alignes ! */ + { + g_CurrentTrackSegment->m_Start.x = pt_cur_ch->pad_end->m_Pos.x; + g_CurrentTrackSegment->m_Start.y = pt_cur_ch->pad_end->m_Pos.y; + } + + else /* Creation d'un segment suppl raccord */ + { + NewTrack = g_CurrentTrackSegment->Copy(); + g_TrackSegmentCount++; + NewTrack->Insert(pcb, g_CurrentTrackSegment); + + g_CurrentTrackSegment->m_Start.x = pt_cur_ch->pad_end->m_Pos.x; + g_CurrentTrackSegment->m_Start.y = pt_cur_ch->pad_end->m_Pos.y; + NewTrack->m_Start.x = g_CurrentTrackSegment->m_End.x; + NewTrack->m_Start.y = g_CurrentTrackSegment->m_End.y; + + g_CurrentTrackSegment = NewTrack; + } + } + else + { + if ( g_CurrentTrackSegment->Pback ) + { + g_CurrentTrackSegment->m_Start.x = ((TRACK*)g_CurrentTrackSegment->Pback)->m_End.x; + g_CurrentTrackSegment->m_Start.y = ((TRACK*)g_CurrentTrackSegment->Pback)->m_End.y; + } + } + g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; + + if ( (g_CurrentTrackSegment->m_Start.x != g_CurrentTrackSegment->m_End.x) || + (g_CurrentTrackSegment->m_Start.y != g_CurrentTrackSegment->m_End.y) ) + { + /* Reduction des segments alignes a 1 seul */ + OldTrack = (TRACK*) g_CurrentTrackSegment->Pback; + if ( OldTrack && (OldTrack->m_StructType != TYPEVIA) ) + { + dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; + dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; + dx0 = OldTrack->m_End.x - OldTrack->m_Start.x; + dy0 = OldTrack->m_End.y - OldTrack->m_Start.y; + if( abs(dx0*dy1) == abs(dx1*dy0) )/* le dernier segment est en ligne*/ + { + OldTrack->m_End.x = g_CurrentTrackSegment->m_End.x; + OldTrack->m_End.y = g_CurrentTrackSegment->m_End.y; + delete g_CurrentTrackSegment; + g_CurrentTrackSegment = OldTrack; + g_CurrentTrackSegment->Pnext = NULL; + g_TrackSegmentCount--; + } + } + } + } +} + + /*******************************************/ + /* static void Place_Piste_en_Buffer(void) */ + /*******************************************/ + +/* Insere la nouvelle piste creee dans la liste standard des pistes. + Modifie les points de debut et fin de piste pour qu'ils soient relies + au centre des pads corresponadants, meme hors grille +*/ +static void Place_Piste_en_Buffer(WinEDA_PcbFrame * pcbframe, wxDC * DC) +{ +TRACK* pt_track; +int dx0, dy0, dx1,dy1; +int marge, via_marge; +WinEDA_DrawPanel * panel = pcbframe->DrawPanel; + + marge = g_DesignSettings.m_TrackClearence + (g_DesignSettings.m_CurrentTrackWidth /2); + via_marge = g_DesignSettings.m_TrackClearence + (g_DesignSettings.m_CurrentViaSize /2); + + /* tst point d'arrivee : doit etre sur pad start */ + + dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; + dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; + /* Replacement sur le centre du pad si hors grille */ + + dx0 = pt_cur_ch->pad_start->m_Pos.x - g_CurrentTrackSegment->m_Start.x; + dy0 = pt_cur_ch->pad_start->m_Pos.y - g_CurrentTrackSegment->m_Start.y; + + /* si aligne: modif du point origine */ + if(abs(dx0*dy1) == abs(dx1*dy0) ) /* Alignes ! */ + { + g_CurrentTrackSegment->m_End.x = pt_cur_ch->pad_start->m_Pos.x; + g_CurrentTrackSegment->m_End.y = pt_cur_ch->pad_start->m_Pos.y; + } + else /* Creation d'un segment suppl raccord */ + { + TRACK * NewTrack = g_CurrentTrackSegment->Copy(); + NewTrack->Insert(pcbframe->m_Pcb, g_CurrentTrackSegment); + + NewTrack->m_End.x = pt_cur_ch->pad_start->m_Pos.x; + NewTrack->m_End.y = pt_cur_ch->pad_start->m_Pos.y; + NewTrack->m_Start.x = g_CurrentTrackSegment->m_End.x; + NewTrack->m_Start.y = g_CurrentTrackSegment->m_End.y; + + g_CurrentTrackSegment = NewTrack; g_TrackSegmentCount++; + } + + + g_FirstTrackSegment->start = Locate_Pad_Connecte(pcbframe->m_Pcb, g_FirstTrackSegment,START); + if(g_FirstTrackSegment->start) g_FirstTrackSegment->SetState(BEGIN_ONPAD,ON); + + g_CurrentTrackSegment->end = Locate_Pad_Connecte(pcbframe->m_Pcb, g_CurrentTrackSegment,END); + if(g_CurrentTrackSegment->end) g_CurrentTrackSegment->SetState(END_ONPAD,ON); + + /* recherche de la zone de rangement et insertion de la nouvelle piste */ + pt_track = g_FirstTrackSegment->GetBestInsertPoint(pcbframe->m_Pcb); + g_FirstTrackSegment->Insert(pcbframe->m_Pcb, pt_track); + + Trace_Une_Piste(panel, DC, g_FirstTrackSegment,g_TrackSegmentCount,GR_OR) ; + + pcbframe->test_1_net_connexion(DC, g_FirstTrackSegment->m_NetCode ); + + /* Trace de la forme exacte de la piste en BOARD */ + for ( pt_track = g_FirstTrackSegment; ; pt_track = (TRACK*)pt_track->Pnext) + { + TraceSegmentPcb(pcbframe->m_Pcb,pt_track,HOLE,marge,WRITE_CELL); + TraceSegmentPcb(pcbframe->m_Pcb,pt_track,VIA_IMPOSSIBLE,via_marge,WRITE_OR_CELL); + if(pt_track == g_CurrentTrackSegment ) break; + } + + ActiveScreen->SetModify(); +} + diff --git a/pcbnew/struct.cpp b/pcbnew/struct.cpp new file mode 100644 index 0000000000..c27bf4e6cb --- /dev/null +++ b/pcbnew/struct.cpp @@ -0,0 +1,160 @@ + /***********************************************/ + /* Routines d'effacement et copie de structures*/ + /***********************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +/* Routines Locales */ +/* Variables locales */ + + +/**************************************************/ +void DeleteStructure( EDA_BaseStruct * PtStruct ) +/**************************************************/ +/* Supprime de la liste chainee la stucture pointee par GenericStructure + et libere la memoire correspondante +*/ +{ +EDA_BaseStruct *PtNext, *PtBack; +int IsDeleted; +int typestruct; +wxString Line; + + if( PtStruct == NULL) return ; + + typestruct = (int)PtStruct->m_StructType; + IsDeleted = PtStruct->GetState(DELETED); + + PtNext = PtStruct->Pnext; + PtBack = PtStruct->Pback; + + switch( typestruct ) + { + case TYPE_NOT_INIT: + DisplayError(NULL, wxT("DeleteStruct: Type Not Init")); + break; + + case PCB_EQUIPOT_STRUCT_TYPE: + #undef Struct + #define Struct ((EQUIPOT*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEMODULE: + #undef Struct + #define Struct ((MODULE*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + + case TYPEPAD: + #undef Struct + #define Struct ((D_PAD*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPECOTATION: + #undef Struct + #define Struct ((COTATION*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEMIRE: + #undef Struct + #define Struct ((MIREPCB*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEDRAWSEGMENT: + #undef Struct + #define Struct ((DRAWSEGMENT*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPETEXTE: + #undef Struct + #define Struct ((TEXTE_PCB*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + + case TYPETEXTEMODULE: + #undef Struct + #define Struct ((TEXTE_MODULE*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEEDGEMODULE: + #undef Struct + #define Struct ((EDGE_MODULE*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPETRACK: + #undef Struct + #define Struct ((TRACK*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEVIA: + #undef Struct + #define Struct ((SEGVIA*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEZONE: + #undef Struct + #define Struct ((SEGZONE*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEMARQUEUR: + #undef Struct + #define Struct ((MARQUEUR*)PtStruct) + Struct->UnLink(); + delete Struct; + break; + + case TYPEPCB: + + default: + Line.Printf( wxT(" DeleteStructure: unexpected Type %d"), + PtStruct->m_StructType); + DisplayError(NULL, Line); + break; + } +} + + +/**************************************************/ +void DeleteStructList( EDA_BaseStruct * PtStruct ) +/**************************************************/ +/* Supprime la liste chainee pointee par PtStruct + et libere la memoire correspondante +*/ +{ +EDA_BaseStruct *PtNext; + while (PtStruct) + { + PtNext = PtStruct->Pnext; + delete PtStruct; + PtStruct = PtNext; + } +} + diff --git a/pcbnew/surbrill.cpp b/pcbnew/surbrill.cpp new file mode 100644 index 0000000000..74f080644d --- /dev/null +++ b/pcbnew/surbrill.cpp @@ -0,0 +1,117 @@ + /****************************/ + /* affichage des empreintes */ + /****************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + +#define Pad_fill (Pad_Fill_Item.State == RUN) + +static void Pad_Surbrillance(WinEDA_DrawPanel * panel, wxDC * DC, MODULE * Module, int NetCode); + +/* variables locales : */ +static int draw_mode ; + +/**************************************************/ +int WinEDA_PcbFrame::Select_High_Light(wxDC * DC) +/**************************************************/ +/* Localise track ou pad et met en surbrillance le net correspondant +Retourne le netcode, ou -1 si pas de net localisé */ +{ +TRACK * pt_piste; +D_PAD* pt_pad ; +int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; +int code = -1; + + if ( g_HightLigt_Status ) Hight_Light(DC); + pt_piste = Locate_Pistes(m_Pcb->m_Track, masquelayer, CURSEUR_OFF_GRILLE); + if ( pt_piste) + { + code = g_HightLigth_NetCode = pt_piste->m_NetCode; + Hight_Light(DC); + } + else + { + pt_pad = Locate_Any_Pad(m_Pcb, CURSEUR_OFF_GRILLE); + if( pt_pad != NULL ) + { + code = g_HightLigth_NetCode = pt_pad->m_NetCode ; + Hight_Light(DC) ; + } + } + + return code; +} + + +/*******************************************/ +void WinEDA_PcbFrame::Hight_Light(wxDC * DC) +/*******************************************/ +/* + fonction d'appel de Surbrillance a partir du menu + Met ou supprime la surbrillance d'un net pointe par la souris +*/ +{ + g_HightLigt_Status = !g_HightLigt_Status; + DrawHightLight( DC, g_HightLigth_NetCode) ; +} + + + +/****************************************************************/ +void WinEDA_PcbFrame::DrawHightLight(wxDC * DC, int NetCode) +/****************************************************************/ +/* Met ou supprime la surbrillance d'un net de nom NetName +*/ +{ +TRACK * pts ; +MODULE * Module; +PCB_SCREEN * OldScreen = (PCB_SCREEN *) ActiveScreen; + + if(g_HightLigt_Status ) draw_mode = GR_SURBRILL | GR_OR; + else draw_mode = GR_AND | GR_SURBRILL; + + Module = m_Pcb->m_Modules; + + /* Surbrillance des Pastilles : */ + + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + Pad_Surbrillance(DrawPanel, DC, Module, NetCode) ; + } + + /* Surbrillance des pistes : */ + for ( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext) + { + /* est ce que la piste fait partie du net ? : */ + if( pts->m_NetCode == NetCode ) + { + pts->Draw(DrawPanel, DC, draw_mode); + } + } +} + + +/*******************************************************/ +static void Pad_Surbrillance(WinEDA_DrawPanel * panel, + wxDC * DC, MODULE * Module, int NetCode) +/*******************************************************/ +/* Mise en Surbrillance des Pads */ +{ +D_PAD * pt_pad ; + + /* trace des pastilles */ + for(pt_pad = Module->m_Pads; pt_pad != NULL; pt_pad = (D_PAD*)pt_pad->Pnext) + { + if ( pt_pad->m_NetCode == NetCode ) + { + pt_pad->Draw(panel, DC, wxPoint(0,0),draw_mode); + } + } +} + diff --git a/pcbnew/tool_modedit.cpp b/pcbnew/tool_modedit.cpp new file mode 100644 index 0000000000..c404f71991 --- /dev/null +++ b/pcbnew/tool_modedit.cpp @@ -0,0 +1,303 @@ + /*****************************************************************/ + /* too_modeit.cpp: construction du menu de l'editeur de modules */ + /*****************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + +#define BITMAP wxBitmap + +#include "bitmaps.h" + +#include "id.h" + +#include "Module_Check.xpm" +#include "Import_Module.xpm" +#include "Export_Module.xpm" +#include "New_FootPrint.xpm" +#include "module_options.xpm" +#include "Load_Module_Board.xpm" +#include "Repl_Module_Board.xpm" + +#ifdef __UNIX__ +#define LISTBOX_WIDTH 120 +#else +#define LISTBOX_WIDTH 100 +#endif + +/***************************************************/ +void WinEDA_ModuleEditFrame::ReCreateHToolbar(void) +/***************************************************/ +{ + // Cecreate the toolbar + if ( m_HToolBar != NULL ) return; + + m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE); + + SetToolBar(m_HToolBar); + + // Set up toolbar + m_HToolBar->AddTool(ID_LIBEDIT_SELECT_CURRENT_LIB, wxEmptyString, + BITMAP(open_library_xpm), + _("Select working library")); + + m_HToolBar->AddTool(ID_MODEDIT_SAVE_LIBMODULE, wxEmptyString, BITMAP(save_library_xpm), + _("Save Module in working library")); + + m_HToolBar->AddTool(ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, wxEmptyString, + BITMAP(new_library_xpm), + _("Create new library and save current module")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_LIBEDIT_DELETE_PART, wxEmptyString, + BITMAP(delete_xpm), + _("Delete part in current library")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_MODEDIT_NEW_MODULE, wxEmptyString, + BITMAP(new_footprint_xpm), + _("New Module")); + + m_HToolBar->AddTool(ID_MODEDIT_LOAD_MODULE, wxEmptyString, + BITMAP(module_xpm), + _("Load module from lib")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString, + BITMAP(load_module_board_xpm), + _("Load module from current BOARD")); + + m_HToolBar->AddTool(ID_MODEDIT_SAVE_MODULE_IN_BOARD, wxEmptyString, + BITMAP(repl_module_board_xpm), + _("Replace module in current BOARD")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_LIBEDIT_IMPORT_PART, wxEmptyString, + BITMAP(import_module_xpm), + _("import module")); + + m_HToolBar->AddTool(ID_LIBEDIT_EXPORT_PART, wxEmptyString, + BITMAP(export_module_xpm), + _("export module")); + + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_MODEDIT_UNDO, wxEmptyString, BITMAP(undo_xpm), + _("Undo last edition")); + m_HToolBar->AddTool(ID_MODEDIT_REDO, wxEmptyString, BITMAP(redo_xpm), + _("Redo the last undo command")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_MODEDIT_EDIT_MODULE_PROPERTIES, wxEmptyString, + BITMAP(module_options_xpm), + _("Module Properties")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_GEN_PRINT, wxEmptyString, BITMAP(print_button), + _("Print Module")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP(zoom_in_xpm), + _("zoom + (F1)")); + + m_HToolBar->AddTool(ID_ZOOM_MOINS_BUTT, wxEmptyString,BITMAP(zoom_out_xpm), + _("zoom - (F2)")); + + m_HToolBar->AddTool(ID_ZOOM_REDRAW_BUTT, wxEmptyString,BITMAP(repaint_xpm), + _("redraw (F3)")); + + m_HToolBar->AddTool(ID_ZOOM_PAGE_BUTT, wxEmptyString,BITMAP(zoom_optimal_xpm), + _("auto zoom")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_MODEDIT_PAD_SETTINGS, wxEmptyString, + BITMAP(options_pad_xpm), + _("Pad Settings")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_MODEDIT_CHECK, wxEmptyString, BITMAP(module_check_xpm), + _("Module Check")); + + // after adding the buttons to the toolbar, must call Realize() to reflect + // the changes + m_HToolBar->Realize(); + SetToolbars(); +} + +/********************************************************/ +void WinEDA_ModuleEditFrame::ReCreateVToolbar(void) +/********************************************************/ +{ + if( m_VToolBar ) return; + + m_VToolBar = new WinEDA_Toolbar(TOOLBAR_TOOL, this, ID_V_TOOLBAR, FALSE); + + // Set up toolbar + m_VToolBar->AddTool(ID_NO_SELECT_BUTT, wxEmptyString, + BITMAP(cursor_xpm), wxEmptyString, wxITEM_CHECK ); + m_VToolBar->ToggleTool(ID_NO_SELECT_BUTT, TRUE); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_MODEDIT_ADD_PAD, wxEmptyString, + BITMAP(pad_xpm), + _("Add Pads"), wxITEM_CHECK); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_LINE_COMMENT_BUTT, wxEmptyString, + BITMAP(add_polygon_xpm), + _("Add graphic line or polygon"), wxITEM_CHECK); + + m_VToolBar->AddTool(ID_PCB_CIRCLE_BUTT, wxEmptyString, + BITMAP(add_circle_xpm), + _("Add graphic circle"), wxITEM_CHECK); + + m_VToolBar->AddTool(ID_PCB_ARC_BUTT, wxEmptyString, + BITMAP(add_arc_xpm), + _("Add graphic arc"), wxITEM_CHECK); + + m_VToolBar->AddTool(ID_TEXT_COMMENT_BUTT, wxEmptyString, + BITMAP(add_text_xpm), + _("Add Text"), wxITEM_CHECK); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_MODEDIT_PLACE_ANCHOR, wxEmptyString, + BITMAP(anchor_xpm), + _("Place anchor"), wxITEM_CHECK); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_MODEDIT_DELETE_ITEM_BUTT, wxEmptyString, + BITMAP(delete_body_xpm), + _("Delete items"), wxITEM_CHECK); + + m_VToolBar->Realize(); + + SetToolbars(); +} + +/*********************************************************/ +void WinEDA_ModuleEditFrame::ReCreateOptToolbar(void) +/*********************************************************/ +{ + + if ( m_OptionsToolBar ) return; + + // creation du tool bar options + m_OptionsToolBar = new WinEDA_Toolbar(TOOLBAR_OPTION, this, ID_OPT_TOOLBAR, FALSE); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_GRID, BITMAP(grid_xpm), + wxNullBitmap, + TRUE, + -1, -1, (wxObject *) NULL, + _("Display Grid OFF")); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString, + BITMAP(polar_coord_xpm), + _("Display Polar Coord ON"), wxITEM_CHECK); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString, + BITMAP(unit_inch_xpm), + _("Units = Inch"), wxITEM_CHECK ); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString, + BITMAP(unit_mm_xpm), + _("Units = mm"), wxITEM_CHECK ); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_CURSOR, BITMAP(cursor_shape_xpm), + wxNullBitmap, + TRUE, + -1, -1, (wxObject *) NULL, + _("Change Cursor Shape")); + + m_OptionsToolBar->AddSeparator(); + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_PADS_SKETCH, + BITMAP(pad_sketch_xpm), + wxNullBitmap, + TRUE, + -1, -1, (wxObject *) NULL, + _("Show Pads Sketch")); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, + BITMAP(text_sketch_xpm), + wxNullBitmap, + TRUE, + -1, -1, (wxObject *) NULL, + _("Show Texts Sketch")); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, + BITMAP(show_mod_edge_xpm), + wxNullBitmap, + TRUE, + -1, -1, (wxObject *) NULL, + _("Show Edges Sketch")); + + m_OptionsToolBar->Realize(); + + SetToolbars(); +} + +/*********************************************************/ +void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar(void) +/*********************************************************/ +{ +int ii; +wxString msg; + + if ( m_AuxiliaryToolBar == NULL ) + { + m_AuxiliaryToolBar = new WinEDA_Toolbar(TOOLBAR_AUX, this, ID_AUX_TOOLBAR, TRUE); + + // Set up toolbar + m_AuxiliaryToolBar->AddSeparator(); + + // Boite de selection du pas de grille + m_SelGridBox = new WinEDAChoiceBox(m_AuxiliaryToolBar, + ID_ON_GRID_SELECT, + wxPoint(-1,-1), wxSize(LISTBOX_WIDTH , -1)); + m_AuxiliaryToolBar->AddControl( m_SelGridBox); + + // Boite de selection du Zoom + m_AuxiliaryToolBar->AddSeparator(); + m_SelZoomBox = new WinEDAChoiceBox(m_AuxiliaryToolBar, + ID_ON_ZOOM_SELECT, + wxPoint(-1,-1), wxSize(LISTBOX_WIDTH , -1)); + msg = _("Auto"); + m_SelZoomBox->Append(msg); + for ( int jj = 0, ii = 1; ii <= m_ZoomMaxValue; ii <<= 1, jj++ ) + { + msg.Printf(_("Zoom %d"), ii); + m_SelZoomBox->Append(msg); + } + m_SelZoomBox->Append(wxT("")); + + m_AuxiliaryToolBar->AddControl( m_SelZoomBox); + // after adding the buttons to the toolbar, must call Realize() to reflect + // the changes + m_AuxiliaryToolBar->Realize(); + } + + // mise a jour des affichages + m_SelGridBox->Clear(); + for ( ii = 0; g_GridList[ii].x > 0; ii++ ) + { + double value = To_User_Unit(g_UnitMetric, g_GridList[ii].x, PCB_INTERNAL_UNIT); + if ( g_UnitMetric == INCHES ) + msg.Printf(_("Grid %.1f"), value * 1000); + else + msg.Printf(_("Grid %.3f"), value); + m_SelGridBox->Append(msg); + } + m_SelGridBox->Append( _("User Grid") ); + + SetToolbars(); +} + + + + + + diff --git a/pcbnew/tool_onrightclick.cpp b/pcbnew/tool_onrightclick.cpp new file mode 100644 index 0000000000..c1c6dc69ea --- /dev/null +++ b/pcbnew/tool_onrightclick.cpp @@ -0,0 +1,83 @@ +/********************************************************************************/ +/* tool_onrightclick.cpp: fonctions appelées par le bouton droit sur un TOOL */ +/********************************************************************************/ + +#include "fctsys.h" + +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "id.h" + +#include "protos.h" + + + +/*****************************************************************/ +void WinEDA_PcbFrame::ToolOnRightClick(wxCommandEvent& event) +/*****************************************************************/ +{ +wxPoint pos; +int id = event.GetSelection(); + + wxGetMousePosition(&pos.x, &pos.y); + pos.x -= 400; + pos.y -= 30; + + switch ( id ) + { + case ID_TRACK_BUTT: + InstallPcbOptionsFrame(pos, NULL, ID_PCB_TRACK_SIZE_SETUP); + break; + + case ID_COMPONENT_BUTT: + break; + + case ID_PCB_CIRCLE_BUTT: + case ID_PCB_ARC_BUTT: + case ID_LINE_COMMENT_BUTT: + case ID_PCB_COTATION_BUTT: + case ID_TEXT_COMMENT_BUTT: + InstallPcbOptionsFrame(pos, NULL, ID_PCB_DRAWINGS_WIDTHS_SETUP); + break; + + default: + break; + } +} + +/************************************************************************/ +void WinEDA_ModuleEditFrame::ToolOnRightClick(wxCommandEvent& event) +/************************************************************************/ +{ +wxPoint pos; +int id = event.GetSelection(); + + wxGetMousePosition(&pos.x, &pos.y); + pos.x -= 400; + pos.y -= 30; + + switch ( id ) + { + case ID_MODEDIT_ADD_PAD: + InstallPadOptionsFrame(NULL, NULL, wxPoint(-1,-1) ); + break; + + case ID_PCB_CIRCLE_BUTT: + case ID_PCB_ARC_BUTT: + case ID_LINE_COMMENT_BUTT: + case ID_PCB_COTATION_BUTT: + case ID_TEXT_COMMENT_BUTT: + InstallOptionsFrame(pos); + break; + + default: + DisplayError(this, wxT("ToolOnRightClick() error")); + break; + } +} + + diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp new file mode 100644 index 0000000000..f2e89916f0 --- /dev/null +++ b/pcbnew/tool_pcb.cpp @@ -0,0 +1,471 @@ + /*********************************************/ + /* tool_pcb.cpp: construction des tool bars */ + /*********************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + +#include "bitmaps.h" + +#include "id.h" + +#define BITMAP wxBitmap + +#ifdef __UNIX__ +#define LISTBOX_WIDTH 140 +#else +#define LISTBOX_WIDTH 120 +#endif + +#include "wx/ownerdrw.h" +#include "wx/menuitem.h" + +#define MUWAVE_ENBL + +#include "mw_Add_Stub.xpm" +#include "mw_Add_stub_arc.xpm" +#include "mw_Add_Shape.xpm" +#include "mw_Add_Line.xpm" +#include "mw_Add_Gap.xpm" +#include "mw_toolbar.xpm" +#include "Add_Tracks.xpm" +#include "Add_Zone.xpm" +#include "Show_Zone.xpm" +#include "net_hightlight.xpm" +#include "PcbOffset.xpm" +#include "Add_Mires.xpm" +#include "Mode_Module.xpm" +#include "Mode_Track.xpm" +#include "tool_ratsnet.xpm" +#include "local_ratsnet.xpm" +#include "general_ratsnet.xpm" +#include "add_cotation.xpm" + +/******************************************/ +void WinEDA_PcbFrame::ReCreateHToolbar(void) +/******************************************/ +// Create the main horizontal toolbar +{ +int ii; + + if ( m_HToolBar != NULL ) + { // simple mise a jour de la liste des fichiers anciens + wxMenuItem * item; + for ( ii = 9; ii >=0 ; ii-- ) + { + if( m_FilesMenu->FindItem(ID_LOAD_FILE_1 + ii) ) + { + item = m_FilesMenu->Remove(ID_LOAD_FILE_1 + ii); + if ( item ) delete item; + } + } + for ( ii = 0; ii < 10; ii++ ) + { + if ( GetLastProject(ii).IsEmpty() ) break; + m_FilesMenu->Append(ID_LOAD_FILE_1 + ii, GetLastProject(ii) ); + } + + SetToolbars(); + return; + } + + + m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE); + m_HToolBar->SetRows(1); + SetToolBar(m_HToolBar); + + // Set up toolbar + m_HToolBar->AddTool(ID_NEW_BOARD, wxEmptyString, BITMAP(new_xpm), _("New Board")); + m_HToolBar->AddTool(ID_LOAD_FILE, wxEmptyString, BITMAP(open_xpm), _("Open existing Board")); + m_HToolBar->AddTool(ID_SAVE_BOARD, wxEmptyString, BITMAP(save_xpm), _("Save Board")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_SHEET_SET, wxEmptyString, BITMAP(sheetset_xpm), _("page settings (size, texts)") ); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_OPEN_MODULE_EDITOR, wxEmptyString, BITMAP(modedit_xpm), + _("Open Module Editor")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(wxID_CUT, wxEmptyString, BITMAP(cut_button), _("Cut selected item")); + +#if 0 + m_HToolBar->AddTool(wxID_COPY, wxEmptyString, BITMAP(copy_button), _("Copy selected item")); + + m_HToolBar->AddTool(wxID_PASTE, wxEmptyString, BITMAP(paste_xpm), _("Paste")); +#endif + + m_HToolBar->AddTool(ID_UNDO_BUTT, wxEmptyString, BITMAP(undelete_xpm), _("Undelete")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_GEN_PRINT, wxEmptyString, BITMAP(print_button), _("Print Board")); + m_HToolBar->AddTool(ID_GEN_PLOT, wxEmptyString, BITMAP(plot_xpm), _("Plot (Hplg, Postscript, or Gerber format)")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP(zoom_in_xpm), _("zoom + (F1)")); + m_HToolBar->AddTool(ID_ZOOM_MOINS_BUTT, wxEmptyString, BITMAP(zoom_out_xpm), _("zoom - (F2)")); + m_HToolBar->AddTool(ID_ZOOM_REDRAW_BUTT, wxEmptyString, BITMAP(repaint_xpm), _("redraw (F3)")); + + m_HToolBar->AddTool(ID_ZOOM_PAGE_BUTT, wxEmptyString, BITMAP(zoom_optimal_xpm), _("auto zoom")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_FIND_ITEMS, wxEmptyString, BITMAP(find_xpm), _("Find components and texts")); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_GET_NETLIST, wxEmptyString, BITMAP(netlist_xpm), _("Read Netlist")); + m_HToolBar->AddTool(ID_DRC_CONTROL, wxEmptyString, BITMAP(erc_xpm), _("Pcb Design Rules Check")); + + m_HToolBar->AddSeparator(); + ReCreateLayerBox(m_HToolBar); + + m_HToolBar->AddSeparator(); + m_HToolBar->AddTool(ID_TOOLBARH_PCB_AUTOPLACE, wxEmptyString, BITMAP(mode_module_xpm), + _("Mode Module: Manual and Automatic Move or Place for modules"), wxITEM_CHECK ); + m_HToolBar->AddTool(ID_TOOLBARH_PCB_AUTOROUTE, wxEmptyString, BITMAP(mode_track_xpm), + _("Mode Track and Autorouting"), wxITEM_CHECK); + + + // after adding the buttons to the toolbar, must call Realize() to reflect + // the changes + + m_HToolBar->Realize(); + + SetToolbars(); +} + +/*********************************************/ +void WinEDA_PcbFrame::ReCreateOptToolbar(void) +/*********************************************/ +// Create the left vertical toolbar (option selections) +{ + if ( m_OptionsToolBar ) return; + + // creation du tool bar options + m_OptionsToolBar = new WinEDA_Toolbar(TOOLBAR_OPTION, this, ID_OPT_TOOLBAR, FALSE); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_DRC_OFF, wxEmptyString, BITMAP(drc_off_xpm), + _("Drc OFF"), wxITEM_CHECK); + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, BITMAP(grid_xpm), + _("Display Grid OFF"), wxITEM_CHECK); + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString, + BITMAP(polar_coord_xpm), _("Display Polar Coord ON"), wxITEM_CHECK); + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString, + BITMAP(unit_inch_xpm), _("Units = Inch"), wxITEM_CHECK ); + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString, + BITMAP(unit_mm_xpm), _("Units = mm"), wxITEM_CHECK ); + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString, BITMAP(cursor_shape_xpm), + _("Change Cursor Shape"), wxITEM_CHECK); + + m_OptionsToolBar->AddSeparator(); + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_RATSNEST, wxEmptyString, + BITMAP(general_ratsnet_xpm), + _("Show General Ratsnest"), wxITEM_CHECK); + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_MODULE_RATSNEST,wxEmptyString, + BITMAP(local_ratsnet_xpm), + _("Show Module Ratsnest when moving"), wxITEM_CHECK); + + m_OptionsToolBar->AddSeparator(); + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_AUTO_DEL_TRACK, wxEmptyString, BITMAP(auto_delete_track_xpm), + _("Enable Auto Del Track"), wxITEM_CHECK); + + m_OptionsToolBar->AddSeparator(); + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_ZONES,wxEmptyString, BITMAP(show_zone_xpm), + _("Show Zones"), wxITEM_CHECK); + + m_OptionsToolBar->AddSeparator(); + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_PADS_SKETCH,wxEmptyString, + BITMAP(pad_sketch_xpm), + _("Show Pads Sketch"), wxITEM_CHECK); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,wxEmptyString, + BITMAP(showtrack_xpm), + _("Show Tracks Sketch"), wxITEM_CHECK); + + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_HIGHT_CONTRAST_MODE, wxEmptyString, + BITMAP(palette_xpm), + _("Hight Contrast Mode Display"), wxITEM_CHECK); + m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_HIGHT_CONTRAST_MODE, + DisplayOpt.ContrastModeDisplay); + +#ifdef MUWAVE_ENBL + m_OptionsToolBar->AddSeparator(); + m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1, wxEmptyString, + BITMAP(mw_toolbar_xpm), + _("Display auxiliary vertical toolbar (tools for micro wave applications)\n This is a very experimental feature (under development)"), wxITEM_CHECK); +#endif + + m_OptionsToolBar->Realize(); + + SetToolbars(); +} + + +/********************************************/ +void WinEDA_PcbFrame::ReCreateVToolbar(void) +/********************************************/ +/* Create the main vertical right toolbar, showing usual tools +*/ +{ + if( m_VToolBar ) return; + + m_VToolBar = new WinEDA_Toolbar(TOOLBAR_TOOL, this, ID_V_TOOLBAR, FALSE); + + // Set up toolbar + m_VToolBar->AddTool(ID_NO_SELECT_BUTT, wxEmptyString, + BITMAP(cursor_xpm), wxEmptyString, wxITEM_CHECK ); + m_VToolBar->ToggleTool(ID_NO_SELECT_BUTT, TRUE); + m_VToolBar->AddSeparator(); + + m_VToolBar->AddTool(ID_PCB_HIGHLIGHT_BUTT, wxEmptyString, + BITMAP(net_hightlight_xpm), _("Net highlight"), wxITEM_CHECK ); + + m_VToolBar->AddTool(ID_PCB_SHOW_1_RATSNEST_BUTT, wxEmptyString, + BITMAP(tool_ratsnet_xpm), + _("Display local ratsnest (pad or module)"), wxITEM_CHECK ); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_COMPONENT_BUTT, wxEmptyString, + BITMAP(module_xpm), + _("Add modules"), wxITEM_CHECK); + + m_VToolBar->AddTool(ID_TRACK_BUTT, wxEmptyString, + BITMAP(add_tracks_xpm), + _("Add Tracks an vias"), wxITEM_CHECK); + + m_VToolBar->AddTool(ID_PCB_ZONES_BUTT, wxEmptyString, + BITMAP(add_zone_xpm), + _("Add Zones"), wxITEM_CHECK); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_LINE_COMMENT_BUTT, wxEmptyString, + BITMAP(add_dashed_line_xpm), + _("Add graphic line or polygon"), wxITEM_CHECK); + + m_VToolBar->AddTool(ID_PCB_CIRCLE_BUTT, wxEmptyString, + BITMAP(add_circle_xpm), + _("Add graphic circle"), wxITEM_CHECK); + + m_VToolBar->AddTool(ID_PCB_ARC_BUTT, wxEmptyString, + BITMAP(add_arc_xpm), + _("Add graphic arc"), wxITEM_CHECK); + + m_VToolBar->AddTool(ID_TEXT_COMMENT_BUTT, wxEmptyString, + BITMAP(add_text_xpm), + _("Add Text"), wxITEM_CHECK); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_PCB_COTATION_BUTT, wxEmptyString, + BITMAP(add_cotation_xpm), + _("Add Cotation"), wxITEM_CHECK); + + m_VToolBar->AddTool(ID_PCB_MIRE_BUTT, wxEmptyString, + BITMAP(add_mires_xpm), + _("Add Mires"), wxITEM_CHECK); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_PCB_DELETE_ITEM_BUTT, wxEmptyString, + BITMAP(delete_body_xpm), + _("Delete items"), wxITEM_CHECK); + + m_VToolBar->AddSeparator(); + m_VToolBar->AddTool(ID_PCB_PLACE_OFFSET_COORD_BUTT, wxEmptyString, + BITMAP(pcb_offset_xpm), + _("Offset adjust for drill and place files"), wxITEM_CHECK); + + m_VToolBar->Realize(); + + SetToolbars(); +} + + +/*********************************************/ +void WinEDA_PcbFrame::ReCreateAuxVToolbar(void) +/*********************************************/ +/* Create the auxiliary vertical right toolbar, showing tools fo microwave applications +*/ +{ + if( m_AuxVToolBar ) return; + + m_AuxVToolBar = new WinEDA_Toolbar(TOOLBAR_TOOL, this, ID_AUX_V_TOOLBAR, FALSE); + + // Set up toolbar + m_AuxVToolBar->AddTool(ID_PCB_MUWAVE_TOOL_SELF_CMD, + BITMAP(mw_Add_Line_xpm), + wxNullBitmap, TRUE, + -1,-1, (wxObject *) NULL, + _("Create line of specified length for microwave applications") ); + + m_AuxVToolBar->AddTool(ID_PCB_MUWAVE_TOOL_GAP_CMD, + BITMAP(mw_Add_Gap_xpm), + wxNullBitmap, TRUE, + -1,-1, (wxObject *) NULL, + _("Create gap of specified length for microwave applications") ); + + m_AuxVToolBar->AddSeparator(); + + m_AuxVToolBar->AddTool(ID_PCB_MUWAVE_TOOL_STUB_CMD, + BITMAP(mw_Add_Stub_xpm), + wxNullBitmap, TRUE, + -1,-1, (wxObject *) NULL, + _("Create stub of specified length for microwave applications") ); + + m_AuxVToolBar->AddTool(ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD, + BITMAP(mw_Add_stub_arc_xpm), + wxNullBitmap, TRUE, + -1,-1, (wxObject *) NULL, + _("Create stub (arc) of specified length for microwave applications") ); + + m_AuxVToolBar->AddTool(ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD, + BITMAP(mw_Add_Shape_xpm), + wxNullBitmap, TRUE, + -1,-1, (wxObject *) NULL, + _("Create a polynomial shape for microwave applications") ); + + m_AuxVToolBar->Realize(); + + SetToolbars(); +} + +/****************************************************/ +void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar(void) +/****************************************************/ +/* Create auxiliary horizontal toolbar +*/ +{ +int ii; +wxString msg; + + if ( m_AuxiliaryToolBar == NULL ) + { + m_AuxiliaryToolBar = new WinEDA_Toolbar(TOOLBAR_AUX, this, ID_AUX_TOOLBAR, TRUE); + + // Set up toolbar + m_AuxiliaryToolBar->AddSeparator(); + m_SelTrackWidthBox = new WinEDAChoiceBox(m_AuxiliaryToolBar, + ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, + wxPoint(-1,-1), wxSize(LISTBOX_WIDTH+20, -1)); + m_AuxiliaryToolBar->AddControl(m_SelTrackWidthBox); + m_SelTrackWidthBox_Changed = TRUE; + + m_AuxiliaryToolBar->AddSeparator(); + m_SelViaSizeBox = new WinEDAChoiceBox(m_AuxiliaryToolBar, + ID_AUX_TOOLBAR_PCB_VIA_SIZE, + wxPoint(-1,-1), wxSize(LISTBOX_WIDTH+10, -1)); + m_AuxiliaryToolBar->AddControl(m_SelViaSizeBox); + + m_AuxiliaryToolBar->AddSeparator(); + // Boite de selection du pas de grille + m_SelGridBox = new WinEDAChoiceBox(m_AuxiliaryToolBar, + ID_ON_GRID_SELECT, + wxPoint(-1,-1), wxSize(LISTBOX_WIDTH, -1)); + m_AuxiliaryToolBar->AddControl( m_SelGridBox); + + // Boite de selection du Zoom + m_AuxiliaryToolBar->AddSeparator(); + m_SelZoomBox = new WinEDAChoiceBox(m_AuxiliaryToolBar, + ID_ON_ZOOM_SELECT, + wxPoint(-1,-1), wxSize(LISTBOX_WIDTH, -1)); + msg = _("Auto"); + m_SelZoomBox->Append(msg); + for ( int jj = 0, ii = 1; ii <= m_ZoomMaxValue; ii <<= 1, jj++ ) + { + msg = _("Zoom "); msg << ii; + m_SelZoomBox->Append(msg); + } + m_SelZoomBox->Append(wxT("")); + + m_AuxiliaryToolBar->AddControl( m_SelZoomBox); + + // after adding the buttons to the toolbar, must call Realize() + m_AuxiliaryToolBar->Realize(); + } + + // mise a jour des affichages + m_SelGridBox->Clear(); + wxString format = _("Grid"); + if ( g_UnitMetric == INCHES ) format += wxT(" %.1f"); + else format += wxT(" %.3f"); + + for ( ii = 0; g_GridList[ii].x > 0; ii++ ) + { + double value = To_User_Unit(g_UnitMetric, g_GridList[ii].x, PCB_INTERNAL_UNIT); + if ( g_UnitMetric == INCHES ) + msg.Printf( format.GetData(), value * 1000); + else + msg.Printf( format.GetData(), value); + m_SelGridBox->Append(msg); + } + m_SelGridBox->Append( _("User Grid") ); + + m_SelViaSizeBox_Changed = TRUE; + m_SelTrackWidthBox_Changed = TRUE; + + SetToolbars(); +} + + +/**********************************************************************/ +WinEDAChoiceBox * WinEDA_PcbFrame::ReCreateLayerBox(WinEDA_Toolbar * parent) +/**********************************************************************/ +{ +int ii, jj, ll; +bool rebuild = FALSE; +long current_mask_layer; + + if ( m_SelLayerBox == NULL ) + { + if ( parent == NULL ) return NULL; + m_SelLayerBox = new WinEDAChoiceBox(parent, ID_TOOLBARH_PCB_SELECT_LAYER, + wxPoint(-1,-1), wxSize(LISTBOX_WIDTH, -1)); + parent->AddControl(m_SelLayerBox); + } + + // Test si reconstruction de la liste nécessaire + current_mask_layer = 0; + int Masque_Layer = g_TabAllCopperLayerMask[g_DesignSettings.m_CopperLayerCount-1]; + Masque_Layer |= ALL_NO_CU_LAYERS; + for ( ii = 0; ii < (int)m_SelLayerBox->GetCount() ; ii ++ ) + { + jj = (int) ((size_t) m_SelLayerBox->GetClientData(ii)); + current_mask_layer |= g_TabOneLayerMask[jj]; + } + if ( current_mask_layer != Masque_Layer) rebuild = TRUE; + + // Construction de la liste + if ( rebuild ) + { + m_SelLayerBox->Clear(); + for ( ii = 0, jj = 0; ii <= EDGE_N ; ii ++ ) + { + if ( (g_TabOneLayerMask[ii] & Masque_Layer) ) + { + m_SelLayerBox->Append(ReturnPcbLayerName(ii)); + m_SelLayerBox->SetClientData(jj, (void*)ii); + jj++; + } + } + } + + // Activation de l'affichage sur la bonne couche + // Pour eviter la reentrance (Bug wxGTK version Linux?), la selection n'est faite que si + // elle est mauvaise (Pb corrige sur wxGTK 2.6.0) + jj = m_SelLayerBox->GetCount(); + ll = m_SelLayerBox->GetChoice(); + for ( ii = 0; ii < jj ; ii ++ ) + { + if ( (int)((size_t)m_SelLayerBox->GetClientData(ii)) == GetScreen()->m_Active_Layer ) + { + if ( ii != ll ) m_SelLayerBox->SetSelection( ii ); + break; + } + } + + return m_SelLayerBox; +} + + diff --git a/pcbnew/tr_modif.cpp b/pcbnew/tr_modif.cpp new file mode 100644 index 0000000000..500b22d4b3 --- /dev/null +++ b/pcbnew/tr_modif.cpp @@ -0,0 +1,212 @@ + /**************************************************/ + /* Edition des pistes */ + /* Routines de modification automatique de pistes */ + /**************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + +/*********************************************************************/ +int EraseOldTrack(WinEDA_BasePcbFrame * frame, BOARD * Pcb, wxDC * DC, + TRACK * pt_new_track, int nbptnewpiste) +/*********************************************************************/ +/* Routine d'effacement de la piste redondante a la piste nouvellement cree + pointee par pt_new_track (nbptnewpiste segments) + + la piste cree est supposee constituee de segments contigus en memoire avec: + point de depart pt_newtrack->m_Start.x,y + point d'arrivee pt_newtrack->m_End.x,y +*/ +{ +TRACK * StartTrack, * EndTrack; /* Pointeurs des segments de debut et fin + (extremites) de la nouvelle piste */ +TRACK * EndNewTrack, /* Pointeur sur le dernier segment de la liste + chainee de la mouvelle piste */ + * pt_segm, * pt_del; +int ii, jj, nb_segm, nbconnect; +wxPoint start; /* coord du point de depart de la piste */ +wxPoint end; /* coord du point de fin de la piste */ +int startmasklayer, endmasklayer; /* masque couche de depart et de fin */ +TRACK * BufDeb, *BufEnd; /* Pointeurs de debut et de fin de la zone + des pistes equipotentielles */ + + /* Reconstitution de la piste complete ( la nouvelle piste + a pu demarrer sur un segment de piste en l'air */ + ListSetState(pt_new_track,nbptnewpiste,BUSY,OFF); + /* si la novelle piste commence par une via, il est plus sur de rechercher + la piste complete en utilisant le segment suivant comme reference, car + une via est souvent sur un carrefour de segments, et ne caracterise pas + une piste */ + if( pt_new_track->m_StructType == TYPEVIA && (nbptnewpiste > 1 ) ) + pt_new_track = (TRACK *) pt_new_track->Pnext; + pt_new_track = Marque_Une_Piste(frame, DC, pt_new_track, &nbptnewpiste, 0); + + EndNewTrack = pt_new_track; + for( ii = 1; ii < nbptnewpiste; ii++ ) + { + EndNewTrack = (TRACK *) EndNewTrack->Pnext; + } + + /* Calcul des limites de recherche des segments de piste */ + /* BufDeb pointe le 1er segment utile */ + BufDeb = Pcb->m_Track->GetStartNetCode(pt_new_track->m_NetCode); + + /* BufEnd Pointe le dernier segment */ + BufEnd = BufDeb->GetEndNetCode(pt_new_track->m_NetCode); + + /* nettoyage des flags pour tout le net */ + for(pt_del = BufDeb; pt_del != NULL; pt_del = (TRACK*)pt_del->Pnext) + { + pt_del->SetState(BUSY|EDIT|CHAIN, OFF); + if( pt_del == BufEnd ) break; + } + + /* Calcul des points limites de la nouvelle piste */ + if( ReturnEndsTrack(pt_new_track,nbptnewpiste, + &StartTrack, &EndTrack) == 0 ) return(0); + + if( (StartTrack == NULL) || (EndTrack == NULL) ) return(0); + + /* Calcul des caracteristiques des points de debut et de fin */ + start = StartTrack->m_Start; + end = EndTrack->m_End; + + /* Les points de depart et de fin doivent etre distincts */ + if( start == end ) return(0); + + /* Determinations des couches interconnectees a ces points */ + startmasklayer = StartTrack->ReturnMaskLayer(); + endmasklayer = EndTrack->ReturnMaskLayer(); + /* Il peut y avoir une via ou un pad sur les extremites: */ + pt_segm = Fast_Locate_Via(Pcb->m_Track, NULL, start, startmasklayer); + if( pt_segm ) startmasklayer |= pt_segm->ReturnMaskLayer(); + if( StartTrack->start && (StartTrack->start->m_StructType == TYPEPAD) ) + { /* start sur pad */ + D_PAD * pt_pad = (D_PAD*) (StartTrack->start) ; + startmasklayer |= pt_pad->m_Masque_Layer; + } + + pt_segm = Fast_Locate_Via(Pcb->m_Track, NULL, end, endmasklayer); + if( pt_segm ) endmasklayer |= pt_segm->ReturnMaskLayer(); + if( EndTrack->end && ( EndTrack->end->m_StructType == TYPEPAD) ) + { + D_PAD * pt_pad = (D_PAD*) (EndTrack->end) ; + endmasklayer |= pt_pad->m_Masque_Layer; + } + + /* Marquage a DELETED de la piste nouvelle (qui ne doit pas intervenir + dans la recherche d'autres connexions) */ + ListSetState(pt_new_track, nbptnewpiste,DELETED,ON); + + /* test : un segment doit etre connecte au point de depart car sinon + il est inutile d'analyser l'autre point */ + + pt_segm = Fast_Locate_Piste(BufDeb, BufEnd, start, startmasklayer); + + if(pt_segm == NULL) /* Pas de piste reliee au point de depart */ + { + /* Suppression du flag DELETED */ + ListSetState(pt_new_track,nbptnewpiste, DELETED,OFF); + return(0); + } + + /* Marquage a CHAIN des segments candidats connectes au point de fin + Remarque: les vias ne sont pas prises en compte car elles ne permettent + pas de definir une piste, puisque elles sont sur un carrefour */ + for( pt_del = BufDeb, nbconnect = 0; ; ) + { + pt_segm = Fast_Locate_Piste( pt_del,BufEnd, end, endmasklayer ); + if( pt_segm == NULL) break; + + if(pt_segm->m_StructType != TYPEVIA) + { /* Segment trouve */ + if( pt_segm->GetState(CHAIN) == 0 ) + { + pt_segm->SetState(CHAIN,ON); + nbconnect++; + } + } + if( pt_del == BufEnd ) break; + pt_del = (TRACK*)pt_segm->Pnext; + } + + + if( nbconnect == 0) + { + /* nettoyage des flags */ + for(pt_del = BufDeb; pt_del != NULL; pt_del = (TRACK*)pt_del->Pnext) + { + pt_del->SetState(DELETED|EDIT|CHAIN, OFF); + if( pt_del == BufEnd ) break; + } + return(0); + } + + /* Marquage a EDIT de la piste nouvelle (qui ne doit pas intervenir + dans la recherche d'autres pistes) */ + ListSetState(pt_new_track,nbptnewpiste, DELETED,OFF); + + ListSetState(pt_new_track,nbptnewpiste, EDIT,ON); + + /* Examen de tous les segments marques */ + while( nbconnect ) + { + for(pt_del = BufDeb; pt_del != NULL; pt_del = (TRACK*)pt_del->Pnext) + { + if( pt_del->GetState(CHAIN) ) break; + if( pt_del == BufEnd ) break; + } + + nbconnect--; pt_del->SetState(CHAIN,OFF); + pt_del = Marque_Une_Piste(frame, DC, pt_del, &nb_segm, 0); + + /* Test si La piste marquee est redondante, c'est a dire si l'un des + segments marques est connecte au point de depart de la piste nouvelle + */ + ii = 0; pt_segm = pt_del; + for( ;pt_segm && (ii < nb_segm); pt_segm = (TRACK*)pt_segm->Pnext, ii++) + { + if( (pt_segm->GetState(BUSY)) == 0 ) break; + + if( (pt_segm->m_Start == start) || (pt_segm->m_End == start) ) + { /* la piste marquee peut etre effacee */ + TRACK* NextS; + Trace_Une_Piste(frame->DrawPanel, DC, pt_del, nb_segm, GR_XOR|GR_SURBRILL); + for ( jj = 0; jj < nb_segm; jj++, pt_del = NextS) + { + NextS = (TRACK*) pt_del->Pnext; + DeleteStructure(pt_del); + } + /* nettoyage des flags */ + for(pt_del = Pcb->m_Track; pt_del != NULL; pt_del = (TRACK*)pt_del->Pnext) + { + if (pt_del->GetState(EDIT) ) + { + pt_del->SetState(EDIT, OFF); + pt_del->Draw(frame->DrawPanel, DC, GR_OR); + } + pt_del->SetState(EDIT|CHAIN, OFF); + } + return(1); + } + } + + /* nettoyage du flag BUSY puisque ici la piste marquee n'a pas + ete retenuee */ + ListSetState(pt_del, nb_segm, BUSY,OFF); + } + + /* nettoyage des flags */ + for(pt_del = Pcb->m_Track; pt_del != NULL; pt_del = (TRACK*)pt_del->Pnext) + { + pt_del->SetState(DELETED|EDIT|CHAIN, OFF); + if( pt_del == BufEnd ) break; + } + return(0); +} + diff --git a/pcbnew/tracemod.cpp b/pcbnew/tracemod.cpp new file mode 100644 index 0000000000..dc078ba528 --- /dev/null +++ b/pcbnew/tracemod.cpp @@ -0,0 +1,89 @@ + /*************************/ + /* affichage des modules */ + /*************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "trigo.h" + +#ifdef PCBNEW +#include "drag.h" +#endif + +#ifdef CVPCB +#include "cvpcb.h" +#endif + +/* Police des caracteres de la routine de trace des textes */ +extern char *graphic_fonte_shape[]; + +#include "protos.h" + +#define L_MIN_DESSIN 1 /* seuil de largeur des segments pour trace autre que filaire */ + +/* fonctions locales : */ + + + +/******************************************************************/ +void Trace_Pads_Only(WinEDA_DrawPanel * panel, wxDC * DC, MODULE * Module, + int ox, int oy, + int MasqueLayer,int draw_mode) +/******************************************************************/ + +/* Trace les pads d'un module en mode SKETCH. + Utilisee pour afficher les pastilles d'un module lorsque celui ci n'est + pas affiche par les options d'affichage des Modules + + Les pads affiches doivent apparaitre sur les couches donnees par + MasqueLayer +*/ +{ +int tmp; +D_PAD * pt_pad ; +PCB_SCREEN * screen; +WinEDA_BasePcbFrame * frame; + + screen = (PCB_SCREEN *) panel->GetScreen(); + frame = (WinEDA_BasePcbFrame *) panel->m_Parent; + + tmp = frame->m_DisplayPadFill; + frame->m_DisplayPadFill = FALSE; + + /* trace des pastilles */ + pt_pad = Module->m_Pads; + for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) + { + if( (pt_pad->m_Masque_Layer & MasqueLayer) == 0 ) continue; + pt_pad->Draw(panel, DC, wxPoint(ox,oy), draw_mode); + } + + frame->m_DisplayPadFill = tmp; +} + + +/***********************************************************************/ +void Affiche_1_Segment(WinEDA_DrawPanel * panel, wxDC * DC, + int ux0, int uy0, int dx, int dy, + int width, int mode, int color) +/***********************************************************************/ +/* Trace un segment origine ux0,uy0, fin en dx, dy, + largeur l_piste, mode FILL ou SKETCH, en couleur color + Les coord sont en 1/10000 pouce +*/ +{ +int zoom = panel->GetZoom(); + + if( (width/zoom) < L_MIN_DESSIN ) + GRLine(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, color) ; + + else + if( mode == SKETCH) + GRCSegm(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, width, color) ; + + else GRFillCSegm(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, width, color) ; +} + diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp new file mode 100644 index 0000000000..0cfc83eac1 --- /dev/null +++ b/pcbnew/tracepcb.cpp @@ -0,0 +1,192 @@ + /*****************************************/ + /* Routines generales d'affichage du PCB */ + /*****************************************/ + + /* fichier tracepcb.cpp */ +/* + Routines d'affichage grille, Boite de coordonnees, Curseurs, marqueurs ... +*/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "pcbplot.h" + +#include "protos.h" + +/* Routines Locales : */ + +/* Variables Locales */ + + +/**********************************************************************/ +void WinEDA_ModuleEditFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg) +/**********************************************************************/ + +/* Trace le PCB, et les elements complementaires ( axes, grille .. ) + pour l'ecran actif et ses sous ecran +*/ + +{ +MODULE * Module; +PCB_SCREEN * screen = GetScreen(); + + if ( ! m_Pcb || ! screen ) return; + + ActiveScreen = screen; + GRSetDrawMode(DC, GR_COPY); + + if ( EraseBg ) DrawPanel->EraseScreen(DC); + + DrawPanel->DrawBackGround(DC); + TraceWorkSheet(DC, screen); + + Module = (MODULE*) m_Pcb->m_Modules; + for ( ; Module != NULL; Module = (MODULE *) Module->Pnext ) + { + Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); + } + + + Affiche_Status_Box(); + + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + + /* Reaffichage du curseur */ + DrawPanel->Trace_Curseur(DC); + + screen->ClrRefreshReq(); +} + +/****************************************************************/ +void WinEDA_PcbFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg) +/****************************************************************/ +/* Trace le PCB, et les elements complementaires ( axes, grille .. ) + pour l'ecran actif et ses sous ecran +*/ +{ +PCB_SCREEN * Screen = GetScreen(); + + if ( ! m_Pcb || ! Screen ) return; + + ActiveScreen = GetScreen(); + GRSetDrawMode(DC, GR_COPY); + + if ( EraseBg ) DrawPanel->EraseScreen(DC); + + DrawPanel->DrawBackGround(DC); + + Trace_Pcb(DC, GR_OR); + TraceWorkSheet(DC, GetScreen()); + Affiche_Status_Box(); + + /* Reaffichage des curseurs */ + for( Screen = GetScreen(); Screen != NULL; Screen = Screen->Next() ) + { + if( DrawPanel->ManageCurseur ) + DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); + DrawPanel->Trace_Curseur(DC); + } +} + +/****************************************************/ +void WinEDA_PcbFrame::Trace_Pcb(wxDC * DC, int mode) +/****************************************************/ +/* Trace l'ensemble des elements du PCB sur l'ecran actif*/ +{ +MARQUEUR * Marqueur; +MODULE * Module; +EDA_BaseStruct * PtStruct; + + if ( ! m_Pcb ) return; + + Module = (MODULE*) m_Pcb->m_Modules; + for ( ; Module != NULL; Module = (MODULE *) Module->Pnext ) + { + bool display = TRUE, MaskLay = ALL_CU_LAYERS; + if( Module->m_Flags & IS_MOVED ) continue ; + + if( ! DisplayOpt.Show_Modules_Cmp ) + { + if(Module->m_Layer == CMP_N) display = FALSE; + MaskLay &= ~CMP_LAYER; + } + if( ! DisplayOpt.Show_Modules_Cu ) + { + if(Module->m_Layer == CUIVRE_N) display = FALSE; + MaskLay &= ~CUIVRE_LAYER; + } + + if ( display ) Module->Draw(DrawPanel, DC, wxPoint(0,0), mode); + else Trace_Pads_Only(DrawPanel, DC, Module, 0, 0, MaskLay, mode); + } + + /* Trace des elements particuliers de Drawings Pcb */ + + PtStruct = m_Pcb->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + if ( PtStruct->m_Flags & IS_MOVED ) continue; + + switch(PtStruct->m_StructType) + { + case TYPECOTATION: + ((COTATION*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0), mode); + break; + + case TYPETEXTE: + ((TEXTE_PCB*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0), mode ); + break; + + case TYPEMIRE: + ((MIREPCB*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0), mode); + break; + + case TYPEMARQUEUR: /* Trace des marqueurs */ + Marqueur = ( MARQUEUR*) PtStruct; + Marqueur->Draw(DrawPanel, DC, mode); + break; + + default: break; + } + } + + Trace_Pistes(DrawPanel, m_Pcb, DC, mode); + if ( g_HightLigt_Status ) DrawHightLight(DC, g_HightLigth_NetCode) ; + + EDGE_ZONE * segment = m_Pcb->m_CurrentLimitZone; + for( ; segment != NULL; segment = (EDGE_ZONE *) segment->Pback) + { + if ( segment->m_Flags & IS_MOVED ) continue; + Trace_DrawSegmentPcb(DrawPanel, DC, segment, mode); + } + + Trace_PcbEdges(DC, mode); + DrawGeneralRatsnest(DC); + + m_CurrentScreen->ClrRefreshReq(); +} + + +/**************************************************************/ +void WinEDA_PcbFrame::Trace_PcbEdges(wxDC * DC, int mode_color) +/**************************************************************/ +/* impression des contours ( edge pcb) : et draw */ +{ +EDA_BaseStruct * PtStruct; + + if ( ! m_Pcb ) return; + for ( PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Pnext) + { + if ( PtStruct->m_Flags & IS_MOVED ) continue; + if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; + Trace_DrawSegmentPcb(DrawPanel, DC, (DRAWSEGMENT *) PtStruct,mode_color); + } +} + + + diff --git a/pcbnew/track.cpp b/pcbnew/track.cpp new file mode 100644 index 0000000000..521b61a80f --- /dev/null +++ b/pcbnew/track.cpp @@ -0,0 +1,401 @@ + /*********************************************/ + /* Edition des pistes: Routines d'effacement */ + /* Effacement de segment, piste, net et zone */ + /*********************************************/ + +#include "fctsys.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + +class TSTSEGM /* memorisation des segments marques */ +{ +public: + TSTSEGM *Pnext, *Pback; + TRACK * RefTrack; + +public: + TSTSEGM(TRACK * Father) + { + Pback = Pnext = NULL; + RefTrack = Father; + } +}; + +/* Routines externes : */ +void Montre_Position_New_Piste(int flag); /* defini dans editrack.cc */ + + +/* Routines Locales */ +static void Marque_Chaine_segments(BOARD * Pcb, wxPoint ref_pos, int masklayer); + +/* Variables locales */ +TSTSEGM * ListSegm = NULL; + +/****************************************************************************/ +TRACK * Marque_Une_Piste(WinEDA_BasePcbFrame * frame, wxDC * DC, + TRACK* pt_segm, int * nb_segm, int flagcolor) +/****************************************************************************/ +/* Routine de Marquage de 1 piste, a partir du segment pointe par pt_segm. + le segment pointe est marque puis les segments connectes + jusqu'a un pad ou un point de jonction de plus de 2 segments + le marquage est la mise a 1 du bit BUSY + Les segments sont ensuite reclasses pour etre contigus en liste chainee + Retourne: + adresse du 1er segment de la chaine creee + nombre de segments +*/ +{ +int NbSegmBusy, masque_layer; +TRACK *Track, *FirstTrack, *NextTrack; +TSTSEGM * Segm, * NextSegm; + + *nb_segm = 0; + if (pt_segm == NULL ) return(NULL) ; + + /* Marquage du segment pointe */ + if(flagcolor) pt_segm->Draw(frame->DrawPanel, DC, flagcolor); + + pt_segm->SetState(BUSY,ON); + masque_layer = pt_segm->ReturnMaskLayer(); + ListSegm = new TSTSEGM(pt_segm); + + /* Traitement du segment pointe : si c'est un segment, le cas est simple. + Si c'est une via, on doit examiner le nombre de segments connectes. + Si <=2, on doit detecter une piste, si > 2 seule la via est marquee + */ + if( pt_segm->m_StructType == TYPEVIA) + { + TRACK * Segm1, *Segm2 = NULL, *Segm3 =NULL; + Segm1 = Fast_Locate_Piste(frame->m_Pcb->m_Track,NULL, + pt_segm->m_Start, masque_layer); + if(Segm1) + { + Segm2 = Fast_Locate_Piste((TRACK*)Segm1->Pnext,NULL, + pt_segm->m_Start, masque_layer); + } + if( Segm2 ) + { + Segm3 = Fast_Locate_Piste((TRACK*)Segm2->Pnext,NULL, + pt_segm->m_Start, masque_layer); + } + if(Segm3) + { + *nb_segm = 1; return (pt_segm); + } + if(Segm1) + { + masque_layer = Segm1->ReturnMaskLayer(); + Marque_Chaine_segments(frame->m_Pcb, pt_segm->m_Start, masque_layer); + } + if(Segm2) + { + masque_layer = Segm2->ReturnMaskLayer(); + Marque_Chaine_segments(frame->m_Pcb, pt_segm->m_Start, masque_layer); + } + } + else /* Marquage de la chaine connectee aux extremites du segment */ + { + Marque_Chaine_segments(frame->m_Pcb, pt_segm->m_Start, masque_layer); + Marque_Chaine_segments(frame->m_Pcb, pt_segm->m_End, masque_layer); + } + + /* marquage des vias (vias non connectees ou inutiles */ + for( Segm = ListSegm; Segm != NULL; Segm = Segm->Pnext ) + { + int layer; + if( Segm->RefTrack->m_StructType != TYPEVIA ) continue; + if( Segm->RefTrack == pt_segm ) continue; + Segm->RefTrack->SetState(BUSY,ON); + masque_layer = Segm->RefTrack->ReturnMaskLayer(); + Track = Fast_Locate_Piste(frame->m_Pcb->m_Track,NULL, + Segm->RefTrack->m_Start, + masque_layer); + if( Track == NULL ) continue; + /* Test des connexions: si via utile: suppression marquage */ + layer = Track->m_Layer; + while ( (Track = Fast_Locate_Piste((TRACK*)Track->Pnext,NULL, + Segm->RefTrack->m_Start, + masque_layer)) != NULL ) + { + if( layer != Track->m_Layer ) + { + Segm->RefTrack->SetState(BUSY,OFF); + break; + } + } + } + + /* liberation memoire */ + for( Segm = ListSegm; Segm != NULL; Segm = NextSegm ) + { + NextSegm = Segm->Pnext; delete Segm; + } + ListSegm = NULL; + + /* Reclassement des segments marques en une chaine */ + FirstTrack = frame->m_Pcb->m_Track; NbSegmBusy = 0; + for ( ; FirstTrack != NULL; FirstTrack = (TRACK*)FirstTrack->Pnext ) + { /* recherche du debut de la liste des segments marques a BUSY */ + if ( FirstTrack->GetState(BUSY) ) + { + NbSegmBusy = 1; break; + } + } + + /* Reclassement de la chaine debutant a FirstTrack et finissant + au dernier segment marque. FirstTrack n'est pas modifie */ + Track = (TRACK*)FirstTrack->Pnext; + for ( ; Track != NULL; Track = NextTrack) + { + NextTrack = (TRACK*) Track->Pnext; + if ( Track->GetState(BUSY) ) + { + NbSegmBusy++; + Track->UnLink(); + Track->Insert(frame->m_Pcb, FirstTrack); + } + } + + *nb_segm = NbSegmBusy; + + if(flagcolor) Trace_Une_Piste(frame->DrawPanel, DC, FirstTrack,NbSegmBusy,flagcolor); + + return(FirstTrack); +} + + +/********************************************************************************/ +static void Marque_Chaine_segments(BOARD * Pcb, wxPoint ref_pos, int masque_layer) +/********************************************************************************/ +/* + routine utilisee par Supprime_1_Piste() + Positionne le bit BUSY dans la chaine de segments commencant + au point ox, oy sur la couche layer + + Les vias sont mises en liste des segments traites mais ne sont pas + marquees. +*/ +{ +TRACK *pt_segm, // Pointe le segment courant analyse + * pt_via, // pointe la via reperee, eventuellement a detruire + * MarqSegm; // pointe le segment a detruire (= NULL ou pt_segm +int NbSegm; +TSTSEGM * Segm; + + if(Pcb->m_Track == NULL) return; + + /* Marquage de la chaine */ + for( ; ; ) + { + if( Fast_Locate_Pad_Connecte(Pcb, ref_pos,masque_layer) != NULL ) return; + + /* Localisation d'une via (car elle connecte plusieurs segments) */ + pt_via = Fast_Locate_Via(Pcb->m_Track, NULL, ref_pos, masque_layer); + if(pt_via) + { + if(pt_via->GetState(EDIT)) return; + masque_layer = pt_via->ReturnMaskLayer(); + Segm = new TSTSEGM(pt_via); + Segm->Pnext = ListSegm; + ListSegm->Pback = Segm; + ListSegm = Segm; + } + + /* Recherche des segments connectes au point ref_pos + si 1 segment: peut etre marque + si > 1 segment: + le segment ne peut etre marque + */ + pt_segm =Pcb->m_Track; MarqSegm = NULL; + NbSegm = 0; + while( (pt_segm = Fast_Locate_Piste(pt_segm, NULL, + ref_pos,masque_layer) ) != NULL ) + { + if(pt_segm->GetState(EDIT)) /* Fin de piste */ + return; + + if(pt_segm->GetState(BUSY) ) + { + pt_segm = (TRACK*)pt_segm->Pnext; + continue; + } + + if( pt_segm == pt_via) /* deja traite */ + { + pt_segm = (TRACK*)pt_segm->Pnext; + continue; + } + + NbSegm++; + if( NbSegm == 1 ) /* 1ere detection de segment de piste */ + { + MarqSegm = pt_segm; + pt_segm = (TRACK*)pt_segm->Pnext; + } + else /* 2eme detection de segment -> fin de piste */ + { + return; + } + } + + if( MarqSegm ) + { + /* preparation de la nouvelle recherche */ + masque_layer = MarqSegm->ReturnMaskLayer(); + if( ref_pos == MarqSegm->m_Start ) + { + ref_pos = MarqSegm->m_End; + } + else { + ref_pos = MarqSegm->m_Start; + } + + pt_segm = Pcb->m_Track; /* reinit recherche des segments */ + + /* Marquage et mise en liste du segment */ + Segm = new TSTSEGM(MarqSegm); + Segm->Pnext = ListSegm; + ListSegm->Pback = Segm; + ListSegm = Segm; + MarqSegm->SetState(BUSY,ON); + } + else return; + } +} + + + /********************************************************/ +int ReturnEndsTrack(TRACK* RefTrack, int NbSegm, + TRACK ** StartTrack, TRACK ** EndTrack) +/**********************************************************/ +/* Calcule les coordonnes des extremites d'une piste + retourne 1 si OK, 0 si piste bouclee + Retourne dans *StartTrack en *EndTrack les segments de debut et fin + Les coord StartTrack->m_Start.x, m_Start.y contiennent le debut de la piste + Les coord EndTrack->m_End.x, m_End.y contiennent le debut de la piste + Les segments sont supposes chaines de facon consecutive +*/ +{ +TRACK * Track, *via, *segm, * TrackListEnd; +int NbEnds, masque_layer, ii, ok = 0; + + if( NbSegm <= 1 ) + { + *StartTrack = *EndTrack = RefTrack; + return(1); /* cas trivial */ + } + + /* calcul de la limite d'analyse */ + *StartTrack = *EndTrack = NULL; + TrackListEnd = Track = RefTrack; ii = 0; + for( ; (Track != NULL) && (ii < NbSegm); ii++, Track = (TRACK*)Track->Pnext) + { + TrackListEnd = Track; + Track->m_Param = 0; + } + + /* Calcul des extremites */ + NbEnds = 0; Track = RefTrack; ii = 0; + for( ; (Track != NULL) && (ii < NbSegm); ii++, Track = (TRACK*)Track->Pnext) + { + if(Track->m_StructType == TYPEVIA) continue; + + masque_layer = Track->ReturnMaskLayer(); + via = Fast_Locate_Via(RefTrack, TrackListEnd, + Track->m_Start, masque_layer); + if( via ) + { + masque_layer |= via->ReturnMaskLayer(); + via->SetState(BUSY,ON); + } + + Track->SetState(BUSY,ON); + segm = Fast_Locate_Piste(RefTrack, TrackListEnd, + Track->m_Start, masque_layer); + Track->SetState(BUSY,OFF); + if(via) via->SetState(BUSY,OFF); + + if( segm == NULL ) + { + switch(NbEnds) + { + case 0: + *StartTrack = Track; NbEnds++; + break; + + case 1: + int BeginPad, EndPad; + *EndTrack = Track; + /* permutation de ox,oy avec fx,fy */ + BeginPad = Track->GetState(BEGIN_ONPAD); + EndPad = Track->GetState(END_ONPAD); + Track->SetState(BEGIN_ONPAD|END_ONPAD, OFF); + if( BeginPad ) + Track->SetState(END_ONPAD, ON); + if( EndPad ) + Track->SetState(BEGIN_ONPAD, ON); + EXCHG(Track->m_Start,Track->m_End); + EXCHG(Track->start,Track->end); + ok = 1; return(ok); + } + } + + masque_layer = Track->ReturnMaskLayer(); + via = Fast_Locate_Via(RefTrack, TrackListEnd, + Track->m_End, masque_layer); + if( via ) + { + masque_layer |= via->ReturnMaskLayer(); + via->SetState(BUSY,ON); + } + + Track->SetState(BUSY,ON); + segm = Fast_Locate_Piste(RefTrack, TrackListEnd, + Track->m_End, masque_layer); + Track->SetState(BUSY,OFF); + if (via) via->SetState(BUSY,OFF); + if ( segm == NULL ) + { + switch(NbEnds) + { + case 0: + int BeginPad, EndPad; + *StartTrack = Track; NbEnds++; + /* permutation de ox,oy avec fx,fy */ + BeginPad = Track->GetState(BEGIN_ONPAD); + EndPad = Track->GetState(END_ONPAD); + Track->SetState(BEGIN_ONPAD|END_ONPAD, OFF); + if( BeginPad ) + Track->SetState(END_ONPAD, ON); + if( EndPad ) + Track->SetState(BEGIN_ONPAD, ON); + EXCHG(Track->m_Start,Track->m_End); + EXCHG(Track->start,Track->end); + break; + + case 1: + *EndTrack = Track; + ok = 1; return(ok); + } + } + } + + return(ok); +} + + +/***************************************************************************/ +void ListSetState(EDA_BaseStruct * Start, int NbItem,int State, int onoff) +/***************************************************************************/ +/* Met a jour le membre .state d'une chaine de structures +*/ +{ + if(Start == NULL ) return; + for( ; (Start != NULL) && (NbItem > 0); NbItem-- , Start = Start->Pnext ) + { + Start->SetState(State,onoff); + } +} diff --git a/pcbnew/trpiste.cpp b/pcbnew/trpiste.cpp new file mode 100644 index 0000000000..dd071a3812 --- /dev/null +++ b/pcbnew/trpiste.cpp @@ -0,0 +1,160 @@ +/*****************************************************************/ +/* Routines de tracage des pistes ( Toutes, 1 piste, 1 segment ) */ +/*****************************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "trigo.h" + +#include "protos.h" + +/* variables locales : */ + +/*********************************************************************************/ +void Trace_Pistes(WinEDA_DrawPanel * panel, BOARD * Pcb, wxDC * DC, int drawmode) +/********************************************************************************/ +/* Draw all tracks and zones. +*/ +{ +TRACK * track; + + track = Pcb->m_Track; + for ( ; track != NULL ; track = track->Next() ) + { + track->Draw(panel, DC, drawmode); + } + + track = Pcb->m_Zone; + for ( ; track != NULL ; track = track->Next() ) + { + track->Draw(panel, DC, drawmode); + } +} + + + +/************************************************************************/ +void Trace_Une_Piste(WinEDA_DrawPanel * panel, wxDC * DC, TRACK * Track, + int nbsegment, int draw_mode) +/************************************************************************/ +/* routine de trace de n segments consecutifs en memoire. + Utile pour monter une piste en cours de trace car les segments de cette + piste sont alors contigus en memoire +Parametres : + pt_start_piste = adresse de depart de la liste des segments + nbsegment = nombre de segments a tracer + draw_mode = mode ( GR_XOR, GR_OR..) +ATTENTION: + le point de depart d'une piste suivante DOIT exister: peut etre + donc mis a 0 avant appel a la routine si la piste a tracer est la derniere +*/ +{ + if ( Track == NULL ) return; + for ( ;nbsegment > 0; nbsegment--, Track = (TRACK*)Track->Pnext) + { + if ( Track == NULL ) break; + Track->Draw(panel, DC, draw_mode) ; + } +} + +/*************************************************************/ +void Trace_DrawSegmentPcb(WinEDA_DrawPanel * panel, wxDC * DC, + DRAWSEGMENT * PtDrawSegment, int draw_mode) +/*************************************************************/ +/* Affichage d'un segment type drawing PCB: + draw_mode = mode de trace ( GR_OR, GR_XOR, GrAND) + Les contours sont de differents type: + segment + cercle + arc +*/ +{ +int ux0, uy0, dx, dy; +int l_piste; +int color, mode; +int zoom; +int rayon; + + color = g_DesignSettings.m_LayerColor[PtDrawSegment->m_Layer]; + if(color & ITEM_NOT_SHOW ) return ; + + if ( panel ) zoom = panel->GetZoom(); + else zoom = ActiveScreen->GetZoom(); + + GRSetDrawMode(DC, draw_mode); + l_piste = PtDrawSegment->m_Width >> 1; /* l_piste = demi largeur piste */ + + /* coord de depart */ + ux0 = PtDrawSegment->m_Start.x; + uy0 = PtDrawSegment->m_Start.y; + /* coord d'arrivee */ + dx = PtDrawSegment->m_End.x; + dy = PtDrawSegment->m_End.y; + + + mode = DisplayOpt.DisplayDrawItems; + if(PtDrawSegment->m_Flags & FORCE_SKETCH) mode = SKETCH; + if ( l_piste < (L_MIN_DESSIN * zoom) ) mode = FILAIRE; + + switch (PtDrawSegment->m_Shape) + { + case S_CIRCLE: + rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) ); + if ( mode == FILAIRE) + { + GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon, color) ; + } + else if( mode == SKETCH) + { + GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon-l_piste, color); + GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon+l_piste, color); + } + else + { + GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon, PtDrawSegment->m_Width,color); + } + break; + + case S_ARC: + { + int StAngle, EndAngle; + rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) ); + StAngle = (int) ArcTangente(dy-uy0, dx-ux0); + EndAngle = StAngle + PtDrawSegment->m_Angle; + if ( StAngle > EndAngle) EXCHG (StAngle, EndAngle); + if ( mode == FILAIRE) + GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon, color); + else if( mode == SKETCH) + { + GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, + rayon - l_piste, color); + GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, + rayon + l_piste, color); + } + else + { + GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, + rayon, PtDrawSegment->m_Width,color); + } + } + break; + + default: + if( mode == FILAIRE) GRLine(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, color) ; + else if( mode == SKETCH) + { + GRCSegm(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, + PtDrawSegment->m_Width, color) ; + } + else + { + GRFillCSegm(&panel->m_ClipBox, DC, ux0, uy0, dx, dy, + PtDrawSegment->m_Width, color) ; + } + break; + } +} + diff --git a/pcbnew/undelete.cpp b/pcbnew/undelete.cpp new file mode 100644 index 0000000000..ce7c181172 --- /dev/null +++ b/pcbnew/undelete.cpp @@ -0,0 +1,144 @@ + /********************************************************/ + /* Effacements : Routines de sauvegarde et d'effacement */ + /********************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "protos.h" + +/* Routines externes : */ + +/* Routines Locales */ + +/********************************************/ +void WinEDA_PcbFrame::UnDeleteItem(wxDC * DC) +/********************************************/ +/* Restitution d'un element (MODULE ou TRACK ) Efface +*/ +{ +EDA_BaseStruct * PtStruct, *PtNext; +TRACK * pt_track; +int net_code; + + if( ! g_UnDeleteStackPtr ) return; + + g_UnDeleteStackPtr --; + PtStruct = g_UnDeleteStack[g_UnDeleteStackPtr]; + if ( PtStruct == NULL ) return; // Ne devrait pas se produire + + switch(PtStruct->m_StructType) + { + case TYPEVIA: + case TYPETRACK: + for( ; PtStruct != NULL; PtStruct = PtNext) + { + PtNext = PtStruct->Pnext; + PtStruct->SetState(DELETED,OFF); /* Effacement du bit DELETED */ + ((TRACK*)PtStruct)->Draw(DrawPanel, DC, GR_OR); + } + + PtStruct = g_UnDeleteStack[g_UnDeleteStackPtr]; + net_code = ((TRACK*)PtStruct)->m_NetCode; + pt_track = ( (TRACK*) PtStruct)->GetBestInsertPoint( m_Pcb ); + ((TRACK*)PtStruct)->Insert(m_Pcb, pt_track); + g_UnDeleteStack[g_UnDeleteStackPtr] = NULL; + + test_1_net_connexion(DC, net_code ); + Affiche_Infos_Status_Pcb(this); + break; + + case TYPEMODULE: + /* Erase general rastnest if needed */ + if(g_Show_Ratsnest) DrawGeneralRatsnest(DC); + /* Reinsertion du module dans la liste chainee des modules, + en debut de chaine */ + PtStruct->Pback = m_Pcb; + PtNext = m_Pcb->m_Modules; + PtStruct->Pnext = PtNext; + if( PtNext) PtNext->Pback = PtStruct; + m_Pcb->m_Modules = (MODULE*)PtStruct; + g_UnDeleteStack[g_UnDeleteStackPtr] = NULL; + + ((MODULE *) PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); + + PtStruct->SetState(DELETED,OFF); /* Creal DELETED flag */ + PtStruct->m_Flags = 0; + m_Pcb->m_Status_Pcb = 0 ; + build_liste_pads(); + ReCompile_Ratsnest_After_Changes( DC ); + break; + + default: + DisplayError(this, wxT("WinEDA_PcbFrame::UnDeleteItem(): unexpected Struct type")); + break; + } +} + + + /**************************************************************/ + /* void * SaveItemEfface(int type, void * PtItem, int nbitems) */ + /**************************************************************/ + +/* Sauvegarde d'un element aux fins de restitution par Undelete + Supporte actuellement : Module et segments de piste +*/ +EDA_BaseStruct * WinEDA_PcbFrame::SaveItemEfface(EDA_BaseStruct * PtItem, int nbitems) +{ +EDA_BaseStruct * NextS, * PtStruct = PtItem; +int ii; + + if( (PtItem == NULL) || (nbitems == 0) ) return NULL; + + if (g_UnDeleteStackPtr >= UNDELETE_STACK_SIZE ) + { + /* Delete last deleted item, and shift stack. */ + DeleteStructList(g_UnDeleteStack[0]); + for (ii = 0; ii < (g_UnDeleteStackPtr-1); ii++) + { + g_UnDeleteStack[ii] = g_UnDeleteStack[ii + 1]; + } + g_UnDeleteStackPtr--;; + } + + switch ( PtStruct->m_StructType ) + { + case TYPEVIA: + case TYPETRACK: + { + EDA_BaseStruct * Back = NULL; + g_UnDeleteStack[g_UnDeleteStackPtr++] = PtStruct; + + for ( ; nbitems > 0; nbitems--, PtStruct = NextS) + { + NextS = PtStruct->Pnext; + ((TRACK*)PtStruct)->UnLink(); + PtStruct->SetState(DELETED, ON); + if( nbitems <= 1 ) NextS = NULL; /* fin de chaine */ + PtStruct->Pnext = NextS; + PtStruct->Pback = Back; Back = PtStruct; + if(NextS == NULL) break; + } + } + break; + + case TYPEMODULE: + { + MODULE * Module = (MODULE*)PtItem; + Module->UnLink(); + Module->SetState(DELETED, ON); + g_UnDeleteStack[g_UnDeleteStackPtr++] = Module; + build_liste_pads(); + } + break; + + default: break; + } + + return(g_UnDeleteStack[g_UnDeleteStackPtr-1]); +} + + diff --git a/pcbnew/via_edit.cpp b/pcbnew/via_edit.cpp new file mode 100644 index 0000000000..9be4f6402e --- /dev/null +++ b/pcbnew/via_edit.cpp @@ -0,0 +1,104 @@ + /**********************************************/ + /* vi_edit.cpp: som editing function for vias */ + /**********************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "id.h" + + +/**********************************************************************************/ +void WinEDA_PcbFrame::Via_Edit_Control(wxDC * DC, int command_type, SEGVIA * via) +/**********************************************************************************/ +/* + Execute edit commands relative to vias +*/ +{ +int ii; +TRACK * via_struct ; + + switch ( command_type ) + { + case ID_POPUP_PCB_SELECT_VIASIZE1: + case ID_POPUP_PCB_SELECT_VIASIZE2: + case ID_POPUP_PCB_SELECT_VIASIZE3: + case ID_POPUP_PCB_SELECT_VIASIZE4: + case ID_POPUP_PCB_SELECT_VIASIZE5: + case ID_POPUP_PCB_SELECT_VIASIZE6: + case ID_POPUP_PCB_SELECT_VIASIZE7: + case ID_POPUP_PCB_SELECT_VIASIZE8: // selec the new current value for via size (via diameter) + DrawPanel->MouseToCursorSchema(); + ii = command_type - ID_POPUP_PCB_SELECT_VIASIZE1; + g_DesignSettings.m_CurrentViaSize = g_DesignSettings.m_ViaSizeHistory[ii]; + DisplayTrackSettings(); + break; + + case ID_POPUP_PCB_VIA_HOLE_ENTER_VALUE: // Enter a new alternate value for drill via + InstallPcbOptionsFrame(wxDefaultPosition, DC, ID_PCB_TRACK_SIZE_SETUP); + DrawPanel->MouseToCursorSchema(); + case ID_POPUP_PCB_VIA_HOLE_TO_VALUE: // Set the drill via to custom + if ( (g_ViaHoleLastValue > 0) && (g_ViaHoleLastValue < via->m_Width) ) + { + via->Draw(DrawPanel, DC, GR_XOR); + via->m_Drill = g_ViaHoleLastValue; + via->Draw(DrawPanel, DC, GR_OR); + GetScreen()->SetModify(); + } + else DisplayError(this, _("Incorrect value for Via drill. No via drill change")); + break; + + + case ID_POPUP_PCB_VIA_HOLE_EXPORT: // Export the current drill value as the new custom value + if ( via->m_Drill > 0 ) g_ViaHoleLastValue = via->m_Drill; + break; + + case ID_POPUP_PCB_VIA_HOLE_EXPORT_TO_OTHERS:// Export the current drill value to via which héave the same size + if ( via->m_Drill > 0 ) g_ViaHoleLastValue = via->m_Drill; + via_struct = m_Pcb->m_Track ; + for ( ; via_struct != NULL; via_struct = (TRACK*) via_struct->Pnext ) + { + if( via_struct->m_StructType == TYPEVIA ) /* mise a jour du diametre de la via */ + { + if ( via_struct->m_Width != via->m_Width ) continue; + via_struct->Draw(DrawPanel, DC, GR_XOR); + via_struct->m_Drill = via->m_Drill; + via_struct->Draw(DrawPanel, DC, GR_OR); + } + } + GetScreen()->SetModify(); + break; + + case ID_POPUP_PCB_VIA_HOLE_TO_DEFAULT: + via->Draw(DrawPanel, DC, GR_XOR); + via->m_Drill = -1; + via->Draw(DrawPanel, DC, GR_OR); + GetScreen()->SetModify(); + break; + + case ID_POPUP_PCB_VIA_HOLE_RESET_TO_DEFAULT: // Reset all via hole to default value + via_struct = m_Pcb->m_Track ; + for ( ; via_struct != NULL; via_struct = (TRACK*) via_struct->Pnext ) + { + if( via_struct->m_StructType == TYPEVIA ) /* mise a jour du diametre de la via */ + { + if( via_struct->m_Drill != -1 ) + { + via_struct->Draw(DrawPanel, DC, GR_XOR); + via_struct->m_Drill = -1; + via_struct->Draw(DrawPanel, DC, GR_OR); + } + } + } + GetScreen()->SetModify(); + break; + + default: + DisplayError( this, wxT("WinEDA_PcbFrame::Via_Edition() error: unknown command")); + break; + } + DrawPanel->MouseToCursorSchema(); +} diff --git a/pcbnew/work.cpp b/pcbnew/work.cpp new file mode 100644 index 0000000000..9bf4adbc77 --- /dev/null +++ b/pcbnew/work.cpp @@ -0,0 +1,207 @@ + /********************************************/ + /* AUTOROUTAGE PCB : routines d'autoroutage */ + /********************************************/ + + /* fichier WORK.CC */ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" +#include "cell.h" + +#include "protos.h" +/**/ + +struct CWORK /* a unit of work is a hole-pair to connect */ + { + struct CWORK *Next; + int FromRow; /* source row */ + int FromCol; /* source column */ + int net_code; /* net_code */ + int ToRow; /* target row */ + int ToCol; /* target column */ + CHEVELU *pt_rats; /* chevelu correspondant*/ + int ApxDist; /* approximate distance */ + int Cost; /* cost for sort by length */ + int Priority; /* routage priority */ + }; + +/* pointers to the first and last item of work to do */ +static CWORK *Head = NULL; +static CWORK *Tail = NULL; +static CWORK *Current = NULL; + +/* Routines definies ici : */ + +void InitWork(void); +void ReInitWork(void); +int SetWork( int, int, int, int, int, CHEVELU *, int ); +void GetWork( int *, int *, int *, int *, int *, CHEVELU ** ); +void SortWork( void ); + + + /************************/ + /* void InitWork (void) */ + /************************/ + + /* initialize the work list */ +void InitWork(void) +{ +CWORK *ptr; + + while( (ptr = Head) != NULL ) + { + Head = ptr->Next; MyFree( ptr ); + } + Tail = Current = NULL; +} + + + /*************************/ + /* void ReInitWork(void) */ + /*************************/ + + /* initialize the work list */ +void ReInitWork(void) + { + Current = Head; + } + +/*****************************************************************************/ +/*int SetWork(int r1,int c1,int* n_c,int r2,int c2,CHEVELU * pt_ch,int pri )*/ +/*****************************************************************************/ + +/* add a unit of work to the work list + Return: + 1 si OK + 0 si defaut d'allocation memoire +*/ +static int GetCost(int r1,int c1,int r2,int c2); + +int SetWork(int r1,int c1,int n_c,int r2,int c2,CHEVELU * pt_ch,int pri ) +{ +CWORK *p; + + if( (p = (CWORK *)MyMalloc( sizeof(CWORK) )) != NULL ) + { + p->FromRow = r1; + p->FromCol = c1; + p->net_code = n_c; + p->ToRow = r2; + p->ToCol = c2; + p->pt_rats = pt_ch; + p->ApxDist = GetApxDist( r1, c1, r2, c2 ); + p->Cost = GetCost( r1, c1, r2, c2 ); + p->Priority = pri; + p->Next = NULL; + if (Head) /* attach at end */ + Tail->Next = p; + else /* first in list */ + Head = Current = p; + Tail = p; + return(1); + } + else /* can't get any more memory */ + return(0); +} + + + /************************************************************************/ + /* void GetWork (int *r1,int *c1,int *r2,int *c2, char **n1,char **n2 ) */ + /************************************************************************/ + +void GetWork (int *r1,int *c1,int *n_c,int *r2,int *c2,CHEVELU** pt_ch ) + /* fetch a unit of work from the work list */ +{ + if (Current) + { + *r1 = Current->FromRow; + *c1 = Current->FromCol; + *n_c = Current->net_code; + *r2 = Current->ToRow; + *c2 = Current->ToCol; + *pt_ch = Current->pt_rats; + Current = Current->Next; + } + + else { /* none left */ + *r1 = *c1 = *r2 = *c2 = ILLEGAL; + *n_c = 0; + *pt_ch = NULL; + } +} + + + /***********************/ + /* void SortWork(void) */ + /***********************/ + +/* order the work items; shortest (low cost) first */ +void SortWork(void) +{ +CWORK *p; +CWORK *q0; /* put PRIORITY CONNECTs in q0 */ +CWORK *q1; /* sort other CONNECTs in q1 */ +CWORK *r; + + q0 = q1 = NULL; + while( (p = Head) != NULL ) + { /* prioritize each work item */ + Head = Head->Next; + if (p->Priority) + { /* put at end of priority list */ + p->Next = NULL; + if ((r = q0) == NULL) /* empty list? */ + q0 = p; + else + { /* attach at end */ + while (r->Next) /* search for end */ + r = r->Next; + r->Next = p; /* attach */ + } + } + else if ( ((r = q1) == NULL) || (p->Cost < q1->Cost) ) + { + p->Next = q1; q1 = p; + } + else { /* find proper position in list */ + while (r->Next && p->Cost >= r->Next->Cost) r = r->Next; + p->Next = r->Next; r->Next = p; + } + } + + if( (p = q0) != NULL) + { /* any priority CONNECTs? */ + while (q0->Next) q0 = q0->Next; + q0->Next = q1; + } + else p = q1; + + /* reposition Head and Tail */ + for(Head = Current = Tail = p; Tail && Tail->Next; Tail = Tail->Next) ; +} + + +/* routine de calcul du cout d'un chevelu: +cout = (|dx| + |dy|) * handicap +handicap = 1 si dx ou dy = 0, max si |dx| # |dy| +*/ +static int GetCost(int r1,int c1,int r2,int c2) +{ +int dx, dy, mx, my; +float incl; + + dx = abs(c2 - c1); + dy = abs(r2 - r1); + incl = 1.0; + mx = dx; my = dy; + if ( mx < my ) { mx = dy; my = dx;} + if ( mx ) incl += (2*(float)my/mx); + + return (int)((dx+dy) * incl) ; +} + + diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp new file mode 100644 index 0000000000..60f394a622 --- /dev/null +++ b/pcbnew/xchgmod.cpp @@ -0,0 +1,628 @@ + /******************************/ + /* PCBNEW: echange de modules */ + /******************************/ + + /* Fichier xchmod.cpp */ + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" +#include "pcbnew.h" +#include "autorout.h" + +#include "protos.h" + +/* variables locales */ + +enum id_ExchangeModule +{ + ID_EXEC_EXCHANGE_MODULE = 1900, + ID_EXEC_EXCHANGE_ID_MODULES, + ID_EXEC_EXCHANGE_ID_MODULE_AND_VALUE, + ID_EXEC_EXCHANGE_ALL_MODULES, + ID_CLOSE_EXCHANGE_MODULE, + ID_BROWSE_LIB_MODULES +}; + + /************************************/ + /* class WinEDA_ExchangeModuleFrame */ + /************************************/ + +class WinEDA_ExchangeModuleFrame: public wxDialog +{ +private: + + WinEDA_BasePcbFrame * m_Parent; + wxDC * m_DC; + MODULE * m_CurrentModule; + WinEDA_EnterText * m_OldModule; + WinEDA_EnterText * m_OldValue; + WinEDA_EnterText * m_NewModule; + wxTextCtrl * m_WinMsg; + +public: + // Constructor and destructor + WinEDA_ExchangeModuleFrame(WinEDA_BasePcbFrame *parent, + MODULE * Module, wxDC * DC, const wxPoint & pos); + ~WinEDA_ExchangeModuleFrame(void) + { + } + +private: + void OnQuit(wxCommandEvent& event); + void Change_Module(wxCommandEvent& event); + void Change_ModuleId(wxCommandEvent& event); + void Change_ModuleAll(wxCommandEvent& event); + int Maj_ListeCmp( + const wxString & reference, + const wxString & old_name, + const wxString & new_name, bool ShowError); + MODULE * Change_1_Module(MODULE * Module, const wxString& new_module, bool ShowError); + void Sel_NewMod_By_Liste(wxCommandEvent& event); + + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(WinEDA_ExchangeModuleFrame, wxDialog) + EVT_BUTTON(ID_EXEC_EXCHANGE_MODULE, WinEDA_ExchangeModuleFrame::Change_Module) + EVT_BUTTON(ID_EXEC_EXCHANGE_ID_MODULES, WinEDA_ExchangeModuleFrame::Change_ModuleId) + EVT_BUTTON(ID_EXEC_EXCHANGE_ID_MODULE_AND_VALUE, WinEDA_ExchangeModuleFrame::Change_ModuleId) + EVT_BUTTON(ID_EXEC_EXCHANGE_ALL_MODULES, WinEDA_ExchangeModuleFrame::Change_ModuleAll) + EVT_BUTTON(ID_CLOSE_EXCHANGE_MODULE, WinEDA_ExchangeModuleFrame::OnQuit) + EVT_BUTTON(ID_BROWSE_LIB_MODULES, WinEDA_ExchangeModuleFrame::Sel_NewMod_By_Liste) +END_EVENT_TABLE() + + +WinEDA_ExchangeModuleFrame::WinEDA_ExchangeModuleFrame(WinEDA_BasePcbFrame *parent, + MODULE * Module,wxDC * DC, + const wxPoint & framepos): + wxDialog(parent, -1, _("Exchange Modules"), framepos, wxSize(360, 460), + DIALOG_STYLE) +{ +wxButton * Button; + + m_Parent = parent; + SetFont(*g_DialogFont); + m_DC = DC; + Centre(); + + m_CurrentModule = Module; + + wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxVERTICAL); + SetSizer(MainBoxSizer); + wxBoxSizer * UpperBoxSizer = new wxBoxSizer(wxHORIZONTAL); + MainBoxSizer->Add(UpperBoxSizer, 0, wxGROW|wxALL, 5); + wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); + UpperBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); + UpperBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + /* Creation des boutons de commande */ + Button = new wxButton(this, ID_EXEC_EXCHANGE_MODULE, + _("Change module")); + Button->SetForegroundColour(*wxBLUE); + RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); + + Button = new wxButton(this, ID_EXEC_EXCHANGE_ID_MODULES, + _("Change same modules")); + Button->SetForegroundColour(*wxRED); + RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT, 5); + + Button = new wxButton(this, ID_EXEC_EXCHANGE_ID_MODULE_AND_VALUE, + _("Ch. same module+value")); + Button->SetForegroundColour(*wxRED); + RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT, 5); + + Button = new wxButton(this, ID_EXEC_EXCHANGE_ALL_MODULES, + _("Change all")); + Button->SetForegroundColour(*wxRED); + RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT, 5); + + Button = new wxButton(this, ID_BROWSE_LIB_MODULES, + _("Browse Libs modules")); + Button->SetForegroundColour(wxColour(0,100,0) ); + RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT, 5); + + Button = new wxButton(this, ID_CLOSE_EXCHANGE_MODULE, + _("Close")); + Button->SetForegroundColour(*wxBLUE); + RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_OldModule = new WinEDA_EnterText(this, _("Current Module"), + m_CurrentModule ? m_CurrentModule->m_LibRef.GetData() :wxEmptyString, + LeftBoxSizer, wxSize( 150,-1) ); + m_OldModule->Enable(FALSE); + + m_OldValue = new WinEDA_EnterText(this, _("Current Value"), + m_CurrentModule ? m_CurrentModule->m_Value->m_Text.GetData() :wxEmptyString, + LeftBoxSizer, wxSize( 150,-1) ); + m_OldValue->Enable(FALSE); + + m_NewModule = new WinEDA_EnterText(this, _("New Module"), + m_OldModule->GetValue(), LeftBoxSizer, wxSize( 150,-1) ); + + m_WinMsg = new wxTextCtrl(this, -1,wxEmptyString, wxDefaultPosition, wxSize(340, 230), + wxTE_READONLY|wxTE_MULTILINE); + MainBoxSizer->Add(m_WinMsg, 0, wxGROW|wxALL, 5); + + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); +} + + +/*********************************************************************/ +void WinEDA_BasePcbFrame::InstallExchangeModuleFrame( MODULE * Module, + wxDC * DC, const wxPoint & pos) +/*********************************************************************/ +{ + WinEDA_ExchangeModuleFrame * frame = new WinEDA_ExchangeModuleFrame(this, + Module, DC, pos); + frame->ShowModal(); frame->Destroy(); +} + + +/**********************************************************************/ +void WinEDA_ExchangeModuleFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +/**********************************************************************/ +{ + Close(true); // true is to force the frame to close +} + + + +/************************************************************************/ +int WinEDA_ExchangeModuleFrame::Maj_ListeCmp( + const wxString & reference, + const wxString & old_name, + const wxString & new_name, bool ShowError) +/************************************************************************/ +/* + Met a jour le fichier name.CMP (s'il existe) apres un echange de module + (par la commande changeMod), si les modules sont geres par ce fichier + + Si ShowError != 0 affiche message d'erreur si le fichier .cmp n'est pas + trouve. + Retoure 1 si erreur +*/ +{ +wxString FileNameCmp, tmpfile; +FILE * FichCmp, *NewFile; +char Line[1024]; +wxString msg; + + if ( old_name == new_name ) return(0); /* pas de changement de nom */ + + /* Calcul nom fichier CMP par changement de l'extension du nom netliste */ + if ( NetNameBuffer == wxEmptyString ) + FileNameCmp = m_Parent->m_CurrentScreen->m_FileName; + else FileNameCmp = NetNameBuffer; + ChangeFileNameExt(FileNameCmp,NetCmpExtBuffer) ; + + // Modification du fichier .cmp correcpondant + FichCmp = wxFopen(FileNameCmp, wxT("rt")); + if( FichCmp == NULL ) + { + if ( ShowError ) + { + msg.Printf( _("file %s not found"), FileNameCmp.GetData()); + m_WinMsg->WriteText(msg); + } + return(1); + } + + /* Analyse du fichier et modif */ + tmpfile = FileNameCmp; + ChangeFileNameExt(tmpfile, wxT(".$$$")); + NewFile = wxFopen(tmpfile, wxT("wt")); + if( NewFile == NULL ) + { + if ( ShowError ) + { + msg.Printf( _("Unable to create file %s"), tmpfile.GetData()); + m_WinMsg->WriteText(msg); + } + return(1); + } + + fgets(Line, sizeof(Line), FichCmp); + fprintf(NewFile,"Cmp-Mod V01 Genere par PcbNew le %s\n", DateAndTime(Line) ); + + bool start_descr = FALSE; + while( fgets(Line, sizeof(Line), FichCmp) != NULL ) + { + if ( strnicmp( Line, "Reference = ", 9 ) == 0 ) + { + char buf[1024]; + strcpy( buf, Line + 12); + strtok(buf,";\n\r"); + if ( stricmp( buf , CONV_TO_UTF8(reference) ) == 0 ) + { + start_descr = TRUE; + } + } + + if ( (strnicmp( Line, "Begin", 5 ) == 0) || + (strnicmp( Line, "End", 3) == 0) ) + { + start_descr = FALSE; + } + + if ( start_descr && strnicmp( Line, "IdModule", 8 ) == 0 ) + { + sprintf(Line + 8," = %s;\n", CONV_TO_UTF8(new_name) ); + + msg.Printf( wxT(" * in %s\n"), FileNameCmp.GetData()); + m_WinMsg->WriteText(msg); + + start_descr = FALSE; + } + fputs(Line, NewFile); + } + + fclose(FichCmp); + fclose(NewFile); + wxRemoveFile(FileNameCmp); + wxRenameFile(tmpfile, FileNameCmp); + return(0); +} + + + +/********************************************************************/ +void WinEDA_ExchangeModuleFrame::Change_Module(wxCommandEvent& event) +/********************************************************************/ + +/* Routine de changement d'un module: + Change le module pointe par la souris, par un autre en conservant + - meme orientation + - meme position + - memes textes valeur et ref + - memes netnames pour pads de meme nom +*/ +{ +wxString newmodulename = m_NewModule->GetValue(); + + if( newmodulename == wxEmptyString ) return; + + if( Change_1_Module(m_CurrentModule, newmodulename,TRUE ) ) + { + m_Parent->m_Pcb->m_Status_Pcb = 0; + m_Parent->build_liste_pads(); + } +} + +/*********************************************************************/ +void WinEDA_ExchangeModuleFrame::Change_ModuleId(wxCommandEvent& event) +/**********************************************************************/ + +/* Routine de changement de tous les modules de meme nom lib que celui + selectionne, en conservant + - meme orientation + - meme position + - memes textes valeur et ref + - memes netnames pour pads de meme nom + et en remplacant l'ancien module par le noveau module + Attention: m_CurrentModule ne pointe plus sur le module de reference + puisque celui ci a ete change!! +*/ +{ +wxString msg; +MODULE * PtModule, *PtBack; +bool change = FALSE; +wxString newmodulename = m_NewModule->GetValue(); +wxString value, lib_reference; // pour memo Reflib et value de reference +bool check_module_value = FALSE; +int ShowErr = 5; // Affiche 5 messages d'err maxi + + if( m_Parent->m_Pcb->m_Modules == NULL ) return; + if( newmodulename == wxEmptyString ) return; + + lib_reference = m_CurrentModule->m_LibRef; + if ( event.GetId() == ID_EXEC_EXCHANGE_ID_MODULE_AND_VALUE ) + { + check_module_value = TRUE; + value = m_CurrentModule->m_Value->m_Text; + msg.Printf( _("Change modules <%s> -> <%s> (val = %s)?"), + m_CurrentModule->m_LibRef.GetData(), + newmodulename.GetData(), + m_CurrentModule->m_Value->m_Text.GetData() ); + } + + else + { + msg.Printf( _("Change modules <%s> -> <%s> ?"), + lib_reference.GetData(), newmodulename.GetData() ); + } + + if( !IsOK(this, msg) ) return; + + /* Le changement s'effectue a partir du dernier module car la routine + Change_1_Module() modifie le dernier module de la liste + */ + + PtModule = m_Parent->m_Pcb->m_Modules; + for ( ; PtModule != NULL; PtModule = (MODULE*)PtModule->Pnext) + { + if(PtModule->Pnext == NULL) break; + } + + /* Ici PtModule pointe le dernier module de la liste */ + for ( ; PtModule != (MODULE*)m_Parent->m_Pcb; PtModule = PtBack) + { + MODULE * module; + PtBack = (MODULE*)PtModule->Pback; + if( lib_reference.CmpNoCase(PtModule->m_LibRef) != 0 ) + continue; + if ( check_module_value ) + { + if( value.CmpNoCase(PtModule->m_Value->m_Text) != 0 ) + continue; + } + module = Change_1_Module(PtModule, newmodulename.GetData(), ShowErr); + if ( module ) change = TRUE; + else if (ShowErr) ShowErr--; + } + if( change ) + { + m_Parent->m_Pcb->m_Status_Pcb = 0; + m_Parent->build_liste_pads(); + } +} + +/***********************************************************************/ +void WinEDA_ExchangeModuleFrame::Change_ModuleAll(wxCommandEvent& event) +/***********************************************************************/ +/* Routine de changement de tous les modules par les modules de meme nom lib: + en conservant + - meme orientation + - meme position + - memes textes valeur et ref + - memes netnames pour pads de meme nom +*/ +{ +MODULE * PtModule, *PtBack; +bool change = FALSE; +int ShowErr = 5; // Affiche 5 messages d'err maxi + + if(m_Parent->m_Pcb->m_Modules == NULL) return; + + if( !IsOK(this, _("Change ALL modules ?")) ) return; + + /* Le changement s'effectue a partir du dernier module car la routine + Change_1_Module() modifie le dernier module de la liste + */ + + PtModule = (MODULE*) m_Parent->m_Pcb->m_Modules; + for ( ; PtModule != NULL; PtModule = (MODULE*)PtModule->Pnext) + { + if(PtModule->Pnext == NULL) break; + } + + /* Ici PtModule pointe le dernier module de la liste */ + for ( ; PtModule != (MODULE*)(m_Parent->m_Pcb); PtModule = PtBack) + { + PtBack = (MODULE*)PtModule->Pback; + if ( Change_1_Module(PtModule, PtModule->m_LibRef.GetData(), ShowErr) ) + change = TRUE; + else if (ShowErr) ShowErr--; + } + + if( change) + { + m_Parent->m_Pcb->m_Status_Pcb = 0; + m_Parent->build_liste_pads(); + } +} + +/******************************************************************/ +MODULE * WinEDA_ExchangeModuleFrame::Change_1_Module(MODULE * PtModule, + const wxString& new_module, bool ShowError) +/*******************************************************************/ +/* Routine de changement d'un module: + Change le module de numero empr, avec le module de nom new_module + - meme orientation + - meme position + - memes textes valeur et ref + - memes netnames pour pads de meme nom + Retourne : + 0 si pas de changement ( si le nouveau module n'est pas en libr) + 1 si OK +*/ +{ +wxString namecmp, oldnamecmp; +MODULE * NewModule; +wxString Line; + + if(PtModule == NULL) return(NULL); + +wxBusyCursor dummy; + + /* Memorisation des parametres utiles de l'ancien module */ + oldnamecmp = PtModule->m_LibRef; + namecmp = new_module; + + /* Chargement du module */ + Line.Printf( _("Change module %s (%s) "), + PtModule->m_Reference->m_Text.GetData(), oldnamecmp.GetData()); + m_WinMsg->WriteText(Line); + + namecmp.Trim(TRUE); + namecmp.Trim(FALSE); + NewModule = m_Parent->Get_Librairie_Module(this, wxEmptyString, namecmp, ShowError); + if( NewModule == NULL) /* Nouveau module NON trouve, reaffichage de l'ancien */ + { + m_WinMsg->WriteText( wxT("No\n")); + return(NULL); + } + + if ( PtModule == m_CurrentModule ) m_CurrentModule = NewModule; + m_WinMsg->WriteText( wxT("Ok\n")); + + /* Effacement a l'ecran de l'ancien module */ + PtModule->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0), GR_XOR); + + m_Parent->Exchange_Module(this, PtModule, NewModule); + + /* Affichage du nouveau module */ + NewModule->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0,0),GR_OR); + + Maj_ListeCmp(NewModule->m_Reference->m_Text, oldnamecmp, namecmp, ShowError); + + return(NewModule); +} + +/***********************************************************************************/ +MODULE * WinEDA_BasePcbFrame::Exchange_Module(wxWindow * winaff, + MODULE * OldModule, MODULE * NewModule) +/***********************************************************************************/ +/* +Remplace le module OldModule par le module NewModule (en conservant position, orientation..) +OldModule est supprimé de la memoire. +*/ +{ +wxPoint oldpos; /* memorisation temporaire pos curseur */ +D_PAD * pt_pad, * pt_old_pad; + + + if ( (OldModule->m_StructType != TYPEMODULE) || (NewModule->m_StructType != TYPEMODULE) ) + { + DisplayError(winaff, wxT("WinEDA_BasePcbFrame::Exchange_Module() StuctType error" )); + } + + NewModule->m_Parent = m_Pcb; + + m_Pcb->m_Status_Pcb = 0 ; + oldpos = m_CurrentScreen->m_Curseur; + m_CurrentScreen->m_Curseur = OldModule->m_Pos; + Place_Module(NewModule, NULL); + m_CurrentScreen->m_Curseur = oldpos; + + /* Changement eventuel de couche */ + if( OldModule->m_Layer != NewModule->m_Layer) + { + Change_Side_Module(NewModule, NULL); + } + + /* Rotation eventuelle du module */ + if( OldModule->m_Orient != NewModule->m_Orient ) + { + Rotate_Module(NULL, NewModule,OldModule->m_Orient, FALSE ); + } + + /* Mise a jour des textes ref et val */ + NewModule->m_Reference->m_Text = OldModule->m_Reference->m_Text; + NewModule->m_Value->m_Text = OldModule->m_Value->m_Text; + + /* Mise a jour des autres parametres */ + NewModule->m_TimeStamp = OldModule->m_TimeStamp; + + /* mise a jour des netnames ( lorsque c'est possible) */ + pt_pad = NewModule->m_Pads; + for( ; pt_pad != NULL; pt_pad = (D_PAD*)pt_pad->Pnext) + { + pt_pad->m_Netname = wxEmptyString; + pt_pad->m_NetCode = 0; + pt_old_pad = OldModule->m_Pads; + for( ; pt_old_pad != NULL; pt_old_pad = (D_PAD*)pt_old_pad->Pnext ) + { + if(strnicmp( pt_pad->m_Padname, pt_old_pad->m_Padname,sizeof(pt_pad->m_Padname)) == 0) + { + pt_pad->m_Netname = pt_old_pad->m_Netname; + pt_pad->m_NetCode = pt_old_pad->m_NetCode; + } + } + } + + /* Effacement de l'ancien module */ + DeleteStructure(OldModule); + + m_Pcb->m_Status_Pcb = 0; + NewModule->m_Flags = 0; + m_CurrentScreen->SetModify(); + + return NewModule; +} + + + /*****************************************/ + /* static void Sel_NewMod_By_Liste(void) */ + /*****************************************/ + +/*affiche la liste des modules en librairie et selectione 1 nom */ + +void WinEDA_ExchangeModuleFrame::Sel_NewMod_By_Liste(wxCommandEvent& event) +{ +wxString newname; + + newname = m_Parent->Select_1_Module_From_List(this, wxEmptyString, wxEmptyString, wxEmptyString); + if ( newname != wxEmptyString ) + m_NewModule->SetValue(newname); +} + + +/***************************************************/ +bool WinEDA_PcbFrame::RecreateCmpFileFromBoard(void) +/***************************************************/ +{ +wxString FullFileNameCmp, mask; +FILE * FichCmp; +char Line[1024]; +MODULE * Module = m_Pcb->m_Modules; +wxString msg; + + if ( Module == NULL) + { + DisplayError(this, _("No Modules!") ); + return FALSE; + } + + /* Calcul nom fichier CMP par changement de l'extension du nom netliste */ + if ( NetNameBuffer == wxEmptyString ) + FullFileNameCmp = m_CurrentScreen->m_FileName; + else FullFileNameCmp = NetNameBuffer; + ChangeFileNameExt(FullFileNameCmp,NetCmpExtBuffer) ; + + mask = wxT("*") + NetCmpExtBuffer; + FullFileNameCmp = EDA_FileSelector( _("Cmp files:"), + wxEmptyString, /* Chemin par defaut */ + FullFileNameCmp, /* nom fichier par defaut */ + NetCmpExtBuffer, /* extension par defaut */ + mask, /* Masque d'affichage */ + this, + wxFD_SAVE, + FALSE + ); + if ( FullFileNameCmp.IsEmpty() ) return FALSE; + + + FichCmp = wxFopen(FullFileNameCmp, wxT("wt")); + if( FichCmp == NULL ) + { + msg = _("Unable to create file ") + FullFileNameCmp; + DisplayError(this, msg); + return FALSE; + } + + fgets(Line, sizeof(Line), FichCmp); + fprintf(FichCmp,"Cmp-Mod V01 Genere par PcbNew le %s\n", DateAndTime(Line) ); + + for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) + { + fprintf(FichCmp,"\nBeginCmp\n" ); + fprintf(FichCmp,"TimeStamp = %8.8lX\n", Module->m_TimeStamp); + fprintf(FichCmp,"Reference = %s;\n", + ! Module->m_Reference->m_Text.IsEmpty() ? + CONV_TO_UTF8(Module->m_Reference->m_Text) : "[NoRef]" ); + fprintf(FichCmp,"ValeurCmp = %s;\n", + !Module->m_Value->m_Text.IsEmpty() ? + CONV_TO_UTF8(Module->m_Value->m_Text) : "[NoVal]" ); + fprintf(FichCmp,"IdModule = %s;\n", CONV_TO_UTF8(Module->m_LibRef)); + fprintf(FichCmp,"EndCmp\n" ); + } + + fprintf(FichCmp,"\nEndListe\n"); + fclose(FichCmp); + + return TRUE; +} diff --git a/pcbnew/zones.cpp b/pcbnew/zones.cpp new file mode 100644 index 0000000000..329c54d9a3 --- /dev/null +++ b/pcbnew/zones.cpp @@ -0,0 +1,1264 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: zones.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 25/01/2006 11:35:19 +// RCS-ID: +// Copyright: GNU License +// Licence: GNU License +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 25/01/2006 11:35:19 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "zones.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes + +#include "zones.h" + +////@begin XPM images +////@end XPM images + +/* Routines Locales */ +static void Display_Zone_Netname(WinEDA_PcbFrame *frame); +static void Exit_Zones(WinEDA_DrawPanel * Panel, wxDC *DC); +static void Show_Zone_Edge_While_MoveMouse(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); +static void Genere_Segments_Zone(WinEDA_PcbFrame *frame, wxDC * DC, int net_code); +static bool Genere_Pad_Connexion(WinEDA_PcbFrame *frame, wxDC * DC, int layer); + +/* Variables locales */ +static bool Zone_Debug = FALSE; +static bool Zone_45_Only = FALSE; +static bool Zone_Exclude_Pads = TRUE; +static bool Zone_Genere_Freins_Thermiques = TRUE; + +static int TimeStamp; /* signature temporelle pour la zone generee */ + +/*! + * WinEDA_ZoneFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_ZoneFrame, wxDialog ) + +/*! + * WinEDA_ZoneFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_ZoneFrame, wxDialog ) + +////@begin WinEDA_ZoneFrame event table entries + EVT_BUTTON( ID_FILL_ZONE, WinEDA_ZoneFrame::ExecFillZone ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_ZoneFrame::OnCancelClick ) + + EVT_BUTTON( ID_SET_OPTIONS_ZONE, WinEDA_ZoneFrame::ExecFillZone ) + +////@end WinEDA_ZoneFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_ZoneFrame constructors + */ + +WinEDA_ZoneFrame::WinEDA_ZoneFrame( ) +{ +} + +WinEDA_ZoneFrame::WinEDA_ZoneFrame( WinEDA_PcbFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + Create(parent, id, caption, pos, size, style); +} + +/*! + * WinEDA_ZoneFrame creator + */ + +bool WinEDA_ZoneFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_ZoneFrame member initialisation + m_GridCtrl = NULL; + m_ClearanceValueTitle = NULL; + m_ZoneClearanceCtrl = NULL; + m_FillOpt = NULL; + m_OrientEdgesOpt = NULL; +////@end WinEDA_ZoneFrame member initialisation + +////@begin WinEDA_ZoneFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + Centre(); +////@end WinEDA_ZoneFrame creation + + return true; +} + +/*! + * Control creation for WinEDA_ZoneFrame + */ + +void WinEDA_ZoneFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_ZoneFrame content construction + // Generated by DialogBlocks, 03/03/2006 13:36:21 (unregistered) + + WinEDA_ZoneFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5); + + wxString m_GridCtrlStrings[] = { + _("0.00000"), + _("0.00000"), + _("0.00000"), + _("0.00000") + }; + m_GridCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Grid size:"), wxDefaultPosition, wxDefaultSize, 4, m_GridCtrlStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer3->Add(m_GridCtrl, 0, wxALIGN_LEFT|wxALL, 5); + + m_ClearanceValueTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Zone clearance value (mm):"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(m_ClearanceValueTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_ZoneClearanceCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(m_ZoneClearanceCtrl, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + itemBoxSizer2->Add(5, 5, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer8, 0, wxGROW|wxALL, 5); + + wxString m_FillOptStrings[] = { + _("Include Pads"), + _("Thermal"), + _("Exclude Pads") + }; + m_FillOpt = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Pad options:"), wxDefaultPosition, wxDefaultSize, 3, m_FillOptStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer8->Add(m_FillOpt, 0, wxALIGN_LEFT|wxALL, 5); + + wxString m_OrientEdgesOptStrings[] = { + _("Any"), + _("H , V and 45 deg") + }; + m_OrientEdgesOpt = new wxRadioBox( itemDialog1, ID_RADIOBOX2, _("Zone edges orient:"), wxDefaultPosition, wxDefaultSize, 2, m_OrientEdgesOptStrings, 1, wxRA_SPECIFY_COLS ); + itemBoxSizer8->Add(m_OrientEdgesOpt, 0, wxALIGN_RIGHT|wxALL, 5); + + itemBoxSizer2->Add(5, 5, 0, wxGROW|wxALL, 5); + + wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer12, 0, wxALIGN_TOP|wxALL, 5); + + wxButton* itemButton13 = new wxButton( itemDialog1, ID_FILL_ZONE, _("Fill"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton13->SetDefault(); + itemButton13->SetForegroundColour(wxColour(204, 0, 0)); + itemBoxSizer12->Add(itemButton13, 0, wxGROW|wxALL, 5); + + wxButton* itemButton14 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton14->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer12->Add(itemButton14, 0, wxGROW|wxALL, 5); + + wxButton* itemButton15 = new wxButton( itemDialog1, ID_SET_OPTIONS_ZONE, _("Update Options"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton15->SetForegroundColour(wxColour(0, 100, 0)); + itemBoxSizer12->Add(itemButton15, 0, wxGROW|wxALL, 5); + + itemBoxSizer2->Add(5, 5, 0, wxGROW|wxALL, 5); + +////@end WinEDA_ZoneFrame content construction +wxString title = _("Zone clearance value:") + ReturnUnitSymbol(g_UnitMetric); + m_ClearanceValueTitle->SetLabel( title ); + + title = _("Grid :") + ReturnUnitSymbol(g_UnitMetric);; + m_GridCtrl->SetLabel(title); + + if ( g_DesignSettings.m_ZoneClearence == 0 ) + g_DesignSettings.m_ZoneClearence = g_DesignSettings.m_TrackClearence; + title = ReturnStringFromValue( g_UnitMetric, g_DesignSettings.m_ZoneClearence, m_Parent->m_InternalUnits); + m_ZoneClearanceCtrl->SetValue( title ); + + if ( Zone_45_Only ) m_OrientEdgesOpt->SetSelection(1); + +int GridList[4] = { 50,100,250,500}, selection = 0; + for ( unsigned int ii = 0; ii < m_GridCtrl->GetCount(); ii++ ) + { + wxString msg = ReturnStringFromValue(g_UnitMetric, GridList[ii], m_Parent->m_InternalUnits); + m_GridCtrl->SetString(ii,msg); + if ( g_GridRoutingSize == GridList[ii] ) selection = ii; + } + m_GridCtrl->SetSelection(selection); + + if ( Zone_Exclude_Pads) + { + if ( Zone_Genere_Freins_Thermiques ) m_FillOpt->SetSelection(1); + else m_FillOpt->SetSelection(2); + } + +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_ZoneFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_ZoneFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_ZoneFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_ZoneFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_ZoneFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_ZoneFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_ZoneFrame icon retrieval +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_ZoneFrame::OnCancelClick( wxCommandEvent& event ) +{ +////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_ZoneFrame. + // Before editing this code, remove the block markers. + event.Skip(); +////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_ZoneFrame. +} + + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON2 + */ +/***********************************************************/ +void WinEDA_ZoneFrame::ExecFillZone( wxCommandEvent & event) +/***********************************************************/ +{ + switch ( m_FillOpt->GetSelection() ) + { + case 0: + Zone_Exclude_Pads = FALSE; + Zone_Genere_Freins_Thermiques = FALSE; + break; + + case 1: + Zone_Exclude_Pads = TRUE; + Zone_Genere_Freins_Thermiques = TRUE; + break; + + case 2: + Zone_Exclude_Pads = TRUE; + Zone_Genere_Freins_Thermiques = FALSE; + break; + } + + switch ( m_GridCtrl->GetSelection() ) + { + case 0: + g_GridRoutingSize = 50; + break; + + case 1: + g_GridRoutingSize = 100; + break; + + case 2: + g_GridRoutingSize = 250; + break; + + case 3: + g_GridRoutingSize = 500; + break; + } + + wxString txtvalue = m_ZoneClearanceCtrl->GetValue(); + g_DesignSettings.m_ZoneClearence = + ReturnValueFromString( g_UnitMetric, txtvalue, m_Parent->m_InternalUnits); + if ( m_OrientEdgesOpt->GetSelection() == 0) Zone_45_Only = FALSE; + else Zone_45_Only = TRUE; + + if ( event.GetId() == ID_SET_OPTIONS_ZONE ) EndModal(1); + else EndModal(0); +} + +/**************************************************************/ +void WinEDA_PcbFrame::Edit_Zone_Width(wxDC * DC, SEGZONE * Zone) +/**************************************************************/ +/* Edite (change la largeur des segments) la zone Zone. + La zone est constituee des segments zones de meme TimeStamp +*/ +{ +SEGZONE * pt_segm, * NextS ; +int TimeStamp; +bool modify = FALSE; +double f_new_width; +int w_tmp; +wxString Line; +wxString Msg( _("New zone segment width: ") ); + + if ( Zone == NULL ) return; + + f_new_width = To_User_Unit(g_UnitMetric, Zone->m_Width, GetScreen()->GetInternalUnits()); + Line.Printf(wxT("%.4f"), f_new_width); + Msg += g_UnitMetric ? wxT("(mm)") : wxT("(\")"); + if ( Get_Message(Msg, Line, this) != 0 ) return; + + w_tmp = g_DesignSettings.m_CurrentTrackWidth; + Line.ToDouble( &f_new_width); + g_DesignSettings.m_CurrentTrackWidth = From_User_Unit(g_UnitMetric, f_new_width, GetScreen()->GetInternalUnits()); + + TimeStamp = Zone->m_TimeStamp; + + for( pt_segm = (SEGZONE*)m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS) + { + NextS = (SEGZONE*) pt_segm->Pnext; + if(pt_segm->m_TimeStamp == TimeStamp) + { + modify = TRUE; + Edit_TrackSegm_Width(DC, pt_segm); + } + } + + g_DesignSettings.m_CurrentTrackWidth = w_tmp; + if ( modify ) + { + GetScreen()->SetModify(); + DrawPanel->Refresh(); + } +} + + + +/**********************************************************/ +void WinEDA_PcbFrame::Delete_Zone(wxDC * DC, SEGZONE * Zone) +/**********************************************************/ +/* Efface la zone Zone. + La zone est constituee des segments zones de meme TimeStamp +*/ +{ +SEGZONE * pt_segm, * NextS ; +int TimeStamp; +int nb_segm = 0; +bool modify = FALSE; + + TimeStamp = Zone->m_TimeStamp; + + for( pt_segm = (SEGZONE*)m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS) + { + NextS = (SEGZONE*) pt_segm->Pnext; + if(pt_segm->m_TimeStamp == TimeStamp) + { + modify = TRUE; + /* effacement des segments a l'ecran */ + Trace_Une_Piste(DrawPanel, DC, pt_segm, nb_segm, GR_XOR); + DeleteStructure(pt_segm); + } + } + + if ( modify ) + { + GetScreen()->SetModify(); + GetScreen()->SetRefreshReq(); + } +} + + +/*****************************************************************************/ +EDGE_ZONE * WinEDA_PcbFrame::Del_SegmEdgeZone(wxDC * DC, EDGE_ZONE * edge_zone) +/*****************************************************************************/ +/* Routine d'effacement du segment de limite zone en cours de trace */ +{ +EDGE_ZONE * Segm, * previous_segm; + + if (m_Pcb->m_CurrentLimitZone) Segm = m_Pcb->m_CurrentLimitZone; + else Segm = edge_zone; + + if( Segm == NULL) return NULL; + + Trace_DrawSegmentPcb(DrawPanel, DC, Segm, GR_XOR); + + previous_segm = (EDGE_ZONE *)Segm->Pback; + delete Segm; + + Segm = previous_segm; + m_Pcb->m_CurrentLimitZone = Segm; + GetScreen()->m_CurrentItem = Segm; + + if( Segm ) + { + Segm->Pnext = NULL; + if( DrawPanel->ManageCurseur) + DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); + } + else + { + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; + GetScreen()->m_CurrentItem = NULL; + } + return Segm; +} + + +/*********************************************/ +void WinEDA_PcbFrame::CaptureNetName(wxDC * DC) +/*********************************************/ +/* routine permettant de capturer le nom net net (netcode) d'un pad + ou d'une piste pour l'utiliser comme netcode de zone +*/ +{ +D_PAD* pt_pad = 0; +TRACK * adrpiste ; +MODULE * Module; +int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; +int netcode; + + netcode = -1; + MsgPanel->EraseMsgBox(); + adrpiste = Locate_Pistes(m_Pcb->m_Track, masquelayer,CURSEUR_OFF_GRILLE); + if ( adrpiste == NULL ) + { + pt_pad = Locate_Any_Pad(m_Pcb, CURSEUR_OFF_GRILLE); + + if(pt_pad) /* Verif qu'il est bien sur la couche active */ + { + Module = (MODULE*) pt_pad->m_Parent; + pt_pad = Locate_Pads(Module,g_TabOneLayerMask[GetScreen()->m_Active_Layer], + CURSEUR_OFF_GRILLE); + } + if( pt_pad ) + { + pt_pad->Display_Infos(this); + netcode = pt_pad->m_NetCode; + } + } + else + { + Affiche_Infos_Piste(this, adrpiste) ; + netcode = adrpiste->m_NetCode; + } + + // Mise en surbrillance du net + if(g_HightLigt_Status) Hight_Light(DC); + g_HightLigth_NetCode = netcode; + + if ( g_HightLigth_NetCode >= 0 ) + { + Hight_Light(DC); + } + + /* Affichage du net selectionne pour la zone a tracer */ + Display_Zone_Netname(this); +} + +/*******************************************************/ +static void Display_Zone_Netname(WinEDA_PcbFrame *frame) +/*******************************************************/ +/* + Affiche le net_code et le nom de net couramment selectionne +*/ +{ +EQUIPOT * pt_equipot; +wxString line; + + pt_equipot = frame->m_Pcb->m_Equipots; + + if( g_HightLigth_NetCode > 0 ) + { + for( ; pt_equipot != NULL; pt_equipot = (EQUIPOT*)pt_equipot->Pnext) + { + if( pt_equipot->m_NetCode == g_HightLigth_NetCode) break; + } + if( pt_equipot ) + { + line.Printf( wxT("Zone: Net[%d] <%s>"),g_HightLigth_NetCode, + pt_equipot->m_Netname.GetData()); + } + else line.Printf( wxT("Zone: NetCode[%d], Equipot not found"), + g_HightLigth_NetCode); + } + + line = _("Zone: No net selected"); + + frame->Affiche_Message(line); +} + +/********************************************************/ +static void Exit_Zones(WinEDA_DrawPanel * Panel, wxDC *DC) +/********************************************************/ +/* routine d'annulation de la Commande Begin_Zone si une piste est en cours + de tracage, ou de sortie de l'application SEGZONES. + Appel par la touche ESC + */ +{ +WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*)Panel->m_Parent; + + if( pcbframe->m_Pcb->m_CurrentLimitZone ) + { + if( Panel->ManageCurseur ) /* trace en cours */ + { + Panel->ManageCurseur(Panel, DC, 0); + } + pcbframe->DelLimitesZone(DC, FALSE); + } + + Panel->ManageCurseur = NULL; + Panel->ForceCloseManageCurseur = NULL; + pcbframe->GetScreen()->m_CurrentItem = NULL; + +} + + +/**************************************************************/ +void WinEDA_BasePcbFrame::DelLimitesZone(wxDC *DC, bool Redraw) +/**************************************************************/ +/* Supprime la liste des segments constituant la frontiere courante + Libere la memoire correspondante +*/ +{ +EDGE_ZONE * segment, * Next; + + if( m_Pcb->m_CurrentLimitZone == NULL ) return; + + if ( ! IsOK(this, _("Delete Current Zone Edges")) ) return; + /* efface ancienne limite de zone */ + segment = m_Pcb->m_CurrentLimitZone; + for( ; segment != NULL; segment = Next) + { + Next = (EDGE_ZONE*) segment->Pback; + if ( Redraw ) Trace_DrawSegmentPcb(DrawPanel, DC, segment,GR_XOR); + segment->Pnext = NULL; delete segment; + } + + GetScreen()->m_CurrentItem = NULL; + m_Pcb->m_CurrentLimitZone = NULL; +} + +/********************************************/ +EDGE_ZONE * WinEDA_PcbFrame::Begin_Zone(void) +/********************************************/ +/* +Routine d'initialisation d'un trace de Limite de Zone ou + de placement d'un point intermediaire +*/ +{ +EDGE_ZONE * oldedge, * newedge = NULL; + + oldedge = m_Pcb->m_CurrentLimitZone; + + if( (m_Pcb->m_CurrentLimitZone == NULL ) || /* debut reel du trace */ + (DrawPanel->ManageCurseur == NULL) ) /* reprise d'un trace complementaire */ + { + m_Pcb->m_CurrentLimitZone = newedge = new EDGE_ZONE( m_Pcb ); + + newedge->m_Flags = IS_NEW | STARTPOINT | IS_MOVED; + newedge->Pback = oldedge; + if(oldedge) oldedge->Pnext = newedge; + newedge->m_Layer = GetScreen()->m_Active_Layer; + newedge->m_Width = 2 ; /* Largeur minimum tracable */ + newedge->m_Start = newedge->m_End = GetScreen()->m_Curseur; + + m_Pcb->m_CurrentLimitZone = newedge; + DrawPanel->ManageCurseur = Show_Zone_Edge_While_MoveMouse; + DrawPanel->ForceCloseManageCurseur = Exit_Zones; + } + + else /* piste en cours : les coord du point d'arrivee ont ete mises + a jour par la routine Show_Zone_Edge_While_MoveMouse*/ + { + if( (oldedge->m_Start.x != oldedge->m_End.x) || + (oldedge->m_Start.y != oldedge->m_End.y) ) + { + newedge = new EDGE_ZONE( oldedge); + newedge->Pback = oldedge; + oldedge->Pnext = newedge; + newedge->m_Flags = IS_NEW | IS_MOVED; + newedge->m_Start = newedge->m_End = oldedge->m_End; + newedge->m_Layer = GetScreen()->m_Active_Layer; + m_Pcb->m_CurrentLimitZone = newedge; + } + } + + return newedge; +} + +/*********************************************/ +void WinEDA_PcbFrame::End_Zone(wxDC * DC) +/*********************************************/ +/* + Routine de fin de trace d'une zone (succession de segments) +*/ +{ +EDGE_ZONE * PtLim; + + if( m_Pcb->m_CurrentLimitZone ) + { + Begin_Zone(); + + /* le dernier point genere est de longueur tj nulle donc inutile. */ + /* il sera raccorde au point de depart */ + PtLim = m_Pcb->m_CurrentLimitZone; + PtLim->m_Flags &= ~(IS_NEW|IS_MOVED); + while( PtLim && PtLim->Pback) + { + PtLim = (EDGE_ZONE*) PtLim->Pback; + if ( PtLim->m_Flags & STARTPOINT) break; + PtLim->m_Flags &= ~(IS_NEW|IS_MOVED); + } + + if( PtLim ) + { + PtLim->m_Flags &= ~(IS_NEW|IS_MOVED); + m_Pcb->m_CurrentLimitZone->m_End = PtLim->m_Start; + } + Trace_DrawSegmentPcb(DrawPanel, DC, m_Pcb->m_CurrentLimitZone,GR_XOR); + } + + DrawPanel->ManageCurseur = NULL; + DrawPanel->ForceCloseManageCurseur = NULL; +} + + +/******************************************************************************************/ +static void Show_Zone_Edge_While_MoveMouse(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) +/******************************************************************************************/ +/* redessin du contour de la piste lors des deplacements de la souris +*/ +{ +EDGE_ZONE * PtLim, * edgezone; +WinEDA_PcbFrame * pcbframe = (WinEDA_PcbFrame *) panel->m_Parent; + + if( pcbframe->m_Pcb->m_CurrentLimitZone == NULL ) return ; + + /* efface ancienne position si elle a ete deja dessinee */ + if( erase ) + { + PtLim = pcbframe->m_Pcb->m_CurrentLimitZone; + for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback) + { + Trace_DrawSegmentPcb(panel, DC, PtLim,GR_XOR); + } + } + + /* mise a jour de la couche */ + edgezone = PtLim = pcbframe->m_Pcb->m_CurrentLimitZone; + for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback) + { + PtLim->m_Layer = pcbframe->GetScreen()->m_Active_Layer; + } + + /* dessin de la nouvelle piste : mise a jour du point d'arrivee */ + if (Zone_45_Only) + {/* Calcul de l'extremite de la piste pour orientations permises: + horiz,vertical ou 45 degre */ + edgezone->m_End = pcbframe->GetScreen()->m_Curseur; + Calcule_Coord_Extremite_45(edgezone->m_Start.x, edgezone->m_Start.y, + &edgezone->m_End.x, &edgezone->m_End.y); + } + else /* ici l'angle d'inclinaison est quelconque */ + { + edgezone->m_End = pcbframe->GetScreen()->m_Curseur; + } + + PtLim = edgezone; + for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback) + { + Trace_DrawSegmentPcb(panel, DC, PtLim,GR_XOR); + } +} + + +/**********************************************/ +void WinEDA_PcbFrame::Fill_Zone(wxDC * DC) +/**********************************************/ +/* +Fonction generale de creation de zone + Un contour de zone doit exister, sinon l'ensemble du PCB est utilise + + ce qui permet de creer des obstacles et donc des parties non remplies. + + Le remplissage s'effectue a partir du point d'ancrage, jusque ves les limites + + + On place la zone sur la couche (layer) active. + + + "Hight Light" la zone fera partie de ce net +*/ +{ +int ii, jj; +EDGE_ZONE* PtLim; +int lp_tmp, lay_tmp_TOP, lay_tmp_BOTTOM; +EQUIPOT* pt_equipot; +int save_isol = g_DesignSettings.m_TrackClearence; +wxPoint ZoneStartFill; +wxString msg; + + MsgPanel->EraseMsgBox(); + if ( m_Pcb->ComputeBoundaryBox() == FALSE ) + { + DisplayError(this, wxT("Board is empty!"), 10); + return; + } + DrawPanel->m_IgnoreMouseEvents = TRUE; + WinEDA_ZoneFrame * frame = new WinEDA_ZoneFrame(this); + ii = frame->ShowModal(); frame->Destroy(); + DrawPanel->MouseToCursorSchema(); + DrawPanel->m_IgnoreMouseEvents = FALSE; + if ( ii ) return; + + g_DesignSettings.m_TrackClearence = g_DesignSettings.m_ZoneClearence; + + /* mise a jour de la couche */ + PtLim = m_Pcb->m_CurrentLimitZone; + for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback) + { + Trace_DrawSegmentPcb(DrawPanel, DC, PtLim, GR_XOR); + PtLim->m_Layer = GetScreen()->m_Active_Layer; + Trace_DrawSegmentPcb(DrawPanel, DC, PtLim, GR_XOR); + } + + TimeStamp = time( NULL ); + + /* Calcul du pas de routage fixe a 5 mils et plus */ + E_scale = g_GridRoutingSize / 50 ; if (g_GridRoutingSize < 1 ) g_GridRoutingSize = 1 ; + + /* calcule de Ncols et Nrow, taille de la matrice de routage */ + ComputeMatriceSize(this, g_GridRoutingSize); + + /* Determination de la cellule pointee par la souris */ + ZoneStartFill.x = (GetScreen()->m_Curseur.x - m_Pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize/2) ) / g_GridRoutingSize; + ZoneStartFill.y = (GetScreen()->m_Curseur.y - m_Pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize/2) ) / g_GridRoutingSize; + if(ZoneStartFill.x < 0) ZoneStartFill.x = 0; + if(ZoneStartFill.x >= Ncols) ZoneStartFill.x = Ncols-1; + if(ZoneStartFill.y < 0) ZoneStartFill.y = 0; + if(ZoneStartFill.y >= Nrows) ZoneStartFill.y = Nrows-1; + + /* Creation du mapping de la matrice de routage */ + Nb_Sides = ONE_SIDE; + if( Board.InitBoard() < 0) + { + DisplayError(this, wxT("Mo memory for creating zones")); + return; + } + + msg.Printf( wxT("%d"),Ncols); + Affiche_1_Parametre(this, 1, wxT("Cols"),msg,GREEN); + msg.Printf( wxT("%d"),Nrows); + Affiche_1_Parametre(this, 7, wxT("Lines"),msg,GREEN); + msg.Printf( wxT("%d"), Board.m_MemSize / 1024 ); + Affiche_1_Parametre(this, 14, wxT("Mem(Ko)"),msg,CYAN); + + lay_tmp_BOTTOM = Route_Layer_BOTTOM; + lay_tmp_TOP = Route_Layer_TOP; + + Route_Layer_BOTTOM = Route_Layer_TOP = GetScreen()->m_Active_Layer; + lp_tmp = g_DesignSettings.m_CurrentTrackWidth; g_DesignSettings.m_CurrentTrackWidth = g_GridRoutingSize; + + /* Affichage du NetName */ + if(g_HightLigth_NetCode > 0) + { + pt_equipot = GetEquipot(m_Pcb, g_HightLigth_NetCode); + if( pt_equipot == NULL) + { + if(g_HightLigth_NetCode > 0 ) DisplayError(this, wxT("Equipot Error")); + } + else msg = pt_equipot->m_Netname; + } + else msg = _("No Net"); + + Affiche_1_Parametre(this, 22,_("NetName"),msg,RED) ; + + /* Init des points d'accrochage possibles de la zone: + les pistes du net sont des points d'accrochage convenables*/ + TRACK * pt_segm = m_Pcb->m_Track; + for( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext) + { + if(g_HightLigth_NetCode != pt_segm->m_NetCode) continue; + if ( pt_segm->m_Layer != GetScreen()->m_Active_Layer ) continue; + if (pt_segm->m_StructType != TYPETRACK ) continue; + TraceSegmentPcb(m_Pcb, pt_segm, CELL_is_FRIEND, 0, WRITE_CELL ); + } + + /* Trace des contours du PCB sur la matrice de routage: */ + Route_Layer_BOTTOM = Route_Layer_TOP = EDGE_N; + PlaceCells(m_Pcb, -1, 0); + Route_Layer_BOTTOM = Route_Layer_TOP = GetScreen()->m_Active_Layer; + + /* Trace des limites de la zone sur la matrice de routage: */ + PtLim = m_Pcb->m_CurrentLimitZone; + for( ; PtLim != NULL; PtLim = (EDGE_ZONE*)PtLim->Pback) + { + int ux0, uy0, ux1, uy1; + ux0 = PtLim->m_Start.x - m_Pcb->m_BoundaryBox.m_Pos.x; + uy0 = PtLim->m_Start.y - m_Pcb->m_BoundaryBox.m_Pos.y; + ux1 = PtLim->m_End.x - m_Pcb->m_BoundaryBox.m_Pos.x; + uy1 = PtLim->m_End.y - m_Pcb->m_BoundaryBox.m_Pos.y; + TraceLignePcb(ux0,uy0,ux1,uy1,-1,HOLE|CELL_is_EDGE,WRITE_CELL); + } + + + OrCell(ZoneStartFill.y,ZoneStartFill.x, BOTTOM, CELL_is_ZONE); + + /* Marquage des cellules faisant partie de la zone*/ + ii = 1; jj = 1; + while( ii ) + { + msg.Printf( wxT("%d"), jj++ ); + Affiche_1_Parametre(this, 50, wxT("Iter."),msg,CYAN); + ii = Propagation(this); + } + + /* Selection des cellules convenables pour les points d'ancrage de la zone */ + for( ii = 0; ii < Nrows ; ii++) + { + for( jj = 0; jj < Ncols ; jj++) + { + long cell = GetCell(ii,jj,BOTTOM); + if( (cell & CELL_is_ZONE) ) + { + if ( (cell & CELL_is_FRIEND) == 0) + AndCell(ii,jj,BOTTOM, ~(CELL_is_FRIEND|CELL_is_ZONE) ); + } + } + } + + + /* Maintenant, toutes les cellules candidates sont marquees */ + /* Placement des cellules (pads, tracks, vias, edges pcb ou segments) + faisant des obsctacles sur la matrice de routage */ + ii = 0; + if( Zone_Exclude_Pads ) ii = FORCE_PADS; + Affiche_1_Parametre(this, 42, wxT("GenZone"),wxEmptyString,RED); + PlaceCells(m_Pcb, g_HightLigth_NetCode, ii); + Affiche_1_Parametre(this, -1, wxEmptyString, _("Ok"),RED); + + /* Trace des limites de la zone sur la matrice de routage + (a pu etre detruit par PlaceCells()) : */ + PtLim = m_Pcb->m_CurrentLimitZone; + for( ; PtLim != NULL; PtLim = (EDGE_ZONE*)PtLim->Pback) + { + int ux0, uy0, ux1, uy1; + ux0 = PtLim->m_Start.x - m_Pcb->m_BoundaryBox.m_Pos.x; + uy0 = PtLim->m_Start.y - m_Pcb->m_BoundaryBox.m_Pos.y; + ux1 = PtLim->m_End.x - m_Pcb->m_BoundaryBox.m_Pos.x; + uy1 = PtLim->m_End.y - m_Pcb->m_BoundaryBox.m_Pos.y; + TraceLignePcb(ux0,uy0,ux1,uy1,-1,HOLE|CELL_is_EDGE,WRITE_CELL); + } + + + /* Init du point d'accrochage de la zone donné par la position souris + (a pu etre detruit par PlaceCells()) : */ + OrCell(ZoneStartFill.y,ZoneStartFill.x, BOTTOM, CELL_is_ZONE); + + if(Zone_Debug) DisplayBoard(DrawPanel, DC); + + /* Remplissage des cellules (creation effective de la zone)*/ + ii = 1; jj = 1; + while( ii ) + { + msg.Printf( wxT("%d"), jj++ ); + Affiche_1_Parametre(this, 50, wxT("Iter."),msg,CYAN); + ii = Propagation(this); + } + + if(Zone_Debug) DisplayBoard(DrawPanel, DC); + + /* Generation des segments de piste type Zone correspondants*/ + if(g_HightLigth_NetCode < 0 ) + Genere_Segments_Zone(this, DC, 0); + else Genere_Segments_Zone(this, DC, g_HightLigth_NetCode); + + /* Trace des connexions type frein thermique */ + g_DesignSettings.m_CurrentTrackWidth = lp_tmp; + if ( Zone_Exclude_Pads && Zone_Genere_Freins_Thermiques) + Genere_Pad_Connexion(this, DC, GetScreen()->m_Active_Layer); + + g_DesignSettings.m_TrackClearence = save_isol; + + GetScreen()->SetModify(); + + /* Liberation de la memoire */ + Board.UnInitBoard(); + + /* Reprise des conditions initiales */ + Route_Layer_TOP = lay_tmp_TOP; + Route_Layer_BOTTOM = lay_tmp_BOTTOM; +} + + +/*******************************************************************************/ +static void Genere_Segments_Zone(WinEDA_PcbFrame *frame, wxDC * DC, int net_code) +/*******************************************************************************/ +/* Genere les segments de piste dans les limites de la zone a remplir + Algorithme: + procede en 2 balayages + - Gauche->droite + - Haut->Bas + Parametres: + net_code = net_code a attribuer au segment de zone + TimeStamp(global): signature temporelle d'identification + (mis en .start) +*/ +{ +int row, col; +long current_cell, old_cell; +int ux0 = 0, uy0 = 0, ux1 = 0, uy1 = 0; +int Xmin = frame->m_Pcb->m_BoundaryBox.m_Pos.x; +int Ymin = frame->m_Pcb->m_BoundaryBox.m_Pos.y; +SEGZONE * pt_track; +int layer = frame->GetScreen()->m_Active_Layer; +int nbsegm = 0; +wxString msg; + + /* balayage Gauche-> droite */ + Affiche_1_Parametre(frame, 64, wxT("Segm H"), wxT("0"),BROWN); + for( row = 0; row < Nrows ; row++) + { + old_cell = 0; + uy0 = uy1 = (row * g_GridRoutingSize) + Ymin; + for( col = 0; col < Ncols ; col++) + { + current_cell = GetCell(row,col,BOTTOM) & CELL_is_ZONE; + if(current_cell) /* ce point doit faire partie d'un segment */ + { + ux1 = (col * g_GridRoutingSize) + Xmin; + if( old_cell == 0 ) ux0 = ux1; + } + + if( ! current_cell || (col == Ncols-1) ) /* peut etre fin d'un segment */ + { + if( (old_cell) && (ux0 != ux1) ) + { /* un segment avait debute de longueur > 0 */ + pt_track = new SEGZONE(frame->m_Pcb); + pt_track->m_Layer = layer; + pt_track->m_NetCode = net_code; + pt_track->m_Width = g_GridRoutingSize; + pt_track->m_Start.x = ux0; pt_track->m_Start.y = uy0; + pt_track->m_End.x = ux1; pt_track->m_End.y = uy1; + pt_track->m_TimeStamp = TimeStamp; + pt_track->Insert(frame->m_Pcb, NULL); + pt_track->Draw(frame->DrawPanel, DC, GR_OR); + nbsegm++; + } + } + old_cell = current_cell; + } + msg.Printf( wxT("%d"),nbsegm); + Affiche_1_Parametre(frame, -1, wxEmptyString,msg,BROWN); + } + + Affiche_1_Parametre(frame, 72, wxT("Segm V"), wxT("0"),BROWN); + for( col = 0; col < Ncols ; col++) + { + old_cell = 0; + ux0 = ux1 = (col * g_GridRoutingSize) + Xmin; + for( row = 0; row < Nrows ; row++) + { + current_cell = GetCell(row,col,BOTTOM) & CELL_is_ZONE; + if(current_cell) /* ce point doit faire partie d'un segment */ + { + uy1 = (row * g_GridRoutingSize) + Ymin; + if( old_cell == 0 ) uy0 = uy1; + } + if( ! current_cell || (row == Nrows-1) ) /* peut etre fin d'un segment */ + { + if( (old_cell) && (uy0 != uy1) ) + { /* un segment avait debute de longueur > 0 */ + pt_track = new SEGZONE(frame->m_Pcb); + pt_track->m_Layer = layer; + pt_track->m_Width = g_GridRoutingSize; + pt_track->m_NetCode = net_code; + pt_track->m_Start.x = ux0; pt_track->m_Start.y = uy0; + pt_track->m_End.x = ux1; pt_track->m_End.y = uy1; + pt_track->m_TimeStamp = TimeStamp; + pt_track->Insert(frame->m_Pcb, NULL); + pt_track->Draw(frame->DrawPanel, DC, GR_OR); + nbsegm++; + } + } + old_cell = current_cell; + } + msg.Printf( wxT("%d"),nbsegm); + Affiche_1_Parametre(frame, -1, wxEmptyString,msg,BROWN); + } +} + + +/********************************************/ +int Propagation(WinEDA_PcbFrame * frame) +/********************************************/ +/* Determine les cellules inscrites dans les limites de la zone a remplir + Algorithme: + Si une cellule disponible a un voisin faisant partie de la zone, elle + devient elle meme partie de la zone + On procede en 4 balayages de la matrice des cellules + - Gauche->droite de Haut->bas + - Droite->gauche de Haut->bas + - Bas->Haut de Droite->gauche + - Bas->Haut de Gauche->Droite + et pour chaque balayage, on considere des 2 cellules voisines de + la cellule courants: cellule precedente sur la ligne et cellule precedente + sur la colonne. + + La routine peut demander plusieurs iterations + les iterations doivent continuer juqu'a ce que la routine ne trouve plus + de cellules a modifier. + Retourne: + Nombre de cellules modifiees (c.a.d mises a la valeur CELL_is_ZONE. +*/ +{ +int row, col, nn; +long current_cell, old_cell_H; +int long * pt_cell_V; +int nbpoints = 0; +#define NO_CELL_ZONE (HOLE | CELL_is_EDGE | CELL_is_ZONE) +wxString msg; + + Affiche_1_Parametre(frame, 57, wxT("Detect"),msg,CYAN); + /* balayage Gauche-> droite de Haut->bas */ + Affiche_1_Parametre(frame, -1, wxEmptyString, wxT("1"),CYAN); + + // Reservation memoire pour stockahe de 1 ligne ou une colonne de cellules + nn = MAX(Nrows, Ncols) * sizeof(*pt_cell_V); + pt_cell_V = (long *) MyMalloc(nn); + memset(pt_cell_V, 0, nn); + for( row = 0; row < Nrows ; row++) + { + old_cell_H = 0; + for( col = 0; col < Ncols ; col++) + { + current_cell = GetCell(row,col,BOTTOM) & NO_CELL_ZONE; + if(current_cell == 0 ) /* une cellule libre a ete trouvee */ + { + if( (old_cell_H & CELL_is_ZONE) + || (pt_cell_V[col] & CELL_is_ZONE) ) + { + OrCell(row,col,BOTTOM,CELL_is_ZONE); + current_cell = CELL_is_ZONE; + nbpoints++; + } + } + pt_cell_V[col] = old_cell_H = current_cell; + } + } + + /* balayage Droite-> gauche de Haut->bas */ + Affiche_1_Parametre(frame, -1, wxEmptyString, wxT("2"),CYAN); + memset(pt_cell_V, 0, nn); + for( row = 0; row < Nrows ; row++) + { + old_cell_H = 0; + for( col = Ncols -1 ; col >= 0 ; col--) + { + current_cell = GetCell(row,col,BOTTOM) & NO_CELL_ZONE ; + if(current_cell == 0 ) /* une cellule libre a ete trouvee */ + { + if( (old_cell_H & CELL_is_ZONE) + || (pt_cell_V[col] & CELL_is_ZONE) ) + { + OrCell(row,col,BOTTOM,CELL_is_ZONE); + current_cell = CELL_is_ZONE; + nbpoints++; + } + } + pt_cell_V[col] = old_cell_H = current_cell; + } + } + + /* balayage Bas->Haut de Droite->gauche */ + Affiche_1_Parametre(frame, -1, wxEmptyString, wxT("3"),CYAN); + memset(pt_cell_V, 0, nn); + for( col = Ncols -1 ; col >= 0 ; col--) + { + old_cell_H = 0; + for( row = Nrows-1; row >= 0 ; row--) + { + current_cell = GetCell(row,col,BOTTOM) & NO_CELL_ZONE ; + if(current_cell == 0 ) /* une cellule libre a ete trouvee */ + { + if( (old_cell_H & CELL_is_ZONE) + || (pt_cell_V[row] & CELL_is_ZONE) ) + { + OrCell(row,col,BOTTOM,CELL_is_ZONE); + current_cell = CELL_is_ZONE; + nbpoints++; + } + } + pt_cell_V[row] = old_cell_H = current_cell; + } + } + + /* balayage Bas->Haut de Gauche->Droite*/ + Affiche_1_Parametre(frame, -1, wxEmptyString, wxT("4"),CYAN); + memset(pt_cell_V, 0, nn); + for( col = 0 ; col < Ncols ; col++) + { + old_cell_H = 0; + for( row = Nrows-1; row >= 0 ; row--) + { + current_cell = GetCell(row,col,BOTTOM) & NO_CELL_ZONE ; + if(current_cell == 0 ) /* une cellule libre a ete trouvee */ + { + if( (old_cell_H & CELL_is_ZONE) + || (pt_cell_V[row] & CELL_is_ZONE) ) + { + OrCell(row,col,BOTTOM,CELL_is_ZONE) ; + current_cell = CELL_is_ZONE; + nbpoints++; + } + } + pt_cell_V[row] = old_cell_H = current_cell; + } + } + + MyFree(pt_cell_V); + + return(nbpoints); +} + + + +/*****************************************************************************/ +static bool Genere_Pad_Connexion(WinEDA_PcbFrame *frame, wxDC * DC, int layer) +/*****************************************************************************/ +/* Generation des segments de zone de connexion zone / pad pour constitution +de freins thermiques +*/ +{ +int ii, jj, Npads; +D_PAD * pt_pad; +LISTE_PAD * pt_liste_pad; +TRACK * pt_track, * loctrack; +int angle; +int cX, cY, dx, dy; +int sommet[4][2]; +wxString msg; + + if( frame->m_Pcb->m_Zone == NULL ) return FALSE; /* pas de zone */ + if( frame->m_Pcb->m_Zone->m_TimeStamp != TimeStamp ) /* c'est une autre zone */ + return FALSE; + + /* Calcul du nombre de pads a traiter et affichage */ + Affiche_1_Parametre(frame, 50, wxT("NPads"),wxT(" "),CYAN); + pt_liste_pad = (LISTE_PAD*) frame->m_Pcb->m_Pads; + for ( ii = 0, Npads = 0; ii < frame->m_Pcb->m_NbPads; ii++, pt_liste_pad++) + { + pt_pad = *pt_liste_pad; + /* la pastille doit etre du meme net */ + if(pt_pad->m_NetCode != g_HightLigth_NetCode) continue; + /* la pastille doit exister sur la couche */ + if( (pt_pad->m_Masque_Layer & g_TabOneLayerMask[layer]) == 0 ) continue; + Npads++; + } + msg.Printf( wxT("%d"), Npads ); + Affiche_1_Parametre(frame, -1, wxEmptyString,msg,CYAN); + + Affiche_1_Parametre(frame, 57, wxT("Pads"), wxT(" "),CYAN); + pt_liste_pad = (LISTE_PAD*) frame->m_Pcb->m_Pads; + for ( ii = 0, Npads = 0; ii < frame->m_Pcb->m_NbPads; ii++, pt_liste_pad++) + { + pt_pad = *pt_liste_pad; + + /* la pastille doit etre du meme net */ + if(pt_pad->m_NetCode != g_HightLigth_NetCode) continue; + /* la pastille doit exister sur la couche */ + if( (pt_pad->m_Masque_Layer & g_TabOneLayerMask[layer]) == 0 ) continue; + + /* traitement du pad en cours */ + Npads++; msg.Printf( wxT("%d"), Npads ); + Affiche_1_Parametre(frame, -1, wxEmptyString,msg,CYAN); + cX = pt_pad->m_Pos.x; cY = pt_pad->m_Pos.y; + dx = pt_pad->m_Size.x / 2; + dy = pt_pad->m_Size.y / 2; + dx += g_DesignSettings.m_TrackClearence + g_GridRoutingSize; + dy += g_DesignSettings.m_TrackClearence + g_GridRoutingSize; + + if(pt_pad->m_PadShape == TRAPEZE) + { + dx += abs(pt_pad->m_DeltaSize.y) / 2; + dy += abs(pt_pad->m_DeltaSize.x) / 2; + } + + /* calcul des coord des 4 segments a rajouter a partir du centre cX,cY */ + sommet[0][0] = 0; sommet[0][1] = -dy; + sommet[1][0] = -dx; sommet[1][1] = 0; + sommet[2][0] = 0; sommet[2][1] = dy; + sommet[3][0] = dx; sommet[3][1] = 0; + + angle = pt_pad->m_Orient; + for(jj = 0; jj < 4; jj++) + { + RotatePoint(&sommet[jj][0], &sommet[jj][1], angle); + + pt_track = new SEGZONE(frame->m_Pcb); + + pt_track->m_Layer = layer; + pt_track->m_Width = g_DesignSettings.m_CurrentTrackWidth; + pt_track->m_NetCode = g_HightLigth_NetCode; + pt_track->start = pt_pad; + pt_track->m_Start.x = cX; pt_track->m_Start.y = cY; + pt_track->m_End.x = cX + sommet[jj][0]; + pt_track->m_End.y = cY + sommet[jj][1]; + pt_track->m_TimeStamp = TimeStamp; + + /* tst si trace possible */ + if( Drc(frame, DC, pt_track,frame->m_Pcb->m_Track,0) == BAD_DRC ) + { + delete pt_track; continue; + } + + /* on doit pouvoir se connecter sur la zone */ + loctrack = Locate_Zone(frame->m_Pcb->m_Zone,pt_track->m_End, layer); + if( (loctrack == NULL) || (loctrack->m_TimeStamp != TimeStamp) ) + { + delete pt_track; continue; + } + + pt_track->Insert(frame->m_Pcb, NULL); + pt_track->Draw(frame->DrawPanel, DC, GR_OR); + } + } + return TRUE; +} + + diff --git a/pcbnew/zones.h b/pcbnew/zones.h new file mode 100644 index 0000000000..acfda6fbaa --- /dev/null +++ b/pcbnew/zones.h @@ -0,0 +1,126 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: zones.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 25/01/2006 11:35:19 +// RCS-ID: +// Copyright: GNU License +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 25/01/2006 11:35:19 + +#ifndef _ZONES_H_ +#define _ZONES_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "zones.h" +#endif + +/*! + * Includes + */ +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "pcbnew.h" + +#include "autorout.h" +#include "cell.h" +#include "trigo.h" + +#include "protos.h" + +////@begin includes +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define SYMBOL_WINEDA_ZONEFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxSTAY_ON_TOP|wxCLOSE_BOX +#define SYMBOL_WINEDA_ZONEFRAME_TITLE _("Fill Zones Options") +#define SYMBOL_WINEDA_ZONEFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_ZONEFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_ZONEFRAME_POSITION wxDefaultPosition +#define ID_RADIOBOX 10001 +#define ID_TEXTCTRL 10006 +#define ID_RADIOBOX1 10004 +#define ID_RADIOBOX2 10005 +#define ID_FILL_ZONE 10002 +#define ID_SET_OPTIONS_ZONE 10003 +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_ZoneFrame class declaration + */ + +class WinEDA_ZoneFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_ZoneFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_ZoneFrame( ); + WinEDA_ZoneFrame( WinEDA_PcbFrame* parent, wxWindowID id = SYMBOL_WINEDA_ZONEFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_ZONEFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_ZONEFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_ZONEFRAME_SIZE, long style = SYMBOL_WINEDA_ZONEFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_ZONEFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_ZONEFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_ZONEFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_ZONEFRAME_SIZE, long style = SYMBOL_WINEDA_ZONEFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_ZoneFrame event handler declarations + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FILL_ZONE + void ExecFillZone( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + +////@end WinEDA_ZoneFrame event handler declarations + +////@begin WinEDA_ZoneFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_ZoneFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + +////@begin WinEDA_ZoneFrame member variables + wxRadioBox* m_GridCtrl; + wxStaticText* m_ClearanceValueTitle; + wxTextCtrl* m_ZoneClearanceCtrl; + wxRadioBox* m_FillOpt; + wxRadioBox* m_OrientEdgesOpt; +////@end WinEDA_ZoneFrame member variables + WinEDA_PcbFrame * m_Parent; +}; + +#endif + // _ZONES_H_ diff --git a/pcbnew/zones.rc b/pcbnew/zones.rc new file mode 100644 index 0000000000..f63e693459 --- /dev/null +++ b/pcbnew/zones.rc @@ -0,0 +1 @@ +#include "wx/msw/wx.rc" diff --git a/share/dialog_print.cpp b/share/dialog_print.cpp new file mode 100644 index 0000000000..2b4813d163 --- /dev/null +++ b/share/dialog_print.cpp @@ -0,0 +1,339 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_print.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 28/02/2006 18:30:16 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 28/02/2006 18:30:16 + +////@begin includes +////@end includes + +#include "dialog_print.h" + +////@begin XPM images +////@end XPM images + +/*! + * WinEDA_PrintFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_PrintFrame, wxDialog ) + +/*! + * WinEDA_PrintFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_PrintFrame, wxDialog ) + +////@begin WinEDA_PrintFrame event table entries + EVT_RADIOBOX( ID_SET_PRINT_SCALE, WinEDA_PrintFrame::OnSetPrintScaleSelected ) + + EVT_SPINCTRL( ID_PEN_WIDTH, WinEDA_PrintFrame::OnPenWidthUpdated ) + + EVT_RADIOBOX( ID_SET_BW, WinEDA_PrintFrame::OnSetBwSelected ) + + EVT_BUTTON( ID_PRINT_SETUP, WinEDA_PrintFrame::OnPrintSetupClick ) + + EVT_BUTTON( ID_PRINT_PREVIEW, WinEDA_PrintFrame::OnPrintPreviewClick ) + + EVT_BUTTON( ID_PRINT_EXECUTE, WinEDA_PrintFrame::OnPrintExecuteClick ) + + EVT_BUTTON( wxID_CLOSE, WinEDA_PrintFrame::OnCloseClick ) + +////@end WinEDA_PrintFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_PrintFrame constructors + */ + +WinEDA_PrintFrame::WinEDA_PrintFrame( ) +{ +} + +WinEDA_PrintFrame::WinEDA_PrintFrame( WinEDA_DrawFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ + m_Parent = parent; + m_XScaleAdjust = m_YScaleAdjust = 1.0; + m_PagesOption = NULL; + + Create(parent, id, caption, pos, size, style); +} + +/*! + * WinEDA_PrintFrame creator + */ + +bool WinEDA_PrintFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_PrintFrame member initialisation + m_CopperLayersBoxSizer = NULL; + m_TechLayersBoxSizer = NULL; + m_ScaleOption = NULL; + m_FineAdjustXscaleTitle = NULL; + m_FineAdjustXscaleOpt = NULL; + m_FineAdjustYscaleTitle = NULL; + m_FineAdjustYscaleOpt = NULL; + m_ButtPenWidth = NULL; + m_Print_Sheet_Ref = NULL; + m_Print_Mirror = NULL; + m_ColorOption = NULL; + m_PagesOptionPcb = NULL; + m_PagesOptionEeschema = NULL; +////@end WinEDA_PrintFrame member initialisation + +////@begin WinEDA_PrintFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + if (GetSizer()) + { + GetSizer()->SetSizeHints(this); + } + Centre(); +////@end WinEDA_PrintFrame creation + return true; +} + +/*! + * Control creation for WinEDA_PrintFrame + */ + +void WinEDA_PrintFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_PrintFrame content construction + // Generated by DialogBlocks, 13/01/2007 16:42:47 (unregistered) + + WinEDA_PrintFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + m_CopperLayersBoxSizer = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(m_CopperLayersBoxSizer, 0, wxALIGN_TOP|wxALL, 5); + + m_TechLayersBoxSizer = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(m_TechLayersBoxSizer, 0, wxALIGN_TOP|wxALL, 5); + + wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer5, 0, wxGROW|wxALL, 5); + + wxString m_ScaleOptionStrings[] = { + _("fit in page"), + _("Scale 0.5"), + _("Scale 0.7"), + _("Approx. Scale 1"), + _("Accurate Scale 1"), + _("Scale 1.4"), + _("Scale 2"), + _("Scale 3"), + _("Scale 4") + }; + m_ScaleOption = new wxRadioBox( itemDialog1, ID_SET_PRINT_SCALE, _("Approx. Scale:"), wxDefaultPosition, wxDefaultSize, 9, m_ScaleOptionStrings, 1, wxRA_SPECIFY_COLS ); + m_ScaleOption->SetSelection(0); + itemBoxSizer5->Add(m_ScaleOption, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + m_FineAdjustXscaleTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("X Scale Adjust"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer5->Add(m_FineAdjustXscaleTitle, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_FineAdjustXscaleOpt = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer5->Add(m_FineAdjustXscaleOpt, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + m_FineAdjustYscaleTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Y Scale Adjust"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer5->Add(m_FineAdjustYscaleTitle, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_FineAdjustYscaleOpt = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer5->Add(m_FineAdjustYscaleOpt, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer12, 0, wxGROW|wxALL, 5); + + wxStaticText* itemStaticText13 = new wxStaticText( itemDialog1, wxID_STATIC, _("Pen width mini"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer12->Add(itemStaticText13, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_ButtPenWidth = new wxSpinCtrl( itemDialog1, ID_PEN_WIDTH, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 100, 0 ); + itemBoxSizer12->Add(m_ButtPenWidth, 0, wxGROW|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer15Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Options:")); + wxStaticBoxSizer* itemStaticBoxSizer15 = new wxStaticBoxSizer(itemStaticBoxSizer15Static, wxVERTICAL); + itemBoxSizer12->Add(itemStaticBoxSizer15, 0, wxGROW|wxALL, 5); + + m_Print_Sheet_Ref = new wxCheckBox( itemDialog1, ID_PRINT_REF, _("Print Sheet Ref"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_Print_Sheet_Ref->SetValue(false); + itemStaticBoxSizer15->Add(m_Print_Sheet_Ref, 0, wxGROW|wxALL, 5); + + m_Print_Mirror = new wxCheckBox( itemDialog1, ID_CHECK_PRINT_MIROR, _("Mirror"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_Print_Mirror->SetValue(false); + itemStaticBoxSizer15->Add(m_Print_Mirror, 0, wxGROW|wxALL, 5); + + wxString m_ColorOptionStrings[] = { + _("Color"), + _("Black") + }; + m_ColorOption = new wxRadioBox( itemDialog1, ID_SET_BW, _("Color Print:"), wxDefaultPosition, wxDefaultSize, 2, m_ColorOptionStrings, 1, wxRA_SPECIFY_COLS ); + m_ColorOption->SetSelection(0); + itemBoxSizer12->Add(m_ColorOption, 0, wxGROW|wxALL, 5); + + wxString m_PagesOptionPcbStrings[] = { + _("1 page per layer"), + _("Single Page") + }; + m_PagesOptionPcb = new wxRadioBox( itemDialog1, ID_PRINT_ALL_IN_ONE, _("Page Print:"), wxDefaultPosition, wxDefaultSize, 2, m_PagesOptionPcbStrings, 1, wxRA_SPECIFY_COLS ); + m_PagesOptionPcb->SetSelection(0); + itemBoxSizer12->Add(m_PagesOptionPcb, 0, wxGROW|wxALL, 5); + + wxString m_PagesOptionEeschemaStrings[] = { + _("Current"), + _("All") + }; + m_PagesOptionEeschema = new wxRadioBox( itemDialog1, ID_PRINT_ALL, _("Page Print:"), wxDefaultPosition, wxDefaultSize, 2, m_PagesOptionEeschemaStrings, 1, wxRA_SPECIFY_COLS ); + m_PagesOptionEeschema->SetSelection(0); + itemBoxSizer12->Add(m_PagesOptionEeschema, 0, wxGROW|wxALL, 5); + + itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer22 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer22, 0, wxALIGN_TOP|wxALL, 5); + + itemBoxSizer22->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxButton* itemButton24 = new wxButton( itemDialog1, ID_PRINT_SETUP, _("Print S&etup"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton24->SetForegroundColour(wxColour(121, 118, 0)); + itemBoxSizer22->Add(itemButton24, 0, wxGROW|wxALL, 5); + + wxButton* itemButton25 = new wxButton( itemDialog1, ID_PRINT_PREVIEW, _("Pre&view"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton25->SetForegroundColour(wxColour(0, 0, 196)); + itemBoxSizer22->Add(itemButton25, 0, wxGROW|wxALL, 5); + + wxButton* itemButton26 = new wxButton( itemDialog1, ID_PRINT_EXECUTE, _("&Print"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton26->SetForegroundColour(wxColour(0, 128, 64)); + itemBoxSizer22->Add(itemButton26, 0, wxGROW|wxALL, 5); + + wxButton* itemButton27 = new wxButton( itemDialog1, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer22->Add(itemButton27, 0, wxGROW|wxALL, 5); + + // Set validators + m_ScaleOption->SetValidator( wxGenericValidator(& s_Scale_Select) ); + m_ButtPenWidth->SetValidator( wxGenericValidator(& PenMinWidth) ); + m_Print_Sheet_Ref->SetValidator( wxGenericValidator(& s_Print_Sheet_Ref) ); + m_Print_Mirror->SetValidator( wxGenericValidator(& s_PrintMirror) ); + m_PagesOptionPcb->SetValidator( wxGenericValidator(& s_OptionPrintPage) ); + m_PagesOptionEeschema->SetValidator( wxGenericValidator(& s_OptionPrintPage) ); +////@end WinEDA_PrintFrame content construction + + SetOthersDatas(); +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_PrintFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_PrintFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_PrintFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_PrintFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_PrintFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_PrintFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_PrintFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PRINT_SETUP + */ + +void WinEDA_PrintFrame::OnPrintSetupClick( wxCommandEvent& event ) +{ + OnPrintSetup(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PRINT_PREVIEW + */ + +void WinEDA_PrintFrame::OnPrintPreviewClick( wxCommandEvent& event ) +{ + OnPrintPreview(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PRINT_EXECUTE + */ + +void WinEDA_PrintFrame::OnPrintExecuteClick( wxCommandEvent& event ) +{ + EDA_PrintPage(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + */ + +void WinEDA_PrintFrame::OnCloseClick( wxCommandEvent& event ) +{ + OnClosePrintDialog(); +} + + +/*! + * wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_PEN_WIDTH + */ + +void WinEDA_PrintFrame::OnPenWidthUpdated( wxSpinEvent& event ) +{ + SetPenWidth(event); +} + + +/*! + * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_SET_PRINT_SCALE + */ + +void WinEDA_PrintFrame::OnSetPrintScaleSelected( wxCommandEvent& event ) +{ + SetScale(event); +} + + +/*! + * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_SET_BW + */ + +void WinEDA_PrintFrame::OnSetBwSelected( wxCommandEvent& event ) +{ + SetColorOrBlack(event); +} + + diff --git a/share/dialog_print.h b/share/dialog_print.h new file mode 100644 index 0000000000..26cf4c8c89 --- /dev/null +++ b/share/dialog_print.h @@ -0,0 +1,160 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_print.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 28/02/2006 18:30:16 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 28/02/2006 18:30:16 + +#ifndef _DIALOG_PRINT_H_ +#define _DIALOG_PRINT_H_ + +/*! + * Includes + */ + +////@begin includes +#include "wx/valgen.h" +#include "wx/spinctrl.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +class wxBoxSizer; +class wxSpinCtrl; +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define ID_SET_PRINT_SCALE 10004 +#define ID_TEXTCTRL 10009 +#define ID_TEXTCTRL1 10010 +#define ID_PEN_WIDTH 10005 +#define ID_PRINT_REF 10006 +#define ID_CHECK_PRINT_MIROR 10011 +#define ID_SET_BW 10007 +#define ID_PRINT_ALL_IN_ONE 10008 +#define ID_PRINT_ALL 10008 +#define ID_PRINT_SETUP 10001 +#define ID_PRINT_PREVIEW 10002 +#define ID_PRINT_EXECUTE 10003 +#define SYMBOL_WINEDA_PRINTFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX +#define SYMBOL_WINEDA_PRINTFRAME_TITLE _("Print") +#define SYMBOL_WINEDA_PRINTFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_PRINTFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_PRINTFRAME_POSITION wxDefaultPosition +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_PrintFrame class declaration + */ + +class WinEDA_PrintFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_PrintFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_PrintFrame( ); + WinEDA_PrintFrame( WinEDA_DrawFrame* parent, wxWindowID id = SYMBOL_WINEDA_PRINTFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PRINTFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PRINTFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PRINTFRAME_SIZE, long style = SYMBOL_WINEDA_PRINTFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PRINTFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PRINTFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PRINTFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PRINTFRAME_SIZE, long style = SYMBOL_WINEDA_PRINTFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_PrintFrame event handler declarations + + /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_SET_PRINT_SCALE + void OnSetPrintScaleSelected( wxCommandEvent& event ); + + /// wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_PEN_WIDTH + void OnPenWidthUpdated( wxSpinEvent& event ); + + /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_SET_BW + void OnSetBwSelected( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PRINT_SETUP + void OnPrintSetupClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PRINT_PREVIEW + void OnPrintPreviewClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PRINT_EXECUTE + void OnPrintExecuteClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + void OnCloseClick( wxCommandEvent& event ); + +////@end WinEDA_PrintFrame event handler declarations + +////@begin WinEDA_PrintFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_PrintFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void OnClosePrintDialog(void); + void OnPrintSetup(wxCommandEvent& event); + void OnPrintPreview(wxCommandEvent& event); + void EDA_PrintPage(wxCommandEvent& event); + void SetPenWidth(wxSpinEvent& event); + void SetColorOrBlack(wxCommandEvent& event); + void SetScale(wxCommandEvent& event); + int SetLayerMaskFromListSelection(void); + wxString BuildPrintTitle(void); + void SetOthersDatas(void); + + +////@begin WinEDA_PrintFrame member variables + wxBoxSizer* m_CopperLayersBoxSizer; + wxBoxSizer* m_TechLayersBoxSizer; + wxRadioBox* m_ScaleOption; + wxStaticText* m_FineAdjustXscaleTitle; + wxTextCtrl* m_FineAdjustXscaleOpt; + wxStaticText* m_FineAdjustYscaleTitle; + wxTextCtrl* m_FineAdjustYscaleOpt; + wxSpinCtrl* m_ButtPenWidth; + wxCheckBox* m_Print_Sheet_Ref; + wxCheckBox* m_Print_Mirror; + wxRadioBox* m_ColorOption; + wxRadioBox* m_PagesOptionPcb; + wxRadioBox* m_PagesOptionEeschema; +////@end WinEDA_PrintFrame member variables + + WinEDA_DrawFrame * m_Parent; + wxRadioBox* m_PagesOption; + wxCheckBox * m_BoxSelecLayer[32]; + double m_XScaleAdjust, m_YScaleAdjust; +}; + +#endif + // _DIALOG_PRINT_H_ diff --git a/share/dialog_print.pjd b/share/dialog_print.pjd new file mode 100644 index 0000000000..7b03c564cc --- /dev/null +++ b/share/dialog_print.pjd @@ -0,0 +1,1472 @@ + + +
+ 0 + "" + "" + "" + "" + 34 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 0 + 4 + " " + "" + 0 + 0 + 1 + 1 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "Print" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "ID_DIALOG" + 10000 + "WinEDA_PrintFrame" + "wxDialog" + "wxDialog" + "dialog_print.cpp" + "dialog_print.h" + "" + "Print" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Horizontal" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbBoxSizerProxy" + "Vertical" + "m_CopperLayersBoxSizer" + "Centre" + "Top" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbBoxSizerProxy" + "Vertical" + "m_TechLayersBoxSizer" + "Centre" + "Top" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxRadioBox: ID_SET_PRINT_SCALE" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbRadioBoxProxy" + "wxEVT_COMMAND_RADIOBOX_SELECTED|OnSetPrintScaleSelected" + "ID_SET_PRINT_SCALE" + 10004 + "wxRadioBox" + "m_ScaleOption" + "Approx. Scale:" + 1 + "fit in page|Scale 0.5|Scale 0.7|Approx. Scale 1|Accurate Scale 1|Scale 1.4|Scale 2|Scale 3|Scale 4" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "s_Scale_Select" + "wxGenericValidator(& %VARIABLE%)" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_FineAdjustXscaleTitle" + "X Scale Adjust" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL" + 10009 + "wxTextCtrl" + "m_FineAdjustXscaleOpt" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_FineAdjustYscaleTitle" + "Y Scale Adjust" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL1" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL1" + 10010 + "wxTextCtrl" + "m_FineAdjustYscaleOpt" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "28/3/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Pen width mini" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxSpinCtrl: ID_PEN_WIDTH" + "dialog-control-document" + "" + "spinctrl" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbSpinCtrlProxy" + "wxEVT_COMMAND_SPINCTRL_UPDATED|OnPenWidthUpdated" + "ID_PEN_WIDTH" + 10005 + "wxSpinCtrl" + "m_ButtPenWidth" + 0 + 100 + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "PenMinWidth" + "wxGenericValidator(& %VARIABLE%)" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "13/1/2007" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + "Options:" + "" + "" + "" + 0 + 1 + "Vertical" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxCheckBox: ID_PRINT_REF" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "13/1/2007" + "wbCheckBoxProxy" + "ID_PRINT_REF" + 10006 + "wxCheckBox" + "m_Print_Sheet_Ref" + "Print Sheet Ref" + 0 + "" + "" + "s_Print_Sheet_Ref" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECK_PRINT_MIROR" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "13/1/2007" + "wbCheckBoxProxy" + "ID_CHECK_PRINT_MIROR" + 10011 + "wxCheckBox" + "m_Print_Mirror" + "Mirror" + 0 + "" + "" + "s_PrintMirror" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxRadioBox: ID_SET_BW" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbRadioBoxProxy" + "wxEVT_COMMAND_RADIOBOX_SELECTED|OnSetBwSelected" + "ID_SET_BW" + 10007 + "wxRadioBox" + "m_ColorOption" + "Color Print:" + 1 + "Color|Black" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxRadioBox: ID_PRINT_ALL_IN_ONE" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbRadioBoxProxy" + "ID_PRINT_ALL_IN_ONE" + 10008 + "wxRadioBox" + "m_PagesOptionPcb" + "Page Print:" + 1 + "1 page per layer|Single Page" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "s_OptionPrintPage" + "wxGenericValidator(& %VARIABLE%)" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxRadioBox: ID_PRINT_ALL" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbRadioBoxProxy" + "ID_PRINT_ALL" + 10008 + "wxRadioBox" + "m_PagesOptionEeschema" + "Page Print:" + 1 + "Current|All" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "s_OptionPrintPage" + "wxGenericValidator(& %VARIABLE%)" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "28/3/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Top" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "28/3/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxButton: ID_PRINT_SETUP" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnPrintSetupClick" + "ID_PRINT_SETUP" + 10001 + "wxButton" + "" + "Print S&etup" + 0 + "" + "" + "" + "797600" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: ID_PRINT_PREVIEW" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnPrintPreviewClick" + "ID_PRINT_PREVIEW" + 10002 + "wxButton" + "" + "Pre&view" + 0 + "" + "" + "" + "0000C4" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: ID_PRINT_EXECUTE" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnPrintExecuteClick" + "ID_PRINT_EXECUTE" + 10003 + "wxButton" + "" + "&Print" + 0 + "" + "" + "" + "008040" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_CLOSE" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "28/12/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCloseClick" + "wxID_CLOSE" + 5001 + "wxButton" + "" + "&Close" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "dialog_print.rc" + "source-editor-document" + "dialog_print.rc" + "source-editor" + 0 + 0 + 1 + 0 + "28/12/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/share/drawframe.cpp b/share/drawframe.cpp new file mode 100644 index 0000000000..1eac6cbd96 --- /dev/null +++ b/share/drawframe.cpp @@ -0,0 +1,826 @@ + /******************************************************************/ + /* drawframe.cpp - fonctions des classes du type WinEDA_DrawFrame */ + /******************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" + +#include "common.h" + +#ifdef PCBNEW +#include "pcbnew.h" +#endif + +#ifdef EESCHEMA +#include "program.h" +#include "libcmp.h" +#include "general.h" +#endif + +#ifdef CVPCB +#include "pcbnew.h" +#include "cvpcb.h" +#endif + +#include + +#include "bitmaps.h" + +#include "protos.h" + +#include "id.h" + + + /*******************************************************/ + /* Constructeur de WinEDA_DrawFrame: la fenetre generale */ + /*******************************************************/ + +WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow * father, int idtype, + WinEDA_App *parent, const wxString & title, + const wxPoint& pos, const wxSize& size): + WinEDA_BasicFrame(father, idtype, parent, title, pos, size) +{ +wxSize minsize; + + m_VToolBar = NULL; + m_AuxVToolBar = NULL; + m_OptionsToolBar = NULL; + m_AuxiliaryToolBar = NULL; + m_SelGridBox = NULL; + m_SelZoomBox = NULL; + m_ZoomMaxValue = 128; + + DrawPanel = NULL; + MsgPanel = NULL; + m_CurrentScreen = NULL; + m_MenuBar = NULL; // menu du haut d'ecran + m_ID_current_state = 0; + m_HTOOL_current_state = 0; + m_FrameIsActive = FALSE; + m_Draw_Axis = FALSE; // TRUE pour avoir les axes dessines + m_Draw_Grid = FALSE; // TRUE pour avoir la axes dessinee + m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessiné + m_Print_Sheet_Ref = TRUE; // TRUE pour avoir le cartouche imprimé + m_Draw_Auxiliary_Axis = FALSE; // TRUE pour avoir les axes auxiliares dessines + m_UnitType = INTERNAL_UNIT_TYPE; // Internal unit = inch + // nombre d'unites internes pour 1 pouce + // = 1000 pour schema, = 10000 pour PCB + m_InternalUnits = EESCHEMA_INTERNAL_UNIT; + if( (m_Ident == PCB_FRAME) || (m_Ident == GERBER_FRAME) || + (m_Ident == CVPCB_DISPLAY_FRAME) || + (m_Ident == MODULE_EDITOR_FRAME) + ) + m_InternalUnits = PCB_INTERNAL_UNIT ; + + minsize.x = 470; + minsize.y = 350 + m_MsgFrameHeight; + SetSizeHints( minsize.x, minsize.y, -1,-1, -1,-1); + + /* Verification des parametres de creation */ + if ( (size.x < minsize.x) || (size.y < minsize.y) ) + SetSize(0,0, minsize.x, minsize.y); + + // Creation de la ligne de status +int dims[6] = { -1, 60, 130, 130, 40, 100}; + CreateStatusBar(6); + SetStatusWidths(6,dims); + + // Create child subwindows. + GetClientSize(&m_FrameSize.x, &m_FrameSize.y); /* dimx, dimy = dimensions utiles de la + zone utilisateur de la fenetre principale */ + m_FramePos.x = m_FramePos.y = 0; + m_FrameSize.y -= m_MsgFrameHeight; + + if ( m_Ident != DISPLAY3D_FRAME) + { + DrawPanel = new WinEDA_DrawPanel(this, -1, wxPoint(0, 0), m_FrameSize); + MsgPanel = new WinEDA_MsgPanel(this, -1, wxPoint(0, m_FrameSize.y), + wxSize(m_FrameSize.x, m_MsgFrameHeight)); + MsgPanel->SetBackgroundColour(wxColour(ColorRefs[LIGHTGRAY].m_Red, + ColorRefs[LIGHTGRAY].m_Green, + ColorRefs[LIGHTGRAY].m_Blue )); + } + +} + +/****************************************/ +WinEDA_DrawFrame::~WinEDA_DrawFrame(void) +/****************************************/ +{ + if ( DrawPanel ) // for WinEDA3D_DrawFrame DrawPanel == NULL ! + m_Parent->m_EDA_Config->Write( wxT("AutoPAN"), DrawPanel->m_AutoPAN_Enable); +} + + +/****************************************************************/ +void WinEDA_DrawFrame::AddFontSelectionMenu(wxMenu * main_menu) +/*****************************************************************/ +/* create the submenu for fonte selection and setup fonte size +*/ +{ +wxMenu * fontmenu = new wxMenu(); + ADD_MENUITEM(fontmenu, ID_PREFERENCES_FONT_DIALOG, _("font for dialog boxes"), + fonts_xpm ); + ADD_MENUITEM(fontmenu, ID_PREFERENCES_FONT_INFOSCREEN, _("font for info display"), + fonts_xpm ); + ADD_MENUITEM(fontmenu, ID_PREFERENCES_FONT_STATUS, _("font for Status Line"), + fonts_xpm ); + ADD_MENUITEM_WITH_HELP_AND_SUBMENU(main_menu, fontmenu, + ID_PREFERENCES_FONT, _("&Font selection"), + _("Choose font type and size for dialogs, infos and status box"), + fonts_xpm); +} + +/********************************************************************/ +void WinEDA_DrawFrame::ProcessFontPreferences(wxCommandEvent& event) +/********************************************************************/ +{ +int id = event.GetId(); +wxFont font; + + switch (id) + { + + case ID_PREFERENCES_FONT: + case ID_PREFERENCES_FONT_DIALOG: + case ID_PREFERENCES_FONT_STATUS: + WinEDA_BasicFrame::ProcessFontPreferences(id); + break; + + + case ID_PREFERENCES_FONT_INFOSCREEN: + { + font = wxGetFontFromUser(this, *g_MsgFont); + if ( font.Ok() ) + { + int pointsize = font.GetPointSize(); + *g_MsgFont = font; + g_MsgFontPointSize = pointsize; + } + break; + } + default: DisplayError(this, wxT("WinEDA_DrawFrame::ProcessFontPreferences Internal Error") ); + break; + } +} + +/**************************************************************/ +void WinEDA_DrawFrame::Affiche_Message(const wxString & message) +/**************************************************************/ +/* + Affiche un message en bas de l'ecran +*/ +{ + SetStatusText(message); +} + +/****************************************/ +void WinEDA_DrawFrame::EraseMsgBox(void) +/****************************************/ +{ + if ( MsgPanel ) MsgPanel->EraseMsgBox(); +} + + +/*******************************************************/ +void WinEDA_DrawFrame::OnActivate(wxActivateEvent& event) +/*******************************************************/ +{ + m_FrameIsActive = event.GetActive(); + if ( DrawPanel ) + DrawPanel->m_CanStartBlock = -1; + + event.Skip(); // required under wxMAC +} + + +/****************************************************/ +void WinEDA_DrawFrame::OnMenuOpen(wxMenuEvent& event) +/****************************************************/ +{ + if ( DrawPanel ) DrawPanel->m_CanStartBlock = -1; + event.Skip(); +} + + +/*******************************************************/ +void WinEDA_DrawFrame::ReCreateAuxiliaryToolbar(void) // fonction virtuelle +/*******************************************************/ +{ +} + +/********************************************/ +void WinEDA_DrawFrame::ReCreateMenuBar(void) // fonction virtuelle +/********************************************/ +{ +} + +/****************************************************/ +void WinEDA_DrawFrame::OnHotKey(wxDC * DC, int hotkey, + EDA_BaseStruct * DrawStruct) // fonction virtuelle +/****************************************************/ +{ +} + + + +/**************************************************************/ +void WinEDA_DrawFrame::ToolOnRightClick(wxCommandEvent & event) // fonction virtuelle +/**************************************************************/ +{ +} + +/********************************************************/ +void WinEDA_DrawFrame::OnSelectGrid(wxCommandEvent& event) // fonction virtuelle +/********************************************************/ +{ + if ( m_SelGridBox == NULL ) return; //Ne devrait pas se produire! + +int id = m_SelGridBox->GetChoice(); + if ( id < 0 ) return; + + m_CurrentScreen->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); +wxSize grid = m_CurrentScreen->GetGrid(); + m_CurrentScreen->SetGrid(g_GridList[id]); +wxSize newgrid = m_CurrentScreen->GetGrid(); + if ( newgrid.x != grid.x || newgrid.y != grid.y ) + Recadre_Trace(FALSE); +} + + +#ifndef EESCHEMA +/**************************************************************/ +void WinEDA_DrawFrame::GeneralControle(wxDC *DC, wxPoint Mouse) +/**************************************************************/ +/* Fonction virtuelle + traitement des touches de fonctions utilisees ds tous les menus + Zoom + Redessin d'ecran + Cht Unites + Cht couches + Remise a 0 de l'origine des coordonnees relatives +*/ +{ +} +#endif + + +/********************************************************/ +void WinEDA_DrawFrame::OnSelectZoom(wxCommandEvent& event) // fonction virtuelle +/********************************************************/ +/* Set the zoom when selected by the Zoom List Box + Note: + position 0 = Fit in Page + position >= 1 = zoom (1 to zoom max) + last position : special zoom +*/ +{ + if ( m_SelZoomBox == NULL ) return; //Ne devrait pas se produire! + +int id = m_SelZoomBox->GetChoice(); + + if ( id < 0 ) return; // No selection + + if ( id == 0 ) // Auto zoom (Fit in Page) + { + Zoom_Automatique(TRUE); + } + else if ( id == (int)(m_SelZoomBox->GetCount()-1) ) // Dummy position: unlisted zoom + return ; + else // zooml 1 to zoom max + { + id --; + int zoom = 1 << id; + if ( zoom > m_ZoomMaxValue ) zoom = m_ZoomMaxValue; + if ( m_CurrentScreen->GetZoom() == zoom) return; + m_CurrentScreen->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); + m_CurrentScreen->SetZoom(zoom); + Recadre_Trace(FALSE); + } +} + +/********************************************************/ +void WinEDA_DrawFrame::OnMouseEvent(wxMouseEvent& event) +/********************************************************/ +{ + event.Skip(); +} + + + + +/***********************************************************************/ +// Virtuelle +void WinEDA_DrawFrame::OnLeftDClick(wxDC * DC, const wxPoint& MousePos) +/***********************************************************************/ +{ +} + +/***************************************/ +void WinEDA_DrawFrame::SetToolbars(void) +/***************************************/ +{ + DisplayUnitsMsg(); +} + +/********************************************************/ +void WinEDA_DrawFrame::DisplayToolMsg(const wxString msg) +/********************************************************/ +{ + SetStatusText(msg, 5); +} + +/*******************************************/ +void WinEDA_DrawFrame::DisplayUnitsMsg(void) +/********************************************/ +/* Display current unit Selection on Statusbar +*/ +{ +wxString msg; + + switch ( g_UnitMetric ) + { + case INCHES: + msg = _("Inch"); + break; + case MILLIMETRE: + msg += _("mm"); + break; + default: + msg += _("??"); + break; + } + + SetStatusText(msg, 4); +} + +/***************************************/ +void WinEDA_DrawFrame::ReDrawPanel(void) +/***************************************/ +{ + if ( DrawPanel == NULL ) return; +wxClientDC dc(DrawPanel); + + DrawPanel->PrepareGraphicContext(&dc); + DrawPanel->ReDraw(&dc); +} + +/**************************************************/ +void WinEDA_DrawFrame::OnSize(wxSizeEvent & SizeEv) +/**************************************************/ +/* recalcule les dimensions des toolbars et du panel d'affichage +*/ +{ +wxSize size; +wxSize opt_size; +wxSize Vtoolbar_size; +wxSize Auxtoolbar_size; + + GetClientSize(&size.x, &size.y); + m_FrameSize = size; + size.y -= m_MsgFrameHeight; + + if ( MsgPanel ) // Positionnement en bas d'ecran + { + MsgPanel->SetSize(0, size.y, size.x, m_MsgFrameHeight); + } + + if( m_AuxiliaryToolBar ) // est sous le m_HToolBar + { + Auxtoolbar_size.x = size.x; // = Largeur de la frame + Auxtoolbar_size.y = m_AuxiliaryToolBar->GetSize().y; + m_AuxiliaryToolBar->SetSize(Auxtoolbar_size); + m_AuxiliaryToolBar->Move(0, 0); + size.y -= Auxtoolbar_size.y; + } + + if( m_VToolBar ) // Toolbar de droite: hauteur = hauteur utile de la frame-Auxtoolbar + { + Vtoolbar_size.x = m_VToolBar->GetSize().x; + Vtoolbar_size.y = size.y; + m_VToolBar->SetSize( Vtoolbar_size); + m_VToolBar->Move(size.x - Vtoolbar_size.x, Auxtoolbar_size.y); + m_VToolBar->Refresh(); + } + + if( m_AuxVToolBar ) // auxiliary vertical right toolbar, showing tools fo microwave applications + { + Vtoolbar_size.x += m_AuxVToolBar->GetSize().x; + Vtoolbar_size.y = size.y; + m_AuxVToolBar->SetSize( m_AuxVToolBar->GetSize().x, Vtoolbar_size.y); + m_AuxVToolBar->Move(size.x - Vtoolbar_size.x, Auxtoolbar_size.y); + m_AuxVToolBar->Refresh(); + } + if( m_OptionsToolBar ) + { + if ( m_OptionsToolBar->m_Horizontal) + { + opt_size.x = 0; + opt_size.y = m_OptionsToolBar->GetSize().y; + m_OptionsToolBar->SetSize(Auxtoolbar_size.x, 0, size.x, opt_size.y); + } + else + { + opt_size.x = m_OptionsToolBar->GetSize().x; + opt_size.y = 0; + m_OptionsToolBar->SetSize(0, Auxtoolbar_size.y, opt_size.x, size.y); + } + } + + if ( DrawPanel ) + { + DrawPanel->SetSize( size.x - Vtoolbar_size.x - opt_size.x, size.y - opt_size.y - 1); + DrawPanel->Move(opt_size.x, opt_size.y + Auxtoolbar_size.y + 1); + } + + SizeEv.Skip(); +} + +/*************************************************************************/ +void WinEDA_DrawFrame::SetToolID(int id, int new_cursor_id, + const wxString & title) +/*************************************************************************/ +/* +Active l'icone de l'outil selectionne dans le toolbar Vertical +( ou l'outil par defaut ID_NO_SELECT_BUTT si pas de nouvelle selection ) +if ( id >= 0 ) + Met a jour toutes les variables associees: + message, m_ID_current_state, curseur +si ( id < 0 ) + Met a jour seulement les variables message et curseur +*/ +{ + // Change Cursor + if (DrawPanel ) + { + DrawPanel->m_PanelDefaultCursor = new_cursor_id; + DrawPanel->SetCursor( new_cursor_id ); + } + SetCursor( wxCURSOR_ARROW ); + DisplayToolMsg(title); + + if ( id < 0 ) return; + + // Old Tool Inactif ou ID_NO_SELECT_BUTT actif si pas de nouveau Tool + if ( m_ID_current_state ) + { + if ( m_VToolBar ) m_VToolBar->ToggleTool(m_ID_current_state, FALSE); + if ( m_AuxVToolBar ) m_AuxVToolBar->ToggleTool(m_ID_current_state, FALSE); + } + else + { + if ( id ) + { + if ( m_VToolBar ) m_VToolBar->ToggleTool(ID_NO_SELECT_BUTT, FALSE); + if ( m_AuxVToolBar ) m_AuxVToolBar->ToggleTool(m_ID_current_state, FALSE); + } + else if ( m_VToolBar ) m_VToolBar->ToggleTool(ID_NO_SELECT_BUTT, TRUE); + } + + // New Tool Actif + if ( id ) + { + if ( m_VToolBar ) m_VToolBar->ToggleTool(id, TRUE); + if ( m_AuxVToolBar ) m_AuxVToolBar->ToggleTool(id, TRUE); + } + else if ( m_VToolBar ) m_VToolBar->ToggleTool(ID_NO_SELECT_BUTT, TRUE); + + m_ID_current_state = id; +} + + +/********************************************/ +void WinEDA_DrawFrame::OnZoom(int zoom_type) +/********************************************/ + +/* Fonction de traitement du zoom + Modifie le facteur de zoom et reaffiche l'ecran + Pour les commandes par menu Popup ou par le clavier, le curseur est + replacé au centre de l'ecran +*/ +{ + if ( DrawPanel == NULL ) return; + +bool move_mouse_cursor = FALSE; +int x,y; +wxPoint old_pos; + + DrawPanel->GetViewStart( &x, &y ); + old_pos = m_CurrentScreen->m_Curseur; + + switch (zoom_type) + { + case ID_POPUP_ZOOM_PLUS: + case ID_ZOOM_PLUS_KEY: + move_mouse_cursor = TRUE; + case ID_ZOOM_PLUS_BUTT: + if ( zoom_type == ID_ZOOM_PLUS_BUTT) + m_CurrentScreen->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); + m_CurrentScreen->SetPreviousZoom(); + Recadre_Trace(move_mouse_cursor); + break; + + case ID_POPUP_ZOOM_MOINS: + case ID_ZOOM_MOINS_KEY: + move_mouse_cursor = TRUE; + case ID_ZOOM_MOINS_BUTT: + if ( zoom_type == ID_ZOOM_MOINS_BUTT) + m_CurrentScreen->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); + m_CurrentScreen->SetNextZoom(); + Recadre_Trace(move_mouse_cursor); + break; + + case ID_POPUP_ZOOM_REDRAW: + case ID_ZOOM_REDRAW_KEY: + case ID_ZOOM_REDRAW_BUTT: + ReDrawPanel(); + break; + + case ID_POPUP_ZOOM_CENTER: + case ID_ZOOM_CENTER_KEY: + Recadre_Trace(TRUE); + break; + + case ID_ZOOM_PAGE_BUTT: + case ID_ZOOM_AUTO: + case ID_POPUP_ZOOM_AUTO: + Zoom_Automatique(FALSE); + break; + + case ID_ZOOM_PANNING_UP: + OnPanning(ID_ZOOM_PANNING_UP); + break; + + case ID_ZOOM_PANNING_DOWN: + OnPanning(ID_ZOOM_PANNING_DOWN); + break; + + case ID_ZOOM_PANNING_LEFT: + OnPanning(ID_ZOOM_PANNING_LEFT); + DrawPanel->CursorOn(NULL); + break; + + case ID_ZOOM_PANNING_RIGHT: + OnPanning(ID_ZOOM_PANNING_RIGHT); + break; + + + default: wxMessageBox( wxT("WinEDA_DrawFrame::OnZoom switch Error") ); + break; + } + Affiche_Status_Box(); +} + +/**********************************************/ +void WinEDA_DrawFrame::OnPanning(int direction) +/**********************************************/ + +/* Fonction de traitement du zoom + Modifie le facteur de zoom et reaffiche l'ecran + Pour les commandes par menu Popup ou par le clavier, le curseur est + replacé au centre de l'ecran +*/ +{ + if ( DrawPanel == NULL ) return; + +int delta; +wxClientDC dc(DrawPanel); +int x,y; + + + DrawPanel->PrepareGraphicContext(&dc); + DrawPanel->GetViewStart( &x, &y ); // x and y are in scroll unit, not in pixels + delta = DrawPanel->m_ScrollButt_unit; + switch (direction) + { + case ID_ZOOM_PANNING_UP: + y -= delta; + break; + + case ID_ZOOM_PANNING_DOWN: + y += delta; + break; + + case ID_ZOOM_PANNING_LEFT: + x -= delta; + break; + + case ID_ZOOM_PANNING_RIGHT: + x += delta; + break; + + default: wxMessageBox( wxT("WinEDA_DrawFrame::OnPanning Error") ); + break; + } + + DrawPanel->Scroll(x, y); + + /* Place le curseur souris sur le curseur SCHEMA*/ + DrawPanel->MouseToCursorSchema(); +} + + + /*****************************/ + /* default virtual fonctions */ + /*****************************/ + +void WinEDA_DrawFrame::OnGrid(int grid_type) +{ +} + +int WinEDA_DrawFrame::ReturnBlockCommand(int key) +{ + return 0; +} + +void WinEDA_DrawFrame::InitBlockPasteInfos() +{ + GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; + DrawPanel->ManageCurseur = NULL; +} + +void WinEDA_DrawFrame::HandleBlockPlace(wxDC * DC) +{ +} + +int WinEDA_DrawFrame::HandleBlockEnd(wxDC * DC) +{ + return 0; +} + + + + +/*********************************************/ +void WinEDA_DrawFrame::AdjustScrollBars(void) +/*********************************************/ +{ +wxSize draw_size, panel_size; +wxSize scrollbar_number; +wxPoint scrollbar_pos; +int zoom = m_CurrentScreen->GetZoom(); +int xUnit, yUnit; + + if ( m_CurrentScreen == NULL) return; + if ( DrawPanel == NULL ) return; + + draw_size = m_CurrentScreen->ReturnPageSize(); + + // La zone d'affichage est reglee a une taille double de la feuille de travail: + draw_size.x *= 2; draw_size.y *= 2; + + // On utilise le centre de l'ecran comme position de reference, donc + // la surface de trace doit etre augmentee + panel_size = DrawPanel->GetClientSize(); + panel_size.x *= zoom; panel_size.y *= zoom; + draw_size.x += panel_size.x/2; + draw_size.y += panel_size.y/2; + + + if ( m_CurrentScreen->m_Center ) + { + m_CurrentScreen->m_DrawOrg.x = - draw_size.x/2; + m_CurrentScreen->m_DrawOrg.y = - draw_size.y/2; + } + else + { + m_CurrentScreen->m_DrawOrg.x = - panel_size.x/2; + m_CurrentScreen->m_DrawOrg.y = - panel_size.y/2; + } + + // DrawOrg est rendu multiple du zoom min : + m_CurrentScreen->m_DrawOrg.x -= m_CurrentScreen->m_DrawOrg.x % 256; + m_CurrentScreen->m_DrawOrg.y -= m_CurrentScreen->m_DrawOrg.y % 256; + + // Calcul du nombre de scrolls (en unites de scrool ) + scrollbar_number.x = draw_size.x / (DrawPanel->m_Scroll_unit*zoom); + scrollbar_number.y = draw_size.y / (DrawPanel->m_Scroll_unit*zoom); + + xUnit = yUnit = DrawPanel->m_Scroll_unit; + + if (xUnit <= 1 ) xUnit = 1; + if (yUnit <= 1 ) yUnit = 1; + xUnit *= zoom; yUnit *= zoom; + + // Calcul de la position, curseur place au centre d'ecran + scrollbar_pos = m_CurrentScreen->m_Curseur; + + scrollbar_pos.x -= m_CurrentScreen->m_DrawOrg.x; + scrollbar_pos.y -= m_CurrentScreen->m_DrawOrg.y; + + scrollbar_pos.x -= panel_size.x /2; + scrollbar_pos.y -= panel_size.y /2; + + if ( scrollbar_pos.x < 0 ) scrollbar_pos.x = 0; + if ( scrollbar_pos.y < 0 ) scrollbar_pos.y = 0; + + scrollbar_pos.x /= xUnit; + scrollbar_pos.y /= yUnit; + m_CurrentScreen->m_ScrollbarPos = scrollbar_pos; + m_CurrentScreen->m_ScrollbarNumber = scrollbar_number; + + DrawPanel->SetScrollbars( DrawPanel->m_Scroll_unit, + DrawPanel->m_Scroll_unit, + m_CurrentScreen->m_ScrollbarNumber.x, + m_CurrentScreen->m_ScrollbarNumber.y, + m_CurrentScreen->m_ScrollbarPos.x, + m_CurrentScreen->m_ScrollbarPos.y, TRUE); + +} + + + +/****************************************************/ +void WinEDA_DrawFrame::SetDrawBgColor(int color_num) +/****************************************************/ +/* met a jour la couleur de fond pour les tracés + seules les couleurs BLACK ou WHITE sont autorisées + le parametre XorMode est mis a jour selon la couleur du fond +*/ +{ + if ( (color_num != WHITE) && (color_num != BLACK) ) color_num = BLACK; + g_DrawBgColor = color_num; + if(color_num == WHITE) + { + g_XorMode = GR_NXOR; + g_GhostColor = BLACK; + } + else + { + g_XorMode = GR_XOR; + g_GhostColor = WHITE; + } + + if ( DrawPanel ) + DrawPanel-> SetBackgroundColour(wxColour(ColorRefs[g_DrawBgColor].m_Red, + ColorRefs[g_DrawBgColor].m_Green, + ColorRefs[g_DrawBgColor].m_Blue )); + +} + + +/********************************************************/ +void WinEDA_DrawFrame::SetLanguage(wxCommandEvent& event) +/********************************************************/ +{ +int id = event.GetId(); + + m_Parent->SetLanguageIdentifier(id ); + m_Parent->SetLanguage(); +} + + +/***********************************************/ +void WinEDA_DrawFrame::Affiche_Status_Box(void) +/***********************************************/ +/* Routine d'affichage du zoom et des coord curseur. +*/ +{ +wxString Line; +int dx, dy; + + if (GetScreen() == NULL ) return; + + /* affichage Zoom et coordonnees absolues */ + Line.Printf(wxT("Z %d"), GetScreen()->GetZoom()); + SetStatusText(Line, 1); + + Line.Printf( g_UnitMetric ? wxT("X %.3f Y %.3f") : wxT("X %.4f Y %.4f"), + To_User_Unit(g_UnitMetric, GetScreen()->m_Curseur.x, + m_InternalUnits), + To_User_Unit(g_UnitMetric, GetScreen()->m_Curseur.y, + m_InternalUnits)); + SetStatusText(Line, 2); + + /* affichage des coordonnees relatives */ + dx = GetScreen()->m_Curseur.x - GetScreen()->m_O_Curseur.x; + dy = GetScreen()->m_Curseur.y - GetScreen()->m_O_Curseur.y; + + Line.Printf( g_UnitMetric ? wxT("x %.3f y %.3f") : wxT("x %.4f y %.4f"), + To_User_Unit(g_UnitMetric, dx, m_InternalUnits), + To_User_Unit(g_UnitMetric, dy, m_InternalUnits) ); + + SetStatusText(Line, 3); + +#ifdef PCBNEW + if ( DisplayOpt.DisplayPolarCood ) /* Display coordonnee polaire */ + { + double theta, ro; + if ( (dx == 0) && (dy == 0) ) theta = 0.0; + else theta = atan2( (double) - dy , (double) dx ); + theta = theta *180 / M_PI; + + ro = sqrt( ((double) dx * dx) + ((double)dy * dy) ); + Line.Printf( g_UnitMetric ? wxT("Ro %.3f Th %.1f") : wxT("Ro %.4f Th %.1f"), + To_User_Unit(g_UnitMetric, (int) round(ro), m_InternalUnits), + theta) ; + SetStatusText(Line, 0); + } +#endif +} + + + diff --git a/share/drawpanel.cpp b/share/drawpanel.cpp new file mode 100644 index 0000000000..497293b6d9 --- /dev/null +++ b/share/drawpanel.cpp @@ -0,0 +1,933 @@ + /******************************************************************/ + /* drawpanel.cpp - fonctions des classes du type WinEDA_DrawPanel */ + /******************************************************************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "fctsys.h" +#include "common.h" + +#include "macros.h" +#include "id.h" + +/* defines locaux */ +#define CURSOR_SIZE 12 /* taille de la croix du curseur PCB */ + +/* Variables locales */ + +/* table des evenements captes par un WinEDA_DrawPanel */ +BEGIN_EVENT_TABLE(WinEDA_DrawPanel, EDA_DRAW_PANEL) + EVT_LEAVE_WINDOW(WinEDA_DrawPanel::OnMouseLeaving) + EVT_MOUSE_EVENTS(WinEDA_DrawPanel::OnMouseEvent) + EVT_CHAR(WinEDA_DrawPanel::OnKeyEvent) + EVT_CHAR_HOOK(WinEDA_DrawPanel::OnKeyEvent) + EVT_PAINT(WinEDA_DrawPanel::OnPaint) + EVT_SIZE(WinEDA_DrawPanel::OnSize) + EVT_ERASE_BACKGROUND(WinEDA_DrawPanel::OnEraseBackground) + EVT_SCROLLWIN(WinEDA_DrawPanel::OnScroll) + EVT_ACTIVATE(WinEDA_DrawPanel::OnActivate) + + EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE, + WinEDA_DrawPanel::Process_Popup_Zoom) + +END_EVENT_TABLE() + + + + + /***********************************************************/ + /* Fonctions de base de WinEDA_DrawPanel: l'ecran de trace */ + /***********************************************************/ + +WinEDA_DrawPanel::WinEDA_DrawPanel(WinEDA_DrawFrame *parent, int id, + const wxPoint& pos, const wxSize& size): + EDA_DRAW_PANEL(parent, id, pos, size, + wxBORDER|wxNO_FULL_REPAINT_ON_RESIZE) +{ + m_Parent = parent; + m_Ident = m_Parent->m_Ident; + m_Scroll_unit = 1; + m_ScrollButt_unit = 40; + SetBackgroundColour(wxColour(ColorRefs[g_DrawBgColor].m_Red, + ColorRefs[g_DrawBgColor].m_Green, + ColorRefs[g_DrawBgColor].m_Blue ) ); + EnableScrolling(TRUE,TRUE); + m_ClipBox.SetSize(size); + m_ClipBox.SetX(0); + m_ClipBox.SetY(0); + m_CanStartBlock = -1; // Command block can start if >= 0 + m_AbortEnable = m_AbortRequest = FALSE; + m_AutoPAN_Enable = TRUE; + m_IgnoreMouseEvents = FALSE; + + ManageCurseur = NULL; + ForceCloseManageCurseur = NULL; + + if ( m_Parent->m_Parent->m_EDA_Config ) + m_AutoPAN_Enable = m_Parent->m_Parent->m_EDA_Config->Read(wxT("AutoPAN"), TRUE); + m_AutoPAN_Request = FALSE; + m_Block_Enable = FALSE; + m_PanelDefaultCursor = m_PanelCursor = wxCURSOR_ARROW; + m_CursorLevel = 0; +} + +/*********************************************************************************/ +void WinEDA_DrawPanel::Trace_Curseur(wxDC * DC, int color) +/*********************************************************************************/ +/* + Trace Le curseur sur la zone PCB , se deplacant sur la grille +*/ +{ + if (m_CursorLevel != 0) { + return; + } + +wxPoint Cursor = GetScreen()->m_Curseur; + + if ( DC == NULL ) return; + + GRSetDrawMode(DC, GR_XOR); + if( g_CursorShape == 1 ) /* Trace d'un reticule */ + { + int dx = m_ClipBox.GetWidth() * GetZoom(); + int dy = m_ClipBox.GetHeight() * GetZoom(); + GRLine(&m_ClipBox, DC, Cursor.x - dx, Cursor.y, + Cursor.x + dx, Cursor.y, color); // axe Y + GRLine(&m_ClipBox, DC, Cursor.x, Cursor.y - dx, + Cursor.x, Cursor.y + dy, color); // axe X + } + + else + { + int len = CURSOR_SIZE * GetZoom(); + GRLine(&m_ClipBox, DC, Cursor.x - len, Cursor.y, + Cursor.x + len, Cursor.y, color); + GRLine(&m_ClipBox, DC, Cursor.x, Cursor.y - len, + Cursor.x, Cursor.y + len, color); + } +} + +/*******************************************************************/ +void WinEDA_DrawPanel::CursorOff(wxDC * DC) +/*******************************************************************/ +/* + Remove the grid cursor from the display in preparation for other drawing operations +*/ +{ + Trace_Curseur(DC); + --m_CursorLevel; +} + +/*******************************************************************/ +void WinEDA_DrawPanel::CursorOn(wxDC * DC) +/*******************************************************************/ +/* + Display the grid cursor +*/ +{ + ++m_CursorLevel; + Trace_Curseur(DC); + + if (m_CursorLevel > 0) // Shouldn't happen, but just in case .. + m_CursorLevel = 0; +} + + +/***********************************/ +int WinEDA_DrawPanel::GetZoom(void) +/***********************************/ +{ + return GetScreen()->GetZoom(); +} + +/***************************************/ +void WinEDA_DrawPanel::SetZoom(int zoom) +/***************************************/ +{ + GetScreen()->SetZoom(zoom); +} + +/************************************/ +wxSize WinEDA_DrawPanel::GetGrid(void) +/************************************/ +{ + return GetScreen()->GetGrid(); +} + + +/******************************************************/ +void WinEDA_DrawPanel::PrepareGraphicContext(wxDC * DC) +/******************************************************/ +{ + DC->SetPen(*DrawPen); + DC->SetBrush(*DrawBrush); + GRResetPenAndBrush(DC); + DC->SetBackgroundMode(wxTRANSPARENT); +#ifdef WX_ZOOM +int zoom = GetZoom(); +double f_scale = 1.0/(double)zoom; + + DC->SetUserScale(f_scale, f_scale); + PrepareDC(*DC); +#endif + SetBoundaryBox(); +} + + +/*********************************************************************/ +wxPoint WinEDA_DrawPanel::CalcAbsolutePosition(const wxPoint & rel_pos) +/*********************************************************************/ +/* retourne la position absolue en pixels de la position rel_pos, +donnée en position relative scrollée (en pixel) +*/ +{ +wxPoint pos; + +#ifdef WX_ZOOM + CalcUnscrolledPosition( rel_pos.x, rel_pos.y, &pos.x, &pos.y ); +#else +int ii, jj; + GetViewStart(&pos.x, &pos.y); + GetScrollPixelsPerUnit(&ii, &jj); + pos.x *= ii; pos.y *= jj; + pos.x += rel_pos.x; + pos.y += rel_pos.y; +#endif + return pos; +} + + +/**********************************************************************/ +wxPoint WinEDA_DrawPanel::CursorRealPosition(const wxPoint & ScreenPos) +/**********************************************************************/ +/* Retourne la position en unites utilisateur du pointeur souris + ScreenPos = position pointeur en coord absolue ecran +*/ +{ +wxPoint curpos; + + curpos.x = ScreenPos.x * GetZoom(); + curpos.y = ScreenPos.y * GetZoom(); + + curpos.x += GetScreen()->m_DrawOrg.x; + curpos.y += GetScreen()->m_DrawOrg.y; + + return curpos; +} + +/********************************************************/ +bool WinEDA_DrawPanel::IsPointOnDisplay(wxPoint ref_pos) +/********************************************************/ +/* retourne TRUE si le point de coord physique ref_pos + est visible sur l'ecran, c'est a dire: + si ref_pos est sur la partie du schema ou pcb affichee a l'ecran +*/ +{ +wxPoint pos; +EDA_Rect display_rect; + + SetBoundaryBox(); + display_rect = m_ClipBox; + + // Reduction legere des dimension de l'ecran utile pour eviter cadrage + // en limite d'ecran + #define PIXEL_MARGIN 8 + display_rect.Inflate(-PIXEL_MARGIN,-PIXEL_MARGIN); + + // Conversion en coord physiques + pos = CalcAbsolutePosition( display_rect.GetPosition() ); + pos.x *= GetZoom(); + pos.y *= GetZoom(); + pos.x += GetScreen()->m_DrawOrg.x; + pos.y += GetScreen()->m_DrawOrg.y; + display_rect.SetX(pos.x); display_rect.SetY(pos.y); + display_rect.SetWidth( display_rect.GetWidth() * GetZoom() ); + display_rect.SetHeight( display_rect.GetHeight() * GetZoom() ); + + return display_rect.Inside(ref_pos); +} + + +/********************************************************/ +wxPoint WinEDA_DrawPanel::CursorScreenPosition(void) +/********************************************************/ +/* retourne la position sur l'ecran,en pixels, du curseur + Orgine = coord absolue 0,0; +*/ +{ +wxPoint curpos = GetScreen()->m_Curseur; + + curpos.x -= GetScreen()->m_DrawOrg.x; + curpos.y -= GetScreen()->m_DrawOrg.y; + + curpos.x /= GetZoom(); + curpos.y /= GetZoom(); + + return curpos; +} + +/*********************************************************/ +wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition(void) +/*********************************************************/ +{ +wxSize size; +wxPoint realpos; + + size = GetClientSize(); + size.x /= 2; size.y /= 2; + + realpos = CalcAbsolutePosition( wxPoint(size.x, size.y) ); + realpos.x *= GetZoom(); + realpos.y *= GetZoom(); + realpos.x += GetScreen()->m_DrawOrg.x; + realpos.y += GetScreen()->m_DrawOrg.y; + + return realpos; +} + + +/**********************************************/ +void WinEDA_DrawPanel::MouseToCursorSchema(void) +/**********************************************/ +/* place le curseur souris sur la position du curseur schema +*/ +{ +wxPoint Mouse = CursorScreenPosition(); + MouseTo(Mouse); +} + +/****************************************************/ +void WinEDA_DrawPanel::MouseTo(const wxPoint & Mouse) +/****************************************************/ +/* place le curseur souris sur la position Mouse +*/ +{ +wxPoint mouse; +#ifdef WX_ZOOM + CalcScrolledPosition(Mouse.x, Mouse.y, &mouse.x, &mouse.y); +#else + mouse = Mouse; + mouse.x -= GetScreen()->m_StartVisu.x; + mouse.y -= GetScreen()->m_StartVisu.y; +#endif + GRMouseWarp(this, mouse); +} + +/********************************************************/ +void WinEDA_DrawPanel::OnActivate(wxActivateEvent& event) +/********************************************************/ +{ + m_CanStartBlock = -1; // Commande block can't start + event.Skip(); +} + + +/***********************************************************/ +void WinEDA_DrawPanel::OnEraseBackground(wxEraseEvent& event) +/***********************************************************/ +{ + event.Skip(); +} + +/*********************************************************/ +void WinEDA_DrawPanel::OnScroll( wxScrollWinEvent &event ) +/*********************************************************/ +{ +int id = event.GetEventType(); +int dir, value = 0; +int x,y; + + GetViewStart( &x, &y ); + dir = event.GetOrientation(); // wxHORIZONTAL ou wxVERTICAL + + if ( id == wxEVT_SCROLLWIN_LINEUP) value = - m_ScrollButt_unit; + + else if ( id == wxEVT_SCROLLWIN_LINEDOWN) value = m_ScrollButt_unit; + + else if ( id == wxEVT_SCROLLWIN_THUMBTRACK ) + { + value = event.GetPosition(); + if ( dir == wxHORIZONTAL ) Scroll( value, -1 ); + else Scroll( -1, value ); + return; + } + + else + { + event.Skip(); + return; + } + + if ( dir == wxHORIZONTAL ) + { + Scroll( x + value, -1 ); + } + else + { + Scroll( -1, y + value ); + } + event.Skip(); +} + + +/*************************************************/ +void WinEDA_DrawPanel::OnSize(wxSizeEvent & event) +/*************************************************/ +{ + SetBoundaryBox(); +} + +/******************************************/ +void WinEDA_DrawPanel::SetBoundaryBox(void) +/******************************************/ +{ +BASE_SCREEN * Screen = GetScreen();; +wxPoint org; +int ii, jj; + + Screen->m_SizeVisu = GetClientSize(); + GetViewStart(&org.x, &org.y); + + GetScrollPixelsPerUnit(&ii, &jj); + org.x *= ii; org.y *= jj; + Screen->m_StartVisu = org; + + m_ClipBox.SetOrigin(org); + m_ClipBox.SetSize(GetClientSize()); + +#ifdef WX_ZOOM + m_ClipBox.m_Pos.x *= GetZoom(); + m_ClipBox.m_Pos.y *= GetZoom(); + m_ClipBox.m_Size.x *= GetZoom(); + m_ClipBox.m_Size.y *= GetZoom(); +#else + m_ClipBox.m_Pos.x -= GetScreen()->m_StartVisu.x; + m_ClipBox.m_Pos.y -= GetScreen()->m_StartVisu.y; +#endif + + m_ScrollButt_unit = MIN( Screen->m_SizeVisu.x, Screen->m_SizeVisu.y ) / 4; + if ( m_ScrollButt_unit < 2 ) m_ScrollButt_unit = 2; + + Screen->m_ScrollbarPos.x = GetScrollPos(wxHORIZONTAL); + Screen->m_ScrollbarPos.y = GetScrollPos(wxVERTICAL); +} + + +/*********************************************/ +void WinEDA_DrawPanel::EraseScreen(wxDC * DC) +/*********************************************/ +{ + GRSetDrawMode(DC, GR_COPY); + GRSFilledRect(&m_ClipBox, DC, m_ClipBox.GetX(), m_ClipBox.GetY(), + m_ClipBox.GetRight(), m_ClipBox.GetBottom(), + g_DrawBgColor, g_DrawBgColor); +} + +/***************************************************/ +void WinEDA_DrawPanel::OnPaint(wxPaintEvent & event) +/***************************************************/ +{ +wxPaintDC paintDC(this); +EDA_Rect tmp; +wxRect PaintClipBox; +wxPoint org; + + PrepareGraphicContext(&paintDC); + tmp = m_ClipBox; + + org = m_ClipBox.GetOrigin(); + + wxRegionIterator upd(GetUpdateRegion()); // get the update rect list + + while ( upd ) + { + PaintClipBox = upd.GetRect(); + upd++; + + PaintClipBox.x += org.x; + PaintClipBox.y += org.y; + +#ifdef WX_ZOOM + m_ClipBox.m_Pos.x = PaintClipBox.x * GetZoom(); + m_ClipBox.m_Pos.y = PaintClipBox.y * GetZoom(); + m_ClipBox.m_Size.x = PaintClipBox.m_Size.x * GetZoom(); + m_ClipBox.m_Size.y = PaintClipBox.m_Size.y * GetZoom(); + PaintClipBox = m_ClipBox; +#else + m_ClipBox.SetX(PaintClipBox.GetX()); + m_ClipBox.SetY(PaintClipBox.GetY()); + m_ClipBox.SetWidth(PaintClipBox.GetWidth()); + m_ClipBox.SetHeight(PaintClipBox.GetHeight()); +#endif + + wxDCClipper * dcclip = new wxDCClipper(paintDC, PaintClipBox); + ReDraw(&paintDC, TRUE); + delete dcclip; + } + + m_ClipBox = tmp; + event.Skip(); +} + +/****************************************************/ +void WinEDA_DrawPanel::ReDraw(wxDC * DC, bool erasebg) +/****************************************************/ +{ +BASE_SCREEN * Screen = GetScreen(); + + if ( Screen == NULL ) return; + + if ( (g_DrawBgColor != WHITE) && (g_DrawBgColor != BLACK) ) g_DrawBgColor = BLACK; + if(g_DrawBgColor == WHITE) + { + g_XorMode = GR_NXOR; + g_GhostColor = BLACK; + } + else + { + g_XorMode = GR_XOR; + g_GhostColor = WHITE; + } + +#ifdef WX_ZOOM +int zoom = GetZoom(); +double f_scale = 1.0/(double)zoom; + DC->SetUserScale(f_scale, f_scale); +#endif + + + if(erasebg) PrepareGraphicContext(DC); + DC->SetFont(* g_StdFont); + + SetBackgroundColour(wxColour(ColorRefs[g_DrawBgColor].m_Red, + ColorRefs[g_DrawBgColor].m_Green, + ColorRefs[g_DrawBgColor].m_Blue )); + + GRResetPenAndBrush(DC); + + DC->SetBackground(*wxBLACK_BRUSH ); + DC->SetBackgroundMode(wxTRANSPARENT); + m_Parent->RedrawActiveWindow(DC, erasebg); +} + +/***********************************************/ +void WinEDA_DrawPanel::DrawBackGround(wxDC * DC) +/***********************************************/ +/* Trace les axes X et Y et la grille + La grille n'est affichee que si elle peut etre facilement visible + La grille passe toujours par le centre de l'ecran +*/ +{ +int Color = BLUE; +BASE_SCREEN * screen = GetScreen(); +int ii,jj ,xg , yg , color; +wxSize pas_grille_affichee; +bool drawgrid = FALSE; +int zoom = GetZoom(); +wxSize size; +wxPoint org; +double pasx, pasy; + + color = g_GridColor; + GRSetDrawMode(DC, GR_COPY); + + /* le pas d'affichage doit etre assez grand pour avoir une grille visible */ + drawgrid = m_Parent->m_Draw_Grid; + pas_grille_affichee = screen->GetGrid(); + + ii = pas_grille_affichee.x / zoom; + if (ii < 5 ) { pas_grille_affichee.x *= 2 ; ii *= 2; } + if( ii < 5 ) drawgrid = FALSE; // grille trop petite + ii = pas_grille_affichee.y / zoom; + if (ii < 5 ) { pas_grille_affichee.y *= 2 ; ii *= 2; } + if( ii < 5 ) drawgrid = FALSE; // grille trop petite + + GetViewStart(&org.x, &org.y); + GetScrollPixelsPerUnit(&ii, &jj); + org.x *= ii; org.y *= jj; + screen->m_StartVisu = org; + + org.x *= zoom; org.y *= zoom; + org.x += screen->m_DrawOrg.x; org.y += screen->m_DrawOrg.y; + + size = GetClientSize(); + size.x *= zoom; size.y *= zoom; + pasx = screen->m_UserGrid.x * m_Parent->m_InternalUnits; + pasy = screen->m_UserGrid.y * m_Parent->m_InternalUnits; + if ( screen->m_UserGridUnit != INCHES ) + { + pasx /= 25.4; pasy /= 25.4; + } + + if( drawgrid) + { + m_Parent->PutOnGrid(&org) ; + + GRSetColorPen(DC, color ); + for ( ii = 0 ; ; ii++ ) + { + xg = screen->m_UserGridIsON ? (int)( (ii * pasx) + 0.5) + :ii * pas_grille_affichee.x; + int xpos = org.x + xg; + for ( jj = 0 ; ; jj++ ) + { + yg = screen->m_UserGridIsON ? (int)( (jj * pasy) + 0.5) + : jj * pas_grille_affichee.y; + GRPutPixel(&m_ClipBox, DC, xpos, org.y + yg, color); + if ( yg > size.y ) break; + } + if ( xg > size.x ) break; + } + } + + /* trace des axes principaux */ + if ( m_Parent->m_Draw_Axis ) + { + /* Trace de l'axe vertical */ + GRDashedLine(&m_ClipBox, DC, 0, -screen->ReturnPageSize().y, + 0, screen->ReturnPageSize().y, Color ); + + /* Trace de l'axe horizontal */ + GRDashedLine(&m_ClipBox, DC, -screen->ReturnPageSize().x, 0, + screen->ReturnPageSize().x, 0, Color ); + } + + /* trace des axes auxiliaires */ + if ( m_Parent->m_Draw_Auxiliary_Axis) + { + m_Draw_Auxiliary_Axis(DC, FALSE); + } +} + +/********************************************************************/ +void WinEDA_DrawPanel::m_Draw_Auxiliary_Axis(wxDC * DC, int drawmode) +/********************************************************************/ +{ + if ( m_Parent->m_Auxiliary_Axis_Position.x == 0 && + m_Parent->m_Auxiliary_Axis_Position.y == 0 ) + return; + +int Color = DARKRED; +BASE_SCREEN * screen = GetScreen(); + + GRSetDrawMode(DC, drawmode); + + /* Trace de l'axe vertical */ + GRDashedLine(&m_ClipBox, DC, + m_Parent->m_Auxiliary_Axis_Position.x, -screen->ReturnPageSize().y, + m_Parent->m_Auxiliary_Axis_Position.x, screen->ReturnPageSize().y, + Color ); + + /* Trace de l'axe horizontal */ + GRDashedLine(&m_ClipBox, DC, + -screen->ReturnPageSize().x, m_Parent->m_Auxiliary_Axis_Position.y, + screen->ReturnPageSize().x, m_Parent->m_Auxiliary_Axis_Position.y, + Color ); +} + +/*******************************************************/ +void WinEDA_DrawPanel::OnRightClick(wxMouseEvent& event) +/*******************************************************/ +/* Construit et affiche un menu Popup lorsque on actionne le bouton droit + de la souris +*/ +{ +wxPoint pos; +wxMenu MasterMenu; + + pos.x = event.GetX(); pos.y = event.GetY(); + m_Parent->OnRightClick(pos, &MasterMenu); + AddMenuZoom(&MasterMenu); + m_IgnoreMouseEvents = TRUE; + PopupMenu( &MasterMenu, pos); + MouseToCursorSchema(); + m_IgnoreMouseEvents = FALSE; +} + + +/******************************************************/ +void WinEDA_DrawPanel::OnMouseLeaving(wxMouseEvent& event) +/*******************************************************/ +// Called when the canvas receives a mouse event leaving frame. // +{ + if (ManageCurseur == NULL ) // Pas de commande encours + m_AutoPAN_Request = FALSE; + + if ( ! m_AutoPAN_Enable || ! m_AutoPAN_Request || m_IgnoreMouseEvents) + return; + // Auto pan if mouse is leave working aera: + wxSize size = GetClientSize(); + if ( (size.x < event.GetX() ) || + (size.y < event.GetY() ) || + ( event.GetX() <= 0) || ( event.GetY() <= 0 ) ) + m_Parent->OnZoom(ID_POPUP_ZOOM_CENTER); +} + + +/******************************************************/ +void WinEDA_DrawPanel::OnMouseEvent(wxMouseEvent& event) +/*******************************************************/ +// Called when the canvas receives a mouse event. // +{ +int localrealbutt = 0, localbutt = 0, localkey = 0; +BASE_SCREEN * screen = GetScreen(); +static WinEDA_DrawPanel * LastPanel; + + if ( event.Leaving() || event.Entering() ) + { + m_CanStartBlock = -1; + } + + if (ManageCurseur == NULL ) // Pas de commande en cours + m_AutoPAN_Request = FALSE; + + if ( m_Parent->m_FrameIsActive ) SetFocus(); + else return; + + // Mouse Wheel is a zoom command: + if ( event.m_wheelRotation ) + { + // This is a zoom in ou out command + if ( event.GetWheelRotation() > 0 ) + { + if( event.ShiftDown() ) localkey = EDA_PANNING_UP_KEY; + else if( event.ControlDown() ) localkey = EDA_PANNING_LEFT_KEY; + else localkey = WXK_F1; + } + else + { + if( event.ShiftDown() ) localkey = EDA_PANNING_DOWN_KEY; + else if( event.ControlDown() ) localkey = EDA_PANNING_RIGHT_KEY; + else localkey = WXK_F2; + } + } + + if( !event.IsButton() && !event.Moving() && + !event.Dragging() && ! localkey ) + { + return; + } + + if( event.RightDown() ) + { + OnRightClick(event); return; + } + + if ( m_IgnoreMouseEvents ) return; + + if( event.LeftIsDown() ) localrealbutt |= GR_M_LEFT_DOWN; + if( event.MiddleIsDown() ) localrealbutt |= GR_M_MIDDLE_DOWN; + + if( event.LeftDown()) localbutt = GR_M_LEFT_DOWN; + + if( event.ButtonDClick(1)) localbutt = GR_M_LEFT_DOWN|GR_M_DCLICK; + if( event.MiddleDown()) localbutt = GR_M_MIDDLE_DOWN; + if( event.ButtonDClick(2)) {}; // Unused + + + localrealbutt |= localbutt; /* compensation defaut wxGTK */ + + screen->m_MousePosition = CalcAbsolutePosition(wxPoint(event.GetX(), event.GetY())); + +wxClientDC DC(this); +int kbstat = 0; + + DC.SetBackground(*wxBLACK_BRUSH ); + PrepareGraphicContext(&DC); + + g_KeyPressed = localkey; + + if( event.ShiftDown() ) kbstat |= GR_KB_SHIFT; + if( event.ControlDown() ) kbstat |= GR_KB_CTRL; + if( event.AltDown() ) kbstat |= GR_KB_ALT; + + g_MouseOldButtons = localrealbutt; + + // Appel des fonctions liées au Double Click ou au Click + if( localbutt == (int)(GR_M_LEFT_DOWN|GR_M_DCLICK) ) + m_Parent->OnLeftDClick(&DC, screen->m_MousePosition); + + else if ( event.LeftDown() ) + m_Parent->OnLeftClick(&DC, screen->m_MousePosition); + + if( event.ButtonUp(2) && (screen->BlockLocate.m_State == STATE_NO_BLOCK) ) + { // The middle button has been relached, with no block command: + // We use it for a zoom center command + g_KeyPressed = localkey = WXK_F4; + } + + + /* Appel de la fonction generale de gestion des mouvements souris + et commandes clavier */ + m_Parent->GeneralControle(&DC, screen->m_MousePosition); + + + /*******************************/ + /* Control of block commands : */ + /*******************************/ + + // Command block can't start if mouse is dragging a new panel + if (LastPanel != this ) m_CanStartBlock = -1; + + // A new command block can start after a release buttons + // Avoid a false start block when a dialog bos is demiss, + // or when changing panels in hierachy navigation + if ( !event.LeftIsDown() && !event.MiddleIsDown()) + { + m_CanStartBlock = 0; + } + + if( m_Block_Enable && !(localbutt & GR_M_DCLICK) ) + { + if ( (screen->BlockLocate.m_Command == BLOCK_IDLE) || + (screen->BlockLocate.m_State == STATE_NO_BLOCK)) + { + m_CursorStartPos = screen->m_Curseur; + screen->BlockLocate.SetOrigin(m_CursorStartPos); + } + if ( event.LeftDown() || event.MiddleDown() ) + { + m_CursorStartPos = screen->m_Curseur; + if ( screen->BlockLocate.m_State == STATE_BLOCK_MOVE ) + { + m_AutoPAN_Request = FALSE; + m_Parent->HandleBlockPlace(&DC); + } + } + else if( (m_CanStartBlock >= 0 ) && + ( event.LeftIsDown() || event.MiddleIsDown() ) + && ManageCurseur == NULL + && ForceCloseManageCurseur == NULL ) + { + if ( screen->BlockLocate.m_State == STATE_NO_BLOCK ) + { + int cmd_type = kbstat; + if ( event.MiddleIsDown() ) cmd_type |= MOUSE_MIDDLE; + if ( ! m_Parent->HandleBlockBegin(&DC, cmd_type, m_CursorStartPos) ) + { // error + m_Parent->DisplayToolMsg( wxT("WinEDA_DrawPanel::OnMouseEvent() Block Error") ); + } + else + { + m_AutoPAN_Request = TRUE; + SetCursor(m_PanelCursor = wxCURSOR_SIZING); + } + } + } + + + if( event.ButtonUp(1) || event.ButtonUp(2) ) + { /* Relachement du bouton: fin de delimitation de block. + La commande peut etre terminee (DELETE) ou continuer par le placement + du block ainsi delimite (MOVE, COPY). + Cependant bloc est annule si sa taille est trop petite*/ + bool BlockIsSmall = + ( ABS(screen->BlockLocate.GetWidth()/GetZoom()) < 3) && + ( ABS(screen->BlockLocate.GetHeight()/GetZoom()) < 3); + + if ( (screen->BlockLocate.m_State != STATE_NO_BLOCK) && BlockIsSmall ) + { + if( ForceCloseManageCurseur ) + { + ForceCloseManageCurseur(this, &DC); + m_AutoPAN_Request = FALSE; + } + SetCursor(m_PanelCursor = m_PanelDefaultCursor); + } + else if ( screen->BlockLocate.m_State == STATE_BLOCK_END ) + { + m_AutoPAN_Request = FALSE; + m_Parent->HandleBlockEnd(&DC); + SetCursor(m_PanelCursor = m_PanelDefaultCursor); + if ( screen->BlockLocate.m_State == STATE_BLOCK_MOVE ) + { + m_AutoPAN_Request = TRUE; + SetCursor(m_PanelCursor = wxCURSOR_HAND); + } + } + } + + } + + // Arret de block sur un double click ( qui peut provoquer un move block + // si on déplace la souris dans ce double click + if ( localbutt == (int)(GR_M_LEFT_DOWN|GR_M_DCLICK) ) + { + if ( screen->BlockLocate.m_Command != BLOCK_IDLE ) + { + if( ForceCloseManageCurseur ) + { + ForceCloseManageCurseur(this, &DC); + m_AutoPAN_Request = FALSE; + } + } + } + + +#if 0 + wxString msg_debug; + msg_debug.Printf(" block state %d, cmd %d", + screen->BlockLocate.m_State, screen->BlockLocate.m_Command); + m_Parent->PrintMsg(msg_debug); +#endif + + LastPanel = this; + m_Parent->SetToolbars(); +} + +/****************************************************/ +void WinEDA_DrawPanel::OnKeyEvent(wxKeyEvent& event) +/****************************************************/ +{ +long key, localkey; +bool escape = FALSE; + + key = localkey = event.m_keyCode; + + switch( localkey ) + { + case WXK_CONTROL: + case WXK_CAPITAL: + case WXK_SHIFT: + case WXK_NUMLOCK: + case WXK_LBUTTON: + case WXK_RBUTTON: + case 0x0135: /* Alt key */ + return; + + case WXK_ESCAPE: + escape = m_AbortRequest = TRUE; + break; + } + + + if( event.ControlDown() ) localkey |= GR_KB_CTRL; + if( event.AltDown() ) localkey |= GR_KB_ALT; + if( event.ShiftDown() && (key > 256) ) localkey |= GR_KB_SHIFT; + + +wxClientDC DC(this); +BASE_SCREEN * Screen = GetScreen(); + + PrepareGraphicContext(&DC); + + g_KeyPressed = localkey; + + if ( escape ) + { + if( ManageCurseur && ForceCloseManageCurseur ) + { + SetCursor(m_PanelCursor = m_PanelDefaultCursor); + ForceCloseManageCurseur(this, &DC); + SetCursor(m_PanelCursor = m_PanelDefaultCursor); + } + else m_Parent->SetToolID(0, m_PanelCursor = m_PanelDefaultCursor = wxCURSOR_ARROW, wxEmptyString); + } + + m_Parent->GeneralControle(&DC, Screen->m_MousePosition); +} + + + diff --git a/share/gr_basic.cpp b/share/gr_basic.cpp new file mode 100644 index 0000000000..530062f035 --- /dev/null +++ b/share/gr_basic.cpp @@ -0,0 +1,1402 @@ + /********************************/ + /* Low level graphics routines */ + /********************************/ + + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" + +#ifdef PCBNEW +#include "pcbnew.h" +#endif + +#ifdef EESCHEMA +#include "program.h" +#include "libcmp.h" +#include "general.h" +#endif + +#ifdef CVPCB +#include "pcbnew.h" +#include "cvpcb.h" +#endif + +#include "trigo.h" + +#ifndef FILLED +#define FILLED 1 +#endif + +#ifndef EXCHG +#define EXCHG(a,b) { int __temp__ = (a); (a) = (b); (b) = __temp__; } +#endif + +/* Variables locales */ +static int GRLastMoveToX , GRLastMoveToY; +static int Text_Color = LIGHTGRAY; + +static int PenMinWidth = 1; /* largeur minimum de la plume (DOIT etre > 0) + (utile pour trace sur imprimante) */ +static int ForceBlackPen; /* si != 0 : traces en noir (utilise pour trace + sur imprimante */ +static int xcliplo = 0, + ycliplo = 0, + xcliphi = 2000, + ycliphi = 2000; /* coord de la surface de trace */ +static int lastcolor = -1; +static int lastwidth = -1; +static wxDC * lastDC = NULL; + +/* + Macro de clipping du trace d'une ligne: + la ligne (x1,y1 x2,y2) est clippee pour rester dans le cadre + (xcliplo,ycliplo xcliphi,ycliphi) (variables globales,locales a ce fichier) + Ceci est necessaire sous WIN95 car les coord de trace + (bien que en int 32bits) sont tronquees en 16 bits (stupide BG) +*/ +#ifndef us +#define us unsigned int +#endif + +static inline int USCALE(us arg, us num, us den) + { + int ii; + + ii = (int)( ((float) arg * num) / den); + return( ii ); + } + + +#ifdef WX_ZOOM +#define GET_ZOOM 1 +#else +#define GET_ZOOM ActiveScreen->GetZoom() +#endif + +static int inline ZoomValue(int value_to_zoom) +{ +int zoom = GET_ZOOM; + if ( value_to_zoom >= 0 ) + return( (value_to_zoom + (zoom >> 1 ) ) /zoom ); + else + return( (value_to_zoom - (zoom >> 1 ) ) /zoom ); +} + +/****************************************/ +/* External reference for the mappings. */ +/****************************************/ +int GRMapX(int x) +{ +int coord = x - ActiveScreen->m_DrawOrg.x; + +#ifndef WX_ZOOM + coord = ZoomValue(coord); + coord -= ActiveScreen->m_StartVisu.x; +#endif + + return coord; +} + +int GRMapY(int y) +{ +int coord = y - ActiveScreen->m_DrawOrg.y; + +#ifndef WX_ZOOM + coord = ZoomValue(coord); + coord -= ActiveScreen->m_StartVisu.y; +#endif + + return coord; +} + + + +#define WHEN_OUTSIDE return +#define WHEN_INSIDE + +#define CLIP_LINE(x1,y1,x2,y2) \ +{\ +int temp;\ +do {\ + if(x1 > x2) { EXCHG(x1,x2); EXCHG(y1,y2); }\ + if((x2 < xcliplo) || (x1 > xcliphi)) { WHEN_OUTSIDE; }\ + if(y1 < y2)\ + {\ + if((y2 < ycliplo) || (y1 > ycliphi)) { WHEN_OUTSIDE;}\ + if(y1 < ycliplo)\ + {\ + temp = USCALE((x2 - x1),(ycliplo - y1),(y2 - y1));\ + if((x1 += temp) > xcliphi) { WHEN_OUTSIDE; }\ + y1 = ycliplo;\ + WHEN_INSIDE;\ + }\ + if(y2 > ycliphi)\ + {\ + temp = USCALE((x2 - x1),(y2 - ycliphi),(y2 - y1));\ + if((x2 -= temp) < xcliplo) { WHEN_OUTSIDE; }\ + y2 = ycliphi;\ + WHEN_INSIDE;\ + }\ + if(x1 < xcliplo)\ + {\ + temp = USCALE((y2 - y1),(xcliplo - x1),(x2 - x1));\ + y1 += temp; x1 = xcliplo;\ + WHEN_INSIDE;\ + }\ + if(x2 > xcliphi)\ + {\ + temp = USCALE((y2 - y1),(x2 - xcliphi),(x2 - x1));\ + y2 -= temp; x2 = xcliphi;\ + WHEN_INSIDE;\ + }\ + }\ + else\ + {\ + if((y1 < ycliplo) || (y2 > ycliphi)) { WHEN_OUTSIDE; }\ + if(y1 > ycliphi)\ + {\ + temp = USCALE((x2 - x1),(y1 - ycliphi),(y1 - y2));\ + if((x1 += temp) > xcliphi) { WHEN_OUTSIDE; }\ + y1 = ycliphi;\ + WHEN_INSIDE;\ + }\ + if(y2 < ycliplo)\ + {\ + temp = USCALE((x2 - x1),(ycliplo - y2),(y1 - y2));\ + if((x2 -= temp) < xcliplo) { WHEN_OUTSIDE; }\ + y2 = ycliplo;\ + WHEN_INSIDE;\ + }\ + if(x1 < xcliplo)\ + {\ + temp = USCALE((y1 - y2),(xcliplo - x1),(x2 - x1));\ + y1 -= temp; x1 = xcliplo;\ + WHEN_INSIDE;\ + }\ + if(x2 > xcliphi)\ + {\ + temp = USCALE((y1 - y2),(x2 - xcliphi),(x2 - x1));\ + y2 += temp; x2 = xcliphi;\ + WHEN_INSIDE;\ + }\ + }\ + } while(0);\ +} + +static void WinClipAndDrawLine(EDA_Rect * ClipBox, wxDC * DC, + int x1, int y1, int x2, int y2, + int Color, int width = 1 ) +{ + GRLastMoveToX = x2; + GRLastMoveToY = y2; + + if ( ClipBox ) + { + xcliplo = ClipBox->GetX(); + ycliplo = ClipBox->GetY(); + xcliphi = ClipBox->GetRight(); + ycliphi = ClipBox->GetBottom(); + + xcliplo -= width; + ycliplo -= width; + + xcliphi += width; + ycliphi += width; + + CLIP_LINE(x1, y1, x2, y2); + } + + GRSetColorPen(DC, Color, width); + DC->DrawLine(x1, y1, x2, y2); +} + + +/* Routine de forcage de la reinit de la plume courante. + Doit etre appelee par securite apres changement de contexte graphique + avant tout trace + */ +void GRResetPenAndBrush(wxDC * DC) +{ + lastcolor = -1; + GRSetBrush(DC, BLACK); // Force no fill + lastDC = NULL; +} + +/* routine d'ajustage de la largeur mini de plume */ +void SetPenMinWidth(int minwidth) +{ + PenMinWidth = minwidth; + if( PenMinWidth < 1 ) PenMinWidth = 1; +} + + +/* Routine de changement de couleurs et epaisseur de la plume courante */ +void GRSetColorPen(wxDC * DC, int Color , int width) +{ + Color &= MASKCOLOR; // Pour 32 couleurs Max + + if(width < PenMinWidth) width = PenMinWidth; + + if( ForceBlackPen && Color != WHITE ) Color = BLACK; + + if( (lastcolor != Color) || (lastwidth != width) || (lastDC != DC ) ) + { + DrawPen->SetColour( + ColorRefs[Color].m_Red, + ColorRefs[Color].m_Green, + ColorRefs[Color].m_Blue + ); + + DrawPen->SetWidth(width); + if ( &DC->GetPen() != DrawPen ) DC->SetPen(*DrawPen); + lastcolor = Color; lastwidth = width; lastDC = DC; + } +} + +/***********************************************/ +void GRSetBrush(wxDC * DC, int Color , int fill) +/***********************************************/ +{ + Color &= MASKCOLOR; // Pour 32 couleurs Max + if( ForceBlackPen && Color != WHITE ) Color = BLACK; + DrawBrush->SetColour( + ColorRefs[Color].m_Red, + ColorRefs[Color].m_Green, + ColorRefs[Color].m_Blue + ); + + if ( fill ) DrawBrush->SetStyle(wxSOLID); + else DrawBrush->SetStyle(wxTRANSPARENT); + if ( &DC->GetBrush() != DrawBrush ) DC->SetBrush(*DrawBrush); +} + +/*************************************/ +void GRForceBlackPen(bool flagforce ) +/*************************************/ +{ + ForceBlackPen = flagforce; +} + + +/************************************************************/ +/* routines de controle et positionnement du curseur souris */ +/************************************************************/ +/* positionne la souris au point de coord pos */ +void GRMouseWarp(WinEDA_DrawPanel * panel, const wxPoint& pos) +{ + if( panel == NULL ) return; + panel->WarpPointer(pos.x, pos.y); +} + +/**********************************************/ +/* Routine pour selectionner le mode de trace */ +/**********************************************/ +void GRSetDrawMode(wxDC * DC, int draw_mode) +{ + if( draw_mode & GR_OR ) DC->SetLogicalFunction(wxOR); + else if( draw_mode & GR_XOR ) DC->SetLogicalFunction(wxXOR); + else if( draw_mode & GR_NXOR ) DC->SetLogicalFunction(wxEQUIV); + else DC->SetLogicalFunction(wxCOPY); +} + + +/*********************************************************************/ +void GRPutPixel(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int Color) +/*********************************************************************/ +{ + GRSPutPixel(ClipBox, DC, GRMapX(x), GRMapY(y), Color); +} + + +/********************************************************************/ +void GRSPutPixel(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int Color) +/********************************************************************/ +{ + + if ( ClipBox ) /* suppression des pixels hors ecran */ + { + if ( x < ClipBox->GetX() ) return; + if ( y < ClipBox->GetY() ) return; + if ( x > (ClipBox->GetRight()) ) return; + if ( y > (ClipBox->GetBottom()) ) return; + } + GRSetColorPen(DC, Color ); + DC->DrawPoint( x, y); +} + + /*******************************************/ + /* int GRGetPixel(wxDC * DC, int x, int y) */ + /*******************************************/ + +int GRGetPixel(wxDC * DC, int x, int y) +{ +wxColour colour; +unsigned char r, g, b; +int ii; + + DC->GetPixel( (long)x, (long)y, &colour); + r = colour.Red(); + b = colour.Blue(); + g = colour.Green(); + for ( ii = 0; ii < NBCOLOR; ii++ ) + { + if( ( r == ColorRefs[ii].m_Red ) && + ( g == ColorRefs[ii].m_Green ) && + ( b == ColorRefs[ii].m_Blue ) ) + break; + } + + return ii; +} + + + +/**************************************************************************** +* Routine to draw a line, in Object spaces. * +****************************************************************************/ +void GRLine(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + GRSLine(ClipBox, DC, GRMapX(x1), GRMapY(y1), GRMapX(x2), GRMapY(y2), Color); +} + +/***************************************************/ +/* Routine to draw a Dashed line, in Screen space. */ +/***************************************************/ +void GRSDashedLine(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + GRLastMoveToX = x2; + GRLastMoveToY = y2; + lastcolor = -1; + DrawPen->SetStyle(wxSHORT_DASH); + GRSLine(ClipBox, DC, x1, y1, x2, y2, Color); + lastcolor = -1; + DrawPen->SetStyle(wxSOLID); +} + +void GRSDashedLineTo(EDA_Rect * ClipBox,wxDC * DC, int x2, int y2, int Color) +{ + lastcolor = -1; + DrawPen->SetStyle(wxSHORT_DASH); + GRSLine(ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x2, y2, Color); + lastcolor = -1; + DrawPen->SetStyle(wxSOLID); + GRLastMoveToX = x2; + GRLastMoveToY = y2; +} +/**************************************************************************** +* Routine to draw a Dashed line, in Object spaces. * +****************************************************************************/ +void GRDashedLineTo(EDA_Rect * ClipBox,wxDC * DC,int x2, int y2, int Color) +{ + GRSDashedLineTo(ClipBox, DC, GRMapX(x2), GRMapY(y2), Color); +} + +void GRDashedLine(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + GRSDashedLine(ClipBox, DC, GRMapX(x1), GRMapY(y1), GRMapX(x2), GRMapY(y2), Color); +} + + +/*************************************************/ +/* Routine to draw a Bus line, in Object spaces. */ +/*************************************************/ + +void GRBusLine(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + x1 = GRMapX(x1); x2 = GRMapX(x2); + y1 = GRMapY(y1); y2 = GRMapY(y2); + GRSBusLine(ClipBox, DC, x1, y1, x2, y2, Color); +} + +/**************************************************************** +* Routine to draw a Bus Line, in Screen (pixels) space. * +****************************************************************************/ +void GRSBusLine(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + GRSFillCSegm(ClipBox, DC, x1, y1, x2, y2, 3*PenMinWidth, Color); + GRLastMoveToX = x2; + GRLastMoveToY = y2; +} + + +/**************************************************************************** +* Routine to move to a new position, in Object space. * +****************************************************************************/ +void GRMoveTo(int x, int y) +{ + GRLastMoveToX = GRMapX(x); + GRLastMoveToY = GRMapY(y); +} + +/*******************************************************/ +/* Routine to draw to a new position, in Object space. */ +/*******************************************************/ +void GRLineTo(EDA_Rect * ClipBox,wxDC * DC, int x, int y, int Color) +{ +int GRLineToX, GRLineToY; + + GRLineToX = GRMapX(x); GRLineToY = GRMapY(y); + GRSLine(ClipBox, DC, GRLastMoveToX, GRLastMoveToY, GRLineToX, GRLineToY, Color); +} + +/*************************************************/ +/* Routine to draw a Mixed line, in Object space */ +/*************************************************/ +void GRMixedLine(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + GRSMixedLine(ClipBox, DC, GRMapX(x1), GRMapY(y1), GRMapX(x2), GRMapY(y2), Color); +} + +/***********************************************************/ +/* Routine to draw a Mixed line, in Screen (Pixels) space */ +/***********************************************************/ +void GRSMixedLine(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + DrawPen->SetStyle(wxDOT_DASH); + GRSLine(ClipBox, DC, x1, y1, x2, y2, Color); + DrawPen->SetStyle(wxSOLID); +} + +/*******************************************************************/ +/* Routine to draw a Bus line to a new position, in Object spaces. */ +/*******************************************************************/ +void GRBusLineTo(EDA_Rect * ClipBox,wxDC * DC, int x, int y, int Color) +{ +int GRLineToX, GRLineToY; + + GRLineToX = GRMapX(x); GRLineToY = GRMapY(y); + + GRSBusLine(ClipBox, DC, GRLastMoveToX, GRLastMoveToY, GRLineToX, GRLineToY, + Color); + GRLastMoveToX = GRLineToX; + GRLastMoveToY = GRLineToY; +} + +/**************************************************************************** +* Routine to move to a new position, in Screen (pixels) space. * +****************************************************************************/ +void GRSMoveTo(int x, int y) +{ + GRLastMoveToX = x; + GRLastMoveToY = y; +} + +/**************************************************************************** +* Routine to draw to a new position, in Screen (pixels) space. * +****************************************************************************/ +void GRSLineTo(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int Color) +{ + GRSLine(ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x, y, Color); + GRLastMoveToX = x; GRLastMoveToY = y; +} + +/**************************************************************************** +* Routine to draw to a new position, in Screen (pixels) space. * +****************************************************************************/ +void GRSLine(EDA_Rect * ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int Color) +{ + WinClipAndDrawLine(ClipBox, DC, x1, y1, x2, y2, Color); + GRLastMoveToX = x2; GRLastMoveToY = y2; +} + +/****************************************************************************/ +/* Routine to move to a new position relative to current one, as in Object */ +/* space. */ +/****************************************************************************/ +void GRMoveRel(int x, int y) +{ + GRLastMoveToX += ZoomValue(x); + GRLastMoveToY += ZoomValue(y); +} + +/**************************************************************************** +* Routine to line to a new position relative to current one, as in Object * +* space. * +****************************************************************************/ +void GRLineRel(EDA_Rect * ClipBox,wxDC * DC, int x, int y, int Color) +{ +int GRLineToX = GRLastMoveToX, + GRLineToY = GRLastMoveToY; + + GRLineToX += ZoomValue(x); + GRLineToY += ZoomValue(y); + + GRSLine(ClipBox, DC, GRLastMoveToX, GRLastMoveToY, GRLineToX, GRLineToY, Color); +} + +/**************************************************************************** +* Routine to move to a new position relative to current one, as in Screen * +* space (pixel coords.). * +****************************************************************************/ +void GRSMoveRel(int x, int y) +{ + GRLastMoveToX += x; + GRLastMoveToY += y; +} + +/**************************************************************************** +* Routine to line to a new position relative to current one, as in Screen * +* space (pixel coords.). * +****************************************************************************/ +void GRSLineRel(EDA_Rect * ClipBox,wxDC * DC, int x, int y, int Color) +{ +long GRLineToX = GRLastMoveToX + x, + GRLineToY = GRLastMoveToY + y; + + GRSLine(ClipBox, DC, GRLastMoveToX, GRLastMoveToY, GRLineToX, GRLineToY, Color); + GRLastMoveToX = GRLineToX; + GRLastMoveToY = GRLineToY; +} + +/**************************************************/ +/* Routine de trace d'un segment a bouts arrondis */ +/* Object space = real coords.). */ +/**************************************************/ +void GRCSegm(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int width, int Color) +{ + GRSCSegm(ClipBox, DC, GRMapX(x1), GRMapY(y1), GRMapX(x2), GRMapY(y2), + ZoomValue(width), Color); +} + +/******************************************************************* +* Routine de trace d'un segment (plein) a bouts arrondis in Object * +* space (real coords.). * +********************************************************************/ +void GRFillCSegm(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int width, int Color) +{ + GRSFillCSegm(ClipBox, DC, GRMapX(x1), GRMapY(y1), GRMapX(x2), GRMapY(y2), + ZoomValue(width), Color); +} + + + /**********************************************************/ + /* Routine de trace d'un segment (plein) a bouts arrondis */ + /* ( Screen space = pixel coords.). */ + /**********************************************************/ + +void GRSFillCSegm(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int width, int Color) +{ + WinClipAndDrawLine(ClipBox, DC, x1,y1,x2,y2, Color, width); +} + + +/****************************************************************/ +/* Routine de trace d'un segment a bouts arrondis (Mode SKETCH) */ +/* Screen space (pixel coords.). */ +/****************************************************************/ +void GRSCSegm(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int width, int Color) +{ +long rayon, dwx, dwy; +long dx, dy, dwx2, dwy2; +long sx1, sy1, ex1, ey1; /* coord du 1er bord */ +long sx2, sy2, ex2, ey2; /* coord du 1eme bord */ +bool swap_ends = FALSE; + + + GRLastMoveToX = x2; + GRLastMoveToY = y2; + + if ( ClipBox ) + { + xcliplo = ClipBox->GetX(); + ycliplo = ClipBox->GetY(); + xcliphi = ClipBox->GetRight(); + ycliphi = ClipBox->GetHeight(); + + xcliplo -= width; + ycliplo -= width; + + xcliphi += width; + ycliphi += width; + + CLIP_LINE(x1, y1, x2, y2); + } + + + if ( width <= 2 ) /* ligne simple ou epaisse de 2 pixels*/ + { + GRSetColorPen(DC, Color, width ); + DC->DrawLine(x1, y1, x2, y2); + return; + } + + GRSetColorPen(DC, Color ); + GRSetBrush(DC,Color,FALSE); + + rayon = (width+1) >> 1; + dx = x2 - x1; dy = y2 - y1; + if ( dx == 0 ) /* segment vertical */ + { + dwx = rayon; + if ( dy >= 0 ) dwx = -dwx; + sx1 = x1 - dwx; sy1 = y1; + ex1 = x2 - dwx; ey1 = y2; + DC->DrawLine(sx1 , sy1, ex1, ey1); + + sx2 = x1 + dwx; sy2 = y1; + ex2 = x2 + dwx; ey2 = y2; + DC->DrawLine(sx2, sy2, ex2, ey2); + } + + else if ( dy == 0 ) /* segment horizontal */ + { + dwy = rayon; + if ( dx < 0 ) dwy = -dwy; + sx1 = x1, sy1 = y1 - dwy; + ex1 = x2; ey1 = y2 - dwy; + DC->DrawLine(sx1, sy1, ex1 , ey1); + + sx2 = x1; sy2 = y1 + dwy; + ex2 = x2; ey2 = y2 + dwy; + DC->DrawLine(sx2, sy2, ex2 , ey2); + } + + else + { + if ( ABS(dx) == ABS(dy) ) /* segment a 45 degre */ + { + dwx = dwy = ((width * 5)+ 4) / 7; // = width/2 * 0.707 + if ( dy < 0 ) + { + if ( dx <= 0 ) + { + dwx = -dwx; swap_ends = TRUE; + } + } + else + { + if( dx > 0 ) + { + dwy = -dwy; swap_ends = TRUE; + } + } + } + + else + { + int delta_angle = ArcTangente(dy, dx); + dwx = 0; dwy = width; + RotatePoint( (int*)&dwx, (int*)&dwy, -delta_angle); + } + dwx2 = dwx >> 1; dwy2 = dwy >> 1; + sx1 = x1 - dwx2; sy1 = y1 - dwy2; + ex1 = x2 - dwx2; ey1 = y2 - dwy2; + DC->DrawLine(sx1, sy1, ex1, ey1); + + sx2 = x1 + dwx2; sy2 = y1 + dwy2; + ex2 = x2 + dwx2; ey2 = y2 + dwy2; + DC->DrawLine(sx2, sy2, ex2, ey2); + } + + if ( swap_ends ) + { + DC->DrawArc(sx2, sy2, sx1 , sy1, x1, y1); + DC->DrawArc(ex1, ey1, ex2, ey2, x2, y2); + } + else + { + DC->DrawArc(sx1, sy1, sx2 , sy2, x1, y1); + DC->DrawArc(ex2, ey2, ex1, ey1, x2, y2); + } +} + + + +static bool IsGRSPolyDrawable( EDA_Rect * ClipBox,int n, int *Points) +{ +int ii; +int Xmin, Xmax, Ymin, Ymax; + + Xmin = Xmax = Points[0]; + Ymin = Ymax = Points[1]; + + for ( ii = 1; ii < n; ii++) // calcul du rectangle d'encadrement + { + int jj = ii * 2; + Xmin = MIN(Xmin,Points[jj]); + Xmax = MAX(Xmax,Points[jj]); + Ymin = MIN(Ymin,Points[jj+1]); + Ymax = MAX(Ymax,Points[jj+1]); + } + + xcliplo = ClipBox->GetX(); + ycliplo = ClipBox->GetY(); + xcliphi = ClipBox->GetRight(); + ycliphi = ClipBox->GetHeight(); + + if ( Xmax < xcliplo ) return FALSE; + if ( Xmin > xcliphi ) return FALSE; + if ( Ymax < ycliplo ) return FALSE; + if ( Ymin > ycliphi ) return FALSE; + + return TRUE; + +} +/************************************************************************/ +/* Routine to draw a new polyline and fill it if Fill, in screen space. */ +/************************************************************************/ +void GRSPoly(EDA_Rect * ClipBox,wxDC * DC, int n, int *Points, int Fill, + int Color, int BgColor) +{ +int startx, starty; + + if ( ! IsGRSPolyDrawable(ClipBox, n, Points) ) return; + + GRSetColorPen(DC, Color ); + + if( Fill && ( n > 2 ) ) + { + GRSetBrush(DC, BgColor, FILLED); + DC->DrawPolygon(n, (wxPoint*)Points); + } + else + { + startx = Points[n * 2 - 2]; starty = Points[n * 2 - 1]; + GRSetBrush(DC, Color); + DC->DrawLines(n, (wxPoint*)Points); + } +} + +/************************************************************************/ +/* Routine to draw a new polyline (line width = Width), in screen space. */ +/************************************************************************/ +void GRSPolyLines(EDA_Rect * ClipBox,wxDC * DC, int n, int *Points, + int Color, int BgColor, int Width) +{ +int startx, starty; + + if ( ! IsGRSPolyDrawable(ClipBox, n, Points) ) return; + + GRSetColorPen(DC, Color, Width ); + + startx = Points[n * 2 - 2]; starty = Points[n * 2 - 1]; + GRSetBrush(DC, Color); + DC->DrawLines(n, (wxPoint*)Points); +} + +/******************************************************************************/ +/* Routine to draw a new closed polyline and fill it if Fill, in screen space */ +/******************************************************************************/ +void GRSClosedPoly(EDA_Rect * ClipBox,wxDC * DC, int n, int *Points, + int Fill, int Color, int BgColor) +{ +int startx, starty; + + if ( ! IsGRSPolyDrawable(ClipBox, n, Points) ) return; + + GRSetColorPen(DC, Color ); + + if( Fill && ( n > 2 ) ) + { + GRSMoveTo(Points[n * 2 - 2], Points[n * 2 - 1]); + GRSetBrush(DC, BgColor, FILLED); + DC->DrawPolygon(n, (wxPoint*) Points, 0, 0,wxODDEVEN_RULE ); + } + else + { + startx = Points[n * 2 - 2]; starty = Points[n * 2 - 1]; + GRSetBrush(DC, BgColor); + DC->DrawLines(n, (wxPoint*)Points); + + /* Fermeture du polygone */ + if( (startx != Points[0]) || (starty != Points[1]) ) + { + GRSLine(ClipBox, DC, Points[0], Points[1], startx, starty, Color); + } + } +} + + +/************************************************************************/ +/* Routine to draw a new polyline and fill it if Fill, in drawing space. */ +/************************************************************************/ +void GRPoly(EDA_Rect * ClipBox, wxDC * DC, int n, int *Points, + int Fill, int Color, int BgColor) +{ +int ii, jj; + + for (ii = 0; ii < n; ii++) + { + jj = ii << 1; + Points[jj] = GRMapX(Points[jj]); + jj++; + Points[jj] = GRMapY(Points[jj]); + } + GRSPoly(ClipBox, DC, n, Points, Fill, Color, BgColor); +} + +void GRPolyLines(EDA_Rect * ClipBox, wxDC * DC, int n, int *Points, + int Color, int BgColor, int width) +{ +int ii, jj; + + width = ZoomValue(width); + + for (ii = 0; ii < n; ii++) + { + jj = ii << 1; + Points[jj] = GRMapX(Points[jj]); + jj++; + Points[jj] = GRMapY(Points[jj]); + } + if ( width <= 1 ) GRSPoly(ClipBox, DC, n, Points, 0, Color, BgColor); + else GRSPolyLines(ClipBox, DC, n, Points, Color, BgColor, width); +} +/**************************************************************************/ +/* Routine to draw a closed polyline and fill it if Fill, in object space */ +/**************************************************************************/ +void GRClosedPoly(EDA_Rect * ClipBox,wxDC * DC, int n, int *Points, + int Fill, int Color, int BgColor) +{ +int ii, jj; + + for (ii = 0; ii < n; ii++) + { + jj = ii << 1; + Points[jj] = GRMapX(Points[jj]); + jj++; + Points[jj] = GRMapY(Points[jj]); + } + GRSClosedPoly(ClipBox, DC, n, Points, Fill, Color, BgColor); +} + +/***********************************************/ +/* Routine to draw a circle, in object space. */ +/***********************************************/ +void GRCircle(EDA_Rect * ClipBox,wxDC * DC, int x, int y, int r, int Color) +{ +int cx = GRMapX(x); +int cy = GRMapY(y); +int rayon = ZoomValue(r); + + GRSCircle(ClipBox, DC, cx, cy, rayon, Color ); +} + +/*****************************************************/ +/* Routine to draw a Filled circle, in object space. */ +/*****************************************************/ +void GRFilledCircle(EDA_Rect * ClipBox,wxDC * DC, int x, int y, int r, + int Color, int BgColor) +{ + r = ZoomValue(r); + GRSFilledCircle(ClipBox, DC, GRMapX(x), GRMapY(y), r, Color, BgColor ); +} + +/***********************************************************/ +/* Routine to draw un anneau, epaisseur w, in object space. */ +/***********************************************************/ +void GRCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r, int width, int Color) +{ + r = ZoomValue(r); + width = ZoomValue(width); + GRSCircle(ClipBox, DC, GRMapX(x), GRMapY(y), r, width, Color); +} + + +/***********************************************/ +/* Routine to draw a circle, in drawing space. */ +/***********************************************/ +void GRSCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r, int Color) +{ +int d = r + r; + + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int x0, y0, xm, ym; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + if ( x < (x0-r) ) return; + if ( y < (y0-r) ) return; + if ( x > (r+xm) ) return; + if ( y > (r+ym) ) return; + } + + GRSetColorPen(DC, Color); + GRSetBrush(DC,Color,FALSE); + DC->DrawEllipse(x-r,y-r, d, d); +} + +/******************************************************/ +/* Routine to draw a FILLED circle, in drawing space. */ +/******************************************************/ +void GRSFilledCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r, + int Color, int BgColor) +{ + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int x0, y0, xm, ym; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + if ( x < (x0-r) ) return; + if ( y < (y0-r) ) return; + if ( x > (r+xm) ) return; + if ( y > (r+ym) ) return; + } + + GRSetColorPen(DC, Color ); + GRSetBrush(DC, BgColor, FILLED); + DC->DrawEllipse(x-r, y-r, r+r, r+r); +} + + /***********************************************************************/ + /* Routine de trace d'un cercle epais ( Screen space = pixel coords.) */ + /***********************************************************************/ + +void GRSCircle(EDA_Rect * ClipBox,wxDC * DC, int xc, int yc, int r, int width, int Color) +{ + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int x0, y0, xm, ym; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + if ( xc < (x0-r - width) ) return; + if ( yc < (y0-r - width) ) return; + if ( xc > (r+xm + width) ) return; + if ( yc > (r+ym + width) ) return; + } + + GRSetColorPen(DC, Color, width); + GRSetBrush(DC, Color, FALSE); + DC->DrawEllipse(xc-r, yc-r, r+r, r+r); +} + + +/************************************************/ +/* Routine to draw an arc, in USER space. */ +/* Debut et fin de l'arc donnes par leur coord. */ +/************************************************/ +void GRArc1(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int xc, int yc, int Color) +{ + GRSArc1(ClipBox, DC, + GRMapX(x1), GRMapY(y1), GRMapX(x2), GRMapY(y2), + GRMapX(xc), GRMapY(yc), Color); +} + +/************************************************/ +/* Routine to draw an arc, width = width in USER space. */ +/* Debut et fin de l'arc donnes par leur coord. */ +/************************************************/ +void GRArc1(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int xc, int yc, int width, int Color) +{ + GRSArc1(ClipBox, DC, + GRMapX(x1), GRMapY(y1), GRMapX(x2), GRMapY(y2), + GRMapX(xc), GRMapY(yc), ZoomValue(width), Color); +} + +/************************************************/ +/* Routine to draw an arc, in screen space. */ +/* Debut et fin de l'arc donnes par leur coord. */ +/************************************************/ +void GRSArc1(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int xc, int yc, int Color) +{ + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int x0, y0, xm, ym, r; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + r = (int)hypot(x1-xc, y1-yc); + if ( xc < (x0-r) ) return; + if ( yc < (y0-r) ) return; + if ( xc > (r+xm) ) return; + if ( yc > (r+ym) ) return; + } + + GRSetColorPen(DC, Color ); + GRSetBrush(DC,Color,FALSE); + DC->DrawArc(x1, y1, x2, y2, xc, yc); +} + +/************************************************/ +/* Routine to draw an arc, width = width, in screen space. */ +/* Debut et fin de l'arc donnes par leur coord. */ +/************************************************/ +void GRSArc1(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int xc, int yc, int width, int Color) +{ + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int x0, y0, xm, ym, r; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + r = (int)hypot(x1-xc, y1-yc); + if ( xc < (x0-r) ) return; + if ( yc < (y0-r) ) return; + if ( xc > (r+xm) ) return; + if ( yc > (r+ym) ) return; + } + + GRSetColorPen(DC, Color , width); + GRSetBrush(DC, Color); + DC->DrawArc(x1, y1, x2, y2, xc, yc); +} + +/********************************************************************/ +/* Routine to draw an arc, in screen space. */ +/* As the Y axe is inverted the Angles should be inverted as well. */ +/********************************************************************/ +void GRSArc(EDA_Rect * ClipBox,wxDC * DC, int xc, int yc, + int StAngle, int EndAngle, int r, int Color) +{ +int x1, y1, x2, y2; + + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int x0, y0, xm, ym; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + if ( xc < (x0-r - 1) ) return; + if ( yc < (y0-r - 1) ) return; + if ( xc > (r+xm + 1) ) return; + if ( yc > (r+ym + 1) ) return; + } + + x1 = r; y1 = 0; + RotatePoint( &x1, & y1, EndAngle); + + x2 = r; y2 = 0; + RotatePoint( &x2, & y2, StAngle); + + GRSetColorPen(DC, Color); + GRSetBrush(DC,Color,FALSE); + DC->DrawArc(xc + x1, yc - y1, xc + x2, yc - y2, xc, yc); +} + +/********************************************************************/ +/* Routine to draw an arc, width = width, in screen space. */ +/* As the Y axe is inverted the Angles should be inverted as well. */ +/********************************************************************/ +void GRSArc(EDA_Rect * ClipBox,wxDC * DC, int xc, int yc, int StAngle, int EndAngle, + int r, int width, int Color) +{ +int x1, y1, x2, y2; + + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int x0, y0, xm, ym; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + if ( xc < (x0-r - width) ) return; + if ( yc < (y0-r - width) ) return; + if ( xc > (r+xm + width) ) return; + if ( yc > (r+ym + width) ) return; + } + + x1 = r; y1 = 0; + RotatePoint( &x1, & y1, EndAngle); + + x2 = r; y2 = 0; + RotatePoint( &x2, & y2, StAngle); + + GRSetColorPen(DC, Color , width); + GRSetBrush(DC, Color); + DC->DrawArc(xc + x1, yc - y1, xc + x2, yc - y2, xc, yc); +} + +/********************************************************************/ +/* Routine to draw an Filled arc, in screen space. */ +/* As the Y axes is inverted the Angles should be inverted as well. */ +/********************************************************************/ +void GRSFilledArc(EDA_Rect * ClipBox,wxDC * DC, int xc, int yc, + int StAngle, int EndAngle, int r, int Color, int BgColor) +{ +int x1, y1, x2, y2; + + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int x0, y0, xm, ym; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + if ( xc < (x0-r - 1) ) return; + if ( yc < (y0-r - 1) ) return; + if ( xc > (r+xm + 1) ) return; + if ( yc > (r+ym + 1) ) return; + } + + x1 = r; y1 = 0; + RotatePoint( &x1, & y1, EndAngle); + + x2 = r; y2 = 0; + RotatePoint( &x2, & y2, StAngle); + + GRSetBrush(DC, BgColor, FILLED); + GRSetColorPen(DC, Color); + DC->DrawArc(xc + x1, yc - y1, xc + x2, yc - y2, xc, yc); +} + +/********************************************************************/ +/* Routine to draw a Filled arc, in drawing space. */ +/* As the Y axes is inverted the Angles should be inverted as well. */ +/********************************************************************/ +void GRFilledArc(EDA_Rect * ClipBox,wxDC * DC, int x, int y, + int StAngle, int EndAngle, int r, int Color, int BgColor) +{ + GRSFilledArc(ClipBox, DC, GRMapX(x), GRMapY(y), + StAngle, EndAngle, + ZoomValue(r), Color, BgColor); +} + +/********************************************************************/ +/* Routine to draw an arc, in drawing space. */ +/* As the Y axes is inverted the Angles should be inverted as well. */ +/********************************************************************/ +void GRArc(EDA_Rect * ClipBox,wxDC * DC, int xc, int yc, int StAngle, + int EndAngle, int r, int Color) +{ +int x1, y1, x2, y2; + + /* suppression des cercles hors ecran */ + if ( ClipBox ) + { + int rayon = ZoomValue(r) + 1; + int x0, y0, xm, ym, x, y; + x0 = ClipBox->GetX(); + y0 = ClipBox->GetY(); + xm = ClipBox->GetRight(); + ym = ClipBox->GetBottom(); + x = GRMapX(xc); y = GRMapY(yc); + if ( x < (x0 - rayon) ) return; + if ( y < (y0 - rayon) ) return; + if ( x > (xm + rayon) ) return; + if ( y > (ym + rayon) ) return; + } + + x1 = r; y1 = 0; + RotatePoint( &x1, & y1, EndAngle); + + x2 = r; y2 = 0; + RotatePoint( &x2, & y2, StAngle); + + GRSetColorPen(DC, Color); + GRSetBrush(DC,Color,FALSE); + DC->DrawArc(GRMapX(xc + x1), GRMapY(yc - y1), + GRMapX(xc + x2), GRMapY(yc - y2), + GRMapX(xc), GRMapY(yc) ); +} + +/********************************************************************/ +/* Routine to draw an arc, width = width, in drawing space. */ +/* As the Y axes is inverted the Angles should be inverted as well. */ +/********************************************************************/ +void GRArc(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int StAngle, int EndAngle, + int r, int width, int Color) +{ + GRSArc(ClipBox, DC, GRMapX(x), GRMapY(y), + StAngle, EndAngle, + ZoomValue(r), + ZoomValue(width), + Color); +} + +/**************************************************/ +/* Routine to draw a Rectangle, in drawing space. */ +/**************************************************/ +void GRRect(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + x1 = GRMapX(x1); y1 = GRMapY(y1); + x2 = GRMapX(x2); y2 = GRMapY(y2); + + GRSRect(ClipBox, DC, x1, y1, x2, y2, Color ); +} + +/************************************************************************************/ +void GRFilledRect(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int Color, int BgColor) +/************************************************************************************/ +/* Routine to draw a Rectangle (filled with AreaColor), in drawing space. */ +{ + x1 = GRMapX(x1); y1 = GRMapY(y1); + x2 = GRMapX(x2); y2 = GRMapY(y2); + + GRSFilledRect(ClipBox, DC, x1, y1, x2, y2, Color, BgColor ); +} + + +/*************************************************/ +/* Routine to draw a Rectangle, in screen space. */ +/*************************************************/ +void GRSRect(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, int Color) +{ + if(x1 > x2) EXCHG(x1,x2); + if(y1 > y2) EXCHG(y1,y2); + + /* Clipping des coordonnees */ + if ( ClipBox ) + { + int xmin = ClipBox->GetX(); + int ymin = ClipBox->GetY(); + int xmax = ClipBox->GetRight(); + int ymax = ClipBox->GetBottom(); + + if ( x1 > xmax ) return; + if ( x2 < xmin ) return; + if ( y1 > ymax ) return; + if ( y2 < ymin ) return; + } + + GRSetColorPen(DC, Color ); + if ( (x1 == x2) || (y1 == y2) ) DC->DrawLine(x1, y1, x2, y2); + else + { + GRSetBrush(DC, BLACK ); + DC->DrawRectangle(x1, y1, x2 - x1, y2 - y1); + } +} + + +/***************************************************************************************/ +void GRSFilledRect(EDA_Rect * ClipBox,wxDC * DC, int x1, int y1, int x2, int y2, + int Color, int BgColor) +/***************************************************************************************/ +/* Routine to draw a Filled Rectangle, in screen space. */ +{ + if(x1 > x2) EXCHG(x1,x2); + if(y1 > y2) EXCHG(y1,y2); + if ( ClipBox ) + { + int xmin = ClipBox->GetX(); + int ymin = ClipBox->GetY(); + int xmax = ClipBox->GetRight(); + int ymax = ClipBox->GetBottom(); + + if ( x1 > xmax ) return; + if ( x2 < xmin ) return; + if ( y1 > ymax ) return; + if ( y2 < ymin ) return; + + // Clipping des coordonnees + if ( x1 < xmin )x1 = xmin -1; + if ( y1 < ymin )y1 = ymin -1; + if ( x2 > xmax ) x2 = xmax +1; + if ( y2 > ymax ) y2 = ymax +1; + } + + GRSetColorPen(DC, Color ); + if ( (x1 == x2) || (y1 == y2) ) DC->DrawLine(x1, y1, x2, y2); + else + { + GRSetBrush(DC, BgColor, FILLED); + DC->DrawRectangle(x1, y1, x2 - x1, y2 - y1); + } +} + + + /****************************************/ + /* Routines relatives au trace de texte */ + /****************************************/ + + /*********************************************/ + /* Routine de selection de la fonte courante */ + /*********************************************/ + +void GRSetFont(wxDC * DC, wxFont * Font) +{ + DC->SetFont(*Font); +} + + /*********************************************************/ + /* void GRSetTextFgColor(wxFont * Font, int Color) */ + /*********************************************************/ + +/* Mise a la valeur Color des textes a afficher */ +void GRSetTextFgColor(wxDC * DC, int Color) +{ + DC->SetTextForeground(wxColour( + ColorRefs[Color].m_Red, + ColorRefs[Color].m_Green, + ColorRefs[Color].m_Blue) + ); +} + +/* Mise a la valeur Color des textes a afficher */ +void GRSetTextFgColor(wxDC * DC, wxFont *, int Color) +{ + DC->SetTextForeground(wxColour( + ColorRefs[Color].m_Red, + ColorRefs[Color].m_Green, + ColorRefs[Color].m_Blue) + ); +} + + +/*****************************************************************************/ +void GRGetTextExtent(wxDC * DC, const wxChar * Text, long * width, long * height) +/*****************************************************************************/ +/* donne la taille du rectangle d'encadrement du texte Text +*/ +{ +long w = 0, h = 0; + + if ( Text ) + { + DC->GetTextExtent(Text, &w, &h ); + } + if ( width ) *width = w; + if ( height ) * height = h; +} + + /********************************/ + /* void GRReseTextFgColor(void) */ + /********************************/ + +/* Mise a la couleur par defaut des textes a afficher */ +void GRResetTextFgColor(wxDC * DC) +{ + GRSetTextFgColor(DC, Text_Color); +} + + + /*********************************************************/ + /* void GRSetTextBgColor(wxFont * Font, int Color) */ + /*********************************************************/ + +/* Mise a la valeur Color du fond pour les textes a afficher */ +void GRSetTextBgColor(wxDC * DC, int Color) +{ + Color &= MASKCOLOR; // Pour 32 couleurs Max + DC->SetTextBackground(wxColour( + ColorRefs[Color].m_Red, + ColorRefs[Color].m_Green, + ColorRefs[Color].m_Blue) + ); +} + +void GRSetTextBgColor(wxDC * DC, wxFont *, int Color) +{ + Color &= MASKCOLOR; // Pour 32 couleurs Max + DC->SetTextBackground(wxColour( + ColorRefs[Color].m_Red, + ColorRefs[Color].m_Green, + ColorRefs[Color].m_Blue) + ); +} + diff --git a/share/infospgm.cpp b/share/infospgm.cpp new file mode 100644 index 0000000000..15944576e9 --- /dev/null +++ b/share/infospgm.cpp @@ -0,0 +1,63 @@ + /****************************************************/ + /* Affichage du panneau d'information (copyright..) */ + /* Commun a CVPCB, EESCHEMA et PCBNEW */ + /****************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "common.h" + +// Import: +extern wxString g_Main_Title; + +wxString MsgInfos( +#ifdef GERBVIEW +wxT("** GERBVIEW (jul 2001 .. 2006) **") +#else +#ifdef PCBNEW +wxT("** PCBNEW (sept 1992 .. 2006) **") +#endif +#endif + +#ifdef CVPCB +wxT("** CVPCB (sept 1992 .. 2006) **") +#endif + +#ifdef KICAD +wxT("** KICAD (jul 2000 .. 2006) **") +#endif + +#ifdef EESCHEMA +wxT("** EESCHEMA (sept 1994 .. 2006) **") +#endif +); + +/* Routines Locales */ + +/*******************************************/ +void Print_Kicad_Infos(wxWindow * frame) +/*******************************************/ +{ +wxString Msg = MsgInfos; + Msg << wxT("\n\n") << _("Build Version:") << wxT("\n") ; + + Msg << g_Main_Title << wxT(" ") << GetBuildVersion(); +#if wxUSE_UNICODE + Msg << wxT(" - Unicode version"); +#else + Msg << wxT(" - Ansi version"); +#endif + Msg << wxT("\n\n") << _("Author:"); + Msg << wxT("JP CHARRAS\n\n") << _("Based on wxWidgets "); + Msg << wxMAJOR_VERSION << wxT(".") << + wxMINOR_VERSION << wxT(".") << wxRELEASE_NUMBER; + if ( wxSUBRELEASE_NUMBER ) + Msg << wxT(".") << wxSUBRELEASE_NUMBER; + Msg << _("\n\nGPL License"); + Msg << _("\n\nWeb sites:\n"); + Msg << wxT("http://iut-tice.ujf-grenoble.fr/kicad/\n"); + Msg << wxT("http://www.lis.inpg.fr/realise_au_lis/kicad/"); + + wxMessageBox(Msg, wxEmptyString, wxICON_INFORMATION, frame); +} + diff --git a/share/selcolor.cpp b/share/selcolor.cpp new file mode 100644 index 0000000000..1f34117c87 --- /dev/null +++ b/share/selcolor.cpp @@ -0,0 +1,162 @@ + /************************/ + /* SETCOLOR.CPP */ + /************************/ +/* Affichage et selection de la palette des couleurs disponibles +dans une frame +*/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "colors.h" + + +enum colors_id { + ID_COLOR_BLACK = 2000, // ID_COLOR_ = ID_COLOR_BLACK a ID_COLOR_BLACK + 31 +}; + + +/*******************************************/ +class WinEDA_SelColorFrame: public wxDialog +/*******************************************/ +/* Frame d'affichage de la palette des couleurs disponibles +*/ +{ +private: +public: + + // Constructor and destructor + WinEDA_SelColorFrame(wxWindow *parent, const wxPoint& framepos); + ~WinEDA_SelColorFrame(void) {}; + +private: + void SelColor(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() + +}; +/* Construction de la table des evenements pour FrameClassMain */ +BEGIN_EVENT_TABLE(WinEDA_SelColorFrame, wxDialog) + EVT_BUTTON(ID_COLOR_BLACK, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+1, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+2, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+3, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+4, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+5, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+6, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+7, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+8, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+9, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+10, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+11, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+12, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+13, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+14, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+15, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+16, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+17, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+18, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+19, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+20, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+21, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+22, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+23, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+24, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+25, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+26, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+27, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+28, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+29, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+30, WinEDA_SelColorFrame::SelColor) + EVT_BUTTON(ID_COLOR_BLACK+31, WinEDA_SelColorFrame::SelColor) +END_EVENT_TABLE() + +/***************************************/ +int DisplayColorFrame(wxWindow * parent) +/***************************************/ +{ +wxPoint framepos; +int color; + + wxGetMousePosition(&framepos.x, &framepos.y); + + WinEDA_SelColorFrame * frame = new WinEDA_SelColorFrame(parent,framepos); + color = frame->ShowModal(); frame->Destroy(); + if (color > NBCOLOR) color = -1; + return color; +} + +/*******************************************************************/ +WinEDA_SelColorFrame::WinEDA_SelColorFrame(wxWindow *parent, + const wxPoint& framepos): + wxDialog(parent, -1, _("Colors"), framepos, wxSize(375, 240), + DIALOG_STYLE ) +/*******************************************************************/ +{ +#define START_Y 10 +wxBitmapButton * Button; +int ii, yy, butt_ID, buttcolor; +wxPoint pos; +int w = 20, h = 20; + + SetFont(*g_DialogFont); + + SetReturnCode(-1); + + pos.x = 5; pos.y = START_Y; + for ( ii = 0; ColorRefs[ii].m_Name != NULL ; ii++ ) + { + butt_ID = ID_COLOR_BLACK + ii; + wxMemoryDC iconDC; + wxBitmap ButtBitmap(w,h); + wxBrush Brush; + iconDC.SelectObject( ButtBitmap ); + buttcolor = ColorRefs[ii].m_Numcolor; + iconDC.SetPen(*wxBLACK_PEN); + Brush.SetColour( + ColorRefs[buttcolor].m_Red, + ColorRefs[buttcolor].m_Green, + ColorRefs[buttcolor].m_Blue + ); + Brush.SetStyle(wxSOLID); + + iconDC.SetBrush(Brush); + iconDC.SetBackground(*wxGREY_BRUSH); + iconDC.Clear(); + iconDC.DrawRoundedRectangle(0,0, w, h, (double)h/3); + + Button = new wxBitmapButton(this, butt_ID, + ButtBitmap, + wxPoint(pos.x, pos.y), wxSize(w,h) ); + + new wxStaticText(this,-1, + ColorRefs[ii].m_Name, + wxPoint(pos.x + 2 + w , pos.y + 4 ), + wxSize(-1,-1), 0 ); + + yy = h + 5; + pos.y += yy; + if ( ii == 7 ) + { + pos.x += w + 80; pos.y = START_Y; + } + else if ( (ii == 15) || (ii == 23) ) + { + pos.x += w + 110; pos.y = START_Y; + } + } +} + + +/*********************************************************/ +void WinEDA_SelColorFrame::SelColor(wxCommandEvent& event) +/*********************************************************/ +{ +int id = event.GetId(); + + EndModal(id - ID_COLOR_BLACK); +} + + + diff --git a/share/setpage.cpp b/share/setpage.cpp new file mode 100644 index 0000000000..c538f4504f --- /dev/null +++ b/share/setpage.cpp @@ -0,0 +1,498 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: setpage.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 06/02/2006 20:53:09 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 06/02/2006 20:53:09 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "setpage.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" + +#ifdef EESCHEMA +#include "program.h" +#include "general.h" +#endif + +#define NB_ITEMS 11 +Ki_PageDescr * SheetList[NB_ITEMS+1] = +{ + &g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2, &g_Sheet_A1, &g_Sheet_A0, + &g_Sheet_A, &g_Sheet_B, &g_Sheet_C, &g_Sheet_D, &g_Sheet_E, + &g_Sheet_user, NULL +}; + +#include "setpage.h" + +////@begin XPM images +////@end XPM images + +/******************************************************************/ +void WinEDA_DrawFrame::Process_PageSettings(wxCommandEvent& event) +/******************************************************************/ +/* Creation de la fenetre de configuration +*/ +{ + WinEDA_SetPageFrame frame(this); + frame.ShowModal(); + ReDrawPanel(); +} + +/*! + * WinEDA_SetPageFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_SetPageFrame, wxDialog ) + +/*! + * WinEDA_SetPageFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_SetPageFrame, wxDialog ) + +////@begin WinEDA_SetPageFrame event table entries + EVT_CLOSE( WinEDA_SetPageFrame::OnCloseWindow ) + + EVT_BUTTON( wxID_OK, WinEDA_SetPageFrame::OnOkClick ) + + EVT_BUTTON( wxID_CANCEL, WinEDA_SetPageFrame::OnCancelClick ) + +////@end WinEDA_SetPageFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_SetPageFrame constructors + */ + +WinEDA_SetPageFrame::WinEDA_SetPageFrame( ) +{ +} + +WinEDA_SetPageFrame::WinEDA_SetPageFrame( WinEDA_DrawFrame* parent, wxWindowID id, + const wxString& caption, const wxPoint& pos, + const wxSize& size, long style ) +{ +wxString msg; + + m_ParentDrawFrame = parent; + m_Screen = m_ParentDrawFrame->m_CurrentScreen; + m_Modified = FALSE; + m_SelectedSheet = NULL; + m_CurrentSelection = 0; + SearchPageSizeSelection(); + Create(parent, id, caption, pos, size, style); + // Init display value for sheet User size + wxString format = m_TextSheetCount->GetLabel(); + msg.Printf(format, m_Screen->m_NumberOfSheet); + m_TextSheetCount->SetLabel(msg); + format = m_TextSheetNumber->GetLabel(); + msg.Printf(format, m_Screen->m_SheetNumber); + m_TextSheetNumber->SetLabel(msg); + if ( g_UnitMetric ) + { + UserSizeX = (double)g_Sheet_user.m_Size.x * 25.4 / 1000 ; + UserSizeY = (double)g_Sheet_user.m_Size.y * 25.4 / 1000; + msg.Printf( wxT("%.2f"), UserSizeX); + m_TextUserSizeX->SetValue(msg); + msg.Printf( wxT("%.2f"), UserSizeY); + m_TextUserSizeY->SetValue(msg); + } + else + { + UserSizeX = (double)g_Sheet_user.m_Size.x / 1000; + UserSizeY = (double)g_Sheet_user.m_Size.y / 1000; + msg.Printf( wxT("%.3f"), UserSizeX ); + m_TextUserSizeX->SetValue(msg); + msg.Printf( wxT("%.3f"), UserSizeY ); + m_TextUserSizeY->SetValue(msg); + } +} + +/*! + * WinEDA_SetPageFrame creator + */ + +bool WinEDA_SetPageFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_SetPageFrame member initialisation + m_PageSizeBox = NULL; + m_TextUserSizeX = NULL; + m_TextUserSizeY = NULL; + m_TextSheetCount = NULL; + m_TextSheetNumber = NULL; + m_RevisionSizer = NULL; + m_TextRevision = NULL; + m_NameSizer = NULL; + m_TextTitle = NULL; + m_CompanySizer = NULL; + m_TextCompany = NULL; + m_Comment1Sizer = NULL; + m_TextComment1 = NULL; + m_Comment2Sizer = NULL; + m_TextComment2 = NULL; + m_Comment3Sizer = NULL; + m_TextComment3 = NULL; + m_Comment4Sizer = NULL; + m_TextComment4 = NULL; +////@end WinEDA_SetPageFrame member initialisation + +////@begin WinEDA_SetPageFrame creation + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + if (GetSizer()) + { + GetSizer()->SetSizeHints(this); + } + Centre(); +////@end WinEDA_SetPageFrame creation + return true; +} + +/*! + * Control creation for WinEDA_SetPageFrame + */ + +void WinEDA_SetPageFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_SetPageFrame content construction + // Generated by DialogBlocks, 11/01/2007 11:38:01 (unregistered) + + WinEDA_SetPageFrame* itemDialog1 = this; + + this->SetForegroundColour(wxColour(0, 128, 64)); + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5); + + wxString m_PageSizeBoxStrings[] = { + _("Size A4"), + _("Size A3"), + _("Size A2"), + _("Size A1"), + _("Size A0"), + _("Size A"), + _("Size B"), + _("Size C"), + _("Size D"), + _("Size E"), + _("User size") + }; + m_PageSizeBox = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Page Size:"), wxDefaultPosition, wxDefaultSize, 11, m_PageSizeBoxStrings, 1, wxRA_SPECIFY_COLS ); + m_PageSizeBox->SetSelection(0); + itemBoxSizer3->Add(m_PageSizeBox, 0, wxGROW|wxALL, 5); + + wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("User Page Size X: "), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(itemStaticText5, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_TextUserSizeX = new wxTextCtrl( itemDialog1, ID_TEXTCTRL7, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(m_TextUserSizeX, 0, wxALIGN_LEFT|wxALL, 5); + + wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _("User Page Size Y: "), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(itemStaticText7, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_TextUserSizeY = new wxTextCtrl( itemDialog1, ID_TEXTCTRL8, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer3->Add(m_TextUserSizeY, 0, wxALIGN_LEFT|wxALL, 5); + + wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer9->Add(itemBoxSizer10, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxButton* itemButton11 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton11->SetDefault(); + itemButton11->SetForegroundColour(wxColour(200, 0, 0)); + itemBoxSizer10->Add(itemButton11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxButton* itemButton12 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton12->SetForegroundColour(wxColour(0, 0, 255)); + itemBoxSizer10->Add(itemButton12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer9->Add(itemBoxSizer13, 0, wxGROW|wxALL, 5); + + m_TextSheetCount = new wxStaticText( itemDialog1, wxID_STATIC, _("Number of sheets: %d"), wxDefaultPosition, wxDefaultSize, 0 ); + m_TextSheetCount->SetForegroundColour(wxColour(128, 0, 128)); + itemBoxSizer13->Add(m_TextSheetCount, 0, wxGROW|wxALL|wxADJUST_MINSIZE, 5); + + itemBoxSizer13->Add(5, 5, 0, wxGROW|wxALL, 5); + + m_TextSheetNumber = new wxStaticText( itemDialog1, wxID_STATIC, _("Sheet number: %d"), wxDefaultPosition, wxDefaultSize, 0 ); + m_TextSheetNumber->SetForegroundColour(wxColour(128, 0, 128)); + itemBoxSizer13->Add(m_TextSheetNumber, 0, wxGROW|wxALL|wxADJUST_MINSIZE, 5); + + wxStaticBox* itemStaticBoxSizer17Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Revision:")); + m_RevisionSizer = new wxStaticBoxSizer(itemStaticBoxSizer17Static, wxHORIZONTAL); + itemStaticBoxSizer17Static->SetForegroundColour(wxColour(200, 0, 0)); + itemBoxSizer9->Add(m_RevisionSizer, 0, wxGROW, 5); + + m_TextRevision = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(100, -1), wxTE_RICH ); + m_RevisionSizer->Add(m_TextRevision, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxStaticBox* itemStaticBoxSizer19Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Title:")); + m_NameSizer = new wxStaticBoxSizer(itemStaticBoxSizer19Static, wxHORIZONTAL); + itemStaticBoxSizer19Static->SetForegroundColour(wxColour(200, 0, 0)); + itemBoxSizer9->Add(m_NameSizer, 0, wxALIGN_CENTER_HORIZONTAL, 5); + + m_TextTitle = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T(""), wxDefaultPosition, wxSize(400, -1), 0 ); + m_NameSizer->Add(m_TextTitle, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer21Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Company:")); + m_CompanySizer = new wxStaticBoxSizer(itemStaticBoxSizer21Static, wxHORIZONTAL); + itemStaticBoxSizer21Static->SetForegroundColour(wxColour(200, 0, 0)); + itemBoxSizer9->Add(m_CompanySizer, 0, wxGROW, 5); + + m_TextCompany = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxSize(400, -1), 0 ); + m_CompanySizer->Add(m_TextCompany, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxStaticBox* itemStaticBoxSizer23Static = new wxStaticBox(itemDialog1, wxID_STATIC, _("Comment1:")); + m_Comment1Sizer = new wxStaticBoxSizer(itemStaticBoxSizer23Static, wxHORIZONTAL); + itemStaticBoxSizer23Static->SetForegroundColour(wxColour(196, 0, 100)); + itemBoxSizer9->Add(m_Comment1Sizer, 0, wxGROW|wxADJUST_MINSIZE, 5); + + m_TextComment1 = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T(""), wxDefaultPosition, wxSize(400, -1), 0 ); + m_Comment1Sizer->Add(m_TextComment1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxStaticBox* itemStaticBoxSizer25Static = new wxStaticBox(itemDialog1, wxID_STATIC, _("Comment2:")); + m_Comment2Sizer = new wxStaticBoxSizer(itemStaticBoxSizer25Static, wxHORIZONTAL); + itemStaticBoxSizer25Static->SetForegroundColour(wxColour(196, 0, 100)); + itemBoxSizer9->Add(m_Comment2Sizer, 0, wxGROW|wxADJUST_MINSIZE, 5); + + m_TextComment2 = new wxTextCtrl( itemDialog1, ID_TEXTCTRL4, _T(""), wxDefaultPosition, wxSize(400, -1), 0 ); + m_Comment2Sizer->Add(m_TextComment2, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxStaticBox* itemStaticBoxSizer27Static = new wxStaticBox(itemDialog1, wxID_STATIC, _("Comment3:")); + m_Comment3Sizer = new wxStaticBoxSizer(itemStaticBoxSizer27Static, wxHORIZONTAL); + itemStaticBoxSizer27Static->SetForegroundColour(wxColour(196, 0, 100)); + itemBoxSizer9->Add(m_Comment3Sizer, 0, wxGROW|wxADJUST_MINSIZE, 5); + + m_TextComment3 = new wxTextCtrl( itemDialog1, ID_TEXTCTRL5, _T(""), wxDefaultPosition, wxSize(400, -1), 0 ); + m_Comment3Sizer->Add(m_TextComment3, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + wxStaticBox* itemStaticBoxSizer29Static = new wxStaticBox(itemDialog1, wxID_STATIC, _("Comment4:")); + m_Comment4Sizer = new wxStaticBoxSizer(itemStaticBoxSizer29Static, wxHORIZONTAL); + itemStaticBoxSizer29Static->SetForegroundColour(wxColour(196, 0, 100)); + itemBoxSizer9->Add(m_Comment4Sizer, 0, wxGROW|wxADJUST_MINSIZE, 5); + + m_TextComment4 = new wxTextCtrl( itemDialog1, ID_TEXTCTRL6, _T(""), wxDefaultPosition, wxSize(400, -1), 0 ); + m_Comment4Sizer->Add(m_TextComment4, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5); + + // Set validators + m_PageSizeBox->SetValidator( wxGenericValidator(& m_CurrentSelection) ); + m_TextRevision->SetValidator( wxTextValidator(wxFILTER_NONE, & m_Screen->m_Revision) ); + m_TextTitle->SetValidator( wxTextValidator(wxFILTER_NONE, & m_Screen->m_Title) ); + m_TextCompany->SetValidator( wxTextValidator(wxFILTER_NONE, & m_Screen->m_Company) ); + m_TextComment1->SetValidator( wxTextValidator(wxFILTER_NONE, & m_Screen->m_Commentaire1) ); + m_TextComment2->SetValidator( wxTextValidator(wxFILTER_NONE, & m_Screen->m_Commentaire2) ); + m_TextComment3->SetValidator( wxTextValidator(wxFILTER_NONE, & m_Screen->m_Commentaire3) ); + m_TextComment4->SetValidator( wxTextValidator(wxFILTER_NONE, & m_Screen->m_Commentaire4) ); +////@end WinEDA_SetPageFrame content construction + +#ifdef EESCHEMA + m_RevisionExport = new wxCheckBox(this, -1,_("Export to other sheets")); + m_RevisionSizer->Add(m_RevisionExport, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxBOTTOM, 5); + m_TitleExport = new wxCheckBox(this, -1,_("Export to other sheets")); + m_NameSizer->Add(m_TitleExport, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxBOTTOM, 5); + m_CompanyExport = new wxCheckBox(this, -1,_("Export to other sheets")); + m_CompanySizer->Add(m_CompanyExport, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxBOTTOM, 5); + m_Comment1Export = new wxCheckBox(this, -1,_("Export to other sheets")); + m_Comment1Sizer->Add(m_Comment1Export, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxBOTTOM, 5); + m_Comment2Export = new wxCheckBox(this, -1,_("Export to other sheets")); + m_Comment2Sizer->Add(m_Comment2Export, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxBOTTOM, 5); + m_Comment3Export = new wxCheckBox(this, -1,_("Export to other sheets")); + m_Comment3Sizer->Add(m_Comment3Export, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxBOTTOM, 5); + m_Comment4Export = new wxCheckBox(this, -1,_("Export to other sheets")); + m_Comment4Sizer->Add(m_Comment4Export, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxBOTTOM, 5); +#else + m_RevisionExport = NULL; + m_TitleExport = NULL; + m_CompanyExport = NULL; + m_Comment1Export = NULL; + m_Comment2Export = NULL; + m_Comment3Export = NULL; + m_Comment4Export = NULL; +#endif +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_SetPageFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_SetPageFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_SetPageFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_SetPageFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_SetPageFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_SetPageFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_SetPageFrame icon retrieval +} +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + */ + +void WinEDA_SetPageFrame::OnOkClick( wxCommandEvent& event ) +{ + SavePageSettings(event); + Close(TRUE); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void WinEDA_SetPageFrame::OnCancelClick( wxCommandEvent& event ) +{ + Close(TRUE); +} + + +/*****************************************************************/ +void WinEDA_SetPageFrame::SavePageSettings(wxCommandEvent& event) +/*****************************************************************/ +/* Mise a jour effective des textes et dimensions +*/ +{ +double dtmp; +wxString msg; + + m_Screen->m_Revision = m_TextRevision->GetValue(); + m_Screen->m_Company = m_TextCompany->GetValue(); + m_Screen->m_Title = m_TextTitle->GetValue(); + m_Screen->m_Commentaire1 = m_TextComment1->GetValue(); + m_Screen->m_Commentaire2 = m_TextComment2->GetValue(); + m_Screen->m_Commentaire3 = m_TextComment3->GetValue(); + m_Screen->m_Commentaire4 = m_TextComment4->GetValue(); + + msg = m_TextUserSizeX->GetValue(); + msg.ToDouble(&dtmp); UserSizeX = dtmp; + msg = m_TextUserSizeY->GetValue(); + msg.ToDouble(&dtmp); UserSizeY = dtmp; + + int ii = m_PageSizeBox->GetSelection(); + if ( ii < 0 ) ii = 0; + m_SelectedSheet = SheetList[ii]; + m_Screen->m_CurrentSheet = m_SelectedSheet; + + if ( g_UnitMetric ) + { + g_Sheet_user.m_Size.x = (int)(UserSizeX * 1000 / 25.4 ); + g_Sheet_user.m_Size.y = (int)(UserSizeY * 1000 / 25.4 ); + } + else + { + g_Sheet_user.m_Size.x = (int)(UserSizeX * 1000 ); + g_Sheet_user.m_Size.y = (int)(UserSizeY * 1000 ); + } + + if ( g_Sheet_user.m_Size.x < 6000 )g_Sheet_user.m_Size.x = 6000; + if ( g_Sheet_user.m_Size.x > 44000 )g_Sheet_user.m_Size.x = 44000; + if ( g_Sheet_user.m_Size.y < 4000 )g_Sheet_user.m_Size.y = 4000; + if ( g_Sheet_user.m_Size.y > 44000 )g_Sheet_user.m_Size.y = 44000; + +#ifdef EESCHEMA + /* Exports settings to other sheets if requested: */ + SCH_SCREEN * screen; + /* Build the screen list */ + EDA_ScreenList ScreenList(NULL); + /* Update the datas */ + for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) + { + if (screen == m_Screen ) continue; + if ( m_RevisionExport->IsChecked() ) screen->m_Revision = m_Screen->m_Revision; + if ( m_TitleExport->IsChecked() ) screen->m_Title =m_Screen->m_Title; + if ( m_CompanyExport->IsChecked() ) screen->m_Company = m_Screen->m_Company; + if ( m_Comment1Export->IsChecked() ) screen->m_Commentaire1 = m_Screen->m_Commentaire1; + if ( m_Comment2Export->IsChecked() ) screen->m_Commentaire2 = m_Screen->m_Commentaire2; + if ( m_Comment3Export->IsChecked() ) screen->m_Commentaire3 = m_Screen->m_Commentaire3; + if ( m_Comment4Export->IsChecked() ) screen->m_Commentaire4 = m_Screen->m_Commentaire4; + } + +#endif + + m_Screen->SetModify(); + m_Screen->SetRefreshReq(); +} + + + +/*******************************************************/ +void WinEDA_SetPageFrame::SearchPageSizeSelection(void) +/*******************************************************/ +/* Search the correct index to activate the radiobox list size selection + according to the current page size +*/ +{ +Ki_PageDescr * sheet; +int ii; + + m_CurrentSelection = NB_ITEMS-1; + for( ii = 0; ii < NB_ITEMS; ii++ ) + { + sheet = SheetList[ii]; + if( m_ParentDrawFrame->m_CurrentScreen->m_CurrentSheet == sheet ) + m_CurrentSelection = ii; + } +} + +/*! + * wxEVT_CLOSE_WINDOW event handler for ID_DIALOG + */ + +void WinEDA_SetPageFrame::OnCloseWindow( wxCloseEvent& event ) +{ + EndModal(m_Modified); +} + + diff --git a/share/setpage.h b/share/setpage.h new file mode 100644 index 0000000000..9a6467cefa --- /dev/null +++ b/share/setpage.h @@ -0,0 +1,160 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: setpage.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 06/02/2006 20:53:09 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 06/02/2006 20:53:09 + +#ifndef _SETPAGE_H_ +#define _SETPAGE_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "setpage.h" +#endif + +/*! + * Includes + */ + +////@begin includes +#include "wx/valgen.h" +#include "wx/valtext.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define ID_RADIOBOX 10001 +#define ID_TEXTCTRL7 10009 +#define ID_TEXTCTRL8 10010 +#define ID_TEXTCTRL 10002 +#define ID_TEXTCTRL2 10004 +#define ID_TEXTCTRL1 10003 +#define ID_TEXTCTRL3 10005 +#define ID_TEXTCTRL4 10006 +#define ID_TEXTCTRL5 10007 +#define ID_TEXTCTRL6 10008 +#define SYMBOL_WINEDA_SETPAGEFRAME_STYLE wxDEFAULT_DIALOG_STYLE +#define SYMBOL_WINEDA_SETPAGEFRAME_TITLE _("Page Settings") +#define SYMBOL_WINEDA_SETPAGEFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_SETPAGEFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_SETPAGEFRAME_POSITION wxDefaultPosition +////@end control identifiers + +/*! + * Compatibility + */ + +/*! + * WinEDA_SetPageFrame class declaration + */ + +class WinEDA_SetPageFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_SetPageFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_SetPageFrame( ); + WinEDA_SetPageFrame( WinEDA_DrawFrame* parent, + wxWindowID id = SYMBOL_WINEDA_SETPAGEFRAME_IDNAME, + const wxString& caption = SYMBOL_WINEDA_SETPAGEFRAME_TITLE, + const wxPoint& pos = SYMBOL_WINEDA_SETPAGEFRAME_POSITION, + const wxSize& size = SYMBOL_WINEDA_SETPAGEFRAME_SIZE, + long style = SYMBOL_WINEDA_SETPAGEFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_SETPAGEFRAME_IDNAME, + const wxString& caption = SYMBOL_WINEDA_SETPAGEFRAME_TITLE, + const wxPoint& pos = SYMBOL_WINEDA_SETPAGEFRAME_POSITION, + const wxSize& size = SYMBOL_WINEDA_SETPAGEFRAME_SIZE, + long style = SYMBOL_WINEDA_SETPAGEFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_SetPageFrame event handler declarations + + /// wxEVT_CLOSE_WINDOW event handler for ID_DIALOG + void OnCloseWindow( wxCloseEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); + +////@end WinEDA_SetPageFrame event handler declarations + +////@begin WinEDA_SetPageFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_SetPageFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void SearchPageSizeSelection(void); + void SavePageSettings(wxCommandEvent& event); + void ReturnSizeSelected(wxCommandEvent& event); + +////@begin WinEDA_SetPageFrame member variables + wxRadioBox* m_PageSizeBox; + wxTextCtrl* m_TextUserSizeX; + wxTextCtrl* m_TextUserSizeY; + wxStaticText* m_TextSheetCount; + wxStaticText* m_TextSheetNumber; + wxStaticBoxSizer* m_RevisionSizer; + wxTextCtrl* m_TextRevision; + wxStaticBoxSizer* m_NameSizer; + wxTextCtrl* m_TextTitle; + wxStaticBoxSizer* m_CompanySizer; + wxTextCtrl* m_TextCompany; + wxStaticBoxSizer* m_Comment1Sizer; + wxTextCtrl* m_TextComment1; + wxStaticBoxSizer* m_Comment2Sizer; + wxTextCtrl* m_TextComment2; + wxStaticBoxSizer* m_Comment3Sizer; + wxTextCtrl* m_TextComment3; + wxStaticBoxSizer* m_Comment4Sizer; + wxTextCtrl* m_TextComment4; +////@end WinEDA_SetPageFrame member variables + wxCheckBox * m_RevisionExport; + wxCheckBox * m_TitleExport; + wxCheckBox * m_CompanyExport; + wxCheckBox * m_Comment1Export; + wxCheckBox * m_Comment2Export; + wxCheckBox * m_Comment3Export; + wxCheckBox * m_Comment4Export; + + WinEDA_DrawFrame *m_ParentDrawFrame; + BASE_SCREEN * m_Screen; + int m_Modified; + Ki_PageDescr * m_SelectedSheet; + float UserSizeX, UserSizeY; + int m_CurrentSelection; +}; + +#endif + // _SETPAGE_H_ diff --git a/share/setpage.pjd b/share/setpage.pjd new file mode 100644 index 0000000000..f83d53a9c7 --- /dev/null +++ b/share/setpage.pjd @@ -0,0 +1,1714 @@ + + +
+ 0 + "" + "" + "" + "" + 37 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 0 + 4 + " " + "" + 0 + 0 + 1 + 1 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "Page Settings" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "6/10/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "wxEVT_CLOSE_WINDOW|OnCloseWindow" + "ID_DIALOG" + 10000 + "WinEDA_SetPageFrame" + "wxDialog" + "wxDialog" + "setpage.cpp" + "setpage.h" + "" + "Page Settings" + 1 + "" + 0 + "" + "" + "" + "008040" + "" + 0 + 1 + "<Any platform>" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Horizontal" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "6/10/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxRadioBox: ID_RADIOBOX" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "6/10/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX" + 10001 + "wxRadioBox" + "m_PageSizeBox" + "Page Size:" + 1 + "Size A4|Size A3|Size A2|Size A1|Size A0|Size A|Size B|Size C|Size D|Size E|User size" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "m_CurrentSelection" + "wxGenericValidator(& %VARIABLE%)" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "6/9/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "User Page Size X: " + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL7" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "6/9/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL7" + 10009 + "wxTextCtrl" + "m_TextUserSizeX" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "6/9/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "User Page Size Y: " + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL8" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "6/9/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL8" + 10010 + "wxTextCtrl" + "m_TextUserSizeY" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "6/10/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "6/10/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxButton: wxID_OK" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "6/10/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnOkClick" + "wxID_OK" + 5100 + "wxButton" + "" + "&OK" + 1 + "" + "" + "" + "C80000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_CANCEL" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "6/10/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCancelClick" + "wxID_CANCEL" + 5101 + "wxButton" + "" + "&Cancel" + 0 + "" + "" + "" + "0000FF" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "6/10/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "6/10/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_TextSheetCount" + "Number of sheets: %d" + -1 + "" + "" + "" + "800080" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + "" + "" + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "6/10/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "6/10/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "m_TextSheetNumber" + "Sheet number: %d" + -1 + "" + "" + "" + "800080" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Expand" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + "" + "" + + + + "wxStaticBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "13/11/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + "Revision:" + "m_RevisionSizer" + "C80000" + "" + 0 + 1 + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxTextCtrl: ID_TEXTCTRL" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "14/11/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL" + 10002 + "wxTextCtrl" + "m_TextRevision" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "m_Screen->m_Revision" + "wxTextValidator(wxFILTER_NONE, & %VARIABLE%)" + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 100 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxStaticBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "13/11/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + -1 + "Title:" + "m_NameSizer" + "C80000" + "" + 0 + 1 + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxTextCtrl: ID_TEXTCTRL2" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "14/11/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL2" + 10004 + "wxTextCtrl" + "m_TextTitle" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "m_Screen->m_Title" + "wxTextValidator(wxFILTER_NONE, & %VARIABLE%)" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 400 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxStaticBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "13/11/2006" + "wbStaticBoxSizerProxy" + "wxID_ANY" + "-1" + "Company:" + "m_CompanySizer" + "C80000" + "" + 0 + 1 + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "<Any platform>" + + "wxTextCtrl: ID_TEXTCTRL1" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "14/11/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL1" + 10003 + "wxTextCtrl" + "m_TextCompany" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "m_Screen->m_Company" + "wxTextValidator(wxFILTER_NONE, & %VARIABLE%)" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 400 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxStaticBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "13/11/2006" + "wbStaticBoxSizerProxy" + "wxID_STATIC" + "-1" + "Comment1:" + "m_Comment1Sizer" + "C40064" + "" + 0 + 1 + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "<Any platform>" + + "wxTextCtrl: ID_TEXTCTRL3" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "14/11/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL3" + 10005 + "wxTextCtrl" + "m_TextComment1" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "m_Screen->m_Commentaire1" + "wxTextValidator(wxFILTER_NONE, & %VARIABLE%)" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 400 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxStaticBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "13/11/2006" + "wbStaticBoxSizerProxy" + "wxID_STATIC" + "-1" + "Comment2:" + "m_Comment2Sizer" + "C40064" + "" + 0 + 1 + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "<Any platform>" + + "wxTextCtrl: ID_TEXTCTRL4" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "13/11/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL4" + 10006 + "wxTextCtrl" + "m_TextComment2" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "m_Screen->m_Commentaire2" + "wxTextValidator(wxFILTER_NONE, & %VARIABLE%)" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 400 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxStaticBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "6/10/2006" + "wbStaticBoxSizerProxy" + "wxID_STATIC" + "-1" + "Comment3:" + "m_Comment3Sizer" + "C40064" + "" + 0 + 1 + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "<Any platform>" + + "wxTextCtrl: ID_TEXTCTRL5" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "13/11/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL5" + 10007 + "wxTextCtrl" + "m_TextComment3" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "m_Screen->m_Commentaire3" + "wxTextValidator(wxFILTER_NONE, & %VARIABLE%)" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 400 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + + "wxStaticBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "6/10/2006" + "wbStaticBoxSizerProxy" + "wxID_STATIC" + "-1" + "Comment4:" + "m_Comment4Sizer" + "C40064" + "" + 0 + 1 + "Horizontal" + "" + "Expand" + "Centre" + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "<Any platform>" + + "wxTextCtrl: ID_TEXTCTRL6" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "13/11/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL6" + 10008 + "wxTextCtrl" + "m_TextComment4" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "m_Screen->m_Commentaire4" + "wxTextValidator(wxFILTER_NONE, & %VARIABLE%)" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + 400 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + + + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "setpage.rc" + "source-editor-document" + "setpage.rc" + "source-editor" + 0 + 0 + 1 + 0 + "6/10/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/share/svg_print.cpp b/share/svg_print.cpp new file mode 100644 index 0000000000..42a0fea5c5 --- /dev/null +++ b/share/svg_print.cpp @@ -0,0 +1,512 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: svg_print.cpp +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 05/02/2006 11:05:19 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 05/02/2006 11:05:19 + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "svg_print.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +////@begin includes +////@end includes + +#include +#include "wx/metafile.h" +#include "wx/image.h" + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" + +#include "dcsvg.h" +#include "svg_print.h" + +#ifdef EESCHEMA +#include "program.h" +#endif + +////@begin XPM images +////@end XPM images + +extern BASE_SCREEN * ActiveScreen; +extern int PenMinWidth; /* dim mini (en 1/100 mmm) pour les traits imprimes */ + +#define WIDTH_MAX_VALUE 100 +#define WIDTH_MIN_VALUE 1 + +// Variables locales +static int Select_PrintAll = FALSE; +static bool Print_Sheet_Ref = TRUE; +static int s_PlotBlackAndWhite = 0; + + + +/*******************************************************/ +void WinEDA_DrawFrame::SVG_Print(wxCommandEvent& event) +/*******************************************************/ +/* Prepare les structures de donnees de gestion de l'impression +et affiche la fenetre de dialogue de gestion de l'impression des feuilles +*/ +{ + // Arret des commandes en cours + if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) + { + wxClientDC dc(DrawPanel); + DrawPanel->PrepareDC(dc); + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + SetToolID(0, wxCURSOR_ARROW,wxEmptyString); + +WinEDA_PrintSVGFrame frame(this); + frame.ShowModal(); +} + + +/*! + * WinEDA_PrintSVGFrame type definition + */ + +IMPLEMENT_DYNAMIC_CLASS( WinEDA_PrintSVGFrame, wxDialog ) + +/*! + * WinEDA_PrintSVGFrame event table definition + */ + +BEGIN_EVENT_TABLE( WinEDA_PrintSVGFrame, wxDialog ) + +////@begin WinEDA_PrintSVGFrame event table entries + EVT_CLOSE( WinEDA_PrintSVGFrame::OnCloseWindow ) + + EVT_SPINCTRL( ID_SPINCTRL, WinEDA_PrintSVGFrame::OnSpinctrlUpdated ) + + EVT_RADIOBOX( ID_RADIOBOX_SETPRINTMODE, WinEDA_PrintSVGFrame::OnRadioboxSetprintmodeSelected ) + + EVT_BUTTON( ID_PRINT_EXECUTE, WinEDA_PrintSVGFrame::OnPrintExecuteClick ) + + EVT_BUTTON( wxID_CLOSE, WinEDA_PrintSVGFrame::OnCloseClick ) + +////@end WinEDA_PrintSVGFrame event table entries + +END_EVENT_TABLE() + +/*! + * WinEDA_PrintSVGFrame constructors + */ + +WinEDA_PrintSVGFrame::WinEDA_PrintSVGFrame( ) +{ +} + +WinEDA_PrintSVGFrame::WinEDA_PrintSVGFrame( WinEDA_DrawFrame* parent, + wxWindowID id, const wxString& caption, const wxPoint& pos, + const wxSize& size, long style ) +{ + m_Parent = parent; + m_ImageXSize_mm = 270; + wxConfig * Config = m_Parent->m_Parent->m_EDA_Config; + if ( Config ) + { + Config->Read(wxT("PlotSVGPenWidth"), &PenMinWidth); + Config->Read(wxT("PlotSVGModeColor"), &s_PlotBlackAndWhite); + } + + Create(parent, id, caption, pos, size, style); +} + +/*! + * WinEDA_PrintSVGFrame creator + */ + +bool WinEDA_PrintSVGFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +{ +////@begin WinEDA_PrintSVGFrame member initialisation + m_ButtPenWidth = NULL; + m_ModeColorOption = NULL; + m_Print_Sheet_Ref = NULL; + m_PagesOption = NULL; + m_FileNameCtrl = NULL; + m_MessagesBox = NULL; +////@end WinEDA_PrintSVGFrame member initialisation + +////@begin WinEDA_PrintSVGFrame creation + SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + if (GetSizer()) + { + GetSizer()->SetSizeHints(this); + } + Centre(); +////@end WinEDA_PrintSVGFrame creation + return true; +} + +/*! + * Control creation for WinEDA_PrintSVGFrame + */ + +void WinEDA_PrintSVGFrame::CreateControls() +{ + SetFont(*g_DialogFont); + +////@begin WinEDA_PrintSVGFrame content construction + // Generated by DialogBlocks, 23/12/2006 12:58:00 (unregistered) + + WinEDA_PrintSVGFrame* itemDialog1 = this; + + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); + itemDialog1->SetSizer(itemBoxSizer2); + + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + + wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("Pen width mini"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer4->Add(itemStaticText5, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_ButtPenWidth = new wxSpinCtrl( itemDialog1, ID_SPINCTRL, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 100, 0 ); + itemBoxSizer4->Add(m_ButtPenWidth, 0, wxALIGN_LEFT|wxALL, 5); + + wxString m_ModeColorOptionStrings[] = { + _("Color"), + _("Black and White") + }; + m_ModeColorOption = new wxRadioBox( itemDialog1, ID_RADIOBOX_SETPRINTMODE, _("Print mode"), wxDefaultPosition, wxDefaultSize, 2, m_ModeColorOptionStrings, 1, wxRA_SPECIFY_COLS ); + m_ModeColorOption->SetSelection(0); + itemBoxSizer4->Add(m_ModeColorOption, 0, wxALIGN_LEFT|wxALL, 5); + + m_Print_Sheet_Ref = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Print Sheet Ref"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_Print_Sheet_Ref->SetValue(false); + itemBoxSizer4->Add(m_Print_Sheet_Ref, 0, wxALIGN_LEFT|wxALL, 5); + + itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 15); + + wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer3->Add(itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxString m_PagesOptionStrings[] = { + _("Current"), + _("All") + }; + m_PagesOption = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Page Print:"), wxDefaultPosition, wxDefaultSize, 2, m_PagesOptionStrings, 1, wxRA_SPECIFY_COLS ); + m_PagesOption->SetSelection(0); + itemBoxSizer10->Add(m_PagesOption, 0, wxALIGN_LEFT|wxALL, 5); + + wxButton* itemButton12 = new wxButton( itemDialog1, ID_PRINT_EXECUTE, _("Create &File"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton12->SetDefault(); + itemButton12->SetForegroundColour(wxColour(0, 128, 0)); + itemBoxSizer10->Add(itemButton12, 0, wxGROW|wxALL, 5); + + wxButton* itemButton13 = new wxButton( itemDialog1, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton13->SetForegroundColour(wxColour(0, 0, 198)); + itemBoxSizer10->Add(itemButton13, 0, wxGROW|wxALL, 5); + + wxStaticText* itemStaticText14 = new wxStaticText( itemDialog1, wxID_STATIC, _("Filename:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add(itemStaticText14, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_FileNameCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add(m_FileNameCtrl, 0, wxGROW|wxALL, 5); + + wxStaticText* itemStaticText16 = new wxStaticText( itemDialog1, wxID_STATIC, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add(itemStaticText16, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + m_MessagesBox = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxSize(-1, 100), wxTE_MULTILINE|wxTE_READONLY ); + itemBoxSizer2->Add(m_MessagesBox, 0, wxGROW|wxALL, 5); + + // Set validators + m_ButtPenWidth->SetValidator( wxGenericValidator(& PenMinWidth) ); + m_ModeColorOption->SetValidator( wxGenericValidator(& s_PlotBlackAndWhite) ); + m_Print_Sheet_Ref->SetValidator( wxGenericValidator(& Print_Sheet_Ref) ); +////@end WinEDA_PrintSVGFrame content construction +} + +/*! + * Should we show tooltips? + */ + +bool WinEDA_PrintSVGFrame::ShowToolTips() +{ + return true; +} + +/*! + * Get bitmap resources + */ + +wxBitmap WinEDA_PrintSVGFrame::GetBitmapResource( const wxString& name ) +{ + // Bitmap retrieval +////@begin WinEDA_PrintSVGFrame bitmap retrieval + wxUnusedVar(name); + return wxNullBitmap; +////@end WinEDA_PrintSVGFrame bitmap retrieval +} + +/*! + * Get icon resources + */ + +wxIcon WinEDA_PrintSVGFrame::GetIconResource( const wxString& name ) +{ + // Icon retrieval +////@begin WinEDA_PrintSVGFrame icon retrieval + wxUnusedVar(name); + return wxNullIcon; +////@end WinEDA_PrintSVGFrame icon retrieval +} + + +/******************************************************/ +wxString WinEDA_PrintSVGFrame::ReturnFullFileName(void) +/******************************************************/ +{ +wxString name, ext; + + name = m_Parent->m_CurrentScreen->m_FileName; + ChangeFileNameExt(name, wxT(".svg")); + return name; +} + + +/*********************************************************/ +void WinEDA_PrintSVGFrame::SetPenWidth(wxSpinEvent& event) +/*********************************************************/ +{ + PenMinWidth = m_ButtPenWidth->GetValue(); + if ( PenMinWidth > WIDTH_MAX_VALUE ) + { + PenMinWidth = WIDTH_MAX_VALUE; + wxBell(); + } + if ( PenMinWidth < WIDTH_MIN_VALUE ) + { + PenMinWidth = WIDTH_MIN_VALUE; + wxBell(); + } + m_ButtPenWidth->SetValue(PenMinWidth); +} + + + +/**************************************************************/ +void WinEDA_PrintSVGFrame::PrintSVGDoc(wxCommandEvent& event) +/**************************************************************/ +/* Called on activate "Print CURRENT" button +*/ +{ +bool print_ref = TRUE; +wxString msg; + + Select_PrintAll = FALSE; + if ( m_PagesOption && (m_PagesOption->GetSelection() == 1) ) + Select_PrintAll = TRUE; + + if ( (m_Print_Sheet_Ref == NULL) || (m_Print_Sheet_Ref->GetValue() == FALSE) ) + print_ref = FALSE; + +wxSpinEvent spinevent; + SetPenWidth(spinevent); + + +BASE_SCREEN * screen = m_Parent->m_CurrentScreen; +BASE_SCREEN *oldscreen = screen; + + if( Select_PrintAll ) + while ( screen->Pback ) screen = (BASE_SCREEN *) screen->Pback; + + if ( (m_Parent->m_Ident == PCB_FRAME) || (m_Parent->m_Ident == GERBER_FRAME) ) + { + if( Select_PrintAll ) + { + m_PrintMaskLayer = 0xFFFFFFFF; + } + else m_PrintMaskLayer = 1; + } + + if (screen == NULL) return; + +#ifdef EESCHEMA + if ( Select_PrintAll && m_Parent->m_Ident == SCHEMATIC_FRAME ) + { + EDA_ScreenList ScreenList(NULL); + + for ( SCH_SCREEN * schscreen = ScreenList.GetFirst(); schscreen != NULL; + schscreen = ScreenList.GetNext() ) + { + /* Create all files *.svg */ + m_Parent->m_CurrentScreen = (BASE_SCREEN *)schscreen; + ActiveScreen = screen; + wxString FullFileName = ReturnFullFileName(); + bool success = DrawPage(FullFileName); + msg = _("Create file ") + FullFileName; + if ( ! success ) msg += _(" error"); + msg += wxT("\n"); + m_MessagesBox->AppendText(msg); + } + } + else +#endif + { + ActiveScreen = screen; + wxString FullFileName = m_FileNameCtrl->GetValue(); + if ( FullFileName.IsEmpty() ) + FullFileName = ReturnFullFileName(); + bool success = DrawPage(FullFileName); + msg = _("Create file ") + FullFileName; + if ( ! success ) msg += _(" error"); + msg += wxT("\n"); + m_MessagesBox->AppendText(msg); + } + ActiveScreen = oldscreen; +} + +/*****************************************************************/ +bool WinEDA_PrintSVGFrame::DrawPage(const wxString & FullFileName) +/*****************************************************************/ +/* + Routine effective d'impression +*/ +{ +int tmpzoom; +wxPoint tmp_startvisu; +wxSize SheetSize; // Sheet size in internal units +wxPoint old_org; +float dpi; +bool success = TRUE; + + /* modification des cadrages et reglages locaux */ + tmp_startvisu = ActiveScreen->m_StartVisu; + tmpzoom = ActiveScreen->GetZoom(); + old_org = ActiveScreen->m_DrawOrg; + ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0; + ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.y = 0; + SheetSize = ActiveScreen->m_CurrentSheet->m_Size; // size in 1/1000 inch + SheetSize.x *= m_Parent->m_InternalUnits / 1000; + SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in pixels + + ActiveScreen->SetZoom(1); + dpi = (float)SheetSize.x * 25.4 /m_ImageXSize_mm; + + WinEDA_DrawPanel * panel = m_Parent->DrawPanel; + +wxSVGFileDC dc(FullFileName, SheetSize.x, SheetSize.y, dpi) ; + + if ( ! dc.Ok() ) + { + DisplayError(this, wxT("SVGprint error: wxSVGFileDC not OK")); + success = FALSE; + } + + else + { + EDA_Rect tmp = panel->m_ClipBox; + GRResetPenAndBrush(&dc); + PenMinWidth = m_ButtPenWidth->GetValue(); + SetPenMinWidth(PenMinWidth); + GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? FALSE : TRUE ); + + + panel->m_ClipBox.SetX(0);panel->m_ClipBox.SetY(0); + panel->m_ClipBox.SetWidth(0x7FFFFF0); panel->m_ClipBox.SetHeight(0x7FFFFF0); + + g_IsPrinting = TRUE; + setlocale(LC_NUMERIC, "C"); // Switch the locale to standard C (needed to print floating point numbers like 1.3) + panel->PrintPage(&dc, m_Print_Sheet_Ref, m_PrintMaskLayer); + setlocale(LC_NUMERIC, ""); // revert to the current locale + g_IsPrinting = FALSE; + panel->m_ClipBox = tmp; + } + + + GRForceBlackPen(FALSE); + SetPenMinWidth(1); + + ActiveScreen->m_StartVisu = tmp_startvisu; + ActiveScreen->m_DrawOrg = old_org; + ActiveScreen->SetZoom(tmpzoom); + + return success; +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PRINT_EXECUTE + */ + +void WinEDA_PrintSVGFrame::OnPrintExecuteClick( wxCommandEvent& event ) +{ + PrintSVGDoc(event); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + */ + +void WinEDA_PrintSVGFrame::OnCloseClick( wxCommandEvent& event ) +{ + Close(TRUE); +} + + +/*! + * wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_SPINCTRL + */ + +void WinEDA_PrintSVGFrame::OnSpinctrlUpdated( wxSpinEvent& event ) +{ + SetPenWidth(event); +} + + +/*! + * wxEVT_CLOSE_WINDOW event handler for ID_DIALOG + */ + +void WinEDA_PrintSVGFrame::OnCloseWindow( wxCloseEvent& event ) +{ + wxConfig * Config = m_Parent->m_Parent->m_EDA_Config; + if ( Config ) + { + s_PlotBlackAndWhite = m_ModeColorOption->GetSelection(); + Config->Write(wxT("PlotSVGPenWidth"), PenMinWidth); + Config->Write(wxT("PlotSVGModeColor"), s_PlotBlackAndWhite); + } + event.Skip(); +} + + + + +/*! + * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX_SETPRINTMODE + */ + +void WinEDA_PrintSVGFrame::OnRadioboxSetprintmodeSelected( wxCommandEvent& event ) +{ + s_PlotBlackAndWhite = m_ModeColorOption->GetSelection(); + event.Skip(); +} + + diff --git a/share/svg_print.h b/share/svg_print.h new file mode 100644 index 0000000000..49fc86547b --- /dev/null +++ b/share/svg_print.h @@ -0,0 +1,142 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: svg_print.h +// Purpose: +// Author: jean-pierre Charras +// Modified by: +// Created: 05/02/2006 11:05:20 +// RCS-ID: +// Copyright: License GNU +// Licence: +///////////////////////////////////////////////////////////////////////////// + +// Generated by DialogBlocks (unregistered), 05/02/2006 11:05:20 + +#ifndef _SVG_PRINT_H_ +#define _SVG_PRINT_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "svg_print.h" +#endif + +/*! + * Includes + */ + +////@begin includes +#include "wx/valgen.h" +#include "wx/spinctrl.h" +////@end includes + +/*! + * Forward declarations + */ + +////@begin forward declarations +class wxSpinCtrl; +////@end forward declarations + +/*! + * Control identifiers + */ + +////@begin control identifiers +#define ID_DIALOG 10000 +#define ID_SPINCTRL 10003 +#define ID_RADIOBOX_SETPRINTMODE 10007 +#define ID_CHECKBOX 10004 +#define ID_RADIOBOX1 10008 +#define ID_PRINT_EXECUTE 10002 +#define ID_TEXTCTRL 10001 +#define ID_TEXTCTRL1 10006 +#define SYMBOL_WINEDA_PRINTSVGFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxFRAME_FLOAT_ON_PARENT +#define SYMBOL_WINEDA_PRINTSVGFRAME_TITLE _("Create SVG file") +#define SYMBOL_WINEDA_PRINTSVGFRAME_IDNAME ID_DIALOG +#define SYMBOL_WINEDA_PRINTSVGFRAME_SIZE wxSize(400, 300) +#define SYMBOL_WINEDA_PRINTSVGFRAME_POSITION wxDefaultPosition +////@end control identifiers + +/*! + * Compatibility + */ + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +/*! + * WinEDA_PrintSVGFrame class declaration + */ + +class WinEDA_PrintSVGFrame: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( WinEDA_PrintSVGFrame ) + DECLARE_EVENT_TABLE() + +public: + /// Constructors + WinEDA_PrintSVGFrame( ); + WinEDA_PrintSVGFrame( WinEDA_DrawFrame* parent, + wxWindowID id = SYMBOL_WINEDA_PRINTSVGFRAME_IDNAME, + const wxString& caption = SYMBOL_WINEDA_PRINTSVGFRAME_TITLE, + const wxPoint& pos = SYMBOL_WINEDA_PRINTSVGFRAME_POSITION, + const wxSize& size = SYMBOL_WINEDA_PRINTSVGFRAME_SIZE, + long style = SYMBOL_WINEDA_PRINTSVGFRAME_STYLE ); + + /// Creation + bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PRINTSVGFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PRINTSVGFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PRINTSVGFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PRINTSVGFRAME_SIZE, long style = SYMBOL_WINEDA_PRINTSVGFRAME_STYLE ); + + /// Creates the controls and sizers + void CreateControls(); + +////@begin WinEDA_PrintSVGFrame event handler declarations + + /// wxEVT_CLOSE_WINDOW event handler for ID_DIALOG + void OnCloseWindow( wxCloseEvent& event ); + + /// wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_SPINCTRL + void OnSpinctrlUpdated( wxSpinEvent& event ); + + /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX_SETPRINTMODE + void OnRadioboxSetprintmodeSelected( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PRINT_EXECUTE + void OnPrintExecuteClick( wxCommandEvent& event ); + + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE + void OnCloseClick( wxCommandEvent& event ); + +////@end WinEDA_PrintSVGFrame event handler declarations + +////@begin WinEDA_PrintSVGFrame member function declarations + + /// Retrieves bitmap resources + wxBitmap GetBitmapResource( const wxString& name ); + + /// Retrieves icon resources + wxIcon GetIconResource( const wxString& name ); +////@end WinEDA_PrintSVGFrame member function declarations + + /// Should we show tooltips? + static bool ShowToolTips(); + + void PrintSVGDoc(wxCommandEvent& event); + bool DrawPage(const wxString & FullFileName); + void SetPenWidth(wxSpinEvent& event); + wxString ReturnFullFileName(void); + +////@begin WinEDA_PrintSVGFrame member variables + wxSpinCtrl* m_ButtPenWidth; + wxRadioBox* m_ModeColorOption; + wxCheckBox* m_Print_Sheet_Ref; + wxRadioBox* m_PagesOption; + wxTextCtrl* m_FileNameCtrl; + wxTextCtrl* m_MessagesBox; +////@end WinEDA_PrintSVGFrame member variables + + WinEDA_DrawFrame * m_Parent; + int m_PrintMaskLayer; + int m_ImageXSize_mm; +}; + +#endif + // _SVG_PRINT_H_ diff --git a/share/svg_print.pjd b/share/svg_print.pjd new file mode 100644 index 0000000000..5879a76367 --- /dev/null +++ b/share/svg_print.pjd @@ -0,0 +1,1067 @@ + + +
+ 0 + "" + "" + "" + "" + 24 + "" + 0 + 0 + 0 + 1 + 1 + 0 + "jean-pierre Charras" + "License GNU" + "" + 0 + 0 + "<All platforms>" + "<Any>" + "///////////////////////////////////////////////////////////////////////////// +// Name: %HEADER-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SOURCE-FILENAME% +// Purpose: +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + " +/*! + * %BODY% + */ + +" + "///////////////////////////////////////////////////////////////////////////// +// Name: %SYMBOLS-FILENAME% +// Purpose: Symbols file +// Author: %AUTHOR% +// Modified by: +// Created: %DATE% +// RCS-ID: +// Copyright: %COPYRIGHT% +// Licence: +///////////////////////////////////////////////////////////////////////////// + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "%HEADER-FILENAME%" +#endif + +" + "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "%HEADER-FILENAME%" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +" + "app_resources.h" + "app_resources.cpp" + "AppResources" + "app.h" + "app.cpp" + "Application" + 0 + "" + "<None>" + "<System>" + "<System>" + "" + 0 + 0 + 4 + " " + "" + 0 + 0 + 1 + 1 + 1 + 1 +
+ + + "" + "data-document" + "" + "" + 0 + 1 + 0 + 0 + + "Configurations" + "config-data-document" + "" + "" + 0 + 1 + 0 + 0 + "" + 1 + "" + "Debug" + "ANSI" + "Static" + "Modular" + "GUI" + "wxMSW" + "Dynamic" + "Yes" + "No" + "No" + "%WXVERSION%" + "%EXECUTABLE%" + "" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + + + + + + + "Projects" + "root-document" + "" + "project" + 1 + 1 + 0 + 0 + + "Windows" + "html-document" + "" + "dialogsfolder" + 1 + 1 + 0 + 1 + + "Print SVG file" + "dialog-document" + "" + "dialog" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbDialogProxy" + 10000 + 0 + "" + 0 + "wxEVT_CLOSE_WINDOW|OnCloseWindow" + "ID_DIALOG" + 10000 + "WinEDA_PrintSVGFrame" + "wxDialog" + "wxDialog" + "svg_print.cpp" + "svg_print.h" + "" + "Create SVG file" + 1 + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + "wxFRAME_FLOAT_ON_PARENT" + 0 + 1 + -1 + -1 + 400 + 300 + "" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "wbBoxSizerProxy" + "Vertical" + "" + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer H" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbBoxSizerProxy" + "Horizontal" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Pen width mini" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxSpinCtrl: ID_SPINCTRL" + "dialog-control-document" + "" + "spinctrl" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbSpinCtrlProxy" + "wxEVT_COMMAND_SPINCTRL_UPDATED|OnSpinctrlUpdated" + "ID_SPINCTRL" + 10003 + "wxSpinCtrl" + "m_ButtPenWidth" + 1 + 100 + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "PenMinWidth" + "wxGenericValidator(& %VARIABLE%)" + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxRadioBox: ID_RADIOBOX_SETPRINTMODE" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "25/11/2006" + "wbRadioBoxProxy" + "wxEVT_COMMAND_RADIOBOX_SELECTED|OnRadioboxSetprintmodeSelected" + "ID_RADIOBOX_SETPRINTMODE" + 10007 + "wxRadioBox" + "m_ModeColorOption" + "Print mode" + 1 + "Color|Black and White" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "s_PlotBlackAndWhite" + "wxGenericValidator(& %VARIABLE%)" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxCheckBox: ID_CHECKBOX" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbCheckBoxProxy" + "ID_CHECKBOX" + 10004 + "wxCheckBox" + "m_Print_Sheet_Ref" + "Print Sheet Ref" + 0 + "" + "" + "Print_Sheet_Ref" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 1 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + "Spacer" + "dialog-control-document" + "" + "spacer" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbSpacerProxy" + 5 + 5 + "Centre" + "Centre" + 0 + 15 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + + "wxBoxSizer V" + "dialog-control-document" + "" + "sizer" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbBoxSizerProxy" + "Vertical" + "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "<Any platform>" + + "wxRadioBox: ID_RADIOBOX1" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "23/12/2006" + "wbRadioBoxProxy" + "ID_RADIOBOX1" + 10008 + "wxRadioBox" + "m_PagesOption" + "Page Print:" + 1 + "Current|All" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: ID_PRINT_EXECUTE" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnPrintExecuteClick" + "ID_PRINT_EXECUTE" + 10002 + "wxButton" + "" + "Create &File" + 1 + "" + "" + "" + "008000" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxButton: wxID_CLOSE" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnCloseClick" + "wxID_CLOSE" + 5001 + "wxButton" + "" + "&Close" + 0 + "" + "" + "" + "0000C6" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Filename:" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Top" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "5/7/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL" + 10001 + "wxTextCtrl" + "m_FileNameCtrl" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxStaticText: wxID_STATIC" + "dialog-control-document" + "" + "statictext" + 0 + 1 + 0 + 0 + "5/9/2006" + "wbStaticTextProxy" + "wxID_STATIC" + 5105 + "wxStaticText" + "" + "Messages:" + -1 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Left" + "Centre" + 0 + 5 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + "" + "" + + + "wxTextCtrl: ID_TEXTCTRL1" + "dialog-control-document" + "" + "textctrl" + 0 + 1 + 0 + 0 + "5/9/2006" + "wbTextCtrlProxy" + "ID_TEXTCTRL1" + 10006 + "wxTextCtrl" + "m_MessagesBox" + "" + 0 + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + "" + "" + 1 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + 100 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + + + + "Sources" + "html-document" + "" + "sourcesfolder" + 1 + 1 + 0 + 1 + + "svg_print.rc" + "source-editor-document" + "svg_print.rc" + "source-editor" + 0 + 0 + 1 + 0 + "5/7/2006" + "" + + + + "Images" + "html-document" + "" + "bitmapsfolder" + 1 + 1 + 0 + 1 + + + + +
diff --git a/share/worksheet.cpp b/share/worksheet.cpp new file mode 100644 index 0000000000..0d0b7c881d --- /dev/null +++ b/share/worksheet.cpp @@ -0,0 +1,281 @@ + /**************************************************/ + /* WORKSHEET.CPP : routines de trace du cartouche */ + /**************************************************/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" + +#ifdef EESCHEMA +#include "program.h" +#include "libcmp.h" +#include "general.h" +#endif + +#ifdef PCBNEW +#include "pcbnew.h" +#endif + +#include "worksheet.h" + +#include "protos.h" + +/*********************************************************************/ +void WinEDA_DrawFrame::TraceWorkSheet(wxDC * DC, BASE_SCREEN * screen) +/*********************************************************************/ +/* Trace l'encadrement de la feuille de travail et le cartouche +*/ +{ + if ( ! m_Draw_Sheet_Ref ) return; + +Ki_PageDescr * Sheet = screen->m_CurrentSheet; +int ii, jj, xg , yg, ipas, gxpas, gypas; +wxPoint pos; +int refx, refy,Color; +wxString Line; +Ki_WorkSheetData * WsItem; +int scale = m_InternalUnits/1000; +wxSize size(SIZETEXT*scale,SIZETEXT*scale); +wxSize size_ref(SIZETEXT_REF*scale,SIZETEXT_REF*scale); +wxString msg; +int UpperLimit = VARIABLE_BLOCK_START_POSITION; + + Color = RED; + if(Sheet == NULL) + { + DisplayError(this, + wxT("WinEDA_DrawFrame::TraceWorkSheet() error: m_CurrentSheet NULL")); + return; + } + + // if not printing, draw the page limits: + if ( ! g_IsPrinting & g_ShowPageLimits ) + { + GRSetDrawMode(DC, GR_COPY); + GRRect(&DrawPanel->m_ClipBox, DC, 0, 0, + Sheet->m_Size.x * scale, Sheet->m_Size.y * scale, + g_DrawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY ); + } + + GRSetDrawMode(DC, GR_COPY); + /* trace de la bordure */ + refx = Sheet->m_LeftMargin; + refy = Sheet->m_TopMargin; /* Upper left corner */ + xg = Sheet->m_Size.x - Sheet->m_RightMargin; + yg = Sheet->m_Size.y - Sheet->m_BottomMargin; /* lower right corner */ + + for ( ii = 0; ii < 2 ; ii++ ) + { + GRRect(&DrawPanel->m_ClipBox, DC, refx * scale, refy * scale, + xg * scale, yg * scale, Color); + + refx += GRID_REF_W; refy += GRID_REF_W; + xg -= GRID_REF_W; yg -= GRID_REF_W; + } + /* trace des reperes */ + refx = Sheet->m_LeftMargin; + refy = Sheet->m_TopMargin; /* Upper left corner */ + xg = Sheet->m_Size.x - Sheet->m_RightMargin; + yg = Sheet->m_Size.y - Sheet->m_BottomMargin; /* lower right corner */ + + /* Trace des reperes selon l'axe X */ + ipas = (xg - refx) / PAS_REF; + gxpas = ( xg - refx) / ipas; + for ( ii = refx + gxpas, jj = 1; ipas > 0 ; ii += gxpas , jj++, ipas--) + { + Line.Printf( wxT("%d"),jj); + if( ii < xg - PAS_REF/2 ) + { + GRLine(&DrawPanel->m_ClipBox, DC, ii * scale, refy * scale, + ii * scale, (refy + GRID_REF_W) * scale, Color); + } + DrawGraphicText(DrawPanel, DC, + wxPoint( (ii - gxpas/2) * scale, (refy + GRID_REF_W/2) * scale), + Color, + Line, TEXT_ORIENT_HORIZ, size_ref, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + if( ii < xg - PAS_REF/2 ) + { + GRLine(&DrawPanel->m_ClipBox, DC,ii * scale, yg * scale, + ii * scale, (yg - GRID_REF_W) * scale, Color); + } + DrawGraphicText(DrawPanel, DC, + wxPoint( (ii - gxpas/2) * scale, (yg - GRID_REF_W/2) * scale), + Color, + Line, TEXT_ORIENT_HORIZ, size_ref, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + } + + /* Trace des reperes selon l'axe Y */ + ipas = (yg - refy) / PAS_REF; + gypas = ( yg - refy) / ipas; + for ( ii = refy + gypas, jj = 0; ipas > 0 ; ii += gypas , jj++, ipas--) + { + Line.Empty(); + if( jj < 26 ) Line.Printf(wxT("%c"), jj + 'A'); + else Line.Printf(wxT("%c"), 'a' + jj - 26); + if( ii < yg - PAS_REF/2 ) + { + GRLine(&DrawPanel->m_ClipBox, DC, refx * scale, ii * scale, + (refx + GRID_REF_W) * scale, ii * scale, Color); + } + DrawGraphicText(DrawPanel, DC, + wxPoint((refx + GRID_REF_W/2) * scale, (ii - gypas/2) * scale), + Color, + Line, TEXT_ORIENT_HORIZ, size_ref, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + if( ii < yg - PAS_REF/2 ) + { + GRLine(&DrawPanel->m_ClipBox, DC, xg * scale, ii * scale, + (xg - GRID_REF_W) * scale, ii * scale, Color); + } + DrawGraphicText(DrawPanel, DC, + wxPoint((xg - GRID_REF_W/2) * scale, (ii - gxpas/2) * scale), + Color, + Line, TEXT_ORIENT_HORIZ, size_ref, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); + } + + + + /* Trace du cartouche */ + refx = Sheet->m_Size.x - Sheet->m_RightMargin - GRID_REF_W; + refy = Sheet->m_Size.y - Sheet->m_BottomMargin - GRID_REF_W; /* lower right corner */ + + for( WsItem = &WS_Date; WsItem != NULL; WsItem = WsItem->Pnext ) + { + pos.x = (refx - WsItem->m_Posx)* scale; + pos.y = (refy - WsItem->m_Posy)* scale; + msg.Empty(); + switch( WsItem->m_Type ) + { + case WS_DATE: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += screen->m_Date; + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + break; + + case WS_REV: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += screen->m_Revision; + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + break; + + case WS_LICENCE: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += g_ProductName + Main_Title; + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + break; + + case WS_SIZESHEET: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += Sheet->m_Name; + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + break; + + + case WS_IDENTSHEET: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg << screen->m_SheetNumber << wxT("/") << + screen->m_NumberOfSheet; + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + break; + + case WS_COMPANY_NAME: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += screen->m_Company; + if ( ! msg.IsEmpty() ) + { + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); + } + break; + + case WS_TITLE: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += screen->m_Title; + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + break; + + case WS_COMMENT1: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += screen->m_Commentaire1; + if ( ! msg.IsEmpty() ) + { + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); + } + break; + + case WS_COMMENT2: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += screen->m_Commentaire2; + if ( ! msg.IsEmpty() ) + { + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); + } + break; + + case WS_COMMENT3: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += screen->m_Commentaire3; + if ( ! msg.IsEmpty() ) + { + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); + } + break; + + case WS_COMMENT4: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg += screen->m_Commentaire4; + if ( ! msg.IsEmpty() ) + { + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); + } + break; + + case WS_UPPER_SEGMENT: + if (UpperLimit == 0 ) break; + case WS_LEFT_SEGMENT: + WS_MostUpperLine.m_Posy = + WS_MostUpperLine.m_Endy = + WS_MostLeftLine.m_Posy = UpperLimit; + pos.y = (refy - WsItem->m_Posy)* scale; + case WS_SEGMENT: + xg = Sheet->m_Size.x - + GRID_REF_W - Sheet->m_RightMargin - WsItem->m_Endx; + yg = Sheet->m_Size.y - + GRID_REF_W - Sheet->m_BottomMargin - WsItem->m_Endy; + GRLine(&DrawPanel->m_ClipBox, DC, pos.x, pos.y, + xg * scale, yg * scale, Color); + break; + + } + } +} diff --git a/share/wxprint.cpp b/share/wxprint.cpp new file mode 100644 index 0000000000..58b2f096f1 --- /dev/null +++ b/share/wxprint.cpp @@ -0,0 +1,745 @@ +/*********************/ +/* File: wxprint.cpp */ +/*********************/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +#include "wx/spinctrl.h" + + +#if !wxUSE_PRINTING_ARCHITECTURE +#error You must set wxUSE_PRINTING_ARCHITECTURE to 1 in setup.h to compile this +#endif + +// Set this to 1 if you want to test PostScript printing under MSW. +#define wxTEST_POSTSCRIPT_IN_MSW 1 + +#include +#include "wx/metafile.h" +#include "wx/print.h" +#include "wx/printdlg.h" +#include "wx/dcmirror.h" + +#if wxTEST_POSTSCRIPT_IN_MSW +#include "wx/generic/printps.h" +#include "wx/generic/prntdlgg.h" +#endif + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" + +#ifdef EESCHEMA +#include "program.h" +#include "libcmp.h" +#include "general.h" +#endif + +#ifdef PCBNEW +#include "pcbnew.h" +extern float Scale_X, Scale_Y; +static long s_SelectedLayers = CUIVRE_LAYER | CMP_LAYER | + SILKSCREEN_LAYER_CMP | SILKSCREEN_LAYER_CU; +static double s_ScaleList[] = + { 0, 0.5, 0.7, 0.999, 1.0, 1.4, 2.0, 3.0, 4.0 }; +#endif + +#include "protos.h" + +//#define DEFAULT_ORIENTATION_PAPER wxPORTRAIT +#define DEFAULT_ORIENTATION_PAPER wxLANDSCAPE +#define WIDTH_MAX_VALUE 100 +#define WIDTH_MIN_VALUE 10 + +// static print data and page setup data, to remember settings during the session +static wxPrintData * g_PrintData; + +/* exportees dans eeconfig.h */ +int PenMinWidth = 20; /* dim mini (en 1/100 mmm) pour les traits imprimes */ + +// Variables locales +static int s_PrintMaskLayer; +static int s_OptionPrintPage = 0; +static int s_Print_Black_and_White = TRUE; +static int s_Scale_Select = 3; // default selected scale = ScaleList[3] = 1 +static bool s_PrintMirror; +static bool s_Print_Sheet_Ref = TRUE; + + /****************************************************************/ + /* frame de Preparation de l'impression (options, selections... */ + /****************************************************************/ + +#include "dialog_print.cpp" + + /***************************/ + /* Gestion de l'impression */ + /***************************/ + +class EDA_Printout: public wxPrintout +{ +public: + bool m_Print_Sheet_Ref; + +public: + WinEDA_DrawFrame * m_Parent; + WinEDA_PrintFrame * m_PrintFrame; + + EDA_Printout(WinEDA_PrintFrame * print_frame, WinEDA_DrawFrame * parent, const wxString & title, bool print_ref): + wxPrintout(title) + { + m_PrintFrame = print_frame; + m_Parent = parent; + s_PrintMaskLayer = 0xFFFFFFFF; + m_Print_Sheet_Ref = print_ref; + } + + bool OnPrintPage(int page); + bool HasPage(int page); + bool OnBeginDocument(int startPage, int endPage); + void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo); + + void DrawPage(void); +}; + +/*******************************************************/ +void WinEDA_DrawFrame::ToPrinter(wxCommandEvent& event) +/*******************************************************/ +/* Prepare les structures de données de gestion de l'impression +et affiche la fenetre de dialogue de gestion de l'impression des feuilles +*/ +{ +wxPoint pos = GetPosition(); +bool PrinterError = FALSE; + + // Stop the pending comand (if any...) + if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) + { + wxClientDC dc(DrawPanel); + DrawPanel->PrepareDC(dc); + DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc); + } + SetToolID(0, wxCURSOR_ARROW,wxEmptyString); + + if ( g_PrintData == NULL ) // First print + { + g_PrintData = new wxPrintData(); + if ( ! g_PrintData->Ok() ) + { + PrinterError = TRUE; + DisplayError( this, _("Error Init Printer info") ); + } + g_PrintData->SetQuality(wxPRINT_QUALITY_HIGH); // Default resolution = HIGHT; + g_PrintData->SetOrientation(DEFAULT_ORIENTATION_PAPER); + } + + + pos.x += 10; pos.y += 10; + WinEDA_PrintFrame * frame = new WinEDA_PrintFrame(this); + frame->ShowModal(); frame->Destroy(); +#ifdef EESCHEMA + g_PrintFillMask = 0; +#endif +} + + +/*******************************************/ +void WinEDA_PrintFrame::SetOthersDatas(void) +/*******************************************/ +{ +#ifndef PCBNEW + m_Print_Mirror->Enable(false); +#endif + + m_ButtPenWidth->SetRange(WIDTH_MIN_VALUE,WIDTH_MAX_VALUE); + m_FineAdjustXscaleOpt->SetToolTip(_("Set X scale adjust for exact scale plotting")); + m_FineAdjustYscaleOpt->SetToolTip(_("Set Y scale adjust for exact scale plotting")); + if ( s_Print_Black_and_White ) m_ColorOption->SetSelection(1); +#ifdef PCBNEW + m_PagesOptionEeschema->Show(false); + m_PagesOption = m_PagesOptionPcb; + /* Create layer list */ + int mask = 1, ii; + for ( ii = 0; ii < NB_LAYERS; ii++, mask <<= 1 ) + { + m_BoxSelecLayer[ii] = new wxCheckBox(this, -1, + ReturnPcbLayerName(ii)); + if ( mask & s_SelectedLayers) m_BoxSelecLayer[ii]->SetValue(TRUE); + if ( ii < 16 ) + m_CopperLayersBoxSizer->Add(m_BoxSelecLayer[ii], + wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE); + else + m_TechLayersBoxSizer->Add(m_BoxSelecLayer[ii], + wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE); + } + // Read the scale adjust option + if ( m_Parent->m_Parent->m_EDA_Config ) + { + m_Parent->m_Parent->m_EDA_Config->Read( wxT("PrintXFineScaleAdj"), &m_XScaleAdjust); + m_Parent->m_Parent->m_EDA_Config->Read( wxT("PrintYFineScaleAdj"), &m_YScaleAdjust); + m_Parent->m_Parent->m_EDA_Config->Read( wxT("PrintScale"), &s_Scale_Select); + } + + m_ScaleOption->SetSelection(s_Scale_Select); + + // Create scale adjust option + wxString msg; + msg.Printf(wxT("%lf"), m_XScaleAdjust); + m_FineAdjustXscaleOpt->SetValue(msg); + msg.Printf(wxT("%lf"), m_YScaleAdjust); + m_FineAdjustYscaleOpt->SetValue(msg); + +#else + m_PagesOption = m_PagesOptionEeschema; + m_PagesOptionPcb->Show(false); + m_ScaleOption->Show(false); + m_FineAdjustXscaleTitle->Show(false); + m_FineAdjustXscaleOpt->Show(false); + m_FineAdjustYscaleTitle->Show(false); + m_FineAdjustYscaleOpt->Show(false); +#endif +} + +/**********************************************************/ +int WinEDA_PrintFrame::SetLayerMaskFromListSelection(void) +/**********************************************************/ +{ +int page_count; + + s_PrintMaskLayer = 0; +#ifdef PCBNEW +int ii; + for ( ii = 0, page_count = 0; ii < NB_LAYERS; ii++ ) + { + if ( m_BoxSelecLayer[ii]->IsChecked() ) + { + page_count++; + s_PrintMaskLayer |= 1 << ii; + } + } +#else + page_count = 1; +#endif + return page_count; +} + +/************************************************************/ +void WinEDA_PrintFrame::SetColorOrBlack(wxCommandEvent& event) +/************************************************************/ +{ + s_Print_Black_and_White = m_ColorOption->GetSelection(); +} + +/****************************************************/ +void WinEDA_PrintFrame::OnClosePrintDialog(void) +/****************************************************/ +/* called when WinEDA_PrintFrame is closed +*/ +{ + if ( m_FineAdjustXscaleOpt ) + m_FineAdjustXscaleOpt->GetValue().ToDouble(&m_XScaleAdjust); + if ( m_FineAdjustYscaleOpt ) + m_FineAdjustYscaleOpt->GetValue().ToDouble(&m_YScaleAdjust); +#ifdef PCBNEW + if ( m_Parent->m_Parent->m_EDA_Config ) + { + m_Parent->m_Parent->m_EDA_Config->Write(wxT("PrintXFineScaleAdj"), m_XScaleAdjust); + m_Parent->m_Parent->m_EDA_Config->Write(wxT("PrintYFineScaleAdj"), m_YScaleAdjust); + m_Parent->m_Parent->m_EDA_Config->Write(wxT("PrintScale"), s_Scale_Select); + } +#endif + EndModal(0); +} + + +/************************************************/ +wxString WinEDA_PrintFrame::BuildPrintTitle(void) +/************************************************/ +/* return a valid filename to create a print file +*/ +{ +wxString name, ext; + + wxFileName::SplitPath(m_Parent->m_CurrentScreen->m_FileName, + (wxString*) NULL, & name, & ext); + name += wxT("-") + ext; + return name; +} + +/******************************************************/ +void WinEDA_PrintFrame::SetScale(wxCommandEvent& event) +/******************************************************/ +{ +#ifdef PCBNEW + s_Scale_Select = m_ScaleOption->GetSelection(); + Scale_X = Scale_Y = s_ScaleList[s_Scale_Select]; + if ( m_FineAdjustXscaleOpt ) + m_FineAdjustXscaleOpt->GetValue().ToDouble(&m_XScaleAdjust); + if ( m_FineAdjustYscaleOpt ) + m_FineAdjustYscaleOpt->GetValue().ToDouble(&m_YScaleAdjust); + Scale_X *= m_XScaleAdjust; + Scale_Y *= m_YScaleAdjust; +#endif +} + +/*********************************************************/ +void WinEDA_PrintFrame::SetPenWidth(wxSpinEvent& event) +/*********************************************************/ +{ + PenMinWidth = m_ButtPenWidth->GetValue(); + if ( PenMinWidth > WIDTH_MAX_VALUE ) + { + PenMinWidth = WIDTH_MAX_VALUE; + wxBell(); + } + if ( PenMinWidth < WIDTH_MIN_VALUE ) + { + PenMinWidth = WIDTH_MIN_VALUE; + wxBell(); + } + m_ButtPenWidth->SetValue(PenMinWidth); +} + + +/**********************************************************/ +void WinEDA_PrintFrame::OnPrintSetup(wxCommandEvent& event) +/**********************************************************/ +/* Open a dialog box for printer setup (printer options, page size ...) +*/ +{ + wxPrintDialogData printDialogData(*g_PrintData); + if ( printDialogData.Ok() ) + { + wxPrintDialog printerDialog(this, & printDialogData); + printerDialog.ShowModal(); + + * g_PrintData = printerDialog.GetPrintDialogData().GetPrintData(); + } + else DisplayError(this, _("Printer Problem!") ); +} + + +/************************************************************/ +void WinEDA_PrintFrame::OnPrintPreview(wxCommandEvent& event) +/************************************************************/ +/* Open and display a previewer frame for printing +*/ +{ +wxSize WSize; +wxPoint WPos; +int x, y; +bool print_ref = TRUE; + +wxSpinEvent spinevent; + + SetScale(event); + SetPenWidth(spinevent); + + if ( m_PagesOption ) + s_OptionPrintPage = m_PagesOption->GetSelection(); + + if ( (m_Print_Sheet_Ref == NULL) || (m_Print_Sheet_Ref->GetValue() == FALSE) ) + print_ref = FALSE; + + // Pass two printout objects: for preview, and possible printing. +wxString title = BuildPrintTitle(); + wxPrintPreview *preview = + new wxPrintPreview(new EDA_Printout(this, m_Parent, title, print_ref), + new EDA_Printout(this, m_Parent, title, print_ref), g_PrintData); + if ( preview == NULL ) + { + DisplayError(this, _("There was a problem previewing")); + return; + } +#ifdef PCBNEW + if ( s_OptionPrintPage ) SetLayerMaskFromListSelection(); +#endif + + m_Parent->GetPosition(&x, &y); + WPos.x = x + 4; + WPos.y = y + 25; + + WSize = m_Parent->GetSize(); + WSize.x -= 3; + WSize.y += 6; + + wxPreviewFrame *frame = new wxPreviewFrame(preview, this, + title, WPos, WSize); + frame->Initialize(); + frame->Show(TRUE); +} + + +/**********************************************************/ +void WinEDA_PrintFrame::EDA_PrintPage(wxCommandEvent& event) +/**********************************************************/ +/* Called on activate "Print CURRENT" button +*/ +{ +bool print_ref = TRUE; + + SetScale(event); + + s_OptionPrintPage = 0; + if ( m_PagesOption ) + s_OptionPrintPage = m_PagesOption->GetSelection(); + + if ( (m_Print_Sheet_Ref == NULL) || (m_Print_Sheet_Ref->GetValue() == FALSE) ) + print_ref = FALSE; + +#ifdef PCBNEW + if ( s_OptionPrintPage ) SetLayerMaskFromListSelection(); +#endif + +wxSpinEvent spinevent; + SetPenWidth(spinevent); + + wxPrintDialogData printDialogData( * g_PrintData); + + wxPrinter printer(& printDialogData); + +wxString title = BuildPrintTitle(); + EDA_Printout printout(this, m_Parent, title, print_ref); + +#ifndef __WINDOWS__ + wxDC * dc = printout.GetDC(); + ((wxPostScriptDC*)dc)->SetResolution(600); // Postscript DC resolution is 600 ppi +#endif + + if (!printer.Print(this, &printout, TRUE)) + { + if (wxPrinter::GetLastError() == wxPRINTER_ERROR) + DisplayError(this, _("There was a problem printing") ); + return; + } + else + { + * g_PrintData = printer.GetPrintDialogData().GetPrintData(); + } +} + + + +/***************************************/ +bool EDA_Printout::OnPrintPage(int page) +/***************************************/ +{ +wxString msg; + + msg.Printf(_("Print page %d"), page); + m_Parent->Affiche_Message(msg); + + +#ifdef EESCHEMA +BASE_SCREEN * screen = m_Parent->m_CurrentScreen; +BASE_SCREEN *oldscreen = screen; + + if( s_OptionPrintPage == 1 ) + { + EDA_ScreenList ScreenList(NULL); + screen = ScreenList.GetScreen(page -1); + } + + if (screen == NULL) return FALSE; + ActiveScreen = (SCH_SCREEN*) screen; + DrawPage(); + ActiveScreen = (SCH_SCREEN*) oldscreen; + +#endif + +#ifdef PCBNEW + if ( (m_Parent->m_Ident == PCB_FRAME) || (m_Parent->m_Ident == GERBER_FRAME) ) + { + m_PrintFrame->SetLayerMaskFromListSelection(); + if ( s_OptionPrintPage == 0 ) + { + // compute layer mask from page number + int ii, jj, mask = 1; + for ( ii = 0, jj = 0; ii < NB_LAYERS; ii++) + { + if ( s_PrintMaskLayer & mask ) jj++; + if ( jj == page ) + { + s_PrintMaskLayer = mask; + break; + } + mask <<= 1; + } + if ( ii == NB_LAYERS ) return FALSE; + } + } + DrawPage(); +#endif + + return TRUE; +} + +/*********************************************************/ +void EDA_Printout::GetPageInfo(int *minPage, int *maxPage, + int *selPageFrom, int *selPageTo) +/*********************************************************/ +{ +int ii = 1; + *minPage = 1; + *selPageFrom = 1; + +#ifdef EESCHEMA + if( s_OptionPrintPage == 1 ) + { + EDA_ScreenList ScreenList(NULL); + ii = ScreenList.GetCount(); + } +#endif + +#ifdef PCBNEW + switch( s_OptionPrintPage ) + { + case 0 :ii = m_PrintFrame->SetLayerMaskFromListSelection(); + break; + + case 1: + ii = 1; + break; + } +#endif + + *maxPage = ii; + *selPageTo = ii; +} + + +/**************************************/ +bool EDA_Printout::HasPage(int pageNum) +/**************************************/ +{ +#ifdef EESCHEMA +int PageCount; + + EDA_ScreenList ScreenList(NULL); + PageCount = ScreenList.GetCount(); + if( PageCount >= pageNum ) return TRUE; + + return FALSE; +#endif + +#ifdef PCBNEW + return TRUE; +#endif +} + +/*************************************************************/ +bool EDA_Printout::OnBeginDocument(int startPage, int endPage) +/*************************************************************/ +{ + if (!wxPrintout::OnBeginDocument(startPage, endPage)) + return FALSE; + + return TRUE; +} + +/********************************/ +void EDA_Printout::DrawPage(void) +/********************************/ +/* + This is the real print function: print the active screen +*/ +{ +int tmpzoom; +wxPoint tmp_startvisu; +wxSize PageSize_in_mm; +wxSize SheetSize; // Page size in internal units +wxSize PlotAreaSize; // plot area size in pixels +double scaleX, scaleY, scale; +wxPoint old_org; +wxPoint DrawOffset; // Offset de trace +double userscale; +int DrawZoom = 1; +wxDC * dc = GetDC(); + + s_PrintMirror = m_PrintFrame->m_Print_Mirror->GetValue(); + + wxBusyCursor dummy; + + GetPageSizeMM(&PageSize_in_mm.x, &PageSize_in_mm.y); + + /* Save old draw scale and draw offset */ + tmp_startvisu = ActiveScreen->m_StartVisu; + tmpzoom = ActiveScreen->GetZoom(); + old_org = ActiveScreen->m_DrawOrg; + /* Change draw scale and offset to draw the whole page */ + ActiveScreen->SetZoom(DrawZoom); + ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0; + ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.y = 0; + + SheetSize = ActiveScreen->m_CurrentSheet->m_Size; // size in 1/1000 inch + SheetSize.x *= m_Parent->m_InternalUnits / 1000; + SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in pixels + + // Get the size of the DC in pixels + dc->GetSize(&PlotAreaSize.x, &PlotAreaSize.y); + +#ifdef PCBNEW + WinEDA_BasePcbFrame * pcbframe = (WinEDA_BasePcbFrame*) m_Parent; + pcbframe->m_Pcb->ComputeBoundaryBox(); + /* Compute the PCB size in internal units*/ + userscale = s_ScaleList[s_Scale_Select]; + if (userscale == 0) // fit in page + { + int extra_margin = 8000; // Margin = 8000/2 units pcb = 0,4 inch + SheetSize.x = pcbframe->m_Pcb->m_BoundaryBox.GetWidth() + extra_margin; + SheetSize.y = pcbframe->m_Pcb->m_BoundaryBox.GetHeight() + extra_margin; + userscale = 0.99; + } + + if ( (s_ScaleList[s_Scale_Select] > 1.0) || // scale > 1 -> Recadrage + (s_ScaleList[s_Scale_Select] == 0) ) // fit in page + { + DrawOffset.x += pcbframe->m_Pcb->m_BoundaryBox.Centre().x; + DrawOffset.y += pcbframe->m_Pcb->m_BoundaryBox.Centre().y; + } +#else + userscale = 1; +#endif + + // Calculate a suitable scaling factor + scaleX = (double)SheetSize.x / PlotAreaSize.x; + scaleY = (double)SheetSize.y / PlotAreaSize.y; + scale = wxMax(scaleX,scaleY) / userscale; // Use x or y scaling factor, whichever fits on the DC + + // ajust the real draw scale +#ifdef PCBNEW +double accurate_Xscale, accurate_Yscale; + dc->SetUserScale(DrawZoom / scale * m_PrintFrame->m_XScaleAdjust, + DrawZoom / scale * m_PrintFrame->m_YScaleAdjust); + // Compute Accurate scale 1 + { + int w, h; + GetPPIPrinter(&w, &h); + accurate_Xscale = ((double)(DrawZoom * w))/ PCB_INTERNAL_UNIT; + accurate_Yscale = ((double)(DrawZoom * h))/ PCB_INTERNAL_UNIT; + if ( IsPreview() ) // Scale must take in account the DC size in Preview + { + // Get the size of the DC in pixels + dc->GetSize(&PlotAreaSize.x, &PlotAreaSize.y); + GetPageSizePixels(&w, &h); + accurate_Xscale *= PlotAreaSize.x; accurate_Xscale /= w; + accurate_Yscale *= PlotAreaSize.y; accurate_Yscale /= h; + } + accurate_Xscale *= m_PrintFrame->m_XScaleAdjust; + accurate_Yscale *= m_PrintFrame->m_YScaleAdjust; + } +#else + dc->SetUserScale(DrawZoom / scale, DrawZoom / scale); +#endif + +#ifdef PCBNEW + if ( (s_ScaleList[s_Scale_Select] > 1.0) || // scale > 1 -> Recadrage + (s_ScaleList[s_Scale_Select] == 0) ) // fit in page + { + DrawOffset.x -= (int)( (PlotAreaSize.x/2) * scale); + DrawOffset.y -= (int)( (PlotAreaSize.y/3) * scale); + } + DrawOffset.x += (int)( (SheetSize.x/2) * (m_PrintFrame->m_XScaleAdjust -1.0)); + DrawOffset.y += (int)( (SheetSize.y/2) * (m_PrintFrame->m_YScaleAdjust -1.0)); +#endif + + ActiveScreen->m_DrawOrg = DrawOffset; + + GRResetPenAndBrush(dc); + if( s_Print_Black_and_White ) GRForceBlackPen(TRUE); + + +#ifdef EESCHEMA + /* set Pen min width */ +float ftmp; + // PenMinWidth est donné en 1/100 mm, a convertir en pixels + ftmp = (float)PenMinWidth / 100; // ftmp est en mm + ftmp *= (float)PlotAreaSize.x / PageSize_in_mm.x; /* ftmp est en pixels */ + SetPenMinWidth((int)ftmp); +#else + SetPenMinWidth(1); +#endif + +WinEDA_DrawPanel * panel = m_Parent->DrawPanel; +EDA_Rect tmp = panel->m_ClipBox; + + panel->m_ClipBox.SetOrigin(wxPoint(0,0)); + panel->m_ClipBox.SetSize(wxSize(0x7FFFFF0, 0x7FFFFF0)); + + g_IsPrinting = TRUE; +#ifdef EESCHEMA + if( s_Print_Black_and_White ) + g_PrintFillMask = FILLED_WITH_BG_BODYCOLOR; +#endif +#ifdef PCBNEW + if ( m_Print_Sheet_Ref ) + m_Parent->TraceWorkSheet( dc, ActiveScreen); + + + if ( userscale == 1.0 ) // Draw the Sheet refs at optimum scale, and board at 1.0 scale + { + m_Print_Sheet_Ref = FALSE; + dc->SetUserScale( accurate_Yscale, accurate_Yscale); + } + + if ( s_PrintMirror ) + { // To plot mirror, we revere the y axis, and modify the plot y origin + double sx, sy; + + dc->GetUserScale(&sx, &sy); + dc->SetAxisOrientation(TRUE, TRUE); + if ( userscale < 1.0 ) sy /= userscale; + /* Plot offset y is moved by the y plot area size in order to have + the old draw area in the new draw area, because the draw origin has not moved + (this is the upper left corner) but the Y axis is reversed, therefore the plotting area + is the y coordinate values from - PlotAreaSize.y to 0 */ + int ysize = (int)( PlotAreaSize.y / sy ); + DrawOffset.y += ysize; + /* in order to keep the board position in the sheet + (when user scale <= 1) the y offset in moved by the distance between + the middle of the page and the middle of the board + This is equivalent to put the mirror axis to the board centre + for scales > 1, the DrawOffset was already computed to have the board centre + to the middle of the page. + */ + wxPoint pcb_centre = pcbframe->m_Pcb->m_BoundaryBox.Centre(); + if ( userscale <= 1.0 ) + DrawOffset.y += pcb_centre.y - (ysize/2); + ActiveScreen->m_DrawOrg = DrawOffset; + panel->m_ClipBox.SetOrigin(wxPoint(-0x7FFFFF,-0x7FFFFF)); + } + + panel->PrintPage(dc, 0, s_PrintMaskLayer); + +#else + panel->PrintPage(dc, m_Print_Sheet_Ref, s_PrintMaskLayer); +#endif + +#ifdef EESCHEMA + g_PrintFillMask = 0; +#endif + + g_IsPrinting = FALSE; + panel->m_ClipBox = tmp; + + SetPenMinWidth(1); + GRForceBlackPen(FALSE); + + ActiveScreen->m_StartVisu = tmp_startvisu; + ActiveScreen->m_DrawOrg = old_org; + ActiveScreen->SetZoom(tmpzoom); +} + diff --git a/share/zoom.cpp b/share/zoom.cpp new file mode 100644 index 0000000000..9a9285d604 --- /dev/null +++ b/share/zoom.cpp @@ -0,0 +1,445 @@ + /************/ + /* zoom.cpp */ + /************/ + +/* + Fonctions de gestion du zoom, du pas de grille et du + recadrage automatique +*/ + +#include "fctsys.h" +#include "gr_basic.h" + +#include "common.h" +#include "macros.h" + +#ifdef EESCHEMA +#include "program.h" +#include "libcmp.h" +#include "general.h" +#endif + +#ifdef PCBNEW +#include "pcbnew.h" +#endif + +#ifdef CVPCB +#include "cvpcb.h" +#endif + +#include "bitmaps.h" + +#include "protos.h" + +#include "id.h" + + +/* Fonctions locales: */ + + +/**************************************************/ +void WinEDA_DrawFrame::Recadre_Trace(bool ToMouse) +/**************************************************/ +/* Calcule les offsets de trace. + Les offsets sont ajustés a un multiple du pas de grille + si ToMouse == TRUE, le curseur souris (curseur "systeme") est replace + en position curseur graphique (curseur kicad) + + Note: Mac OS ** does not ** allow moving mouse cursor by program. +*/ +{ + + /* decalages a apporter au trace en coordonnees ecran */ + PutOnGrid(& m_CurrentScreen->m_Curseur) ; + AdjustScrollBars(); + + ReDrawPanel(); + + /* Place le curseur souris sur le curseur SCHEMA*/ + if ( ToMouse == TRUE ) + DrawPanel->MouseToCursorSchema(); +} + +/************************************************/ +void WinEDA_DrawFrame::PutOnGrid(wxPoint * coord) +/************************************************/ +/* retourne la valeur de la coordonnee coord sur le point de grille le plus proche */ +{ +double ftmp; + if ( ! m_CurrentScreen->m_UserGridIsON ) + { + wxSize grid_size = m_CurrentScreen->GetGrid(); + ftmp = (double)coord->x / grid_size.x; + coord->x = ((int)round(ftmp)) * grid_size.x; + + ftmp = (double)coord->y / grid_size.y; + coord->y = ((int)round(ftmp)) * grid_size.y; + } + else + { + double pasx = m_CurrentScreen->m_UserGrid.x * m_InternalUnits; + double pasy = m_CurrentScreen->m_UserGrid.y * m_InternalUnits; + if ( m_CurrentScreen->m_UserGridUnit != INCHES ) + { + pasx /= 25.4; pasy /= 25.4; + } + int nn = (int) round( coord->x /pasx); + coord->x = (int) round( pasx * nn); + nn = (int) round( coord->y /pasy); + coord->y = (int) round( pasy * nn); + } +} + +/**************************************************************/ +void WinEDA_DrawFrame::Zoom_Automatique(bool move_mouse_cursor) +/**************************************************************/ +/* Affiche le Schema au meilleur zoom au meilleur centrage pour le dessin + de facon a avoir toute la feuille affichee a l'ecran +*/ +{ +int bestzoom; + + bestzoom = BestZoom(); + m_CurrentScreen->SetZoom(bestzoom); + Recadre_Trace(move_mouse_cursor); +} + +/*************************************************/ +void WinEDA_DrawFrame::Window_Zoom(EDA_Rect &Rect) +/*************************************************/ +/* Compute the zoom factor and the new draw offset to draw the + selected area (Rect) in full window screen +*/ +{ +int ii, jj; +int bestzoom; +wxSize size; + + /* Compute the best zoom */ + Rect.Normalize(); + size = DrawPanel->GetClientSize(); + ii = Rect.GetSize().x / size.x; + jj = Rect.GetSize().y / size.y; + bestzoom = MAX(ii, jj); + if ( bestzoom <= 0 ) bestzoom = 1; + + m_CurrentScreen->SetZoom(bestzoom); + + m_CurrentScreen->m_Curseur = Rect.Centre(); + Recadre_Trace(TRUE); +} + +/*****************************************************************/ +void WinEDA_DrawPanel::Process_Popup_Zoom( wxCommandEvent &event ) +/*****************************************************************/ +/* Gere les commandes de zoom appelées par le menu Popup +Toute autre commande est transmise a Parent->Process_Special_Functions(event) +*/ +{ +int id = event.GetId(); +wxClientDC dc(this); + + switch (id) + { + case ID_POPUP_ZOOM_PLUS : + case ID_POPUP_ZOOM_MOINS : + case ID_POPUP_ZOOM_CENTER : + case ID_POPUP_ZOOM_AUTO : + case ID_POPUP_ZOOM_REDRAW : + m_Parent->OnZoom(id); + break; + + case ID_POPUP_ZOOM_SELECT : + break; + + case ID_POPUP_CANCEL : + MouseToCursorSchema(); + break; + + case ID_POPUP_ZOOM_LEVEL_1 : + m_Parent->m_CurrentScreen->SetZoom(1); + m_Parent->Recadre_Trace(TRUE); + break; + + case ID_POPUP_ZOOM_LEVEL_2 : + m_Parent->m_CurrentScreen->SetZoom(2); + m_Parent->Recadre_Trace(TRUE); + break; + + case ID_POPUP_ZOOM_LEVEL_4 : + m_Parent->m_CurrentScreen->SetZoom(4); + m_Parent->Recadre_Trace(TRUE); + break; + + case ID_POPUP_ZOOM_LEVEL_8 : + m_Parent->m_CurrentScreen->SetZoom(8); + m_Parent->Recadre_Trace(TRUE); + break; + + case ID_POPUP_ZOOM_LEVEL_16 : + m_Parent->m_CurrentScreen->SetZoom(16); + m_Parent->Recadre_Trace(TRUE); + break; + + case ID_POPUP_ZOOM_LEVEL_32 : + m_Parent->m_CurrentScreen->SetZoom(32); + m_Parent->Recadre_Trace(TRUE); + break; + + case ID_POPUP_ZOOM_LEVEL_64 : + m_Parent->m_CurrentScreen->SetZoom(64); + m_Parent->Recadre_Trace(TRUE); + break; + + case ID_POPUP_ZOOM_LEVEL_128 : + m_Parent->m_CurrentScreen->SetZoom(128); + m_Parent->Recadre_Trace(TRUE); + break; + + case ID_POPUP_ZOOM_LEVEL_256 : + m_Parent->m_CurrentScreen->SetZoom(256); + m_Parent->Recadre_Trace(TRUE); + break; + + case ID_POPUP_ZOOM_LEVEL_512 : + m_Parent->m_CurrentScreen->SetZoom(512); + m_Parent->Recadre_Trace(TRUE); + break; + + case ID_POPUP_ZOOM_LEVEL_1024 : + m_Parent->m_CurrentScreen->SetZoom(1024); + m_Parent->Recadre_Trace(TRUE); + break; + + case ID_POPUP_ZOOM_LEVEL_2048 : + m_Parent->m_CurrentScreen->SetZoom(2048); + m_Parent->Recadre_Trace(TRUE); + break; + + case ID_POPUP_GRID_LEVEL_1 : + m_Parent->m_CurrentScreen->SetGrid(wxSize(1,1)); + m_Parent->ReDrawPanel(); + break; + + case ID_POPUP_GRID_LEVEL_2 : + m_Parent->m_CurrentScreen->SetGrid(wxSize(2,2)); + m_Parent->ReDrawPanel(); + break; + + case ID_POPUP_GRID_LEVEL_5 : + m_Parent->m_CurrentScreen->SetGrid(wxSize(5,5)); + m_Parent->ReDrawPanel(); + break; + + case ID_POPUP_GRID_LEVEL_10 : + m_Parent->m_CurrentScreen->SetGrid(wxSize(10,10)); + m_Parent->ReDrawPanel(); + break; + + case ID_POPUP_GRID_LEVEL_20 : + m_Parent->m_CurrentScreen->SetGrid(wxSize(20,20)); + m_Parent->ReDrawPanel(); + break; + + case ID_POPUP_GRID_LEVEL_25 : + m_Parent->m_CurrentScreen->SetGrid(wxSize(25,25)); + m_Parent->ReDrawPanel(); + break; + + case ID_POPUP_GRID_LEVEL_50 : + m_Parent->m_CurrentScreen->SetGrid(wxSize(50,50)); + m_Parent->ReDrawPanel(); + break; + + case ID_POPUP_GRID_LEVEL_100 : + m_Parent->m_CurrentScreen->SetGrid(wxSize(100,100)); + m_Parent->ReDrawPanel(); + break; + + case ID_POPUP_GRID_LEVEL_200 : + m_Parent->m_CurrentScreen->SetGrid(wxSize(200,200)); + m_Parent->ReDrawPanel(); + break; + + case ID_POPUP_GRID_LEVEL_250 : + m_Parent->m_CurrentScreen->SetGrid(wxSize(250,250)); + m_Parent->ReDrawPanel(); + break; + + case ID_POPUP_GRID_LEVEL_500 : + m_Parent->m_CurrentScreen->SetGrid(wxSize(500,500)); + m_Parent->ReDrawPanel(); + break; + + case ID_POPUP_GRID_LEVEL_1000 : + m_Parent->m_CurrentScreen->SetGrid(wxSize(1000,1000)); + m_Parent->ReDrawPanel(); + break; + + case ID_POPUP_GRID_USER : + m_Parent->m_CurrentScreen->SetGrid(wxSize(-1,-1)); + m_Parent->ReDrawPanel(); + break; + + default: + DisplayError(this, wxT("WinEDA_DrawPanel::Process_Popup_Zoom() ID error") ); + break; + } + + m_Parent->Affiche_Status_Box(); +} + +class grid_list_struct +{ +public: + int m_value; + int m_id; + const wxChar * m_msg; +}; + + +/*************************************************************/ +void WinEDA_DrawPanel::AddMenuZoom( wxMenu * MasterMenu ) +/*************************************************************/ +/* add the zoom list menu the the MasterMenu. + used in OnRightClick(wxMouseEvent& event) +*/ +{ +int zoom; +wxSize grid; +int zoom_value; +wxString zoom_msg = _("Zoom: "); +wxString grid_msg = _("Grid:"), msg; +int ii; +wxString line; + +grid_list_struct grid_list_pcb[] = +{ + { 1000, ID_POPUP_GRID_LEVEL_1000, wxT(" 100") }, + { 500, ID_POPUP_GRID_LEVEL_500, wxT(" 50") }, + { 250, ID_POPUP_GRID_LEVEL_250, wxT(" 25") }, + { 200, ID_POPUP_GRID_LEVEL_200, wxT(" 20") }, + { 100, ID_POPUP_GRID_LEVEL_100, wxT(" 10") }, + { 50, ID_POPUP_GRID_LEVEL_50, wxT(" 5") }, + { 25, ID_POPUP_GRID_LEVEL_25, wxT(" 2.5") }, + { 20, ID_POPUP_GRID_LEVEL_20, wxT(" 2") }, + { 10, ID_POPUP_GRID_LEVEL_10, wxT(" 1") }, + { 5, ID_POPUP_GRID_LEVEL_5, wxT(" 0.5") }, + { 2, ID_POPUP_GRID_LEVEL_2, wxT(" 0.2") }, + { 1, ID_POPUP_GRID_LEVEL_1, wxT(" 0.1") }, + { 0, ID_POPUP_GRID_USER, _("grid user") } +}; + +grid_list_struct grid_list_schematic[] = +{ + { 50, ID_POPUP_GRID_LEVEL_50, wxT(" 50") }, + { 25, ID_POPUP_GRID_LEVEL_25, wxT(" 25") }, + { 10, ID_POPUP_GRID_LEVEL_10, wxT(" 10") }, + { 5, ID_POPUP_GRID_LEVEL_5, wxT(" 5") }, + { 2, ID_POPUP_GRID_LEVEL_2, wxT(" 2") }, + { 1, ID_POPUP_GRID_LEVEL_1, wxT(" 1") }, + { 0, ID_POPUP_GRID_USER, _("grid user") } +}; + + + ADD_MENUITEM(MasterMenu, ID_POPUP_ZOOM_CENTER, _("Center"), zoom_center_xpm); + ADD_MENUITEM(MasterMenu, ID_POPUP_ZOOM_PLUS, _("Zoom +"), zoom_out_xpm); + ADD_MENUITEM(MasterMenu, ID_POPUP_ZOOM_MOINS, _("Zoom -"), zoom_in_xpm); + +wxMenu * zoom_choice = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU(MasterMenu, zoom_choice, + ID_POPUP_ZOOM_SELECT, _("Zoom Select"), zoom_select_xpm); + + ADD_MENUITEM(MasterMenu, ID_POPUP_ZOOM_AUTO, _("Auto"), zoom_optimal_xpm); + ADD_MENUITEM(MasterMenu, ID_POPUP_ZOOM_REDRAW, _("Redraw"), repaint_xpm); + + /* Create the basic zoom list: */ + zoom = m_Parent->m_CurrentScreen->GetZoom(); + zoom_value = 1; + for ( ii = 0; zoom_value <= m_Parent->m_ZoomMaxValue; zoom_value <<= 1, ii ++ ) // Create zoom choice 1 .. zoom max + { + line.Printf( wxT("%u"), zoom_value); + zoom_choice->Append(ID_POPUP_ZOOM_LEVEL_1 + ii, + zoom_msg + line, wxEmptyString,TRUE); + if( zoom == zoom_value ) + zoom_choice->Check(ID_POPUP_ZOOM_LEVEL_1 + ii, TRUE); + } + +wxMenu * grid_choice = new wxMenu; + ADD_MENUITEM_WITH_SUBMENU(MasterMenu, grid_choice, + ID_POPUP_GRID_SELECT, _("Grid Select"), grid_select_xpm); + + grid = m_Parent->m_CurrentScreen->GetGrid(); + switch(m_Parent->m_Ident ) + { + case MODULE_EDITOR_FRAME: + case GERBER_FRAME: + case PCB_FRAME: + case CVPCB_DISPLAY_FRAME: + for ( ii = 0; ; ii ++ ) // Create grid list + { + msg = grid_msg + grid_list_pcb[ii].m_msg; + grid_choice->Append(grid_list_pcb[ii].m_id, msg, wxEmptyString, TRUE); + if( grid_list_pcb[ii].m_value <= 0 ) + { + if ( m_Parent->m_CurrentScreen->m_UserGridIsON ) + grid_choice->Check(grid_list_pcb[ii].m_id, TRUE); + break; + } + if( grid.x == grid_list_pcb[ii].m_value ) + grid_choice->Check(grid_list_pcb[ii].m_id, TRUE); + } + break; + + case SCHEMATIC_FRAME: + case LIBEDITOR_FRAME: + for ( ii = 0; ; ii ++ ) // Create zoom choice 256 .. 1024 + { + if ( grid_list_schematic[ii].m_value <= 0) + break; + msg = grid_msg + grid_list_schematic[ii].m_msg; + grid_choice->Append(grid_list_schematic[ii].m_id, + msg, wxEmptyString, TRUE); + if( grid.x == grid_list_schematic[ii].m_value ) + grid_choice->Check(grid_list_schematic[ii].m_id, TRUE); + } + break; + + case VIEWER_FRAME: + break; + } + + MasterMenu->AppendSeparator(); + ADD_MENUITEM(MasterMenu, ID_POPUP_CANCEL, _("Close"), cancel_xpm); +} + + + +/**********************************************************/ +void WinEDA_DrawFrame::Process_Zoom(wxCommandEvent& event) +/**********************************************************/ +/* fonction de traitement des boutons de Zoom. + Appelle simplement la fonction de traitement du Zoom de la + fenetre active. +*/ +{ +int id = event.GetId(); + + switch (id) + { + case ID_ZOOM_PLUS_BUTT: + case ID_ZOOM_MOINS_BUTT: + case ID_ZOOM_REDRAW_BUTT: + case ID_ZOOM_PAGE_BUTT: + OnZoom(id); + break; + + default: + DisplayError(this, wxT("WinEDA_DrawFrame::Process_Zoom id Error") ); + break; + } +} + + + +