[rkward-cvs] SF.net SVN: rkward:[2934] trunk/rkward/rkward
kapatp at users.sourceforge.net
kapatp at users.sourceforge.net
Sun Jul 4 08:15:13 UTC 2010
Revision: 2934
http://rkward.svn.sourceforge.net/rkward/?rev=2934&view=rev
Author: kapatp
Date: 2010-07-04 08:15:12 +0000 (Sun, 04 Jul 2010)
Log Message:
-----------
Add an option to delete a plot from the history; this will be handy in setting history limits.
Modified Paths:
--------------
trunk/rkward/rkward/misc/rkstandardicons.cpp
trunk/rkward/rkward/misc/rkstandardicons.h
trunk/rkward/rkward/rbackend/rpackages/rkward/R/public_graphics.R
trunk/rkward/rkward/windows/rkcatchedx11windowpart.rc
trunk/rkward/rkward/windows/rkwindowcatcher.cpp
trunk/rkward/rkward/windows/rkwindowcatcher.h
Modified: trunk/rkward/rkward/misc/rkstandardicons.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkstandardicons.cpp 2010-07-04 03:47:32 UTC (rev 2933)
+++ trunk/rkward/rkward/misc/rkstandardicons.cpp 2010-07-04 08:15:12 UTC (rev 2934)
@@ -62,7 +62,8 @@
icons[ActionMoveUp] = KIcon ("go-up");
icons[ActionMoveDown] = KIcon ("go-down");
- icons[ActionSnapshot] = KIcon ("flag.png");
+ icons[ActionSnapshot] = KIcon ("list-add.png");
+ icons[ActionRemovePlot] = KIcon ("list-remove.png");
icons[ActionClear] = KIcon ("edit-clear.png");
Modified: trunk/rkward/rkward/misc/rkstandardicons.h
===================================================================
--- trunk/rkward/rkward/misc/rkstandardicons.h 2010-07-04 03:47:32 UTC (rev 2933)
+++ trunk/rkward/rkward/misc/rkstandardicons.h 2010-07-04 08:15:12 UTC (rev 2934)
@@ -63,6 +63,7 @@
ActionMoveDown,
ActionSnapshot,
+ ActionRemovePlot,
ActionClear,
Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/public_graphics.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/public_graphics.R 2010-07-04 03:47:32 UTC (rev 2933)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/public_graphics.R 2010-07-04 08:15:12 UTC (rev 2934)
@@ -166,6 +166,44 @@
record (deviceId, newplotflag = FALSE)
}
}
+ remove <- function (deviceId = dev.cur ())
+ {
+ history_length <- length (recorded)
+ if (history_length <= 1) {
+ if (history_length == 1) .rk.graph.history.gui ()
+ return (invisible (NULL))
+ }
+
+ deviceId <- as.character (deviceId)
+ n <- histPositions [[deviceId]] # history position of the calling device
+
+ if (newPlotExists [[deviceId]]) {
+ # for unsaved plots, just set the flag to FALSE and replay the previous (== n) plot
+
+ newPlotExists [[deviceId]] <<- FALSE
+ replay (n, deviceId)
+ } else {
+ # a saved plot: delete it:
+ recorded [[n]] <<- NULL
+
+ # devices with position = n:
+ dEqn <- names (histPositions)[unlist (histPositions) == n]
+ # devices with position > n:
+ dGtn <- names (histPositions)[unlist (histPositions) > n]
+
+ if (n > length (recorded)) n <- n - 1
+
+ # for all devices in dEqn, replay the next (== n) plot, or, if this was the last plot then,
+ # replay the previous (== n) plot
+ lapply (X = dEqn, function (d,N) replay (n = N, deviceId = d), N = n)
+
+ # for all devices in dGtn, decrese their position counter by 1 and update the gui
+ histPositions [dGtn] <<- lapply (histPositions [dGtn], FUN = function (d) d-1)
+ .rk.graph.history.gui (dGtn)
+ }
+
+ invisible (NULL)
+ }
replay <- function(n = histPositions [[as.character (deviceId)]] - 1L, deviceId = dev.cur ())
{
deviceId <- as.character (deviceId)
@@ -273,3 +311,9 @@
rk.record.plot$record (deviceId, newplotflag=FALSE, force=TRUE)
rk.record.plot$printPars ()
}
+"rk.removethis.plot" <- function (deviceId = dev.cur ())
+{
+ rk.record.plot$remove (deviceId)
+ rk.record.plot$printPars ()
+}
+
Modified: trunk/rkward/rkward/windows/rkcatchedx11windowpart.rc
===================================================================
--- trunk/rkward/rkward/windows/rkcatchedx11windowpart.rc 2010-07-04 03:47:32 UTC (rev 2933)
+++ trunk/rkward/rkward/windows/rkcatchedx11windowpart.rc 2010-07-04 08:15:12 UTC (rev 2934)
@@ -17,6 +17,7 @@
<Action name="plot_last"/>
<Separator/>
<Action name="plot_record"/>
+ <Action name="plot_remove"/>
<Separator/>
<Action name="plot_clear_history"/>
</Menu>
@@ -40,6 +41,7 @@
<Action name="plot_last"/>
<Separator/>
<Action name="plot_record"/>
+ <Action name="plot_remove"/>
<Separator/>
<Action name="plot_clear_history"/>
</ToolBar>
Modified: trunk/rkward/rkward/windows/rkwindowcatcher.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.cpp 2010-07-04 03:47:32 UTC (rev 2933)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.cpp 2010-07-04 08:15:12 UTC (rev 2934)
@@ -421,6 +421,12 @@
//updateHistoryActions (history_length+1, history_length+1);
}
+void RKCaughtX11Window::removeCurrentPlot () {
+ RK_TRACE (MISC);
+
+ RKGlobals::rInterface ()->issueCommand ("rk.removethis.plot (" + QString::number (device_number) + ')', RCommand::App, i18n ("Remove current plot from history (device number %1)", device_number), error_dialog);
+}
+
void RKCaughtX11Window::clearHistory () {
RK_TRACE (MISC);
@@ -440,7 +446,9 @@
plot_prev_action->setEnabled (position > 1);
plot_next_action->setEnabled ((history_length > 0) && (position < history_length));
plot_last_action->setEnabled ((history_length > 0) && (position < history_length));
-
+
+ plot_remove_action->setEnabled (history_length > 1);
+
plot_clear_history_action->setEnabled (history_length > 0);
}
@@ -517,6 +525,11 @@
action = actionCollection ()->addAction ("plot_record", window, SLOT (recordCurrentPlot()));
action->setText (i18n ("Add to history"));
action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionSnapshot));
+ action = actionCollection ()->addAction ("plot_remove", window, SLOT (removeCurrentPlot()));
+ action->setText (i18n ("Remove from history"));
+ action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRemovePlot));
+ window->plot_remove_action = (KAction*) action;
+
action = actionCollection ()->addAction ("plot_clear_history", window, SLOT (clearHistory()));
window->plot_clear_history_action = (KAction*) action;
action->setText (i18n ("Clear history"));
Modified: trunk/rkward/rkward/windows/rkwindowcatcher.h
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.h 2010-07-04 03:47:32 UTC (rev 2933)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.h 2010-07-04 08:15:12 UTC (rev 2934)
@@ -150,6 +150,8 @@
/** history navigation */
void recordCurrentPlot ();
/** history navigation */
+ void removeCurrentPlot ();
+/** history navigation */
void clearHistory ();
/** reimplemented to keep window alive while saving history */
@@ -184,6 +186,7 @@
KAction *plot_next_action;
KAction *plot_first_action;
KAction *plot_last_action;
+ KAction *plot_remove_action;
KAction *plot_clear_history_action;
KPassivePopup* status_popup;
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