/*========================================================================*/ int ControlRock(PyMOLGlobals * G, int mode) { switch (mode) { case -2: break; case -1: SettingSetGlobal_b(G, cSetting_rock, !SettingGetGlobal_b(G, cSetting_rock)); if(SettingGetGlobal_b(G, cSetting_rock)) { SceneRestartSweepTimer(G); } break; case 0: SettingSetGlobal_b(G, cSetting_rock, false); break; case 1: SettingSetGlobal_b(G, cSetting_rock, true); SceneRestartSweepTimer(G); break; } if(mode != -2) { SceneRestartFrameTimer(G); OrthoDirty(G); } return SettingGetGlobal_b(G, cSetting_rock); }
static int RepWireBondCGOGenerate(RepWireBond * I, RenderInfo * info) { PyMOLGlobals *G = I->R.G; CGO *convertcgo = NULL; int ok = true; short line_as_cylinders = 0; line_as_cylinders = SettingGetGlobal_b(G, cSetting_use_shaders) && SettingGetGlobal_b(G, cSetting_render_as_cylinders) && SettingGetGlobal_b(G, cSetting_line_as_cylinders); { if (ok && I->primitiveCGO){ if (line_as_cylinders){ CGO *tmpCGO = CGONew(G); if (ok) ok &= CGOEnable(tmpCGO, GL_CYLINDER_SHADER); if (ok) ok &= CGOSpecial(tmpCGO, CYLINDER_WIDTH_FOR_REPWIRE); convertcgo = CGOConvertLinesToCylinderShader(I->primitiveCGO, tmpCGO); I->shaderCGO_has_cylinders = true; if (ok) ok &= CGOAppendNoStop(tmpCGO, convertcgo); if (ok) ok &= CGODisable(tmpCGO, GL_CYLINDER_SHADER); if (ok) ok &= CGOStop(tmpCGO); CGOFreeWithoutVBOs(convertcgo); convertcgo = tmpCGO; } else { bool trilines = SettingGetGlobal_b(G, cSetting_trilines); CGO *tmpCGO = CGONew(G), *tmp2CGO; int shader = trilines ? GL_TRILINES_SHADER : GL_LINE_SHADER; if (ok) ok &= CGOEnable(tmpCGO, shader); if (ok) ok &= CGODisable(tmpCGO, CGO_GL_LIGHTING); if (trilines) { if (ok) ok &= CGOSpecial(tmpCGO, LINEWIDTH_DYNAMIC_WITH_SCALE); tmp2CGO = CGOConvertToTrilinesShader(I->primitiveCGO, tmpCGO); } else { tmp2CGO = CGOConvertToLinesShader(I->primitiveCGO, tmpCGO); } if (ok) ok &= CGOAppendNoStop(tmpCGO, tmp2CGO); if (ok) ok &= CGODisable(tmpCGO, shader); if (ok) ok &= CGOStop(tmpCGO); CGOFreeWithoutVBOs(tmp2CGO); convertcgo = tmpCGO; } convertcgo->use_shader = true; } CGOFree(I->shaderCGO); I->shaderCGO = convertcgo; CHECKOK(ok, I->shaderCGO); } return ok; }
/*========================================================================*/ int ControlIdling(PyMOLGlobals * G) { CControl *I = G->Control; return (I->sdofActive || MoviePlaying(G) || SettingGetGlobal_b(G, cSetting_rock) || SettingGet(G, cSetting_sculpting)); }
int ControlRocking(PyMOLGlobals * G) { if(G->Interrupt) { SettingSetGlobal_b(G, cSetting_rock, false); } return SettingGetGlobal_b(G, cSetting_rock); }
void *_MemoryCacheCalloc(PyMOLGlobals * G, unsigned int number, unsigned int size, int group_id, int block_id MD_FILE_LINE_Decl) { if((group_id < 0) || (!SettingGetGlobal_b(G, cSetting_cache_memory))) return (mcalloc(number, size)); { register CMemoryCache *I = G->MemoryCache; register MemoryCacheRec *rec = &I->Cache[group_id][block_id]; unsigned int true_size = number * size; /* interesting result: calloc is faster than cacheing */ if(!rec->ptr) { rec->size = true_size; rec->ptr = mcalloc(number, size); } else if(rec->size < true_size) { mfree(rec->ptr); rec->size = true_size; rec->ptr = mcalloc(number, size); } else { mfree(rec->ptr); rec->size = true_size; rec->ptr = mcalloc(number, size); } return (rec->ptr); } }
void *_MemoryShrinkForSure(PyMOLGlobals * G, void *ptr, unsigned int size, int group_id, int block_id MD_FILE_LINE_Decl) { /* no checking done */ if((group_id < 0) || (!SettingGetGlobal_b(G, cSetting_cache_memory))) return (ReallocForSure(ptr, size)); /* NOTE: fatal if new ptr is larger than old... */ { register CMemoryCache *I = G->MemoryCache; register MemoryCacheRec *rec = &I->Cache[group_id][block_id]; if(ptr != rec->ptr) printf("Error: Memory Cache Mismatch 2 %d %d\n", group_id, block_id); if(!rec->ptr) { /* not currently cache-allocated... this should never happen */ rec->size = size; rec->ptr = mrealloc(ptr, size); } else if(rec->size < size) { rec->ptr = MemoryReallocForSureSafe(ptr, size, rec->size); rec->size = size; } else { /* expanding size...should never happen... this should never happen */ rec->size = size; rec->ptr = mrealloc(ptr, size); } return (rec->ptr); } }
static void RepWireBondRender(RepWireBond * I, RenderInfo * info) { PyMOLGlobals *G = I->R.G; CRay *ray = info->ray; auto pick = info->pick; int ok = true; if(ray) { #ifndef _PYMOL_NO_RAY CGORenderRay(I->primitiveCGO, ray, info, NULL, NULL, I->R.cs->Setting, I->R.cs->Obj->Obj.Setting); ray->transparentf(0.0); #endif } else if(G->HaveGUI && G->ValidContext) { bool use_shader = SettingGetGlobal_b(G, cSetting_line_use_shader) && SettingGetGlobal_b(G, cSetting_use_shaders); if(pick) { CGORenderGLPicking(use_shader ? I->shaderCGO : I->primitiveCGO, info, &I->R.context, NULL, NULL, &I->R); } else { /* else not pick i.e., when rendering */ short line_as_cylinders ; line_as_cylinders = SettingGetGlobal_b(G, cSetting_render_as_cylinders) && SettingGetGlobal_b(G, cSetting_line_as_cylinders); if (I->shaderCGO && (!use_shader || (line_as_cylinders ^ I->shaderCGO_has_cylinders))){ CGOFree(I->shaderCGO); I->shaderCGO_has_cylinders = 0; } if (ok){ if (use_shader) { if (!I->shaderCGO) ok &= RepWireBondCGOGenerate(I, info); CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R); } else { CGORenderGL(I->primitiveCGO, NULL, NULL, NULL, info, &I->R); } } } } if (!ok){ CGOFree(I->shaderCGO); I->R.fInvalidate(&I->R, I->R.cs, cRepInvPurge); I->R.cs->Active[cRepLine] = false; } }
void MemoryCacheReplaceBlock(PyMOLGlobals * G, void *ptr, int group_id, int old_block_id, int new_block_id) { if((group_id < 0) || (!SettingGetGlobal_b(G, cSetting_cache_memory))) return; { register CMemoryCache *I = G->MemoryCache; register MemoryCacheRec *old_rec = &I->Cache[group_id][old_block_id]; register MemoryCacheRec *new_rec = &I->Cache[group_id][new_block_id]; if(new_rec->ptr) mfree(new_new->ptr); *(new_rec) = *(old_rec); old_rec->ptr = NULL; } }
void _MemoryCacheFree(PyMOLGlobals * G, void *ptr, int group_id, int block_id, int force MD_FILE_LINE_Decl) { if((group_id < 0) || (!SettingGetGlobal_b(G, cSetting_cache_memory))) { mfree(ptr); return; } { register CMemoryCache *I = G->MemoryCache; MemoryCacheRec *rec = &I->Cache[group_id][block_id]; if(rec->ptr && (ptr != rec->ptr)) printf("Error: Memory Cache Mismatch 2 %d %d\n", group_id, block_id); if(force) { if(rec->ptr) mfree(rec->ptr); rec->ptr = NULL; } } }
void *_MemoryCacheMalloc(PyMOLGlobals * G, unsigned int size, int group_id, int block_id MD_FILE_LINE_Decl) { if((group_id < 0) || (!SettingGetGlobal_b(G, cSetting_cache_memory))) return (mmalloc(size)); { register CMemoryCache *I = G->MemoryCache; register MemoryCacheRec *rec = &I->Cache[group_id][block_id]; if(!rec->ptr) { rec->size = size; rec->ptr = mmalloc(size); } else if(rec->size < size) { rec->size = size; mfree(rec->ptr); rec->ptr = mmalloc(size); } return (rec->ptr); } }
void *_MemoryCacheRealloc(PyMOLGlobals * G, void *ptr, unsigned int size, int group_id, int block_id MD_FILE_LINE_Decl) { /* no checking done */ if((group_id < 0) || (!SettingGetGlobal_b(G, cSetting_cache_memory))) return (mrealloc(ptr, size)); { register CMemoryCache *I = G->MemoryCache; register MemoryCacheRec *rec = &I->Cache[group_id][block_id]; if(ptr != rec->ptr) printf("Error: Memory Cache Mismatch 2 %d %d\n", group_id, block_id); if(!rec->ptr) { rec->size = size; rec->ptr = mrealloc(ptr, size); } else if(rec->size < size) { rec->size = size; rec->ptr = mrealloc(ptr, size); } return (rec->ptr); } }
/*========================================================================*/ static void ControlDraw(Block * block) { PyMOLGlobals *G = block->G; register CControl *I = G->Control; int x, y; int nButton = I->NButton; int but_num; float lightEdge[3] = { 0.65F, 0.65F, 0.65F }; float darkEdge[3] = { 0.3F, 0.3F, 0.3F }; float pushed[3] = { 0.8F, 0.8F, 0.8F }; if(G->HaveGUI && G->ValidContext) { int control_width = I->Block->rect.right - (I->Block->rect.left + cControlLeftMargin); #ifdef PURE_OPENGL_ES_2 /* TODO */ #else glColor3fv(I->Block->BackColor); #endif BlockFill(I->Block); #ifdef PURE_OPENGL_ES_2 /* TODO */ #else glColor3fv(I->Block->TextColor); #endif { int top, left, bottom, right; left = I->Block->rect.left + 1; bottom = I->Block->rect.bottom + 1; top = I->Block->rect.top - (cControlTopMargin - 1); right = left + 5; /* This draws the separator on the left side of the movie control buttons */ #ifdef PURE_OPENGL_ES_2 /* TODO */ #else #ifdef _PYMOL_GL_DRAWARRAYS { const GLint polyVerts[] = { right, top, right, bottom, left, bottom, left, bottom, left, top, right, top, right, top - 1, right, bottom, left + 1, bottom, left + 1, bottom, left + 1, top - 1, right, top - 1, right - 1, top - 1, right - 1, bottom + 1, left + 1, bottom + 1, left + 1, bottom + 1, left + 1, top - 1, right - 1, top - 1, }; const GLfloat colorVerts[] = { 0.8F, 0.8F, 0.8F, 1.f, 0.8F, 0.8F, 0.8F, 1.f, 0.8F, 0.8F, 0.8F, 1.f, 0.8F, 0.8F, 0.8F, 1.f, 0.8F, 0.8F, 0.8F, 1.f, 0.8F, 0.8F, 0.8F, 1.f, 0.3F, 0.3F, 0.3F, 1.f, 0.3F, 0.3F, 0.3F, 1.f, 0.3F, 0.3F, 0.3F, 1.f, 0.3F, 0.3F, 0.3F, 1.f, 0.3F, 0.3F, 0.3F, 1.f, 0.3F, 0.3F, 0.3F, 1.f, I->ButtonColor[0], I->ButtonColor[1], I->ButtonColor[2], 1.f, I->ButtonColor[0], I->ButtonColor[1], I->ButtonColor[2], 1.f, I->ButtonColor[0], I->ButtonColor[1], I->ButtonColor[2], 1.f, I->ButtonColor[0], I->ButtonColor[1], I->ButtonColor[2], 1.f, I->ButtonColor[0], I->ButtonColor[1], I->ButtonColor[2], 1.f, I->ButtonColor[0], I->ButtonColor[1], I->ButtonColor[2], 1.f }; glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glColorPointer(4, GL_FLOAT, 0, colorVerts); glVertexPointer(2, GL_INT, 0, polyVerts); glDrawArrays(GL_TRIANGLES, 0, 18); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); } #else glColor3f(0.8F, 0.8F, 0.8F); glBegin(GL_POLYGON); glVertex2i(right, top); glVertex2i(right, bottom); glVertex2i(left, bottom); glVertex2i(left, top); glEnd(); glColor3f(0.3F, 0.3F, 0.3F); glBegin(GL_POLYGON); glVertex2i(right, top - 1); glVertex2i(right, bottom); glVertex2i(left + 1, bottom); glVertex2i(left + 1, top - 1); glEnd(); glColor3fv(I->ButtonColor); glBegin(GL_POLYGON); glVertex2i(right - 1, top - 1); glVertex2i(right - 1, bottom + 1); glVertex2i(left + 1, bottom + 1); glVertex2i(left + 1, top - 1); glEnd(); #endif #endif } y = I->Block->rect.top - cControlTopMargin; for(but_num = 0; but_num < nButton; but_num++) { int but_width; int but_left; int but_bottom; int but_height; but_left = I->Block->rect.left + cControlLeftMargin + (but_num * control_width) / nButton; but_width = (((but_num + 1) * control_width / nButton) - ((but_num) * control_width / nButton)) - 1; but_bottom = y - (cControlBoxSize - 1); but_height = cControlBoxSize; if((but_num == I->Active)) { draw_button(but_left, but_bottom, but_width, but_height, lightEdge, darkEdge, pushed); } else if(((but_num == 6) && ((int) SettingGet(G, cSetting_seq_view))) || ((but_num == 3) && (MoviePlaying(G))) || ((but_num == 7) && (SettingGetGlobal_b(G, cSetting_rock))) || ((but_num == 8) && (SettingGetGlobal_b(G, cSetting_full_screen)))) { draw_button(but_left, but_bottom, but_width, but_height, lightEdge, darkEdge, I->ActiveColor); } else { draw_button(but_left, but_bottom, but_width, but_height, lightEdge, darkEdge, I->ButtonColor); } if(control_width > 100) { x = but_left + (but_width - cControlBoxSize) / 2; #ifdef PURE_OPENGL_ES_2 /* TODO */ #else glColor3fv(I->Block->TextColor); #endif switch (but_num) { case 0: #ifdef PURE_OPENGL_ES_2 /* TODO */ #else #ifdef _PYMOL_GL_DRAWARRAYS { const GLint polyVerts[] = { x + (cControlBoxSize - 1) - cControlInnerMargin, y - cControlInnerMargin, x + (cControlBoxSize - 1) - cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin, x + cControlInnerMargin, y - (cControlBoxSize / 2) }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_INT, 0, polyVerts); glDrawArrays(GL_TRIANGLES, 0, 3); glDisableClientState(GL_VERTEX_ARRAY); } { const GLint lineVerts[] = { x + cControlInnerMargin, y - cControlInnerMargin, x + cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_INT, 0, lineVerts); glDrawArrays(GL_LINES, 0, 2); glDisableClientState(GL_VERTEX_ARRAY); } #else glBegin(GL_TRIANGLES); glVertex2i(x + (cControlBoxSize - 1) - cControlInnerMargin, y - cControlInnerMargin); glVertex2i(x + (cControlBoxSize - 1) - cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin); glVertex2i(x + cControlInnerMargin, y - (cControlBoxSize / 2)); glEnd(); glBegin(GL_LINES); glVertex2i(x + cControlInnerMargin, y - cControlInnerMargin); glVertex2i(x + cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin); glEnd(); #endif #endif break; case 1: #ifdef PURE_OPENGL_ES_2 /* TODO */ #else #ifdef _PYMOL_GL_DRAWARRAYS { const GLint polyVerts[] = { x + cControlBoxSize / 2 + 2, y - (cControlBoxSize / 2), x + (cControlBoxSize - 1) - cControlInnerMargin, y - cControlInnerMargin, x + (cControlBoxSize - 1) - cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin, x + cControlInnerMargin, y - (cControlBoxSize / 2) }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_INT, 0, polyVerts); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDisableClientState(GL_VERTEX_ARRAY); } #else glBegin(GL_POLYGON); glVertex2i(x + cControlBoxSize / 2 + 2, y - (cControlBoxSize / 2)); glVertex2i(x + (cControlBoxSize - 1) - cControlInnerMargin, y - cControlInnerMargin); glVertex2i(x + cControlInnerMargin, y - (cControlBoxSize / 2)); glVertex2i(x + (cControlBoxSize - 1) - cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin); glEnd(); #endif #endif break; case 2: #ifdef PURE_OPENGL_ES_2 /* TODO */ #else #ifdef _PYMOL_GL_DRAWARRAYS { const GLint polyVerts[] = { x + cControlInnerMargin, y - cControlInnerMargin, x + cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin, x + (cControlBoxSize - 1) - cControlInnerMargin, y - cControlInnerMargin, x + (cControlBoxSize - 1) - cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_INT, 0, polyVerts); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDisableClientState(GL_VERTEX_ARRAY); } #else glBegin(GL_POLYGON); glVertex2i(x + cControlInnerMargin, y - cControlInnerMargin); glVertex2i(x + cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin); glVertex2i(x + (cControlBoxSize - 1) - cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin); glVertex2i(x + (cControlBoxSize - 1) - cControlInnerMargin, y - cControlInnerMargin); glEnd(); #endif #endif break; case 3: #ifdef PURE_OPENGL_ES_2 /* TODO */ #else #ifdef _PYMOL_GL_DRAWARRAYS { const GLint polyVerts[] = { x + cControlInnerMargin, y - cControlInnerMargin + 1, x + cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin - 1, x + (cControlBoxSize) - cControlInnerMargin, y - (cControlBoxSize / 2) }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_INT, 0, polyVerts); glDrawArrays(GL_TRIANGLES, 0, 3); glDisableClientState(GL_VERTEX_ARRAY); } #else glBegin(GL_TRIANGLES); glVertex2i(x + cControlInnerMargin, y - cControlInnerMargin + 1); glVertex2i(x + cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin - 1); glVertex2i(x + (cControlBoxSize) - cControlInnerMargin, y - (cControlBoxSize / 2)); glEnd(); #endif #endif break; case 4: #ifdef PURE_OPENGL_ES_2 /* TODO */ #else #ifdef _PYMOL_GL_DRAWARRAYS { const GLint polyVerts[] = { x + cControlBoxSize / 2 - 2, y - (cControlBoxSize / 2), x + cControlInnerMargin, y - cControlInnerMargin, x + cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin, x + (cControlBoxSize - 1) - cControlInnerMargin, y - (cControlBoxSize / 2) }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_INT, 0, polyVerts); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDisableClientState(GL_VERTEX_ARRAY); } #else glBegin(GL_POLYGON); glVertex2i(x + cControlBoxSize / 2 - 2, y - (cControlBoxSize / 2)); glVertex2i(x + cControlInnerMargin, y - cControlInnerMargin); glVertex2i(x + (cControlBoxSize - 1) - cControlInnerMargin, y - (cControlBoxSize / 2)); glVertex2i(x + cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin); glEnd(); #endif #endif break; case 5: #ifdef PURE_OPENGL_ES_2 /* TODO */ #else #ifdef _PYMOL_GL_DRAWARRAYS { const GLint polyVerts[] = { x + cControlInnerMargin, y - cControlInnerMargin, x + cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin, x + (cControlBoxSize - 1) - cControlInnerMargin, y - (cControlBoxSize / 2) }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_INT, 0, polyVerts); glDrawArrays(GL_TRIANGLES, 0, 3); glDisableClientState(GL_VERTEX_ARRAY); } { const GLint lineVerts[] = { x + (cControlBoxSize - 1) - cControlInnerMargin, y - cControlInnerMargin, x + (cControlBoxSize - 1) - cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_INT, 0, lineVerts); glDrawArrays(GL_LINES, 0, 2); glDisableClientState(GL_VERTEX_ARRAY); } #else glBegin(GL_TRIANGLES); glVertex2i(x + cControlInnerMargin, y - cControlInnerMargin); glVertex2i(x + cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin); glVertex2i(x + (cControlBoxSize - 1) - cControlInnerMargin, y - (cControlBoxSize / 2)); glEnd(); glBegin(GL_LINES); glVertex2i(x + (cControlBoxSize - 1) - cControlInnerMargin, y - cControlInnerMargin); glVertex2i(x + (cControlBoxSize - 1) - cControlInnerMargin, y - (cControlBoxSize - 1) + cControlInnerMargin); glEnd(); #endif #endif break; case 6: TextDrawStrAt(G, "S", x + cControlInnerMargin, y - cControlBoxSize + cControlInnerMargin + 1); break; case 7: /* TextDrawStrAt(G,"R",x+cControlInnerMargin, y-cControlBoxSize+cControlInnerMargin+1); */ #ifdef PURE_OPENGL_ES_2 /* TODO */ #else #ifdef _PYMOL_GL_DRAWARRAYS { const GLint polyVerts[] = { x + (cControlBoxSize / 2) + cControlSpread, y - cControlInnerMargin, x + (cControlBoxSize / 2), y - (cControlBoxSize) + cControlInnerMargin, x + (cControlBoxSize / 2) - cControlSpread, y - cControlInnerMargin }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_INT, 0, polyVerts); glDrawArrays(GL_TRIANGLES, 0, 3); glDisableClientState(GL_VERTEX_ARRAY); } #else glBegin(GL_POLYGON); glVertex2i(x + (cControlBoxSize / 2) + cControlSpread, y - cControlInnerMargin); glVertex2i(x + (cControlBoxSize / 2), y - (cControlBoxSize) + cControlInnerMargin); glVertex2i(x + (cControlBoxSize / 2) - cControlSpread, y - cControlInnerMargin); glEnd(); #endif #endif break; case 8: TextDrawStrAt(G, "F", x + cControlInnerMargin, y - cControlBoxSize + cControlInnerMargin + 1); break; } } } #ifdef _MACPYMOL_XCODE if((I->Block->rect.bottom==0) && (!SettingGetGlobal_b(G,cSetting_full_screen))) { int x1 = I->Block->rect.right + 1; int y1 = I->Block->rect.bottom - 1; int x2 = I->Block->rect.right - 3; int y2 = I->Block->rect.bottom - 5; glColor3f(0.3F, 0.3F, 0.3F); #ifdef PURE_OPENGL_ES_2 /* TODO */ #else #ifdef _PYMOL_GL_DRAWARRAYS { const GLint lineVerts[] = { x1, y1, x2, y2, x1, y1 + 4, x2 - 4, y2, x1, y1 + 8, x2 - 8, y2, x1, y1 + 12, x2 - 12, y2, x1 - 4, y1 + 12, x2 - 12, y2 + 4, x1 - 8, y1 + 12, x2 - 12, y2 + 8, x1 - 12, y1 + 12, x2 - 12, y2 + 12 }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_INT, 0, lineVerts); glDrawArrays(GL_LINES, 0, 14); glDisableClientState(GL_VERTEX_ARRAY); } #else glBegin(GL_LINES); glVertex2i(x1, y1); glVertex2i(x2, y2); x2 -= 4; y1 += 4; glVertex2i(x1, y1); glVertex2i(x2, y2); x2 -= 4; y1 += 4; glVertex2i(x1, y1); glVertex2i(x2, y2); x2 -= 4; y1 += 4; glVertex2i(x1, y1); glVertex2i(x2, y2); y2 += 4; x1 -= 4; glVertex2i(x1, y1); glVertex2i(x2, y2); y2 += 4; x1 -= 4; glVertex2i(x1, y1); glVertex2i(x2, y2); y2 += 4; x1 -= 4; glVertex2i(x1, y1); glVertex2i(x2, y2); glEnd(); #endif #endif x1 = I->Block->rect.right + 1; y1 = I->Block->rect.bottom - 2; x2 = I->Block->rect.right - 2; y2 = I->Block->rect.bottom - 5; #ifdef PURE_OPENGL_ES_2 /* TODO */ #else glColor3f(0.85F, 0.85F, 0.85F); #ifdef _PYMOL_GL_DRAWARRAYS { const GLint lineVerts[] = { x1, y1, x2, y2, x1, y1 + 4, x2 - 4, y2, x1, y1 + 8, x2 - 8, y2, x1, y1 + 12, x2 - 12, y2, x1 - 4, y1 + 12, x2 - 12, y2 + 4, x1 - 8, y1 + 12, x2 - 12, y2 + 8, x1 - 12, y1 + 12, x2 - 12, y2 + 12 }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_INT, 0, lineVerts); glDrawArrays(GL_LINES, 0, 14); glDisableClientState(GL_VERTEX_ARRAY); } #else glBegin(GL_LINES); glVertex2i(x1, y1); glVertex2i(x2, y2); x2 -= 4; y1 += 4; glVertex2i(x1, y1); glVertex2i(x2, y2); x2 -= 4; y1 += 4; glVertex2i(x1, y1); glVertex2i(x2, y2); x2 -= 4; y1 += 4; glVertex2i(x1, y1); glVertex2i(x2, y2); y2 += 4; x1 -= 4; glVertex2i(x1, y1); glVertex2i(x2, y2); y2 += 4; x1 -= 4; glVertex2i(x1, y1); glVertex2i(x2, y2); y2 += 4; x1 -= 4; glVertex2i(x1, y1); glVertex2i(x2, y2); glEnd(); #endif #endif x1 = I->Block->rect.right + 1; y1 = I->Block->rect.bottom - 3; x2 = I->Block->rect.right - 1; y2 = I->Block->rect.bottom - 5; #ifdef PURE_OPENGL_ES_2 /* TODO */ #else glColor3f(0.7F, 0.7F, 0.7F); #ifdef _PYMOL_GL_DRAWARRAYS { const GLint lineVerts[] = { x1, y1, x2, y2, x1, y1 + 4, x2 - 4, y2, x1, y1 + 8, x2 - 8, y2, x1, y1 + 12, x2 - 12, y2, x1 - 4, y1 + 12, x2 - 12, y2 + 4, x1 - 8, y1 + 12, x2 - 12, y2 + 8, x1 - 12, y1 + 12, x2 - 12, y2 + 12 }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_INT, 0, lineVerts); glDrawArrays(GL_LINES, 0, 14); glDisableClientState(GL_VERTEX_ARRAY); } #else glBegin(GL_LINES); glVertex2i(x1, y1); glVertex2i(x2, y2); x2 -= 4; y1 += 4; glVertex2i(x1, y1); glVertex2i(x2, y2); x2 -= 4; y1 += 4; glVertex2i(x1, y1); glVertex2i(x2, y2); x2 -= 4; y1 += 4; glVertex2i(x1, y1); glVertex2i(x2, y2); y2 += 4; x1 -= 4; glVertex2i(x1, y1); glVertex2i(x2, y2); y2 += 4; x1 -= 4; glVertex2i(x1, y1); glVertex2i(x2, y2); y2 += 4; x1 -= 4; glVertex2i(x1, y1); glVertex2i(x2, y2); glEnd(); #endif #endif } #endif } }
static int ControlRelease(Block * block, int button, int x, int y, int mod) { PyMOLGlobals *G = block->G; register CControl *I = G->Control; int sel = 0; I->LastPos = x; sel = which_button(I, x, y); if(!I->SkipRelease) { switch (sel) { case 0: SceneSetFrame(G, 4, 0); PLog(G, "cmd.rewind()", cPLog_pym); break; case 1: SceneSetFrame(G, 5, -1); PLog(G, "cmd.back()", cPLog_pym); break; case 2: MoviePlay(G, cMovieStop); if(SettingGet(G, cSetting_sculpting)) SettingSet(G, cSetting_sculpting, 0); if(SettingGetGlobal_b(G, cSetting_rock)) SettingSetGlobal_b(G, cSetting_rock, false); ExecutiveDrawNow(G); OrthoDirty(G); PLog(G, "cmd.mstop()", cPLog_pym); break; case 3: if(!MoviePlaying(G)) { if(mod & cOrthoCTRL) { PLog(G, "cmd.rewind()", cPLog_pym); PLog(G, "cmd.mplay()", cPLog_pym); SceneSetFrame(G, 4, 0); MoviePlay(G, cMoviePlay); } else { PLog(G, "cmd.mplay()", cPLog_pym); MoviePlay(G, cMoviePlay); } } else { MoviePlay(G, cMovieStop); ExecutiveDrawNow(G); OrthoDirty(G); PLog(G, "cmd.mstop()", cPLog_pym); } break; case 4: SceneSetFrame(G, 5, 1); PLog(G, "cmd.forward()", cPLog_pym); break; case 5: if(mod & cOrthoCTRL) { SceneSetFrame(G, 3, 0); PLog(G, "cmd.middle()", cPLog_pym); } else { SceneSetFrame(G, 6, 0); PLog(G, "cmd.ending()", cPLog_pym); } break; case 6: if(SettingGetGlobal_b(G, cSetting_seq_view)) { SettingSetGlobal_b(G, cSetting_seq_view, 0); SeqChanged(G); PLog(G, "cmd.set('seq_view',0)", cPLog_pym); } else { SettingSetGlobal_b(G, cSetting_seq_view, 1); SeqChanged(G); PLog(G, "cmd.set('seq_view',1)", cPLog_pym); } OrthoDirty(G); break; case 7: SettingSetGlobal_b(G, cSetting_rock, !SettingGetGlobal_b(G, cSetting_rock)); if(SettingGetGlobal_b(G, cSetting_rock)) { SceneRestartSweepTimer(G); PLog(G, "cmd.rock(1)", cPLog_pym); } else PLog(G, "cmd.rock(0)", cPLog_pym); SceneRestartFrameTimer(G); OrthoDirty(G); break; case 8: PLog(G, "cmd.fullscreen()", cPLog_pym); ExecutiveFullScreen(G, -1); break; } OrthoDirty(G); OrthoUngrab(G); I->LastClickTime = UtilGetSeconds(G); I->DragFlag = false; I->Active = -1; I->Pressed = -1; } return (1); }
static void RepLabelRender(RepLabel * I, RenderInfo * info) { CRay *ray = info->ray; Picking **pick = info->pick; PyMOLGlobals *G = I->R.G; float *v = I->V; int c = I->N; int *l = I->L; int font_id = SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting, cSetting_label_font_id); float font_size = SettingGet_f(G, I->R.cs->Setting, I->R.obj->Setting, cSetting_label_size); if(ray) { if(c) { char *st; TextSetOutlineColor(G, I->OutlineColor); while(c--) { if(*l) { st = OVLexicon_FetchCString(G->Lexicon, *l); TextSetPosNColor(G, v + 3, v); TextRenderRay(G, ray, font_id, st, font_size, v + 6); } v += 9; l++; } } } else if(G->HaveGUI && G->ValidContext) { if(pick) { Pickable *p = I->R.P; int i; if (I->shaderCGO){ CGORenderGLPicking(I->shaderCGO, pick, &I->R.context, I->R.cs->Setting, I->R.obj->Setting); return; } SceneSetupGLPicking(G); if(c) { char *st; int float_text = SettingGetGlobal_i(G, cSetting_float_labels); if(float_text) glDisable(GL_DEPTH_TEST); i = (*pick)->src.index; while(c--) { if(*l) { int first_pass = (!(*pick)[0].src.bond); i++; TextSetPosNColor(G, v + 3, v); TextSetPickColor(G, first_pass, i); if(first_pass) { VLACheck((*pick), Picking, i); p++; (*pick)[i].src = *p; /* copy object and atom info */ (*pick)[i].context = I->R.context; } st = OVLexicon_FetchCString(G->Lexicon, *l); TextRenderOpenGL(G, info, font_id, st, font_size, v + 6, SHADERCGO); } l++; v += 9; } if(float_text) glEnable(GL_DEPTH_TEST); (*pick)[0].src.index = i; /* pass the count */ } } else { if(c) { char *st; int float_text = SettingGetGlobal_i(G, cSetting_float_labels); short use_shader; Pickable *p = I->R.P; use_shader = SettingGetGlobal_b(G, cSetting_use_shaders); if(float_text) glDisable(GL_DEPTH_TEST); if (use_shader){ if (!I->shaderCGO){ I->shaderCGO = CGONew(G); if (use_shader){ I->shaderCGO->use_shader = true; I->shaderCGO->enable_shaders = true; } } else { CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R); if(float_text) glEnable(GL_DEPTH_TEST); return; } } else if (I->shaderCGO) { CGOFree(I->shaderCGO); I->shaderCGO = NULL; } TextSetOutlineColor(G, I->OutlineColor); while(c--) { if(*l) { p++; if (I->shaderCGO) CGOPickColor(I->shaderCGO, p->index, p->bond); TextSetPosNColor(G, v + 3, v); st = OVLexicon_FetchCString(G->Lexicon, *l); TextRenderOpenGL(G, info, font_id, st, font_size, v + 6, SHADERCGO); } l++; v += 9; } if (I->shaderCGO){ CGO *convertcgo; CGOStop(I->shaderCGO); convertcgo = CGOOptimizeLabels(I->shaderCGO, 0); CGOFree(I->shaderCGO); I->shaderCGO = convertcgo; convertcgo = NULL; if (I->shaderCGO){ I->shaderCGO->use_shader = true; I->shaderCGO->enable_shaders = true; CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R); } } if(float_text) glEnable(GL_DEPTH_TEST); } } } }