void WSortView::CheckSorted() { unmark_all(); // needed because iterator instrumentated algorithms may have changed the array RecalcInversions(); ArrayItem prev = get_nocount(0); mark(0); for (size_t i = 1; i < size(); ++i) { ArrayItem key = get_nocount(i); g_compare_count--; // dont count the following comparison if (!(prev <= key)) { wxLogError(_T("Result of sorting algorithm is incorrect!")); break; } mark(i); prev = key; } unmark_all(); m_is_sorted = true; }
void ship_select::OnOK() { int i; object *ptr; unmark_all(); update_status(); ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { if (ptr->flags & OF_TEMP_MARKED) mark_object(OBJ_INDEX(ptr)); ptr = GET_NEXT(ptr); } if (query_valid_object() && (Marked == 1) && (Objects[cur_object_index].type == OBJ_POINT)) { Assert(Briefing_dialog); Briefing_dialog->icon_select(Objects[cur_object_index].instance); } else { if (Briefing_dialog) Briefing_dialog->icon_select(-1); } filter_ships = m_filter_ships; filter_starts = m_filter_starts; filter_waypoints = m_filter_waypoints; for (i = 0; i < MAX_IFFS; i++) filter_iff[i] = m_filter_iff[i]; CDialog::OnOK(); }
void ship_select::OnOK() { object *ptr; unmark_all(); update_status(); ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { if (ptr->flags & OF_TEMP_MARKED) mark_object(OBJ_INDEX(ptr)); ptr = GET_NEXT(ptr); } if (query_valid_object() && (Marked == 1) && (Objects[cur_object_index].type == OBJ_POINT)) { Assert(Briefing_dialog); Briefing_dialog->icon_select(Objects[cur_object_index].instance); } else { if (Briefing_dialog) Briefing_dialog->icon_select(-1); } filter_ships = m_filter_ships; filter_starts = m_filter_starts; filter_waypoints = m_filter_waypoints; filter_friendly = m_filter_friendly; filter_hostile = m_filter_hostile; filter_neutral = m_filter_neutral; filter_unknown = m_filter_unknown; CDialog::OnOK(); }
void event_list::verify_and_link (midipulse slength) { clear_links(); for (event_list::iterator on = m_events.begin(); on != m_events.end(); on++) { event & eon = dref(on); if (eon.is_note_on()) /* Note On, find its Note Off */ { event_list::iterator off = on; /* get next possible Note Off */ off++; bool endfound = false; while (off != m_events.end()) { event & eoff = dref(off); if /* Off, == notes, not marked */ ( eoff.is_note_off() && eoff.get_note() == eon.get_note() && ! eoff.is_marked() ) { eon.link(&eoff); /* link + mark */ eoff.link(&eon); eon.mark(); eoff.mark(); endfound = true; break; } off++; } if (! endfound) { off = m_events.begin(); while (off != on) { event & eoff = dref(off); if ( eoff.is_note_off() && eoff.get_note() == eon.get_note() && ! eoff.is_marked() ) { eon.link(&eoff); /* link + mark */ eoff.link(&eon); eon.mark(); eoff.mark(); endfound = true; break; } off++; } } } } unmark_all(); mark_out_of_range(slength); }
void mark_wing(int wing) { int i; unmark_all(); Assert(Wings[wing].special_ship >= 0 && Wings[wing].special_ship < Wings[wing].wave_count); set_cur_object_index(wing_objects[wing][Wings[wing].special_ship]); for (i=0; i<Wings[wing].wave_count; i++) mark_object(wing_objects[wing][i]); }
void BrowserNode::mark_management(int choice) { BrowserNode * bn; switch (choice) { case 0: case 1: // mark / unmark toggle_mark(); return; case 2: // unmark all unmark_all(); return; case 3: // move into for (bn = marked_list.last(); bn != 0; bn = marked_list.prev()) move(bn, 0); break; case 4: // move after { BrowserNode * p = (BrowserNode *) parent(); for (bn = marked_list.last(); bn != 0; bn = marked_list.prev()) p->move(bn, this); } break; case 5: // duplicate into for (bn = marked_list.last(); bn != 0; bn = marked_list.prev()) move(bn->duplicate(this), 0); break; #ifndef SIMPLE_DUPLICATION case 6: // duplicate recursivelly into break; #endif case 7: // duplicate after { BrowserNode * p = (BrowserNode *) parent(); for (bn = marked_list.last(); bn != 0; bn = marked_list.prev()) p->move(bn->duplicate(p), this); } break; #ifndef SIMPLE_DUPLICATION case 8: // duplicate recursivelly after break; #endif } }
ReferenceDialog::ReferenceDialog(BrowserNode * bn) : QDialog(0/*, "Referenced By dialog", Qt::WA_DeleteOnClose*/) { the = this; target = bn; setWindowTitle(tr("Referenced By dialog")); QVBoxLayout * vbox = new QVBoxLayout(this); vbox->setMargin(5); QString s = target->get_name(); s += QObject::tr(" is referenced by :"); vbox->addWidget(new QLabel(s, this)); results = new QComboBox(this); vbox->addWidget(results); QHBoxLayout * hbox = new QHBoxLayout(); vbox->addLayout(hbox); QPushButton * search_b = new QPushButton(tr("Recompute"), this); QPushButton * close_b = new QPushButton(tr("Close"), this); hbox->setMargin(5); hbox->addWidget(search_b); hbox->addWidget(select_b = new QPushButton(tr("Select"), this)); hbox->addWidget(mark_unmark_b = new QPushButton(tr("Unmark"), this)); hbox->addWidget(mark_them_b = new QPushButton(tr("Mark them"), this)); hbox->addWidget(unmark_all_b = new QPushButton(tr("Unmark all"), this)); hbox->addWidget(close_b); search_b->setDefault(TRUE); connect(search_b, SIGNAL(clicked()), this, SLOT(compute())); connect(select_b, SIGNAL(clicked()), this, SLOT(select())); connect(close_b, SIGNAL(clicked()), this, SLOT(reject())); connect(mark_unmark_b, SIGNAL(clicked()), this, SLOT(mark_unmark())); connect(mark_them_b, SIGNAL(clicked()), this, SLOT(mark_them())); connect(unmark_all_b, SIGNAL(clicked()), this, SLOT(unmark_all())); connect(results, SIGNAL(activated(int)), this, SLOT(selected(int))); compute(); open_dialog(this); }
ReferenceDialog::ReferenceDialog(BrowserNode * bn) : QDialog(0, "Referenced By dialog", FALSE, Qt::WDestructiveClose) { the = this; target = bn; setCaption(TR("Referenced By dialog")); Q3VBoxLayout * vbox = new Q3VBoxLayout(this); vbox->setMargin(5); QString s = target->get_name(); s += TR(" is referenced by :"); vbox->addWidget(new QLabel(s, this)); results = new Q3ComboBox(FALSE, this); vbox->addWidget(results); Q3HBoxLayout * hbox = new Q3HBoxLayout(vbox); QPushButton * search_b = new QPushButton(TR("Recompute"), this); QPushButton * close_b = new QPushButton(TR("Close"), this); hbox->setMargin(5); hbox->addWidget(search_b); hbox->addWidget(select_b = new QPushButton(TR("Select"), this)); hbox->addWidget(mark_unmark_b = new QPushButton(TR("Unmark"), this)); hbox->addWidget(mark_them_b = new QPushButton(TR("Mark them"), this)); hbox->addWidget(unmark_all_b = new QPushButton(TR("Unmark all"), this)); hbox->addWidget(close_b); search_b->setDefault(TRUE); connect(search_b, SIGNAL(clicked()), this, SLOT(compute())); connect(select_b, SIGNAL(clicked()), this, SLOT(select())); connect(close_b, SIGNAL(clicked()), this, SLOT(reject())); connect(mark_unmark_b, SIGNAL(clicked()), this, SLOT(mark_unmark())); connect(mark_them_b, SIGNAL(clicked()), this, SLOT(mark_them())); connect(unmark_all_b, SIGNAL(clicked()), this, SLOT(unmark_all())); connect(results, SIGNAL(activated(int)), this, SLOT(selected(int))); compute(); open_dialog(this); }
void WSortView::FinishFill() { ASSERT(m_array.size() > 0); // calculate max value in array m_array_max = m_array[0].get_direct(); for (size_t i = 1; i < size(); ++i) { if (m_array_max < m_array[i].get_direct()) m_array_max = m_array[i].get_direct(); } // reset access markers unmark_all(); unwatch_all(); // reset counters and info m_is_sorted = false; g_access_count = 0; g_compare_count = 0; m_calc_inversions = true; RecalcInversions(); }
BrowserSearchDialog::BrowserSearchDialog() : QDialog(0, "Browser search", FALSE, Qt::WDestructiveClose) { the = this; setCaption(TR("Browser search")); Q3VBoxLayout * vbox = new Q3VBoxLayout(this); vbox->setMargin(5); Q3GridLayout * gl = new Q3GridLayout(vbox, 4, 2, 5/*space*/); gl->addWidget(new QLabel(TR("Kind"), this), 0, 0, Qt::AlignLeft); kind = new Q3ComboBox(FALSE, this); for (int index = 0; index != sizeof(Kinds) / sizeof(*Kinds); index += 1) kind->insertItem(TR(Kinds[index].lbl)); kind->setCurrentItem(saved_kind); gl->addWidget(kind, 0, 1); ed = new LineEdit(this); ed->setText(saved_ed); gl->addWidget(new QLabel(TR("Containing"), this), 1, 0, Qt::AlignLeft); gl->addWidget(ed, 1, 1); ed->setFocus(); Q3HBox * hb = new Q3HBox(this); gl->addWidget(hb, 2, 1); Q3GroupBox * gb = new Q3GroupBox(2, Qt::Horizontal, hb); case_sensitive = new QCheckBox(TR("case sensitive"), gb); case_sensitive->setChecked(saved_case_sensitive); even_deleted = new QCheckBox(TR("even deleted"), gb); even_deleted->setChecked(saved_even_deleted); Q3ButtonGroup * bg = new Q3ButtonGroup(4, Qt::Horizontal, hb); bg->setExclusive(TRUE); for_name = new QRadioButton(TR("name"), bg); for_name->setChecked(saved_name); for_stereotype = new QRadioButton(TR("stereotype"), bg); for_stereotype->setChecked(saved_stereotype); for_comment = new QRadioButton(TR("description"), bg); for_comment->setChecked(saved_comment); for_decldefbody = new QRadioButton(TR("declaration/definition/body"), bg); for_decldefbody->setChecked(saved_decldefbody); gl->addWidget(new QLabel(TR("Result"), this), 3, 0, Qt::AlignLeft); results = new Q3ComboBox(FALSE, this); gl->addWidget(results, 3, 1); Q3HBoxLayout * hbox = new Q3HBoxLayout(vbox); QPushButton * search_b = new QPushButton(TR("Search"), this); QPushButton * close_b = new QPushButton(TR("Close"), this); hbox->setMargin(5); hbox->addWidget(search_b); hbox->addWidget(select_b = new QPushButton(TR("Select"), this)); hbox->addWidget(mark_unmark_b = new QPushButton(TR("Unmark"), this)); hbox->addWidget(mark_them_b = new QPushButton(TR("Mark them"), this)); hbox->addWidget(unmark_all_b = new QPushButton(TR("Unmark all"), this)); hbox->addWidget(close_b); search_b->setDefault(TRUE); connect(search_b, SIGNAL(clicked()), this, SLOT(search())); connect(select_b, SIGNAL(clicked()), this, SLOT(select())); connect(close_b, SIGNAL(clicked()), this, SLOT(reject())); connect(mark_unmark_b, SIGNAL(clicked()), this, SLOT(mark_unmark())); connect(mark_them_b, SIGNAL(clicked()), this, SLOT(mark_them())); connect(unmark_all_b, SIGNAL(clicked()), this, SLOT(unmark_all())); connect(results, SIGNAL(activated(int)), this, SLOT(selected(int))); if ((saved_kind != 0) || !saved_ed.isEmpty()) search(); else selected(-1); open_dialog(this); }
void briefing_editor_dlg::OnMakeIcon() { char *name; int z, len, team, ship, waypoint, count = -1; int cargo = 0, cargo_count = 0, freighter_count = 0; object *ptr; vec3d min, max, pos; brief_icon *iconp; if (Briefing->stages[m_cur_stage].num_icons >= MAX_STAGE_ICONS) return; m_cur_icon = Briefing->stages[m_cur_stage].num_icons++; iconp = &Briefing->stages[m_cur_stage].icons[m_cur_icon]; ship = waypoint = -1; team = 0; jump_node *jnp = NULL; vm_vec_make(&min, 9e19f, 9e19f, 9e19f); vm_vec_make(&max, -9e19f, -9e19f, -9e19f); ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { if (ptr->flags & OF_MARKED) { if (ptr->pos.xyz.x < min.xyz.x) min.xyz.x = ptr->pos.xyz.x; if (ptr->pos.xyz.x > max.xyz.x) max.xyz.x = ptr->pos.xyz.x; if (ptr->pos.xyz.y < min.xyz.y) min.xyz.y = ptr->pos.xyz.y; if (ptr->pos.xyz.y > max.xyz.y) max.xyz.y = ptr->pos.xyz.y; if (ptr->pos.xyz.z < min.xyz.z) min.xyz.z = ptr->pos.xyz.z; if (ptr->pos.xyz.z > max.xyz.z) max.xyz.z = ptr->pos.xyz.z; switch (ptr->type) { case OBJ_SHIP: case OBJ_START: ship = ptr->instance; break; case OBJ_WAYPOINT: waypoint = ptr->instance; break; case OBJ_JUMP_NODE: jnp = ptr->jnp; break; default: Int3(); } if (ship >= 0) { team = Ships[ship].team; z = ship_query_general_type(ship); if (Ship_info[Ships[ship].ship_info_index].flags & SIF_CARGO) cargo_count++; if (Ship_info[Ships[ship].ship_info_index].flags & SIF_FREIGHTER) { // direct docked with any marked cargo? for (dock_instance *dock_ptr = ptr->dock_list; dock_ptr != NULL; dock_ptr = dock_ptr->next) { if (dock_ptr->docked_objp->flags & OF_MARKED) { if (Ship_info[Ships[dock_ptr->docked_objp->instance].ship_info_index].flags & SIF_CARGO) freighter_count++; } } } } count++; } ptr = GET_NEXT(ptr); } if (cargo_count && cargo_count == freighter_count) cargo = 1; vm_vec_avg(&pos, &min, &max); if (ship >= 0) name = Ships[ship].ship_name; else if (waypoint >= 0) name = Waypoint_lists[waypoint / 65536].name; else if (jnp != NULL) name = jnp->get_name_ptr(); else return; len = strlen(name); if (len >= MAX_LABEL_LEN - 1) len = MAX_LABEL_LEN - 1; strncpy(iconp->label, name, len); iconp->label[len] = 0; // iconp->text[0] = 0; iconp->type = 0; iconp->team = team; iconp->pos = pos; iconp->flags = 0; iconp->id = Cur_brief_id++; if (ship >= 0) { iconp->ship_class = Ships[ship].ship_info_index; switch (Ship_info[Ships[ship].ship_info_index].flags & SIF_ALL_SHIP_TYPES) { case SIF_KNOSSOS_DEVICE: iconp->type = ICON_KNOSSOS_DEVICE; break; case SIF_CORVETTE: iconp->type = ICON_CORVETTE; break; case SIF_GAS_MINER: iconp->type = ICON_GAS_MINER; break; case SIF_SUPERCAP: iconp->type = ICON_SUPERCAP; break; case SIF_SENTRYGUN: iconp->type = ICON_SENTRYGUN; break; case SIF_AWACS: iconp->type = ICON_AWACS; break; case SIF_CARGO: if (cargo) iconp->type = (count == 1) ? ICON_FREIGHTER_WITH_CARGO : ICON_FREIGHTER_WING_WITH_CARGO; else iconp->type = count ? ICON_CARGO_WING : ICON_CARGO; break; case SIF_SUPPORT: iconp->type = ICON_SUPPORT_SHIP; break; case SIF_FIGHTER: iconp->type = count ? ICON_FIGHTER_WING : ICON_FIGHTER; break; case SIF_BOMBER: iconp->type = count ? ICON_BOMBER_WING : ICON_BOMBER; break; case SIF_FREIGHTER: if (cargo) iconp->type = (count == 1) ? ICON_FREIGHTER_WITH_CARGO : ICON_FREIGHTER_WING_WITH_CARGO; else iconp->type = count ? ICON_FREIGHTER_WING_NO_CARGO : ICON_FREIGHTER_NO_CARGO; break; case SIF_CRUISER: iconp->type = count ? ICON_CRUISER_WING : ICON_CRUISER; break; case SIF_TRANSPORT: iconp->type = count ? ICON_TRANSPORT_WING : ICON_TRANSPORT; break; case SIF_CAPITAL: case SIF_DRYDOCK: iconp->type = ICON_CAPITAL; break; case SIF_NAVBUOY: iconp->type = ICON_WAYPOINT; break; default: iconp->type = ICON_ASTEROID_FIELD; break; } } // jumpnodes else if(jnp != NULL){ // find the first navbuoy iconp->ship_class = -1; for (int i = 0; i < Num_ship_classes; i++) { if (Ship_info[i].flags & SIF_NAVBUOY) { iconp->ship_class = i; break; } } iconp->type = ICON_JUMP_NODE; } // everything else else { // find the first navbuoy iconp->ship_class = -1; for (int i = 0; i < Num_ship_classes; i++) { if (Ship_info[i].flags & SIF_NAVBUOY) { iconp->ship_class = i; break; } } iconp->type = ICON_WAYPOINT; } if (!m_change_local){ propagate_icon(m_cur_icon); } icon_obj[m_cur_icon] = obj_create(OBJ_POINT, -1, m_cur_icon, NULL, &pos, 0.0f, OF_RENDERS); Assert(icon_obj[m_cur_icon] >= 0); obj_merge_created_list(); unmark_all(); set_cur_object_index(icon_obj[m_cur_icon]); GetDlgItem(IDC_MAKE_ICON) -> EnableWindow(FALSE); GetDlgItem(IDC_PROPAGATE_ICONS) -> EnableWindow(TRUE); update_data(1); }