Bug 129598 - Inconsistent UI in regard to color palette
Summary: Inconsistent UI in regard to color palette
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-21 20:46 UTC by Andrew Walker
Modified: 2006-06-23 22:12 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Walker 2006-06-21 20:46:08 UTC
Version:           1.2.1 (using KDE KDE 3.5.0)
OS:                Linux

At present a color palette is drawn in the New Image dialog whenever the user highlights a different color palette. 

Similar color palette selection is provided by the CSD and Settings dialog, but no corresponding color palette is drawn. For consistency of the UI this should probably be added.
Comment 1 Andrew Walker 2006-06-22 20:39:50 UTC
SVN commit 553980 by arwalker:

CCBUG:129598 Add palette visualisation to csd dialog

 M  +21 -3     csddialogwidget.ui  
 M  +33 -0     kstcsddialog_i.cpp  
 M  +2 -1      kstcsddialog_i.h  


--- trunk/extragear/graphics/kst/src/libkstapp/csddialogwidget.ui #553979:553980
@@ -9,9 +9,12 @@
             <x>0</x>
             <y>0</y>
             <width>549</width>
-            <height>462</height>
+            <height>488</height>
         </rect>
     </property>
+    <property name="caption">
+        <string>CSDDialogWidget</string>
+    </property>
     <grid>
         <property name="name">
             <cstring>unnamed</cstring>
@@ -158,7 +161,7 @@
                 </property>
                 <widget class="QLayoutWidget" row="0" column="0">
                     <property name="name">
-                        <cstring>layout47</cstring>
+                        <cstring>layout10</cstring>
                     </property>
                     <hbox>
                         <property name="name">
@@ -204,13 +207,22 @@
                                 <bool>false</bool>
                             </property>
                         </widget>
+                        <widget class="QLabel">
+                            <property name="name">
+                                <cstring>_paletteDisplay</cstring>
+                            </property>
+                            <property name="text">
+                                <string></string>
+                            </property>
+                        </widget>
                     </hbox>
                 </widget>
             </grid>
         </widget>
     </grid>
 </widget>
-<layoutdefaults spacing="6" margin="11"/>
+<customwidgets>
+</customwidgets>
 <tabstops>
     <tabstop>_vector</tabstop>
     <tabstop>_windowSize</tabstop>
@@ -223,4 +235,10 @@
     <include location="global" impldecl="in declaration">kst_export.h</include>
 </includes>
 <exportmacro>KST_EXPORT</exportmacro>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+    <includehint>vectorselector.h</includehint>
+    <includehint>fftoptionswidget.h</includehint>
+    <includehint>curveplacementwidget.h</includehint>
+</includehints>
 </UI>
--- trunk/extragear/graphics/kst/src/libkstapp/kstcsddialog_i.cpp #553979:553980
@@ -61,6 +61,8 @@
   _w = new CSDDialogWidget(_contents);
   setMultiple(true);
   connect(_w->_vector, SIGNAL(newVectorCreated(const QString&)), this, SIGNAL(modified()));
+  connect(_w->_palette, SIGNAL(highlighted(const QString&)), this, SLOT(updatePalette(const QString&)));
+  connect(_w->_palette, SIGNAL(activated(const QString&)), this, SLOT(updatePalette(const QString&)));
  
   //for multiple edit mode
   connect(_w->_kstFFTOptions->Apodize, SIGNAL(clicked()), this, SLOT(setApodizeDirty()));
@@ -147,6 +149,37 @@
 }
 
 
