BALL  1.5.0
colorProcessor.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 // $Id: colorProcessor.h,v 1.32.18.1 2007/03/25 21:26:06 oliver Exp $
5 //
6 
7 #ifndef BALL_VIEW_MODELS_COLORPROCESSOR_H
8 #define BALL_VIEW_MODELS_COLORPROCESSOR_H
9 
10 #ifndef BALL_CONCEPT_PROCESSOR_H
11 # include <BALL/CONCEPT/processor.h>
12 #endif
13 
14 #ifndef BALL_VIEW_KERNEL_GEOMETRICOBJECT_H
16 #endif
17 
18 #ifndef BALL_DATATYPE_HASHGRID_H
19 # include <BALL/DATATYPE/hashGrid.h>
20 #endif
21 
22 #ifndef BALL_VIEW_KERNEL_COMMON_H
23 # include <BALL/VIEW/KERNEL/common.h>
24 #endif
25 
26 namespace BALL
27 {
28  class Atom;
29 
30  namespace VIEW
31  {
32  class Mesh;
33 
51  : public UnaryProcessor<GeometricObject*>
52 {
53  public:
54 
56 
57 
58  typedef HashSet<const Composite*> CompositeSet;
59 
61  typedef HashGrid3<const Atom*> AtomGrid;
62 
64  typedef HashGridBox3<const Atom*> AtomBox;
65 
68 
70  ColorProcessor(const ColorProcessor& color_calculator);
71 
73  virtual ~ColorProcessor();
74 
80  virtual void clear();
81 
83  void set(const ColorProcessor& color_calculator);
84 
86  virtual bool start();
87 
91  const ColorProcessor& operator = (const ColorProcessor& color_calculator);
92 
101  bool updateAlwaysNeeded() { return update_always_needed_;};
102 
105  void setDefaultColor(const ColorRGBA& color);
106 
109  const ColorRGBA& getDefaultColor() const
110  {return default_color_;}
111 
114  virtual Processor::Result operator() (GeometricObject*& object);
115 
122  virtual void getColor(const Composite& composite, ColorRGBA& color_to_be_set);
123 
126  { return transparency_;}
127 
131  virtual void setTransparency(Size value);
132 
136  void setComposites(const std::list<const Composite*>* composites);
137 
139  const std::list<const Composite*>* getComposites()
140  { return composites_;}
141 
143  void clearAtomGrid();
144 
146  void setAdditionalGridDistance(float distance)
147  { additional_grid_distance_ = distance;}
148 
151  { return additional_grid_distance_;}
152 
154  void setMinGridSpacing(float spacing) {min_spacing_ = spacing;}
155 
158  { return atom_grid_;}
159 
166  virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
167 
169  void setModelType(ModelType type) {model_type_ = type;}
170 
171  //_ Create the threedimensional grid from the CompositeSet, or a given Composite
172  virtual void createAtomGrid(const Composite* from_mesh = 0);
173 
175  const Atom* getClosestItem(const Vector3& v) const;
176 
177  protected:
178 
179  //_ Colorize the mesh with the computed grid.
180  virtual void colorMeshFromGrid_(Mesh& mesh);
181 
182  //_
183  virtual bool canUseMeshShortcut_(const Composite&) { return false;}
184 
186  //_ a color that will be used if no other color can be calculated.
188  //_ for speedup, we dont have to set transparency each time we color a geometric object
191 
192  const std::list<const Composite*>* composites_;
193 
200 };
201 
202 
207  : public ColorProcessor
208 {
209  public:
210 
212  enum Mode
213  {
215  USE_OUTSIDE_COLOR = 0,
216 
219 
221  NO_OUTSIDE_COLORS
222  };
223 
224 
226 
227 
229 
232 
234  virtual bool start();
235 
237  void setMode(Mode mode) { mode_ = mode;}
238 
240  Mode getMode() const { return mode_;}
241 
243  vector<ColorRGBA>& getColors() { return colors_;}
244 
246  const vector<ColorRGBA>& getColors() const { return colors_;}
247 
249  void setColors(const vector<ColorRGBA>& colors) { colors_ = colors;}
250 
252  void setMinColor(const ColorRGBA& color);
253 
255  void setMaxColor(const ColorRGBA& color);
256 
258  const ColorRGBA& getMinColor() const;
259 
261  const ColorRGBA& getMaxColor() const;
262 
264  void setMaxValue(float value) {max_value_ = value;}
265 
267  float getMaxValue() const { return max_value_;}
268 
270  void setMinValue(float value) { min_value_ = value;}
271 
273  float getMinValue() const { return min_value_;}
274 
278  virtual void interpolateColor(float value, ColorRGBA& color_to_be_set);
279 
280  protected:
281 
282  // out of range colors
284  max_color_;
285 
286  // standard colors
287  vector<ColorRGBA> colors_;
288 
290 
291  float max_value_;
292  float min_value_;
293 
294  // value distance between two colors
295  float x_;
296 };
297 
298 } } // namespaces
299 
300 #endif // BALL_VIEW_MODELS_COLORPROCESSOR_H
geometricObject.h
BALL::VIEW::InterpolateColorProcessor::Mode
Mode
Definition: colorProcessor.h:212
BALL::VIEW::InterpolateColorProcessor::setColors
void setColors(const vector< ColorRGBA > &colors)
Definition: colorProcessor.h:249
BALL::VIEW::InterpolateColorProcessor::getMinValue
float getMinValue() const
Definition: colorProcessor.h:273
BALL::VIEW::ColorProcessor::last_composite_of_grid_
const Composite * last_composite_of_grid_
Definition: colorProcessor.h:196
BALL_VIEW_EXPORT
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
BALL::VIEW::InterpolateColorProcessor::setMode
void setMode(Mode mode)
Definition: colorProcessor.h:237
BALL::HashSet
Definition: hashSet.h:45
BALL::VIEW::InterpolateColorProcessor::setMaxValue
void setMaxValue(float value)
Definition: colorProcessor.h:264
BALL::VIEW::InterpolateColorProcessor::DEFAULT_COLOR_FOR_OUTSIDE_COLORS
Definition: colorProcessor.h:218
BALL::VIEW::InterpolateColorProcessor::getColors
vector< ColorRGBA > & getColors()
Definition: colorProcessor.h:243
BALL::TVector3< float >
BALL_SIZE_TYPE
BALL::VIEW::ModelType
ModelType
Definition: VIEW/KERNEL/common.h:165
BALL::VIEW::ColorProcessor::getAdditionalGridDistance
float getAdditionalGridDistance() const
Definition: colorProcessor.h:150
BALL::VIEW::InterpolateColorProcessor::mode_
Mode mode_
Definition: colorProcessor.h:289
BALL::Atom
Definition: atom.h:87
BALL::VIEW::InterpolateColorProcessor::x_
float x_
Definition: colorProcessor.h:295
BALL::VIEW::Mesh
Definition: mesh.h:38
BALL::VIEW::ColorProcessor::default_color_
ColorRGBA default_color_
Definition: colorProcessor.h:187
BALL::VIEW::InterpolateColorProcessor::min_color_
ColorRGBA min_color_
Definition: colorProcessor.h:283
BALL
Definition: constants.h:12
BALL::VIEW::ColorProcessor::setModelType
void setModelType(ModelType type)
Definition: colorProcessor.h:169
BALL::VIEW::InterpolateColorProcessor
Definition: colorProcessor.h:206
BALL::VIEW::InterpolateColorProcessor::getColors
const vector< ColorRGBA > & getColors() const
Definition: colorProcessor.h:246
BALL::HashGridBox3
Definition: hashGrid.h:54
BALL::VIEW::ColorProcessor::min_spacing_
float min_spacing_
Definition: colorProcessor.h:198
BALL::PDB::Atom
char Atom[5]
Definition: PDBdefs.h:257
hashGrid.h
BALL::VIEW::ColorProcessor::additional_grid_distance_
float additional_grid_distance_
Definition: colorProcessor.h:197
BALL::VIEW::ColorProcessor::update_always_needed_
bool update_always_needed_
Definition: colorProcessor.h:185
BALL::VIEW::ColorProcessor::getComposites
const std::list< const Composite * > * getComposites()
Return a pointer to the Composites.
Definition: colorProcessor.h:139
BALL::VIEW::ColorProcessor::atom_grid_
AtomGrid atom_grid_
Definition: colorProcessor.h:194
BALL::VIEW::ColorProcessor::getAtomGrid
AtomGrid & getAtomGrid()
Definition: colorProcessor.h:157
BALL::VIEW::ColorProcessor::getTransparency
Size getTransparency() const
Definition: colorProcessor.h:125
BALL::HashGrid3
Three-dimensional Hash Grid Class.
Definition: hashGrid.h:38
BALL::VIEW::InterpolateColorProcessor::setMinValue
void setMinValue(float value)
Definition: colorProcessor.h:270
BALL::VIEW::ColorRGBA
Definition: colorRGBA.h:31
BALL::VIEW::InterpolateColorProcessor::getMode
Mode getMode() const
Definition: colorProcessor.h:240
BALL::VIEW::InterpolateColorProcessor::colors_
vector< ColorRGBA > colors_
Definition: colorProcessor.h:287
BALL::VIEW::InterpolateColorProcessor::min_value_
float min_value_
Definition: colorProcessor.h:292
processor.h
BALL::VIEW::ColorProcessor
Definition: colorProcessor.h:50
BALL::VIEW::ColorProcessor::model_type_
ModelType model_type_
Definition: colorProcessor.h:195
BALL::UnaryProcessor
Definition: processor.h:58
BALL::VIEW::ColorProcessor::setAdditionalGridDistance
void setAdditionalGridDistance(float distance)
Definition: colorProcessor.h:146
BALL::VIEW::ColorProcessor::canUseMeshShortcut_
virtual bool canUseMeshShortcut_(const Composite &)
Definition: colorProcessor.h:183
BALL::VIEW::ColorProcessor::selection_color_
ColorRGBA selection_color_
Definition: colorProcessor.h:189
BALL::Composite
Definition: composite.h:71
BALL::VIEW::ColorProcessor::transparency_
Size transparency_
Definition: colorProcessor.h:190
BALL::VIEW::GeometricObject
Definition: geometricObject.h:36
BALL::Processor::Result
int Result
Definition: processor.h:36
BALL_CREATE
#define BALL_CREATE(name)
Definition: create.h:62
BALL::VIEW::ColorProcessor::composites_
const std::list< const Composite * > * composites_
Definition: colorProcessor.h:192
BALL::VIEW::InterpolateColorProcessor::getMaxValue
float getMaxValue() const
Definition: colorProcessor.h:267
BALL::VIEW::getColor
BALL_VIEW_EXPORT ColorRGBA getColor(const QLabel *label)
BALL::VIEW::ColorProcessor::setMinGridSpacing
void setMinGridSpacing(float spacing)
Definition: colorProcessor.h:154
common.h
BALL::VIEW::ColorProcessor::getDefaultColor
const ColorRGBA & getDefaultColor() const
Definition: colorProcessor.h:109
BALL::VIEW::InterpolateColorProcessor::max_value_
float max_value_
Definition: colorProcessor.h:291