UnityMol  0.9.6-875
UnityMol viewer / In developement
LoadTypeGUI.cs
Go to the documentation of this file.
1 
66 
67 namespace UI{
68  using UnityEngine;
69  using System.Collections;
70  using System.Collections.Generic;
71  using Molecule.Model;
72  using Molecule.View;
73  using Reorient;
74  using OptimalView;
75 
76  // Can't be static because GUIMoleculeController isn't, thought it probably ought to be.
78 
79 
80 
81  // Note : LoadTypeGUI and GUIDisplay are separated randomly. Don't know why some UI features are in one or another. Here, it forces us to set this public.
82  // TODO : Fusion LoadTypeGUI and GUIDisplay ? (and GUIMoleculeController ???) or at least do some cleaning in those
83 
84 
85  // TODO : Make C-Alpha trace and his color/texture work again
86 /* // Textures for buttons in AdvOptions
87  private static Texture2D chainATex;
88  private static Texture2D chainBTex;
89  private static Texture2D chainCTex;
90  private static Texture2D chainDTex;
91  private static Texture2D chainETex;
92  private static Texture2D chainFTex;
93  private static Texture2D chainGTex;
94  private static Texture2D chainHTex;
95 
96  // Colors for the chains
97  private static ColorObject chainAColor = new ColorObject(Color.white);
98  private static ColorObject chainBColor = new ColorObject(Color.white);
99  private static ColorObject chainCColor = new ColorObject(Color.white);
100  private static ColorObject chainDColor = new ColorObject(Color.white);
101  private static ColorObject chainEColor = new ColorObject(Color.white);
102  private static ColorObject chainFColor = new ColorObject(Color.white);
103  private static ColorObject chainGColor = new ColorObject(Color.white);
104  private static ColorObject chainHColor = new ColorObject(Color.white);
105 
106 
107  // Color arrays for the button Textures
108  private static Color[] chainAColors = new Color[200];
109  private static Color[] chainBColors = new Color[200];
110  private static Color[] chainCColors = new Color[200];
111  private static Color[] chainDColors = new Color[200];
112  private static Color[] chainEColors = new Color[200];
113  private static Color[] chainFColors = new Color[200];
114  private static Color[] chainGColors = new Color[200];
115  private static Color[] chainHColors = new Color[200];
116 
117  // Set to true when the chainXColors arrays have been initalized
118  private static bool chainColorsInit = false ;
119 */
120 
121 
129  public static void SetTitle(string s) {
130  GUILayout.BeginHorizontal();
131  GUILayout.FlexibleSpace();
132  GUILayout.Label(s);
133  GUILayout.FlexibleSpace();
134  GUILayout.EndHorizontal();
135  }
136 
137 
153  public static bool SetTitleExit(string s) {
154  GUILayout.BeginHorizontal();
155  GUILayout.FlexibleSpace();
156 
157  bool keepOpen = true ;
158 
159  GUILayout.Label(s);
160  GUILayout.FlexibleSpace();
161  if(GUILayout.Button(new GUIContent("X", "Close window")))
162  keepOpen = false;
163 
164  GUILayout.EndHorizontal();
165 
166  return keepOpen;
167  }
168 
169 
170 
171  // public static void showHydrogens(bool show){
172  // int i=0;
173  // for (i=0; i<HBallManager.hballs.Length; i++){
174  // if (HBallManager.hballs[i].tag=="H"){
175  // HBallManager.hballs[i].GetComponent<Renderer>().enabled=show;
176  // }
177  // // We want to check atoms and bond in one loop.
178  // //so we check if we not over the size of the bond list
179  // if (i<HStickManager.sticks.Length){
180  // // if ((HStickManager.sticks[i].atompointer2.tag == "H") ||
181  // // (HStickManager.sticks[i].atompointer1.tag == "H"))
182  // if(MoleculeModel.atomsTypelist[HStickManager.sticks[i].atomnumber1].type == "H" ||
183  // MoleculeModel.atomsTypelist[HStickManager.sticks[i].atomnumber2].type == "H")
184 
185  // HStickManager.sticks[i].GetComponent<Renderer>().enabled=show;
186  // }
187  // }
188  // //If we didn't finish to check the bond list (more bond than atoms)
189  // //we check the end of the list.
190  // while(i<HStickManager.sticks.Length){
191  // // if ((HStickManager.sticks[i].atompointer2.tag == "H") ||
192  // // (HStickManager.sticks[i].atompointer1.tag == "H"))
193  // if(MoleculeModel.atomsTypelist[HStickManager.sticks[i].atomnumber1].type == "H" ||
194  // MoleculeModel.atomsTypelist[HStickManager.sticks[i].atomnumber2].type == "H")
195 
196  // HStickManager.sticks[i].GetComponent<Renderer>().enabled=show;
197  // i++;
198  // }
199  // }
200 
201 
202 
203 
204 
205 
213  private static Texture2D MakeButtonTex(Texture2D tex) {
214  if (tex)
215  return(tex);
216  else
217  return (new Texture2D(20,10,TextureFormat.ARGB32,false));
218  }
219 
220 
221 
222 
223 
242  public static bool InDeadZone(Rect rect, Vector3 mpos)
243  {
244  GUIStyle currentStyle = GUI.skin.label;
245  GUIContent strContent = new GUIContent("str"); // Creating a GUIContent of type string. Probably not the cleanest way.
246  float deadZone = currentStyle.CalcSize(strContent).y; // Getting its height in pixels.
247  deadZone *= 3.0f ; // Making it a bit bigger. After all, the title label doesn't start right at the top of the window.
248 
249  SurfaceOldGUI.cutPlaneIsDraggable = (mpos.y - rect.yMin < deadZone); // if true, we're in the dead zone
251  }
252 
253 
254 
262  public static void MainFun (int a) {
263 
264 
265 // GUILayout.BeginVertical();
266 
267  GUILayout.BeginHorizontal();
268 // if (GUI.Button (new Rect(300,5,40,10),new GUIContent ("Open", "Open the File Open dialogue"))) {
269  if (GUILayout.Button (new GUIContent ("PDB File", "Open the File Open dialogue"))) {
270  if (showOpenMenu)
271  showOpenMenu = false;
272  else {
273  showOpenMenu = true;
274  showReactionMenu = false;
275  showAnimationMenu = false;
276  showAtomMenu = false;
281  showSetAtomScales = false;
282  showPanelsMenu = false;
283  GUIDisplay.m_texture = false;
284  showSurfaceButton = false;
289  showAtomsExtendedMenu = false;
290  showResiduesMenu = false;
291  showChainsMenu = false;
293  SugarOldGUI.showSugarChainMenu=false; //T TEST
294  showArtemisMenu = false;
295  showHiRERNAMenu = false;
296  showWebContestMenu = false;
297  showTestMenu = false;
298  }
299  m_colorPicker = null ;
300 
301 
302  }
303 
304  //Aurelien : displays the reaction menu
305  if (GUILayout.Button (new GUIContent ("Reaction", "Opens reaction menu")))
306  {
307  if (showReactionMenu)
308  showReactionMenu = false;
309  else{
310  showOpenMenu = false;
311  showAtomMenu = false;
312  showAnimationMenu = false;
316  //menuField_show = false;
317  showSetAtomScales = false;
319  GUIDisplay.m_texture = false;
320  // atomtype_show=false;
321  // bondtype_show=false;
322  // effecttype_show=false;
323  //SurfaceButton_show = false;
324  //backgroundtype_show = false;
325  // metaphortype_show=false;
326  // ParamFieldLine_show=false;
327  //SurfaceCut_show = false;
328  //SurfaceMobileCut_show = false;
329  //surface_texture_show = false;
330  showReactionMenu = true;
331  }
332  m_colorPicker = null ;
333 
334  }
335 
336  //Aurelien : displays the animation menu
337  if (GUILayout.Button (new GUIContent ("Animation", "Opens animation menu")))
338  {
339  if (showAnimationMenu)
340  showAnimationMenu = false;
341  else{
342  showOpenMenu = false;
343  showReactionMenu = false;
344  showAtomMenu = false;
348  //menuField_show = false;
349  showSetAtomScales = false;
351  GUIDisplay.m_texture = false;
352  // atomtype_show=false;
353  // bondtype_show=false;
354  // effecttype_show=false;
355  //SurfaceButton_show = false;
356  //backgroundtype_show = false;
357  // metaphortype_show=false;
358  // ParamFieldLine_show=false;
359  //SurfaceCut_show = false;
360  //SurfaceMobileCut_show = false;
361  //surface_texture_show = false;
362  showAnimationMenu = true;
363  }
364  m_colorPicker = null ;
365 
366  }
367 
369  GUI.enabled = false;
370  if (GUILayout.Button (new GUIContent ("Atoms", "Open the Atom appearance dialogue"))) {
371  if (showAtomMenu) { // already open, we close it
372  showAtomMenu = false;
373  GUIDisplay.m_texture = false ; // this is pointless when the atom menu is closed
374  showSetAtomScales = false;
375  } else {
376  showAtomMenu = true;
377  showOpenMenu = false;
378  showReactionMenu = false;
379  showAnimationMenu = false;
380  }
381  m_colorPicker = null ;
382 
383  }
384 
385  if(GUILayout.Button(new GUIContent("Sec. Structures", "Open the secondary structures dialogue"))){
386  m_colorPicker = null ;
388  }
389 
390  if (GUILayout.Button (new GUIContent ("Surface", "Open the Surface rendering dialogue"))) {
392  m_colorPicker = null ;
393 
394  }
395  //No bfactor option in this version
396 /* if (GUI.Button (new Rect (240 + 23, 2, 80, 20), new GUIContent ("Bfactor", "Open the Bfactor settings dialogue")))
397  {
398  if (showBfactorMenu) {
399  showBfactorMenu = false;
400  showSurfaceCut = false;
401  showSurfaceMobileCut = false;
402  m_colorpick_fieldline = null;
403  showSurfaceTexture = false;
404  ;
405  m_colorpick_Surface = null;
406  } else {
407  showBfactorMenu = true;
408  showSurfaceMenu = false;
409  showOpenMenu = false;
410 
411  }
412  if (!UIData.toggleBfac) {
413  UIData.toggleBfac = true;
414  UIData.toggleSurf = false;
415  pdbGen = false;
416  }
417  }
418 */
420  GUI.enabled = false;
421  if (GUILayout.Button (new GUIContent ("Electrostat.", "Open the electrostatics field lines dialogue"))) {
424  showGrayColor = false;
425  } else {
427  showOpenMenu = false;
428  showReactionMenu = false;
429  }
430  m_colorPicker = null ;
431 
432  }
433  GUI.enabled = true ;
434 
436  GUI.enabled = false;
437 
438  if (GUILayout.Button(new GUIContent("Advanced", "Opens the advanced options menu"))){
439  m_colorPicker = null ;
441  }
442 
443  if (GUILayout.Button (new GUIContent ("Guided Nav.", "Opens the guided navigation menu"))){
444  m_colorPicker = null ;
446  }
447 
448  if (GUILayout.Button(new GUIContent("Sugar", "Opens the Sugar visualisation menu"))) {//T TEST
450  m_colorPicker = null ;
451  }
452 
453  if (GUILayout.Button (new GUIContent("Artemis", "Configure and run a molecular dynamics simulation"))) {
455  m_colorPicker = null ;
456  }
457 
458  if (GUILayout.Button (new GUIContent("HiRE-RNA", "Setup HiRE-RNA visualization options."))) {
460  m_colorPicker = null ;
461  }
462 
463  if (GUILayout.Button (new GUIContent("Contest", "Participe to the HiRE-RNA Contest."))) {
465  m_colorPicker = null ;
466  }
467 
468  if (GUILayout.Button (new GUIContent("Reset", "Resets the molecule to its original position"))) {
469  m_colorPicker = null ;
470  maxCamera fixeCam;
471  fixeCam = scenecontroller.GetComponent<maxCamera> ();
472  fixeCam.ToCenter();
473  if(UIData.atomtype == UIData.AtomType.hyperball){
474  GameObject hbManagerObj = GameObject.FindGameObjectWithTag("HBallManager");
475  HBallManager hbManager = hbManagerObj.GetComponent<HBallManager>();
476  hbManager.ResetPositions();
477  }
478 
479  // Resets the light parent and position.
480  // /!\ Warning: Assumes the presence of a single light called "Directional light" in the scene.
481  Transform lightrans;
482  lightrans = GameObject.Find("Directional light").transform;
483  lightrans.parent = mainCamera.transform;
484  lightrans.localPosition = Vector3.zero;
485  lightrans.localRotation = Quaternion.identity;
486  UIData.lightStop = false;
488  }
489 
490 
491  GUILayout.EndHorizontal();
492  GUI.enabled = true;
493 
494  //GUILayout.EndVertical();
495 
496  // generate the cam target.
497  if (!toggle_NA_MAXCAM && scenecontroller.GetComponent<maxCamera> ().enabled) {
498  scenecontroller.GetComponent<maxCamera> ().enabled = false;
499  scenecontroller.transform.rotation = NA_SCCROT;
500  scenecontroller.transform.position = NA_SCCPOS;
501  } else if (toggle_NA_MAXCAM && !scenecontroller.GetComponent<maxCamera> ().enabled)
502  scenecontroller.GetComponent<maxCamera> ().enabled = true;
503 
504  if (!toggle_NA_AUTOMOVE && scenecontroller.GetComponent<maxCamera> ().automove) {
505  scenecontroller.GetComponent<maxCamera> ().automove = false;
506  } else if (toggle_NA_AUTOMOVE && !scenecontroller.GetComponent<maxCamera> ().automove) {
507  scenecontroller.GetComponent<maxCamera> ().automove = true;
508  }
509  if (Event.current.type == EventType.Repaint)
510  MoleculeModel.newtooltip = GUI.tooltip;
511 
512  } // End of MainFun
513 
514 
515 
516 
517 
518 
519 /*
520  private static string hideOrShowAtoms() {
521  if (showAtoms)
522  return("Hide atoms");
523  else
524  return("Show atoms");
525  }
526 
527 
531  private static void ToggleAtoms() {
532  GUILayout.BeginHorizontal();
533  if (GUILayout.Button(new GUIContent(hideOrShowAtoms(), "This button enables/disables atoms"))) {
534  showAtoms = !showAtoms;
535  if(showAtoms)
536  globalRadius = prevRadius ;
537  else {
538  prevRadius = globalRadius ;
539  globalRadius = 0f;
540  }
541  }
542  GUILayout.EndHorizontal();
543  } // End of ToggleAtoms
544 */
545 
546 
547 
548 
549 
550  }
551 }
override void ResetPositions()
Resets the positions of all balls.
void ToCenter()
Definition: maxCamera.cs:427
static bool showElectrostaticsMenu
bool enabled
Definition: ColorPicker.cs:98
static void openCloseSurfaceMenu()
Opens or closes the surface menu.
static bool lightStop
Definition: UIData.cs:133
static ColorPicker m_colorPicker
bool automove
Definition: maxCamera.cs:89
static bool InDeadZone(Rect rect, Vector3 mpos)
Returns true if the mouse cursor is lower than the Window title.
Definition: LoadTypeGUI.cs:242
static bool showSurfaceMenu
static Texture2D MakeButtonTex(Texture2D tex)
Creates a new texture of the appropriate size for a button, unless it already exists.
Definition: LoadTypeGUI.cs:213
static bool cutPlaneIsDraggable
static bool showBfactorMenu
static bool showSurfaceCut
static bool showSugarChainMenu
Definition: SugarOldGUI.cs:20
!WiP Includes FLAGS of GUI.
Definition: UIData.cs:78
static void MainFun(int a)
Defines the main menu of the GUI.
Definition: LoadTypeGUI.cs:262
static bool SetTitleExit(string s)
This is a somewhat odd but very convenient function.
Definition: LoadTypeGUI.cs:153
!WiP manage GUI, and provide static strings for the GUI.
Definition: GUIDisplay.cs:94
static bool fieldLineColorGradient
static void SetTitle(string s)
Sets the title of the current window.
Definition: LoadTypeGUI.cs:129
static AtomType atomtype
Definition: UIData.cs:139
static bool showSurfaceMobileCut
static bool m_texture
Definition: GUIDisplay.cs:125
static bool hasMoleculeDisplay
Definition: UIData.cs:96
static bool showSurfaceTexture
static bool showSecStructMenu
Triggers the secondary structure menu display.
Definition: GUIDisplay.cs:66