Adds possibility to color marks in scatter plots 27/16327/3
Calixte DENIZET [Sun, 24 Feb 2013 21:51:49 +0000 (22:51 +0100)]
Change-Id: I64226da83167765a26e9eba0f9ae775161658f8f

33 files changed:
scilab/CHANGES_5.6.X [moved from scilab/CHANGES_5.6.x with 65% similarity]
scilab/modules/graphic_objects/includes/NgonPolylineData.hxx
scilab/modules/graphic_objects/includes/graphicObjectProperties.h
scilab/modules/graphic_objects/src/cpp/NgonPolylineData.cpp
scilab/modules/graphic_objects/src/cpp/PolylineDecomposer.cpp
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/graphicObject/GraphicObjectProperties.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/polyline/Polyline.java
scilab/modules/graphic_objects/src/scripts/propertiesMap.properties
scilab/modules/graphics/Makefile.am
scilab/modules/graphics/Makefile.in
scilab/modules/graphics/graphics.vcxproj
scilab/modules/graphics/graphics.vcxproj.filters
scilab/modules/graphics/macros/%h_p.sci
scilab/modules/graphics/src/c/getHandleProperty/GetHashTable.c
scilab/modules/graphics/src/c/getHandleProperty/SetHashTable.c
scilab/modules/graphics/src/c/getHandleProperty/getHandleProperty.h
scilab/modules/graphics/src/c/getHandleProperty/get_colors_property.c [new file with mode: 0644]
scilab/modules/graphics/src/c/getHandleProperty/setHandleProperty.h
scilab/modules/graphics/src/c/getHandleProperty/set_color_property.c [new file with mode: 0644]
scilab/modules/graphics/src/c/getHandleProperty/set_colors_property.c [new file with mode: 0644]
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/DrawerVisitor.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/mark/MarkSpriteFactory.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/mark/MarkSpriteManager.java
scilab/modules/renderer/tests/unit_tests/mark_color.tst [new file with mode: 0644]
scilab/modules/renderer/tests/unit_tests/mark_color3d.tst [new file with mode: 0644]
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/DrawingTools.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/g2d/G2DDrawingTools.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/g2d/motor/Motor3D.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/g2d/motor/SpritedRectangle.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/g2d/texture/G2DTextureDrawingTools.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/jogl/JoGLDrawingTools.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/jogl/drawer/JoGLShapeDrawer.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/jogl/texture/JoGLTextureManager.java

similarity index 65%
rename from scilab/CHANGES_5.6.x
rename to scilab/CHANGES_5.6.X
index 85b99ec..c331d1c 100644 (file)
@@ -1,7 +1,12 @@
-
                      Changes between version 5.5.1 and 5.6.0
                      =======================================
 
+New Features
+=============
+
+* scatter plot with different mark colors is now available:
+  TODO : save/load+display+doc of new properties
+
 
 Compilation
 ============
index b6e9df4..eb6481b 100644 (file)
@@ -59,6 +59,11 @@ private :
     int* display_function_data;
     int display_function_data_size;
 
+    /** The colors array */
+    int* colors;
+
+    int numColors;
+
 public :
     /**
      * Constructor
@@ -213,6 +218,12 @@ public :
      */
     void copyShiftCoordinatesArray(double * newShift, double const* oldShift, int numElementsNew);
 
+    int setColors(int const* newColors, int numElements);
+
+    int * getColors();
+
+    int getNumColors();
+
     /**
      * Deletes the coordinates and shift arrays
      */
index 63f71de..578ec0f 100755 (executable)
 #define __GO_UI_TITLE_SCROLL__ 391
 #define __GO_UI_FRAME_BORDER_TYPE__ 392
 #define __GO_UI_SCROLLABLE__ 393
+#define __GO_COLOR_SET__ 394
 
 #endif /* !__GRAPHIC_OBJECT_PROPERTIES_H__ */
index d28fd2d..989d554 100644 (file)
@@ -40,6 +40,7 @@ NgonPolylineData::NgonPolylineData(void)
     display_function_data = NULL;
     display_function_data_size = 0;
 
+    colors = NULL;
 }
 
 NgonPolylineData::~NgonPolylineData(void)
@@ -63,6 +64,11 @@ NgonPolylineData::~NgonPolylineData(void)
     {
         delete[] display_function_data;
     }
+
+    if (colors)
+    {
+        delete [] colors;
+    }
 }
 
 int NgonPolylineData::getPropertyFromName(int propertyName)
@@ -91,6 +97,10 @@ int NgonPolylineData::getPropertyFromName(int propertyName)
             return DISPLAY_FUNCTION_DATA;
         case __GO_DATA_MODEL_DISPLAY_FUNCTION_SIZE__ :
             return DISPLAY_FUNCTION_DATA_SIZE;
+        case __GO_DATA_MODEL_COLORS__ :
+            return COLORS;
+        case __GO_DATA_MODEL_NUM_COLORS__ :
+            return NUM_COLORS;
         default :
             return NgonGeneralData::getPropertyFromName(propertyName);
     }
@@ -125,11 +135,12 @@ int NgonPolylineData::setDataProperty(int property, void const* value, int numEl
         case DISPLAY_FUNCTION_DATA :
             setDisplayFunctionData((int const*) value, numElements);
             break;
+        case COLORS :
+            setColors((int const*) value, numElements);
+            break;
         default :
             return NgonGeneralData::setDataProperty(property, value, numElements);
     }
-
-    return 1;
 }
 
 void NgonPolylineData::getDataProperty(int property, void **_pvData)
@@ -166,6 +177,12 @@ void NgonPolylineData::getDataProperty(int property, void **_pvData)
         case DISPLAY_FUNCTION_DATA_SIZE :
             ((int *) *_pvData)[0] = getDisplayFunctionDataSize();
             break;
+        case COLORS :
+            *_pvData = getColors();
+            break;
+        case NUM_COLORS :
+            ((int *) *_pvData)[0] = getNumColors();
+            break;
         default :
             NgonGeneralData::getDataProperty(property, _pvData);
     }
@@ -480,6 +497,54 @@ int NgonPolylineData::setNumElementsArray(int const* numElementsArray)
     return result;
 }
 
