[rkward-cvs] SF.net SVN: rkward: [1402] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Feb 16 12:21:01 UTC 2007


Revision: 1402
          http://svn.sourceforge.net/rkward/?rev=1402&view=rev
Author:   tfry
Date:     2007-02-16 04:21:01 -0800 (Fri, 16 Feb 2007)

Log Message:
-----------
add copy tag to facilitate multiple interface case

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/TODO
    trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
    trunk/rkward/rkward/plugin/rkstandardcomponent.h
    trunk/rkward/rkward/plugins/plots/scatterplot.xml

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2007-02-16 09:59:10 UTC (rev 1401)
+++ trunk/rkward/ChangeLog	2007-02-16 12:21:01 UTC (rev 1402)
@@ -1,3 +1,5 @@
+- add a "copy" tag to facilitate writing plugins with both dialog and wizard interfaces		TODO: document, convert all wizards to use this
+- fixed: graph previews would stop working when the interface is switched from dialog to wizard or vice versa
 - new options for plugin dialogs: Configure whether code display is by default, and at what size
 
 --- Version 0.4.6 - Feb-15-2007

Modified: trunk/rkward/TODO
===================================================================
--- trunk/rkward/TODO	2007-02-16 09:59:10 UTC (rev 1401)
+++ trunk/rkward/TODO	2007-02-16 12:21:01 UTC (rev 1402)
@@ -164,6 +164,12 @@
 			- static members should be moved to the respective classes. Much cleaner!
 
 R plugins:
+	- import plugins:
+		- standardized? checkbox to open imported object for editing
+			- would be nice, if this box could be affected (default) by a global setting
+	- multiple interfaces (dialog and wizard)
+		- create a new tag <copy id="..."/> to "copy" an entire element from <dialog> to <wizard> or vice versa. Perhaps additional arguments could be specified, and those would override the ones in the other definition (but maybe this isn't even needed).
+		- should make it much easier to keep the interfaces in sync
 	- Generalized preview:
 		- E.g. for data import plugins
 	- Ability to pre-select some default values with a single option

Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2007-02-16 09:59:10 UTC (rev 1401)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2007-02-16 12:21:01 UTC (rev 1402)
@@ -280,7 +280,7 @@
 	XMLHelper* xml = XMLHelper::getStaticHelper ();
 
 	// create a builder
-	RKComponentBuilder *builder = new RKComponentBuilder (this);
+	RKComponentBuilder *builder = new RKComponentBuilder (this, doc_element);
 
 	// go
 	builder->buildElement (gui_element, parent_widget, build_wizard);
@@ -294,7 +294,9 @@
 	delete builder;
 	created = true;
 	if (gui && (!enslaved)) {
-		gui->show ();
+		// somehow, when switching the interface, and we show before the old GUI has been fully deleted (it is deleted via deleteLater (), then there may be strange graphical glitches until the GUI is first redrawn completely.
+		// Likely a difficult bug in Qt. Delaying the show until the next event loop solves the problem.
+		QTimer::singleShot (0, gui, SLOT (show ()));
 	}
 	changed ();
 }
@@ -426,15 +428,52 @@
 
 #include <qpushbutton.h>
 
