geosolver/workbench/cvitems.py
kwikrick cc4e6f431a geometric.py
FixConstraint now works again in workbench
 GeometricCluster now called GeometricDecomposition
 added MateConstraint

intersections.py:
 fixed degenerate intersections in sss_int and cl_int
 fixed degenerate coordinate systems in make_hcs_3d

matfunc.py: 
 eye now returns a matrix with float values

__init__.py 
  import MateConstraint, LeftHandedConstraint, RightHandedConstraint

configuration.py
  changed how underconstrained situations are is determined

clsolver.py
   add fewer SelectionMethods and PrototypeMethods
   removed methods: rigids(), hedghogs(), balloon(), replaced by clusters()

clsolver3D.py
    added MergeGluable (for solving MateConstraint)

cluster.py
    add Gluable cluster (for solving MateConstraint)

and lots of other small fixes and changes...
2009-11-21 12:42:24 +00:00

78 lines
3.4 KiB
Python

from includes import *
from geosolver import GeometricDecomposition
from parameters import Settings
class CVCluster(QtGui.QGraphicsItem):
""" Visualisation of the clusters (nodes) in the decompositionView """
def __init__(self, compView, cluster, x,y):
QtGui.QGraphicsItem.__init__(self)
self.compositionView = compView
self.cluster = cluster
self.position = QtCore.QPointF(x, y)
self.textGraphic = QtGui.QGraphicsSimpleTextItem(str(list(self.cluster.variables)), self)
#self.textGraphic.translate(x,y)
self.paintRect = self.textGraphic.boundingRect()
#self.paintRect.translate(x,y)
self.translate(x,y)
def boundingRect(self):
""" Overridden function where a update area is determined for painting and returned """
return self.paintRect
def paint(self, painter, option, widget):
""" Visualisation of a clusteritem """
painter.setPen(QtGui.QColor(0,155,50))
if self.cluster.flag != None:
if self.cluster.flag == GeometricDecomposition.OK:
painter.setBrush(QtGui.QBrush(self.compositionView.wellConstrainedColor))
elif self.cluster.flag == GeometricDecomposition.I_UNDER or self.cluster.flag == GeometricDecomposition.S_UNDER:
painter.setBrush(QtGui.QBrush(self.compositionView.underConstrainedColor))
elif self.cluster.flag == GeometricDecomposition.I_OVER or self.cluster.flag == GeometricDecomposition.S_OVER:
painter.setBrush(QtGui.QBrush(self.compositionView.overConstrainedColor))
elif self.cluster.flag == GeometricDecomposition.UNSOLVED:
painter.setBrush(QtGui.QBrush(self.compositionView.unsolvedColor))
painter.drawRect(self.paintRect)
class CVConnection(QtGui.QGraphicsItem):
""" Visualisation of the connections between the clusters, where two types of visualisation can be chosen: Bezier(default) and Lines """
def __init__(self, compView, nodeFrom , nodeTo):
QtGui.QGraphicsItem.__init__(self)
self.settings = Settings()
self.compositionView = compView
self.nodeFrom = nodeFrom
self.nodeTo = nodeTo
self.beziercurve = None
self.paintRect = None
self.setZValue(1)
self.determinePath()
def determinePath(self):
if self.nodeFrom != None and self.nodeTo != None:
self.beziercurve = QtGui.QPainterPath()
x1 = self.nodeFrom.position.x() + self.nodeFrom.paintRect.width()/2
x2 = self.nodeTo.position.x() + self.nodeTo.paintRect.width()/2
y1 = self.nodeFrom.position.y()
y2 = self.nodeTo.position.y() + self.nodeFrom.paintRect.height()
p1 = QtCore.QPointF(x1,y1)
p2 = QtCore.QPointF(x1,y1+(y2-y1)/2)
p3 = QtCore.QPointF(x2,y1+(y2-y1)/2)
p4 = QtCore.QPointF(x2,y2)
self.beziercurve.moveTo(p1)
self.beziercurve.cubicTo(p2,p3,p4)
def paint(self, painter, option, widget):
""" Visualisation of the connection between two nodes """
if self.beziercurve:
painter.drawPath(self.beziercurve)
def boundingRect(self):
""" Overridden function where a update area is determined for painting and returned """
return self.beziercurve.boundingRect()