Bug 252874 - Change Data File creates too many dependents
Summary: Change Data File creates too many dependents
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 2.0.1
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: 2.0.1
Assignee: Netterfield
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-30 16:24 UTC by Nicolas Brisset
Modified: 2010-11-12 10:37 UTC (History)
1 user (show)

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 Nicolas Brisset 2010-09-30 16:24:35 UTC
Version:           2.0.1
OS:                Linux

Using the Tools->Change Data File tool, it should be possible to substitute the current data with data coming from another file (seems to work), but also and more interestingly to duplicate all curves depending on those data.
An example will surely be clearer...

Suppose you have vectors Y1, Y2, Y3 and X in data1.dat, and the same vectors in data2.dat from the same experiments conducted under slightly different conditions. You want to compare the two. 
- you load the vectors from data1.dat and create 3 curves (Y1 vs X, Y2 vs X, Y3 vs X). So far, so good. 
- now, you'd like to compare with results in data2.dat => you fire up the "Change Data File" tool and select all vectors from data1.dat, then check "duplicate selected vectors and matrices" and "Duplicate dependents" to also get the new curves, not just the new vectors.
- hit apply: the vectors are duplicated correctly, but you also get a load of new curves: Y1 vs X', Y1' vs X, Y1' vs X' and the same for the other vectors. That's way too much!

The code is not completely trivial, so I'm not yet sure what it exactly does. But what I think it should do is:
1) replace or duplicate all selected vectors and matrices - if duplicating, store the correspondence between old and new (QMap<DataVectorPtr, DataVectorPtr> duplicatedVectors; seems unused, maybe that's what it's for?) 
2) only when done treating primitive objects (vectors, matrices), and if duplicating dependents call duplicateDependents(), passing it the list of substitutions to perform
3) for each relation, iterate over its inputs
  3.1) for each input check whether it has been duplicated
    3.1.1) if the input has been duplicated, and the relation not yet => duplicate the relation and substitute that input with the new one
    3.1.2) if the input has been duplicated and the relation as well already => just substitute the input
4) add the substituted relations to plots ("render items")
5) call update()

This way, I think we cover all cases cleanly. In the example above, each curve would be duplicated only once and it would even be possible to plot the new Y' vectors against the old X (by not selecting X in the list).

Reproducible: Always
Comment 1 Nicolas Brisset 2010-10-01 00:16:31 UTC
SVN commit 1181400 by brisset:

Start fixing the change data file bug. Not 100% complete yet. It works
for curves at least, but has to be checked for data objects. Matrices
not handled yet. Also fix some small issues along the way, and change
one UI string...

I'd appreciate if someone could check the changes because it is
definitely more complex than what I've done up to now. The areas I'm
particularly worried about are:
- the locks I added (because relation.h I think mentioned that when
calling inputVectors() it was required): are they OK?
- the casts (kst_cast<T>()), which cost me most of the time it took to
make the changes!

CCBUG: 252874


 M  +34 -42    changefiledialog.cpp  
 M  +1 -2      changefiledialog.h  
 M  +1 -1      changefiledialog.ui  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1181400
Comment 2 Netterfield 2010-10-15 02:38:05 UTC
I have been working on this - and its taking far longer than I had hoped!

Mostly, it has been difficult due to some issues with the overall inheritance structure of primitives and data objects in kst.  I am in the process of fixing them, at which time this problem will become trivial(ish).
Comment 3 Nicolas Brisset 2010-10-15 07:55:51 UTC
OK, nice to know that you're looking into it. I asked you for help because I had the feeling that it was not so trivial indeed...
Comment 4 Netterfield 2010-10-21 01:58:03 UTC
SVN commit 1187994 by netterfield:

BUG: 252874

Refactor objects to provide the tools needed to do bulk modifications to objects.
Then fix the change file dialog.  It is pretty likely that there are new and exciting bugs in the
dialog, as there are more corner cases than you can shake a stick at here... So please test and
open new reports with what you find.

