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

Adam Treat treat at kde.org
Fri Aug 24 21:40:33 CEST 2007


SVN commit 704391 by treat:

* Begin work on a layout class for plots


 M  +2 -0      libkstapp.pro  
 M  +27 -4     mainwindow.cpp  
 M  +1 -0      mainwindow.h  
 M  +0 -3      plotitem.cpp  
 M  +4 -0      plotitem.h  
 A             plotlayoutitem.cpp   [License: GPL (v2+)]
 A             plotlayoutitem.h   [License: GPL (v2+)]


--- branches/work/kst/portto4/kst/src/libkstapp/libkstapp.pro #704390:704391
@@ -39,6 +39,7 @@
     memorywidget.cpp \
     pictureitem.cpp \
     plotitem.cpp \
+    plotlayoutitem.cpp \
     plotrenderitem.cpp \
     qgetoptions.cpp \
     vectorcurverenderitem.cpp \
@@ -76,6 +77,7 @@
     memorywidget.h \
     pictureitem.h \
     plotitem.h \
+    plotlayoutitem.h \
     plotrenderitem.h \
     qgetoptions.h \
     vectorcurverenderitem.h \
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #704390:704391
@@ -33,12 +33,13 @@
 
 #include <QtGui>
 
-// Temporaries
+//FIXME Temporaries REMOVE!!
 #include "kstavector.h"
 #include "kstdatacollection.h"
 #include "kstdataobjectcollection.h"
 #include "kstequation.h"
 
+#include "plotlayoutitem.h"
 
 namespace Kst {
 
@@ -306,6 +307,23 @@
 }
 
 
+void MainWindow::demoPlotLayout() {
+
+  View *v = tabWidget()->currentView();
+  PlotLayoutItem *layout = new PlotLayoutItem(v);
+  v->scene()->addItem(layout);
+  layout->setZValue(1);
+  foreach (QGraphicsItem *item, v->items()) {
+    if (PlotItem *plot = qgraphicsitem_cast<PlotItem*>(item)) {
+      plot->setParentItem(layout);
+    }
+  }
+
+  layout->setViewRect(QRectF(0,0,300,300));
+
+}
+
+
 void MainWindow::demoModel() {
   KstVectorPtr v = new KstVector;
   v->resize(999999);
@@ -470,9 +488,14 @@
 
   // FIXME: remove this later.
   QMenu *demoMenu = menuBar()->addMenu("&Demo");
-  QAction *demo = new QAction("Vector model", this);
-  connect(demo, SIGNAL(triggered()), this, SLOT(demoModel()));
-  demoMenu->addAction(demo);
+
+  QAction *demoLayout = new QAction("Plot layout", this);
+  connect(demoLayout, SIGNAL(triggered()), this, SLOT(demoPlotLayout()));
+  demoMenu->addAction(demoLayout);
+
+  QAction *demoModel = new QAction("Vector model", this);
+  connect(demoModel, SIGNAL(triggered()), this, SLOT(demoModel()));
+  demoMenu->addAction(demoModel);
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.h #704390:704391
@@ -69,6 +69,7 @@
     void createPlot();
     void createSvg();
 
+    void demoPlotLayout();
     void demoModel();
 
     void performHeavyStartupActions();
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #704390:704391
@@ -9,9 +9,6 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <QDebug>
-#include <QPainterPath>
-
 #include "plotitem.h"
 
 #include "plotrenderitem.h"
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #704390:704391
@@ -30,6 +30,10 @@
   public:
     PlotItem(View *parent);
     virtual ~PlotItem();
+
+    enum { Type = UserType + 1 };
+    int type() const { return Type; }
+
     void paint(QPainter *painter);
 
     qreal width() const { return viewRect().normalized().width(); }


More information about the Kst mailing list