Cpn new curves (-100,-100) to (100,100)
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "curvedata.h"
|
#include "curvedata.h"
|
||||||
#include "radiodata.h"
|
#include "datahelpers.h"
|
||||||
|
|
||||||
CurveData::CurveData()
|
CurveData::CurveData()
|
||||||
{
|
{
|
||||||
@@ -30,19 +30,27 @@ void CurveData::clear(int count)
|
|||||||
{
|
{
|
||||||
memset(reinterpret_cast<void *>(this), 0, sizeof(CurveData));
|
memset(reinterpret_cast<void *>(this), 0, sizeof(CurveData));
|
||||||
this->count = count;
|
this->count = count;
|
||||||
|
|
||||||
|
int incr = 200 / (count - 1);
|
||||||
|
|
||||||
|
// points[0].x must be -100
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
if (i < count - 1)
|
||||||
|
points[i].x = -100 + incr * i;
|
||||||
|
else
|
||||||
|
points[i].x = 100; // points[last].x must be +100 do not risk a rounding issue using incr
|
||||||
|
|
||||||
|
points[i].y = points[i].x;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CurveData::isEmpty() const
|
bool CurveData::isEmpty() const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < count; i++) {
|
CurveData tmp;
|
||||||
if (points[i].y != 0) {
|
return !memcmp(this, &tmp, sizeof(CurveData));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CurveData::nameToString(const int idx) const
|
QString CurveData::nameToString(const int idx) const
|
||||||
{
|
{
|
||||||
return RadioData::getElementName(tr("CV"), idx + 1, name);
|
return DataHelpers::getElementName(tr("CV"), idx + 1, name);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user