~valavanisalex/ubuntu/maverick/scidavis/fix-604811

« back to all changes in this revision

Viewing changes to scidavis/src/Graph3D.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ruben Molina
  • Date: 2009-09-06 11:34:04 UTC
  • Revision ID: james.westby@ubuntu.com-20090906113404-4awaey82l3686w4q
Tags: upstream-0.2.3
ImportĀ upstreamĀ versionĀ 0.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
    File                 : Graph3D.cpp
 
3
    Project              : SciDAVis
 
4
    --------------------------------------------------------------------
 
5
    Copyright            : (C) 2006 by Ion Vasilief, Tilman Benkert
 
6
    Email (use @ for *)  : ion_vasilief*yahoo.fr, thzs*gmx.net
 
7
    Description          : 3D graph widget
 
8
 
 
9
 ***************************************************************************/
 
10
 
 
11
/***************************************************************************
 
12
 *                                                                         *
 
13
 *  This program is free software; you can redistribute it and/or modify   *
 
14
 *  it under the terms of the GNU General Public License as published by   *
 
15
 *  the Free Software Foundation; either version 2 of the License, or      *
 
16
 *  (at your option) any later version.                                    *
 
17
 *                                                                         *
 
18
 *  This program is distributed in the hope that it will be useful,        *
 
19
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 
20
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 
21
 *  GNU General Public License for more details.                           *
 
22
 *                                                                         *
 
23
 *   You should have received a copy of the GNU General Public License     *
 
24
 *   along with this program; if not, write to the Free Software           *
 
25
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
 
26
 *   Boston, MA  02110-1301  USA                                           *
 
27
 *                                                                         *
 
28
 ***************************************************************************/
 
29
#include "Graph3D.h"
 
30
#include "Bar.h"
 
31
#include "Cone3D.h"
 
32
#include "MyParser.h"
 
33
#include "core/column/Column.h"
 
34
 
 
35
#include <QApplication>
 
36
#include <QMessageBox>
 
37
#include <QFileDialog>
 
38
#include <QPrinter>
 
39
#include <QClipboard>
 
40
#include <QPixmap>
 
41
#include <QBitmap>
 
42
#include <QDateTime>
 
43
#include <QCursor>
 
44
#include <QImageWriter>
 
45
 
 
46
#include <qwt3d_io_gl2ps.h>
 
47
#include <qwt3d_coordsys.h>
 
48
 
 
49
#include <gsl/gsl_vector.h>
 
50
#include <fstream>
 
51
 
 
52
UserFunction::UserFunction(const QString& s, SurfacePlot& pw)
 
53
: Function(pw)
 
54
{
 
55
        formula=s;
 
56
}
 
57
 
 
58
double UserFunction::operator()(double x, double y)
 
59
{
 
60
        if (formula.isEmpty())
 
61
                return 0.0;
 
62
 
 
63
        MyParser parser;
 
64
        double result=0.0;
 
65
        try
 
66
        {
 
67
                parser.DefineVar("x", &x);
 
68
                parser.DefineVar("y", &y);
 
69
 
 
70
                parser.SetExpr((const std::string)formula.toAscii().constData());
 
71
                result=parser.Eval();
 
72
        }
 
73
        catch(mu::ParserError &e)
 
74
        {
 
75
                QMessageBox::critical(0,"Input function error",QString::fromStdString(e.GetMsg()));
 
76
        }
 
77
        return result;
 
78
}
 
79
 
 
80
UserFunction::~UserFunction()
 
81
{
 
82
}
 
83
 
 
84
        Graph3D::Graph3D(const QString& label, QWidget* parent, const char* name, Qt::WFlags f)
 
85
: MyWidget(label,parent,name,f)
 
86
{
 
87
        initPlot();
 
88
}
 
89
 
 
90
void Graph3D::initPlot()
 
91
{
 
92
        worksheet = 0;
 
93
        d_matrix = 0;
 
94
    plotAssociation = QString();
 
95
 
 
96
        QDateTime dt = QDateTime::currentDateTime ();
 
97
        setBirthDate(dt.toString(Qt::LocalDate));
 
98
 
 
99
    color_map = QString::null;
 
100
    animation_redraw_wait = 50;
 
101
    d_timer = new QTimer(this);
 
102
    connect(d_timer, SIGNAL(timeout()), this, SLOT(rotate()) );
 
103
        ignoreFonts = false;
 
104
 
 
105
        sp = new SurfacePlot(this);
 
106
        sp->resize(500,400);
 
107
        sp->installEventFilter(this);
 
108
        sp->setRotation(30,0,15);
 
109
        sp->setScale(1,1,1);
 
110
        sp->setShift(0.15,0,0);
 
111
        sp->setZoom(0.9);
 
112
        sp->setOrtho(false);
 
113
 
 
114
        smoothMesh = true;
 
115
        sp->setSmoothMesh(smoothMesh);
 
116
 
 
117
        d_autoscale = true;
 
118
 
 
119
        title = QString();
 
120
        sp->setTitle(title);
 
121
 
 
122
        titleCol = QColor(Qt::black);
 
123
        sp->setTitleColor(Qt2GL(titleCol));
 
124
 
 
125
        titleFnt = QFont("Times New Roman",14);
 
126
        titleFnt.setBold(true);
 
127
 
 
128
        sp->setTitleFont(titleFnt.family(),titleFnt.pointSize(),
 
129
                        titleFnt.weight(),titleFnt.italic());
 
130
 
 
131
        axesCol=QColor(Qt::black);
 
132
        labelsCol=QColor(Qt::black);
 
133
        numCol=QColor(Qt::black);
 
134
        meshCol=QColor(Qt::black);
 
135
        gridCol=QColor(Qt::black);
 
136
        bgCol=QColor(255, 255, 255);
 
137
        fromColor=QColor(Qt::red);
 
138
        toColor=QColor(Qt::blue);
 
139
 
 
140
        col_ = 0;
 
141
 
 
142
        legendOn = false;
 
143
        legendMajorTicks = 5;
 
144
        sp->showColorLegend(legendOn);
 
145
        sp->legend()->setAutoScale(true);
 
146
        sp->legend()->setMajors (legendMajorTicks) ;
 
147
 
 
148
        labelsDist=0;
 
149
 
 
150
        scaleType=QVector<int>(3);
 
151
        for (int j=0;j<3;j++)
 
152
                scaleType[j]=0;
 
153
 
 
154
        pointStyle = None;
 
155
        func = 0;
 
156
        alpha = 1.0;
 
157
        barsRad = 0.007;
 
158
        pointSize = 5; smooth = false;
 
159
        crossHairRad = 0.03, crossHairLineWidth = 2;
 
160
        crossHairSmooth = true, crossHairBoxed = false;
 
161
        conesQuality = 32; conesRad = 0.5;
 
162
 
 
163
        style_ = NOPLOT;
 
164
        initCoord();
 
165
 
 
166
        connect(sp,SIGNAL(rotationChanged(double, double, double)),this,SLOT(rotationChanged(double, double, double)));
 
167
        connect(sp,SIGNAL(zoomChanged(double)),this,SLOT(zoomChanged(double)));
 
168
        connect(sp,SIGNAL(scaleChanged(double, double, double)),this,SLOT(scaleChanged(double, double, double)));
 
169
        connect(sp,SIGNAL(shiftChanged(double, double, double)),this,SLOT(shiftChanged(double, double, double)));
 
170
}
 
171
 
 
172
void Graph3D::initCoord()
 
173
{
 
174
        sp->makeCurrent();
 
175
        for (unsigned i=0; i!=sp->coordinates()->axes.size(); ++i)
 
176
        {
 
177
                sp->coordinates()->axes[i].setMajors(5);
 
178
                sp->coordinates()->axes[i].setMinors(5);
 
179
        }
 
180
 
 
181
        QString s = tr("X axis");
 
182
        sp->coordinates()->axes[X1].setLabelString(s);
 
183
        sp->coordinates()->axes[X2].setLabelString(s);
 
184
        sp->coordinates()->axes[X3].setLabelString(s);
 
185
        sp->coordinates()->axes[X4].setLabelString(s);
 
186
        labels<<s;
 
187
 
 
188
        s = tr("Y axis");
 
189
        sp->coordinates()->axes[Y1].setLabelString(s);
 
190
        sp->coordinates()->axes[Y2].setLabelString(s);
 
191
        sp->coordinates()->axes[Y3].setLabelString(s);
 
192
        sp->coordinates()->axes[Y4].setLabelString(s);
 
193
        labels<<s;
 
194
 
 
195
        s = tr("Z axis");
 
196
        sp->coordinates()->axes[Z1].setLabelString(s);
 
197
        sp->coordinates()->axes[Z2].setLabelString(s);
 
198
        sp->coordinates()->axes[Z3].setLabelString(s);
 
199
        sp->coordinates()->axes[Z4].setLabelString(s);
 
200
        labels<<s;
 
201
 
 
202
        sp->setCoordinateStyle(BOX);
 
203
        sp->coordinates()->setAutoScale(false);
 
204
}
 
205
 
 
206
void Graph3D::addFunction(const QString& s,double xl,double xr,double yl,
 
207
                double yr,double zl,double zr)
 
208
{
 
209
        sp->makeCurrent();
 
210
        sp->resize(this->size());
 
211
 
 
212
        func= new UserFunction(s, *sp);
 
213
 
 
214
        func->setMesh(41,31);
 
215
        func->setDomain(xl,xr,yl,yr);
 
216
        func->setMinZ(zl);
 
217
        func->setMaxZ(zr);
 
218
        func->create();
 
219
 
 
220
        sp->legend()->setLimits(zl,zr);
 
221
 
 
222
        if (sp->plotStyle() == NOPLOT)
 
223
        {
 
224
                sp->setPlotStyle(FILLED);
 
225
                style_=FILLED;
 
226
                pointStyle = None;
 
227
        }
 
228
        sp->createCoordinateSystem(Triple(xl, yl, zl), Triple(xr, yr, zr));
 
229
        findBestLayout();
 
230
}
 
231
 
 
232
void Graph3D::insertFunction(const QString& s,double xl,double xr,double yl,
 
233
                double yr,double zl,double zr)
 
234
{
 
235
        addFunction(s,xl,xr,yl,yr,zl,zr);
 
236
        update();
 
237
}
 
238
 
 
239
void Graph3D::addData(Table* table, int xcol, int ycol)
 
240
{
 
241
        worksheet=table;
 
242
        int r=table->numRows();
 
243
        int i, xmesh=0, ymesh=2;
 
244
        for (i = 0; i < r; i++)
 
245
        {
 
246
                if (!table->column(xcol)->isInvalid(i) && !table->column(ycol)->isInvalid(i))
 
247
                        xmesh++;
 
248
        }
 
249
 
 
250
        if (xmesh == 0)
 
251
                xmesh++;
 
252
 
 
253
        double **data = Matrix::allocateMatrixData(xmesh, ymesh);
 
254
        gsl_vector * x = gsl_vector_alloc (xmesh);
 
255
        gsl_vector * y = gsl_vector_alloc (xmesh);
 
256
 
 
257
        for (int j = 0; j < ymesh; j++)
 
258
        {
 
259
                int k=0;
 
260
                for (i = 0; i < r; i++)
 
261
                {
 
262
                        if (!table->column(xcol)->isInvalid(i) && !table->column(ycol)->isInvalid(i))
 
263
                        {
 
264
                                gsl_vector_set (x, k, table->cell(i, xcol));
 
265
 
 
266
                                double yv = table->cell(i, ycol);
 
267
                                gsl_vector_set (y, k, yv);
 
268
                                data[k][j] = yv;
 
269
                                k++;
 
270
                        }
 
271
                }
 
272
        }
 
273
 
 
274
        double maxy=gsl_vector_max(y);
 
275
        double maxz=0.6*maxy;
 
276
        sp->makeCurrent();
 
277
        sp->legend()->setLimits(gsl_vector_min(y),maxy);
 
278
        sp->loadFromData(data, xmesh, ymesh, gsl_vector_min(x),gsl_vector_max(x),0,maxz);
 
279
 
 
280
        if (d_autoscale)
 
281
                findBestLayout();
 
282
 
 
283
        gsl_vector_free (x);
 
284
        gsl_vector_free (y);
 
285
        Matrix::freeMatrixData(data, xmesh);
 
286
}
 
287
 
 
288
void Graph3D::addData(Table* table,const QString& colName)
 
289
{
 
290
        int ycol = table->colIndex(colName);
 
291
        int xcol=table->colX(ycol);
 
292
        plotAssociation = table->colName(xcol)+"(X)," + colName + "(Y)";
 
293
 
 
294
        addData(table, xcol, ycol);
 
295
}
 
296
 
 
297
void Graph3D::addData(Table* table,const QString& xColName,const QString& yColName)
 
298
{
 
299
        int xcol=table->colIndex(xColName);
 
300
        plotAssociation = table->colName(xcol)+"(X)," + yColName+"(Y)";
 
301
 
 
302
        addData(table, xcol, table->colIndex(yColName));
 
303
}
 
304
 
 
305
void Graph3D::changeMatrix(Matrix* m)
 
306
{
 
307
        if (d_matrix == m)
 
308
                return;
 
309
 
 
310
        addMatrixData(m);
 
311
}
 
312
 
 
313
void Graph3D::addMatrixData(Matrix* m)
 
314
{
 
315
        if (d_matrix == m)
 
316
                return;
 
317
 
 
318
        bool first_time = false;
 
319
        if(!d_matrix)
 
320
                first_time = true;
 
321
 
 
322
        d_matrix = m;
 
323
        plotAssociation = "matrix<" + QString(m->name()) + ">";
 
324
 
 
325
        int cols = m->numCols();
 
326
        int rows = m->numRows();
 
327
        double **data_matrix = Matrix::allocateMatrixData(rows, cols);
 
328
        for (int i = 0; i < rows; i++ )
 
329
        {
 
330
                for (int j = 0; j < cols; j++)
 
331
                        data_matrix[i][j] = m->cell(i,j);
 
332
        }
 
333
 
 
334
        sp->makeCurrent();
 
335
        sp->loadFromData(data_matrix, rows, cols, m->xStart(), m->xEnd(),
 
336
                        m->yStart(), m->yEnd());
 
337
 
 
338
        double start, end;
 
339
        sp->coordinates()->axes[Z1].limits (start, end);
 
340
        sp->legend()->setLimits(start, end);
 
341
        sp->legend()->setMajors(legendMajorTicks);
 
342
 
 
343
        Matrix::freeMatrixData(data_matrix, rows);
 
344
 
 
345
        if (d_autoscale || first_time)
 
346
                findBestLayout();
 
347
        update();
 
348
}
 
349
 
 
350
void Graph3D::addMatrixData(Matrix* m, double xl, double xr,
 
351
                double yl, double yr, double zl, double zr)
 
352
{
 
353
        d_matrix = m;
 
354
        plotAssociation = "matrix<" + QString(m->name()) + ">";
 
355
 
 
356
        updateScalesFromMatrix(xl, xr, yl, yr, zl, zr);
 
357
}
 
358
 
 
359
void Graph3D::addData(Table* table,const QString& xColName,const QString& yColName,
 
360
                double xl, double xr, double yl, double yr, double zl, double zr)
 
