Visio .vsdx Unwanted Behavior: Why is User-Defined Shape Value Truncated to 0.00E0 from 1.00E-7? - visio

Problem.
A user-defined shape value is unexplainably truncated to 0.00E0 in some (but not all) shapes when saved as a .vsdx-formatted drawing.
Desired Outcome.The original (correct) shape value is 1.00E-7 when saved as a .vsd drawing and should be the value for the .vsdx drawing.
Observation.
In Visio 2013 + 2016, when a .vsd drawing with a "bus" shape is saved, closed, and opened as a .vsdx drawing, the user-defined shape value for failure rate changes from a numerical value of 1.00E-7 to 0.00E0. This behavior does not occur with every shape. For example, the failure rate for "Bus, substation" remains a constant numerical value of 2.05E-6 when the drawing is saved, closed, and opened in .vsdx format.
If the precision of the failure rate is increased to 1.001E-7, the failure rate is retained as 1.001E-7 when saved, closed, and opened as a .vsdx drawing.
In addition to the failure rate changing for "Bus" on the drawing, it also changes for "Bus" in the stencil even though the stencil is not editable ... which is really puzzling!
Workaround.
A workaround for the problem is to enclose the failure rate in quotes in the Shapesheet in both the drawing shape and stencil master. When the failure rate is in quotes, the value is retained after saving, closing, and opening the .vsdx drawing.
Explanations for this behavior are encouraged. Thank you.

You also can store your values in Shape Data section. In this section values can have various type of data: string, number, duration etc
For number type user can select format with float point and set how many digits after zero he need to use !
You can see in my GIF that in ShapeData window (at left side) values shown correctly, but in ShapeSheet in this row you see value 0.
And in user-defined cell which show value of shape data (prop.row_2) you also can see correct value !

I try wrap values in cell with quotes. In this case "values" in these cells not truncated and correctly calculated like at this gif.
May be this not best way, but it works !

Related

Export to vector graphics fails with large number of data-points

I want to export some MATLAB-plots as vector-graphics for presentations. In the most cases, using print-command, for example:
set(0,'defaultAxesTickLabelInterpreter','Latex')
set(0,'defaultTextInterpreter','Latex')
t=linspace(0,6,6000);
s=sin(t);
figure
for spl=1:16
subplot(4,4,spl);
plot(t,s,'k')
end
print('Sinetest','-dpdf');
but as soon as the number of data-points (or the expected file size) turns too big, for example use t=linspace(0,6,7000); the method fails: instead of a scalable vector graphic, an ugly pixel-monster is saved in the .pdf-file. I've tried to use other file-formats, for exampl .emf, .eps, .svg (svg is what I need actually) instead of .pdf, but it's always the same problem. Reducing the number of data points works in this example, but not in general for me.
Is there any option or work around?
The solution is to specify that the painter renderer should be used:
print('Sinetest','-dpdf', '-painters');
If you save to a vector graphics file and if the figure RendererMode
property is set to 'auto', then print automatically attempts to use
the Painters renderer. If you want to ensure that your output format
is a true vector graphics file, then specify the Painters renderer.
Note that this may result in long rendering times as mentioned in the docs:
Sometimes, saving a file with the '-painters' option can cause longer
rendering times [...]

How to overwrite part of a png?

Given a png image and a set of data to write to it, is it possible to overwrite pixels in the existing png in a particular area of interest? For example, If I have a block of data in a rectangle between pixels (0,0) (5,10) would it be possible to write this data as a block into a 10X10 png without any concern for the area not being overwritten? My use case is that I have map tiles where half the data will be in one tile and half in the other, with the blank pixels being white squares. I would like to combine them by simply writing the non-white pixels directly to the existing png in a block without having to open, combine, then re-write the entire png. Does the structure of a png allow this?
I'm loath to claim that this is impossible, but it is certainly complicated.
First of all, pixels of a PNG are (sometimes) interlaced, so you'd have to calculate the locations of your target pixels based on the Adam7 scheme.
Furthermore each row is independently filtered, so you'd have to transform each row of your source using the filter of the target row. Depending on the filter you'd also have to adjust additional bytes on the border of the updated target bytes. Straight from the horse's mouth:
Though the concept is simple, there are quite a few subtleties in the actual mechanics of filtering.
Finally, all the filtered bytes are compressed using a generic compression algorithm called "deflate." Unless you want to decompress the whole thing beforehand, you need to make sure both that (1) your source data can be properly decoded and (2) the bytes near the border of the target bytes are properly compressed in the context of their new neighbors.
I'm not a compression expert, so I won't argue in more detail. One piece of good news is that the algorithm seems to preserve independence between distant regions due to its sliding window scheme: data are only compressed based on data in some preceding range, say 13,000 bytes.
If this seems at all easy to you, give it a try. If you're like me, though, you'll just decode the whole thing, overwrite the pixels as bitmap data, and encode the result.
This is practically impossible because the pixels data (after a row-by-row "filtering") is compressed with ZLIB. And it's practically impossible to change part of a compressed stream.

