root/trunk/FRII/gui/HorizontalSequenceView.hh

Revision 10, 3.1 kB (checked in by t, 3 years ago)

Tailorization
Import of the upstream sources from

Repository: :pserver:anonymous@cvs.sf.net:/cvsroot/familyjewels

Kind: cvs

Module: FRII

Revision: 2005-12-09 09:00:54 by titus

Original author: tailor@vallista.idyll.org
Date: 2005-12-09 09:00:54

Line 
1 /*
2  * This file is part of the FamilyRelations II source distribution.
3  *
4  * FamilyRelations II is part of the FamilyJewels package for comparative
5  * sequence analysis: http://family.caltech.edu/.
6  *
7  * Contact author: C. Titus Brown, titus@caltech.edu.
8  *
9  * This program and all associated source code files are Copyright (C) 2003,
10  * 2004 the California Institute of Technology, Pasadena, CA, 91125 USA.  It
11  * is under the Lesser GNU Public License; please see the included
12  * LICENSE.txt file for more information, or contact Titus directly.
13  *
14  */
15
16 // A (horizontal) sequence-view class that draws a sequence line, tick marks,
17 // and features on the sequence.
18
19 #ifndef HORIZONTAL_SEQUENCE_VIEW_HH
20 #define HORIZONTAL_SEQUENCE_VIEW_HH
21
22 #include <FL/Fl.H>
23 #include <FL/Fl_Window.H>
24 #include <FL/Fl_Box.H>
25 #include <FL/fl_draw.H>
26
27 #include "SequenceView.hh"
28
29 namespace gui {
30   class HorizontalSequenceView : public SequenceView {
31   protected:
32     //
33     // customizable in subclasses
34     //
35
36     // size of the border on either side of the sequence line
37     const static unsigned int border = 60;
38
39     // thickness of the sequence line
40     const static unsigned int line_thickness = 6;
41
42     // height of tick marks / 2
43     const static unsigned int half_tick_height = 5;
44
45     // thickness of the line used to draw ticks
46     const static unsigned int tick_thickness = 2;
47
48     // half the size of the text label
49     const static unsigned int half_label_height = 6;
50
51     // the width of the text label
52     const static unsigned int label_width = border - 2;
53
54     // drawing stuff
55     void draw();
56     void draw_ticks();
57     void draw_ticks_at_spacing(int);
58     void draw_labels();
59     void draw_selection_box();
60     void draw_features();
61     bool _show_sequence_line;
62
63     // Specific event handler
64     virtual int handle(int e);
65
66     // internal access to some of the drawing information.
67     unsigned int get_left(), get_width(), get_mid();
68   public:
69     // constructor with only sequence length.
70     HorizontalSequenceView(int x, int y,
71                            unsigned int width, unsigned int seq_len) :
72       SequenceView(x, y, width, height, seq_len) {
73       _show_sequence_line = true;
74     };
75
76     // constructor with sequence, too.
77     HorizontalSequenceView(int x, int y, unsigned int width,
78                            std::string seq_name, std::string seq) :
79       SequenceView(x, y, width, height, seq.length()) {
80       _sequence_name = seq_name;
81       _sequence_text = seq;
82       _show_sequence_line = true;
83     };
84
85     // public access to the height; this must sometimes be used by groups,
86     // before the sequence is instantiated, which is why it's a static
87     // variable by default.
88     const static unsigned int height = 20;
89     virtual void h(unsigned int _h) { SequenceView::h(_h); }
90     virtual unsigned int h() { return SequenceView::h(); }
91
92     // coordinate stuff
93     unsigned int base_to_pos(int base);
94     unsigned int pos_to_base(int pos);
95
96     // display info: draw lines/ticks?
97     void show_sequence_line(bool s) { _show_sequence_line = s; }
98     bool show_sequence_line() { return _show_sequence_line; }
99   };
100 }
101
102 #endif // HORIZONTAL_SEQUENCE_VIEW_HH
103
Note: See TracBrowser for help on using the browser.