Refactoring.

--HG--
branch : develop
This commit is contained in:
dismine 2014-08-17 21:49:29 +03:00
parent b72f5511b4
commit fcffc03649
18 changed files with 379 additions and 450 deletions

View File

@ -137,30 +137,27 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (type == SceneObject::Point) if (type == SceneObject::Point)
{ {
if (number == 0) switch (number)
{ {
if (ChoosedPoint(id, ui->comboBoxFirstPoint, tr("Select second point of line"))) case 0:
{ if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of line")))
number++; {
line->VisualMode(id); number++;
return; line->VisualMode(id);
} }
} break;
if (number == 1) case 1:
{ if (SetObject(id, ui->comboBoxSecondPoint, ""))
if (ChoosedPoint(id, ui->comboBoxSecondPoint, ""))
{
number = 0;
if (isInitialized == false)
{ {
line->setPoint2Id(id); line->setPoint2Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
prepare = true; prepare = true;
this->setModal(true); this->setModal(true);
this->show(); this->show();
} }
} break;
default:
break;
} }
} }
} }

View File

@ -187,16 +187,18 @@ void DialogArc::SetRadius(const QString &value)
*/ */
void DialogArc::ChosenObject(quint32 id, const SceneObject &type) void DialogArc::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (type == SceneObject::Point) if (prepare == false)// After first choose we ignore all objects
{ {
const VPointF *point = data->GeometricObject<const VPointF *>(id); if (type == SceneObject::Point)
{
ChangeCurrentText(ui->comboBoxBasePoint, point->name()); if (SetObject(id, ui->comboBoxBasePoint, ""))
path->VisualMode(id); {
prepare = true; path->VisualMode(id);
emit ToolTip(""); prepare = true;
this->setModal(true); this->setModal(true);
this->show(); this->show();
}
}
} }
} }

View File

@ -147,49 +147,35 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (type == SceneObject::Point) if (type == SceneObject::Point)
{ {
const VPointF *point = data->GeometricObject<const VPointF *>(id); switch (number)
if (number == 0)
{ {
qint32 index = ui->comboBoxFirstPoint->findText(point->name()); case 0:
if ( index != -1 ) if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of angle")))
{ // -1 for not found {
ui->comboBoxFirstPoint->setCurrentIndex(index); number++;
number++; line->VisualMode(id);
line->VisualMode(id); }
emit ToolTip(tr("Select second point of angle")); break;
return; case 1:
} if (SetObject(id, ui->comboBoxSecondPoint, tr("Select third point of angle")))
} {
if (number == 1) number++;
{ line->setPoint2Id(id);
qint32 index = ui->comboBoxSecondPoint->findText(point->name()); line->RefreshGeometry();
if ( index != -1 ) }
{ // -1 for not found break;
ui->comboBoxSecondPoint->setCurrentIndex(index); case 2:
number++; if (SetObject(id, ui->comboBoxThirdPoint, ""))
line->setPoint2Id(id); {
line->RefreshGeometry(); line->setPoint3Id(id);
emit ToolTip(tr("Select third point of angle")); line->RefreshGeometry();
return; prepare = true;
} this->setModal(true);
} this->show();
if (number == 2) }
{ break;
qint32 index = ui->comboBoxThirdPoint->findText(point->name()); default:
if ( index != -1 ) break;
{ // -1 for not found
ui->comboBoxThirdPoint->setCurrentIndex(index);
number = 0;
line->setPoint3Id(id);
line->RefreshGeometry();
prepare = true;
emit ToolTip("");
}
if (isInitialized == false)
{
this->setModal(true);
this->show();
}
} }
} }
} }

View File

@ -107,15 +107,18 @@ DialogCutArc::~DialogCutArc()
*/ */
void DialogCutArc::ChosenObject(quint32 id, const SceneObject &type) void DialogCutArc::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (type == SceneObject::Arc) if (prepare == false)// After first choose we ignore all objects
{ {
const VArc *arc = data->GeometricObject<const VArc *>(id); if (type == SceneObject::Arc)
ChangeCurrentText(ui->comboBoxArc, arc->name()); {
path->VisualMode(id); if (SetObject(id, ui->comboBoxArc, ""))
prepare = true; {
emit ToolTip(""); path->VisualMode(id);
this->setModal(true); prepare = true;
this->show(); this->setModal(true);
this->show();
}
}
} }
} }

