Exemplo n.º 1
0
CustomQGraphicsView.py
.. module:: CustomQGraphicsView
   :platform: Unix, Windows, Mac OS X
   :synopsis: A Custom QGraphicsView module to allow focus input events
   like mouse clicks and panning and zooming

.. moduleauthor::  Nick Conway on 2011-01-17.
Copyright (c) 2010 . All rights reserved.

"""
from cadnano2.cadnano import app
from cadnano2.views import styles

import cadnano2.util as util
# import Qt stuff into the module namespace with PySide, PyQt4 independence
util.qtWrapImport('QtCore', globals(),
                  ['Qt', 'QTimer', 'pyqtSignal', 'QTimeLine'])
util.qtWrapImport('QtGui', globals(), ['QGuiApplication', 'QPaintEngine'])
util.qtWrapImport('QtWidgets', globals(), ['QGraphicsView', 'QGraphicsScene'])

# for OpenGL mode
try:
    # from OpenGL import GL
    from PyQt6.QtWidgets import QOpenGLWidget
except ImportError:
    GL = False

GL = False


class CustomQGraphicsView(QGraphicsView):
    """
Exemplo n.º 2
0
#!/usr/bin/env python
# encoding: utf-8

import cadnano2.util as util
from cadnano2.views import styles

from cadnano2.model.enum import StrandType

# import Qt stuff into the module namespace with PySide, PyQt4 independence
util.qtWrapImport('QtCore', globals(), ['QPointF', 'QRectF', 'Qt'])
util.qtWrapImport('QtGui', globals(), [
    'QBrush', 'QFont', 'QFontMetrics', 'QPainterPath', 'QPolygonF', 'QPen',
    'QUndoCommand'
])
util.qtWrapImport(
    'QtWidgets', globals(),
    ['QGraphicsPathItem', 'QGraphicsRectItem', 'QGraphicsSimpleTextItem'])


# construct paths for breakpoint handles
def _hashMarkGen(path, p1, p2, p3):
    path.moveTo(p1)
    path.lineTo(p2)
    path.lineTo(p3)


# end

