Fix xclick in drawlater mode.
Jean-baptiste Silvy [Mon, 18 Feb 2008 16:13:08 +0000 (16:13 +0000)]
Add the drawing of only a single object.

28 files changed:
scilab/modules/graphics/includes/Axes.h
scilab/modules/graphics/sci_gateway/c/sci_StringBox.c
scilab/modules/graphics/sci_gateway/c/sci_draw.c
scilab/modules/graphics/sci_gateway/c/sci_xclick.c
scilab/modules/graphics/src/c/Axes.c
scilab/modules/graphics/src/c/GetProperty.c
scilab/modules/graphics/src/c/InitObjects.c
scilab/modules/graphics/src/c/Interaction.c
scilab/modules/renderer/graphics_Import.def
scilab/modules/renderer/includes/DrawingBridge.h
scilab/modules/renderer/src/cpp/DrawingBridge.cpp
scilab/modules/renderer/src/cpp/figureDrawing/ConcreteDrawableFigure.cpp
scilab/modules/renderer/src/cpp/figureDrawing/ConcreteDrawableFigure.h
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/rectangleDrawing/DrawableRectangle.cpp
scilab/modules/renderer/src/cpp/subwinDrawing/DrawableSubwin.cpp
scilab/modules/renderer/src/cpp/subwinDrawing/DrawableSubwin.h
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/jni/DrawableFigureGL.cpp
scilab/modules/renderer/src/jni/DrawableFigureGL.giws.xml
scilab/modules/renderer/src/jni/DrawableFigureGL.hxx

index 7a0b02b..0f6e76c 100644 (file)
@@ -42,5 +42,10 @@ void initSubWinBounds( sciPointObj * pSubWin ) ;
 /* return TRUE if the window has been redrawn */
 BOOL checkRedrawing( void ) ;
 
+/**
+ * Update subwin size and scale
+ */
+void updateSubwinScale(sciPointObj * pSubwin);
+
 /*-----------------------------------------------------------------------------*/
 #endif /*__SCI_AXES_H_*/
index 4ff2594..cb60e25 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 */
-  sciDrawObj(pText);
+  sciDrawSingleObj(pText);
 
   /* get the string box */
   sciGet2dViewBoundingBox( pText, corners[0], corners[1], corners[2], corners[3]) ;
index 9986828..bb51fc1 100644 (file)
@@ -31,7 +31,7 @@
 int sci_draw( char * fname, unsigned long fname_len )
 { 
   unsigned long hdl;
-  sciPointObj *pobj, *psubwin, *tmpsubwin;
+  sciPointObj *pobj;
   integer m,n,l,lw;
 
   CheckRhs(0,1) ;
@@ -54,25 +54,8 @@ int sci_draw( char * fname, unsigned long fname_len )
     pobj = sciGetPointerFromHandle(hdl);   
   }
   if (pobj != NULL )
