Closed modelica-trac-importer closed 6 years ago
Comment by anonymous on 26 Oct 2011 09:00 UTC
I'd say that what the user expects when inheriting a class without using primitivesVisible=false
is to get exactly the same icon. So if A inherits B without primitivesVisible=false
, and B inherits C with primitivesVisible=false
, then A should show the primitives from B, but neither A nor B should show the primitives from C.
I think that is the most logical way to interpret the specification, but maybe it needs to be clarified. (Unless we all agree of what the logical interpretation is, then it probably does need clarification.)
Comment by jmattsson on 26 Oct 2011 09:01 UTC Last comment was me, forgot to log in.
Comment by choeger on 26 Oct 2011 09:23 UTC The question goes a little bit deeper. The question is, where does evaluation happen.
model A
Integer x = 1;
Real y;
equation
time * x = y;
end A;
model B
extends A(x = 2);
end B;
What equation does this yield?
Comment by jmattsson on 26 Oct 2011 09:28 UTC Replying to [comment:3 choeger]:
The question goes a little bit deeper. The question is, where does evaluation happen.
model A Integer x = 1; Real y; equation time \* x = y; end A; model B extends A(x = 2); end B;
What equation does this yield?
Are you sure you are in the right ticket? That seems unrelated.
Though to answer your question, it gives two equations:
time * x = y;
x = 2;
Comment by hansolsson on 26 Oct 2011 09:52 UTC I agree with JMattson that primitivesVisible=true should not modify inherited primitives. Looking at the 17.5.3 see that it is combined with re-mapping of graphics for an extends-clause:
model A
extends B annotation(
IconMap(extent={{-100,-100}, {100,100}},primitivesVisible=false),
DiagramMap(extent={{-50,-50}, {0,0}},primitivesVisible=true)
);
end A;
The re-mapping can transform the inherited graphics and primitivesVisible can hide the inherited primitives.
The normal and default behaviour is to inherit without this annotation. The expected normal and default behaviour is that the inherited graphics is shown in the same way as in the base-class.
Since primitivesVisible=true is the default it implies that primitivesVisible=true should not make any primitives that were hidden visible again.
Comment by choeger on 26 Oct 2011 10:27 UTC Replying to [comment:4 jmattsson]:
What equation does this yield? Are you sure you are in the right ticket? That seems unrelated.
Yes, I am sure. And it is related: In both cases we see inheritance and modification. Why should inheritance behave differently for graphical classes? And if it does, where is the specification for that behavior?
Comment by jmattsson on 26 Oct 2011 12:27 UTC Replying to [comment:6 choeger]:
In both cases we see inheritance and modification.
No, in the graphical case it is an annotation, not a modification.
Replying to [comment:6 choeger]:
Why should inheritance behave differently for graphical classes?
(Graphical annotations, not classes.) I don't see where the difference lies. You inherit some parts and add some stuff. When inheriting classes, you don't inherit e.g. imports. You also don't inherit primitives from graphical annotations if the extends clause has this annotation.
Replying to [comment:6 choeger]:
And if it does, where is the specification for that behavior?
Section 17.5 in the specification describes graphical annotations, this case in particular is mostly in 17.5.3.
Perhaps the relevant part of the spec. should talk about "not inheriting/showing/drawing" primitives rather than they being "not visible by default".
Comment by choeger on 26 Oct 2011 13:36 UTC Replying to [comment:7 jmattsson]:
Perhaps the relevant part of the spec. should talk about "not inheriting/showing/drawing" primitives rather than they being "not visible by default".
Sorry, my fault. I intepreted the sentence
All graphical primitives are inherited from a base class.
wrong. Apparently, there is no inheritance for graphical elements in place, but the graphical elements are inhertited. Everything is of course perfectly fine with your interpretation, since every extends statement has it's own visibility.
Comment by hansolsson on 27 Feb 2012 18:01 UTC Language group: The idea is that with primitivesVisible=false no graphichal primitives are added from that base-class (or any of its base-classes); and primitivesVisible=true graphical primitives are added in the normal way - previously hidden ones are not resurrected. This seems to be fairly clear, but could be improved further for next revision.
Comment by hansolsson on 9 May 2012 10:03 UTC Part of 3.3.
Reported by stefanv on 25 Oct 2011 19:34 UTC Section 17.5.3 of Modelica 3.1 and 3.2 specifications state:
All graphical primitives are inherited from a base class. If the primitivesVisible attribute is false, components and connections are by default visible but graphical primitives are not.
What happens if the derived class is extended once again, and there
primitivesVisible=true
. Do the primitives from the original class once again become visible?Migrated-From: https://trac.modelica.org/Modelica/ticket/630