class EMInspectorControlScatterPlot(EMInspectorControlShape): """ Class to make scatter plot 3D inspector """ def __init__(self, name, item3d): EMInspectorControlShape.__init__(self, name, item3d) def updateItemControls(self): """ Updates this item inspector. Function is called by the item it observes""" super(EMInspectorControlScatterPlot, self).updateItemControls() self.pointsize.setValue(self.item3d().getPointSize()) def addTabs(self): """ Add a tab for each 'column' """ super(EMInspectorControlScatterPlot, self).addTabs() tabwidget = QtGui.QWidget() gridbox = QtGui.QGridLayout() EMInspectorControlScatterPlot.addControls(self, gridbox) tabwidget.setLayout(gridbox) self.addTab(tabwidget, "scatterplot") def addControls(self, gridbox): """ Construct all the widgets in this Item Inspector """ scatterframe = QtGui.QFrame() scatterframe.setFrameShape(QtGui.QFrame.StyledPanel) lfont = QtGui.QFont() lfont.setBold(True) scattergridbox = QtGui.QGridLayout() scattergridbox.setAlignment(QtCore.Qt.AlignTop) # Add widgets to frame pslabel = QtGui.QLabel("Point Size") pslabel.setFont(lfont) pslabel.setAlignment(QtCore.Qt.AlignCenter) scattergridbox.addWidget(pslabel, 0, 0, 1, 1) self.pointsize = EMSpinWidget(int(self.item3d().getPointSize()), 1.0, rounding=0) self.pointsize.setMinimumWidth(120) scattergridbox.addWidget(self.pointsize, 1, 0, 1, 1) scatterframe.setLayout(scattergridbox) gridbox.addWidget(scatterframe, 3, 0) # set to default, but run only as a base class if type(self) == EMInspectorControlScatterPlot: self.updateItemControls() QtCore.QObject.connect(self.pointsize,QtCore.SIGNAL("valueChanged(int)"),self.onPointSizeChanged) def onPointSizeChanged(self): self.item3d().setPointSize(self.pointsize.getValue()) if self.inspector: self.inspector().updateSceneGraph()
class EMInspectorControlLine(EMInspectorControlShape): """ Class to make EMItem GUI SHAPE Line Inspector """ def __init__(self, name, item3d): EMInspectorControlShape.__init__(self, name, item3d) def updateItemControls(self): """ Updates this item inspector. Function is called by the item it observes""" super(EMInspectorControlLine, self).updateItemControls() def updateMetaData(self): """ Updates the items metadata, such as line length, width. Function is called by the item it observes when the items meta data changes """ super(EMInspectorControlLine, self).updateMetaData() self.leftArrowSize.setValue(self.item3d().leftArrowSize, quiet=1) self.leftArrowLength.setValue(self.item3d().leftArrowLength, quiet=1) self.rightArrowSize.setValue(self.item3d().rightArrowSize, quiet=1) self.rightArrowLength.setValue(self.item3d().rightArrowLength, quiet=1) self.slice.setValue(self.item3d().slices, quiet=1) self.stack.setValue(self.item3d().stacks, quiet=1) self.linelength.setValue(int(self.item3d().length), quiet=1) def addTabs(self): """ Add a tab for each 'column' """ super(EMInspectorControlLine, self).addTabs() tabwidget = QtGui.QWidget() gridbox = QtGui.QGridLayout() EMInspectorControlLine.addControls(self, gridbox) tabwidget.setLayout(gridbox) self.addTab(tabwidget, "line") def addControls(self, gridbox): """ Construct all the widgets in this Item Inspector """ #frame to control properties of left/right arrows lineframe = QtGui.QFrame() lineframe.setFrameShape(QtGui.QFrame.StyledPanel) lfont = QtGui.QFont() lfont.setBold(True) linegridbox = QtGui.QGridLayout() leftlabel = QtGui.QLabel("Left arrow") leftlabel.setFont(lfont) leftlabel.setAlignment(QtCore.Qt.AlignCenter) linegridbox.addWidget(leftlabel, 0, 1, 1, 1) sidelabel1 = QtGui.QLabel("Size") sidelabel1.setFont(lfont) sidelabel1.setAlignment(QtCore.Qt.AlignVCenter) linegridbox.addWidget(sidelabel1, 2, 0, 1, 1) sidelabel2 = QtGui.QLabel("Length") sidelabel2.setFont(lfont) sidelabel2.setAlignment(QtCore.Qt.AlignVCenter) linegridbox.addWidget(sidelabel2, 3, 0, 1, 1) self.leftShowArrow = QtGui.QCheckBox("Show") self.leftShowArrow.setChecked(self.item3d().showLeftArrow) linegridbox.addWidget(self.leftShowArrow, 1, 1, 1, 1) self.leftArrowSize = EMSpinWidget(int(self.item3d().leftArrowSize), 1.0, rounding=0) self.leftArrowSize.setMinimumWidth(120) linegridbox.addWidget(self.leftArrowSize, 2, 1, 1, 1) self.leftArrowLength = EMSpinWidget(int(self.item3d().leftArrowLength), 1.0, rounding=0) self.leftArrowLength.setMinimumWidth(120) linegridbox.addWidget(self.leftArrowLength, 3, 1, 1, 1) rightlabel = QtGui.QLabel("Right arrow") rightlabel.setFont(lfont) rightlabel.setAlignment(QtCore.Qt.AlignCenter) linegridbox.addWidget(rightlabel, 0, 2, 1, 1) self.rightShowArrow = QtGui.QCheckBox("Show") self.rightShowArrow.setChecked(self.item3d().showRightArrow) linegridbox.addWidget(self.rightShowArrow, 1, 2, 1, 1) self.rightArrowSize = EMSpinWidget(int(self.item3d().rightArrowSize), 1.0, rounding=0) self.rightArrowSize.setMinimumWidth(120) linegridbox.addWidget(self.rightArrowSize, 2, 2, 1, 1) self.rightArrowLength = EMSpinWidget(int(self.item3d().rightArrowLength), 1.0, rounding=0) self.rightArrowLength.setMinimumWidth(120) linegridbox.addWidget(self.rightArrowLength, 3, 2, 1, 1) linelengthlabel = QtGui.QLabel("Line Length") linelengthlabel.setFont(lfont) linelengthlabel.setAlignment(QtCore.Qt.AlignCenter) linegridbox.addWidget(linelengthlabel, 4, 0, 2, 2) self.linelength = EMSpinWidget(int(self.item3d().length), 1.0, rounding=0) linegridbox.addWidget(self.linelength, 4, 2, 2, 2) linewidthlabel = QtGui.QLabel("Line Width") linewidthlabel.setFont(lfont) linewidthlabel.setAlignment(QtCore.Qt.AlignCenter) linegridbox.addWidget(linewidthlabel, 5, 0, 1, 2) self.linewidth = EMSpinWidget(int(self.item3d().width), 1.0, rounding=0) linegridbox.addWidget(self.linewidth, 5, 2, 1, 2) lineframe.setLayout(linegridbox) gridbox.addWidget(lineframe, 2, 0) #frame to control slice/stack of the line lineframe2 = QtGui.QFrame() lineframe2.setFrameShape(QtGui.QFrame.StyledPanel) linehbox = QtGui.QVBoxLayout() self.slice = ValSlider(lineframe2, (1, 100), "Slice", rounding=0) self.slice.setValue(self.item3d().slices) self.stack = ValSlider(lineframe2, (1, 100), "Stack", rounding=0) self.slice.setValue(self.item3d().stacks) linehbox.addWidget(self.slice) linehbox.addWidget(self.stack) lineframe2.setLayout(linehbox) gridbox.addWidget(lineframe2, 3, 0) # set to default, but run only as a base class if type(self) == EMInspectorControl3DText: self.updateItemControls() self.updateMetaData() QtCore.QObject.connect(self.leftShowArrow, QtCore.SIGNAL("stateChanged(int)"), self.redraw) QtCore.QObject.connect(self.rightShowArrow, QtCore.SIGNAL("stateChanged(int)"), self.redraw) QtCore.QObject.connect(self.leftArrowSize,QtCore.SIGNAL("valueChanged(int)"),self.redraw) QtCore.QObject.connect(self.leftArrowLength,QtCore.SIGNAL("valueChanged(int)"),self.redraw) QtCore.QObject.connect(self.rightArrowSize,QtCore.SIGNAL("valueChanged(int)"),self.redraw) QtCore.QObject.connect(self.rightArrowLength,QtCore.SIGNAL("valueChanged(int)"),self.redraw) QtCore.QObject.connect(self.linelength,QtCore.SIGNAL("valueChanged(int)"),self.redraw) QtCore.QObject.connect(self.linewidth,QtCore.SIGNAL("valueChanged(int)"),self.redraw) QtCore.QObject.connect(self.slice,QtCore.SIGNAL("valueChanged"),self.redraw) QtCore.QObject.connect(self.stack,QtCore.SIGNAL("valueChanged"),self.redraw) def redraw(self): self.item3d().setShowLeftArrow(self.leftShowArrow.isChecked()) self.item3d().setShowRightArrow(self.rightShowArrow.isChecked()) self.item3d().leftArrowSize = self.leftArrowSize.getValue() self.item3d().leftArrowLength = self.leftArrowLength.getValue() self.item3d().rightArrowSize = self.rightArrowSize.getValue() self.item3d().rightArrowLength = self.rightArrowLength.getValue() self.item3d().setLength(self.linelength.getValue()) self.item3d().setWidth(self.linewidth.getValue()) self.item3d().setSlices(self.slice.getValue()) self.item3d().setStacks(self.stack.getValue()) if self.inspector: self.inspector().updateSceneGraph()
class EMInspectorControl3DText(EMInspectorControlShape): """ Class to make EMItem GUI SHAPE 3DText Inspector """ def __init__(self, name, item3d): EMInspectorControlShape.__init__(self, name, item3d) def updateItemControls(self): """ Updates this item inspector. Function is called by the item it observes""" super(EMInspectorControl3DText, self).updateItemControls() self.fontDepth.setValue(int(self.item3d().getFontDepth())) self.fontSize.setValue(int(self.item3d().getFontSize())) def updateMetaData(self): """ Updates the items metadata, such as line length, width. Function is called by the item it observes when the items meta data changes """ super(EMInspectorControlShape, self).updateMetaData() if self.item3d().getFontMode() == FTGLFontMode.EXTRUDE: self.textModeBox.setCurrentIndex(0) if self.item3d().getFontMode() == FTGLFontMode.TEXTURE: self.textModeBox.setCurrentIndex(1) if self.item3d().getFontMode() == FTGLFontMode.POLYGON: self.textModeBox.setCurrentIndex(2) if self.item3d().getFontMode() == FTGLFontMode.OUTLINE: self.textModeBox.setCurrentIndex(3) def addTabs(self): """ Add a tab for each 'column' """ super(EMInspectorControl3DText, self).addTabs() tabwidget = QtGui.QWidget() gridbox = QtGui.QGridLayout() EMInspectorControl3DText.addControls(self, gridbox) tabwidget.setLayout(gridbox) self.addTab(tabwidget, "text") def addControls(self, gridbox): """ Construct all the widgets in this Item Inspector """ textframe = QtGui.QFrame() textframe.setFrameShape(QtGui.QFrame.StyledPanel) lfont = QtGui.QFont() lfont.setBold(True) textgridbox = QtGui.QGridLayout() # Add widgets to textframe textlabel = QtGui.QLabel("3D Font Mode") textlabel.setFont(lfont) textlabel.setAlignment(QtCore.Qt.AlignCenter) textgridbox.addWidget(textlabel, 0, 0, 1, 1) self.textModeBox = QtGui.QComboBox() self.textModeBox.addItems(["EXTRUDE", "TEXTURE", "POLYGON", "OUTLINE"]) textgridbox.addWidget(self.textModeBox, 0, 1, 1, 1) textlabel2 = QtGui.QLabel("3D Font Depth") textlabel2.setFont(lfont) textlabel2.setAlignment(QtCore.Qt.AlignCenter) textgridbox.addWidget(textlabel2, 1, 0, 1, 1) self.fontDepth = EMSpinWidget(int(self.item3d().getFontDepth()), 1.0, rounding=0) self.fontDepth.setMinimumWidth(120) textgridbox.addWidget(self.fontDepth, 1, 1, 1, 1) textlabel2 = QtGui.QLabel("3D Font Size") textlabel2.setFont(lfont) textlabel2.setAlignment(QtCore.Qt.AlignCenter) textgridbox.addWidget(textlabel2, 2, 0, 1, 1) self.fontSize = EMSpinWidget(int(self.item3d().getFontSize()), 1.0, rounding=0) self.fontSize.setMinimumWidth(120) textgridbox.addWidget(self.fontSize, 2, 1, 1, 1) textframe.setLayout(textgridbox) gridbox.addWidget(textframe, 2, 0) # Add text text3dframe = QtGui.QFrame() text3dframe.setFrameShape(QtGui.QFrame.StyledPanel) text3dgridbox = QtGui.QGridLayout() textlabel3 = QtGui.QLabel("3D Text") textlabel3.setFont(lfont) text3dgridbox.addWidget(textlabel3, 3, 0, 2, 1) self.text3d = QtGui.QLineEdit(self.item3d().getRenderString()) text3dgridbox.addWidget(self.text3d, 3, 1, 2, 1) text3dframe.setLayout(text3dgridbox) gridbox.addWidget(text3dframe, 3, 0) # set to default, but run only as a base class if type(self) == EMInspectorControl3DText: self.updateItemControls() self.updateMetaData() self.textModeBox.currentIndexChanged.connect(self.on3DTextModeChanged) QtCore.QObject.connect(self.fontDepth,QtCore.SIGNAL("valueChanged(int)"),self.on3DTextDepthChanged) QtCore.QObject.connect(self.fontSize,QtCore.SIGNAL("valueChanged(int)"),self.on3DTextFontChanged) QtCore.QObject.connect(self.text3d,QtCore.SIGNAL("textChanged(const QString&)"),self.on3DTextChanged) def on3DTextModeChanged(self): textMode = str(self.textModeBox.currentText()) if textMode == "EXTRUDE": self.item3d().setFontMode(FTGLFontMode.EXTRUDE) elif textMode == "TEXTURE": self.item3d().setFontMode(FTGLFontMode.TEXTURE) elif textMode == "POLYGON": self.item3d().setFontMode(FTGLFontMode.POLYGON) elif textMode == "OUTLINE": self.item3d().setFontMode(FTGLFontMode.OUTLINE) if self.inspector: self.inspector().updateSceneGraph() def on3DTextDepthChanged(self): self.item3d().setFontDepth(int(self.fontDepth.getValue())) if self.inspector: self.inspector().updateSceneGraph() def on3DTextFontChanged(self): self.item3d().setRenderString(self.item3d().getRenderString(), int(self.fontSize.getValue())) if self.inspector: self.inspector().updateSceneGraph() def on3DTextChanged(self, string): self.item3d().setRenderString(str(string), self.item3d().getFontSize()) if self.inspector: self.inspector().updateSceneGraph()