Пример #1
0
void UmlRelation::search_class_assoc() {
  if (side(TRUE) != this)
    return;
    
  switch (relationKind()) {
  case aGeneralisation:
  case aRealization:
  case aDependency:
    break;
  default:
    {
      UmlTypeSpec a = association();
      
      if (a.type != 0) {
	// not generated for actors
	UmlItem * p = parent();
	
	if (p->stereotype() != "actor") {
	  do {
	    p = p->parent();
	  } while (p->kind() == aClass);
	  if (p->kind() == aClassView)
	    _assoc_class = a.type->set_assoc(this);
	}
      }
    }
  }
}
Пример #2
0
static void model_edge(Agraph_t *model, Agedge_t *orig)
{
	Agedge_t	*e;
	Agnode_t	*low, *high, *u, *v;
	port_t		lowport, highport;
	vpath_t		*path;
	rep_t			rep;
	int				i;

	rep = association(model,orig);
	if (rep.type == 0) {
		low = orig->tail; high = orig->head;
		getlowhigh(&low,&high);
		u = association(model,low).p; assert(u);
		v = association(model,high).p; assert(v);
		path = newpath(model,u,ND_rank(low),v,ND_rank(high));
		rep.type = PATH;
		rep.p = path;
		associate(model,orig,rep);
	}
	else path = rep.p;

	/* merge the attributes of orig */
	for (i = path->low; i < path->high; i++) {
		e = path->e[i];
		ED_xpenalty(e) += ED_xpenalty(orig);
		ED_weight(e) += ED_weight(orig);
	}

	/* deal with ports.  note that ends could be swapped! */
	if (ND_rank(orig->tail) <= ND_rank(orig->head)) {
		lowport = ED_tailport(orig);
		highport = ED_headport(orig);
	}
	else {
		highport = ED_tailport(orig);
		lowport = ED_headport(orig);
	}
	if (lowport.defined)
		path->avgtailport = ((path->weight * path->avgtailport) + ED_weight(orig) * lowport.p.x) / (path->weight + ED_weight(orig));
	if (highport.defined)
		path->avgheadport = ((path->weight * path->avgheadport) + ED_weight(orig) * highport.p.x) / (path->weight + ED_weight(orig));
	path->weight += ED_weight(orig);
}
Пример #3
0
void UmlRelation::compute_dependency(Q3PtrList<CppRefType> & dependencies,
				     const Q3CString & cl_stereotype,
				     bool all_in_h) {
  if (cl_stereotype == "enum")
    return;
  
  switch (relationKind()) {
  case aDependency:
    if (stereotype() == "friend")
      break;
    CppRefType::add(roleType(), dependencies, cppDecl() != "#include in source",
		    roleType()->isCppExternal());
    break;
  case aGeneralisation:
  case aRealization:
    CppRefType::add(roleType(), dependencies, TRUE);
    break;
  default:
    Q3CString decl = cppDecl();
    int index;
    
    if ((index = decl.find("${static}")) != -1)
      decl.remove((unsigned) index, 9);
    if ((index = decl.find("${mutable}")) != -1)
      decl.remove((unsigned) index, 10);
    if ((index = decl.find("${volatile}")) != -1)
      decl.remove((unsigned) index, 11);
    if ((index = decl.find("${const}")) != -1)
      decl.remove((unsigned) index, 8);
    if ((index = decl.find("${multiplicity}")) != -1)
      decl.remove((unsigned) index, 15);
    if ((index = decl.find("${name}")) != -1)
      decl.remove((unsigned) index, 7);
    if ((index = decl.find("${inverse_name}")) != -1)
      decl.remove((unsigned) index, 15);
    if ((index = decl.find("${value}")) != -1)
      decl.remove((unsigned) index, 8);
    if ((index = decl.find("${h_value}")) != -1)
      decl.remove((unsigned) index, 10);
    if ((index = decl.find("${stereotype}")) != -1)
      decl.replace((unsigned) index, 13,
		   CppSettings::relationAttributeStereotype(stereotype()));
    if ((index = decl.find("${association}")) != -1) {
      decl.replace((unsigned) index, 14,
		   association().toString());
    }
    replace_alias(decl);
    
    UmlTypeSpec type;
    
    type.type = roleType();
    UmlClassMember::compute_dependency(dependencies, decl, type, all_in_h);
  }
}
Пример #4
0
/* bind/construct representative of an internal cluster of a model graph */
static rep_t model_clust(Agraph_t *model, Agraph_t *origclust)
{
	rep_t		rep;

	rep = association(model,origclust);
	if (rep.type) return rep;

	rep.p = newpath(model,NILnode,GD_minrank(origclust),NILnode,GD_maxrank(origclust));
	rep.type = SKELETON;
	associate(model,origclust,rep);
	return rep;
}
Пример #5
0
static void associate(Agraph_t *model, void *key, rep_t val)
{
	Dict_t		*dict;
	repkey_t	*newelt;

	assert(association(model,key).type == 0);
	dict = repdict(model);
	newelt = NEW(repkey_t);
	newelt->key = key;
	newelt->val = val;
	dtinsert(dict,newelt);
}
Пример #6
0
/* bind/construct representative of an external endpoint to a model graph */
static rep_t model_extnode(Agraph_t *model, Agnode_t *orig)
{
	Agnode_t	*v;
	rep_t		rep;

	rep = association(model,orig);
	if (rep.type) return rep;

	/* assume endpoint is represented by one node, even if orig is multi-rank */
	rep.p = v = agnode(model,orig->name);
	rep.type = EXTNODE;
	ND_rank(v) = ND_rank(orig);	/* should be ND_rank(orig)+ranksize(orig)? */
	associate(model,orig,rep);
	return rep;
}
		ibool Preferences::OnCmdOk(Param& param)
		{
			if (param.Button().Clicked())
			{
				for (uint i=0; i < NUM_SETTINGS; ++i)
				{
					if (i != SAVE_SETTINGS)
						settings[i] = dialog.CheckBox( IDC_PREFERENCES_STARTUP_FULLSCREEN + i ).Checked();
				}

				settings.priority = static_cast<Priority>(dialog.ComboBox( IDC_PREFERENCES_PRIORITY ).Selection().GetIndex());

				settings.menuLookDesktop.color = menuColorWindows[0].color;
				settings.menuLookFullscreen.color = menuColorWindows[1].color;

				settings.menuLookDesktop.enabled = dialog.CheckBox( IDC_PREFERENCES_MENUCOLOR_DESKTOP_DEFAULT ).Unchecked();
				settings.menuLookFullscreen.enabled = dialog.CheckBox( IDC_PREFERENCES_MENUCOLOR_FULLSCREEN_DEFAULT ).Unchecked();

				settings.favoredSystem =
				(
					dialog.RadioButton( IDC_PREFERENCES_FAVORED_NES_PAL ).Checked() ? Nes::Machine::FAVORED_NES_PAL :
					dialog.RadioButton( IDC_PREFERENCES_FAVORED_FAMICOM ).Checked() ? Nes::Machine::FAVORED_FAMICOM :
					dialog.RadioButton( IDC_PREFERENCES_FAVORED_DENDY   ).Checked() ? Nes::Machine::FAVORED_DENDY   :
                                                                                      Nes::Machine::FAVORED_NES_NTSC
				);

				settings.alwaysAskSystem = dialog.RadioButton( IDC_PREFERENCES_FAVORED_ALWAYS_ASK ).Checked();

				Application::Instance::SetIconStyle( dialog.RadioButton(IDC_PREFERENCES_STYLE_NES).Checked() ? Application::Instance::ICONSTYLE_NES : Application::Instance::ICONSTYLE_FAMICOM );

				{
					Association association( true );
					const uint iconOffset = (Application::Instance::GetIconStyle() == Application::Instance::ICONSTYLE_NES ? 3 : 4);

					for (uint i=0; i < Association::NUM_EXTENSIONS; ++i)
					{
						if (dialog.CheckBox( IDC_PREFERENCES_ASSOCIATE_NES + i ).Checked())
							association.Create( i, icons[i][iconOffset] );
						else
							association.Delete( i );
					}
				}

				dialog.Close();
			}

			return true;
		}
