IMP  2.1.0
The Integrative Modeling Platform
BildWriter.h
Go to the documentation of this file.
1 /**
2  * \file IMP/display/BildWriter.h
3  * \brief Writer for the Chimera BILD file format.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPDISPLAY_BILD_WRITER_H
9 #define IMPDISPLAY_BILD_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_DEPRECATED_HEADER(2.1, "Use IMP.rmf")
19 
20 IMPDISPLAY_BEGIN_NAMESPACE
21 
22 //! Write a Bild file with the geometry
23 /** The bild file format is a simple format for displaying geometry in Chimera.
24  The bild writer supports points, spheres, cyliners, and segments.
25 
26  \deprecated_at{2.1} Use IMP::rmf when interfacing with Chimera.
27  */
28 class IMPDISPLAYEXPORT BildWriter : public TextWriter {
29  void handle(Color color) {
30  get_stream() << ".color " << SpacesIO(color) << "\n";
31  }
32  bool handle_point(PointGeometry *g, Color color, std::string) {
33  handle(color);
34  get_stream() << ".dotat " << algebra::spaces_io(g->get_geometry()) << "\n";
35  return true;
36  }
37  bool handle_segment(SegmentGeometry *g, Color color, std::string) {
38  handle(color);
39  get_stream() << ".move "
40  << algebra::spaces_io(g->get_geometry().get_point(0)) << "\n";
41  get_stream() << ".draw "
42  << algebra::spaces_io(g->get_geometry().get_point(1)) << "\n";
43  return true;
44  }
45  bool handle_polygon(PolygonGeometry *g, Color color, std::string) {
46  handle(color);
47  get_stream() << ".polygon ";
48  for (unsigned int i = 0; i < g->get_geometry().size(); ++i) {
49  get_stream() << " " << algebra::spaces_io(g->get_geometry().at(i));
50  }
51  get_stream() << "\n";
52  return true;
53  }
54  bool handle_triangle(TriangleGeometry *g, Color color, std::string) {
55  handle(color);
56  get_stream() << ".polygon ";
57  for (unsigned int i = 0; i < 3; ++i) {
58  get_stream() << " " << algebra::spaces_io(g->get_geometry().get_point(i));
59  }
60  get_stream() << "\n";
61  return true;
62  }
63  bool handle_sphere(SphereGeometry *g, Color color, std::string) {
64  handle(color);
65  get_stream() << ".sphere "
66  << algebra::spaces_io(g->get_geometry().get_center()) << " "
67  << g->get_geometry().get_radius() << "\n";
68  return true;
69  }
70  bool handle_cylinder(CylinderGeometry *g, Color color, std::string) {
71  handle(color);
72  get_stream() << ".cylinder "
73  << algebra::spaces_io(
74  g->get_geometry().get_segment().get_point(0)) << " "
75  << algebra::spaces_io(
76  g->get_geometry().get_segment().get_point(1)) << " "
77  << g->get_geometry().get_radius() << "\n";
78  return true;
79  }
80 
81  public:
82  IMPDISPLAY_DEPRECATED_OBJECT_DECL(2.1)
84 };
85 
86 IMPDISPLAY_END_NAMESPACE
87 
88 #endif /* IMPDISPLAY_BILD_WRITER_H */
Represent an RGB color.
Definition: Color.h:24
Import IMP/kernel/SingletonContainer.h in the namespace.
macros for display classes
Import IMP/kernel/PairContainer.h in the namespace.
Write a Bild file with the geometry.
Definition: BildWriter.h:28
Base class for writing geometry to a file.
const Vector3D & get_point(unsigned int i) const
Get the start=0/end=1 point of the segment.
Definition: Triangle3D.h:29
#define IMP_TEXT_WRITER(Name)
Define information for an TextWriter object.
Definition: writer_macros.h:16
const Vector3D & get_point(unsigned int i) const
Get the start=0/end=1 point of the segment.
Definition: Segment3D.h:28