ModelicaSpecification
ModelicaSpecification copied to clipboard
Keep icon graphics untransformed when coordinate system is flipped or rotated
Modified by beutlich on 3 May 2018 09:57 UTC We have the requirement (both from customers and our own library developers) to not rotate or flip the icon graphics of a quadratic icon if the coordinate system is flipped or rotated by 90/180/270 deg.
Test model
model T2248
Modelica.Blocks.Sources.Clock clock
annotation(Placement(transformation(extent={{-80,60},{-60,80}})));
Modelica.Blocks.Sources.Clock clock_flipH
annotation(Placement(transformation(extent={{-20,60},{-40,80}})));
Modelica.Blocks.Sources.Clock clock_flipV
annotation(Placement(transformation(extent={{0,80},{20,60}})));
Modelica.Blocks.Sources.Clock clock_rotate90 annotation(Placement(
transformation(extent={{-10,-10},{10,10}}, rotation=90, origin={-70,30})));
Modelica.Blocks.Sources.Clock clock_rotate180 annotation(Placement(
transformation(extent={{-10,-10},{10,10}}, rotation=180, origin={-30,30})));
Modelica.Blocks.Sources.Clock clock_rotate270 annotation(Placement(
transformation( extent={{-10,-10},{10,10}}, rotation=270, origin={10,30})));
annotation(uses(Modelica(version="3.2.2")));
end T2248;
Current rendering

Ideally, the clock icon should not rotate or flip along with the coordinate system, as for example known from Simulink.
Modified by beutlich on 3 May 2018 09:53 UTC We have the requirement (both from customers and our own library developers) to not rotate or flip the icon graphics of a quadaratic icon if the coordinate system is flipped or rotated by 90/180/270 deg.
Test model
model T2248
Modelica.Blocks.Sources.Clock clock
annotation(Placement(transformation(extent={{-80,60},{-60,80}})));
Modelica.Blocks.Sources.Clock clock_flipH
annotation(Placement(transformation(extent={{-20,60},{-40,80}})));
Modelica.Blocks.Sources.Clock clock_flipV
annotation(Placement(transformation(extent={{0,80},{20,60}})));
Modelica.Blocks.Sources.Clock clock_rotate90 annotation(Placement(
transformation(extent={{-10,-10},{10,10}}, rotation=90, origin={-70,30})));
Modelica.Blocks.Sources.Clock clock_rotate180 annotation(Placement(
transformation(extent={{-10,-10},{10,10}}, rotation=180, origin={-30,30})));
Modelica.Blocks.Sources.Clock clock_rotate270 annotation(Placement(
transformation( extent={{-10,-10},{10,10}}, rotation=270, origin={10,30})));
annotation(uses(Modelica(version="3.2.2")));
end T2248;
Current rendering

Ideally, the clock icon should not rotate or flip along with the coordinate system, as for example known from Simulink.
Reported by beutlich on 3 May 2018 09:52 UTC We have the requirement (both from customers and our own library developers) to not rotate or flip the icon graphics of a quadaratic icon if the coordinate system is flipped or rotated by 90/180/170 deg.
Test model
model T2248
Modelica.Blocks.Sources.Clock clock
annotation(Placement(transformation(extent={{-80,60},{-60,80}})));
Modelica.Blocks.Sources.Clock clock_flipH
annotation(Placement(transformation(extent={{-20,60},{-40,80}})));
Modelica.Blocks.Sources.Clock clock_flipV
annotation(Placement(transformation(extent={{0,80},{20,60}})));
Modelica.Blocks.Sources.Clock clock_rotate90 annotation(Placement(
transformation(extent={{-10,-10},{10,10}}, rotation=90, origin={-70,30})));
Modelica.Blocks.Sources.Clock clock_rotate180 annotation(Placement(
transformation(extent={{-10,-10},{10,10}}, rotation=180, origin={-30,30})));
Modelica.Blocks.Sources.Clock clock_rotate270 annotation(Placement(
transformation( extent={{-10,-10},{10,10}}, rotation=270, origin={10,30})));
annotation(uses(Modelica(version="3.2.2")));
end T2248;
Current rendering