-RKComponentBuilder::RKComponentBuilder (RKStandardComponent *parent_component) {
+RKComponentBuilder::RKComponentBuilder (RKStandardComponent *parent_component, const QDomElement &document_element) {
 	RK_TRACE (PLUGIN);
 	parent = parent_component;
+	doc_elem = document_element;
 }
 
 RKComponentBuilder::~RKComponentBuilder () {
 	RK_TRACE (PLUGIN);
 }
 
+QDomElement RKComponentBuilder::doElementCopy (const QString id, const QDomElement &copy) {
+	RK_TRACE (PLUGIN);
+
+	XMLHelper* xml = XMLHelper::getStaticHelper ();
+	QDomElement res;
+
+	if (id.isEmpty ()) {
+		xml->displayError (&copy, "no id given for copy element", DL_ERROR, DL_ERROR);
+		return res;	// null
+	}
+
+	// find matching element to copy from
+	XMLChildList candidates = xml->findElementsWithAttribute (doc_elem, "id", id, true, DL_ERROR);
+	XMLChildList::const_iterator it;
+	for (it = candidates.constBegin (); it != candidates.constEnd (); ++it) {
+		if ((*it).tagName () == "copy") continue;
+		res = (*it).cloneNode ().toElement ();
+		break;
+	}
+	if (res.isNull ()) {
+		xml->displayError (&copy, "no matching element found to copy from", DL_ERROR, DL_ERROR);
+		return res;
+	}
+
+	// copy overridden attributes
+	QDomNamedNodeMap attribs = copy.attributes ();
+	int len = attribs.count ();
+	for (int i=0; i < len; ++i) {
+		QDomAttr attr = attribs.item (i).toAttr ();
+		if (attr.name () == "copy_element_tag_name") res.setTagName (attr.value ());
+		else res.setAttribute (attr.name (), attr.value ());
+	}
+
+	return res;
+}
+
 void RKComponentBuilder::buildElement (const QDomElement &element, QWidget *parent_widget, bool allow_pages) {
 	RK_TRACE (PLUGIN);
 
@@ -447,6 +486,10 @@
 		QDomElement e = *it;		// shorthand
 		QString id = xml->getStringAttribute (e, "id", QString::null, DL_INFO);
 
+		if (e.tagName () == "copy") {
+			e = doElementCopy (id, e);
+		}	// no else, here. e may be changed to some entirely different element, now.
+
 		if (allow_pages && (e.tagName () == "page")) {
 			widget = component ()->addPage ();
 			QVBoxLayout *layout = new QVBoxLayout (widget);

Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.h
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.h	2007-02-16 09:59:10 UTC (rev 1401)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.h	2007-02-16 12:21:01 UTC (rev 1402)
@@ -120,7 +120,7 @@
 @author Thomas Friedrichsmeier */
 class RKComponentBuilder {
 public:
-	RKComponentBuilder (RKStandardComponent *parent_component);
+	RKComponentBuilder (RKStandardComponent *parent_component, const QDomElement &document_element);
 	~RKComponentBuilder ();
 	void buildElement (const QDomElement &element, QWidget *parent_widget, bool allow_pages);
 	void parseLogic (const QDomElement &element);
@@ -129,6 +129,8 @@
 private:
 /** internal convenience function to schedule a property connection */
 	void addConnection (const QString &client_id, const QString &client_property, const QString &governor_id, const QString &governor_property, bool reconcile, const QDomElement &origin);
+	QDomElement doElementCopy (const QString id, const QDomElement &copy);
+	QDomElement doc_elem;
 	RKStandardComponent *parent;
 	struct RKComponentPropertyConnection {
 		QString governor_property;

Modified: trunk/rkward/rkward/plugins/plots/scatterplot.xml
===================================================================
--- trunk/rkward/rkward/plugins/plots/scatterplot.xml	2007-02-16 09:59:10 UTC (rev 1401)
+++ trunk/rkward/rkward/plugins/plots/scatterplot.xml	2007-02-16 12:21:01 UTC (rev 1402)
@@ -27,7 +27,7 @@
 	</logic>
 	<dialog label="Scatterplot" >
 		<tabbook>
-			<tab label="Variables" >
+			<tab label="Variables" id="variables_tab">
 				<row>
 					<varselector id="vars" />
 					<column>
@@ -39,7 +39,7 @@
 					</column>
 				</row>
 			</tab>
-			<tab label="Axes" >
+			<tab label="Axes" id="axes_tab">
 				<row>
 					<varselector id="varname" />
 					<column>
@@ -56,7 +56,7 @@
 					</column>
 				</row>
 			</tab>
-			<tab label="Type" >
+			<tab label="Type" id="type_tab">
 				<dropdown id="type" label="Type of graphics" >
 					<option value="'p'" label="Plot individual dots" />
 					<option value="'l'" label="Plot lines" />
@@ -69,7 +69,7 @@
 				</dropdown>
 				<input size="medium" id="typeCusto" label="Give a character vector eg : c('p','l')" />
 			</tab>
-			<tab label="Names" >
+			<tab label="Names" id="names_tab">
 				<row>
 					<column>
 						<checkbox checked="false" value="1" id="isXaxis" label="Give a name to 'X' axis" />
@@ -88,7 +88,7 @@
 					</column>
 				</row>
 			</tab>
-			<tab label="Options" >
+			<tab label="Options" id="options_tab">
 				<frame>
 					<row>
 						<radio id="color" label="Color" >
@@ -136,119 +136,11 @@
 		</tabbook>
 	</dialog>
 	<wizard label="Scatterplot">
-	<!--variable
-	-->
-		<page>
-			<row>
-				<varselector id="vars" />
-				<column>
-					<row>
-						<varslot multi="true" duplicate="true" types="number unknown" id="x" source="vars" label="'X' variables" required="true" />
-						<varslot multi="true" duplicate="true" types="number unknown" id="y" source="vars" label="'Y' variables" required="true" />
-					</row>
-					<preview id="preview"/>
-				</column>
-			</row>
-		</page>
-	<!-- axes-->
-		<page>
-			<row>
-				<varselector id="varname" />
-				<column>
-					<radio id="columns" label="Value for 'X' scale" >
-						<option value="FALSE" label="Default" />
-						<option value="custoCol" label="Customize" />
-					</radio>
-					<varslot multi="false" types="number unknown" source="varname" id="Xscale" />
-					<radio id="rows" label="Value for 'Y' scale" >
-						<option value="FALSE" id="temp2" label="Default" />
-						<option value="custoRow" label="Customize" />
-					</radio>
-					<varslot multi="false" types="number unknown" id="Yscale" source="varname" />
-				</column>
-			</row>
-		</page>
-	<!--couleur
-	-->
-		<page>
-			<frame>
-				<row>
-					<radio id="color" label="Color" >
-						<option value="all" label="Same color for all variables" />
-						<option value="each" label="Different for each variable" />
-					</radio>
-					<column>
-						<text>
-				Enter value - for diff.col. enter a vector -
-				eg:  c(1,2) or c('red','green')
-						</text>
-						<input size="small" id="col" initial="'black'" label=" " />
-					</column>
-				</row>
-			</frame>
-			<frame>
-				<row>
-					<radio id="isCex" label="Size" >
-						<option value="all" label="Same for all variables" />
-						<option value="each" label="Different for each variable" />
-					</radio>
-					<column>
-						<text>
-				A numerical value giving the amount by which plotting text and symbols should be scaled relative to the default. 
-						</text>
-						<input size="small" id="cex" initial="1" label="Enter value - for diff.size. enter a vector -" />
-					</column>
-				</row>
-			</frame>
-			<frame>
-				<row>
-					<radio id="isPch" label="Symbol" >
-						<option value="all" label="Same for all variables" />
-						<option value="each" label="Different for each variable" />
-					</radio>
-					<column>
-						<text>
-				Either an integer specifying a symbol or a single character to be used as the default in plotting points.
-						</text>
-						<input size="small" id="pch" initial="1" label="Enter value - for diff.symbol. enter a vector -" />
-					</column>
-				</row>
-			</frame>
-		</page>
-	<!--type
-	-->
-		<page>
-			<dropdown id="type" label="Type of graphics" >
-				<option value="'p'" label="Plot individual points " />
-				<option value="'l'" label="Plot lines " />
-				<option value="'b'" label="Plot points connected by lines (both)" />
-				<option value="'o'" label="Plot points overlaid by lines " />
-				<option value="'h'" label="Plot vertical lines from points to the zero axis (high-density)" />
-				<option value="'s'" label="Step-function plots : the top of the vertical defines the point" />
-				<option value="'S'" label="Step-function plots : the bottom of the vertical defines the point" />
-				<option value="custoType" label="Customize" />
-			</dropdown>
-			<input size="medium" id="typeCusto" label="Give a character vector eg : c('p','l')" />
-		</page>
-		<!--titre-->
-		<page>
-			<row>
-				<column>
-					<checkbox checked="false" value="1" id="isXaxis" label="Give a name to 'X' axis" />
-					<input size="medium" id="Xname" initial="X" label="Name for X axis" />
-					<checkbox checked="false" value="1" id="isYaxis" label="Give a name to Y axis" />
-					<input size="medium" id="Yname" initial="Y" label="Name of Y axis" />
-					<checkbox checked="false" value="1" id="isTitle" label="Give a title" />
-					<input size="medium" id="main" />
-					<checkbox checked="false" value="1" id="isSub" label="Give a subtitle" />
-					<input size="medium" id="sub" />
-				</column>
-				<column>
-					<checkbox value_unchecked="FALSE" checked="true" value="TRUE" id="axes" label="Generate axes" />
-					<checkbox value_unchecked="" checked="false" value="x" id="logX" label="X as logarythm" />
-					<checkbox value_unchecked="" checked="false" value="y" id="logY" label="Y as logarythm" />
-				</column>
-			</row>
-		</page>
+	<!-- This wizard is somewhat pointless, as all it's really just a copy of the dialog tabs, with one tab per page. But so what, maybe it still "looks" friendlier, while it does not really change anything -->
+		<copy id="variables_tab" copy_element_tag_name="page" />
+		<copy id="axes_tab" copy_element_tag_name="page" />
+		<copy id="type_tab" copy_element_tag_name="page" />
+		<copy id="names_tab" copy_element_tag_name="page" />
+		<copy id="options_tab" copy_element_tag_name="page" />
 	</wizard>
 </document>


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