VTK
dox/Domains/Chemistry/vtkMoleculeMapper.h
Go to the documentation of this file.
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 "vtkDomainsChemistryModule.h" // For export macro
00030 #include "vtkMapper.h"
00031 #include "vtkNew.h" // For vtkNew
00032 
00033 class vtkActor;
00034 class vtkGlyph3DMapper;
00035 class vtkIdTypeArray;
00036 class vtkMolecule;
00037 class vtkPeriodicTable;
00038 class vtkPolyData;
00039 class vtkRenderer;
00040 class vtkSelection;
00041 class vtkSphereSource;
00042 class vtkTrivialProducer;
00043 
00044 class VTKDOMAINSCHEMISTRY_EXPORT vtkMoleculeMapper : public vtkMapper
00045 {
00046 public:
00047   static vtkMoleculeMapper *New();
00048   vtkTypeMacro(vtkMoleculeMapper,vtkMapper);
00049   void PrintSelf(ostream& os, vtkIndent indent);
00050 
00052 
00053   void SetInputData(vtkMolecule *in);
00054   vtkMolecule *GetInput();
00056 
00062   void UseBallAndStickSettings();
00063 
00069   void UseVDWSpheresSettings();
00070 
00076   void UseLiquoriceStickSettings();
00077 
00085   void UseFastSettings();
00086 
00088 
00089   vtkGetMacro(RenderAtoms, bool);
00090   vtkSetMacro(RenderAtoms, bool);
00091   vtkBooleanMacro(RenderAtoms, bool);
00093 
00095 
00096   vtkGetMacro(RenderBonds, bool);
00097   vtkSetMacro(RenderBonds, bool);
00098   vtkBooleanMacro(RenderBonds, bool);
00100 
00101   enum {
00102     CovalentRadius = 0,
00103     VDWRadius,
00104     UnitRadius
00105   };
00106 
00108 
00110   vtkGetMacro(AtomicRadiusType, int);
00111   vtkSetMacro(AtomicRadiusType, int);
00112   const char * GetAtomicRadiusTypeAsString();
00113   void SetAtomicRadiusTypeToCovalentRadius()
00114   {
00115     this->SetAtomicRadiusType(CovalentRadius);
00116   }
00117   void SetAtomicRadiusTypeToVDWRadius()
00118   {
00119     this->SetAtomicRadiusType(VDWRadius);
00120   }
00121   void SetAtomicRadiusTypeToUnitRadius()
00122   {
00123     this->SetAtomicRadiusType(UnitRadius);
00124   }
00126 
00128 
00130   vtkGetMacro(AtomicRadiusScaleFactor, float);
00131   vtkSetMacro(AtomicRadiusScaleFactor, float);
00133 
00135 
00137   vtkGetMacro(UseMultiCylindersForBonds, bool);
00138   vtkSetMacro(UseMultiCylindersForBonds, bool);
00139   vtkBooleanMacro(UseMultiCylindersForBonds, bool);
00141 
00142   enum {
00143     SingleColor = 0,
00144     DiscreteByAtom
00145   };
00146 
00148 
00153   vtkGetMacro(BondColorMode, int);
00154   vtkSetMacro(BondColorMode, int);
00155   const char * GetBondColorModeAsString();
00156   void SetBondColorModeToSingleColor()
00157   {
00158     this->SetBondColorMode(SingleColor);
00159   }
00160   void SetBondColorModeToDiscreteByAtom()
00161   {
00162     this->SetBondColorMode(DiscreteByAtom);
00163   }
00165 
00167 
00169   vtkGetVector3Macro(BondColor, unsigned char);
00170   vtkSetVector3Macro(BondColor, unsigned char);
00172 
00174 
00175   vtkGetMacro(BondRadius, float);
00176   vtkSetMacro(BondRadius, float);
00178 
00180 
00182   virtual void GetSelectedAtomsAndBonds(vtkSelection *selection,
00183                                         vtkIdTypeArray *atomIds,
00184                                         vtkIdTypeArray *bondIds);
00185   virtual void GetSelectedAtoms(vtkSelection *selection,
00186                                 vtkIdTypeArray *atomIds)
00187   {
00188     this->GetSelectedAtomsAndBonds(selection, atomIds, NULL);
00189   }
00190   virtual void GetSelectedBonds(vtkSelection *selection,
00191                                 vtkIdTypeArray *bondIds)
00192   {
00193     this->GetSelectedAtomsAndBonds(selection, NULL, bondIds);
00194   }
00196 
00198 
00199   virtual void Render(vtkRenderer *, vtkActor *);
00200   virtual void ReleaseGraphicsResources(vtkWindow *);
00201   double * GetBounds();
00202   void GetBounds(double bounds[6]) { vtkAbstractMapper3D::GetBounds(bounds); }
00203   virtual int FillInputPortInformation(int port, vtkInformation* info);
00204   virtual bool GetSupportsSelection() {return true;}
00206 
00207 protected:
00208   vtkMoleculeMapper();
00209   ~vtkMoleculeMapper();
00210 
00212 
00213   bool RenderAtoms;
00214   int AtomicRadiusType;
00215   float AtomicRadiusScaleFactor;
00217 
00219 
00220   bool RenderBonds;
00221   int BondColorMode;
00222   bool UseMultiCylindersForBonds;
00223   float BondRadius;
00224   unsigned char BondColor[3];
00226 
00228   void GlyphRender(vtkRenderer *ren, vtkActor *act);
00229 
00231 
00232   vtkNew<vtkPolyData> AtomGlyphPolyData;
00233   vtkNew<vtkTrivialProducer> AtomGlyphPointOutput;
00234   vtkNew<vtkPolyData> BondGlyphPolyData;
00235   vtkNew<vtkTrivialProducer> BondGlyphPointOutput;
00236   bool GlyphDataInitialized;
00237   void UpdateGlyphPolyData();
00238   void UpdateAtomGlyphPolyData();
00239   void UpdateBondGlyphPolyData();
00241 
00243 
00244   vtkNew<vtkGlyph3DMapper> AtomGlyphMapper;
00245   vtkNew<vtkGlyph3DMapper> BondGlyphMapper;
00247 
00249   vtkNew<vtkPeriodicTable> PeriodicTable;
00250 
00251 private:
00252   vtkMoleculeMapper(const vtkMoleculeMapper&);  // Not implemented.
00253   void operator=(const vtkMoleculeMapper&);  // Not implemented.
00254 };
00255 
00256 #endif