PickCoordinate

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
Tom
Newbie Member
Posts: 4
Joined: Thu Feb 18, 2016 5:29 pm

PickCoordinate

Post by Tom » Thu Apr 14, 2016 9:22 am

Hui Guys,

the Last two days I wondered and wondered. I want use a Snap with PickCoordinate a decide to use RSnapEnd() to catch Points from Entities. If I use the RSnapEnd-Object from Stack QCAD crashed on finishing of the ActionAdapter, but trigger a coordinateEvent Event. If I use the RSnapEnd-Object from Heap QCAD not crash, but not trigger a coordinateEvent Event. And be sure, I don't make a mistake with allocation or heap management. Is there any example for use the setClickMode(PickCoordinate) in C++, no Scripting. For this I should have a full compileable Version of QCAD.

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: PickCoordinate

Post by andrew » Thu Apr 14, 2016 9:35 am

Snaps can be set through the document interface, setSnap:
di->setSnap(new RSnapEnd());
The document interface takes ownership of the snap object (i.e. deletes it if no longer needed).
Is there any example for use the setClickMode(PickCoordinate) in C++, no Scripting.
No, QCAD does all user interaction on the scripting level.
However, you should be able to translate js code directly to C++ code (see for example SnapEnd.js to learn how to set the snap function or Point1P for a setClickMode usage example.

Tom
Newbie Member
Posts: 4
Joined: Thu Feb 18, 2016 5:29 pm

Re: PickCoordinate

Post by Tom » Fri Apr 15, 2016 5:40 am

I'm so sorry. But I don't want use Scripting because it is sooooooooo slow. If you know the solution for my problem is simple. It's important to call setClickMode() before you set a Snap Object with setSnap(). And it's important that you generate the Snapobject on Heap, because RDocumentInterface try to delete this Object after finish to use.

If anyone interested on Customized Menus write to me. I write a Module for read the Menudatas from a XML-File an generate a new Menu. A Blockmanager will follow.

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: PickCoordinate

Post by andrew » Fri Apr 15, 2016 8:19 am

Tom wrote:I'm so sorry. But I don't want use Scripting because it is sooooooooo slow.
I'm sorry to hear that. I don't see any noticeable differences here, except on very old (10+ years) machines from the single core CPU area.

Poor performance can also be caused by a slow hard disk or if QCAD is run from a network drive. This has nothing to do with scripting but rather with the fact that QCAD loads tools and resources (.js files, .ui files, .svg files) on demand. It would be possible to work around this by bundling all resources (scripts, icons, etc.) into a resource plugin which is then loaded at start up.

Scripting is mostly used to trigger C++ code and to build up the GUI. The reasoning being that when it comes to user interaction, the user is typically the slowest element.

The most script intensive part of QCAD is the start up to build up the whole user interface. This take about 3s here on a modern system and 4.5s on a 6 years old computer. When running an emulated Windows system under vmware on that 6 years old computer it's about 5.5s. It would be interesting to hear how long that takes on your end (on Unices, you can measure the startup time using this command (-quit quits immediately after start up is complete):

time ./qcad -quit

Triggering a tool through scripting might cause a slight delay when the tool is started for the first time (code and resources have to be loaded). Depending on the tool this can be between 50ms (line tool) and 250ms (switching to print preview) but I don't think this can be described as soo slow with quite that many o's ;)

It might be worth looking into the actual cause of the performance issues you are experiencing before rewriting 50% of the QCAD source code. To be perfectly honest, if you don't intend to use scripting, I would strongly recommend not to be using QCAD at all and base your application on something else like Teigha.

Tom
Newbie Member
Posts: 4
Joined: Thu Feb 18, 2016 5:29 pm

Re: PickCoordinate

Post by Tom » Mon Apr 18, 2016 4:25 am

It's difficult to explain, but I try. You are right if you write that user interachtion is not time critical. That's true. But this isn't the point. The point is that QCAD has signifikant latency if a user make actions wich correspondence to the QCAD Kernel. For example. I load a drawing with 1000 entities (that is a small drawing for me). In that drawing we use 30 layer from layer1 until layer30. Then I open the Layer Management Window an press the freeze button. Now you wait a bit then the view change. If you do it fast, and in the Layer Management Window you can do it fast, the system not fast enough to follow the clicks. That is a knock out criteria. Only that example ? No, I have one more. I use the same drawing as before. I change in Selection mode and klick to an entity. After 2 Seconds the Entity was marked. But sorry, why I have to wait 2 seconds ? This is a drawing with 1000 Entities. The selection need maximum 1/1000 Sec. . Why I wait 2 Seconds ? I can proof what I write ? Sure I reimplement both functionalities in C++ and it works with the speed I want. So I decide that I reimplemeted every functionality I need from QCAD in C++. The user interface is not the problem. The problem is if the user interface need the kernel to make an operation on the drawing database.

Oh, my developement system is a first generation i7 2940 Mhz, a hard disk newest generation (2 month old). 3 Gbyte RAM on a 32 Bit Windows 7 System. No Internet, no network.

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: PickCoordinate

Post by andrew » Mon Apr 18, 2016 7:54 am

Can you e-mail me that drawing file? Selection of a single entity is instant here even with 100'000 entities. If there are bottlenecks caused by scripting, those need to be carefully investigated and addressed. Freezing a layer does not involve much more than one script call into C++ (as you can see in ToggleLayerVisibility.js). If there is a performance problem, it's somewhere else.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”