[Updated beta 0.42e] FlexPainter beta 0.34

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.

CVH
Premier Member
Posts: 3415
Joined: Wed Sep 27, 2017 4:17 pm

[Updated beta 0.42e] FlexPainter beta 0.34

Post by CVH » Thu Sep 05, 2019 4:15 pm

Hello to you all,

Here goes nothing....

It started with an order of my old mentor in engraving.
He is retired and lives partially in Uganda these days.
The order was to make 14 badges as relation gift.

The first pic is the design I got from him, the second is what I proposed.
ESCU_Commodore.png
ESCU_Commodore.png (64.89 KiB) Viewed 28457 times
ESCU_Commodore_v2.png
ESCU_Commodore_v2.png (32.47 KiB) Viewed 28457 times
I followed a tube on how to flex the rope manually.
Drew 1 corner with Qcad and cloned it 3 times.

The badges are allready donated a while ago.
Engraving them was a whole other story.
Sharpest detail radius is 0.08mm in engavers brass.

But something kept me coming back to it.
As it was merely slicing the 'painter' and recasting it orthogonal on the bend.
A script could do that.
And it could do that with any 'painter' or lines, dots, ....
It is that versatility that drived me in coding it.

For now, the zip package is intended to be extracted to QCAD\scripts\Misc\Examples\MathExamples\
In there is a subfolder 'FlexPainterTemplates' with 2 dxf drawings.
A tutorial on how the painter is constructed, and one with a bunch of test cases.
On a win system they might beter be moved out of the protected OS portion.

Its stable and works exactly how it is intended.
I came to a point where I need some input of the community.
There is a lot of info inside the script file. Look also for 'ToDo' and 'Issue'.
A large remark block is at the end of the script.
These are not intended as a thousand questions in one post.
They are my guidlines to start asking questions or simply not to forget anything....

It might that the coding is horrible, not Java minded, nor Qcad minded, nor proper coded.
But you have to look at the potential far beyond casting a rope.
As I hate to be verbose the tool is persistent verbose.

I like to hear the others their opinion, and if any, about unknown issues.
In the long run I see it to be promoted out the experimental level.

On simple request I will redraw the proposition.

Kind regards,
CVH
Attachments
FlexPainter.zip
(95.19 KiB) Downloaded 2982 times
Last edited by CVH on Sat Aug 29, 2020 4:31 pm, edited 5 times in total.

CVH
Premier Member
Posts: 3415
Joined: Wed Sep 27, 2017 4:17 pm

Re: FlexPainter beta 0.34

Post by CVH » Fri Sep 06, 2019 9:23 am

The script adds an entry to Misc| Script Examples | Mathematics | ..
The script mimics a roller stamp that travels along the selected base curve.

Pictures say more then words.
FlexPainterDialog.png
Command started with all selected.
FlexPainterDialog.png (111.66 KiB) Viewed 28428 times
FlexPainterResult.png
Resulting castings
FlexPainterResult.png (133.96 KiB) Viewed 28428 times

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

Re: FlexPainter beta 0.34

Post by andrew » Fri Sep 06, 2019 9:36 am

This is truly impressive! It's like complex line types on steroids e_surprised

Can this be included in QCAD as an (impressive) example script? What are the licensing terms?
If so, how can I credit you in the about dialog? As CVH?

Thanks.

CVH
Premier Member
Posts: 3415
Joined: Wed Sep 27, 2017 4:17 pm

Re: FlexPainter beta 0.34

Post by CVH » Fri Sep 06, 2019 10:28 am

Thanks Andrew,
much appreciated coming from you.

Please read inside the script.

The math was simply cast left , cast right.
But then it evolved in several stages.
All curve-based
Nice endings.
Apexes.
Dynamically scaling to a closed form (without apexes)
The idee of insertions eg. a knot in this case.
Global casts along the base curve.
Margin crossing.

The FlexPainter having the flaws in steep curves is error-like but it is super realistic.
Twisting a roller stamp to much will smudge.
What about chain-like behaviour?!
Or common stamp like?

