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++; number++;
line->VisualMode(id); line->VisualMode(id);
return;
} }
} 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

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

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) {
case 0:
if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of angle")))
{ {
qint32 index = ui->comboBoxFirstPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
line->VisualMode(id); line->VisualMode(id);
emit ToolTip(tr("Select second point of angle"));
return;
} }
} break;
if (number == 1) case 1:
if (SetObject(id, ui->comboBoxSecondPoint, tr("Select third point of angle")))
{ {
qint32 index = ui->comboBoxSecondPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index);
number++; number++;
line->setPoint2Id(id); line->setPoint2Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
emit ToolTip(tr("Select third point of angle"));
return;
} }
} break;
if (number == 2) case 2:
if (SetObject(id, ui->comboBoxThirdPoint, ""))
{ {
qint32 index = ui->comboBoxThirdPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxThirdPoint->setCurrentIndex(index);
number = 0;
line->setPoint3Id(id); line->setPoint3Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
prepare = true; prepare = true;
emit ToolTip("");
}
if (isInitialized == false)
{
this->setModal(true); this->setModal(true);
this->show(); this->show();
} }
break;
default:
break;
} }
} }
} }

View File

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

View File

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

View File

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

View File

@ -140,18 +140,16 @@ 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; basePointId = id;
ChangeCurrentText(ui->comboBoxBasePoint, point->name());
line->VisualMode(id); line->VisualMode(id);
connect(line, &VisToolEndLine::ToolTip, this, &DialogTool::ShowVisToolTip); connect(line, &VisToolEndLine::ToolTip, this, &DialogTool::ShowVisToolTip);
emit ToolTip("");
prepare = true; prepare = true;
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**

View File

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

View File

@ -166,36 +166,34 @@ void DialogLine::SaveData()
* @param type type of object * @param type type of object
*/ */
void DialogLine::ChosenObject(quint32 id, const SceneObject &type) void DialogLine::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false)// After first choose we ignore all objects
{ {
if (type == SceneObject::Point) if (type == SceneObject::Point)
{ {
const VPointF *point = data->GeometricObject<const VPointF *>(id); switch (number)
if (number == 0) {
case 0:
if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point")))
{ {
qint32 index = ui->comboBoxFirstPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
line->VisualMode(id);
ui->comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select second point")); line->VisualMode(id);
return;
} }
} break;
if (number == 1) case 1:
if (SetObject(id, ui->comboBoxSecondPoint, ""))
{ {
qint32 index = ui->comboBoxSecondPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index);
if (flagError) if (flagError)
{ {
number = 0; number = 0;
prepare = true; prepare = true;
emit ToolTip("");
DialogAccepted(); DialogAccepted();
} }
} }
break;
default:
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>
@ -82,66 +82,46 @@ DialogLineIntersect::~DialogLineIntersect()
* @param type type of object * @param type type of object
*/ */
void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false)// After first choose we ignore all objects
{ {
if (type == SceneObject::Point) if (type == SceneObject::Point)
{ {
const VPointF *point = data->GeometricObject<const VPointF *>(id); switch (number)
if (number == 0)
{ {
qint32 index = ui->comboBoxP1Line1->findText(point->name()); case 0:
if ( index != -1 ) if (SetObject(id, ui->comboBoxP1Line1, tr("Select second point of first line")))
{ // -1 for not found {
ui->comboBoxP1Line1->setCurrentIndex(index); number++;
p1Line1 = id; p1Line1 = id;
number++;
line->VisualMode(id); line->VisualMode(id);
emit ToolTip(tr("Select second point of first line"));
return;
} }
} break;
if (number == 1) case 1:
if (SetObject(id, ui->comboBoxP2Line1, tr("Select first point of second line")))
{ {
qint32 index = ui->comboBoxP2Line1->findText(point->name()); number++;
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP2Line1->setCurrentIndex(index);
p2Line1 = id; p2Line1 = id;
number++; line->setLine1P2Id(id);
line->setLine1P2Id(p2Line1);
line->RefreshGeometry(); line->RefreshGeometry();
emit ToolTip(tr("Select first point of second line"));
return;
} }
} break;
if (number == 2) case 2:
if (SetObject(id, ui->comboBoxP1Line2, tr("Select second point of second line")))
{ {
qint32 index = ui->comboBoxP1Line2->findText(point->name()); number++;
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1Line2->setCurrentIndex(index);
p1Line2 = id; p1Line2 = id;
number++; line->setLine2P1Id(id);
line->setLine2P1Id(p1Line2);
line->RefreshGeometry(); line->RefreshGeometry();
emit ToolTip(tr("Select second point of second line"));
return;
} }
} break;
if (number == 3) case 3:
if (SetObject(id, ui->comboBoxP2Line2, ""))
{ {
qint32 index = ui->comboBoxP2Line2->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP2Line2->setCurrentIndex(index);
p2Line2 = id; p2Line2 = id;
number = 0; line->setLine2P2Id(id);
line->setLine2P2Id(p2Line2);
line->RefreshGeometry(); line->RefreshGeometry();
prepare = true; prepare = true;
emit ToolTip("");
}
if (isInitialized == false)
{
flagPoint = CheckIntersecion(); flagPoint = CheckIntersecion();
CheckState(); CheckState();
this->setModal(true); this->setModal(true);
@ -159,6 +139,10 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::P2Line2Changed); &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++; number++;
line->VisualMode(id); line->VisualMode(id);
return;
} }
} break;
if (number == 1) case 1:
if (SetObject(id, ui->comboBoxSecondPoint, ""))
{ {
if (ChoosedPoint(id, ui->comboBoxSecondPoint, ""))
{
number = 0;
line->setPoint2Id(id); line->setPoint2Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
prepare = true; prepare = true;
if (isInitialized == false)
{
this->setModal(true); this->setModal(true);
this->show(); this->show();
} }
} break;
default:
break;
} }
} }
} }

