1 2 /* 3 A* ------------------------------------------------------------------- 4 B* This file contains source code for the PyMOL computer program 5 C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific. 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_Scene 19 #define _H_Scene 20 21 #include"Base.h" 22 #include"PyMOLObject.h" 23 #include"Ortho.h" 24 #include"View.h" 25 #include"SceneDef.h" 26 #include"SceneRender.h" 27 #include"ShaderMgr.h" 28 #include"pymol/zstring_view.h" 29 30 #define SDOF_NORMAL_MODE 0 31 #define SDOF_CLIP_MODE 1 32 #define SDOF_DRAG_MODE 2 33 34 // TODO: define remaining cSceneRay_MODEs (VRML, COLLADA, etc.) 35 #define cSceneRay_MODE_IDTF 7 36 37 #define cSceneImage_Default -1 38 #define cSceneImage_Normal 0 39 #define cSceneImage_Draw 1 40 #define cSceneImage_Ray 2 41 42 #define cSceneViewSize 25 43 typedef float SceneViewType[cSceneViewSize]; 44 45 enum cSceneClip { 46 cSceneClip_invalid = -1, 47 cSceneClip_near = 0, 48 cSceneClip_far = 1, 49 cSceneClip_move = 2, 50 cSceneClip_slab = 3, 51 cSceneClip_atoms = 4, 52 }; 53 54 cSceneClip SceneClipGetEnum(pymol::zstring_view mode); 55 56 float SceneGetDynamicLineWidth(RenderInfo * info, float line_width); 57 void SceneInvalidateStencil(PyMOLGlobals * G); 58 int SceneHasImage(PyMOLGlobals * G); 59 int SceneInit(PyMOLGlobals * G); 60 void SceneUpdate(PyMOLGlobals * G, int force); 61 int SceneRenderCached(PyMOLGlobals * G); 62 int SceneSetFog(PyMOLGlobals *G); 63 void SceneSetFogUniforms(PyMOLGlobals * G, CShaderPrg *); 64 void SceneSetFrame(PyMOLGlobals * G, int mode, int frame); 65 int SceneGetFrame(PyMOLGlobals * G); 66 int SceneGetState(PyMOLGlobals * G); 67 int SceneGetButtonMargin(PyMOLGlobals * G); 68 69 void SceneDirty(PyMOLGlobals * G); /* scene dirty, but leave the overlay if one exists */ 70 void SceneInvalidate(PyMOLGlobals * G); /* scene dirty and remove the overlay */ 71 void SceneChanged(PyMOLGlobals * G); /* update 3D objects */ 72 73 int SceneCountFrames(PyMOLGlobals * G); 74 int SceneGetNFrame(PyMOLGlobals * G, int *has_movie=nullptr); 75 void SceneSetMatrix(PyMOLGlobals * G, float *); 76 float *SceneGetMatrix(PyMOLGlobals * G); 77 78 #define SceneGetModMatrix SceneGetModelViewMatrix 79 80 float *SceneGetPmvMatrix(PyMOLGlobals * G); 81 82 float SceneGetScreenVertexScale(PyMOLGlobals * G, const float *v1); 83 bool SceneGetVisible(PyMOLGlobals * G, const float *v1); 84 float SceneGetDepth(PyMOLGlobals * G, const float *v1); 85 float SceneGetRawDepth(PyMOLGlobals * G, const float *v1); 86 87 void SceneIdle(PyMOLGlobals * G); 88 void SceneFree(PyMOLGlobals * G); 89 90 int SceneGetDrawFlagGrid(PyMOLGlobals * G, GridInfo * grid, int slot); 91 int SceneDeferRay(PyMOLGlobals * G, 92 int ray_width, 93 int ray_height, 94 int mode, 95 float angle, float shift, int quiet, int show_timing, int antialias); 96 int SceneMakeMovieImage(PyMOLGlobals * G, 97 int show_timing, int validate, int mode, 98 int width=0, int height=0); 99 int SceneValidateImageMode(PyMOLGlobals * G, int mode, bool defaultdraw); 100 101 bool ScenePNG(PyMOLGlobals * G, const char *png, float dpi, int quiet, 102 int prior_only, int format); 103 int SceneCopyExternal(PyMOLGlobals * G, int width, int height, int rowbytes, 104 unsigned char *dest, int mode); 105 106 void SceneResetMatrix(PyMOLGlobals * G); 107 108 void SceneRestartFrameTimer(PyMOLGlobals * G); 109 110 void SceneGetEyeNormal(PyMOLGlobals * G, float *v1, float *normal); 111 112 void SceneRotate(PyMOLGlobals * G, float angle, float x, float y, float z); 113 void SceneTranslate(PyMOLGlobals * G, float x, float y, float z); 114 115 void SceneTranslateScaled(PyMOLGlobals * G, float x, float y, float z, int sdof_mode); 116 void SceneRotateScaled(PyMOLGlobals * G, float rx, float ry, float rz, int sdof_mode); 117 118 void SceneClip(PyMOLGlobals * G, int plane, float movement, const char *sele, int state); 119 std::pair<int, int> SceneGetImageSize(PyMOLGlobals * G); 120 float SceneGetGridAspectRatio(PyMOLGlobals * G); 121 void SceneScale(PyMOLGlobals * G, float scale); 122 void SceneResetNormalCGO(PyMOLGlobals * G, CGO *cgo, int lines); 123 void SceneResetNormal(PyMOLGlobals * G, int lines); 124 void SceneResetNormalUseShader(PyMOLGlobals * G, int lines, short use_shader); 125 void SceneResetNormalToViewVector(PyMOLGlobals * G, short use_shader); 126 void SceneResetNormalUseShaderAttribute(PyMOLGlobals * G, int lines, short use_shader, int attr); 127 void SceneGetResetNormal(PyMOLGlobals * G, float *normal, int lines); 128 129 int SceneObjectAdd(PyMOLGlobals * G, CObject * obj); 130 int SceneObjectDel(PyMOLGlobals * G, CObject * obj, int allow_purge); 131 int SceneObjectIsActive(PyMOLGlobals * G, CObject * obj); 132 void SceneOriginSet(PyMOLGlobals * G, const float *origin, int preserve); 133 void SceneOriginGet(PyMOLGlobals * G, float *origin); 134 void SceneWindowSphere(PyMOLGlobals * G, const float *location, float radius); 135 void SceneRelocate(PyMOLGlobals * G, const float *location); 136 Block *SceneGetBlock(PyMOLGlobals * G); 137 void SceneApplyMatrix(PyMOLGlobals * G, float *m); 138 void SceneSetStereo(PyMOLGlobals * G, bool flag); 139 int SceneGetStereo(PyMOLGlobals * G); 140 void SceneDontCopyNext(PyMOLGlobals * G); 141 void SceneGetViewNormal(PyMOLGlobals * G, float *v); 142 void SceneClipSet(PyMOLGlobals * G, float front, float back); 143 void SceneGetView(PyMOLGlobals * G, SceneViewType view); 144 void SceneSetView(PyMOLGlobals * G, const SceneViewType view, 145 int quiet, float animate, int hand); 146 void SceneRestartSweepTimer(PyMOLGlobals * G); 147 int SceneViewEqual(SceneViewType left, SceneViewType right); 148 void SceneToViewElem(PyMOLGlobals * G, CViewElem * elem, const char *scene_name); 149 void SceneFromViewElem(PyMOLGlobals * G, CViewElem * elem, int dirty); 150 void SceneGetCenter(PyMOLGlobals * G, float *pos); 151 void SceneGetWidthHeight(PyMOLGlobals * G, int *width, int *height); 152 void SceneGetWidthHeightStereo(PyMOLGlobals * G, int *width, int *height); 153 void SceneInvalidateCopy(PyMOLGlobals * G, int free_buffer); 154 155 void SceneSetCardInfo(PyMOLGlobals * G, const char *vendor, const char *renderer, const char *version); 156 void SceneGetCardInfo(PyMOLGlobals * G, char **vendor, char **renderer, char **version); 157 int SceneLoadPNG(PyMOLGlobals * G, const char *fname, int movie_flag, int stereo, int quiet); 158 159 void SceneSetDefaultView(PyMOLGlobals * G); 160 void SceneRovingDirty(PyMOLGlobals * G); 161 int SceneRovingCheckDirty(PyMOLGlobals * G); 162 void SceneRovingUpdate(PyMOLGlobals * G); 163 void SceneRovingChanged(PyMOLGlobals * G); 164 void SceneRovingPostpone(PyMOLGlobals * G); 165 int SceneReinitialize(PyMOLGlobals * G); 166 void SceneUpdateStereoMode(PyMOLGlobals * G); 167 void SceneSuppressMovieFrame(PyMOLGlobals * G); 168 int SceneDeferClick(Block * block, int button, int x, int y, int mod); 169 int SceneDeferDrag(Block * block, int x, int y, int mod); 170 int SceneDeferImage(PyMOLGlobals * G, int width, int height, const char *filename, 171 int antialias, float dpi, int format, int quiet); 172 const char *SceneGetSeleModeKeyword(PyMOLGlobals * G); 173 void SceneUpdateStereo(PyMOLGlobals * G); 174 float ScenePushRasterMatrix(PyMOLGlobals * G, float *v); 175 void ScenePopRasterMatrix(PyMOLGlobals * G); 176 void ScenePrimeAnimation(PyMOLGlobals * G); 177 void SceneLoadAnimation(PyMOLGlobals * G, double duration, int hand); 178 int SceneMustDrawBoth(PyMOLGlobals * G); 179 float SceneGetReflectScaleValue(PyMOLGlobals * G, int limit = 8); 180 float SceneGetSpecularValue(PyMOLGlobals * G, float spec, int limit = 8); 181 182 void SceneGetAdjustedLightValues(PyMOLGlobals * G, 183 float *ptr_spec, 184 float *ptr_spec_power, 185 float *ptr_spec_direct, 186 float *ptr_spec_direct_power, 187 int limit = 8); 188 189 void SceneAbortAnimation(PyMOLGlobals * G); 190 void SceneObjectUpdateThread(CObjectUpdateThreadInfo * T); 191 int SceneCaptureWindow(PyMOLGlobals * G); 192 193 void SceneZoom(PyMOLGlobals * G, float scale); 194 195 int SceneGetTwoSidedLighting(PyMOLGlobals * G); 196 int SceneGetTwoSidedLightingSettings(PyMOLGlobals * G, const CSetting *set1, const CSetting *set2); 197 198 float SceneGetLineWidthForCylinders(PyMOLGlobals * G, RenderInfo * info, float line_width); 199 float SceneGetLineWidthForCylindersStatic(PyMOLGlobals * G, RenderInfo * info, float dynamic_line_width_arg, float line_width); 200 201 void ScenePushModelViewMatrix(PyMOLGlobals * G); 202 void ScenePopModelViewMatrix(PyMOLGlobals * G, bool); 203 204 float *SceneGetModelViewMatrix(PyMOLGlobals * G); 205 float *SceneGetProjectionMatrix(PyMOLGlobals * G); 206 void SceneSetBackgroundColorAlreadySet(PyMOLGlobals * G, int); 207 int SceneGetBackgroundColorAlreadySet(PyMOLGlobals * G); 208 void SceneSetDoNotClearBackground(PyMOLGlobals * G, int); 209 int SceneGetDoNotClearBackground(PyMOLGlobals * G); 210 211 void SceneProgramLighting(PyMOLGlobals * G, CShaderPrg * shaderPrg = NULL); 212 void SceneGLClear(PyMOLGlobals * G, GLbitfield mask); 213 214 #ifdef _PYMOL_IOS 215 void SceneTranslateSceneXYWithScale(PyMOLGlobals * G, float x, float y); 216 int SceneIsTwisting(PyMOLGlobals * G); 217 #endif 218 219 void SceneUpdateAnimation(PyMOLGlobals * G); 220 221 void SceneSetupGLPicking(PyMOLGlobals * G); 222 223 int SceneDrawImageOverlay(PyMOLGlobals * G, int override ORTHOCGOARG); 224 225 int SceneIncrementTextureRefreshes(PyMOLGlobals * G); 226 227 void SceneResetTextureRefreshes(PyMOLGlobals * G); 228 229 void SceneGetScaledAxes(PyMOLGlobals * G, CObject *obj, float *xn, float *yn); 230 void SceneGetScaledAxesAtPoint(PyMOLGlobals * G, float *pt, float *xn, float *yn); 231 232 int SceneGetCopyType(PyMOLGlobals * G); 233 234 void SceneGenerateMatrixToAnotherZFromZ(PyMOLGlobals *G, float *convMatrix, float *curpt, float *pt); 235 void SceneAdjustZtoScreenZ(PyMOLGlobals *G, float *pos, float z); 236 float SceneGetCurrentBackSafe(PyMOLGlobals *G); 237 float SceneGetCurrentFrontSafe(PyMOLGlobals *G); 238 void SceneSetPointToWorldScreenRelative(PyMOLGlobals *G, float *pos, float *screenPt); 239 240 int StereoIsAdjacent(PyMOLGlobals * G); 241 242 int SceneGetGridSize(PyMOLGlobals * G, int grid_mode); 243 244 void GridUpdate(GridInfo * I, float asp_ratio, int mode, int size); 245 void GridGetRayViewport(GridInfo * I, int width, int height); 246 void GridSetRayViewport(GridInfo * I, int slot, int *x, int *y, int *width, 247 int *height); 248 int SceneGetDrawFlag(GridInfo * grid, int *slot_vla, int slot); 249 250 void SceneApplyImageGamma(PyMOLGlobals * G, unsigned int *buffer, int width, 251 int height); 252 void ScenePrepareUnitContext(SceneUnitContext * context, int width, int height); 253 254 float GetFovWidth(PyMOLGlobals * G); 255 256 void ScenePrepareMatrix(PyMOLGlobals * G, int mode, int stereo_mode = 0); 257 258 void SceneCopy(PyMOLGlobals * G, GLenum buffer, int force, int entire_window); 259 260 // FIXME use pymol matrices 261 void SceneGetModel2WorldMatrix(PyMOLGlobals * G, float *matrix); 262 void SceneSetModel2WorldMatrix(PyMOLGlobals * G, float const *matrix); 263 float SceneGetScale(PyMOLGlobals * G); 264 265 void ScenePickAtomInWorld(PyMOLGlobals * G, int x, int y, float *atomWorldPos); 266 267 void SceneInvalidatePicking(PyMOLGlobals * G); 268 269 pymol::Image* SceneImagePrepare(PyMOLGlobals * G, bool prior_only); 270 271 #endif 272 273