![]() Registered Member ![]()
|
I was writing a plugin to utilize my 3d mouse with krita using spacenav library. I wish to be able to pan, scale and rotate via 3d mouse.
I was able to get events from it using QSocketNotifier via python plugin, but I cannot find a way how to pan the canvas (or view) from there. I searched for any functions regarding that at these places : - https://api.kde.org/extragear-api/graph ... anvas.html - https://api.kde.org/extragear-api/graph ... sView.html Is there any other way to achieve panning via API ? To clarify, I want smooth panning, which means i'd prefer to be able to tell how much to pan with great precision. This is what you get if you pan via mouse but NOT via keyboard, panning via keyboard is in large steps (which i dont want). |
![]() KDE Developer ![]()
|
No that's not possible. Interestingly, we used to have a spacenav plugin, back in the koffice/calligra days. We even had two devices, but they disappeared when the developers who had them left the project. The code should be easy to resurrecct from an older calligra release, though.
|
![]() Registered Member ![]()
|
Oh. Well... if its old code then I am not very sure if it will be easily useable via python. I was hoping to do it via python only. Thanks anyways though. |
![]() KDE Developer ![]()
|
Well if you just want support for the 3d mouse, it might be easier to resurrect the plugin
![]() |
![]() Registered Member ![]()
|
The problem is I will have to first understand how to make c++ plugins for krita. I did find out the code by searching in git, but I have no idea how can I port it to current Krita. I am not saying its a huge task, but I dont even know how big or small it is. Next I will need to figure out how to retrieve the objects I require, and I havent yet found a nice dev guide for krita (I havent looked very hard though), but this is understandable as krita is undergoing heavy development. Last, but not the least, I wanted to avoid the compile/run cycle. That being said, I did found a way to achieve it via Python. ![]() Then I did QObject::dumpObjectTree on the MainWindow object (acquired via .qwindow() method from python API) to find out where these controllers are. I found that they are under KisView objects, which are named view_0, view_1, and so on, depending upon how many views are open. I then searched for children of the toplevel window using regular expression "view_.*" (using QObject.findChildren). From the list i got, I iterate to check which one of them is under the mouse, and that happens to be the view where I am working on. Then I acquired the KisCanvasController child as QAbstractScrollArea, and then retrieved their .horizontalScrollBar () and .verticalScrollBar () and then modify their .value () property as needed.
|
![]() KDE Developer ![]()
|
That is hacky, but cool
![]() |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]