Exemplo n.º 1
0
 def __init__(self, parent=None, position=None):
     super(ActionHandler, self).__init__(parent)
     # supported event
     self.customAction = PyCadEvent()
     self.fireApply = PyCadEvent()
     # Center point
     p0 = QtCore.QPointF(5, 5)
     self.circle = CirclePosition(self, p0)
     self.circle.customAction += self.positionChanged
     self.circle.fireApply += self._fireApply
     # Angle hendler
     self.arcAngle = ArcAngle(self, p0)
     self.arcAngle.customAction += self.positionChanged
     self.arcAngle.fireApply += self._fireApply
     p1 = QtCore.QPointF(10, 0)
     # Horizontal Arrow
     self.hArrow = ArrowItem(self, p1)
     p2 = QtCore.QPointF(0, -10)
     self.hArrow.customAction += self.positionChanged
     self.arcAngle.fireApply += self._fireApply
     # Vertical Arrow
     self.vArrow = ArrowItem(self, p2, 90,
                             QtGui.QPen(QtGui.QColor(79, 106, 25)))
     self.vArrow.customAction += self.positionChanged
     self.arcAngle.fireApply += self._fireApply
     # QGraphicsItem settings
     if position != None:
         self.setPos(position)
     self.position = position
     self.setAcceptsHoverEvents(True)
     self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True)
Exemplo n.º 2
0
 def __init__(self, parent=None, position=None):
     super(CirclePosition, self).__init__(parent)
     self.setAcceptsHoverEvents(True)  #Fire over events
     self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable, True)
     self.setAcceptDrops(True)
     self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, False)
     if position != None:
         self.setPos(position)
     self.customAction = PyCadEvent()
     self.fireApply = PyCadEvent()
Exemplo n.º 3
0
    def __init__(self, document, parent=None):
        super(CadScene, self).__init__(parent)

        self.active_command = None
        self.active_entity = None
        self.preview_item = None
        self.connect(parent._mainwindow, QtCore.SIGNAL('command_started'),
                     self._start_command)
        self.connect(self, QtCore.SIGNAL('left_mouse_release'),
                     self._process_click)
        self.connect(self, QtCore.SIGNAL('mouse_move'), self._process_move)

        # drawing limits
        self.setSceneRect(-10000, -10000, 20000, 20000)
        # scene custom event
        self.zoomWindows = PyCadEvent()
        self.fireCommandlineFocus = PyCadEvent()
        self.fireKeyShortcut = PyCadEvent()
        self.fireKeyEvent = PyCadEvent()
        self.fireWarning = PyCadEvent()
        self.fireCoords = PyCadEvent()
        #fire Pan and Zoom events to the view
        self.firePan = PyCadEvent()
        self.fireZoomFit = PyCadEvent()
        self.document = document
        self.needPreview = False
        self.forceDirectionEnabled = False
        self.forceDirection = None
        self.__lastPickedEntity = None
        self.isInPan = False
        self.forceSnap = None
        self._cmdZoomWindow = None
        self.showHandler = False
        self.posHandler = None
        #
        # new command implementation
        #
        self.__activeKernelCommand = None
        self.activeICommand = None
        #
        self.__grapWithd = 20.0
        #
        # Input implemetation by carlo
        #
        self.fromPoint = None  #frompoint is assigned in icommand.getClickedPoint() and deleted by applycommand and cancelcommand, is needed for statusbar coordinates dx,dy
        self.selectionAddMode = False

        # Init loading of snap marks
        self.initSnap()

        # Init loading of guides
        self.isGuided = None
        self.isGuideLocked = None
        self.initGuides()

        # scene aspect
        r, g, b = BACKGROUND_COLOR  #defined in cadinitsetting
        self.setBackgroundBrush(
            QtGui.QBrush(QtGui.QColor(r, g, b), QtCore.Qt.SolidPattern))
Exemplo n.º 4
0
 def __init__(self, position=None):
     super(PositionHandler, self).__init__()
     self.setAcceptsHoverEvents(True)
     self.circle = CirclePosition(self, QtCore.QPointF(5, 5))
     self.circle.setAcceptsHoverEvents(False)
     self.circle.setFlag(QtGui.QGraphicsItem.ItemIsSelectable, False)
     self.circle.setAcceptDrops(False)
     self.circle.setFlag(QtGui.QGraphicsItem.ItemIsMovable, False)
     self.ActionHandler = ActionHandler(self, QtCore.QPointF(0, 0))
     self.ActionHandler.fireApply += self._fireApply
     self.customAction = PyCadEvent()
     self.confirmEvent = PyCadEvent()
     self.fireApply = PyCadEvent()
     if position != None:
         self.setPos(position)
     self.position = position
