VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkMoleculeMapper.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00026 #ifndef __vtkMoleculeMapper_h 00027 #define __vtkMoleculeMapper_h 00028 00029 #include "vtkMapper.h" 00030 #include "vtkNew.h" // For vtkNew 00031 00032 class vtkActor; 00033 class vtkGlyph3DMapper; 00034 class vtkIdTypeArray; 00035 class vtkMolecule; 00036 class vtkPeriodicTable; 00037 class vtkPolyData; 00038 class vtkRenderer; 00039 class vtkSelection; 00040 class vtkSphereSource; 00041 class vtkTrivialProducer; 00042 00043 class VTK_CHEMISTRY_EXPORT vtkMoleculeMapper : public vtkMapper 00044 { 00045 public: 00046 static vtkMoleculeMapper *New(); 00047 vtkTypeMacro(vtkMoleculeMapper,vtkMapper); 00048 void PrintSelf(ostream& os, vtkIndent indent); 00049 00051 00052 void SetInput(vtkMolecule *in); 00053 vtkMolecule *GetInput(); 00055 00061 void UseBallAndStickSettings(); 00062 00068 void UseVDWSpheresSettings(); 00069 00075 void UseLiquoriceStickSettings(); 00076 00084 void UseFastSettings(); 00085 00087 00088 vtkGetMacro(RenderAtoms, bool); 00089 vtkSetMacro(RenderAtoms, bool); 00090 vtkBooleanMacro(RenderAtoms, bool); 00092 00094 00095 vtkGetMacro(RenderBonds, bool); 00096 vtkSetMacro(RenderBonds, bool); 00097 vtkBooleanMacro(RenderBonds, bool); 00099 00100 enum { 00101 CovalentRadius = 0, 00102 VDWRadius, 00103 UnitRadius 00104 }; 00105 00107 00109 vtkGetMacro(AtomicRadiusType, int); 00110 vtkSetMacro(AtomicRadiusType, int); 00111 const char * GetAtomicRadiusTypeAsString(); 00112 void SetAtomicRadiusTypeToCovalentRadius() 00113 { 00114 this->SetAtomicRadiusType(CovalentRadius); 00115 } 00116 void SetAtomicRadiusTypeToVDWRadius() 00117 { 00118 this->SetAtomicRadiusType(VDWRadius); 00119 } 00120 void SetAtomicRadiusTypeToUnitRadius() 00121 { 00122 this->SetAtomicRadiusType(UnitRadius); 00123 } 00125 00127 00129 vtkGetMacro(AtomicRadiusScaleFactor, float); 00130 vtkSetMacro(AtomicRadiusScaleFactor, float); 00132 00134 00136 vtkGetMacro(UseMultiCylindersForBonds, bool); 00137 vtkSetMacro(UseMultiCylindersForBonds, bool); 00138 vtkBooleanMacro(UseMultiCylindersForBonds, bool); 00140 00141 enum { 00142 SingleColor = 0, 00143 DiscreteByAtom 00144 }; 00145 00147 00152 vtkGetMacro(BondColorMode, int); 00153 vtkSetMacro(BondColorMode, int); 00154 const char * GetBondColorModeAsString(); 00155 void SetBondColorModeToSingleColor() 00156 { 00157 this->SetBondColorMode(SingleColor); 00158 } 00159 void SetBondColorModeToDiscreteByAtom() 00160 { 00161 this->SetBondColorMode(DiscreteByAtom); 00162 } 00164 00166 00168 vtkGetVector3Macro(BondColor, unsigned char); 00169 vtkSetVector3Macro(BondColor, unsigned char); 00171 00173 00174 vtkGetMacro(BondRadius, float); 00175 vtkSetMacro(BondRadius, float); 00177 00179 00181 virtual void GetSelectedAtomsAndBonds(vtkSelection *selection, 00182 vtkIdTypeArray *atomIds, 00183 vtkIdTypeArray *bondIds); 00184 virtual void GetSelectedAtoms(vtkSelection *selection, 00185 vtkIdTypeArray *atomIds) 00186 { 00187 this->GetSelectedAtomsAndBonds(selection, atomIds, NULL); 00188 } 00189 virtual void GetSelectedBonds(vtkSelection *selection, 00190 vtkIdTypeArray *bondIds) 00191 { 00192 this->GetSelectedAtomsAndBonds(selection, NULL, bondIds); 00193 } 00195 00197 00198 virtual void Render(vtkRenderer *, vtkActor *); 00199 virtual void ReleaseGraphicsResources(vtkWindow *); 00200 double * GetBounds(); 00201 void GetBounds(double bounds[6]) { vtkAbstractMapper3D::GetBounds(bounds); } 00202 virtual int FillInputPortInformation(int port, vtkInformation* info); 00203 virtual bool GetSupportsSelection() {return true;} 00205 00206 protected: 00207 vtkMoleculeMapper(); 00208 ~vtkMoleculeMapper(); 00209 00211 00212 bool RenderAtoms; 00213 int AtomicRadiusType; 00214 float AtomicRadiusScaleFactor; 00216 00218 00219 bool RenderBonds; 00220 int BondColorMode; 00221 bool UseMultiCylindersForBonds; 00222 float BondRadius; 00223 unsigned char BondColor[3]; 00225 00227 void GlyphRender(vtkRenderer *ren, vtkActor *act); 00228 00230 00231 vtkNew<vtkPolyData> AtomGlyphPolyData; 00232 vtkNew<vtkTrivialProducer> AtomGlyphPointOutput; 00233 vtkNew<vtkPolyData> BondGlyphPolyData; 00234 vtkNew<vtkTrivialProducer> BondGlyphPointOutput; 00235 bool GlyphDataInitialized; 00236 void UpdateGlyphPolyData(); 00237 void UpdateAtomGlyphPolyData(); 00238 void UpdateBondGlyphPolyData(); 00240 00242 00243 vtkNew<vtkGlyph3DMapper> AtomGlyphMapper; 00244 vtkNew<vtkGlyph3DMapper> BondGlyphMapper; 00246 00248 vtkNew<vtkPeriodicTable> PeriodicTable; 00249 00250 private: 00251 vtkMoleculeMapper(const vtkMoleculeMapper&); // Not implemented. 00252 void operator=(const vtkMoleculeMapper&); // Not implemented. 00253 }; 00254 00255 #endif