Alternative to simulink transparent subsystem - simulink

I need to organize a set of elements in simulink. The first method is to create a subsystem. The problem with subsystem is that the elements inside it are no longer visible. An alternative method is to create a colorized box and put it behind a set of elements as a background. It makes a lot of troubles during selection of elements.
The ideal method is to have a subsystem which is transparent but you can see the elements inside it. So you can make it large and see inside it without opening it.
What is the feasible alternative method?

Knowing that there is no support by simulink doing this, the only possibility would be to use a mask icon which shows the content. The following is a very rough prototype for the mask code:
model='s1/Subsystem';
loc=fullfile(pwd,[model,'.png']);
print(['-s' model], ['-dpng'], '-r300', loc);
image(loc);
port_label('input',1,'In1');
port_label('output',1,'Out1');
Obviously this prototype has multiple issues which must be addressed when really using the code:
Remove the hard-coded directory.
Set in- and outports automatically.
create required folder structure. (folder s1 must be created once manually)
Scale the subsystem block to make the image look good
work properly if pwd is not the directory the model is stored in

You can make use of the 'Icon Drawing Commands' of the mask parameter's tab 'Icon and Ports' :-
Take a screenshot of the logic gates you want to be visible on the subsystem (the ones with a blue background color shown in your question)
Save the picture e.g 'mylogic.png'
Write this command in the 'Icon Drawing Command' field of Icon and Ports image(imread('Pause_Icon.png'));
You're done. But yes, make sure you have the picture file in the same folder as your model or simply add the folder containing the picture on your path.
Of course, if you update the blocks inside the subsystem, you'll have to update the mask icon with the new screenshot.

Related

How to add a "tutorial message div" to figures?

After installing R2018b, the first figure I opened contained an interesting message (shown in blue):
The reason it's interesting is because it contains features like text wrapping, transparency, the fact that the image maintains a constant width even though the text resizes (this reminded me of CSS3 flexbox, hence the tag), etc.
The last part of the animation is in slow motion, to better show how the div's size follows that of the figure.
In case it matters, I'm using Win 10 v1803.
Question:
I'd like to know how we can draw similar, custom, divs (for a lack of a better word) in our figures. (It's important to stress that this is not a UIFigure!)
What I found so far:
The Learn More link opens the page:
web(fullfile(docroot, 'matlab/creating_plots/interactively-explore-plotted-data.html'))
yet breakpoints in the entry points of either web or docroot (or even doc) aren't hit.
Assuming that this element is a Child of the figure, I attempted to locate a handle to it:
>> set(gcf,'MenuBar','none'); findall(gcf)
ans =
22×1 graphics array:
Figure (1)
ContextMenu
AnnotationPane
Axes
AxesToolbar
Text
Text
Text
ToolbarStateButton (Brush/Select Data)
ToolbarStateButton (Data Tips)
ToolbarStateButton (Rotate 3-D)
ToolbarStateButton (Pan)
ToolbarStateButton (Zoom In)
ToolbarStateButton (Zoom Out)
ToolbarPushButton (Restore View)
Button
Button
Button
Button
Button
Button
Button
however, making these controls invisible using set(h(2:end), 'Visible', false) didn't make the div disappear.
Saving the figure as .fig or generating code for it, doesn't leave any trace of this div.
When uiinspect-ing the figure, this div doesn't show (or at least, I couldn't find it).
I don't know what exactly I did to make it reappear once more, but since it's set to appear on the very first time you boot R2018b, I suspect deleting prefdir (obviously, after backing it up) and restarting MATLAB could bring it back.
The only thing I didn't try yet, is to attach a java debugger to MATLAB and attempt to trace the caller to com.mathworks.mlservices.MLHelpServices.setCurrentLocation (from mlservices.jar), which opens the help browser.
After some digging in the Java side of things (starting from findjobj, followed by a lot of .getComponent(0).getComponent(0)...), I've finally managed to locate the component in question. Here's what I learned:
This component is called InfoPanel, and is part of MATLAB's Java API. The class definition itself is found in:
MATLAB/R2018b/java/jar/hg.jar!/com/mathworks/hg/util/InfoPanel.class
To make it appear, we need to call the static method addBannerPanel, passing in a figure handle:
com.mathworks.hg.util.InfoPanel.addBannerPanel( figure(randi(1E4)) );
Or another signature that also accepts a custom panel:
jIP = com.mathworks.hg.util.InfoPanel;
jIP.setBackground(java.awt.Color(0.8, 0.7, 0.1));
com.mathworks.hg.util.InfoPanel.addBannerPanel( figure(randi(1E4)), jIP );
The MATLAB setting that controls whether this should appear is showinteractioninfobar inside the <prefdir>/matlab.settings XML.
It appears that the "interesting parts" of InfoPanel are private, which means it allows barely any customization (mostly some colors; not the string or the icon), but it should be fairly easy to make a copy of this class and expose all elements we need.

PyQt5 select text across multiple QTextEdit boxes

I am trying to create something similar to this in PyQt5:
https://www.screencast.com/t/1FikGosKbS
I tried using a separate QTextEdit widget for each bullet point and overriding the enter key to go to the next textbox, but I don't know how to make multiple QTextEdit widgets selectable (and able to copy paste) like in the example.
How can I allow the user to drag to select text across multiple QTextEdit boxes? Or is there a better approach to this?
I don't know this application is made from Qt or not,but I have an idea.
Parhaps you might have made the most part of this application... I can't know them from your question.I write my opinion on the premise that you don't know QText handling at all.
QTextEdit,QTextDocument,QTextCursor are used fully.
1.To understand block.
2.To use QTextBlockUserData(If you want.)
3.To use QGraphicsItem as nodes.
4.To go other page,we add a new QTextEdit on QStackedWidget or replace the QTextDocument of QTextEdit.
5.To make sub-nodes block,you can coordinate the indentation of blocks.
QTextBlock is a read-only data in a document.
You make QTextBlockUserData and set it to the block.
If you select multiple blocks you want to drag & drop , you use QTextCursor and movePosition methods with sequence.
The nodes of this application can not be QTextListFormat,because we cannot handle mouse click on the style.But you can insert empty-style QTextListFormat.
The truth of the nodes may be QGraphicsItem.
You can allocate it each the start position of blocks and the item can also have the block data.
It will difficult to take care of the connection between the nodes and the blocks.
In advance, you must set QGraphicsView & QGraphicsScene.
I insert many data on the container.
Which should we control with nodes or block?
My trial.
1.Nodes & Text
2.To the other page
3.Sub nodes & blocks
4.close sub nodes & blocks
My trial is incomplete,but it will be completed with endurance.
Logically,I think I can go step until the good point with these combinations.
But it will be diffcult...
These nodes are made from QGraphicsItem and allocated each Blocks.
You must calculate the position and recalculate during editing.
The mouse cursor image is deleted on these images.
It is outrange of screenshot.

Masks: Setting "MaskValues" parameter failling on matlab 2014b

I am currently working with a bunch of code using matlab programatically controlled masks.
I just ran into a new problem, which I did not experience before.
I have to change a checkbox state in the mask, I am basically doing the following:
maskNames = get_param(gcb, 'MaskNames');
maskValues = get_param(gcb, 'MaskValues');
// search in maskNames for the checkbox
// change the corresponding index in maskValues (from "on" to "off" in this case)
set_param(gcb, 'MaskValues', maskValues);
For some reason, this is not working under matlab 2014b. The checkbox remains checked, and if I perform a "get_param('MaskValues')" I can see the value is still to "on".
This works on Matlab2011b (same code, no version branches).
However, if I do a simple : set_param(gcb, 'ParameterName', 'off'), then it works. However I cannot really do this as there could be multiple checkbox to change at once and we are using the MaskNames cell search in order to determine which mask component should be modified.
What I do not get, is that I already work on masked blocks and we are using the exact same framework to communicate with them. So basically on other blocks on which I am setting popups, it is working on matlab 2014b.
So I'd like to have an insight of what could cause this problem and how to solve it, because basically I am in a situation where I cannot guarantee that the other chunks of code and other existing blocks using this technique will continue to work or are not even already broken.
Thank you guys

