[rkward-cvs] SF.net SVN: rkward-code:[4636] branches/development_branches/ rkward_graphpics_device/rkward/rbackend
tfry at users.sf.net
tfry at users.sf.net
Tue Mar 26 19:30:52 UTC 2013
Revision: 4636
http://sourceforge.net/p/rkward/code/4636
Author: tfry
Date: 2013-03-26 19:30:51 +0000 (Tue, 26 Mar 2013)
Log Message:
-----------
Just a few more bits. Most importantly an R wrapper function to create the device.
Modified Paths:
--------------
branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkrbackend.cpp
branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice.h
branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp
branches/development_branches/rkward_graphpics_device/rkward/rbackend/rpackages/rkward/NAMESPACE
branches/development_branches/rkward_graphpics_device/rkward/rbackend/rpackages/rkward/R/public_graphics.R
Added Paths:
-----------
branches/development_branches/rkward_graphpics_device/rkward/rbackend/rpackages/rkward/man/RKdevice.Rd
Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkrbackend.cpp
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkrbackend.cpp 2013-03-26 16:53:22 UTC (rev 4635)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkrbackend.cpp 2013-03-26 19:30:51 UTC (rev 4636)
@@ -992,7 +992,7 @@
return (R_NilValue);
}
-SEXP RKStartGraphicsDevice (SEXP width, SEXP height, SEXP pointsize, SEXP family);
+SEXP RKStartGraphicsDevice (SEXP width, SEXP height, SEXP pointsize, SEXP family, SEXP bg, SEXP title, SEXP antialias);
bool RKRBackend::startR () {
RK_TRACE (RBACKEND);
@@ -1079,7 +1079,7 @@
{ "rk.dialog", (DL_FUNC) &doDialog, 6 },
{ "rk.update.locale", (DL_FUNC) &doUpdateLocale, 0 },
{ "rk.locale.name", (DL_FUNC) &doLocaleName, 0 },
- { "rk.graphics.device", (DL_FUNC) &RKStartGraphicsDevice, 4},
+ { "rk.graphics.device", (DL_FUNC) &RKStartGraphicsDevice, 7},
{ 0, 0, 0 }
};
R_registerRoutines (R_getEmbeddingDllInfo(), NULL, callMethods, NULL, NULL);
Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp 2013-03-26 16:53:22 UTC (rev 4635)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp 2013-03-26 19:30:51 UTC (rev 4636)
@@ -21,6 +21,7 @@
#include <QGraphicsView>
#include <QGraphicsRectItem>
#include <qmath.h>
+#include <klocale.h>
#include "../../debug.h"
@@ -32,7 +33,6 @@
RK_TRACE (GRAPHICS_DEVICE);
painter.setRenderHints (QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
view = new QLabel ();
- view->setFixedSize (area.size ());
connect (&updatetimer, SIGNAL (timeout ()), this, SLOT (updateNow ()));
updatetimer.setSingleShot (true);
clear ();
@@ -51,7 +51,10 @@
void RKGraphicsDevice::updateNow () {
if (painter.isActive ()) painter.end ();
view->setPixmap (area);
- view->show ();
+ if (!view->isVisible ()) {
+ view->resize (area.size ());
+ view->show ();
+ }
painter.begin (&area);
}
Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice.h
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice.h 2013-03-26 16:53:22 UTC (rev 4635)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice.h 2013-03-26 19:30:51 UTC (rev 4636)
@@ -57,6 +57,7 @@
QPixmap area;
QPainter painter;
QLabel *view;
+ QWidget *status_overlay;
};
#endif
Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp 2013-03-26 16:53:22 UTC (rev 4635)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp 2013-03-26 19:30:51 UTC (rev 4636)
@@ -37,15 +37,20 @@
#include <R_ext/GraphicsEngine.h>
}
+#ifndef rcolor
+#define rcolor unsigned int
+#endif
+
struct RKGraphicsDeviceDesc {
- bool initRDevDesc (pDevDesc dev, double pointsize);
+ bool initRDevDesc (pDevDesc dev, double pointsize, rcolor bg);
int devnum;
double width, height;
QString getFontFamily (bool symbolfont) const {
- if (symbolfont) return QString ("symbol");
+ if (symbolfont) return default_symbol_family;
return default_family;
}
QString default_family;
+ QString default_symbol_family;
pDevDesc rdevdesc;
};
@@ -53,14 +58,16 @@
#define RKGD_DPI 72
-void RKStartGraphicsDevice (double width, double height, double pointsize, const QString &family) {
+void RKStartGraphicsDevice (double width, double height, double pointsize, const QStringList &family, rcolor bg, const char* title, bool antialias) {
if (width <= 0 || height <= 0) {
Rf_error ("Invalid width or height: (%g, %g)", width, height);
}
RKGraphicsDeviceDesc *desc = new RKGraphicsDeviceDesc;
desc->width = width * RKGD_DPI;
desc->height = height * RKGD_DPI;
- desc->default_family = family;
+ desc->default_family = family.value (0, "Helvetica");
+ desc->default_symbol_family = family.value (0, "Symbol");
+#warning: Title, antialias
R_GE_checkVersionOrDie (R_GE_version);
R_CheckDeviceAvailable ();
@@ -68,7 +75,7 @@
BEGIN_SUSPEND_INTERRUPTS {
/* Allocate and initialize the device driver data */
dev = (pDevDesc) calloc (1, sizeof(DevDesc));
- if (!(dev && desc->initRDevDesc (dev, pointsize) && RKGraphicsDeviceBackendTransmitter::instance ())) {
+ if (!(dev && desc->initRDevDesc (dev, pointsize, bg) && RKGraphicsDeviceBackendTransmitter::instance ())) {
free (dev);
delete (desc);
desc = 0;
@@ -90,14 +97,12 @@
}
}
-SEXP RKStartGraphicsDevice (SEXP width, SEXP height, SEXP pointsize, SEXP family
-#warning TODO: add more params for compatibility with X11()
-) {
- RKStartGraphicsDevice (Rf_asReal (width), Rf_asReal (height), Rf_asReal (pointsize), RKRSupport::SEXPToString (family));
+SEXP RKStartGraphicsDevice (SEXP width, SEXP height, SEXP pointsize, SEXP family, SEXP bg, SEXP title, SEXP antialias) {
+ RKStartGraphicsDevice (Rf_asReal (width), Rf_asReal (height), Rf_asReal (pointsize), RKRSupport::SEXPToStringList (family), R_GE_str2col (CHAR(Rf_asChar(bg))), CHAR(Rf_asChar(title)), Rf_asLogical (antialias));
return R_NilValue;
}
-bool RKGraphicsDeviceDesc::initRDevDesc (pDevDesc dev, double pointsize) {
+bool RKGraphicsDeviceDesc::initRDevDesc (pDevDesc dev, double pointsize, rcolor bg) {
dev->deviceSpecific = (void *) this;
// pointsize?
@@ -108,7 +113,7 @@
dev->startfont = 1;
dev->startps = pointsize;
dev->startcol = R_RGB(0, 0, 0);
- dev->startfill = R_TRANWHITE;
+ dev->startfill = bg;
dev->startlty = LTY_SOLID;
dev->startgamma = 1;
/*
Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rpackages/rkward/NAMESPACE
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rpackages/rkward/NAMESPACE 2013-03-26 16:53:22 UTC (rev 4635)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rpackages/rkward/NAMESPACE 2013-03-26 19:30:51 UTC (rev 4636)
@@ -3,6 +3,7 @@
export(q)
export(quit)
export(require)
+export(RK)
export(.rk.app.version)
export(.rk.backups)
export(.rk.cached.available.packages)
Modified: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rpackages/rkward/R/public_graphics.R
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rpackages/rkward/R/public_graphics.R 2013-03-26 16:53:22 UTC (rev 4635)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rpackages/rkward/R/public_graphics.R 2013-03-26 19:30:51 UTC (rev 4636)
@@ -85,6 +85,32 @@
invisible (ret)
}
+#' Plot graphics to RKWard native device
+#'
+#' \code{RK()} creates an R on-screen device that will be rendered in the RKWard frontend.
+#' The default settings for \code{width}, and \code{height} can be modified from Settings -> Configure RKWard -> Onscreen Graphics.
+#'
+#' @param width Width of the device in inches. The default is to use the heigth configured in Settings -> Configure RKWard -> Onscreen Graphics.
+#' @param height Height of the device in inchesgraphics in pixels. The default is to use the heigth configured in Settings -> Configure RKWard -> Onscreen Graphics.
+#' @param pointsize Default pointsize
+#' @param family Default font family. This can be a character vector of length 1 or 2. The second value is used for
+#' plotting symbols. Effectively the default is c("Helvetica", "Symbol"). A wide variety of sepcification is supported,
+#' including the device independent fonts names "sans", "serif", and "mono"
+#' @param bg Background color.
+#' @param title Window title.
+#' @param antialias Antialiasing. Can be turned off for somewhat faster drawing.
+#'
+#' @keywords devices
+#'
+#' @export
+#' @aliases RK
+#' @rdname RKdevice
+"RK" <- function (width=getOption("rk.screendevice.width"), height=getOption("rk.screendevice.height"), pointsize=12, family=NULL, bg="white", title="", antialias=TRUE) {
+ if (is.null (width)) width <- 7
+ if (is.null (height)) height <- 7
+ .Call ("rk.graphics.device", as.integer (width), as.integer (height), as.integer (pointsize), family, bg, title, isTRUE (antialias), PACKAGE="(embedding)")
+}
+
#' \code{rk.graph.off()} closes the device that was opened by \code{rk.graph.on}.
#'
#' @rdname rk.graph.on
Added: branches/development_branches/rkward_graphpics_device/rkward/rbackend/rpackages/rkward/man/RKdevice.Rd
===================================================================
--- branches/development_branches/rkward_graphpics_device/rkward/rbackend/rpackages/rkward/man/RKdevice.Rd (rev 0)
+++ branches/development_branches/rkward_graphpics_device/rkward/rbackend/rpackages/rkward/man/RKdevice.Rd 2013-03-26 19:30:51 UTC (rev 4636)
@@ -0,0 +1,42 @@
+\name{RK}
+\alias{RK}
+\title{Plot graphics to RKWard native device}
+\usage{
+ RK(width = options("rk.screendevice.width"),
+ height = options("rk.screendevice.height"),
+ pointsize = 12, family = NULL, bg = "white",
+ title = "", antialias = TRUE)
+}
+\arguments{
+ \item{width}{Width of the device in inches. The default
+ is to use the heigth configured in Settings -> Configure
+ RKWard -> Onscreen Graphics.}
+
+ \item{height}{Height of the device in inchesgraphics in
+ pixels. The default is to use the heigth configured in
+ Settings -> Configure RKWard -> Onscreen Graphics.}
+
+ \item{pointsize}{Default pointsize}
+
+ \item{family}{Default font family. This can be a
+ character vector of length 1 or 2. The second value is
+ used for plotting symbols. Effectively the default is
+ c("Helvetica", "Symbol"). A wide variety of sepcification
+ is supported, including the device independent fonts
+ names "sans", "serif", and "mono"}
+
+ \item{bg}{Background color.}
+
+ \item{title}{Window title.}
+
+ \item{antialias}{Antialiasing. Can be turned off for
+ somewhat faster drawing.}
+}
+\description{
+ \code{RK()} creates an R on-screen device that will be
+ rendered in the RKWard frontend. The default settings for
+ \code{width}, and \code{height} can be modified from
+ Settings -> Configure RKWard -> Onscreen Graphics.
+}
+\keyword{devices}
+
More information about the rkward-tracker
mailing list