Visualization for VToolPointOfIntersection.

--HG--
branch : develop
This commit is contained in:
dismine 2014-08-13 14:31:01 +03:00
parent 8d1b68d448
commit 16fa925021
7 changed files with 66 additions and 19 deletions

View File

@ -31,6 +31,8 @@
#include "../../geometry/vpointf.h"
#include "../../container/vcontainer.h"
#include "../../visualization/vistoolpointofintersection.h"
#include "../../widgets/vmaingraphicsscene.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -40,7 +42,7 @@
*/
DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection), number(0), pointName(QString()),
firstPointId(0), secondPointId(0)
firstPointId(0), secondPointId(0), line(nullptr)
{
ui->setupUi(this);
labelEditNamePoint = ui->labelEditNamePoint;
@ -57,11 +59,14 @@ DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, con
this, &DialogPointOfIntersection::PointNameChanged);
connect(ui->comboBoxSecondPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogPointOfIntersection::PointNameChanged);
line = new VisToolPointOfIntersection(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogPointOfIntersection::~DialogPointOfIntersection()
{
delete line;
delete ui;
}
@ -73,6 +78,7 @@ DialogPointOfIntersection::~DialogPointOfIntersection()
void DialogPointOfIntersection::setSecondPointId(const quint32 &value)
{
setPointId(ui->comboBoxSecondPoint, secondPointId, value);
line->setPoint2Id(secondPointId);
}
//---------------------------------------------------------------------------------------------------------------------
@ -93,6 +99,7 @@ void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index);
number++;
line->VisualMode(id);
emit ToolTip(tr("Select point horizontally"));
return;
}
@ -104,6 +111,9 @@ void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index);
number = 0;
line->setPoint2Id(id);
line->RefreshGeometry();
prepare = true;
emit ToolTip("");
}
if (isInitialized == false)
@ -121,6 +131,10 @@ void DialogPointOfIntersection::SaveData()
pointName = ui->lineEditNamePoint->text();
firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint);
secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint);
line->setPoint1Id(firstPointId);
line->setPoint2Id(secondPointId);
line->RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
@ -151,6 +165,18 @@ void DialogPointOfIntersection::UpdateList()
*/
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersection::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor);
scene->addItem(line);
line->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setFirstPointId set id of first point
@ -159,6 +185,7 @@ void DialogPointOfIntersection::UpdateList()
void DialogPointOfIntersection::setFirstPointId(const quint32 &value)
{
setPointId(ui->comboBoxFirstPoint, firstPointId, value);
line->setPoint1Id(firstPointId);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -36,6 +36,8 @@ namespace Ui
class DialogPointOfIntersection;
}
class VisToolPointOfIntersection;
/**
* @brief The DialogPointOfIntersection class dialog for ToolPointOfIntersection. Help create point and edit option.
*/
@ -59,6 +61,7 @@ public slots:
virtual void PointNameChanged();
virtual void UpdateList();
protected:
virtual void ShowVisualization();
/**
* @brief SaveData Put dialog data in local variables
*/
@ -80,6 +83,7 @@ private:
/** @brief secondPointId id second point of line */
quint32 secondPointId;
VisToolPointOfIntersection *line;
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -591,9 +591,11 @@ void MainWindow::ToolTriangle(bool checked)
*/
void MainWindow::ToolPointOfIntersection(bool checked)
{
SetToolButton<DialogPointOfIntersection>(checked, Tool::PointOfIntersection,
":/cursor/pointofintersect_cursor.png", tr("Select point vertically"),
&MainWindow::ClosedDialog<VToolPointOfIntersection>);
SetToolButtonWithApply<DialogPointOfIntersection>(checked, Tool::PointOfIntersection,
":/cursor/pointofintersect_cursor.png",
tr("Select point vertically"),
&MainWindow::ClosedDialogWithApply<VToolPointOfIntersection>,
&MainWindow::ApplyDialog<VToolPointOfIntersection>);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -81,8 +81,9 @@ void VToolPointOfIntersection::setDialog()
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @return the created tool
*/
void VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VToolPointOfIntersection *VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data)
{
SCASSERT(dialog != nullptr);
@ -91,7 +92,14 @@ void VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *sc
const quint32 firstPointId = dialogTool->getFirstPointId();
const quint32 secondPointId = dialogTool->getSecondPointId();
const QString pointName = dialogTool->getPointName();
Create(0, pointName, firstPointId, secondPointId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
VToolPointOfIntersection *point = nullptr;
point = Create(0, pointName, firstPointId, secondPointId, 5, 10, scene, doc, data, Document::FullParse,
Source::FromGui);
if (point != nullptr)
{
point->dialog=dialogTool;
}
return point;
}
//---------------------------------------------------------------------------------------------------------------------
@ -108,11 +116,13 @@ void VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *sc
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
* @return the created tool
*/
void VToolPointOfIntersection::Create(const quint32 _id, const QString &pointName, const quint32 &firstPointId,
const quint32 &secondPointId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
VToolPointOfIntersection *VToolPointOfIntersection::Create(const quint32 _id, const QString &pointName,
const quint32 &firstPointId, const quint32 &secondPointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation)
{
const VPointF *firstPoint = data->GeometricObject<const VPointF *>(firstPointId);
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(secondPointId);
@ -143,7 +153,9 @@ void VToolPointOfIntersection::Create(const quint32 _id, const QString &pointNam
doc->AddTool(id, point);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
return point;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -42,11 +42,12 @@ public:
const quint32 &secondPointId, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual void setDialog();
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static void Create(const quint32 _id, const QString &pointName, const quint32 &firstPointId,
const quint32 &secondPointId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static VToolPointOfIntersection *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data);
static VToolPointOfIntersection *Create(const quint32 _id, const QString &pointName, const quint32 &firstPointId,
const quint32 &secondPointId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static const QString ToolType;
public slots:
virtual void FullUpdateFromFile();

View File

@ -125,6 +125,7 @@ QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Li
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @return the created tool
*/
VToolShoulderPoint* VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data)
@ -165,6 +166,7 @@ VToolShoulderPoint* VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphics
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
* @return the created tool
*/
VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formula, const quint32 &p1Line,
const quint32 &p2Line, const quint32 &pShoulder, const QString &typeLine,

View File

@ -59,7 +59,6 @@ void VisToolPointOfIntersection::RefreshGeometry()
QLineF axisL2;
if (point2Id <= 0)
{
DrawPoint(axisP2, scenePos, supportColor);
axisL2 = Axis(scenePos, 180);
}
else
@ -67,9 +66,9 @@ void VisToolPointOfIntersection::RefreshGeometry()
const VPointF *second = data->GeometricObject<const VPointF *>(point2Id);
DrawPoint(axisP2, second->toQPointF(), supportColor);
axisL2 = Axis(second->toQPointF(), 180);
ShowIntersection(axisL1, axisL2);
}
DrawLine(axis2, axisL2, supportColor, Qt::DashLine);
ShowIntersection(axisL1, axisL2);
}
}
@ -99,6 +98,6 @@ void VisToolPointOfIntersection::ShowIntersection(const QLineF &axis1, const QLi
}
else
{
point->setVisible(true);
point->setVisible(false);
}
}