1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
/*
A* -------------------------------------------------------------------
B* This file contains source code for the PyMOL computer program
C* Copyright (c) Schrodinger, LLC.
D* -------------------------------------------------------------------
E* It is unlawful to modify or remove this copyright notice.
F* -------------------------------------------------------------------
G* Please see the accompanying LICENSE file for further information.
H* -------------------------------------------------------------------
I* Additional authors of this source file include:
-*
-*
-*
Z* -------------------------------------------------------------------
*/
#include"os_python.h"
#include"os_predef.h"
#include"os_gl.h"
#include"Block.h"
#include"main.h"
#include"CGO.h"
void BlockGetSize(Block * I, int *width, int *height)
{
*width = I->rect.right - I->rect.left;
*height = I->rect.top - I->rect.bottom;
}
/*========================================================================*/
void BlockInit(PyMOLGlobals * G, Block * I)
{
I->G = G;
I->BackColor[0] = 0.2F;
I->BackColor[1] = 0.2F;
I->BackColor[2] = 0.2F;
I->TextColor[0] = 1.0F;
I->TextColor[1] = 1.0F;
I->TextColor[2] = 1.0F;
}
/*========================================================================*/
void BlockFill(Block * I ORTHOCGOARG)
{
PyMOLGlobals *G = I->G;
if(G->HaveGUI && G->ValidContext) {
if (orthoCGO){
CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
CGOVertex(orthoCGO, I->rect.right, I->rect.top, 0.f);
CGOVertex(orthoCGO, I->rect.right, I->rect.bottom, 0.f);
CGOVertex(orthoCGO, I->rect.left, I->rect.top, 0.f);
CGOVertex(orthoCGO, I->rect.left, I->rect.bottom, 0.f);
CGOEnd(orthoCGO);
} else {
glBegin(GL_POLYGON);
glVertex2i(I->rect.right, I->rect.top);
glVertex2i(I->rect.right, I->rect.bottom);
glVertex2i(I->rect.left, I->rect.bottom);
glVertex2i(I->rect.left, I->rect.top);
glEnd();
}
}
}
/*========================================================================*/
void BlockDrawLeftEdge(Block * I ORTHOCGOARG)
{
PyMOLGlobals *G = I->G;
if(G->HaveGUI && G->ValidContext) {
if (orthoCGO){
CGOColor(orthoCGO, .3f, .3f, .3f);
CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
CGOVertex(orthoCGO, I->rect.left, I->rect.bottom, 0.f);
CGOVertex(orthoCGO, I->rect.left + 1.f, I->rect.bottom, 0.f);
CGOVertex(orthoCGO, I->rect.left, I->rect.top, 0.f);
CGOVertex(orthoCGO, I->rect.left + 1.f, I->rect.top, 0.f);
CGOEnd(orthoCGO);
} else {
if(G->HaveGUI && G->ValidContext) {
glColor3f(0.3, 0.3, 0.3);
glBegin(GL_LINES);
glVertex2i(I->rect.left, I->rect.bottom);
glVertex2i(I->rect.left, I->rect.top);
glEnd();
}
}
}
}
/*========================================================================*/
void BlockDrawTopEdge(Block * I)
{
#ifndef PURE_OPENGL_ES_2
PyMOLGlobals *G = I->G;
if(G->HaveGUI && G->ValidContext) {
glColor3f(0.3, 0.3, 0.3);
glBegin(GL_LINES);
glVertex2i(I->rect.right, I->rect.top);
glVertex2i(I->rect.left, I->rect.top);
glEnd();
}
#endif
}
/*========================================================================*/
void BlockSetMargin(Block * block, int t, int l, int b, int r)
{
block->margin.top = t;
block->margin.left = l;
block->margin.bottom = b;
block->margin.right = r;
}
/*========================================================================*/
void BlockReshape(Block * I, int width, int height)
{
I->rect.top = (height - I->margin.top);
I->rect.left = I->margin.left;
I->rect.bottom = I->margin.bottom;
I->rect.right = (width - I->margin.right);
}
/*========================================================================*/
void BlockTranslate(Block * I, int dx, int dy)
{
I->rect.top += dy;
I->rect.left += dx;
I->rect.bottom += dy;
I->rect.right += dx;
}
/*========================================================================*/
void BlockRecursiveDraw(Block * block ORTHOCGOARG)
{
if(block) {
if(block->next)
BlockRecursiveDraw(block->next ORTHOCGOARGVAR);
if(block->active) {
if(block->fDraw)
block->fDraw(block ORTHOCGOARGVAR);
if(block->inside)
BlockRecursiveDraw(block->inside ORTHOCGOARGVAR);
}
}
}
/*========================================================================*/
short BlockRecursiveFastDraw(Block * block ORTHOCGOARG)
{
short ret = false;
if(block) {
if(block->next)
ret |= BlockRecursiveFastDraw(block->next ORTHOCGOARGVAR);
if(block->active) {
if(block->fFastDraw)
ret |= block->fFastDraw(block ORTHOCGOARGVAR);
if(block->inside)
ret |= BlockRecursiveFastDraw(block->inside ORTHOCGOARGVAR);
}
}
return ret;
}
/*========================================================================*/
Block *BlockRecursiveFind(Block * block, int x, int y)
{
Block *check;
if(block) {
if(!block->active)
block = BlockRecursiveFind(block->next, x, y);
else if(!((block->rect.top >= y) &&
(block->rect.bottom <= y) &&
(block->rect.left <= x) && (block->rect.right >= x)))
block = BlockRecursiveFind(block->next, x, y);
else if(block->inside)
if((check = BlockRecursiveFind(block->inside, x, y)))
block = check;
}
return (block);
}
int BlockRectXYInside(BlockRect *rect, int x, int y)
{
return ((y <= rect->top) && (y >= rect->bottom) &&
(x <= rect->right) && (x >= rect->left));
}
|