parent
2885abb5a1
commit
c2191dd8d0
|
@ -92,6 +92,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
sceneDraw = new VMainGraphicsScene();
|
sceneDraw = new VMainGraphicsScene();
|
||||||
currentScene = sceneDraw;
|
currentScene = sceneDraw;
|
||||||
qApp->setCurrentScene(currentScene);
|
qApp->setCurrentScene(currentScene);
|
||||||
|
connect(this, &MainWindow::EnableItemMove, sceneDraw, &VMainGraphicsScene::EnableItemMove);
|
||||||
connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
|
connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
|
||||||
sceneDetails = new VMainGraphicsScene();
|
sceneDetails = new VMainGraphicsScene();
|
||||||
connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
|
connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
|
||||||
|
@ -244,7 +245,9 @@ void MainWindow::ActionNewPP()
|
||||||
sceneDraw->addItem(spoint);
|
sceneDraw->addItem(spoint);
|
||||||
ui->view->itemClicked(spoint);
|
ui->view->itemClicked(spoint);
|
||||||
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
|
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
|
||||||
|
connect(sceneDraw, &VMainGraphicsScene::DisableItem, spoint, &VToolSinglePoint::Disable);
|
||||||
connect(sceneDraw, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor);
|
connect(sceneDraw, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor);
|
||||||
|
connect(sceneDraw, &VMainGraphicsScene::EnableToolMove, spoint, &VToolSinglePoint::EnableToolMove);
|
||||||
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
||||||
SCASSERT(tools != nullptr);
|
SCASSERT(tools != nullptr);
|
||||||
tools->insert(id, spoint);
|
tools->insert(id, spoint);
|
||||||
|
@ -1046,114 +1049,75 @@ void MainWindow::CancelTool()
|
||||||
ui->actionArrowTool->setChecked(false);
|
ui->actionArrowTool->setChecked(false);
|
||||||
helpLabel->setText("");
|
helpLabel->setText("");
|
||||||
ui->actionStopTool->setEnabled(true);
|
ui->actionStopTool->setEnabled(true);
|
||||||
break;
|
emit EnableItemMove(false);
|
||||||
|
return;
|
||||||
case Tool::SinglePoint:
|
case Tool::SinglePoint:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
//Nothing to do here because we can't create this tool from main window.
|
//Nothing to do here because we can't create this tool from main window.
|
||||||
break;
|
break;
|
||||||
case Tool::EndLine:
|
case Tool::EndLine:
|
||||||
ui->toolButtonEndLine->setChecked(false);
|
ui->toolButtonEndLine->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::Line:
|
case Tool::Line:
|
||||||
ui->toolButtonLine->setChecked(false);
|
ui->toolButtonLine->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearFocus();
|
|
||||||
break;
|
break;
|
||||||
case Tool::AlongLine:
|
case Tool::AlongLine:
|
||||||
ui->toolButtonAlongLine->setChecked(false);
|
ui->toolButtonAlongLine->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::ShoulderPoint:
|
case Tool::ShoulderPoint:
|
||||||
ui->toolButtonShoulderPoint->setChecked(false);
|
ui->toolButtonShoulderPoint->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::Normal:
|
case Tool::Normal:
|
||||||
ui->toolButtonNormal->setChecked(false);
|
ui->toolButtonNormal->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::Bisector:
|
case Tool::Bisector:
|
||||||
ui->toolButtonBisector->setChecked(false);
|
ui->toolButtonBisector->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::LineIntersect:
|
case Tool::LineIntersect:
|
||||||
ui->toolButtonLineIntersect->setChecked(false);
|
ui->toolButtonLineIntersect->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::Spline:
|
case Tool::Spline:
|
||||||
ui->toolButtonSpline->setChecked(false);
|
ui->toolButtonSpline->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::Arc:
|
case Tool::Arc:
|
||||||
ui->toolButtonArc->setChecked(false);
|
ui->toolButtonArc->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::SplinePath:
|
case Tool::SplinePath:
|
||||||
ui->toolButtonSplinePath->setChecked(false);
|
ui->toolButtonSplinePath->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::PointOfContact:
|
case Tool::PointOfContact:
|
||||||
ui->toolButtonPointOfContact->setChecked(false);
|
ui->toolButtonPointOfContact->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::Detail:
|
case Tool::Detail:
|
||||||
ui->toolButtonNewDetail->setChecked(false);
|
ui->toolButtonNewDetail->setChecked(false);
|
||||||
break;
|
break;
|
||||||
case Tool::Height:
|
case Tool::Height:
|
||||||
ui->toolButtonHeight->setChecked(false);
|
ui->toolButtonHeight->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::Triangle:
|
case Tool::Triangle:
|
||||||
ui->toolButtonTriangle->setChecked(false);
|
ui->toolButtonTriangle->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::PointOfIntersection:
|
case Tool::PointOfIntersection:
|
||||||
ui->toolButtonPointOfIntersection->setChecked(false);
|
ui->toolButtonPointOfIntersection->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::CutSpline:
|
case Tool::CutSpline:
|
||||||
ui->toolButtonSplineCutPoint->setChecked(false);
|
ui->toolButtonSplineCutPoint->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::CutSplinePath:
|
case Tool::CutSplinePath:
|
||||||
ui->toolButtonSplinePathCutPoint->setChecked(false);
|
ui->toolButtonSplinePathCutPoint->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::UnionDetails:
|
case Tool::UnionDetails:
|
||||||
ui->toolButtonUnionDetails->setChecked(false);
|
ui->toolButtonUnionDetails->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::CutArc:
|
case Tool::CutArc:
|
||||||
ui->toolButtonArcCutPoint->setChecked(false);
|
ui->toolButtonArcCutPoint->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::LineIntersectAxis:
|
case Tool::LineIntersectAxis:
|
||||||
ui->toolButtonLineIntersectAxis->setChecked(false);
|
ui->toolButtonLineIntersectAxis->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::CurveIntersectAxis:
|
case Tool::CurveIntersectAxis:
|
||||||
ui->toolButtonCurveIntersectAxis->setChecked(false);
|
ui->toolButtonCurveIntersectAxis->setChecked(false);
|
||||||
ui->toolButtonArcIntersectAxis->setChecked(false);
|
ui->toolButtonArcIntersectAxis->setChecked(false);
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
break;
|
break;
|
||||||
case Tool::NodePoint:
|
case Tool::NodePoint:
|
||||||
case Tool::NodeArc:
|
case Tool::NodeArc:
|
||||||
|
@ -1163,6 +1127,9 @@ void MainWindow::CancelTool()
|
||||||
qDebug()<<"Got wrong tool type. Ignored.";
|
qDebug()<<"Got wrong tool type. Ignored.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
currentScene->setFocus(Qt::OtherFocusReason);
|
||||||
|
currentScene->clearSelection();
|
||||||
|
emit EnableItemMove(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -139,6 +139,7 @@ signals:
|
||||||
void ModelChosen(QVector<VLayoutDetail> listDetails, const QString &curFile,
|
void ModelChosen(QVector<VLayoutDetail> listDetails, const QString &curFile,
|
||||||
const QString &description);
|
const QString &description);
|
||||||
void RefreshHistory();
|
void RefreshHistory();
|
||||||
|
void EnableItemMove(bool move);
|
||||||
protected:
|
protected:
|
||||||
virtual void keyPressEvent(QKeyEvent *event);
|
virtual void keyPressEvent(QKeyEvent *event);
|
||||||
virtual void showEvent(QShowEvent *event);
|
virtual void showEvent(QShowEvent *event);
|
||||||
|
|
|
@ -206,6 +206,13 @@ void VDrawTool::SetFactor(qreal factor)
|
||||||
VApplication::CheckFactor(this->factor, factor);
|
VApplication::CheckFactor(this->factor, factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VDrawTool::EnableToolMove(bool move)
|
||||||
|
{
|
||||||
|
Q_UNUSED(move)
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief CheckFormula check formula.
|
* @brief CheckFormula check formula.
|
||||||
|
|
|
@ -69,6 +69,7 @@ public slots:
|
||||||
virtual void FullUpdateFromGuiOk(int result);
|
virtual void FullUpdateFromGuiOk(int result);
|
||||||
virtual void FullUpdateFromGuiApply();
|
virtual void FullUpdateFromGuiApply();
|
||||||
virtual void SetFactor(qreal factor);
|
virtual void SetFactor(qreal factor);
|
||||||
|
virtual void EnableToolMove(bool move);
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/** @brief ignoreFullUpdate ignore or not full updates. */
|
/** @brief ignoreFullUpdate ignore or not full updates. */
|
||||||
|
|
|
@ -216,6 +216,7 @@ void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
||||||
|
QGraphicsEllipseItem::hoverLeaveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -205,7 +205,10 @@ void VToolSinglePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
VToolPoint::hoverEnterEvent(event);
|
VToolPoint::hoverEnterEvent(event);
|
||||||
|
|
||||||
VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1);
|
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||||
|
{
|
||||||
|
VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -213,16 +216,22 @@ void VToolSinglePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
VToolPoint::hoverLeaveEvent(event);
|
VToolPoint::hoverLeaveEvent(event);
|
||||||
|
|
||||||
//Disable cursor-arrow-openhand
|
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||||
VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"));
|
{
|
||||||
|
//Disable cursor-arrow-openhand
|
||||||
|
VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||||
{
|
{
|
||||||
VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1);
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
|
{
|
||||||
|
VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
VToolPoint::mousePressEvent(event);
|
VToolPoint::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -230,10 +239,13 @@ void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||||
{
|
{
|
||||||
//Disable cursor-arrow-closehand
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"));
|
{
|
||||||
|
//Disable cursor-arrow-closehand
|
||||||
|
VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
VToolPoint::mouseReleaseEvent(event);
|
VToolPoint::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -332,3 +344,9 @@ void VToolSinglePoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
|
||||||
ContextMenu<DialogSinglePoint>(this, event, false);
|
ContextMenu<DialogSinglePoint>(this, event, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolSinglePoint::EnableToolMove(bool move)
|
||||||
|
{
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsMovable, move);
|
||||||
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ public slots:
|
||||||
virtual void FullUpdateFromFile();
|
virtual void FullUpdateFromFile();
|
||||||
virtual void SetFactor(qreal factor);
|
virtual void SetFactor(qreal factor);
|
||||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
|
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
|
||||||
|
virtual void EnableToolMove(bool move);
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* @brief FullUpdateTree handle if need update pattern file.
|
* @brief FullUpdateTree handle if need update pattern file.
|
||||||
|
|
|
@ -126,3 +126,9 @@ void VMainGraphicsScene::SetFactor(qreal factor)
|
||||||
scaleFactor=scaleFactor*factor;
|
scaleFactor=scaleFactor*factor;
|
||||||
emit NewFactor(scaleFactor);
|
emit NewFactor(scaleFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VMainGraphicsScene::EnableItemMove(bool move)
|
||||||
|
{
|
||||||
|
emit EnableToolMove(move);
|
||||||
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void ChoosedItem(quint32 id, const SceneObject &type);
|
void ChoosedItem(quint32 id, const SceneObject &type);
|
||||||
void SetFactor(qreal factor);
|
void SetFactor(qreal factor);
|
||||||
|
void EnableItemMove(bool move);
|
||||||
protected:
|
protected:
|
||||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
@ -78,6 +79,7 @@ signals:
|
||||||
*/
|
*/
|
||||||
void NewFactor(qreal factor);
|
void NewFactor(qreal factor);
|
||||||
void DisableItem(bool disable);
|
void DisableItem(bool disable);
|
||||||
|
void EnableToolMove(bool move);
|
||||||
private:
|
private:
|
||||||
/** @brief horScrollBar value horizontal scroll bar. */
|
/** @brief horScrollBar value horizontal scroll bar. */
|
||||||
qint32 horScrollBar;
|
qint32 horScrollBar;
|
||||||
|
|
|
@ -1163,6 +1163,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor);
|
||||||
connect(scene, &VMainGraphicsScene::DisableItem, spoint, &VToolSinglePoint::Disable);
|
connect(scene, &VMainGraphicsScene::DisableItem, spoint, &VToolSinglePoint::Disable);
|
||||||
|
connect(scene, &VMainGraphicsScene::EnableToolMove, spoint, &VToolSinglePoint::EnableToolMove);
|
||||||
tools[id] = spoint;
|
tools[id] = spoint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user