[rkward-cvs] rkward/rkward/plugin Makefile.am,1.8,1.9 rkformula.cpp,1.8,1.9 rkformula.h,1.5,1.6 rkstandardcomponent.cpp,1.7,1.8

Thomas Friedrichsmeier tfry at users.sourceforge.net
Thu Mar 16 22:31:10 UTC 2006


Update of /cvsroot/rkward/rkward/rkward/plugin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7396/plugin

Modified Files:
	Makefile.am rkformula.cpp rkformula.h rkstandardcomponent.cpp 
Log Message:
Moved over RKFormula

Index: rkformula.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkformula.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** rkformula.h	26 Mar 2005 10:32:17 -0000	1.5
--- rkformula.h	16 Mar 2006 22:31:08 -0000	1.6
***************
*** 3,7 ****
                               -------------------
      begin                : Thu Aug 12 2004
!     copyright            : (C) 2004 by Thomas Friedrichsmeier
      email                : tfry at users.sourceforge.net
   ***************************************************************************/
--- 3,7 ----
                               -------------------
      begin                : Thu Aug 12 2004
!     copyright            : (C) 2004, 2006 by Thomas Friedrichsmeier
      email                : tfry at users.sourceforge.net
   ***************************************************************************/
***************
*** 18,26 ****
  #define RKFORMULA_H
  
! #include <rkpluginwidget.h>
  
  #include <qstring.h>
  #include <qmap.h>
! #include "../core/rkvariable.h"
  
  class QListView;
--- 18,26 ----
  #define RKFORMULA_H
  
! #include "rkcomponent.h"
  
  #include <qstring.h>
  #include <qmap.h>
! #include "../core/robject.h"
  
  class QListView;
***************
*** 30,44 ****
  class QSpinBox;
  class QListViewItem;
! class RKVarSlot;
  
  /**
  @author Thomas Friedrichsmeier
  */
! class RKFormula : public RKPluginWidget {
    Q_OBJECT
  public:
!     RKFormula(const QDomElement &element, QWidget *parent, RKPlugin *plugin);
!     ~RKFormula();
!   void  setEnabled(bool);
  
  public slots:
--- 30,43 ----
  class QSpinBox;
  class QListViewItem;
! class QDomElement;
  
  /**
  @author Thomas Friedrichsmeier
  */
! class RKFormula : public RKComponent {
    Q_OBJECT
  public:
! 	RKFormula (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget);
! 	~RKFormula ();
  
  public slots:
***************
*** 46,59 ****
  	void addButtonClicked ();
  	void removeButtonClicked ();
! 	void factorsChanged ();
!   void slotActive();
!   void slotActive(bool);
  
  private:
!  QString model_string;
! 	QString table_string;
  	bool multitable;
  	bool model_ok;
! 	typedef QMap<QString, RKVariable*> MangledNames;
  	MangledNames mangled_names;
  
--- 45,60 ----
  	void addButtonClicked ();
  	void removeButtonClicked ();
! 	void factorsChanged (RKComponentPropertyBase *);
  
  private:
! 	RKComponentPropertyRObjects *fixed_factors;
! 	RKComponentPropertyRObjects *dependent;
! 	RKComponentPropertyBase *model;
! 	RKComponentPropertyBase *table;
! 	RKComponentPropertyBase *labels;
! 
  	bool multitable;
  	bool model_ok;
! 	typedef QMap<QString, RObject*> MangledNames;
  	MangledNames mangled_names;
  
***************
*** 65,69 ****
  	QListView *model_view;
  	QListView *predictors_view;
-   QString depend ; 
  	QPushButton *add_button;
  	QPushButton *remove_button;
--- 66,69 ----
***************
*** 72,83 ****
  	void checkCustomModel ();
  	void makeModelString ();
! 	QString mangleName (RKVariable *var);
  	
! 	typedef QMap<QListViewItem*, RKVariable*> ItemMap;
  	ItemMap item_map;
  	
  	struct Interaction {
  		int level;
! 		RKVarPtr* vars;
  	};
  	
--- 72,83 ----
  	void checkCustomModel ();
  	void makeModelString ();
! 	QString mangleName (RObject *var);
  	
! 	typedef QMap<QListViewItem*, RObject*> ItemMap;
  	ItemMap item_map;
  	
  	struct Interaction {
  		int level;
! 		RObjectPtr* vars;
  	};
  	
***************
*** 90,103 ****
  	/** recursively cross the given source variables on level level. Returns the resulting terms in an array. The number
  	of interactions generated is stored in count */
! 	Interaction *makeInteractions (int level, const RKVarPtr *source_vars, int source_count, int *count);
! 	
! 	QString fixed_factors_id;
! 	QString dependent_id;
! 	RKVarSlot *fixed_factors;
! 	RKVarSlot *dependent;
! protected:
  	bool isSatisfied ();
- 	QString value (const QString &modifier);
- 	void initialize ();
  };
  
--- 90,96 ----
  	/** recursively cross the given source variables on level level. Returns the resulting terms in an array. The number
  	of interactions generated is stored in count */
! 	Interaction *makeInteractions (int level, const RObjectPtr *source_vars, int source_count, int *count);
! 
  	bool isSatisfied ();
  };
  

