UnityMol  0.9.6-875
UnityMol viewer / In developement
AtomSphereStyle.cs
Go to the documentation of this file.
1 using System.Collections.Generic;
66 
67 
68 namespace Molecule.View.DisplayAtom
69 {
70 
71  using UnityEngine;
72  using System.Collections;
73  using Molecule.Model;
74  using Molecule.Control;
75  using UI;
76  public class AtomSphereStyle : IAtomStyle
77  {
78  public static ArrayList atomOrderList=new ArrayList();
79 
81 
82  public static GameObject AtomSphereParent = new GameObject("AtomSphereParent");
83 
84  public AtomSphereStyle()
85  {
86 
87  }
88 
89 
90  public void DisplayAtoms(UIData.AtomType type_atom, bool force_display = false)
91  {
92  UIData.shadow = true;
93  if(type_atom != UIData.AtomType.particleball || !UIData.isParticlesInitialized ||force_display)
94  {
95  //if(!UIData.isSphereLoaded){
96  if(AtomSphereParent == null)
97  AtomSphereParent = new GameObject("AtomSphereParent");
98 
99  if(MoleculeModel.atoms != null)
100  {
101  MoleculeModel.atoms.Clear();
102  MoleculeModel.atoms=null;
103  }
104  MoleculeModel.atoms=new ArrayList();
105 
106  atomtype = type_atom;
107 
108  if(atomtype==UIData.AtomType.sphere)
109  {
110 
112  DisplayAtomMethodBySphere(MoleculeModel.CaSplineList, MoleculeModel.CaSplineTypeList);}
113  else
114  DisplayAtomMethodBySphere(MoleculeModel.atomsLocationlist, MoleculeModel.atomsTypelist);
115  }
116  GameObject sphereManagerObj = GameObject.FindGameObjectWithTag("SphereManager");
117  SphereManager sphereManager = sphereManagerObj.GetComponent<SphereManager>();
118  sphereManager.Init();
119  UIData.isSphereLoaded = true;
120  //}
121  }
122  }
123 
124  private void DisplayAtomMethodBySphere(IList alist, IList typelist) // used to be public
125  {
126  Vector3 vl=new Vector3();
127  MoleculeModel.atomsnumber=alist.Count;
128  List<GameObject> gameObjectList = new List<GameObject>();
129 
130  for(int i=0;i<alist.Count;i++)
131  {
132 
133  GameObject o;
134 
135  float [] a=alist[i] as float[];
136  AtomModel aModel = (AtomModel)typelist[i];
137  vl.x=a[0];
138  vl.y=a[1];
139  vl.z=a[2];
140  BallUpdateSphere comp1;
141 
142  o = GameObject.CreatePrimitive(PrimitiveType.Sphere);
143  gameObjectList.Add(o);
144  o.transform.position = vl;
145  MoleculeModel.atoms.Add(o);
146  o.transform.parent = AtomSphereParent.transform;
147  comp1 = o.AddComponent<BallUpdateSphere>();
148  comp1.rayon = aModel.radius*2;
149  comp1.number=i;
150  comp1.enabled = true;
151  comp1.atomcolor = aModel.baseColor; // Why is this suddenly necessary???
152  o.transform.GetComponent<Renderer>().material.SetColor("_Color", aModel.baseColor);
153  comp1.SetRayonFactor(aModel.scale/100);
154  o.tag=aModel.type;
155 
156  }
157  SphereManager.sphereGameObjects = gameObjectList.ToArray();
158  }
159 
160 
161  }
162 }
virtual void SetRayonFactor(float rf)
Definition: BallUpdate.cs:97
static bool secondarystruct
Switch between all atoms and C-alpha trace or BFactor secondary structure representation.
Definition: UIData.cs:176
void DisplayAtomMethodBySphere(IList alist, IList typelist)
static List< AtomModel > atomsTypelist
The type of each atom.
Color atomcolor
Definition: BallUpdate.cs:86
void DisplayAtoms(UIData.AtomType type_atom, bool force_display=false)
long number
Definition: BallUpdate.cs:84
float rayon
Definition: BallUpdate.cs:78
static List< float[]> CaSplineList
The coordinates of each Carbon alpha in the CA-Spline.
!WiP Includes FLAGS of GUI.
Definition: UIData.cs:78
static bool isParticlesInitialized
Definition: UIData.cs:101
override void Init()
Initializes this sphere manager.
static GameObject[] sphereGameObjects
static bool isSphereLoaded
Definition: UIData.cs:104
static bool shadow
Definition: UIData.cs:198
static List< AtomModel > CaSplineTypeList
Type of each carbon alpha in the CA-Spline.
Definition: GUIDisplay.cs:66
static List< float[]> atomsLocationlist
The coordinates of each atom.