+int NgonPolylineData::getNumColors(void)
+{
+    return numColors;
+}
+
+int* NgonPolylineData::getColors(void)
+{
+    return colors;
+}
+
+int NgonPolylineData::setColors(int const* newColors, int numElements)
+{
+    int * _newColors = 0;
+
+    if (numElements == 0)
+    {
+        if (colors)
+        {
+            delete[] colors;
+        }
+        colors = NULL;
+        numColors = 0;
+
+        return 1;
+    }
+
+    try
+    {
+        _newColors = new int[numElements];
+    }
+    catch (const std::exception& e)
+    {
+        e.what();
+        return 0;
+    }
+
+    memcpy(_newColors, newColors, numElements * sizeof(int));
+    if (colors)
+    {
+        delete[] colors;
+    }
+
+    colors = _newColors;
+    numColors = numElements;
+
+    return 1;
+}
+
 void NgonPolylineData::copyShiftCoordinatesArray(double * newShift, double const* oldShift, int numElementsNew)
 {
     int numElementsCopied = 0;
@@ -565,4 +630,4 @@ int NgonPolylineData::setDisplayFunctionData(int const* data, int numElements)
 
     memcpy(display_function_data, data, display_function_data_size * sizeof(int));
     return 1;
-}
\ No newline at end of file
+}
index 6d9310b..1e07033 100644 (file)
@@ -667,6 +667,8 @@ void PolylineDecomposer::fillColors(int id, float* buffer, int bufferLength, int
 
     int interpColorMode = 0;
     int* piInterpColorMode = &interpColorMode;
+    int colorSet = 0;
+    int* piColorSet = &colorSet;
     int polylineStyle = 0;
     int* piPolylineStyle = &polylineStyle;
     int nPoints = 0;
@@ -679,15 +681,16 @@ void PolylineDecomposer::fillColors(int id, float* buffer, int bufferLength, int
     double* colormap = NULL;
 
     getGraphicObjectProperty(id, __GO_INTERP_COLOR_MODE__, jni_bool, (void**) &piInterpColorMode);
+    getGraphicObjectProperty(id, __GO_COLOR_SET__, jni_bool, (void**) &piColorSet);
 
-    if (interpColorMode == 0)
+    if (interpColorMode == 0 && colorSet == 0)
     {
         return;
     }
 
     getGraphicObjectProperty(id, __GO_POLYLINE_STYLE__, jni_int, (void**) &piPolylineStyle);
 
-    if (polylineStyle  != 1)
+    if (polylineStyle != 1 && colorSet == 0)
     {
         return;
     }
@@ -718,39 +721,76 @@ void PolylineDecomposer::fillColors(int id, float* buffer, int bufferLength, int
         return;
     }
 
-    /*
-     * The interpolated color vector is a 3- or 4-element vector.
-     * However, if nPoints is greater than 4, we choose to output
-     * 4 colors (this behaviour is kept for compatibility, see fillTriangleIndices).
-     */
-    if (nPoints < 3)
+    if (interpColorMode == 1)
     {
-        return;
-    }
+        /*
+         * The interpolated color vector is a 3- or 4-element vector.
+         * However, if nPoints is greater than 4, we choose to output
+         * 4 colors (this behaviour is kept for compatibility, see fillTriangleIndices).
+         */
+        if (nPoints < 3)
+        {
+            return;
+        }
 
-    getGraphicObjectProperty(id, __GO_INTERP_COLOR_VECTOR__, jni_int_vector, (void**) &interpColorVector);
-    getGraphicObjectProperty(parentFigure, __GO_COLORMAP__, jni_double_vector, (void**) &colormap);
-    getGraphicObjectProperty(parentFigure, __GO_COLORMAP_SIZE__, jni_int, (void**) &piColormapSize);
+        getGraphicObjectProperty(id, __GO_INTERP_COLOR_VECTOR__, jni_int_vector, (void**) &interpColorVector);
+        getGraphicObjectProperty(parentFigure, __GO_COLORMAP__, jni_double_vector, (void**) &colormap);
+        getGraphicObjectProperty(parentFigure, __GO_COLORMAP_SIZE__, jni_int, (void**) &piColormapSize);
 
-    if (nPoints > 4)
-    {
-        nPoints = 4;
-    }
+        if (nPoints > 4)
+        {
+            nPoints = 4;
+        }
 
-    for (int i = 0; i < nPoints; i++)
+        for (int i = 0; i < nPoints; i++)
+        {
+            ColorComputer::getDirectColor((double) interpColorVector[i] - 1.0, colormap, colormapSize, &buffer[bufferOffset]);
+
+            if (elementsSize == 4)
+            {
+                buffer[bufferOffset + 3] = 1.0;
+            }
+
+            bufferOffset += elementsSize;
+        }
+
+        releaseGraphicObjectProperty(__GO_COLORMAP__, colormap, jni_double_vector, colormapSize);
+        releaseGraphicObjectProperty(__GO_INTERP_COLOR_VECTOR__, interpColorVector, jni_int_vector, 0);
+    }
+    else
     {
-        ColorComputer::getDirectColor((double) interpColorVector[i] - 1.0, colormap, colormapSize, &buffer[bufferOffset]);
+        int* colors = NULL;
+        int numColors = 0;
+        int * piNumColors = &numColors;
+        int min;
 
-        if (elementsSize == 4)
+        getGraphicObjectProperty(id, __GO_DATA_MODEL_NUM_COLORS__, jni_int, (void**) &piNumColors);
+        getGraphicObjectProperty(id, __GO_DATA_MODEL_COLORS__, jni_int_vector, (void**) &colors);
+        if (!colors)
         {
             buffer[bufferOffset + 3] = 1.0;
         }
 
-        bufferOffset += elementsSize;
-    }
+        min = nPoints < numColors ? nPoints : numColors;
 
-    releaseGraphicObjectProperty(__GO_COLORMAP__, colormap, jni_double_vector, colormapSize);
-    releaseGraphicObjectProperty(__GO_INTERP_COLOR_VECTOR__, interpColorVector, jni_int_vector, 0);
+        getGraphicObjectProperty(parentFigure, __GO_COLORMAP__, jni_double_vector, (void**) &colormap);
+        getGraphicObjectProperty(parentFigure, __GO_COLORMAP_SIZE__, jni_int, (void**) &piColormapSize);
+
+        for (int i = 0; i < min; i++)
+        {
+            ColorComputer::getDirectColor(colors[i] - 1.0, colormap, colormapSize, &buffer[bufferOffset]);
+
+            if (elementsSize == 4)
+            {
+                buffer[bufferOffset + 3] = 1.0;
+            }
+
+            bufferOffset += elementsSize;
+        }
+
+        releaseGraphicObjectProperty(__GO_COLORMAP__, colormap, jni_double_vector, colormapSize);
+        releaseGraphicObjectProperty(__GO_INTERP_COLOR_VECTOR__, interpColorVector, jni_int_vector, 0);
+    }
 }
 
 void PolylineDecomposer::fillTextureCoordinates(int id, float* buffer, int bufferLength)
index f5b4305..a865ff2 100755 (executable)
@@ -415,5 +415,6 @@ public class GraphicObjectProperties {
     public static final int __GO_UI_TITLE_SCROLL__ = 391;
     public static final int __GO_UI_FRAME_BORDER_TYPE__ = 392;
     public static final int __GO_UI_SCROLLABLE__ = 393;
+    public static final int __GO_COLOR_SET__ = 394;
 
 }