But that is all artistic stuff.
Its also a base for more technical stuff with a custom well defined painterset.
Repetitive texts if you like.
Splines through offsets at regular intervals.
......
Endless

Thanks, again
Kind regards,
CVH
Last edited by CVH on Wed Jan 22, 2020 2:07 pm, edited 1 time in total.

CVH
Premier Member
Posts: 3415
Joined: Wed Sep 27, 2017 4:17 pm

Re: FlexPainter beta 0.34

Post by CVH » Fri Sep 06, 2019 11:04 am

My first hurdle is SIZE.

To have a idea of the actual width....
I was thinking in the way CXF is standarized.
A non-limiting base height of 9 units.
4.5 up & 4.5 down.

Then we could work with actual dimensions instead of a scaler of something hardcoded.

But how will this work out on system or a document not in mm.
The hardcoded stamp is about 3mm high.
(10x actual size on the badges)
On a system in inches the same painter is 3 inch high.

We could keep units for units and only adapt the default scaling on first load to the system/document settings.
Metric then starts with eg. f2.5 and Inches with f 0.1 (same order as 0.09842519...)

Do you have an addressable parameter in scope that tells us what the document it's units are?
With this, I think I can test this route out and perhaps increase the user friendliness.
But that all depends on the yes & no of a circular value conflict.

Regards,
CVH

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

Re: FlexPainter beta 0.34

Post by andrew » Fri Sep 06, 2019 1:24 pm

CVH wrote:
Fri Sep 06, 2019 11:04 am
My first hurdle is SIZE.
Yes, I think a standard size would probably be the easiest to implement.
CVH wrote:
Fri Sep 06, 2019 11:04 am
Do you have an addressable parameter in scope that tells us what the document it's units are?

Code: Select all

doc.getUnit()
This returns RS.Unit (RS.Millimeter, RS.Inch, etc.).

Class RUnit has some conversion tools:

Code: Select all

RUnit.convert(1.2, RS.Millimeter, RS.Inch);
to convert 1.2 from Millimeter to Inch.

CVH
Premier Member
Posts: 3415
Joined: Wed Sep 27, 2017 4:17 pm

Re: FlexPainter beta 0.34

Post by CVH » Fri Sep 06, 2019 1:52 pm

Will look into it.
CVH

CVH
Premier Member
Posts: 3415
Joined: Wed Sep 27, 2017 4:17 pm

Re: FlexPainter beta 0.34

Post by CVH » Wed Sep 11, 2019 9:58 am

Andrew,
is there an 'easy' way to set a Dialog not modal.
Can't follow my script in debugger mode with the dialog displayed.

Tried to create a widget instead.

Code: Select all

WidgetFactory.createDialog(...)
vs.
WidgetFactory.createWidget(...)
Only found:

Code: Select all

progressDialog.windowModality = Qt.WindowModal;
ProgressBar.progressDialog.windowModality = Qt.ApplicationModal;
in the master scripts and nothing related to modal online.

Regards,
CVH

CVH
Premier Member
Posts: 3415
Joined: Wed Sep 27, 2017 4:17 pm

Re: FlexPainter beta 0.34

Post by CVH » Fri Sep 13, 2019 9:01 am

CVH wrote:
Wed Sep 11, 2019 9:58 am
Can't follow my script in debugger mode with the dialog displayed.
This seems to be a MS Windows issue only.

CVH
Premier Member
Posts: 3415
Joined: Wed Sep 27, 2017 4:17 pm

Re: FlexPainter beta 0.34

Post by CVH » Fri Sep 13, 2019 10:58 am

Andrew, all,

v0.36 now and a little stuck.

The painter width is now base9.
By this the user can choose the actual width.
And it was also possible to let the actual painter length and stepsize to be set individually.
PreserveLook overrides these two and revert back to base9 times a factor dictated by the unchanged width.
On first load reasonable defaults are set.
(Still not sure how to handle doc changes)

