Creating a tool that gets coordinates of selected object

Discussion forum for contributors and developers who are using the QCAD version 3 ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Creating a tool that gets coordinates of selected object

Postby s4eed » Mon Nov 18, 2013 9:44 pm

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/developer/_creating_new_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!
s4eed
Junior Member
 
Posts: 18
Joined: Fri Sep 27, 2013 3:23 pm

Re: Creating a tool that gets coordinates of selected object

Postby andrew » Mon Nov 18, 2013 9:58 pm

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/master/scripts/Misc/Examples/DrawExamples/ExDrawBoundingBox/ExDrawBoundingBox.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...");
User avatar
andrew
Site Admin
 
Posts: 2754
Joined: Fri Mar 30, 2007 6:07 am

Re: Creating a tool that gets coordinates of selected object

Postby s4eed » Mon Nov 18, 2013 10:10 pm

: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?
s4eed
Junior Member
 
Posts: 18
Joined: Fri Sep 27, 2013 3:23 pm

Re: Creating a tool that gets coordinates of selected object

Postby s4eed » Mon Nov 18, 2013 10:11 pm

Got It ! I can use every Qt classes in my .js file. Is it true?
s4eed
Junior Member
 
Posts: 18
Joined: Fri Sep 27, 2013 3:23 pm

Re: Creating a tool that gets coordinates of selected object

Postby andrew » Mon Nov 18, 2013 10:18 pm

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.
User avatar
andrew
Site Admin
 
Posts: 2754
Joined: Fri Mar 30, 2007 6:07 am

Re: Creating a tool that gets coordinates of selected object

Postby s4eed » Mon Nov 18, 2013 10:22 pm

I've never seen someone conscientious like you Andrew. Again thank you.
s4eed
Junior Member
 
Posts: 18
Joined: Fri Sep 27, 2013 3:23 pm


Return to QCAD 3 Developers and Contributors

Who is online

Users browsing this forum: No registered users and 1 guest