Add zoom functions.
Jean-baptiste Silvy [Mon, 7 Jan 2008 10:23:35 +0000 (10:23 +0000)]
Interface piwel_drawing_mode property of figures.

52 files changed:
scilab/modules/graphics/includes/GetProperty.h
scilab/modules/graphics/includes/ObjectStructure.h
scilab/modules/graphics/includes/axesScale.h
scilab/modules/graphics/includes/math_graphics.h
scilab/modules/graphics/sci_gateway/c/sci_geom3d.c
scilab/modules/graphics/sci_gateway/c/sci_unzoom.c
scilab/modules/graphics/sci_gateway/c/sci_zoom_rect.c
scilab/modules/graphics/src/c/GetProperty.c
scilab/modules/graphics/src/c/Plo2dEch.c
scilab/modules/graphics/src/c/axesScale.c
scilab/modules/graphics/src/c/getHandleProperty/set_zoom_box_property.c
scilab/modules/graphics/src/c/math_graphics.c
scilab/modules/renderer/graphics_Import.def
scilab/modules/renderer/includes/GetJavaProperty.h
scilab/modules/renderer/includes/SetJavaProperty.h
scilab/modules/renderer/renderer_header.def
scilab/modules/renderer/src/cpp/GetJavaProperty.cpp
scilab/modules/renderer/src/cpp/SetJavaProperty.cpp
scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigure.cpp
scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigure.h
scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureBridge.h
scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJavaMapper.cpp
scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJavaMapper.hxx
scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJoGL.cpp
scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJoGL.h
scilab/modules/renderer/src/cpp/subwinDrawing/Camera.cpp
scilab/modules/renderer/src/cpp/subwinDrawing/Camera.h
scilab/modules/renderer/src/cpp/subwinDrawing/CameraBridge.h
scilab/modules/renderer/src/cpp/subwinDrawing/CameraJavaMapper.hxx
scilab/modules/renderer/src/cpp/subwinDrawing/CameraJoGL.cpp
scilab/modules/renderer/src/cpp/subwinDrawing/CameraJoGL.h
scilab/modules/renderer/src/cpp/subwinDrawing/ConcreteDrawableSubwin.hxx
scilab/modules/renderer/src/cpp/subwinDrawing/IsoViewCameraJavaMapper.cpp
scilab/modules/renderer/src/cpp/subwinDrawing/IsoViewCameraJavaMapper.hxx
scilab/modules/renderer/src/cpp/subwinDrawing/IsometricCameraJavaMapper.cpp
scilab/modules/renderer/src/cpp/subwinDrawing/IsometricCameraJavaMapper.hxx
scilab/modules/renderer/src/java/org/scilab/modules/renderer/figureDrawing/DrawableFigureGL.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/figureDrawing/RendererProperties.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/figureDrawing/SciRenderer.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/subwinDrawing/CameraGL.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/textDrawing/TextContentDrawerGL.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/utils/CoordinateTransformation.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/utils/geom3D/Matrix4D.java
scilab/modules/renderer/src/jni/DrawableFigureGL.cpp
scilab/modules/renderer/src/jni/DrawableFigureGL.giws.xml
scilab/modules/renderer/src/jni/DrawableFigureGL.hxx
scilab/modules/renderer/src/jni/IsoViewCameraGL.cpp
scilab/modules/renderer/src/jni/IsoViewCameraGL.giws.xml
scilab/modules/renderer/src/jni/IsoViewCameraGL.hxx
scilab/modules/renderer/src/jni/IsometricCameraGL.cpp
scilab/modules/renderer/src/jni/IsometricCameraGL.giws.xml
scilab/modules/renderer/src/jni/IsometricCameraGL.hxx

index 1e527c7..1e70b48 100644 (file)
@@ -219,6 +219,8 @@ void sciGetTextPos(sciPointObj * pObj, double position[3]); /* GET */
 
 void sciGetPixelCoordinate(sciPointObj * pObj, const double userCoord[3], int pixCoord[2]); /* GET */
 
+void sciGet2dViewCoordinate(sciPointObj * pObj, const double userCoords3D[3], double userCoords2D[2]); /* GET */
+
 BOOL sciGetIsIsoView(sciPointObj * pObj); /* GET */
 
 BOOL sciGetIsCubeScaled(sciPointObj * pObj); /* GET */
index 8ac4864..e899e33 100644 (file)
@@ -393,7 +393,7 @@ typedef struct
                       
   
 }/** */
-scigMode;  
+scigMode;
 
 
 /**
@@ -462,7 +462,6 @@ typedef struct
   /** specifies the number of the selected son         */
   int numsubwinselected;
   /** specifies the current pixmap status         */
-  /*int pixmap; */ /* DJ.A 30/12 */
   int wshow ;
   
   BOOL allredraw;
