예제 #1
0
KJS::Object KstBindLegend::construct(KJS::ExecState *exec, const KJS::List& args) {
  if (args.size() == 0 || args.size() > 2) {
    return createSyntaxError(exec);
  }

  KstViewObjectPtr view = extractViewObject(exec, args[0]);
  if (!view) {
    KstViewWindow *w = extractWindow(exec, args[0]);
    if (w) {
      view = w->view();
    } else {
      return createTypeError(exec, 0);
    }
  }

  QString txt;
  if (args.size() == 2) {
    if (args[1].type() != KJS::StringType) {
      return createTypeError(exec, 1);
    }
    txt = args[1].toString(exec).qstring();
  }

  KstViewLegendPtr b = new KstViewLegend;
  view->appendChild(b.data());
  KstApp::inst()->paintAll(KstPainter::P_PAINT);
  return KJS::Object(new KstBindLegend(exec, b));
}
예제 #2
0
KJS::Object KstBindLine::construct(KJS::ExecState *exec, const KJS::List& args) {
  if (args.size() != 1) {
    return createSyntaxError(exec);
  }

  KstViewObjectPtr view = extractViewObject(exec, args[0]);
  if (!view) {
    KstViewWindow *w = extractWindow(exec, args[0]);
    if (w) {
      view = w->view();
    } else {
      return createTypeError(exec, 0);
    }
  }

  KstViewLinePtr b = new KstViewLine;
  view->appendChild(b.data());
  KstApp::inst()->paintAll(KstPainter::P_PAINT);
  return KJS::Object(new KstBindLine(exec, b));
}
예제 #3
0
KJS::Object KstBindPlot::construct(KJS::ExecState *exec, const KJS::List& args) {
  KstViewWindow *w = 0L;
  if (args.size() == 1) {
    w = extractWindow(exec, args[0]);
    if (!w) {
      return createTypeError(exec, 0);
    }
  } else {
    return createSyntaxError(exec);
  }

  QString n = w->createPlotObject(KST::suggestPlotName(), false);
  Kst2DPlotPtr p = *w->view()->findChildrenType<Kst2DPlot>(true).findTag(n);
  if (!p) {
    return createGeneralError(exec, i18n("Failed to create plot."));
  }

  w->view()->paint(KstPainter::P_PAINT);

  return KJS::Object(new KstBindPlot(exec, p));
}
KJS::Object KstBindEllipse::construct(KJS::ExecState *exec, const KJS::List& args) {
  if (args.size() != 1) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError);
    exec->setException(eobj);
    return KJS::Object();
  }

  KstViewObjectPtr view = extractViewObject(exec, args[0]);
  if (!view) {
    KstViewWindow *w = extractWindow(exec, args[0]);
    if (w) {
      view = w->view();
    } else {
      KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
      exec->setException(eobj);
      return KJS::Object();
    }
  }

  KstViewEllipsePtr b = new KstViewEllipse;
  view->appendChild(b.data());
  KstApp::inst()->paintAll(KstPainter::P_PAINT);
  return KJS::Object(new KstBindEllipse(exec, b));
}