361
{
 
362
        worksheet=table;
 
363
        int r=table->numRows();
 
364
        int xcol=table->colIndex(xColName);
 
365
        int ycol=table->colIndex(yColName);
 
366
 
 
367
        QString s=table->colName(xcol)+"(X),";
 
368
        s+=yColName+"(Y)";
 
369
        plotAssociation = s;
 
370
 
 
371
        int i, j, xmesh=0, ymesh=2;
 
372
        double xv, yv;
 
373
 
 
374
        for (i = 0; i < r; i++)
 
375
        {
 
376
                if (!table->column(xcol)->isInvalid(i) && !table->column(ycol)->isInvalid(i))
 
377
                {
 
378
                        xv=table->cell(i, xcol);
 
379
                        if (xv>=xl && xv <= xr)
 
380
                                xmesh++;
 
381
                }
 
382
        }
 
383
 
 
384
        if (xmesh == 0)
 
385
                xmesh++;
 
386
 
 
387
        double **data = Matrix::allocateMatrixData(xmesh, ymesh);
 
388
        for ( j = 0; j < ymesh; j++)
 
389
        {
 
390
                int k=0;
 
391
                for ( i = 0; i < r; i++)
 
392
                {
 
393
                        if (!table->column(xcol)->isInvalid(i) && !table->column(ycol)->isInvalid(i))
 
394
                        {
 
395
                                xv=table->cell(i,xcol);
 
396
                                if (xv>=xl && xv <= xr)
 
397
                                {
 
398
                                        yv=table->cell(i,ycol);
 
399
                                        if (yv > zr)
 
400
                                                data[k][j] = zr;
 
401
                                        else if (yv < zl)
 
402
                                                data[k][j] = zl;
 
403
                                        else
 
404
                                                data[k][j] = yv;
 
405
                                        k++;
 
406
                                }
 
407
                        }
 
408
                }
 
409
        }
 
410
        sp->makeCurrent();
 
411
        sp->loadFromData(data, xmesh, ymesh, xl, xr, yl, yr);
 
412
        sp->createCoordinateSystem(Triple(xl, yl, zl), Triple(xr, yr, zr));
 
413
        sp->legend()->setLimits(zl, zr);
 
414
        sp->legend()->setMajors(legendMajorTicks);
 
415
 
 
416
        Matrix::freeMatrixData(data, xmesh);
 
417
}
 
418
 
 
419
void Graph3D::insertNewData(Table* table, const QString& colName)
 
420
{
 
421
        int zCol=table->colIndex(colName);
 
422
        int yCol=table->colY(zCol);
 
423
        int xCol=table->colX(zCol);
 
424
 
 
425
        addData(table, xCol, yCol, zCol, Trajectory);
 
426
        update();
 
427
}
 
428
 
 
429
void Graph3D::changeDataColumn(Table* table, const QString& colName)
 
430
{
 
431
        int zCol=table->colIndex(colName);
 
432
        int yCol=table->colY(zCol);
 
433
        int xCol=table->colX(zCol);
 
434
 
 
435
        plotAssociation = table->colName(xCol)+"(X)," + table->colName(yCol)+"(Y),";
 
436
        plotAssociation += colName+"(Z)";
 
437
 
 
438
        updateDataXYZ(table, xCol, yCol, zCol);
 
439
        if (d_autoscale)
 
440
                findBestLayout();
 
441
}
 
442
 
 
443
void Graph3D::addData(Table* table, int xCol,int yCol,int zCol, int type)
 
444
{
 
445
        worksheet=table;
 
446
        int r=table->numRows();
 
447
 
 
448
        QString s=table->colName(xCol)+"(X),";
 
449
        s+=table->colName(yCol)+"(Y),";
 
450
        s+=table->colName(zCol)+"(Z)";
 
451
        plotAssociation = s;
 
452
 
 
453
        int i,j,columns=0;
 
454
        for ( i = 0; i < r; i++)
 
455
        {
 
456
                if (!table->column(xCol)->isInvalid(i) && !table->column(yCol)->isInvalid(i) && !table->column(zCol)->isInvalid(i))
 
457
                        columns++;
 
458
        }
 
459
 
 
460
        if (columns == 0)
 
461
                columns++;
 
462
 
 
463
        Qwt3D::Triple **data=allocateData(columns,columns);
 
464
        for (j = 0; j < columns; j++)
 
465
        {
 
466
                int k=0;
 
467
                for ( i = 0; i < r; i++)
 
468
                {
 
469
                        if (!table->column(xCol)->isInvalid(i) && !table->column(yCol)->isInvalid(i) && !table->column(zCol)->isInvalid(i))
 
470
                        {
 
471
                                double xv=table->cell(i,xCol);
 
472
                                double yv=table->cell(i,yCol);
 
473
                                double zv=table->cell(i,zCol);
 
474
 
 
475
                                data[k][j] = Triple(xv,yv,zv);
 
476
                                k++;
 
477
                        }
 
478
                }
 
479
        }
 
480
 
 
481
        sp->makeCurrent();
 
482
        sp->loadFromData (data, columns, columns, false,false);
 
483
 
 
484
        double start, end;
 
485
        sp->coordinates()->axes[Z1].limits (start, end);
 
486
        sp->legend()->setLimits(start, end);
 
487
        sp->legend()->setMajors(legendMajorTicks);
 
488
 
 
489
        if (type == Scatter)
 
490
        {
 
491
                Dot d(pointSize, smooth);
 
492
                sp->setPlotStyle(d);
 
493
                pointStyle=Dots;
 
494
                style_ = Qwt3D::USER;
 
495
        }
 
496
        else if (type == Trajectory)
 
497
        {
 
498
                legendOn=false;
 
499
                sp->showColorLegend(legendOn);
 
500
        }
 
501
        else
 
502
        {
 
503
                sp->setPlotStyle(Bar(barsRad));
 
504
                pointStyle=VerticalBars;
 
505
                style_ = Qwt3D::USER;
 
506
        }
 
507
 
 
508
        if (d_autoscale)
 
509
                findBestLayout();
 
510
        deleteData(data,columns);
 
511
}
 
512
 
 
513
void Graph3D::addData(Table* table, int xCol,int yCol,int zCol,
 
514
                double xl, double xr, double yl, double yr, double zl, double zr)
 
515
{
 
516
        worksheet=table;
 
517
        int r=table->numRows();
 
518
 
 
519
        QString s=table->colName(xCol)+"(X),";
 
520
        s+=table->colName(yCol)+"(Y),";
 
521
        s+=table->colName(zCol)+"(Z)";
 
522
        plotAssociation = s;
 
523
 
 
524
        int i,j,columns=0;
 
525
        double xv,yv;
 
526
        for ( i = 0; i < r; i++)
 
527
        {
 
528
                if (!table->column(xCol)->isInvalid(i) && !table->column(yCol)->isInvalid(i) && !table->column(zCol)->isInvalid(i))
 
529
                {
 
530
                        xv=table->cell(i,xCol);
 
531
                        yv=table->cell(i,yCol);
 
532
                        if (xv >= xl && xv <= xr && yv >= yl && yv <= yr)
 
533
                                columns++;
 
534
                }
 
535
        }
 
536
 
 
537
        if (columns == 0)
 
538
                columns++;
 
539
 
 
540
        Qwt3D::Triple **data=allocateData(columns,columns);
 
541
        for (j = 0; j < columns; j++)
 
542
        {
 
543
                int k=0;
 
544
                for ( i = 0; i < r; i++)
 
545
                {
 
546
                        if (!table->column(xCol)->isInvalid(i) && !table->column(yCol)->isInvalid(i) && !table->column(zCol)->isInvalid(i))
 
547
                        {
 
548
                                xv=table->cell(i,xCol);
 
549
                                yv=table->cell(i,yCol);
 
550
                                if (xv >= xl && xv <= xr && yv >= yl && yv <= yr)
 
551
                                {
 
552
                                        double zv=table->cell(i,zCol);
 
553
                                        if (zv > zr)
 
554
                                                data[k][j] = Triple(xv,yv,zr);
 
555
                                        else if (zv < zl)
 
556
                                                data[k][j] = Triple(xv,yv,zl);
 
557
                                        else
 
558
                                                data[k][j] = Triple(xv,yv,zv);
 
559
                                        k++;
 
560
                                }
 
561
                        }
 
562
                }
 
563
        }
 
564
        sp->makeCurrent();
 
565
        sp->loadFromData (data, columns, columns, false, false);
 
566
        sp->createCoordinateSystem(Triple(xl, yl, zl), Triple(xr, yr, zr));
 
567
        sp->legend()->setLimits(zl, zr);
 
568
        sp->legend()->setMajors(legendMajorTicks);
 
569
 
 
570
        deleteData(data,columns);
 
571
}
 
572
 
 
573
void Graph3D::updateData(Table* table)
 
574
{
 
575
        if (func)// function plot
 
576
                return;
 
577
 
 
578
        QString name = plotAssociation;
 
579
        int pos=name.indexOf("_",0);
 
580
        int posX=name.indexOf("(",pos);
 
581
        QString xColName=name.mid(pos+1,posX-pos-1);
 
582
 
 
583
        pos=name.indexOf(",",posX);
 
584
        posX=name.indexOf("(",pos);
 
585
        QString yColName=name.mid(pos+1,posX-pos-1);
 
586
 
 
587
        int xCol=table->colIndex(xColName);
 
588
        int yCol=table->colIndex(yColName);
 
589
 
 
590
        if (name.contains("(Z)",true))
 
591
        {
 
592
                pos=name.indexOf(",",posX);
 
593
                posX=name.indexOf("(",pos);
 
594
                QString zColName=name.mid(pos+1,posX-pos-1);
 
595
                int zCol=table->colIndex(zColName);
 
596
                updateDataXYZ(table, xCol, yCol, zCol);
 
597
        }
 
598
        else
 
599
                updateDataXY(table, xCol, yCol);
 
600
 
 
601
        if (d_autoscale)
 
602
                findBestLayout();
 
603
        update();
 
604
}
 
605
 
 
606
void Graph3D::updateDataXY(Table* table, int xCol, int yCol)
 
607
{
 
608
        int r=table->numRows();
 
609
        int i, j, xmesh=0, ymesh=2;
 
610
 
 
611
        for (i = 0; i < r; i++)
 
612
        {
 
613
                if (!table->column(xCol)->isInvalid(i) && !table->column(yCol)->isInvalid(i))
 
614
                        xmesh++;
 
615
        }
 
616
 
 
617
        if (xmesh<2)
 
618
        {
 
619
                sp->setPlotStyle(NOPLOT);
 
620
                update();
 
621
                return;
 
622
        }
 
623
 
 
624
        double **data = Matrix::allocateMatrixData(xmesh, ymesh);
 
625
        gsl_vector * x = gsl_vector_alloc (xmesh);
 
626
        gsl_vector * y = gsl_vector_alloc (xmesh);
 
627
 
 
628
        for ( j = 0; j < ymesh; j++)
 
629
        {
 
630
                int k=0;
 
631
                for ( i = 0; i < r; i++)
 
632
                {
 
633
                        if (!table->column(xCol)->isInvalid(i) && !table->column(yCol)->isInvalid(i))
 
634
                        {
 
635
                                double xv=table->cell(i,xCol);
 
636
                                double yv=table->cell(i,yCol);
 
637
 
 
638
                                gsl_vector_set (x, k, xv);
 
639
                                gsl_vector_set (y, k, yv);
 
640
 
 
641
                                data[k][j] =yv;
 
642
                                k++;
 
643
                        }
 
644
                }
 
645
        }
 
646
 
 
647
        double minx=gsl_vector_min (x);
 
648
        double maxx=gsl_vector_max(x);
 
649
        double minz=gsl_vector_min (y);
 
650
        double maxz=gsl_vector_max(y);
 
651
        double miny, maxy;
 
652
 
 
653
        sp->makeCurrent();
 
654
        resetNonEmptyStyle();
 
655
        sp->coordinates()->axes[Y1].limits (miny,maxy); //actual Y scale limits
 
656
        sp->loadFromData(data, xmesh, ymesh, minx, maxx, miny, maxy);
 
657
        sp->legend()->setLimits(minz,maxz);
 
658
        sp->legend()->setMajors(legendMajorTicks);
 
659
 
 
660
        gsl_vector_free (x);gsl_vector_free (y);
 
661
        Matrix::freeMatrixData(data, xmesh);
 
662
}
 
663
 
 
664
void Graph3D::updateDataXYZ(Table* table, int xCol, int yCol, int zCol)
 
665
{
 
666
        int r=table->numRows();
 
667
        int i,j,columns=0;
 
668
 
 
669
        for ( i = 0; i < r; i++)
 
670
        {
 
671
                if (!table->column(xCol)->isInvalid(i) && !table->column(yCol)->isInvalid(i) && !table->column(zCol)->isInvalid(i))
 
672
                        columns++;
 
673
        }
 
674
 
 
675
        if (columns<2)
 
676
        {
 
677
                sp->setPlotStyle(NOPLOT);
 
678
                update();
 
679
                return;
 
680
        }
 
681
 
 
682
        Qwt3D::Triple **data=allocateData(columns,columns);
 
683
        gsl_vector * z = gsl_vector_alloc (columns);
 
684
 
 
685
        for ( j = 0; j < columns; j++)
 
686
        {
 
687
                int k=0;
 
688
                for ( i = 0; i < r; i++)
 
689
                {
 
690
                        if (!table->column(xCol)->isInvalid(i) && !table->column(yCol)->isInvalid(i) && !table->column(zCol)->isInvalid(i))
 
691
                        {
 
692
                                double xv=table->cell(i,xCol);
 
693
                                double yv=table->cell(i,yCol);
 
694
                                double zv=table->cell(i,zCol);
 
695
 
 
696
                                gsl_vector_set (z, k, zv);
 
697
                                data[k][j] = Triple(xv,yv,zv);
 
698
                                k++;
 
699
                        }
 
700
                }
 
701
        }
 
702
 
 
703
        double minz=gsl_vector_min(z);
 
704
        double maxz=gsl_vector_max(z);
 
705
        gsl_vector_free (z);
 
706
 
 
707
        sp->makeCurrent();
 
708
        resetNonEmptyStyle();
 
709
 
 
710
        sp->loadFromData (data, columns, columns, false,false);
 
711
        sp->legend()->setLimits(minz,maxz);
 
712
        sp->legend()->setMajors(legendMajorTicks);
 
713
 
 
714
        deleteData(data,columns);
 
715
}
 
716
 
 
717
void Graph3D::updateMatrixData(Matrix* m)
 
718
{
 
719
        int cols=m->numCols();
 
720
        int rows=m->numRows();
 
721
 
 
722
        double **data = Matrix::allocateMatrixData(rows, cols);
 
723
        for (int i = 0; i < rows; i++ ){
 
724
                for (int j = 0; j < cols; j++)
 
725
                        data[i][j] = m->cell(i, j);
 
726
        }
 
727
 
 
728
        sp->loadFromData(data, rows, cols, m->xStart(), m->xEnd(), m->yStart(), m->yEnd());
 
729
 
 
730
        Qwt3D::Axis z_axis = sp->coordinates()->axes[Z1];
 
731
        double start, end;
 
732
        z_axis.limits (start, end);
 
733
        z_axis.setMajors(z_axis.majors());
 
734
        z_axis.setMajors(z_axis.minors());
 
735
 
 
736
        sp->legend()->setLimits(start, end);
 
737
        sp->legend()->setMajors(legendMajorTicks);
 
738
 
 
739
        Matrix::freeMatrixData(data, rows);
 
740
        if (d_autoscale)
 
741
                findBestLayout();
 
742
        update();
 
743
}
 
744
 
 
745
void Graph3D::resetNonEmptyStyle()
 
746
{
 
747
        if (sp->plotStyle() != Qwt3D::NOPLOT )
 
748
                return; // the plot was not previousely emptied
 
749
 
 
750
        if (style_== Qwt3D::USER)
 
751
        {// reseting the right user plot style
 
752
                switch (pointStyle)
 
753
                {
 
754
                        case None:
 
755
                                break;
 
756
 
 
757
                        case Dots :
 
758
                                sp->setPlotStyle(Dot(pointSize, smooth));
 
759
                                break;
 
760
 
 
761
                        case VerticalBars :
 
762
                                sp->setPlotStyle(Bar(barsRad));
 
763
                                break;
 
764
 
 
765
                        case HairCross :
 
766
                                sp->setPlotStyle(CrossHair(crossHairRad, crossHairLineWidth, crossHairSmooth, crossHairBoxed));
 
767
                                break;
 
768
 
 
769
                        case Cones :
 
770
                                sp->setPlotStyle(Cone3D(conesRad, conesQuality));
 
771
                                break;
 
772
                }
 
773
        }
 
774
        else
 
775
                sp->setPlotStyle(style_);
 
776
}
 
