UnityMol  0.9.6-875
UnityMol viewer / In developement
HBallManager.cs
Go to the documentation of this file.
1 
60 using UnityEngine;
61 using UnityEngine.Rendering;
62 
63 using System.Collections;
64 using System.Collections.Generic;
65 using UI;
66 
67 // Foreach statements are bad, they should all be removed! Unfortunately, I discovered that a little late. --- Alexandre
68 using Molecule.Model;
69 using System.Linq;
70 
71 
73 
74  public static string[] allowedAtomsForPosition = {"CY", "C1", "U1", "G1", "G2", "A1", "A2"};
75 
76 
77  public static BallUpdateHB[] hballs;
78  private GameObject[] hballsGameObjects;
79 
80  public static bool xgmml = false;
81  public static float depthFactor = 1.0f;
82  public static float brightness = 1.0f;
83  public static float shininess = 0.0f;
84  public static bool resetBrightness = false;
85  public static bool resetShininess = false;
86  private static float oldDepthFactor = 1.0f;
87  private static bool mouseOvers = false;
88  private static bool wasInteractiveColored = false;
89 
90  static public bool ellipsoidView = false;
91  static public bool ellipsoidsInitialized = false;
92  public bool ellipsoidViewEnabled() {
93  return ellipsoidView;
94  }
95 
99  public override void Init () {
100  hballs = GameObject.FindObjectsOfType(typeof(BallUpdateHB)) as BallUpdateHB[];
101  if(UI.GUIDisplay.file_extension=="xgmml")
102  xgmml = true;
103 
104  // Useful for second molecule
105  BallUpdate.resetColors = true;
106  BallUpdate.resetRadii = true;
107  for (int i=0; i<hballs.Length; i++) {
108  hballs[i].GetComponent<Renderer>().enabled = true;
109  hballs[i].GetComponent<Renderer>().shadowCastingMode = ShadowCastingMode.Off;
110  hballs[i].GetComponent<Renderer>().receiveShadows = false;
111 // hballs[i].renderer.material.shader = Shader.Find("Diffuse");
112  }
113  hballsGameObjects = new GameObject[MoleculeModel.atoms.Count];
114  MoleculeModel.atoms.CopyTo(hballsGameObjects);
115  enabled = true;
116  isInit = true;
117 
118  }
119 
123  public override void DestroyAll() {
124  Debug.Log("Destroying Hyperboloids");
125 // Debug.Log(hballs.Length.ToString());
126 
127 
128 
129  hballs = GameObject.FindObjectsOfType(typeof(BallUpdateHB)) as BallUpdateHB[];
130  for (int i=0; i<hballs.Length; i++) {
131 // hballs[i].renderer.enabled = false;
132 // DestroyImmediate(hb);
133  GameObject.Destroy(hballs[i].gameObject);
134  }
135 
136 
137  for (int i = 0; i < MoleculeModel.ellipsoids.Count; i++)
138  GameObject.Destroy(MoleculeModel.ellipsoids[i]);
139 
140  MoleculeModel.ellipsoids.Clear();
141 
142  isInit = false;
143  }
144 
148 /* private void InitSticks() {
149  sticks = GameObject.FindObjectsOfType(typeof(StickUpdate)) as StickUpdate[];
150  Debug.Log("HBallManager: Init sticks");
151  foreach(StickUpdate stu in sticks) {
152  stu.renderer.enabled = true;
153  stu.renderer.shadowCastingMode = ShadowCastingMode. false;
154  stu.renderer.receiveShadows = false;
155 // stu.renderer.material.shader = Shader.Find("Diffuse");
156  }
157  initSticks = true;
158  }
159 */
160 
161 /*
165  public void SetStickShader(){
166  if(!GUIMoleculeController.toggle_NA_TEXATOM)
167  {
168  if(UIData.bondtype == UIData.BondType.hyperstick)
169  foreach(StickUpdate stu in sticks)
170  stu.renderer.material.shader = Shader.Find("FvNano/Stick HyperBalls OpenGL");
171  }
172  else
173  {
174  if(UIData.bondtype == UIData.BondType.hyperstick)
175  foreach(StickUpdate stu in sticks)
176  stu.renderer.material.shader = Shader.Find("FvNano/Stick HyperBalls 2 OpenGL");
177  }
178 
179  }
180 */
181 
182  public override void ToggleDistanceCueing(bool enabling) {
183  if(UIData.bondtype != UIData.BondType.hyperstick)
184  return;
185  float attenuation;
186  attenuation = enabling? 1f : 0f;
187 
188  for (int i=0; i<hballs.Length; i++)
189  hballs[i].GetComponent<Renderer>().material.SetFloat("_Attenuation", attenuation);
190  }
191 
192 
193 
194 
195 
196 /* /// <summary>
202  public void SetTexture(Texture texture) {
203  Debug.Log("HBallManager object: SetTexture(Texture)");
204 
205  for (int i=0; i<hballs.Length; i++)
206  if(hb!=null)
207  hballs[i].renderer.material.SetTexture("_MatCap", texture);
208  BallUpdate.bondsReadyToBeReset = true;
209  }
210 */
211 
212 /* /// <summary>
218  public void SetTexture(string resource_name) {
219  Debug.Log("HBallManager object: SetTexture(String) : " + resource_name);
220 
221  Texture text2D = (Texture)Resources.Load(resource_name);
222  SetTexture(text2D);
223  }
224 */
225 
226 
242  public void SetTexture(Texture texture, List<string> atom, string residue = "All", string chain = "All") {
243  if(hballs == null)
244  findAtoms();
245  Debug.Log("SetTexture HBall");
246  for (int i = 0; i < MoleculeModel.ellipsoids.Count; i++)
247  {
248  MoleculeModel.ellipsoids[i].GetComponent<Renderer>().material.SetTexture("_MatCap", texture);
249  }
250  if(!atom.Contains ("All")){
251  if(residue == "All"){
252  if(chain == "All"){
253  // ---------- ATOM
254 // Debug.Log("ATOM");
256  for (int i=0; i<hballs.Length; i++)
257  if(atom.Contains(hballs[i].tag))
258  hballs[i].GetComponent<Renderer>().material.SetTexture("_MatCap", texture);
259  }else{
260  for (int i=0; i<hballs.Length; i++)
261  if(atom.Contains(Molecule.Model.MoleculeModel.atomsNamelist[(int)hballs[i].number]))
262  hballs[i].GetComponent<Renderer>().material.SetTexture("_MatCap", texture);
263  }
264  }
265  else{
266  // ---------- ATOM + CHAIN
267 // Debug.Log("ATOM+CHAIN");
269  for (int i=0; i<hballs.Length; i++){
270  if(atom.Contains(hballs[i].tag)
271  && Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
272  hballs[i].GetComponent<Renderer>().material.SetTexture("_MatCap", texture);
273  }
274  }else{
275  for (int i=0; i<hballs.Length; i++){
276  if(atom.Contains(Molecule.Model.MoleculeModel.atomsNamelist[(int)hballs[i].number])
277  && Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
278  hballs[i].GetComponent<Renderer>().material.SetTexture("_MatCap", texture);
279  }
280  }
281  }
282  }
283  else{
284  if(chain == "All"){
285  // ---------- ATOM + RESIDUE
286 // Debug.Log("ATOM+RESIDUE");
288  for (int i=0; i<hballs.Length; i++){
289  if(atom.Contains(hballs[i].tag)
290  && Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue)
291  hballs[i].GetComponent<Renderer>().material.SetTexture("_MatCap", texture);
292  }
293  }else{
294  for (int i=0; i<hballs.Length; i++){
295  if(atom.Contains(Molecule.Model.MoleculeModel.atomsNamelist[(int)hballs[i].number])
296  && Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue)
297  hballs[i].GetComponent<Renderer>().material.SetTexture("_MatCap", texture);
298  }
299  }
300  }
301  else{
302  // ---------- ATOM + RESIDUE + CHAIN
303 // Debug.Log("ATOM+RESIDUE+CHAIN");
305  for (int i=0; i<hballs.Length; i++){
306  if(atom.Contains(hballs[i].tag)
307  && Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue
308  && Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
309  hballs[i].GetComponent<Renderer>().material.SetTexture("_MatCap", texture);
310  }
311  }else{
312  for (int i=0; i<hballs.Length; i++){
313  if(atom.Contains(hballs[i].tag)
314  && Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue
315  && Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
316  hballs[i].GetComponent<Renderer>().material.SetTexture("_MatCap", texture);
317  }
318  }
319  }
320  }
321  }
322  else{
323  if(residue == "All"){
324  if(chain == "All"){
325  // ---------- ALL
326 // Debug.Log("ALL");
327  for (int i=0; i<hballs.Length; i++)
328  hballs[i].GetComponent<Renderer>().material.SetTexture("_MatCap", texture);
329  }
330  else{
331  // ---------- CHAIN
332 // Debug.Log("CHAIN");
333  for (int i=0; i<hballs.Length; i++){
334  if(Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
335  hballs[i].GetComponent<Renderer>().material.SetTexture("_MatCap", texture);
336  }
337  }
338  }
339  else{
340  if(chain == "All"){
341  // ---------- RESIDUE
342 // Debug.Log("RESIDUE");
343  for (int i=0; i<hballs.Length; i++){
344  if(Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue)
345  hballs[i].GetComponent<Renderer>().material.SetTexture("_MatCap", texture);
346  }
347  }
348  else{
349  // ---------- RESIDUE + CHAIN
350 // Debug.Log("RESIDUE.CHAIN");
351  for (int i=0; i<hballs.Length; i++){
352  if(Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue
353  && Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
354  hballs[i].GetComponent<Renderer>().material.SetTexture("_MatCap", texture);
355  }
356  }
357  }
358  }
359 
361  }
362 
378  public void SetTexture(string resource_name, List<string> atom, string residue = "All", string chain = "All") {
379  Texture text2D = (Texture)Resources.Load(resource_name);
380  SetTexture(text2D, atom, residue, chain);
381  }
382 
392  public void SetTexture(Texture texture, int atomNum) {
393  Debug.Log("HBallManager object: SetTexture(Texture, int) : " + texture.name + " - " + atomNum);
394 
395  for (int i=0; i<hballs.Length; i++)
396  if(hballs[i].GetComponent<BallUpdate>().number == atomNum)
397  hballs[i].GetComponent<Renderer>().material.SetTexture("_MatCap", texture);
399  }
400 
410  public void SetTexture(string resource_name, int atomNum) {
411  Texture text2D = (Texture)Resources.Load(resource_name);
412  SetTexture(text2D, atomNum);
413  }
414 
415 
420  private void ResetColors() {
421 // Debug.Log("Resetting HBall colors");
422  if(UIData.atomtype == UIData.AtomType.hyperball) {
423 
424  for (int i=0; i<hballs.Length; i++)
425  //C.R
427  hballs[i].GetComponent<Renderer>().material.SetColor("_Color", hballs[i].atomcolor);}
428  else
429  {
430  hballs[i].GetComponent<Renderer>().material.SetColor("_Color", Molecule.Model.MoleculeModel.atomsColorList[(int)hballs[i].number]);
431  }
432  BallUpdate.resetColors = false;
434  }
435  }
436 
437 
453  public override void SetColor(Color col, List<string> atom, string residue = "All", string chain = "All") {
454 // Debug.Log("SetColor HBall");
455  if(!atom.Contains ("All")){
456  if(residue == "All"){
457  if(chain == "All"){
458  // ---------- ATOM
459 // Debug.Log("ATOM");
461  for (int i=0; i<hballs.Length; i++){
462  if(atom.Contains(hballs[i].tag))
463  Molecule.Model.MoleculeModel.atomsColorList[(int)hballs[i].number] = col;
464  }
465  }else{
466  for (int i=0; i<hballs.Length; i++){
467  if(atom.Contains(Molecule.Model.MoleculeModel.atomsNamelist[(int)hballs[i].number]))
468  Molecule.Model.MoleculeModel.atomsColorList[(int)hballs[i].number] = col;
469  }
470  }
471  }
472  else{
473  // ---------- ATOM + CHAIN
474 // Debug.Log("ATOM+CHAIN");
476  for (int i=0; i<hballs.Length; i++){
477  if(atom.Contains(hballs[i].tag)
478  && Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
479  Molecule.Model.MoleculeModel.atomsColorList[(int)hballs[i].number] = col;
480  }
481  }else{
482  for (int i=0; i<hballs.Length; i++){
483  if(atom.Contains(Molecule.Model.MoleculeModel.atomsNamelist[(int)hballs[i].number])
484  && Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
485  Molecule.Model.MoleculeModel.atomsColorList[(int)hballs[i].number] = col;
486  }
487  }
488  }
489  }
490  else{
491  if(chain == "All"){
492  // ---------- ATOM + RESIDUE
493 // Debug.Log("ATOM+RESIDUE");
495  for (int i=0; i<hballs.Length; i++){
496  if(atom.Contains(hballs[i].tag)
497  && Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue)
498  Molecule.Model.MoleculeModel.atomsColorList[(int)hballs[i].number] = col;
499  }
500  }else{
501  for (int i=0; i<hballs.Length; i++){
502  if(atom.Contains(Molecule.Model.MoleculeModel.atomsNamelist[(int)hballs[i].number])
503  && Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue)
504  Molecule.Model.MoleculeModel.atomsColorList[(int)hballs[i].number] = col;
505  }
506  }
507  }
508  else{
509  // ---------- ATOM + RESIDUE + CHAIN
510 // Debug.Log("ATOM+RESIDUE+CHAIN");
512  for (int i=0; i<hballs.Length; i++){
513  if(atom.Contains(hballs[i].tag)
514  && Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue
515  && Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
516  Molecule.Model.MoleculeModel.atomsColorList[(int)hballs[i].number] = col;
517  }
518  }else{
519  for (int i=0; i<hballs.Length; i++){
520  if(atom.Contains(Molecule.Model.MoleculeModel.atomsNamelist[(int)hballs[i].number])
521  && Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue
522  && Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
523  Molecule.Model.MoleculeModel.atomsColorList[(int)hballs[i].number] = col;
524  }
525  }
526  }
527  }
528  }
529  else{
530  if(residue == "All"){
531  if(chain == "All"){
532  // ---------- EVERYTHING
533 // Debug.Log("EVERYTHING");
534  for (int i=0; i<hballs.Length; i++)
535  Molecule.Model.MoleculeModel.atomsColorList[(int)hballs[i].number] = col;
536  }
537  else{
538  // ---------- CHAIN
539 // Debug.Log("CHAIN");
540  for (int i=0; i<hballs.Length; i++){
541  if(Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
542  Molecule.Model.MoleculeModel.atomsColorList[(int)hballs[i].number] = col;
543  }
544  }
545  }
546  else{
547  if(chain == "All"){
548  // ---------- RESIDUE
549 // Debug.Log("RESIDUE");
550  for (int i=0; i<hballs.Length; i++){
551  if(Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue){
552  Molecule.Model.MoleculeModel.atomsColorList[(int)hballs[i].number] = col;
553  }
554  }
555  }
556  else{
557  // ---------- CHAIN + RESIDUE
558 // Debug.Log("RESIDUE+CHAIN");
559  for (int i=0; i<hballs.Length; i++){
560  if(Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue
561  && Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
562  Molecule.Model.MoleculeModel.atomsColorList[(int)hballs[i].number] = col;
563  }
564  }
565  }
566  }
567 
568  BallUpdate.resetColors = true;
569 // BallUpdate.bondsReadyToBeReset = true;
570  }
571 
581  public override void SetColor(Color col, int atomNum) {
582  for (int i=0; i<hballs.Length; i++){
583  if(hballs[i].GetComponent<BallUpdate>().number == atomNum)
584  Molecule.Model.MoleculeModel.atomsColorList[(int)hballs[i].number] = col;
585  }
586  BallUpdate.resetColors = true;
587  }
588 
601  public override void SetRadii(List<string> atom, string residue = "All", string chain = "All") {
602  if(!atom.Contains ("All")){
603  if(residue == "All"){
604  if(chain == "All"){
605  // ---------- ATOM
607  for (int i=0; i<hballs.Length; i++) {
608  if(atom.Contains(hballs[i].tag))
610  }
611  }else{
612  for (int i=0; i<hballs.Length; i++) {
613  if(atom.Contains(Molecule.Model.MoleculeModel.atomsNamelist[(int)hballs[i].number]))
615  }
616  }
617  }
618  else{
619  // ---------- ATOM + CHAIN
621  for (int i=0; i<hballs.Length; i++) {
622  if(atom.Contains(hballs[i].tag)
623  && Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
625  }
626  }else{
627  for (int i=0; i<hballs.Length; i++) {
628  if(atom.Contains(Molecule.Model.MoleculeModel.atomsNamelist[(int)hballs[i].number])
629  && Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
631  }
632  }
633  }
634  }
635  else{
636  if(chain == "All"){
637  // ---------- ATOM + RESIDUE
639  for (int i=0; i<hballs.Length; i++) {
640  if(atom.Contains(hballs[i].tag)
641  && Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue)
643  }
644  }else{
645  for (int i=0; i<hballs.Length; i++) {
646  if(atom.Contains(Molecule.Model.MoleculeModel.atomsNamelist[(int)hballs[i].number])
647  && Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue)
649  }
650  }
651  }
652  else{
653  // ---------- ATOM + CHAIN + RESIDUE
655  for (int i=0; i<hballs.Length; i++) {
656  if(atom.Contains(hballs[i].tag)
657  && Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue
658  && Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
660  }
661  }else{
662  for (int i=0; i<hballs.Length; i++) {
663  if(atom.Contains(Molecule.Model.MoleculeModel.atomsNamelist[(int)hballs[i].number])
664  && Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue
665  && Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
667  }
668  }
669  }
670  }
671  }
672  else{
673  if(residue == "All"){
674  if(chain == "All"){
675  // ---------- EVERYTHING
676  for (int i=0; i<hballs.Length; i++) {
678  }
679  }
680  else{
681  // ---------- CHAIN
682  for (int i=0; i<hballs.Length; i++) {
683  if(Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
685  }
686  }
687  }
688  else{
689  if(chain == "All"){
690  // ---------- RESIDUE
691  for (int i=0; i<hballs.Length; i++) {
692  if(Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue)
694  }
695  }
696  else{
697  // ---------- CHAIN + RESIDUE
698  for (int i=0; i<hballs.Length; i++) {
699  if(Molecule.Model.MoleculeModel.atomsResnamelist[(int)hballs[i].number] == residue
700  && Molecule.Model.MoleculeModel.atomsChainList[(int)hballs[i].number] == chain)
702  }
703  }
704  }
705  }
706  BallUpdate.resetRadii = true;
708  }
709 
716  public override void SetRadii(int id) {
717  for (int i=0; i<hballs.Length; i++) {
718  if((int)hballs[i].number == id)
720  }
721  BallUpdate.resetRadii = true;
723  }
724 
734  public Color GetColor(Vector3 pos){
735  for (int i=0; i<hballs.Length; i++)
736  if(hballs[i].transform.position == pos)
737  return hballs[i].GetComponent<Renderer>().material.GetColor("_Color");
738  return Color.white;
739  }
740 
750  public override GameObject GetBall(int id){
751  return hballs[id].gameObject;
752  }
753 
754 
758  private void MoveNetworkNodes() {
759  for (int i=0; i<hballs.Length; i++)
760  hballs[i].transform.localPosition = new Vector3(hballs[i].transform.localPosition.x,hballs[i].transform.localPosition.y, hballs[i].z * depthFactor);
761  }
762 
766  public override void ResetPositions(){
767  if(hballs == null){
768  Init();
769  }
770  for (int j=0; j<hballs.Length; j++){
771  int i = (int)hballs[j].number;
772  hballs[j].transform.localPosition = new Vector3(MoleculeModel.atomsLocationlist[i][0],
775  }
778  }
779 
783  public override void ResetIMDSimulationPositions(){
784  for (int j=0; j<hballs.Length; j++){
785  int i = (int)hballs[j].number;
786  hballs[j].transform.localPosition = MoleculeModel.atomsIMDSimulationLocationlist[i];
787  }
788  }
789 
793  public override void ResetRadii() {
794  if(UIData.atomtype == UIData.AtomType.hyperball){
795  hballs = GameObject.FindObjectsOfType(typeof(BallUpdateHB)) as BallUpdateHB[];
796  //T.T sometimes this list is not initialized. So we initialise it here.
797 
799  for (int i=0; i<(Molecule.Model.MoleculeModel.atomsTypelist.Count); i++){
801  }
802  }
803 
804  //C.R
805  if (Molecule.Model.MoleculeModel.atomsLocalScaleList.Count < hballs[0].number+1){
806  for(int i=(Molecule.Model.MoleculeModel.atomsLocalScaleList.Count)+1; i<=hballs[0].number+1; i++){
808  }
809  }
810 
811  for (int i=0; i<hballs.Length; i++) {
812  if (UIData.secondarystruct){
813  if(SecondaryStructureOldGUI.structType == "B Factor"){
814  if (hballs[i].rayon == 3.7f){
815  hballs[i].GetComponent<Renderer>().material.SetFloat("_Rayon", hballs[i].rayon
818  * (Molecule.Model.MoleculeModel.atomsLocalScaleList[(int)hballs[i].number]/100));}
819  else{
820  hballs[i].GetComponent<Renderer>().material.SetFloat("_Rayon", hballs[i].rayon
822  * (Molecule.Model.MoleculeModel.atomsLocalScaleList[(int)hballs[i].number]/100));
823  }
824  }
825  else
826  hballs[i].GetComponent<Renderer>().material.SetFloat("_Rayon", hballs[i].rayon
828  * (Molecule.Model.MoleculeModel.atomsLocalScaleList[(int)hballs[i].number]/100));
829  }
830  else{
831  hballs[i].GetComponent<Renderer>().material.SetFloat("_Rayon", Molecule.Model.MoleculeModel.atomsTypelist[(int)hballs[i].number].radius
833  * (Molecule.Model.MoleculeModel.atomsLocalScaleList[(int)hballs[i].number]/100));
834  }
835  }
837  }
838  }
839 
843  private void CreateMouseOvers() {
844 
845  for (int i=0; i<hballs.Length; i++) {
846  hballs[i].gameObject.AddComponent<MouseOverMolecule>();
847  }
848  mouseOvers = true;
849  }
850 
854  private void DestroyMouseOvers() {
855  hballs = GameObject.FindObjectsOfType(typeof(BallUpdateHB)) as BallUpdateHB[];
856  for (int i=0; i<hballs.Length; i++) {
857  Destroy(hballs[i].GetComponent<MouseOverMolecule>());
858  }
859  mouseOvers = false;
860  }
861  private void ExitInteractive(){
862  for (int i=0; i<hballs.Length; i++) {
863  Destroy(hballs[i].GetComponent<SpringJoint>());
864  Destroy(hballs[i].GetComponent<Rigidbody>());
865  }
866  ResetPositions();
867  ResetColors();
868  }
869 
871  for (int i=0; i<hballsGameObjects.Length; i++) {
872  MouseOverMoleculeIMDSimulation mover = (MouseOverMoleculeIMDSimulation) hballsGameObjects[i].AddComponent<MouseOverMoleculeIMDSimulation>();
873  mover.setAtomId(i);
874  }
875  mouseOvers = true;
876  }
877 
879  hballs = GameObject.FindObjectsOfType(typeof(BallUpdateHB)) as BallUpdateHB[];
880  for (int i=0; i<hballsGameObjects.Length; i++) {
881  Destroy(hballsGameObjects[i].GetComponent<MouseOverMoleculeIMDSimulation>());
882  }
883  mouseOvers = false;
884  }
885 
886  private void StartPhysicsManagement(){
887  for (int i=0; i<hballs.Length; i++) {
888  if(!hballs[i].GetComponent<Rigidbody>())
889  hballs[i].gameObject.AddComponent<Rigidbody>();
890  if(!hballs[i].GetComponent<SpringJoint>())
891  hballs[i].gameObject.AddComponent<SpringJoint>();
892  }
893  }
898  private void ManagePhysics() {
899 
900  if(UIData.toggleGray) {
901  for (int i=0; i<hballs.Length; i++) {
902  float v = hballs[i].GetComponent<Rigidbody>().velocity.magnitude;
903 
904  Color c = Color.Lerp(Color.white, Color.black, v);
905  hballs[i].GetComponent<Renderer>().material.SetColor("_Color", c); // ugly
906 
907  }
908  wasInteractiveColored = true;
909  }
910  else if(wasInteractiveColored){
911  for (int i=0; i<hballs.Length; i++) {
912  hballs[i].GetComponent<Renderer>().material.SetColor("_Color", Molecule.Model.MoleculeModel.atomsColorList[(int)hballs[i].number]);
913  }
914  wasInteractiveColored = false;
915  }
916  }
917 
918 
922  public override void DisableRenderers() {
923  Debug.Log("HBallManager: Disabling renderers");
925  {
927  }
928  hballs = GameObject.FindObjectsOfType(typeof(BallUpdateHB)) as BallUpdateHB[];
929  for (int i=0; i<hballs.Length; i++){
930  //if(hb)
931  hballs[i].GetComponent<Renderer>().enabled = false;
932  if(UIData.atomtype != UIData.AtomType.particleball) // Particles don't have their own collider so we must keep it
933  hballs[i].GetComponent<Collider>().enabled = false; // Disable the collider at the same time to avoid ghost-clicking with atom selection
934  }
935 // DeactivateBases();
937 
938  enabled = false;
939  }
940 
941 
945  public override void EnableRenderers(){
947  {
949  }
951  hballs = GameObject.FindObjectsOfType(typeof(BallUpdateHB)) as BallUpdateHB[];
952  //if(UIData.atomtype != UIData.AtomType.hyperball)
953  // return;
954 
955  for (int i=0; i<hballs.Length; i++){
956  //if(hb)
957  hballs[i].GetComponent<Renderer>().enabled = true;
958  hballs[i].GetComponent<Collider>().enabled = true;
959  }
960 
961  Debug.Log("HBallManager: Enabling renderer");
962  enabled = true;
963  }
964 
965  public override void EnableShadows(){
966  hballs = GameObject.FindObjectsOfType(typeof(BallUpdateHB)) as BallUpdateHB[];
967  for(int i=0; i<hballs.Length; i++){
968  hballs[i].GetComponent<Renderer>().shadowCastingMode = ShadowCastingMode.On;
969  hballs[i].GetComponent<Renderer>().receiveShadows = true;
970  hballs[i].GetComponent<Renderer>().material.shader = Shader.Find("FvNano/HyperBalls Shadow GL_D3D");
971  }
972  }
973 
974  public override void DisableShadows(){
975  hballs = GameObject.FindObjectsOfType(typeof(BallUpdateHB)) as BallUpdateHB[];
976  for(int i=0; i<hballs.Length; i++){
977  hballs[i].GetComponent<Renderer>().shadowCastingMode = ShadowCastingMode.Off;
978  hballs[i].GetComponent<Renderer>().receiveShadows = false;
979  hballs[i].GetComponent<Renderer>().material.shader = Shader.Find("FvNano/HyperBalls GL_D3D");
980 
981  }
982  }
983 
984 
985 
986  private void ResetBrightness() {
987  for(int i=0; i<hballs.Length; i++)
988  hballs[i].GetComponent<Renderer>().material.SetFloat("_Brightness", brightness);
989 
992  resetBrightness = false;
993  }
994 
995 
996  void Update () {
997  if (UIData.isHBallLoaded == true && ellipsoidsInitialized == false && UIData.ffType == UIData.FFType.HiRERNA)
998  {
1000  }
1001 
1002  //if(UIData.atomtype != UIData.AtomType.hyperball) {
1003  // DisableRenderers();
1004  //}
1005 
1007 // Debug.Log("HBALL RESETCOLOR CALL" + UIData.atomtype);
1008  ResetColors();
1009  }
1010 
1011  if(resetBrightness)
1012  ResetBrightness();
1013 
1014  if (xgmml && (oldDepthFactor!=depthFactor)) {
1015  MoveNetworkNodes();
1016  oldDepthFactor=depthFactor;
1017  }
1018 
1019  if(mouseOvers && !GUIMoleculeController.toggle_NA_INTERACTIVE ){
1021  ExitInteractive();
1022  }
1023 
1025  if(!mouseOvers) {
1026  CreateMouseOvers();
1028  }
1029 
1030  ManagePhysics();
1031  }
1032 
1033 
1034 
1037  || (StickUpdate.scale != StickUpdate.oldscale)) ) ) {
1038  if(UIData.atomtype == UIData.AtomType.hyperball) {
1039  ResetRadii();
1040  BallUpdate.resetRadii = false;
1041  }
1042  if(UIData.bondtype == UIData.BondType.hyperstick)
1043  HStickManager.adjustRadii = true;
1044  }
1045 
1046  if (GUIMoleculeController.toggle_IMD && ellipsoidView)
1047  {
1048 // Debug.Log(">>>>>>>>>>>>>>>Update Ellipsoids");
1049  UpdateEllipsoids();
1050  }
1051  if(resetShininess)
1052  ResetShininess();
1053 /* if(UIData.EnableUpdate){ // not sure what that's for
1054 
1055  }
1056 */
1057  }
1058 
1059  //
1060  // HiRERNA
1061  //
1062 
1068  public Vector3 computeEllipsoidPosition(int residueId)
1069  {
1070  int[] atoms = MoleculeModel.atomsForEllipsoidsPerResidue[residueId];
1071 
1072  Vector3 sum = new Vector3(0.0f, 0.0f, 0.0f);
1073  int currentAtomId = 0;
1074  int nbOfAtoms = 0;
1075  for (int i = 0; i < 3; i++) {
1076  currentAtomId = atoms[i];
1077  if (allowedAtomsForPosition.Contains(MoleculeModel.atomsNamelist[currentAtomId])) {
1078  GameObject go = hballsGameObjects[currentAtomId] as GameObject;
1079  sum += go.transform.position;
1080  nbOfAtoms += 1;
1081  }
1082  }
1083 
1084  return sum / nbOfAtoms;
1085  }
1086 
1092  public Vector3 computeEllipsoidNormal(int residueId)
1093  {
1094  int[] atoms = MoleculeModel.atomsForEllipsoidsPerResidue[residueId];
1095 
1096  GameObject go = hballsGameObjects[atoms[0]] as GameObject;
1097  Vector3 point1 = go.transform.position;
1098 
1099  go = hballsGameObjects[atoms[1]] as GameObject;
1100  Vector3 point2 = go.transform.position;
1101 
1102  go = hballsGameObjects[atoms[2]] as GameObject;
1103  Vector3 point3 = go.transform.position;
1104 
1105  // Vector3 planeNormal =
1106 
1107  // float angleXY = 180 * Mathf.Acos(Vector3.Dot (planeNormal, new Vector3(0.0f, 0.0f, 1.0f)) / planeNormal.magnitude) / Mathf.PI;
1108  // float angleXZ = 180 * Mathf.Acos(Vector3.Dot (planeNormal, new Vector3(0.0f, 1.0f, 0.0f)) / planeNormal.magnitude) / Mathf.PI;
1109  // float angleYZ = 180 * Mathf.Acos(Vector3.Dot (planeNormal, new Vector3(1.0f, 0.0f, 0.0f)) / planeNormal.magnitude) / Mathf.PI;
1110 
1111  // Debug.Log (angleXY);
1112  // Debug.Log (angleXZ);
1113  // Debug.Log (angleYZ);
1114 
1115  return Vector3.Cross(point2 - point1, point3 - point1).normalized;
1116  }
1117 
1118  public Vector3 computeEllipsoidOrientation(int residueId)
1119  {
1120  return (hballsGameObjects[MoleculeModel.atomsForEllipsoidsOrientationPerResidue[residueId]].transform.position - MoleculeModel.ellipsoidsPerResidue[residueId].transform.position).normalized;
1121  }
1122 
1126  public void findAtoms()
1127  {
1128  // Traverse "residues" (in fact, these are nucleotides)
1129  Debug.Log("Finding atoms");
1130  foreach (KeyValuePair<int, ArrayList> entry in MoleculeModel.residues)
1131  {
1132  int nbOfAtoms = entry.Value.Count;
1133 
1134  int currentAtomId = 0;
1135  string currentAtomName;
1136  string currentResidueName;
1137 
1138  int i = 0;
1139  List<int> triplet = new List<int>();
1140  while (i != nbOfAtoms)
1141  {
1142  currentAtomId = (int)entry.Value[i];
1143  currentAtomName = MoleculeModel.atomsNamelist[currentAtomId];
1144  currentResidueName = MoleculeModel.atomsResnamelist[currentAtomId]; // Could potentially be out of this loop
1145 
1146  // For bases G and A, ellipsoid is computed from the triplet CY-G1-G2 or CY-A1-A2
1147  // For U and C, we use CA-CY-C1 or CA-CY-U1
1148  if (currentResidueName == "G" || currentResidueName == "A") {
1149  if (currentAtomName == "CY" || currentAtomName == "G1" || currentAtomName == "G2" || currentAtomName == "A1" || currentAtomName == "A2") {
1150  triplet.Add (currentAtomId);
1151  }
1152  }
1153  else
1154  {
1155  if (currentAtomName == "CY" || currentAtomName == "CA" || currentAtomName == "C1" || currentAtomName == "U1") {
1156  triplet.Add (currentAtomId);
1157  }
1158  }
1159 
1160  if (triplet.Count == 3)
1161  {
1162  i = nbOfAtoms;
1163  }
1164  else
1165  {
1166  i++;
1167  }
1168  }
1169  MoleculeModel.atomsForEllipsoidsPerResidue[entry.Key] = triplet.ToArray();
1170 
1171  i = 0;
1172  while (i != nbOfAtoms)
1173  {
1174  currentAtomId = (int)entry.Value[i];
1175  currentAtomName = MoleculeModel.atomsNamelist[currentAtomId];
1176  if (currentAtomName == "CA")
1177  {
1178 // Debug.Log ("Residue: " + entry.Key);
1179 // Debug.Log ("Found CA atom");
1180  MoleculeModel.atomsForEllipsoidsOrientationPerResidue[entry.Key] = currentAtomId;
1181  i = nbOfAtoms;
1182  }
1183  else
1184  {
1185  i++;
1186  }
1187  }
1188  }
1189  }
1190 
1194  public void findBonds()
1195  {
1196  // Find bonds associated with base atoms
1197  StickUpdate[] sticks = GameObject.FindObjectsOfType(typeof(StickUpdate)) as StickUpdate[];
1199  int nbOfSticks = sticks.Length;
1200  for (int i = 0; i < nbOfSticks; i++)
1201  {
1202  int atomNumber1 = sticks[i].atomnumber1;
1203  int atomNumber2 = sticks[i].atomnumber2;
1204 
1205  if ( MoleculeModel.atomsTypelist[atomNumber1].type == "X"
1206  || MoleculeModel.atomsTypelist[atomNumber2].type == "X"
1207  || MoleculeModel.atomsNamelist[atomNumber1] == "CY"
1208  || MoleculeModel.atomsNamelist[atomNumber2] == "CY")
1209  {
1210  MoleculeModel.bondsForReplacedAtoms.Add(sticks[i].gameObject);
1211  }
1212  }
1213  }
1214 
1215  public void UpdateEllipsoids()
1216  {
1217  foreach (KeyValuePair<int, GameObject> entry in MoleculeModel.ellipsoidsPerResidue)
1218  {
1219  GameObject Atom = entry.Value;
1220 
1221  Vector3 pos = computeEllipsoidPosition(entry.Key);
1222  Atom.transform.position = pos;
1223 
1224  Vector3 normal = computeEllipsoidNormal(entry.Key);
1225  Atom.transform.forward = normal;
1226 
1227  Atom.transform.LookAt(hballsGameObjects[MoleculeModel.atomsForEllipsoidsOrientationPerResidue[entry.Key]].transform.position, normal);
1228  }
1229  }
1230 
1234  public void GenerateEllipsoids()
1235  {
1236  findAtoms();
1237 
1238  findBonds();
1239 
1240  string currentResidueName;
1241 
1242  GameObject Atom;
1243 
1244  // Create ellipsoid game objects and bonds
1245  foreach (KeyValuePair<int, ArrayList> entry in MoleculeModel.residues)
1246  {
1247  Atom = GameObject.CreatePrimitive(PrimitiveType.Cube);
1248 
1249  Atom.GetComponent<Renderer>().material.shader = Shader.Find("FvNano/HyperBalls GL_D3D");
1250 
1251  Atom.AddComponent<BallUpdate>();
1252  BallUpdate comp = Atom.GetComponent<BallUpdate>();
1253 
1254  currentResidueName = MoleculeModel.atomsResnamelist[(int)entry.Value[0]];
1255 
1256  if (currentResidueName == "C") {
1257  Atom.GetComponent<Renderer>().material.SetColor("_Color", Color.yellow);
1258  }
1259  else if (currentResidueName == "G") {
1260  Atom.GetComponent<Renderer>().material.SetColor("_Color", Color.green);
1261  }
1262  else if (currentResidueName == "A") {
1263  Atom.GetComponent<Renderer>().material.SetColor("_Color", Color.red);
1264  }
1265  else if (currentResidueName == "U") {
1266  Atom.GetComponent<Renderer>().material.SetColor("_Color", new Color(0.7f, 0.7f, 0.98f));
1267  }
1268 
1269  comp.rayon = 1.0f;
1270  comp.SetRayonFactor(1.0f);
1271  Atom.GetComponent<Renderer>().material.SetFloat("_Rayon", 1.0f);
1272  Atom.GetComponent<Renderer>().material.SetVector("_Equation", new Vector4(1.0f, 1.0f, 1.0f, 1.0f));
1273 
1274  Atom.GetComponent<Renderer>().transform.localScale = new Vector3(3.0f, 1.5f, 4.0f);
1275 
1276 // Atom.AddComponent<Projector>();
1277  comp.enabled = true;
1278 
1279  MoleculeModel.ellipsoidsPerResidue[entry.Key] = Atom;
1280  MoleculeModel.ellipsoids.Add(Atom);
1281  }
1282 
1283  UpdateEllipsoids();
1284 
1285  ellipsoidsInitialized = true;
1287  }
1288 
1289  public void ActivateBases()
1290  {
1291  // Enable base atoms and bonds, then disable ellipsoids
1292 // GameObject[] baseAtoms = MoleculeModel.atomsByChar["X"];
1293 // for (int i = 0; i < baseAtoms.Length; i++)
1294 // {
1295 // baseAtoms[i].SetActive(true);
1296 // baseAtoms[i].renderer.enabled = true;
1297 // }
1298  foreach (KeyValuePair<int, int[]> entry in MoleculeModel.atomsForEllipsoidsPerResidue)
1299  {
1300  for(int i = 0; i < entry.Value.Length; i++)
1301  {
1302  if (allowedAtomsForPosition.Contains(MoleculeModel.atomsNamelist[entry.Value[i]])) {
1303  GameObject go = hballsGameObjects[entry.Value[i]] as GameObject;
1304  go.GetComponent<Renderer>().enabled = true;
1305  }
1306  }
1307  }
1308 
1309  for (int i = 0; i < MoleculeModel.bondsForReplacedAtoms.Count; i++)
1310  {
1311  // MoleculeModel.bondsForReplacedAtoms[i].SetActive(true);
1312  MoleculeModel.bondsForReplacedAtoms[i].GetComponent<Renderer>().enabled = true;
1313  }
1314  }
1315 
1316  public void DeactivateBases()
1317  {
1318  // Disable base atoms and bonds, then enable ellipsoids
1319 // GameObject[] baseAtoms = MoleculeModel.atomsByChar["X"];
1320 // for (int i = 0; i < baseAtoms.Length; i++)
1321 // {
1322  // baseAtoms[i].SetActive(false);
1323 // baseAtoms[i].renderer.enabled = false;
1324 // }
1325  foreach (KeyValuePair<int, int[]> entry in MoleculeModel.atomsForEllipsoidsPerResidue)
1326  {
1327  for(int i = 0; i < entry.Value.Length; i++)
1328  {
1329  if (allowedAtomsForPosition.Contains(MoleculeModel.atomsNamelist[entry.Value[i]])) {
1330  GameObject go = hballsGameObjects[entry.Value[i]] as GameObject;
1331  go.GetComponent<Renderer>().enabled = false;
1332  }
1333  }
1334  }
1335 
1336  for (int i = 0; i < MoleculeModel.bondsForReplacedAtoms.Count; i++)
1337  {
1338 // MoleculeModel.bondsForReplacedAtoms[i].SetActive(false);
1340  {
1341  MoleculeModel.bondsForReplacedAtoms[i].GetComponent<Renderer>().enabled = false;
1342  }
1343  }
1344  }
1345 
1346  public void ActivateEllipsoids()
1347  {
1348  if (ellipsoidsInitialized == false)
1349  return;
1350  for (int i = 0; i < MoleculeModel.ellipsoids.Count(); i++)
1351  {
1352  MoleculeModel.ellipsoids[i].GetComponent<Renderer>().enabled = true;
1353  }
1354  }
1355 
1356  public void DeactivateEllipsoids()
1357  {
1358  if (ellipsoidsInitialized == false)
1359  return;
1360  for (int i = 0; i < MoleculeModel.ellipsoids.Count(); i++)
1361  {
1362  MoleculeModel.ellipsoids[i].GetComponent<Renderer>().enabled = false;
1363  }
1364  }
1365 
1366  public void RenderEllipsoids()
1367  {
1368  DeactivateBases();
1369 
1371  }
1372 
1373  public void RenderAtoms()
1374  {
1376 
1377  ActivateBases();
1378  }
1379 
1380  public void SwitchRendering()
1381  {
1382  ellipsoidView = !ellipsoidView;
1383  if (ellipsoidView == true)
1384  {
1385  RenderEllipsoids();
1386  }
1387  else
1388  {
1389  RenderAtoms();
1390  }
1391  }
1392 
1393  public void ResetShininess(){
1394  for(int i=0; i<hballs.Length; i++)
1395  hballs[i].GetComponent<Renderer>().material.SetFloat("_Shininess", shininess);
1396 
1397  resetShininess = false;
1402  }
1403 
1404  // Returns the closest atom game object in space from a given position during an IMD simulation.
1406  BallUpdateHB closestAtom = hballs[0];
1407  BallUpdateHB tempAtom;
1408 
1409  SingleAtomSelection selection = new SingleAtomSelection();
1410 
1411  float minDist = Vector3.Distance(closestAtom.gameObject.transform.position, position);
1412  float tempDist;
1413 
1414  for (int i = 1; i < hballs.Length; i++) {
1415  tempAtom = hballs[i];
1416  tempDist = Vector3.Distance(tempAtom.gameObject.transform.position, position);
1417  if (tempDist < minDist) {
1418  minDist = tempDist;
1419  closestAtom = tempAtom;
1420  }
1421  }
1422 
1423  selection.go = closestAtom.gameObject;
1424  selection.pdbIndex = (int) closestAtom.number;
1425 
1426  return selection;
1427  }
1428 
1429  public override void showHydrogens(bool hide) {
1430  for (int j=0; j<hballs.Length; j++){
1431  if (hballs[j].tag=="H")
1432  hballs[j].GetComponent<Renderer>().enabled = !hide;
1433  }
1434  }
1435 
1436 }
static float highBFradius
Radius used for the highest B factor value.
override void ResetPositions()
Resets the positions of all balls.
override void SetColor(Color col, int atomNum)
Sets the color of a specific atom.
void ResetBrightness()
void ActivateBases()
GameObject[] hballsGameObjects
Definition: HBallManager.cs:78
void CreateMouseOversIMDSimulation()
static bool resetShininess
static float newScale
Definition: GUIDisplay.cs:144
static float shininess
override void SetColor(Color col, List< string > atom, string residue="All", string chain="All")
Sets the color of atoms.
void CreateMouseOvers()
Creates the mouse overs, needed when interactive mode is triggered.
static float depthFactor
Definition: HBallManager.cs:81
static float scale
Definition: StickUpdate.cs:79
static bool secondarystruct
Switch between all atoms and C-alpha trace or BFactor secondary structure representation.
Definition: UIData.cs:176
static bool resetShininess
Definition: HBallManager.cs:85
Vector3 computeEllipsoidPosition(int residueId)
Compute an ellipsoid position based on its associated atoms
override void ResetIMDSimulationPositions()
Resets the positions of all balls.
static string[] allowedAtomsForPosition
Definition: HBallManager.cs:74
static float shininess
override void showHydrogens(bool hide)
void SetTexture(string resource_name, int atomNum)
Sets the MatCap texture for one atom.
override void DestroyAll()
Disable and destroys all the Hyperballs and Sticks.
static float oldshrink
Definition: StickUpdate.cs:77
static bool isFileLoaded
Definition: UIData.cs:115
static float shininess
Definition: HBallManager.cs:83
static bool resetBrightness
static float oldscale
Definition: StickUpdate.cs:80
void UpdateEllipsoids()
void DestroyMouseOvers()
Destroys the mouse overs, needed when interactive mode is turned off.
static FFType ffType
Definition: UIData.cs:241
void ResetColors()
Resets the colors of all balls and sticks.
static List< string > atomsNamelist
The name of each atom.
static float oldDepthFactor
Definition: HBallManager.cs:86
static List< string > atomsChainList
The chain of each atom.
static List< AtomModel > atomsTypelist
The type of each atom.
static bool ellipsoidsInitialized
Definition: HBallManager.cs:91
static bool resetColors
Definition: BallUpdate.cs:73
static List< Vector3 > atomsIMDSimulationLocationlist
The coordinates of each atom, simulated through an IMD simulation.
void DeactivateBases()
override void SetRadii(List< string > atom, string residue="All", string chain="All")
Changes the scale of the atoms.
void DeactivateEllipsoids()
override void ToggleDistanceCueing(bool enabling)
Initializes the list of sticks.
int atomnumber1
Definition: StickUpdate.cs:85
Color atomcolor
Definition: BallUpdate.cs:86
static BallUpdateHB[] hballs
Definition: HBallManager.cs:77
bool ellipsoidViewEnabled()
Definition: HBallManager.cs:92
void SetTexture(Texture texture, List< string > atom, string residue="All", string chain="All")
Sets the texture of atoms.
int atomnumber2
Definition: StickUpdate.cs:86
static string structType
The current rendered structure type.
static List< GameObject > bondsForReplacedAtoms
long number
Definition: BallUpdate.cs:84
void RenderEllipsoids()
float rayon
Definition: BallUpdate.cs:78
static bool resetBrightness
Definition: HBallManager.cs:84
void RenderAtoms()
static void setCurrentAtomManager(GenericManager manager)
Definition: UnityMolMain.cs:63
void StartPhysicsManagement()
static void SetTexture(Texture text)
Definition: BallUpdateHB.cs:85
void GenerateEllipsoids()
Generates the ellipsoids based on coarse-grain model
Vector3 computeEllipsoidOrientation(int residueId)
static bool resetBrightness
static Dictionary< int, GameObject > ellipsoidsPerResidue
The ellipsoids per residue.
!WiP Includes FLAGS of GUI.
Definition: UIData.cs:78
override GameObject GetBall(int id)
Gets the GameObject from hballs at the position "id".
override void DisableShadows()
static bool wasInteractiveColored
Definition: HBallManager.cs:88
static void ChangeRepresentation(UIData.AtomType newAtomType, UIData.BondType newBondType=UIData.BondType.nobond)
static bool resetShininess
static BondType bondtype
Definition: UIData.cs:141
!WiP manage GUI, and provide static strings for the GUI.
Definition: GUIDisplay.cs:94
override void ResetRadii()
Resets the radii of all balls when it is changed via the GUI.
static List< Color > atomsColorList
The color of each atom.
void findBonds()
Find bonds to be hidden to render ellipsoids
static float radiusFactor
Definition: BallUpdate.cs:81
static string file_extension
Definition: GUIDisplay.cs:121
static Dictionary< int, ArrayList > residues
The residues.
static bool ellipsoidView
Definition: HBallManager.cs:90
void SetTexture(string resource_name, List< string > atom, string residue="All", string chain="All")
Sets the texture of one atom.
void ActivateEllipsoids()
static float oldRadiusFactor
Definition: BallUpdate.cs:82
Vector3 computeEllipsoidNormal(int residueId)
Compute the plane normal for an ellipsoid (given a residue)
void DestroyMouseOversIMDSimulation()
static bool bondsReadyToBeReset
Definition: BallUpdate.cs:75
override void SetRadii(int id)
Changes the scale for Atom selection.
override void EnableShadows()
static bool toggleGray
Definition: UIData.cs:125
static bool mouseOvers
Definition: HBallManager.cs:87
void MoveNetworkNodes()
Moves the network nodes when the depth factor is changed.
static AtomType atomtype
Definition: UIData.cs:139
static List< string > atomsResnamelist
The name of the residue to which each atom belongs.
void SwitchRendering()
static bool quickSelection
Definition: GUIDisplay.cs:157
static List< GameObject > ellipsoids
Contiguous (really?) list of ellipsoids
void ExitInteractive()
static bool adjustRadii
void ResetShininess()
void SetTexture(Texture texture, int atomNum)
Sets the MatCap texture for one atom.
static Dictionary< int, int > atomsForEllipsoidsOrientationPerResidue
override void Init()
Initalizes this instance.
Definition: HBallManager.cs:99
override void DisableRenderers()
Disables the renderers for the entire set of balls and sticks.
static bool isHBallLoaded
Definition: UIData.cs:105
static bool xgmml
Definition: HBallManager.cs:80
void ManagePhysics()
Manages the rigidbody physics.
static float brightness
Definition: HBallManager.cs:82
static float shrink
Definition: StickUpdate.cs:76
Color GetColor(Vector3 pos)
Gets the color of the atom at the location "pos".
void findAtoms()
Find atoms used to compute the ellipsoid plane
static Dictionary< int, int[]> atomsForEllipsoidsPerResidue
The atoms per ellipsoids per residue for HiRERNA rendering Key is the residue id Value is an array of...
override void EnableRenderers()
Enables the renderers for the entire set of balls and sticks.
Definition: GUIDisplay.cs:66
static List< float > atomsLocalScaleList
static bool resetRadii
Definition: BallUpdate.cs:76
static List< float[]> atomsLocationlist
The coordinates of each atom.
SingleAtomSelection getClosestAtomGameObject(Vector3 position)