Index: Makefile.am
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/Makefile.am,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Makefile.am	15 Mar 2006 18:09:22 -0000	1.8
--- Makefile.am	16 Mar 2006 22:31:08 -0000	1.9
***************
*** 3,14 ****
  noinst_LIBRARIES =  libplugin.a
  libplugin_a_SOURCES = rkcomponentmap.cpp rkcomponentproperties.cpp rkcomponent.cpp \
! 	rkstandardcomponent.cpp rkvarselector.cpp rkvarslot.cpp
! # rkcheckbox.cpp rkformula.cpp rkplugin.cpp \
  #	rkpluginhandle.cpp rkpluginspinbox.cpp rkpluginwidget.cpp rkradio.cpp rktext.cpp \
  #	 rkinput.cpp rknote.cpp \
  #	rkpluginbrowser.cpp 
  noinst_HEADERS = rkcomponentmap.h rkcomponentproperties.h rkcomponent.h \
! 	rkstandardcomponent.h rkvarselector.h rkvarslot.h
! # rkcheckbox.h rkformula.h rkplugin.h rkpluginhandle.h \
  #	rkpluginspinbox.h rkpluginwidget.h rkradio.h rktext.h  \
  #	rkpluginbrowser.h rkinput.h rknote.h 
--- 3,14 ----
  noinst_LIBRARIES =  libplugin.a
  libplugin_a_SOURCES = rkcomponentmap.cpp rkcomponentproperties.cpp rkcomponent.cpp \
! 	rkstandardcomponent.cpp rkvarselector.cpp rkvarslot.cpp rkformula.cpp
! # rkcheckbox.cpp rkplugin.cpp \
  #	rkpluginhandle.cpp rkpluginspinbox.cpp rkpluginwidget.cpp rkradio.cpp rktext.cpp \
  #	 rkinput.cpp rknote.cpp \
  #	rkpluginbrowser.cpp 
  noinst_HEADERS = rkcomponentmap.h rkcomponentproperties.h rkcomponent.h \
! 	rkstandardcomponent.h rkvarselector.h rkvarslot.h rkformula.h
! # rkcheckbox.h rkplugin.h rkpluginhandle.h \
  #	rkpluginspinbox.h rkpluginwidget.h rkradio.h rktext.h  \
  #	rkpluginbrowser.h rkinput.h rknote.h 