View File

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

View File

@ -88,39 +88,33 @@ void DialogPointOfIntersection::setSecondPointId(const quint32 &value)
* @param type type of object * @param type type of object
*/ */
void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type) void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false)// After first choose we ignore all objects
{ {
if (type == SceneObject::Point) if (type == SceneObject::Point)
{ {
const VPointF *point = data->GeometricObject<const VPointF *>(id); switch (number)
if (number == 0) {
case 0:
if (SetObject(id, ui->comboBoxFirstPoint, tr("Select point horizontally")))
{ {
qint32 index = ui->comboBoxFirstPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
line->VisualMode(id); line->VisualMode(id);
emit ToolTip(tr("Select point horizontally"));
return;
} }
} break;
if (number == 1) case 1:
if (SetObject(id, ui->comboBoxSecondPoint, ""))
{ {
qint32 index = ui->comboBoxSecondPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index);
number = 0;
line->setPoint2Id(id); line->setPoint2Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
prepare = true; prepare = true;
emit ToolTip("");
}
if (isInitialized == false)
{
this->setModal(true); this->setModal(true);
this->show(); 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) {
case 0:
if (SetObject(id, ui->comboBoxPShoulder, tr("Select first point of line")))
{ {
qint32 index = ui->comboBoxPShoulder->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxPShoulder->setCurrentIndex(index);
number++; number++;
line->VisualMode(id); line->VisualMode(id);
emit ToolTip(tr("Select first point of line"));
return;
} }
} break;
if (number == 1) case 1:
if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line")))
{ {
qint32 index = ui->comboBoxP1Line->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1Line->setCurrentIndex(index);
number++; number++;
line->setLineP1Id(id); line->setLineP1Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
emit ToolTip(tr("Select second point of line"));
return;
} }
} break;
if (number == 2) case 2:
if (SetObject(id, ui->comboBoxP2Line, ""))
{ {
qint32 index = ui->comboBoxP2Line->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP2Line->setCurrentIndex(index);
number = 0;
line->setLineP2Id(id); line->setLineP2Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
prepare = true; prepare = true;
emit ToolTip("");
}
if (isInitialized == false)
{
this->setModal(true); this->setModal(true);
this->show(); this->show();
} }
break;
default:
break;
} }
} }
} }

View File

@ -79,25 +79,21 @@ 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) {
case 0:
if (SetObject(id, ui->comboBoxP1, tr("Select last point of curve")))
{ {
qint32 index = ui->comboBoxP1->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select last point of curve"));
return;
} }
} break;
if (number == 1) case 1:
{ {
const VPointF *point = data->GeometricObject<const VPointF *>(id);
qint32 index = ui->comboBoxP4->findText(point->name()); qint32 index = ui->comboBoxP4->findText(point->name());
if ( index != -1 ) if ( index != -1 )
{ // -1 for not found { // -1 for not found
ui->comboBoxP4->setCurrentIndex(index); ui->comboBoxP4->setCurrentIndex(index);
number = 0;
emit ToolTip(""); emit ToolTip("");
index = ui->comboBoxP1->currentIndex(); index = ui->comboBoxP1->currentIndex();
quint32 p1Id = qvariant_cast<quint32>(ui->comboBoxP1->itemData(index)); quint32 p1Id = qvariant_cast<quint32>(ui->comboBoxP1->itemData(index));
@ -107,12 +103,18 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type)
ui->spinBoxAngle1->setValue(static_cast<qint32>(QLineF(p1, p4).angle())); ui->spinBoxAngle1->setValue(static_cast<qint32>(QLineF(p1, p4).angle()));
ui->spinBoxAngle2->setValue(static_cast<qint32>(QLineF(p4, p1).angle())); ui->spinBoxAngle2->setValue(static_cast<qint32>(QLineF(p4, p1).angle()));
}
if (isInitialized == false)
{
this->setModal(true); this->setModal(true);
this->show(); 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

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