|
|
Home » Developing U++ » UppHub » GraphDraw/GraphCtrl
|
Re: GraphDraw/GraphCtrl [message #56886 is a reply to message #56871] |
Mon, 26 April 2021 12:50   |
 |
Pradip
Messages: 109 Registered: February 2019 Location: India
|
Experienced Member |
|
|
Hello Didier,
Another question, while trying to implement mouse click on data point:
void CustomData_Job::PaintDataPoint(BufferPainter& dw, int scale, const CoordinateConverter* xCoordConv, const CoordinateConverter* yCoordConv ) const
{
const TypeScreenCoord left = xCoordConv->toScreen(rectGraphBound.left);
const TypeScreenCoord right = xCoordConv->toScreen(rectGraphBound.right);
const TypeScreenCoord bottom = yCoordConv->toScreen(rectGraphBound.top);
const TypeScreenCoord top = yCoordConv->toScreen(rectGraphBound.bottom);
Rect r(left,top, right, bottom);
r.Normalize();
ChPaint(dw, r, rectStyle);
if (isSelected) {
DrawFrame(dw, r, Cyan());
}
}
bool SimpleJobSerie::LeftDown (unsigned int pIndex, PointGraph p, dword keyflags) {
data[pIndex].isSelected = !(data[pIndex].isSelected);
return true;
}
Here, the Cyan frame isn't drawn when mouse is clicked, it's only drawn at the time of next repaint. What to do?
Regards,
Pradip
[Updated on: Tue, 27 April 2021 08:20] Report message to a moderator
|
|
|
Re: GraphDraw/GraphCtrl [message #56891 is a reply to message #56886] |
Mon, 26 April 2021 22:48   |
Didier
Messages: 725 Registered: November 2008 Location: France
|
Contributor |
|
|
Hello Pradip,
Quote:One question:
How to pass the style info (StyleGS) from GraphSerie derived classes to CustomData derived classes?
The best way to do this is to initialize you're instances : look at the CustomData_Job::Init().
I would set a parameter to the GrapSerie owner instance and get acces to it's Style
This will have very poor performance, but I introduced CustomData / SimpleArrayGraphSerie classes to ease development of simple series with few data.
So it shouldn't be a problem.
Quote:Another question, while trying to implement mouse click on data point: it's only drawn at the time of next repaint. What to do?
These CustomData / SimpleArrayGraphSerie aren't finished so this doesn't work at this time.
But ... you don't need this to get selection working. I have something working which doesn't use SimpleGraphSerie but I don't have to code at hand right now.
I'll tell you tomorow how I did it
[Updated on: Mon, 26 April 2021 22:50] Report message to a moderator
|
|
|
|
|
|
Re: GraphDraw/GraphCtrl [message #56899 is a reply to message #56898] |
Tue, 27 April 2021 23:33   |
Didier
Messages: 725 Registered: November 2008 Location: France
|
Contributor |
|
|
Hello Pradip,
Here is my latest version:
- Separation from ScatterDraw is complete (although I am not satified about how I did it : I had to copy the drawing methods,and this is not good but it will do for the moment)
- Added ability to Refresh owner graph from a GraphSerie
This is what was missing in SimpleJobSerie and it's more open to other usages - replaced all dynamic_cast<> left in code with static_cast<>
- Finished memory cleaning of GraphSeries (their was a memory leak)
- Did some cleaning of management of auto color of series
- Added possibility to change legend text color : if NULL, text will have same color as serie, otherwise it will have the color set for legend test (black by default)
[Edit] : removed download file (new version available)
[Updated on: Sun, 16 May 2021 22:37] Report message to a moderator
|
|
|
|
Re: GraphDraw/GraphCtrl [message #56938 is a reply to message #56897] |
Sun, 02 May 2021 12:31   |
 |
Pradip
Messages: 109 Registered: February 2019 Location: India
|
Experienced Member |
|
|
Hello Didier,
Didier wrote on Tue, 27 April 2021 23:38Hello Pradip,
In fact you caught me in middle of refactroring/enhancement process, that's why things aren't stable/finished
I correct my previous reply
Quote:These CustomData / SimpleArrayGraphSerie aren't finished so this doesn't work at this time.
Yes they are not finished but the have to be used to evolve in the right direction
Of course, I'm totally with you on this process of development of GraphCtrl, and very happy to be a part of it!
Didier wrote on Tue, 27 April 2021 23:38
The CustomData_Job is only an example class which is intended to be a first use case (with selection ) and be a laboratory for features that will go in SimpleArrayGraphSerie or GraphSerie but this stopped when I switched to cleaning style management.
I first needed to clean style management before going further: I think style and associated properties editors management is OK now 
Yes understood about the example class. Will keep giving you inputs about it, giving few in next message. I will check the style management / properties management dialogs soon and will ask my doubts then
Regards,
Pradip
|
|
|
Re: GraphDraw/GraphCtrl [message #56939 is a reply to message #56899] |
Sun, 02 May 2021 12:43   |
 |
Pradip
Messages: 109 Registered: February 2019 Location: India
|
Experienced Member |
|
|
Hello Didier,
Didier wrote on Wed, 28 April 2021 03:03Hello Pradip,
Here is my latest version:
- Separation from ScatterDraw is complete (although I am not satified about how I did it : I had to copy the drawing methods,and this is not good but it will do for the moment)
- Added ability to Refresh owner graph from a GraphSerie
This is what was missing in SimpleJobSerie and it's more open to other usages - replaced all dynamic_cast<> left in code with static_cast<>
- Finished memory cleaning of GraphSeries (their was a memory leak)
- Did some cleaning of management of auto color of series
- Added possibility to change legend text color : if NULL, text will have same color as serie, otherwise it will have the color set for legend test (black by default)
Synced with your latest version, no trouble syncing at all!
Pointwise:
- Great, now it compiles without ScatterDraw
- Refreshing owner graph works quite well, I can use it now for that selection, but as you said it repaints the whole graph, so may not be optimal. Can the PaintOne method help in this scenario?
- Okay
- Right, had noticed some memory leak before, will let you know if I encounter that now
- Not using for Gantt, will check for other usage
- So thoughtful! Not using for Gantt, will check for other usage
New question:
Is there any way the painting order of X and Y grid can be specified? Now that order seems to change randomly.
Regards,
Pradip
|
|
|
Re: GraphDraw/GraphCtrl [message #56956 is a reply to message #56939] |
Mon, 03 May 2021 23:00   |
Didier
Messages: 725 Registered: November 2008 Location: France
|
Contributor |
|
|
Hello Pradip,
Quote:Is there any way the painting order of X and Y grid can be specified? Now that order seems to change randomly.
The order is absolutely not random: it is directly dependent on the order the GraphElements are inserted and where the drawng is supposed to be done:
The different painting layers are drawn in the following order :
* Draw Graph background and Plot background
* Call PaintOnPlot_underData()
* Paint Series DATA
* Call PaintOnPlot_overData()
* Call PaintElement()
* Call PaintFloatElement()
Look at GraphDrawBase.h L901 CRTP_EmptyGraphDraw::Paint() method
Quote:Right, had noticed some memory leak before, will let you know if I encounter that now
If you encounter such issues please tell me so that I can correct
Quote:Refreshing owner graph works quite well, I can use it now for that selection, but as you said it repaints the whole graph, so may not be optimal. Can the PaintOne method help in this scenario?
I'm not sure about it: if the API is to directive, this will close many possible usages.
Example:
- If I use the PaintOne() method, this will work perfectly in you're case
- If I take another use case : "try to select many data points of scatter data with a select rectangle", the PaintOne() method will be very slow and completely unadapted
Maybe these two use case are to far away to be approached in one unified way (I don't think so): but I really have to spend some time on it before giving up.
If you have some ideas, they are welcome
|
|
|
Re: GraphDraw/GraphCtrl [message #56965 is a reply to message #56956] |
Tue, 04 May 2021 13:15   |
 |
Pradip
Messages: 109 Registered: February 2019 Location: India
|
Experienced Member |
|
|
Hello Didier,
Quote:
Look at GraphDrawBase.h L901 CRTP_EmptyGraphDraw::Paint() method
Studied GraphDrawBase.h.

In these lines, since Sort() is used, and since X and Y grids are having same priority, at times the draw order is changed (only between X and Y grids, draw order of other elements are just fine). Uploading a PDF in next message to illustrate the effect. Have tried changing Sort() to StableSort(), which resolves this issue, please consider this.
Quote:
If you have some ideas, they are welcome
Let me think about this, if I get any idea I'll be glad to share with you.
Regards,
Pradip
|
|
|
|
|
Re: GraphDraw/GraphCtrl [message #57033 is a reply to message #53791] |
Sun, 16 May 2021 22:30   |
Didier
Messages: 725 Registered: November 2008 Location: France
|
Contributor |
|
|
Hello Pradip,
Here is a new version.
Most of the work is :
* code cleaning
* quality enhancement: memory leaks, uninitialized vars, readability
* and some code corrections
Next step is try to get Selection running 
Details are here:
* Code cleaning
* Replace Sort() with StableSort in GraphDraw
* Documentation:
* Corrected invalid references
* Somme documentation writing
* GSeriesCtrlDlg :
* Correct series common style parameters modification when editor CANCEL (modifications should not be applied)
* Correct series Serie style modification when editor CANCEL (modifications should not be applied)
* Erase previous SeriesEditor current GraphSerieserie when Serie doesn't create one
* Corr update after SeriesStyle modification
* renamed
class SeriesPropertiesDlgInfo ==> class GraphSerieEditorInterface
GraphSerie_child_classes::
MakeSerieEditorDlg() ==> MakeGraphSerieEditorInfo()
class GraphSeriesGroup::
AddCustomSeries() ==> AddCustomSeries()
SetModifyCustomSeries() ==> SetModifyGraphSeries()
CreateCustomSeries() ==> CreateGraphSerie()
ClearModifyCustomSeries() ==> ClearModifyGraphSeries()
IsModifyCustomSeries() ==> IsModifyGraphSeries()
ClearAllCustomSeries() ==> ClearAllOwnedGraphSeries()
OwnedGraphDataSources ==> GraphSeriesGroup::OwnedGraphSeries
customDataSourceProxyVector ==> graphSeriesProxyList
_isCustomSeriesModified ==> _isGraphSeriesModified
class GraphSerieDecorator::
SetDataSource() ==> SetGraphSerie()
[EDIT] removed dowload file (newer one available further)
[Updated on: Thu, 20 May 2021 22:32] Report message to a moderator
|
|
|
|
Re: GraphDraw/GraphCtrl [message #57067 is a reply to message #53791] |
Thu, 20 May 2021 10:52   |
 |
Pradip
Messages: 109 Registered: February 2019 Location: India
|
Experienced Member |
|
|
Hello Didier!
Synced with the new version seamlessly! Glad to see GraphCtrl evolving so well , I can't live without it anymore !
Following are my points:
- Noted the overall change in terminology: CustomSeries ==> GraphSeries
- For the selection, I tried something different (without using RefreshOwnerGraph()); made a separate GraphSeries, only to display the selection, and it worked so well! Though still it works through SetModifyGraphSeries(), which isn't optimal, but it does the job for me. Uploading the CustomGantt package in next message, you may have a look.
- About using the PaintOne() method, I was thinking about this use case :"try to select many data points of scatter data with a select rectangle"; to make this work, I think the client code in any case must go through each data point and run a check if the point is contained within the select rectangle, which might be speeded up with some hash value (I didn't work with hash values yet so can't say for sure). If a data point is contained, then the client code can still use PaintOne() method to show the selected points differently.
- About drawing order, yess I know you wrote that part many years back! Right, StableSort() is making it predictable, and also after you wrote I've figured out about stacking priority of grids, just incrementing one grid's stacking priority gives full control! Wow you thought about everything didn't you!
- Not seeing any more memory leaks
- Please see line 123 of CustomGantt.h (uploaded in next message). Can you give some idea how to use StyleGS to specify the colours used in GanttChart without using GanttColors* as I've done before?
- I was trying to display information about the Gantt bars when mouse hovered on them, with some ToolTip, but then noticed that MouseEnter() or MouseLeave() are not implemented in GraphSerie class. Tried to do that with MouseMove() but neither that was captured for GraphSerie. Any thought about it?
See how the app looks now, with selection!

Regards,
Pradip
|
|
|
|
Re: GraphDraw/GraphCtrl [message #57070 is a reply to message #57067] |
Thu, 20 May 2021 19:45   |
Didier
Messages: 725 Registered: November 2008 Location: France
|
Contributor |
|
|
Hello Pradip,
You're app is looking good
Quote:Noted the overall change in terminology: CustomSeries ==> GraphSeries
Naming is now stabilising, I'm feeling quite happy with them now
Quote:For the selection, I tried something different (without usi...
Well I made huge progress with selection, I have something almost ready for delivery : with point and area selection, selection with append and/or include/intersect
All is already ready for GraphSeries inheriting from SimpleGraphSerie (which I might rename SmallGraphSerie since it refletcs more what it really is)
Only two methods need to be written and evrything will work out of the box
I will deliver it very soon (maybe tonight)
Note: Since it is the first delivery, things are not very stable but it's looking quite good
Quote:Please see line 123 of CustomGantt.h
I just looked quickly: it should fit in easily, I will try to do the code
Quote:I was trying to display information about the Gantt bars when mouse hovered on them, with some ToolTip, but then noticed that MouseEnter() or MouseLeave() are not implemented in GraphSerie class
I have never needed MouseEnter or MouseLeave so they are not there ...
After second though, I'm not sure this is not a good idea. MouseLeav and MouseEnter() are called when mouse enters or leaves GraphCtrl.
I would have to reproduce this behaviour: I'm not sure this is a good idea for performance view.
Maybe you can get around this limitation by using CenterClick() or RightClick() to get help or CursorImage()
Another solution maybe would be to introduce some CursorTip() method that would be called after 1s of no mouse movement. This would not impact performance and do just what you need
GraphCtrl is looking more and more like it's own Ctrl management framework (although it's not the case and certainly not intented to be the case )
[Updated on: Thu, 20 May 2021 20:09] Report message to a moderator
|
|
|
Re: GraphDraw/GraphCtrl [message #57071 is a reply to message #57070] |
Thu, 20 May 2021 22:30   |
Didier
Messages: 725 Registered: November 2008 Location: France
|
Contributor |
|
|
Hello Pradip,
Here is the updated package.
Compile my example app and play with the Full Demo tab.
* SHIT : activates select (
* CTRL : activates APPEND to select (otherwise previous selection is lost each time you select)
* ALT : activates INTERSECT (when selecting in an area, all objects that interset with the area are selected. Otherwise only the fully include ones are selected)
Point selection is enabled ( with flip/flop selection : if object is already selected it is unselected )
* SHIFT, SHIFT+CTRL
Area selection is enabled
* SHIFT, SHIFT+CTRL, SHIFT+ALT, SHIFT+CTRL+ALT
Image cursor changes with use-case (tried to make somthing not two ugly)
To enable selection for you're SimpleGraphSeries, you have to add the following methods (for the moment the '=0' are not enabled in base classes because other series are not updated yet).
* In CustomData child class : virtual void PaintDataPoint(BufferPainter& dw, int scale, int style, const CoordinateConverter* xCoordConv, const CoordinateConverter* yCoordConv ) const override;
This will paint the data that is HIGHLIGHTED if style==DataPaintingStyle::HIGHLIGHT_STYLE
* In you're GraphSerie's constructor: set the serie Ctrlable() and Selectable()
Look at SimpleGraphSerie for an example 
[Edit] deleted download file : newer version available further
[Updated on: Tue, 01 June 2021 23:25] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Apr 25 20:40:23 CEST 2025
Total time taken to generate the page: 0.01620 seconds
|
|
|