http://redmine.emweb.be/http://redmine.emweb.be/favicon.ico?16934085252013-01-03T10:15:02ZRedmineWt - Feature #1608: chart improvementshttp://redmine.emweb.be/issues/1608?journal_id=45402013-01-03T10:15:02ZJan Hrubeš
<ul></ul><p>Another great feature would be order swapping of individual curves in graph to change z-axis order. In Matlab you can simple swap curve handlers in children vector to do this. In wt WObject::children() method returns const vector, so it can't be used directly and children_ is private of WObject. Using WObject::addChild() and WObject::removeChild() seems to be overhead for this. Can simple WObject::swapChildren(WObject *A, WObject *B) do any hurt? It can be useful when reordering widgets too.</p>
<pre><code>// maybe return bool if swapping was successful
void WObject::swapChildren(WObject *A, WObject *B)
{
if ( A->parent_ != this || B->parent_ != this )
throw WException("WObject::swapChildren() called with non-child");
std::vector<WObject*>::iterator iBegin, iEnd, iA, iB;
iBegin = children_->begin();
iEnd = children_->end();
// should optimize for one iteration over vector
iA = std::find(iBegin, iEnd, A);
iB = std::find(iBegin, iEnd, B);
if ( (iA != iEnd) && (iB != iEnd) )
{
std::iter_swap(iA,iB);
}
}
</code></pre>