777
 
 
778
UserFunction* Graph3D::userFunction()
 
779
{
 
780
        if (func)
 
781
                return func;
 
782
        else
 
783
                return 0;
 
784
}
 
785
 
 
786
void Graph3D::update()
 
787
{
 
788
        sp->makeCurrent();
 
789
 
 
790
        resetAxesLabels();
 
791
 
 
792
        sp->updateData();
 
793
        sp->updateGL();
 
794
}
 
795
 
 
796
void Graph3D::adjustLabels(int val)
 
797
{
 
798
        if (labelsDist != val)
 
799
        {
 
800
                labelsDist=val;
 
801
                sp->coordinates()->adjustLabels(val);
 
802
                sp->makeCurrent();
 
803
                sp->updateGL();
 
804
        }
 
805
        emit modified();
 
806
}
 
807
 
 
808
QFont Graph3D::numbersFont()
 
809
{
 
810
        return sp->coordinates()->axes[X1].numberFont();
 
811
}
 
812
 
 
813
void Graph3D::setNumbersFont(const QFont& font)
 
814
{
 
815
        sp->coordinates()->setNumberFont (font);
 
816
        sp->makeCurrent();
 
817
        sp->updateGL();
 
818
}
 
819
 
 
820
void Graph3D::setNumbersFont(const QStringList& lst)
 
821
{
 
822
        QFont fnt=QFont(lst[1],lst[2].toInt(),lst[3].toInt(),lst[4].toInt());
 
823
        sp->coordinates()->setNumberFont(fnt);
 
824
}
 
825
 
 
826
void Graph3D::setXAxisLabelFont(const QFont& fnt)
 
827
{
 
828
        sp->coordinates()->axes[X1].setLabelFont(fnt);
 
829
        sp->coordinates()->axes[X2].setLabelFont(fnt);
 
830
        sp->coordinates()->axes[X3].setLabelFont(fnt);
 
831
        sp->coordinates()->axes[X4].setLabelFont(fnt);
 
832
}
 
833
 
 
834
void Graph3D::setYAxisLabelFont(const QFont& fnt)
 
835
{
 
836
        sp->coordinates()->axes[Y1].setLabelFont(fnt);
 
837
        sp->coordinates()->axes[Y2].setLabelFont(fnt);
 
838
        sp->coordinates()->axes[Y3].setLabelFont(fnt);
 
839
        sp->coordinates()->axes[Y4].setLabelFont(fnt);
 
840
}
 
841
 
 
842
void Graph3D::setZAxisLabelFont(const QFont& fnt)
 
843
{
 
844
        sp->coordinates()->axes[Z1].setLabelFont(fnt);
 
845
        sp->coordinates()->axes[Z2].setLabelFont(fnt);
 
846
        sp->coordinates()->axes[Z3].setLabelFont(fnt);
 
847
        sp->coordinates()->axes[Z4].setLabelFont(fnt);
 
848
}
 
849
 
 
850
void Graph3D::setXAxisLabelFont(const QStringList& lst)
 
851
{
 
852
        QFont fnt=QFont(lst[1],lst[2].toInt(),lst[3].toInt(),lst[4].toInt());
 
853
        sp->coordinates()->axes[X1].setLabelFont(fnt);
 
854
        sp->coordinates()->axes[X2].setLabelFont(fnt);
 
855
        sp->coordinates()->axes[X3].setLabelFont(fnt);
 
856
        sp->coordinates()->axes[X4].setLabelFont(fnt);
 
857
}
 
858
 
 
859
void Graph3D::setYAxisLabelFont(const QStringList& lst)
 
860
{
 
861
        QFont fnt=QFont(lst[1],lst[2].toInt(),lst[3].toInt(),lst[4].toInt());
 
862
        sp->coordinates()->axes[Y1].setLabelFont(fnt);
 
863
        sp->coordinates()->axes[Y2].setLabelFont(fnt);
 
864
        sp->coordinates()->axes[Y3].setLabelFont(fnt);
 
865
        sp->coordinates()->axes[Y4].setLabelFont(fnt);
 
866
}
 
867
 
 
868
void Graph3D::setZAxisLabelFont(const QStringList& lst)
 
869
{
 
870
        QFont fnt=QFont(lst[1],lst[2].toInt(),lst[3].toInt(),lst[4].toInt());
 
871
        sp->coordinates()->axes[Z1].setLabelFont(fnt);
 
872
        sp->coordinates()->axes[Z2].setLabelFont(fnt);
 
873
        sp->coordinates()->axes[Z3].setLabelFont(fnt);
 
874
        sp->coordinates()->axes[Z4].setLabelFont(fnt);
 
875
}
 
876
 
 
877
QStringList Graph3D::axisTickLengths()
 
878
{
 
879
        QStringList lst;
 
880
        double majorl,minorl;
 
881
 
 
882
        sp->coordinates()->axes[X1].ticLength (majorl,minorl);
 
883
        lst<<QString::number(majorl);
 
884
        lst<<QString::number(minorl);
 
885
 
 
886
        sp->coordinates()->axes[Y1].ticLength (majorl,minorl);
 
887
        lst<<QString::number(majorl);
 
888
        lst<<QString::number(minorl);
 
889
 
 
890
        sp->coordinates()->axes[Z1].ticLength (majorl,minorl);
 
891
        lst<<QString::number(majorl);
 
892
        lst<<QString::number(minorl);
 
893
 
 
894
        return lst;
 
895
}
 
896
 
 
897
void Graph3D::setTickLengths(const QStringList& lst)
 
898
{
 
899
        double majorl,minorl;
 
900
        QStringList tick_length = lst;
 
901
        if (int(lst.count()) > 6)
 
902
                tick_length.remove(tick_length.first());
 
903
 
 
904
        majorl=tick_length[0].toDouble();
 
905
        minorl=tick_length[1].toDouble();
 
906
        sp->coordinates()->axes[X1].setTicLength (majorl,minorl);
 
907
        sp->coordinates()->axes[X2].setTicLength (majorl,minorl);
 
908
        sp->coordinates()->axes[X3].setTicLength (majorl,minorl);
 
909
        sp->coordinates()->axes[X4].setTicLength (majorl,minorl);
 
910
 
 
911
        majorl=tick_length[2].toDouble();
 
912
        minorl=tick_length[3].toDouble();
 
913
        sp->coordinates()->axes[Y1].setTicLength (majorl,minorl);
 
914
        sp->coordinates()->axes[Y2].setTicLength (majorl,minorl);
 
915
        sp->coordinates()->axes[Y3].setTicLength (majorl,minorl);
 
916
        sp->coordinates()->axes[Y4].setTicLength (majorl,minorl);
 
917
 
 
918
        majorl=tick_length[4].toDouble();
 
919
        minorl=tick_length[5].toDouble();
 
920
        sp->coordinates()->axes[Z1].setTicLength (majorl,minorl);
 
921
        sp->coordinates()->axes[Z2].setTicLength (majorl,minorl);
 
922
        sp->coordinates()->axes[Z3].setTicLength (majorl,minorl);
 
923
        sp->coordinates()->axes[Z4].setTicLength (majorl,minorl);
 
924
}
 
925
 
 
926
void Graph3D::updateTickLength(int axis,double majorLength, double minorLength)
 
927
{
 
928
        double majorl,minorl;
 
929
        switch(axis)
 
930
        {
 
931
                case 0:
 
932
                        sp->coordinates()->axes[X1].ticLength (majorl,minorl);
 
933
                        if (majorl != majorLength || minorl != minorLength)
 
934
                        {
 
935
                                sp->coordinates()->axes[X1].setTicLength (majorLength,minorLength);
 
936
                                sp->coordinates()->axes[X2].setTicLength (majorLength,minorLength);
 
937
                                sp->coordinates()->axes[X3].setTicLength (majorLength,minorLength);
 
938
                                sp->coordinates()->axes[X4].setTicLength (majorLength,minorLength);
 
939
                        }
 
940
                        break;
 
941
 
 
942
                case 1:
 
943
                        sp->coordinates()->axes[Y1].ticLength (majorl,minorl);
 
944
                        if (majorl != majorLength || minorl != minorLength)
 
945
                        {
 
946
                                sp->coordinates()->axes[Y1].setTicLength (majorLength,minorLength);
 
947
                                sp->coordinates()->axes[Y2].setTicLength (majorLength,minorLength);
 
948
                                sp->coordinates()->axes[Y3].setTicLength (majorLength,minorLength);
 
949
                                sp->coordinates()->axes[Y4].setTicLength (majorLength,minorLength);
 
950
                        }
 
951
                        break;
 
952
 
 
953
                case 2:
 
954
                        sp->coordinates()->axes[Z1].ticLength (majorl,minorl);
 
955
                        if (majorl != majorLength || minorl != minorLength)
 
956
                        {
 
957
                                sp->coordinates()->axes[Z1].setTicLength (majorLength,minorLength);
 
958
                                sp->coordinates()->axes[Z2].setTicLength (majorLength,minorLength);
 
959
                                sp->coordinates()->axes[Z3].setTicLength (majorLength,minorLength);
 
960
                                sp->coordinates()->axes[Z4].setTicLength (majorLength,minorLength);
 
961
                        }
 
962
                        break;
 
963
        }
 
964
        sp->updateGL();
 
965
}
 
966
 
 
967
void Graph3D::rotationChanged(double, double, double)
 
968
{
 
969
        emit modified();
 
970
}
 
971
 
 
972
void Graph3D::scaleChanged(double, double, double)
 
973
{
 
974
        emit modified();
 
975
}
 
976
 
 
977
void Graph3D::shiftChanged(double, double, double)
 
978
{
 
979
        emit modified();
 
980
}
 
981
 
 
982
void Graph3D::zoomChanged(double)
 
983
{
 
984
        emit modified();
 
985
}
 
986
 
 
987
void Graph3D::resetAxesLabels()
 
988
{
 
989
        sp->coordinates()->axes[X1].setLabelString(labels[0]);
 
990
        sp->coordinates()->axes[X2].setLabelString(labels[0]);
 
991
        sp->coordinates()->axes[X3].setLabelString(labels[0]);
 
992
        sp->coordinates()->axes[X4].setLabelString(labels[0]);
 
993
 
 
994
        sp->coordinates()->axes[Y1].setLabelString(labels[1]);
 
995
        sp->coordinates()->axes[Y2].setLabelString(labels[1]);
 
996
        sp->coordinates()->axes[Y3].setLabelString(labels[1]);
 
997
        sp->coordinates()->axes[Y4].setLabelString(labels[1]);
 
998
 
 
999
        sp->coordinates()->axes[Z1].setLabelString(labels[2]);
 
1000
        sp->coordinates()->axes[Z2].setLabelString(labels[2]);
 
1001
        sp->coordinates()->axes[Z3].setLabelString(labels[2]);
 
1002
        sp->coordinates()->axes[Z4].setLabelString(labels[2]);
 
1003
}
 
1004
 
 
1005
void Graph3D::setAxesLabels(const QStringList& l)
 
1006
{
 
1007
        QString label= l[0];
 
1008
        sp->coordinates()->axes[X1].setLabelString(label);
 
1009
        sp->coordinates()->axes[X2].setLabelString(label);
 
1010
        sp->coordinates()->axes[X3].setLabelString(label);
 
1011
        sp->coordinates()->axes[X4].setLabelString(label);
 
1012
 
 
1013
        label= l[1];
 
1014
        sp->coordinates()->axes[Y1].setLabelString(label);
 
1015
        sp->coordinates()->axes[Y2].setLabelString(label);
 
1016
        sp->coordinates()->axes[Y3].setLabelString(label);
 
1017
        sp->coordinates()->axes[Y4].setLabelString(label);
 
1018
 
 
1019
        label= l[2];
 
1020
        sp->coordinates()->axes[Z1].setLabelString(label);
 
1021
        sp->coordinates()->axes[Z2].setLabelString(label);
 
1022
        sp->coordinates()->axes[Z3].setLabelString(label);
 
1023
        sp->coordinates()->axes[Z4].setLabelString(label);
 
1024
 
 
1025
        labels=l;
 
1026
}
 
1027
 
 
1028
void Graph3D::updateLabel(int axis,const QString& label, const QFont& f)
 
1029
{
 
1030
        switch(axis)
 
1031
        {
 
1032
                case 0:
 
1033
                        if (labels[0] != label)
 
1034
                        {
 
1035
                                sp->coordinates()->axes[X1].setLabelString(label);
 
1036
                                sp->coordinates()->axes[X2].setLabelString(label);
 
1037
                                sp->coordinates()->axes[X3].setLabelString(label);
 
1038
                                sp->coordinates()->axes[X4].setLabelString(label);
 
1039
                                labels[0]=label;
 
1040
                        }
 
1041
                        if (sp->coordinates()->axes[X1].labelFont() != f)
 
1042
                        {
 
1043
                                sp->coordinates()->axes[X1].setLabelFont (f);
 
1044
                                sp->coordinates()->axes[X2].setLabelFont (f);
 
1045
                                sp->coordinates()->axes[X3].setLabelFont (f);
 
1046
                                sp->coordinates()->axes[X4].setLabelFont (f);
 
1047
                        }
 
1048
                        break;
 
1049
 
 
1050
                case 1:
 
1051
                        if (labels[1] != label)
 
1052
                        {
 
1053
                                sp->coordinates()->axes[Y1].setLabelString(label);
 
1054
                                sp->coordinates()->axes[Y2].setLabelString(label);
 
1055
                                sp->coordinates()->axes[Y3].setLabelString(label);
 
1056
                                sp->coordinates()->axes[Y4].setLabelString(label);
 
1057
 
 
1058
                                labels[1]=label;
 
1059
                        }
 
1060
                        if (sp->coordinates()->axes[Y1].labelFont() != f)
 
1061
                        {
 
1062
                                sp->coordinates()->axes[Y1].setLabelFont (f);
 
1063
                                sp->coordinates()->axes[Y2].setLabelFont (f);
 
1064
                                sp->coordinates()->axes[Y3].setLabelFont (f);
 
1065
                                sp->coordinates()->axes[Y4].setLabelFont (f);
 
1066
                        }
 
1067
                        break;
 
1068
 
 
1069
                case 2:
 
1070
                        if (labels[2] != label)
 
1071
                        {
 
1072
                                sp->coordinates()->axes[Z1].setLabelString(label);
 
1073
                                sp->coordinates()->axes[Z2].setLabelString(label);
 
1074
                                sp->coordinates()->axes[Z3].setLabelString(label);
 
1075
                                sp->coordinates()->axes[Z4].setLabelString(label);
 
1076
                                labels[2]=label;
 
1077
                        }
 
1078
                        if (sp->coordinates()->axes[Z1].labelFont() != f)
 
1079
                        {
 
1080
                                sp->coordinates()->axes[Z1].setLabelFont (f);
 
1081
                                sp->coordinates()->axes[Z2].setLabelFont (f);
 
1082
                                sp->coordinates()->axes[Z3].setLabelFont (f);
 
1083
                                sp->coordinates()->axes[Z4].setLabelFont (f);
 
1084
                        }
 
1085
                        break;
 
1086
        }
 
1087
 
 
1088
        sp->makeCurrent();
 
1089
        sp->updateGL();
 
1090
        emit modified();
 
1091
}
 