index c050cd0..4fec866 100644 (file)
@@ -28,8 +28,9 @@ int trans3d( sciPointObj * pobj,
 /*------------------------------------------------------------------------------*/
 int sciZoom2D(sciPointObj * pObj, const double zoomRect[4]);
 int sciZoom3D(sciPointObj * pObj, const double zoomBox[6]);
-void sciUnzoom(sciPointObj * pObj);
 void sciGetZoom3D(sciPointObj * pObj, double zoomBox[6]);
+void sciZoomRect(sciPointObj * pObj, int posX, int posY, int width, int height);
+void sciUnzoom(sciPointObj * subwins[], int nbSubwins);
 /*------------------------------------------------------------------------------*/
 BOOL checkDataBounds(sciPointObj * pObj, double xMin, double xMax,
                      double yMin, double yMax, double zMin, double zMax);
index cef4b14..1416e64 100644 (file)
@@ -140,14 +140,24 @@ void normalize2d( double vect[2] ) ;
 void iNormalize2d( int vect[2] ) ;
 
 /**
+ * Perform the substraction of vect1 and vect2 and store it in res
+ */
+void vectSubstract2D(const double vect1[2], const double vect2[], double res[2]);
+
+/**
  * return the scalar product of two 2d vectors.
  */
 #define DOT_PROD_2D(v1,v2) ( ((v1)[0]) * ((v2)[0]) + ((v1)[1]) * ((v2)[1]) )
 
 /**
+ * Square norm of a vector
+ */
+#define SQUARE_NORM_2D(v) ( DOT_PROD_2D((v),(v)) )
+
+/**
  * Norm of a 2D vector
  */
-#define NORM_2D(v) ( sqrt( DOT_PROD_2D((v),(v)) ) ) ;
+#define NORM_2D(v) ( sqrt( SQUARE_NORM_2D(v) ) )
 
 /************************************************************************/
 /* 3D algorithms                                                        */
@@ -172,13 +182,23 @@ void crossProduct( const double v1[3], const double v2[3], double res[3] ) ;
 /**
  * Norm of a 3D vector
  */
-#define NORM_3D(v) ( sqrt( SQUARE_NORM_3D(v) ) ) ;
+#define NORM_3D(v) ( sqrt( SQUARE_NORM_3D(v) ) )
 
 /**
  * Normalize a 3D vector
  */
 void normalize3D( double vect[3] ) ;
 
+/**
+ * Set a 4x4 matrix to identity.
+ */
+void setToIdentity(double mat4D[4][4]);
+
+/**
+ * Compute the product mat4D*vect3D and store the result in res.
+ */
+void mat4DMult(const double mat4D[4][4], const double vect3D[3], double res[3]);
+
 /*----------------------------------------------------------------------------*/
 /* check if two values can be considered equal given an accurracy */
 int safeEqual( double val1, double val2, double accuracy ) ;
index 4d54ed0..e6168dd 100644 (file)
@@ -19,16 +19,16 @@ int geom3d(double *x, double *y, double *z, int n) ;
 int geom3d(double *x, double *y, double *z, int n)
 {
   int i;
-  int pixCoords[2];
+  double userCoords2d[2];
 
   sciPointObj * psubwin = sciGetCurrentSubWin();
   
   for (i = 0; i < n; i++)
   {
     double userCoords[3] = {x[i], y[i], z[i]};
-    sciGetPixelCoordinate(psubwin, userCoords, pixCoords);
-    x[i] = pixCoords[0];
-    y[i] = pixCoords[1];
+    sciGet2dViewCoordinate(psubwin, userCoords, userCoords2d);
+    x[i] = userCoords2d[0];
+    y[i] = userCoords2d[1];
   }
 
   return 0;
@@ -42,7 +42,7 @@ int sci_geom3d( char * fname, unsigned long fname_len )
   if ( Rhs <= 0 )
   {
     int one = 1 ;
-    sci_demo( fname, "t=0:0.1:5*%pi,[x,y]=geom3d(sin(t),cos(t),t/10);", &one ) ;
+    sci_demo( fname, "t=0:0.1:5*%pi,[x,y]=geom3d(sin(t),cos(t),t/10)", &one ) ;
     return 0 ;
   }
 
index 18b5e0a..4c2d38f 100644 (file)
@@ -7,29 +7,71 @@
 
 #include "sci_unzoom.h"
 #include "stack-c.h"
-#include "PloEch.h"
 #include "GetProperty.h"
-#include "BuildObjects.h"
+#include "MALLOC.h"
 #include "gw_graphics.h"
+#include "SetProperty.h"
+#include "axesScale.h"
+#include "localization.h"
+#include "CurrentObjectsManagement.h"
+#include "sciprint.h"
+#include "getPropertyAssignedValue.h"
 
 /*--------------------------------------------------------------------------*/
 int sci_unzoom(char *fname,unsigned long fname_len)
 {
+  sciPointObj ** unzoomedSubwins = NULL;
+  int nbUnzoomedSubwins = 0;
   CheckRhs(0,1) ;
-  CheckLhs(0,1) ;;
+  CheckLhs(0,1) ;
   if ( Rhs == 0 )
   {
-    unzoom();
+    sciPointObj * curSubwin = sciGetCurrentSubWin();
+    unzoomedSubwins = &curSubwin;
+    nbUnzoomedSubwins = 1;
   }
   else
   {
-    int m,n,l,i;
-    GetRhsVar(1,GRAPHICAL_HANDLE_DATATYPE,&m,&n,&l); 
-    for (i=0;i<m*n;i++)
+    int m,n,i;
+    int stackPointer;
+    GetRhsVar(1,GRAPHICAL_HANDLE_DATATYPE,&m,&n,&stackPointer);
+    
+    nbUnzoomedSubwins = m * n;
+
+    unzoomedSubwins = MALLOC( nbUnzoomedSubwins * sizeof(sciPointObj *));
+    
+    if (unzoomedSubwins == NULL)
     {
-      unzoom_one_axes((sciPointObj*)sciGetPointerFromHandle((long) *hstk(l+i))); /** Correction Bug 1476 + Warning Windows **/
+      sciprint(_("%s: no more memory.\n"),fname);
+      LhsVar(1)=0; 
+      return 0;
     }
+
+    for ( i = 0 ; i < nbUnzoomedSubwins ; i++ )
+    {
+      unzoomedSubwins[i] = sciGetPointerFromHandle(getHandleFromStack(stackPointer + i));
+      if (sciGetEntityType(unzoomedSubwins[i]) != SCI_SUBWIN)
+      {
+        sciprint(_("%s: Wrong type for input argument: vector of axes handles expected.\n"),fname);
+        FREE(unzoomedSubwins);
+        LhsVar(1)=0; 
+        return 0;
+      }
+      //sciSetZooming(sciGetPointerFromHandle(getHandleFromStack(stackPointer + i)), FALSE); /** Correction Bug 1476 + Warning Windows **/
+    }
+    
+    
+
   }
+
+  sciUnzoom(unzoomedSubwins, nbUnzoomedSubwins);
+
+  if (Rhs != 0) 
+  {
+    FREE(unzoomedSubwins);
+  }
+  
+
   LhsVar(1)=0; 
   return 0;
 }
index 8949814..83d1efb 100644 (file)
 #include "gw_graphics.h"
 #include "axesScale.h"
 #include "CurrentObjectsManagement.h"
+#include "GraphicSynchronizerInterface.h"
 
 /*--------------------------------------------------------------------------*/
 int sci_zoom_rect(char *fname,unsigned long fname_len)
 {
-  int m,n,l;
-  /* int x_pixel=0,y_pixel=0; */
+  int m,n;
+  int stackPointer;
   CheckRhs(0,1) ;
   CheckLhs(0,1) ;
   if (Rhs <= 0) 
@@ -27,10 +28,25 @@ int sci_zoom_rect(char *fname,unsigned long fname_len)
   }
   else
   {
-    GetRhsVar(1,MATRIX_OF_DOUBLE_DATATYPE,&m,&n,&l); 
+    double * rectData = NULL;
+    sciPointObj * curFigure = NULL;
+    sciPointObj * curSubWin = NULL;
+
+
+    GetRhsVar(1,MATRIX_OF_DOUBLE_DATATYPE,&m,&n,&stackPointer); 
     CheckLength(1,4,m*n);
-    /*zoom_box(stk(l),&x_pixel,&y_pixel);*/
-    sciZoom2D(sciGetCurrentSubWin(), getDoubleMatrixFromStack(l));
+    /*sciZoom2D(sciGetCurrentSubWin(), getDoubleMatrixFromStack(stackPointer));*/
+    rectData = getDoubleMatrixFromStack(stackPointer);
+    
+    curFigure = sciGetCurrentFigure();
+    curSubWin = sciGetCurrentSubWin();
+
+    startFigureDataWriting(curFigure);
+    sciZoomRect(curSubWin, (int) rectData[0], (int) rectData[1],
+                (int) rectData[2], (int) rectData[3]);
+    endFigureDataWriting(curFigure);
+
+    sciDrawObj(curSubWin);
   }
 
   LhsVar(1)=0; 
index d310c92..d0d1a43 100644 (file)
@@ -4133,7 +4133,7 @@ void sciGetPixelCoordinate(sciPointObj * pObj, const double userCoord[3], int pi
     sciGetJavaPixelCoordinates(pObj, userCoord, pixCoord);
     break;
   default:
-    sciprint(_("Pixel coordinates are only applicable on axes objects.\n"));
+    sciprint(_("Coordinates modifications are only applicable on axes objects.\n"));
     pixCoord[0] = -1;
     pixCoord[1] = -1;
     break;
@@ -4141,6 +4141,27 @@ void sciGetPixelCoordinate(sciPointObj * pObj, const double userCoord[3], int pi
 }
 /*----------------------------------------------------------------------------------*/
 /**
+ * Convert user coordinates to pixel ones (relative to the viewing canvas).
+ * @param pObj subwindow handle
+ * @param userCoord user coordinates
+ * @param userCoords2D result in user coord but in the default 2D plane.
+ */
+void sciGet2dViewCoordinate(sciPointObj * pObj, const double userCoords3D[3], double userCoords2D[2])
+{
+  switch(sciGetEntityType(pObj))
+  {
+  case SCI_SUBWIN:
+    sciGetJava2dViewCoordinates(pObj, userCoords3D, userCoords2D);
+    break;
+  default:
+    sciprint(_("Coordinates modifications are only applicable on axes objects.\n"));
+    userCoords2D[0] = 0.0;
+    userCoords2D[1] = 0.0;
+    break;
+  }
+}
+/*----------------------------------------------------------------------------------*/
+/**
  * @return TRUE if pObj is a subwin with isoview mode on.
  */
 BOOL sciGetIsIsoView(sciPointObj * pObj)
index 447cba0..4f78994 100644 (file)
@@ -1292,10 +1292,6 @@ extern void unzoom()
       if (sciGetZooming(psousfen))
       {
         sciSetZooming(psousfen, 0);
-        /*   pSUBWIN_FEATURE (psousfen)->ZRect[0]   = pSUBWIN_FEATURE (psousfen)->ZRect_kp[0]; */
-        /*                   pSUBWIN_FEATURE (psousfen)->ZRect[1]   = pSUBWIN_FEATURE (psousfen)->ZRect_kp[1]; */
-        /*                   pSUBWIN_FEATURE (psousfen)->ZRect[2]   = pSUBWIN_FEATURE (psousfen)->ZRect_kp[2]; */
-        /*                   pSUBWIN_FEATURE (psousfen)->ZRect[3]   = pSUBWIN_FEATURE (psousfen)->ZRect_kp[3]; */
 
         pSUBWIN_FEATURE (psousfen)->ZRect[0]   = pSUBWIN_FEATURE (psousfen)->SRect[0];
         pSUBWIN_FEATURE (psousfen)->ZRect[1]   = pSUBWIN_FEATURE (psousfen)->SRect[1];
@@ -1333,10 +1329,6 @@ extern void unzoom_one_axes(sciPointObj *psousfen)
   if (sciGetEntityType (psousfen) == SCI_SUBWIN) {
     if (sciGetZooming(psousfen))       {
       sciSetZooming(psousfen, 0);
-      /*   pSUBWIN_FEATURE (psousfen)->ZRect[0]   = pSUBWIN_FEATURE (psousfen)->ZRect_kp[0]; */
-      /*         pSUBWIN_FEATURE (psousfen)->ZRect[1]   = pSUBWIN_FEATURE (psousfen)->ZRect_kp[1]; */
-      /*         pSUBWIN_FEATURE (psousfen)->ZRect[2]   = pSUBWIN_FEATURE (psousfen)->ZRect_kp[2]; */
-      /*         pSUBWIN_FEATURE (psousfen)->ZRect[3]   = pSUBWIN_FEATURE (psousfen)->ZRect_kp[3]; */
 
       pSUBWIN_FEATURE (psousfen)->ZRect[0]   = pSUBWIN_FEATURE (psousfen)->SRect[0];
       pSUBWIN_FEATURE (psousfen)->ZRect[1]   = pSUBWIN_FEATURE (psousfen)->SRect[1];
index ccb11b8..98ac59c 100644 (file)
 #include "Vertices.h"
 #include "localization.h"
 #include "SetPropertyStatus.h"
+#include "SetJavaProperty.h"
+#include "GraphicSynchronizerInterface.h"
+#include "DrawingBridge.h"
+#include "CurrentObjectsManagement.h"
 
 /*------------------------------------------------------------------------------*/
 double InvAxis( double min, double max, double u )
@@ -390,14 +394,6 @@ int sciZoom3D(sciPointObj * pObj, const double zoomBox[6])
 }
 /*------------------------------------------------------------------------------*/
 /**
- * Unzoom the selected subwin
- */
-void sciUnzoom(sciPointObj * pObj)
-{
-  sciSetZooming(pObj, FALSE);
-}
-/*------------------------------------------------------------------------------*/
-/**
  * get the zoom box to dispplay in Scilab for a sunwin object
  * @param[out] zoomBox [xMin, yMin, xMax, yMax, zMin, zMax];
  */
@@ -414,6 +410,15 @@ void sciGetZoom3D(sciPointObj * pObj, double zoomBox[6])
 }
 /*------------------------------------------------------------------------------*/
 /**
+ *  Zoom on a subwidow using a rectangle specified by user in pixels
+ */
+void sciZoomRect(sciPointObj * pObj, int posX, int posY, int width, int height)
+{
+  sciJavaZoomRect(pObj, posX, posY, width, height);
+  sciSetZooming(pObj, TRUE);
+}
+/*------------------------------------------------------------------------------*/
+/**
  * Check if the follawing data bounds can be used as new data bounds for the subwin object
  * @return TRUE if values can be used, false otherwise
  */
@@ -454,3 +459,19 @@ BOOL checkDataBounds(sciPointObj * pObj, double xMin, double xMax,
   return TRUE;
 }
 /*------------------------------------------------------------------------------*/
+/**
+ * Unzoom several subwindows in the same time
+ */
+void sciUnzoom(sciPointObj * subwins[], int nbSubwins)
+{
+  int i;
+  for (i = 0; i < nbSubwins; i++)
+  {
+    sciPointObj * parentFig = sciGetParentFigure(subwins[i]);
+    startFigureDataWriting(parentFig);
+    sciSetZooming(subwins[i], FALSE);
+    endFigureDataWriting(parentFig);
+    sciDrawObj(subwins[i]);
+  }
+}
+/*------------------------------------------------------------------------------*/
index f54223e..d8607f9 100644 (file)
@@ -34,7 +34,6 @@ int set_zoom_box_property( sciPointObj * pobj, int stackPointer, int valueType,
   /* We must have a 4x1 matrix */
   if ( nbRow * nbCol == 6 )
   {
-    //scizoom( getDoubleMatrixFromStack( stackPointer ), pobj ) ;
     return sciZoom3D(pobj, getDoubleMatrixFromStack(stackPointer));
   }
   else if( nbRow * nbCol == 4)
@@ -43,8 +42,7 @@ int set_zoom_box_property( sciPointObj * pobj, int stackPointer, int valueType,
   }
   else if ( nbCol * nbRow == 0 )
   {
-    sciUnzoom(pobj);
-    //unzoom() ;
+    sciUnzoom(&pobj, 1);
   }
   else
   {
index b3d3a14..a197c1a 100644 (file)
@@ -122,6 +122,12 @@ void iTranslate2D( int from[2], int trans[2], int dest[2] )
   dest[1] = from[1] + trans[1] ;
 }
 /*----------------------------------------------------------------------------*/
+void vectSubstract2D(const double vect1[2], const double vect2[], double res[2])
+{
+  res[0] = vect1[0] - vect2[0];
+  res[1] = vect1[1] - vect2[1];
+}
+/*----------------------------------------------------------------------------*/
 void normalize2d( double vect[2] )
 {
   double norm = NORM_2D(vect) ;
@@ -151,6 +157,34 @@ void normalize3D( double vect[3] )
   vect[2] /= norm ;
 }
 /*----------------------------------------------------------------------------*/
+void setToIdentity(double mat4D[4][4])
+{
+  int i;
+  int j;
+  for (i = 0; i < 4; i++)
+  {
+    for (j = 0; j < 4; j++)
+    {
+      mat4D[i][j] = 0.0;
+    }
+    mat4D[i][i] = 1.0;
+  }
+}
+/*----------------------------------------------------------------------------*/
+void mat4DMult(const double mat4D[4][4], const double vect3D[3], double res[3])
+{
+  int i;
+  double res4D[4];
+  // w coordinate of the vector is supposed to be 1;
+  for (i = 0; i < 4; i++) {
+    res4D[i]  =  vect3D[0] * mat4D[i][0] + vect3D[1] * mat4D[i][1]
+               + vect3D[2] * mat4D[i][2] + mat4D[i][3];
+  }
+  res[0] = res4D[0] / res4D[3];
+  res[1] = res4D[1] / res4D[3];
+  res[2] = res4D[2] / res4D[3];
+}
+/*----------------------------------------------------------------------------*/
 /* check if two values can be considered equal given an accurracy */
 int safeEqual( double val1, double val2, double accuracy )
 {
index eff45ac..fc0deeb 100644 (file)
@@ -91,3 +91,8 @@ ComputeNbSubTics
 sciGetIs3d
 sciGetGridStyle
 sciGetDisplayedDataBounds
+setToIdentity
+mat4DMult
+sciSetZoomBox
+vectSubstract2D
+sciGetXorMode
index 76b2e0d..bf75728 100644 (file)
@@ -50,10 +50,15 @@ BOOL sciGetJavaPixmapMode(sciPointObj * pFigure);
 void sciGetJavaPixelCoordinates(sciPointObj * pSubwin, const double userCoord[3], int pixCoord[2]);
 
 /**
-* Convert user Coordinate to pixel coordinates using 2d view.
-*/
+ * Convert user Coordinate to pixel coordinates using 2d view.
+ */
 void sciGetJava2dViewPixelCoordinates(sciPointObj * pSubwin, const double userCoord[3], int pixCoord[2]);
 
+/**
+ * Project 3d coordinates on the Default 2d plane
+ */
+void sciGetJava2dViewCoordinates(sciPointObj * pSubwin, const double userCoords3D[3], double userCoords2D[2]);
+
 #ifdef __cplusplus
 }
 #endif
index ec8a303..1bda180 100644 (file)
@@ -55,6 +55,11 @@ void sciSetJavaPixmapMode(sciPointObj * pFigure, BOOL onOrOff);
  */
 void sciSetJavaRenderingEnable(sciPointObj * pFigure, BOOL isEnable);
 
+/**
+ * Zoom a subwin object with the specified rectangle in pixels
+ */
+void sciJavaZoomRect(sciPointObj * pSubwin, int posX, int posY, int width, int height);
+
 #ifdef __cplusplus
 }
 #endif
index 01a832c..03942f6 100644 (file)
@@ -37,5 +37,7 @@ sciSetJavaWindowPosition
 sciSetJavaInfoMessage
 endFigureDataWriting
 startFigureDataWriting
+sciGetJava2dViewPixelCoordinates
+sciGetJava2dViewCoordinates
 ; --------------------------------------- 
 
index 1aba22b..baa799d 100644 (file)
@@ -55,3 +55,8 @@ void sciGetJava2dViewPixelCoordinates(sciPointObj * pSubwin, const double userCo
    getSubwinDrawer(pSubwin)->getCamera()->get2dViewPixelCoordinates(userCoord, pixCoord);
 }
 /*---------------------------------------------------------------------------------*/
+void sciGetJava2dViewCoordinates(sciPointObj * pSubwin, const double userCoords3D[3], double userCoords2D[2])
+{
+  getSubwinDrawer(pSubwin)->getCamera()->get2dViewCoordinates(userCoords3D, userCoords2D);
+}
+/*---------------------------------------------------------------------------------*/
index 58036a4..27be482 100644 (file)
@@ -9,6 +9,7 @@
 #include "SetJavaProperty.h"
 #include "getHandleDrawer.h"
 #include "figureDrawing/DrawableFigure.h"
+#include "subwinDrawing/DrawableSubwin.h"
 
 using namespace sciGraphics ;
 
@@ -48,3 +49,8 @@ void sciSetJavaRenderingEnable(sciPointObj * pFigure, BOOL isEnable)
   getFigureDrawer(pFigure)->setRenderingEnable(isEnable == TRUE);
 }
 /*---------------------------------------------------------------------------------*/
+void sciJavaZoomRect(sciPointObj * pSubwin, int posX, int posY, int width, int height)
+{
+  getSubwinDrawer(pSubwin)->getCamera()->zoomRect(posX, posY, width, height);
+}
+/*---------------------------------------------------------------------------------*/
\ No newline at end of file
index 26ab27d..bc5c8b4 100644 (file)
@@ -81,7 +81,7 @@ void DrawableFigure::closeRenderingCanvas( void )
 void DrawableFigure::drawInContext( void )
 {
   initializeDrawing() ;
-  setBackgroundColor() ;
+  setFigureParameters() ;
   if ( checkVisibility() )
   {
     displayChildren() ;
@@ -122,9 +122,9 @@ void DrawableFigure::setInfoMessage( const char * infoMessage )
   getFigureImp()->setInfoMessage(infoMessage) ;
 }
 /*---------------------------------------------------------------------------------*/
-void DrawableFigure::setBackgroundColor( void )
+void DrawableFigure::setFigureParameters( void )
 {
-  getFigureImp()->setBackgroundColor( sciGetGraphicContext(getDrawedObject())->backgroundcolor ) ;
+  getFigureImp()->setFigureParameters() ;
 }
 /*---------------------------------------------------------------------------------*/
 void DrawableFigure::getWindowPosition( int pos[2] )
index 5cbb0bc..3c4fff2 100644 (file)
@@ -155,7 +155,7 @@ protected:
   /**
    * Set the background color of the figure
    */
-  void setBackgroundColor( void ) ;
+  void setFigureParameters( void ) ;
 
   /*-----------------------------------------------------------------------------*/
   /** Synchronizer object used to protect data of the figure and its children */
index 363e499..3e4b315 100644 (file)
@@ -44,7 +44,7 @@ public:
   /**
    * Set the background color of the figure
    */
-  virtual void setBackgroundColor( int backgroundColor ) = 0 ;
+  virtual void setFigureParameters(void) = 0 ;
 
   /**
    * Set a new colormap to this figure
index 9bbcb24..ace9835 100644 (file)
@@ -68,9 +68,9 @@ void DrawableFigureJavaMapper::closeRenderingCanvas(void)
   m_pJavaObject->closeRenderingCanvas();
 }
 /*---------------------------------------------------------------------------------*/
-void DrawableFigureJavaMapper::setBackgroundColor(int backgroundColor)
+void DrawableFigureJavaMapper::setFigureParameters(int backgroundColor, int logicOpIndex)
 {
-  m_pJavaObject->setBackgroundColor(backgroundColor);
+  m_pJavaObject->setFigureParameters(backgroundColor, logicOpIndex);
 }
 /*---------------------------------------------------------------------------------*/
 void DrawableFigureJavaMapper::setColorMapData(const double rgbmat[], int nbColor)
@@ -147,27 +147,12 @@ void DrawableFigureJavaMapper::setInfoMessage(char * infoMessage)
 /*---------------------------------------------------------------------------------*/
 void DrawableFigureJavaMapper::setPixmapMode(bool onOrOff)
 {
-  if (onOrOff)
-  {
-    m_pJavaObject->setPixmapMode(1);
-  }
-  else
-  {
-    m_pJavaObject->setPixmapMode(0);
-  }
-  
+  m_pJavaObject->setPixmapMode(onOrOff);  
 }
 /*---------------------------------------------------------------------------------*/
 bool DrawableFigureJavaMapper::getPixmapMode(void)
 {
-  if (m_pJavaObject->getPixmapMode() == 0)
-  {
-    return false;
-  }
-  else
-  {
-    return true;
-  }
+ return m_pJavaObject->getPixmapMode();
 }
 /*---------------------------------------------------------------------------------*/
 void DrawableFigureJavaMapper::setRenderingEnable(bool isEnable)
index ad31357..992831e 100644 (file)
@@ -41,7 +41,7 @@ public:
 
   virtual void closeRenderingCanvas(void);
 
-  virtual void setBackgroundColor(int backgroundColor);
+  virtual void setFigureParameters(int backgroundColor, int logicOpIndex);
 
   virtual void setColorMapData(const double rgbmat[], int nbColor);
   virtual void getColorMapData(double rgbmat[]);
index 850b153..a1a2bb2 100644 (file)
@@ -57,9 +57,11 @@ void DrawableFigureJoGL::closeRenderingCanvas( void )
   }
 }
 /*---------------------------------------------------------------------------------*/
-void DrawableFigureJoGL::setBackgroundColor( int backgroundColor )
+void DrawableFigureJoGL::setFigureParameters(void)
 {
-  getFigureJavaMapper()->setBackgroundColor(backgroundColor);
+  sciPointObj * pFigure = getFigureDrawer()->getDrawedObject();
+  getFigureJavaMapper()->setFigureParameters(sciGetGraphicContext(pFigure)->backgroundcolor,
+                                             sciGetXorMode(pFigure));
 }
 /*---------------------------------------------------------------------------------*/
 void DrawableFigureJoGL::setColorMap( const double rgbMat[], int nbColor )
index 11ac2fb..149ee9c 100644 (file)
@@ -45,7 +45,7 @@ public:
   /**
    * Set the background color of the figure
    */
-  virtual void setBackgroundColor( int backgroundColor ) ;
+  virtual void setFigureParameters(void) ;
 
   /**
    * Set a new colormap to this figure
index 14623e2..2d99fad 100644 (file)
@@ -13,6 +13,7 @@ extern "C"
 {
 #include "math_graphics.h"
 #include "GetProperty.h"
+#include "SetProperty.h"
 }
 
 namespace sciGraphics
@@ -134,6 +135,21 @@ void Camera::get2dViewPixelCoordinates(const double userCoord[3], int pixCoord[2
   getCameraImp()->get2dViewPixelCoordinates(userCoord, pixCoord);
 }
 /*--------------------------------------------------------------------------*/
+void Camera::get2dViewCoordinates(const int pixCoords[2], double userCoord2D[2])
+{
+  getCameraImp()->get2dViewCoordinates(pixCoords, userCoord2D);
+}
+/*--------------------------------------------------------------------------*/
+void Camera::get2dViewCoordinates(const double userCoords[3], double coord2D[2])
+{
+  int pixCoords[2];
+  // convert usetr coords to pixel ones
+  getPixelCoordinates(userCoords, pixCoords);
+
+  // convert pixel ones to 2d frame ones
+  get2dViewCoordinates(pixCoords, coord2D);
+}
+/*--------------------------------------------------------------------------*/
 void Camera::draw( void )
 {
   initializeDrawing();
@@ -148,6 +164,113 @@ void Camera::show( void )
   getCameraImp()->show();
   endDrawing();
 }
+/*------------------------------------------------------------------------------------------*/
+void Camera::zoomRect(int posX, int posY, int width, int height)
+{
+  double rectCorners[4][2] = {{posX        , posY + height},
+                              {posX        , posY         },
+                              {posX + width, posY         },
+                              {posX + width, posY + height}};
+
+  zoomRect(rectCorners);
+
+}
+/*------------------------------------------------------------------------------------------*/
+void Camera::zoomRect(const double corners[4][2])
+{
+
+  double oldDataBounds[6];
+  double newDataBounds[6];
+
+  sciGetRealDataBounds(m_pDrawed, oldDataBounds);
+  
+  // x axis
+
+  // (xmin, ymin zmin)
+  double xAxisBound1[3] = {oldDataBounds[0], oldDataBounds[2], oldDataBounds[4]};
+  // (xmax, ymin zmin)
+  double xAxisBound2[3] = {oldDataBounds[1], oldDataBounds[2], oldDataBounds[4]};
+
+  getNewBounds(corners, xAxisBound1, xAxisBound2, oldDataBounds[0], oldDataBounds[1],
+               &(newDataBounds[0]), &(newDataBounds[1]));
+
+
+  // y axis
+
+  // (xmin, ymin zmin)
+  double yAxisBound1[3] = {oldDataBounds[0], oldDataBounds[2], oldDataBounds[4]};
+  // (xmin, ymax zmin)
+  double yAxisBound2[3] = {oldDataBounds[0], oldDataBounds[3], oldDataBounds[4]};
+
+  getNewBounds(corners, yAxisBound1, yAxisBound2, oldDataBounds[2], oldDataBounds[3],
+              &(newDataBounds[2]), &(newDataBounds[3]));
+
+  // x axis
+
+  // (xmin, ymin zmin)
+  double zAxisBound1[3] = {oldDataBounds[0], oldDataBounds[2], oldDataBounds[4]};
+  // (xmin, ymin zmax)
+  double zAxisBound2[3] = {oldDataBounds[0], oldDataBounds[2], oldDataBounds[5]};
+
+  getNewBounds(corners, zAxisBound1, zAxisBound2, oldDataBounds[4], oldDataBounds[5],
+               &(newDataBounds[4]), &(newDataBounds[5]));
+
+  sciSetZoomBox(m_pDrawed, newDataBounds);
+
+}
+/*------------------------------------------------------------------------------------------*/
+void Camera::getNewBounds(const double corners[4][2], const double axisPoint1[3], const double axisPoint2[3],
+                          double oldMinBound, double oldMaxBound, double * newMinBound, double * newMaxBound)
+{
+  // convert axis points into pixels
+  
+  int pixPoint[2];
+  getPixelCoordinates(axisPoint1, pixPoint);
+  double pixPoint1[2] = {pixPoint[0], pixPoint[1]};
+
+  getPixelCoordinates(axisPoint2, pixPoint);
+  double pixPoint2[2] = {pixPoint[0], pixPoint[1]};
+
+  // compute the distance between the two points
+  double p1p2[2];
+  vectSubstract2D(pixPoint2, pixPoint1, p1p2);
+  if (NORM_2D(p1p2) < 5.0)
+  {
+    // axes too short for projection
+    *newMinBound = oldMinBound;
+    *newMaxBound = oldMaxBound;
+    return;
+  }
+
+  getNewBoundsPix(corners, pixPoint1, pixPoint2, oldMinBound, oldMaxBound, newMinBound, newMaxBound);
+
+}
+/*------------------------------------------------------------------------------------------*/
+void Camera::getNewBoundsPix(const double corners[4][2], const double axisPoint1[2], const double axisPoint2[2],
+                             double oldMinBound, double oldMaxBound, double * newMinBound, double * newMaxBound)
+{
+  double axisVector[2];
+  vectSubstract2D(axisPoint2, axisPoint1, axisVector);
+
+  // get the projection of the four pixels on the axis
+  // for each compute its abscissa along the axis
+  // get the two extreme as new bounds
+  *newMinBound = oldMaxBound;
+  *newMaxBound = oldMinBound;
+  for (int i = 0; i < 4; i++)
+  {
+    double point1Corner[2];
+    vectSubstract2D(corners[i], axisPoint1, point1Corner);
+    // get the projection between 0 and 1
+    double proj = DOT_PROD_2D(axisVector, point1Corner) / SQUARE_NORM_2D(axisVector);
+
+    // then find its abscissa along the axis
+    double abscissa = (oldMaxBound - oldMinBound) * proj + oldMinBound;
+    
+    if (abscissa > *newMaxBound) { *newMaxBound = abscissa ;}
+    if (abscissa < *newMinBound) { *newMinBound = abscissa ;}
+  }
+}
 /*--------------------------------------------------------------------------*/
 CameraBridge * Camera::getCameraImp( void )
 {
@@ -155,5 +278,3 @@ CameraBridge * Camera::getCameraImp( void )
 }
 /*--------------------------------------------------------------------------*/
 }
-
-#undef FIT_WINDOW_RATIO
index 8dd30ab..ab9ac3f 100644 (file)
@@ -42,6 +42,15 @@ public:
    */
   void get2dViewPixelCoordinates(const double userCoord[3], int pixCoord[2]);
 
+  /**
+   * Find coordinates in 2D view from pixel ones
+   */
+  void get2dViewCoordinates(const int pixCoords[2], double userCoord2D[2]);
+
+  /**
+   * Find the projection of user coords on the 2D frame.
+   */
+  void get2dViewCoordinates(const double userCoords[3], double coord2D[2]);
 
   /**
    * Draw the graphic handle and store it representation in memory
@@ -55,6 +64,15 @@ public:
    */
   virtual void show( void );
 
+  /**
+   * Apply a zoom square on the axes box
+   * @param posX X coordinate of the lower left point of the zoom box in pixels.
+   * @param posY Y coordinate of the lower left point of the zoom box in pixels.
+   * @param width width of the zooming rectangle.
+   * @param height height of the zooming rectangle.
+   */
+  void zoomRect(int posX, int posY, int width, int height);
+
 protected:
 
   /**
@@ -92,6 +110,38 @@ protected:
   void renderPosition( void ) ;
 
   /**
+   * Apply a zoom square on the axes box
+   * @param corners the 4 corners of the zooming rectangle in pixel
+   */
+  void zoomRect(const double corners[4][2]);
+
+  /**
+   * Compute new bounds for one axis.
+   * @param corners coordinates of the zooming rectangle in pixels
+   * @param axisPoint1 coordinates of a point on the axis in user coordinates.
+   * @param axisPoint2 coordinate of an other point on the axis in user coordinates.
+   * @param minBound old minimum bound on the axis
+   * @param maxNound old maximum bound on the axis
+   * @param[out] newMinBound newly computed minimum bound
+   * @param[out] newMaxBound newly computed maximum bound.
+   */
+  void getNewBounds(const double corners[4][2], const double axisPoint1[3], const double axisPoint2[3],
+                   double oldMinBound, double oldMaxBound, double * newMinBound, double * newMaxBound);
+
+  /**
+   * Compute new bounds for one axis.
+   * @param corners coordinates of the zooming rectangle in pixels
+   * @param axisPoint1 coordinates of a point on the axis in pixels
+   * @param axisPoint2 coordinate of an other point on the axis in pixels
+   * @param minBound old minimum bound on the axis
+   * @param maxNound old maximum bound on the axis
+   * @param[out] newMinBound newly computed minimum bound
+   * @param[out] newMaxBound newly computed maximum bound.
+   */
+  void getNewBoundsPix(const double corners[4][2], const double axisPoint1[2], const double axisPoint2[2],
+                       double oldMinBound, double oldMaxBound, double * newMinBound, double * newMaxBound);
+
+  /**
    * Return the real type of implementation object
    */
   CameraBridge * getCameraImp( void ) ;
index 815e79a..3c254f0 100644 (file)
@@ -69,6 +69,11 @@ public:
   virtual void get2dViewPixelCoordinates(const double userCoord[3], int pixCoord[2]) = 0;
 
   /**
+   * Find coordinates in 2D view from pixel ones
+   */
+  virtual void get2dViewCoordinates(const int pixCoords[2], double userCoord2D[2]) = 0;
+
+  /**
    * Position the view and view area accordingly to previous calls.
    */
   virtual void renderPosition( void ) = 0 ;
index d55d3d0..a5287ae 100644 (file)
@@ -42,6 +42,21 @@ public:
 
   virtual void getPixelCoordinates(double userCoordX, double userCoordY, double userCoordZ, int pixCoord[2]) = 0;
   virtual void get2dViewPixelCoordinates(double userCoordX, double userCoordY, double userCoordZ, int pixCoord[2]) = 0;
+
+  virtual void getProjectionMatrix(double mat[4][4]) = 0;
+  virtual void getUnprojectMatrix(double mat[4][4]) = 0;
+  virtual void get2dViewProjectionMatrix(double mat[4][4]) = 0;
+  virtual void get2dViewUnprojectMatrix(double mat[4][4]) = 0;
+  virtual void getViewPort(double viewPort[4]) = 0;
+  /*----------------------------------------------------------------------*/
+  void convertMatrixFormat(const double src[16], double dest[4][4]) {
+    for (int i = 0; i < 4; i++) {
+      dest[i][0] = src[4 * i];
+      dest[i][1] = src[4 * i + 1];
+      dest[i][2] = src[4 * i + 2];
+      dest[i][3] = src[4 * i + 3];
+    }
+  }
   /*----------------------------------------------------------------------*/
 
 
index d218bea..561e9bb 100644 (file)
@@ -8,6 +8,11 @@
 #include "CameraJoGL.h"
 #include "DrawableSubwin.h"
 
+extern "C"
+{
+#include "math_graphics.h"
+}
+
 namespace sciGraphics
 {
 
@@ -15,7 +20,15 @@ namespace sciGraphics
 CameraJoGL::CameraJoGL( Camera * camera )
   : CameraBridge(), DrawableObjectJoGL(camera)
 {
+  setToIdentity(m_aProjMatrix2D);
+  setToIdentity(m_aProjMatrix3D);
+  setToIdentity(m_aUnprojMatrix2D);
+  setToIdentity(m_aUnprojMatrix3D);
 
+  m_aViewPort[0] = 0.0;
+  m_aViewPort[1] = 0.0;
+  m_aViewPort[2] = 0.0;
+  m_aViewPort[3] = 0.0;
 }
 /*--------------------------------------------------------------------------*/
 void CameraJoGL::renderPosition( void )
@@ -38,9 +51,38 @@ void CameraJoGL::renderPosition( void )
 /*--------------------------------------------------------------------------*/
 void CameraJoGL::replaceCamera( void )
 {
+  // save camera viewing settings
+  getCameraJavaMapper()->getProjectionMatrix(m_aProjMatrix3D);
+  getCameraJavaMapper()->getUnprojectMatrix(m_aUnprojMatrix3D);
+  getCameraJavaMapper()->get2dViewProjectionMatrix(m_aProjMatrix2D);
+  getCameraJavaMapper()->get2dViewUnprojectMatrix(m_aUnprojMatrix2D);
+  getCameraJavaMapper()->getViewPort(m_aViewPort);
+
+
   getCameraJavaMapper()->replaceCamera();
 }
 /*--------------------------------------------------------------------------*/
+void CameraJoGL::project(const double projMatrix[4][4], const double viewPort[4],
+                         const double sceneCoordinates[3], double pixCoordinates[3])
+{
+
+  mat4DMult(projMatrix, sceneCoordinates, pixCoordinates);
+  pixCoordinates[0] = viewPort[0] + viewPort[2] * (pixCoordinates[0] + 1.0) / 2.0;
+  pixCoordinates[1] = viewPort[1] + viewPort[3] * (pixCoordinates[1] + 1.0) / 2.0;
+  pixCoordinates[2] = (viewPort[2] + 1.0) / 2.0;
+}
+/*--------------------------------------------------------------------------*/
+void CameraJoGL::unProject(double unProjMatrix[4][4], double viewPort[4],
+                           const double pixCoordinates[3], double sceneCoordinates[3])
+{
+  double viewPix[3];
+  viewPix[0] = 2.0 * (pixCoordinates[0] - viewPort[0]) / viewPort[2] - 1.0;
+  viewPix[1] = 2.0 * (pixCoordinates[1] - viewPort[1]) / viewPort[3] - 1.0;
+  viewPix[2] = 2.0 * pixCoordinates[2] - 1.0;
+
+  mat4DMult(unProjMatrix, viewPix, sceneCoordinates);
+}
+/*--------------------------------------------------------------------------*/
 CameraJavaMapper * CameraJoGL::getCameraJavaMapper(void)
 {
   return dynamic_cast<CameraJavaMapper *>(getJavaMapper());
@@ -52,8 +94,14 @@ void CameraJoGL::getPixelCoordinates(const double userCoord[3], int pixCoord[2])
   // convert user coordinates to log scale if needed
   m_pDrawer->pointScale(userCoord[0], userCoord[1], userCoord[2],
                         &(finalUserCoord[0]), &(finalUserCoord[1]), (&finalUserCoord[2]));
-
-  getCameraJavaMapper()->getPixelCoordinates(finalUserCoord[0], finalUserCoord[1], finalUserCoord[2], pixCoord);
+  
+  // project point on the screen
+  double pixCoordsD[3];
+  project(m_aProjMatrix3D, m_aViewPort, finalUserCoord, pixCoordsD);
+  
+  // get the two pixels coordinates
+  pixCoord[0] = (int) pixCoordsD[0];
+  pixCoord[1] = (int) pixCoordsD[1];
 }
 /*--------------------------------------------------------------------------*/
 void CameraJoGL::get2dViewPixelCoordinates(const double userCoord[3], int pixCoord[2])
@@ -63,7 +111,24 @@ void CameraJoGL::get2dViewPixelCoordinates(const double userCoord[3], int pixCoo
   m_pDrawer->pointScale(userCoord[0], userCoord[1], userCoord[2],
                         &(finalUserCoord[0]), &(finalUserCoord[1]), (&finalUserCoord[2]));
 
-  getCameraJavaMapper()->get2dViewPixelCoordinates(finalUserCoord[0], finalUserCoord[1], finalUserCoord[2], pixCoord);
+  // project point on the screen
+  double pixCoordsD[3];
+  project(m_aProjMatrix2D, m_aViewPort, finalUserCoord, pixCoordsD);
+
+  // get the two pixels coordinates
+  pixCoord[0] = (int) pixCoordsD[0];
+  pixCoord[1] = (int) pixCoordsD[1];
+}
+/*--------------------------------------------------------------------------*/
+void CameraJoGL::get2dViewCoordinates(const int pixCoords[2], double userCoord2D[2])
+{
+  double pixCoordsD[3] = {pixCoords[0], pixCoords[1], 0.0};
+  double sceneCoords[3];
+  unProject(m_aUnprojMatrix2D, m_aViewPort, pixCoordsD, sceneCoords);
+
+  // convert user coordinates to log scale if needed
+  m_pDrawer->inversePointScale(sceneCoords[0], sceneCoords[1], sceneCoords[2],
+                               &(userCoord2D[0]), &(userCoord2D[1]), NULL);
 }
 /*--------------------------------------------------------------------------*/
 }
index a5fcf8e..a7ff9b4 100644 (file)
@@ -49,12 +49,45 @@ public:
    */
   virtual void get2dViewPixelCoordinates(const double userCoord[3], int pixCoord[2]);
 
+  /**
+   * Find coordinates in 2D view from pixel ones
+   */
+  virtual void get2dViewCoordinates(const int pixCoords[2], double userCoord2D[2]);
+
 protected:
 
+  /*----------------------------------------------------------------*/
+
+  /**
+   * Get the projection of a point on the canvas.
+   */
+  void project(const double projMatrix[4][4], const double viewPort[4],
+               const double sceneCoordinate[3], double pixCoordinate[3]);
+
+  /**
+   * Retrieve the position of a point from its coordinates on the canvas.
+   */
+  void unProject(double unProjMatrix[4][4], double viewPort[4],
+                 const double pixCoordinates[3], double sceneCoordinates[3]);
+
   /**
    * Get the object performing mapping with Java class.
    */
   CameraJavaMapper * getCameraJavaMapper(void);
+  /*----------------------------------------------------------------*/
+  /** Projection matrix in current coordinates frame */
+  double m_aProjMatrix3D[4][4];
+  /** inverse of projection matrix in current coordinates frame */
+  double m_aUnprojMatrix3D[4][4];
+
+  /** Projection matrix fro 2D projection */
+  double m_aProjMatrix2D[4][4];
+  /** Inverse of projMatrix2D */
+  double m_aUnprojMatrix2D[4][4];
+
+  /** Current viewPort */
+  double m_aViewPort[4];
+  /*----------------------------------------------------------------*/
 
 };
 