On PainterSet change two values are needed: the base9 painter length & the base9 painter stepsize.
These are set by a function FlexPainter.prototype.PainterSetInit(painterSet) part of Flexpainter.js script.

With inserting a multitude of 'debuggers;' and canceling the Dialog every time,
I still could evaluate one widget dialog change functions at a time before the dialog itself terminates.

I'm stuck on the fact that when the on change functions run the data is out off scope.
(This is starting to begin to be the story off my Qcad experience) :oops:

I've looked up the use of '.connect' in the master scripts and tried some things out.
I don't get further then declaring copies in the FlexPainter.prototype.initWidgets function.
After declaring they remain static and don't reflect the PainterSet change.

As an on change functions runs the flexpainter functions are also out off scope.
Can't find a way to run the FlexPainter.prototype.PainterSetInit(painterSet) function.

Is there a proper way so: :?:
On PainterSet change my data storage reflect the change?
The on change functions have access to that data?

I don't include the new sources because they are corrupt without a solution.
I can PM them for evaluation as long as the dialog is cancelled.

Any help appreciated,
CVH

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

Re: FlexPainter beta 0.34

Post by andrew » Fri Sep 13, 2019 1:34 pm

I tend to use qDebug("..."); rather than debugger statements, especially with dialogs. The debugger can change the order in which events are processed and even lead to crashes. Feel free to PM the sources and I will have a look. That would have to wait till next week though.

CVH
Premier Member
Posts: 3415
Joined: Wed Sep 27, 2017 4:17 pm

Re: FlexPainter beta 0.34

Post by CVH » Fri Sep 13, 2019 2:13 pm

I'll first try to get a version running stable with a 'fixed' actual painterset selection.
Handy, when it not crashes on its own.

I've seen the qDebug throughout the project.
And this link:
https://www.ribbonsoft.com/rsforum/viewtopic.php?t=2872

I suppose the qDebug("..."); is shown in the Debug output tab of the Qt debugger.
When first activated by a 'debugger;' command!?

Regards,

CVH
Premier Member
Posts: 3415
Joined: Wed Sep 27, 2017 4:17 pm

Re: FlexPainter beta 0.34

Post by CVH » Thu Sep 19, 2019 9:09 am


CVH
Premier Member
Posts: 3415
Joined: Wed Sep 27, 2017 4:17 pm

Re: Updated beta 0.40 FlexPainter beta 0.34

Post by CVH » Sun Sep 22, 2019 9:11 am

Flexpainter Beta v0.40
point4 is in essence a full rewrite of the casting core envelope.

Painters are base9 in analog of the CXF fonts. :!:
Definition width is changed to 9 units, non-restrictive.
The user can choose width, length and stepsize in actual document units.

Aligning is now properly supported, with sub-chains as well globally as locally.
(What was of no issue for the 'CurtainRope' because it is slanted) :o

Solved the issues with painter definitions situated on the margins.
The problems occured at entity endings of splines and polys.
I'll post a seperate topic on that. :|

Added several simple but usefull painter sets besides the 'CurtainRope' painter.
These were primarily used for testing.
The sets definitions are still hardcoded in the script file. :|

One catch however: :!:
I am stuck in the code with selecting painter sets in the Dialog. :oops:
Andrew has promised to have a look. :?
I didn't see any gain in sending him a non functional bunch of code.
It took me a while to have it running and to clean out crap code.

Andrew, I've included a problem description.

For now the workaround is to edit the Flexpainter.js:
Activate the desired set at:
lines 1043-1054
And reboot Qcad, sorry for that. :oops:

While you are at it, clean the [FlexPainterOptions] in <QCAD3.ini>.
Changing to units the UI naming stuff changed a bit.
You will get what I mean by this. :wink:
At the moment my insights in this matter is basic to none. :oops:

The adaptation to different document units is still non existent.
A user that paints 1 inch wide should paint 25.4 wide swapping to a document in mm.