Ideally, the clock icon should not rotate or flip along with the coordinate system, as for example known from Simulink.
Migrated-From: https://trac.modelica.org/Modelica/ticket/2248
Modified by beutlich on 3 May 2018 09:53 UTC
Comment by beutlich on 3 May 2018 09:57 UTC We would be happy to provide an MCP for this, once the rough direction is emerged and if there is some consens within the project members.
Modified by beutlich on 3 May 2018 09:57 UTC
Comment by hansolsson on 3 May 2018 11:50 UTC Some questions:
- What happens if we rotate 45 degrees?
- The connectors and possibly texts should rotate, right?
- We have had the opposite idea for texts (can't find trac-number) - i.e. that a symbol such as "<" should be rotated 180 degrees/flipped even if that normally makes text unreadable.
This leads to the question whether it should be an attribute on parts of the graphics, instead of an attribute on the entire icon.
Comment by beutlich on 4 May 2018 12:28 UTC Replying to [comment:4 Hans Olsson]:
Some questions: * What happens if we rotate 45 degrees?
No special handling. The proposal holds only for
- quadratic extents with flipped coordinate systems or rotations by 90/180/270 degrees and
- rectangular extents with flipped coordinate systems or rotations by 180 degrees which is similar to current tools heuristics to not transform text in icons.
* The connectors and possibly texts should rotate, right?
Connectors, yes. The proposal also holds for text as it is part of the icon graphics.
* We have had the opposite idea for texts (can't find trac-number) - i.e. that a symbol such as "<" should be rotated 180 degrees/flipped even if that normally makes text unreadable.
#746 it is.
Comment by beutlich on 29 Jun 2018 06:48 UTC We implemented a prototype (vendor-specific) preserveOrientation attribute (similar as preserveAspectRatio) with the semantics as described above.
record CoordinateSystem
Extent extent;
Boolean preserveAspectRatio = true;
Boolean preserveOrientation = false;
Real initialScale = 0.1;
DrawingUnit grid[2];
end CoordinateSystem;
Note that if we decide to add this and #746 I would propose that we use the same annotation-name for both, even though the defaults are opposite.
Phone meeting: Test whether it makes sense for class and/or component.
Phone meeting: Test whether it makes sense for class and/or component.
Has anyone tested this?
Phone meeting: Test whether it makes sense for class and/or component.
Has anyone tested this?
Oh, it turns out that we implemented a test in Dymola:
package T
model T2248
ContinuousClock clock
annotation (Placement(transformation(extent={{-80,60},{-60,80}})));
ContinuousClock clock_flipH
annotation (Placement(transformation(extent={{0,60},{-20,80}})));
ContinuousClock clock_flipV
annotation (Placement(transformation(extent={{40,80},{60,60}})));
ContinuousClock clock_rotate90 annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=90,
origin={-70,10})));
ContinuousClock clock_rotate180 annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=180,
origin={-10,10})));
ContinuousClock clock_rotate270 annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={50,10})));
end T2248;
model T2248Extended
extends T2248;
ContinuousClock clock_rotate45 annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=45,
origin={-90,-30})));
ContinuousClock clock_rotate135 annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=135,
origin={-36,-30})));
ContinuousClock clock_rotate225 annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=225,
origin={22,-28})));
ContinuousClock clock_rotatem45 annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=-45,
origin={80,-30})));
Modelica.Blocks.Sources.ContinuousClock
clock_rotate1 annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=90,
origin={-72,-70})));
Modelica.Blocks.Sources.ContinuousClock
clock_rotate2 annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=180,
origin={-10,-70})));
Modelica.Blocks.Sources.ContinuousClock
clock_rotate3 annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={50,-70})));
annotation();
end T2248Extended;
model T2248Orig
import Modelica.Blocks.Sources.ContinuousClock;
ContinuousClock clock
annotation (Placement(transformation(extent={{-80,60},{-60,80}})));
ContinuousClock clock_flipH
annotation (Placement(transformation(extent={{-20,60},{-40,80}})));
ContinuousClock clock_flipV
annotation (Placement(transformation(extent={{0,80},{20,60}})));
ContinuousClock clock_rotate90 annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=90,
origin={-70,30})));
ContinuousClock clock_rotate180 annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=180,
origin={-30,30})));
ContinuousClock clock_rotate270 annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={10,30})));
annotation();
end T2248Orig;
block ContinuousClock
extends Modelica.Blocks.Sources.ContinuousClock;
annotation (
Icon(coordinateSystem(
preserveAspectRatio=true,
preserveOrientation=true,
extent={{-100,-100},{100,100}})));
end ContinuousClock;
annotation (uses(Modelica(version="4.0.0")));
end T;
Gives the two possibilities (preserved or not):
Do others still think this is a good idea? If so it seems fairly easy to add.
Can you show what it looks like when you rotate for instance 45, 135, 225, 315 degrees? I assume they will all look like 45 degrees?
Can you show what it looks like when you rotate for instance 45, 135, 225, 315 degrees? I assume they will all look like 45 degrees?
They look the same as without the annotation, I updated the package with that and the result is as follows:
So, I have preserveOrientation components on top, and a bottom row for rotating the original for comparison. The 45-degree variants are placed in the order (so 135 degrees between 90 and 180 degrees), and should be the same for preserveOrientation as for without (that's why it is placed between them).
The changes in the orientation of the texts makes it a bit subtle to discover the simple pattern.
Language group:
- Should be restricted to square components? Skip that, instead:
- No special case for non-90 degree rotations, the one using it is responsible for making it look good.
- Different name? (since connectors are still impacted? seems to be too long and complicated). Scaling and movement is still possible.
General idea looks good.