View File

@ -115,13 +115,16 @@ void DialogCutSpline::setSplineId(const quint32 &value)
*/ */
void DialogCutSpline::ChosenObject(quint32 id, const SceneObject &type) void DialogCutSpline::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (type == SceneObject::Spline) if (prepare == false)// After first choose we ignore all objects
{ {
const VSpline *spl = data->GeometricObject<const VSpline *>(id); if (type == SceneObject::Spline)
ChangeCurrentText(ui->comboBoxSpline, spl->name()); {
emit ToolTip(""); if (SetObject(id, ui->comboBoxSpline, ""))
this->setModal(true); {
this->show(); this->setModal(true);
this->show();
}
}
} }
} }

View File

@ -115,13 +115,16 @@ void DialogCutSplinePath::setSplinePathId(const quint32 &value)
*/ */
void DialogCutSplinePath::ChosenObject(quint32 id, const SceneObject &type) void DialogCutSplinePath::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (type == SceneObject::SplinePath) if (prepare == false)// After first choose we ignore all objects
{ {
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(id); if (type == SceneObject::SplinePath)
ChangeCurrentText(ui->comboBoxSplinePath, splPath->name()); {
emit ToolTip(""); if (SetObject(id, ui->comboBoxSplinePath, ""))
this->setModal(true); {
this->show(); this->setModal(true);
this->show();
}
}
} }
} }

View File

@ -140,15 +140,13 @@ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (type == SceneObject::Point) if (type == SceneObject::Point)
{ {
const VPointF *point = data->GeometricObject<const VPointF *>(id); if (SetObject(id, ui->comboBoxBasePoint, ""))
basePointId = id; {
ChangeCurrentText(ui->comboBoxBasePoint, point->name()); basePointId = id;
line->VisualMode(id);
line->VisualMode(id); connect(line, &VisToolEndLine::ToolTip, this, &DialogTool::ShowVisToolTip);
connect(line, &VisToolEndLine::ToolTip, this, &DialogTool::ShowVisToolTip); prepare = true;
}
emit ToolTip("");
prepare = true;
} }
} }
} }

View File

@ -137,39 +137,40 @@ void DialogHeight::setP2LineId(const quint32 &value)
*/ */
void DialogHeight::ChosenObject(quint32 id, const SceneObject &type) void DialogHeight::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (type == SceneObject::Point) if (prepare == false)// After first choose we ignore all objects
{ {
const VPointF *point = data->GeometricObject<const VPointF *>(id); if (type == SceneObject::Point)
switch (number)
{ {
case (0): switch (number)
ChangeCurrentText(ui->comboBoxBasePoint, point->name()); {
number++; case (0):
line->VisualMode(id); if (SetObject(id, ui->comboBoxBasePoint, tr("Select first point of line")))
emit ToolTip(tr("Select first point of line")); {
break; number++;
case (1): line->VisualMode(id);
ChangeCurrentText(ui->comboBoxP1Line, point->name()); }
number++; break;
line->setLineP1Id(id); case (1):
line->RefreshGeometry(); if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line")))
emit ToolTip(tr("Select second point of line")); {
break; number++;
case (2): line->setLineP1Id(id);
ChangeCurrentText(ui->comboBoxP2Line, point->name()); line->RefreshGeometry();
number = 0; }
emit ToolTip(""); break;
line->setLineP2Id(id); case (2):
line->RefreshGeometry(); if (SetObject(id, ui->comboBoxP2Line, ""))
prepare = true; {
if (isInitialized == false) line->setLineP2Id(id);
{ line->RefreshGeometry();
this->setModal(true); prepare = true;
this->show(); this->setModal(true);
} this->show();
break; }
default: break;
break; default:
break;
}
} }
} }
} }

View File

