26 #if defined (HAVE_CONFIG_H)
40 #if defined (HAVE_QOPENGLWIDGET)
41 # define OCTAVE_QT_OPENGL_WIDGET_FORMAT_ARGS
43 # if defined (Q_OS_WIN32)
44 # define OCTAVE_QT_OPENGL_WIDGET_FORMAT_ARGS \
45 QGLFormat (QGL::SampleBuffers | QGL::AlphaChannel \
46 | QGL::IndirectRendering),
48 # define OCTAVE_QT_OPENGL_WIDGET_FORMAT_ARGS \
49 QGLFormat (QGL::SampleBuffers | QGL::AlphaChannel),
54 octave::interpreter& interp,
57 Canvas (oct_qobj, interp, gh), m_glfcns (), m_renderer (m_glfcns)
59 setFocusPolicy (Qt::ClickFocus);
77 octave::autolock guard (gh_mgr.graphics_lock ());
79 graphics_object go = gh_mgr.get_object (gh);
83 graphics_object fig = go.get_ancestor (
"figure");
84 double dpr = fig.get (
"__device_pixel_ratio__").double_value ();
85 m_renderer.set_viewport (dpr * width (), dpr * height ());
98 graphics_object go = gh_mgr.get_object (gh);
100 if (go && go.isa (
"figure"))
102 Matrix pos = go.get (
"position").matrix_value ();
103 double dpr = go.get (
"__device_pixel_ratio__").double_value ();
114 if (go.get (
"visible").string_value () ==
"off"
115 || go.get (
"__printing__").string_value () ==
"on")
119 OCTAVE_QT_OPENGL_FBO::Attachment::Depth);
126 retval =
m_renderer.get_pixels (pos(2), pos(3));
135 retval =
m_renderer.get_pixels (pos(2), pos(3));
150 octave::autolock guard (gh_mgr.graphics_lock ());
152 graphics_object go = gh_mgr.get_object (handle);
154 if (go.valid_object ())
156 graphics_object fig (go.get_ancestor (
"figure"));
160 error (
"print: no valid OpenGL offscreen context");
164 if (fig.get (
"visible").string_value () ==
"on")
166 term.toStdString ());
171 Matrix pos = fig.get (
"position").matrix_value ();
172 double dpr = fig.get (
"__device_pixel_ratio__").double_value ();
178 OCTAVE_QT_OPENGL_FBO::Attachment::Depth);
183 term.toStdString ());
188 catch (octave::execution_exception& ee)
209 octave::opengl_selector s (
m_glfcns);
211 s.set_viewport (width (), height ());
212 return s.select (ax, pt.x (), height () - pt.y (),
216 return graphics_object ();
222 Matrix overlaycolor (3, 1);
223 overlaycolor(0) = 0.45;
224 overlaycolor(1) = 0.62;
225 overlaycolor(2) = 0.81;
226 double overlayalpha = 0.1;
227 Matrix bordercolor = overlaycolor;
228 double borderalpha = 0.9;
229 double borderwidth = 1.5;
231 m_renderer.draw_zoom_box (width (), height (),
232 p1.x (), p1.y (), p2.x (), p2.y (),
233 overlaycolor, overlayalpha,
234 bordercolor, borderalpha, borderwidth);
277 OCTAVE_QT_OPENGL_WIDGET::keyPressEvent (xevent);
284 OCTAVE_QT_OPENGL_WIDGET::keyReleaseEvent (xevent);
294 # if defined (HAVE_QT_OFFSCREEN)
295 static bool os_ctx_ok =
true;
296 if (os_ctx_ok && ! m_os_context.isValid ())
299 m_os_surface.create ();
300 if (! m_os_context.create ())
307 retval = m_os_context.makeCurrent (&m_os_surface);
#define OCTAVE_QT_OPENGL_WIDGET_FORMAT_ARGS
void canvasMouseReleaseEvent(QMouseEvent *event)
octave::interpreter & m_interpreter
void canvasPaintEvent(void)
void canvasMouseDoubleClickEvent(QMouseEvent *event)
bool canvasKeyReleaseEvent(QKeyEvent *event)
void interpreter_event(const octave::fcn_callback &fcn)
void canvasWheelEvent(QWheelEvent *event)
void canvasMousePressEvent(QMouseEvent *event)
void canvasMouseMoveEvent(QMouseEvent *event)
bool canvasKeyPressEvent(QKeyEvent *event)
bool begin_rendering(void)
void mouseReleaseEvent(QMouseEvent *event)
octave::opengl_renderer m_renderer
GLCanvas(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_handle &handle, QWidget *parent)
void keyReleaseEvent(QKeyEvent *event)
graphics_object selectFromAxes(const graphics_object &ax, const QPoint &pt)
void mousePressEvent(QMouseEvent *event)
void wheelEvent(QWheelEvent *event)
uint8NDArray do_getPixels(const graphics_handle &handle)
void keyPressEvent(QKeyEvent *event)
void mouseDoubleClickEvent(QMouseEvent *event)
void draw(const graphics_handle &handle)
void mouseMoveEvent(QMouseEvent *event)
octave::qopengl_functions m_glfcns
void drawZoomBox(const QPoint &p1, const QPoint &p2)
void do_print(const QString &file_cmd, const QString &term, const graphics_handle &handle)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void error(const char *fmt,...)
void gl2ps_print(opengl_functions &glfcns, const graphics_object &fig, const std::string &stream, const std::string &term)