index 0c3892f..8af2f84 100644 (file)
@@ -26,6 +26,7 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_X_SHIFT__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_Y_SHIFT__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_Z_SHIFT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_COLOR_SET__;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -50,7 +51,8 @@ public class Polyline extends ClippableContouredObject {
     /** Polyline properties names */
     private enum PolylineProperty { CLOSED, ARROWSIZEFACTOR, POLYLINESTYLE,
                                     INTERPCOLORVECTOR, INTERPCOLORVECTORSET, INTERPCOLORMODE,
-                                    XSHIFT, YSHIFT, ZSHIFT, BARWIDTH, DATATIPS, DATATIPSCOUNT, TIP_DISPLAY_FNC, TIP_MARK
+                                    XSHIFT, YSHIFT, ZSHIFT, BARWIDTH, DATATIPS, DATATIPSCOUNT,
+                                    TIP_DISPLAY_FNC, TIP_MARK, COLORSET
                                   };
 
     /** Specifies whether the polyline is closed */
@@ -91,6 +93,8 @@ public class Polyline extends ClippableContouredObject {
 
     private Integer tipMark;
 
+    private boolean colorSet;
+
     /** Constructor */
     public Polyline() {
         super();
@@ -107,6 +111,7 @@ public class Polyline extends ClippableContouredObject {
         datatips = new ArrayList<Integer>();
         displayFnc = "";
         tipMark = 11;
+        colorSet = false;
     }
 
     @Override
@@ -149,6 +154,8 @@ public class Polyline extends ClippableContouredObject {
                 return PolylineProperty.TIP_DISPLAY_FNC;
             case __GO_DATATIP_MARK__ :
                 return PolylineProperty.TIP_MARK;
+            case __GO_COLOR_SET__ :
+                return PolylineProperty.COLORSET;
             default :
                 return super.getPropertyFromName(propertyName);
         }
@@ -190,6 +197,8 @@ public class Polyline extends ClippableContouredObject {
                     return getDisplayFunction();
                 case TIP_MARK:
                     return getTipMark();
+                case COLORSET:
+                    return getColorSet();
             }
         }
         return super.getProperty(property);
@@ -241,6 +250,9 @@ public class Polyline extends ClippableContouredObject {
                     case TIP_MARK:
                         setTipMark((Integer) value);
                         break;
+                    case COLORSET:
+                        setColorSet((Boolean) value);
+                        break;
                 }
             }
             return super.setProperty(property, value);
@@ -418,13 +430,6 @@ public class Polyline extends ClippableContouredObject {
     }
 
     /**
-     * @return Type as String
-     */
-    public Integer getType() {
-        return GraphicObjectProperties.__GO_POLYLINE__;
-    }
-
-    /**
      * @return datatips
      */
     public Integer[] getDatatips() {
@@ -475,4 +480,26 @@ public class Polyline extends ClippableContouredObject {
 
         return UpdateStatus.NoChange;
     }
+
+    /**
+     * @return the colorSet
+     */
+    public Boolean getColorSet() {
+        return colorSet;
+    }
+
+    /**
+     * @param colorSet the colorSet to set
+     */
+    public UpdateStatus setColorSet(Boolean colorSet) {
+        this.colorSet = colorSet;
+        return UpdateStatus.Success;
+    }
+
+    /**
+     * @return Type as String
+     */
+    public Integer getType() {
+        return GraphicObjectProperties.__GO_POLYLINE__;
+    }
 }
index 40c6204..d3df5e5 100644 (file)
@@ -348,6 +348,8 @@ src/c/getHandleProperty/get_marks_count_property.c \
 src/c/getHandleProperty/set_marks_count_property.c \
 src/c/getHandleProperty/get_line_width_property.c \
 src/c/getHandleProperty/set_line_width_property.c \
+src/c/getHandleProperty/set_colors_property.c \
+src/c/getHandleProperty/get_colors_property.c \
 src/c/DefaultCommandArg.c \
 src/c/Axes.c \
 src/c/sciMatrix.c \
index 060b475..6fbd0c8 100644 (file)
@@ -495,6 +495,8 @@ am__objects_1 = src/c/libscigraphics_algo_la-GetCommandArg.lo \
        src/c/getHandleProperty/libscigraphics_algo_la-set_marks_count_property.lo \
        src/c/getHandleProperty/libscigraphics_algo_la-get_line_width_property.lo \
        src/c/getHandleProperty/libscigraphics_algo_la-set_line_width_property.lo \
+       src/c/getHandleProperty/libscigraphics_algo_la-set_colors_property.lo \
+       src/c/getHandleProperty/libscigraphics_algo_la-get_colors_property.lo \
        src/c/libscigraphics_algo_la-DefaultCommandArg.lo \
        src/c/libscigraphics_algo_la-Axes.lo \
        src/c/libscigraphics_algo_la-sciMatrix.lo \
@@ -1322,6 +1324,8 @@ src/c/getHandleProperty/get_marks_count_property.c \
 src/c/getHandleProperty/set_marks_count_property.c \
 src/c/getHandleProperty/get_line_width_property.c \
 src/c/getHandleProperty/set_line_width_property.c \
+src/c/getHandleProperty/set_colors_property.c \
+src/c/getHandleProperty/get_colors_property.c \
 src/c/DefaultCommandArg.c \
 src/c/Axes.c \
 src/c/sciMatrix.c \
@@ -2656,6 +2660,12 @@ src/c/getHandleProperty/libscigraphics_algo_la-get_line_width_property.lo:  \
 src/c/getHandleProperty/libscigraphics_algo_la-set_line_width_property.lo:  \
        src/c/getHandleProperty/$(am__dirstamp) \
        src/c/getHandleProperty/$(DEPDIR)/$(am__dirstamp)
+src/c/getHandleProperty/libscigraphics_algo_la-set_colors_property.lo:  \
+       src/c/getHandleProperty/$(am__dirstamp) \
+       src/c/getHandleProperty/$(DEPDIR)/$(am__dirstamp)
+src/c/getHandleProperty/libscigraphics_algo_la-get_colors_property.lo:  \
+       src/c/getHandleProperty/$(am__dirstamp) \
+       src/c/getHandleProperty/$(DEPDIR)/$(am__dirstamp)
 src/c/libscigraphics_algo_la-DefaultCommandArg.lo:  \
        src/c/$(am__dirstamp) src/c/$(DEPDIR)/$(am__dirstamp)
 src/c/libscigraphics_algo_la-Axes.lo: src/c/$(am__dirstamp) \
@@ -3153,6 +3163,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_color_mode_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_color_range_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_colored_property.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_colors_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_constraints_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_cube_scaling_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_current_axes_property.Plo@am__quote@
@@ -3320,6 +3331,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_color_mode_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_color_range_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_colored_property.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_colors_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_constraints_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_cube_scaling_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_current_axes_property.Plo@am__quote@
@@ -5737,6 +5749,20 @@ src/c/getHandleProperty/libscigraphics_algo_la-set_line_width_property.lo: src/c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/getHandleProperty/libscigraphics_algo_la-set_line_width_property.lo `test -f 'src/c/getHandleProperty/set_line_width_property.c' || echo '$(srcdir)/'`src/c/getHandleProperty/set_line_width_property.c
 
+src/c/getHandleProperty/libscigraphics_algo_la-set_colors_property.lo: src/c/getHandleProperty/set_colors_property.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/c/getHandleProperty/libscigraphics_algo_la-set_colors_property.lo -MD -MP -MF src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_colors_property.Tpo -c -o src/c/getHandleProperty/libscigraphics_algo_la-set_colors_property.lo `test -f 'src/c/getHandleProperty/set_colors_property.c' || echo '$(srcdir)/'`src/c/getHandleProperty/set_colors_property.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_colors_property.Tpo src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_colors_property.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='src/c/getHandleProperty/set_colors_property.c' object='src/c/getHandleProperty/libscigraphics_algo_la-set_colors_property.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/getHandleProperty/libscigraphics_algo_la-set_colors_property.lo `test -f 'src/c/getHandleProperty/set_colors_property.c' || echo '$(srcdir)/'`src/c/getHandleProperty/set_colors_property.c
+
+src/c/getHandleProperty/libscigraphics_algo_la-get_colors_property.lo: src/c/getHandleProperty/get_colors_property.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/c/getHandleProperty/libscigraphics_algo_la-get_colors_property.lo -MD -MP -MF src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_colors_property.Tpo -c -o src/c/getHandleProperty/libscigraphics_algo_la-get_colors_property.lo `test -f 'src/c/getHandleProperty/get_colors_property.c' || echo '$(srcdir)/'`src/c/getHandleProperty/get_colors_property.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_colors_property.Tpo src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_colors_property.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='src/c/getHandleProperty/get_colors_property.c' object='src/c/getHandleProperty/libscigraphics_algo_la-get_colors_property.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/getHandleProperty/libscigraphics_algo_la-get_colors_property.lo `test -f 'src/c/getHandleProperty/get_colors_property.c' || echo '$(srcdir)/'`src/c/getHandleProperty/get_colors_property.c
+
 src/c/libscigraphics_algo_la-DefaultCommandArg.lo: src/c/DefaultCommandArg.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/c/libscigraphics_algo_la-DefaultCommandArg.lo -MD -MP -MF src/c/$(DEPDIR)/libscigraphics_algo_la-DefaultCommandArg.Tpo -c -o src/c/libscigraphics_algo_la-DefaultCommandArg.lo `test -f 'src/c/DefaultCommandArg.c' || echo '$(srcdir)/'`src/c/DefaultCommandArg.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) src/c/$(DEPDIR)/libscigraphics_algo_la-DefaultCommandArg.Tpo src/c/$(DEPDIR)/libscigraphics_algo_la-DefaultCommandArg.Plo
index e0e63e4..d1c46a3 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="Debug|Win32">
@@ -256,6 +256,7 @@ lib /DEF:"$(ProjectDir)elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS /MA
     <ClCompile Include="src\c\getHandleProperty\get_color_mode_property.c" />
     <ClCompile Include="src\c\getHandleProperty\get_color_range_property.c" />
     <ClCompile Include="src\c\getHandleProperty\get_colored_property.c" />
+    <ClCompile Include="src\c\getHandleProperty\get_colors_property.c" />
     <ClCompile Include="src\c\getHandleProperty\get_cube_scaling_property.c" />
     <ClCompile Include="src\c\getHandleProperty\get_current_axes_property.c" />
     <ClCompile Include="src\c\getHandleProperty\get_current_entity_property.c" />
@@ -529,7 +530,9 @@ lib /DEF:"$(ProjectDir)elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS /MA
     <ClCompile Include="src\c\getHandleProperty\set_color_map_property.c" />
     <ClCompile Include="src\c\getHandleProperty\set_color_mode_property.c" />
     <ClCompile Include="src\c\getHandleProperty\set_color_range_property.c" />
+    <ClCompile Include="src\c\getHandleProperty\set_color_property.c" />
     <ClCompile Include="src\c\getHandleProperty\set_colored_property.c" />
+    <ClCompile Include="src\c\getHandleProperty\set_colors_property.c" />
     <ClCompile Include="src\c\getHandleProperty\set_cube_scaling_property.c" />
     <ClCompile Include="src\c\getHandleProperty\set_current_axes_property.c" />
     <ClCompile Include="src\c\getHandleProperty\set_current_entity_property.c" />
@@ -752,4 +755,4 @@ lib /DEF:"$(ProjectDir)elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS /MA
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
index 446bcbb..b9a1192 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup>
     <Filter Include="Source Files">
     <ClCompile Include="src\c\getHandleProperty\get_colored_property.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="src\c\getHandleProperty\get_colors_property.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="src\c\getHandleProperty\get_cube_scaling_property.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="src\c\getHandleProperty\set_color_range_property.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="src\c\getHandleProperty\set_color_property.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="src\c\getHandleProperty\set_colored_property.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="src\c\getHandleProperty\set_colors_property.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="src\c\getHandleProperty\set_cube_scaling_property.c">
       <Filter>Source Files</Filter>
     </ClCompile>
       <Filter>Resource Files</Filter>
     </ResourceCompile>
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
index 90428f8..906d152 100755 (executable)
@@ -75,6 +75,7 @@ function %h_p(h)
             "background = "+string(h.background)
             "interp_color_vector = "+sci2exp(h.interp_color_vector)
             "interp_color_mode = "+sci2exp(h.interp_color_mode)
