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
|
/*
A* -------------------------------------------------------------------
B* This file contains source code for the PyMOL computer program
C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
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* -------------------------------------------------------------------
*/
#ifndef _H_Color
#define _H_Color
#include <unordered_map>
#include <string>
#include"os_python.h"
#include"Rep.h"
#include"Vector.h"
#include"PyMOLGlobals.h"
#include"Word.h"
#include"OVLexicon.h"
#include"OVOneToOne.h"
#define cColorGadgetRamp 1
#define cColorDefault -1
#define cColorNewAuto -2
#define cColorCurAuto -3
#define cColorAtomic -4
#define cColorObject -5
#define cColorFront -6
#define cColorBack -7
#define cColorExtCutoff (-10)
#define cColor_TRGB_Bits 0x40000000
#define cColor_TRGB_Mask 0xC0000000
typedef struct {
const char* Name;
Vector3f Color, LutColor;
char LutColorFlag;
char Custom, Fixed;
/* not saved */
int old_session_index;
} ColorRec;
typedef struct {
const char* Name;
void *Ptr;
int Type;
/* not saved */
int old_session_index;
} ExtRec;
struct CColor {
using ColorIdx = int;
ColorRec *Color{};
int NColor{};
ExtRec *Ext{};
int NExt{};
int LUTActive{};
std::vector<unsigned int> ColorTable{};
float Gamma = 1.0f;
int BigEndian{};
std::unordered_map<std::string, ColorIdx> Idx;
float RGBColor[3]{}; /* save global float for returning (float*) */
char RGBName[11]{}; // "0xTTRRGGBB"
/* not stored */
int HaveOldSessionColors{};
int HaveOldSessionExtColors{};
float Front[3] { 1.0f, 1.0f, 1.0f };
float Back[3]{};
};
int ColorInit(PyMOLGlobals * G);
void ColorFree(PyMOLGlobals * G);
int ColorGetNext(PyMOLGlobals * G);
int ColorGetCurrent(PyMOLGlobals * G);
int ColorGetIndex(PyMOLGlobals * G, const char *name);
int ColorConvertOldSessionIndex(PyMOLGlobals * G, int index);
void ColorUpdateFront(PyMOLGlobals * G, const float *back);
void ColorUpdateFrontFromSettings(PyMOLGlobals * G);
const float *ColorGet(PyMOLGlobals * G, int index); /* pointer maybe invalid after creating a new color */
const float *ColorGetRaw(PyMOLGlobals * G, int index); /* pointer maybe invalid after creating a new color */
const float *ColorGetSpecial(PyMOLGlobals * G, int index);
const float *ColorGetNamed(PyMOLGlobals * G, const char *name);
void ColorDef(PyMOLGlobals * G, const char *name, const float *v, int mode, int quiet);
int ColorGetNColor(PyMOLGlobals * G);
const char *ColorGetName(PyMOLGlobals * G, int index);
int ColorGetStatus(PyMOLGlobals * G, int index);
void ColorReset(PyMOLGlobals * G);
int ColorGetRamped(PyMOLGlobals * G, int index, const float *vertex, float *color, int state);
int ColorCheckRamped(PyMOLGlobals * G, int index);
bool ColorGetCheckRamped(PyMOLGlobals * G, int index, const float *vertex, float *color, int state);
struct ObjectGadgetRamp *ColorGetRamp(PyMOLGlobals * G, int index);
void ColorRegisterExt(PyMOLGlobals * G, const char *name, void *extPtr, int type);
void ColorForgetExt(PyMOLGlobals * G, const char *name);
PyObject *ColorAsPyList(PyMOLGlobals * G);
int ColorFromPyList(PyMOLGlobals * G, PyObject * list, int partial_restore);
int ColorExtFromPyList(PyMOLGlobals * G, PyObject * list, int partial_restore);
PyObject *ColorExtAsPyList(PyMOLGlobals * G);
int ColorTableLoad(PyMOLGlobals * G, const char *fname, float gamma, int quiet);
void ColorUpdateFromLut(PyMOLGlobals * G, int index);
int ColorLookupColor(PyMOLGlobals * G, float *color);
void ColorGetBkrdContColor(PyMOLGlobals * G, float *rgb, int invert_flag);
unsigned int ColorGet32BitWord(PyMOLGlobals * G, const float *rgba);
int ColorGetEncoded(PyMOLGlobals * G, int index, float *color);
int Color3fToInt(PyMOLGlobals * G, const float *rgb);
#endif
|