UnityMol  0.9.6-875
UnityMol viewer / In developement
AtomParticuleStyle.cs
Go to the documentation of this file.
1 
2 
3 
4 namespace Molecule.View.DisplayAtom
5 {
6 
7  using UnityEngine;
8  using System.Collections;
9  using Molecule.Model;
10  using Molecule.Control;
11  using UI;
13  {
14  public static ArrayList atomOrderList;
15  public static ArrayList atomOrderListArray;
16 
17  private float[] scale=new float[7];
18 
19 
21  {
23  MoleculeModel.p = new Particle[MoleculeModel.CaSplineList.Count];
24  else
25  MoleculeModel.p = new Particle[MoleculeModel.atomsLocationlist.Count];
26 
27 
28  scale[0]=(MoleculeModel.carbonScale)/10;
29  scale[1]=(MoleculeModel.nitrogenScale)/10;
30  scale[2]=(MoleculeModel.oxygenScale)/10;
31  scale[3]=(MoleculeModel.sulphurScale)/10;
32  scale[4]=(MoleculeModel.phosphorusScale)/10;
33  scale[5]=(MoleculeModel.hydrogenScale)/10;
34  scale[6]=(MoleculeModel.unknownScale)/10;
35  }
36 
37 
38  public void DisplayAtoms(UIData.AtomType type_atom, bool force_display = false)
39  {
40  UIData.shadow = false;
41 
42 
43  if(type_atom==UIData.AtomType.particleball) {
44  ArrayList atomListByAxisOrder;
45 
47  atomListByAxisOrder=AtomListByAxisOrder(MoleculeModel.CaSplineList);
48  else
49  atomListByAxisOrder=AtomListByAxisOrder(MoleculeModel.atomsLocationlist);
50 
51  DisplayAtomParticle(atomListByAxisOrder);
52  }
53  else if(type_atom==UIData.AtomType.particleballalphablend) {
54  ArrayList atomListByAxisOrder;
56  atomListByAxisOrder=AtomListByAxisOrder(MoleculeModel.CaSplineList);
57  }
58  else {
59  atomListByAxisOrder=AtomListByAxisOrder(MoleculeModel.atomsLocationlist);
60  }
61  DisplayAtomParticle(atomListByAxisOrder);
62  }
63 
64  GameObject shurikenParticleManagerObj = GameObject.FindGameObjectWithTag("ShurikenParticleManager");
65  ShurikenParticleManager shManager = shurikenParticleManagerObj.GetComponent<ShurikenParticleManager>();
66  shManager.Init();
67 
69 
70  }
71 
72 
73 
74  private void DisplayAtomParticle(ArrayList atomsLocation) {
75  Color c=new Color();
76  Vector3 v=new Vector3();
77 
78  int Number=atomsLocation.Count;
79 
80  for(int k=0;k<Number;k++) {
81  int i = (int)(atomsLocation[k] as float[])[4];
82  int order=1;
83 
84  float typenumber=(atomsLocation[k] as float[])[3];
86  switch ( (int) typenumber ) {
87  case 0:
88  //c= (MoleculeModel.carbonColor.color);
89  v=new Vector3(1.7f*scale[0],1.7f*scale[0],1.7f*scale[0]);
90  break;
91  case 1:
92  //c= (MoleculeModel.nitrogenColor.color);
93  v=new Vector3(1.55f*scale[1],1.55f*scale[1],1.55f*scale[1]);
94  break;
95  case 2:
96  //c= (MoleculeModel.oxygenColor.color);
97  v=new Vector3(1.52f*scale[2],1.52f*scale[2],1.52f*scale[2]);
98  break;
99  case 3:
100  //c= (MoleculeModel.sulphurColor.color);
101  v=new Vector3(2.27f*scale[3],2.27f*scale[3],2.27f*scale[3]);
102  break;
103  case 4:
104  //c= (MoleculeModel.phosphorusColor.color);
105  v=new Vector3(1.18f*scale[4],1.18f*scale[4],1.18f*scale[4]);
106  break;
107  case 5:
108  //c= (MoleculeModel.hydrogenColor.color);
109  v=new Vector3(1.2f*scale[5],1.2f*scale[5],1.2f*scale[5]);
110  break;
111  default:
112  //c= (MoleculeModel.unknownColor.color);
113  v=new Vector3(1.0f*scale[6],1.0f*scale[6],1.0f*scale[6]);
114  break;
115  }
116  CreateParticleBall(i,k,atomsLocation,c,v,order);
117  }
118 
119  }
120 
121  private void CreateParticleBall(int type,int start,ArrayList atomLocationalist,Color c,Vector3 v,int order) {
122 // Debug.Log("CreateParticleBall"+start);
123  float[] fLocation=atomLocationalist[start] as float[];
124  Vector3 location=new Vector3(fLocation[0],fLocation[1],fLocation[2]);
125  MoleculeModel.p[start].position=location;
126  MoleculeModel.p[start].size=(float)(v[0]);
127  MoleculeModel.p[start].color=c;
128  MoleculeModel.p[start].energy=1000;
129  }
130 
131 // private ArrayList AtomListByAxisOrder(ArrayList alist)
132  public ArrayList AtomListByAxisOrder(IList alist) {
133  // Debug.Log("Entering :: AtomListByAxisOrder");
134  ArrayList atomListByOrder=new ArrayList();
135 
136  for(int i=0;i<alist.Count;i++) {
137  float typenumber=0f;
138  string type;
140  type = (MoleculeModel.CaSplineTypeList[i] as AtomModel).type;
141  else
142  type = (MoleculeModel.atomsTypelist[i] as AtomModel).type;
143 
144  switch(type) {
145  case "C":
146  typenumber=0f;
147  break;
148  case "N":
149  typenumber=1f;
150  break;
151  case "O":
152  typenumber=2f;
153  break;
154  case "S":
155  typenumber=3f;
156  break;
157  case "P":
158  typenumber=4f;
159  break;
160  case "H":
161  typenumber=5f;
162  break;
163  default:
164  typenumber=6f;
165  break;
166  }
167  float[] atom=new float[5];
168  atom[0]=(alist[i] as float[])[0];
169  atom[1]=(alist[i] as float[])[1];
170  atom[2]=(alist[i] as float[])[2];
171  atom[3]=typenumber;
172  atom[4]=i;
173  atomListByOrder.Add(atom);
174  }
175 // atomListByOrder=alist;//if we write like this directly, it will change the order of alist.
176  atomListByOrder.Sort(new StructComparer());
177 
178  return atomListByOrder;
179  }
180 
181  }
182 }
override void Init()
Initializes this instance of the ParticleSystem Manager.
static bool secondarystruct
Switch between all atoms and C-alpha trace or BFactor secondary structure representation.
Definition: UIData.cs:176
void DisplayAtoms(UIData.AtomType type_atom, bool force_display=false)
static List< AtomModel > atomsTypelist
The type of each atom.
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
static List< Color > atomsColorList
The color of each atom.
void CreateParticleBall(int type, int start, ArrayList atomLocationalist, Color c, Vector3 v, int order)
static bool shadow
Definition: UIData.cs:198
void DisplayAtomParticle(ArrayList atomsLocation)
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.