Hello,
I'm drawing some curves onto the spectrogram and want to adapt/limit the bounds of curve to the bounds of spectrogram. As you can see in the attached image, the bound for x2 in spectrogram is 4, but the curve has bigger x2 values than 4, thus the image is not nice, because the plot should be only filled with spectrogramdata ( without grey areas) and on it there should be curves, which should respect the bounds of spectrogram. How to do the limitations?
best regards,
Vitali
I set the curve data with this class:
{
// The x values depend on its index and the y values
// can be calculated from the corresponding x value.
// So we don't need to store the values.
// Such an implementation is slower because every point
// has to be recalculated for every replot, but it demonstrates how
// QwtData can be used.
public:
SimpleData( double (*b)(double), double rang1[2], double step)
{
constraintFunc = b;
_step = step;
rangeX[0]= rang1[0]; rangeX[1] = rang1[1];
range = (rang1[1] - rang1[0])/step;
if(range<0){
range = range *(-1);
}
d_size = size_t(range);
}
{
return new SimpleData(*this);
}
virtual size_t size() const
{
return d_size;
}
virtual double x(size_t i) const
{
if(rangeX[0]<0){
return (-(range- i) + i)/ range;
}
else
return ((range + i) + i)/ range;
}
virtual double y(size_t i) const
{
return (*constraintFunc)(x(i));
}
private:
size_t d_size;
double range;
double _step;
double (*constraintFunc)(double); // function pointer for constraint function
double rangeX[2];
};
class SimpleData: public QwtData
{
// The x values depend on its index and the y values
// can be calculated from the corresponding x value.
// So we don't need to store the values.
// Such an implementation is slower because every point
// has to be recalculated for every replot, but it demonstrates how
// QwtData can be used.
public:
SimpleData( double (*b)(double), double rang1[2], double step)
{
constraintFunc = b;
_step = step;
rangeX[0]= rang1[0]; rangeX[1] = rang1[1];
range = (rang1[1] - rang1[0])/step;
if(range<0){
range = range *(-1);
}
d_size = size_t(range);
}
virtual QwtData *copy() const
{
return new SimpleData(*this);
}
virtual size_t size() const
{
return d_size;
}
virtual double x(size_t i) const
{
if(rangeX[0]<0){
return (-(range- i) + i)/ range;
}
else
return ((range + i) + i)/ range;
}
virtual double y(size_t i) const
{
return (*constraintFunc)(x(i));
}
private:
size_t d_size;
double range;
double _step;
double (*constraintFunc)(double); // function pointer for constraint function
double rangeX[2];
};
To copy to clipboard, switch view to plain text mode
Bookmarks