Page 1 of 1

Creating a tool that gets coordinates of selected object

Posted: Mon Nov 18, 2013 9:44 pm
by s4eed
Hi friends. Specially dear Andrew!
I need to create a new tool that extracts properties of selected object(x, y, width, height) and processes them and displays a result to the user. For example suppose this scenario :
1-User selects a car in his map ( opened in QCad )
2-User selects my tool(from toolbar or menubar)
3-(Here is the problem!) My tool gets x,y,w,h of selected car and produces a result based on these four numbers and displays a message box to the user.

I can create new tool (I've read this : http://www.qcad.org/doc/qcad/3.0/develo ... _tool.html!) But first of all I want to know whether it's possible doing such a task completely in Qt(processing the x,y,w,h numbers)?
Second I need a start point for how to do this task?
Thank you guys!

Re: Creating a tool that gets coordinates of selected object

Posted: Mon Nov 18, 2013 9:58 pm
by andrew
You might want to have a look at the bounding box example which is very similar:

scripts/Misc/Examples/DrawExamples/ExDrawBoundingBox/ExDrawBoundingBox.js

(Online at: https://github.com/qcad/qcad/blob/maste ... dingBox.js)

This is no problem with the Qt / QCAD script environment.
Displaying a message box is as simple as:
QMessageBox.information(null, "Title", "My message...");

Re: Creating a tool that gets coordinates of selected object

Posted: Mon Nov 18, 2013 10:10 pm
by s4eed
:D Really thank you ! But how can I create a tool completely in Qt.That's my problem, not showing a message :D . Is there any tutorial?

Re: Creating a tool that gets coordinates of selected object

Posted: Mon Nov 18, 2013 10:11 pm
by s4eed
Got It ! I can use every Qt classes in my .js file. Is it true?

Re: Creating a tool that gets coordinates of selected object

Posted: Mon Nov 18, 2013 10:18 pm
by andrew
Yes. Almost the entire Qt API is available in scripts. If you need help or an example for a particular class, just search through the scripts directory of QCAD - chances are there is already a script showing how to use that class somewhere.

Re: Creating a tool that gets coordinates of selected object

Posted: Mon Nov 18, 2013 10:22 pm
by s4eed
I've never seen someone conscientious like you Andrew. Again thank you.