Quartz 2D substitude for graphicsPort in SDK 10.10 - deprecated

The scenario:
I'm editing some CGImages and strangely enough until now I was first creating NSImages from those CGImages before drawing them. So I tried to change the code so that I would draw the CGImages directly in into NSGraphicsContext.currentContext().graphicsPort. As you see I'm using Swing here but the same problem goes for Objective-C I presume.
Having a look into the documentation I saw that graphicsPort will be deprecated in 10.10, but I couldn't find another way to the current CGContext from NSGraphicsContext nor is there a way to create the CGContext from an NSGraphicsContext.
The Question:
Does anybody know what the proper way to retrieve the context would be? If not - Is there a way to cast the graphicsPort's COpaquePointer, which apparently is an initialized NSPipeObject, to a CGContextRef? Although using code that has already been marked deprecated would be quite unsatisfactory I would consider it until there is a better solution.

After spending a half hour digging around for information on this, I realized I should just check out the header file for NSGraphicsContext. Turns out there's a new property on NSGraphicsContext that's apparently not documented yet: CGContext. The header also notes that this should be used instead of graphicsPort.

Related

How can I get a Clip object for a ClipLauncherSlot?

I have a ClipLauncherSlot in Bitwig API, and I'd like to get ahold of the Clip within it so I can transpose it on user input.
The docs aren't online that I know of, so I can't link to them. But extensive searching has yielding absolutely no way of getting ahold of Clip objects in general.
I think you're supposed to work with a CursorClip.
Instead of directly accessing the clip, you access it through a CursorClip. The CursorClip will follow your selection and always represent the currently selected clip.
Something like this:
CursorClip cursorClip = host.createLauncherCursorClip()
clipLauncherSlot.select()
// Now your cursorClips represents the desired clip.
cursorClip.transpose()
Not entirely sure about the exact implementation, maybe you have to do some additonal steps for the cursor to correctly follow, but something like this should work.
See also here: https://www.kvraudio.com/forum/viewtopic.php?t=550738 for a similar problem. They had some problems with execution time, keep that in mind if you run into unexpected behaviour.

Is it possible to include the os library in lua 4.0?

I'm stuck using the 4.0 version of lua which does not seem to support the os library. Is there a way to include this library into my project?
Or get another way to use the functionality contained within pertaining to date time calculations?
Preferably by using a *.lua file and not a *.c file since I don't have complete access to the code.
When I run the following line,
print(os.time{year=1970, month=1, day=1, hour=0})
I get an error stating:
attempt to index global 'os'(a nil value)
As #Colonel Thirty Two said it's not possible to use the os library. So the time() funciton is not available for me.
Adding to the (totally correct) currently accepted answer (that if "os" access was not allowed to you, you're generally done), there's some very slight chance the Original Programmer may have provided you with some alternative facilities to do your thing (fingers crossed). In a perfect world, those would be described in some kind of a User's Manual for your scripting environment. But if the manual was lost to time (or never existed in the first place), you might possibly try your luck at exploring any preloaded libraries by digging through the result of the globals() Basic Function. (At least I hope that's how it was done in 4.0 too.) That is, if the Original Programmer didn't block globals() for you too...

Equivalent to JGraph for JavaFX8?

I want to port an old swing tool which uses an also old version of JGraph to JavaFX8. However, since JGraph is a Swing-Based library, is thought about replacing it, too. So, is there something equivalent to JGraph, but working with JavaFX8?
So, is there something equivalent to JGraph, but working with JavaFX8?
Following Jonathan Giles Blog, I can't remember having read anything about a JavaFX based graph library yet -> so, most likely, no
But you should be able to use Swing controls in JavaFX: https://docs.oracle.com/javase/8/javafx/api/javafx/embed/swing/SwingNode.html

Sketchup API for navigating around a model (eventually to integrate with Leap Motion)

I'm trying to use to SketchUp API to navigate around 3D models (zoom, pan, rotate, etc). My ultimate aim is to integrate it with a Leap Motion app.
However, right now I think my first step would be to figure out how to control the basic navigation gestures via the Sketchup API. After a bit of research, I see that there are the 'Camera' and the 'Animation' interfaces, but I think they would be more suited to 'hardcoded' paths and motions within the script.
Therefore I was wondering - does anyone know how I can write a plugin that is able to accept inputs from another program (my eventual Leap Motion App in this case) and translate it into specific navigation commands using the Sketchup API (like pan, zoom, etc). Can this be done using the 'Camera' and the 'Animation' interfaces (in some sort of step increments), or are there other interfaces I should be looking at.
As usual, and examples would be most helpful.
Thanks!
View, Camera and the Animation class is what you are looking for. Maybe you don't even need the Animation class, you might just be ok with using the time in the UI class. Depends on the details of what you will be doing.
You can set the camera directly like so:
Sketchup.active_model.active_view.camera.set(ORIGIN, Z_AXIS, Y_AXIS)
or you can use View.camera= which also accept a transition time argument if you find that useful.
For bridging input you could always create a Ruby C Extension that takes care of the communication between the applications. There are some quirks in getting C Extensions work for SketchUp Ruby as oppose to regular Ruby though - depending on how you compile it.
I wrote a hello world example a couple of years ago: https://bitbucket.org/thomthom/sketchup-ruby-c-extension
Though note that I have since found a better solution for Windows, using the Development Kit from Ruby Installers: http://rubyinstaller.org/
This answer is related to my comment above regarding the view seemingly 'jumping' when I assign a new camera to the current view using camera=, but not if I use camera.set.
I figured out this was happening because the camera FOV for the original camera was different, and the new camera was defaulting to an FOV of 30. By explicitly creating the camera with the optional perspective and FOV arguments from the initial camera solves this problem:
new_camera = Sketchup::Camera.new new_eye, new_target, curr_camera.up, curr_camera.perspective?, curr_camera.fov
Hope people find this useful!

Undocumented ProcessEventsFlag enums in QT

I noticed that modal dialogs on QT uses a local QEventLoop with the ProcessEventFlags set as "DialogExec"
eventLoop.exec(QEventLoop::DialogExec);
The QT assistant has no information on what this enum means. There is another one called EventLoopExec. Anyone has any idea what they actually mean and why aren't they documented?
Thanks
I did some poking around and this is what I found:
This enum is intentionally omitted from the documentation, along with several other QEventLoop::ProcessEventsFlag enum values (X11ExcludeTimers, ExcludeUserInput, WaitForMore, EventLoopExec) as there is an \omitvalue in front of each one in the comments that generate the docs.
There is only one place in all of Qt that actually uses it, in qeventdispatcher_mac.mm in which it appears to be some kind of mac-specific optimization according to the in-line comments
The intentional omission of these values from the docs leads me to conclude that they're for internal Qt use only, and that you shouldn't need to use them or worry about them.

Resources