# create hash marks QPainterPaths only once
_ppRect = QRectF(0, 0, styles.PATH_BASE_WIDTH, styles.PATH_BASE_WIDTH)
_pathCenter = QPointF(styles.PATH_BASE_WIDTH / 2,\
Exemplo n.º 3
0
#!/usr/bin/env python
# encoding: utf-8

from math import floor
from cadnano2.controllers.itemcontrollers.strand.stranditemcontroller import StrandItemController
from .endpointitem import EndpointItem
from cadnano2.views import styles
from .xoveritem import XoverItem
from .decorators.insertionitem import InsertionItem

import cadnano2.views.pathview.pathselection as pathselection

import cadnano2.util as util
# import Qt stuff into the module namespace with PySide, PyQt4 independence
util.qtWrapImport('QtCore', globals(),
                  ['pyqtSignal', 'QObject', 'Qt', 'QRectF'])
util.qtWrapImport('QtGui', globals(),
                  ['QBrush', 'QColor', 'QFont', 'QFontMetricsF', 'QPen'])
util.qtWrapImport('QtWidgets', globals(), [
    'QGraphicsLineItem', 'QGraphicsPathItem', 'QGraphicsItem',
    'QGraphicsSimpleTextItem', 'QGraphicsRectItem'
])

_baseWidth = styles.PATH_BASE_WIDTH
_defaultRect = QRectF(0, 0, _baseWidth, _baseWidth)
_noPen = QPen(Qt.PenStyle.NoPen)


class StrandItem(QGraphicsLineItem):
    _filterName = "strand"
Exemplo n.º 4
0
import cadnano2.util as util
# import Qt stuff into the module namespace with PySide, PyQt4 independence
util.qtWrapImport('QtCore', globals(), ['pyqtSignal', 'QObject'])
util.qtWrapImport('QtGui', globals(), ['QActionGroup'])


class SliceToolManager(QObject):
    """Manages interactions between the slice widgets/UI and the model."""
    def __init__(self, win):
        """
        We store mainWindow because a controller's got to have
        references to both the layer above (UI) and the layer below (model)
        """
        super(SliceToolManager, self).__init__()
        self._window = win
        self._connectWindowSignalsToSelf()

    ### SIGNALS ###
    activeSliceSetToFirstIndexSignal = pyqtSignal()
    activeSliceSetToLastIndexSignal = pyqtSignal()
    activePartRenumber = pyqtSignal()

    ### SLOTS ###
    def activeSliceFirstSlot(self):
        """
        Use a signal to notify the ActiveSliceHandle to move. A signal is used
        because the SliceToolManager must be instantiated first, and the
        ActiveSliceHandle can later subscribe.
        """
        part = self._window.selectedPart()
        if part != None:
Exemplo n.º 5
0
#!/usr/bin/env python
# encoding: utf-8

from operator import attrgetter
import cadnano2.util as util
from array import array

# import Qt stuff into the module namespace with PySide, PyQt4 independence
util.qtWrapImport('QtCore', globals(), ['QObject', 'Qt'])
util.qtWrapImport('QtGui', globals(), ['QUndoStack', 'QUndoCommand'])


class Decorator(object):
    """
    Decorators do not affect an applied sequence
    """
    def __init__(self, index):
        if self.__class__ == Decorator:
            e = "Decorator should be subclassed."
            raise NotImplementedError(e)
        self._index = idex
        self._dType = None
        self._privateSequence = None

    # end def

    def privateLength(self):
        """
        This is the length of a sequence that is immutable by the strand
        """
        return length(self._privateSequence)
Exemplo n.º 6
0
from cadnano2.controllers.viewrootcontroller import ViewRootController
from .partitem import PartItem
import cadnano2.util as util
util.qtWrapImport('QtCore', globals(), ['pyqtSignal', 'QObject'])
util.qtWrapImport('QtWidgets', globals(), ['QGraphicsRectItem'])


class SliceRootItem(QGraphicsRectItem):
    """
    PathRootItem is the root item in the PathView. It gets added directly
    to the pathscene by DocumentWindow. It receives two signals
    (partAddedSignal and selectedPartChangedSignal) via its ViewRootController.

    PathRootItem must instantiate its own controller to receive signals
    from the model.
    """
    def __init__(self, rect, parent, window, document):
        super(SliceRootItem, self).__init__(rect, parent)
        self._window = window
        self._document = document
        self._controller = ViewRootController(self, document)
        self._instanceItems = {}

    ### SIGNALS ###

    ### SLOTS ###
    def partAddedSlot(self, sender, modelPart):
        """
        Receives notification from the model that a part has been added.
        Views that subclass AbstractView should override this method.
        """
Exemplo n.º 7
0
from .abstractpathtool import AbstractPathTool
import cadnano2.util as util

util.qtWrapImport('QtCore', globals(), [])
util.qtWrapImport('QtGui', globals(), [])


class SelectTool(AbstractPathTool):
    """
    SelectTool is the default tool. It allows editing of breakpoints
    (by clicking and dragging) and toggling of crossovers.
    """
    def __init__(self, controller):
        super(SelectTool, self).__init__(controller)

    def __repr__(self):
        return "selectTool"  # first letter should be lowercase
Exemplo n.º 8
0
from math import floor
from .abstractpathtool import AbstractPathTool
from cadnano2.views import styles

import cadnano2.util as util
# import Qt stuff into the module namespace with PySide, PyQt4 independence
util.qtWrapImport('QtCore', globals(), ['Qt', 'QEvent', 'QPointF', 'QRectF'])
util.qtWrapImport('QtGui', globals(), [
    'QBrush', 'QColor', 'QFont', 'QFontMetrics', 'QPainterPath', 'QPolygonF',
    'QPen'
])
util.qtWrapImport('QtWidgets', globals(), [
    'QGraphicsItem', 'QGraphicsLineItem', 'QGraphicsPathItem',
    'QGraphicsRectItem', 'QGraphicsSimpleTextItem'
])

_baseWidth = styles.PATH_BASE_WIDTH
_pencilcolor = styles.redstroke
_defaultRect = QRectF(0, 0, _baseWidth, _baseWidth)
_noPen = QPen(Qt.PenStyle.NoPen)


class PencilTool(AbstractPathTool):
    """
    docstring for PencilTool
    """
    def __init__(self, controller):
        super(PencilTool, self).__init__(controller)
        self._tempXover = ForcedXoverItem(self, None, None)
        self._tempStrandItem = ForcedStrandItem(self, None)
        self._tempStrandItem.hide()
Exemplo n.º 9
0
import re
from .abstractpathtool import AbstractPathTool
from cadnano2.data.dnasequences import sequences
from cadnano2.ui.dialogs.ui_addseq import Ui_AddSeqDialog
from cadnano2.views import styles
import cadnano2.util as util

util.qtWrapImport('QtCore', globals(), [
    'Qt', 'QObject', 'QPointF', 'QRegularExpression', 'QSignalMapper',
    'pyqtSignal', 'pyqtSlot'
])
util.qtWrapImport('QtGui', globals(), [
    'QBrush', 'QColor', 'QFont', 'QPen', 'QSyntaxHighlighter',
    'QTextCharFormat'
])
util.qtWrapImport('QtWidgets', globals(), [
    'QDialog',
    'QDialogButtonBox',
    'QRadioButton',
])

dnapattern = QRegularExpression("([^ACGTacgt]+)")


class DNAHighlighter(QSyntaxHighlighter):
    def __init__(self, parent):
        QSyntaxHighlighter.__init__(self, parent)
        self.parent = parent
        self.format = QTextCharFormat()
        self.format.setBackground(QBrush(styles.INVALID_DNA_COLOR))
        if styles.UNDERLINE_INVALID_DNA:
Exemplo n.º 10
0
import io
import os
from ..cadnano import app
from ..model.document import Document
from ..model.io.decoder import decode
from ..model.io.encoder import encode
from ..views.documentwindow import DocumentWindow
from ..views import styles
import cadnano2.util as util
util.qtWrapImport('QtCore', globals(),
                  ['QDir', 'QFileInfo', 'QRect', 'QSettings', 'QSize', 'Qt'])
util.qtWrapImport('QtGui', globals(), ['QIcon', 'QKeySequence', 'QPainter'])
util.qtWrapImport('QtWidgets', globals(), [
    'QApplication', 'QDialog', 'QDockWidget', 'QFileDialog', 'QGraphicsItem',
    'QMainWindow', 'QMessageBox', 'QStyleOptionGraphicsItem'
])
util.qtWrapImport('QtSvg', globals(), ['QSvgGenerator'])


class DocumentController():
    """
    Connects UI buttons to their corresponding actions in the model.
    """

    ### INIT METHODS ###
    def __init__(self):
        """docstring for __init__"""
        # initialize variables
        self._document = Document()
        self._document.setController(self)
        self._activePart = None
Exemplo n.º 11
0
from cadnano2.views import styles
import cadnano2.util as util
util.qtWrapImport('QtCore', globals(), ['QRectF', 'Qt'])
util.qtWrapImport('QtGui', globals(), ['QBrush', 'QFont'])
util.qtWrapImport('QtWidgets', globals(),  ['QColorDialog',
                                            'QGraphicsItem',
                                            'QGraphicsSimpleTextItem'])

_font = QFont(styles.thefont, 12, QFont.Weight.Bold)


class ColorPanel(QGraphicsItem):
    _scafColors = styles.scafColors
    _stapColors = styles.stapColors
    _pen = Qt.PenStyle.NoPen

    def __init__(self, parent=None):
        super(ColorPanel, self).__init__(parent)
        self.rect = QRectF(0, 0, 30, 30)
        self.setFlag(QGraphicsItem.GraphicsItemFlag.ItemIgnoresTransformations)
        self.colordialog = QColorDialog()
        # self.colordialog.setOption(QColorDialog.DontUseNativeDialog)
        self._scafColorIndex = -1  # init on -1, painttool will cycle to 0
        self._stapColorIndex = -1  # init on -1, painttool will cycle to 0
        self._scafColor = self._scafColors[self._scafColorIndex]
        self._stapColor = self._stapColors[self._stapColorIndex]
        self._scafBrush = QBrush(self._scafColor)
        self._stapBrush = QBrush(self._stapColor)
        self._initLabel()
        self.hide()
Exemplo n.º 12
0
import maya.OpenMayaMPx as OpenMayaMPx
import maya.cmds as cmds
import maya.OpenMayaUI as OpenMayaUI
import maya.mel as mel
import sip

sys.path.insert(0, os.environ['CADNANO_PATH'])
# cmds.flushUndo()
# cmds.undoInfo(state=False)

import cadnano2.views.solidview.mayaHotKeys as mayaHotKeys
import cadnano2.views.solidview.mayaUI as mayaUI

import cadnano2.util as util
util.qtFrameworkList = ['PyQt']  # necessary to overide defaults
util.qtWrapImport('QtGui', globals(), ['qApp', 'QDockWidget', 'QSizePolicy'])

util.qtWrapImport('QtCore', globals(), ['Qt', 'QObject'])

kPluginName = "spCadNano"
gCadNanoButton = None
gCadNanoToolbar = None
fMayaExitingCB = None

gCadNanoApp = None

gIconPath = (os.environ['CADNANO_PATH'] +
             "/ui/mainwindow/images/cadnano2-app-icon_shelf.png")


# command
Exemplo n.º 13
0
from cadnano2.controllers.itemcontrollers.partitemcontroller import PartItemController
from .emptyhelixitem import EmptyHelixItem
from .virtualhelixitem import VirtualHelixItem
from .activesliceitem import ActiveSliceItem
from cadnano2.views import styles
import cadnano2.util as util
# import Qt stuff into the module namespace with PySide, PyQt4 independence
util.qtWrapImport(
    'QtCore', globals(),
    ['QRectF', 'QPointF', 'QEvent', 'Qt', 'pyqtSignal', 'pyqtSlot', 'QObject'])
util.qtWrapImport('QtGui', globals(), ['QBrush', 'QPainterPath', 'QPen'])
util.qtWrapImport('QtWidgets', globals(),
                  ['QGraphicsItem', 'QGraphicsEllipseItem'])

_radius = styles.SLICE_HELIX_RADIUS
_defaultRect = QRectF(0, 0, 2 * _radius, 2 * _radius)
highlightWidth = styles.SLICE_HELIX_MOD_HILIGHT_WIDTH
delta = (highlightWidth - styles.SLICE_HELIX_STROKE_WIDTH) / 2.
_hoverRect = _defaultRect.adjusted(-delta, -delta, delta, delta)
_modPen = QPen(styles.bluestroke, highlightWidth)


class PartItem(QGraphicsItem):
    _radius = styles.SLICE_HELIX_RADIUS

    def __init__(self, modelPart, parent=None):
        """
        Parent should be either a SliceRootItem, or an AssemblyItem.

        Invariant: keys in _emptyhelixhash = range(_nrows) x range(_ncols)
        where x is the cartesian product.
Exemplo n.º 14
0
#!/usr/bin/env python
# encoding: utf-8

from math import floor
from cadnano2.controllers.itemcontrollers.virtualhelixitemcontroller import VirtualHelixItemController
from cadnano2.model.enum import StrandType
from .strand.stranditem import StrandItem
from cadnano2.views import styles
from .virtualhelixhandleitem import VirtualHelixHandleItem
import cadnano2.util as util
# import Qt stuff into the module namespace with PySide, PyQt4 independence
util.qtWrapImport('QtCore', globals(),
                  ['pyqtSignal', 'QObject', 'Qt', 'QRectF'])
util.qtWrapImport('QtGui', globals(),
                  ['QBrush', 'QPainterPath', 'QPen', 'QBrush', 'QColor'])
util.qtWrapImport('QtWidgets', globals(),
                  ['QGraphicsItem', 'QGraphicsPathItem', 'QGraphicsRectItem'])

_baseWidth = styles.PATH_BASE_WIDTH
# _gridPen = QPen(styles.minorgridstroke, styles.MINOR_GRID_STROKE_WIDTH)
# _gridPen.setCosmetic(True)


class VirtualHelixItem(QGraphicsPathItem):
    """VirtualHelixItem for PathView"""
    findChild = util.findChild  # for debug

    def __init__(self, partItem, modelVirtualHelix, viewroot, activeTool):
        super(VirtualHelixItem, self).__init__(partItem.proxy())
        self._partItem = partItem
        self._modelVirtualHelix = modelVirtualHelix
Exemplo n.º 15
0
#!/usr/bin/env python
# encoding: utf-8

import cadnano2.util as util
util.qtWrapImport('QtGui', globals(), ['QGraphicsPathItem'])


class AbstractDecoratorItem(QGraphicsPathItem):
    def __init__(self, parent):
        """The parent should be a VirtualHelixItem."""
        if self.__class__ == AbstractDecoratorItem:
            e = "AbstractDecoratorItem should be subclassed."
            raise NotImplementedError(e)
        super(AbstractDecoratorItem, self).__init__(parent)
        self._strand = None
        self._oligo = None

    ### SIGNALS ###

    ### SLOTS ###
    def strandResizedSlot(self):
        """docstring for strandResizedSlot"""
        pass

    def sequenceAddedSlot(self, oligo):
        """docstring for sequenceAddedSlot"""
        pass

    def decoratorRemovedSlot(self, oligo):
        """docstring for sequenceClearedSlot"""
        pass
Exemplo n.º 16
0
import json
from .legacydecoder import import_legacy_dict
from cadnano2.ui.dialogs.ui_latticetype import Ui_LatticeType
import cadnano2.util as util
import cadnano2.cadnano as cadnano
if cadnano.app().isGui():  # headless:
    from cadnano2.ui.dialogs.ui_latticetype import Ui_LatticeType
    util.qtWrapImport('QtWidgets', globals(), ['QDialog', 'QDialogButtonBox'])


def decode(document, string):
    if cadnano.app().isGui():
        # from ui.dialogs.ui_latticetype import Ui_LatticeType
        # util.qtWrapImport('QtGui', globals(),  ['QDialog', 'QDialogButtonBox'])
        dialog = QDialog()
        dialogLT = Ui_LatticeType()  # reusing this dialog, should rename
        dialogLT.setupUi(dialog)

    # try:  # try to do it fast
    #     try:
    #         import cjson
    #         packageObject = cjson.decode(string)
    #     except:  # fall back to if cjson not available or on decode error
    #         packageObject = json.loads(string)
    # except ValueError:
    #     dialogLT.label.setText("Error decoding JSON object.")
    #     dialogLT.buttonBox.setStandardButtons(QDialogButtonBox.Ok)
    #     dialog.exec()
    #     return
    packageObject = json.loads(string)
Exemplo n.º 17
0
from .abstractpathtool import AbstractPathTool
from cadnano2.views import styles
import cadnano2.util as util
util.qtWrapImport('QtCore', globals(), ['QPointF', 'QRectF', 'Qt'])
util.qtWrapImport('QtGui', globals(), ['QBrush', 'QFont', 'QPainterPath',
                                       'QPen', 'QPolygonF'])
util.qtWrapImport('QtWidgets', globals(), ['QGraphicsItem'])

_bw = styles.PATH_BASE_WIDTH
_pen = QPen(styles.redstroke, 1)
_rect = QRectF(0, 0, _bw, _bw)
_pathArrowLeft = QPainterPath()
_l3poly = QPolygonF()
_l3poly.append(QPointF(_bw, 0))
_l3poly.append(QPointF(0.25 * _bw, 0.5 * _bw))
_l3poly.append(QPointF(_bw, _bw))
_pathArrowLeft.addPolygon(_l3poly)
_pathArrowRight = QPainterPath()
_r3poly = QPolygonF()  # right-hand 3' arr
_r3poly.append(QPointF(0, 0))
_r3poly.append(QPointF(0.75 * _bw, 0.5 * _bw))
_r3poly.append(QPointF(0, _bw))
_pathArrowRight.addPolygon(_r3poly)


class BreakTool(AbstractPathTool):
    """
    docstring for BreakTool
    """
    def __init__(self, controller):
        super(BreakTool, self).__init__(controller)
Exemplo n.º 18
0
import cadnano2.util as util
util.qtWrapImport('QtCore', globals(), ['QObject', 'pyqtSignal', 'Qt'])
util.qtWrapImport('QtWidgets', globals(), ['QGraphicsObject'])
util.qtWrapImport('QtSvg', globals(), ['QSvgRenderer'])


class SVGButton(QGraphicsObject):
    def __init__(self, fname, parent=None):
        super(SVGButton, self).__init__(parent)
        self.svg = QSvgRenderer(fname)

    def paint(self, painter, options, widget):
        self.svg.render(painter, self.boundingRect())

    def boundingRect(self):
        return self.svg.viewBoxF()

    clicked = pyqtSignal()

    def mousePressEvent(self, event):
        self.clicked.emit()
Exemplo n.º 19
0
Created by Simon Breslav on 2011-10-05.
"""

from controllers.mayacontrollers.mayaObjectManager import Mom
from cadnano2.controllers.itemcontrollers.strand.stranditemcontroller \
                                                import StrandItemController
from cadnano2.model.enum import StrandType
from cadnano2.model.enum import LatticeType

from cadnano2.cadnano import app
import maya.OpenMayaUI as mui
import maya.OpenMaya as mo
import maya.cmds as cmds
import cadnano2.util as util

util.qtWrapImport('QtCore', globals(), ['pyqtSignal', 'pyqtSlot', \
                                        'QObject', 'Qt'])
util.qtWrapImport('QtGui', globals(), ['QColor'])


class StrandItem(object):
    """
    StrandItem is the visual representation of the strand in the 3D SolidView.
    For this visual representation, StrandItem creates HalfCylinderHelixNode
    Node inside of Maya, so while the StrandItem itself does not get drawn in
    any way, it is the object that communicates with Maya Nodes associated
    with a given strand.
    """
    def __init__(self, mID, modelStrand, virtualHelixItem):
        """
        The parent should be a VirtualHelixItem.
        Initialize function creates the Maya Node for the strand, and setups
Exemplo n.º 20
0
#!/usr/bin/env python
# encoding: utf-8

import cadnano2.util as util
import copy
from .strand import Strand
# import Qt stuff into the module namespace with PySide, PyQt4 independence
util.qtWrapImport('QtCore', globals(), ['pyqtSignal', 'QObject'])
util.qtWrapImport('QtGui', globals(), ['QUndoCommand'])


class Oligo(QObject):
    """
    Oligo is a group of Strands that are connected via 5' and/or 3'
    connections. It corresponds to the physical DNA strand, and is thus
    used tracking and storing properties that are common to a single strand,
    such as its color.

    Commands that affect Strands (e.g. create, remove, merge, split) are also
    responsible for updating the affected Oligos.
    """
    def __init__(self, part, color=None):
        super(Oligo, self).__init__(part)
        self._part = part
        self._strand5p = None
        self._length = 0
        self._isLoop = False
        self._color = color if color else "#0066cc"

    # end def
Exemplo n.º 21
0
"""
styles.py

Created by Shawn on 2010-06-15.
"""

import cadnano2.util as util
# import Qt stuff into the module namespace with PySide, PyQt4 independence
util.qtWrapImport('QtGui', globals(), ['QColor', 'QFont', 'QFontMetricsF'])

# Slice Sizing
SLICE_HELIX_RADIUS = 15
SLICE_HELIX_STROKE_WIDTH = 0.5
SLICE_HELIX_HILIGHT_WIDTH = 2.5
SLICE_HELIX_MOD_HILIGHT_WIDTH = 1
HONEYCOMB_PART_MAXROWS = 30
HONEYCOMB_PART_MAXCOLS = 32
HONEYCOMB_PART_MAXSTEPS = 2
SQUARE_PART_MAXROWS = 50
SQUARE_PART_MAXCOLS = 50
SQUARE_PART_MAXSTEPS = 2

# Slice Colors
bluefill = QColor(153, 204, 255)  # 99ccff
bluestroke = QColor(0, 102, 204)  # 0066cc
bluishstroke = QColor(0, 182, 250)  #
orangefill = QColor(255, 204, 153)  # ffcc99
orangestroke = QColor(204, 102, 51)  # cc6633
lightorangefill = QColor(255, 234, 183)
lightorangestroke = QColor(234, 132, 81)
grayfill = QColor(238, 238, 238)  # eeeeee (was a1a1a1)
Exemplo n.º 22
0
from ..ui.dialogs.ui_preferences import Ui_Preferences
from ..views import styles
import cadnano2.util as util
from .. import cadnano
import os.path, zipfile, shutil, platform, subprocess, tempfile, errno
util.qtWrapImport('QtCore', globals(),
                  ['QObject', 'QSettings', 'pyqtSlot', 'Qt'])
util.qtWrapImport('QtWidgets', globals(), [
    'QWidget', 'QDialogButtonBox', 'QTableWidgetItem', 'QFileDialog',
    'QMessageBox'
])


class Preferences(object):
    """docstring for Preferences"""
    def __init__(self):
        self.qs = QSettings()
        self.uiPrefs = Ui_Preferences()
        self.widget = QWidget()
        self.uiPrefs.setupUi(self.widget)
        self.readPreferences()
        self.widget.addAction(self.uiPrefs.actionClose)
        self.uiPrefs.actionClose.triggered.connect(self.hideDialog)
        self.uiPrefs.honeycombRowsSpinBox.valueChanged.connect(
            self.setHoneycombRows)
        self.uiPrefs.honeycombColsSpinBox.valueChanged.connect(
            self.setHoneycombCols)
        self.uiPrefs.honeycombStepsSpinBox.valueChanged.connect(
            self.setHoneycombSteps)
        self.uiPrefs.squareRowsSpinBox.valueChanged.connect(self.setSquareRows)
        self.uiPrefs.squareColsSpinBox.valueChanged.connect(self.setSquareCols)
Exemplo n.º 23
0
from cadnano2.cadnano import app
from .pathview.colorpanel import ColorPanel
from .pathview.tools.pathtoolmanager import PathToolManager
from .sliceview.slicerootitem import SliceRootItem
from .pathview.pathrootitem import PathRootItem

from .sliceview.tools.slicetoolmanager import SliceToolManager
import cadnano2.ui.mainwindow.ui_mainwindow as ui_mainwindow
import cadnano2.util as util

util.qtWrapImport('QtCore', globals(), [
    'pyqtSignal',
    'Qt',
    'QFileInfo',
    'QPoint',
    'QSettings',
    'QSize',
])
util.qtWrapImport('QtGui', globals(), ['QAction', 'QPaintEngine'])
util.qtWrapImport('QtWidgets', globals(), [
    'QApplication',
    'QGraphicsObject',
    'QGraphicsScene',
    'QGraphicsView',
    'QGraphicsItem',
    'QGraphicsRectItem',
    'QMainWindow',
    'QWidget',
])

# for OpenGL mode
Exemplo n.º 24
0
"""
config
Created by Jonathan deWerd on 2012-01-19.
"""
import cadnano2.util as util
import cadnano2.cadnano as cadnano
from . import autobreakconfig_ui
from . import autobreak
util.qtWrapImport('QtGui', globals(), ['QKeySequence'])
util.qtWrapImport('QtCore', globals(), ['Qt'])
util.qtWrapImport('QtWidgets', globals(), ['QDialog', 'QDialogButtonBox'])


class AutobreakConfig(QDialog, autobreakconfig_ui.Ui_Dialog):
    def __init__(self, parent, handler):
        QDialog.__init__(self, parent, Qt.WindowType.Sheet)
        self.setupUi(self)
        self.handler = handler
        fb = self.buttonBox.button(QDialogButtonBox.Cancel)
        fb.setShortcut(QKeySequence(Qt.CTRL | Qt.Key.Key_R))

    def keyPressEvent(self, e):
        return QDialog.keyPressEvent(self, e)

    def closeDialog(self):
        self.close()

    def accept(self):
        part = self.handler.doc.controller().activePart()
        if part != None:
            settings = {\
Exemplo n.º 25
0
"""
pathselection.py

Created by Nick on 2011-06-27.
"""

from cadnano2.views import styles
from math import floor
import cadnano2.util as util

# import Qt stuff into the module namespace with PySide, PyQt4 independence
util.qtWrapImport('QtCore', globals(), ['Qt', 'QPointF', 'QEvent', 'QRectF'])
util.qtWrapImport('QtGui', globals(),
                  ['QPen', 'QBrush', 'QColor', 'QPainterPath'])
util.qtWrapImport(
    'QtWidgets',
    globals(),
    [  # 'qApp',
        'QGraphicsItem', 'QGraphicsItemGroup', 'QGraphicsPathItem'
    ])


class SelectionItemGroup(QGraphicsItemGroup):
    """
    SelectionItemGroup
    """
    def __init__(self, boxtype, constraint='y', parent=None):
        super(SelectionItemGroup, self).__init__(parent)
        self._viewroot = parent
        self.setFiltersChildEvents(True)
Exemplo n.º 26
0
#!/usr/bin/env python
# encoding: utf-8

import cadnano2.util as util
from cadnano2.views import styles

# import Qt stuff into the module namespace with PySide, PyQt4 independence
util.qtWrapImport('QtCore', globals(), ['QPointF', 'QRectF', 'Qt'])
util.qtWrapImport('QtGui', globals(), ['QBrush',
                                       'QColor',
                                       'QFont',
                                       'QFontMetricsF',
                                       'QPainterPath',
                                       'QPen',
                                       'QTextCursor',
                                       'QTransform'])
util.qtWrapImport('QtWidgets', globals(), ['QGraphicsItem',
                                           'QGraphicsPathItem',
                                           'QGraphicsRectItem',
                                           'QGraphicsTextItem',
                                           'QLabel',
                                           ])


_baseWidth = _bw = styles.PATH_BASE_WIDTH
_halfbaseWidth = _hbw = _baseWidth / 2
_offset1 = _baseWidth / 4
_defaultRect = QRectF(0, 0, _bw, _bw)
_bpen = QPen(styles.bluestroke, styles.INSERTWIDTH)
_rpen = QPen(styles.redstroke, styles.SKIPWIDTH)
_noPen = QPen(Qt.PenStyle.NoPen)
Exemplo n.º 27
0
"""
activeslicehandle.py
Created by Shawn on 2011-02-05.
"""

from cadnano2.controllers.itemcontrollers.activesliceitemcontroller import ActiveSliceItemController
import cadnano2.util as util

# import Qt stuff into the module namespace with PySide, PyQt4 independence
util.qtWrapImport('QtCore', globals(), ['QPointF', 'QRectF', 'Qt', 'QObject',\
                                        'pyqtSignal', 'pyqtSlot', 'QEvent'])
util.qtWrapImport('QtGui', globals(),
                  ['QBrush', 'QFont', 'QPen', 'QDrag', 'QUndoCommand'])
util.qtWrapImport(
    'QtWidgets', globals(),
    ['QGraphicsItem', 'QGraphicsRectItem', 'QGraphicsSimpleTextItem'])


class ActiveSliceItem(QGraphicsRectItem):
    """ActiveSliceItem for the Slice View"""
    def __init__(self, partItem, activeBaseIndex):
        super(ActiveSliceItem, self).__init__(partItem)
        self._partItem = partItem
        self._controller = ActiveSliceItemController(self, partItem.part())
        self.setFlag(QGraphicsItem.GraphicsItemFlag.ItemHasNoContents)

    # end def

    ### SLOTS ###
    def strandChangedSlot(self, sender, vh):
        if vh == None:
Exemplo n.º 28
0
from cadnano2.views import styles
from cadnano2.model.enum import StrandType

import cadnano2.util as util
# import Qt stuff into the module namespace with PySide, PyQt4 independence
util.qtWrapImport('QtCore', globals(), ['QPointF', 'QRectF', 'Qt'])
util.qtWrapImport('QtGui', globals(), ['QBrush', 'QFont', 'QPen'])
util.qtWrapImport('QtWidgets', globals(),
                  ['QGraphicsItem', 'QGraphicsItemGroup', 'QGraphicsObject'])

_bw = styles.PATH_BASE_WIDTH
_toolRect = QRectF(0, 0, _bw, _bw)  # protected not private
_rect = QRectF(-styles.PATH_BASE_HL_STROKE_WIDTH,
               -styles.PATH_BASE_HL_STROKE_WIDTH,
               _bw + 2 * styles.PATH_BASE_HL_STROKE_WIDTH,
               _bw + 2 * styles.PATH_BASE_HL_STROKE_WIDTH)
_pen = QPen(styles.redstroke, styles.PATH_BASE_HL_STROKE_WIDTH)
_brush = QBrush(Qt.BrushStyle.NoBrush)

# There's a bug where C++ will free orphaned graphics items out from
# under pyqt. To avoid this, "_mother" adopts orphaned graphics items.
_mother = QGraphicsItemGroup()


class AbstractPathTool(QGraphicsObject):
    """Abstract base class to be subclassed by all other pathview tools."""
    def __init__(self, controller, parent=None):
        super(AbstractPathTool, self).__init__(parent)
        self._controller = controller
        self._window = controller.window
        self._active = False
Exemplo n.º 29
0
"""
pathhelixhandle.py
Created by Shawn on 2011-02-05.
"""
from cadnano2.views import styles

import cadnano2.util as util
# import Qt stuff into the module namespace with PySide, PyQt4 independence
util.qtWrapImport('QtCore', globals(), ['QPointF', 'QRectF', 'Qt'])
util.qtWrapImport(
    'QtGui', globals(),
    ['QBrush', 'QFont', 'QPen', 'QDrag', 'QTransform', 'QUndoCommand'])
util.qtWrapImport('QtWidgets', globals(), [
    'QGraphicsEllipseItem', 'QGraphicsItem', 'QGraphicsSimpleTextItem',
    'QGraphicsTextItem', 'QStyle'
])

_radius = styles.VIRTUALHELIXHANDLEITEM_RADIUS
_rect = QRectF(0, 0, 2*_radius + styles.VIRTUALHELIXHANDLEITEM_STROKE_WIDTH,\
        2*_radius + styles.VIRTUALHELIXHANDLEITEM_STROKE_WIDTH)
_defBrush = QBrush(styles.grayfill)
_defPen = QPen(styles.graystroke, styles.VIRTUALHELIXHANDLEITEM_STROKE_WIDTH)
_hovBrush = QBrush(styles.bluefill)
_hovPen = QPen(styles.bluestroke, styles.VIRTUALHELIXHANDLEITEM_STROKE_WIDTH)
_useBrush = QBrush(styles.orangefill)
_usePen = QPen(styles.orangestroke, styles.VIRTUALHELIXHANDLEITEM_STROKE_WIDTH)
_font = styles.VIRTUALHELIXHANDLEITEM_FONT


class VirtualHelixHandleItem(QGraphicsEllipseItem):
    """docstring for VirtualHelixHandleItem"""
Exemplo n.º 30
0
# encoding: utf-8

from collections import defaultdict
from math import ceil
from .activesliceitem import ActiveSliceItem
from cadnano2.controllers.itemcontrollers.partitemcontroller import PartItemController
from .prexoveritem import PreXoverItem
from .strand.xoveritem import XoverNode3
from cadnano2.ui.mainwindow.svgbutton import SVGButton
from cadnano2.views import styles
from .virtualhelixitem import VirtualHelixItem
import cadnano2.util as util
from cadnano2.cadnano import app

# import Qt stuff into the module namespace with PySide, PyQt4 independence
util.qtWrapImport('QtCore', globals(), ['QDir', 'QPointF', 'QRectF', 'Qt'])
util.qtWrapImport('QtGui', globals(), ['QBrush', 'QPen'])
util.qtWrapImport('QtWidgets', globals(), [
    'QGraphicsPathItem', 'QGraphicsItem', 'QGraphicsRectItem', 'QInputDialog'
])

_baseWidth = _bw = styles.PATH_BASE_WIDTH
_defaultRect = QRectF(0, 0, _baseWidth, _baseWidth)
_modPen = QPen(styles.bluestroke)


class ProxyParentItem(QGraphicsRectItem):
    """an invisible container that allows one to play with Z-ordering"""
    findChild = util.findChild  # for debug