[Kst] branches/work/kst/portto4/kst/src/libkstapp

Mike Fenton mike at staikos.net
Fri Jul 4 16:37:18 CEST 2008


SVN commit 828069 by fenton:

Add Legend class with placement but no drawing.


 M  +23 -0     labeltab.cpp  
 M  +6 -0      labeltab.h  
 M  +47 -4     labeltab.ui  
 A             legenditem.cpp   [License: GPL (v2+)]
 A             legenditem.h   [License: GPL (v2+)]
 M  +2 -0      libkstapp.pro  
 M  +32 -0     plotitem.cpp  
 M  +12 -0     plotitem.h  
 M  +6 -0      plotitemdialog.cpp  
 M  +1 -0      viewitemzorder.h  


--- branches/work/kst/portto4/kst/src/libkstapp/labeltab.cpp #828068:828069
@@ -52,6 +52,9 @@
   connect(_bottomFamily, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
   connect(_rightFamily, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
 
+  connect(_showLegend, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
+  connect(_matchLegendContents, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
+
   connect(_applyGlobalsButton, SIGNAL(pressed()), this, SLOT(applyGlobals()));
   connect(_autoLabel, SIGNAL(pressed()), this, SLOT(autoLabel()));
 }
@@ -248,6 +251,26 @@
   _bottomFontSize->setValue(scale);
 }
 
+
+bool LabelTab::showLegend() const {
+  return _showLegend->isChecked();
 }
 
+
+void LabelTab::setShowLegend(const bool show) {
+  _showLegend->setChecked(show);
+}
+
+
+bool LabelTab::matchLegend() const {
+  return _matchLegendContents->isChecked();
+}
+
+
+void LabelTab::setMatchLegend(const bool match) {
+  _matchLegendContents->setChecked(match);
+}
+
+}
+
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/labeltab.h #828068:828069
@@ -62,6 +62,12 @@
     qreal rightLabelFontScale() const;
     void setRightLabelFontScale(const qreal scale);
 
+    bool showLegend() const;
+    void setShowLegend(const bool show);
+
+    bool matchLegend() const;
+    void setMatchLegend(const bool match);
+
   public Q_SLOTS:
     void update();
     void autoLabel();
--- branches/work/kst/portto4/kst/src/libkstapp/labeltab.ui #828068:828069
@@ -5,7 +5,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>762</width>
+    <width>773</width>
     <height>499</height>
    </rect>
   </property>
@@ -364,15 +364,58 @@
      </layout>
     </widget>
    </item>
-   <item row="3" column="0" >
+   <item row="3" column="0" colspan="2" >
+    <widget class="QGroupBox" name="_legendGroupBox" >
+     <property name="title" >
+      <string>Legend</string>
+     </property>
+     <layout class="QGridLayout" >
+      <item row="0" column="0" >
+       <widget class="QCheckBox" name="_showLegend" >
+        <property name="text" >
+         <string>Show Legend</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1" >
+       <widget class="QCheckBox" name="_matchLegendContents" >
+        <property name="text" >
+         <string>Match to Contents</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="2" >
+       <widget class="QPushButton" name="_editLegendContents" >
+        <property name="text" >
+         <string>Edit</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="3" >
+       <spacer>
+        <property name="orientation" >
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" >
+         <size>
+          <width>40</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="4" column="0" >
     <spacer>
      <property name="orientation" >
       <enum>Qt::Vertical</enum>
      </property>
      <property name="sizeHint" >
       <size>
-       <width>20</width>
-       <height>41</height>
+       <width>372</width>
+       <height>21</height>
       </size>
      </property>
     </spacer>
--- branches/work/kst/portto4/kst/src/libkstapp/libkstapp.pro #828068:828069
@@ -75,6 +75,7 @@
     labeltab.cpp \
     layoutboxitem.cpp \
     layouttab.cpp \
+    legenditem.cpp \
     lineitem.cpp \
     mainwindow.cpp \
     markerstab.cpp \
@@ -168,6 +169,7 @@
     labeltab.h \
     layoutboxitem.h \
     layouttab.h \
+    legenditem.h \
     lineitem.h \
     mainwindow.h \
     markerstab.h \
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #828068:828069
@@ -65,6 +65,9 @@
   _bottomLabelFontScale(0.0),
   _topLabelFontScale(0.0),
   _rightLabelFontScale(0.0),
+  _showLegend(false),
+  _autoLegend(true),
+  _legend(0),
   _zoomMenu(0)
  {
 
@@ -1613,6 +1616,35 @@
 }
 
 
+bool PlotItem::showLegend() const {
+  return _showLegend;
+}
+
+
+void PlotItem::setShowLegend(const bool show) {
+  qDebug() << "setShowLegend";
+  _showLegend = show;
+  if (show) {
+    if (!_legend) {
+      _legend = new LegendItem(this);
+    }
+    _legend->setVisible(true);
+  } else {
+    _legend->setVisible(false);
+  }
+}
+
+
+bool PlotItem::matchLegend() const {
+  return _showLegend;
+}
+
+
+void PlotItem::setMatchLegend(const bool match) {
+  _autoLegend = match;
+}
+
+
 bool PlotItem::tryShortcut(const QString &keySequence) {
   return ViewItem::tryShortcut(keySequence);
 }
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #828068:828069
@@ -24,6 +24,7 @@
 #include "plotmarkers.h"
 
 #include "plotaxis.h"
+#include "legenditem.h"
 
 namespace Kst {
 
@@ -148,6 +149,12 @@
     qreal rightLabelFontScale() const;
     void setRightLabelFontScale(const qreal scale);
 
+    bool showLegend() const;
+    void setShowLegend(const bool show);
+
+    bool matchLegend() const;
+    void setMatchLegend(const bool match);
+
     qreal mapXToPlot(const qreal &x) const;
     qreal mapYToPlot(const qreal &y) const;
     QPointF mapToPlot(const QPointF &point) const;
@@ -306,6 +313,11 @@
     qreal _topLabelFontScale;
     qreal _rightLabelFontScale;
 
+    bool _showLegend;
+    bool _autoLegend;
+
+    LegendItem* _legend;
+
     QMenu *_zoomMenu;
     QAction *_zoomMaximum;
     QAction *_zoomMaxSpikeInsensitive;
--- branches/work/kst/portto4/kst/src/libkstapp/plotitemdialog.cpp #828068:828069
@@ -110,6 +110,10 @@
   _labelTab->setBottomLabelFontScale(_plotItem->bottomLabelFontScale());
   _labelTab->setTopLabelFontScale(_plotItem->topLabelFontScale());
   _labelTab->setRightLabelFontScale(_plotItem->rightLabelFontScale());
+
+  _labelTab->setShowLegend(_plotItem->showLegend());
+  _labelTab->setMatchLegend(_plotItem->matchLegend());
+
 }
 
 
@@ -440,6 +444,8 @@
   _plotItem->setRightLabelFontScale(_labelTab->rightLabelFontScale());
   _plotItem->setTopLabelFontScale(_labelTab->topLabelFontScale());
   _plotItem->setBottomLabelFontScale(_labelTab->bottomLabelFontScale());
+  _plotItem->setShowLegend(_labelTab->showLegend());
+  _plotItem->setMatchLegend(_labelTab->matchLegend());
 
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/viewitemzorder.h #828068:828069
@@ -19,6 +19,7 @@
 #define PICTURE_ZVALUE      7
 #define SVG_ZVALUE          7
 #define LABEL_ZVALUE        8
+#define LEGEND_ZVALUE       8
 #define LINE_ZVALUE         9
 #define ARROW_ZVALUE        9
 


More information about the Kst mailing list