1092
 
 
1093
QFont Graph3D::xAxisLabelFont()
 
1094
{
 
1095
        return sp->coordinates()->axes[X1].labelFont();
 
1096
}
 
1097
 
 
1098
QFont Graph3D::yAxisLabelFont()
 
1099
{
 
1100
        return sp->coordinates()->axes[Y1].labelFont();
 
1101
}
 
1102
 
 
1103
QFont Graph3D::zAxisLabelFont()
 
1104
{
 
1105
        return sp->coordinates()->axes[Z1].labelFont();
 
1106
}
 
1107
 
 
1108
double Graph3D::xStart()
 
1109
{
 
1110
        double start,stop;
 
1111
        sp->coordinates()->axes[X1].limits (start,stop);
 
1112
        return start;
 
1113
}
 
1114
 
 
1115
double Graph3D::xStop()
 
1116
{
 
1117
        double start,stop;
 
1118
        sp->coordinates()->axes[X1].limits (start,stop);
 
1119
        return stop;
 
1120
}
 
1121
 
 
1122
double Graph3D::yStart()
 
1123
{
 
1124
        double start,stop;
 
1125
        sp->coordinates()->axes[Y1].limits (start,stop);
 
1126
        return start;
 
1127
}
 
1128
 
 
1129
double Graph3D::yStop()
 
1130
{
 
1131
        double start,stop;
 
1132
        sp->coordinates()->axes[Y1].limits (start,stop);
 
1133
        return stop;
 
1134
}
 
1135
 
 
1136
double Graph3D::zStart()
 
1137
{
 
1138
        double start,stop;
 
1139
        sp->coordinates()->axes[Z1].limits (start,stop);
 
1140
        return start;
 
1141
}
 
1142
 
 
1143
double Graph3D::zStop()
 
1144
{
 
1145
        double start,stop;
 
1146
        sp->coordinates()->axes[Z1].limits(start, stop);
 
1147
        return stop;
 
1148
}
 
1149
 
 
1150
QStringList Graph3D::scaleLimits()
 
1151
{
 
1152
        QStringList limits;
 
1153
        double start,stop;
 
1154
        int majors,minors;
 
1155
 
 
1156
        sp->coordinates()->axes[X1].limits (start,stop);
 
1157
        majors=sp->coordinates()->axes[X1].majors();
 
1158
        minors=sp->coordinates()->axes[X1].minors();
 
1159
 
 
1160
        limits<<QString::number(start);
 
1161
        limits<<QString::number(stop);
 
1162
        limits<<QString::number(majors);
 
1163
        limits<<QString::number(minors);
 
1164
        limits<<QString::number(scaleType[0]);
 
1165
 
 
1166
        sp->coordinates()->axes[Y1].limits (start,stop);
 
1167
        majors=sp->coordinates()->axes[Y1].majors();
 
1168
        minors=sp->coordinates()->axes[Y1].minors();
 
1169
 
 
1170
        limits<<QString::number(start);
 
1171
        limits<<QString::number(stop);
 
1172
        limits<<QString::number(majors);
 
1173
        limits<<QString::number(minors);
 
1174
        limits<<QString::number(scaleType[1]);
 
1175
 
 
1176
        sp->coordinates()->axes[Z1].limits (start,stop);
 
1177
        majors=sp->coordinates()->axes[Z1].majors();
 
1178
        minors=sp->coordinates()->axes[Z1].minors();
 
1179
 
 
1180
        limits<<QString::number(start);
 
1181
        limits<<QString::number(stop);
 
1182
        limits<<QString::number(majors);
 
1183
        limits<<QString::number(minors);
 
1184
        limits<<QString::number(scaleType[2]);
 
1185
 
 
1186
        return limits;
 
1187
}
 
1188
 
 
1189
QStringList Graph3D::scaleTicks()
 
1190
{
 
1191
        QStringList limits;
 
1192
        int majors,minors;
 
1193
 
 
1194
        majors=sp->coordinates()->axes[X1].majors();
 
1195
        minors=sp->coordinates()->axes[X1].minors();
 
1196
        limits<<QString::number(majors);
 
1197
        limits<<QString::number(minors);
 
1198
 
 
1199
        majors=sp->coordinates()->axes[Y1].majors();
 
1200
        minors=sp->coordinates()->axes[Y1].minors();
 
1201
        limits<<QString::number(majors);
 
1202
        limits<<QString::number(minors);
 
1203
 
 
1204
        majors=sp->coordinates()->axes[Z1].majors();
 
1205
        minors=sp->coordinates()->axes[Z1].minors();
 
1206
        limits<<QString::number(majors);
 
1207
        limits<<QString::number(minors);
 
1208
 
 
1209
        return limits;
 
1210
}
 
1211
 
 
1212
void Graph3D::updateScale(int axis,const QStringList& options)
 
1213
{
 
1214
        double xMin,xMax,yMin,yMax,zMin,zMax;
 
1215
        double *min, *max;
 
1216
        int majors, minors, newMaj, newMin;
 
1217
        Qwt3D::Axis *targetAxes[4];
 
1218
 
 
1219
        sp->makeCurrent();
 
1220
 
 
1221
        switch (axis) {
 
1222
                case 0:
 
1223
                        targetAxes[0] = &sp->coordinates()->axes[X1];
 
1224
                        targetAxes[1] = &sp->coordinates()->axes[X2];
 
1225
                        targetAxes[2] = &sp->coordinates()->axes[X3];
 
1226
                        targetAxes[3] = &sp->coordinates()->axes[X4];
 
1227
                        min = &xMin; max = &xMax;
 
1228
                        break;
 
1229
                case 1:
 
1230
                        targetAxes[0] = &sp->coordinates()->axes[Y1];
 
1231
                        targetAxes[1] = &sp->coordinates()->axes[Y2];
 
1232
                        targetAxes[2] = &sp->coordinates()->axes[Y3];
 
1233
                        targetAxes[3] = &sp->coordinates()->axes[Y4];
 
1234
                        min = &yMin; max = &yMax;
 
1235
                        break;
 
1236
                case 2:
 
1237
                        targetAxes[0] = &sp->coordinates()->axes[Z1];
 
1238
                        targetAxes[1] = &sp->coordinates()->axes[Z2];
 
1239
                        targetAxes[2] = &sp->coordinates()->axes[Z3];
 
1240
                        targetAxes[3] = &sp->coordinates()->axes[Z4];
 
1241
                        min = &zMin; max = &zMax;
 
1242
                        break;
 
1243
        }
 
1244
 
 
1245
        majors = targetAxes[0]->majors();
 
1246
        minors = targetAxes[0]->minors();
 
1247
 
 
1248
        sp->coordinates()->axes[X1].limits(xMin,xMax);
 
1249
        sp->coordinates()->axes[Y1].limits(yMin,yMax);
 
1250
        sp->coordinates()->axes[Z1].limits(zMin,zMax);
 
1251
 
 
1252
        if (*min != options[0].toDouble() || *max != options[1].toDouble()) {
 
1253
                        *min = options[0].toDouble();
 
1254
                        *max = options[1].toDouble();
 
1255
                        if (func) {
 
1256
                                        func->setDomain(xMin, xMax, yMin, yMax);
 
1257
                                        func->setMinZ(zMin); func->setMaxZ(zMax);
 
1258
                                        func->create();
 
1259
                                        sp->createCoordinateSystem(Triple(xMin, yMin, zMin), Triple(xMax, yMax, zMax));
 
1260
                        } else
 
1261
                                        updateScales(xMin, xMax, yMin, yMax, zMin, zMax);
 
1262
                        sp->legend()->setLimits(zMin, zMax);
 
1263
        }
 
1264
 
 
1265
        if (QString::number(scaleType[axis]) != options[4]) {
 
1266
                        if (options[4] == "0") {
 
1267
                                        targetAxes[0]->setScale(LINEARSCALE);
 
1268
                                        if (axis == 2) sp->legend()->setScale(LINEARSCALE);
 
1269
                                        scaleType[axis] = 0;
 
1270
                        } else {
 
1271
                                        targetAxes[0]->setScale(LOG10SCALE);
 
1272
                                        if (axis == 2) sp->legend()->setScale(LOG10SCALE);
 
1273
                                        scaleType[axis] = 1;
 
1274
                        }
 
1275
        }
 
1276
 
 
1277
 
 
1278
        newMaj = options[2].toInt();
 
1279
        if (majors != newMaj)
 
1280
                        for (int i=0; i<4; i++)
 
1281
                                        targetAxes[i]->setMajors(newMaj);
 
1282
 
 
1283
        newMin = options[3].toInt();
 
1284
        if (minors != newMin)
 
1285
                        for (int i=0; i<4; i++)
 
1286
                                        targetAxes[i]->setMinors(newMin);
 
1287
 
 
1288
        update();
 
1289
        emit modified();
 
1290
}
 
1291
 
 
1292
void Graph3D::updateScales(double xl, double xr, double yl, double yr, double zl, double zr)
 
1293
{
 
1294
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 
1295
 
 
1296
        if (d_matrix)
 
1297
                updateScalesFromMatrix(xl, xr, yl, yr, zl, zr);
 
1298
        else
 
1299
        {
 
1300
                QString name= plotAssociation;
 
1301
 
 
1302
                int pos=name.indexOf("_",0);
 
1303
                int posX=name.indexOf("(",pos);
 
1304
                QString xColName=name.mid(pos+1,posX-pos-1);
 
1305
                int xCol=worksheet->colIndex(xColName);
 
1306
 
 
1307
                pos=name.indexOf(",",posX);
 
1308
                posX=name.indexOf("(",pos);
 
1309
                QString yColName=name.mid(pos+1,posX-pos-1);
 
1310
                int yCol=worksheet->colIndex(yColName);
 
1311
 
 
1312
                if (name.endsWith("(Z)",true))
 
1313
                {
 
1314
                        pos=name.indexOf(",",posX);
 
1315
                        posX=name.indexOf("(",pos);
 
1316
                        QString zColName=name.mid(pos+1,posX-pos-1);
 
1317
                        int zCol=worksheet->colIndex(zColName);
 
1318
 
 
1319
                        updateScales(xl, xr, yl, yr, zl, zr, xCol, yCol, zCol);
 
1320
                }
 
1321
                else if (name.endsWith("(Y)",true))
 
1322
                        updateScales(xl, xr, yl, yr, zl, zr, xCol, yCol);
 
1323
        }
 
1324
 
 
1325
        QApplication::restoreOverrideCursor();
 
1326
}
 
1327
 
 
1328
void Graph3D::updateScalesFromMatrix(double xl, double xr, double yl,
 
1329
                double yr, double zl, double zr)
 
1330
{
 
1331
        double xStart = qMin(d_matrix->xStart(), d_matrix->xEnd());
 
1332
        double xEnd = qMax(d_matrix->xStart(), d_matrix->xEnd());
 
1333
        double yStart = qMin(d_matrix->yStart(), d_matrix->yEnd());
 
1334
        double yEnd = qMax(d_matrix->yStart(), d_matrix->yEnd());
 
1335
 
 
1336
        double dx = fabs((xEnd - xStart)/double(d_matrix->numCols()-1));
 
1337
        double dy = fabs((yEnd - yStart)/double(d_matrix->numRows()-1));
 
1338
 
 
1339
        int nc = int(fabs(xr - xl)/dx)+1;
 
1340
        int nr = int(fabs(yr - yl)/dy)+1;
 
1341
 
 
1342
    double x_begin = qMin(xl, xr);
 
1343
        double y_begin = qMin(yl, yr);
 
1344
 
 
1345
        double **data_matrix = Matrix::allocateMatrixData(nc, nr);
 
1346
        for (int i = 0; i < nc; i++){
 
1347
                double x = x_begin + i*dx;
 
1348
                for (int j = 0; j < nr; j++){
 
1349
                        double y = y_begin + j*dy;
 
1350
                        if (x >= xStart && x <= xEnd && y >= yStart && y <= yEnd){
 
1351
                                int k = abs((y - yStart)/dy);
 
1352
                                int l = abs((x - xStart)/dx);
 
1353
                                double val = d_matrix->cell(k, l);
 
1354
                                if (val > zr)
 
1355
                                        data_matrix[i][j] = zr;
 
1356
                                else if (val < zl)
 
1357
                                        data_matrix[i][j] = zl;
 
1358
                                else
 
1359
                                        data_matrix[i][j] = val;
 
1360
                        } else
 
1361
                                data_matrix[i][j] = 0.0;
 
1362
                }
 
1363
        }
 
1364
        sp->loadFromData(data_matrix, nc, nr, xl, xr, yl, yr);
 
1365
        Matrix::freeMatrixData(data_matrix, nc);
 
1366
 
 
1367
        sp->createCoordinateSystem(Triple(xl, yl, zl), Triple(xr, yr, zr));
 
1368
        sp->legend()->setLimits(zl, zr);
 
1369
        sp->legend()->setMajors(legendMajorTicks);
 
1370
        update();
 
1371
}
 
1372
 
 
1373
void Graph3D::updateScales(double xl, double xr, double yl, double yr,double zl, double zr,
 
1374
                int xcol, int ycol)
 
1375
{
 
1376
        int r=worksheet->numRows();
 
1377
        int i, j, xmesh=0, ymesh=2;
 
1378
        double xv, yv;
 
1379
 
 
1380
        for (i = 0; i < r; i++)
 
1381
        {
 
1382
                if (!worksheet->column(xcol)->isInvalid(i) && !worksheet->column(ycol)->isInvalid(i))
 
1383
                {
 
1384
                        xv=worksheet->cell(i,xcol);
 
1385
                        if (xv >= xl && xv <= xr)
 
1386
                                xmesh++;
 
1387
                }
 
1388
        }
 
1389
 
 
1390
        if (xmesh == 0)
 
1391
                xmesh++;
 
1392
 
 
1393
        double **data = Matrix::allocateMatrixData(xmesh, ymesh);
 
1394
 
 
1395
        for ( j = 0; j < ymesh; j++)
 
1396
        {
 
1397
                int k=0;
 
1398
                for ( i = 0; i < r; i++)
 
1399
                {
 
1400
                        if (!worksheet->column(xcol)->isInvalid(i) && !worksheet->column(ycol)->isInvalid(i))
 
1401
                        {
 
1402
                                xv=worksheet->cell(i,xcol);
 
1403
                                if (xv >= xl && xv <= xr)
 
1404
                                {
 
1405
                                        yv=worksheet->cell(i,ycol);
 
1406
                                        if (yv > zr)
 
1407
                                                data[k][j] = zr;
 
1408
                                        else if (yv < zl)
 
1409
                                                data[k][j] = zl;
 
1410
                                        else
 
1411
                                                data[k][j] = yv;
 
1412
                                        k++;
 
1413
                                }
 
1414
                        }
 
1415
                }
 
1416
        }
 
1417
 
 
1418
        sp->loadFromData(data, xmesh, ymesh, xl, xr, yl, yr);
 
1419
        sp->createCoordinateSystem(Triple(xl, yl, zl), Triple(xr, yr, zr));
 
1420
        Matrix::freeMatrixData(data, xmesh);
 
1421
}
 
1422
 
 
1423
void Graph3D::updateScales(double xl, double xr, double yl, double yr, double zl, double zr,
 
1424
                int xCol, int yCol, int zCol)
 
