Visualization for VToolLineIntersect.
--HG-- branch : develop
This commit is contained in:
parent
f055c74944
commit
3f582123db
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
#include "../../geometry/vpointf.h"
|
#include "../../geometry/vpointf.h"
|
||||||
#include "../../container/vcontainer.h"
|
#include "../../container/vcontainer.h"
|
||||||
|
#include "../../visualization/vistoollineintersect.h"
|
||||||
|
#include "../../widgets/vmaingraphicsscene.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -40,11 +42,11 @@
|
||||||
*/
|
*/
|
||||||
DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()),
|
:DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()),
|
||||||
p1Line1(0), p2Line1(0), p1Line2(0), p2Line2(0), flagPoint(true)
|
p1Line1(0), p2Line1(0), p1Line2(0), p2Line2(0), flagPoint(true), line(nullptr)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
number = 0;
|
number = 0;
|
||||||
InitOkCancel(ui);
|
InitOkCancelApply(ui);
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
labelEditNamePoint = ui->labelEditNamePoint;
|
||||||
flagName = false;
|
flagName = false;
|
||||||
|
|
||||||
|
@ -62,11 +64,14 @@ DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &
|
||||||
this, &DialogLineIntersect::PointNameChanged);
|
this, &DialogLineIntersect::PointNameChanged);
|
||||||
connect(ui->comboBoxP2Line2, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxP2Line2, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogLineIntersect::PointNameChanged);
|
this, &DialogLineIntersect::PointNameChanged);
|
||||||
|
|
||||||
|
line = new VisToolLineIntersect(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogLineIntersect::~DialogLineIntersect()
|
DialogLineIntersect::~DialogLineIntersect()
|
||||||
{
|
{
|
||||||
|
delete line;
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +94,7 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
ui->comboBoxP1Line1->setCurrentIndex(index);
|
ui->comboBoxP1Line1->setCurrentIndex(index);
|
||||||
p1Line1 = id;
|
p1Line1 = id;
|
||||||
number++;
|
number++;
|
||||||
|
line->VisualMode(id);
|
||||||
emit ToolTip(tr("Select second point of first line"));
|
emit ToolTip(tr("Select second point of first line"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -101,6 +107,8 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
ui->comboBoxP2Line1->setCurrentIndex(index);
|
ui->comboBoxP2Line1->setCurrentIndex(index);
|
||||||
p2Line1 = id;
|
p2Line1 = id;
|
||||||
number++;
|
number++;
|
||||||
|
line->setLine1P2Id(p2Line1);
|
||||||
|
line->RefreshGeometry();
|
||||||
emit ToolTip(tr("Select first point of second line"));
|
emit ToolTip(tr("Select first point of second line"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -113,6 +121,8 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
ui->comboBoxP1Line2->setCurrentIndex(index);
|
ui->comboBoxP1Line2->setCurrentIndex(index);
|
||||||
p1Line2 = id;
|
p1Line2 = id;
|
||||||
number++;
|
number++;
|
||||||
|
line->setLine2P1Id(p1Line2);
|
||||||
|
line->RefreshGeometry();
|
||||||
emit ToolTip(tr("Select second point of second line"));
|
emit ToolTip(tr("Select second point of second line"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -125,6 +135,9 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
ui->comboBoxP2Line2->setCurrentIndex(index);
|
ui->comboBoxP2Line2->setCurrentIndex(index);
|
||||||
p2Line2 = id;
|
p2Line2 = id;
|
||||||
number = 0;
|
number = 0;
|
||||||
|
line->setLine2P2Id(p2Line2);
|
||||||
|
line->RefreshGeometry();
|
||||||
|
prepare = true;
|
||||||
emit ToolTip("");
|
emit ToolTip("");
|
||||||
}
|
}
|
||||||
if (isInitialized == false)
|
if (isInitialized == false)
|
||||||
|
@ -158,6 +171,12 @@ void DialogLineIntersect::SaveData()
|
||||||
p2Line1 = getCurrentObjectId(ui->comboBoxP2Line1);
|
p2Line1 = getCurrentObjectId(ui->comboBoxP2Line1);
|
||||||
p1Line2 = getCurrentObjectId(ui->comboBoxP1Line2);
|
p1Line2 = getCurrentObjectId(ui->comboBoxP1Line2);
|
||||||
p2Line2 = getCurrentObjectId(ui->comboBoxP2Line2);
|
p2Line2 = getCurrentObjectId(ui->comboBoxP2Line2);
|
||||||
|
|
||||||
|
line->setPoint1Id(p1Line1);
|
||||||
|
line->setLine1P2Id(p2Line1);
|
||||||
|
line->setLine2P1Id(p1Line2);
|
||||||
|
line->setLine2P2Id(p2Line2);
|
||||||
|
line->RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -170,6 +189,8 @@ void DialogLineIntersect::P1Line1Changed( int index)
|
||||||
p1Line1 = qvariant_cast<quint32>(ui->comboBoxP1Line1->itemData(index));
|
p1Line1 = qvariant_cast<quint32>(ui->comboBoxP1Line1->itemData(index));
|
||||||
flagPoint = CheckIntersecion();
|
flagPoint = CheckIntersecion();
|
||||||
CheckState();
|
CheckState();
|
||||||
|
|
||||||
|
line->setPoint1Id(p1Line1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -182,6 +203,8 @@ void DialogLineIntersect::P2Line1Changed(int index)
|
||||||
p2Line1 = qvariant_cast<quint32>(ui->comboBoxP2Line1->itemData(index));
|
p2Line1 = qvariant_cast<quint32>(ui->comboBoxP2Line1->itemData(index));
|
||||||
flagPoint = CheckIntersecion();
|
flagPoint = CheckIntersecion();
|
||||||
CheckState();
|
CheckState();
|
||||||
|
|
||||||
|
line->setLine1P2Id(p2Line1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -194,6 +217,8 @@ void DialogLineIntersect::P1Line2Changed(int index)
|
||||||
p1Line2 = qvariant_cast<quint32>(ui->comboBoxP1Line2->itemData(index));
|
p1Line2 = qvariant_cast<quint32>(ui->comboBoxP1Line2->itemData(index));
|
||||||
flagPoint = CheckIntersecion();
|
flagPoint = CheckIntersecion();
|
||||||
CheckState();
|
CheckState();
|
||||||
|
|
||||||
|
line->setLine2P1Id(p1Line2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -206,6 +231,8 @@ void DialogLineIntersect::P2Line2Changed(int index)
|
||||||
p2Line2 = qvariant_cast<quint32>(ui->comboBoxP2Line2->itemData(index));
|
p2Line2 = qvariant_cast<quint32>(ui->comboBoxP2Line2->itemData(index));
|
||||||
flagPoint = CheckIntersecion();
|
flagPoint = CheckIntersecion();
|
||||||
CheckState();
|
CheckState();
|
||||||
|
|
||||||
|
line->setLine2P2Id(p2Line2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -259,6 +286,18 @@ void DialogLineIntersect::UpdateList()
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogLineIntersect::ShowVisualization()
|
||||||
|
{
|
||||||
|
if (prepare == false)
|
||||||
|
{
|
||||||
|
VMainGraphicsScene *scene = qApp->getCurrentScene();
|
||||||
|
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor);
|
||||||
|
scene->addItem(line);
|
||||||
|
line->RefreshGeometry();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief CheckState check state of dialog. Enable or disable button ok.
|
* @brief CheckState check state of dialog. Enable or disable button ok.
|
||||||
|
@ -303,6 +342,7 @@ bool DialogLineIntersect::CheckIntersecion()
|
||||||
void DialogLineIntersect::setP2Line2(const quint32 &value)
|
void DialogLineIntersect::setP2Line2(const quint32 &value)
|
||||||
{
|
{
|
||||||
setPointId(ui->comboBoxP2Line2, p2Line2, value);
|
setPointId(ui->comboBoxP2Line2, p2Line2, value);
|
||||||
|
line->setLine2P2Id(p2Line2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -313,6 +353,7 @@ void DialogLineIntersect::setP2Line2(const quint32 &value)
|
||||||
void DialogLineIntersect::setP1Line2(const quint32 &value)
|
void DialogLineIntersect::setP1Line2(const quint32 &value)
|
||||||
{
|
{
|
||||||
setPointId(ui->comboBoxP1Line2, p1Line2, value);
|
setPointId(ui->comboBoxP1Line2, p1Line2, value);
|
||||||
|
line->setLine2P1Id(p1Line2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -323,6 +364,7 @@ void DialogLineIntersect::setP1Line2(const quint32 &value)
|
||||||
void DialogLineIntersect::setP2Line1(const quint32 &value)
|
void DialogLineIntersect::setP2Line1(const quint32 &value)
|
||||||
{
|
{
|
||||||
setPointId(ui->comboBoxP2Line1, p2Line1, value);
|
setPointId(ui->comboBoxP2Line1, p2Line1, value);
|
||||||
|
line->setLine1P2Id(p2Line1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -333,6 +375,7 @@ void DialogLineIntersect::setP2Line1(const quint32 &value)
|
||||||
void DialogLineIntersect::setP1Line1(const quint32 &value)
|
void DialogLineIntersect::setP1Line1(const quint32 &value)
|
||||||
{
|
{
|
||||||
setPointId(ui->comboBoxP1Line1, p1Line1, value);
|
setPointId(ui->comboBoxP1Line1, p1Line1, value);
|
||||||
|
line->setPoint1Id(p1Line1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -36,6 +36,8 @@ namespace Ui
|
||||||
class DialogLineIntersect;
|
class DialogLineIntersect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class VisToolLineIntersect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The DialogLineIntersect class dialog for ToolLineIntersect. Help create point and edit option.
|
* @brief The DialogLineIntersect class dialog for ToolLineIntersect. Help create point and edit option.
|
||||||
*/
|
*/
|
||||||
|
@ -69,6 +71,7 @@ public slots:
|
||||||
virtual void PointNameChanged();
|
virtual void PointNameChanged();
|
||||||
virtual void UpdateList();
|
virtual void UpdateList();
|
||||||
protected:
|
protected:
|
||||||
|
virtual void ShowVisualization();
|
||||||
/**
|
/**
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
|
@ -100,6 +103,8 @@ private:
|
||||||
/** @brief flagPoint keep state of point */
|
/** @brief flagPoint keep state of point */
|
||||||
bool flagPoint;
|
bool flagPoint;
|
||||||
|
|
||||||
|
VisToolLineIntersect *line;
|
||||||
|
|
||||||
virtual void CheckState();
|
virtual void CheckState();
|
||||||
bool CheckIntersecion();
|
bool CheckIntersecion();
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>370</width>
|
<width>367</width>
|
||||||
<height>196</height>
|
<height>196</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -158,7 +158,7 @@
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -460,9 +460,10 @@ void MainWindow::ToolBisector(bool checked)
|
||||||
*/
|
*/
|
||||||
void MainWindow::ToolLineIntersect(bool checked)
|
void MainWindow::ToolLineIntersect(bool checked)
|
||||||
{
|
{
|
||||||
SetToolButton<DialogLineIntersect>(checked, Tool::LineIntersectTool, ":/cursor/intersect_cursor.png",
|
SetToolButtonWithApply<DialogLineIntersect>(checked, Tool::LineIntersectTool, ":/cursor/intersect_cursor.png",
|
||||||
tr("Select first point of first line"),
|
tr("Select first point of first line"),
|
||||||
&MainWindow::ClosedDialog<VToolLineIntersect>);
|
&MainWindow::ClosedDialogWithApply<VToolLineIntersect>,
|
||||||
|
&MainWindow::ApplyDialog<VToolLineIntersect>);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -87,8 +87,10 @@ void VToolLineIntersect::setDialog()
|
||||||
* @param scene pointer to scene.
|
* @param scene pointer to scene.
|
||||||
* @param doc dom document container.
|
* @param doc dom document container.
|
||||||
* @param data container with variables.
|
* @param data container with variables.
|
||||||
|
* @return the created tool
|
||||||
*/
|
*/
|
||||||
void VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
|
VToolLineIntersect* VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
|
||||||
|
VContainer *data)
|
||||||
{
|
{
|
||||||
SCASSERT(dialog != nullptr);
|
SCASSERT(dialog != nullptr);
|
||||||
DialogLineIntersect *dialogTool = qobject_cast<DialogLineIntersect*>(dialog);
|
DialogLineIntersect *dialogTool = qobject_cast<DialogLineIntersect*>(dialog);
|
||||||
|
@ -98,8 +100,14 @@ void VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
|
||||||
const quint32 p1Line2Id = dialogTool->getP1Line2();
|
const quint32 p1Line2Id = dialogTool->getP1Line2();
|
||||||
const quint32 p2Line2Id = dialogTool->getP2Line2();
|
const quint32 p2Line2Id = dialogTool->getP2Line2();
|
||||||
const QString pointName = dialogTool->getPointName();
|
const QString pointName = dialogTool->getPointName();
|
||||||
Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, scene, doc, data,
|
VToolLineIntersect* point = nullptr;
|
||||||
Document::FullParse, Source::FromGui);
|
point = Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, scene, doc, data,
|
||||||
|
Document::FullParse, Source::FromGui);
|
||||||
|
if (point != nullptr)
|
||||||
|
{
|
||||||
|
point->dialog=dialogTool;
|
||||||
|
}
|
||||||
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -118,12 +126,13 @@ void VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
|
||||||
* @param data container with variables.
|
* @param data container with variables.
|
||||||
* @param parse parser file mode.
|
* @param parse parser file mode.
|
||||||
* @param typeCreation way we create this tool.
|
* @param typeCreation way we create this tool.
|
||||||
|
* @return the created tool
|
||||||
*/
|
*/
|
||||||
void VToolLineIntersect::Create(const quint32 _id, const quint32 &p1Line1Id, const quint32 &p2Line1Id,
|
VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32 &p1Line1Id, const quint32 &p2Line1Id,
|
||||||
const quint32 &p1Line2Id, const quint32 &p2Line2Id, const QString &pointName,
|
const quint32 &p1Line2Id, const quint32 &p2Line2Id,
|
||||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
const QString &pointName, const qreal &mx, const qreal &my,
|
||||||
VPattern *doc, VContainer *data, const Document &parse,
|
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
|
||||||
const Source &typeCreation)
|
const Document &parse, const Source &typeCreation)
|
||||||
{
|
{
|
||||||
const VPointF *p1Line1 = data->GeometricObject<const VPointF *>(p1Line1Id);
|
const VPointF *p1Line1 = data->GeometricObject<const VPointF *>(p1Line1Id);
|
||||||
const VPointF *p2Line1 = data->GeometricObject<const VPointF *>(p2Line1Id);
|
const VPointF *p2Line1 = data->GeometricObject<const VPointF *>(p2Line1Id);
|
||||||
|
@ -171,8 +180,10 @@ void VToolLineIntersect::Create(const quint32 _id, const quint32 &p1Line1Id, con
|
||||||
doc->IncrementReferens(p2Line1Id);
|
doc->IncrementReferens(p2Line1Id);
|
||||||
doc->IncrementReferens(p1Line2Id);
|
doc->IncrementReferens(p1Line2Id);
|
||||||
doc->IncrementReferens(p2Line2Id);
|
doc->IncrementReferens(p2Line2Id);
|
||||||
|
return point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -42,11 +42,11 @@ public:
|
||||||
const quint32 &p2Line1, const quint32 &p1Line2, const quint32 &p2Line2,
|
const quint32 &p2Line1, const quint32 &p1Line2, const quint32 &p2Line2,
|
||||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||||
virtual void setDialog();
|
virtual void setDialog();
|
||||||
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
|
static VToolLineIntersect *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
|
||||||
static void Create(const quint32 _id, const quint32 &p1Line1Id, const quint32 &p2Line1Id, const quint32 &p1Line2Id,
|
static VToolLineIntersect *Create(const quint32 _id, const quint32 &p1Line1Id, const quint32 &p2Line1Id,
|
||||||
const quint32 &p2Line2Id, const QString &pointName, const qreal &mx, const qreal &my,
|
const quint32 &p1Line2Id, const quint32 &p2Line2Id, const QString &pointName,
|
||||||
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
|
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
|
||||||
const Document &parse, const Source &typeCreation);
|
VContainer *data, const Document &parse, const Source &typeCreation);
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile();
|
virtual void FullUpdateFromFile();
|
||||||
|
|
130
src/app/visualization/vistoollineintersect.cpp
Normal file
130
src/app/visualization/vistoollineintersect.cpp
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vistoollineintersect.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 14 8, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2014 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "vistoollineintersect.h"
|
||||||
|
#include "../geometry/vpointf.h"
|
||||||
|
#include "../container/vcontainer.h"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VisToolLineIntersect::VisToolLineIntersect(const VContainer *data, QGraphicsItem *parent)
|
||||||
|
:VisLine(data, parent), line1P2Id(0), line2P1Id(0), line2P2Id(0), point(nullptr), line1P1(nullptr),
|
||||||
|
line1P2(nullptr), line1(nullptr), line2P1(nullptr), line2P2(nullptr)
|
||||||
|
{
|
||||||
|
line1P1 = InitPoint(supportColor);
|
||||||
|
line1P2 = InitPoint(supportColor);
|
||||||
|
line1 = InitItem<QGraphicsLineItem>(supportColor);
|
||||||
|
|
||||||
|
line2P1 = InitPoint(supportColor);
|
||||||
|
line2P2 = InitPoint(supportColor);
|
||||||
|
|
||||||
|
point = InitPoint(mainColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VisToolLineIntersect::~VisToolLineIntersect()
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VisToolLineIntersect::RefreshGeometry()
|
||||||
|
{
|
||||||
|
if (point1Id > 0)
|
||||||
|
{
|
||||||
|
const VPointF *first = data->GeometricObject<const VPointF *>(point1Id);
|
||||||
|
DrawPoint(line1P1, first->toQPointF(), supportColor);
|
||||||
|
|
||||||
|
if (line1P2Id <= 0)
|
||||||
|
{
|
||||||
|
DrawLine(line1, QLineF(first->toQPointF(), scenePos), supportColor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const VPointF *second = data->GeometricObject<const VPointF *>(line1P2Id);
|
||||||
|
DrawPoint(line1P2, second->toQPointF(), supportColor);
|
||||||
|
|
||||||
|
DrawLine(line1, QLineF(first->toQPointF(), second->toQPointF()), supportColor);
|
||||||
|
|
||||||
|
if (line2P1Id <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const VPointF *third = data->GeometricObject<const VPointF *>(line2P1Id);
|
||||||
|
DrawPoint(line2P1, third->toQPointF(), supportColor);
|
||||||
|
|
||||||
|
if (line2P2Id <= 0)
|
||||||
|
{
|
||||||
|
DrawLine(this, QLineF(third->toQPointF(), scenePos), supportColor);
|
||||||
|
|
||||||
|
QLineF l1(first->toQPointF(), second->toQPointF());
|
||||||
|
QLineF l2(third->toQPointF(), scenePos);
|
||||||
|
QPointF fPoint;
|
||||||
|
QLineF::IntersectType intersect = l1.intersect(l2, &fPoint);
|
||||||
|
if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
|
||||||
|
{
|
||||||
|
DrawPoint(point, fPoint, mainColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const VPointF *forth = data->GeometricObject<const VPointF *>(line2P2Id);
|
||||||
|
DrawPoint(line2P2, forth->toQPointF(), supportColor);
|
||||||
|
|
||||||
|
DrawLine(this, QLineF(third->toQPointF(), forth->toQPointF()), supportColor);
|
||||||
|
|
||||||
|
QLineF l1(first->toQPointF(), second->toQPointF());
|
||||||
|
QLineF l2(third->toQPointF(), forth->toQPointF());
|
||||||
|
QPointF fPoint;
|
||||||
|
QLineF::IntersectType intersect = l1.intersect(l2, &fPoint);
|
||||||
|
if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
|
||||||
|
{
|
||||||
|
DrawPoint(point, fPoint, mainColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VisToolLineIntersect::setLine1P2Id(const quint32 &value)
|
||||||
|
{
|
||||||
|
line1P2Id = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VisToolLineIntersect::setLine2P1Id(const quint32 &value)
|
||||||
|
{
|
||||||
|
line2P1Id = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VisToolLineIntersect::setLine2P2Id(const quint32 &value)
|
||||||
|
{
|
||||||
|
line2P2Id = value;
|
||||||
|
}
|
59
src/app/visualization/vistoollineintersect.h
Normal file
59
src/app/visualization/vistoollineintersect.h
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vistoollineintersect.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 14 8, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2014 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef VISTOOLLINEINTERSECT_H
|
||||||
|
#define VISTOOLLINEINTERSECT_H
|
||||||
|
|
||||||
|
#include "visline.h"
|
||||||
|
|
||||||
|
class VisToolLineIntersect :public VisLine
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VisToolLineIntersect(const VContainer *data, QGraphicsItem *parent = 0);
|
||||||
|
virtual ~VisToolLineIntersect();
|
||||||
|
|
||||||
|
virtual void RefreshGeometry();
|
||||||
|
|
||||||
|
void setLine1P2Id(const quint32 &value);
|
||||||
|
void setLine2P1Id(const quint32 &value);
|
||||||
|
void setLine2P2Id(const quint32 &value);
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(VisToolLineIntersect)
|
||||||
|
quint32 line1P2Id;
|
||||||
|
quint32 line2P1Id;
|
||||||
|
quint32 line2P2Id;
|
||||||
|
QGraphicsEllipseItem *point;
|
||||||
|
QGraphicsEllipseItem *line1P1;
|
||||||
|
QGraphicsEllipseItem *line1P2;
|
||||||
|
QGraphicsLineItem *line1;
|
||||||
|
QGraphicsEllipseItem *line2P1;
|
||||||
|
QGraphicsEllipseItem *line2P2;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VISTOOLLINEINTERSECT_H
|
|
@ -13,7 +13,8 @@ HEADERS += \
|
||||||
visualization/vistoolheight.h \
|
visualization/vistoolheight.h \
|
||||||
visualization/vistoolpointofintersection.h \
|
visualization/vistoolpointofintersection.h \
|
||||||
visualization/vistooltriangle.h \
|
visualization/vistooltriangle.h \
|
||||||
visualization/vistoolpointofcontact.h
|
visualization/vistoolpointofcontact.h \
|
||||||
|
visualization/vistoollineintersect.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
visualization/vgraphicssimpletextitem.cpp \
|
visualization/vgraphicssimpletextitem.cpp \
|
||||||
|
@ -30,4 +31,5 @@ SOURCES += \
|
||||||
visualization/vistoolheight.cpp \
|
visualization/vistoolheight.cpp \
|
||||||
visualization/vistoolpointofintersection.cpp \
|
visualization/vistoolpointofintersection.cpp \
|
||||||
visualization/vistooltriangle.cpp \
|
visualization/vistooltriangle.cpp \
|
||||||
visualization/vistoolpointofcontact.cpp
|
visualization/vistoolpointofcontact.cpp \
|
||||||
|
visualization/vistoollineintersect.cpp
|
||||||
|
|
Loading…
Reference in New Issue
Block a user