From 0f1098c1aeefaaa8539e991a06727626442845dd Mon Sep 17 00:00:00 2001 From: David Rose Date: Sat, 11 Aug 2012 14:28:56 +0000 Subject: [PATCH] move PfmFile to pnmimage --- panda/src/grutil/Sources.pp | 6 ---- panda/src/grutil/config_grutil.cxx | 30 ------------------- panda/src/grutil/config_grutil.h | 5 ---- panda/src/grutil/p3grutil_composite2.cxx | 2 -- panda/src/pnmimage/Sources.pp | 6 ++++ panda/src/pnmimage/config_pnmimage.cxx | 30 +++++++++++++++++++ panda/src/pnmimage/config_pnmimage.h | 7 +++++ panda/src/pnmimage/p3pnmimage_composite1.cxx | 2 ++ panda/src/{grutil => pnmimage}/pfmFile.I | 0 panda/src/{grutil => pnmimage}/pfmFile.cxx | 26 ++++++++-------- panda/src/{grutil => pnmimage}/pfmFile.h | 2 +- .../{grutil => pnmimage}/pnmFileTypePfm.cxx | 2 +- .../src/{grutil => pnmimage}/pnmFileTypePfm.h | 3 +- 13 files changed, 62 insertions(+), 59 deletions(-) rename panda/src/{grutil => pnmimage}/pfmFile.I (100%) mode change 100755 => 100644 rename panda/src/{grutil => pnmimage}/pfmFile.cxx (99%) mode change 100755 => 100644 rename panda/src/{grutil => pnmimage}/pfmFile.h (99%) mode change 100755 => 100644 rename panda/src/{grutil => pnmimage}/pnmFileTypePfm.cxx (99%) rename panda/src/{grutil => pnmimage}/pnmFileTypePfm.h (96%) diff --git a/panda/src/grutil/Sources.pp b/panda/src/grutil/Sources.pp index de532b43a7..cc00879b9f 100644 --- a/panda/src/grutil/Sources.pp +++ b/panda/src/grutil/Sources.pp @@ -25,8 +25,6 @@ lineSegs.I lineSegs.h \ multitexReducer.I multitexReducer.h multitexReducer.cxx \ nodeVertexTransform.I nodeVertexTransform.h \ - pfmFile.I pfmFile.h \ - pnmFileTypePfm.h \ rigidBodyCombiner.I rigidBodyCombiner.h #define INCLUDED_SOURCES \ @@ -41,8 +39,6 @@ sceneGraphAnalyzerMeter.cxx \ heightfieldTesselator.cxx \ nodeVertexTransform.cxx \ - pfmFile.cxx \ - pnmFileTypePfm.cxx \ pipeOcclusionCullTraverser.cxx \ lineSegs.cxx \ rigidBodyCombiner.cxx @@ -60,8 +56,6 @@ lineSegs.I lineSegs.h \ multitexReducer.I multitexReducer.h \ nodeVertexTransform.I nodeVertexTransform.h \ - pfmFile.I pfmFile.h \ - pnmFileTypePfm.h \ rigidBodyCombiner.I rigidBodyCombiner.h #define IGATESCAN all diff --git a/panda/src/grutil/config_grutil.cxx b/panda/src/grutil/config_grutil.cxx index 4cdf89e957..64acac1a4b 100644 --- a/panda/src/grutil/config_grutil.cxx +++ b/panda/src/grutil/config_grutil.cxx @@ -24,8 +24,6 @@ #include "nodeVertexTransform.h" #include "rigidBodyCombiner.h" #include "pipeOcclusionCullTraverser.h" -#include "pnmFileTypePfm.h" -#include "pnmFileTypeRegistry.h" #include "dconfig.h" @@ -63,29 +61,6 @@ ConfigVariableDouble scene_graph_analyzer_meter_scale ConfigVariableDouble scene_graph_analyzer_meter_side_margins ("scene-graph-analyzer-meter-side-margins", 0.5); -ConfigVariableBool pfm_force_littleendian -("pfm-force-littleendian", false, - PRC_DESC("This forces a pfm file to be read as a sequence of little-endian " - "floats, even if its scale factor is given as a positive number.")); - -ConfigVariableBool pfm_reverse_dimensions -("pfm-reverse-dimensions", false, - PRC_DESC("Understands that the width and height of a pfm file are given " - "backwards, in the form height width instead of width height, " - "on input. Does not affect output, which is always written width height.")); - -ConfigVariableInt pfm_vis_max_vertices -("pfm-vis-max-vertices", 65535, - PRC_DESC("Specifies the maximum number of vertex entries that may appear in " - "a single generated mesh. If the mesh would require more than that, " - "the mesh is subdivided into smaller pieces.")); - -ConfigVariableInt pfm_vis_max_indices -("pfm-vis-max-indices", 1048576, - PRC_DESC("Specifies the maximum number of vertex references that may appear in " - "a single generated mesh. If the mesh would require more than that, " - "the mesh is subdivided into smaller pieces.")); - ConfigVariableBool movies_sync_pages ("movies-sync-pages", true, PRC_DESC("Set this true to force multi-page MovieTextures to hold pages " @@ -134,10 +109,5 @@ init_libgrutil() { TexturePool *ts = TexturePool::get_global_ptr(); ts->register_texture_type(MovieTexture::make_texture, "avi mov mpg mpeg mp4 wmv asf flv nut ogm mkv"); #endif // HAVE_FFMPEG - - PNMFileTypeRegistry *tr = PNMFileTypeRegistry::get_global_ptr(); - PNMFileTypePfm::init_type(); - PNMFileTypePfm::register_with_read_factory(); - tr->register_type(new PNMFileTypePfm); } diff --git a/panda/src/grutil/config_grutil.h b/panda/src/grutil/config_grutil.h index 6a9eb7b746..a13106e403 100644 --- a/panda/src/grutil/config_grutil.h +++ b/panda/src/grutil/config_grutil.h @@ -35,11 +35,6 @@ extern ConfigVariableInt scene_graph_analyzer_meter_layer_sort; extern ConfigVariableDouble scene_graph_analyzer_meter_scale; extern ConfigVariableDouble scene_graph_analyzer_meter_side_margins; -extern ConfigVariableBool pfm_force_littleendian; -extern ConfigVariableBool pfm_reverse_dimensions; -extern ConfigVariableInt pfm_vis_max_vertices; -extern ConfigVariableInt pfm_vis_max_indices; - extern ConfigVariableBool movies_sync_pages; extern EXPCL_PANDA_GRUTIL void init_libgrutil(); diff --git a/panda/src/grutil/p3grutil_composite2.cxx b/panda/src/grutil/p3grutil_composite2.cxx index 3a5bf4d0ff..38b3ae66f3 100644 --- a/panda/src/grutil/p3grutil_composite2.cxx +++ b/panda/src/grutil/p3grutil_composite2.cxx @@ -4,5 +4,3 @@ #include "rigidBodyCombiner.cxx" #include "meshDrawer.cxx" #include "meshDrawer2D.cxx" -#include "pfmFile.cxx" -#include "pnmFileTypePfm.cxx" diff --git a/panda/src/pnmimage/Sources.pp b/panda/src/pnmimage/Sources.pp index a3e906f8ef..8d1e91319f 100644 --- a/panda/src/pnmimage/Sources.pp +++ b/panda/src/pnmimage/Sources.pp @@ -11,6 +11,8 @@ #define SOURCES \ config_pnmimage.h \ + pfmFile.I pfmFile.h \ + pnmFileTypePfm.h \ pnmbitio.h \ pnmBrush.h pnmBrush.I \ pnmFileType.h pnmFileTypeRegistry.h pnmImage.I \ @@ -22,6 +24,8 @@ #define INCLUDED_SOURCES \ config_pnmimage.cxx \ + pfmFile.cxx \ + pnmFileTypePfm.cxx \ pnm-image-filter.cxx \ pnmbitio.cxx \ pnmBrush.cxx \ @@ -33,6 +37,8 @@ #define INSTALL_HEADERS \ config_pnmimage.h \ + pfmFile.I pfmFile.h \ + pnmFileTypePfm.h \ pnmBrush.h pnmBrush.I \ pnmFileType.h pnmFileTypeRegistry.h pnmImage.I \ pnmImage.h pnmImageHeader.I pnmImageHeader.h \ diff --git a/panda/src/pnmimage/config_pnmimage.cxx b/panda/src/pnmimage/config_pnmimage.cxx index 2598cae568..2ea285c79c 100644 --- a/panda/src/pnmimage/config_pnmimage.cxx +++ b/panda/src/pnmimage/config_pnmimage.cxx @@ -14,6 +14,8 @@ #include "config_pnmimage.h" #include "pnmFileType.h" +#include "pnmFileTypePfm.h" +#include "pnmFileTypeRegistry.h" #include "dconfig.h" @@ -24,6 +26,29 @@ ConfigureFn(config_pnmimage) { init_libpnmimage(); } +ConfigVariableBool pfm_force_littleendian +("pfm-force-littleendian", false, + PRC_DESC("This forces a pfm file to be read as a sequence of little-endian " + "floats, even if its scale factor is given as a positive number.")); + +ConfigVariableBool pfm_reverse_dimensions +("pfm-reverse-dimensions", false, + PRC_DESC("Understands that the width and height of a pfm file are given " + "backwards, in the form height width instead of width height, " + "on input. Does not affect output, which is always written width height.")); + +ConfigVariableInt pfm_vis_max_vertices +("pfm-vis-max-vertices", 65535, + PRC_DESC("Specifies the maximum number of vertex entries that may appear in " + "a single generated mesh. If the mesh would require more than that, " + "the mesh is subdivided into smaller pieces.")); + +ConfigVariableInt pfm_vis_max_indices +("pfm-vis-max-indices", 1048576, + PRC_DESC("Specifies the maximum number of vertex references that may appear in " + "a single generated mesh. If the mesh would require more than that, " + "the mesh is subdivided into smaller pieces.")); + //////////////////////////////////////////////////////////////////// // Function: init_libpnmimage // Description: Initializes the library. This must be called at @@ -41,4 +66,9 @@ init_libpnmimage() { initialized = true; PNMFileType::init_type(); + + PNMFileTypeRegistry *tr = PNMFileTypeRegistry::get_global_ptr(); + PNMFileTypePfm::init_type(); + PNMFileTypePfm::register_with_read_factory(); + tr->register_type(new PNMFileTypePfm); } diff --git a/panda/src/pnmimage/config_pnmimage.h b/panda/src/pnmimage/config_pnmimage.h index 2b022de7a6..b8c49d1c51 100644 --- a/panda/src/pnmimage/config_pnmimage.h +++ b/panda/src/pnmimage/config_pnmimage.h @@ -17,9 +17,16 @@ #include "pandabase.h" #include "notifyCategoryProxy.h" +#include "configVariableInt.h" +#include "configVariableBool.h" NotifyCategoryDecl(pnmimage, EXPCL_PANDA_PNMIMAGE, EXPTP_PANDA_PNMIMAGE); +extern ConfigVariableBool pfm_force_littleendian; +extern ConfigVariableBool pfm_reverse_dimensions; +extern ConfigVariableInt pfm_vis_max_vertices; +extern ConfigVariableInt pfm_vis_max_indices; + extern EXPCL_PANDA_PNMIMAGE void init_libpnmimage(); #endif diff --git a/panda/src/pnmimage/p3pnmimage_composite1.cxx b/panda/src/pnmimage/p3pnmimage_composite1.cxx index 0a2a6c01f1..c7a0716feb 100644 --- a/panda/src/pnmimage/p3pnmimage_composite1.cxx +++ b/panda/src/pnmimage/p3pnmimage_composite1.cxx @@ -1,4 +1,6 @@ #include "config_pnmimage.cxx" +#include "pfmFile.cxx" +#include "pnmFileTypePfm.cxx" #include "pnm-image-filter.cxx" #include "pnmbitio.cxx" #include "pnmBrush.cxx" diff --git a/panda/src/grutil/pfmFile.I b/panda/src/pnmimage/pfmFile.I old mode 100755 new mode 100644 similarity index 100% rename from panda/src/grutil/pfmFile.I rename to panda/src/pnmimage/pfmFile.I diff --git a/panda/src/grutil/pfmFile.cxx b/panda/src/pnmimage/pfmFile.cxx old mode 100755 new mode 100644 similarity index 99% rename from panda/src/grutil/pfmFile.cxx rename to panda/src/pnmimage/pfmFile.cxx index 635eec2098..048616e11c --- a/panda/src/grutil/pfmFile.cxx +++ b/panda/src/pnmimage/pfmFile.cxx @@ -12,7 +12,7 @@ // //////////////////////////////////////////////////////////////////// -#include "config_grutil.h" +#include "config_pnmimage.h" #include "pfmFile.h" #include "virtualFileSystem.h" #include "pandaFileStream.h" @@ -144,13 +144,13 @@ read(const Filename &fullpath) { PT(VirtualFile) file = vfs->get_file(filename); if (file == (VirtualFile *)NULL) { // No such file. - grutil_cat.error() + pnmimage_cat.error() << "Could not find " << fullpath << "\n"; return false; } - if (grutil_cat.is_debug()) { - grutil_cat.debug() + if (pnmimage_cat.is_debug()) { + pnmimage_cat.debug() << "Reading PFM file " << filename << "\n"; } @@ -201,13 +201,13 @@ read(istream &in, const Filename &fullpath, const string &magic_number) { PNMReader *reader = pnm.make_reader (&in, false, fullpath, identifier, NULL, false); if (reader == (PNMReader *)NULL) { - grutil_cat.error() + pnmimage_cat.error() << "Not a PFM file or known image file type: " << fullpath << "\n"; return false; } if (!pnm.read(reader)) { - grutil_cat.error() + pnmimage_cat.error() << "Invalid image file: " << fullpath << "\n"; return false; } @@ -219,7 +219,7 @@ read(istream &in, const Filename &fullpath, const string &magic_number) { PN_float32 scale; in >> width >> height >> scale; if (!in) { - grutil_cat.error() + pnmimage_cat.error() << "Error parsing PFM header: " << fullpath << "\n"; return false; } @@ -291,7 +291,7 @@ read(istream &in, const Filename &fullpath, const string &magic_number) { bool PfmFile:: write(const Filename &fullpath) { if (!is_valid()) { - grutil_cat.error() + pnmimage_cat.error() << "PFM file is invalid.\n"; return false; } @@ -299,7 +299,7 @@ write(const Filename &fullpath) { Filename filename = Filename::binary_filename(fullpath); pofstream out; if (!filename.open_write(out)) { - grutil_cat.error() + pnmimage_cat.error() << "Unable to open " << filename << "\n"; return false; } @@ -319,8 +319,8 @@ write(const Filename &fullpath) { } } - if (grutil_cat.is_debug()) { - grutil_cat.debug() + if (pnmimage_cat.is_debug()) { + pnmimage_cat.debug() << "Writing PFM file " << filename << "\n"; } @@ -1485,8 +1485,8 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { } // OK, now we know how many cells we need. - if (grutil_cat.is_debug()) { - grutil_cat.debug() + if (pnmimage_cat.is_debug()) { + pnmimage_cat.debug() << "Generating mesh with " << num_x_cells << " x " << num_y_cells << " pieces.\n"; } diff --git a/panda/src/grutil/pfmFile.h b/panda/src/pnmimage/pfmFile.h old mode 100755 new mode 100644 similarity index 99% rename from panda/src/grutil/pfmFile.h rename to panda/src/pnmimage/pfmFile.h index a6cb4ecf2e..df2e0dd7fa --- a/panda/src/grutil/pfmFile.h +++ b/panda/src/pnmimage/pfmFile.h @@ -33,7 +33,7 @@ class GeomVertexWriter; // numbers, either 3-component or 1-component, or with a // special extension, 4-component. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_GRUTIL PfmFile { +class EXPCL_PANDA_PNMIMAGE PfmFile { PUBLISHED: PfmFile(); PfmFile(const PfmFile ©); diff --git a/panda/src/grutil/pnmFileTypePfm.cxx b/panda/src/pnmimage/pnmFileTypePfm.cxx similarity index 99% rename from panda/src/grutil/pnmFileTypePfm.cxx rename to panda/src/pnmimage/pnmFileTypePfm.cxx index a4b5191a0b..3077fd9301 100644 --- a/panda/src/grutil/pnmFileTypePfm.cxx +++ b/panda/src/pnmimage/pnmFileTypePfm.cxx @@ -13,7 +13,7 @@ //////////////////////////////////////////////////////////////////// #include "pnmFileTypePfm.h" -#include "config_grutil.h" +#include "config_pnmimage.h" #include "pnmFileTypeRegistry.h" #include "bamReader.h" diff --git a/panda/src/grutil/pnmFileTypePfm.h b/panda/src/pnmimage/pnmFileTypePfm.h similarity index 96% rename from panda/src/grutil/pnmFileTypePfm.h rename to panda/src/pnmimage/pnmFileTypePfm.h index 6f2c73eac1..a42da2b405 100644 --- a/panda/src/grutil/pnmFileTypePfm.h +++ b/panda/src/pnmimage/pnmFileTypePfm.h @@ -18,6 +18,7 @@ #include "pandabase.h" #include "pnmFileType.h" +#include "pnmImage.h" #include "pnmReader.h" #include "pnmWriter.h" @@ -26,7 +27,7 @@ // Description : For reading and writing PFM files using the basic // PNMImage interface, as if they were basic RGB files. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_GRUTIL PNMFileTypePfm : public PNMFileType { +class EXPCL_PANDA_PNMIMAGE PNMFileTypePfm : public PNMFileType { public: PNMFileTypePfm();