smartavionics / RawMouse

Cura Plugin that lets you use a HID mouse to pan/rotate/zoom the view
94 stars 7 forks source link

All axes inverted. A simple fix is below: #11

Open mbourque opened 3 years ago

mbourque commented 3 years ago

I just started to use this and found the 3dmouse moves opposite than expected. On a hunch I edited the config.json file and reversed the scale so that anything negative was positive and visa versa. Now it works great!

"profiles" : { "spacemouse" : { "axes" : [ { "offset": 0.0, "scale": 0.1, "threshold": 0.01, "target": "movx" }, { "offset": 0.0, "scale": 100.0, "threshold": 1.0, "target": "zoom" }, { "offset": 0.0, "scale": 0.1, "threshold": 0.01, "target": "movy" }, { "offset": 0.0, "scale": 0.05 , "threshold": 0.01, "target": "rotpitch" }, { "offset": 0.0, "scale": 0.05, "threshold": 0.01, "target": "rotroll" }, { "offset": 0.0, "scale": -0.1, "threshold": 0.01, "target": "rotyaw" }

ztaylor54 commented 3 years ago

Same for me. Great fix!

jedikalimero commented 3 years ago

I wouldn't call it an issue, but I guess it doesn't fit anywhere else.

The thing is it doesn't move the opposite than expected. The author expected the 3D mouse to act as the controller of the flyby point of view over a static virtual 3D printer (this is the way the 3D mouse works in Google Earth and it makes perfect sense there) while you expected the 3D mouse to act as your hand moving the 3D printer while your eyes stay static. It all depends on the point of view.

But I also find more intuitive and comfortable for me to think about it as you do, so I also inverted the scale values. ;-)

I think to avoid the users having to touch the code just for this, a new feature should be added in the Cura menu Extensions/Rawmouse: a menu entry called something like "flyby mode" that would be checked by default (the way the author conceived) but if you uncheck it, then all scale values are inverted, resulting in the way we feel more intuitive for us.

jedikalimero commented 3 years ago

I experimented a little with RawMouse.py and changed a couple of things to get this feature.

First, I added the new menu item so the new menu definition now reads:

self.setMenuName(catalog.i18nc("@item:inmenu", "RawMouse")) self.addMenuItem(catalog.i18nc("@item:inmenu", "Stop"), self._stop) self.addMenuItem(catalog.i18nc("@item:inmenu", "Restart"), self._restart) self.addMenuItem(catalog.i18nc("@item:inmenu", "Invert FlyBy Mode"), self._invertScales) self.addMenuItem(catalog.i18nc("@item:inmenu", "Show Device Information"), self._showDeviceInformation)

Then I added the function invertScales:

def _invertScales(self): for a in range(0, 6): self._axis_scale[a] = - self._axis_scale[a] return

It works like a charm. Every time you select "Invert FlyBy Mode" in the RawMouse menu, the controls are inverted. The problem is I don't know how to keep this preference after Cura shoots down, so the next time it opens with the controls as they were the last time. I really don't know how to program in Python so I did this just by inspecting the code already present in the program and couldn't find any clue about how to achieve this, but I'm sure the author or someone else who knows more than me will solve it.

smartavionics commented 3 years ago

Hi @jedikalimero , thanks for your suggestions. I have now released version 1.1.1 which, essentially does what you have suggested and it also saves the current state to the Cura preferences so it persists across sessions. Please give it a go.

jedikalimero commented 3 years ago

That's great! Thank you for considering my idea. I'm sure I will learn a little more of Python looking at how you solved saving the state that I couldn't figure out 😊😉👍