1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2008-2009 Pierre Ratinaud
8 from chemins import ffr, ConstructAfcmPath, ConstructPathOut
9 from functions import exec_rcode, check_Rresult
10 from ProfList import *
11 from dialog import PrefQuestAlc
13 from time import sleep
16 def __init__(self, parent, LISTNUMACTIVE, LISTVARSUP):
20 self.tempgraph = tempfile.mktemp(dir=parent.TEMPDIR)
21 #if parent.g_id: rownames = '1'
22 #else : rownames = 'NULL'
23 #if parent.g_header : header = 'TRUE'
24 #else : header = 'FALSE'
26 datadm <- read.table("%s", header = TRUE, sep = ';', quote='"', encoding="%s",row.names=1)
27 """ % (ffr(parent.tableau.parametre['csvfile']), parent.tableau.parametre['encodage'])
28 if len(LISTVARSUP) == 1 :
29 strlistsup = str(tuple(LISTVARSUP)).replace(',', '')
31 strlistsup = str(tuple(LISTVARSUP))
32 if len(LISTNUMACTIVE) == 1:
33 strlistact = str(tuple(LISTNUMACTIVE)).replace(',', '')
35 strlistact = str(tuple(LISTNUMACTIVE))
38 """ % self.parent.RscriptsPath['Rgraph']
47 """ % ffr(self.tempgraph)
48 #FIXME : faire une fonction pour le graph
51 dataact<-datadm[,lact]
52 act <- mca(dataact, abbrev = TRUE)
53 datasup<-datadm[,lsup]
54 sup <- predict(act, datasup, type="factor")
55 ftab<-cbind(dataact,datasup)
58 #debs<-ncol(dataact)+1
59 #fins<-ncol(dataact)+ncol(datasup)
60 #ftab.mjca<-mjca(ftab,supcol=c(debs:fins),nd=3)
61 open_file_graph(filename, width = 800, height = 800)
67 tmpfile = tempfile.mktemp(dir=parent.TEMPDIR)
68 tmpscript = open(tmpfile, 'w')
71 pid = exec_rcode(self.parent.RPath, tmpfile, wait = False)
72 while pid.poll() == None :
74 check_Rresult(self.parent, pid)
78 txt = '<img src="%s" />' % self.tempgraph
81 # def OnRGL(self, event):
82 # self.parent.text_ctrl_1.write('runrgl\n')
83 # RAFC3DRGL = os.path.join(self.PathFile, self.RAFC3DRGL)
87 def __init__(self, parent):
88 dlg = PrefQuestAlc(parent, sim = True)
89 #dlg = CHDDialog(parent, -1, u"AFCM", size=(350, 400), style=wx.DEFAULT_DIALOG_STYLE)
91 self.val = dlg.ShowModal()
92 if self.val == wx.ID_OK:
93 LISTNUMACTIVE = dlg.nactives
94 LISTVARSUP = dlg.varsup
97 afcm = AFCMQ(parent, LISTNUMACTIVE, LISTVARSUP)
98 txtgraph = afcm.DoLayout()
99 parent.newtab = wx.html.HtmlWindow(parent.nb, -1)
100 if "gtk2" in wx.PlatformInfo:
101 parent.newtab.SetStandardFonts()
102 parent.newtab.SetPage(txtgraph)
103 parent.nb.AddPage(parent.newtab, u"AFCM")
104 parent.nb.SetSelection(parent.nb.GetPageCount() - 1)
105 parent.ShowTab(wx.EVT_BUTTON)