Matlab imshow update image at old position and magnification

I currently use Matlab's imshow to output an image at every iteration of a diffusion filter process, i.e. multiple times per second.
Sometimes during filtering I want a closer look at specific image parts.
However, when using the ('Parent', handle) name-value pair for imshow the magnification and position gets reset.
Is there a way to update the underlying image but having the magnification and position intact?
You can update the cdata in the current axis to your new data matrix which will keep all other settings the same. If this is in a loop, you probably need to call drawnow. E.g:
x=randn(100);
figure;imagesc(x);
Now zoom / pan / do whatever manipulations you want.
f=gca;
x=randn(100);
f.Children.CData = x;
This method of updating of child data is recommended by Matlab as more efficient than destroying the axis child Image and recreating each frame (can't remember the source, it was in one of the help files).
Edit: Just remembered that this syntax won't work on older versions of matlab (pre 2015 or so). In that case, use get/set syntax:
set(get(gca,'Children'),'CData',x);

Get absolute position in frame

The way I understand how emacs displays stuff is that essentially everything is text. If you have something in the fringe or linum mode active, essentially your document is pushed a little inwards and something is written in the first few columns.
I'm writing a function for putting some stuff into the head-line and this works nicely, however, I would like the start of the text to be aligned with the start of the document.
Thus I am looking for a way to get the number of columns that sit between the frame border and the start of the actual document.
Let me illustrate using a poorly produced graphic:
I want to get the number of columns (or the number of pixels) that make up the distance marker by the ruler just below the line number 10000.
The function which returns this value shall be executed in the functions which create the head-line.
There is a function called window-inside-edges that you can use to determine the offset of the text area ("window body") from the total width and height of the window in columns and lines, respectively.
It returns a list four values; the order is left - top - right - bottom, so to get the value you are interested in for the current window, just do
(car (window-inside-edges))
More information on window coordinates can be found here; this page has information about window sizes, including a nice ASCII representation of window elements.

Drawing text using PdfTextArray in iTextSharp - how?

I am drawing text in a PDF page using iTextSharp, and I have two requirements:
1) the text needs to be searchable by Adobe Reader and such
2) I need character-level control over where the text is drawn.
I can draw the text word-by-word using PdfContentByte.ShowText(), but I don't have control over where each character is drawn.
I can draw the text character-by-character using PdfContentByte.ShowText() but then it isn't searchable.
I'm now trying to create a PdfTextArray, which would seem to satisfy both of my requirements, but I'm having trouble calculating the correct offsets.
So my first question is: do you agree that PdfTextArray is what I need to do, in order to satisfy both of my original requirements?
If so, I have the PdfTextArray working correctly (in that it's outputting text) but I can't figure out how to accurately calculate the positioning offset that needs to get put between each pair of characters (right now I'm just using the fixed value -200 just to prove that the function works).
I believe the positioning offset is the distance from the right edge of the previous character to the left edge of the new character, expressed in "thousandths of a unit of text space". That leaves me two problems:
1) How wide is the previous character (in points), as drawn in the specified font & height? (I know where its left edge is, since I drew it there)
2) How do I convert from points to "units of text space"?
I'm not doing any fancy scaling or rotating, so my transformation matrices should all be identity matrices, which should simplify the calculations ...
Thanks,
Chris