Developer documentation | Axl-2.5.1

axlAbstractDataReader.cpp
Go to the documentation of this file.
1 /* axlAbstractDataReader.cpp ---
2  *
3  * Author: Julien Wintz
4  * Copyright (C) 2008-2011 - Julien Wintz, Inria.
5  * Created: Wed Sep 21 10:38:57 2011 (+0200)
6  * Version: $Id$
7  * Last-Updated: Wed Sep 21 10:40:38 2011 (+0200)
8  * By: Julien Wintz
9  * Update #: 5
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
20 #include "axlAbstractDataReader.h"
21 
22 #include <QtGui>
23 
24 axlAbstractDataReader::axlAbstractDataReader(void) : dtkAbstractDataReader()
25 {
26 
27 }
28 
30 {
31 
32 }
33 
34 void axlAbstractDataReader::setNameOf(axlAbstractData* data, const QDomElement& e)
35 {
36  if(e.hasAttribute("name"))
37  data->setObjectName(e.attribute("name"));
38 }
39 
40 void axlAbstractDataReader::setColorOf(axlAbstractData* data, const QDomElement& e)
41 {
42  if(e.hasAttribute("color"))
43  {
44  QString color = e.attribute("color");
45  QStringList colorList = color.split(" ");
46  if(colorList.size() >= 3) // rgb components
47  data->setColor(QColor(colorList.at(0).toInt(),
48  colorList.at(1).toInt(),
49  colorList.at(2).toInt()));
50  if(colorList.size() >= 4)
51  data->setOpacity(colorList.at(3).toFloat());
52  }
53 }
54 
55 void axlAbstractDataReader::setSizeOf(axlAbstractData* data, const QDomElement& e)
56 {
57  if(e.hasAttribute("size"))
58  {
59  double size = e.attribute("size").toDouble();
60  if (size<0) size=0.;
61  data->setSize(size);
62  }
63 }
64 
65 void axlAbstractDataReader::setShaderOf(axlAbstractData* data, const QDomElement& e)
66 {
67  if(e.hasAttribute("shader"))
68  {
69  QString shader = e.attribute("shader");
70  QString dirShader;
71  if(!shader.isEmpty())
72  {
73  // try to read from axelShader.qrc
74  dirShader = ":axlShader/shader/"+shader;
75  if(!QFile::exists(dirShader))
76  {
77  QSettings settings("inria", "dtk");
78  QString defaultPath;
79  settings.beginGroup("shader");
80  dirShader = settings.value("path", defaultPath).toString();
81  // dirShader = this->file().left(this->file().lastIndexOf("axel-data") + 9); // to Remove later
82  dirShader.append("/"+shader);
83  }
84  data->setShader(dirShader);
85  }
86  }
87 }
void setShaderOf(axlAbstractData *data, const QDomElement &e)
void setColorOf(axlAbstractData *data, const QDomElement &e)
void setShader(const QString &shader)
void setNameOf(axlAbstractData *data, const QDomElement &e)
void setSizeOf(axlAbstractData *data, const QDomElement &e)
void setOpacity(const double &opacity)
void setSize(const double &size)
void setColor(double r, double g, double b)
Class axlAbstractData defines an API for all type of axel data.