Example #1
0
void InstrumentWindowMaskTab::init()
{
  connect(m_instrumentDisplay->getSurface(),SIGNAL(shapeCreated()),this,SLOT(shapeCreated()));
  connect(m_instrumentDisplay->getSurface(),SIGNAL(shapeSelected()),this,SLOT(shapeSelected()));
  connect(m_instrumentDisplay->getSurface(),SIGNAL(shapesDeselected()),this,SLOT(shapesDeselected()));
  connect(m_instrumentDisplay->getSurface(),SIGNAL(shapeChanged()),this,SLOT(shapeChanged()));
}
/**
  * Initialize the tab when new projection surface is created.
  */
void InstrumentWindowMaskTab::initSurface()
{
  connect(m_instrWindow->getSurface().get(),SIGNAL(shapeCreated()),this,SLOT(shapeCreated()));
  connect(m_instrWindow->getSurface().get(),SIGNAL(shapeSelected()),this,SLOT(shapeSelected()));
  connect(m_instrWindow->getSurface().get(),SIGNAL(shapesDeselected()),this,SLOT(shapesDeselected()));
  connect(m_instrWindow->getSurface().get(),SIGNAL(shapeChanged()),this,SLOT(shapeChanged()));
  connect(m_instrWindow->getSurface().get(),SIGNAL(shapesCleared()),this,SLOT(shapesCleared()));
  enableApplyButtons();
}
Example #3
0
void CMindMapUiShapeList::onActionTriggered(QAction *act)
{
	int				i = 0;

	for (i = 0; i < m_actions.length(); ++i)
	{
		if (act == m_actions[i])
			break;
	}

    emit shapeSelected( act->data().toInt() );
}
Example #4
0
void CanvasWidget::mousePressEvent(QMouseEvent *event) {

    pressedPoint.x = event->localPos().x();
    pressedPoint.y = event->localPos().y();

    selected = NULL;
    transformation = NONE;
    for(unsigned i = shapes.size(); i > 0; i--) {
        if(shapes[i - 1]->belongs(pressedPoint)) {
            //Нажали на фигуру
            toFront(i - 1); //переместилю фигуру вперед
            selected = shapes[shapes.size() - 1]; //Запоминаем последню выбранную фигуры
            if (selected != NULL && selectedShapes.size() == 1)
                emit shapeSelected(selected->getType());
            //Проверяем нажатие на контроллер масштабирования (левый верхний)
            if(selected->isTopLeft(pressedPoint, epsilon)) {
                topLeftResize = true;
            } else if(selected->isBottomRight(pressedPoint, epsilon)) {
                bottomRightResize = true;
            } else if(selected->isBottomLeft(pressedPoint, epsilon)) {
               bottomLeftResize = true;
            } else if(selected->isTopRight(pressedPoint, epsilon)) {
               topRightResize = true;
                // transformation = LEFT_RESIZE;
            }

            if (transformation == LEFT_RESIZE || transformation == RIGHT_RESIZE) //Оставляем только одну выделенную фигуру6 которую хотим масштабировать
                clearSelectedShapes();
            if (havingShapeInSelectedShapes(selected))
                transformation = MOVING;
             insertShapeInSelectedShapes(selected);

            if(selected->getType() == 2) {
                if(((QtParallelogram*)selected)->isControlPoint(pressedPoint, epsilon)) {
                    controlPointModify = true;
                }
            }

            pressedPoint -= selected->getCenter();
            break;
        }
    }
}
Example #5
0
//! [0]
Window::Window()
{
    originalRenderArea = new RenderArea;

    shapeComboBox = new QComboBox;
    shapeComboBox->addItem(tr("Clock"));
    shapeComboBox->addItem(tr("House"));
    shapeComboBox->addItem(tr("Text"));
    shapeComboBox->addItem(tr("Truck"));

    QGridLayout *layout = new QGridLayout;
    layout->addWidget(originalRenderArea, 0, 0);
    layout->addWidget(shapeComboBox, 1, 0);
//! [0]

//! [1]
    for (int i = 0; i < NumTransformedAreas; ++i) {
        transformedRenderAreas[i] = new RenderArea;

        operationComboBoxes[i] = new QComboBox;
        operationComboBoxes[i]->addItem(tr("No transformation"));
        operationComboBoxes[i]->addItem(tr("Rotate by 60\xB0"));
        operationComboBoxes[i]->addItem(tr("Scale to 75%"));
        operationComboBoxes[i]->addItem(tr("Translate by (50, 50)"));

        connect(operationComboBoxes[i], SIGNAL(activated(int)),
                this, SLOT(operationChanged()));

        layout->addWidget(transformedRenderAreas[i], 0, i + 1);
        layout->addWidget(operationComboBoxes[i], 1, i + 1);
    }
//! [1]

//! [2]
    setLayout(layout);
    setupShapes();
    shapeSelected(0);

    setWindowTitle(tr("Transformations"));
}
Example #6
0
void CanvasWidget::mouseReleaseEvent(QMouseEvent *)
{
    if (selected == NULL) { //Нажатие на пустую область. Снимаем выдиление
        clearSelectedShapes();
    }
    if (transformation == MOVING) {}
    else if(transformation == CREATING or !isKeyPressed(Qt::Key_Control) and selected != NULL) { //Оставляем 1 выделенную фигуру: конец создания фигуры, нажатие без Ctrl
        clearSelectedShapes();
        insertShapeInSelectedShapes(selected);
        if (selected != NULL && selectedShapes.size() == 1)
            emit shapeSelected(selected->getType());
    }

    update();

    topLeftResize = false;
    bottomRightResize = false;
    topRightResize = false;
    bottomLeftResize = false;


    controlPointModify = false;
    selected = NULL;
}