src/cpp/Fac3DDecomposer.cpp \
src/cpp/NgonGridDataDecomposer.cpp \
src/cpp/NgonGridGrayplotDataDecomposer.cpp \
+ src/cpp/MatPlotDecomposer.cpp \
src/cpp/NgonGridMatplotDataDecomposer.cpp \
src/cpp/Plot3DDecomposer.cpp \
src/cpp/PolylineDecomposer.cpp \
libscigraphic_objects_la-Fac3DDecomposer.lo \
libscigraphic_objects_la-NgonGridDataDecomposer.lo \
libscigraphic_objects_la-NgonGridGrayplotDataDecomposer.lo \
+ libscigraphic_objects_la-MatPlotDecomposer.lo \
libscigraphic_objects_la-NgonGridMatplotDataDecomposer.lo \
libscigraphic_objects_la-Plot3DDecomposer.lo \
libscigraphic_objects_la-PolylineDecomposer.lo \
src/cpp/Fac3DDecomposer.cpp \
src/cpp/NgonGridDataDecomposer.cpp \
src/cpp/NgonGridGrayplotDataDecomposer.cpp \
+ src/cpp/MatPlotDecomposer.cpp \
src/cpp/NgonGridMatplotDataDecomposer.cpp \
src/cpp/Plot3DDecomposer.cpp \
src/cpp/PolylineDecomposer.cpp \
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigraphic_objects_la-FigureList.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigraphic_objects_la-FigureModel.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigraphic_objects_la-HandleManagement.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigraphic_objects_la-MatPlotDecomposer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigraphic_objects_la-NgonData.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigraphic_objects_la-NgonGeneralData.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigraphic_objects_la-NgonGridData.Plo@am__quote@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscigraphic_objects_la-NgonGridGrayplotDataDecomposer.lo `test -f 'src/cpp/NgonGridGrayplotDataDecomposer.cpp' || echo '$(srcdir)/'`src/cpp/NgonGridGrayplotDataDecomposer.cpp
+libscigraphic_objects_la-MatPlotDecomposer.lo: src/cpp/MatPlotDecomposer.cpp
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscigraphic_objects_la-MatPlotDecomposer.lo -MD -MP -MF $(DEPDIR)/libscigraphic_objects_la-MatPlotDecomposer.Tpo -c -o libscigraphic_objects_la-MatPlotDecomposer.lo `test -f 'src/cpp/MatPlotDecomposer.cpp' || echo '$(srcdir)/'`src/cpp/MatPlotDecomposer.cpp
+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/libscigraphic_objects_la-MatPlotDecomposer.Tpo $(DEPDIR)/libscigraphic_objects_la-MatPlotDecomposer.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/cpp/MatPlotDecomposer.cpp' object='libscigraphic_objects_la-MatPlotDecomposer.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscigraphic_objects_la-MatPlotDecomposer.lo `test -f 'src/cpp/MatPlotDecomposer.cpp' || echo '$(srcdir)/'`src/cpp/MatPlotDecomposer.cpp
+
libscigraphic_objects_la-NgonGridMatplotDataDecomposer.lo: src/cpp/NgonGridMatplotDataDecomposer.cpp
@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscigraphic_objects_la-NgonGridMatplotDataDecomposer.lo -MD -MP -MF $(DEPDIR)/libscigraphic_objects_la-NgonGridMatplotDataDecomposer.Tpo -c -o libscigraphic_objects_la-NgonGridMatplotDataDecomposer.lo `test -f 'src/cpp/NgonGridMatplotDataDecomposer.cpp' || echo '$(srcdir)/'`src/cpp/NgonGridMatplotDataDecomposer.cpp
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/libscigraphic_objects_la-NgonGridMatplotDataDecomposer.Tpo $(DEPDIR)/libscigraphic_objects_la-NgonGridMatplotDataDecomposer.Plo
{
/**
+ * Return the texture width for the given object.
+ * @param[in] the given object id.
+ * @return the texture width for the given object.
+ */
+ int getTextureWidth(char* id);
+
+ /**
+ * Return the texture height for the given object.
+ * @param[in] the given object id.
+ * @return the texture height for the given object.
+ */
+ int getTextureHeight(char* id);
+
+ /**
+ * Fill the given buffer with texture data.
+ * @param[in] the id of the object texture.
+ * @param[out] the buffer to fill.
+ * @param[in] the buffer length in number of elements.
+ * @return the length of writed data.
+ */
+ int fillTextureData(char *id, float* buffer, int bufferLength);
+
+ /**
+ * Fill the given buffer with sub-texture data.
+ * @param[in] the id of the object texture.
+ * @param[out] the buffer to fill.
+ * @param[in] the buffer length in number of elements.
+ * @param[in] the x-coordinate of the first pixel.
+ * @param[in] the y-coordinate of the first pixel.
+ * @param[in] the width of the sub-texture.
+ * @param[in] the length of the sub-texture.
+ * @return the length of writed data.
+ */
+ int fillSubTextureData(char* id, float* buffer, int bufferLength, int x, int y, int width, int height);
+
+ /**
* Return the number of data elements for the given object.
* @param[in] the given object id.
* @return the number of data elements.
}
-#endif DATA_LOADER_HXX
+#endif /* DATA_LOADER_HXX */
+
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011-2012 - DIGITEO - Pierre Lando
+ *
+ * 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-en.txt
+ *
+ */
+
+#ifndef MATPLOT_DECOMPOSER_HXX
+#define MATPLOT_DECOMPOSER_HXX
+
+class MatPlotDecomposer
+{
+public:
+ static int getTextureWidth(char* id);
+ static int getTextureHeight(char* id);
+ static int fillTextureData(char* id, float* buffer, int bufferLength);
+ static int fillTextureData(char* id, float* buffer, int bufferLength, int x, int y, int width, int height);
+};
+
+#endif
<ClCompile Include="..\cpp\FigureModel.cpp" />
<ClCompile Include="..\cpp\getConsoleIdentifier.cpp" />
<ClCompile Include="..\cpp\HandleManagement.cpp" />
+ <ClCompile Include="..\cpp\MatPlotDecomposer.cpp" />
<ClCompile Include="..\cpp\NgonGridMatplotDataDecomposer.cpp" />
<ClCompile Include="..\cpp\ScilabView.cpp" />
<ClCompile Include="..\cpp\Triangulator.cpp" />
<ClInclude Include="..\..\includes\getConsoleIdentifier.h" />
<ClInclude Include="..\..\includes\getGraphicObjectProperty.h" />
<ClInclude Include="..\..\includes\graphicObjectProperties.h" />
+ <ClInclude Include="..\..\includes\MatPlotDecomposer.hxx" />
<ClInclude Include="..\..\includes\NgonGridMatplotDataDecomposer.hxx" />
<ClInclude Include="..\..\includes\returnType.h" />
<ClInclude Include="..\..\includes\ScilabView.hxx" />
<ClCompile Include="..\cpp\Triangulator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\cpp\MatPlotDecomposer.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\jni\CallGraphicController.hxx">
<ClInclude Include="..\..\includes\Triangulator.hxx">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\includes\MatPlotDecomposer.hxx">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\locales\en_US\messages.pot">
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2010 - DIGITEO - Pierre Lando
* Copyright (C) 2011-2012 - DIGITEO - Manuel Juliachs
+ * Copyright (C) 2011-2012 - DIGITEO - Pierre Lando
*
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
#include "DataLoader.hxx"
+#include "MatPlotDecomposer.hxx"
#include "Fac3DDecomposer.hxx"
#include "NgonGridGrayplotDataDecomposer.hxx"
#include "NgonGridMatplotDataDecomposer.hxx"
// TODO: switch using the Type
+
+int getTextureWidth(char* id)
+{
+ char* type;
+ getGraphicObjectProperty(id, __GO_TYPE__, jni_string, (void**) &type);
+ if (strcmp(type, __GO_MATPLOT__) == 0)
+ {
+ return MatPlotDecomposer::getTextureWidth(id);
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+int getTextureHeight(char* id)
+{
+ char* type;
+ getGraphicObjectProperty(id, __GO_TYPE__, jni_string, (void**) &type);
+ if (strcmp(type, __GO_MATPLOT__) == 0)
+ {
+ return MatPlotDecomposer::getTextureHeight(id);
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+int fillTextureData(char* id, float* buffer, int bufferLength)
+{
+ char* type;
+ getGraphicObjectProperty(id, __GO_TYPE__, jni_string, (void**) &type);
+ if (strcmp(type, __GO_MATPLOT__) == 0)
+ {
+ return MatPlotDecomposer::fillTextureData(id, buffer, bufferLength);
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+int fillSubTextureData(char* id, float* buffer, int bufferLength, int x, int y, int width, int height)
+{
+ char* type;
+ getGraphicObjectProperty(id, __GO_TYPE__, jni_string, (void**) &type);
+ if (strcmp(type, __GO_MATPLOT__) == 0)
+ {
+ return MatPlotDecomposer::fillTextureData(id, buffer, bufferLength, x, y, width, height);
+ }
+ else
+ {
+ return 0;
+ }
+}
+
int getDataSize(char* id)
{
char* type;
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011-2012 - DIGITEO - Pierre Lando
+ *
+ * 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-en.txt
+ *
+ */
+
+#include "DecompositionUtils.hxx"
+#include "MatPlotDecomposer.hxx"
+#include "DataProperties.hxx"
+#include "ColorComputer.hxx"
+#include <iostream>
+
+extern "C" {
+#include "getGraphicObjectProperty.h"
+#include "graphicObjectProperties.h"
+}
+
+int MatPlotDecomposer::getTextureWidth(char* id)
+{
+ int width;
+ int* piWidth = &width;
+ getGraphicObjectProperty(id, __GO_DATA_MODEL_NUM_X__, jni_int, (void**) &piWidth);
+ return width - 1;
+}
+
+
+int MatPlotDecomposer::getTextureHeight(char* id)
+{
+ int height;
+ int* piHeight = &height;
+ getGraphicObjectProperty(id, __GO_DATA_MODEL_NUM_Y__, jni_int, (void**) &piHeight);
+ return height - 1;
+}
+
+
+int MatPlotDecomposer::fillTextureData(char* id, float* buffer, int bufferLength)
+{
+ double* value;
+ getGraphicObjectProperty(id, __GO_DATA_MODEL_Z__, jni_double_vector, (void**) &value);
+ int textureWidth = getTextureWidth(id);
+ int textureHeight = getTextureHeight(id);
+ int dataSize = textureWidth * textureHeight;
+ if (dataSize * 4 == bufferLength)
+ {
+
+ char* parentFigure;
+ double* colormap;
+ int colormapSize;
+ int* piColormapSize = &colormapSize;
+
+ getGraphicObjectProperty(id, __GO_PARENT_FIGURE__, jni_string, (void**) &parentFigure);
+ getGraphicObjectProperty(parentFigure, __GO_COLORMAP__, jni_double_vector, (void**) &colormap);
+ getGraphicObjectProperty(parentFigure, __GO_COLORMAP_SIZE__, jni_int, (void**) &piColormapSize);
+
+ for (int i = 0 ; i < textureWidth ; i++)
+ {
+ for (int j = 0 ; j < textureHeight ; j++)
+ {
+ ColorComputer::getDirectColor(value[j + i * textureHeight] - 1, colormap, colormapSize, &buffer[4 * (i + j * textureWidth)]);
+ buffer[4 * (i + j * textureWidth) + 3] = 1;
+ }
+ }
+
+ return bufferLength;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+
+int MatPlotDecomposer::fillTextureData(char* id, float* buffer, int bufferLength, int x, int y, int width, int height)
+{
+ double* value;
+ getGraphicObjectProperty(id, __GO_DATA_MODEL_Z__, jni_double_vector, (void**) &value);
+ if (width * height * 4 == bufferLength)
+ {
+ char* parentFigure;
+ double* colormap;
+ int colormapSize;
+ int* piColormapSize = &colormapSize;
+ getGraphicObjectProperty(id, __GO_PARENT_FIGURE__, jni_string, (void**) &parentFigure);
+ getGraphicObjectProperty(parentFigure, __GO_COLORMAP__, jni_double_vector, (void**) &colormap);
+ getGraphicObjectProperty(parentFigure, __GO_COLORMAP_SIZE__, jni_int, (void**) &piColormapSize);
+ int textureHeight = getTextureHeight(id);
+ int k = 0;
+ for (int j = y ; j < y + height ; j++)
+ {
+ for (int i = x ; i < x + width ; i++)
+ {
+ ColorComputer::getDirectColor(value[j + i * textureHeight] - 1, colormap, colormapSize, &buffer[k]);
+ buffer[k + 3] = 1;
+ k += 4;
+ }
+ }
+ return bufferLength;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
package org.scilab.modules.graphic_objects;
public class DataLoader {
+ public static int getTextureWidth(String id) {
+ return DataLoaderJNI.getTextureWidth(id);
+ }
+
+ public static int getTextureHeight(String id) {
+ return DataLoaderJNI.getTextureHeight(id);
+ }
+
+ public static int fillTextureData(String id, java.nio.FloatBuffer buffer, int bufferLength) {
+ assert buffer.isDirect() : "Buffer must be allocated direct.";
+ {
+ return DataLoaderJNI.fillTextureData(id, buffer, bufferLength);
+ }
+ }
+
+ public static int fillSubTextureData(String id, java.nio.FloatBuffer buffer, int bufferLength, int x, int y, int width, int height) {
+ assert buffer.isDirect() : "Buffer must be allocated direct.";
+ {
+ return DataLoaderJNI.fillSubTextureData(id, buffer, bufferLength, x, y, width, height);
+ }
+ }
+
public static int getDataSize(String id) {
return DataLoaderJNI.getDataSize(id);
}
}
}
+ public final static native int getTextureWidth(String jarg1);
+ public final static native int getTextureHeight(String jarg1);
+ public final static native int fillTextureData(String jarg1, java.nio.FloatBuffer jarg2, int jarg3);
+ public final static native int fillSubTextureData(String jarg1, java.nio.FloatBuffer jarg2, int jarg3, int jarg4, int jarg5, int jarg6, int jarg7);
public final static native int getDataSize(String jarg1);
public final static native void fillVertices(String jarg1, java.nio.FloatBuffer jarg2, int jarg3, int jarg4, int jarg5, double[] jarg6, double[] jarg7, int jarg8);
public final static native void fillColors(String jarg1, java.nio.FloatBuffer jarg2, int jarg3, int jarg4);
import org.scilab.modules.graphic_objects.graphicObject.GraphicObject;
import org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties;
+import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.util.Arrays;
*/
public class MainDataLoader {
- /**
- * The names of Java-based objects.
- */
- private static final Set<String> JAVA_OBJECTS = new HashSet<String>(Arrays.asList(
- GraphicObjectProperties.__GO_ARC__,
- GraphicObjectProperties.__GO_CHAMP__,
- GraphicObjectProperties.__GO_RECTANGLE__,
- GraphicObjectProperties.__GO_SEGS__
- ));
-
- /**
- * Returns the number of data elements for the given object.
- * @param the id of the given object.
- * @return the number of data elements.
- */
- public static int getDataSize(String id) {
- String type = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
-
- if (JAVA_OBJECTS.contains(type)) {
- return JavaObjectLoader.getDataSize(id);
- } else {
- return DataLoader.getDataSize(id);
- }
- }
+ /**
+ * The names of Java-based objects.
+ */
+ private static final Set<String> JAVA_OBJECTS = new HashSet<String>(Arrays.asList(
+ GraphicObjectProperties.__GO_ARC__,
+ GraphicObjectProperties.__GO_CHAMP__,
+ GraphicObjectProperties.__GO_RECTANGLE__,
+ GraphicObjectProperties.__GO_SEGS__
+ ));
+
+ /**
+ * Returns the data width for the given object.
+ * @param id of the given object.
+ * @return the data width.
+ */
+ public static int getTextureWidth(String id) {
+ return DataLoader.getTextureWidth(id);
+ }
- /**
- * Fills the given buffer with vertex data from the given object.
- * @param the id of the given object.
- * @param the buffer to fill.
- * @param the number of coordinates taken by one element in the buffer.
- * @param the bit mask specifying which coordinates are filled (1 for X, 2 for Y, 4 for Z).
- * @param the conversion scale factor to apply to data.
- * @param the conversion translation value to apply to data.
- * @param the bit mask specifying whether logarithmic coordinates are used.
- */
- public static void fillVertices(String id, FloatBuffer buffer, int elementsSize,
- int coordinateMask, double[] scale, double[] translation, int logMask) {
- String type = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
-
- if (JAVA_OBJECTS.contains(type)) {
- JavaObjectLoader.fillVertices(id, buffer, elementsSize, coordinateMask, scale, translation, logMask);
- } else {
- DataLoader.fillVertices(id, buffer, buffer.capacity(), elementsSize, coordinateMask, scale, translation, logMask);
- }
- }
+ /**
+ * Returns the data height for the given object.
+ * @param id of the given object.
+ * @return the data height.
+ */
+ public static int getTextureHeight(String id) {
+ return DataLoader.getTextureHeight(id);
+ }
- public static void fillTextureCoordinates(String id, FloatBuffer buffer, int bufferLength) {
- DataLoader.fillTextureCoordinates(id, buffer, bufferLength);
- }
+ public static void fillTextureCoordinates(String id, FloatBuffer buffer, int bufferLength) {
+ DataLoader.fillTextureCoordinates(id, buffer, bufferLength);
+ }
- /**
- * Fills the given buffer with color data from the given object.
- * @param the id of the given object.
- * @param the buffer to fill.
- * @param the number of components taken by one element in the buffer (3 or 4).
- */
- public static void fillColors(String id, FloatBuffer buffer, int elementsSize) {
- String type = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
-
- if (JAVA_OBJECTS.contains(type)) {
- JavaObjectLoader.fillColors(id, buffer, elementsSize);
- } else {
- DataLoader.fillColors(id, buffer, buffer.capacity(), elementsSize);
- }
- }
+ public static void fillTextureData(String id, FloatBuffer buffer, int bufferLength) {
+ DataLoader.fillTextureData(id, buffer, bufferLength);
+ }
- /**
- * Returns the number of indices for the given object.
- * @param the id of the given object.
- * @return the object's number of indices.
- */
- public static int getIndicesSize(String id) {
- String type = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
-
- if (JAVA_OBJECTS.contains(type)) {
- return JavaObjectLoader.getIndicesSize(id);
- } else {
- return DataLoader.getIndicesSize(id);
- }
- }
+ public static void fillTextureData(String identifier, FloatBuffer buffer, int bufferLength, int x, int y, int width, int height) {
+ DataLoader.fillSubTextureData(identifier, buffer, bufferLength, x, y, width, height);
+ }
- /**
- * Fills the given buffer with indices data of the given object.
- * @param the id of the given object.
- * @param the buffer to fill.
- * @param the bit mask specifying whether logarithmic coordinates are used.
- * @return the number of indices actually written.
- */
- public static int fillIndices(String id, IntBuffer buffer, int logMask) {
- String type = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
-
- if (JAVA_OBJECTS.contains(type)) {
- return JavaObjectLoader.fillIndices(id, buffer, logMask);
- } else {
- return DataLoader.fillIndices(id, buffer, buffer.capacity(), logMask);
- }
- }
+ /**
+ * Returns the number of data elements for the given object.
+ * @param the id of the given object.
+ * @return the number of data elements.
+ */
+ public static int getDataSize(String id) {
+ String type = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
+
+ if (JAVA_OBJECTS.contains(type)) {
+ return JavaObjectLoader.getDataSize(id);
+ } else {
+ return DataLoader.getDataSize(id);
+ }
+ }
- /**
- * Returns the number of wireframe indices of the given object.
- * @param the id of the given object.
- * @return the object's number of indices.
- */
- public static int getWireIndicesSize(String id) {
- String type = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
-
- if (JAVA_OBJECTS.contains(type)) {
- return JavaObjectLoader.getWireIndicesSize(id);
- } else {
- return DataLoader.getWireIndicesSize(id);
- }
- }
+ /**
+ * Fills the given buffer with vertex data from the given object.
+ * @param the id of the given object.
+ * @param the buffer to fill.
+ * @param the number of coordinates taken by one element in the buffer.
+ * @param the bit mask specifying which coordinates are filled (1 for X, 2 for Y, 4 for Z).
+ * @param the conversion scale factor to apply to data.
+ * @param the conversion translation value to apply to data.
+ * @param the bit mask specifying whether logarithmic coordinates are used.
+ */
+ public static void fillVertices(String id, FloatBuffer buffer, int elementsSize,
+ int coordinateMask, double[] scale, double[] translation, int logMask) {
+ String type = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
+
+ if (JAVA_OBJECTS.contains(type)) {
+ JavaObjectLoader.fillVertices(id, buffer, elementsSize, coordinateMask, scale, translation, logMask);
+ } else {
+ DataLoader.fillVertices(id, buffer, buffer.capacity(), elementsSize, coordinateMask, scale, translation, logMask);
+ }
+ }
- /**
- * Fills the given buffer with wireframe index data of the given object.
- * @param the id of the given object.
- * @param the buffer to fill.
- * @param the bit mask specifying whether logarithmic coordinates are used.
- * @return the number of indices actually written.
- */
- public static int fillWireIndices(String id, IntBuffer buffer, int logMask) {
- String type = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
-
- if (JAVA_OBJECTS.contains(type)) {
- return JavaObjectLoader.fillWireIndices(id, buffer, logMask);
- } else {
- return DataLoader.fillWireIndices(id, buffer, buffer.capacity(), logMask);
- }
- }
+ /**
+ * Fills the given buffer with color data from the given object.
+ * @param the id of the given object.
+ * @param the buffer to fill.
+ * @param the number of components taken by one element in the buffer (3 or 4).
+ */
+ public static void fillColors(String id, FloatBuffer buffer, int elementsSize) {
+ String type = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
+
+ if (JAVA_OBJECTS.contains(type)) {
+ JavaObjectLoader.fillColors(id, buffer, elementsSize);
+ } else {
+ DataLoader.fillColors(id, buffer, buffer.capacity(), elementsSize);
+ }
+ }
- /**
- * Returns the number of mark indices of the given object.
- * To implement.
- * @param the id of the given object.
- * @return the number of mark indices.
- */
- public static int getMarkIndicesSize(String id)
- {
- return 0;
- }
+ /**
+ * Returns the number of indices for the given object.
+ * @param the id of the given object.
+ * @return the object's number of indices.
+ */
+ public static int getIndicesSize(String id) {
+ String type = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
+
+ if (JAVA_OBJECTS.contains(type)) {
+ return JavaObjectLoader.getIndicesSize(id);
+ } else {
+ return DataLoader.getIndicesSize(id);
+ }
+ }
- /**
- * Fills the given buffer with mark index data of the given object.
- * To implement.
- * @param the id of the given object.
- * @param the buffer to fill.
- * @return the number of indices actually written.
- */
- public static int fillMarkIndices(String id, IntBuffer buffer)
- {
- return 0;
- }
+ /**
+ * Fills the given buffer with indices data of the given object.
+ * @param the id of the given object.
+ * @param the buffer to fill.
+ * @param the bit mask specifying whether logarithmic coordinates are used.
+ * @return the number of indices actually written.
+ */
+ public static int fillIndices(String id, IntBuffer buffer, int logMask) {
+ String type = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
+
+ if (JAVA_OBJECTS.contains(type)) {
+ return JavaObjectLoader.fillIndices(id, buffer, logMask);
+ } else {
+ return DataLoader.fillIndices(id, buffer, buffer.capacity(), logMask);
+ }
+ }
+
+ /**
+ * Returns the number of wireframe indices of the given object.
+ * @param the id of the given object.
+ * @return the object's number of indices.
+ */
+ public static int getWireIndicesSize(String id) {
+ String type = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
+
+ if (JAVA_OBJECTS.contains(type)) {
+ return JavaObjectLoader.getWireIndicesSize(id);
+ } else {
+ return DataLoader.getWireIndicesSize(id);
+ }
+ }
+
+ /**
+ * Fills the given buffer with wireframe index data of the given object.
+ * @param the id of the given object.
+ * @param the buffer to fill.
+ * @param the bit mask specifying whether logarithmic coordinates are used.
+ * @return the number of indices actually written.
+ */
+ public static int fillWireIndices(String id, IntBuffer buffer, int logMask) {
+ String type = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
+
+ if (JAVA_OBJECTS.contains(type)) {
+ return JavaObjectLoader.fillWireIndices(id, buffer, logMask);
+ } else {
+ return DataLoader.fillWireIndices(id, buffer, buffer.capacity(), logMask);
+ }
+ }
+
+ /**
+ * Returns the number of mark indices of the given object.
+ * To implement.
+ * @param the id of the given object.
+ * @return the number of mark indices.
+ */
+ public static int getMarkIndicesSize(String id) {
+ return 0;
+ }
+
+ /**
+ * Fills the given buffer with mark index data of the given object.
+ * To implement.
+ * @param the id of the given object.
+ * @param the buffer to fill.
+ * @return the number of indices actually written.
+ */
+ public static int fillMarkIndices(String id, IntBuffer buffer) {
+ return 0;
+ }
public static int getLogMask(String id) {
try {
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2010 - DIGITEO - Pierre LANDO
+ * Copyright (C) 2010-2012 - DIGITEO - Pierre LANDO
* 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
%typemap(jni) CTYPE* LABEL "jobject"
%typemap(jtype) CTYPE* LABEL "BUFFERTYPE"
%typemap(jstype) CTYPE* LABEL "BUFFERTYPE"
- %typemap(javain,
- pre=" assert $javainput.isDirect() : \"Buffer must be allocated direct.\";") CTYPE* LABEL "$javainput"
+ %typemap(javain, pre=" assert $javainput.isDirect() : \"Buffer must be allocated direct.\";") CTYPE* LABEL "$javainput"
%typemap(javaout) CTYPE* LABEL {
return $jnicall;
}
%apply int *BUFF {int *buffer};
%inline %{
+ extern int getTextureWidth(char* id);
+ extern int getTextureHeight(char* id);
+ extern int fillTextureData(char* id, float* buffer, int bufferLength);
+ extern int fillSubTextureData(char* id, float* buffer, int bufferLength, int x, int y, int width, int height);
+
extern int getDataSize(char* id);
extern void fillVertices(char* id, float* buffer, int bufferLength, int elementsSize, int coordinateMask, double scale[], double translation[], int logMask);
extern void fillColors(char* id, float* buffer, int bufferLength, int elementsSize);
extern int getMarkIndicesSize(char* id);
extern int fillMarkIndices(char* id, int* BUFF, int bufferLength);
%}
-
#endif
+ extern int getTextureWidth(char* id);
+ extern int getTextureHeight(char* id);
+ extern int fillTextureData(char* id, float* buffer, int bufferLength);
+ extern int fillSubTextureData(char* id, float* buffer, int bufferLength, int x, int y, int width, int height);
+
extern int getDataSize(char* id);
extern void fillVertices(char* id, float* buffer, int bufferLength, int elementsSize, int coordinateMask, double scale[], double translation[], int logMask);
extern void fillColors(char* id, float* buffer, int bufferLength, int elementsSize);
extern "C" {
#endif
+SWIGEXPORT jint JNICALL Java_org_scilab_modules_graphic_1objects_DataLoaderJNI_getTextureWidth(JNIEnv *jenv, jclass jcls, jstring jarg1) {
+ jint jresult = 0 ;
+ char *arg1 = (char *) 0 ;
+ int result;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = 0;
+ if (jarg1) {
+ arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0);
+ if (!arg1) return 0;
+ }
+ result = (int)getTextureWidth(arg1);
+ jresult = (jint)result;
+ if (arg1) (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1);
+ return jresult;
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_scilab_modules_graphic_1objects_DataLoaderJNI_getTextureHeight(JNIEnv *jenv, jclass jcls, jstring jarg1) {
+ jint jresult = 0 ;
+ char *arg1 = (char *) 0 ;
+ int result;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = 0;
+ if (jarg1) {
+ arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0);
+ if (!arg1) return 0;
+ }
+ result = (int)getTextureHeight(arg1);
+ jresult = (jint)result;
+ if (arg1) (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1);
+ return jresult;
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_scilab_modules_graphic_1objects_DataLoaderJNI_fillTextureData(JNIEnv *jenv, jclass jcls, jstring jarg1, jobject jarg2, jint jarg3) {
+ jint jresult = 0 ;
+ char *arg1 = (char *) 0 ;
+ float *arg2 = (float *) 0 ;
+ int arg3 ;
+ int result;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = 0;
+ if (jarg1) {
+ arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0);
+ if (!arg1) return 0;
+ }
+ {
+ arg2 = (*jenv)->GetDirectBufferAddress(jenv, jarg2);
+ if (arg2 == NULL) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "Unable to get address of direct buffer. Buffer must be allocated direct.");
+ }
+ }
+ arg3 = (int)jarg3;
+ result = (int)fillTextureData(arg1,arg2,arg3);
+ jresult = (jint)result;
+ if (arg1) (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1);
+ return jresult;
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_scilab_modules_graphic_1objects_DataLoaderJNI_fillSubTextureData(JNIEnv *jenv, jclass jcls, jstring jarg1, jobject jarg2, jint jarg3, jint jarg4, jint jarg5, jint jarg6, jint jarg7) {
+ jint jresult = 0 ;
+ char *arg1 = (char *) 0 ;
+ float *arg2 = (float *) 0 ;
+ int arg3 ;
+ int arg4 ;
+ int arg5 ;
+ int arg6 ;
+ int arg7 ;
+ int result;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = 0;
+ if (jarg1) {
+ arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0);
+ if (!arg1) return 0;
+ }
+ {
+ arg2 = (*jenv)->GetDirectBufferAddress(jenv, jarg2);
+ if (arg2 == NULL) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "Unable to get address of direct buffer. Buffer must be allocated direct.");
+ }
+ }
+ arg3 = (int)jarg3;
+ arg4 = (int)jarg4;
+ arg5 = (int)jarg5;
+ arg6 = (int)jarg6;
+ arg7 = (int)jarg7;
+ result = (int)fillSubTextureData(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
+ jresult = (jint)result;
+ if (arg1) (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1);
+ return jresult;
+}
+
+
SWIGEXPORT jint JNICALL Java_org_scilab_modules_graphic_1objects_DataLoaderJNI_getDataSize(JNIEnv *jenv, jclass jcls, jstring jarg1) {
jint jresult = 0 ;
char *arg1 = (char *) 0 ;
import org.scilab.forge.scirenderer.texture.AbstractDataProvider;
import org.scilab.forge.scirenderer.texture.Texture;
import org.scilab.forge.scirenderer.texture.TextureDataProvider;
+import org.scilab.forge.scirenderer.tranformations.Transformation;
+import org.scilab.forge.scirenderer.tranformations.TransformationFactory;
+import org.scilab.forge.scirenderer.tranformations.TransformationStack;
import org.scilab.modules.graphic_objects.arc.Arc;
import org.scilab.modules.graphic_objects.axes.Axes;
import org.scilab.modules.graphic_objects.axis.Axis;
private final ColorMapTextureDataProvider colorMapTextureDataProvider;
+ private final TextureManager textureManager;
private final MarkSpriteManager markManager;
private final LabelManager labelManager;
private final DataManager dataManager;
private Texture colorMapTexture;
private ColorMap colorMap;
+ private Axes currentAxes;
+
/**
* The map between the existing Figures' identifiers and their corresponding Visitor.
* Used to get access to the DrawerVisitor corresponding to a given Figure when the
this.figure = figure;
this.dataManager = new DataManager(canvas);
+ this.textureManager = new TextureManager(this);
this.markManager = new MarkSpriteManager(canvas.getSpriteManager());
this.textManager = new TextManager(canvas.getSpriteManager());
this.labelManager = new LabelManager(canvas.getSpriteManager());
public void visit(Axes axes) {
if (axes.getVisible()) {
try {
+ currentAxes = axes;
axesDrawer.draw(axes);
} catch (SciRendererException e) {
System.err.println("A '" + axes.getType() + "' is not drawable because: '" + e.getMessage() + "'");
public void visit(final Matplot matplot) {
if (matplot.getVisible()) {
try {
- DefaultGeometry triangles = new DefaultGeometry();
- triangles.setFillDrawingMode(Geometry.FillDrawingMode.TRIANGLES);
- triangles.setVertices(dataManager.getVertexBuffer(matplot.getIdentifier()));
- triangles.setColors(dataManager.getColorBuffer(matplot.getIdentifier()));
- triangles.setIndices(dataManager.getIndexBuffer(matplot.getIdentifier()));
- triangles.setFaceCullingMode(Geometry.FaceCullingMode.BOTH);
- Appearance trianglesAppearance = new Appearance();
- drawingTools.draw(triangles, trianglesAppearance);
+ if ((currentAxes != null) && (currentAxes.getXAxisLogFlag() || currentAxes.getYAxisLogFlag())) {
+ DefaultGeometry geometry = new DefaultGeometry();
+ geometry.setFillDrawingMode(Geometry.FillDrawingMode.TRIANGLES);
+ geometry.setVertices(dataManager.getVertexBuffer(matplot.getIdentifier()));
+ geometry.setColors(dataManager.getColorBuffer(matplot.getIdentifier()));
+ geometry.setIndices(dataManager.getIndexBuffer(matplot.getIdentifier()));
+ geometry.setFaceCullingMode(Geometry.FaceCullingMode.BOTH);
+ Appearance appearance = new Appearance();
+ drawingTools.draw(geometry, appearance);
+ } else {
+ TransformationStack modelViewStack = drawingTools.getTransformationManager().getModelViewStack();
+ Transformation t = TransformationFactory.getTranslateTransformation(.5, .5, 0);
+ modelViewStack.pushRightMultiply(t);
+ drawingTools.draw(textureManager.getTexture(matplot.getIdentifier()));
+ modelViewStack.pop();
+ }
} catch (SciRendererException e) {
System.err.println("A '" + matplot.getType() + "' is not drawable because: '" + e.getMessage() + "'");
}
}
}
}
-
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2012 - DIGITEO - Pierre Lando
+ *
+ * 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-en.txt
+ */
+
+package org.scilab.modules.renderer.JoGLView;
+
+import com.sun.opengl.util.BufferUtil;
+import org.scilab.forge.scirenderer.Canvas;
+import org.scilab.forge.scirenderer.texture.AbstractDataProvider;
+import org.scilab.forge.scirenderer.texture.Texture;
+import org.scilab.forge.scirenderer.texture.TextureDataProvider;
+import org.scilab.modules.graphic_objects.MainDataLoader;
+import org.scilab.modules.graphic_objects.graphicController.GraphicController;
+import org.scilab.modules.graphic_objects.graphicView.GraphicView;
+
+import java.awt.Dimension;
+import java.nio.Buffer;
+import java.nio.FloatBuffer;
+import java.util.HashMap;
+
+/**
+ * @author Pierre Lando
+ */
+public class TextureManager {
+
+ private final HashMap<String, Texture> hashMap = new HashMap<String, Texture>();
+ private final Canvas canvas;
+
+ public TextureManager(DrawerVisitor drawerVisitor) {
+ this.canvas = drawerVisitor.getCanvas();
+ }
+
+ /**
+ * {@link Texture} getter.
+ * @param identifier object identifier.
+ * @return the {@link Texture} used to drawn the object who have the given identifier.
+ */
+ public Texture getTexture(String identifier) {
+ Texture texture = hashMap.get(identifier);
+ if (texture == null) {
+ texture = canvas.getTextureManager().createTexture();
+ texture.setDataProvider(new ScilabTextureDataProvider(identifier));
+ texture.setMagnificationFilter(Texture.Filter.NEAREST);
+ texture.setMinifyingFilter(Texture.Filter.NEAREST);
+ hashMap.put(identifier, texture);
+ }
+ return texture;
+ }
+
+
+ private class ScilabTextureDataProvider extends AbstractDataProvider<Texture> implements TextureDataProvider, GraphicView {
+ private final String identifier;
+ private Dimension dimension;
+ private boolean isValid;
+
+ public ScilabTextureDataProvider(String identifier) {
+ this.identifier = identifier;
+ this.isValid = (identifier != null);
+
+ if (isValid()) {
+ updateData();
+ }
+ GraphicController.getController().register(this);
+ }
+
+ private void updateData() {
+ int width = MainDataLoader.getTextureWidth(identifier);
+ int height = MainDataLoader.getTextureHeight(identifier);
+ dimension = new Dimension(width, height);
+ fireUpdate();
+ }
+
+ @Override
+ public Dimension getTextureSize() {
+ if (isValid()) {
+ return new Dimension(dimension);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public Buffer getData() {
+ int bufferLength = dimension.width * dimension.height * 4;
+ FloatBuffer buffer;
+ try {
+ buffer = BufferUtil.newFloatBuffer(bufferLength);
+ } catch (OutOfMemoryError error) {
+ // TODO: Scilab error.
+ System.out.println("Java heap space to small, can't get " + bufferLength / (1024*1024) + "MBytes");
+ return null;
+ }
+ MainDataLoader.fillTextureData(identifier, buffer, bufferLength);
+ buffer.rewind();
+ return buffer;
+ }
+
+ @Override
+ public Buffer getSubData(int x, int y, int width, int height) {
+ int bufferLength = width * height * 4;
+ FloatBuffer buffer;
+ try {
+ buffer = BufferUtil.newFloatBuffer(bufferLength);
+ } catch (OutOfMemoryError error) {
+ // TODO: Scilab error.
+ System.out.println("Java heap space to small, can't get " + bufferLength / (1024*1024) + "MBytes");
+ return null;
+ }
+ MainDataLoader.fillTextureData(identifier, buffer, bufferLength, x, y, width, height);
+ buffer.rewind();
+ return buffer;
+ }
+
+ @Override
+ public boolean isValid() {
+ return isValid;
+ }
+
+ @Override
+ public void updateObject(String id, String property) {
+ if (isValid() && identifier.equals(id)) {
+ // TODO check Property.
+ // System.out.println("Prop: " + property);
+ updateData();
+ }
+ }
+
+ @Override
+ public void deleteObject(String id) {
+ if (isValid() && identifier.equals(id)) {
+ isValid = false;
+ // TODO: GraphicController.getController().unRegister(this);
+ }
+ }
+
+ @Override
+ public void createObject(String id) {
+ }
+ }
+}