32 #ifndef sec_assert // happens in NDEBUG mode
33 #define sec_assert(cond) arb_assert(cond)
45 while (part != start_part);
54 nailedAbsPos = absPos;
55 drawnAbsPos = *drawnPositions->
drawn_at(absPos);
60 if (cursorAbsPos >= 0) {
61 if (drawnPositions && !drawnPositions->
empty()) {
63 drawnAbsPos = drawnPositions->
drawn_after(cursorAbsPos-1, &abs);
70 if (autoscroll) *autoscroll += scroll;
71 else autoscroll =
new Vector(scroll);
75 bool scrolled =
false;
78 if (canvas && (nailedAbsPos != -1 || autoscroll)) {
81 if (nailedAbsPos != -1) {
83 int absPos = nailedAbsPos;
84 Vector *scroll = autoscroll;
98 nailedAbsPos = absPos;
103 Vector old2new(drawnAbsPos, *newPos);
104 #if defined(DEBUG) && 0
105 printf(
"drawnAbsPos=%.2f/%.2f newPos=%.2f/%.2f old2new=%.2f/%.2f\n",
106 drawnAbsPos.
xpos(), drawnAbsPos.
ypos(),
108 old2new.
x(), old2new.
y());
118 #if defined(DEBUG) && 0
119 printf(
"autoscroll=%.2f/%.2f screen_scroll=%.2f/%.2f\n",
120 autoscroll->
x(), autoscroll->
y(),
121 screen_scroll.
x(), screen_scroll.
y());
131 canvas->
scroll(screen_scroll);
153 if (evenIfVisible || !screen.contains(cursor)) {
157 if (!screen.contains(cursor)) {
168 Vector scroll(cursor.centroid(), screen.centroid());
170 #if defined(DEBUG) && 1
171 printf(
"Auto-scroll: scroll = (%f, %f) [Center cursor]\n", scroll.x(), scroll.y());
173 scr->scroll(-scroll);
174 scr->request_refresh();
196 const char *text =
NULp;
242 #define ASS "ARB secondary structure v1" // don't change version here!
243 #define ASS_START "[" ASS "]"
244 #define ASS_EOS "[end of structure]"
245 #define ASS_EOF "[end of " ASS "]"
252 error =
"Please select a species (to display structure once) before saving";
257 FILE *out = fopen(filename,
"wt");
276 fprintf(out,
"foldedHelices=%s\n", foldInfo);
286 error =
GB_export_errorf(
"Can't write secondary structure to '%s'", filename);
300 if (!file.
getLine(line) || line != expected) {
313 size_t equal = line.find(
'=');
315 if (equal == string::npos) {
316 error =
"Expected '='";
319 token = line.substr(0, equal);
320 rest = line.substr(equal+1);
324 error =
"Unexpected EOF";
331 string foundToken =
scanToken(file, content, error);
341 error =
"Please select a species in EDIT4";
345 FILE *in = fopen(filename,
"rt");
360 structure += line +
"\n";
364 char *x_string =
NULp;
367 string token =
scanToken(file, content, error);
373 if (token ==
"foldedHelices") {
376 else if (token ==
"no of helices") {
377 int saved_helices = atoi(content.c_str());
379 error =
expectToken(file,
"length of xstring", content);
380 if (!error) error =
expectToken(file,
"xstring_rel_helix", content);
384 if (helices_in_db != saved_helices) {
386 "Saving the structure again from another DB with correct number of helices will work around this restriction.",
387 saved_helices, helices_in_db);
392 error =
"Expected 'foldedHelices' or 'no of helices'";
403 db->
graphic()->write_data_to_db(structure.c_str(), x_string);
419 AW_window_simple *aws =
new AW_window_simple;
421 if (export_to_file) aws->init(root,
"export_secondary_structure",
"Export secondary structure to ...");
422 else aws->init(root,
"import_secondary_structure",
"Import secondary structure from ...");
428 aws->create_button(
"CLOSE",
"CLOSE",
"C");
432 aws->create_button(
"HELP",
"HELP",
"H");
437 if (export_to_file) {
439 aws->create_button(
"EXPORT",
"EXPORT",
"E");
443 aws->create_button(
"IMPORT",
"IMPORT",
"I");
452 char *new_name =
aw_input(
"Rename structure",
"New name", structure->
name());
454 structure->setName(new_name);
473 switch (
aw_question(
NULp,
"Create new structure?",
"Default bone,Copy current,Abort")) {
475 error = structure->
copyTo(
"Default");
513 aw_message(
"You cannot delete the last structure");
530 "User1",
"User2",
"Probe",
531 "Primerl",
"Primerr",
"Primerg",
532 "Sigl",
"Sigr",
"Sigg",
538 "RANGE_0",
"RANGE_1",
"RANGE_2",
539 "RANGE_3",
"RANGE_4",
"RANGE_5",
540 "RANGE_6",
"RANGE_7",
"RANGE_8",
552 AW_window_simple *aws =
new AW_window_simple;
555 aws->init(awr,
"SEC_BONDDEF",
"Bond definitions");
556 aws->load_xfig(
"sec_bonddef.fig");
560 aws->create_button(
"CLOSE",
"CLOSE",
"C");
564 aws->create_button(
"HELP",
"HELP",
"H");
566 aws->label_length(24);
569 aws->label(
"Helix symbols\n"
570 "defined in EDIT4:");
573 aws->at(
"translate");
574 aws->label(
"Translate into\n"
575 "for display in SECEDIT:");
604 AW_window_simple *aws =
new AW_window_simple;
606 const int SCALED_TEXT_COLUMNS = 7;
609 aws->auto_space(5, 5);
611 aws->init(awr,
"SEC_DISPLAY_OPTS",
"Display options");
612 aws->load_xfig(
"sec_display.fig");
616 aws->create_button(
"CLOSE",
"CLOSE",
"C");
620 aws->create_button(
"HELP",
"HELP",
"H");
625 aws->label(
"Display bases :");
628 aws->at(
"strand_dist");
629 aws->label(
"Distance between strands :");
633 aws->label(
"Display bonds");
638 aws->update_option_menu();
642 aws->create_button(
"sec_bonddef",
"Define");
644 aws->at(
"bondThickness");
645 aws->label(
"Bond thickness :");
651 aws->label(
"Annotate cursor :");
657 aws->update_option_menu();
660 aws->label(
"Annotate helices :");
664 aws->label(
"Annotate ecoli positions :");
668 aws->label(
"Visualize search results :");
672 aws->label(
"Visualize SAI :");
678 aws->label(
"Binding helix positions :");
682 aws->label(
"Ecoli base positions :");
687 aws->at(
"strSkeleton");
688 aws->label(
"Display structure skeleton :");
691 aws->at(
"skelThickness");
692 aws->label(
"Skeleton thickness :");
696 aws->at(
"show_debug");
697 aws->label(
"Show debug info:");
702 {
"*bonds_arb7",
"Translation of helix symbols\n(from ARB_EDIT4 -> ARB_SECEDIT)\nSimulates bond display used up to arb 7.0",
"bondsymbol_edit4='#~-=';bondsymbol_trans=' -.o'" },
725 SEC_graphic *gfx =
new SEC_graphic(awr, gb_main);
729 awm->
init(awr,
"ARB_SECEDIT",
"ARB_SECEDIT: Secondary structure editor", 200, 200);
734 root->
init(gfx, scr, host);
static void sec_mode_event(AW_window *aws, SEC_root *sec_root, AWT_COMMAND_MODE mode)
GB_ERROR GB_begin_transaction(GBDATA *gbd)
void nail_position(size_t absPos)
#define AWAR_SECEDIT_SHOW_CURPOS
AW_window * AW_create_gc_window_named(AW_root *aw_root, AW_gc_manager *gcman, const char *wid, const char *windowname)
AW::Vector transform(const AW::Vector &vec) const
virtual void clear(AW_bitset filteri)
#define AWAR_SECEDIT_SKELETON_THICKNESS
static AW_window * SEC_importExport(AW_root *root, bool export_to_file, const SEC_db_interface *db)
static void SEC_rename_structure(AW_window *, const SEC_db_interface *db)
static void export_structure_to_file(AW_window *, const SEC_db_interface *db)
void invalidate_base_count()
GB_ERROR GB_commit_transaction(GBDATA *gbd)
void button_length(int length)
void request_zoom_reset()
AW_device * get_device(AW_area area)
static void import_structure_from_file(AW_window *, const SEC_db_interface *db)
const AW_screen_area & get_area_size() const
bool getLine(string &line)
#define MODE_TEXT_2BUTTONS(modeName, leftInfo, rightInfo)
const SEC_db_interface * get_db() const
void update_display_as_requested(AWT_canvas *scr, bool perform_refresh)
void insert_menu_topic(const char *id, const char *name, const char *mnemonic, const char *help_text_, AW_active mask, const WindowCallback &wcb)
void GB_atclose_callback(GBDATA *gbd, const DatabaseCallback &atClose)
void load_xfig(const char *file, bool resize=true)
const char * get_window_id() const
static const int SCALER_WIDTH
#define AWAR_SECEDIT_DISPLAY_SEARCH
void GB_unlink_or_warn(const char *path, GB_ERROR *error)
char * buildStructureString()
size_t get_x_string_length() const
AWT_canvas * canvas() const
void AW_create_standard_fileselection(AW_window *aws, const char *awar_prefix)
void AWT_insert_config_manager(AW_window *aww, AW_default default_file_, const char *id, const StoreConfigCallback &store_cb, const RestoreConfigCallback &load_or_reset_cb, const char *macro_id, const AWT_predefined_config *predef)
const BI_helix * get_helixDef() const
void create_default_bone()
const char * GBS_global_string(const char *templat,...)
void AW_POPDOWN(AW_window *window)
static AW_window * SEC_create_bonddef_window(AW_root *awr)
void init(SEC_graphic *gfx, AWT_canvas *scr, ED4_plugin_host &host)
void reset_layout(const char *YYYYMMDD)
#define AWAR_FOOTER_MAX_LEN
char * SEC_xstring_to_foldedHelixList(const char *x_string, size_t xlength, const BI_helix *helix, GB_ERROR &error)
static void SEC_center_cb(AW_window *, SEC_root *root)
static void SEC_sync_colors(AW_window *aww, SyncColors which)
#define AWAR_SECEDIT_BOND_THICKNESS
const LineVector & get_last_drawed_cursor_position() const
void AWT_popup_sec_export_window(AW_window *parent_win, AWT_canvas *scr)
SEC_structure_toggler * structure() const
AW_window * start_SECEDIT_plugin(ED4_plugin_host &host)
int create_mode(const char *pixmap, const char *help_text_, AW_active mask, const WindowCallback &cb)
WindowCallback makeHelpCallback(const char *helpfile)
#define MODE_TEXT_STANDARD_ZOOMMODE()
static void SEC_undo_cb(AW_window *, const SEC_db_interface *db, GB_UNDO_TYPE undo_type)
const XString & get_xString() const
const double & ypos() const
GB_ERROR expectedError(const char *expected)
char * SEC_foldedHelixList_to_xstring(const char *foldedHelices, size_t xlength, const BI_helix *helix, GB_ERROR &error)
const char * get_x_string() const
void set_show_constraints(SEC_BASE_TYPE show)
#define MODE_TEXT_1BUTTON(modeName, leftInfo)
string lineError(const string &msg) const
#define AWAR_SECEDIT_SHOW_STR_SKELETON
#define AWAR_SECEDIT_SAVEDIR
SEC_graphic * graphic() const
void create_menu(const char *name, const char *mnemonic, AW_active mask=AWM_ALL)
void help_text(const char *id)
SEC_loop * get_root_loop() const
const SEC_region * get_region() const
static void error(const char *msg)
#define AWAR_SECEDIT_HIDE_BASES
static void SEC_exit(GBDATA *, SEC_root *sec_root)
void restore_at_from(const AW_at_storage &stored)
virtual GBDATA * get_database() const =0
#define AWAR_SECEDIT_SHOW_DEBUG
#define AWAR_SECEDIT_SHOW_ECOLI_POS
bool perform_autoscroll()
SEC_root * secroot() const
static AW_window * SEC_create_display_window(AW_root *awr)
const Position & drawn_after(size_t abspos, size_t *after_abs) const
void AW_copy_GC_colors(AW_root *aw_root, const char *source_gcman, const char *dest_gcman, const char *id0,...)
char * read_string() const
#define AWAR_SECEDIT_SHOW_BONDS
#define AWAR_SECEDIT_SHOW_HELIX_NRS
#define AWAR_SECEDIT_DIST_BETW_STRANDS
AW_awar * awar(const char *awar)
const char * no_mode_text_defined()
static string scanToken(LineReader &file, string &rest, GB_ERROR &error)
#define AWAR_SECEDIT_BOND_SYMBOLS_EDIT4
static AW_window_menu_modes_opengl * awm
#define AWAR_SECEDIT_BOND_SYMBOLS_TRANS
static AW_at_storage * make(AW_window *aww, AW_at_storage_type type)
GB_ERROR GB_undo(GBDATA *gb_main, GB_UNDO_TYPE type) __ATTR__USERESULT
bool aw_ask_sure(const char *unique_id, const char *msg)
int aw_question(const char *unique_id, const char *question, const char *buttons, bool sameSizeButtons, const char *helpfile)
void set_info_area_height(int height)
fputs(TRACE_PREFIX, stderr)
GB_ERROR GB_export_errorf(const char *templat,...)
void set_mode(AWT_COMMAND_MODE mo)
void scroll(int delta_x, int delta_y, bool dont_update_scrollbars=false)
static void SEC_toggle_cb(AW_window *, const SEC_db_interface *db)
void auto_space(int xspace, int yspace)
void AW_help_entry_pressed(AW_window *aww)
static AWT_config_mapping_def secedit_display_config_mapping[]
AW_gc_manager * gc_manager
void add_autoscroll(const Vector &scroll)
GB_ERROR expectContent(LineReader &file, const char *expected)
GB_ERROR copyTo(const char *name)
static void SEC_new_structure(AW_window *, const SEC_db_interface *db)
void AWT_popup_print_window(AW_window *parent_win, AWT_canvas *scr)
#define AWAR_SECEDIT_DISPLAY_SAI
AWT_graphic_exports exports
void init_device(AW_device *device)
void init_toggler() const
#define AWAR_SECEDIT_DISPPOS_ECOLI
static void SEC_delete_structure(AW_window *, const SEC_db_interface *db)
const char * GBS_static_string(const char *str)
void aw_message(const char *msg)
const Position * drawn_at(size_t abs) const
const double & xpos() const
void invalidate_base_positions()
char * old_decode_xstring_rel_helix(GB_CSTR rel_helix, size_t xlength, const BI_helix *helix, int *no_of_helices_ptr)
int & get_modifying_flag_ref()
GB_ERROR write_string(const char *aw_string)
void position_cursor(bool toCenter, bool evenIfVisible)
static void SEC_fit_window_cb(AW_window *, const SEC_db_interface *db)
void callback(const WindowCallback &cb)
int get_at_yposition() const
static GB_ERROR expectToken(LineReader &file, const char *token, string &content)
char * aw_input(const char *title, const char *prompt, const char *default_input)
static AW_window * SEC_create_gc_window(AW_root *awr, AW_gc_manager *gcman)
virtual AW_root * get_application_root() const =0
#define AWAR_SECEDIT_DISPPOS_BINDING
void create_button(const char *macro_name, AW_label label, const char *mnemonic=NULp, const char *color=NULp)