Permalink
Browse files

se pueden agregar anotaciones por página

git-svn-id: http://superficie.svn.sourceforge.net/svnroot/superficie@106 a15ea993-2c5a-0410-b96a-e3977f56398a
  • Loading branch information...
1 parent f723052 commit 377ef336c47fdfdcd28a621f816f7d96e86e35bb jpablo committed Nov 5, 2010
Showing with 55 additions and 18 deletions.
  1. +45 −9 Book.py
  2. +2 −2 VariousObjects.py
  3. +8 −7 Viewer.py
View
@@ -39,7 +39,9 @@ def __init__(self):
## this dictionary contains the chapters python objects
## not only the SoSeparator
self.chaptersObjects = nodeDict()
+ ## chapterStack has one widget (of controls) per chapter
self.chaptersStack = QtGui.QStackedWidget()
+ self.notasStack = QtGui.QStackedWidget()
def __len__(self):
"""The number of chapters"""
@@ -65,8 +67,8 @@ def addChapter(self, chapter):
self.chapters.addChild(chapter.root)
## ============================
## setup the UI
- ui = chapter.getGui()
- self.chaptersStack.addWidget(ui)
+ self.chaptersStack.addWidget(chapter.getGui())
+ self.notasStack.addWidget(chapter.getNotas())
self.whichChapter = len(self.chapters) - 1
#=======================================================================
chapter.pageChanged.connect(self._pageChangedCB)
@@ -108,6 +110,7 @@ def setWhichChapter(self, n):
obAnterior.chapterSpecificOut()
self.chapters.whichChild = n
self.chaptersStack.setCurrentIndex(n)
+ self.notasStack.setCurrentIndex(n)
chapterob = self.chapter
if hasattr(chapterob, "chapterSpecificIn") and chapterChanged:
chapterob.chapterSpecificIn()
@@ -134,11 +137,14 @@ def __init__(self, name=""):
self.__pages = nodeDict()
## ============================
+ ## self.wiget has next, prev buttons, plus a QStackedWidget for holding per page controls
self.widget = ChangePageUI()
self.widget.setStyleSheet("QWidget { background:white }")
connect(self.widget.siguiente, "clicked(bool)", self.nextPage)
connect(self.widget.previa, "clicked(bool)", self.prevPage)
## ============================
+ self.notasStack = QtGui.QStackedWidget()
+ ## ============================
## the initial sate
self.widget.previa.hide()
self.widget.siguiente.hide()
@@ -170,19 +176,30 @@ def addPage(self, page):
self.pages[root] = page
self.pagesSwitch.addChild(root)
## ============================
- layout = QtGui.QVBoxLayout()
- layout.setMargin(0)
- layout.setSpacing(0)
+ guiLayout = QtGui.QVBoxLayout()
+ guiLayout.setMargin(0)
+ guiLayout.setSpacing(0)
widget = QtGui.QWidget()
widget.setObjectName("PageGui")
- widget.setLayout(layout)
+ widget.setLayout(guiLayout)
self.widget.pageStack.addWidget(widget)
## ============================
- ## this sets both self.pagesSwitch and self.widget.pageStack
+ notasLayout = QtGui.QVBoxLayout()
+ notasLayout.setMargin(0)
+ notasLayout.setSpacing(0)
+ widget = QtGui.QWidget()
+ widget.setObjectName("PageNotas")
+ widget.setLayout(notasLayout)
+ self.notasStack.addWidget(widget)
+ ## ============================
+ ## this sets self.pagesSwitch, self.widget.pageStack, self.notasStack
self.whichPage = len(self.pagesSwitch) - 1
## ============================
if hasattr(page, "getGui"):
- layout.addWidget(page.getGui())
+ guiLayout.addWidget(page.getGui())
+ ## ============================
+ if hasattr(page, "getNotas"):
+ notasLayout.addWidget(page.getNotas())
## ============================
if len(self.pagesSwitch) == 2:
self.widget.previa.show()
@@ -192,6 +209,9 @@ def addPage(self, page):
def getGui(self):
return self.widget
+ def getNotas(self):
+ return self.notasStack
+
def chapterSpecificIn(self):
"code to be executed whenever the chapter is displayed"
"this is intended for global changes to the scenegraph that"
@@ -238,6 +258,7 @@ def setWhichPage(self, n):
self.pages[node].pre()
self.pagesSwitch.whichChild = n
self.widget.pageStack.setCurrentIndex(n)
+ self.notasStack.setCurrentIndex(n)
self.pageChanged.emit(n)
whichPage = property(getWhichPage, setWhichPage)
@@ -290,14 +311,29 @@ def __init__(self, name=""):
self.widget = QtGui.QWidget()
self.widget.setLayout(layout)
if self.name != "":
- layout.addWidget(QtGui.QLabel("<center><h1>%s</h1></center>" % self.name))
+ titulo = QtGui.QLabel("<center><h1>%s</h1></center>" % self.name)
+ titulo.setWordWrap(True)
+ layout.addWidget(titulo)
+ layout.addStretch()
+ ## ============================
+ layout = QtGui.QVBoxLayout()
+ self.notasWidget = QtGui.QWidget()
+ self.notasWidget.setLayout(layout)
+ notas = QtGui.QLabel(self.__doc__)
+ notas.setWordWrap(True)
+ notas.setTextFormat(QtCore.Qt.RichText)
+ layout.addWidget(notas)
+ layout.addStretch()
## ============================
self.coordPlanes = {}
self.setupAxis()
def getGui(self):
return self.widget
+ def getNotas(self):
+ return self.notasWidget
+
def addWidget(self, widget):
self.widget.layout().addWidget(widget)
View
@@ -568,12 +568,12 @@ class Curve3D(GraphicObject):
"""
A curve in 3D. It is composed of one or several Lines
"""
- def __init__(self, func, (tmin,tmax,npts), color=(1, 1, 1), width=1, nvertices= -1, visible=True, parent=None, domTrans=None):
+ def __init__(self, func, iter, color=(1, 1, 1), width=1, nvertices= -1, visible=True, parent=None, domTrans=None):
GraphicObject.__init__(self, visible, parent)
self.__derivative = None
self.fields = {}
self.lines = []
- self.iter = (tmin,tmax,npts)
+ self.iter = iter
c = lambda t: Vec3(func(t))
## ============================
if domTrans:
View
@@ -36,11 +36,10 @@
class Viewer(QWidget):
- "Viewer"
- def __init__(self, parent=None, uiLayout=None, luces=True):
- QWidget.__init__(self, parent)
- globals.ViewerInstances.append(self) #@UndefinedVariable
+ def __init__(self, parent=None, uiLayout=None, notasLayout=None, luces=True):
+ super(Viewer, self).__init__(parent)
+ globals.ViewerInstances.append(self)
self.book = Book()
#=======================================================================
# Copiamos algunos atributos de book
@@ -49,9 +48,10 @@ def __init__(self, parent=None, uiLayout=None, luces=True):
self.createChapter = self.book.createChapter
self.addChapter = self.book.addChapter
self.chaptersStack = self.book.chaptersStack
+ self.notasStack = self.book.notasStack
#=======================================================================
self.initializeViewer(luces)
- self.initializeUI(uiLayout)
+ self.initializeUI(uiLayout,notasLayout)
#=======================================================================
self.book.pageChanged.connect(self.onPageChanged)
self.book.chapterChanged.connect(self.onChapterChanged)
@@ -177,10 +177,11 @@ def initializeViewer(self, luces):
self.root.addChild(hints)
- def initializeUI(self, uilayout):
-# self.chaptersStack = QtGui.QStackedWidget()
+ def initializeUI(self, uilayout,notasLayout):
if uilayout:
uilayout.addWidget(self.chaptersStack)
+ if notasLayout:
+ notasLayout.addWidget(self.notasStack)
@QtCore.pyqtSignature("bool")
def on_axisButton_clicked(self, b):

0 comments on commit 377ef33

Please sign in to comment.