Oh, and there are binary incompatible changes here to libkst, so people will have to completely re-build
everything.




 M  +3 -0      devel-docs/Kst2Specs/Bugs  
 M  +56 -43    src/libkst/datamatrix.cpp  
 M  +6 -4      src/libkst/datamatrix.h  
 M  +44 -25    src/libkst/dataprimitive.cpp  
 M  +13 -8     src/libkst/dataprimitive.h  
 M  +41 -31    src/libkst/datascalar.cpp  
 M  +6 -4      src/libkst/datascalar.h  
 M  +44 -30    src/libkst/datastring.cpp  
 M  +6 -4      src/libkst/datastring.h  
 M  +73 -64    src/libkst/datavector.cpp  
 M  +5 -4      src/libkst/datavector.h  
 M  +31 -5     src/libkst/matrix.cpp  
 M  +13 -8     src/libkst/matrix.h  
 M  +0 -62     src/libkst/objectstore.cpp  
 M  +4 -0      src/libkst/primitive.cpp  
 M  +20 -1     src/libkst/primitive.h  
 M  +19 -11    src/libkst/vector.cpp  
 M  +10 -10    src/libkst/vector.h  
 M  +14 -2     src/libkst/vscalar.cpp  
 M  +5 -3      src/libkst/vscalar.h  
 M  +128 -137  src/libkstapp/changefiledialog.cpp  
 M  +0 -1      src/libkstapp/changefiledialog.h  
 M  +3 -3      src/libkstapp/choosecolordialog.cpp  
 M  +2 -2      src/libkstapp/commandlineparser.cpp  
 M  +2 -2      src/libkstapp/matrixdialog.cpp  
 M  +6 -6      src/libkstapp/scalardialog.cpp  
 M  +3 -3      src/libkstapp/stringdialog.cpp  
 M  +3 -3      src/libkstapp/vectordialog.cpp  
 M  +1 -1      src/libkstmath/basicplugin.cpp  
 M  +1 -1      src/libkstmath/basicplugin.h  
 M  +1 -1      src/libkstmath/csd.cpp  
 M  +1 -1      src/libkstmath/csd.h  
 M  +1 -2      src/libkstmath/curve.cpp  
 M  +2 -1      src/libkstmath/curve.h  
 M  +112 -244  src/libkstmath/dataobject.cpp  
 M  +6 -8      src/libkstmath/dataobject.h  
 M  +31 -96    src/libkstmath/equation.cpp  
 M  +4 -6      src/libkstmath/equation.h  
 M  +1 -78     src/libkstmath/eventmonitorentry.cpp  
 M  +1 -6      src/libkstmath/eventmonitorentry.h  
 M  +3 -0      src/libkstmath/fftsg_h.c  
 M  +1 -1      src/libkstmath/histogram.cpp  
 M  +1 -1      src/libkstmath/histogram.h  
 M  +1 -2      src/libkstmath/image.cpp  
 M  +1 -1      src/libkstmath/image.h  
 M  +1 -1      src/libkstmath/psd.cpp  
 M  +1 -1      src/libkstmath/psd.h  
 M  +38 -96    src/libkstmath/relation.cpp  
 M  +5 -4      src/libkstmath/relation.h  
 M  +1 -1      src/widgets/curveselector.cpp  
 M  +2 -2      src/widgets/dialogdefaults.cpp  
 M  +4 -4      src/widgets/gradienteditor.cpp  
 M  +1 -1      src/widgets/matrixselector.cpp  
 M  +1 -1      src/widgets/stringselector.cpp  
 M  +1 -1      src/widgets/vectorselector.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1187994
Comment 5 Nicolas Brisset 2010-10-21 09:51:04 UTC
Wow, that's a whole lot of changes!
I have just tested it, and there is some improvement. However I have found a small bug, which I'll report separately, so that you have an easy-to-fix one :-)
But at least curves from derived objects are considered now.

Thanks for all the work!
Comment 6 Peter Kümmel 2010-11-12 10:37:15 UTC
There is no version list for "Version Fixed in".
Use Target Milestone as indicator when the bug was fixed.