Version: 1.0.0_devel (using KDE 3.3.0, compiled sources) Compiler: gcc version 3.3.2 OS: SunOS (sun4u) release 5.8 In the new "Tools" category, yet another one... Imagine you have created a number of curves, plots, etc, to investigate experiment A, invoking the datawizard many times. Now, you would like to see whether what you observe also happened in experiment B and compare both. If you change the data file A->B, you get a new window but experiment A is gone and the comparison becomes difficult. You can open a second kst window and switch between windows, but that's not so convenient either. Now, imagine you can invoke a "Tools->Compare with file..." wizard, that does the following: 1) it prompts you for the name of file A among the list of loaded files and allows you to select file B with a standard file selector 2) when you hit "Next", it looks for all vectors from file A currently in memory, and looks for the same vectors in file B. It then shows a list of vectors found, possibly with sample numbers (and checkboxes if you want to disable some) 3) hit "Next" to load the vectors, and it shows a list of curves using them (optionally with checkboxes if you don't want them all) 4) hit "Finish": it will create curves from the new file and add them automatically to the plots where they belong. Nice, isn't it ? If it's too complicated, a stripped down version could be as simple as a dialog implementing only step 1 and trying its best to create all curves from vectors read in the new file. That would actually probably be enough and a good start, as more subtle changes can always be done with the datawizard. By the way, such a tool would probably also obsolete the need to be able to work with more than one file in the datawizard as I expressed long ago :-)
Actually, after thinking some more about this need, I believe this can be achieved using a variation of the current "Change data file..." tool. The idea is more or less the same: load data from another file, plotting the same curves for comparison purposes. Instead of replacing all selected vectors as is currently the case, there could be two radiobuttons "Add vectors" and "Replace vectors" added in the dialog. "Replace vectors" would do exactly what it does now, while "Add" would duplicate selected vectors and their dependencies (plugins, equations, etc) but with vector contents coming from the new file. I have no idea how complicated this would be to implement, but it would be extremely useful. If the feature existed, I would have used it a number of times already, instead of going copy&paste in the .kst file :-)
I have had to do this again manually (compare two data files with some rather complex plots and equation/plugin dependencies), and it would have been _REALLY_ great if there had been this option in the "change data file..." tool (which would obviously need to be renamed to "load data from new file..." or something of the kind). Once again, I don't know how complicated it would be to implement this with the whole dependency walking, but the functionality is *extremely useful* ! I hope someone tackles this soon :-)
I will add a duplicateDependents function to KstDataObject which will duplicate all dependents of the data object. Pure virtual functions replaceDependency and makeDuplicate will be added as well to replace a dependency with a new data object and make a duplicate of the object respectively. The last 2 functions are needed because I plan to maintain a map of old objects to new objects in the new_i function of the change file dialog to keep track of items which have been duplicated (in which case only dependencies should be altered).
Going to implement copy constructors for all data objects (unless there is a better way?)
On Thursday 23 June 2005 20:48, Rick Chern wrote: > 02:47 ------- Going to implement copy constructors for all data objects > (unless there is a better way?) It seems to make sense but I'm not convinced of the usage pattern. It requires something to the effect of: KstDataObjectFooPtr x = new KstDataObjectFoo(*fooToCopy); I'm thinking it would be clearer to have: KstDataObjectFooPtr x = fooToCopy->duplicate(); would be better. Several reasons: 1) Implementing the copy constructor basically means we have to implement the assignment operator, otherwise we get inconsistent behavior. 2) The copy constructor has to copy -everything-, whereas duplicate() can be defined to create a new object and populate it only with what is needed. 3) Shared objects are really pointers, so using them by value and copying is really unusual and potentially dangerous. 4) The idea of implicit copies of these things really scares me. I actually think we should explicitly disable the copy constructor for safety reasons in KstObject. I think the new dependents functions you mentioned are fine, but they probably don't need to be virtual. I'm going to do a virtual table cleanup at some point because we have too many we don't need and it's making things big and slow. If they absolutely need to be virtual though, go ahead. I might have missed something...
SVN commit 429527 by rchern: Basic support for duplicating vectors and dependencies when changing files - no support for matrices and images yet, but will be supported once matrices are reworked and data objects have _inputMatrices - still need to implement more support for equations and events, as they have more dependencies than just _inputVectors, _inputScalars, and _inputStrings CCMAIL: 91692@bugs.kde.org M +242 -155 changefiledialog.ui M +27 -3 kstchangefiledialog_i.cpp M +8 -0 kstcsd.cpp M +2 -0 kstcsd.h M +1 -0 kstcurvehint.h M +93 -0 kstdataobject.cpp M +13 -4 kstdataobject.h M +8 -0 kstequation.cpp M +2 -0 kstequation.h M +16 -0 ksteventmonitorentry.cpp M +2 -0 ksteventmonitorentry.h M +10 -0 ksthistogram.cpp M +2 -0 ksthistogram.h M +13 -0 kstimage.cpp M +2 -0 kstimage.h M +6 -0 kstmatrix.cpp M +2 -0 kstmatrix.h M +50 -0 kstplugin.cpp M +2 -0 kstplugin.h M +8 -0 kstpsd.cpp M +2 -0 kstpsd.h M +6 -0 kstrvector.cpp M +4 -0 kstrvector.h M +24 -0 kstvcurve.cpp M +2 -0 kstvcurve.h M +30 -0 kstvector.cpp M +5 -0 kstvector.h
SVN commit 429788 by rchern: Add duplicated curves to plots as well CCMAIL: 91692-done@bugs.kde.org M +28 -1 kstchangefiledialog_i.cpp M +2 -1 kstvcurve.cpp --- trunk/extragear/graphics/kst/kst/kstchangefiledialog_i.cpp #429787:429788 @@ -32,6 +32,7 @@ #include "kstdatacollection.h" #include "kstrvector.h" #include "kstvectordefaults.h" +#include "kstviewwindow.h" KstChangeFileDialogI::KstChangeFileDialogI(QWidget* parent, const char* name, @@ -200,13 +201,39 @@ app->slotUpdateProgress(selected, ++handled, i18n("Updating vectors...")); } } - + app->slotUpdateProgress(0, 0, QString::null); file->writeUnlock(); file = 0L; + // now add any curves to plots if they were duplicated + if (_duplicateSelected->isChecked() && _duplicateDependents->isChecked()) { + for (QMap<KstDataObjectPtr, KstDataObjectPtr>::Iterator iter = duplicatedMap.begin(); iter != duplicatedMap.end(); ++iter) { + if (KstBaseCurvePtr curve = kst_cast<KstBaseCurve>(iter.data())) { + KstApp *app = KstApp::inst(); + KMdiIterator<KMdiChildView*> *it = app->createIterator(); + while (it->currentItem()) { + KstViewWindow *w = dynamic_cast<KstViewWindow*>(it->currentItem()); + if (w) { + KstTopLevelViewPtr view = kst_cast<KstTopLevelView>(w->view()); + if (view) { + Kst2DPlotList plots = view->findChildrenType<Kst2DPlot>(true); + for (Kst2DPlotList::Iterator plotIter = plots.begin(); plotIter != plots.end(); ++plotIter) { + if ((*plotIter)->Curves.contains(kst_cast<KstBaseCurve>(iter.key()))) { + (*plotIter)->addCurve(curve); + } + } + } + } + it->next(); + } + app->deleteIterator(it); + } + } + } + if (!invalidSources.isEmpty()) { if (invalid == 1) { KMessageBox::sorry(this, i18n("The following field is not defined for the requested file:\n%1").arg(invalidSources)); --- trunk/extragear/graphics/kst/kst/kstvcurve.cpp #429787:429788 @@ -567,8 +567,9 @@ vcurve->setLineStyle(LineStyle); vcurve->setPointDensity(PointDensity); - duplicatedMap.insert(this, KstDataObjectPtr(vcurve)); + duplicatedMap.insert(this, KstDataObjectPtr(vcurve)); return KstDataObjectPtr(vcurve); } + // vim: ts=2 sw=2 et