summaryrefslogtreecommitdiff
path: root/modules/graphic_objects/includes/NgonGridMatplotData.hxx
blob: eed9f0dd629423fc4d652baaa804462213c11582 (plain)
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
/*
 *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 *  Copyright (C) 2011-2012 - DIGITEO - Manuel Juliachs
 *  Copyright (C) 2013 - Scilab Enterprises - Calixte DENIZET
 *
 *  This file must be used under the terms of the CeCILL.
 *  This source file is licensed as described in the file COPYING, which
 *  you should have received as part of this distribution.  The terms
 *  are also available at
 *  http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
 *
 */

#ifndef NGON_GRID_MATPLOT_DATA_HXX
#define NGON_GRID_MATPLOT_DATA_HXX

#include <string>

#include "NgonGridData.hxx"

extern "C" {
#include "BOOL.h"
#include "Matplot.h"
}

/**
 * N-gons grid Matplot data class
 * The xDimensions and yDimensions properties inherited from NgonGridData have no
 * useful purpose, as the x and y coordinates arrays are not currently visible to
 * the user.
 * To be done: refactoring
 */

class NgonGridMatplotData : public NgonGridData
{

private :

    /** The 2D bounding rectangle {xmin, xmax, ymin, ymax} */
    double boundingRectangle[4];

    /**
     * Matplot type
     * Specifies whether x and y coordinates are computed directly from element indices (0)
     * or computed using the 2D bounding rectangle (1)
     */
    int type;
    ImageType imagetype;
    DataType datatype;
    GLType gltype;
    DataOrder dataorder;
    void * data;
    void * scilabData;
    unsigned int dataSize;

    static const bool isLittleEndian;
    static bool isABGRSupported;

protected :

    /**
     * Computes the x and y coordinates depending on the type member
     * If type is equal to 0, x and y coordinates are directly computed from matrix indices
     * and the rectangle bounds are updated
     * else, if equal to 1, the coordinates are computed by interpolating between the bounding
     * rectangle's min and max vertices
     */
    void computeCoordinates(void);

public :

    /**
     * Constructor
     */
    NgonGridMatplotData(void);

    /**
     * Destructor
     */
    ~NgonGridMatplotData(void);

    /**
     * Returns the identifier associated to a property name
     * @param[in] propertyName the property name
     * @return the property identifier
     */
    int getPropertyFromName(int propertyName);

    /**
     * Sets a data property
     * @param[in] property the property identifier
     * @param[in] value a pointer to the property values
     * @param[in] numElements the number of elements to set
     * @return 1 if the property has been successfully set, 0 otherwise
     */
    int setDataProperty(int property, void const* value, int numElements);

    /**
     * Returns a data property
     * @param[in] property the property identifier
     * @param[out] a pointer to a pointer to the returned property values
     */
    void getDataProperty(int property, void **_pvData);

    /**
     * Sets the grid's x and y vectors dimensions
     * Resizes the x, y, and z data coordinates arrays if required
     * and must therefore be called prior to any setData call
     * Similar to NgonGridData's setGridSize method, the main difference being how the z data array's size
     * is computed.
     * To be done: refactoring
     * @param[in] gridSize a pointer to a 4-element array: x vector (nb rows, nb cols) and y vector (nb rows, nb cols) dimensions
     * @return 1 if the property has been successfully set, 0 otherwise (failed allocation)
     */
    int setGridSize(int const* gridSize);

    /**
     * Sets the 2D bounding rectangle's coordinates
     * Also sets the internal property type according to the value of its argument
     * To be done: use the same coordinate ordering as the internal array
     * @param[in] a pointer to a 4-element array: {xmin, ymin, xmax, ymax} bounds. If bounds is NULL, type is set to 0, else, it is set to 1
     */
    void setBounds(double const* bounds);

    /**
     * Returns the 2D bounding rectangle's coordinates
     * @return a pointer to the bounding rectangle coordinates array {xmin, xmax, ymin, ymax}
     */
    double* getBounds(void);

    /**
     * Returns the Matplot type
     * @return the Matplot type value
     */
    int getType(void);

    /**
     * Set the info about data
     * @param[in] data info built with buildMatplotType
     */
    void setDataInfos(int datainfos);

    /**
     * Get the info about data
     * @return the info
     */
    int getDataInfos();

    /**
     * Get the OpenGL type
     * @return the type
     */
    int getGLType();

    /**
     * Get the image type
     * @return the type
     */
    int getImageType();

    /**
     * Set the image type
     * @param[in] imagetype the image type
     */
    int setImageType(int imagetype);

    /**
     * Get the data order (MATPLOT_FORTRAN or MATPLOT_C corresponding to COLUMN_MAJOR_ORDER & ROW_MAJOR_ORDER)
     * @return the order
     */
    int getDataOrder();

    /**
     * Set the data order (MATPLOT_FORTRAN or MATPLOT_C corresponding to COLUMN_MAJOR_ORDER & ROW_MAJOR_ORDER)
     * @param[in] the order
     */
    void setDataOrder(int dataOrder);

    /**
     * Set the Scilab data type
     * @param[in] datatype the Scilab data type
     */
    void setDataType(int datatype);

    /**
     * Get the Scilab data type
     * @return the Scilab data type
     */
    int getDataType();

    /**
     * Set the image data
     * @param[in] data the image data
     * @param[in] numElements the number of elements
     */
    void setImageData(void const* data, const int numElements);

    /**
     * Get the image data
     * @return the image data
     */
    void * getImageData();

    /**
     * Get the Scilab data
     * @return the Scilab data
     */
    void * getScilabData();

    /**
     * Get the image data size
     * @return the iamge data size
     */
    unsigned int getImageDataSize();

    /**
     * Dispose the texture data
     */
    void disposeTextureData();

    /**
     * Sets the grid's z data
     * This method is almost identical to NgonGridData's own setDataZ method
     * the only difference being how the maximum number of elements is computed
     * To be done: refactoring
     * @param[in] data a pointer to the z data (numElements values)
     * @param[in] numElements the number of elements to set
     */
    void setDataZ(double const* data, int numElements);

    /**
     * Set true if ABGR extension is supported
     * @param[in] _isABGRSupported true if ABGR extension is supported
     */
    static void setABGRSupported(bool _isABGRSupported);

private:

    /**
     * Init a boolean to true or false according to the endianess
     */
    static bool initEndian();

};

#endif