-  {  
-    tmpsubwin = sciGetCurrentSubWin(); 
-    psubwin = sciGetParentSubwin(pobj);
-    if ( psubwin != NULL )
-    {
-      sciSetSelectedSubWin(psubwin); 
-      set_scale ("tttftt", pSUBWIN_FEATURE (psubwin)->WRect, 
-        pSUBWIN_FEATURE (psubwin)->FRect,
-        NULL, pSUBWIN_FEATURE (psubwin)->logflags, 
-        pSUBWIN_FEATURE (psubwin)->ARect); 
-
-      sciDrawObj(pobj); 
-      sciSetSelectedSubWin(tmpsubwin);
-    }
-    else
-    {
-      Scierror(999,_("%s: Object has no parent.\n"),fname);
-      return 0;
-    }
+  {
+    sciDrawSingleObj(pobj);
   }
 
   LhsVar(1) = 0;
index 895e2b1..64dff11 100644 (file)
@@ -2,6 +2,7 @@
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2006 - INRIA - Fabrice Leray
  * Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy
+ * Copyright (C) 2007 - INRIA - Vincent Couvert
  * 
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
@@ -27,6 +28,7 @@
 #include "GetProperty.h"
 #include "ObjectSelection.h"
 #include "WindowList.h"
+#include "Axes.h"
 /*--------------------------------------------------------------------------*/
 int sci_xclick(char *fname,unsigned long fname_len)
 {
@@ -53,16 +55,18 @@ int sci_xclick(char *fname,unsigned long fname_len)
 
   // Get return values
   mouseButtonNumber = getJxclickMouseButtonNumber();
-  pixelCoords[0] = getJxclickXCoordinate();
-  pixelCoords[1] = getJxclickYCoordinate();
+  pixelCoords[0] = (int) getJxclickXCoordinate();
+  pixelCoords[1] = (int) getJxclickYCoordinate();
   windowID = getJxclickWindowID();
   menuCallback = getJxclickMenuCallback();
 
   // Convert pixel coordinates to user coordinates
   // Conversion is not done if the user clicked on a menu (pixelCoords[*] == -1)
-  if (pixelCoords[0]!=-1 && pixelCoords[1]!=-1)
+  if (pixelCoords[0] != -1 && pixelCoords[1] != -1)
     {
-      sciGet2dViewCoordFromPixel(sciGetFirstTypedSelectedSon(getFigureFromIndex(windowID), SCI_SUBWIN), pixelCoords, userCoords2D);
+      sciPointObj * clickedSubwin = sciGetFirstTypedSelectedSon(getFigureFromIndex(windowID), SCI_SUBWIN);
+      updateSubwinScale(clickedSubwin);
+      sciGet2dViewCoordFromPixel(clickedSubwin, pixelCoords, userCoords2D);
     }
   else
     {
index ed56dc2..8bd1df7 100644 (file)
@@ -30,6 +30,8 @@
 #include "SetProperty.h"
 #include "axesScale.h"
 #include "CurrentObjectsManagement.h"
+#include "DrawingBridge.h"
+#include "pixel_mode.h"
 
 
 #include "MALLOC.h" /* MALLOC */
@@ -136,5 +138,22 @@ 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);
+}
 /*--------------------------------------------------------------------------------*/
index 5569435..a32ae12 100644 (file)
@@ -42,6 +42,7 @@
 #include "GetJavaProperty.h"
 #include "BasicAlgos.h"
 #include "localization.h"
+#include "Axes.h"
 
 #include "MALLOC.h" /* MALLOC */
 
@@ -4325,7 +4326,7 @@ void sciGetZoomBox(sciPointObj * pObj, double zoomBox[6])
  * Get the 4 corners of the bounding box of a text object in 3D
  */
 void sciGetTextBoundingBox(sciPointObj * pObj, double corner1[3], double corner2[3],
-                            double corner3[3], double corner4[3])
+                           double corner3[3], double corner4[3])
 {
   switch (sciGetEntityType(pObj))
   {
index 4aeb3af..c15e64a 100644 (file)
@@ -815,7 +815,7 @@ sciInitGraphicMode (sciPointObj * pobj)
          (sciGetGraphicMode (pobj))->addplot = TRUE;
          (sciGetGraphicMode (pobj))->autoscaling = TRUE;
          (sciGetGraphicMode (pobj))->zooming = FALSE;
-         (sciGetGraphicMode (pobj))->xormode = 3;
+         (sciGetGraphicMode (pobj))->xormode = 3; /* copy */
        }
       else
        {
index 7ff7510..4a2a57b 100644 (file)
@@ -729,7 +729,7 @@ int Objmove (sciPointObj * pobj, double d[], int m,BOOL opt)
   if (opt)
   {
     /* should be sci draw single obj */
-    sciRefreshObj(pobj);
+    sciDrawSingleObj(pobj);
   }
   else
   {
index 2febf54..de174ff 100644 (file)
@@ -130,3 +130,6 @@ copyFormatedArray
 ComputeC_format
 destroyGraphicPointer
 destroyGraphicStringArray
+sciGetIsAutoDrawable
+sciSetXorMode
+getPixelModeIndex
index 0e58609..ac39337 100644 (file)
@@ -31,6 +31,12 @@ extern "C" {
   void sciDrawObj( sciPointObj * pObj ) ;
 
   /**
+  * Draw a single graphic handle.
+  * Should normally not be called directly. Observers should call it automatically.
+  */
+  void sciDrawSingleObj( sciPointObj * pObj ) ;
+
+  /**
    * Redraw an object and all its children.
    * To be called on a figure to redraw a whole window
    */
index af9eb76..24b7689 100644 (file)
@@ -42,6 +42,13 @@ void sciDrawObj( sciPointObj * pObj )
   getHandleDrawer( sciGetParentFigure( pObj ) )->display() ;
 }
 /*---------------------------------------------------------------------------------*/
+void sciDrawSingleObj( sciPointObj * pObj )
+{
+  /* force a redraw of the object */
+  getHandleDrawer(pObj)->hasChanged();
+  getFigureDrawer(sciGetParentFigure(pObj))->drawSingleObj(pObj);
+}
+/*---------------------------------------------------------------------------------*/
 void displayChildren( sciPointObj * pObj )
 {
   getHandleDrawer( pObj )->displayChildren() ;
index 4e69220..a2df5f6 100644 (file)
@@ -7,18 +7,72 @@
 /*------------------------------------------------------------------------*/
 
 #include "ConcreteDrawableFigure.h"
+#include "getHandleDrawer.h"
 
 extern "C"
 {
 #include "GetProperty.h"
+#include "pixel_mode.h"
+#include "SetProperty.h"
 }
 
 namespace sciGraphics
 {
 /*---------------------------------------------------------------------------------*/
+ConcreteDrawableFigure::ConcreteDrawableFigure( sciPointObj * pObj )
+    : DrawableFigure( pObj )
+{
+  m_pSingleObject = NULL;
+}
+/*---------------------------------------------------------------------------------*/
+ConcreteDrawableFigure::~ConcreteDrawableFigure(void)
+{
+  m_pSingleObject = NULL;
+}
+/*---------------------------------------------------------------------------------*/
+void ConcreteDrawableFigure::drawSingleObj(sciPointObj * pObj)
+{
+  // set the single object to draw
+  m_pSingleObject = pObj;
+
+
+  int curPixelMode = sciGetXorMode(m_pDrawed);
+
+  // launch display
+  // displaySingleObject will be called
+  display();
+
+  sciSetXorMode(m_pDrawed, curPixelMode);
+
+  // restore normal mode
+  m_pSingleObject = NULL;
+}
+/*---------------------------------------------------------------------------------*/
 bool ConcreteDrawableFigure::checkAutoRedraw( void )
 {
-  return ( pFIGURE_FEATURE(m_pDrawed)->auto_redraw == TRUE ) ;
+  return ( sciGetIsAutoDrawable(m_pDrawed) == TRUE ) ;
+}
+/*---------------------------------------------------------------------------------*/
+bool ConcreteDrawableFigure::isDisplayingSingleObject(void)
+{
+  if (m_pSingleObject == NULL)
+  {
+    return false;
+  }
+
+  if (sciGetEntityType(m_pSingleObject) == SCI_FIGURE)
+  {
+    // should be itself so it is like a normal draw
+    return false;
+  }
+    
+  return true;
+}
+/*---------------------------------------------------------------------------------*/
+void ConcreteDrawableFigure::displaySingleObject(void)
+{
+  // tell the subwin to draw only this object
+  getSubwinDrawer(sciGetParentSubwin(m_pSingleObject))->displaySingleObj(m_pSingleObject);
 }
 /*---------------------------------------------------------------------------------*/
 
index 9bc373c..b332e06 100644 (file)
@@ -20,13 +20,39 @@ class ConcreteDrawableFigure : public DrawableFigure
 
 public:
 
-  ConcreteDrawableFigure( sciPointObj * pObj ) : DrawableFigure( pObj ) {}
+  ConcreteDrawableFigure( sciPointObj * pObj );
+
+  ~ConcreteDrawableFigure(void);
 
   /**
+   * Like display but to display only a single object
+   */
+  virtual void drawSingleObj(sciPointObj * pObj);
+
+protected:
+
+  /*------------------------------------------------------------------------*/
+  /**
    * check if the auto_redraw option is enable
    */
   virtual bool checkAutoRedraw( void ) ;
 
+  /**
+   * Check wether the whole figure and hierechy should be redrawn
+   * or just a single object.
+   */
+  virtual bool isDisplayingSingleObject(void);
+
+  /**
+   * Display the single object
+   */
+  virtual void displaySingleObject(void);
+  /*------------------------------------------------------------------------*/
+  sciPointObj * m_pSingleObject;
+  /*------------------------------------------------------------------------*/
+
+
+
 } ;
 
 }
index e150cdd..1bf8e09 100644 (file)
@@ -76,23 +76,41 @@ void DrawableFigure::closeRenderingCanvas( void )
   getFigureImp()->closeRenderingCanvas() ;
 }
 /*---------------------------------------------------------------------------------*/
+void DrawableFigure::drawBackground(void)
+{
+  getFigureImp()->drawBackground();
+}
+/*---------------------------------------------------------------------------------*/
 void DrawableFigure::drawInContext( void )
 {
   initializeDrawing() ;
-  setFigureParameters() ;
   // retest on auto_redraw
   // because display may come directly from JoGL
-  if ( checkVisibility() && checkAutoRedraw() )
+  if ( checkVisibility() )
   {
-    displayChildren() ;
+    if (isDisplayingSingleObject())
+    {
+      setFigureParameters() ;
+      displaySingleObject();
+    }
+    else
+    {
+      if (checkAutoRedraw())
+      {
+        drawBackground();
+        setFigureParameters() ;
+        displayChildren() ;
+      }
+    }
   }
   endDrawing() ;
 }
 /*---------------------------------------------------------------------------------*/
 void DrawableFigure::draw( void )
 { 
-  if ( !checkAutoRedraw() )
+  if ( !checkAutoRedraw() && !isDisplayingSingleObject() )
   {
+    // if a single object is available this override drawlater()/ drawnow()
     return ;
   }
 
index e5feb78..e0e4f9c 100644 (file)
@@ -31,6 +31,11 @@ public:
    */
   virtual void drawInContext( void ) ;
 
+  /**
+   * Like display but to display only a single object
+   */
+  virtual void drawSingleObj(sciPointObj * pObj) = 0;
+
   /*-----------------------------------------------------------------------------*/
   /* Set/Get properties */
 
@@ -102,6 +107,11 @@ public:
     */
    void openRenderingCanvas( void ) ;
 
+   /**
+    * Draw the background of the figure
+    */
+   void drawBackground(void);
+
   /*-----------------------------------------------------------------------------*/
    /**
     * Get the synchronization object that protect this figure.
@@ -139,6 +149,17 @@ protected:
    * check if the auto_redraw option is enable
    */
   virtual bool checkAutoRedraw( void ) = 0 ;
+
+  /**
+   * Check wether the whole figure and hierechy should be redrawn
+   * or just a single object.
+   */
+  virtual bool isDisplayingSingleObject(void) = 0;
+
+  /**
+   * Display the single object
+   */
+  virtual void displaySingleObject(void) = 0;
   /*-----------------------------------------------------------------------------*/
   // Driver dependant algorithms
 
index 3e4b315..0ea5809 100644 (file)
@@ -47,6 +47,11 @@ public:
   virtual void setFigureParameters(void) = 0 ;
 
   /**
+   * Draw the background of the figure
+   */
+  virtual void drawBackground(void) = 0;
+
+  /**
    * Set a new colormap to this figure
    * @param nbColor x 3 matrix contains the three channels RGB of each color
    * @param nbColor number of color in the colormap
index ace9835..b664d10 100644 (file)
@@ -68,9 +68,14 @@ void DrawableFigureJavaMapper::closeRenderingCanvas(void)
   m_pJavaObject->closeRenderingCanvas();
 }
 /*---------------------------------------------------------------------------------*/
-void DrawableFigureJavaMapper::setFigureParameters(int backgroundColor, int logicOpIndex)
+void DrawableFigureJavaMapper::drawBackground(int colorIndex)
 {
-  m_pJavaObject->setFigureParameters(backgroundColor, logicOpIndex);
+  m_pJavaObject->drawBackground(colorIndex); 
+}
+/*---------------------------------------------------------------------------------*/
+void DrawableFigureJavaMapper::setLogicalOp(int logicOpIndex)
+{
+  m_pJavaObject->setLogicalOp(logicOpIndex);
 }
 /*---------------------------------------------------------------------------------*/
 void DrawableFigureJavaMapper::setColorMapData(const double rgbmat[], int nbColor)
index c09b071..946e9d6 100644 (file)
@@ -41,7 +41,10 @@ public:
 
   virtual void closeRenderingCanvas(void);
 
-  virtual void setFigureParameters(int backgroundColor, int logicOpIndex);
+  virtual void drawBackground(int colorIndex);
+  
+  virtual void setLogicalOp(int logicOpIndex);
+
 
   virtual void setColorMapData(const double rgbmat[], int nbColor);
   virtual void getColorMapData(double rgbmat[]);
index a1a2bb2..339072b 100644 (file)
@@ -60,8 +60,13 @@ void DrawableFigureJoGL::closeRenderingCanvas( void )
 void DrawableFigureJoGL::setFigureParameters(void)
 {
   sciPointObj * pFigure = getFigureDrawer()->getDrawedObject();
-  getFigureJavaMapper()->setFigureParameters(sciGetGraphicContext(pFigure)->backgroundcolor,
-                                             sciGetXorMode(pFigure));
+  getFigureJavaMapper()->setLogicalOp(sciGetXorMode(pFigure));
+}
+/*---------------------------------------------------------------------------------*/
+void DrawableFigureJoGL::drawBackground(void)
+{
+  sciPointObj * pFigure = getFigureDrawer()->getDrawedObject();
+  getFigureJavaMapper()->drawBackground(sciGetGraphicContext(pFigure)->backgroundcolor);
 }
 /*---------------------------------------------------------------------------------*/
 void DrawableFigureJoGL::setColorMap( const double rgbMat[], int nbColor )
index 149ee9c..fdd8d40 100644 (file)
@@ -48,6 +48,11 @@ public:
   virtual void setFigureParameters(void) ;
 
   /**
+   * Draw the background of the figure
+   */
+  virtual void drawBackground(void);
+
+  /**
    * Set a new colormap to this figure
    * @param nbColor x 3 matrix contains the three channels RGB of each color
    * @param nbColor number of color in the colormap
index f18f126..7ae7ab1 100644 (file)
@@ -5,9 +5,10 @@
 /* desc : Class containing the drawing routine for a rectangle object     */
 /*------------------------------------------------------------------------*/
 
-#include "DrawableRectangle.h"
 
 
+#include "DrawableRectangle.h"
+
 namespace sciGraphics
 {
 
@@ -21,6 +22,7 @@ DrawableRectangle::~DrawableRectangle( void )
 /*---------------------------------------------------------------------------------*/
 void DrawableRectangle::draw( void )
 {
+
   initializeDrawing() ;
   if ( !checkVisibility() )
   {
@@ -31,6 +33,7 @@ void DrawableRectangle::draw( void )
   drawRectangle() ;
   unClip();
   endDrawing();
+
 }
 /*---------------------------------------------------------------------------------*/
 void DrawableRectangle::show( void )
index 0b2f520..0050c21 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "DrawableSubwin.h"
 #include "DrawableSubwinBridge.h"
+#include "getHandleDrawer.h"
 
 extern "C"
 {
@@ -41,21 +42,51 @@ void DrawableSubwin::setCamera( Camera * cam )
   m_pCamera = cam;
 }
 /*---------------------------------------------------------------------------------*/
-void DrawableSubwin::draw( void )
+void DrawableSubwin::displaySingleObj(sciPointObj * pObj)
 {
-  initializeDrawing() ;
-  if ( !checkVisibility() )
+
+  if (sciGetEntityType(pObj) == SCI_SUBWIN)
   {
-    endDrawing();
-    return;
+    if (m_bNeedRedraw)
+    {
+      draw();
+    }
+    else
+    {
+      show();
+    }
+  }
+  // it is a child
+  else if (m_bNeedRedraw)
+  {
+    drawSingleObj(pObj);
+  }
+  else
+  {
+    showSingleObj(pObj);
   }
+}
+/*---------------------------------------------------------------------------------*/
+void DrawableSubwin::draw( void )
+{
+  initializeDrawing() ;
 
   // fill Frect with real data bounds
   computeRealDataBounds();
 
   // set up camera
+  // so update coordinates transformations
   m_pCamera->draw();
 
+  if ( !checkVisibility() )
+  {
+    // needed
+    m_pCamera->replaceCamera();
+
+    endDrawing();
+    return;
+  }
+
   drawAxesBox();
 
   displayChildren() ;
@@ -68,16 +99,22 @@ void DrawableSubwin::draw( void )
 /*---------------------------------------------------------------------------------*/
 void DrawableSubwin::show( void )
 {
+  
   initializeDrawing() ;
+
+  // set up camera
+  // so update coordinates transformations
+  m_pCamera->show();
+
   if ( !checkVisibility() )
   {
+    // needed
+    m_pCamera->replaceCamera();
+
     endDrawing();
     return;
   }
 
-  // set up camera
-  m_pCamera->show();
-
   showAxesBox();
 
   displayChildren() ;
@@ -99,6 +136,62 @@ void DrawableSubwin::showAxesBox(void)
   showBox();
   showTicks();
 }
+/*------------------------------------------------------------------------------------------*/
+void DrawableSubwin::drawSingleObj(sciPointObj * pObj)
+{
+
+  initializeDrawing() ;
+
+  // fill Frect with real data bounds
+  computeRealDataBounds();
+
+  // set up camera
+  m_pCamera->draw();
+
+  if ( !checkVisibility() )
+  {
+    // needed
+    m_pCamera->replaceCamera();
+
+    endDrawing();
+    return;
+  }
+
+  // camera has been set
+  // display only the children
+  getHandleDrawer(pObj)->display();
+
+  // needed
+  m_pCamera->replaceCamera();
+
+  endDrawing();
+}
+/*------------------------------------------------------------------------------------------*/
+void DrawableSubwin::showSingleObj(sciPointObj * pObj)
+{
+  initializeDrawing() ;
+
+  // set up camera
+  m_pCamera->show();
+
+  if ( !checkVisibility() )
+  {
+    // needed
+    m_pCamera->replaceCamera();
+
+    endDrawing();
+    return;
+  }
+
+  // camera has been set
+  // display only the children
+  getHandleDrawer(pObj)->display();
+
+  // needed
+  m_pCamera->replaceCamera();
+
+  endDrawing();
+}
 /*---------------------------------------------------------------------------------*/
 DrawableSubwinBridge * DrawableSubwin::getSubwinImp( void )
 {
index 418606f..3c8859a 100644 (file)
@@ -35,6 +35,12 @@ public:
    */
   void setCamera( Camera * cam ) ;
 
+  /**
+   * Display the subwin by just setting the camera
+   * and its children pObj
+   */
+  void displaySingleObj(sciPointObj * pObj);
+
 protected:
 
   /**
@@ -80,6 +86,18 @@ protected:
   virtual void showTicks(void) = 0;
 
   /**
+   * draw the subwin by just setting the camera
+   * and its children pObj
+   */
+  virtual void drawSingleObj(sciPointObj * pObj);
+
+  /**
+   * show the subwin by just setting the camera
+   * and its children pObj
+   */
+  virtual void showSingleObj(sciPointObj * pObj);
+
+  /**
    * Return the real type of implementation object
    */
   DrawableSubwinBridge * getSubwinImp( void ) ;
index 4ae90e3..f4341d3 100644 (file)
@@ -144,8 +144,11 @@ public class DrawableFigureGL extends ObjectGL {
                destroyedObjects.destroyAll(parentFigureIndex);
                
                super.initializeDrawing(parentFigureIndex);
+               
                GL gl = getGL();
-               gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+               // don't clear the color buffer as usual, we may need to keep it
+               // depending on the pixel mode
+               gl.glClear(GL.GL_DEPTH_BUFFER_BIT);
                gl.glClearDepth(1.0f);
        }
        
@@ -239,9 +242,38 @@ public class DrawableFigureGL extends ObjectGL {
         * Set the background color of the figure
         * @param colorIndex index of the color to use
         */
-       public void setBackgroundColor(int colorIndex) {
+       public void drawBackground(int colorIndex) {
+               GL gl = getGL();
                double[] color = getColorMap().getColor(colorIndex);
-               getGL().glClearColor((float) color[0], (float) color[1], (float) color[2], 1.0f); // alpha is set to 1
+               // not really needed actually
+               gl.glClearColor((float) color[0], (float) color[1], (float) color[2], 1.0f); // alpha is set to 1
+               
+               // for compatibility with Scilab 4
+               // logic_op only applies to axes (not to background)
+               gl.glDisable(GL.GL_COLOR_LOGIC_OP);
+           gl.glColorMask(true, true, true, false);
+               
+               // draw a quad in the background with color mode
+               
+           // set up very basic view
+           gl.glMatrixMode(GL.GL_PROJECTION);
+           gl.glLoadIdentity();
+           gl.glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
+           gl.glMatrixMode(GL.GL_MODELVIEW);
+           gl.glLoadIdentity();
+           
+           // not needed here it should be drawn first
+           gl.glDisable(GL.GL_DEPTH_TEST);
+           gl.glColor3d(color[0], color[1], color[2]);
+           
+           // draw it in the back just to be sure
+           gl.glBegin(GL.GL_QUADS);
+           gl.glVertex3d(0.0, 0.0, 1.0);
+           gl.glVertex3d(1.0, 0.0, 1.0);
+           gl.glVertex3d(1.0, 1.0, 1.0);
+           gl.glVertex3d(0.0, 1.0, 1.0);
+           gl.glEnd();
+           gl.glEnable(GL.GL_DEPTH_TEST);
        }
        
        
@@ -251,17 +283,9 @@ public class DrawableFigureGL extends ObjectGL {
         */
        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);
+               GL gl = getGL();
+               gl.glEnable(GL.GL_COLOR_LOGIC_OP); // to use pixel drawing mode
+               gl.glLogicOp(LOGICAL_OPS[logicOpIndex]);
        }
        
        /**
index 925fbb5..3b7b417 100644 (file)
@@ -92,12 +92,12 @@ public class SciRenderer
       GL gl = gLDrawable.getGL();
       gl.glShadeModel(GL.GL_SMOOTH);              // Enable Smooth Shading
       gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);    // white Background
+      gl.glClear(GL.GL_COLOR_BUFFER_BIT); // clear here othrwise we don't know what we will have
       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 fast
-      gl.glDisable(GL.GL_LINE_SMOOTH); // we prefer thin lines
-         gl.glEnable(GL.GL_COLOR_LOGIC_OP); // to use pixel drawing mode
+      gl.glDisable(GL.GL_LINE_SMOOTH); // we prefer thin line
 
     }
     
index 8ee5a81..df8c349 100644 (file)
@@ -104,7 +104,8 @@ voiddestroyjintID=NULL;
 voidsetFigureIndexjintID=NULL; 
 voiddrawCanvasID=NULL; 
 voidcloseRenderingCanvasID=NULL; 
-voidsetFigureParametersjintjintID=NULL; 
+voiddrawBackgroundjintID=NULL; 
+voidsetLogicalOpjintID=NULL; 
 voidsetColorMapDatajdoubleArrayID=NULL; 
 jdoubleArraygetColorMapDataID=NULL; 
 jintgetColorMapSizeID=NULL; 
@@ -150,7 +151,8 @@ voiddestroyjintID=NULL;
 voidsetFigureIndexjintID=NULL; 
 voiddrawCanvasID=NULL; 
 voidcloseRenderingCanvasID=NULL; 
-voidsetFigureParametersjintjintID=NULL; 
+voiddrawBackgroundjintID=NULL; 
+voidsetLogicalOpjintID=NULL; 
 voidsetColorMapDatajdoubleArrayID=NULL; 
 jdoubleArraygetColorMapDataID=NULL; 
 jintgetColorMapSizeID=NULL; 
@@ -351,18 +353,38 @@ curEnv->ExceptionDescribe() ;
                         
 }
 
-void DrawableFigureGL::setFigureParameters (long backgroundColor, long logicOpIndex){
+void DrawableFigureGL::drawBackground (long backgroundColor){
 
 JNIEnv * curEnv = getCurrentEnv();
 jclass cls = curEnv->FindClass( className().c_str() );
 
-jmethodID voidsetFigureParametersjintjintID = curEnv->GetMethodID(this->instanceClass, "setFigureParameters", "(II)V" ) ;
-if (voidsetFigureParametersjintjintID == NULL) {
-std::cerr << "Could not access to the method " << "setFigureParameters" << std::endl;
+jmethodID voiddrawBackgroundjintID = curEnv->GetMethodID(this->instanceClass, "drawBackground", "(I)V" ) ;
+if (voiddrawBackgroundjintID == NULL) {
+std::cerr << "Could not access to the method " << "drawBackground" << std::endl;
 exit(EXIT_FAILURE);
 }
 
-                         curEnv->CallVoidMethod( this->instance, voidsetFigureParametersjintjintID ,backgroundColor, logicOpIndex);
+                         curEnv->CallVoidMethod( this->instance, voiddrawBackgroundjintID ,backgroundColor);
+                        
+if (curEnv->ExceptionOccurred()) {
+curEnv->ExceptionDescribe() ;
+}
+
+                        
+}
+
+void DrawableFigureGL::setLogicalOp (long logicOpIndex){
+
+JNIEnv * curEnv = getCurrentEnv();
+jclass cls = curEnv->FindClass( className().c_str() );
+
+jmethodID voidsetLogicalOpjintID = curEnv->GetMethodID(this->instanceClass, "setLogicalOp", "(I)V" ) ;
+if (voidsetLogicalOpjintID == NULL) {
+std::cerr << "Could not access to the method " << "setLogicalOp" << std::endl;
+exit(EXIT_FAILURE);
+}
+
+                         curEnv->CallVoidMethod( this->instance, voidsetLogicalOpjintID ,logicOpIndex);
                         
 if (curEnv->ExceptionOccurred()) {
 curEnv->ExceptionDescribe() ;
index e08c322..1e6c5dd 100644 (file)
     </method>
     <method name="closeRenderingCanvas" returnType="void">
     </method>
-    <method name="setFigureParameters" returnType="void">
+    <method name="drawBackground" returnType="void">
       <param type="int" name="backgroundColor" />
+    </method>
+    <method name="setLogicalOp" returnType="void">
       <param type="int" name="logicOpIndex" />
     </method>
     <method name="setColorMapData" returnType="void">
index 444fd23..ea731fb 100644 (file)
@@ -60,7 +60,8 @@ jmethodID voiddestroyjintID; // cache method id
 jmethodID voidsetFigureIndexjintID; // cache method id
 jmethodID voiddrawCanvasID; // cache method id
 jmethodID voidcloseRenderingCanvasID; // cache method id
-jmethodID voidsetFigureParametersjintjintID; // cache method id
+jmethodID voiddrawBackgroundjintID; // cache method id
+jmethodID voidsetLogicalOpjintID; // cache method id
 jmethodID voidsetColorMapDatajdoubleArrayID; // cache method id
 jmethodID jdoubleArraygetColorMapDataID; // cache method id
 jmethodID jintgetColorMapSizeID; // cache method id
@@ -134,7 +135,9 @@ void drawCanvas();
 
 void closeRenderingCanvas();
 
-void setFigureParameters(long backgroundColor, long logicOpIndex);
+void drawBackground(long backgroundColor);
+
+void setLogicalOp(long logicOpIndex);
 
 void setColorMapData(double * rgbmat, int rgbmatSize);