|
|
Home » Community » Newbie corner » Adding a text box in a scatterDraw/ScatterCtrl
Adding a text box in a scatterDraw/ScatterCtrl [message #47612] |
Tue, 07 February 2017 09:46  |
Giorgio
Messages: 218 Registered: August 2015
|
Experienced Member |
|
|
Hi there,
I am experimenting with ScatterDraw/ScatterCtrl. I have the need to add some kind of "text box" in a scatter. This is because I need to explain why a graph all of sudden change its behaviour. To give you some context: the graph describes the speed of a production line; usually it is almost constant, but sometimes it drops because of a breakdown of some component on the line. Is there a way to add some kind of text box?
Thanks,
Giorgio
|
|
|
|
|
|
|
|
|
Re: Adding a text box in a scatterDraw/ScatterCtrl [message #47622 is a reply to message #47621] |
Fri, 10 February 2017 23:15   |
 |
koldo
Messages: 3432 Registered: August 2008
|
Senior Veteran |
|
|
Hi Giorgio
Sources are updated. ScatterCtrl demo includes tab17_UserPaint including it.
Provisional interface uses:
- GetPlotWidth(), GetPlotHeight() to get plot area size in pixels
- Pointf GetPosPrimary(double x, double y)
double GetSizeX(double cx)
double GetSizeYPrimary(double cy)
Pointf GetPosSecondary(double x, double y)
double GetSizeYSecondary(double cy)
to get positions and sizes from plot units to pixel units.
As I do not know how to use templates in callbacks, it is used instead this:
void OnPainter(Painter &w) {OnPaint(w);}
void OnDraw(Draw &w) {OnPaint(w);}
template <class T>
void OnPaint(T& w) {
...
}
Advice is acknowledged.
Best regards
Iñaki
[Updated on: Fri, 10 February 2017 23:15] Report message to a moderator
|
|
|
Re: Adding a text box in a scatterDraw/ScatterCtrl [message #48103 is a reply to message #47622] |
Wed, 17 May 2017 12:11   |
Giorgio
Messages: 218 Registered: August 2015
|
Experienced Member |
|
|
Hi Koldo,
it took me ages to test it... the project was stopped and then it suddenly restarted some weeks ago.
A little bit of context: there is an application used on a couple production lines in the factory I work for. This application registers automatically (in a db) the speed of the production line: the line operate on cables and can treat x meters of cable per minute depending on the type of operation. The machinist, using another applications, enters in the db what is doing (setting up the machine, running the machine...) and what product-id he is working on. The goal is to put together all the information to have a report on the production of each shift. This is the result:
https://pasteboard.co/7jRIiP3B3.png
-Using the standard scatter function AddSeries() I draw the blue line (the speed);
-I created also the green, red yellow, bars (those bars says what the operator is doing: running setting up etc.) with AddSeries(), but with a little trick: it is a very thick line with just two points: the first is the begin of e.g running time, the second is the end;
Now comes in the new method OnPaint; with that method:
-I add a letter on the bars to explains what the bar represents (e.g. 'R' for running);
-I add the product-id that has been processed (e.g. 160997100A-60-2 represents a certain type of cable).
That works very well, the problems come when I print or scroll the report:
https://pasteboard.co/7jQzP6HMn.png
https://pasteboard.co/7jStsxNhI.png
When I scroll the report:
-The texts stay "fixed" while the graphs are resized
When I print the report:
-All the texts are very small;
-The bars have rounded edges.
I had a look at the code of the tab "User paint" of the ScatterCtrl_Demo and saw that using scaled font you do not have the same problem I have, so is just a matter of checking the code and understand how scaled font works.
So, the feedback is that the UserPaint callback provides all the needed functionality, it works as expected and has no bugs (consider that the application that generates the report has been used on a daily basis by a couple of users for about 3 weeks and they have not found any problem).
Thanks a lot for your effort!
Regards,
Gio
[Updated on: Wed, 17 May 2017 12:14] Report message to a moderator
|
|
|
|
|
|
|
Re: Adding a text box in a scatterDraw/ScatterCtrl [message #48143 is a reply to message #48141] |
Fri, 26 May 2017 14:45   |
Giorgio
Messages: 218 Registered: August 2015
|
Experienced Member |
|
|
Hi Koldo,
thank you for you prompt support.
I have noticed something weird with this release.
This is the application compiled with the old version:
https://ibb.co/hjKz5v
This is the one with the the new version:
https://ibb.co/cuMJyF
A little background: to draw the big bars in the lower part of the screen I use this code
Vector<Pointf> b_temp = {};
b_temp << Pointf(t_in, posBarre) << Pointf(t_fine, posBarre);
barre.Add(b_temp);
...
for(int i = 0; i < barre.size(); i++){
...
scOee.AddSeries(barre[i]).NoMark().Stroke(30, t_color).Dash(LINE_SOLID).Legend(AsString(i));
}
To draw the light green line I use the following code:
Vector<Pointf> v_media_temp = {};
v_media_temp << Pointf(t_in, lista_ml_l[i].QuestaMLav.v_media ) << Pointf(t_fine, lista_ml_l[i].QuestaMLav.v_media);
vel_media.Add(v_media_temp);
...
for(int i = 0; i < vel_media.size(); i++)
{
...
scOee.AddSeries(vel_media[i]).NoMark().Stroke(1, LtGreen).Dash(LINE_SOLID).Legend("vm"+AsString(i));
}
The important thing here is that both the big bars and the light green line share the same x (t_in in my code). Thus, they are aligned. This is what happened with the old version, but with the new version they are no more aligned.
As far as regards, the report, I still get round edges:
https://ibb.co/gEXQdF
Regards,
Gio
|
|
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 20:38:48 CEST 2025
Total time taken to generate the page: 0.01057 seconds
|
|
|