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.
Laurent Montel [Mon, 23 Oct 2006 08:12:44 +0000 (08:12 +0000)]
Apply Alex patch (now we can use enable-final argument
some module compiles with enable-final now)
As discussed with Alex it's not necessary to have program name
into automoc macro
Carsten Niehaus [Tue, 17 Oct 2006 16:14:32 +0000 (16:14 +0000)]
I needed to introduce this new ctor because I am using a KPlotWidget in a .ui file in Kalzium (see Revision 596474). The uic always uses Foo(QWidget*) and you cannot change this. Therefor I need a KPlotWidget(QWidget*)-ctor. Another solution would be to change the order of the arguements so that the QWidget = 0 would be at the first position. I would of course prefere that solution as it would remove this stupid second ctor.
Laurent Montel [Fri, 13 Oct 2006 07:58:31 +0000 (07:58 +0000)]
Necessary to change KDE4_AUTOMOC macro to support
enable-final argument
(there was not a dependancy between <name>_final.cpp file and
moc generated files => moc files were never created)
Not necessary to rebuild all kdelibs just cp kdelibs/cmake/modules/KDE4Macros.cmake <path_kde4>/share/apps/cmake/modules
I ported and tested all kde module (without enable-final argument, it compiles fines (test and program))
Don't try to use enable-final argument for the moment it doesn't compile (but dependancy works)
Jason Harris [Fri, 15 Sep 2006 21:45:57 +0000 (21:45 +0000)]
Fixed crash condition in ExtDate::fromString(QString, QDateFormat).
When using the TextFormat QDateFormat, the code creates a QStringList
from the space-separated fields of the input string, but it then assumed
that the stringlist contains at least three members, which caused a
crash when this was not the case. Now, it will return an invalid
ExtDate if the stringlist contains fewer than three members.
Jason Harris [Wed, 6 Sep 2006 14:17:11 +0000 (14:17 +0000)]
Cleanup KPlotWidget
KPlotWidget:
- added setAntialias(bool), set to true for smoother (but slower)
plots
- removed explicit double-buffering (Qt4 does this automatically)
- added top and right axes (by default, they show the same tickmarks
as bottom and left)
- added optional secondary data limits for showing alternate
set of tickmarks on top and right axes.
- removed setShowTickMarks() / setShowTickLabels()...each axis now
handles its own visibility logic.
KPlotAxis:
- each axis now calculates its own tickmark positions (rather
than KPlotWidget)
- rather than setting the number of tickmarks and distance between
them, the tickmark positions are now stored in a QList<double>
- simplified visibility logic:
+ isVisible() : draw axis and tickmarks ?
+ showTickLabels() : obvious
+ the axis label is drawn if it is not empty
- added new ticklabel format 't', which indicates that the ticklabel
values are decimal hours, and should be rendered with a clock-time
format ("hh:mm"). Other special format flags are possible.
I didn't have to modify kalzium or ktouch, so the API hasn't
changed too much. Most of the changes are "under the hood".
I also didn't look at kmathtool, since they have their own copy
of KPlotWidget in the playground. I'll let them decide if and when
to use this version.
Benoît Jacob [Tue, 25 Jul 2006 14:24:47 +0000 (14:24 +0000)]
Change some things in the way OpenGL selection is done
It now happens on button press, instead of happening on button release.
The clicked atom is highlighted in a separate color (currently some
shade of purple, tell me what you think) even if it is not selected. The
point of that is that this clicked atom is going to play a very
important role in the mouse navigation system I plan to write. Any
rotation/move will be done with respect to it. So I thought that this
special role of this atom should correspond to a visual highlighting.
M kalzium/src/kalziumglwidget.h
M kalzium/src/kalziumglwidget.cpp
Benoît Jacob [Tue, 25 Jul 2006 13:18:32 +0000 (13:18 +0000)]
Added OpenGL selection code.
Single left click on an atom now selects/deselects it, if the mouse
didn't move between button press and button release. Some tolerance (2
pixels) added to make that usable with imprecise pointing devices.
TODO: notify the treeview (currently it doesn't get updated).
M kalzium/src/kalziumglwidget.h
M kalzium/src/kalziumglhelperclasses.h
M kalzium/src/kalziumglwidget.cpp
M kalzium/src/kalziumglhelperclasses.cpp