NCBI C++ ToolKit
cn3d_colors.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: cn3d_colors.cpp 33815 2007-05-04 17:18:18Z kazimird $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Authors: Paul Thiessen
27 *
28 * File Description:
29 * Holds various color values and cycles
30 *
31 * ===========================================================================
32 */
33 
34 #include <ncbi_pch.hpp>
35 #include <corelib/ncbistd.hpp>
36 
37 #include <math.h>
38 
40 
41 #include "cn3d_colors.hpp"
42 #include "cn3d_tools.hpp"
43 
45 
46 
47 BEGIN_SCOPE(Cn3D)
48 
49 // the global Colors object
51 
53 {
54  return &colors;
55 }
56 
57 
58 // # colors for color cycles
59 const unsigned int
60  Colors::nCycle1 = 10;
61 
62 // # colors for color maps (must be >1)
63 const unsigned int
68 
69 
71 {
72  // default colors
73  colors[eHighlight].Set(1, 1, 0);
74  colors[eMergeFail].Set(1, .8, .8);
75  colors[eGeometryViolation].Set(.6, 1, .6);
76  colors[eMarkBlock].Set(.8, .8, .8);
77 
78  colors[eHelix].Set(.1, .9, .1);
79  colors[eStrand].Set(.9, .7, .2);
80  colors[eCoil].Set(.3, .9, .9);
81 
82  colors[ePositive].Set(.2, .3, 1.0);
83  colors[eNegative].Set(.9, .2, .2);
84  colors[eNeutral].Set(.6, .6, .6);
85 
86  colors[eNuc_A].Set(.1, .9, .2);
87  colors[eNuc_T_U].Set(.9, .1, .2);
88  colors[eNuc_C].Set(.1, .2, 1.0);
89  colors[eNuc_G].Set(.85, .7, 0);
90  colors[eNuc_X].Set(.6, .6, .6);
91 
92  colors[eNoDomain].Set(.4, .4, .4);
93  colors[eNoTemperature].Set(.4, .4, .4);
94  colors[eNoHydrophobicity].Set(.4, .4, .4);
95  colors[eUnaligned].Set(.4, .4, .4);
96  colors[eNoCoordinates].Set(.4, .4, .4);
97 
98  // cycles and maps
100  mapColors.resize(eNumColorMaps);
101 
102  // colors for cycle1
103  cycleColors[eCycle1].resize(nCycle1);
104  cycleColors[eCycle1][0].Set(1, 0, 1);
105  cycleColors[eCycle1][1].Set(0, 0, 1);
106  cycleColors[eCycle1][2].Set(139.0/255, 87.0/255, 66.0/255);
107  cycleColors[eCycle1][3].Set(0, 1, .5);
108  cycleColors[eCycle1][4].Set(.7, .7, .7);
109  cycleColors[eCycle1][5].Set(1, 165.0/255, 0);
110  cycleColors[eCycle1][6].Set(1, 114.0/255, 86.0/255);
111  cycleColors[eCycle1][7].Set(0, 1, 0);
112  cycleColors[eCycle1][8].Set(0, 1, 1);
113  cycleColors[eCycle1][9].Set(1, 236.0/255, 139.0/255);
114 
115  // colors for temperature map
117  mapColors[eTemperatureMap][0].Set(0.2, 0.2, 0.7);
118  mapColors[eTemperatureMap][1].Set(0.1, 0.6, 0.2);
119  mapColors[eTemperatureMap][2].Set(0.9, 0.8, 0.2);
120  mapColors[eTemperatureMap][3].Set(0.9, 0.2, 0.2);
121  mapColors[eTemperatureMap][4].Set(0.9, 0.9, 0.9);
122 
123  // colors for hydrophobicity map
125  mapColors[eHydrophobicityMap][0].Set(0.2, 0.2, 0.7);
126  mapColors[eHydrophobicityMap][1].Set(0.2, 0.5, 0.6);
127  mapColors[eHydrophobicityMap][2].Set(0.7, 0.4, 0.3);
128 
129  // colors for conservation map
131  mapColors[eConservationMap][0].Set(0.0, 75.0/255, 1.0);
132  mapColors[eConservationMap][1].Set(1.0, 0.0, 0.0);
133 
134  // colors for rainbow map
136  mapColors[eRainbowMap][0].Set(0.9, 0.1, 0.1);
137  mapColors[eRainbowMap][1].Set(1.0, 0.5, 0.1);
138  mapColors[eRainbowMap][2].Set(0.8, 0.9, 0.1);
139  mapColors[eRainbowMap][3].Set(0.1, 0.9, 0.1);
140  mapColors[eRainbowMap][4].Set(0.1, 0.1, 1.0);
141  mapColors[eRainbowMap][5].Set(0.5, 0.2, 1.0);
142  mapColors[eRainbowMap][6].Set(0.9, 0.2, 0.5);
143 }
144 
145 const Vector& Colors::Get(eColor which) const
146 {
147  if (which >= 0 && which < eNumColors) return colors[which];
148  ERRORMSG("Colors::Get() - bad eColor " << (int) which);
149  return colors[0];
150 }
151 
152 const Vector& Colors::Get(eColorCycle which, unsigned int n) const
153 {
154  if (which >= 0 && which < eNumColorCycles)
155  return cycleColors[which][n % cycleColors[which].size()];
156  ERRORMSG("Colors::Get() - bad eColorCycle " << (int) which);
157  return cycleColors[0][0];
158 }
159 
160 Vector Colors::Get(eColorMap which, double f) const
161 {
162  if (which >= 0 && which < eNumColorMaps && f >= 0.0 && f <= 1.0) {
163  const vector < Vector >& colorMap = mapColors[which];
164  if (f == 1.0) return colorMap[colorMap.size() - 1];
165  double bin = 1.0 / (colorMap.size() - 1);
166  unsigned int low = (unsigned int) (f / bin);
167  double fraction = fmod(f, bin) / bin;
168  const Vector &color1 = colorMap[low], &color2 = colorMap[low + 1];
169  return (color1 + fraction * (color2 - color1));
170  }
171  ERRORMSG("Colors::Get() - bad eColorMap " << (int) which << " at " << f);
172  return mapColors[0][0];
173 }
174 
175 const Vector* Colors::Get(eColorMap which, unsigned int index) const
176 {
177  if (which < eNumColorMaps && index < mapColors[which].size())
178  return &(mapColors[which][index]);
179  else
180  return NULL;
181 }
182 
183 END_SCOPE(Cn3D)
#define static
static const unsigned int nHydrophobicityMap
@ eNumColorMaps
@ eTemperatureMap
@ eHydrophobicityMap
@ eConservationMap
std::vector< std::vector< Vector > > cycleColors
static const unsigned int nTemperatureMap
@ eHighlight
Definition: cn3d_colors.hpp:60
@ eUnaligned
Definition: cn3d_colors.hpp:86
@ eNoHydrophobicity
Definition: cn3d_colors.hpp:85
@ eNoCoordinates
Definition: cn3d_colors.hpp:87
@ eNumColors
Definition: cn3d_colors.hpp:89
@ eNoTemperature
Definition: cn3d_colors.hpp:84
@ eGeometryViolation
Definition: cn3d_colors.hpp:62
@ eMergeFail
Definition: cn3d_colors.hpp:61
@ eMarkBlock
Definition: cn3d_colors.hpp:63
static const unsigned int nRainbowMap
static const unsigned int nConservationMap
@ eNumColorCycles
Definition: cn3d_colors.hpp:97
std::vector< std::vector< Vector > > mapColors
static const unsigned int nCycle1
Definition: cn3d_colors.hpp:99
const Vector & Get(eColor which) const
Vector colors[eNumColors]
Colors(void)
Definition: cn3d_colors.cpp:70
void Set(double xs, double ys, double zs)
Definition: vector_math.hpp:62
static const Colors colors
Definition: cn3d_colors.cpp:50
const Colors * GlobalColors(void)
Definition: cn3d_colors.cpp:52
USING_NCBI_SCOPE
Definition: cn3d_colors.cpp:44
#define ERRORMSG(stream)
Definition: cn3d_tools.hpp:86
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define NULL
Definition: ncbistd.hpp:225
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
yy_size_t n
const struct ncbi::grid::netcache::search::fields::SIZE size
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
#define const
Definition: zconf.h:232
Modified on Thu Jul 04 15:53:28 2024 by modify_doxy.py rev. 669887