示例#1
0
QRectF QtPoint2D::boundingRect() const
{
	QRectF rect(QPointF(GetSValue(),-GetTValue()),
 				QPointF(GetSValue(),-GetTValue()));
	
	// increase the size of the box to account for the actual radius of the point that represents the circle
	// @fixme if the user zooms out or if the model has a large length scale, the bounding box wont contain the whole point
	rect.adjust(-GetBoundingRectPad(),-GetBoundingRectPad(),GetBoundingRectPad(),GetBoundingRectPad());
	
	return rect;
}
示例#2
0
void QtPoint2D::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event )
{
	if (event->button() & Qt::LeftButton && pending_db_save_) 
	{
		// if there is a pending db save, do the save now (this happens at the end of a drag event)
		SetSValue(GetSValue());
		SetTValue(GetTValue());

		pending_db_save_ = false;
	}

	// let the base class do it's thing
	QGraphicsItem::mouseReleaseEvent(event);
}
示例#3
0
int SetColourR(Colour *c, int r)
{
	COLORREF col;

	if (c->r == r)
		return 0;

	if (r < 0)
		r = 0;

	if (r > 255)
		r = 255;

	c->r = r;

	col = RGBtoHSV(c->r, c->g, c->b);
	c->h = GetHValue(col);
	c->s = GetSValue(col);
	c->v = GetVValue(col);

	return 1;
}
示例#4
0
int SetColourB(Colour *c, int b)
{
	COLORREF col;

	if (c->b == b)
		return 0;

	if (b < 0)
		b = 0;

	if (b > 255)
		b = 255;

	c->b = b;

	col = RGBtoHSV(c->r, c->g, c->b);
	c->h = GetHValue(col);
	c->s = GetSValue(col);
	c->v = GetVValue(col);

	return 1;
}
示例#5
0
int SetColourG(Colour *c, int g)
{
	COLORREF col;

	if (c->g == g)
		return 0;

	if (g < 0)
		g = 0;

	if (g > 255)
		g = 255;

	c->g = g;

	col = RGBtoHSV(c->r, c->g, c->b);
	c->h = GetHValue(col);
	c->s = GetSValue(col);
	c->v = GetVValue(col);

	return 1;
}
示例#6
0
void QtPoint2D::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * /* widget */) 
{
	double level_of_detail = QStyleOptionGraphicsItem::levelOfDetailFromTransform(painter->worldTransform());
	
	DisplayProperties current_properties;

	// @fixme the way constraint_properties is defined in the following if statement block will prevent the user from changing the display properties of the point constraints at run time since the DisplayProperties constructor is used to set these properties
	DisplayProperties constraint_properties;

	if(option->state & QStyle::State_MouseOver && IsSelectable())
	{
		current_properties = GetMouseHoverProperties();
		constraint_properties = DisplayProperties(HoverAnnotation);
	} else if (option->state & QStyle::State_Selected) {
		current_properties = GetSelectedProperties();
		constraint_properties = DisplayProperties(SelectedAnnotation);
	} else {
		current_properties = GetProperties();
		constraint_properties = DisplayProperties(Annotation);
	}

	painter->setPen(current_properties.GetPen(level_of_detail));
	painter->setBrush(current_properties.GetBrush());	

	QPainterPath point_path;
	PaintPointAndSelectionPath(painter, option, GetSValue(), -GetTValue(),point_path);

	// if point is constrained, draw the constraints
	if(! SIsFree() || ! TIsFree())
	{
		painter->setPen(constraint_properties.GetPen(level_of_detail));
		painter->setBrush(constraint_properties.GetBrush());
		
		double radius = 5.0/level_of_detail;

		if((! SIsFree() && ! GetSDOF()->IsDependent() )  && (! TIsFree() && ! GetTDOF()->IsDependent() ))
		{
			QRectF rect(QPointF(GetSValue()-radius,-(GetTValue()-radius)),
			QPointF(GetSValue()+radius,-(GetTValue()+radius)));
			painter->setBrush(Qt::NoBrush);
			painter->drawEllipse(rect);

		} else if((! SIsFree() && ! GetSDOF()->IsDependent() )) {

			painter->drawLine(QPointF(GetSValue()-radius,-(GetTValue()-radius)),
			QPointF(GetSValue()-radius,-(GetTValue()+radius)));

			painter->drawLine(QPointF(GetSValue()+radius,-(GetTValue()-radius)),
			QPointF(GetSValue()+radius,-(GetTValue()+radius)));

		} else if((! TIsFree() && ! GetTDOF()->IsDependent() )) {

			painter->drawLine(QPointF(GetSValue()+radius,-(GetTValue()+radius)),
			QPointF(GetSValue()-radius,-(GetTValue()+radius)));

			painter->drawLine(QPointF(GetSValue()-radius,-(GetTValue()-radius)),
			QPointF(GetSValue()+radius,-(GetTValue()-radius)));
		}
	}
	

	current_shape_ = point_path;
}
示例#7
0
///////////////////////////////////////////////////////////////////////////////
// HSB --> RGB 
///////////////////////////////////////////////////////////////////////////////
Color HSBtoRGB (unsigned long hsb) 
{
	return HSBtoRGB (GetHValue (hsb), GetSValue (hsb), GetVValue (hsb));
}