Resolved issue #275. Add 'Show Curve Details' icon on top menu bar to show/hide

control points and curve direction.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-04-23 18:06:17 +03:00
parent 768a5df031
commit 354ca935d2
13 changed files with 108 additions and 10 deletions

View file

@ -1479,6 +1479,7 @@ void MainWindow::Clear()
ui->actionTable->setEnabled(false);
ui->actionEdit_pattern_code->setEnabled(false);
ui->actionLast_tool->setEnabled(false);
ui->actionShowCurveDetails->setEnabled(false);
SetEnableTool(false);
qApp->setPatternUnit(Unit::Cm);
qApp->setPatternType(MeasurementsType::Individual);
@ -1669,6 +1670,7 @@ void MainWindow::SetEnabledGUI(bool enabled)
ui->actionTable->setEnabled(enabled);
ui->actionZoomFitBest->setEnabled(enabled);
ui->actionZoomOriginal->setEnabled(enabled);
ui->actionShowCurveDetails->setEnabled(enabled);
if (enabled)
{
@ -1839,6 +1841,7 @@ void MainWindow::SetEnableWidgets(bool enable)
ui->actionZoomOut->setEnabled(enable);
ui->actionZoomFitBest->setEnabled(enable);
ui->actionZoomOriginal->setEnabled(enable);
ui->actionShowCurveDetails->setEnabled(enable);
//Now we want allow user call context menu
ui->view->setEnabled(enable);
}
@ -1896,6 +1899,13 @@ void MainWindow::ActionHistory(bool checked)
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ActionDetailsMode(bool checked)
{
ui->view->itemClicked(nullptr);
sceneDraw->EnableDetailsMode(checked);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ActionLayout begin creation layout.
@ -2383,6 +2393,7 @@ void MainWindow::CreateActions()
ui->actionPattern_properties->setEnabled(false);
connect(ui->actionEdit_pattern_code, &QAction::triggered, this, &MainWindow::EditPatternCode);
connect(ui->actionCloseWindow, &QAction::triggered, this, &MainWindow::ResetWindow);
connect(ui->actionShowCurveDetails, &QAction::triggered, this, &MainWindow::ActionDetailsMode);
ui->actionEdit_pattern_code->setEnabled(false);
//Actions for recent files loaded by a main window application.

View file

@ -67,6 +67,7 @@ public slots:
void ActionLayout(bool checked);
void ActionTable(bool checked);
void ActionHistory(bool checked);
void ActionDetailsMode(bool checked);
void tableClosed();
void ClosedActionTable();

View file

@ -803,6 +803,7 @@
<addaction name="actionZoomOriginal"/>
<addaction name="separator"/>
<addaction name="actionLast_tool"/>
<addaction name="actionShowCurveDetails"/>
<addaction name="actionPattern_properties"/>
<addaction name="actionEdit_pattern_code"/>
</widget>
@ -1356,6 +1357,23 @@
<string>L</string>
</property>
</action>
<action name="actionShowCurveDetails">
<property name="checkable">
<bool>true</bool>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Show Curve Details</string>
</property>
<property name="toolTip">
<string>Show/hide control points and curve direction</string>
</property>
<property name="shortcut">
<string>F2</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>

View file

@ -34,7 +34,7 @@ const QString VAbstractSpline::TagName = QStringLiteral("spline");
//---------------------------------------------------------------------------------------------------------------------
VAbstractSpline::VAbstractSpline(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent)
:VDrawTool(doc, data, id), QGraphicsPathItem(parent), controlPoints(QVector<VControlPointSpline *>()),
sceneType(SceneObject::Unknown), isHovered(false)
sceneType(SceneObject::Unknown), isHovered(false), detailsMode(false)
{
ignoreFullUpdate = true;
}
@ -82,6 +82,14 @@ void VAbstractSpline::Disable(bool disable)
emit setEnabledPoint(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::DetailsMode(bool mode)
{
detailsMode = mode;
RefreshGeometry();
ShowHandles(detailsMode);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
@ -140,7 +148,14 @@ void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor));
this->setPath(ToolPath());
if (detailsMode)
{
this->setPath(ToolPath(PathDirection::Show));
}
else
{
this->setPath(ToolPath());
}
isHovered = false;
QGraphicsPathItem::hoverLeaveEvent(event);
}

View file

@ -52,6 +52,7 @@ public:
public slots:
virtual void FullUpdateFromFile ();
void Disable(bool disable);
void DetailsMode(bool mode);
signals:
/**
* @brief RefreshLine refresh control line.
@ -74,6 +75,7 @@ protected:
QVector<VControlPointSpline *> controlPoints;
SceneObject sceneType;
bool isHovered;
bool detailsMode;
/**
* @brief RefreshGeometry refresh item on scene.
*/

View file