+            "colors = "+sci2exp(h.colors)
             "mark_mode = "+sci2exp(h.mark_mode)
             "mark_style = "+sci2exp(h.mark_style)
             "mark_size_unit = "+sci2exp(h.mark_size_unit)
index bbe65b2..9d40fed 100755 (executable)
@@ -253,6 +253,7 @@ static getHashTableCouple propertyGetTable[] =
     {"marks_count", get_marks_count_property},
     {"ticks_format", get_ticks_format_property},
     {"ticks_st", get_ticks_st_property},
+    {"colors", get_colors_property}
 };
 
 /*--------------------------------------------------------------------------*/
index f74d4cd..c95fc91 100755 (executable)
@@ -255,6 +255,7 @@ static setHashTableCouple propertySetTable[] =
     {"marks_count", set_marks_count_property},
     {"ticks_format", set_ticks_format_property},
     {"ticks_st", set_ticks_st_property},
+    {"colors", set_colors_property}
 };
 
 /*--------------------------------------------------------------------------*/
index 5d944f9..2678f14 100755 (executable)
@@ -199,5 +199,6 @@ int get_marks_count_property(void* _pvCtx, int iObjUID);
 int get_auto_margins_property(void* _pvCtx, int iObjUID);
 int get_ticks_format_property(void* _pvCtx, int iObjUID);
 int get_ticks_st_property(void* _pvCtx, int iObjUID);
+int get_colors_property(void* _pvCtx, char *pobjUID);
 
 #endif /* _GET_HANDLE_PROPERTY_H_ */
diff --git a/scilab/modules/graphics/src/c/getHandleProperty/get_colors_property.c b/scilab/modules/graphics/src/c/getHandleProperty/get_colors_property.c
new file mode 100644 (file)
index 0000000..645ef16
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - 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-en.txt
+ *
+ */
+
+/*------------------------------------------------------------------------*/
+/* file: get_colors_property.c                                            */
+/* desc : function to get in Scilab the polyline colors                */
+/*------------------------------------------------------------------------*/
+
+#include "SetPropertyStatus.h"
+#include "getHandleProperty.h"
+#include "GetProperty.h"
+#include "returnProperty.h"
+#include "Scierror.h"
+#include "localization.h"
+
+#include "getGraphicObjectProperty.h"
+#include "graphicObjectProperties.h"
+
+/*------------------------------------------------------------------------*/
+int get_colors_property(void* _pvCtx, char* pobjUID)
+{
+    int * colors = NULL;
+    int numColors = 0;
+    int * piNumColors = &numColors;
+    int colorSet = 0;
+    int *piColorSet = &colorSet;
+
+    getGraphicObjectProperty(pobjUID, __GO_COLOR_SET__, jni_bool, (void **)&piColorSet);
+    if (piColorSet == NULL)
+    {
+        Scierror(999, _("'%s' property does not exist for this handle.\n"), "colors");
+        return -1;
+    }
+
+    getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_COLORS__, jni_int_vector, (void **)&colors);
+    getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_NUM_COLORS__, jni_int, &piNumColors);
+
+    if (colors == NULL || numColors == 0)
+    {
+        sciReturnEmptyMatrix(_pvCtx);
+        return SET_PROPERTY_SUCCEED;
+    }
+
+    return sciReturnRowVectorFromInt(_pvCtx, colors, numColors);
+}
+/*------------------------------------------------------------------------*/
index 342ab23..f90539b 100755 (executable)
@@ -28,7 +28,6 @@
 
 #include "SetUicontrol.h"
 
-
 int set_color_map_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
 int set_old_style_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
 int set_figure_style_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
@@ -203,5 +202,6 @@ int set_marks_count_property(void* _pvCtx, int iObj, void* _pvData, int valueTyp
 int set_auto_margins_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
 int set_ticks_format_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
 int set_ticks_st_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
+int set_colors_property(void* _pvCtx, char* pobj, size_t stackPointer, int valueType, int nbRow, int nbCol);
 
 #endif /* _SET_HANDLE_PROPERTY_H_ */
diff --git a/scilab/modules/graphics/src/c/getHandleProperty/set_color_property.c b/scilab/modules/graphics/src/c/getHandleProperty/set_color_property.c
new file mode 100644 (file)
index 0000000..6910bd6
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - 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-en.txt
+ *
+ */
+
+/*------------------------------------------------------------------------*/
+/* file: set_colors_property.c                                            */
+/* desc : function to modify in Scilab the polyline colors                */
+/*------------------------------------------------------------------------*/
+
+#include "MALLOC.h"
+#include "setHandleProperty.h"
+#include "SetProperty.h"
+#include "getPropertyAssignedValue.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "GetProperty.h"
+#include "SetPropertyStatus.h"
+
+#include "getGraphicObjectProperty.h"
+#include "setGraphicObjectProperty.h"
+#include "graphicObjectProperties.h"
+
+/*------------------------------------------------------------------------*/
+int set_colors_property(void* _pvCtx, char* pobjUID, size_t stackPointer, int valueType, int nbRow, int nbCol )
+{
+    BOOL status = FALSE;
+    int iNumElements = 0;
+    int* piNumElements = &iNumElements;
+
+    if (valueType != sci_matrix)
+    {
+        Scierror(999, _("Wrong type for '%s' property: Real matrix expected.\n"), "interp_color_vector");
+        return SET_PROPERTY_ERROR;
+    }
+
+    getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_NUM_ELEMENTS__, jni_int, (void **) &piNumElements);
+
+    /*
+     * A way to display a more explicit message would be to first get the
+     * interpolation vector set flag and test it for NULL.
+     */
+    if (piNumElements == NULL)
+    {
+        Scierror(999, _("'%s' property does not exist for this handle.\n"), "data");
+        return SET_PROPERTY_ERROR;
+    }
+
+    if (nbCol == 0)
+    {
+        int colorSet = 0;
+        setGraphicObjectProperty(pobjUID, __GO_COLOR_SET__, &colorSet, jni_bool, 1);
+    }
+
+    if (nbCol == iNumElements)
+    {
+        int * tmp = MALLOC(nbCol * sizeof(int));
+        stk(stackPointer);
+
+        copyDoubleVectorToIntFromStack(stackPointer, tmp, nbCol);
+
+        status = setGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_COLORS__, tmp, jni_int_vector, nbCol);
+        if (status == TRUE)
+        {
+            int colorSet = 1;
+            setGraphicObjectProperty(pobjUID, __GO_COLOR_SET__, &colorSet, jni_bool, 1);
+            FREE(tmp);
+            return SET_PROPERTY_SUCCEED;
+        }
+        else
+        {
+            FREE(tmp);
+            Scierror(999, _("'%s' property does not exist for this handle.\n"), "interp_color_vector");
+            return SET_PROPERTY_ERROR;
+        }
+    }
+    else
+    {
+        Scierror(999, _("The number of column of the color vector must match the number of points defining the line.\n"));
+        return SET_PROPERTY_ERROR;
+    }
+}
+/*------------------------------------------------------------------------*/
diff --git a/scilab/modules/graphics/src/c/getHandleProperty/set_colors_property.c b/scilab/modules/graphics/src/c/getHandleProperty/set_colors_property.c
new file mode 100644 (file)
index 0000000..023d8db
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - 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-en.txt
+ *
+ */
+
+/*------------------------------------------------------------------------*/
+/* file: set_colors_property.c                                            */
+/* desc : function to modify in Scilab he polylines colors                */
+/*------------------------------------------------------------------------*/
+
+#include "MALLOC.h"
+#include "setHandleProperty.h"
+#include "SetProperty.h"
+#include "getPropertyAssignedValue.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "GetProperty.h"
+#include "SetPropertyStatus.h"
+
+#include "getGraphicObjectProperty.h"
+#include "setGraphicObjectProperty.h"
+#include "graphicObjectProperties.h"
+
+/*------------------------------------------------------------------------*/
+int set_colors_property(void* _pvCtx, char* pobjUID, size_t stackPointer, int valueType, int nbRow, int nbCol )
+{
+    BOOL status = FALSE;
+    int iNumElements = 0;
+    int* piNumElements = &iNumElements;
+
+    if (valueType != sci_matrix)
+    {
+        Scierror(999, _("Wrong type for '%s' property: Real matrix expected.\n"), "colors");
+        return SET_PROPERTY_ERROR;
+    }
+
+    getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_NUM_ELEMENTS__, jni_int, (void **) &piNumElements);
+
+    /*
+     * A way to display a more explicit message would be to first get the
+     * interpolation vector set flag and test it for NULL.
+     */
+    if (piNumElements == NULL)
+    {
+        Scierror(999, _("'%s' property does not exist for this handle.\n"), "data");
+        return SET_PROPERTY_ERROR;
+    }
+
+    if (nbCol == 0)
+    {
+        int colorSet = 0;
+        status = setGraphicObjectProperty(pobjUID, __GO_COLOR_SET__, &colorSet, jni_bool, 1);
+        if (status == FALSE)
+        {
+            Scierror(999, _("'%s' property does not exist for this handle.\n"), "colors");
+            return SET_PROPERTY_ERROR;
+        }
+        setGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_COLORS__, NULL, jni_int_vector, 0);
+
+        return SET_PROPERTY_SUCCEED;
+    }
+
+    if (nbCol == iNumElements)
+    {
+        int * tmp = MALLOC(nbCol * sizeof(int));
+        stk(stackPointer);
+
+        copyDoubleVectorToIntFromStack(stackPointer, tmp, nbCol);
+
+        status = setGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_COLORS__, tmp, jni_int_vector, nbCol);
+        if (status == TRUE)
+        {
+            int colorSet = 1;
+            setGraphicObjectProperty(pobjUID, __GO_COLOR_SET__, &colorSet, jni_bool, 1);
+            FREE(tmp);
+            return SET_PROPERTY_SUCCEED;
+        }
+        else
+        {
+            FREE(tmp);
+            Scierror(999, _("'%s' property does not exist for this handle.\n"), "colors");
+            return SET_PROPERTY_ERROR;
+        }
+    }
+    else
+    {
+        Scierror(999, _("The number of column of the color vector must match the number of points defining the line.\n"));
+        return SET_PROPERTY_ERROR;
+    }
+}
+/*------------------------------------------------------------------------*/
index 20a1985..5b703fe 100755 (executable)
@@ -557,7 +557,14 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                         geometry.setTextureCoordinates(dataManager.getTextureCoordinatesBuffer(polyline.getIdentifier()));
                         appearance.setTexture(getColorMapTexture());
                     } else {
-                        geometry.setColors(null);
+                        if (polyline.getColorSet()) {
+                            ElementsBuffer colors = dataManager.getColorBuffer(polyline.getIdentifier());
+                            geometry.setColors(colors);
+                            appearance.setLineColor(null);
+                        } else {
+                            geometry.setColors(null);
+                            appearance.setLineColor(ColorFactory.createColor(colorMap, polyline.getLineColor()));
+                        }
                     }
 
                     Integer lineColor = polyline.getSelected() ? polyline.getSelectedColor() : polyline.getLineColor();
