Hello,

I have implemented the dragging function of some QwtPlotMarkers by using the QwtPlotPicker ( see code below), but I'm not satisfied about the speed of replot, because when I move the items they don't move fluently but with jumps and I can also see the for loop in it, because first one item is moved then the second and so on. How can I move the selected items simultaneously? Help me please.

Thank you

best regards,

Vitali

Qt Code:
  1. // this function provides the ability to move items on the plot
  2. void Plot::cursorMoved( const QwtDoublePoint& Point){
  3.  
  4. if(_mf->getMode() == mainFrame::Recombination){ // allow to move the plot items only in Recombination phase
  5.  
  6. if(!selected_Points.empty()){ //if the list with selected items is not empty, then...
  7. for(int i=0; i< selected_Points.size(); ++i) {
  8. picker->setRubberBand(QwtPicker::NoRubberBand); // switch off the rubber band during drag process
  9. double delta_x = Point.x() - clickpos->x(); // calculate the x difference
  10. double delta_y = Point.y() - clickpos->y(); // calculate the y difference
  11.  
  12. unsigned idx=_mf->objFunction;
  13. double rangex1[2] = {optProbList[idx]->range_x1[0], optProbList[idx]->range_x1[1]};
  14. double rangex2[2] = {optProbList[idx]->range_x2[0], optProbList[idx]->range_x2[1]};
  15.  
  16. // set the new coordinates to the moved item, but check first whether the movement is within the valid area
  17. if((selected_Points[i]->xValue() + delta_x) < rangex1[1] && (selected_Points[i]->xValue() + delta_x) > rangex1[0]){
  18. selected_Points[i]->setXValue(selected_Points[i]->xValue() + delta_x);
  19. }
  20. if((selected_Points[i]->yValue() + delta_y) < rangex2[1] && (selected_Points[i]->yValue() + delta_y) > rangex2[0]){
  21. selected_Points[i]->setYValue(selected_Points[i]->yValue() + delta_y);
  22. }
  23. // check which index does this selected item have
  24. int index = (selected_Points[i]->title().text().toInt()); // transform from string to integer
  25. _mf->updateChromosome( selected_Points[i]->value(),index); // update the individuals with new values
  26. }
  27. this->replot(); // replot the plot widget after the selected point was moved
  28. }
  29. else{
  30. picker->setRubberBand(QwtPicker::RectRubberBand); // switch on the rectangle rubber band
  31. }
  32. clickpos = new QwtDoublePoint(Point); // update the reference point
  33. }
  34. else return;
  35. }
To copy to clipboard, switch view to plain text mode