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

Squashed 'moose-gui/' changes from 6104940..d282884

d282884 specific math functions are imported
16439cc checked for Qt_Version and icon takes config.settings
cecb74c resize qObject if change in text size

git-subtree-dir: moose-gui
git-subtree-split: d282884250997aa6cc1154b6ba93fee6c3ccc630
parent e565756c
Branches
Tags
No related merge requests found
from PyQt4.QtGui import QPolygonF
from PyQt4.QtCore import QLineF,QPointF
import math
from math import sin,cos,atan2,radians
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 \
......@@ -46,9 +46,9 @@ def calcArrow(srcdes_list,itemignoreZooming,iconScale):
dy = desRect.center().y()- srcRect.center().y()
dx0 = dy
dy0 = -dx
tetha1 = (math.atan2(dy0,dx0))
a0 = 4 *(math.cos(tetha1))
b0 = 4 *(math.sin(tetha1))
tetha1 = (atan2(dy0,dx0))
a0 = 4 *(cos(tetha1))
b0 = 4 *(sin(tetha1))
''' Higher order ( > 4) connectivity will not be done'''
if ((order == 3) or (order == 4)):
a0 = a0*2
......@@ -154,9 +154,9 @@ def calcLineRectIntersection(rect, centerLine):
def arrowHead(srcAngle,degree,lineSpoint,iconScale):
''' arrow head is calculated '''
r = 8*iconScale
delta = math.radians(srcAngle) + math.radians(degree)
width = math.sin(delta)*r
height = math.cos(delta)*r
delta = radians(srcAngle) + radians(degree)
width = sin(delta)*r
height = cos(delta)*r
srcXArr = (lineSpoint.x() + width)
srcYArr = (lineSpoint.y() + height)
return srcXArr,srcYArr
......@@ -15,6 +15,7 @@ from PyQt4 import QtGui, QtCore, Qt
from moose import *
from PyQt4.QtGui import QPixmap, QImage, QGraphicsPixmapItem
from constants import *
from os import path
class KineticsDisplayItem(QtGui.QGraphicsWidget):
"""Base class for display elemenets in kinetics layout"""
......@@ -71,7 +72,9 @@ class FuncItem(KineticsDisplayItem):
def __init__(self, mobj, parent):
super(FuncItem, self).__init__(mobj, parent)
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.setAcceptHoverEvents(True)
self.gobj = QtGui.QGraphicsPixmapItem(QtGui.QPixmap.fromImage(self.funcImage),self.bg)
......@@ -195,6 +198,9 @@ class PoolItem(KineticsDisplayItem):
#This func will adjust the background color with respect to text size
self.gobj.setText(self.mobj.name)
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):
self.bg.setBrush(QtGui.QBrush(QtGui.QColor(bgcolor)))
......@@ -491,6 +497,8 @@ class ComptItem(QtGui.QGraphicsRectItem):
self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True);
self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable)
#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:
self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges, 1)
'''
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment