Speed up a little text rendering.
Jean-baptiste Silvy [Tue, 29 Apr 2008 13:01:31 +0000 (13:01 +0000)]
56 files changed:
scilab/modules/graphics/includes/Axes.h
scilab/modules/graphics/includes/axesScale.h
scilab/modules/graphics/sci_gateway/c/sci_StringBox.c
scilab/modules/graphics/sci_gateway/c/sci_xchange.c
scilab/modules/graphics/sci_gateway/c/sci_xclick.c
scilab/modules/graphics/sci_gateway/c/sci_xgetmouse.c
scilab/modules/graphics/src/c/Axes.c
scilab/modules/graphics/src/c/axesScale.c
scilab/modules/renderer/graphics_Import.def
scilab/modules/renderer/includes/SetJavaProperty.h
scilab/modules/renderer/src/cpp/DrawableObject.cpp
scilab/modules/renderer/src/cpp/DrawableObject.h
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/FigureScilabCall.cpp
scilab/modules/renderer/src/cpp/figureDrawing/FigureScilabCall.h
scilab/modules/renderer/src/cpp/subwinDrawing/ConcreteDrawableSubwin.cpp
scilab/modules/renderer/src/cpp/subwinDrawing/ConcreteDrawableSubwin.hxx
scilab/modules/renderer/src/cpp/subwinDrawing/DrawableSubwin.cpp
scilab/modules/renderer/src/cpp/subwinDrawing/DrawableSubwin.h
scilab/modules/renderer/src/cpp/textDrawing/CenteredTextDrawerJavaMapper.cpp
scilab/modules/renderer/src/cpp/textDrawing/CenteredTextDrawerJavaMapper.hxx
scilab/modules/renderer/src/cpp/textDrawing/ConcreteDrawableText.cpp
scilab/modules/renderer/src/cpp/textDrawing/ConcreteDrawableText.hxx
scilab/modules/renderer/src/cpp/textDrawing/DrawTextContentStrategy.hxx
scilab/modules/renderer/src/cpp/textDrawing/DrawableText.cpp
scilab/modules/renderer/src/cpp/textDrawing/DrawableText.h
scilab/modules/renderer/src/cpp/textDrawing/FilledTextDrawerJavaMapper.cpp
scilab/modules/renderer/src/cpp/textDrawing/FilledTextDrawerJavaMapper.hxx
scilab/modules/renderer/src/cpp/textDrawing/StandardTextDrawerJavaMapper.cpp
scilab/modules/renderer/src/cpp/textDrawing/StandardTextDrawerJavaMapper.hxx
scilab/modules/renderer/src/cpp/textDrawing/TextContentDrawerJavaMapper.hxx
scilab/modules/renderer/src/cpp/textDrawing/TextContentDrawerJoGL.cpp
scilab/modules/renderer/src/cpp/textDrawing/TextContentDrawerJoGL.hxx
scilab/modules/renderer/src/cpp/textDrawing/TextFillBoxDrawerJoGL.cpp
scilab/modules/renderer/src/cpp/textDrawing/TextLineBoxDrawerJoGL.cpp
scilab/modules/renderer/src/java/org/scilab/modules/renderer/figureDrawing/DrawableFigureGL.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/figureDrawing/SciRenderer.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/jni/FigureScilabCall.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/jni/FigureScilabCallJNI.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/textDrawing/FilledTextDrawerGL.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/textDrawing/FixedFontTextDrawerGL.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/textDrawing/TextContentDrawerGL.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/utils/geom3D/Vector3D.java
scilab/modules/renderer/src/jni/CenteredTextDrawerGL.cpp
scilab/modules/renderer/src/jni/CenteredTextDrawerGL.giws.xml
scilab/modules/renderer/src/jni/CenteredTextDrawerGL.hxx
scilab/modules/renderer/src/jni/FigureScilabCall.i
scilab/modules/renderer/src/jni/FigureScilabCall_wrap.c
scilab/modules/renderer/src/jni/FilledTextDrawerGL.cpp
scilab/modules/renderer/src/jni/FilledTextDrawerGL.giws.xml
scilab/modules/renderer/src/jni/FilledTextDrawerGL.hxx
scilab/modules/renderer/src/jni/StandardTextDrawerGL.cpp
scilab/modules/renderer/src/jni/StandardTextDrawerGL.giws.xml
scilab/modules/renderer/src/jni/StandardTextDrawerGL.hxx

index 869691f..4b614b6 100644 (file)
@@ -43,11 +43,6 @@ void initSubWinBounds( sciPointObj * pSubWin ) ;
 BOOL checkRedrawing( void ) ;
 
 /**
- * Update subwin size and scale
- */
-void updateSubwinScale(sciPointObj * pSubwin);
-
-/**
  * Find which subwindow is selected by clincking at pixel coordinates (xCoord, yCoord).
  * @param pFigure index of parent figure in which the subwindow will be selected
  * @return NULL if no subwindow could be selected, the seleceted subwindow otherwise
index ea42956..832128a 100644 (file)
@@ -48,6 +48,16 @@ void sciUnzoomSubwin(sciPointObj * subwin);
 void sciUnzoomFigure(sciPointObj * figure);
 void sciUnzoomAll(void);
 void sciUnzoomArray(sciPointObj * zoomedObjects[], int nbSubwin);
+
+/**
+ * Update subwin size and scale if needed
+ */
+void updateSubwinScale(sciPointObj * pSubwin);
+
+/**
+ * Update text bounds if needed
+ */
+void updateTextBounds(sciPointObj * pText);
 /*------------------------------------------------------------------------------*/
 BOOL checkDataBounds(sciPointObj * pObj, double xMin, double xMax,
                      double yMin, double yMax, double zMin, double zMax);
index cb60e25..0c9a556 100644 (file)
@@ -75,7 +75,7 @@ int sci_StringBox( char * fname, unsigned long fname_len )
   /* create a window if needed to initialize the X11 graphic context  */
 
   /* force drawing of text to update stringbox */
-  sciDrawSingleObj(pText);
+  updateTextBounds(pText);
 
   /* get the string box */
   sciGet2dViewBoundingBox( pText, corners[0], corners[1], corners[2], corners[3]) ;
index 4d11a9e..aa8c300 100644 (file)
@@ -22,6 +22,7 @@
 #include "gw_graphics.h"
 #include "PloEch.h"
 #include "GetProperty.h"
+#include "axesScale.h"
 
 #define VIEWING_RECT_SIZE 4
 
index 64dff11..390c27a 100644 (file)
@@ -28,7 +28,7 @@
 #include "GetProperty.h"
 #include "ObjectSelection.h"
 #include "WindowList.h"
-#include "Axes.h"
+#include "axesScale.h"
 /*--------------------------------------------------------------------------*/
 int sci_xclick(char *fname,unsigned long fname_len)
 {
index e666398..84c19dd 100644 (file)
@@ -25,7 +25,7 @@
 #include "GetProperty.h"
 #include "ObjectSelection.h"
 #include "WindowList.h"
-#include "Axes.h"
+#include "axesScale.h"
 #include "sciprint.h"
 #include "Scierror.h"
 #include "localization.h"
index 36a30cc..091da3d 100644 (file)
@@ -28,6 +28,7 @@
 #include "DrawObjects.h"
 #include "InitObjects.h"
 #include "SetProperty.h"
+#include "SetJavaProperty.h"
 #include "axesScale.h"
 #include "CurrentObjectsManagement.h"
 #include "DrawingBridge.h"
@@ -141,24 +142,6 @@ BOOL checkRedrawing( void )
   return FALSE ;
 }
 /*--------------------------------------------------------------------------------*/
-void updateSubwinScale(sciPointObj * pSubwin)
-{
-  
-
-  sciPointObj * parentFigure = sciGetParentFigure(pSubwin);
-  BOOL visible = sciGetVisibility(pSubwin);
-  int pixelMode = sciGetXorMode(parentFigure);
-
-
-  // update the data by just calling
-  // display on the invisible window
-  sciSetXorMode(parentFigure, getPixelModeIndex("noop"));
-  sciSetVisibility(pSubwin, FALSE);
-  sciDrawSingleObj(pSubwin);
-  sciSetVisibility(pSubwin, visible);
-  sciSetXorMode(parentFigure, pixelMode);
-}
-/*--------------------------------------------------------------------------------*/
 /**
  * Return the square distance between the center of axes box anf point (xCoord, yCoord);
  */