index 8b067a7..6b884df 100644 (file)
@@ -69,6 +69,7 @@ public:
                               double startingPointsX[], double startingPointsY[],
                               double startingPointsZ[], double vectorLength);
 
+
 protected:
 
   /*---------------------------------------------------------------------*/
index ce3a592..6918f70 100644 (file)
@@ -115,5 +115,42 @@ void IsoViewCameraJavaMapper::get2dViewPixelCoordinates(double userCoordX, doubl
   delete[] javaCoords;
 }
 /*--------------------------------------------------------------------------*/
-
+void IsoViewCameraJavaMapper::getProjectionMatrix(double mat[4][4])
+{
+  double * matArray = m_pJavaObject->getProjectionMatrix();
+  convertMatrixFormat(matArray, mat);
+  delete[] matArray;
+}
+/*--------------------------------------------------------------------------*/
+void IsoViewCameraJavaMapper::getUnprojectMatrix(double mat[4][4])
+{
+  double * matArray = m_pJavaObject->getUnprojectMatrix();
+  convertMatrixFormat(matArray, mat);
+  delete[] matArray;
+}
+/*--------------------------------------------------------------------------*/
+void IsoViewCameraJavaMapper::get2dViewProjectionMatrix(double mat[4][4])
+{
+  double * matArray = m_pJavaObject->get2dViewProjectionMatrix();
+  convertMatrixFormat(matArray, mat);
+  delete[] matArray;
+}
+/*--------------------------------------------------------------------------*/
+void IsoViewCameraJavaMapper::get2dViewUnprojectMatrix(double mat[4][4])
+{
+  double * matArray = m_pJavaObject->get2dViewUnprojectMatrix();
+  convertMatrixFormat(matArray, mat);
+  delete[] matArray;
+}
+/*--------------------------------------------------------------------------*/
+void IsoViewCameraJavaMapper::getViewPort(double viewPort[4])
+{
+  double * javaViewPort = m_pJavaObject->getViewPort();
+  viewPort[0] = javaViewPort[0];
+  viewPort[1] = javaViewPort[1];
+  viewPort[2] = javaViewPort[2];
+  viewPort[3] = javaViewPort[3];
+  delete[] javaViewPort;
+}
+/*--------------------------------------------------------------------------*/
 }
