Basically, the interface of C++/Tk with regard to Point is self-contained in the sense that no conversions should be necessary - some functions return Points, other accept them (if there is any inconsistency, let me know). This means that the only needs for such conversions can only arise in user code. The problem is that such conversions can be performed in many ways (for example - should it be "(x, y)" or "[x, y]", etc.) and C++/Tk is in no position to define what is the "right" way. Note that Tk::Point is a simple struct with members x and y, so that defining any additional logic should be rather straightforward.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Indeed, interesting example. :)
No, this is not supported at the moment.
The possible solution (for today) is to write custom iterator that will "translate" the sequence of points into the sequence of their coordinates. The resulting sequence will have twice as much elements and the usage might be something like:
Hi Maciej,
Could comment my proposal in Feature Requests submited as "[1471099] Tk::Point to std::string conversion" ?
Mateusz
Basically, the interface of C++/Tk with regard to Point is self-contained in the sense that no conversions should be necessary - some functions return Points, other accept them (if there is any inconsistency, let me know). This means that the only needs for such conversions can only arise in user code. The problem is that such conversions can be performed in many ways (for example - should it be "(x, y)" or "[x, y]", etc.) and C++/Tk is in no position to define what is the "right" way. Note that Tk::Point is a simple struct with members x and y, so that defining any additional logic should be rather straightforward.
I understand those arguments. They seem to be clear.
Nevertheless it's clear, I think it could be nice to be able to e.g. draw line in following way:
std::vector<Tk::Point> pts;
// fill points
".c" << Tk::create(Tk::line, pts.begin(), pts.end());
So, is this still possible without having stream operator?
Indeed, interesting example. :)
No, this is not supported at the moment.
The possible solution (for today) is to write custom iterator that will "translate" the sequence of points into the sequence of their coordinates. The resulting sequence will have twice as much elements and the usage might be something like:
".c" << create(line, Point2PairIterator(pts.begin()), Point2PairIterator());
Internally, the iterator with each dereference will get x and y components of subsequent Points.
Just an idea.