"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "layer1/Ortho.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.

Ortho.cpp  (pymol-open-source-2.2.0):Ortho.cpp  (pymol-open-source-2.3.0)
skipping to change at line 18 skipping to change at line 18
F* ------------------------------------------------------------------- F* -------------------------------------------------------------------
G* Please see the accompanying LICENSE file for further information. G* Please see the accompanying LICENSE file for further information.
H* ------------------------------------------------------------------- H* -------------------------------------------------------------------
I* Additional authors of this source file include: I* Additional authors of this source file include:
-* -*
-* -*
-* -*
Z* ------------------------------------------------------------------- Z* -------------------------------------------------------------------
*/ */
#include <queue>
#include <string>
#include <array>
#include"os_python.h" #include"os_python.h"
#include"os_predef.h" #include"os_predef.h"
#include"os_std.h" #include"os_std.h"
#include"os_gl.h" #include"os_gl.h"
#include"main.h" #include"main.h"
#include"Version.h" #include"Version.h"
#include"MemoryDebug.h" #include"MemoryDebug.h"
#include"Err.h" #include"Err.h"
skipping to change at line 39 skipping to change at line 43
#include"ListMacros.h" #include"ListMacros.h"
#include"Ortho.h" #include"Ortho.h"
#include"P.h" #include"P.h"
#include"Scene.h" #include"Scene.h"
#include"Executive.h" #include"Executive.h"
#include"ButMode.h" #include"ButMode.h"
#include "Seq.h" #include "Seq.h"
#include"Control.h" #include"Control.h"
#include"Setting.h" #include"Setting.h"
#include"Wizard.h" #include"Wizard.h"
#include"Queue.h"
#include"Pop.h" #include"Pop.h"
#include"Seq.h" #include"Seq.h"
#include"Text.h" #include"Text.h"
#include"PyMOLOptions.h" #include"PyMOLOptions.h"
#include"PyMOL.h" #include"PyMOL.h"
#include"Movie.h" #include"Movie.h"
#include "ShaderMgr.h" #include "ShaderMgr.h"
#include "Vector.h" #include "Vector.h"
#include "CGO.h" #include "CGO.h"
#include "MyPNG.h" #include "MyPNG.h"
#include "MacPyMOL.h" #include "MacPyMOL.h"
#include "File.h" #include "File.h"
#include "LangUtil.h"
#ifndef true
#define true 1
#endif
#ifndef false
#define false 0
#endif
#define OrthoSaveLines 0xFF #define OrthoSaveLines 0xFF
#define OrthoHistoryLines 0xFF #define OrthoHistoryLines 0xFF
#define cOrthoCharWidth DIP2PIXEL(8) #define cOrthoCharWidth DIP2PIXEL(8)
#define cOrthoLeftMargin DIP2PIXEL(3) #define cOrthoLeftMargin DIP2PIXEL(3)
#define cOrthoBottomMargin DIP2PIXEL(5) #define cOrthoBottomMargin DIP2PIXEL(5)
#define CMD_QUEUE_MASK 0x3 #define CMD_QUEUE_MASK 0x3
skipping to change at line 100 skipping to change at line 96
int DirtyFlag; int DirtyFlag;
double BusyLast, BusyLastUpdate; double BusyLast, BusyLastUpdate;
int BusyStatus[4]; int BusyStatus[4];
char BusyMessage[255]; char BusyMessage[255];
char *WizardPromptVLA; char *WizardPromptVLA;
int SplashFlag; int SplashFlag;
int HaveSeqViewer; int HaveSeqViewer;
BlockRect LoopRect; BlockRect LoopRect;
int LoopFlag; int LoopFlag;
int cmdNestLevel; int cmdNestLevel;
CQueue *cmdQueue[CMD_QUEUE_MASK + 1], *cmdActiveQueue; std::array<std::queue<std::string>, CMD_QUEUE_MASK + 1> cmdQueue;
std::queue<std::string> *cmdActiveQueue;
int cmdActiveBusy; int cmdActiveBusy;
CQueue *feedback; std::queue<std::string> feedback;
int Pushed; int Pushed;
CDeferred *deferred; std::vector<std::unique_ptr<CDeferred>> deferred; //Ortho manages DeferredObjs
int RenderMode; int RenderMode;
GLint ViewPort[4]; GLint ViewPort[4];
int WrapXFlag; int WrapXFlag;
GLenum ActiveGLBuffer; GLenum ActiveGLBuffer;
double DrawTime, LastDraw; double DrawTime, LastDraw;
int WrapClickSide; /* ugly kludge for finding click side in geowall stereo mode */ int WrapClickSide; /* ugly kludge for finding click side in geowall stereo mode */
/* packing information */ /* packing information */
int WizardHeight; int WizardHeight;
int TextBottom; int TextBottom;
int IssueViewportWhenReleased; int IssueViewportWhenReleased;
GLuint bg_texture_id; GLuint bg_texture_id;
short bg_texture_needs_update; short bg_texture_needs_update;
CGO *bgCGO; CGO *bgCGO;
int bgWidth, bgHeight; //void *bgData; // this is the image data set from CMol, takes precedence of
void *bgData; // this is the image data set from CMol, takes precedence of bg bg_gradient or bg_image_filename
_gradient or bg_image_filename std::shared_ptr<pymol::Image> bgData;
CGO *orthoCGO, *orthoFastCGO; CGO *orthoCGO, *orthoFastCGO;
}; };
int OrthoBackgroundDataIsSet(PyMOLGlobals *G){ bool OrthoBackgroundDataIsSet(const COrtho& ortho)
COrtho *I = G->Ortho; {
return (I->bgData && (I->bgWidth > 0 && I->bgHeight > 0)); return (ortho.bgData && (!ortho.bgData->empty()));
// return (I->bgCGO != NULL && (I->bgWidth > 0 && I->bgHeight > 0));
} }
void *OrthoBackgroundDataGet(PyMOLGlobals *G, int *width, int *height){
COrtho *I = G->Ortho; std::shared_ptr<pymol::Image> OrthoBackgroundDataGet(const COrtho& ortho)
*width = I->bgWidth; {
*height = I->bgHeight; return ortho.bgData;
return (I->bgData);
} }
void OrthoGetSize(PyMOLGlobals *G, int *width, int *height){ std::pair<int, int> OrthoGetSize(const COrtho& ortho){
COrtho *I = G->Ortho; return std::make_pair(ortho.Width, ortho.Height);
*width = I->Width;
*height = I->Height;
} }
void OrthoGetBackgroundSize(PyMOLGlobals * G, int *width, int *height){ std::pair<int, int> OrthoGetBackgroundSize(const COrtho& ortho){
COrtho *I = G->Ortho; if(ortho.bgData){
*width = I->bgWidth; return ortho.bgData->getSize();
*height = I->bgHeight; } else{
return std::make_pair(0, 0);
}
} }
static
void OrthoParseCurrentLine(PyMOLGlobals * G); void OrthoParseCurrentLine(PyMOLGlobals * G);
Block *OrthoFindBlock(PyMOLGlobals * G, int x, int y);
void OrthoKeyControl(PyMOLGlobals * G, unsigned char k);
void OrthoKeyAlt(PyMOLGlobals * G, unsigned char k);
void OrthoKeyCtSh(PyMOLGlobals * G, unsigned char k);
void OrthoKeyCmmd(PyMOLGlobals * G, unsigned char k);
#define cBusyWidth 240 #define cBusyWidth 240
#define cBusyHeight 60 #define cBusyHeight 60
#define cBusyMargin 10 #define cBusyMargin 10
#define cBusyBar 10 #define cBusyBar 10
#define cBusySpacing 15 #define cBusySpacing 15
#define cBusyUpdate 0.2 #define cBusyUpdate 0.2
#define cWizardTopMargin 15 #define cWizardTopMargin 15
#define cWizardLeftMargin 15 #define cWizardLeftMargin 15
skipping to change at line 239 skipping to change at line 229
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
I->LoopRect = (*rect); I->LoopRect = (*rect);
I->LoopFlag = flag; I->LoopFlag = flag;
OrthoInvalidateDoDraw(G); OrthoInvalidateDoDraw(G);
OrthoDirty(G); OrthoDirty(G);
} }
int OrthoDeferredWaiting(PyMOLGlobals * G) int OrthoDeferredWaiting(PyMOLGlobals * G)
{ {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
return (I->deferred != NULL); return (!I->deferred.empty());
} }
void OrthoExecDeferred(PyMOLGlobals * G) void OrthoExecDeferred(PyMOLGlobals * G)
{ {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
CDeferred *deferred = I->deferred;
I->deferred = NULL;
/* execute all deferred actions that happened to require a /* execute all deferred actions that happened to require a
* valid OpenGL context (such as atom picks, etc.) */ * valid OpenGL context (such as atom picks, etc.) */
for(const auto& d : I->deferred){
DeferredExec(deferred); d->exec();
}
I->deferred.clear();
} }
void OrthoDefer(PyMOLGlobals * G, CDeferred * D) void OrthoDefer(PyMOLGlobals * G, std::unique_ptr<CDeferred> && D)
{ {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
CDeferred *d = I->deferred; I->deferred.emplace_back(std::move(D));
if(d) {
while(d->next)
d = d->next;
d->next = D;
} else {
I->deferred = D;
}
OrthoDirty(G); OrthoDirty(G);
} }
int OrthoGetWidth(PyMOLGlobals * G) int OrthoGetWidth(PyMOLGlobals * G)
{ {
if(G) { if(G) {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
return (I->Width); return (I->Width);
} }
return 0; return 0;
skipping to change at line 431 skipping to change at line 413
void OrthoCommandNest(PyMOLGlobals * G, int dir) void OrthoCommandNest(PyMOLGlobals * G, int dir)
{ {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
I->cmdNestLevel += dir; I->cmdNestLevel += dir;
{ {
int level = I->cmdNestLevel; int level = I->cmdNestLevel;
if(level < 0) if(level < 0)
level = 0; level = 0;
if(level > CMD_QUEUE_MASK) if(level > CMD_QUEUE_MASK)
level = CMD_QUEUE_MASK; level = CMD_QUEUE_MASK;
I->cmdActiveQueue = I->cmdQueue[level]; I->cmdActiveQueue = &I->cmdQueue[level];
} }
} }
/*========================================================================*/ /*========================================================================*/
int OrthoCommandOutSize(PyMOLGlobals * G){ bool OrthoCommandIsEmpty(COrtho& ortho){
if(G) { return ortho.cmdActiveQueue->empty();
COrtho *I = G->Ortho;
if(I && I->cmdActiveQueue) {
return QueueStrCheck(I->cmdActiveQueue);
}
}
return 0;
} }
int OrthoCommandOut(PyMOLGlobals * G, char *buffer) /*========================================================================*/
{ std::string OrthoCommandOut(COrtho& ortho){
if(G && buffer) { std::string str;
COrtho *I = G->Ortho; if(ortho.cmdActiveQueue){
str = std::move(ortho.cmdActiveQueue->front());
if(I && I->cmdActiveQueue) { ortho.cmdActiveQueue->pop();
int result;
result = QueueStrOut(I->cmdActiveQueue, buffer);
return (result);
}
} }
return 0; return str;
} }
/*========================================================================*/ /*========================================================================*/
int OrthoCommandWaiting(PyMOLGlobals * G) int OrthoCommandWaiting(PyMOLGlobals * G)
{ {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
return (I->cmdActiveBusy || QueueStrCheck(I->cmdActiveQueue)); return (I->cmdActiveBusy || !OrthoCommandIsEmpty(*I));
} }
/*========================================================================*/ /*========================================================================*/
void OrthoClear(PyMOLGlobals * G) void OrthoClear(PyMOLGlobals * G)
{ {
int a; int a;
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
for(a = 0; a <= OrthoSaveLines; a++) for(a = 0; a <= OrthoSaveLines; a++)
I->Line[a][0] = 0; I->Line[a][0] = 0;
OrthoNewLine(G, NULL, true); OrthoNewLine(G, NULL, true);
OrthoRestorePrompt(G); OrthoRestorePrompt(G);
OrthoInvalidateDoDraw(G); OrthoInvalidateDoDraw(G);
OrthoDirty(G); OrthoDirty(G);
} }
/*========================================================================*/ /*========================================================================*/
void OrthoFeedbackIn(PyMOLGlobals * G, const char *buffer) void OrthoFeedbackIn(PyMOLGlobals * G, const char *buffer)
{ {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
if(G->Option->pmgui) { if(G->Option->pmgui) {
if(I->feedback) I->feedback.emplace(buffer);
QueueStrIn(I->feedback, buffer);
} }
} }
/*========================================================================*/ /*========================================================================*/
int OrthoFeedbackOut(PyMOLGlobals * G, char *buffer) // For now keep G here for Settings
std::string OrthoFeedbackOut(PyMOLGlobals* G, COrtho& ortho)
{ {
COrtho *I = G->Ortho; std::string buffer;
if(!I->feedback) if (ortho.feedback.empty()) {
return 0; return buffer;
}
int status = QueueStrOut(I->feedback, buffer); buffer = std::move(ortho.feedback.front());
ortho.feedback.pop();
if (status && !SettingGetGlobal_b(G, cSetting_colored_feedback)) { if (!SettingGetGlobal_b(G, cSetting_colored_feedback)) {
UtilStripANSIEscapes(buffer); UtilStripANSIEscapes(buffer);
} }
return status; return buffer;
} }
/*========================================================================*/ /*========================================================================*/
void OrthoDirty(PyMOLGlobals * G) void OrthoDirty(PyMOLGlobals * G)
{ {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
PRINTFD(G, FB_Ortho) PRINTFD(G, FB_Ortho)
" OrthoDirty: called.\n" ENDFD; " OrthoDirty: called.\n" ENDFD;
if(!I->DirtyFlag) { if(!I->DirtyFlag) {
I->DirtyFlag = true; I->DirtyFlag = true;
skipping to change at line 761 skipping to change at line 733
curLine = I->CurLine & OrthoSaveLines; curLine = I->CurLine & OrthoSaveLines;
strcpy(I->Line[curLine], I->Prompt); strcpy(I->Line[curLine], I->Prompt);
I->CurChar = (I->PromptChar = strlen(I->Prompt)); I->CurChar = (I->PromptChar = strlen(I->Prompt));
} }
} }
I->InputFlag = 1; I->InputFlag = 1;
} }
} }
/*========================================================================*/ /*========================================================================*/
static
void OrthoKeyControl(PyMOLGlobals * G, unsigned char k) void OrthoKeyControl(PyMOLGlobals * G, unsigned char k)
{ {
char buffer[OrthoLineLength]; char buffer[OrthoLineLength];
/* safer... */ /* safer... */
sprintf(buffer, "cmd._ctrl(chr(%d))", k); sprintf(buffer, "cmd._ctrl(chr(%d))", k);
/* sprintf(buffer,"_ctrl %c",k); */ /* sprintf(buffer,"_ctrl %c",k); */
PLog(G, buffer, cPLog_pym); PLog(G, buffer, cPLog_pym);
PParse(G, buffer); PParse(G, buffer);
PFlush(G); PFlush(G);
} }
/*========================================================================*/ /*========================================================================*/
static
void OrthoKeyCmmd(PyMOLGlobals * G, unsigned char k) void OrthoKeyCmmd(PyMOLGlobals * G, unsigned char k)
{ {
char buffer[OrthoLineLength]; char buffer[OrthoLineLength];
/* safer... */ /* safer... */
sprintf(buffer, "cmd._cmmd(chr(%d))", k); sprintf(buffer, "cmd._cmmd(chr(%d))", k);
/* sprintf(buffer,"_ctrl %c",k); */ /* sprintf(buffer,"_ctrl %c",k); */
PLog(G, buffer, cPLog_pym); PLog(G, buffer, cPLog_pym);
PParse(G, buffer); PParse(G, buffer);
PFlush(G); PFlush(G);
} }
/*========================================================================*/ /*========================================================================*/
static
void OrthoKeyCtSh(PyMOLGlobals * G, unsigned char k) void OrthoKeyCtSh(PyMOLGlobals * G, unsigned char k)
{ {
char buffer[OrthoLineLength]; char buffer[OrthoLineLength];
/* safer... */ /* safer... */
sprintf(buffer, "cmd._ctsh(chr(%d))", k); sprintf(buffer, "cmd._ctsh(chr(%d))", k);
/* sprintf(buffer,"_ctrl %c",k); */ /* sprintf(buffer,"_ctrl %c",k); */
PLog(G, buffer, cPLog_pym); PLog(G, buffer, cPLog_pym);
PParse(G, buffer); PParse(G, buffer);
PFlush(G); PFlush(G);
} }
/*========================================================================*/ /*========================================================================*/
static
void OrthoKeyAlt(PyMOLGlobals * G, unsigned char k) void OrthoKeyAlt(PyMOLGlobals * G, unsigned char k)
{ {
char buffer[OrthoLineLength]; char buffer[OrthoLineLength];
/* safer... */ /* safer... */
if(k == '@') { if(k == '@') {
/* option G produces '@' on some non-US keyboards, so simply /* option G produces '@' on some non-US keyboards, so simply
ignore the modifier */ ignore the modifier */
OrthoKey(G, k, 0, 0, 0); OrthoKey(G, k, 0, 0, 0);
skipping to change at line 1219 skipping to change at line 1195
} }
/*========================================================================*/ /*========================================================================*/
void OrthoUngrab(PyMOLGlobals * G) void OrthoUngrab(PyMOLGlobals * G)
{ {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
I->GrabbedBy = NULL; I->GrabbedBy = NULL;
} }
/*========================================================================*/ /*========================================================================*/
Block *OrthoNewBlock(PyMOLGlobals * G, Block * block)
{
if(!block)
ListElemAlloc(G, block, Block);
UtilZeroMem(block, sizeof(Block));
BlockInit(G, block);
return (block);
}
/*========================================================================*/
void OrthoFreeBlock(PyMOLGlobals * G, Block * block)
{
if(block)
ListElemFree(block);
}
/*========================================================================*/
void OrthoAttach(PyMOLGlobals * G, Block * block, int type) void OrthoAttach(PyMOLGlobals * G, Block * block, int type)
{ {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
ListInsert(I->Blocks, block, NULL, next, Block); ListInsert(I->Blocks, block, NULL, next, Block);
} }
/*========================================================================*/ /*========================================================================*/
void OrthoDetach(PyMOLGlobals * G, Block * block) void OrthoDetach(PyMOLGlobals * G, Block * block)
{ {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
skipping to change at line 1390 skipping to change at line 1349
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, I->bg_texture_id); glBindTexture(GL_TEXTURE_2D, I->bg_texture_id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, is_repeat ? GL_REPEAT : GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, is_repeat ? GL_REPEAT : GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, is_repeat ? GL_REPEAT : GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, is_repeat ? GL_REPEAT : GL_CLAMP_TO_EDGE);
{ {
int bg_image_linear = SettingGet_b(G, NULL, NULL, cSetting_bg_image_linea r); int bg_image_linear = SettingGet_b(G, NULL, NULL, cSetting_bg_image_linea r);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, bg_image_linear ? G L_LINEAR : GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, bg_image_linear ? G L_LINEAR : GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, bg_image_linear ? G L_LINEAR : GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, bg_image_linear ? G L_LINEAR : GL_NEAREST);
} }
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
I->bgWidth, I->bgHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)I->bgData); I->bgData->getWidth(), I->bgData->getHeight(), 0, GL_RGBA, GL_ UNSIGNED_BYTE, (GLvoid*)I->bgData->bits());
bg_image = false; bg_image = false;
bg_gradient = I->bg_texture_needs_update = 0; bg_gradient = I->bg_texture_needs_update = 0;
} }
if (ok && !bg_is_solid && (bg_image && (!I->bg_texture_id || I->bg_texture_n eeds_update))){ if (ok && !bg_is_solid && (bg_image && (!I->bg_texture_id || I->bg_texture_n eeds_update))){
// checking to see if bg_image_filename can be loaded into texture // checking to see if bg_image_filename can be loaded into texture
ImageType *bgImage = Calloc(ImageType, 1); auto bgImage = MyPNGRead(bg_image_filename);
if(MyPNGRead(bg_image_filename, if(bgImage) {
(unsigned char **) &bgImage->data,
(unsigned int *) &bgImage->width, (unsigned int *) &bgImage->h
eight)) {
short is_new = !I->bg_texture_id; short is_new = !I->bg_texture_id;
int buff_total = bgImage->width * bgImage->height; int buff_total = bgImage->getWidth() * bgImage->getHeight();
I->bgWidth = bgImage->width;
I->bgHeight = bgImage->height;
bgImage->size = buff_total * 4;
if (is_new){ if (is_new){
glGenTextures(1, &I->bg_texture_id); glGenTextures(1, &I->bg_texture_id);
} }
glActiveTexture(GL_TEXTURE4); glActiveTexture(GL_TEXTURE4);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, I->bg_texture_id); glBindTexture(GL_TEXTURE_2D, I->bg_texture_id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, is_repeat ? GL_REPEAT : GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, is_repeat ? GL_REPEAT : GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, is_repeat ? GL_REPEAT : GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, is_repeat ? GL_REPEAT : GL_CLAMP_TO_EDGE);
{ {
int bg_image_linear = SettingGet_b(G, NULL, NULL, cSetting_bg_image_lin ear); int bg_image_linear = SettingGet_b(G, NULL, NULL, cSetting_bg_image_lin ear);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, bg_image_linear ? GL_LINEAR : GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, bg_image_linear ? GL_LINEAR : GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, bg_image_linear ? GL_LINEAR : GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, bg_image_linear ? GL_LINEAR : GL_NEAREST);
} }
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bgImage->getWidth(),
bgImage->width, bgImage->height, 0, GL_RGBA, GL_UNSIGNED_BYT bgImage->getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE,
E, (GLvoid*)bgImage->data); (GLvoid*) bgImage->bits());
FreeP(bgImage->data); bgImage.reset();
bg_gradient = I->bg_texture_needs_update = 0; bg_gradient = I->bg_texture_needs_update = 0;
} else { } else {
I->bgWidth = 0;
I->bgHeight = 0;
PRINTFB(G, FB_Ortho, FB_Errors) PRINTFB(G, FB_Ortho, FB_Errors)
"Ortho: bg_grad: bg_image_filename='%s' cannot be loaded, unset\n", bg_ image_filename "Ortho: bg_grad: bg_image_filename='%s' cannot be loaded, unset\n", bg_ image_filename
ENDFB(G); ENDFB(G);
SettingSetGlobal_s(G, cSetting_bg_image_filename, ""); SettingSetGlobal_s(G, cSetting_bg_image_filename, "");
G->ShaderMgr->Reload_All_Shaders(); G->ShaderMgr->Reload_All_Shaders();
} }
FreeP(bgImage); bgImage = nullptr;
} }
if (ok && !bg_is_solid && bg_gradient && (!I->bg_texture_id || I->bg_texture _needs_update)){ if (ok && !bg_is_solid && bg_gradient && (!I->bg_texture_id || I->bg_texture _needs_update)){
short is_new = !I->bg_texture_id; short is_new = !I->bg_texture_id;
int tex_dim = BACKGROUND_TEXTURE_SIZE; int tex_dim = BACKGROUND_TEXTURE_SIZE;
int buff_total = tex_dim * tex_dim; pymol::Image tmpImg(tex_dim, tex_dim);
unsigned char *temp_buffer = Alloc(unsigned char, buff_total * 4);
I->bg_texture_needs_update = 0; I->bg_texture_needs_update = 0;
I->bgWidth = BACKGROUND_TEXTURE_SIZE;
I->bgHeight = BACKGROUND_TEXTURE_SIZE;
if (is_new){ if (is_new){
glGenTextures(1, &I->bg_texture_id); glGenTextures(1, &I->bg_texture_id);
} }
glActiveTexture(GL_TEXTURE4); glActiveTexture(GL_TEXTURE4);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, I->bg_texture_id); glBindTexture(GL_TEXTURE_2D, I->bg_texture_id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, is_repeat ? GL_REPEAT : GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, is_repeat ? GL_REPEAT : GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, is_repeat ? GL_REPEAT : GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, is_repeat ? GL_REPEAT : GL_CLAMP_TO_EDGE);
{ {
int bg_image_linear = SettingGet_b(G, NULL, NULL, cSetting_bg_image_linea r); int bg_image_linear = SettingGet_b(G, NULL, NULL, cSetting_bg_image_linea r);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, bg_image_linear ? G L_LINEAR : GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, bg_image_linear ? G L_LINEAR : GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, bg_image_linear ? G L_LINEAR : GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, bg_image_linear ? G L_LINEAR : GL_NEAREST);
} }
UtilZeroMem(temp_buffer, buff_total * 4);
{ {
int a, b; int a, b;
unsigned char *q, val[4]; unsigned char *q, val[4];
float bot[3] = { bottom[0]*255, bottom[1]*255, bottom[2]*255 }; float bot[3] = { bottom[0]*255, bottom[1]*255, bottom[2]*255 };
float tmpb, diff[3] = { 255.f*(top[0] - bottom[0]), float tmpb, diff[3] = { 255.f*(top[0] - bottom[0]),
255.f*(top[1] - bottom[1]), 255.f*(top[1] - bottom[1]),
255.f*(top[2] - bottom[2]) }; 255.f*(top[2] - bottom[2]) };
for(b = 0; b < BACKGROUND_TEXTURE_SIZE; b++) { for(b = 0; b < BACKGROUND_TEXTURE_SIZE; b++) {
tmpb = b / (BACKGROUND_TEXTURE_SIZE-1.f); tmpb = b / (BACKGROUND_TEXTURE_SIZE-1.f);
val[0] = (unsigned char)pymol_roundf(bot[0] + tmpb*diff[0]) ; val[0] = (unsigned char)pymol_roundf(bot[0] + tmpb*diff[0]) ;
val[1] = (unsigned char)pymol_roundf(bot[1] + tmpb*diff[1]) ; val[1] = (unsigned char)pymol_roundf(bot[1] + tmpb*diff[1]) ;
val[2] = (unsigned char)pymol_roundf(bot[2] + tmpb*diff[2]) ; val[2] = (unsigned char)pymol_roundf(bot[2] + tmpb*diff[2]) ;
for(a = 0; a < BACKGROUND_TEXTURE_SIZE; a++) { for(a = 0; a < BACKGROUND_TEXTURE_SIZE; a++) {
q = temp_buffer + (4 * BACKGROUND_TEXTURE_SIZE * b) + 4 * a; q = tmpImg.bits() + (4 * BACKGROUND_TEXTURE_SIZE * b) + 4 * a;
*(q++) = val[0]; *(q++) = val[0];
*(q++) = val[1]; *(q++) = val[1];
*(q++) = val[2]; *(q++) = val[2];
*(q++) = 255; *(q++) = 255;
} }
} }
} }
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
tex_dim, tex_dim, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)temp_ tex_dim, tex_dim, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)tmpIm
buffer); g.bits());
FreeP(temp_buffer);
} }
if (ok && I->bgCGO) { if (ok && I->bgCGO) {
CGORenderGL(I->bgCGO, NULL, NULL, NULL, NULL, NULL); CGORenderGL(I->bgCGO, NULL, NULL, NULL, NULL, NULL);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
} }
} }
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
} }
skipping to change at line 1649 skipping to change at line 1597
break; break;
} }
OrthoPushMatrix(G); OrthoPushMatrix(G);
if (G->ShaderMgr->ShadersPresent()){ if (G->ShaderMgr->ShadersPresent()){
if(SettingGetGlobal_b(G, cSetting_internal_gui) && if(SettingGetGlobal_b(G, cSetting_internal_gui) &&
SettingGetGlobal_b(G, cSetting_use_shaders)){ SettingGetGlobal_b(G, cSetting_use_shaders)){
CGO *orthoFastCGO = CGONew(G); CGO *orthoFastCGO = CGONew(G);
CGOFree(I->orthoFastCGO); CGOFree(I->orthoFastCGO);
if (BlockRecursiveFastDraw(I->Blocks ORTHOFASTCGOARGVAR)){ if (I->Blocks->recursiveFastDraw(orthoFastCGO)){
int ok = true; int ok = true;
CGO *expandedCGO; CGO *expandedCGO;
CGOStop(orthoFastCGO); CGOStop(orthoFastCGO);
expandedCGO = CGOExpandDrawTextures(orthoFastCGO, 0); expandedCGO = CGOExpandDrawTextures(orthoFastCGO, 0);
CHECKOK(ok, expandedCGO); CHECKOK(ok, expandedCGO);
if (ok) if (ok)
I->orthoFastCGO = CGOOptimizeScreenTexturesAndPolygons(expandedCGO, 0); I->orthoFastCGO = CGOOptimizeScreenTexturesAndPolygons(expandedCGO, 0);
CHECKOK(ok, I->orthoFastCGO); CHECKOK(ok, orthoFastCGO);
CGOFree(orthoFastCGO); CGOFree(orthoFastCGO);
CGOFree(expandedCGO); CGOFree(expandedCGO);
} else { } else {
CGOFree(orthoFastCGO); CGOFree(orthoFastCGO);
} }
if (!I->orthoCGO){ if (!I->orthoCGO){
orthoCGO = CGONew(G); orthoCGO = CGONew(G);
generate_shader_cgo = true; generate_shader_cgo = true;
} else { } else {
OrthoRenderCGO(G); OrthoRenderCGO(G);
skipping to change at line 1818 skipping to change at line 1766
} }
OrthoDrawWizardPrompt(G ORTHOCGOARGVAR); OrthoDrawWizardPrompt(G ORTHOCGOARGVAR);
if(SettingGetGlobal_b(G, cSetting_text) || I->SplashFlag) { if(SettingGetGlobal_b(G, cSetting_text) || I->SplashFlag) {
Block *block; Block *block;
int active_tmp; int active_tmp;
block = SeqGetBlock(G); block = SeqGetBlock(G);
active_tmp = block->active; active_tmp = block->active;
block->active = false; block->active = false;
BlockRecursiveDraw(I->Blocks ORTHOCGOARGVAR); I->Blocks->recursiveDraw(orthoCGO);
block->active = active_tmp; block->active = active_tmp;
} else { } else {
BlockRecursiveDraw(I->Blocks ORTHOCGOARGVAR); I->Blocks->recursiveDraw(orthoCGO);
} }
PRINTFD(G, FB_Ortho) PRINTFD(G, FB_Ortho)
" OrthoDoDraw: blocks drawn.\n" ENDFD; " OrthoDoDraw: blocks drawn.\n" ENDFD;
if(I->LoopFlag) { if(I->LoopFlag) {
const float *vc = ColorGet(G, cColorFront); const float *vc = ColorGet(G, cColorFront);
if (generate_shader_cgo){ if (generate_shader_cgo){
CGOColor(orthoCGO, vc[0], vc[1], vc[2]); CGOColor(orthoCGO, vc[0], vc[1], vc[2]);
skipping to change at line 2137 skipping to change at line 2085
int wizardBottom = butModeBottom + butModeHeight; int wizardBottom = butModeBottom + butModeHeight;
int executiveBottom = wizardBottom + wizardHeight; int executiveBottom = wizardBottom + wizardHeight;
int height = I->Height; int height = I->Height;
if(SettingGetGlobal_b(G, cSetting_internal_gui)) { if(SettingGetGlobal_b(G, cSetting_internal_gui)) {
/* The Executive Block consists of the area in which object entries are rend ered, /* The Executive Block consists of the area in which object entries are rend ered,
if the wizard doesn't exist, then this region extends all the way down to the if the wizard doesn't exist, then this region extends all the way down to the
top of the ButMode block */ top of the ButMode block */
block = ExecutiveGetBlock(G); block = ExecutiveGetBlock(G);
BlockSetMargin(block, m_top, m_left, executiveBottom, m_right); block->setMargin(m_top, m_left, executiveBottom, m_right);
block->active = true; block->active = true;
/* The Wizard Block is shown when a wizard is loaded, it is the area between the /* The Wizard Block is shown when a wizard is loaded, it is the area between the
Executive Block and the ButMode Block, and is used for Wizard-related inf o/buttons */ Executive Block and the ButMode Block, and is used for Wizard-related inf o/buttons */
block = WizardGetBlock(G); block = WizardGetBlock(G);
BlockSetMargin(block, height - executiveBottom + 1, m_left, wizardBottom, m_ right); block->setMargin(height - executiveBottom + 1, m_left, wizardBottom, m_right );
block->active = false; block->active = false;
/* The ButMode block shows info about which Mouse Mode, Selecting Mode, Stat e info, /* The ButMode block shows info about which Mouse Mode, Selecting Mode, Stat e info,
and other info like frame rate. It is located under the Wizard Block, and above and other info like frame rate. It is located under the Wizard Block, and above
the Control Block */ the Control Block */
block = ButModeGetBlock(G); block = ButModeGetBlock(G);
BlockSetMargin(block, height - wizardBottom + 1, m_left, butModeBottom, m_ri ght); block->setMargin(height - wizardBottom + 1, m_left, butModeBottom, m_right);
block->active = true; block->active = true;
/* Controls are the Movie/Scene arrow buttons at the very bottom */ /* Controls are the Movie/Scene arrow buttons at the very bottom */
block = ControlGetBlock(G); block = ControlGetBlock(G);
BlockSetMargin(block, height - butModeBottom + 1, m_left, controlBottom, m_r ight); block->setMargin(height - butModeBottom + 1, m_left, controlBottom, m_right) ;
block->active = true; block->active = true;
} else { } else {
/* The Executive Block consists of the area in which object entries are rend ered, /* The Executive Block consists of the area in which object entries are rend ered,
if the wizard doesn't exist, then this region extends all the way down to the if the wizard doesn't exist, then this region extends all the way down to the
top of the ButMode block */ top of the ButMode block */
block = ExecutiveGetBlock(G); block = ExecutiveGetBlock(G);
BlockSetMargin(block, m_right, m_bottom, m_right, m_bottom); block->setMargin(m_right, m_bottom, m_right, m_bottom);
block->active = false; block->active = false;
/* The Wizard Block is shown when a wizard is loaded, it is the area between the /* The Wizard Block is shown when a wizard is loaded, it is the area between the
Executive Block and the ButMode Block, and is used for Wizard-related inf o/buttons */ Executive Block and the ButMode Block, and is used for Wizard-related inf o/buttons */
block = WizardGetBlock(G); block = WizardGetBlock(G);
BlockSetMargin(block, m_right, m_bottom, m_right, m_bottom); block->setMargin(m_right, m_bottom, m_right, m_bottom);
block->active = false; block->active = false;
/* The ButMode block shows info about which Mouse Mode, Selecting Mode, Stat e info, /* The ButMode block shows info about which Mouse Mode, Selecting Mode, Stat e info,
and other info like frame rate. It is located under the Wizard Block, and above and other info like frame rate. It is located under the Wizard Block, and above
the Control Block */ the Control Block */
block = ButModeGetBlock(G); block = ButModeGetBlock(G);
BlockSetMargin(block, m_right, m_bottom, m_right, m_bottom); block->setMargin(m_right, m_bottom, m_right, m_bottom);
block->active = false; block->active = false;
/* Controls are the Movie/Scene arrow buttons at the very bottom */ /* Controls are the Movie/Scene arrow buttons at the very bottom */
block = ControlGetBlock(G); block = ControlGetBlock(G);
BlockSetMargin(block, m_right, m_bottom, m_right, m_bottom); block->setMargin(m_right, m_bottom, m_right, m_bottom);
block->active = false; block->active = false;
} }
} }
/*========================================================================*/ /*========================================================================*/
void OrthoReshape(PyMOLGlobals * G, int width, int height, int force) void OrthoReshape(PyMOLGlobals * G, int width, int height, int force)
{ {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
if(!G->HaveGUI && width < 0) if(!G->HaveGUI && width < 0)
skipping to change at line 2263 skipping to change at line 2211
{ {
int seqHeight; int seqHeight;
block = SeqGetBlock(G); block = SeqGetBlock(G);
block->active = true; block->active = true;
/* reloate the sequence viewer as necessary */ /* reloate the sequence viewer as necessary */
if(SettingGetGlobal_b(G, cSetting_seq_view_location)) { if(SettingGetGlobal_b(G, cSetting_seq_view_location)) {
BlockSetMargin(block, height - sceneBottom - 10, 0, sceneBottom, sceneRi block->setMargin(height - sceneBottom - 10, 0, sceneBottom, sceneRight);
ght); block->reshape(width, height);
if(block->fReshape)
block->fReshape(block, width, height);
seqHeight = SeqGetHeight(G); seqHeight = SeqGetHeight(G);
BlockSetMargin(block, height - sceneBottom - seqHeight, 0, sceneBottom, block->setMargin(height - sceneBottom - seqHeight, 0, sceneBottom,
sceneRight); sceneRight);
if(!SettingGetGlobal_b(G, cSetting_seq_view_overlay)) { if(!SettingGetGlobal_b(G, cSetting_seq_view_overlay)) {
sceneBottom += seqHeight; sceneBottom += seqHeight;
} }
} else { } else {
BlockSetMargin(block, 0, 0, height - 10, sceneRight); block->setMargin(0, 0, height - 10, sceneRight);
if(block->fReshape) block->reshape(width, height);
block->fReshape(block, width, height);
seqHeight = SeqGetHeight(G); seqHeight = SeqGetHeight(G);
BlockSetMargin(block, 0, 0, height - seqHeight, sceneRight); block->setMargin(0, 0, height - seqHeight, sceneRight);
if(!SettingGetGlobal_b(G, cSetting_seq_view_overlay)) { if(!SettingGetGlobal_b(G, cSetting_seq_view_overlay)) {
sceneTop = seqHeight; sceneTop = seqHeight;
} }
} }
} }
OrthoLayoutPanel(G, 0, width - internal_gui_width, textBottom, 0); OrthoLayoutPanel(G, 0, width - internal_gui_width, textBottom, 0);
block = MovieGetBlock(G); block = MovieGetBlock(G);
BlockSetMargin(block, height - textBottom, 0, 0, 0); block->setMargin(height - textBottom, 0, 0, 0);
block->active = textBottom ? true : false; block->active = textBottom ? true : false;
block = SceneGetBlock(G); block = SceneGetBlock(G);
BlockSetMargin(block, sceneTop, 0, sceneBottom, sceneRight); block->setMargin(sceneTop, 0, sceneBottom, sceneRight);
block = NULL; block = NULL;
while(ListIterate(I->Blocks, block, next)) while(ListIterate(I->Blocks, block, next)){
if(block->fReshape) { block->reshape(width, height);
block->fReshape(block, width, height); }
}
WizardRefresh(G); /* safe to call even if no wizard exists */ WizardRefresh(G); /* safe to call even if no wizard exists */
} }
SceneInvalidateStencil(G); SceneInvalidateStencil(G);
G->ShaderMgr->ResetUniformSet(); G->ShaderMgr->ResetUniformSet();
OrthoInvalidateDoDraw(G); OrthoInvalidateDoDraw(G);
OrthoDirty(G); OrthoDirty(G);
} }
/*========================================================================*/ /*========================================================================*/
void OrthoReshapeWizard(PyMOLGlobals * G, ov_size wizHeight) void OrthoReshapeWizard(PyMOLGlobals * G, ov_size wizHeight)
{ {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
I->WizardHeight = wizHeight; I->WizardHeight = wizHeight;
if(SettingGetGlobal_b(G, cSetting_internal_gui) > 0.0) { if(SettingGetGlobal_b(G, cSetting_internal_gui)) {
Block *block; Block *block;
int internal_gui_width = DIP2PIXEL(SettingGetGlobal_i(G, cSetting_internal_g ui_width)); int internal_gui_width = DIP2PIXEL(SettingGetGlobal_i(G, cSetting_internal_g ui_width));
OrthoLayoutPanel(G, 0, I->Width - internal_gui_width, I->TextBottom, 0); OrthoLayoutPanel(G, 0, I->Width - internal_gui_width, I->TextBottom, 0);
block = ExecutiveGetBlock(G); block = ExecutiveGetBlock(G);
block->fReshape(block, I->Width, I->Height); block->reshape(I->Width, I->Height);
block = WizardGetBlock(G); block = WizardGetBlock(G);
block->fReshape(block, I->Width, I->Height); block->reshape(I->Width, I->Height);
block->active = wizHeight ? true : false; block->active = wizHeight ? true : false;
} }
} }
/*========================================================================*/ /*========================================================================*/
static
Block *OrthoFindBlock(PyMOLGlobals * G, int x, int y) Block *OrthoFindBlock(PyMOLGlobals * G, int x, int y)
{ {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
return (BlockRecursiveFind(I->Blocks, x, y)); return (I->Blocks->recursiveFind(x, y));
} }
/*========================================================================*/ /*========================================================================*/
int OrthoGetWrapClickSide(PyMOLGlobals * G) int OrthoGetWrapClickSide(PyMOLGlobals * G)
{ {
return G->Ortho->WrapClickSide; return G->Ortho->WrapClickSide;
} }
/*========================================================================*/ /*========================================================================*/
int OrthoButton(PyMOLGlobals * G, int button, int state, int x, int y, int mod) int OrthoButton(PyMOLGlobals * G, int button, int state, int x, int y, int mod)
skipping to change at line 2386 skipping to change at line 2332
I->X = x; I->X = x;
I->Y = y; I->Y = y;
I->LastX = x; I->LastX = x;
I->LastY = y; I->LastY = y;
I->LastModifiers = mod; I->LastModifiers = mod;
if(state == P_GLUT_DOWN) { if(state == P_GLUT_DOWN) {
I->ActiveButton = button; I->ActiveButton = button;
if(I->GrabbedBy) { if(I->GrabbedBy) {
if(I->GrabbedBy->inside) if(I->GrabbedBy->inside)
block = BlockRecursiveFind(I->GrabbedBy->inside, x, y); block = I->GrabbedBy->inside->recursiveFind(x, y);
else else
block = I->GrabbedBy; block = I->GrabbedBy;
} else if(!block) } else if(!block)
block = OrthoFindBlock(G, x, y); block = OrthoFindBlock(G, x, y);
if(block) { if(block) {
I->ClickedIn = block; I->ClickedIn = block;
if(block->fClick) { handled = block->click(button, x, y, mod);
handled = block->fClick(block, button, x, y, mod);
}
} }
} else if(state == P_GLUT_UP) { } else if(state == P_GLUT_UP) {
if(I->IssueViewportWhenReleased) { if(I->IssueViewportWhenReleased) {
OrthoCommandIn(G, "viewport"); OrthoCommandIn(G, "viewport");
I->IssueViewportWhenReleased = false; I->IssueViewportWhenReleased = false;
} }
if(I->GrabbedBy) { if(I->GrabbedBy) {
block = I->GrabbedBy; block = I->GrabbedBy;
if(block->fRelease) handled = block->release(button, x, y, mod);
handled = block->fRelease(block, button, x, y, mod);
I->ClickedIn = NULL; I->ClickedIn = NULL;
} }
if(I->ClickedIn) { if(I->ClickedIn) {
block = I->ClickedIn; block = I->ClickedIn;
if(block->fRelease) handled = block->release(button, x, y, mod);
handled = block->fRelease(block, button, x, y, mod);
I->ClickedIn = NULL; I->ClickedIn = NULL;
} }
I->ActiveButton = -1; I->ActiveButton = -1;
} }
if (handled) if (handled)
OrthoInvalidateDoDraw(G); OrthoInvalidateDoDraw(G);
return (handled); return (handled);
} }
/*========================================================================*/ /*========================================================================*/
skipping to change at line 2442 skipping to change at line 2384
} }
I->LastX = x; I->LastX = x;
I->LastY = y; I->LastY = y;
I->LastModifiers = mod; I->LastModifiers = mod;
I->X = x; I->X = x;
I->Y = y; I->Y = y;
if(I->GrabbedBy) { if(I->GrabbedBy) {
block = I->GrabbedBy; block = I->GrabbedBy;
if(block->fDrag) handled = block->drag(x, y, mod);
handled = block->fDrag(block, x, y, mod);
} else if(I->ClickedIn) { } else if(I->ClickedIn) {
block = I->ClickedIn; block = I->ClickedIn;
if(block->fDrag) handled = block->drag(x, y, mod);
handled = block->fDrag(block, x, y, mod);
} }
if (handled && block!=SceneGetBlock(G)) // if user is not draging inside scen e, then update OrthoCGO if (handled && block!=SceneGetBlock(G)) // if user is not draging inside scen e, then update OrthoCGO
OrthoInvalidateDoDraw(G); OrthoInvalidateDoDraw(G);
return (handled); return (handled);
} }
/*========================================================================*/ /*========================================================================*/
void OrthoSplash(PyMOLGlobals * G) void OrthoSplash(PyMOLGlobals * G)
{ {
skipping to change at line 2529 skipping to change at line 2469
#endif #endif
} }
/*========================================================================*/ /*========================================================================*/
int OrthoInit(PyMOLGlobals * G, int showSplash) int OrthoInit(PyMOLGlobals * G, int showSplash)
{ {
COrtho *I = NULL; COrtho *I = NULL;
if((I = (G->Ortho = Calloc(COrtho, 1)))) { if((I = (G->Ortho = Calloc(COrtho, 1)))) {
new (&I->deferred)(decltype(I->deferred));
new (&I->feedback)(decltype(I->feedback));
new (&I->cmdQueue)(decltype(I->cmdQueue));
ListInit(I->Blocks); ListInit(I->Blocks);
I->ActiveButton = -1; I->ActiveButton = -1;
I->Pushed = 0; I->Pushed = 0;
{ I->cmdActiveQueue = &(*I->cmdQueue.begin());
int a; I->cmdNestLevel = 0;
for(a = 0; a <= CMD_QUEUE_MASK; a++)
I->cmdQueue[a] = QueueNew(G, 0x7FFF); /* 32K ea. level for commands */
I->cmdActiveQueue = I->cmdQueue[0];
I->cmdNestLevel = 0;
}
I->feedback = QueueNew(G, 0x3FFFF); /* ~256K for output */
I->deferred = NULL;
I->RenderMode = 0; I->RenderMode = 0;
I->WrapXFlag = false; I->WrapXFlag = false;
I->WizardBackColor[0] = 0.2F; I->WizardBackColor[0] = 0.2F;
I->WizardBackColor[1] = 0.2F; I->WizardBackColor[1] = 0.2F;
I->WizardBackColor[2] = 0.2F; I->WizardBackColor[2] = 0.2F;
I->WizardTextColor[0] = 0.2F; I->WizardTextColor[0] = 0.2F;
I->WizardTextColor[1] = 1.0F; I->WizardTextColor[1] = 1.0F;
I->WizardTextColor[2] = 0.2F; I->WizardTextColor[2] = 0.2F;
skipping to change at line 2582 skipping to change at line 2519
I->SplashFlag = false; I->SplashFlag = false;
I->ShowLines = 1; I->ShowLines = 1;
I->Saved[0] = 0; I->Saved[0] = 0;
I->DirtyFlag = true; I->DirtyFlag = true;
I->ActiveGLBuffer = GL_NONE; I->ActiveGLBuffer = GL_NONE;
I->LastDraw = UtilGetSeconds(G); I->LastDraw = UtilGetSeconds(G);
I->DrawTime = 0.0; I->DrawTime = 0.0;
I->bg_texture_id = 0; I->bg_texture_id = 0;
I->bg_texture_needs_update = 0; I->bg_texture_needs_update = 0;
I->bgCGO = NULL; I->bgCGO = NULL;
I->bgWidth = I->bgHeight = 0; I->bgData = nullptr;
I->bgData = NULL;
I->orthoCGO = NULL; I->orthoCGO = NULL;
I->orthoFastCGO = NULL; I->orthoFastCGO = NULL;
if(showSplash) { if(showSplash) {
OrthoSplash(G); OrthoSplash(G);
I->SplashFlag = true; I->SplashFlag = true;
} }
/* OrthoFeedbackIn(G," "); */ /* OrthoFeedbackIn(G," "); */
I->CurLine++; I->CurLine++;
skipping to change at line 2628 skipping to change at line 2564
/*========================================================================*/ /*========================================================================*/
void OrthoFree(PyMOLGlobals * G) void OrthoFree(PyMOLGlobals * G)
{ {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
VLAFreeP(I->WizardPromptVLA); VLAFreeP(I->WizardPromptVLA);
PopFree(G); PopFree(G);
{ {
int a; int a;
I->cmdActiveQueue = NULL; I->cmdActiveQueue = NULL;
for(a = 0; a <= CMD_QUEUE_MASK; a++) {
QueueFree(I->cmdQueue[a]);
I->cmdQueue[a] = NULL;
}
}
QueueFree(I->feedback);
I->feedback = NULL;
if(I->deferred) {
DeferredFree(I->deferred);
I->deferred = NULL;
}
if (I->bgData){
FreeP(I->bgData);
I->bgData = NULL;
} }
pymol::destroy_at(&I->deferred);
pymol::destroy_at(&I->feedback);
pymol::destroy_at(&I->cmdQueue);
I->bgData = nullptr;
CGOFree(I->bgCGO); CGOFree(I->bgCGO);
CGOFree(I->orthoCGO); CGOFree(I->orthoCGO);
CGOFree(I->orthoFastCGO); CGOFree(I->orthoFastCGO);
FreeP(G->Ortho); FreeP(G->Ortho);
} }
/*========================================================================*/ /*========================================================================*/
void OrthoPushMatrix(PyMOLGlobals * G) void OrthoPushMatrix(PyMOLGlobals * G)
{ {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
skipping to change at line 2725 skipping to change at line 2654
} }
} }
} }
int OrthoGetPushed(PyMOLGlobals * G) int OrthoGetPushed(PyMOLGlobals * G)
{ {
return G->Ortho->Pushed; return G->Ortho->Pushed;
} }
/*========================================================================*/ /*========================================================================*/
void OrthoCommandIn(PyMOLGlobals * G, const char *buffer) void OrthoCommandIn(COrtho& ortho, const char* buffer)
{ {
COrtho *I = G->Ortho; if (ortho.cmdActiveQueue) {
if(I->cmdActiveQueue) ortho.cmdActiveQueue->emplace(buffer);
QueueStrIn(I->cmdActiveQueue, buffer); }
} }
void OrthoCommandSetBusy(PyMOLGlobals * G, int busy){ void OrthoCommandSetBusy(PyMOLGlobals * G, int busy){
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
I->cmdActiveBusy = busy; I->cmdActiveBusy = busy;
} }
/*========================================================================*/ /*========================================================================*/
void OrthoPasteIn(PyMOLGlobals * G, const char *buffer) void OrthoPasteIn(PyMOLGlobals * G, const char *buffer)
{ {
skipping to change at line 2794 skipping to change at line 2723
break; break;
} }
} }
if(execFlag) { if(execFlag) {
printf("[%s]\n", I->Line[curLine]); printf("[%s]\n", I->Line[curLine]);
OrthoParseCurrentLine(G); OrthoParseCurrentLine(G);
} else } else
I->InputFlag = true; I->InputFlag = true;
} }
#if 0
/* TODO: Removed. Check in Mobile PyMOL to see if needed - PYMOL-3148*/
void OrthoSetBackgroundImage(PyMOLGlobals * G, const char *image_data, int width , int height){ void OrthoSetBackgroundImage(PyMOLGlobals * G, const char *image_data, int width , int height){
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
int buff_total = width * height; int buff_total = width * height;
short should_update = 0; short should_update = 0;
if (I->bgData){ if (I->bgData){
FreeP(I->bgData); FreeP(I->bgData);
I->bgData = NULL; I->bgData = NULL;
I->bgWidth = 0; I->bgWidth = 0;
I->bgHeight = 0; I->bgHeight = 0;
should_update = 1; should_update = 1;
skipping to change at line 2824 skipping to change at line 2755
ColorUpdateFront(G, bg); ColorUpdateFront(G, bg);
ExecutiveInvalidateRep(G, "all", cRepAll, cRepInvColor); ExecutiveInvalidateRep(G, "all", cRepAll, cRepInvColor);
} }
#endif #endif
} }
if (should_update){ if (should_update){
G->ShaderMgr->Reload_All_Shaders(); G->ShaderMgr->Reload_All_Shaders();
I->bg_texture_needs_update = 1; I->bg_texture_needs_update = 1;
} }
} }
#endif
void OrthoInvalidateDoDraw(PyMOLGlobals * G) void OrthoInvalidateDoDraw(PyMOLGlobals * G)
{ {
COrtho *I = G->Ortho; COrtho *I = G->Ortho;
if (I->orthoCGO){ if (I->orthoCGO){
CGOFree(I->orthoCGO); CGOFree(I->orthoCGO);
PyMOL_NeedRedisplay(G->PyMOL); PyMOL_NeedRedisplay(G->PyMOL);
} }
} }
 End of changes. 82 change blocks. 
200 lines changed or deleted 129 lines changed or added

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