@@ -589,11 +596,17 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                     }
 
                     if (polyline.getMarkMode()) {
-                        Texture sprite = markManager.getMarkSprite(polyline, colorMap, appearance);
                         ElementsBuffer positions = dataManager.getVertexBuffer(polyline.getIdentifier());
                         int offset = polyline.getMarkOffset();
                         int stride = polyline.getMarkStride();
-                        drawingTools.draw(sprite, AnchorPosition.CENTER, positions, offset, stride, 0);
+                        if (polyline.getColorSet() && polyline.getMark().getBackground() == -3) {
+                            Texture sprite = markManager.getMarkSprite(polyline, null, appearance);
+                            ElementsBuffer colors = dataManager.getColorBuffer(polyline.getIdentifier());
+                            drawingTools.draw(sprite, AnchorPosition.CENTER, positions, offset, stride, 0, colors);
+                        } else {
+                            Texture sprite = markManager.getMarkSprite(polyline, colorMap, appearance);
+                            drawingTools.draw(sprite, AnchorPosition.CENTER, positions, offset, stride, 0, null);
+                        }
                     }
                 } catch (ObjectRemovedException e) {
                     invalidate(polyline, e);
@@ -776,9 +789,15 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                         appearance.setLineWidth(plot3d.getLineThickness().floatValue());
                     }
 
-                    Texture texture = markManager.getMarkSprite(plot3d, colorMap, appearance);
                     ElementsBuffer positions = dataManager.getVertexBuffer(plot3d.getIdentifier());
-                    drawingTools.draw(texture, AnchorPosition.CENTER, positions);
+                    if (plot3d.getMark().getBackground() == -3 && plot3d.getColorFlag() == 1) {
+                        Texture sprite = markManager.getMarkSprite(plot3d, null, appearance);
+                        ElementsBuffer colors = dataManager.getColorBuffer(plot3d.getIdentifier());
+                        drawingTools.draw(sprite, AnchorPosition.CENTER, positions, colors);
+                    } else {
+                        Texture sprite = markManager.getMarkSprite(plot3d, colorMap, appearance);
+                        drawingTools.draw(sprite, AnchorPosition.CENTER, positions, null);
+                    }
                 }
             } catch (ObjectRemovedException e) {
                 invalidate(plot3d, e);
@@ -789,7 +808,6 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
             }
             axesDrawer.disableClipping(plot3d.getClipProperty());
         }
-
     }
 
     @Override
@@ -906,11 +924,19 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                  * in order to obtain the latter's Mark (all arrows are supposed to have the same contour properties for now).
                  */
                 if (segs.getMarkMode()) {
-                    Texture texture = markManager.getMarkSprite(segs.getIdentifier(), segs.getArrows().get(0).getMark(), colorMap, null);
                     ElementsBuffer positions = dataManager.getVertexBuffer(segs.getIdentifier());
                     // Take only into account start-end of segs and not the arrow head.
                     positions.getData().limit(segs.getNumberArrows() * 2 * 4);
-                    drawingTools.draw(texture, AnchorPosition.CENTER, positions);
+
+                    if (segs.getArrows().get(0).getMark().getBackground() == -3) {
+                        Texture sprite = markManager.getMarkSprite(segs.getIdentifier(), segs.getArrows().get(0).getMark(), null, null);
+                        ElementsBuffer colors = dataManager.getColorBuffer(segs.getIdentifier());
+                        drawingTools.draw(sprite, AnchorPosition.CENTER, positions, colors);
+                    } else {
+                        Texture sprite = markManager.getMarkSprite(segs.getIdentifier(), segs.getArrows().get(0).getMark(), colorMap, null);
+                        drawingTools.draw(sprite, AnchorPosition.CENTER, positions, null);
+                    }
+
                     positions.getData().limit(positions.getData().capacity());
                 }
 