@ -167,34 +167,32 @@ void DialogLine::SaveData()
*/ */
void DialogLine::ChosenObject(quint32 id, const SceneObject &type) void DialogLine::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (type == SceneObject::Point) if (prepare == false)// After first choose we ignore all objects
{ {
const VPointF *point = data->GeometricObject<const VPointF *>(id); if (type == SceneObject::Point)
if (number == 0)
{ {
qint32 index = ui->comboBoxFirstPoint->findText(point->name()); switch (number)
if ( index != -1 ) {
{ // -1 for not found case 0:
line->VisualMode(id); if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point")))
ui->comboBoxFirstPoint->setCurrentIndex(index); {
number++; number++;
emit ToolTip(tr("Select second point")); line->VisualMode(id);
return; }
} break;
} case 1:
if (number == 1) if (SetObject(id, ui->comboBoxSecondPoint, ""))
{ {
qint32 index = ui->comboBoxSecondPoint->findText(point->name()); if (flagError)
if ( index != -1 ) {
{ // -1 for not found number = 0;
ui->comboBoxSecondPoint->setCurrentIndex(index); prepare = true;
if (flagError) DialogAccepted();
{ }
number = 0; }
prepare = true; break;
emit ToolTip(""); default:
DialogAccepted(); break;
}
} }
} }
} }

View File

@ -1,4 +1,4 @@
/************************************************************************ /************************************************************************
** **
** @file dialoglineintersect.cpp ** @file dialoglineintersect.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @author Roman Telezhynskyi <dismine(at)gmail.com>
@ -83,81 +83,65 @@ DialogLineIntersect::~DialogLineIntersect()
*/ */
void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (type == SceneObject::Point) if (prepare == false)// After first choose we ignore all objects
{ {
const VPointF *point = data->GeometricObject<const VPointF *>(id); if (type == SceneObject::Point)
if (number == 0)
{ {
qint32 index = ui->comboBoxP1Line1->findText(point->name()); switch (number)
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1Line1->setCurrentIndex(index);
p1Line1 = id;
number++;
line->VisualMode(id);
emit ToolTip(tr("Select second point of first line"));
return;
}
}
if (number == 1)
{
qint32 index = ui->comboBoxP2Line1->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP2Line1->setCurrentIndex(index);
p2Line1 = id;
number++;
line->setLine1P2Id(p2Line1);
line->RefreshGeometry();
emit ToolTip(tr("Select first point of second line"));
return;
}
}
if (number == 2)
{
qint32 index = ui->comboBoxP1Line2->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1Line2->setCurrentIndex(index);
p1Line2 = id;
number++;
line->setLine2P1Id(p1Line2);
line->RefreshGeometry();
emit ToolTip(tr("Select second point of second line"));
return;
}
}
if (number == 3)
{
qint32 index = ui->comboBoxP2Line2->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP2Line2->setCurrentIndex(index);
p2Line2 = id;
number = 0;
line->setLine2P2Id(p2Line2);
line->RefreshGeometry();
prepare = true;
emit ToolTip("");
}
if (isInitialized == false)
{ {
flagPoint = CheckIntersecion(); case 0:
CheckState(); if (SetObject(id, ui->comboBoxP1Line1, tr("Select second point of first line")))
this->setModal(true); {
this->show(); number++;
connect(ui->comboBoxP1Line1, p1Line1 = id;
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, line->VisualMode(id);
&DialogLineIntersect::P1Line1Changed); }
connect(ui->comboBoxP2Line1, break;
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, case 1:
&DialogLineIntersect::P2Line1Changed); if (SetObject(id, ui->comboBoxP2Line1, tr("Select first point of second line")))
connect(ui->comboBoxP1Line2, {
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, number++;
&DialogLineIntersect::P1Line2Changed); p2Line1 = id;
connect(ui->comboBoxP2Line2, line->setLine1P2Id(id);
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, line->RefreshGeometry();
&DialogLineIntersect::P2Line2Changed); }
break;
case 2:
if (SetObject(id, ui->comboBoxP1Line2, tr("Select second point of second line")))
{
number++;
p1Line2 = id;
line->setLine2P1Id(id);
line->RefreshGeometry();
}
break;
case 3:
if (SetObject(id, ui->comboBoxP2Line2, ""))
{
p2Line2 = id;
line->setLine2P2Id(id);
line->RefreshGeometry();
prepare = true;
flagPoint = CheckIntersecion();
CheckState();
this->setModal(true);
this->show();
connect(ui->comboBoxP1Line1,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::P1Line1Changed);
connect(ui->comboBoxP2Line1,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::P2Line1Changed);
connect(ui->comboBoxP1Line2,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::P1Line2Changed);
connect(ui->comboBoxP2Line2,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::P2Line2Changed);
}
break;
default:
break;
} }
} }
} }