1425
{
 
1426
        int r=worksheet->numRows();
 
1427
        int i,j,columns=0;
 
1428
        double xv, yv, zv;
 
1429
        for ( i = 0; i < r; i++)
 
1430
        {
 
1431
                if (!worksheet->column(xCol)->isInvalid(i) && !worksheet->column(yCol)->isInvalid(i) && !worksheet->column(zCol)->isInvalid(i))
 
1432
                {
 
1433
                        xv=worksheet->cell(i,xCol);
 
1434
                        yv=worksheet->cell(i,yCol);
 
1435
                        if (xv >= xl && xv <= xr && yv >= yl && yv <= yr)
 
1436
                                columns++;
 
1437
                }
 
1438
        }
 
1439
 
 
1440
        if (columns == 0)
 
1441
                columns++;
 
1442
 
 
1443
        Qwt3D::Triple **data=allocateData(columns,columns);
 
1444
        for ( j = 0; j < columns; j++)
 
1445
        {
 
1446
                int k=0;
 
1447
                for ( i = 0; i < r; i++)
 
1448
                {
 
1449
                        if (!worksheet->column(xCol)->isInvalid(i) && !worksheet->column(yCol)->isInvalid(i) && !worksheet->column(zCol)->isInvalid(i))
 
1450
                        {
 
1451
                                xv=worksheet->cell(i,xCol);
 
1452
                                yv=worksheet->cell(i,yCol);
 
1453
                                if (xv >= xl && xv <= xr && yv >= yl && yv <= yr )
 
1454
                                {
 
1455
                                        zv=worksheet->cell(i,zCol);
 
1456
                                        if (zv > zr)
 
1457
                                                data[k][j] = Triple(xv,yv,zr);
 
1458
                                        else if (zv < zl)
 
1459
                                                data[k][j] = Triple(xv,yv,zl);
 
1460
                                        else
 
1461
                                                data[k][j] = Triple(xv,yv,zv);
 
1462
                                        k++;
 
1463
                                }
 
1464
                        }
 
1465
                }
 
1466
        }
 
1467
        sp->loadFromData (data, columns, columns, false,false);
 
1468
        sp->createCoordinateSystem(Triple(xl, yl, zl), Triple(xr, yr, zr));
 
1469
        deleteData(data,columns);
 
1470
}
 
1471
 
 
1472
void Graph3D::setTicks(const QStringList& options)
 
1473
{
 
1474
        int min,maj;
 
1475
        if (int(options.count()) == 6)
 
1476
        {
 
1477
                maj=options[0].toInt();
 
1478
                sp->coordinates()->axes[X1].setMajors(maj);
 
1479
                sp->coordinates()->axes[X2].setMajors(maj);
 
1480
                sp->coordinates()->axes[X3].setMajors(maj);
 
1481
                sp->coordinates()->axes[X4].setMajors(maj);
 
1482
 
 
1483
                min=options[1].toInt();
 
1484
                sp->coordinates()->axes[X1].setMinors(min);
 
1485
                sp->coordinates()->axes[X2].setMinors(min);
 
1486
                sp->coordinates()->axes[X3].setMinors(min);
 
1487
                sp->coordinates()->axes[X4].setMinors(min);
 
1488
 
 
1489
                maj=options[2].toInt();
 
1490
                sp->coordinates()->axes[Y1].setMajors(maj);
 
1491
                sp->coordinates()->axes[Y2].setMajors(maj);
 
1492
                sp->coordinates()->axes[Y3].setMajors(maj);
 
1493
                sp->coordinates()->axes[Y4].setMajors(maj);
 
1494
 
 
1495
                min=options[3].toInt();
 
1496
                sp->coordinates()->axes[Y1].setMinors(min);
 
1497
                sp->coordinates()->axes[Y2].setMinors(min);
 
1498
                sp->coordinates()->axes[Y3].setMinors(min);
 
1499
                sp->coordinates()->axes[Y4].setMinors(min);
 
1500
 
 
1501
                maj=options[4].toInt();
 
1502
                sp->coordinates()->axes[Z1].setMajors(maj);
 
1503
                sp->coordinates()->axes[Z2].setMajors(maj);
 
1504
                sp->coordinates()->axes[Z3].setMajors(maj);
 
1505
                sp->coordinates()->axes[Z4].setMajors(maj);
 
1506
 
 
1507
                min=options[5].toInt();
 
1508
                sp->coordinates()->axes[Z1].setMinors(min);
 
1509
                sp->coordinates()->axes[Z2].setMinors(min);
 
1510
                sp->coordinates()->axes[Z3].setMinors(min);
 
1511
                sp->coordinates()->axes[Z4].setMinors(min);
 
1512
        }
 
1513
        else
 
1514
        {
 
1515
                maj=options[1].toInt();
 
1516
                sp->coordinates()->axes[X1].setMajors(maj);
 
1517
                sp->coordinates()->axes[X2].setMajors(maj);
 
1518
                sp->coordinates()->axes[X3].setMajors(maj);
 
1519
                sp->coordinates()->axes[X4].setMajors(maj);
 
1520
 
 
1521
                min=options[2].toInt();
 
1522
                sp->coordinates()->axes[X1].setMinors(min);
 
1523
                sp->coordinates()->axes[X2].setMinors(min);
 
1524
                sp->coordinates()->axes[X3].setMinors(min);
 
1525
                sp->coordinates()->axes[X4].setMinors(min);
 
1526
 
 
1527
                maj=options[3].toInt();
 
1528
                sp->coordinates()->axes[Y1].setMajors(maj);
 
1529
                sp->coordinates()->axes[Y2].setMajors(maj);
 
1530
                sp->coordinates()->axes[Y3].setMajors(maj);
 
1531
                sp->coordinates()->axes[Y4].setMajors(maj);
 
1532
 
 
1533
                min=options[4].toInt();
 
1534
                sp->coordinates()->axes[Y1].setMinors(min);
 
1535
                sp->coordinates()->axes[Y2].setMinors(min);
 
1536
                sp->coordinates()->axes[Y3].setMinors(min);
 
1537
                sp->coordinates()->axes[Y4].setMinors(min);
 
1538
 
 
1539
                maj=options[5].toInt();
 
1540
                sp->coordinates()->axes[Z1].setMajors(maj);
 
1541
                sp->coordinates()->axes[Z2].setMajors(maj);
 
1542
                sp->coordinates()->axes[Z3].setMajors(maj);
 
1543
                sp->coordinates()->axes[Z4].setMajors(maj);
 
1544
 
 
1545
                min=options[6].toInt();
 
1546
                sp->coordinates()->axes[Z1].setMinors(min);
 
1547
                sp->coordinates()->axes[Z2].setMinors(min);
 
1548
                sp->coordinates()->axes[Z3].setMinors(min);
 
1549
                sp->coordinates()->axes[Z4].setMinors(min);
 
1550
        }
 
1551
}
 
1552
 
 
1553
void Graph3D::setColors(const QColor& meshColor,const QColor& axesColor,const QColor& numColor,
 
1554
                const QColor& labelColor,const QColor& bgColor,const QColor& gridColor)
 
1555
{
 
1556
        if (meshCol != meshColor)
 
1557
        {
 
1558
                sp->setMeshColor(Qt2GL(meshColor));
 
1559
                meshCol=meshColor;
 
1560
        }
 
1561
 
 
1562
        if(axesCol != axesColor)
 
1563
        {
 
1564
                sp->coordinates()->setAxesColor(Qt2GL(axesColor));
 
1565
                axesCol=axesColor;
 
1566
        }
 
1567
 
 
1568
        if(numCol !=numColor)
 
1569
        {
 
1570
                sp->coordinates()->setNumberColor(Qt2GL(numColor));
 
1571
                numCol=numColor;
 
1572
        }
 
1573
 
 
1574
        if(labelsCol !=labelColor)
 
1575
        {
 
1576
                sp->coordinates()->setLabelColor(Qt2GL(labelColor));
 
1577
                labelsCol=labelColor;
 
1578
        }
 
1579
 
 
1580
        if(bgCol !=bgColor)
 
1581
        {
 
1582
                sp->setBackgroundColor(Qt2GL(bgColor));
 
1583
                bgCol=bgColor;
 
1584
        }
 
1585
 
 
1586
        if(gridCol !=gridColor)
 
1587
        {
 
1588
                sp->coordinates()->setGridLinesColor(Qt2GL(gridColor));
 
1589
                gridCol=gridColor;
 
1590
        }
 
1591
}
 
1592
 
 
1593
void Graph3D::setColors(const QStringList& colors)
 
1594
{
 
1595
        meshCol=QColor(colors[1]);
 
1596
        sp->setMeshColor(Qt2GL(meshCol));
 
1597
 
 
1598
        axesCol=QColor(colors[2]);
 
1599
        sp->coordinates()->setAxesColor(Qt2GL(axesCol));
 
1600
 
 
1601
        numCol=QColor(colors[3]);
 
1602
        sp->coordinates()->setNumberColor(Qt2GL(numCol));
 
1603
 
 
1604
        labelsCol=QColor(colors[4]);
 
1605
        sp->coordinates()->setLabelColor(Qt2GL(labelsCol));
 
1606
 
 
1607
        bgCol=QColor(colors[5]);
 
1608
        sp->setBackgroundColor(Qt2GL(bgCol));
 
1609
 
 
1610
        gridCol=QColor(colors[6]);
 
1611
        sp->coordinates()->setGridLinesColor(Qt2GL(gridCol));
 
1612
 
 
1613
        if ((int)colors.count()>7)
 
1614
        {
 
1615
                QColor min=QColor(colors[7]);
 
1616
                QColor max=QColor(colors[8]);
 
1617
                alpha = colors[9].toDouble();
 
1618
                if ((int)colors.count() == 11)
 
1619
            setDataColorMap(colors[10]);
 
1620
        else
 
1621
                    setDataColors(min,max);
 
1622
        }
 
1623
}
 
1624
 
 
1625
void Graph3D::updateColors(const QColor& meshColor,const QColor& axesColor,const QColor& numColor,
 
1626
                const QColor& labelColor,const QColor& bgColor,const QColor& gridColor)
 
1627
{
 
1628
        if (meshCol != meshColor)
 
1629
        {
 
1630
                sp->setMeshColor(Qt2GL(meshColor));
 
1631
                meshCol=meshColor;
 
1632
        }
 
1633
 
 
1634
        if(axesCol != axesColor)
 
1635
        {
 
1636
                sp->coordinates()->setAxesColor(Qt2GL(axesColor));
 
1637
                axesCol=axesColor;
 
1638
        }
 
1639
 
 
1640
        if(numCol !=numColor)
 
1641
        {
 
1642
                sp->coordinates()->setNumberColor(Qt2GL(numColor));
 
1643
                numCol=numColor;
 
1644
        }
 
1645
 
 
1646
        if(labelsCol !=labelColor)
 
1647
        {
 
1648
                sp->coordinates()->setLabelColor(Qt2GL(labelColor));
 
1649
                labelsCol=labelColor;
 
1650
        }
 
1651
 
 
1652
        if(bgCol !=bgColor)
 
1653
        {
 
1654
                sp->setBackgroundColor(Qt2GL(bgColor));
 
1655
                bgCol=bgColor;
 
1656
        }
 
1657
 
 
1658
        if(gridCol !=gridColor)
 
1659
        {
 
1660
                sp->coordinates()->setGridLinesColor(Qt2GL(gridColor));
 
1661
                gridCol=gridColor;
 
1662
        }
 
1663
 
 
1664
        sp->updateData();
 
1665
        sp->updateGL();
 
1666
        emit modified();
 
1667
}
 
1668
 
 
1669
void Graph3D::scaleFonts(double factor)
 
1670
{
 
1671
        QFont font = sp->coordinates()->axes[X1].numberFont();
 
1672
        font.setPointSizeF(font.pointSizeF()*factor);
 
1673
        sp->coordinates()->setNumberFont (font);
 
1674
 
 
1675
        titleFnt.setPointSizeF(factor*titleFnt.pointSizeF());
 
1676
        sp->setTitleFont(titleFnt.family(),titleFnt.pointSize(),titleFnt.weight(),titleFnt.italic());
 
1677
 
 
1678
        font = xAxisLabelFont();
 
1679
        font.setPointSizeF(factor*font.pointSizeF());
 
1680
        setXAxisLabelFont(font);
 
1681
 
 
1682
        font = yAxisLabelFont();
 
1683
        font.setPointSizeF(factor*font.pointSizeF());
 
1684
        setYAxisLabelFont(font);
 
1685
 
 
1686
        font = zAxisLabelFont();
 
1687
        font.setPointSizeF(factor*font.pointSizeF());
 
1688
        setZAxisLabelFont(font);
 
1689
}
 
1690
 
 
1691
void Graph3D::resizeEvent ( QResizeEvent *e)
 
1692
{
 
1693
        QSize size=e->size();
 
1694
 
 
1695
        sp->makeCurrent();
 
1696
        sp->resize(size);
 
1697
 
 
1698
        if (!ignoreFonts && this->isVisible())
 
1699
        {
 
1700
                QSize oldSize=e->oldSize();
 
1701
                double ratio=(double)size.height()/(double)oldSize.height();
 
1702
                scaleFonts(ratio);
 
1703
        }
 
1704
 
 
1705
        sp->updateGL();
 
1706
        emit resizedWindow(this);
 
1707
        emit modified();
 
1708
}
 
1709
 
 
1710
void Graph3D::contextMenuEvent(QContextMenuEvent *e)
 
1711
{
 
1712
        emit showContextMenu();
 
1713
        e->accept();
 
1714
}
 
1715
 
 
1716
void Graph3D::setFramed()
 
1717
{
 
1718
        if (sp->coordinates()->style() == FRAME)
 
1719
                return;
 
1720
 
 
1721
        sp->makeCurrent();
 
1722
        sp->setCoordinateStyle(FRAME);
 
1723
}
 
1724
 
 
1725
void Graph3D::setBoxed()
 
1726
{
 
1727
        if (sp->coordinates()->style() == BOX)
 
1728
                return;
 
1729
 
 
1730
        sp->makeCurrent();
 
1731
        sp->setCoordinateStyle(BOX);
 
1732
}
 
1733
 
 
1734
void Graph3D::setNoAxes()
 
1735
{
 
1736
        if (sp->coordinates()->style() == NOCOORD)
 
1737
                return;
 
1738
 
 
1739
        sp->makeCurrent();
 
1740
        sp->setCoordinateStyle(NOCOORD);
 
1741
}
 
1742
 
 
1743
void Graph3D::setNoGrid()
 
1744
{
 
1745
        if (sp->plotStyle() == FILLED)
 
1746
                return;
 
1747
 
 
1748
        sp->makeCurrent();
 
1749
        sp->setPlotStyle(FILLED);
 
1750
        sp->updateData();
 
1751
        sp->updateGL();
 
1752
 
 
1753
        style_=FILLED;
 
1754
        pointStyle = None;
 
1755
}
 
1756
 
 
1757
void Graph3D::setFilledMesh()
 
1758
{
 
1759
        if (sp->plotStyle() == FILLEDMESH)
 
1760
                return;
 
1761
 
 
1762
        sp->makeCurrent();
 
1763
        sp->setPlotStyle(FILLEDMESH);
 
1764
        sp->updateData();
 
1765
        sp->updateGL();
 
1766
 
 
1767
        style_=FILLEDMESH;
 
1768
        pointStyle = None;
 
1769
}
 
1770
 
 
1771
void Graph3D::setHiddenLineGrid()
 
1772
{
 
1773
        if (sp->plotStyle() == HIDDENLINE)
 
1774
                return;
 
1775
 
 
1776
        sp->makeCurrent();
 
1777
        sp->setPlotStyle(HIDDENLINE);
 
1778
        sp->showColorLegend(false);
 
1779
        sp->updateData();
 
1780
        sp->updateGL();
 
1781
 
 
1782
        style_=HIDDENLINE;
 
1783
        pointStyle = None;
 
1784
        legendOn=false;
 
1785
}
 
1786
 
 
1787
void Graph3D::setLineGrid()
 
