Ejemplo n.º 1
0
	void GSurface::regeneratePath(int ns, int nt){
		  updateCoords();
		  calculateCoefficients();
		  double delta_s = 1.0 / (ns - 1);
		  double delta_t = 1.0 / (nt - 1);
		  createDeltaMatrices(delta_s, delta_t);
		  createForwardDiffMatrices();
		  _curves.clear();
		  for (int i = 0; i < ns; i++) {
			  makeCurve(nt,
		                     _DDx[0][0], _DDx[0][1], _DDx[0][2], _DDx[0][3],
		                     _DDy[0][0], _DDy[0][1], _DDy[0][2], _DDy[0][3],
		                     _DDz[0][0], _DDz[0][1], _DDz[0][2], _DDz[0][3] );
		    UpdateForwardDiffMatrices();
		  }

		  createForwardDiffMatrices();
		  _DDx = Transformation(_DDx).transpose().m();
		  _DDy = Transformation(_DDy).transpose().m();
		  _DDz = Transformation(_DDz).transpose().m();
		  for (int i = 0; i < nt; i++) {
			  makeCurve(ns,
			  		                     _DDx[0][0], _DDx[0][1], _DDx[0][2], _DDx[0][3],
			  		                     _DDy[0][0], _DDy[0][1], _DDy[0][2], _DDy[0][3],
			  		                     _DDz[0][0], _DDz[0][1], _DDz[0][2], _DDz[0][3] );
		    UpdateForwardDiffMatrices();
		  }
	}
