/** {@inheritDoc} */ public void callBack() { File f = new File(System.getenv("SCI")); if (f.exists() && f.isDirectory() && f.canRead()) { InterpreterManagement.requestScilabExec("chdir('" + f.getAbsolutePath() + "')"); FileBrowser.setBaseDir(f.getAbsolutePath()); } }
/** Change Global property forceGLCanvas if no GLJPanel is available, GLCanvas is forced */ public static boolean switchToGLCanvas(boolean onOrOff) { Debug.DEBUG("SwingScilabCanvasImpl", "switchToGLCanvas " + onOrOff); if (!onOrOff && noGLJPanel) { InterpreterManagement.requestScilabExec( Messages.gettext( "disp(\"WARNING: Despite of our previous warning, you choose to use Scilab with advanced graphics capabilities. Type \"\"help usecanvas\"\" for more information.\")")); } enableGLCanvas = onOrOff; return enableGLCanvas; }
static { long lastTime = Calendar.getInstance().getTimeInMillis(); Debug.DEBUG("SwingScilabCanvasImpl", "======================================="); String OS_NAME = System.getProperty("os.name"); Debug.DEBUG("SwingScilabCanvasImpl", "os.name=" + OS_NAME); String OS_ARCH = System.getProperty("os.arch"); Debug.DEBUG("SwingScilabCanvasImpl", "os.arch=" + OS_ARCH); Debug.DEBUG("SwingScilabCanvasImpl", "======================================="); /* * Bug #7526: moved out of the try/catch block since it contains * no OpenGL calls. */ if (OS_NAME.contains("Windows") && OS_ARCH.equals("amd64")) { // bug 3919 : JOGL x64 doesn't like x64 remote desktop on Windows // @TODO : bug report to JOGL String REMOTEDESKTOP = System.getenv("SCILAB_MSTS_SESSION"); if (REMOTEDESKTOP != null) { if (REMOTEDESKTOP.equals("OK")) { noGLJPanel = true; } } if (noGLJPanel) { /** Inform the users */ InterpreterManagement.requestScilabExec( String.format( "disp(\"%s\"), disp(\"%s\")", String.format( Messages.gettext( "WARNING: Due to your configuration limitations, Scilab switched in a mode where mixing uicontrols and graphics is not available. Type %s for more information."), "\"\"help usecanvas\"\""), String.format( Messages.gettext("In some cases, %s fixes the issue"), "\"\"system_setproperty(''jogl.gljpanel.nohw'','''');\"\""))); } } /* * Bug #7526: this code block causes a crash on Windows and Intel Graphic HD cards * with graphics drivers older than 8.15.10.2279 and is therefore not executed if * Windows is the OS (the tests on driver and OpenGL versions are Linux-specific). * Consequently, updateMaxCanvasSize, which determines the canvas size, is not called * any more on Windows. However, it is still called when an actual graphics window is created * (by the renderer module's SciRenderer init method), which still allows getting the maximum * canvas dimensions, so this should not be an issue. */ if (!OS_NAME.contains("Windows")) { try { GLCanvas tmpCanvas = new GLCanvas(new GLCapabilities(GLProfile.getDefault())); Frame tmpFrame = new Frame(); tmpFrame.add(tmpCanvas); tmpFrame.setVisible(true); tmpCanvas.getContext().makeCurrent(); GL gl = tmpCanvas.getGL(); String GL_VENDOR = gl.glGetString(GL.GL_VENDOR); Debug.DEBUG("SwingScilabCanvasImpl", "GL_VENDOR=" + GL_VENDOR); String GL_RENDERER = gl.glGetString(GL.GL_RENDERER); Debug.DEBUG("SwingScilabCanvasImpl", "GL_RENDERER=" + GL_RENDERER); String GL_VERSION = gl.glGetString(GL.GL_VERSION); Debug.DEBUG("SwingScilabCanvasImpl", "GL_VERSION=" + GL_VERSION); // Debug.DEBUG("SwingScilabCanvasImpl", "GL_EXTENSIONS="+gl.glGetString(GL.GL_EXTENSIONS)); Debug.DEBUG("SwingScilabCanvasImpl", "======================================="); // System.getProperties().list(System.err); // get maximum axes size // RenderingCapabilities.updateMaxCanvasSize(gl); tmpCanvas.getContext().release(); tmpFrame.remove(tmpCanvas); tmpFrame.setVisible(false); tmpFrame.dispose(); Debug.DEBUG( "SwingScilabCanvasImpl", "Testing time = " + (Calendar.getInstance().getTimeInMillis() - lastTime) + "ms"); noGLJPanel = false; // By default disable GLJPanel on Linux if (OS_NAME.contains("Linux")) { noGLJPanel = true; // Linux && NVIDIA if (GL_VENDOR.contains("NVIDIA")) { noGLJPanel = false; } // Linux && ATI if (GL_VENDOR.contains("ATI")) { StringTokenizer stSpace = new StringTokenizer(GL_VERSION, " "); StringTokenizer stDot = new StringTokenizer(stSpace.nextToken(), "."); int majorVersion = Integer.parseInt(stDot.nextToken()); int minorVersion = Integer.parseInt(stDot.nextToken()); int releaseVersion = Integer.parseInt(stDot.nextToken()); // Only OpenGL version newer than 2.1.7873 works // available through ATI 8.8 installer // and driver newer than 8.52.3 Debug.DEBUG( "SwingScilabCanvasImpl", "majorVersion = " + majorVersion + " minorVersion = " + minorVersion + " releaseVersion = " + releaseVersion); if (majorVersion > 2 || majorVersion == 2 && minorVersion > 1 || majorVersion == 2 && minorVersion == 1 && releaseVersion >= 7873) { noGLJPanel = false; } } } if (noGLJPanel) { /** Inform the users */ InterpreterManagement.requestScilabExec( String.format( "disp(\"%s\"), disp(\"%s\")", String.format( Messages.gettext( "WARNING: Due to your configuration limitations, Scilab switched in a mode where mixing uicontrols and graphics is not available. Type %s for more information."), "\"\"help usecanvas\"\""), String.format( Messages.gettext("In some cases, %s fixes the issue"), "\"\"system_setproperty(''jogl.gljpanel.nohw'','''');\"\""))); } } catch (GLException e) { noGLJPanel = true; /** Inform the users */ InterpreterManagement.requestScilabExec( String.format( "disp(\"%s\"), disp(\"%s\")", Messages.gettext( "Due to your video card drivers limitations, that are not able to manage OpenGL, Scilab will not be able to draw any graphics. Please update your driver."), String.format( Messages.gettext("In some cases, %s fixes the issue"), "\"\"system_setproperty(''jogl.gljpanel.nohw'','''');\"\""))); } catch (HeadlessException e) { // do not print anything on a CLI only environment noGLJPanel = true; } } }
/** * This method is called by the OSXAdapter class when the specific Mac OS X "Preferences" menu is * called. It is the only case where this method should be used */ public void macosxPreferences() { InterpreterManagement.requestScilabExec("preferences();"); }
/** * This method is called by the OSXAdapter class when the specific Mac OS X "Quit Scilab" menu is * called. It is the only case where this method should be used */ public boolean macosxQuit() { InterpreterManagement.requestScilabExec("exit()"); return false; }
/** * This method is called by the OSXAdapter class when the specific Mac OS X "About" menu is * called. It is the only case where this method should be used */ public void macosxAbout() { InterpreterManagement.requestScilabExec("about()"); }
private static final void chDir(String path) { File f = new File(path); if (f.exists() && f.isDirectory() && f.canRead()) { InterpreterManagement.requestScilabExec("chdir('" + path + "')"); } }
/** * Threats the event * * @param e the action event that occurred * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { if (isWindows()) { InterpreterManagement.putCommandInScilabQueue("consolebox('toggle');"); } }