* Bug #13794 fixed - Datatips display mode 07/18407/5
Caio SOUZA [Wed, 3 Aug 2016 18:30:05 +0000 (15:30 -0300)]
Added polyline property "datatip_display_mode", allowing datatips to be displayed "always", "mouseclick" or "mouseover".

Change-Id: I724e990d99048fea346cfcb875476d3137d1ebe7

16 files changed:
scilab/CHANGES.md
scilab/modules/graphic_objects/includes/graphicObjectProperties.h
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/graphicObject/GraphicObjectProperties.java [changed mode: 0755->0644]
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/help/en_US/polygon/polyline_properties.xml
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_datatip_property.c
scilab/modules/graphics/src/c/getHandleProperty/setHandleProperty.h
scilab/modules/graphics/src/c/getHandleProperty/set_datatip_property.c
scilab/modules/hdf5/src/cpp/handle_properties.hxx
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/DrawerVisitor.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/datatip/DatatipDisplayModeManager.java [new file with mode: 0644]

index 008691b..dd2d2ef 100644 (file)
@@ -339,6 +339,7 @@ Bug Fixes
 * [#12017](http://bugzilla.scilab.org/show_bug.cgi?id=12017): `figure.pixel_drawing_mode` is ignored for filled regular polygons and other shapes, still does not work for vectorial export (eps, pdf, etc).
 * [#12110](http://bugzilla.scilab.org/show_bug.cgi?id=12110): Unable to zoom multiple axes at once
 * [#12431](http://bugzilla.scilab.org/show_bug.cgi?id=12431): The page describing the `%helps` variable needed clarification.
+* [#13794](http://bugzilla.scilab.org/show_bug.cgi?id=13794): Added polyline property "datatip_display_mode", allowing datatips to be displayed "always", "mouseclick" or "mouseover".
 * [#13166](http://bugzilla.scilab.org/show_bug.cgi?id=13166): `l` and `b` endian flags used with `mget` and `mgeti` were sticky
 * [#13375](http://bugzilla.scilab.org/show_bug.cgi?id=13375): If (Max - Min) == 1, then the multiple selection is not allowed.
 * [#13583](http://bugzilla.scilab.org/show_bug.cgi?id=13583): `getd` loading a script including a `clear` instruction yielded an error
index 18ffa88..5aea4b6 100755 (executable)
 #define __GO_DATATIPS__ 350
 #define __GO_DATATIPS_COUNT__ 351
 #define __GO_DATATIP_INDEXES__ 352
-#define __GO_DATA_MODEL_DISPLAY_FUNCTION__ 353
-#define __GO_DATA_MODEL_DISPLAY_FUNCTION_SIZE__ 354
-#define __GO_RESIZE__ 355
-#define __GO_TOOLBAR__ 356
-#define __GO_TOOLBAR_VISIBLE__ 357
-#define __GO_MENUBAR__ 358
-#define __GO_MENUBAR_VISIBLE__ 359
-#define __GO_INFOBAR_VISIBLE__ 360
-#define __GO_DOCKABLE__ 361
-#define __GO_LAYOUT__ 362
-#define __GO_LAYOUT_SET__ 363
-#define __GO_UI_TAB__ 364
-#define __GO_UI_GRIDBAG_GRID__ 365
-#define __GO_UI_GRIDBAG_WEIGHT__ 366
-#define __GO_UI_GRIDBAG_FILL__ 367
-#define __GO_UI_GRIDBAG_ANCHOR__ 368
-#define __GO_UI_GRIDBAG_PADDING__ 369
-#define __GO_UI_GRIDBAG_PREFERREDSIZE__ 370
-#define __GO_UI_GRID_GRID__ 371
-#define __GO_UI_GRID_PADDING__ 372
-#define __GO_UI_BORDER_POSITION__ 373
-#define __GO_UI_BORDER_PREFERREDSIZE__ 374
-#define __GO_GRID_OPT_GRID__ 375
-#define __GO_GRID_OPT_PADDING__ 376
-#define __GO_BORDER_OPT_PADDING__ 377
-#define __GO_UI_FRAME_BORDER__ 378
-#define __GO_UI_FRAME_BORDER_COLOR__ 379
-#define __GO_UI_FRAME_BORDER_HIGHLIGHT_IN__ 380
-#define __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__ 381
-#define __GO_UI_FRAME_BORDER_IN_BORDER__ 382
-#define __GO_UI_FRAME_BORDER_JUSTIFICATION__ 383
-#define __GO_UI_FRAME_BORDER_OUT_BORDER__ 384
-#define __GO_UI_FRAME_BORDER_ROUNDED__ 385
-#define __GO_UI_FRAME_BORDER_SHADOW_IN__ 386
-#define __GO_UI_FRAME_BORDER_SHADOW_OUT__ 387
-#define __GO_UI_FRAME_BORDER_TITLE__ 388
-#define __GO_UI_FRAME_BORDER_POSITION__ 389
-#define __GO_UI_FRAME_BORDER_STYLE__ 390
-#define __GO_UI_GROUP_NAME__ 391
-#define __GO_UI_TITLE_POSITION__ 392
-#define __GO_UI_TITLE_SCROLL__ 393
-#define __GO_UI_FRAME_BORDER_TYPE__ 394
-#define __GO_UI_SCROLLABLE__ 395
-#define __GO_COLOR_SET__ 396
-#define __GO_MARK_SIZES__ 397
-#define __GO_NUM_MARK_SIZES__ 398
-#define __GO_MARK_FOREGROUNDS__ 399
-#define __GO_NUM_MARK_FOREGROUNDS__ 400
-#define __GO_MARK_BACKGROUNDS__ 401
-#define __GO_NUM_MARK_BACKGROUNDS__ 402
+#define __GO_DATATIP_DISPLAY_MODE__ 353
+#define __GO_DATA_MODEL_DISPLAY_FUNCTION__ 354
+#define __GO_DATA_MODEL_DISPLAY_FUNCTION_SIZE__ 355
+#define __GO_RESIZE__ 356
+#define __GO_TOOLBAR__ 357
+#define __GO_TOOLBAR_VISIBLE__ 358
+#define __GO_MENUBAR__ 359
+#define __GO_MENUBAR_VISIBLE__ 360
+#define __GO_INFOBAR_VISIBLE__ 361
+#define __GO_DOCKABLE__ 362
+#define __GO_LAYOUT__ 363
+#define __GO_LAYOUT_SET__ 364
+#define __GO_UI_TAB__ 365
+#define __GO_UI_GRIDBAG_GRID__ 366
+#define __GO_UI_GRIDBAG_WEIGHT__ 367
+#define __GO_UI_GRIDBAG_FILL__ 368
+#define __GO_UI_GRIDBAG_ANCHOR__ 369
+#define __GO_UI_GRIDBAG_PADDING__ 370
+#define __GO_UI_GRIDBAG_PREFERREDSIZE__ 371
+#define __GO_UI_GRID_GRID__ 372
+#define __GO_UI_GRID_PADDING__ 373
+#define __GO_UI_BORDER_POSITION__ 374
+#define __GO_UI_BORDER_PREFERREDSIZE__ 375
+#define __GO_GRID_OPT_GRID__ 376
+#define __GO_GRID_OPT_PADDING__ 377
+#define __GO_BORDER_OPT_PADDING__ 378
+#define __GO_UI_FRAME_BORDER__ 379
+#define __GO_UI_FRAME_BORDER_COLOR__ 380
+#define __GO_UI_FRAME_BORDER_HIGHLIGHT_IN__ 381
+#define __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__ 382
+#define __GO_UI_FRAME_BORDER_IN_BORDER__ 383
+#define __GO_UI_FRAME_BORDER_JUSTIFICATION__ 384
+#define __GO_UI_FRAME_BORDER_OUT_BORDER__ 385
+#define __GO_UI_FRAME_BORDER_ROUNDED__ 386
+#define __GO_UI_FRAME_BORDER_SHADOW_IN__ 387
+#define __GO_UI_FRAME_BORDER_SHADOW_OUT__ 388
+#define __GO_UI_FRAME_BORDER_TITLE__ 389
+#define __GO_UI_FRAME_BORDER_POSITION__ 390
+#define __GO_UI_FRAME_BORDER_STYLE__ 391
+#define __GO_UI_GROUP_NAME__ 392
+#define __GO_UI_TITLE_POSITION__ 393
+#define __GO_UI_TITLE_SCROLL__ 394
+#define __GO_UI_FRAME_BORDER_TYPE__ 395
+#define __GO_UI_SCROLLABLE__ 396
+#define __GO_COLOR_SET__ 397
+#define __GO_MARK_SIZES__ 398
+#define __GO_NUM_MARK_SIZES__ 399
+#define __GO_MARK_FOREGROUNDS__ 400
+#define __GO_NUM_MARK_FOREGROUNDS__ 401
+#define __GO_MARK_BACKGROUNDS__ 402
+#define __GO_NUM_MARK_BACKGROUNDS__ 403
 
 #endif /* !__GRAPHIC_OBJECT_PROPERTIES_H__ */
old mode 100755 (executable)
new mode 100644 (file)
index 189d56c..e02d689
@@ -373,55 +373,56 @@ public class GraphicObjectProperties {
     public static final int __GO_DATATIPS__ = 350;
     public static final int __GO_DATATIPS_COUNT__ = 351;
     public static final int __GO_DATATIP_INDEXES__ = 352;
-    public static final int __GO_DATA_MODEL_DISPLAY_FUNCTION__ = 353;
-    public static final int __GO_DATA_MODEL_DISPLAY_FUNCTION_SIZE__ = 354;
-    public static final int __GO_RESIZE__ = 355;
-    public static final int __GO_TOOLBAR__ = 356;
-    public static final int __GO_TOOLBAR_VISIBLE__ = 357;
-    public static final int __GO_MENUBAR__ = 358;
-    public static final int __GO_MENUBAR_VISIBLE__ = 359;
-    public static final int __GO_INFOBAR_VISIBLE__ = 360;
-    public static final int __GO_DOCKABLE__ = 361;
-    public static final int __GO_LAYOUT__ = 362;
-    public static final int __GO_LAYOUT_SET__ = 363;
-    public static final int __GO_UI_TAB__ = 364;
-    public static final int __GO_UI_GRIDBAG_GRID__ = 365;
-    public static final int __GO_UI_GRIDBAG_WEIGHT__ = 366;
-    public static final int __GO_UI_GRIDBAG_FILL__ = 367;
-    public static final int __GO_UI_GRIDBAG_ANCHOR__ = 368;
-    public static final int __GO_UI_GRIDBAG_PADDING__ = 369;
-    public static final int __GO_UI_GRIDBAG_PREFERREDSIZE__ = 370;
-    public static final int __GO_UI_GRID_GRID__ = 371;
-    public static final int __GO_UI_GRID_PADDING__ = 372;
-    public static final int __GO_UI_BORDER_POSITION__ = 373;
-    public static final int __GO_UI_BORDER_PREFERREDSIZE__ = 374;
-    public static final int __GO_GRID_OPT_GRID__ = 375;
-    public static final int __GO_GRID_OPT_PADDING__ = 376;
-    public static final int __GO_BORDER_OPT_PADDING__ = 377;
-    public static final int __GO_UI_FRAME_BORDER__ = 378;
-    public static final int __GO_UI_FRAME_BORDER_COLOR__ = 379;
-    public static final int __GO_UI_FRAME_BORDER_HIGHLIGHT_IN__ = 380;
-    public static final int __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__ = 381;
-    public static final int __GO_UI_FRAME_BORDER_IN_BORDER__ = 382;
-    public static final int __GO_UI_FRAME_BORDER_JUSTIFICATION__ = 383;
-    public static final int __GO_UI_FRAME_BORDER_OUT_BORDER__ = 384;
-    public static final int __GO_UI_FRAME_BORDER_ROUNDED__ = 385;
-    public static final int __GO_UI_FRAME_BORDER_SHADOW_IN__ = 386;
-    public static final int __GO_UI_FRAME_BORDER_SHADOW_OUT__ = 387;
-    public static final int __GO_UI_FRAME_BORDER_TITLE__ = 388;
-    public static final int __GO_UI_FRAME_BORDER_POSITION__ = 389;
-    public static final int __GO_UI_FRAME_BORDER_STYLE__ = 390;
-    public static final int __GO_UI_GROUP_NAME__ = 391;
-    public static final int __GO_UI_TITLE_POSITION__ = 392;
-    public static final int __GO_UI_TITLE_SCROLL__ = 393;
-    public static final int __GO_UI_FRAME_BORDER_TYPE__ = 394;
-    public static final int __GO_UI_SCROLLABLE__ = 395;
-    public static final int __GO_COLOR_SET__ = 396;
-    public static final int __GO_MARK_SIZES__ = 397;
-    public static final int __GO_NUM_MARK_SIZES__ = 398;
-    public static final int __GO_MARK_FOREGROUNDS__ = 399;
-    public static final int __GO_NUM_MARK_FOREGROUNDS__ = 400;
-    public static final int __GO_MARK_BACKGROUNDS__ = 401;
-    public static final int __GO_NUM_MARK_BACKGROUNDS__ = 402;
+    public static final int __GO_DATATIP_DISPLAY_MODE__ = 353;
+    public static final int __GO_DATA_MODEL_DISPLAY_FUNCTION__ = 354;
+    public static final int __GO_DATA_MODEL_DISPLAY_FUNCTION_SIZE__ = 355;
+    public static final int __GO_RESIZE__ = 356;
+    public static final int __GO_TOOLBAR__ = 357;
+    public static final int __GO_TOOLBAR_VISIBLE__ = 358;
+    public static final int __GO_MENUBAR__ = 359;
+    public static final int __GO_MENUBAR_VISIBLE__ = 360;
+    public static final int __GO_INFOBAR_VISIBLE__ = 361;
+    public static final int __GO_DOCKABLE__ = 362;
+    public static final int __GO_LAYOUT__ = 363;
+    public static final int __GO_LAYOUT_SET__ = 364;
+    public static final int __GO_UI_TAB__ = 365;
+    public static final int __GO_UI_GRIDBAG_GRID__ = 366;
+    public static final int __GO_UI_GRIDBAG_WEIGHT__ = 367;
+    public static final int __GO_UI_GRIDBAG_FILL__ = 368;
+    public static final int __GO_UI_GRIDBAG_ANCHOR__ = 369;
+    public static final int __GO_UI_GRIDBAG_PADDING__ = 370;
+    public static final int __GO_UI_GRIDBAG_PREFERREDSIZE__ = 371;
+    public static final int __GO_UI_GRID_GRID__ = 372;
+    public static final int __GO_UI_GRID_PADDING__ = 373;
+    public static final int __GO_UI_BORDER_POSITION__ = 374;
+    public static final int __GO_UI_BORDER_PREFERREDSIZE__ = 375;
+    public static final int __GO_GRID_OPT_GRID__ = 376;
+    public static final int __GO_GRID_OPT_PADDING__ = 377;
+    public static final int __GO_BORDER_OPT_PADDING__ = 378;
+    public static final int __GO_UI_FRAME_BORDER__ = 379;
+    public static final int __GO_UI_FRAME_BORDER_COLOR__ = 380;
+    public static final int __GO_UI_FRAME_BORDER_HIGHLIGHT_IN__ = 381;
+    public static final int __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__ = 382;
+    public static final int __GO_UI_FRAME_BORDER_IN_BORDER__ = 383;
+    public static final int __GO_UI_FRAME_BORDER_JUSTIFICATION__ = 384;
+    public static final int __GO_UI_FRAME_BORDER_OUT_BORDER__ = 385;
+    public static final int __GO_UI_FRAME_BORDER_ROUNDED__ = 386;
+    public static final int __GO_UI_FRAME_BORDER_SHADOW_IN__ = 387;
+    public static final int __GO_UI_FRAME_BORDER_SHADOW_OUT__ = 388;
+    public static final int __GO_UI_FRAME_BORDER_TITLE__ = 389;
+    public static final int __GO_UI_FRAME_BORDER_POSITION__ = 390;
+    public static final int __GO_UI_FRAME_BORDER_STYLE__ = 391;
+    public static final int __GO_UI_GROUP_NAME__ = 392;
+    public static final int __GO_UI_TITLE_POSITION__ = 393;
+    public static final int __GO_UI_TITLE_SCROLL__ = 394;
+    public static final int __GO_UI_FRAME_BORDER_TYPE__ = 395;
+    public static final int __GO_UI_SCROLLABLE__ = 396;
+    public static final int __GO_COLOR_SET__ = 397;
+    public static final int __GO_MARK_SIZES__ = 398;
+    public static final int __GO_NUM_MARK_SIZES__ = 399;
+    public static final int __GO_MARK_FOREGROUNDS__ = 400;
+    public static final int __GO_NUM_MARK_FOREGROUNDS__ = 401;
+    public static final int __GO_MARK_BACKGROUNDS__ = 402;
+    public static final int __GO_NUM_MARK_BACKGROUNDS__ = 403;
 
 }
index 81d83ce..b105123 100644 (file)
@@ -22,6 +22,7 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_DATATIPS__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_DATATIP_DISPLAY_FNC__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_DATATIP_MARK__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_DATATIP_DISPLAY_MODE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_INTERP_COLOR_MODE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_INTERP_COLOR_VECTOR_SET__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_INTERP_COLOR_VECTOR__;
@@ -55,9 +56,25 @@ public class Polyline extends ClippableContouredObject {
     private enum PolylineProperty { CLOSED, ARROWSIZEFACTOR, POLYLINESTYLE,
                                     INTERPCOLORVECTOR, INTERPCOLORVECTORSET, INTERPCOLORMODE,
                                     XSHIFT, YSHIFT, ZSHIFT, BARWIDTH, DATATIPS, DATATIPSCOUNT,
-                                    TIP_DISPLAY_FNC, TIP_MARK, COLORSET
+                                    TIP_DISPLAY_FNC, TIP_MARK, COLORSET, DATATIPDISPLAYMODE
                                   };
 
+    public enum DatatipDisplayMode { ALWAYS, MOUSECLICK, MOUSEOVER;
+
+    public static DatatipDisplayMode intToEnum(Integer i) {
+        switch (i) {
+            case 0:
+                return DatatipDisplayMode.ALWAYS;
+            case 1:
+                return DatatipDisplayMode.MOUSECLICK;
+            case 2:
+                return DatatipDisplayMode.MOUSEOVER;
+            default:
+                return DatatipDisplayMode.ALWAYS;
+        }
+    }
+                                   };
+
     /** Specifies whether the polyline is closed */
     private boolean closed;
 
@@ -99,6 +116,8 @@ public class Polyline extends ClippableContouredObject {
     /** has color set */
     private boolean colorSet;
 
+    DatatipDisplayMode datatipDisplayMode;
+
     /** Constructor */
     public Polyline() {
         super();
@@ -116,6 +135,7 @@ public class Polyline extends ClippableContouredObject {
         displayFnc = "";
         tipMark = 11;
         colorSet = false;
+        datatipDisplayMode = DatatipDisplayMode.ALWAYS;
     }
 
     @Override
@@ -160,6 +180,8 @@ public class Polyline extends ClippableContouredObject {
                 return PolylineProperty.TIP_MARK;
             case __GO_COLOR_SET__ :
                 return PolylineProperty.COLORSET;
+            case __GO_DATATIP_DISPLAY_MODE__:
+                return PolylineProperty.DATATIPDISPLAYMODE;
             default :
                 return super.getPropertyFromName(propertyName);
         }
@@ -203,6 +225,8 @@ public class Polyline extends ClippableContouredObject {
                     return getTipMark();
                 case COLORSET:
                     return getColorSet();
+                case DATATIPDISPLAYMODE:
+                    return getDatatipDisplayMode();
             }
         }
         return super.getProperty(property);
@@ -260,6 +284,8 @@ public class Polyline extends ClippableContouredObject {
                     case COLORSET:
                         setColorSet((Boolean) value);
                         break;
+                    case DATATIPDISPLAYMODE:
+                        return setDatatipDisplayMode((Integer)value);
                 }
             }
             return super.setProperty(property, value);
@@ -495,6 +521,41 @@ public class Polyline extends ClippableContouredObject {
         return UpdateStatus.Success;
     }
 
+
+    /**
+     * Get the current datatip display mode
+     * @return the datatip display mode
+     */
+    public Integer getDatatipDisplayMode() {
+        return datatipDisplayMode.ordinal();
+    }
+
+    /**
+     * Get the current datatip display mode as a enum
+     * @return the datatip display mode
+     */
+    public DatatipDisplayMode getDatatipDisplayModeAsEnum() {
+        return datatipDisplayMode;
+    }
+
+    /**
+     * Set the datatip display mode
+     * @param dm datatip display mode.
+     */
+    public UpdateStatus setDatatipDisplayMode(Integer dm) {
+        datatipDisplayMode = DatatipDisplayMode.intToEnum(dm);
+        return UpdateStatus.Success;
+    }
+
+    /**
+     * Set the datatip display mode
+     * @param dm datatip display mode.
+     */
+    public UpdateStatus setDatatipDisplayModeAsEnum(DatatipDisplayMode dm) {
+        datatipDisplayMode = dm;
+        return UpdateStatus.Success;
+    }
+
     /**
      * @return Type as String
      */
index a69679f..724fea2 100755 (executable)
@@ -395,6 +395,7 @@ __GO_LIGHT_TYPE__
 __GO_DATATIPS__
 __GO_DATATIPS_COUNT__
 __GO_DATATIP_INDEXES__
+__GO_DATATIP_DISPLAY_MODE__
 
 __GO_DATA_MODEL_DISPLAY_FUNCTION__
 __GO_DATA_MODEL_DISPLAY_FUNCTION_SIZE__
index 509e7f3..dc275c1 100644 (file)
                 </listitem>
             </varlistentry>
             <varlistentry>
+                <term>datatip_display_mode: </term>
+                <listitem>
+                    <para>
+                        This field determines how the datatips are displayed. Its value can be <literal>always</literal>, 
+                        <literal>mouseclick</literal> or <literal>mouseover</literal>.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
                 <term>display_function: </term>
                 <listitem>
                     <para>
index 9651273..21a294a 100755 (executable)
@@ -84,6 +84,7 @@ function %h_p(h)
             "parent: "+h.parent.type
             "children: "+fmtchildren(h.children)
             "datatips: "+fmtchildren(h.datatips)
+            "datatip_display_mode: "+sci2exp(h.datatip_display_mode)
             "display_function = "++sci2exp(h.display_function)
             "display_function_data = "+fmtuser_data(h.display_function_data)
             "visible = "+sci2exp(h.visible)
index 86d7232..61d0a5c 100755 (executable)
@@ -221,6 +221,7 @@ static getHashTableCouple propertyGetTable[] =
     {"orientation", get_tip_orientation_property},
     {"z_component", get_tip_z_component_property},
     {"display_components", get_tip_display_components_property},
+    {"datatip_display_mode", get_datatip_display_mode_property},
     {"auto_orientation", get_tip_auto_orientation_property},
     {"interp_mode", get_tip_interp_mode_property},
     {"box_mode", get_tip_box_mode_property},
index 5746c4d..9aa2986 100755 (executable)
@@ -220,6 +220,7 @@ static setHashTableCouple propertySetTable[] =
     {"orientation", set_tip_orientation_property},
     {"z_component", set_tip_z_component_property},
     {"display_components", set_tip_display_components_property},
+    {"datatip_display_mode", set_datatip_display_mode_property},
     {"auto_orientation", set_tip_auto_orientation_property},
     {"interp_mode", set_tip_interp_mode_property},
     {"box_mode", set_tip_box_mode_property},
index 05a9f00..5eb82c8 100755 (executable)
@@ -166,6 +166,7 @@ GRAPHICS_IMPEXP void* get_UID(void* _pvCtx, int iObjUID);
 GRAPHICS_IMPEXP void* get_tip_orientation_property(void* _pvCtx, int iObjUID);
 GRAPHICS_IMPEXP void* get_tip_z_component_property(void* _pvCtx, int iObjUID);
 GRAPHICS_IMPEXP void* get_tip_display_components_property(void* _pvCtx, int iObjUID);
+GRAPHICS_IMPEXP void* get_datatip_display_mode_property(void* _pvCtx, int iObjUID);
 GRAPHICS_IMPEXP void* get_tip_auto_orientation_property(void* _pvCtx, int iObjUID);
 GRAPHICS_IMPEXP void* get_tip_interp_mode_property(void* _pvCtx, int iObjUID);
 GRAPHICS_IMPEXP void* get_tip_box_mode_property(void* _pvCtx, int iObjUID);
index e61bef2..72d990c 100755 (executable)
@@ -64,6 +64,41 @@ void* get_tip_z_component_property(void* _pvCtx, int iObjUID)
     return NULL;
 }
 
+/**
+ * Get display mode for datatips
+ */
+void* get_datatip_display_mode_property(void* _pvCtx, int iObjUID)
+{
+    int datatip_display_mode = -1;
+    int * p_datatip_display_mode = &datatip_display_mode;
+    const char * name = NULL;
+    getGraphicObjectProperty(iObjUID, __GO_DATATIP_DISPLAY_MODE__, jni_int, (void **)&p_datatip_display_mode);
+
+    if (datatip_display_mode == -1)
+    {
+        Scierror(999, _("'%s' property does not exist for this handle.\n"), "datatip_display_mode");
+        return NULL;
+    }
+
+    switch (datatip_display_mode)
+    {
+        case 0:
+            name = "always";
+            break;
+        case 1:
+            name = "mouseclick";
+            break;
+        case 2:
+            name = "mouseover";
+            break;
+        default:
+            name = "always";
+            break;
+    }
+
+    return sciReturnString(name);
+}
+
 
 /**
  * Get the datatip components that should be displayed
index 2def651..f5fd643 100755 (executable)
@@ -168,6 +168,7 @@ int set_tag_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int n
 int set_tip_orientation_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
 int set_tip_z_component_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
 int set_tip_display_components_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
+int set_datatip_display_mode_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
 int set_tip_auto_orientation_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
 int set_tip_interp_mode_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
 int set_tip_box_mode_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
index 63bf0bf..700a1f1 100755 (executable)
@@ -77,6 +77,52 @@ int set_tip_z_component_property(void* _pvCtx, int iObj, void* _pvData, int valu
 }
 
 /**
+ * Set display mode for datatips
+ */
+int set_datatip_display_mode_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol)
+{
+    BOOL status = FALSE;
+    const char * value = (const char*) _pvData;
+    int datatip_display_mode = -1;
+    if (strcmp(value, "always") == 0)
+    {
+        datatip_display_mode = 0;
+    }
+    else if (strcmp(value, "mouseclick") == 0)
+    {
+        datatip_display_mode = 1;
+    }
+    else if (strcmp(value, "mouseover") == 0)
+    {
+        datatip_display_mode = 2;
+    }
+
+    if (datatip_display_mode >= 0)
+    {
+        status = setGraphicObjectProperty(iObj, __GO_DATATIP_DISPLAY_MODE__, &datatip_display_mode, jni_int, 1);
+        if (status == TRUE)
+        {
+            return SET_PROPERTY_SUCCEED;
+        }
+    }
+    else
+    {
+        int type;
+        int *piType = &type;
+        getGraphicObjectProperty(iObj, __GO_TYPE__, jni_int, (void **)&piType);
+        if (type == __GO_POLYLINE__)
+        {
+            Scierror(999, _("Inavlid value for '%s' property, use 'always', 'mouseclick' or 'mouseover'.\n"), "datatip_display_mode");
+        }
+        else
+        {
+            Scierror(999, _("'%s' property does not exist for this handle.\n"), "datatip_display_mode");
+        }
+        return SET_PROPERTY_ERROR;
+    }
+}
+
+/**
  * Set which coordinate components should be displayed
  */
 int set_tip_display_components_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol)
index 11150d5..3d64dc4 100644 (file)
@@ -367,6 +367,7 @@ struct PolylineHandle
         m.emplace_back("bar_width", std::vector<int>({SAVE_LOAD, __GO_BAR_WIDTH__, jni_double}));
         m.emplace_back("clip_box", std::vector<int>({SAVE_LOAD, __GO_CLIP_BOX__, jni_double_vector, -1, -4}));
         m.emplace_back("clip_state", std::vector<int>({SAVE_LOAD, __GO_CLIP_STATE__, jni_int}));
+        m.emplace_back("datatip_display_mode", std::vector<int>({SAVE_LOAD, __GO_DATATIP_DISPLAY_MODE__, jni_int}));
 
         //@end
         m.emplace_back("visible", std::vector<int>({SAVE_LOAD, __GO_VISIBLE__, jni_bool}));
index 8380721..0801e12 100755 (executable)
@@ -81,6 +81,7 @@ import org.scilab.modules.renderer.JoGLView.arrowDrawing.ArrowDrawer;
 import org.scilab.modules.renderer.JoGLView.axes.AxesDrawer;
 import org.scilab.modules.renderer.JoGLView.contouredObject.ContouredObjectDrawer;
 import org.scilab.modules.renderer.JoGLView.datatip.DatatipTextDrawer;
+import org.scilab.modules.renderer.JoGLView.datatip.DatatipDisplayModeManager;
 import org.scilab.modules.renderer.JoGLView.interaction.InteractionManager;
 import org.scilab.modules.renderer.JoGLView.label.LabelManager;
 import org.scilab.modules.renderer.JoGLView.legend.LegendDrawer;
@@ -147,6 +148,7 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
     private final ArrowDrawer arrowDrawer;
     private final FecDrawer fecDrawer;
     private final DatatipTextDrawer datatipTextDrawer;
+    private DatatipDisplayModeManager datatipDisplayModeManager;
 
     private DrawingTools drawingTools;
     private Texture colorMapTexture;
@@ -189,6 +191,7 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
         this.fecDrawer = new FecDrawer(this);
         this.colorMapTextureDataProvider = new ColorMapTextureDataProvider();
         this.datatipTextDrawer = new DatatipTextDrawer(canvas);
+        this.datatipDisplayModeManager = new DatatipDisplayModeManager(component);
 
         visitorMap.put(figure.getIdentifier(), this);
     }
@@ -954,7 +957,8 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                         Texture texture = markManager.getMarkSprite(datatip, colorMap, null);
                         drawingTools.draw(texture, AnchorPosition.CENTER, markPos);
                     }
-                    if (datatip.getTipLabelMode()) {
+                    if (datatip.getTipLabelMode() &&
+                            datatipDisplayModeManager.needDraw(datatip.getIdentifier())) {
                         datatipTextDrawer.draw(drawingTools, colorMap, datatip);
                     }
                 }
@@ -1295,6 +1299,9 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
     @Override
     public void deleteObject(Integer id) {
         Integer type = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
+        if (type == GraphicObjectProperties.__GO_DATATIP__) {
+            datatipDisplayModeManager.remove(id);
+        }
         if (!figure.getIdentifier().equals(id) && type == GraphicObjectProperties.__GO_UICONTROL__ || type == GraphicObjectProperties.__GO_UIMENU__) {
             return; // Not of my managed openGL children
         }
diff --git a/scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/datatip/DatatipDisplayModeManager.java b/scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/datatip/DatatipDisplayModeManager.java
new file mode 100644 (file)
index 0000000..f11cbe6
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *
+ * Copyright (C) 2016 - Scilab Enterprises
+ * Copyright (C) 2016 - Caio SOUZA
+ *
+ * This file is hereby licensed under the terms of the GNU GPL v2.0,
+ * pursuant to article 5.3.4 of the CeCILL v.2.1.
+ * This file was originally licensed under the terms of the CeCILL v2.1,
+ * and continues to be available under such terms.
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
+ *
+ */
+
+package org.scilab.modules.renderer.JoGLView.datatip;
+
+import org.scilab.modules.graphic_objects.graphicController.GraphicController;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_PARENT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_DATA_MODEL__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_PARENT_AXES__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_DATATIP_DISPLAY_MODE__;
+import static org.scilab.modules.graphic_objects.polyline.Polyline.DatatipDisplayMode;
+
+import org.scilab.modules.graphic_objects.axes.Axes;
+import org.scilab.modules.graphic_objects.datatip.Datatip;
+
+import org.scilab.modules.renderer.JoGLView.axes.AxesDrawer;
+
+import java.awt.Component;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.AWTEvent;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.HashMap;
+import java.util.Map;
+
+public class DatatipDisplayModeManager {
+
+    List<Integer> clicked_datatips = new LinkedList<Integer>();
+
+
+    class Position {
+        public double x;
+        public double y;
+        public Position(double x, double y) {
+            this.x = x;
+            this.y = y;
+        }
+    };
+
+    Integer hover = 0;
+
+    private Map<Integer, Position> datatips = new HashMap<Integer, Position>();
+
+    public DatatipDisplayModeManager(Component component) {
+
+        if (component != null) {
+            component.addMouseListener(new MouseAdapter() {
+                @Override
+                public void mouseClicked(MouseEvent event) {
+                    onMouseClick(event.getX(), event.getY());
+                }
+            });
+
+            component.addMouseMotionListener(new MouseAdapter() {
+                @Override
+                public void mouseMoved(MouseEvent event) {
+                    onMouseMove(event.getX(), event.getY());
+                }
+            });
+        }
+    }
+
+    public void add(Integer uid) {
+        GraphicController controller =  GraphicController.getController();
+        Datatip datatip = (Datatip) controller.getObjectFromId(uid);
+        Double p[] = datatip.getTipData();
+        Integer auid = (Integer) controller.getProperty(uid, __GO_PARENT_AXES__);
+        Axes axes = (Axes) controller.getObjectFromId(auid);
+        if (axes != null) {
+            double position[] = AxesDrawer.computePixelFrom3dCoordinates(axes, new double[] {p[0], p[1], p[2]});
+            datatips.put(uid, new Position(position[0], position[1]));
+        }
+    }
+
+    public void remove(Integer uid) {
+        datatips.remove(uid);
+        clicked_datatips.remove(uid);
+    }
+
+    public boolean needDraw(Integer uid) {
+        add(uid);
+        GraphicController controller =  GraphicController.getController();
+        Integer puid = (Integer) controller.getProperty(uid, __GO_PARENT__);
+        Integer mode = (Integer) controller.getProperty(puid, __GO_DATATIP_DISPLAY_MODE__);
+        DatatipDisplayMode eMode = DatatipDisplayMode.intToEnum(mode);
+        switch (eMode) {
+            case ALWAYS:
+                return true;
+            case MOUSECLICK:
+                return clicked_datatips.contains(uid);
+            case MOUSEOVER:
+                return (uid == hover);
+            default:
+                return true;
+        }
+    }
+
+    private Integer get(int x, int y) {
+        for (Map.Entry<Integer, Position> entry : datatips.entrySet()) {
+            Integer uid = entry.getKey();
+            Position p = entry.getValue();
+            double x2 = (p.x - x * 1.0) * (p.x - x * 1.0);
+            double y2 = (p.y - y * 1.0) * (p.y - y * 1.0);
+
+            if ((x2 + y2) < 20.0) {
+                return uid;
+            }
+        }
+        return 0;
+    }
+
+    public void onMouseMove(int x, int y) {
+        Integer datatip = get(x, y);
+        if (datatip > 0) {
+            if (datatip != hover) {
+                hover = datatip;
+                //triger redreaw
+                GraphicController.getController().setProperty(datatip, __GO_DATA_MODEL__, 0);
+            }
+        } else {
+            if (hover != 0) {
+                GraphicController.getController().setProperty(hover, __GO_DATA_MODEL__, 0);
+                hover = 0;
+            }
+        }
+    }
+
+    public void onMouseClick(int x, int y) {
+        Integer datatip = get(x, y);
+        if (datatip > 0) {
+            if (clicked_datatips.contains(datatip)) {
+                clicked_datatips.remove(datatip);
+            } else {
+                clicked_datatips.add(datatip);
+            }
+            //triger redreaw
+            GraphicController.getController().setProperty(datatip, __GO_DATA_MODEL__, 0);
+        }
+    }
+}