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

View File

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

View File

@ -803,6 +803,7 @@
<addaction name="actionZoomOriginal"/> <addaction name="actionZoomOriginal"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionLast_tool"/> <addaction name="actionLast_tool"/>
<addaction name="actionShowCurveDetails"/>
<addaction name="actionPattern_properties"/> <addaction name="actionPattern_properties"/>
<addaction name="actionEdit_pattern_code"/> <addaction name="actionEdit_pattern_code"/>
</widget> </widget>
@ -1356,6 +1357,23 @@
<string>L</string> <string>L</string>
</property> </property>
</action> </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> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<customwidgets> <customwidgets>

View File

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

View File

@ -52,6 +52,7 @@ public:
public slots: public slots:
virtual void FullUpdateFromFile (); virtual void FullUpdateFromFile ();
void Disable(bool disable); void Disable(bool disable);
void DetailsMode(bool mode);
signals: signals:
/** /**
* @brief RefreshLine refresh control line. * @brief RefreshLine refresh control line.
@ -74,6 +75,7 @@ protected:
QVector<VControlPointSpline *> controlPoints; QVector<VControlPointSpline *> controlPoints;
SceneObject sceneType; SceneObject sceneType;
bool isHovered; bool isHovered;
bool detailsMode;
/** /**
* @brief RefreshGeometry refresh item on scene. * @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, const quint32 &curveCutId, const quint32 &curve1id, const quint32 &curve2id, const QString &color,
QGraphicsItem *parent) QGraphicsItem *parent)
:VToolPoint(doc, data, id, parent), formula(formula), firstCurve(nullptr), secondCurve(nullptr), :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(curveCutId > 0, Q_FUNC_INFO, "curveCutId <= 0");
Q_ASSERT_X(curve1id > 0, Q_FUNC_INFO, "curve1id <= 0"); Q_ASSERT_X(curve1id > 0, Q_FUNC_INFO, "curve1id <= 0");
@ -85,6 +85,12 @@ void VToolCut::Disable(bool disable)
secondCurve->ChangedActivDraw(enabled); secondCurve->ChangedActivDraw(enabled);
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolCut::DetailsMode(bool mode)
{
detailsMode = mode;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
quint32 VToolCut::getCurveCutId() const quint32 VToolCut::getCurveCutId() const

View File

@ -54,6 +54,7 @@ public slots:
virtual void CurveChoosed(quint32 id)=0; virtual void CurveChoosed(quint32 id)=0;
void HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction); void HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction);
void Disable(bool disable); void Disable(bool disable);
void DetailsMode(bool mode);
protected: protected:
/** @brief formula keep formula of length */ /** @brief formula keep formula of length */
QString formula; QString formula;
@ -68,6 +69,8 @@ protected:
quint32 curve1id; quint32 curve1id;
quint32 curve2id; quint32 curve2id;
bool detailsMode;
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
PathDirection direction = PathDirection::Hide)=0; PathDirection direction = PathDirection::Hide)=0;
void RefreshGeometry(); 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::NewFactor, point, &VToolCutSpline::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSpline::Disable); connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSpline::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutSpline::EnableToolMove); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutSpline::EnableToolMove);
connect(scene, &VMainGraphicsScene::CurveDetailsMode, point, &VToolCutSpline::DetailsMode);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->AddTool(spl1id, point); doc->AddTool(spl1id, point);
doc->AddTool(spl2id, point); doc->AddTool(spl2id, point);
@ -226,7 +227,14 @@ void VToolCutSpline::ShowVisualization(bool show)
} }
if (VAbstractSpline *parentCurve = qobject_cast<VAbstractSpline *>(doc->getTool(curveCutId))) 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::NewFactor, point, &VToolCutSplinePath::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSplinePath::Disable); connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSplinePath::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutSplinePath::EnableToolMove); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutSplinePath::EnableToolMove);
connect(scene, &VMainGraphicsScene::CurveDetailsMode, point, &VToolCutSplinePath::DetailsMode);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->AddTool(splPath1id, point); doc->AddTool(splPath1id, point);
doc->AddTool(splPath2id, point); doc->AddTool(splPath2id, point);
@ -271,7 +272,14 @@ void VToolCutSplinePath::ShowVisualization(bool show)
} }
if (VAbstractSpline *parentCurve = qobject_cast<VAbstractSpline *>(doc->getTool(curveCutId))) 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::NewFactor, spl, &VToolSpline::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolSpline::Disable); connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolSpline::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, spl, &VToolSpline::EnableToolMove); connect(scene, &VMainGraphicsScene::EnableToolMove, spl, &VToolSpline::EnableToolMove);
connect(scene, &VMainGraphicsScene::CurveDetailsMode, spl, &VToolSpline::DetailsMode);
doc->AddTool(id, spl); doc->AddTool(id, spl);
doc->IncrementReferens(p1); doc->IncrementReferens(p1);
doc->IncrementReferens(p4); doc->IncrementReferens(p4);
@ -261,7 +262,15 @@ void VToolSpline::ShowVisualization(bool show)
delete vis; delete vis;
vis = nullptr; vis = nullptr;
} }
ShowHandles(show);
if (detailsMode)
{
ShowHandles(detailsMode);
}
else
{
ShowHandles(show);
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -484,7 +493,7 @@ void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void VToolSpline::RefreshGeometry() void VToolSpline::RefreshGeometry()
{ {
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor)); this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor));
if (isHovered) if (isHovered || detailsMode)
{ {
this->setPath(ToolPath(PathDirection::Show)); this->setPath(ToolPath(PathDirection::Show));
} }

View File

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

View File

@ -132,3 +132,9 @@ void VMainGraphicsScene::EnableItemMove(bool move)
{ {
emit EnableToolMove(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 ChoosedItem(quint32 id, const SceneObject &type);
void SetFactor(qreal factor); void SetFactor(qreal factor);
void EnableItemMove(bool move); void EnableItemMove(bool move);
void EnableDetailsMode(bool mode);
protected: protected:
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
@ -80,6 +81,7 @@ signals:
void NewFactor(qreal factor); void NewFactor(qreal factor);
void DisableItem(bool disable); void DisableItem(bool disable);
void EnableToolMove(bool move); void EnableToolMove(bool move);
void CurveDetailsMode(bool mode);
private: private:
/** @brief horScrollBar value horizontal scroll bar. */ /** @brief horScrollBar value horizontal scroll bar. */
qint32 horScrollBar; qint32 horScrollBar;