index cbbd6b5..7f56000 100644 (file)
@@ -711,4 +711,14 @@ void sciUnzoomArray(sciPointObj * zoomedObjects[], int nbObjects)
 
   List_free(redrawnFigures);
 }
+/*--------------------------------------------------------------------------------*/
+void updateSubwinScale(sciPointObj * pSubwin)
+{
+  sciJavaUpdateSubwinScale(pSubwin);
+}
 /*------------------------------------------------------------------------------*/
+void updateTextBounds(sciPointObj * pText)
+{
+  sciJavaUpdateTextBoundingBox(pText);
+}
+/*------------------------------------------------------------------------------*/
\ No newline at end of file
index 8847bc6..da8304a 100644 (file)
@@ -138,3 +138,4 @@ vectAdd3D
 scalarMult3D
 vectSubstract3D
 sciSetZooming
+sciSetVisibility
index 9bfe6f0..6335ccd 100644 (file)
@@ -84,6 +84,16 @@ void sciSetJavaBackground(sciPointObj * pFigure, int backColor);
  */
 void sciSetJavaTitle( sciPointObj * pFigure, const char * title ) ;
 
+/**
+ * Update subwin size and scale
+ */
+void sciJavaUpdateSubwinScale(sciPointObj * pSubwin);
+
+/**
+ * Update bounding box of a text objectr if needed
+ */
+void sciJavaUpdateTextBoundingBox(sciPointObj * pText);
+
 #ifdef __cplusplus
 }
 #endif
index 3007c88..fb6df68 100644 (file)
@@ -60,7 +60,10 @@ void DrawableObject::hasChanged( void )
 /*---------------------------------------------------------------------------------*/
 void DrawableObject::familyHasChanged( void )
 {
+  // force redraw
   hasChanged();
+
+  // do the same for childrens
   sciSons * curSon = sciGetLastSons( m_pDrawed ) ;
   while ( curSon != NULL )
   {
@@ -73,6 +76,21 @@ void DrawableObject::familyHasChanged( void )
   }
 }
 /*---------------------------------------------------------------------------------*/
+void DrawableObject::parentSubwinChanged( void )
+{
+  // just call the function on children
+  sciSons * curSon = sciGetLastSons( m_pDrawed ) ;
+  while ( curSon != NULL )
+  {
+    if (sciGetEntityType(curSon->pointobj) != SCI_UICONTROL
+      && sciGetEntityType(curSon->pointobj) != SCI_UIMENU) 
+    {
+      getHandleDrawer( curSon->pointobj )->parentSubwinChanged();
+    }
+    curSon = curSon->pprev ;
+  }
+}
+/*---------------------------------------------------------------------------------*/
 void DrawableObject::displayChildren( void )
 {
   sciSons * curSon = sciGetLastSons( m_pDrawed ) ;
index 01f5a62..a4b80df 100644 (file)
@@ -49,7 +49,7 @@ public:
   /**
    * To specify that the object was modified and need to be redrawn
    */
-  void hasChanged( void ) ;
+  virtual void hasChanged( void ) ;
 
   /**
    * To specify that an object and its children have changed
@@ -57,6 +57,13 @@ public:
   void familyHasChanged( void ) ;
 
   /**
+   * Specify that the parent axis have changed.
+   * Children which need to be redrawn must redefine this
+   * function.
+   */
+  virtual void parentSubwinChanged( void );
+
+  /**
    * Common to every object, draw their children
    */
   void displayChildren( void ) ;
index 87b8f52..d86a4fe 100644 (file)
@@ -82,3 +82,14 @@ void sciSetJavaTitle( sciPointObj * pFigure, const char * title )
   getFigureDrawer(pFigure)->setTitle(title);
 }
 /*---------------------------------------------------------------------------------*/
+void sciJavaUpdateSubwinScale(sciPointObj * pSubwin)
+{
+  getSubwinDrawer(pSubwin)->updateScale();
+}
+/*---------------------------------------------------------------------------------*/
+void sciJavaUpdateTextBoundingBox(sciPointObj * pText)
+{
+  getTextDrawer(pText)->updateTextBox();
+}
+/*---------------------------------------------------------------------------------*/
+
index f9e3390..de5e8f9 100644 (file)
@@ -14,6 +14,8 @@
 
 #include "DrawableFigure.h"
 #include "DrawableFigureBridge.h"
+#include "../subwinDrawing/DrawableSubwin.h"
+#include "../getHandleDrawer.h"
 
 //#include <time.h>
 //#include <sched.h>
@@ -138,6 +140,20 @@ void DrawableFigure::redrawInContext( void )
   //drawInContext();
 }
 /*---------------------------------------------------------------------------------*/
+void DrawableFigure::redrawSubwins(void)
+{
+  // just call the function on children
+  sciSons * curSon = sciGetLastSons( m_pDrawed ) ;
+  while ( curSon != NULL )
+  {
+    if (sciGetEntityType(curSon->pointobj) == SCI_SUBWIN)
+    {
+      getSubwinDrawer( curSon->pointobj )->parentSubwinChanged();
+    }
+    curSon = curSon->pprev ;
+  }
+}
+/*---------------------------------------------------------------------------------*/
 void DrawableFigure::draw( void )
 { 
   if ( !checkAutoRedraw() && !isDisplayingSingleObject() )
index cb284d3..71b846e 100644 (file)
@@ -38,12 +38,17 @@ public:
   virtual void drawInContext( void ) ;
 
   /**
-   * redraw all the figure and all its chidren
+   * redraw all the figure and all its children
    * Can only be called within the OpenGL thread
    */
   void redrawInContext( void );
 
   /**
+   * Redraw all subwindows contained in the figure.
+   */
+  void redrawSubwins( void );
+
+  /**
    * Like display but to display only a single object
    */
   virtual void drawSingleObj(sciPointObj * pObj) = 0;
index 75eb7d9..7f882be 100644 (file)
@@ -59,3 +59,22 @@ void redrawFigure(int figureId)
   endFigureDataDisplaying(curFig);
 }
 /*--------------------------------------------------------------------------*/
+
+
+/*--------------------------------------------------------------------------*/
+void redrawSubwins(int figureId)
+{
+  startGraphicDataReading();
+  sciPointObj * curFig = getFigureFromIndex(figureId) ;
+  endGraphicDataReading();
+
+  if ( curFig == NULL )
+  {
+    return ;
+  }
+
+  startFigureDataDisplaying(curFig);
+  (sciGraphics::getFigureDrawer(curFig))->redrawSubwins() ;
+  endFigureDataDisplaying(curFig);
+}
+/*--------------------------------------------------------------------------*/
index 16de279..f151cea 100644 (file)
@@ -22,6 +22,8 @@ void displayFigure(int figureId);
 
 void redrawFigure(int figureId) ;
 
+void redrawSubwins(int figureId) ;
+
 #ifdef __cplusplus
 }
 #endif
index 7b1d1cb..f554fdf 100644 (file)
@@ -18,8 +18,12 @@ extern "C"
 {
 #include "GetProperty.h"
 #include "SetProperty.h"
+#include "pixel_mode.h"
+#include "DrawingBridge.h"
 }
 
+using namespace std;
+
 namespace sciGraphics
 {
 
@@ -200,6 +204,26 @@ void ConcreteDrawableSubwin::computeRealDataBounds(void)
 
 }
 /*------------------------------------------------------------------------------------------*/
