"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "layer1/Seq.cpp" between
pymol-open-source-2.2.0.tar.gz and pymol-open-source-2.3.0.tar.gz

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

Seq.cpp  (pymol-open-source-2.2.0):Seq.cpp  (pymol-open-source-2.3.0)
skipping to change at line 37 skipping to change at line 37
#include "Scene.h" #include "Scene.h"
#include "Text.h" #include "Text.h"
#include "Seeker.h" #include "Seeker.h"
#include "Menu.h" #include "Menu.h"
#include "Executive.h" #include "Executive.h"
#include "Ortho.h" #include "Ortho.h"
#include "CGO.h" #include "CGO.h"
struct _CSeq { struct CSeq : public Block {
::Block *Block; bool DragFlag { false };
int DragFlag; bool ScrollBarActive { true };
int ScrollBarActive; int NSkip {};
int NSkip; ScrollBar m_ScrollBar;
struct CScrollBar *ScrollBar; CSeqRow *Row { nullptr };
CSeqRow *Row; int NRow { 0 };
int NRow; int Size {};
int Size; int VisSize {};
int VisSize; int Changed {};
int Changed; bool Dirty { true };
int Dirty; int LineHeight { 13 };
int LineHeight; int CharWidth { 8 };
int CharWidth; int ScrollBarWidth { 16 };
int ScrollBarWidth; int ScrollBarMargin { 2 };
int ScrollBarMargin; int CharMargin { 2 };
int CharMargin; int LastRow { -1 };
int LastRow; CSeqHandler *Handler {}; /* borrowed pointer */
CSeqHandler *Handler; /* borrowed pointer */
CSeq(PyMOLGlobals * G) : Block(G), m_ScrollBar(G, true) {}
int click(int button, int x, int y, int mod) override;
void draw(CGO* orthoCGO) override;
int drag(int x, int y, int mod) override;
int release(int button, int x, int y, int mod) override;
void reshape(int width, int height) override;
}; };
static int SeqFindRowCol(PyMOLGlobals * G, int x, int y, int *row_num_ptr, static int SeqFindRowCol(PyMOLGlobals * G, int x, int y, int *row_num_ptr,
int *col_num_ptr, int fixed_row) int *col_num_ptr, int fixed_row)
{ {
CSeq *I = G->Seq; CSeq *I = G->Seq;
int result = 0; int result = 0;
int row_num = 0; int row_num = 0;
int col_num = 0; int col_num = 0;
if(I->ScrollBarActive) { if(I->ScrollBarActive) {
y -= DIP2PIXEL(I->ScrollBarWidth); y -= DIP2PIXEL(I->ScrollBarWidth);
} }
if(fixed_row >= 0) { if(fixed_row >= 0) {
row_num = fixed_row; row_num = fixed_row;
} else { } else {
row_num = (y - I->Block->rect.bottom) / DIP2PIXEL(I->LineHeight); row_num = (y - I->rect.bottom) / DIP2PIXEL(I->LineHeight);
row_num = (I->NRow - 1) - row_num; row_num = (I->NRow - 1) - row_num;
} }
if((row_num >= 0) && (row_num < I->NRow)) { if((row_num >= 0) && (row_num < I->NRow)) {
int char_num; int char_num;
CSeqRow *row; CSeqRow *row;
row = I->Row + row_num; row = I->Row + row_num;
char_num = (x - I->Block->rect.left - DIP2PIXEL(I->CharMargin)) / DIP2PIXEL( I->CharWidth); char_num = (x - I->rect.left - DIP2PIXEL(I->CharMargin)) / DIP2PIXEL(I->Char Width);
if(row->nCol && !row->label_flag) if(row->nCol && !row->label_flag)
if(char_num < I->VisSize) { if(char_num < I->VisSize) {
char_num += I->NSkip; char_num += I->NSkip;
if((char_num >= 0) && (char_num < row->ext_len) && (row->char2col)) { if((char_num >= 0) && (char_num < row->ext_len) && (row->char2col)) {
col_num = row->char2col[char_num]; col_num = row->char2col[char_num];
if(col_num) { if(col_num) {
col_num--; col_num--;
if(col_num < row->nCol) { if(col_num < row->nCol) {
result = true; result = true;
} else if(fixed_row >= 0) { } else if(fixed_row >= 0) {
skipping to change at line 127 skipping to change at line 134
I->Dirty = true; I->Dirty = true;
OrthoReshape(G, -1, -1, false); /* careful, this is recursive... */ OrthoReshape(G, -1, -1, false); /* careful, this is recursive... */
} }
if(I->Dirty) { if(I->Dirty) {
if(I->Handler->fRefresh) if(I->Handler->fRefresh)
I->Handler->fRefresh(G, I->Row); I->Handler->fRefresh(G, I->Row);
I->Dirty = false; I->Dirty = false;
} }
} }
static void SeqReshape(Block * block, int width, int height) void CSeq::reshape(int width, int height)
{ {
PyMOLGlobals *G = block->G; PyMOLGlobals *G = m_G;
CSeq *I = G->Seq; CSeq *I = G->Seq;
BlockReshape(block, width, height); Block::reshape(width, height);
{ /* get current sequence sizes */ { /* get current sequence sizes */
int a; int a;
I->Size = 0; I->Size = 0;
for(a = 0; a < I->NRow; a++) { for(a = 0; a < I->NRow; a++) {
if(I->Row[a].ext_len > I->Size) if(I->Row[a].ext_len > I->Size)
I->Size = I->Row[a].ext_len; I->Size = I->Row[a].ext_len;
} }
} }
{ {
int extra; int extra;
I->VisSize = (I->Block->rect.right - I->Block->rect.left - 1) / DIP2PIXEL(I- I->VisSize = (I->rect.right - I->rect.left - 1) / DIP2PIXEL(I->CharWidth);
>CharWidth); /* printf("%d %d %d %d %d\n",cw,I->rect.right,I->rect.left,I->VisSize,I->
/* printf("%d %d %d %d %d\n",cw,I->Block->rect.right,I->Block->rect.left, Size); */
I->VisSize,I->Size); */
if(I->VisSize < 1) if(I->VisSize < 1)
I->VisSize = 1; I->VisSize = 1;
extra = I->Size - I->VisSize; extra = I->Size - I->VisSize;
if(extra <= 0) { if(extra <= 0) {
I->ScrollBarActive = false; I->ScrollBarActive = false;
} else { } else {
I->ScrollBarActive = true; I->ScrollBarActive = true;
ScrollBarSetLimits(I->ScrollBar, I->Size, I->VisSize); m_ScrollBar.setLimits(I->Size, I->VisSize);
} }
} }
} }
void SeqDirty(PyMOLGlobals * G) void SeqDirty(PyMOLGlobals * G)
{ {
CSeq *I = G->Seq; CSeq *I = G->Seq;
I->Dirty = true; I->Dirty = true;
SceneInvalidate(G); SceneInvalidate(G);
} }
void SeqChanged(PyMOLGlobals * G) void SeqChanged(PyMOLGlobals * G)
{ {
CSeq *I = G->Seq; CSeq *I = G->Seq;
I->Changed = true; I->Changed = true;
SceneInvalidate(G); SceneInvalidate(G);
} }
static int SeqDrag(Block * block, int x, int y, int mod) int CSeq::drag(int x, int y, int mod)
{ {
PyMOLGlobals *G = block->G; PyMOLGlobals *G = m_G;
CSeq *I = G->Seq; CSeq *I = G->Seq;
int pass = 0; int pass = 0;
int row_num; int row_num;
int col_num; int col_num;
if(!pass) { if(!pass) {
if(SeqFindRowCol(G, x, y, &row_num, &col_num, I->LastRow)) { if(SeqFindRowCol(G, x, y, &row_num, &col_num, I->LastRow)) {
if(I->Handler) if(I->Handler)
if(I->Handler->fDrag) if(I->Handler->fDrag)
I->Handler->fDrag(G, I->Row, row_num, col_num, mod); I->Handler->fDrag(G, I->Row, row_num, col_num, mod);
OrthoDirty(G); OrthoDirty(G);
} }
} }
return (1); return (1);
} }
static int SeqRelease(Block * block, int button, int x, int y, int mod) int CSeq::release(int button, int x, int y, int mod)
{ {
PyMOLGlobals *G = block->G; PyMOLGlobals *G = m_G;
CSeq *I = G->Seq; CSeq *I = G->Seq;
int pass = 0; int pass = 0;
/*
if(I->ScrollBarActive) {
if((y-I->Block->rect.bottom)<I->ScrollBarWidth) {
pass = 1;
ScrollBarDoRelease(I->ScrollBar,button,x,y,mod);
OrthoUngrab(G);
}
}
*/
if(!pass) { if(!pass) {
int row_num; int row_num;
int col_num; int col_num;
if(SeqFindRowCol(G, x, y, &row_num, &col_num, I->LastRow)) { if(SeqFindRowCol(G, x, y, &row_num, &col_num, I->LastRow)) {
if(I->Handler) if(I->Handler)
if(I->Handler->fRelease) if(I->Handler->fRelease)
I->Handler->fRelease(G, I->Row, button, row_num, col_num, mod); I->Handler->fRelease(G, I->Row, button, row_num, col_num, mod);
OrthoDirty(G); OrthoDirty(G);
} else { } else {
if(I->Handler) if(I->Handler)
skipping to change at line 244 skipping to change at line 242
} }
return (height); return (height);
} }
void SeqSetHandler(PyMOLGlobals * G, CSeqHandler * handler) void SeqSetHandler(PyMOLGlobals * G, CSeqHandler * handler)
{ {
CSeq *I = G->Seq; CSeq *I = G->Seq;
I->Handler = handler; I->Handler = handler;
} }
static int SeqClick(Block * block, int button, int x, int y, int mod) int CSeq::click(int button, int x, int y, int mod)
{ {
PyMOLGlobals *G = block->G; PyMOLGlobals *G = m_G;
CSeq *I = G->Seq; CSeq *I = G->Seq;
int pass = 0; int pass = 0;
int row_num; int row_num;
int col_num; int col_num;
switch(button) {
case P_GLUT_BUTTON_SCROLL_FORWARD:
I->m_ScrollBar.moveBy(-1);
return 1;
case P_GLUT_BUTTON_SCROLL_BACKWARD:
I->m_ScrollBar.moveBy(1);
return 1;
}
if(I->ScrollBarActive) { if(I->ScrollBarActive) {
if((y - I->Block->rect.bottom) < DIP2PIXEL(I->ScrollBarWidth)) { if((y - rect.bottom) < DIP2PIXEL(I->ScrollBarWidth)) {
pass = 1; pass = 1;
ScrollBarDoClick(I->ScrollBar, button, x, y, mod); I->m_ScrollBar.click(button, x, y, mod);
} }
} }
if(!pass) { if(!pass) {
if(SeqFindRowCol(G, x, y, &row_num, &col_num, -1)) { if(SeqFindRowCol(G, x, y, &row_num, &col_num, -1)) {
if(I->Handler) if(I->Handler)
if(I->Handler->fClick) if(I->Handler->fClick)
I->Handler->fClick(G, I->Row, button, row_num, col_num, mod, x, y); I->Handler->fClick(G, I->Row, button, row_num, col_num, mod, x, y);
I->DragFlag = true; I->DragFlag = true;
I->LastRow = row_num; I->LastRow = row_num;
OrthoDirty(G); OrthoDirty(G);
skipping to change at line 286 skipping to change at line 294
if(I->Handler) if(I->Handler)
if(I->Handler->fClick) if(I->Handler->fClick)
I->Handler->fClick(G, I->Row, button, -1, -1, mod, x, y); I->Handler->fClick(G, I->Row, button, -1, -1, mod, x, y);
break; break;
} }
} }
} }
return (1); return (1);
} }
static void SeqDraw(Block * block ORTHOCGOARG) void CSeq::draw(CGO* orthoCGO)
{ {
PyMOLGlobals *G = block->G; PyMOLGlobals *G = m_G;
CSeq *I = G->Seq; CSeq *I = G->Seq;
if(G->HaveGUI && G->ValidContext) { if(G->HaveGUI && G->ValidContext) {
int x = I->Block->rect.left; int x = rect.left;
int y = I->Block->rect.bottom + DIP2PIXEL(I->ScrollBarMargin) + 1; int y = rect.bottom + DIP2PIXEL(I->ScrollBarMargin) + 1;
float bg_color[3] = { 0.f, 0.f, 0.f }, overlay_color[3] = { 1.0F, 1.0F, 1.0F }; float bg_color[3] = { 0.f, 0.f, 0.f }, overlay_color[3] = { 1.0F, 1.0F, 1.0F };
int label_color_index = SettingGetGlobal_color(G, cSetting_seq_view_label_co lor); int label_color_index = SettingGetGlobal_color(G, cSetting_seq_view_label_co lor);
const float *label_color = ColorGet(G, label_color_index); const float *label_color = ColorGet(G, label_color_index);
copy3f(label_color, overlay_color); copy3f(label_color, overlay_color);
if (SettingGetGlobal_b(G, cSetting_bg_gradient)){ if (SettingGetGlobal_b(G, cSetting_bg_gradient)){
if(SettingGetGlobal_b(G, cSetting_seq_view_location)) { if(SettingGetGlobal_b(G, cSetting_seq_view_location)) {
copy3f(ColorGet(G, SettingGetGlobal_color(G, cSetting_bg_rgb_bottom)), bg _color); copy3f(ColorGet(G, SettingGetGlobal_color(G, cSetting_bg_rgb_bottom)), bg _color);
} else { } else {
copy3f(ColorGet(G, SettingGetGlobal_color(G, cSetting_bg_rgb_top)), bg_co lor); copy3f(ColorGet(G, SettingGetGlobal_color(G, cSetting_bg_rgb_top)), bg_co lor);
} }
} else { } else {
copy3f(ColorGet(G, SettingGetGlobal_color(G, cSetting_bg_rgb)), bg_color); copy3f(ColorGet(G, SettingGetGlobal_color(G, cSetting_bg_rgb)), bg_color);
} }
if(!SettingGetGlobal_b(G, cSetting_seq_view_overlay)) { if(!SettingGetGlobal_b(G, cSetting_seq_view_overlay)) {
if (orthoCGO){ if (orthoCGO){
CGOColorv(orthoCGO, bg_color); CGOColorv(orthoCGO, bg_color);
} else { } else {
glColor3fv(bg_color); glColor3fv(bg_color);
} }
BlockFill(I->Block ORTHOCGOARGVAR); fill(orthoCGO);
} }
if(I->ScrollBarActive) { if(I->ScrollBarActive) {
ScrollBarSetBox(I->ScrollBar, I->Block->rect.bottom + DIP2PIXEL(I->ScrollB I->m_ScrollBar.setBox(rect.bottom + DIP2PIXEL(I->ScrollBarWidth),
arWidth), rect.left + DIP2PIXEL(I->ScrollBarMargin),
I->Block->rect.left + DIP2PIXEL(I->ScrollBarMargin), rect.bottom + DIP2PIXEL(2),
I->Block->rect.bottom + DIP2PIXEL(2), rect.right - DIP2PIXEL(I->ScrollBarMargin));
I->Block->rect.right - DIP2PIXEL(I->ScrollBarMargin)); I->m_ScrollBar.draw(orthoCGO);
ScrollBarDoDraw(I->ScrollBar ORTHOCGOARGVAR);
y += DIP2PIXEL(I->ScrollBarWidth); y += DIP2PIXEL(I->ScrollBarWidth);
I->NSkip = (int) ScrollBarGetValue(I->ScrollBar); I->NSkip = static_cast<int>(I->m_ScrollBar.getValue());
} else { } else {
I->NSkip = 0; I->NSkip = 0;
} }
if(I->NRow) { /* get current sequence sizes */ if(I->NRow) { /* get current sequence sizes */
int a, b; int a, b;
float black[3] = { 0, 0, 0 }; float black[3] = { 0, 0, 0 };
float blue[3] = { 0.5, 0.5, 1.0 }; float blue[3] = { 0.5, 0.5, 1.0 };
const float *cur_color; const float *cur_color;
CSeqRow *row; CSeqRow *row;
CSeqCol *col; CSeqCol *col;
skipping to change at line 594 skipping to change at line 602
glVertex2i(xx2, yy + DIP2PIXEL(I->LineHeight) - 2); glVertex2i(xx2, yy + DIP2PIXEL(I->LineHeight) - 2);
glVertex2i(xx2, yy); glVertex2i(xx2, yy);
glEnd(); glEnd();
} }
} }
} }
} }
if(I->ScrollBarActive) { if(I->ScrollBarActive) {
int real_count = n_real; int real_count = n_real;
int mode = 0; int mode = 0;
float width = (float) (I->Block->rect.right - I->Block->rect.left); float width = (float) (rect.right - rect.left);
float start = 0, stop; float start = 0, stop;
int right = 0; int right = 0;
float bot, top, cent; float bot, top, cent;
float height = (float) DIP2PIXEL(I->ScrollBarWidth - I->ScrollBarMargin) ; float height = (float) DIP2PIXEL(I->ScrollBarWidth - I->ScrollBarMargin) ;
int last_color = -1; int last_color = -1;
cur_color = blue; cur_color = blue;
for(a = 0; a < I->NRow; a++) { for(a = 0; a < I->NRow; a++) {
row = I->Row + a; row = I->Row + a;
if(!row->label_flag) { if(!row->label_flag) {
top = top =
I->Block->rect.bottom + DIP2PIXEL(I->ScrollBarMargin) + (height * real_count) / n_real; rect.bottom + DIP2PIXEL(I->ScrollBarMargin) + (height * real_count ) / n_real;
real_count--; real_count--;
bot = bot =
I->Block->rect.bottom + DIP2PIXEL(I->ScrollBarMargin) + (height * real_count) / n_real; rect.bottom + DIP2PIXEL(I->ScrollBarMargin) + (height * real_count ) / n_real;
mode = 0; mode = 0;
for(b = 0; b < row->nCol; b++) { for(b = 0; b < row->nCol; b++) {
col = row->col + b; col = row->col + b;
if(col->inverse && (!mode)) { if(col->inverse && (!mode)) {
start = (width * col->offset) / max_len; start = (width * col->offset) / max_len;
right = col->offset + (col->stop - col->start); right = col->offset + (col->stop - col->start);
mode = 1; mode = 1;
last_color = col->color; last_color = col->color;
if(row->label_flag) if(row->label_flag)
cur_color = overlay_color; cur_color = overlay_color;
skipping to change at line 722 skipping to change at line 730
glVertex2f(start, bot); glVertex2f(start, bot);
glVertex2f(start, top); glVertex2f(start, top);
glVertex2f(stop, top); glVertex2f(stop, top);
glVertex2f(stop, bot); glVertex2f(stop, bot);
glEnd(); glEnd();
} }
} }
} }
} }
ScrollBarDrawHandle(I->ScrollBar, 0.35F ORTHOCGOARGVAR); I->m_ScrollBar.drawHandle(0.35F, orthoCGO);
} }
} }
} }
} }
int SeqInit(PyMOLGlobals * G) int SeqInit(PyMOLGlobals * G)
{ {
CSeq *I = NULL; CSeq *I = NULL;
if((I = (G->Seq = Calloc(CSeq, 1)))) { if((I = (G->Seq = new CSeq(G)))) {
I->Block = OrthoNewBlock(G, NULL); I->active = true;
I->Block->fClick = SeqClick; I->TextColor[0] = 1.0;
I->Block->fDraw = SeqDraw; I->TextColor[1] = 0.75;
I->Block->fDrag = SeqDrag; I->TextColor[2] = 0.75;
I->Block->fRelease = SeqRelease; OrthoAttach(G, I, cOrthoTool);
I->Block->fReshape = SeqReshape; I->m_ScrollBar.setValue(0);
I->Block->active = true;
I->Block->TextColor[0] = 1.0;
I->Block->TextColor[1] = 0.75;
I->Block->TextColor[2] = 0.75;
OrthoAttach(G, I->Block, cOrthoTool);
I->DragFlag = false;
I->ScrollBarActive = true;
I->ScrollBar = ScrollBarNew(G, true);
ScrollBarSetValue(I->ScrollBar, 0);
I->Row = NULL;
I->NRow = 0;
I->Dirty = true;
I->ScrollBarWidth = 16;
I->ScrollBarMargin = 2;
I->LineHeight = 13;
I->CharMargin = 2;
I->LastRow = -1;
I->CharWidth = 8;
return 1; return 1;
} else } else
return 0; return 0;
} }
static void SeqPurgeRowVLA(PyMOLGlobals * G) static void SeqPurgeRowVLA(PyMOLGlobals * G)
{ {
CSeq *I = G->Seq; CSeq *I = G->Seq;
if(I->Row) { if(I->Row) {
int a; int a;
skipping to change at line 793 skipping to change at line 783
SeqPurgeRowVLA(G); SeqPurgeRowVLA(G);
I->Row = row; I->Row = row;
I->NRow = nRow; I->NRow = nRow;
} }
void SeqFree(PyMOLGlobals * G) void SeqFree(PyMOLGlobals * G)
{ {
CSeq *I = G->Seq; CSeq *I = G->Seq;
SeqPurgeRowVLA(G); SeqPurgeRowVLA(G);
if(I->ScrollBar) DeleteP(G->Seq);
ScrollBarFree(I->ScrollBar);
OrthoFreeBlock(G, I->Block);
FreeP(G->Seq);
} }
Block *SeqGetBlock(PyMOLGlobals * G) Block *SeqGetBlock(PyMOLGlobals * G)
{ {
CSeq *I = G->Seq; CSeq *I = G->Seq;
{ {
return (I->Block); return (I);
} }
} }
 End of changes. 32 change blocks. 
92 lines changed or deleted 77 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)