File: Feedback.cpp

package info (click to toggle)
pymol 1.8.4.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 42,248 kB
  • ctags: 24,095
  • sloc: cpp: 474,635; python: 75,034; ansic: 22,888; sh: 236; makefile: 78; csh: 21
file content (143 lines) | stat: -rw-r--r-- 3,757 bytes parent folder | download | duplicates (2)
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


/* 
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_predef.h"
#include"os_std.h"
#include"MemoryDebug.h"
#include"Feedback.h"
#include"Ortho.h"

int FeedbackInit(PyMOLGlobals * G, int quiet)
{
  int a;

  CFeedback *I;
  I = (G->Feedback = Calloc(CFeedback, 1));

  I->Stack = VLAlloc(char, FB_Total);
  I->Depth = 0;
  G->Feedback->Mask = I->Stack;

  if(quiet) {
    for(a = 0; a < FB_Total; a++) {
      G->Feedback->Mask[a] = 0;
    }
  } else {
    for(a = 0; a < FB_Total; a++) {
      G->Feedback->Mask[a] =
        FB_Output | FB_Results | FB_Errors | FB_Warnings | FB_Actions | FB_Details;
    }

    G->Feedback->Mask[FB_Main] &= ~(FB_Errors); /* suppress opengl errors in main */

  }
  return 1;
}

void FeedbackFree(PyMOLGlobals * G)
{
  CFeedback *I = G->Feedback;

  VLAFreeP(I->Stack);
  FreeP(G->Feedback);

}


/* below we'll presume that any standard feedback on the feedback
module itself will be effected at the Python level, since feedback
levels will be changed as a matter of course inside of PyMOL in order
to quietly perform complex actions.  */

void FeedbackPush(PyMOLGlobals * G)
{
  CFeedback *I = G->Feedback;
  int a;
  I->Depth++;
  VLACheck(I->Stack, char, (I->Depth + 1) * FB_Total);
  G->Feedback->Mask = I->Stack + (I->Depth * FB_Total);
  for(a = 0; a < FB_Total; a++) {
    G->Feedback->Mask[a] = G->Feedback->Mask[a - FB_Total];
  }
  PRINTFD(G, FB_Feedback) " Feedback: push\n" ENDFD;
}

void FeedbackPop(PyMOLGlobals * G)
{
  CFeedback *I = G->Feedback;
  if(I->Depth) {
    I->Depth--;
    G->Feedback->Mask = I->Stack + (I->Depth * FB_Total);
  }
  PRINTFD(G, FB_Feedback) " Feedback: pop\n" ENDFD;
}

void FeedbackSetMask(PyMOLGlobals * G, unsigned int sysmod, unsigned char mask)
{
  int a;
  if((sysmod > 0) && (sysmod < FB_Total)) {
    G->Feedback->Mask[sysmod] = mask;
  } else if(!sysmod) {
    for(a = 0; a < FB_Total; a++) {
      G->Feedback->Mask[a] = mask;
    }
  }
  PRINTFD(G, FB_Feedback)
    " FeedbackSetMask: sysmod %d, mask 0x%02X\n", sysmod, mask ENDFD;
}

void FeedbackDisable(PyMOLGlobals * G, unsigned int sysmod, unsigned char mask)
{
  int a;
  if((sysmod > 0) && (sysmod < FB_Total)) {
    G->Feedback->Mask[sysmod] = G->Feedback->Mask[sysmod] & (0xFF - mask);
  } else if(!sysmod) {
    for(a = 0; a < FB_Total; a++) {
      G->Feedback->Mask[a] = G->Feedback->Mask[a] & (0xFF - mask);
    }
  }
  PRINTFD(G, FB_Feedback)
    " FeedbackDisable: sysmod %d, mask 0x%02X\n", sysmod, mask ENDFD;

}

void FeedbackEnable(PyMOLGlobals * G, unsigned int sysmod, unsigned char mask)
{
  int a;
  if((sysmod > 0) && (sysmod < FB_Total)) {
    G->Feedback->Mask[sysmod] = G->Feedback->Mask[sysmod] | mask;
  } else if(!sysmod) {
    for(a = 0; a < FB_Total; a++) {
      G->Feedback->Mask[a] = G->Feedback->Mask[a] | mask;
    }
  }
  PRINTFD(G, FB_Feedback)
    " FeedbackEnable: sysmod %d, mask 0x%02X\n", sysmod, mask ENDFD;

}

void FeedbackAutoAdd(PyMOLGlobals * G, unsigned int sysmod, unsigned char mask, const char *str)
{
  if(Feedback(G, sysmod, mask))
    OrthoAddOutput(G, str);
}

void FeedbackAdd(PyMOLGlobals * G, const char *str)
{
  OrthoAddOutput(G, str);
}