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

Barth Netterfield netterfield at astro.utoronto.ca
Fri Sep 10 15:35:35 CEST 2010


SVN commit 1173797 by netterfield:

Add some builtin palettes.
Fix data manager update problems

BUG: 248888



 M  +1 -2      libkst/objectstore.cpp  
 M  +2 -2      libkst/objectstore.h  
 M  +9 -2      libkstapp/datadialog.cpp  
 M  +1 -0      libkstapp/datamanager.cpp  
 M  +5 -23     libkstapp/sessionmodel.cpp  
 U             libkstapp/vectordialog.cpp  
 A             libkstmath/builtinpalettes.h   [License: GPL (v2+)]
 M  +1 -0      libkstmath/libkstmath.pro  
 M  +30 -17    libkstmath/palette.cpp  
 M  +1 -0      libkstmath/palette.h  
 M  +5 -2      widgets/colorpalette.cpp  
 M  +9 -2      widgets/colorpalette.ui  


--- branches/work/kst/portto4/kst/src/libkst/objectstore.cpp #1173796:1173797
@@ -3,7 +3,7 @@
                              -------------------
     begin                : November 22, 2006
     copyright            : (C) 2006 The University of Toronto
-    email                :
+    email                : netterfield at astro.utoronto.ca
  ***************************************************************************/
 
 /***************************************************************************
@@ -43,7 +43,6 @@
 
 bool ObjectStore::removeObject(Object *o) {
   if (!this) {
-    qDebug() << "tried to remove object in store, but there is no store?\n";
     return false;
   }
 
--- branches/work/kst/portto4/kst/src/libkst/objectstore.h #1173796:1173797
@@ -2,8 +2,8 @@
               objectstore.h: store of Objects
                              -------------------
     begin                : November 22, 2006
-    copyright            : (C) 2006 The University of Toronto
-    email                :
+    copyright            : (C) 2006-2010 The University of Toronto
+    email                : netterfield at astro.utoronto.ca
  ***************************************************************************/
 
 /***************************************************************************
--- branches/work/kst/portto4/kst/src/libkstapp/datadialog.cpp #1173796:1173797
@@ -29,6 +29,7 @@
 #include "mainwindow.h"
 #include "application.h"
 #include "updatemanager.h"
+#include "sessionmodel.h"
 
 namespace Kst {
 
@@ -146,13 +147,19 @@
 
 void DataDialog::slotApply() {
   Kst::ObjectPtr ptr;
-  if (!dataObject())
+  bool do_session_reset = false;
+  if (!dataObject()) {
     ptr = createNewDataObject();
-  else
+    do_session_reset = true;
+  } else {
     ptr = editExistingDataObject();
+  }
   setDataObject(ptr);
   UpdateManager::self()->doUpdates();
   kstApp->mainWindow()->document()->setChanged(true);
+  if (do_session_reset) {
+    kstApp->mainWindow()->document()->session()->triggerReset();
+  }
   clearModified();
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/datamanager.cpp #1173796:1173797
@@ -565,6 +565,7 @@
   do {
     setUsedFlags();
   } while (_doc->objectStore()->deleteUnsetUsedFlags());
+  _doc->session()->triggerReset();
   _session->reset();
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/sessionmodel.cpp #1173796:1173797
@@ -36,7 +36,7 @@
 
 int SessionModel::columnCount(const QModelIndex& parent) const {
   Q_UNUSED(parent)
-  return 5;
+  return 4;
 }
 
 
@@ -182,15 +182,9 @@
       rc = p->typeString();
       break;
     case 2:
-      // this is very fragile and depends on how the smart pointers are being carried around.
-      // we should consider a different approach (?).  Keep it now for debugging...
-      // It doesn't know, for instance, if a plot has been 'deleted'.
-      rc = QString::number(p.count()-4); //4: object store, session model, cast, local
-      break;
-    case 3:
       rc = p->sizeString();
       break;
-    case 4:
+    case 3:
       rc = p->propertyString();
       break;
     default:
@@ -218,16 +212,11 @@
       p->unlock();
       break;
     case 2:
-      // this is very fragile and depends on how the smart pointers are being carried around.
-      // we should consider a different approach or delete(?).   Keep it now for debugging...
-      rc = QString::number(p.count()-4); //4: object store, session model, cast, local
-      break;
-    case 3:
       p->readLock();
       rc = p->sampleCount();
       p->unlock();
       break;
-    case 4:
+    case 3:
       p->readLock();
       rc = p->propertyString();
       p->unlock();
@@ -257,16 +246,11 @@
       p->unlock();
       break;
     case 2:
-      // this is very fragile and depends on how the smart pointers are being carried around.
-      // we should consider a different approach or delete (?).  Keep it now for debugging...
-      rc = QString::number(p.count()-4); //4: object store, session model, cast, local
-      break;
-    case 3:
       p->readLock();
       rc = p->sampleCount();
       p->unlock();
       break;
-    case 4:
+    case 3:
       p->readLock();
       rc = p->propertyString();
       p->unlock();
@@ -340,10 +324,8 @@
     case 1:
       return tr("Type");
     case 2:
-      return tr("Used");
-    case 3:
       return tr("Samples");
-    case 4:
+    case 3:
       return tr("Properties");
     default:
       break;
--- branches/work/kst/portto4/kst/src/libkstmath/libkstmath.pro #1173796:1173797
@@ -73,6 +73,7 @@
     basicpluginfactory.h \
     builtinobjects.h \
     builtinrelations.h \
+    builtinpalettes.h \
     colorsequence.h \
     csd.h \
     csdfactory.h \
--- branches/work/kst/portto4/kst/src/libkstmath/palette.cpp #1173796:1173797
@@ -15,30 +15,19 @@
 #include <QVector>
 #include <qapplication.h>
 #include <math_kst.h>
+#include "builtinpalettes.h"
 
 namespace Kst {
 
 
-// Default palette.
-static const char *const KstColors[] = { "red",
-                                      "blue",
-                                      "green",
-                                      "black",
-                                      "magenta",
-                                      "steelblue",
-                                      "#501010",
-                                      "#105010"
-                                      };
-static const int KstColorsCount = sizeof(KstColors) / sizeof(char*);
-static const QString KstColorsName = "Kst Colors";
-
-static const int KstGrayscaleCount = 255;
-static const QString KstGrayscaleName = "Kst Grayscale";
-
 QStringList Palette::getPaletteList() { 
   QStringList paletteList;
 
   paletteList.append(KstGrayscaleName);
+  paletteList.append(RedTempName);
+  paletteList.append(SpectrumName);
+  paletteList.append(EosAName);
+  paletteList.append(EosBName);
   paletteList.append(KstColorsName);
 
   //TODO: support loading palettes from disk.
@@ -47,7 +36,7 @@
 }
 
 Palette::Palette(): _colors(0), _count(0) {
-  changePaletteName(KstColorsName);
+  changePaletteName(DefaultPalette);
 }
 
 
@@ -81,6 +70,30 @@
       _rgb[i] = _colors[i].rgb();
     }
     _count = KstColorsCount;
+  } else if (_paletteName == RedTempName) {
+    for (int i = 0; i < RedTempCount; i++) {
+      _colors[i] = QColor(RedTemp[i][0], RedTemp[i][1], RedTemp[i][2]);
+      _rgb[i] = _colors[i].rgb();
+    }
+    _count = RedTempCount;
+  } else if (_paletteName == SpectrumName) {
+    for (int i = 0; i < SpectrumCount; i++) {
+      _colors[i] = QColor(Spectrum[i][0], Spectrum[i][1], Spectrum[i][2]);
+      _rgb[i] = _colors[i].rgb();
+    }
+    _count = SpectrumCount;
+  } else if (_paletteName == EosAName) {
+    for (int i = 0; i < EosACount; i++) {
+      _colors[i] = QColor(EosA[i][0], EosA[i][1], EosA[i][2]);
+      _rgb[i] = _colors[i].rgb();
+    }
+    _count = EosACount;
+  } else if (_paletteName == EosBName) {
+    for (int i = 0; i < EosBCount; i++) {
+      _colors[i] = QColor(EosB[i][0], EosB[i][1], EosB[i][2]);
+      _rgb[i] = _colors[i].rgb();
+    }
+    _count = EosBCount;  
   } else {
     for (int i = 0; i < KstGrayscaleCount; i++) {
       _colors[i] = QColor(i, i, i);
--- branches/work/kst/portto4/kst/src/libkstmath/palette.h #1173796:1173797
@@ -23,6 +23,7 @@
 
 const unsigned int maxColorTableSize = 2048;
 
+const QString DefaultPalette("Kst Grayscale");
 class KSTMATH_EXPORT Palette 
 {
   public:
--- branches/work/kst/portto4/kst/src/widgets/colorpalette.cpp #1173796:1173797
@@ -26,8 +26,8 @@
   connect(_palette, SIGNAL(activated(const QString&)), this, SLOT(updatePalette(const QString&)));
   connect(_palette, SIGNAL(currentIndexChanged(int)), this, SIGNAL(selectionChanged()));
 
-  refresh();
-  updatePalette();
+  refresh(DefaultPalette);
+  updatePalette(DefaultPalette);
 }
 
 
@@ -111,8 +111,11 @@
       }
     }
     if (i == _palette->count()) {
+      i = _palette->findText(DefaultPalette);
+      if (i<0) {
       i = 0;
     }
+    }
     _palette->setCurrentIndex(i);
   }
 }
--- branches/work/kst/portto4/kst/src/widgets/colorpalette.ui #1173796:1173797
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0" >
  <class>ColorPalette</class>
  <widget class="QWidget" name="ColorPalette" >
@@ -19,7 +20,7 @@
    <item>
     <widget class="QLabel" name="_label" >
      <property name="sizePolicy" >
-      <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+      <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
        <horstretch>0</horstretch>
        <verstretch>0</verstretch>
       </sizepolicy>
@@ -41,7 +42,7 @@
    <item>
     <widget class="QComboBox" name="_palette" >
      <property name="sizePolicy" >
-      <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
+      <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
        <horstretch>0</horstretch>
        <verstretch>0</verstretch>
       </sizepolicy>
@@ -53,6 +54,12 @@
    </item>
    <item>
     <widget class="QLabel" name="_paletteDisplay" >
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
      <property name="text" >
       <string/>
      </property>


More information about the Kst mailing list