View File

@ -135,29 +135,27 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (type == SceneObject::Point) if (type == SceneObject::Point)
{ {
if (number == 0) switch (number)
{ {
if (ChoosedPoint(id, ui->comboBoxFirstPoint, tr("Select second point of line"))) case 0:
{ if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of line")))
number++;
line->VisualMode(id);
return;
}
}
if (number == 1)
{
if (ChoosedPoint(id, ui->comboBoxSecondPoint, ""))
{
number = 0;
line->setPoint2Id(id);
line->RefreshGeometry();
prepare = true;
if (isInitialized == false)
{ {
number++;
line->VisualMode(id);
}
break;
case 1:
if (SetObject(id, ui->comboBoxSecondPoint, ""))
{
line->setPoint2Id(id);
line->RefreshGeometry();
prepare = true;
this->setModal(true); this->setModal(true);
this->show(); this->show();
} }
} break;
default:
break;
} }
} }
} }

View File

@ -155,50 +155,39 @@ void DialogPointOfContact::DeployFormulaTextEdit()
*/ */
void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type) void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (type == SceneObject::Point) if (prepare == false)// After first choose we ignore all objects
{ {
const VPointF *point = data->GeometricObject<const VPointF *>(id); if (type == SceneObject::Point)
if (number == 0)
{ {
qint32 index = ui->comboBoxFirstPoint->findText(point->name()); switch (number)
if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index);
number++;
line->VisualMode(id);
emit ToolTip(tr("Select second point of line"));
return;
}
}
if (number == 1)
{
qint32 index = ui->comboBoxSecondPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index);
number++;
line->setLineP2Id(id);
line->RefreshGeometry();
emit ToolTip(tr("Select point of center of arc"));
return;
}
}
if (number == 2)
{
qint32 index = ui->comboBoxCenter->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxCenter->setCurrentIndex(index);
number = 0;
line->setRadiusId(id);
line->RefreshGeometry();
prepare = true;
emit ToolTip("");
}
if (isInitialized == false)
{ {
this->setModal(true); case 0:
this->show(); if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of line")))
{
number++;
line->VisualMode(id);
}
break;
case 1:
if (SetObject(id, ui->comboBoxSecondPoint, tr("Select point of center of arc")))
{
number++;
line->setLineP2Id(id);
line->RefreshGeometry();
}
break;
case 2:
if (SetObject(id, ui->comboBoxCenter, ""))
{
line->setRadiusId(id);
line->RefreshGeometry();
prepare = true;
this->setModal(true);
this->show();
}
break;
default:
break;
} }
} }
} }

View File

@ -89,37 +89,31 @@ void DialogPointOfIntersection::setSecondPointId(const quint32 &value)
*/ */
void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type) void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (type == SceneObject::Point) if (prepare == false)// After first choose we ignore all objects
{ {
const VPointF *point = data->GeometricObject<const VPointF *>(id); if (type == SceneObject::Point)
if (number == 0)
{ {
qint32 index = ui->comboBoxFirstPoint->findText(point->name()); switch (number)
if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index);
number++;
line->VisualMode(id);
emit ToolTip(tr("Select point horizontally"));
return;
}
}
if (number == 1)
{
qint32 index = ui->comboBoxSecondPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index);
number = 0;
line->setPoint2Id(id);
line->RefreshGeometry();
prepare = true;
emit ToolTip("");
}
if (isInitialized == false)
{ {
this->setModal(true); case 0:
this->show(); if (SetObject(id, ui->comboBoxFirstPoint, tr("Select point horizontally")))
{
number++;
line->VisualMode(id);
}
break;
case 1:
if (SetObject(id, ui->comboBoxSecondPoint, ""))
{
line->setPoint2Id(id);
line->RefreshGeometry();
prepare = true;
this->setModal(true);
this->show();
}
break;
default:
break;
} }
} }
} }

View File

