void BrowserClassInstance::compute_referenced_by(QList<BrowserNode *> & l, BrowserNode * target) { IdIterator<BrowserClassInstance> it(all); while(it.hasNext()){ it.next(); if(it.value()) { if (!it.value()->deletedp()) { ClassInstanceData * data = it.value()->def; bool add = (data->get_class() == target); if (!add && (target->get_type() == UmlAttribute)) { const QList<SlotAttr> & attrs = data->get_attributes(); QList<SlotAttr>::ConstIterator it_a; for (it_a = attrs.begin(); it_a != attrs.end(); ++it_a) { if ((*it_a).att == target) { add = TRUE; break; } } } if (!add) { const QList<SlotRel> & rels = data->get_relations(); QList<SlotRel>::ConstIterator it_r; for (it_r = rels.begin(); it_r != rels.end(); ++it_r) { const SlotRel & slot = *it_r; if ((slot.is_a) ? (slot.rel->get_start() == target) : (slot.rel->get_end() == target)) { add = TRUE; break; } if (slot.value == target) { add = TRUE; break; } } } if (add) l.append(it.value()); } } } }
void OdClassInstCanvas::compute_size() { UmlCanvas * canvas = the_canvas(); ClassInstanceData * data = (ClassInstanceData *) browser_node->get_data(); used_color = (itscolor == UmlDefaultColor) ? canvas->browser_diagram()->get_color(UmlClass) : itscolor; switch (show_stereotype_properties) { case UmlYes: show_properties = TRUE; break; case UmlNo: show_properties = FALSE; break; default: // right arg set by the diagram itself show_properties = canvas->browser_diagram()->get_show_stereotype_properties(); } QFontMetrics fm(canvas->get_font(UmlNormalUnderlinedFont)); double zoom = canvas->zoom(); const int two = (int)(2 * zoom); int wi, he; horiz = TRUE; if (!get_name().isEmpty()) { switch (write_horizontally) { case UmlYes: horiz = TRUE; break; case UmlNo: horiz = FALSE; break; default: // right get_classinstwritehorizontally arg set by the diagram itself horiz = canvas->browser_diagram()->get_classinstwritehorizontally(); } } he = fm.height() + two + two; used_show_context_mode = (show_context_mode == DefaultShowContextMode) ? canvas->browser_diagram()->get_classinstshowmode() : show_context_mode; if (horiz) wi = fm.width(full_name()); else { he += fm.height(); int w = fm.width(get_name() + ":"); wi = fm.width(data->get_class()->contextual_name(used_show_context_mode)); if (w > wi) wi = w; } const Q3ValueList<SlotAttr> & attributes = data->get_attributes(); if (! attributes.isEmpty()) { Q3ValueList<SlotAttr>::ConstIterator it = attributes.begin(); QString egal = " = "; do { QString s = (*it).att->get_name() + egal + (*it).value; int w = fm.width(s); if (w > wi) wi = w; ++it; } while (it != attributes.end()); he += (fm.height() + two) * attributes.count() + two + two; } if (used_color != UmlTransparent) { const int shadow = canvas->shadow(); wi += shadow; he += shadow; } const int eight = (int)(8 * zoom); wi += (((ClassData *) data->get_class()->get_data())->get_is_active()) ? eight * 3 : eight; int minw = (int)(zoom * CLASSINST_CANVAS_MIN_SIZE); if (wi < minw) wi = minw; // force odd width and height for line alignment DiagramCanvas::resize(wi | 1, he | 1); }