better motif editor
[mussa.git] / qui / motif_editor / MotifElement.cpp
diff --git a/qui/motif_editor/MotifElement.cpp b/qui/motif_editor/MotifElement.cpp
new file mode 100644 (file)
index 0000000..5bbda0e
--- /dev/null
@@ -0,0 +1,97 @@
+#include "qui/motif_editor/MotifEditor.hpp"
+
+#include <iostream>
+
+MotifElement::MotifElement() :
+  enabled(true),
+  color(Color(1.0,0.0,0.0,1.0)),
+  motif()
+{
+}
+
+MotifElement::MotifElement(const Sequence& seq, Color c) :
+  enabled(true),
+  color(c),
+  motif(seq)
+{
+}
+
+bool MotifElement::isEmpty() const
+{
+  if (motif.get_name().size() == 0 and motif.size() == 0) {
+    return true;
+  }
+  return false;
+}
+//! should we search the analysis for this element?
+bool MotifElement::isEnabled() const
+{
+  return enabled;
+}
+
+//! set the state for searching the analysis for this element?
+void MotifElement::setEnabled(bool enabled_)
+{
+  enabled = enabled_;
+}
+  
+//! return color should this motif be drawn as
+Color MotifElement::getColor() const
+{
+  return color;
+}
+
+//! set what color this motif should be drawn as
+void MotifElement::setColor(const Color& c)
+{
+  color = c;
+}
+  
+//! return color should this motif be drawn as
+QColor MotifElement::getQColor() const
+{
+  QColor qcolor;
+  qcolor.setRgbF(color.r(), color.g(), color.b(), color.a());
+  return qcolor;
+}
+
+//! set what color this motif should be drawn as
+void MotifElement::setQColor(const QColor& c)
+{
+  color = Color(c.redF(), c.greenF(), c.blueF(), c.alphaF());
+}
+  
+//! return sequence
+const Sequence& MotifElement::getSequence() const
+{
+  return motif;
+}
+
+//! set sequence
+void MotifElement::setSequence(const Sequence& seq)
+{
+  motif = seq;
+}
+
+//! set sequence text
+void MotifElement::setSequence(const std::string& seq_text)
+{
+  motif.set_sequence(seq_text);
+}
+
+QString MotifElement::getSequenceText() const
+{
+  return QString(motif.get_sequence().c_str());
+}
+  
+//! get sequence name
+std::string MotifElement::getName() const
+{
+  return motif.get_name();
+}
+
+//! set sequence name
+void MotifElement::setName(const std::string& seq_name)
+{
+  motif.set_fasta_header(seq_name);
+}
\ No newline at end of file