+void ConcreteDrawableSubwin::updateScale(void)
+{
+  sciPointObj * parentFigure = sciGetParentFigure(m_pDrawed);
+  BOOL visible = sciGetVisibility(m_pDrawed);
+  int pixelMode = sciGetXorMode(parentFigure);
+
+  if (!m_bNeedRedraw) {
+    // no need to update
+    return;
+  }
+
+  // update the data by just calling
+  // display on the invisible window
+  sciSetXorMode(parentFigure, getPixelModeIndex("noop"));
+  sciSetVisibility(m_pDrawed, FALSE);
+  sciDrawSingleObj(m_pDrawed);
+  sciSetVisibility(m_pDrawed, visible);
+  sciSetXorMode(parentFigure, pixelMode);
+}
+/*------------------------------------------------------------------------------------------*/
 void ConcreteDrawableSubwin::drawBox(void)
 {
   // If axes is not displayed m_pAxesbox is not drawn.
index c988a17..7492e1e 100644 (file)
 #ifndef _CONCRETE_DRAWABLE_SUBWIN_HXX_
 #define _CONCRETE_DRAWABLE_SUBWIN_HXX_
 
+#include <list>
+
 #include "DrawableSubwin.h"
 #include "ComputeBoundsStrategy.hxx"
 #include "DrawAxesBoxStrategy.hxx"
 #include "TicksDrawer.hxx"
 #include "../labelDrawing/LabelPositioner.hxx"
 
+
 namespace sciGraphics
 {
 
@@ -81,6 +84,11 @@ public:
    */
   virtual void computeRealDataBounds(void);
 
+  /**
+   * Just update scale and size if needed
+   */
+  virtual void updateScale(void);
+
 
 protected:
 
@@ -123,6 +131,7 @@ protected:
   TicksDrawer * m_pZTicksDrawer;
 
   DrawAxesBoxStrategy * m_pAxesBoxDrawer;
+
   /*---------------------------------------------------------------------*/
 
 private:
index b3ab70e..3fc9f64 100644 (file)
@@ -48,6 +48,12 @@ void DrawableSubwin::setCamera( Camera * cam )
   m_pCamera = cam;
 }
 /*---------------------------------------------------------------------------------*/
+void DrawableSubwin::hasChanged( void )
+{
+  DrawableObject::hasChanged();
+  parentSubwinChanged();
+}
+/*---------------------------------------------------------------------------------*/
 void DrawableSubwin::displaySingleObj(sciPointObj * pObj)
 {
 
index 7d1e19d..bfc9a12 100644 (file)
@@ -42,6 +42,12 @@ public:
   void setCamera( Camera * cam ) ;
 
   /**
+   * Redefine has changed so children
+   * so that needed children will also be redrawn
+   */
+  virtual void hasChanged( void ) ;
+
+  /**
    * Display the subwin by just setting the camera
    * and its children pObj
    */
@@ -53,6 +59,11 @@ public:
    */
   virtual void computeRealDataBounds(void) = 0;
 
+  /**
+   * Just update scale and size if needed
+   */
+  virtual void updateScale(void) = 0;
+
 protected:
 
   /**
index 5ac8724..9abbe83 100644 (file)
@@ -80,9 +80,9 @@ void CenteredTextDrawerJavaMapper::setCenterPosition(double centerX, double cent
   m_pJavaObject->setCenterPosition(centerX, centerY, centerZ);
 }
 /*---------------------------------------------------------------------------------*/
-void CenteredTextDrawerJavaMapper::drawTextContent(void)
+double * CenteredTextDrawerJavaMapper::drawTextContent(void)
 {
-  m_pJavaObject->drawTextContent();
+  return m_pJavaObject->drawTextContent();
 }
 /*---------------------------------------------------------------------------------*/
 double * CenteredTextDrawerJavaMapper::getBoundingRectangle(void)
index 4c06597..a1d03bb 100644 (file)
@@ -45,7 +45,7 @@ public:
   // Inherited from TextContentDrawerJavaMapper
   virtual void setTextContent(char ** text, int nbRow, int nbCol);
   virtual void setCenterPosition(double centerX, double centerY, double centerZ);
-  virtual void drawTextContent(void);
+  virtual double * drawTextContent(void);
 
   virtual double * getBoundingRectangle(void);
 
index c342127..63e1c67 100644 (file)
 
 
 #include "ConcreteDrawableText.hxx"
+#include "DrawingBridge.h"
 
 extern "C"
 {
 #include "GetProperty.h"
+#include "SetProperty.h"
 }
 
 namespace sciGraphics
@@ -79,7 +81,8 @@ void ConcreteDrawableText::drawBox(void)
   
   // get bounding rectangle corners
   double corners[4][3];
-  m_pDrawingTextStrategy->getBoundingRectangle(corners[0], corners[1], corners[2], corners[3]);
+  sciGetTextBoundingBox(m_pDrawed, corners[0], corners[1], corners[2], corners[3]);
+  //m_pDrawingTextStrategy->getBoundingRectangle(corners[0], corners[1], corners[2], corners[3]);
 
   for( ; it != m_oDrawingBoxStrategies.end(); it++)
   {
@@ -90,7 +93,10 @@ void ConcreteDrawableText::drawBox(void)
 /*---------------------------------------------------------------------------------*/
 void ConcreteDrawableText::drawTextContent(void)
 {
-  m_pDrawingTextStrategy->drawTextContent();
+  // draw text content and update bounding box
+  sciText * ppText = pTEXT_FEATURE(m_pDrawed);
+  m_pDrawingTextStrategy->drawTextContent(ppText->corners[0], ppText->corners[1],
+                                          ppText->corners[2], ppText->corners[3]);
 }
 /*---------------------------------------------------------------------------------*/
 void ConcreteDrawableText::showBox(void)
@@ -99,8 +105,8 @@ void ConcreteDrawableText::showBox(void)
 
   // get bounding rectangle corners
   double corners[4][3];
-  //sciGetTextBoundingBox(m_pDrawed, corners[0], corners[1], corners[2], corners[3]);
-  m_pDrawingTextStrategy->getBoundingRectangle(corners[0], corners[1], corners[2], corners[3]);
+  sciGetTextBoundingBox(m_pDrawed, corners[0], corners[1], corners[2], corners[3]);
+  //m_pDrawingTextStrategy->getBoundingRectangle(corners[0], corners[1], corners[2], corners[3]);
 
   for( ; it != m_oDrawingBoxStrategies.end(); it++)
   {
@@ -111,7 +117,7 @@ void ConcreteDrawableText::showBox(void)
 /*---------------------------------------------------------------------------------*/
 void ConcreteDrawableText::showTextContent(void)
 {
-  m_pDrawingTextStrategy->drawTextContent();
+  m_pDrawingTextStrategy->showTextContent();
 }
 /*---------------------------------------------------------------------------------*/
 bool ConcreteDrawableText::isTextEmpty(void)
@@ -145,6 +151,20 @@ bool ConcreteDrawableText::isTextEmpty(void)
 /*---------------------------------------------------------------------------------*/
 void ConcreteDrawableText::updateTextBox(void)
 {
+  if (!m_bNeedRedraw)
+  {
+    // text already up to date
+    return;
+  }
+  // just update, no need to draw
+  BOOL visibility = sciGetVisibility(m_pDrawed);
+  sciSetVisibility(m_pDrawed, FALSE);
+  sciDrawSingleObj(m_pDrawed);
+  sciSetVisibility(m_pDrawed, visibility);
+}
+/*---------------------------------------------------------------------------------*/
+void ConcreteDrawableText::updateTextBoxFromContext(void)
+{
   sciText * ppText = pTEXT_FEATURE(m_pDrawed);
   getBoundingRectangle(ppText->corners[0], ppText->corners[1],
                        ppText->corners[2], ppText->corners[3]);
index a18afb4..81324d7 100644 (file)
@@ -69,6 +69,11 @@ public:
    */
   virtual void updateTextBox(void);
 
+  /**
+   * Update the text box a text object from OpenGL context.
+   */
+  virtual void updateTextBoxFromContext(void);
+
 protected:
 
   /*---------------------------------------------------------------------------------*/
index 9eee382..9c86e04 100644 (file)
@@ -40,7 +40,7 @@ public:
   /**
    * Draw the rectangle surrounding the text.
    */
-  virtual void drawTextContent(void) = 0;
+  virtual void drawTextContent(double corner1[3], double corner2[3], double corner3[3], double corner4[3]) = 0;
 
   /**
    * Display the text using display lists.
index 6a91847..f980773 100644 (file)
  */
 
 #include "DrawableText.h"
+#include "../DrawableObject.h"
+#include "../getHandleDrawer.h"
 
-namespace sciGraphics
+extern "C"
 {
+#include "GetProperty.h"
+}
 
+namespace sciGraphics
+{
+/*---------------------------------------------------------------------------------*/
+void DrawableText::parentSubwinChanged( void )
+{
+  m_bNeedRedraw = true;
+}
 /*---------------------------------------------------------------------------------*/
 void DrawableText::draw( void )
 {
   
   // update might be needed
-  updateTextBox();
+  //updateTextBox();
   if (!checkVisibility() || isTextEmpty() )
   {
+    updateTextBoxFromContext();
     return ;
   }
 
   initializeDrawing() ;
   
   clip();
-  drawBox();
   drawTextContent();
+  drawBox();
   unClip();
   endDrawing();
 }
@@ -39,15 +51,15 @@ void DrawableText::draw( void )
 void DrawableText::show( void )
 {
   // update might be needed
-  updateTextBox();
+  //updateTextBox();
   if (!checkVisibility() || isTextEmpty() )
   {
     return ;
   }
   initializeDrawing();
   clip();
-  showBox();
   showTextContent();
+  showBox();
   unClip();
   endDrawing();
 }
index fd0d6d1..9fb9d28 100644 (file)
@@ -30,6 +30,11 @@ public:
   virtual ~DrawableText( void ) {}
 
   /**
+   * Text must be updated whenever the parent axes changed
+   */
+  virtual void parentSubwinChanged( void );
+
+  /**
    * Get the 4 corners of the text bounding rectangle (the text lies within a plane).
    * Used to draw the rectangle around the text.
    */
@@ -51,6 +56,11 @@ public:
    */
   virtual void updateTextBox(void) = 0;
 
+  /**
+   * Update the text box a text object from OpenGL context.
+   */
+  virtual void updateTextBoxFromContext(void) = 0;
+
 protected:
 
   /**
index 31166f9..3fe6d75 100644 (file)
@@ -78,9 +78,9 @@ void FilledTextDrawerJavaMapper::setCenterPosition(double centerX, double center
   m_pJavaObject->setCenterPosition(centerX, centerY, centerZ);
 }
 /*---------------------------------------------------------------------------------*/
-void FilledTextDrawerJavaMapper::drawTextContent(void)
+double * FilledTextDrawerJavaMapper::drawTextContent(void)
 {
-  m_pJavaObject->drawTextContent();
+  return m_pJavaObject->drawTextContent();
 }
 /*---------------------------------------------------------------------------------*/
 double * FilledTextDrawerJavaMapper::getBoundingRectangle(void)
index 60c3e3a..6563bce 100644 (file)
@@ -45,7 +45,7 @@ public:
   // Inherited from TextContentDrawerJavaMapper
   virtual void setTextContent(char ** text, int nbRow, int nbCol);
   virtual void setCenterPosition(double centerX, double centerY, double centerZ);
-  virtual void drawTextContent(void);
+  virtual double * drawTextContent(void);
 
   virtual double * getBoundingRectangle(void);
 
index 9f3283e..2f89141 100644 (file)
@@ -79,9 +79,9 @@ void StandardTextDrawerJavaMapper::setCenterPosition(double centerX, double cent
   m_pJavaObject->setCenterPosition(centerX, centerY, centerZ);
 }
 /*---------------------------------------------------------------------------------*/
-void StandardTextDrawerJavaMapper::drawTextContent(void)
+double * StandardTextDrawerJavaMapper::drawTextContent(void)
 {
-  m_pJavaObject->drawTextContent();
+  return m_pJavaObject->drawTextContent();
 }
 /*---------------------------------------------------------------------------------*/
 double * StandardTextDrawerJavaMapper::getBoundingRectangle(void)
index 1010a17..7cd6b07 100644 (file)
@@ -45,7 +45,7 @@ public:
   // Inherited from TextContentDrawerJavaMapper
   virtual void setTextContent(char ** text, int nbRow, int nbCol);
   virtual void setCenterPosition(double centerX, double centerY, double centerZ);
-  virtual void drawTextContent(void);
+  virtual double * drawTextContent(void);
 
   virtual double * getBoundingRectangle(void);
 
index d332099..c44045f 100644 (file)
@@ -29,7 +29,7 @@ public:
 
   virtual void setTextContent(char ** text, int nbRow, int nbCol) = 0;
   virtual void setCenterPosition(double centerX, double centerY, double centerZ) = 0;
-  virtual void drawTextContent(void) = 0;
+  virtual double * drawTextContent(void) = 0;
 
   virtual double * getBoundingRectangle(void) = 0;
 
index 3cc2e91..c1fdfd6 100644 (file)
@@ -43,33 +43,10 @@ void TextContentDrawerJoGL::getBoundingRectangle(double corner1[3], double corne
   // we got an array of size 12
   double * rect = getTextContentDrawerJavaMapper()->getBoundingRectangle();
 
-  corner1[0] = rect[0];
-  corner1[1] = rect[1];
-  corner1[2] = rect[2];
-
-  corner2[0] = rect[3];
-  corner2[1] = rect[4];
-  corner2[2] = rect[5];
-
-  corner3[0] = rect[6];
-  corner3[1] = rect[7];
-  corner3[2] = rect[8];
+  convertCornersArray(rect, corner1, corner2, corner3, corner4);
 
-  corner4[0] = rect[9];
-  corner4[1] = rect[10];
-  corner4[2] = rect[11];
   delete[] rect;
 
-  // use logarithmic scale if needed.
-  m_pDrawed->inversePointScale(corner1[0], corner1[1], corner1[2],
-                               &(corner1[0]), &(corner1[1]), &(corner1[2]));
-  m_pDrawed->inversePointScale(corner2[0], corner2[1], corner2[2],
-                               &(corner2[0]), &(corner2[1]), &(corner2[2]));
-  m_pDrawed->inversePointScale(corner3[0], corner3[1], corner3[2],
-                               &(corner3[0]), &(corner3[1]), &(corner3[2]));
-  m_pDrawed->inversePointScale(corner4[0], corner4[1], corner4[2],
-                               &(corner4[0]), &(corner4[1]), &(corner4[2]));
-
   endDrawing();
 }
 /*---------------------------------------------------------------------------------*/
@@ -97,12 +74,15 @@ void TextContentDrawerJoGL::getScreenBoundingBox(int corner1[2], int corner2[2],
   endDrawing();
 }
 /*---------------------------------------------------------------------------------*/
-void TextContentDrawerJoGL::drawTextContent(void)
+void TextContentDrawerJoGL::drawTextContent(double corner1[3], double corner2[3], double corner3[3], double corner4[3])
 {
   initializeDrawing();
   setDrawerParameters();
 
-  getTextContentDrawerJavaMapper()->drawTextContent();
+  double * rect = getTextContentDrawerJavaMapper()->drawTextContent();
+  convertCornersArray(rect, corner1, corner2, corner3, corner4);
+
+  delete[] rect;
   endDrawing();
 }
 /*---------------------------------------------------------------------------------*/
@@ -163,6 +143,41 @@ void TextContentDrawerJoGL::getTextBoxDisplaySize(double * width, double * heigh
                             width, height, NULL);
 }
 /*---------------------------------------------------------------------------------*/
+void TextContentDrawerJoGL::convertCornersArray(const double corners[12],
+                                                double corner1[3],
+                                                double corner2[3],
+                                                double corner3[3],
+                                                double corner4[3])
+{
+  // we got an array of size 12
+
+  corner1[0] = corners[0];
+  corner1[1] = corners[1];
+  corner1[2] = corners[2];
+
+  corner2[0] = corners[3];
+  corner2[1] = corners[4];
+  corner2[2] = corners[5];
+
+  corner3[0] = corners[6];
+  corner3[1] = corners[7];
+  corner3[2] = corners[8];
+
+  corner4[0] = corners[9];
+  corner4[1] = corners[10];
+  corner4[2] = corners[11];
+
+  // use logarithmic scale if needed.
+  m_pDrawed->inversePointScale(corner1[0], corner1[1], corner1[2],
+    &(corner1[0]), &(corner1[1]), &(corner1[2]));
+  m_pDrawed->inversePointScale(corner2[0], corner2[1], corner2[2],
+    &(corner2[0]), &(corner2[1]), &(corner2[2]));
+  m_pDrawed->inversePointScale(corner3[0], corner3[1], corner3[2],
+    &(corner3[0]), &(corner3[1]), &(corner3[2]));
+  m_pDrawed->inversePointScale(corner4[0], corner4[1], corner4[2],
+    &(corner4[0]), &(corner4[1]), &(corner4[2]));
+}
+/*---------------------------------------------------------------------------------*/
 TextContentDrawerJavaMapper * TextContentDrawerJoGL::getTextContentDrawerJavaMapper(void)
 {
   return dynamic_cast<TextContentDrawerJavaMapper *>(getJavaMapper());
index 5f35e98..79d781e 100644 (file)
@@ -43,7 +43,7 @@ public:
   /**
    * Draw the rectangle surrounding the text.
    */
-  virtual void drawTextContent(void);
+  virtual void drawTextContent(double corner1[3], double corner2[3], double corner3[3], double corner4[3]);
 
   /**
    * Display the text using display lists.
@@ -73,6 +73,16 @@ protected:
   void getTextBoxDisplaySize(double * width, double * height);
 
   /**
+   * Convert an array containing the coordinates of four corners
+   * into 3 distincts vectors.
+   */
+  void convertCornersArray(const double corners[12],
+                           double corner1[3],
+                           double corner2[3],
+                           double corner3[3],
+                           double corner4[3]);
+
+  /**
    * Get the object performing mapping with Java class.
    */
   TextContentDrawerJavaMapper * getTextContentDrawerJavaMapper(void);
index 97e24ce..4f8b39a 100644 (file)
@@ -54,7 +54,7 @@ void TextFillBoxDrawerJoGL::showBox(void)
 {
   // we need to redraw the whole text object since
   // since it is not displayed in the same frame as other objects.
-  drawBox();
+  show();
 }
 /*---------------------------------------------------------------------------------*/
 RectangleFillDrawerJavaMapper * TextFillBoxDrawerJoGL::getFillDrawerJavaMapper(void)
index faf7969..9ba928f 100644 (file)
@@ -54,7 +54,7 @@ void TextLineBoxDrawerJoGL::drawBox(void)
 /*---------------------------------------------------------------------------------*/
 void TextLineBoxDrawerJoGL::showBox(void)
 {
-  drawBox();
+  show();
 }
 /*---------------------------------------------------------------------------------*/
 RectangleLineDrawerJavaMapper * TextLineBoxDrawerJoGL::getLineDrawerJavaMapper(void)
index fcff099..878ce52 100644 (file)
@@ -333,20 +333,21 @@ public class DrawableFigureGL extends ObjectGL {
                setIsRenderingEnable(false);
                FigureMapper.removeMapping(figureId);
                
-               if (Threading.isOpenGLThread()) {
-                       getRenderingTarget().getContext().destroy();
-               } else {
-                       Threading.invokeOnOpenGLThread(new Runnable() {
-                               public void run() {
-                                       getRenderingTarget().getContext().destroy();
-                               }
-                       });
-               }
 
                // then destroy canvas
                // call it on an other thread to avoid deadlocks
                Thread destroyThread = new Thread(new Runnable() {
                        public void run() {
+                               
+                               if (Threading.isOpenGLThread()) {
+                                       getRenderingTarget().getContext().destroy();
+                               } else {
+                                       Threading.invokeOnOpenGLThread(new Runnable() {
+                                               public void run() {
+                                                       getRenderingTarget().getContext().destroy();
+                                               }
+                                       });
+                               }
 
                                if (SwingUtilities.isEventDispatchThread()) {
                                        getRendererProperties().closeCanvas();
@@ -560,7 +561,6 @@ public class DrawableFigureGL extends ObjectGL {
                if (textWriter == null || !textWriter.hasFont(font)) {
                        if (textWriter != null) {
                                // free resources used by the current one if exists
-                               textWriter.flush();
                                textWriter.dispose();
                        }
                        textWriter = (SciTextRenderer) getTextRendererFactory().createTextRenderer(font, color);
@@ -577,7 +577,6 @@ public class DrawableFigureGL extends ObjectGL {
        public void destroyTextWriter() {
                if (textWriter != null) {
                        // free resources used by the current one
-                       textWriter.flush();
                        textWriter.dispose();
                }
                textWriter = null;
index ca7dcf7..dbac611 100644 (file)
@@ -140,6 +140,13 @@ public class SciRenderer
   public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height)  {
          DrawableFigureGL curFigure = FigureMapper.getCorrespondingFigure(renderedFigure);
          
+         if (curFigure == null || !curFigure.getIsRenderingEnable()) {
+                 return;
+         }
+         
+         // Axes ticks may change with new shape so redraw all subwins
+         FigureScilabCall.redrawSubwins(renderedFigure);
+         
          if (curFigure.isRubberBoxModeOn()) {
                // in rubber box mode we don't automatically redraw the figure
                // so we need to force a redraw to get a consistent background
index a2f5d9c..0e14bf3 100644 (file)
@@ -40,4 +40,14 @@ public static void redrawFigure(int figureId) {
     FigureScilabCallJNI.redrawFigure(figureId);
   }
 
+  
+ /**
+  * Redraw all the subwindows inside a figure.
+  * This should be called when the figure is resized.
+  * @param figureId index of the figure to redraw
+  */
+public static void redrawSubwins(int figureId) {
+    FigureScilabCallJNI.redrawSubwins(figureId);
+  }
+
 }
index 0c53f2a..915cf38 100644 (file)
@@ -37,4 +37,5 @@ public class FigureScilabCallJNI {
 
   public final static native void displayFigure(int jarg1);
   public final static native void redrawFigure(int jarg1);
+  public final static native void redrawSubwins(int jarg1);
 }
index fb9ba62..56eb206 100644 (file)
@@ -23,11 +23,17 @@ import org.scilab.modules.renderer.utils.geom3D.Vector3D;
  */
 public class FilledTextDrawerGL extends TextContentDrawerGL {
 
-       private static final double DEFAULT_FONT_SIZE = 10.0;
+       private static final float DEFAULT_FONT_SIZE = 10.0f;
        
        private double filledBoxWidth;
        private double filledBoxHeight;
        
+       private TextGrid stringPos;
+       
+       private float finalFontSize;
+       
+       private Vector3D realCenter;
+       
        /**
         * Default constructor
         */
@@ -35,6 +41,9 @@ public class FilledTextDrawerGL extends TextContentDrawerGL {
                super();
                filledBoxWidth = 0.0;
                filledBoxHeight = 0.0;
+               stringPos = null;
+               finalFontSize = DEFAULT_FONT_SIZE;
+               realCenter = null;
        }
        
        /**
@@ -65,33 +74,32 @@ public class FilledTextDrawerGL extends TextContentDrawerGL {
        
        /**
         * Draw the text using pixel coordinates.
-        * @param textCenterPix center of text to draw in pixels
+        * @return 4 corners of the rectangle bounding box.
         */
-       @Override
-       public void drawTextContentPix(Vector3D textCenterPix) {
+       public Vector3D[] drawTextContentPix() {
                SciTextRenderer renderer = getTextRenderer();
                
-               StringMatrixGL textMatrix = computeStringSizes(renderer, getTextMatrix());
+               setTextMatrix(computeStringSizes(renderer, getTextMatrix()));
                // get default position with size 1.
-               TextGrid stringPos = getStringsPositions(textMatrix);
+               stringPos = getStringsPositions(getTextMatrix());
 
                // Compute a new font size which will fill the box.
                Vector3D[] bounds = stringPos.getExtremBounds();
                double curWidth = bounds[2].getX() - bounds[1].getX();
                double curHeight = bounds[0].getY() - bounds[1].getY();
                
-               Vector3D newCenter = new Vector3D(textCenterPix);
+               realCenter = new Vector3D(getTextCenterPix());
                double newBoxWidth = filledBoxWidth;
                double newBoxHeight = filledBoxHeight;
                // when axes are reversed size might be negative
                if (newBoxWidth < 0) {
                        newBoxWidth = -newBoxWidth;
-                       newCenter.setX(newCenter.getX() - newBoxWidth);
+                       realCenter.setX(realCenter.getX() - newBoxWidth);
                }
                
                if (newBoxHeight < 0) {
                        newBoxHeight = -newBoxHeight;
-                       newCenter.setY(newCenter.getY() - newBoxHeight);
+                       realCenter.setY(realCenter.getY() - newBoxHeight);
                }
                
                // compute the needed size for each dimension.
@@ -101,20 +109,36 @@ public class FilledTextDrawerGL extends TextContentDrawerGL {
                // apply scale factor
                double factor = Math.min(xFactor, yFactor);
                
-               float newFontSize = (float) (getFont().getSize2D() * factor);
+               finalFontSize = (float) (getFont().getSize2D() * factor);
                stringPos.scale(factor);
                
                // create a new renderer with a new font.
-               renderer = getTextRenderer(newFontSize);
+               renderer = getTextRenderer(finalFontSize);
                
                // update StringSizes with the new renderer
-               textMatrix.update(renderer);
-               stringPos = placeTextGrid(stringPos, newCenter, textCenterPix, getRotationAngle());
+               getTextMatrix().update(renderer);
+               stringPos = placeTextGrid(stringPos, realCenter, getTextCenterPix(), getRotationAngle());
                
+               drawText(renderer, getTextMatrix(), stringPos);
+               
+               Vector3D[] bbox = stringPos.getExtremBounds(); 
+               return placeBoundingBox(bbox, getTextCenterPix(), getRotationAngle());
+               
+       }
+       
+       /**
+        * Display some from text from already precomputed positions.
+        */
+       public void showTextContentPix() {
+               SciTextRenderer renderer = getTextRenderer(finalFontSize);
                
-               drawText(renderer, textMatrix, stringPos);
+               placeTextGrid(stringPos, realCenter, getTextCenterPix(), getRotationAngle());
                
+               drawText(renderer, getTextMatrix(), stringPos);
+
        }
+       
+       
 
        /**
         * Get the bounding box of the text matrix centered at the origin.
@@ -129,16 +153,16 @@ public class FilledTextDrawerGL extends TextContentDrawerGL {
                                                  new Vector3D(filledBoxWidth, filledBoxHeight, 0.0)};
                return res;
        }
+       
+       
 
        /**
         * Compute the 4 corners of the bounding rectangle of the text in pixels coordinates.
-        * @param textCenterPix center of the text in pixel coordinates.
         * @return array of size 4 with the four corners.
         */
-       @Override
-       public Vector3D[] getBoundingRectanglePix(Vector3D textCenterPix) {
+       public Vector3D[] getBoundingRectanglePix() {
                Vector3D[] bbox = getBoundingBox(null);
-               return placeBoundingBox(bbox, textCenterPix, getRotationAngle());
+               return placeBoundingBox(bbox, getTextCenterPix(), getRotationAngle());
        }
 
        /**
@@ -169,7 +193,6 @@ public class FilledTextDrawerGL extends TextContentDrawerGL {
         * @param rotationAngle angle in radian.
         * @return the new text grid ut at the right position.
         */
-       //@Override
        public TextGrid placeTextGrid(TextGrid stringPositions,
                                                                  Vector3D textCenterPix, Vector3D rotationCenter, double rotationAngle) {
                GL gl = getGL();
@@ -196,7 +219,6 @@ public class FilledTextDrawerGL extends TextContentDrawerGL {
         */
        @Override
        public TextGrid placeTextGrid(TextGrid stringPositions, Vector3D textCenterPix, double rotationAngle) {
-               // TODO Auto-generated method stub
                return null;
        }
 
index 8303f13..9b2726e 100644 (file)
@@ -23,25 +23,44 @@ import org.scilab.modules.renderer.utils.geom3D.Vector3D;
  */
 public abstract class FixedFontTextDrawerGL extends TextContentDrawerGL {
 
+       private TextGrid stringPos;
+       
        /**
         * Default constructor.
         */
        public FixedFontTextDrawerGL() {
                super();
+               stringPos = null;
        }
        
        /**
         * Draw the text using pixel coordinates.
-        * @param textCenterPix center of text to draw in pixels
+        * @return 4 corners of the rectangle bounding box.
+        */
+       public Vector3D[] drawTextContentPix() {
+               SciTextRenderer renderer = getTextRenderer();
+               
+               setTextMatrix(computeStringSizes(renderer, getTextMatrix()));
+               
+               stringPos = getStringsPositions(getTextMatrix());
+               
+               stringPos = placeTextGrid(stringPos, getTextCenterPix(), getRotationAngle());
+               
+               drawText(renderer, getTextMatrix(), stringPos);
+               
+               Vector3D[] bbox = stringPos.getExtremBounds();
+               return placeBoundingBox(bbox, getTextCenterPix(), getRotationAngle());
+       }
+       
+       /**
+        * Display some from text from already precomputed positions.
         */
-       public void drawTextContentPix(Vector3D textCenterPix) {
+       public void showTextContentPix() {
                SciTextRenderer renderer = getTextRenderer();
                
-               StringMatrixGL textMatrix = computeStringSizes(renderer, getTextMatrix());
-               TextGrid stringPos = getStringsPositions(textMatrix);
-               stringPos = placeTextGrid(stringPos, textCenterPix, getRotationAngle());
-               drawText(renderer, textMatrix, stringPos);
+               placeTextGrid(stringPos, getTextCenterPix(), getRotationAngle());
                
+               drawText(renderer, getTextMatrix(), stringPos);
        }
 
 
@@ -58,16 +77,15 @@ public abstract class FixedFontTextDrawerGL extends TextContentDrawerGL {
        
        /**
         * Compute the 4 corners of the bounding rectangle of the text in pixels coordinates.
-        * @param textCenterPix center of the text in pixel coordinates.
         * @return array of size 4 with the four corners.
         */
-       public Vector3D[] getBoundingRectanglePix(Vector3D textCenterPix) {
+       public Vector3D[] getBoundingRectanglePix() {
                // assume we are in pixels coordinates
                SciTextRenderer renderer = getTextRenderer();
                
-               StringMatrixGL textMatrix = computeStringSizes(renderer, getTextMatrix());
-               Vector3D[] bbox = getBoundingBox(textMatrix);
-               bbox = placeBoundingBox(bbox, textCenterPix, getRotationAngle());
+               setTextMatrix(computeStringSizes(renderer, getTextMatrix()));
+               Vector3D[] bbox = getBoundingBox(getTextMatrix());
+               bbox = placeBoundingBox(bbox, getTextCenterPix(), getRotationAngle());
                
                return bbox;
        }
index 78ae119..40b664b 100644 (file)
@@ -37,6 +37,7 @@ public abstract class TextContentDrawerGL extends DrawableObjectGL implements Te
        /** Rotation angle in radian */
        private double rotationAngle;
        private Vector3D textCenter;
+       private Vector3D textCenterPix;
        
        /**
         * Default constructor
@@ -76,8 +77,9 @@ public abstract class TextContentDrawerGL extends DrawableObjectGL implements Te
         * @param parentFigureIndex index of the parent figure in which the object will be drawn
         */
        public void show(int parentFigureIndex) {
+               
                initializeDrawing(parentFigureIndex);
-               drawTextContent();
+               showTextContent3D();
                endDrawing();
        }
        
@@ -97,6 +99,13 @@ public abstract class TextContentDrawerGL extends DrawableObjectGL implements Te
        }
        
        /**
+        * @return text center in pixel
+        */
+       protected Vector3D getTextCenterPix() {
+               return textCenterPix;
+       }
+       
+       /**
         * @return Font to use to display strings.
         */
        public Font getFont() {
@@ -221,9 +230,17 @@ public abstract class TextContentDrawerGL extends DrawableObjectGL implements Te
        }
        
        /**
+        * @param textMatrix new text matrxi to use
+        */
+       protected void setTextMatrix(StringMatrixGL textMatrix) {
+               this.textMatrix = textMatrix;
+       }
+       
+       /**
         * Draw a text on the screen.
+        * @return coordinates of the 4 corners of the text in pixels
         */
-       public void drawTextContent() {
+       public Vector3D[] drawTextContent3D() {
                
                GL gl = getGL();
                gl.glDisable(GL.GL_COLOR_LOGIC_OP); // does not work well with thext rendering
@@ -231,27 +248,53 @@ public abstract class TextContentDrawerGL extends DrawableObjectGL implements Te
                CoordinateTransformation transform = CoordinateTransformation.getTransformation(gl);
 
                //Put the text on the figure
-               /*gl.glRasterPos3d(getTextCenter().getX(), getTextCenter().getY(), getTextCenter().getZ());
-               GL2PS gl2ps = new GL2PS();
-               gl2ps.gl2psText("totototot", "Courier", (short) 12);*/
        
+               textCenterPix = transform.getCanvasCoordinates(gl, getTextCenter());
                
-               Vector3D textCenterPix = transform.getCanvasCoordinates(gl, getTextCenter());
                // switch to pixel coordinates
                GLTools.usePixelCoordinates(gl);
                
                
-               
-               //textCenterPix = transform.retrieveSceneCoordinates(gl, textCenterPix);
-               
                // draw the text using the new coordinates
-               drawTextContentPix(textCenterPix);
+               Vector3D[] res = drawTextContentPix();
                
                
                GLTools.endPixelCoordinates(gl);
                
                gl.glEnable(GL.GL_COLOR_LOGIC_OP); // does not work well with thext rendering
                
+               for (int i = 0; i < res.length; i++) {
+                       res[i] = transform.retrieveSceneCoordinates(gl, res[i]);
+               }
+               return res;
+               
+       }
+       
+       /**
+        * Draw the text from already computed data
+        */
+       public void showTextContent3D() {
+               GL gl = getGL();
+               gl.glDisable(GL.GL_COLOR_LOGIC_OP); // does not work well with thext rendering
+               
+               // switch to pixel coordinates
+               GLTools.usePixelCoordinates(gl);
+               
+               // draw the text using the new coordinates
+               showTextContentPix();
+               
+               GLTools.endPixelCoordinates(gl);
+               
+               gl.glEnable(GL.GL_COLOR_LOGIC_OP); // does not work well with thext rendering
+       }
+       
+       /**
+        * Draw the text and compute its bounding box in pixels
+        * @return array of size 12 which is the concatenation of the 4 corners
+        *         where a corner is the array {cornerX, cornerY, cornerZ}.
+        */
+       public double[] drawTextContent() {
+               return convertToArray(drawTextContent3D());
        }
        
        /**
@@ -260,14 +303,21 @@ public abstract class TextContentDrawerGL extends DrawableObjectGL implements Te
         *         where a corner is the array {cornerX, cornerY, cornerZ}.
         */
        public double[] getBoundingRectangle() {
-               Vector3D[] resVect = getBoundingRectangle3D();
-               int nbCorner = resVect.length;
-               int nbDim = 2 + 1;
-               double[] res = new double[nbCorner * nbDim];
-               for (int i = 0; i < nbCorner; i++) {
-                       res[nbDim * i] = resVect[i].getX();
-                       res[nbDim * i + 1] = resVect[i].getY();
-                       res[nbDim * i + 2] = resVect[i].getZ();
+               return convertToArray(getBoundingRectangle3D());
+       }
+       
+       /**
+        * Concatenate the coordinates of each points into an array of double
+        * @param vects vectors to concatenate
+        * @return array of size nbVects * 3, containing the nummber of vectors
+        */
+       protected double[] convertToArray(Vector3D[] vects) {
+               int nbVects = vects.length;
+               double[] res = new double[nbVects * Vector3D.DIMENSION];
+               for (int i = 0; i < nbVects; i++) {
+                       res[Vector3D.DIMENSION * i] = vects[i].getX();
+                       res[Vector3D.DIMENSION * i + 1] = vects[i].getY();
+                       res[Vector3D.DIMENSION * i + 2] = vects[i].getZ();
                }
                return res;
        }
@@ -310,17 +360,10 @@ public abstract class TextContentDrawerGL extends DrawableObjectGL implements Te
        public Vector3D[] getBoundingRectangle2D() {
                GL gl = getGL();
                CoordinateTransformation transform = CoordinateTransformation.getTransformation(gl);
-               Vector3D textCenterPix = transform.getCanvasCoordinates(gl, getTextCenter());
+               textCenterPix = transform.getCanvasCoordinates(gl, getTextCenter());
                GLTools.usePixelCoordinates(gl);
                
-               //textCenterPix = transform.retrieveSceneCoordinates(gl, textCenterPix);
-               
-               Vector3D[] resPix = getBoundingRectanglePix(textCenterPix);
-               
-               // retrieve canvas coordinates
-               /*for (int i = 0; i < resPix.length; i++) {
-                       resPix[i] = transform.getCanvasCoordinates(gl, resPix[i]);
-               }*/
+               Vector3D[] resPix = getBoundingRectanglePix();
                
                GLTools.endPixelCoordinates(gl);
                return resPix;
@@ -369,16 +412,20 @@ public abstract class TextContentDrawerGL extends DrawableObjectGL implements Te
        
        /**
         * Draw the text using pixel coordinates.
-        * @param textCenterPix center of text to draw in pixels
+        * @return 4 corners of the rectangle bounding box.
+        */
+       public abstract Vector3D[] drawTextContentPix();
+       
+       /**
+        * Display some from text from already precomputed positions.
         */
-       public abstract void drawTextContentPix(Vector3D textCenterPix);
+       public abstract void showTextContentPix();
        
        /**
         * Compute the 4 corners of the bounding rectangle of the text in pixels coordinates.
-        * @param textCenterPix center of the text in pixel coordinates.
         * @return array of size 4 with the four corners.
         */
-       public abstract Vector3D[] getBoundingRectanglePix(Vector3D textCenterPix);
+       public abstract Vector3D[] getBoundingRectanglePix();
        
        /**
         * Get the bounding box of the text matrix centerd at the origin.
index cf922e5..ad19153 100644 (file)
@@ -26,6 +26,9 @@ public class Vector3D {
        public static final Vector3D Y_AXIS = new Vector3D(0.0, 1.0, 0.0);
        public static final Vector3D Z_AXIS = new Vector3D(0.0, 0.0, 1.0);
        
+       /** Number of dimensions in a Vector */
+       public static final int DIMENSION = 3;
+       
        private double xCoord;
        private double yCoord;
        private double zCoord;
index 4d4ede7..1d4c448 100644 (file)
@@ -115,7 +115,7 @@ jclass localStringArrayClass = curEnv->FindClass("Ljava/lang/String;");
 stringArrayClass = (jclass) curEnv->NewGlobalRef(localStringArrayClass);
 curEnv->DeleteLocalRef(localStringArrayClass);
 voidsetCenterPositionjdoublejdoublejdoubleID=NULL; 
-voiddrawTextContentID=NULL; 
+jdoubleArraydrawTextContentID=NULL; 
 jdoubleArraygetBoundingRectangleID=NULL; 
 jintArraygetScreenBoundingBoxID=NULL; 
 
@@ -156,7 +156,7 @@ jclass localStringArrayClass = curEnv->FindClass("Ljava/lang/String;");
 stringArrayClass = (jclass) curEnv->NewGlobalRef(localStringArrayClass);
 curEnv->DeleteLocalRef(localStringArrayClass);
 voidsetCenterPositionjdoublejdoublejdoubleID=NULL; 
-voiddrawTextContentID=NULL; 
+jdoubleArraydrawTextContentID=NULL; 
 jdoubleArraygetBoundingRectangleID=NULL; 
 jintArraygetScreenBoundingBoxID=NULL; 
 
@@ -380,23 +380,39 @@ curEnv->ExceptionDescribe() ;
                         
 }
 
-void CenteredTextDrawerGL::drawTextContent (){
+double * CenteredTextDrawerGL::drawTextContent (){
 
 JNIEnv * curEnv = getCurrentEnv();
 
-if (voiddrawTextContentID==NULL) { /* Use the cache Luke */ voiddrawTextContentID = curEnv->GetMethodID(this->instanceClass, "drawTextContent", "()V" ) ;
-if (voiddrawTextContentID == NULL) {
+if (jdoubleArraydrawTextContentID==NULL) { /* Use the cache Luke */ jdoubleArraydrawTextContentID = curEnv->GetMethodID(this->instanceClass, "drawTextContent", "()[D" ) ;
+if (jdoubleArraydrawTextContentID == NULL) {
 std::cerr << "Could not access to the method " << "drawTextContent" << std::endl;
 exit(EXIT_FAILURE);
 }
 }
-                         curEnv->CallVoidMethod( this->instance, voiddrawTextContentID );
+                        jdoubleArray res =  (jdoubleArray) curEnv->CallObjectMethod( this->instance, jdoubleArraydrawTextContentID );
                         
 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);
+
+                        curEnv->DeleteLocalRef(res);
+
+return myArray;
+
 }
 
 double * CenteredTextDrawerGL::getBoundingRectangle (){
index 522cbcb..e681370 100644 (file)
@@ -35,7 +35,7 @@
       <param type="double" name="centerY" />
       <param type="double" name="centerZ" />
     </method>
-    <method name="drawTextContent" returnType="void">
+    <method name="drawTextContent" returnType="double[]">
     </method>
     <method name="getBoundingRectangle" returnType="double[]">
     </method>
index 8e2a11d..a706402 100644 (file)
@@ -62,7 +62,7 @@ jmethodID voidsetTextParametersjintjintjintjdoublejdoublejintjintID; // cache me
 jmethodID voidsetTextContentjobjectArrayjintjintID; // cache method id
 jclass stringArrayClass;
 jmethodID voidsetCenterPositionjdoublejdoublejdoubleID; // cache method id
-jmethodID voiddrawTextContentID; // cache method id
+jmethodID jdoubleArraydrawTextContentID; // cache method id
 jmethodID jdoubleArraygetBoundingRectangleID; // cache method id
 jmethodID jintArraygetScreenBoundingBoxID; // cache method id
 
@@ -124,7 +124,7 @@ void setTextContent(char ** text, int textSize, long nbRow, long nbCol);
 
 void setCenterPosition(double centerX, double centerY, double centerZ);
 
-void drawTextContent();
+double * drawTextContent();
 
 double * getBoundingRectangle();
 
index e116fde..65d33a2 100644 (file)
@@ -76,4 +76,12 @@ void displayFigure(int figureId);
 public";
 void redrawFigure(int figureId);
 
-
+/* JavaDoc */
+%javamethodmodifiers redrawSubwins(int figureId) "
+ /**
+  * Redraw all the subwindows inside a figure.
+  * This should be called when the figure is resized.
+  * @param figureId index of the figure to redraw
+  */
+public";
+void redrawSubwins(int figureId);
index 81629a1..748e8ab 100644 (file)
@@ -199,6 +199,16 @@ SWIGEXPORT void JNICALL Java_org_scilab_modules_renderer_jni_FigureScilabCallJNI
 }
 
 
+SWIGEXPORT void JNICALL Java_org_scilab_modules_renderer_jni_FigureScilabCallJNI_redrawSubwins(JNIEnv *jenv, jclass jcls, jint jarg1) {
+  int arg1 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = (int)jarg1; 
+  redrawSubwins(arg1);
+}
+
+
 #ifdef __cplusplus
 }
 #endif
index 508ef66..41c176e 100644 (file)
@@ -115,7 +115,7 @@ jclass localStringArrayClass = curEnv->FindClass("Ljava/lang/String;");
 stringArrayClass = (jclass) curEnv->NewGlobalRef(localStringArrayClass);
 curEnv->DeleteLocalRef(localStringArrayClass);
 voidsetCenterPositionjdoublejdoublejdoubleID=NULL; 
-voiddrawTextContentID=NULL; 
+jdoubleArraydrawTextContentID=NULL; 
 jdoubleArraygetBoundingRectangleID=NULL; 
 jintArraygetScreenBoundingBoxID=NULL; 
 
@@ -156,7 +156,7 @@ jclass localStringArrayClass = curEnv->FindClass("Ljava/lang/String;");
 stringArrayClass = (jclass) curEnv->NewGlobalRef(localStringArrayClass);
 curEnv->DeleteLocalRef(localStringArrayClass);
 voidsetCenterPositionjdoublejdoublejdoubleID=NULL; 
-voiddrawTextContentID=NULL; 
+jdoubleArraydrawTextContentID=NULL; 
 jdoubleArraygetBoundingRectangleID=NULL; 
 jintArraygetScreenBoundingBoxID=NULL; 
 
@@ -380,23 +380,39 @@ curEnv->ExceptionDescribe() ;
                         
 }
 
-void FilledTextDrawerGL::drawTextContent (){
+double * FilledTextDrawerGL::drawTextContent (){
 
 JNIEnv * curEnv = getCurrentEnv();
 
-if (voiddrawTextContentID==NULL) { /* Use the cache Luke */ voiddrawTextContentID = curEnv->GetMethodID(this->instanceClass, "drawTextContent", "()V" ) ;
-if (voiddrawTextContentID == NULL) {
+if (jdoubleArraydrawTextContentID==NULL) { /* Use the cache Luke */ jdoubleArraydrawTextContentID = curEnv->GetMethodID(this->instanceClass, "drawTextContent", "()[D" ) ;
+if (jdoubleArraydrawTextContentID == NULL) {
 std::cerr << "Could not access to the method " << "drawTextContent" << std::endl;
 exit(EXIT_FAILURE);
 }
 }
-                         curEnv->CallVoidMethod( this->instance, voiddrawTextContentID );
+                        jdoubleArray res =  (jdoubleArray) curEnv->CallObjectMethod( this->instance, jdoubleArraydrawTextContentID );
                         
 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);
+
+                        curEnv->DeleteLocalRef(res);
+
+return myArray;
+
 }
 
 double * FilledTextDrawerGL::getBoundingRectangle (){
index b3d0353..da2ec12 100644 (file)
@@ -34,7 +34,7 @@
       <param type="double" name="centerY" />
       <param type="double" name="centerZ" />
     </method>
-    <method name="drawTextContent" returnType="void">
+    <method name="drawTextContent" returnType="double[]">
     </method>
     <method name="getBoundingRectangle" returnType="double[]">
     </method>
index 3ab870d..23770ca 100644 (file)
@@ -62,7 +62,7 @@ jmethodID voidsetTextParametersjintjintjintjdoublejintjintID; // cache method id
 jmethodID voidsetTextContentjobjectArrayjintjintID; // cache method id
 jclass stringArrayClass;
 jmethodID voidsetCenterPositionjdoublejdoublejdoubleID; // cache method id
-jmethodID voiddrawTextContentID; // cache method id
+jmethodID jdoubleArraydrawTextContentID; // cache method id
 jmethodID jdoubleArraygetBoundingRectangleID; // cache method id
 jmethodID jintArraygetScreenBoundingBoxID; // cache method id
 
@@ -124,7 +124,7 @@ void setTextContent(char ** text, int textSize, long nbRow, long nbCol);
 
 void setCenterPosition(double centerX, double centerY, double centerZ);
 
-void drawTextContent();
+double * drawTextContent();
 
 double * getBoundingRectangle();
 
index a428802..bcc5c4f 100644 (file)
@@ -115,7 +115,7 @@ jclass localStringArrayClass = curEnv->FindClass("Ljava/lang/String;");
 stringArrayClass = (jclass) curEnv->NewGlobalRef(localStringArrayClass);
 curEnv->DeleteLocalRef(localStringArrayClass);
 voidsetCenterPositionjdoublejdoublejdoubleID=NULL; 
-voiddrawTextContentID=NULL; 
+jdoubleArraydrawTextContentID=NULL; 
 jdoubleArraygetBoundingRectangleID=NULL; 
 jintArraygetScreenBoundingBoxID=NULL; 
 
@@ -156,7 +156,7 @@ jclass localStringArrayClass = curEnv->FindClass("Ljava/lang/String;");
 stringArrayClass = (jclass) curEnv->NewGlobalRef(localStringArrayClass);
 curEnv->DeleteLocalRef(localStringArrayClass);
 voidsetCenterPositionjdoublejdoublejdoubleID=NULL; 
-voiddrawTextContentID=NULL; 
+jdoubleArraydrawTextContentID=NULL; 
 jdoubleArraygetBoundingRectangleID=NULL; 
 jintArraygetScreenBoundingBoxID=NULL; 
 
@@ -380,23 +380,39 @@ curEnv->ExceptionDescribe() ;
                         
 }
 
-void StandardTextDrawerGL::drawTextContent (){
+double * StandardTextDrawerGL::drawTextContent (){
 
 JNIEnv * curEnv = getCurrentEnv();
 
-if (voiddrawTextContentID==NULL) { /* Use the cache Luke */ voiddrawTextContentID = curEnv->GetMethodID(this->instanceClass, "drawTextContent", "()V" ) ;
-if (voiddrawTextContentID == NULL) {
+if (jdoubleArraydrawTextContentID==NULL) { /* Use the cache Luke */ jdoubleArraydrawTextContentID = curEnv->GetMethodID(this->instanceClass, "drawTextContent", "()[D" ) ;
+if (jdoubleArraydrawTextContentID == NULL) {
 std::cerr << "Could not access to the method " << "drawTextContent" << std::endl;
 exit(EXIT_FAILURE);
 }
 }
-                         curEnv->CallVoidMethod( this->instance, voiddrawTextContentID );
+                        jdoubleArray res =  (jdoubleArray) curEnv->CallObjectMethod( this->instance, jdoubleArraydrawTextContentID );
                         
 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);
+
+                        curEnv->DeleteLocalRef(res);
+
+return myArray;
+
 }
 
 double * StandardTextDrawerGL::getBoundingRectangle (){
index 810478b..24250c8 100644 (file)
@@ -33,7 +33,7 @@
       <param type="double" name="centerY" />
       <param type="double" name="centerZ" />
     </method>
-    <method name="drawTextContent" returnType="void">
+    <method name="drawTextContent" returnType="double[]">
     </method>
     <method name="getBoundingRectangle" returnType="double[]">
     </method>
index 5d6b419..9cba3a0 100644 (file)
@@ -62,7 +62,7 @@ jmethodID voidsetTextParametersjintjintjintjdoublejdoubleID; // cache method id
 jmethodID voidsetTextContentjobjectArrayjintjintID; // cache method id
 jclass stringArrayClass;
 jmethodID voidsetCenterPositionjdoublejdoublejdoubleID; // cache method id
-jmethodID voiddrawTextContentID; // cache method id
+jmethodID jdoubleArraydrawTextContentID; // cache method id
 jmethodID jdoubleArraygetBoundingRectangleID; // cache method id
 jmethodID jintArraygetScreenBoundingBoxID; // cache method id
 
@@ -124,7 +124,7 @@ void setTextContent(char ** text, int textSize, long nbRow, long nbCol);
 
 void setCenterPosition(double centerX, double centerY, double centerZ);
 
-void drawTextContent();
+double * drawTextContent();
 
 double * getBoundingRectangle();