def setImageSequenceCurrentIndex(self, pImageSequenceCurrentIndex): self.imageSequenceFileCurrentIndexLabel.setText( pImageSequenceCurrentIndex) CDConstants.printOut( "___ - DEBUG ----- CDControlCellScene: setImageSequenceCurrentIndex(pImageSequenceCurrentIndex==" + str(pImageSequenceCurrentIndex) + "): done", CDConstants.DebugVerbose)
def endElement(self, namespaceURI, localName, qName): CDConstants.printOut( "___ - DEBUG ----- CDConstants: endElement( namespaceURI==" + str(namespaceURI) + ", localName==" + str(localName) + ", qName==" + str(qName) + " ), self.currentText==" + str(self.currentText), CDConstants.DebugExcessive) # if qName == 'title': # if self.item: # self.item.setText(0, self.currentText) if qName == "PIFScene": if self.item: self.item.setText(1, str(self.currentText)) # we got the filename for the Scene file: self.theParentWindget.thePIFSceneFileName = str(self.currentText) self.item = self.item.parent() elif qName == "PIFF": if self.item: self.item.setText(1, str(self.currentText)) # we got the filename for the PIFF file: self.theParentWindget.thePIFFFileName = str(self.currentText) self.item = self.item.parent() elif qName == "ResDir": self.item = self.item.parent() return True
def setImageSequenceImageUnitsLabel(self, pImageSequenceImageUnitsLabel): self.imageSequenceImageOrImagesLabel.setText( pImageSequenceImageUnitsLabel) CDConstants.printOut( "___ - DEBUG ----- CDControlCellScene: setImageSequenceImageUnitsLabel(pImageSequenceImageUnitsLabel==" + str(pImageSequenceImageUnitsLabel) + "): done", CDConstants.DebugVerbose)
def fatalError(self, exception): CDConstants.printOut( "___ - DEBUG ----- CDConstants: fatalError( exception=="+str(exception)+" )" , CDConstants.DebugExcessive ) QtGui.QMessageBox.information(self.treeWidget.window(), "SAX Bookmarks", "Parse error at line %d, column %d:\n%s" % (exception.lineNumber(), exception.columnNumber(), exception.message())) return False
def characters(self, txt): CDConstants.printOut( "___ - DEBUG ----- CDConstants: characters( txt==" + str(txt) + " )", CDConstants.DebugExcessive) self.currentText += txt return True
def setFixedRasterWidth(self, pTheNewValue): if pTheNewValue != self.thePIFFFixedRasterWidth: self.thePIFFFixedRasterWidth = pTheNewValue CDConstants.printOut("the PIFF fixed raster width is now = "+str(self.thePIFFFixedRasterWidth), CDConstants.DebugTODO ) # propagate the signal upstream, for example to parent objects: self.signalPIFFGenerationModeHasChanged.emit( \ self.thePIFFGenerationMode, self.thePIFFFixedRasterWidth)
def setImageSequenceDepthLabel(self, pImageSequenceDepthLabel): self.imageSequenceDepthLabel.setText(pImageSequenceDepthLabel) # also update the image selection range in the Image Sequence controls, # remembering that the index starts at 0 so the max image index should be: self.setMaxImageIndex(int(pImageSequenceDepthLabel)-1) # self.controlsForImageSequence.setMaxImageIndex(int(pImageSequenceDepthLabel)-1) CDConstants.printOut("___ - DEBUG ----- CDControlCellScene: setImageSequenceDepthLabel(pImageSequenceDepthLabel=="+str(pImageSequenceDepthLabel)+"): done", CDConstants.DebugVerbose )
def getCellColorsDict(self): # regionUseDict = a dict of all cell colors, # one for each RGBA color: [name,#regions](color) self.regionUseDict = {} lRowCount = self.typeColorTable.rowCount() CDConstants.printOut("-=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=-", CDConstants.DebugAll) CDConstants.printOut( "self.typeColorTable = " + str(self.typeColorTable), CDConstants.DebugAll) CDConstants.printOut( "self.typeColorTable.rowCount() = " + str(self.typeColorTable.rowCount()), CDConstants.DebugAll) for i in range(lRowCount): # get the QString at item (i, 0) and place it into a str(): lCellID = str(self.typeColorTable.item(i, 0).text()) # get the QColor from the QBrush at item (i, 1) and place it into an int: lCellColor = self.typeColorTable.item( i, 1).background().color().rgba() self.regionUseDict[lCellID] = lCellColor CDConstants.printOut( "i=" + str(i) + " self.regionUseDict[lCellID==" + str(lCellID) + "] = lCellColor==" + str(lCellColor), CDConstants.DebugAll) CDConstants.printOut("-=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=-", CDConstants.DebugAll) return self.regionUseDict
def setImageSequenceCurrentFilename(self, pImageSequenceCurrentFilename): self.imageSequenceCurrentFilename.setText( pImageSequenceCurrentFilename) CDConstants.printOut( "___ - DEBUG ----- CDControlCellScene: setImageSequenceCurrentFilename(pImageSequenceCurrentFilename==" + str(pImageSequenceCurrentFilename) + "): done", CDConstants.DebugVerbose)
def handleScaleZoomChanged(self, pValueString): CDConstants.printOut( "the requested Input Image scale/zoom is = "+str(pValueString), CDConstants.DebugTODO ) lScaleZoom = pValueString if lScaleZoom != self.theScaleZoom: self.theScaleZoom = lScaleZoom CDConstants.printOut( "the new Input Image scale/zoom will be = "+str(self.theScaleZoom), CDConstants.DebugTODO ) # propagate the signal upstream, for example to parent objects: self.signalImageScaleZoomHasChanged.emit(self.theScaleZoom)
def __handleImageScaleChanged(self, pValueString): CDConstants.printOut( "the requested Input Image scale is = "+str(pValueString), CDConstants.DebugTODO ) lScaleFactor = pValueString if lScaleFactor != self.__theImageScaleFactor: self.__theImageScaleFactor = lScaleFactor CDConstants.printOut( "the new Input Image scale will be = "+str(self.__theImageScaleFactor), CDConstants.DebugTODO ) # propagate the signal upstream, for example to parent objects: self.signalImageScaleHasChanged.emit(self.__theImageScaleFactor)
def handlePIFFGenerationModeHasChanged(self, pNewMode, pNewFixedRasterSize): if (pNewMode != self.piffGenerationMode) or (pNewFixedRasterSize != self.piffFixedRasterWidth): CDConstants.printOut("CDPreferences() - handlePIFFGenerationModeHasChanged(pNewMode=="+str(pNewMode)+", pNewFixedRasterSize=="+str(pNewFixedRasterSize)+" )", CDConstants.DebugTODO ) # change global variables AKA preferences: self.piffGenerationMode = pNewMode self.piffFixedRasterWidth = pNewFixedRasterSize # automatically save preferences to disk: self.writePreferencesToDisk()
def getPIFFFileName(self): lTmpPathOnly = os.path.join(self.thePathToSceneBundleDir, self.theResDir) lTmpPathAndFileName = os.path.join(lTmpPathOnly, self.thePIFFFileName) CDConstants.printOut( "___ - DEBUG ----- CDSceneBundle: getPIFFFileName() lTmpPathAndFileName==" + lTmpPathAndFileName, CDConstants.DebugVerbose) return lTmpPathAndFileName
def createChildItem(self, tagName): CDConstants.printOut( "___ - DEBUG ----- CDConstants: createChildItem()" , CDConstants.DebugExcessive ) if self.item: childItem = QtGui.QTreeWidgetItem(self.item) else: childItem = QtGui.QTreeWidgetItem(self.treeWidget) childItem.setData(0, QtCore.Qt.UserRole, tagName) return childItem
def __init__(self,pString=None,pParent=None): if (pString==None): lString=QtCore.QString("CDControlSceneZoomToolbar QToolBar") else: lString=QtCore.QString(pString) QtGui.QToolBar.__init__(self, lString, pParent) # the class global keeping track of the current scene zoom value: self.__theZoomFactor = "100%" # ---------------------------------------------------------------- # # QWidget setup (1) - windowing GUI setup for Scene Zoom controls: # # ---------------------------------------------------------------- # # QWidget setup (2) - "Zoom" QGroupBox: self.__theZoomGroupBox = QtGui.QGroupBox("Zoom Scene") # self.__theZoomGroupBox.setPalette(QtGui.QPalette(QtGui.QColor(222,222,222))) # self.__theZoomGroupBox.setAutoFillBackground(True) # set the position of the QGroupBox's label: self.__theZoomGroupBox.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom) self.__theZoomGroupBox.setFlat(False) self.__theZoomGroupBox.setLayout(QtGui.QHBoxLayout()) self.__theZoomGroupBox.layout().setMargin(0) self.__theZoomGroupBox.layout().setSpacing(0) self.__theZoomGroupBox.layout().setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) # a "combo box" pop-up menu to select the Zoom Scene factor: self.__sceneZoomComboBox = QtGui.QComboBox() self.__sceneZoomComboBox.addItems(["50%", "75%", "100%", "125%", "150%", "200%", "250%", "300%", "400%", "500%", "1000%", "2000%", "4000%"]) self.__sceneZoomComboBox.setCurrentIndex(2) self.__sceneZoomComboBox.clearFocus() self.__sceneZoomComboBox.setStatusTip("Zoom the Cell Scene view") self.__sceneZoomComboBox.setToolTip("Zoom Cell Scene") self.__sceneZoomComboBox.setFrame(False) # call __handleSceneZoomChanged() when __sceneZoomComboBox changes index: self.__sceneZoomComboBox.currentIndexChanged[str].connect(self.__handleSceneZoomChanged) # add the combo box to the QGroupBox: self.__theZoomGroupBox.layout().addWidget(self.__sceneZoomComboBox) # finally add the QGroupBox to the QToolBar: # self.addWidget(QtGui.QLabel("[")) self.addWidget(self.__theZoomGroupBox) # self.addWidget(QtGui.QLabel("]")) self.show() CDConstants.printOut( "----- CDControlSceneZoomToolbar.__init__(pString=="+str(pString)+", pParent=="+str(pParent)+") done. -----", CDConstants.DebugExcessive )
def setFixedRasterWidth(self, pTheNewValue): if pTheNewValue != self.thePIFFFixedRasterWidth: self.thePIFFFixedRasterWidth = pTheNewValue CDConstants.printOut( "the PIFF fixed raster width is now = " + str(self.thePIFFFixedRasterWidth), CDConstants.DebugTODO) # propagate the signal upstream, for example to parent objects: self.signalPIFFGenerationModeHasChanged.emit( \ self.thePIFFGenerationMode, self.thePIFFFixedRasterWidth)
def setValue(self, pValue): self.progressBar.setValue(pValue) curVal = self.progressBar.value() maxVal = self.progressBar.maximum() lPercentage = (float(curVal) / float(maxVal)) * 100.0 self.percentageLabel.setText( QtCore.QString("... %1 %").arg(lPercentage, 0, 'g', 2) ) QtGui.QApplication.processEvents(QtCore.QEventLoop.ExcludeUserInputEvents) CDConstants.printOut( "___ - DEBUG ----- CDImageNP.setValue( "+str(pValue)+" ) done." , CDConstants.DebugExcessive )
def __handleSceneZoomChanged(self, pValueString): CDConstants.printOut( "the requested Scene zoom is = "+str(pValueString), CDConstants.DebugTODO ) lZoomFactor = pValueString if lZoomFactor != self.__theZoomFactor: self.__theZoomFactor = lZoomFactor CDConstants.printOut( "the new Scene zoom will be = "+str(self.__theZoomFactor), CDConstants.DebugTODO ) # propagate the signal upstream, for example to parent objects: self.signalZoomFactorHasChanged.emit(self.__theZoomFactor)
def setImageSequenceDepthLabel(self, pImageSequenceDepthLabel): self.imageSequenceDepthLabel.setText(pImageSequenceDepthLabel) # also update the image selection range in the Image Sequence controls, # remembering that the index starts at 0 so the max image index should be: self.setMaxImageIndex(int(pImageSequenceDepthLabel) - 1) # self.controlsForImageSequence.setMaxImageIndex(int(pImageSequenceDepthLabel)-1) CDConstants.printOut( "___ - DEBUG ----- CDControlCellScene: setImageSequenceDepthLabel(pImageSequenceDepthLabel==" + str(pImageSequenceDepthLabel) + "): done", CDConstants.DebugVerbose)
def isTheBackgroundAnImage(self): buttons = self.buttonGroupForBackgrounds.buttons() for myButton in buttons: CDConstants.printOut( " 123123123123123 = "+str(myButton)+" button has text "+str(myButton.text())+" ", CDConstants.DebugTODO ) if myButton.isChecked() == True: lText = myButton.text() if (lText == "Blue Grid") or (lText == "White Grid") or (lText == "Gray Grid") or (lText == "No Grid"): return False else: return True
def fatalError(self, exception): CDConstants.printOut( "___ - DEBUG ----- CDConstants: fatalError( exception==" + str(exception) + " )", CDConstants.DebugExcessive) QtGui.QMessageBox.information( self.treeWidget.window(), "SAX Bookmarks", "Parse error at line %d, column %d:\n%s" % (exception.lineNumber(), exception.columnNumber(), exception.message())) return False
def createChildItem(self, tagName): CDConstants.printOut( "___ - DEBUG ----- CDConstants: createChildItem()", CDConstants.DebugExcessive) if self.item: childItem = QtGui.QTreeWidgetItem(self.item) else: childItem = QtGui.QTreeWidgetItem(self.treeWidget) childItem.setData(0, QtCore.Qt.UserRole, tagName) return childItem
def __handleImageScaleChanged(self, pValueString): CDConstants.printOut( "the requested Input Image scale is = " + str(pValueString), CDConstants.DebugTODO) lScaleFactor = pValueString if lScaleFactor != self.__theImageScaleFactor: self.__theImageScaleFactor = lScaleFactor CDConstants.printOut( "the new Input Image scale will be = " + str(self.__theImageScaleFactor), CDConstants.DebugTODO) # propagate the signal upstream, for example to parent objects: self.signalImageScaleHasChanged.emit(self.__theImageScaleFactor)
def handlePIFFGenerationModeHasChanged(self, pNewMode, pNewFixedRasterSize): if (pNewMode != self.piffGenerationMode) or ( pNewFixedRasterSize != self.piffFixedRasterWidth): CDConstants.printOut( "CDPreferences() - handlePIFFGenerationModeHasChanged(pNewMode==" + str(pNewMode) + ", pNewFixedRasterSize==" + str(pNewFixedRasterSize) + " )", CDConstants.DebugTODO) # change global variables AKA preferences: self.piffGenerationMode = pNewMode self.piffFixedRasterWidth = pNewFixedRasterSize # automatically save preferences to disk: self.writePreferencesToDisk()
def setValue(self, pValue): self.progressBar.setValue(pValue) curVal = self.progressBar.value() maxVal = self.progressBar.maximum() lPercentage = (float(curVal) / float(maxVal)) * 100.0 self.percentageLabel.setText( QtCore.QString("... %1 %").arg(lPercentage, 0, 'g', 2)) QtGui.QApplication.processEvents( QtCore.QEventLoop.ExcludeUserInputEvents) CDConstants.printOut( "___ - DEBUG ----- CDImageNP.setValue( " + str(pValue) + " ) done.", CDConstants.DebugExcessive)
def __init__(self, pTitle="CellDraw: processing.", pLabelText=" ", pMaxValue=100, pParent=None): # it is compulsory to call the parent's __init__ class right away: super(CDWaitProgressBar, self).__init__(pParent) # print "CDWaitProgressBar.__init__()" # the progress bar widget is defined in __createProgressBar() below: self.__progressBar = None self.__theTitle = pTitle self.__theLabelText = pLabelText self.__maxValue = pMaxValue self.__theParent = pParent # if we needed an image in the progress bar, we'd now: # self.__imageLabel, self.__waitProgressBarGroupBox = self.__InitCentralWidget(self.__theTitle) self.__waitProgressBarGroupBox = self.__InitCentralWidget( self.__theTitle) # # set up a widget with a QProgressBar, show it inside the QWidget: # lFont = QtGui.QFont() lFont.setWeight(QtGui.QFont.Light) self.setFont(lFont) self.setLayout(QtGui.QHBoxLayout()) self.layout().setMargin(0) self.layout().setSpacing(0) self.layout().setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) self.setWindowTitle("CellDraw: processing windowTitle.") self.setStatusTip(QtCore.QString(self.__theTitle)) self.setToolTip(QtCore.QString(self.__theTitle)) # do not delete the window widget when the window is closed: self.setAttribute(QtCore.Qt.WA_DeleteOnClose, False) # if we needed an image in the progress bar, we'd now: # self.layout().addWidget(self.__imageLabel) self.layout().addWidget(self.__waitProgressBarGroupBox) CDConstants.printOut( " " + str("--- - DEBUG ----- CDWaitProgressBar: __init__(): done") + " ", CDConstants.DebugTODO)
def handleAreaOrEdgeButtonGroupClicked(self, pChecked): lImageSequenceProcessingMode = 0 if self.regionSeedsButton.isChecked(): lImageSequenceProcessingMode |= (1 << CDConstants.ImageSequenceUseAreaSeeds) if self.regionEdgeButton.isChecked(): lImageSequenceProcessingMode |= (1 << CDConstants.ImageSequenceUse2DEdges) if self.regionContoursButton.isChecked(): lImageSequenceProcessingMode |= (1 << CDConstants.ImageSequenceUse3DContours) if self.regionVolumeButton.isChecked(): lImageSequenceProcessingMode |= (1 << CDConstants.ImageSequenceUse3DVolume) if self.discretizeToBWModeButton.isChecked(): lImageSequenceProcessingMode |= (1 << CDConstants.ImageSequenceUseDiscretizedToBWMode) # TODO add fourth mode here, in the sequence class, and in the rasterizer class: # # then TODO change PIFF numbering format printout specifically only for image sequence rasterization: if lImageSequenceProcessingMode != self.theImageSequenceProcessingMode: self.theImageSequenceProcessingMode = lImageSequenceProcessingMode # bin() does not exist in Python 2.5: if ((sys.version_info[0] >= 2) and (sys.version_info[1] >= 6)) : CDConstants.printOut( "CDControlImageSequence - handleAreaOrEdgeButtonGroupClicked(), str(type(self.theImageSequenceProcessingMode))==["+str(type(self.theImageSequenceProcessingMode))+"], str(type(self.theImageSequenceProcessingMode).__name__)==["+str(type(self.theImageSequenceProcessingMode).__name__)+"], str(self.theImageSequenceProcessingMode)==["+str(self.theImageSequenceProcessingMode)+"], str(bin(int(self.theImageSequenceProcessingMode)))==["+str(bin(int(self.theImageSequenceProcessingMode)))+"]" , CDConstants.DebugTODO ) CDConstants.printOut("CDControlImageSequence - handleAreaOrEdgeButtonGroupClicked(), theImageSequenceProcessingMode is = " +str(bin(self.theImageSequenceProcessingMode)), CDConstants.DebugVerbose) else: CDConstants.printOut( "CDControlImageSequence - handleAreaOrEdgeButtonGroupClicked(), str(type(self.theImageSequenceProcessingMode))==["+str(type(self.theImageSequenceProcessingMode))+"], str(type(self.theImageSequenceProcessingMode).__name__)==["+str(type(self.theImageSequenceProcessingMode).__name__)+"], str(self.theImageSequenceProcessingMode)==["+str(self.theImageSequenceProcessingMode)+"], str(int(self.theImageSequenceProcessingMode))==["+str(int(self.theImageSequenceProcessingMode))+"]" , CDConstants.DebugTODO ) CDConstants.printOut("CDControlImageSequence - handleAreaOrEdgeButtonGroupClicked(), theImageSequenceProcessingMode is = " +str(self.theImageSequenceProcessingMode), CDConstants.DebugVerbose) # propagate the signal upstream, for example to parent objects: self.signalImageSequenceProcessingModeHasChanged.emit(self.theImageSequenceProcessingMode)
def addActionToControlsForSceneItemEdit(self, pAction): # add an action to the QGroupBox: lToolButton = QtGui.QToolButton(self) lToolButton.setDefaultAction(pAction) lToolButton.setCheckable(pAction.isCheckable()) lToolButton.setChecked(pAction.isChecked()) lToolButton.setIcon(pAction.icon()) lToolButton.setIconSize(QtCore.QSize(24, 24)) lToolButton.setToolTip(pAction.toolTip()) lToolButton.setStatusTip(pAction.toolTip() + " Scene Item") self.itemEditGroupBox.layout().addWidget(lToolButton) CDConstants.printOut( "___ - DEBUG ----- CDControlSceneItemEdit: addActionToControlsForSceneItemEdit("+ str(pAction) + ") done." , CDConstants.DebugTODO )
def handlerForSceneResized(self, pDict): lDict = dict(pDict) CDConstants.printOut(" ", CDConstants.DebugTODO) CDConstants.printOut( " TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO ", CDConstants.DebugTODO ) CDConstants.printOut(str(lDict), CDConstants.DebugTODO) CDConstants.printOut( " TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO ", CDConstants.DebugTODO ) CDConstants.printOut(" ", CDConstants.DebugTODO) self.setSceneWidthLabel(lDict[0]) self.setSceneHeightLabel(lDict[1]) self.setSceneDepthLabel(lDict[2]) self.setSceneUnitsLabel(lDict[3])
def handlerForSceneResized(self, pDict): lDict = dict(pDict) CDConstants.printOut(" ", CDConstants.DebugTODO) CDConstants.printOut( " TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO ", CDConstants.DebugTODO) CDConstants.printOut(str(lDict), CDConstants.DebugTODO) CDConstants.printOut( " TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO ", CDConstants.DebugTODO) CDConstants.printOut(" ", CDConstants.DebugTODO) self.setSceneWidthLabel(lDict[0]) self.setSceneHeightLabel(lDict[1]) self.setSceneDepthLabel(lDict[2]) self.setSceneUnitsLabel(lDict[3])
def handleLayerButtonGroupClicked(self, pChecked): if self.pointerButton.isChecked(): lLayerMode = CDConstants.SceneModeMoveItem elif self.resizeButton.isChecked(): lLayerMode = CDConstants.SceneModeResizeItem elif self.imageLayerButton.isChecked(): lLayerMode = CDConstants.SceneModeImageLayer elif self.imageSequenceButton.isChecked(): lLayerMode = CDConstants.SceneModeImageSequence elif self.editClusterButton.isChecked(): lLayerMode = CDConstants.SceneModeEditCluster if lLayerMode != self.theLayerMode: self.theLayerMode = lLayerMode CDConstants.printOut("CDControlLayerSelection - handleLayerButtonGroupClicked(), the layer mode is = " +str(self.theLayerMode), CDConstants.DebugVerbose) # propagate the signal upstream, for example to parent objects: self.signalLayersSelectionModeHasChanged.emit(self.theLayerMode)
def handleLayerActionGroupTriggered(self, pChecked): if self.pointerAction.isChecked(): lLayerMode = CDConstants.SceneModeMoveItem elif self.resizeAction.isChecked(): lLayerMode = CDConstants.SceneModeResizeItem elif self.imageLayerAction.isChecked(): lLayerMode = CDConstants.SceneModeImageLayer elif self.imageSequenceAction.isChecked(): lLayerMode = CDConstants.SceneModeImageSequence # elif self.editClusterAction.isChecked(): # lLayerMode = CDConstants.SceneModeEditCluster if lLayerMode != self.selectedSceneMode: self.selectedSceneMode = lLayerMode CDConstants.printOut("CDModeSelectToolBar - handleLayerActionGroupTriggered(), the layer mode is = " +str(self.selectedSceneMode), CDConstants.DebugVerbose) # propagate the signal upstream, for example to parent objects: self.signalModeSelectToolbarChanged.emit(self.selectedSceneMode)
def startElement(self, namespaceURI, localName, qName, attributes): CDConstants.printOut( "___ - DEBUG ----- CDConstants: startElement( namespaceURI==" + str(namespaceURI) + ", localName==" + str(localName) + ", qName==" + str(qName) + ", attributes==" + str(attributes) + " )", CDConstants.DebugExcessive) if not self.metCc3sTag and qName != CDConstants.SceneBundleFileExtension: self.errorStr = "The file is not a cc3s file." return False # check that the XML is of the type of document we want: if qName == CDConstants.SceneBundleFileExtension: version = attributes.value('version') if version and version != '1.0': self.errorStr = "The file is not a cc3s version 1.0 file." return False self.metCc3sTag = True elif qName == 'ResDir': self.item = self.createChildItem(qName) self.item.setFlags(self.item.flags() | QtCore.Qt.ItemIsEditable) self.item.setIcon(0, self.folderIcon) self.item.setText(0, "DirName") self.item.setText(1, attributes.value("DirName")) # assign the resources directory name: self.theParentWindget.theResDir = str(attributes.value("DirName")) self.treeWidget.setItemExpanded(self.item, True) elif qName == 'PIFScene': self.item = self.createChildItem(qName) self.item.setFlags(self.item.flags() | QtCore.Qt.ItemIsEditable) self.item.setIcon(0, self.bookmarkIcon) self.item.setText(0, attributes.value("Type")) self.item.setText(1, "Unknown Filename") elif qName == 'PIFF': self.item = self.createChildItem(qName) self.item.setFlags(self.item.flags() | QtCore.Qt.ItemIsEditable) self.item.setIcon(0, self.bookmarkIcon) self.item.setText(0, attributes.value("Type")) self.item.setText(1, "Unknown Filename") # elif qName == 'separator': # self.item = self.createChildItem(qName) # self.item.setFlags(self.item.flags() & ~QtCore.Qt.ItemIsSelectable) # self.item.setText(0, 30 * "\xb7") self.currentText = '' return True
def handleButtonGroupForPIFFGenerationClicked(self, pChecked): if self.fixedRasterButton.isChecked(): lPIFFGenerationMode = CDConstants.PIFFSaveWithFixedRaster # fixed raster PIFF Generation button: rasterWidthSpinBox = QtGui.QSpinBox() rasterWidthSpinBox.setMinimum(4) rasterWidthSpinBox.setValue(self.thePIFFFixedRasterWidth) lStringForToolTip = "PIFF Generation - Fixed Raster Width\n sets all PIFF cell regions\n to be made of same-sized square cells." rasterWidthSpinBox.setToolTip(lStringForToolTip) rasterWidthSpinBox.setStatusTip( "PIFF Generation: save all cells in all regions as squares on a fixed raster" ) # call setFixedRasterWidth() every time the rasterWidthSpinBox changes its value: rasterWidthSpinBox.valueChanged[int].connect( self.setFixedRasterWidth) lPopUpWindow = QtGui.QDialog(self) lPopUpWindow.setLayout(QtGui.QHBoxLayout()) lPopUpWindow.layout().addWidget( QtGui.QLabel("Fixed Raster Width:")) lPopUpWindow.layout().addWidget(rasterWidthSpinBox) lPopUpWindow.setWindowFlags(QtCore.Qt.Tool | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.CustomizeWindowHint) lPopUpWindow.setAttribute(QtCore.Qt.WindowModal | \ QtCore.Qt.WA_MacNoClickThrough | \ QtCore.Qt.WA_MacVariableSize ) lPopUpWindow.setMinimumSize(256, 64) lPopUpWindow.show() elif self.oneRasterPerRegionButton.isChecked(): lPIFFGenerationMode = CDConstants.PIFFSaveWithOneRasterPerRegion elif self.usePottsForPIFFButton.isChecked(): lPIFFGenerationMode = CDConstants.PIFFSaveWithPotts if lPIFFGenerationMode != self.thePIFFGenerationMode: self.thePIFFGenerationMode = lPIFFGenerationMode CDConstants.printOut( "the PIFF generation mode is now = " + str(self.thePIFFGenerationMode), CDConstants.DebugTODO) # propagate the signal upstream, for example to parent objects: self.signalPIFFGenerationModeHasChanged.emit( \ self.thePIFFGenerationMode, self.thePIFFFixedRasterWidth)
def openSceneBundleFile(self, pPathToSceneBundleMainFile=None): if (pPathToSceneBundleMainFile == None) or (not (os.path.isfile(pPathToSceneBundleMainFile))): CDConstants.printOut( "___ - DEBUG ----- CDSceneBundle: openSceneBundleFile() can not find " + str(pPathToSceneBundleMainFile) + " path.", CDConstants.DebugSparse) return else: self.treeWidget.clear() lXMLHandler = CC3SHandler(self) lXMLReader = QtXml.QXmlSimpleReader() lXMLReader.setContentHandler(lXMLHandler) lXMLReader.setErrorHandler(lXMLHandler) lFile = QtCore.QFile(pPathToSceneBundleMainFile) if not lFile.open(QtCore.QFile.ReadOnly | QtCore.QFile.Text): QtGui.QMessageBox.warning( self, "CC3D Scene Bundle", "Cannot read file %s:\n%s." % (pPathToSceneBundleMainFile, lFile.errorString())) return False xmlInputSource = QtXml.QXmlInputSource(lFile) if lXMLReader.parse(xmlInputSource): self.thePathToSceneBundleDir, self.theSceneBundleMainFileName = os.path.split( str(pPathToSceneBundleMainFile)) CDConstants.printOut( "___ - DEBUG ----- CDSceneBundle: openSceneBundleFile() parsed file "+ \ str(pPathToSceneBundleMainFile) + " self.thePathToSceneBundleDir==" + \ self.thePathToSceneBundleDir + " self.theSceneBundleMainFileName==" + \ self.theSceneBundleMainFileName , CDConstants.DebugAll ) # parsing went fine, show the user what we got: self.show() self.treeWidget.clearFocus() return True else: QtGui.QMessageBox.warning( self, "CC3D Scene Bundle", "Cannot parse file %s" % pPathToSceneBundleMainFile) return False
def handleLayerActionGroupTriggered(self, pChecked): if self.pointerAction.isChecked(): lLayerMode = CDConstants.SceneModeMoveItem elif self.resizeAction.isChecked(): lLayerMode = CDConstants.SceneModeResizeItem elif self.imageLayerAction.isChecked(): lLayerMode = CDConstants.SceneModeImageLayer elif self.imageSequenceAction.isChecked(): lLayerMode = CDConstants.SceneModeImageSequence # elif self.editClusterAction.isChecked(): # lLayerMode = CDConstants.SceneModeEditCluster if lLayerMode != self.selectedSceneMode: self.selectedSceneMode = lLayerMode CDConstants.printOut( "CDModeSelectToolBar - handleLayerActionGroupTriggered(), the layer mode is = " + str(self.selectedSceneMode), CDConstants.DebugVerbose) # propagate the signal upstream, for example to parent objects: self.signalModeSelectToolbarChanged.emit(self.selectedSceneMode)
def handleLayerButtonGroupClicked(self, pChecked): if self.pointerButton.isChecked(): lLayerMode = CDConstants.SceneModeMoveItem elif self.resizeButton.isChecked(): lLayerMode = CDConstants.SceneModeResizeItem elif self.imageLayerButton.isChecked(): lLayerMode = CDConstants.SceneModeImageLayer elif self.imageSequenceButton.isChecked(): lLayerMode = CDConstants.SceneModeImageSequence elif self.editClusterButton.isChecked(): lLayerMode = CDConstants.SceneModeEditCluster if lLayerMode != self.theLayerMode: self.theLayerMode = lLayerMode CDConstants.printOut( "CDControlLayerSelection - handleLayerButtonGroupClicked(), the layer mode is = " + str(self.theLayerMode), CDConstants.DebugVerbose) # propagate the signal upstream, for example to parent objects: self.signalLayersSelectionModeHasChanged.emit(self.theLayerMode)
def __init__(self, pTitle="CellDraw: processing.", pLabelText=" ", pMaxValue=100, pParent=None): # it is compulsory to call the parent's __init__ class right away: super(CDWaitProgressBar, self).__init__(pParent) # print "CDWaitProgressBar.__init__()" # the progress bar widget is defined in __createProgressBar() below: self.__progressBar = None self.__theTitle = pTitle self.__theLabelText = pLabelText self.__maxValue = pMaxValue self.__theParent = pParent # if we needed an image in the progress bar, we'd now: # self.__imageLabel, self.__waitProgressBarGroupBox = self.__InitCentralWidget(self.__theTitle) self.__waitProgressBarGroupBox = self.__InitCentralWidget(self.__theTitle) # # set up a widget with a QProgressBar, show it inside the QWidget: # lFont = QtGui.QFont() lFont.setWeight(QtGui.QFont.Light) self.setFont(lFont) self.setLayout(QtGui.QHBoxLayout()) self.layout().setMargin(0) self.layout().setSpacing(0) self.layout().setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) self.setWindowTitle("CellDraw: processing windowTitle.") self.setStatusTip(QtCore.QString(self.__theTitle)) self.setToolTip(QtCore.QString(self.__theTitle)) # do not delete the window widget when the window is closed: self.setAttribute(QtCore.Qt.WA_DeleteOnClose, False) # if we needed an image in the progress bar, we'd now: # self.layout().addWidget(self.__imageLabel) self.layout().addWidget(self.__waitProgressBarGroupBox) CDConstants.printOut( " "+str( "--- - DEBUG ----- CDWaitProgressBar: __init__(): done" )+" ", CDConstants.DebugTODO )
def startElement(self, namespaceURI, localName, qName, attributes): CDConstants.printOut( "___ - DEBUG ----- CDConstants: startElement( namespaceURI=="+str(namespaceURI)+", localName=="+str(localName)+", qName=="+str(qName)+", attributes=="+str(attributes)+" )" , CDConstants.DebugExcessive ) if not self.metCc3sTag and qName != CDConstants.SceneBundleFileExtension: self.errorStr = "The file is not a cc3s file." return False # check that the XML is of the type of document we want: if qName == CDConstants.SceneBundleFileExtension: version = attributes.value('version') if version and version != '1.0': self.errorStr = "The file is not a cc3s version 1.0 file." return False self.metCc3sTag = True elif qName == 'ResDir': self.item = self.createChildItem(qName) self.item.setFlags(self.item.flags() | QtCore.Qt.ItemIsEditable) self.item.setIcon(0, self.folderIcon) self.item.setText(0, "DirName") self.item.setText(1, attributes.value("DirName")) # assign the resources directory name: self.theParentWindget.theResDir = str(attributes.value("DirName")) self.treeWidget.setItemExpanded(self.item, True) elif qName == 'PIFScene': self.item = self.createChildItem(qName) self.item.setFlags(self.item.flags() | QtCore.Qt.ItemIsEditable) self.item.setIcon(0, self.bookmarkIcon) self.item.setText(0, attributes.value("Type")) self.item.setText(1, "Unknown Filename") elif qName == 'PIFF': self.item = self.createChildItem(qName) self.item.setFlags(self.item.flags() | QtCore.Qt.ItemIsEditable) self.item.setIcon(0, self.bookmarkIcon) self.item.setText(0, attributes.value("Type")) self.item.setText(1, "Unknown Filename") # elif qName == 'separator': # self.item = self.createChildItem(qName) # self.item.setFlags(self.item.flags() & ~QtCore.Qt.ItemIsSelectable) # self.item.setText(0, 30 * "\xb7") self.currentText = '' return True
def getCellColorsDict(self): # regionUseDict = a dict of all cell colors, # one for each RGBA color: [name,#regions](color) self.regionUseDict = {} lRowCount = self.typeColorTable.rowCount() CDConstants.printOut( "-=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=-" , CDConstants.DebugAll ) CDConstants.printOut("self.typeColorTable = "+str(self.typeColorTable),CDConstants.DebugAll) CDConstants.printOut("self.typeColorTable.rowCount() = "+str(self.typeColorTable.rowCount()),CDConstants.DebugAll) for i in range(lRowCount): # get the QString at item (i, 0) and place it into a str(): lCellID = str( self.typeColorTable.item(i, 0).text() ) # get the QColor from the QBrush at item (i, 1) and place it into an int: lCellColor = self.typeColorTable.item(i, 1).background().color().rgba() self.regionUseDict[lCellID] = lCellColor CDConstants.printOut("i="+str(i)+" self.regionUseDict[lCellID=="+str(lCellID)+"] = lCellColor=="+str(lCellColor),CDConstants.DebugAll) CDConstants.printOut( "-=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=-" , CDConstants.DebugAll ) return self.regionUseDict
def addActionToColorGroupBox(self, pGroupBox, pAction, pIsDefault=False): lToolButton = QtGui.QToolButton(self) lToolButton.setDefaultAction(pAction) lToolButton.setCheckable(pAction.isCheckable()) if (pIsDefault == True): lToolButton.setChecked(True) else: lToolButton.setChecked(False) lToolButton.setIcon(pAction.icon()) lToolButton.setIconSize(QtCore.QSize(16, 16)) lToolButton.setToolTip(pAction.toolTip()) lToolButton.setStatusTip(pAction.toolTip() + " Cell Type") lToolButton.clearFocus() pGroupBox.layout().addWidget(lToolButton) # also add to global dict of buttons, with their color names as keys: self.theColorButtonDict[str(pAction.text())] = lToolButton CDConstants.printOut( "pAction.text() = "+str(pAction.text()) , CDConstants.DebugTODO ) CDConstants.printOut( "self.theColorButtonDict = "+str(self.theColorButtonDict) , CDConstants.DebugTODO )
def handleButtonGroupForPIFFGenerationClicked(self, pChecked): if self.fixedRasterButton.isChecked(): lPIFFGenerationMode = CDConstants.PIFFSaveWithFixedRaster self.placeHolderForFixedRasterSize.show() elif self.oneRasterPerRegionButton.isChecked(): lPIFFGenerationMode = CDConstants.PIFFSaveWithOneRasterPerRegion self.placeHolderForFixedRasterSize.hide() elif self.usePottsForPIFFButton.isChecked(): lPIFFGenerationMode = CDConstants.PIFFSaveWithPotts self.placeHolderForFixedRasterSize.hide() if lPIFFGenerationMode != self.thePIFFGenerationMode: self.thePIFFGenerationMode = lPIFFGenerationMode CDConstants.printOut( "the PIFF generation mode is now = " + str(self.thePIFFGenerationMode), CDConstants.DebugTODO ) # propagate the signal upstream, for example to parent objects: self.signalPIFFGenerationModeHasChanged.emit(self.thePIFFGenerationMode, self.thePIFFFixedRasterWidth)
def handleCellTypeColorClicked(self): # get data from the triggered action: self.clickedCellTypeAction = self.sender() CDConstants.printOut( "handleCellTypeColorClicked() .... self.clickedCellTypeAction = "+str(self.clickedCellTypeAction) , CDConstants.DebugTODO ) CDConstants.printOut( "handleCellTypeColorClicked() .... dir(self.clickedCellTypeAction) = "+str(dir(self.clickedCellTypeAction)) , CDConstants.DebugTODO ) # the data received from the action is a QVariant, can be converted to QColor: self.chosenCellTypeColor = QtGui.QColor(self.clickedCellTypeAction.data()) CDConstants.printOut( "handleCellTypeColorClicked() .... self.chosenCellTypeColor = "+str(self.chosenCellTypeColor) , CDConstants.DebugTODO ) for lKey in self.theColorButtonDict: lButton = self.theColorButtonDict[lKey] lButton.setChecked(False) lButton.setFocus(False) for lColor, lName in zip(CDConstants.TypesColors, CDConstants.TypesColorNames): # CDConstants.printOut( "lColor ="+str(lColor)+" lName ="+str(lName) , CDConstants.DebugTODO ) if ( QtGui.QColor(lColor).rgba() == self.chosenCellTypeColor.rgba()): lButton = self.theColorButtonDict[str(lName)] lButton.setChecked(True) lButton.setFocus(True) # CDConstants.printOut( "self.chosenCellTypeColor is now == "+str(self.chosenCellTypeColor)+ " not "+str(QtGui.QColor(self.chosenCellTypeColor)) , CDConstants.DebugTODO ) # self.fillColorToolButton.setIcon( \ # self.createFloodFillToolButtonIcon(':/icons/floodfill.png', \ # QtGui.QColor(self.chosenCellTypeColor) ) ) # self.fillColorToolButton.setIconSize(QtCore.QSize(24, 24)) # propagate the signal upstream, for example to parent objects: self.signalSetCurrentTypeColor.emit( QtGui.QColor(self.chosenCellTypeColor) )
def endElement(self, namespaceURI, localName, qName): CDConstants.printOut( "___ - DEBUG ----- CDConstants: endElement( namespaceURI=="+str(namespaceURI)+", localName=="+str(localName)+", qName=="+str(qName)+" ), self.currentText=="+str(self.currentText) , CDConstants.DebugExcessive ) # if qName == 'title': # if self.item: # self.item.setText(0, self.currentText) if qName == "PIFScene": if self.item: self.item.setText(1, str(self.currentText)) # we got the filename for the Scene file: self.theParentWindget.thePIFSceneFileName = str(self.currentText) self.item = self.item.parent() elif qName == "PIFF": if self.item: self.item.setText(1, str(self.currentText)) # we got the filename for the PIFF file: self.theParentWindget.thePIFFFileName = str(self.currentText) self.item = self.item.parent() elif qName == "ResDir": self.item = self.item.parent() return True
def handleButtonGroupForPIFFGenerationClicked(self, pChecked): if self.fixedRasterButton.isChecked(): lPIFFGenerationMode = CDConstants.PIFFSaveWithFixedRaster self.placeHolderForFixedRasterSize.show() elif self.oneRasterPerRegionButton.isChecked(): lPIFFGenerationMode = CDConstants.PIFFSaveWithOneRasterPerRegion self.placeHolderForFixedRasterSize.hide() elif self.usePottsForPIFFButton.isChecked(): lPIFFGenerationMode = CDConstants.PIFFSaveWithPotts self.placeHolderForFixedRasterSize.hide() if lPIFFGenerationMode != self.thePIFFGenerationMode: self.thePIFFGenerationMode = lPIFFGenerationMode CDConstants.printOut( "the PIFF generation mode is now = " + str(self.thePIFFGenerationMode), CDConstants.DebugTODO) # propagate the signal upstream, for example to parent objects: self.signalPIFFGenerationModeHasChanged.emit( \ self.thePIFFGenerationMode, self.thePIFFFixedRasterWidth)
def handleButtonGroupForPIFFGenerationClicked(self, pChecked): if self.fixedRasterButton.isChecked(): lPIFFGenerationMode = CDConstants.PIFFSaveWithFixedRaster # fixed raster PIFF Generation button: rasterWidthSpinBox = QtGui.QSpinBox() rasterWidthSpinBox.setMinimum(4) rasterWidthSpinBox.setValue(self.thePIFFFixedRasterWidth) lStringForToolTip = "PIFF Generation - Fixed Raster Width\n sets all PIFF cell regions\n to be made of same-sized square cells." rasterWidthSpinBox.setToolTip(lStringForToolTip) rasterWidthSpinBox.setStatusTip("PIFF Generation: save all cells in all regions as squares on a fixed raster") # call setFixedRasterWidth() every time the rasterWidthSpinBox changes its value: rasterWidthSpinBox.valueChanged[int].connect(self.setFixedRasterWidth) lPopUpWindow = QtGui.QDialog(self) lPopUpWindow.setLayout(QtGui.QHBoxLayout()) lPopUpWindow.layout().addWidget(QtGui.QLabel("Fixed Raster Width:")) lPopUpWindow.layout().addWidget(rasterWidthSpinBox) lPopUpWindow.setWindowFlags(QtCore.Qt.Tool | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.CustomizeWindowHint) lPopUpWindow.setAttribute(QtCore.Qt.WindowModal | \ QtCore.Qt.WA_MacNoClickThrough | \ QtCore.Qt.WA_MacVariableSize ) lPopUpWindow.setMinimumSize(256, 64) lPopUpWindow.show() elif self.oneRasterPerRegionButton.isChecked(): lPIFFGenerationMode = CDConstants.PIFFSaveWithOneRasterPerRegion elif self.usePottsForPIFFButton.isChecked(): lPIFFGenerationMode = CDConstants.PIFFSaveWithPotts if lPIFFGenerationMode != self.thePIFFGenerationMode: self.thePIFFGenerationMode = lPIFFGenerationMode CDConstants.printOut("the PIFF generation mode is now = "+str(self.thePIFFGenerationMode), CDConstants.DebugTODO ) # propagate the signal upstream, for example to parent objects: self.signalPIFFGenerationModeHasChanged.emit( \ self.thePIFFGenerationMode, self.thePIFFFixedRasterWidth)
def openSceneBundleFile(self, pPathToSceneBundleMainFile=None): if (pPathToSceneBundleMainFile == None) or (not (os.path.isfile(pPathToSceneBundleMainFile))): CDConstants.printOut( "___ - DEBUG ----- CDSceneBundle: openSceneBundleFile() can not find "+str(pPathToSceneBundleMainFile)+" path." , CDConstants.DebugSparse ) return else: self.treeWidget.clear() lXMLHandler = CC3SHandler(self) lXMLReader = QtXml.QXmlSimpleReader() lXMLReader.setContentHandler(lXMLHandler) lXMLReader.setErrorHandler(lXMLHandler) lFile = QtCore.QFile(pPathToSceneBundleMainFile) if not lFile.open(QtCore.QFile.ReadOnly | QtCore.QFile.Text): QtGui.QMessageBox.warning(self, "CC3D Scene Bundle", "Cannot read file %s:\n%s." % (pPathToSceneBundleMainFile, lFile.errorString())) return False xmlInputSource = QtXml.QXmlInputSource(lFile) if lXMLReader.parse(xmlInputSource): self.thePathToSceneBundleDir,self.theSceneBundleMainFileName = os.path.split(str(pPathToSceneBundleMainFile)) CDConstants.printOut( "___ - DEBUG ----- CDSceneBundle: openSceneBundleFile() parsed file "+ \ str(pPathToSceneBundleMainFile) + " self.thePathToSceneBundleDir==" + \ self.thePathToSceneBundleDir + " self.theSceneBundleMainFileName==" + \ self.theSceneBundleMainFileName , CDConstants.DebugAll ) # parsing went fine, show the user what we got: self.show() self.treeWidget.clearFocus() return True else: QtGui.QMessageBox.warning(self, "CC3D Scene Bundle", "Cannot parse file %s" % pPathToSceneBundleMainFile) return False
def addActionToColorGroupBox(self, pGroupBox, pAction, pIsDefault=False): lToolButton = QtGui.QToolButton(self) lToolButton.setDefaultAction(pAction) lToolButton.setCheckable(pAction.isCheckable()) if (pIsDefault == True): lToolButton.setChecked(True) else: lToolButton.setChecked(False) lToolButton.setIcon(pAction.icon()) lToolButton.setIconSize(QtCore.QSize(16, 16)) lToolButton.setToolTip(pAction.toolTip()) lToolButton.setStatusTip(pAction.toolTip() + " Cell Type") lToolButton.clearFocus() pGroupBox.layout().addWidget(lToolButton) # also add to global dict of buttons, with their color names as keys: self.theColorButtonDict[str(pAction.text())] = lToolButton CDConstants.printOut("pAction.text() = " + str(pAction.text()), CDConstants.DebugTODO) CDConstants.printOut( "self.theColorButtonDict = " + str(self.theColorButtonDict), CDConstants.DebugTODO)
def handleRadioButtonClick(self, pChecked): if self.pickCellDrawingButton.isChecked(): lWhatToDraw = CDConstants.ItsaCellConst CDConstants.printOut("CDControlRegionOrCell handleRadioButtonClick() -- ItsaCellConst, lWhatToDraw is now =="+str(lWhatToDraw), CDConstants.DebugTODO ) elif self.pickRegionDrawingButton.isChecked(): lWhatToDraw = CDConstants.ItsaRegionConst CDConstants.printOut("CDControlRegionOrCell handleRadioButtonClick() -- ItsaRegionConst, lWhatToDraw is now == "+str(lWhatToDraw), CDConstants.DebugTODO ) self.drawRegionOrCell = lWhatToDraw CDConstants.printOut("CDControlRegionOrCell handleRadioButtonClick() -- now drawing regions or cells == "+str(self.drawRegionOrCell), CDConstants.DebugTODO ) # propagate the signal upstream, for example to parent objects: self.signalSetRegionOrCell.emit(self.drawRegionOrCell)
def handleRadioButtonClick(self, pChecked): if self.pickCellDrawingButton.isChecked(): lWhatToDraw = CDConstants.ItsaCellConst CDConstants.printOut( "CDControlRegionOrCell handleRadioButtonClick() -- ItsaCellConst, lWhatToDraw is now ==" + str(lWhatToDraw), CDConstants.DebugTODO) elif self.pickRegionDrawingButton.isChecked(): lWhatToDraw = CDConstants.ItsaRegionConst CDConstants.printOut( "CDControlRegionOrCell handleRadioButtonClick() -- ItsaRegionConst, lWhatToDraw is now == " + str(lWhatToDraw), CDConstants.DebugTODO) self.drawRegionOrCell = lWhatToDraw CDConstants.printOut( "CDControlRegionOrCell handleRadioButtonClick() -- now drawing regions or cells == " + str(self.drawRegionOrCell), CDConstants.DebugTODO) # propagate the signal upstream, for example to parent objects: self.signalSetRegionOrCell.emit(self.drawRegionOrCell)
def __init__(self,pParent): # we don't use the pParent parameter to pass it to QObject, # but directly as parent object for all the QToolBar objects instantiated here: super(CDToolBars, self).__init__(None) self.mainWindow = pParent # # # demo toolbar object: # lOneToolbar = QtGui.QToolBar("QToolBar | OneToolbar") # CDConstants.printOut( "----- CDToolBars.__init__() - lOneToolbar = "+str(lOneToolbar), CDConstants.DebugExcessive ) # # set all icons in this QToolBar to be of the same size: # lOneToolbar.setIconSize(QtCore.QSize(24, 24)) # lOneToolbar.setObjectName("setObjectName OneToolbar") # lOneToolbar.setToolTip("setToolTip OneToolbar") # lOneToolbar.addWidget(QtGui.QLabel("*")) # lOneToolbar.addWidget(QtGui.QLabel(" ")) # lOneToolbar.addWidget(QtGui.QLabel("_")) # lPrintOut = self.mainWindow.addToolBar(QtCore.Qt.TopToolBarArea, lOneToolbar) # CDConstants.printOut( "----- CDToolBars.__init__() - self.mainWindow.addToolBar(QtCore.Qt.TopToolBarArea, lOneToolbar) = "+str(lPrintOut), CDConstants.DebugExcessive ) # # addToolBarBreak() places the next toolbar in the same toolbar area in a "new line" # # print self.mainWindow.addToolBarBreak(QtCore.Qt.TopToolBarArea) # # ---------- # 2011 - Mitja: to control the "layer selection" for Cell Scene mode, # we add a set of radio-buttons: self.__theModeSelectToolBar = CDControlModeSelectToolBar("CellDraw | Main Mode ToolBar") self.__theModeSelectToolBar.setObjectName("theModeSelectToolBar") lPrintOut = self.mainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.__theModeSelectToolBar) CDConstants.printOut( "----- CDToolBars.__init__() - self.mainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.__theModeSelectToolBar) = "+str(lPrintOut), CDConstants.DebugExcessive ) # print self.mainWindow.addToolBarBreak(QtCore.Qt.TopToolBarArea) # ---------- # 2012 - Mitja: to control the "scene zoom" factor, # we add a "combo box": self.__theSceneZoomToolbar = CDControlSceneZoomToolbar("CellDraw | Scene Zoom ToolBar") self.__theSceneZoomToolbar.setObjectName("theSceneZoomToolbar") lPrintOut = self.mainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.__theSceneZoomToolbar) CDConstants.printOut( "----- CDToolBars.__init__() - self.mainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.__theSceneZoomToolbar) = "+str(lPrintOut), CDConstants.DebugExcessive ) # print self.mainWindow.addToolBarBreak(QtCore.Qt.TopToolBarArea) CDConstants.printOut( "----- CDToolBars.__init__(pParent=="+str(pParent)+") done. -----", CDConstants.DebugExcessive )
def setMaxImageIndex(self, pValueInt): self.imageSelectionSlider.setMaximum(pValueInt) self.imageSelectionSlider.update() CDConstants.printOut("CDControlClusters - setMaxImageIndex( " +str(pValueInt)+" )", CDConstants.DebugVerbose)
def populateControlPanel(self): # ---------------------------------------------------------------- # # QWidget setup (2) - prepare Scene Layer controls: # # # # ---------------------------------------------------------------- # # # # QWidget setup (2a) - add controls for scene zoom: # # # lFirstSimpleQHBoxLayout = QtGui.QHBoxLayout() # lFirstSimpleQHBoxLayout.setMargin(2) # lFirstSimpleQHBoxLayout.setSpacing(4) # lFirstSimpleQHBoxLayout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) # # # 2012 - Mitja: the layer selection controls have been moved to a QToolBar: # # but we keep them here until we decouple actions/signals/slots/handlers: # # # # the layer selection control is defined in its own class: # # # # lFirstSimpleQHBoxLayout.addWidget(self.controlsForLayerSelection) # # # the combobox/pop-up menu for scene zoom control is defined in its own class: # # # lFirstSimpleQHBoxLayout.addWidget(self.controlsForSceneZoom) # # self.mainControlCellSceneLayout.addLayout(lFirstSimpleQHBoxLayout) # # # ---------------------------------------------------------------- # # QWidget setup (2a) - add controls for Item editing in the Scene: # # ---------------------------------------------------------------- # # QWidget setup (2a) - add a QGroupBox containing buttons with # scene item edit controls, such as cut/copy/paste/delete etc. # # this is the "Item Edit" QGroupBox, defined in TODO TODO WHERE? .py file? : # self.mainControlCellSceneLayout.addWidget(self.controlsForSceneItemEdit) # ---------------------------------------------------------------- # # QWidget setup (2b) - add a QGroupBox for adding new Items to the Scene: # self.sceneItemLayerGroupBox = QtGui.QGroupBox("New Item") # self.sceneItemLayerGroupBox.setPalette(QtGui.QPalette(QtGui.QColor(222,222,222))) # self.sceneItemLayerGroupBox.setAutoFillBackground(True) self.sceneItemLayerGroupBox.setLayout(QtGui.QVBoxLayout()) self.sceneItemLayerGroupBox.layout().setMargin(2) self.sceneItemLayerGroupBox.layout().setSpacing(4) self.sceneItemLayerGroupBox.layout().setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) lFont = QtGui.QFont() lFont.setWeight(QtGui.QFont.Light) sceneItemLayerLayout = QtGui.QHBoxLayout() sceneItemLayerLayout.setMargin(2) sceneItemLayerLayout.setSpacing(4) sceneItemLayerLayout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) # CDConstants.printOut( " "+str( "___ - DEBUG ----- CDControlCellScene: 1" )+" ", CDConstants.DebugTODO ) sceneItemLayerLayout.addWidget(self.createRegionShapeButton("Ellipse", CDControlCellScene.PathConst)) # CDConstants.printOut( " "+str( "___ - DEBUG ----- CDControlCellScene: 2" )+" ", CDConstants.DebugTODO ) sceneItemLayerLayout.addWidget(self.createRegionShapeButton("Rectangle", CDControlCellScene.RectangleConst)) # CDConstants.printOut( " "+str( "___ - DEBUG ----- CDControlCellScene: empty" )+" ", CDConstants.DebugTODO ) sceneItemLayerLayout.addSpacing(40) # CDConstants.printOut( " "+str( "___ - DEBUG ----- CDControlCellScene: 3" )+" ", CDConstants.DebugTODO ) sceneItemLayerLayout.addWidget(self.createRegionShapeButton("TenByTenBox", CDControlCellScene.TenByTenBoxConst)) # CDConstants.printOut( " "+str( "___ - DEBUG ----- CDControlCellScene: 4" )+" ", CDConstants.DebugTODO ) sceneItemLayerLayout.addWidget(self.createRegionShapeButton("TwoByTwoBox", CDControlCellScene.TwoByTwoBoxConst)) self.sceneItemLayerGroupBox.layout().addLayout(sceneItemLayerLayout) sceneXSignLabel = QtGui.QLabel() sceneXSignLabel.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) sceneXSignLabel.setText("x:") sceneXSignLabel.setFont(lFont) sceneXSignLabel.setMargin(2) sceneYSignLabel = QtGui.QLabel() sceneYSignLabel.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) sceneYSignLabel.setText(" y:") sceneYSignLabel.setFont(lFont) sceneYSignLabel.setMargin(2) sceneWidthSignLabel = QtGui.QLabel() sceneWidthSignLabel.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) sceneWidthSignLabel.setText(" w:") sceneWidthSignLabel.setMargin(2) sceneWidthSignLabel.setFont(lFont) sceneHeightSignLabel = QtGui.QLabel() sceneHeightSignLabel.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) sceneHeightSignLabel.setText(" h:") sceneHeightSignLabel.setMargin(2) sceneHeightSignLabel.setFont(lFont) self.resizingItemXLabel = QtGui.QLabel() self.resizingItemXLabel.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) self.resizingItemXLabel.setText(" ") self.resizingItemXLabel.setMargin(2) self.resizingItemXLabel.setFont(lFont) self.resizingItemYLabel = QtGui.QLabel() self.resizingItemYLabel.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) self.resizingItemYLabel.setText(" ") self.resizingItemYLabel.setMargin(2) self.resizingItemYLabel.setFont(lFont) self.resizingItemWidthLabel = QtGui.QLabel() self.resizingItemWidthLabel.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) self.resizingItemWidthLabel.setText(" ") self.resizingItemWidthLabel.setMargin(2) self.resizingItemWidthLabel.setFont(lFont) self.resizingItemHeightLabel = QtGui.QLabel() self.resizingItemHeightLabel.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) self.resizingItemHeightLabel.setText(" ") self.resizingItemHeightLabel.setMargin(2) self.resizingItemHeightLabel.setFont(lFont) self.resizingItemLabelWidget = QtGui.QWidget() self.resizingItemLabelWidget.setLayout(QtGui.QHBoxLayout()) self.resizingItemLabelWidget.layout().setMargin(2) self.resizingItemLabelWidget.layout().setSpacing(4) self.resizingItemLabelWidget.setFont(lFont) self.resizingItemLabelWidget.layout().addWidget(sceneXSignLabel) self.resizingItemLabelWidget.layout().addWidget(self.resizingItemXLabel) self.resizingItemLabelWidget.layout().addWidget(sceneYSignLabel) self.resizingItemLabelWidget.layout().addWidget(self.resizingItemYLabel) self.resizingItemLabelWidget.layout().addWidget(sceneWidthSignLabel) self.resizingItemLabelWidget.layout().addWidget(self.resizingItemWidthLabel) self.resizingItemLabelWidget.layout().addWidget(sceneHeightSignLabel) self.resizingItemLabelWidget.layout().addWidget(self.resizingItemHeightLabel) self.sceneItemLayerGroupBox.layout().addWidget(self.resizingItemLabelWidget) self.mainControlCellSceneLayout.addWidget(self.sceneItemLayerGroupBox) # ---------------------------------------------------------------- # # QWidget setup (2c) - add controls for item types: # anotherSimpleQHBoxLayout = QtGui.QHBoxLayout() anotherSimpleQHBoxLayout.setMargin(2) anotherSimpleQHBoxLayout.setSpacing(4) anotherSimpleQHBoxLayout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) # the "regionOrCell" control is defined in its own class: # anotherSimpleQHBoxLayout.addWidget(self.controlsForDrawingRegionOrCell) # the controls for types of regions and cells are defined in its own class: # anotherSimpleQHBoxLayout.addWidget(self.controlsForTypes) # add both these two controls as hbox to the main controls layout: self.mainControlCellSceneLayout.addLayout(anotherSimpleQHBoxLayout) # ---------------------------------------------------------------- # # QWidget setup (2d) - add a QGroupBox for selecting Scene backrounds: # self.sceneBackgroundLayerGroupBox = QtGui.QGroupBox("Background") # self.sceneBackgroundLayerGroupBox.setPalette(QtGui.QPalette(QtGui.QColor(222,222,222))) # self.sceneBackgroundLayerGroupBox.setAutoFillBackground(True) self.sceneBackgroundLayerGroupBox.setLayout(QtGui.QVBoxLayout()) self.sceneBackgroundLayerGroupBox.layout().setMargin(2) self.sceneBackgroundLayerGroupBox.layout().setSpacing(4) self.sceneBackgroundLayerGroupBox.layout().setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.backgroundLayout = QtGui.QGridLayout() self.backgroundLayout.setMargin(2) self.backgroundLayout.setSpacing(4) self.backgroundLayout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.theBackgroundImageCellWidget = self.createBackgroundCellWidgetFromImage( \ self.imageNameFromFile, self.imageFromFile) self.backgroundLayout.addWidget(self.theBackgroundImageCellWidget, 0, 0) self.backgroundLayout.addWidget(self.createBackgroundCellWidget("No Grid", ':/icons/background4.png'), 0, 1) # self.backgroundLayout.addWidget(self.createBackgroundCellWidget("White Grid", # ':/icons/background2.png'), 0, 2) # self.backgroundLayout.addWidget(self.createBackgroundCellWidget("Gray Grid", # ':/icons/background3.png'), 0, 3) # self.backgroundLayout.addWidget(self.createBackgroundCellWidget("Blue Grid", # ':/icons/background1.png'), 0, 4) # 2011 - Mitja: make sure that one background button is checked: theBgButtons = self.buttonGroupForBackgrounds.buttons() for myButton in theBgButtons: CDConstants.printOut( "123123123123123 myButton="+str(myButton)+"myButton.text()="+str(myButton.text()), CDConstants.DebugTODO ) if myButton.text() == "No Grid": myButton.setChecked(True) self.sceneBackgroundLayerGroupBox.layout().addLayout(self.backgroundLayout) self.mainControlCellSceneLayout.addWidget(self.sceneBackgroundLayerGroupBox) # ---------------------------------------------------------------- # # QWidget setup (2e) - add a QGroupBox for showing Scene dimensions: # # this now goes to its own class: CDViewSceneDimensions() # ---------------------------------------------------------------- # # QWidget setup (2f) - add controls for scene zoom, and for # the types of regions and cells: # # ---------------------------------------------------------------- # # QWidget setup (6a) - add controls for Cell Clusters content: # labelHeaderFont = QtGui.QFont() labelHeaderFont.setStyleStrategy(QtGui.QFont.PreferAntialias | QtGui.QFont.PreferQuality) labelHeaderFont.setStyleHint(QtGui.QFont.SansSerif) labelHeaderFont.setWeight(QtGui.QFont.Bold) lClustersHeaderLabel = QtGui.QLabel("Cell Clusters") lClustersHeaderLabel.setFont(labelHeaderFont) lClustersHeaderLabel.setMargin(2) lClustersHeaderLabel.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) # this QGroupBox is defined in its own class: # lTheClustersTabLayout.addWidget(self.controlsForClusters) CDConstants.printOut("___ - DEBUG ----- CDControlCellScene: populateControlPanel(): done", CDConstants.DebugTODO )
def __init__(self, pParent = None): super(CDControlCellScene,self).__init__(pParent) # ----- ----- ----- ----- # declare object globals: # ----- ----- ----- ----- self.parentWindow = pParent # a QGroupBox containing buttons for toggling the layer selection # it's assigned below, in setControlsForLayerSelection() self.controlsForLayerSelection = 0 # # # a QGroupBox with a combobox (pop-up menu) for scene zoom # # it's assigned below, in setControlsForSceneZoom() # self.controlsForSceneZoom = 0 # a QGroupBox containing buttons for toggling the # drawing mode between regions and cells, # it's assigned below, in setControlsForDrawingRegionOrCellToggle() self.controlsForDrawingRegionOrCell = 0 # a QGroupBox containing buttons for types of regions and cells # it's assigned below, in setControlsForTypes() self.controlsForTypes = 0 # a QGroupBox containing buttons with scene item edit controls, # it's assigned below, in setControlsForSceneItemEdit() self.controlsForSceneItemEdit = 0 # the widgetDict dictionary object is local to this class and # contains references to icons: self.widgetDict = { \ CDControlCellScene.RectangleConst: QtGui.QIcon(), \ CDControlCellScene.TenByTenBoxConst: QtGui.QIcon(), \ CDControlCellScene.StartEndConst: QtGui.QIcon(), \ CDControlCellScene.TwoByTwoBoxConst: QtGui.QIcon(), \ CDControlCellScene.PathConst: QtGui.QIcon(), \ } # a QButtonGroup containing all buttons for region shapes, # it's assigned below, in setButtonGroupForRegionShapes() self.buttonGroupForRegionShapes = 0 # a QButtonGroup containing all buttons for backgrounds, # it's assigned below, in setButtonGroupForBackgrounds() self.buttonGroupForBackgrounds = 0 # a QGroupBox containing buttons and sliders for controlling # clusters of cells, it's assigned below, in setControlsForClusters() self.controlsForClusters = 0 # class globals for the background button from input image: # 2010 - Mitja: add code for new backgrounds: lBoringPixMap = QtGui.QPixmap(240, 180) lBoringPixMap.fill( QtGui.QColor(QtCore.Qt.white) ) self.imageFromFile = QtGui.QImage(lBoringPixMap) self.imageNameFromFile = "BlankBackground" # ----- ----- ----- ----- # declare object globals: # ----- ----- ----- ----- # # QWidget setup (1) - windowing GUI setup for Control Panel: # self.setWindowTitle("Control Panel Window Title") # QVBoxLayout layout lines up widgets vertically: self.mainControlCellSceneLayout = QtGui.QVBoxLayout() self.mainControlCellSceneLayout.setMargin(4) self.mainControlCellSceneLayout.setSpacing(4) self.mainControlCellSceneLayout.setAlignment( \ QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.setLayout(self.mainControlCellSceneLayout) # # QWidget setup (2) - more windowing GUI setup for Control Panel: # CDConstants.printOut( "___ - DEBUG ----- CDControlCellScene: __init__(): done" , CDConstants.DebugTODO )