UnityMol  0.9.6-875
UnityMol viewer / In developement
AtomModel.cs
Go to the documentation of this file.
1 
66 namespace Molecule.Model
67 {
68  using UnityEngine;
69  using System.Collections;
70  using System.Collections.Specialized;
71 
72  public class AtomModel {
73  protected string _type; //Atomic Element
74  protected float _radius; //Radius
75  protected float _scale; //Scale
76  protected Color _baseColor; //Color
77  protected string _baseTexture;//Texture
78 
79  public string type {
80  get { return _type; }
81  }
82 
83  public float radius {
84  get { return _radius; }
85  set { _radius = value; }
86  }
87 
88  public float scale {
89  get { return _scale; }
90  set { _scale = value; }
91  }
92 
93  public Color baseColor {
94  get { return _baseColor; }
95  set { _baseColor = value; }
96  }
97 
98  public string baseTexture {
99  get { return _baseTexture; }
100  set { _baseTexture = value; }
101  }
102 
103  AtomModel(string type, float radius, float scale, Color col, string texture) {
104  _type = type;
105  _radius = radius;
106  _scale = scale;
107  _baseColor = col;
108  _baseTexture = texture;
109  }
110 
111  private static OrderedDictionary s_typeToModel = null;
112 
113 
123  public static void ChangeChainColor(string chain, Color c) {
124  ((AtomModel)s_typeToModel[chain])._baseColor = c;
125  }
126 
127 
137  public static Color GetChainColor(string chain) {
138  return ( ((AtomModel)s_typeToModel[chain])._baseColor ) ;
139  }
140 
150  public static void ChangeAtomColor(string atomType, Color c) {
151  ((AtomModel)s_typeToModel[atomType])._baseColor = c;
152  }
153 
163  public static Color GetAtomColor(string atomType) {
164  return ((AtomModel)s_typeToModel[atomType])._baseColor;
165  }
166 
173  public static bool IsAlive() {
174  return(s_typeToModel != null);
175  }
176 
180  public static void InitAtomic() {
181  s_typeToModel = new OrderedDictionary();
182 
183  //Atomic
184 /*
185  // OLD BASIC COLOR SCHEME
186  s_typeToModel.Add("O", new AtomModel("O", 1.52f, 100, Color.red, null));
187  s_typeToModel.Add("C", new AtomModel("C", 1.70f, 100, Color.green, null));
188  s_typeToModel.Add("N", new AtomModel("N", 1.55f, 100, Color.blue, null));
189  s_typeToModel.Add("H", new AtomModel("H", 1.20f, 100, Color.white, null));
190  s_typeToModel.Add("S", new AtomModel("S", 2.27f, 100, Color.yellow, null));
191  s_typeToModel.Add("P", new AtomModel("P", 1.80f, 100, new Color(0.55f,0.44f,0.01f), null)); //tan
192  s_typeToModel.Add("X", new AtomModel("X", 1.40f, 100, Color.black, null));
193 */
194  // NEW PASTEL COLOR THEME
195  s_typeToModel.Add("O", new AtomModel("O", 1.52f, 100, new Color(0.827f,0.294f,0.333f,1f), null));
196  s_typeToModel.Add("C", new AtomModel("C", 1.70f, 100, new Color(0.282f,0.6f,0.498f,1f) , null));
197  s_typeToModel.Add("N", new AtomModel("N", 1.55f, 100, new Color(0.443f,0.662f,0.882f,1f), null));
198  s_typeToModel.Add("H", new AtomModel("H", 1.20f, 100, Color.white , null));
199  s_typeToModel.Add("S", new AtomModel("S", 2.27f, 100, new Color(1f,0.839f,0.325f,1f) , null));
200  s_typeToModel.Add("P", new AtomModel("P", 1.80f, 100, new Color(0.960f,0.521f,0.313f,1f), null));
201  s_typeToModel.Add("X", new AtomModel("X", 1.40f, 100, new Color(1f,0.4f,1f,1f) , null));//Color.black, null));
202 
203  //Chains
204  s_typeToModel.Add("chainA", new AtomModel("C", 1.70f, 100, Color.red, null));
205  s_typeToModel.Add("chainB", new AtomModel("C", 1.70f, 100, Color.green, null));
206  s_typeToModel.Add("chainC", new AtomModel("C", 1.70f, 100, Color.blue, null));
207  s_typeToModel.Add("chainD", new AtomModel("C", 1.70f, 100, Color.yellow, null)); //orange
208  s_typeToModel.Add("chainE", new AtomModel("C", 1.70f, 100, Color.gray, null));
209  s_typeToModel.Add("chainF", new AtomModel("C", 1.70f, 100, new Color(1.0f,0.5f,0.0f), null)); //tan
210  s_typeToModel.Add("chainG", new AtomModel("C", 1.70f, 100, new Color(0.5f,0.2f,1.0f), null)); //silver
211  s_typeToModel.Add("chainH", new AtomModel("C", 1.70f, 100, Color.white, null));
212 
213  //Bfactor
214  s_typeToModel.Add("BF1", new AtomModel("C", 1.00f, 100, new Color(0.0f, 0.0f, 1.0f), null));
215  s_typeToModel.Add("BF2", new AtomModel("C", 1.30f, 100, new Color(0.1f, 0.0f, 0.9f), null));
216  s_typeToModel.Add("BF3", new AtomModel("C", 1.60f, 100, new Color(0.2f, 0.0f, 0.8f), null));
217  s_typeToModel.Add("BF4", new AtomModel("C", 1.90f, 100, new Color(0.3f, 0.0f, 0.7f), null));
218  s_typeToModel.Add("BF5", new AtomModel("C", 2.20f, 100, new Color(0.4f, 0.0f, 0.6f), null));
219  s_typeToModel.Add("BF6", new AtomModel("C", 2.50f, 100, new Color(0.5f, 0.0f, 0.5f), null));
220  s_typeToModel.Add("BF7", new AtomModel("C", 2.80f, 100, new Color(0.6f, 0.0f, 0.4f), null));
221  s_typeToModel.Add("BF8", new AtomModel("C", 3.10f, 100, new Color(0.7f, 0.0f, 0.3f), null));
222  s_typeToModel.Add("BF9", new AtomModel("C", 3.40f, 100, new Color(0.8f, 0.0f, 0.2f), null));
223  s_typeToModel.Add("BF10", new AtomModel("C", 3.70f, 100, new Color(0.9f, 0.0f, 0.1f), null));
224 
225  }
226 
227  public static void InitHiRERNA() {
228  s_typeToModel = new OrderedDictionary();
229 
230  //Atomic
231 // s_typeToModel.Add("O", new AtomModel("O", 3.5f, 100, Color.red, null));
232 // s_typeToModel.Add("C", new AtomModel("C", 3.5f, 100, Color.green, null));
233 // s_typeToModel.Add("P", new AtomModel("P", 5.0f, 100, new Color(0.55f,0.44f,0.01f), null)); //tan
234 // s_typeToModel.Add("G", new AtomModel("G", 3.5f, 100, Color.cyan, null));
235 // s_typeToModel.Add("A", new AtomModel("A", 3.5f, 100, Color.cyan, null));
236 // s_typeToModel.Add("U", new AtomModel("U", 3.5f, 100, Color.cyan, null));
237 // s_typeToModel.Add("C1", new AtomModel("C1", 3.5f, 100, Color.cyan, null));
238 // s_typeToModel.Add("X", new AtomModel("X", 1.40f, 100, Color.black, null));
239 
240  s_typeToModel.Add("P", new AtomModel("P", 3.5f, 100, MoleculeModel.phosphorusColor.color, null));
241  s_typeToModel.Add("O5*", new AtomModel("O", 3.5f, 100, MoleculeModel.oxygenColor.color, null));
242  s_typeToModel.Add("C5*", new AtomModel("C", 3.5f, 100, MoleculeModel.carbonColor.color, null));
243  s_typeToModel.Add("CA", new AtomModel("C", 3.5f, 100, MoleculeModel.carbonColor.color, null));
244  s_typeToModel.Add("CY", new AtomModel("C", 3.5f, 100, MoleculeModel.carbonColor.color, null));
245 
246  s_typeToModel.Add("G1", new AtomModel("X", 3.5f, 100, Color.green, null));
247  s_typeToModel.Add("G2", new AtomModel("X", 3.5f, 100, Color.green, null));
248 
249  s_typeToModel.Add("C1", new AtomModel("X", 3.5f, 100, Color.yellow, null));
250 
251  s_typeToModel.Add("A1", new AtomModel("X", 3.5f, 100, Color.red, null));
252  s_typeToModel.Add("A2", new AtomModel("X", 3.5f, 100, Color.red, null));
253 
254  s_typeToModel.Add("U1", new AtomModel("X", 3.5f, 100, new Color(0.7f, 0.7f, 0.98f), null));
255  }
256 
257  public static AtomModel GetModel(string type) {
258  if(s_typeToModel == null)
259  return null;
260  return (AtomModel)s_typeToModel[type];
261  }
262 
263  }
264 }
static void ChangeChainColor(string chain, Color c)
Changes the color of the chain.
Definition: AtomModel.cs:123
static void InitHiRERNA()
Definition: AtomModel.cs:227
static ColorObject phosphorusColor
static ColorObject carbonColor
static AtomModel GetModel(string type)
Definition: AtomModel.cs:257
static Color GetAtomColor(string atomType)
Gets the color of the atom type.
Definition: AtomModel.cs:163
Color color
Definition: ColorObject.cs:72
static ColorObject oxygenColor
static bool IsAlive()
Determines whether this instance is alive.
Definition: AtomModel.cs:173
static void ChangeAtomColor(string atomType, Color c)
Changes the color of the atom type.
Definition: AtomModel.cs:150
AtomModel(string type, float radius, float scale, Color col, string texture)
Definition: AtomModel.cs:103
static void InitAtomic()
Inits the atomic and chains scales.
Definition: AtomModel.cs:180
static Color GetChainColor(string chain)
Gets the color of the chain.
Definition: AtomModel.cs:137