labplot  2.8.2
About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.
  Fossies Dox: labplot-2.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ColorMapRenderer.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  File : ColorMapRenderer.cc
3  Project : LabPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2008 by Alexander Semke
6  Email (use @ for *) : alexander.semke*web.de
7  Description : colormap renderer class
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 "ColorMapRenderer.h"
30 
31 #include <KDebug>
32 #include <QFile>
33 #include <QPainter>
34 
35 QPixmap ColorMapRenderer::pixmap(const QString& fileName) {
36  QFile file(fileName);
37  if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
38  kDebug()<<"file "<<fileName<<" not found"<<endl;
39  return QPixmap();
40  }
41 
42  QColor rgb;
43  QList<QColor> list_rgb;
44  int red, green, blue;
45  QTextStream in(&file);
46 
47  while (!in.atEnd()) {
48  in.readLine();
49  in >> red >> green >> blue;
50  rgb.setRgb( red, green, blue );
51  list_rgb.append(rgb);
52 // kDebug()<<red<<"\t"<<green<<"\t"<<blue<<endl;
53  }
54 
55  int height = list_rgb.size();
56  int width = 80;
57 // kDebug()<<height<<"line read."<<endl;
58  QPixmap pixmap(width, height);
59  QPainter p( &pixmap );
60  for (int i = 0; i != height; ++i) {
61  rgb = list_rgb.at(i);
62  p.setPen( rgb );
63  p.drawLine( QPoint(0, height-i), QPoint(width, height-i) );
64  }
65 
66  return pixmap;
67 }
static QPixmap pixmap(const QString &)
@ Text
Definition: OriginObj.h:45