[Kst] extragear/graphics/kst/kst

Barth Netterfield netterfield at astro.utoronto.ca
Fri Nov 18 05:35:02 CET 2005


SVN commit 481169 by netterfield:

Save/load new legends. 
Loading old legends isn't started yet.

A start at contentsRect()



 M  +7 -0      kst2dplot.cpp  
 M  +3 -0      kst2dplot.h  
 M  +25 -22    kstviewlegend.cpp  
 M  +5 -1      kstviewobject.cpp  


--- trunk/extragear/graphics/kst/kst/kst2dplot.cpp #481168:481169
@@ -6462,6 +6462,13 @@
   return vl;
 }
 
+QRect Kst2DPlot::contentsRect() const{
+  return QRect(PlotRegion.left() + geometry().left(), 
+               PlotRegion.top() + geometry().top(),
+               PlotRegion.width(),
+               PlotRegion.height());
+}
+
 #undef LABEL_PRECISION
 #include "kst2dplot.moc"
 
--- trunk/extragear/graphics/kst/kst/kst2dplot.h #481168:481169
@@ -340,6 +340,9 @@
   KstViewLegendPtr legend();
 
   KstViewLegendPtr getOrCreateLegend();
+  
+  virtual QRect contentsRect() const;
+
 signals:
   void modified();
 
--- trunk/extragear/graphics/kst/kst/kstviewlegend.cpp #481168:481169
@@ -1,9 +1,9 @@
 /***************************************************************************
                               kstviewlegend.cpp
                              ------------------
-    begin                : Apr 10 2004
-    copyright            : (C) 2000 by cbn
-                           (C) 2004 by The University of Toronto
+    begin                : September 2005
+    copyright            : (C) 2005 by cbn
+                           (C) 2005 by The University of Toronto
     email                :
  ***************************************************************************/
 
@@ -37,13 +37,14 @@
 #include <qbitmap.h>
 #include <qmetaobject.h>
 #include <qptrstack.h>
+#include <qstylesheet.h>
 
 #include <stdlib.h>
 
 #define MIN_FONT_SIZE 5
 
 KstViewLegend::KstViewLegend()
-: KstBorderedViewObject("Label") {
+: KstBorderedViewObject("Legend") {
   _rotation = 0;
   _vertical = true;
   _fontName = KstApp::inst()->defaultFont();
@@ -61,7 +62,7 @@
 : KstBorderedViewObject(e) {
 
   // some defaults and invariants
-  _type = "Label";
+  _type = "Legend";
   _rotation = 0.0;
   _fontName = KstApp::inst()->defaultFont();
   _fontSize = 0;
@@ -69,7 +70,8 @@
   _absFontSize = _fontSize+KstSettings::globalSettings()->plotFontSize;
   _layoutActions |= Delete | Raise | Lower | RaiseToTop | LowerToBottom | Rename | Edit;
   _standardActions |= Delete | Edit;
-
+  QStringList ctaglist;
+  
   // read the properties
   QDomNode n = e.firstChild();
   while (!n.isNull()) {
@@ -77,10 +79,20 @@
     if (!el.isNull()) {
       if (metaObject()->findProperty(el.tagName().latin1(), true) > -1) {
         setProperty(el.tagName().latin1(), QVariant(el.text()));
+      } else if (el.tagName() == "curvetag") {
+        ctaglist.append(el.text()); 
       }
     }
     n = n.nextSibling();
   }
+
+  KstBaseCurveList l = kstObjectSubList<KstDataObject,KstBaseCurve>(KST::dataObjectList);
+  for (QStringList::iterator str = ctaglist.begin(); str!=ctaglist.end(); ++str) {
+    KstBaseCurveList::Iterator it = l.findTag(*str);
+    if (it != l.end()) {
+      addCurve(*it);
+    }
+  }
 }
 
 
@@ -113,18 +125,16 @@
 void KstViewLegend::save(QTextStream &ts, const QString& indent) {
   ts << indent << "<" << type() << ">" << endl;
   KstBorderedViewObject::save(ts, indent + "  ");
+  
+  for (KstBaseCurveList::Iterator j = Curves.begin(); j != Curves.end(); ++j) {
+    (*j)->readLock();
+    ts << indent+"  " << "<curvetag>" << QStyleSheet::escape((*j)->tagName()) << "</curvetag>" << endl;
+    (*j)->readUnlock();
+  }
+
   ts << indent << "</" << type() << ">" << endl;
 }
 
-
-void KstViewLegend::setDoScalarReplacement(bool replace) {
-  if (replace != _replace) {
-    setDirty();
-    _replace = replace;
-  }
-}
-
-
 void KstViewLegend::drawToBuffer() {
   setDirty(false);
 
@@ -323,16 +333,9 @@
 
 bool KstViewLegend::layoutPopupMenu(KPopupMenu *menu, const QPoint& pos, KstViewObjectPtr topLevelParent) {
   KstViewObject::layoutPopupMenu(menu, pos, topLevelParent);
-  //menu->insertItem(i18n("&Adjust Size"), this, SLOT(adjustSizeForText()));
   return true;
 }
 
-
-bool KstViewLegend::doScalarReplacement() const {
-  return _replace;
-}
-
-
 KstViewObjectPtr create_KstViewLegend() {
   return KstViewObjectPtr(new KstViewLegend());
 }
--- trunk/extragear/graphics/kst/kst/kstviewobject.cpp #481168:481169
@@ -44,6 +44,7 @@
 #include "kstviewbox.h"
 #include "kstviewellipse.h"
 #include "kstviewlabel.h"
+#include "kstviewlegend.h"
 #include "kstviewobject.h"
 #include "kstviewobjectfactory.h"
 #include "kstviewpicture.h"
@@ -195,6 +196,10 @@
         KstViewLabelPtr label = new KstViewLabel(el);
         appendChild(label.data(), true);
         label->loadChildren(el);  
+      } else if (el.tagName() == "Legend") {
+        KstViewLegendPtr legend = new KstViewLegend(el);
+        appendChild(legend.data(), true);
+        legend->loadChildren(el);  
       } else if (el.tagName() == "Picture") {
         KstViewPicturePtr picture = new KstViewPicture(el);
         appendChild(picture.data(), true);
@@ -288,7 +293,6 @@
   ts << indent << "</" << type() << ">" << endl;
 }
 
-
 void KstViewObject::paint(KstPaintType type, QPainter& p, const QRegion& bounds) {
   p.save();
   p.setViewport(geometry());


More information about the Kst mailing list