OSDN Git Service

M src/gui/plot/PlotModifierWidget.cpp: fix a bug
authornogu <nogu@3964cfc2-352b-0410-b06c-9ff7d3e98643>
Sun, 22 Mar 2009 10:57:19 +0000 (10:57 +0000)
committernogu <nogu@3964cfc2-352b-0410-b06c-9ff7d3e98643>
Sun, 22 Mar 2009 10:57:19 +0000 (10:57 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/cueplot/trunk@983 3964cfc2-352b-0410-b06c-9ff7d3e98643

src/gui/plot/PlotModifierWidget.cpp

index a6148e8..965bfd1 100644 (file)
@@ -214,37 +214,80 @@ const QList<PlotModifier> &PlotModifierWidget::modifier() const
 
 void PlotModifierWidget::apply()
 {
+       int indexArray[3];
+       bool hasIndexArray[3];
+       for (int i = 0; i < 3; i++) {
+               bool isChecked = indexCheckBoxList[i]->isChecked();
+               int index = isChecked ? indexSpinBoxList[i]->value() : -1;
+               indexArray[i] = index;
+               hasIndexArray[i] = (!isChecked || index >= 0);
+       }
+       int samplingArray[6];
+       bool hasSamplingArray[6];
+       for (int i = 0; i < 6; i++) {
+               bool isChecked = samplingCheckBoxList[i]->isChecked();
+               int sampling = isChecked ? samplingSpinBoxList[i]->value() : -1;
+               samplingArray[i] = sampling;
+               hasSamplingArray[i] = (!isChecked || sampling >= 0);
+       }
+       bool isChecked = interpCheckBox->isChecked();
+       int smooth = isChecked ? interpComboBox->currentIndex() : -1;
+       bool hasSmooth = (!isChecked || smooth >= 0);
+
+       QString entryArray[AXIS_NUM];
+       bool hasEntryArray[AXIS_NUM];
+       for (int i = 0; i < AXIS_NUM; i++) {
+               bool isChecked = columnCheckBox[i]->isChecked();
+               QString entry = isChecked ? columnLineEdit[i]->text() : "";
+               entryArray[i] = entry;
+               hasEntryArray[i] = (!isChecked || !entry.isEmpty());
+       }
+
+       isChecked = formatCheckBox->isChecked();
+       QString format = isChecked ? formatLineEdit->text() : "";
+       bool hasFormat = (!isChecked || !format.isEmpty());
        for (int i = 0, j = plotModifierList.size(); i < j; i++) {
-               QList<int> indexList;
-               for (int k = 0, l = indexCheckBoxList.size(); k < l; k++) {
-                       indexList.append(indexCheckBoxList[k]->isChecked() ?  
-                                       indexSpinBoxList[k]->value() : -1);
+               if (hasIndexArray[0]) {
+                       plotModifierList[i].setM(indexArray[0]);
+               }
+               if (hasIndexArray[1]) {
+                       plotModifierList[i].setN(indexArray[1]);
                }
-               plotModifierList[i].setM(indexList.at(0));
-               plotModifierList[i].setN(indexList.at(1));
-               plotModifierList[i].setP(indexList.at(2));
-
-               QList<int> samplingList;
-               for (int k = 0, l = samplingCheckBoxList.size(); k < l; k++) {
-                       samplingList.append(samplingCheckBoxList[k]->isChecked() 
-                                       ? samplingSpinBoxList[k]->value() : -1);
+               if (hasIndexArray[2]) {
+                       plotModifierList[i].setP(indexArray[2]);
                }
-               plotModifierList[i].setPointIncrement(samplingList.at(0));
-               plotModifierList[i].setStartPoint(samplingList.at(1));
-               plotModifierList[i].setEndPoint(samplingList.at(2));
-               plotModifierList[i].setBlockIncrement(samplingList.at(3));
-               plotModifierList[i].setStartBlock(samplingList.at(4));
-               plotModifierList[i].setEndBlock(samplingList.at(5));
 
-               plotModifierList[i].setSmooth(interpCheckBox->isChecked() ? 
-                               interpComboBox->currentIndex() : -1);
+               if (hasSamplingArray[0]) {
+                       plotModifierList[i].setPointIncrement(samplingArray[0]);
+               }
+               if (hasSamplingArray[1]) {
+                       plotModifierList[i].setStartPoint(samplingArray[1]);
+               }
+               if (hasSamplingArray[2]) {
+                       plotModifierList[i].setEndPoint(samplingArray[2]);
+               }
+               if (hasSamplingArray[3]) {
+                       plotModifierList[i].setBlockIncrement(samplingArray[3]);
+               }
+               if (hasSamplingArray[4]) {
+                       plotModifierList[i].setStartBlock(samplingArray[4]);
+               }
+               if (hasSamplingArray[5]) {
+                       plotModifierList[i].setEndBlock(samplingArray[5]);
+               }
+
+               if (hasSmooth) {
+                       plotModifierList[i].setSmooth(smooth);
+               }
 
                for (int k = 0; k < AXIS_NUM; k++) {
-                       plotModifierList[i].setEntry(k, columnCheckBox[k]->isChecked()
-                                       ? columnLineEdit[k]->text() : "");
+                       if (hasEntryArray[k]) {
+                               plotModifierList[i].setEntry(k, entryArray[k]);
+                       }
+               }
+               if (hasFormat) {
+                       plotModifierList[i].setFormat(format);
                }
-               plotModifierList[i].setFormat(formatCheckBox->isChecked()
-                               ? formatLineEdit->text() : "");
        }
 }