better motif editor
[mussa.git] / qui / motif_editor / MotifElement.cpp
1 #include "qui/motif_editor/MotifEditor.hpp"
2
3 #include <iostream>
4
5 MotifElement::MotifElement() :
6   enabled(true),
7   color(Color(1.0,0.0,0.0,1.0)),
8   motif()
9 {
10 }
11
12 MotifElement::MotifElement(const Sequence& seq, Color c) :
13   enabled(true),
14   color(c),
15   motif(seq)
16 {
17 }
18
19 bool MotifElement::isEmpty() const
20 {
21   if (motif.get_name().size() == 0 and motif.size() == 0) {
22     return true;
23   }
24   return false;
25 }
26 //! should we search the analysis for this element?
27 bool MotifElement::isEnabled() const
28 {
29   return enabled;
30 }
31
32 //! set the state for searching the analysis for this element?
33 void MotifElement::setEnabled(bool enabled_)
34 {
35   enabled = enabled_;
36 }
37   
38 //! return color should this motif be drawn as
39 Color MotifElement::getColor() const
40 {
41   return color;
42 }
43
44 //! set what color this motif should be drawn as
45 void MotifElement::setColor(const Color& c)
46 {
47   color = c;
48 }
49   
50 //! return color should this motif be drawn as
51 QColor MotifElement::getQColor() const
52 {
53   QColor qcolor;
54   qcolor.setRgbF(color.r(), color.g(), color.b(), color.a());
55   return qcolor;
56 }
57
58 //! set what color this motif should be drawn as
59 void MotifElement::setQColor(const QColor& c)
60 {
61   color = Color(c.redF(), c.greenF(), c.blueF(), c.alphaF());
62 }
63   
64 //! return sequence
65 const Sequence& MotifElement::getSequence() const
66 {
67   return motif;
68 }
69
70 //! set sequence
71 void MotifElement::setSequence(const Sequence& seq)
72 {
73   motif = seq;
74 }
75
76 //! set sequence text
77 void MotifElement::setSequence(const std::string& seq_text)
78 {
79   motif.set_sequence(seq_text);
80 }
81
82 QString MotifElement::getSequenceText() const
83 {
84   return QString(motif.get_sequence().c_str());
85 }
86   
87 //! get sequence name
88 std::string MotifElement::getName() const
89 {
90   return motif.get_name();
91 }
92
93 //! set sequence name
94 void MotifElement::setName(const std::string& seq_name)
95 {
96   motif.set_fasta_header(seq_name);
97 }