[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Thu Nov 17 15:49:03 CET 2005


SVN commit 481024 by staikos:

some cleanup related to 116488


 M  +46 -54    kstfitdialog_i.cpp  


--- trunk/extragear/graphics/kst/kst/kstfitdialog_i.cpp #481023:481024
@@ -125,13 +125,7 @@
 bool KstFitDialogI::createCurve(KstPluginPtr plugin) {
   KstVectorPtr xVector;
   KstVectorPtr yVector;
-  KstVectorPtr wVector;
-  KstVCurvePtr fit;
-  QString strLabel;
-  bool bRetVal = false;
 
-  QString c_name = KST::suggestCurveName(plugin->tagName(), true);
-
   if (plugin->inputVectors().contains("X Array")) {
     xVector = plugin->inputVectors()["X Array"];
   }
@@ -139,65 +133,63 @@
     yVector = plugin->outputVectors()["Y Fitted"];
   }
 
-  if (xVector && yVector) {
-    fit = new KstVCurve(c_name, KstVectorPtr(xVector), KstVectorPtr(yVector), KstVectorPtr(0L), KstVectorPtr(0L), KstVectorPtr(0L), KstVectorPtr(0L), _w->_curveAppearance->color());
-    if (fit) {
-      fit->setHasPoints(_w->_curveAppearance->showPoints());
-      fit->setHasLines(_w->_curveAppearance->showLines());
-      fit->setHasBars(_w->_curveAppearance->showBars());
-      fit->setLineWidth(_w->_curveAppearance->lineWidth());
-      fit->setLineStyle(_w->_curveAppearance->lineStyle());
-      fit->Point.setType(_w->_curveAppearance->pointType());
-      fit->setBarStyle(_w->_curveAppearance->barStyle());
-      fit->setPointDensity(_w->_curveAppearance->pointDensity());
+  if (!xVector || !yVector) {
+    return false;
+  }
 
-      strLabel = i18n("curvename: pluginname\\n", "%2: %1\\n").
-                 arg(_strCurve.replace( '_',  "\\_" ).remove( QRegExp( "^[C][0-9]{1,2}\\-" ) )).
-                 arg(plugin->plugin()->data()._readableName);
+  QString c_name = KST::suggestCurveName(plugin->tagName(), true);
 
-      KstVectorPtr vectorParam = plugin->outputVectors()["Parameters"];
-      if (vectorParam) {
-        plugin->createFitScalars();
-        int i;
-        QString strParamName;
-        for (i = 0, strParamName = plugin->plugin()->parameterName(0); !strParamName.isEmpty(); strParamName = plugin->plugin()->parameterName(++i)) {
-          if (!strParamName.isEmpty()) {
-            if (plugin->outputScalars().contains(strParamName)) {
-              KstScalarPtr scalar = plugin->outputScalars()[strParamName];
+  KstVCurvePtr fit = new KstVCurve(c_name, KstVectorPtr(xVector), KstVectorPtr(yVector), KstVectorPtr(0L), KstVectorPtr(0L), KstVectorPtr(0L), KstVectorPtr(0L), _w->_curveAppearance->color());
+  fit->setHasPoints(_w->_curveAppearance->showPoints());
+  fit->setHasLines(_w->_curveAppearance->showLines());
+  fit->setHasBars(_w->_curveAppearance->showBars());
+  fit->setLineWidth(_w->_curveAppearance->lineWidth());
+  fit->setLineStyle(_w->_curveAppearance->lineStyle());
+  fit->Point.setType(_w->_curveAppearance->pointType());
+  fit->setBarStyle(_w->_curveAppearance->barStyle());
+  fit->setPointDensity(_w->_curveAppearance->pointDensity());
 
-              if (scalar) {
-                strLabel += i18n("parametername: [scalarname]\\n", "%1: [%2]\\n").arg(strParamName).arg(scalar->tagName());
-              }
-            }
+  QString strLabel = i18n("curvename: pluginname\\n", "%2: %1\\n").
+    arg(_strCurve.replace('_', "\\_").remove(QRegExp("^[C][0-9]{1,2}\\-"))).
+    arg(plugin->plugin()->data()._readableName);
+
+  if (plugin->outputVectors().contains("Parameters")) {
+    plugin->createFitScalars();
+    int i = 0;
+    QString strParamName;
+    for (strParamName = plugin->plugin()->parameterName(0); !strParamName.isEmpty(); strParamName = plugin->plugin()->parameterName(++i)) {
+      if (!strParamName.isEmpty()) {
+        if (plugin->outputScalars().contains(strParamName)) {
+          KstScalarPtr scalar = plugin->outputScalars()[strParamName];
+          if (scalar) {
+            strLabel += i18n("parametername: [scalarname]\\n", "%1: [%2]\\n").arg(strParamName).arg(scalar->tagName());
           }
         }
       }
+    }
+  }
 
-      // add the label and the curve to the plot
-      KstViewWindow *w = dynamic_cast<KstViewWindow*>(KstApp::inst()->findWindow(_strWindow));
-      if (w && w->view()->findChild(_strPlotName)) {
-        Kst2DPlotPtr plot = kst_cast<Kst2DPlot>(w->view()->findChild(_strPlotName));
-        if (plot) {
-          KstViewLabelPtr label = new KstViewLabel(strLabel, KST_JUSTIFY_H_LEFT | KST_JUSTIFY_V_TOP, 0.0);
-          label->setTransparent(true);
-          plot->appendChild(KstViewObjectPtr(label), true);
-          label->resizeFromAspect(0.1, 0.1, 0.05, 0.05);
-          label->setJustification(SET_KST_JUSTIFY(KST_JUSTIFY_H_LEFT, KST_JUSTIFY_V_BOTTOM));
-          label->setAutoResize(true);
+  // add the label and the curve to the plot
+  KstViewWindow *w = dynamic_cast<KstViewWindow*>(KstApp::inst()->findWindow(_strWindow));
+  if (w && w->view()->findChild(_strPlotName)) {
+    Kst2DPlotPtr plot = kst_cast<Kst2DPlot>(w->view()->findChild(_strPlotName));
+    if (plot) {
+      KstViewLabelPtr label = new KstViewLabel(strLabel, KST_JUSTIFY_H_LEFT | KST_JUSTIFY_V_TOP, 0.0);
+      label->setTransparent(true);
+      plot->appendChild(KstViewObjectPtr(label), true);
+      label->resizeFromAspect(0.1, 0.1, 0.05, 0.05);
+      label->setJustification(SET_KST_JUSTIFY(KST_JUSTIFY_H_LEFT, KST_JUSTIFY_V_BOTTOM));
+      label->setAutoResize(true);
 
-          plot->addCurve(KstBaseCurvePtr(fit));
-        }
-      }
-
-      KST::dataObjectList.lock().writeLock();
-      KST::dataObjectList.append(fit.data());
-      KST::dataObjectList.lock().writeUnlock();
-
-      bRetVal = true;
+      plot->addCurve(KstBaseCurvePtr(fit));
     }
   }
 
-  return bRetVal;
+  KST::dataObjectList.lock().writeLock();
+  KST::dataObjectList.append(fit.data());
+  KST::dataObjectList.lock().writeUnlock();
+
+  return true;
 }
 
 


More information about the Kst mailing list