index 0ec588b..e81da1f 100644 (file)
@@ -55,6 +55,12 @@ public:
 
   virtual void getPixelCoordinates(double userCoordX, double userCoordY, double userCoordZ, int pixCoord[2]);
   virtual void get2dViewPixelCoordinates(double userCoordX, double userCoordY, double userCoordZ, int pixCoord[2]);
+
+  virtual void getProjectionMatrix(double mat[4][4]);
+  virtual void getUnprojectMatrix(double mat[4][4]);
+  virtual void get2dViewProjectionMatrix(double mat[4][4]);
+  virtual void get2dViewUnprojectMatrix(double mat[4][4]);
+  virtual void getViewPort(double viewPort[4]);
   /*----------------------------------------------------------------------*/
 
 private:
index ca96781..11b1d12 100644 (file)
@@ -114,5 +114,42 @@ void IsometricCameraJavaMapper::get2dViewPixelCoordinates(double userCoordX, dou
   delete[] javaCoords;
 }
 /*--------------------------------------------------------------------------*/
-
+void IsometricCameraJavaMapper::getProjectionMatrix(double mat[4][4])
+{
+  double * matArray = m_pJavaObject->getProjectionMatrix();
+  convertMatrixFormat(matArray, mat);
+  delete[] matArray;
+}
+/*--------------------------------------------------------------------------*/
+void IsometricCameraJavaMapper::getUnprojectMatrix(double mat[4][4])
+{
+  double * matArray = m_pJavaObject->getUnprojectMatrix();
+  convertMatrixFormat(matArray, mat);
+  delete[] matArray;
+}
+/*--------------------------------------------------------------------------*/
+void IsometricCameraJavaMapper::get2dViewProjectionMatrix(double mat[4][4])
+{
+  double * matArray = m_pJavaObject->get2dViewProjectionMatrix();
+  convertMatrixFormat(matArray, mat);
+  delete[] matArray;
+}
+/*--------------------------------------------------------------------------*/
+void IsometricCameraJavaMapper::get2dViewUnprojectMatrix(double mat[4][4])
+{
+  double * matArray = m_pJavaObject->get2dViewUnprojectMatrix();
+  convertMatrixFormat(matArray, mat);
+  delete[] matArray;
+}
+/*--------------------------------------------------------------------------*/
+void IsometricCameraJavaMapper::getViewPort(double viewPort[4])
+{
+  double * javaViewPort = m_pJavaObject->getViewPort();
+  viewPort[0] = javaViewPort[0];
+  viewPort[1] = javaViewPort[1];
+  viewPort[2] = javaViewPort[2];
+  viewPort[3] = javaViewPort[3];
+  delete[] javaViewPort;
+}
+/*--------------------------------------------------------------------------*/
 }
