libsbml-draw
arrowhead.h
Go to the documentation of this file.
1 //== FILEDOC =========================================================================
2 
11 //== BEGINNING OF CODE ===============================================================
12 
13 #ifndef __SBNW_LAYOUT_ARROWHEAD_H_
14 #define __SBNW_LAYOUT_ARROWHEAD_H_
15 
16 //== INCLUDES ========================================================================
17 
18 #include "SagittariusCore.h"
19 #include "point.h"
20 #include "transform.h"
21 
22 //-- C++ code --
23 #ifdef __cplusplus
24 
25 #include <string>
26 
27 #include <iostream>
28 
29 namespace LibsbmlDraw {
30 
31  typedef int ArrowheadStyle;
32 
34  class Arrowhead {
35  public:
36  virtual ~Arrowhead() {}
37 
38  virtual unsigned long getNumVerts() const = 0;
39  virtual Point getVert(unsigned long n) const = 0;
40 
41  Point getTransformedVert(unsigned long n) const {
42  return tf_*getVert(n);
43  }
44 
45  Affine2d getTransform() const { return tf_; }
46 
47  void setTransform(const Affine2d& tf, bool recurse = true) { tf_ = tf; }
48 
49  Affine2d getInverseTransform() const { return itf_; }
50 
51  void setInverseTransform(const Affine2d& itf, bool recurse = true) { itf_ = itf; }
52 
53  protected:
55  Affine2d tf_;
57  Affine2d itf_;
58 
59  };
60 
61  class PlainArrowhead : public Arrowhead {
62  public:
63  virtual unsigned long getNumVerts() const {
64  return 3;
65  }
66 
67  virtual Point getVert(unsigned long n) const {
68  switch (n) {
69  case 0:
70  return Point(0, 1);
71  case 1:
72  return Point(1, 0);
73  case 2:
74  return Point(-1, 0);
75  default:
76  SBNW_THROW(InvalidParameterException, "Index out of range", "Arrowhead::getVert");
77  }
78  }
79 
80  };
81 
82  class SubstrateArrowhead : public Arrowhead {
83  public:
84  virtual unsigned long getNumVerts() const;
85 
86  virtual Point getVert(unsigned long n) const;
87  };
88 
89  class ProductArrowhead : public Arrowhead {
90  public:
91  virtual unsigned long getNumVerts() const;
92 
93  virtual Point getVert(unsigned long n) const;
94  };
95 
96  class ActivatorArrowhead : public Arrowhead {
97  public:
98  virtual unsigned long getNumVerts() const;
99 
100  virtual Point getVert(unsigned long n) const;
101  };
102 
103  class InhibitorArrowhead : public Arrowhead {
104  public:
105  virtual unsigned long getNumVerts() const;
106 
107  virtual Point getVert(unsigned long n) const;
108  };
109 
110  class ModifierArrowhead : public Arrowhead {
111  public:
112  virtual unsigned long getNumVerts() const;
113 
114  virtual Point getVert(unsigned long n) const;
115  };
116 
117  class ArrowheadStyles {
118  public:
119  static unsigned long count();
120 
121  static bool isFilled(ArrowheadStyle style);
122 
123  static unsigned long getNumVerts(ArrowheadStyle style);
124 
125  static Point getVert(ArrowheadStyle style, int n);
126 
127  };
128 
129  extern ArrowheadStyle sub_arrow_style_;
130  inline ArrowheadStyle ArrowheadStyleLookup(const SubstrateArrowhead* ) {
131  return sub_arrow_style_;
132  }
133 
134  extern ArrowheadStyle prod_arrow_style_;
135  inline ArrowheadStyle ArrowheadStyleLookup(const ProductArrowhead* ) {
136  return prod_arrow_style_;
137  }
138 
139  extern ArrowheadStyle act_arrow_style_;
140  inline ArrowheadStyle ArrowheadStyleLookup(const ActivatorArrowhead* ) {
141  return act_arrow_style_;
142  }
143 //
144  extern ArrowheadStyle inh_arrow_style_;
145  inline ArrowheadStyle ArrowheadStyleLookup(const InhibitorArrowhead* ) {
146  return inh_arrow_style_;
147  }
148 //
149  extern ArrowheadStyle mod_arrow_style_;
150  inline ArrowheadStyle ArrowheadStyleLookup(const ModifierArrowhead* ) {
151  return mod_arrow_style_;
152  }
153 
154  // set arrowhead style based on type
155  template<typename ArrowheadT>
156  class ArrowheadStyleControl {
157  public:
158  };
159 
160  template<>
161  class ArrowheadStyleControl<SubstrateArrowhead> {
162  public:
163  static void set(ArrowheadStyle val) {
164 // std::cerr << "libsbml_draw: set style for substrate arrowhead\n";
165  sub_arrow_style_ = val;
166  }
167 
168  static ArrowheadStyle get() {
169  return sub_arrow_style_;
170  }
171  };
172 
173  template<>
174  class ArrowheadStyleControl<ProductArrowhead> {
175  public:
176  static void set(ArrowheadStyle val) {
177 // std::cerr << "libsbml_draw: set style for product arrowhead\n";
178  prod_arrow_style_ = val;
179  }
180 
181  static ArrowheadStyle get() {
182  return prod_arrow_style_;
183  }
184  };
185 
186  template<>
187  class ArrowheadStyleControl<ActivatorArrowhead> {
188  public:
189  static void set(ArrowheadStyle val) {
190 // std::cerr << "libsbml_draw: set style for activator arrowhead\n";
191  act_arrow_style_ = val;
192  }
193 
194  static ArrowheadStyle get() {
195  return act_arrow_style_;
196  }
197  };
198 
199  template<>
200  class ArrowheadStyleControl<InhibitorArrowhead> {
201  public:
202  static void set(ArrowheadStyle val) {
203 // std::cerr << "libsbml_draw: set style for inhibitor arrowhead\n";
204  inh_arrow_style_ = val;
205  }
206 
207  static ArrowheadStyle get() {
208  return inh_arrow_style_;
209  }
210  };
211 
212  template<>
213  class ArrowheadStyleControl<ModifierArrowhead> {
214  public:
215  static void set(ArrowheadStyle val) {
216 // std::cerr << "libsbml_draw: set style for modifier arrowhead\n";
217  mod_arrow_style_ = val;
218  }
219 
220  static ArrowheadStyle get() {
221  return mod_arrow_style_;
222  }
223  };
224 
225 }
226 
227 #endif
228 
229 #endif
First file included.
Roots of cubic equations.