本文整理汇总了C++中PointSet::setLineColor方法的典型用法代码示例。如果您正苦于以下问题:C++ PointSet::setLineColor方法的具体用法?C++ PointSet::setLineColor怎么用?C++ PointSet::setLineColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointSet
的用法示例。
在下文中一共展示了PointSet::setLineColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculateDifferences
void RangeProfilePlotManager::calculateDifferences()
{
// ensure we have only two objects selected
VERIFYNRV(mpView);
std::list<PlotObject*> selected;
mpView->getSelectedObjects(selected, true);
std::list<PlotObject*>::iterator selIt = selected.begin();
PointSet* pFirst = (selIt == selected.end()) ? NULL : dynamic_cast<PointSet*>(*(selIt++));
PointSet* pSecond = (selIt == selected.end()) ? NULL : dynamic_cast<PointSet*>(*(selIt++));
if (pFirst == NULL || pSecond == NULL)
{
return;
}
// locate the Difference point set
std::list<PlotObject*> allObjects;
mpView->getObjects(POINT_SET, allObjects);
PointSet* pDiffSet = NULL;
for (std::list<PlotObject*>::iterator obj = allObjects.begin(); obj != allObjects.end(); ++obj)
{
PointSet* pSet = static_cast<PointSet*>(*obj);
std::string name;
pSet->getObjectName(name);
if (name == "Difference")
{
pDiffSet = pSet;
pDiffSet->clear(true);
break;
}
}
if (pDiffSet == NULL)
{
pDiffSet = static_cast<PointSet*>(mpView->addObject(POINT_SET, true));
pDiffSet->setObjectName("Difference");
}
// calculate the differences and errors
std::vector<Point*> aPoints = pFirst->getPoints();
std::vector<Point*> bPoints = pSecond->getPoints();
if (aPoints.size() < 2 || bPoints.size() < 2)
{
return;
}
double mae = 0.0;
double mse1 = 0.0;
double mse2 = 0.0;
for (size_t aIdx = 0; aIdx < aPoints.size(); ++aIdx)
{
Point* pA = aPoints[aIdx];
VERIFYNRV(pA);
LocationType aVal = pA->getLocation();
LocationType newVal;
// locate the associated spot in b
for (size_t bIdx = 0; bIdx < bPoints.size(); ++bIdx)
{
Point* pB = bPoints[bIdx];
VERIFYNRV(pB);
LocationType bVal = pB->getLocation();
double diff = aVal.mX - bVal.mX;
if (fabs(diff) < 0.0000001) // a == b use the exact value
{
newVal.mX = aVal.mX;
newVal.mY = bVal.mY - aVal.mY;
break;
}
else if (diff < 0.0) // a < b found the upper point, interpolate
{
newVal.mX = aVal.mX;
LocationType secondBVal;
if (bIdx == 0) // we are at the start so continue the segment from the right
{
Point* pSecondB = bPoints[1];
VERIFYNRV(pSecondB);
secondBVal = pSecondB->getLocation();
}
else // grab the previous point for interpolation
{
Point* pSecondB = bPoints[bIdx-1];
VERIFYNRV(pSecondB);
secondBVal = pSecondB->getLocation();
}
// calculate slope-intercept
double m = (bVal.mY - secondBVal.mY) / (bVal.mX - secondBVal.mX);
double b = bVal.mY - m * bVal.mX;
// find the y corresponding to the interpolated x
newVal.mY = m * newVal.mX + b;
newVal.mY -= aVal.mY;
break;
}
}
mae += fabs(newVal.mY);
mse1 += newVal.mY * newVal.mY;
mse2 += (newVal.mY * newVal.mY) / (aVal.mY * aVal.mY);
pDiffSet->addPoint(newVal.mX, newVal.mY);
}
pDiffSet->setLineColor(ColorType(200, 0, 0));
//.........这里部分代码省略.........
示例2: plotProfile
bool RangeProfilePlotManager::plotProfile(Signature* pSignature)
{
VERIFY(mpView && pSignature);
std::string plotName = pSignature->getDisplayName();
if (plotName.empty())
{
plotName = pSignature->getName();
}
if (plotName == "Difference")
{
QMessageBox::warning(Service<DesktopServices>()->getMainWidget(),
"Invalid signature", "Signatures can not be named 'Difference' as this is a reserved "
"name for this plot. Please rename your signature and try again.");
return false;
}
const Units* pXUnits = NULL;
const Units* pYUnits = NULL;
std::vector<double> xData;
std::vector<double> yData;
std::set<std::string> dataNames = pSignature->getDataNames();
for (std::set<std::string>::const_iterator dataName = dataNames.begin();
dataName != dataNames.end() && (pXUnits == NULL || pYUnits == NULL);
++dataName)
{
const Units* pUnits = pSignature->getUnits(*dataName);
if (pUnits == NULL)
{
continue;
}
if (pUnits->getUnitType() == DISTANCE)
{
if (pXUnits == NULL)
{
pXUnits = pUnits;
xData = dv_cast<std::vector<double> >(pSignature->getData(*dataName), std::vector<double>());
}
}
else if (pYUnits == NULL)
{
pYUnits = pUnits;
yData = dv_cast<std::vector<double> >(pSignature->getData(*dataName), std::vector<double>());
}
}
if (xData.empty() || xData.size() != yData.size())
{
QMessageBox::warning(Service<DesktopServices>()->getMainWidget(),
"Invalid signature", QString("Signatures must have a distance axis. '%1' does not and will not be plotted.")
.arg(QString::fromStdString(pSignature->getName())));
return false;
}
std::map<Signature*, std::string>::iterator oldPointSet = mSigPointSets.find(pSignature);
PointSet* pSet = getPointSet(pSignature);
if (pSet != NULL)
{
pSet->clear(true);
}
std::list<PlotObject*> curObjects;
mpView->getObjects(POINT_SET, curObjects);
if (pSet == NULL)
{
std::vector<ColorType> excluded;
excluded.push_back(ColorType(255, 255, 255)); // background
excluded.push_back(ColorType(200, 0, 0)); // color for the difference plot
for (std::list<PlotObject*>::const_iterator cur = curObjects.begin(); cur != curObjects.end(); ++cur)
{
excluded.push_back(static_cast<PointSet*>(*cur)->getLineColor());
}
pSet = static_cast<PointSet*>(mpView->addObject(POINT_SET, true));
mSigPointSets[pSignature] = plotName;
pSignature->attach(SIGNAL_NAME(Subject, Deleted), Slot(this, &RangeProfilePlotManager::signatureDeleted));
pSignature->getDataDescriptor()->attach(SIGNAL_NAME(DataDescriptor, Renamed),
Slot(this, &RangeProfilePlotManager::signatureRenamed));
std::vector<ColorType> colors;
ColorType::getUniqueColors(1, colors, excluded);
if (!colors.empty())
{
pSet->setLineColor(colors.front());
}
}
pSet->setObjectName(plotName);
for (size_t idx = 0; idx < xData.size(); ++idx)
{
pSet->addPoint(xData[idx], yData[idx]);
}
VERIFY(mpPlot);
Axis* pBottom = mpPlot->getAxis(AXIS_BOTTOM);
Axis* pLeft = mpPlot->getAxis(AXIS_LEFT);
VERIFYRV(pBottom && pLeft, NULL);
if (pBottom->getTitle().empty())
{
pBottom->setTitle(pXUnits->getUnitName());
}
if (pLeft->getTitle().empty())
{
pLeft->setTitle(pYUnits->getUnitName());
}
else if (pLeft->getTitle() != pYUnits->getUnitName())
{
Axis* pRight = mpPlot->getAxis(AXIS_RIGHT);
//.........这里部分代码省略.........