1788
{
 
1789
        if (sp->plotStyle() == WIREFRAME)
 
1790
                return;
 
1791
 
 
1792
        sp->makeCurrent();
 
1793
        sp->setPlotStyle(WIREFRAME);
 
1794
        sp->showColorLegend(false);
 
1795
        sp->updateData();
 
1796
        sp->updateGL();
 
1797
 
 
1798
        pointStyle = None;
 
1799
        style_=WIREFRAME;
 
1800
        legendOn=false;
 
1801
}
 
1802
 
 
1803
void Graph3D::setPointsMesh()
 
1804
{
 
1805
        if (!sp  || pointStyle == Dots)
 
1806
                return;
 
1807
 
 
1808
        pointStyle=Dots;
 
1809
        style_=Qwt3D::USER;
 
1810
 
 
1811
        sp->makeCurrent();
 
1812
        sp->setPlotStyle(Dot(pointSize, smooth));
 
1813
        sp->updateData();
 
1814
        sp->updateGL();
 
1815
}
 
1816
 
 
1817
void Graph3D::setConesMesh()
 
1818
{
 
1819
        if (!sp  || pointStyle == Cones )
 
1820
                return;
 
1821
 
 
1822
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 
1823
 
 
1824
        pointStyle=Cones;
 
1825
        style_=Qwt3D::USER;
 
1826
 
 
1827
        sp->makeCurrent();
 
1828
        sp->setPlotStyle(Cone3D(conesRad,conesQuality));
 
1829
        sp->updateData();
 
1830
        sp->updateGL();
 
1831
 
 
1832
        QApplication::restoreOverrideCursor();
 
1833
}
 
1834
 
 
1835
void Graph3D::setCrossMesh()
 
1836
{
 
1837
        if (!sp || pointStyle == HairCross)
 
1838
                return;
 
1839
 
 
1840
        pointStyle=HairCross;
 
1841
        style_=Qwt3D::USER;
 
1842
 
 
1843
        sp->makeCurrent();
 
1844
        sp->setPlotStyle(CrossHair(crossHairRad, crossHairLineWidth,crossHairSmooth,crossHairBoxed));
 
1845
        sp->updateData();
 
1846
        sp->updateGL();
 
1847
}
 
1848
 
 
1849
void Graph3D::clearData()
 
1850
{
 
1851
        if (d_matrix)
 
1852
                d_matrix = 0;
 
1853
        else if (worksheet)
 
1854
                worksheet = 0;
 
1855
        else if (func)
 
1856
        {
 
1857
                delete func;
 
1858
                func = 0;
 
1859
        }
 
1860
        plotAssociation = QString();
 
1861
 
 
1862
        sp->makeCurrent();
 
1863
        sp->loadFromData (0, 0, 0, false, false);
 
1864
        sp->updateData();
 
1865
        sp->updateGL();
 
1866
}
 
1867
 
 
1868
void Graph3D::setBarsPlot()
 
1869
{
 
1870
        if (pointStyle == VerticalBars)
 
1871
                return;
 
1872
 
 
1873
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 
1874
 
 
1875
        pointStyle=VerticalBars;
 
1876
        style_=Qwt3D::USER;
 
1877
 
 
1878
        sp->makeCurrent();
 
1879
        sp->setPlotStyle(Bar(barsRad));
 
1880
        sp->updateData();
 
1881
        sp->updateGL();
 
1882
        QApplication::restoreOverrideCursor();
 
1883
}
 
1884
 
 
1885
void Graph3D::setFloorData()
 
1886
{
 
1887
        if (sp->floorStyle() == FLOORDATA)
 
1888
                return;
 
1889
 
 
1890
        sp->makeCurrent();
 
1891
        sp->setFloorStyle(FLOORDATA);
 
1892
        sp->updateData();
 
1893
        sp->updateGL();
 
1894
}
 
1895
 
 
1896
void Graph3D::setFloorIsolines()
 
1897
{
 
1898
        if (sp->floorStyle() == FLOORISO)
 
1899
                return;
 
1900
 
 
1901
        sp->makeCurrent();
 
1902
        sp->setFloorStyle(FLOORISO);
 
1903
        sp->updateData();
 
1904
        sp->updateGL();
 
1905
}
 
1906
 
 
1907
void Graph3D::setEmptyFloor()
 
1908
{
 
1909
        if (sp->floorStyle() == NOFLOOR)
 
1910
                return;
 
1911
 
 
1912
        sp->makeCurrent();
 
1913
        sp->setFloorStyle(NOFLOOR);
 
1914
        sp->updateData();
 
1915
        sp->updateGL();
 
1916
}
 
1917
 
 
1918
void Graph3D::setMeshLineWidth(int lw)
 
1919
{
 
1920
        if ((int)sp->meshLineWidth() == lw)
 
1921
                return;
 
1922
 
 
1923
        sp->makeCurrent();
 
1924
        sp->setMeshLineWidth((double)lw);
 
1925
        sp->updateData();
 
1926
        sp->updateGL();
 
1927
}
 
1928
 
 
1929
int Graph3D::grids()
 
1930
{
 
1931
        return sp->coordinates()->grids();
 
1932
}
 
1933
 
 
1934
void Graph3D::setGrid(Qwt3D::SIDE s, bool b)
 
1935
{
 
1936
        if (!sp)
 
1937
                return;
 
1938
 
 
1939
        int sum = sp->coordinates()->grids();
 
1940
 
 
1941
        if (b)
 
1942
                sum |= s;
 
1943
        else
 
1944
                sum &= ~s;
 
1945
 
 
1946
        sp->coordinates()->setGridLines(sum!=Qwt3D::NOSIDEGRID, false, sum);
 
1947
        sp->updateGL();
 
1948
        emit modified();
 
1949
}
 
1950
 
 
1951
void Graph3D::setGrid(int grids)
 
1952
{
 
1953
        if (!sp)
 
1954
                return;
 
1955
 
 
1956
        sp->coordinates()->setGridLines(true, false,grids);
 
1957
}
 
1958
 
 
1959
void Graph3D::setLeftGrid(bool b)
 
1960
{
 
1961
        setGrid(Qwt3D::LEFT,b);
 
1962
}
 
1963
void Graph3D::setRightGrid(bool b)
 
1964
{
 
1965
        setGrid(Qwt3D::RIGHT,b);
 
1966
}
 
1967
void Graph3D::setCeilGrid(bool b)
 
1968
{
 
1969
        setGrid(Qwt3D::CEIL,b);
 
1970
}
 
1971
void Graph3D::setFloorGrid(bool b)
 
1972
{
 
1973
        setGrid(Qwt3D::FLOOR,b);
 
1974
}
 
1975
void Graph3D::setFrontGrid(bool b)
 
1976
{
 
1977
        setGrid(Qwt3D::FRONT,b);
 
1978
}
 
1979
void Graph3D::setBackGrid(bool b)
 
1980
{
 
1981
        setGrid(Qwt3D::BACK,b);
 
1982
}
 
1983
 
 
1984
void Graph3D::print()
 
1985
{
 
1986
        QPrinter printer;
 
1987
        printer.setOrientation(QPrinter::Landscape);
 
1988
        printer.setColorMode (QPrinter::Color);
 
1989
        printer.setFullPage(false);
 
1990
 
 
1991
        if (printer.setup())
 
1992
        {
 
1993
                if (IO::save (sp,"scidavis.png","PNG"))
 
1994
                {
 
1995
                        QPixmap p;
 
1996
                        p.load ("scidavis.png","PNG", QPixmap::Color );
 
1997
 
 
1998
                        QPainter paint(&printer);
 
1999
                        paint.drawPixmap(QPoint(0,0),p);
 
2000
                        paint.end();
 
2001
 
 
2002
                        QFile f("scidavis.png");
 
2003
                        f.remove();
 
2004
                }
 
2005
                else
 
2006
                        QMessageBox::about(0,tr("IO Error"),
 
2007
                                        tr("Could not print: <h4>" + QString(name()) + "</h4>."));
 
2008
        }
 
2009
}
 
2010
 
 
2011
void Graph3D::copyImage()
 
2012
{
 
2013
    QApplication::clipboard()->setPixmap(sp->renderPixmap(), QClipboard::Clipboard);
 
2014
    sp->updateData();
 
2015
}
 
2016
 
 
2017
void Graph3D::exportImage(const QString& fileName, int quality, bool transparent)
 
2018
{
 
2019
        if (transparent)
 
2020
        {
 
2021
        QPixmap pic = sp->renderPixmap();
 
2022
        sp->updateData();
 
2023
 
 
2024
        QBitmap mask(pic.size());
 
2025
                mask.fill(Qt::color1);
 
2026
                QPainter p;
 
2027
                p.begin(&mask);
 
2028
                p.setPen(Qt::color0);
 
2029
 
 
2030
                QColor background = QColor (Qt::white);
 
2031
                QRgb backgroundPixel = background.rgb ();
 
2032
                QImage image = pic.convertToImage();
 
2033
                for (int y=0; y<image.height(); y++)
 
2034
                {
 
2035
                        for ( int x=0; x<image.width(); x++ )
 
2036
                        {
 
2037
                                QRgb rgb = image.pixel(x, y);
 
2038
                                if (rgb == backgroundPixel) // we want the frame transparent
 
2039
                                        p.drawPoint( x, y );
 
2040
                        }
 
2041
                }
 
2042
                p.end();
 
2043
                pic.setMask(mask);
 
2044
                pic.save(fileName, 0, quality);
 
2045
        }
 
2046
    else
 
2047
    {
 
2048
        QImage im = sp->grabFrameBuffer(true);
 
2049
        QImageWriter iw(fileName);
 
2050
        iw.setQuality(quality);
 
2051
        iw.write(im);
 
2052
    }
 
2053
}
 
2054
 
 
2055
void Graph3D::exportPDF(const QString& fileName)
 
2056
{
 
2057
        exportVector(fileName);
 
2058
}
 
2059
 
 
2060
void Graph3D::exportVector(const QString& fileName, const QString& fileType)
 
2061
{
 
2062
        if ( fileName.isEmpty() )
 
2063
        {
 
2064
                QMessageBox::critical(0, tr("Error"), tr("Please provide a valid file name!"));
 
2065
        return;
 
2066
        }
 
2067
 
 
2068
    QString format = fileType;
 
2069
    format = format.toUpper();
 
2070
 
 
2071
    VectorWriter * gl2ps = (VectorWriter*)IO::outputHandler(format);
 
2072
    if (gl2ps)
 
2073
    {
 
2074
      gl2ps->setTextMode(VectorWriter::NATIVE);
 
2075
    }
 
2076
    IO::save(sp, fileName, format);
 
2077
}
 
2078
 
 
2079
bool Graph3D::eventFilter(QObject *object, QEvent *e)
 
2080
{
 
2081
        if (e->type() == QEvent::MouseButtonDblClick && object == (QObject *)this->sp)
 
2082
        {
 
2083
                emit showOptionsDialog();
 
2084
                return TRUE;
 
2085
        }
 
2086
        return MyWidget::eventFilter(object, e);
 
2087
}
 
2088
 
 
2089
void Graph3D::setPointOptions(double size, bool s)
 
2090
{
 
2091
        if (pointSize == size && smooth == s)
 
2092
                return;
 
2093
 
 
2094
        pointSize = size;
 
2095
        smooth = s;
 
2096
}
 
2097
 
 
2098
double Graph3D::barsRadius()
 
2099
{
 
2100
        if (sp->plotStyle() == Qwt3D::USER && sp->plotStyle() != Qwt3D::POINTS)
 
2101
                return barsRad;
 
2102
        else
 
2103
                return 0.0;
 
2104
}
 
2105
 
 
2106
void Graph3D::setBarsRadius(double rad)
 
2107
{
 
2108
        if (barsRad == rad)
 
2109
                return;
 
2110
 
 
2111
        barsRad = rad;
 
2112
}
 
2113
 
 
2114
void Graph3D::updateBars(double rad)
 
2115
{
 
2116
        if (barsRad == rad)
 
2117
                return;
 
2118
 
 
2119
        barsRad = rad;
 
2120
        sp->setPlotStyle(Bar(barsRad));
 
2121
        update();
 
2122
}
 
2123
 
 
2124
void Graph3D::updatePoints(double size, bool sm)
 
2125
{
 
2126
        if (pointStyle == Dots && pointSize == size && smooth == sm)
 
2127
                return;
 
2128
 
 
2129
        pointSize = size;
 
2130
        smooth = sm;
 
2131
        pointStyle = Dots;
 
2132
 
 
2133
        Dot d(pointSize, smooth);
 
2134
        sp->setPlotStyle(d);
 
2135
 
 
2136
        update();
 
2137
        emit modified();
 
2138
        emit custom3DActions(this);
 
2139
}
 
2140
 
 
2141
void Graph3D::updateCones(double rad, int quality)
 
2142
{
 
2143
        if (pointStyle == Cones && conesRad == rad && conesQuality == quality)
 
2144
                return;
 
2145
 
 
2146
        conesRad = rad;
 
2147
        conesQuality = quality;
 
2148
        pointStyle = Cones;
 
2149
        sp->setPlotStyle(Cone3D(conesRad,conesQuality));
 
2150
        update();
 
2151
        emit modified();
 
2152
        emit custom3DActions(this);
 
2153
}
 
2154
 
 
2155
void Graph3D::setConesOptions(double rad, int quality)
 
2156
{
 
2157
        conesRad = rad;
 
2158
        conesQuality = quality;
 
2159
}
 
2160
 
 
2161
void Graph3D::updateCross(double rad, double linewidth, bool smooth, bool boxed)
 
2162
{
 
2163
        if (pointStyle == HairCross && crossHairRad == rad &&
 
2164
                        crossHairSmooth == smooth && crossHairBoxed == boxed &&
 
2165
                        crossHairLineWidth == linewidth)
 
2166
                return;
 
2167
 
 
2168
        crossHairRad = rad;
 
2169
        crossHairLineWidth=linewidth;
 
2170
        crossHairSmooth = smooth;
 
2171
        crossHairBoxed = boxed;
 
2172
        pointStyle = HairCross;
 
2173
 
 
2174
        sp->setPlotStyle(CrossHair(rad,linewidth, smooth, boxed));
 
2175
        update();
 
2176
        emit modified();
 
2177
        emit custom3DActions(this);
 
2178
}
 
2179
 
 
2180
void Graph3D::setCrossOptions(double rad, double linewidth, bool smooth, bool boxed)
 
2181
{
 
2182
        crossHairRad = rad ;
 
2183
        crossHairLineWidth=linewidth;
 
2184
        crossHairSmooth = smooth;
 
2185
        crossHairBoxed = boxed;
 
2186
}
 
2187
 
 
2188
void Graph3D::setStyle(Qwt3D::COORDSTYLE coord,Qwt3D::FLOORSTYLE floor,
 
2189
                Qwt3D::PLOTSTYLE plot, Graph3D::PointStyle point)
 
2190
{
 
2191
        sp->setCoordinateStyle(coord);
 
2192
        sp->setFloorStyle(floor);
 
2193
 
 
2194
        if (point == None)
 
2195
                sp->setPlotStyle(plot);
 
2196
        else if (point == VerticalBars)
 
2197
                sp->setPlotStyle(Bar(barsRad));
 
2198
        else if (point == Dots)
 
2199
                sp->setPlotStyle(Dot(pointSize, smooth));
 
2200
        else if (point == HairCross)
 
2201
                sp->setPlotStyle(CrossHair(crossHairRad, crossHairLineWidth, crossHairSmooth, crossHairBoxed));
 
2202
        else if (point == Cones)
 
2203
                sp->setPlotStyle(Cone3D(conesRad, conesQuality));
 
2204
 
 
2205
        pointStyle=point;
 
2206
        style_=sp->plotStyle() ;
 
2207
}
 
2208
 
 
2209
void Graph3D::customPlotStyle(int style)
 
