static DiaObject * image_load(ObjectNode obj_node, int version, DiaContext *ctx) { Image *image; Element *elem; DiaObject *obj; int i; AttributeNode attr; char *diafile_dir; image = g_malloc0(sizeof(Image)); elem = &image->element; obj = &elem->object; obj->type = &image_type; obj->ops = &image_ops; element_load(elem, obj_node, ctx); image->border_width = 0.1; attr = object_find_attribute(obj_node, "border_width"); if (attr != NULL) image->border_width = data_real(attribute_first_data(attr), ctx); image->border_color = color_black; attr = object_find_attribute(obj_node, "border_color"); if (attr != NULL) data_color(attribute_first_data(attr), &image->border_color, ctx); image->line_style = LINESTYLE_SOLID; attr = object_find_attribute(obj_node, "line_style"); if (attr != NULL) image->line_style = data_enum(attribute_first_data(attr), ctx); image->dashlength = DEFAULT_LINESTYLE_DASHLEN; attr = object_find_attribute(obj_node, "dashlength"); if (attr != NULL) image->dashlength = data_real(attribute_first_data(attr), ctx); image->draw_border = TRUE; attr = object_find_attribute(obj_node, "draw_border"); if (attr != NULL) image->draw_border = data_boolean(attribute_first_data(attr), ctx); image->keep_aspect = TRUE; attr = object_find_attribute(obj_node, "keep_aspect"); if (attr != NULL) image->keep_aspect = data_boolean(attribute_first_data(attr), ctx); attr = object_find_attribute(obj_node, "file"); if (attr != NULL) { image->file = data_filename(attribute_first_data(attr), ctx); } else { image->file = g_strdup(""); } element_init(elem, 8, NUM_CONNECTIONS); for (i=0;i<NUM_CONNECTIONS;i++) { obj->connections[i] = &image->connections[i]; image->connections[i].object = obj; image->connections[i].connected = NULL; } image->connections[8].flags = CP_FLAGS_MAIN; image->image = NULL; if (strcmp(image->file, "")!=0) { diafile_dir = get_directory(dia_context_get_filename(ctx)); if (g_path_is_absolute(image->file)) { /* Absolute pathname */ image->image = dia_image_load(image->file); if (image->image == NULL) { /* Not found as abs path, try in same dir as diagram. */ char *temp_string; const char *image_file_name = image->file; const char *psep; psep = strrchr(image->file, G_DIR_SEPARATOR); /* try the other G_OS as well */ if (!psep) psep = strrchr(image->file, G_DIR_SEPARATOR == '/' ? '\\' : '/'); if (psep) image_file_name = psep + 1; temp_string = g_build_filename(diafile_dir, image_file_name, NULL); image->image = dia_image_load(temp_string); if (image->image != NULL) { /* Found file in same dir as diagram. */ message_warning(_("The image file '%s' was not found in the specified directory.\n" "Using the file '%s' instead.\n"), image->file, temp_string); g_free(image->file); image->file = temp_string; } else { g_free(temp_string); image->image = dia_image_load((char *)image_file_name); if (image->image != NULL) { char *tmp; /* Found file in current dir. */ message_warning(_("The image file '%s' was not found in the specified directory.\n" "Using the file '%s' instead.\n"), image->file, image_file_name); tmp = image->file; image->file = g_strdup(image_file_name); g_free(tmp); } else { message_warning(_("The image file '%s' was not found.\n"), image_file_name); } } } } else { /* Relative pathname: */ char *temp_string; temp_string = g_build_filename (diafile_dir, image->file, NULL); image->image = dia_image_load(temp_string); if (image->image != NULL) { /* Found file in same dir as diagram. */ g_free(image->file); image->file = temp_string; } else { g_free(temp_string); image->image = dia_image_load(image->file); if (image->image == NULL) { /* Didn't find file in current dir. */ message_warning(_("The image file '%s' was not found.\n"), image->file); } } } g_free(diafile_dir); } /* if we don't have an image yet try to recover it from inlined data */ if (!image->image) { attr = object_find_attribute(obj_node, "pixbuf"); if (attr != NULL) { GdkPixbuf *pixbuf = data_pixbuf (attribute_first_data(attr)); if (pixbuf) { image->image = dia_image_new_from_pixbuf (pixbuf); image->inline_data = TRUE; /* avoid loosing it */ /* FIXME: should we reset the filename? */ g_object_unref (pixbuf); } } } /* update mtime */ { struct stat st; if (g_stat (image->file, &st) != 0) st.st_mtime = 0; image->mtime = st.st_mtime; } image_update_data(image); return &image->element.object; }
static DiaObject * image_load(ObjectNode obj_node, int version, const char *filename) { EImage *image; Element *elem; DiaObject *obj; int i; AttributeNode attr; char *diafile_dir; Diagram *dia; GList *list; image = g_malloc0(sizeof(EImage)); elem = &image->element; obj = &elem->object; obj->type = &eimage_type; obj->ops = &eimage_ops; element_load(elem, obj_node); image->border_width = 0.1; attr = object_find_attribute(obj_node, "border_width"); if (attr != NULL) image->border_width = data_real( attribute_first_data(attr) ); image->border_color = color_black; attr = object_find_attribute(obj_node, "border_color"); if (attr != NULL) data_color(attribute_first_data(attr), &image->border_color); image->line_style = LINESTYLE_SOLID; attr = object_find_attribute(obj_node, "line_style"); if (attr != NULL) image->line_style = data_enum( attribute_first_data(attr) ); image->dashlength = DEFAULT_LINESTYLE_DASHLEN; attr = object_find_attribute(obj_node, "dashlength"); if (attr != NULL) image->dashlength = data_real(attribute_first_data(attr)); image->draw_border = TRUE; attr = object_find_attribute(obj_node, "draw_border"); if (attr != NULL) image->draw_border = data_boolean( attribute_first_data(attr) ); image->keep_aspect = TRUE; attr = object_find_attribute(obj_node, "keep_aspect"); if (attr != NULL) image->keep_aspect = data_boolean( attribute_first_data(attr) ); image->keep_orig_aspect = TRUE; attr = object_find_attribute(obj_node, "keep_orig_aspect"); if (attr != NULL) image->keep_orig_aspect = data_boolean( attribute_first_data(attr) ); attr = object_find_attribute(obj_node, "file"); if (attr != NULL) { image->file = data_filename( attribute_first_data(attr) ); } else { image->file = g_strdup(""); } attr = object_find_attribute(obj_node, "embed_id"); if (attr) { image->embed_id = dtree_conv_longname_from_xml(data_string(attribute_first_data(attr))); } else { image->embed_id = get_default_embed_id("embed_image"); } register_embed_id(image->embed_id); element_init(elem, 8, NUM_CONNECTIONS); for (i=0;i<NUM_CONNECTIONS;i++) { obj->connections[i] = &image->connections[i]; image->connections[i].object = obj; image->connections[i].connected = NULL; } image->connections[8].flags = CP_FLAGS_MAIN; image->image = NULL; if (strcmp(image->file, "")!=0) { diafile_dir = get_directory(filename); if (g_path_is_absolute(image->file)) { /* Absolute pathname */ image->image = dia_image_load(image->file); if (image->image == NULL) { /* Not found as abs path, try in same dir as diagram. */ char *temp_string; const char *image_file_name = image->file; const char *psep; psep = strrchr(image->file, G_DIR_SEPARATOR); /* try the other G_OS as well */ if (!psep) psep = strrchr(image->file, G_DIR_SEPARATOR == '/' ? '\\' : '/'); if (psep) image_file_name = psep + 1; temp_string = g_build_filename(diafile_dir, image_file_name, NULL); image->image = dia_image_load(temp_string); if (image->image != NULL) { /* Found file in same dir as diagram. */ message_warning(_("The image file '%s' was not found in that directory.\n" "Using the file '%s' instead\n"), image->file, temp_string); g_free(image->file); image->file = temp_string; } else { g_free(temp_string); image->image = dia_image_load((char *)image_file_name); if (image->image != NULL) { char *tmp; /* Found file in current dir. */ message_warning(_("The image file '%s' was not found in that directory.\n" "Using the file '%s' instead\n"), image->file, image_file_name); tmp = image->file; image->file = g_strdup(image_file_name); g_free(tmp); } else { message_warning(_("The image file '%s' was not found.\n"), image_file_name); } } } } else { /* Relative pathname: */ char *temp_string; temp_string = g_build_filename (diafile_dir, image->file, NULL); image->image = dia_image_load(temp_string); if (image->image != NULL) { /* Found file in same dir as diagram. */ g_free(image->file); image->file = temp_string; } else { g_free(temp_string); image->image = dia_image_load(image->file); if (image->image == NULL) { /* Didn't find file in current dir. */ message_warning(_("The image file '%s' was not found.\n"), image->file); } } } g_free(diafile_dir); } /* update mtime */ { struct stat st; if (g_stat (image->file, &st) != 0) st.st_mtime = 0; image->mtime = st.st_mtime; } image_update_data(image); obj->node = NULL; list = dia_open_diagrams(); while (list != NULL) { dia = (Diagram *)list->data; if (!g_strcmp0(dia->filename,filename)) { obj->node = dtree_set_data_by_longname(DIA_DIAGRAM_DATA(dia)->dtree, image->embed_id,&image->element.object); } list = g_list_next(list); } return &image->element.object; }
int main(int argc, const char **argv) { Parameters par(argc, argv); #ifdef HHSEARCH HHsearch::ProcessAllArguments(par); #elif HHALIGN HHalign::ProcessAllArguments(par); #else HHblits::ProcessAllArguments(par); #endif // hhblits_mpi will be parallelized with openmpi, no other parallelization par.threads = 1; #ifdef OPENMP omp_set_num_threads(1); #endif std::string data_filename(par.infile); data_filename.append(".ffdata"); std::string index_filename(par.infile); index_filename.append(".ffindex"); FFindexDatabase reader(data_filename.c_str(), index_filename.c_str(), false); reader.ensureLinearAccess(); int mpq_status = MPQ_Init(argc, argv, reader.db_index->n_entries); if (mpq_status == MPQ_SUCCESS) { if (MPQ_rank == MPQ_MASTER) { MPQ_Master(1); } else { std::vector<OutputFFIndex> outputDatabases; makeOutputFFIndex(par.outfile, MPQ_rank, &HHblits::writeHHRFile, outputDatabases); makeOutputFFIndex(par.scorefile, MPQ_rank, &HHblits::writeScoresFile, outputDatabases); makeOutputFFIndex(par.pairwisealisfile, MPQ_rank, &HHblits::writePairwiseAlisFile, outputDatabases); makeOutputFFIndex(par.alitabfile, MPQ_rank, &HHblits::writeAlitabFile, outputDatabases); makeOutputFFIndex(par.psifile, MPQ_rank, &HHblits::writePsiFile, outputDatabases); makeOutputFFIndex(par.hhmfile, MPQ_rank, &HHblits::writeHMMFile, outputDatabases); makeOutputFFIndex(par.alnfile, MPQ_rank, &HHblits::writeA3MFile, outputDatabases); makeOutputFFIndex(par.matrices_output_file, MPQ_rank, &HHblits::writeMatricesFile, outputDatabases); makeOutputFFIndex(par.m8file, MPQ_rank, &HHblits::writeM8, outputDatabases); std::vector<HHblitsDatabase*> databases; #ifdef HHSEARCH HHsearch::prepareDatabases(par, databases); HHblits app(par, databases); #elif HHalign HHalign app(par); #else HHblits::prepareDatabases(par, databases); HHblits app(par, databases); #endif HHblits_MPQ_Wrapper wrapper(reader.db_data, reader.db_index, app, outputDatabases); MPQ_Worker(payload, &wrapper); for (size_t i = 0; i < outputDatabases.size(); i++) { outputDatabases[i].close(); } } MPI_Barrier(MPI_COMM_WORLD); if (MPQ_rank == MPQ_MASTER) { merge_splits(par.outfile); merge_splits(par.scorefile); merge_splits(par.pairwisealisfile); merge_splits(par.alitabfile); merge_splits(par.psifile); merge_splits(par.hhmfile); merge_splits(par.alnfile); merge_splits(par.matrices_output_file); merge_splits(par.m8file); } } else { if (mpq_status == MPQ_ERROR_NO_WORKERS) { fprintf(stderr, "MPQ_Init: Needs at least one worker process.\n"); exit(EXIT_FAILURE); } } MPI_Finalize(); return EXIT_SUCCESS; }