IMP logo
IMP Reference Guide  2.20.0
The Integrative Modeling Platform
PymolWriter.h
Go to the documentation of this file.
1 /**
2  * \file IMP/display/PymolWriter.h
3  * \brief Write a CGO file with the geometry.
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPDISPLAY_PYMOL_WRITER_H
9 #define IMPDISPLAY_PYMOL_WRITER_H
10 
11 #include <IMP/display/display_config.h>
12 #include "writer_macros.h"
13 
14 #include <IMP/PairContainer.h>
15 #include <IMP/SingletonContainer.h>
16 #include <IMP/display/Writer.h>
17 
18 IMPDISPLAY_BEGIN_NAMESPACE
19 
20 //! Write a CGO file with the geometry
21 /** The CGO file format is a simple format for displaying geometry in Pymol.
22  The CGO writer supports points, spheres, cylinders, and segments.
23  The file name should end in ".pym".
24 
25  The geometry is assembled into objects in pymol based on the passed
26  names. For example, all geometry named "box" becomes one pymol object.
27  If many files are loaded into Python defining the same objects, they
28  become sequential frames in a movie. The frame numbers are determined
29  sequentially from the file load order (so they can form a subset of
30  the generated files).
31 
32  This writer will write many frames to the same file.
33  */
34 class IMPDISPLAYEXPORT PymolWriter : public TextWriter {
35  std::string lastname_;
36  int last_frame_;
37  enum Type {
38  NONE = 0,
39  LINES,
40  TRIANGLES,
41  OTHER
42  };
43  Type open_type_;
44  friend class CGOAnimationWriter;
45  void setup(std::string name, Type type, bool opendata = true);
46  void cleanup(std::string name, bool close = true);
47  bool handle_sphere(SphereGeometry *g, Color color,
48  std::string name) override;
49  bool handle_cylinder(CylinderGeometry *g, Color color,
50  std::string name) override;
51  bool handle_point(PointGeometry *g, Color color,
52  std::string name) override;
53  bool handle_segment(SegmentGeometry *g, Color color,
54  std::string name) override;
55  bool handle_polygon(PolygonGeometry *g, Color color,
56  std::string name) override;
57  bool handle_triangle(TriangleGeometry *g, Color color,
58  std::string name) override;
59  bool handle_label(LabelGeometry *g, Color color,
60  std::string name) override;
61  bool handle_surface(SurfaceMeshGeometry *g, Color color, std::string name);
62 
63  void do_set_frame() override;
64 
65  public:
67 };
68 
69 IMPDISPLAY_END_NAMESPACE
70 
71 #endif /* IMPDISPLAY_PYMOL_WRITER_H */
Represent an RGB color.
Definition: Color.h:25
A container for Singletons.
virtual void do_set_frame() override
in case you want to take action on a new frame
macros for display classes
A container for Pairs.
Base class for writing geometry to a file.
Write a CGO file with the geometry.
Definition: PymolWriter.h:34
#define IMP_TEXT_WRITER(Name)
Define information for an TextWriter object.
Definition: writer_macros.h:17
A text label for a ball in space.