/usr/include/Wt/Chart/WAbstractGridData is in libwt-dev 3.3.4+dfsg-6ubuntu1.
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 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | // 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_WABSTRACTGRIDDATA_H
#define CHART_WABSTRACTGRIDDATA_H
#include <Wt/Chart/WAbstractDataSeries3D>
#include <Wt/Chart/WCartesian3DChart>
#include <Wt/Chart/WSelection>
#include <Wt/WPen>
namespace Wt {
class WAbstractItemModel;
class WMemoryResource;
class WVector3;
namespace Chart {
class WCartesian3DChart;
/*! \brief Enumeration with the possible representations of a WAbstractGridData
*
* \ingroup charts
*/
enum Series3DType {
PointSeries3D, //!< Series rendered as points
SurfaceSeries3D, //!< Series rendered as a surface
BarSeries3D //!< Series rendered as bars
};
/*! \class WAbstractGridData
* \brief Class representing grid-based data for on a 3D chart.
*
* General information can be found at WAbstractDataSeries3D. Information on
* how the model is structured is provided in the subclasses. GridData can be
* represented in three ways. This is indicated by \ref Series3DType and can be
* either PointSeries3D, SurfaceSeries3D or BarSeries3D. Note that points and
* surfaces can only be added to charts of type \ref ScatterPlot, while bars
* can only be added to charts of type \ref CategoryChart.
*
* When the data is shown as a surface, a mesh can be added to the surface.
* This draws lines over the surface at the positions of the x- and y-values.
* For bar-series data, it is possible to adjust the width of the bars in both
* directions.
*
* The three types of data-representation are illustrated below.
*
* \image html gridDataTypes.png "The three representation types of grid-based data"
*
* \ingroup charts
*/
class WT_API WAbstractGridData : public WAbstractDataSeries3D {
public:
/*! \brief Constructor
*/
WAbstractGridData(WAbstractItemModel *model);
virtual ~WAbstractGridData();
virtual double minimum(Axis axis) const = 0;
virtual double maximum(Axis axis) const = 0;
/*! \brief Sets the type of representation that will be used for the data.
*
* All representations in \ref Series3DType are possible for the data. Note
* that \ref PointSeries3D and \ref SurfaceSeries3D can only be used on a
* chart that is configured as a \ref ScatterPlot and \ref BarSeries3D can
* only be used on a chart that is configured to be a \ref CategoryChart.
*
* The default value is PointSeries3D.
*/
void setType(Series3DType type);
/*! \brief Returns the type of representation that will be used for the data.
*
* \sa setType()
*/
virtual Series3DType type() const { return seriesType_; }
/*! \brief Enables or disables a mesh for when a surface is drawn.
*
* The default value is false. This option only takes effect when the type of
* this WGridData is \ref SurfaceSeries3D. The mesh is drawn at the position
* of the x-axis and y-axis values.
*/
void setSurfaceMeshEnabled(bool enabled = true);
/*! \brief Returns whether the surface-mesh is enabled for this dataseries.
*
* \sa setSurfaceMeshEnabled()
*/
bool isSurfaceMeshEnabled() { return surfaceMeshEnabled_; }
/*! \brief Sets the bar-width.
*
* This option only takes effect when the type of this WGridData is
* BarSeries3D. The values provided should be between 0 and 1, where 1 lets
* the bars each take up 1/(nb of x/y-values) of the axis.
*
* The default bar-width is 0.5 in both directions.
*/
void setBarWidth(double xWidth, double yWidth);
/*! \brief Returns the bar-width in the X-axis direction.
*
* \sa setBarWidth()
*/
double barWidthX() { return barWidthX_; }
/*! \brief Returns the bar-width in the Y-axis direction.
*
* \sa setBarWidth()
*/
double barWidthY() { return barWidthY_; }
/*! \brief Sets the WPen that is used for drawing the mesh.
*
* Used when drawing the mesh on a surface or the lines around bars. The
* default is a default constructed WPen (black and one pixel wide).
*
* Note: only the width and color of this WPen are used.
*
* \sa setSurfaceMeshEnabled()
*/
void setPen(const WPen &pen);
/*! \brief Returns the pen that is used for drawing the mesh.
*
* \sa setPen()
*/
WPen pen() const { return meshPen_; }
/*! \brief Find all points on the surface that are projected to the given pixel.
*
* A ray is cast from the given pixel's x,y position (from the top left of the chart,
* in screen coordinates) and every intersection with the surface is returned, along
* with its distance from the look point. Note that the coordinates of the intersection
* points are interpolated between the data points that make up the surface.
*/
std::vector<WSurfaceSelection> pickSurface(int x, int y) const;
/*! \brief Return the bar that is closest to the look point at the given pixel.
*
* A ray is cast from the given pixel's x,y position (from the top left of the chart,
* in screen coordinates), and the closest bar on this WAbstractGridData
* is returned, along with its distance from the look point.
*
* Note that if this WAbstractGridData is hidden, this method still returns the
* closest bar as if it was visible. Also, if multiple bars are on the same bar chart,
* the bar that is returned may be behind another data series. Use the distance
* field of the returned WBarSelection to determine which data series is in front from
* the given angle.
*
* If there is no bar at the given pixel, then a selection with an invalid WModelIndex
* is returned. The distance is then set to positive infinity.
*/
WBarSelection pickBar(int x, int y) const;
/*! \brief Set isoline levels.
*
* Isolines are drawn on the top or ground plane of the chart.
* Only applies if the type is SurfaceSeries3D.
*
* The isoline levels are set in the coordinate system of the item model.
*/
void setIsoLevels(const std::vector<double> &isoLevels);
/*! \brief Get all of the isoline levels.
*
* \sa addIsoLevel()
*/
const std::vector<double> &isoLevels() const;
/*! \brief Set the color map for the isolines.
*
* When no color map is defined for the isolines, i.e. isoColorMap()
* is set to NULL, the color map of this WAbstractGridData will be used.
*
* The isolines are only drawn if the type is SurfaceSeries3D.
*
* \if cpp
* If the colormap has no parent yet, then ownership is transferred to this
* %WAbstractGridData, and thus the validator will be deleted together with
* the %WAbstractGridData.
* \endif
*
* \sa addIsoLevel(), setColorMap()
*/
void setIsoColorMap(WAbstractColorMap *colormap);
/*! \brief Get the color map for the isolines.
*
* \sa setIsoColorMap()
*/
const WAbstractColorMap *isoColorMap() const { return isoLineColorMap_; }
/*! \brief Set the value below which the data series will be clipped on the given axis.
*
* This only affects data series whose type is SurfaceSeries3D.
*/
void setClippingMin(Axis axis, float v);
/*! \brief Gets the value below which the data series will be clipped on the given axis.
*
* \sa setClippingMin()
*/
float clippingMin(Axis axis) const;
/*! \brief JSlot to change the value below which the data series will be clipped on the given axis.
*
* The JSlot takes one extra argument: the value to clip below.
*
* The jsRef() of this JSlot is only valid when this WAbstractGridData has been added to
* a WCartesian3DChart. If this WAbstractGridData moves to another WCartesian3DChart, the
* jsRef() of the JSlot changes.
*
* \sa setClippingMin()
*/
JSlot &changeClippingMin(Axis axis);
/*! \brief Set the value above which the data series will be clipped on the given axis.
*
* This only affects data series whose type is SurfaceSeries3D.
*/
void setClippingMax(Axis axis, float v);
/*! \brief Gets the value above which the data series will be clipped on the given axis.
*
* \sa setClippingMax()
*/
float clippingMax(Axis axis) const;
/*! \brief JSlot to change the value above which the data series will be clipped on the given axis.
*
* The JSlot takes one extra argument: the value to clip below.
*
* The jsRef() of this JSlot is only valid when this WAbstractGridData has been added to
* a WCartesian3DChart. If this WAbstractGridData moves to another WCartesian3DChart, the
* jsRef() of the JSlot changes.
*
* \sa setClippingMax()
*/
JSlot &changeClippingMax(Axis axis);
/*! \brief Sets whether clipping lines should be drawn where a surface
* is clipped.
*
* Clipping lines are disabled by default. Note that rendering will
* be significantly slower when enabled.
*/
void setClippingLinesEnabled(bool clippingLinesEnabled);
/*! \brief Returns whether clipping lines are enabled.
*
* \sa setClippingLinesEnabled()
*/
bool clippingLinesEnabled() const { return clippingLinesEnabled_; }
/*! \brief Sets the color of the clipping lines.
*
* \sa setClippingLinesEnabled()
*/
void setClippingLinesColor(WColor color);
/*! \brief Gets the color of the clipping lines.
*
* \sa setClippingLinesColor(), setClippingLinesEnabled()
*/
WColor clippingLinesColor() const { return clippingLinesColor_; }
static const int SURFACE_SIDE_LIMIT = 256; // = sqrt(2^16)
static const int BAR_BUFFER_LIMIT = 8190; // = 2^16/8
virtual int nbXPoints() const = 0;
virtual int nbYPoints() const = 0;
virtual WString axisLabel(int u, Axis axis) const = 0;
virtual boost::any data(int i, int j) const = 0;
virtual void setChart(WCartesian3DChart *chart);
virtual void initializeGL();
virtual void paintGL() const;
virtual void updateGL();
virtual void resizeGL();
virtual void deleteAllGLResources();
protected:
virtual void pointDataFromModel(FloatBuffer& simplePtsArray,
FloatBuffer& simplePtsSize,
FloatBuffer& coloredPtsArray,
FloatBuffer& coloredPtsSize,
FloatBuffer& coloredPtsColor) const = 0;
virtual void surfaceDataFromModel(std::vector<FloatBuffer>& simplePtsArrays) const = 0;
virtual void barDataFromModel(std::vector<FloatBuffer>& simplePtsArrays) const = 0;
virtual void barDataFromModel(std::vector<FloatBuffer>& simplePtsArrays,
std::vector<FloatBuffer>& coloredPtsArrays,
std::vector<FloatBuffer>& coloredPtsColors) const = 0;
// data without color-role
virtual int countSimpleData() const = 0;
// adds up the value (i, j) for all dataseries, i and j should be specified
// without any offsets for axes in the model
float stackAllValues(std::vector<WAbstractGridData*> dataseries,
int i, int j) const;
Series3DType seriesType_;
bool surfaceMeshEnabled_;
bool colorRoleEnabled_;
double barWidthX_;
double barWidthY_;
WPen meshPen_;
static const float zeroBarCompensation;
private:
void initShaders();
void initializePointSeriesBuffers();
void initializeSurfaceSeriesBuffers();
void initializeBarSeriesBuffers();
void loadBinaryResource(FloatBuffer&,
std::vector<WGLWidget::Buffer>& buffers);
void barSeriesVertexData(FloatBuffer& verticesIN,
FloatBuffer& verticesOUT) const;
void generateVertexIndices(IntBuffer& indicesOUT,
int Nx, int Ny, int size = 0) const;
void generateMeshIndices(IntBuffer& indicesOUT,
int Nx, int Ny, int size = 0);
void generateTextureCoords(FloatBuffer& coordsOUT,
const FloatBuffer& dataArray,
int size);
void paintGLIndex(unsigned index) const;
void paintGLIndex(unsigned index, double marginX, double marginY, double marginZ) const;
void paintGLPositions() const;
void paintGLPositions(double marginX, double marginY, double marginZ) const;
double rayTriangleIntersect(const WVector3 &re, const WVector3 &rd, const WVector3 &camera, const WVector3 &v0, const WVector3 &v1, const WVector3 &v2, WVector3 &point) const;
void drawIsoLines() const;
void linesForIsoLevel(double z, std::vector<float> &result) const;
WGLWidget::Texture isoLineColorMapTexture();
std::vector<int> vertexPosBufferSizes_, vertexPosBuffer2Sizes_;
std::vector<int> indexBufferSizes_, lineBufferSizes_;
std::vector<int> indexBufferSizes2_, lineBufferSizes2_;
std::vector<int> isoLineBufferSizes_;
std::vector<double> isoLineHeights_;
WAbstractColorMap *isoLineColorMap_;
std::vector<WGLWidget::Buffer> vertexPosBuffers_;
std::vector<WGLWidget::Buffer> vertexPosBuffers2_;
std::vector<WGLWidget::Buffer> vertexSizeBuffers_;
std::vector<WGLWidget::Buffer> vertexSizeBuffers2_;
std::vector<WGLWidget::Buffer> vertexColorBuffers2_;
std::vector<WGLWidget::Buffer> indexBuffers_;
std::vector<WGLWidget::Buffer> indexBuffers2_;
std::vector<WGLWidget::Buffer> overlayLinesBuffers_;
std::vector<WGLWidget::Buffer> overlayLinesBuffers2_;
std::vector<WGLWidget::Buffer> colormapTexBuffers_;
std::vector<WGLWidget::Buffer> isoLineBuffers_;
std::vector<WMemoryResource*> binaryResources_;
// Shader program
WGLWidget::Shader fragShader_;
WGLWidget::Shader colFragShader_;
WGLWidget::Shader meshFragShader_;
WGLWidget::Shader singleColorFragShader_;
WGLWidget::Shader positionFragShader_;
WGLWidget::Shader isoLineFragShader_;
WGLWidget::Shader vertShader_;
WGLWidget::Shader colVertShader_;
WGLWidget::Shader meshVertShader_;
WGLWidget::Shader isoLineVertexShader_;
WGLWidget::Program seriesProgram_;
WGLWidget::Program colSeriesProgram_;
WGLWidget::Program meshProgram_;
WGLWidget::Program singleColorProgram_;
WGLWidget::Program positionProgram_;
WGLWidget::Program isoLineProgram_;
// Shader attributes
WGLWidget::AttribLocation vertexPosAttr_;
WGLWidget::AttribLocation vertexPosAttr2_;
WGLWidget::AttribLocation singleColor_vertexPosAttr_;
WGLWidget::AttribLocation position_vertexPosAttr_;
WGLWidget::AttribLocation meshVertexPosAttr_;
WGLWidget::AttribLocation isoLineVertexPosAttr_;
WGLWidget::AttribLocation vertexSizeAttr_;
WGLWidget::AttribLocation vertexSizeAttr2_;
WGLWidget::AttribLocation vertexColAttr2_;
WGLWidget::AttribLocation barTexCoordAttr_;
// Shader uniform variables
WGLWidget::UniformLocation mvMatrixUniform_;
WGLWidget::UniformLocation mvMatrixUniform2_;
WGLWidget::UniformLocation singleColor_mvMatrixUniform_;
WGLWidget::UniformLocation position_mvMatrixUniform_;
WGLWidget::UniformLocation mesh_mvMatrixUniform_;
WGLWidget::UniformLocation isoLine_mvMatrixUniform_;
WGLWidget::UniformLocation pMatrix_;
WGLWidget::UniformLocation pMatrix2_;
WGLWidget::UniformLocation singleColor_pMatrix_;
WGLWidget::UniformLocation position_pMatrix_;
WGLWidget::UniformLocation mesh_pMatrix_;
WGLWidget::UniformLocation isoLine_pMatrix_;
WGLWidget::UniformLocation cMatrix_;
WGLWidget::UniformLocation cMatrix2_;
WGLWidget::UniformLocation singleColor_cMatrix_;
WGLWidget::UniformLocation position_cMatrix_;
WGLWidget::UniformLocation mesh_cMatrix_;
WGLWidget::UniformLocation isoLine_cMatrix_;
WGLWidget::UniformLocation TexSampler_;
WGLWidget::UniformLocation isoLine_TexSampler_;
WGLWidget::UniformLocation mesh_colorUniform_;
WGLWidget::UniformLocation singleColorUniform_;
WGLWidget::UniformLocation pointSpriteUniform_;
WGLWidget::UniformLocation pointSpriteUniform2_;
WGLWidget::UniformLocation vpHeightUniform_;
WGLWidget::UniformLocation vpHeightUniform2_;
WGLWidget::UniformLocation offset_;
WGLWidget::UniformLocation isoLine_offset_;
WGLWidget::UniformLocation scaleFactor_;
WGLWidget::UniformLocation isoLine_scaleFactor_;
WGLWidget::UniformLocation minPtUniform_;
WGLWidget::UniformLocation mesh_minPtUniform_;
WGLWidget::UniformLocation singleColor_minPtUniform_;
WGLWidget::UniformLocation position_minPtUniform_;
WGLWidget::UniformLocation maxPtUniform_;
WGLWidget::UniformLocation mesh_maxPtUniform_;
WGLWidget::UniformLocation singleColor_maxPtUniform_;
WGLWidget::UniformLocation position_maxPtUniform_;
WGLWidget::UniformLocation dataMinPtUniform_;
WGLWidget::UniformLocation mesh_dataMinPtUniform_;
WGLWidget::UniformLocation singleColor_dataMinPtUniform_;
WGLWidget::UniformLocation position_dataMinPtUniform_;
WGLWidget::UniformLocation dataMaxPtUniform_;
WGLWidget::UniformLocation mesh_dataMaxPtUniform_;
WGLWidget::UniformLocation singleColor_dataMaxPtUniform_;
WGLWidget::UniformLocation position_dataMaxPtUniform_;
WGLWidget::UniformLocation singleColor_marginUniform_;
WGLWidget::UniformLocation position_marginUniform_;
WGLWidget::Texture colormapTexture_;
WGLWidget::Texture isoLineColorMapTexture_;
WGLWidget::Texture pointSpriteTexture_;
std::vector<float> minPt_;
std::vector<float> maxPt_;
WGLWidget::JavaScriptVector jsMinPt_;
WGLWidget::JavaScriptVector jsMaxPt_;
bool minPtChanged_;
bool maxPtChanged_;
JSlot changeClippingMinX_;
JSlot changeClippingMaxX_;
JSlot changeClippingMinY_;
JSlot changeClippingMaxY_;
JSlot changeClippingMinZ_;
JSlot changeClippingMaxZ_;
bool clippingLinesEnabled_;
WColor clippingLinesColor_;
friend class WCartesian3DChart;
};
}
}
#endif
|