UnityMol  0.9.6-875
UnityMol viewer / In developement
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
SurfaceOldGUI.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using System.Collections;
3 using UI;
4 using Molecule.Model;
5 
6 public class SurfaceOldGUI {
7  /*
8  * Old GUI related booleans
9  */
10  public static bool showSurfaceMenu = false;
11  public static bool showBfactorMenu = false;
12  public static bool showSurfaceTexture = false;
13  public static bool showHydroMenu = false;
14 
15  // variable for the surface and field lines cutting
16  public static bool showSurfaceCut = false;
17  public static bool showSurfaceMobileCut = false;
18 
19  public static bool cutPlaneIsDraggable = true;
20  private static ColorObject tmpSurfaceColor = new ColorObject(Color.white);
21  private static ColorObject tmpSurfaceInsideColor = new ColorObject(Color.gray);
22  private static bool isTransparentSurface = false;
23 
24  private static float alphaTransparentSurface = 0.25f;
25 
26  /*****************************
27  * Old GUI related functions *
28  *****************************/
29 
33  public static void openCloseSurfaceMenu ()
34  {
37  // showSurfaceCut=false;
38  // showSurfaceMobileCut=false;
40  } else {
43  LoadTypeGUI.showOpenMenu = false;
46  }
47  if (!UIData.toggleSurf) {
48  UIData.toggleBfac = false;
49  UIData.toggleSurf = true;
50  SurfaceManager.pdbGen = false;
51  }
52  }
53 
60  public static void Surface (int a) {
62 
63  GUILayout.BeginHorizontal ();
65  "Determines ramp value for surface generation", true, (int) (0.5 * Rectangles.surfaceMenuWidth), 1);
66  GUILayout.EndHorizontal ();
67 
68  GUILayout.BeginHorizontal ();
69  GUI.enabled = UIData.hasMoleculeDisplay; // trying to generate a surface without a molecule would generate an error
70  if (GUILayout.Button (new GUIContent ("Generate", "Generate a new surface mesh"))) {
72  isTransparentSurface = false;
73  }
74  GUILayout.EndHorizontal();
75 
76  GUILayout.BeginHorizontal ();
77  GUI.enabled = UIData.hasMoleculeDisplay; // trying to generate a surface without a molecule would generate an error
78  if (GUILayout.Button (new GUIContent ("BFactor", "Generate a new surface mesh using b-factors"))) {
80  }
81  GUILayout.EndHorizontal();
82 
83  GUILayout.BeginHorizontal ();
84  if (GUILayout.Button (new GUIContent("Volumetric", "Display volumetric density"))) {
86  }
87  GUI.enabled = true;
88  GUILayout.EndHorizontal ();
89 
90  GUILayout.BeginHorizontal();
92  if (GUILayout.Button (new GUIContent ("Toggle surface", "Toggles surface from visible to hidden and vice versa"))) {
94  }
95  GUILayout.EndHorizontal();
96 
97 
98  GUILayout.BeginHorizontal();
99  GUI.enabled = true; // otherwise the window might not be draggabl
100 
102  new GUIContent("HetAtoms", "Use Hetero atoms for surface calculation"));
104  new GUIContent("Sugars", "Use sugar for surface calculation"));
105  GUILayout.EndHorizontal();
106 
107  if (Event.current.type == EventType.Repaint)
108  MoleculeModel.newtooltip = GUI.tooltip;
109 
110  GUI.enabled = true; // otherwise the window might not be draggable
111  GUI.DragWindow();
112  } // End of Surface
113 
121  public static void SurfaceParams (int a) {
122  LoadTypeGUI.SetTitle("Parameters");
123 
124  if (GUILayout.Button (new GUIContent ("Transparent", "Show a transparent surface"))){
125  // LoadTypeGUI.CreateColorPicker(tmpSurfaceColor,"", null);
126  isTransparentSurface = !isTransparentSurface;
127  UnityMolMain.getSurfaceManager().SetTransparentSurface(isTransparentSurface);
128  }
129  if(isTransparentSurface){
130  if (GUILayout.Button (new GUIContent ("Color", "Choose the color of the surface"))){
131  LoadTypeGUI.CreateColorPicker(tmpSurfaceColor,"Surface Color", null);
132  }
134  {
135  Color mycol = tmpSurfaceColor.color;
136  mycol.a = (float)alphaTransparentSurface;
138  }
139 
140  float tmpalpha = alphaTransparentSurface;
141  tmpalpha = GUIMoleculeController.LabelSlider (tmpalpha, 0f, 1f, "Alpha: " + tmpalpha,
142  "Determines the transparency of the surface", true, (int) (0.5f * Rectangles.surfaceMenuWidth), 1);
143 
144  if(tmpalpha != alphaTransparentSurface){
145  alphaTransparentSurface = tmpalpha;
146  Color mycol = tmpSurfaceColor.color;
147  mycol.a = (float)alphaTransparentSurface;
149  }
150 
151  }
152 
153  if(!isTransparentSurface){
154  if (GUILayout.Button (new GUIContent ("Color", "Choose the color of the surface"))){
155  LoadTypeGUI.CreateColorPicker(tmpSurfaceColor,"Surface Color", null);
156  }
158  {
161  }
162  if (GUILayout.Button (new GUIContent ("Inside color", "Choose the color of the inside of the surface")))
163  LoadTypeGUI.CreateColorPicker(tmpSurfaceInsideColor, "Surface inside color", null);
164 
166  SurfaceManager.SurfaceInsideColor.color = tmpSurfaceInsideColor.color;
168  }
169 
171  GUI.enabled = false;
172  if (GUILayout.Button (new GUIContent ("Use atom color", "Enable/Disable the colors of the atoms on the surface (\"Hide\" must be off)"))) {
174  }
175  GUI.enabled = true;
176 
177  if (GUILayout.Button (new GUIContent ("Use chain color", "Enable/Disable the colors of the chain on the surface (\"Hide\" must be off)"))) {
179  }
180 
181  if (GUILayout.Button (new GUIContent ("Hydrophobic scale", "Open Hydrophobic scales Menu"))) {
183 
184  }
185 
186  if (GUILayout.Button (new GUIContent ("Use properties color", "Show amino acids properties (red/acid ; blue/basic ; green/polar ; white/apolar) (\"Hide\" must be off)"))) {
188  }
189 
190  if (GUILayout.Button (new GUIContent ("Use BFactor color", "Show B-Factor values (\"Hide\" must be off)"))) {
192  }
193 
194 
195  if (GUILayout.Button (new GUIContent ("Texture", "Choose the texture of the surface")))
197 
198  if (GUILayout.Button (new GUIContent ("Static cut", "Activate a static cut plane on the surface"))) {
199  if(SurfaceManager.cutMode == 1){
201  showSurfaceCut = false;
202 
203  }
204  else{
206  showSurfaceCut = true;
207  showSurfaceMobileCut = false;
208  }
209  }
210 
211  if (GUILayout.Button (new GUIContent ("Mobile cut", "Activate a mobile cut plane on the surface"))) {
212  if(SurfaceManager.cutMode == 2){
214  showSurfaceMobileCut = false;
215  }
216  else{
218  showSurfaceMobileCut = true;
219  showSurfaceCut = false;
220  }
221  }
222 
223  GUILayout.BeginHorizontal();
224  GUILayout.Label("Brightness: " + SurfaceManager.brightness.ToString("0.00"));
225  GUILayout.EndHorizontal();
226 
227  GUILayout.BeginHorizontal();
228  int sliderWidth = (int) (Rectangles.surfaceMenuWidth * 0.9f);
229  float brightness = LoadTypeGUI.LabelSlider(SurfaceManager.brightness, 0.33f, 2.0f, "",
230  "Adjust the brightness of the surface", true, sliderWidth, 0, false);
231  if(GUI.changed)
232  SurfaceManager.setBrightness(brightness);
233  GUILayout.EndHorizontal();
234 
235 
236  GUILayout.BeginHorizontal();
237  GUILayout.Label("Color weight: " + SurfaceManager.colorWeight.ToString("0.00"));
238  GUILayout.EndHorizontal();
239 
240  GUILayout.BeginHorizontal();
241  float colorWeight = LoadTypeGUI.LabelSlider(SurfaceManager.colorWeight, 0f, 1f, "",
242  "Adjust the weight of the vertex colors of the surface", true, sliderWidth, 0, false);
243  if(GUI.changed)
244  SurfaceManager.setColorWeight(colorWeight);
245  GUILayout.EndHorizontal();
246  }
247 
248  if (Event.current.type == EventType.Repaint)
249  MoleculeModel.newtooltip = GUI.tooltip;
250 
251  GUI.DragWindow();
252  } // End of Surface Params
253 
254  public static void HydroMenu (int a) {
255 
256  SurfaceOldGUI.showHydroMenu = LoadTypeGUI.SetTitleExit("Hydrophobic scales");
257 
258  if (GUILayout.Button (new GUIContent ("Kyte & Doolittle", "Surface coloring by using Kyte and Doolittle hydrophobic scale"))) {
260  }
261 
262  if (GUILayout.Button (new GUIContent ("Engleman & al.", "Surface coloring by using Engleman & al hydrophobic scale"))) {
264  }
265 
266  if (GUILayout.Button (new GUIContent ("Eisenberg", "Surface coloring by using Eisenberg scale"))) {
268  }
269 
270  if (GUILayout.Button (new GUIContent ("White Octanol", "Surface coloring by using White Octanol scale"))) {
272  }
273 
274  GUI.DragWindow();
275 
276  } // End of HydroMenu
277 
284  public static void SurfaceCut (int a) {
286 
287  int sliderWidth = (int) (Rectangles.surfaceCutWidth * 0.80f);
288 
290  "Determines cut plane depth position", true, sliderWidth, 1, true);
291  SurfaceManager.cutX = LoadTypeGUI.LabelSlider (SurfaceManager.cutX, -1f, 1f, " X: " + SurfaceManager.cutX.ToString("0.00"),
292  "Determines cut plane X position", true, sliderWidth, 1, true);
293  SurfaceManager.cutY = LoadTypeGUI.LabelSlider (SurfaceManager.cutY, -1f, 1f, " Y: " + SurfaceManager.cutY.ToString("0.00"),
294  "Determines cut plane Y position", true, sliderWidth, 1, true);
295  SurfaceManager.cutZ = LoadTypeGUI.LabelSlider (SurfaceManager.cutZ, -1f, 1f, " Z: " + SurfaceManager.cutZ.ToString("0.00"),
296  "Determines cut plane Z position", true, sliderWidth, 1, true);
297 
298  if(GUI.changed)
300  GUI.enabled = true;
301  GUI.DragWindow();
302  }
303 
311  public static void MoveCutPlane (int a) {
312  LoadTypeGUI.SetTitle("Move cut plane");
314  GUI.DragWindow();
315 
316  Vector3 mousePos = Input.mousePosition;
317  mousePos.y = Screen.height - mousePos.y;
319  && !LoadTypeGUI.InDeadZone(Rectangles.movePlaneRect, mousePos) && GUIUtility.hotControl == 0)
320  {
321  if (Input.GetMouseButton (0)) {
322  SurfaceManager.cutX += Input.GetAxis ("Mouse X") * 1 * 0.02f;
323  SurfaceManager.cutY -= Input.GetAxis ("Mouse Y") * 1 * 0.02f;
324  SurfaceManager.cutZ -= Input.GetAxis ("Mouse X") * 1 * 0.02f;
325  }
326  if (SurfaceManager.cutX < -1)
327  SurfaceManager.cutX = -1;
328  if (SurfaceManager.cutX > 1)
329  SurfaceManager.cutX = 1;
330  if (SurfaceManager.cutY < -1)
331  SurfaceManager.cutY = -1;
332  if (SurfaceManager.cutY > 1)
333  SurfaceManager.cutY = 1;
334  if (SurfaceManager.cutZ < -1)
335  SurfaceManager.cutZ = -1;
336  if (SurfaceManager.cutZ > 1)
337  SurfaceManager.cutZ = 1;
338  SurfaceManager.depthCut -= Input.GetAxis ("Mouse ScrollWheel");
340  }
341  }
342 
349  public static void SurfaceMobileCut (int a) {
350  int sliderWidth = (int) (Rectangles.surfaceCutWidth * 0.45f);
351  LoadTypeGUI.SetTitle("Surface Mobile Cut");
353  "Determines mobile cut plane depth position", true, sliderWidth, 1);
354 
356  "Determines field line cut position", true, sliderWidth, 1);
357 
359  GUI.enabled = false;
360 
361  if(GUI.changed)
363  GUI.DragWindow();
364  }
365 
366 
367 
380  private static void textureMenu (string texDir, string[] texList, string texDescr) {
381  // GUI.Label (new Rect (0, 0, 290, 20), "Surface Texture - " + texDescr, CentredText);
382  SurfaceOldGUI.showSurfaceTexture = LoadTypeGUI.SetTitleExit("Surface Texture - " + texDescr); //, CentredText);
383 
384  #if !UNITY_WEBPLAYER
385  SurfaceManager.m_last_extSurf_Path = System.IO.Directory.GetCurrentDirectory();
386  #endif
387 
388  GUILayout.BeginHorizontal();
389  GUILayout.FlexibleSpace();
390  UIData.grayscalemode = GUILayout.Toggle (UIData.grayscalemode, new GUIContent ("Grayscale", "Use grayscale version of the texture"));
391  GUILayout.EndHorizontal();
392 
393  GUILayout.BeginHorizontal ();
394  if (GUILayout.Button (new GUIContent ("<<", "Go to previous series of textures"))) { // cycle through texture sets
396 
398  if(LoadTypeGUI.texture_set < 0)
399  LoadTypeGUI.texture_set = 4; // First 5 pages are best textures (0-4)
400  }
401  else{
402  if(LoadTypeGUI.texture_set < 5)
404  }
405  }
406 
407  // if(GUILayout.Button(new GUIContent("Confirm","Confirm all the modification of the molecule.")))
408  if (GUILayout.Button (new GUIContent ("Open", "Open custom texture image from disk"))) {
411  new Rect (400, 100, 600, 500),
412  "Choose Image File",
415  );
416  }
417 
418  if (GUILayout.Button (new GUIContent (">>", "Go to next series of textures"))) { // cycle through texture sets
420 
422  if(LoadTypeGUI.texture_set>4) // First 5 pages are best textures (0-4)
424  }
425  else{
428  }
429  }
430  GUILayout.EndHorizontal ();
431 
432  GUILayout.BeginHorizontal ();
433 
434  // check whether texList has more than 15 entries and raise an error!!
435  int i = 0;
436  // GUILayout.EndHorizontal(); GUILayout.Box(texDescr); GUILayout.BeginHorizontal();
437  foreach (string texFil in texList) {
438  i++;
439  if (i > 5) {
440  GUILayout.EndHorizontal ();
441  GUILayout.BeginHorizontal ();
442  i = 1;
443  }
444  // if(GUILayout.Button((Texture2D)Resources.Load(texDir+texFil),GUILayout.Width(50),GUILayout.Height(50)))
445  int buttonWidth = (int) (Rectangles.textureWidth *0.18f);
446  int buttonHeight = (int) (Rectangles.textureHeight / 4f);
447  if (GUILayout.Button (new GUIContent ((Texture2D)Resources.Load (texDir + texFil), texFil), GUILayout.Width (buttonWidth), GUILayout.Height (buttonHeight))) {
448  if(texFil != "None") {
449  SurfaceManager.surfaceTextureName = texDir + texFil;
451  }
452  else {
453  SurfaceManager.surfaceTextureName = "lit_spheres/divers/daphz1";
455  }
456  }
457  }
458  GUILayout.EndHorizontal ();
459  if (Event.current.type == EventType.Repaint)
460  MoleculeModel.newtooltip = GUI.tooltip;
461  }
462 
463 
471  public static void SurfaceTexture (int a) {
472 
474 
475  GUI.DragWindow();
476  } // End of SurfaceTexture
477 
478  public static void FileSelectedCallback (string path) {
479  #if !UNITY_WEBPLAYER
481  if (path != null) {
483  SurfaceManager.m_last_extSurf_Path = System.IO.Path.GetDirectoryName (path);
485  }
486  // FileBrowser_show = false;
488  WWW www = new WWW ("file://" + GUIMoleculeController.m_textPath);
489  SurfaceManager.extSurf = www.texture;
490  Debug.Log (GUIMoleculeController.m_textPath);
491  #endif
492  }
493 }
static float cutX
static void useChainColor()
static ColorObject SurfaceColor
static float depthCutMax
static void SurfaceParams(int a)
Defines the Surface Parameters menu window.
static bool useHetatmForSurface
static ColorObject tmpSurfaceInsideColor
static float depthCutMin
static float cutZ
static void openCloseSurfaceMenu()
Opens or closes the surface menu.
void SetTransparentSurface(bool transparent)
static bool toggleSurf
Definition: UIData.cs:194
static float cutY
static ImprovedFileBrowser m_fileBrowser
static void useBFactorColor()
static void useEnglemanColor()
static void SurfaceRenderUp()
static int surfaceCutWidth
Definition: Rectangles.cs:186
static ColorObject tmpSurfaceColor
static void useEinsenbergColor()
static bool showHydroMenu
static void ShowHideSurfaces()
static void GenerateSurfaceBfact()
static bool externalSurfaceTexture
bool changed
Definition: ColorPicker.cs:90
static bool pdbGen
static void textureMenu(string texDir, string[] texList, string texDescr)
Helper function to fill a texture choice menu with up to 15 boxes.
static ColorPicker m_colorPicker
GameObject[] getSurfaces()
static List< string[]> textureMenuList
Definition: GUIDisplay.cs:176
static void SurfaceCut(int a)
Defines the static surface cut window, which is opened from the Surface parameters menu...
static int surfaceMenuWidth
Definition: Rectangles.cs:162
static bool InDeadZone(Rect rect, Vector3 mpos)
Returns true if the mouse cursor is lower than the Window title.
Definition: LoadTypeGUI.cs:242
static void ShowHideVolumetricDensity()
static int textureWidth
Definition: Rectangles.cs:308
Color color
Definition: ColorObject.cs:72
static bool isTransparentSurface
static void setBrightness(float value)
static bool showSurfaceMenu
static Texture2D extSurf
static void MoveCutPlane(int a)
Defines the move cut plane window, that lets the user change the cut plane of the surface by clicking...
static int textureHeight
Definition: Rectangles.cs:309
static void FileSelectedCallback(string path)
static void Surface(int a)
Defines the Surface menu window, which is opened from the main menu window.
static bool cutPlaneIsDraggable
static bool toggleBfac
Definition: UIData.cs:195
static bool showBfactorMenu
static void useWhiteOctanolColor()
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 alphaTransparentSurface
static void usePropertiesColor()
static float depthCut
static bool showSurfaceCut
static string surfaceTextureName
static ElectrostaticManager getElectrostaticManager()
Definition: UnityMolMain.cs:42
static string m_last_extSurf_Path
!WiP Includes FLAGS of GUI.
Definition: UIData.cs:78
static ColorObject SurfaceInsideColor
static bool SetTitleExit(string s)
This is a somewhat odd but very convenient function.
Definition: LoadTypeGUI.cs:153
static float colorWeight
!WiP manage GUI, and provide static strings for the GUI.
Definition: GUIDisplay.cs:94
static void useKyteAndDoolittleColor()
static void CreateColorPicker(ColorObject col, string title, List< string > atomTarget, string residueTarget="All", string chainTarget="All")
static void HydroMenu(int a)
static bool useSugarForSurface
static List< string > textureMenuTitles
Definition: GUIDisplay.cs:175
void SetTransparentSurfaceColor(Color newcolor)
static void SetTitle(string s)
Sets the title of the current window.
Definition: LoadTypeGUI.cs:129
static Rect movePlaneRect
Definition: Rectangles.cs:206
static bool showSurfaceMobileCut
static SurfaceManager getSurfaceManager()
Definition: UnityMolMain.cs:24
static bool hasMoleculeDisplay
Definition: UIData.cs:96
static bool grayscalemode
Definition: UIData.cs:159
static void SurfaceTexture(int a)
Defines the texture selection window.
static float brightness
static void GenerateSurface()
static bool showSurfaceTexture
static int cutMode
static float surfaceThreshold
static void SurfaceMobileCut(int a)
Defines the mobile surface cut window, which is opened from the Surface parameters menu...
Definition: GUIDisplay.cs:66
static void setColorWeight(float value)