diff --git a/misc/CMake/FindGL2PS.cmake b/misc/CMake/FindGL2PS.cmake deleted file mode 100644 index 8ccaa8a51c..0000000000 --- a/misc/CMake/FindGL2PS.cmake +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright (c) 1993-2015 Ken Martin, Will Schroeder, Bill Lorensen -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names -# of any contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -find_path(GL2PS_INCLUDE_DIR - NAMES gl2ps.h - DOC "gl2ps include directories") -mark_as_advanced(GL2PS_INCLUDE_DIR) - -find_library(GL2PS_LIBRARY - NAMES gl2ps - DOC "gl2ps library") -mark_as_advanced(GL2PS_LIBRARY) - -if (GL2PS_INCLUDE_DIR) - file(STRINGS "${GL2PS_INCLUDE_DIR}/gl2ps.h" _gl2ps_version_lines REGEX "#define[ \t]+GL2PS_(MAJOR|MINOR|PATCH)_VERSION[ \t]+") - string(REGEX REPLACE ".*GL2PS_MAJOR_VERSION *\([0-9]*\).*" "\\1" _gl2ps_version_major "${_gl2ps_version_lines}") - string(REGEX REPLACE ".*GL2PS_MINOR_VERSION *\([0-9]*\).*" "\\1" _gl2ps_version_minor "${_gl2ps_version_lines}") - string(REGEX REPLACE ".*GL2PS_PATCH_VERSION *\([0-9]*\).*" "\\1" _gl2ps_version_patch "${_gl2ps_version_lines}") - set(GL2PS_VERSION "${_gl2ps_version_major}.${_gl2ps_version_minor}.${_gl2ps_version_patch}") - unset(_gl2ps_version_major) - unset(_gl2ps_version_minor) - unset(_gl2ps_version_patch) - unset(_gl2ps_version_lines) -endif () - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GL2PS - REQUIRED_VARS GL2PS_LIBRARY GL2PS_INCLUDE_DIR - VERSION_VAR GL2PS_VERSION) - -if (GL2PS_FOUND) - set(GL2PS_INCLUDE_DIRS "${GL2PS_INCLUDE_DIR}") - set(GL2PS_LIBRARIES "${GL2PS_LIBRARY}") - - if (NOT TARGET GL2PS::GL2PS) - add_library(GL2PS::GL2PS UNKNOWN IMPORTED) - set_target_properties(GL2PS::GL2PS PROPERTIES - IMPORTED_LOCATION "${GL2PS_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${GL2PS_INCLUDE_DIR}") - endif () -endif () - - -# Local Variables: -# tab-width: 8 -# mode: cmake -# indent-tabs-mode: t -# End: -# ex: shiftwidth=2 tabstop=8 diff --git a/src/libged/dm/CMakeLists.txt b/src/libged/dm/CMakeLists.txt index 7688b5e18f..7dbe9760cb 100644 --- a/src/libged/dm/CMakeLists.txt +++ b/src/libged/dm/CMakeLists.txt @@ -12,28 +12,9 @@ set(DM_SRCS screengrab.c ) -set(DM_LIBS - libged - libdm - libbu - ) - -# TODO - check if we can use GL2PS without a system OpenGL install, using only -# the libosmesa backend. In theory we should be able to capture from swrast -# with GL2PS without anything else, but I don't know if GL2PS is set up to make -# that practical... -if(BRLCAD_ENABLE_OPENGL AND BRLCAD_ENABLE_GL2PS) - find_package(GL2PS) - if (GL2PS_FOUND) - add_definitions(-DUSE_GL2PS) - set(DM_LIBS ${DM_LIBS} GL2PS::GL2PS) - include_directories(${GL2PS_INCLUDE_DIRS}) - endif (GL2PS_FOUND) -endif(BRLCAD_ENABLE_OPENGL AND BRLCAD_ENABLE_GL2PS) - add_definitions(-DGED_PLUGIN) ged_plugin_library(ged-dm SHARED ${DM_SRCS}) -target_link_libraries(ged-dm ${DM_LIBS}) +target_link_libraries(ged-dm libged libdm libbu) set_property(TARGET ged-dm APPEND PROPERTY COMPILE_DEFINITIONS BRLCADBUILD HAVE_CONFIG_H) VALIDATE_STYLE(ged-dm ${DM_SRCS}) PLUGIN_SETUP(ged-dm ged) diff --git a/src/libged/dm/screengrab.c b/src/libged/dm/screengrab.c index a764022755..984f0052dc 100644 --- a/src/libged/dm/screengrab.c +++ b/src/libged/dm/screengrab.c @@ -29,81 +29,29 @@ #include #include #include "icv.h" -#define DM_WITH_RT #include "dm.h" #include "../ged_private.h" -struct image_mime_t { - bu_mime_image_t img; - bu_mime_application_t vec; -}; -#define IMAGE_MIME_NULL {BU_MIME_IMAGE_UNKNOWN, BU_MIME_APPLICATION_UNKNOWN} - -#ifdef USE_GL2PS -#include "gl2ps.h" -int -gl2ps_screengrab(struct ged *gedp, struct dm *dmp, bu_mime_application_t fmt, const char *ofile) -{ - GLint format = GL2PS_PS; - format = (fmt == BU_MIME_APPLICATION_PDF) ? GL2PS_PDF : format; - int buffsize = dm_get_width(dmp) * dm_get_height(dmp); - FILE *fp = fopen(ofile, "wb"); - if (!fp) - return BRLCAD_ERROR; - gl2psBeginPage("GED Scene Capture", "screengrab", NULL, format, GL2PS_BSP_SORT, - GL2PS_DRAW_BACKGROUND | GL2PS_USE_CURRENT_VIEWPORT, - GL_RGBA, 0, NULL, 0, 0, 0, buffsize, fp, NULL); - dm_draw_begin(dmp); - dm_draw_objs(gedp->ged_gvp, NULL, NULL); - dm_draw_end(dmp); - gl2psEndPage(); - fclose(fp); - return BRLCAD_OK; -} -#else -int -gl2ps_screengrab(struct ged *gedp, struct dm *UNUSED(dmp), bu_mime_application_t UNUSED(fmt), const char *ofile) -{ - bu_vls_printf(gedp->ged_result_str, "GL2PS disabled - image format of output %s is not supported", ofile); - return BRLCAD_ERROR; -} -#endif - - static int image_mime(struct bu_vls *msg, size_t argc, const char **argv, void *set_mime) { int type_int; - bu_mime_image_t img_type = BU_MIME_IMAGE_UNKNOWN; - struct image_mime_t *set_type = (struct image_mime_t *)set_mime; + bu_mime_image_t type = BU_MIME_IMAGE_UNKNOWN; + bu_mime_image_t *set_type = (bu_mime_image_t *)set_mime; BU_OPT_CHECK_ARGV0(msg, argc, argv, "mime format"); type_int = bu_file_mime(argv[0], BU_MIME_IMAGE); - img_type = (type_int < 0) ? BU_MIME_IMAGE_UNKNOWN : (bu_mime_image_t)type_int; - if (img_type == BU_MIME_IMAGE_UNKNOWN) { - // See if we've got a vector format requested - bu_mime_application_t app_type = BU_MIME_APPLICATION_UNKNOWN; - type_int = bu_file_mime(argv[0], BU_MIME_APPLICATION); - app_type = (type_int < 0) ? BU_MIME_APPLICATION_UNKNOWN : (bu_mime_application_t)type_int; - if (app_type == BU_MIME_APPLICATION_UNKNOWN) { - if (msg) - bu_vls_sprintf(msg, "Error - unknown geometry file type: %s \n", argv[0]); - return -1; - } else { - if (app_type != BU_MIME_APPLICATION_POSTSCRIPT && - app_type != BU_MIME_APPLICATION_PDF) { - if (msg) - bu_vls_sprintf(msg, "Error - unknown geometry file type: %s \n", argv[0]); - return -1; - } - if (set_type) - set_type->vec = app_type; + type = (type_int < 0) ? BU_MIME_IMAGE_UNKNOWN : (bu_mime_image_t)type_int; + if (type == BU_MIME_IMAGE_UNKNOWN) { + if (msg) { + bu_vls_sprintf(msg, "Error - unknown geometry file type: %s \n", argv[0]); } - } else { - if (set_type) - set_type->img = img_type; + return -1; + } + if (set_type) { + (*set_type) = type; } return 1; } @@ -122,7 +70,7 @@ ged_screen_grab_core(struct ged *gedp, int argc, const char *argv[]) struct icv_image *bif = NULL; /**< icv image container for saving images */ struct fb *fbp = NULL; struct bu_vls dm_name = BU_VLS_INIT_ZERO; - struct image_mime_t type = IMAGE_MIME_NULL; + bu_mime_image_t type = BU_MIME_IMAGE_AUTO; static char usage[] = "Usage: screengrab [-h] [-F] [-D name] [--format fmt] [file.img]\n"; struct bu_opt_desc d[5]; @@ -195,13 +143,6 @@ ged_screen_grab_core(struct ged *gedp, int argc, const char *argv[]) /* create image file */ if (!grab_fb) { - if (type.img == BU_MIME_IMAGE_PS) - type.vec = BU_MIME_APPLICATION_POSTSCRIPT; - - if (type.img == BU_MIME_IMAGE_UNKNOWN && type.vec != BU_MIME_APPLICATION_UNKNOWN) { - // Postscript or PDF output requested - return gl2ps_screengrab(gedp, dmp, type.vec, argv[0]); - } bytes_per_pixel = 3; bytes_per_line = dm_get_width(dmp) * bytes_per_pixel; @@ -233,7 +174,7 @@ ged_screen_grab_core(struct ged *gedp, int argc, const char *argv[]) } } - icv_write(bif, argv[0], type.img); + icv_write(bif, argv[0], type); icv_destroy(bif); return BRLCAD_OK;