* Bug #13049 fixed - New handled protocols added in links in SciNotes.
+* Bug #13053 fixed - datatipCreate did not return datatip handle.
+
Xcos Bug Fixes
==============
#include "HandleManagement.h"
#include "getGraphicObjectProperty.h"
#include "graphicObjectProperties.h"
+#include "stricmp.h"
}
using namespace org_scilab_modules_gui_datatip;
return iRet;
}
- compVar = strcmp(pstData, "upper left");
+ compVar = stricmp(pstData, "upper left");
if (compVar == 0)
{
DatatipOrientation::datatipSetOrientation(getScilabJavaVM(), iDatatipUID, (char*)pstData, 0);
return 0;
}
- compVar = strcmp(pstData, "upper right");
+ compVar = stricmp(pstData, "upper right");
if (compVar == 0)
{
DatatipOrientation::datatipSetOrientation(getScilabJavaVM(), iDatatipUID, (char*)pstData, 1);
return 0;
}
- compVar = strcmp(pstData, "lower left");
+ compVar = stricmp(pstData, "lower left");
if (compVar == 0)
{
DatatipOrientation::datatipSetOrientation(getScilabJavaVM(), iDatatipUID, (char*)pstData, 2);
return 0;
}
- compVar = strcmp(pstData, "lower right");
+ compVar = stricmp(pstData, "lower right");
if (compVar == 0)
{
DatatipOrientation::datatipSetOrientation(getScilabJavaVM(), iDatatipUID, (char*)pstData, 3);
return 0;
}
- compVar = strcmp(pstData, "automatic");
+ compVar = stricmp(pstData, "automatic");
if (compVar == 0)
{
DatatipOrientation::datatipSetOrientation(getScilabJavaVM(), iDatatipUID, (char*)pstData, 4);
Scierror(999, _("%s: Wrong size for input argument #%d: 1-by-%d or %d-by-1 vector expected.\n"), fname, 2, 2, 3);
return 1;
}
+
+ llHandle = ScilabView::getObjectHandle(iDatatip_handler);
}
else
{
*
* @param datatipUid Datatip unique identifier.
*/
- public static void deleteDatatip(Integer datatipUid) {
+ public static void deleteDatatip(int datatipUid) {
Double[] datatipPosition = (Double[]) GraphicController.getController().getProperty(datatipUid, GraphicObjectProperties.__GO_DATATIP_DATA__);
* @param polylineUid Polyline unique identifier.
* @param indexRemove Index of the datatip to be removed.
*/
- public static void datatipRemoveProgramIndex(Integer polylineUid, int indexRemove) {
+ public static void datatipRemoveProgramIndex(int polylineUid, int indexRemove) {
Integer[] datatips = (new ObjectSearcher()).search(polylineUid, GraphicObjectProperties.__GO_DATATIP__);
* @param datatipUid Datatip unique identifier.
* @param figureUid Figure unique identifier.
*/
- public static void datatipRemoveProgramHandler(Integer datatipUid, Integer figureUid) {
+ public static void datatipRemoveProgramHandler(int datatipUid, Integer figureUid) {
deleteDatatip(datatipUid);
}
* @param endX Integer with pixel mouse position x after mouse drag.
* @param endY Integer with pixel mouse position y after mouse drag.
*/
- public static void dragDatatip(Integer datatipUid, int endX, int endY) {
+ public static void dragDatatip(int datatipUid, int endX, int endY) {
Integer parentPolyline = DatatipCommon.getParentPolyline(datatipUid);
GraphicController.getController().setProperty(datatip, __GO_DATATIP_ORIENTATION__, finalOrientation);
-
/* check if the tip is visible*/
CallRenderer.updateTextBounds(datatip);
Double[] corners = (Double[])GraphicController.getController().getProperty(datatip, __GO_CORNERS__);
* @param datatipOrientation String with datatip orientation.
* @param datatipOrientationNum Integer with datatip orientation to set property.
*/
- public static void datatipSetOrientation (Integer datatipUid, String datatipOrientation, int datatipOrientationNum) {
-
- if (datatipOrientationNum == 0) {
- GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_AUTOORIENTATION__, false);
- GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_ORIENTATION__, datatipOrientationNum);
- } else if (datatipOrientationNum == 1) {
- GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_AUTOORIENTATION__, false);
- GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_ORIENTATION__, datatipOrientationNum);
- } else if (datatipOrientationNum == 2) {
- GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_AUTOORIENTATION__, false);
- GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_ORIENTATION__, datatipOrientationNum);
- } else if (datatipOrientationNum == 3) {
- GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_AUTOORIENTATION__, false);
- GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_ORIENTATION__, datatipOrientationNum);
- } else if (datatipOrientationNum == 4) {
- GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_AUTOORIENTATION__, true);
- } else {
- String errorMsg = "error(msprintf(_( \"%s: Unknown input argument #%d: ''%s'' is not valid.\n\"),\"datatipSetOrientation\",2,\"" + datatipOrientation + "\"));";
- InterpreterManagement.requestScilabExec(errorMsg);
+ public static void datatipSetOrientation(int datatipUid, String datatipOrientation, int datatipOrientationNum) {
+ switch (datatipOrientationNum) {
+ case 0: // upper left
+ GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_AUTOORIENTATION__, false);
+ GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_ORIENTATION__, 0);
+ break;
+ case 1: // upper right
+ GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_AUTOORIENTATION__, false);
+ GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_ORIENTATION__, 1);
+ break;
+ case 2: // lower left
+ GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_AUTOORIENTATION__, false);
+ GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_ORIENTATION__, 2);
+ break;
+ case 3: // lower right
+ GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_AUTOORIENTATION__, false);
+ GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_ORIENTATION__, 3);
+ break;
+ case 4: // automatic
+ GraphicController.getController().setProperty(datatipUid, __GO_DATATIP_AUTOORIENTATION__, true);
+ break;
+ default:
+ String errorMsg = "error(msprintf(_( \"%s: Unknown input argument #%d: ''%s'' is not valid.\n\"),\"datatipSetOrientation\",2,\"" + datatipOrientation + "\"));";
+ InterpreterManagement.requestScilabExec(errorMsg);
}
-
}
}
--- /dev/null
+// =============================================================================
+// 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.
+// =============================================================================
+// <-- TEST WITH GRAPHIC -->
+//
+// <-- Non-regression test for bug 13053 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13053
+//
+// <-- Short Description -->
+// datatipCreate did not return datatip handle.
+clf();
+x=linspace(-20,20,1000);
+plot(x,sinc(x),x,sinc(x^2));
+plot(x,sinc(x),x,sinc(x^2));
+ !
+at line 34 of exec file called by :
+_TMP_28708_1blIKW/bug_12978.tst',-1
+
+Attention : La syntaxe "vector ^ scalar" est obsolète. Elle sera supprimée dans Scilab 6.0.
+ Veuillez utiliser "vector .^ scalar" à la place.
+
+e=gce();
+e=e.children;
+d1=datatipCreate(e(1),500);
+assert_checkequal(typeof(d1), "handle");
+assert_checkequal(d1.type, "Datatip");
// This file is distributed under the same license as the Scilab package.
// =============================================================================
-// <-- INTERACTIVE TEST -->
+// <-- TEST WITH GRAPHIC -->
//
-// <-- Non-regression test for bug 12978 -->
+// <-- Non-regression test for bug 13053 -->
//
// <-- Bugzilla URL -->
-// http://bugzilla.scilab.org/12978
+// http://bugzilla.scilab.org/13053
//
// <-- Short Description -->
-// exportUI returned an error when arg was a figure handle
+// datatipCreate did not return datatip handle.
-exportUI(gcf());
\ No newline at end of file
+clf();
+x=linspace(-20,20,1000);
+plot(x,sinc(x),x,sinc(x^2));
+e=gce();
+e=e.children;
+d1=datatipCreate(e(1),500);
+
+assert_checkequal(typeof(d1), "handle");
+assert_checkequal(d1.type, "Datatip");
\ No newline at end of file
Transformation projection = drawingTools.getTransformationManager().getCanvasProjection();
- Vector3d textPosition = new Vector3d(datatip.getPosition());
-
Integer parentAxesId = datatip.getParentAxes();
Axes parentAxes = (Axes) GraphicController.getController().getObjectFromId(parentAxesId);
/* Compute the text box vectors and the text box to texture dimension ratios */
- Vector3d[] textBoxVectors = computeTextBoxVectors(projection, datatip, texture.getDataProvider().getTextureSize(), parentAxes);
+ Vector3d[] textBoxVectors = computeTextBoxVectors(projection, datatip, texture.getDataProvider().getTextureSize(), parentAxes);
+
double[] ratios = computeRatios(projection, datatip, textBoxVectors, texture.getDataProvider().getTextureSize(), spriteDims);
/* If text box mode is equal to filled, the texture must be updated */
double r = datatip.getMarkStyle() == 11 ? 1.0 : 2.0;
finalSize -= (finalSize >= 2.0) ? r : 0.0;
-
Vector3d delta = new Vector3d(finalSize, finalSize, 0);
/* set up the text position according to the datatip orientation*/
- if (datatip.getOrientation() == 2 ||
- datatip.getOrientation() == 3) {
- cornerPositions[0] = cornerPositions[0].minus(textBoxVectors[1]);
- delta = delta.setY(-finalSize);
- }
- if (datatip.getOrientation() == 0 ||
- datatip.getOrientation() == 2) {
- cornerPositions[0] = cornerPositions[0].minus(textBoxVectors[0]);
- delta = delta.setX(-finalSize);
+ if (datatip.isAutoOrientationEnabled()) {
+ Vector3d a = cornerPositions[0];
+ Vector3d position = projection.unproject(cornerPositions[0].minus(textBoxVectors[0]).plus(textBoxVectors[1]));
+ if (position.getX() >= -1 && position.getX() <= 1 && position.getY() >= -1 && position.getY() <= 1) {
+ cornerPositions[0] = cornerPositions[0].minus(textBoxVectors[0]);
+ delta = delta.setX(-finalSize);
+ } else {
+ position = projection.unproject(cornerPositions[0].plus(textBoxVectors[0]).minus(textBoxVectors[1]));
+ if (position.getX() >= -1 && position.getX() <= 1 && position.getY() >= -1 && position.getY() <= 1) {
+ cornerPositions[0] = cornerPositions[0].minus(textBoxVectors[1]);
+ delta = delta.setY(-finalSize);
+ } else {
+ position = projection.unproject(cornerPositions[0].minus(textBoxVectors[0]).minus(textBoxVectors[1]));
+ if (position.getX() >= -1 && position.getX() <= 1 && position.getY() >= -1 && position.getY() <= 1) {
+ cornerPositions[0] = cornerPositions[0].minus(textBoxVectors[1]);
+ cornerPositions[0] = cornerPositions[0].minus(textBoxVectors[0]);
+ delta = delta.setX(-finalSize);
+ delta = delta.setY(-finalSize);
+ }
+ }
+ }
+ } else {
+ if (datatip.getOrientation() == 2 || datatip.getOrientation() == 3) {
+ cornerPositions[0] = cornerPositions[0].minus(textBoxVectors[1]);
+ delta = delta.setY(-finalSize);
+ }
+ if (datatip.getOrientation() == 0 || datatip.getOrientation() == 2) {
+ cornerPositions[0] = cornerPositions[0].minus(textBoxVectors[0]);
+ delta = delta.setX(-finalSize);
+ }
}
cornerPositions[0] = cornerPositions[0].plus(delta);
cornerPositions[1] = cornerPositions[1].plus(delta);
+
/* The Text object's rotation direction convention is opposite to the standard one, its angle is expressed in radians. */
drawingTools.draw(texture, AnchorPosition.LOWER_LEFT, cornerPositions[0], -180.0 * datatip.getFontAngle() / Math.PI);
Double[] pos = text.getPosition();
/* The text position vector before logarithmic scaling */
- Vector3d unscaledTextPosition = new Vector3d(pos);
+ Vector3d textPosition = new Vector3d(pos);
boolean[] logFlags = new boolean[] {parentAxes.getXAxisLogFlag(), parentAxes.getYAxisLogFlag(), parentAxes.getZAxisLogFlag()};
/* Apply logarithmic scaling and then project */
- Vector3d textPosition = ScaleUtils.applyLogScale(unscaledTextPosition, logFlags);
- unscaledTextPosition = new Vector3d(unscaledTextPosition.getX() * factors[0][0] + factors[1][0], unscaledTextPosition.getY() * factors[0][1] + factors[1][1], unscaledTextPosition.getZ() * factors[0][2] + factors[1][2]);
+ textPosition = ScaleUtils.applyLogScale(textPosition, logFlags);
+ textPosition = new Vector3d(textPosition.getX() * factors[0][0] + factors[1][0], textPosition.getY() * factors[0][1] + factors[1][1], textPosition.getZ() * factors[0][2] + factors[1][2]);
Vector3d projTextPosition = projection.project(textPosition);
/* Compute the text label vectors in window coordinates */
textHeight = ScaleUtils.applyInverseLogScale(textHeight, logFlags);
- textWidth = textWidth.minus(unscaledTextPosition);
- textHeight = textHeight.minus(unscaledTextPosition);
+ textWidth = textWidth.minus(textPosition);
+ textHeight = textHeight.minus(textPosition);
if (text.getTextBoxMode() >= 1) {
textWidth = textWidth.getNormalized().times(textBox[0] * factors[0][0]);
}
/* Computes the lower-right and upper-left corners. */
- textWidth = textWidth.plus(unscaledTextPosition);
- textHeight = textHeight.plus(unscaledTextPosition);
+ textWidth = textWidth.plus(textPosition);
+ textHeight = textHeight.plus(textPosition);
/* Finally re-apply logarithmic scaling, compute the vectors and project */
textWidth = ScaleUtils.applyLogScale(textWidth, logFlags);
textHeight = ScaleUtils.applyLogScale(textHeight, logFlags);
- textWidth = textWidth.minus(unscaledTextPosition);
- textHeight = textHeight.minus(unscaledTextPosition);
+ textWidth = textWidth.minus(textPosition);
+ textHeight = textHeight.minus(textPosition);
projTextWidth = projection.projectDirection(textWidth);
projTextHeight = projection.projectDirection(textHeight);