Ejemplo n.º 1
0
 def setRect(self, r):
     parent = self.parentItem()
     if (parent is None): return
     siblings = parent.childItems()
     gr = QRectF()
     for view in siblings:
         if ((hasattr(view, 'unit')) and (view.unit in self.unit.units)):
             vr = view.rect()
             if ((gr.width() == 0.0) and (gr.height() == 0.0)):
                 gr = vr
             else:
                 gr = gr.united(vr)
     # add a margin around the content
     cm = int(1.5 * self.MARGIN)
     gr.adjust(-cm, -cm, cm, cm)
     self._group_rect = gr
     # leave room for the unit view's elements and borders
     m = self.MARGIN
     r = QRectF(gr)
     r.adjust(-m, -self.TOP_HEIGHT, m, 0.0)
     self.prepareGeometryChange()
     UnitView.setRect(self, r)
     # put groups behind other units and the connections layer (z-value -1.0)
     #  and order them by size so the biggest are in the back, to support
     #  nested groups without traversing the tree
     self.setZValue(-1.0 - gr.width())
     self.layout()
Ejemplo n.º 2
0
 def setRect(self, r):
   parent = self.parentItem()
   if (parent is None): return
   siblings = parent.childItems()
   gr = QRectF()
   for view in siblings:
     if ((hasattr(view, 'unit')) and (view.unit in self.unit.units)):
       vr = view.rect()
       if ((gr.width() == 0.0) and (gr.height() == 0.0)):
         gr = vr
       else:
         gr = gr.united(vr)
   # add a margin around the content
   cm = int(1.5 * self.MARGIN)
   gr.adjust(- cm, - cm, cm, cm)
   self._group_rect = gr
   # leave room for the unit view's elements and borders
   m = self.MARGIN
   r = QRectF(gr)
   r.adjust(- m, - self.TOP_HEIGHT, m, 0.0)
   self.prepareGeometryChange()
   UnitView.setRect(self, r)
   # put groups behind other units and the connections layer (z-value -1.0) 
   #  and order them by size so the biggest are in the back, to support 
   #  nested groups without traversing the tree
   self.setZValue(-1.0 - gr.width())
   self.layout()
Ejemplo n.º 3
0
 def layout(self):
   y = self._rect.y()
   x = self._rect.x()
   extents = QRectF()
   moving_unit = False
   for view in self._views:
     unit = view.unit
     r = view.rect()
     view_rect = QRectF(
       # use integer coordinates for sharp antialiasing
       round(x + unit.x - (r.width() / 2.0)), 
       round(y + unit.y - (r.height() / 2.0)), 
       r.width(), r.height())
     view.setRect(view_rect)
     extents = extents.united(view_rect)
     try:
       moving_unit = moving_unit or view.moving
     except AttributeError: pass
   # size the workspace to the units in it plus a margin
   m = 100.0
   extents.adjust(- m, - m, m, m)
   old_extents = self.extents
   if (moving_unit):
     extents = extents.united(old_extents)
   self.extents = extents
Ejemplo n.º 4
0
 def layout(self):
     y = self._rect.y()
     r = self.mapRectFromParent(self._rect)
     h = r.height()
     for view in self._views:
         x = view.model.time
         try:
             w = view.model.duration
         except AttributeError:
             w = view.rect().width()
         view.setRect(QRectF(x, y, w, h))
Ejemplo n.º 5
0
 def layout(self):
   y = self._rect.y()
   r = self.mapRectFromParent(self._rect)
   h = r.height()
   for view in self._views:
     x = view.model.time
     try:
       w = view.model.duration
     except AttributeError:
       w = view.rect().width()
     view.setRect(QRectF(x, y, w, h))
Ejemplo n.º 6
0
    def switchLevel(self, newLevel):
        levels = self.__map.levels()
        if self.__map.levelExists(newLevel):
            level = self.__map.getLevelByIndex(newLevel)
            if self.__registry.currentLevel is level:
                return

            newView = level.getView()
            view = self.__registry.currentLevel.getView().views()[0]
            center = view.mapToScene(view.rect().center())
            self.__registry.mainWindow.mapView().setScene(self.__map.getLevelByIndex(newLevel).getView())
            scene = self.__registry.mainWindow.mapView().scene().getModel()
            view.centerOn(center)
Ejemplo n.º 7
0
    def switchLevel(self, newLevel):
        levels = self.__map.levels()
        if self.__map.levelExists(newLevel):
            level = self.__map.getLevelByIndex(newLevel)
            if self.__registry.currentLevel is level:
                return

            newView = level.getView()
            view = self.__registry.currentLevel.getView().views()[0]
            center = view.mapToScene(view.rect().center())
            self.__registry.mainWindow.mapView().setScene(
                self.__map.getLevelByIndex(newLevel).getView())
            scene = self.__registry.mainWindow.mapView().scene().getModel()
            view.centerOn(center)
Ejemplo n.º 8
0
 def layout(self):
   r = self.boundingRect()
   cr = self.effectiveClipRect()
   pitch_map = dict()
   i = 0.5
   for pitch in reversed(self._track.pitches):
     pitch_map[pitch] = i
     i += 1.0
   if (self._views is not None):
     for view in self._views:
       note = view.note
       try:
         y = pitch_map[note.pitch]
       except KeyError:
         y = -1.0
       view.setPos(QPointF(r.x() + note.time, r.y() + y))
       view.setVisible((cr is None) or (view.rect().intersects(cr)))