+void KstCsdDialogI::updatePalette(const QString& palette) {
+  KPalette* newPal = new KPalette(palette);
+  QColor color;
+  int nrColors = newPal->nrColors();
+  int height = _w->_paletteDisplay->contentsRect().height();
+  int width = 7 * height;
+  QPixmap pix(width, height);
+  QPainter p(&pix);
+  int size;
+  int step = 1;
+  int pos = 0;
+  int i;
+
+  size = width / nrColors;
+  if (size == 0) {
+    size = 1;
+    step = nrColors / width;
+  }
+
+  p.fillRect(p.window(), QColor("white"));
+  for (i=0; i<nrColors; i+=step) {
+    color = newPal->color(i);
+    p.fillRect(pos*size, 0, size, height, QBrush(color));
+    ++pos;
+  }  
+  _w->_paletteDisplay->setPixmap(pix);
+  
+  delete newPal;
+}
+
+
 /* returns true if succesful */
 bool KstCsdDialogI::newObject() {
   QString tag_name = _tagName->text();
--- trunk/extragear/graphics/kst/src/libkstapp/kstcsddialog_i.h #553979:553980
@@ -64,7 +64,8 @@
     void setApodizeDirty();
     void setRemoveMeanDirty();
     void setInterleavedDirty();
-
+    void updatePalette(const QString& palette);
+    
   private:
     static const QString& defaultTag;
     void fillFieldsForEdit();
Comment 2 Duncan Hanson 2006-06-22 23:44:21 UTC
SVN commit 554016 by dhanson:

CCBUG:129598 i find that the psds calculated with psdcalculator differ from those calculated by KstPSD because of normalization. i've reverted PSDCalculator to the original normalization- but I can't see that I've done anything wrong.

 M  +12 -2     psdcalculator.cpp  


--- trunk/extragear/graphics/kst/src/libkstmath/psdcalculator.cpp #554015:554016
@@ -33,7 +33,7 @@
 #define PSDMINLEN 2
 #define PSDMAXLEN 27
 
-double PSDCalculator::cabs2(double r, double i) {
+inline double PSDCalculator::cabs2(double r, double i) {
   return r*r + i*i;
 }
 
@@ -184,7 +184,7 @@
     updateWindowFxn(apodizeFxn, gaussianSigma);
   }
 
-  int currentCopyLen;
+  int currentCopyLen, nsamples = 0;
   int i_samp, i_subset, ioffset;
 
   memset(output, 0, sizeof(double)*outputLen); // initialize output.
@@ -246,6 +246,8 @@
       }
     }
 
+    nsamples += currentCopyLen;
+
     rdft(_awLen, 1, _a); //real discrete fourier transorm on _a.
 
     output[0] += _a[0] * _a[0];
@@ -255,6 +257,9 @@
     }
   }
 
+  // FIXME: NORMALIZATION. 
+  /* This normalization doesn't give the same results as the original KstPSD.
+
   double frequencyStep = .5*(double)inputSamplingFreq/(double)(outputLen-1);
 
   //normalization factors which were left out earlier for speed. 
@@ -262,7 +267,12 @@
   //    - /(_awLen*_awLen) for the constant Wss from numerical recipes in C. (ensure that the window function agrees with this.)
   //    - /i_subset to average the powers in all the subsets.
   double norm = 2.0/(double)_awLen/(double)_awLen/(double)i_subset;
+  */
 
+  // original normalization
+  double frequencyStep = 2.0*(double)inputSamplingFreq/(double)nsamples; //OLD value for frequencyStep.
+  double norm = 2.0/(double)nsamples*2.0/(double)nsamples; //OLD value for norm.
+
   switch (outputType) {
   default:
     case PSDAmplitudeSpectralDensity: // amplitude spectral density (default) [V/Hz^1/2]
Comment 3 Andrew Walker 2006-06-23 22:12:36 UTC
SVN commit 554349 by arwalker:

BUG:129598 Use widget for color palette selection for consistency of UI elements across dialogs

 M  +67 -99    libkstapp/csddialogwidget.ui  
 M  +67 -93    libkstapp/imagedialogwidget.ui  
 M  +3 -45     libkstapp/kstcsddialog_i.cpp  
 M  +0 -1      libkstapp/kstcsddialog_i.h  
 M  +24 -79    libkstapp/kstimagedialog_i.cpp  
 M  +0 -1      libkstapp/kstimagedialog_i.h  
 M  +99 -91    libkstapp/kstsettingsdlg.ui  
 M  +9 -25     libkstapp/kstsettingsdlg.ui.h  
 M  +2 -1      widgets/Makefile.am  
 A             widgets/colorpalettewidget.ui  
 A             widgets/colorpalettewidget.ui.h   [License: no copyright]