index 7c9b9e2..72ec98f 100644 (file)
@@ -72,8 +72,16 @@ public class MarkSpriteFactory {
     private static TextureDrawer getSpriteDrawer(Mark mark, Integer selectedColor, int finalSize, ColorMap colorMap, Appearance usedAppearance) {
         final Appearance appearance = new Appearance();
         Integer markColor = selectedColor == null ? mark.getForeground() : selectedColor;
-        Color backgroundColor = ColorFactory.createColor(colorMap, mark.getBackground());
-        Color foregroundColor = ColorFactory.createColor(colorMap, markColor);
+        Color backgroundColor;
+        Color foregroundColor;
+
+        if (colorMap != null) {
+            backgroundColor = ColorFactory.createColor(colorMap, mark.getBackground());
+            foregroundColor = ColorFactory.createColor(colorMap, markColor);
+        } else {
+            backgroundColor = new Color(1f, 1f, 1f, 1f);
+            foregroundColor = new Color(0f, 0f, 0f, 1f);
+        }
 
         if (mark.getBackground() != 0) {
             appearance.setFillColor(backgroundColor);
@@ -94,7 +102,11 @@ public class MarkSpriteFactory {
         if (finalSize != 1) {
             switch (mark.getStyle()) {
                 case  0:
-                    return new DotSpriteDrawer(foregroundColor, finalSize);
+                    if (colorMap == null) {
+                        return new DotSpriteDrawer(backgroundColor, finalSize);
+                    } else {
+                        return new DotSpriteDrawer(foregroundColor, finalSize);
+                    }
                 case  1:
                     return new PlusSpriteDrawer(appearance, finalSize);
                 case  2:
@@ -102,7 +114,11 @@ public class MarkSpriteFactory {
                 case  3:
                     return new StarSpriteDrawer(appearance, finalSize);
                 case  4:
-                    return new FilledDiamondSpriteDrawer(foregroundColor, finalSize);
+                    if (colorMap == null) {
+                        return new FilledDiamondSpriteDrawer(backgroundColor, finalSize);
+                    } else {
+                        return new FilledDiamondSpriteDrawer(foregroundColor, finalSize);
+                    }
                 case  5:
                     return new DiamondSpriteDrawer(appearance, finalSize);
                 case  6:
index 21455c1..fc57036 100644 (file)
@@ -48,7 +48,6 @@ public class MarkSpriteManager {
         this.textureManager = textureManager;
     }
 
-
     /**
      * Return the mark sprite for the given contoured object.
      *
@@ -101,7 +100,8 @@ public class MarkSpriteManager {
                 || property == GraphicObjectProperties.__GO_MARK_FOREGROUND__
                 || property == GraphicObjectProperties.__GO_MARK_BACKGROUND__
                 || property == GraphicObjectProperties.__GO_LINE_THICKNESS__
-                || property == GraphicObjectProperties.__GO_SELECTED__) {
+                || property == GraphicObjectProperties.__GO_SELECTED__
+                || property == GraphicObjectProperties.__GO_COLOR_SET__) {
             dispose(id);
         }
     }
diff --git a/scilab/modules/renderer/tests/unit_tests/mark_color.tst b/scilab/modules/renderer/tests/unit_tests/mark_color.tst
new file mode 100644 (file)
index 0000000..9fafac9
--- /dev/null
@@ -0,0 +1,51 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Pierre-Aime Agnel
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Unit-test for color in marks -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/
+//
+// <-- Short Description -->
+// Tests that the marks can be coloured in 2D plots with offset and stride set
+// 
+// <-- INTERACTIVE TEST -->
+
+x = (1:100);
+rand("normal");
+y_1 = 5 * (x + 15*rand(1,100)) + 10;
+y_2 = 15 * (x + 10 *rand(1,100)) - 18;
+
+clf();
+drawlater();
+plot(x, y_1, ".c");
+plot(x, y_2, ".c");
+
+fig = gcf();
+fig.color_map = rainbowcolormap(32);
+ax = gca();
+pl_2 = ax.children(1).children(1);
+pl_2.mark_mode = "on";
+pl_2.mark_offset = 3;
+pl_2.mark_background = -3;
+pl_2.mark_stride = 5;
+pl_2.mark_size_unit = "point";
+pl_2.mark_size = 10;
+pl_2.colors = grand(1, 100, "uin", 1, 32);
+
+
+pl_1 = ax.children(2).children(1);
+pl_1.mark_mode = "on";
+pl_1.mark_offset = 3;
+pl_1.mark_background = -3;
+pl_1.mark_stride = 5;
+pl_1.mark_size_unit = "point";
+pl_1.mark_size = 20;
+pl_1.colors = grand(1, 100, "uin", 1, 32);
+drawnow();
+rand("uniform");
diff --git a/scilab/modules/renderer/tests/unit_tests/mark_color3d.tst b/scilab/modules/renderer/tests/unit_tests/mark_color3d.tst
new file mode 100644 (file)
index 0000000..956b2b9
--- /dev/null
@@ -0,0 +1,46 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Calixte Denizet
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Unit test for coloured marks -->
+//
+// <-- Short Description -->
+// Tests the coloured mark on a 3d plot
+//
+// <-- INTERACTIVE TEST -->
+
+
+function newH = fall(h, v, t)
+    i = find(h ~= 0);
+    newH(i) = h(i)+v(i)*t-0.5*9.81*t^2
+    j = find(newH < 0);
+    newH(j) = 0;
+endfunction
+
+drawlater();
+clf();
+plot3d();
+a=gca();
+p=a.children(1);
+p.mark_background=-3;
+p.mark_size=1;
+p.mark_mode="on";
+p.surface_mode="off";
+p.data.z = p.data.z + 10; 
+a.data_bounds=[-%pi -%pi 9; %pi %pi 11];
+drawnow();
+
+t=0;
+step = 0.01;
+hinit = p.data.z;
+h = hinit;
+v=4*(rand(hinit) - 0.5);
+while or(h)
+    t = t + step;
+    h = fall(hinit, v, t);
+    p.data.z = h;
+    sleep(20);
+end
index 0223ea7..4652efb 100644 (file)
@@ -115,9 +115,55 @@ public interface DrawingTools {
      * @param rotationAngle the rotation angle.
      * @throws SciRendererException if the texture is not drawable.
      */
+    void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, double rotationAngle) throws SciRendererException;
+
+    /**
+     * Draw the given texture at all given position with selected colors.
+     * @param texture the texture to draw.
+     * @param anchor the texture anchor position.
+     * @param positions the positions where the texture will be drawn.
+     * @param colors the colors of the texture.
+     * @throws SciRendererException if the texture is not drawable.
+     */
+    void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, ElementsBuffer colors) throws SciRendererException;
+
+    /**
+     * Draw the given texture at all given position with the given rotation angle with selected colors.
+     * @param texture the texture to draw.
+     * @param anchor the texture anchor position.
+     * @param positions the positions where the texture will be drawn.
+     * @param rotationAngle the rotation angle.
+     * @param colors the colors of the texture.
+     * @throws SciRendererException if the texture is not drawable.
+     */
+    void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, double rotationAngle, ElementsBuffer colors) throws SciRendererException;
+
+    /**
+     * Draw the given texture at all given position with given offset and stride with the given rotation angle.
+     * @param texture the texture to draw.
+     * @param anchor the texture anchor position.
+     * @param positions the positions where the texture will be drawn.
+     * @param offset the position of the first mark.
+     * @param stride the spacing between two marks.
+     * @param rotationAngle the rotation angle.
+     * @throws SciRendererException if the texture is not drawable.
+     */
     void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle) throws SciRendererException;
 
     /**
+     * Draw the given texture at all given position with given offset and stride with the given rotation angle with the given color.
+     * @param texture the texture to draw.
+     * @param anchor the texture anchor position.
+     * @param positions the positions where the texture will be drawn.
+     * @param offset the position of the first mark.
+     * @param stride the spacing between two marks.
+     * @param rotationAngle the rotation angle.
+     * @param colors the colors of the texture.
+     * @throws SciRendererException if the texture is not drawable.
+     */
+    void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle, ElementsBuffer colors) throws SciRendererException;
+
+    /**
      * Draw the given texture at given position.
      * @param texture the texture to draw.
      * @param anchor the texture anchor position.
index c859415..1cc0d14 100644 (file)
@@ -127,12 +127,32 @@ public class G2DDrawingTools implements DrawingTools {
 
     @Override
     public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions) {
-        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, 0, 1, 0);
+        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, 0, 1, 0, null);
+    }
+
+    @Override
+    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, double rotationAngle) {
+        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, 0, 1, rotationAngle, null);
+    }
+
+    @Override
+    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, ElementsBuffer colors) {
+        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, 0, 1, 0, colors);
+    }
+
+    @Override
+    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, double rotationAngle, ElementsBuffer colors) {
+        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, 0, 1, rotationAngle, colors);
     }
 
     @Override
     public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle) {
-        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, offset, stride, rotationAngle);
+        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, offset, stride, rotationAngle, null);
+    }
+
+    @Override
+    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle, ElementsBuffer colors) {
+        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, offset, stride, rotationAngle, colors);
     }
 
     @Override
index 9b6be63..0a0686c 100644 (file)
@@ -15,6 +15,7 @@ import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Graphics2D;
 import java.awt.RenderingHints;
+import java.awt.Stroke;
 import java.awt.image.BufferedImage;
 import java.nio.FloatBuffer;
 import java.nio.IntBuffer;
@@ -208,11 +209,12 @@ public class Motor3D {
         }
     }
 
-    public void draw(DrawingTools drawingTools, Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle) {
+    public void draw(DrawingTools drawingTools, Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle, ElementsBuffer colors) {
         FloatBuffer positionsBuffer = positions.getData();
         float[] buffer;
         offset = offset < 0 ? 0 : offset;
         stride = stride < 1 ? 1 : stride;
+        Color[] colorsArray = null;
 
         positionsBuffer.rewind();
         if (positionsBuffer.hasArray()) {
@@ -221,11 +223,29 @@ public class Motor3D {
             buffer = new float[positionsBuffer.limit()];
             positionsBuffer.get(buffer);
         }
-
         Vector3d[] verticesArray = getMultiVectors(buffer, transf, false);
+
+        if (colors != null) {
+            FloatBuffer colorsBuffer = colors.getData();
+            colorsBuffer.rewind();
+            if (colorsBuffer.hasArray()) {
+                buffer = colorsBuffer.array();
+            } else {
+                buffer = new float[colorsBuffer.limit()];
+                colorsBuffer.get(buffer);
+            }
+            colorsArray = getMultiColors(buffer);
+        }
+
         for (int i = offset; i < verticesArray.length; i += stride) {
             try {
-                SpritedRectangle o = new SpritedRectangle(verticesArray[i], texture, anchor, textureDrawingTools, rotationAngle);
+                Vector3d v = verticesArray[i];
+                SpritedRectangle o;
+                if (colorsArray == null) {
+                    o = new SpritedRectangle(v, texture, anchor, textureDrawingTools, rotationAngle, null);
+                } else {
+                    o = new SpritedRectangle(v, texture, anchor, textureDrawingTools, rotationAngle, colorsArray[i]);
+                }
                 add(o);
             } catch (InvalidPolygonException e) { }
         }
@@ -233,7 +253,7 @@ public class Motor3D {
 
     public void draw(DrawingTools drawingTools, Texture texture, AnchorPosition anchor, Vector3d position, double rotationAngle) {
         try {
-            add(new SpritedRectangle(transf.project(position), texture, anchor, textureDrawingTools, rotationAngle));
+            add(new SpritedRectangle(transf.project(position), texture, anchor, textureDrawingTools, rotationAngle, null));
         } catch (InvalidPolygonException e) { }
     }
 
index 472403a..a4371f8 100644 (file)
@@ -42,13 +42,15 @@ public class SpritedRectangle extends ConvexObject {
     private double rotationAngle;
     private Texture.Filter filter;
     private Vector3d position;
+    private Color fillColor;
 
-    public SpritedRectangle(Vector3d vertex, Texture sprite, AnchorPosition anchor, G2DTextureDrawingTools drawingTools, double rotationAngle) throws InvalidPolygonException {
+    public SpritedRectangle(Vector3d vertex, Texture sprite, AnchorPosition anchor, G2DTextureDrawingTools drawingTools, double rotationAngle, Color fillColor) throws InvalidPolygonException {
         super(getSpriteVertices(vertex, sprite, anchor, rotationAngle), null);
         this.sprite = sprite;
         this.drawingTools = drawingTools;
         this.rotationAngle = rotationAngle;
         this.position = vertex;
+        this.fillColor = fillColor;
     }
 
     public SpritedRectangle(Vector3d vertex, Transformation transf, BufferedImage image, Texture.Filter filter) throws InvalidPolygonException {
@@ -295,7 +297,7 @@ public class SpritedRectangle extends ConvexObject {
                 g2d.translate(vertices[0].getX(), vertices[0].getY());
             }
 
-            drawingTools.accept(sprite);
+            drawingTools.accept(sprite, fillColor);
             g2d.setTransform(oldTransf);
             g2d.setStroke(oldStroke);
         } else {
index 3ae9a6a..2c8480e 100644 (file)
@@ -41,6 +41,7 @@ public class G2DTextureDrawingTools implements TextureDrawingTools {
     private Graphics2D g2d;
     private int width;
     private int height;
+    private java.awt.Color fillColor;
 
     /**
      * Default constructor.
@@ -57,12 +58,16 @@ public class G2DTextureDrawingTools implements TextureDrawingTools {
     }
 
     public void accept(Texture texture) {
+        accept(texture, null);
+    }
+
+    public void accept(Texture texture, java.awt.Color fillColor) {
         G2DTextureManager.G2DTexture t = (G2DTextureManager.G2DTexture) texture;
         TextureDrawer drawer = t.getDrawer();
         Dimension d = drawer.getTextureSize();
         this.width = (int) d.getWidth();
         this.height = (int) d.getHeight();
-        accept(drawer, this.width, this.height);
+        accept(drawer, this.width, this.height, fillColor);
     }
 
     /**
@@ -70,7 +75,7 @@ public class G2DTextureDrawingTools implements TextureDrawingTools {
      * This image will contain the drawing of the given drawer.
      * @param spriteDrawer the given sprite drawer.
      */
-    public void accept(TextureDrawer textureDrawer, int width, int height) {
+    public void accept(TextureDrawer textureDrawer, int width, int height, java.awt.Color fillColor) {
         // Change center coordinate to (0, 0).
         if (textureDrawer.getOriginPosition() == TextureDrawer.OriginPosition.CENTER) {
             g2d.translate(width / 2.0, height / 2.0);
@@ -80,7 +85,9 @@ public class G2DTextureDrawingTools implements TextureDrawingTools {
         if (!aa) {
             g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
         }
+        this.fillColor = fillColor;
         textureDrawer.draw(this);
+        this.fillColor = null;
 
         if (!aa) {
             g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
@@ -119,7 +126,7 @@ public class G2DTextureDrawingTools implements TextureDrawingTools {
             k++;
         }
 
-        g2d.setColor(appearance.getLineColor());
+        g2d.setColor(getColor(appearance.getLineColor()));
         g2d.setStroke(G2DStroke.getStroke(appearance, 0));
 
         g2d.drawPolyline(xCoordinates, yCoordinates, nbPoint);
@@ -140,7 +147,7 @@ public class G2DTextureDrawingTools implements TextureDrawingTools {
         }
 
         if (appearance.getFillColor().getAlphaAsFloat() != 0) {
-            g2d.setColor(appearance.getFillColor());
+            g2d.setColor(getColor(appearance.getFillColor()));
             g2d.fillPolygon(xCoordinates, yCoordinates, nbPoint);
         }
 
@@ -157,7 +164,7 @@ public class G2DTextureDrawingTools implements TextureDrawingTools {
 
     @Override
     public void drawCircle(int x, int y, int diameter, Appearance appearance) {
-        g2d.setColor(appearance.getLineColor());
+        g2d.setColor(getColor(appearance.getLineColor()));
         g2d.setStroke(G2DStroke.getStroke(appearance, 0));
         double r = ((double) diameter) / 2;
         g2d.draw(new Ellipse2D.Double(x - r, y - r, diameter, diameter));
@@ -166,7 +173,7 @@ public class G2DTextureDrawingTools implements TextureDrawingTools {
     @Override
     public void fillDisc(int x, int y, int diameter, Color color) {
         if (color.getAlphaAsFloat() != 0) {
-            g2d.setColor(color);
+            g2d.setColor(getColor(color));
             double r = ((double) diameter) / 2;
             g2d.fill(new Ellipse2D.Double(x - r, y - r, diameter, diameter));
         }
@@ -186,7 +193,7 @@ public class G2DTextureDrawingTools implements TextureDrawingTools {
             } else {
                 g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
             }
-            g2d.setColor(textEntity.getTextColor());
+            g2d.setColor(getColor(textEntity.getTextColor()));
             TextLayout textLayout = new TextLayout(textEntity.getText(), textEntity.getFont(), g2d.getFontRenderContext());
             Rectangle2D bounds = textLayout.getBounds();
             g2d.setFont(textEntity.getFont());
@@ -201,7 +208,19 @@ public class G2DTextureDrawingTools implements TextureDrawingTools {
 
     @Override
     public void clear(Color color) {
-        g2d.setColor(color);
+        g2d.setColor(getColor(color));
         g2d.fillRect(0, 0, width, height);
     }
+
+    public java.awt.Color getColor(Color color) {
+        if (fillColor == null) {
+            return color;
+        } else {
+            if (color.equals(Color.WHITE)) {
+                return fillColor;
+            } else {
+                return color;
+            }
+        }
+    }
 }
index d7b34d3..3a922ee 100644 (file)
@@ -159,12 +159,32 @@ public class JoGLDrawingTools implements DrawingTools {
 
     @Override
     public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions) throws SciRendererException {
-        canvas.getTextureManager().draw(this, texture, anchor, positions, 0, 1, 0);
+        canvas.getTextureManager().draw(this, texture, anchor, positions, 0, 1, 0, null);
+    }
+
+    @Override
+    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, double rotationAngle) throws SciRendererException {
+        canvas.getTextureManager().draw(this, texture, anchor, positions, 0, 1, rotationAngle, null);
+    }
+
+    @Override
+    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, ElementsBuffer colors) throws SciRendererException {
+        canvas.getTextureManager().draw(this, texture, anchor, positions, 0, 1, 0, colors);
+    }
+
+    @Override
+    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, double rotationAngle, ElementsBuffer colors) throws SciRendererException {
+        canvas.getTextureManager().draw(this, texture, anchor, positions, 0, 1, rotationAngle, colors);
     }
 
     @Override
     public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle) throws SciRendererException {
-        canvas.getTextureManager().draw(this, texture, anchor, positions, offset, stride, rotationAngle);
+        canvas.getTextureManager().draw(this, texture, anchor, positions, offset, stride, rotationAngle, null);
+    }
+
+    @Override
+    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle, ElementsBuffer colors) throws SciRendererException {
+        canvas.getTextureManager().draw(this, texture, anchor, positions, offset, stride, rotationAngle, colors);
     }
 
     @Override
index 87f3099..8c11226 100644 (file)
@@ -164,6 +164,9 @@ public final class JoGLShapeDrawer {
         gl.glDisable(GL2.GL_NORMALIZE);
 
         if (geometry.getLineDrawingMode() != Geometry.LineDrawingMode.NONE) {
+            // to avoid color smoothing between edge
+            // TODO: add an option in Appearance
+            gl.glShadeModel(GL2.GL_FLAT);
             if (appearance.getLineColor() != null || geometry.getColors() != null) {
                 GLShortCuts.useLineAppearance(gl, appearance);
                 if (appearance.getLineColor() == null) {
@@ -257,6 +260,7 @@ public final class JoGLShapeDrawer {
 
         if (geometry.getFillDrawingMode() != Geometry.FillDrawingMode.NONE) {
             GLShortCuts.useColor(gl, appearance.getFillColor());
+            gl.glShadeModel(GL2.GL_FLAT);
             gl.glBegin(getGlMode(geometry.getFillDrawingMode()));
             if (indices != null) {
                 IntBuffer indicesBuffer = indices.getData();
index 71876e1..1470650 100644 (file)
@@ -69,7 +69,7 @@ public class JoGLTextureManager implements TextureManager {
     /**
      * Draw the given texture.
      * @param drawingTools used drawing tools.
-     * @param texture the texture too drawn.
+     * @param texture the texture to draw.
      * @throws org.scilab.forge.scirenderer.SciRendererException if the texture is invalid.
      */
     public void draw(JoGLDrawingTools drawingTools, Texture texture) throws SciRendererException {
@@ -82,35 +82,75 @@ public class JoGLTextureManager implements TextureManager {
         }
     }
 
-    public void draw(JoGLDrawingTools drawingTools, Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle) throws SciRendererException {
+    public void draw(JoGLDrawingTools drawingTools, Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle, ElementsBuffer colors) throws SciRendererException {
         if ((texture instanceof JoGLTexture) && (allTextures.contains((JoGLTexture) texture))) {
             if (positions != null) {
                 FloatBuffer data = positions.getData();
+                FloatBuffer dataColors = null;
+
                 if (data != null) {
+                    data.rewind();
+                    // Initializing dataColors Buffer
+                    if (colors != null) {
+                        dataColors = colors.getData();
+                        if (dataColors != null){
+                            dataColors.rewind();
+                            // There should be as many colors as there are positions
+                            if (dataColors.limit() != data.limit()) {
+                                throw new SciRendererException("Vertices do not have the same number of positions and colors");
+                            }
+                        }
+                    }
                     float[] position = {0, 0, 0, 1};
+                    float[] color = {0, 0, 0, 0};
+                    int mark = 0;
+
                     final JoGLTexture jt = (JoGLTexture) texture;
                     if (jt.preDraw(drawingTools)) {
                         stride = stride < 1 ? 1 : stride;
                         offset = offset < 0 ? 0 : offset;
                         if (stride == 1) {
-                            data.position(4 * offset);
+                            // skip offset positions in the data Buffer
+                            // a position is 4 elements
+                            mark = 4 * offset;
+                            data.position(mark);
+                            if (dataColors != null) {
+                                dataColors.position(mark);
+                            }
                             while (data.remaining() >= 4) {
                                 data.get(position);
-                                jt.draw(drawingTools, anchor, new Vector3d(position), rotationAngle);
+                                if (dataColors == null){
+                                    jt.draw(drawingTools, anchor, new Vector3d(position), rotationAngle, null);
+                                }
+                                else {
+                                    dataColors.get(color);
+                                    jt.draw(drawingTools, anchor, new Vector3d(position), rotationAngle, color);
+                                }
                             }
                         } else {
-                            int mark = 4 * offset;
+                            mark = 4 * offset;
                             if (mark < data.capacity()) {
                                 data.position(mark);
                                 while (data.remaining() >= 4) {
                                     data.get(position);
+                                    if (dataColors == null){
+                                        jt.draw(drawingTools, anchor, new Vector3d(position), rotationAngle, null);
+                                    }
+                                    else {
+                                        dataColors.position(mark);
+                                        dataColors.get(color);
+                                        jt.draw(drawingTools, anchor, new Vector3d(position), rotationAngle, color);
+                                    }
+                                    // reposition the mark on data and dataColors
                                     mark += stride * 4;
                                     if (mark < data.capacity()) {
                                         data.position(mark);
+                                        if (dataColors != null) {
+                                            dataColors.position(mark);
+                                        }
                                     } else {
                                         break;
                                     }
-                                    jt.draw(drawingTools, anchor, new Vector3d(position), rotationAngle);
                                 }
                             }
                         }
@@ -125,7 +165,7 @@ public class JoGLTextureManager implements TextureManager {
         if ((texture instanceof JoGLTexture) && (allTextures.contains((JoGLTexture) texture))) {
             final JoGLTexture jt = (JoGLTexture) texture;
             jt.preDraw(drawingTools);
-            jt.draw(drawingTools, anchor, position, rotationAngle);
+            jt.draw(drawingTools, anchor, position, rotationAngle, null);
             jt.postDraw(drawingTools);
         }
     }
@@ -361,7 +401,8 @@ public class JoGLTextureManager implements TextureManager {
 
             gl.glPushAttrib(GL2.GL_ALL_ATTRIB_BITS);
 
-            gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
+            gl.glColor4f(1f, 1f, 1f, 1f);
+            gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE);
 
             for (int k = 0; k < wCuts * hCuts; k++) {
                 textures[k].enable(gl);
@@ -379,7 +420,7 @@ public class JoGLTextureManager implements TextureManager {
             return true;
         }
 
-        public void draw(JoGLDrawingTools drawingTools, AnchorPosition anchor, Vector3d position, double rotationAngle) throws SciRendererException {
+        public void draw(JoGLDrawingTools drawingTools, AnchorPosition anchor, Vector3d position, double rotationAngle, float[] color) throws SciRendererException {
             TransformationManager transformationManager = drawingTools.getTransformationManager();
             Transformation canvasProjection = transformationManager.getCanvasProjection();
             boolean sceneCoordinate = drawingTools.getTransformationManager().isUsingSceneCoordinate();
@@ -406,7 +447,7 @@ public class JoGLTextureManager implements TextureManager {
                 gl.glTranslated(Math.round(getAnchorDeltaX(anchor)), Math.round(getAnchorDeltaY(anchor)), 0);
             }
 
-            draw(drawingTools);
+            draw(drawingTools, color);
 
             gl.glMatrixMode(GL2.GL_MODELVIEW);
             gl.glPopMatrix();
@@ -431,12 +472,16 @@ public class JoGLTextureManager implements TextureManager {
             gl.glPopMatrix();
         }
 
+        public void draw(JoGLDrawingTools drawingTools) throws SciRendererException {
+            draw(drawingTools, null);
+        }
+
         /**
          * Draw the texture in XY plane.
          * @param drawingTools the drawing tools.
          * @throws SciRendererException if the texture is invalid.
          */
-        public void draw(JoGLDrawingTools drawingTools) throws SciRendererException {
+        public void draw(JoGLDrawingTools drawingTools, float[] color) throws SciRendererException {
             final int maxSize = drawingTools.getGLCapacity().getMaximumTextureSize();
             final Dimension textureSize = getDataProvider().getTextureSize();
             final GL2 gl = drawingTools.getGl().getGL2();
@@ -451,6 +496,10 @@ public class JoGLTextureManager implements TextureManager {
                     }
                     textures[0].bind(gl);
 
+                    if (color != null) {
+                        gl.glColor4fv(color, 0);
+                    }
+
                     gl.glBegin(GL2.GL_QUADS);
                     gl.glTexCoord2f(coords.left(), coords.bottom());
                     if (isRowMajorOrder()) {
@@ -487,6 +536,10 @@ public class JoGLTextureManager implements TextureManager {
                             }
                             textures[k].bind(gl);
 
+                            if (color != null) {
+                                gl.glColor4fv(color, 0);
+                            }
+
                             gl.glBegin(GL2.GL_QUADS);
                             gl.glTexCoord2f(coords.left(), coords.top());
                             gl.glVertex2f(x, textureSize.height - y);