glcolortable.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:4k
- /*
- * ===========================================================================
- * PRODUCTION $Log: glcolortable.cpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 20:50:39 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: glcolortable.cpp,v 1000.1 2004/06/01 20:50:39 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:
- * Incremental and mutually contrastive color table generator.
- */
- #include <ncbi_pch.hpp>
- #include <gui/opengl/glcolortable.hpp>
- BEGIN_NCBI_SCOPE
- CGlColorTable::CGlColorTable()
- : m_MaxItems(8),
- m_ColorStep(1.0f),
- m_MinColor(0.0f),
- m_MaxColor(1.0f),
- m_ColorDiff(1.0f)
- {
- }
- CGlColorTable::CGlColorTable(int items, float min_color, float max_color)
- : m_MaxItems(items),
- m_ColorStep(1.0f),
- m_MinColor(min_color),
- m_MaxColor(max_color),
- m_ColorDiff(1.0f)
- {
- if (m_MaxColor < m_MinColor) {
- std::swap(m_MaxColor, m_MinColor);
- }
- m_ColorDiff = m_MaxColor - m_MinColor;
- x_CalcColorStep();
- }
- CGlColor CGlColorTable::GetColor(int i) const
- {
- i = abs (i % m_MaxItems);
- int reps = i / 7;
- int idx = i % 7 + 1;
- CGlColor color;
- float val = (reps + 1) * m_ColorStep + m_MinColor;
- color.SetRed (val * ((idx & 0x01) ));
- color.SetGreen(val * ((idx & 0x02) >> 1));
- color.SetBlue (val * ((idx & 0x04) >> 2));
- return color;
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: glcolortable.cpp,v $
- * Revision 1000.1 2004/06/01 20:50:39 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5
- *
- * Revision 1.5 2004/05/21 22:27:45 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.4 2003/01/15 21:14:21 dicuccio
- * Fixed bugs in indexing colors - must index only 7 (not 8) colors
- *
- * Revision 1.3 2003/01/13 13:10:11 dicuccio
- * Namespace clean-up. Retired namespace gui -> converted all to namespace ncbi.
- * Moved all FLUID-generated code into namespace ncbi.
- *
- * Revision 1.2 2003/01/10 15:28:10 dicuccio
- * Changed logic of CGlColorTable - support m_MaxItems colors as a rotating color
- * buffer (i.e., index = index mod m_MaxItems)
- *
- * Revision 1.1 2002/11/22 18:06:28 dicuccio
- * Initial revision.
- *
- * ===========================================================================
- */