1 | #include "RNA3D_GlobalHeader.hxx" |
---|
2 | |
---|
3 | #include <GL/aw_window_ogl.hxx> |
---|
4 | #include <aw_window_Xm_interface.hxx> |
---|
5 | |
---|
6 | #include "RNA3D_Global.hxx" |
---|
7 | #include "RNA3D_Graphics.hxx" |
---|
8 | #include "RNA3D_OpenGLEngine.hxx" |
---|
9 | #include "RNA3D_Interface.hxx" |
---|
10 | #include "RNA3D_OpenGLGraphics.hxx" |
---|
11 | #include "RNA3D_StructureData.hxx" |
---|
12 | |
---|
13 | #include <string> |
---|
14 | #include <iostream> |
---|
15 | |
---|
16 | #include <X11/keysym.h> |
---|
17 | |
---|
18 | #include <aw_preset.hxx> |
---|
19 | #include <aw_root.hxx> |
---|
20 | #include <aw_msg.hxx> |
---|
21 | #include <aw_awars.hxx> |
---|
22 | |
---|
23 | |
---|
24 | using namespace std; |
---|
25 | |
---|
26 | static AW_window_menu_modes_opengl *awm; |
---|
27 | static XtAppContext appContext; |
---|
28 | static XtWorkProcId workId = 0; |
---|
29 | |
---|
30 | // ========= SpinMolecule(XtPointer ...) : The Actual WorkProc Routine ============// |
---|
31 | // => Sets the Rotation speed to 0.05 : default speed in Rotation Mode. |
---|
32 | // => Calls RefreshOpenGLDisplay() : to calculate new rotate matrix |
---|
33 | // and then, redraws the entire scene. |
---|
34 | // => Returns False : so that the work proc remains registered and |
---|
35 | // the animation will continue. |
---|
36 | // ===============================================================================// |
---|
37 | |
---|
38 | static Boolean SpinMolecule(XtPointer /* clientData */) { |
---|
39 | RNA3D->ROTATION_SPEED = 0.05; |
---|
40 | RefreshOpenGLDisplay(); |
---|
41 | return false; // leave work proc active |
---|
42 | } |
---|
43 | |
---|
44 | // ========== RotateMoleculeStateChanged(void)==================================// |
---|
45 | // => if bAutoRotate, removes the WorkProc routine and sets bAutoRotate to false. |
---|
46 | // => if not, adds the WorkProc routine [SpinMolecule()] and sets bAutoRotate to true. |
---|
47 | // bAutoRotate is used in recalculation of Rotation Matrix |
---|
48 | // in RenderOpenGLScene() ==> defined in RNA3D_OpenGLEngine.cxx. |
---|
49 | // ===============================================================================// |
---|
50 | |
---|
51 | static void RotateMoleculeStateChanged(AW_root *awr) { |
---|
52 | bool rotate = awr->awar(AWAR_3D_MOL_ROTATE)->read_int(); |
---|
53 | if (rotate != RNA3D->bAutoRotate) { |
---|
54 | if (RNA3D->bAutoRotate) { |
---|
55 | XtRemoveWorkProc(workId); |
---|
56 | RNA3D->bAutoRotate = false; |
---|
57 | } |
---|
58 | else { |
---|
59 | workId = XtAppAddWorkProc(appContext, SpinMolecule, NULp); |
---|
60 | RNA3D->bAutoRotate = true; |
---|
61 | } |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | // ============ RotateMoleculeStateChanged_cb(AW_root *awr)===========================// |
---|
66 | // Callback bound to Rotatation Awar (AWAR_3D_MOL_ROTATE) |
---|
67 | // Is called when the |
---|
68 | // 1. Rotation Awar is changed. |
---|
69 | // 2. Also when the Spacebar is pressed in KeyBoardEventHandler(). |
---|
70 | // ===============================================================================// |
---|
71 | |
---|
72 | static void RotateMoleculeStateChanged_cb(AW_root *awr) { |
---|
73 | MapDisplayParameters(awr); |
---|
74 | RotateMoleculeStateChanged(awr); |
---|
75 | RefreshOpenGLDisplay(); |
---|
76 | } |
---|
77 | |
---|
78 | static void ResizeOpenGLWindow(Widget /* w */, XtPointer /* client_data */, XEvent *event, char* /* x */) { |
---|
79 | XConfigureEvent *evt; |
---|
80 | evt = (XConfigureEvent*) event; |
---|
81 | |
---|
82 | if (RNA3D->OpenGLEngineState == NOT_CREATED) { |
---|
83 | return; |
---|
84 | } |
---|
85 | |
---|
86 | ReshapeOpenGLWindow((GLint) evt->width, (GLint) evt->height); |
---|
87 | |
---|
88 | RefreshOpenGLDisplay(); |
---|
89 | } |
---|
90 | |
---|
91 | static void KeyReleaseEventHandler(Widget /* w */, XtPointer /* client_data */, XEvent * /* event */, char* /* x */) { |
---|
92 | RefreshOpenGLDisplay(); |
---|
93 | } |
---|
94 | |
---|
95 | static void KeyPressEventHandler(Widget /* w */, XtPointer /* client_data */, XEvent *event, char* /* x */) { |
---|
96 | char buffer[1]; |
---|
97 | KeySym keysym; |
---|
98 | |
---|
99 | // Converting keycode to keysym |
---|
100 | XLookupString((XKeyEvent *) event, buffer, 1, &keysym, NULp); |
---|
101 | |
---|
102 | switch (keysym) { |
---|
103 | case XK_space: |
---|
104 | RNA3D->iRotateMolecule = !RNA3D->iRotateMolecule; |
---|
105 | RNA3D->root->awar(AWAR_3D_MOL_ROTATE)->write_int(RNA3D->iRotateMolecule); |
---|
106 | break; |
---|
107 | case XK_Escape: |
---|
108 | RNA3D->bDisplayComments = !RNA3D->bDisplayComments; |
---|
109 | break; |
---|
110 | case XK_Tab: |
---|
111 | RNA3D->bDisplayMask = !RNA3D->bDisplayMask; |
---|
112 | break; |
---|
113 | case XK_Up: |
---|
114 | RNA3D->Center.y -= 0.1; |
---|
115 | break; |
---|
116 | case XK_Down: |
---|
117 | RNA3D->Center.y += 0.1; |
---|
118 | break; |
---|
119 | case XK_Left: |
---|
120 | RNA3D->Center.x -= 0.1; |
---|
121 | break; |
---|
122 | case XK_Right: |
---|
123 | RNA3D->Center.x += 0.1; |
---|
124 | break; |
---|
125 | } |
---|
126 | |
---|
127 | RefreshOpenGLDisplay(); |
---|
128 | } |
---|
129 | |
---|
130 | static void ButtonReleaseEventHandler(Widget /* w */, XtPointer /* client_data */, XEvent *event, char* /* x */) { |
---|
131 | XButtonEvent *xr; |
---|
132 | xr = (XButtonEvent*) event; |
---|
133 | |
---|
134 | switch (xr->button) { |
---|
135 | case LEFT_BUTTON: RNA3D->bRotateMolecule = false; break; |
---|
136 | case MIDDLE_BUTTON: break; |
---|
137 | case RIGHT_BUTTON: break; |
---|
138 | } |
---|
139 | |
---|
140 | RefreshOpenGLDisplay(); |
---|
141 | } |
---|
142 | |
---|
143 | static void ButtonPressEventHandler(Widget /* w */, XtPointer /* client_data */, XEvent *event, char* /* x */) { |
---|
144 | |
---|
145 | XButtonEvent *xp; |
---|
146 | xp = (XButtonEvent*) event; |
---|
147 | |
---|
148 | switch (xp->button) { |
---|
149 | case LEFT_BUTTON: |
---|
150 | RNA3D->bRotateMolecule = true; |
---|
151 | RNA3D->saved_x = xp->x; |
---|
152 | RNA3D->saved_y = xp->y; |
---|
153 | break; |
---|
154 | |
---|
155 | case MIDDLE_BUTTON: |
---|
156 | RNA3D->gl_Canvas->set_mode(AWT_MODE_NONE); |
---|
157 | break; |
---|
158 | |
---|
159 | case RIGHT_BUTTON: |
---|
160 | break; |
---|
161 | |
---|
162 | case WHEEL_UP: |
---|
163 | RNA3D->scale += ZOOM_FACTOR; |
---|
164 | break; |
---|
165 | |
---|
166 | case WHEEL_DOWN: |
---|
167 | RNA3D->scale -= ZOOM_FACTOR; |
---|
168 | break; |
---|
169 | } |
---|
170 | |
---|
171 | RefreshOpenGLDisplay(); |
---|
172 | } |
---|
173 | |
---|
174 | static void MouseMoveEventHandler(Widget /* w */, XtPointer /* client_data */, XEvent *event, char* /* x */) { |
---|
175 | |
---|
176 | XMotionEvent *xp; |
---|
177 | xp = (XMotionEvent*) event; |
---|
178 | |
---|
179 | if (!RNA3D->bAutoRotate) { |
---|
180 | RNA3D->ROTATION_SPEED = 0.5; |
---|
181 | } |
---|
182 | |
---|
183 | if (RNA3D->bRotateMolecule) { |
---|
184 | // ComputeRotationXY : computes new rotation X and Y based on the mouse movement |
---|
185 | ComputeRotationXY(xp->x, xp->y); |
---|
186 | } |
---|
187 | |
---|
188 | RefreshOpenGLDisplay(); |
---|
189 | } |
---|
190 | |
---|
191 | static void ExposeOpenGLWindow(Widget w, XtPointer /* client_data */, XEvent *event, char* /* x */) { |
---|
192 | static bool ok = false; |
---|
193 | |
---|
194 | if (RNA3D->OpenGLEngineState == NOT_CREATED) { |
---|
195 | InitializeOpenGLWindow(w); |
---|
196 | |
---|
197 | XExposeEvent *evt; |
---|
198 | evt = (XExposeEvent*) event; |
---|
199 | |
---|
200 | try { |
---|
201 | InitializeOpenGLEngine((GLint) evt->height, (GLint) evt->height); |
---|
202 | ReshapeOpenGLWindow((GLint) evt->width, (GLint) evt->height); |
---|
203 | ok = true; |
---|
204 | } |
---|
205 | catch (string& err) { |
---|
206 | // errors catched here should close the RNA3D window again (or prevent it from opening) |
---|
207 | aw_message(GBS_global_string("Error in RNA3D: %s", err.c_str())); |
---|
208 | awm->hide(); |
---|
209 | } |
---|
210 | } |
---|
211 | |
---|
212 | if (ok) RefreshOpenGLDisplay(); |
---|
213 | } |
---|
214 | |
---|
215 | void RefreshOpenGLDisplay() { |
---|
216 | |
---|
217 | if (RNA3D->OpenGLEngineState == CREATED) { |
---|
218 | RenderOpenGLScene(RNA3D->glw); |
---|
219 | } |
---|
220 | } |
---|
221 | |
---|
222 | static void RefreshCanvas(AW_root *awr) { |
---|
223 | MapDisplayParameters(awr); |
---|
224 | RefreshOpenGLDisplay(); |
---|
225 | } |
---|
226 | |
---|
227 | static void SynchronizeColorsWithEditor(AW_window *aww) { |
---|
228 | // overwrites color settings with those from EDIT4 |
---|
229 | |
---|
230 | AW_copy_GC_colors(aww->get_root(), "ARB_EDIT4", "RNA3D", |
---|
231 | "User1", "User2", "Probe", |
---|
232 | "Primerl", "Primerr", "Primerg", |
---|
233 | "Sigl", "Sigr", "Sigg", |
---|
234 | "RANGE_0", "RANGE_1", "RANGE_2", |
---|
235 | "RANGE_3", "RANGE_4", "RANGE_5", |
---|
236 | "RANGE_6", "RANGE_7", "RANGE_8", |
---|
237 | "RANGE_9", |
---|
238 | NULp); |
---|
239 | } |
---|
240 | |
---|
241 | static void Change3DMolecule_CB(AW_root *awr) { |
---|
242 | cout<<"Rendering new 3D molecule.... please wait..."<<endl; |
---|
243 | |
---|
244 | RNA3D->cStructure->LSU_molID = awr->awar(AWAR_3D_23S_RRNA_MOL)->read_int(); |
---|
245 | |
---|
246 | RNA3D->cStructure->DeleteOldMoleculeData(); // Deleting the old molecule data |
---|
247 | RNA3D->cStructure->ReadCoOrdinateFile(); // Reading Structure information |
---|
248 | RNA3D->cStructure->GetSecondaryStructureInfo(); // Getting Secondary Structure Information |
---|
249 | RNA3D->cStructure->Combine2Dand3DstructureInfo(); // Combining Secondary Structure data with 3D Coordinates |
---|
250 | RNA3D->cStructure->GenerateDisplayLists(); // Generating Display Lists for Rendering |
---|
251 | |
---|
252 | // recalculate the mapping information |
---|
253 | awr->awar(AWAR_SPECIES_NAME)->touch(); |
---|
254 | |
---|
255 | // recalculate helix numbering |
---|
256 | awr->awar(AWAR_3D_HELIX_FROM)->touch(); |
---|
257 | |
---|
258 | // render new structure in OpenGL window |
---|
259 | RefreshCanvas(awr); |
---|
260 | } |
---|
261 | |
---|
262 | static void Change3DMolecule(AW_window *aww, int molID) { |
---|
263 | // changes the displayed 3D structure in the case of 23S rRNA |
---|
264 | aww->get_root()->awar(AWAR_3D_23S_RRNA_MOL)->write_int(molID); |
---|
265 | } |
---|
266 | |
---|
267 | static void DisplayMoleculeMask(AW_root * /* awr */) { |
---|
268 | RNA3D->bDisplayMask = !RNA3D->bDisplayMask; |
---|
269 | RefreshOpenGLDisplay(); |
---|
270 | } |
---|
271 | |
---|
272 | |
---|
273 | // ---------------------------- Creating WINDOWS ------------------------------ |
---|
274 | static void AddCallBacks(AW_root *awr) { |
---|
275 | // adding callbacks to the awars to refresh the display if received any changes |
---|
276 | |
---|
277 | // General Molecule Display Section |
---|
278 | awr->awar(AWAR_3D_MOL_BACKBONE)->add_callback(RefreshCanvas); |
---|
279 | awr->awar(AWAR_3D_MOL_COLORIZE)->add_callback(RefreshCanvas); |
---|
280 | awr->awar(AWAR_3D_MOL_SIZE)->add_callback(RefreshCanvas); |
---|
281 | awr->awar(AWAR_3D_MOL_DISP_POS)->add_callback(RefreshCanvas); |
---|
282 | awr->awar(AWAR_3D_MOL_ROTATE)->add_callback(RotateMoleculeStateChanged_cb); |
---|
283 | awr->awar(AWAR_3D_MOL_POS_INTERVAL)->add_callback(DisplayPostionsIntervalChanged_CB); |
---|
284 | awr->awar(AWAR_3D_CURSOR_POSITION)->add_callback(RefreshCanvas); |
---|
285 | awr->awar(AWAR_CURSOR_POSITION)->add_callback(CursorPositionChanged_CB); |
---|
286 | |
---|
287 | // Display Base Section |
---|
288 | awr->awar(AWAR_3D_DISPLAY_BASES)->add_callback(RefreshCanvas); |
---|
289 | awr->awar(AWAR_3D_DISPLAY_SIZE)->add_callback(RefreshCanvas); |
---|
290 | awr->awar(AWAR_3D_BASES_MODE)->add_callback(RefreshCanvas); |
---|
291 | awr->awar(AWAR_3D_BASES_HELIX)->add_callback(RefreshCanvas); |
---|
292 | awr->awar(AWAR_3D_BASES_UNPAIRED_HELIX)->add_callback(RefreshCanvas); |
---|
293 | awr->awar(AWAR_3D_BASES_NON_HELIX)->add_callback(RefreshCanvas); |
---|
294 | awr->awar(AWAR_3D_SHAPES_HELIX)->add_callback(RefreshCanvas); |
---|
295 | awr->awar(AWAR_3D_SHAPES_UNPAIRED_HELIX)->add_callback(RefreshCanvas); |
---|
296 | awr->awar(AWAR_3D_SHAPES_NON_HELIX)->add_callback(RefreshCanvas); |
---|
297 | |
---|
298 | // Display Helix Section |
---|
299 | awr->awar(AWAR_3D_DISPLAY_HELIX)->add_callback(RefreshCanvas); |
---|
300 | awr->awar(AWAR_3D_HELIX_BACKBONE)->add_callback(RefreshCanvas); |
---|
301 | awr->awar(AWAR_3D_HELIX_MIDPOINT)->add_callback(RefreshCanvas); |
---|
302 | awr->awar(AWAR_3D_HELIX_FROM)->add_callback(makeRootCallback(DisplayHelixNrsChanged_CB, false)); |
---|
303 | awr->awar(AWAR_3D_HELIX_TO)->add_callback(makeRootCallback(DisplayHelixNrsChanged_CB, true)); |
---|
304 | awr->awar(AWAR_3D_HELIX_NUMBER)->add_callback(RefreshCanvas); |
---|
305 | awr->awar(AWAR_3D_HELIX_SIZE)->add_callback(RefreshCanvas); |
---|
306 | awr->awar(AWAR_3D_DISPLAY_TERTIARY_INTRACTIONS)->add_callback(RefreshCanvas); |
---|
307 | |
---|
308 | // Mapping Sequence Data Section |
---|
309 | awr->awar(AWAR_SPECIES_NAME)->add_callback(MapSelectedSpeciesChanged_CB); |
---|
310 | awr->awar(AWAR_3D_MAP_ENABLE)->add_callback(RefreshCanvas); |
---|
311 | |
---|
312 | awr->awar(AWAR_3D_MAP_SAI)->add_callback(RefreshCanvas); |
---|
313 | awr->awar(AWAR_SAI_GLOBAL)->add_callback(MapSaiToEcoliTemplateChanged_CB); |
---|
314 | awr->awar(AWAR_3D_MAP_SEARCH_STRINGS)->add_callback(RefreshCanvas); |
---|
315 | |
---|
316 | awr->awar(AWAR_3D_MAP_SPECIES)->add_callback(RefreshCanvas); |
---|
317 | awr->awar(AWAR_3D_MAP_SPECIES_DISP_BASE)->add_callback(RefreshCanvas); |
---|
318 | awr->awar(AWAR_3D_MAP_SPECIES_DISP_POS)->add_callback(RefreshCanvas); |
---|
319 | awr->awar(AWAR_3D_MAP_SPECIES_DISP_DELETIONS)->add_callback(RefreshCanvas); |
---|
320 | awr->awar(AWAR_3D_MAP_SPECIES_DISP_MISSING)->add_callback(RefreshCanvas); |
---|
321 | awr->awar(AWAR_3D_MAP_SPECIES_DISP_INSERTIONS)->add_callback(RefreshCanvas); |
---|
322 | awr->awar(AWAR_3D_MAP_SPECIES_DISP_INSERTIONS_INFO)->add_callback(RefreshCanvas); |
---|
323 | |
---|
324 | awr->awar(AWAR_3D_DISPLAY_MASK)->add_callback(DisplayMoleculeMask); |
---|
325 | awr->awar(AWAR_3D_23S_RRNA_MOL)->add_callback(Change3DMolecule_CB); |
---|
326 | } |
---|
327 | |
---|
328 | static void InitCallBacks(AW_root *awr) { |
---|
329 | // init callbacks |
---|
330 | RotateMoleculeStateChanged_cb(awr); |
---|
331 | } |
---|
332 | |
---|
333 | static void RefreshMappingDisplay(AW_window * /* aw */) { |
---|
334 | // Refreshes the SAI Display if and when ... |
---|
335 | // 1.Changes made to SAI related settings in EDIT4 and not updated automatically |
---|
336 | // 2.Colors related to SAI Display changed in RNA3D Application |
---|
337 | MapSaiToEcoliTemplateChanged_CB(RNA3D->root); |
---|
338 | |
---|
339 | // Refreshes the Search Strings Display if |
---|
340 | // Colors related to Search Strings changed in RNA3D Application |
---|
341 | // and not updated automatically |
---|
342 | MapSearchStringsToEcoliTemplateChanged_CB(RNA3D->root); |
---|
343 | |
---|
344 | // Resetting the Molecule Transformations |
---|
345 | // 1.Reset the Molecule view to Center of the viewer (default view). |
---|
346 | // 2.Zoom the Molecule to fit to window (default zoom). |
---|
347 | RNA3D->Center = Vector3(0.0, 0.0, 0.0); |
---|
348 | RNA3D->scale = 0.01; |
---|
349 | |
---|
350 | RefreshCanvas(RNA3D->root); |
---|
351 | } |
---|
352 | |
---|
353 | static void insertShapeSelection(AW_window *aws, const char *at, const char *awar_name) { |
---|
354 | aws->at(at); |
---|
355 | aws->create_toggle_field(awar_name, 1); |
---|
356 | aws->insert_toggle("#circle.xpm", "C", 0); |
---|
357 | aws->insert_toggle("#diamond.xpm", "D", 1); |
---|
358 | aws->insert_toggle("#polygon.xpm", "P", 2); |
---|
359 | aws->insert_toggle("#star.xpm", "S", 3); |
---|
360 | aws->insert_toggle("#rectangle.xpm", "R", 4); |
---|
361 | aws->update_toggle_field(); |
---|
362 | } |
---|
363 | |
---|
364 | static AW_window *CreateDisplayBases_window(AW_root *aw_root) { |
---|
365 | AW_window_simple *aws = new AW_window_simple; |
---|
366 | |
---|
367 | aws->init(aw_root, "DISPLAY_BASES", "RNA3D : Display BASES"); |
---|
368 | aws->load_xfig("RNA3D_DisplayBases.fig"); |
---|
369 | |
---|
370 | aws->callback(makeHelpCallback("rna3d_dispBases.hlp")); |
---|
371 | aws->at("help"); |
---|
372 | aws->button_length(0); |
---|
373 | aws->create_button("HELP", "#help.xpm"); |
---|
374 | |
---|
375 | aws->at("close"); |
---|
376 | aws->callback(AW_POPDOWN); |
---|
377 | aws->button_length(0); |
---|
378 | aws->create_button("CLOSE", "#closeText.xpm"); |
---|
379 | |
---|
380 | { // Display Bases Section |
---|
381 | aws->at("dispBases"); |
---|
382 | aws->create_toggle(AWAR_3D_DISPLAY_BASES); |
---|
383 | |
---|
384 | aws->at("helix"); |
---|
385 | aws->create_toggle(AWAR_3D_BASES_HELIX); |
---|
386 | aws->at("unpairHelix"); |
---|
387 | aws->create_toggle(AWAR_3D_BASES_UNPAIRED_HELIX); |
---|
388 | aws->at("nonHelix"); |
---|
389 | aws->create_toggle(AWAR_3D_BASES_NON_HELIX); |
---|
390 | |
---|
391 | aws->at("shapesSize"); |
---|
392 | aws->create_input_field(AWAR_3D_DISPLAY_SIZE, 5); |
---|
393 | |
---|
394 | aws->at("basesMode"); |
---|
395 | aws->create_toggle_field(AWAR_3D_BASES_MODE, 0); |
---|
396 | aws->insert_toggle("CHARACTERS", "C", 0); |
---|
397 | aws->insert_toggle("SHAPES", "S", 1); |
---|
398 | aws->update_toggle_field(); |
---|
399 | |
---|
400 | insertShapeSelection(aws, "spHelix", AWAR_3D_SHAPES_HELIX); |
---|
401 | insertShapeSelection(aws, "spUnpairedHelix", AWAR_3D_SHAPES_UNPAIRED_HELIX); |
---|
402 | insertShapeSelection(aws, "spNonHelix", AWAR_3D_SHAPES_NON_HELIX); |
---|
403 | } |
---|
404 | |
---|
405 | aws->show(); |
---|
406 | |
---|
407 | return aws; |
---|
408 | } |
---|
409 | |
---|
410 | static AW_window *CreateDisplayHelices_window(AW_root *aw_root) { |
---|
411 | AW_window_simple *aws = new AW_window_simple; |
---|
412 | |
---|
413 | aws->init(aw_root, "DISPLAY_HELICES", "RNA3D : Display HELICES"); |
---|
414 | aws->load_xfig("RNA3D_DisplayHelices.fig"); |
---|
415 | |
---|
416 | aws->callback(makeHelpCallback("rna3d_dispHelices.hlp")); |
---|
417 | aws->at("help"); |
---|
418 | aws->button_length(0); |
---|
419 | aws->create_button("HELP", "#help.xpm"); |
---|
420 | |
---|
421 | aws->at("close"); |
---|
422 | aws->callback(AW_POPDOWN); |
---|
423 | aws->button_length(0); |
---|
424 | aws->create_button("CLOSE", "#closeText.xpm"); |
---|
425 | |
---|
426 | { // Display Helices Section |
---|
427 | aws->at("dispHelix"); |
---|
428 | aws->create_toggle(AWAR_3D_DISPLAY_HELIX); |
---|
429 | |
---|
430 | aws->at("backbone"); |
---|
431 | aws->create_toggle(AWAR_3D_HELIX_BACKBONE); |
---|
432 | aws->at("midHelix"); |
---|
433 | aws->create_toggle(AWAR_3D_HELIX_MIDPOINT); |
---|
434 | aws->at("helixNr"); |
---|
435 | aws->create_toggle(AWAR_3D_HELIX_NUMBER); |
---|
436 | aws->at("from"); |
---|
437 | aws->create_input_field(AWAR_3D_HELIX_FROM, 5); |
---|
438 | aws->at("to"); |
---|
439 | aws->create_input_field(AWAR_3D_HELIX_TO, 5); |
---|
440 | aws->at("helixSize"); |
---|
441 | aws->create_input_field(AWAR_3D_HELIX_SIZE, 5); |
---|
442 | { |
---|
443 | const char *helixRange = NULp; |
---|
444 | |
---|
445 | arb_assert(RNA3D->cStructure); |
---|
446 | int rnaType = RNA3D->cStructure->FindTypeOfRNA(); |
---|
447 | |
---|
448 | switch (rnaType) { |
---|
449 | case LSU_23S: helixRange = "[1-101]"; break; |
---|
450 | case SSU_16S: helixRange = "[1-50]"; break; |
---|
451 | case LSU_5S: helixRange = "[1-5]"; break; |
---|
452 | } |
---|
453 | aws->at("rangeLabel"); |
---|
454 | aws->create_autosize_button(NULp, helixRange); |
---|
455 | } |
---|
456 | |
---|
457 | aws->at("dispTI"); |
---|
458 | aws->create_toggle(AWAR_3D_DISPLAY_TERTIARY_INTRACTIONS); |
---|
459 | } |
---|
460 | aws->show(); |
---|
461 | return aws; |
---|
462 | } |
---|
463 | |
---|
464 | static AW_window *CreateDisplayOptions_window(AW_root *aw_root) { |
---|
465 | AW_window_simple *aws = new AW_window_simple; |
---|
466 | |
---|
467 | aws->init(aw_root, "GENERAL_DISPLAY", "RNA3D : General Display "); |
---|
468 | aws->load_xfig("RNA3D_DisplayOptions.fig"); |
---|
469 | |
---|
470 | aws->callback(makeHelpCallback("rna3d_dispMolecule.hlp")); |
---|
471 | aws->at("help"); |
---|
472 | aws->button_length(0); |
---|
473 | aws->create_button("HELP", "#help.xpm"); |
---|
474 | |
---|
475 | aws->at("close"); |
---|
476 | aws->callback(AW_POPDOWN); |
---|
477 | aws->button_length(0); |
---|
478 | aws->create_button("CLOSE", "#closeText.xpm"); |
---|
479 | |
---|
480 | { // Display Molecule Section |
---|
481 | aws->at("backbone"); |
---|
482 | aws->create_toggle(AWAR_3D_MOL_BACKBONE); |
---|
483 | aws->at("color"); |
---|
484 | aws->create_toggle(AWAR_3D_MOL_COLORIZE); |
---|
485 | aws->at("dispPos"); |
---|
486 | aws->create_toggle(AWAR_3D_MOL_DISP_POS); |
---|
487 | aws->at("rot"); |
---|
488 | aws->create_toggle(AWAR_3D_MOL_ROTATE); |
---|
489 | aws->at("pos"); |
---|
490 | aws->create_input_field(AWAR_3D_MOL_POS_INTERVAL, 2); |
---|
491 | aws->at("molSize"); |
---|
492 | aws->create_input_field(AWAR_3D_MOL_SIZE, 5); |
---|
493 | aws->at("cp"); |
---|
494 | aws->create_toggle(AWAR_3D_CURSOR_POSITION); |
---|
495 | } |
---|
496 | aws->show(); |
---|
497 | return aws; |
---|
498 | } |
---|
499 | |
---|
500 | |
---|
501 | static AW_window *CreateMapSequenceData_window(AW_root *aw_root) { |
---|
502 | AW_window_simple *aws = new AW_window_simple; |
---|
503 | |
---|
504 | aws->init(aw_root, "MAP_SPECIES", "RNA3D : Map Sequence Data "); |
---|
505 | aws->load_xfig("RNA3D_SeqMapping.fig"); |
---|
506 | |
---|
507 | aws->callback(makeHelpCallback("rna3d_mapSeqData.hlp")); |
---|
508 | aws->at("help"); |
---|
509 | aws->button_length(0); |
---|
510 | aws->create_button("HELP", "#help.xpm"); |
---|
511 | |
---|
512 | aws->at("close"); |
---|
513 | aws->callback(AW_POPDOWN); |
---|
514 | aws->button_length(0); |
---|
515 | aws->create_button("CLOSE", "#closeText.xpm"); |
---|
516 | |
---|
517 | aws->callback(SynchronizeColorsWithEditor); |
---|
518 | aws->at("sync"); |
---|
519 | aws->button_length(35); |
---|
520 | aws->create_button("SYNC", "SYNCHRONIZE COLORS WITH EDITOR"); |
---|
521 | |
---|
522 | { // Display Map Current Species Section |
---|
523 | aws->at("en"); |
---|
524 | aws->create_toggle(AWAR_3D_MAP_ENABLE); |
---|
525 | |
---|
526 | aws->at("src"); |
---|
527 | aws->create_toggle(AWAR_3D_MAP_SEARCH_STRINGS); |
---|
528 | |
---|
529 | aws->at("sai"); |
---|
530 | aws->create_toggle(AWAR_3D_MAP_SAI); |
---|
531 | |
---|
532 | aws->callback(RefreshMappingDisplay); |
---|
533 | aws->at("ref"); |
---|
534 | aws->button_length(0); |
---|
535 | aws->create_button("REFRESH", "#refresh.xpm"); |
---|
536 | |
---|
537 | aws->at("sp"); |
---|
538 | aws->create_toggle(AWAR_3D_MAP_SPECIES); |
---|
539 | aws->at("base"); |
---|
540 | aws->create_toggle(AWAR_3D_MAP_SPECIES_DISP_BASE); |
---|
541 | aws->at("pos"); |
---|
542 | aws->create_toggle(AWAR_3D_MAP_SPECIES_DISP_POS); |
---|
543 | aws->at("del"); |
---|
544 | aws->create_toggle(AWAR_3D_MAP_SPECIES_DISP_DELETIONS); |
---|
545 | aws->at("mis"); |
---|
546 | aws->create_toggle(AWAR_3D_MAP_SPECIES_DISP_MISSING); |
---|
547 | aws->at("ins"); |
---|
548 | aws->create_toggle(AWAR_3D_MAP_SPECIES_DISP_INSERTIONS); |
---|
549 | aws->at("bs"); |
---|
550 | aws->create_toggle(AWAR_3D_MAP_SPECIES_DISP_INSERTIONS_INFO); |
---|
551 | } |
---|
552 | aws->show(); |
---|
553 | return aws; |
---|
554 | } |
---|
555 | |
---|
556 | static AW_window *CreateChangeMolecule_window(AW_root *aw_root) { |
---|
557 | AW_window_simple *aws = new AW_window_simple; |
---|
558 | |
---|
559 | aws->init(aw_root, "CHANGE_MOLECULE", "RNA3D : Change 3D Molecule"); |
---|
560 | aws->load_xfig("RNA3D_ChangeMolecule.fig"); |
---|
561 | |
---|
562 | aws->callback(makeHelpCallback("rna3d_changeMolecule.hlp")); |
---|
563 | aws->at("help"); |
---|
564 | aws->button_length(0); |
---|
565 | aws->create_button("HELP", "#help.xpm"); |
---|
566 | |
---|
567 | aws->at("close"); |
---|
568 | aws->callback(AW_POPDOWN); |
---|
569 | aws->button_length(0); |
---|
570 | aws->create_button("CLOSE", "#closeText.xpm"); |
---|
571 | |
---|
572 | aws->callback(makeWindowCallback(Change3DMolecule, 1)); |
---|
573 | aws->at("1pnu"); |
---|
574 | aws->button_length(73); |
---|
575 | aws->create_button(NULp, "1PNU: 8.7 A^ Vila-Sanjurjo et al. Proc.Nat.Acad.Sci.(2003) 100, 8682."); |
---|
576 | |
---|
577 | aws->callback(makeWindowCallback(Change3DMolecule, 2)); |
---|
578 | aws->at("1vor"); |
---|
579 | aws->button_length(73); |
---|
580 | aws->create_button(NULp, "1VOR: 11.5 A^ Vila-Sanjurjo et al. Nat.Struct.Mol.Biol.(2004) 11, 1054."); |
---|
581 | |
---|
582 | aws->callback(makeWindowCallback(Change3DMolecule, 3)); |
---|
583 | aws->at("1c2w"); |
---|
584 | aws->button_length(73); |
---|
585 | aws->create_button(NULp, "1C2W: 7.5 A^ Mueller et al. J.Mol.Biol.(2000) 298, 35-59.", NULp, "white"); |
---|
586 | |
---|
587 | aws->show(); |
---|
588 | return aws; |
---|
589 | } |
---|
590 | |
---|
591 | static AW_window *CreateRNA3DGcWindow(AW_root *awr, AW_gc_manager *gcman) { |
---|
592 | return AW_create_gc_window_named(awr, gcman, "RNA3D_COLOR_DEF2", "RNA3D colors and fonts"); |
---|
593 | } |
---|
594 | |
---|
595 | AW_window *CreateRNA3DMainWindow(AW_root *awr, GBDATA *gb_main, ED4_plugin_host& host) { |
---|
596 | // Main Window - Canvas on which the actual painting is done |
---|
597 | GB_transaction ta(gb_main); |
---|
598 | |
---|
599 | awr->awar_int(AWAR_3D_SAI_SELECTED, 0, AW_ROOT_DEFAULT); |
---|
600 | |
---|
601 | RNA3D_init_global_data(host); |
---|
602 | |
---|
603 | awm = new AW_window_menu_modes_opengl; |
---|
604 | awm->init(awr, "RNA3D", "RNA3D: 3D Structure of Ribosomal RNA", WINDOW_WIDTH, WINDOW_HEIGHT); |
---|
605 | |
---|
606 | RNA3D_Graphics *rna3DGraphics = new RNA3D_Graphics(awr, gb_main); |
---|
607 | |
---|
608 | Structure3D::gb_main = gb_main; |
---|
609 | |
---|
610 | RNA3D->gl_Canvas = new AWT_canvas(Structure3D::gb_main, awm, awm->get_window_id(), rna3DGraphics); |
---|
611 | |
---|
612 | AWT_auto_refresh allowed_on(RNA3D->gl_Canvas); |
---|
613 | RNA3D->gl_Canvas->request_resize(); |
---|
614 | RNA3D->gl_Canvas->set_mode(AWT_MODE_NONE); |
---|
615 | |
---|
616 | awm->create_menu("File", "F", AWM_ALL); |
---|
617 | { |
---|
618 | arb_assert(RNA3D->cStructure); |
---|
619 | int rnaType = RNA3D->cStructure->FindTypeOfRNA(); |
---|
620 | if (rnaType == LSU_23S) { |
---|
621 | awm->insert_menu_topic("changeMolecule", "Change Molecule", "M", "rna3d_changeMolecule.hlp", AWM_ALL, CreateChangeMolecule_window); |
---|
622 | } |
---|
623 | } |
---|
624 | awm->insert_menu_topic("close", "Close", "C", "quit.hlp", AWM_ALL, AW_POPDOWN); |
---|
625 | |
---|
626 | { |
---|
627 | awm->at(1, 2); |
---|
628 | awm->auto_space(2, 0); |
---|
629 | awm->shadow_width(1); |
---|
630 | |
---|
631 | int cur_x, cur_y, start_x, first_line_y, second_line_y; |
---|
632 | awm->get_at_position(&start_x, &first_line_y); |
---|
633 | awm->button_length(0); |
---|
634 | awm->callback(AW_POPDOWN); |
---|
635 | awm->create_button("Quit", "#quit.xpm"); |
---|
636 | |
---|
637 | awm->get_at_position(&cur_x, &cur_y); |
---|
638 | awm->callback(RefreshMappingDisplay); |
---|
639 | awm->button_length(0); |
---|
640 | awm->create_button("REFRESH", "#refresh.xpm"); |
---|
641 | |
---|
642 | awm->get_at_position(&cur_x, &cur_y); |
---|
643 | awm->button_length(0); |
---|
644 | awm->create_toggle(AWAR_3D_DISPLAY_MASK, "#unmask.xpm", "#mask.xpm"); |
---|
645 | |
---|
646 | awm->get_at_position(&cur_x, &cur_y); |
---|
647 | awm->callback(makeCreateWindowCallback(CreateRNA3DGcWindow, RNA3D->gl_Canvas->gc_manager)); |
---|
648 | awm->button_length(0); |
---|
649 | awm->create_button("setColors", "#colors.xpm"); |
---|
650 | |
---|
651 | awm->get_at_position(&cur_x, &cur_y); |
---|
652 | awm->help_text("rna3d_dispBases.hlp"); |
---|
653 | awm->callback(CreateDisplayBases_window); |
---|
654 | awm->button_length(0); |
---|
655 | awm->create_button("displayBases", "#basesText.xpm"); |
---|
656 | |
---|
657 | awm->get_at_position(&cur_x, &cur_y); |
---|
658 | awm->at(cur_x-10, cur_y); |
---|
659 | awm->create_toggle(AWAR_3D_DISPLAY_BASES, "#uncheck.xpm", "#check.xpm"); |
---|
660 | |
---|
661 | awm->get_at_position(&cur_x, &cur_y); |
---|
662 | awm->help_text("rna3d_dispHelices.hlp"); |
---|
663 | awm->callback(CreateDisplayHelices_window); |
---|
664 | awm->button_length(0); |
---|
665 | awm->create_button("displayHelix", "#helixText.xpm"); |
---|
666 | |
---|
667 | awm->get_at_position(&cur_x, &cur_y); |
---|
668 | awm->at(cur_x-10, cur_y); |
---|
669 | awm->create_toggle(AWAR_3D_DISPLAY_HELIX, "#uncheck.xpm", "#check.xpm"); |
---|
670 | |
---|
671 | awm->get_at_position(&cur_x, &cur_y); |
---|
672 | awm->help_text("rna3d_dispMolecule.hlp"); |
---|
673 | awm->callback(CreateDisplayOptions_window); |
---|
674 | awm->button_length(0); |
---|
675 | awm->create_button("displayMolecule", "#molText.xpm"); |
---|
676 | |
---|
677 | awm->get_at_position(&cur_x, &cur_y); |
---|
678 | awm->help_text("rna3d_mapSeqData.hlp"); |
---|
679 | awm->callback(CreateMapSequenceData_window); |
---|
680 | awm->button_length(0); |
---|
681 | awm->create_button("mapSpecies", "#mapping.xpm"); |
---|
682 | |
---|
683 | awm->get_at_position(&cur_x, &cur_y); |
---|
684 | awm->at(cur_x-10, cur_y); |
---|
685 | awm->create_toggle(AWAR_3D_MAP_ENABLE, "#uncheck.xpm", "#check.xpm"); |
---|
686 | |
---|
687 | awm->get_at_position(&cur_x, &cur_y); |
---|
688 | awm->callback(makeHelpCallback("rna3d_general.hlp")); |
---|
689 | awm->button_length(0); |
---|
690 | awm->create_button("help", "#helpText.xpm"); |
---|
691 | |
---|
692 | awm->at_newline(); |
---|
693 | awm->get_at_position(&cur_x, &second_line_y); |
---|
694 | awm->create_autosize_button(NULp, " Spacebar = auto rotate mode on/off | Mouse Left Button + Move = Rotates Molecule | Mouse Wheel = Zoom in/out"); |
---|
695 | } |
---|
696 | |
---|
697 | AddCallBacks(awr); |
---|
698 | RNA3D->root = awr; |
---|
699 | |
---|
700 | appContext = AW_get_XtAppContext(awr); |
---|
701 | |
---|
702 | RNA3D->OpenGLEngineState = NOT_CREATED; |
---|
703 | |
---|
704 | // Add event handlers: |
---|
705 | Widget middle_area_widget = AW_get_AreaWidget(RNA3D->gl_Canvas->aww, AW_MIDDLE_AREA); |
---|
706 | |
---|
707 | XtAddEventHandler(middle_area_widget, StructureNotifyMask, 0, ResizeOpenGLWindow, (XtPointer)NULp); |
---|
708 | XtAddEventHandler(middle_area_widget, ExposureMask, 0, ExposeOpenGLWindow, (XtPointer)NULp); |
---|
709 | XtAddEventHandler(middle_area_widget, KeyPressMask, 0, KeyPressEventHandler, (XtPointer)NULp); |
---|
710 | XtAddEventHandler(middle_area_widget, KeyReleaseMask, 0, KeyReleaseEventHandler, (XtPointer)NULp); |
---|
711 | XtAddEventHandler(middle_area_widget, ButtonPressMask, 0, ButtonPressEventHandler, (XtPointer)NULp); |
---|
712 | XtAddEventHandler(middle_area_widget, ButtonReleaseMask, 0, ButtonReleaseEventHandler, (XtPointer)NULp); |
---|
713 | XtAddEventHandler(middle_area_widget, PointerMotionMask, 0, MouseMoveEventHandler, (XtPointer)NULp); |
---|
714 | |
---|
715 | #ifdef DEBUG |
---|
716 | cout<<"RNA3D: OpenGL Window created!"<<endl; |
---|
717 | #endif |
---|
718 | |
---|
719 | InitCallBacks(awr); |
---|
720 | |
---|
721 | return awm; |
---|
722 | } |
---|