2210
{
 
2211
        sp->makeCurrent();
 
2212
        if (sp->plotStyle() == style)
 
2213
                return;
 
2214
 
 
2215
        switch (style)
 
2216
        {
 
2217
                case WIREFRAME  :
 
2218
                        {
 
2219
                                sp->setPlotStyle(WIREFRAME  );
 
2220
                                style_= WIREFRAME ;
 
2221
                                pointStyle = None;
 
2222
 
 
2223
                                legendOn = false;
 
2224
                                sp->showColorLegend(legendOn);
 
2225
                                break;
 
2226
                        }
 
2227
 
 
2228
                case FILLED :
 
2229
                        {
 
2230
                                sp->setPlotStyle(FILLED );
 
2231
                                style_= FILLED;
 
2232
                                pointStyle = None;
 
2233
                                break;
 
2234
                        }
 
2235
 
 
2236
                case FILLEDMESH  :
 
2237
                        {
 
2238
                                sp->setPlotStyle(FILLEDMESH);
 
2239
                                style_= FILLEDMESH;
 
2240
                                pointStyle = None;
 
2241
                                break;
 
2242
                        }
 
2243
 
 
2244
                case HIDDENLINE:
 
2245
                        {
 
2246
                                sp->setPlotStyle(HIDDENLINE);
 
2247
                                style_= HIDDENLINE;
 
2248
                                pointStyle = None;
 
2249
                                legendOn = false;
 
2250
                                sp->showColorLegend(legendOn);
 
2251
                                break;
 
2252
                        }
 
2253
 
 
2254
                case Qwt3D::POINTS:
 
2255
                        {
 
2256
                                pointSize = 0.5;
 
2257
                                smooth = true;
 
2258
                                pointStyle=Dots;
 
2259
                                style_ = Qwt3D::USER;
 
2260
 
 
2261
                                Dot d(pointSize, smooth);
 
2262
                                sp->setPlotStyle(d);
 
2263
                                break;
 
2264
                        }
 
2265
 
 
2266
                case Qwt3D::USER:
 
2267
                        {
 
2268
                                pointStyle = VerticalBars;
 
2269
                                style_ = Qwt3D::USER;
 
2270
                                sp->setPlotStyle(Bar(barsRad));
 
2271
                                break;
 
2272
                        }
 
2273
        }
 
2274
 
 
2275
        sp->updateData();
 
2276
        sp->updateGL();
 
2277
}
 
2278
 
 
2279
void Graph3D::setStyle(const QStringList& st)
 
2280
{
 
2281
        if (st[1] =="nocoord")
 
2282
                sp->setCoordinateStyle(NOCOORD);
 
2283
        else if (st[1] =="frame")
 
2284
                sp->setCoordinateStyle(FRAME);
 
2285
        else if (st[1] =="box")
 
2286
                sp->setCoordinateStyle(BOX);
 
2287
 
 
2288
        if (st[2] =="nofloor")
 
2289
                sp->setFloorStyle(NOFLOOR);
 
2290
        else if (st[2] =="flooriso")
 
2291
                sp->setFloorStyle(FLOORISO);
 
2292
        else if (st[2] =="floordata")
 
2293
                sp->setFloorStyle(FLOORDATA);
 
2294
 
 
2295
        if (st[3] =="filledmesh")
 
2296
                sp->setPlotStyle(FILLEDMESH);
 
2297
        else if (st[3] =="filled")
 
2298
                sp->setPlotStyle(FILLED);
 
2299
        else if (st[3] =="points")
 
2300
        {
 
2301
                pointSize = st[4].toDouble();
 
2302
 
 
2303
                smooth=false;
 
2304
                if (st[5] == "1")
 
2305
                        smooth=true;
 
2306
 
 
2307
                sp->setPlotStyle(Dot(pointSize, smooth));
 
2308
                pointStyle = Dots;
 
2309
        }
 
2310
        else if (st[3] =="wireframe")
 
2311
                sp->setPlotStyle(WIREFRAME);
 
2312
        else if (st[3] =="hiddenline")
 
2313
                sp->setPlotStyle(HIDDENLINE);
 
2314
        else if (st[3] =="bars")
 
2315
        {
 
2316
                barsRad = (st[4]).toDouble();
 
2317
                sp->setPlotStyle(Bar(barsRad));
 
2318
                pointStyle = VerticalBars;
 
2319
        }
 
2320
        else if (st[3] =="cones")
 
2321
        {
 
2322
                conesRad = (st[4]).toDouble();
 
2323
                conesQuality = (st[5]).toInt();
 
2324
 
 
2325
                sp->setPlotStyle(Cone3D(conesRad, conesQuality));
 
2326
                pointStyle = Cones;
 
2327
        }
 
2328
        else if (st[3] =="cross")
 
2329
        {
 
2330
                crossHairRad = (st[4]).toDouble();
 
2331
                crossHairLineWidth = (st[5]).toDouble();
 
2332
 
 
2333
                crossHairSmooth=false;
 
2334
                if (st[6] == "1")
 
2335
                        crossHairSmooth=true;
 
2336
 
 
2337
                crossHairBoxed=false;
 
2338
                if (st[7] == "1")
 
2339
                        crossHairBoxed=true;
 
2340
 
 
2341
                sp->setPlotStyle(CrossHair(crossHairRad, crossHairLineWidth, crossHairSmooth, crossHairBoxed));
 
2342
                pointStyle = HairCross;
 
2343
        }
 
2344
 
 
2345
        style_ = sp->plotStyle() ;
 
2346
}
 
2347
 
 
2348
void Graph3D::setRotation(double  xVal,double  yVal,double  zVal)
 
2349
{
 
2350
        sp->setRotation(xVal,yVal,zVal);
 
2351
}
 
2352
 
 
2353
void Graph3D::setScale(double  xVal,double  yVal,double  zVal)
 
2354
{
 
2355
        sp->setScale(xVal,yVal,zVal);
 
2356
}
 
2357
 
 
2358
void Graph3D::setShift(double  xVal,double  yVal,double  zVal)
 
2359
{
 
2360
        sp->setShift(xVal,yVal,zVal);
 
2361
}
 
2362
 
 
2363
void Graph3D::setZoom(double  val)
 
2364
{
 
2365
        sp->setZoom(val);
 
2366
}
 
2367
 
 
2368
void Graph3D::updateZoom(double  val)
 
2369
{
 
2370
        if (sp->zoom() == val)
 
2371
                return;
 
2372
 
 
2373
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 
2374
 
 
2375
        sp->makeCurrent();
 
2376
        sp->setZoom(val);
 
2377
        sp->updateData();
 
2378
        sp->updateGL();
 
2379
 
 
2380
        QApplication::restoreOverrideCursor();
 
2381
}
 
2382
 
 
2383
void Graph3D::updateScaling(double  xVal,double  yVal,double  zVal)
 
2384
{
 
2385
        if (sp->xScale() == xVal && sp->yScale() == yVal && sp->zScale() == zVal)
 
2386
                return;
 
2387
 
 
2388
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 
2389
 
 
2390
        sp->setScale(xVal,yVal,zVal);
 
2391
        sp->updateData();
 
2392
        sp->updateGL();
 
2393
 
 
2394
        QApplication::restoreOverrideCursor();
 
2395
}
 
2396
 
 
2397
Qwt3D::PLOTSTYLE Graph3D::plotStyle()
 
2398
{
 
2399
        return sp->plotStyle();
 
2400
}
 
2401
 
 
2402
Qwt3D::FLOORSTYLE Graph3D::floorStyle()
 
2403
{
 
2404
        return sp->floorStyle();
 
2405
}
 
2406
 
 
2407
Qwt3D::COORDSTYLE Graph3D::coordStyle()
 
2408
{
 
2409
        return sp->coordinates()->style();
 
2410
}
 
2411
 
 
2412
QString Graph3D::formula()
 
2413
{
 
2414
        if (func)
 
2415
                return func->function();
 
2416
        else
 
2417
                return plotAssociation;
 
2418
}
 
2419
 
 
2420
QString Graph3D::saveToString(const QString& geometry)
 
2421
{
 
2422
        QString s="<SurfacePlot>\n";
 
2423
        s+= QString(name())+"\t";
 
2424
        s+= birthDate() + "\n";
 
2425
        s+= geometry;
 
2426
        s+= "SurfaceFunction\t";
 
2427
 
 
2428
        sp->makeCurrent();
 
2429
        if (func)
 
2430
                s+=func->function()+"\t";
 
2431
        else
 
2432
        {
 
2433
                s+= plotAssociation;
 
2434
                s+="\t";
 
2435
        }
 
2436
 
 
2437
        double start,stop;
 
2438
        sp->coordinates()->axes[X1].limits(start,stop);
 
2439
        s+=QString::number(start)+"\t";
 
2440
        s+=QString::number(stop)+"\t";
 
2441
        sp->coordinates()->axes[Y1].limits(start,stop);
 
2442
        s+=QString::number(start)+"\t";
 
2443
        s+=QString::number(stop)+"\t";
 
2444
        sp->coordinates()->axes[Z1].limits(start,stop);
 
2445
        s+=QString::number(start)+"\t";
 
2446
        s+=QString::number(stop)+"\n";
 
2447
 
 
2448
        QString st;
 
2449
        if (sp->coordinates()->style() == Qwt3D::NOCOORD)
 
2450
                st="nocoord";
 
2451
        else if (sp->coordinates()->style() == Qwt3D::BOX)
 
2452
                st="box";
 
2453
        else
 
2454
                st="frame";
 
2455
        s+="Style\t"+st+"\t";
 
2456
 
 
2457
        switch(sp->floorStyle ())
 
2458
        {
 
2459
                case NOFLOOR:
 
2460
                        st="nofloor";
 
2461
                        break;
 
2462
 
 
2463
                case FLOORISO:
 
2464
                        st="flooriso";
 
2465
                        break;
 
2466
 
 
2467
                case FLOORDATA:
 
2468
                        st="floordata";
 
2469
                        break;
 
2470
        }
 
2471
        s+=st+"\t";
 
2472
 
 
2473
        switch(sp->plotStyle())
 
2474
        {
 
2475
                case USER:
 
2476
                        if (pointStyle == VerticalBars)
 
2477
                                st="bars\t"+QString::number(barsRad);
 
2478
                        else if (pointStyle == Dots)
 
2479
                        {
 
2480
                                st="points\t"+QString::number(pointSize);
 
2481
                                st+="\t"+QString::number(smooth);
 
2482
                        }
 
2483
                        else if (pointStyle == Cones)
 
2484
                        {
 
2485
                                st="cones\t"+QString::number(conesRad);
 
2486
                                st+="\t"+QString::number(conesQuality);
 
2487
                        }
 
2488
                        else if (pointStyle == HairCross)
 
2489
                        {
 
2490
                                st="cross\t"+QString::number(crossHairRad);
 
2491
                                st+="\t"+QString::number(crossHairLineWidth);
 
2492
                                st+="\t"+QString::number(crossHairSmooth);
 
2493
                                st+="\t"+QString::number(crossHairBoxed);
 
2494
                        }
 
2495
                        break;
 
2496
 
 
2497
                case WIREFRAME:
 
2498
                        st="wireframe";
 
2499
                        break;
 
2500
 
 
2501
                case HIDDENLINE:
 
2502
                        st="hiddenline";
 
2503
                        break;
 
2504
 
 
2505
                case FILLED:
 
2506
                        st="filled";
 
2507
                        break;
 
2508
 
 
2509
                case FILLEDMESH:
 
2510
                        st="filledmesh";
 
2511
                        break;
 
2512
 
 
2513
                default:
 
2514
                        ;
 
2515
        }
 
2516
        s+=st+"\n";
 
2517
 
 
2518
        s+="grids\t";
 
2519
        s+=QString::number(sp->coordinates()->grids())+"\n";
 
2520
 
 
2521
        s+="title\t";
 
2522
        s+=title+"\t";
 
2523
        s+=titleCol.name()+"\t";
 
2524
        s+=titleFnt.family()+"\t";
 
2525
        s+=QString::number(titleFnt.pointSize())+"\t";
 
2526
        s+=QString::number(titleFnt.weight())+"\t";
 
2527
        s+=QString::number(titleFnt.italic())+"\n";
 
2528
 
 
2529
        s+="colors\t";
 
2530
        s+=meshCol.name()+"\t";
 
2531
        s+=axesCol.name()+"\t";
 
2532
        s+=numCol.name()+"\t";
 
2533
        s+=labelsCol.name()+"\t";
 
2534
        s+=bgCol.name()+"\t";
 
2535
        s+=gridCol.name()+"\t";
 
2536
        s+=fromColor.name()+"\t";
 
2537
        s+=toColor.name()+"\t";
 
2538
        s+=QString::number(alpha) + "\t" + color_map + "\n";
 
2539
 
 
2540
        s+="axesLabels\t";
 
2541
        s+=labels.join("\t")+"\n";
 
2542
 
 
2543
        s+="tics\t";
 
2544
        QStringList tl=scaleTicks();
 
2545
        s+=tl.join("\t")+"\n";
 
2546
 
 
2547
        s+="tickLengths\t";
 
2548
        tl=axisTickLengths();
 
2549
        s+=tl.join("\t")+"\n";
 
2550
 
 
2551
        s+="options\t";
 
2552
        s+=QString::number(legendOn)+"\t";
 
2553
        s+=QString::number(sp->resolution())+"\t";
 
2554
        s+=QString::number(labelsDist)+"\n";
 
2555
 
 
2556
        s+="numbersFont\t";
 
2557
        QFont fnt=sp->coordinates()->axes[X1].numberFont();
 
2558
        s+=fnt.family()+"\t";
 
2559
        s+=QString::number(fnt.pointSize())+"\t";
 
2560
        s+=QString::number(fnt.weight())+"\t";
 
2561
        s+=QString::number(fnt.italic())+"\n";
 
2562
 
 
2563
        s+="xAxisLabelFont\t";
 
2564
        fnt=sp->coordinates()->axes[X1].labelFont();
 
2565
        s+=fnt.family()+"\t";
 
2566
        s+=QString::number(fnt.pointSize())+"\t";
 
2567
        s+=QString::number(fnt.weight())+"\t";
 
2568
        s+=QString::number(fnt.italic())+"\n";
 
2569
 
 
2570
        s+="yAxisLabelFont\t";
 
2571
        fnt=sp->coordinates()->axes[Y1].labelFont();
 
2572
        s+=fnt.family()+"\t";
 
2573
        s+=QString::number(fnt.pointSize())+"\t";
 
2574
        s+=QString::number(fnt.weight())+"\t";
 
2575
        s+=QString::number(fnt.italic())+"\n";
 
2576
 
 
2577
        s+="zAxisLabelFont\t";
 
2578
        fnt=sp->coordinates()->axes[Z1].labelFont();
 
2579
        s+=fnt.family()+"\t";
 
2580
        s+=QString::number(fnt.pointSize())+"\t";
 
2581
        s+=QString::number(fnt.weight())+"\t";
 
2582
        s+=QString::number(fnt.italic())+"\n";
 
2583
 
 
2584
        s+="rotation\t";
 
2585
        s+=QString::number(sp->xRotation())+"\t";
 
2586
        s+=QString::number(sp->yRotation())+"\t";
 
2587
        s+=QString::number(sp->zRotation())+"\n";
 
2588
 
 
2589
        s+="zoom\t";
 
2590
        s+=QString::number(sp->zoom())+"\n";
 
2591
 
 
2592
        s+="scaling\t";
 
2593
        s+=QString::number(sp->xScale())+"\t";
 
2594
        s+=QString::number(sp->yScale())+"\t";
 
2595
        s+=QString::number(sp->zScale())+"\n";
 
2596
 
 
2597
        s+="shift\t";
 
2598
        s+=QString::number(sp->xShift())+"\t";
 
2599
        s+=QString::number(sp->yShift())+"\t";
 
2600
        s+=QString::number(sp->zShift())+"\n";
 
2601
 
 
2602
        s+="LineWidth\t";
 
2603
        s+=QString::number(sp->meshLineWidth())+"\n";
 
2604
        s+="WindowLabel\t" + windowLabel() + "\t" + QString::number(captionPolicy()) + "\n";
 
2605
        s+="Orthogonal\t" + QString::number(sp->ortho())+"\n";
 
2606
        s+="</SurfacePlot>\n";
 
2607
        return s;
 
2608
}
 