Exemplo n.º 5
0
 def __init__(self,
              parent=None,
              position=None,
              rotation=None,
              arrowColor=None):
     super(ArrowItem, self).__init__(parent)
     self.setAcceptsHoverEvents(True)  #Fire over events
     self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable, True)
     self.setAcceptDrops(True)
     self.arrowColor = QtGui.QPen(QtGui.QColor(79, 106, 25))
     self._angle = 0
     if arrowColor != None:
         self.arrowColor = arrowColor
     if position != None:
         self.setPos(position)
     if rotation != None:
         self.rotate(-rotation)
         self._angle = rotation
     self.delta = 0
     self.customAction = PyCadEvent()
     self.fireApply = PyCadEvent()
Exemplo n.º 6
0
    def __init__(self, title, parent):
        '''
            Creates an edit line in which commands or expressions are evaluated.
            Evaluation of expressions is done by the FunctionHandler object.
        '''
        super(CmdLineDock, self).__init__(title, parent)
        self.setMinimumHeight(100)
        self._remainder = []
        self._remainderIndex = 0
        # only dock at the bottom or top
        self.setAllowedAreas(QtCore.Qt.BottomDockWidgetArea
                             | QtCore.Qt.TopDockWidgetArea)
        self.dockWidgetContents = QtGui.QWidget()
        self.dockWidgetContents.setObjectName("dockWidgetContents")
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
                                       QtGui.QSizePolicy.Ignored)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.dockWidgetContents.sizePolicy().hasHeightForWidth())
        self.dockWidgetContents.setSizePolicy(sizePolicy)
        self.verticalLayout_2 = QtGui.QVBoxLayout(self.dockWidgetContents)
        self.verticalLayout_2.setObjectName("verticalLayout_2")

        self.textEditOutput = PyCadTextView(self.dockWidgetContents)

        self.verticalLayout_2.addWidget(self.textEditOutput)
        self.__edit_ctrl = QtGui.QLineEdit(self,
                                           returnPressed=self._returnPressed)
        self.__edit_ctrl.keyPressEvent = self._keyPress

        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.textEditOutput.sizePolicy().hasHeightForWidth())
        self.__edit_ctrl.setSizePolicy(sizePolicy)
        self.verticalLayout_2.addWidget(self.__edit_ctrl)
        self.setWidget(self.dockWidgetContents)
        self.__function_handler = FunctionHandler(self.__edit_ctrl,
                                                  self.textEditOutput)
        #QtCore.QObject.connect(self.__edit_ctrl, QtCore.SIGNAL("returnPressed()"), self.textEditOutput.centerCursor)
        #
        self.evaluatePressed = PyCadEvent()

        self.setObjectName(
            "CmdLineDock"
        )  #this is needed for remember toolbar position in cadwindow.writesettings(savestate)
Exemplo n.º 7
0
 def __init__(self, dbPath=None):
     """
         init of the kernel
     """
     self.__logger=logging.getLogger('DbKernel')
     self.__logger.debug('__init__')
     super(Document, self).__init__()
     # set the events
     self.__logger.debug('set events')
     self.saveEntityEvent=PyCadEvent()
     self.deleteEntityEvent=PyCadEvent()
     self.massiveDeleteEvent=PyCadEvent()
     self.showEntEvent=PyCadEvent()
     self.hideEntEvent=PyCadEvent()
     self.updateShowEntEvent=PyCadEvent()
     self.undoRedoEvent=PyCadEvent()
     self.handledErrorEvent=PyCadEvent()
     #create Connection
     self.createConnection(dbPath) #
     # inizialize extentionObject
     self.__UndoDb=UndoDb(self.getConnection())
     self.__EntityDb=EntityDb(self.getConnection())
     self.__RelationDb=RelationDb(self.getConnection())
     # Some inizialization parameter
     self.__bulkCommit=False
     self.__bulkUndoIndex=-1     # undo index are always positive so we do not brake in case missing entity id
     self.__entId=self.__EntityDb.getNewEntId()
     #   set the default style
     self.__logger.debug('Set Style')
     self.__activeStyleObj=None
     self.__activeStyleObj=self.getMainStyle()
     self.__settings=self.getDbSettingsObject()
     self.__property={}
     #************************
     #Inizialize Layer structure
     #************************
     self.__logger.debug('Inizialize layer structure')
     try:
         self.__LayerTable = LayerTable(self)
     except StructuralError:
         raise StructuralError, 'Unable to create LayerTree structure'
     self.__logger.debug('Done inizialization')
 def __init__(self):
     super(DinamicEntryLine, self).__init__()
     self.hide()
     self.h = 20
     self.w = 60
     self.onEnter = PyCadEvent()