The main casting loop is fully revised and better prepared for future enhancements.
For convience some part is cutted up in little detached if blocks.
What has lead to doubling the same if's, off course. :)
The pro was that applying rules and methods and the order of became more flexibel.
It will allready support insertions and sub-chains in testfase.

Treatment of painters adapt to:
a) Over-stepped: step > length
b) Box-stepped: step = length (in se !=a and !=c)
c) Under-stepped: length > step eg. slanted: 'CurtainRope'
Set definitions are categorized in intended purpose.
Not limiting that combinations of parameters may alter the actual type & purpose.

Some groundrules had to be aplied: e_ugeek
1) Painter defs are confined within their lenght and start at the leftside.
2) In essence a complete 'painter' is scaled and stepped.
If this 'painter' ends with a void in any way, the void is part of the 'painter'.
Any chain of repeated painters then ends in one such void.
Casting finishes near the end of an entity.
A 'reversed look' is only achieved on a reversed entity, and not by aligning.

For now only splines were used for the artistic look and the natural behaviour.
Straight splines with only two points are merely Line entities.
One thing lead to more and additional datatypes will be added later:
* Point, Line, Arc?, Circle?, Poly, Hatch?
Several pitfalls here:
* Points are used to cast splines globally along the base entity.
* How to morph a Poly, a Hatch?
Allready the points used for global fitpoints were called 'Dots'
And luckily the first four don't need morphing.

Again, much more in detail it can be viewed is the script file itself. :mrgreen:

Regards,
CVH
Attachments
Note to Andrew.txt
(901 Bytes) Downloaded 2988 times
FlexPainter.v0.40.zip
(108.21 KiB) Downloaded 3033 times

CVH
Premier Member
Posts: 3415
Joined: Wed Sep 27, 2017 4:17 pm

Re: Updated beta 0.41 FlexPainter beta 0.34

Post by CVH » Thu Oct 10, 2019 9:49 pm

Flexpainter Beta v0.41

:!:
Solved the painter selection issue. :)
Don't ask me how. :?
At the moment my insights in this matter is basic to none.

With this fixed the focus is now set on insertions eg. a knot.

:!:
On firts load or on document switch the tool shall
auto adapt to different document units.
There is a story about that this morning, you may want
to read in the note to Andrew.

:!:
Repared the 'flip painter' that was broken with the transition to units.
Repared the spinnerbox for 0-100% shifting that was not spinning. :oops:

:!:
Enhanced the painter definitions types:
- Local: Point, Line, Spline, Arc, Circle, Poly (+bulge!?)
- Global: Spline, Poly (no bulge yet)

:!:
The user can choose width, length and stepsize in actual document units.
Painters are base9 in analogue with the CXF fonts.
Definition width is 9 units, non-restrictive.

:!:
Added some more painters sets.
Added all preview icons of these painter sets.
The sets definitions are still hardcoded in the script file.
The icons are all in a sub-folder 'Icons'.
The idea where I am playing with is to split the definitions into files/scripts.
Any ideas or preferences someone? :idea:

I see that Flexpainter 0.34 is allready included on Github. :shock:
This zip package with version 0.41 is intended to be extracted to:
QCAD\scripts\Misc\Examples\MathExamples\
Included is a subfolder 'FlexPainterTemplates' with 2 dxf drawings.
One is a tutorial on how the painter is constructed, and one with a bunch of test cases.
On a win system it might be beter to move these out of the protected OS portion as Admin.

While you are at it and if you may have used 0.34:
Clean anything related to FlexPainter in <QCAD3.ini>.
You will get what I mean by this. Same as starting with a clean slate.
Changing to units after 0.34 the UI naming stuff has changed accordingly.


Again, much more in detail can be viewed in the script file itself.

Regards,
CVH
Attachments
FlexPainter Beta v0.41.zip
(226.78 KiB) Downloaded 2942 times
Note to Andrew.txt
(1.52 KiB) Downloaded 3005 times

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”