PDA

View Full Version : problem with dot style



21did21
26th June 2011, 22:20
hello world,

recently i make a graphic with line style and after this i have changed the style with this command :


mycurve->attach( myPlot1 );
mycurve->setStyle( QwtPlotCurve::Dots );
mycurve->setPen( QPen( Qt::blue, 0.1 ) );

and to plot:


QVector<double> x3(0);
QVector<double> y3(0);
x3.reserve(timeNb3);
y3.reserve(timeNb3);
x3 << Points3_OneXtwoY[i][z][0] ;
y3 << Points3_OneXtwoY[i][z][1] ;
}
mycurve->setSamples(x3.data(),y3.data(),x3.size());
myPlot3->replot();
repaint();


all worked nice, but now i re-test this code but it don't plot with dots

i have forget something but i don't understand what

can you help me please ?

FelixB
27th June 2011, 09:35
what does the curve look like? are you sure you call replot *after* setting the style? what happens when you don't set the pen?

21did21
28th June 2011, 14:59
hello Felix

1°) my curve it's here:
http://imageshack.us/photo/my-images/339/curvei.jpg/

2°) i have tested without modify Qpen and it don't change anything

3°) i define style in the constructor and i use replot only in a method of my class "window". I just have tested replot in the constructor and it don't change anything

==> this is my real definition of curves in constructor:


myPlot1 = new QwtPlot();
myPlot2 = new QwtPlot();
for ( int k = 0 ; k < NombrePrecipitesSimules ; ++k )
{
mycurve[0+k*nombreDoublePlot]->attach( myPlot1 );
mycurve[0+k*nombreDoublePlot]->setStyle( QwtPlotCurve::Dots );
//mycurve[0+k*nombreDoublePlot]->setPen( QPen( Qt::blue, 0.1 ) );
mycurve[1+k*nombreDoublePlot]->attach( myPlot2 );
mycurve[1+k*nombreDoublePlot]->setStyle( QwtPlotCurve::Dots );
//mycurve[1+k*nombreDoublePlot]->setPen( QPen( Qt::blue, 0.1 ) );
}

this is private attribut of my class:

QwtPlot *myPlot1;
QwtPlot *myPlot2;
QVector< QwtPlotCurve* > mycurve;


and this is my utilisation:


for (int i=0;i<nb;i++)
{
int timeNb3=0;
timeNb3=Points3_OneXtwoY[i].size();
QVector<double> x3(0);
QVector<double> y3(0);
x3.reserve(timeNb3);
y3.reserve(timeNb3);
//i fill Qvectors
for (int z=0;z<timeNb3;z++)
{
x3 << Points3_OneXtwoY[i][z][0] ;
y3 << Points3_OneXtwoY[i][z][1] ;
}
mycurve[2+i*nombreDoublePlot]->setSamples(x3.data(),y3.data(),x3.size());
myPlot3->replot();
repaint();


with: Points3_OneXtwoY a " vector<vector<vector<double>>> "

FelixB
29th June 2011, 07:58
I can't see anything wrong. where do you call "new QwtPlotCurve()?"

21did21
29th June 2011, 14:07
hello Fellix, thank for your help,

in the constructor i have this:


for ( int k = 0 ; k < nbDoubleCurve ; ++k )
{
QwtPlotCurve * curve= new QwtPlotCurve();
mycurve.push_back(curve);
}

FelixB
1st July 2011, 08:01
why don't you set the style in the constructor? does it change anything if you do so? I still can't see any errors in your code :(

21did21
1st July 2011, 11:20
thank Felix for your help i will try to test a lot of different thing, if it's work i will explain toyou what was the problem

EDIT:

i have done some modification and now it's works but i don't understand why... :p

21did21
2nd July 2011, 15:35
Now i have a problem to change the symbol of this curve... :(

for the moment i have several dots, it's nice but i want to change dots by triangle :confused:

I have done this in my constructor:


MySymbol =new QwtSymbol();
MySymbol->Triangle;
mycurve->setStyle( QwtPlotCurve::Dots );
mycurve->setSymbol( MySymbol );


My curve always have dots and Triangles are not taken into account i have always Dots.

=> if i erase this line:

mycurve->setStyle( QwtPlotCurve::Dots );

my curve don't appears,

So i think i haven't understand the difference between style and symbol, i don't want line but i want to change Dots by triangle

i hope you can help me ;)

thank a lot

21did21
4th July 2011, 17:57
it's work now but i superpoze dots and triangles... :o