This file is indexed.

/usr/include/sofa/gui/qt/GraphDataWidget.h is in libsofa1-dev 1.0~beta4-9.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/******************************************************************************
*       SOFA, Simulation Open-Framework Architecture, version 1.0 beta 4      *
*                (c) 2006-2009 MGH, INRIA, USTL, UJF, CNRS                    *
*                                                                             *
* This program is free software; you can redistribute it and/or modify it     *
* under the terms of the GNU General Public License as published by the Free  *
* Software Foundation; either version 2 of the License, or (at your option)   *
* any later version.                                                          *
*                                                                             *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    *
* more details.                                                               *
*                                                                             *
* You should have received a copy of the GNU General Public License along     *
* with this program; if not, write to the Free Software Foundation, Inc., 51  *
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.                   *
*******************************************************************************
*                            SOFA :: Applications                             *
*                                                                             *
* Authors: M. Adam, J. Allard, B. Andre, P-J. Bensoussan, S. Cotin, C. Duriez,*
* H. Delingette, F. Falipou, F. Faure, S. Fonteneau, L. Heigeas, C. Mendoza,  *
* M. Nesme, P. Neumann, J-P. de la Plata Alcade, F. Poyer and F. Roy          *
*                                                                             *
* Contact information: contact@sofa-framework.org                             *
******************************************************************************/
#ifndef SOFA_GUI_QT_GRAPHDATAWIDGET_H
#define SOFA_GUI_QT_GRAPHDATAWIDGET_H

#include <sofa/gui/qt/TableDataWidget.h>
#include <sofa/component/topology/PointSubset.h>
#include <sofa/component/topology/PointData.h>
#include <qwt_plot.h>
#include <qwt_legend.h>
#include <qwt_scale_engine.h>
#include <qwt_data.h>
#include <qwt_double_rect.h>

namespace sofa
{

namespace gui
{

namespace qt
{

template<class T>
class QwtDataAccess : public QwtData
{
protected:
    const T* data0;
    const T** pdata;
public:
    typedef vector_data_trait<T> trait;
    typedef typename trait::value_type value_type;
    typedef vector_data_trait<value_type> vtrait;
    typedef typename vtrait::value_type real_type;
    QwtDataAccess() : data0(NULL) { pdata = &data0; }
    QwtDataAccess(const QwtDataAccess<T>& c) : QwtData(c), data0(c.data0), pdata(c.pdata) {}
    void setData(const T** p) { pdata = p; }
    void setData(const T* p) { data0 = p; pdata = &data0; }
    virtual QwtData* copy() const { return new QwtDataAccess<T>(*this); }
    virtual size_t size() const
    {
	if (*pdata == NULL)
	    return 0;
	else
	    return trait::size(*(*pdata));
    }
    virtual double x (size_t i) const
    {
	if (i >= size())
	    return 0.0;
	else if (vtrait::size(*trait::get(*(*pdata), i)) < 2)
	    return (double)i;
	else
	    return (double)(*vtrait::get(*trait::get(*(*pdata), i), 0));
    }
    virtual double y (size_t i) const
    {
	if (i >= size())
	    return 0.0;
	else if (vtrait::size(*trait::get(*(*pdata), i)) < 2)
	    return (double)(*vtrait::get(*trait::get(*(*pdata), i), 0));
	else
	    return (double)(*vtrait::get(*trait::get(*(*pdata), i), 1));
    }
};

template<class T>
class graph_data_widget_container
{
public:
    typedef T data_type;
    typedef vector_data_trait<T> trait;
    typedef typename trait::value_type curve_type;
    typedef QwtPlot Widget;
    typedef QwtPlotCurve Curve;
    typedef QwtDataAccess<curve_type> CurveData;

    Widget* w;
    helper::vector<Curve*> curve;
    helper::vector<CurveData*> cdata;
    data_type currentData;
    QwtDoubleRect rect;
    graph_data_widget_container() : w(NULL) {}

    template<class Dialog, class Slot>
    bool createWidgets(Dialog* /*dialog*/, Slot /*s*/, QWidget* parent, const data_type& d, bool /*readOnly*/)
    {
	if (Q3GroupBox* box = dynamic_cast<Q3GroupBox*>(parent)) box->setColumns(1);
#ifdef SOFA_QT4
	w = new Widget(QwtText("Graph"), parent);
#else
	w = new Widget(parent, "Graph");
#endif
	w->insertLegend(new QwtLegend(), QwtPlot::BottomLegend);
	w->setAxisScaleEngine(Widget::yLeft, new QwtLog10ScaleEngine);
	readFromData(d);
	return true;
    }
    void setReadOnly(bool /*readOnly*/)
    {
    }
    void readFromData(const data_type& d)
    {
	currentData = d;
	int s = curve.size();
	int n = trait::size(d);
	for (int i=0;i<n;++i)
	{
	    const curve_type* v = trait::get(d,i);
	    const char* name = trait::header(d,i);
	    if (i >= s)
	    {
		Curve *c;
		QString s;
		if (name && *name) s = name;
		c = new Curve(s);
		c->attach(w);
		switch(i)
		{
		case 0 : c->setPen(QPen(Qt::red)); break;
		case 1 : c->setPen(QPen(Qt::green)); break;
		case 2 : c->setPen(QPen(Qt::blue)); break;
		case 3 : c->setPen(QPen(Qt::cyan)); break;
		case 4 : c->setPen(QPen(Qt::magenta)); break;
		case 5 : c->setPen(QPen(Qt::yellow)); break;
		}
		CurveData* cd = new CurveData;
		cd->setData(v);
		c->setData(*cd);
		curve.push_back(c);
		cdata.push_back(cd);
		s = i+1;
	    }
	    else
	    {
		Curve* c = curve[i];
		CurveData* cd = cdata[i];
		QString s;
		if (name && *name) s = name;
		if (s != c->title().text())
		    c->setTitle(s);
		cd->setData(v);
		c->setData(*cd);
	    }
	    rect = rect.unite(cdata[i]->boundingRect());
	}
	if (s != n)
	{
	    while (s > n)
	    {
		Curve* c = curve[s];
		CurveData* cd = cdata[s];
		c->detach();
		delete c;
		delete cd;
		--s;
	    }
	    curve.resize(n);
	    cdata.resize(n);
	}
	if (n > 0 && !rect.isNull())
	{
	    w->setAxisScale(Widget::yLeft, rect.top(), rect.bottom());
	    w->setAxisScale(Widget::xBottom, rect.left(), rect.right());
	}
	w->replot();
    }
    void writeToData(data_type& /*d*/)
    {
    }
    bool processChange(const QObject* sender)
    {
	if (sender == w)
	    return true;
	return false;
    }
};

template<class T>
class GraphDataWidget : public SimpleDataWidget<T, graph_data_widget_container< T > >
{
public:
    typedef SimpleDataWidget<T, graph_data_widget_container< T > > Inherit;
    typedef sofa::core::objectmodel::TData<T> MyData;
public:
    GraphDataWidget(MyData* d) : Inherit(d) {}
    virtual unsigned int sizeWidget(){return 3;}
};

} // namespace qt

} // namespace gui

} // namespace sofa


#endif