print_utils.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:4k
- /*
- * ===========================================================================
- * PRODUCTION $Log: print_utils.hpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 19:50:46 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5
- * PRODUCTION
- * ===========================================================================
- */
- #ifndef GUI_UTILS__PRINT_UTILS_HPP
- #define GUI_UTILS__PRINT_UTILS_HPP
- /* $Id: print_utils.hpp,v 1000.1 2004/06/01 19:50:46 gouriano Exp $
- * ===========================================================================
- *
- * PUBLIC DOMAIN NOTICE
- * National Center for Biotechnology Information
- *
- * This software/database is a "United States Government Work" under the
- * terms of the United States Copyright Act. It was written as part of
- * the author's official duties as a United States Government employee and
- * thus cannot be copyrighted. This software/database is freely available
- * to the public for use. The National Library of Medicine and the U.S.
- * Government have not placed any restriction on its use or reproduction.
- *
- * Although all reasonable efforts have been taken to ensure the accuracy
- * and reliability of the software and data, the NLM and the U.S.
- * Government do not and cannot warrant the performance or results that
- * may be obtained by using this software or data. The NLM and the U.S.
- * Government disclaim all warranties, express or implied, including
- * warranties of performance, merchantability or fitness for any particular
- * purpose.
- *
- * Please cite the author in any work or product based on this material.
- *
- * ===========================================================================
- *
- * Authors: Peter Meric
- *
- * File Description:
- * print-related utilities
- *
- */
- #include <corelib/ncbistd.hpp>
- #include <gui/gui.hpp>
- BEGIN_NCBI_SCOPE
- class NCBI_GUIUTILS_EXPORT CUnit
- {
- public:
- enum EUnit
- {
- eInch,
- eMillimeter,
- ePdfUnit
- };
- typedef enum EUnit TUnit;
- typedef float TInch;
- typedef float TMillimeter;
- typedef float TPdfUnit;
- static string UnitToString(TUnit unit)
- {
- switch (unit) {
- case eInch:
- return "inch";
- case eMillimeter:
- return "millimeter";
- case ePdfUnit:
- return "point";
- }
- NCBI_THROW(CException, eUnknown, "CUnit::UnitToString: unknown unit");
- }
- static string UnitToSymbol(TUnit unit)
- {
- switch (unit) {
- case eInch:
- return """;
- case eMillimeter:
- return "mm";
- case ePdfUnit:
- return "pt";
- }
- return "";
- }
- };
- inline CUnit::TPdfUnit InchesToPdfUnits(CUnit::TInch x)
- {
- return x * 72;
- }
- inline CUnit::TPdfUnit MmToPdfUnits(CUnit::TMillimeter x)
- {
- return InchesToPdfUnits(x / 25.4f);
- }
- inline CUnit::TInch PdfUnitsToInches(CUnit::TPdfUnit x)
- {
- return x / 72;
- }
- inline CUnit::TMillimeter PdfUnitsToMm(CUnit::TPdfUnit x)
- {
- return PdfUnitsToInches(x) * 25.4f;
- }
- END_NCBI_SCOPE
- #endif // GUI_UTILS__PRINT_UTILS_HPP
- /*
- * ===========================================================================
- * $Log: print_utils.hpp,v $
- * Revision 1000.1 2004/06/01 19:50:46 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5
- *
- * Revision 1.5 2004/05/03 12:44:50 dicuccio
- * Added #include for gui/gui.hpp. Fixed compiler warning about double -> float
- * conversion
- *
- * Revision 1.4 2003/09/29 15:20:08 dicuccio
- * Deprecated gui/scope.hpp. Merged gui/core/types.hpp into gui/types.hpp
- *
- * Revision 1.3 2003/06/27 17:38:46 meric
- * Added "point" and "pt" as text and symbol respectively for PDF unit
- *
- * Revision 1.2 2003/06/24 17:24:28 meric
- * Added typdefs TInch, TMillimeter and TPdfUnit.
- *
- * Revision 1.1 2003/06/16 15:55:58 dicuccio
- * Work-in-progress: everything compiles, still much reorganization to be done.
- * Moved generic functionality out of opengl/print/ and into gui/utils (print
- * options, print dialogs, etc.). Removed interactive state from CGlCanvas.
- * Added hook in CView for opening standard print dialog, and for generic print
- * handling.
- *
- * Revision 1.2 2003/06/16 12:46:21 dicuccio
- * Clean-up after initial commit
- *
- * Revision 1.1 2003/06/13 19:00:30 meric
- * Initial version
- *
- *
- * ===========================================================================
- */