/usr/include/Wt/Chart/WScatterData is in libwt-dev 3.3.6+dfsg-1.1.
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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2013 Emweb bvba, Leuven, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef CHART_SCATTERDATA_H
#define CHART_SCATTERDATA_H
#include <Wt/WModelIndex>
#include <Wt/Chart/WAbstractDataSeries3D>
#include <Wt/Chart/WCartesian3DChart>
#include <Wt/Chart/WSelection>
namespace Wt {
class WMemoryResource;
namespace Chart {
/*! \class WScatterData
* \brief Class representing a collection of points for on a 3D chart.
*
* General information can be found at WAbstractDataSeries3D. The model should
* be structured as a table where every row represents a point. In the simplest
* case, there are three columns representing the x-, y- and z-values. By
* default, this is column 0 for X, column 1 for Y and column 2 for Z. It is
* also possible to provide an additional column containing information on the
* color for each point. The same is possible for the size. Color-information
* in the model should be present as a WColor.
*
* If these extra columns are not included, the MarkerBrushColorRole and
* MarkerScaleFactorRole can still be used to style individual points. These
* dataroles should be set on the values in the column containing the z-values.
*
* The figure below shows an upward spiral of points, with droplines enabled
* and a pointsize of 5 pixels.
*
* \image html spiral.png "An example of WScatterData"
*
* \ingroup charts
*/
class WT_API WScatterData : public WAbstractDataSeries3D {
public:
/*! \brief Constructor
*/
WScatterData(WAbstractItemModel *model);
/*! \brief Enables or disables droplines for all points.
*
* Enabling droplines will cause a line to be drawn from every point to the
* the ground-plane of the chart's plotcube. By default the droplines are
* disabled.
*
* \sa setDroplinesPen()
*/
void setDroplinesEnabled(bool enable = true);
/*! \brief Returns whether droplines are enabled.
*
* \sa setDroplinesEnabled(), setDroplinesPen()
*/
bool droplinesEnabled() const { return droplinesEnabled_; }
/*! \brief Sets the pen that is used to draw droplines.
*
* The default pen is a default constructed WPen.
*
* Note: only the width and color of the pen are used.
*
* \sa setDroplinesEnabled()
*/
void setDroplinesPen(const WPen &pen);
/*! \brief Returns the pen that is used to draw droplines.
*
* \sa setDroplinesEnabled(), setDroplinesPen()
*/
WPen droplinesPen() const { return droplinesPen_; }
/*! \brief Sets the column-index from the model that is used for the
* x-coordinate of all points.
*
* The default X column index is 0.
*/
void setXSeriesColumn(int columnNumber) { XSeriesColumn_ = columnNumber; }
/*! \brief Returns the column-index from the model that is used for the
* x-coordinate of all points.
*
* \sa setXSeriesColumn()
*/
int XSeriesColumn() const { return XSeriesColumn_; }
/*! \brief Sets the column-index from the model that is used for the
* y-coordinate of all points.
*
* The default X column index is 1.
*/
void setYSeriesColumn(int columnNumber) { YSeriesColumn_ = columnNumber; }
/*! \brief Returns the column-index from the model that is used for the
* y-coordinate of all points.
*
* \sa setYSeriesColumn()
*/
int YSeriesColumn() const { return YSeriesColumn_; }
/*! \brief Sets the column-index from the model that is used for the
* z-coordinate of all points.
*
* The default Z column index is 2.
*
* Note that this column is also used to check for a MarkerBrushColorRole
* and a MarkerScaleFactorRole is no color-column or size-column are set.
*
* \sa setColorColumn(), setSizeColumn()
*/
void setZSeriesColumn(int columnNumber) { ZSeriesColumn_ = columnNumber; }
/*! \brief Returns the column-index from the model that is used for the
* z-coordinate of all points.
*
* \sa setZSeriesColumn()
*/
int ZSeriesColumn() const { return ZSeriesColumn_; }
#ifndef WT_TARGET_JAVA
/*! \brief Configure a column in the model to be used for the color of the
* points.
*
* By default, the color-column is set to -1. This means there is no column
* which specifies color-values. Also, the basic mechanism of using the
* MarkerBrushColorRole (if present) is then active. The Z-seriescolumn is
* checked for the presence of this Role.
*
* /sa setZSeriesColumn()
*/
void setColorColumn(int columnNumber, ItemDataRole role = DisplayRole);
/*! \brief Configure a column in the model to be used for the size of the
* points.
*
* By default, the size-column is set to -1. This means there is no column
* which specifies size-values. Also, the basic mechanism of using the
* MarkerScaleFactorRole (if present) is then active. The Z-seriescolumn is
* checked for the presence of this Role.
*
* /sa setZSeriesColumn()
*/
void setSizeColumn(int columnNumber, ItemDataRole role = DisplayRole);
#else
void setColorColumn(int columnNumber, int role = DisplayRole);
void setSizeColumn(int columnNumber, int role = DisplayRole);
#endif
/*! \brief Pick points on this WScatterData using a single pixel.
*
* x,y are the screen coordinates of the pixel from the top left of
* the chart, and radius is the radius in pixels around that pixel.
* All points around the ray projected through the pixel within the
* given radius will be returned.
*/
std::vector<WPointSelection> pickPoints(int x, int y, int radius) const;
/*! \brief Pick points on this WScatterData inside of a rectangle.
*
* The screen coordinates (x1, y1) and (x2, y2) from the top left of
* the chart define a rectangle within which the points should be selected.
*/
std::vector<WPointSelection> pickPoints(int x1, int y1, int x2, int y2) const;
virtual double minimum(Axis axis) const;
virtual double maximum(Axis axis) const;
virtual std::vector<boost::any> getGlObjects();
virtual void initializeGL() {}
virtual void paintGL() const;
virtual void updateGL();
virtual void resizeGL();
virtual void deleteAllGLResources();
private:
int countSimpleData() const;
void dataFromModel(FloatBuffer& simplePtsArray,
FloatBuffer& simplePtsSize,
FloatBuffer& coloredPtsArray,
FloatBuffer& coloredPtsSize,
FloatBuffer& coloredPtsColor);
void dropLineVertices(FloatBuffer& dataPoints,
FloatBuffer& verticesOUT);
void initShaders();
void findXRange() const;
void findYRange() const;
void findZRange() const;
int XSeriesColumn_;
int YSeriesColumn_;
int ZSeriesColumn_;
int colorColumn_;
#ifndef WT_TARGET_JAVA
ItemDataRole asColorRole_;
ItemDataRole asSizeRole_;
#else
int asColorRole_;
int asSizeRole_;
#endif
int sizeColumn_;
bool droplinesEnabled_;
WPen droplinesPen_;
mutable double xMin_, xMax_, yMin_, yMax_;
mutable bool xRangeCached_;
mutable bool yRangeCached_;
WGLWidget::Buffer vertexPosBuffer_, vertexSizeBuffer_;
WGLWidget::Buffer vertexPosBuffer2_, vertexSizeBuffer2_, vertexColorBuffer2_;
WGLWidget::Buffer lineVertBuffer_;
int vertexBufferSize_, vertexBuffer2Size_, lineVertBufferSize_;
WGLWidget::Texture colormapTexture_;
WGLWidget::Texture pointSpriteTexture_;
WGLWidget::Shader vertexShader_;
WGLWidget::Shader colVertexShader_;
WGLWidget::Shader linesVertShader_;
WGLWidget::Shader fragmentShader_;
WGLWidget::Shader colFragmentShader_;
WGLWidget::Shader linesFragShader_;
WGLWidget::Program shaderProgram_;
WGLWidget::Program colShaderProgram_;
WGLWidget::Program linesProgram_;
WGLWidget::AttribLocation posAttr_;
WGLWidget::AttribLocation posAttr2_;
WGLWidget::AttribLocation posAttrLines_;
WGLWidget::AttribLocation sizeAttr_;
WGLWidget::AttribLocation sizeAttr2_;
WGLWidget::AttribLocation colorAttr2_;
WGLWidget::UniformLocation mvMatrixUniform_;
WGLWidget::UniformLocation mvMatrixUniform2_;
WGLWidget::UniformLocation mvMatrixUniform3_;
WGLWidget::UniformLocation pMatrixUniform_;
WGLWidget::UniformLocation pMatrixUniform2_;
WGLWidget::UniformLocation pMatrixUniform3_;
WGLWidget::UniformLocation cMatrixUniform_;
WGLWidget::UniformLocation cMatrixUniform2_;
WGLWidget::UniformLocation cMatrixUniform3_;
WGLWidget::UniformLocation lineColorUniform_;
WGLWidget::UniformLocation samplerUniform_;
WGLWidget::UniformLocation pointSpriteUniform_;
WGLWidget::UniformLocation pointSpriteUniform2_;
WGLWidget::UniformLocation vpHeightUniform_;
WGLWidget::UniformLocation vpHeightUniform2_;
WGLWidget::UniformLocation offsetUniform_;
WGLWidget::UniformLocation scaleFactorUniform_;
};
}
}
#endif
|