Pino Toscano [Sat, 17 Feb 2007 12:21:41 +0000 (12:21 +0000)]
API change:
- move all the private members of KPlotObject into a Private class
- make the class non-copiable
- merge the two constructors in one, made explicit
Pino Toscano [Fri, 16 Feb 2007 23:04:51 +0000 (23:04 +0000)]
API changes:
- kill the x()/y()/x2()/y2()/dataWidth()/dataHeight() functions in flavour of a simplier dataRect() that just return the rect. (Note that x() and y() were quite ambiguous.)
- move the data rect and the secondary data rect in the Private class
Pino Toscano [Fri, 16 Feb 2007 20:12:31 +0000 (20:12 +0000)]
API change in the plot objects handling:
- add plotObjects() to get the list of the plot objects (thus removing objectCount() )
- add addPlotObjects() to add more objects with a single update
- add 'Plot' in the name of the other functions that work with the plot objects
- finally hide the real object list in the Private class
Pino Toscano [Fri, 16 Feb 2007 16:12:55 +0000 (16:12 +0000)]
API work on KPlotAxis:
- hide all the private stuff into the Private class
- disable the copy of the class
- merge the two constructors in one, explicit
- remove the 'inline' declarations
Carsten Niehaus [Mon, 27 Nov 2006 14:40:54 +0000 (14:40 +0000)]
Wow, this commit looks huge :)
Technically I am just moving code from A to B. The 3D-Viewer is now
independend of Kalzium, I just need to rename the classes (from
Kalzium* to Compound* I think...). But I wanted to move the code itself
first.
Carsten Niehaus [Sun, 26 Nov 2006 12:35:19 +0000 (12:35 +0000)]
* Ok, I still see no real way to test my KPart-code but this might
work. I will move it to libkdeedu as Kalzium is not using this
code anyway. There, I will code a small mini-demo application
to test the KPart-stuff.
So eventually Konq will be able to display molecules in 3D by
using Kalziums 3D code (which is 99.999% done by Benoit Jacob)
Benoît Jacob [Sun, 26 Nov 2006 12:17:25 +0000 (12:17 +0000)]
- fix compilation against latest OpenBabel (so you need to update your
OpenBabel)
- remove abstract base class VertexArray, remove virtual stuff in
Sphere and Cylinder. That doesn't increase speed, because anyway we
use OpenGL displaylist caching, but that makes the source code easier
to read.
Benoît Jacob [Fri, 17 Nov 2006 08:42:01 +0000 (08:42 +0000)]
Twofold improvement in Kalzium's 3D viewer:
- automatically set up nice viewpoint when loading a molecule.
- draw multiple bonds with "intelligent" orientation, so that they
avoid looking like single bonds.
Both improvements rely on Eigen's linear regression feature.
Jason Harris [Sun, 29 Oct 2006 21:31:43 +0000 (21:31 +0000)]
Draw a line from a data point to its label if the label is not
very near the point. When a line is drawn, it also draws a
rounded rectangle around the label text.
Jason Harris [Sun, 29 Oct 2006 03:25:34 +0000 (03:25 +0000)]
Implementing non-colliding text labels in kdeeduplot, based on kmplot
code.
It works, but it could probably be faster. You don't need to know
anything about it to use the feature, it all happens behind the scenes.
Just add some items with labels and enjoy the magic.
However, in the interest of inspiring optimization, here's a brief
description of how it works:
KPlotWidget now has a private array of floats: PlotMask[100][100].
This is a rough division of the content of the plot into a 100x100
grid. Where the plot is empty, the array is zero, where it has content,
it is >0. When items are added to the plot (points, lines, bars, or
labels), the corresponding positions in PlotMask are incremented by an
amount that can vary for different kinds of items (for example, right
now Bars don't increment as much as points or lines).
The function KPlotWidget::placeLabel() is responsible for positioning
item labels. It attempts to place the label close to the point to
which it belongs, while minimizing the label's overlap with masked
regions of the plot. Ideally, it won't overlap with masked regions at
all. This is done in a rather brute-force way: it tests label
positions in a 40x40 grid around the position of the point, and
determines the "cost" for placing the label at each position. Higher
cost is incurred for (a) overlapping with a masked region, (b) being
further from the point position, and (c) extending beyond the bounds
of the plot. The position that has the lowest "cost" is then adopted,
and the label is drawn at that position.
You can get an idea of the CPU impact of this cost-analysis using
the test suite I added to kdeeduplot. Display the "Points, lines
and bars" plot, and then resize the window. Note the smoothness of
the redraws. Now display "Points, lines and bars with labels" and
resize the window. The redraws take much longer in this case.
Jason Harris [Sat, 28 Oct 2006 00:04:44 +0000 (00:04 +0000)]
Internal changes to libkdeeduplot in preparation for implementing
non-colliding labels. Basically, I was looking at the code and
saw several things that needed to be improved.
+ Added a "BARS" type for KPlotObject, and removed the "POLYGON"
type. "CURVES" type is now called "LINES".
+ A single KPlotObject can now be any combination of POINTS,
LINES, and BARS. These enum items have bitmask values (1,2,4),
so you should be able to OR them together in the ctor, but I
haven't gotten that to work yet. Instead you can set it to one
type in the ctor, and use the
setShowPoints(bool)/setShowLines(bool)/setShowBars(bool)
convenience functions.
+ There are many more point shapes available now: CIRCLE, LETTER,
TRIANGLE, SQUARE, PENTAGON, HEXAGON, ASTERISK, and STAR
+ Plot objects no longer have a Name property. It's unnecessary with
the new labeling scheme.
+ There is no longer a LABEL object type. Instead, you can
define a label for any data point by adding a string argument to
addPoint(), like so:
+ There is no longer an enum for specifying line styles.
Instead, you can now define QPens and QBrushes for drawing
points, lines and bars. This is much more flexible.
+ renamed mapToPoint() to toScreen()
+ I added a "tests" subdirectory which demonstrates the library.
Please have a look.
TODO: It looks like drawing an axis using secondary data limits
is not working. The "Lines" demo in the tests directory should
show the angle in degrees along the top axis (the angle is shown
in radians on the bottom axis).
As I said, I haven't gotten the KPlotObject ctor to accept multiple PlotType values. i.e., this works:
I checked to see that the kdeedu module compiles with these changes
(other than kstars changes, I only had to make a few modifications to
kalzium/src/elementdataviewer.cpp and ktouch/src/ktouchstatistics.cpp;
check it out, I think you'll like the new API)
Jason Harris [Wed, 25 Oct 2006 01:17:21 +0000 (01:17 +0000)]
Convert plotting data to floating-point variants (QPoint-->QPointF,
QPolygon-->QPolygonF, etc). Moved mapToPoint() definition from
kplotwidget.h to kplotwidget.cpp.