Skip to content
Snippets Groups Projects
Commit 224487f4 authored by Dilawar Singh's avatar Dilawar Singh
Browse files

Merge commit '25a907eb'

parents 02fcf721 25a907eb
No related branches found
No related tags found
No related merge requests found
from PyQt4.QtGui import QPolygonF from PyQt4.QtGui import QPolygonF
from PyQt4.QtCore import QLineF,QPointF from PyQt4.QtCore import QLineF,QPointF
import math from math import sin,cos,atan2,radians
from kkitQGraphics import PoolItem #, ReacItem,EnzItem,CplxItem,ComptItem from kkitQGraphics import PoolItem #, ReacItem,EnzItem,CplxItem,ComptItem
''' One to need to pass the source, destination,endtype and order for drawing the arrow between 2 object \ ''' One to need to pass the source, destination,endtype and order for drawing the arrow between 2 object \
...@@ -46,9 +46,9 @@ def calcArrow(srcdes_list,itemignoreZooming,iconScale): ...@@ -46,9 +46,9 @@ def calcArrow(srcdes_list,itemignoreZooming,iconScale):
dy = desRect.center().y()- srcRect.center().y() dy = desRect.center().y()- srcRect.center().y()
dx0 = dy dx0 = dy
dy0 = -dx dy0 = -dx
tetha1 = (math.atan2(dy0,dx0)) tetha1 = (atan2(dy0,dx0))
a0 = 4 *(math.cos(tetha1)) a0 = 4 *(cos(tetha1))
b0 = 4 *(math.sin(tetha1)) b0 = 4 *(sin(tetha1))
''' Higher order ( > 4) connectivity will not be done''' ''' Higher order ( > 4) connectivity will not be done'''
if ((order == 3) or (order == 4)): if ((order == 3) or (order == 4)):
a0 = a0*2 a0 = a0*2
...@@ -154,9 +154,9 @@ def calcLineRectIntersection(rect, centerLine): ...@@ -154,9 +154,9 @@ def calcLineRectIntersection(rect, centerLine):
def arrowHead(srcAngle,degree,lineSpoint,iconScale): def arrowHead(srcAngle,degree,lineSpoint,iconScale):
''' arrow head is calculated ''' ''' arrow head is calculated '''
r = 8*iconScale r = 8*iconScale
delta = math.radians(srcAngle) + math.radians(degree) delta = radians(srcAngle) + radians(degree)
width = math.sin(delta)*r width = sin(delta)*r
height = math.cos(delta)*r height = cos(delta)*r
srcXArr = (lineSpoint.x() + width) srcXArr = (lineSpoint.x() + width)
srcYArr = (lineSpoint.y() + height) srcYArr = (lineSpoint.y() + height)
return srcXArr,srcYArr return srcXArr,srcYArr
...@@ -15,6 +15,7 @@ from PyQt4 import QtGui, QtCore, Qt ...@@ -15,6 +15,7 @@ from PyQt4 import QtGui, QtCore, Qt
from moose import * from moose import *
from PyQt4.QtGui import QPixmap, QImage, QGraphicsPixmapItem from PyQt4.QtGui import QPixmap, QImage, QGraphicsPixmapItem
from constants import * from constants import *
from os import path
class KineticsDisplayItem(QtGui.QGraphicsWidget): class KineticsDisplayItem(QtGui.QGraphicsWidget):
"""Base class for display elemenets in kinetics layout""" """Base class for display elemenets in kinetics layout"""
...@@ -71,7 +72,9 @@ class FuncItem(KineticsDisplayItem): ...@@ -71,7 +72,9 @@ class FuncItem(KineticsDisplayItem):
def __init__(self, mobj, parent): def __init__(self, mobj, parent):
super(FuncItem, self).__init__(mobj, parent) super(FuncItem, self).__init__(mobj, parent)
self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True) self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True)
self.funcImage = QImage('icons/classIcon/Function.png').scaled(15,33) #self.funcImage = QImage('icons/classIcon/Function.png').scaled(15,33)
iconmap_file = (path.join(config.settings[config.KEY_ICON_DIR], 'classIcon/Function.png'))
self.funcImage = QImage(iconmap_file).scaled(15,33)
self.bg = QtGui.QGraphicsRectItem(self) self.bg = QtGui.QGraphicsRectItem(self)
self.bg.setAcceptHoverEvents(True) self.bg.setAcceptHoverEvents(True)
self.gobj = QtGui.QGraphicsPixmapItem(QtGui.QPixmap.fromImage(self.funcImage),self.bg) self.gobj = QtGui.QGraphicsPixmapItem(QtGui.QPixmap.fromImage(self.funcImage),self.bg)
...@@ -195,6 +198,9 @@ class PoolItem(KineticsDisplayItem): ...@@ -195,6 +198,9 @@ class PoolItem(KineticsDisplayItem):
#This func will adjust the background color with respect to text size #This func will adjust the background color with respect to text size
self.gobj.setText(self.mobj.name) self.gobj.setText(self.mobj.name)
self.bg.setRect(0, 0, self.gobj.boundingRect().width()+PoolItem.fontMetrics.width(' '), self.gobj.boundingRect().height()) self.bg.setRect(0, 0, self.gobj.boundingRect().width()+PoolItem.fontMetrics.width(' '), self.gobj.boundingRect().height())
self.setGeometry(self.pos().x(),self.pos().y(),self.gobj.boundingRect().width()
+PoolItem.fontMetrics.width(''),
self.gobj.boundingRect().height())
def updateColor(self,bgcolor): def updateColor(self,bgcolor):
self.bg.setBrush(QtGui.QBrush(QtGui.QColor(bgcolor))) self.bg.setBrush(QtGui.QBrush(QtGui.QColor(bgcolor)))
...@@ -490,7 +496,9 @@ class ComptItem(QtGui.QGraphicsRectItem): ...@@ -490,7 +496,9 @@ class ComptItem(QtGui.QGraphicsRectItem):
self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True); self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True);
self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable) self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable)
#self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges, 1) #self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges, 1)
QT_VERSION = str(QtCore.QT_VERSION_STR).split('.')
QT_MINOR_VERSION = int(QT_VERSION[1])
if config.QT_MINOR_VERSION >= 6: if config.QT_MINOR_VERSION >= 6:
self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges, 1) self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges, 1)
''' '''
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment