How is it possible to get, directly from the Matlab command window, the position (i.e. the coordinates) of an object (e.g. an arrow, a rectangle or sim.) that I have drawn on a plot?
You can usually do this using the handle graphics properties. For example:
Make a plot
h = plot(1:10, rand(10,1));
Then get the actual values of the points
x = get(h,'xdata')
y = get(h,'ydata')
Different types of objects have different properties, sometimes you have to explore. In that case this syntax is useful.
get(h) %This displays all available properties on `h` to the command window
A final useful tidbit is the gco ("get current object") function, which provides the handle of the last item that you plotted or manually clicked on. This can help if you're not sure where the plotted item came from.
Edit:
To find all of the properties which are descendents of an object, use either findobj, or findall. For example:
findobj(gcf); %Returns all non-hidden, typical objects. This should be your first attempt.
findall(gcf); %Returns all children, even hidden object, such as titles, manually added annotations, and UI menus
This call removes some common UI annotations
get(findall(gcf,'-not','type','uimenu','-not','type','uitoggletool','-not','type','uipushtool','-not','type','uitogglesplittool'),'type')
(Presumably the last example could be improved with a properly designed regexp, but I can't seem to get that working right now.)
Related
I am building up composite layups and assigning them to element sets. When I do so as soon as I try to submit the job, Abaqus always gives me the error "The following parts have some elements without any section assigned". There is not a single element without a material property, I do this by a script. As soon as I use a set which does not contain elements but a geometry Abaqus highlights the region green, but using geometry instead of element sets is not very suitable for me, because I am changing the properties of different elements. Also the region selection window opened by abaqus says "Sets below may contain elements, cells, shell faces or wire edges", so it should be possible to use element sets right?
I use the section assignment only for a small amount of elements, everything else is covered by composite layups.
If needed I can share more details from my model, but as I am not sure where to look for any errors right now, I wont do that right now.
Best regards and thanks for any advice!
You can do data check and then in open generated odb in viewer. In opened odb you can find ErrElemMissingSection in 'Display groups'
We have a script that export our Indesign documents to HTML and one of the routine is to export tables. In this script we go throught each Tables->Rows->Cells and evaluate some of the properties (i.e. bottomEdgeStrokeType, topEdgeStrokeType, etc...) and transport them to HTML.
Now yesterday we had problem converting one particular document because some cells were missing the "bottomEdgeStrokeType" property entirely. I've discovered this by outputting the properties of each cells and compare the faulty ones with the others.
This line bellow was trowing the error: "Invalid object for this request.".
var cellType = cell["bottomEdgeStrokeType"];
Now, to fix this I've wrapped this around a try catch block to handle the case when it's not there, but now what is puzzling me is how on earth can Extendscript instantiate an object with missing properties?
Indesign version: CS5.5
A property is not only 'undefined' if it cannot exist at all (such as asking for the parent text frame for a character in overset text), but InDesign's Javascript engine also fails to return a reasonably accurate result for multiple values.
If you ask for "the" point size of a paragraph, where this paragraph contains multiple sizes, poor ID does not consider to return something like CONSTANT.Mixed, or the first value only, or (what I might have preferred) an array of the values; it returns undefined instead.
So how can a single table cell have multiple bottom strokes? If the cell underneath it is split into multiple cells, and one has a "top" stroke but the other has not.
It's difficult to recommend an adequate solution. You could first test if the current cell is "merged" (as far as InDesign's internal table model is concerned) with columnSpan; and if so, iterate over the number of columns spanned and test the next row's cells for their top stroke, which in theory should match the bottom stroke of the cell above. (I find myself wondering if this is always true. ID's table model is ... weird. It's not entirely like a HTML table, despite the functional overlaps.)
If columnSpan is greater than 1 and equal to the number of cells immediately below the current one, you could test if all of their "top" values are the same and if so use that value. (I never tested this so ID's table model may simply fail because a cell is merged, regardless of same-values or not.)
One could attempt to flag this cell's next row to output "top" strokes as well -- but alternating top and bottom strokes may not align nicely in CSS, side to side. Perhaps it's best to translate only the first top stroke value to "the" bottom stroke property for your current cell, and fix up manually where needed (how?) or, a reasonable action, hope that no-one will ever notice it.
For mouse I'm using:
ourEvent = CGEventCreate(None);
currentpos = CGEventGetLocation(ourEvent);
What can I use for the caret?
First the bad news.
Not every app is Cocoa-based, and those that are neither Cocoa nor Carbon nor a straight mix of the two—i.e., those based on wxWidgets, Qt, or some other cross-platform framework—typically reimplement the entire GUI stack on top of raw event and drawing primitives.
That means that there is typically no way to get this information from those applications (unless they're scriptable and expose it that way).
The good news is, Cocoa apps and some Carbon apps may expose this via Accessibility.
The user will need to have assistive devices turned on in System Preferences. Once that condition is met, you can use the Accessibility framework to get the frontmost application, get its focused window, get its focused view, and get its selection ranges.
A text view with an insertion point has exactly one selection range, and that range is empty (length=0). The location is where the insertion point is.
Of course, those are character indexes, not on-screen bounds.
That's where parameterized attributes come in. There's one for converting ranges to bounds. That's the one you want.
Theoretically (I haven't tried this), you should be able to convert the empty range of the insertion point to an empty or nearly-empty rectangle whose location is somewhere within the vertical line of the insertion point.
Make sure you test this with text views that are in scroll views, particularly when the insertion point is scrolled partially or completely out of view.
You'll want to use the Accessibility Inspector to see for yourself where your application will need to look, and to test individual applications and investigate reported failures.
You can get it from the Developer Downloads page, in the “Accessibility Tools” disk image.
If you want to focus a window, forging a mouse event to click on it is a bad idea—anything can happen if you click on the wrong thing. Send the window an kAXRaiseAction action instead.
If you want to set a text view's insertion point (and are looking to find where you need to forge a mouse event to click to set it in the desired position), again, that's a bad way to do it. Set the view's kAXSelectedTextRangesAttribute attribute instead. Again, an insertion point is a single empty range.
Did you try like this below?
NSPoint p=[[NSApp currentEvent]locationInWindow];
CGFloat X=p.x;
CGFloat Y=p.y;
NSLog(#"%f %f",X,Y);
For a word processor I am writing I need to know sometimes the caret coordinates (the reason is long and uninteresting for the question itself). I writing the app. in Objective-C. I don't want to make calls to JavaScript and I don't want to make "tricks" like altering the DOM to get the caret coordinates (one solution would be to insert an empty span at the caret position and measure it bounding box). I've searched for methods that get the selected domrange bounding box with no success.
The only thing I found was a caretRectAtNode:offset:affinity in WebCoreFrameBridge (and other methods that seem to do what I want). So I see basically two answers to my question
1) There is a magic method in WebView that I am not considering
2) Tell me how to call methods inside WebCoreFrameBridge using Obj-C, and having a reference to a WebView/Frame/etc.
Is there a way in Gtk+ to stack one widget on top of another -- not counting GtkFixed? GtkFixed doesn't work well for two reasons: 1) I need Z order, and 2) I need one widget to stretch and fill provided space.
I had this exact issue using a Gtk::Fixed (actually gtk.Fixed -- pygtk -- but I think it's all the same underneath) and I was able to handle it quite easily by manipulating each widget's window.
In my case, the widgets already are EventBox instances, and I just needed to make sure that the one I was dragging around was on top, because otherwise it slid underneath others, which looked quite wrong. The solution was as simple as calling "widget.window.raise_()" to raise the widget's underlying window when the widget was clicked to begin the drag.
So I'm basically just reaffirming that the previous answer works, but I wanted to point out that it's actually pretty easy. It sounds like you may need to create some EventBoxes to hold your widgets, but after that it should just work.
You can see the code I was working on at http://github.com/divegeek/BlockHead
I don't think there is a proper container in standard GTK. I would subclass Gtk::Fixed... it is still the closest one you can get, and if you use gtkmm then subclassing shouldn't be very difficult¹. Then you can control the dimensions of all widgets, stretching one selected child to fill space.
To control Z-axis you will probably need to manipulate widget's X windows--check GDK documentation on topic of GDK windows². I remember that in PyGTK each widget has gtk.Widget.window property, I guess that the same is for gtkmm. This assumes that all your child widgets have X windows, so f.e. you'll need to wrap Gtk::Label inside Gtk::EventBox.
¹ http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/chapter-customwidgets.html
² http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGdk_1_1Window.html#6eef65b862344ad01b01e527f2c39741
I was able to do exactly that -
display one widget filling the entire space, and then another on top at a fixed location, both visible at the same time
in gtk2 by using GtkFixed, working out a suitable insertion order (first inserted - bottom, last inserted - top), and - most importantly!! - forcing GtkFixed to have it's own window:
`f := gtk_fixed_new();
gtk_widget_set_has_window(f, 1);`
If you don't do set_has_window(f, 1), all children windows will be inserted into some parent widget/window (see gtk_fixed_realize() in gtkfixed.c), and that might create z-order mess.