Physion

  • Increase font size
  • Default font size
  • Decrease font size
Welcome, Guest
Username Password: Remember me

zzz_mousefilter V1.0, adds some useful functions
(1 viewing) (1) Guest

TOPIC: zzz_mousefilter V1.0, adds some useful functions

Re: Move objects with Shift pressed+Mousemove 6 years, 6 months ago #444

  • Lynxx
  • OFFLINE
  • Moderator
  • Java/C#-Developer
  • Posts: 223
Nait wrote:
Lynxx wrote:
It's nice, you may know there is already a rotate/scale-filter in Physion:
Select one or more objects, Press and hold Shift (to rotate) or Ctrl (to scale), then use the Mousewheel.

It's gradual rotate (in 4 degree step) and scale (*1.1), i thought that manual is better))
But yours is nice to because it let all objects rotate around their combined center.

Yeahh, it was the hardest thing to do - i even got such result that objects begin to move on spiral trajectory!
I tried to change it QEvent.Wheel + Alt press, but failed .. :-/

I don't understand anything of what you wrote
Is it important to change onWheelSpin action?
---
Btw, it's a good idea! I think, I should try to make a clone and resize filters with manual-mouse control!

I guess i found out what the problem with the "events" is, all Event-Classes derive from QEvent (that perfectly normal and it should be this way), but only QEvent is given in the Filter-Function.

The object must then be casted to it's original classtype before it's possible to access the additional fields.

Something like:
helpevent = static_cast<QHelpEvent *>(event); or
helpevent = qt_metacast<QHelpEvent *>(event); or
helpevent = qscriptvalue_cast<QHelpEvent *>(event); or
helpevent = cast<QHelpEvent *>(event); or
helpevent = qobject_cast<QHelpEvent *>(event); or
helpevent = QObject.qobject_cast<QHelpEvent *>(event); or
helpevent = QObject.cast<QHelpEvent *>(event); or
helpevent = qvariant_cast<QHelpEvent *>(event); or
eval("helpevent = static_cast<QHelpEvent *>(event);"); or
eval("helpevent = qt_metacast<QHelpEvent *>(event);"); or
eval("helpevent = qscriptvalue_cast<QHelpEvent *>(event);") or
eval("helpevent = cast<QHelpEvent *>(event);"); or
eval("helpevent = qobject_cast<QHelpEvent *>(event);"); or
eval("helpevent = QObject.qobject_cast<QHelpEvent *>(event);"); or
eval("helpevent = QObject.cast<QHelpEvent *>(event);"); or
eval("helpevent = qvariant_cast<QHelpEvent *>(event);") or
...

but neither of this will work in Physion .. it's javascript is some special (even simpler) form then documented in Qt Reference Documentation, imho it's "qtscript" !?
Infinity is vast, especially near end.
bye, Lynxx

Re: Move objects with Shift pressed+Mousemove 6 years, 6 months ago #448

  • Nait
  • OFFLINE
  • Senior Boarder
  • Posts: 60
I've made resize filter, but it works only with circles and boxes(
Here it is.
If polygon points were written as an array not as string...
Gonna make clone filter.
Btw, I tried to use NoModifier instead ShiftModifier , but it doesn't seem to work
Attachments:
Last Edit: 6 years, 6 months ago by Nait.

Re: Move objects with Shift pressed+Mousemove 6 years, 6 months ago #450

  • Lynxx
  • OFFLINE
  • Moderator
  • Java/C#-Developer
  • Posts: 223
Nait wrote:
...
If polygon points were written as an array not as string...
Gonna make clone filter.
Btw, I tried to use NoModifier instead ShiftModifier , but it doesn't seem to work

Nice, made a new version.

About the polygon-problem:
Convert a String to an array, for example in Polygons
item.GeometryString.split(' ');


Mouse & Keyboard-enum bug
Mouse and Keyboard-Modifiers are defined as an enum of QFlags
which is decribed as "The QFlags class provides a type-safe way of storing OR-combinations of enum values."
this means it should contain bits for the pressed modifiers/buttons.
In Physion it's implemented as Object and if you i.e do in console:
QApplication.keyboardModifiers()
while pressing for example Shift+Alt+Return you will see:
NoModifier,ShiftModifier,AltModifier

Normally those flags would be checked by using QFlag.testFlag(Enum flag), but QFlag isn't avail in Physion,
but masking the values with the checked modifier/button using and operator should work.
But both enums for Keyboard-Modifiers and Mouse-Modifiers are starting with a 0 (zero), which isn't a good idea because it's no bit.
if(QApplication.mouseButtons() == Qt.NoButton) will work (objects are the same, or compare-operator of this object is working correctly),
but if(QApplication.keyboardModifiers() == Qt.NoModifier) will not work (either object not the same, or compare-operator not working correctly),
so the only safe way to check for NoModifier/NoButton is converting the result of .keyboardModifiers/.mouseButtons to a number and compare them:
var modi = QApplication.keyboardModifiers();
if (modi.valueOf() == Qt.NoModifier)
debug("No Modifier");
else
debug("Modifiers: "+modi.toString());
 
var butt=QApplication.mouseButtons();
if (butt.valueOf() == Qt.NoButton)
debug("No button");
else
debug("Button: "+butt.toString());
Infinity is vast, especially near end.
bye, Lynxx

Re: Move objects with Shift pressed+Mousemove 6 years, 6 months ago #453

  • Nait
  • OFFLINE
  • Senior Boarder
  • Posts: 60
Lynxx wrote:
About the polygon-problem:
Convert a String to an array, for example in Polygons
item.GeometryString.split(' ');

This doesn't solve the problem
I.e
arr = [0.5, 6]; 
//arr[0] returns 0.5
var points = item6.GeometryString.split(' ')
// points[0] returns -0.75,2 , but points[0][0] returns - instead of -0.75

And please, can you tell me about Creative Commons in two words?

Re: Move objects with Shift pressed+Mousemove 6 years, 6 months ago #455

  • Lynxx
  • OFFLINE
  • Moderator
  • Java/C#-Developer
  • Posts: 223
Nait wrote:
item.GeometryString.split(' ');

This doesn't solve the problem
var points = item6.GeometryString.split(' ')
// points[0] returns -0.75,2 , but points[0][0] returns - instead of -0.75

Just split again:
obj=points[0].split(',');
debug("X: "+obj[0]+" Y:"+obj[1]);

Nait wrote:
And please, can you tell me about Creative Commons in two words?

Oh should have used the english link.
Infinity is vast, especially near end.
bye, Lynxx

Re: Move objects with Shift pressed+Mousemove 6 years, 6 months ago #460

  • Dimitris
  • OFFLINE
  • Administrator
  • Posts: 218
Veeeery nice

The only slight problem is that by pressing the 'Alt' key, the menu is triggered. So I have to first press and hold 'Shift' and then press and hold 'Alt' to make the objects rotate.

But yours is nice to because it let all objects rotate around their combined center.
I agree

The object must then be casted to it's original classtype before it's possible to access the additional fields.
Is it possible to cast (to a non standard type) in javascript?

The event that is passed to eventFilter is the specific QxxxEvent and in that sense (in languages like javascript) you can call event.SpecificMethod() without first having to cast it. At least that was the impression I had. Now it's a mystery to me why, for example, when the event is of type "GraphicsSceneMouseMove" you cannot access the method pos() through the event.
Moderators: Lynxx, Glenn555
Time to create page: 0.23 seconds