index fafa65e..ee00b0f 100644 (file)
@@ -54,6 +54,12 @@ public:
 
   virtual void getPixelCoordinates(double userCoordX, double userCoordY, double userCoordZ, int pixCoord[2]);
   virtual void get2dViewPixelCoordinates(double userCoordX, double userCoordY, double userCoordZ, int pixCoord[2]);
+
+  virtual void getProjectionMatrix(double mat[4][4]);
+  virtual void getUnprojectMatrix(double mat[4][4]);
+  virtual void get2dViewProjectionMatrix(double mat[4][4]);
+  virtual void get2dViewUnprojectMatrix(double mat[4][4]);
+  virtual void getViewPort(double viewPort[4]);
   /*----------------------------------------------------------------------*/
 
 private:
index bd713f0..bd828d3 100644 (file)
@@ -25,6 +25,24 @@ import org.scilab.modules.renderer.ObjectGLCleaner;
  */
 public class DrawableFigureGL extends ObjectGL {
        
+       /** Mapping between scilab pixel drawing mode and OpenGL ones */
+       private static final int[] LOGICAL_OPS = {GL.GL_CLEAR,
+                                                                                         GL.GL_AND,
+                                                                                         GL.GL_AND_REVERSE,
+                                                                                         GL.GL_COPY,
+                                                                                         GL.GL_AND_INVERTED,
+                                                                                         GL.GL_NOOP,
+                                                                                         GL.GL_XOR,
+                                                                                         GL.GL_OR,
+                                                                                         GL.GL_NOR,
+                                                                                         GL.GL_EQUIV,
+                                                                                         GL.GL_INVERT,
+                                                                                         GL.GL_OR_REVERSE,
+                                                                                         GL.GL_COPY_INVERTED,
+                                                                                         GL.GL_OR_INVERTED,
+                                                                                         GL.GL_NAND,
+                                                                                         GL.GL_SET};
+       
        /** Canvas to draw the figure */
        private RendererProperties guiProperties;
        /** store the figureIndex */
@@ -35,6 +53,8 @@ public class DrawableFigureGL extends ObjectGL {
        /** To know if the figure can be displayed */
        private boolean isReadyForRendering;
        
+       private boolean pixmapModeOn;
+       
        /**
         * Default Constructor
         */
@@ -45,6 +65,7 @@ public class DrawableFigureGL extends ObjectGL {
        figureId = -1; // figure ids should be greater than 0.
        destroyedObjects = new ObjectGLCleaner();
        isReadyForRendering = false;
+       pixmapModeOn = true;
     }
        
        /**
@@ -199,12 +220,31 @@ public class DrawableFigureGL extends ObjectGL {
        
        /**
         * Set the background color of the figure
-        * @param colorIndex index of the colro to use
+        * @param colorIndex index of the color to use
         */
        public void setBackgroundColor(int colorIndex) {
                double[] color = getColorMap().getColor(colorIndex);
-               getGL().glClearColor((float) color[0], (float) color[1], (float) color[2], 1.0f); // alpha is set to 1
-               getGL().glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+               getGL().glClearColor((float) color[0], (float) color[1], (float) color[2], 1.0f); // alpha is set to 1
+       }
+       
+       
+       /**
+     * Set the pixel drawing mode of the figure.
+        * @param logicOpIndex Scilab value of pixel drawing mode
+        */
+       public void setLogicalOp(int logicOpIndex) {
+               // convert to OpenGL value
+               getGL().glLogicOp(LOGICAL_OPS[logicOpIndex]);
+       }
+       
+       /**
+        * Set all figure parameters in one time
+        * @param backgroundColor index of the background color
+        * @param logicOpIndex Scilab value of pixel drawing mode
+        */
+       public void setFigureParameters(int backgroundColor, int logicOpIndex) {
+               setLogicalOp(logicOpIndex);
+               setBackgroundColor(backgroundColor);
        }
        
        /**
@@ -304,36 +344,14 @@ public class DrawableFigureGL extends ObjectGL {
         * @param onOrOff specify if we set the pixmap on or off
         */
        public void setPixmapMode(boolean onOrOff) {
-               
+               pixmapModeOn = onOrOff;
        }
        
        /**
         * @return wether the pixmap mode is on ar off.
         */
-       public boolean getPixmapModeB() {
-               return false;
-       }
-       
-       /**
-        * @param onOrOff if 0 set pixmap mode to false, otherwise set it to true.
-        */
-       public void setPixmapMode(int onOrOff) {
-               if (onOrOff == 0) {
-                       setPixmapMode(false);
-               } else {
-                       setPixmapMode(true);
-               }
-       }
-       
-       /**
-        * @return 0 if pixmap mode is false, 1 otherwise.
-        */
-       public int getPixmapMode() {
-               if (getPixmapModeB()) {
-                       return 1;
-               } else {
-                       return 0;
-               }
+       public boolean getPixmapMode() {
+               return pixmapModeOn;
        }
        
        
index 273f360..5742493 100644 (file)
@@ -41,10 +41,17 @@ public class SciRenderer
    * @param gLDrawable The GLDrawable object.
    */    
   public void display(GLAutoDrawable gLDrawable) {
+       //gLDrawable.setAutoSwapBufferMode(false);
+       DrawableFigureGL curFigure = FigureMapper.getCorrespondingFigure(renderedFigure);
     // should call the draw function of the corresponding figure
-       if (FigureMapper.getCorrespondingFigure(renderedFigure).getIsRenderingEnable()) {
+       if (curFigure.getIsRenderingEnable()) {
                FigureScilabCall.displayFigure(renderedFigure);
        }
+       
+       // seems that buffers will be swaped any way with GLJPanel
+       if (!gLDrawable.getAutoSwapBufferMode()) {
+               gLDrawable.swapBuffers();
+       }
 
   }
     
@@ -62,6 +69,7 @@ public class SciRenderer
    * @param gLDrawable The GLDrawable object.
    */
   public void init(GLAutoDrawable gLDrawable) {
+         gLDrawable.setAutoSwapBufferMode(false);
          DrawableFigureGL curFigure = FigureMapper.getCorrespondingFigure(renderedFigure);
       if (curFigure.getIsRenderingEnable()) {
          FigureMapper.getCorrespondingFigure(renderedFigure).getColorMap().clearTexture();
@@ -73,8 +81,9 @@ public class SciRenderer
       gl.glClearDepth(1.0f);                      // Depth Buffer Setup
       gl.glEnable(GL.GL_DEPTH_TEST);                                                   // Enables Depth Testing
       gl.glDepthFunc(GL.GL_LEQUAL);                                                            // The Type Of Depth Testing To Do
-      gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_FASTEST);     // Really Nice Perspective Calculations
+      gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_FASTEST);     // Really fast
       gl.glDisable(GL.GL_LINE_SMOOTH); // we prefer thin lines
+         gl.glEnable(GL.GL_COLOR_LOGIC_OP); // to use pixel drawing mode
 
     }
     
index 0a6d83d..e045c8a 100644 (file)
@@ -369,6 +369,47 @@ public abstract class CameraGL extends ObjectGL {
        }
        
        /**
+        * @return array of size 16 containing the current projection matrix
+        */
+       public double[] getProjectionMatrix() {
+               return CoordinateTransformation.getTransformation(getGL()).getProjectionMatrix().getRowWiseRepresentation();
+       }
+       
+       /**
+        * @return array of size 16 containing the inverse of projection matrix.
+        */
+       public double[] getUnprojectMatrix() {
+               return CoordinateTransformation.getTransformation(getGL()).getUnprojectMatrix().getRowWiseRepresentation();
+       }
+       
+       /**
+        * @return array of size 16 containing the projection matrix for 2d view.
+        */
+       public double[] get2dViewProjectionMatrix() {
+               switchTo2DCoordinates();
+               double[] res = getProjectionMatrix();
+               backTo3DCoordinates();
+               return res;
+       }
+       
+       /**
+        * @return array of size 16 containing the inverse of projection matrix for 2d view.
+        */
+       public double[] get2dViewUnprojectMatrix() {
+               switchTo2DCoordinates();
+               double[] res = getUnprojectMatrix();
+               backTo3DCoordinates();
+               return res;
+       }
+       
+       /**
+        * @return Array of size 4 containing the viewPort.
+        */
+       public double[] getViewPort() {
+               return CoordinateTransformation.getTransformation(getGL()).getViewPort();
+       }
+       
+       /**
         * Move the camera to the default 2D coordinates.
         * Try to avoid to use this method, but it sometime needed
         * for backward compatibility with old renderer.
index 8252ddf..0bad0f9 100644 (file)
@@ -224,6 +224,8 @@ public abstract class TextContentDrawerGL extends DrawableObjectGL implements Te
        public void drawTextContent() {
                
                GL gl = getGL();
+               gl.glDisable(GL.GL_COLOR_LOGIC_OP); // does not work well with thext rendering
+               
                CoordinateTransformation transform = CoordinateTransformation.getTransformation(gl);
 
                Vector3D textCenterPix = transform.getCanvasCoordinates(gl, getTextCenter());
@@ -238,6 +240,8 @@ public abstract class TextContentDrawerGL extends DrawableObjectGL implements Te
                
                GLTools.endPixelCoordinates(gl);
                
+               gl.glEnable(GL.GL_COLOR_LOGIC_OP); // does not work well with thext rendering
+               
        }
        
        /**
index 196b160..ded43e5 100644 (file)
@@ -57,6 +57,27 @@ public class CoordinateTransformation {
        }
        
        /**
+        * @return current projection matrix
+        */
+       public Matrix4D getProjectionMatrix() {
+               return projectMatrix;
+       }
+       
+       /**
+        * @return current inverse of projection matrix
+        */
+       public Matrix4D getUnprojectMatrix() {
+               return unprojectMatrix;
+       }
+       
+       /**
+        * @return current viewPort
+        */
+       public double[] getViewPort() {
+               return viewPort;
+       }
+       
+       /**
         * Update the projection data of the coordinates.
         * @param gl current Gl pipeline
         */
index df8818b..8ed23b9 100644 (file)
@@ -16,6 +16,8 @@ package org.scilab.modules.renderer.utils.geom3D;
  */
 public class Matrix4D {
 
+       private static final String COMMA = ", ";
+       
        private static final int MATRIX_SIZE = 4;
        private static final int MATRIX_NB_ELEMENTS = MATRIX_SIZE * MATRIX_SIZE;
        
@@ -112,6 +114,21 @@ public class Matrix4D {
        }
        
        /**
+        * @return an array of size 16, stored row wise.
+        */
+       public double[] getRowWiseRepresentation() {
+               double[] res = new double[MATRIX_NB_ELEMENTS];
+               
+               for (int i = 0; i < MATRIX_SIZE; i++) {
+                       res[MATRIX_SIZE * i] = values[i][0];
+                       res[MATRIX_SIZE * i + 1] = values[i][1];
+                       res[MATRIX_SIZE * i + 2] = values[i][2];
+                       res[MATRIX_SIZE * i + MATRIX_SIZE - 1] = values[i][MATRIX_SIZE - 1];
+               }
+               return res;
+       }
+       
+       /**
         * Change an element of the matrix
         * @param numRow index of the element row
         * @param numCol index of the element column
@@ -307,10 +324,9 @@ public class Matrix4D {
         * @return text of the matrix
         */
        public String toString() {
-               final String comma = ", ";
                String res = new String();
                for (int i = 0; i < MATRIX_SIZE; i++) {
-                       res += "[" + values[i][0] + comma + values[i][1] + comma + values[i][2] + comma + values[i][MATRIX_SIZE - 1] + "]" + "\n";
+                       res += "[" + values[i][0] + COMMA + values[i][1] + COMMA + values[i][2] + COMMA + values[i][MATRIX_SIZE - 1] + "]" + "\n";
                }
                return res;
        }
index 8aa1f03..8ee5a81 100644 (file)
@@ -1,5 +1,5 @@
 #include "DrawableFigureGL.hxx"
-/* Generated by GIWS (version 0.9.8) */
+/* Generated by GIWS (version 0.9.9) */
 /*
 
 Copyright 2007 INRIA
@@ -104,7 +104,7 @@ voiddestroyjintID=NULL;
 voidsetFigureIndexjintID=NULL; 
 voiddrawCanvasID=NULL; 
 voidcloseRenderingCanvasID=NULL; 
-voidsetBackgroundColorjintID=NULL; 
+voidsetFigureParametersjintjintID=NULL; 
 voidsetColorMapDatajdoubleArrayID=NULL; 
 jdoubleArraygetColorMapDataID=NULL; 
 jintgetColorMapSizeID=NULL; 
@@ -118,8 +118,8 @@ jintgetWindowWidthID=NULL;
 jintgetWindowHeightID=NULL; 
 voidsetWindowSizejintjintID=NULL; 
 voidsetInfoMessagejstringID=NULL; 
-voidsetPixmapModejintID=NULL; 
-jintgetPixmapModeID=NULL; 
+voidsetPixmapModejbooleanID=NULL; 
+jbooleangetPixmapModeID=NULL; 
 voidsetIsRenderingEnablejbooleanID=NULL; 
 
 
@@ -150,7 +150,7 @@ voiddestroyjintID=NULL;
 voidsetFigureIndexjintID=NULL; 
 voiddrawCanvasID=NULL; 
 voidcloseRenderingCanvasID=NULL; 
-voidsetBackgroundColorjintID=NULL; 
+voidsetFigureParametersjintjintID=NULL; 
 voidsetColorMapDatajdoubleArrayID=NULL; 
 jdoubleArraygetColorMapDataID=NULL; 
 jintgetColorMapSizeID=NULL; 
@@ -164,8 +164,8 @@ jintgetWindowWidthID=NULL;
 jintgetWindowHeightID=NULL; 
 voidsetWindowSizejintjintID=NULL; 
 voidsetInfoMessagejstringID=NULL; 
-voidsetPixmapModejintID=NULL; 
-jintgetPixmapModeID=NULL; 
+voidsetPixmapModejbooleanID=NULL; 
+jbooleangetPixmapModeID=NULL; 
 voidsetIsRenderingEnablejbooleanID=NULL; 
 
 
@@ -351,18 +351,18 @@ curEnv->ExceptionDescribe() ;
                         
 }
 
-void DrawableFigureGL::setBackgroundColor (long backgroundColor){
+void DrawableFigureGL::setFigureParameters (long backgroundColor, long logicOpIndex){
 
 JNIEnv * curEnv = getCurrentEnv();
 jclass cls = curEnv->FindClass( className().c_str() );
 
-jmethodID voidsetBackgroundColorjintID = curEnv->GetMethodID(this->instanceClass, "setBackgroundColor", "(I)V" ) ;
-if (voidsetBackgroundColorjintID == NULL) {
-std::cerr << "Could not access to the method " << "setBackgroundColor" << std::endl;
+jmethodID voidsetFigureParametersjintjintID = curEnv->GetMethodID(this->instanceClass, "setFigureParameters", "(II)V" ) ;
+if (voidsetFigureParametersjintjintID == NULL) {
+std::cerr << "Could not access to the method " << "setFigureParameters" << std::endl;
 exit(EXIT_FAILURE);
 }
 
-                         curEnv->CallVoidMethod( this->instance, voidsetBackgroundColorjintID ,backgroundColor);
+                         curEnv->CallVoidMethod( this->instance, voidsetFigureParametersjintjintID ,backgroundColor, logicOpIndex);
                         
 if (curEnv->ExceptionOccurred()) {
 curEnv->ExceptionDescribe() ;
@@ -664,18 +664,20 @@ curEnv->ExceptionDescribe() ;
                         
 }
 
-void DrawableFigureGL::setPixmapMode (long onOrOff){
+void DrawableFigureGL::setPixmapMode (bool onOrOff){
 
 JNIEnv * curEnv = getCurrentEnv();
 jclass cls = curEnv->FindClass( className().c_str() );
 
-jmethodID voidsetPixmapModejintID = curEnv->GetMethodID(this->instanceClass, "setPixmapMode", "(I)V" ) ;
-if (voidsetPixmapModejintID == NULL) {
+jmethodID voidsetPixmapModejbooleanID = curEnv->GetMethodID(this->instanceClass, "setPixmapMode", "(Z)V" ) ;
+if (voidsetPixmapModejbooleanID == NULL) {
 std::cerr << "Could not access to the method " << "setPixmapMode" << std::endl;
 exit(EXIT_FAILURE);
 }
 
-                         curEnv->CallVoidMethod( this->instance, voidsetPixmapModejintID ,onOrOff);
+jboolean onOrOff_ = ((bool) onOrOff ? JNI_TRUE : JNI_FALSE);
+
+                         curEnv->CallVoidMethod( this->instance, voidsetPixmapModejbooleanID ,onOrOff_);
                         
 if (curEnv->ExceptionOccurred()) {
 curEnv->ExceptionDescribe() ;
@@ -684,25 +686,25 @@ curEnv->ExceptionDescribe() ;
                         
 }
 
-long DrawableFigureGL::getPixmapMode (){
+bool DrawableFigureGL::getPixmapMode (){
 
 JNIEnv * curEnv = getCurrentEnv();
 jclass cls = curEnv->FindClass( className().c_str() );
 
-jmethodID jintgetPixmapModeID = curEnv->GetMethodID(this->instanceClass, "getPixmapMode", "()I" ) ;
-if (jintgetPixmapModeID == NULL) {
+jmethodID jbooleangetPixmapModeID = curEnv->GetMethodID(this->instanceClass, "getPixmapMode", "()Z" ) ;
+if (jbooleangetPixmapModeID == NULL) {
 std::cerr << "Could not access to the method " << "getPixmapMode" << std::endl;
 exit(EXIT_FAILURE);
 }
 
-                        jint res =  (jint) curEnv->CallIntMethod( this->instance, jintgetPixmapModeID );
+                        jboolean res =  (jboolean) curEnv->CallBooleanMethod( this->instance, jbooleangetPixmapModeID );
                         
 if (curEnv->ExceptionOccurred()) {
 curEnv->ExceptionDescribe() ;
 }
 
                         
-return res;
+return (res == JNI_TRUE);
 
 }
 
index 0be30b2..e08c322 100644 (file)
@@ -20,8 +20,9 @@
     </method>
     <method name="closeRenderingCanvas" returnType="void">
     </method>
-    <method name="setBackgroundColor" returnType="void">
+    <method name="setFigureParameters" returnType="void">
       <param type="int" name="backgroundColor" />
+      <param type="int" name="logicOpIndex" />
     </method>
     <method name="setColorMapData" returnType="void">
       <param type="double[]" name="rgbmat" />
@@ -58,9 +59,9 @@
       <param type="String" name="infoMessage" />
     </method>
     <method name="setPixmapMode" returnType="void">
-      <param type="int" name="onOrOff" />
+      <param type="boolean" name="onOrOff" />
     </method>
-    <method name="getPixmapMode" returnType="int">
+    <method name="getPixmapMode" returnType="boolean">
     </method>
     <method name="setIsRenderingEnable" returnType="void">
       <param type="boolean" name="isEnable" />
index d4ada80..444fd23 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by GIWS (version 0.9.8) */
+/* Generated by GIWS (version 0.9.9) */
 /*
 
 Copyright 2007 INRIA
@@ -60,7 +60,7 @@ jmethodID voiddestroyjintID; // cache method id
 jmethodID voidsetFigureIndexjintID; // cache method id
 jmethodID voiddrawCanvasID; // cache method id
 jmethodID voidcloseRenderingCanvasID; // cache method id
-jmethodID voidsetBackgroundColorjintID; // cache method id
+jmethodID voidsetFigureParametersjintjintID; // cache method id
 jmethodID voidsetColorMapDatajdoubleArrayID; // cache method id
 jmethodID jdoubleArraygetColorMapDataID; // cache method id
 jmethodID jintgetColorMapSizeID; // cache method id
@@ -74,8 +74,8 @@ jmethodID jintgetWindowWidthID; // cache method id
 jmethodID jintgetWindowHeightID; // cache method id
 jmethodID voidsetWindowSizejintjintID; // cache method id
 jmethodID voidsetInfoMessagejstringID; // cache method id
-jmethodID voidsetPixmapModejintID; // cache method id
-jmethodID jintgetPixmapModeID; // cache method id
+jmethodID voidsetPixmapModejbooleanID; // cache method id
+jmethodID jbooleangetPixmapModeID; // cache method id
 jmethodID voidsetIsRenderingEnablejbooleanID; // cache method id
 
 
@@ -134,7 +134,7 @@ void drawCanvas();
 
 void closeRenderingCanvas();
 
-void setBackgroundColor(long backgroundColor);
+void setFigureParameters(long backgroundColor, long logicOpIndex);
 
 void setColorMapData(double * rgbmat, int rgbmatSize);
 
@@ -162,9 +162,9 @@ void setWindowSize(long width, long height);
 
 void setInfoMessage(char * infoMessage);
 
-void setPixmapMode(long onOrOff);
+void setPixmapMode(bool onOrOff);
 
-long getPixmapMode();
+bool getPixmapMode();
 
 void setIsRenderingEnable(bool isEnable);
 
index 8581e95..062cc1a 100644 (file)
@@ -1,5 +1,5 @@
 #include "IsoViewCameraGL.hxx"
-/* Generated by GIWS (version 0.9.8) */
+/* Generated by GIWS (version 0.9.9) */
 /*
 
 Copyright 2007 INRIA
@@ -111,6 +111,11 @@ voidreplaceCameraID=NULL;
 voidsetAxesReversejbooleanjbooleanjbooleanID=NULL; 
 jintArraygetPixelCoordinatesjdoublejdoublejdoubleID=NULL; 
 jintArrayget2dViewPixelCoordinatesjdoublejdoublejdoubleID=NULL; 
+jdoubleArraygetProjectionMatrixID=NULL; 
+jdoubleArraygetUnprojectMatrixID=NULL; 
+jdoubleArrayget2dViewProjectionMatrixID=NULL; 
+jdoubleArrayget2dViewUnprojectMatrixID=NULL; 
+jdoubleArraygetViewPortID=NULL; 
 
 
 }
@@ -147,6 +152,11 @@ voidreplaceCameraID=NULL;
 voidsetAxesReversejbooleanjbooleanjbooleanID=NULL; 
 jintArraygetPixelCoordinatesjdoublejdoublejdoubleID=NULL; 
 jintArrayget2dViewPixelCoordinatesjdoublejdoublejdoubleID=NULL; 
+jdoubleArraygetProjectionMatrixID=NULL; 
+jdoubleArraygetUnprojectMatrixID=NULL; 
+jdoubleArrayget2dViewProjectionMatrixID=NULL; 
+jdoubleArrayget2dViewUnprojectMatrixID=NULL; 
+jdoubleArraygetViewPortID=NULL; 
 
 
 }
@@ -505,4 +515,174 @@ return myArray;
 
 }
 
+double * IsoViewCameraGL::getProjectionMatrix (){
+
+JNIEnv * curEnv = getCurrentEnv();
+jclass cls = curEnv->FindClass( className().c_str() );
+
+jmethodID jdoubleArraygetProjectionMatrixID = curEnv->GetMethodID(this->instanceClass, "getProjectionMatrix", "()[D" ) ;
+if (jdoubleArraygetProjectionMatrixID == NULL) {
+std::cerr << "Could not access to the method " << "getProjectionMatrix" << std::endl;
+exit(EXIT_FAILURE);
+}
+
+                        jdoubleArray res =  (jdoubleArray) curEnv->CallObjectMethod( this->instance, jdoubleArraygetProjectionMatrixID );
+                        
+if (curEnv->ExceptionOccurred()) {
+curEnv->ExceptionDescribe() ;
+}
+
+                        
+jsize len = curEnv->GetArrayLength(res);
+jboolean isCopy = JNI_FALSE;
+
+/* faster than getXXXArrayElements */
+jdouble *resultsArray = (jdouble *) curEnv->GetPrimitiveArrayCritical(res, &isCopy);
+double * myArray= new double[len];
+
+for (jsize i = 0; i < len; i++){
+myArray[i]=resultsArray[i];
+}
+curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+return myArray;
+
+}
+
+double * IsoViewCameraGL::getUnprojectMatrix (){
+
+JNIEnv * curEnv = getCurrentEnv();
+jclass cls = curEnv->FindClass( className().c_str() );
+
+jmethodID jdoubleArraygetUnprojectMatrixID = curEnv->GetMethodID(this->instanceClass, "getUnprojectMatrix", "()[D" ) ;
+if (jdoubleArraygetUnprojectMatrixID == NULL) {
+std::cerr << "Could not access to the method " << "getUnprojectMatrix" << std::endl;
+exit(EXIT_FAILURE);
+}
+
+                        jdoubleArray res =  (jdoubleArray) curEnv->CallObjectMethod( this->instance, jdoubleArraygetUnprojectMatrixID );
+                        
+if (curEnv->ExceptionOccurred()) {
+curEnv->ExceptionDescribe() ;
+}
+
+                        
+jsize len = curEnv->GetArrayLength(res);
+jboolean isCopy = JNI_FALSE;
+
+/* faster than getXXXArrayElements */
+jdouble *resultsArray = (jdouble *) curEnv->GetPrimitiveArrayCritical(res, &isCopy);
+double * myArray= new double[len];
+
+for (jsize i = 0; i < len; i++){
+myArray[i]=resultsArray[i];
+}
+curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+return myArray;
+
+}
+
+double * IsoViewCameraGL::get2dViewProjectionMatrix (){
+
+JNIEnv * curEnv = getCurrentEnv();
+jclass cls = curEnv->FindClass( className().c_str() );
+
+jmethodID jdoubleArrayget2dViewProjectionMatrixID = curEnv->GetMethodID(this->instanceClass, "get2dViewProjectionMatrix", "()[D" ) ;
+if (jdoubleArrayget2dViewProjectionMatrixID == NULL) {
+std::cerr << "Could not access to the method " << "get2dViewProjectionMatrix" << std::endl;
+exit(EXIT_FAILURE);
+}
+
+                        jdoubleArray res =  (jdoubleArray) curEnv->CallObjectMethod( this->instance, jdoubleArrayget2dViewProjectionMatrixID );
+                        
+if (curEnv->ExceptionOccurred()) {
+curEnv->ExceptionDescribe() ;
+}
+
+                        
+jsize len = curEnv->GetArrayLength(res);
+jboolean isCopy = JNI_FALSE;
+
+/* faster than getXXXArrayElements */
+jdouble *resultsArray = (jdouble *) curEnv->GetPrimitiveArrayCritical(res, &isCopy);
+double * myArray= new double[len];
+
+for (jsize i = 0; i < len; i++){
+myArray[i]=resultsArray[i];
+}
+curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+return myArray;
+
+}
+
+double * IsoViewCameraGL::get2dViewUnprojectMatrix (){
+
+JNIEnv * curEnv = getCurrentEnv();
+jclass cls = curEnv->FindClass( className().c_str() );
+
+jmethodID jdoubleArrayget2dViewUnprojectMatrixID = curEnv->GetMethodID(this->instanceClass, "get2dViewUnprojectMatrix", "()[D" ) ;
+if (jdoubleArrayget2dViewUnprojectMatrixID == NULL) {
+std::cerr << "Could not access to the method " << "get2dViewUnprojectMatrix" << std::endl;
+exit(EXIT_FAILURE);
+}
+
+                        jdoubleArray res =  (jdoubleArray) curEnv->CallObjectMethod( this->instance, jdoubleArrayget2dViewUnprojectMatrixID );
+                        
+if (curEnv->ExceptionOccurred()) {
+curEnv->ExceptionDescribe() ;
+}
+
+                        
+jsize len = curEnv->GetArrayLength(res);
+jboolean isCopy = JNI_FALSE;
+
+/* faster than getXXXArrayElements */
+jdouble *resultsArray = (jdouble *) curEnv->GetPrimitiveArrayCritical(res, &isCopy);
+double * myArray= new double[len];
+
+for (jsize i = 0; i < len; i++){
+myArray[i]=resultsArray[i];
+}
+curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+return myArray;
+
+}
+
+double * IsoViewCameraGL::getViewPort (){
+
+JNIEnv * curEnv = getCurrentEnv();
+jclass cls = curEnv->FindClass( className().c_str() );
+
+jmethodID jdoubleArraygetViewPortID = curEnv->GetMethodID(this->instanceClass, "getViewPort", "()[D" ) ;
+if (jdoubleArraygetViewPortID == NULL) {
+std::cerr << "Could not access to the method " << "getViewPort" << std::endl;
+exit(EXIT_FAILURE);
+}
+
+                        jdoubleArray res =  (jdoubleArray) curEnv->CallObjectMethod( this->instance, jdoubleArraygetViewPortID );
+                        
+if (curEnv->ExceptionOccurred()) {
+curEnv->ExceptionDescribe() ;
+}
+
+                        
+jsize len = curEnv->GetArrayLength(res);
+jboolean isCopy = JNI_FALSE;
+
+/* faster than getXXXArrayElements */
+jdouble *resultsArray = (jdouble *) curEnv->GetPrimitiveArrayCritical(res, &isCopy);
+double * myArray= new double[len];
+
+for (jsize i = 0; i < len; i++){
+myArray[i]=resultsArray[i];
+}
+curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+return myArray;
+
+}
+
 }
index 82a476a..e2c361c 100644 (file)
       <param type="double" name="userCoordY" />
       <param type="double" name="userCoordZ" />
     </method>
+    <method name="getProjectionMatrix" returnType="double[]">
+    </method>
+    <method name="getUnprojectMatrix" returnType="double[]">
+    </method>
+    <method name="get2dViewProjectionMatrix" returnType="double[]">
+    </method>
+    <method name="get2dViewUnprojectMatrix" returnType="double[]">
+    </method>
+    <method name="getViewPort" returnType="double[]">
+    </method>
   </object>
 </package>
index e8e2746..faeffbd 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by GIWS (version 0.9.8) */
+/* Generated by GIWS (version 0.9.9) */
 /*
 
 Copyright 2007 INRIA
@@ -67,6 +67,11 @@ jmethodID voidreplaceCameraID; // cache method id
 jmethodID voidsetAxesReversejbooleanjbooleanjbooleanID; // cache method id
 jmethodID jintArraygetPixelCoordinatesjdoublejdoublejdoubleID; // cache method id
 jmethodID jintArrayget2dViewPixelCoordinatesjdoublejdoublejdoubleID; // cache method id
+jmethodID jdoubleArraygetProjectionMatrixID; // cache method id
+jmethodID jdoubleArraygetUnprojectMatrixID; // cache method id
+jmethodID jdoubleArrayget2dViewProjectionMatrixID; // cache method id
+jmethodID jdoubleArrayget2dViewUnprojectMatrixID; // cache method id
+jmethodID jdoubleArraygetViewPortID; // cache method id
 
 
 /**
@@ -138,6 +143,16 @@ long * getPixelCoordinates(double userCoordX, double userCoordY, double userCoor
 
 long * get2dViewPixelCoordinates(double userCoordX, double userCoordY, double userCoordZ);
 
+double * getProjectionMatrix();
+
+double * getUnprojectMatrix();
+
+double * get2dViewProjectionMatrix();
+
+double * get2dViewUnprojectMatrix();
+
+double * getViewPort();
+
 
                         /**
                         * Get class name to use for static methods
index 4c95dd2..28ee75b 100644 (file)
@@ -1,5 +1,5 @@
 #include "IsometricCameraGL.hxx"
-/* Generated by GIWS (version 0.9.8) */
+/* Generated by GIWS (version 0.9.9) */
 /*
 
 Copyright 2007 INRIA
@@ -111,6 +111,11 @@ voidreplaceCameraID=NULL;
 voidsetAxesReversejbooleanjbooleanjbooleanID=NULL; 
 jintArraygetPixelCoordinatesjdoublejdoublejdoubleID=NULL; 
 jintArrayget2dViewPixelCoordinatesjdoublejdoublejdoubleID=NULL; 
+jdoubleArraygetProjectionMatrixID=NULL; 
+jdoubleArraygetUnprojectMatrixID=NULL; 
+jdoubleArrayget2dViewProjectionMatrixID=NULL; 
+jdoubleArrayget2dViewUnprojectMatrixID=NULL; 
+jdoubleArraygetViewPortID=NULL; 
 
 
 }
@@ -147,6 +152,11 @@ voidreplaceCameraID=NULL;
 voidsetAxesReversejbooleanjbooleanjbooleanID=NULL; 
 jintArraygetPixelCoordinatesjdoublejdoublejdoubleID=NULL; 
 jintArrayget2dViewPixelCoordinatesjdoublejdoublejdoubleID=NULL; 
+jdoubleArraygetProjectionMatrixID=NULL; 
+jdoubleArraygetUnprojectMatrixID=NULL; 
+jdoubleArrayget2dViewProjectionMatrixID=NULL; 
+jdoubleArrayget2dViewUnprojectMatrixID=NULL; 
+jdoubleArraygetViewPortID=NULL; 
 
 
 }
@@ -505,4 +515,174 @@ return myArray;
 
 }
 
+double * IsometricCameraGL::getProjectionMatrix (){
+
+JNIEnv * curEnv = getCurrentEnv();
+jclass cls = curEnv->FindClass( className().c_str() );
+
+jmethodID jdoubleArraygetProjectionMatrixID = curEnv->GetMethodID(this->instanceClass, "getProjectionMatrix", "()[D" ) ;
+if (jdoubleArraygetProjectionMatrixID == NULL) {
+std::cerr << "Could not access to the method " << "getProjectionMatrix" << std::endl;
+exit(EXIT_FAILURE);
+}
+
+                        jdoubleArray res =  (jdoubleArray) curEnv->CallObjectMethod( this->instance, jdoubleArraygetProjectionMatrixID );
+                        
+if (curEnv->ExceptionOccurred()) {
+curEnv->ExceptionDescribe() ;
+}
+
+                        
+jsize len = curEnv->GetArrayLength(res);
+jboolean isCopy = JNI_FALSE;
+
+/* faster than getXXXArrayElements */
+jdouble *resultsArray = (jdouble *) curEnv->GetPrimitiveArrayCritical(res, &isCopy);
+double * myArray= new double[len];
+
+for (jsize i = 0; i < len; i++){
+myArray[i]=resultsArray[i];
+}
+curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+return myArray;
+
+}
+
+double * IsometricCameraGL::getUnprojectMatrix (){
+
+JNIEnv * curEnv = getCurrentEnv();
+jclass cls = curEnv->FindClass( className().c_str() );
+
+jmethodID jdoubleArraygetUnprojectMatrixID = curEnv->GetMethodID(this->instanceClass, "getUnprojectMatrix", "()[D" ) ;
+if (jdoubleArraygetUnprojectMatrixID == NULL) {
+std::cerr << "Could not access to the method " << "getUnprojectMatrix" << std::endl;
+exit(EXIT_FAILURE);
+}
+
+                        jdoubleArray res =  (jdoubleArray) curEnv->CallObjectMethod( this->instance, jdoubleArraygetUnprojectMatrixID );
+                        
+if (curEnv->ExceptionOccurred()) {
+curEnv->ExceptionDescribe() ;
+}
+
+                        
+jsize len = curEnv->GetArrayLength(res);
+jboolean isCopy = JNI_FALSE;
+
+/* faster than getXXXArrayElements */
+jdouble *resultsArray = (jdouble *) curEnv->GetPrimitiveArrayCritical(res, &isCopy);
+double * myArray= new double[len];
+
+for (jsize i = 0; i < len; i++){
+myArray[i]=resultsArray[i];
+}
+curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+return myArray;
+
+}
+
+double * IsometricCameraGL::get2dViewProjectionMatrix (){
+
+JNIEnv * curEnv = getCurrentEnv();
+jclass cls = curEnv->FindClass( className().c_str() );
+
+jmethodID jdoubleArrayget2dViewProjectionMatrixID = curEnv->GetMethodID(this->instanceClass, "get2dViewProjectionMatrix", "()[D" ) ;
+if (jdoubleArrayget2dViewProjectionMatrixID == NULL) {
+std::cerr << "Could not access to the method " << "get2dViewProjectionMatrix" << std::endl;
+exit(EXIT_FAILURE);
+}
+
+                        jdoubleArray res =  (jdoubleArray) curEnv->CallObjectMethod( this->instance, jdoubleArrayget2dViewProjectionMatrixID );
+                        
+if (curEnv->ExceptionOccurred()) {
+curEnv->ExceptionDescribe() ;
+}
+
+                        
+jsize len = curEnv->GetArrayLength(res);
+jboolean isCopy = JNI_FALSE;
+
+/* faster than getXXXArrayElements */
+jdouble *resultsArray = (jdouble *) curEnv->GetPrimitiveArrayCritical(res, &isCopy);
+double * myArray= new double[len];
+
+for (jsize i = 0; i < len; i++){
+myArray[i]=resultsArray[i];
+}
+curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+return myArray;
+
+}
+
+double * IsometricCameraGL::get2dViewUnprojectMatrix (){
+
+JNIEnv * curEnv = getCurrentEnv();
+jclass cls = curEnv->FindClass( className().c_str() );
+
+jmethodID jdoubleArrayget2dViewUnprojectMatrixID = curEnv->GetMethodID(this->instanceClass, "get2dViewUnprojectMatrix", "()[D" ) ;
+if (jdoubleArrayget2dViewUnprojectMatrixID == NULL) {
+std::cerr << "Could not access to the method " << "get2dViewUnprojectMatrix" << std::endl;
+exit(EXIT_FAILURE);
+}
+
+                        jdoubleArray res =  (jdoubleArray) curEnv->CallObjectMethod( this->instance, jdoubleArrayget2dViewUnprojectMatrixID );
+                        
+if (curEnv->ExceptionOccurred()) {
+curEnv->ExceptionDescribe() ;
+}
+
+                        
+jsize len = curEnv->GetArrayLength(res);
+jboolean isCopy = JNI_FALSE;
+
+/* faster than getXXXArrayElements */
+jdouble *resultsArray = (jdouble *) curEnv->GetPrimitiveArrayCritical(res, &isCopy);
+double * myArray= new double[len];
+
+for (jsize i = 0; i < len; i++){
+myArray[i]=resultsArray[i];
+}
+curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+return myArray;
+
+}
+
+double * IsometricCameraGL::getViewPort (){
+
+JNIEnv * curEnv = getCurrentEnv();
+jclass cls = curEnv->FindClass( className().c_str() );
+
+jmethodID jdoubleArraygetViewPortID = curEnv->GetMethodID(this->instanceClass, "getViewPort", "()[D" ) ;
+if (jdoubleArraygetViewPortID == NULL) {
+std::cerr << "Could not access to the method " << "getViewPort" << std::endl;
+exit(EXIT_FAILURE);
+}
+
+                        jdoubleArray res =  (jdoubleArray) curEnv->CallObjectMethod( this->instance, jdoubleArraygetViewPortID );
+                        
+if (curEnv->ExceptionOccurred()) {
+curEnv->ExceptionDescribe() ;
+}
+
+                        
+jsize len = curEnv->GetArrayLength(res);
+jboolean isCopy = JNI_FALSE;
+
+/* faster than getXXXArrayElements */
+jdouble *resultsArray = (jdouble *) curEnv->GetPrimitiveArrayCritical(res, &isCopy);
+double * myArray= new double[len];
+
+for (jsize i = 0; i < len; i++){
+myArray[i]=resultsArray[i];
+}
+curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+return myArray;
+
+}
+
 }
