glcanvas.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:7k
- /*
- * ===========================================================================
- * PRODUCTION $Log: glcanvas.hpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 19:49:29 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.18
- * PRODUCTION
- * ===========================================================================
- */
- #ifndef GUI_OPENGL___GL_CANVAS__HPP
- #define GUI_OPENGL___GL_CANVAS__HPP
- /* $Id: glcanvas.hpp,v 1000.1 2004/06/01 19:49:29 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: Mike DiCuccio
- *
- * File Description:
- * CGlCanvas -- provide standardized OpenGL view setup for FLTK
- *
- */
- #include <corelib/ncbistd.hpp>
- #include <gui/opengl.h>
- #include <gui/opengl/glcamera.hpp>
- #include <FL/Fl_Gl_Window.H>
- /** @addtogroup GUI_OPENGL
- *
- * @{
- */
- BEGIN_NCBI_SCOPE
- class CPrintOptions;
- //
- // class CGlCanvas provides an abstraction for manipulating an OpenGL context,
- // and provides hooks to FLTK's interaction model.
- //
- // This class provides standard rendering support and interaction through FLTK.
- // It is an abstract base class; its two subclasses provide an easy means of
- // configuring 2D and 3D views. In addition, this class provides standard
- // hooks for print capture and output.
- //
- class NCBI_GUIOPENGL_EXPORT CGlCanvas : public Fl_Gl_Window
- {
- public:
- // rendering modes - includes various basic OpenGL enables
- enum ERenderMode {
- fLighting = 0x01,
- fCullFace = 0x02,
- fDepthTest = 0x04,
- fTexture2D = 0x08
- };
- typedef unsigned int TRenderMode; // bitwise OR of "ERenderMode"
- CGlCanvas(int x, int y, int wid, int ht, const char* label = 0);
- virtual ~CGlCanvas(void);
- // overloaded FLTK drawing hook. Calls x_Draw(). If not in
- // print capture mode, also calls x_OverlayDraw()
- virtual void draw(void);
- virtual void draw_print(void);
- // print the resulting OpenGL window, according to the options
- // defined in CPrintOptions
- void Print(const CPrintOptions& options);
- protected:
- // an object to control our camera set-up
- CGlCamera m_Camera;
- // bitmask of our rendering modes
- TRenderMode m_RenderModes;
-
- bool m_Capture;
- // set the standard rendering modes (OpenGL enables, etc)
- virtual void x_SetupRenderModes(void);
- // draw the background color.
- virtual void x_DrawBackground(float red, float green, float blue);
- // set the viewing matrices. derived classes must provide this.
- virtual void x_SetupView(void) = 0;
- // draw our scene
- virtual void x_Draw(void) { };
- virtual void x_OverlayDraw(void) { }
- };
- END_NCBI_SCOPE
- /* @} */
- /*
- * ===========================================================================
- * $Log: glcanvas.hpp,v $
- * Revision 1000.1 2004/06/01 19:49:29 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.18
- *
- * Revision 1.18 2004/05/11 18:54:22 dicuccio
- * Added doxygne modules info
- *
- * Revision 1.17 2003/09/29 15:20:07 dicuccio
- * Deprecated gui/scope.hpp. Merged gui/core/types.hpp into gui/types.hpp
- *
- * Revision 1.16 2003/07/21 19:21:47 dicuccio
- * Removed unused additional constructor
- *
- * Revision 1.15 2003/06/25 16:22:49 meric
- * Moved printing functionality to gui/opengl/gl_print and gui/utils/print
- *
- * Revision 1.14 2003/06/18 17:27:19 meric
- * Final phase of print reorg: print classes now in gui/utils
- *
- * Revision 1.13 2003/06/16 15:55:57 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.12 2003/06/13 18:59:12 meric
- * Initialization in x_Init(), which is called by all c'tors
- * Remove print-related functinality from draw(), which can now be
- * overridden freely without affecting the Print() function.
- * Add print functions [ Print(), x_Print() etc ]
- *
- * Revision 1.11 2003/06/03 17:42:54 dicuccio
- * Added texture support. Added classes to handle OpenGL camera setup, viewport
- * specification
- *
- * Revision 1.10 2003/05/13 19:22:34 dicuccio
- * Prepared CGlCanvas for printing - from Peter Meric
- *
- * Revision 1.9 2003/05/06 15:51:56 dicuccio
- * Reorganized CGlCanvas and CGlUtils: moved hardware check into CGlUtils; split
- * CGlCanvas into 2D and 3D variants
- *
- * Revision 1.8 2003/03/28 17:15:06 dicuccio
- * Added first support for determining hardware acceleration
- *
- * Revision 1.7 2003/03/25 13:07:58 dicuccio
- * Use the proper FLTK header (ends in '.H')
- *
- * Revision 1.6 2003/01/13 13:11:42 dicuccio
- * Namespace clean-up. Retired namespace gui -> converted to namespace ncbi.
- * Moved all FLUID-generated code into namespace ncbi.
- *
- * Revision 1.5 2002/12/19 18:13:03 dicuccio
- * Added export specifiers for Win32.
- *
- * Revision 1.4 2002/11/14 16:13:36 dicuccio
- * Changed to include standard OpenGL headers in 'gui/opengl.h'
- *
- * Revision 1.3 2002/11/07 18:24:46 dicuccio
- * Minor #ifdef changes. Created macro to wrap dumping of OpenGL state.
- *
- * Revision 1.2 2002/11/05 19:49:47 dicuccio
- * Renamed ERenderMode members as flags (eBar to fBar)
- *
- * Revision 1.1 2002/11/04 20:05:37 dicuccio
- * Initial revision
- *
- * ===========================================================================
- */
- #endif // GUI_OPENGL___GL_CANVAS__HPP