UnityMol  0.9.6-875
UnityMol viewer / In developement
SecondaryStructureOldGUI.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using System.Collections;
3 using UI;
4 using Molecule.Model;
5 using Molecule.View;
6 
9  public static bool showSecStructMenu = false;
10 
12  public static bool toggle_SEC_STRUCT = false;
13 
16  public static string structType = "All atoms";
17 
19  public static float highBFradius = 1.0f;
20 
22  public static bool isRescale = false;
23 
25  public static bool ssColChain = false;
26 
28  public static bool ssColStruct = false;
29 
31  public static bool ssDivCol = false;
32 
33  // Default colors for buttons in secondary structure menu
34  public static Color[] helixButtonNew = new Color[200];
35  public static Texture2D helixButton = new Texture2D(20,10,TextureFormat.ARGB32,false);
36  public static Color[] sheetButtonNew = new Color[200];
37  public static Texture2D sheetButton = new Texture2D(20,10,TextureFormat.ARGB32,false);
38  public static Color[] coilButtonNew = new Color[200];
39  public static Texture2D coilButton = new Texture2D(20,10,TextureFormat.ARGB32,false);
40 
41  public static Texture2D chainbuttonA = new Texture2D(20,10,TextureFormat.ARGB32,false);
42  public static Color[] chainbuttonAnew = new Color[200];
43  public static Texture2D chainbuttonB = new Texture2D(20,10,TextureFormat.ARGB32,false);
44  public static Color[] chainbuttonBnew = new Color[200];
45  public static Texture2D chainbuttonC = new Texture2D(20,10,TextureFormat.ARGB32,false);
46  public static Color[] chainbuttonCnew = new Color[200];
47  public static Texture2D chainbuttonD = new Texture2D(20,10,TextureFormat.ARGB32,false);
48  public static Color[] chainbuttonDnew = new Color[200];
49  public static Texture2D chainbuttonE = new Texture2D(20,10,TextureFormat.ARGB32,false);
50  public static Color[] chainbuttonEnew = new Color[200];
51 
58  public static void SecStructMenu(int a) {
60  bool ssToggled = toggle_SEC_STRUCT;
61 
62  GUILayout.BeginHorizontal();
63  GUILayout.Box("Secondary structures");
64  GUILayout.EndHorizontal();
65 
66  GUILayout.BeginHorizontal();
67  toggle_SEC_STRUCT = UIData.hasMoleculeDisplay && GUILayout.Toggle(toggle_SEC_STRUCT,
68  new GUIContent("Enable Secondary structures", "Switch between all-atoms and secondary structures representation"));
69  // MVB: changed the behavior so that when enabling SS, HB molecule is always hidden and when disabling SS, HB is always shown
70  if(!ssToggled && toggle_SEC_STRUCT) { // enabling the ribbons
72  //LoadTypeGUI.toggle_NA_HIDE = !LoadTypeGUI.toggle_NA_HIDE;
76  } else {
77  if (ssToggled && !toggle_SEC_STRUCT) { // destroying the ribbons
78  //LoadTypeGUI.toggle_NA_HIDE = !LoadTypeGUI.toggle_NA_HIDE;
83 
84  }
85  }
86  GUILayout.EndHorizontal();
87 
88 
89 
90  // Bugs otherwise.
93  return;
94  }
95 
96  int labelWidth = (int) (0.45f * Rectangles.secStructMenuWidth);
97  int sliderWidth = (int) (0.50f * Rectangles.secStructMenuWidth);
98 
99  GUILayout.BeginHorizontal();
101  "Helix Width: " + Ribbons.ribbonWidth[0].ToString("0.00"), "", true, sliderWidth, labelWidth, true);
102  GUILayout.EndHorizontal();
103 
104  GUILayout.BeginHorizontal();
106  "Sheet Width: " + Ribbons.ribbonWidth[1].ToString("0.00"), "", true, sliderWidth, labelWidth, true);
107  GUILayout.EndHorizontal();
108 
109  GUILayout.BeginHorizontal();
111  "Coil Width: " + Ribbons.ribbonWidth[2].ToString("0.00"), "", true, sliderWidth, labelWidth, true);
112  GUILayout.EndHorizontal();
113 
114  GUILayout.BeginHorizontal();
116  "Thickness: " + Ribbons.THICKNESS.ToString("0.00"), "", true, sliderWidth, labelWidth, true);
117  GUILayout.EndHorizontal();
118 
119  GUILayout.BeginHorizontal();
121  "Helix diameter: " + Ribbons.HELIX_DIAM.ToString("0.00"), "", true, sliderWidth, labelWidth, true);
122  GUILayout.EndHorizontal();
123 
124  GUILayout.BeginHorizontal();
126  "Arrow width: " + Ribbons.ARROW_WIDTH.ToString("0.00"), "", true, sliderWidth, labelWidth, true);
127  GUILayout.EndHorizontal();
128 
129  GUILayout.BeginHorizontal ();
130  //UIData.ssColStruct = UIData.hasMoleculeDisplay && GUILayout.Toggle(UIData.ssColStruct,
131  //new GUIContent("Color by Structure", "Color cartoon representation by structure"));
132  if(GUILayout.Button(new GUIContent("Color by ss")))
134  GUILayout.EndHorizontal();
135 
137  GUILayout.BeginHorizontal();
138  GUILayout.Label("Helix Color :");
139  GUILayout.FlexibleSpace();
140  if(GUILayout.Button(helixButton,GUILayout.MinWidth(100),GUILayout.MinHeight(20))){
142  }
143  GUILayout.EndHorizontal();
144 
145  GUILayout.BeginHorizontal();
146  GUILayout.Label("Sheet Color :");
147  GUILayout.FlexibleSpace();
148  if(GUILayout.Button(sheetButton,GUILayout.MinWidth(100),GUILayout.MinHeight(20))){
150  }
151  GUILayout.EndHorizontal();
152 
153  GUILayout.BeginHorizontal();
154  GUILayout.Label("Coil Color :");
155  GUILayout.FlexibleSpace();
156  if(GUILayout.Button(coilButton,GUILayout.MinWidth(100),GUILayout.MinHeight(20))){
158  }
159  GUILayout.EndHorizontal();
160  }
161 
162  //C.R Test color by chains
163  GUILayout.BeginHorizontal ();
164  //UIData.ssColChain = UIData.hasMoleculeDisplay && GUILayout.Toggle(UIData.ssColChain,
165  //new GUIContent("Color by Chain", "Color cartoon representation by chain"));
166  if(GUILayout.Button(new GUIContent("Color by chain")))
168  GUILayout.EndHorizontal();
169 
171 
172  if(UIData.isGLIC){
173  GUILayout.BeginHorizontal();
175  new GUIContent("Show domains", "Color by domains"));
176  GUILayout.EndHorizontal();}
177 
178  GUILayout.BeginHorizontal();
179  GUILayout.Label("Chain A :");
180  if(GUILayout.Button(chainbuttonA,GUILayout.MinWidth(100),GUILayout.MinHeight(20))){
182  }
183  GUILayout.EndHorizontal();
184 
185  GUILayout.BeginHorizontal();
186  GUILayout.Label("Chain B :");
187  if(GUILayout.Button(chainbuttonB,GUILayout.MinWidth(100),GUILayout.MinHeight(20))){
189  }
190  GUILayout.EndHorizontal();
191 
192  GUILayout.BeginHorizontal();
193  GUILayout.Label("Chain C :");
194  if(GUILayout.Button(chainbuttonC,GUILayout.MinWidth(100),GUILayout.MinHeight(20))){
196  }
197  GUILayout.EndHorizontal();
198 
199  GUILayout.BeginHorizontal();
200  GUILayout.Label("Chain D :");
201  if(GUILayout.Button(chainbuttonD,GUILayout.MinWidth(100),GUILayout.MinHeight(20))){
203  }
204  GUILayout.EndHorizontal();
205 
206  GUILayout.BeginHorizontal();
207  GUILayout.Label("Chain E :");
208  if(GUILayout.Button(chainbuttonE,GUILayout.MinWidth(100),GUILayout.MinHeight(20))){
210  }
211  GUILayout.EndHorizontal();
212  }
213 
214  GUILayout.BeginHorizontal();
215  GUI.enabled = toggle_SEC_STRUCT;
216 
217  // Ribbons color is changed by recreating them from scratch.
218  if(GUILayout.Button(new GUIContent("Apply changes"))) {
219  // Destroying the ribbons
222  // Recreating them
225  }
226  GUI.enabled = true;
227  GUILayout.EndHorizontal();
228 
229  /*
230  // ---------- C-ALPHA TRACE ----------
231  GUILayout.BeginHorizontal();
232  GUILayout.Box("C-alpha trace");
233  GUILayout.EndHorizontal();
234 
235  GUILayout.BeginHorizontal();
236  ChooseStructure();
237  GUILayout.EndHorizontal ();
238  GUILayout.BeginHorizontal();
239  ChooseSmoothness();
240  GUILayout.EndHorizontal (); */
241 
242  //C.R
243 
244  GUILayout.BeginHorizontal();
245  GUILayout.Box("Bfactor Representation");
246  GUILayout.EndHorizontal();
247 
248  GUILayout.BeginHorizontal();
250  GUILayout.EndHorizontal ();
251  GUILayout.BeginHorizontal();
253  GUILayout.EndHorizontal ();
254  GUILayout.BeginHorizontal();
255  MinMaxChoice ();
256  GUILayout.EndHorizontal ();
257  GUILayout.BeginHorizontal();
258  SetHighBFSlider ();
259  GUILayout.EndHorizontal ();
260 
261  GUI.DragWindow();
262  }
263 
264  private static string structTypeButtonLabel(string st) {
265  if(st == "All atoms")
266  return("C-alpha trace");
267  else
268  return("All atoms");
269  }
270 
271  private static string structTypeButtonLabel_BF(string st) {
272  if(st == "All atoms")
273  return("B Factor");
274  else
275  return("All atoms");
276  }
277 
278  /*
282  private static void ChooseStructure () {
283  GUILayout.BeginHorizontal ();
284 
285  GUI.enabled = (MoleculeModel.CatomsLocationlist.Count > 2);
286  if (GUILayout.Button (new GUIContent (structTypeButtonLabel(structType), "Switch to " + structTypeButtonLabel(structType)))) {
287 
288  if (UIData.secondarystruct) {
289  UIData.secondarystruct = false;
290  structType = "All atoms";
291  UIData.changeStructure = true;
292  GUIMoleculeController.globalRadius = 0.40f;
293  GUIMoleculeController.shrink = 0.50f;
294  } else {
295  UIData.secondarystruct = true;
296  structType = "C-alpha trace";
297  if (UIData.toggle_bf){
298  AlphaChainSmoother.ReSpline ();
299  DisplayMolecule.InitManagers();
300  UIData.toggle_bf = false;
301  }
302  UIData.changeStructure = true;
303  GUIMoleculeController.globalRadius = 0.25f;
304  GUIMoleculeController.shrink = 0.0001f;
305  }
306  DisplayMolecule.DestroyAtomsAndBonds();
307 
308  LoadTypeGUI.SetAtomStyle();
309  }
310 
311  GUI.enabled = true;
312  GUILayout.EndHorizontal ();
313  if (Event.current.type == EventType.Repaint)
314  MoleculeModel.newtooltip = GUI.tooltip;
315  }
316  */
320  private static void ChooseStructure_BF () {
321  GUILayout.BeginHorizontal ();
322 
323  GUI.enabled = (MoleculeModel.CatomsLocationlist.Count > 2);
324  if (GUILayout.Button (new GUIContent (structTypeButtonLabel_BF(structType), "Switch to " + structTypeButtonLabel_BF(structType)))) {
325  if (UIData.secondarystruct) {
326  UIData.secondarystruct = false;
327  structType = "All atoms";
328  UIData.changeStructure = true;
331  } else {
332  UIData.secondarystruct = true;
333  structType = "B Factor";
334  // DisplayMolecule.DestroyAtomsAndBonds();
335  UIData.toggle_bf = true;
337  UIData.changeStructure = true;
339  RepresentationOldGUI.shrink = 0.0001f;
340 
341  // UIData.resetDisplay = true;
342  }
343 
344  //if (Event.current.type == EventType.Repaint)
345  //MoleculeModel.newtooltip = GUI.tooltip;
347 
349  }
350  GUI.enabled = true;
351  GUILayout.EndHorizontal ();
352  if (Event.current.type == EventType.Repaint)
353  MoleculeModel.newtooltip = GUI.tooltip;
354  }
355  /*
356 
360  private static void ChooseSmoothness () {
361  bool isChain = (structType == "C-alpha trace");
362  int labelWidth = (int) (0.35f * Rectangles.secStructMenuWidth);
363  int sliderWidth = (int) (0.55f * Rectangles.secStructMenuWidth);
364  int newSmooth;
365  newSmooth = (int) GUIMoleculeController.LabelSlider(GenInterpolationPoint.smoothnessFactor, 1f, 15f,
366  "Smoothness", "Smoothness of the carbon alpha chain spline", isChain, sliderWidth, labelWidth, true);
367  GUI.enabled = true;
368 
369  if(newSmooth != GenInterpolationPoint.smoothnessFactor) {
370  GenInterpolationPoint.smoothnessFactor = newSmooth;
371  DisplayMolecule.DestroyAtomsAndBonds();
372  AlphaChainSmoother.ReSpline();
373  DisplayMolecule.InitManagers();
374  UIData.changeStructure = true;
375  }
376 
377  if (Event.current.type == EventType.Repaint)
378  MoleculeModel.newtooltip = GUI.tooltip;
379  } // End of ChooseSmoothness
380  */
384  private static void ChooseSmoothness_BF () {
385  bool isChain = (structType == "B Factor");
386  int labelWidth = (int) (0.35f * Rectangles.secStructMenuWidth);
387  int sliderWidth = (int) (0.55f * Rectangles.secStructMenuWidth);
388  int newSmooth;
390  "Smoothness", "Smoothness of the Bfactor color/radius Representation", isChain, sliderWidth, labelWidth, true);
391  GUI.enabled = true;
392 
393  if(newSmooth != GenInterpolationPoint_BF.smoothnessFactor) {
397  UIData.changeStructure = true;
398 
399  }
400 
401  if (Event.current.type == EventType.Repaint)
402  MoleculeModel.newtooltip = GUI.tooltip;
403  } // End of ChooseSmoothness
404 
408  private static void SetHighBFSlider(){
409 
410  bool isChain = (structType == "B Factor");
411  int labelWidth = (int) (0.35f * Rectangles.secStructMenuWidth);
412  int sliderWidth = (int) (0.55f * Rectangles.secStructMenuWidth);
413 
414  GUI.enabled = true;
415 
416  highBFradius = GUIMoleculeController.LabelSlider(highBFradius, 1.0f, 2.0f, "High value radius", "Set highest Bfactor radius value", isChain, sliderWidth, labelWidth, true);
417 
418  if (GUI.changed) {
419  BallUpdate.resetRadii = true;
420  }
421  }
422 
426  public static void MinMaxChoice(){
427 
428  bool isChain = (structType == "B Factor");
429  int textWidth = (int) (0.18f * Rectangles.secStructMenuWidth);
430  int buttonWidth = (int) (0.47 * Rectangles.secStructMenuWidth);
431  GUI.enabled = isChain;
432 
433  GUILayout.Label ("Choose scale");
434  GUILayout.Label ("Min");
435  //BFactorRep.minval = GUILayout.TextField (BFactorRep.minValue.ToString(), 8, GUILayout.Width (labelWidth));
436  BFactorRep.minval = GUILayout.TextField (BFactorRep.minval, 6, GUILayout.Width (textWidth));
437  GUILayout.Label ("Max");
438  BFactorRep.maxval = GUILayout.TextField (BFactorRep.maxval, 6, GUILayout.Width (textWidth));
439 
440  GUILayout.EndHorizontal ();
441  GUILayout.BeginHorizontal ();
442 
443  if (GUILayout.Button (new GUIContent ("Rescaling", "Rescale Bfactor values"), GUILayout.Width (buttonWidth))) {
447  UIData.changeStructure = true;
448 
449  }
450 
451  if (GUILayout.Button (new GUIContent ("Reset", "Reset to original Bfactor values"), GUILayout.Width (buttonWidth))){
455  UIData.changeStructure = true;
456  }
457  }
458 
459 }
static float highBFradius
Radius used for the highest B factor value.
static ColorObject ChainColorD
Definition: Ribbons.cs:37
static bool ssDivCol
When true, triggers the per domain coloring.
static string structTypeButtonLabel(string st)
static bool secondarystruct
Switch between all atoms and C-alpha trace or BFactor secondary structure representation.
Definition: UIData.cs:176
static int secStructMenuWidth
Definition: Rectangles.cs:155
static ColorObject ChainColorB
Definition: Ribbons.cs:35
static bool toggle_bf
Triggers the C-alpha trace regeneration when switching to it.
Definition: UIData.cs:179
static void CreateBFRep()
Definition: BFactorRep.cs:17
static float[] ribbonWidth
Definition: Ribbons.cs:44
static bool toggle_SEC_STRUCT
Triggers the switch between atom and secondary structure generation and rendering.
static bool ssColChain
When true, triggers the per chain secondary structure coloring.
static float HELIX_DIAM
Definition: Ribbons.cs:40
static ColorObject COIL_COLOR
Definition: Ribbons.cs:32
static void ChooseSmoothness_BF()
Chooses the smoothness of the BFactor color/radius Representation.
static void SecStructMenu(int a)
Defines the menu for handling secondary structures (with ribbons)
static ColorObject ChainColorC
Definition: Ribbons.cs:36
static bool changeStructure
Definition: UIData.cs:95
static void ChooseStructure_BF()
Induces switch between all-atom and Bfactor color/radius representation
static List< float[]> CatomsLocationlist
The coordinates of each Carbon alpha.
static string maxval
Definition: BFactorRep.cs:15
static ColorObject ChainColorA
Definition: Ribbons.cs:34
static bool ssColStruct
When true, triggers the per secondary structure type coloring.
static string structType
The current rendered structure type.
static bool isRescale
When true, triggers the B factor value rescaling.
static float LabelSlider(float sliderValue, float sliderMinValue, float sliderMaxValue, string labelText, string toolTip, bool enable, int sliderwidth, int labelwidth=100, bool newLine=false)
static float ARROW_WIDTH
Definition: Ribbons.cs:42
static void MinMaxChoice()
Chooses min and max values to use for BFactor Representation
static string minval
Definition: BFactorRep.cs:14
!WiP Includes FLAGS of GUI.
Definition: UIData.cs:78
static SecondaryStructureManager getSecondaryStructureManager()
Definition: UnityMolMain.cs:34
static ColorObject STRAND_COLOR
Definition: Ribbons.cs:31
static bool isGLIC
Definition: UIData.cs:189
static bool SetTitleExit(string s)
This is a somewhat odd but very convenient function.
Definition: LoadTypeGUI.cs:153
static void SetHighBFSlider()
Display slider setting the radius value for the highest Bfactor
static void CreateColorPicker(ColorObject col, string title, List< string > atomTarget, string residueTarget="All", string chainTarget="All")
static ColorObject ChainColorE
Definition: Ribbons.cs:38
static string structTypeButtonLabel_BF(string st)
static bool hasMoleculeDisplay
Definition: UIData.cs:96
static bool showSecStructMenu
Triggers the secondary structure menu display.
static void SetAtomStyle()
Sets the atom style.
static float THICKNESS
Definition: Ribbons.cs:41
static ColorObject HELIX_COLOR
Definition: Ribbons.cs:30
Definition: GUIDisplay.cs:66
static bool resetRadii
Definition: BallUpdate.cs:76