- 2D draw some rectangle.
- 3D draw some cube.
- Able to return mouse button used in 2D/3D click mode.
- Able to drag in 2D. Drag in 3D is non-sense.
- Able to set start point in 2D.
- Bug #11089 fixed - rubberbox crashed Scilab.
Change-Id: I22b389dedd3fafcac717d5b044107c1b39bab02f
* Bug #10809, #10810 fixed - error_table help page was not up-to-date.
-* Bug #10820 fixed - datatipscurve generator was freezing Scilab.
-
* Bug #10828 fixed - Developer arguments were not displayed in the help of
Scilab scripts.
* Bug #7289 fixed - The menu handle was still valid after calling delmenu(console_menu_handle).
+* Bug #7728 fixed - rubberbox(): Instantaneous pointer's coordinates are now displayed in the status bar.
+
* Bug #7779 fixed - genlib did not check input arguments and did not use current
path as default.
* Bug #10807 fixed - It was not possible to overload fft and fftw for list,
tlist, mlist type.
+* Bug #10820 fixed - datatipscurve generator was freezing Scilab.
+
* Bug #10831 fixed - set("auto_clear", "on") and set("auto_clear", "off") returned an error.
* Bug #10835 fixed - Typo that made the 'atanm' function unusable fixed.
*/
typedef enum
{
- RESIZE_SUCCESS = 0,
- RESIZE_MULTIPLE_DOCKED_TAB = -1,
- RESIZE_SIZE_TOO_LARGE = -2,
- RESIZE_UNCHANGED = 1
+ RESIZE_SUCCESS = 0,
+ RESIZE_MULTIPLE_DOCKED_TAB = -1,
+ RESIZE_SIZE_TOO_LARGE = -2,
+ RESIZE_UNCHANGED = 1
} EResizeStatus;
* the rubber box
* @param[out] usedButton Scilab code of the button used to terminate the rubber box
*/
-GRAPHICS_IMPEXP void pixelRubberBox(sciPointObj * pFigure, BOOL isClick,
- const int initialRect[4], int endRect[4], int * usedButton);
+GRAPHICS_IMPEXP void pixelRubberBox(char * pFigure, BOOL isClick,
+ const int initialRect[4], int endRect[4], int * usedButton);
/**
* Call rubber box using a subwn scale
* @param[out] endRect array containing the [x,y,w,h] of the selected rectangle
* @param[out] usedButton Scilab code of the button used to terminate the rubber box
*/
-GRAPHICS_IMPEXP void rubberBox(sciPointObj * pSubwin, BOOL isClick,
- const double initialRect[4], double endRect[4], int * usedButton);
+GRAPHICS_IMPEXP void rubberBox(char * pSubwin, BOOL isClick,
+ const double initialRect[4], double endRect[4], int * usedButton);
/**
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2008 - INRIA - Jean-Baptiste Silvy
+ * Copyright (C) 2012 - DIGITEO - Vincent COUVERT
+ * Copyright (C) 2012 - Scilab Enterprises - Bruno JOFRET
*
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
#include "localization.h"
#include "getPropertyAssignedValue.h"
#include "Scierror.h"
-#include "Interaction.h"
+#include "JavaInteraction.h"
#include "HandleManagement.h"
+#include "BuildObjects.h"
+#include "CurrentSubwin.h"
+#include "getGraphicObjectProperty.h"
+#include "graphicObjectProperties.h"
/*--------------------------------------------------------------------------*/
static int getInitialRectangle(double initRect[4]);
static int getEditionMode(int rhsPos);
-static int returnRectAndButton(const double selectedRect[4], int button);
+static int returnRectAndButton(const double *_piJavaValues, int _iSelectedRectSize);
/*--------------------------------------------------------------------------*/
static int getInitialRectangle(double initRect[4])
{
- int rectNbRow = 0;
- int rectNbCol = 0;
- int rectStackPointer = 0;
- int i;
- int nbDims;
- double * rect;
-
- /* Initial rect is always in first position */
- GetRhsVar(1,MATRIX_OF_DOUBLE_DATATYPE,&rectNbRow,&rectNbCol,&rectStackPointer);
-
- /* We have found a matrix of double within the parameters check its dims */
- nbDims = rectNbCol * rectNbRow;
- if (nbDims != 2 && nbDims != 4)
- {
- return -1;
- }
-
-
- /* pointer on the stack */
- rect = getDoubleMatrixFromStack(rectStackPointer);
-
- /* intialize to 0 */
- for (i = 0; i < 4; i++)
- {
- initRect[i] = 0.0;
- }
-
- /* Set specified values */
- for (i = 0; i < nbDims; i++)
- {
- initRect[i] = rect[i];
- }
- return 1;
+ int rectNbRow = 0;
+ int rectNbCol = 0;
+ int rectStackPointer = 0;
+ int i;
+ int nbDims;
+ double * rect;
+
+ /* Initial rect is always in first position */
+ GetRhsVar(1, MATRIX_OF_DOUBLE_DATATYPE, &rectNbRow, &rectNbCol, &rectStackPointer);
+
+ /* We have found a matrix of double within the parameters check its dims */
+ nbDims = rectNbCol * rectNbRow;
+
+ if (nbDims != 2 && nbDims != 4)
+ {
+ return -1;
+ }
+
+
+ /* pointer on the stack */
+ rect = getDoubleMatrixFromStack(rectStackPointer);
+
+ /* intialize to 0 */
+ for (i = 0; i < 4; i++)
+ {
+ initRect[i] = 0.0;
+ }
+
+ /* Set specified values */
+ for (i = 0; i < nbDims; i++)
+ {
+ initRect[i] = rect[i];
+ }
+ return 1;
}
/*--------------------------------------------------------------------------*/
static int getEditionMode(int rhsPos)
{
- int stackPointer = 0;
- int nbRow = 0;
- int nbCol = 0;
- BOOL isEditionModeOn;
- GetRhsVar(rhsPos,MATRIX_OF_BOOLEAN_DATATYPE,&nbRow,&nbCol,&stackPointer);
-
- if (nbRow * nbCol != 1)
- {
- return -1;
- }
-
- isEditionModeOn = *istk(stackPointer);
- if (isEditionModeOn)
- {
- return 1;
- }
- else
- {
- return 0;
- }
+ int stackPointer = 0;
+ int nbRow = 0;
+ int nbCol = 0;
+ BOOL isEditionModeOn;
+ GetRhsVar(rhsPos, MATRIX_OF_BOOLEAN_DATATYPE, &nbRow, &nbCol, &stackPointer);
+
+ if (nbRow * nbCol != 1)
+ {
+ return -1;
+ }
+
+ isEditionModeOn = *istk(stackPointer);
+ if (isEditionModeOn)
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
}
/*--------------------------------------------------------------------------*/
-static int returnRectAndButton(const double selectedRect[4], int button)
+static int returnRectAndButton(const double *_piJavaValues, int _iSelectedRectSize)
{
- int selectedRectSize = 4;
- int one = 1;
- int rectStackPointer = 0;
- int i;
-
- /* return rectangle */
- CreateVar(Rhs + 1, MATRIX_OF_DOUBLE_DATATYPE, &one, &selectedRectSize, &rectStackPointer);
- for ( i = 0; i < selectedRectSize; i++)
- {
- stk(rectStackPointer)[i] = selectedRect[i];
- }
- LhsVar(1) = Rhs + 1;
-
- /* return button */
- if (Lhs >= 2)
- {
- int buttonStackPointer = 0;
- CreateVar(Rhs + 2, MATRIX_OF_DOUBLE_DATATYPE, &one, &one, &buttonStackPointer);
- *stk(buttonStackPointer) = button;
- LhsVar(2) = Rhs + 2;
- }
-
- PutLhsVar();
- return 0;
+ int zero = 0;
+ int one = 1;
+ int rectStackPointer = 0;
+ int i = 0;
+ int j = 0;
+
+ // button < 0 means user cancelled selection so return [] or [], []
+ if (_piJavaValues[0] < 0)
+ {
+ CreateVar(Rhs + 1, MATRIX_OF_DOUBLE_DATATYPE, &zero, &zero, &rectStackPointer);
+ LhsVar(1) = Rhs + 1;
+ if (Lhs >= 2)
+ {
+ CreateVar(Rhs + 2, MATRIX_OF_DOUBLE_DATATYPE, &zero, &zero, &rectStackPointer);
+ LhsVar(2) = Rhs + 2;
+ }
+ PutLhsVar();
+ return 0;
+ }
+
+ /* return rectangle */
+ CreateVar(Rhs + 1, MATRIX_OF_DOUBLE_DATATYPE, &one, &_iSelectedRectSize, &rectStackPointer);
+ for ( i = 0; i < _iSelectedRectSize / 2; i++)
+ {
+ j = i + _iSelectedRectSize / 2;
+ stk(rectStackPointer)[i] = _piJavaValues[i + 1];
+ stk(rectStackPointer)[j] = _piJavaValues[i + 4];
+ }
+ LhsVar(1) = Rhs + 1;
+
+ /* return button */
+ if (Lhs >= 2)
+ {
+ int buttonStackPointer = 0;
+ CreateVar(Rhs + 2, MATRIX_OF_DOUBLE_DATATYPE, &one, &one, &buttonStackPointer);
+ *stk(buttonStackPointer) = _piJavaValues[0];
+ LhsVar(2) = Rhs + 2;
+ }
+
+ PutLhsVar();
+ return 0;
}
/*--------------------------------------------------------------------------*/
int sci_rubberbox(char * fname, unsigned long fname_len)
{
- /* [final_rect, btn] = rubberbox([initial_rect],[edition_mode]) */
-
- int button = 0;
- double selectedRect[4];
-
- CheckRhs(0,2);
- CheckLhs(1,2);
-
- if (Rhs == 0)
- {
- /* rubberbox() */
- rubberBox(sciGetCurrentSubWin(), TRUE, NULL, selectedRect, &button);
- }
- else if (Rhs == 1)
- {
- /* rubberbox(initial_rect) or rubberbox(edition_mode) */
- if (GetType(1) == sci_matrix)
- {
- /* rubberbox(initial_rect) */
- /* Default values, intial rect and edition mode to false */
- double initialRect[4] = {0.0, 0.0, 0.0, 0.0};
-
- if (getInitialRectangle(initialRect) == 1)
- {
- rubberBox(sciGetCurrentSubWin(), TRUE, initialRect, selectedRect, &button);
- }
- else
- {
- Scierror(999, _("%s: Wrong size for input argument #%d: Vector of size %d or %d expected.\n"), fname, 1, 2, 4);
- return -1;
- }
- }
- else if (GetType(1) == sci_boolean)
- {
- /* rubberbox(editionMode) */
- int editionModeStatus = getEditionMode(1);
- if (editionModeStatus == 1)
- {
- /* rubberbox(%t) */
- rubberBox(sciGetCurrentSubWin(), FALSE, NULL, selectedRect, &button);
- }
- else if (editionModeStatus == 0)
- {
- /* rubberbox(%f) */
- rubberBox(sciGetCurrentSubWin(), TRUE, NULL, selectedRect, &button);
- }
- else
- {
- Scierror(999, _("%s: Wrong size for input argument #%d: A boolean expected\n."), fname, 1);
- return -1;
- }
- }
- else
- {
- /* Wrong parameter specified, neither edition mode nor intial rect */
- Scierror(999, _("%s: Wrong type for input argument #%d: Real row vector or a boolean expected.\n"), fname, 1);
- return -1;
- }
- }
- else if (Rhs == 2)
- {
- /* rubberbox(initial_rect, edition_mode) */
-
- /* Default values, intial rect and edition mode to false */
- double initialRect[4] = {0.0, 0.0, 0.0, 0.0};
- int editionModeStatus;
-
- if (GetType(1) != sci_matrix)
- {
- Scierror(999, _("%s: Wrong type for input argument #%d: Real row vector expected.\n"), fname, 1);
- return -1;
- }
-
- if (GetType(2) != sci_boolean)
- {
- Scierror(999, _("%s: Wrong type for input argument #%d: A boolean expected.\n"), fname, 2);
- return -1;
- }
-
- /* Getting initial rect */
- if(getInitialRectangle(initialRect) != 1)
- {
- Scierror(999, _("%s: Wrong size for input argument #%d: Vector of size %d or %d expected.\n"), fname, 1, 2, 4);
- return -1;
- }
-
- /* Getting edition mode */
- editionModeStatus = getEditionMode(2);
-
- if (editionModeStatus == 1)
- {
- /* rubberbox(initial_rect, %t) */
- rubberBox(sciGetCurrentSubWin(), FALSE, initialRect, selectedRect, &button);
- }
- else if (editionModeStatus == 0)
- {
- /* rubberbox(initial_rect, %f) */
- rubberBox(sciGetCurrentSubWin(), TRUE, initialRect, selectedRect, &button);
- }
- else
- {
- Scierror(999, _("%s: Wrong size for input argument #%d: A boolean expected\n."), fname, 2);
- return -1;
- }
-
- }
-
-
- /* Put values into the stack and return */
- return returnRectAndButton(selectedRect, button);
+ /* [final_rect, btn] = rubberbox([initial_rect],[edition_mode]) */
+
+ int button = 0;
+ double initialRect[4] = {0.0, 0.0, 0.0, 0.0};
+ int initialRectSize = 0;
+
+ double *piJavaValues = NULL;
+ char *pFigureUID;
+ char *pSubwinUID = getOrCreateDefaultSubwin();
+ int iView = 0;
+ int* piView = &iView;
+
+ BOOL bClickMode = TRUE;
+
+ CheckRhs(0, 2);
+ CheckLhs(1, 2);
+ // iView == 1 => 2D
+ // else 3D
+ getGraphicObjectProperty(pSubwinUID, __GO_VIEW__, jni_int, &piView);
+ getGraphicObjectProperty(pSubwinUID, __GO_PARENT__, jni_string, &pFigureUID);
+
+ if (Rhs == 0)
+ {
+ /* rubberbox() */
+ bClickMode = TRUE;
+ initialRectSize = 0;
+ }
+ else if (Rhs == 1)
+ {
+ // Check we are running 2D view rubberbox,
+ // Otherwise initial_rect and edition_mode are not usable.
+ if (iView == 1) // 3D
+ {
+ Scierror(999, _("%s: Can not run rubberbox on a 3D view with initial_rect or edition_mode option. See help for more information.\n"), fname);
+ return -1;
+ }
+ /* rubberbox(initial_rect) or rubberbox(edition_mode) */
+ if (GetType(1) == sci_matrix)
+ {
+ /* rubberbox(initial_rect) */
+ if (getInitialRectangle(initialRect) == 1)
+ {
+ bClickMode = TRUE;
+ initialRectSize = 4;
+ }
+ else
+ {
+ Scierror(999, _("%s: Wrong size for input argument #%d: Vector of size %d or %d expected.\n"), fname, 1, 2, 4);
+ return -1;
+ }
+ }
+ else if (GetType(1) == sci_boolean)
+ {
+ /* rubberbox(editionMode) */
+ int editionModeStatus = getEditionMode(1);
+ initialRectSize = 0;
+ if (editionModeStatus == 1)
+ {
+ /* rubberbox(%t) */
+ bClickMode = FALSE;
+ }
+ else if (editionModeStatus == 0)
+ {
+ /* rubberbox(%f) */
+ bClickMode = TRUE;
+ }
+ else
+ {
+ Scierror(999, _("%s: Wrong size for input argument #%d: A boolean expected\n."), fname, 1);
+ return -1;
+ }
+ }
+ else
+ {
+ /* Wrong parameter specified, neither edition mode nor intial rect */
+ Scierror(999, _("%s: Wrong type for input argument #%d: Real row vector or a boolean expected.\n"), fname, 1);
+ return -1;
+ }
+ }
+ else if (Rhs == 2)
+ {
+ /* rubberbox(initial_rect, edition_mode) */
+
+ /* Default values, intial rect and edition mode to false */
+ double initialRect[4] = {0.0, 0.0, 0.0, 0.0};
+ int editionModeStatus;
+
+ // Check we are running 2D view rubberbox,
+ // Otherwise initial_rect and edition_mode are not usable.
+ if (iView == 1) // 3D
+ {
+ Scierror(999, _("%s: Can not run rubberbox on a 3D view with initial_rect or edition_mode option. See help for more information.\n"), fname);
+ return -1;
+ }
+
+ if (GetType(1) != sci_matrix)
+ {
+ Scierror(999, _("%s: Wrong type for input argument #%d: Real row vector expected.\n"), fname, 1);
+ return -1;
+ }
+
+ if (GetType(2) != sci_boolean)
+ {
+ Scierror(999, _("%s: Wrong type for input argument #%d: A boolean expected.\n"), fname, 2);
+ return -1;
+ }
+
+ /* Getting initial rect */
+ if (getInitialRectangle(initialRect) != 1)
+ {
+ Scierror(999, _("%s: Wrong size for input argument #%d: Vector of size %d or %d expected.\n"), fname, 1, 2, 4);
+ return -1;
+ }
+
+ /* Getting edition mode */
+ editionModeStatus = getEditionMode(2);
+
+ if (editionModeStatus == 1)
+ {
+ /* rubberbox(initial_rect, %t) */
+ /*
+ ** Force click mode !!! Don't know to drag
+ ** if first point is set using init rect
+ */
+ bClickMode = TRUE;
+ }
+ else if (editionModeStatus == 0)
+ {
+ /* rubberbox(initial_rect, %f) */
+ bClickMode = TRUE;
+ }
+ else
+ {
+ Scierror(999, _("%s: Wrong size for input argument #%d: A boolean expected\n."), fname, 2);
+ return -1;
+ }
+
+ }
+
+
+ if (bClickMode == TRUE)
+ {
+ piJavaValues = javaClickRubberBox(pFigureUID, initialRect, initialRectSize);
+ }
+ else
+ {
+ piJavaValues = javaDragRubberBox(pFigureUID);
+ }
+ /* Put values into the stack and return */
+ if (iView == 1)
+ {
+ return returnRectAndButton(piJavaValues, 6);
+ }
+ else
+ {
+ return returnRectAndButton(piJavaValues, 4);
+ }
}
/*--------------------------------------------------------------------------*/
* exec the callback associated with pthis
*/
int
-sciAddCallback (sciPointObj * pthis,char *code, int len, int mevent )
+sciAddCallback (sciPointObj * pthis, char *code, int len, int mevent )
{
- /* Destruction de l'ancienne callback si elle existait */
- sciDelCallback (pthis);
+ /* Destruction de l'ancienne callback si elle existait */
+ sciDelCallback (pthis);
- switch (sciGetEntityType (pthis))
+ switch (sciGetEntityType (pthis))
{
- case SCI_SUBWIN:
- if ((pSUBWIN_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"),"sciAddCallback");
- return -1;
- }
- else
- {
- strncpy(pSUBWIN_FEATURE (pthis)->callback, code, len);
- pSUBWIN_FEATURE (pthis)->callbacklen = len;
- pSUBWIN_FEATURE (pthis)->callbackevent = mevent;
- }
- break;
- case SCI_ARC:
- if ((pARC_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"),"sciAddCallback");
- return -1;
- }
- else
- {
- strncpy(pARC_FEATURE (pthis)->callback, code, len);
- pARC_FEATURE (pthis)->callbacklen = len;
- pARC_FEATURE (pthis)->callbackevent = mevent;
-
- }
- break;
- case SCI_RECTANGLE:
- if ((pRECTANGLE_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"),"sciAddCallback");
- return -1;
- }
- else
- {
- strncpy(pRECTANGLE_FEATURE (pthis)->callback, code, len);
- pRECTANGLE_FEATURE (pthis)->callbacklen = len;
- pRECTANGLE_FEATURE (pthis)->callbackevent = mevent;
-
- }
- break;
- case SCI_SEGS:
- if ((pSEGS_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"),"sciAddCallback");
- return -1;
- }
- else
- {
- strncpy(pSEGS_FEATURE (pthis)->callback, code, len);
- pPOLYLINE_FEATURE (pthis)->callbacklen = len;
- pPOLYLINE_FEATURE (pthis)->callbackevent = mevent;
-
- }
- break;
- case SCI_FEC:
- if ((pFEC_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"),"sciAddCallback");
- return -1;
- }
- else
- {
- strncpy(pFEC_FEATURE (pthis)->callback, code, len);
- pPOLYLINE_FEATURE (pthis)->callbacklen = len;
- pPOLYLINE_FEATURE (pthis)->callbackevent = mevent;
-
- }
- break;
- case SCI_GRAYPLOT:
- if ((pGRAYPLOT_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"),"sciAddCallback");
- return -1;
- }
- else
- {
- strncpy(pGRAYPLOT_FEATURE (pthis)->callback, code, len);
- pPOLYLINE_FEATURE (pthis)->callbacklen = len;
- pPOLYLINE_FEATURE (pthis)->callbackevent = mevent;
-
- }
- break;
- case SCI_POLYLINE:
- if ((pPOLYLINE_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
- {
- Scierror(9999, _("%s: No more memory.\n"),"sciAddCallback");
- return -1;
- }
- else
- {
- strncpy(pPOLYLINE_FEATURE (pthis)->callback, code, len);
- pPOLYLINE_FEATURE (pthis)->callbacklen = len;
- pPOLYLINE_FEATURE (pthis)->callbackevent = mevent;
-
- }
- break;
- case SCI_UICONTROL:
- case SCI_UIMENU:
- break;
- case SCI_TEXT:
- case SCI_LEGEND:
- case SCI_SURFACE:
- case SCI_AXES:
- case SCI_FIGURE:
- case SCI_AGREG:
- case SCI_LABEL: /* F.Leray 28.05.04 */
-
- default:
- Scierror(999, _("No Callback is associated with this Entity.\n"));
- return -1;
- break;
+ case SCI_SUBWIN:
+ if ((pSUBWIN_FEATURE (pthis)->callback = CALLOC (len + 1, sizeof (char))) == NULL)
+ {
+ Scierror(999, _("%s: No more memory.\n"), "sciAddCallback");
+ return -1;
+ }
+ else
+ {
+ strncpy(pSUBWIN_FEATURE (pthis)->callback, code, len);
+ pSUBWIN_FEATURE (pthis)->callbacklen = len;
+ pSUBWIN_FEATURE (pthis)->callbackevent = mevent;
+ }
+ break;
+ case SCI_ARC:
+ if ((pARC_FEATURE (pthis)->callback = CALLOC (len + 1, sizeof (char))) == NULL)
+ {
+ Scierror(999, _("%s: No more memory.\n"), "sciAddCallback");
+ return -1;
+ }
+ else
+ {
+ strncpy(pARC_FEATURE (pthis)->callback, code, len);
+ pARC_FEATURE (pthis)->callbacklen = len;
+ pARC_FEATURE (pthis)->callbackevent = mevent;
+
+ }
+ break;
+ case SCI_RECTANGLE:
+ if ((pRECTANGLE_FEATURE (pthis)->callback = CALLOC (len + 1, sizeof (char))) == NULL)
+ {
+ Scierror(999, _("%s: No more memory.\n"), "sciAddCallback");
+ return -1;
+ }
+ else
+ {
+ strncpy(pRECTANGLE_FEATURE (pthis)->callback, code, len);
+ pRECTANGLE_FEATURE (pthis)->callbacklen = len;
+ pRECTANGLE_FEATURE (pthis)->callbackevent = mevent;
+
+ }
+ break;
+ case SCI_SEGS:
+ if ((pSEGS_FEATURE (pthis)->callback = CALLOC (len + 1, sizeof (char))) == NULL)
+ {
+ Scierror(999, _("%s: No more memory.\n"), "sciAddCallback");
+ return -1;
+ }
+ else
+ {
+ strncpy(pSEGS_FEATURE (pthis)->callback, code, len);
+ pPOLYLINE_FEATURE (pthis)->callbacklen = len;
+ pPOLYLINE_FEATURE (pthis)->callbackevent = mevent;
+
+ }
+ break;
+ case SCI_FEC:
+ if ((pFEC_FEATURE (pthis)->callback = CALLOC (len + 1, sizeof (char))) == NULL)
+ {
+ Scierror(999, _("%s: No more memory.\n"), "sciAddCallback");
+ return -1;
+ }
+ else
+ {
+ strncpy(pFEC_FEATURE (pthis)->callback, code, len);
+ pPOLYLINE_FEATURE (pthis)->callbacklen = len;
+ pPOLYLINE_FEATURE (pthis)->callbackevent = mevent;
+
+ }
+ break;
+ case SCI_GRAYPLOT:
+ if ((pGRAYPLOT_FEATURE (pthis)->callback = CALLOC (len + 1, sizeof (char))) == NULL)
+ {
+ Scierror(999, _("%s: No more memory.\n"), "sciAddCallback");
+ return -1;
+ }
+ else
+ {
+ strncpy(pGRAYPLOT_FEATURE (pthis)->callback, code, len);
+ pPOLYLINE_FEATURE (pthis)->callbacklen = len;
+ pPOLYLINE_FEATURE (pthis)->callbackevent = mevent;
+
+ }
+ break;
+ case SCI_POLYLINE:
+ if ((pPOLYLINE_FEATURE (pthis)->callback = CALLOC (len + 1, sizeof (char))) == NULL)
+ {
+ Scierror(9999, _("%s: No more memory.\n"), "sciAddCallback");
+ return -1;
+ }
+ else
+ {
+ strncpy(pPOLYLINE_FEATURE (pthis)->callback, code, len);
+ pPOLYLINE_FEATURE (pthis)->callbacklen = len;
+ pPOLYLINE_FEATURE (pthis)->callbackevent = mevent;
+
+ }
+ break;
+ case SCI_UICONTROL:
+ case SCI_UIMENU:
+ break;
+ case SCI_TEXT:
+ case SCI_LEGEND:
+ case SCI_SURFACE:
+ case SCI_AXES:
+ case SCI_FIGURE:
+ case SCI_AGREG:
+ case SCI_LABEL: /* F.Leray 28.05.04 */
+
+ default:
+ Scierror(999, _("No Callback is associated with this Entity.\n"));
+ return -1;
+ break;
}
- return -1;
+ return -1;
}
*/
char *sciGetCallback(sciPointObj * pthis)
{
- switch (sciGetEntityType (pthis))
+ switch (sciGetEntityType (pthis))
{
- case SCI_SUBWIN:
- return (char *)(pSUBWIN_FEATURE(pthis)->callback);
- break;
- case SCI_ARC:
- return (char *)(pARC_FEATURE(pthis)->callback);
- break;
- case SCI_SEGS:
- return (char *)(pSEGS_FEATURE(pthis)->callback);
- break;
- case SCI_FEC:
- return (char *)(pFEC_FEATURE(pthis)->callback);
- break;
- case SCI_GRAYPLOT:
- return (char *)(pGRAYPLOT_FEATURE(pthis)->callback);
- break;
- case SCI_POLYLINE:
- return (char *)(pPOLYLINE_FEATURE(pthis)->callback);
- break;
- case SCI_RECTANGLE:
- return (char *)(pRECTANGLE_FEATURE(pthis)->callback);
- break;
- case SCI_TEXT:
- return (char *)(pTEXT_FEATURE(pthis)->callback);
- break;
- case SCI_SURFACE:
- return (char *)(pSURFACE_FEATURE(pthis)->callback);
- break;
- case SCI_AXES:
- return (char *)(pAXES_FEATURE(pthis)->callback);
- break;
- case SCI_UIMENU:
- return (char *)(pUIMENU_FEATURE(pthis)->callback);
- break;
- case SCI_UICONTROL:
- return (char *)(pUICONTROL_FEATURE(pthis)->callback);
- break;
- case SCI_LEGEND:
- case SCI_FIGURE:
- case SCI_AGREG:
- case SCI_LABEL: /* F.Leray 28.05.04 */
- default:
- Scierror(999, _("No Callback is associated with this Entity.\n"));
- return (char *)NULL;
- break;
+ case SCI_SUBWIN:
+ return (char *)(pSUBWIN_FEATURE(pthis)->callback);
+ break;
+ case SCI_ARC:
+ return (char *)(pARC_FEATURE(pthis)->callback);
+ break;
+ case SCI_SEGS:
+ return (char *)(pSEGS_FEATURE(pthis)->callback);
+ break;
+ case SCI_FEC:
+ return (char *)(pFEC_FEATURE(pthis)->callback);
+ break;
+ case SCI_GRAYPLOT:
+ return (char *)(pGRAYPLOT_FEATURE(pthis)->callback);
+ break;
+ case SCI_POLYLINE:
+ return (char *)(pPOLYLINE_FEATURE(pthis)->callback);
+ break;
+ case SCI_RECTANGLE:
+ return (char *)(pRECTANGLE_FEATURE(pthis)->callback);
+ break;
+ case SCI_TEXT:
+ return (char *)(pTEXT_FEATURE(pthis)->callback);
+ break;
+ case SCI_SURFACE:
+ return (char *)(pSURFACE_FEATURE(pthis)->callback);
+ break;
+ case SCI_AXES:
+ return (char *)(pAXES_FEATURE(pthis)->callback);
+ break;
+ case SCI_UIMENU:
+ return (char *)(pUIMENU_FEATURE(pthis)->callback);
+ break;
+ case SCI_UICONTROL:
+ return (char *)(pUICONTROL_FEATURE(pthis)->callback);
+ break;
+ case SCI_LEGEND:
+ case SCI_FIGURE:
+ case SCI_AGREG:
+ case SCI_LABEL: /* F.Leray 28.05.04 */
+ default:
+ Scierror(999, _("No Callback is associated with this Entity.\n"));
+ return (char *)NULL;
+ break;
}
}
*/
int sciGetCallbackMouseEvent(sciPointObj * pthis)
{
- switch (sciGetEntityType (pthis))
+ switch (sciGetEntityType (pthis))
{
- case SCI_SUBWIN:
- return pSUBWIN_FEATURE(pthis)->callbackevent;
- break;
- case SCI_ARC:
- return pARC_FEATURE(pthis)->callbackevent;
- break;
- case SCI_SEGS:
- return pSEGS_FEATURE(pthis)->callbackevent;
- break;
- case SCI_FEC:
- return pFEC_FEATURE(pthis)->callbackevent;
- break;
- case SCI_GRAYPLOT:
- return pGRAYPLOT_FEATURE(pthis)->callbackevent;
- break;
- case SCI_POLYLINE:
- return pPOLYLINE_FEATURE(pthis)->callbackevent;
- break;
- case SCI_RECTANGLE:
- return pRECTANGLE_FEATURE(pthis)->callbackevent;
- break;
- case SCI_TEXT:
- return pTEXT_FEATURE(pthis)->callbackevent;
- break;
- case SCI_SURFACE:
- return pSURFACE_FEATURE(pthis)->callbackevent;
- break;
- case SCI_AXES:
- return pAXES_FEATURE(pthis)->callbackevent;
- break;
- case SCI_UIMENU:
- case SCI_LEGEND:
- case SCI_FIGURE:
- case SCI_AGREG:
- case SCI_LABEL: /* F.Leray 28.05.04 */
- default:
- Scierror(999, _("No Callback is associated with this Entity.\n"));
- return 100;
- break;
+ case SCI_SUBWIN:
+ return pSUBWIN_FEATURE(pthis)->callbackevent;
+ break;
+ case SCI_ARC:
+ return pARC_FEATURE(pthis)->callbackevent;
+ break;
+ case SCI_SEGS:
+ return pSEGS_FEATURE(pthis)->callbackevent;
+ break;
+ case SCI_FEC:
+ return pFEC_FEATURE(pthis)->callbackevent;
+ break;
+ case SCI_GRAYPLOT:
+ return pGRAYPLOT_FEATURE(pthis)->callbackevent;
+ break;
+ case SCI_POLYLINE:
+ return pPOLYLINE_FEATURE(pthis)->callbackevent;
+ break;
+ case SCI_RECTANGLE:
+ return pRECTANGLE_FEATURE(pthis)->callbackevent;
+ break;
+ case SCI_TEXT:
+ return pTEXT_FEATURE(pthis)->callbackevent;
+ break;
+ case SCI_SURFACE:
+ return pSURFACE_FEATURE(pthis)->callbackevent;
+ break;
+ case SCI_AXES:
+ return pAXES_FEATURE(pthis)->callbackevent;
+ break;
+ case SCI_UIMENU:
+ case SCI_LEGEND:
+ case SCI_FIGURE:
+ case SCI_AGREG:
+ case SCI_LABEL: /* F.Leray 28.05.04 */
+ default:
+ Scierror(999, _("No Callback is associated with this Entity.\n"));
+ return 100;
+ break;
}
}
*/
int sciSetCallbackMouseEvent(sciPointObj * pthis, int mevent)
{
- switch (sciGetEntityType (pthis))
+ switch (sciGetEntityType (pthis))
{
- case SCI_SUBWIN:
- pSUBWIN_FEATURE(pthis)->callbackevent = mevent;
- break;
- case SCI_ARC:
- pARC_FEATURE(pthis)->callbackevent = mevent;
- break;
- case SCI_SEGS:
- pSEGS_FEATURE(pthis)->callbackevent = mevent;
- break;
- case SCI_FEC:
- pFEC_FEATURE(pthis)->callbackevent = mevent;
- break;
- case SCI_GRAYPLOT:
- pGRAYPLOT_FEATURE(pthis)->callbackevent = mevent;
- break;
- case SCI_POLYLINE:
- pPOLYLINE_FEATURE(pthis)->callbackevent = mevent;
- break;
- case SCI_RECTANGLE:
- pRECTANGLE_FEATURE(pthis)->callbackevent = mevent;
- break;
- case SCI_TEXT:
- pTEXT_FEATURE(pthis)->callbackevent = mevent;
- break;
- case SCI_SURFACE:
- pSURFACE_FEATURE(pthis)->callbackevent = mevent;
- break;
- case SCI_AXES:
- pAXES_FEATURE(pthis)->callbackevent = mevent;
- break;
- case SCI_LEGEND:
- case SCI_FIGURE:
- case SCI_AGREG:
- case SCI_UIMENU:
- case SCI_LABEL: /* F.Leray 28.05.04 */
- default:
- Scierror (999, _("No Callback is associated with this Entity.\n"));
- return 100;
- break;
+ case SCI_SUBWIN:
+ pSUBWIN_FEATURE(pthis)->callbackevent = mevent;
+ break;
+ case SCI_ARC:
+ pARC_FEATURE(pthis)->callbackevent = mevent;
+ break;
+ case SCI_SEGS:
+ pSEGS_FEATURE(pthis)->callbackevent = mevent;
+ break;
+ case SCI_FEC:
+ pFEC_FEATURE(pthis)->callbackevent = mevent;
+ break;
+ case SCI_GRAYPLOT:
+ pGRAYPLOT_FEATURE(pthis)->callbackevent = mevent;
+ break;
+ case SCI_POLYLINE:
+ pPOLYLINE_FEATURE(pthis)->callbackevent = mevent;
+ break;
+ case SCI_RECTANGLE:
+ pRECTANGLE_FEATURE(pthis)->callbackevent = mevent;
+ break;
+ case SCI_TEXT:
+ pTEXT_FEATURE(pthis)->callbackevent = mevent;
+ break;
+ case SCI_SURFACE:
+ pSURFACE_FEATURE(pthis)->callbackevent = mevent;
+ break;
+ case SCI_AXES:
+ pAXES_FEATURE(pthis)->callbackevent = mevent;
+ break;
+ case SCI_LEGEND:
+ case SCI_FIGURE:
+ case SCI_AGREG:
+ case SCI_UIMENU:
+ case SCI_LABEL: /* F.Leray 28.05.04 */
+ default:
+ Scierror (999, _("No Callback is associated with this Entity.\n"));
+ return 100;
+ break;
}
- return 100;
+ return 100;
}
int
sciDelCallback (sciPointObj * pthis)
{
- switch (sciGetEntityType (pthis))
+ switch (sciGetEntityType (pthis))
{
- case SCI_SUBWIN:
- pSUBWIN_FEATURE (pthis)->callbacklen = 0;
- pSUBWIN_FEATURE (pthis)->callbackevent = 100;
- FREE(pSUBWIN_FEATURE (pthis)->callback);
- pSUBWIN_FEATURE (pthis)->callback = NULL;
- break;
- case SCI_ARC:
- pARC_FEATURE (pthis)->callbacklen = 0;
- pARC_FEATURE (pthis)->callbackevent = 100;
- FREE(pARC_FEATURE (pthis)->callback);
- pARC_FEATURE (pthis)->callback = NULL;
- break;
- case SCI_RECTANGLE:
- pRECTANGLE_FEATURE (pthis)->callbacklen = 0;
- pRECTANGLE_FEATURE (pthis)->callbackevent = 100;
- FREE(pRECTANGLE_FEATURE (pthis)->callback);
- pRECTANGLE_FEATURE (pthis)->callback = NULL;
- break;
- case SCI_SEGS:
- pSEGS_FEATURE (pthis)->callbacklen = 0;
- pSEGS_FEATURE (pthis)->callbackevent = 100;
- FREE(pSEGS_FEATURE (pthis)->callback);
- pSEGS_FEATURE (pthis)->callback = NULL;
- break;
- case SCI_FEC:
- pFEC_FEATURE (pthis)->callbacklen = 0;
- pFEC_FEATURE (pthis)->callbackevent = 100;
- FREE(pFEC_FEATURE (pthis)->callback);
- pFEC_FEATURE (pthis)->callback = NULL;
- break;
- case SCI_GRAYPLOT:
- pGRAYPLOT_FEATURE (pthis)->callbacklen = 0;
- pGRAYPLOT_FEATURE (pthis)->callbackevent = 100;
- FREE(pGRAYPLOT_FEATURE (pthis)->callback);
- pGRAYPLOT_FEATURE (pthis)->callback = NULL;
- break;
- case SCI_POLYLINE:
- pPOLYLINE_FEATURE (pthis)->callbacklen = 0;
- pPOLYLINE_FEATURE (pthis)->callbackevent = 100;
- FREE(pPOLYLINE_FEATURE (pthis)->callback);
- pPOLYLINE_FEATURE (pthis)->callback = NULL;
- break;
- case SCI_UIMENU:
- case SCI_TEXT:
- case SCI_LEGEND:
- case SCI_SURFACE:
- case SCI_AXES:
- case SCI_FIGURE:
- case SCI_AGREG:
- case SCI_LABEL: /* F.Leray 28.05.04 */
- default:
- Scierror(999, _("No Callback is associated with this Entity.\n"));
- return -1;
- break;
+ case SCI_SUBWIN:
+ pSUBWIN_FEATURE (pthis)->callbacklen = 0;
+ pSUBWIN_FEATURE (pthis)->callbackevent = 100;
+ FREE(pSUBWIN_FEATURE (pthis)->callback);
+ pSUBWIN_FEATURE (pthis)->callback = NULL;
+ break;
+ case SCI_ARC:
+ pARC_FEATURE (pthis)->callbacklen = 0;
+ pARC_FEATURE (pthis)->callbackevent = 100;
+ FREE(pARC_FEATURE (pthis)->callback);
+ pARC_FEATURE (pthis)->callback = NULL;
+ break;
+ case SCI_RECTANGLE:
+ pRECTANGLE_FEATURE (pthis)->callbacklen = 0;
+ pRECTANGLE_FEATURE (pthis)->callbackevent = 100;
+ FREE(pRECTANGLE_FEATURE (pthis)->callback);
+ pRECTANGLE_FEATURE (pthis)->callback = NULL;
+ break;
+ case SCI_SEGS:
+ pSEGS_FEATURE (pthis)->callbacklen = 0;
+ pSEGS_FEATURE (pthis)->callbackevent = 100;
+ FREE(pSEGS_FEATURE (pthis)->callback);
+ pSEGS_FEATURE (pthis)->callback = NULL;
+ break;
+ case SCI_FEC:
+ pFEC_FEATURE (pthis)->callbacklen = 0;
+ pFEC_FEATURE (pthis)->callbackevent = 100;
+ FREE(pFEC_FEATURE (pthis)->callback);
+ pFEC_FEATURE (pthis)->callback = NULL;
+ break;
+ case SCI_GRAYPLOT:
+ pGRAYPLOT_FEATURE (pthis)->callbacklen = 0;
+ pGRAYPLOT_FEATURE (pthis)->callbackevent = 100;
+ FREE(pGRAYPLOT_FEATURE (pthis)->callback);
+ pGRAYPLOT_FEATURE (pthis)->callback = NULL;
+ break;
+ case SCI_POLYLINE:
+ pPOLYLINE_FEATURE (pthis)->callbacklen = 0;
+ pPOLYLINE_FEATURE (pthis)->callbackevent = 100;
+ FREE(pPOLYLINE_FEATURE (pthis)->callback);
+ pPOLYLINE_FEATURE (pthis)->callback = NULL;
+ break;
+ case SCI_UIMENU:
+ case SCI_TEXT:
+ case SCI_LEGEND:
+ case SCI_SURFACE:
+ case SCI_AXES:
+ case SCI_FIGURE:
+ case SCI_AGREG:
+ case SCI_LABEL: /* F.Leray 28.05.04 */
+ default:
+ Scierror(999, _("No Callback is associated with this Entity.\n"));
+ return -1;
+ break;
}
- return 0;
+ return 0;
}
int i;
double x = displacement[0];
double y = displacement[1];
- double z = (displacementSize == 3? displacement[2] : 0.0);
+ double z = (displacementSize == 3 ? displacement[2] : 0.0);
int iNum;
int *piNum = &iNum;
getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_Y__, jni_double_vector, &dataY);
getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_Z__, jni_double_vector, &dataZ);
- for (i = 0; i < iNumVPG*iNum; i++)
+ for (i = 0; i < iNumVPG * iNum; i++)
{
dataX[i] += x;
dataY[i] += y;
}
/* Model data has been updated by direct pointer access, trigger update within the renderer. */
- setGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_Z__, dataZ, jni_double_vector, iNumVPG*iNum);
+ setGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_Z__, dataZ, jni_double_vector, iNumVPG * iNum);
return 0;
}
for (i = 0; i < iNum; i++)
{
- pdblData[3*i] += x;
- pdblData[3*i+1] += y;
- pdblData[3*i+2] += z;
+ pdblData[3 * i] += x;
+ pdblData[3 * i + 1] += y;
+ pdblData[3 * i + 2] += z;
}
- setGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_COORDINATES__, pdblData, jni_double_vector, 3*iNum);
+ setGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_COORDINATES__, pdblData, jni_double_vector, 3 * iNum);
return 0;
}
for (i = 0; i < iNum; i++)
{
- pdblData[3*i] += x;
- pdblData[3*i+1] += y;
- pdblData[3*i+2] += z;
+ pdblData[3 * i] += x;
+ pdblData[3 * i + 1] += y;
+ pdblData[3 * i + 2] += z;
}
for (i = 0; i < iNum; i++)
{
- pdblDirection[3*i] += x;
- pdblDirection[3*i+1] += y;
- pdblDirection[3*i+2] += z;
+ pdblDirection[3 * i] += x;
+ pdblDirection[3 * i + 1] += y;
+ pdblDirection[3 * i + 2] += z;
}
- setGraphicObjectProperty(pobjUID, __GO_BASE__, pdblData, jni_double_vector, 3*iNum);
- setGraphicObjectProperty(pobjUID, __GO_DIRECTION__, pdblDirection, jni_double_vector, 3*iNum);
+ setGraphicObjectProperty(pobjUID, __GO_BASE__, pdblData, jni_double_vector, 3 * iNum);
+ setGraphicObjectProperty(pobjUID, __GO_DIRECTION__, pdblDirection, jni_double_vector, 3 * iNum);
return 0;
}
return 0;
}
-// Default error.
+ // Default error.
Scierror(999, _("This object can not be moved.\n"));
return -1;
-/*
- getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_NUM_X__, jni_int, &piNumX);
- getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_NUM_Y__, jni_int, &piNumY);
+ /*
+ getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_NUM_X__, jni_int, &piNumX);
+ getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_NUM_Y__, jni_int, &piNumY);
- getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_X__, jni_double_vector, &dataX);
- getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_Y__, jni_double_vector, &dataY);
+ getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_X__, jni_double_vector, &dataX);
+ getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_Y__, jni_double_vector, &dataY);
- // X
- for (i = 0 ; i < iNumX ; ++i)
- {
- dataX[i] += x;
- }
- setGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_X__, dataX, jni_double_vector, iNumX);
+ // X
+ for (i = 0 ; i < iNumX ; ++i)
+ {
+ dataX[i] += x;
+ }
+ setGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_X__, dataX, jni_double_vector, iNumX);
- // Y
- for (i = 0 ; i < iNumY ; ++i)
- {
- dataY[i] += y;
- }
- setGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_Y__, dataY, jni_double_vector, iNumY);
+ // Y
+ for (i = 0 ; i < iNumY ; ++i)
+ {
+ dataY[i] += y;
+ }
+ setGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_Y__, dataY, jni_double_vector, iNumY);
- // Z if needed
- if (displacementSize == 3)
- {
- getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_NUM_Z__, jni_int, &piNumZ);
- getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_Z__, jni_double_vector, &dataZ);
- for (i = 0 ; i < iNumZ ; ++i)
+ // Z if needed
+ if (displacementSize == 3)
{
- dataZ[i] += z;
+ getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_NUM_Z__, jni_int, &piNumZ);
+ getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_Z__, jni_double_vector, &dataZ);
+ for (i = 0 ; i < iNumZ ; ++i)
+ {
+ dataZ[i] += z;
+ }
}
- }
- return 0;
-*/
+ return 0;
+ */
#if 0
- switch (sciGetEntityType (pobj))
- {
- case SCI_SUBWIN:
- {
- sciSons * psonstmp = sciGetSons(pobj);
- while ((psonstmp != NULL) && (psonstmp->pointobj != NULL))
- {
- moveObj(psonstmp->pointobj, displacement, displacementSize);
- psonstmp = psonstmp->pnext;
- }
- }
- break;
- case SCI_ARC:
- pARC_FEATURE(pobj)->x +=x;
- pARC_FEATURE(pobj)->y += y;
- if (displacementSize == 3) pARC_FEATURE(pobj)->z += z;
- break;
- case SCI_RECTANGLE:
- pRECTANGLE_FEATURE(pobj)->x += x;
- pRECTANGLE_FEATURE(pobj)->y += y;
- if (displacementSize == 3) pRECTANGLE_FEATURE(pobj)->z += z;
- break;
- case SCI_AGREG:
+ switch (sciGetEntityType (pobj))
{
- sciSons * psonstmp = sciGetSons(pobj);
- while ((psonstmp != NULL) && (psonstmp->pointobj != NULL))
- {
- moveObj(psonstmp->pointobj, displacement, displacementSize);
- psonstmp = psonstmp->pnext;
- }
- }
- break;
- case SCI_TEXT:
- pTEXT_FEATURE(pobj)->x += x;
- pTEXT_FEATURE(pobj)->y += y;
- if (displacementSize == 3) pTEXT_FEATURE(pobj)->z += z;
- break;
- case SCI_SEGS:
- n=pSEGS_FEATURE(pobj)->Nbr1;
- for (i=0;i<n;i++) {
- pSEGS_FEATURE(pobj)->vx[i] += x;
- pSEGS_FEATURE(pobj)->vy[i] += y;
- }
- if (displacementSize == 3)
- {
- if (pSEGS_FEATURE(pobj)->vz == (double *)NULL)
+ case SCI_SUBWIN:
{
- if ((pSEGS_FEATURE(pobj)->vz = MALLOC (n * sizeof (double)))==NULL)
+ sciSons * psonstmp = sciGetSons(pobj);
+ while ((psonstmp != NULL) && (psonstmp->pointobj != NULL))
{
- return -1;
+ moveObj(psonstmp->pointobj, displacement, displacementSize);
+ psonstmp = psonstmp->pnext;
}
- for (i=0;i<n;i++)
+ }
+ break;
+ case SCI_ARC:
+ pARC_FEATURE(pobj)->x += x;
+ pARC_FEATURE(pobj)->y += y;
+ if (displacementSize == 3) pARC_FEATURE(pobj)->z += z;
+ break;
+ case SCI_RECTANGLE:
+ pRECTANGLE_FEATURE(pobj)->x += x;
+ pRECTANGLE_FEATURE(pobj)->y += y;
+ if (displacementSize == 3) pRECTANGLE_FEATURE(pobj)->z += z;
+ break;
+ case SCI_AGREG:
+ {
+ sciSons * psonstmp = sciGetSons(pobj);
+ while ((psonstmp != NULL) && (psonstmp->pointobj != NULL))
{
- pSEGS_FEATURE(pobj)->vz[i] = z;
+ moveObj(psonstmp->pointobj, displacement, displacementSize);
+ psonstmp = psonstmp->pnext;
}
}
- else
- for (i=0;i<n;i++)
+ break;
+ case SCI_TEXT:
+ pTEXT_FEATURE(pobj)->x += x;
+ pTEXT_FEATURE(pobj)->y += y;
+ if (displacementSize == 3) pTEXT_FEATURE(pobj)->z += z;
+ break;
+ case SCI_SEGS:
+ n = pSEGS_FEATURE(pobj)->Nbr1;
+ for (i = 0; i < n; i++)
{
- pSEGS_FEATURE(pobj)->vz[i] += z;
+ pSEGS_FEATURE(pobj)->vx[i] += x;
+ pSEGS_FEATURE(pobj)->vy[i] += y;
}
- }
- break;
- case SCI_POLYLINE:
- n=pPOLYLINE_FEATURE(pobj)->n1;
- for (i=0;i<n;i++)
- {
- pPOLYLINE_FEATURE(pobj)->pvx[i] += x;
- pPOLYLINE_FEATURE(pobj)->pvy[i] += y;
- }
- if (displacementSize == 3)
- {
- if (pPOLYLINE_FEATURE(pobj)->pvz == (double *)NULL)
- {
- if ((pPOLYLINE_FEATURE(pobj)->pvz = MALLOC (n * sizeof (double)))==NULL)
- {
- return -1;
- }
- for (i=0;i<n;i++)
- {
- pPOLYLINE_FEATURE(pobj)->pvz[i] = z;
- }
- }
- else
- {
- for (i=0;i<n;i++)
- {
- pPOLYLINE_FEATURE(pobj)->pvz[i] += z;
- }
- }
- }
- break;
- case SCI_FEC:
- for (i=0;i<pFEC_FEATURE(pobj)->Nnode;i++)
- {
- pFEC_FEATURE(pobj)->pvecx[i] += x;
- pFEC_FEATURE(pobj)->pvecy[i] += y;
- }
- break;
- case SCI_GRAYPLOT:
- if (pGRAYPLOT_FEATURE(pobj)->type == 2)
- {
- /* Matplot 1, it is not possible to move a Matplot*/
- pGRAYPLOT_FEATURE(pobj)->pvecx[0] += x;
- pGRAYPLOT_FEATURE(pobj)->pvecx[2] += x;
- pGRAYPLOT_FEATURE(pobj)->pvecx[1] += y;
- pGRAYPLOT_FEATURE(pobj)->pvecx[3] += y;
- }
- else if (pGRAYPLOT_FEATURE(pobj)->type == 0)
- {
- /* Grayplot */
- for (i=0;i<pGRAYPLOT_FEATURE(pobj)->nx;i++)
- {
- pGRAYPLOT_FEATURE(pobj)->pvecx[i] += x;
- }
- for (i=0;i<pGRAYPLOT_FEATURE(pobj)->ny;i++)
- {
- pGRAYPLOT_FEATURE(pobj)->pvecy[i] += y;
- }
- }
- else
- {
- Scierror(999, _("This object can not be moved.\n"));
- return -1;
- }
-
- break;
- case SCI_SURFACE:
- switch(pSURFACE_FEATURE (pobj)->typeof3d)
- {
- case SCI_FAC3D:
- n= pSURFACE_FEATURE (pobj)->dimzx* pSURFACE_FEATURE (pobj)->dimzy;
- for (i=0;i<n;i++) {
- pSURFACE_FEATURE(pobj)->pvecx[i] += x;
- pSURFACE_FEATURE(pobj)->pvecy[i] += y;
- }
- if (displacementSize == 3) {
- if (pSURFACE_FEATURE(pobj)->pvecz == (double *)NULL) {
- if ((pSURFACE_FEATURE(pobj)->pvecz = MALLOC (n * sizeof (double)))==NULL) return -1;
- for (i=0;i<n;i++)
- pSURFACE_FEATURE(pobj)->pvecz[i] = z;
- }
- else
- for (i=0;i<n;i++)
- pSURFACE_FEATURE(pobj)->pvecz[i] += z;
- }
- break;
- case SCI_PLOT3D:
- for (i=0;i<pSURFACE_FEATURE (pobj)->dimzx;i++)
- pSURFACE_FEATURE(pobj)->pvecx[i] += x;
- for (i=0;i<pSURFACE_FEATURE (pobj)->dimzy;i++)
- pGRAYPLOT_FEATURE(pobj)->pvecy[i] += y;
- if (displacementSize == 3) {
- n=pSURFACE_FEATURE (pobj)->dimzx*pSURFACE_FEATURE (pobj)->dimzy;
- if (pSURFACE_FEATURE(pobj)->pvecz == (double *)NULL) {
- if ((pSURFACE_FEATURE(pobj)->pvecz = MALLOC (n * sizeof (double)))==NULL) return -1;
- for (i=0;i<n;i++)
- pSURFACE_FEATURE(pobj)->pvecz[i] = z;
+ if (displacementSize == 3)
+ {
+ if (pSEGS_FEATURE(pobj)->vz == (double *)NULL)
+ {
+ if ((pSEGS_FEATURE(pobj)->vz = MALLOC (n * sizeof (double))) == NULL)
+ {
+ return -1;
+ }
+ for (i = 0; i < n; i++)
+ {
+ pSEGS_FEATURE(pobj)->vz[i] = z;
+ }
+ }
+ else
+ for (i = 0; i < n; i++)
+ {
+ pSEGS_FEATURE(pobj)->vz[i] += z;
+ }
+ }
+ break;
+ case SCI_POLYLINE:
+ n = pPOLYLINE_FEATURE(pobj)->n1;
+ for (i = 0; i < n; i++)
+ {
+ pPOLYLINE_FEATURE(pobj)->pvx[i] += x;
+ pPOLYLINE_FEATURE(pobj)->pvy[i] += y;
+ }
+ if (displacementSize == 3)
+ {
+ if (pPOLYLINE_FEATURE(pobj)->pvz == (double *)NULL)
+ {
+ if ((pPOLYLINE_FEATURE(pobj)->pvz = MALLOC (n * sizeof (double))) == NULL)
+ {
+ return -1;
+ }
+ for (i = 0; i < n; i++)
+ {
+ pPOLYLINE_FEATURE(pobj)->pvz[i] = z;
+ }
+ }
+ else
+ {
+ for (i = 0; i < n; i++)
+ {
+ pPOLYLINE_FEATURE(pobj)->pvz[i] += z;
+ }
+ }
+ }
+ break;
+ case SCI_FEC:
+ for (i = 0; i < pFEC_FEATURE(pobj)->Nnode; i++)
+ {
+ pFEC_FEATURE(pobj)->pvecx[i] += x;
+ pFEC_FEATURE(pobj)->pvecy[i] += y;
+ }
+ break;
+ case SCI_GRAYPLOT:
+ if (pGRAYPLOT_FEATURE(pobj)->type == 2)
+ {
+ /* Matplot 1, it is not possible to move a Matplot*/
+ pGRAYPLOT_FEATURE(pobj)->pvecx[0] += x;
+ pGRAYPLOT_FEATURE(pobj)->pvecx[2] += x;
+ pGRAYPLOT_FEATURE(pobj)->pvecx[1] += y;
+ pGRAYPLOT_FEATURE(pobj)->pvecx[3] += y;
+ }
+ else if (pGRAYPLOT_FEATURE(pobj)->type == 0)
+ {
+ /* Grayplot */
+ for (i = 0; i < pGRAYPLOT_FEATURE(pobj)->nx; i++)
+ {
+ pGRAYPLOT_FEATURE(pobj)->pvecx[i] += x;
+ }
+ for (i = 0; i < pGRAYPLOT_FEATURE(pobj)->ny; i++)
+ {
+ pGRAYPLOT_FEATURE(pobj)->pvecy[i] += y;
+ }
+ }
+ else
+ {
+ Scierror(999, _("This object can not be moved.\n"));
+ return -1;
+ }
+
+ break;
+ case SCI_SURFACE:
+ switch (pSURFACE_FEATURE (pobj)->typeof3d)
+ {
+ case SCI_FAC3D:
+ n = pSURFACE_FEATURE (pobj)->dimzx * pSURFACE_FEATURE (pobj)->dimzy;
+ for (i = 0; i < n; i++)
+ {
+ pSURFACE_FEATURE(pobj)->pvecx[i] += x;
+ pSURFACE_FEATURE(pobj)->pvecy[i] += y;
+ }
+ if (displacementSize == 3)
+ {
+ if (pSURFACE_FEATURE(pobj)->pvecz == (double *)NULL)
+ {
+ if ((pSURFACE_FEATURE(pobj)->pvecz = MALLOC (n * sizeof (double))) == NULL) return -1;
+ for (i = 0; i < n; i++)
+ pSURFACE_FEATURE(pobj)->pvecz[i] = z;
+ }
+ else
+ for (i = 0; i < n; i++)
+ pSURFACE_FEATURE(pobj)->pvecz[i] += z;
+ }
+ break;
+ case SCI_PLOT3D:
+ for (i = 0; i < pSURFACE_FEATURE (pobj)->dimzx; i++)
+ pSURFACE_FEATURE(pobj)->pvecx[i] += x;
+ for (i = 0; i < pSURFACE_FEATURE (pobj)->dimzy; i++)
+ pGRAYPLOT_FEATURE(pobj)->pvecy[i] += y;
+ if (displacementSize == 3)
+ {
+ n = pSURFACE_FEATURE (pobj)->dimzx * pSURFACE_FEATURE (pobj)->dimzy;
+ if (pSURFACE_FEATURE(pobj)->pvecz == (double *)NULL)
+ {
+ if ((pSURFACE_FEATURE(pobj)->pvecz = MALLOC (n * sizeof (double))) == NULL) return -1;
+ for (i = 0; i < n; i++)
+ pSURFACE_FEATURE(pobj)->pvecz[i] = z;
+ }
+ else
+ for (i = 0; i < n; i++)
+ pSURFACE_FEATURE(pobj)->pvecz[i] += z;
+ }
+ break;
+ case SCI_CONTOUR:
+ case SCI_PARAM3D:
+ case SCI_PARAM3D1: /* Nothing to be done */
+ break;
+ }
+ break;
+ case SCI_LABEL:
+ {
+ double pos[3];
+ sciGetTextPos(pobj, pos) ;
+ sciSetTextPos(pobj, pos[0] + x, pos[1] + y, pos[2] + z) ;
+ pLABEL_FEATURE(pobj)->auto_position = FALSE;
+ break;
}
- else
- for (i=0;i<n;i++)
- pSURFACE_FEATURE(pobj)->pvecz[i] += z;
- }
- break;
- case SCI_CONTOUR:
- case SCI_PARAM3D:
- case SCI_PARAM3D1: /* Nothing to be done */
- break;
- }
- break;
- case SCI_LABEL:
- {
- double pos[3];
- sciGetTextPos(pobj, pos) ;
- sciSetTextPos(pobj, pos[0] + x, pos[1] + y, pos[2] + z) ;
- pLABEL_FEATURE(pobj)->auto_position = FALSE;
- break;
+ case SCI_FIGURE:
+ case SCI_AXES:
+ case SCI_LEGEND:
+ case SCI_UIMENU:
+ default:
+ Scierror(999, _("This object can not be moved.\n"));
+ return -1;
+ break;
}
- case SCI_FIGURE:
- case SCI_AXES:
- case SCI_LEGEND:
- case SCI_UIMENU:
- default:
- Scierror(999, _("This object can not be moved.\n"));
- return -1;
- break;
- }
- /* update the object */
- forceMove(pobjUID, x, y, z);
+ /* update the object */
+ forceMove(pobjUID, x, y, z);
#endif
- return 0;
+ return 0;
}
-int Objmove (char *pobjUID, double d[], int m,BOOL opt)
+int Objmove (char *pobjUID, double d[], int m, BOOL opt)
{
int status = moveObj(pobjUID, d, m);
#if 0
- if (status < 0)
- {
- return status;
- }
+ if (status < 0)
+ {
+ return status;
+ }
if (opt)
{
}
/*---------------------------------------------------------------------------------*/
-void pixelRubberBox(sciPointObj * pFigure, BOOL isClick,
- const int initialRect[4], int endRect[4], int * usedButton)
-{
- javaRubberBox(pFigure, isClick, initialRect, endRect, usedButton);
-}
-/*---------------------------------------------------------------------------------*/
-void rubberBox(sciPointObj * pSubwin, BOOL isClick,
- const double initialRect[4], double endRect[4], int * usedButton)
-{
- int endPixelRect[4];
- double endFirstCorner[2];
- double endSecondCorner[2];
-
- /* get up to date coordinates */
- updateSubwinScale((char*)pSubwin);
-
- /* convert initial rect in */
-
- if (initialRect != NULL)
- {
- int initialPixelRect[4];
-
- /* Convert initial rect in pixels */
- double firstCorner[2];
- double secondCorner[2];
- firstCorner[0] = initialRect[0];
- firstCorner[1] = initialRect[1]; /* upper left point */
- secondCorner[0] = initialRect[0] + initialRect[2];
- secondCorner[1] = initialRect[1] - initialRect[3];
- sciGet2dViewPixelCoordinates((char*)pSubwin, firstCorner, initialPixelRect);
- sciGet2dViewPixelCoordinates((char*)pSubwin, secondCorner, initialPixelRect + 2);
-
- pixelRubberBox(sciGetParentFigure(pSubwin), isClick, initialPixelRect, endPixelRect, usedButton);
- }
- else
- {
- pixelRubberBox(sciGetParentFigure(pSubwin), isClick, NULL, endPixelRect, usedButton);
- }
-
- /* here we get the two opposite points of the rectangle in pixels */
- /* convert them in user coordinates */
- sciGet2dViewCoordFromPixel((char*)pSubwin, endPixelRect, endFirstCorner);
- sciGet2dViewCoordFromPixel((char*)pSubwin, endPixelRect + 2, endSecondCorner);
-
- /* [x,y,w,h] array where (x,y) is the upper left point of the rectangle */
- endRect[0] = Min(endFirstCorner[0], endSecondCorner[0]);
- endRect[1] = Max(endFirstCorner[1], endSecondCorner[1]);
- endRect[2] = Abs(endFirstCorner[0] - endSecondCorner[0]);
- endRect[3] = Abs(endFirstCorner[1] - endSecondCorner[1]);
-
-}
-/*---------------------------------------------------------------------------------*/
void interactiveZoom(sciPointObj * pObj)
{
- if (sciGetEntityType(pObj) == SCI_FIGURE)
- {
- interactiveJavaZoom(pObj);
- }
- else if (sciGetEntityType(pObj) == SCI_SUBWIN)
- {
- interactiveJavaSubwinZoom(pObj);
- }
+ if (sciGetEntityType(pObj) == SCI_FIGURE)
+ {
+ interactiveJavaZoom(pObj);
+ }
+ else if (sciGetEntityType(pObj) == SCI_SUBWIN)
+ {
+ interactiveJavaSubwinZoom(pObj);
+ }
}
/*---------------------------------------------------------------------------------*/
void interactiveRotation(sciPointObj * pFigure)
{
- interactiveJavaRotation(pFigure);
+ interactiveJavaRotation(pFigure);
}
/*---------------------------------------------------------------------------------*/
void interactiveSubwinRotation(sciPointObj * pSubwin)
{
- /* get coordinates of first mouse click */
- interactiveJavaSubwinRotation(pSubwin);
+ /* get coordinates of first mouse click */
+ interactiveJavaSubwinRotation(pSubwin);
}
/*---------------------------------------------------------------------------------*/
void showWindow(char * pFigureUID)
/**
* Call rubber box on a figure
- * @param pFigure figure on which to apply the rubber box
- * @param isClick specify whether the rubber box is selected by mouse click
- * or a sequence of press/release.
+ * @param pstObjUID figure UID on which to apply the rubber box
* @param intialRect if not null, specify the initial rectangle to use
- * @param[out] endRect array containing the coordinates of two opposite corners of
- * the rubber box
- * @param[out] usedButton Scilab code of the button used to terminate the rubber box
+ * @return [usedButton x y z l L h]
*/
-RENDERER_IMPEXP void javaRubberBox(sciPointObj * pFigure, BOOL isClick, const int initialRect[4], int endRect[4], int * usedButton);
+RENDERER_IMPEXP double *javaClickRubberBox(char *pstObjUID, double *initialRect, int iRectSize);
+ RENDERER_IMPEXP double *javaDragRubberBox(char *pstObjUID);
/**
* Perform an interactive zoom of the figure using a rectangular selection.
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2007 - INRIA - Jean-Baptiste Silvy
+ * Copyright (C) 2012 - Scilab Enterprises - Bruno JOFRET
*
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
}
/*---------------------------------------------------------------------------------*/
-void javaRubberBox(sciPointObj * pFigure, BOOL isClick, const int initialRect[4], int endRect[4], int * usedButton)
+double *javaClickRubberBox(char *pstObjUID, double *initialRect, int iRectSize)
{
- //getFigureDrawer(pFigure)->rubberBox((isClick == TRUE), initialRect, endRect, usedButton);
+ return org_scilab_modules_renderer::CallRenderer::clickRubberBox(getScilabJavaVM(), pstObjUID, initialRect, iRectSize);
}
+
+/*---------------------------------------------------------------------------------*/
+double *javaDragRubberBox(char *pstObjUID)
+{
+ return org_scilab_modules_renderer::CallRenderer::dragRubberBox(getScilabJavaVM(), pstObjUID);
+}
+
+
/*---------------------------------------------------------------------------------*/
void interactiveJavaZoom(sciPointObj * pFigure)
{
visitor.getInteractionManager().startInteractiveZoom();
}
}
-
+
+ public static double[] clickRubberBox(String id, double initialRect[]) {
+ DrawerVisitor visitor = DrawerVisitor.getVisitor(id);
+ if (visitor != null) {
+ return visitor.getInteractionManager().startClickRubberBox(initialRect);
+ }
+ return new double[] {-1,-1,-1,-1,-1,-1,-1};
+ }
+
+ public static double[] dragRubberBox(String id) {
+ DrawerVisitor visitor = DrawerVisitor.getVisitor(id);
+ if (visitor != null) {
+ return visitor.getInteractionManager().startDragRubberBox();
+ }
+ return new double[] {-1,-1,-1,-1,-1,-1,-1};
+ }
/**
* Updates the coordinate transformation of the Axes object given by the identifier.
* @param id the Axes' identifier.
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Bruno JOFRET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ */
+
+package org.scilab.modules.renderer.JoGLView.interaction;
+
+import java.awt.event.MouseEvent;
+
+import org.scilab.modules.renderer.JoGLView.DrawerVisitor;
+
+/**
+ * @author Bruno JOFRET
+ */
+public class DragPointRubberBox extends TwoPointsRubberBox {
+
+ /**
+ * Default constructor.
+ *
+ * @param drawerVisitor parent drawer visitor.
+ */
+ public DragPointRubberBox(DrawerVisitor drawerVisitor) {
+ super(drawerVisitor);
+ }
+
+ @Override
+ public final void mouseClicked(MouseEvent e) {
+
+ }
+ @Override
+ public void mousePressed(MouseEvent e) {
+ mouseButton = e.getButton();
+ switch (status) {
+ case WAIT_POINT_A:
+ if (setPointA(e.getPoint())) {
+ status = Status.WAIT_POINT_B;
+ } else {
+ setEnable(false);
+ fireRubberBoxEnd();
+ }
+ break;
+ case WAIT_POINT_B:
+ setPointB(e.getPoint());
+ if (pointBComputer.is2D()) {
+ process();
+ setEnable(false);
+ fireRubberBoxEnd();
+ } else {
+ status = Status.WAIT_POINT_C;
+ }
+ break;
+ case WAIT_POINT_C:
+ setPointC(e.getPoint());
+ status = Status.WAIT_POINT_D;
+ break;
+ case WAIT_POINT_D:
+ setPointD(e.getPoint());
+ process();
+ setEnable(false);
+ fireRubberBoxEnd();
+ break;
+ default:
+ }
+ updateInfoMessage();
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ mouseButton = e.getButton();
+ switch (status) {
+ case WAIT_POINT_A:
+ if (setPointA(e.getPoint())) {
+ status = Status.WAIT_POINT_B;
+ } else {
+ setEnable(false);
+ fireRubberBoxEnd();
+ }
+ break;
+ case WAIT_POINT_B:
+ setPointB(e.getPoint());
+ if (pointBComputer.is2D()) {
+ process();
+ setEnable(false);
+ fireRubberBoxEnd();
+ } else {
+ status = Status.WAIT_POINT_C;
+ }
+ break;
+ case WAIT_POINT_C:
+ setPointC(e.getPoint());
+ status = Status.WAIT_POINT_D;
+ break;
+ case WAIT_POINT_D:
+ setPointD(e.getPoint());
+ process();
+ setEnable(false);
+ fireRubberBoxEnd();
+ break;
+ default:
+ }
+ updateInfoMessage();
+ }
+
+ @Override
+ public final void mouseDragged(MouseEvent e) {
+ switch (status) {
+ case WAIT_POINT_A:
+ setPointA(e.getPoint());
+ getDrawerVisitor().getCanvas().redraw();
+ break;
+ case WAIT_POINT_B:
+ setPointB(e.getPoint());
+ getDrawerVisitor().getCanvas().redraw();
+ break;
+ case WAIT_POINT_C:
+ setPointC(e.getPoint());
+ getDrawerVisitor().getCanvas().redraw();
+ break;
+ case WAIT_POINT_D:
+ setPointD(e.getPoint());
+ getDrawerVisitor().getCanvas().redraw();
+ break;
+ default:
+ }
+ updateInfoMessage();
+ }
+
+
+}
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2009-2010 - DIGITEO - Pierre Lando
+ * Copyright (C) 2012 - Scilab Enterprises - Bruno JOFRET
*
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
package org.scilab.modules.renderer.JoGLView.interaction;
+import org.scilab.modules.commons.utils.BlockingResult;
import org.scilab.modules.renderer.JoGLView.DrawerVisitor;
/**
private RubberBox rubberBox;
/** The drag, zoom, rotate interaction manager */
- DragZoomRotateInteraction dragZoomRotateInteraction;
+ private final DragZoomRotateInteraction dragZoomRotateInteraction;
+
+ /** Parent drawer visitor */
+ private DrawerVisitor drawerVisitor;
/**
* Default constructor.
* @param drawerVisitor parent drawer visitor.
*/
public InteractionManager(DrawerVisitor drawerVisitor) {
+ this.drawerVisitor = drawerVisitor;
dragZoomRotateInteraction = new DragZoomRotateInteraction(drawerVisitor);
dragZoomRotateInteraction.setEnable(true);
-
- rubberBox = new RubberBox(drawerVisitor);
- rubberBox.addListener(this);
- drawerVisitor.addPostRendering(rubberBox);
}
/**
* @exception Throwable the <code>Exception</code> raised by this method
*/
public void finalize() throws Throwable {
- rubberBox.removeListener(this);
+ if (rubberBox != null) {
+ rubberBox.removeListener(this);
+ }
super.finalize();
}
* Called to start zooming.
*/
public void startInteractiveZoom() {
+ final ZoomRubberBox rubberBox = new ZoomRubberBox(drawerVisitor);
+ dragZoomRotateInteraction.setEnable(false);
+
+ rubberBox.addListener(new RubberBoxListener() {
+ public void rubberBoxEnd() {
+ dragZoomRotateInteraction.setEnable(true);
+ drawerVisitor.removePostRendering(rubberBox);
+ }
+ });
+ drawerVisitor.addPostRendering(rubberBox);
+ rubberBox.setEnable(true);
+ }
+
+ public double[] startClickRubberBox(double initialRect[]) {
+ final BlockingResult<double []> result = new BlockingResult<double[]>();
+ final PointRubberBox rubberBox;
+ if (initialRect.length == 0) {
+ rubberBox = new TwoPointsRubberBox(drawerVisitor);
+ } else {
+ rubberBox = new OnePointRubberBox(drawerVisitor, initialRect);
+ }
+
dragZoomRotateInteraction.setEnable(false);
+ rubberBox.addListener(new RubberBoxListener() {
+ @Override
+ public void rubberBoxEnd() {
+ result.setResult(rubberBox.getResults());
+ dragZoomRotateInteraction.setEnable(true);
+ drawerVisitor.removePostRendering(rubberBox);
+ }
+ });
+ drawerVisitor.addPostRendering(rubberBox);
rubberBox.setEnable(true);
+ return result.getResult();
}
+
+ public double[] startDragRubberBox() {
+ final BlockingResult<double []> result = new BlockingResult<double []>();
+ final DragPointRubberBox rubberBox = new DragPointRubberBox(drawerVisitor);
+ dragZoomRotateInteraction.setEnable(false);
+ rubberBox.addListener(new RubberBoxListener() {
+ @Override
+ public void rubberBoxEnd() {
+ result.setResult(rubberBox.getResults());
+ dragZoomRotateInteraction.setEnable(true);
+ drawerVisitor.removePostRendering(rubberBox);
+ }
+ });
+ drawerVisitor.addPostRendering(rubberBox);
+ rubberBox.setEnable(true);
+ return result.getResult();
+ }
+
@Override
public void rubberBoxEnd() {
dragZoomRotateInteraction.setEnable(true);
+ rubberBox = null;
}
}
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Bruno JOFRET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ */
+
+package org.scilab.modules.renderer.JoGLView.interaction;
+
+import java.awt.Point;
+import java.awt.event.MouseEvent;
+
+import org.scilab.forge.scirenderer.tranformations.Vector3d;
+import org.scilab.modules.renderer.JoGLView.DrawerVisitor;
+import org.scilab.modules.renderer.JoGLView.interaction.util.PointAComputer;
+
+/**
+ * @author Bruno JOFRET
+ */
+public class OnePointRubberBox extends RubberBox implements PointRubberBox {
+
+ /**
+ * Default constructor.
+ *
+ * @param drawerVisitor parent drawer visitor.
+ */
+ public OnePointRubberBox(DrawerVisitor drawerVisitor) {
+ super(drawerVisitor);
+ }
+
+ public OnePointRubberBox(DrawerVisitor drawerVisitor, double initialRect[]) {
+ super(drawerVisitor);
+ firstPoint = new Vector3d(initialRect[0], initialRect[1], 0);
+ secondPoint = firstPoint;
+ status = Status.WAIT_POINT_B;
+ setEnable(true);
+ }
+
+ public double[] getResults() {
+ double result[] = {
+ mouseButton - 1,
+ Math.min(firstPoint.getX(), secondPoint.getX()),
+ Math.max(firstPoint.getY(), secondPoint.getY()),
+ Math.max(firstPoint.getZ(), secondPoint.getZ()),
+ Math.abs(firstPoint.getX() - secondPoint.getX()),
+ Math.abs(firstPoint.getY() - secondPoint.getY()),
+ Math.abs(firstPoint.getZ() - secondPoint.getZ())
+ };
+
+ return result;
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ mouseButton = e.getButton();
+ setPointB(e.getPoint());
+ process();
+ setEnable(false);
+ fireRubberBoxEnd();
+ }
+
+ /**
+ * Set the first point.
+ * @param point first point AWT coordinate.
+ * @return true if the first point is valid.
+ */
+ protected boolean setPointB(Point point) {
+ axes = getUnderlyingAxes(point);
+ if (axes != null) {
+ PointAComputer pointComputer = new PointAComputer(axes, point);
+ if (pointComputer.isValid()) {
+ pointBComputer = pointComputer;
+ secondPoint = pointComputer.getPosition();
+ return true;
+ }
+ }
+ return false;
+ }
+}
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Bruno JOFRET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ */
+
+package org.scilab.modules.renderer.JoGLView.interaction;
+
+import org.scilab.modules.renderer.JoGLView.postRendering.PostRendered;
+
+public interface PointRubberBox extends PostRendered {
+
+ public double[] getResults();
+
+ public void addListener(RubberBoxListener listener);
+
+ public void setEnable(boolean enabled);
+
+}
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2009-2010 - DIGITEO - Pierre Lando
+ * Copyright (C) 2012 - Scilab Enterprises - Bruno JOFRET
*
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
package org.scilab.modules.renderer.JoGLView.interaction;
+import java.awt.Component;
+import java.awt.Point;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.text.DecimalFormat;
+
+import javax.swing.event.EventListenerList;
+
import org.scilab.forge.scirenderer.DrawingTools;
import org.scilab.forge.scirenderer.SciRendererException;
import org.scilab.forge.scirenderer.buffers.BuffersManager;
import org.scilab.modules.renderer.JoGLView.interaction.util.PointDComputer;
import org.scilab.modules.renderer.JoGLView.postRendering.PostRendered;
-import javax.swing.event.EventListenerList;
-import java.awt.Component;
-import java.awt.Point;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseMotionListener;
-import java.text.DecimalFormat;
-
/**
* @author Pierre Lando
*/
/** Rubber box status */
public static enum Status {
WAIT_POINT_A,
- WAIT_POINT_B,
- WAIT_POINT_C,
- WAIT_POINT_D,
- }
+ WAIT_POINT_B,
+ WAIT_POINT_C,
+ WAIT_POINT_D,
+ }
/** Rubber box color */
private static final Color RUBBER_BOX_COLOR = new Color(.2f, .3f, .4f);
/** Rubber box pattern */
private static final short RUBBER_BOX_PATTERN = (short) 0xFAFA;
- /** The mouse button used to perform a rubber box */
- private static final int MOUSE_MODIFIER = MouseEvent.BUTTON1_MASK;
-
- /** This key stop the rubber box */
- private static final int STOP_KEY = KeyEvent.VK_ESCAPE;
-
/** Helpers appearance */
private static Appearance helpersAppearance;
private DefaultGeometry cubeGeometry;
/** Current status */
- private Status status;
+ protected Status status;
+
+ protected Axes axes;
- private Axes axes;
+ private PointComputer pointAComputer;
+ protected PointComputer pointBComputer;
+ private PointComputer pointCComputer;
+ private PointComputer pointDComputer;
+ protected Vector3d firstPoint;
+ protected Vector3d secondPoint;
- private PointAComputer pointAComputer;
- private PointBComputer pointBComputer;
- private PointCComputer pointCComputer;
- private PointDComputer pointDComputer;
- private Vector3d firstPoint;
- private Vector3d secondPoint;
+ protected int mouseButton;
/**
* Default constructor.
*
* @param drawerVisitor parent drawer visitor.
*/
- public RubberBox(DrawerVisitor drawerVisitor) {
+ protected RubberBox(DrawerVisitor drawerVisitor) {
super(drawerVisitor);
status = Status.WAIT_POINT_A;
}
/**
* Notify all listener that the rubber box have ended
*/
- private void fireRubberBoxEnd() {
+ protected void fireRubberBoxEnd() {
for (RubberBoxListener rubberBoxListener : listenerList.getListeners(RubberBoxListener.class)) {
rubberBoxListener.rubberBoxEnd();
}
if (isEnable() && (axes != null)) {
drawingTools.getTransformationManager().useSceneCoordinate();
drawingTools.getTransformationManager().getModelViewStack().push(
- getDrawerVisitor().getAxesDrawer().getSceneProjection(axes.getIdentifier())
- );
+ getDrawerVisitor().getAxesDrawer().getSceneProjection(axes.getIdentifier())
+ );
if (status != Status.WAIT_POINT_A) {
drawingTools.draw(getCubeGeometry(drawingTools), getCubeAppearance());
public final void changeEnable(boolean isEnable) {
Component component = getDrawerVisitor().getComponent();
if (isEnable) {
- status = Status.WAIT_POINT_A;
+ //status = Status.WAIT_POINT_A;
pointAComputer = null;
component.addMouseListener(this);
component.addMouseMotionListener(this);
@Override
public final void keyTyped(KeyEvent e) {
- if (e.getKeyChar() == STOP_KEY) {
+ if (e.getKeyChar() == KeyEvent.VK_ESCAPE) {
+ mouseButton = -1;
setEnable(false);
fireRubberBoxEnd();
}
}
@Override
- public final void mouseClicked(MouseEvent e) {
- if (e.getModifiers() == MOUSE_MODIFIER) {
- switch (status) {
- case WAIT_POINT_A:
- if (setPointA(e.getPoint())) {
- status = Status.WAIT_POINT_B;
- } else {
- setEnable(false);
- fireRubberBoxEnd();
- }
- break;
- case WAIT_POINT_B:
- setPointB(e.getPoint());
- if (pointBComputer.is2D()) {
- setZoomBox();
- setEnable(false);
- fireRubberBoxEnd();
- } else {
- status = Status.WAIT_POINT_C;
- }
- break;
- case WAIT_POINT_C:
- setPointC(e.getPoint());
- status = Status.WAIT_POINT_D;
- break;
- case WAIT_POINT_D:
- setPointD(e.getPoint());
- setZoomBox();
+ public void mouseClicked(MouseEvent e) {
+ mouseButton = e.getButton();
+ switch (status) {
+ case WAIT_POINT_A:
+ if (setPointA(e.getPoint())) {
+ status = Status.WAIT_POINT_B;
+ } else {
setEnable(false);
fireRubberBoxEnd();
- break;
- default:
}
- updateInfoMessage();
+ break;
+ case WAIT_POINT_B:
+ setPointB(e.getPoint());
+ if (pointBComputer.is2D()) {
+ process();
+ setEnable(false);
+ fireRubberBoxEnd();
+ } else {
+ status = Status.WAIT_POINT_C;
+ }
+ break;
+ case WAIT_POINT_C:
+ setPointC(e.getPoint());
+ status = Status.WAIT_POINT_D;
+ break;
+ case WAIT_POINT_D:
+ setPointD(e.getPoint());
+ process();
+ setEnable(false);
+ fireRubberBoxEnd();
+ break;
+ default:
}
+ updateInfoMessage();
+
+
}
@Override
/**
* Update displayed info message.
*/
- private void updateInfoMessage() {
+ protected void updateInfoMessage() {
if (isEnable()) {
switch (status) {
case WAIT_POINT_A:
}
} else {
GraphicController.getController().setProperty(
- getDrawerVisitor().getFigure().getIdentifier(),
- GraphicObjectProperties.__GO_INFO_MESSAGE__,
- null
- );
- }
- }
-
- /**
- * Set the info message.
- * @param baseMessage the base of the message.
- * @param pointComputer current used point computer.
- * @param oneAxis true if only one coordinate is currently set.
- */
- private void setInfoMessage(String baseMessage, PointComputer pointComputer, boolean oneAxis) {
- if ((pointComputer != null) && (pointComputer.isValid())) {
- String message = baseMessage + " ";
- double[] data = pointComputer.getSecondPosition().getData();
- String comma;
- if (oneAxis) {
- comma = "";
- } else {
- comma = ", ";
- }
-
- for (int i = 0; i < PointComputer.AXIS_NUMBER; i++) {
- if ((i != pointComputer.getFirstAxisIndex()) ^ oneAxis) {
- message += AXES_NAMES[i] + " = " + DECIMAL_FORMAT.format(data[i]) + comma;
- comma = "";
- }
- }
- GraphicController.getController().setProperty(
- getDrawerVisitor().getFigure().getIdentifier(),
- GraphicObjectProperties.__GO_INFO_MESSAGE__,
- message
- );
- } else {
- String message = "Move your mouse on an axes box.";
- GraphicController.getController().setProperty(
- getDrawerVisitor().getFigure().getIdentifier(),
- GraphicObjectProperties.__GO_INFO_MESSAGE__,
- message
- );
+ getDrawerVisitor().getFigure().getIdentifier(),
+ GraphicObjectProperties.__GO_INFO_MESSAGE__,
+ ""
+ );
}
- }
-
- /**
- * Actually set the zoom box depending on current value of firstPoint and secondPoint.
- */
- private void setZoomBox() {
- Double[] bounds = {
- Math.min(firstPoint.getX(), secondPoint.getX()), Math.max(firstPoint.getX(), secondPoint.getX()),
- Math.min(firstPoint.getY(), secondPoint.getY()), Math.max(firstPoint.getY(), secondPoint.getY()),
- Math.min(firstPoint.getZ(), secondPoint.getZ()), Math.max(firstPoint.getZ(), secondPoint.getZ()),
- };
-
- if (bounds[0].compareTo(bounds[1]) != 0 && bounds[2].compareTo(bounds[3]) != 0 && bounds[4].compareTo(bounds[5]) != 0) {
- Boolean zoomed = tightZoomBounds(axes, bounds);
- GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_ZOOM_BOX__, bounds);
- GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_ZOOM_ENABLED__, zoomed);
- getDrawerVisitor().getCanvas().redraw();
- }
- }
-
- /**
- * Set the first point.
- * @param point first point AWT coordinate.
- * @return true if the first point is valid.
- */
- private boolean setPointA(Point point) {
- axes = getUnderlyingAxes(point);
- if (axes != null) {
- PointAComputer pointComputer = new PointAComputer(axes, point);
- if (pointComputer.isValid()) {
- this.pointAComputer = pointComputer;
- firstPoint = pointComputer.getPosition();
- secondPoint = firstPoint;
- return true;
- }
- }
- return false;
- }
-
- /**
- * Set second point in 3D zoom.
- * @param point second point.
- * @return true if the point is valid.
- */
- private boolean setPointB(Point point) {
- PointBComputer pointComputer = new PointBComputer(axes, pointAComputer, point);
- if (pointComputer.isValid()) {
- this.pointBComputer = pointComputer;
- firstPoint = pointComputer.getFirstPosition();
- secondPoint = pointComputer.getSecondPosition();
- getDrawerVisitor().getCanvas().redraw();
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Set zoom box position in 3D zoom.
- * @param point mouse position.
- * @return true if the point is valid.
- */
- private boolean setPointC(Point point) {
- PointCComputer pointComputer = new PointCComputer(axes, pointBComputer, point);
- if (pointComputer.isValid()) {
- this.pointCComputer = pointComputer;
- firstPoint = pointComputer.getFirstPosition();
- secondPoint = pointComputer.getSecondPosition();
- getDrawerVisitor().getCanvas().redraw();
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Set zoom box position in 3D zoom.
- * @param point mouse position.
- * @return true if the point is valid.
- */
- private boolean setPointD(Point point) {
- PointDComputer pointComputer = new PointDComputer(axes, pointCComputer, point);
- if (pointComputer.isValid()) {
- this.pointDComputer = pointComputer;
- firstPoint = pointComputer.getFirstPosition();
- secondPoint = pointComputer.getSecondPosition();
- getDrawerVisitor().getCanvas().redraw();
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Initialise or update the helpers geometry.
- * @param drawingTools the drawing tools used to draw the helpers.
- * @return updated helpers geometry.
- */
- private Geometry getHelpersGeometry(DrawingTools drawingTools) {
- if (helpersGeometry == null) {
- helpersGeometry = new HelpersGeometry(drawingTools);
- }
- helpersGeometry.updateVertex(axes, pointAComputer, secondPoint, status);
- return helpersGeometry;
- }
-
- /**
- * Helpers appearance getter.
- * First initialise the helpers appearance.
- * @return the helpers appearance.
- */
- public final Appearance getHelpersAppearance() {
- if (helpersAppearance == null) {
- helpersAppearance = new Appearance();
- helpersAppearance.setLineColor(new Color(1, 0, 0));
- helpersAppearance.setLineWidth(2);
- }
- return helpersAppearance;
- }
-
- /**
- * Rubber box cube geometry getter.
- * @param drawingTools the drawing tools.
- * @return the rubber box cubeGeometry.
- */
- private Geometry getCubeGeometry(DrawingTools drawingTools) {
- if (cubeGeometry == null) {
- cubeGeometry = new DefaultGeometry();
-
- BuffersManager bufferManager = drawingTools.getCanvas().getBuffersManager();
- ElementsBuffer vertexBuffer = bufferManager.createElementsBuffer();
- IndicesBuffer indicesBuffer = bufferManager.createIndicesBuffer();
- indicesBuffer.setData(CUBE_INDICES);
-
- cubeGeometry.setLineDrawingMode(Geometry.LineDrawingMode.SEGMENTS);
- cubeGeometry.setFillDrawingMode(Geometry.FillDrawingMode.NONE);
- cubeGeometry.setVertices(vertexBuffer);
- cubeGeometry.setWireIndices(indicesBuffer);
- }
-
- cubeGeometry.getVertices().setData(new float[] {
- (float) firstPoint.getX(), (float) firstPoint.getY(), (float) firstPoint.getZ(), 1,
- (float) firstPoint.getX(), (float) firstPoint.getY(), (float) secondPoint.getZ(), 1,
- (float) firstPoint.getX(), (float) secondPoint.getY(), (float) secondPoint.getZ(), 1,
- (float) firstPoint.getX(), (float) secondPoint.getY(), (float) firstPoint.getZ(), 1,
- (float) secondPoint.getX(), (float) firstPoint.getY(), (float) firstPoint.getZ(), 1,
- (float) secondPoint.getX(), (float) firstPoint.getY(), (float) secondPoint.getZ(), 1,
- (float) secondPoint.getX(), (float) secondPoint.getY(), (float) secondPoint.getZ(), 1,
- (float) secondPoint.getX(), (float) secondPoint.getY(), (float) firstPoint.getZ(), 1
- }, 4);
-
- return cubeGeometry;
- }
-
- /**
- * Rubber-box cube appearance getter.
- * @return the rubber-box cube appearance.
- */
- private Appearance getCubeAppearance() {
- if (cubeAppearance == null) {
- cubeAppearance = new Appearance();
- cubeAppearance.setLineColor(RUBBER_BOX_COLOR);
- cubeAppearance.setLineWidth(RUBBER_BOX_THICKNESS);
- cubeAppearance.setLinePattern(RUBBER_BOX_PATTERN);
- }
- return cubeAppearance;
- }
-
- @Override
- public void mousePressed(MouseEvent e) {
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- }
-
- @Override
- public void mouseDragged(MouseEvent e) {
- }
-
- @Override
- public void keyPressed(KeyEvent e) {
- }
-
- @Override
- public void keyReleased(KeyEvent e) {
- }
+ }
+
+ /**
+ * Set the info message.
+ * @param baseMessage the base of the message.
+ * @param pointComputer current used point computer.
+ * @param oneAxis true if only one coordinate is currently set.
+ */
+ private void setInfoMessage(String baseMessage, PointComputer pointComputer, boolean oneAxis) {
+ if ((pointComputer != null) && (pointComputer.isValid())) {
+ String message = baseMessage + " ";
+ double[] data = pointComputer.getSecondPosition().getData();
+ String comma;
+ if (oneAxis) {
+ comma = "";
+ } else {
+ comma = ", ";
+ }
+
+ for (int i = 0; i < PointComputer.AXIS_NUMBER; i++) {
+ if ((i != pointComputer.getFirstAxisIndex()) ^ oneAxis) {
+ message += AXES_NAMES[i] + " = " + DECIMAL_FORMAT.format(data[i]) + comma;
+ comma = "";
+ }
+ }
+ GraphicController.getController().setProperty(
+ getDrawerVisitor().getFigure().getIdentifier(),
+ GraphicObjectProperties.__GO_INFO_MESSAGE__,
+ message
+ );
+ } else {
+ String message = "Move your mouse on an axes box.";
+ GraphicController.getController().setProperty(
+ getDrawerVisitor().getFigure().getIdentifier(),
+ GraphicObjectProperties.__GO_INFO_MESSAGE__,
+ message
+ );
+ }
+ }
+
+ /**
+ * Process action on RupperBox
+ * Do nothing by default
+ */
+ protected void process()
+ {
+ // Do nothing
+ }
+
+ /**
+ * Set the first point.
+ * @param point first point AWT coordinate.
+ * @return true if the first point is valid.
+ */
+ protected boolean setPointA(Point point) {
+ axes = getUnderlyingAxes(point);
+ if (axes != null) {
+ PointAComputer pointComputer = new PointAComputer(axes, point);
+ if (pointComputer.isValid()) {
+ this.pointAComputer = pointComputer;
+ firstPoint = pointComputer.getPosition();
+ secondPoint = firstPoint;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Set second point in 3D zoom.
+ * @param point second point.
+ * @return true if the point is valid.
+ */
+ protected boolean setPointB(Point point) {
+ PointBComputer pointComputer = new PointBComputer(axes, pointAComputer, point);
+ if (pointComputer.isValid()) {
+ this.pointBComputer = pointComputer;
+ firstPoint = pointComputer.getFirstPosition();
+ secondPoint = pointComputer.getSecondPosition();
+ getDrawerVisitor().getCanvas().redraw();
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Set zoom box position in 3D zoom.
+ * @param point mouse position.
+ * @return true if the point is valid.
+ */
+ protected boolean setPointC(Point point) {
+ PointCComputer pointComputer = new PointCComputer(axes, pointBComputer, point);
+ if (pointComputer.isValid()) {
+ this.pointCComputer = pointComputer;
+ firstPoint = pointComputer.getFirstPosition();
+ secondPoint = pointComputer.getSecondPosition();
+ getDrawerVisitor().getCanvas().redraw();
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Set zoom box position in 3D zoom.
+ * @param point mouse position.
+ * @return true if the point is valid.
+ */
+ protected boolean setPointD(Point point) {
+ PointDComputer pointComputer = new PointDComputer(axes, pointCComputer, point);
+ if (pointComputer.isValid()) {
+ this.pointDComputer = pointComputer;
+ firstPoint = pointComputer.getFirstPosition();
+ secondPoint = pointComputer.getSecondPosition();
+ getDrawerVisitor().getCanvas().redraw();
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Initialise or update the helpers geometry.
+ * @param drawingTools the drawing tools used to draw the helpers.
+ * @return updated helpers geometry.
+ */
+ private Geometry getHelpersGeometry(DrawingTools drawingTools) {
+ if (helpersGeometry == null) {
+ helpersGeometry = new HelpersGeometry(drawingTools);
+ }
+ helpersGeometry.updateVertex(axes, pointAComputer, secondPoint, status);
+ return helpersGeometry;
+ }
+
+ /**
+ * Helpers appearance getter.
+ * First initialise the helpers appearance.
+ * @return the helpers appearance.
+ */
+ public final Appearance getHelpersAppearance() {
+ if (helpersAppearance == null) {
+ helpersAppearance = new Appearance();
+ helpersAppearance.setLineColor(new Color(1, 0, 0));
+ helpersAppearance.setLineWidth(2);
+ }
+ return helpersAppearance;
+ }
+
+ /**
+ * Rubber box cube geometry getter.
+ * @param drawingTools the drawing tools.
+ * @return the rubber box cubeGeometry.
+ */
+ private Geometry getCubeGeometry(DrawingTools drawingTools) {
+ if (cubeGeometry == null) {
+ cubeGeometry = new DefaultGeometry();
+
+ BuffersManager bufferManager = drawingTools.getCanvas().getBuffersManager();
+ ElementsBuffer vertexBuffer = bufferManager.createElementsBuffer();
+ IndicesBuffer indicesBuffer = bufferManager.createIndicesBuffer();
+ indicesBuffer.setData(CUBE_INDICES);
+
+ cubeGeometry.setLineDrawingMode(Geometry.LineDrawingMode.SEGMENTS);
+ cubeGeometry.setFillDrawingMode(Geometry.FillDrawingMode.NONE);
+ cubeGeometry.setVertices(vertexBuffer);
+ cubeGeometry.setWireIndices(indicesBuffer);
+ }
+
+ cubeGeometry.getVertices().setData(new float[] {
+ (float) firstPoint.getX(), (float) firstPoint.getY(), (float) firstPoint.getZ(), 1,
+ (float) firstPoint.getX(), (float) firstPoint.getY(), (float) secondPoint.getZ(), 1,
+ (float) firstPoint.getX(), (float) secondPoint.getY(), (float) secondPoint.getZ(), 1,
+ (float) firstPoint.getX(), (float) secondPoint.getY(), (float) firstPoint.getZ(), 1,
+ (float) secondPoint.getX(), (float) firstPoint.getY(), (float) firstPoint.getZ(), 1,
+ (float) secondPoint.getX(), (float) firstPoint.getY(), (float) secondPoint.getZ(), 1,
+ (float) secondPoint.getX(), (float) secondPoint.getY(), (float) secondPoint.getZ(), 1,
+ (float) secondPoint.getX(), (float) secondPoint.getY(), (float) firstPoint.getZ(), 1
+ }, 4);
+
+ return cubeGeometry;
+ }
+
+ /**
+ * Rubber-box cube appearance getter.
+ * @return the rubber-box cube appearance.
+ */
+ private Appearance getCubeAppearance() {
+ if (cubeAppearance == null) {
+ cubeAppearance = new Appearance();
+ cubeAppearance.setLineColor(RUBBER_BOX_COLOR);
+ cubeAppearance.setLineWidth(RUBBER_BOX_THICKNESS);
+ cubeAppearance.setLinePattern(RUBBER_BOX_PATTERN);
+ }
+ return cubeAppearance;
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDragged(MouseEvent e) {
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ }
}
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Bruno JOFRET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ */
+
+package org.scilab.modules.renderer.JoGLView.interaction;
+
+import java.awt.Point;
+
+import org.scilab.forge.scirenderer.tranformations.Vector3d;
+import org.scilab.modules.renderer.JoGLView.DrawerVisitor;
+
+/**
+ * @author Bruno JOFRET
+ */
+public class TwoPointsRubberBox extends RubberBox implements PointRubberBox {
+
+ /**
+ * Default constructor.
+ *
+ * @param drawerVisitor parent drawer visitor.
+ */
+ public TwoPointsRubberBox(DrawerVisitor drawerVisitor) {
+ super(drawerVisitor);
+ }
+
+ public double[] getResults() {
+ double result[] = {
+ mouseButton - 1,
+ Math.min(firstPoint.getX(), secondPoint.getX()),
+ Math.max(firstPoint.getY(), secondPoint.getY()),
+ Math.max(firstPoint.getZ(), secondPoint.getZ()),
+ Math.abs(firstPoint.getX() - secondPoint.getX()),
+ Math.abs(firstPoint.getY() - secondPoint.getY()),
+ Math.abs(firstPoint.getZ() - secondPoint.getZ())
+ };
+
+ return result;
+ }
+}
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Bruno JOFRET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ */
+
+package org.scilab.modules.renderer.JoGLView.interaction;
+
+import java.awt.event.MouseEvent;
+
+import org.scilab.modules.graphic_objects.graphicController.GraphicController;
+import org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties;
+import org.scilab.modules.renderer.JoGLView.DrawerVisitor;
+
+/**
+ * @author Bruno JOFRET
+ */
+public class ZoomRubberBox extends RubberBox {
+
+ /**
+ * Default constructor.
+ *
+ * @param drawerVisitor parent drawer visitor.
+ */
+ public ZoomRubberBox(DrawerVisitor drawerVisitor) {
+ super(drawerVisitor);
+ }
+
+ @Override
+ public final void mouseClicked(MouseEvent e) {
+ mouseButton = e.getButton();
+ if (e.getButton() == MouseEvent.BUTTON1) {
+ switch (status) {
+ case WAIT_POINT_A:
+ if (setPointA(e.getPoint())) {
+ status = Status.WAIT_POINT_B;
+ } else {
+ setEnable(false);
+ fireRubberBoxEnd();
+ }
+ break;
+ case WAIT_POINT_B:
+ setPointB(e.getPoint());
+ if (pointBComputer.is2D()) {
+ process();
+ setEnable(false);
+ fireRubberBoxEnd();
+ } else {
+ status = Status.WAIT_POINT_C;
+ }
+ break;
+ case WAIT_POINT_C:
+ setPointC(e.getPoint());
+ status = Status.WAIT_POINT_D;
+ break;
+ case WAIT_POINT_D:
+ setPointD(e.getPoint());
+ process();
+ setEnable(false);
+ fireRubberBoxEnd();
+ break;
+ default:
+ }
+ updateInfoMessage();
+ }
+
+ if (e.getButton() == MouseEvent.BUTTON3) {
+ setEnable(false);
+ fireRubberBoxEnd();
+ }
+ }
+
+ /**
+ * Actually set the zoom box depending on current value of firstPoint and secondPoint.
+ */
+ @Override
+ protected void process() {
+ Double[] bounds = {
+ Math.min(firstPoint.getX(), secondPoint.getX()), Math.max(firstPoint.getX(), secondPoint.getX()),
+ Math.min(firstPoint.getY(), secondPoint.getY()), Math.max(firstPoint.getY(), secondPoint.getY()),
+ Math.min(firstPoint.getZ(), secondPoint.getZ()), Math.max(firstPoint.getZ(), secondPoint.getZ()),
+ };
+
+ if (bounds[0].compareTo(bounds[1]) != 0 && bounds[2].compareTo(bounds[3]) != 0 && bounds[4].compareTo(bounds[5]) != 0) {
+ Boolean zoomed = tightZoomBounds(axes, bounds);
+ GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_ZOOM_BOX__, bounds);
+ GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_ZOOM_ENABLED__, zoomed);
+ getDrawerVisitor().getCanvas().redraw();
+ }
+ }
+}
bufferManager.dispose(vertexBuffer);
}
- public void updateVertex(Axes axes, PointAComputer pointAComputer, Vector3d secondPoint, RubberBox.Status status) {
+ public void updateVertex(Axes axes, PointComputer pointAComputer, Vector3d secondPoint, RubberBox.Status status) {
if ((pointAComputer != null) && (pointAComputer.getFirstAxisIndex() != -1)) {
FloatBuffer data;
boolean oneAxis;
* The point correspond to a mouse coordinate.
* @author Pierre Lando
*/
-public class PointAComputer extends CubeFacesPointComputer {
+public class PointAComputer extends CubeFacesPointComputer implements PointComputer {
/**
* Constructor.
public final Vector3d getSecondPosition() {
return getPosition();
}
+
+ @Override
+ public boolean is2D() {
+ return false;
+ }
}
/**
* @author Pierre Lando
*/
-public class PointBComputer extends AbstractPointComputer {
+public class PointBComputer extends AbstractPointComputer implements PointComputer {
/** First axis index */
private final int firstAxisIndex;
* @param pointAComputer the first point computer.
* @param point the clicked point in AWT coordinate.
*/
- public PointBComputer(Axes axes, PointAComputer pointAComputer, Point point) {
+ public PointBComputer(Axes axes, PointComputer pointAComputer, Point point) {
super(axes, point);
firstAxisIndex = pointAComputer.getFirstAxisIndex();
if (firstAxisIndex != -1) {
- double value = pointAComputer.getPosition().getData()[firstAxisIndex];
+ double value = pointAComputer.getFirstPosition().getData()[firstAxisIndex];
double lambda = computeLambda(value, firstAxisIndex);
Vector3d coordinate = computeCoordinate(lambda, value, firstAxisIndex);
- firstPosition = pointAComputer.getPosition();
+ firstPosition = pointAComputer.getFirstPosition();
secondPosition = clamp(coordinate);
if (check2D()) {
/**
* @author Pierre Lando
*/
-public class PointCComputer extends CubeFacesPointComputer {
+public class PointCComputer extends CubeFacesPointComputer implements PointComputer {
private final Vector3d secondPosition;
private final Vector3d firstPosition;
* @param pointBComputer previous point computer.
* @param point clicked point in AWT coordinate.
*/
- public PointCComputer(Axes axes, PointBComputer pointBComputer, Point point) {
+ public PointCComputer(Axes axes, PointComputer pointBComputer, Point point) {
super(axes, point);
firstAxisIndex = pointBComputer.getFirstAxisIndex();
if (getPosition() != null) {
public final Vector3d getSecondPosition() {
return secondPosition;
}
+
+ @Override
+ public boolean is2D() {
+ return false;
+ }
}
* @return the first axis index.
*/
public abstract int getFirstAxisIndex();
+
+ /**
+ * 2D status getter.
+ * @return true if the zoom is in 2D mode.
+ */
+ public boolean is2D();
}
/**
* @author Pierre Lando
*/
-public class PointDComputer extends CubeFacesPointComputer {
+public class PointDComputer extends CubeFacesPointComputer implements PointComputer {
private final int firstAxisIndex;
private final Vector3d secondPosition;
* @param pointCComputer previous point computer.
* @param point clicked point in AWT coordinate.
*/
- public PointDComputer(Axes axes, PointCComputer pointCComputer, Point point) {
+ public PointDComputer(Axes axes, PointComputer pointCComputer, Point point) {
super(axes, point);
firstAxisIndex = pointCComputer.getFirstAxisIndex();
if (getPosition() != null) {
public final int getFirstAxisIndex() {
return firstAxisIndex;
}
+
+ @Override
+ public boolean is2D() {
+ return false;
+ }
}
#include "CallRenderer.hxx"
-/* Generated by GIWS (version 2.0.0) with command:
+/* Generated by GIWS (version 2.0.1) with command:
giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/renderer.giws.xml
*/
/*
-Copyright 2007-2008 INRIA
-Copyright 2008-2011 DIGITEO
-Copyright 2011-2012 Scilab Enterprises
-
-Author : Sylvestre Ledru & others
-
This is generated code.
This software is a computer program whose purpose is to hide the complexity
/* Methods ID set to NULL */
voidstartInteractiveZoomjstringjava_lang_StringID=NULL;
+jdoubleArray_clickRubberBoxjstringjava_lang_StringjdoubleArray_doubledoubleID=NULL;
+jdoubleArray_dragRubberBoxjstringjava_lang_StringID=NULL;
voidupdateTextBoundsjstringjava_lang_StringID=NULL;
voidupdateSubwinScalejstringjava_lang_StringID=NULL;
jdoubleArray_get2dViewCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID=NULL;
}
/* Methods ID set to NULL */
voidstartInteractiveZoomjstringjava_lang_StringID=NULL;
+jdoubleArray_clickRubberBoxjstringjava_lang_StringjdoubleArray_doubledoubleID=NULL;
+jdoubleArray_dragRubberBoxjstringjava_lang_StringID=NULL;
voidupdateTextBoundsjstringjava_lang_StringID=NULL;
voidupdateSubwinScalejstringjava_lang_StringID=NULL;
jdoubleArray_get2dViewCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID=NULL;
}
}
+double* CallRenderer::clickRubberBox (JavaVM * jvm_, char const* id, double const* startRectangle, int startRectangleSize){
+
+JNIEnv * curEnv = NULL;
+jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+jclass cls = curEnv->FindClass( className().c_str() );
+
+jmethodID jdoubleArray_clickRubberBoxjstringjava_lang_StringjdoubleArray_doubledoubleID = curEnv->GetStaticMethodID(cls, "clickRubberBox", "(Ljava/lang/String;[D)[D" ) ;
+if (jdoubleArray_clickRubberBoxjstringjava_lang_StringjdoubleArray_doubledoubleID == NULL) {
+throw GiwsException::JniMethodNotFoundException(curEnv, "clickRubberBox");
+}
+
+jstring id_ = curEnv->NewStringUTF( id );
+if (id != NULL && id_ == NULL)
+{
+throw GiwsException::JniBadAllocException(curEnv);
+}
+
+
+jdoubleArray startRectangle_ = curEnv->NewDoubleArray( startRectangleSize ) ;
+
+if (startRectangle_ == NULL)
+{
+// check that allocation succeed
+throw GiwsException::JniBadAllocException(curEnv);
+}
+
+curEnv->SetDoubleArrayRegion( startRectangle_, 0, startRectangleSize, (jdouble*)(startRectangle) ) ;
+
+
+ jdoubleArray res = static_cast<jdoubleArray>( curEnv->CallStaticObjectMethod(cls, jdoubleArray_clickRubberBoxjstringjava_lang_StringjdoubleArray_doubledoubleID ,id_, startRectangle_));
+ if (res == NULL) { return NULL; }
+ if (curEnv->ExceptionCheck()) {
+throw GiwsException::JniCallMethodException(curEnv);
+}int lenRow;
+ lenRow = curEnv->GetArrayLength(res);
+jboolean isCopy = JNI_FALSE;
+
+/* GetPrimitiveArrayCritical is faster than getXXXArrayElements */
+jdouble *resultsArray = static_cast<jdouble *>(curEnv->GetPrimitiveArrayCritical(res, &isCopy));
+double* myArray= new double[ lenRow];
+
+for (jsize i = 0; i < lenRow; i++){
+myArray[i]=resultsArray[i];
+}
+curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+ curEnv->DeleteLocalRef(res);
+curEnv->DeleteLocalRef(id_);
+curEnv->DeleteLocalRef(startRectangle_);
+curEnv->DeleteLocalRef(cls);
+if (curEnv->ExceptionCheck()) {
+delete[] myArray;
+ throw GiwsException::JniCallMethodException(curEnv);
+}
+return myArray;
+
+}
+
+double* CallRenderer::dragRubberBox (JavaVM * jvm_, char const* id){
+
+JNIEnv * curEnv = NULL;
+jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+jclass cls = curEnv->FindClass( className().c_str() );
+
+jmethodID jdoubleArray_dragRubberBoxjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "dragRubberBox", "(Ljava/lang/String;)[D" ) ;
+if (jdoubleArray_dragRubberBoxjstringjava_lang_StringID == NULL) {
+throw GiwsException::JniMethodNotFoundException(curEnv, "dragRubberBox");
+}
+
+jstring id_ = curEnv->NewStringUTF( id );
+if (id != NULL && id_ == NULL)
+{
+throw GiwsException::JniBadAllocException(curEnv);
+}
+
+
+ jdoubleArray res = static_cast<jdoubleArray>( curEnv->CallStaticObjectMethod(cls, jdoubleArray_dragRubberBoxjstringjava_lang_StringID ,id_));
+ if (res == NULL) { return NULL; }
+ if (curEnv->ExceptionCheck()) {
+throw GiwsException::JniCallMethodException(curEnv);
+}int lenRow;
+ lenRow = curEnv->GetArrayLength(res);
+jboolean isCopy = JNI_FALSE;
+
+/* GetPrimitiveArrayCritical is faster than getXXXArrayElements */
+jdouble *resultsArray = static_cast<jdouble *>(curEnv->GetPrimitiveArrayCritical(res, &isCopy));
+double* myArray= new double[ lenRow];
+
+for (jsize i = 0; i < lenRow; i++){
+myArray[i]=resultsArray[i];
+}
+curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+ curEnv->DeleteLocalRef(res);
+curEnv->DeleteLocalRef(id_);
+curEnv->DeleteLocalRef(cls);
+if (curEnv->ExceptionCheck()) {
+delete[] myArray;
+ throw GiwsException::JniCallMethodException(curEnv);
+}
+return myArray;
+
+}
+
void CallRenderer::updateTextBounds (JavaVM * jvm_, char const* id){
JNIEnv * curEnv = NULL;
-/* Generated by GIWS (version 2.0.0) with command:
+/* Generated by GIWS (version 2.0.1) with command:
giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/renderer.giws.xml
*/
/*
-Copyright 2007-2008 INRIA
-Copyright 2008-2011 DIGITEO
-Copyright 2011-2012 Scilab Enterprises
-
-Author : Sylvestre Ledru & others
-
This is generated code.
This software is a computer program whose purpose is to hide the complexity
protected:
jmethodID voidstartInteractiveZoomjstringjava_lang_StringID; // cache method id
+jmethodID jdoubleArray_clickRubberBoxjstringjava_lang_StringjdoubleArray_doubledoubleID; // cache method id
+jmethodID jdoubleArray_dragRubberBoxjstringjava_lang_StringID; // cache method id
jmethodID voidupdateTextBoundsjstringjava_lang_StringID; // cache method id
jmethodID voidupdateSubwinScalejstringjava_lang_StringID; // cache method id
jmethodID jdoubleArray_get2dViewCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID; // cache method id
// Methods
static void startInteractiveZoom(JavaVM * jvm_, char const* id);
+static double* clickRubberBox(JavaVM * jvm_, char const* id, double const* startRectangle, int startRectangleSize);
+
+static double* dragRubberBox(JavaVM * jvm_, char const* id);
+
static void updateTextBounds(JavaVM * jvm_, char const* id);
static void updateSubwinScale(JavaVM * jvm_, char const* id);
#include "XlFontManager.hxx"
-/* Generated by GIWS (version 2.0.0) with command:
+/* Generated by GIWS (version 2.0.1) with command:
giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/XlFontManager.giws.xml
*/
/*
-Copyright 2007-2008 INRIA
-Copyright 2008-2011 DIGITEO
-Copyright 2011-2012 Scilab Enterprises
-
-Author : Sylvestre Ledru & others
-
This is generated code.
This software is a computer program whose purpose is to hide the complexity
-/* Generated by GIWS (version 2.0.0) with command:
+/* Generated by GIWS (version 2.0.1) with command:
giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/XlFontManager.giws.xml
*/
/*
-Copyright 2007-2008 INRIA
-Copyright 2008-2011 DIGITEO
-Copyright 2011-2012 Scilab Enterprises
-
-Author : Sylvestre Ledru & others
-
This is generated code.
This software is a computer program whose purpose is to hide the complexity
<method name="startInteractiveZoom" returnType="void" modifier="static">
<parameter name="id" type="String"/>
</method>
+
+ <method name="clickRubberBox" returnType="double[]" modifier="static">
+ <parameter name="id" type="String"/>
+ <parameter name="startRectangle" type="double[]"/>
+ </method>
+
+ <method name="dragRubberBox" returnType="double[]" modifier="static">
+ <parameter name="id" type="String"/>
+ </method>
+
+
<method name="updateTextBounds" returnType="void" modifier="static">
<parameter name="id" type="String"/>
</method>