Index: rkstandardcomponent.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkstandardcomponent.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** rkstandardcomponent.cpp	15 Mar 2006 20:31:28 -0000	1.7
--- rkstandardcomponent.cpp	16 Mar 2006 22:31:08 -0000	1.8
***************
*** 53,61 ****
  #include "rkvarselector.h"
  #include "rkvarslot.h"
  /*#include "rktext.h"
  #include "rkradio.h"
  #include "rkcheckbox.h"
  #include "rkpluginspinbox.h"
- #include "rkformula.h"
  #include "rknote.h"
  #include "rkinput.h"
--- 53,61 ----
  #include "rkvarselector.h"
  #include "rkvarslot.h"
+ #include "rkformula.h"
  /*#include "rktext.h"
  #include "rkradio.h"
  #include "rkcheckbox.h"
  #include "rkpluginspinbox.h"
  #include "rknote.h"
  #include "rkinput.h"
***************
*** 199,202 ****
--- 199,206 ----
  			widget = new RKVarSlot (e, component (), parent_widget);
  			addConnection (id, "source", xml->getStringAttribute (e, "source", "#noid#", DL_INFO), "selected", false, e);
+ 		} else if (e.tagName () == "formula") {
+ 			widget = new RKFormula (e, component (), parent_widget);
+ 			addConnection (id, "dependent", xml->getStringAttribute (e, "dependent", "#noid#", DL_INFO), "available", false, e);
+ 			addConnection (id, "fixed_factors", xml->getStringAttribute (e, "fixed_factors", "#noid#", DL_INFO), "available", false, e);
  /*		} else if (e.tagName () == "radio") {
  			widget = new RKRadio (e, parent_component, parent_widget);
***************
*** 205,211 ****
  		} else if (e.tagName () == "spinbox") {
  			widget = new RKPluginSpinBox (e, parent_component, parent_widget);
! 		} else if (e.tagName () == "formula") {
! 			widget = new RKFormula (e, parent_component, parent_widget);
! //		} else if (e.tagName () == "note") {		//TODO: remove corresonding class
  //			widget = new RKNote (e, parent_widget, this);
  		} else if (e.tagName () == "browser") {
--- 209,213 ----
  		} else if (e.tagName () == "spinbox") {
  			widget = new RKPluginSpinBox (e, parent_component, parent_widget);
! //		} else if (e.tagName () == "note") {		//TODO: remove corresponding class
  //			widget = new RKNote (e, parent_widget, this);
  		} else if (e.tagName () == "browser") {

Index: rkformula.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkformula.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** rkformula.cpp	29 Sep 2005 16:02:51 -0000	1.8
--- rkformula.cpp	16 Mar 2006 22:31:08 -0000	1.9
***************
*** 3,7 ****
                               -------------------
      begin                : Thu Aug 12 2004
!     copyright            : (C) 2004 by Thomas Friedrichsmeier
      email                : tfry at users.sourceforge.net
   ***************************************************************************/
--- 3,7 ----
                               -------------------
      begin                : Thu Aug 12 2004
!     copyright            : (C) 2004, 2006 by Thomas Friedrichsmeier
      email                : tfry at users.sourceforge.net
   ***************************************************************************/
***************
*** 27,48 ****
  
  #include <klocale.h>
  
! #include "rkplugin.h"
! #include "rkvarslot.h"
! #include "rkvarselector.h"
! #include "../core/rkvariable.h"
  #include "../rkglobals.h"
  
  #include "../debug.h"
  