index 1fccd5a..dfe2e29 100644 (file)
       <param type="double" name="userCoordY" />
       <param type="double" name="userCoordZ" />
     </method>
+    <method name="getProjectionMatrix" returnType="double[]">
+    </method>
+    <method name="getUnprojectMatrix" returnType="double[]">
+    </method>
+    <method name="get2dViewProjectionMatrix" returnType="double[]">
+    </method>
+    <method name="get2dViewUnprojectMatrix" returnType="double[]">
+    </method>
+    <method name="getViewPort" returnType="double[]">
+    </method>
   </object>
 </package>
index 945bc39..e18e725 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by GIWS (version 0.9.8) */
+/* Generated by GIWS (version 0.9.9) */
 /*
 
 Copyright 2007 INRIA
@@ -67,6 +67,11 @@ jmethodID voidreplaceCameraID; // cache method id
 jmethodID voidsetAxesReversejbooleanjbooleanjbooleanID; // cache method id
 jmethodID jintArraygetPixelCoordinatesjdoublejdoublejdoubleID; // cache method id
 jmethodID jintArrayget2dViewPixelCoordinatesjdoublejdoublejdoubleID; // cache method id
+jmethodID jdoubleArraygetProjectionMatrixID; // cache method id
+jmethodID jdoubleArraygetUnprojectMatrixID; // cache method id
+jmethodID jdoubleArrayget2dViewProjectionMatrixID; // cache method id
+jmethodID jdoubleArrayget2dViewUnprojectMatrixID; // cache method id
+jmethodID jdoubleArraygetViewPortID; // cache method id
 
 
 /**
@@ -138,6 +143,16 @@ long * getPixelCoordinates(double userCoordX, double userCoordY, double userCoor
 
 long * get2dViewPixelCoordinates(double userCoordX, double userCoordY, double userCoordZ);
 
+double * getProjectionMatrix();
+
+double * getUnprojectMatrix();
+
+double * get2dViewProjectionMatrix();
+
+double * get2dViewUnprojectMatrix();
+
+double * getViewPort();
+
 
                         /**
                         * Get class name to use for static methods