Example #1
0
KstViewLegend::KstViewLegend(const QDomElement& e)
: KstBorderedViewObject(e) {

  // some defaults and invariants
  _fallThroughTransparency = false;
  _container = false;
  _type = "Legend";
  _rotation = 0.0;
  _fontName = KstApp::inst()->defaultFont();
  _vertical = true;
  _isResizable = false;
  _fontSize = -1;
  setFontSize(0);
  _layoutActions &= ~(MoveTo | Copy | CopyTo);
  _standardActions |= Delete | Edit;
  _legendMargin = 5;
  _parsedTitle = 0L;
  _trackContents = true;

  QStringList ctaglist;

  // read the properties
  QDomNode n = e.firstChild();
  while (!n.isNull()) {
    QDomElement el = n.toElement();
    if (!el.isNull()) {
      if (metaObject()->indexOfProperty(el.tagName().toLatin1()) > -1) {
        setProperty(el.tagName().toLatin1(), QVariant(el.text()));
      } else if (el.tagName() == "curvetag") {
        ctaglist.append(el.text()); 
      }
    }
    n = n.nextSibling();
  }
  if (!_title.isEmpty()) {
    reparseTitle();
  }

  KstBaseCurveList l = kstObjectSubList<KstDataObject,KstBaseCurve>(KST::dataObjectList);
  KstBaseCurveList::ConstIterator end = l.end();
  for (QStringList::ConstIterator str = ctaglist.begin(); str != ctaglist.end(); ++str) {
    KstBaseCurveList::ConstIterator it = l.findTag(*str);
    if (it != end) {
      addCurve(*it);
    }
  }
  
  // Padding was incorrectly saved as 5 in Kst <= 1.2.0 so we need to strip it
  // out here since this object is buggy.  Remove this once padding is properly
  // supported?  Maybe, but geometries are then wrong.
  if (e.ownerDocument().documentElement().attribute("version") == "1.2") {
    setPadding(0);
  }
}
Example #2
0
bool KstIfaceImpl::removeCurveFromPlot(const QString& plot, const QString& curve) {
  KstPlot *p = KST::plotList.FindKstPlot(plot);
  KstBaseCurveList bcl = kstObjectSubList<KstDataObject,KstBaseCurve>(KST::dataObjectList);
  KstBaseCurveList::Iterator ci = bcl.findTag(curve);

  if (p && ci != bcl.end()) {
    (*ci)->readLock();
    p->Curves.remove(*ci);
    (*ci)->readUnlock();
    _doc->forceUpdate();
    _doc->setModified();
    return true;
  }

  return false;
}
Example #3
0
bool KstIfaceImpl::addCurveToPlot(const QString& plot, const QString& curve) {
  KstPlot *p = KST::plotList.FindKstPlot(plot);
  KstBaseCurveList bcl = kstObjectSubList<KstDataObject,KstBaseCurve>(KST::dataObjectList);
  KstBaseCurveList::Iterator ci = bcl.findTag(curve);

  if (p && ci != bcl.end()) {
    if (!p->Curves.contains(*ci)) {
      p->addCurve(*ci);
    }
    _doc->forceUpdate();
    _doc->setModified();
    return true;
  }

  return false;
}
Example #4
0
/** apply properties in the custom config widget to this */
bool KstViewLegend::readConfigWidget(QWidget *w) {
  KstViewLegendList legends;
  KstViewLegendPtr legendExtra;

  ViewLegendWidget *widget = dynamic_cast<ViewLegendWidget*>(w);
  if (!widget) {
    return false;
  }

  if (widget->_thisLegend->isChecked()) {
    legends += this;
  } else if (widget->_thisWindow->isChecked()) {
    legends = topLevelParent()->findChildrenType<KstViewLegend>(true);
  } else {
    legends = globalLegendList();
  }

  // apply the curve list, but only to this legend!
  KstBaseCurveList allCurves = kstObjectSubList<KstDataObject, KstBaseCurve>(KST::dataObjectList);
  _curves.clear();
  for (unsigned i = 0; i < widget->DisplayedCurveList->count(); i++) {
    KstBaseCurveList::Iterator it = allCurves.findTag(widget->DisplayedCurveList->text(i));
    if (it != allCurves.end()) {
      _curves.append(*it);
    }
  }

  for (uint i = 0; i < legends.size(); i++) {
    legendExtra = legends[i];

    legendExtra->setFontSize(widget->_fontSize->value());
    legendExtra->setForegroundColor(widget->_fontColor->color());
    legendExtra->setFontName(widget->_font->currentFont().toString());
    legendExtra->setTitle(widget->_title->text());

    legendExtra->setTransparent(widget->_transparent->isChecked());
    legendExtra->setBorderWidth(widget->_border->value());
    legendExtra->setBorderColor(widget->_boxColors->color());
    legendExtra->setBackgroundColor(widget->_boxColors->color());
    legendExtra->setLegendMargin(widget->_margin->value());
    legendExtra->setVertical(widget->_vertical->isChecked());
    legendExtra->setTrackContents(widget->TrackContents->isChecked());
  }

  setDirty();
  return true;
}
Example #5
0
bool KstIfaceImpl::removeCurveFromPlot(KMdiChildView *win, const QString& plot, const QString& curve) {
  KstViewWindow *w = dynamic_cast<KstViewWindow*>(win);

  if (w) {
    KstTopLevelViewPtr view = kst_cast<KstTopLevelView>(w->view());
    if (view) {
      Kst2DPlotList plots = view->findChildrenType<Kst2DPlot>(true);
      if (plots.findTag(plot) != plots.end()) {
        Kst2DPlotPtr p = *(plots.findTag(plot));
        KstBaseCurveList bcl = kstObjectSubList<KstDataObject,KstBaseCurve>(KST::dataObjectList);
        KstBaseCurveList::Iterator ci = bcl.findTag(curve);
        if (p && ci != bcl.end()) {
          p->removeCurve(*ci);
          _doc->forceUpdate();
          return true;
        }
      }
    }
  }

  return false;
}