From: <fic...@gm...> - 2006-12-04 18:39:55
|
Hello everyone, I tried to find another simple example for loading z-values, but I didn't find one. It would be great if someone would be so kind to mail a small example, that creates a plot just like the one in the "simple plot"-example, but with precomputed z-values. I'm also not sure which subclass of Plot3D is best for this purpose. The background of my question is, that I'm using the CImg-library (maybe someone knows this lib) for the image processing algorithms and I want to display some 2D image data as 3D plots. Here is an extract of what I tried so far (I used a lot of the simpleplot example here): The header file: #ifndef FSURFACEPLOT_H_ #define FSURFACEPLOT_H_ #include <math.h> #include <qapplication.h> #include <qwt3d_surfaceplot.h> #include <qwt3d_function.h> #include "CImg.h" using namespace Qwt3D; class FSurfacePlot : public SurfacePlot { public: FSurfacePlot(cimg_library::CImg<>& data); }; #endif And the source file: #include "FSurfacePlot.h" FSurfacePlot::FSurfacePlot(cimg_library::CImg<>& data) { setTitle("Time-space image"); int columns = data.dimx(); int rows = data.dimy(); double** newdata = new double* [columns]; for( int i = 0; i < columns; ++i) newdata[i] = new double[rows]; for(int i = 0; i < columns; i++) { for(int j = 0; j < rows; j++) { newdata[i][j] = data(i,j); } } loadFromData(newdata,columns,rows,1,columns,1,rows); setRotation(30,0,15); setScale(1,1,1); setShift(0.15,0,0); setZoom(0.9); for (unsigned i=0; i!=coordinates()->axes.size(); ++i) { coordinates()->axes[i].setMajors(7); coordinates()->axes[i].setMinors(4); } coordinates()->axes[X1].setLabelString("x-axis"); coordinates()->axes[Y1].setLabelString("y-axis"); //coordinates()->axes[Z1].setLabelString(QChar(0x38f)); // Omega - see http://www.unicode.org/charts/ setCoordinateStyle(BOX); updateData(); updateGL(); } Everything compiles without errors, but when the widget is shown, I just see a black window with a wireframe box, whose colors are changing in a weird way. Maybe you can tell me, where I'm thinking wrong or give me some other clues!? Best regards! Florian |
From: Micha B. <kri...@us...> - 2006-12-04 23:37:06
|
Doesn't look too alien to me. Could you provide your 'data' field in order to reproduce the error? No unexpected (uninitialized, big, small) z-values or extreme different scales between axes? What system (OS, Qt version, etc.) are you using? Micha --=20 |
From: <fic...@gm...> - 2006-12-05 21:32:44
|
The data field is calculated by some complex algebraic algorithms, but just for testing issues: Setting line 17 e.g. to newdata[i][j] = (double)(i*j); results in this output: http://students.informatik.uni-luebeck.de/~muellefl/unknown1.jpg So that it seems, (at least for me) that it's not a data dependent problem. I'm using a Windows system with Qt 4.2.1, developing in Eclipse with CDT (i.e. compiling with MinGW). Flo Micha Bieber schrieb: > Doesn't look too alien to me. Could you provide your 'data' field in > order to reproduce the error? No unexpected (uninitialized, big, small) > z-values or extreme different scales between axes? > What system (OS, Qt version, etc.) are you using? > > Micha > |
From: Micha B. <kri...@us...> - 2006-12-05 23:07:40
|
Tuesday, December 5, 2006, 22:32:33, Florian M=FCller wrote: > The data field is calculated by some complex algebraic algorithms, but > just for testing issues: Setting line 17 e.g. to > newdata[i][j] =3D (double)(i*j); > results in this output: > http://students.informatik.uni-luebeck.de/~muellefl/unknown1.jpg Unfortunately, I cannot see your row and column values. If I modify your = source int columns =3D 40; int rows =3D 50; I can see a similar picture (not twisted to the degree of your example). Try to rotate it with your left mouse button and scale with your wheel. I think, you will see something nicer than. Not actually the solution, though. > So that it seems, (at least for me) that it's not a data dependent prob= lem. It is in this example, because the z maxima climbs up to 2000 and the aspect ratio of the poor thing turns from worse into ugly. You can control it with Plot3D's scaling properties (also independent for all three dimensions). The tic lines probably require some manual adaption in such cases, but you have access to all of the 12 axes in order to adjust them. Another possibility is to pre-scale your data befor feeding them into loadFromData. > I'm using a Windows system with Qt 4.2.1, developing in Eclipse with CD= T > (i.e. compiling with MinGW). Unfortunately I never tested it against this system. I hold a commercial Qt license on Windows and don't bother there with g++ (probably I should, for Qt4). BTW, the compiler option adheres to Visual C++, so you can safely delete them. I've used Qt4.2.2 + Visual Studio + qwtplot3d0.2.6 for this. Micha =20 --=20 |
From: <fic...@gm...> - 2006-12-05 21:40:04
|
I have just seen that there's a compiler warning: g++: unrecognized option `-GX' I'm not sure, if this could be the problem? Regards Flo Micha Bieber schrieb: > Doesn't look too alien to me. Could you provide your 'data' field in > order to reproduce the error? No unexpected (uninitialized, big, small) > z-values or extreme different scales between axes? > What system (OS, Qt version, etc.) are you using? > > Micha > -- Florian Müller, Lübeck |