VTK  9.3.20240418
vtkMoleculeMapper.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
34 #ifndef vtkMoleculeMapper_h
35 #define vtkMoleculeMapper_h
36 
37 #include "vtkDomainsChemistryModule.h" // For export macro
38 #include "vtkMapper.h"
39 #include "vtkNew.h" // For vtkNew
40 
41 VTK_ABI_NAMESPACE_BEGIN
42 class vtkActor;
43 class vtkGlyph3DMapper;
44 class vtkIdTypeArray;
45 class vtkMolecule;
46 class vtkPeriodicTable;
47 class vtkPolyData;
48 class vtkPolyDataMapper;
49 class vtkRenderer;
50 class vtkSelection;
51 class vtkSphereSource;
52 class vtkTrivialProducer;
53 
54 class VTKDOMAINSCHEMISTRY_EXPORT vtkMoleculeMapper : public vtkMapper
55 {
56 public:
58  vtkTypeMacro(vtkMoleculeMapper, vtkMapper);
59  void PrintSelf(ostream& os, vtkIndent indent) override;
60 
62 
68 
81 
94 
107 
123 
125 
128  vtkGetMacro(RenderAtoms, bool);
129  vtkSetMacro(RenderAtoms, bool);
130  vtkBooleanMacro(RenderAtoms, bool);
132 
134 
137  vtkGetMacro(RenderBonds, bool);
138  vtkSetMacro(RenderBonds, bool);
139  vtkBooleanMacro(RenderBonds, bool);
141 
143 
147  vtkGetMacro(RenderLattice, bool);
148  vtkSetMacro(RenderLattice, bool);
149  vtkBooleanMacro(RenderLattice, bool);
151 
152  enum
153  {
154  CovalentRadius = 0,
157  CustomArrayRadius
158  };
159 
161 
166  vtkGetMacro(AtomicRadiusType, int);
167  vtkSetMacro(AtomicRadiusType, int);
169  void SetAtomicRadiusTypeToCovalentRadius() { this->SetAtomicRadiusType(CovalentRadius); }
170  void SetAtomicRadiusTypeToVDWRadius() { this->SetAtomicRadiusType(VDWRadius); }
171  void SetAtomicRadiusTypeToUnitRadius() { this->SetAtomicRadiusType(UnitRadius); }
172  void SetAtomicRadiusTypeToCustomArrayRadius() { this->SetAtomicRadiusType(CustomArrayRadius); }
174 
176 
181  vtkGetMacro(AtomicRadiusScaleFactor, float);
182  vtkSetMacro(AtomicRadiusScaleFactor, float);
184 
186 
190  vtkGetMacro(UseMultiCylindersForBonds, bool);
191  vtkSetMacro(UseMultiCylindersForBonds, bool);
192  vtkBooleanMacro(UseMultiCylindersForBonds, bool);
194 
195  enum
196  {
197  SingleColor = 0,
198  DiscreteByAtom
199  };
200 
202 
212  vtkGetMacro(BondColorMode, int);
213  vtkSetClampMacro(BondColorMode, int, SingleColor, DiscreteByAtom);
214  void SetBondColorModeToSingleColor() { this->SetBondColorMode(SingleColor); }
215  void SetBondColorModeToDiscreteByAtom() { this->SetBondColorMode(DiscreteByAtom); }
218 
220 
229  vtkGetMacro(AtomColorMode, int);
230  vtkSetClampMacro(AtomColorMode, int, SingleColor, DiscreteByAtom);
232 
234 
238  vtkGetVector3Macro(AtomColor, unsigned char);
239  vtkSetVector3Macro(AtomColor, unsigned char);
241 
243 
247  vtkGetVector3Macro(BondColor, unsigned char);
248  vtkSetVector3Macro(BondColor, unsigned char);
250 
252 
255  vtkGetMacro(BondRadius, float);
256  vtkSetMacro(BondRadius, float);
258 
260 
264  vtkGetVector3Macro(LatticeColor, unsigned char);
265  vtkSetVector3Macro(LatticeColor, unsigned char);
267 
269 
274  vtkSelection* selection, vtkIdTypeArray* atomIds, vtkIdTypeArray* bondIds);
275  virtual void GetSelectedAtoms(vtkSelection* selection, vtkIdTypeArray* atomIds)
276  {
277  this->GetSelectedAtomsAndBonds(selection, atomIds, nullptr);
278  }
279  virtual void GetSelectedBonds(vtkSelection* selection, vtkIdTypeArray* bondIds)
280  {
281  this->GetSelectedAtomsAndBonds(selection, nullptr, bondIds);
282  }
284 
286 
289  void Render(vtkRenderer*, vtkActor*) override;
291  double* GetBounds() override;
292  void GetBounds(double bounds[6]) override { Superclass::GetBounds(bounds); }
294  bool GetSupportsSelection() override { return true; }
296 
298 
302  vtkGetStringMacro(AtomicRadiusArrayName);
303  vtkSetStringMacro(AtomicRadiusArrayName);
305 
310  virtual void SetMapScalars(bool map);
311 
315  vtkPeriodicTable* GetPeriodicTable() { return this->PeriodicTable; }
316 
317 protected:
319  ~vtkMoleculeMapper() override;
320 
322 
330  unsigned char AtomColor[3];
332 
334 
340  float BondRadius;
341  unsigned char BondColor[3];
343 
345 
349  void GlyphRender(vtkRenderer* ren, vtkActor* act);
350 
352 
360  virtual void UpdateGlyphPolyData();
361  virtual void UpdateAtomGlyphPolyData();
362  virtual void UpdateBondGlyphPolyData();
364 
366 
372 
373  unsigned char LatticeColor[3];
376  virtual void UpdateLatticePolyData();
377 
382 
383 private:
384  vtkMoleculeMapper(const vtkMoleculeMapper&) = delete;
385  void operator=(const vtkMoleculeMapper&) = delete;
386 };
387 
388 VTK_ABI_NAMESPACE_END
389 #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:151
vtkGlyph3D on the GPU.
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:108
Store vtkAlgorithm input/output information.
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:137
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:84
Access to information about the elements.
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:181
abstract specification for renderers
Definition: vtkRenderer.h:172
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:159
create a polygonal sphere centered at the origin
Producer for stand-alone data objects.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:48
@ info
Definition: vtkX3D.h:376
@ port
Definition: vtkX3D.h:447