Пример #8
0
/* bind/construct representative of an internal node in a model graph */
static rep_t model_intnode(Agraph_t *model, Agnode_t *orig)
{
	int				nr;
	rep_t			rep;
	Agnode_t	*v;
	
	rep = association(model,orig);
	if (rep.type) return rep;
	
	nr = ND_ranksize(orig);
	if (nr <= 1) {			/* simple case */
		v = rep.p = agnode(model,orig->name);
		rep.type = NODE;
		ND_rank(v) = ND_rank(orig);
	}
	else {							/* multi-rank node case */
		rep.p = newpath(model,NILnode,ND_rank(orig),NILnode,ND_rank(orig)+nr-1);
		rep.type = TALLNODE;
	}
	associate(model,orig,rep);
	return rep;
}
Пример #9
0
void UmlRelation::generate(QTextOStream & f, const Q3CString & cl_stereotype,
                           Q3CString indent) {
    switch (relationKind()) {
    case aDependency:
    case aGeneralisation:
    case aRealization:
        break;
    default:
        if (!javaDecl().isEmpty()) {
            if (cl_stereotype == "enum_pattern") {
                write_trace_header();
                UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b>an <i>enum_pattern</i> cannot have relation</b></font><br>");
                incr_warning();
                return;
            }

            const char * p = javaDecl();
            const char * pp = 0;
            Q3CString s;

            while ((*p == ' ') || (*p == '\t'))
                indent += *p++;

            f << indent;

            for (;;) {
                if (*p == 0) {
                    if (pp == 0)
                        break;

                    // comment management done
                    p = pp;
                    pp = 0;
                    if (*p == 0)
                        break;
                    f << indent;
                }

                if (*p == '\n') {
                    f << *p++;
                    if (*p)
                        f << indent;
                }
                else if (*p == '@')
                    manage_alias(p, f);
                else if (*p != '$')
                    f << *p++;
                else if (!strncmp(p, "${comment}", 10))
                    manage_comment(p, pp, JavaSettings::isGenerateJavadocStyleComment());
                else if (!strncmp(p, "${description}", 14))
                    manage_description(p, pp);
                else if (!strncmp(p, "${visibility}", 13)) {
                    p += 13;
                    generate_visibility(f, cl_stereotype);
                }
                else if (!strncmp(p, "${static}", 9)) {
                    p += 9;
                    if (isClassMember())
                        f << "static ";
                }
                else if (!strncmp(p, "${final}", 8)) {
                    p += 8;
                    if (isReadOnly())
                        f << "final ";
                }
                else if (!strncmp(p, "${transient}", 12)) {
                    p += 12;
                    if (isJavaTransient())
                        f << "transient ";
                }
                else if (!strncmp(p, "${volatile}", 11)) {
                    p += 11;
                    if (isVolatile())
                        f << "volatile ";
                }
                else if (!strncmp(p, "${type}", 7)) {
                    p += 7;
                    roleType()->write(f);
                }
                else if (!strncmp(p, "${stereotype}", 13)) {
                    p += 13;
                    f << JavaSettings::relationAttributeStereotype(stereotype());
                }
                else if (!strncmp(p, "${name}", 7)) {
                    p += 7;
                    f << roleName();
                }
                else if (!strncmp(p, "${inverse_name}", 15)) {
                    p += 15;
                    switch (relationKind()) {
                    case anAssociation:
                    case anAggregation:
                    case anAggregationByValue:
                        f << side(side(TRUE) != this)->roleName();
                    default:
                        break;
                    }
                }
                else if (!strncmp(p, "${multiplicity}", 15)) {
                    p += 15;

                    Q3CString m = multiplicity();

                    if (*m != '[')
                        f << "[]";
                    else {
                        for (unsigned index = 0; index != m.length(); index += 1) {
                            switch (m.at(index)) {
                            case '[':
                                f << '[';
                                break;
                            case ']':
                                f << ']';
                            default:
                                break;
                            }
                        }
                    }
                }
                else if (!strncmp(p, "${value}", 8)) {
                    if (!defaultValue().isEmpty()) {
                        if (need_equal(p, defaultValue()))
                            f << " = ";
                        f << defaultValue();
                    }
                    p += 8;
                }
                else if (!strncmp(p, "${association}", 14)) {
                    p += 14;
                    UmlClass::write(f, association());
                }
                else if (!strncmp(p, "${@}", 4)) {
                    p += 4;
                    if (pp != 0)
                        f << "${@}";
                    else if (! javaAnnotations().isEmpty()) {
                        pp =p;
                        p = javaAnnotations();
                    }
                }
                else
                    // strange
                    f << *p++;
            }

            f << '\n';
        }
    }
}
Пример #10
0
void UmlRelation::generate_decl(QTextStream & f,
                                const WrapperStr & cl_stereotype,
                                WrapperStr indent, bool)
{
    if ((relationKind() != aGeneralisation) &&
            (relationKind() != aRealization) &&
            (relationKind() != aDependency)) {
        if (cl_stereotype == "enum") {
            write_trace_header();
            UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b>an <i>enum</i> cannot have relation</b></font><br>");
            incr_warning();
            return;
        }

        if (cl_stereotype == "typedef") {
            write_trace_header();
            UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b>a <i>typedef</i> cannot have relation</b></font><br>");
            incr_warning();
            return;
        }

        if (!idlDecl().isEmpty()) {
            const char * p = idlDecl();
            const char * pp = 0;
            WrapperStr s;

            while ((*p == ' ') || (*p == '\t'))
                indent += *p++;

            if (*p != '#')
                f << indent;

            for (;;) {
                if (*p == 0) {
                    if (pp == 0)
                        break;

                    // comment management done
                    p = pp;
                    pp = 0;

                    if (*p == 0)
                        break;

                    if (*p != '#')
                        f << indent;
                }

                if (*p == '\n') {
                    f << *p++;

                    if (*p && (*p != '#'))
                        f << indent;
                }
                else if (*p == '@')
                    manage_alias(p, f);
                else if (*p != '$')
                    f << *p++;
                else if (!strncmp(p, "${comment}", 10))
                    manage_comment(p, pp);
                else if (!strncmp(p, "${description}", 14))
                    manage_description(p, pp);
                else if (!strncmp(p, "${readonly}", 11)) {
                    p += 11;

                    if (isReadOnly())
                        f << "readonly ";
                }
                else if (!strncmp(p, "${attribut}", 11)) {
                    // old version
                    p += 11;

                    if (cl_stereotype == "interface")
                        f << "attribute ";
                }
                else if (!strncmp(p, "${attribute}", 12)) {
                    p += 12;

                    if (cl_stereotype == "interface")
                        f << "attribute ";
                }
                else if (!strncmp(p, "${visibility}", 13)) {
                    p += 13;

                    if (cl_stereotype == "valuetype") {
                        switch (visibility()) {
                        case PublicVisibility:
                        case PackageVisibility:
                            f << "public ";
                            break;

                        default:
                            f << "private ";
                        }
                    }
                }
                else if (!strncmp(p, "${case}", 7)) {
                    p += 7;

                    WrapperStr idl_case = idlCase();

                    if (idl_case.isEmpty()) {
                        write_trace_header();
                        UmlCom::trace(WrapperStr("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b>unspecified <i>case</i> for <i>")
                                      + name() + "</b></font><br>");
                        incr_error();
                    }
                    else
                        f << idlCase();
                }
                else if (!strncmp(p, "${type}", 7)) {
                    p += 7;
                    roleType()->write(f);
                }
                else if (!strncmp(p, "${name}", 7)) {
                    p += 7;
                    f << roleName();
                }
                else if (!strncmp(p, "${inverse_name}", 15)) {
                    p += 15;

                    switch (relationKind()) {
                    case anAssociation:
                    case anAggregation:
                    case anAggregationByValue:
                        f << side(side(TRUE) != this)->roleName();

                    default:
                        break;
                    }
                }
                else if (!strncmp(p, "${stereotype}", 13)) {
                    p += 13;
                    f << IdlSettings::relationAttributeStereotype(stereotype());
                }
                else if (!strncmp(p, "${multiplicity}", 15)) {
                    p += 15;
                    f << multiplicity();
                }
                else if (!strncmp(p, "${association}", 14)) {
                    p += 14;
                    f << IdlSettings::type(association().toString());
                }
                else
                    // strange
                    f << *p++;
            }

            f << '\n';
        }
    }
}
Пример #11
0
void UmlRelation::generate_def(QTextStream & f, WrapperStr indent, bool h,
                               WrapperStr templates, WrapperStr cl_names,
                               WrapperStr, WrapperStr)
{
    if (isClassMember() && !cppDecl().isEmpty()) {
        UmlClass * cl = (UmlClass *) parent();

        if ((!templates.isEmpty() || (cl->name().find('<') != -1))
            ? h : !h) {
            const char * p = cppDecl();
            const char * pp = 0;

            while ((*p == ' ') || (*p == '\t'))
                p += 1;

            bool re_template = !templates.isEmpty() &&
                               insert_template(p, f, indent, templates);

            if (*p != '#')
                f << indent;

            const char * pname = name_spec(p);

            for (;;) {
                if (*p == 0) {
                    if (pp == 0)
                        break;

                    // comment management done
                    p = pp;
                    pp = 0;

                    if (re_template)
                        f << templates;

                    if (*p == 0)
                        break;

                    if (*p != '#')
                        f << indent;
                }

                if (*p == '\n') {
                    f << toLocale(p);

                    if (*p && (*p != '#'))
                        f << indent;
                }
                else if (*p == '@')
                    manage_alias(p, f);
                else if (*p != '$') {
                    if (p == pname)
                        f << cl_names << "::";

                    f << toLocale(p);
                }
                else if (!strncmp(p, "${comment}", 10)) {
                    if (!manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment())
                        && re_template)
                        f << templates;
                }
                else if (!strncmp(p, "${description}", 14)) {
                    if (!manage_description(p, pp) && re_template)
                        f << templates;
                }
                else if (!strncmp(p, "${static}", 9)) {
                    p += 9;
                }
                else if (!strncmp(p, "${const}", 8)) {
                    p += 8;

                    if (isReadOnly())
                        f << "const ";
                }
                else if (!strncmp(p, "${volatile}", 11)) {
                    p += 11;

                    if (isVolatile())
                        f << "volatile ";
                }
                else if (!strncmp(p, "${mutable}", 10)) {
                    p += 10;
                }
                else if (!strncmp(p, "${type}", 7)) {
                    p += 7;
                    roleType()->write(f);
                }
                else if (!strncmp(p, "${name}", 7)) {
                    p += 7;

                    if (*pname == '$')
                        f << cl_names << "::";

                    f << roleName();
                }
                else if (!strncmp(p, "${inverse_name}", 15)) {
                    p += 15;

                    switch (relationKind()) {
                    case anAssociation:
                    case anAggregation:
                    case anAggregationByValue:
                        f << side(side(TRUE) != this)->roleName();

                    default:
                        break;
                    }
                }
                else if (!strncmp(p, "${multiplicity}", 15)) {
                    p += 15;

                    const WrapperStr & m = multiplicity();

                    if (!m.isEmpty() && (*((const char *) m) == '['))
                        f << m;
                    else
                        f << '[' << m << ']';
                }
                else if (!strncmp(p, "${stereotype}", 13)) {
                    p += 13;
                    f << CppSettings::relationAttributeStereotype(stereotype());
                }
                else if (!strncmp(p, "${value}", 8)) {
                    if (!defaultValue().isEmpty()) {
                        if (need_equal(p, defaultValue()))
                            f << " = ";

                        f << defaultValue();
                    }

                    p += 8;
                }
                else if (!strncmp(p, "${h_value}", 10))
                    p += 10;
                else if (!strncmp(p, "${association}", 14)) {
                    p += 14;
                    UmlClass::write(f, association());
                }
                else
                    // strange
                    f << toLocale(p);
            }

            f << '\n';
        }
    }
}
Пример #12
0
void UmlRelation::generate_decl(aVisibility & current_visibility, QTextStream & f_h,
                                const WrapperStr & cl_stereotype, WrapperStr indent,
                                BooL & first, bool)
{
    switch (relationKind()) {
    case aDependency:
        if (stereotype() == "friend") {
            Q3ValueList<UmlFormalParameter> formals = roleType()->formals();

            if (! formals.isEmpty()) {
                const char * sep = "  template <";
                Q3ValueList<UmlFormalParameter>::ConstIterator it;

                for (it = formals.begin(); it != formals.end(); ++it) {
                    f_h << sep << (*it).type() << ' ' << (*it).name();
                    sep = ", ";
                }

                f_h << "> ";
            }
            else
                f_h << "  ";

            f_h << "friend " << roleType()->cpp_stereotype() << " ";
            roleType()->write(f_h, FALSE);
            f_h << ";\n";
            first = FALSE;
        }

        break;

    case aGeneralisation:
    case aRealization:
        break;

    default:
        if (!cppDecl().isEmpty()) {
            if (cl_stereotype == "enum") {
                write_trace_header();
                UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b>an <i>enum</i> cannot have relation</b></font><br>");
                incr_warning();
                return;
            }

            if (cl_stereotype == "typedef") {
                write_trace_header();
                UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b>a <i>typedef</i> cannot have relation</b></font><br>");
                incr_warning();
                return;
            }

            generate_visibility(current_visibility, f_h, first, indent);
            first = FALSE;

            const char * p = cppDecl();
            const char * pp = 0;
            WrapperStr s;

            while ((*p == ' ') || (*p == '\t'))
                indent += toLocale(p);

            if (*p != '#')
                f_h << indent;

            for (;;) {
                if (*p == 0) {
                    if (pp == 0)
                        break;

                    // comment management done
                    p = pp;
                    pp = 0;

                    if (*p == 0)
                        break;

                    if (*p != '#')
                        f_h << indent;
                }

                if (*p == '\n') {
                    f_h << toLocale(p);

                    if (*p && (*p != '#'))
                        f_h << indent;
                }
                else if (*p == '@')
                    manage_alias(p, f_h);
                else if (*p != '$')
                    f_h << toLocale(p);
                else if (!strncmp(p, "${comment}", 10))
                    manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment());
                else if (!strncmp(p, "${description}", 14))
                    manage_description(p, pp);
                else if (!strncmp(p, "${static}", 9)) {
                    p += 9;

                    if (isClassMember())
                        f_h << "static ";
                }
                else if (!strncmp(p, "${const}", 8)) {
                    p += 8;

                    if (isReadOnly())
                        f_h << "const ";
                }
                else if (!strncmp(p, "${volatile}", 11)) {
                    p += 11;

                    if (isVolatile())
                        f_h << "volatile ";
                }
                else if (!strncmp(p, "${mutable}", 10)) {
                    p += 10;

                    if (isCppMutable())
                        f_h << "mutable ";
                }
                else if (!strncmp(p, "${type}", 7)) {
                    p += 7;
                    roleType()->write(f_h);
                }
                else if (!strncmp(p, "${name}", 7)) {
                    p += 7;
                    f_h << roleName();
                }
                else if (!strncmp(p, "${inverse_name}", 15)) {
                    p += 15;

                    switch (relationKind()) {
                    case anAssociation:
                    case anAggregation:
                    case anAggregationByValue:
                        f_h << side(side(TRUE) != this)->roleName();

                    default:
                        break;
                    }
                }
                else if (!strncmp(p, "${multiplicity}", 15)) {
                    p += 15;

                    const WrapperStr & m = multiplicity();

                    if (!m.isEmpty() && (*((const char *) m) == '['))
                        f_h << m;
                    else
                        f_h << '[' << m << ']';
                }
                else if (!strncmp(p, "${stereotype}", 13)) {
                    p += 13;
                    f_h << CppSettings::relationAttributeStereotype(stereotype());
                }
                else if (!strncmp(p, "${value}", 8))
                    p += 8;
                else if (!strncmp(p, "${h_value}", 10)) {
                    if (!defaultValue().isEmpty() && isClassMember()) {
                        if (need_equal(p, defaultValue()))
                            f_h << " = ";

                        f_h << defaultValue();
                    }

                    p += 10;
                }
                else if (!strncmp(p, "${association}", 14)) {
                    p += 14;
                    UmlClass::write(f_h, association());
                }
                else
                    // strange
                    f_h << toLocale(p);
            }

            f_h << '\n';
        }
    }
}
Пример #13
0
void UmlRelation::gen_java_decl(QByteArray s, bool descr)
{
    const char * p = bypass_comment(s);

    while (*p) {
        if (!strncmp(p, "${comment}", 10))
            p += 10;
        else if (!strncmp(p, "${description}", 14))
            p += 14;
        else if (!strncmp(p, "${visibility}", 13)) {
            p += 13;
            write(visibility(), javaLanguage);
            fw.write(' ');
        }
        else if (!strncmp(p, "${static}", 9)) {
            p += 9;

            if (isClassMember())
                fw.write("static ");
        }
        else if (!strncmp(p, "${transient}", 12)) {
            p += 12;

            if (isJavaTransient())
                fw.write("transient ");
        }
        else if (!strncmp(p, "${volatile}", 11)) {
            p += 11;

            if (isVolatile())
                fw.write("volatile ");
        }
        else if (!strncmp(p, "${final}", 8)) {
            p += 8;

            if (isReadOnly())
                fw.write("final ");
        }
        else if (!strncmp(p, "${type}", 7)) {
            p += 7;
            roleType()->write();
        }
        else if (!strncmp(p, "${name}", 7)) {
            p += 7;
            writeq(roleName());
        }
        else if (!strncmp(p, "${multiplicity}", 15)) {
            p += 15;

            QByteArray m = multiplicity();

            if (! m.isEmpty()) {
                const char * s = m;

                if (*s != '[')
                    fw.write("[]");
                else {
                    while (*s) {
                        switch (*s++) {
                        case '[':
                            fw.write('[');
                            break;

                        case ']':
                            fw.write(']');

                        default:
                            break;
                        }
                    }
                }
            }
        }
        else if (!strncmp(p, "${stereotype}", 13)) {
            p += 13;
            writeq(JavaSettings::relationAttributeStereotype(stereotype()));
        }
        else if (!strncmp(p, "${value}", 8)) {
            p += 8;
        }
        else if (!strncmp(p, "${association}", 14)) {
            p += 14;
            write(association(), javaLanguage);
        }
        else if (!strncmp(p, "${@}", 4))
            p += 4;
        else if (*p == '\r')
            p += 1;
        else if (*p == '\n') {
            if (descr) {
                fw.write("<br />");
                p += 1;
            }
            else {
                fw.write(' ');

                do
                    p += 1;

                while ((*p != 0) && (*p <= ' '));
            }
        }
        else if (*p == ';') {
            if (descr)
                fw.write(*p++);
            else
                break;
        }
        else if (*p == '@')
            manage_alias(p);
        else
            writeq(*p++);
    }
}
Пример #14
0
void UmlRelation::gen_cpp_decl(QByteArray s, bool descr)
{
    const char * p;

    if (! descr) {
        write((cppVisibility() == DefaultVisibility)
              ? visibility() : cppVisibility(),
              cppLanguage);
        fw.write(": ");
        p = bypass_comment(s);
    }
    else
        p = s;

    while (*p) {
        if (!strncmp(p, "${comment}", 10))
            p += 10;
        else if (!strncmp(p, "${description}", 14))
            p += 14;
        else if (!strncmp(p, "${static}", 9)) {
            p += 9;

            if (isClassMember())
                fw.write("static ");
        }
        else if (!strncmp(p, "${const}", 8)) {
            p += 8;

            if (isReadOnly())
                fw.write("const ");
        }
        else if (!strncmp(p, "${mutable}", 10)) {
            p += 10;

            if (isCppMutable())
                fw.write("mutable ");
        }
        else if (!strncmp(p, "${volatile}", 11)) {
            p += 11;

            if (isVolatile())
                fw.write("volatile ");
        }
        else if (!strncmp(p, "${type}", 7)) {
            p += 7;
            roleType()->write();
        }
        else if (!strncmp(p, "${name}", 7)) {
            p += 7;
            writeq(roleName());
        }
        else if (!strncmp(p, "${multiplicity}", 15)) {
            p += 15;

            QByteArray m = multiplicity();

            if (m.isEmpty() || (((const char *) m)[0] != '[')) {
                fw.write("[");
                writeq(m);
                fw.write("]");
            }
            else
                writeq(m);
        }
        else if (!strncmp(p, "${stereotype}", 13)) {
            p += 13;
            writeq(CppSettings::relationAttributeStereotype(stereotype()));
        }
        else if (!strncmp(p, "${value}", 8) || !strncmp(p, "${h_value}", 10)) {
            break;
        }
        else if (!strncmp(p, "${association}", 14)) {
            p += 14;
            write(association(), cppLanguage);
        }
        else if (*p == '\r')
            p += 1;
        else if (*p == '\n') {
            if (descr) {
                fw.write("<br />");
                p += 1;
            }
            else {
                fw.write(' ');

                do
                    p += 1;

                while ((*p != 0) && (*p <= ' '));
            }
        }
        else if (*p == ';') {
            if (descr)
                fw.write(*p++);
            else
                break;
        }
        else if (*p == '@')
            manage_alias(p);
        else
            writeq(*p++);
    }
}
Пример #15
0
void playLoop(IplImage* frameBuffer[], int frameCount)
{
    Blob* pBlobs = NULL;
    int pBlobCount = 0;

    CvMemStorage* storage = cvCreateMemStorage(0);

    /////////////////////////////////////////// 
    // Etape 1: construction du modele de fond
    MedianModel medianModel;

    // Apprentissage du modele
    learnMedianModel(&medianModel, "../View_008", "%s/frame_%04d.jpg", frameCount, 0.95);
    
    char filename[255];
    int i, pb, b;
    IplImage* frame = NULL, *segFrame = NULL;
    for(i = 0; i < frameCount; i++)
    {
        frame = frameBuffer[i];
        
        ////////////////////////////////////////////
        // Etape 2: segmentation utilisant un modele
         
        segFrame = segmentMedianStdDev(frame, 2.0, &medianModel);
        
        opening(segFrame, segFrame, 3);
        closing(segFrame, segFrame, 3);
        

        ///////////////////////////////////////////////////////////
        // Etape 3: extraction des blobs et de leur caracteristiques
        
        Blob* blobs;
        DistMetrics m;

        // Extraction des blobs
        int blobCount = extractBlobs(segFrame, frame, &blobs, storage);
    
        if(pBlobs != NULL)
        {
            // Matrice des combinaisons de recouvrements spatiaux
            m.mSpatial = cvCreateMat(blobCount, pBlobCount, CV_32FC1);

            // Matrices des differences d'histogramme
            m.mHist5 = cvCreateMat(blobCount, pBlobCount, CV_32FC3);
            m.mHist10 = cvCreateMat(blobCount, pBlobCount, CV_32FC3);
            m.mHist15 = cvCreateMat(blobCount, pBlobCount, CV_32FC3);

            float coverage, absDiff;
            Blob *b1, *b2;
            int step = m.mSpatial->step, hstep = m.mHist5->step;
            for(b = 0; b < blobCount; b++)
            {
                for(pb = 0; pb < pBlobCount; pb++)
                {
                    b1 = &blobs[b];
                    b2 = &pBlobs[pb];

                    coverage = percentOverlap(b1, b2);
                    ((float*)(m.mSpatial->data.ptr + b*step))[pb] = coverage;

                    absDiff = absDiffHistograms(&b1->h5, &b2->h5, 0);
                    ((float*)(m.mHist5->data.ptr + b*hstep))[pb*3] = absDiff;

                    absDiff = absDiffHistograms(&b1->h10, &b2->h10, 0);
                    ((float*)(m.mHist10->data.ptr + b*hstep))[pb*3] = absDiff;

                    absDiff = absDiffHistograms(&b1->h15, &b2->h15, 0);
                    ((float*)(m.mHist15->data.ptr + b*hstep))[pb*3] = absDiff;

                    // TODO: Faire les autres canaux
                }
            }


            //////////////////////////////////////////////////////////
            // Etape 4: association temporelle avec le frame precedent
            int assocMatrix[blobCount];
            association(blobs, pBlobs, &m, assocMatrix);

            // Transfer des identites (etiquettes) aux nouveaux blobs
            for(b = 0; b < blobCount; b++)
            {
                int index = assocMatrix[b];
                if(index != -1)
                    blobs[b].label = pBlobs[index].label;
                else
                    blobs[b].label = generateLabel();
            }
        }
        else
        {
            // Attribution d'une premiere etiquette a chaque blob
            for(b = 0; b < blobCount; b++)
                blobs[b].label = generateLabel();
        }

        // Images binaires
        drawBoundingRects(segFrame, blobs, blobCount);
        drawLabels(segFrame, blobs, blobCount);
        sprintf(filename, "bbox_%04d.jpg", i);
        cvSaveImage(filename, segFrame);

        // Image originales
        drawBoundingRects(frame, blobs, blobCount);
        drawLabels(frame, blobs, blobCount);
        sprintf(filename, "suivi_%04d.jpg", i);
        cvSaveImage(filename, frame);

        pBlobCount = blobCount;
        pBlobs = blobs;
    }
    cvReleaseMemStorage(&storage);
}