void Curve::point(int i, double &x, double &y) const { VectorPtr xv = xVector(); if (xv) { x = xv->interpolate(i, NS); } VectorPtr yv = yVector(); if (yv) { y = yv->interpolate(i, NS); } }
KstBaseCurvePtr KstCurveHint::makeCurve(const QString& tag, const QColor& color) const { KstVectorPtr x = xVector(); KstVectorPtr y = yVector(); if (!x || !y) { kstdDebug() << "Couldn't find either " << _xVectorName << " or " << _yVectorName << endl; return 0L; } return new KstVCurve(tag, x, y, 0L, 0L, 0L, 0L, color); }
KstBaseCurvePtr KstCurveHint::makeCurve(const QString& tag, const QColor& color) const { KstVectorPtr x = xVector(); KstVectorPtr y = yVector(); if (!x || !y) { return KstBaseCurvePtr(); } return KstBaseCurvePtr(new KstVCurve(tag, x, y, KstVectorPtr(), KstVectorPtr(), KstVectorPtr(), KstVectorPtr(), color)); }
void Curve::getEYMinusPoint(int i, double &x, double &y, double &ey) { VectorPtr xv = xVector(); if (xv) { x = xv->interpolate(i, NS); } VectorPtr yv = yVector(); if (yv) { y = yv->interpolate(i, NS); } VectorPtr eyv = yMinusErrorVector(); if (eyv) { ey = eyv->interpolate(i, NS); } }
void Curve::getEXMinusPoint(int i, double &x, double &y, double &ex) { VectorPtr xv = xVector(); if (xv) { x = xv->interpolate(i, NS); } VectorPtr yv = yVector(); if (yv) { y = yv->interpolate(i, NS); } VectorPtr exmv = xMinusErrorVector(); if (exmv) { ex = exmv->interpolate(i, NS); } }
void CVecTests::ShouldNormalizeItself() { CVec xVector(100,0,0); xVector.normalize(); QVERIFY2(xVector.x() == 1.0, "X component should be normalize to 1.0"); CVec yVector(0,100,0); yVector.normalize(); QVERIFY2(yVector.y() == 1.0, "Y component should be normalize to 1.0"); CVec zVector(0,0,100); zVector.normalize(); QVERIFY2(zVector.z() == 1.0, "Z component should be normalize to 1.0"); }
void Curve::getEYPoints(int i, double &x, double &y, double &eyminus, double &eyplus) { VectorPtr xv = xVector(); if (xv) { x = xv->interpolate(i, NS); } VectorPtr yv = yVector(); if (yv) { y = yv->interpolate(i, NS); } VectorPtr eyv = yErrorVector(); if (eyv) { eyplus = eyv->interpolate(i, NS); } VectorPtr eymv = yMinusErrorVector(); if (eymv) { eyminus = eymv->interpolate(i, NS); } }
RelationPtr Curve::makeDuplicate(QMap<RelationPtr, RelationPtr> &duplicatedRelations) { CurvePtr curve = store()->createObject<Curve>(); if (descriptiveNameIsManual()) { curve->setDescriptiveName(descriptiveName()); } curve->setXVector(xVector()); curve->setYVector(yVector()); if (hasXError()) { curve->setXError(xErrorVector()); } if (hasYError()) { curve->setYError(yErrorVector()); } if (hasXMinusError()) { curve->setXMinusError(xMinusErrorVector()); } if (hasYMinusError()) { curve->setYMinusError(yMinusErrorVector()); } curve->setColor(Color); curve->setHasPoints(HasPoints); curve->setHasLines(HasLines); curve->setHasBars(HasBars); curve->setLineWidth(LineWidth); curve->setLineStyle(LineStyle); curve->setPointType(PointDensity); curve->setPointDensity(PointDensity); curve->setBarStyle(BarStyle); curve->writeLock(); curve->registerChange(); curve->unlock(); duplicatedRelations.insert(this, RelationPtr(curve)); return RelationPtr(curve); }
//---------------------------------------------------------------------------- void GlossMaps::CreateScene () { mScene = new0 Node(); mTrnNode = new0 Node(); mScene->AttachChild(mTrnNode); // Create vertex and index buffers to be shared by two meshes. VertexFormat* vformat = VertexFormat::Create(3, VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0, VertexFormat::AU_NORMAL, VertexFormat::AT_FLOAT3, 0, VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0); int vstride = vformat->GetStride(); VertexBuffer* vbuffer = new0 VertexBuffer(4, vstride); VertexBufferAccessor vba(vformat, vbuffer); Float3 yVector(0.0f, 1.0f, 0.0f); vba.Position<Float3>(0) = Float3(-0.5f, 0.0f, -0.5f); vba.Position<Float3>(1) = Float3(-0.5f, 0.0f, 0.5f); vba.Position<Float3>(2) = Float3( 0.5f, 0.0f, 0.5f); vba.Position<Float3>(3) = Float3( 0.5f, 0.0f, -0.5f); vba.Normal<Float3>(0) = yVector; vba.Normal<Float3>(1) = yVector; vba.Normal<Float3>(2) = yVector; vba.Normal<Float3>(3) = yVector; vba.TCoord<Float2>(0, 0) = Float2(1.0f, 0.0f); vba.TCoord<Float2>(0, 1) = Float2(1.0f, 1.0f); vba.TCoord<Float2>(0, 2) = Float2(0.0f, 1.0f); vba.TCoord<Float2>(0, 3) = Float2(0.0f, 0.0f); IndexBuffer* ibuffer = new0 IndexBuffer(6, sizeof(int)); int* indices = (int*)ibuffer->GetData(); indices[0] = 0; indices[1] = 1; indices[2] = 3; indices[3] = 3; indices[4] = 1; indices[5] = 2; // The light and material are used by both the gloss and non-gloss // objects. Light* light = new0 Light(Light::LT_DIRECTIONAL); light->Ambient = Float4(0.1f, 0.1f, 0.1f, 1.0f); light->Diffuse = Float4(0.6f, 0.6f, 0.6f, 1.0f); light->Specular = Float4(1.0f, 1.0f, 1.0f, 1.0f); light->DVector = AVector(0.0f, -1.0f, 0.0f); Material* material = new0 Material(); material->Ambient = Float4(0.2f, 0.2f, 0.2f, 1.0f); material->Diffuse = Float4(0.7f, 0.7f, 0.7f, 1.0f); material->Specular = Float4(1.0f, 1.0f, 1.0f, 25.0f); // Create a non-gloss-mapped square. TriMesh* squareNoGloss = new0 TriMesh(vformat, vbuffer, ibuffer); squareNoGloss->LocalTransform.SetRotate(HMatrix(AVector::UNIT_X, -0.25f*Mathf::PI)); squareNoGloss->LocalTransform.SetTranslate(APoint(1.0f, -1.0f, 0.0f)); squareNoGloss->SetEffectInstance( LightDirPerVerEffect::CreateUniqueInstance(light, material)); mTrnNode->AttachChild(squareNoGloss); // Create a gloss-mapped square. TriMesh* squareGloss = new0 TriMesh(vformat, vbuffer, ibuffer); squareGloss->LocalTransform.SetRotate(HMatrix(AVector::UNIT_X, -0.25f*Mathf::PI)); squareGloss->LocalTransform.SetTranslate(APoint(-1.0f, -1.0f, 0.0f)); mTrnNode->AttachChild(squareGloss); std::string effectFile = Environment::GetPathR("GlossMap.wmfx"); GlossMapEffect* effect = new0 GlossMapEffect(effectFile); std::string baseName = Environment::GetPathR("Magic.wmtf"); Texture2D* baseTexture = Texture2D::LoadWMTF(baseName); squareGloss->SetEffectInstance(effect->CreateInstance(baseTexture, light, material)); }
QString Curve::propertyString() const { return i18n("%1 vs %2").arg(yVector()->Name()).arg(xVector()->Name()); }