How to set the visual size of one component based on another component in the same type? - modelica

I am using Dymola. Assuming that I have two components in my model, I want to use the same visual size for the components that share the same type.
So how could I set the visual size of one component according to another one?
I am not planning to use annotation code, cause that could be too much trouble when there are many components?

I think using annotations will be the only way to go. This is where the position and size of a component are determined. The only way that comes to my mind is using parameters to set these positions as (partially) shown below.
model pos_params
parameter Real pos_x1 = -10;
Modelica.Blocks.Sources.Constant const annotation (Placement(transformation(extent={{pos_x1,-10},{10,10}})));
end pos_params;
To get to your result you would need to have some additional parameters in multiple components.
Still, doing this in Dymola will make make the graphical manipulation of size an position of a model cumbersome, as the icon will be set to have zero size.

There is no way around annotations, because they define the graphical representation of components. But you can copy-paste the relevant extent values easily from one component to another using the Annotation window.

Related

No support for custom shapped windows in gtk3?

I want to use a custom shaped window using gtk3. I found gtk_widget_shape_combine_mask_() in gtk2. The closest thing I can find in gtk3 is gdk_window_shape_combine_region_(), which only allows for rectangular shaped regions. Why was the support dropped? Or was it changed and implemented in a different way?
What do you mean with "why was the support dropped?".
gtk_widget_shape_combine_mask() only supports rectangular shapes, too. That's what a GdkBitmap is: An image with a bit depth of 1. This means that a pixel is either included or not.
This is basically the same as a cairo_region_t. The difference is only in how the data is stored: Instead of a bitmap, cairo_region_t uses a list of rectangles to describe the same result.
"Or was it changed and implemented in a different way?"
Yes and you already found the replacement yourself.

Performance on changing colour of big geojson by using data-driven (comparing to using setPaintProperty)

I have been rendering a FeatureCollection of polygons into the Map (in one GeoJSONLayer). The size of each polygon is big (5mb, 10mb). With user interactions, the colours of polygons would be re-calculated & changed constantly. We are using data-driven method and keeping the data in properties of each feature. So GeoJSONLayer has to call .setData(geojson) everytime the data and colours changed (they are kept in properties).
I find above approach is lead to performance issue since the size of geojsons is big and calling .setData() is expensive.
I'm thinking of separating the geojson source and the data, style, colouring and calling direct function (setPaintProperty) whenever colours changed would be better than.
Someone told me that .setData and .setPaintProperty would do the same thing, both 2 will trigger re-rendering whole polygons.
Kindly need help to advice on this matter
Thanks a lot!
If I understand you correctly, you're asking which of these two is faster:
map.setData(mylayer, mygeojson)
map.setPaintProperty(mylayer, 'fill-color', ...mydatadrivenproperty)
I haven't tested, but I'd assume the second is faster, because the first one has to:
Parse the GeoJSON
Convert it to vector tiles
Repaint
whereas the second just has to parse the property repaint. Try them both out to see.
You may also consider a third way, which is to have a second layer which is a highlight, which you update by calling map.setFilter(mylayer, ...).

How to make a DEM in QGIS using spot heights and contors

I have 2 shapefiles. One is the contors of an area and the other the spot heights. Both of them has a altitude attribute. In ArcGIS there is a tool called topo to raster were you can use both these features to create a dem. In qgis I have only found tools were you can only use one.
Any Ideas?
There is only the interpolation tool that I know of which will create a DEM. Depending on the resolution you're after, you could BUFFER the spot heights, then MERGE SHAPE FILES and run the interpolation tool on that.
Using the graphical modeler would prevent the buffer layer being created making the process a little tidier (and i'm sure there's a better way using the python console). Hope this helps.

add simple geometric elements to GUIDE GUI

I am desiging a simple GUI application in Matlab using GUIDE.
I am displayed a number of axis - and I would like to add some simple design elements to make the interface clearer. I would like to draw a colored rectangle around an axis (seperate from the axis)... there are two such axes, each displaying details of some things shown in a third plot, and I would like this color clue to link the details to the overview.
So is it possible to add simple geometric shape objects to a Matlab GUI? I don't see anything but controls in GUIDE but perhaps its possible to add them manually with an explicit command?
It is generally difficult to draw any random shape. Except Square & rectangle, for which you can create panels and change the properties like BorderWidth and HighlightColor.
Since MATLAB GUI is based on Java, you can create any object in MATLAB GUI which can be created in Java. You can refer to this website [1] for further learning.
[1] http://undocumentedmatlab.com/matlab-java-book/

Change label of data tips on bode nichols diagram

When we plot a bode/nichols locus, the name of workspace variable is used
tmp=ss(1,1,1,0);
nichols(tmp);
will use 'tmp' as label.
When using more complex data, matlab is using 'untitled1','untitled2',...
tmp={ss(1,1,1,0) , ss(1.2,1,1,0)};
nichols(tmp{:});
How can I change this label programmatically?
Ideally, I'd like a solution working with Matlab 6.5.1, but I'm also interested in solutions restricted to newer versions.
You can modify the labels programmatically via their graphics handles. It looks like the values you want to change are the DisplayName property of some of the children of the current axis. So in your first example, I can change the display name like this:
ch = get(gca,'Children');
set(ch(1),'DisplayName','Fred');
In general, I'm not sure how to predict which children of the current axis are the ones you need to change. For the second example you give, the two curves appear to be the second and third children when I run your code.