@ -146,50 +146,35 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (type == SceneObject::Point) if (type == SceneObject::Point)
{ {
const VPointF *point = data->GeometricObject<const VPointF *>(id); switch (number)
if (number == 0)
{ {
qint32 index = ui->comboBoxPShoulder->findText(point->name()); case 0:
if ( index != -1 ) if (SetObject(id, ui->comboBoxPShoulder, tr("Select first point of line")))
{ // -1 for not found {
ui->comboBoxPShoulder->setCurrentIndex(index); number++;
number++; line->VisualMode(id);
line->VisualMode(id); }
emit ToolTip(tr("Select first point of line")); break;
return; case 1:
} if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line")))
} {
if (number == 1) number++;
{ line->setLineP1Id(id);
qint32 index = ui->comboBoxP1Line->findText(point->name()); line->RefreshGeometry();
if ( index != -1 ) }
{ // -1 for not found break;
ui->comboBoxP1Line->setCurrentIndex(index); case 2:
number++; if (SetObject(id, ui->comboBoxP2Line, ""))
line->setLineP1Id(id); {
line->RefreshGeometry(); line->setLineP2Id(id);
emit ToolTip(tr("Select second point of line")); line->RefreshGeometry();
return; prepare = true;
} this->setModal(true);
} this->show();
if (number == 2) }
{ break;
qint32 index = ui->comboBoxP2Line->findText(point->name()); default:
break;
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP2Line->setCurrentIndex(index);
number = 0;
line->setLineP2Id(id);
line->RefreshGeometry();
prepare = true;
emit ToolTip("");
}
if (isInitialized == false)
{
this->setModal(true);
this->show();
}
} }
} }
} }

View File

@ -79,40 +79,42 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (type == SceneObject::Point) if (type == SceneObject::Point)
{ {
const VPointF *point = data->GeometricObject<const VPointF *>(id); switch (number)
if (number == 0)
{ {
qint32 index = ui->comboBoxP1->findText(point->name()); case 0:
if ( index != -1 ) if (SetObject(id, ui->comboBoxP1, tr("Select last point of curve")))
{ // -1 for not found {
ui->comboBoxP1->setCurrentIndex(index); number++;
number++; }
emit ToolTip(tr("Select last point of curve")); break;
return; case 1:
}
}
if (number == 1)
{
qint32 index = ui->comboBoxP4->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP4->setCurrentIndex(index);
number = 0;
emit ToolTip("");
index = ui->comboBoxP1->currentIndex();
quint32 p1Id = qvariant_cast<quint32>(ui->comboBoxP1->itemData(index));
QPointF p1 = data->GeometricObject<const VPointF *>(p1Id)->toQPointF();
QPointF p4 = data->GeometricObject<const VPointF *>(id)->toQPointF();
ui->spinBoxAngle1->setValue(static_cast<qint32>(QLineF(p1, p4).angle()));
ui->spinBoxAngle2->setValue(static_cast<qint32>(QLineF(p4, p1).angle()));
}
if (isInitialized == false)
{ {
this->setModal(true); const VPointF *point = data->GeometricObject<const VPointF *>(id);
this->show(); qint32 index = ui->comboBoxP4->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP4->setCurrentIndex(index);
emit ToolTip("");
index = ui->comboBoxP1->currentIndex();
quint32 p1Id = qvariant_cast<quint32>(ui->comboBoxP1->itemData(index));
QPointF p1 = data->GeometricObject<const VPointF *>(p1Id)->toQPointF();
QPointF p4 = data->GeometricObject<const VPointF *>(id)->toQPointF();
ui->spinBoxAngle1->setValue(static_cast<qint32>(QLineF(p1, p4).angle()));
ui->spinBoxAngle2->setValue(static_cast<qint32>(QLineF(p4, p1).angle()));
this->setModal(true);
this->show();
}
else
{
qWarning()<<"Can't find object by name"<<point->name();
}
break;
} }
default:
break;
} }
} }
} }

View File