2609
 
 
2610
void Graph3D::showColorLegend(bool show)
 
2611
{
 
2612
        if (legendOn == show)
 
2613
                return;
 
2614
 
 
2615
        sp->makeCurrent();
 
2616
        sp->showColorLegend(show);
 
2617
 
 
2618
        legendOn=show;
 
2619
        sp->updateGL();
 
2620
        emit modified();
 
2621
}
 
2622
 
 
2623
void Graph3D::setResolution(int r)
 
2624
{
 
2625
        if (sp->resolution() == r)
 
2626
                return;
 
2627
 
 
2628
        sp->makeCurrent();
 
2629
        sp->setResolution(r);
 
2630
        sp->updateData();
 
2631
        sp->updateGL();
 
2632
        emit modified();
 
2633
}
 
2634
 
 
2635
void Graph3D::setTitle(const QStringList& lst)
 
2636
{
 
2637
        title=lst[1];
 
2638
        sp->setTitle(title);
 
2639
 
 
2640
        titleCol=QColor(lst[2]);
 
2641
        sp->setTitleColor(Qt2GL(titleCol));
 
2642
 
 
2643
        titleFnt=QFont(lst[3],lst[4].toInt(),lst[5].toInt(),lst[6].toInt());
 
2644
        sp->setTitleFont(titleFnt.family(),titleFnt.pointSize(),titleFnt.weight(),titleFnt.italic());
 
2645
}
 
2646
 
 
2647
void Graph3D::setTitle(const QString& s,const QColor& color,const QFont& font)
 
2648
{
 
2649
        if (title != s)
 
2650
        {
 
2651
                title=s;
 
2652
                sp->setTitle(title);
 
2653
        }
 
2654
 
 
2655
        titleCol=color;
 
2656
        sp->setTitleColor(Qt2GL(color));
 
2657
 
 
2658
        if (titleFnt != font)
 
2659
        {
 
2660
                titleFnt=font;
 
2661
                sp->setTitleFont(font.family(),font.pointSize(),font.weight(),font.italic());
 
2662
        }
 
2663
}
 
2664
 
 
2665
void Graph3D::updateTitle(const QString& s,const QColor& color,const QFont& font)
 
2666
{
 
2667
        if (title != s)
 
2668
        {
 
2669
                title=s;
 
2670
                sp->setTitle(title);
 
2671
        }
 
2672
 
 
2673
        titleCol=color;
 
2674
        sp->setTitleColor(Qt2GL(color));
 
2675
 
 
2676
        if (titleFnt != font)
 
2677
        {
 
2678
                titleFnt=font;
 
2679
                sp->setTitleFont(font.family(),font.pointSize(),font.weight(),font.italic());
 
2680
        }
 
2681
 
 
2682
        sp->makeCurrent();
 
2683
        sp->updateGL();
 
2684
        emit modified();
 
2685
}
 
2686
 
 
2687
void Graph3D::setTitleFont(const QFont& font)
 
2688
{
 
2689
        if (titleFnt != font)
 
2690
        {
 
2691
                titleFnt=font;
 
2692
                sp->setTitleFont(font.family(),font.pointSize(),font.weight(),font.italic());
 
2693
        }
 
2694
}
 
2695
 
 
2696
void Graph3D::setOptions(const QStringList& lst)
 
2697
{
 
2698
        legendOn=false;
 
2699
        if (lst[1].toInt() == 1)
 
2700
                legendOn=true;
 
2701
        sp->showColorLegend(legendOn);
 
2702
        sp->setResolution(lst[2].toInt());
 
2703
        adjustLabels(lst[3].toInt());
 
2704
}
 
2705
 
 
2706
 
 
2707
void Graph3D::setOptions(bool legend, int r, int dist)
 
2708
{
 
2709
        sp->showColorLegend(legend);
 
2710
        legendOn=legend;
 
2711
        sp->setResolution(r);
 
2712
        adjustLabels(dist);
 
2713
}
 
2714
 
 
2715
Qwt3D::Triple** Graph3D::allocateData(int columns, int rows)
 
2716
{
 
2717
        Qwt3D::Triple** data = new Qwt3D::Triple* [columns];
 
2718
 
 
2719
        for ( int i = 0; i < columns; ++i)
 
2720
        {
 
2721
                data[i] = new Qwt3D::Triple [rows];
 
2722
        }
 
2723
        return data;
 
2724
}
 
2725
 
 
2726
void Graph3D::deleteData(Qwt3D::Triple **data, int columns)
 
2727
{
 
2728
        for ( int i = 0; i < columns; i++)
 
2729
        {
 
2730
                delete [] data[i];
 
2731
        }
 
2732
        delete [] data;
 
2733
}
 
2734
 
 
2735
QColor Graph3D::minDataColor()
 
2736
{
 
2737
        return fromColor;
 
2738
}
 
2739
 
 
2740
QColor Graph3D::maxDataColor()
 
2741
{
 
2742
        return toColor;
 
2743
}
 
2744
 
 
2745
void Graph3D::setDataColors(const QColor& cMin, const QColor& cMax)
 
2746
{
 
2747
        if (cMin == fromColor && cMax == toColor)
 
2748
                return;
 
2749
 
 
2750
        fromColor=cMin;
 
2751
        toColor=cMax;
 
2752
 
 
2753
        Qwt3D::ColorVector cv;
 
2754
 
 
2755
        int size=255;
 
2756
        double dsize = size;
 
2757
 
 
2758
        double r1=cMax.red()/dsize;
 
2759
        double r2=cMin.red()/dsize;
 
2760
 
 
2761
        double stepR = (r1-r2)/dsize;
 
2762
 
 
2763
        double g1=cMax.green()/dsize;
 
2764
        double g2=cMin.green()/dsize;
 
2765
 
 
2766
        double stepG = (g1-g2)/dsize;
 
2767
 
 
2768
        double b1=cMax.blue()/dsize;
 
2769
        double b2=cMin.blue()/dsize;
 
2770
 
 
2771
        double stepB = (b1-b2)/dsize;
 
2772
 
 
2773
        RGBA rgb;
 
2774
        for (int i=0; i<size; i++)
 
2775
        {
 
2776
                rgb.r = r1-i*stepR;
 
2777
                rgb.g = g1-i*stepG;
 
2778
                rgb.b = b1-i*stepB;
 
2779
                rgb.a = alpha;
 
2780
 
 
2781
                cv.push_back(rgb);
 
2782
        }
 
2783
 
 
2784
        col_ = new StandardColor(sp);
 
2785
        col_->setColorVector(cv);
 
2786
        sp->setDataColor(col_);
 
2787
 
 
2788
        if (legendOn)
 
2789
        {
 
2790
                sp->showColorLegend(false);
 
2791
                sp->showColorLegend(legendOn);
 
2792
        }
 
2793
}
 
2794
 
 
2795
void Graph3D::changeTransparency(double t)
 
2796
{
 
2797
        if (alpha == t)
 
2798
                return;
 
2799
 
 
2800
        alpha = t;
 
2801
 
 
2802
        Qwt3D::StandardColor* color=(StandardColor*) sp->dataColor ();
 
2803
        color->setAlpha(t);
 
2804
 
 
2805
    sp->showColorLegend(legendOn);
 
2806
        sp->updateData();
 
2807
        sp->updateGL();
 
2808
        emit modified();
 
2809
}
 
2810
 
 
2811
void Graph3D::setTransparency(double t)
 
2812
{
 
2813
        if (alpha == t)
 
2814
                return;
 
2815
 
 
2816
        alpha = t;
 
2817
 
 
2818
        Qwt3D::StandardColor* color=(StandardColor*) sp->dataColor ();
 
2819
        color->setAlpha(t);
 
2820
}
 
2821
 
 
2822
void Graph3D::showWorksheet()
 
2823
{
 
2824
        if (worksheet)
 
2825
                worksheet->showMaximized();
 
2826
        else if (d_matrix)
 
2827
                d_matrix->showMaximized();
 
2828
}
 
2829
 
 
2830
void Graph3D::setSmoothMesh(bool smooth)
 
2831
{
 
2832
        if (smoothMesh == smooth)
 
2833
                return;
 
2834
 
 
2835
        smoothMesh = smooth;
 
2836
        sp->setSmoothMesh(smoothMesh);
 
2837
        sp->coordinates()->setLineSmooth(smoothMesh);
 
2838
        sp->updateData();
 
2839
        sp->updateGL();
 
2840
}
 
2841
 
 
2842
QString Graph3D::saveAsTemplate(const QString& geometryInfo)
 
2843
{
 
2844
        QString s = saveToString(geometryInfo);
 
2845
        QStringList lst = s.split("\n", QString::SkipEmptyParts);
 
2846
        QStringList l = lst[3].split("\t");
 
2847
        l[1] = QString();
 
2848
        lst[3] = l.join("\t");
 
2849
        return lst.join("\n");
 
2850
}
 
2851
 
 
2852
/*!
 
2853
Turns 3D animation on or off
 
2854
*/
 
2855
void Graph3D::animate(bool on)
 
2856
{
 
2857
if ( on )
 
2858
   d_timer->start( animation_redraw_wait ); // Wait this many msecs before redraw
 
2859
else
 
2860
    d_timer->stop();
 
2861
}
 
2862
 
 
2863
void Graph3D::rotate()
 
2864
{
 
2865
if (!sp)
 
2866
   return;
 
2867
 
 
2868
sp->setRotation(int(sp->xRotation() + 1) % 360, int(sp->yRotation() + 1) % 360, int(sp->zRotation() + 1) % 360);
 
2869
}
 
2870
 
 
2871
void Graph3D::setDataColorMap(const QString& fileName)
 
2872
{
 
2873
if (color_map == fileName)
 
2874
   return;
 
2875
 
 
2876
ColorVector cv;
 
2877
if (!openColorMap(cv, fileName))
 
2878
   return;
 
2879
 
 
2880
color_map = fileName;
 
2881
 
 
2882
col_ = new StandardColor(sp);
 
2883
col_->setColorVector(cv);
 
2884
 
 
2885
sp->setDataColor(col_);
 
2886
sp->updateData();
 
2887
sp->showColorLegend(legendOn);
 
2888
sp->updateGL();
 
2889
}
 
2890
 
 
2891
bool Graph3D::openColorMap(ColorVector& cv, QString fname)
 
2892
{
 
2893
if (fname.isEmpty())
 
2894
   return false;
 
2895
 
 
2896
using std::ifstream;
 
2897
ifstream file(QWT3DLOCAL8BIT(fname));
 
2898
if (!file)
 
2899
   return false;
 
2900
 
 
2901
RGBA rgb;
 
2902
cv.clear();
 
2903
 
 
2904
while ( file )
 
2905
      {
 
2906
      file >> rgb.r >> rgb.g >> rgb.b;
 
2907
      file.ignore(10000,'\n');
 
2908
      if (!file.good())
 
2909
         break;
 
2910
      else
 
2911
          {
 
2912
          rgb.a = 1;
 
2913
          rgb.r /= 255;
 
2914
          rgb.g /= 255;
 
2915
          rgb.b /= 255;
 
2916
          cv.push_back(rgb);
 
2917
          }
 
2918
      }
 
2919
return true;
 
2920
}
 
2921
 
 
2922
void Graph3D::findBestLayout()
 
2923
{
 
2924
        double start, end;
 
2925
        sp->coordinates()->axes[X1].limits (start, end);
 
2926
        double xScale = 1/fabs(end-start);
 
2927
 
 
2928
        sp->coordinates()->axes[Y1].limits (start, end);
 
2929
        double yScale = 1/fabs(end-start);
 
2930
 
 
2931
        sp->coordinates()->axes[Z1].limits (start, end);
 
2932
        double zScale = 1/fabs(end-start);
 
2933
 
 
2934
        double d = (sp->hull().maxVertex-sp->hull().minVertex).length();
 
2935
        sp->setScale(xScale, yScale, zScale);
 
2936
        sp->setZoom(d/sqrt(3));
 
2937
 
 
2938
        double majl = 0.1/yScale;
 
2939
        updateTickLength(0, majl, 0.6*majl);
 
2940
        majl = 0.1/xScale;
 
2941
        updateTickLength(1, majl, 0.6*majl);
 
2942
        updateTickLength(2, majl, 0.6*majl);
 
2943
}
 
2944
 
 
2945
void Graph3D::copy(Graph3D* g)
 
2946
{
 
2947
        if (!g)
 
2948
        return;
 
2949
 
 
2950
        Graph3D::PointStyle pt = g->pointType();
 
2951
        if (g->plotStyle() == Qwt3D::USER ){
 
2952
                switch (pt){
 
2953
                        case Graph3D::None :
 
2954
                                break;
 
2955
 
 
2956
                        case Graph3D::Dots :
 
2957
                                setPointOptions(g->pointsSize(), g->smoothPoints());
 
2958
                                break;
 
2959
 
 
2960
                        case Graph3D::VerticalBars :
 
2961
                                setBarsRadius(g->barsRadius());
 
2962
                                break;
 
2963
 
 
2964
                        case Graph3D::HairCross :
 
2965
                                setCrossOptions(g->crossHairRadius(), g->crossHairLinewidth(), g->smoothCrossHair(), g->boxedCrossHair());
 
2966
                                break;
 
2967
 
 
2968
                        case Graph3D::Cones :
 
2969
                                setConesOptions(g->coneRadius(), g->coneQuality());
 
2970
                                break;
 
2971
                }
 
2972
        }
 
2973
        setStyle(g->coordStyle(), g->floorStyle(), g->plotStyle(), pt);
 
2974
        setGrid(g->grids());
 
2975
        setTitle(g->plotTitle(),g->titleColor(),g->titleFont());
 
2976
        setTransparency(g->transparency());
 
2977
        if (!g->colorMap().isEmpty())
 
2978
                setDataColorMap(g->colorMap());
 
2979
        else
 
2980
                setDataColors(g->minDataColor(),g->maxDataColor());
 
2981
        
 
2982
        setColors(g->meshColor(),g->axesColor(),g->numColor(),
 
2983
                                g->labelColor(), g->bgColor(),g->gridColor());
 
2984
        setAxesLabels(g->axesLabels());
 
2985
        setTicks(g->scaleTicks());
 
2986
        setTickLengths(g->axisTickLengths());
 
2987
        setOptions(g->isLegendOn(), g->resolution(),g->labelsDistance());
 
2988
        setNumbersFont(g->numbersFont());
 
2989
        setXAxisLabelFont(g->xAxisLabelFont());
 
2990
        setYAxisLabelFont(g->yAxisLabelFont());
 
2991
        setZAxisLabelFont(g->zAxisLabelFont());
 
2992
        setRotation(g->xRotation(),g->yRotation(),g->zRotation());
 
2993
        setZoom(g->zoom());
 
2994
        setScale(g->xScale(),g->yScale(),g->zScale());
 
2995
        setShift(g->xShift(),g->yShift(),g->zShift());
 
2996
        setMeshLineWidth((int)g->meshLineWidth());
 
2997
        setOrtho(g->isOrthogonal());
 
2998
        update();
 
2999
        animate(g->isAnimated());
 
3000
}
 
3001
 
 
3002
Graph3D::~Graph3D()
 
3003
{
 
3004
        if (func)
 
3005
                delete func;
 
3006
 
 
3007
        delete sp;
 
3008
}