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