14 #ifndef _GLIBCXX_IOSFWD
18 #ifndef AW_FONT_GROUP_HXX
22 #ifndef SEC_ABSPOS_HXX
31 #ifndef SECEDIT_EXTERN_HXX
37 #ifndef ARB_GLOBAL_DEFS_H
43 #define DATA_VERSION 3
54 #define CHECK_INTEGRITY // check structure integrity after changes
55 #define PAINT_ABSOLUTE_POSITION // paint some positions near center (range = 0..len-1)
59 #ifdef CHECK_INTEGRITY
64 CHECK_ALL = CHECK_STRUCTURE|CHECK_SIZE|CHECK_POSITIONS,
76 int sequence_start, sequence_end;
82 #if defined(ASSERTION_USED)
83 int abspos_array_size;
84 #endif // ASSERTION_USED
86 void create_abspos_array(
const int *static_array);
88 void set_base_count(
int bc) {
100 void save(std::ostream & out,
int indent,
const XString& x_string);
104 void invalidate_base_count();
113 if (sequence_end<sequence_start) {
114 return pos<sequence_end || sequence_start <= pos;
116 return sequence_start <= pos && pos < sequence_end;
120 sequence_start =
start;
122 invalidate_base_count();
124 void generate_x_string(
XString& x_string);
132 if (basenr >= 0 && basenr<get_base_count()) {
136 pos = abspos_array[basenr];
142 pos = (basenr == 0) ? get_sequence_start() : get_sequence_end();
147 #if defined(CHECK_INTEGRITY)
148 void check_integrity(
const SEC_root *root, SEC_CHECK_TYPE what)
const;
149 #endif // CHECK_INTEGRITY
160 void refreshDrawnSize() { dSize = (sSize<Min && Min>0) ? Min : ((sSize>Max && Max>0) ? Max : sSize); }
174 if (Min>Max) Max = 0;
177 else if (sSize > size) {
179 if (Max<Min) Min = 0;
183 #if defined(DEBUG) && 0
184 printf(
"setDrawnSize(%.2f) -> sSize=%.2f dSize=%.2f Min=%.2f Max=%.2f\n", size, sSize, dSize, Min, Max);
208 mutable Angle abs_angle;
209 mutable bool abs_angle_valid;
211 const Angle& calc_abs_angle()
const;
212 const Angle& calc_rel_angle();
219 virtual void invalidate_sub_angles() = 0;
227 abs_angle_valid =
false;
228 invalidate_sub_angles();
231 if (abs_angle_valid) {
241 invalidate_sub_angles();
276 virtual const Position& get_fixpoint()
const = 0;
277 virtual void reset_angles() = 0;
279 virtual void orientationChanged() = 0;
280 virtual void sizeChanged() = 0;
308 size_t getNextAbspos()
const;
315 class SEC_helix_strand;
320 SEC_helix_strand *strand_to_root;
326 SEC_helix(
SEC_root *root, SEC_helix_strand *to_root, SEC_helix_strand *from_root);
329 void calculate_helix_size();
330 void calculate_helix_coordinates();
332 void save(std::ostream & out,
int indent,
const XString& x_string);
333 GB_ERROR read(std::istream & in,
int version,
double& old_angle_in);
338 SEC_helix_strand *strandToOutside()
const;
340 SEC_helix_strand *strandAwayFrom(
const SEC_loop *loop)
const;
341 SEC_helix_strand *strandTowards(
const SEC_loop *loop)
const;
343 SEC_loop *otherLoop(
const SEC_loop *loop)
const;
344 SEC_loop *rootsideLoop()
const;
345 SEC_loop *outsideLoop()
const;
347 bool hasLoop(SEC_loop *loop)
const {
return loop == rootsideLoop() || loop == outsideLoop(); }
353 void fixAngleBugs(
int version);
355 #if defined(CHECK_INTEGRITY)
356 void check_integrity(SEC_CHECK_TYPE what)
const;
357 #endif // CHECK_INTEGRITY
360 void invalidate_sub_angles()
OVERRIDE;
367 void orientationChanged() OVERRIDE;
368 void sizeChanged() OVERRIDE;
377 friend class SEC_helix;
379 SEC_loop *origin_loop;
380 SEC_helix_strand *other_strand;
381 SEC_helix *helix_info;
382 SEC_segment *next_segment;
389 void set_helix_info(SEC_helix *helix_info_) { helix_info = helix_info_; }
390 void set_other_strand(SEC_helix_strand *other_strand_) { other_strand = other_strand_; }
393 SEC_base *get_parent() OVERRIDE {
return helix_info; }
394 SEC_base_part *get_next() OVERRIDE;
399 ~SEC_helix_strand() OVERRIDE;
401 GB_ERROR read(SEC_loop *loop_,
std::istream & in,
int version);
404 void unlink(
bool fromOtherStrandAsWell);
406 void paint_strands(
AW_device *device, const
Vector& strand_dir, const
double& strand_length);
407 void paint_constraints(
AW_device *device);
409 const
SEC_root *get_root()
const {
return helix_info->get_root(); }
412 const SEC_helix *
get_helix()
const {
return helix_info; }
426 bool is3end()
const {
return get_region()->get_sequence_start() > other_strand->get_region()->get_sequence_start(); }
436 const SEC_region *reg = get_other_strand()->get_region();
453 SEC_segment * get_previous_segment();
459 SEC_loop *
get_rootside_loop() {
return isRootsideFixpoint() ? get_origin_loop() : get_destination_loop(); }
464 #if defined(CHECK_INTEGRITY)
465 void check_integrity(SEC_CHECK_TYPE what)
const;
466 #endif // CHECK_INTEGRITY
480 SEC_helix_strand *next_helix_strand;
493 GB_ERROR read(SEC_loop *loop_,
std::istream & in,
int version);
495 void calculate_segment_size();
498 void paint(
AW_device *device, SEC_helix_strand *previous_strand_pointer);
501 void prepare_paint(SEC_helix_strand *previous_strand_pointer,
double &gamma,
double &eta,
double &radius,
int &base_count,
double &angle_step);
503 void mergeWith(SEC_segment *other, SEC_loop *target_loop);
504 SEC_helix_strand *split(
size_t start,
size_t end, SEC_segment **new_segment);
507 int is_endings_segment() {
508 int seq_start = get_region()->get_sequence_start();
509 int seq_end = get_region()->get_sequence_end();
511 return seq_start>seq_end;
515 SEC_segment *segment =
this;
517 SEC_helix_strand *next_strand = segment->next_helix_strand;
519 if (!next_strand)
break;
520 if (next_strand == strand) { segment->next_helix_strand =
NULp;
break; }
522 segment = next_strand->get_next_segment();
523 if (!segment || segment==
this) {
525 printf(
"SEC_segment %p did not contain pointer to SEC_helix_strand %p\n",
this, strand);
532 SEC_helix_strand *get_previous_strand();
545 #if defined(CHECK_INTEGRITY)
546 void check_integrity(SEC_CHECK_TYPE what)
const;
547 #endif // CHECK_INTEGRITY
554 double Circumference;
556 SEC_helix_strand *primary_strand;
560 void compute_circumference();
561 void compute_radius();
571 GB_ERROR read(SEC_helix_strand *rootside_strand,
std::istream & in,
int version,
double loop_angle);
573 void calculate_loop_size();
574 void calculate_loop_coordinates();
577 void paint_constraints(
AW_device *device);
579 const
Position& get_center()
const {
return center; }
582 bool is_root_loop()
const;
591 void toggle_root(SEC_loop *root_loop);
595 void fixAngleBugs(
int version);
597 #if defined(CHECK_INTEGRITY)
598 void check_integrity(SEC_CHECK_TYPE what)
const;
599 #endif // CHECK_INTEGRITY
602 void invalidate_sub_angles()
OVERRIDE;
610 SEC_helix *helix = get_fixpoint_helix();
611 return helix->strandAwayFrom(
this)->get_fixpoint();
699 double skelThickWorld;
700 double bondThickWorld;
717 void paintHelixNumbers(
AW_device *device);
718 void paintEcoliPositions(
AW_device *device);
719 #if defined(PAINT_ABSOLUTE_POSITION)
720 void showSomeAbsolutePositions(
AW_device *device);
722 void fixStructureBugs(
int version);
724 void cacheBackgroundColor();
726 static bool hasBase(
int pos,
const char *
seq,
int len) {
734 void delete_root_loop() { SEC_loop *old_root_loop = root_loop; root_loop =
NULp;
delete old_root_loop; }
735 void delete_announced_positions();
755 const char *
helixNrAt(
int abspos)
const {
return get_helixDef()->helixNr(abspos); }
757 const size_t *getHelixPositions(
const char *helixNr)
const;
769 #if defined(CHECK_INTEGRITY)
770 void check_integrity(SEC_CHECK_TYPE what)
const;
771 #endif // CHECK_INTEGRITY
778 char *buildStructureString();
779 GB_ERROR read_data(
const char *input_string,
const char *x_string_in);
781 void add_autoscroll(
const Vector& scroll);
782 void nail_position(
size_t absPos);
784 void position_cursor(
bool toCenter,
bool evenIfVisible);
785 void set_cursor(
int abspos);
787 bool perform_autoscroll();
790 void calculate_size();
791 void calculate_coordinates();
794 #if defined(CHECK_INTEGRITY)
795 void recalc() { check_integrity(static_cast<SEC_CHECK_TYPE>(CHECK_STRUCTURE|CHECK_SIZE));
796 calculate_coordinates(); check_integrity(CHECK_POSITIONS);
798 void relayout() { check_integrity(CHECK_STRUCTURE);
799 calculate_size(); check_integrity(CHECK_SIZE);
800 calculate_coordinates(); check_integrity(CHECK_POSITIONS);
804 calculate_coordinates();
808 calculate_coordinates();
812 GB_ERROR split_loop(
int start1,
int end1,
int start2,
int end2);
815 GB_ERROR unsplit_loop(SEC_helix_strand *delete_strand);
816 void set_root(SEC_loop *loop);
817 void create_default_bone();
818 void generate_x_string();
820 void update_shown_positions();
822 void invalidate_base_positions();
827 return center_char[gc];
831 size_t len = db->
length();
850 void announce_base_position(
int base_pos,
const Position& draw_pos);
851 void clear_announced_positions();
857 void paintAnnotation(
AW_device *device,
int gc,
859 double noteDistance,
const char *text,
860 bool lineToAnnotated,
bool linesToLeftRight,
bool boxText);
863 void paintPosAnnotation(
AW_device *device,
int gc,
size_t absPos,
const char *text,
bool lineToBase,
bool boxText);
872 inline void SEC_helix::flip() {
873 strand_to_root = strand_to_root->get_other_strand();
876 inline SEC_helix_strand *SEC_helix::strandToOutside()
const {
877 return strandToRoot()->get_other_strand();
880 inline SEC_helix_strand *SEC_helix::strandAwayFrom(
const SEC_loop *loop)
const {
881 if (strandToRoot()->get_origin_loop() == loop) {
882 return strandToRoot();
884 sec_assert(strandToOutside()->get_origin_loop() == loop);
885 return strandToOutside();
888 inline SEC_helix_strand *SEC_helix::strandTowards(
const SEC_loop *loop)
const {
889 return strandAwayFrom(loop)->get_other_strand();
892 inline SEC_loop *SEC_helix::otherLoop(
const SEC_loop *loop)
const {
893 return strandTowards(loop)->get_origin_loop();
896 inline SEC_loop *SEC_helix::rootsideLoop()
const {
return strandToOutside()->get_origin_loop(); }
897 inline SEC_loop *SEC_helix::outsideLoop()
const {
return strandToRoot()->get_origin_loop(); }
899 inline const Position& SEC_helix::get_fixpoint()
const {
return strandToOutside()->get_fixpoint(); }
901 inline void SEC_helix::setFixpoints(
const Position& rootside,
const Position& outside) {
902 strandToRoot()->setFixpoint(outside);
903 strandToOutside()->setFixpoint(rootside);
906 inline void SEC_helix::orientationChanged() {
910 SEC_loop *loop = rootsideLoop();
912 if (loop->is_root_loop()) {
915 get_root()->recalc();
918 #if defined(CHECK_INTEGRITY)
919 loop->check_integrity(CHECK_STRUCTURE);
920 loop->check_integrity(CHECK_SIZE);
921 #endif // CHECK_INTEGRITY
922 loop->calculate_loop_coordinates();
923 #if defined(CHECK_INTEGRITY)
924 loop->check_integrity(CHECK_POSITIONS);
925 #endif // CHECK_INTEGRITY
928 inline void SEC_helix::sizeChanged() {
929 #if defined(CHECK_INTEGRITY)
930 check_integrity(CHECK_STRUCTURE);
931 #endif // CHECK_INTEGRITY
932 calculate_helix_size();
933 #if defined(CHECK_INTEGRITY)
934 check_integrity(CHECK_SIZE);
935 #endif // CHECK_INTEGRITY
936 calculate_helix_coordinates();
937 #if defined(CHECK_INTEGRITY)
938 check_integrity(CHECK_POSITIONS);
939 #endif // CHECK_INTEGRITY
942 inline SEC_base *SEC_helix::get_parent() {
return rootsideLoop(); }
946 inline SEC_base_part *SEC_helix_strand::get_next() {
return get_other_strand()->get_next_segment(); }
950 inline bool SEC_loop::is_root_loop()
const {
return get_root()->get_root_loop() ==
this; }
952 inline void SEC_loop::orientationChanged() {
953 if (is_root_loop()) {
954 get_root()->recalc();
959 SEC_helix *helix = get_fixpoint_helix();
960 #if defined(CHECK_INTEGRITY)
961 helix->check_integrity(CHECK_STRUCTURE);
962 helix->check_integrity(CHECK_SIZE);
963 #endif // CHECK_INTEGRITY
964 helix->calculate_helix_coordinates();
965 #if defined(CHECK_INTEGRITY)
966 helix->check_integrity(CHECK_POSITIONS);
967 #endif // CHECK_INTEGRITY
970 inline void SEC_loop::sizeChanged() {
971 if (is_root_loop()) {
972 get_root()->relayout();
975 SEC_helix *helix = get_fixpoint_helix();
976 #if defined(CHECK_INTEGRITY)
977 helix->check_integrity(CHECK_STRUCTURE);
978 #endif // CHECK_INTEGRITY
979 helix->calculate_helix_size();
980 #if defined(CHECK_INTEGRITY)
981 helix->check_integrity(CHECK_SIZE);
982 #endif // CHECK_INTEGRITY
983 helix->calculate_helix_coordinates();
984 #if defined(CHECK_INTEGRITY)
985 helix->check_integrity(CHECK_POSITIONS);
986 #endif // CHECK_INTEGRITY
992 inline SEC_base *SEC_segment::get_parent() {
return loop; }
1000 if (end1 == start2)
return true;
1007 #error SEC_root.hxx included twice
const SEC_helix * get_helix() const
bool is_pairpos(size_t pos) const
int get_base_count() const
SEC_root * get_root() const
void set_under_construction(bool construct)
double standardSize() const
const Position & startAttachPoint() const
SEC_helix_strand * get_next_strand()
bool shallDisplayPosition(size_t abspos) const
int get_sequence_start() const
void mark_angle_absolute()
void update_base_count(SEC_root *root)
SEC_helix_strand * get_fixpoint_strand() const
const SEC_db_interface * get_db() const
const double & get_char_radius(int gc) const
SEC_segment * get_next_segment()
SEC_loop * get_destination_loop()
int get_sequence_end() const
int getBackgroundColor(int abspos)
const ED4_plugin_host & host() const
bool hasLoop(SEC_loop *loop) const
bool are_adjacent_regions(const SEC_region *reg1, const SEC_region *reg2)
void delete_pointer_2(SEC_helix_strand *strand)
void set_rel_angle(const double &rel)
const BI_helix * get_helixDef() const
const SEC_base * parent() const
void clear_last_drawed_cursor_position()
const Position & leftAttachPoint() const
const SEC_displayParams & display_params() const
const SEC_base_part * next() const
bool contains_seq_position(int pos) const
SEC_helix_strand * get_other_strand()
SEC_BASE_TYPE get_show_constraints()
SEC_region * get_region()
#define SEC_GC_DATA_COUNT
const SEC_loop * get_origin_loop() const
const Vector & normal() const
const Angle & get_abs_angle() const
const LineVector & get_last_drawed_cursor_position() const
int endAttachAbspos() const
static HelixNrInfo * start
bool pointsToRoot() const
void reread_display_params(AW_root *aw_root, const ED4_plugin_host &Host)
static int diff(int v1, int v2, int v3, int v4, int st, int en)
void setAttachPoints(const Position &left, const Position &right)
const double & get_circumference() const
SEC_helix * get_fixpoint_helix() const
const AW_font_group & get_font_group() const
const Vector & get_center_char_vector(int gc)
const SEC_helix_strand * get_next_strand() const
SEC_helix_strand * strandToRoot() const
const XString & get_xString() const
void set_last_drawed_cursor_position(const LineVector &line)
const Position & rightAttachPoint() const
double distance_between_strands
SEC_helix_strand * get_rootside_strand() const
void set_sequence_portion(int start, int end)
void set_origin_loop(SEC_loop *loop_)
void set_show_constraints(SEC_BASE_TYPE show)
SEC_loop * get_root_loop() const
const SEC_region * get_region() const
void set_abs_angle(const Angle &abs)
const SEC_loop * get_loop() const
int startAttachAbspos() const
void setStandardSize(double size)
SEC_loop * get_rootside_loop()
double get_bondThickWorld() const
void set_next_strand(SEC_helix_strand *strand)
SEC_root * get_root() const
void reread(AW_root *aw_root, const ED4_plugin_host &host)
void set_rel_angle(const Angle &rel)
void set_sequence_portion(int start, int end)
const Angle & get_rel_angle() const
#define SEC_GC_FONT_COUNT
SEC_loop * get_origin_loop()
const char * helixNrAt(int abspos) const
void set_fixpoint_strand(SEC_helix_strand *strand)
const SEC_base * parent() const
void set_loop(SEC_loop *loop_)
const ED4_plugin_host & host() const
bool shallDisplayPosition(int abspos) const
int getBasePos(int basenr) const
const SEC_segment * get_next_segment() const
void setConstraints(double low, double high)
void set_center(const Position &p)
bool under_construction() const
bool is_normalized() const
static ARB_init_perl_interface init
int rightAttachAbspos() const
void setFixpoint(const Position &p)
SEC_helix * get_rootside_helix() const
const Position & get_fixpoint() const
bool is_std_gap(const char c)
bool is_pairpos(int abspos) const
bool pointsToOutside() const
const Position & endAttachPoint() const
static long count_bases(const char *data, long len)
int leftAttachAbspos() const
const SEC_helix_strand * get_other_strand() const
void set_root_loop(SEC_loop *loop)
void setDrawnSize(double size)
void set_next_segment(SEC_segment *next_segment_)
ShowCursorPos show_curpos
void set_abs_angle(const double &abs)
bool isRootsideFixpoint() const