Ejemplo n.º 2
0
KJS::Value KstBindCurve::yMinusErrorPoint(KJS::ExecState *exec, const KJS::List& args) {
  KstVCurvePtr d = makeCurve(_d);
  if (!d) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
    exec->setException(eobj);
    return KJS::Undefined();
  }

  if (args.size() != 1) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires exactly one argument.");
    exec->setException(eobj);
    return KJS::Undefined();
  }

  unsigned i = 0;
  if (args[0].type() != KJS::NumberType || !args[0].toUInt32(i)) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return KJS::Undefined();
  }

  KstReadLocker rl(d);
  double x, y, e;
  d->getEYMinusPoint(i, x, y, e);
  return KJS::Number(e);
}
Ejemplo n.º 3
0
void KstDataManagerI::contextMenu(QListViewItem *i, const QPoint& p, int col) {
  Q_UNUSED(col)
  KstObjectItem *koi = static_cast<KstObjectItem*>(i);
  KstBaseCurve *c;

  if (koi->rtti() == RTTI_OBJ_OBJECT || koi->rtti() == RTTI_OBJ_DATA_VECTOR) {
    KPopupMenu *m = new KPopupMenu(this);

    m->setTitle(koi->text(0));

    int id = m->insertItem(i18n("&Edit..."), this, SLOT(edit_I()));
    //m->setItemEnabled(id, RTTI_OBJ_VECTOR != koi->rtti());

    if (koi->rtti() == RTTI_OBJ_DATA_VECTOR) {
      id = m->insertItem(i18n("&Make Curve..."), koi, SLOT(makeCurve()));
    } else if ((c = dynamic_cast<KstBaseCurve*>(koi->dataObject().data()))) {
      KPopupMenu *addMenu = new KPopupMenu(this);
      KPopupMenu *removeMenu = new KPopupMenu(this);
      PlotMap.clear();
      id = 100;
      bool haveAdd = false, haveRemove = false;
      for (KstPlot *p = KST::plotList.first(); p; p = KST::plotList.next()) {
        if (!p->Curves.contains(c)) {
          addMenu->insertItem(p->tagName(), koi, SLOT(addToPlot(int)), 0, id);
          haveAdd = true;
        } else {
Ejemplo n.º 4
0
void makeFan(GeometryBatch &b, float radius, float height, int divisions,
    bool normals, bool uvs, const LColor *color)
{
  b.init(GL_TRIANGLE_FAN, "fan");
  vector<LPoint> curve;
  makeCurve(curve, radius, divisions);
  b.ps.clear();
  b.ps.push_back(LPoint(0, height, 0));
  for (int j = 0; j < curve.size(); ++j)
  {
    b.ps.push_back(curve[j] + LPoint(0,-height,0));
  }

  if (uvs)
  {
    b.uvs[0].push_back(UV(0.5f, 1.0f));
    for (int j = 0; j < curve.size(); ++j)
    {
      const float jNorm = (float)j / (float)divisions;
      b.uvs[0].push_back(UV(jNorm,0.0f));
    }

    if (color)
    {
      b.cs.assign(b.ps.size(), *color);
    }
  }
}
Ejemplo n.º 5
0
KJS::Value KstBindCurve::yLabel(KJS::ExecState *exec) const {
  Q_UNUSED(exec)
  KstVCurvePtr d = makeCurve(_d);
  if (d) {
    KstReadLocker rl(d);
    return KJS::String(d->yLabel());
  }
  return KJS::String();
}
Ejemplo n.º 6
0
KJS::Value KstBindCurve::barStyle(KJS::ExecState *exec) const {
  Q_UNUSED(exec)
  KstVCurvePtr d = makeCurve(_d);
  if (d) {
    KstReadLocker rl(d);
    return KJS::Number(d->barStyle());
  }
  return KJS::Number(0);
}
Ejemplo n.º 7
0
KJS::Value KstBindCurve::hasBars(KJS::ExecState *exec) const {
  Q_UNUSED(exec)
  KstVCurvePtr d = makeCurve(_d);
  if (d) {
    KstReadLocker rl(d);
    return KJS::Boolean(d->hasBars());
  }
  return KJS::Boolean(false);
}
Ejemplo n.º 8
0
KJS::Value KstBindCurve::color(KJS::ExecState *exec) const {
  KstVCurvePtr d = makeCurve(_d);
  if (d) {
    KstReadLocker rl(d);
    return KJSEmbed::convertToValue(exec, d->color());
  }

  return KJSEmbed::convertToValue(exec, QColor());
}
Ejemplo n.º 9
0
void KstBindCurve::setYMinusErrorVector(KJS::ExecState *exec, const KJS::Value& value) {
  KstVCurvePtr d = makeCurve(_d);
  if (d) {
    KstVectorPtr vp = extractVector(exec, value);
    if (vp) {
      KstWriteLocker wl(d);
      d->setYMinusError(vp);
    }
  }
}
Ejemplo n.º 10
0
KJS::Value KstBindCurve::yMinusErrorVector(KJS::ExecState *exec) const {
  KstVCurvePtr d = makeCurve(_d);
  if (d) {
    KstReadLocker rl(d);
    KstVectorPtr vp = d->yMinusErrorVector();
    if (vp) {
      return KJS::Object(new KstBindVector(exec, vp));
    }
  }
  return KJS::Null();
}
Ejemplo n.º 11
0
void KstBindCurve::setHasBars(KJS::ExecState *exec, const KJS::Value& value) {
  if (value.type() != KJS::BooleanType) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstVCurvePtr d = makeCurve(_d);
  if (d) {
    KstWriteLocker wl(d);
    d->setHasBars(value.toBoolean(exec));
  }
}
Ejemplo n.º 12
0
void KstBindCurve::setBarStyle(KJS::ExecState *exec, const KJS::Value& value) {
  unsigned i = 0;
  if (value.type() != KJS::NumberType || !value.toUInt32(i)) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstVCurvePtr d = makeCurve(_d);
  if (d) {
    KstWriteLocker wl(d);
    d->setBarStyle(i);
  }
}
Ejemplo n.º 13
0
void KstBindCurve::setColor(KJS::ExecState *exec, const KJS::Value& value) {
  QVariant cv = KJSEmbed::convertToVariant(exec, value);
  if (!cv.canCast(QVariant::Color)) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstVCurvePtr d = makeCurve(_d);
  if (d) {
    KstWriteLocker rl(d);
    d->setColor(cv.toColor());
  }
}
Ejemplo n.º 14
0
void makeRing(GeometryBatch &b, float radius, float height, int divisions, 
    bool normals, bool uvs, const LColor *color)
{
  b.init(GL_TRIANGLE_STRIP, "ring");
  std::vector<LPoint> curve;
  makeCurve(curve, radius, divisions);
  b.ps.clear();
  for (int j = 0; j < curve.size(); ++j)
  {
    b.ps.push_back(curve[j] + LPoint(0,height,0));
    b.ps.push_back(curve[j] + LPoint(0,-height,0));
  }
  if (uvs)
  {
    for (int j = 0; j < curve.size(); ++j)
    {
      const float jNorm = (float)j / (float)divisions;
      b.uvs[0].push_back(UV(jNorm, 1.0f));
      b.uvs[0].push_back(UV(jNorm, 0.0f));
    }
  }

  if (normals)
  {
    for (int j = 0; j < curve.size(); ++j)
    {
      b.ns.push_back(normalize(LNormal(curve[j] - LPoint(0,0,0))));
      b.ns.push_back(normalize(LNormal(curve[j] - LPoint(0,0,0))));
    }

  }

  if (color)
  {
    b.cs.assign(b.ps.size(), *color);
  }
}