void inventory_selector::print_right_column() const { if (right_column_width == 0) { return; } player &u = g->u; int drp_line = 1; drop_map::const_iterator dit = dropping.find(-1); if (dit != dropping.end()) { std::string item_name = u.weapname(); if (dit->second == -1) { item_name.insert(0, "+ "); } else { item_name = string_format("# %s {%d}", item_name.c_str(), dit->second); } const char invlet = invlet_or_space(u.weapon); item_name = trim_to(item_name, right_column_width - 2); // 2 for the invlet & space mvwprintz(w_inv, drp_line, right_column_offset, c_ltblue, "%c %s", invlet, item_name.c_str()); drp_line++; } for (size_t k = 0; k < u.worn.size(); k++) { // worn items can not be dropped partially if (dropping.count(player::worn_position_to_index(k)) == 0) { continue; } const char invlet = invlet_or_space(u.worn[k]); std::string item_name = trim_to(u.worn[k].display_name(), right_column_width - 4); // 2 for the invlet '+' & 2 space mvwprintz(w_inv, drp_line, right_column_offset, c_cyan, "%c + %s", invlet, item_name.c_str()); drp_line++; } for (drop_map::const_iterator a = dropping.begin(); a != dropping.end(); ++a) { if (a->first < 0) { // worn or wielded item, already displayed above continue; } const std::list<item> &stack = u.inv.const_stack(a->first); const item &it = stack.front(); const char invlet = invlet_or_space(it); const int count = a->second; const int display_count = (count == -1) ? (it.charges >= 0) ? it.charges : stack.size() : count; const nc_color col = it.color_in_inventory(); std::string item_name = it.tname( display_count ); if (count == -1) { if (stack.size() > 1) { item_name = string_format("%d %s", stack.size(), item_name.c_str()); } else { item_name.insert(0, "+ "); } } else { item_name = string_format("# %s {%d}", item_name.c_str(), count); } item_name = trim_to(item_name, right_column_width - 2); // 2 for the invlet & space mvwprintz(w_inv, drp_line, right_column_offset, col, "%c %s", invlet, item_name.c_str()); drp_line++; } }
void inventory_selector::print_column(const itemstack_vector &items, size_t y, size_t w, size_t selected, size_t current_page_offset) const { nc_color selected_line_color = inCategoryMode ? c_white_red : h_white; if ((&items == &this->items) != in_inventory) { selected_line_color = inCategoryMode ? c_ltgray_red : h_ltgray; } int cur_line = 2; for (size_t a = 0; a + current_page_offset < items.size() && a < items_per_page; a++, cur_line++) { const itemstack_or_category &cur_entry = items[a + current_page_offset]; if (cur_entry.category == NULL) { continue; } if (cur_entry.it == NULL) { const std::string name = trim_to(cur_entry.category->name, w); mvwprintz(w_inv, cur_line, y, c_magenta, "%s", name.c_str()); continue; } const item &it = *cur_entry.it; std::string item_name = it.display_name(); if (cur_entry.slice != NULL) { const size_t count = cur_entry.slice->size(); if (count > 1) { item_name = string_format("%d %s", count, it.display_name(count).c_str()); } } nc_color name_color = it.color_in_inventory(); nc_color invlet_color = c_white; if (a + current_page_offset == selected) { name_color = selected_line_color; invlet_color = selected_line_color; } item_name = get_drop_icon(dropping.find(cur_entry.item_pos)) + item_name; item_name = trim_to(item_name, w - 2); // 2 for the invlet & space if (it.invlet != 0) { mvwputch(w_inv, cur_line, y, invlet_color, it.invlet); } mvwprintz(w_inv, cur_line, y + 2, name_color, "%s", item_name.c_str()); } }
// Return succ/failure bool BF::set_high_end(const End &e) { if (!e.is_ge(0)) return false; if ((e.is_infinite() && low.type() == ET_wraparound) || (e.type() == ET_wraparound && low.is_infinite())) return false; high = e; tape.trim_values(low.bound(), high.bound()); eof_value = trim_to(eof_value, low.bound(), high.bound()); return true; }
// Return succ/failure bool BF::set_right_end(const End &e) { if (!e.is_infinite() && !tape.get_left().is_infinite() && tape.get_left().value() > e.value()) return false; if ((e.is_infinite() && type_left == ET_wraparound) || (e.type() == ET_wraparound && tape.get_left().is_infinite())) return false; tape.set_right(e.bound()); type_right = e.type(); position = trim_to(position, tape.get_left(), tape.get_right()); return true; }
int fftMatch_opt(char *inFile1, char *inFile2, float *offsetX, float *offsetY) { // Generate temporary directory char tmpDir[1024]; char metaFile[1024], outFile[1024], sarFile[1024], opticalFile[1024]; char *baseName = get_basename(inFile1); strcpy(tmpDir, baseName); strcat(tmpDir, "-"); strcat(tmpDir, time_stamp_dir()); create_clean_dir(tmpDir); // Cutting optical to SAR extent asfPrintStatus("Cutting optical to SAR extent ...\n"); sprintf(metaFile, "%s.meta", inFile1); sprintf(outFile, "%s%c%s_sub.img", tmpDir, DIR_SEPARATOR, inFile2); trim_to(inFile2, outFile, metaFile); // Clipping optical image including blackfill asfPrintStatus("\nClipping optical image including blackfill ...\n"); meta_parameters *metaOpt = meta_read(outFile); meta_parameters *metaSAR = meta_read(metaFile); int line_count = metaSAR->general->line_count; int sample_count = metaSAR->general->sample_count; float *floatLine = (float *) MALLOC(sizeof(float)*sample_count); unsigned char *byteLine = (unsigned char *) MALLOC(sizeof(char)*sample_count); FILE *fpOptical = FOPEN(outFile, "rb"); sprintf(sarFile, "%s.img", inFile1); FILE *fpSAR = FOPEN(sarFile, "rb"); sprintf(outFile, "%s%c%s_mask.img", tmpDir, DIR_SEPARATOR, inFile2); sprintf(metaFile, "%s%c%s_mask.meta", tmpDir, DIR_SEPARATOR, inFile2); FILE *fpOut = FOPEN(outFile, "wb"); int ii, kk; for (ii=0; ii<line_count; ii++) { get_float_line(fpSAR, metaSAR, ii, floatLine); get_byte_line(fpOptical, metaOpt, ii, byteLine); for (kk=0; kk<sample_count; kk++) { if (!FLOAT_EQUIVALENT(floatLine[kk], 0.0)) floatLine[kk] = (float) byteLine[kk]; } put_float_line(fpOut, metaSAR, ii, floatLine); } FCLOSE(fpOptical); FCLOSE(fpSAR); FCLOSE(fpOut); meta_write(metaSAR, metaFile); // Edge filtering optical image asfPrintStatus("\nEdge filtering optical image ...\n"); sprintf(opticalFile, "%s%c%s_sobel.img", tmpDir, DIR_SEPARATOR, inFile2); kernel_filter(outFile, opticalFile, SOBEL, 3, 0, 0); // Edge filtering SAR image asfPrintStatus("\nEdge filtering SAR image ...\n"); sprintf(sarFile, "%s%c%s_sobel.img", tmpDir, DIR_SEPARATOR, inFile1); kernel_filter(inFile1, sarFile, SOBEL, 3, 0, 0); // FFT matching on a grid asfPrintStatus("\nFFT matching on a grid ...\n"); float certainty; fftMatch_proj(sarFile, opticalFile, offsetX, offsetY, &certainty); // Clean up remove_dir(tmpDir); return (0); }