[rkward-cvs] SF.net SVN: rkward:[3028] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Mon Sep 13 18:34:47 UTC 2010
Revision: 3028
http://rkward.svn.sourceforge.net/rkward/?rev=3028&view=rev
Author: tfry
Date: 2010-09-13 18:34:47 +0000 (Mon, 13 Sep 2010)
Log Message:
-----------
Move graphics window related options to a separate page, and add option for default onscreen graphics size
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal_graphics.R
trunk/rkward/rkward/rbackend/rthread.cpp
trunk/rkward/rkward/settings/CMakeLists.txt
trunk/rkward/rkward/settings/rksettings.cpp
trunk/rkward/rkward/settings/rksettings.h
trunk/rkward/rkward/windows/rkwindowcatcher.cpp
Added Paths:
-----------
trunk/rkward/rkward/settings/rksettingsmodulegraphics.cpp
trunk/rkward/rkward/settings/rksettingsmodulegraphics.h
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2010-09-13 11:31:50 UTC (rev 3027)
+++ trunk/rkward/ChangeLog 2010-09-13 18:34:47 UTC (rev 3028)
@@ -1,3 +1,4 @@
+- Add option to specify default onscreen graphics dimensions TODO: test on windows
- Fixed: Graphics windows used to assume a minimum size of 640*480 pixels, even if a smaller size was specified / TODO: check on Windows!
- Add option to disable function argument hinting
- New functions rk.show.message() and rk.show.question() for user interaction from R code
Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal_graphics.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal_graphics.R 2010-09-13 11:31:50 UTC (rev 3027)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal_graphics.R 2010-09-13 18:34:47 UTC (rev 3028)
@@ -7,11 +7,16 @@
old_dev <- dev.cur ()
+ args <- list (...)
if (!exists (".rk.default.device")) {
if (base::.Platform$OS.type == "unix") {
device <- grDevices::x11
} else {
device <- grDevices::windows
+ if (is.null (args[["width"]])) args[["width"]] <- options ("rk.screendevice.width")[[1]]
+ if (!is.numeric (args[["width"]])) args[["width"]] <- 7
+ if (is.null (args[["height"]])) args[["height"]] <- options ("rk.screendevice.height")[[1]]
+ if (!is.numeric (args[["height"]])) args[["height"]] <- 7
}
} else {
device <- .rk.default.device
@@ -19,7 +24,7 @@
device <- get (.rk.default.device)
}
}
- x <- device (...)
+ do.call (device, args)
.rk.do.call ("endOpenX11", as.character (dev.cur ()));
Modified: trunk/rkward/rkward/rbackend/rthread.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.cpp 2010-09-13 11:31:50 UTC (rev 3027)
+++ trunk/rkward/rkward/rbackend/rthread.cpp 2010-09-13 18:34:47 UTC (rev 3028)
@@ -20,6 +20,7 @@
#include "rcommandstack.h"
#include "../settings/rksettingsmoduler.h"
#include "../settings/rksettingsmoduleoutput.h"
+#include "../settings/rksettingsmodulegraphics.h"
#include "../settings/rksettingsmodulegeneral.h"
#include "../rkglobals.h"
#include "../rkward.h" // for startup options
@@ -517,7 +518,7 @@
delete [] help_base_url;
// apply user configurable run time options
- QStringList commands = RKSettingsModuleR::makeRRunTimeOptionCommands () + RKSettingsModuleRPackages::makeRRunTimeOptionCommands () + RKSettingsModuleOutput::makeRRunTimeOptionCommands ();
+ QStringList commands = RKSettingsModuleR::makeRRunTimeOptionCommands () + RKSettingsModuleRPackages::makeRRunTimeOptionCommands () + RKSettingsModuleOutput::makeRRunTimeOptionCommands () + RKSettingsModuleGraphics::makeRRunTimeOptionCommands ();
for (QStringList::const_iterator it = commands.begin (); it != commands.end (); ++it) {
runCommandInternal ((*it).toLocal8Bit (), &error);
if (error) {
Modified: trunk/rkward/rkward/settings/CMakeLists.txt
===================================================================
--- trunk/rkward/rkward/settings/CMakeLists.txt 2010-09-13 11:31:50 UTC (rev 3027)
+++ trunk/rkward/rkward/settings/CMakeLists.txt 2010-09-13 18:34:47 UTC (rev 3028)
@@ -8,6 +8,7 @@
rksettingsmodule.cpp
rksettingsmodulegeneral.cpp
rksettingsmoduleoutput.cpp
+ rksettingsmodulegraphics.cpp
rksettingsmodulephp.cpp
rksettingsmoduleplugins.cpp
rksettingsmoduler.cpp
Modified: trunk/rkward/rkward/settings/rksettings.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettings.cpp 2010-09-13 11:31:50 UTC (rev 3027)
+++ trunk/rkward/rkward/settings/rksettings.cpp 2010-09-13 18:34:47 UTC (rev 3028)
@@ -31,6 +31,7 @@
#include "rksettingsmodulephp.h"
#include "rksettingsmodulegeneral.h"
#include "rksettingsmoduleoutput.h"
+#include "rksettingsmodulegraphics.h"
#include "rksettingsmodulewatch.h"
#include "rksettingsmoduleobjectbrowser.h"
#include "rksettingsmoduleconsole.h"
@@ -101,6 +102,7 @@
modules.insert (PagePHP, new RKSettingsModulePHP (this, 0));
modules.insert (PageGeneral, new RKSettingsModuleGeneral (this, 0));
modules.insert (PageOutput, new RKSettingsModuleOutput (this, 0));
+ modules.insert (PageX11, new RKSettingsModuleGraphics (this, 0));
modules.insert (PageWatch, new RKSettingsModuleWatch (this, 0));
modules.insert (PageConsole, new RKSettingsModuleConsole (this, 0));
modules.insert (PageCommandEditor, new RKSettingsModuleCommandEditor (this, 0));
@@ -187,6 +189,7 @@
RKSettingsModuleRPackages::loadSettings(config);
RKSettingsModulePHP::loadSettings(config);
RKSettingsModuleOutput::loadSettings(config);
+ RKSettingsModuleGraphics::loadSettings(config);
RKSettingsModuleWatch::loadSettings(config);
RKSettingsModuleConsole::loadSettings(config);
RKSettingsModuleCommandEditor::loadSettings(config);
@@ -202,6 +205,7 @@
RKSettingsModuleRPackages::saveSettings(config);
RKSettingsModulePHP::saveSettings(config);
RKSettingsModuleOutput::saveSettings(config);
+ RKSettingsModuleGraphics::saveSettings(config);
RKSettingsModuleWatch::saveSettings(config);
RKSettingsModuleConsole::saveSettings(config);
RKSettingsModuleCommandEditor::saveSettings(config);
Modified: trunk/rkward/rkward/settings/rksettings.h
===================================================================
--- trunk/rkward/rkward/settings/rksettings.h 2010-09-13 11:31:50 UTC (rev 3027)
+++ trunk/rkward/rkward/settings/rksettings.h 2010-09-13 18:34:47 UTC (rev 3028)
@@ -37,17 +37,18 @@
public:
enum SettingsPage {
NoPage=0,
- PagePlugins=1,
- PageR=2,
- PageRPackages=3,
- PagePHP=4,
- PageGeneral=5,
- PageOutput=6,
- PageWatch=7,
- PageConsole=8,
- PageCommandEditor=9,
- PageObjectBrowser=10,
- PageDebug=11,
+ PagePlugins,
+ PageR,
+ PageRPackages,
+ PagePHP,
+ PageGeneral,
+ PageOutput,
+ PageX11,
+ PageWatch,
+ PageConsole,
+ PageCommandEditor,
+ PageObjectBrowser,
+ PageDebug,
NumPages = PageDebug + 1
};
Added: trunk/rkward/rkward/settings/rksettingsmodulegraphics.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodulegraphics.cpp (rev 0)
+++ trunk/rkward/rkward/settings/rksettingsmodulegraphics.cpp 2010-09-13 18:34:47 UTC (rev 3028)
@@ -0,0 +1,165 @@
+/***************************************************************************
+ rksettingsmodulegraphics - description
+ -------------------
+ begin : Mon Sep 13 2010
+ copyright : (C) 2010 by Thomas Friedrichsmeier
+ email : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include "rksettingsmodulegraphics.h"
+
+#include <klocale.h>
+#include <kconfig.h>
+#include <kconfiggroup.h>
+#include <knuminput.h>
+
+#include <qlayout.h>
+#include <qlabel.h>
+#include <QGroupBox>
+#include <qcheckbox.h>
+#include <QVBoxLayout>
+#include <QComboBox>
+
+#include "../rkglobals.h"
+#include "../rbackend/rinterface.h"
+#include "../debug.h"
+
+// static members
+int RKSettingsModuleGraphics::graphics_width;
+int RKSettingsModuleGraphics::graphics_height;
+bool RKSettingsModuleGraphics::graphics_hist_enable;
+int RKSettingsModuleGraphics::graphics_hist_max_length;
+int RKSettingsModuleGraphics::graphics_hist_max_plotsize;
+
+RKSettingsModuleGraphics::RKSettingsModuleGraphics (RKSettings *gui, QWidget *parent) : RKSettingsModule(gui, parent) {
+ RK_TRACE (SETTINGS);
+
+ QVBoxLayout *main_vbox = new QVBoxLayout (this);
+
+ QGroupBox *group = new QGroupBox (i18n ("Default window size"), this);
+ QVBoxLayout* group_layout = new QVBoxLayout (group);
+ group_layout->addWidget (new QLabel (i18n ("Default width (inches):"), group));
+ group_layout->addWidget (graphics_width_box = new KIntSpinBox (1, 100, 1, graphics_width, group));
+ group_layout->addSpacing (2*RKGlobals::spacingHint ());
+ group_layout->addWidget (new QLabel (i18n ("Default height (inches)"), group));
+ group_layout->addWidget (graphics_height_box = new KIntSpinBox (1, 100, 1, graphics_height, group));
+ connect (graphics_width_box, SIGNAL (valueChanged (int)), this, SLOT (boxChanged ()));
+ connect (graphics_height_box, SIGNAL (valueChanged (int)), this, SLOT (boxChanged ()));
+ main_vbox->addWidget (group);
+
+ main_vbox->addWidget (group);
+
+ graphics_hist_box = new QGroupBox (i18n ("Screen device history"), this);
+ graphics_hist_box->setCheckable (true);
+ graphics_hist_box->setChecked (graphics_hist_enable);
+ group_layout = new QVBoxLayout (graphics_hist_box);
+ connect (graphics_hist_box, SIGNAL (toggled ()), this, SLOT (boxChanged ()));
+ QHBoxLayout *h_layout = new QHBoxLayout (graphics_hist_box);
+ group_layout->addLayout (h_layout);
+ h_layout->addWidget (new QLabel (i18n ("Maximum number of recorded plots:"), graphics_hist_box));
+ h_layout->addWidget (graphics_hist_max_length_box = new KIntSpinBox (1, 200, 1, graphics_hist_max_length, graphics_hist_box));
+ h_layout = new QHBoxLayout (graphics_hist_box);
+ group_layout->addLayout (h_layout);
+ h_layout->addWidget (new QLabel (i18n ("Maximum size of a single recorded plot (in KB):"), graphics_hist_box));
+ h_layout->addWidget (graphics_hist_max_plotsize_box = new KIntSpinBox (4, 20000, 4, graphics_hist_max_plotsize, graphics_hist_box));
+ connect (graphics_hist_max_length_box, SIGNAL (valueChanged (int)), this, SLOT (boxChanged ()));
+ connect (graphics_hist_max_plotsize_box, SIGNAL (valueChanged (int)), this, SLOT (boxChanged ()));
+
+ main_vbox->addWidget (graphics_hist_box);
+
+ main_vbox->addStretch ();
+}
+
+RKSettingsModuleGraphics::~RKSettingsModuleGraphics() {
+ RK_TRACE (SETTINGS);
+}
+
+void RKSettingsModuleGraphics::boxChanged () {
+ RK_TRACE (SETTINGS);
+ change ();
+}
+
+QString RKSettingsModuleGraphics::caption () {
+ RK_TRACE (SETTINGS);
+ return (i18n ("Onscreen Graphics"));
+}
+
+bool RKSettingsModuleGraphics::hasChanges () {
+ RK_TRACE (SETTINGS);
+ return changed;
+}
+
+void RKSettingsModuleGraphics::applyChanges () {
+ RK_TRACE (SETTINGS);
+
+ graphics_width = graphics_width_box->value ();
+ graphics_height = graphics_height_box->value ();
+
+ graphics_hist_enable = graphics_hist_box->isChecked ();
+ graphics_hist_max_length = graphics_hist_max_length_box->value ();
+ graphics_hist_max_plotsize = graphics_hist_max_plotsize_box->value ();
+
+ QStringList commands = makeRRunTimeOptionCommands ();
+ for (QStringList::const_iterator it = commands.begin (); it != commands.end (); ++it) {
+ RKGlobals::rInterface ()->issueCommand (*it, RCommand::App, QString::null, 0, 0, commandChain ());
+ }
+}
+
+void RKSettingsModuleGraphics::save (KConfig *config) {
+ RK_TRACE (SETTINGS);
+
+ saveSettings (config);
+}
+
+void RKSettingsModuleGraphics::saveSettings (KConfig *config) {
+ RK_TRACE (SETTINGS);
+
+ KConfigGroup cg = config->group ("Graphics Device Windows");
+ cg.writeEntry ("graphics_width", graphics_width);
+ cg.writeEntry ("graphics_height", graphics_height);
+ cg.writeEntry ("graphics_hist_enable", graphics_hist_enable);
+ cg.writeEntry ("graphics_hist_max_length", graphics_hist_max_length);
+ cg.writeEntry ("graphics_hist_max_plotsize", graphics_hist_max_plotsize);
+}
+
+void RKSettingsModuleGraphics::loadSettings (KConfig *config) {
+ RK_TRACE (SETTINGS);
+
+ KConfigGroup cg = config->group ("Graphics Device Windows");
+ graphics_width = cg.readEntry ("graphics_width", 7);
+ graphics_height = cg.readEntry ("graphics_height", 7);
+ graphics_hist_enable = cg.readEntry ("graphics_hist_enable", true);
+ graphics_hist_max_length = cg.readEntry ("graphics_hist_max_length", 20);
+ graphics_hist_max_plotsize = cg.readEntry ("graphics_hist_max_plotsize", 1024);
+}
+
+//static
+QStringList RKSettingsModuleGraphics::makeRRunTimeOptionCommands () {
+ QStringList list;
+
+#ifdef Q_WS_X11
+ QString command = "X11.options";
+ command.append ("(\"width\"=" + QString::number (graphics_width));
+ command.append (", \"height\"=" + QString::number (graphics_height) + ")\n");
+#else
+ QString command = "options";
+ command.append ("(\"rk.screendevice.width\"=" + QString::number (graphics_width));
+ command.append (", \"rk.screendevice.height\"=" + QString::number (graphics_height) + ")\n");
+#endif
+ list.append (command);
+ list.append ("options (\"rk.graphics.hist.max.plotsize\"=" + QString::number (graphics_hist_max_plotsize) + ")\n");
+ list.append ("rk.toggle.plot.history (" + QString (graphics_hist_enable?"TRUE":"FALSE") + ")\n");
+ list.append ("rk.verify.plot.hist.limits (" + QString::number (graphics_hist_max_length) + ")\n");
+
+ return (list);
+}
+
+#include "rksettingsmodulegraphics.moc"
Added: trunk/rkward/rkward/settings/rksettingsmodulegraphics.h
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodulegraphics.h (rev 0)
+++ trunk/rkward/rkward/settings/rksettingsmodulegraphics.h 2010-09-13 18:34:47 UTC (rev 3028)
@@ -0,0 +1,67 @@
+/***************************************************************************
+ rksettingsmodulegraphics - description
+ -------------------
+ begin : Mon Sep 13 2010
+ copyright : (C) 2010 by Thomas Friedrichsmeier
+ email : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef RKSETTINGSMODULEGRAPHICS_H
+#define RKSETTINGSMODULEGRAPHICS_H
+
+#include "rksettingsmodule.h"
+
+#include <QStringList>
+
+class QGroupBox;
+class KIntSpinBox;
+
+/**
+ at author Thomas Friedrichsmeier
+*/
+class RKSettingsModuleGraphics : public RKSettingsModule {
+ Q_OBJECT
+public:
+ RKSettingsModuleGraphics (RKSettings *gui, QWidget *parent);
+ ~RKSettingsModuleGraphics ();
+
+ bool hasChanges ();
+ void applyChanges ();
+ void save (KConfig *config);
+
+/** generate the commands needed to set the R run time options */
+ static QStringList makeRRunTimeOptionCommands ();
+
+ static void saveSettings (KConfig *config);
+ static void loadSettings (KConfig *config);
+
+ QString caption ();
+
+ static bool plotHistoryEnabled () { return graphics_hist_enable; };
+public slots:
+ void boxChanged ();
+private:
+ QGroupBox *graphics_hist_box;
+ KIntSpinBox *graphics_hist_max_length_box;
+ KIntSpinBox *graphics_hist_max_plotsize_box;
+
+ KIntSpinBox *graphics_height_box;
+ KIntSpinBox *graphics_width_box;
+
+ static bool graphics_hist_enable;
+ static int graphics_hist_max_length;
+ static int graphics_hist_max_plotsize;
+
+ static int graphics_height;
+ static int graphics_width;
+};
+
+#endif
Modified: trunk/rkward/rkward/windows/rkwindowcatcher.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.cpp 2010-09-13 11:31:50 UTC (rev 3027)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.cpp 2010-09-13 18:34:47 UTC (rev 3028)
@@ -27,7 +27,7 @@
#include <kwindowsystem.h>
#include "../rkwardapplication.h"
-#include "../settings/rksettingsmoduleoutput.h"
+#include "../settings/rksettingsmodulegraphics.h"
#include "rkworkplace.h"
#include "../misc/rkstandardicons.h"
#include "../debug.h"
@@ -473,11 +473,11 @@
plot_list_action->setCurrentItem (history_position - 1);
plot_list_action->setEnabled (history_length > 0);
- plot_force_append_action->setEnabled (RKSettingsModuleOutput::plotHistoryEnabled ());
+ plot_force_append_action->setEnabled (RKSettingsModuleGraphics::plotHistoryEnabled ());
plot_remove_action->setEnabled (history_length > 0);
plot_clear_history_action->setEnabled (history_length > 0);
- plot_properties_action->setEnabled (RKSettingsModuleOutput::plotHistoryEnabled ());
+ plot_properties_action->setEnabled (RKSettingsModuleGraphics::plotHistoryEnabled ());
}
void RKCaughtX11Window::setStatusMessage (const QString& message, RCommand *command) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list