! RKFormula::RKFormula (const QDomElement &element, QWidget *parent, RKPlugin *plugin) : RKPluginWidget (element, parent, plugin) {
  	RK_TRACE (PLUGIN);
  	QVBoxLayout *vbox = new QVBoxLayout (this, RKGlobals::spacingHint ());
! 	depend = element.attribute ("depend", QString::null);
! 	
  	type_selector = new QButtonGroup (this);
  	type_selector->setColumnLayout (0, Qt::Vertical);
! 	type_selector->layout()->setSpacing (RKGlobals::spacingHint ());
! 	type_selector->layout()->setMargin (RKGlobals::marginHint ());
  	QVBoxLayout *group_layout = new QVBoxLayout (type_selector->layout());
  	group_layout->addWidget (new QRadioButton (i18n ("Full Model"), type_selector));
--- 27,66 ----
  
  #include <klocale.h>
+ #include <kiconloader.h>
  
! #include "rkcomponent.h"
! #include "../core/rcontainerobject.h"
! #include "../misc/xmlhelper.h"
  #include "../rkglobals.h"
  
  #include "../debug.h"
  
! RKFormula::RKFormula (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
  	RK_TRACE (PLUGIN);
+ 
+ 	// create and register properties
+ 	fixed_factors = new RKComponentPropertyRObjects (this, true);
+ 	connect (fixed_factors, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (factorsChanged (RKComponentPropertyBase *)));
+ 	addChild ("fixed_factors", fixed_factors);
+ 	dependent = new RKComponentPropertyRObjects (this, true);
+ 	connect (dependent, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (factorsChanged (RKComponentPropertyBase *)));
+ 	addChild ("dependent", dependent);
+ 	model = new RKComponentPropertyBase (this, true);
+ 	addChild ("model", model);
+ 	table = new RKComponentPropertyBase (this, true);
+ 	addChild ("table", table);
+ 	labels = new RKComponentPropertyBase (this, true);
+ 	addChild ("labels", labels);
+ 
+ 	// get xmlHelper
+ 	XMLHelper *xml = XMLHelper::getStaticHelper ();
+ 
+ 	// create layout
  	QVBoxLayout *vbox = new QVBoxLayout (this, RKGlobals::spacingHint ());
! 
  	type_selector = new QButtonGroup (this);
  	type_selector->setColumnLayout (0, Qt::Vertical);
! 	type_selector->layout ()->setSpacing (RKGlobals::spacingHint ());
! 	type_selector->layout ()->setMargin (RKGlobals::marginHint ());
  	QVBoxLayout *group_layout = new QVBoxLayout (type_selector->layout());
  	group_layout->addWidget (new QRadioButton (i18n ("Full Model"), type_selector));
***************
*** 54,58 ****
  	QHBoxLayout *model_hbox = new QHBoxLayout (custom_model_widget, RKGlobals::spacingHint ());
  	predictors_view = new QListView (custom_model_widget);
! 	predictors_view->addColumn ("Name");
  	predictors_view->setSelectionMode (QListView::Extended);
  	predictors_view->setSorting (100);
--- 72,76 ----
  	QHBoxLayout *model_hbox = new QHBoxLayout (custom_model_widget, RKGlobals::spacingHint ());
  	predictors_view = new QListView (custom_model_widget);
! 	predictors_view->addColumn (i18n ("Name"));
  	predictors_view->setSelectionMode (QListView::Extended);
  	predictors_view->setSorting (100);
***************
*** 61,78 ****
  	
  	QVBoxLayout *model_vbox = new QVBoxLayout (model_hbox, RKGlobals::spacingHint ());
! 	add_button = new QPushButton ("->", custom_model_widget);
  	connect (add_button, SIGNAL (clicked ()), this, SLOT (addButtonClicked ()));
  	model_vbox->addWidget (add_button);
! 	remove_button = new QPushButton ("<-", custom_model_widget);
  	connect (remove_button, SIGNAL (clicked ()), this, SLOT (removeButtonClicked ()));
  	model_vbox->addWidget (remove_button);
  	level_box = new QSpinBox (0, 0, 1, custom_model_widget);
! 	level_box->setSpecialValueText ("Main effects");
  	model_vbox->addWidget (level_box);
  	model_hbox->addSpacing (6);
  
  	model_view = new QListView (custom_model_widget);
! 	model_view->addColumn ("Level");
! 	model_view->addColumn ("Term");
  	model_view->setSorting (0);
  	model_view->setRootIsDecorated (true);
--- 79,98 ----
  	
  	QVBoxLayout *model_vbox = new QVBoxLayout (model_hbox, RKGlobals::spacingHint ());
! 	add_button = new QPushButton (QString::null, custom_model_widget);
! 	add_button->setPixmap (SmallIcon ("1rightarrow"));
  	connect (add_button, SIGNAL (clicked ()), this, SLOT (addButtonClicked ()));
  	model_vbox->addWidget (add_button);
! 	remove_button = new QPushButton (QString::null, custom_model_widget);
! 	remove_button->setPixmap (SmallIcon ("1leftarrow"));
  	connect (remove_button, SIGNAL (clicked ()), this, SLOT (removeButtonClicked ()));
  	model_vbox->addWidget (remove_button);
  	level_box = new QSpinBox (0, 0, 1, custom_model_widget);
! 	level_box->setSpecialValueText (i18n ("Main effects"));
  	model_vbox->addWidget (level_box);
  	model_hbox->addSpacing (6);
  
  	model_view = new QListView (custom_model_widget);
! 	model_view->addColumn (i18n ("Level"));
! 	model_view->addColumn (i18n ("Term"));
  	model_view->setSorting (0);
  	model_view->setRootIsDecorated (true);
***************
*** 81,106 ****
  	group_layout->addWidget (custom_model_widget);
  
! 	fixed_factors_id = element.attribute ("fixed_factors");
! 	dependent_id = element.attribute ("dependent");
! 	type_selector->setCaption (element.attribute ("label", "Specify model"));
  
  	vbox->addWidget (type_selector);
  }
  
- 
  RKFormula::~RKFormula () {
  	RK_TRACE (PLUGIN);
  }
  
! void RKFormula::initialize () {
! 	RK_TRACE (PLUGIN);
! 	fixed_factors = plugin ()->getVarSlot (fixed_factors_id);
! 	connect (fixed_factors, SIGNAL (changed ()), this, SLOT (factorsChanged ()));
! 	dependent = plugin ()->getVarSlot (dependent_id);
! 	connect (dependent, SIGNAL (changed ()), this, SLOT (factorsChanged ()));
! 	typeChange (0);
! }
! 
! void RKFormula::factorsChanged () {
  	RK_TRACE (PLUGIN);
  	// trigger update:
--- 101,114 ----
  	group_layout->addWidget (custom_model_widget);
  
! 	type_selector->setCaption (xml->getStringAttribute (element, "label", i18n ("Specify model"), DL_INFO));
  
  	vbox->addWidget (type_selector);
  }
  
  RKFormula::~RKFormula () {
  	RK_TRACE (PLUGIN);
  }
  
! void RKFormula::factorsChanged (RKComponentPropertyBase *) {
  	RK_TRACE (PLUGIN);
  	// trigger update:
***************
*** 119,124 ****
  		predictors_view->clear ();
  		item_map.clear ();
! 		QValueList<RKVariable*> fixed_list = fixed_factors->getVariables ();
! 		for (QValueList<RKVariable*>::Iterator it = fixed_list.begin (); it != fixed_list.end (); ++it) {
  			QListViewItem *new_item = new QListViewItem (predictors_view, (*it)->getShortName ());
  			item_map.insert (new_item, (*it));
--- 127,132 ----
  		predictors_view->clear ();
  		item_map.clear ();
! 		ObjectList fixed_list = fixed_factors->objectList ();
! 		for (ObjectList::const_iterator it = fixed_list.begin (); it != fixed_list.end (); ++it) {
  			QListViewItem *new_item = new QListViewItem (predictors_view, (*it)->getShortName ());
  			item_map.insert (new_item, (*it));
***************
*** 130,159 ****
  	model_type = (ModelType) id;
  	makeModelString ();
- 	emit (changed ());
  }
  
  void RKFormula::makeModelString () {
  	RK_TRACE (PLUGIN);
! 	// first find out, whether mulitple tables are involved and construct table string
  	multitable = false;
  	model_ok = false;
  	mangled_names.clear ();
! 	RKVariable *dep_var = 0;
! 	QString table;
! 	if (dependent->getNumVars()) {
! 		dep_var = dependent->getVariables ().first ();
  		model_ok = true;
  	}
! 	QValueList<RKVariable*> vlist = fixed_factors->getVariables ();
  	if (vlist.empty ()) {
  		model_ok = false;
  	}
  	if (dep_var) {
! 		table = dep_var->getTable ();
  	} else if (!vlist.empty ()) {
! 		table = vlist.first ()->getTable ();
  	}
! 	for (QValueList<RKVariable*>::iterator it = vlist.begin (); it != vlist.end (); ++it) {
! 		if ((*it)->getTable () != table) {
  			multitable = true;
  			break;
--- 138,166 ----
  	model_type = (ModelType) id;
  	makeModelString ();
  }
  
  void RKFormula::makeModelString () {
  	RK_TRACE (PLUGIN);
! 	// first find out, whether multiple containers are involved and construct table string
  	multitable = false;
  	model_ok = false;
+ 	QString table_string, model_string, labels_string;
  	mangled_names.clear ();
! 	RObject *dep_var = dependent->objectValue ();
! 	RObject *container;
! 	if (dep_var) {
  		model_ok = true;
  	}
! 	ObjectList vlist = fixed_factors->objectList ();
  	if (vlist.empty ()) {
  		model_ok = false;
  	}
  	if (dep_var) {
! 		container = dep_var->getContainer ();
  	} else if (!vlist.empty ()) {
! 		container = vlist.first ()->getContainer ();
  	}
! 	for (ObjectList::const_iterator it = vlist.begin (); it != vlist.end (); ++it) {
! 		if ((*it)->getContainer () != container) {
  			multitable = true;
  			break;
***************
*** 163,172 ****
  		table_string = "data.frame (";
  		if (dep_var) table_string.append (mangleName (dep_var) + "=" + dep_var->getFullName ());
! 		for (QValueList<RKVariable*>::iterator it = vlist.begin (); it != vlist.end (); ++it) {
  			table_string.append (", " + mangleName ((*it)) + "=" + (*it)->getFullName ());
  		}
  		table_string.append (")");
  	} else {
! 		table_string = table;
  	}
  	
--- 170,179 ----
  		table_string = "data.frame (";
  		if (dep_var) table_string.append (mangleName (dep_var) + "=" + dep_var->getFullName ());
! 		for (ObjectList::const_iterator it = vlist.begin (); it != vlist.end (); ++it) {
  			table_string.append (", " + mangleName ((*it)) + "=" + (*it)->getFullName ());
  		}
  		table_string.append (")");
  	} else {
! 		table_string = container->getFullName ();;
  	}
  	
***************
*** 174,183 ****
  	model_string = mangleName (dep_var) + " ~ ";
  	if (model_type == FullModel) {
! 		for (QValueList<RKVariable*>::iterator it = vlist.begin (); it != vlist.end (); ++it) {
  			if (it != vlist.begin ()) model_string.append (" * ");
  			model_string.append (mangleName (*it));
  		}
  	} else if (model_type == MainEffects) {
! 		for (QValueList<RKVariable*>::iterator it = vlist.begin (); it != vlist.end (); ++it) {
  			if (it != vlist.begin ()) model_string.append (" + ");
  			model_string.append (mangleName (*it));
--- 181,190 ----
  	model_string = mangleName (dep_var) + " ~ ";
  	if (model_type == FullModel) {
! 		for (ObjectList::const_iterator it = vlist.begin (); it != vlist.end (); ++it) {
  			if (it != vlist.begin ()) model_string.append (" * ");
  			model_string.append (mangleName (*it));
  		}
  	} else if (model_type == MainEffects) {
! 		for (ObjectList::const_iterator it = vlist.begin (); it != vlist.end (); ++it) {
  			if (it != vlist.begin ()) model_string.append (" + ");
  			model_string.append (mangleName (*it));
***************
*** 197,208 ****
  		}
  	}
  }
  
! QString RKFormula::mangleName (RKVariable *var) {
  	RK_TRACE (PLUGIN);
  	if (!var) return QString::null;
  		
  	QString dummy = var->getShortName ();
! 	QString dummy2= dummy;
  	MangledNames::iterator it;
  	int i=-1;
--- 204,230 ----
  		}
  	}
+ 
+ 	// labels
+ 	labels_string = "list (";
+ 	MangledNames::const_iterator it;
+ 	for (it = mangled_names.begin (); it != mangled_names.end (); ++it) {
+ 		if (it != mangled_names.begin ()) {
+ 			labels_string.append (", ");
+ 		}
+ 		labels_string.append (it.key () + "=\"" + it.data ()->getDescription () + "\"");
+ 	}
+ 	labels_string.append (")");
+ 
+ 	table->setValue (table_string);
+ 	model->setValue (model_string);
+ 	labels->setValue (labels_string);
  }
  
! QString RKFormula::mangleName (RObject *var) {
  	RK_TRACE (PLUGIN);
  	if (!var) return QString::null;
  		
  	QString dummy = var->getShortName ();
! 	QString dummy2 = dummy;
  	MangledNames::iterator it;
  	int i=-1;
***************
*** 216,222 ****
  void RKFormula::addButtonClicked () {
  	RK_TRACE (PLUGIN);
! 	// create an array of selcted variables
  	// we allocate more than we'll probably need, but it's only going to be a handful of vars anyway.
! 	RKVariable *varlist[predictors_view->childCount ()];
  	int num_selected_vars = 0;
  	for (ItemMap::iterator item = item_map.begin (); item != item_map.end (); ++item) {
--- 238,244 ----
  void RKFormula::addButtonClicked () {
  	RK_TRACE (PLUGIN);
! 	// create an array of selected variables
  	// we allocate more than we'll probably need, but it's only going to be a handful of vars anyway.
! 	RObject *varlist[predictors_view->childCount ()];
  	int num_selected_vars = 0;
  	for (ItemMap::iterator item = item_map.begin (); item != item_map.end (); ++item) {
***************
*** 288,295 ****
  	
  	makeModelString ();
- 	emit (changed ());
  }
  
! RKFormula::Interaction* RKFormula::makeInteractions (int level, const RKVarPtr *source_vars, int source_count, int *count) {
  	RK_TRACE (PLUGIN);
  	RK_DO (qDebug ("makeInteractions: level %d, source_count %d", level, source_count), PLUGIN, DL_DEBUG);
--- 310,316 ----
  	
  	makeModelString ();
  }
  
! RKFormula::Interaction* RKFormula::makeInteractions (int level, const RObjectPtr *source_vars, int source_count, int *count) {
  	RK_TRACE (PLUGIN);
  	RK_DO (qDebug ("makeInteractions: level %d, source_count %d", level, source_count), PLUGIN, DL_DEBUG);
***************
*** 312,316 ****
  			RK_DO (qDebug ("start_var %d, source_count %d", start_var, source_count), PLUGIN, DL_DEBUG);
  			ret[start_var].level = 0;
! 			ret[start_var].vars = new RKVarPtr[1];
  			ret[start_var].vars[0] = source_vars[start_var];
  		}
--- 333,337 ----
  			RK_DO (qDebug ("start_var %d, source_count %d", start_var, source_count), PLUGIN, DL_DEBUG);
  			ret[start_var].level = 0;
! 			ret[start_var].vars = new RObjectPtr[1];
  			ret[start_var].vars[0] = source_vars[start_var];
  		}
***************
*** 333,337 ****
  		for (int sub = 0; sub < sub_counts[start_var]; ++sub) {
  			// copy values
! 			ret[current_interaction].vars = new RKVarPtr [sub_interactions[start_var][sub].level + 2];
  			ret[current_interaction].vars[0] = source_vars[start_var];
  			for (int i=1; i <= (sub_interactions[start_var][sub].level + 1); ++i) {
--- 354,358 ----
  		for (int sub = 0; sub < sub_counts[start_var]; ++sub) {
  			// copy values
! 			ret[current_interaction].vars = new RObjectPtr [sub_interactions[start_var][sub].level + 2];
  			ret[current_interaction].vars[0] = source_vars[start_var];
  			for (int i=1; i <= (sub_interactions[start_var][sub].level + 1); ++i) {
***************
*** 399,403 ****
  	
  	makeModelString ();
- 	emit (changed ());
  }
  
--- 420,423 ----
***************
*** 442,479 ****
  }
  
- QString RKFormula::value (const QString &modifier) {
- 	RK_TRACE (PLUGIN);
- 	if (modifier == "data") {
- 		return table_string;
- 	} else if (modifier == "labels") {
- 		QString ret = "list (";
- 		MangledNames::iterator it;
- 		for (it = mangled_names.begin (); it != mangled_names.end (); ++it) {
- 			if (it != mangled_names.begin ()) {
- 				ret.append (", ");
- 			}
- 			ret.append (it.key () + "=\"" + it.data ()->getDescription () + "\"");
- 		}
- 		ret.append (")");
- 		return ret;
- 	} else {
- 		return model_string;
- 	}
- }
- 
- void RKFormula::setEnabled(bool checked){
- type_selector->setEnabled(checked);
- }
- 
- void RKFormula::slotActive(){
-   bool isOk = type_selector->isEnabled();
-   type_selector->setEnabled(! isOk);
- }
- 
- void RKFormula::slotActive(bool isOk){
-   type_selector->setEnabled( isOk);
-   }
- 
- 
- 
  #include "rkformula.moc"
--- 462,464 ----





More information about the rkward-tracker mailing list