@ -35,7 +35,7 @@ VToolCut::VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QSt
const quint32 &curveCutId, const quint32 &curve1id, const quint32 &curve2id, const QString &color,
QGraphicsItem *parent)
:VToolPoint(doc, data, id, parent), formula(formula), firstCurve(nullptr), secondCurve(nullptr),
curveCutId(curveCutId), curve1id(curve1id), curve2id(curve2id)
curveCutId(curveCutId), curve1id(curve1id), curve2id(curve2id), detailsMode(false)
{
Q_ASSERT_X(curveCutId > 0, Q_FUNC_INFO, "curveCutId <= 0");
Q_ASSERT_X(curve1id > 0, Q_FUNC_INFO, "curve1id <= 0");
@ -85,6 +85,12 @@ void VToolCut::Disable(bool disable)
secondCurve->ChangedActivDraw(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCut::DetailsMode(bool mode)
{
detailsMode = mode;
}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
quint32 VToolCut::getCurveCutId() const

View file

@ -54,6 +54,7 @@ public slots:
virtual void CurveChoosed(quint32 id)=0;
void HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction);
void Disable(bool disable);
void DetailsMode(bool mode);
protected:
/** @brief formula keep formula of length */
QString formula;
@ -68,6 +69,8 @@ protected:
quint32 curve1id;
quint32 curve2id;
bool detailsMode;
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
PathDirection direction = PathDirection::Hide)=0;
void RefreshGeometry();

View file

@ -184,6 +184,7 @@ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointNa
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutSpline::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSpline::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutSpline::EnableToolMove);
connect(scene, &VMainGraphicsScene::CurveDetailsMode, point, &VToolCutSpline::DetailsMode);
doc->AddTool(id, point);
doc->AddTool(spl1id, point);
doc->AddTool(spl2id, point);
@ -226,7 +227,14 @@ void VToolCutSpline::ShowVisualization(bool show)
}
if (VAbstractSpline *parentCurve = qobject_cast<VAbstractSpline *>(doc->getTool(curveCutId)))
{
parentCurve->ShowHandles(show);
if (detailsMode)
{
parentCurve->ShowHandles(detailsMode);
}
else
{
parentCurve->ShowHandles(show);
}
}
}

View file

@ -229,6 +229,7 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutSplinePath::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSplinePath::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutSplinePath::EnableToolMove);
connect(scene, &VMainGraphicsScene::CurveDetailsMode, point, &VToolCutSplinePath::DetailsMode);
doc->AddTool(id, point);
doc->AddTool(splPath1id, point);
doc->AddTool(splPath2id, point);
@ -271,7 +272,14 @@ void VToolCutSplinePath::ShowVisualization(bool show)
}
if (VAbstractSpline *parentCurve = qobject_cast<VAbstractSpline *>(doc->getTool(curveCutId)))
{
parentCurve->ShowHandles(show);
if (detailsMode)
{
parentCurve->ShowHandles(detailsMode);
}
else
{
parentCurve->ShowHandles(show);
}
}
}

View file

@ -201,6 +201,7 @@ VToolSpline* VToolSpline::Create(const quint32 _id, const quint32 &p1, const qui
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSpline::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolSpline::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, spl, &VToolSpline::EnableToolMove);
connect(scene, &VMainGraphicsScene::CurveDetailsMode, spl, &VToolSpline::DetailsMode);
doc->AddTool(id, spl);
doc->IncrementReferens(p1);
doc->IncrementReferens(p4);
@ -261,7 +262,15 @@ void VToolSpline::ShowVisualization(bool show)
delete vis;
vis = nullptr;
}
ShowHandles(show);
if (detailsMode)
{
ShowHandles(detailsMode);
}
else
{
ShowHandles(show);
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -484,7 +493,7 @@ void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void VToolSpline::RefreshGeometry()
{
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor));
if (isHovered)
if (isHovered || detailsMode)
{
this->setPath(ToolPath(PathDirection::Show));
}

View file

@ -85,7 +85,7 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co
controlPoints.append(controlPoint);
}
ShowHandlers(false);
ShowHandles(false);
if (typeCreation == Source::FromGui)
{
@ -178,6 +178,7 @@ VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, c
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSplinePath::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolSplinePath::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, spl, &VToolSplinePath::EnableToolMove);
connect(scene, &VMainGraphicsScene::CurveDetailsMode, spl, &VToolSplinePath::DetailsMode);
doc->AddTool(id, spl);
return spl;
}
@ -333,7 +334,15 @@ void VToolSplinePath::ShowVisualization(bool show)
delete vis;
vis = nullptr;
}
ShowHandlers(show);
if (detailsMode)
{
ShowHandles(detailsMode);
}
else
{
ShowHandles(show);
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -552,7 +561,7 @@ void VToolSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
*/
void VToolSplinePath::RefreshGeometry()
{
if (isHovered)
if (isHovered || detailsMode)
{
this->setPath(ToolPath(PathDirection::Show));
}

View file

@ -132,3 +132,9 @@ void VMainGraphicsScene::EnableItemMove(bool move)
{
emit EnableToolMove(move);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::EnableDetailsMode(bool mode)
{
emit CurveDetailsMode(mode);
}

View file

@ -53,6 +53,7 @@ public slots:
void ChoosedItem(quint32 id, const SceneObject &type);
void SetFactor(qreal factor);
void EnableItemMove(bool move);
void EnableDetailsMode(bool mode);
protected:
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
@ -80,6 +81,7 @@ signals:
void NewFactor(qreal factor);
void DisableItem(bool disable);
void EnableToolMove(bool move);
void CurveDetailsMode(bool mode);
private:
/** @brief horScrollBar value horizontal scroll bar. */
qint32 horScrollBar;