From f11c97777abdd7d28939caa78abcd5cdbf4f7fd8 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 9 Aug 2013 04:57:18 +0000 Subject: [PATCH] Merged qtest branch into trunk. --- BSDmakefile | 2 - Makefile | 204 -- common/Makefile | 1 - common/array.cpp | 0 common/array.h | 15 + common/basewnd.h | 212 +- common/camera.cpp | 7 +- common/camera.h | 3 +- common/curve.cpp | 0 common/curve.h | 4 +- common/defines.h | 153 +- common/globals.cpp | 10 - common/globals.h | 12 - common/group.h | 4 +- common/im_bmp.cpp | 493 --- common/im_png.cpp | 374 -- common/image.cpp | 482 +-- common/image.h | 58 +- common/keyboard.cpp | 432 --- common/keyboard.h | 151 - common/lc_application.cpp | 812 ++--- common/lc_application.h | 98 +- common/lc_category.cpp | 152 + common/lc_category.h | 25 + common/lc_colors.cpp | 1180 +++--- common/lc_colors.h | 194 +- common/lc_commands.cpp | 1206 ++++++ common/lc_commands.h | 196 + common/lc_global.cpp | 1 + common/lc_global.h | 62 +- common/lc_glwidget.h | 83 + common/lc_library.cpp | 4659 +++++++++++------------- common/lc_library.h | 327 +- common/lc_math.h | 3067 ++++++++-------- common/lc_mesh.cpp | 938 ++--- common/lc_mesh.h | 338 +- common/lc_profile.cpp | 95 + common/lc_profile.h | 103 + common/lc_shortcuts.cpp | 110 + common/lc_shortcuts.h | 25 + common/lc_texture.cpp | 199 +- common/lc_texture.h | 109 +- common/lc_zipfile.cpp | 2232 ++++++------ common/lc_zipfile.h | 166 +- common/light.cpp | 5 +- common/mainwnd.cpp | 110 +- common/mainwnd.h | 66 +- common/message.cpp | 33 - common/message.h | 40 - common/minifig.cpp | 401 +- common/minifig.h | 44 +- common/object.cpp | 4 - common/object.h | 0 common/opengl.cpp | 1221 +------ common/opengl.h | 1303 ++----- common/piece.cpp | 10 +- common/piece.h | 6 +- common/pieceinf.cpp | 2 +- common/preview.cpp | 49 +- common/preview.h | 18 +- common/project.cpp | 3885 +++++++++++--------- common/project.h | 197 +- common/quant.cpp | 662 ---- common/quant.h | 6 - common/system.h | 110 +- common/terrain.cpp | 5 +- common/terrain.h | 4 + common/typedefs.h | 388 -- common/view.cpp | 55 +- common/view.h | 25 +- docs/CREDITS.txt | 15 + docs/INSTALL.txt | 26 - docs/LINUX.txt | 89 - README.txt => docs/README.txt | 0 leocad.pro | 213 ++ leocad.qrc | 66 + linux/Makefile | 1 - linux/basewnd.cpp | 123 - linux/dialogs.cpp | 2840 --------------- linux/dialogs.h | 29 - linux/dlgfile.cpp | 296 -- linux/dlgpiece.cpp | 373 -- linux/glwindow.cpp | 527 --- linux/gtkmisc.cpp | 191 - linux/gtkmisc.h | 25 - linux/gtktools.cpp | 114 - linux/gtktools.h | 12 - linux/lc_config.h | 26 - linux/libdlg.cpp | 346 -- linux/libdlg.h | 35 - linux/linux_gl.cpp | 160 - linux/linux_gl.h | 114 - linux/main.cpp | 783 ---- linux/main.h | 86 - linux/menu.cpp | 282 -- linux/module.mk | 5 - linux/pixmaps/ac-brick.xpm | 25 - linux/pixmaps/ac-cam.xpm | 24 - linux/pixmaps/ac-erase.xpm | 26 - linux/pixmaps/ac-light.xpm | 23 - linux/pixmaps/ac-move.xpm | 25 - linux/pixmaps/ac-next.xpm | 27 - linux/pixmaps/ac-paint.xpm | 25 - linux/pixmaps/ac-pan.xpm | 23 - linux/pixmaps/ac-prev.xpm | 27 - linux/pixmaps/ac-roll.xpm | 26 - linux/pixmaps/ac-rot.xpm | 25 - linux/pixmaps/ac-rotv.xpm | 25 - linux/pixmaps/ac-sel.xpm | 23 - linux/pixmaps/ac-spot.xpm | 24 - linux/pixmaps/ac-zoom.xpm | 25 - linux/pixmaps/ac-zoome.xpm | 27 - linux/pixmaps/ac-zoomr.xpm | 27 - linux/pixmaps/an-anim.xpm | 23 - linux/pixmaps/an-first.xpm | 25 - linux/pixmaps/an-key.xpm | 27 - linux/pixmaps/an-last.xpm | 25 - linux/pixmaps/an-next.xpm | 25 - linux/pixmaps/an-play.xpm | 26 - linux/pixmaps/an-prev.xpm | 25 - linux/pixmaps/an-stop.xpm | 26 - linux/pixmaps/cr_brick.xpm | 41 - linux/pixmaps/cr_cam.xpm | 41 - linux/pixmaps/cr_erase.xpm | 41 - linux/pixmaps/cr_light.xpm | 41 - linux/pixmaps/cr_move.xpm | 41 - linux/pixmaps/cr_paint.xpm | 41 - linux/pixmaps/cr_pan.xpm | 41 - linux/pixmaps/cr_roll.xpm | 41 - linux/pixmaps/cr_rot.xpm | 41 - linux/pixmaps/cr_rotv.xpm | 41 - linux/pixmaps/cr_sel.xpm | 41 - linux/pixmaps/cr_selm.xpm | 43 - linux/pixmaps/cr_spot.xpm | 41 - linux/pixmaps/cr_zoom.xpm | 42 - linux/pixmaps/cr_zoomr.xpm | 41 - linux/pixmaps/icon32.xpm | 41 - linux/pixmaps/info.xpm | 26 - linux/pixmaps/photo.xpm | 28 - linux/pixmaps/pi-acces.xpm | 24 - linux/pixmaps/pi-brick.xpm | 24 - linux/pixmaps/pi-extra.xpm | 25 - linux/pixmaps/pi-misc.xpm | 23 - linux/pixmaps/pi-plate.xpm | 24 - linux/pixmaps/pi-slope.xpm | 24 - linux/pixmaps/pi-space.xpm | 25 - linux/pixmaps/pi-tech.xpm | 26 - linux/pixmaps/pi-tile.xpm | 24 - linux/pixmaps/pi-train.xpm | 25 - linux/pixmaps/st-about.xpm | 24 - linux/pixmaps/st-bg.xpm | 23 - linux/pixmaps/st-copy.xpm | 25 - linux/pixmaps/st-cut.xpm | 24 - linux/pixmaps/st-fast.xpm | 21 - linux/pixmaps/st-help.xpm | 25 - linux/pixmaps/st-lock.xpm | 34 - linux/pixmaps/st-new.xpm | 24 - linux/pixmaps/st-open.xpm | 26 - linux/pixmaps/st-paste.xpm | 29 - linux/pixmaps/st-prev.xpm | 24 - linux/pixmaps/st-print.xpm | 24 - linux/pixmaps/st-redo.xpm | 24 - linux/pixmaps/st-save.xpm | 25 - linux/pixmaps/st-snap.xpm | 27 - linux/pixmaps/st-snapa.xpm | 23 - linux/pixmaps/st-undo.xpm | 24 - linux/profile.cpp | 196 - linux/system.cpp | 796 ---- linux/toolbar.cpp | 1255 ------- linux/toolbar.h | 81 - qt/Info.plist | 74 + qt/lc_config.h | 36 + qt/lc_qaboutdialog.cpp | 20 + qt/lc_qaboutdialog.h | 24 + qt/lc_qaboutdialog.ui | 153 + qt/lc_qapplication.cpp | 35 + qt/lc_qarraydialog.cpp | 98 + qt/lc_qarraydialog.h | 28 + qt/lc_qarraydialog.ui | 217 ++ qt/lc_qcategorydialog.cpp | 50 + qt/lc_qcategorydialog.h | 28 + qt/lc_qcategorydialog.ui | 104 + qt/lc_qcolorlist.cpp | 373 ++ qt/lc_qcolorlist.h | 46 + qt/lc_qcolorpicker.cpp | 179 + qt/lc_qcolorpicker.h | 66 + qt/lc_qeditgroupsdialog.cpp | 121 + qt/lc_qeditgroupsdialog.h | 39 + qt/lc_qeditgroupsdialog.ui | 98 + qt/lc_qfinddialog.cpp | 49 + qt/lc_qfinddialog.h | 28 + qt/lc_qfinddialog.ui | 136 + qt/lc_qglwidget.cpp | 325 ++ qt/lc_qglwidget.h | 35 + qt/lc_qgroupdialog.cpp | 37 + qt/lc_qgroupdialog.h | 27 + qt/lc_qgroupdialog.ui | 91 + qt/lc_qhtmldialog.cpp | 76 + qt/lc_qhtmldialog.h | 29 + qt/lc_qhtmldialog.ui | 330 ++ qt/lc_qimage.cpp | 193 + qt/lc_qimagedialog.cpp | 98 + qt/lc_qimagedialog.h | 29 + qt/lc_qimagedialog.ui | 229 ++ qt/lc_qmainwindow.cpp | 1268 +++++++ qt/lc_qmainwindow.h | 106 + qt/lc_qminifigdialog.cpp | 324 ++ qt/lc_qminifigdialog.h | 40 + qt/lc_qminifigdialog.ui | 741 ++++ qt/lc_qpartstree.cpp | 220 ++ qt/lc_qpartstree.h | 35 + qt/lc_qpovraydialog.cpp | 76 + qt/lc_qpovraydialog.h | 31 + qt/lc_qpovraydialog.ui | 197 + qt/lc_qpreferencesdialog.cpp | 547 +++ qt/lc_qpreferencesdialog.h | 57 + qt/lc_qpreferencesdialog.ui | 670 ++++ qt/lc_qprofile.cpp | 102 + qt/lc_qpropertiesdialog.cpp | 185 + qt/lc_qpropertiesdialog.h | 30 + qt/lc_qpropertiesdialog.ui | 385 ++ qt/lc_qpropertiestree.cpp | 899 +++++ qt/lc_qpropertiestree.h | 104 + qt/lc_qselectdialog.cpp | 202 + qt/lc_qselectdialog.h | 43 + qt/lc_qselectdialog.ui | 111 + qt/lc_qupdatedialog.cpp | 123 + qt/lc_qupdatedialog.h | 32 + qt/lc_qupdatedialog.ui | 77 + qt/lc_qutils.cpp | 75 + qt/lc_qutils.h | 27 + qt/leocad.desktop | 16 + qt/leocad.rc | 1 + linux/leocad-mime.xml => qt/leocad.xml | 26 +- qt/qtmain.cpp | 495 +++ qt/system.cpp | 63 + resources/action_camera.png | Bin 0 -> 412 bytes resources/action_delete.png | Bin 0 -> 306 bytes resources/action_insert.png | Bin 0 -> 347 bytes resources/action_light.png | Bin 0 -> 332 bytes resources/action_move.png | Bin 0 -> 348 bytes resources/action_next.png | Bin 0 -> 397 bytes resources/action_paint.png | Bin 0 -> 331 bytes resources/action_pan.png | Bin 0 -> 333 bytes resources/action_previous.png | Bin 0 -> 393 bytes resources/action_roll.png | Bin 0 -> 339 bytes resources/action_rotate.png | Bin 0 -> 364 bytes resources/action_rotate_view.png | Bin 0 -> 349 bytes resources/action_select.png | Bin 0 -> 289 bytes resources/action_spotlight.png | Bin 0 -> 402 bytes resources/action_zoom.png | Bin 0 -> 400 bytes resources/action_zoom_extents.png | Bin 0 -> 361 bytes resources/action_zoom_region.png | Bin 0 -> 387 bytes resources/application-vnd.leocad.svg | 782 ++++ resources/cursor_camera.png | Bin 0 -> 353 bytes resources/cursor_delete.png | Bin 0 -> 318 bytes resources/cursor_insert.png | Bin 0 -> 329 bytes resources/cursor_light.png | Bin 0 -> 316 bytes resources/cursor_move.png | Bin 0 -> 353 bytes resources/cursor_paint.png | Bin 0 -> 356 bytes resources/cursor_pan.png | Bin 0 -> 358 bytes resources/cursor_roll.png | Bin 0 -> 391 bytes resources/cursor_rotate.png | Bin 0 -> 487 bytes resources/cursor_rotate_view.png | Bin 0 -> 474 bytes resources/cursor_rotatex.png | Bin 0 -> 330 bytes resources/cursor_rotatey.png | Bin 0 -> 323 bytes resources/cursor_select.png | Bin 0 -> 336 bytes resources/cursor_select_multiple.png | Bin 0 -> 369 bytes resources/cursor_spotlight.png | Bin 0 -> 318 bytes resources/cursor_zoom.png | Bin 0 -> 337 bytes resources/cursor_zoom_region.png | Bin 0 -> 412 bytes resources/edit_copy.png | Bin 0 -> 512 bytes resources/edit_cut.png | Bin 0 -> 1237 bytes resources/edit_lock.png | Bin 0 -> 324 bytes resources/edit_paste.png | Bin 0 -> 825 bytes resources/edit_redo.png | Bin 0 -> 1019 bytes resources/edit_snap_angle.png | Bin 0 -> 383 bytes resources/edit_snap_move.png | Bin 0 -> 344 bytes resources/edit_transform.png | Bin 0 -> 267 bytes resources/edit_undo.png | Bin 0 -> 979 bytes resources/file_new.png | Bin 0 -> 1038 bytes resources/file_open.png | Bin 0 -> 854 bytes resources/file_picture.png | Bin 0 -> 173 bytes resources/file_print.png | Bin 0 -> 937 bytes resources/file_print_preview.png | Bin 0 -> 1188 bytes resources/file_save.png | Bin 0 -> 1172 bytes resources/help_email.png | Bin 0 -> 141 bytes resources/help_homepage.png | Bin 0 -> 166 bytes resources/icon64.png | Bin 0 -> 4123 bytes resources/leocad.icns | Bin 0 -> 212496 bytes resources/leocad.ico | Bin 0 -> 71684 bytes resources/leocad.svg | 782 ++++ resources/time_first.png | Bin 0 -> 716 bytes resources/time_last.png | Bin 0 -> 775 bytes resources/time_next.png | Bin 0 -> 689 bytes resources/time_pause.png | Bin 0 -> 425 bytes resources/time_play.png | Bin 0 -> 814 bytes resources/time_previous.png | Bin 0 -> 668 bytes resources/time_stop.png | Bin 0 -> 407 bytes resources/view_split_horizontal.png | Bin 0 -> 118 bytes resources/view_split_vertical.png | Bin 0 -> 121 bytes resources/view_zoomextents.png | Bin 0 -> 168 bytes tools/utils/partsgen.cpp | 267 ++ win/Leocad.cpp | 12 +- win/Povdlg.cpp | 19 - win/System.cpp | 55 - win/povdlg.h | 1 - 307 files changed, 25195 insertions(+), 26292 deletions(-) delete mode 100644 BSDmakefile delete mode 100644 Makefile delete mode 100644 common/Makefile mode change 100755 => 100644 common/array.cpp mode change 100755 => 100644 common/array.h mode change 100755 => 100644 common/curve.cpp mode change 100755 => 100644 common/curve.h delete mode 100644 common/globals.cpp delete mode 100644 common/globals.h delete mode 100755 common/im_bmp.cpp delete mode 100755 common/im_png.cpp delete mode 100644 common/keyboard.cpp delete mode 100644 common/keyboard.h create mode 100644 common/lc_category.cpp create mode 100644 common/lc_category.h create mode 100644 common/lc_commands.cpp create mode 100644 common/lc_commands.h create mode 100644 common/lc_global.cpp create mode 100644 common/lc_glwidget.h create mode 100644 common/lc_profile.cpp create mode 100644 common/lc_profile.h create mode 100644 common/lc_shortcuts.cpp create mode 100644 common/lc_shortcuts.h delete mode 100644 common/message.cpp delete mode 100644 common/message.h mode change 100755 => 100644 common/object.cpp mode change 100755 => 100644 common/object.h mode change 100755 => 100644 common/opengl.cpp mode change 100755 => 100644 common/opengl.h delete mode 100644 common/quant.cpp delete mode 100644 common/quant.h mode change 100755 => 100644 common/system.h delete mode 100644 common/typedefs.h create mode 100644 docs/CREDITS.txt delete mode 100644 docs/INSTALL.txt delete mode 100644 docs/LINUX.txt rename README.txt => docs/README.txt (100%) create mode 100644 leocad.pro create mode 100644 leocad.qrc delete mode 100644 linux/Makefile delete mode 100644 linux/basewnd.cpp delete mode 100644 linux/dialogs.cpp delete mode 100644 linux/dialogs.h delete mode 100755 linux/dlgfile.cpp delete mode 100755 linux/dlgpiece.cpp delete mode 100644 linux/glwindow.cpp delete mode 100755 linux/gtkmisc.cpp delete mode 100755 linux/gtkmisc.h delete mode 100644 linux/gtktools.cpp delete mode 100644 linux/gtktools.h delete mode 100644 linux/lc_config.h delete mode 100755 linux/libdlg.cpp delete mode 100755 linux/libdlg.h delete mode 100755 linux/linux_gl.cpp delete mode 100755 linux/linux_gl.h delete mode 100644 linux/main.cpp delete mode 100644 linux/main.h delete mode 100644 linux/menu.cpp delete mode 100644 linux/module.mk delete mode 100644 linux/pixmaps/ac-brick.xpm delete mode 100644 linux/pixmaps/ac-cam.xpm delete mode 100644 linux/pixmaps/ac-erase.xpm delete mode 100644 linux/pixmaps/ac-light.xpm delete mode 100644 linux/pixmaps/ac-move.xpm delete mode 100644 linux/pixmaps/ac-next.xpm delete mode 100644 linux/pixmaps/ac-paint.xpm delete mode 100644 linux/pixmaps/ac-pan.xpm delete mode 100644 linux/pixmaps/ac-prev.xpm delete mode 100644 linux/pixmaps/ac-roll.xpm delete mode 100644 linux/pixmaps/ac-rot.xpm delete mode 100644 linux/pixmaps/ac-rotv.xpm delete mode 100644 linux/pixmaps/ac-sel.xpm delete mode 100644 linux/pixmaps/ac-spot.xpm delete mode 100644 linux/pixmaps/ac-zoom.xpm delete mode 100644 linux/pixmaps/ac-zoome.xpm delete mode 100644 linux/pixmaps/ac-zoomr.xpm delete mode 100644 linux/pixmaps/an-anim.xpm delete mode 100644 linux/pixmaps/an-first.xpm delete mode 100644 linux/pixmaps/an-key.xpm delete mode 100644 linux/pixmaps/an-last.xpm delete mode 100644 linux/pixmaps/an-next.xpm delete mode 100644 linux/pixmaps/an-play.xpm delete mode 100644 linux/pixmaps/an-prev.xpm delete mode 100644 linux/pixmaps/an-stop.xpm delete mode 100644 linux/pixmaps/cr_brick.xpm delete mode 100644 linux/pixmaps/cr_cam.xpm delete mode 100644 linux/pixmaps/cr_erase.xpm delete mode 100644 linux/pixmaps/cr_light.xpm delete mode 100644 linux/pixmaps/cr_move.xpm delete mode 100644 linux/pixmaps/cr_paint.xpm delete mode 100644 linux/pixmaps/cr_pan.xpm delete mode 100644 linux/pixmaps/cr_roll.xpm delete mode 100644 linux/pixmaps/cr_rot.xpm delete mode 100644 linux/pixmaps/cr_rotv.xpm delete mode 100644 linux/pixmaps/cr_sel.xpm delete mode 100644 linux/pixmaps/cr_selm.xpm delete mode 100644 linux/pixmaps/cr_spot.xpm delete mode 100644 linux/pixmaps/cr_zoom.xpm delete mode 100644 linux/pixmaps/cr_zoomr.xpm delete mode 100644 linux/pixmaps/icon32.xpm delete mode 100644 linux/pixmaps/info.xpm delete mode 100644 linux/pixmaps/photo.xpm delete mode 100644 linux/pixmaps/pi-acces.xpm delete mode 100644 linux/pixmaps/pi-brick.xpm delete mode 100644 linux/pixmaps/pi-extra.xpm delete mode 100644 linux/pixmaps/pi-misc.xpm delete mode 100644 linux/pixmaps/pi-plate.xpm delete mode 100644 linux/pixmaps/pi-slope.xpm delete mode 100644 linux/pixmaps/pi-space.xpm delete mode 100644 linux/pixmaps/pi-tech.xpm delete mode 100644 linux/pixmaps/pi-tile.xpm delete mode 100644 linux/pixmaps/pi-train.xpm delete mode 100644 linux/pixmaps/st-about.xpm delete mode 100644 linux/pixmaps/st-bg.xpm delete mode 100644 linux/pixmaps/st-copy.xpm delete mode 100644 linux/pixmaps/st-cut.xpm delete mode 100644 linux/pixmaps/st-fast.xpm delete mode 100644 linux/pixmaps/st-help.xpm delete mode 100755 linux/pixmaps/st-lock.xpm delete mode 100644 linux/pixmaps/st-new.xpm delete mode 100644 linux/pixmaps/st-open.xpm delete mode 100644 linux/pixmaps/st-paste.xpm delete mode 100644 linux/pixmaps/st-prev.xpm delete mode 100644 linux/pixmaps/st-print.xpm delete mode 100644 linux/pixmaps/st-redo.xpm delete mode 100644 linux/pixmaps/st-save.xpm delete mode 100644 linux/pixmaps/st-snap.xpm delete mode 100644 linux/pixmaps/st-snapa.xpm delete mode 100644 linux/pixmaps/st-undo.xpm delete mode 100755 linux/profile.cpp delete mode 100644 linux/system.cpp delete mode 100644 linux/toolbar.cpp delete mode 100644 linux/toolbar.h create mode 100644 qt/Info.plist create mode 100644 qt/lc_config.h create mode 100644 qt/lc_qaboutdialog.cpp create mode 100644 qt/lc_qaboutdialog.h create mode 100644 qt/lc_qaboutdialog.ui create mode 100644 qt/lc_qapplication.cpp create mode 100644 qt/lc_qarraydialog.cpp create mode 100644 qt/lc_qarraydialog.h create mode 100644 qt/lc_qarraydialog.ui create mode 100644 qt/lc_qcategorydialog.cpp create mode 100644 qt/lc_qcategorydialog.h create mode 100644 qt/lc_qcategorydialog.ui create mode 100644 qt/lc_qcolorlist.cpp create mode 100644 qt/lc_qcolorlist.h create mode 100644 qt/lc_qcolorpicker.cpp create mode 100644 qt/lc_qcolorpicker.h create mode 100644 qt/lc_qeditgroupsdialog.cpp create mode 100644 qt/lc_qeditgroupsdialog.h create mode 100644 qt/lc_qeditgroupsdialog.ui create mode 100644 qt/lc_qfinddialog.cpp create mode 100644 qt/lc_qfinddialog.h create mode 100644 qt/lc_qfinddialog.ui create mode 100644 qt/lc_qglwidget.cpp create mode 100644 qt/lc_qglwidget.h create mode 100644 qt/lc_qgroupdialog.cpp create mode 100644 qt/lc_qgroupdialog.h create mode 100644 qt/lc_qgroupdialog.ui create mode 100644 qt/lc_qhtmldialog.cpp create mode 100644 qt/lc_qhtmldialog.h create mode 100644 qt/lc_qhtmldialog.ui create mode 100644 qt/lc_qimage.cpp create mode 100644 qt/lc_qimagedialog.cpp create mode 100644 qt/lc_qimagedialog.h create mode 100644 qt/lc_qimagedialog.ui create mode 100644 qt/lc_qmainwindow.cpp create mode 100644 qt/lc_qmainwindow.h create mode 100644 qt/lc_qminifigdialog.cpp create mode 100644 qt/lc_qminifigdialog.h create mode 100644 qt/lc_qminifigdialog.ui create mode 100644 qt/lc_qpartstree.cpp create mode 100644 qt/lc_qpartstree.h create mode 100644 qt/lc_qpovraydialog.cpp create mode 100644 qt/lc_qpovraydialog.h create mode 100644 qt/lc_qpovraydialog.ui create mode 100644 qt/lc_qpreferencesdialog.cpp create mode 100644 qt/lc_qpreferencesdialog.h create mode 100644 qt/lc_qpreferencesdialog.ui create mode 100644 qt/lc_qprofile.cpp create mode 100644 qt/lc_qpropertiesdialog.cpp create mode 100644 qt/lc_qpropertiesdialog.h create mode 100644 qt/lc_qpropertiesdialog.ui create mode 100644 qt/lc_qpropertiestree.cpp create mode 100644 qt/lc_qpropertiestree.h create mode 100644 qt/lc_qselectdialog.cpp create mode 100644 qt/lc_qselectdialog.h create mode 100644 qt/lc_qselectdialog.ui create mode 100644 qt/lc_qupdatedialog.cpp create mode 100644 qt/lc_qupdatedialog.h create mode 100644 qt/lc_qupdatedialog.ui create mode 100644 qt/lc_qutils.cpp create mode 100644 qt/lc_qutils.h create mode 100644 qt/leocad.desktop create mode 100644 qt/leocad.rc rename linux/leocad-mime.xml => qt/leocad.xml (96%) create mode 100644 qt/qtmain.cpp create mode 100644 qt/system.cpp create mode 100644 resources/action_camera.png create mode 100644 resources/action_delete.png create mode 100644 resources/action_insert.png create mode 100644 resources/action_light.png create mode 100644 resources/action_move.png create mode 100644 resources/action_next.png create mode 100644 resources/action_paint.png create mode 100644 resources/action_pan.png create mode 100644 resources/action_previous.png create mode 100644 resources/action_roll.png create mode 100644 resources/action_rotate.png create mode 100644 resources/action_rotate_view.png create mode 100644 resources/action_select.png create mode 100644 resources/action_spotlight.png create mode 100644 resources/action_zoom.png create mode 100644 resources/action_zoom_extents.png create mode 100644 resources/action_zoom_region.png create mode 100644 resources/application-vnd.leocad.svg create mode 100644 resources/cursor_camera.png create mode 100644 resources/cursor_delete.png create mode 100644 resources/cursor_insert.png create mode 100644 resources/cursor_light.png create mode 100644 resources/cursor_move.png create mode 100644 resources/cursor_paint.png create mode 100644 resources/cursor_pan.png create mode 100644 resources/cursor_roll.png create mode 100644 resources/cursor_rotate.png create mode 100644 resources/cursor_rotate_view.png create mode 100644 resources/cursor_rotatex.png create mode 100644 resources/cursor_rotatey.png create mode 100644 resources/cursor_select.png create mode 100644 resources/cursor_select_multiple.png create mode 100644 resources/cursor_spotlight.png create mode 100644 resources/cursor_zoom.png create mode 100644 resources/cursor_zoom_region.png create mode 100644 resources/edit_copy.png create mode 100644 resources/edit_cut.png create mode 100644 resources/edit_lock.png create mode 100644 resources/edit_paste.png create mode 100644 resources/edit_redo.png create mode 100644 resources/edit_snap_angle.png create mode 100644 resources/edit_snap_move.png create mode 100644 resources/edit_transform.png create mode 100644 resources/edit_undo.png create mode 100644 resources/file_new.png create mode 100644 resources/file_open.png create mode 100644 resources/file_picture.png create mode 100644 resources/file_print.png create mode 100644 resources/file_print_preview.png create mode 100644 resources/file_save.png create mode 100644 resources/help_email.png create mode 100644 resources/help_homepage.png create mode 100644 resources/icon64.png create mode 100644 resources/leocad.icns create mode 100644 resources/leocad.ico create mode 100644 resources/leocad.svg create mode 100644 resources/time_first.png create mode 100644 resources/time_last.png create mode 100644 resources/time_next.png create mode 100644 resources/time_pause.png create mode 100644 resources/time_play.png create mode 100644 resources/time_previous.png create mode 100644 resources/time_stop.png create mode 100644 resources/view_split_horizontal.png create mode 100644 resources/view_split_vertical.png create mode 100644 resources/view_zoomextents.png create mode 100644 tools/utils/partsgen.cpp diff --git a/BSDmakefile b/BSDmakefile deleted file mode 100644 index 85457488..00000000 --- a/BSDmakefile +++ /dev/null @@ -1,2 +0,0 @@ -all: - gmake ${.MAKEFLAGS} ${.TARGETS} diff --git a/Makefile b/Makefile deleted file mode 100644 index 6af33dbd..00000000 --- a/Makefile +++ /dev/null @@ -1,204 +0,0 @@ -### ALL CONFIGURATION SHOULD BE IN CONFIG.MK, NOT HERE -include config.mk - -### Module directories -MODULES := $(OSDIR) common - -### Look for include files in each of the modules -CPPFLAGS += $(patsubst %,-I%,$(MODULES)) -CPPFLAGS += -g -Wextra -Wall -Wno-unused-parameter -Wshadow - -### Extra libraries if required -LIBS := - -### Each module will add to this -SRC := - -BIN := bin/leocad -OBJDIR := obj - -ifeq ($(findstring $(MAKECMDGOALS), help config-help config clean veryclean source-tgz source-zip), ) --include $(OSDIR)/config.mk -endif - -### Include the description for each module -include $(patsubst %,%/module.mk,$(MODULES)) - -### Determine the object files -OBJ := $(patsubst %.cpp,$(OBJDIR)/%.o,$(filter %.cpp,$(SRC))) - -### Link the program -.PHONY: all static - -all: $(BIN) - -static: bin/leocad.static - -bin/leocad: $(OBJ) bin Makefile - @echo Linking $@ - @$(CXX) -o $@ $(OBJ) $(LIBS) $(LDFLAGS) - -bin/leocad.static: $(OBJ) bin Makefile - $(CXX) -static -o $@ $(OBJ) $(LIBS) $(LDFLAGS) - -bin: - @mkdir bin - -obj: - @mkdir $(OBJDIR) $(addprefix $(OBJDIR)/,$(MODULES)) - -### Include the C/C++ include dependencies -ifeq ($(findstring $(MAKECMDGOALS), help config-help config clean veryclean source-tgz source-zip), ) --include $(OBJ:.o=.d) -endif - -### Calculate C/C++ include dependencies -$(OBJDIR)/%.d: %.cpp obj $(OSDIR)/config.mk - @$(CXX) -MM -MT '$(patsubst %.d,%.o, $@)' $(CXXFLAGS) $(CPPFLAGS) -w $< > $@ - @[ -s $@ ] || rm -f $@ - -### Main compiler rule -$(OBJDIR)/%.o: %.cpp obj $(OSDIR)/config.mk - @echo $< - @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o '$(patsubst %.cpp,%.o, $@)' $< - @[ -s $@ ] || rm -f $@ - -### Various cleaning functions -.PHONY: clean distclean veryclean spotless all - -clean: - @[ ! -d $(OBJDIR) ] || find $(OBJDIR) -name \*.o | xargs rm -f - -veryclean: clean - @rm -rf $(OBJDIR) - @rm -rf bin - @rm -rf arch $(OSDIR)/config.mk - -distclean: veryclean - -### Dependency stuff is done automatically, so these do nothing. -.PHONY: dep depend - - -### Help function -.PHONY: help - -help: - @echo 'Possible Targets are:' - @echo ' help (this is it)' - @echo ' all' - @echo ' install' - @echo ' uninstall' - @echo ' binary' - @echo ' source' - @echo ' (binary and source can be called as' - @echo ' a -zip or -tgz variants)' - @echo ' clean' - @echo ' veryclean' - @echo - -### Rules to make various packaging -.PHONY: binary binary-tgz source-zip source-tgz source install uninstall - -arch: - mkdir arch - -desktop: obj - @echo "[Desktop Entry]" > $(OBJDIR)/leocad.desktop - @echo "Version=1.0" >> $(OBJDIR)/leocad.desktop - @echo "Name=LeoCAD" >> $(OBJDIR)/leocad.desktop - @echo "Comment=Create virtual LEGO models" >> $(OBJDIR)/leocad.desktop - @echo "Comment[eo]=Kreu virtualajn LEGO-ajn modelojn" >> $(OBJDIR)/leocad.desktop - @echo "Comment[it]=Crea modelli LEGO virtuali" >> $(OBJDIR)/leocad.desktop - @echo "Comment[nb]=Lag virtuelle LEGO-modeller" >> $(OBJDIR)/leocad.desktop - @echo "Comment[pt_BR]=Criar modelos virtuais de LEGO" >> $(OBJDIR)/leocad.desktop - @echo "Exec=$(PREFIX)/bin/leocad %f" >> $(OBJDIR)/leocad.desktop - @echo "Terminal=false" >> $(OBJDIR)/leocad.desktop - @echo "Type=Application" >> $(OBJDIR)/leocad.desktop - @echo "Icon=$(PREFIX)/share/pixmaps/leocad.svg" >> $(OBJDIR)/leocad.desktop - @echo "MimeType=application/vnd.leocad;application/x-ldraw;application/x-multi-part-ldraw;application/x-ldlite;" >> $(OBJDIR)/leocad.desktop - @echo "Categories=Graphics;3DGraphics;Education;" >> $(OBJDIR)/leocad.desktop - @echo "Keywords=CAD;LEGO;LDraw;" >> $(OBJDIR)/leocad.desktop - -install: $(BIN) install-data install-update -uninstall: uninstall-data install-update - -install-data: desktop - @install -d $(DESTDIR)$(PREFIX)/bin - @install -c -m 0755 $(BIN) $(DESTDIR)$(PREFIX)/bin/ - @install -d $(DESTDIR)$(PREFIX)/share/man/man1 - @install -c -m 0644 docs/leocad.1 $(DESTDIR)$(PREFIX)/share/man/man1/ - @install -d $(DESTDIR)$(PREFIX)/share/leocad - @install -c -m 0644 tools/icon/icon128.png $(DESTDIR)$(PREFIX)/share/leocad/icon.png - @install -d $(DESTDIR)$(PREFIX)/share/applications - @install -c -m 0644 $(OBJDIR)/leocad.desktop $(DESTDIR)$(PREFIX)/share/applications/ - @install -d $(DESTDIR)$(PREFIX)/share/pixmaps - @install -c -m 0644 tools/icon/icon.svg $(DESTDIR)$(PREFIX)/share/pixmaps/leocad.svg - @install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/mimetypes/ - @rm -f $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/mimetypes/application-vnd.leocad.svg - @ln -s $(PREFIX)/share/pixmaps/leocad.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/mimetypes/application-vnd.leocad.svg - @install -d $(DESTDIR)$(PREFIX)/share/mime/packages - @install -c -m 0644 linux/leocad-mime.xml $(DESTDIR)$(PREFIX)/share/mime/packages/ - -uninstall-data: - @rm -f $(DESTDIR)$(PREFIX)/bin/$(BIN) - @rm -f $(DESTDIR)$(PREFIX)/share/man/man1/leocad.1 - @rm -f $(DESTDIR)$(PREFIX)/share/leocad/icon.png - @rm -f $(DESTDIR)$(PREFIX)/share/applications/leocad.desktop - @rm -f $(DESTDIR)$(PREFIX)/share/pixmaps/leocad.svg - @rm -f $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/mimetypes/application-vnd.leocad.svg - @rm -f $(DESTDIR)$(PREFIX)/share/mime/packages/leocad-mime.xml - -install-update: - @if test -z "$(DESTDIR)"; then \ - if which gtk-update-icon-cache>/dev/null 2>&1; then \ - gtk-update-icon-cache -q -f -t $(DESTDIR)$(PREFIX)/share/icons/hicolor; \ - fi; \ - if which update-mime-database>/dev/null 2>&1; then \ - update-mime-database $(DESTDIR)$(PREFIX)/share/mime/; \ - fi; \ - if which update-desktop-database>/dev/null 2>&1; then \ - update-desktop-database; \ - fi; \ - fi - -binary: binary-zip binary-tgz - -binary-zip: arch/leocad-linux.zip - -binary-tgz: arch/leocad-linux.tgz - -source: source-tgz source-zip - -source-tgz: arch/leocad-src.tgz - -source-zip: arch/leocad-src.zip - -### Create a directory with the files needed for a binary package -package-dir: arch all - mkdir leocad - cp bin/leocad leocad - cp CREDITS.txt leocad/CREDITS - cp README.txt leocad/README - cp docs/INSTALL.txt leocad/INSTALL - cp docs/LINUX.txt leocad/LINUX - cp docs/leocad.1 leocad - -arch/leocad-linux.zip: package-dir - rm -f $@ - zip -r $@ leocad - rm -rf leocad - -arch/leocad-linux.tgz: package-dir - rm -f $@ - tar -cvzf $@ leocad - rm -rf leocad - -arch/leocad-src.tgz: veryclean arch - rm -f $@ - ( cd .. ; tar --exclude=leocad/arch/\* --exclude=.svn -cvzf leocad/$@ leocad ) - -arch/leocad-src.zip: veryclean arch - rm -f $@ - ( cd .. ; zip -r leocad/$@ leocad -x '*/arch/*' -x '*/.svn/*' -x '*~' -x '*/core' -x '*/.#*') - diff --git a/common/Makefile b/common/Makefile deleted file mode 100644 index 05788fd5..00000000 --- a/common/Makefile +++ /dev/null @@ -1 +0,0 @@ -include ../generic.mk diff --git a/common/array.cpp b/common/array.cpp old mode 100755 new mode 100644 diff --git a/common/array.h b/common/array.h old mode 100755 new mode 100644 index 00015b10..e9008d06 --- a/common/array.h +++ b/common/array.h @@ -58,6 +58,21 @@ public: void InsertAt(int Index, const T& Obj); void Sort(LC_OBJARRAY_COMPARE_FUNC SortFunc, void* SortData); + ObjArray& operator=(const ObjArray& Array) + { + m_Length = Array.m_Length; + m_Alloc = Array.m_Alloc; + m_Grow = Array.m_Grow; + + delete[] m_Data; + m_Data = new T[m_Alloc]; + + for (int i = 0; i < m_Length; i++) + m_Data[i] = Array.m_Data[i]; + + return *this; + } + T& operator [](int Index) const { return m_Data[Index]; } diff --git a/common/basewnd.h b/common/basewnd.h index f26f4f57..9980e754 100644 --- a/common/basewnd.h +++ b/common/basewnd.h @@ -1,40 +1,15 @@ #ifndef _BASEWND_H_ #define _BASEWND_H_ -#include +#include "defines.h" +#include "lc_math.h" +#include "array.h" +#include "project.h" +#include "lc_category.h" +#include "image.h" +#include "lc_shortcuts.h" -// FIXME: move this to another place -#ifdef WIN32 -#include "stdafx.h" -typedef CWnd* BaseWndXID; -typedef struct -{ - CWnd* wnd; - int index; - UINT command; -} BaseMenuItem; -#endif - -#ifdef LC_LINUX -#include -typedef GtkWidget* BaseWndXID; -typedef struct -{ - GtkWidget* widget; - GtkAccelGroup* accel; -} BaseMenuItem; -#endif - -#ifdef LC_MACOSX -typedef void* BaseWndXID; -typedef struct -{ - void* Dummy; -} BaseMenuItem; -#endif - -// ============================================================================= -// Message Box constants +class Group; #define LC_OK 1 #define LC_CANCEL 2 @@ -59,44 +34,155 @@ typedef struct #define LC_MB_TYPEMASK 0x00F #define LC_MB_ICONMASK 0x0F0 -// ============================================================================= +enum LC_DIALOG_TYPE +{ + LC_DIALOG_OPEN_PROJECT, + LC_DIALOG_SAVE_PROJECT, + LC_DIALOG_MERGE_PROJECT, + LC_DIALOG_SAVE_IMAGE, + LC_DIALOG_EXPORT_3DSTUDIO, + LC_DIALOG_EXPORT_BRICKLINK, + LC_DIALOG_EXPORT_CSV, + LC_DIALOG_EXPORT_HTML, + LC_DIALOG_EXPORT_POVRAY, + LC_DIALOG_EXPORT_WAVEFRONT, + LC_DIALOG_PROPERTIES, + LC_DIALOG_PRINT, + LC_DIALOG_FIND, + LC_DIALOG_SELECT_BY_NAME, + LC_DIALOG_MINIFIG, + LC_DIALOG_PIECE_ARRAY, + LC_DIALOG_PIECE_GROUP, + LC_DIALOG_EDIT_GROUPS, + LC_DIALOG_PREFERENCES, + LC_DIALOG_CHECK_UPDATES, + LC_DIALOG_ABOUT +}; -class BaseWnd +struct lcImageDialogOptions +{ + char FileName[LC_MAXPATH]; + LC_IMAGE_FORMAT Format; + bool Transparent; + int Width; + int Height; + int Start; + int End; +}; + +struct lcHTMLDialogOptions +{ + char PathName[LC_MAXPATH]; + LC_IMAGE_FORMAT ImageFormat; + bool TransparentImages; + bool SinglePage; + bool IndexPage; + int StepImagesWidth; + int StepImagesHeight; + bool HighlightNewParts; + bool PartsListStep; + bool PartsListEnd; + bool PartsListImages; + int PartImagesColor; + int PartImagesWidth; + int PartImagesHeight; +}; + +struct lcPOVRayDialogOptions +{ + char FileName[LC_MAXPATH]; + char POVRayPath[LC_MAXPATH]; + char LGEOPath[LC_MAXPATH]; + bool Render; +}; + +struct lcPropertiesDialogOptions +{ + const char* Title; + + char Author[101]; + char Description[101]; + char Comments[256]; + + int BackgroundType; + lcVector3 SolidColor; + lcVector3 GradientColor1; + lcVector3 GradientColor2; + char BackgroundFileName[LC_MAXPATH]; + bool BackgroundTile; + bool FogEnabled; + float FogDensity; + lcVector3 FogColor; + lcVector3 AmbientColor; + bool DrawFloor; + bool SetDefault; + + ObjArray PartsUsed; +}; + +struct lcArrayDialogOptions +{ + int Counts[3]; + lcVector3 Offsets[3]; + lcVector3 Rotations[3]; +}; + +struct lcEditGroupsDialogOptions +{ + PtrArray PieceParents; + PtrArray GroupParents; +}; + +struct lcSelectDialogOptions +{ + ObjArray Selection; +}; + +struct lcPreferencesDialogOptions +{ + char DefaultAuthor[101]; + char ProjectsPath[LC_MAXPATH]; + char LibraryPath[LC_MAXPATH]; + int MouseSensitivity; + int CheckForUpdates; + + lcuint32 Snap; + lcuint32 Detail; + float LineWidth; + int AASamples; + int GridSize; + + ObjArray Categories; + bool CategoriesModified; + bool CategoriesDefault; + + lcKeyboardShortcuts KeyboardShortcuts; + bool ShortcutsModified; + bool ShortcutsDefault; +}; + +class lcBaseWindow { public: - BaseWnd (BaseWnd *parent, int menu_count); - virtual ~BaseWnd (); + lcBaseWindow() + { + mHandle = NULL; + } - int MessageBox (const char* text, const char* caption="LeoCAD", int flags=LC_MB_OK|LC_MB_ICONINFORMATION); - void BeginWait (); - void EndWait (); - void SetTitle (const char *title); + ~lcBaseWindow() + { + } - void ShowMenuItem (int id, bool show); - void EnableMenuItem (int id, bool enable); - void CheckMenuItem (int id, bool check); - void SetMenuItemText (int id, const char *text); + bool DoDialog(LC_DIALOG_TYPE Type, void* Data); - BaseWndXID GetXID () const - { return m_pXID; } - void SetXID (BaseWndXID id) - { m_pXID = id; } + int DoMessageBox(const char* Text, int Flags = LC_MB_OK | LC_MB_ICONINFORMATION) + { + return DoMessageBox(Text, "LeoCAD", Flags); + } -#ifdef LC_LINUX - // FIXME: remove - operator GtkWidget* () const - { return m_pXID; } -#endif + int DoMessageBox(const char* Text, const char* Caption = "LeoCAD", int Flags = LC_MB_OK | LC_MB_ICONINFORMATION); - BaseMenuItem* GetMenuItem (int id) const - { return &m_pMenuItems[id]; } - void SetMenuItem (int id, BaseMenuItem* item) - { memcpy (&m_pMenuItems[id], item, sizeof (BaseMenuItem)); } - - protected: - BaseWnd* m_pParent; - BaseWndXID m_pXID; - BaseMenuItem* m_pMenuItems; + void* mHandle; }; #endif // _BASEWND_H_ diff --git a/common/camera.cpp b/common/camera.cpp index 62f0064b..eee2871d 100644 --- a/common/camera.cpp +++ b/common/camera.cpp @@ -6,7 +6,6 @@ #include #include #include "opengl.h" -#include "globals.h" #include "lc_file.h" #include "camera.h" #include "view.h" @@ -665,7 +664,7 @@ void Camera::LoadProjection(float fAspect) void Camera::ZoomExtents(View* view, const lcVector3& Center, const lcVector3* Points, int NumPoints, unsigned short nTime, bool bAnimation, bool bAddKey) { - int Viewport[4] = { 0, 0, view->GetWidth(), view->GetHeight() }; + int Viewport[4] = { 0, 0, view->mWidth, view->mHeight }; float Aspect = (float)Viewport[2]/(float)Viewport[3]; @@ -687,7 +686,7 @@ void Camera::ZoomExtents(View* view, const lcVector3& Center, const lcVector3* P void Camera::ZoomRegion(View* view, float Left, float Right, float Bottom, float Top, unsigned short nTime, bool bAnimation, bool bAddKey) { - int Viewport[4] = { 0, 0, view->GetWidth(), view->GetHeight() }; + int Viewport[4] = { 0, 0, view->mWidth, view->mHeight }; float Aspect = (float)Viewport[2]/(float)Viewport[3]; const lcMatrix44& ModelView = mWorldView; @@ -781,7 +780,7 @@ void Camera::DoRotate(int dx, int dy, int mouse, unsigned short nTime, bool bAni Z[1] = -Z[1]; dx = -dx; } - + lcMatrix44 YRot(lcVector4(Z[0], Z[1], 0.0f, 0.0f), lcVector4(-Z[1], Z[0], 0.0f, 0.0f), lcVector4(0.0f, 0.0f, 1.0f, 0.0f), lcVector4(0.0f, 0.0f, 0.0f, 1.0f)); lcMatrix44 transform = lcMul(lcMul(lcMul(lcMatrix44AffineInverse(YRot), lcMatrix44RotationY(0.1f * dy / (21 - mouse))), YRot), lcMatrix44RotationZ(-0.1f * dx / (21 - mouse))); diff --git a/common/camera.h b/common/camera.h index e79f69b7..e4cb5ecb 100644 --- a/common/camera.h +++ b/common/camera.h @@ -158,6 +158,8 @@ public: void GetTileInfo(int* row, int* col, int* width, int* height); bool EndTile(); + char m_strName[81]; + float m_fovy; float m_zNear; float m_zFar; @@ -174,7 +176,6 @@ protected: CameraTarget* m_pTarget; // Attributes - char m_strName[81]; unsigned char m_nState; unsigned char m_nType; diff --git a/common/curve.cpp b/common/curve.cpp old mode 100755 new mode 100644 diff --git a/common/curve.h b/common/curve.h old mode 100755 new mode 100644 index 21a7a35c..9777c2e4 --- a/common/curve.h +++ b/common/curve.h @@ -1,6 +1,6 @@ #ifndef _CURVE_H_ #define _CURVE_H_ - +#if 0 #include "object.h" #include "opengl.h" #include "array.h" @@ -123,5 +123,5 @@ class Curve : public Object PtrArray m_Points; }; - +#endif #endif // _CURVE_H_ diff --git a/common/defines.h b/common/defines.h index a99c258c..0739c258 100644 --- a/common/defines.h +++ b/common/defines.h @@ -1,99 +1,33 @@ -// Constant definitions. -// - #ifndef _DEFINES_H_ #define _DEFINES_H_ -// Check for supported platforms. -#if !(defined(LC_WINDOWS) || defined(LC_LINUX) || defined(LC_MACOSX)) -#error YOU NEED TO DEFINE YOUR OS -#endif - -// ============================================================================ -// Old defines (mostly deprecated). +// TODO: cleanup defines and remove this file #ifdef LC_WINDOWS #define LC_MAXPATH 260 //_MAX_PATH -#define KEY_SHIFT VK_SHIFT #define KEY_CONTROL VK_CONTROL -#define KEY_ALT VK_MENU #define KEY_ESCAPE VK_ESCAPE #define KEY_TAB VK_TAB -#define KEY_INSERT VK_INSERT -#define KEY_DELETE VK_DELETE -#define KEY_UP VK_UP -#define KEY_DOWN VK_DOWN -#define KEY_LEFT VK_LEFT -#define KEY_RIGHT VK_RIGHT -#define KEY_PRIOR VK_PRIOR -#define KEY_NEXT VK_NEXT -#define KEY_PLUS VK_ADD -#define KEY_MINUS VK_SUBTRACT - -#define isnan _isnan #endif -#ifdef LC_LINUX -#include +#ifdef LC_QT +#define LC_MAXPATH 1024//MAXPATHLEN //FILENAME_MAX -#define LC_MAXPATH 1024 //FILENAME_MAX -#define KEY_SHIFT 0x01 -#define KEY_CONTROL 0x02 -#define KEY_ALT 0x03 -#define KEY_ESCAPE 0x04 -#define KEY_TAB 0x05 -#define KEY_INSERT 0x06 -#define KEY_DELETE 0x07 -#define KEY_UP 0x08 -#define KEY_DOWN 0x09 -#define KEY_LEFT 0x0A -#define KEY_RIGHT 0x0B -#define KEY_PRIOR 0x0C -#define KEY_NEXT 0x0D -#define KEY_PLUS '+' -#define KEY_MINUS '-' +#define KEY_CONTROL Qt::CTRL +#define KEY_ESCAPE Qt::Key_Escape +#define KEY_TAB Qt::Key_Tab +#ifndef WIN32 char* strupr(char* string); char* strlwr(char* string); int stricmp(const char* str1, const char* str2); - #endif -#ifdef LC_MACOSX -#include -#define LC_MAXPATH MAXPATHLEN //FILENAME_MAX - -#define KEY_SHIFT 0x01 -#define KEY_CONTROL 0x02 -#define KEY_ESCAPE 0x03 -#define KEY_TAB 0x04 -#define KEY_INSERT 0x05 -#define KEY_DELETE 0x06 -#define KEY_UP 0x07 -#define KEY_DOWN 0x08 -#define KEY_LEFT 0x09 -#define KEY_RIGHT 0x0A -#define KEY_PRIOR 0x0B -#define KEY_NEXT 0x0C -#define KEY_PLUS '+' -#define KEY_MINUS '-' - -char* strupr(char* string); -char* strlwr(char* string); -int stricmp(const char* str1, const char* str2); - #endif - ///////////////////////////////////////////////////////////////////////////// // LeoCAD constants -#ifndef LC_WINDOWS -#define RGB(r, g, b) ((unsigned long)(((unsigned char) (r) | ((unsigned short) (g) << 8))|(((unsigned long) (unsigned char) (b)) << 16))) -#endif - -#define FLOATRGB(f) RGB(f[0]*255, f[1]*255, f[2]*255) - #define LC_FOURCC(ch0, ch1, ch2, ch3) (lcuint32)((lcuint32)(lcuint8)(ch0) | ((lcuint32)(lcuint8)(ch1) << 8) | \ ((lcuint32)(lcuint8)(ch2) << 16) | ((lcuint32)(lcuint8)(ch3) << 24 )) @@ -101,57 +35,6 @@ int stricmp(const char* str1, const char* str2); #define LC_STR_VERSION "LeoCAD 0.7 Project\0\0" // char[20] - -//#define DET_BACKFACES 0x00001 // Draw backfaces -//#define DET_DEPTH 0x00002 // Enable depth test -//#define DET_CLEAR 0x00004 // Use clear colors -#define LC_DET_LIGHTING 0x00008 // Lighting -#define LC_DET_SMOOTH 0x00010 // Smooth shading -//#define DET_STUDS 0x00020 // Draw studs -//#define DET_WIREFRAME 0x00040 // Wireframe -//#define LC_DET_ANTIALIAS 0x00080 // Turn on anti-aliasing -#define LC_DET_BRICKEDGES 0x00100 // Draw lines -//#define LC_DET_DITHER 0x00200 // Enable dithering -//#define LC_DET_BOX_FILL 0x00400 // Filled boxes -//#define LC_DET_HIDDEN_LINE 0x00800 // Remove hidden lines -//#define DET_STUDS_BOX 0x01000 // Draw studs as boxes -//#define LC_DET_LINEAR 0x02000 // Linear filtering -#define LC_DET_FAST 0x04000 // Fast rendering (boxes) -//#define LC_DET_BACKGROUND 0x08000 // Background rendering -//#define LC_DET_SCREENDOOR 0x10000 // No alpha blending - -#define LC_DRAW_AXIS 0x0001 // Orientation icon -#define LC_DRAW_GRID 0x0002 // Grid -#define LC_DRAW_SNAP_A 0x0004 // Snap Angle -#define LC_DRAW_SNAP_X 0x0008 // Snap X -#define LC_DRAW_SNAP_Y 0x0010 // Snap Y -#define LC_DRAW_SNAP_Z 0x0020 // Snap Z -#define LC_DRAW_SNAP_XYZ (LC_DRAW_SNAP_X | LC_DRAW_SNAP_Y | LC_DRAW_SNAP_Z) -#define LC_DRAW_GLOBAL_SNAP 0x0040 // Don't allow relative snap. -//#define LC_DRAW_MOVE 0x0080 // Switch to move after insert -#define LC_DRAW_LOCK_X 0x0100 // Lock X -#define LC_DRAW_LOCK_Y 0x0200 // Lock Y -#define LC_DRAW_LOCK_Z 0x0400 // Lock Z -#define LC_DRAW_LOCK_XYZ (LC_DRAW_LOCK_X | LC_DRAW_LOCK_Y | LC_DRAW_LOCK_Z) -#define LC_DRAW_MOVEAXIS 0x0800 // Move on fixed axis -//#define LC_DRAW_PREVIEW 0x1000 // Show piece position -#define LC_DRAW_CM_UNITS 0x2000 // Use centimeters -//#define LC_DRAW_3DMOUSE 0x4000 // Mouse moves in all directions - -// #define RENDER_FAST 0x001 -// #define RENDER_BACKGROUND 0x002 -#define LC_SCENE_FOG 0x004 // Enable fog -// #define RENDER_FOG_BG 0x008 // Use bg color for fog -#define LC_SCENE_BG 0x010 // Draw bg image -// #define RENDER_BG_FAST 0x020 -#define LC_SCENE_BG_TILE 0x040 // Tile bg image -#define LC_SCENE_FLOOR 0x080 // Render floor -#define LC_SCENE_GRADIENT 0x100 // Draw gradient - -#define LC_TERRAIN_FLAT 0x01 // Flat terrain -#define LC_TERRAIN_TEXTURE 0x02 // Use texture -#define LC_TERRAIN_SMOOTH 0x04 // Smooth shading - #define LC_AUTOSAVE_FLAG 0x100000 // Enable auto-saving #define LC_SEL_NO_PIECES 0x001 // No pieces in the project @@ -165,26 +48,4 @@ int stricmp(const char* str1, const char* str2); #define LC_SEL_FOCUSGROUP 0x200 // focused piece is grouped #define LC_SEL_CANGROUP 0x400 // can make a new group -// Image Options -#define LC_IMAGE_PROGRESSIVE 0x1000 -#define LC_IMAGE_TRANSPARENT 0x2000 -#define LC_IMAGE_HIGHCOLOR 0x4000 -#define LC_IMAGE_MASK 0x7000 - -// HTML export options -#define LC_HTML_SINGLEPAGE 0x01 -#define LC_HTML_INDEX 0x02 -#define LC_HTML_IMAGES 0x04 -#define LC_HTML_LISTEND 0x08 -#define LC_HTML_LISTSTEP 0x10 -#define LC_HTML_HIGHLIGHT 0x20 -//#define LC_HTML_HTMLEXT 0x40 -#define LC_HTML_LISTID 0x80 - -// Piece library update -#define LC_UPDATE_DELETE 0x00 -#define LC_UPDATE_DESCRIPTION 0x01 -#define LC_UPDATE_DRAWINFO 0x02 -#define LC_UPDATE_NEWPIECE 0x04 - #endif // _DEFINES_H_ diff --git a/common/globals.cpp b/common/globals.cpp deleted file mode 100644 index 2454fcbf..00000000 --- a/common/globals.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// -// Global variables common to all platforms. -// - -#include "lc_global.h" -#include -#include "globals.h" - -Messenger* messenger; -MainWnd* main_window; diff --git a/common/globals.h b/common/globals.h deleted file mode 100644 index 59c3ddb5..00000000 --- a/common/globals.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _GLOBALS_H_ -#define _GLOBALS_H_ - -#include "console.h" - -class Messenger; -extern Messenger* messenger; - -class MainWnd; -extern MainWnd* main_window; - -#endif // _GLOBALS_H_ diff --git a/common/group.h b/common/group.h index 34d74482..6d6b7955 100644 --- a/common/group.h +++ b/common/group.h @@ -1,6 +1,8 @@ #ifndef _GROUP_H_ #define _GROUP_H_ +#define LC_MAX_GROUP_NAME 64 + class Group { public: @@ -18,7 +20,7 @@ public: void FileLoad(lcFile* file); void FileSave(lcFile* file, Group* pGroups); - char m_strName[65]; + char m_strName[LC_MAX_GROUP_NAME + 1]; float m_fCenter[3]; }; diff --git a/common/im_bmp.cpp b/common/im_bmp.cpp deleted file mode 100755 index 5e3ca4bc..00000000 --- a/common/im_bmp.cpp +++ /dev/null @@ -1,493 +0,0 @@ -#include "lc_global.h" -#include -#include -#include "quant.h" -#include "image.h" -#include "lc_file.h" - -// ======================================================== - -bool Image::LoadBMP(lcFile& file) -{ - lcint32 bmWidth, bmHeight; - lcuint16 bmPlanes, bmBitsPixel; - lcuint8 m1, m2; - typedef struct { - unsigned char rgbBlue; - unsigned char rgbGreen; - unsigned char rgbRed; - unsigned char rgbReserved; - } RGBQUAD; - lcint16 res1,res2; - lcint32 filesize, pixoff; - lcint32 bmisize, compression; - lcint32 xscale, yscale; - lcint32 colors, impcol, rc; - lcuint32 sizeimage, m_bytesRead = 0; - - FreeData (); - - if (file.ReadU8(&m1, 1) != 1) - return false; - m_bytesRead++; - - if (file.ReadU8(&m2, 1) != 1) - return false; - m_bytesRead++; - - if ((m1 != 'B') || (m2 != 'M')) - return false; - - rc = file.ReadS32(&filesize, 1); m_bytesRead+=4; - if (rc != 1) { return false; } - - rc = file.ReadS16(&res1, 1); m_bytesRead+=2; - if (rc != 1) { return false; } - - rc = file.ReadS16(&res2, 1); m_bytesRead+=2; - if (rc != 1) { return false; } - - rc = file.ReadS32(&pixoff, 1); m_bytesRead+=4; - if (rc != 1) { return false; } - - rc = file.ReadS32(&bmisize, 1); m_bytesRead+=4; - if (rc != 1) { return false; } - - rc = file.ReadS32(&bmWidth, 1); m_bytesRead+=4; - if (rc != 1) { return false; } - - rc = file.ReadS32(&bmHeight, 1); m_bytesRead+=4; - if (rc != 1) { return false; } - - rc = file.ReadU16(&bmPlanes, 1); m_bytesRead+=2; - if (rc != 1) { return false; } - - rc = file.ReadU16(&bmBitsPixel, 1); m_bytesRead+=2; - if (rc != 1) { return false; } - - rc = file.ReadS32(&compression, 1); m_bytesRead+=4; - if (rc != 1) { return false; } - - rc = file.ReadU32(&sizeimage, 1); m_bytesRead+=4; - if (rc != 1) {return false; } - - rc = file.ReadS32(&xscale, 1); m_bytesRead+=4; - if (rc != 1) { return false; } - - rc = file.ReadS32(&yscale, 1); m_bytesRead+=4; - if (rc != 1) { return false; } - - rc = file.ReadS32(&colors, 1); m_bytesRead+=4; - if (rc != 1) { return false; } - - rc = file.ReadS32(&impcol, 1); m_bytesRead+=4; - if (rc != 1) { return false; } - - if (colors == 0) - colors = 1 << bmBitsPixel; - - RGBQUAD *colormap = NULL; - - if (bmBitsPixel != 24) - { - colormap = new RGBQUAD[colors]; - if (colormap == NULL) - return false; - - int i; - for (i = 0; i < colors; i++) - { - unsigned char r ,g, b, dummy; - - rc = file.ReadU8(&b, 1); - m_bytesRead++; - if (rc!=1) - { - delete [] colormap; - return false; - } - - rc = file.ReadU8(&g, 1); - m_bytesRead++; - if (rc!=1) - { - delete [] colormap; - return false; - } - - rc = file.ReadU8(&r, 1); - m_bytesRead++; - if (rc != 1) - { - delete [] colormap; - return false; - } - - rc = file.ReadU8(&dummy, 1); - m_bytesRead++; - if (rc != 1) - { - delete [] colormap; - return false; - } - - colormap[i].rgbRed = r; - colormap[i].rgbGreen = g; - colormap[i].rgbBlue = b; - } - } - - if ((long)m_bytesRead > pixoff) - { - delete [] colormap; - return false; - } - - while ((long)m_bytesRead < pixoff) - { - lcuint8 dummy; - file.ReadU8(&dummy, 1); - m_bytesRead++; - } - - int w = bmWidth; - int h = bmHeight; - - // set the output params - m_pData = (unsigned char*)malloc (w*h*3); - long row_size = w * 3; - - if (m_pData != NULL) - { - m_nWidth = w; - m_nHeight = h; - m_bAlpha = false; - unsigned char* outbuf = m_pData; - long row = 0; - long rowOffset = 0; - - if (compression == 0) // BI_RGB - { - // read rows in reverse order - for (row=bmHeight-1;row>=0;row--) - { - // which row are we working on? - rowOffset = (long unsigned)row*row_size; - - if (bmBitsPixel == 24) - { - for (int col=0;col> bit_count) & mask; - - // lookup the color from the colormap - stuff it in our buffer - // swap red and blue - *(outbuf + rowOffset + col * 3 + 2) = colormap[pix].rgbBlue; - *(outbuf + rowOffset + col * 3 + 1) = colormap[pix].rgbGreen; - *(outbuf + rowOffset + col * 3 + 0) = colormap[pix].rgbRed; - } - - // read DWORD padding - while ((m_bytesRead-pixoff)&3) - { - lcuint8 dummy; - if (file.ReadU8(&dummy, 1) != 1) - { - FreeData (); - if (colormap) - delete [] colormap; - return false; - } - m_bytesRead++; - } - } - } - } - else - { - int i, x = 0; - unsigned char c, c1 = 0, *pp; - row = 0; - pp = outbuf + (bmHeight-1)*bmWidth*3; - - if (bmBitsPixel == 8) - { - while (row < bmHeight) - { - c = file.ReadU8(); - - if (c) - { - // encoded mode - c1 = file.ReadU8(); - for (i = 0; i < c; x++, i++) - { - *pp = colormap[c1].rgbRed; pp++; - *pp = colormap[c1].rgbGreen; pp++; - *pp = colormap[c1].rgbBlue; pp++; - } - } - else - { - // c==0x00, escape codes - c = file.ReadU8(); - - if (c == 0x00) // end of line - { - row++; - x = 0; - pp = outbuf + (bmHeight-row-1)*bmWidth*3; - } - else if (c == 0x01) - break; // end of pic - else if (c == 0x02) // delta - { - c = file.ReadU8(); - x += c; - c = file.ReadU8(); - row += c; - pp = outbuf + x*3 + (bmHeight-row-1)*bmWidth*3; - } - else // absolute mode - { - for (i = 0; i < c; x++, i++) - { - c1 = file.ReadU8(); - *pp = colormap[c1].rgbRed; pp++; - *pp = colormap[c1].rgbGreen; pp++; - *pp = colormap[c1].rgbBlue; pp++; - } - - if (c & 1) - file.ReadU8(); // odd length run: read an extra pad byte - } - } - } - } - else if (bmBitsPixel == 4) - { - while (row < bmHeight) - { - c = file.ReadU8(); - - if (c) - { - // encoded mode - c1 = file.ReadU8(); - for (i = 0; i < c; x++, i++) - { - *pp = colormap[(i&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f)].rgbRed; pp++; - *pp = colormap[(i&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f)].rgbGreen; pp++; - *pp = colormap[(i&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f)].rgbBlue; pp++; - } - } - else - { - // c==0x00, escape codes - c = file.ReadU8(); - - if (c == 0x00) // end of line - { - row++; - x = 0; - pp = outbuf + (bmHeight-row-1)*bmWidth*3; - } - else if (c == 0x01) - break; // end of pic - else if (c == 0x02) // delta - { - c = file.ReadU8(); - x += c; - c = file.ReadU8(); - row += c; - pp = outbuf + x*3 + (bmHeight-row-1)*bmWidth*3; - } - else // absolute mode - { - for (i = 0; i < c; x++, i++) - { - if ((i&1) == 0) - c1 = file.ReadU8(); - *pp = colormap[(i&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f)].rgbRed; pp++; - *pp = colormap[(i&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f)].rgbGreen; pp++; - *pp = colormap[(i&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f)].rgbBlue; pp++; - } - - if (((c&3) == 1) || ((c&3) == 2)) - file.ReadU8(); // odd length run: read an extra pad byte - } - } - } - } - } - - if (colormap) - delete [] colormap; - } - - return true; -} - -// ======================================================== - -bool Image::SaveBMP(lcFile& file, bool quantize) const -{ - lcuint16 bits; - lcuint32 cmap, bfSize; - lcuint8 pal[3][256], *colormappedbuffer = NULL; - - if (quantize) - { - colormappedbuffer = (unsigned char*)malloc(m_nWidth*m_nHeight); - dl1quant (m_pData, colormappedbuffer, m_nWidth, m_nHeight, 256, true, pal); - bits = 8; - cmap = 256; - bfSize = 1078 + m_nWidth*m_nHeight; - } - else - { - bits = 24; - cmap = 0; - bfSize = 54 + m_nWidth*m_nHeight*3; - } - - long byteswritten = 0; - lcuint32 pixoff = 54 + cmap*4; - lcuint16 res = 0; - lcuint8 m1 ='B', m2 ='M'; - file.WriteU8(&m1, 1); byteswritten++; // B - file.WriteU8(&m2, 1); byteswritten++; // M - file.WriteU32(&bfSize, 1); byteswritten+=4;// bfSize - file.WriteU16(&res, 1); byteswritten+=2;// bfReserved1 - file.WriteU16(&res, 1); byteswritten+=2;// bfReserved2 - file.WriteU32(&pixoff, 1); byteswritten+=4;// bfOffBits - - lcuint32 biSize = 40, compress = 0, size = 0; - lcuint32 width = m_nWidth, height = m_nHeight, pixels = 0; - lcuint16 planes = 1; - file.WriteU32(&biSize, 1); byteswritten+=4;// biSize - file.WriteU32(&width, 1); byteswritten+=4;// biWidth - file.WriteU32(&height, 1); byteswritten+=4;// biHeight - file.WriteU16(&planes, 1); byteswritten+=2;// biPlanes - file.WriteU16(&bits, 1); byteswritten+=2;// biBitCount - file.WriteU32(&compress, 1); byteswritten+=4;// biCompression - file.WriteU32(&size, 1); byteswritten+=4;// biSizeImage - file.WriteU32(&pixels, 1); byteswritten+=4;// biXPelsPerMeter - file.WriteU32(&pixels, 1); byteswritten+=4;// biYPelsPerMeter - file.WriteU32(&cmap, 1); byteswritten+=4;// biClrUsed - file.WriteU32(&cmap, 1); byteswritten+=4;// biClrImportant - - if (quantize) - { - for (int i = 0; i < 256; i++) - { - file.WriteU8(pal[2][i]); - file.WriteU8(pal[1][i]); - file.WriteU8(pal[0][i]); - file.WriteU8(0); // dummy - } - - for (int row = 0; row < m_nHeight; row++) - { - int pixbuf = 0; - - for (int col = 0; col < m_nWidth; col++) - { - int offset = (m_nHeight-row-1) * width + col; // offset into our color-mapped RGB buffer - unsigned char pval = *(colormappedbuffer + offset); - - pixbuf = (pixbuf << 8) | pval; - - file.WriteU8(pixbuf); - pixbuf = 0; - byteswritten++; - } - - // DWORD align - while ((byteswritten - pixoff) & 3) - { - file.WriteU8(0); - byteswritten++; - } - } - - free(colormappedbuffer); - } - else - { - unsigned long widthDW = (((m_nWidth*24) + 31) / 32 * 4); - long row, row_size = m_nWidth*3; - for (row = 0; row < m_nHeight; row++) - { - unsigned char* buf = m_pData+(m_nHeight-row-1)*row_size; - - // write a row - for (int col = 0; col < row_size; col += 3) - { - file.WriteU8(buf[col+2]); - file.WriteU8(buf[col+1]); - file.WriteU8(buf[col]); - } - byteswritten += row_size; - - for (unsigned long count = row_size; count < widthDW; count++) - { - file.WriteU8(0); // dummy - byteswritten++; - } - } - } - - return true; -} diff --git a/common/im_png.cpp b/common/im_png.cpp deleted file mode 100755 index 79360788..00000000 --- a/common/im_png.cpp +++ /dev/null @@ -1,374 +0,0 @@ -#include "lc_global.h" -#include -#include "image.h" -#include "lc_file.h" - -#ifdef LC_HAVE_PNGLIB - -#include - -#define alpha_composite(composite, fg, alpha, bg) { \ - unsigned short temp = ((unsigned short)(fg)*(unsigned short)(alpha) + \ - (unsigned short)(bg)*(unsigned short)(255 - (unsigned short)(alpha)) + (unsigned short)128); \ - (composite) = (unsigned char)((temp + (temp >> 8)) >> 8); \ -} - -// ============================================================================= - -static void user_read_fn(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - // Read() returns 0 on error, so it is OK to store this in a png_size_t - // instead of an int, which is what Read() actually returns. - check = (png_size_t)((lcFile*)png_get_io_ptr(png_ptr))->ReadBuffer(data, length); - - if (check != length) - png_error(png_ptr, "Read Error"); -} - -bool Image::LoadPNG(lcFile& file) -{ - unsigned char sig[8], red, green, blue; - unsigned char *image_data = NULL; - unsigned char *src, *dest; - unsigned char r, g, b, a; - unsigned long i, row; - unsigned long image_rowbytes; - png_color_16p pBackground; - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; - png_uint_32 width, height; - png_bytepp row_pointers = NULL; - int bit_depth, color_type; - int image_channels; - double gamma; - - FreeData(); - - file.ReadBuffer(sig, 8); - if (!png_check_sig(sig, 8)) - return false; // bad signature - - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png_ptr) - return false; // out of memory - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, NULL, NULL); - return false; // out of memory - } - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return false; - } - - png_set_read_fn(png_ptr, (void*)&file, user_read_fn); - // png_init_io(png_ptr, f); - png_set_sig_bytes(png_ptr, 8); // we already read the 8 signature bytes - - png_read_info(png_ptr, info_ptr); // read all PNG info up to image data - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, NULL, NULL, NULL); - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return false; - } - - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD)) - { - png_get_bKGD(png_ptr, info_ptr, &pBackground); - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return false; - } - - // however, it always returns the raw bKGD data, regardless of any - // bit-depth transformations, so check depth and adjust if necessary - if (bit_depth == 16) - { - red = pBackground->red >> 8; - green = pBackground->green >> 8; - blue = pBackground->blue >> 8; - } - else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - { - if (bit_depth == 1) - red = green = blue = pBackground->gray? 255 : 0; - else if (bit_depth == 2) - red = green = blue = (255/3) * pBackground->gray; - else // bit_depth == 4 - red = green = blue = (255/15) * pBackground->gray; - } - else - { - red = (unsigned char)pBackground->red; - green = (unsigned char)pBackground->green; - blue = (unsigned char)pBackground->blue; - } - } - else - { - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return false; - } - - red = green = blue = 0; - } - - // expand palette images to RGB, low-bit-depth grayscale images to 8 bits, - // transparency chunks to full alpha channel; strip 16-bit-per-sample - // images to 8 bits per sample; and convert grayscale to RGB[A] - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_expand(png_ptr); - if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_expand(png_ptr); - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_expand(png_ptr); - if (bit_depth == 16) - png_set_strip_16(png_ptr); - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) - png_set_gamma(png_ptr, 2.2, gamma); - - // all transformations have been registered; now update info_ptr data, - // get rowbytes and channels, and allocate image memory - png_read_update_info(png_ptr, info_ptr); - - image_rowbytes = png_get_rowbytes(png_ptr, info_ptr); - image_channels = (int)png_get_channels(png_ptr, info_ptr); - - if ((image_data = (unsigned char*)malloc(image_rowbytes*height)) == NULL) - { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return false; - } - - if ((row_pointers = (png_bytepp)malloc(height*sizeof(png_bytep))) == NULL) - { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - free(image_data); - return false; - } - - // set the individual row_pointers to point at the correct offsets - for (i = 0; i < height; ++i) - row_pointers[i] = image_data + i*image_rowbytes; - - // now we can go ahead and just read the whole image - png_read_image(png_ptr, row_pointers); - - // and we're done! (png_read_end() can be omitted if no processing of - // post-IDAT text/time/etc. is desired) - free(row_pointers); - row_pointers = NULL; - - png_read_end(png_ptr, NULL); - - // done with PNG file, so clean up to minimize memory usage - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - - if (!image_data) - return false; - - // get our buffer set to hold data - m_pData = (unsigned char*)malloc(width*height*image_channels); - - if (m_pData == NULL) - { - free (image_data); - return false; - } - - m_nWidth = width; - m_nHeight = height; - if (image_channels == 3) - m_bAlpha = false; - else - m_bAlpha = true; - - for (row = 0; row < height; row++) - { - src = image_data + row*image_rowbytes; - dest = m_pData + row*image_channels*width; - - if (image_channels == 3) - { - for (i = width; i > 0; i--) - { - r = *src++; - g = *src++; - b = *src++; - *dest++ = r; - *dest++ = g; - *dest++ = b; - } - } - else // if (image_channels == 4) - { - for (i = width; i > 0; i--) - { - r = *src++; - g = *src++; - b = *src++; - a = *src++; - - if (a == 255) - { - *dest++ = r; - *dest++ = g; - *dest++ = b; - } - else if (a == 0) - { - *dest++ = red; - *dest++ = green; - *dest++ = blue; - } - else - { - // this macro (copied from png.h) composites the - // foreground and background values and puts the - // result into the first argument; there are no - // side effects with the first argument - alpha_composite(*dest++, r, a, red); - alpha_composite(*dest++, g, a, green); - alpha_composite(*dest++, b, a, blue); - } - *dest++ = a; - } - } - } - - free(image_data); - return true; -} - -// ============================================================================= - -static void user_write_fn(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - - check = ((lcFile*)png_get_io_ptr(png_ptr))->WriteBuffer(data, length); - if (check != length) - { - png_error(png_ptr, "Write Error"); - } -} - -static void user_flush_fn(png_structp png_ptr) -{ - ((lcFile*)png_get_io_ptr(png_ptr))->Flush(); -} - -bool Image::SavePNG(lcFile& file, bool transparent, bool interlaced, unsigned char* background) const -{ - png_structp png_ptr; - png_infop info_ptr; - png_bytepp row_pointers = NULL; - png_color_8 sig_bit; - png_color_16 bg; - int i; - - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png_ptr) - return false; - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_write_struct(&png_ptr, NULL); - return false; - } - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - return false; - } - - // png_init_io(png_ptr, fp); - png_set_write_fn(png_ptr, &file, user_write_fn, user_flush_fn); - - png_set_IHDR(png_ptr, info_ptr, m_nWidth, m_nHeight, 8, - transparent ? PNG_COLOR_TYPE_RGB_ALPHA : PNG_COLOR_TYPE_RGB, - interlaced ? PNG_INTERLACE_ADAM7 : PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - - bg.red = background[0]; - bg.green = background[1]; - bg.blue = background[2]; - png_set_bKGD(png_ptr, info_ptr, &bg); - - png_write_info(png_ptr, info_ptr); - - // Set the true bit depth of the image data - sig_bit.red = 8; - sig_bit.green = 8; - sig_bit.blue = 8; - sig_bit.alpha = 8; - - png_set_sBIT(png_ptr, info_ptr, &sig_bit); - - if ((row_pointers = (png_bytepp)malloc(m_nHeight*sizeof(png_bytep))) == NULL) - { - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - return false; - } - - // set the individual row_pointers to point at the correct offsets - if (transparent) - { - unsigned char *buf, *src, *dst, alpha; - dst = buf = (unsigned char*)malloc(m_nWidth*m_nHeight*4); - src = m_pData; - - for (i = 0; i < m_nWidth*m_nHeight; i++) - { - if ((src[0] == background[0]) && - (src[1] == background[1]) && - (src[2] == background[2])) - alpha = 0; - else - alpha = 255; - *dst++ = *src++; - *dst++ = *src++; - *dst++ = *src++; - *dst++ = alpha; - } - - for (i = 0; i < m_nHeight; i++) - row_pointers[i] = buf + i*m_nWidth*4; - png_write_image(png_ptr, row_pointers); - - free(buf); - } - else - { - for (i = 0; i < m_nHeight; i++) - row_pointers[i] = m_pData + i*m_nWidth*3; - png_write_image(png_ptr, row_pointers); - } - - free(row_pointers); - - png_write_end(png_ptr, info_ptr); - png_destroy_write_struct(&png_ptr, &info_ptr); - - return true; -} - -#endif // LC_HAVE_PNGLIB diff --git a/common/image.cpp b/common/image.cpp index 0241458c..05c5d071 100644 --- a/common/image.cpp +++ b/common/image.cpp @@ -1,75 +1,58 @@ -// Image I/O routines -// - #include "lc_global.h" -#include "opengl.h" -#ifdef LC_WINDOWS -#include -#include -//#include -#include -#endif -#include -#include -#include -#include #include "image.h" -#include "lc_file.h" - -// ============================================================================= -// Image functions +#include "opengl.h" Image::Image () { - m_nWidth = 0; - m_nHeight = 0; - m_bAlpha = false; - m_pData = NULL; + mData = NULL; + mWidth = 0; + mHeight = 0; + mAlpha = false; } Image::~Image () { - free (m_pData); + FreeData(); } void Image::FreeData () { - m_nWidth = 0; - m_nHeight = 0; - m_bAlpha = false; - free (m_pData); - m_pData = NULL; + free(mData); + mData = NULL; + mWidth = 0; + mHeight = 0; + mAlpha = false; } -void Image::Allocate (int width, int height, bool alpha) +void Image::Allocate(int Width, int Height, bool Alpha) { FreeData (); - m_nWidth = width; - m_nHeight = height; - m_bAlpha = alpha; + mWidth = Width; + mHeight = Height; + mAlpha = Alpha; - if (m_bAlpha) - m_pData = (unsigned char*)malloc (width * height * 4); + if (mAlpha) + mData = (unsigned char*)malloc(mWidth * mHeight * 4); else - m_pData = (unsigned char*)malloc (width * height * 3); + mData = (unsigned char*)malloc(mWidth * mHeight * 3); } void Image::ResizePow2 () { int i, shifted_x, shifted_y; - shifted_x = m_nWidth; + shifted_x = mWidth; for (i = 0; ((i < 16) && (shifted_x != 0)); i++) shifted_x = shifted_x >> 1; shifted_x = (i != 0) ? 1 << (i-1) : 1; - shifted_y = m_nHeight; + shifted_y = mHeight; for (i = 0; ((i < 16) && (shifted_y != 0)); i++) shifted_y = shifted_y >> 1; shifted_y = (i != 0) ? 1 << (i-1) : 1; - if ((shifted_x != m_nWidth) || (shifted_y != m_nHeight)) + if ((shifted_x != mWidth) || (shifted_y != mHeight)) Resize (shifted_x, shifted_y); } @@ -79,434 +62,45 @@ void Image::Resize (int width, int height) float accumx, accumy; unsigned char* bits; - if (m_bAlpha) + if (mAlpha) components = 4; else components = 3; bits = (unsigned char*)malloc (width * height * components); - for (j = 0; j < m_nHeight; j++) + for (j = 0; j < mHeight; j++) { - accumy = (float)height*j/(float)m_nHeight; + accumy = (float)height*j/(float)mHeight; sty = (int)floor(accumy); - for (i = 0; i < m_nWidth; i++) + for (i = 0; i < mWidth; i++) { - accumx = (float)width*i/(float)m_nWidth; + accumx = (float)width*i/(float)mWidth; stx = (int)floor(accumx); for (k = 0; k < components; k++) - bits[(stx+sty*width)*components+k] = m_pData[(i+j*m_nWidth)*components+k]; + bits[(stx+sty*width)*components+k] = mData[(i+j*mWidth)*components+k]; } } - free (m_pData); - m_pData = bits; - m_nWidth = width; - m_nHeight = height; + free (mData); + mData = bits; + mWidth = width; + mHeight = height; } -void Image::FromOpenGL (int width, int height) +void Image::FromOpenGL(int Width, int Height) { - unsigned char *buf; - buf = (unsigned char*)malloc (width*height*3); + Allocate(Width, Height, true); - FreeData (); - - m_pData = (unsigned char*)malloc (width*height*3); - m_nWidth = width; - m_nHeight = height; - m_bAlpha = false; + lcuint8* Buffer = (lcuint8*)malloc(Width * Height * 4); glPixelStorei (GL_PACK_ALIGNMENT, 1); - glReadPixels (0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, buf); + glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, Buffer); - for (int row = 0; row < height; row++) - memcpy (m_pData + (row*width*3), buf + ((height-row-1)*width*3), width*3); + for (int Row = 0; Row < Height; Row++) + memcpy(mData + (Row * Width * 4), Buffer + ((Height - Row - 1) * Width * 4), Width * 4); - free (buf); + free(Buffer); } - -bool Image::FileLoad(lcFile& file) -{ - unsigned char buf[8]; - - // Read a few bytes - if (file.ReadBuffer(buf, 8) != 8) - return false; - file.Seek (-8, SEEK_CUR); - - // Check for the BMP header - if ((buf[0] == 'B') && (buf[1] == 'M')) - { - if (!LoadBMP (file)) - return false; - - return true; - } - -#ifdef LC_HAVE_JPEGLIB - if ((buf[0] == 0xFF) && (buf[1] == 0xD8)) - { - if (!LoadJPG (file)) - return false; - - return true; - } -#endif - -#ifdef LC_HAVE_PNGLIB - const unsigned char png_signature[8] = { 137, 80, 78, 71, 13, 10, 26, 10 }; - - // Check for the PNG header - if (memcmp (buf, png_signature, 8) == 0) - { - if (!LoadPNG (file)) - return false; - - return true; - } -#endif - - // Check for the GIF header - if ((buf[0] == 'G') && (buf[1] == 'I') && (buf[2] == 'F') && - (buf[3] == '8') && ((buf[4] == '7') || (buf[4] == '9')) && - (buf[5] == 'a')) - { - if (!LoadGIF (file)) - return false; - - return true; - } - -// MessageBox (NULL, "Unknown File Format", "Error", MB_ICONSTOP); - return false; -} - -bool Image::FileLoad(const char* filename) -{ - lcDiskFile file; - - if (!file.Open (filename, "rb")) - return false; - - return FileLoad (file); -} - -bool Image::FileSave(lcFile& file, LC_IMAGE_OPTS* opts) const -{ - switch (opts->format) - { -#ifdef LC_HAVE_JPEGLIB - case LC_IMAGE_JPG: - return SaveJPG (file, opts->quality, opts->interlaced); -#endif - - case LC_IMAGE_GIF: - return SaveGIF (file, opts->transparent, opts->interlaced, opts->background); - - case LC_IMAGE_BMP: - return SaveBMP (file, opts->truecolor == false); - -#ifdef LC_HAVE_PNGLIB - case LC_IMAGE_PNG: - return SavePNG (file, opts->transparent, opts->interlaced, opts->background); -#endif - - default: - break; - } - -// MessageBox (NULL, "Could not save file", "Error", MB_ICONSTOP); - - return false; -} - -bool Image::FileSave(const char* filename, LC_IMAGE_OPTS* opts) const -{ - char name[LC_MAXPATH], ext[5], *p; - lcDiskFile file; - bool needext = false; - - strcpy (name, filename); - p = name + strlen (name) - 1; - - while ((p > name) && (*p != '/') && (*p != '\\') && (*p != '.')) - p--; - - if (*p != '.') - needext = true; - else - { - if (strlen (p) > 5) - needext = true; - else - { - strcpy (ext, p+1); - strlwr (ext); - - if (strcmp (ext, "bmp") == 0) - opts->format = LC_IMAGE_BMP; - else if (strcmp (ext, "gif") == 0) - opts->format = LC_IMAGE_GIF; -#ifdef LC_HAVE_JPEGLIB - else if (strcmp (ext, "jpg") == 0) - opts->format = LC_IMAGE_JPG; - else if (strcmp (ext, "jpeg") == 0) - opts->format = LC_IMAGE_JPG; -#endif -#ifdef LC_HAVE_PNGLIB - else if (strcmp (ext, "png") == 0) - opts->format = LC_IMAGE_PNG; -#endif - else - needext = true; - } - } - - if (needext) - { - // no extension, add from the options - switch (opts->format) - { - case LC_IMAGE_BMP: - strcat (name, ".bmp"); - break; - case LC_IMAGE_GIF: - strcat (name, ".gif"); - break; -#ifdef LC_HAVE_JPEGLIB - case LC_IMAGE_JPG: - strcat (name, ".jpg"); - break; -#endif -#ifdef LC_HAVE_PNGLIB - case LC_IMAGE_PNG: - strcat (name, ".png"); - break; -#endif - default: - return false; - } - } - - if (!file.Open(name, "wb")) - return false; - - return FileSave(file, opts); -} - - - - - -// ============================================================================= -// Global functions - -#ifdef LC_WINDOWS -#include "system.h" - -#define AVIIF_KEYFRAME 0x00000010L // this frame is a key frame. -#define LPLPBI LPBITMAPINFOHEADER * - -static HANDLE MakeDib (HBITMAP hbitmap, Image& image) -{ - HANDLE hdib ; - HDC hdc ; - BITMAP bitmap ; - UINT wLineLen ; - DWORD dwSize ; - DWORD wColSize ; - LPBITMAPINFOHEADER lpbi ; - LPBYTE lpBits ; - UINT bits = 24; - int i, j; - - GetObject(hbitmap,sizeof(BITMAP),&bitmap) ; - - // DWORD align the width of the DIB - // Figure out the size of the colour table - // Calculate the size of the DIB - wLineLen = (bitmap.bmWidth*bits+31)/32 * 4; - wColSize = sizeof(RGBQUAD)*((bits <= 8) ? 1<biSize = sizeof(BITMAPINFOHEADER) ; - lpbi->biWidth = bitmap.bmWidth ; - lpbi->biHeight = bitmap.bmHeight ; - lpbi->biPlanes = 1 ; - lpbi->biBitCount = (WORD) bits ; - lpbi->biCompression = BI_RGB ; - lpbi->biSizeImage = dwSize - sizeof(BITMAPINFOHEADER) - wColSize ; - lpbi->biXPelsPerMeter = 0 ; - lpbi->biYPelsPerMeter = 0 ; - lpbi->biClrUsed = (bits <= 8) ? 1<biClrImportant = 0 ; - - // Get the bits from the bitmap and stuff them after the LPBI - lpBits = (LPBYTE)(lpbi+1)+wColSize ; - - hdc = CreateCompatibleDC(NULL) ; - - GetDIBits(hdc,hbitmap,0,bitmap.bmHeight,lpBits,(LPBITMAPINFO)lpbi, DIB_RGB_COLORS); - - for (i = 0; i < lpbi->biHeight; i++) - { - unsigned char *src = image.GetData() + i * image.Width() * 3; - unsigned char *dst = lpBits + (lpbi->biHeight - i - 1) * wLineLen; - - for (j = 0; j < lpbi->biWidth; j++) - { - dst[0] = src[2]; - dst[1] = src[1]; - dst[2] = src[0]; - - src += 3; - dst += 3; - } - } - - // Fix this if GetDIBits messed it up.... - lpbi->biClrUsed = (bits <= 8) ? 1<biSizeImage; - SetRect(&strhdr.rcFrame, 0, 0, (int) plpbi[0]->biWidth, (int) plpbi[0]->biHeight); - - // And create the stream. - if (AVIFileCreateStream(pfile, &ps, &strhdr) == AVIERR_OK) - if (AVISaveOptions(NULL, 0, 1, &ps, (LPAVICOMPRESSOPTIONS FAR *) &aopts)) -// if (AVISaveOptions(AfxGetMainWnd()->m_hWnd, 0, 1, &ps, (LPAVICOMPRESSOPTIONS FAR *) &aopts)) - if (AVIMakeCompressedStream(&psCompressed, ps, &opts, NULL) == AVIERR_OK) - if (AVIStreamSetFormat(psCompressed, 0, plpbi[0], plpbi[0]->biSize + plpbi[0]->biClrUsed * sizeof(RGBQUAD)) == AVIERR_OK) - { - float fPause = (float)Sys_ProfileLoadInt("Default", "AVI Pause", 100)/100; - int time = (int)(fPause * 15); -///////////// set FPS - time = 1; - - for (int i = 0; i < count; i++) - { - if (AVIStreamWrite(psCompressed, i * time, 1, - (LPBYTE) plpbi[i] + plpbi[i]->biSize + plpbi[i]->biClrUsed * sizeof(RGBQUAD), - plpbi[i]->biSizeImage, i%5 ? 0 : AVIIF_KEYFRAME, NULL, NULL) != AVIERR_OK) - break; - } - } - } - - FreeFrames (plpbi, count); - - // Now close the file - if (ps) AVIStreamClose(ps); - if (psCompressed) AVIStreamClose(psCompressed); - if (pfile) AVIFileClose(pfile); - AVIFileExit(); -} -#else -void SaveVideo(char* filename, Image *images, int count, float fps) -{ - // SystemDoMessageBox("Format not supported under this platform.", LC_MB_OK|LC_MB_ERROR); -} -#endif diff --git a/common/image.h b/common/image.h index a7a70a12..4ce8c228 100644 --- a/common/image.h +++ b/common/image.h @@ -1,7 +1,18 @@ #ifndef _IMAGE_H_ #define _IMAGE_H_ -#include "typedefs.h" +// Image Options +//#define LC_IMAGE_PROGRESSIVE 0x1000 +#define LC_IMAGE_TRANSPARENT 0x2000 +//#define LC_IMAGE_HIGHCOLOR 0x4000 +#define LC_IMAGE_MASK 0x7000 + +enum LC_IMAGE_FORMAT +{ + LC_IMAGE_BMP, + LC_IMAGE_JPG, + LC_IMAGE_PNG +}; class Image { @@ -9,44 +20,21 @@ public: Image(); virtual ~Image(); - bool FileSave(lcFile& file, LC_IMAGE_OPTS* opts) const; - bool FileSave(const char* filename, LC_IMAGE_OPTS* opts) const; - bool FileLoad(lcFile& file); - bool FileLoad(const char* filename); + bool FileSave(lcMemFile& File, LC_IMAGE_FORMAT Format, bool Transparent) const; + bool FileSave(const char* FileName, LC_IMAGE_FORMAT Format, bool Transparent) const; + bool FileLoad(lcMemFile& File); + bool FileLoad(const char* FileName); - void Resize(int width, int height); + void Resize(int Width, int Height); void ResizePow2(); - void FromOpenGL(int width, int height); - void Allocate(int width, int height, bool alpha); - - int Width() const - { return m_nWidth; } - int Height() const - { return m_nHeight; } - int Alpha() const - { return m_bAlpha; } - unsigned char* GetData() const - { return m_pData; } - -protected: + void FromOpenGL(int Width, int Height); + void Allocate(int Width, int Height, bool Alpha); void FreeData(); - bool LoadJPG(lcFile& file); - bool LoadBMP(lcFile& file); - bool LoadPNG(lcFile& file); - bool LoadGIF(lcFile& file); - - bool SaveJPG(lcFile& file, int quality, bool progressive) const; - bool SaveBMP(lcFile& file, bool quantize) const; - bool SavePNG(lcFile& file, bool transparent, bool interlaced, unsigned char* background) const; - bool SaveGIF(lcFile& file, bool transparent, bool interlaced, unsigned char* background) const; - - int m_nWidth; - int m_nHeight; - bool m_bAlpha; - unsigned char* m_pData; + int mWidth; + int mHeight; + bool mAlpha; + unsigned char* mData; }; -void SaveVideo(char* filename, Image *images, int count, float fps); - #endif // _IMAGE_H_ diff --git a/common/keyboard.cpp b/common/keyboard.cpp deleted file mode 100644 index c668277e..00000000 --- a/common/keyboard.cpp +++ /dev/null @@ -1,432 +0,0 @@ -// -// Code to handle user-defined keyboard shortcuts. -// - -#include "lc_global.h" -#include -#include "system.h" -#include "keyboard.h" -#include "lc_file.h" -#include "str.h" - -// ============================================================================ -// Globals. - -LC_KEYBOARD_COMMAND DefaultKeyboardShortcuts[] = -{ - { LC_FILE_NEW, "New Project", LC_KEYMOD1_CONTROL, LC_KEY_N, 0 }, - { LC_FILE_OPEN, "Open Project", LC_KEYMOD1_CONTROL, LC_KEY_O, 0 }, - { LC_FILE_MERGE, "Merge Project", 0, 0, 0 }, - { LC_FILE_SAVE, "Save Project", LC_KEYMOD1_CONTROL, LC_KEY_S, 0 }, - { LC_FILE_SAVEAS, "Save Project As", 0, 0, 0 }, - { LC_FILE_PICTURE, "Save Picture", 0, 0, 0 }, - { LC_FILE_3DS, "Export 3D Studio", 0, 0, 0 }, - { LC_FILE_HTML, "Export HTML", 0, 0, 0 }, - { LC_FILE_BRICKLINK, "Export BrickLink", 0, 0, 0 }, - { LC_FILE_POVRAY, "Export POV-Ray", 0, 0, 0 }, - { LC_FILE_WAVEFRONT, "Export Wavefront", 0, 0, 0 }, - { LC_FILE_PROPERTIES, "Project Properties", 0, 0, 0 }, -// { LC_FILE_TERRAIN, "Terrain Editor", 0, 0, 0 }, - { LC_FILE_LIBRARY, "Piece Library Manager", 0, 0, 0 }, -// { LC_FILE_RECENT, "Open Recent File", 0, 0, 0 }, - { LC_EDIT_UNDO, "Undo", LC_KEYMOD1_CONTROL, LC_KEY_Z, 0 }, - { LC_EDIT_REDO, "Redo", LC_KEYMOD1_CONTROL, LC_KEY_Y, 0 }, - { LC_EDIT_CUT, "Cut", LC_KEYMOD1_CONTROL, LC_KEY_X, 0 }, - { LC_EDIT_COPY, "Copy", LC_KEYMOD1_CONTROL, LC_KEY_C, 0 }, - { LC_EDIT_PASTE, "Paste", LC_KEYMOD1_CONTROL, LC_KEY_V, 0 }, - { LC_EDIT_SELECT_ALL, "Select All", LC_KEYMOD1_CONTROL, LC_KEY_A, 0 }, - { LC_EDIT_SELECT_NONE, "Select None", 0, 0, 0 }, - { LC_EDIT_SELECT_INVERT, "Select Invert", LC_KEYMOD1_CONTROL, LC_KEY_I, 0 }, - { LC_EDIT_SELECT_BYNAME, "Select By Name", 0, 0, 0 }, - { LC_PIECE_INSERT, "Piece Insert", 0, LC_KEY_INSERT, 0 }, - { LC_PIECE_DELETE, "Piece Delete", 0, LC_KEY_DELETE, 0 }, -// { LC_PIECE_MINIFIG, "Minifig Wizard", 0, 0, 0 }, - { LC_PIECE_ARRAY, "Piece Array", 0, 0, 0 }, -// { LC_PIECE_COPYKEYS, "", 0, 0, 0 }, - { LC_PIECE_GROUP, "Piece Group", LC_KEYMOD1_CONTROL, LC_KEY_G, 0 }, - { LC_PIECE_UNGROUP, "Piece Ungroup", LC_KEYMOD1_CONTROL, LC_KEY_U, 0 }, - { LC_PIECE_GROUP_ADD, "Group Add Piece", 0, 0, 0 }, - { LC_PIECE_GROUP_REMOVE, "Group Remove Piece", 0, 0, 0 }, - { LC_PIECE_GROUP_EDIT, "Group Edit", 0, 0, 0 }, - { LC_PIECE_HIDE_SELECTED, "Hide Selection", LC_KEYMOD1_CONTROL, LC_KEY_H, 0 }, - { LC_PIECE_HIDE_UNSELECTED, "Unhide Selection", 0, 0, 0 }, - { LC_PIECE_UNHIDE_ALL, "Unhide All", 0, 0, 0 }, - { LC_PIECE_PREVIOUS, "Piece Previous Step", 0, 0, 0 }, - { LC_PIECE_NEXT, "Piece Next Step", 0, 0, 0 }, - { LC_VIEW_PREFERENCES, "Preferences", 0, 0, 0 }, -// { LC_VIEW_ZOOM, "", 0, 0, 0 }, - { LC_VIEW_ZOOMIN, "Zoom In", 0, 0, 0 }, - { LC_VIEW_ZOOMOUT, "Zoom Out", 0, 0, 0 }, - { LC_VIEW_ZOOMEXTENTS, "Zoom Extents", 0, 0, 0 }, - { LC_VIEW_STEP_NEXT, "Step Next", 0, 0, 0 }, - { LC_VIEW_STEP_PREVIOUS, "Step Previous", 0, 0, 0 }, - { LC_VIEW_STEP_FIRST, "Step First", 0, 0, 0 }, - { LC_VIEW_STEP_LAST, "Step Last", 0, 0, 0 }, -// { LC_VIEW_STEP_CHOOSE, "", 0, 0, 0 }, -// { LC_VIEW_STEP_SET, "", 0, 0, 0 }, -// { LC_VIEW_STOP, "", 0, 0, 0 }, -// { LC_VIEW_PLAY, "", 0, 0, 0 }, - { LC_VIEW_VIEWPOINT_FRONT, "Viewpoint Front", LC_KEYMOD_VIEWONLY, LC_KEY_F, 0 }, - { LC_VIEW_VIEWPOINT_BACK, "Viewpoint Back", LC_KEYMOD_VIEWONLY, LC_KEY_B, 0 }, - { LC_VIEW_VIEWPOINT_TOP, "Viewpoint Top", LC_KEYMOD_VIEWONLY, LC_KEY_T, 0 }, - { LC_VIEW_VIEWPOINT_BOTTOM, "Viewpoint Bottom", LC_KEYMOD_VIEWONLY, LC_KEY_O, 0 }, - { LC_VIEW_VIEWPOINT_LEFT, "Viewpoint Left", LC_KEYMOD_VIEWONLY, LC_KEY_L, 0 }, - { LC_VIEW_VIEWPOINT_RIGHT, "Viewpoint Right", LC_KEYMOD_VIEWONLY, LC_KEY_R, 0 }, - { LC_VIEW_VIEWPOINT_HOME, "Viewpoint Home", LC_KEYMOD_VIEWONLY, LC_KEY_M, 0 }, -// { LC_VIEW_CAMERA_MENU, "", 0, 0, 0 }, -// { LC_VIEW_CAMERA_RESET, "", 0, 0, 0 }, -// { LC_HELP_ABOUT, "", 0, 0, 0 }, -// { LC_TOOLBAR_ANIMATION, "", 0, 0, 0 }, -// { LC_TOOLBAR_ADDKEYS, "", 0, 0, 0 }, -// { LC_TOOLBAR_SNAPMENU, "", 0, 0, 0 }, -// { LC_TOOLBAR_LOCKMENU, "", 0, 0, 0 }, -// { LC_TOOLBAR_FASTRENDER, "", 0, 0, 0 }, - { LC_VIEW_STEP_INSERT, "Step Insert", 0, 0, 0 }, - { LC_VIEW_STEP_DELETE, "Step Delete", 0, 0, 0 }, - { LC_EDIT_MOVEXY_SNAP_0, "Move XY Snap 0", LC_KEYMOD_VIEWONLY, LC_KEY_0, 0 }, - { LC_EDIT_MOVEXY_SNAP_1, "Move XY Snap 1", LC_KEYMOD_VIEWONLY, LC_KEY_1, 0 }, - { LC_EDIT_MOVEXY_SNAP_2, "Move XY Snap 2", LC_KEYMOD_VIEWONLY, LC_KEY_2, 0 }, - { LC_EDIT_MOVEXY_SNAP_3, "Move XY Snap 3", LC_KEYMOD_VIEWONLY, LC_KEY_3, 0 }, - { LC_EDIT_MOVEXY_SNAP_4, "Move XY Snap 4", LC_KEYMOD_VIEWONLY, LC_KEY_4, 0 }, - { LC_EDIT_MOVEXY_SNAP_5, "Move XY Snap 5", LC_KEYMOD_VIEWONLY, LC_KEY_5, 0 }, - { LC_EDIT_MOVEXY_SNAP_6, "Move XY Snap 6", LC_KEYMOD_VIEWONLY, LC_KEY_6, 0 }, - { LC_EDIT_MOVEXY_SNAP_7, "Move XY Snap 7", LC_KEYMOD_VIEWONLY, LC_KEY_7, 0 }, - { LC_EDIT_MOVEXY_SNAP_8, "Move XY Snap 8", LC_KEYMOD_VIEWONLY, LC_KEY_8, 0 }, - { LC_EDIT_MOVEXY_SNAP_9, "Move XY Snap 9", LC_KEYMOD_VIEWONLY, LC_KEY_9, 0 }, - { LC_EDIT_MOVEZ_SNAP_0, "Move Z Snap 0", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT|LC_KEYMOD1_CONTROL, LC_KEY_0, 0 }, - { LC_EDIT_MOVEZ_SNAP_1, "Move Z Snap 1", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT|LC_KEYMOD1_CONTROL, LC_KEY_1, 0 }, - { LC_EDIT_MOVEZ_SNAP_2, "Move Z Snap 2", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT|LC_KEYMOD1_CONTROL, LC_KEY_2, 0 }, - { LC_EDIT_MOVEZ_SNAP_3, "Move Z Snap 3", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT|LC_KEYMOD1_CONTROL, LC_KEY_3, 0 }, - { LC_EDIT_MOVEZ_SNAP_4, "Move Z Snap 4", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT|LC_KEYMOD1_CONTROL, LC_KEY_4, 0 }, - { LC_EDIT_MOVEZ_SNAP_5, "Move Z Snap 5", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT|LC_KEYMOD1_CONTROL, LC_KEY_5, 0 }, - { LC_EDIT_MOVEZ_SNAP_6, "Move Z Snap 6", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT|LC_KEYMOD1_CONTROL, LC_KEY_6, 0 }, - { LC_EDIT_MOVEZ_SNAP_7, "Move Z Snap 7", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT|LC_KEYMOD1_CONTROL, LC_KEY_7, 0 }, - { LC_EDIT_MOVEZ_SNAP_8, "Move Z Snap 8", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT|LC_KEYMOD1_CONTROL, LC_KEY_8, 0 }, - { LC_EDIT_MOVEZ_SNAP_9, "Move Z Snap 9", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT|LC_KEYMOD1_CONTROL, LC_KEY_9, 0 }, - { LC_EDIT_ANGLE_SNAP_0, "Angle Snap 0", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT, LC_KEY_0, 0 }, - { LC_EDIT_ANGLE_SNAP_1, "Angle Snap 1", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT, LC_KEY_1, 0 }, - { LC_EDIT_ANGLE_SNAP_2, "Angle Snap 5", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT, LC_KEY_2, 0 }, - { LC_EDIT_ANGLE_SNAP_3, "Angle Snap 10", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT, LC_KEY_3, 0 }, - { LC_EDIT_ANGLE_SNAP_4, "Angle Snap 15", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT, LC_KEY_4, 0 }, - { LC_EDIT_ANGLE_SNAP_5, "Angle Snap 30", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT, LC_KEY_5, 0 }, - { LC_EDIT_ANGLE_SNAP_6, "Angle Snap 45", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT, LC_KEY_6, 0 }, - { LC_EDIT_ANGLE_SNAP_7, "Angle Snap 60", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT, LC_KEY_7, 0 }, - { LC_EDIT_ANGLE_SNAP_8, "Angle Snap 90", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT, LC_KEY_8, 0 }, - { LC_EDIT_ANGLE_SNAP_9, "Angle Snap 180", LC_KEYMOD_VIEWONLY|LC_KEYMOD1_SHIFT, LC_KEY_9, 0 }, - { LC_EDIT_ACTION_SELECT, "Select Mode", 0, 0, 0 }, - { LC_EDIT_ACTION_INSERT, "Insert Mode", 0, 0, 0 }, - { LC_EDIT_ACTION_LIGHT, "Light Mode", 0, 0, 0 }, - { LC_EDIT_ACTION_SPOTLIGHT, "Spotlight Mode", 0, 0, 0 }, - { LC_EDIT_ACTION_CAMERA, "Camera Mode", 0, 0, 0 }, - { LC_EDIT_ACTION_MOVE, "Move Mode", LC_KEYMOD1_SHIFT, LC_KEY_M, 0 }, - { LC_EDIT_ACTION_ROTATE, "Rotate Mode", LC_KEYMOD1_SHIFT, LC_KEY_R, 0 }, - { LC_EDIT_ACTION_ERASER, "Eraser Mode", LC_KEYMOD1_SHIFT, LC_KEY_E, 0 }, - { LC_EDIT_ACTION_PAINT, "Paint Mode", LC_KEYMOD1_SHIFT, LC_KEY_N, 0 }, - { LC_EDIT_ACTION_ZOOM, "Zoom Mode", LC_KEYMOD1_SHIFT, LC_KEY_Z, 0 }, - { LC_EDIT_ACTION_ZOOM_REGION, "Zoom Region Mode", 0, 0, 0 }, - { LC_EDIT_ACTION_PAN, "Pan Mode", LC_KEYMOD1_SHIFT, LC_KEY_P, 0 }, - { LC_EDIT_ACTION_ROTATE_VIEW, "Rotate View Mode", LC_KEYMOD1_SHIFT, LC_KEY_T, 0 }, - { LC_EDIT_ACTION_ROLL, "Roll Camera Mode", LC_KEYMOD1_SHIFT, LC_KEY_L, 0 }, -}; - -const int KeyboardShortcutsCount = sizeof(DefaultKeyboardShortcuts)/sizeof(KeyboardShortcuts[0]); - -LC_KEYBOARD_COMMAND KeyboardShortcuts[KeyboardShortcutsCount]; - -// ============================================================================ -// Functions - -bool SaveKeyboardShortcuts(const char* FileName) -{ - lcDiskFile f; - - if (!f.Open(FileName, "wt")) - return false; - - for (int i = 0; i < KeyboardShortcutsCount; i++) - { - LC_KEYBOARD_COMMAND& Cmd = KeyboardShortcuts[i]; - String str; - - str = Cmd.Description; - str += "="; - - if (Cmd.Key1) - { - if (Cmd.Flags & LC_KEYMOD1_SHIFT) - str += "Shift+"; - - if (Cmd.Flags & LC_KEYMOD1_CONTROL) - str += "Ctrl+"; - - str += "\""; - str += GetKeyName(Cmd.Key1); - str += "\""; - } - - if (Cmd.Key2) - { - str += ","; - - if (Cmd.Flags & LC_KEYMOD2_SHIFT) - str += "Shift+"; - - if (Cmd.Flags & LC_KEYMOD2_CONTROL) - str += "Ctrl+"; - - str += "\""; - str += GetKeyName(Cmd.Key2); - str += "\""; - } - - str += "\n"; - - f.WriteBuffer((const char*)str, str.GetLength()); - } - - return true; -} - -bool LoadKeyboardShortcuts(const char* FileName) -{ - lcDiskFile f; - int i; - - if (!f.Open(FileName, "rt")) - return false; - - // Remove all existing shortcuts - for (i = 0; i < KeyboardShortcutsCount; i++) - { - LC_KEYBOARD_COMMAND& Cmd = KeyboardShortcuts[i]; - - Cmd.Key1 = 0; - Cmd.Key2 = 0; - Cmd.Flags = DefaultKeyboardShortcuts[i].Flags & ~LC_KEYMOD_MASK; - } - - char Line[1024]; - while (f.ReadLine(Line, 1024)) - { - char* ptr = strchr(Line, '='); - - if (ptr == NULL) - continue; - - *ptr = 0; - ptr++; - - - for (i = 0; i < KeyboardShortcutsCount; i++) - { - LC_KEYBOARD_COMMAND& Cmd = KeyboardShortcuts[i]; - - if (strcmp(Line, Cmd.Description)) - continue; - - if (!strncmp(ptr, "Shift+", 6)) - { - Cmd.Flags |= LC_KEYMOD1_SHIFT; - ptr += 6; - } - - if (!strncmp(ptr, "Ctrl+", 5)) - { - Cmd.Flags |= LC_KEYMOD1_CONTROL; - ptr += 5; - } - - ptr++; - char* ptr2 = strchr(ptr, '\"'); - - if (ptr2 == NULL) - { - Cmd.Flags &= ~(LC_KEYMOD1_SHIFT | LC_KEYMOD1_CONTROL); - break; - } - - *ptr2 = 0; - Cmd.Key1 = GetKeyFromName(ptr); - - ptr = ptr2 + 1; - - if (*ptr != ',') - break; - ptr++; - - if (!strncmp(ptr, "Shift+", 6)) - { - Cmd.Flags |= LC_KEYMOD2_SHIFT; - ptr += 6; - } - - if (!strncmp(ptr, "Ctrl+", 5)) - { - Cmd.Flags |= LC_KEYMOD2_CONTROL; - ptr += 5; - } - - ptr++; - ptr2 = strchr(ptr, '\"'); - - if (ptr2 == NULL) - { - Cmd.Flags &= ~(LC_KEYMOD2_SHIFT | LC_KEYMOD2_CONTROL); - break; - } - - *ptr2 = 0; - Cmd.Key2 = GetKeyFromName(ptr); - - break; - } - } - - return true; -} - -void ResetKeyboardShortcuts() -{ - memcpy(KeyboardShortcuts, DefaultKeyboardShortcuts, sizeof(KeyboardShortcuts)); -} - -void InitKeyboardShortcuts() -{ - const char* FileName = Sys_ProfileLoadString("Settings", "Keyboard", ""); - - ResetKeyboardShortcuts(); - LoadKeyboardShortcuts(FileName); -} - -struct LC_KEYNAME_ENTRY -{ - int Key; - const char* Name; -}; - -static LC_KEYNAME_ENTRY KeyNames[] = -{ - { LC_KEY_BACK, "Backspace" }, - { LC_KEY_TAB, "Tab" }, - { LC_KEY_RETURN, "Return" }, - { LC_KEY_PAUSE, "Pause" }, - { LC_KEY_CAPITAL, "Caps" }, - { LC_KEY_ESCAPE, "Escape" }, - { LC_KEY_SPACE, "Space" }, - { LC_KEY_PRIOR, "Page Up" }, - { LC_KEY_NEXT, "Page Down" }, - { LC_KEY_END, "End" }, - { LC_KEY_HOME, "Home" }, - { LC_KEY_LEFT, "Left" }, - { LC_KEY_UP, "Up" }, - { LC_KEY_RIGHT, "Right" }, - { LC_KEY_DOWN, "Down" }, - { LC_KEY_SELECT, "Select" }, - { LC_KEY_PRINT, "Print" }, - { LC_KEY_INSERT, "Insert" }, - { LC_KEY_DELETE, "Delete" }, - { LC_KEY_0, "0" }, - { LC_KEY_1, "1" }, - { LC_KEY_2, "2" }, - { LC_KEY_3, "3" }, - { LC_KEY_4, "4" }, - { LC_KEY_5, "5" }, - { LC_KEY_6, "6" }, - { LC_KEY_7, "7" }, - { LC_KEY_8, "8" }, - { LC_KEY_9, "9" }, - { LC_KEY_A, "A" }, - { LC_KEY_B, "B" }, - { LC_KEY_C, "C" }, - { LC_KEY_D, "D" }, - { LC_KEY_E, "E" }, - { LC_KEY_F, "F" }, - { LC_KEY_G, "G" }, - { LC_KEY_H, "H" }, - { LC_KEY_I, "I" }, - { LC_KEY_J, "J" }, - { LC_KEY_K, "K" }, - { LC_KEY_L, "L" }, - { LC_KEY_M, "M" }, - { LC_KEY_N, "N" }, - { LC_KEY_O, "O" }, - { LC_KEY_P, "P" }, - { LC_KEY_Q, "Q" }, - { LC_KEY_R, "R" }, - { LC_KEY_S, "S" }, - { LC_KEY_T, "T" }, - { LC_KEY_U, "U" }, - { LC_KEY_V, "V" }, - { LC_KEY_W, "W" }, - { LC_KEY_X, "X" }, - { LC_KEY_Y, "Y" }, - { LC_KEY_Z, "Z" }, - { LC_KEY_NUMPAD0, "Numpad 0" }, - { LC_KEY_NUMPAD1, "Numpad 1" }, - { LC_KEY_NUMPAD2, "Numpad 2" }, - { LC_KEY_NUMPAD3, "Numpad 3" }, - { LC_KEY_NUMPAD4, "Numpad 4" }, - { LC_KEY_NUMPAD5, "Numpad 5" }, - { LC_KEY_NUMPAD6, "Numpad 6" }, - { LC_KEY_NUMPAD7, "Numpad 7" }, - { LC_KEY_NUMPAD8, "Numpad 8" }, - { LC_KEY_NUMPAD9, "Numpad 9" }, - { LC_KEY_MULTIPLY, "Numpad *" }, - { LC_KEY_ADD, "Numpad +" }, - { LC_KEY_SUBTRACT, "Numpad -" }, - { LC_KEY_DECIMAL, "Numpad ." }, - { LC_KEY_DIVIDE, "Numpad /" }, - { LC_KEY_F1, "F1" }, - { LC_KEY_F2, "F2" }, - { LC_KEY_F3, "F3" }, - { LC_KEY_F4, "F4" }, - { LC_KEY_F5, "F5" }, - { LC_KEY_F6, "F6" }, - { LC_KEY_F7, "F7" }, - { LC_KEY_F8, "F8" }, - { LC_KEY_F9, "F9" }, - { LC_KEY_F10, "F10" }, - { LC_KEY_F11, "F11" }, - { LC_KEY_F12, "F12" }, - { LC_KEY_F13, "F13" }, - { LC_KEY_F14, "F14" }, - { LC_KEY_F15, "F15" }, - { LC_KEY_F16, "F16" }, - { LC_KEY_F17, "F17" }, - { LC_KEY_F18, "F18" }, - { LC_KEY_F19, "F19" }, - { LC_KEY_F20, "F20" }, - { LC_KEY_F21, "F21" }, - { LC_KEY_F22, "F22" }, - { LC_KEY_F23, "F23" }, - { LC_KEY_F24, "F24" }, - { LC_KEY_NUMLOCK, "Num Lock" }, - { LC_KEY_SCROLL, "Scroll" } -}; - -// Returns a string with the name of the key. -const char* GetKeyName(char Key) -{ - int Count = sizeof(KeyNames)/sizeof(KeyNames[0]); - - for (int i = 0; i < Count; i++) - { - if (Key == KeyNames[i].Key) - return KeyNames[i].Name; - } - - return NULL; -} - -char GetKeyFromName(const char* Name) -{ - int Count = sizeof(KeyNames)/sizeof(KeyNames[0]); - - for (int i = 0; i < Count; i++) - { - if (!strcmp(Name, KeyNames[i].Name)) - return KeyNames[i].Key; - } - - return 0; -} diff --git a/common/keyboard.h b/common/keyboard.h deleted file mode 100644 index 80cfe9e4..00000000 --- a/common/keyboard.h +++ /dev/null @@ -1,151 +0,0 @@ -#ifndef _KEYBOARD_H_ -#define _KEYBOARD_H_ - -#include "typedefs.h" - -// ============================================================================ -// Keyboard keys. - -#define LC_KEY_BACK 0x08 -#define LC_KEY_TAB 0x09 - -#define LC_KEY_RETURN 0x0D - -#define LC_KEY_PAUSE 0x13 -#define LC_KEY_CAPITAL 0x14 - -#define LC_KEY_ESCAPE 0x1B - -#define LC_KEY_SPACE 0x20 -#define LC_KEY_PRIOR 0x21 -#define LC_KEY_NEXT 0x22 -#define LC_KEY_END 0x23 -#define LC_KEY_HOME 0x24 -#define LC_KEY_LEFT 0x25 -#define LC_KEY_UP 0x26 -#define LC_KEY_RIGHT 0x27 -#define LC_KEY_DOWN 0x28 -#define LC_KEY_SELECT 0x29 -#define LC_KEY_PRINT 0x2A -#define LC_KEY_INSERT 0x2D -#define LC_KEY_DELETE 0x2E - -#define LC_KEY_0 0x30 -#define LC_KEY_1 0x31 -#define LC_KEY_2 0x32 -#define LC_KEY_3 0x33 -#define LC_KEY_4 0x34 -#define LC_KEY_5 0x35 -#define LC_KEY_6 0x36 -#define LC_KEY_7 0x37 -#define LC_KEY_8 0x38 -#define LC_KEY_9 0x39 - -#define LC_KEY_A 0x41 -#define LC_KEY_B 0x42 -#define LC_KEY_C 0x43 -#define LC_KEY_D 0x44 -#define LC_KEY_E 0x45 -#define LC_KEY_F 0x46 -#define LC_KEY_G 0x47 -#define LC_KEY_H 0x48 -#define LC_KEY_I 0x49 -#define LC_KEY_J 0x4A -#define LC_KEY_K 0x4B -#define LC_KEY_L 0x4C -#define LC_KEY_M 0x4D -#define LC_KEY_N 0x4E -#define LC_KEY_O 0x4F -#define LC_KEY_P 0x50 -#define LC_KEY_Q 0x51 -#define LC_KEY_R 0x52 -#define LC_KEY_S 0x53 -#define LC_KEY_T 0x54 -#define LC_KEY_U 0x55 -#define LC_KEY_V 0x56 -#define LC_KEY_W 0x57 -#define LC_KEY_X 0x58 -#define LC_KEY_Y 0x59 -#define LC_KEY_Z 0x5A - -#define LC_KEY_NUMPAD0 0x60 -#define LC_KEY_NUMPAD1 0x61 -#define LC_KEY_NUMPAD2 0x62 -#define LC_KEY_NUMPAD3 0x63 -#define LC_KEY_NUMPAD4 0x64 -#define LC_KEY_NUMPAD5 0x65 -#define LC_KEY_NUMPAD6 0x66 -#define LC_KEY_NUMPAD7 0x67 -#define LC_KEY_NUMPAD8 0x68 -#define LC_KEY_NUMPAD9 0x69 -#define LC_KEY_MULTIPLY 0x6A -#define LC_KEY_ADD 0x6B -//#define LC_KEY_SEPARATOR 0x6C -#define LC_KEY_SUBTRACT 0x6D -#define LC_KEY_DECIMAL 0x6E -#define LC_KEY_DIVIDE 0x6F -#define LC_KEY_F1 0x70 -#define LC_KEY_F2 0x71 -#define LC_KEY_F3 0x72 -#define LC_KEY_F4 0x73 -#define LC_KEY_F5 0x74 -#define LC_KEY_F6 0x75 -#define LC_KEY_F7 0x76 -#define LC_KEY_F8 0x77 -#define LC_KEY_F9 0x78 -#define LC_KEY_F10 0x79 -#define LC_KEY_F11 0x7A -#define LC_KEY_F12 0x7B -#define LC_KEY_F13 0x7C -#define LC_KEY_F14 0x7D -#define LC_KEY_F15 0x7E -#define LC_KEY_F16 0x7F -#define LC_KEY_F17 0x80 -#define LC_KEY_F18 0x81 -#define LC_KEY_F19 0x82 -#define LC_KEY_F20 0x83 -#define LC_KEY_F21 0x84 -#define LC_KEY_F22 0x85 -#define LC_KEY_F23 0x86 -#define LC_KEY_F24 0x87 - -#define LC_KEY_NUMLOCK 0x90 -#define LC_KEY_SCROLL 0x91 - -// ============================================================================ -// Functions. - -#define LC_KEYMOD1_SHIFT 0x01 -#define LC_KEYMOD1_CONTROL 0x02 -#define LC_KEYMOD2_SHIFT 0x04 -#define LC_KEYMOD2_CONTROL 0x08 -#define LC_KEYMOD_VIEWONLY 0x10 - -#define LC_KEYMOD1_MASK (LC_KEYMOD1_SHIFT | LC_KEYMOD1_CONTROL) -#define LC_KEYMOD2_MASK (LC_KEYMOD2_SHIFT | LC_KEYMOD2_CONTROL) -#define LC_KEYMOD_MASK (LC_KEYMOD1_MASK | LC_KEYMOD2_MASK) - -#define LC_KEYMOD_1TO2(a) ((a & ~LC_KEYMOD_MASK) | ((a & LC_KEYMOD1_MASK) << 2)) -#define LC_KEYMOD_2TO1(a) ((a & ~LC_KEYMOD_MASK) | ((a & LC_KEYMOD2_MASK) >> 2)) - -struct LC_KEYBOARD_COMMAND -{ - LC_COMMANDS ID; - const char* Description; - unsigned char Flags; - unsigned char Key1; - unsigned char Key2; -}; - -extern LC_KEYBOARD_COMMAND KeyboardShortcuts[]; -extern const int KeyboardShortcutsCount; - -const char* GetKeyName(char Key); -char GetKeyFromName(const char* Name); - -void InitKeyboardShortcuts(); -void ResetKeyboardShortcuts(); -bool SaveKeyboardShortcuts(const char* FileName); -bool LoadKeyboardShortcuts(const char* FileName); - -#endif // _KEYBOARD_H_ diff --git a/common/lc_application.cpp b/common/lc_application.cpp index f7df143d..e7dd5ed5 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -1,427 +1,385 @@ -#include "lc_global.h" -#include -#include "lc_application.h" -#include "lc_colors.h" -#include "lc_library.h" -#include "system.h" -#include "console.h" -#include "opengl.h" -#include "project.h" -#include "image.h" - -// ---------------------------------------------------------------------------- -// Global functions. - -lcApplication* g_App; - -lcPiecesLibrary* lcGetPiecesLibrary() -{ - LC_ASSERT(g_App, "g_App not initialized."); - return g_App->GetPiecesLibrary(); -} - -Project* lcGetActiveProject() -{ - LC_ASSERT(g_App, "g_App not initialized."); - return g_App->GetActiveProject(); -} - -// ---------------------------------------------------------------------------- -// lcApplication class. - -lcApplication::lcApplication() -{ - m_ActiveProject = NULL; - m_Library = NULL; -} - -lcApplication::~lcApplication() -{ -} - -void lcApplication::AddProject(Project* project) -{ - m_Projects.Add(project); - - if (m_ActiveProject == NULL) - m_ActiveProject = project; -} - -bool lcApplication::LoadPiecesLibrary(const char* LibPath, const char* LibraryInstallPath, const char* LibraryCachePath) -{ - if (m_Library == NULL) - m_Library = new lcPiecesLibrary(); - - if (LibPath && LibPath[0]) - { - if (m_Library->Load(LibPath, LibraryCachePath)) - return true; - } - else - { - char* EnvPath = getenv("LEOCAD_LIB"); - - if (EnvPath && EnvPath[0]) - { - if (m_Library->Load(EnvPath, LibraryCachePath)) - return true; - } - else - { - const char* CustomPath = Sys_ProfileLoadString("Settings", "CustomPiecesLibrary", ""); - - if (CustomPath[0]) - { - if (m_Library->Load(CustomPath, LibraryCachePath)) - return true; - } - else if (LibraryInstallPath && LibraryInstallPath[0]) - { - char LibraryPath[LC_MAXPATH]; - - strcpy(LibraryPath, LibraryInstallPath); - - int i = strlen(LibraryPath) - 1; - if ((LibraryPath[i] != '\\') && (LibraryPath[i] != '/')) - strcat(LibraryPath, "/"); - - strcat(LibraryPath, "library.bin"); - - if (m_Library->Load(LibraryPath, LibraryCachePath)) - { - m_Library->mNumOfficialPieces = m_Library->mPieces.GetSize(); - return true; - } - } - } - } - - return false; -} - -void lcApplication::ParseIntegerArgument(int* CurArg, int argc, char* argv[], int* Value) -{ - if (argc > (*CurArg + 1)) - { - (*CurArg)++; - int val; - - if ((sscanf(argv[(*CurArg)], "%d", &val) == 1) && (val > 0)) - *Value = val; - else - console.PrintWarning("Invalid value specified for the %s argument.", argv[(*CurArg) - 1]); - } - else - { - console.PrintWarning("Not enough parameters for the %s argument.", argv[(*CurArg) - 1]); - } -} - -void lcApplication::ParseStringArgument(int* CurArg, int argc, char* argv[], char** Value) -{ - if (argc > (*CurArg + 1)) - { - (*CurArg)++; - *Value = argv[(*CurArg)]; - } - else - { - console.PrintWarning("No path specified after the %s argument.", argv[(*CurArg) - 1]); - } -} - -bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstallPath, const char* LibraryCachePath) -{ - // System setup parameters. - char* LibPath = NULL; - char* GLPath = NULL; - - // Image output options. - bool SaveImage = false; - bool ImageAnimation = false; - bool ImageInstructions = false; - bool ImageHighlight = false; - int ImageWidth = Sys_ProfileLoadInt("Default", "Image Width", 640); - int ImageHeight = Sys_ProfileLoadInt("Default", "Image Height", 480); - int ImageStart = 0; - int ImageEnd = 0; - char* ImageName = NULL; - - // File to open. - char* ProjectName = NULL; - - // Parse the command line arguments. - for (int i = 1; i < argc; i++) - { - char* Param = argv[i]; - - if (Param[0] == '-') - { - if (strcmp(Param, "--libgl") == 0) - { - ParseStringArgument(&i, argc, argv, &GLPath); - } - else if ((strcmp(Param, "-l") == 0) || (strcmp(Param, "--libpath") == 0)) - { - ParseStringArgument(&i, argc, argv, &LibPath); - } - else if ((strcmp(Param, "-i") == 0) || (strcmp(Param, "--image") == 0)) - { - SaveImage = true; - - if ((argc > (i+1)) && (argv[i+1][0] != '-')) - { - i++; - ImageName = argv[i]; - } - } - else if ((strcmp(Param, "-w") == 0) || (strcmp(Param, "--width") == 0)) - { - ParseIntegerArgument(&i, argc, argv, &ImageWidth); - } - else if ((strcmp(Param, "-h") == 0) || (strcmp(Param, "--height") == 0)) - { - ParseIntegerArgument(&i, argc, argv, &ImageHeight); - } - else if ((strcmp(Param, "-f") == 0) || (strcmp(Param, "--from") == 0)) - { - ParseIntegerArgument(&i, argc, argv, &ImageStart); - } - else if ((strcmp(Param, "-t") == 0) || (strcmp(Param, "--to") == 0)) - { - ParseIntegerArgument(&i, argc, argv, &ImageEnd); - } - else if (strcmp(Param, "--animation") == 0) - ImageAnimation = true; - else if (strcmp(Param, "--instructions") == 0) - ImageInstructions = true; - else if (strcmp(Param, "--highlight") == 0) - ImageHighlight = true; - else if ((strcmp(Param, "-v") == 0) || (strcmp(Param, "--version") == 0)) - { - printf("LeoCAD Version " LC_VERSION_TEXT "\n"); - printf("Copyright (c) 1996-2006, BT Software\n"); - printf("Compiled "__DATE__"\n"); - - return false; - } - else if ((strcmp(Param, "-?") == 0) || (strcmp(Param, "--help") == 0)) - { - printf("Usage: leocad [options] [file]\n"); - printf(" [options] can be:\n"); - printf(" --libgl : Searches for OpenGL libraries in path.\n"); - printf(" -l, --libpath : Loads the Pieces Library from path.\n"); - printf(" -i, --image : Saves a picture in the format specified by ext.\n"); - printf(" -w, --width : Sets the picture width.\n"); - printf(" -h, --height : Sets the picture height.\n"); - printf(" -f, --from