1 2 /* 3 A* ------------------------------------------------------------------- 4 B* This file contains source code for the PyMOL computer program 5 C* Copyright (c) Schrodinger, LLC. 6 D* ------------------------------------------------------------------- 7 E* It is unlawful to modify or remove this copyright notice. 8 F* ------------------------------------------------------------------- 9 G* Please see the accompanying LICENSE file for further information. 10 H* ------------------------------------------------------------------- 11 I* Additional authors of this source file include: 12 -* 13 -* 14 -* 15 Z* ------------------------------------------------------------------- 16 */ 17 18 #ifndef _H_SceneDef 19 #define _H_SceneDef 20 21 #include"gl_def.h" 22 #include"Base.h" 23 #include"PyMOLObject.h" 24 #include"Ortho.h" 25 #include"View.h" 26 #include"Image.h" 27 #include"ScrollBar.h" 28 #include<list> 29 #include<vector> 30 31 #define TRN_BKG 0x30 32 #define MAX_ANI_ELEM 300 33 34 struct DeferredMouse : public CDeferred { 35 Block *block { nullptr }; 36 int button { 0 }; 37 int x { 0 }; 38 int y { 0 }; 39 int mod { 0 }; 40 double when { 0.0 }; 41 int mode_override { 0 }; DeferredMouseDeferredMouse42 DeferredMouse(PyMOLGlobals * G) : CDeferred(G){} 43 }; 44 45 struct DeferredImage : public CDeferred { 46 int width { 0 }; 47 int height { 0 }; 48 std::string filename; 49 int quiet { 0 }; 50 int antialias { 0 }; 51 float dpi { 0.0f }; 52 int entire_window { 0 }; 53 int format { 0 }; DeferredImageDeferredImage54 DeferredImage(PyMOLGlobals * G) : CDeferred(G){} 55 }; 56 57 struct DeferredRay : public CDeferred { 58 int ray_width { 0 }; 59 int ray_height { 0 }; 60 int mode { 0 }; 61 float angle { 0.0f }; 62 float shift { 0.0f }; 63 int quiet { 0 }; 64 int show_timing { 0 }; 65 int antialias { 0 }; DeferredRayDeferredRay66 DeferredRay(PyMOLGlobals * G) : CDeferred(G){} 67 }; 68 69 typedef struct { 70 int len; 71 const char *name; 72 int x1, y1, x2, y2, drawn; 73 } SceneElem; 74 75 typedef struct { 76 float unit_left, unit_right, unit_top, unit_bottom, unit_front, unit_back; 77 } SceneUnitContext; 78 79 typedef struct { 80 int n_col; 81 int n_row; 82 int first_slot; 83 int last_slot; 84 float asp_adjust; 85 int active; 86 int size; 87 int slot; 88 int mode; 89 GLint cur_view[4]; 90 GLint cur_viewport_size[2]; 91 SceneUnitContext context; /* for whole-window display */ 92 } GridInfo; 93 94 struct SceneView { 95 struct ClippingPlane { 96 float m_front; 97 float m_back; 98 }; 99 float m_rotMatrix[16]; /*Column major--consistent with OpenGL spec*/ 100 float m_pos[3]; 101 float m_origin[3]; 102 ClippingPlane m_clip; 103 ClippingPlane m_clipSafe; 104 }; 105 106 class CScene : public Block { 107 public: 108 std::list<CObject*> Obj, GadgetObjs, NonGadgetObjs; 109 SceneView m_view{}; 110 float InvMatrix[16]; /* WARNING: column major, as per OpenGL spec */ 111 float PmvMatrix[16]; 112 float Scale; 113 int Width, Height; 114 int Button; 115 int LastX, LastY; 116 int StartX, StartY; 117 int LastWinX, LastWinY; 118 double LastClickTime; 119 int LastButton, LastMod; 120 int PossibleSingleClick; 121 double LastReleaseTime; 122 double SingleClickDelay; 123 float ViewNormal[3], LinesNormal[3]; 124 float H; 125 float TextColor[3]; 126 double SweepTime; 127 int DirtyFlag; 128 int ChangedFlag; 129 int CopyType, CopyNextFlag, CopyForced; 130 int NFrame { 0 }; 131 int HasMovie { 0 }; 132 std::shared_ptr<pymol::Image> Image { nullptr }; 133 int MovieFrameFlag; 134 double LastRender, RenderTime, LastFrameTime, LastFrameAdjust; 135 double LastSweep, LastSweepTime; 136 float LastSweepX, LastSweepY; 137 int RockFrame; 138 Picking LastPicked; 139 int StereoMode; 140 OrthoLineType vendor, renderer, version; 141 int SculptingFlag, SculptingSave; 142 int RovingDirtyFlag; 143 int RovingCleanupFlag; 144 double RovingLastUpdate; 145 int Threshold, ThresholdX, ThresholdY; 146 float LastPickVertex[3], LastClickVertex[3]; 147 int LastPickVertexFlag; 148 int LoopFlag; 149 int LoopMod; 150 BlockRect LoopRect; 151 CViewElem ani_elem[MAX_ANI_ELEM + 1]; 152 int cur_ani_elem, n_ani_elem; 153 int LastStateBuilt; 154 int AnimationStartFlag; 155 double AnimationStartTime; 156 double AnimationLagTime; 157 int AnimationStartFrame; 158 double ApproxRenderTime; 159 float VertexScale; 160 float FogStart; 161 float FogEnd; 162 163 /* Scene Names */ 164 int ButtonsShown, ButtonDrag, ButtonMargin, ButtonsValid; 165 int Over, Pressed, PressMode, HowFarDown, NSkip; 166 int ScrollBarActive; 167 int ReorderFlag; 168 OrthoLineType ReorderLog; 169 ScrollBar m_ScrollBar; 170 char *SceneNameVLA { nullptr }; 171 SceneElem *SceneVLA { nullptr }; 172 int NScene; 173 CGO *AlphaCGO { nullptr }; 174 175 int *SlotVLA { nullptr }; 176 177 int StencilValid, StencilParity; 178 int ReinterpolateFlag; 179 CObject *ReinterpolateObj { nullptr }; 180 CObject *MotionGrabbedObj { nullptr }; 181 182 short prev_no_z_rotation1, prev_no_z_rotation2; 183 int orig_x_rotation, orig_y_rotation; 184 185 std::vector<float> m_ModelViewMatrixStack; 186 int m_ModelViewMatrixStackDepth { 0 }; 187 188 union { 189 float ModelViewMatrix[16]; 190 float ModMatrix[16]; // old alias, deprecated 191 }; 192 193 float ProjectionMatrix[16]; 194 int background_color_already_set; 195 int do_not_clear; 196 GridInfo grid; 197 int last_grid_size; 198 int n_texture_refreshes { 0 }; 199 CGO *offscreenCGO { nullptr }; 200 CGO *offscreenOIT_CGO { nullptr }; 201 CGO *offscreenOIT_CGO_copy { nullptr }; 202 void (*vp_prepareViewPortForStereo)(PyMOLGlobals *, CScene *, int, short, int, int, int, int, int); 203 int vp_times, vp_x, vp_y, vp_owidth, vp_oheight, vp_stereo_mode; 204 float vp_width_scale; 205 PickColorManager pickmgr; 206 CScene(PyMOLGlobals * G)207 CScene(PyMOLGlobals * G) : Block(G), m_ScrollBar(G, false) {} 208 209 virtual int click(int button, int x, int y, int mod) override; 210 virtual int release(int button, int x, int y, int mod) override; 211 virtual int drag(int x, int y, int mod) override; 212 virtual void draw(CGO* orthoCGO) override; 213 virtual void reshape(int width, int height) override; 214 215 // PYMOL-2561, PYMOL-2711 : This structure used to be calloc-ed, this replicates that new(size_t size)216 void *operator new(size_t size) { 217 void *mem = ::operator new(size); 218 memset(mem, 0, size); 219 return mem; 220 } getSceneView()221 SceneView getSceneView() const { return m_view; } setSceneView(const SceneView & view)222 void setSceneView(const SceneView& view) { m_view = view; } 223 }; 224 225 #endif 226