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

Mike Fenton mike at staikos.net
Fri Oct 5 23:15:44 CEST 2007


SVN commit 721682 by fenton:

Update of spacing on Equation Dialog, population of Combobox entries and
creation of Equation support.


 M  +121 -2    equationdialog.cpp  
 M  +10 -0     equationdialog.h  
 M  +11 -11    equationtab.ui  


--- branches/work/kst/portto4/kst/src/libkstapp/equationdialog.cpp #721681:721682
@@ -15,6 +15,11 @@
 
 #include "datacollection.h"
 #include "dataobjectcollection.h"
+#include "equation.h"
+#include "plotitem.h"
+#include "vectorcurverenderitem.h"
+#include "curve.h"
+#include "defaultnames.h"
 
 namespace Kst {
 
@@ -23,6 +28,8 @@
 
   setupUi(this);
   setTabTitle(tr("Equation"));
+
+  populateFunctionList();
 }
 
 
@@ -30,6 +37,81 @@
 }
 
 
+void EquationTab::populateFunctionList() {
+  Operators->clear();
+  Operators->addItem("+");
+  Operators->addItem("-");
+  Operators->addItem("*");
+  Operators->addItem("/");
+  Operators->addItem("%");
+  Operators->addItem("^");
+  Operators->addItem("&");
+  Operators->addItem("|");
+  Operators->addItem("&&");
+  Operators->addItem("||");
+  Operators->addItem("!");
+  Operators->addItem("<");
+  Operators->addItem("<=");
+  Operators->addItem("==");
+  Operators->addItem(">=");
+  Operators->addItem(">");
+  Operators->addItem("!=");
+  Operators->addItem("PI");
+  Operators->addItem("e");
+  Operators->addItem("STEP()");
+  Operators->addItem("ABS()");
+  Operators->addItem("SQRT()");
+  Operators->addItem("CBRT()");
+  Operators->addItem("SIN()");
+  Operators->addItem("COS()");
+  Operators->addItem("TAN()");
+  Operators->addItem("ASIN()");
+  Operators->addItem("ACOS()");
+  Operators->addItem("ATAN()");
+  Operators->addItem("SEC()");
+  Operators->addItem("CSC()");
+  Operators->addItem("COT()");
+  Operators->addItem("SINH()");
+  Operators->addItem("COSH()");
+  Operators->addItem("TANH()");
+  Operators->addItem("EXP()");
+  Operators->addItem("LN()");
+  Operators->addItem("LOG()");
+  Operators->addItem("PLUGIN()");
+
+}
+
+
+VectorPtr EquationTab::xVector() const {
+  return _xVectors->selectedVector();
+}
+
+
+void EquationTab::setXVector(VectorPtr vector) {
+  _xVectors->setSelectedVector(vector);
+}
+
+QString EquationTab::Equation() const {
+  return _equation->text();
+}
+
+
+void EquationTab::setEquation(QString equation) {
+  _equation->setText(equation);
+}
+
+bool EquationTab::DoInterpolation() const {
+  return _doInterpolation->checkState() == Qt::Checked;
+}
+
+
+void EquationTab::setDoInterpolation(bool doInterpolation) {
+  if (doInterpolation)
+    _doInterpolation->setCheckState(Qt::Checked);
+  else
+    _doInterpolation->setCheckState(Qt::Unchecked);
+}
+
 EquationDialog::EquationDialog(ObjectPtr dataObject, QWidget *parent)
   : DataDialog(dataObject, parent) {
 
@@ -55,8 +137,45 @@
 
 
 ObjectPtr EquationDialog::createNewDataObject() const {
-  qDebug() << "createNewDataObject" << endl;
-  return 0;
+  //FIXME Eli, how should I construct this tag??
+  EquationPtr equation = new Equation(tagName(),
+                                     _equationTab->Equation(),
+                                     _equationTab->xVector(),
+                                     _equationTab->DoInterpolation());
+
+  equation->writeLock();
+  equation->update(0);
+  equation->unlock();
+
+  //FIXME assume new plot for now...
+  //FIXME this should be a command...
+  //FIXME need some smart placement...
+  //FIXME need to hook up appearance and placement...
+
+  CurvePtr curve = new Curve(suggestCurveName(equation->tag(), true),
+                                     equation->vX(),
+                                     equation->vY(),
+                                     0L, 0L, 0L, 0L,
+                                     QColor(Qt::red));
+
+  curve->writeLock();
+  curve->update(0);
+  curve->unlock();
+
+  CreatePlotForCurve *cmd = new CreatePlotForCurve;
+  cmd->createItem();
+
+  PlotItem *plotItem = static_cast<PlotItem*>(cmd->item());
+
+  RelationList relationList;
+  relationList.append(kst_cast<Relation>(curve));
+
+  VectorCurveRenderItem *vectorCurve = new VectorCurveRenderItem(plotItem);
+  vectorCurve->setRelationList(relationList);
+
+  plotItem->addRenderItem(vectorCurve);
+
+  return ObjectPtr(equation.data());
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/equationdialog.h #721681:721682
@@ -27,8 +27,18 @@
     EquationTab(QWidget *parent = 0);
     virtual ~EquationTab();
 
+    VectorPtr xVector() const;
+    void setXVector(VectorPtr vector);
+
+    QString Equation() const;
+    void setEquation(QString equation);
+
+    bool DoInterpolation() const;
+    void setDoInterpolation(bool doInterpolation);
+
   private Q_SLOTS:
   private:
+    void populateFunctionList();
 };
 
 class KST_EXPORT EquationDialog : public DataDialog {
--- branches/work/kst/portto4/kst/src/libkstapp/equationtab.ui #721681:721682
@@ -11,22 +11,22 @@
   </property>
   <layout class="QGridLayout" >
    <property name="leftMargin" >
-    <number>0</number>
+    <number>9</number>
    </property>
    <property name="topMargin" >
-    <number>0</number>
+    <number>9</number>
    </property>
    <property name="rightMargin" >
-    <number>0</number>
+    <number>9</number>
    </property>
    <property name="bottomMargin" >
-    <number>0</number>
+    <number>9</number>
    </property>
    <property name="horizontalSpacing" >
-    <number>0</number>
+    <number>-1</number>
    </property>
    <property name="verticalSpacing" >
-    <number>0</number>
+    <number>-1</number>
    </property>
    <item row="2" column="0" >
     <widget class="Kst::CurvePlacement" native="1" name="_curvePlacement" />
@@ -177,11 +177,6 @@
    <header>vectorselector.h</header>
   </customwidget>
   <customwidget>
-   <class>Kst::ScalarSelector</class>
-   <extends>QWidget</extends>
-   <header>scalarselector.h</header>
-  </customwidget>
-  <customwidget>
    <class>Kst::CurvePlacement</class>
    <extends>QWidget</extends>
    <header>curveplacement.h</header>
@@ -191,6 +186,11 @@
    <extends>QWidget</extends>
    <header>curveappearance.h</header>
   </customwidget>
+  <customwidget>
+   <class>Kst::ScalarSelector</class>
+   <extends>QWidget</extends>
+   <header>scalarselector.h</header>
+  </customwidget>
  </customwidgets>
  <tabstops>
   <tabstop>Operators</tabstop>


More information about the Kst mailing list