Bokeh - How to use box tool without default selections?

I have built a bokeh app that allows users to select windows in data and run python code to find and label (with markers) extreme values within these limits. For ease of interaction, I use the box select tool for the range selection. My problem arises when repeating this process for subsequent cases. After markers are placed for the results, they are rendered invisible by setting alpha to zero and another case needs to be chosen. When the new select box includes previous markers, they become visible based on the selection. How do I override this default behavior? Can markers be made unselectable? or can I add code to the customJS to hide them after they are selected?
Thanks in advance for any help!
There are a few possible approaches. If you just want non-selected glyphs to "disappear" visually, you can set a policy to do that as described here:
http://docs.bokeh.org/en/latest/docs/user_guide/styling.html#selected-and-unselected-glyphs
Basically, for bokeh.plotting, pass
nonselection_fill_alpha=0.0,
nonselection_line_alpha=0.0,
as arguments to your plot.circle call or whatever. Or if you are using the low level bokeh.models interface, something like:
renderer.nonselection_glyph = Circle(fill_alpha=0.0, line_alpha=0.0)
But be aware (I think you already are) that the invisible markers are still there, and still selectable if the user happens to draw a box over them with the selection tool.
If you truly want only a subset of the data to be visible and selectable after a selection, I'd say you want to replace the data in the column data source wholesale with the subset in your selection callback.

how to hide existing uicontrol in Matlab before printing figure?

I am using a Matlab based program that does some nice plots of some model results. It adds uicontrol slides and buttons in figures. I have no expierence with gui programming in Matlab, and I dont need it, I just wanna add on my matlab script a couple of lines to hide slides and buttons. I can do it manually from the property editor and set "Visible" to "off", but I was reading the Matlab manual and it does not explain how to retrieve an existing uicontrol and change its properties. Any hint? I tried this with no luck:
b = get(gcf,'uicontrol');
set(b,'Style','pushbutton','Visible','off');
Thanks
You simply need to access the element from the handles structure and change its property from there.
For example, if the pushbutton is stored in the handles structure like this:
handles.b %// Whatever name you gave it and see in the Property Inspector
you can make it not visible using the command
set(handles.b,'Visible','off')
and likewise for every other properties.
Little trick: If you need to repeatedly turn on and off elements of your GUI, you can put them in an array of handles for example in the Opening_Fcn of the GUI and change them all at once using this array anywhere in the GUI. This way you won't have to always call them one by one which can be tedious.
Example:
handles.AllButtons = [handles.button1; handles.button2; handles.button3]
this contains the handles to 3 pushbuttons let's say. Now if yu need to turn them all off/on at the same time, you can do:
set(handles.AllButtons,'Visible','off')
instead of doing
set(handles.button1,'Visible','off')
set(handles.button2,'Visible','off')
set(handles.button3,'Visible','off')
From GUIDE, you can check the actual name of any uicontrol component in the Property Inspector. Here is a screenshot from a GUI I made with GUIDE:
In this case, the Tag associated with the button is pushbutton28_ReferenceChannelApply.
Therefore, in order to change any of its properties I would need to use:
set(handles.pushbutton28_ReferenceChannelApply,'Property','value')
EDIT 2
You can look for pushbuttons in your GUI with the findobj command like so:
FindButtons = findobj('Style','push')
which will output an array of handles to those pushbuttons. Then you can query their properties using the get command:
get(FindButtons(1))