IMP  2.0.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_BEGIN_NAMESPACE
19 
20 #if IMP_HAS_DEPRECATED
21 //! Write a Bild file with the geometry
22 /** The bild file format is a simple format for displaying geometry in Chimera.
23  The bild writer supports points, spheres, cyliners, and segments.
24 
25  \deprecated Use IMP::rmf when interfacing with Chimera.
26  */
27 class IMPDISPLAYEXPORT BildWriter: public TextWriter
28 {
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())
35  << "\n";
36  return true;
37  }
38  bool handle_segment(SegmentGeometry *g, Color color, std::string) {
39  handle(color);
40  get_stream() << ".move "
41  << algebra::spaces_io(g->get_geometry().get_point(0)) << "\n";
42  get_stream() << ".draw "
43  << algebra::spaces_io(g->get_geometry().get_point(1))
44  << "\n";
45  return true;
46  }
47  bool handle_polygon(PolygonGeometry *g, Color color, std::string) {
48  handle(color);
49  get_stream() << ".polygon ";
50  for (unsigned int i=0; i< g->get_geometry().size(); ++i) {
51  get_stream() << " " << algebra::spaces_io(g->get_geometry().at(i));
52  }
53  get_stream() << "\n";
54  return true;
55  }
56  bool handle_triangle(TriangleGeometry *g, Color color, std::string) {
57  handle(color);
58  get_stream() << ".polygon ";
59  for (unsigned int i=0; i< 3; ++i) {
60  get_stream() << " " << algebra::spaces_io(g->get_geometry().get_point(i));
61  }
62  get_stream() << "\n";
63  return true;
64  }
65  bool handle_sphere(SphereGeometry *g, Color color, std::string) {
66  handle(color);
67  get_stream() << ".sphere "
68  << algebra::spaces_io(g->get_geometry().get_center()) << " "
69  << g->get_geometry().get_radius() << "\n";
70  return true;
71  }
72  bool handle_cylinder(CylinderGeometry *g, Color color, std::string) {
73  handle(color);
74  get_stream() << ".cylinder "
75  << algebra::spaces_io(g->get_geometry()
76  .get_segment().get_point(0))
77  << " "
78  << algebra::spaces_io(g->get_geometry()
79  .get_segment().get_point(1)) << " "
80  << g->get_geometry().get_radius() << "\n";
81  return true;
82  }
83 public:
84 
86 };
87 #endif
88 
89 
90 IMPDISPLAY_END_NAMESPACE
91 
92 #endif /* IMPDISPLAY_BILD_WRITER_H */