Exemplo n.º 1
0
void BinaryOutputElement::setInputSize(int inputs)
{
	if(aligment == Vertical){
		intRect = QRectF(5, 5, 9, inputs*7 + 2);
		setContainerRect(intRect.adjusted(-5, -5, 5, 5));
	}else{
		intRect = QRectF(5, 5, inputs*7 + 2, 9);
		setContainerRect(intRect.adjusted(-5, -5, 5, 5));
	}
	this->inputs.resize(inputs);
	update();
}
Exemplo n.º 2
0
void core::DotMatrix::init(int dotSize, int rows, int cols, DataFormat dt)
{
	this->size = dotSize;

	//QActions
	continuousDrawingAction = new QAction(ICON_FREEHAND, "Dibujo continuo", this);
	clearAction = new QAction(ICON_CLEAR, "Limpiar", this);
	fillAction = new QAction(ICON_FILL, "Llenar", this);
	eraserAction = new QAction(ICON_ERASER, "Borrador", this);

	continuousDrawingAction->setCheckable(true);
	eraserAction->setCheckable(true);

	contextMenu.insertAction(getLockAction(), continuousDrawingAction);
	contextMenu.insertAction(continuousDrawingAction, fillAction);
	contextMenu.insertAction(fillAction, clearAction);
	contextMenu.insertAction(clearAction, eraserAction);

	setEnableContinuousDrawing(true);
	setEnableEraserPen(false);

	setRows(rows);
	setCols(cols);

	setEnableEdit(true);
	setBorder(QPen(Qt::black, 1));
	setContainerRect(getContainer());
	setDataType(dt);

	connect(continuousDrawingAction, SIGNAL(triggered(bool)), SLOT(setEnableContinuousDrawing(bool)));
	connect(clearAction, SIGNAL(triggered()), SLOT(clear()));
	connect(fillAction, SIGNAL(triggered()), SLOT(fill()));
	connect(eraserAction, SIGNAL(triggered(bool)), SLOT(setEnableEraserPen(bool)));
}
Exemplo n.º 3
0
void core::Connector::setEndObject(GraphicObject *end)
{
	if(!end) return;

	endObject = end;

//	qDebug() << currentMousePos;
	//we use currentMousePos instead internal currentMousePos from "end" object due update mouse position problems
	//there are conflicts when moving mouse so using this currentMousePos ensures mouse pos is always updated

//	qDebug() << portRect;
	endPoint = mapFromItem(end, end->getCurrentPortPos(mapToItem(end, currentMousePos)));
	isBuildingConector = false;
//	qDebug() << portCenter;

	QRectF container = getContainerRect();


	if(currentMousePos.x() < 0 && currentMousePos.y() < 0){
		container.setTopLeft(endPoint );
	}else if(currentMousePos.x() < 0 && currentMousePos.y() >= 0){
		container.setBottomLeft(endPoint );
	}else if(currentMousePos.x() >= 0 && currentMousePos.y() < 0){
		container.setTopRight(endPoint );
	}else if(currentMousePos.x() >= 0 && currentMousePos.y() >= 0){
		container.setBottomRight(endPoint );
	}else{
		container= QRectF(0, 0, 0, 0);
	}

	setContainerRect(container);
}
Exemplo n.º 4
0
void core::DotMatrix::setCols(int value)
{
	if(cols != value){
		cols = value;

		updateDotList();
		setContainerRect(getContainer());
		update();

		emit colCountChanged(value);
	}
}
Exemplo n.º 5
0
void core::DotMatrix::setDotSize(int size)
{
	if(this->size != size){
		this->size = size;

		setContainerRect(getContainer());

		update();

		emit dotSizeChanged(size);
	}
}
Exemplo n.º 6
0
void core::DotMatrix::setRows(int value)
{
	if(rows != value){
		rows = value;

		updateDotList();
		setContainerRect(getContainer());
		update();

		emit rowCountChanged(value);
	}
}
Exemplo n.º 7
0
void core::DotMatrix::setMatrixSize(const QSize &size)
{
	if(rows != size.height() || cols != size.width()){
		rows = size.height();
		cols = size.width();

		setContainerRect(getContainer());
		updateDotList();

		update(getContainerRect());

		emit matrixSizeChanged(size);
	}
}
Exemplo n.º 8
0
void core::DotMatrix::setInputs(const vector<double> &inputs)
{
	GraphicObject::setInputs(inputs);
	setInputsSize((int)inputs.size());

	updateDotList();

	setContainerRect(getContainer());

	vector<int> intInputs(inputs.begin(), inputs.end());

	update();

	emit statusChanged(QVector<int>::fromStdVector(intInputs));
}
Exemplo n.º 9
0
void core::Connector::init(GraphicObject *begin, GraphicObject *end)
{
	clearance = 10;

	beginObject = begin;
	endObject = end;

	isBuildingConector = false;

	getSaveAction()->setVisible(false);
	getOpenAction()->setVisible(false);
	getCopyAction()->setVisible(false);
	getCutAction()->setVisible(false);
	getPasteAction()->setVisible(false);

	setContainerRect(QRectF(0, 0, 0, 0));
	setObjectLocked(true);
}
Exemplo n.º 10
0
bool core::Connector::eventFilter(QObject *sender, QEvent *event)
{
//	qDebug () << event->type();
	if(event->type() == QEvent::MouseMove){
		QMouseEvent *hEvent = (QMouseEvent*)event;

		GraphicDetailedView *gdv = (GraphicDetailedView*)sender;

		QPointF pos = mapFromScene(gdv->mapToScene(hEvent->pos()));
		currentMousePos = pos;

//		qDebug() << currentMousePos << "<< currentMousePos";

		QRectF container = getContainerRect();

		if(pos.x() < 0 && pos.y() < 0){
			container.setTopLeft(pos);
			container.setBottomRight(QPointF(0, 0));
		}else if(pos.x() < 0 && pos.y() >= 0){
			container.setBottomLeft(pos);
			container.setTopRight(QPointF(0, 0));
		}else if(pos.x() >= 0 && pos.y() < 0){
			container.setTopRight(pos);
			container.setBottomLeft(QPointF(0, 0));
		}else if(pos.x() >= 0 && pos.y() >= 0){
			container.setBottomRight(pos);
			container.setTopLeft(QPointF(0, 0));
		}else{
			container= QRectF(0, 0, 0, 0);
		}

		setContainerRect(container);

		if(isBuildingConector){
			updateConectorLine(beginPoint, pos);
		}

		return true;
	}

	return GraphicObject::eventFilter(sender, event);
}
Exemplo n.º 11
0
void core::ImageEffect::updateImage()
{
	minImage = modImage.scaled(50, 50, Qt::KeepAspectRatio/*, Qt::SmoothTransformation*/);
	setContainerRect(minImage.rect());
	update();
}