Hello,
now I changed my code so that the Markers are not deleted every time, when their coords are changed, and recreated again, but just change the plot positions and then replot. Unfortunately it did not speed up the plot process. It still needs 4 seconds to replot 20 QwtPlotMarkers and a spectrogramm (which has no changes). I guess I do something wrong, because I cannot imagine that plotting 20 markers can last so long time!
Do you have other ideas or hints, how to make it faster?
Thank you
best regards,
Vitali
// this functions is responsible for creating circles( points) and setting their position on the plot
void mainFrame::drawIndividuals(PopulationT<double> *population){
// first delete redundant markers if the size of marker's list is bigger than the population size
while(list_of_markers.size() > population->size()){
list_of_markers[list_of_markers.size()-1]->detach();
list_of_markers.pop_back();
count_of_drawn--;
}
for (int i = 0; i < population->size(); ++i){
double xCoord = (*population)[ i ][ 0 ][0]; // read out the values of individuals in population
double yCoord = (*population)[ i ][ 1 ][0];
if(i > (count_of_drawn - 1)){ // if the size of plotted markers is less than the size of population, then create and plot further markers
// create PlotMarkers to visualize the individuals
symb
->setBrush
(QBrush(Qt
::red, Qt
::SolidPattern));
// red, solid color symb
->setStyle
(QwtSymbol::Ellipse);
// it will be a circle symb->setSize(5,5);
mark->setSymbol(*symb);
mark->setXValue(xCoord); // set the position of marker on the plot
mark->setYValue(yCoord);
char idx[5];
sprintf(idx,"%d", i);
mark->setTitle(idx); // set title to the marker, which afterwards helps to indicate the certain individual
//mark->setLabel(QwtText(idx));
mark->attach(d_plot);
// insert the new created marker into the marker list
list_of_markers.push_back(mark);
count_of_drawn++;
}
else{
list_of_markers[i]->setXValue(xCoord);
list_of_markers[i]->setYValue(yCoord);
}
}
d_plot->selected_Points.clear();
d_plot->selected_to_recombine.clear();
d_plot->replot();
}
// this functions is responsible for creating circles( points) and setting their position on the plot
void mainFrame::drawIndividuals(PopulationT<double> *population){
// first delete redundant markers if the size of marker's list is bigger than the population size
while(list_of_markers.size() > population->size()){
list_of_markers[list_of_markers.size()-1]->detach();
list_of_markers.pop_back();
count_of_drawn--;
}
for (int i = 0; i < population->size(); ++i){
double xCoord = (*population)[ i ][ 0 ][0]; // read out the values of individuals in population
double yCoord = (*population)[ i ][ 1 ][0];
if(i > (count_of_drawn - 1)){ // if the size of plotted markers is less than the size of population, then create and plot further markers
// create PlotMarkers to visualize the individuals
QwtPlotMarker *mark = new QwtPlotMarker();
QwtSymbol *symb = new QwtSymbol();
symb->setBrush(QBrush(Qt::red, Qt::SolidPattern)); // red, solid color
symb->setStyle(QwtSymbol::Ellipse); // it will be a circle
symb->setSize(5,5);
mark->setSymbol(*symb);
mark->setXValue(xCoord); // set the position of marker on the plot
mark->setYValue(yCoord);
char idx[5];
sprintf(idx,"%d", i);
mark->setTitle(idx); // set title to the marker, which afterwards helps to indicate the certain individual
//mark->setLabel(QwtText(idx));
mark->attach(d_plot);
// insert the new created marker into the marker list
list_of_markers.push_back(mark);
count_of_drawn++;
}
else{
list_of_markers[i]->setXValue(xCoord);
list_of_markers[i]->setYValue(yCoord);
}
}
d_plot->selected_Points.clear();
d_plot->selected_to_recombine.clear();
d_plot->replot();
}
To copy to clipboard, switch view to plain text mode
Bookmarks