VTK  9.2.5
vtkMoleculeMapper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMoleculeMapper.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
46 #ifndef vtkMoleculeMapper_h
47 #define vtkMoleculeMapper_h
48 
49 #include "vtkDomainsChemistryModule.h" // For export macro
50 #include "vtkMapper.h"
51 #include "vtkNew.h" // For vtkNew
52 
53 class vtkActor;
54 class vtkGlyph3DMapper;
55 class vtkIdTypeArray;
56 class vtkMolecule;
57 class vtkPeriodicTable;
58 class vtkPolyData;
59 class vtkPolyDataMapper;
60 class vtkRenderer;
61 class vtkSelection;
62 class vtkSphereSource;
63 class vtkTrivialProducer;
64 
65 class VTKDOMAINSCHEMISTRY_EXPORT vtkMoleculeMapper : public vtkMapper
66 {
67 public:
69  vtkTypeMacro(vtkMoleculeMapper, vtkMapper);
70  void PrintSelf(ostream& os, vtkIndent indent) override;
71 
73 
79 
92 
105 
118 
134 
136 
139  vtkGetMacro(RenderAtoms, bool);
140  vtkSetMacro(RenderAtoms, bool);
141  vtkBooleanMacro(RenderAtoms, bool);
143 
145 
148  vtkGetMacro(RenderBonds, bool);
149  vtkSetMacro(RenderBonds, bool);
150  vtkBooleanMacro(RenderBonds, bool);
152 
154 
158  vtkGetMacro(RenderLattice, bool);
159  vtkSetMacro(RenderLattice, bool);
160  vtkBooleanMacro(RenderLattice, bool);
162 
163  enum
164  {
165  CovalentRadius = 0,
168  CustomArrayRadius
169  };
170 
172 
177  vtkGetMacro(AtomicRadiusType, int);
178  vtkSetMacro(AtomicRadiusType, int);
180  void SetAtomicRadiusTypeToCovalentRadius() { this->SetAtomicRadiusType(CovalentRadius); }
181  void SetAtomicRadiusTypeToVDWRadius() { this->SetAtomicRadiusType(VDWRadius); }
182  void SetAtomicRadiusTypeToUnitRadius() { this->SetAtomicRadiusType(UnitRadius); }
183  void SetAtomicRadiusTypeToCustomArrayRadius() { this->SetAtomicRadiusType(CustomArrayRadius); }
185 
187 
192  vtkGetMacro(AtomicRadiusScaleFactor, float);
193  vtkSetMacro(AtomicRadiusScaleFactor, float);
195 
197 
201  vtkGetMacro(UseMultiCylindersForBonds, bool);
202  vtkSetMacro(UseMultiCylindersForBonds, bool);
203  vtkBooleanMacro(UseMultiCylindersForBonds, bool);
205 
206  enum
207  {
208  SingleColor = 0,
209  DiscreteByAtom
210  };
211 
213 
223  vtkGetMacro(BondColorMode, int);
224  vtkSetClampMacro(BondColorMode, int, SingleColor, DiscreteByAtom);
225  void SetBondColorModeToSingleColor() { this->SetBondColorMode(SingleColor); }
226  void SetBondColorModeToDiscreteByAtom() { this->SetBondColorMode(DiscreteByAtom); }
229 
231 
240  vtkGetMacro(AtomColorMode, int);
241  vtkSetClampMacro(AtomColorMode, int, SingleColor, DiscreteByAtom);
243 
245 
249  vtkGetVector3Macro(AtomColor, unsigned char);
250  vtkSetVector3Macro(AtomColor, unsigned char);
252 
254 
258  vtkGetVector3Macro(BondColor, unsigned char);
259  vtkSetVector3Macro(BondColor, unsigned char);
261 
263 
266  vtkGetMacro(BondRadius, float);
267  vtkSetMacro(BondRadius, float);
269 
271 
275  vtkGetVector3Macro(LatticeColor, unsigned char);
276  vtkSetVector3Macro(LatticeColor, unsigned char);
278 
280 
285  vtkSelection* selection, vtkIdTypeArray* atomIds, vtkIdTypeArray* bondIds);
286  virtual void GetSelectedAtoms(vtkSelection* selection, vtkIdTypeArray* atomIds)
287  {
288  this->GetSelectedAtomsAndBonds(selection, atomIds, nullptr);
289  }
290  virtual void GetSelectedBonds(vtkSelection* selection, vtkIdTypeArray* bondIds)
291  {
292  this->GetSelectedAtomsAndBonds(selection, nullptr, bondIds);
293  }
295 
297 
300  void Render(vtkRenderer*, vtkActor*) override;
302  double* GetBounds() override;
303  void GetBounds(double bounds[6]) override { vtkAbstractMapper3D::GetBounds(bounds); }
305  bool GetSupportsSelection() override { return true; }
307 
309 
313  vtkGetStringMacro(AtomicRadiusArrayName);
314  vtkSetStringMacro(AtomicRadiusArrayName);
316 
321  virtual void SetMapScalars(bool map);
322 
326  vtkPeriodicTable* GetPeriodicTable() { return this->PeriodicTable; }
327 
328 protected:
330  ~vtkMoleculeMapper() override;
331 
333 
341  unsigned char AtomColor[3];
343 
345 
351  float BondRadius;
352  unsigned char BondColor[3];
354 
356 
360  void GlyphRender(vtkRenderer* ren, vtkActor* act);
361 
363 
371  virtual void UpdateGlyphPolyData();
372  virtual void UpdateAtomGlyphPolyData();
373  virtual void UpdateBondGlyphPolyData();
375 
377 
383 
384  unsigned char LatticeColor[3];
387  virtual void UpdateLatticePolyData();
388 
393 
394 private:
395  vtkMoleculeMapper(const vtkMoleculeMapper&) = delete;
396  void operator=(const vtkMoleculeMapper&) = delete;
397 };
398 
399 #endif
virtual double * GetBounds()=0
Return bounding box (array of six doubles) of data expressed as (xmin,xmax, ymin,ymax,...
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:161
vtkGlyph3D on the GPU.
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:119
Store vtkAlgorithm input/output information.
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:177
Mapper that draws vtkMolecule objects.
virtual void GetSelectedBonds(vtkSelection *selection, vtkIdTypeArray *bondIds)
Extract the ids atoms and/or bonds rendered by this molecule from a vtkSelection object.
virtual void GetSelectedAtoms(vtkSelection *selection, vtkIdTypeArray *atomIds)
Extract the ids atoms and/or bonds rendered by this molecule from a vtkSelection object.
virtual void SetMapScalars(bool map)
Helper method to set ScalarMode on both AtomGlyphMapper and BondGlyphMapper.
void SetBondColorModeToDiscreteByAtom()
Get/Set the method by which bonds are colored.
void SetAtomicRadiusTypeToUnitRadius()
Get/Set the type of radius used to generate the atoms.
bool GlyphDataInitialized
Cached variables and update methods.
vtkNew< vtkGlyph3DMapper > AtomGlyphMapper
Internal mappers.
bool RenderAtoms
Customize atom rendering.
void SetAtomicRadiusTypeToVDWRadius()
Get/Set the type of radius used to generate the atoms.
void UseLiquoriceStickSettings()
Set ivars to default liquorice stick settings.
vtkNew< vtkPeriodicTable > PeriodicTable
Periodic table for lookups.
float AtomicRadiusScaleFactor
Customize atom rendering.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPeriodicTable * GetPeriodicTable()
Accessor to internal structure.
virtual void GetSelectedAtomsAndBonds(vtkSelection *selection, vtkIdTypeArray *atomIds, vtkIdTypeArray *bondIds)
Extract the ids atoms and/or bonds rendered by this molecule from a vtkSelection object.
float BondRadius
Customize bond rendering.
~vtkMoleculeMapper() override
int AtomicRadiusType
Customize atom rendering.
bool RenderBonds
Customize bond rendering.
void Render(vtkRenderer *, vtkActor *) override
Reimplemented from base class.
void SetAtomicRadiusTypeToCustomArrayRadius()
Get/Set the type of radius used to generate the atoms.
void SetAtomicRadiusTypeToCovalentRadius()
Get/Set the type of radius used to generate the atoms.
char * AtomicRadiusArrayName
Customize atom rendering.
int FillInputPortInformation(int port, vtkInformation *info) override
Reimplemented from base class.
double * GetBounds() override
Reimplemented from base class.
virtual void UpdateAtomGlyphPolyData()
Cached variables and update methods.
int AtomColorMode
Customize atom rendering.
virtual void UpdateGlyphPolyData()
Cached variables and update methods.
vtkNew< vtkPolyData > BondGlyphPolyData
Cached variables and update methods.
vtkNew< vtkTrivialProducer > BondGlyphPointOutput
Cached variables and update methods.
static vtkMoleculeMapper * New()
void UseFastSettings()
Set ivars to use fast settings that may be useful for rendering extremely large molecules where the o...
void SetBondColorModeToSingleColor()
Get/Set the method by which bonds are colored.
const char * GetBondColorModeAsString()
Get/Set the method by which bonds are colored.
bool UseMultiCylindersForBonds
Customize bond rendering.
vtkMolecule * GetInput()
Get/Set the input vtkMolecule.
bool GetSupportsSelection() override
Reimplemented from base class.
vtkNew< vtkGlyph3DMapper > BondGlyphMapper
Internal mappers.
void SetInputData(vtkMolecule *in)
Get/Set the input vtkMolecule.
virtual void UpdateLatticePolyData()
void UseBallAndStickSettings()
Set ivars to default ball-and-stick settings.
const char * GetAtomicRadiusTypeAsString()
Get/Set the type of radius used to generate the atoms.
void GlyphRender(vtkRenderer *ren, vtkActor *act)
Internal render methods.
int BondColorMode
Customize bond rendering.
void ReleaseGraphicsResources(vtkWindow *) override
Reimplemented from base class.
void UseVDWSpheresSettings()
Set ivars to default van der Waals spheres settings.
vtkNew< vtkTrivialProducer > AtomGlyphPointOutput
Cached variables and update methods.
void GetBounds(double bounds[6]) override
Reimplemented from base class.
virtual void UpdateBondGlyphPolyData()
Cached variables and update methods.
vtkNew< vtkPolyDataMapper > LatticeMapper
vtkNew< vtkPolyData > LatticePolyData
vtkNew< vtkPolyData > AtomGlyphPolyData
Cached variables and update methods.
class describing a molecule
Definition: vtkMolecule.h:114
Access to information about the elements.
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:200
abstract specification for renderers
Definition: vtkRenderer.h:182
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:169
create a polygonal sphere centered at the origin
Producer for stand-alone data objects.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453