22
15
#include "SEC_bonddef.hxx"
23
16
#include "SEC_toggle.hxx"
21
#include <ed4_extern.hxx>
25
28
using namespace std;
30
// -------------------
33
#if defined(ASSERTION_USED)
35
inline bool valid_cb_params(AW_CL cd1, AW_CL cd2) {
36
return cd1 == 0 || cd2 != -1;
38
inline bool valid_cb_params(AW_device *device) {
39
const AW_click_cd *cd = device->get_click_cd();
40
return valid_cb_params(cd->get_cd1(), cd->get_cd2());
32
46
// #define PAINT_REGION_INDEX // // paint region-internal index next to base
34
static bool valid_cb_params(AW_CL cd1, AW_CL cd2) {
35
return cd1 == 0 || cd2 != -1;
38
static void paintDebugInfo(AW_device *device, int color, const Position& pos, const char *txt, AW_CL cd1, AW_CL cd2) {
39
sec_assert(valid_cb_params(cd1, cd2));
40
device->circle(color, true, pos.xpos(), pos.ypos(), 0.06, 0.06, -1, cd1, cd2);
41
device->text(SEC_GC_DEFAULT, txt, pos.xpos(), pos.ypos(), 0, 1, cd1, cd2, 0);
48
static void paintDebugInfo(AW_device *device, int color, const Position& pos, const char *txt) {
49
sec_assert(valid_cb_params(device));
50
device->circle(color, true, pos.xpos(), pos.ypos(), 0.06, 0.06);
51
device->text(SEC_GC_DEFAULT, txt, pos.xpos(), pos.ypos(), 0, AW_SCREEN, 0);
43
53
static void paintStrandDebugInfo(AW_device *device, int color, SEC_helix_strand *strand) {
44
paintDebugInfo(device, color, strand->rightAttachPoint(), "RAP", strand->self(), strand->rightAttachAbspos());
45
paintDebugInfo(device, color, strand->leftAttachPoint(), "LAP", strand->self(), strand->leftAttachAbspos());
46
paintDebugInfo(device, color, strand->get_fixpoint(), strand->isRootsideFixpoint() ? "RFP" : "FP", strand->self(), strand->startAttachAbspos());
54
AW_click_cd cd(device, strand->self(), strand->rightAttachAbspos()); paintDebugInfo(device, color, strand->rightAttachPoint(), "RAP");
55
cd.set_cd2(strand->leftAttachAbspos()); paintDebugInfo(device, color, strand->leftAttachPoint(), "LAP");
56
cd.set_cd2(strand->startAttachAbspos()); paintDebugInfo(device, color, strand->get_fixpoint(), strand->isRootsideFixpoint() ? "RFP" : "FP");
61
// -------------------
56
65
int gc_edit4_to_secedit[ED4_G_DRAG+1]; // GC translation table (EDIT4 -> SECEDIT)
112
121
static PaintData paintData;
114
// --------------------
123
// ---------------------
116
// --------------------
118
126
void SEC_root::paintAnnotation(AW_device *device, int gc,
119
127
const Position& pos, const Position& left, const Position& right,
120
128
double noteDistance, const char *text,
121
bool lineToPos, bool linesToLeftRight, bool boxText,
122
AW_CL cd1, AW_CL cd2)
129
bool lineToPos, bool linesToLeftRight, bool boxText)
124
131
// draw annotation to explicit position 'pos' (annotation is drawn "above" the line left->right)
125
132
// The distance between pos and note is determined by
126
133
// * textsize (minimal half textsize/boxsize) and
127
// * the given 'noteDistance'
128
// lineToPos == true -> draw a line from text to 'pos'
134
// * the given 'noteDistance'
135
// lineToPos == true -> draw a line from text to 'pos'
129
136
// linesToLeftRight == true -> draw lines from text to 'left' and 'right'
130
137
// boxText == true -> draw a box around text
132
sec_assert(valid_cb_params(cd1, cd2));
139
sec_assert(valid_cb_params(device));
134
141
Vector strand(left, right);
135
Angle pos2note(strand);
142
Angle pos2note(strand);
136
143
pos2note.rotate270deg();
138
145
int fontgc = gc <= SEC_GC_LAST_FONT ? gc : SEC_GC_DEFAULT;
168
174
Vector toRight(note_center, right);
170
176
device->line(gc, boxText ? note_center : note_center+toLeft*(half_width/toLeft.length()),
171
left-toLeft*(half_charSize/toLeft.length()), -1, cd1, cd2);
177
left-toLeft*(half_charSize/toLeft.length()), AW_ALL_DEVICES_SCALED);
172
178
device->line(gc, boxText ? note_center : note_center+toRight*(half_width/toRight.length()),
173
right-toRight*(half_charSize/toRight.length()), -1, cd1, cd2);
175
// Vector dist = Vector(left, note_center).normalize()*half_charSize;
176
// device->line(gc, boxText ? note_center : note_center-dist, left+dist, -1, cd1, cd2);
177
// dist = Vector(right, note_center).normalize()*half_charSize;
178
// device->line(gc, boxText ? note_center : note_center-dist, right+dist, -1, cd1, cd2);
179
right-toRight*(half_charSize/toRight.length()), AW_ALL_DEVICES_SCALED);
181
182
Vector rightIndent = out;
185
186
Position leftOut = left+out-rightIndent;
187
188
Vector posPad = Vector(right, rightOut).set_length(half_charSize);
188
device->line(gc, right+posPad, rightOut, -1, cd1, cd2);
189
device->line(gc, right+posPad, rightOut);
189
190
posPad.rotate90deg();
190
device->line(gc, left+posPad, leftOut, -1, cd1, cd2);
191
device->line(gc, left+posPad, leftOut);
193
device->line(gc, leftOut, rightOut, -1, cd1, cd2);
194
device->line(gc, leftOut, rightOut);
196
197
Vector rightTextPad(note_center, rightOut);
197
198
rightTextPad.set_length(half_width);
199
device->line(gc, note_center+rightTextPad, rightOut, -1, cd1, cd2);
200
device->line(gc, note_center-rightTextPad, leftOut, -1, cd1, cd2);
200
device->line(gc, note_center+rightTextPad, rightOut);
201
device->line(gc, note_center-rightTextPad, leftOut);
211
212
Rectangle box(note_center+center_corner, -2*center_corner);
213
214
device->clear_part(box, -1);
214
device->box(gc, false, box, -1, cd1, cd2);
215
device->box(gc, false, box);
217
device->text(gc, text, textcorner, 0, -1, cd1, cd2, 0);
218
device->text(gc, text, textcorner);
220
221
void SEC_root::paintPosAnnotation(AW_device *device, int gc, size_t absPos, const char *text, bool lineToBase, bool boxText) {
236
237
if (posDrawn) { // absPos was drawn
239
else { // absPos was not drawn -> use position inbetween
240
else { // absPos was not drawn -> use position in-between
244
245
if (!text) text = GBS_global_string("%zu", absPos);
246
paintAnnotation(device, gc, pos, pos1, pos2, vec12.length(), text, lineToBase, false, boxText, 0, absPos);
247
AW_click_cd cd(device, 0, absPos);
248
paintAnnotation(device, gc, pos, pos1, pos2, vec12.length(), text, lineToBase, false, boxText);
249
251
void SEC_root::paintEcoliPositions(AW_device *device) {
251
253
paintPosAnnotation(device, SEC_GC_ECOLI, size_t(abspos), "1", true, true);
253
255
const BI_ecoli_ref *ecoli = db->ecoli();
254
for (size_t ep = 99; ep < ecoli->base_count(); ep += 100) {
256
for (size_t ep = bio2info(100); ep < (size_t)ecoli->base_count(); ep += 100) {
255
257
abspos = ecoli->rel_2_abs(ep);
256
paintPosAnnotation(device, SEC_GC_ECOLI, size_t(abspos), GBS_global_string("%zu", ep+1), true, true);
258
paintPosAnnotation(device, SEC_GC_ECOLI, size_t(abspos), GBS_global_string("%i", info2bio(ep)), true, true);
278
280
const Position& end = strand->endAttachPoint();
279
281
Position helixCenter = centroid(start, end);
283
AW_click_cd cd(device, strand->self(), absPos);
281
284
paintAnnotation(device, SEC_GC_HELIX_NO,
282
285
helixCenter, start, end,
283
// displayParams.distance_between_strands*2,
284
displayParams.distance_between_strands,
285
helixNr, false, true, true, strand->self(), absPos);
286
// displayParams.distance_between_strands*2,
287
displayParams.distance_between_strands,
288
helixNr, false, true, true);
293
296
#if defined(PAINT_ABSOLUTE_POSITION)
294
297
void SEC_root::showSomeAbsolutePositions(AW_device *device) {
295
if (device->filter != AW_SIZE) { // ignore for size calculation
296
Rectangle screen(device->rtransform(device->get_area_size()));
297
Vector diag3 = screen.diagonal()/3;
298
if (device->get_filter() != AW_SIZE) { // ignore for size calculation (@@@)
299
Rectangle screen = device->rtransform(Rectangle(device->get_area_size(), INCLUSIVE_OUTLINE));
300
Vector diag3 = screen.diagonal()/3;
298
301
Rectangle showInside(screen.upper_left_corner()+diag3*1.85, diag3);
300
device->box(SEC_GC_DEFAULT, false, showInside, -1, 0, -1);
303
AW_click_cd cd(device, 0, -1);
304
device->box(SEC_GC_DEFAULT, false, showInside);
302
306
PosMap::const_iterator end = drawnPositions->end();
303
307
for (PosMap::const_iterator pos = drawnPositions->begin(); pos != end; ++pos) {
338
341
bool drawMidLine = minS>0 && maxS>0;
339
342
Position minP = startP + Vector(startP, endP) * (drawMidLine ? minS/maxS : 0.5);
344
AW_click_cd cd(device, self(), startAttachAbspos());
341
345
get_root()->paintAnnotation(device, SEC_GC_DEFAULT,
342
346
minP, startP, endP,
343
347
get_root()->display_params().distance_between_strands*2,
344
348
GBS_global_string("%.1f-%.1f", minS, maxS),
345
drawMidLine, true, true,
346
self(), startAttachAbspos());
349
drawMidLine, true, true);
354
357
double maxS = maxSize();
356
359
if (minS>0 || maxS>0) {
357
if (minS>0) device->circle(SEC_GC_DEFAULT, false, center, minS, minS, -1, self(), abspos);
358
if (maxS>0) device->circle(SEC_GC_DEFAULT, false, center, maxS, maxS, -1, self(), abspos);
360
AW_click_cd cd(device, self(), abspos);
362
if (minS>0) device->circle(SEC_GC_DEFAULT, false, center, Vector(minS, minS));
363
if (maxS>0) device->circle(SEC_GC_DEFAULT, false, center, Vector(maxS, maxS));
360
device->text(SEC_GC_DEFAULT, GBS_global_string("%.1f-%.1f", minS, maxS), center+Vector(0, max(minS, maxS)/2), 0.5, -1, self(), abspos);
365
device->text(SEC_GC_DEFAULT, GBS_global_string("%.1f-%.1f", minS, maxS), center+Vector(0, max(minS, maxS)/2), 0.5, AW_ALL_DEVICES_UNSCALED);
364
// --------------------------
369
// ---------------------------
365
370
// Background colors
366
// --------------------------
372
#if defined(WARN_TODO)
368
373
#warning move to SEC_db_interface
369
375
void SEC_root::cacheBackgroundColor() {
370
freeset(bg_color, 0);
372
const ED4_sequence_terminal *sterm = db->get_seqTerminal();
375
int len = db->length();
378
bg_color = (char*)malloc(len);
380
const char *bg_sai = displayParams.display_sai ? ED4_getSaiColorString(db->awroot(), start, end) : 0;
381
const char *bg_search = displayParams.display_search ? ED4_buildColorString(sterm, start, end) : 0;
385
for (int i = start; i <= end; ++i) {
386
bg_color[i] = bg_search[i] ? bg_search[i] : bg_sai[i];
379
int len = db->length();
382
bg_color = (char*)malloc(len);
384
const char *bg_sai = displayParams.display_sai ? host().get_SAI_background(start, end) : 0;
385
const char *bg_search = displayParams.display_search ? host().get_search_background(start, end) : 0;
389
for (int i = start; i <= end; ++i) {
390
bg_color[i] = bg_search[i] ? bg_search[i] : bg_sai[i];
389
else memcpy(bg_color, bg_sai, len);
392
if (bg_search) memcpy(bg_color, bg_search, len);
393
else memset(bg_color, 0, len);
393
else memcpy(bg_color, bg_sai, len);
396
if (bg_search) memcpy(bg_color, bg_search, len);
397
else memset(bg_color, 0, len);
398
void SEC_root::paintBackgroundColor(AW_device *device, SEC_bgpaint_mode mode, const Position& p1, int color1, int gc1, const Position& p2, int color2, int gc2, int skel_gc, AW_CL cd1, AW_CL cd2) {
401
void SEC_root::paintBackgroundColor(AW_device *device, SEC_bgpaint_mode mode, const Position& p1, int color1, int gc1, const Position& p2, int color2, int gc2, int skel_gc) {
399
402
// paints background colors for p2 and connection between p1 and p2.
400
403
// gc1/gc2 are foreground gc used to detect size of background regions
402
405
// Also paints skeleton
404
sec_assert(valid_cb_params(cd1, cd2));
407
sec_assert(valid_cb_params(device));
406
409
color1 = paintData.convert_BackgroundGC(color1); // convert EDIT4-GCs into SECEDIT-GCs
407
410
color2 = paintData.convert_BackgroundGC(color2);
409
412
if (color1 >= 0 || color2 >= 0 || displayParams.show_strSkeleton) {
410
const double& radius1 = char_radius[gc1];
411
const double& radius2 = char_radius[gc2];
413
const double& radius1 = get_char_radius(gc1);
414
const double& radius2 = get_char_radius(gc2);
413
416
Position s1 = p1;
414
417
Position s2 = p2;
431
434
if (mode & BG_PAINT_FIRST && color1 >= 0) { // paint first circle ?
432
device->circle(color1, true, p1, radius1, radius1, -1, cd1, cd2);
435
device->circle(color1, true, p1, Vector(radius1, radius1));
435
438
if (mode & BG_PAINT_SECOND && color2 >= 0) { // paint second circle ?
436
device->circle(color2, true, p2, radius1, radius1, -1, cd1, cd2);
439
device->circle(color2, true, p2, Vector(radius1, radius1));
439
442
if (color1 == color2 && color1 >= 0) { // colors are equal -> paint background between points
440
443
device->set_line_attributes(color1, bg_linewidth[paintData.get_linePropertyGC(gc1, gc2)], AW_SOLID);
441
device->line(color1, p1, p2, -1, cd1, cd2);
444
device->line(color1, p1, p2);
445
448
if (displayParams.show_strSkeleton) { // paint skeleton
446
449
device->set_line_attributes(skel_gc, displayParams.skeleton_thickness, AW_SOLID);
447
450
#if defined(DEBUG)
448
451
if (displayParams.show_debug) { s1 = p1; s2 = p2; } // in debug mode always show full skeleton
450
device->line(skel_gc, s1, s2, -1, cd1, cd2);
453
device->line(skel_gc, s1, s2);
456
459
void SEC_root::paintSearchPatternStrings(AW_device *device, int clickedPos, AW_pos xPos, AW_pos yPos) {
457
460
int searchColor = getBackgroundColor(clickedPos);
459
462
if (searchColor >= SEC_GC_SBACK_0 && searchColor <= SEC_GC_SBACK_8) {
460
463
static const char *text[SEC_GC_SBACK_8-SEC_GC_SBACK_0+1] = {
468
"Signature (region)",
471
"Signature (region)",
469
472
"Signature (global)",
472
device->text(searchColor, text[searchColor-SEC_GC_SBACK_0], xPos, yPos, 0, 1, 0, clickedPos, 0);
475
AW_click_cd cd(device, 0, clickedPos);
476
device->text(searchColor, text[searchColor-SEC_GC_SBACK_0], xPos, yPos, 0, AW_SCREEN, 0);
475
479
aw_message("Please click on a search result");
484
void SEC_bond_def::paint(AW_device *device, char base1, char base2, const Position& p1, const Position& p2, const Vector& toNextBase, const double& char_radius, AW_CL cd1, AW_CL cd2) const {
486
void SEC_bond_def::paint(AW_device *device, char base1, char base2, const Position& p1, const Position& p2, const Vector& toNextBase, const double& char_radius) const {
485
487
if (base1 && base2) {
486
488
char Bond = get_bond(base1, base2);
487
489
if (Bond == ' ') {
489
const char *iupac1 = AWT_decode_iupac(base1, ali_type, 0);
490
const char *iupac2 = AWT_decode_iupac(base2, ali_type, 0);
491
const char *iupac1 = iupac::decode(base1, ali_type, 0);
492
const char *iupac2 = iupac::decode(base2, ali_type, 0);
492
494
bool useBond[SEC_BOND_PAIR_CHARS];
493
495
for (int i = 0; i<SEC_BOND_PAIR_CHARS; i++) useBond[i] = false;
510
512
if (maxIdx >= 0) {
511
513
for (int i = 0; i<SEC_BOND_PAIR_CHARS; i++) {
512
514
if (useBond[i]) {
513
paint(device, i == maxIdx ? SEC_GC_BONDS : SEC_GC_ERROR, SEC_BOND_PAIR_CHAR[i], p1, p2, toNextBase, char_radius, cd1, cd2);
515
paint(device, i == maxIdx ? SEC_GC_BONDS : SEC_GC_ERROR, SEC_BOND_PAIR_CHAR[i], p1, p2, toNextBase, char_radius);
519
paint(device, SEC_GC_BONDS, Bond, p1, p2, toNextBase, char_radius, cd1, cd2);
521
paint(device, SEC_GC_BONDS, Bond, p1, p2, toNextBase, char_radius);
524
void SEC_bond_def::paint(AW_device *device, int GC, char bondChar, const Position& p1, const Position& p2, const Vector& toNextBase, const double& char_radius, AW_CL cd1, AW_CL cd2) const {
526
void SEC_bond_def::paint(AW_device *device, int GC, char bondChar, const Position& p1, const Position& p2, const Vector& toNextBase, const double& char_radius) const {
525
527
Vector v12(p1, p2);
526
528
double oppoDist = v12.length();
527
529
double bondLen = oppoDist-2*char_radius;
540
542
switch (bondChar) {
541
543
case '-': // single line
542
device->line(GC, b1, b2, -1, cd1, cd2);
544
device->line(GC, b1, b2);
545
547
case '#': // double cross
546
548
case '=': // double line
547
device->line(GC, b1+aside, b2+aside, -1, cd1, cd2);
548
device->line(GC, b1-aside, b2-aside, -1, cd1, cd2);
549
device->line(GC, b1+aside, b2+aside);
550
device->line(GC, b1-aside, b2-aside);
550
552
if (bondChar == '#') {
551
553
Vector outside = v12*(bondLen/oppoDist/4);
552
554
Position c1 = center+outside;
553
555
Position c2 = center-outside;
557
device->line(GC, c1-aside, c1+aside, -1, cd1, cd2);
558
device->line(GC, c2-aside, c2+aside, -1, cd1, cd2);
559
device->line(GC, c1-aside, c1+aside);
560
device->line(GC, c2-aside, c2+aside);
563
565
double radius = aside.length();
576
578
Angle angle(outside);
577
int deg = int(angle.degrees()+0.5);
579
device->arc(GC, false, c1, radius, radius, deg+180-1, 180+30, -1, cd1, cd2);
580
device->arc(GC, false, c2, radius, radius, deg-1, 180+30, -1, cd1, cd2);
579
int deg = AW_INT(angle.degrees());
581
const int INSIDE = 2;
582
const int OUTSIDE = 15;
584
Vector vRadius(radius, radius);
585
device->arc(GC, false, c1, vRadius, deg+180+INSIDE, -(180+INSIDE+OUTSIDE));
586
device->arc(GC, false, c2, vRadius, deg+INSIDE, -(180+INSIDE+OUTSIDE));
584
590
case '+': // cross
586
device->line(GC, center-aside, center+aside, -1, cd1, cd2);
592
device->line(GC, center-aside, center+aside);
587
593
if (2*aside.length() < bondLen) {
588
594
aside.rotate90deg();
589
device->line(GC, center-aside, center+aside, -1, cd1, cd2);
595
device->line(GC, center-aside, center+aside);
592
device->line(GC, b1, b2, -1, cd1, cd2);
598
device->line(GC, b1, b2);
597
603
case '.': { // circles
598
604
double radius = aside.length();
599
605
if (bondChar == 'o') radius *= 2;
600
device->circle(GC, false, center, radius, radius, -1, cd1, cd2);
606
device->circle(GC, false, center, Vector(radius, radius));
604
610
case '@': // error in bonddef
605
device->text(GC, "Err", center+Vector(0, char_radius), 0.5, -1, cd1, cd2);
611
device->text(GC, "Err", center+Vector(0, char_radius), 0.5, AW_ALL_DEVICES_UNSCALED);
714
719
if (curr->drawn[strand]) {
715
720
StrandPositionData *prev = &data[curr->previous[strand]];
717
int backAbs = disp.edit_direction
722
int backAbs = disp.edit_rightward
718
723
? max(prev->abs[strand], curr->abs[strand])
719
724
: min(prev->abs[strand], curr->abs[strand]);
726
AW_click_cd cd(device, self(), backAbs);
721
727
root->paintBackgroundColor(device,
722
728
pos == base_count-1 ? BG_PAINT_NONE : BG_PAINT_SECOND,
723
729
prev->realpos[strand], root->getBackgroundColor(prev->abs[strand]), pair2helixGC[prev->isPair],
724
730
curr->realpos[strand], root->getBackgroundColor(curr->abs[strand]), pair2helixGC[curr->isPair],
725
pair2skelGC[curr->isPair && prev->isPair],
731
pair2skelGC[curr->isPair && prev->isPair]);
745
750
sec_assert(abs >= 0);
748
base[strand] = db->baseAt(abs);
749
root->announce_base_position(abs, realPos);
752
// base[strand] = '-';
752
base[strand] = db->baseAt(abs);
753
root->announce_base_position(abs, realPos);
755
755
if (!disp.hide_bases) {
756
756
baseBuf[0] = base[strand];
757
757
Position base_pos = realPos + center_char; // center base at realpos
758
AW_click_cd cd(device, self(), abs);
758
759
#if defined(DEBUG)
759
if (disp.show_debug) device->line(gc, realPos, base_pos, -1, self(), abs);
760
// sprintf(baseBuf+1, "%i", abs);
760
if (disp.show_debug) device->line(gc, realPos, base_pos);
763
device->text(gc, baseBuf, base_pos, 0, -1, self(), abs, 0);
763
device->text(gc, baseBuf, base_pos, 0.0, AW_ALL_DEVICES_SCALED);
768
768
if (disp.show_bonds == SHOW_NHELIX_BONDS || (disp.show_bonds == SHOW_HELIX_BONDS && curr->isPair)) {
769
AW_click_cd cd(device, self(), curr->abs[0]);
769
770
db->bonds()->paint(device, base[0], base[1], curr->realpos[0], curr->realpos[1], vnext,
770
root->get_char_radius(pair2helixGC[curr->isPair]),
771
self(), curr->abs[0]);
771
root->get_char_radius(pair2helixGC[curr->isPair]));
776
776
void SEC_helix_strand::paint(AW_device *device) {
777
777
sec_assert(isRootsideFixpoint());
779
779
Vector strand_vec(rightAttach, other_strand->leftAttach);
780
780
double strand_len = strand_vec.length(); // length of strand
808
804
strandArrow = LineVector(get_fixpoint()-fix2arrowStart, 2*fix2arrowStart);
811
AW_CL cd1 = (AW_CL)get_helix()->self();
812
AW_CL cd2 = (AW_CL)startAttachAbspos();
807
AW_click_cd cd(device, get_helix()->self(), startAttachAbspos());
808
// AW_CL cd1 = (AW_CL)get_helix()->self();
809
// AW_CL cd2 = (AW_CL)startAttachAbspos();
814
device->line(SEC_GC_HELIX, strandArrow, -1, cd1, cd2);
811
device->line(SEC_GC_HELIX, strandArrow);
816
813
Vector right = strandArrow.line_vector(); // left arrowhead vector
817
814
right = (right * (disp.distance_between_strands*0.35/right.length())).rotate135deg();
881
876
int startAbsPos = previous_strand_pointer->rightAttachAbspos();
882
877
int endAbsPos = next_helix_strand->leftAttachAbspos();
884
paintDebugInfo(device, SEC_GC_LOOP, center1, GBS_global_string("SC1 (step=%5.3f)", step), self(), startAbsPos);
885
paintDebugInfo(device, SEC_GC_LOOP, center2, "SC2", self(), endAbsPos);
886
device->line(SEC_GC_LOOP, center1, startP, -1, self(), startAbsPos);
887
device->line(SEC_GC_LOOP, center2, endP, -1, self(), endAbsPos);
888
device->line(SEC_GC_LOOP, center1, center2, -1, self(), startAbsPos);
879
AW_click_cd cd(device, self(), startAbsPos);
880
paintDebugInfo(device, SEC_GC_LOOP, center1, GBS_global_string("SC1 (step=%5.3f)", step));
881
device->line(SEC_GC_LOOP, center1, startP);
882
device->line(SEC_GC_LOOP, center1, center2);
884
cd.set_cd2(endAbsPos);
885
paintDebugInfo(device, SEC_GC_LOOP, center2, "SC2");
886
device->line(SEC_GC_LOOP, center2, endP);
921
921
int nextBack = root->getBackgroundColor(nextAbs);
923
923
// paint background (from pos to nextPos)
924
AW_click_cd cd(device, self(), disp.edit_rightward ? nextAbs : abs);
924
925
root->paintBackgroundColor(device, i == -1 ? BG_PAINT_BOTH : BG_PAINT_SECOND,
925
pos, back, gc, nextPos, nextBack, nextGc, SEC_SKELE_LOOP, self(),
926
disp.edit_direction ? nextAbs : abs);
928
// if (disp.show_strSkeleton) {
929
// device->line(SEC_SKELE_LOOP, pos, nextPos, -1, self(), abs);
926
pos, back, gc, nextPos, nextBack, nextGc, SEC_SKELE_LOOP);
933
929
// paint base char at pos
934
// baseBuf[0] = abs>0 ? root->sequence[abs] : '?';
935
baseBuf[0] = abs>0 ? db->baseAt(abs) : '?';
930
baseBuf[0] = abs>0 ? db->baseAt(abs) : '?';
936
931
Vector center_char = root->get_center_char_vector(gc);
937
932
Position base_pos = pos + center_char; // center base character at pos
939
// #if defined(DEBUG)
940
// if (disp.show_debug) {
941
// #if defined(PAINT_REGION_INDEX)
942
// sprintf(baseBuf+1, "%i", i);
943
// #endif // // PAINT_REGION_INDEX
945
// #endif // // DEBUG
947
935
if (!disp.hide_bases) {
948
936
#if defined(DEBUG)
949
937
// show line from base paint pos to calculated center of char
950
938
// (which is currently calculated wrong!)
951
if (disp.show_debug) device->line(SEC_GC_LOOP, pos, base_pos, -1, self(), abs);
939
if (disp.show_debug) device->line(SEC_GC_LOOP, pos, base_pos);
953
device->text(SEC_GC_LOOP, baseBuf, base_pos, 0, -1, self(), abs, 0 );
941
device->text(SEC_GC_LOOP, baseBuf, base_pos, 0.0, AW_ALL_DEVICES_SCALED);
955
943
root->announce_base_position(abs, pos);
976
964
if (sroot->display_params().show_debug) {
977
965
SEC_helix_strand *fixpoint_strand = get_fixpoint_strand();
978
966
int abspos = fixpoint_strand->startAttachAbspos();
967
AW_click_cd cd(device, self(), abspos);
980
969
device->set_line_attributes(SEC_GC_CURSOR, 1, AW_SOLID);
981
device->line(SEC_GC_CURSOR, get_center(), fixpoint_strand->get_fixpoint(), self(), abspos);
970
device->line(SEC_GC_CURSOR, get_center(), fixpoint_strand->get_fixpoint());
983
972
paintStrandDebugInfo(device, SEC_GC_CURSOR, fixpoint_strand);
984
paintDebugInfo(device, SEC_GC_CURSOR, get_center(), "LC", self(), abspos);
973
paintDebugInfo(device, SEC_GC_CURSOR, get_center(), "LC");
987
976
if (sroot->get_show_constraints() & SEC_LOOP) paint_constraints(device);
990
// ---------------------------------------------------------
979
// ------------------------------------------------------------
991
980
// Paint the whole structure (starting with SEC_root)
992
// ---------------------------------------------------------
994
982
GB_ERROR SEC_root::paint(AW_device *device) {
995
983
SEC_loop *rootLoop = get_root_loop();
1027
1015
device->set_line_attributes(SEC_SKELE_LOOP, displayParams.skeleton_thickness, AW_SOLID);
1028
1016
device->set_line_attributes(SEC_GC_BONDS, displayParams.bond_thickness, AW_SOLID);
1030
// mark the rootLoop with a box and print stucture number
1018
// mark the rootLoop with a box and print structure number
1032
1020
const Position& loop_center = rootLoop->get_center();
1033
1021
const char *structId = db->structure()->name();
1035
// Vector textAdjust = center_char[SEC_GC_DEFAULT];
1036
// textAdjust.setx(0); // // only adjust y
1038
AW_CL cd1 = rootLoop->self();
1023
AW_click_cd cd(device, rootLoop->self(), -1);
1024
// AW_CL cd1 = rootLoop->self();
1041
1027
Vector center2corner(-1, -1);
1042
1028
center2corner.set_length(rootLoop->drawnSize()*0.33);
1044
1030
Position upperleft_corner = loop_center+center2corner;
1045
1031
Vector diagonal = -2*center2corner;
1047
1033
Position textPos(loop_center.xpos(), upperleft_corner.ypos());
1049
device->box(SEC_GC_DEFAULT, false, upperleft_corner, diagonal, -1, cd1, cd2);
1050
device->text(SEC_GC_DEFAULT, structId, textPos, 0.5, -1, cd1, cd2, 0);
1035
device->box(SEC_GC_DEFAULT, false, upperleft_corner, diagonal, AW_ALL_DEVICES_UNSCALED);
1036
device->text(SEC_GC_DEFAULT, structId, textPos, 0.5, AW_ALL_DEVICES_UNSCALED, 0);
1053
1039
#if defined(CHECK_INTEGRITY)
1075
AW_click_cd cd(device, 0, curAbs);
1089
1076
#if defined(DEBUG) && 1
1090
1077
// draw a testline to see the baseline on that the cursor is positioned
1091
device->set_line_attributes(SEC_GC_CURSOR, 1, AW_DOTTED);
1092
device->line(SEC_GC_CURSOR, pos1, pos2, -1, 0, curAbs);
1078
device->set_line_attributes(SEC_GC_CURSOR, 1, AW_DASHED);
1079
device->line(SEC_GC_CURSOR, pos1, pos2);
1095
1082
Position mid = centroid(pos1, pos2);
1103
1090
double cursor_size = 1.3 * max(font_group.get_max_width(), font_group.get_max_ascent()); // 30% bigger than max font size
1104
1091
double stretch = cursor_size*0.5/drawn_length; // stretch cursor (half fontsize in each direction)
1106
1093
v.rotate90deg() *= stretch;
1109
1096
LineVector cursor(mid+v, mid-v);
1110
1097
device->set_line_attributes(SEC_GC_CURSOR, 3, AW_SOLID);
1111
device->line(SEC_GC_CURSOR, cursor, -1, 0, curAbs);
1098
device->line(SEC_GC_CURSOR, cursor);
1112
1099
set_last_drawed_cursor_position(cursor);
1114
LineVector cursor_dir(cursor.head(), displayParams.edit_direction ? v.rotate270deg() : v.rotate90deg());
1115
device->line(SEC_GC_CURSOR, cursor_dir, -1, 0, curAbs);
1101
LineVector cursor_dir(cursor.head(), displayParams.edit_rightward ? v.rotate270deg() : v.rotate90deg());
1102
device->line(SEC_GC_CURSOR, cursor_dir);
1118
1105
int cursor_gc = -1;
1119
int cursor_pos = -1;
1121
1108
switch (displayParams.show_curpos) {
1122
1109
case SHOW_ABS_CURPOS:
1123
cursor_gc = SEC_GC_CURSOR;
1124
cursor_pos = curAbs+1; // show absolute position starting with 1
1110
cursor_gc = SEC_GC_CURSOR;
1111
disp_pos = info2bio(curAbs);
1126
1113
case SHOW_BASE_CURPOS:
1127
cursor_gc = SEC_GC_DEFAULT;
1128
cursor_pos = ED4_get_base_position(db->get_seqTerminal(), curAbs)+1; // show base position starting with 1
1114
cursor_gc = SEC_GC_DEFAULT;
1115
disp_pos = host().get_base_position(curAbs+1); // show bases up to cursorpos (inclusive)
1130
1117
case SHOW_ECOLI_CURPOS: {
1131
cursor_gc = SEC_GC_ECOLI;
1132
cursor_pos = db->ecoli()->abs_2_rel(curAbs)+1; // show ecoli base position starting with 1
1118
cursor_gc = SEC_GC_ECOLI;
1119
disp_pos = db->ecoli()->abs_2_rel(curAbs+1); // show ecoli base position (inclusive cursorpos)
1135
1122
case SHOW_NO_CURPOS:
1140
1127
if (cursor_gc >= 0) {
1141
paintPosAnnotation(device, cursor_gc, curAbs, GBS_global_string("%u", cursor_pos), true, true);
1128
paintPosAnnotation(device, cursor_gc, curAbs, GBS_global_string("%u", disp_pos), true, true);