Skip to content

Commit 43acf5d

Browse files
committed
add svn menu. fix bug with unicode text and filename. add box and quad primitive to turtle
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/vplants/vplants/trunk/lpy@16927 ab253cce-29fb-0310-bb2f-979600cdbdeb
1 parent ec97902 commit 43acf5d

12 files changed

+276
-71
lines changed

src/cpp/moduleclass.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ typedef pgl_hash_map_string<size_t> ParameterNameDict;
9393
MACRO(iRollR) \
9494
MACRO(TurnAround) \
9595
MACRO(RollToVert) \
96-
MACRO(Sphere) \
96+
MACRO(Sphere) \
97+
MACRO(Box) \
98+
MACRO(Quad) \
9799
MACRO(Circle) \
98100
MACRO(Label) \
99101
MACRO(Frame) \

src/cpp/predefinedmodules.cpp

+30-1
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,33 @@ DeclareSimpleModule(rollToVert, "Roll to Vertical : Roll the turtle around the H
443443
DeclareModuleReal1(sphere,"Draw a sphere. Params : 'radius' (optional, should be positive, default = line width).",ePrimitive)
444444
DeclareModuleReal1(circle,"Draw a circle. Params : 'radius' (optional, should be positive, default = line width).",ePrimitive)
445445

446+
DeclareModuleBegin(box,"Draw a box. Params : 'length','topradius'.",ePrimitive)
447+
{
448+
#if PGL_VERSION >= 0x021300
449+
switch(m.size()){
450+
case 0: t.box(); break;
451+
case 1: t.box(m._getReal(0)); break;
452+
default:
453+
t.box(m._getReal(0),m._getReal(1)); break;
454+
}
455+
#endif
456+
}
457+
DeclareModuleEnd
458+
459+
DeclareModuleBegin(quad,"Draw a quad. Params : 'length','topradius'.",ePrimitive)
460+
{
461+
#if PGL_VERSION >= 0x021300
462+
switch(m.size()){
463+
case 0: t.quad(); break;
464+
case 1: t.quad(m._getReal(0)); break;
465+
default:
466+
t.quad(m._getReal(0),m._getReal(1)); break;
467+
}
468+
#endif
469+
}
470+
DeclareModuleEnd
471+
472+
446473
DeclareModuleBegin(label,"Draw a text label. Params : 'text','size'.",ePrimitive)
447474
{
448475
if(m.empty())LsysWarning("Argument missing for module "+m.name());
@@ -999,7 +1026,9 @@ void ModuleClass::createPredefinedClasses() {
9991026
iRollR = new DeclaredModule(iRollR)("iRollR");
10001027
TurnAround = new DeclaredModule(turnAround)("|","TurnAround");
10011028
RollToVert = new DeclaredModule(rollToVert)("@v","RollToVert");
1002-
Sphere = new DeclaredModule(sphere)("@O","Sphere");
1029+
Sphere = new DeclaredModule(sphere)("@O","Sphere");
1030+
Box = new DeclaredModule(box)("@B","Box");
1031+
Quad = new DeclaredModule(quad)("@b","Quad");
10031032
Circle = new DeclaredModule(circle)("@o","Circle");
10041033
Label = new DeclaredModule(label)("@L","Label");
10051034
IncWidth = new DeclaredModule(incWidth)("_","IncWidth");

src/openalea/lpy/gui/lpycodeeditor.py

+18-11
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def setTabViewActivation(self,value):
101101
self.tabviewactivated = value
102102
self.rehighlight()
103103
def highlightBlock(self,text):
104-
text = str(text)
104+
text = unicode(text)
105105
if self.activated:
106106
lentxt = len(text)
107107
prevst = self.currentBlockState()
@@ -141,10 +141,10 @@ def highlightBlock(self,text):
141141
if prevst > 0 and (prevst & 2) and self.currentBlockState() < 2:
142142
self.releaselinedata(prevst)
143143
for i,c in enumerate(text):
144-
if str(c) in self.delimiterkeywords:
144+
if c in self.delimiterkeywords:
145145
self.setFormat(i, 1, self.delimiterFormat)
146146
if self.currentBlockState() == 1:
147-
if lentxt > 0 and not str(text[0]) in " \t":
147+
if lentxt > 0 and not text[0] in " \t":
148148
for ruleExp in self.lsysruleExp:
149149
index = ruleExp.indexIn(text)
150150
if index >= 0:
@@ -498,7 +498,7 @@ def returnEvent(self):
498498
while txtok:
499499
ok = cursor.movePosition(QTextCursor.NextCharacter,QTextCursor.KeepAnchor)
500500
if not ok: break
501-
txt2 = str(cursor.selection().toPlainText())
501+
txt2 = unicode(cursor.selection().toPlainText())
502502
txtok = (txt2[-1] in ' \t')
503503
if txtok:
504504
txt = txt2
@@ -511,7 +511,7 @@ def returnEvent(self):
511511
while txtok:
512512
ok = cursor.movePosition(QTextCursor.PreviousCharacter,QTextCursor.KeepAnchor)
513513
if not ok: break
514-
txt2 = str(cursor.selection().toPlainText())
514+
txt2 = unicode(cursor.selection().toPlainText())
515515
txtok = (txt2[0] in ' \t')
516516
if not txtok:
517517
if txt2[0] == ':':
@@ -639,14 +639,16 @@ def isTabHighLightActivated(self):
639639
def canInsertFromMimeData(self,source):
640640
if source.hasUrls():
641641
return True
642-
else:
643-
return qt.QtGui.QTextEdit.canInsertFromMimeData(self,source)
642+
else: return source.hasText()
643+
# return qt.QtGui.QTextEdit.canInsertFromMimeData(self,source)
644644
def insertFromMimeData(self,source):
645645
if source.hasUrls():
646646
if not self.editor is None:
647647
self.editor.openfile(str(source.urls()[0].toLocalFile()))
648-
else:
649-
qt.QtGui.QTextEdit.insertFromMimeData(self,source)
648+
else :
649+
nsource = qt.QtCore.QMimeData()
650+
nsource.setText(source.text())
651+
qt.QtGui.QTextEdit.insertFromMimeData(self,nsource)
650652
def comment(self):
651653
cursor = self.textCursor()
652654
beg = cursor.selectionStart()
@@ -774,9 +776,11 @@ def gotoLine(self,lineno):
774776
def gotoLineFromEdit(self):
775777
self.gotoLine(int(self.gotoEdit.text()))
776778
def setLineInEdit(self):
777-
self.gotoEdit.setText(str(str(self.textCursor().blockNumber()+1)))
779+
self.gotoEdit.setText(unicode(self.textCursor().blockNumber()+1))
778780
self.gotoEdit.selectAll()
779781
def restoreSimuState(self,simu):
782+
if self.hasError:
783+
self.clearErrorHightlight()
780784
firstinit = simu.textdocument is None
781785
if firstinit:
782786
simu.textdocument = self.document().clone()
@@ -790,11 +794,14 @@ def restoreSimuState(self,simu):
790794
self.verticalScrollBar().setValue(simu.vvalue)
791795
self.sidebar.restoreState(simu)
792796
def saveSimuState(self,simu):
793-
simu.code = str(self.toPlainText())
797+
simu.code = self.getCode()
794798
if simu.textdocument is None:
795799
print 'custom document clone'
796800
simu.textdocument = self.document().clone()
797801
simu.cursor = self.textCursor()
798802
simu.hvalue = self.horizontalScrollBar().value()
799803
simu.vvalue = self.verticalScrollBar().value()
800804
self.sidebar.saveState(simu)
805+
806+
def getCode(self):
807+
return unicode(self.toPlainText()).encode('iso-8859-1','replace')

src/openalea/lpy/gui/lpydock.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ def initDocks(lpywidget):
8686
lpywidget.interpreter.locals['window'] = lpywidget
8787
lpywidget.interpreter.locals['clear'] = lpywidget.shell.clear
8888
try:
89-
lpywidget.interpreter.loadcode('from openalea.plantgl.all import *' )
90-
lpywidget.interpreter.loadcode('from openalea.lpy import *')
91-
# lpywidget.interpreter.runcode('from openalea.plantgl.all import *', hidden=True)
92-
# lpywidget.interpreter.runcode('from openalea.lpy import *', hidden=True)
89+
exec('from openalea.plantgl.all import *',lpywidget.interpreter.locals,lpywidget.interpreter.locals)
90+
exec('from openalea.lpy import *',lpywidget.interpreter.locals,lpywidget.interpreter.locals)
91+
#lpywidget.interpreter.loadcode('from openalea.plantgl.all import *' )
92+
#lpywidget.interpreter.loadcode('from openalea.lpy import *')
93+
# lpywidget.interpreter.runcode('from openalea.plantgl.all import *')
94+
# lpywidget.interpreter.runcode('from openalea.lpy import *')
9395
except:
9496
lpywidget.interpreter.runcode('from openalea.plantgl.all import *')
9597
lpywidget.interpreter.runcode('from openalea.lpy import *')

src/openalea/lpy/gui/lpymainwindow.py

+29-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Form implementation generated from reading ui file '/Users/fboudon/Develop/vplants/trunk/lpy/src/openalea/lpy/gui/lpymainwindow.ui'
44
#
5-
# Created: Wed Jun 18 18:49:08 2014
5+
# Created: Fri Jun 20 17:30:14 2014
66
# by: PyQt4 UI code generator 4.10.4
77
#
88
# WARNING! All changes made in this file will be lost!
@@ -205,7 +205,7 @@ def setupUi(self, MainWindow):
205205
self.verticalLayout_2.addWidget(self.referenceEdit)
206206
self.lpytoolbox.addItem(self.page, _fromUtf8(""))
207207
self.page_2 = QtGui.QWidget()
208-
self.page_2.setGeometry(QtCore.QRect(0, 0, 112, 296))
208+
self.page_2.setGeometry(QtCore.QRect(0, 0, 98, 296))
209209
self.page_2.setObjectName(_fromUtf8("page_2"))
210210
self.verticalLayout = QtGui.QVBoxLayout(self.page_2)
211211
self.verticalLayout.setSpacing(2)
@@ -445,6 +445,8 @@ def setupUi(self, MainWindow):
445445
icon4.addPixmap(QtGui.QPixmap(_fromUtf8(":/images/icons/book.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
446446
self.menuTutorials.setIcon(icon4)
447447
self.menuTutorials.setObjectName(_fromUtf8("menuTutorials"))
448+
self.menuSVN = QtGui.QMenu(self.menuFile)
449+
self.menuSVN.setObjectName(_fromUtf8("menuSVN"))
448450
self.menuEdit = QtGui.QMenu(self.menubar)
449451
self.menuEdit.setObjectName(_fromUtf8("menuEdit"))
450452
self.menuHelp = QtGui.QMenu(self.menubar)
@@ -457,7 +459,7 @@ def setupUi(self, MainWindow):
457459
MainWindow.setStatusBar(self.statusbar)
458460
self.FileBar = QtGui.QToolBar(MainWindow)
459461
icon5 = QtGui.QIcon()
460-
icon5.addPixmap(QtGui.QPixmap(_fromUtf8("../../../../../../../../.designer/backup/logo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
462+
icon5.addPixmap(QtGui.QPixmap(_fromUtf8("../../../../../../../../../../../../../../.designer/backup/logo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
461463
self.FileBar.setWindowIcon(icon5)
462464
self.FileBar.setIconSize(QtCore.QSize(32, 32))
463465
self.FileBar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
@@ -720,6 +722,16 @@ def setupUi(self, MainWindow):
720722
self.actionExecute = QtGui.QAction(MainWindow)
721723
self.actionExecute.setIcon(icon30)
722724
self.actionExecute.setObjectName(_fromUtf8("actionExecute"))
725+
self.actionSVNUpdate = QtGui.QAction(MainWindow)
726+
self.actionSVNUpdate.setObjectName(_fromUtf8("actionSVNUpdate"))
727+
self.actionSVNIsUpToDate = QtGui.QAction(MainWindow)
728+
self.actionSVNIsUpToDate.setObjectName(_fromUtf8("actionSVNIsUpToDate"))
729+
self.actionSVNCommit = QtGui.QAction(MainWindow)
730+
self.actionSVNCommit.setObjectName(_fromUtf8("actionSVNCommit"))
731+
self.actionSVNRevert = QtGui.QAction(MainWindow)
732+
self.actionSVNRevert.setObjectName(_fromUtf8("actionSVNRevert"))
733+
self.actionSVNAdd = QtGui.QAction(MainWindow)
734+
self.actionSVNAdd.setObjectName(_fromUtf8("actionSVNAdd"))
723735
self.menuL_systems.addAction(self.actionRun)
724736
self.menuL_systems.addAction(self.actionAnimate)
725737
self.menuL_systems.addSeparator()
@@ -741,13 +753,21 @@ def setupUi(self, MainWindow):
741753
self.menuImport.addAction(self.actionImportCpfgProject)
742754
self.menuImport.addAction(self.actionImportCpfgFile)
743755
self.menuTutorials.addAction(self.actionTutorialTest1)
756+
self.menuSVN.addAction(self.actionSVNUpdate)
757+
self.menuSVN.addAction(self.actionSVNCommit)
758+
self.menuSVN.addAction(self.actionSVNRevert)
759+
self.menuSVN.addSeparator()
760+
self.menuSVN.addAction(self.actionSVNAdd)
761+
self.menuSVN.addSeparator()
762+
self.menuSVN.addAction(self.actionSVNIsUpToDate)
744763
self.menuFile.addAction(self.actionNew)
745764
self.menuFile.addSeparator()
746765
self.menuFile.addAction(self.actionOpen)
747766
self.menuFile.addAction(self.actionSave)
748767
self.menuFile.addAction(self.actionSaveAs)
749768
self.menuFile.addAction(self.actionSaveAll)
750769
self.menuFile.addAction(self.actionClose)
770+
self.menuFile.addAction(self.menuSVN.menuAction())
751771
self.menuFile.addSeparator()
752772
self.menuFile.addAction(self.menuImport.menuAction())
753773
self.menuFile.addSeparator()
@@ -894,6 +914,7 @@ def retranslateUi(self, MainWindow):
894914
self.menuRecents.setTitle(_translate("MainWindow", "Recents", None))
895915
self.menuImport.setTitle(_translate("MainWindow", "Import", None))
896916
self.menuTutorials.setTitle(_translate("MainWindow", "Tutorials", None))
917+
self.menuSVN.setTitle(_translate("MainWindow", "SVN", None))
897918
self.menuEdit.setTitle(_translate("MainWindow", "Edit", None))
898919
self.menuHelp.setTitle(_translate("MainWindow", "Help", None))
899920
self.menuView.setTitle(_translate("MainWindow", "View", None))
@@ -973,6 +994,11 @@ def retranslateUi(self, MainWindow):
973994
self.actionTutorialTest1.setText(_translate("MainWindow", "Test 1", None))
974995
self.actionExecute.setText(_translate("MainWindow", "Execute ...", None))
975996
self.actionExecute.setShortcut(_translate("MainWindow", "Ctrl+E", None))
997+
self.actionSVNUpdate.setText(_translate("MainWindow", "Update", None))
998+
self.actionSVNIsUpToDate.setText(_translate("MainWindow", "Is Up-to-Date ?", None))
999+
self.actionSVNCommit.setText(_translate("MainWindow", "Commit", None))
1000+
self.actionSVNRevert.setText(_translate("MainWindow", "Revert", None))
1001+
self.actionSVNAdd.setText(_translate("MainWindow", "Add", None))
9761002

9771003
from lpycodeeditor import LpyCodeEditor
9781004
from scalareditor import ScalarEditor

src/openalea/lpy/gui/lpymainwindow.ui

+40-2
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@
439439
<rect>
440440
<x>0</x>
441441
<y>0</y>
442-
<width>112</width>
442+
<width>98</width>
443443
<height>296</height>
444444
</rect>
445445
</property>
@@ -976,13 +976,26 @@
976976
</property>
977977
<addaction name="actionTutorialTest1"/>
978978
</widget>
979+
<widget class="QMenu" name="menuSVN">
980+
<property name="title">
981+
<string>SVN</string>
982+
</property>
983+
<addaction name="actionSVNUpdate"/>
984+
<addaction name="actionSVNCommit"/>
985+
<addaction name="actionSVNRevert"/>
986+
<addaction name="separator"/>
987+
<addaction name="actionSVNAdd"/>
988+
<addaction name="separator"/>
989+
<addaction name="actionSVNIsUpToDate"/>
990+
</widget>
979991
<addaction name="actionNew"/>
980992
<addaction name="separator"/>
981993
<addaction name="actionOpen"/>
982994
<addaction name="actionSave"/>
983995
<addaction name="actionSaveAs"/>
984996
<addaction name="actionSaveAll"/>
985997
<addaction name="actionClose"/>
998+
<addaction name="menuSVN"/>
986999
<addaction name="separator"/>
9871000
<addaction name="menuImport"/>
9881001
<addaction name="separator"/>
@@ -1063,7 +1076,7 @@
10631076
</property>
10641077
<property name="windowIcon">
10651078
<iconset>
1066-
<normaloff>../../../../../../../../.designer/backup/logo.png</normaloff>../../../../../../../../.designer/backup/logo.png</iconset>
1079+
<normaloff>../../../../../../../../../../../../../../.designer/backup/logo.png</normaloff>../../../../../../../../../../../../../../.designer/backup/logo.png</iconset>
10671080
</property>
10681081
<property name="iconSize">
10691082
<size>
@@ -1716,6 +1729,31 @@
17161729
<string>Ctrl+E</string>
17171730
</property>
17181731
</action>
1732+
<action name="actionSVNUpdate">
1733+
<property name="text">
1734+
<string>Update</string>
1735+
</property>
1736+
</action>
1737+
<action name="actionSVNIsUpToDate">
1738+
<property name="text">
1739+
<string>Is Up-to-Date ?</string>
1740+
</property>
1741+
</action>
1742+
<action name="actionSVNCommit">
1743+
<property name="text">
1744+
<string>Commit</string>
1745+
</property>
1746+
</action>
1747+
<action name="actionSVNRevert">
1748+
<property name="text">
1749+
<string>Revert</string>
1750+
</property>
1751+
</action>
1752+
<action name="actionSVNAdd">
1753+
<property name="text">
1754+
<string>Add</string>
1755+
</property>
1756+
</action>
17191757
</widget>
17201758
<customwidgets>
17211759
<customwidget>

0 commit comments

Comments
 (0)