@ -322,25 +322,6 @@ void DialogTool::SetupTypeLine(QComboBox *box, const QString &value)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChangeCurrentText select item in combobox by name
* @param box combobox
* @param value name of item
*/
void DialogTool::ChangeCurrentText(QComboBox *box, const QString &value)
{
qint32 index = box->findText(value);
if (index != -1)
{
box->setCurrentIndex(index);
}
else
{
qDebug()<<"Can't find object by name"<<value;
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief ChangeCurrentData select item in combobox by id * @brief ChangeCurrentData select item in combobox by id
@ -579,18 +560,22 @@ quint32 DialogTool::getCurrentObjectId(QComboBox *box) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool DialogTool::ChoosedPoint(const quint32 &id, QComboBox *box, const QString &toolTip) bool DialogTool::SetObject(const quint32 &id, QComboBox *box, const QString &toolTip)
{ {
SCASSERT(box != nullptr); SCASSERT(box != nullptr);
const VPointF *point = data->GeometricObject<const VPointF *>(id); const VGObject *obj = data->GetGObject(id);
SCASSERT(point != nullptr); SCASSERT(obj != nullptr);
const qint32 index = box->findText(point->name()); const qint32 index = box->findText(obj->name());
if ( index != -1 ) if ( index != -1 )
{ // -1 for not found { // -1 for not found
box->setCurrentIndex(index); box->setCurrentIndex(index);
emit ToolTip(toolTip); emit ToolTip(toolTip);
return true; return true;
} }
else
{
qWarning()<<"Can't find object by name"<<obj->name();
}
return false; return false;
} }

View File

@ -213,7 +213,6 @@ protected:
template <class key, class val> template <class key, class val>
void ShowVariable(const QMap<key, val> var); void ShowVariable(const QMap<key, val> var);
void SetupTypeLine(QComboBox *box, const QString &value); void SetupTypeLine(QComboBox *box, const QString &value);
void ChangeCurrentText(QComboBox *box, const QString &value);
void ChangeCurrentData(QComboBox *box, const quint32 &value) const; void ChangeCurrentData(QComboBox *box, const quint32 &value) const;
void PutValHere(QLineEdit *lineEdit, QListWidget *listWidget); void PutValHere(QLineEdit *lineEdit, QListWidget *listWidget);
void PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget); void PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget);
@ -229,7 +228,7 @@ protected:
void setCurrentSplinePathId(QComboBox *box, quint32 &splinePathId, const quint32 &value, void setCurrentSplinePathId(QComboBox *box, quint32 &splinePathId, const quint32 &value,
ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const; ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const;
quint32 getCurrentObjectId(QComboBox *box) const; quint32 getCurrentObjectId(QComboBox *box) const;
bool ChoosedPoint(const quint32 &id, QComboBox *box, const QString &toolTip); bool SetObject(const quint32 &id, QComboBox *box, const QString &toolTip);
void DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight); void DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight);
template <typename T> template <typename T>
void InitArrow(T *ui) void InitArrow(T *ui)

View File

@ -83,46 +83,48 @@ DialogTriangle::~DialogTriangle()
*/ */
void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type) void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (type == SceneObject::Point) if (prepare == false)// After first choose we ignore all objects
{ {
const VPointF *point = data->GeometricObject<const VPointF *>(id); if (type == SceneObject::Point)
switch (number)
{ {
case (0): switch (number)
ChangeCurrentText(ui->comboBoxAxisP1, point->name()); {
number++; case (0):
line->VisualMode(id); if (SetObject(id, ui->comboBoxAxisP1, tr("Select second point of axis")))
emit ToolTip(tr("Select second point of axis")); {
break; number++;
case (1): line->VisualMode(id);
ChangeCurrentText(ui->comboBoxAxisP2, point->name()); }
number++; break;
line->setPoint2Id(id); case (1):
line->RefreshGeometry(); if (SetObject(id, ui->comboBoxAxisP2, tr("Select first point")))
emit ToolTip(tr("Select first point")); {
break; number++;
case (2): line->setPoint2Id(id);
ChangeCurrentText(ui->comboBoxFirstPoint, point->name()); line->RefreshGeometry();
number++; }
line->setHypotenuseP1Id(id); break;
line->RefreshGeometry(); case (2):
emit ToolTip(tr("Select second point")); if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point")))
break; {
case (3): number++;
ChangeCurrentText(ui->comboBoxSecondPoint, point->name()); line->setHypotenuseP1Id(id);
number = 0; line->RefreshGeometry();
line->setHypotenuseP2Id(id); }
line->RefreshGeometry(); break;
prepare = true; case (3):
emit ToolTip(tr("")); if (SetObject(id, ui->comboBoxSecondPoint, ""))
if (isInitialized == false) {
{ line->setHypotenuseP2Id(id);
this->setModal(true); line->RefreshGeometry();
this->show(); prepare = true;
} this->setModal(true);
break; this->show();
default: }
break; break;
default:
break;
}
} }
} }
} }